Babylon.js 1.3 MB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. var __decorate=this&&this.__decorate||function(e,t,i,r){var n,o=arguments.length,s=3>o?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,i,r);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(s=(3>o?n(s):o>3?n(t,i,s):n(t,i))||s);return o>3&&s&&Object.defineProperty(t,i,s),s},__extends=this&&this.__extends||function(e,t){function i(){this.constructor=e}for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r]);i.prototype=t.prototype,e.prototype=new i},BABYLON;!function(e){e.ToGammaSpace=1/2.2,e.ToLinearSpace=2.2,e.Epsilon=.001;var t=function(){function e(){}return e.WithinEpsilon=function(e,t,i){void 0===i&&(i=1.401298e-45);var r=e-t;return r>=-i&&i>=r},e.ToHex=function(e){var t=e.toString(16);return 15>=e?("0"+t).toUpperCase():t.toUpperCase()},e.Sign=function(e){return e=+e,0===e||isNaN(e)?e:e>0?1:-1},e.Clamp=function(e,t,i){return void 0===t&&(t=0),void 0===i&&(i=1),Math.min(i,Math.max(t,e))},e}();e.MathTools=t;var i=function(){function i(e,t,i){void 0===e&&(e=0),void 0===t&&(t=0),void 0===i&&(i=0),this.r=e,this.g=t,this.b=i}return i.prototype.toString=function(){return"{R: "+this.r+" G:"+this.g+" B:"+this.b+"}"},i.prototype.getClassName=function(){return"Color3"},i.prototype.getHashCode=function(){var e=this.r||0;return e=397*e^(this.g||0),e=397*e^(this.b||0)},i.prototype.toArray=function(e,t){return void 0===t&&(t=0),e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,this},i.prototype.toColor4=function(e){return void 0===e&&(e=1),new r(this.r,this.g,this.b,e)},i.prototype.asArray=function(){var e=[];return this.toArray(e,0),e},i.prototype.toLuminance=function(){return.3*this.r+.59*this.g+.11*this.b},i.prototype.multiply=function(e){return new i(this.r*e.r,this.g*e.g,this.b*e.b)},i.prototype.multiplyToRef=function(e,t){return t.r=this.r*e.r,t.g=this.g*e.g,t.b=this.b*e.b,this},i.prototype.equals=function(e){return e&&this.r===e.r&&this.g===e.g&&this.b===e.b},i.prototype.equalsFloats=function(e,t,i){return this.r===e&&this.g===t&&this.b===i},i.prototype.scale=function(e){return new i(this.r*e,this.g*e,this.b*e)},i.prototype.scaleToRef=function(e,t){return t.r=this.r*e,t.g=this.g*e,t.b=this.b*e,this},i.prototype.add=function(e){return new i(this.r+e.r,this.g+e.g,this.b+e.b)},i.prototype.addToRef=function(e,t){return t.r=this.r+e.r,t.g=this.g+e.g,t.b=this.b+e.b,this},i.prototype.subtract=function(e){return new i(this.r-e.r,this.g-e.g,this.b-e.b)},i.prototype.subtractToRef=function(e,t){return t.r=this.r-e.r,t.g=this.g-e.g,t.b=this.b-e.b,this},i.prototype.clone=function(){return new i(this.r,this.g,this.b)},i.prototype.copyFrom=function(e){return this.r=e.r,this.g=e.g,this.b=e.b,this},i.prototype.copyFromFloats=function(e,t,i){return this.r=e,this.g=t,this.b=i,this},i.prototype.toHexString=function(){var e=255*this.r|0,i=255*this.g|0,r=255*this.b|0;return"#"+t.ToHex(e)+t.ToHex(i)+t.ToHex(r)},i.prototype.toLinearSpace=function(){var e=new i;return this.toLinearSpaceToRef(e),e},i.prototype.toLinearSpaceToRef=function(t){return t.r=Math.pow(this.r,e.ToLinearSpace),t.g=Math.pow(this.g,e.ToLinearSpace),t.b=Math.pow(this.b,e.ToLinearSpace),this},i.prototype.toGammaSpace=function(){var e=new i;return this.toGammaSpaceToRef(e),e},i.prototype.toGammaSpaceToRef=function(t){return t.r=Math.pow(this.r,e.ToGammaSpace),t.g=Math.pow(this.g,e.ToGammaSpace),t.b=Math.pow(this.b,e.ToGammaSpace),this},i.FromHexString=function(e){if("#"!==e.substring(0,1)||7!==e.length)return new i(0,0,0);var t=parseInt(e.substring(1,3),16),r=parseInt(e.substring(3,5),16),n=parseInt(e.substring(5,7),16);return i.FromInts(t,r,n)},i.FromArray=function(e,t){return void 0===t&&(t=0),new i(e[t],e[t+1],e[t+2])},i.FromInts=function(e,t,r){return new i(e/255,t/255,r/255)},i.Lerp=function(e,t,r){var n=e.r+(t.r-e.r)*r,o=e.g+(t.g-e.g)*r,s=e.b+(t.b-e.b)*r;return new i(n,o,s)},i.Red=function(){return new i(1,0,0)},i.Green=function(){return new i(0,1,0)},i.Blue=function(){return new i(0,0,1)},i.Black=function(){return new i(0,0,0)},i.White=function(){return new i(1,1,1)},i.Purple=function(){return new i(.5,0,.5)},i.Magenta=function(){return new i(1,0,1)},i.Yellow=function(){return new i(1,1,0)},i.Gray=function(){return new i(.5,.5,.5)},i}();e.Color3=i;var r=function(){function e(e,t,i,r){this.r=e,this.g=t,this.b=i,this.a=r}return e.prototype.addInPlace=function(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this.a+=e.a,this},e.prototype.asArray=function(){var e=[];return this.toArray(e,0),e},e.prototype.toArray=function(e,t){return void 0===t&&(t=0),e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e[t+3]=this.a,this},e.prototype.add=function(t){return new e(this.r+t.r,this.g+t.g,this.b+t.b,this.a+t.a)},e.prototype.subtract=function(t){return new e(this.r-t.r,this.g-t.g,this.b-t.b,this.a-t.a)},e.prototype.subtractToRef=function(e,t){return t.r=this.r-e.r,t.g=this.g-e.g,t.b=this.b-e.b,t.a=this.a-e.a,this},e.prototype.scale=function(t){return new e(this.r*t,this.g*t,this.b*t,this.a*t)},e.prototype.scaleToRef=function(e,t){return t.r=this.r*e,t.g=this.g*e,t.b=this.b*e,t.a=this.a*e,this},e.prototype.multiply=function(t){return new e(this.r*t.r,this.g*t.g,this.b*t.b,this.a*t.a)},e.prototype.multiplyToRef=function(e,t){return t.r=this.r*e.r,t.g=this.g*e.g,t.b=this.b*e.b,t.a=this.a*e.a,t},e.prototype.toString=function(){return"{R: "+this.r+" G:"+this.g+" B:"+this.b+" A:"+this.a+"}"},e.prototype.getClassName=function(){return"Color4"},e.prototype.getHashCode=function(){var e=this.r||0;return e=397*e^(this.g||0),e=397*e^(this.b||0),e=397*e^(this.a||0)},e.prototype.clone=function(){return new e(this.r,this.g,this.b,this.a)},e.prototype.copyFrom=function(e){return this.r=e.r,this.g=e.g,this.b=e.b,this.a=e.a,this},e.prototype.toHexString=function(){var e=255*this.r|0,i=255*this.g|0,r=255*this.b|0,n=255*this.a|0;return"#"+t.ToHex(e)+t.ToHex(i)+t.ToHex(r)+t.ToHex(n)},e.FromHexString=function(t){if("#"!==t.substring(0,1)||9!==t.length)return new e(0,0,0,0);var i=parseInt(t.substring(1,3),16),r=parseInt(t.substring(3,5),16),n=parseInt(t.substring(5,7),16),o=parseInt(t.substring(7,9),16);return e.FromInts(i,r,n,o)},e.Lerp=function(t,i,r){var n=new e(0,0,0,0);return e.LerpToRef(t,i,r,n),n},e.LerpToRef=function(e,t,i,r){r.r=e.r+(t.r-e.r)*i,r.g=e.g+(t.g-e.g)*i,r.b=e.b+(t.b-e.b)*i,r.a=e.a+(t.a-e.a)*i},e.FromArray=function(t,i){return void 0===i&&(i=0),new e(t[i],t[i+1],t[i+2],t[i+3])},e.FromInts=function(t,i,r,n){return new e(t/255,i/255,r/255,n/255)},e.CheckColors4=function(e,t){if(e.length===3*t){for(var i=[],r=0;r<e.length;r+=3){var n=r/3*4;i[n]=e[r],i[n+1]=e[r+1],i[n+2]=e[r+2],i[n+3]=1}return i}return e},e}();e.Color4=r;var n=function(){function i(e,t){this.x=e,this.y=t}return i.prototype.toString=function(){return"{X: "+this.x+" Y:"+this.y+"}"},i.prototype.getClassName=function(){return"Vector2"},i.prototype.getHashCode=function(){var e=this.x||0;return e=397*e^(this.y||0)},i.prototype.toArray=function(e,t){return void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,this},i.prototype.asArray=function(){var e=[];return this.toArray(e,0),e},i.prototype.copyFrom=function(e){return this.x=e.x,this.y=e.y,this},i.prototype.copyFromFloats=function(e,t){return this.x=e,this.y=t,this},i.prototype.add=function(e){return new i(this.x+e.x,this.y+e.y)},i.prototype.addToRef=function(e,t){return t.x=this.x+e.x,t.y=this.y+e.y,this},i.prototype.addVector3=function(e){return new i(this.x+e.x,this.y+e.y)},i.prototype.subtract=function(e){return new i(this.x-e.x,this.y-e.y)},i.prototype.subtractToRef=function(e,t){return t.x=this.x-e.x,t.y=this.y-e.y,this},i.prototype.subtractInPlace=function(e){return this.x-=e.x,this.y-=e.y,this},i.prototype.multiplyInPlace=function(e){return this.x*=e.x,this.y*=e.y,this},i.prototype.multiply=function(e){return new i(this.x*e.x,this.y*e.y)},i.prototype.multiplyToRef=function(e,t){return t.x=this.x*e.x,t.y=this.y*e.y,this},i.prototype.multiplyByFloats=function(e,t){return new i(this.x*e,this.y*t)},i.prototype.divide=function(e){return new i(this.x/e.x,this.y/e.y)},i.prototype.divideToRef=function(e,t){return t.x=this.x/e.x,t.y=this.y/e.y,this},i.prototype.negate=function(){return new i(-this.x,-this.y)},i.prototype.scaleInPlace=function(e){return this.x*=e,this.y*=e,this},i.prototype.scale=function(e){return new i(this.x*e,this.y*e)},i.prototype.equals=function(e){return e&&this.x===e.x&&this.y===e.y},i.prototype.equalsWithEpsilon=function(i,r){return void 0===r&&(r=e.Epsilon),i&&t.WithinEpsilon(this.x,i.x,r)&&t.WithinEpsilon(this.y,i.y,r)},i.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y)},i.prototype.lengthSquared=function(){return this.x*this.x+this.y*this.y},i.prototype.normalize=function(){var e=this.length();if(0===e)return this;var t=1/e;return this.x*=t,this.y*=t,this},i.prototype.clone=function(){return new i(this.x,this.y)},i.Zero=function(){return new i(0,0)},i.FromArray=function(e,t){return void 0===t&&(t=0),new i(e[t],e[t+1])},i.FromArrayToRef=function(e,t,i){i.x=e[t],i.y=e[t+1]},i.CatmullRom=function(e,t,r,n,o){var s=o*o,a=o*s,h=.5*(2*t.x+(-e.x+r.x)*o+(2*e.x-5*t.x+4*r.x-n.x)*s+(-e.x+3*t.x-3*r.x+n.x)*a),c=.5*(2*t.y+(-e.y+r.y)*o+(2*e.y-5*t.y+4*r.y-n.y)*s+(-e.y+3*t.y-3*r.y+n.y)*a);return new i(h,c)},i.Clamp=function(e,t,r){var n=e.x;n=n>r.x?r.x:n,n=n<t.x?t.x:n;var o=e.y;return o=o>r.y?r.y:o,o=o<t.y?t.y:o,new i(n,o)},i.Hermite=function(e,t,r,n,o){var s=o*o,a=o*s,h=2*a-3*s+1,c=-2*a+3*s,l=a-2*s+o,u=a-s,f=e.x*h+r.x*c+t.x*l+n.x*u,d=e.y*h+r.y*c+t.y*l+n.y*u;return new i(f,d)},i.Lerp=function(e,t,r){var n=e.x+(t.x-e.x)*r,o=e.y+(t.y-e.y)*r;return new i(n,o)},i.Dot=function(e,t){return e.x*t.x+e.y*t.y},i.Normalize=function(e){var t=e.clone();return t.normalize(),t},i.Minimize=function(e,t){var r=e.x<t.x?e.x:t.x,n=e.y<t.y?e.y:t.y;return new i(r,n)},i.Maximize=function(e,t){var r=e.x>t.x?e.x:t.x,n=e.y>t.y?e.y:t.y;return new i(r,n)},i.Transform=function(e,t){var r=i.Zero();return i.TransformToRef(e,t,r),r},i.TransformToRef=function(e,t,i){var r=e.x*t.m[0]+e.y*t.m[4]+t.m[12],n=e.x*t.m[1]+e.y*t.m[5]+t.m[13];i.x=r,i.y=n},i.PointInTriangle=function(e,t,i,r){var n=.5*(-i.y*r.x+t.y*(-i.x+r.x)+t.x*(i.y-r.y)+i.x*r.y),o=0>n?-1:1,s=(t.y*r.x-t.x*r.y+(r.y-t.y)*e.x+(t.x-r.x)*e.y)*o,a=(t.x*i.y-t.y*i.x+(t.y-i.y)*e.x+(i.x-t.x)*e.y)*o;return s>0&&a>0&&2*n*o>s+a},i.Distance=function(e,t){return Math.sqrt(i.DistanceSquared(e,t))},i.DistanceSquared=function(e,t){var i=e.x-t.x,r=e.y-t.y;return i*i+r*r},i.DistanceOfPointFromSegment=function(e,t,r){var n=i.DistanceSquared(t,r);if(0===n)return i.Distance(e,t);var o=r.subtract(t),s=Math.max(0,Math.min(1,i.Dot(e.subtract(t),o)/n)),a=t.add(o.multiplyByFloats(s,s));return i.Distance(e,a)},i}();e.Vector2=n;var o=function(){function i(e,t,i){this.x=e,this.y=t,this.z=i}return i.prototype.toString=function(){return"{X: "+this.x+" Y:"+this.y+" Z:"+this.z+"}"},i.prototype.getClassName=function(){return"Vector3"},i.prototype.getHashCode=function(){var e=this.x||0;return e=397*e^(this.y||0),e=397*e^(this.z||0)},i.prototype.asArray=function(){var e=[];return this.toArray(e,0),e},i.prototype.toArray=function(e,t){return void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,this},i.prototype.toQuaternion=function(){var e=new h(0,0,0,1),t=Math.cos(.5*(this.x+this.z)),i=Math.sin(.5*(this.x+this.z)),r=Math.cos(.5*(this.z-this.x)),n=Math.sin(.5*(this.z-this.x)),o=Math.cos(.5*this.y),s=Math.sin(.5*this.y);return e.x=r*s,e.y=-n*s,e.z=i*o,e.w=t*o,e},i.prototype.addInPlace=function(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this},i.prototype.add=function(e){return new i(this.x+e.x,this.y+e.y,this.z+e.z)},i.prototype.addToRef=function(e,t){return t.x=this.x+e.x,t.y=this.y+e.y,t.z=this.z+e.z,this},i.prototype.subtractInPlace=function(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this},i.prototype.subtract=function(e){return new i(this.x-e.x,this.y-e.y,this.z-e.z)},i.prototype.subtractToRef=function(e,t){return t.x=this.x-e.x,t.y=this.y-e.y,t.z=this.z-e.z,this},i.prototype.subtractFromFloats=function(e,t,r){return new i(this.x-e,this.y-t,this.z-r)},i.prototype.subtractFromFloatsToRef=function(e,t,i,r){return r.x=this.x-e,r.y=this.y-t,r.z=this.z-i,this},i.prototype.negate=function(){return new i(-this.x,-this.y,-this.z)},i.prototype.scaleInPlace=function(e){return this.x*=e,this.y*=e,this.z*=e,this},i.prototype.scale=function(e){return new i(this.x*e,this.y*e,this.z*e)},i.prototype.scaleToRef=function(e,t){t.x=this.x*e,t.y=this.y*e,t.z=this.z*e},i.prototype.equals=function(e){return e&&this.x===e.x&&this.y===e.y&&this.z===e.z},i.prototype.equalsWithEpsilon=function(i,r){return void 0===r&&(r=e.Epsilon),i&&t.WithinEpsilon(this.x,i.x,r)&&t.WithinEpsilon(this.y,i.y,r)&&t.WithinEpsilon(this.z,i.z,r)},i.prototype.equalsToFloats=function(e,t,i){return this.x===e&&this.y===t&&this.z===i},i.prototype.multiplyInPlace=function(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this},i.prototype.multiply=function(e){return new i(this.x*e.x,this.y*e.y,this.z*e.z)},i.prototype.multiplyToRef=function(e,t){return t.x=this.x*e.x,t.y=this.y*e.y,t.z=this.z*e.z,this},i.prototype.multiplyByFloats=function(e,t,r){return new i(this.x*e,this.y*t,this.z*r)},i.prototype.divide=function(e){return new i(this.x/e.x,this.y/e.y,this.z/e.z)},i.prototype.divideToRef=function(e,t){return t.x=this.x/e.x,t.y=this.y/e.y,t.z=this.z/e.z,this},i.prototype.MinimizeInPlace=function(e){return e.x<this.x&&(this.x=e.x),e.y<this.y&&(this.y=e.y),e.z<this.z&&(this.z=e.z),this},i.prototype.MaximizeInPlace=function(e){return e.x>this.x&&(this.x=e.x),e.y>this.y&&(this.y=e.y),e.z>this.z&&(this.z=e.z),this},i.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},i.prototype.lengthSquared=function(){return this.x*this.x+this.y*this.y+this.z*this.z},i.prototype.normalize=function(){var e=this.length();if(0===e||1===e)return this;var t=1/e;return this.x*=t,this.y*=t,this.z*=t,this},i.prototype.clone=function(){return new i(this.x,this.y,this.z)},i.prototype.copyFrom=function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this},i.prototype.copyFromFloats=function(e,t,i){return this.x=e,this.y=t,this.z=i,this},i.GetClipFactor=function(e,t,r,n){var o=i.Dot(e,r)-n,s=i.Dot(t,r)-n,a=o/(o-s);return a},i.FromArray=function(e,t){return t||(t=0),new i(e[t],e[t+1],e[t+2])},i.FromFloatArray=function(e,t){return t||(t=0),new i(e[t],e[t+1],e[t+2])},i.FromArrayToRef=function(e,t,i){i.x=e[t],i.y=e[t+1],i.z=e[t+2]},i.FromFloatArrayToRef=function(e,t,i){i.x=e[t],i.y=e[t+1],i.z=e[t+2]},i.FromFloatsToRef=function(e,t,i,r){r.x=e,r.y=t,r.z=i},i.Zero=function(){return new i(0,0,0)},i.Up=function(){return new i(0,1,0)},i.TransformCoordinates=function(e,t){var r=i.Zero();return i.TransformCoordinatesToRef(e,t,r),r},i.TransformCoordinatesToRef=function(e,t,i){var r=e.x*t.m[0]+e.y*t.m[4]+e.z*t.m[8]+t.m[12],n=e.x*t.m[1]+e.y*t.m[5]+e.z*t.m[9]+t.m[13],o=e.x*t.m[2]+e.y*t.m[6]+e.z*t.m[10]+t.m[14],s=e.x*t.m[3]+e.y*t.m[7]+e.z*t.m[11]+t.m[15];i.x=r/s,i.y=n/s,i.z=o/s},i.TransformCoordinatesFromFloatsToRef=function(e,t,i,r,n){var o=e*r.m[0]+t*r.m[4]+i*r.m[8]+r.m[12],s=e*r.m[1]+t*r.m[5]+i*r.m[9]+r.m[13],a=e*r.m[2]+t*r.m[6]+i*r.m[10]+r.m[14],h=e*r.m[3]+t*r.m[7]+i*r.m[11]+r.m[15];n.x=o/h,n.y=s/h,n.z=a/h},i.TransformNormal=function(e,t){var r=i.Zero();return i.TransformNormalToRef(e,t,r),r},i.TransformNormalToRef=function(e,t,i){i.x=e.x*t.m[0]+e.y*t.m[4]+e.z*t.m[8],i.y=e.x*t.m[1]+e.y*t.m[5]+e.z*t.m[9],i.z=e.x*t.m[2]+e.y*t.m[6]+e.z*t.m[10]},i.TransformNormalFromFloatsToRef=function(e,t,i,r,n){n.x=e*r.m[0]+t*r.m[4]+i*r.m[8],n.y=e*r.m[1]+t*r.m[5]+i*r.m[9],n.z=e*r.m[2]+t*r.m[6]+i*r.m[10]},i.CatmullRom=function(e,t,r,n,o){var s=o*o,a=o*s,h=.5*(2*t.x+(-e.x+r.x)*o+(2*e.x-5*t.x+4*r.x-n.x)*s+(-e.x+3*t.x-3*r.x+n.x)*a),c=.5*(2*t.y+(-e.y+r.y)*o+(2*e.y-5*t.y+4*r.y-n.y)*s+(-e.y+3*t.y-3*r.y+n.y)*a),l=.5*(2*t.z+(-e.z+r.z)*o+(2*e.z-5*t.z+4*r.z-n.z)*s+(-e.z+3*t.z-3*r.z+n.z)*a);return new i(h,c,l)},i.Clamp=function(e,t,r){var n=e.x;n=n>r.x?r.x:n,n=n<t.x?t.x:n;var o=e.y;o=o>r.y?r.y:o,o=o<t.y?t.y:o;var s=e.z;return s=s>r.z?r.z:s,s=s<t.z?t.z:s,new i(n,o,s)},i.Hermite=function(e,t,r,n,o){var s=o*o,a=o*s,h=2*a-3*s+1,c=-2*a+3*s,l=a-2*s+o,u=a-s,f=e.x*h+r.x*c+t.x*l+n.x*u,d=e.y*h+r.y*c+t.y*l+n.y*u,p=e.z*h+r.z*c+t.z*l+n.z*u;return new i(f,d,p)},i.Lerp=function(e,t,r){var n=e.x+(t.x-e.x)*r,o=e.y+(t.y-e.y)*r,s=e.z+(t.z-e.z)*r;return new i(n,o,s)},i.Dot=function(e,t){return e.x*t.x+e.y*t.y+e.z*t.z},i.Cross=function(e,t){var r=i.Zero();return i.CrossToRef(e,t,r),r},i.CrossToRef=function(e,t,i){E.Vector3[0].x=e.y*t.z-e.z*t.y,E.Vector3[0].y=e.z*t.x-e.x*t.z,E.Vector3[0].z=e.x*t.y-e.y*t.x,i.copyFrom(E.Vector3[0])},i.Normalize=function(e){var t=i.Zero();return i.NormalizeToRef(e,t),t},i.NormalizeToRef=function(e,t){t.copyFrom(e),t.normalize()},i.Project=function(e,t,r,n){var o=n.width,s=n.height,a=n.x,h=n.y,l=c.FromValues(o/2,0,0,0,0,-s/2,0,0,0,0,1,0,a+o/2,s/2+h,0,1),u=t.multiply(r).multiply(l);return i.TransformCoordinates(e,u)},i.UnprojectFromTransform=function(e,r,n,o,s){var a=o.multiply(s);a.invert(),e.x=e.x/r*2-1,e.y=-(e.y/n*2-1);var h=i.TransformCoordinates(e,a),c=e.x*a.m[3]+e.y*a.m[7]+e.z*a.m[11]+a.m[15];return t.WithinEpsilon(c,1)&&(h=h.scale(1/c)),h},i.Unproject=function(e,r,n,o,s,a){var h=o.multiply(s).multiply(a);h.invert();var c=new i(e.x/r*2-1,-(e.y/n*2-1),e.z),l=i.TransformCoordinates(c,h),u=c.x*h.m[3]+c.y*h.m[7]+c.z*h.m[11]+h.m[15];return t.WithinEpsilon(u,1)&&(l=l.scale(1/u)),l},i.Minimize=function(e,t){var i=e.clone();return i.MinimizeInPlace(t),i},i.Maximize=function(e,t){var i=e.clone();return i.MaximizeInPlace(t),i},i.Distance=function(e,t){return Math.sqrt(i.DistanceSquared(e,t))},i.DistanceSquared=function(e,t){var i=e.x-t.x,r=e.y-t.y,n=e.z-t.z;return i*i+r*r+n*n},i.Center=function(e,t){var i=e.add(t);return i.scaleInPlace(.5),i},i.RotationFromAxis=function(e,t,r){var n=i.Zero();return i.RotationFromAxisToRef(e,t,r,n),n},i.RotationFromAxisToRef=function(r,n,o,s){var a=r.normalize(),h=o.normalize(),c=d.X,l=d.Y,u=0,f=0,p=0,_=0,m=0,g=0,v=0,y=-1,x=0,b=E.Vector3[0],P=0,A=E.Vector3[1];t.WithinEpsilon(h.z,0,e.Epsilon)?g=1:t.WithinEpsilon(h.x,0,e.Epsilon)?_=1:(v=h.z/h.x,_=-v*Math.sqrt(1/(1+v*v)),g=Math.sqrt(1/(1+v*v))),A.x=_,A.y=m,A.z=g,A.normalize(),i.CrossToRef(a,A,b),b.normalize(),i.Dot(h,b)<0&&(y=1),P=i.Dot(a,A),P=Math.min(1,Math.max(-1,P)),p=Math.acos(P)*y,i.Dot(A,c)<0&&(p=Math.PI+p,A=A.scaleInPlace(-1),x++);var T=E.Vector3[2],C=E.Vector3[3];_=0,m=0,g=0,y=-1,t.WithinEpsilon(h.z,0,e.Epsilon)?_=1:(v=A.z/A.x,_=-v*Math.sqrt(1/(1+v*v)),g=Math.sqrt(1/(1+v*v))),T.x=_,T.y=m,T.z=g,T.normalize(),i.CrossToRef(T,A,C),C.normalize(),i.CrossToRef(h,T,b),b.normalize(),i.Dot(A,b)<0&&(y=1),P=i.Dot(h,T),P=Math.min(1,Math.max(-1,P)),f=Math.acos(P)*y,i.Dot(C,l)<0&&(f=Math.PI+f,x++),y=-1,i.CrossToRef(c,A,b),b.normalize(),i.Dot(b,l)<0&&(y=1),P=i.Dot(A,c),P=Math.min(1,Math.max(-1,P)),u=-Math.acos(P)*y,0>P&&2>x&&(u=Math.PI+u),s.x=f,s.y=u,s.z=p},i}();e.Vector3=o;var s=function(){function i(e,t,i,r){this.x=e,this.y=t,this.z=i,this.w=r}return i.prototype.toString=function(){return"{X: "+this.x+" Y:"+this.y+" Z:"+this.z+"W:"+this.w+"}"},i.prototype.getClassName=function(){return"Vector4"},i.prototype.getHashCode=function(){var e=this.x||0;return e=397*e^(this.y||0),e=397*e^(this.z||0),e=397*e^(this.w||0)},i.prototype.asArray=function(){var e=[];return this.toArray(e,0),e},i.prototype.toArray=function(e,t){return void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,this},i.prototype.addInPlace=function(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this},i.prototype.add=function(e){return new i(this.x+e.x,this.y+e.y,this.z+e.z,this.w+e.w)},i.prototype.addToRef=function(e,t){return t.x=this.x+e.x,t.y=this.y+e.y,t.z=this.z+e.z,t.w=this.w+e.w,this},i.prototype.subtractInPlace=function(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this},i.prototype.subtract=function(e){return new i(this.x-e.x,this.y-e.y,this.z-e.z,this.w-e.w)},i.prototype.subtractToRef=function(e,t){return t.x=this.x-e.x,t.y=this.y-e.y,t.z=this.z-e.z,t.w=this.w-e.w,this},i.prototype.subtractFromFloats=function(e,t,r,n){return new i(this.x-e,this.y-t,this.z-r,this.w-n)},i.prototype.subtractFromFloatsToRef=function(e,t,i,r,n){return n.x=this.x-e,n.y=this.y-t,n.z=this.z-i,n.w=this.w-r,this},i.prototype.negate=function(){return new i(-this.x,-this.y,-this.z,-this.w)},i.prototype.scaleInPlace=function(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this},i.prototype.scale=function(e){return new i(this.x*e,this.y*e,this.z*e,this.w*e)},i.prototype.scaleToRef=function(e,t){t.x=this.x*e,t.y=this.y*e,t.z=this.z*e,t.w=this.w*e},i.prototype.equals=function(e){return e&&this.x===e.x&&this.y===e.y&&this.z===e.z&&this.w===e.w},i.prototype.equalsWithEpsilon=function(i,r){return void 0===r&&(r=e.Epsilon),i&&t.WithinEpsilon(this.x,i.x,r)&&t.WithinEpsilon(this.y,i.y,r)&&t.WithinEpsilon(this.z,i.z,r)&&t.WithinEpsilon(this.w,i.w,r)},i.prototype.equalsToFloats=function(e,t,i,r){return this.x===e&&this.y===t&&this.z===i&&this.w===r},i.prototype.multiplyInPlace=function(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this},i.prototype.multiply=function(e){return new i(this.x*e.x,this.y*e.y,this.z*e.z,this.w*e.w)},i.prototype.multiplyToRef=function(e,t){return t.x=this.x*e.x,t.y=this.y*e.y,t.z=this.z*e.z,t.w=this.w*e.w,this},i.prototype.multiplyByFloats=function(e,t,r,n){return new i(this.x*e,this.y*t,this.z*r,this.w*n)},i.prototype.divide=function(e){return new i(this.x/e.x,this.y/e.y,this.z/e.z,this.w/e.w)},i.prototype.divideToRef=function(e,t){return t.x=this.x/e.x,t.y=this.y/e.y,t.z=this.z/e.z,t.w=this.w/e.w,this},i.prototype.MinimizeInPlace=function(e){return e.x<this.x&&(this.x=e.x),e.y<this.y&&(this.y=e.y),e.z<this.z&&(this.z=e.z),e.w<this.w&&(this.w=e.w),this},i.prototype.MaximizeInPlace=function(e){return e.x>this.x&&(this.x=e.x),e.y>this.y&&(this.y=e.y),e.z>this.z&&(this.z=e.z),e.w>this.w&&(this.w=e.w),this},i.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},i.prototype.lengthSquared=function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},i.prototype.normalize=function(){var e=this.length();if(0===e)return this;var t=1/e;return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this},i.prototype.toVector3=function(){return new o(this.x,this.y,this.z)},i.prototype.clone=function(){return new i(this.x,this.y,this.z,this.w)},i.prototype.copyFrom=function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w,this},i.prototype.copyFromFloats=function(e,t,i,r){return this.x=e,this.y=t,this.z=i,this.w=r,this},i.FromArray=function(e,t){return t||(t=0),new i(e[t],e[t+1],e[t+2],e[t+3])},i.FromArrayToRef=function(e,t,i){i.x=e[t],i.y=e[t+1],i.z=e[t+2],i.w=e[t+3]},i.FromFloatArrayToRef=function(e,t,i){i.x=e[t],i.y=e[t+1],i.z=e[t+2],i.w=e[t+3]},i.FromFloatsToRef=function(e,t,i,r,n){n.x=e,n.y=t,n.z=i,n.w=r},i.Zero=function(){return new i(0,0,0,0)},i.Normalize=function(e){var t=i.Zero();return i.NormalizeToRef(e,t),t},i.NormalizeToRef=function(e,t){t.copyFrom(e),t.normalize()},i.Minimize=function(e,t){var i=e.clone();return i.MinimizeInPlace(t),i},i.Maximize=function(e,t){var i=e.clone();return i.MaximizeInPlace(t),i},i.Distance=function(e,t){return Math.sqrt(i.DistanceSquared(e,t))},i.DistanceSquared=function(e,t){var i=e.x-t.x,r=e.y-t.y,n=e.z-t.z,o=e.w-t.w;return i*i+r*r+n*n+o*o},i.Center=function(e,t){var i=e.add(t);return i.scaleInPlace(.5),i},i}();e.Vector4=s;var a=function(){function e(e,t){this.width=e,this.height=t}return e.prototype.toString=function(){return"{W: "+this.width+", H: "+this.height+"}"},e.prototype.getClassName=function(){return"Size"},e.prototype.getHashCode=function(){var e=this.width||0;return e=397*e^(this.height||0)},e.prototype.copyFrom=function(e){this.width=e.width,this.height=e.height},e.prototype.clone=function(){return new e(this.width,this.height)},e.prototype.equals=function(e){return e?this.width===e.width&&this.height===e.height:!1},Object.defineProperty(e.prototype,"surface",{get:function(){return this.width*this.height},enumerable:!0,configurable:!0}),e.Zero=function(){return new e(0,0)},e.prototype.add=function(t){var i=new e(this.width+t.width,this.height+t.height);return i},e.prototype.substract=function(t){var i=new e(this.width-t.width,this.height-t.height);return i},e.Lerp=function(t,i,r){var n=t.width+(i.width-t.width)*r,o=t.height+(i.height-t.height)*r;return new e(n,o)},e}();e.Size=a;var h=function(){function e(e,t,i,r){void 0===e&&(e=0),void 0===t&&(t=0),void 0===i&&(i=0),void 0===r&&(r=1),this.x=e,this.y=t,this.z=i,this.w=r}return e.prototype.toString=function(){return"{X: "+this.x+" Y:"+this.y+" Z:"+this.z+" W:"+this.w+"}"},e.prototype.getClassName=function(){return"Quaternion"},e.prototype.getHashCode=function(){var e=this.x||0;return e=397*e^(this.y||0),e=397*e^(this.z||0),e=397*e^(this.w||0)},e.prototype.asArray=function(){return[this.x,this.y,this.z,this.w]},e.prototype.equals=function(e){return e&&this.x===e.x&&this.y===e.y&&this.z===e.z&&this.w===e.w},e.prototype.clone=function(){return new e(this.x,this.y,this.z,this.w)},e.prototype.copyFrom=function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w,this},e.prototype.copyFromFloats=function(e,t,i,r){return this.x=e,this.y=t,this.z=i,this.w=r,this},e.prototype.add=function(t){return new e(this.x+t.x,this.y+t.y,this.z+t.z,this.w+t.w)},e.prototype.subtract=function(t){return new e(this.x-t.x,this.y-t.y,this.z-t.z,this.w-t.w)},e.prototype.scale=function(t){return new e(this.x*t,this.y*t,this.z*t,this.w*t)},e.prototype.multiply=function(t){var i=new e(0,0,0,1);return this.multiplyToRef(t,i),i},e.prototype.multiplyToRef=function(e,t){var i=this.x*e.w+this.y*e.z-this.z*e.y+this.w*e.x,r=-this.x*e.z+this.y*e.w+this.z*e.x+this.w*e.y,n=this.x*e.y-this.y*e.x+this.z*e.w+this.w*e.z,o=-this.x*e.x-this.y*e.y-this.z*e.z+this.w*e.w;return t.copyFromFloats(i,r,n,o),this},e.prototype.multiplyInPlace=function(e){return this.multiplyToRef(e,this),this},e.prototype.conjugateToRef=function(e){return e.copyFromFloats(-this.x,-this.y,-this.z,this.w),this},e.prototype.conjugateInPlace=function(){return this.x*=-1,this.y*=-1,this.z*=-1,this},e.prototype.conjugate=function(){var t=new e(-this.x,-this.y,-this.z,this.w);return t},e.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},e.prototype.normalize=function(){var e=1/this.length();return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this},e.prototype.toEulerAngles=function(e){void 0===e&&(e="YZX");var t=o.Zero();return this.toEulerAnglesToRef(t,e),t},e.prototype.toEulerAnglesToRef=function(e,t){void 0===t&&(t="YZX");var i,r,n,o=this.x,s=this.y,a=this.z,h=this.w;switch(t){case"YZX":var c=o*s+a*h;if(c>.499&&(i=2*Math.atan2(o,h),r=Math.PI/2,n=0),-.499>c&&(i=-2*Math.atan2(o,h),r=-Math.PI/2,n=0),isNaN(i)){var l=o*o,u=s*s,f=a*a;i=Math.atan2(2*s*h-2*o*a,1-2*u-2*f),r=Math.asin(2*c),n=Math.atan2(2*o*h-2*s*a,1-2*l-2*f)}break;default:throw new Error("Euler order "+t+" not supported yet.")}return e.y=i,e.z=r,e.x=n,this},e.prototype.toRotationMatrix=function(e){var t=this.x*this.x,i=this.y*this.y,r=this.z*this.z,n=this.x*this.y,o=this.z*this.w,s=this.z*this.x,a=this.y*this.w,h=this.y*this.z,c=this.x*this.w;return e.m[0]=1-2*(i+r),e.m[1]=2*(n+o),e.m[2]=2*(s-a),e.m[3]=0,e.m[4]=2*(n-o),e.m[5]=1-2*(r+t),e.m[6]=2*(h+c),e.m[7]=0,e.m[8]=2*(s+a),e.m[9]=2*(h-c),e.m[10]=1-2*(i+t),e.m[11]=0,e.m[12]=0,e.m[13]=0,e.m[14]=0,e.m[15]=1,this},e.prototype.fromRotationMatrix=function(t){return e.FromRotationMatrixToRef(t,this),this},e.FromRotationMatrix=function(t){var i=new e;return e.FromRotationMatrixToRef(t,i),i},e.FromRotationMatrixToRef=function(e,t){var i,r=e.m,n=r[0],o=r[4],s=r[8],a=r[1],h=r[5],c=r[9],l=r[2],u=r[6],f=r[10],d=n+h+f;d>0?(i=.5/Math.sqrt(d+1),t.w=.25/i,t.x=(u-c)*i,t.y=(s-l)*i,t.z=(a-o)*i):n>h&&n>f?(i=2*Math.sqrt(1+n-h-f),t.w=(u-c)/i,t.x=.25*i,t.y=(o+a)/i,t.z=(s+l)/i):h>f?(i=2*Math.sqrt(1+h-n-f),t.w=(s-l)/i,t.x=(o+a)/i,t.y=.25*i,t.z=(c+u)/i):(i=2*Math.sqrt(1+f-n-h),t.w=(a-o)/i,t.x=(s+l)/i,t.y=(c+u)/i,t.z=.25*i)},e.Inverse=function(t){return new e(-t.x,-t.y,-t.z,t.w)},e.Identity=function(){return new e(0,0,0,1)},e.RotationAxis=function(t,i){var r=new e,n=Math.sin(i/2);return t.normalize(),r.w=Math.cos(i/2),r.x=t.x*n,r.y=t.y*n,r.z=t.z*n,r},e.FromArray=function(t,i){return i||(i=0),new e(t[i],t[i+1],t[i+2],t[i+3])},e.RotationYawPitchRoll=function(t,i,r){var n=new e;return e.RotationYawPitchRollToRef(t,i,r,n),n},e.RotationYawPitchRollToRef=function(e,t,i,r){var n=.5*i,o=.5*t,s=.5*e,a=Math.sin(n),h=Math.cos(n),c=Math.sin(o),l=Math.cos(o),u=Math.sin(s),f=Math.cos(s);r.x=f*c*h+u*l*a,r.y=u*l*h-f*c*a,r.z=f*l*a-u*c*h,r.w=f*l*h+u*c*a},e.RotationAlphaBetaGamma=function(t,i,r){var n=new e;return e.RotationAlphaBetaGammaToRef(t,i,r,n),n},e.RotationAlphaBetaGammaToRef=function(e,t,i,r){var n=.5*(i+e),o=.5*(i-e),s=.5*t;r.x=Math.cos(o)*Math.sin(s),r.y=Math.sin(o)*Math.sin(s),r.z=Math.sin(n)*Math.cos(s),r.w=Math.cos(n)*Math.cos(s)},e.Slerp=function(t,i,r){var n,o,s=r,a=t.x*i.x+t.y*i.y+t.z*i.z+t.w*i.w,h=!1;if(0>a&&(h=!0,a=-a),a>.999999)o=1-s,n=h?-s:s;else{var c=Math.acos(a),l=1/Math.sin(c);o=Math.sin((1-s)*c)*l,n=h?-Math.sin(s*c)*l:Math.sin(s*c)*l}return new e(o*t.x+n*i.x,o*t.y+n*i.y,o*t.z+n*i.z,o*t.w+n*i.w)},e}();e.Quaternion=h;var c=function(){function e(){this.m=new Float32Array(16)}return e.prototype.isIdentity=function(){return 1!==this.m[0]||1!==this.m[5]||1!==this.m[10]||1!==this.m[15]?!1:0===this.m[1]&&0===this.m[2]&&0===this.m[3]&&0===this.m[4]&&0===this.m[6]&&0===this.m[7]&&0===this.m[8]&&0===this.m[9]&&0===this.m[11]&&0===this.m[12]&&0===this.m[13]&&0===this.m[14]},e.prototype.determinant=function(){var e=this.m[10]*this.m[15]-this.m[11]*this.m[14],t=this.m[9]*this.m[15]-this.m[11]*this.m[13],i=this.m[9]*this.m[14]-this.m[10]*this.m[13],r=this.m[8]*this.m[15]-this.m[11]*this.m[12],n=this.m[8]*this.m[14]-this.m[10]*this.m[12],o=this.m[8]*this.m[13]-this.m[9]*this.m[12];return this.m[0]*(this.m[5]*e-this.m[6]*t+this.m[7]*i)-this.m[1]*(this.m[4]*e-this.m[6]*r+this.m[7]*n)+this.m[2]*(this.m[4]*t-this.m[5]*r+this.m[7]*o)-this.m[3]*(this.m[4]*i-this.m[5]*n+this.m[6]*o)},e.prototype.toArray=function(){return this.m},e.prototype.asArray=function(){return this.toArray()},e.prototype.invert=function(){return this.invertToRef(this),this},e.prototype.reset=function(){for(var e=0;16>e;e++)this.m[e]=0;return this},e.prototype.add=function(t){var i=new e;return this.addToRef(t,i),i},e.prototype.addToRef=function(e,t){for(var i=0;16>i;i++)t.m[i]=this.m[i]+e.m[i];return this},e.prototype.addToSelf=function(e){for(var t=0;16>t;t++)this.m[t]+=e.m[t];return this},e.prototype.invertToRef=function(e){var t=this.m[0],i=this.m[1],r=this.m[2],n=this.m[3],o=this.m[4],s=this.m[5],a=this.m[6],h=this.m[7],c=this.m[8],l=this.m[9],u=this.m[10],f=this.m[11],d=this.m[12],p=this.m[13],_=this.m[14],m=this.m[15],g=u*m-f*_,v=l*m-f*p,y=l*_-u*p,x=c*m-f*d,b=c*_-u*d,P=c*p-l*d,A=s*g-a*v+h*y,T=-(o*g-a*x+h*b),E=o*v-s*x+h*P,C=-(o*y-s*b+a*P),S=1/(t*A+i*T+r*E+n*C),M=a*m-h*_,I=s*m-h*p,D=s*_-a*p,R=o*m-h*d,O=o*_-a*d,w=o*p-s*d,L=a*f-h*u,B=s*f-h*l,V=s*u-a*l,F=o*f-h*c,N=o*u-a*c,z=o*l-s*c;return e.m[0]=A*S,e.m[4]=T*S,e.m[8]=E*S,e.m[12]=C*S,e.m[1]=-(i*g-r*v+n*y)*S,e.m[5]=(t*g-r*x+n*b)*S,e.m[9]=-(t*v-i*x+n*P)*S,e.m[13]=(t*y-i*b+r*P)*S,e.m[2]=(i*M-r*I+n*D)*S,e.m[6]=-(t*M-r*R+n*O)*S,e.m[10]=(t*I-i*R+n*w)*S,e.m[14]=-(t*D-i*O+r*w)*S,e.m[3]=-(i*L-r*B+n*V)*S,e.m[7]=(t*L-r*F+n*N)*S,e.m[11]=-(t*B-i*F+n*z)*S,e.m[15]=(t*V-i*N+r*z)*S,this},e.prototype.setTranslation=function(e){return this.m[12]=e.x,this.m[13]=e.y,this.m[14]=e.z,this},e.prototype.getTranslation=function(){return new o(this.m[12],this.m[13],this.m[14])},e.prototype.multiply=function(t){var i=new e;return this.multiplyToRef(t,i),i},e.prototype.copyFrom=function(e){for(var t=0;16>t;t++)this.m[t]=e.m[t];return this},e.prototype.copyToArray=function(e,t){void 0===t&&(t=0);for(var i=0;16>i;i++)e[t+i]=this.m[i];return this},e.prototype.multiplyToRef=function(e,t){return this.multiplyToArray(e,t.m,0),this},e.prototype.multiplyToArray=function(e,t,i){var r=this.m[0],n=this.m[1],o=this.m[2],s=this.m[3],a=this.m[4],h=this.m[5],c=this.m[6],l=this.m[7],u=this.m[8],f=this.m[9],d=this.m[10],p=this.m[11],_=this.m[12],m=this.m[13],g=this.m[14],v=this.m[15],y=e.m[0],x=e.m[1],b=e.m[2],P=e.m[3],A=e.m[4],T=e.m[5],E=e.m[6],C=e.m[7],S=e.m[8],M=e.m[9],I=e.m[10],D=e.m[11],R=e.m[12],O=e.m[13],w=e.m[14],L=e.m[15];
  2. return t[i]=r*y+n*A+o*S+s*R,t[i+1]=r*x+n*T+o*M+s*O,t[i+2]=r*b+n*E+o*I+s*w,t[i+3]=r*P+n*C+o*D+s*L,t[i+4]=a*y+h*A+c*S+l*R,t[i+5]=a*x+h*T+c*M+l*O,t[i+6]=a*b+h*E+c*I+l*w,t[i+7]=a*P+h*C+c*D+l*L,t[i+8]=u*y+f*A+d*S+p*R,t[i+9]=u*x+f*T+d*M+p*O,t[i+10]=u*b+f*E+d*I+p*w,t[i+11]=u*P+f*C+d*D+p*L,t[i+12]=_*y+m*A+g*S+v*R,t[i+13]=_*x+m*T+g*M+v*O,t[i+14]=_*b+m*E+g*I+v*w,t[i+15]=_*P+m*C+g*D+v*L,this},e.prototype.equals=function(e){return e&&this.m[0]===e.m[0]&&this.m[1]===e.m[1]&&this.m[2]===e.m[2]&&this.m[3]===e.m[3]&&this.m[4]===e.m[4]&&this.m[5]===e.m[5]&&this.m[6]===e.m[6]&&this.m[7]===e.m[7]&&this.m[8]===e.m[8]&&this.m[9]===e.m[9]&&this.m[10]===e.m[10]&&this.m[11]===e.m[11]&&this.m[12]===e.m[12]&&this.m[13]===e.m[13]&&this.m[14]===e.m[14]&&this.m[15]===e.m[15]},e.prototype.clone=function(){return e.FromValues(this.m[0],this.m[1],this.m[2],this.m[3],this.m[4],this.m[5],this.m[6],this.m[7],this.m[8],this.m[9],this.m[10],this.m[11],this.m[12],this.m[13],this.m[14],this.m[15])},e.prototype.getClassName=function(){return"Matrix"},e.prototype.getHashCode=function(){for(var e=this.m[0]||0,t=1;16>t;t++)e=397*e^(this.m[t]||0);return e},e.prototype.decompose=function(i,r,n){n.x=this.m[12],n.y=this.m[13],n.z=this.m[14];var o=t.Sign(this.m[0]*this.m[1]*this.m[2]*this.m[3])<0?-1:1,s=t.Sign(this.m[4]*this.m[5]*this.m[6]*this.m[7])<0?-1:1,a=t.Sign(this.m[8]*this.m[9]*this.m[10]*this.m[11])<0?-1:1;if(i.x=o*Math.sqrt(this.m[0]*this.m[0]+this.m[1]*this.m[1]+this.m[2]*this.m[2]),i.y=s*Math.sqrt(this.m[4]*this.m[4]+this.m[5]*this.m[5]+this.m[6]*this.m[6]),i.z=a*Math.sqrt(this.m[8]*this.m[8]+this.m[9]*this.m[9]+this.m[10]*this.m[10]),0===i.x||0===i.y||0===i.z)return r.x=0,r.y=0,r.z=0,r.w=1,!1;var c=e.FromValues(this.m[0]/i.x,this.m[1]/i.x,this.m[2]/i.x,0,this.m[4]/i.y,this.m[5]/i.y,this.m[6]/i.y,0,this.m[8]/i.z,this.m[9]/i.z,this.m[10]/i.z,0,0,0,0,1);return h.FromRotationMatrixToRef(c,r),!0},e.FromArray=function(t,i){var r=new e;return i||(i=0),e.FromArrayToRef(t,i,r),r},e.FromArrayToRef=function(e,t,i){for(var r=0;16>r;r++)i.m[r]=e[r+t]},e.FromFloat32ArrayToRefScaled=function(e,t,i,r){for(var n=0;16>n;n++)r.m[n]=e[n+t]*i},e.FromValuesToRef=function(e,t,i,r,n,o,s,a,h,c,l,u,f,d,p,_,m){m.m[0]=e,m.m[1]=t,m.m[2]=i,m.m[3]=r,m.m[4]=n,m.m[5]=o,m.m[6]=s,m.m[7]=a,m.m[8]=h,m.m[9]=c,m.m[10]=l,m.m[11]=u,m.m[12]=f,m.m[13]=d,m.m[14]=p,m.m[15]=_},e.prototype.getRow=function(e){if(0>e||e>3)return null;var t=4*e;return new s(this.m[t+0],this.m[t+1],this.m[t+2],this.m[t+3])},e.prototype.setRow=function(e,t){if(0>e||e>3)return this;var i=4*e;return this.m[i+0]=t.x,this.m[i+1]=t.y,this.m[i+2]=t.z,this.m[i+3]=t.w,this},e.FromValues=function(t,i,r,n,o,s,a,h,c,l,u,f,d,p,_,m){var g=new e;return g.m[0]=t,g.m[1]=i,g.m[2]=r,g.m[3]=n,g.m[4]=o,g.m[5]=s,g.m[6]=a,g.m[7]=h,g.m[8]=c,g.m[9]=l,g.m[10]=u,g.m[11]=f,g.m[12]=d,g.m[13]=p,g.m[14]=_,g.m[15]=m,g},e.Compose=function(t,i,r){var n=e.FromValues(t.x,0,0,0,0,t.y,0,0,0,0,t.z,0,0,0,0,1),o=e.Identity();return i.toRotationMatrix(o),n=n.multiply(o),n.setTranslation(r),n},e.Identity=function(){return e.FromValues(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1)},e.IdentityToRef=function(t){e.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,t)},e.Zero=function(){return e.FromValues(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)},e.RotationX=function(t){var i=new e;return e.RotationXToRef(t,i),i},e.Invert=function(t){var i=new e;return t.invertToRef(i),i},e.RotationXToRef=function(e,t){var i=Math.sin(e),r=Math.cos(e);t.m[0]=1,t.m[15]=1,t.m[5]=r,t.m[10]=r,t.m[9]=-i,t.m[6]=i,t.m[1]=0,t.m[2]=0,t.m[3]=0,t.m[4]=0,t.m[7]=0,t.m[8]=0,t.m[11]=0,t.m[12]=0,t.m[13]=0,t.m[14]=0},e.RotationY=function(t){var i=new e;return e.RotationYToRef(t,i),i},e.RotationYToRef=function(e,t){var i=Math.sin(e),r=Math.cos(e);t.m[5]=1,t.m[15]=1,t.m[0]=r,t.m[2]=-i,t.m[8]=i,t.m[10]=r,t.m[1]=0,t.m[3]=0,t.m[4]=0,t.m[6]=0,t.m[7]=0,t.m[9]=0,t.m[11]=0,t.m[12]=0,t.m[13]=0,t.m[14]=0},e.RotationZ=function(t){var i=new e;return e.RotationZToRef(t,i),i},e.RotationZToRef=function(e,t){var i=Math.sin(e),r=Math.cos(e);t.m[10]=1,t.m[15]=1,t.m[0]=r,t.m[1]=i,t.m[4]=-i,t.m[5]=r,t.m[2]=0,t.m[3]=0,t.m[6]=0,t.m[7]=0,t.m[8]=0,t.m[9]=0,t.m[11]=0,t.m[12]=0,t.m[13]=0,t.m[14]=0},e.RotationAxis=function(t,i){var r=e.Zero();return e.RotationAxisToRef(t,i,r),r},e.RotationAxisToRef=function(e,t,i){var r=Math.sin(-t),n=Math.cos(-t),o=1-n;e.normalize(),i.m[0]=e.x*e.x*o+n,i.m[1]=e.x*e.y*o-e.z*r,i.m[2]=e.x*e.z*o+e.y*r,i.m[3]=0,i.m[4]=e.y*e.x*o+e.z*r,i.m[5]=e.y*e.y*o+n,i.m[6]=e.y*e.z*o-e.x*r,i.m[7]=0,i.m[8]=e.z*e.x*o-e.y*r,i.m[9]=e.z*e.y*o+e.x*r,i.m[10]=e.z*e.z*o+n,i.m[11]=0,i.m[15]=1},e.RotationYawPitchRoll=function(t,i,r){var n=new e;return e.RotationYawPitchRollToRef(t,i,r,n),n},e.RotationYawPitchRollToRef=function(e,t,i,r){h.RotationYawPitchRollToRef(e,t,i,this._tempQuaternion),this._tempQuaternion.toRotationMatrix(r)},e.Scaling=function(t,i,r){var n=e.Zero();return e.ScalingToRef(t,i,r,n),n},e.ScalingToRef=function(e,t,i,r){r.m[0]=e,r.m[1]=0,r.m[2]=0,r.m[3]=0,r.m[4]=0,r.m[5]=t,r.m[6]=0,r.m[7]=0,r.m[8]=0,r.m[9]=0,r.m[10]=i,r.m[11]=0,r.m[12]=0,r.m[13]=0,r.m[14]=0,r.m[15]=1},e.Translation=function(t,i,r){var n=e.Identity();return e.TranslationToRef(t,i,r,n),n},e.TranslationToRef=function(t,i,r,n){e.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,t,i,r,1,n)},e.Lerp=function(t,i,r){for(var n=e.Zero(),o=0;16>o;o++)n.m[o]=t.m[o]*(1-r)+i.m[o]*r;return n},e.DecomposeLerp=function(t,i,r){var n=new o(0,0,0),s=new h,a=new o(0,0,0);t.decompose(n,s,a);var c=new o(0,0,0),l=new h,u=new o(0,0,0);i.decompose(c,l,u);var f=o.Lerp(n,c,r),d=h.Slerp(s,l,r),p=o.Lerp(a,u,r);return e.Compose(f,d,p)},e.LookAtLH=function(t,i,r){var n=e.Zero();return e.LookAtLHToRef(t,i,r,n),n},e.LookAtLHToRef=function(t,i,r,n){i.subtractToRef(t,this._zAxis),this._zAxis.normalize(),o.CrossToRef(r,this._zAxis,this._xAxis),0===this._xAxis.lengthSquared()?this._xAxis.x=1:this._xAxis.normalize(),o.CrossToRef(this._zAxis,this._xAxis,this._yAxis),this._yAxis.normalize();var s=-o.Dot(this._xAxis,t),a=-o.Dot(this._yAxis,t),h=-o.Dot(this._zAxis,t);return e.FromValuesToRef(this._xAxis.x,this._yAxis.x,this._zAxis.x,0,this._xAxis.y,this._yAxis.y,this._zAxis.y,0,this._xAxis.z,this._yAxis.z,this._zAxis.z,0,s,a,h,1,n)},e.OrthoLH=function(t,i,r,n){var o=e.Zero();return e.OrthoLHToRef(t,i,r,n,o),o},e.OrthoLHToRef=function(t,i,r,n,o){var s=2/t,a=2/i,h=1/(n-r),c=r/(r-n);e.FromValuesToRef(s,0,0,0,0,a,0,0,0,0,h,0,0,0,c,1,o)},e.OrthoOffCenterLH=function(t,i,r,n,o,s){var a=e.Zero();return e.OrthoOffCenterLHToRef(t,i,r,n,o,s,a),a},e.OrthoOffCenterLHToRef=function(e,t,i,r,n,o,s){s.m[0]=2/(t-e),s.m[1]=s.m[2]=s.m[3]=0,s.m[5]=2/(r-i),s.m[4]=s.m[6]=s.m[7]=0,s.m[10]=-1/(n-o),s.m[8]=s.m[9]=s.m[11]=0,s.m[12]=(e+t)/(e-t),s.m[13]=(r+i)/(i-r),s.m[14]=n/(n-o),s.m[15]=1},e.PerspectiveLH=function(t,i,r,n){var o=e.Zero();return o.m[0]=2*r/t,o.m[1]=o.m[2]=o.m[3]=0,o.m[5]=2*r/i,o.m[4]=o.m[6]=o.m[7]=0,o.m[10]=-n/(r-n),o.m[8]=o.m[9]=0,o.m[11]=1,o.m[12]=o.m[13]=o.m[15]=0,o.m[14]=r*n/(r-n),o},e.PerspectiveFovLH=function(t,i,r,n){var o=e.Zero();return e.PerspectiveFovLHToRef(t,i,r,n,o),o},e.PerspectiveFovLHToRef=function(e,t,i,r,n,o){void 0===o&&(o=!0);var s=1/Math.tan(.5*e);o?n.m[0]=s/t:n.m[0]=s,n.m[1]=n.m[2]=n.m[3]=0,o?n.m[5]=s:n.m[5]=s*t,n.m[4]=n.m[6]=n.m[7]=0,n.m[8]=n.m[9]=0,n.m[10]=-r/(i-r),n.m[11]=1,n.m[12]=n.m[13]=n.m[15]=0,n.m[14]=i*r/(i-r)},e.GetFinalMatrix=function(t,i,r,n,o,s){var a=t.width,h=t.height,c=t.x,l=t.y,u=e.FromValues(a/2,0,0,0,0,-h/2,0,0,0,0,s-o,0,c+a/2,h/2+l,o,1);return i.multiply(r).multiply(n).multiply(u)},e.GetAsMatrix2x2=function(e){return new Float32Array([e.m[0],e.m[1],e.m[4],e.m[5]])},e.GetAsMatrix3x3=function(e){return new Float32Array([e.m[0],e.m[1],e.m[2],e.m[4],e.m[5],e.m[6],e.m[8],e.m[9],e.m[10]])},e.Transpose=function(t){var i=new e;return i.m[0]=t.m[0],i.m[1]=t.m[4],i.m[2]=t.m[8],i.m[3]=t.m[12],i.m[4]=t.m[1],i.m[5]=t.m[5],i.m[6]=t.m[9],i.m[7]=t.m[13],i.m[8]=t.m[2],i.m[9]=t.m[6],i.m[10]=t.m[10],i.m[11]=t.m[14],i.m[12]=t.m[3],i.m[13]=t.m[7],i.m[14]=t.m[11],i.m[15]=t.m[15],i},e.Reflection=function(t){var i=new e;return e.ReflectionToRef(t,i),i},e.ReflectionToRef=function(e,t){e.normalize();var i=e.normal.x,r=e.normal.y,n=e.normal.z,o=-2*i,s=-2*r,a=-2*n;t.m[0]=o*i+1,t.m[1]=s*i,t.m[2]=a*i,t.m[3]=0,t.m[4]=o*r,t.m[5]=s*r+1,t.m[6]=a*r,t.m[7]=0,t.m[8]=o*n,t.m[9]=s*n,t.m[10]=a*n+1,t.m[11]=0,t.m[12]=o*e.d,t.m[13]=s*e.d,t.m[14]=a*e.d,t.m[15]=1},e._tempQuaternion=new h,e._xAxis=o.Zero(),e._yAxis=o.Zero(),e._zAxis=o.Zero(),e}();e.Matrix=c;var l=function(){function e(e,t,i,r){this.normal=new o(e,t,i),this.d=r}return e.prototype.asArray=function(){return[this.normal.x,this.normal.y,this.normal.z,this.d]},e.prototype.clone=function(){return new e(this.normal.x,this.normal.y,this.normal.z,this.d)},e.prototype.getClassName=function(){return"Plane"},e.prototype.getHashCode=function(){var e=this.normal.getHashCode();return e=397*e^(this.d||0)},e.prototype.normalize=function(){var e=Math.sqrt(this.normal.x*this.normal.x+this.normal.y*this.normal.y+this.normal.z*this.normal.z),t=0;return 0!==e&&(t=1/e),this.normal.x*=t,this.normal.y*=t,this.normal.z*=t,this.d*=t,this},e.prototype.transform=function(t){var i=c.Transpose(t),r=this.normal.x,n=this.normal.y,o=this.normal.z,s=this.d,a=r*i.m[0]+n*i.m[1]+o*i.m[2]+s*i.m[3],h=r*i.m[4]+n*i.m[5]+o*i.m[6]+s*i.m[7],l=r*i.m[8]+n*i.m[9]+o*i.m[10]+s*i.m[11],u=r*i.m[12]+n*i.m[13]+o*i.m[14]+s*i.m[15];return new e(a,h,l,u)},e.prototype.dotCoordinate=function(e){return this.normal.x*e.x+this.normal.y*e.y+this.normal.z*e.z+this.d},e.prototype.copyFromPoints=function(e,t,i){var r,n=t.x-e.x,o=t.y-e.y,s=t.z-e.z,a=i.x-e.x,h=i.y-e.y,c=i.z-e.z,l=o*c-s*h,u=s*a-n*c,f=n*h-o*a,d=Math.sqrt(l*l+u*u+f*f);return r=0!==d?1/d:0,this.normal.x=l*r,this.normal.y=u*r,this.normal.z=f*r,this.d=-(this.normal.x*e.x+this.normal.y*e.y+this.normal.z*e.z),this},e.prototype.isFrontFacingTo=function(e,t){var i=o.Dot(this.normal,e);return t>=i},e.prototype.signedDistanceTo=function(e){return o.Dot(e,this.normal)+this.d},e.FromArray=function(t){return new e(t[0],t[1],t[2],t[3])},e.FromPoints=function(t,i,r){var n=new e(0,0,0,0);return n.copyFromPoints(t,i,r),n},e.FromPositionAndNormal=function(t,i){var r=new e(0,0,0,0);return i.normalize(),r.normal=i,r.d=-(i.x*t.x+i.y*t.y+i.z*t.z),r},e.SignedDistanceToPlaneFromPositionAndNormal=function(e,t,i){var r=-(t.x*e.x+t.y*e.y+t.z*e.z);return o.Dot(i,t)+r},e}();e.Plane=l;var u=function(){function e(e,t,i,r){this.x=e,this.y=t,this.width=i,this.height=r}return e.prototype.toGlobal=function(t,i){return new e(this.x*t,this.y*i,this.width*t,this.height*i)},e}();e.Viewport=u;var f=function(){function e(){}return e.GetPlanes=function(t){for(var i=[],r=0;6>r;r++)i.push(new l(0,0,0,0));return e.GetPlanesToRef(t,i),i},e.GetPlanesToRef=function(e,t){t[0].normal.x=e.m[3]+e.m[2],t[0].normal.y=e.m[7]+e.m[6],t[0].normal.z=e.m[11]+e.m[10],t[0].d=e.m[15]+e.m[14],t[0].normalize(),t[1].normal.x=e.m[3]-e.m[2],t[1].normal.y=e.m[7]-e.m[6],t[1].normal.z=e.m[11]-e.m[10],t[1].d=e.m[15]-e.m[14],t[1].normalize(),t[2].normal.x=e.m[3]+e.m[0],t[2].normal.y=e.m[7]+e.m[4],t[2].normal.z=e.m[11]+e.m[8],t[2].d=e.m[15]+e.m[12],t[2].normalize(),t[3].normal.x=e.m[3]-e.m[0],t[3].normal.y=e.m[7]-e.m[4],t[3].normal.z=e.m[11]-e.m[8],t[3].d=e.m[15]-e.m[12],t[3].normalize(),t[4].normal.x=e.m[3]-e.m[1],t[4].normal.y=e.m[7]-e.m[5],t[4].normal.z=e.m[11]-e.m[9],t[4].d=e.m[15]-e.m[13],t[4].normalize(),t[5].normal.x=e.m[3]+e.m[1],t[5].normal.y=e.m[7]+e.m[5],t[5].normal.z=e.m[11]+e.m[9],t[5].d=e.m[15]+e.m[13],t[5].normalize()},e}();e.Frustum=f,function(e){e[e.LOCAL=0]="LOCAL",e[e.WORLD=1]="WORLD"}(e.Space||(e.Space={}));var d=(e.Space,function(){function e(){}return e.X=new o(1,0,0),e.Y=new o(0,1,0),e.Z=new o(0,0,1),e}());e.Axis=d;var p=function(){function e(){}return e.interpolate=function(e,t,i,r,n){for(var o=1-3*r+3*t,s=3*r-6*t,a=3*t,h=e,c=0;5>c;c++){var l=h*h,u=l*h,f=o*u+s*l+a*h,d=1/(3*o*l+2*s*h+a);h-=(f-e)*d,h=Math.min(1,Math.max(0,h))}return 3*Math.pow(1-h,2)*h*i+3*(1-h)*Math.pow(h,2)*n+Math.pow(h,3)},e}();e.BezierCurve=p,function(e){e[e.CW=0]="CW",e[e.CCW=1]="CCW"}(e.Orientation||(e.Orientation={}));var _=e.Orientation,m=function(){function e(e){var t=this;this.degrees=function(){return 180*t._radians/Math.PI},this.radians=function(){return t._radians},this._radians=e,this._radians<0&&(this._radians+=2*Math.PI)}return e.BetweenTwoPoints=function(t,i){var r=i.subtract(t),n=Math.atan2(r.y,r.x);return new e(n)},e.FromRadians=function(t){return new e(t)},e.FromDegrees=function(t){return new e(t*Math.PI/180)},e}();e.Angle=m;var g=function(){function e(e,t,i){this.startPoint=e,this.midPoint=t,this.endPoint=i;var r=Math.pow(t.x,2)+Math.pow(t.y,2),o=(Math.pow(e.x,2)+Math.pow(e.y,2)-r)/2,s=(r-Math.pow(i.x,2)-Math.pow(i.y,2))/2,a=(e.x-t.x)*(t.y-i.y)-(t.x-i.x)*(e.y-t.y);this.centerPoint=new n((o*(t.y-i.y)-s*(e.y-t.y))/a,((e.x-t.x)*s-(t.x-i.x)*o)/a),this.radius=this.centerPoint.subtract(this.startPoint).length(),this.startAngle=m.BetweenTwoPoints(this.centerPoint,this.startPoint);var h=this.startAngle.degrees(),c=m.BetweenTwoPoints(this.centerPoint,this.midPoint).degrees(),l=m.BetweenTwoPoints(this.centerPoint,this.endPoint).degrees();c-h>180&&(c-=360),-180>c-h&&(c+=360),l-c>180&&(l-=360),-180>l-c&&(l+=360),this.orientation=0>c-h?_.CW:_.CCW,this.angle=m.FromDegrees(this.orientation===_.CW?h-l:l-h)}return e}();e.Arc2=g;var v=function(){function e(e,t){this._points=new Array,this._length=0,this.closed=!1,this._points.push(new n(e,t))}return e.prototype.addLineTo=function(e,t){if(closed)return this;var i=new n(e,t),r=this._points[this._points.length-1];return this._points.push(i),this._length+=i.subtract(r).length(),this},e.prototype.addArcTo=function(e,t,i,r,o){if(void 0===o&&(o=36),closed)return this;var s=this._points[this._points.length-1],a=new n(e,t),h=new n(i,r),c=new g(s,a,h),l=c.angle.radians()/o;c.orientation===_.CW&&(l*=-1);for(var u=c.startAngle.radians()+l,f=0;o>f;f++){var d=Math.cos(u)*c.radius+c.centerPoint.x,p=Math.sin(u)*c.radius+c.centerPoint.y;this.addLineTo(d,p),u+=l}return this},e.prototype.close=function(){return this.closed=!0,this},e.prototype.length=function(){var e=this._length;if(!this.closed){var t=this._points[this._points.length-1],i=this._points[0];e+=i.subtract(t).length()}return e},e.prototype.getPoints=function(){return this._points},e.prototype.getPointAtLengthPosition=function(e){if(0>e||e>1)return n.Zero();for(var t=e*this.length(),i=0,r=0;r<this._points.length;r++){var o=(r+1)%this._points.length,s=this._points[r],a=this._points[o],h=a.subtract(s),c=h.length()+i;if(t>=i&&c>=t){var l=h.normalize(),u=t-i;return new n(s.x+l.x*u,s.y+l.y*u)}i=c}return n.Zero()},e.StartingAt=function(t,i){return new e(t,i)},e}();e.Path2=v;var y=function(){function i(e,t,i){this.path=e,this._curve=new Array,this._distances=new Array,this._tangents=new Array,this._normals=new Array,this._binormals=new Array;for(var r=0;r<e.length;r++)this._curve[r]=e[r].clone();this._raw=i||!1,this._compute(t)}return i.prototype.getCurve=function(){return this._curve},i.prototype.getTangents=function(){return this._tangents},i.prototype.getNormals=function(){return this._normals},i.prototype.getBinormals=function(){return this._binormals},i.prototype.getDistances=function(){return this._distances},i.prototype.update=function(e,t){for(var i=0;i<e.length;i++)this._curve[i].x=e[i].x,this._curve[i].y=e[i].y,this._curve[i].z=e[i].z;return this._compute(t),this},i.prototype._compute=function(e){var t=this._curve.length;this._tangents[0]=this._getFirstNonNullVector(0),this._raw||this._tangents[0].normalize(),this._tangents[t-1]=this._curve[t-1].subtract(this._curve[t-2]),this._raw||this._tangents[t-1].normalize();var i=this._tangents[0],r=this._normalVector(this._curve[0],i,e);this._normals[0]=r,this._raw||this._normals[0].normalize(),this._binormals[0]=o.Cross(i,this._normals[0]),this._raw||this._binormals[0].normalize(),this._distances[0]=0;for(var n,s,a,h,c=1;t>c;c++)n=this._getLastNonNullVector(c),t-1>c&&(s=this._getFirstNonNullVector(c),this._tangents[c]=n.add(s),this._tangents[c].normalize()),this._distances[c]=this._distances[c-1]+n.length(),a=this._tangents[c],h=this._binormals[c-1],this._normals[c]=o.Cross(h,a),this._raw||this._normals[c].normalize(),this._binormals[c]=o.Cross(a,this._normals[c]),this._raw||this._binormals[c].normalize()},i.prototype._getFirstNonNullVector=function(e){for(var t=1,i=this._curve[e+t].subtract(this._curve[e]);0===i.length()&&e+t+1<this._curve.length;)t++,i=this._curve[e+t].subtract(this._curve[e]);return i},i.prototype._getLastNonNullVector=function(e){for(var t=1,i=this._curve[e].subtract(this._curve[e-t]);0===i.length()&&e>t+1;)t++,i=this._curve[e].subtract(this._curve[e-t]);return i},i.prototype._normalVector=function(i,r,n){var s;if(void 0===n||null===n){var a;t.WithinEpsilon(r.y,1,e.Epsilon)?t.WithinEpsilon(r.x,1,e.Epsilon)?t.WithinEpsilon(r.z,1,e.Epsilon)||(a=new o(0,0,1)):a=new o(1,0,0):a=new o(0,-1,0),s=o.Cross(r,a)}else s=o.Cross(r,n),o.CrossToRef(s,r,s);return s.normalize(),s},i}();e.Path3D=y;var x=function(){function e(e){this._length=0,this._points=e,this._length=this._computeLength(e)}return e.CreateQuadraticBezier=function(t,i,r,n){n=n>2?n:3;for(var s=new Array,a=function(e,t,i,r){var n=(1-e)*(1-e)*t+2*e*(1-e)*i+e*e*r;return n},h=0;n>=h;h++)s.push(new o(a(h/n,t.x,i.x,r.x),a(h/n,t.y,i.y,r.y),a(h/n,t.z,i.z,r.z)));return new e(s)},e.CreateCubicBezier=function(t,i,r,n,s){s=s>3?s:4;for(var a=new Array,h=function(e,t,i,r,n){var o=(1-e)*(1-e)*(1-e)*t+3*e*(1-e)*(1-e)*i+3*e*e*(1-e)*r+e*e*e*n;return o},c=0;s>=c;c++)a.push(new o(h(c/s,t.x,i.x,r.x,n.x),h(c/s,t.y,i.y,r.y,n.y),h(c/s,t.z,i.z,r.z,n.z)));return new e(a)},e.CreateHermiteSpline=function(t,i,r,n,s){for(var a=new Array,h=1/s,c=0;s>=c;c++)a.push(o.Hermite(t,i,r,n,c*h));return new e(a)},e.prototype.getPoints=function(){return this._points},e.prototype.length=function(){return this._length},e.prototype["continue"]=function(t){for(var i=this._points[this._points.length-1],r=this._points.slice(),n=t.getPoints(),o=1;o<n.length;o++)r.push(n[o].subtract(n[0]).add(i));var s=new e(r);return s},e.prototype._computeLength=function(e){for(var t=0,i=1;i<e.length;i++)t+=e[i].subtract(e[i-1]).length();return t},e}();e.Curve3=x;var b=function(){function e(){this.L00=o.Zero(),this.L1_1=o.Zero(),this.L10=o.Zero(),this.L11=o.Zero(),this.L2_2=o.Zero(),this.L2_1=o.Zero(),this.L20=o.Zero(),this.L21=o.Zero(),this.L22=o.Zero()}return e.prototype.addLight=function(e,t,i){var r=new o(t.r,t.g,t.b),n=r.scale(i);this.L00=this.L00.add(n.scale(.282095)),this.L1_1=this.L1_1.add(n.scale(.488603*e.y)),this.L10=this.L10.add(n.scale(.488603*e.z)),this.L11=this.L11.add(n.scale(.488603*e.x)),this.L2_2=this.L2_2.add(n.scale(1.092548*e.x*e.y)),this.L2_1=this.L2_1.add(n.scale(1.092548*e.y*e.z)),this.L21=this.L21.add(n.scale(1.092548*e.x*e.z)),this.L20=this.L20.add(n.scale(.315392*(3*e.z*e.z-1))),this.L22=this.L22.add(n.scale(.546274*(e.x*e.x-e.y*e.y)))},e.prototype.scale=function(e){this.L00=this.L00.scale(e),this.L1_1=this.L1_1.scale(e),this.L10=this.L10.scale(e),this.L11=this.L11.scale(e),this.L2_2=this.L2_2.scale(e),this.L2_1=this.L2_1.scale(e),this.L20=this.L20.scale(e),this.L21=this.L21.scale(e),this.L22=this.L22.scale(e)},e}();e.SphericalHarmonics=b;var P=function(){function e(){this.x=o.Zero(),this.y=o.Zero(),this.z=o.Zero(),this.xx=o.Zero(),this.yy=o.Zero(),this.zz=o.Zero(),this.xy=o.Zero(),this.yz=o.Zero(),this.zx=o.Zero()}return e.prototype.addAmbient=function(e){var t=new o(e.r,e.g,e.b);this.xx=this.xx.add(t),this.yy=this.yy.add(t),this.zz=this.zz.add(t)},e.getSphericalPolynomialFromHarmonics=function(t){var i=new e;return i.x=t.L11.scale(1.02333),i.y=t.L1_1.scale(1.02333),i.z=t.L10.scale(1.02333),i.xx=t.L00.scale(.886277).subtract(t.L20.scale(.247708)).add(t.L22.scale(.429043)),i.yy=t.L00.scale(.886277).subtract(t.L20.scale(.247708)).subtract(t.L22.scale(.429043)),i.zz=t.L00.scale(.886277).add(t.L20.scale(.495417)),i.yz=t.L2_1.scale(.858086),i.zx=t.L21.scale(.858086),i.xy=t.L2_2.scale(.858086),i},e}();e.SphericalPolynomial=P;var A=function(){function e(e,t){void 0===e&&(e=o.Zero()),void 0===t&&(t=o.Up()),this.position=e,this.normal=t}return e.prototype.clone=function(){return new e(this.position.clone(),this.normal.clone())},e}();e.PositionNormalVertex=A;var T=function(){function e(e,t,i){void 0===e&&(e=o.Zero()),void 0===t&&(t=o.Up()),void 0===i&&(i=n.Zero()),this.position=e,this.normal=t,this.uv=i}return e.prototype.clone=function(){return new e(this.position.clone(),this.normal.clone(),this.uv.clone())},e}();e.PositionNormalTextureVertex=T;var E=function(){function e(){}return e.Color3=[i.Black(),i.Black(),i.Black()],e.Vector2=[n.Zero(),n.Zero(),n.Zero()],e.Vector3=[o.Zero(),o.Zero(),o.Zero(),o.Zero(),o.Zero(),o.Zero(),o.Zero(),o.Zero(),o.Zero()],e.Vector4=[s.Zero(),s.Zero(),s.Zero()],e.Quaternion=[new h(0,0,0,0)],e.Matrix=[c.Zero(),c.Zero(),c.Zero(),c.Zero(),c.Zero(),c.Zero(),c.Zero(),c.Zero()],e}();e.Tmp=E}(BABYLON||(BABYLON={}));var BABYLON;!function(e){function t(e,t){return function(i,r){i.__serializableMembers||(i.__serializableMembers={}),i.__serializableMembers[r]={type:e,sourceName:t}}}function i(e){return t(0,e)}function r(e){return t(1,e)}function n(e){return t(2,e)}function o(e){return t(3,e)}function s(e){return t(4,e)}function a(e){return t(5,e)}function h(e){return t(6,e)}function c(e){return t(7,e)}e.serialize=i,e.serializeAsTexture=r,e.serializeAsColor3=n,e.serializeAsFresnelParameters=o,e.serializeAsVector2=s,e.serializeAsVector3=a,e.serializeAsMeshReference=h,e.serializeAsColorCurves=c;var l=function(){function t(){}return t.Serialize=function(t,i){i||(i={}),i.tags=e.Tags.GetTags(t);for(var r in t.__serializableMembers){var n=t.__serializableMembers[r],o=n.sourceName||r,s=n.type,a=t[r];if(void 0!==a&&null!==a)switch(s){case 0:i[o]=a;break;case 1:i[o]=a.serialize();break;case 2:i[o]=a.asArray();break;case 3:i[o]=a.serialize();break;case 4:i[o]=a.asArray();break;case 5:i[o]=a.asArray();break;case 6:i[o]=a.id;break;case 7:i[o]=a.serialize()}}return i},t.Parse=function(t,i,r,n){var o=t();e.Tags.AddTagsTo(o,i.tags);for(var s in o.__serializableMembers){var a=o.__serializableMembers[s],h=i[a.sourceName||s],c=a.type;if(void 0!==h&&null!==h)switch(c){case 0:o[s]=h;break;case 1:o[s]=e.Texture.Parse(h,r,n);break;case 2:o[s]=e.Color3.FromArray(h);break;case 3:o[s]=e.FresnelParameters.Parse(h);break;case 4:o[s]=e.Vector2.FromArray(h);break;case 5:o[s]=e.Vector3.FromArray(h);break;case 6:o[s]=r.getLastMeshByID(h);break;case 7:o[s]=e.ColorCurves.Parse(h)}}return o},t.Clone=function(t,i){var r=t();e.Tags.AddTagsTo(r,i.tags);for(var n in r.__serializableMembers){var o=r.__serializableMembers[n],s=i[n],a=o.type;if(void 0!==s&&null!==s)switch(a){case 0:case 6:r[n]=s;break;case 1:case 2:case 3:case 4:case 5:case 7:r[n]=s.clone()}}return r},t}();e.SerializationHelper=l}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function e(e,t){void 0===t&&(t=!1),this.mask=e,this.skipNextObservers=t}return e}();e.EventState=t;var i=function(){function e(e,t){this.callback=e,this.mask=t}return e}();e.Observer=i;var r=function(){function e(){this._observers=new Array}return e.prototype.add=function(e,t,r){if(void 0===t&&(t=-1),void 0===r&&(r=!1),!e)return null;var n=new i(e,t);return r?this._observers.unshift(n):this._observers.push(n),n},e.prototype.remove=function(e){var t=this._observers.indexOf(e);return-1!==t?(this._observers.splice(t,1),!0):!1},e.prototype.removeCallback=function(e){for(var t=0;t<this._observers.length;t++)if(this._observers[t].callback===e)return this._observers.splice(t,1),!0;return!1},e.prototype.notifyObservers=function(e,i){void 0===i&&(i=-1);for(var r=new t(i),n=0,o=this._observers;n<o.length;n++){var s=o[n];if(s.mask&i&&s.callback(e,r),r.skipNextObservers)break}},e.prototype.hasObservers=function(){return this._observers.length>0},e.prototype.clear=function(){this._observers=new Array},e.prototype.clone=function(){var t=new e;return t._observers=this._observers.slice(0),t},e}();e.Observable=r}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(e,i){this.idbFactory=window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB,this.callbackManifestChecked=i,this.currentSceneUrl=t.ReturnFullUrlLocation(e),this.db=null,this.enableSceneOffline=!1,this.enableTexturesOffline=!1,this.manifestVersionFound=0,this.mustUpdateRessources=!1,this.hasReachedQuota=!1,t.IDBStorageEnabled?this.checkManifestFile():this.callbackManifestChecked(!0)}return t.prototype.checkManifestFile=function(){function t(){r.enableSceneOffline=!1,r.enableTexturesOffline=!1,r.callbackManifestChecked(!1)}var i=this,r=this,n=!1,o=this.currentSceneUrl+".manifest",s=new XMLHttpRequest;navigator.onLine&&(n=!0,o=o+(null==o.match(/\?/)?"?":"&")+(new Date).getTime()),s.open("GET",o,!0),s.addEventListener("load",function(){if(200===s.status||e.Tools.ValidateXHRData(s,1))try{var r=JSON.parse(s.response);i.enableSceneOffline=r.enableSceneOffline,i.enableTexturesOffline=r.enableTexturesOffline,r.version&&!isNaN(parseInt(r.version))&&(i.manifestVersionFound=r.version),i.callbackManifestChecked&&i.callbackManifestChecked(!0)}catch(n){t()}else t()},!1),s.addEventListener("error",function(e){if(n){n=!1;var r=i.currentSceneUrl+".manifest";s.open("GET",r,!0),s.send()}else t()},!1);try{s.send()}catch(a){e.Tools.Error("Error on XHR send request."),r.callbackManifestChecked(!1)}},t.prototype.openAsync=function(t,i){function r(){o.isSupported=!1,i&&i()}var n=this,o=this;if(this.idbFactory&&(this.enableSceneOffline||this.enableTexturesOffline))if(this.db)t&&t();else{this.hasReachedQuota=!1,this.isSupported=!0;var s=this.idbFactory.open("babylonjs",1);s.onerror=function(e){r()},s.onblocked=function(t){e.Tools.Error("IDB request blocked. Please reload the page."),r()},s.onsuccess=function(e){n.db=s.result,t()},s.onupgradeneeded=function(t){n.db=t.target.result;try{n.db.createObjectStore("scenes",{keyPath:"sceneUrl"}),n.db.createObjectStore("versions",{keyPath:"sceneUrl"}),n.db.createObjectStore("textures",{keyPath:"textureUrl"})}catch(i){e.Tools.Error("Error while creating object stores. Exception: "+i.message),r()}}}else this.isSupported=!1,i&&i()},t.prototype.loadImageFromDB=function(e,i){var r=this,n=t.ReturnFullUrlLocation(e),o=function(){r.hasReachedQuota||null===r.db?i.src=e:r._saveImageIntoDBAsync(n,i)};this.mustUpdateRessources?o():this._loadImageFromDBAsync(n,i,o)},t.prototype._loadImageFromDBAsync=function(t,i,r){if(this.isSupported&&null!==this.db){var n,o=this.db.transaction(["textures"]);o.onabort=function(e){i.src=t},o.oncomplete=function(o){var s;if(n){var a=window.URL||window.webkitURL;s=a.createObjectURL(n.data,{oneTimeOnly:!0}),i.onerror=function(){e.Tools.Error("Error loading image from blob URL: "+s+" switching back to web url: "+t),i.src=t},i.src=s}else r()};var s=o.objectStore("textures").get(t);s.onsuccess=function(e){n=e.target.result},s.onerror=function(r){e.Tools.Error("Error loading texture "+t+" from DB."),i.src=t}}else e.Tools.Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open."),i.src=t},t.prototype._saveImageIntoDBAsync=function(i,r){var n=this;if(this.isSupported){var o=function(){var e;if(s){var t=window.URL||window.webkitURL;try{e=t.createObjectURL(s,{oneTimeOnly:!0})}catch(i){e=t.createObjectURL(s)}}r.src=e};if(t.IsUASupportingBlobStorage){var s,a=new XMLHttpRequest;a.open("GET",i,!0),a.responseType="blob",a.addEventListener("load",function(){if(200===a.status){s=a.response;var e=n.db.transaction(["textures"],"readwrite");e.onabort=function(e){try{e.srcElement.error&&"QuotaExceededError"===e.srcElement.error.name&&(this.hasReachedQuota=!0)}catch(t){}o()},e.oncomplete=function(e){o()};var h={textureUrl:i,data:s};try{var c=e.objectStore("textures").put(h);c.onsuccess=function(e){},c.onerror=function(e){o()}}catch(l){25===l.code&&(t.IsUASupportingBlobStorage=!1),r.src=i}}else r.src=i},!1),a.addEventListener("error",function(t){e.Tools.Error("Error in XHR request in BABYLON.Database."),r.src=i},!1),a.send()}else r.src=i}else e.Tools.Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open."),r.src=i},t.prototype._checkVersionFromDB=function(e,t){var i=this,r=function(r){i._saveVersionIntoDBAsync(e,t)};this._loadVersionFromDBAsync(e,t,r)},t.prototype._loadVersionFromDBAsync=function(t,i,r){var n=this;if(this.isSupported){var o;try{var s=this.db.transaction(["versions"]);s.oncomplete=function(e){o?n.manifestVersionFound>o.data?(n.mustUpdateRessources=!0,r()):i(o.data):(n.mustUpdateRessources=!0,r())},s.onabort=function(e){i(-1)};var a=s.objectStore("versions").get(t);a.onsuccess=function(e){o=e.target.result},a.onerror=function(r){e.Tools.Error("Error loading version for scene "+t+" from DB."),i(-1)}}catch(h){e.Tools.Error("Error while accessing 'versions' object store (READ OP). Exception: "+h.message),i(-1)}}else e.Tools.Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open."),i(-1)},t.prototype._saveVersionIntoDBAsync=function(t,i){var r=this;if(this.isSupported&&!this.hasReachedQuota)try{var n=this.db.transaction(["versions"],"readwrite");n.onabort=function(e){try{e.srcElement.error&&"QuotaExceededError"===e.srcElement.error.name&&(r.hasReachedQuota=!0)}catch(t){}i(-1)},n.oncomplete=function(e){i(r.manifestVersionFound)};var o={sceneUrl:t,data:this.manifestVersionFound},s=n.objectStore("versions").put(o);s.onsuccess=function(e){},s.onerror=function(t){e.Tools.Error("Error in DB add version request in BABYLON.Database.")}}catch(a){e.Tools.Error("Error while accessing 'versions' object store (WRITE OP). Exception: "+a.message),i(-1)}else i(-1)},t.prototype.loadFileFromDB=function(e,i,r,n,o){var s=this,a=t.ReturnFullUrlLocation(e),h=function(e){s._saveFileIntoDBAsync(a,i,r)};this._checkVersionFromDB(a,function(e){-1!==e?s.mustUpdateRessources?s._saveFileIntoDBAsync(a,i,r,o):s._loadFileFromDBAsync(a,i,h,o):n()})},t.prototype._loadFileFromDBAsync=function(t,i,r,n){if(this.isSupported){var o;o=-1!==t.indexOf(".babylon")?"scenes":"textures";var s,a=this.db.transaction([o]);a.oncomplete=function(e){s?i(s.data):r()},a.onabort=function(e){r()};var h=a.objectStore(o).get(t);h.onsuccess=function(e){s=e.target.result},h.onerror=function(i){e.Tools.Error("Error loading file "+t+" from DB."),r()}}else e.Tools.Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open."),i()},t.prototype._saveFileIntoDBAsync=function(t,i,r,n){var o=this;if(this.isSupported){var s;s=-1!==t.indexOf(".babylon")?"scenes":"textures";var a,h=new XMLHttpRequest;h.open("GET",t,!0),n&&(h.responseType="arraybuffer"),h.onprogress=r,h.addEventListener("load",function(){if(200===h.status||e.Tools.ValidateXHRData(h,n?6:1))if(a=n?h.response:h.responseText,o.hasReachedQuota)i(a);else{var r=o.db.transaction([s],"readwrite");r.onabort=function(e){try{e.srcElement.error&&"QuotaExceededError"===e.srcElement.error.name&&(this.hasReachedQuota=!0)}catch(t){}i(a)},r.oncomplete=function(e){i(a)};var c;c="scenes"===s?{sceneUrl:t,data:a,version:o.manifestVersionFound}:{textureUrl:t,data:a};try{var l=r.objectStore(s).put(c);l.onsuccess=function(e){},l.onerror=function(t){e.Tools.Error("Error in DB add file request in BABYLON.Database.")}}catch(u){i(a)}}else i()},!1),h.addEventListener("error",function(t){e.Tools.Error("error on XHR request."),i()},!1),h.send()}else e.Tools.Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open."),i()},t.IsUASupportingBlobStorage=!0,t.IDBStorageEnabled=!0,t.parseURL=function(e){var t=document.createElement("a");t.href=e;var i=e.substring(0,e.lastIndexOf("#")),r=e.substring(i.lastIndexOf("/")+1,e.length),n=e.substring(0,e.indexOf(r,0));return n},t.ReturnFullUrlLocation=function(e){return-1===e.indexOf("http:/")?t.parseURL(window.location.href)+e:e},t}();e.Database=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t;!function(t){var i=function(){function t(){}return t.GetTGAHeader=function(e){var t=0,i={id_length:e[t++],colormap_type:e[t++],image_type:e[t++],
  3. colormap_index:e[t++]|e[t++]<<8,colormap_length:e[t++]|e[t++]<<8,colormap_size:e[t++],origin:[e[t++]|e[t++]<<8,e[t++]|e[t++]<<8],width:e[t++]|e[t++]<<8,height:e[t++]|e[t++]<<8,pixel_size:e[t++],flags:e[t++]};return i},t.UploadContent=function(i,r){if(r.length<19)return void e.Tools.Error("Unable to load TGA file - Not enough data to contain header");var n=18,o=t.GetTGAHeader(r);if(o.id_length+n>r.length)return void e.Tools.Error("Unable to load TGA file - Not enough data");n+=o.id_length;var s=!1,a=!1,h=!1,c=!1;switch(o.image_type){case t._TYPE_RLE_INDEXED:s=!0;case t._TYPE_INDEXED:a=!0;break;case t._TYPE_RLE_RGB:s=!0;case t._TYPE_RGB:h=!0;break;case t._TYPE_RLE_GREY:s=!0;case t._TYPE_GREY:c=!0}var l,u,f=(15&o.flags,o.pixel_size>>3),d=o.width*o.height*f;if(a&&(u=r.subarray(n,n+=o.colormap_length*(o.colormap_size>>3))),s){l=new Uint8Array(d);for(var p,_,m,g=0,v=new Uint8Array(f);d>n&&d>g;)if(p=r[n++],_=(127&p)+1,128&p){for(m=0;f>m;++m)v[m]=r[n++];for(m=0;_>m;++m)l.set(v,g+m*f);g+=f*_}else{for(_*=f,m=0;_>m;++m)l[g+m]=r[n++];g+=_}}else l=r.subarray(n,n+=a?o.width*o.height:d);var y,x,b,P,A,T;switch((o.flags&t._ORIGIN_MASK)>>t._ORIGIN_SHIFT){default:case t._ORIGIN_UL:y=0,b=1,T=o.width,x=0,P=1,A=o.height;break;case t._ORIGIN_BL:y=0,b=1,T=o.width,x=o.height-1,P=-1,A=-1;break;case t._ORIGIN_UR:y=o.width-1,b=-1,T=-1,x=0,P=1,A=o.height;break;case t._ORIGIN_BR:y=o.width-1,b=-1,T=-1,x=o.height-1,P=-1,A=-1}var E="_getImageData"+(c?"Grey":"")+o.pixel_size+"bits",C=t[E](o,u,l,x,P,A,y,b,T);i.texImage2D(i.TEXTURE_2D,0,i.RGBA,o.width,o.height,0,i.RGBA,i.UNSIGNED_BYTE,C)},t._getImageData8bits=function(e,t,i,r,n,o,s,a,h){var c,l,u,f=i,d=t,p=e.width,_=e.height,m=0,g=new Uint8Array(p*_*4);for(u=r;u!==o;u+=n)for(l=s;l!==h;l+=a,m++)c=f[m],g[4*(l+p*u)+3]=255,g[4*(l+p*u)+2]=d[3*c+0],g[4*(l+p*u)+1]=d[3*c+1],g[4*(l+p*u)+0]=d[3*c+2];return g},t._getImageData16bits=function(e,t,i,r,n,o,s,a,h){var c,l,u,f=i,d=e.width,p=e.height,_=0,m=new Uint8Array(d*p*4);for(u=r;u!==o;u+=n)for(l=s;l!==h;l+=a,_+=2)c=f[_+0]+(f[_+1]<<8),m[4*(l+d*u)+0]=(31744&c)>>7,m[4*(l+d*u)+1]=(992&c)>>2,m[4*(l+d*u)+2]=(31&c)>>3,m[4*(l+d*u)+3]=32768&c?0:255;return m},t._getImageData24bits=function(e,t,i,r,n,o,s,a,h){var c,l,u=i,f=e.width,d=e.height,p=0,_=new Uint8Array(f*d*4);for(l=r;l!==o;l+=n)for(c=s;c!==h;c+=a,p+=3)_[4*(c+f*l)+3]=255,_[4*(c+f*l)+2]=u[p+0],_[4*(c+f*l)+1]=u[p+1],_[4*(c+f*l)+0]=u[p+2];return _},t._getImageData32bits=function(e,t,i,r,n,o,s,a,h){var c,l,u=i,f=e.width,d=e.height,p=0,_=new Uint8Array(f*d*4);for(l=r;l!==o;l+=n)for(c=s;c!==h;c+=a,p+=4)_[4*(c+f*l)+2]=u[p+0],_[4*(c+f*l)+1]=u[p+1],_[4*(c+f*l)+0]=u[p+2],_[4*(c+f*l)+3]=u[p+3];return _},t._getImageDataGrey8bits=function(e,t,i,r,n,o,s,a,h){var c,l,u,f=i,d=e.width,p=e.height,_=0,m=new Uint8Array(d*p*4);for(u=r;u!==o;u+=n)for(l=s;l!==h;l+=a,_++)c=f[_],m[4*(l+d*u)+0]=c,m[4*(l+d*u)+1]=c,m[4*(l+d*u)+2]=c,m[4*(l+d*u)+3]=255;return m},t._getImageDataGrey16bits=function(e,t,i,r,n,o,s,a,h){var c,l,u=i,f=e.width,d=e.height,p=0,_=new Uint8Array(f*d*4);for(l=r;l!==o;l+=n)for(c=s;c!==h;c+=a,p+=2)_[4*(c+f*l)+0]=u[p+0],_[4*(c+f*l)+1]=u[p+0],_[4*(c+f*l)+2]=u[p+0],_[4*(c+f*l)+3]=u[p+1];return _},t._TYPE_NO_DATA=0,t._TYPE_INDEXED=1,t._TYPE_RGB=2,t._TYPE_GREY=3,t._TYPE_RLE_INDEXED=9,t._TYPE_RLE_RGB=10,t._TYPE_RLE_GREY=11,t._ORIGIN_MASK=48,t._ORIGIN_SHIFT=4,t._ORIGIN_BL=0,t._ORIGIN_BR=1,t._ORIGIN_UL=2,t._ORIGIN_UR=3,t}();t.TGATools=i}(t=e.Internals||(e.Internals={}))}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function e(t){this.length=0,this._duplicateId=0,this.data=new Array(t),this._id=e._GlobalId++}return e.prototype.push=function(e){this.data[this.length++]=e,this.length>this.data.length&&(this.data.length*=2),e.__smartArrayFlags||(e.__smartArrayFlags={}),e.__smartArrayFlags[this._id]=this._duplicateId},e.prototype.pushNoDuplicate=function(e){return e.__smartArrayFlags&&e.__smartArrayFlags[this._id]===this._duplicateId?!1:(this.push(e),!0)},e.prototype.sort=function(e){this.data.sort(e)},e.prototype.reset=function(){this.length=0,this._duplicateId++},e.prototype.concat=function(e){if(0!==e.length){this.length+e.length>this.data.length&&(this.data.length=2*(this.length+e.length));for(var t=0;t<e.length;t++)this.data[this.length++]=(e.data||e)[t]}},e.prototype.concatWithNoDuplicate=function(e){if(0!==e.length){this.length+e.length>this.data.length&&(this.data.length=2*(this.length+e.length));for(var t=0;t<e.length;t++){var i=(e.data||e)[t];this.pushNoDuplicate(i)}}},e.prototype.indexOf=function(e){var t=this.data.indexOf(e);return t>=this.length?-1:t},e._GlobalId=0,e}();e.SmartArray=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function e(){this._count=0,this._data={}}return e.prototype.get=function(e){var t=this._data[e];return void 0!==t?t:void 0},e.prototype.getOrAddWithFactory=function(e,t){var i=this.get(e);return void 0!==i?i:(i=t(e),i&&this.add(e,i),i)},e.prototype.getOrAdd=function(e,t){var i=this.get(e);return void 0!==i?i:(this.add(e,t),t)},e.prototype.contains=function(e){return void 0!==this._data[e]},e.prototype.add=function(e,t){return void 0!==this._data[e]?!1:(this._data[e]=t,++this._count,!0)},e.prototype.set=function(e,t){return void 0===this._data[e]?!1:(this._data[e]=t,!0)},e.prototype.remove=function(e){return this.contains(e)?(delete this._data[e],--this._count,!0):!1},e.prototype.clear=function(){this._data={},this._count=0},Object.defineProperty(e.prototype,"count",{get:function(){return this._count},enumerable:!0,configurable:!0}),e.prototype.forEach=function(e){for(var t in this._data){var i=this._data[t];e(t,i)}},e.prototype.first=function(e){for(var t in this._data){var i=this._data[t],r=e(t,i);if(r)return r}return null},e}();e.StringDictionary=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){function t(e){return function(t){t.__bjsclassName__=e}}var i,r=function(t,i){return t?t instanceof e.Mesh?null:t instanceof e.SubMesh?t.clone(i):t.clone?t.clone():null:null},n=function(){function t(){}return t.Instantiate=function(e){for(var t=e.split("."),i=window||this,r=0,n=t.length;n>r;r++)i=i[t[r]];return"function"!=typeof i?null:i},t.SetImmediate=function(e){window.setImmediate?window.setImmediate(e):setTimeout(e,1)},t.IsExponentOfTwo=function(e){var t=1;do t*=2;while(e>t);return t===e},t.GetExponentOfTwo=function(e,t){var i=1;do i*=2;while(e>i);return i>t&&(i=t),i},t.GetFilename=function(e){var t=e.lastIndexOf("/");return 0>t?e:e.substring(t+1)},t.GetDOMTextContent=function(e){for(var t="",i=e.firstChild;i;)3===i.nodeType&&(t+=i.textContent),i=i.nextSibling;return t},t.ToDegrees=function(e){return 180*e/Math.PI},t.ToRadians=function(e){return e*Math.PI/180},t.EncodeArrayBufferTobase64=function(e){for(var t,i,r,n,o,s,a,h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",c="",l=0,u=new Uint8Array(e);l<u.length;)t=u[l++],i=l<u.length?u[l++]:Number.NaN,r=l<u.length?u[l++]:Number.NaN,n=t>>2,o=(3&t)<<4|i>>4,s=(15&i)<<2|r>>6,a=63&r,isNaN(i)?s=a=64:isNaN(r)&&(a=64),c+=h.charAt(n)+h.charAt(o)+h.charAt(s)+h.charAt(a);return"data:image/png;base64,"+c},t.ExtractMinAndMaxIndexed=function(t,i,r,n,o){void 0===o&&(o=null);for(var s=new e.Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),a=new e.Vector3(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),h=r;r+n>h;h++){var c=new e.Vector3(t[3*i[h]],t[3*i[h]+1],t[3*i[h]+2]);s=e.Vector3.Minimize(c,s),a=e.Vector3.Maximize(c,a)}return o&&(s.x-=s.x*o.x+o.y,s.y-=s.y*o.x+o.y,s.z-=s.z*o.x+o.y,a.x+=a.x*o.x+o.y,a.y+=a.y*o.x+o.y,a.z+=a.z*o.x+o.y),{minimum:s,maximum:a}},t.ExtractMinAndMax=function(t,i,r,n,o){void 0===n&&(n=null);var s=new e.Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),a=new e.Vector3(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);o||(o=3);for(var h=i;i+r>h;h++){var c=new e.Vector3(t[h*o],t[h*o+1],t[h*o+2]);s=e.Vector3.Minimize(c,s),a=e.Vector3.Maximize(c,a)}return n&&(s.x-=s.x*n.x+n.y,s.y-=s.y*n.x+n.y,s.z-=s.z*n.x+n.y,a.x+=a.x*n.x+n.y,a.y+=a.y*n.x+n.y,a.z+=a.z*n.x+n.y),{minimum:s,maximum:a}},t.Vector2ArrayFeeder=function(t){return function(i){var r=void 0!==t.BYTES_PER_ELEMENT,n=r?t.length/2:t.length;if(i>=n)return null;if(r){var o=t;return new e.Vector2(o[2*i+0],o[2*i+1])}var s=t;return s[i]}},t.ExtractMinAndMaxVector2=function(t,i){void 0===i&&(i=null);for(var r=new e.Vector2(Number.MAX_VALUE,Number.MAX_VALUE),n=new e.Vector2(-Number.MAX_VALUE,-Number.MAX_VALUE),o=0,s=t(o++);s;)r=e.Vector2.Minimize(s,r),n=e.Vector2.Maximize(s,n),s=t(o++);return i&&(r.x-=r.x*i.x+i.y,r.y-=r.y*i.x+i.y,n.x+=n.x*i.x+i.y,n.y+=n.y*i.x+i.y),{minimum:r,maximum:n}},t.MakeArray=function(e,t){return t===!0||void 0!==e&&null!=e?Array.isArray(e)?e:[e]:void 0},t.GetPointerPrefix=function(){var e="pointer";return window.PointerEvent||navigator.pointerEnabled||(e="mouse"),e},t.QueueNewFrame=function(e){window.requestAnimationFrame?window.requestAnimationFrame(e):window.msRequestAnimationFrame?window.msRequestAnimationFrame(e):window.webkitRequestAnimationFrame?window.webkitRequestAnimationFrame(e):window.mozRequestAnimationFrame?window.mozRequestAnimationFrame(e):window.oRequestAnimationFrame?window.oRequestAnimationFrame(e):window.setTimeout(e,16)},t.RequestFullscreen=function(e,t){var i=e.requestFullscreen||e.msRequestFullscreen||e.webkitRequestFullscreen||e.mozRequestFullScreen;i&&i.call(e,t)},t.ExitFullscreen=function(){document.exitFullscreen?document.exitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitCancelFullScreen?document.webkitCancelFullScreen():document.msCancelFullScreen&&document.msCancelFullScreen()},t.CleanUrl=function(e){return e=e.replace(/#/gm,"%23")},t.LoadImage=function(i,r,n,o){i instanceof ArrayBuffer&&(i=t.EncodeArrayBufferTobase64(i)),i=t.CleanUrl(i);var s=new Image;if("data:"!==i.substr(0,5)&&t.CorsBehavior)switch(typeof t.CorsBehavior){case"function":var a=t.CorsBehavior(i);a&&(s.crossOrigin=a);break;case"string":default:s.crossOrigin=t.CorsBehavior}s.onload=function(){r(s)},s.onerror=function(e){t.Error("Error while trying to load texture: "+i),t.UseFallbackTexture?(s.src="data:image/jpg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD/4QBmRXhpZgAATU0AKgAAAAgABAEaAAUAAAABAAAAPgEbAAUAAAABAAAARgEoAAMAAAABAAIAAAExAAIAAAAQAAAATgAAAAAAAABgAAAAAQAAAGAAAAABcGFpbnQubmV0IDQuMC41AP/bAEMABAIDAwMCBAMDAwQEBAQFCQYFBQUFCwgIBgkNCw0NDQsMDA4QFBEODxMPDAwSGBITFRYXFxcOERkbGRYaFBYXFv/bAEMBBAQEBQUFCgYGChYPDA8WFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFv/AABEIAQABAAMBIgACEQEDEQH/xAAfAAABBQEBAQEBAQAAAAAAAAAAAQIDBAUGBwgJCgv/xAC1EAACAQMDAgQDBQUEBAAAAX0BAgMABBEFEiExQQYTUWEHInEUMoGRoQgjQrHBFVLR8CQzYnKCCQoWFxgZGiUmJygpKjQ1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4eLj5OXm5+jp6vHy8/T19vf4+fr/xAAfAQADAQEBAQEBAQEBAAAAAAAAAQIDBAUGBwgJCgv/xAC1EQACAQIEBAMEBwUEBAABAncAAQIDEQQFITEGEkFRB2FxEyIygQgUQpGhscEJIzNS8BVictEKFiQ04SXxFxgZGiYnKCkqNTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqCg4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2dri4+Tl5ufo6ery8/T19vf4+fr/2gAMAwEAAhEDEQA/APH6KKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FCiiigD6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++gooooA+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gUKKKKAPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76CiiigD5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BQooooA+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/voKKKKAPl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FCiiigD6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++gooooA+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gUKKKKAPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76CiiigD5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BQooooA+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/voKKKKAPl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FCiiigD6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++gooooA+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gUKKKKAPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76P//Z",r(s)):n()};var h=function(){s.src=i},c=function(){o.loadImageFromDB(i,s)};if("data:"!==i.substr(0,5)&&o&&o.enableTexturesOffline&&e.Database.IsUASupportingBlobStorage)o.openAsync(c,h);else if(-1===i.indexOf("file:"))h();else try{var l,u=i.substring(5).toLowerCase();try{l=URL.createObjectURL(e.FilesInput.FilesTextures[u],{oneTimeOnly:!0})}catch(f){l=URL.createObjectURL(e.FilesInput.FilesTextures[u])}s.src=l}catch(d){s.src=null}return s},t.LoadFile=function(i,r,n,o,s,a){i=t.CleanUrl(i);var h=function(){var e=new XMLHttpRequest,o=t.BaseUrl+i;e.open("GET",o,!0),s&&(e.responseType="arraybuffer"),e.onprogress=n,e.onreadystatechange=function(){if(4===e.readyState)if(200===e.status||t.ValidateXHRData(e,s?6:1))r(s?e.response:e.responseText);else{if(!a)throw new Error("Error status: "+e.status+" - Unable to load "+o);a()}},e.send(null)},c=function(){o.loadFileFromDB(i,r,n,h,s)};if(-1!==i.indexOf("file:")){var l=i.substring(5).toLowerCase();t.ReadFile(e.FilesInput.FilesToLoad[l],r,n,s)}else o&&o.enableSceneOffline?o.openAsync(c,h):h()},t.ReadFileAsDataURL=function(e,t,i){var r=new FileReader;r.onload=function(e){t(e.target.result)},r.onprogress=i,r.readAsDataURL(e)},t.ReadFile=function(e,i,r,n){var o=new FileReader;o.onerror=function(r){t.Log("Error while reading file: "+e.name),i(JSON.stringify({autoClear:!0,clearColor:[1,0,0],ambientColor:[0,0,0],gravity:[0,-9.807,0],meshes:[],cameras:[],lights:[]}))},o.onload=function(e){i(e.target.result)},o.onprogress=r,n?o.readAsArrayBuffer(e):o.readAsText(e)},t.FileAsURL=function(e){var t=new Blob([e]),i=window.URL||window.webkitURL,r=i.createObjectURL(t);return r},t.Format=function(e,t){return void 0===t&&(t=2),e.toFixed(t)},t.CheckExtends=function(e,t,i){e.x<t.x&&(t.x=e.x),e.y<t.y&&(t.y=e.y),e.z<t.z&&(t.z=e.z),e.x>i.x&&(i.x=e.x),e.y>i.y&&(i.y=e.y),e.z>i.z&&(i.z=e.z)},t.DeepCopy=function(e,t,i,n){for(var o in e)if(("_"!==o[0]||n&&-1!==n.indexOf(o))&&(!i||-1===i.indexOf(o))){var s=e[o],a=typeof s;if("function"!==a)if("object"===a)if(s instanceof Array){if(t[o]=[],s.length>0)if("object"==typeof s[0])for(var h=0;h<s.length;h++){var c=r(s[h],t);-1===t[o].indexOf(c)&&t[o].push(c)}else t[o]=s.slice(0)}else t[o]=r(s,t);else t[o]=s}},t.IsEmpty=function(e){for(var t in e)return!1;return!0},t.RegisterTopRootEvents=function(e){for(var t=0;t<e.length;t++){var i=e[t];window.addEventListener(i.name,i.handler,!1);try{window.parent&&window.parent.addEventListener(i.name,i.handler,!1)}catch(r){}}},t.UnregisterTopRootEvents=function(e){for(var t=0;t<e.length;t++){var i=e[t];window.removeEventListener(i.name,i.handler);try{window.parent&&window.parent.removeEventListener(i.name,i.handler)}catch(r){}}},t.DumpFramebuffer=function(e,t,r,n){for(var o=4*e,s=t/2,a=r.readPixels(0,0,e,t),h=0;s>h;h++)for(var c=0;o>c;c++){var l=c+h*o,u=t-h-1,f=c+u*o,d=a[l];a[l]=a[f],a[f]=d}i||(i=document.createElement("canvas")),i.width=e,i.height=t;var p=i.getContext("2d"),_=p.createImageData(e,t),m=_.data;m.set(a),p.putImageData(_,0,0);var g=i.toDataURL();if(n)n(g);else if("download"in document.createElement("a")){var v=window.document.createElement("a");v.href=g;var y=new Date,x=(y.getFullYear()+"-"+(y.getMonth()+1)).slice(-2)+"-"+y.getDate()+"_"+y.getHours()+"-"+("0"+y.getMinutes()).slice(-2);v.setAttribute("download","screenshot_"+x+".png"),window.document.body.appendChild(v),v.addEventListener("click",function(){v.parentElement.removeChild(v)}),v.click()}else{var b=window.open(""),P=b.document.createElement("img");P.src=g,b.document.body.appendChild(P)}},t.CreateScreenshot=function(i,r,n,o){var s,a;if(n.precision)s=Math.round(i.getRenderWidth()*n.precision),a=Math.round(s/i.getAspectRatio(r)),n={width:s,height:a};else if(n.width&&n.height)s=n.width,a=n.height;else if(n.width&&!n.height)s=n.width,a=Math.round(s/i.getAspectRatio(r)),n={width:s,height:a};else if(n.height&&!n.width)a=n.height,s=Math.round(a*i.getAspectRatio(r)),n={width:s,height:a};else{if(isNaN(n))return void t.Error("Invalid 'size' parameter !");a=n,s=n}var h=r.getScene(),c=null;h.activeCamera!==r&&(c=h.activeCamera,h.activeCamera=r);var l=new e.RenderTargetTexture("screenShot",n,h,!1,!1);l.renderList=h.meshes,l.onAfterRenderObservable.add(function(){t.DumpFramebuffer(s,a,i,o)}),h.incrementRenderId(),h.resetCachedMaterial(),l.render(!0),l.dispose(),c&&(h.activeCamera=c),r.getProjectionMatrix(!0)},t.ValidateXHRData=function(t,i){void 0===i&&(i=7);try{if(1&i){if(t.responseText&&t.responseText.length>0)return!0;if(1===i)return!1}if(2&i){var r=e.Internals.TGATools.GetTGAHeader(t.response);if(r.width&&r.height&&r.width>0&&r.height>0)return!0;if(2===i)return!1}if(4&i){var n=new Uint8Array(t.response,0,3);return 68===n[0]&&68===n[1]&&83===n[2]}}catch(o){}return!1},Object.defineProperty(t,"NoneLogLevel",{get:function(){return t._NoneLogLevel},enumerable:!0,configurable:!0}),Object.defineProperty(t,"MessageLogLevel",{get:function(){return t._MessageLogLevel},enumerable:!0,configurable:!0}),Object.defineProperty(t,"WarningLogLevel",{get:function(){return t._WarningLogLevel},enumerable:!0,configurable:!0}),Object.defineProperty(t,"ErrorLogLevel",{get:function(){return t._ErrorLogLevel},enumerable:!0,configurable:!0}),Object.defineProperty(t,"AllLogLevel",{get:function(){return t._MessageLogLevel|t._WarningLogLevel|t._ErrorLogLevel},enumerable:!0,configurable:!0}),t._AddLogEntry=function(e){t._LogCache=e+t._LogCache,t.OnNewCacheEntry&&t.OnNewCacheEntry(e)},t._FormatMessage=function(e){var t=function(e){return 10>e?"0"+e:""+e},i=new Date;return"["+t(i.getHours())+":"+t(i.getMinutes())+":"+t(i.getSeconds())+"]: "+e},t._LogDisabled=function(e){},t._LogEnabled=function(e){var i=t._FormatMessage(e);console.log("BJS - "+i);var r="<div style='color:white'>"+i+"</div><br>";t._AddLogEntry(r)},t._WarnDisabled=function(e){},t._WarnEnabled=function(e){var i=t._FormatMessage(e);console.warn("BJS - "+i);var r="<div style='color:orange'>"+i+"</div><br>";t._AddLogEntry(r)},t._ErrorDisabled=function(e){},t._ErrorEnabled=function(e){t.errorsCount++;var i=t._FormatMessage(e);console.error("BJS - "+i);var r="<div style='color:red'>"+i+"</div><br>";t._AddLogEntry(r)},Object.defineProperty(t,"LogCache",{get:function(){return t._LogCache},enumerable:!0,configurable:!0}),t.ClearLogCache=function(){t._LogCache="",t.errorsCount=0},Object.defineProperty(t,"LogLevels",{set:function(e){(e&t.MessageLogLevel)===t.MessageLogLevel?t.Log=t._LogEnabled:t.Log=t._LogDisabled,(e&t.WarningLogLevel)===t.WarningLogLevel?t.Warn=t._WarnEnabled:t.Warn=t._WarnDisabled,(e&t.ErrorLogLevel)===t.ErrorLogLevel?t.Error=t._ErrorEnabled:t.Error=t._ErrorDisabled},enumerable:!0,configurable:!0}),Object.defineProperty(t,"PerformanceNoneLogLevel",{get:function(){return t._PerformanceNoneLogLevel},enumerable:!0,configurable:!0}),Object.defineProperty(t,"PerformanceUserMarkLogLevel",{get:function(){return t._PerformanceUserMarkLogLevel},enumerable:!0,configurable:!0}),Object.defineProperty(t,"PerformanceConsoleLogLevel",{get:function(){return t._PerformanceConsoleLogLevel},enumerable:!0,configurable:!0}),Object.defineProperty(t,"PerformanceLogLevel",{set:function(e){return(e&t.PerformanceUserMarkLogLevel)===t.PerformanceUserMarkLogLevel?(t.StartPerformanceCounter=t._StartUserMark,void(t.EndPerformanceCounter=t._EndUserMark)):(e&t.PerformanceConsoleLogLevel)===t.PerformanceConsoleLogLevel?(t.StartPerformanceCounter=t._StartPerformanceConsole,void(t.EndPerformanceCounter=t._EndPerformanceConsole)):(t.StartPerformanceCounter=t._StartPerformanceCounterDisabled,void(t.EndPerformanceCounter=t._EndPerformanceCounterDisabled))},enumerable:!0,configurable:!0}),t._StartPerformanceCounterDisabled=function(e,t){},t._EndPerformanceCounterDisabled=function(e,t){},t._StartUserMark=function(e,i){void 0===i&&(i=!0),i&&t._performance.mark&&t._performance.mark(e+"-Begin")},t._EndUserMark=function(e,i){void 0===i&&(i=!0),i&&t._performance.mark&&(t._performance.mark(e+"-End"),t._performance.measure(e,e+"-Begin",e+"-End"))},t._StartPerformanceConsole=function(e,i){void 0===i&&(i=!0),i&&(t._StartUserMark(e,i),console.time&&console.time(e))},t._EndPerformanceConsole=function(e,i){void 0===i&&(i=!0),i&&(t._EndUserMark(e,i),console.time&&console.timeEnd(e))},Object.defineProperty(t,"Now",{get:function(){return window.performance&&window.performance.now?window.performance.now():(new Date).getTime()},enumerable:!0,configurable:!0}),t.getClassName=function(e,t){void 0===t&&(t=!1);var i=null;if(!t&&e.getClassName)i=e.getClassName();else{if(e instanceof Object){var r=t?e:Object.getPrototypeOf(e);i=r.constructor.__bjsclassName__}i||(i=typeof e)}return i},t.first=function(e,t){for(var i=0;i<e.length;i++){var r=e[i];if(t(r))return r}},t.arrayOrStringFeeder=function(e){return function(i){if(i>=e.length)return null;var r=e.charCodeAt?e.charCodeAt(i):e[i];return r&&r.getHashCode&&(r=r.getHashCode()),"string"==typeof r?t.hashCodeFromStream(t.arrayOrStringFeeder(r)):r}},t.hashCodeFromStream=function(e){for(var t=0,i=0,r=e(i++);null!=r;)t=(t<<5)-t+r,t|=0,r=e(i++);return t},t.BaseUrl="",t.CorsBehavior="anonymous",t.UseFallbackTexture=!0,t._NoneLogLevel=0,t._MessageLogLevel=1,t._WarningLogLevel=2,t._ErrorLogLevel=4,t._LogCache="",t.errorsCount=0,t.Log=t._LogEnabled,t.Warn=t._WarnEnabled,t.Error=t._ErrorEnabled,t._PerformanceNoneLogLevel=0,t._PerformanceUserMarkLogLevel=1,t._PerformanceConsoleLogLevel=2,t._performance=window.performance,t.StartPerformanceCounter=t._StartPerformanceCounterDisabled,t.EndPerformanceCounter=t._EndPerformanceCounterDisabled,t}();e.Tools=n,e.className=t;var o=function(){function e(e,t,i,r){void 0===r&&(r=0),this.iterations=e,this._fn=t,this._successCallback=i,this.index=r-1,this._done=!1}return e.prototype.executeNext=function(){this._done||(this.index+1<this.iterations?(++this.index,this._fn(this)):this.breakLoop())},e.prototype.breakLoop=function(){this._done=!0,this._successCallback()},e.Run=function(t,i,r,n){void 0===n&&(n=0);var o=new e(t,i,r,n);return o.executeNext(),o},e.SyncAsyncForLoop=function(t,i,r,n,o,s){void 0===s&&(s=0),e.Run(Math.ceil(t/i),function(e){o&&o()?e.breakLoop():setTimeout(function(){for(var n=0;i>n;++n){var s=e.index*i+n;if(s>=t)break;if(r(s),o&&o()){e.breakLoop();break}}e.executeNext()},s)},n)},e}();e.AsyncLoop=o}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t;!function(e){var t=function(){function e(){this._isAlphaBlendDirty=!1,this._isBlendFunctionParametersDirty=!1,this._alphaBlend=!1,this._blendFunctionParameters=new Array(4)}return Object.defineProperty(e.prototype,"isDirty",{get:function(){return this._isAlphaBlendDirty||this._isBlendFunctionParametersDirty},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"alphaBlend",{get:function(){return this._alphaBlend},set:function(e){this._alphaBlend!==e&&(this._alphaBlend=e,this._isAlphaBlendDirty=!0)},enumerable:!0,configurable:!0}),e.prototype.setAlphaBlendFunctionParameters=function(e,t,i,r){this._blendFunctionParameters[0]===e&&this._blendFunctionParameters[1]===t&&this._blendFunctionParameters[2]===i&&this._blendFunctionParameters[3]===r||(this._blendFunctionParameters[0]=e,this._blendFunctionParameters[1]=t,this._blendFunctionParameters[2]=i,this._blendFunctionParameters[3]=r,this._isBlendFunctionParametersDirty=!0)},e.prototype.reset=function(){this._alphaBlend=!1,this._blendFunctionParameters[0]=null,this._blendFunctionParameters[1]=null,this._blendFunctionParameters[2]=null,this._blendFunctionParameters[3]=null,this._isAlphaBlendDirty=!0,this._isBlendFunctionParametersDirty=!1},e.prototype.apply=function(e){this.isDirty&&(this._isAlphaBlendDirty&&(this._alphaBlend?e.enable(e.BLEND):e.disable(e.BLEND),this._isAlphaBlendDirty=!1),this._isBlendFunctionParametersDirty&&(e.blendFuncSeparate(this._blendFunctionParameters[0],this._blendFunctionParameters[1],this._blendFunctionParameters[2],this._blendFunctionParameters[3]),this._isBlendFunctionParametersDirty=!1))},e}();e._AlphaState=t}(t=e.Internals||(e.Internals={}))}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t;!function(e){var t=function(){function e(){this._isDepthTestDirty=!1,this._isDepthMaskDirty=!1,this._isDepthFuncDirty=!1,this._isCullFaceDirty=!1,this._isCullDirty=!1,this._isZOffsetDirty=!1}return Object.defineProperty(e.prototype,"isDirty",{get:function(){return this._isDepthFuncDirty||this._isDepthTestDirty||this._isDepthMaskDirty||this._isCullFaceDirty||this._isCullDirty||this._isZOffsetDirty},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"zOffset",{get:function(){return this._zOffset},set:function(e){this._zOffset!==e&&(this._zOffset=e,this._isZOffsetDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"cullFace",{get:function(){return this._cullFace},set:function(e){this._cullFace!==e&&(this._cullFace=e,this._isCullFaceDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"cull",{get:function(){return this._cull},set:function(e){this._cull!==e&&(this._cull=e,this._isCullDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"depthFunc",{get:function(){return this._depthFunc},set:function(e){this._depthFunc!==e&&(this._depthFunc=e,this._isDepthFuncDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"depthMask",{get:function(){return this._depthMask},set:function(e){this._depthMask!==e&&(this._depthMask=e,this._isDepthMaskDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"depthTest",{get:function(){return this._depthTest},set:function(e){this._depthTest!==e&&(this._depthTest=e,this._isDepthTestDirty=!0)},enumerable:!0,configurable:!0}),e.prototype.reset=function(){this._depthMask=!0,this._depthTest=!0,this._depthFunc=null,this._cullFace=null,this._cull=null,this._zOffset=0,this._isDepthTestDirty=!0,this._isDepthMaskDirty=!0,this._isDepthFuncDirty=!1,this._isCullFaceDirty=!1,this._isCullDirty=!1,this._isZOffsetDirty=!1},e.prototype.apply=function(e){this.isDirty&&(this._isCullDirty&&(this.cull?e.enable(e.CULL_FACE):e.disable(e.CULL_FACE),this._isCullDirty=!1),this._isCullFaceDirty&&(e.cullFace(this.cullFace),this._isCullFaceDirty=!1),this._isDepthMaskDirty&&(e.depthMask(this.depthMask),this._isDepthMaskDirty=!1),this._isDepthTestDirty&&(this.depthTest?e.enable(e.DEPTH_TEST):e.disable(e.DEPTH_TEST),this._isDepthTestDirty=!1),this._isDepthFuncDirty&&(e.depthFunc(this.depthFunc),this._isDepthFuncDirty=!1),this._isZOffsetDirty&&(this.zOffset?(e.enable(e.POLYGON_OFFSET_FILL),e.polygonOffset(this.zOffset,0)):e.disable(e.POLYGON_OFFSET_FILL),this._isZOffsetDirty=!1))},e}();e._DepthCullingState=t}(t=e.Internals||(e.Internals={}))}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(e,t,i,r){var n=e.createShader("vertex"===i?e.VERTEX_SHADER:e.FRAGMENT_SHADER);if(e.shaderSource(n,(r?r+"\n":"")+t),e.compileShader(n),!e.getShaderParameter(n,e.COMPILE_STATUS))throw new Error(e.getShaderInfoLog(n));return n},i=function(e,t){var i=e.UNSIGNED_BYTE;return t===c.TEXTURETYPE_FLOAT&&(i=e.FLOAT),i},r=function(t,i,r){var n=r.NEAREST,o=r.NEAREST;return t===e.Texture.BILINEAR_SAMPLINGMODE?(n=r.LINEAR,o=i?r.LINEAR_MIPMAP_NEAREST:r.LINEAR):t===e.Texture.TRILINEAR_SAMPLINGMODE?(n=r.LINEAR,o=i?r.LINEAR_MIPMAP_LINEAR:r.LINEAR):t===e.Texture.NEAREST_SAMPLINGMODE&&(n=r.NEAREST,o=i?r.NEAREST_MIPMAP_LINEAR:r.NEAREST),{min:o,mag:n}},n=function(t,i,n,o,s,a,h,c,l,u,f){void 0===f&&(f=e.Texture.TRILINEAR_SAMPLINGMODE);var d=n.getEngine(),p=e.Tools.GetExponentOfTwo(o,d.getCaps().maxTextureSize),_=e.Tools.GetExponentOfTwo(s,d.getCaps().maxTextureSize);i.bindTexture(i.TEXTURE_2D,t),i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,void 0===a?1:a?1:0),t._baseWidth=o,t._baseHeight=s,t._width=p,t._height=_,t.isReady=!0,l(p,_);var m=r(f,!h,i);i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,m.mag),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,m.min),h||c||i.generateMipmap(i.TEXTURE_2D),i.bindTexture(i.TEXTURE_2D,null),d.resetTextureCache(),n._removePendingData(t),u&&u()},o=function(t,i,r,n,o){var s,a=function(){r[i]=s,r._internalCount++,n._removePendingData(s),6===r._internalCount&&o(r)},h=function(){n._removePendingData(s)};s=e.Tools.LoadImage(t,a,h,n.database),n._addPendingData(s)},s=function(e,t,i,r){var n=[];n._internalCount=0;for(var s=0;6>s;s++)o(r[s],s,n,t,i)},a=function(){function e(){}return e}();e.InstancingAttributeInfo=a;var h=function(){function e(){}return e}();e.EngineCapabilities=h;var c=function(){function o(t,i,r,n){var s=this;if(void 0===n&&(n=!0),this.isFullscreen=!1,this.isPointerLock=!1,this.cullBackFaces=!0,this.renderEvenInBackground=!0,this.enableOfflineSupport=!0,this.scenes=new Array,this._windowIsBackground=!1,this._webGLVersion="1.0",this._drawCalls=0,this._renderingQueueLaunched=!1,this._activeRenderLoops=[],this.fpsRange=60,this.previousFramesDuration=[],this.fps=60,this.deltaTime=0,this._depthCullingState=new e.Internals._DepthCullingState,this._alphaState=new e.Internals._AlphaState,this._alphaMode=o.ALPHA_DISABLE,this._loadedTexturesCache=new Array,this._maxTextureChannels=16,this._activeTexturesCache=new Array(this._maxTextureChannels),this._compiledEffects={},this._uintIndicesCurrentlySet=!1,this._currentBoundBuffer=new Array,this._currentInstanceLocations=new Array,this._currentInstanceBuffers=new Array,this._renderingCanvas=t,this._externalData=new e.StringDictionary,r=r||{},r.antialias=i,void 0===r.preserveDrawingBuffer&&(r.preserveDrawingBuffer=!1),!this._gl)try{this._gl=t.getContext("webgl",r)||t.getContext("experimental-webgl",r)}catch(a){throw new Error("WebGL not supported")}if(!this._gl)throw new Error("WebGL not supported");this._onBlur=function(){s._windowIsBackground=!0},this._onFocus=function(){s._windowIsBackground=!1},window.addEventListener("blur",this._onBlur),window.addEventListener("focus",this._onFocus);var c=r.limitDeviceRatio||window.devicePixelRatio||1;this._hardwareScalingLevel=n?1/Math.min(c,window.devicePixelRatio||1):1,this.resize(),this._caps=new h,this._caps.maxTexturesImageUnits=this._gl.getParameter(this._gl.MAX_TEXTURE_IMAGE_UNITS),this._caps.maxTextureSize=this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE),this._caps.maxCubemapTextureSize=this._gl.getParameter(this._gl.MAX_CUBE_MAP_TEXTURE_SIZE),
  4. this._caps.maxRenderTextureSize=this._gl.getParameter(this._gl.MAX_RENDERBUFFER_SIZE),this._glVersion=this._gl.getParameter(this._gl.VERSION);var l=this._gl.getExtension("WEBGL_debug_renderer_info");if(null!=l&&(this._glRenderer=this._gl.getParameter(l.UNMASKED_RENDERER_WEBGL),this._glVendor=this._gl.getParameter(l.UNMASKED_VENDOR_WEBGL)),this._glVendor||(this._glVendor="Unknown vendor"),this._glRenderer||(this._glRenderer="Unknown renderer"),this._caps.standardDerivatives=null!==this._gl.getExtension("OES_standard_derivatives"),this._caps.s3tc=this._gl.getExtension("WEBGL_compressed_texture_s3tc"),this._caps.textureFloat=null!==this._gl.getExtension("OES_texture_float"),this._caps.textureAnisotropicFilterExtension=this._gl.getExtension("EXT_texture_filter_anisotropic")||this._gl.getExtension("WEBKIT_EXT_texture_filter_anisotropic")||this._gl.getExtension("MOZ_EXT_texture_filter_anisotropic"),this._caps.maxAnisotropy=this._caps.textureAnisotropicFilterExtension?this._gl.getParameter(this._caps.textureAnisotropicFilterExtension.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0,this._caps.instancedArrays=this._gl.getExtension("ANGLE_instanced_arrays"),this._caps.uintIndices=null!==this._gl.getExtension("OES_element_index_uint"),this._caps.fragmentDepthSupported=null!==this._gl.getExtension("EXT_frag_depth"),this._caps.highPrecisionShaderSupported=!0,this._caps.drawBuffersExtension=this._gl.getExtension("WEBGL_draw_buffers"),this._caps.textureFloatLinearFiltering=this._gl.getExtension("OES_texture_float_linear"),this._caps.textureLOD=this._gl.getExtension("EXT_shader_texture_lod"),this._gl.getShaderPrecisionFormat){var u=this._gl.getShaderPrecisionFormat(this._gl.FRAGMENT_SHADER,this._gl.HIGH_FLOAT);this._caps.highPrecisionShaderSupported=0!==u.precision}this.setDepthBuffer(!0),this.setDepthFunctionToLessOrEqual(),this.setDepthWrite(!0),this._onFullscreenChange=function(){void 0!==document.fullscreen?s.isFullscreen=document.fullscreen:void 0!==document.mozFullScreen?s.isFullscreen=document.mozFullScreen:void 0!==document.webkitIsFullScreen?s.isFullscreen=document.webkitIsFullScreen:void 0!==document.msIsFullScreen&&(s.isFullscreen=document.msIsFullScreen),s.isFullscreen&&s._pointerLockRequested&&(t.requestPointerLock=t.requestPointerLock||t.msRequestPointerLock||t.mozRequestPointerLock||t.webkitRequestPointerLock,t.requestPointerLock&&t.requestPointerLock())},document.addEventListener("fullscreenchange",this._onFullscreenChange,!1),document.addEventListener("mozfullscreenchange",this._onFullscreenChange,!1),document.addEventListener("webkitfullscreenchange",this._onFullscreenChange,!1),document.addEventListener("msfullscreenchange",this._onFullscreenChange,!1),this._onPointerLockChange=function(){s.isPointerLock=document.mozPointerLockElement===t||document.webkitPointerLockElement===t||document.msPointerLockElement===t||document.pointerLockElement===t},document.addEventListener("pointerlockchange",this._onPointerLockChange,!1),document.addEventListener("mspointerlockchange",this._onPointerLockChange,!1),document.addEventListener("mozpointerlockchange",this._onPointerLockChange,!1),document.addEventListener("webkitpointerlockchange",this._onPointerLockChange,!1),e.AudioEngine&&!o.audioEngine&&(o.audioEngine=new e.AudioEngine),this._loadingScreen=new e.DefaultLoadingScreen(this._renderingCanvas),e.Tools.Log("Babylon.js engine (v"+o.Version+") launched")}return Object.defineProperty(o,"ALPHA_DISABLE",{get:function(){return o._ALPHA_DISABLE},enumerable:!0,configurable:!0}),Object.defineProperty(o,"ALPHA_ONEONE",{get:function(){return o._ALPHA_ONEONE},enumerable:!0,configurable:!0}),Object.defineProperty(o,"ALPHA_ADD",{get:function(){return o._ALPHA_ADD},enumerable:!0,configurable:!0}),Object.defineProperty(o,"ALPHA_COMBINE",{get:function(){return o._ALPHA_COMBINE},enumerable:!0,configurable:!0}),Object.defineProperty(o,"ALPHA_SUBTRACT",{get:function(){return o._ALPHA_SUBTRACT},enumerable:!0,configurable:!0}),Object.defineProperty(o,"ALPHA_MULTIPLY",{get:function(){return o._ALPHA_MULTIPLY},enumerable:!0,configurable:!0}),Object.defineProperty(o,"ALPHA_MAXIMIZED",{get:function(){return o._ALPHA_MAXIMIZED},enumerable:!0,configurable:!0}),Object.defineProperty(o,"DELAYLOADSTATE_NONE",{get:function(){return o._DELAYLOADSTATE_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(o,"DELAYLOADSTATE_LOADED",{get:function(){return o._DELAYLOADSTATE_LOADED},enumerable:!0,configurable:!0}),Object.defineProperty(o,"DELAYLOADSTATE_LOADING",{get:function(){return o._DELAYLOADSTATE_LOADING},enumerable:!0,configurable:!0}),Object.defineProperty(o,"DELAYLOADSTATE_NOTLOADED",{get:function(){return o._DELAYLOADSTATE_NOTLOADED},enumerable:!0,configurable:!0}),Object.defineProperty(o,"TEXTUREFORMAT_ALPHA",{get:function(){return o._TEXTUREFORMAT_ALPHA},enumerable:!0,configurable:!0}),Object.defineProperty(o,"TEXTUREFORMAT_LUMINANCE",{get:function(){return o._TEXTUREFORMAT_LUMINANCE},enumerable:!0,configurable:!0}),Object.defineProperty(o,"TEXTUREFORMAT_LUMINANCE_ALPHA",{get:function(){return o._TEXTUREFORMAT_LUMINANCE_ALPHA},enumerable:!0,configurable:!0}),Object.defineProperty(o,"TEXTUREFORMAT_RGB",{get:function(){return o._TEXTUREFORMAT_RGB},enumerable:!0,configurable:!0}),Object.defineProperty(o,"TEXTUREFORMAT_RGBA",{get:function(){return o._TEXTUREFORMAT_RGBA},enumerable:!0,configurable:!0}),Object.defineProperty(o,"TEXTURETYPE_UNSIGNED_INT",{get:function(){return o._TEXTURETYPE_UNSIGNED_INT},enumerable:!0,configurable:!0}),Object.defineProperty(o,"TEXTURETYPE_FLOAT",{get:function(){return o._TEXTURETYPE_FLOAT},enumerable:!0,configurable:!0}),Object.defineProperty(o,"Version",{get:function(){return"2.4.0"},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"webGLVersion",{get:function(){return this._webGLVersion},enumerable:!0,configurable:!0}),o.prototype._prepareWorkingCanvas=function(){this._workingCanvas||(this._workingCanvas=document.createElement("canvas"),this._workingContext=this._workingCanvas.getContext("2d"))},o.prototype.resetTextureCache=function(){for(var e=0;e<this._maxTextureChannels;e++)this._activeTexturesCache[e]=null},o.prototype.getGlInfo=function(){return{vendor:this._glVendor,renderer:this._glRenderer,version:this._glVersion}},o.prototype.getAspectRatio=function(e,t){void 0===t&&(t=!1);var i=e.viewport;return this.getRenderWidth(t)*i.width/(this.getRenderHeight(t)*i.height)},o.prototype.getRenderWidth=function(e){return void 0===e&&(e=!1),!e&&this._currentRenderTarget?this._currentRenderTarget._width:this._renderingCanvas.width},o.prototype.getRenderHeight=function(e){return void 0===e&&(e=!1),!e&&this._currentRenderTarget?this._currentRenderTarget._height:this._renderingCanvas.height},o.prototype.getRenderingCanvas=function(){return this._renderingCanvas},o.prototype.getRenderingCanvasClientRect=function(){return this._renderingCanvas.getBoundingClientRect()},o.prototype.setHardwareScalingLevel=function(e){this._hardwareScalingLevel=e,this.resize()},o.prototype.getHardwareScalingLevel=function(){return this._hardwareScalingLevel},o.prototype.getLoadedTexturesCache=function(){return this._loadedTexturesCache},o.prototype.getCaps=function(){return this._caps},Object.defineProperty(o.prototype,"drawCalls",{get:function(){return this._drawCalls},enumerable:!0,configurable:!0}),o.prototype.resetDrawCalls=function(){this._drawCalls=0},o.prototype.getDepthFunction=function(){return this._depthCullingState.depthFunc},o.prototype.setDepthFunction=function(e){this._depthCullingState.depthFunc=e},o.prototype.setDepthFunctionToGreater=function(){this._depthCullingState.depthFunc=this._gl.GREATER},o.prototype.setDepthFunctionToGreaterOrEqual=function(){this._depthCullingState.depthFunc=this._gl.GEQUAL},o.prototype.setDepthFunctionToLess=function(){this._depthCullingState.depthFunc=this._gl.LESS},o.prototype.setDepthFunctionToLessOrEqual=function(){this._depthCullingState.depthFunc=this._gl.LEQUAL},o.prototype.stopRenderLoop=function(e){if(!e)return void(this._activeRenderLoops=[]);var t=this._activeRenderLoops.indexOf(e);t>=0&&this._activeRenderLoops.splice(t,1)},o.prototype._renderLoop=function(){var t=!0;if(!this.renderEvenInBackground&&this._windowIsBackground&&(t=!1),t){this.beginFrame();for(var i=0;i<this._activeRenderLoops.length;i++){var r=this._activeRenderLoops[i];r()}this.endFrame()}this._activeRenderLoops.length>0?e.Tools.QueueNewFrame(this._bindedRenderFunction):this._renderingQueueLaunched=!1},o.prototype.runRenderLoop=function(t){-1===this._activeRenderLoops.indexOf(t)&&(this._activeRenderLoops.push(t),this._renderingQueueLaunched||(this._renderingQueueLaunched=!0,this._bindedRenderFunction=this._renderLoop.bind(this),e.Tools.QueueNewFrame(this._bindedRenderFunction)))},o.prototype.switchFullscreen=function(t,i){this.isFullscreen?e.Tools.ExitFullscreen():(this._pointerLockRequested=t,e.Tools.RequestFullscreen(this._renderingCanvas,i))},o.prototype.clear=function(e,t,i){this.applyStates(),t&&this._gl.clearColor(e.r,e.g,e.b,void 0!==e.a?e.a:1),i&&this._depthCullingState.depthMask&&this._gl.clearDepth(1);var r=0;t&&(r|=this._gl.COLOR_BUFFER_BIT),i&&this._depthCullingState.depthMask&&(r|=this._gl.DEPTH_BUFFER_BIT),this._gl.clear(r)},o.prototype.scissorClear=function(e,t,i,r,n){var o=this._gl,s=o.getParameter(o.SCISSOR_TEST),a=o.getParameter(o.SCISSOR_BOX);o.enable(o.SCISSOR_TEST),o.scissor(e,t,i,r),this.clear(n,!0,!0),o.scissor(a[0],a[1],a[2],a[3]),s===!0?o.enable(o.SCISSOR_TEST):o.disable(o.SCISSOR_TEST)},o.prototype.setViewport=function(e,t,i){var r=t||(navigator.isCocoonJS?window.innerWidth:this._renderingCanvas.width),n=i||(navigator.isCocoonJS?window.innerHeight:this._renderingCanvas.height),o=e.x||0,s=e.y||0;this._cachedViewport=e,this._gl.viewport(o*r,s*n,r*e.width,n*e.height)},o.prototype.setDirectViewport=function(e,t,i,r){var n=this._cachedViewport;return this._cachedViewport=null,this._gl.viewport(e,t,i,r),n},o.prototype.beginFrame=function(){this._measureFps()},o.prototype.endFrame=function(){},o.prototype.resize=function(){var e=navigator.isCocoonJS?window.innerWidth:this._renderingCanvas.clientWidth,t=navigator.isCocoonJS?window.innerHeight:this._renderingCanvas.clientHeight;this.setSize(e/this._hardwareScalingLevel,t/this._hardwareScalingLevel);for(var i=0;i<this.scenes.length;i++){var r=this.scenes[i];r.debugLayer.isVisible()&&r.debugLayer._syncPositions()}},o.prototype.setSize=function(e,t){this._renderingCanvas.width=e,this._renderingCanvas.height=t;for(var i=0;i<this.scenes.length;i++)for(var r=this.scenes[i],n=0;n<r.cameras.length;n++){var o=r.cameras[n];o._currentRenderId=0}},o.prototype.bindFramebuffer=function(e,t,i,r){this._currentRenderTarget=e;var n=this._gl;n.bindFramebuffer(n.FRAMEBUFFER,e._framebuffer),e.isCube?n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+t,e,0):n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,e,0),this._gl.viewport(0,0,i||e._width,r||e._height),this.wipeCaches()},o.prototype.unBindFramebuffer=function(e,t){if(void 0===t&&(t=!1),this._currentRenderTarget=null,e.generateMipMaps&&!t){var i=this._gl;i.bindTexture(i.TEXTURE_2D,e),i.generateMipmap(i.TEXTURE_2D),i.bindTexture(i.TEXTURE_2D,null)}this._gl.bindFramebuffer(this._gl.FRAMEBUFFER,null)},o.prototype.generateMipMapsForCubemap=function(e){if(e.generateMipMaps){var t=this._gl;t.bindTexture(t.TEXTURE_CUBE_MAP,e),t.generateMipmap(t.TEXTURE_CUBE_MAP),t.bindTexture(t.TEXTURE_CUBE_MAP,null)}},o.prototype.flushFramebuffer=function(){this._gl.flush()},o.prototype.restoreDefaultFramebuffer=function(){this._currentRenderTarget=null,this._gl.bindFramebuffer(this._gl.FRAMEBUFFER,null),this.setViewport(this._cachedViewport),this.wipeCaches()},o.prototype._resetVertexBufferBinding=function(){this.bindBuffer(null,this._gl.ARRAY_BUFFER),this._cachedVertexBuffers=null},o.prototype.createVertexBuffer=function(e){var t=this._gl.createBuffer();return this.bindBuffer(t,this._gl.ARRAY_BUFFER),e instanceof Float32Array?this._gl.bufferData(this._gl.ARRAY_BUFFER,e,this._gl.STATIC_DRAW):this._gl.bufferData(this._gl.ARRAY_BUFFER,new Float32Array(e),this._gl.STATIC_DRAW),this._resetVertexBufferBinding(),t.references=1,t},o.prototype.createDynamicVertexBuffer=function(e){var t=this._gl.createBuffer();return this.bindBuffer(t,this._gl.ARRAY_BUFFER),e instanceof Float32Array?this._gl.bufferData(this._gl.ARRAY_BUFFER,e,this._gl.DYNAMIC_DRAW):this._gl.bufferData(this._gl.ARRAY_BUFFER,new Float32Array(e),this._gl.DYNAMIC_DRAW),this._resetVertexBufferBinding(),t.references=1,t},o.prototype.updateDynamicVertexBuffer=function(e,t,i,r){this.bindBuffer(e,this._gl.ARRAY_BUFFER),void 0===i&&(i=0),void 0===r?t instanceof Float32Array?this._gl.bufferSubData(this._gl.ARRAY_BUFFER,i,t):this._gl.bufferSubData(this._gl.ARRAY_BUFFER,i,new Float32Array(t)):t instanceof Float32Array?this._gl.bufferSubData(this._gl.ARRAY_BUFFER,0,t.subarray(i,i+r)):this._gl.bufferSubData(this._gl.ARRAY_BUFFER,0,new Float32Array(t).subarray(i,i+r)),this._resetVertexBufferBinding()},o.prototype._resetIndexBufferBinding=function(){this.bindBuffer(null,this._gl.ELEMENT_ARRAY_BUFFER),this._cachedIndexBuffer=null},o.prototype.createIndexBuffer=function(e){var t=this._gl.createBuffer();this.bindBuffer(t,this._gl.ELEMENT_ARRAY_BUFFER);var i,r=!1;if(this._caps.uintIndices){for(var n=0;n<e.length;n++)if(e[n]>65535){r=!0;break}i=r?new Uint32Array(e):new Uint16Array(e)}else i=new Uint16Array(e);return this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER,i,this._gl.STATIC_DRAW),this._resetIndexBufferBinding(),t.references=1,t.is32Bits=r,t},o.prototype.bindArrayBuffer=function(e){this.bindBuffer(e,this._gl.ARRAY_BUFFER)},o.prototype.updateArrayBuffer=function(e){this._gl.bufferSubData(this._gl.ARRAY_BUFFER,0,e)},o.prototype.bindBuffer=function(e,t){this._currentBoundBuffer[t]!==e&&(this._gl.bindBuffer(t,e),this._currentBoundBuffer[t]=e)},o.prototype.bindBuffersDirectly=function(e,t,i,r,n){if(this._cachedVertexBuffers!==e||this._cachedEffectForVertexBuffers!==n){this._cachedVertexBuffers=e,this._cachedEffectForVertexBuffers=n,this.bindBuffer(e,this._gl.ARRAY_BUFFER);for(var o=0,s=0;s<i.length;s++){var a=n.getAttributeLocation(s);a>=0&&this._gl.vertexAttribPointer(a,i[s],this._gl.FLOAT,!1,r,o),o+=4*i[s]}}this._cachedIndexBuffer!==t&&(this._cachedIndexBuffer=t,this.bindBuffer(t,this._gl.ELEMENT_ARRAY_BUFFER),this._uintIndicesCurrentlySet=t.is32Bits)},o.prototype.bindBuffers=function(e,t,i){if(this._cachedVertexBuffers!==e||this._cachedEffectForVertexBuffers!==i){this._cachedVertexBuffers=e,this._cachedEffectForVertexBuffers=i;for(var r=i.getAttributesNames(),n=0;n<r.length;n++){var o=i.getAttributeLocation(n);if(o>=0){var s=e[r[n]];if(!s)continue;var a=s.getBuffer();this.bindBuffer(a,this._gl.ARRAY_BUFFER),this._gl.vertexAttribPointer(o,s.getSize(),this._gl.FLOAT,!1,4*s.getStrideSize(),4*s.getOffset()),s.getIsInstanced()&&(this._caps.instancedArrays.vertexAttribDivisorANGLE(o,1),this._currentInstanceLocations.push(o),this._currentInstanceBuffers.push(a))}}}null!=t&&this._cachedIndexBuffer!==t&&(this._cachedIndexBuffer=t,this.bindBuffer(t,this._gl.ELEMENT_ARRAY_BUFFER),this._uintIndicesCurrentlySet=t.is32Bits)},o.prototype.unbindInstanceAttributes=function(){for(var e,t=0,i=this._currentInstanceLocations.length;i>t;t++){var r=this._currentInstanceBuffers[t];e!=r&&(e=r,this.bindBuffer(r,this._gl.ARRAY_BUFFER));var n=this._currentInstanceLocations[t];this._caps.instancedArrays.vertexAttribDivisorANGLE(n,0)}this._currentInstanceBuffers.length=0,this._currentInstanceLocations.length=0},o.prototype._releaseBuffer=function(e){return e.references--,0===e.references?(this._gl.deleteBuffer(e),!0):!1},o.prototype.createInstancesBuffer=function(e){var t=this._gl.createBuffer();return t.capacity=e,this.bindBuffer(t,this._gl.ARRAY_BUFFER),this._gl.bufferData(this._gl.ARRAY_BUFFER,e,this._gl.DYNAMIC_DRAW),t},o.prototype.deleteInstancesBuffer=function(e){this._gl.deleteBuffer(e)},o.prototype.updateAndBindInstancesBuffer=function(e,t,i){if(this.bindBuffer(e,this._gl.ARRAY_BUFFER),t&&this._gl.bufferSubData(this._gl.ARRAY_BUFFER,0,t),void 0!==i[0].index){for(var r=0,n=0;n<i.length;n++){var o=i[n];r+=4*o.attributeSize}for(var n=0;n<i.length;n++){var o=i[n];this._gl.enableVertexAttribArray(o.index),this._gl.vertexAttribPointer(o.index,o.attributeSize,o.attribyteType||this._gl.FLOAT,o.normalized||!1,r,o.offset),this._caps.instancedArrays.vertexAttribDivisorANGLE(o.index,1),this._currentInstanceLocations.push(o.index),this._currentInstanceBuffers.push(e)}}else for(var s=0;4>s;s++){var a=i[s];this._gl.enableVertexAttribArray(a),this._gl.vertexAttribPointer(a,4,this._gl.FLOAT,!1,64,16*s),this._caps.instancedArrays.vertexAttribDivisorANGLE(a,1),this._currentInstanceLocations.push(a),this._currentInstanceBuffers.push(e)}},o.prototype.applyStates=function(){this._depthCullingState.apply(this._gl),this._alphaState.apply(this._gl)},o.prototype.draw=function(e,t,i,r){this.applyStates(),this._drawCalls++;var n=this._uintIndicesCurrentlySet?this._gl.UNSIGNED_INT:this._gl.UNSIGNED_SHORT,o=this._uintIndicesCurrentlySet?4:2;return r?void this._caps.instancedArrays.drawElementsInstancedANGLE(e?this._gl.TRIANGLES:this._gl.LINES,i,n,t*o,r):void this._gl.drawElements(e?this._gl.TRIANGLES:this._gl.LINES,i,n,t*o)},o.prototype.drawPointClouds=function(e,t,i){return this.applyStates(),this._drawCalls++,i?void this._caps.instancedArrays.drawArraysInstancedANGLE(this._gl.POINTS,e,t,i):void this._gl.drawArrays(this._gl.POINTS,e,t)},o.prototype.drawUnIndexed=function(e,t,i,r){return this.applyStates(),this._drawCalls++,r?void this._caps.instancedArrays.drawArraysInstancedANGLE(e?this._gl.TRIANGLES:this._gl.LINES,t,i,r):void this._gl.drawArrays(e?this._gl.TRIANGLES:this._gl.LINES,t,i)},o.prototype._releaseEffect=function(e){this._compiledEffects[e._key]&&(delete this._compiledEffects[e._key],e.getProgram()&&this._gl.deleteProgram(e.getProgram()))},o.prototype.createEffect=function(t,i,r,n,o,s,a,h,c){var l=t.vertexElement||t.vertex||t,u=t.fragmentElement||t.fragment||t,f=l+"+"+u+"@"+o;if(this._compiledEffects[f])return this._compiledEffects[f];var d=new e.Effect(t,i,r,n,this,o,s,a,h,c);return d._key=f,this._compiledEffects[f]=d,d},o.prototype.createEffectForParticles=function(e,t,i,r,n,o,s){return void 0===t&&(t=[]),void 0===i&&(i=[]),void 0===r&&(r=""),this.createEffect({vertex:"particles",fragmentElement:e},["position","color","options"],["view","projection"].concat(t),["diffuseSampler"].concat(i),r,n,o,s)},o.prototype.createShaderProgram=function(e,i,r){var n=t(this._gl,e,"vertex",r),o=t(this._gl,i,"fragment",r),s=this._gl.createProgram();this._gl.attachShader(s,n),this._gl.attachShader(s,o),this._gl.linkProgram(s);var a=this._gl.getProgramParameter(s,this._gl.LINK_STATUS);if(!a){var h=this._gl.getProgramInfoLog(s);if(h)throw new Error(h)}return this._gl.deleteShader(n),this._gl.deleteShader(o),s},o.prototype.getUniforms=function(e,t){for(var i=[],r=0;r<t.length;r++)i.push(this._gl.getUniformLocation(e,t[r]));return i},o.prototype.getAttributes=function(e,t){for(var i=[],r=0;r<t.length;r++)try{i.push(this._gl.getAttribLocation(e,t[r]))}catch(n){i.push(-1)}return i},o.prototype.enableEffect=function(e){if(!e||!e.getAttributesCount()||this._currentEffect===e)return void(e&&e.onBind&&e.onBind(e));this._vertexAttribArraysToUse=this._vertexAttribArraysToUse||[],this._vertexAttribArraysEnabled=this._vertexAttribArraysEnabled||[],this._gl.useProgram(e.getProgram());var t,i;for(t=0,i=this._vertexAttribArraysToUse.length;i>t;t++)this._vertexAttribArraysToUse[t]=!1;var r=e.getAttributesCount();for(t=0;r>t;t++){var n=e.getAttributeLocation(t);n>=0&&(this._vertexAttribArraysToUse[n]=!0)}for(t=0,i=this._vertexAttribArraysEnabled.length;i>t;t++)t>this._gl.VERTEX_ATTRIB_ARRAY_ENABLED||!this._vertexAttribArraysEnabled[t]||this._vertexAttribArraysToUse[t]||(this._vertexAttribArraysEnabled[t]=!1,this._gl.disableVertexAttribArray(t));for(t=0,i=this._vertexAttribArraysToUse.length;i>t;t++)this._vertexAttribArraysToUse[t]&&!this._vertexAttribArraysEnabled[t]&&(this._vertexAttribArraysEnabled[t]=!0,this._gl.enableVertexAttribArray(t));this._currentEffect=e,e.onBind&&e.onBind(e)},o.prototype.setArray=function(e,t){e&&this._gl.uniform1fv(e,t)},o.prototype.setArray2=function(e,t){e&&t.length%2===0&&this._gl.uniform2fv(e,t)},o.prototype.setArray3=function(e,t){e&&t.length%3===0&&this._gl.uniform3fv(e,t)},o.prototype.setArray4=function(e,t){e&&t.length%4===0&&this._gl.uniform4fv(e,t)},o.prototype.setMatrices=function(e,t){e&&this._gl.uniformMatrix4fv(e,!1,t)},o.prototype.setMatrix=function(e,t){e&&this._gl.uniformMatrix4fv(e,!1,t.toArray())},o.prototype.setMatrix3x3=function(e,t){e&&this._gl.uniformMatrix3fv(e,!1,t)},o.prototype.setMatrix2x2=function(e,t){e&&this._gl.uniformMatrix2fv(e,!1,t)},o.prototype.setFloat=function(e,t){e&&this._gl.uniform1f(e,t)},o.prototype.setFloat2=function(e,t,i){e&&this._gl.uniform2f(e,t,i)},o.prototype.setFloat3=function(e,t,i,r){e&&this._gl.uniform3f(e,t,i,r)},o.prototype.setBool=function(e,t){e&&this._gl.uniform1i(e,t)},o.prototype.setFloat4=function(e,t,i,r,n){e&&this._gl.uniform4f(e,t,i,r,n)},o.prototype.setColor3=function(e,t){e&&this._gl.uniform3f(e,t.r,t.g,t.b)},o.prototype.setColor4=function(e,t,i){e&&this._gl.uniform4f(e,t.r,t.g,t.b,i)},o.prototype.setState=function(e,t,i,r){void 0===t&&(t=0),void 0===r&&(r=!1);var n=r?this._gl.FRONT:this._gl.BACK,o=r?this._gl.BACK:this._gl.FRONT,s=this.cullBackFaces?n:o;(this._depthCullingState.cull!==e||i||this._depthCullingState.cullFace!==s)&&(e?(this._depthCullingState.cullFace=s,this._depthCullingState.cull=!0):this._depthCullingState.cull=!1),this._depthCullingState.zOffset=t},o.prototype.setDepthBuffer=function(e){this._depthCullingState.depthTest=e},o.prototype.getDepthWrite=function(){return this._depthCullingState.depthMask},o.prototype.setDepthWrite=function(e){this._depthCullingState.depthMask=e},o.prototype.setColorWrite=function(e){this._gl.colorMask(e,e,e,e)},o.prototype.setAlphaMode=function(e,t){if(void 0===t&&(t=!1),this._alphaMode!==e){switch(e){case o.ALPHA_DISABLE:this._alphaState.alphaBlend=!1;break;case o.ALPHA_COMBINE:this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA,this._gl.ONE_MINUS_SRC_ALPHA,this._gl.ONE,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case o.ALPHA_ONEONE:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE,this._gl.ONE,this._gl.ZERO,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case o.ALPHA_ADD:this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA,this._gl.ONE,this._gl.ZERO,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case o.ALPHA_SUBTRACT:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ZERO,this._gl.ONE_MINUS_SRC_COLOR,this._gl.ONE,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case o.ALPHA_MULTIPLY:this._alphaState.setAlphaBlendFunctionParameters(this._gl.DST_COLOR,this._gl.ZERO,this._gl.ONE,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case o.ALPHA_MAXIMIZED:this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA,this._gl.ONE_MINUS_SRC_COLOR,this._gl.ONE,this._gl.ONE),this._alphaState.alphaBlend=!0}t||this.setDepthWrite(e===o.ALPHA_DISABLE),this._alphaMode=e}},o.prototype.getAlphaMode=function(){return this._alphaMode},o.prototype.setAlphaTesting=function(e){this._alphaTest=e},o.prototype.getAlphaTesting=function(){return this._alphaTest},o.prototype.wipeCaches=function(){this.resetTextureCache(),this._currentEffect=null,this._depthCullingState.reset(),this.setDepthFunctionToLessOrEqual(),this._alphaState.reset(),this._cachedVertexBuffers=null,this._cachedIndexBuffer=null,this._cachedEffectForVertexBuffers=null},o.prototype.setSamplingMode=function(t,i){var r=this._gl;r.bindTexture(r.TEXTURE_2D,t);var n=r.NEAREST,o=r.NEAREST;i===e.Texture.BILINEAR_SAMPLINGMODE?(n=r.LINEAR,o=r.LINEAR):i===e.Texture.TRILINEAR_SAMPLINGMODE&&(n=r.LINEAR,o=r.LINEAR_MIPMAP_LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,n),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,o),r.bindTexture(r.TEXTURE_2D,null),t.samplingMode=i},o.prototype.createTexture=function(t,i,r,o,s,a,h,c){var l=this;void 0===s&&(s=e.Texture.TRILINEAR_SAMPLINGMODE),void 0===a&&(a=null),void 0===h&&(h=null),void 0===c&&(c=null);var u,f=this._gl.createTexture(),d=!1;if("data:"===t.substr(0,5)&&(d=!0),d){var p=t;d=p.split(":"),t=p,u=d[1].substr(d[1].length-4,4).toLowerCase()}else u=t.substr(t.length-4,4).toLowerCase();var _=this.getCaps().s3tc&&".dds"===u,m=".tga"===u;o._addPendingData(f),f.url=t,f.noMipmap=i,f.references=1,f.samplingMode=s,this._loadedTexturesCache.push(f);var g,v=function(){o._removePendingData(f),h&&h()};if(m)g=function(t){var h=new Uint8Array(t),c=e.Internals.TGATools.GetTGAHeader(h);n(f,l._gl,o,c.width,c.height,r,i,!1,function(){e.Internals.TGATools.UploadContent(l._gl,h)},a,s)},d instanceof Array?g(c):e.Tools.LoadFile(t,function(e){g(e)},v,o.database,!0);else if(_)g=function(t){var h=e.Internals.DDSTools.GetDDSInfo(t),c=(h.isRGB||h.isLuminance||h.mipmapCount>1)&&!i&&h.width>>h.mipmapCount-1===1;n(f,l._gl,o,h.width,h.height,r,!c,h.isFourCC,function(){e.Internals.DDSTools.UploadDDSLevels(l._gl,l.getCaps().s3tc,t,h,c,1)},a,s)},d instanceof Array?g(c):e.Tools.LoadFile(t,function(e){g(e)},v,o.database,!0);else{var y=function(t){n(f,l._gl,o,t.width,t.height,r,i,!1,function(i,r){var n=t.width===i&&t.height===r;n||(l._prepareWorkingCanvas(),l._workingCanvas.width=i,l._workingCanvas.height=r,s===e.Texture.NEAREST_SAMPLINGMODE&&(l._workingContext.imageSmoothingEnabled=!1,l._workingContext.mozImageSmoothingEnabled=!1,l._workingContext.oImageSmoothingEnabled=!1,l._workingContext.webkitImageSmoothingEnabled=!1,l._workingContext.msImageSmoothingEnabled=!1),l._workingContext.drawImage(t,0,0,t.width,t.height,0,0,i,r),s===e.Texture.NEAREST_SAMPLINGMODE&&(l._workingContext.imageSmoothingEnabled=!0,l._workingContext.mozImageSmoothingEnabled=!0,l._workingContext.oImageSmoothingEnabled=!0,l._workingContext.webkitImageSmoothingEnabled=!0,l._workingContext.msImageSmoothingEnabled=!0)),l._gl.texImage2D(l._gl.TEXTURE_2D,0,l._gl.RGBA,l._gl.RGBA,l._gl.UNSIGNED_BYTE,n?t:l._workingCanvas)},a,s)};d instanceof Array?e.Tools.LoadImage(c,y,v,o.database):e.Tools.LoadImage(t,y,v,o.database)}return f},o.prototype._getInternalFormat=function(e){var t=this._gl.RGBA;switch(e){case o.TEXTUREFORMAT_ALPHA:t=this._gl.ALPHA;break;case o.TEXTUREFORMAT_LUMINANCE:t=this._gl.LUMINANCE;break;case o.TEXTUREFORMAT_LUMINANCE_ALPHA:t=this._gl.LUMINANCE_ALPHA;break;case o.TEXTUREFORMAT_RGB:t=this._gl.RGB;break;case o.TEXTUREFORMAT_RGBA:t=this._gl.RGBA}return t},o.prototype.updateRawTexture=function(e,t,i,r,n){void 0===n&&(n=null);var o=this._getInternalFormat(i);this._gl.bindTexture(this._gl.TEXTURE_2D,e),this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL,void 0===r?1:r?1:0),e._width%4!==0&&this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT,1),n?this._gl.compressedTexImage2D(this._gl.TEXTURE_2D,0,this.getCaps().s3tc[n],e._width,e._height,0,t):this._gl.texImage2D(this._gl.TEXTURE_2D,0,o,e._width,e._height,0,o,this._gl.UNSIGNED_BYTE,t),e.generateMipMaps&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._gl.bindTexture(this._gl.TEXTURE_2D,null),this.resetTextureCache(),e.isReady=!0},o.prototype.createRawTexture=function(e,t,i,n,o,s,a,h){void 0===h&&(h=null);var c=this._gl.createTexture();c._baseWidth=t,c._baseHeight=i,c._width=t,c._height=i,c.references=1,this.updateRawTexture(c,e,n,s,h),this._gl.bindTexture(this._gl.TEXTURE_2D,c);var l=r(a,o,this._gl);return this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MAG_FILTER,l.mag),this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MIN_FILTER,l.min),this._gl.bindTexture(this._gl.TEXTURE_2D,null),c.samplingMode=a,this._loadedTexturesCache.push(c),c},o.prototype.createDynamicTexture=function(t,i,r,n){var o=this._gl.createTexture();return o._baseWidth=t,o._baseHeight=i,r&&(t=e.Tools.GetExponentOfTwo(t,this._caps.maxTextureSize),i=e.Tools.GetExponentOfTwo(i,this._caps.maxTextureSize)),this.resetTextureCache(),o._width=t,o._height=i,o.isReady=!1,o.generateMipMaps=r,o.references=1,o.samplingMode=n,this.updateTextureSamplingMode(n,o),this._loadedTexturesCache.push(o),o},o.prototype.updateTextureSamplingMode=function(e,t){var i=r(e,t.generateMipMaps,this._gl);t.isCube?(this._gl.bindTexture(this._gl.TEXTURE_CUBE_MAP,t),this._gl.texParameteri(this._gl.TEXTURE_CUBE_MAP,this._gl.TEXTURE_MAG_FILTER,i.mag),this._gl.texParameteri(this._gl.TEXTURE_CUBE_MAP,this._gl.TEXTURE_MIN_FILTER,i.min),this._gl.bindTexture(this._gl.TEXTURE_CUBE_MAP,null)):(this._gl.bindTexture(this._gl.TEXTURE_2D,t),this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MAG_FILTER,i.mag),this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MIN_FILTER,i.min),this._gl.bindTexture(this._gl.TEXTURE_2D,null))},o.prototype.updateDynamicTexture=function(e,t,i,r){void 0===r&&(r=!1),this._gl.bindTexture(this._gl.TEXTURE_2D,e),this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL,i?1:0),r&&this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,1),this._gl.texImage2D(this._gl.TEXTURE_2D,0,this._gl.RGBA,this._gl.RGBA,this._gl.UNSIGNED_BYTE,t),e.generateMipMaps&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._gl.bindTexture(this._gl.TEXTURE_2D,null),this.resetTextureCache(),e.isReady=!0},o.prototype.updateVideoTexture=function(e,t,i){if(!e._isDisabled){this._gl.bindTexture(this._gl.TEXTURE_2D,e),this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL,i?0:1);try{void 0===this._videoTextureSupported&&(this._gl.texImage2D(this._gl.TEXTURE_2D,0,this._gl.RGBA,this._gl.RGBA,this._gl.UNSIGNED_BYTE,t),0!==this._gl.getError()?this._videoTextureSupported=!1:this._videoTextureSupported=!0),this._videoTextureSupported?this._gl.texImage2D(this._gl.TEXTURE_2D,0,this._gl.RGBA,this._gl.RGBA,this._gl.UNSIGNED_BYTE,t):(e._workingCanvas||(e._workingCanvas=document.createElement("canvas"),e._workingContext=e._workingCanvas.getContext("2d"),e._workingCanvas.width=e._width,e._workingCanvas.height=e._height),e._workingContext.drawImage(t,0,0,t.videoWidth,t.videoHeight,0,0,e._width,e._height),this._gl.texImage2D(this._gl.TEXTURE_2D,0,this._gl.RGBA,this._gl.RGBA,this._gl.UNSIGNED_BYTE,e._workingCanvas)),e.generateMipMaps&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._gl.bindTexture(this._gl.TEXTURE_2D,null),this.resetTextureCache(),e.isReady=!0}catch(r){e._isDisabled=!0}}},o.prototype.createRenderTargetTexture=function(t,n){var s=!1,a=!0,h=o.TEXTURETYPE_UNSIGNED_INT,c=e.Texture.TRILINEAR_SAMPLINGMODE;void 0!==n&&(s=void 0===n.generateMipMaps?n:n.generateMipMaps,a=void 0===n.generateDepthBuffer?!0:n.generateDepthBuffer,h=void 0===n.type?h:n.type,void 0!==n.samplingMode&&(c=n.samplingMode),h===o.TEXTURETYPE_FLOAT&&(c=e.Texture.NEAREST_SAMPLINGMODE));var l=this._gl,u=l.createTexture();l.bindTexture(l.TEXTURE_2D,u);var f=t.width||t,d=t.height||t,p=r(c,s,l);h!==o.TEXTURETYPE_FLOAT||this._caps.textureFloat||(h=o.TEXTURETYPE_UNSIGNED_INT,e.Tools.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type")),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MAG_FILTER,p.mag),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MIN_FILTER,p.min),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_S,l.CLAMP_TO_EDGE),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_T,l.CLAMP_TO_EDGE),l.texImage2D(l.TEXTURE_2D,0,l.RGBA,f,d,0,l.RGBA,i(l,h),null);var _;a&&(_=l.createRenderbuffer(),l.bindRenderbuffer(l.RENDERBUFFER,_),l.renderbufferStorage(l.RENDERBUFFER,l.DEPTH_COMPONENT16,f,d));var m=l.createFramebuffer();return l.bindFramebuffer(l.FRAMEBUFFER,m),a&&l.framebufferRenderbuffer(l.FRAMEBUFFER,l.DEPTH_ATTACHMENT,l.RENDERBUFFER,_),s&&this._gl.generateMipmap(this._gl.TEXTURE_2D),l.bindTexture(l.TEXTURE_2D,null),l.bindRenderbuffer(l.RENDERBUFFER,null),l.bindFramebuffer(l.FRAMEBUFFER,null),u._framebuffer=m,a&&(u._depthBuffer=_),u._baseWidth=f,u._baseHeight=d,u._width=f,u._height=d,u.isReady=!0,u.generateMipMaps=s,u.references=1,u.samplingMode=c,this.resetTextureCache(),this._loadedTexturesCache.push(u),
  5. u},o.prototype.createRenderTargetCubeTexture=function(t,i){var n=this._gl,o=n.createTexture(),s=!0,a=e.Texture.TRILINEAR_SAMPLINGMODE;void 0!==i&&(s=void 0===i.generateMipMaps?i:i.generateMipMaps,void 0!==i.samplingMode&&(a=i.samplingMode)),o.isCube=!0,o.references=1,o.generateMipMaps=s,o.references=1,o.samplingMode=a;var h=r(a,s,n);n.bindTexture(n.TEXTURE_CUBE_MAP,o);for(var c=0;6>c;c++)n.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+c,0,n.RGBA,t,t,0,n.RGBA,n.UNSIGNED_BYTE,null);n.texParameteri(n.TEXTURE_CUBE_MAP,n.TEXTURE_MAG_FILTER,h.mag),n.texParameteri(n.TEXTURE_CUBE_MAP,n.TEXTURE_MIN_FILTER,h.min),n.texParameteri(n.TEXTURE_CUBE_MAP,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_CUBE_MAP,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE);var l=n.createRenderbuffer();n.bindRenderbuffer(n.RENDERBUFFER,l),n.renderbufferStorage(n.RENDERBUFFER,n.DEPTH_COMPONENT16,t,t);var u=n.createFramebuffer();return n.bindFramebuffer(n.FRAMEBUFFER,u),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.RENDERBUFFER,l),o.generateMipMaps&&(n.bindTexture(n.TEXTURE_CUBE_MAP,o),n.generateMipmap(n.TEXTURE_CUBE_MAP)),n.bindTexture(n.TEXTURE_CUBE_MAP,null),n.bindRenderbuffer(n.RENDERBUFFER,null),n.bindFramebuffer(n.FRAMEBUFFER,null),o._framebuffer=u,o._depthBuffer=l,this.resetTextureCache(),o._width=t,o._height=t,o.isReady=!0,o},o.prototype.createCubeTexture=function(t,i,r,n){var o=this,a=this._gl,h=a.createTexture();h.isCube=!0,h.url=t,h.references=1;var c=t.substr(t.length-4,4).toLowerCase(),l=this.getCaps().s3tc&&".dds"===c;return l?e.Tools.LoadFile(t,function(t){var i=e.Internals.DDSTools.GetDDSInfo(t),r=(i.isRGB||i.isLuminance||i.mipmapCount>1)&&!n;a.bindTexture(a.TEXTURE_CUBE_MAP,h),a.pixelStorei(a.UNPACK_FLIP_Y_WEBGL,1),e.Internals.DDSTools.UploadDDSLevels(o._gl,o.getCaps().s3tc,t,i,r,6),n||i.isFourCC||1!==i.mipmapCount||a.generateMipmap(a.TEXTURE_CUBE_MAP),a.texParameteri(a.TEXTURE_CUBE_MAP,a.TEXTURE_MAG_FILTER,a.LINEAR),a.texParameteri(a.TEXTURE_CUBE_MAP,a.TEXTURE_MIN_FILTER,r?a.LINEAR_MIPMAP_LINEAR:a.LINEAR),a.texParameteri(a.TEXTURE_CUBE_MAP,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_CUBE_MAP,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE),a.bindTexture(a.TEXTURE_CUBE_MAP,null),o.resetTextureCache(),h._width=i.width,h._height=i.height,h.isReady=!0},null,null,!0):s(t,i,function(t){var i=e.Tools.GetExponentOfTwo(t[0].width,o._caps.maxCubemapTextureSize),r=i;o._prepareWorkingCanvas(),o._workingCanvas.width=i,o._workingCanvas.height=r;var s=[a.TEXTURE_CUBE_MAP_POSITIVE_X,a.TEXTURE_CUBE_MAP_POSITIVE_Y,a.TEXTURE_CUBE_MAP_POSITIVE_Z,a.TEXTURE_CUBE_MAP_NEGATIVE_X,a.TEXTURE_CUBE_MAP_NEGATIVE_Y,a.TEXTURE_CUBE_MAP_NEGATIVE_Z];a.bindTexture(a.TEXTURE_CUBE_MAP,h),a.pixelStorei(a.UNPACK_FLIP_Y_WEBGL,0);for(var c=0;c<s.length;c++)o._workingContext.drawImage(t[c],0,0,t[c].width,t[c].height,0,0,i,r),a.texImage2D(s[c],0,a.RGBA,a.RGBA,a.UNSIGNED_BYTE,o._workingCanvas);n||a.generateMipmap(a.TEXTURE_CUBE_MAP),a.texParameteri(a.TEXTURE_CUBE_MAP,a.TEXTURE_MAG_FILTER,a.LINEAR),a.texParameteri(a.TEXTURE_CUBE_MAP,a.TEXTURE_MIN_FILTER,n?a.LINEAR:a.LINEAR_MIPMAP_LINEAR),a.texParameteri(a.TEXTURE_CUBE_MAP,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_CUBE_MAP,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE),a.bindTexture(a.TEXTURE_CUBE_MAP,null),o.resetTextureCache(),h._width=i,h._height=r,h.isReady=!0},r),h},o.prototype.updateTextureSize=function(e,t,i){e._width=t,e._height=i,e._size=t*i,e._baseWidth=t,e._baseHeight=i},o.prototype.createRawCubeTexture=function(t,i,r,n,s,a,h,c){var l=this,u=this._gl,f=u.createTexture();i._addPendingData(f),f.isCube=!0,f.references=1,f.url=t;var d=this._getInternalFormat(n),p=u.UNSIGNED_BYTE;s===o.TEXTURETYPE_FLOAT&&(p=u.FLOAT);var _=r,m=_,g=e.Tools.IsExponentOfTwo(_)&&e.Tools.IsExponentOfTwo(m);f._width=_,f._height=m;var v=function(){i._removePendingData(f)},y=function(t){var r=h(t),n=[u.TEXTURE_CUBE_MAP_POSITIVE_X,u.TEXTURE_CUBE_MAP_POSITIVE_Y,u.TEXTURE_CUBE_MAP_POSITIVE_Z,u.TEXTURE_CUBE_MAP_NEGATIVE_X,u.TEXTURE_CUBE_MAP_NEGATIVE_Y,u.TEXTURE_CUBE_MAP_NEGATIVE_Z];if(_=f._width,m=f._height,g=e.Tools.IsExponentOfTwo(_)&&e.Tools.IsExponentOfTwo(m),u.bindTexture(u.TEXTURE_CUBE_MAP,f),u.pixelStorei(u.UNPACK_FLIP_Y_WEBGL,0),!a&&g)if(c){var o=[];o.push(r[0]),o.push(r[3]),o.push(r[1]),o.push(r[4]),o.push(r[2]),o.push(r[5]);for(var s=c(o),v=0;v<s.length;v++){var y=_>>v;u.texImage2D(n[0],v,d,y,y,0,d,p,s[v][0]),u.texImage2D(n[1],v,d,y,y,0,d,p,s[v][2]),u.texImage2D(n[2],v,d,y,y,0,d,p,s[v][4]),u.texImage2D(n[3],v,d,y,y,0,d,p,s[v][1]),u.texImage2D(n[4],v,d,y,y,0,d,p,s[v][3]),u.texImage2D(n[5],v,d,y,y,0,d,p,s[v][5])}}else{for(var x=0;x<n.length;x++){var b=r[x];u.texImage2D(n[x],0,d,_,m,0,d,p,b)}if(u.generateMipmap(u.TEXTURE_CUBE_MAP),p===u.FLOAT&&d===u.RGB&&1282===u.getError()){e.Tools.Log("RGB32F not renderable on Firefox, trying fallback to RGBA32F.");for(var x=0;x<n.length;x++){for(var b=r[x],P=new Float32Array(_*m*4),A=0;_>A;A++)for(var T=0;m>T;T++){var E=3*(T*_+A),C=4*(T*_+A);P[C+0]=b[E+0],P[C+1]=b[E+1],P[C+2]=b[E+2],P[C+3]=1}u.texImage2D(n[x],0,u.RGBA,_,m,0,u.RGBA,p,P)}u.generateMipmap(u.TEXTURE_CUBE_MAP)}}else a=!0;p!==u.FLOAT||l._caps.textureFloatLinearFiltering?(u.texParameteri(u.TEXTURE_CUBE_MAP,u.TEXTURE_MAG_FILTER,u.LINEAR),u.texParameteri(u.TEXTURE_CUBE_MAP,u.TEXTURE_MIN_FILTER,a?u.LINEAR:u.LINEAR_MIPMAP_LINEAR)):(u.texParameteri(u.TEXTURE_CUBE_MAP,u.TEXTURE_MAG_FILTER,u.NEAREST),u.texParameteri(u.TEXTURE_CUBE_MAP,u.TEXTURE_MIN_FILTER,u.NEAREST)),u.texParameteri(u.TEXTURE_CUBE_MAP,u.TEXTURE_WRAP_S,u.CLAMP_TO_EDGE),u.texParameteri(u.TEXTURE_CUBE_MAP,u.TEXTURE_WRAP_T,u.CLAMP_TO_EDGE),u.bindTexture(u.TEXTURE_CUBE_MAP,null),f.isReady=!0,l.resetTextureCache(),i._removePendingData(f)};return e.Tools.LoadFile(t,function(e){y(e)},v,i.database,!0),f},o.prototype._releaseTexture=function(e){var t=this._gl;e._framebuffer&&t.deleteFramebuffer(e._framebuffer),e._depthBuffer&&t.deleteRenderbuffer(e._depthBuffer),t.deleteTexture(e),this.unbindAllTextures();var i=this._loadedTexturesCache.indexOf(e);-1!==i&&this._loadedTexturesCache.splice(i,1)},o.prototype.bindSamplers=function(e){this._gl.useProgram(e.getProgram());for(var t=e.getSamplers(),i=0;i<t.length;i++){var r=e.getUniform(t[i]);this._gl.uniform1i(r,i)}this._currentEffect=null},o.prototype._bindTexture=function(e,t){0>e||(this._gl.activeTexture(this._gl["TEXTURE"+e]),this._gl.bindTexture(this._gl.TEXTURE_2D,t),this._activeTexturesCache[e]=null)},o.prototype.setTextureFromPostProcess=function(e,t){this._bindTexture(e,t._textures.data[t._currentRenderTextureInd])},o.prototype.unbindAllTextures=function(){for(var e=0;e<this._caps.maxTexturesImageUnits;e++)this._gl.activeTexture(this._gl["TEXTURE"+e]),this._gl.bindTexture(this._gl.TEXTURE_2D,null),this._gl.bindTexture(this._gl.TEXTURE_CUBE_MAP,null),this._activeTexturesCache[e]=null},o.prototype.setTexture=function(t,i){if(!(0>t)){if(!i||!i.isReady())return void(null!=this._activeTexturesCache[t]&&(this._gl.activeTexture(this._gl["TEXTURE"+t]),this._gl.bindTexture(this._gl.TEXTURE_2D,null),this._gl.bindTexture(this._gl.TEXTURE_CUBE_MAP,null),this._activeTexturesCache[t]=null));var r=!1;if(i instanceof e.VideoTexture)this._gl.activeTexture(this._gl["TEXTURE"+t]),r=!0,i.update();else if(i.delayLoadState===o.DELAYLOADSTATE_NOTLOADED)return void i.delayLoad();if(this._activeTexturesCache[t]!==i){this._activeTexturesCache[t]=i;var n=i.getInternalTexture();if(r||this._gl.activeTexture(this._gl["TEXTURE"+t]),n.isCube){if(this._gl.bindTexture(this._gl.TEXTURE_CUBE_MAP,n),n._cachedCoordinatesMode!==i.coordinatesMode){n._cachedCoordinatesMode=i.coordinatesMode;var s=i.coordinatesMode!==e.Texture.CUBIC_MODE&&i.coordinatesMode!==e.Texture.SKYBOX_MODE?this._gl.REPEAT:this._gl.CLAMP_TO_EDGE;this._gl.texParameteri(this._gl.TEXTURE_CUBE_MAP,this._gl.TEXTURE_WRAP_S,s),this._gl.texParameteri(this._gl.TEXTURE_CUBE_MAP,this._gl.TEXTURE_WRAP_T,s)}this._setAnisotropicLevel(this._gl.TEXTURE_CUBE_MAP,i)}else{if(this._gl.bindTexture(this._gl.TEXTURE_2D,n),n._cachedWrapU!==i.wrapU)switch(n._cachedWrapU=i.wrapU,i.wrapU){case e.Texture.WRAP_ADDRESSMODE:this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_WRAP_S,this._gl.REPEAT);break;case e.Texture.CLAMP_ADDRESSMODE:this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_WRAP_S,this._gl.CLAMP_TO_EDGE);break;case e.Texture.MIRROR_ADDRESSMODE:this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_WRAP_S,this._gl.MIRRORED_REPEAT)}if(n._cachedWrapV!==i.wrapV)switch(n._cachedWrapV=i.wrapV,i.wrapV){case e.Texture.WRAP_ADDRESSMODE:this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_WRAP_T,this._gl.REPEAT);break;case e.Texture.CLAMP_ADDRESSMODE:this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_WRAP_T,this._gl.CLAMP_TO_EDGE);break;case e.Texture.MIRROR_ADDRESSMODE:this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_WRAP_T,this._gl.MIRRORED_REPEAT)}this._setAnisotropicLevel(this._gl.TEXTURE_2D,i)}}}},o.prototype._setAnisotropicLevel=function(t,i){var r=this._caps.textureAnisotropicFilterExtension,n=i.anisotropicFilteringLevel;i.getInternalTexture().samplingMode===e.Texture.NEAREST_SAMPLINGMODE&&(n=1),r&&i._cachedAnisotropicFilteringLevel!==n&&(this._gl.texParameterf(t,r.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(n,this._caps.maxAnisotropy)),i._cachedAnisotropicFilteringLevel=n)},o.prototype.readPixels=function(e,t,i,r){var n=new Uint8Array(r*i*4);return this._gl.readPixels(e,t,i,r,this._gl.RGBA,this._gl.UNSIGNED_BYTE,n),n},o.prototype.addExternalData=function(e,t){return this._externalData.add(e,t)},o.prototype.getExternalData=function(e){return this._externalData.get(e)},o.prototype.getOrAddExternalDataWithFactory=function(e,t){return this._externalData.getOrAddWithFactory(e,t)},o.prototype.removeExternalData=function(e){return this._externalData.remove(e)},o.prototype.releaseInternalTexture=function(e){if(e&&(e.references--,0===e.references)){var t=this.getLoadedTexturesCache(),i=t.indexOf(e);i>-1&&t.splice(i,1),this._releaseTexture(e)}},o.prototype.dispose=function(){for(this.hideLoadingUI(),this.stopRenderLoop();this.scenes.length;)this.scenes[0].dispose();o.audioEngine.dispose();for(var e in this._compiledEffects)this._gl.deleteProgram(this._compiledEffects[e]._program);if(this._vertexAttribArraysEnabled)for(var t=0,i=this._vertexAttribArraysEnabled.length;i>t;t++)t>this._gl.VERTEX_ATTRIB_ARRAY_ENABLED||!this._vertexAttribArraysEnabled[t]||this._gl.disableVertexAttribArray(t);this._gl=null,window.removeEventListener("blur",this._onBlur),window.removeEventListener("focus",this._onFocus),document.removeEventListener("fullscreenchange",this._onFullscreenChange),document.removeEventListener("mozfullscreenchange",this._onFullscreenChange),document.removeEventListener("webkitfullscreenchange",this._onFullscreenChange),document.removeEventListener("msfullscreenchange",this._onFullscreenChange),document.removeEventListener("pointerlockchange",this._onPointerLockChange),document.removeEventListener("mspointerlockchange",this._onPointerLockChange),document.removeEventListener("mozpointerlockchange",this._onPointerLockChange),document.removeEventListener("webkitpointerlockchange",this._onPointerLockChange)},o.prototype.displayLoadingUI=function(){this._loadingScreen.displayLoadingUI()},o.prototype.hideLoadingUI=function(){this._loadingScreen.hideLoadingUI()},Object.defineProperty(o.prototype,"loadingScreen",{get:function(){return this._loadingScreen},set:function(e){this._loadingScreen=e},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"loadingUIText",{set:function(e){this._loadingScreen.loadingUIText=e},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"loadingUIBackgroundColor",{set:function(e){this._loadingScreen.loadingUIBackgroundColor=e},enumerable:!0,configurable:!0}),o.prototype.getFps=function(){return this.fps},o.prototype.getDeltaTime=function(){return this.deltaTime},o.prototype._measureFps=function(){this.previousFramesDuration.push(e.Tools.Now);var t=this.previousFramesDuration.length;if(t>=2&&(this.deltaTime=this.previousFramesDuration[t-1]-this.previousFramesDuration[t-2]),t>=this.fpsRange){t>this.fpsRange&&(this.previousFramesDuration.splice(0,1),t=this.previousFramesDuration.length);for(var i=0,r=0;t-1>r;r++)i+=this.previousFramesDuration[r+1]-this.previousFramesDuration[r];this.fps=1e3/(i/(t-1))}},o.isSupported=function(){try{if(navigator.isCocoonJS)return!0;var e=document.createElement("canvas"),t=e.getContext("webgl")||e.getContext("experimental-webgl");return null!=t&&!!window.WebGLRenderingContext}catch(i){return!1}},o._ALPHA_DISABLE=0,o._ALPHA_ADD=1,o._ALPHA_COMBINE=2,o._ALPHA_SUBTRACT=3,o._ALPHA_MULTIPLY=4,o._ALPHA_MAXIMIZED=5,o._ALPHA_ONEONE=6,o._DELAYLOADSTATE_NONE=0,o._DELAYLOADSTATE_LOADED=1,o._DELAYLOADSTATE_LOADING=2,o._DELAYLOADSTATE_NOTLOADED=4,o._TEXTUREFORMAT_ALPHA=0,o._TEXTUREFORMAT_LUMINANCE=1,o._TEXTUREFORMAT_LUMINANCE_ALPHA=2,o._TEXTUREFORMAT_RGB=4,o._TEXTUREFORMAT_RGBA=5,o._TEXTURETYPE_UNSIGNED_INT=0,o._TEXTURETYPE_FLOAT=1,o.CollisionsEpsilon=.001,o.CodeRepository="src/",o.ShadersRepository="src/Shaders/",o}();e.Engine=c}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(e,t){this.state="",this.animations=new Array,this._ranges={},this._childrenFlag=-1,this._isEnabled=!0,this._isReady=!0,this._currentRenderId=-1,this._parentRenderId=-1,this.name=e,this.id=e,this._scene=t,this._initCache()}return Object.defineProperty(t.prototype,"parent",{get:function(){return this._parentNode},set:function(e){if(this._parentNode!==e){if(this._parentNode){var t=this._parentNode._children.indexOf(this);-1!==t&&this._parentNode._children.splice(t,1)}this._parentNode=e,this._parentNode&&(this._parentNode._children||(this._parentNode._children=new Array),this._parentNode._children.push(this))}},enumerable:!0,configurable:!0}),t.prototype.getScene=function(){return this._scene},t.prototype.getEngine=function(){return this._scene.getEngine()},t.prototype.getWorldMatrix=function(){return e.Matrix.Identity()},t.prototype._initCache=function(){this._cache={},this._cache.parent=void 0},t.prototype.updateCache=function(e){!e&&this.isSynchronized()||(this._cache.parent=this.parent,this._updateCache())},t.prototype._updateCache=function(e){},t.prototype._isSynchronized=function(){return!0},t.prototype._markSyncedWithParent=function(){this._parentRenderId=this.parent._currentRenderId},t.prototype.isSynchronizedWithParent=function(){return this.parent?this._parentRenderId!==this.parent._currentRenderId?!1:this.parent.isSynchronized():!0},t.prototype.isSynchronized=function(e){var t=this.hasNewParent();return t=t||!this.isSynchronizedWithParent(),t=t||!this._isSynchronized(),e&&this.updateCache(!0),!t},t.prototype.hasNewParent=function(e){return this._cache.parent===this.parent?!1:(e&&(this._cache.parent=this.parent),!0)},t.prototype.isReady=function(){return this._isReady},t.prototype.isEnabled=function(){return this._isEnabled?this.parent?this.parent.isEnabled():!0:!1},t.prototype.setEnabled=function(e){this._isEnabled=e},t.prototype.isDescendantOf=function(e){return this.parent?this.parent===e?!0:this.parent.isDescendantOf(e):!1},t.prototype._getDescendants=function(e,t,i){if(void 0===t&&(t=!1),this._children)for(var r=0;r<this._children.length;r++){var n=this._children[r];i&&!i(n)||e.push(n),t||n._getDescendants(e,!1,i)}},t.prototype.getDescendants=function(e,t){var i=[];return this._getDescendants(i,e,t),i},t.prototype.getChildren=function(e){return this.getDescendants(!0,e)},t.prototype.getChildMeshes=function(t,i){var r=[];return this._getDescendants(r,t,function(t){return(!i||i(t))&&t instanceof e.AbstractMesh}),r},t.prototype._setReady=function(e){if(e!==this._isReady){if(!e)return void(this._isReady=!1);this._isReady=!0,this.onReady&&this.onReady(this)}},t.prototype.getAnimationByName=function(e){for(var t=0;t<this.animations.length;t++){var i=this.animations[t];if(i.name===e)return i}return null},t.prototype.createAnimationRange=function(t,i,r){if(!this._ranges[t]){this._ranges[t]=new e.AnimationRange(t,i,r);for(var n=0,o=this.animations.length;o>n;n++)this.animations[n]&&this.animations[n].createRange(t,i,r)}},t.prototype.deleteAnimationRange=function(e,t){void 0===t&&(t=!0);for(var i=0,r=this.animations.length;r>i;i++)this.animations[i]&&this.animations[i].deleteRange(e,t);this._ranges[e]=void 0},t.prototype.getAnimationRange=function(e){return this._ranges[e]},t.prototype.beginAnimation=function(e,t,i,r){var n=this.getAnimationRange(e);return n?void this._scene.beginAnimation(this,n.from,n.to,t,i,r):null},t.prototype.serializeAnimationRanges=function(){var e=[];for(var t in this._ranges){var i={};i.name=t,i.from=this._ranges[t].from,i.to=this._ranges[t].to,e.push(i)}return e},t.prototype.dispose=function(){this.parent=null},t.ParseAnimationRanges=function(e,t,i){if(t.ranges)for(var r=0;r<t.ranges.length;r++){var n=t.ranges[r];e.createAnimationRange(n.name,n.from,n.to)}},__decorate([e.serialize()],t.prototype,"name",void 0),__decorate([e.serialize()],t.prototype,"id",void 0),__decorate([e.serialize()],t.prototype,"uniqueId",void 0),__decorate([e.serialize()],t.prototype,"state",void 0),t}();e.Node=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(e,t,i,r,n,o,s,a){this._engine=e,this._canvas=i,this._currentScene=t,this._sceneLoadedCallback=r,this._progressCallback=n,this._additionnalRenderLoopLogicCallback=o,this._textureLoadingCallback=s,this._startingProcessingFilesCallback=a}return t.prototype.monitorElementForDragNDrop=function(e){var t=this;e&&(this._elementToMonitor=e,this._elementToMonitor.addEventListener("dragenter",function(e){t.drag(e)},!1),this._elementToMonitor.addEventListener("dragover",function(e){t.drag(e)},!1),this._elementToMonitor.addEventListener("drop",function(e){t.drop(e)},!1))},t.prototype.renderFunction=function(){if(this._additionnalRenderLoopLogicCallback&&this._additionnalRenderLoopLogicCallback(),this._currentScene){if(this._textureLoadingCallback){var e=this._currentScene.getWaitingItemsCount();e>0&&this._textureLoadingCallback(e)}this._currentScene.render()}},t.prototype.drag=function(e){e.stopPropagation(),e.preventDefault()},t.prototype.drop=function(e){e.stopPropagation(),e.preventDefault(),this.loadFiles(e)},t.prototype.loadFiles=function(e){if(this._startingProcessingFilesCallback&&this._startingProcessingFilesCallback(),e&&e.dataTransfer&&e.dataTransfer.files&&(this._filesToLoad=e.dataTransfer.files),e&&e.target&&e.target.files&&(this._filesToLoad=e.target.files),this._filesToLoad&&this._filesToLoad.length>0){for(var i=0;i<this._filesToLoad.length;i++)switch(this._filesToLoad[i].type){case"image/jpeg":case"image/png":case"image/bmp":t.FilesTextures[this._filesToLoad[i].name.toLowerCase()]=this._filesToLoad[i];break;case"image/targa":case"image/vnd.ms-dds":case"audio/wav":case"audio/x-wav":case"audio/mp3":case"audio/mpeg":case"audio/mpeg3":case"audio/x-mpeg-3":case"audio/ogg":t.FilesToLoad[this._filesToLoad[i].name.toLowerCase()]=this._filesToLoad[i];break;default:-1!==this._filesToLoad[i].name.indexOf(".mtl")?t.FilesToLoad[this._filesToLoad[i].name.toLowerCase()]=this._filesToLoad[i]:-1===this._filesToLoad[i].name.indexOf(".babylon")&&-1===this._filesToLoad[i].name.indexOf(".stl")&&-1===this._filesToLoad[i].name.indexOf(".obj")||-1!==this._filesToLoad[i].name.indexOf(".manifest")||-1!==this._filesToLoad[i].name.indexOf(".incremental")||-1!==this._filesToLoad[i].name.indexOf(".babylonmeshdata")||-1!==this._filesToLoad[i].name.indexOf(".babylongeometrydata")||-1!==this._filesToLoad[i].name.indexOf(".babylonbinarymeshdata")||-1!==this._filesToLoad[i].name.indexOf(".binary.babylon")||(this._sceneFileToLoad=this._filesToLoad[i])}this.reload()}},t.prototype.reload=function(){var t=this,i=this;this._sceneFileToLoad?(this._currentScene&&(e.Tools.errorsCount>0&&(e.Tools.ClearLogCache(),e.Tools.Log("Babylon.js engine (v"+e.Engine.Version+") launched")),this._engine.stopRenderLoop(),this._currentScene.dispose()),e.SceneLoader.Load("file:",this._sceneFileToLoad,this._engine,function(e){i._currentScene=e,i._currentScene.executeWhenReady(function(){i._currentScene.activeCamera&&0!==i._currentScene.lights.length||i._currentScene.createDefaultCameraOrLight(),i._currentScene.activeCamera.attachControl(i._canvas),i._sceneLoadedCallback&&i._sceneLoadedCallback(t._sceneFileToLoad,i._currentScene),i._engine.runRenderLoop(function(){i.renderFunction()})})},function(e){t._progressCallback&&t._progressCallback(e)})):e.Tools.Error("Please provide a valid .babylon file.")},t.FilesTextures=new Array,t.FilesToLoad=new Array,t}();e.FilesInput=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function e(e,t,i){this.bu=e,this.bv=t,this.distance=i,this.faceId=0,this.subMeshId=0}return e}();e.IntersectionInfo=t;var i=function(){function t(){this.hit=!1,this.distance=0,this.pickedPoint=null,this.pickedMesh=null,this.bu=0,this.bv=0,this.faceId=-1,this.subMeshId=0,this.pickedSprite=null}return t.prototype.getNormal=function(t,i){if(void 0===t&&(t=!1),void 0===i&&(i=!0),!this.pickedMesh||!this.pickedMesh.isVerticesDataPresent(e.VertexBuffer.NormalKind))return null;var r,n=this.pickedMesh.getIndices();if(i){var o=this.pickedMesh.getVerticesData(e.VertexBuffer.NormalKind),s=e.Vector3.FromArray(o,3*n[3*this.faceId]),a=e.Vector3.FromArray(o,3*n[3*this.faceId+1]),h=e.Vector3.FromArray(o,3*n[3*this.faceId+2]);s=s.scale(this.bu),a=a.scale(this.bv),h=h.scale(1-this.bu-this.bv),r=new e.Vector3(s.x+a.x+h.x,s.y+a.y+h.y,s.z+a.z+h.z)}else{var c=this.pickedMesh.getVerticesData(e.VertexBuffer.PositionKind),l=e.Vector3.FromArray(c,3*n[3*this.faceId]),u=e.Vector3.FromArray(c,3*n[3*this.faceId+1]),f=e.Vector3.FromArray(c,3*n[3*this.faceId+2]),d=l.subtract(u),p=f.subtract(u);r=e.Vector3.Cross(d,p)}return t&&(r=e.Vector3.TransformNormal(r,this.pickedMesh.getWorldMatrix())),e.Vector3.Normalize(r)},t.prototype.getTextureCoordinates=function(){if(!this.pickedMesh||!this.pickedMesh.isVerticesDataPresent(e.VertexBuffer.UVKind))return null;var t=this.pickedMesh.getIndices(),i=this.pickedMesh.getVerticesData(e.VertexBuffer.UVKind),r=e.Vector2.FromArray(i,2*t[3*this.faceId]),n=e.Vector2.FromArray(i,2*t[3*this.faceId+1]),o=e.Vector2.FromArray(i,2*t[3*this.faceId+2]);return r=r.scale(1-this.bu-this.bv),n=n.scale(this.bu),o=o.scale(this.bv),new e.Vector2(r.x+n.x+o.x,r.y+n.y+o.y)},t}();e.PickingInfo=i}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(t,i){this.minimum=t,this.maximum=i,this._tempRadiusVector=e.Vector3.Zero();var r=e.Vector3.Distance(t,i);this.center=e.Vector3.Lerp(t,i,.5),this.radius=.5*r,this.centerWorld=e.Vector3.Zero(),this._update(e.Matrix.Identity())}return t.prototype._update=function(t){e.Vector3.TransformCoordinatesToRef(this.center,t,this.centerWorld),e.Vector3.TransformNormalFromFloatsToRef(1,1,1,t,this._tempRadiusVector),this.radiusWorld=Math.max(Math.abs(this._tempRadiusVector.x),Math.abs(this._tempRadiusVector.y),Math.abs(this._tempRadiusVector.z))*this.radius},t.prototype.isInFrustum=function(e){for(var t=0;6>t;t++)if(e[t].dotCoordinate(this.centerWorld)<=-this.radiusWorld)return!1;return!0},t.prototype.intersectsPoint=function(t){var i=this.centerWorld.x-t.x,r=this.centerWorld.y-t.y,n=this.centerWorld.z-t.z,o=Math.sqrt(i*i+r*r+n*n);return!(Math.abs(this.radiusWorld-o)<e.Epsilon)},t.Intersects=function(e,t){var i=e.centerWorld.x-t.centerWorld.x,r=e.centerWorld.y-t.centerWorld.y,n=e.centerWorld.z-t.centerWorld.z,o=Math.sqrt(i*i+r*r+n*n);return!(e.radiusWorld+t.radiusWorld<o)},t}();e.BoundingSphere=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(t,i){this.minimum=t,this.maximum=i,this.vectors=new Array,this.vectorsWorld=new Array,this.vectors.push(this.minimum.clone()),this.vectors.push(this.maximum.clone()),this.vectors.push(this.minimum.clone()),this.vectors[2].x=this.maximum.x,this.vectors.push(this.minimum.clone()),this.vectors[3].y=this.maximum.y,this.vectors.push(this.minimum.clone()),this.vectors[4].z=this.maximum.z,this.vectors.push(this.maximum.clone()),this.vectors[5].z=this.minimum.z,this.vectors.push(this.maximum.clone()),this.vectors[6].x=this.minimum.x,this.vectors.push(this.maximum.clone()),this.vectors[7].y=this.minimum.y,this.center=this.maximum.add(this.minimum).scale(.5),this.extendSize=this.maximum.subtract(this.minimum).scale(.5),this.directions=[e.Vector3.Zero(),e.Vector3.Zero(),e.Vector3.Zero()];for(var r=0;r<this.vectors.length;r++)this.vectorsWorld[r]=e.Vector3.Zero();this.minimumWorld=e.Vector3.Zero(),this.maximumWorld=e.Vector3.Zero(),this._update(e.Matrix.Identity())}return t.prototype.getWorldMatrix=function(){return this._worldMatrix},t.prototype.setWorldMatrix=function(e){return this._worldMatrix.copyFrom(e),this},t.prototype._update=function(t){e.Vector3.FromFloatsToRef(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,this.minimumWorld),e.Vector3.FromFloatsToRef(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE,this.maximumWorld);for(var i=0;i<this.vectors.length;i++){var r=this.vectorsWorld[i];e.Vector3.TransformCoordinatesToRef(this.vectors[i],t,r),r.x<this.minimumWorld.x&&(this.minimumWorld.x=r.x),r.y<this.minimumWorld.y&&(this.minimumWorld.y=r.y),r.z<this.minimumWorld.z&&(this.minimumWorld.z=r.z),r.x>this.maximumWorld.x&&(this.maximumWorld.x=r.x),r.y>this.maximumWorld.y&&(this.maximumWorld.y=r.y),r.z>this.maximumWorld.z&&(this.maximumWorld.z=r.z)}this.maximumWorld.addToRef(this.minimumWorld,this.center),this.center.scaleInPlace(.5),e.Vector3.FromFloatArrayToRef(t.m,0,this.directions[0]),e.Vector3.FromFloatArrayToRef(t.m,4,this.directions[1]),e.Vector3.FromFloatArrayToRef(t.m,8,this.directions[2]),this._worldMatrix=t},t.prototype.isInFrustum=function(e){return t.IsInFrustum(this.vectorsWorld,e)},t.prototype.isCompletelyInFrustum=function(e){return t.IsCompletelyInFrustum(this.vectorsWorld,e)},t.prototype.intersectsPoint=function(t){var i=-e.Epsilon;return this.maximumWorld.x-t.x<i||i>t.x-this.minimumWorld.x?!1:this.maximumWorld.y-t.y<i||i>t.y-this.minimumWorld.y?!1:!(this.maximumWorld.z-t.z<i||i>t.z-this.minimumWorld.z)},t.prototype.intersectsSphere=function(e){return t.IntersectsSphere(this.minimumWorld,this.maximumWorld,e.centerWorld,e.radiusWorld)},t.prototype.intersectsMinMax=function(e,t){return this.maximumWorld.x<e.x||this.minimumWorld.x>t.x?!1:this.maximumWorld.y<e.y||this.minimumWorld.y>t.y?!1:!(this.maximumWorld.z<e.z||this.minimumWorld.z>t.z)},t.Intersects=function(e,t){return e.maximumWorld.x<t.minimumWorld.x||e.minimumWorld.x>t.maximumWorld.x?!1:e.maximumWorld.y<t.minimumWorld.y||e.minimumWorld.y>t.maximumWorld.y?!1:!(e.maximumWorld.z<t.minimumWorld.z||e.minimumWorld.z>t.maximumWorld.z)},t.IntersectsSphere=function(t,i,r,n){var o=e.Vector3.Clamp(r,t,i),s=e.Vector3.DistanceSquared(r,o);return n*n>=s},t.IsCompletelyInFrustum=function(e,t){for(var i=0;6>i;i++)for(var r=0;8>r;r++)if(t[i].dotCoordinate(e[r])<0)return!1;return!0},t.IsInFrustum=function(e,t){for(var i=0;6>i;i++){for(var r=8,n=0;8>n&&t[i].dotCoordinate(e[n])<0;n++)--r;if(0===r)return!1}return!0},t}();e.BoundingBox=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(t,i){var r=e.Vector3.Dot(i.center,t),n=Math.abs(e.Vector3.Dot(i.directions[0],t))*i.extendSize.x,o=Math.abs(e.Vector3.Dot(i.directions[1],t))*i.extendSize.y,s=Math.abs(e.Vector3.Dot(i.directions[2],t))*i.extendSize.z,a=n+o+s;return{min:r-a,max:r+a}},i=function(e,t,i,r){return!(e>r||i>t)},r=function(e,r,n){var o=t(e,r),s=t(e,n);return i(o.min,o.max,s.min,s.max)},n=function(){function t(t,i){this.minimum=t,this.maximum=i,this._isLocked=!1,this.boundingBox=new e.BoundingBox(t,i),this.boundingSphere=new e.BoundingSphere(t,i)}return Object.defineProperty(t.prototype,"isLocked",{get:function(){return this._isLocked},set:function(e){this._isLocked=e},enumerable:!0,configurable:!0}),t.prototype.update=function(e){this._isLocked||(this.boundingBox._update(e),this.boundingSphere._update(e))},t.prototype.isInFrustum=function(e){return this.boundingSphere.isInFrustum(e)?this.boundingBox.isInFrustum(e):!1},t.prototype.isCompletelyInFrustum=function(e){return this.boundingBox.isCompletelyInFrustum(e)},t.prototype._checkCollision=function(e){return e._canDoCollision(this.boundingSphere.centerWorld,this.boundingSphere.radiusWorld,this.boundingBox.minimumWorld,this.boundingBox.maximumWorld)},t.prototype.intersectsPoint=function(e){return this.boundingSphere.centerWorld&&this.boundingSphere.intersectsPoint(e)?!!this.boundingBox.intersectsPoint(e):!1},t.prototype.intersects=function(t,i){if(!this.boundingSphere.centerWorld||!t.boundingSphere.centerWorld)return!1;if(!e.BoundingSphere.Intersects(this.boundingSphere,t.boundingSphere))return!1;if(!e.BoundingBox.Intersects(this.boundingBox,t.boundingBox))return!1;if(!i)return!0;var n=this.boundingBox,o=t.boundingBox;return r(n.directions[0],n,o)&&r(n.directions[1],n,o)&&r(n.directions[2],n,o)&&r(o.directions[0],n,o)&&r(o.directions[1],n,o)&&r(o.directions[2],n,o)&&r(e.Vector3.Cross(n.directions[0],o.directions[0]),n,o)&&r(e.Vector3.Cross(n.directions[0],o.directions[1]),n,o)&&r(e.Vector3.Cross(n.directions[0],o.directions[2]),n,o)&&r(e.Vector3.Cross(n.directions[1],o.directions[0]),n,o)&&r(e.Vector3.Cross(n.directions[1],o.directions[1]),n,o)&&r(e.Vector3.Cross(n.directions[1],o.directions[2]),n,o)&&r(e.Vector3.Cross(n.directions[2],o.directions[0]),n,o)&&r(e.Vector3.Cross(n.directions[2],o.directions[1]),n,o)?!!r(e.Vector3.Cross(n.directions[2],o.directions[2]),n,o):!1},t}();e.BoundingInfo=n}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(e,t,i){void 0===i&&(i=Number.MAX_VALUE),this.origin=e,this.direction=t,this.length=i}return t.prototype.intersectsBoxMinMax=function(e,t){var i,r,n,o,s=0,a=Number.MAX_VALUE;if(Math.abs(this.direction.x)<1e-7){if(this.origin.x<e.x||this.origin.x>t.x)return!1}else if(i=1/this.direction.x,r=(e.x-this.origin.x)*i,n=(t.x-this.origin.x)*i,n===-(1/0)&&(n=1/0),r>n&&(o=r,r=n,n=o),s=Math.max(r,s),a=Math.min(n,a),s>a)return!1;if(Math.abs(this.direction.y)<1e-7){if(this.origin.y<e.y||this.origin.y>t.y)return!1}else if(i=1/this.direction.y,r=(e.y-this.origin.y)*i,n=(t.y-this.origin.y)*i,n===-(1/0)&&(n=1/0),r>n&&(o=r,r=n,n=o),s=Math.max(r,s),a=Math.min(n,a),s>a)return!1;if(Math.abs(this.direction.z)<1e-7){if(this.origin.z<e.z||this.origin.z>t.z)return!1}else if(i=1/this.direction.z,r=(e.z-this.origin.z)*i,n=(t.z-this.origin.z)*i,n===-(1/0)&&(n=1/0),r>n&&(o=r,r=n,n=o),s=Math.max(r,s),a=Math.min(n,a),s>a)return!1;return!0},t.prototype.intersectsBox=function(e){return this.intersectsBoxMinMax(e.minimum,e.maximum)},t.prototype.intersectsSphere=function(e){var t=e.center.x-this.origin.x,i=e.center.y-this.origin.y,r=e.center.z-this.origin.z,n=t*t+i*i+r*r,o=e.radius*e.radius;if(o>=n)return!0;var s=t*this.direction.x+i*this.direction.y+r*this.direction.z;if(0>s)return!1;var a=n-s*s;return o>=a},t.prototype.intersectsTriangle=function(t,i,r){this._edge1||(this._edge1=e.Vector3.Zero(),this._edge2=e.Vector3.Zero(),this._pvec=e.Vector3.Zero(),this._tvec=e.Vector3.Zero(),this._qvec=e.Vector3.Zero()),i.subtractToRef(t,this._edge1),r.subtractToRef(t,this._edge2),e.Vector3.CrossToRef(this.direction,this._edge2,this._pvec);var n=e.Vector3.Dot(this._edge1,this._pvec);if(0===n)return null;var o=1/n;this.origin.subtractToRef(t,this._tvec);var s=e.Vector3.Dot(this._tvec,this._pvec)*o;if(0>s||s>1)return null;e.Vector3.CrossToRef(this._tvec,this._edge1,this._qvec);var a=e.Vector3.Dot(this.direction,this._qvec)*o;if(0>a||s+a>1)return null;var h=e.Vector3.Dot(this._edge2,this._qvec)*o;return h>this.length?null:new e.IntersectionInfo(s,a,h)},t.prototype.intersectsPlane=function(t){var i,r=e.Vector3.Dot(t.normal,this.direction);if(Math.abs(r)<9.99999997475243e-7)return null;var n=e.Vector3.Dot(t.normal,this.origin);return i=(-t.d-n)/r,0>i?-9.99999997475243e-7>i?null:0:i},t.prototype.intersectionSegment=function(i,r,n){var o,s,a,h,c=this.origin.add(this.direction.multiplyByFloats(t.rayl,t.rayl,t.rayl)),l=r.subtract(i),u=c.subtract(this.origin),f=i.subtract(this.origin),d=e.Vector3.Dot(l,l),p=e.Vector3.Dot(l,u),_=e.Vector3.Dot(u,u),m=e.Vector3.Dot(l,f),g=e.Vector3.Dot(u,f),v=d*_-p*p,y=v,x=v;
  6. v<t.smallnum?(s=0,y=1,h=g,x=_):(s=p*g-_*m,h=d*g-p*m,0>s?(s=0,h=g,x=_):s>y&&(s=y,h=g+p,x=_)),0>h?(h=0,0>-m?s=0:-m>d?s=y:(s=-m,y=d)):h>x&&(h=x,0>-m+p?s=0:-m+p>d?s=y:(s=-m+p,y=d)),o=Math.abs(s)<t.smallnum?0:s/y,a=Math.abs(h)<t.smallnum?0:h/x;var b=u.multiplyByFloats(a,a,a),P=f.add(l.multiplyByFloats(o,o,o)).subtract(b),A=a>0&&a<=this.length&&P.lengthSquared()<n*n;return A?b.length():-1},t.CreateNew=function(i,r,n,o,s,a,h){var c=e.Vector3.Unproject(new e.Vector3(i,r,0),n,o,s,a,h),l=e.Vector3.Unproject(new e.Vector3(i,r,1),n,o,s,a,h),u=l.subtract(c);return u.normalize(),new t(c,u)},t.CreateNewFromTo=function(i,r,n){void 0===n&&(n=e.Matrix.Identity());var o=r.subtract(i),s=Math.sqrt(o.x*o.x+o.y*o.y+o.z*o.z);return o.normalize(),t.Transform(new t(i,o,s),n)},t.Transform=function(i,r){var n=e.Vector3.TransformCoordinates(i.origin,r),o=e.Vector3.TransformNormal(i.direction,r);return o.normalize(),new t(n,o,i.length)},t.smallnum=1e-8,t.rayl=1e9,t}();e.Ray=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(t){function i(r,n){var o=this;t.call(this,r,n),this.onDisposeObservable=new e.Observable,this.onCollideObservable=new e.Observable,this.onCollisionPositionChangeObservable=new e.Observable,this.onAfterWorldMatrixUpdateObservable=new e.Observable,this.definedFacingForward=!0,this.position=new e.Vector3(0,0,0),this._rotation=new e.Vector3(0,0,0),this._scaling=new e.Vector3(1,1,1),this.billboardMode=i.BILLBOARDMODE_NONE,this.visibility=1,this.alphaIndex=Number.MAX_VALUE,this.infiniteDistance=!1,this.isVisible=!0,this.isPickable=!0,this.showBoundingBox=!1,this.showSubMeshesBoundingBox=!1,this.isBlocker=!1,this.renderingGroupId=0,this.receiveShadows=!1,this.renderOutline=!1,this.outlineColor=e.Color3.Red(),this.outlineWidth=.02,this.renderOverlay=!1,this.overlayColor=e.Color3.Red(),this.overlayAlpha=.5,this.hasVertexAlpha=!1,this.useVertexColors=!0,this.applyFog=!0,this.computeBonesUsingShaders=!0,this.scalingDeterminant=1,this.numBoneInfluencers=4,this.useOctreeForRenderingSelection=!0,this.useOctreeForPicking=!0,this.useOctreeForCollisions=!0,this.layerMask=268435455,this.alwaysSelectAsActiveMesh=!1,this._checkCollisions=!1,this.ellipsoid=new e.Vector3(.5,1,.5),this.ellipsoidOffset=new e.Vector3(0,0,0),this._collider=new e.Collider,this._oldPositionForCollisions=new e.Vector3(0,0,0),this._diffPositionForCollisions=new e.Vector3(0,0,0),this._newPositionForCollisions=new e.Vector3(0,0,0),this.edgesWidth=1,this.edgesColor=new e.Color4(1,0,0,1),this._localWorld=e.Matrix.Zero(),this._worldMatrix=e.Matrix.Zero(),this._rotateYByPI=e.Matrix.RotationY(Math.PI),this._absolutePosition=e.Vector3.Zero(),this._collisionsTransformMatrix=e.Matrix.Zero(),this._collisionsScalingMatrix=e.Matrix.Zero(),this._isDirty=!1,this._pivotMatrix=e.Matrix.Identity(),this._isDisposed=!1,this._renderId=0,this._intersectionsInProgress=new Array,this._isWorldMatrixFrozen=!1,this._unIndexed=!1,this._onCollisionPositionChange=function(t,i,r){void 0===r&&(r=null),o.getScene().workerCollisions&&i.multiplyInPlace(o._collider.radius),i.subtractToRef(o._oldPositionForCollisions,o._diffPositionForCollisions),o._diffPositionForCollisions.length()>e.Engine.CollisionsEpsilon&&o.position.addInPlace(o._diffPositionForCollisions),r&&o.onCollideObservable.notifyObservers(r),o.onCollisionPositionChangeObservable.notifyObservers(o.position)},n.addMesh(this)}return __extends(i,t),Object.defineProperty(i,"BILLBOARDMODE_NONE",{get:function(){return i._BILLBOARDMODE_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(i,"BILLBOARDMODE_X",{get:function(){return i._BILLBOARDMODE_X},enumerable:!0,configurable:!0}),Object.defineProperty(i,"BILLBOARDMODE_Y",{get:function(){return i._BILLBOARDMODE_Y},enumerable:!0,configurable:!0}),Object.defineProperty(i,"BILLBOARDMODE_Z",{get:function(){return i._BILLBOARDMODE_Z},enumerable:!0,configurable:!0}),Object.defineProperty(i,"BILLBOARDMODE_ALL",{get:function(){return i._BILLBOARDMODE_ALL},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"onCollide",{set:function(e){this._onCollideObserver&&this.onCollideObservable.remove(this._onCollideObserver),this._onCollideObserver=this.onCollideObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"onCollisionPositionChange",{set:function(e){this._onCollisionPositionChangeObserver&&this.onCollisionPositionChangeObservable.remove(this._onCollisionPositionChangeObserver),this._onCollisionPositionChangeObserver=this.onCollisionPositionChangeObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"skeleton",{get:function(){return this._skeleton},set:function(e){this._skeleton&&this._skeleton.needInitialSkinMatrix&&this._skeleton._unregisterMeshWithPoseMatrix(this),e&&e.needInitialSkinMatrix&&e._registerMeshWithPoseMatrix(this),this._skeleton=e,this._skeleton||(this._bonesTransformMatrices=null)},enumerable:!0,configurable:!0}),i.prototype.toString=function(t){var i="Name: "+this.name+", isInstance: "+(this instanceof e.InstancedMesh?"YES":"NO");return i+=", # of submeshes: "+(this.subMeshes?this.subMeshes.length:0),this._skeleton&&(i+=", skeleton: "+this._skeleton.name),t&&(i+=", billboard mode: "+["NONE","X","Y",null,"Z",null,null,"ALL"][this.billboardMode],i+=", freeze wrld mat: "+(this._isWorldMatrixFrozen||this._waitingFreezeWorldMatrix?"YES":"NO")),i},Object.defineProperty(i.prototype,"rotation",{get:function(){return this._rotation},set:function(e){this._rotation=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"scaling",{get:function(){return this._scaling},set:function(e){this._scaling=e,this.physicsImpostor&&this.physicsImpostor.forceUpdate()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"rotationQuaternion",{get:function(){return this._rotationQuaternion},set:function(e){this._rotationQuaternion=e,e&&this.rotation.length()&&this.rotation.copyFromFloats(0,0,0)},enumerable:!0,configurable:!0}),i.prototype.updatePoseMatrix=function(e){this._poseMatrix.copyFrom(e)},i.prototype.getPoseMatrix=function(){return this._poseMatrix},i.prototype.disableEdgesRendering=function(){void 0!==this._edgesRenderer&&(this._edgesRenderer.dispose(),this._edgesRenderer=void 0)},i.prototype.enableEdgesRendering=function(t,i){void 0===t&&(t=.95),void 0===i&&(i=!1),this.disableEdgesRendering(),this._edgesRenderer=new e.EdgesRenderer(this,t,i)},Object.defineProperty(i.prototype,"isBlocked",{get:function(){return!1},enumerable:!0,configurable:!0}),i.prototype.getLOD=function(e){return this},i.prototype.getTotalVertices=function(){return 0},i.prototype.getIndices=function(){return null},i.prototype.getVerticesData=function(e){return null},i.prototype.isVerticesDataPresent=function(e){return!1},i.prototype.getBoundingInfo=function(){return this._masterMesh?this._masterMesh.getBoundingInfo():(this._boundingInfo||this._updateBoundingInfo(),this._boundingInfo)},Object.defineProperty(i.prototype,"useBones",{get:function(){return this.skeleton&&this.getScene().skeletonsEnabled&&this.isVerticesDataPresent(e.VertexBuffer.MatricesIndicesKind)&&this.isVerticesDataPresent(e.VertexBuffer.MatricesWeightsKind)},enumerable:!0,configurable:!0}),i.prototype._preActivate=function(){},i.prototype._preActivateForIntermediateRendering=function(e){},i.prototype._activate=function(e){this._renderId=e},i.prototype.getWorldMatrix=function(){return this._masterMesh?this._masterMesh.getWorldMatrix():(this._currentRenderId!==this.getScene().getRenderId()&&this.computeWorldMatrix(),this._worldMatrix)},Object.defineProperty(i.prototype,"worldMatrixFromCache",{get:function(){return this._worldMatrix},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"absolutePosition",{get:function(){return this._absolutePosition},enumerable:!0,configurable:!0}),i.prototype.freezeWorldMatrix=function(){this._isWorldMatrixFrozen=!1,this.computeWorldMatrix(!0),this._isWorldMatrixFrozen=!0},i.prototype.unfreezeWorldMatrix=function(){this._isWorldMatrixFrozen=!1,this.computeWorldMatrix(!0)},Object.defineProperty(i.prototype,"isWorldMatrixFrozen",{get:function(){return this._isWorldMatrixFrozen},enumerable:!0,configurable:!0}),i.prototype.rotate=function(t,i,r){t.normalize(),this.rotationQuaternion||(this.rotationQuaternion=e.Quaternion.RotationYawPitchRoll(this.rotation.y,this.rotation.x,this.rotation.z),this.rotation=e.Vector3.Zero());var n;if(r&&r!==e.Space.LOCAL){if(this.parent){var o=this.parent.getWorldMatrix().clone();o.invert(),t=e.Vector3.TransformNormal(t,o)}n=e.Quaternion.RotationAxis(t,i),this.rotationQuaternion=n.multiply(this.rotationQuaternion)}else n=e.Quaternion.RotationAxis(t,i),this.rotationQuaternion=this.rotationQuaternion.multiply(n)},i.prototype.translate=function(t,i,r){var n=t.scale(i);if(r&&r!==e.Space.LOCAL)this.setAbsolutePosition(this.getAbsolutePosition().add(n));else{var o=this.getPositionExpressedInLocalSpace().add(n);this.setPositionWithLocalVector(o)}},i.prototype.getAbsolutePosition=function(){return this.computeWorldMatrix(),this._absolutePosition},i.prototype.setAbsolutePosition=function(t){if(t){var i,r,n;if(void 0===t.x){if(arguments.length<3)return;i=arguments[0],r=arguments[1],n=arguments[2]}else i=t.x,r=t.y,n=t.z;if(this.parent){var o=this.parent.getWorldMatrix().clone();o.invert();var s=new e.Vector3(i,r,n);this.position=e.Vector3.TransformCoordinates(s,o)}else this.position.x=i,this.position.y=r,this.position.z=n}},i.prototype.movePOV=function(e,t,i){this.position.addInPlace(this.calcMovePOV(e,t,i))},i.prototype.calcMovePOV=function(t,i,r){var n=new e.Matrix,o=this.rotationQuaternion?this.rotationQuaternion:e.Quaternion.RotationYawPitchRoll(this.rotation.y,this.rotation.x,this.rotation.z);o.toRotationMatrix(n);var s=e.Vector3.Zero(),a=this.definedFacingForward?-1:1;return e.Vector3.TransformCoordinatesFromFloatsToRef(t*a,i,r*a,n,s),s},i.prototype.rotatePOV=function(e,t,i){this.rotation.addInPlace(this.calcRotatePOV(e,t,i))},i.prototype.calcRotatePOV=function(t,i,r){var n=this.definedFacingForward?1:-1;return new e.Vector3(t*n,i,r*n)},i.prototype.setPivotMatrix=function(e){this._pivotMatrix=e,this._cache.pivotMatrixUpdated=!0},i.prototype.getPivotMatrix=function(){return this._pivotMatrix},i.prototype._isSynchronized=function(){if(this._isDirty)return!1;if(this.billboardMode!==this._cache.billboardMode||this.billboardMode!==i.BILLBOARDMODE_NONE)return!1;if(this._cache.pivotMatrixUpdated)return!1;if(this.infiniteDistance)return!1;if(!this._cache.position.equals(this.position))return!1;if(this.rotationQuaternion){if(!this._cache.rotationQuaternion.equals(this.rotationQuaternion))return!1}else if(!this._cache.rotation.equals(this.rotation))return!1;return!!this._cache.scaling.equals(this.scaling)},i.prototype._initCache=function(){t.prototype._initCache.call(this),this._cache.localMatrixUpdated=!1,this._cache.position=e.Vector3.Zero(),this._cache.scaling=e.Vector3.Zero(),this._cache.rotation=e.Vector3.Zero(),this._cache.rotationQuaternion=new e.Quaternion(0,0,0,0),this._cache.billboardMode=-1},i.prototype.markAsDirty=function(e){"rotation"===e&&(this.rotationQuaternion=null),this._currentRenderId=Number.MAX_VALUE,this._isDirty=!0},i.prototype._updateBoundingInfo=function(){this._boundingInfo=this._boundingInfo||new e.BoundingInfo(this.absolutePosition,this.absolutePosition),this._boundingInfo.update(this.worldMatrixFromCache),this._updateSubMeshesBoundingInfo(this.worldMatrixFromCache)},i.prototype._updateSubMeshesBoundingInfo=function(e){if(this.subMeshes)for(var t=0;t<this.subMeshes.length;t++){var i=this.subMeshes[t];i.IsGlobal||i.updateBoundingInfo(e)}},i.prototype.computeWorldMatrix=function(t){if(this._isWorldMatrixFrozen)return this._worldMatrix;if(!t&&(this._currentRenderId===this.getScene().getRenderId()||this.isSynchronized(!0)))return this._currentRenderId=this.getScene().getRenderId(),this._worldMatrix;if(this._cache.position.copyFrom(this.position),this._cache.scaling.copyFrom(this.scaling),this._cache.pivotMatrixUpdated=!1,this._cache.billboardMode=this.billboardMode,this._currentRenderId=this.getScene().getRenderId(),this._isDirty=!1,e.Matrix.ScalingToRef(this.scaling.x*this.scalingDeterminant,this.scaling.y*this.scalingDeterminant,this.scaling.z*this.scalingDeterminant,e.Tmp.Matrix[1]),this.rotationQuaternion){var r=this.rotation.length();r&&(this.rotationQuaternion.multiplyInPlace(e.Quaternion.RotationYawPitchRoll(this.rotation.y,this.rotation.x,this.rotation.z)),this.rotation.copyFromFloats(0,0,0))}if(this.rotationQuaternion?(this.rotationQuaternion.toRotationMatrix(e.Tmp.Matrix[0]),this._cache.rotationQuaternion.copyFrom(this.rotationQuaternion)):(e.Matrix.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,e.Tmp.Matrix[0]),this._cache.rotation.copyFrom(this.rotation)),this.infiniteDistance&&!this.parent){var n=this.getScene().activeCamera;if(n){var o=n.getWorldMatrix(),s=new e.Vector3(o.m[12],o.m[13],o.m[14]);e.Matrix.TranslationToRef(this.position.x+s.x,this.position.y+s.y,this.position.z+s.z,e.Tmp.Matrix[2])}}else e.Matrix.TranslationToRef(this.position.x,this.position.y,this.position.z,e.Tmp.Matrix[2]);if(this._pivotMatrix.multiplyToRef(e.Tmp.Matrix[1],e.Tmp.Matrix[4]),e.Tmp.Matrix[4].multiplyToRef(e.Tmp.Matrix[0],e.Tmp.Matrix[5]),this.billboardMode!==i.BILLBOARDMODE_NONE&&this.getScene().activeCamera){e.Tmp.Vector3[0].copyFrom(this.position);var a=e.Tmp.Vector3[0];if(this.parent&&this.parent.getWorldMatrix){this._markSyncedWithParent();var h;this._meshToBoneReferal?(this.parent.getWorldMatrix().multiplyToRef(this._meshToBoneReferal.getWorldMatrix(),e.Tmp.Matrix[6]),h=e.Tmp.Matrix[6]):h=this.parent.getWorldMatrix(),e.Vector3.TransformNormalToRef(a,h,e.Tmp.Vector3[1]),a=e.Tmp.Vector3[1]}var c=this.getScene().activeCamera.globalPosition.clone();this.parent&&this.parent.position&&(a.addInPlace(this.parent.position),e.Matrix.TranslationToRef(a.x,a.y,a.z,e.Tmp.Matrix[2])),(this.billboardMode&i.BILLBOARDMODE_ALL)!==i.BILLBOARDMODE_ALL&&(this.billboardMode&i.BILLBOARDMODE_X&&(c.x=a.x+e.Epsilon),this.billboardMode&i.BILLBOARDMODE_Y&&(c.y=a.y+e.Epsilon),this.billboardMode&i.BILLBOARDMODE_Z&&(c.z=a.z+e.Epsilon)),e.Matrix.LookAtLHToRef(a,c,e.Vector3.Up(),e.Tmp.Matrix[3]),e.Tmp.Matrix[3].m[12]=e.Tmp.Matrix[3].m[13]=e.Tmp.Matrix[3].m[14]=0,e.Tmp.Matrix[3].invert(),e.Tmp.Matrix[5].multiplyToRef(e.Tmp.Matrix[3],this._localWorld),this._rotateYByPI.multiplyToRef(this._localWorld,e.Tmp.Matrix[5])}return e.Tmp.Matrix[5].multiplyToRef(e.Tmp.Matrix[2],this._localWorld),this.parent&&this.parent.getWorldMatrix&&this.billboardMode===i.BILLBOARDMODE_NONE?(this._markSyncedWithParent(),this._meshToBoneReferal?(this._localWorld.multiplyToRef(this.parent.getWorldMatrix(),e.Tmp.Matrix[6]),e.Tmp.Matrix[6].multiplyToRef(this._meshToBoneReferal.getWorldMatrix(),this._worldMatrix)):this._localWorld.multiplyToRef(this.parent.getWorldMatrix(),this._worldMatrix)):this._worldMatrix.copyFrom(this._localWorld),this._updateBoundingInfo(),this._absolutePosition.copyFromFloats(this._worldMatrix.m[12],this._worldMatrix.m[13],this._worldMatrix.m[14]),this.onAfterWorldMatrixUpdateObservable.notifyObservers(this),this._poseMatrix||(this._poseMatrix=e.Matrix.Invert(this._worldMatrix)),this._worldMatrix},i.prototype.registerAfterWorldMatrixUpdate=function(e){this.onAfterWorldMatrixUpdateObservable.add(e)},i.prototype.unregisterAfterWorldMatrixUpdate=function(e){this.onAfterWorldMatrixUpdateObservable.removeCallback(e)},i.prototype.setPositionWithLocalVector=function(t){this.computeWorldMatrix(),this.position=e.Vector3.TransformNormal(t,this._localWorld)},i.prototype.getPositionExpressedInLocalSpace=function(){this.computeWorldMatrix();var t=this._localWorld.clone();return t.invert(),e.Vector3.TransformNormal(this.position,t)},i.prototype.locallyTranslate=function(t){this.computeWorldMatrix(!0),this.position=e.Vector3.TransformCoordinates(t,this._localWorld)},i.prototype.lookAt=function(t,i,r,n){i=i||0,r=r||0,n=n||0;var o=t.subtract(this.position),s=-Math.atan2(o.z,o.x)-Math.PI/2,a=Math.sqrt(o.x*o.x+o.z*o.z),h=Math.atan2(o.y,a);this.rotationQuaternion=e.Quaternion.RotationYawPitchRoll(s+i,h+r,n)},i.prototype.attachToBone=function(e,t){this._meshToBoneReferal=t,this.parent=e,e.getWorldMatrix().determinant()<0&&(this.scalingDeterminant*=-1)},i.prototype.detachFromBone=function(){this.parent.getWorldMatrix().determinant()<0&&(this.scalingDeterminant*=-1),this._meshToBoneReferal=null,this.parent=null},i.prototype.isInFrustum=function(e){return this._boundingInfo.isInFrustum(e)},i.prototype.isCompletelyInFrustum=function(t){t||(t=this.getScene().activeCamera);var i=t.getViewMatrix().multiply(t.getProjectionMatrix());return!!this._boundingInfo.isCompletelyInFrustum(e.Frustum.GetPlanes(i))},i.prototype.intersectsMesh=function(e,t){return this._boundingInfo&&e._boundingInfo?this._boundingInfo.intersects(e._boundingInfo,t):!1},i.prototype.intersectsPoint=function(e){return this._boundingInfo?this._boundingInfo.intersectsPoint(e):!1},i.prototype.setPhysicsState=function(t,i){return t.impostor&&(i=t,t=t.impostor),this.physicsImpostor=new e.PhysicsImpostor(this,t,i,this.getScene()),this.physicsImpostor.physicsBody},i.prototype.getPhysicsImpostor=function(){return this.physicsImpostor},i.prototype.getPhysicsMass=function(){return this.physicsImpostor.getParam("mass")},i.prototype.getPhysicsFriction=function(){return this.physicsImpostor.getParam("friction")},i.prototype.getPhysicsRestitution=function(){return this.physicsImpostor.getParam("resitution")},i.prototype.getPositionInCameraSpace=function(t){return t||(t=this.getScene().activeCamera),e.Vector3.TransformCoordinates(this.absolutePosition,t.getViewMatrix())},i.prototype.getDistanceToCamera=function(e){return e||(e=this.getScene().activeCamera),this.absolutePosition.subtract(e.position).length()},i.prototype.applyImpulse=function(e,t){this.physicsImpostor&&this.physicsImpostor.applyImpulse(e,t)},i.prototype.setPhysicsLinkWith=function(t,i,r,n){this.physicsImpostor&&t.physicsImpostor&&this.physicsImpostor.createJoint(t.physicsImpostor,e.PhysicsJoint.HingeJoint,{mainPivot:i,connectedPivot:r,nativeParams:n})},i.prototype.updatePhysicsBodyPosition=function(){e.Tools.Warn("updatePhysicsBodyPosition() is deprecated, please use updatePhysicsBody()"),this.updatePhysicsBody()},i.prototype.updatePhysicsBody=function(){},Object.defineProperty(i.prototype,"checkCollisions",{get:function(){return this._checkCollisions},set:function(e){this._checkCollisions=e,this.getScene().workerCollisions&&this.getScene().collisionCoordinator.onMeshUpdated(this)},enumerable:!0,configurable:!0}),i.prototype.moveWithCollisions=function(e){var t=this.getAbsolutePosition();t.subtractFromFloatsToRef(0,this.ellipsoid.y,0,this._oldPositionForCollisions),this._oldPositionForCollisions.addInPlace(this.ellipsoidOffset),this._collider.radius=this.ellipsoid,this.getScene().collisionCoordinator.getNewPosition(this._oldPositionForCollisions,e,this._collider,3,this,this._onCollisionPositionChange,this.uniqueId)},i.prototype.createOrUpdateSubmeshesOctree=function(t,i){void 0===t&&(t=64),void 0===i&&(i=2),this._submeshesOctree||(this._submeshesOctree=new e.Octree(e.Octree.CreationFuncForSubMeshes,t,i)),this.computeWorldMatrix(!0);var r=this.getBoundingInfo().boundingBox;return this._submeshesOctree.update(r.minimumWorld,r.maximumWorld,this.subMeshes),this._submeshesOctree},i.prototype._collideForSubMesh=function(t,i,r){if(this._generatePointsArray(),!t._lastColliderWorldVertices||!t._lastColliderTransformMatrix.equals(i)){t._lastColliderTransformMatrix=i.clone(),t._lastColliderWorldVertices=[],t._trianglePlanes=[];for(var n=t.verticesStart,o=t.verticesStart+t.verticesCount,s=n;o>s;s++)t._lastColliderWorldVertices.push(e.Vector3.TransformCoordinates(this._positions[s],i))}r._collide(t._trianglePlanes,t._lastColliderWorldVertices,this.getIndices(),t.indexStart,t.indexStart+t.indexCount,t.verticesStart,!!t.getMaterial()),r.collisionFound&&(r.collidedMesh=this)},i.prototype._processCollisionsForSubMeshes=function(e,t){var i,r;if(this._submeshesOctree&&this.useOctreeForCollisions){var n=e.velocityWorldLength+Math.max(e.radius.x,e.radius.y,e.radius.z),o=this._submeshesOctree.intersects(e.basePointWorld,n);r=o.length,i=o.data}else i=this.subMeshes,r=i.length;for(var s=0;r>s;s++){var a=i[s];r>1&&!a._checkCollision(e)||this._collideForSubMesh(a,t,e)}},i.prototype._checkCollision=function(t){this._boundingInfo._checkCollision(t)&&(e.Matrix.ScalingToRef(1/t.radius.x,1/t.radius.y,1/t.radius.z,this._collisionsScalingMatrix),this.worldMatrixFromCache.multiplyToRef(this._collisionsScalingMatrix,this._collisionsTransformMatrix),this._processCollisionsForSubMeshes(t,this._collisionsTransformMatrix))},i.prototype._generatePointsArray=function(){return!1},i.prototype.intersects=function(t,i){var r=new e.PickingInfo;if(!(this.subMeshes&&this._boundingInfo&&t.intersectsSphere(this._boundingInfo.boundingSphere)&&t.intersectsBox(this._boundingInfo.boundingBox)))return r;if(!this._generatePointsArray())return r;var n,o,s=null;if(this._submeshesOctree&&this.useOctreeForPicking){var a=e.Ray.Transform(t,this.getWorldMatrix()),h=this._submeshesOctree.intersectsRay(a);o=h.length,n=h.data}else n=this.subMeshes,o=n.length;for(var c=0;o>c;c++){var l=n[c];if(!(o>1)||l.canIntersects(t)){var u=l.intersects(t,this._positions,this.getIndices(),i);if(u&&(i||!s||u.distance<s.distance)&&(s=u,s.subMeshId=c,i))break}}if(s){var f=this.getWorldMatrix(),d=e.Vector3.TransformCoordinates(t.origin,f),p=t.direction.clone();p=p.scale(s.distance);var _=e.Vector3.TransformNormal(p,f),m=d.add(_);return r.hit=!0,r.distance=e.Vector3.Distance(d,m),r.pickedPoint=m,r.pickedMesh=this,r.bu=s.bu,r.bv=s.bv,r.faceId=s.faceId,r.subMeshId=s.subMeshId,r}return r},i.prototype.clone=function(e,t,i){return null},i.prototype.releaseSubMeshes=function(){if(this.subMeshes)for(;this.subMeshes.length;)this.subMeshes[0].dispose();else this.subMeshes=new Array},i.prototype.dispose=function(e){var i,r=this;for(this.actionManager&&(this.actionManager.dispose(),this.actionManager=null),this.skeleton=null,this.getScene().stopAnimation(this),this.physicsImpostor&&this.physicsImpostor.dispose(),i=0;i<this._intersectionsInProgress.length;i++){var n=this._intersectionsInProgress[i],o=n._intersectionsInProgress.indexOf(this);n._intersectionsInProgress.splice(o,1)}this._intersectionsInProgress=[];var s=this.getScene().lights;if(s.forEach(function(e){var t=e.includedOnlyMeshes.indexOf(r);-1!==t&&e.includedOnlyMeshes.splice(t,1),t=e.excludedMeshes.indexOf(r),-1!==t&&e.excludedMeshes.splice(t,1)}),this._edgesRenderer&&(this._edgesRenderer.dispose(),this._edgesRenderer=null),this.releaseSubMeshes(),this.getScene().removeMesh(this),e){var a=this.getChildMeshes(!0);for(i=0;i<a.length;i++){var h=a[i];h.parent=null,h.computeWorldMatrix(!0)}}else{for(i=0;i<this.getScene().particleSystems.length;i++)this.getScene().particleSystems[i].emitter===this&&(this.getScene().particleSystems[i].dispose(),i--);var c=this.getDescendants(!0);for(i=0;i<c.length;i++)c[i].dispose()}t.prototype.dispose.call(this),this.onAfterWorldMatrixUpdateObservable.clear(),this.onCollideObservable.clear(),this.onCollisionPositionChangeObservable.clear(),this._isDisposed=!0,this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear()},i._BILLBOARDMODE_NONE=0,i._BILLBOARDMODE_X=1,i._BILLBOARDMODE_Y=2,i._BILLBOARDMODE_Z=4,i._BILLBOARDMODE_ALL=7,i}(e.Node);e.AbstractMesh=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(t){function i(i,r){t.call(this,i,r),this.diffuse=new e.Color3(1,1,1),this.specular=new e.Color3(1,1,1),this.intensity=1,this.range=Number.MAX_VALUE,this.includeOnlyWithLayerMask=0,this.includedOnlyMeshes=new Array,this.excludedMeshes=new Array,this.excludeWithLayerMask=0,this.radius=1e-5,this._excludedMeshesIds=new Array,this._includedOnlyMeshesIds=new Array,r.addLight(this)}return __extends(i,t),i.prototype.toString=function(e){var t="Name: "+this.name;if(t+=", type: "+["Point","Directional","Spot","Hemispheric"][this.getTypeID()],this.animations)for(var i=0;i<this.animations.length;i++)t+=", animation[0]: "+this.animations[i].toString(e);return t},i.prototype.getShadowGenerator=function(){return this._shadowGenerator},i.prototype.getAbsolutePosition=function(){return e.Vector3.Zero()},i.prototype.transferToEffect=function(e,t,i){},i.prototype._getWorldMatrix=function(){return e.Matrix.Identity()},i.prototype.canAffectMesh=function(e){return e?this.includedOnlyMeshes.length>0&&-1===this.includedOnlyMeshes.indexOf(e)?!1:this.excludedMeshes.length>0&&-1!==this.excludedMeshes.indexOf(e)?!1:0!==this.includeOnlyWithLayerMask&&0===(this.includeOnlyWithLayerMask&e.layerMask)?!1:!(0!==this.excludeWithLayerMask&&this.excludeWithLayerMask&e.layerMask):!0},i.prototype.getWorldMatrix=function(){this._currentRenderId=this.getScene().getRenderId();var t=this._getWorldMatrix();return this.parent&&this.parent.getWorldMatrix?(this._parentedWorldMatrix||(this._parentedWorldMatrix=e.Matrix.Identity()),t.multiplyToRef(this.parent.getWorldMatrix(),this._parentedWorldMatrix),this._markSyncedWithParent(),this._parentedWorldMatrix):t},i.prototype.dispose=function(){this._shadowGenerator&&(this._shadowGenerator.dispose(),this._shadowGenerator=null),this.getScene().stopAnimation(this),this.getScene().removeLight(this),t.prototype.dispose.call(this)},i.prototype.getTypeID=function(){return 0},i.prototype.clone=function(t){return e.SerializationHelper.Clone(i.GetConstructorFromName(this.getTypeID(),t,this.getScene()),this)},i.prototype.serialize=function(){var t=e.SerializationHelper.Serialize(this);return t.type=this.getTypeID(),this.parent&&(t.parentId=this.parent.id),this.excludedMeshes.length>0&&(t.excludedMeshesIds=[],this.excludedMeshes.forEach(function(e){t.excludedMeshesIds.push(e.id)})),this.includedOnlyMeshes.length>0&&(t.includedOnlyMeshesIds=[],this.includedOnlyMeshes.forEach(function(e){t.includedOnlyMeshesIds.push(e.id)})),e.Animation.AppendSerializedAnimations(this,t),t.ranges=this.serializeAnimationRanges(),t},i.GetConstructorFromName=function(t,i,r){switch(t){case 0:return function(){return new e.PointLight(i,e.Vector3.Zero(),r)};case 1:return function(){return new e.DirectionalLight(i,e.Vector3.Zero(),r)};case 2:return function(){return new e.SpotLight(i,e.Vector3.Zero(),e.Vector3.Zero(),0,0,r)};case 3:return function(){return new e.HemisphericLight(i,e.Vector3.Zero(),r)}}},i.Parse=function(t,r){var n=e.SerializationHelper.Parse(i.GetConstructorFromName(t.type,t.name,r),t,r);if(t.excludedMeshesIds&&(n._excludedMeshesIds=t.excludedMeshesIds),t.includedOnlyMeshesIds&&(n._includedOnlyMeshesIds=t.includedOnlyMeshesIds),t.parentId&&(n._waitingParentId=t.parentId),t.animations){for(var o=0;o<t.animations.length;o++){var s=t.animations[o];n.animations.push(e.Animation.Parse(s))}e.Node.ParseAnimationRanges(n,t,r)}return t.autoAnimate&&r.beginAnimation(n,t.autoAnimateFrom,t.autoAnimateTo,t.autoAnimateLoop,t.autoAnimateSpeed||1),n},__decorate([e.serializeAsColor3()],i.prototype,"diffuse",void 0),__decorate([e.serializeAsColor3()],i.prototype,"specular",void 0),__decorate([e.serialize()],i.prototype,"intensity",void 0),__decorate([e.serialize()],i.prototype,"range",void 0),__decorate([e.serialize()],i.prototype,"includeOnlyWithLayerMask",void 0),__decorate([e.serialize()],i.prototype,"excludeWithLayerMask",void 0),__decorate([e.serialize()],i.prototype,"radius",void 0),i}(e.Node);e.Light=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(t){function i(e,i,r){t.call(this,e,r),this.position=i}return __extends(i,t),i.prototype.getAbsolutePosition=function(){return this.transformedPosition?this.transformedPosition:this.position},i.prototype.computeTransformedPosition=function(){return this.parent&&this.parent.getWorldMatrix?(this.transformedPosition||(this.transformedPosition=e.Vector3.Zero()),e.Vector3.TransformCoordinatesToRef(this.position,this.parent.getWorldMatrix(),this.transformedPosition),!0):!1},i.prototype.transferToEffect=function(e,t){return this.parent&&this.parent.getWorldMatrix?(this.computeTransformedPosition(),void e.setFloat4(t,this.transformedPosition.x,this.transformedPosition.y,this.transformedPosition.z,0)):void e.setFloat4(t,this.position.x,this.position.y,this.position.z,0)},i.prototype.needCube=function(){return!0},i.prototype.supportsVSM=function(){return!1},i.prototype.needRefreshPerFrame=function(){return!1},i.prototype.getShadowDirection=function(t){switch(t){case 0:return new e.Vector3(1,0,0);case 1:return new e.Vector3(-1,0,0);case 2:return new e.Vector3(0,-1,0);case 3:return new e.Vector3(0,1,0);case 4:return new e.Vector3(0,0,1);case 5:return new e.Vector3(0,0,-1)}return e.Vector3.Zero()},i.prototype.setShadowProjectionMatrix=function(t,i,r){var n=this.getScene().activeCamera;e.Matrix.PerspectiveFovLHToRef(Math.PI/2,1,n.minZ,n.maxZ,t)},i.prototype._getWorldMatrix=function(){return this._worldMatrix||(this._worldMatrix=e.Matrix.Identity()),e.Matrix.TranslationToRef(this.position.x,this.position.y,this.position.z,this._worldMatrix),this._worldMatrix},i.prototype.getTypeID=function(){return 0},__decorate([e.serializeAsVector3()],i.prototype,"position",void 0),i}(e.Light);e.PointLight=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(t){function i(e,i,r,n,o,s){t.call(this,e,s),this.position=i,this.direction=r,this.angle=n,this.exponent=o}return __extends(i,t),i.prototype.getAbsolutePosition=function(){return this.transformedPosition?this.transformedPosition:this.position},i.prototype.setShadowProjectionMatrix=function(t,i,r){var n=this.getScene().activeCamera;e.Matrix.PerspectiveFovLHToRef(this.angle,1,n.minZ,n.maxZ,t)},i.prototype.needCube=function(){return!1},i.prototype.supportsVSM=function(){return!0},i.prototype.needRefreshPerFrame=function(){return!1},i.prototype.getShadowDirection=function(e){return this.direction},i.prototype.setDirectionToTarget=function(t){return this.direction=e.Vector3.Normalize(t.subtract(this.position)),this.direction},i.prototype.computeTransformedPosition=function(){return this.parent&&this.parent.getWorldMatrix?(this.transformedPosition||(this.transformedPosition=e.Vector3.Zero()),e.Vector3.TransformCoordinatesToRef(this.position,this.parent.getWorldMatrix(),this.transformedPosition),!0):!1},i.prototype.transferToEffect=function(t,i,r){var n;this.parent&&this.parent.getWorldMatrix?(this._transformedDirection||(this._transformedDirection=e.Vector3.Zero()),this.computeTransformedPosition(),e.Vector3.TransformNormalToRef(this.direction,this.parent.getWorldMatrix(),this._transformedDirection),t.setFloat4(i,this.transformedPosition.x,this.transformedPosition.y,this.transformedPosition.z,this.exponent),n=e.Vector3.Normalize(this._transformedDirection)):(t.setFloat4(i,this.position.x,this.position.y,this.position.z,this.exponent),n=e.Vector3.Normalize(this.direction)),t.setFloat4(r,n.x,n.y,n.z,Math.cos(.5*this.angle))},i.prototype._getWorldMatrix=function(){return this._worldMatrix||(this._worldMatrix=e.Matrix.Identity()),e.Matrix.TranslationToRef(this.position.x,this.position.y,this.position.z,this._worldMatrix),this._worldMatrix},i.prototype.getTypeID=function(){return 2},__decorate([e.serializeAsVector3()],i.prototype,"position",void 0),__decorate([e.serializeAsVector3()],i.prototype,"direction",void 0),__decorate([e.serialize()],i.prototype,"angle",void 0),__decorate([e.serialize()],i.prototype,"exponent",void 0),i}(e.Light);e.SpotLight=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(t){function i(i,r,n){t.call(this,i,n),this.groundColor=new e.Color3(0,0,0),this.direction=r}return __extends(i,t),i.prototype.setDirectionToTarget=function(t){return this.direction=e.Vector3.Normalize(t.subtract(e.Vector3.Zero())),this.direction;
  7. },i.prototype.getShadowGenerator=function(){return null},i.prototype.transferToEffect=function(t,i,r){var n=e.Vector3.Normalize(this.direction);t.setFloat4(i,n.x,n.y,n.z,0),t.setColor3(r,this.groundColor.scale(this.intensity))},i.prototype._getWorldMatrix=function(){return this._worldMatrix||(this._worldMatrix=e.Matrix.Identity()),this._worldMatrix},i.prototype.getTypeID=function(){return 3},__decorate([e.serializeAsColor3()],i.prototype,"groundColor",void 0),__decorate([e.serializeAsVector3()],i.prototype,"direction",void 0),i}(e.Light);e.HemisphericLight=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(t){function i(e,i,r){t.call(this,e,r),this.shadowOrthoScale=.5,this.autoUpdateExtends=!0,this._orthoLeft=Number.MAX_VALUE,this._orthoRight=Number.MIN_VALUE,this._orthoTop=Number.MIN_VALUE,this._orthoBottom=Number.MAX_VALUE,this.position=i.scale(-1),this.direction=i}return __extends(i,t),i.prototype.getAbsolutePosition=function(){return this.transformedPosition?this.transformedPosition:this.position},i.prototype.setDirectionToTarget=function(t){return this.direction=e.Vector3.Normalize(t.subtract(this.position)),this.direction},i.prototype.setShadowProjectionMatrix=function(t,i,r){var n=this.getScene().activeCamera;if(this.autoUpdateExtends||this._orthoLeft===Number.MAX_VALUE){var o=e.Vector3.Zero();this._orthoLeft=Number.MAX_VALUE,this._orthoRight=Number.MIN_VALUE,this._orthoTop=Number.MIN_VALUE,this._orthoBottom=Number.MAX_VALUE;for(var s=0;s<r.length;s++){var a=r[s];if(a){var h=a.getBoundingInfo();if(h)for(var c=h.boundingBox,l=0;l<c.vectorsWorld.length;l++)e.Vector3.TransformCoordinatesToRef(c.vectorsWorld[l],i,o),o.x<this._orthoLeft&&(this._orthoLeft=o.x),o.y<this._orthoBottom&&(this._orthoBottom=o.y),o.x>this._orthoRight&&(this._orthoRight=o.x),o.y>this._orthoTop&&(this._orthoTop=o.y)}}}var u=this._orthoRight-this._orthoLeft,f=this._orthoTop-this._orthoBottom;e.Matrix.OrthoOffCenterLHToRef(this._orthoLeft-u*this.shadowOrthoScale,this._orthoRight+u*this.shadowOrthoScale,this._orthoBottom-f*this.shadowOrthoScale,this._orthoTop+f*this.shadowOrthoScale,-n.maxZ,n.maxZ,t)},i.prototype.supportsVSM=function(){return!0},i.prototype.needRefreshPerFrame=function(){return!0},i.prototype.needCube=function(){return!1},i.prototype.getShadowDirection=function(e){return this.direction},i.prototype.computeTransformedPosition=function(){return this.parent&&this.parent.getWorldMatrix?(this.transformedPosition||(this.transformedPosition=e.Vector3.Zero()),e.Vector3.TransformCoordinatesToRef(this.position,this.parent.getWorldMatrix(),this.transformedPosition),!0):!1},i.prototype.transferToEffect=function(t,i){return this.parent&&this.parent.getWorldMatrix?(this._transformedDirection||(this._transformedDirection=e.Vector3.Zero()),e.Vector3.TransformNormalToRef(this.direction,this.parent.getWorldMatrix(),this._transformedDirection),void t.setFloat4(i,this._transformedDirection.x,this._transformedDirection.y,this._transformedDirection.z,1)):void t.setFloat4(i,this.direction.x,this.direction.y,this.direction.z,1)},i.prototype._getWorldMatrix=function(){return this._worldMatrix||(this._worldMatrix=e.Matrix.Identity()),e.Matrix.TranslationToRef(this.position.x,this.position.y,this.position.z,this._worldMatrix),this._worldMatrix},i.prototype.getTypeID=function(){return 1},__decorate([e.serializeAsVector3()],i.prototype,"position",void 0),__decorate([e.serializeAsVector3()],i.prototype,"direction",void 0),__decorate([e.serialize()],i.prototype,"shadowOrthoScale",void 0),__decorate([e.serialize()],i.prototype,"autoUpdateExtends",void 0),i}(e.Light);e.DirectionalLight=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(i,r){var n=this;this._filter=t.FILTER_NONE,this.blurScale=2,this._blurBoxOffset=0,this._bias=5e-5,this._lightDirection=e.Vector3.Zero(),this.forceBackFacesOnly=!1,this._darkness=0,this._transparencyShadow=!1,this._viewMatrix=e.Matrix.Zero(),this._projectionMatrix=e.Matrix.Zero(),this._transformMatrix=e.Matrix.Zero(),this._worldViewProjection=e.Matrix.Zero(),this._currentFaceIndex=0,this._currentFaceIndexCache=0,this._light=r,this._scene=r.getScene(),this._mapSize=i,r._shadowGenerator=this,this._shadowMap=new e.RenderTargetTexture(r.name+"_shadowMap",i,this._scene,!1,!0,e.Engine.TEXTURETYPE_UNSIGNED_INT,r.needCube()),this._shadowMap.wrapU=e.Texture.CLAMP_ADDRESSMODE,this._shadowMap.wrapV=e.Texture.CLAMP_ADDRESSMODE,this._shadowMap.anisotropicFilteringLevel=1,this._shadowMap.updateSamplingMode(e.Texture.NEAREST_SAMPLINGMODE),this._shadowMap.renderParticles=!1,this._shadowMap.onBeforeRenderObservable.add(function(e){n._currentFaceIndex=e}),this._shadowMap.onAfterUnbindObservable.add(function(){n.useBlurVarianceShadowMap&&(n._shadowMap2||(n._shadowMap2=new e.RenderTargetTexture(r.name+"_shadowMap",i,n._scene,!1),n._shadowMap2.wrapU=e.Texture.CLAMP_ADDRESSMODE,n._shadowMap2.wrapV=e.Texture.CLAMP_ADDRESSMODE,n._shadowMap2.updateSamplingMode(e.Texture.TRILINEAR_SAMPLINGMODE),n._downSamplePostprocess=new e.PassPostProcess("downScale",1/n.blurScale,null,e.Texture.BILINEAR_SAMPLINGMODE,n._scene.getEngine()),n._downSamplePostprocess.onApplyObservable.add(function(e){e.setTexture("textureSampler",n._shadowMap)}),n.blurBoxOffset=1),n._scene.postProcessManager.directRender([n._downSamplePostprocess,n._boxBlurPostprocess],n._shadowMap2.getInternalTexture()))});var o=function(t){var i=t.getRenderingMesh(),r=n._scene,o=r.getEngine();o.setState(t.getMaterial().backFaceCulling);var s=i._getInstancesRenderList(t._id);if(!s.mustReturn){var a=null!==o.getCaps().instancedArrays&&null!==s.visibleInstances[t._id]&&void 0!==s.visibleInstances[t._id];if(n.isReady(t,a)){o.enableEffect(n._effect),i._bind(t,n._effect,e.Material.TriangleFillMode);var h=t.getMaterial();if(n._effect.setMatrix("viewProjection",n.getTransformMatrix()),n._effect.setVector3("lightPosition",n.getLight().position),n.getLight().needCube()&&n._effect.setFloat2("depthValues",r.activeCamera.minZ,r.activeCamera.maxZ),h&&h.needAlphaTesting()){var c=h.getAlphaTestTexture();n._effect.setTexture("diffuseSampler",c),n._effect.setMatrix("diffuseMatrix",c.getTextureMatrix())}i.useBones&&i.computeBonesUsingShaders&&n._effect.setMatrices("mBones",i.skeleton.getTransformMatrices(i)),n.forceBackFacesOnly&&o.setState(!0,0,!1,!0),i._processRendering(t,n._effect,e.Material.TriangleFillMode,s,a,function(e,t){return n._effect.setMatrix("world",t)}),n.forceBackFacesOnly&&o.setState(!0,0,!1,!1)}else n._shadowMap.resetRefreshCounter()}};this._shadowMap.customRenderFunction=function(e,t,i){var r;for(r=0;r<e.length;r++)o(e.data[r]);for(r=0;r<t.length;r++)o(t.data[r]);if(n._transparencyShadow)for(r=0;r<i.length;r++)o(i.data[r])},this._shadowMap.onClearObservable.add(function(t){n.useBlurVarianceShadowMap||n.useVarianceShadowMap?t.clear(new e.Color4(0,0,0,0),!0,!0):t.clear(new e.Color4(1,1,1,1),!0,!0)})}return Object.defineProperty(t,"FILTER_NONE",{get:function(){return t._FILTER_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(t,"FILTER_VARIANCESHADOWMAP",{get:function(){return t._FILTER_VARIANCESHADOWMAP},enumerable:!0,configurable:!0}),Object.defineProperty(t,"FILTER_POISSONSAMPLING",{get:function(){return t._FILTER_POISSONSAMPLING},enumerable:!0,configurable:!0}),Object.defineProperty(t,"FILTER_BLURVARIANCESHADOWMAP",{get:function(){return t._FILTER_BLURVARIANCESHADOWMAP},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"bias",{get:function(){return this._bias},set:function(e){this._bias=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"blurBoxOffset",{get:function(){return this._blurBoxOffset},set:function(t){var i=this;this._blurBoxOffset!==t&&(this._blurBoxOffset=t,this._boxBlurPostprocess&&this._boxBlurPostprocess.dispose(),this._boxBlurPostprocess=new e.PostProcess("DepthBoxBlur","depthBoxBlur",["screenSize","boxOffset"],[],1/this.blurScale,null,e.Texture.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,"#define OFFSET "+t),this._boxBlurPostprocess.onApplyObservable.add(function(e){e.setFloat2("screenSize",i._mapSize/i.blurScale,i._mapSize/i.blurScale)}))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"filter",{get:function(){return this._filter},set:function(t){this._filter!==t&&(this._filter=t,this.useVarianceShadowMap||this.useBlurVarianceShadowMap||this.usePoissonSampling?(this._shadowMap.anisotropicFilteringLevel=16,this._shadowMap.updateSamplingMode(e.Texture.BILINEAR_SAMPLINGMODE)):(this._shadowMap.anisotropicFilteringLevel=1,this._shadowMap.updateSamplingMode(e.Texture.NEAREST_SAMPLINGMODE)))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useVarianceShadowMap",{get:function(){return this.filter===t.FILTER_VARIANCESHADOWMAP&&this._light.supportsVSM()},set:function(e){this.filter=e?t.FILTER_VARIANCESHADOWMAP:t.FILTER_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"usePoissonSampling",{get:function(){return this.filter===t.FILTER_POISSONSAMPLING||!this._light.supportsVSM()&&(this.filter===t.FILTER_VARIANCESHADOWMAP||this.filter===t.FILTER_BLURVARIANCESHADOWMAP)},set:function(e){this.filter=e?t.FILTER_POISSONSAMPLING:t.FILTER_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useBlurVarianceShadowMap",{get:function(){return this.filter===t.FILTER_BLURVARIANCESHADOWMAP&&this._light.supportsVSM()},set:function(e){this.filter=e?t.FILTER_BLURVARIANCESHADOWMAP:t.FILTER_NONE},enumerable:!0,configurable:!0}),t.prototype.isReady=function(t,i){var r=[];(this.useVarianceShadowMap||this.useBlurVarianceShadowMap)&&r.push("#define VSM"),this.getLight().needCube()&&r.push("#define CUBEMAP");var n=[e.VertexBuffer.PositionKind],o=t.getMesh(),s=t.getMaterial();s&&s.needAlphaTesting()&&(r.push("#define ALPHATEST"),o.isVerticesDataPresent(e.VertexBuffer.UVKind)&&(n.push(e.VertexBuffer.UVKind),r.push("#define UV1")),o.isVerticesDataPresent(e.VertexBuffer.UV2Kind)&&(n.push(e.VertexBuffer.UV2Kind),r.push("#define UV2"))),o.useBones&&o.computeBonesUsingShaders?(n.push(e.VertexBuffer.MatricesIndicesKind),n.push(e.VertexBuffer.MatricesWeightsKind),o.numBoneInfluencers>4&&(n.push(e.VertexBuffer.MatricesIndicesExtraKind),n.push(e.VertexBuffer.MatricesWeightsExtraKind)),r.push("#define NUM_BONE_INFLUENCERS "+o.numBoneInfluencers),r.push("#define BonesPerMesh "+(o.skeleton.bones.length+1))):r.push("#define NUM_BONE_INFLUENCERS 0"),i&&(r.push("#define INSTANCES"),n.push("world0"),n.push("world1"),n.push("world2"),n.push("world3"));var a=r.join("\n");return this._cachedDefines!==a&&(this._cachedDefines=a,this._effect=this._scene.getEngine().createEffect("shadowMap",n,["world","mBones","viewProjection","diffuseMatrix","lightPosition","depthValues"],["diffuseSampler"],a)),this._effect.isReady()},t.prototype.getShadowMap=function(){return this._shadowMap},t.prototype.getShadowMapForRendering=function(){return this._shadowMap2?this._shadowMap2:this._shadowMap},t.prototype.getLight=function(){return this._light},t.prototype.getTransformMatrix=function(){var t=this._scene;if(this._currentRenderID===t.getRenderId()&&this._currentFaceIndexCache===this._currentFaceIndex)return this._transformMatrix;this._currentRenderID=t.getRenderId(),this._currentFaceIndexCache=this._currentFaceIndex;var i=this._light.position;return e.Vector3.NormalizeToRef(this._light.getShadowDirection(this._currentFaceIndex),this._lightDirection),1===Math.abs(e.Vector3.Dot(this._lightDirection,e.Vector3.Up()))&&(this._lightDirection.z=1e-13),this._light.computeTransformedPosition()&&(i=this._light.transformedPosition),!this._light.needRefreshPerFrame()&&this._cachedPosition&&this._cachedDirection&&i.equals(this._cachedPosition)&&this._lightDirection.equals(this._cachedDirection)||(this._cachedPosition=i.clone(),this._cachedDirection=this._lightDirection.clone(),e.Matrix.LookAtLHToRef(i,i.add(this._lightDirection),e.Vector3.Up(),this._viewMatrix),this._light.setShadowProjectionMatrix(this._projectionMatrix,this._viewMatrix,this.getShadowMap().renderList),this._viewMatrix.multiplyToRef(this._projectionMatrix,this._transformMatrix)),this._transformMatrix},t.prototype.getDarkness=function(){return this._darkness},t.prototype.setDarkness=function(e){e>=1?this._darkness=1:0>=e?this._darkness=0:this._darkness=e},t.prototype.setTransparencyShadow=function(e){this._transparencyShadow=e},t.prototype._packHalf=function(t){var i=255*t,r=i-Math.floor(i);return new e.Vector2(t-r/255,r)},t.prototype.dispose=function(){this._shadowMap.dispose(),this._shadowMap2&&this._shadowMap2.dispose(),this._downSamplePostprocess&&this._downSamplePostprocess.dispose(),this._boxBlurPostprocess&&this._boxBlurPostprocess.dispose()},t.prototype.serialize=function(){var e={};e.lightId=this._light.id,e.mapSize=this.getShadowMap().getRenderSize(),e.useVarianceShadowMap=this.useVarianceShadowMap,e.usePoissonSampling=this.usePoissonSampling,e.forceBackFacesOnly=this.forceBackFacesOnly,e.renderList=[];for(var t=0;t<this.getShadowMap().renderList.length;t++){var i=this.getShadowMap().renderList[t];e.renderList.push(i.id)}return e},t.Parse=function(e,i){for(var r=i.getLightByID(e.lightId),n=new t(e.mapSize,r),o=0;o<e.renderList.length;o++){var s=i.getMeshesByID(e.renderList[o]);s.forEach(function(e){n.getShadowMap().renderList.push(e)})}return e.usePoissonSampling?n.usePoissonSampling=!0:e.useVarianceShadowMap?n.useVarianceShadowMap=!0:e.useBlurVarianceShadowMap&&(n.useBlurVarianceShadowMap=!0,e.blurScale&&(n.blurScale=e.blurScale),e.blurBoxOffset&&(n.blurBoxOffset=e.blurBoxOffset)),void 0!==e.bias&&(n.bias=e.bias),n.forceBackFacesOnly=e.forceBackFacesOnly,n},t._FILTER_NONE=0,t._FILTER_VARIANCESHADOWMAP=1,t._FILTER_POISSONSAMPLING=2,t._FILTER_BLURVARIANCESHADOWMAP=3,t}();e.ShadowGenerator=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(e,t,i,r){return e.x>i.x+r?!1:i.x-r>t.x?!1:e.y>i.y+r?!1:i.y-r>t.y?!1:e.z>i.z+r?!1:!(i.z-r>t.z)},i=function(e,t,i,r){var n=t*t-4*e*i,o={root:0,found:!1};if(0>n)return o;var s=Math.sqrt(n),a=(-t-s)/(2*e),h=(-t+s)/(2*e);if(a>h){var c=h;h=a,a=c}return a>0&&r>a?(o.root=a,o.found=!0,o):h>0&&r>h?(o.root=h,o.found=!0,o):o},r=function(){function r(){this.radius=new e.Vector3(1,1,1),this.retry=0,this.basePointWorld=e.Vector3.Zero(),this.velocityWorld=e.Vector3.Zero(),this.normalizedVelocity=e.Vector3.Zero(),this._collisionPoint=e.Vector3.Zero(),this._planeIntersectionPoint=e.Vector3.Zero(),this._tempVector=e.Vector3.Zero(),this._tempVector2=e.Vector3.Zero(),this._tempVector3=e.Vector3.Zero(),this._tempVector4=e.Vector3.Zero(),this._edge=e.Vector3.Zero(),this._baseToVertex=e.Vector3.Zero(),this._destinationPoint=e.Vector3.Zero(),this._slidePlaneNormal=e.Vector3.Zero(),this._displacementVector=e.Vector3.Zero()}return r.prototype._initialize=function(t,i,r){this.velocity=i,e.Vector3.NormalizeToRef(i,this.normalizedVelocity),this.basePoint=t,t.multiplyToRef(this.radius,this.basePointWorld),i.multiplyToRef(this.radius,this.velocityWorld),this.velocityWorldLength=this.velocityWorld.length(),this.epsilon=r,this.collisionFound=!1},r.prototype._checkPointInTriangle=function(t,i,r,n,o){i.subtractToRef(t,this._tempVector),r.subtractToRef(t,this._tempVector2),e.Vector3.CrossToRef(this._tempVector,this._tempVector2,this._tempVector4);var s=e.Vector3.Dot(this._tempVector4,o);return 0>s?!1:(n.subtractToRef(t,this._tempVector3),e.Vector3.CrossToRef(this._tempVector2,this._tempVector3,this._tempVector4),s=e.Vector3.Dot(this._tempVector4,o),0>s?!1:(e.Vector3.CrossToRef(this._tempVector3,this._tempVector,this._tempVector4),s=e.Vector3.Dot(this._tempVector4,o),s>=0))},r.prototype._canDoCollision=function(i,r,n,o){var s=e.Vector3.Distance(this.basePointWorld,i),a=Math.max(this.radius.x,this.radius.y,this.radius.z);return s>this.velocityWorldLength+a+r?!1:!!t(n,o,this.basePointWorld,this.velocityWorldLength+a)},r.prototype._testTriangle=function(t,r,n,o,s,a){var h,c=!1;r||(r=[]),r[t]||(r[t]=new e.Plane(0,0,0,0),r[t].copyFromPoints(n,o,s));var l=r[t];if(a||l.isFrontFacingTo(this.normalizedVelocity,0)){var u=l.signedDistanceTo(this.basePoint),f=e.Vector3.Dot(l.normal,this.velocity);if(0==f){if(Math.abs(u)>=1)return;c=!0,h=0}else{h=(-1-u)/f;var d=(1-u)/f;if(h>d){var p=d;d=h,h=p}if(h>1||0>d)return;0>h&&(h=0),h>1&&(h=1)}this._collisionPoint.copyFromFloats(0,0,0);var _=!1,m=1;if(c||(this.basePoint.subtractToRef(l.normal,this._planeIntersectionPoint),this.velocity.scaleToRef(h,this._tempVector),this._planeIntersectionPoint.addInPlace(this._tempVector),this._checkPointInTriangle(this._planeIntersectionPoint,n,o,s,l.normal)&&(_=!0,m=h,this._collisionPoint.copyFrom(this._planeIntersectionPoint))),!_){var g=this.velocity.lengthSquared(),v=g;this.basePoint.subtractToRef(n,this._tempVector);var y=2*e.Vector3.Dot(this.velocity,this._tempVector),x=this._tempVector.lengthSquared()-1,b=i(v,y,x,m);b.found&&(m=b.root,_=!0,this._collisionPoint.copyFrom(n)),this.basePoint.subtractToRef(o,this._tempVector),y=2*e.Vector3.Dot(this.velocity,this._tempVector),x=this._tempVector.lengthSquared()-1,b=i(v,y,x,m),b.found&&(m=b.root,_=!0,this._collisionPoint.copyFrom(o)),this.basePoint.subtractToRef(s,this._tempVector),y=2*e.Vector3.Dot(this.velocity,this._tempVector),x=this._tempVector.lengthSquared()-1,b=i(v,y,x,m),b.found&&(m=b.root,_=!0,this._collisionPoint.copyFrom(s)),o.subtractToRef(n,this._edge),n.subtractToRef(this.basePoint,this._baseToVertex);var P=this._edge.lengthSquared(),A=e.Vector3.Dot(this._edge,this.velocity),T=e.Vector3.Dot(this._edge,this._baseToVertex);if(v=P*-g+A*A,y=P*(2*e.Vector3.Dot(this.velocity,this._baseToVertex))-2*A*T,x=P*(1-this._baseToVertex.lengthSquared())+T*T,b=i(v,y,x,m),b.found){var E=(A*b.root-T)/P;E>=0&&1>=E&&(m=b.root,_=!0,this._edge.scaleInPlace(E),n.addToRef(this._edge,this._collisionPoint))}s.subtractToRef(o,this._edge),o.subtractToRef(this.basePoint,this._baseToVertex),P=this._edge.lengthSquared(),A=e.Vector3.Dot(this._edge,this.velocity),T=e.Vector3.Dot(this._edge,this._baseToVertex),v=P*-g+A*A,y=P*(2*e.Vector3.Dot(this.velocity,this._baseToVertex))-2*A*T,x=P*(1-this._baseToVertex.lengthSquared())+T*T,b=i(v,y,x,m),b.found&&(E=(A*b.root-T)/P,E>=0&&1>=E&&(m=b.root,_=!0,this._edge.scaleInPlace(E),o.addToRef(this._edge,this._collisionPoint))),n.subtractToRef(s,this._edge),s.subtractToRef(this.basePoint,this._baseToVertex),P=this._edge.lengthSquared(),A=e.Vector3.Dot(this._edge,this.velocity),T=e.Vector3.Dot(this._edge,this._baseToVertex),v=P*-g+A*A,y=P*(2*e.Vector3.Dot(this.velocity,this._baseToVertex))-2*A*T,x=P*(1-this._baseToVertex.lengthSquared())+T*T,b=i(v,y,x,m),b.found&&(E=(A*b.root-T)/P,E>=0&&1>=E&&(m=b.root,_=!0,this._edge.scaleInPlace(E),s.addToRef(this._edge,this._collisionPoint)))}if(_){var C=m*this.velocity.length();(!this.collisionFound||C<this.nearestDistance)&&(this.intersectionPoint?this.intersectionPoint.copyFrom(this._collisionPoint):this.intersectionPoint=this._collisionPoint.clone(),this.nearestDistance=C,this.collisionFound=!0)}}},r.prototype._collide=function(e,t,i,r,n,o,s){for(var a=r;n>a;a+=3){var h=t[i[a]-o],c=t[i[a+1]-o],l=t[i[a+2]-o];this._testTriangle(a,e,l,c,h,s)}},r.prototype._getResponse=function(t,i){t.addToRef(i,this._destinationPoint),i.scaleInPlace(this.nearestDistance/i.length()),this.basePoint.addToRef(i,t),t.subtractToRef(this.intersectionPoint,this._slidePlaneNormal),this._slidePlaneNormal.normalize(),this._slidePlaneNormal.scaleToRef(this.epsilon,this._displacementVector),t.addInPlace(this._displacementVector),this.intersectionPoint.addInPlace(this._displacementVector),this._slidePlaneNormal.scaleInPlace(e.Plane.SignedDistanceToPlaneFromPositionAndNormal(this.intersectionPoint,this._slidePlaneNormal,this._destinationPoint)),this._destinationPoint.subtractInPlace(this._slidePlaneNormal),this._destinationPoint.subtractToRef(this.intersectionPoint,i)},r}();e.Collider=r}(BABYLON||(BABYLON={}));var BABYLON;!function(e){e.CollisionWorker="",function(e){e[e.INIT=0]="INIT",e[e.UPDATE=1]="UPDATE",e[e.COLLIDE=2]="COLLIDE"}(e.WorkerTaskType||(e.WorkerTaskType={}));var t=e.WorkerTaskType;!function(e){e[e.SUCCESS=0]="SUCCESS",e[e.UNKNOWN_ERROR=1]="UNKNOWN_ERROR"}(e.WorkerReplyType||(e.WorkerReplyType={}));var i=e.WorkerReplyType,r=function(){function r(){var n=this;this._scaledPosition=e.Vector3.Zero(),this._scaledVelocity=e.Vector3.Zero(),this.onMeshUpdated=function(e){n._addUpdateMeshesList[e.uniqueId]=r.SerializeMesh(e)},this.onGeometryUpdated=function(e){n._addUpdateGeometriesList[e.id]=r.SerializeGeometry(e)},this._afterRender=function(){if(n._init&&!(0==n._toRemoveGeometryArray.length&&0==n._toRemoveMeshesArray.length&&0==Object.keys(n._addUpdateGeometriesList).length&&0==Object.keys(n._addUpdateMeshesList).length||n._runningUpdated>4)){++n._runningUpdated;var e={updatedMeshes:n._addUpdateMeshesList,updatedGeometries:n._addUpdateGeometriesList,removedGeometries:n._toRemoveGeometryArray,removedMeshes:n._toRemoveMeshesArray},i={payload:e,taskType:t.UPDATE},r=[];for(var o in e.updatedGeometries)e.updatedGeometries.hasOwnProperty(o)&&(r.push(i.payload.updatedGeometries[o].indices.buffer),r.push(i.payload.updatedGeometries[o].normals.buffer),r.push(i.payload.updatedGeometries[o].positions.buffer));n._worker.postMessage(i,r),n._addUpdateMeshesList={},n._addUpdateGeometriesList={},n._toRemoveGeometryArray=[],n._toRemoveMeshesArray=[]}},this._onMessageFromWorker=function(r){var o=r.data;if(o.error!=i.SUCCESS)return void e.Tools.Warn("error returned from worker!");switch(o.taskType){case t.INIT:n._init=!0,n._scene.meshes.forEach(function(e){n.onMeshAdded(e)}),n._scene.getGeometries().forEach(function(e){n.onGeometryAdded(e)});break;case t.UPDATE:n._runningUpdated--;break;case t.COLLIDE:n._runningCollisionTask=!1;var s=o.payload;if(!n._collisionsCallbackArray[s.collisionId])return;n._collisionsCallbackArray[s.collisionId](s.collisionId,e.Vector3.FromArray(s.newPosition),n._scene.getMeshByUniqueID(s.collidedMeshUniqueId)),n._collisionsCallbackArray[s.collisionId]=void 0}},this._collisionsCallbackArray=[],this._init=!1,this._runningUpdated=0,this._runningCollisionTask=!1,this._addUpdateMeshesList={},this._addUpdateGeometriesList={},this._toRemoveGeometryArray=[],this._toRemoveMeshesArray=[]}return r.prototype.getNewPosition=function(e,i,r,n,o,s,a){if(this._init&&!this._collisionsCallbackArray[a]&&!this._collisionsCallbackArray[a+1e5]){e.divideToRef(r.radius,this._scaledPosition),i.divideToRef(r.radius,this._scaledVelocity),this._collisionsCallbackArray[a]=s;var h={collider:{position:this._scaledPosition.asArray(),velocity:this._scaledVelocity.asArray(),radius:r.radius.asArray()},collisionId:a,excludedMeshUniqueId:o?o.uniqueId:null,maximumRetry:n},c={payload:h,taskType:t.COLLIDE};this._worker.postMessage(c)}},r.prototype.init=function(i){this._scene=i,this._scene.registerAfterRender(this._afterRender);var r=e.WorkerIncluded?e.Engine.CodeRepository+"Collisions/babylon.collisionWorker.js":URL.createObjectURL(new Blob([e.CollisionWorker],{type:"application/javascript"}));this._worker=new Worker(r),this._worker.onmessage=this._onMessageFromWorker;var n={payload:{},taskType:t.INIT};this._worker.postMessage(n)},r.prototype.destroy=function(){this._scene.unregisterAfterRender(this._afterRender),this._worker.terminate()},r.prototype.onMeshAdded=function(e){e.registerAfterWorldMatrixUpdate(this.onMeshUpdated),this.onMeshUpdated(e)},r.prototype.onMeshRemoved=function(e){this._toRemoveMeshesArray.push(e.uniqueId)},r.prototype.onGeometryAdded=function(e){e.onGeometryUpdated=this.onGeometryUpdated,this.onGeometryUpdated(e)},r.prototype.onGeometryDeleted=function(e){this._toRemoveGeometryArray.push(e.id)},r.SerializeMesh=function(t){var i=[];t.subMeshes&&(i=t.subMeshes.map(function(e,t){return{position:t,verticesStart:e.verticesStart,verticesCount:e.verticesCount,indexStart:e.indexStart,indexCount:e.indexCount,hasMaterial:!!e.getMaterial(),sphereCenter:e.getBoundingInfo().boundingSphere.centerWorld.asArray(),sphereRadius:e.getBoundingInfo().boundingSphere.radiusWorld,boxMinimum:e.getBoundingInfo().boundingBox.minimumWorld.asArray(),boxMaximum:e.getBoundingInfo().boundingBox.maximumWorld.asArray()}}));var r=null;return t instanceof e.Mesh?r=t.geometry?t.geometry.id:null:t instanceof e.InstancedMesh&&(r=t.sourceMesh&&t.sourceMesh.geometry?t.sourceMesh.geometry.id:null),{uniqueId:t.uniqueId,id:t.id,name:t.name,geometryId:r,sphereCenter:t.getBoundingInfo().boundingSphere.centerWorld.asArray(),sphereRadius:t.getBoundingInfo().boundingSphere.radiusWorld,boxMinimum:t.getBoundingInfo().boundingBox.minimumWorld.asArray(),boxMaximum:t.getBoundingInfo().boundingBox.maximumWorld.asArray(),worldMatrixFromCache:t.worldMatrixFromCache.asArray(),subMeshes:i,checkCollisions:t.checkCollisions}},r.SerializeGeometry=function(t){return{id:t.id,positions:new Float32Array(t.getVerticesData(e.VertexBuffer.PositionKind)||[]),normals:new Float32Array(t.getVerticesData(e.VertexBuffer.NormalKind)||[]),indices:new Int32Array(t.getIndices()||[])}},r}();e.CollisionCoordinatorWorker=r;var n=function(){function t(){this._scaledPosition=e.Vector3.Zero(),this._scaledVelocity=e.Vector3.Zero(),this._finalPosition=e.Vector3.Zero()}return t.prototype.getNewPosition=function(e,t,i,r,n,o,s){e.divideToRef(i.radius,this._scaledPosition),t.divideToRef(i.radius,this._scaledVelocity),i.collidedMesh=null,i.retry=0,i.initialVelocity=this._scaledVelocity,i.initialPosition=this._scaledPosition,this._collideWithWorld(this._scaledPosition,this._scaledVelocity,i,r,this._finalPosition,n),this._finalPosition.multiplyInPlace(i.radius),o(s,this._finalPosition,i.collidedMesh)},t.prototype.init=function(e){this._scene=e},t.prototype.destroy=function(){},t.prototype.onMeshAdded=function(e){},t.prototype.onMeshUpdated=function(e){},t.prototype.onMeshRemoved=function(e){},t.prototype.onGeometryAdded=function(e){},t.prototype.onGeometryUpdated=function(e){},t.prototype.onGeometryDeleted=function(e){},t.prototype._collideWithWorld=function(t,i,r,n,o,s){void 0===s&&(s=null);var a=10*e.Engine.CollisionsEpsilon;if(r.retry>=n)return void o.copyFrom(t);r._initialize(t,i,a);for(var h=0;h<this._scene.meshes.length;h++){var c=this._scene.meshes[h];c.isEnabled()&&c.checkCollisions&&c.subMeshes&&c!==s&&c._checkCollision(r)}return r.collisionFound?(0===i.x&&0===i.y&&0===i.z||r._getResponse(t,i),i.length()<=a?void o.copyFrom(t):(r.retry++,void this._collideWithWorld(t,i,r,n,o,s))):void t.addToRef(i,o)},t}();e.CollisionCoordinatorLegacy=n}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(t){function i(r,n,o){t.call(this,r,o),this.upVector=e.Vector3.Up(),this.orthoLeft=null,this.orthoRight=null,this.orthoBottom=null,this.orthoTop=null,this.fov=.8,this.minZ=1,this.maxZ=1e4,this.inertia=.9,this.mode=i.PERSPECTIVE_CAMERA,this.isIntermediate=!1,this.viewport=new e.Viewport(0,0,1,1),this.layerMask=268435455,this.fovMode=i.FOVMODE_VERTICAL_FIXED,this.cameraRigMode=i.RIG_MODE_NONE,this._rigCameras=new Array,this._computedViewMatrix=e.Matrix.Identity(),this._projectionMatrix=new e.Matrix,this._postProcesses=new Array,this._activeMeshes=new e.SmartArray(256),this._globalPosition=e.Vector3.Zero(),o.addCamera(this),o.activeCamera||(o.activeCamera=this),this.position=n}return __extends(i,t),Object.defineProperty(i,"PERSPECTIVE_CAMERA",{get:function(){return i._PERSPECTIVE_CAMERA},enumerable:!0,configurable:!0}),Object.defineProperty(i,"ORTHOGRAPHIC_CAMERA",{get:function(){return i._ORTHOGRAPHIC_CAMERA},enumerable:!0,configurable:!0}),Object.defineProperty(i,"FOVMODE_VERTICAL_FIXED",{get:function(){return i._FOVMODE_VERTICAL_FIXED},enumerable:!0,configurable:!0}),Object.defineProperty(i,"FOVMODE_HORIZONTAL_FIXED",{get:function(){return i._FOVMODE_HORIZONTAL_FIXED},enumerable:!0,configurable:!0}),Object.defineProperty(i,"RIG_MODE_NONE",{get:function(){return i._RIG_MODE_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(i,"RIG_MODE_STEREOSCOPIC_ANAGLYPH",{get:function(){return i._RIG_MODE_STEREOSCOPIC_ANAGLYPH},enumerable:!0,configurable:!0}),Object.defineProperty(i,"RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL",{get:function(){return i._RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL},enumerable:!0,configurable:!0}),Object.defineProperty(i,"RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED",{get:function(){return i._RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED},enumerable:!0,configurable:!0}),Object.defineProperty(i,"RIG_MODE_STEREOSCOPIC_OVERUNDER",{get:function(){return i._RIG_MODE_STEREOSCOPIC_OVERUNDER},enumerable:!0,configurable:!0}),Object.defineProperty(i,"RIG_MODE_VR",{get:function(){return i._RIG_MODE_VR},enumerable:!0,configurable:!0}),i.prototype.toString=function(e){var t="Name: "+this.name;if(t+=", type: "+this.getTypeName(),this.animations)for(var i=0;i<this.animations.length;i++)t+=", animation[0]: "+this.animations[i].toString(e);return t},Object.defineProperty(i.prototype,"globalPosition",{get:function(){return this._globalPosition},enumerable:!0,configurable:!0}),i.prototype.getActiveMeshes=function(){return this._activeMeshes},i.prototype.isActiveMesh=function(e){return-1!==this._activeMeshes.indexOf(e)},i.prototype._initCache=function(){t.prototype._initCache.call(this),this._cache.position=new e.Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.upVector=new e.Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.mode=void 0,this._cache.minZ=void 0,this._cache.maxZ=void 0,this._cache.fov=void 0,this._cache.aspectRatio=void 0,this._cache.orthoLeft=void 0,this._cache.orthoRight=void 0,this._cache.orthoBottom=void 0,this._cache.orthoTop=void 0,this._cache.renderWidth=void 0,this._cache.renderHeight=void 0},i.prototype._updateCache=function(e){e||t.prototype._updateCache.call(this);var i=this.getEngine();this._cache.position.copyFrom(this.position),this._cache.upVector.copyFrom(this.upVector),this._cache.mode=this.mode,this._cache.minZ=this.minZ,this._cache.maxZ=this.maxZ,this._cache.fov=this.fov,this._cache.aspectRatio=i.getAspectRatio(this),this._cache.orthoLeft=this.orthoLeft,this._cache.orthoRight=this.orthoRight,this._cache.orthoBottom=this.orthoBottom,this._cache.orthoTop=this.orthoTop,this._cache.renderWidth=i.getRenderWidth(),this._cache.renderHeight=i.getRenderHeight()},i.prototype._updateFromScene=function(){this.updateCache(),this._update()},i.prototype._isSynchronized=function(){return this._isSynchronizedViewMatrix()&&this._isSynchronizedProjectionMatrix()},i.prototype._isSynchronizedViewMatrix=function(){return t.prototype._isSynchronized.call(this)?this._cache.position.equals(this.position)&&this._cache.upVector.equals(this.upVector)&&this.isSynchronizedWithParent():!1},i.prototype._isSynchronizedProjectionMatrix=function(){var e=this._cache.mode===this.mode&&this._cache.minZ===this.minZ&&this._cache.maxZ===this.maxZ;if(!e)return!1;var t=this.getEngine();return e=this.mode===i.PERSPECTIVE_CAMERA?this._cache.fov===this.fov&&this._cache.aspectRatio===t.getAspectRatio(this):this._cache.orthoLeft===this.orthoLeft&&this._cache.orthoRight===this.orthoRight&&this._cache.orthoBottom===this.orthoBottom&&this._cache.orthoTop===this.orthoTop&&this._cache.renderWidth===t.getRenderWidth()&&this._cache.renderHeight===t.getRenderHeight()},i.prototype.attachControl=function(e,t){},i.prototype.detachControl=function(e){},i.prototype._update=function(){this.cameraRigMode!==i.RIG_MODE_NONE&&this._updateRigCameras(),this._checkInputs()},i.prototype._checkInputs=function(){},i.prototype._cascadePostProcessesToRigCams=function(){this._postProcesses.length>0&&this._postProcesses[0].markTextureDirty();for(var t=0,i=this._rigCameras.length;i>t;t++){var r=this._rigCameras[t],n=r._rigPostProcess;if(n){var o=n instanceof e.PassPostProcess;o&&(r.isIntermediate=0===this._postProcesses.length),r._postProcesses=this._postProcesses.slice(0).concat(n),n.markTextureDirty()}else r._postProcesses=this._postProcesses.slice(0)}},i.prototype.attachPostProcess=function(t,i){return void 0===i&&(i=null),!t.isReusable()&&this._postProcesses.indexOf(t)>-1?(e.Tools.Error("You're trying to reuse a post process not defined as reusable."),
  8. 0):(null==i||0>i?this._postProcesses.push(t):this._postProcesses.splice(i,0,t),this._cascadePostProcessesToRigCams(),this._postProcesses.indexOf(t))},i.prototype.detachPostProcess=function(e,t){void 0===t&&(t=null);var i,r,n=[];if(t)for(t=t instanceof Array?t:[t],i=t.length-1;i>=0;i--)this._postProcesses[t[i]]===e?this._postProcesses.splice(r,1):n.push(i);else{var o=this._postProcesses.indexOf(e);-1!==o&&this._postProcesses.splice(o,1)}return this._cascadePostProcessesToRigCams(),n},i.prototype.getWorldMatrix=function(){this._worldMatrix||(this._worldMatrix=e.Matrix.Identity());var t=this.getViewMatrix();return t.invertToRef(this._worldMatrix),this._worldMatrix},i.prototype._getViewMatrix=function(){return e.Matrix.Identity()},i.prototype.getViewMatrix=function(t){return this._computedViewMatrix=this._computeViewMatrix(t),!t&&this._isSynchronizedViewMatrix()?this._computedViewMatrix:(this.parent&&this.parent.getWorldMatrix?(this._worldMatrix||(this._worldMatrix=e.Matrix.Identity()),this._computedViewMatrix.invertToRef(this._worldMatrix),this._worldMatrix.multiplyToRef(this.parent.getWorldMatrix(),this._computedViewMatrix),this._globalPosition.copyFromFloats(this._computedViewMatrix.m[12],this._computedViewMatrix.m[13],this._computedViewMatrix.m[14]),this._computedViewMatrix.invert(),this._markSyncedWithParent()):this._globalPosition.copyFrom(this.position),this._currentRenderId=this.getScene().getRenderId(),this._computedViewMatrix)},i.prototype._computeViewMatrix=function(e){return!e&&this._isSynchronizedViewMatrix()?this._computedViewMatrix:(this._computedViewMatrix=this._getViewMatrix(),this._currentRenderId=this.getScene().getRenderId(),this._computedViewMatrix)},i.prototype.getProjectionMatrix=function(t){if(!t&&this._isSynchronizedProjectionMatrix())return this._projectionMatrix;var r=this.getEngine();if(this.mode===i.PERSPECTIVE_CAMERA)return this.minZ<=0&&(this.minZ=.1),e.Matrix.PerspectiveFovLHToRef(this.fov,r.getAspectRatio(this),this.minZ,this.maxZ,this._projectionMatrix,this.fovMode===i.FOVMODE_VERTICAL_FIXED),this._projectionMatrix;var n=r.getRenderWidth()/2,o=r.getRenderHeight()/2;return e.Matrix.OrthoOffCenterLHToRef(this.orthoLeft||-n,this.orthoRight||n,this.orthoBottom||-o,this.orthoTop||o,this.minZ,this.maxZ,this._projectionMatrix),this._projectionMatrix},i.prototype.dispose=function(){for(this.getScene().stopAnimation(this),this.getScene().removeCamera(this);this._rigCameras.length>0;)this._rigCameras.pop().dispose();for(var e=0;e<this._postProcesses.length;++e)this._postProcesses[e].dispose(this);t.prototype.dispose.call(this)},i.prototype.setCameraRigMode=function(t,r){for(;this._rigCameras.length>0;)this._rigCameras.pop().dispose();switch(this.cameraRigMode=t,this._cameraRigParams={},this._cameraRigParams.interaxialDistance=r.interaxialDistance||.0637,this._cameraRigParams.stereoHalfAngle=e.Tools.ToRadians(this._cameraRigParams.interaxialDistance/.0637),this.cameraRigMode!==i.RIG_MODE_NONE&&(this._rigCameras.push(this.createRigCamera(this.name+"_L",0)),this._rigCameras.push(this.createRigCamera(this.name+"_R",1))),this.cameraRigMode){case i.RIG_MODE_STEREOSCOPIC_ANAGLYPH:this._rigCameras[0]._rigPostProcess=new e.PassPostProcess(this.name+"_passthru",1,this._rigCameras[0]),this._rigCameras[1]._rigPostProcess=new e.AnaglyphPostProcess(this.name+"_anaglyph",1,this._rigCameras);break;case i.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case i.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:case i.RIG_MODE_STEREOSCOPIC_OVERUNDER:var n=this.cameraRigMode===i.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL||this.cameraRigMode===i.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED;this._rigCameras[0]._rigPostProcess=new e.PassPostProcess(this.name+"_passthru",1,this._rigCameras[0]),this._rigCameras[1]._rigPostProcess=new e.StereoscopicInterlacePostProcess(this.name+"_stereoInterlace",this._rigCameras,n);break;case i.RIG_MODE_VR:var o=r.vrCameraMetrics||e.VRCameraMetrics.GetDefault();this._rigCameras[0]._cameraRigParams.vrMetrics=o,this._rigCameras[0].viewport=new e.Viewport(0,0,.5,1),this._rigCameras[0]._cameraRigParams.vrWorkMatrix=new e.Matrix,this._rigCameras[0]._cameraRigParams.vrHMatrix=o.leftHMatrix,this._rigCameras[0]._cameraRigParams.vrPreViewMatrix=o.leftPreViewMatrix,this._rigCameras[0].getProjectionMatrix=this._rigCameras[0]._getVRProjectionMatrix,this._rigCameras[1]._cameraRigParams.vrMetrics=o,this._rigCameras[1].viewport=new e.Viewport(.5,0,.5,1),this._rigCameras[1]._cameraRigParams.vrWorkMatrix=new e.Matrix,this._rigCameras[1]._cameraRigParams.vrHMatrix=o.rightHMatrix,this._rigCameras[1]._cameraRigParams.vrPreViewMatrix=o.rightPreViewMatrix,this._rigCameras[1].getProjectionMatrix=this._rigCameras[1]._getVRProjectionMatrix,o.compensateDistortion&&(this._rigCameras[0]._rigPostProcess=new e.VRDistortionCorrectionPostProcess("VR_Distort_Compensation_Left",this._rigCameras[0],!1,o),this._rigCameras[1]._rigPostProcess=new e.VRDistortionCorrectionPostProcess("VR_Distort_Compensation_Right",this._rigCameras[1],!0,o))}this._cascadePostProcessesToRigCams(),this._update()},i.prototype._getVRProjectionMatrix=function(){return e.Matrix.PerspectiveFovLHToRef(this._cameraRigParams.vrMetrics.aspectRatioFov,this._cameraRigParams.vrMetrics.aspectRatio,this.minZ,this.maxZ,this._cameraRigParams.vrWorkMatrix),this._cameraRigParams.vrWorkMatrix.multiplyToRef(this._cameraRigParams.vrHMatrix,this._projectionMatrix),this._projectionMatrix},i.prototype.setCameraRigParameter=function(t,i){this._cameraRigParams||(this._cameraRigParams={}),this._cameraRigParams[t]=i,"interaxialDistance"===t&&(this._cameraRigParams.stereoHalfAngle=e.Tools.ToRadians(i/.0637))},i.prototype.createRigCamera=function(e,t){return null},i.prototype._updateRigCameras=function(){for(var e=0;e<this._rigCameras.length;e++)this._rigCameras[e].minZ=this.minZ,this._rigCameras[e].maxZ=this.maxZ,this._rigCameras[e].fov=this.fov;this.cameraRigMode===i.RIG_MODE_STEREOSCOPIC_ANAGLYPH&&(this._rigCameras[0].viewport=this._rigCameras[1].viewport=this.viewport)},i.prototype._setupInputs=function(){},i.prototype.serialize=function(){var t=e.SerializationHelper.Serialize(this);return t.type=this.getTypeName(),this.parent&&(t.parentId=this.parent.id),this.inputs&&this.inputs.serialize(t),e.Animation.AppendSerializedAnimations(this,t),t.ranges=this.serializeAnimationRanges(),t},i.prototype.getTypeName=function(){return"Camera"},i.prototype.clone=function(t){return e.SerializationHelper.Clone(i.GetConstructorFromName(this.getTypeName(),t,this.getScene(),this.interaxialDistance,this.isStereoscopicSideBySide),this)},i.GetConstructorFromName=function(t,i,r,n,o){switch(void 0===n&&(n=0),void 0===o&&(o=!0),t){case"ArcRotateCamera":return function(){return new e.ArcRotateCamera(i,0,0,1,e.Vector3.Zero(),r)};case"DeviceOrientationCamera":return function(){return new e.DeviceOrientationCamera(i,e.Vector3.Zero(),r)};case"FollowCamera":return function(){return new e.FollowCamera(i,e.Vector3.Zero(),r)};case"ArcFollowCamera":return function(){return new e.ArcFollowCamera(i,0,0,1,null,r)};case"GamepadCamera":return function(){return new e.GamepadCamera(i,e.Vector3.Zero(),r)};case"TouchCamera":return function(){return new e.TouchCamera(i,e.Vector3.Zero(),r)};case"VirtualJoysticksCamera":return function(){return new e.VirtualJoysticksCamera(i,e.Vector3.Zero(),r)};case"WebVRFreeCamera":return function(){return new e.WebVRFreeCamera(i,e.Vector3.Zero(),r)};case"VRDeviceOrientationFreeCamera":return function(){return new e.VRDeviceOrientationFreeCamera(i,e.Vector3.Zero(),r)};case"AnaglyphArcRotateCamera":return function(){return new e.AnaglyphArcRotateCamera(i,0,0,1,e.Vector3.Zero(),n,r)};case"AnaglyphFreeCamera":return function(){return new e.AnaglyphFreeCamera(i,e.Vector3.Zero(),n,r)};case"AnaglyphGamepadCamera":return function(){return new e.AnaglyphGamepadCamera(i,e.Vector3.Zero(),n,r)};case"AnaglyphUniversalCamera":return function(){return new e.AnaglyphUniversalCamera(i,e.Vector3.Zero(),n,r)};case"StereoscopicArcRotateCamera":return function(){return new e.StereoscopicArcRotateCamera(i,0,0,1,e.Vector3.Zero(),n,o,r)};case"StereoscopicFreeCamera":return function(){return new e.StereoscopicFreeCamera(i,e.Vector3.Zero(),n,o,r)};case"StereoscopicGamepadCamera":return function(){return new e.StereoscopicGamepadCamera(i,e.Vector3.Zero(),n,o,r)};case"StereoscopicUniversalCamera":return function(){return new e.StereoscopicUniversalCamera(i,e.Vector3.Zero(),n,o,r)};case"FreeCamera":return function(){return new e.UniversalCamera(i,e.Vector3.Zero(),r)};default:return function(){return new e.UniversalCamera(i,e.Vector3.Zero(),r)}}},i.Parse=function(t,r){var n=t.type,o=i.GetConstructorFromName(n,t.name,r,t.interaxial_distance,t.isStereoscopicSideBySide),s=e.SerializationHelper.Parse(o,t,r);if(t.parentId&&(s._waitingParentId=t.parentId),s.inputs&&(s.inputs.parse(t),s._setupInputs()),t.target&&s.setTarget&&s.setTarget(e.Vector3.FromArray(t.target)),t.cameraRigMode){var a=t.interaxial_distance?{interaxialDistance:t.interaxial_distance}:{};s.setCameraRigMode(t.cameraRigMode,a)}if(t.animations){for(var h=0;h<t.animations.length;h++){var c=t.animations[h];s.animations.push(e.Animation.Parse(c))}e.Node.ParseAnimationRanges(s,t,r)}return t.autoAnimate&&r.beginAnimation(s,t.autoAnimateFrom,t.autoAnimateTo,t.autoAnimateLoop,t.autoAnimateSpeed||1),s},i._PERSPECTIVE_CAMERA=0,i._ORTHOGRAPHIC_CAMERA=1,i._FOVMODE_VERTICAL_FIXED=0,i._FOVMODE_HORIZONTAL_FIXED=1,i._RIG_MODE_NONE=0,i._RIG_MODE_STEREOSCOPIC_ANAGLYPH=10,i._RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL=11,i._RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED=12,i._RIG_MODE_STEREOSCOPIC_OVERUNDER=13,i._RIG_MODE_VR=20,i.ForceAttachControlToAlwaysPreventDefault=!1,__decorate([e.serializeAsVector3()],i.prototype,"position",void 0),__decorate([e.serializeAsVector3()],i.prototype,"upVector",void 0),__decorate([e.serialize()],i.prototype,"orthoLeft",void 0),__decorate([e.serialize()],i.prototype,"orthoRight",void 0),__decorate([e.serialize()],i.prototype,"orthoBottom",void 0),__decorate([e.serialize()],i.prototype,"orthoTop",void 0),__decorate([e.serialize()],i.prototype,"fov",void 0),__decorate([e.serialize()],i.prototype,"minZ",void 0),__decorate([e.serialize()],i.prototype,"maxZ",void 0),__decorate([e.serialize()],i.prototype,"inertia",void 0),__decorate([e.serialize()],i.prototype,"mode",void 0),__decorate([e.serialize()],i.prototype,"layerMask",void 0),__decorate([e.serialize()],i.prototype,"fovMode",void 0),__decorate([e.serialize()],i.prototype,"cameraRigMode",void 0),__decorate([e.serialize()],i.prototype,"interaxialDistance",void 0),__decorate([e.serialize()],i.prototype,"isStereoscopicSideBySide",void 0),i}(e.Node);e.Camera=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){e.CameraInputTypes={};var t=function(){function t(e){this.attached={},this.camera=e,this.checkInputs=function(){}}return t.prototype.add=function(t){var i=t.getSimpleName();return this.attached[i]?void e.Tools.Warn("camera input of type "+i+" already exists on camera"):(this.attached[i]=t,t.camera=this.camera,t.checkInputs&&(this.checkInputs=this._addCheckInputs(t.checkInputs.bind(t))),void(this.attachedElement&&t.attachControl(this.attachedElement)))},t.prototype.remove=function(e){for(var t in this.attached){var i=this.attached[t];i===e&&(i.detachControl(this.attachedElement),delete this.attached[t],this.rebuildInputCheck())}},t.prototype.removeByType=function(e){for(var t in this.attached){var i=this.attached[t];i.getTypeName()===e&&(i.detachControl(this.attachedElement),delete this.attached[t],this.rebuildInputCheck())}},t.prototype._addCheckInputs=function(e){var t=this.checkInputs;return function(){t(),e()}},t.prototype.attachInput=function(e){e.attachControl(this.attachedElement,this.noPreventDefault)},t.prototype.attachElement=function(t,i){if(!this.attachedElement){i=e.Camera.ForceAttachControlToAlwaysPreventDefault?!1:i,this.attachedElement=t,this.noPreventDefault=i;for(var r in this.attached){this.attached[r];this.attached[r].attachControl(t,i)}}},t.prototype.detachElement=function(e){if(this.attachedElement===e){for(var t in this.attached){this.attached[t];this.attached[t].detachControl(e)}this.attachedElement=null}},t.prototype.rebuildInputCheck=function(){this.checkInputs=function(){};for(var e in this.attached){var t=this.attached[e];t.checkInputs&&(this.checkInputs=this._addCheckInputs(t.checkInputs.bind(t)))}},t.prototype.clear=function(){this.attachedElement&&this.detachElement(this.attachedElement),this.attached={},this.attachedElement=null,this.checkInputs=function(){}},t.prototype.serialize=function(t){var i={};for(var r in this.attached){var n=this.attached[r],o=e.SerializationHelper.Serialize(n);i[n.getTypeName()]=o}t.inputsmgr=i},t.prototype.parse=function(t){var i=t.inputsmgr;if(i){this.clear();for(var r in i){var n=e.CameraInputTypes[r];if(n){var o=i[r],s=e.SerializationHelper.Parse(function(){return new n},o,null);this.add(s)}}}else for(var r in this.attached){var n=e.CameraInputTypes[this.attached[r].getTypeName()];if(n){var s=e.SerializationHelper.Parse(function(){return new n},t,null);this.remove(this.attached[r]),this.add(s)}}},t}();e.CameraInputsManager=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(e){void 0===e&&(e=!0),this.touchEnabled=e,this.angularSensibility=2e3}return t.prototype.attachControl=function(t,i){var r=this;if(!this._pointerInput){var n=this.camera,o=this.camera.getEngine();this._pointerInput=function(t,s){var a=t.event;if(r.touchEnabled||"touch"!==a.pointerType)if(t.type===e.PointerEventTypes.POINTERDOWN){try{a.srcElement.setPointerCapture(a.pointerId)}catch(h){}r.previousPosition={x:a.clientX,y:a.clientY},i||a.preventDefault()}else if(t.type===e.PointerEventTypes.POINTERUP){try{a.srcElement.releasePointerCapture(a.pointerId)}catch(h){}r.previousPosition=null,i||a.preventDefault()}else if(t.type===e.PointerEventTypes.POINTERMOVE){if(!r.previousPosition&&!o.isPointerLock)return;var c,l;o.isPointerLock?(c=a.movementX||a.mozMovementX||a.webkitMovementX||a.msMovementX||0,l=a.movementY||a.mozMovementY||a.webkitMovementY||a.msMovementY||0):(c=a.clientX-r.previousPosition.x,l=a.clientY-r.previousPosition.y),n.cameraRotation.y+=c/r.angularSensibility,n.cameraRotation.x+=l/r.angularSensibility,r.previousPosition={x:a.clientX,y:a.clientY},i||a.preventDefault()}}}this._observer=this.camera.getScene().onPointerObservable.add(this._pointerInput,e.PointerEventTypes.POINTERDOWN|e.PointerEventTypes.POINTERUP|e.PointerEventTypes.POINTERMOVE)},t.prototype.detachControl=function(e){this._observer&&e&&(this.camera.getScene().onPointerObservable.remove(this._observer),this._observer=null,this.previousPosition=null)},t.prototype.getTypeName=function(){return"FreeCameraMouseInput"},t.prototype.getSimpleName=function(){return"mouse"},__decorate([e.serialize()],t.prototype,"angularSensibility",void 0),t}();e.FreeCameraMouseInput=t,e.CameraInputTypes.FreeCameraMouseInput=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(){this._keys=[],this.keysUp=[38],this.keysDown=[40],this.keysLeft=[37],this.keysRight=[39]}return t.prototype.attachControl=function(t,i){var r=this;this._onKeyDown||(this._onKeyDown=function(e){if(-1!==r.keysUp.indexOf(e.keyCode)||-1!==r.keysDown.indexOf(e.keyCode)||-1!==r.keysLeft.indexOf(e.keyCode)||-1!==r.keysRight.indexOf(e.keyCode)){var t=r._keys.indexOf(e.keyCode);-1===t&&r._keys.push(e.keyCode),i||e.preventDefault()}},this._onKeyUp=function(e){if(-1!==r.keysUp.indexOf(e.keyCode)||-1!==r.keysDown.indexOf(e.keyCode)||-1!==r.keysLeft.indexOf(e.keyCode)||-1!==r.keysRight.indexOf(e.keyCode)){var t=r._keys.indexOf(e.keyCode);t>=0&&r._keys.splice(t,1),i||e.preventDefault()}},e.Tools.RegisterTopRootEvents([{name:"keydown",handler:this._onKeyDown},{name:"keyup",handler:this._onKeyUp},{name:"blur",handler:this._onLostFocus}]))},t.prototype.detachControl=function(t){this._onKeyDown&&(e.Tools.UnregisterTopRootEvents([{name:"keydown",handler:this._onKeyDown},{name:"keyup",handler:this._onKeyUp},{name:"blur",handler:this._onLostFocus}]),this._keys=[],this._onKeyDown=null,this._onKeyUp=null)},t.prototype.checkInputs=function(){if(this._onKeyDown)for(var t=this.camera,i=0;i<this._keys.length;i++){var r=this._keys[i],n=t._computeLocalCameraSpeed();-1!==this.keysLeft.indexOf(r)?t._localDirection.copyFromFloats(-n,0,0):-1!==this.keysUp.indexOf(r)?t._localDirection.copyFromFloats(0,0,n):-1!==this.keysRight.indexOf(r)?t._localDirection.copyFromFloats(n,0,0):-1!==this.keysDown.indexOf(r)&&t._localDirection.copyFromFloats(0,0,-n),t.getViewMatrix().invertToRef(t._cameraTransformMatrix),e.Vector3.TransformNormalToRef(t._localDirection,t._cameraTransformMatrix,t._transformedDirection),t.cameraDirection.addInPlace(t._transformedDirection)}},t.prototype.getTypeName=function(){return"FreeCameraKeyboardMoveInput"},t.prototype._onLostFocus=function(e){this._keys=[]},t.prototype.getSimpleName=function(){return"keyboard"},__decorate([e.serialize()],t.prototype,"keysUp",void 0),__decorate([e.serialize()],t.prototype,"keysDown",void 0),__decorate([e.serialize()],t.prototype,"keysLeft",void 0),__decorate([e.serialize()],t.prototype,"keysRight",void 0),t}();e.FreeCameraKeyboardMoveInput=t,e.CameraInputTypes.FreeCameraKeyboardMoveInput=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(){this._offsetX=null,this._offsetY=null,this._pointerCount=0,this._pointerPressed=[],this.touchAngularSensibility=2e5,this.touchMoveSensibility=250}return t.prototype.attachControl=function(t,i){var r,n=this;void 0===this._pointerInput&&(this._onLostFocus=function(e){n._offsetX=null,n._offsetY=null},this._pointerInput=function(t,o){var s=t.event;if("mouse"!==s.pointerType)if(t.type===e.PointerEventTypes.POINTERDOWN){if(i||s.preventDefault(),n._pointerPressed.push(s.pointerId),1!==n._pointerPressed.length)return;r={x:s.clientX,y:s.clientY}}else if(t.type===e.PointerEventTypes.POINTERUP){i||s.preventDefault();var a=n._pointerPressed.indexOf(s.pointerId);if(-1===a)return;if(n._pointerPressed.splice(a,1),0!=a)return;r=null,n._offsetX=null,n._offsetY=null}else if(t.type===e.PointerEventTypes.POINTERMOVE){if(i||s.preventDefault(),!r)return;var a=n._pointerPressed.indexOf(s.pointerId);if(0!=a)return;n._offsetX=s.clientX-r.x,n._offsetY=-(s.clientY-r.y)}}),this._observer=this.camera.getScene().onPointerObservable.add(this._pointerInput,e.PointerEventTypes.POINTERDOWN|e.PointerEventTypes.POINTERUP|e.PointerEventTypes.POINTERMOVE),t.addEventListener("blur",this._onLostFocus)},t.prototype.detachControl=function(e){this._pointerInput&&e&&(this.camera.getScene().onPointerObservable.remove(this._observer),this._observer=null,e.removeEventListener("blur",this._onLostFocus),this._onLostFocus=null,this._pointerPressed=[],this._offsetX=null,this._offsetY=null,this._pointerCount=0)},t.prototype.checkInputs=function(){if(this._offsetX){var t=this.camera;if(t.cameraRotation.y+=this._offsetX/this.touchAngularSensibility,this._pointerPressed.length>1)t.cameraRotation.x+=-this._offsetY/this.touchAngularSensibility;else{var i=t._computeLocalCameraSpeed(),r=new e.Vector3(0,0,i*this._offsetY/this.touchMoveSensibility);e.Matrix.RotationYawPitchRollToRef(t.rotation.y,t.rotation.x,0,t._cameraRotationMatrix),t.cameraDirection.addInPlace(e.Vector3.TransformCoordinates(r,t._cameraRotationMatrix))}}},t.prototype.getTypeName=function(){return"FreeCameraTouchInput"},t.prototype.getSimpleName=function(){return"touch"},__decorate([e.serialize()],t.prototype,"touchAngularSensibility",void 0),__decorate([e.serialize()],t.prototype,"touchMoveSensibility",void 0),t}();e.FreeCameraTouchInput=t,e.CameraInputTypes.FreeCameraTouchInput=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(){var t=this;this._screenOrientationAngle=0,this._screenQuaternion=new e.Quaternion,this._alpha=0,this._beta=0,this._gamma=0,this._orientationChanged=function(){t._screenOrientationAngle=void 0!==window.orientation?+window.orientation:window.screen.orientation&&window.screen.orientation.angle?window.screen.orientation.angle:0,t._screenOrientationAngle=-e.Tools.ToRadians(t._screenOrientationAngle/2),t._screenQuaternion.copyFromFloats(0,Math.sin(t._screenOrientationAngle),0,Math.cos(t._screenOrientationAngle))},this._deviceOrientation=function(e){t._alpha=e.alpha,t._beta=e.beta,t._gamma=e.gamma},this._constantTranform=new e.Quaternion(-Math.sqrt(.5),0,0,Math.sqrt(.5)),this._orientationChanged()}return Object.defineProperty(t.prototype,"camera",{get:function(){return this._camera},set:function(t){this._camera=t,this._camera.rotationQuaternion||(this._camera.rotationQuaternion=new e.Quaternion)},enumerable:!0,configurable:!0}),t.prototype.attachControl=function(e,t){window.addEventListener("orientationchange",this._orientationChanged),window.addEventListener("deviceorientation",this._deviceOrientation)},t.prototype.detachControl=function(e){window.removeEventListener("orientationchange",this._orientationChanged),window.removeEventListener("deviceorientation",this._deviceOrientation)},t.prototype.checkInputs=function(){e.Quaternion.RotationYawPitchRollToRef(e.Tools.ToRadians(this._alpha),e.Tools.ToRadians(this._beta),-e.Tools.ToRadians(this._gamma),this.camera.rotationQuaternion),this._camera.rotationQuaternion.multiplyInPlace(this._screenQuaternion),this._camera.rotationQuaternion.multiplyInPlace(this._constantTranform),this._camera.rotationQuaternion.z*=-1,this._camera.rotationQuaternion.w*=-1},t.prototype.getTypeName=function(){return"FreeCameraDeviceOrientationInput"},t.prototype.getSimpleName=function(){return"deviceOrientation"},t}();e.FreeCameraDeviceOrientationInput=t,e.CameraInputTypes.FreeCameraDeviceOrientationInput=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function e(){this.alphaCorrection=1,this.betaCorrection=1,this.gammaCorrection=1,this._alpha=0,this._beta=0,this._gamma=0,this._dirty=!1,this._deviceOrientationHandler=this._onOrientationEvent.bind(this)}return e.prototype.attachControl=function(e,t){window.addEventListener("deviceorientation",this._deviceOrientationHandler)},e.prototype._onOrientationEvent=function(e){this.camera;this._alpha=e.alpha,this._beta=e.beta,this._gamma=e.gamma,this._dirty=!0},e.prototype.checkInputs=function(){if(this._dirty){this._dirty=!1;var e=this._gamma;e=0>e?90+e:270-e,this.camera.rotation.x=this.gammaCorrection*e/180*Math.PI,this.camera.rotation.y=this.alphaCorrection*-this._alpha/180*Math.PI,this.camera.rotation.z=this.betaCorrection*this._beta/180*Math.PI}},e.prototype.detachControl=function(e){window.removeEventListener("deviceorientation",this._deviceOrientationHandler)},e.prototype.getTypeName=function(){return"FreeCameraVRDeviceOrientationInput"},e.prototype.getSimpleName=function(){return"VRDeviceOrientation"},e}();e.FreeCameraVRDeviceOrientationInput=t,e.CameraInputTypes.FreeCameraVRDeviceOrientationInput=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(){this.gamepadAngularSensibility=200,this.gamepadMoveSensibility=40}return t.prototype.attachControl=function(t,i){var r=this;this._gamepads=new e.Gamepads(function(e){r._onNewGameConnected(e)})},t.prototype.detachControl=function(e){this._gamepads&&this._gamepads.dispose(),this.gamepad=null},t.prototype.checkInputs=function(){if(this.gamepad){var t=this.camera,i=this.gamepad.leftStick,r=i.x/this.gamepadMoveSensibility,n=i.y/this.gamepadMoveSensibility;i.x=Math.abs(r)>.005?0+r:0,i.y=Math.abs(n)>.005?0+n:0;var o=this.gamepad.rightStick,s=o.x/this.gamepadAngularSensibility,a=o.y/this.gamepadAngularSensibility;o.x=Math.abs(s)>.001?0+s:0,o.y=Math.abs(a)>.001?0+a:0;var h=e.Matrix.RotationYawPitchRoll(t.rotation.y,t.rotation.x,0),c=50*t._computeLocalCameraSpeed(),l=e.Vector3.TransformCoordinates(new e.Vector3(i.x*c,0,-i.y*c),h);t.cameraDirection=t.cameraDirection.add(l),t.cameraRotation=t.cameraRotation.add(new e.Vector2(o.y,o.x))}},t.prototype._onNewGameConnected=function(e){0===e.index&&(this.gamepad=e)},t.prototype.getTypeName=function(){return"FreeCameraGamepadInput"},t.prototype.getSimpleName=function(){return"gamepad"},__decorate([e.serialize()],t.prototype,"gamepadAngularSensibility",void 0),__decorate([e.serialize()],t.prototype,"gamepadMoveSensibility",void 0),t}();e.FreeCameraGamepadInput=t,e.CameraInputTypes.FreeCameraGamepadInput=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(){this._keys=[],this.keysUp=[38],this.keysDown=[40],this.keysLeft=[37],this.keysRight=[39]}return t.prototype.attachControl=function(t,i){var r=this;this._onKeyDown=function(e){if(-1!==r.keysUp.indexOf(e.keyCode)||-1!==r.keysDown.indexOf(e.keyCode)||-1!==r.keysLeft.indexOf(e.keyCode)||-1!==r.keysRight.indexOf(e.keyCode)){var t=r._keys.indexOf(e.keyCode);-1===t&&r._keys.push(e.keyCode),e.preventDefault&&(i||e.preventDefault())}},this._onKeyUp=function(e){if(-1!==r.keysUp.indexOf(e.keyCode)||-1!==r.keysDown.indexOf(e.keyCode)||-1!==r.keysLeft.indexOf(e.keyCode)||-1!==r.keysRight.indexOf(e.keyCode)){var t=r._keys.indexOf(e.keyCode);t>=0&&r._keys.splice(t,1),e.preventDefault&&(i||e.preventDefault())}},this._onLostFocus=function(){r._keys=[]},e.Tools.RegisterTopRootEvents([{name:"keydown",handler:this._onKeyDown},{name:"keyup",handler:this._onKeyUp},{name:"blur",handler:this._onLostFocus}])},t.prototype.detachControl=function(t){e.Tools.UnregisterTopRootEvents([{name:"keydown",handler:this._onKeyDown},{name:"keyup",handler:this._onKeyUp},{name:"blur",handler:this._onLostFocus}]),this._keys=[],this._onKeyDown=null,this._onKeyUp=null,this._onLostFocus=null},t.prototype.checkInputs=function(){if(this._onKeyDown)for(var e=this.camera,t=0;t<this._keys.length;t++){var i=this._keys[t];-1!==this.keysLeft.indexOf(i)?e.inertialAlphaOffset-=.01:-1!==this.keysUp.indexOf(i)?e.inertialBetaOffset-=.01:-1!==this.keysRight.indexOf(i)?e.inertialAlphaOffset+=.01:-1!==this.keysDown.indexOf(i)&&(e.inertialBetaOffset+=.01)}},t.prototype.getTypeName=function(){return"ArcRotateCameraKeyboardMoveInput"},t.prototype.getSimpleName=function(){return"keyboard"},__decorate([e.serialize()],t.prototype,"keysUp",void 0),__decorate([e.serialize()],t.prototype,"keysDown",void 0),__decorate([e.serialize()],t.prototype,"keysLeft",void 0),__decorate([e.serialize()],t.prototype,"keysRight",void 0),t}();e.ArcRotateCameraKeyboardMoveInput=t,e.CameraInputTypes.ArcRotateCameraKeyboardMoveInput=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(){this.wheelPrecision=3}return t.prototype.attachControl=function(t,i){var r=this;this._wheel=function(t,n){if(t.type===e.PointerEventTypes.POINTERWHEEL){var o=t.event,s=0;o.wheelDelta?s=o.wheelDelta/(40*r.wheelPrecision):o.detail&&(s=-o.detail/r.wheelPrecision),s&&(r.camera.inertialRadiusOffset+=s),o.preventDefault&&(i||o.preventDefault())}},this._observer=this.camera.getScene().onPointerObservable.add(this._wheel,e.PointerEventTypes.POINTERWHEEL)},t.prototype.detachControl=function(e){this._observer&&e&&(this.camera.getScene().onPointerObservable.remove(this._observer),this._observer=null,this._wheel=null)},t.prototype.getTypeName=function(){return"ArcRotateCameraMouseWheelInput"},t.prototype.getSimpleName=function(){return"mousewheel"},__decorate([e.serialize()],t.prototype,"wheelPrecision",void 0),t}();e.ArcRotateCameraMouseWheelInput=t,e.CameraInputTypes.ArcRotateCameraMouseWheelInput=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=(e.Tools.GetPointerPrefix(),function(){function t(){this.angularSensibilityX=1e3,this.angularSensibilityY=1e3,this.pinchPrecision=6,this.panningSensibility=50,this._isRightClick=!1,this._isCtrlPushed=!1,this.pinchInwards=!0}return t.prototype.attachControl=function(t,i){var r,n,o,s=this,a=this.camera.getEngine(),h=0;this._pointerInput=function(t,a){var c=t.event;if(t.type===e.PointerEventTypes.POINTERDOWN){try{c.srcElement.setPointerCapture(c.pointerId)}catch(l){}s._isRightClick=2===c.button,r={x:c.clientX,y:c.clientY,pointerId:c.pointerId,type:c.pointerType},void 0===n?n=r:void 0===o&&(o=r),i||c.preventDefault()}else if(t.type===e.PointerEventTypes.POINTERUP){try{c.srcElement.releasePointerCapture(c.pointerId)}catch(l){}r=null,h=0,n=o=void 0,i||c.preventDefault()}else if(t.type===e.PointerEventTypes.POINTERMOVE)if(i||c.preventDefault(),n&&void 0===o){if(0!==s.panningSensibility&&(s._isCtrlPushed&&s.camera._useCtrlForPanning||!s.camera._useCtrlForPanning&&s._isRightClick))s.camera.inertialPanningX+=-(c.clientX-r.x)/s.panningSensibility,s.camera.inertialPanningY+=(c.clientY-r.y)/s.panningSensibility;else{var u=c.clientX-r.x,f=c.clientY-r.y;s.camera.inertialAlphaOffset-=u/s.angularSensibilityX,s.camera.inertialBetaOffset-=f/s.angularSensibilityY}r.x=c.clientX,r.y=c.clientY}else if(n&&o){var d=n.pointerId===c.pointerId?n:o;d.x=c.clientX,d.y=c.clientY;var p=s.pinchInwards?1:-1,_=n.x-o.x,m=n.y-o.y,g=_*_+m*m;if(0===h)return void(h=g);g!==h&&(s.camera.inertialRadiusOffset+=(g-h)/(s.pinchPrecision*((s.angularSensibilityX+s.angularSensibilityY)/2)*p),h=g)}},this._observer=this.camera.getScene().onPointerObservable.add(this._pointerInput,e.PointerEventTypes.POINTERDOWN|e.PointerEventTypes.POINTERUP|e.PointerEventTypes.POINTERMOVE),this._onContextMenu=function(e){e.preventDefault()},this.camera._useCtrlForPanning||t.addEventListener("contextmenu",this._onContextMenu,!1),this._onLostFocus=function(){n=o=void 0,h=0,r=null},this._onKeyDown=function(e){s._isCtrlPushed=e.ctrlKey},this._onKeyUp=function(e){s._isCtrlPushed=e.ctrlKey},this._onMouseMove=function(e){if(a.isPointerLock){var t=e.movementX||e.mozMovementX||e.webkitMovementX||e.msMovementX||0,r=e.movementY||e.mozMovementY||e.webkitMovementY||e.msMovementY||0;s.camera.inertialAlphaOffset-=t/s.angularSensibilityX,s.camera.inertialBetaOffset-=r/s.angularSensibilityY,i||e.preventDefault()}},this._onGestureStart=function(e){void 0!==window.MSGesture&&(s._MSGestureHandler||(s._MSGestureHandler=new MSGesture,s._MSGestureHandler.target=t),s._MSGestureHandler.addPointer(e.pointerId))},this._onGesture=function(e){s.camera.radius*=e.scale,e.preventDefault&&(i||(e.stopPropagation(),e.preventDefault()))},t.addEventListener("mousemove",this._onMouseMove,!1),t.addEventListener("MSPointerDown",this._onGestureStart,!1),t.addEventListener("MSGestureChange",this._onGesture,!1),e.Tools.RegisterTopRootEvents([{name:"keydown",handler:this._onKeyDown},{name:"keyup",handler:this._onKeyUp},{name:"blur",handler:this._onLostFocus}])},t.prototype.detachControl=function(t){t&&this._observer&&(this.camera.getScene().onPointerObservable.remove(this._observer),this._observer=null,t.removeEventListener("contextmenu",this._onContextMenu),t.removeEventListener("mousemove",this._onMouseMove),t.removeEventListener("MSPointerDown",this._onGestureStart),t.removeEventListener("MSGestureChange",this._onGesture),this._isRightClick=!1,this._isCtrlPushed=!1,this.pinchInwards=!0,this._onKeyDown=null,this._onKeyUp=null,this._onMouseMove=null,this._onGestureStart=null,this._onGesture=null,this._MSGestureHandler=null,this._onLostFocus=null,this._onContextMenu=null),e.Tools.UnregisterTopRootEvents([{name:"keydown",handler:this._onKeyDown},{name:"keyup",handler:this._onKeyUp},{name:"blur",handler:this._onLostFocus}])},t.prototype.getTypeName=function(){return"ArcRotateCameraPointersInput"},t.prototype.getSimpleName=function(){return"pointers"},__decorate([e.serialize()],t.prototype,"angularSensibilityX",void 0),__decorate([e.serialize()],t.prototype,"angularSensibilityY",void 0),__decorate([e.serialize()],t.prototype,"pinchPrecision",void 0),__decorate([e.serialize()],t.prototype,"panningSensibility",void 0),t}());e.ArcRotateCameraPointersInput=t,e.CameraInputTypes.ArcRotateCameraPointersInput=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(){this.gamepadRotationSensibility=80,this.gamepadMoveSensibility=40}return t.prototype.attachControl=function(t,i){var r=this;this._gamepads=new e.Gamepads(function(e){r._onNewGameConnected(e)})},t.prototype.detachControl=function(e){this._gamepads&&this._gamepads.dispose(),
  9. this.gamepad=null},t.prototype.checkInputs=function(){if(this.gamepad){var e=this.camera,t=this.gamepad.rightStick;if(0!=t.x){var i=t.x/this.gamepadRotationSensibility;0!=i&&Math.abs(i)>.005&&(e.inertialAlphaOffset+=i)}if(0!=t.y){var r=t.y/this.gamepadRotationSensibility;0!=r&&Math.abs(r)>.005&&(e.inertialBetaOffset+=r)}var n=this.gamepad.leftStick;if(0!=n.y){var o=n.y/this.gamepadMoveSensibility;0!=o&&Math.abs(o)>.005&&(this.camera.inertialRadiusOffset-=o)}}},t.prototype._onNewGameConnected=function(e){0===e.index&&(this.gamepad=e)},t.prototype.getTypeName=function(){return"ArcRotateCameraGamepadInput"},t.prototype.getSimpleName=function(){return"gamepad"},__decorate([e.serialize()],t.prototype,"gamepadRotationSensibility",void 0),__decorate([e.serialize()],t.prototype,"gamepadMoveSensibility",void 0),t}();e.ArcRotateCameraGamepadInput=t,e.CameraInputTypes.ArcRotateCameraGamepadInput=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function e(){this.alphaCorrection=1,this.betaCorrection=1,this.gammaCorrection=1,this._alpha=0,this._beta=0,this._gamma=0,this._dirty=!1,this._deviceOrientationHandler=this._onOrientationEvent.bind(this)}return e.prototype.attachControl=function(e,t){this.camera.attachControl(e,t),window.addEventListener("deviceorientation",this._deviceOrientationHandler)},e.prototype._onOrientationEvent=function(e){this.camera;this._alpha=0|+e.alpha,this._beta=0|+e.beta,this._gamma=0|+e.gamma,this._dirty=!0},e.prototype.checkInputs=function(){this._dirty&&(this._dirty=!1,this._gamma<0&&(this._gamma=180+this._gamma),this.camera.alpha=-this._alpha/180*Math.PI%Math.PI*2,this.camera.beta=this._gamma/180*Math.PI)},e.prototype.detachControl=function(e){window.removeEventListener("deviceorientation",this._deviceOrientationHandler)},e.prototype.getTypeName=function(){return"ArcRotateCameraVRDeviceOrientationInput"},e.prototype.getSimpleName=function(){return"VRDeviceOrientation"},e}();e.ArcRotateCameraVRDeviceOrientationInput=t,e.CameraInputTypes.ArcRotateCameraVRDeviceOrientationInput=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(t){function i(i,r,n){t.call(this,i,r,n),this.cameraDirection=new e.Vector3(0,0,0),this.cameraRotation=new e.Vector2(0,0),this.rotation=new e.Vector3(0,0,0),this.speed=2,this.noRotationConstraint=!1,this.lockedTarget=null,this._currentTarget=e.Vector3.Zero(),this._viewMatrix=e.Matrix.Zero(),this._camMatrix=e.Matrix.Zero(),this._cameraTransformMatrix=e.Matrix.Zero(),this._cameraRotationMatrix=e.Matrix.Zero(),this._referencePoint=new e.Vector3(0,0,1),this._defaultUpVector=new e.Vector3(0,1,0),this._transformedReferencePoint=e.Vector3.Zero(),this._lookAtTemp=e.Matrix.Zero(),this._tempMatrix=e.Matrix.Zero()}return __extends(i,t),i.prototype.getFrontPosition=function(e){var t=this.getTarget().subtract(this.position);return t.normalize(),t.scaleInPlace(e),this.globalPosition.add(t)},i.prototype._getLockedTargetPosition=function(){return this.lockedTarget?this.lockedTarget.position||this.lockedTarget:null},i.prototype._initCache=function(){t.prototype._initCache.call(this),this._cache.lockedTarget=new e.Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.rotation=new e.Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.rotationQuaternion=new e.Quaternion(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE)},i.prototype._updateCache=function(e){e||t.prototype._updateCache.call(this);var i=this._getLockedTargetPosition();i?this._cache.lockedTarget?this._cache.lockedTarget.copyFrom(i):this._cache.lockedTarget=i.clone():this._cache.lockedTarget=null,this._cache.rotation.copyFrom(this.rotation),this.rotationQuaternion&&this._cache.rotationQuaternion.copyFrom(this.rotationQuaternion)},i.prototype._isSynchronizedViewMatrix=function(){if(!t.prototype._isSynchronizedViewMatrix.call(this))return!1;var e=this._getLockedTargetPosition();return(this._cache.lockedTarget?this._cache.lockedTarget.equals(e):!e)&&(this.rotationQuaternion?this.rotationQuaternion.equals(this._cache.rotationQuaternion):this._cache.rotation.equals(this.rotation))},i.prototype._computeLocalCameraSpeed=function(){var e=this.getEngine();return this.speed*(e.getDeltaTime()/(10*e.getFps()))},i.prototype.setTarget=function(t){this.upVector.normalize(),e.Matrix.LookAtLHToRef(this.position,t,this._defaultUpVector,this._camMatrix),this._camMatrix.invert(),this.rotation.x=Math.atan(this._camMatrix.m[6]/this._camMatrix.m[10]);var i=t.subtract(this.position);i.x>=0?this.rotation.y=-Math.atan(i.z/i.x)+Math.PI/2:this.rotation.y=-Math.atan(i.z/i.x)-Math.PI/2,this.rotation.z=0,isNaN(this.rotation.x)&&(this.rotation.x=0),isNaN(this.rotation.y)&&(this.rotation.y=0),isNaN(this.rotation.z)&&(this.rotation.z=0),this.rotationQuaternion&&e.Quaternion.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,this.rotationQuaternion)},i.prototype.getTarget=function(){return this._currentTarget},i.prototype._decideIfNeedsToMove=function(){return Math.abs(this.cameraDirection.x)>0||Math.abs(this.cameraDirection.y)>0||Math.abs(this.cameraDirection.z)>0},i.prototype._updatePosition=function(){this.position.addInPlace(this.cameraDirection)},i.prototype._checkInputs=function(){var i=this._decideIfNeedsToMove(),r=Math.abs(this.cameraRotation.x)>0||Math.abs(this.cameraRotation.y)>0;if(i&&this._updatePosition(),r&&(this.rotation.x+=this.cameraRotation.x,this.rotation.y+=this.cameraRotation.y,!this.noRotationConstraint)){var n=Math.PI/2*.95;this.rotation.x>n&&(this.rotation.x=n),this.rotation.x<-n&&(this.rotation.x=-n)}i&&(Math.abs(this.cameraDirection.x)<e.Epsilon&&(this.cameraDirection.x=0),Math.abs(this.cameraDirection.y)<e.Epsilon&&(this.cameraDirection.y=0),Math.abs(this.cameraDirection.z)<e.Epsilon&&(this.cameraDirection.z=0),this.cameraDirection.scaleInPlace(this.inertia)),r&&(Math.abs(this.cameraRotation.x)<e.Epsilon&&(this.cameraRotation.x=0),Math.abs(this.cameraRotation.y)<e.Epsilon&&(this.cameraRotation.y=0),this.cameraRotation.scaleInPlace(this.inertia)),t.prototype._checkInputs.call(this)},i.prototype._updateCameraRotationMatrix=function(){this.rotationQuaternion?(this.rotationQuaternion.toRotationMatrix(this._cameraRotationMatrix),e.Vector3.TransformNormalToRef(this._defaultUpVector,this._cameraRotationMatrix,this.upVector)):e.Matrix.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,this._cameraRotationMatrix)},i.prototype._getViewMatrix=function(){return this.lockedTarget?this._currentTarget.copyFrom(this._getLockedTargetPosition()):(this._updateCameraRotationMatrix(),e.Vector3.TransformCoordinatesToRef(this._referencePoint,this._cameraRotationMatrix,this._transformedReferencePoint),this.position.addToRef(this._transformedReferencePoint,this._currentTarget)),e.Matrix.LookAtLHToRef(this.position,this._currentTarget,this.upVector,this._viewMatrix),this._viewMatrix},i.prototype.createRigCamera=function(t,r){if(this.cameraRigMode!==e.Camera.RIG_MODE_NONE){var n=new i(t,this.position.clone(),this.getScene());return this.cameraRigMode===e.Camera.RIG_MODE_VR&&(this.rotationQuaternion||(this.rotationQuaternion=new e.Quaternion),n._cameraRigParams={},n.rotationQuaternion=new e.Quaternion),n}return null},i.prototype._updateRigCameras=function(){var i=this._rigCameras[0],r=this._rigCameras[1];switch(this.cameraRigMode){case e.Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:case e.Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER:var n=this.cameraRigMode===e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED?1:-1,o=this.cameraRigMode===e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED?-1:1;this._getRigCamPosition(this._cameraRigParams.stereoHalfAngle*n,i.position),this._getRigCamPosition(this._cameraRigParams.stereoHalfAngle*o,r.position),i.setTarget(this.getTarget()),r.setTarget(this.getTarget());break;case e.Camera.RIG_MODE_VR:i.rotationQuaternion.copyFrom(this.rotationQuaternion),r.rotationQuaternion.copyFrom(this.rotationQuaternion),i.position.copyFrom(this.position),r.position.copyFrom(this.position)}t.prototype._updateRigCameras.call(this)},i.prototype._getRigCamPosition=function(t,i){this._rigCamTransformMatrix||(this._rigCamTransformMatrix=new e.Matrix);var r=this.getTarget();e.Matrix.Translation(-r.x,-r.y,-r.z).multiplyToRef(e.Matrix.RotationY(t),this._rigCamTransformMatrix),this._rigCamTransformMatrix=this._rigCamTransformMatrix.multiply(e.Matrix.Translation(r.x,r.y,r.z)),e.Vector3.TransformCoordinatesToRef(this.position,this._rigCamTransformMatrix,i)},i.prototype.getTypeName=function(){return"TargetCamera"},__decorate([e.serializeAsVector3()],i.prototype,"rotation",void 0),__decorate([e.serialize()],i.prototype,"speed",void 0),__decorate([e.serializeAsMeshReference("lockedTargetId")],i.prototype,"lockedTarget",void 0),i}(e.Camera);e.TargetCamera=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(t){function i(i,r,n){var o=this;t.call(this,i,r,n),this.ellipsoid=new e.Vector3(.5,1,.5),this.checkCollisions=!1,this.applyGravity=!1,this._collider=new e.Collider,this._needMoveForGravity=!1,this._oldPosition=e.Vector3.Zero(),this._diffPosition=e.Vector3.Zero(),this._newPosition=e.Vector3.Zero(),this._onCollisionPositionChange=function(t,i,r){void 0===r&&(r=null),o.getScene().workerCollisions&&i.multiplyInPlace(o._collider.radius);var n=function(t){o._newPosition.copyFrom(t),o._newPosition.subtractToRef(o._oldPosition,o._diffPosition);o.position.clone();o._diffPosition.length()>e.Engine.CollisionsEpsilon&&(o.position.addInPlace(o._diffPosition),o.onCollide&&r&&o.onCollide(r))};n(i)},this.inputs=new e.FreeCameraInputsManager(this),this.inputs.addKeyboard().addMouse()}return __extends(i,t),Object.defineProperty(i.prototype,"angularSensibility",{get:function(){var e=this.inputs.attached.mouse;return e?e.angularSensibility:void 0},set:function(e){var t=this.inputs.attached.mouse;t&&(t.angularSensibility=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"keysUp",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysUp:void 0},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysUp=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"keysDown",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysDown:void 0},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysDown=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"keysLeft",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysLeft:void 0},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysLeft=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"keysRight",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysRight:void 0},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysRight=e)},enumerable:!0,configurable:!0}),i.prototype.attachControl=function(e,t){this.inputs.attachElement(e,t)},i.prototype.detachControl=function(t){this.inputs.detachElement(t),this.cameraDirection=new e.Vector3(0,0,0),this.cameraRotation=new e.Vector2(0,0)},i.prototype._collideWithWorld=function(t){var i;i=this.parent?e.Vector3.TransformCoordinates(this.position,this.parent.getWorldMatrix()):this.position,i.subtractFromFloatsToRef(0,this.ellipsoid.y,0,this._oldPosition),this._collider.radius=this.ellipsoid;var r=t;this.applyGravity&&(r=t.add(this.getScene().gravity)),this.getScene().collisionCoordinator.getNewPosition(this._oldPosition,r,this._collider,3,null,this._onCollisionPositionChange,this.uniqueId)},i.prototype._checkInputs=function(){this._localDirection||(this._localDirection=e.Vector3.Zero(),this._transformedDirection=e.Vector3.Zero()),this.inputs.checkInputs(),t.prototype._checkInputs.call(this)},i.prototype._decideIfNeedsToMove=function(){return this._needMoveForGravity||Math.abs(this.cameraDirection.x)>0||Math.abs(this.cameraDirection.y)>0||Math.abs(this.cameraDirection.z)>0},i.prototype._updatePosition=function(){this.checkCollisions&&this.getScene().collisionsEnabled?this._collideWithWorld(this.cameraDirection):this.position.addInPlace(this.cameraDirection)},i.prototype.dispose=function(){this.inputs.clear(),t.prototype.dispose.call(this)},i.prototype.getTypeName=function(){return"FreeCamera"},__decorate([e.serializeAsVector3()],i.prototype,"ellipsoid",void 0),__decorate([e.serialize()],i.prototype,"checkCollisions",void 0),__decorate([e.serialize()],i.prototype,"applyGravity",void 0),i}(e.TargetCamera);e.FreeCamera=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(t){function i(e){t.call(this,e)}return __extends(i,t),i.prototype.addKeyboard=function(){return this.add(new e.FreeCameraKeyboardMoveInput),this},i.prototype.addMouse=function(t){return void 0===t&&(t=!0),this.add(new e.FreeCameraMouseInput(t)),this},i.prototype.addGamepad=function(){return this.add(new e.FreeCameraGamepadInput),this},i.prototype.addDeviceOrientation=function(){return this.add(new e.FreeCameraDeviceOrientationInput),this},i.prototype.addVRDeviceOrientation=function(){return this.add(new e.FreeCameraVRDeviceOrientationInput),this},i.prototype.addTouch=function(){return this.add(new e.FreeCameraTouchInput),this},i.prototype.addVirtualJoystick=function(){return this.add(new e.FreeCameraVirtualJoystickInput),this},i}(e.CameraInputsManager);e.FreeCameraInputsManager=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(t){function i(e,i,r,n){t.call(this,e,i,r),this.radius=12,this.rotationOffset=0,this.heightOffset=4,this.cameraAcceleration=.05,this.maxCameraSpeed=20,this.target=n}return __extends(i,t),i.prototype.getRadians=function(e){return e*Math.PI/180},i.prototype.follow=function(t){if(t){var i;if(t.rotationQuaternion){var r=new e.Matrix;t.rotationQuaternion.toRotationMatrix(r),i=Math.atan2(r.m[8],r.m[10])}else i=t.rotation.y;var n=this.getRadians(this.rotationOffset)+i,o=t.position.x+Math.sin(n)*this.radius,s=t.position.z+Math.cos(n)*this.radius,a=o-this.position.x,h=t.position.y+this.heightOffset-this.position.y,c=s-this.position.z,l=a*this.cameraAcceleration*2,u=h*this.cameraAcceleration,f=c*this.cameraAcceleration*2;(l>this.maxCameraSpeed||l<-this.maxCameraSpeed)&&(l=1>l?-this.maxCameraSpeed:this.maxCameraSpeed),(u>this.maxCameraSpeed||u<-this.maxCameraSpeed)&&(u=1>u?-this.maxCameraSpeed:this.maxCameraSpeed),(f>this.maxCameraSpeed||f<-this.maxCameraSpeed)&&(f=1>f?-this.maxCameraSpeed:this.maxCameraSpeed),this.position=new e.Vector3(this.position.x+l,this.position.y+u,this.position.z+f),this.setTarget(t.position)}},i.prototype._checkInputs=function(){t.prototype._checkInputs.call(this),this.follow(this.target)},i.prototype.getTypeName=function(){return"FollowCamera"},__decorate([e.serialize()],i.prototype,"radius",void 0),__decorate([e.serialize()],i.prototype,"rotationOffset",void 0),__decorate([e.serialize()],i.prototype,"heightOffset",void 0),__decorate([e.serialize()],i.prototype,"cameraAcceleration",void 0),__decorate([e.serialize()],i.prototype,"maxCameraSpeed",void 0),__decorate([e.serializeAsMeshReference("lockedTargetId")],i.prototype,"target",void 0),i}(e.TargetCamera);e.FollowCamera=t;var i=function(t){function i(i,r,n,o,s,a){t.call(this,i,e.Vector3.Zero(),a),this.alpha=r,this.beta=n,this.radius=o,this.target=s,this._cartesianCoordinates=e.Vector3.Zero(),this.follow()}return __extends(i,t),i.prototype.follow=function(){this._cartesianCoordinates.x=this.radius*Math.cos(this.alpha)*Math.cos(this.beta),this._cartesianCoordinates.y=this.radius*Math.sin(this.beta),this._cartesianCoordinates.z=this.radius*Math.sin(this.alpha)*Math.cos(this.beta),this.position=this.target.position.add(this._cartesianCoordinates),this.setTarget(this.target.position)},i.prototype._checkInputs=function(){t.prototype._checkInputs.call(this),this.follow()},i.prototype.getTypeName=function(){return"ArcFollowCamera"},i}(e.TargetCamera);e.ArcFollowCamera=i}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(e){function t(t,i,r){e.call(this,t,i,r),this.inputs.addTouch(),this._setupInputs()}return __extends(t,e),Object.defineProperty(t.prototype,"touchAngularSensibility",{get:function(){var e=this.inputs.attached.touch;return e?e.touchAngularSensibility:void 0},set:function(e){var t=this.inputs.attached.touch;t&&(t.touchAngularSensibility=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"touchMoveSensibility",{get:function(){var e=this.inputs.attached.touch;return e?e.touchMoveSensibility:void 0},set:function(e){var t=this.inputs.attached.touch;t&&(t.touchMoveSensibility=e)},enumerable:!0,configurable:!0}),t.prototype.getTypeName=function(){return"TouchCamera"},t.prototype._setupInputs=function(){var e=this.inputs.attached.mouse;e&&(e.touchEnabled=!1)},t}(e.FreeCamera);e.TouchCamera=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(t){function i(i,r,n,o,s,a){var h=this;t.call(this,i,e.Vector3.Zero(),a),this.inertialAlphaOffset=0,this.inertialBetaOffset=0,this.inertialRadiusOffset=0,this.lowerAlphaLimit=null,this.upperAlphaLimit=null,this.lowerBetaLimit=.01,this.upperBetaLimit=Math.PI,this.lowerRadiusLimit=null,this.upperRadiusLimit=null,this.inertialPanningX=0,this.inertialPanningY=0,this.zoomOnFactor=1,this.targetScreenOffset=e.Vector2.Zero(),this.allowUpsideDown=!0,this._viewMatrix=new e.Matrix,this.panningAxis=new e.Vector3(1,1,0),this.checkCollisions=!1,this.collisionRadius=new e.Vector3(.5,.5,.5),this._collider=new e.Collider,this._previousPosition=e.Vector3.Zero(),this._collisionVelocity=e.Vector3.Zero(),this._newPosition=e.Vector3.Zero(),this._onCollisionPositionChange=function(t,i,r){void 0===r&&(r=null),h.getScene().workerCollisions&&h.checkCollisions&&i.multiplyInPlace(h._collider.radius),r?(h.setPosition(i),h.onCollide&&h.onCollide(r)):h._previousPosition.copyFrom(h.position);var n=Math.cos(h.alpha),o=Math.sin(h.alpha),s=Math.cos(h.beta),a=Math.sin(h.beta);0===a&&(a=1e-4);var c=h._getTargetPosition();c.addToRef(new e.Vector3(h.radius*n*a,h.radius*s,h.radius*o*a),h._newPosition),h.position.copyFrom(h._newPosition);var l=h.upVector;h.allowUpsideDown&&h.beta<0&&(l=l.clone(),l=l.negate()),e.Matrix.LookAtLHToRef(h.position,c,l,h._viewMatrix),h._viewMatrix.m[12]+=h.targetScreenOffset.x,h._viewMatrix.m[13]+=h.targetScreenOffset.y,h._collisionTriggered=!1},s?this.target=s:this.target=e.Vector3.Zero(),this.alpha=r,this.beta=n,this.radius=o,this.getViewMatrix(),this.inputs=new e.ArcRotateCameraInputsManager(this),this.inputs.addKeyboard().addMouseWheel().addPointers().addGamepad()}return __extends(i,t),Object.defineProperty(i.prototype,"angularSensibilityX",{get:function(){var e=this.inputs.attached.pointers;return e?e.angularSensibilityX:void 0},set:function(e){var t=this.inputs.attached.pointers;t&&(t.angularSensibilityX=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"angularSensibilityY",{get:function(){var e=this.inputs.attached.pointers;return e?e.angularSensibilityY:void 0},set:function(e){var t=this.inputs.attached.pointers;t&&(t.angularSensibilityY=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"pinchPrecision",{get:function(){var e=this.inputs.attached.pointers;return e?e.pinchPrecision:void 0},set:function(e){var t=this.inputs.attached.pointers;t&&(t.pinchPrecision=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"panningSensibility",{get:function(){var e=this.inputs.attached.pointers;return e?e.panningSensibility:void 0},set:function(e){var t=this.inputs.attached.pointers;t&&(t.panningSensibility=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"keysUp",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysUp:void 0},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysUp=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"keysDown",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysDown:void 0},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysDown=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"keysLeft",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysLeft:void 0},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysLeft=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"keysRight",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysRight:void 0},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysRight=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"wheelPrecision",{get:function(){var e=this.inputs.attached.mousewheel;return e?e.wheelPrecision:void 0},set:function(e){var t=this.inputs.attached.mousewheel;t&&(t.wheelPrecision=e)},enumerable:!0,configurable:!0}),i.prototype._initCache=function(){t.prototype._initCache.call(this),this._cache.target=new e.Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.alpha=void 0,this._cache.beta=void 0,this._cache.radius=void 0,this._cache.targetScreenOffset=e.Vector2.Zero()},i.prototype._updateCache=function(e){e||t.prototype._updateCache.call(this),this._cache.target.copyFrom(this._getTargetPosition()),this._cache.alpha=this.alpha,this._cache.beta=this.beta,this._cache.radius=this.radius,this._cache.targetScreenOffset.copyFrom(this.targetScreenOffset)},i.prototype._getTargetPosition=function(){return this.target.getAbsolutePosition?this.target.getAbsolutePosition():this.target},i.prototype._isSynchronizedViewMatrix=function(){return t.prototype._isSynchronizedViewMatrix.call(this)?this._cache.target.equals(this.target)&&this._cache.alpha===this.alpha&&this._cache.beta===this.beta&&this._cache.radius===this.radius&&this._cache.targetScreenOffset.equals(this.targetScreenOffset):!1},i.prototype.attachControl=function(e,t,i){var r=this;void 0===i&&(i=!0),this._useCtrlForPanning=i,this.inputs.attachElement(e,t),this._reset=function(){r.inertialAlphaOffset=0,r.inertialBetaOffset=0,r.inertialRadiusOffset=0}},i.prototype.detachControl=function(e){this.inputs.detachElement(e),this._reset&&this._reset()},i.prototype._checkInputs=function(){this._collisionTriggered||(this.inputs.checkInputs(),0===this.inertialAlphaOffset&&0===this.inertialBetaOffset&&0===this.inertialRadiusOffset||(this.alpha+=this.beta<=0?-this.inertialAlphaOffset:this.inertialAlphaOffset,this.beta+=this.inertialBetaOffset,this.radius-=this.inertialRadiusOffset,this.inertialAlphaOffset*=this.inertia,this.inertialBetaOffset*=this.inertia,this.inertialRadiusOffset*=this.inertia,Math.abs(this.inertialAlphaOffset)<e.Epsilon&&(this.inertialAlphaOffset=0),Math.abs(this.inertialBetaOffset)<e.Epsilon&&(this.inertialBetaOffset=0),Math.abs(this.inertialRadiusOffset)<e.Epsilon&&(this.inertialRadiusOffset=0)),0===this.inertialPanningX&&0===this.inertialPanningY||(this._localDirection||(this._localDirection=e.Vector3.Zero(),this._transformedDirection=e.Vector3.Zero()),this.inertialPanningX*=this.inertia,this.inertialPanningY*=this.inertia,Math.abs(this.inertialPanningX)<e.Epsilon&&(this.inertialPanningX=0),Math.abs(this.inertialPanningY)<e.Epsilon&&(this.inertialPanningY=0),this._localDirection.copyFromFloats(this.inertialPanningX,this.inertialPanningY,this.inertialPanningY),this._localDirection.multiplyInPlace(this.panningAxis),this._viewMatrix.invertToRef(this._cameraTransformMatrix),e.Vector3.TransformNormalToRef(this._localDirection,this._cameraTransformMatrix,this._transformedDirection),this.panningAxis.y||(this._transformedDirection.y=0),this.target.getAbsolutePosition||this.target.addInPlace(this._transformedDirection)),this._checkLimits(),t.prototype._checkInputs.call(this))},i.prototype._checkLimits=function(){null===this.lowerBetaLimit||void 0===this.lowerBetaLimit?this.allowUpsideDown&&this.beta>Math.PI&&(this.beta=this.beta-2*Math.PI):this.beta<this.lowerBetaLimit&&(this.beta=this.lowerBetaLimit),null===this.upperBetaLimit||void 0===this.upperBetaLimit?this.allowUpsideDown&&this.beta<-Math.PI&&(this.beta=this.beta+2*Math.PI):this.beta>this.upperBetaLimit&&(this.beta=this.upperBetaLimit),this.lowerAlphaLimit&&this.alpha<this.lowerAlphaLimit&&(this.alpha=this.lowerAlphaLimit),this.upperAlphaLimit&&this.alpha>this.upperAlphaLimit&&(this.alpha=this.upperAlphaLimit),this.lowerRadiusLimit&&this.radius<this.lowerRadiusLimit&&(this.radius=this.lowerRadiusLimit),this.upperRadiusLimit&&this.radius>this.upperRadiusLimit&&(this.radius=this.upperRadiusLimit)},i.prototype.rebuildAnglesAndRadius=function(){var e=this.position.subtract(this._getTargetPosition());this.radius=e.length(),this.alpha=Math.acos(e.x/Math.sqrt(Math.pow(e.x,2)+Math.pow(e.z,2))),e.z<0&&(this.alpha=2*Math.PI-this.alpha),this.beta=Math.acos(e.y/this.radius),this._checkLimits()},i.prototype.setPosition=function(e){this.position.equals(e)||(this.position=e,this.rebuildAnglesAndRadius())},i.prototype.setTarget=function(e){this._getTargetPosition().equals(e)||(this.target=e,this.rebuildAnglesAndRadius())},i.prototype._getViewMatrix=function(){var t=Math.cos(this.alpha),i=Math.sin(this.alpha),r=Math.cos(this.beta),n=Math.sin(this.beta);0===n&&(n=1e-4);var o=this._getTargetPosition();if(o.addToRef(new e.Vector3(this.radius*t*n,this.radius*r,this.radius*i*n),this._newPosition),this.getScene().collisionsEnabled&&this.checkCollisions)this._collider.radius=this.collisionRadius,this._newPosition.subtractToRef(this.position,this._collisionVelocity),this._collisionTriggered=!0,this.getScene().collisionCoordinator.getNewPosition(this.position,this._collisionVelocity,this._collider,3,null,this._onCollisionPositionChange,this.uniqueId);else{this.position.copyFrom(this._newPosition);var s=this.upVector;this.allowUpsideDown&&this.beta<0&&(s=s.clone(),s=s.negate()),e.Matrix.LookAtLHToRef(this.position,o,s,this._viewMatrix),this._viewMatrix.m[12]+=this.targetScreenOffset.x,this._viewMatrix.m[13]+=this.targetScreenOffset.y}return this._viewMatrix},i.prototype.zoomOn=function(t,i){void 0===i&&(i=!1),t=t||this.getScene().meshes;var r=e.Mesh.MinMax(t),n=e.Vector3.Distance(r.min,r.max);this.radius=n*this.zoomOnFactor,this.focusOn({min:r.min,max:r.max,distance:n},i)},i.prototype.focusOn=function(t,i){void 0===i&&(i=!1);var r,n;void 0===t.min?(r=t||this.getScene().meshes,r=e.Mesh.MinMax(r),n=e.Vector3.Distance(r.min,r.max)):(r=t,n=t.distance),this.target=e.Mesh.Center(r),i||(this.maxZ=2*n)},i.prototype.createRigCamera=function(t,r){var n;switch(this.cameraRigMode){case e.Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case e.Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER:case e.Camera.RIG_MODE_VR:n=this._cameraRigParams.stereoHalfAngle*(0===r?1:-1);break;case e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:n=this._cameraRigParams.stereoHalfAngle*(0===r?-1:1)}var o=new i(t,this.alpha+n,this.beta,this.radius,this.target,this.getScene());return o._cameraRigParams={},o},i.prototype._updateRigCameras=function(){var i=this._rigCameras[0],r=this._rigCameras[1];switch(i.beta=r.beta=this.beta,i.radius=r.radius=this.radius,this.cameraRigMode){case e.Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case e.Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER:case e.Camera.RIG_MODE_VR:i.alpha=this.alpha-this._cameraRigParams.stereoHalfAngle,r.alpha=this.alpha+this._cameraRigParams.stereoHalfAngle;break;case e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:i.alpha=this.alpha+this._cameraRigParams.stereoHalfAngle,r.alpha=this.alpha-this._cameraRigParams.stereoHalfAngle}t.prototype._updateRigCameras.call(this)},i.prototype.dispose=function(){this.inputs.clear(),t.prototype.dispose.call(this)},i.prototype.getTypeName=function(){return"ArcRotateCamera"},__decorate([e.serialize()],i.prototype,"alpha",void 0),__decorate([e.serialize()],i.prototype,"beta",void 0),__decorate([e.serialize()],i.prototype,"radius",void 0),__decorate([e.serializeAsVector3()],i.prototype,"target",void 0),__decorate([e.serialize()],i.prototype,"inertialAlphaOffset",void 0),__decorate([e.serialize()],i.prototype,"inertialBetaOffset",void 0),__decorate([e.serialize()],i.prototype,"inertialRadiusOffset",void 0),__decorate([e.serialize()],i.prototype,"lowerAlphaLimit",void 0),__decorate([e.serialize()],i.prototype,"upperAlphaLimit",void 0),__decorate([e.serialize()],i.prototype,"lowerBetaLimit",void 0),__decorate([e.serialize()],i.prototype,"upperBetaLimit",void 0),__decorate([e.serialize()],i.prototype,"lowerRadiusLimit",void 0),__decorate([e.serialize()],i.prototype,"upperRadiusLimit",void 0),__decorate([e.serialize()],i.prototype,"inertialPanningX",void 0),__decorate([e.serialize()],i.prototype,"inertialPanningY",void 0),__decorate([e.serialize()],i.prototype,"zoomOnFactor",void 0),__decorate([e.serialize()],i.prototype,"allowUpsideDown",void 0),i}(e.TargetCamera);e.ArcRotateCamera=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(t){function i(e){t.call(this,e)}return __extends(i,t),i.prototype.addMouseWheel=function(){return this.add(new e.ArcRotateCameraMouseWheelInput),this},i.prototype.addPointers=function(){return this.add(new e.ArcRotateCameraPointersInput),this},i.prototype.addKeyboard=function(){return this.add(new e.ArcRotateCameraKeyboardMoveInput),this},i.prototype.addGamepad=function(){return this.add(new e.ArcRotateCameraGamepadInput),this},i.prototype.addVRDeviceOrientation=function(){return this.add(new e.ArcRotateCameraVRDeviceOrientationInput),this},i}(e.CameraInputsManager);e.ArcRotateCameraInputsManager=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(e){this._renderingGroups=new Array,this._scene=e}return t.prototype._renderParticles=function(t,i){if(0!==this._scene._activeParticleSystems.length){for(var r=this._scene.activeCamera,n=e.Tools.Now,o=0;o<this._scene._activeParticleSystems.length;o++){var s=this._scene._activeParticleSystems.data[o];s.renderingGroupId===t&&0!==(r.layerMask&s.layerMask)&&(this._clearDepthBuffer(),s.emitter.position&&i&&-1===i.indexOf(s.emitter)||(this._scene._activeParticles+=s.render()))}this._scene._particlesDuration+=e.Tools.Now-n}},t.prototype._renderSprites=function(t){if(this._scene.spritesEnabled&&0!==this._scene.spriteManagers.length){for(var i=this._scene.activeCamera,r=e.Tools.Now,n=0;n<this._scene.spriteManagers.length;n++){var o=this._scene.spriteManagers[n];o.renderingGroupId===t&&0!==(i.layerMask&o.layerMask)&&(this._clearDepthBuffer(),o.render())}this._scene._spritesDuration+=e.Tools.Now-r}},t.prototype._clearDepthBuffer=function(){this._depthBufferAlreadyCleaned||(this._scene.getEngine().clear(0,!1,!0),this._depthBufferAlreadyCleaned=!0)},t.prototype._renderSpritesAndParticles=function(){this._currentRenderSprites&&this._renderSprites(this._currentIndex),this._currentRenderParticles&&this._renderParticles(this._currentIndex,this._currentActiveMeshes)},t.prototype.render=function(e,i,r,n){this._currentActiveMeshes=i,this._currentRenderParticles=r,this._currentRenderSprites=n;for(var o=0;o<t.MAX_RENDERINGGROUPS;o++){this._depthBufferAlreadyCleaned=0==o;var s=this._renderingGroups[o],a=!1;this._currentIndex=o,s?(this._clearDepthBuffer(),s.onBeforeTransparentRendering||(s.onBeforeTransparentRendering=this._renderSpritesAndParticles.bind(this)),s.render(e)||(this._renderingGroups.splice(o,1),a=!0,this._renderSpritesAndParticles())):this._renderSpritesAndParticles(),a&&o--}},t.prototype.reset=function(){this._renderingGroups.forEach(function(e,t,i){e&&e.prepare()})},t.prototype.dispatch=function(t){var i=t.getMesh(),r=i.renderingGroupId||0;this._renderingGroups[r]||(this._renderingGroups[r]=new e.RenderingGroup(r,this._scene)),this._renderingGroups[r].dispatch(t)},t.MAX_RENDERINGGROUPS=4,t}();e.RenderingManager=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(t,i){this.index=t,this._opaqueSubMeshes=new e.SmartArray(256),this._transparentSubMeshes=new e.SmartArray(256),this._alphaTestSubMeshes=new e.SmartArray(256),this._scene=i}return t.prototype.render=function(t){
  10. if(t)return t(this._opaqueSubMeshes,this._alphaTestSubMeshes,this._transparentSubMeshes),!0;if(0===this._opaqueSubMeshes.length&&0===this._alphaTestSubMeshes.length&&0===this._transparentSubMeshes.length)return this.onBeforeTransparentRendering&&this.onBeforeTransparentRendering(),!1;var i,r,n=this._scene.getEngine();for(i=0;i<this._opaqueSubMeshes.length;i++)r=this._opaqueSubMeshes.data[i],r.render(!1);for(n.setAlphaTesting(!0),i=0;i<this._alphaTestSubMeshes.length;i++)r=this._alphaTestSubMeshes.data[i],r.render(!1);if(n.setAlphaTesting(!1),this.onBeforeTransparentRendering&&this.onBeforeTransparentRendering(),this._transparentSubMeshes.length){for(i=0;i<this._transparentSubMeshes.length;i++)r=this._transparentSubMeshes.data[i],r._alphaIndex=r.getMesh().alphaIndex,r._distanceToCamera=r.getBoundingInfo().boundingSphere.centerWorld.subtract(this._scene.activeCamera.globalPosition).length();var o=this._transparentSubMeshes.data.slice(0,this._transparentSubMeshes.length);for(o.sort(function(e,t){return e._alphaIndex>t._alphaIndex?1:e._alphaIndex<t._alphaIndex?-1:e._distanceToCamera<t._distanceToCamera?1:e._distanceToCamera>t._distanceToCamera?-1:0}),i=0;i<o.length;i++)r=o[i],r.render(!0);n.setAlphaMode(e.Engine.ALPHA_DISABLE)}return!0},t.prototype.prepare=function(){this._opaqueSubMeshes.reset(),this._transparentSubMeshes.reset(),this._alphaTestSubMeshes.reset()},t.prototype.dispatch=function(e){var t=e.getMaterial(),i=e.getMesh();t.needAlphaBlending()||i.visibility<1||i.hasVertexAlpha?this._transparentSubMeshes.push(e):t.needAlphaTesting()?this._alphaTestSubMeshes.push(e):this._opaqueSubMeshes.push(e)},t}();e.RenderingGroup=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function e(){}return Object.defineProperty(e,"POINTERDOWN",{get:function(){return e._POINTERDOWN},enumerable:!0,configurable:!0}),Object.defineProperty(e,"POINTERUP",{get:function(){return e._POINTERUP},enumerable:!0,configurable:!0}),Object.defineProperty(e,"POINTERMOVE",{get:function(){return e._POINTERMOVE},enumerable:!0,configurable:!0}),Object.defineProperty(e,"POINTERWHEEL",{get:function(){return e._POINTERWHEEL},enumerable:!0,configurable:!0}),Object.defineProperty(e,"POINTERPICK",{get:function(){return e._POINTERPICK},enumerable:!0,configurable:!0}),e._POINTERDOWN=1,e._POINTERUP=2,e._POINTERMOVE=4,e._POINTERWHEEL=8,e._POINTERPICK=16,e}();e.PointerEventTypes=t;var i=function(){function e(e,t){this.type=e,this.event=t}return e}();e.PointerInfoBase=i;var r=function(t){function i(i,r,n,o){t.call(this,i,r),this.skipOnPointerObservable=!1,this.localPosition=new e.Vector2(n,o)}return __extends(i,t),i}(i);e.PointerInfoPre=r;var n=function(e){function t(t,i,r){e.call(this,t,i),this.pickInfo=r}return __extends(t,e),t}(i);e.PointerInfo=n;var o=function(){function i(t){this.autoClear=!0,this.clearColor=new e.Color3(.2,.2,.3),this.ambientColor=new e.Color3(0,0,0),this.forceWireframe=!1,this.forcePointsCloud=!1,this.forceShowBoundingBoxes=!1,this.animationsEnabled=!0,this.constantlyUpdateMeshUnderPointer=!1,this.onDisposeObservable=new e.Observable,this.onBeforeRenderObservable=new e.Observable,this.onAfterRenderObservable=new e.Observable,this.onReadyObservable=new e.Observable,this.onBeforeCameraRenderObservable=new e.Observable,this.onAfterCameraRenderObservable=new e.Observable,this.onNewCameraAddedObservable=new e.Observable,this.onCameraRemovedObservable=new e.Observable,this.onNewLightAddedObservable=new e.Observable,this.onLightRemovedObservable=new e.Observable,this.onNewGeometryAddedObservable=new e.Observable,this.onGeometryRemovedObservable=new e.Observable,this.onNewMeshAddedObservable=new e.Observable,this.onMeshRemovedObservable=new e.Observable,this.animations=[],this.onPrePointerObservable=new e.Observable,this.onPointerObservable=new e.Observable,this.cameraToUseForPointers=null,this._startingPointerPosition=new e.Vector2(0,0),this._startingPointerTime=0,this.fogEnabled=!0,this.fogMode=i.FOGMODE_NONE,this.fogColor=new e.Color3(.2,.2,.3),this.fogDensity=.1,this.fogStart=0,this.fogEnd=1e3,this.shadowsEnabled=!0,this.lightsEnabled=!0,this.lights=new Array,this.cameras=new Array,this.activeCameras=new Array,this.meshes=new Array,this._geometries=new Array,this.materials=new Array,this.multiMaterials=new Array,this.defaultMaterial=new e.StandardMaterial("default material",this),this.texturesEnabled=!0,this.textures=new Array,this.particlesEnabled=!0,this.particleSystems=new Array,this.spritesEnabled=!0,this.spriteManagers=new Array,this.layers=new Array,this.skeletonsEnabled=!0,this.skeletons=new Array,this.lensFlaresEnabled=!0,this.lensFlareSystems=new Array,this.collisionsEnabled=!0,this.gravity=new e.Vector3(0,-9.807,0),this.postProcessesEnabled=!0,this.renderTargetsEnabled=!0,this.dumpNextRenderTargets=!1,this.customRenderTargets=new Array,this.importedMeshesFiles=new Array,this.probesEnabled=!0,this.reflectionProbes=new Array,this._actionManagers=new Array,this._meshesForIntersections=new e.SmartArray(256),this.proceduralTexturesEnabled=!0,this._proceduralTextures=new Array,this.soundTracks=new Array,this._audioEnabled=!0,this._headphone=!1,this._totalVertices=0,this._activeIndices=0,this._activeParticles=0,this._lastFrameDuration=0,this._evaluateActiveMeshesDuration=0,this._renderTargetsDuration=0,this._particlesDuration=0,this._renderDuration=0,this._spritesDuration=0,this._animationRatio=0,this._renderId=0,this._executeWhenReadyTimeoutId=-1,this._intermediateRendering=!1,this._toBeDisposed=new e.SmartArray(256),this._pendingData=[],this._activeMeshes=new e.SmartArray(256),this._processedMaterials=new e.SmartArray(256),this._renderTargets=new e.SmartArray(256),this._activeParticleSystems=new e.SmartArray(256),this._activeSkeletons=new e.SmartArray(32),this._softwareSkinnedMeshes=new e.SmartArray(32),this._activeBones=0,this._activeAnimatables=new Array,this._transformMatrix=e.Matrix.Zero(),this._edgesRenderers=new e.SmartArray(16),this._uniqueIdCounter=0,this._engine=t,t.scenes.push(this),this._renderingManager=new e.RenderingManager(this),this.postProcessManager=new e.PostProcessManager(this),this.postProcessRenderPipelineManager=new e.PostProcessRenderPipelineManager,this._boundingBoxRenderer=new e.BoundingBoxRenderer(this),e.OutlineRenderer&&(this._outlineRenderer=new e.OutlineRenderer(this)),this.attachControl(),e.SoundTrack&&(this.mainSoundTrack=new e.SoundTrack(this,{mainTrack:!0})),e.SimplificationQueue&&(this.simplificationQueue=new e.SimplificationQueue),this.workerCollisions=!1}return Object.defineProperty(i,"FOGMODE_NONE",{get:function(){return i._FOGMODE_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(i,"FOGMODE_EXP",{get:function(){return i._FOGMODE_EXP},enumerable:!0,configurable:!0}),Object.defineProperty(i,"FOGMODE_EXP2",{get:function(){return i._FOGMODE_EXP2},enumerable:!0,configurable:!0}),Object.defineProperty(i,"FOGMODE_LINEAR",{get:function(){return i._FOGMODE_LINEAR},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"beforeRender",{set:function(e){this._onBeforeRenderObserver&&this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),this._onBeforeRenderObserver=this.onBeforeRenderObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"afterRender",{set:function(e){this._onAfterRenderObserver&&this.onAfterRenderObservable.remove(this._onAfterRenderObserver),this._onAfterRenderObserver=this.onAfterRenderObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"beforeCameraRender",{set:function(e){this._onBeforeCameraRenderObserver&&this.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver),this._onBeforeCameraRenderObserver=this.onBeforeCameraRenderObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"afterCameraRender",{set:function(e){this._onAfterCameraRenderObserver&&this.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver),this._onAfterCameraRenderObserver=this.onAfterCameraRenderObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"unTranslatedPointer",{get:function(){return new e.Vector2(this._unTranslatedPointerX,this._unTranslatedPointerY)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"debugLayer",{get:function(){return this._debugLayer||(this._debugLayer=new e.DebugLayer(this)),this._debugLayer},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"workerCollisions",{get:function(){return this._workerCollisions},set:function(t){t=t&&!!Worker,this._workerCollisions=t,this.collisionCoordinator&&this.collisionCoordinator.destroy(),this.collisionCoordinator=t?new e.CollisionCoordinatorWorker:new e.CollisionCoordinatorLegacy,this.collisionCoordinator.init(this)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"SelectionOctree",{get:function(){return this._selectionOctree},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"meshUnderPointer",{get:function(){return this._pointerOverMesh},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"pointerX",{get:function(){return this._pointerX},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"pointerY",{get:function(){return this._pointerY},enumerable:!0,configurable:!0}),i.prototype.getCachedMaterial=function(){return this._cachedMaterial},i.prototype.getBoundingBoxRenderer=function(){return this._boundingBoxRenderer},i.prototype.getOutlineRenderer=function(){return this._outlineRenderer},i.prototype.getEngine=function(){return this._engine},i.prototype.getTotalVertices=function(){return this._totalVertices},i.prototype.getActiveIndices=function(){return this._activeIndices},i.prototype.getActiveParticles=function(){return this._activeParticles},i.prototype.getActiveBones=function(){return this._activeBones},i.prototype.getLastFrameDuration=function(){return this._lastFrameDuration},i.prototype.getEvaluateActiveMeshesDuration=function(){return this._evaluateActiveMeshesDuration},i.prototype.getActiveMeshes=function(){return this._activeMeshes},i.prototype.getRenderTargetsDuration=function(){return this._renderTargetsDuration},i.prototype.getRenderDuration=function(){return this._renderDuration},i.prototype.getParticlesDuration=function(){return this._particlesDuration},i.prototype.getSpritesDuration=function(){return this._spritesDuration},i.prototype.getAnimationRatio=function(){return this._animationRatio},i.prototype.getRenderId=function(){return this._renderId},i.prototype.incrementRenderId=function(){this._renderId++},i.prototype._updatePointerPosition=function(e){var t=this._engine.getRenderingCanvasClientRect();this._pointerX=e.clientX-t.left,this._pointerY=e.clientY-t.top,this._unTranslatedPointerX=this._pointerX,this._unTranslatedPointerY=this._pointerY,this.cameraToUseForPointers&&(this._pointerX=this._pointerX-this.cameraToUseForPointers.viewport.x*this._engine.getRenderWidth(),this._pointerY=this._pointerY-this.cameraToUseForPointers.viewport.y*this._engine.getRenderHeight())},i.prototype.attachControl=function(i,o,s){var a=this;void 0===i&&(i=!0),void 0===o&&(o=!0),void 0===s&&(s=!0);var h=function(e){return e.isPickable&&e.actionManager&&e.actionManager.hasPointerTriggers};this._onPointerMove=function(e){if(a._updatePointerPosition(e),a.onPrePointerObservable.hasObservers()){var i="mousewheel"===e.type||"DOMMouseScroll"===e.type?t.POINTERWHEEL:t.POINTERMOVE,o=new r(i,e,a._unTranslatedPointerX,a._unTranslatedPointerY);if(a.onPrePointerObservable.notifyObservers(o,i),o.skipOnPointerObservable)return}if(a.cameraToUseForPointers||a.activeCamera){var s=a._engine.getRenderingCanvas();a.pointerMovePredicate||(a.pointerMovePredicate=function(e){return e.isPickable&&e.isVisible&&e.isReady()&&(a.constantlyUpdateMeshUnderPointer||null!==e.actionManager&&void 0!==e.actionManager)});var c=a.pick(a._unTranslatedPointerX,a._unTranslatedPointerY,a.pointerMovePredicate,!1,a.cameraToUseForPointers);if(c.hit&&c.pickedMesh?(a.setPointerOverSprite(null),a.setPointerOverMesh(c.pickedMesh),a._pointerOverMesh.actionManager&&a._pointerOverMesh.actionManager.hasPointerTriggers?s.style.cursor="pointer":s.style.cursor=""):(a.setPointerOverMesh(null),c=a.pickSprite(a._unTranslatedPointerX,a._unTranslatedPointerY,h,!1,a.cameraToUseForPointers),c.hit&&c.pickedSprite?(s.style.cursor="pointer",a.setPointerOverSprite(c.pickedSprite)):(a.setPointerOverSprite(null),s.style.cursor="")),a.onPointerMove&&a.onPointerMove(e,c),a.onPointerObservable.hasObservers()){var i="mousewheel"===e.type||"DOMMouseScroll"===e.type?t.POINTERWHEEL:t.POINTERMOVE,o=new n(i,e,c);a.onPointerObservable.notifyObservers(o,i)}}},this._onPointerDown=function(i){if(a._updatePointerPosition(i),a.onPrePointerObservable.hasObservers()){var o=t.POINTERDOWN,s=new r(o,i,a._unTranslatedPointerX,a._unTranslatedPointerY);if(a.onPrePointerObservable.notifyObservers(s,o),s.skipOnPointerObservable)return}if(a.cameraToUseForPointers||a.activeCamera){a._startingPointerPosition.x=a._pointerX,a._startingPointerPosition.y=a._pointerY,a._startingPointerTime=(new Date).getTime(),a.pointerDownPredicate||(a.pointerDownPredicate=function(e){return e.isPickable&&e.isVisible&&e.isReady()&&(!e.actionManager||e.actionManager.hasPointerTriggers)}),a._pickedDownMesh=null;var c=a.pick(a._unTranslatedPointerX,a._unTranslatedPointerY,a.pointerDownPredicate,!1,a.cameraToUseForPointers);if(c.hit&&c.pickedMesh&&c.pickedMesh.actionManager){if(a._pickedDownMesh=c.pickedMesh,c.pickedMesh.actionManager.hasPickTriggers){switch(i.button){case 0:c.pickedMesh.actionManager.processTrigger(e.ActionManager.OnLeftPickTrigger,e.ActionEvent.CreateNew(c.pickedMesh,i));break;case 1:c.pickedMesh.actionManager.processTrigger(e.ActionManager.OnCenterPickTrigger,e.ActionEvent.CreateNew(c.pickedMesh,i));break;case 2:c.pickedMesh.actionManager.processTrigger(e.ActionManager.OnRightPickTrigger,e.ActionEvent.CreateNew(c.pickedMesh,i))}c.pickedMesh.actionManager.processTrigger(e.ActionManager.OnPickDownTrigger,e.ActionEvent.CreateNew(c.pickedMesh,i))}if(c.pickedMesh.actionManager.hasSpecificTrigger(e.ActionManager.OnLongPressTrigger)){var l=a;window.setTimeout(function(){var t=l.pick(l._unTranslatedPointerX,l._unTranslatedPointerY,function(t){return t.isPickable&&t.isVisible&&t.isReady()&&t.actionManager&&t.actionManager.hasSpecificTrigger(e.ActionManager.OnLongPressTrigger)},!1,l.cameraToUseForPointers);t.hit&&t.pickedMesh&&t.pickedMesh.actionManager&&0!==l._startingPointerTime&&(new Date).getTime()-l._startingPointerTime>e.ActionManager.LongPressDelay&&Math.abs(l._startingPointerPosition.x-l._pointerX)<e.ActionManager.DragMovementThreshold&&Math.abs(l._startingPointerPosition.y-l._pointerY)<e.ActionManager.DragMovementThreshold&&(l._startingPointerTime=0,t.pickedMesh.actionManager.processTrigger(e.ActionManager.OnLongPressTrigger,e.ActionEvent.CreateNew(t.pickedMesh,i)))},e.ActionManager.LongPressDelay)}}if(a.onPointerDown&&a.onPointerDown(i,c),a.onPointerObservable.hasObservers()){var o=t.POINTERDOWN,s=new n(o,i,c);a.onPointerObservable.notifyObservers(s,o)}if(a._pickedDownSprite=null,a.spriteManagers.length>0&&(c=a.pickSprite(a._unTranslatedPointerX,a._unTranslatedPointerY,h,!1,a.cameraToUseForPointers),c.hit&&c.pickedSprite&&c.pickedSprite.actionManager)){switch(a._pickedDownSprite=c.pickedSprite,i.button){case 0:c.pickedSprite.actionManager.processTrigger(e.ActionManager.OnLeftPickTrigger,e.ActionEvent.CreateNewFromSprite(c.pickedSprite,a,i));break;case 1:c.pickedSprite.actionManager.processTrigger(e.ActionManager.OnCenterPickTrigger,e.ActionEvent.CreateNewFromSprite(c.pickedSprite,a,i));break;case 2:c.pickedSprite.actionManager.processTrigger(e.ActionManager.OnRightPickTrigger,e.ActionEvent.CreateNewFromSprite(c.pickedSprite,a,i))}c.pickedSprite.actionManager.processTrigger(e.ActionManager.OnPickDownTrigger,e.ActionEvent.CreateNewFromSprite(c.pickedSprite,a,i))}}},this._onPointerUp=function(i){if(a._updatePointerPosition(i),a.onPrePointerObservable.hasObservers()){var o=t.POINTERUP,s=new r(o,i,a._unTranslatedPointerX,a._unTranslatedPointerY);if(a.onPrePointerObservable.notifyObservers(s,o),s.skipOnPointerObservable)return}if(a.cameraToUseForPointers||a.activeCamera){a.pointerUpPredicate||(a.pointerUpPredicate=function(t){return t.isPickable&&t.isVisible&&t.isReady()&&(!t.actionManager||t.actionManager.hasPickTriggers||t.actionManager.hasSpecificTrigger(e.ActionManager.OnLongPressTrigger))});var c=a.pick(a._unTranslatedPointerX,a._unTranslatedPointerY,a.pointerUpPredicate,!1,a.cameraToUseForPointers);if(c.hit&&c.pickedMesh){if(null!=a._pickedDownMesh&&c.pickedMesh==a._pickedDownMesh&&(a.onPointerPick&&a.onPointerPick(i,c),a.onPointerObservable.hasObservers())){var o=t.POINTERPICK,s=new n(o,i,c);a.onPointerObservable.notifyObservers(s,o)}c.pickedMesh.actionManager&&(c.pickedMesh.actionManager.processTrigger(e.ActionManager.OnPickUpTrigger,e.ActionEvent.CreateNew(c.pickedMesh,i)),Math.abs(a._startingPointerPosition.x-a._pointerX)<e.ActionManager.DragMovementThreshold&&Math.abs(a._startingPointerPosition.y-a._pointerY)<e.ActionManager.DragMovementThreshold&&c.pickedMesh.actionManager.processTrigger(e.ActionManager.OnPickTrigger,e.ActionEvent.CreateNew(c.pickedMesh,i)))}if(a._pickedDownMesh&&a._pickedDownMesh!==c.pickedMesh&&a._pickedDownMesh.actionManager.processTrigger(e.ActionManager.OnPickOutTrigger,e.ActionEvent.CreateNew(a._pickedDownMesh,i)),a.onPointerUp&&a.onPointerUp(i,c),a.onPointerObservable.hasObservers()){var o=t.POINTERUP,s=new n(o,i,c);a.onPointerObservable.notifyObservers(s,o)}a._startingPointerTime=0,a.spriteManagers.length>0&&(c=a.pickSprite(a._unTranslatedPointerX,a._unTranslatedPointerY,h,!1,a.cameraToUseForPointers),c.hit&&c.pickedSprite&&c.pickedSprite.actionManager&&(c.pickedSprite.actionManager.processTrigger(e.ActionManager.OnPickUpTrigger,e.ActionEvent.CreateNewFromSprite(c.pickedSprite,a,i)),Math.abs(a._startingPointerPosition.x-a._pointerX)<e.ActionManager.DragMovementThreshold&&Math.abs(a._startingPointerPosition.y-a._pointerY)<e.ActionManager.DragMovementThreshold&&c.pickedSprite.actionManager.processTrigger(e.ActionManager.OnPickTrigger,e.ActionEvent.CreateNewFromSprite(c.pickedSprite,a,i))),a._pickedDownSprite&&a._pickedDownSprite!==c.pickedSprite&&a._pickedDownSprite.actionManager.processTrigger(e.ActionManager.OnPickOutTrigger,e.ActionEvent.CreateNewFromSprite(a._pickedDownSprite,a,i)))}},this._onKeyDown=function(t){a.actionManager&&a.actionManager.processTrigger(e.ActionManager.OnKeyDownTrigger,e.ActionEvent.CreateNewFromScene(a,t))},this._onKeyUp=function(t){a.actionManager&&a.actionManager.processTrigger(e.ActionManager.OnKeyUpTrigger,e.ActionEvent.CreateNewFromScene(a,t))};var c=e.Tools.GetPointerPrefix();s&&(this._engine.getRenderingCanvas().addEventListener(c+"move",this._onPointerMove,!1),this._engine.getRenderingCanvas().addEventListener("mousewheel",this._onPointerMove,!1),this._engine.getRenderingCanvas().addEventListener("DOMMouseScroll",this._onPointerMove,!1)),o&&this._engine.getRenderingCanvas().addEventListener(c+"down",this._onPointerDown,!1),i&&this._engine.getRenderingCanvas().addEventListener(c+"up",this._onPointerUp,!1),e.Tools.RegisterTopRootEvents([{name:"keydown",handler:this._onKeyDown},{name:"keyup",handler:this._onKeyUp}])},i.prototype.detachControl=function(){var t=e.Tools.GetPointerPrefix();this._engine.getRenderingCanvas().removeEventListener(t+"move",this._onPointerMove),this._engine.getRenderingCanvas().removeEventListener(t+"down",this._onPointerDown),this._engine.getRenderingCanvas().removeEventListener(t+"up",this._onPointerUp),this._engine.getRenderingCanvas().removeEventListener("mousewheel",this._onPointerMove),this._engine.getRenderingCanvas().removeEventListener("DOMMouseScroll",this._onPointerMove),e.Tools.UnregisterTopRootEvents([{name:"keydown",handler:this._onKeyDown},{name:"keyup",handler:this._onKeyUp}])},i.prototype.isReady=function(){if(this._pendingData.length>0)return!1;var t;for(t=0;t<this._geometries.length;t++){var i=this._geometries[t];if(i.delayLoadState===e.Engine.DELAYLOADSTATE_LOADING)return!1}for(t=0;t<this.meshes.length;t++){var r=this.meshes[t];if(!r.isReady())return!1;var n=r.material;if(n&&!n.isReady(r))return!1}return!0},i.prototype.resetCachedMaterial=function(){this._cachedMaterial=null},i.prototype.registerBeforeRender=function(e){this.onBeforeRenderObservable.add(e)},i.prototype.unregisterBeforeRender=function(e){this.onBeforeRenderObservable.removeCallback(e)},i.prototype.registerAfterRender=function(e){this.onAfterRenderObservable.add(e)},i.prototype.unregisterAfterRender=function(e){this.onAfterRenderObservable.removeCallback(e)},i.prototype._addPendingData=function(e){this._pendingData.push(e)},i.prototype._removePendingData=function(e){var t=this._pendingData.indexOf(e);-1!==t&&this._pendingData.splice(t,1)},i.prototype.getWaitingItemsCount=function(){return this._pendingData.length},i.prototype.executeWhenReady=function(e){var t=this;this.onReadyObservable.add(e),-1===this._executeWhenReadyTimeoutId&&(this._executeWhenReadyTimeoutId=setTimeout(function(){t._checkIsReady()},150))},i.prototype._checkIsReady=function(){var e=this;return this.isReady()?(this.onReadyObservable.notifyObservers(this),this.onReadyObservable.clear(),void(this._executeWhenReadyTimeoutId=-1)):void(this._executeWhenReadyTimeoutId=setTimeout(function(){e._checkIsReady()},150))},i.prototype.beginAnimation=function(t,i,r,n,o,s,a){if(void 0===o&&(o=1),this.stopAnimation(t),a||(a=new e.Animatable(this,t,i,r,n,o,s)),t.animations&&a.appendAnimations(t,t.animations),t.getAnimatables)for(var h=t.getAnimatables(),c=0;c<h.length;c++)this.beginAnimation(h[c],i,r,n,o,s,a);return a.reset(),a},i.prototype.beginDirectAnimation=function(t,i,r,n,o,s,a){void 0===s&&(s=1);var h=new e.Animatable(this,t,r,n,o,s,a,i);return h},i.prototype.getAnimatableByTarget=function(e){for(var t=0;t<this._activeAnimatables.length;t++)if(this._activeAnimatables[t].target===e)return this._activeAnimatables[t];return null},Object.defineProperty(i.prototype,"Animatables",{get:function(){return this._activeAnimatables},enumerable:!0,configurable:!0}),i.prototype.stopAnimation=function(e){var t=this.getAnimatableByTarget(e);t&&t.stop()},i.prototype._animate=function(){if(this.animationsEnabled&&0!==this._activeAnimatables.length){if(!this._animationStartDate){if(this._pendingData.length>0)return;this._animationStartDate=e.Tools.Now}for(var t=e.Tools.Now,i=t-this._animationStartDate,r=0;r<this._activeAnimatables.length;r++)this._activeAnimatables[r]._animate(i)}},i.prototype.getViewMatrix=function(){return this._viewMatrix},i.prototype.getProjectionMatrix=function(){return this._projectionMatrix},i.prototype.getTransformMatrix=function(){return this._transformMatrix},i.prototype.setTransformMatrix=function(e,t){this._viewMatrix=e,this._projectionMatrix=t,this._viewMatrix.multiplyToRef(this._projectionMatrix,this._transformMatrix)},i.prototype.addMesh=function(e){e.uniqueId=this._uniqueIdCounter++;this.meshes.push(e);this.collisionCoordinator.onMeshAdded(e),this.onNewMeshAddedObservable.notifyObservers(e)},i.prototype.removeMesh=function(e){var t=this.meshes.indexOf(e);return-1!==t&&this.meshes.splice(t,1),this.collisionCoordinator.onMeshRemoved(e),this.onMeshRemovedObservable.notifyObservers(e),t},i.prototype.removeSkeleton=function(e){var t=this.skeletons.indexOf(e);return-1!==t&&this.skeletons.splice(t,1),t},i.prototype.removeLight=function(e){var t=this.lights.indexOf(e);return-1!==t&&this.lights.splice(t,1),this.onLightRemovedObservable.notifyObservers(e),t},i.prototype.removeCamera=function(e){var t=this.cameras.indexOf(e);-1!==t&&this.cameras.splice(t,1);var i=this.activeCameras.indexOf(e);return-1!==i&&this.activeCameras.splice(i,1),this.activeCamera===e&&(this.cameras.length>0?this.activeCamera=this.cameras[0]:this.activeCamera=null),this.onCameraRemovedObservable.notifyObservers(e),t},i.prototype.addLight=function(e){e.uniqueId=this._uniqueIdCounter++;this.lights.push(e);this.onNewLightAddedObservable.notifyObservers(e)},i.prototype.addCamera=function(e){e.uniqueId=this._uniqueIdCounter++;this.cameras.push(e);this.onNewCameraAddedObservable.notifyObservers(e)},i.prototype.swithActiveCamera=function(e,t){void 0===t&&(t=!0);var i=this._engine.getRenderingCanvas();this.activeCamera.detachControl(i),this.activeCamera=e,t&&e.attachControl(i)},i.prototype.setActiveCameraByID=function(e){var t=this.getCameraByID(e);return t?(this.activeCamera=t,t):null},i.prototype.setActiveCameraByName=function(e){var t=this.getCameraByName(e);return t?(this.activeCamera=t,t):null},i.prototype.getMaterialByID=function(e){for(var t=0;t<this.materials.length;t++)if(this.materials[t].id===e)return this.materials[t];return null},i.prototype.getMaterialByName=function(e){for(var t=0;t<this.materials.length;t++)if(this.materials[t].name===e)return this.materials[t];return null},i.prototype.getLensFlareSystemByName=function(e){for(var t=0;t<this.lensFlareSystems.length;t++)if(this.lensFlareSystems[t].name===e)return this.lensFlareSystems[t];return null},i.prototype.getLensFlareSystemByID=function(e){for(var t=0;t<this.lensFlareSystems.length;t++)if(this.lensFlareSystems[t].id===e)return this.lensFlareSystems[t];return null},i.prototype.getCameraByID=function(e){for(var t=0;t<this.cameras.length;t++)if(this.cameras[t].id===e)return this.cameras[t];return null},i.prototype.getCameraByUniqueID=function(e){for(var t=0;t<this.cameras.length;t++)if(this.cameras[t].uniqueId===e)return this.cameras[t];return null},i.prototype.getCameraByName=function(e){for(var t=0;t<this.cameras.length;t++)if(this.cameras[t].name===e)return this.cameras[t];return null},i.prototype.getBoneByID=function(e){for(var t=0;t<this.skeletons.length;t++)for(var i=this.skeletons[t],r=0;r<i.bones.length;r++)if(i.bones[r].id===e)return i.bones[r];return null},i.prototype.getBoneByName=function(e){for(var t=0;t<this.skeletons.length;t++)for(var i=this.skeletons[t],r=0;r<i.bones.length;r++)if(i.bones[r].name===e)return i.bones[r];return null},i.prototype.getLightByName=function(e){for(var t=0;t<this.lights.length;t++)if(this.lights[t].name===e)return this.lights[t];return null},i.prototype.getLightByID=function(e){for(var t=0;t<this.lights.length;t++)if(this.lights[t].id===e)return this.lights[t];return null},i.prototype.getLightByUniqueID=function(e){for(var t=0;t<this.lights.length;t++)if(this.lights[t].uniqueId===e)return this.lights[t];return null},i.prototype.getParticleSystemByID=function(e){for(var t=0;t<this.particleSystems.length;t++)if(this.particleSystems[t].id===e)return this.particleSystems[t];return null},i.prototype.getGeometryByID=function(e){for(var t=0;t<this._geometries.length;t++)if(this._geometries[t].id===e)return this._geometries[t];return null},i.prototype.pushGeometry=function(e,t){return!t&&this.getGeometryByID(e.id)?!1:(this._geometries.push(e),this.collisionCoordinator.onGeometryAdded(e),this.onNewGeometryAddedObservable.notifyObservers(e),!0)},i.prototype.removeGeometry=function(e){var t=this._geometries.indexOf(e);return t>-1?(this._geometries.splice(t,1),this.collisionCoordinator.onGeometryDeleted(e),this.onGeometryRemovedObservable.notifyObservers(e),!0):!1},i.prototype.getGeometries=function(){return this._geometries},i.prototype.getMeshByID=function(e){for(var t=0;t<this.meshes.length;t++)if(this.meshes[t].id===e)return this.meshes[t];return null},i.prototype.getMeshesByID=function(e){return this.meshes.filter(function(t){return t.id===e})},i.prototype.getMeshByUniqueID=function(e){for(var t=0;t<this.meshes.length;t++)if(this.meshes[t].uniqueId===e)return this.meshes[t];return null},i.prototype.getLastMeshByID=function(e){for(var t=this.meshes.length-1;t>=0;t--)if(this.meshes[t].id===e)return this.meshes[t];return null},i.prototype.getLastEntryByID=function(e){var t;for(t=this.meshes.length-1;t>=0;t--)if(this.meshes[t].id===e)return this.meshes[t];for(t=this.cameras.length-1;t>=0;t--)if(this.cameras[t].id===e)return this.cameras[t];for(t=this.lights.length-1;t>=0;t--)if(this.lights[t].id===e)return this.lights[t];return null},i.prototype.getNodeByID=function(e){var t=this.getMeshByID(e);if(t)return t;var i=this.getLightByID(e);if(i)return i;var r=this.getCameraByID(e);if(r)return r;var n=this.getBoneByID(e);return n},i.prototype.getNodeByName=function(e){var t=this.getMeshByName(e);if(t)return t;var i=this.getLightByName(e);if(i)return i;var r=this.getCameraByName(e);if(r)return r;var n=this.getBoneByName(e);return n},i.prototype.getMeshByName=function(e){for(var t=0;t<this.meshes.length;t++)if(this.meshes[t].name===e)return this.meshes[t];return null},i.prototype.getSoundByName=function(t){var i;if(e.AudioEngine){for(i=0;i<this.mainSoundTrack.soundCollection.length;i++)if(this.mainSoundTrack.soundCollection[i].name===t)return this.mainSoundTrack.soundCollection[i];for(var r=0;r<this.soundTracks.length;r++)for(i=0;i<this.soundTracks[r].soundCollection.length;i++)if(this.soundTracks[r].soundCollection[i].name===t)return this.soundTracks[r].soundCollection[i]}return null},i.prototype.getLastSkeletonByID=function(e){for(var t=this.skeletons.length-1;t>=0;t--)if(this.skeletons[t].id===e)return this.skeletons[t];return null},i.prototype.getSkeletonById=function(e){for(var t=0;t<this.skeletons.length;t++)if(this.skeletons[t].id===e)return this.skeletons[t];return null},i.prototype.getSkeletonByName=function(e){for(var t=0;t<this.skeletons.length;t++)if(this.skeletons[t].name===e)return this.skeletons[t];return null},i.prototype.isActiveMesh=function(e){return-1!==this._activeMeshes.indexOf(e)},i.prototype._evaluateSubMesh=function(e,t){if(t.alwaysSelectAsActiveMesh||1===t.subMeshes.length||e.isInFrustum(this._frustumPlanes)){var i=e.getMaterial();t.showSubMeshesBoundingBox&&this._boundingBoxRenderer.renderList.push(e.getBoundingInfo().boundingBox),i&&(i.getRenderTargetTextures&&-1===this._processedMaterials.indexOf(i)&&(this._processedMaterials.push(i),this._renderTargets.concatWithNoDuplicate(i.getRenderTargetTextures())),this._activeIndices+=e.indexCount,this._renderingManager.dispatch(e))}},i.prototype._isInIntermediateRendering=function(){return this._intermediateRendering},i.prototype._evaluateActiveMeshes=function(){this.activeCamera._activeMeshes.reset(),this._activeMeshes.reset(),this._renderingManager.reset(),this._processedMaterials.reset(),this._activeParticleSystems.reset(),this._activeSkeletons.reset(),this._softwareSkinnedMeshes.reset(),this._boundingBoxRenderer.reset(),this._edgesRenderers.reset(),this._frustumPlanes?e.Frustum.GetPlanesToRef(this._transformMatrix,this._frustumPlanes):this._frustumPlanes=e.Frustum.GetPlanes(this._transformMatrix);var t,i;if(this._selectionOctree){var r=this._selectionOctree.select(this._frustumPlanes);t=r.data,i=r.length}else i=this.meshes.length,t=this.meshes;for(var n=0;i>n;n++){var o=t[n];if(!o.isBlocked&&(this._totalVertices+=o.getTotalVertices(),o.isReady()&&o.isEnabled())){o.computeWorldMatrix(),o.actionManager&&o.actionManager.hasSpecificTriggers([e.ActionManager.OnIntersectionEnterTrigger,e.ActionManager.OnIntersectionExitTrigger])&&this._meshesForIntersections.pushNoDuplicate(o);var s=o.getLOD(this.activeCamera);s&&(o._preActivate(),(o.alwaysSelectAsActiveMesh||o.isVisible&&o.visibility>0&&0!==(o.layerMask&this.activeCamera.layerMask)&&o.isInFrustum(this._frustumPlanes))&&(this._activeMeshes.push(o),this.activeCamera._activeMeshes.push(o),o._activate(this._renderId),this._activeMesh(s)))}}var a=e.Tools.Now;if(this.particlesEnabled){e.Tools.StartPerformanceCounter("Particles",this.particleSystems.length>0);for(var h=0;h<this.particleSystems.length;h++){var c=this.particleSystems[h];c.isStarted()&&(!c.emitter.position||c.emitter&&c.emitter.isEnabled())&&(this._activeParticleSystems.push(c),
  11. c.animate())}e.Tools.EndPerformanceCounter("Particles",this.particleSystems.length>0)}this._particlesDuration+=e.Tools.Now-a},i.prototype._activeMesh=function(e){if(e.skeleton&&this.skeletonsEnabled&&(this._activeSkeletons.pushNoDuplicate(e.skeleton)&&e.skeleton.prepare(),e.computeBonesUsingShaders||this._softwareSkinnedMeshes.pushNoDuplicate(e)),(e.showBoundingBox||this.forceShowBoundingBoxes)&&this._boundingBoxRenderer.renderList.push(e.getBoundingInfo().boundingBox),e._edgesRenderer&&this._edgesRenderers.push(e._edgesRenderer),e&&e.subMeshes){var t,i;if(e._submeshesOctree&&e.useOctreeForRenderingSelection){var r=e._submeshesOctree.select(this._frustumPlanes);t=r.length,i=r.data}else i=e.subMeshes,t=i.length;for(var n=0;t>n;n++){var o=i[n];this._evaluateSubMesh(o,e)}}},i.prototype.updateTransformMatrix=function(e){this.setTransformMatrix(this.activeCamera.getViewMatrix(),this.activeCamera.getProjectionMatrix(e))},i.prototype._renderForCamera=function(t){var i=this._engine;if(this.activeCamera=t,!this.activeCamera)throw new Error("Active camera not set");e.Tools.StartPerformanceCounter("Rendering camera "+this.activeCamera.name),i.setViewport(this.activeCamera.viewport),this.resetCachedMaterial(),this._renderId++,this.updateTransformMatrix(),this.onBeforeCameraRenderObservable.notifyObservers(this.activeCamera);var r=e.Tools.Now;e.Tools.StartPerformanceCounter("Active meshes evaluation"),this._evaluateActiveMeshes(),this._evaluateActiveMeshesDuration+=e.Tools.Now-r,e.Tools.EndPerformanceCounter("Active meshes evaluation");for(var n=0;n<this._softwareSkinnedMeshes.length;n++){var o=this._softwareSkinnedMeshes.data[n];o.applySkeleton(o.skeleton)}var s=e.Tools.Now;if(this.renderTargetsEnabled&&this._renderTargets.length>0){this._intermediateRendering=!0,e.Tools.StartPerformanceCounter("Render targets",this._renderTargets.length>0);for(var a=0;a<this._renderTargets.length;a++){var h=this._renderTargets.data[a];if(h._shouldRender()){this._renderId++;var c=h.activeCamera&&h.activeCamera!==this.activeCamera;h.render(c,this.dumpNextRenderTargets)}}e.Tools.EndPerformanceCounter("Render targets",this._renderTargets.length>0),this._intermediateRendering=!1,this._renderId++,i.restoreDefaultFramebuffer()}this._renderTargetsDuration+=e.Tools.Now-s,this.postProcessManager._prepareFrame();var l,u,f=e.Tools.Now;if(this.layers.length){for(i.setDepthBuffer(!1),l=0;l<this.layers.length;l++)u=this.layers[l],u.isBackground&&u.render();i.setDepthBuffer(!0)}e.Tools.StartPerformanceCounter("Main render"),this._renderingManager.render(null,null,!0,!0),e.Tools.EndPerformanceCounter("Main render"),this._boundingBoxRenderer.render();for(var d=0;d<this._edgesRenderers.length;d++)this._edgesRenderers.data[d].render();if(this.lensFlaresEnabled){e.Tools.StartPerformanceCounter("Lens flares",this.lensFlareSystems.length>0);for(var p=0;p<this.lensFlareSystems.length;p++){var _=this.lensFlareSystems[p];0!==(t.layerMask&_.layerMask)&&_.render()}e.Tools.EndPerformanceCounter("Lens flares",this.lensFlareSystems.length>0)}if(this.layers.length){for(i.setDepthBuffer(!1),l=0;l<this.layers.length;l++)u=this.layers[l],u.isBackground||u.render();i.setDepthBuffer(!0)}this._renderDuration+=e.Tools.Now-f,this.postProcessManager._finalizeFrame(t.isIntermediate),this.activeCamera._updateFromScene(),this._renderTargets.reset(),this.onAfterCameraRenderObservable.notifyObservers(this.activeCamera),e.Tools.EndPerformanceCounter("Rendering camera "+this.activeCamera.name)},i.prototype._processSubCameras=function(t){if(t.cameraRigMode===e.Camera.RIG_MODE_NONE)return void this._renderForCamera(t);for(var i=0;i<t._rigCameras.length;i++)this._renderForCamera(t._rigCameras[i]);this.activeCamera=t,this.setTransformMatrix(this.activeCamera.getViewMatrix(),this.activeCamera.getProjectionMatrix()),this.activeCamera._updateFromScene()},i.prototype._checkIntersections=function(){for(var t=0;t<this._meshesForIntersections.length;t++)for(var i=this._meshesForIntersections.data[t],r=0;r<i.actionManager.actions.length;r++){var n=i.actionManager.actions[r];if(n.trigger===e.ActionManager.OnIntersectionEnterTrigger||n.trigger===e.ActionManager.OnIntersectionExitTrigger){var o=n.getTriggerParameter(),s=o instanceof e.AbstractMesh?o:o.mesh,a=s.intersectsMesh(i,o.usePreciseIntersection),h=i._intersectionsInProgress.indexOf(s);a&&-1===h?n.trigger===e.ActionManager.OnIntersectionEnterTrigger?(n._executeCurrent(e.ActionEvent.CreateNew(i,null,s)),i._intersectionsInProgress.push(s)):n.trigger===e.ActionManager.OnIntersectionExitTrigger&&i._intersectionsInProgress.push(s):!a&&h>-1&&(n.trigger===e.ActionManager.OnIntersectionExitTrigger&&n._executeCurrent(e.ActionEvent.CreateNew(i,null,s)),i.actionManager.hasSpecificTrigger(e.ActionManager.OnIntersectionExitTrigger)&&n.trigger!==e.ActionManager.OnIntersectionExitTrigger||i._intersectionsInProgress.splice(h,1))}}},i.prototype.render=function(){var t=e.Tools.Now;this._particlesDuration=0,this._spritesDuration=0,this._activeParticles=0,this._renderDuration=0,this._renderTargetsDuration=0,this._evaluateActiveMeshesDuration=0,this._totalVertices=0,this._activeIndices=0,this._activeBones=0,this.getEngine().resetDrawCalls(),this._meshesForIntersections.reset(),this.resetCachedMaterial(),e.Tools.StartPerformanceCounter("Scene rendering"),this.actionManager&&this.actionManager.processTrigger(e.ActionManager.OnEveryFrameTrigger,null),this.simplificationQueue&&!this.simplificationQueue.running&&this.simplificationQueue.executeNext();var r=Math.max(i.MinDeltaTime,Math.min(this._engine.getDeltaTime(),i.MaxDeltaTime));this._animationRatio=.06*r,this._animate(),this._physicsEngine&&(e.Tools.StartPerformanceCounter("Physics"),this._physicsEngine._step(r/1e3),e.Tools.EndPerformanceCounter("Physics")),this.onBeforeRenderObservable.notifyObservers(this);var n=e.Tools.Now,o=this.getEngine(),s=this.activeCamera;if(this.renderTargetsEnabled){e.Tools.StartPerformanceCounter("Custom render targets",this.customRenderTargets.length>0);for(var a=0;a<this.customRenderTargets.length;a++){var h=this.customRenderTargets[a];if(h._shouldRender()){if(this._renderId++,this.activeCamera=h.activeCamera||this.activeCamera,!this.activeCamera)throw new Error("Active camera not set");o.setViewport(this.activeCamera.viewport),this.updateTransformMatrix(),h.render(s!==this.activeCamera,this.dumpNextRenderTargets)}}e.Tools.EndPerformanceCounter("Custom render targets",this.customRenderTargets.length>0),this._renderId++}if(this.customRenderTargets.length>0&&o.restoreDefaultFramebuffer(),this._renderTargetsDuration+=e.Tools.Now-n,this.activeCamera=s,this.proceduralTexturesEnabled){e.Tools.StartPerformanceCounter("Procedural textures",this._proceduralTextures.length>0);for(var c=0;c<this._proceduralTextures.length;c++){var l=this._proceduralTextures[c];l._shouldRender()&&l.render()}e.Tools.EndPerformanceCounter("Procedural textures",this._proceduralTextures.length>0)}if(this._engine.clear(this.clearColor,this.autoClear||this.forceWireframe||this.forcePointsCloud,!0),this.shadowsEnabled)for(var u=0;u<this.lights.length;u++){var f=this.lights[u],d=f.getShadowGenerator();f.isEnabled()&&d&&-1!==d.getShadowMap().getScene().textures.indexOf(d.getShadowMap())&&this._renderTargets.push(d.getShadowMap())}if(this._depthRenderer&&this._renderTargets.push(this._depthRenderer.getDepthMap()),this.postProcessRenderPipelineManager.update(),this.activeCameras.length>0)for(var p=this._renderId,_=0;_<this.activeCameras.length;_++)this._renderId=p,_>0&&this._engine.clear(0,!1,!0),this._processSubCameras(this.activeCameras[_]);else{if(!this.activeCamera)throw new Error("No camera defined");this._processSubCameras(this.activeCamera)}this._checkIntersections(),e.AudioEngine&&this._updateAudioParameters(),this.afterRender&&this.afterRender(),this.onAfterRenderObservable.notifyObservers(this);for(var m=0;m<this._toBeDisposed.length;m++)this._toBeDisposed.data[m].dispose(),this._toBeDisposed[m]=null;this._toBeDisposed.reset(),this.dumpNextRenderTargets&&(this.dumpNextRenderTargets=!1),e.Tools.EndPerformanceCounter("Scene rendering"),this._lastFrameDuration=e.Tools.Now-t},i.prototype._updateAudioParameters=function(){if(this.audioEnabled&&(0!==this.mainSoundTrack.soundCollection.length||1!==this.soundTracks.length)){var t,i=e.Engine.audioEngine;if(t=this.activeCameras.length>0?this.activeCameras[0]:this.activeCamera,t&&i.canUseWebAudio){i.audioContext.listener.setPosition(t.position.x,t.position.y,t.position.z);var r=e.Matrix.Invert(t.getViewMatrix()),n=e.Vector3.TransformNormal(new e.Vector3(0,0,-1),r);n.normalize(),i.audioContext.listener.setOrientation(n.x,n.y,n.z,0,1,0);var o;for(o=0;o<this.mainSoundTrack.soundCollection.length;o++){var s=this.mainSoundTrack.soundCollection[o];s.useCustomAttenuation&&s.updateDistanceFromListener()}for(o=0;o<this.soundTracks.length;o++)for(var a=0;a<this.soundTracks[o].soundCollection.length;a++)s=this.soundTracks[o].soundCollection[a],s.useCustomAttenuation&&s.updateDistanceFromListener()}}},Object.defineProperty(i.prototype,"audioEnabled",{get:function(){return this._audioEnabled},set:function(t){this._audioEnabled=t,e.AudioEngine&&(this._audioEnabled?this._enableAudio():this._disableAudio())},enumerable:!0,configurable:!0}),i.prototype._disableAudio=function(){var e;for(e=0;e<this.mainSoundTrack.soundCollection.length;e++)this.mainSoundTrack.soundCollection[e].pause();for(e=0;e<this.soundTracks.length;e++)for(var t=0;t<this.soundTracks[e].soundCollection.length;t++)this.soundTracks[e].soundCollection[t].pause()},i.prototype._enableAudio=function(){var e;for(e=0;e<this.mainSoundTrack.soundCollection.length;e++)this.mainSoundTrack.soundCollection[e].isPaused&&this.mainSoundTrack.soundCollection[e].play();for(e=0;e<this.soundTracks.length;e++)for(var t=0;t<this.soundTracks[e].soundCollection.length;t++)this.soundTracks[e].soundCollection[t].isPaused&&this.soundTracks[e].soundCollection[t].play()},Object.defineProperty(i.prototype,"headphone",{get:function(){return this._headphone},set:function(t){this._headphone=t,e.AudioEngine&&(this._headphone?this._switchAudioModeForHeadphones():this._switchAudioModeForNormalSpeakers())},enumerable:!0,configurable:!0}),i.prototype._switchAudioModeForHeadphones=function(){this.mainSoundTrack.switchPanningModelToHRTF();for(var e=0;e<this.soundTracks.length;e++)this.soundTracks[e].switchPanningModelToHRTF()},i.prototype._switchAudioModeForNormalSpeakers=function(){this.mainSoundTrack.switchPanningModelToEqualPower();for(var e=0;e<this.soundTracks.length;e++)this.soundTracks[e].switchPanningModelToEqualPower()},i.prototype.enableDepthRenderer=function(){return this._depthRenderer?this._depthRenderer:(this._depthRenderer=new e.DepthRenderer(this),this._depthRenderer)},i.prototype.disableDepthRenderer=function(){this._depthRenderer&&(this._depthRenderer.dispose(),this._depthRenderer=null)},i.prototype.freezeMaterials=function(){for(var e=0;e<this.materials.length;e++)this.materials[e].freeze()},i.prototype.unfreezeMaterials=function(){for(var e=0;e<this.materials.length;e++)this.materials[e].unfreeze()},i.prototype.dispose=function(){this.beforeRender=null,this.afterRender=null,this.skeletons=[],this._boundingBoxRenderer.dispose(),this._depthRenderer&&this._depthRenderer.dispose(),this._debugLayer&&this._debugLayer.hide(),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this.onBeforeRenderObservable.clear(),this.onAfterRenderObservable.clear(),this.detachControl(),e.AudioEngine&&this.disposeSounds();var t,i=this._engine.getRenderingCanvas();for(t=0;t<this.cameras.length;t++)this.cameras[t].detachControl(i);for(;this.lights.length;)this.lights[0].dispose();for(;this.meshes.length;)this.meshes[0].dispose(!0);for(;this.cameras.length;)this.cameras[0].dispose();for(;this.materials.length;)this.materials[0].dispose();for(;this.particleSystems.length;)this.particleSystems[0].dispose();for(;this.spriteManagers.length;)this.spriteManagers[0].dispose();for(;this.layers.length;)this.layers[0].dispose();for(;this.textures.length;)this.textures[0].dispose();this.postProcessManager.dispose(),this._physicsEngine&&this.disablePhysicsEngine(),t=this._engine.scenes.indexOf(this),t>-1&&this._engine.scenes.splice(t,1),this._engine.wipeCaches()},i.prototype.disposeSounds=function(){this.mainSoundTrack.dispose();for(var e=0;e<this.soundTracks.length;e++)this.soundTracks[e].dispose()},i.prototype.getWorldExtends=function(){for(var t=new e.Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),i=new e.Vector3(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),r=0;r<this.meshes.length;r++){var n=this.meshes[r];n.computeWorldMatrix(!0);var o=n.getBoundingInfo().boundingBox.minimumWorld,s=n.getBoundingInfo().boundingBox.maximumWorld;e.Tools.CheckExtends(o,t,i),e.Tools.CheckExtends(s,t,i)}return{min:t,max:i}},i.prototype.createOrUpdateSelectionOctree=function(t,i){void 0===t&&(t=64),void 0===i&&(i=2),this._selectionOctree||(this._selectionOctree=new e.Octree(e.Octree.CreationFuncForMeshes,t,i));var r=this.getWorldExtends();return this._selectionOctree.update(r.min,r.max,this.meshes),this._selectionOctree},i.prototype.createPickingRay=function(t,i,r,n,o){void 0===o&&(o=!1);var s=this._engine;if(!n){if(!this.activeCamera)throw new Error("Active camera not set");n=this.activeCamera}var a=n.viewport,h=a.toGlobal(s.getRenderWidth(),s.getRenderHeight());return t=t/this._engine.getHardwareScalingLevel()-h.x,i=i/this._engine.getHardwareScalingLevel()-(this._engine.getRenderHeight()-h.y-h.height),e.Ray.CreateNew(t,i,h.width,h.height,r?r:e.Matrix.Identity(),o?e.Matrix.Identity():n.getViewMatrix(),n.getProjectionMatrix())},i.prototype.createPickingRayInCameraSpace=function(t,i,r){var n=this._engine;if(!r){if(!this.activeCamera)throw new Error("Active camera not set");r=this.activeCamera}var o=r.viewport,s=o.toGlobal(n.getRenderWidth(),n.getRenderHeight()),a=e.Matrix.Identity();return t=t/this._engine.getHardwareScalingLevel()-s.x,i=i/this._engine.getHardwareScalingLevel()-(this._engine.getRenderHeight()-s.y-s.height),e.Ray.CreateNew(t,i,s.width,s.height,a,a,r.getProjectionMatrix())},i.prototype._internalPick=function(t,i,r){for(var n=null,o=0;o<this.meshes.length;o++){var s=this.meshes[o];if(i){if(!i(s))continue}else if(!s.isEnabled()||!s.isVisible||!s.isPickable)continue;var a=s.getWorldMatrix(),h=t(a),c=s.intersects(h,r);if(c&&c.hit&&(r||null==n||!(c.distance>=n.distance))&&(n=c,r))break}return n||new e.PickingInfo},i.prototype._internalPickSprites=function(t,i,r,n){var o=null;if(n=n||this.activeCamera,this.spriteManagers.length>0)for(var s=0;s<this.spriteManagers.length;s++){var a=this.spriteManagers[s];if(a.isPickable){var h=a.intersects(t,n,i,r);if(h&&h.hit&&(r||null==o||!(h.distance>=o.distance))&&(o=h,r))break}}return o||new e.PickingInfo},i.prototype.pick=function(e,t,i,r,n){var o=this;return this._internalPick(function(i){return o.createPickingRay(e,t,i,n)},i,r)},i.prototype.pickSprite=function(e,t,i,r,n){return this._internalPickSprites(this.createPickingRayInCameraSpace(e,t,n),i,r,n)},i.prototype.pickWithRay=function(t,i,r){var n=this;return this._internalPick(function(i){return n._pickWithRayInverseMatrix||(n._pickWithRayInverseMatrix=e.Matrix.Identity()),i.invertToRef(n._pickWithRayInverseMatrix),e.Ray.Transform(t,n._pickWithRayInverseMatrix)},i,r)},i.prototype.setPointerOverMesh=function(t){this._pointerOverMesh!==t&&(this._pointerOverMesh&&this._pointerOverMesh.actionManager&&this._pointerOverMesh.actionManager.processTrigger(e.ActionManager.OnPointerOutTrigger,e.ActionEvent.CreateNew(this._pointerOverMesh)),this._pointerOverMesh=t,this._pointerOverMesh&&this._pointerOverMesh.actionManager&&this._pointerOverMesh.actionManager.processTrigger(e.ActionManager.OnPointerOverTrigger,e.ActionEvent.CreateNew(this._pointerOverMesh)))},i.prototype.getPointerOverMesh=function(){return this._pointerOverMesh},i.prototype.setPointerOverSprite=function(t){this._pointerOverSprite!==t&&(this._pointerOverSprite&&this._pointerOverSprite.actionManager&&this._pointerOverSprite.actionManager.processTrigger(e.ActionManager.OnPointerOutTrigger,e.ActionEvent.CreateNewFromSprite(this._pointerOverSprite,this)),this._pointerOverSprite=t,this._pointerOverSprite&&this._pointerOverSprite.actionManager&&this._pointerOverSprite.actionManager.processTrigger(e.ActionManager.OnPointerOverTrigger,e.ActionEvent.CreateNewFromSprite(this._pointerOverSprite,this)))},i.prototype.getPointerOverSprite=function(){return this._pointerOverSprite},i.prototype.getPhysicsEngine=function(){return this._physicsEngine},i.prototype.enablePhysics=function(t,i){if(this._physicsEngine)return!0;try{return this._physicsEngine=new e.PhysicsEngine(t,i),!0}catch(r){return e.Tools.Error(r.message),!1}},i.prototype.disablePhysicsEngine=function(){this._physicsEngine&&(this._physicsEngine.dispose(),this._physicsEngine=void 0)},i.prototype.isPhysicsEnabled=function(){return void 0!==this._physicsEngine},i.prototype.setGravity=function(t){e.Tools.Warn("Deprecated, please use 'scene.getPhysicsEngine().setGravity()'"),this._physicsEngine&&this._physicsEngine.setGravity(t)},i.prototype.createCompoundImpostor=function(t,i){e.Tools.Warn("Scene.createCompoundImpostor is deprecated. Please use PhysicsImpostor parent/child"),t.parts&&(i=t,t=t.parts);var r=t[0].mesh;r.physicsImpostor=new e.PhysicsImpostor(r,t[0].impostor,i,this);for(var n=1;n<t.length;n++){var o=t[n].mesh;o.parent!==r&&(o.position=o.position.subtract(r.position),o.parent=r),o.physicsImpostor=new e.PhysicsImpostor(o,t[n].impostor,i,this)}r.physicsImpostor.forceUpdate()},i.prototype.deleteCompoundImpostor=function(e){var t=e.parts[0].mesh;t.physicsImpostor.dispose(),t.physicsImpostor=null},i.prototype.createDefaultCameraOrLight=function(){if(0===this.lights.length&&new e.HemisphericLight("default light",e.Vector3.Up(),this),!this.activeCamera){var t=new e.FreeCamera("default camera",e.Vector3.Zero(),this),i=this.getWorldExtends(),r=i.min.add(i.max.subtract(i.min).scale(.5));t.position=new e.Vector3(r.x,r.y,i.min.z-(i.max.z-i.min.z)),t.setTarget(r),this.activeCamera=t}},i.prototype._getByTags=function(t,i,r){if(void 0===i)return t;var n=[];r=r||function(e){};for(var o in t){var s=t[o];e.Tags.MatchesQuery(s,i)&&(n.push(s),r(s))}return n},i.prototype.getMeshesByTags=function(e,t){return this._getByTags(this.meshes,e,t)},i.prototype.getCamerasByTags=function(e,t){return this._getByTags(this.cameras,e,t)},i.prototype.getLightsByTags=function(e,t){return this._getByTags(this.lights,e,t)},i.prototype.getMaterialByTags=function(e,t){return this._getByTags(this.materials,e,t).concat(this._getByTags(this.multiMaterials,e,t))},i._FOGMODE_NONE=0,i._FOGMODE_EXP=1,i._FOGMODE_EXP2=2,i._FOGMODE_LINEAR=3,i.MinDeltaTime=1,i.MaxDeltaTime=1e3,i}();e.Scene=o}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(t,i,r,n,o,s){t instanceof e.Mesh?this._engine=t.getScene().getEngine():this._engine=t,this._updatable=r,this._data=i,this._strideSize=n,o||this.create(),this._instanced=s}return t.prototype.createVertexBuffer=function(t,i,r,n){return new e.VertexBuffer(this._engine,this,t,this._updatable,!0,n?n:this._strideSize,this._instanced,i,r)},t.prototype.isUpdatable=function(){return this._updatable},t.prototype.getData=function(){return this._data},t.prototype.getBuffer=function(){return this._buffer},t.prototype.getStrideSize=function(){return this._strideSize},t.prototype.getIsInstanced=function(){return this._instanced},t.prototype.create=function(e){!e&&this._buffer||(e=e||this._data,this._buffer?this._updatable&&(this._engine.updateDynamicVertexBuffer(this._buffer,e),this._data=e):this._updatable?(this._buffer=this._engine.createDynamicVertexBuffer(e),this._data=e):this._buffer=this._engine.createVertexBuffer(e))},t.prototype.update=function(e){this.create(e)},t.prototype.updateDirectly=function(e,t,i){this._buffer&&this._updatable&&(this._engine.updateDynamicVertexBuffer(this._buffer,e,t,i?i*this.getStrideSize():void 0),this._data=null)},t.prototype.dispose=function(){this._buffer&&this._engine._releaseBuffer(this._buffer)&&(this._buffer=null)},t}();e.Buffer=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(i,r,n,o,s,a,h,c,l){if(!a)switch(n){case t.PositionKind:a=3;break;case t.NormalKind:a=3;break;case t.UVKind:case t.UV2Kind:case t.UV3Kind:case t.UV4Kind:case t.UV5Kind:case t.UV6Kind:a=2;break;case t.ColorKind:a=4;break;case t.MatricesIndicesKind:case t.MatricesIndicesExtraKind:a=4;break;case t.MatricesWeightsKind:case t.MatricesWeightsExtraKind:a=4}r instanceof e.Buffer?(a||(a=r.getStrideSize()),this._buffer=r,this._ownsBuffer=!1):(this._buffer=new e.Buffer(i,r,o,a,s,h),this._ownsBuffer=!0),this._stride=a,this._offset=c?c:0,this._size=l?l:a,this._kind=n}return t.prototype.getKind=function(){return this._kind},t.prototype.isUpdatable=function(){return this._buffer.isUpdatable()},t.prototype.getData=function(){return this._buffer.getData()},t.prototype.getBuffer=function(){return this._buffer.getBuffer()},t.prototype.getStrideSize=function(){return this._stride},t.prototype.getOffset=function(){return this._offset},t.prototype.getSize=function(){return this._size},t.prototype.getIsInstanced=function(){return this._buffer.getIsInstanced()},t.prototype.create=function(e){return this._buffer.create(e)},t.prototype.update=function(e){return this._buffer.update(e)},t.prototype.updateDirectly=function(e,t){return this._buffer.updateDirectly(e,t)},t.prototype.dispose=function(){this._ownsBuffer&&this._buffer.dispose()},Object.defineProperty(t,"PositionKind",{get:function(){return t._PositionKind},enumerable:!0,configurable:!0}),Object.defineProperty(t,"NormalKind",{get:function(){return t._NormalKind},enumerable:!0,configurable:!0}),Object.defineProperty(t,"UVKind",{get:function(){return t._UVKind},enumerable:!0,configurable:!0}),Object.defineProperty(t,"UV2Kind",{get:function(){return t._UV2Kind},enumerable:!0,configurable:!0}),Object.defineProperty(t,"UV3Kind",{get:function(){return t._UV3Kind},enumerable:!0,configurable:!0}),Object.defineProperty(t,"UV4Kind",{get:function(){return t._UV4Kind},enumerable:!0,configurable:!0}),Object.defineProperty(t,"UV5Kind",{get:function(){return t._UV5Kind},enumerable:!0,configurable:!0}),Object.defineProperty(t,"UV6Kind",{get:function(){return t._UV6Kind},enumerable:!0,configurable:!0}),Object.defineProperty(t,"ColorKind",{get:function(){return t._ColorKind},enumerable:!0,configurable:!0}),Object.defineProperty(t,"MatricesIndicesKind",{get:function(){return t._MatricesIndicesKind},enumerable:!0,configurable:!0}),Object.defineProperty(t,"MatricesWeightsKind",{get:function(){return t._MatricesWeightsKind},enumerable:!0,configurable:!0}),Object.defineProperty(t,"MatricesIndicesExtraKind",{get:function(){return t._MatricesIndicesExtraKind},enumerable:!0,configurable:!0}),Object.defineProperty(t,"MatricesWeightsExtraKind",{get:function(){return t._MatricesWeightsExtraKind},enumerable:!0,configurable:!0}),t._PositionKind="position",t._NormalKind="normal",t._UVKind="uv",t._UV2Kind="uv2",t._UV3Kind="uv3",t._UV4Kind="uv4",t._UV5Kind="uv5",t._UV6Kind="uv6",t._ColorKind="color",t._MatricesIndicesKind="matricesIndices",t._MatricesWeightsKind="matricesWeights",t._MatricesIndicesExtraKind="matricesIndicesExtra",t._MatricesWeightsExtraKind="matricesWeightsExtra",t}();e.VertexBuffer=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(t){function i(e,i){t.call(this,e,i.getScene()),i.instances.push(this),this._sourceMesh=i,this.position.copyFrom(i.position),this.rotation.copyFrom(i.rotation),this.scaling.copyFrom(i.scaling),i.rotationQuaternion&&(this.rotationQuaternion=i.rotationQuaternion.clone()),this.infiniteDistance=i.infiniteDistance,this.setPivotMatrix(i.getPivotMatrix()),this.refreshBoundingInfo(),this._syncSubMeshes()}return __extends(i,t),Object.defineProperty(i.prototype,"receiveShadows",{get:function(){return this._sourceMesh.receiveShadows},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"material",{get:function(){return this._sourceMesh.material},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"visibility",{get:function(){return this._sourceMesh.visibility},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"skeleton",{get:function(){return this._sourceMesh.skeleton},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"renderingGroupId",{get:function(){return this._sourceMesh.renderingGroupId},enumerable:!0,configurable:!0}),i.prototype.getTotalVertices=function(){return this._sourceMesh.getTotalVertices()},Object.defineProperty(i.prototype,"sourceMesh",{get:function(){return this._sourceMesh},enumerable:!0,configurable:!0}),i.prototype.getVerticesData=function(e,t){return this._sourceMesh.getVerticesData(e,t)},i.prototype.isVerticesDataPresent=function(e){return this._sourceMesh.isVerticesDataPresent(e)},i.prototype.getIndices=function(){return this._sourceMesh.getIndices()},Object.defineProperty(i.prototype,"_positions",{get:function(){return this._sourceMesh._positions},enumerable:!0,configurable:!0}),i.prototype.refreshBoundingInfo=function(){var t=this._sourceMesh.getBoundingInfo();this._boundingInfo=new e.BoundingInfo(t.minimum.clone(),t.maximum.clone()),this._updateBoundingInfo()},i.prototype._preActivate=function(){this._currentLOD&&this._currentLOD._preActivate()},i.prototype._activate=function(e){this._currentLOD&&this._currentLOD._registerInstanceForRenderId(this,e)},i.prototype.getLOD=function(e){return this._currentLOD=this.sourceMesh.getLOD(this.getScene().activeCamera,this.getBoundingInfo().boundingSphere),this._currentLOD===this.sourceMesh?this:this._currentLOD},i.prototype._syncSubMeshes=function(){if(this.releaseSubMeshes(),this._sourceMesh.subMeshes)for(var e=0;e<this._sourceMesh.subMeshes.length;e++)this._sourceMesh.subMeshes[e].clone(this,this._sourceMesh)},i.prototype._generatePointsArray=function(){return this._sourceMesh._generatePointsArray()},i.prototype.clone=function(t,i,r){var n=this._sourceMesh.createInstance(t);if(e.Tools.DeepCopy(this,n,["name","subMeshes"],[]),this.refreshBoundingInfo(),i&&(n.parent=i),!r)for(var o=0;o<this.getScene().meshes.length;o++){var s=this.getScene().meshes[o];s.parent===this&&s.clone(s.name,n)}return n.computeWorldMatrix(!0),n},i.prototype.dispose=function(e){var i=this._sourceMesh.instances.indexOf(this);this._sourceMesh.instances.splice(i,1),t.prototype.dispose.call(this,e)},i}(e.AbstractMesh);e.InstancedMesh=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function e(){this.mustReturn=!1,this.visibleInstances=new Array,this.renderSelf=new Array}return e}();e._InstancesBatch=t;var i=function(i){function r(n,o,s,a,h,c){if(void 0===s&&(s=null),void 0===c&&(c=!0),i.call(this,n,o),this.onBeforeRenderObservable=new e.Observable,this.onAfterRenderObservable=new e.Observable,this.onBeforeDrawObservable=new e.Observable,this.delayLoadState=e.Engine.DELAYLOADSTATE_NONE,this.instances=new Array,this._LODLevels=new Array,this._visibleInstances={},this._renderIdForInstances=new Array,this._batchCache=new t,this._instancesBufferSize=2048,this._sideOrientation=r._DEFAULTSIDE,this._areNormalsFrozen=!1,a){a._geometry&&a._geometry.applyToMesh(this),e.Tools.DeepCopy(a,this,["name","material","skeleton","instances"],["_poseMatrix"]),this.setPivotMatrix(a.getPivotMatrix()),this.id=n+"."+a.id,this.material=a.material;var l;if(!h)for(l=0;l<o.meshes.length;l++){var u=o.meshes[l];if(u.parent===a){u.clone(n+"."+u.name,this,h)}}var f=this.getScene().getPhysicsEngine();if(c&&f){var d=f.getImpostorForPhysicsObject(a);d&&(this.physicsImpostor=d.clone(this))}for(l=0;l<o.particleSystems.length;l++){var p=o.particleSystems[l];p.emitter===a&&p.clone(p.name,this)}this.computeWorldMatrix(!0)}null!==s&&(this.parent=s)}return __extends(r,i),Object.defineProperty(r,"FRONTSIDE",{get:function(){return r._FRONTSIDE},enumerable:!0,configurable:!0}),Object.defineProperty(r,"BACKSIDE",{get:function(){return r._BACKSIDE},enumerable:!0,configurable:!0}),Object.defineProperty(r,"DOUBLESIDE",{get:function(){return r._DOUBLESIDE},enumerable:!0,configurable:!0}),Object.defineProperty(r,"DEFAULTSIDE",{get:function(){return r._DEFAULTSIDE},enumerable:!0,configurable:!0}),Object.defineProperty(r,"NO_CAP",{get:function(){return r._NO_CAP},enumerable:!0,configurable:!0}),Object.defineProperty(r,"CAP_START",{get:function(){return r._CAP_START},enumerable:!0,configurable:!0}),Object.defineProperty(r,"CAP_END",{get:function(){return r._CAP_END},enumerable:!0,configurable:!0}),Object.defineProperty(r,"CAP_ALL",{get:function(){return r._CAP_ALL},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"onBeforeDraw",{set:function(e){this._onBeforeDrawObserver&&this.onBeforeDrawObservable.remove(this._onBeforeDrawObserver),this._onBeforeDrawObserver=this.onBeforeDrawObservable.add(e)},enumerable:!0,configurable:!0}),r.prototype.toString=function(t){var r=i.prototype.toString.call(this,t);if(r+=", n vertices: "+this.getTotalVertices(),r+=", parent: "+(this._waitingParentId?this._waitingParentId:this.parent?this.parent.name:"NONE"),this.animations)for(var n=0;n<this.animations.length;n++)r+=", animation[0]: "+this.animations[n].toString(t);return t&&(r+=", flat shading: "+(this._geometry?this.getVerticesData(e.VertexBuffer.PositionKind).length/3===this.getIndices().length?"YES":"NO":"UNKNOWN")),r},Object.defineProperty(r.prototype,"hasLODLevels",{get:function(){return this._LODLevels.length>0},enumerable:!0,configurable:!0}),r.prototype._sortLODLevels=function(){this._LODLevels.sort(function(e,t){return e.distance<t.distance?1:e.distance>t.distance?-1:0})},r.prototype.addLODLevel=function(t,i){if(i&&i._masterMesh)return e.Tools.Warn("You cannot use a mesh as LOD level twice"),this;var r=new e.Internals.MeshLODLevel(t,i);return this._LODLevels.push(r),i&&(i._masterMesh=this),this._sortLODLevels(),this},r.prototype.getLODLevelAtDistance=function(e){for(var t=0;t<this._LODLevels.length;t++){var i=this._LODLevels[t];if(i.distance===e)return i.mesh}return null},r.prototype.removeLODLevel=function(e){for(var t=0;t<this._LODLevels.length;t++)this._LODLevels[t].mesh===e&&(this._LODLevels.splice(t,1),e&&(e._masterMesh=null));return this._sortLODLevels(),this},r.prototype.getLOD=function(e,t){if(!this._LODLevels||0===this._LODLevels.length)return this;var i=(t?t:this.getBoundingInfo().boundingSphere).centerWorld.subtract(e.globalPosition).length();if(this._LODLevels[this._LODLevels.length-1].distance>i)return this.onLODLevelSelection&&this.onLODLevelSelection(i,this,this._LODLevels[this._LODLevels.length-1].mesh),this;for(var r=0;r<this._LODLevels.length;r++){var n=this._LODLevels[r];if(n.distance<i)return n.mesh&&(n.mesh._preActivate(),n.mesh._updateSubMeshesBoundingInfo(this.worldMatrixFromCache)),this.onLODLevelSelection&&this.onLODLevelSelection(i,this,n.mesh),n.mesh}return this.onLODLevelSelection&&this.onLODLevelSelection(i,this,this),this},Object.defineProperty(r.prototype,"geometry",{get:function(){return this._geometry},enumerable:!0,configurable:!0}),r.prototype.getTotalVertices=function(){return this._geometry?this._geometry.getTotalVertices():0},r.prototype.getVerticesData=function(e,t){return this._geometry?this._geometry.getVerticesData(e,t):null},r.prototype.getVertexBuffer=function(e){return this._geometry?this._geometry.getVertexBuffer(e):void 0},r.prototype.isVerticesDataPresent=function(e){return this._geometry?this._geometry.isVerticesDataPresent(e):this._delayInfo?-1!==this._delayInfo.indexOf(e):!1},r.prototype.getVerticesDataKinds=function(){if(!this._geometry){var e=[];if(this._delayInfo)for(var t in this._delayInfo)e.push(t);return e}return this._geometry.getVerticesDataKinds()},r.prototype.getTotalIndices=function(){return this._geometry?this._geometry.getTotalIndices():0},r.prototype.getIndices=function(e){return this._geometry?this._geometry.getIndices(e):[]},Object.defineProperty(r.prototype,"isBlocked",{get:function(){return null!==this._masterMesh&&void 0!==this._masterMesh;
  12. },enumerable:!0,configurable:!0}),r.prototype.isReady=function(){return this.delayLoadState===e.Engine.DELAYLOADSTATE_LOADING?!1:i.prototype.isReady.call(this)},r.prototype.isDisposed=function(){return this._isDisposed},Object.defineProperty(r.prototype,"sideOrientation",{get:function(){return this._sideOrientation},set:function(e){this._sideOrientation=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"areNormalsFrozen",{get:function(){return this._areNormalsFrozen},enumerable:!0,configurable:!0}),r.prototype.freezeNormals=function(){this._areNormalsFrozen=!0},r.prototype.unfreezeNormals=function(){this._areNormalsFrozen=!1},Object.defineProperty(r.prototype,"overridenInstanceCount",{set:function(e){this._overridenInstanceCount=e},enumerable:!0,configurable:!0}),r.prototype._preActivate=function(){var e=this.getScene().getRenderId();this._preActivateId!==e&&(this._preActivateId=e,this._visibleInstances=null)},r.prototype._preActivateForIntermediateRendering=function(e){this._visibleInstances&&(this._visibleInstances.intermediateDefaultRenderId=e)},r.prototype._registerInstanceForRenderId=function(e,t){this._visibleInstances||(this._visibleInstances={},this._visibleInstances.defaultRenderId=t,this._visibleInstances.selfDefaultRenderId=this._renderId),this._visibleInstances[t]||(this._visibleInstances[t]=new Array),this._visibleInstances[t].push(e)},r.prototype.refreshBoundingInfo=function(){if(!this._boundingInfo.isLocked){var t=this.getVerticesData(e.VertexBuffer.PositionKind);if(t){var i=e.Tools.ExtractMinAndMax(t,0,this.getTotalVertices());this._boundingInfo=new e.BoundingInfo(i.minimum,i.maximum)}if(this.subMeshes)for(var r=0;r<this.subMeshes.length;r++)this.subMeshes[r].refreshBoundingInfo();this._updateBoundingInfo()}},r.prototype._createGlobalSubMesh=function(){var t=this.getTotalVertices();return t&&this.getIndices()?(this.releaseSubMeshes(),new e.SubMesh(0,0,t,0,this.getTotalIndices(),this)):null},r.prototype.subdivide=function(t){if(!(1>t)){for(var i=this.getTotalIndices(),r=i/t|0,n=0;r%3!==0;)r++;this.releaseSubMeshes();for(var o=0;t>o&&!(n>=i);o++)e.SubMesh.CreateFromIndices(0,n,Math.min(r,i-n),this),n+=r;this.synchronizeInstances()}},r.prototype.setVerticesData=function(t,i,r,n){if(this._geometry)this._geometry.setVerticesData(t,i,r,n);else{var o=new e.VertexData;o.set(i,t);var s=this.getScene();new e.Geometry(e.Geometry.RandomId(),s,o,r,this)}},r.prototype.setVerticesBuffer=function(t){if(!this._geometry){var i=this.getScene();new e.Geometry(e.Geometry.RandomId(),i).applyToMesh(this)}this._geometry.setVerticesBuffer(t)},r.prototype.updateVerticesData=function(e,t,i,r){this._geometry&&(r?(this.makeGeometryUnique(),this.updateVerticesData(e,t,i,!1)):this._geometry.updateVerticesData(e,t,i))},r.prototype.updateVerticesDataDirectly=function(t,i,r,n){e.Tools.Warn("Mesh.updateVerticesDataDirectly deprecated since 2.3."),this._geometry&&(n?(this.makeGeometryUnique(),this.updateVerticesDataDirectly(t,i,r,!1)):this._geometry.updateVerticesDataDirectly(t,i,r))},r.prototype.updateMeshPositions=function(t,i){void 0===i&&(i=!0);var r=this.getVerticesData(e.VertexBuffer.PositionKind);if(t(r),this.updateVerticesData(e.VertexBuffer.PositionKind,r,!1,!1),i){var n=this.getIndices(),o=this.getVerticesData(e.VertexBuffer.NormalKind);e.VertexData.ComputeNormals(r,n,o),this.updateVerticesData(e.VertexBuffer.NormalKind,o,!1,!1)}},r.prototype.makeGeometryUnique=function(){if(this._geometry){var t=this._geometry.copy(e.Geometry.RandomId());t.applyToMesh(this)}},r.prototype.setIndices=function(t,i){if(this._geometry)this._geometry.setIndices(t,i);else{var r=new e.VertexData;r.indices=t;var n=this.getScene();new e.Geometry(e.Geometry.RandomId(),n,r,!1,this)}},r.prototype.toLeftHanded=function(){this._geometry&&this._geometry.toLeftHanded()},r.prototype._bind=function(t,i,r){var n,o=this.getScene().getEngine();if(this._unIndexed)n=null;else switch(r){case e.Material.PointFillMode:n=null;break;case e.Material.WireFrameFillMode:n=t.getLinesIndexBuffer(this.getIndices(),o);break;default:case e.Material.TriangleFillMode:n=this._unIndexed?null:this._geometry.getIndexBuffer()}o.bindBuffers(this._geometry.getVertexBuffers(),n,i)},r.prototype._draw=function(t,i,r){if(this._geometry&&this._geometry.getVertexBuffers()&&this._geometry.getIndexBuffer()){this.onBeforeDrawObservable.notifyObservers(this);var n=this.getScene().getEngine();switch(i){case e.Material.PointFillMode:n.drawPointClouds(t.verticesStart,t.verticesCount,r);break;case e.Material.WireFrameFillMode:this._unIndexed?n.drawUnIndexed(!1,t.verticesStart,t.verticesCount,r):n.draw(!1,0,r>0?t.linesIndexCount/2:t.linesIndexCount,r);break;default:this._unIndexed?n.drawUnIndexed(!0,t.verticesStart,t.verticesCount,r):n.draw(!0,t.indexStart,t.indexCount,r)}}},r.prototype.registerBeforeRender=function(e){this.onBeforeRenderObservable.add(e)},r.prototype.unregisterBeforeRender=function(e){this.onBeforeRenderObservable.removeCallback(e)},r.prototype.registerAfterRender=function(e){this.onAfterRenderObservable.add(e)},r.prototype.unregisterAfterRender=function(e){this.onAfterRenderObservable.removeCallback(e)},r.prototype._getInstancesRenderList=function(e){var t=this.getScene();if(this._batchCache.mustReturn=!1,this._batchCache.renderSelf[e]=this.isEnabled()&&this.isVisible,this._batchCache.visibleInstances[e]=null,this._visibleInstances){var i=t.getRenderId(),r=t._isInIntermediateRendering()?this._visibleInstances.intermediateDefaultRenderId:this._visibleInstances.defaultRenderId;this._batchCache.visibleInstances[e]=this._visibleInstances[i];var n=this._renderId;if(!this._batchCache.visibleInstances[e]&&r&&(this._batchCache.visibleInstances[e]=this._visibleInstances[r],i=Math.max(r,i),n=Math.max(this._visibleInstances.selfDefaultRenderId,i)),this._batchCache.visibleInstances[e]&&this._batchCache.visibleInstances[e].length){if(this._renderIdForInstances[e]===i)return this._batchCache.mustReturn=!0,this._batchCache;i!==n&&(this._batchCache.renderSelf[e]=!1)}this._renderIdForInstances[e]=i}return this._batchCache},r.prototype._renderWithInstances=function(t,i,r,n,o){for(var s=r.visibleInstances[t._id],a=s.length+1,h=16*a*4,c=this._instancesBufferSize,l=this._instancesBuffer;this._instancesBufferSize<h;)this._instancesBufferSize*=2;this._instancesData&&c==this._instancesBufferSize||(this._instancesData=new Float32Array(this._instancesBufferSize/4));var u=0,f=0,d=this.getWorldMatrix();if(r.renderSelf[t._id]&&(d.copyToArray(this._instancesData,u),u+=16,f++),s)for(var p=0;p<s.length;p++){var _=s[p];_.getWorldMatrix().copyToArray(this._instancesData,u),u+=16,f++}l&&c==this._instancesBufferSize?l.updateDirectly(this._instancesData,0,f):(l&&l.dispose(),l=new e.Buffer(o,this._instancesData,!0,16,!1,!0),this._instancesBuffer=l,this.setVerticesBuffer(l.createVertexBuffer("world0",0,4)),this.setVerticesBuffer(l.createVertexBuffer("world1",4,4)),this.setVerticesBuffer(l.createVertexBuffer("world2",8,4)),this.setVerticesBuffer(l.createVertexBuffer("world3",12,4))),o.bindBuffers(this.geometry.getVertexBuffers(),this.geometry.getIndexBuffer(),n),this._draw(t,i,f),o.unbindInstanceAttributes()},r.prototype._processRendering=function(e,t,i,r,n,o){var s=this.getScene(),a=s.getEngine();if(n)this._renderWithInstances(e,i,r,t,a);else if(r.renderSelf[e._id]&&(o&&o(!1,this.getWorldMatrix()),this._draw(e,i,this._overridenInstanceCount)),r.visibleInstances[e._id])for(var h=0;h<r.visibleInstances[e._id].length;h++){var c=r.visibleInstances[e._id][h],l=c.getWorldMatrix();o&&o(!0,l),this._draw(e,i)}},r.prototype.render=function(t,i){var r=this.getScene(),n=this._getInstancesRenderList(t._id);if(!n.mustReturn&&this._geometry&&this._geometry.getVertexBuffers()&&this._geometry.getIndexBuffer()){this.onBeforeRenderObservable.notifyObservers(this);var o=r.getEngine(),s=null!==o.getCaps().instancedArrays&&null!==n.visibleInstances[t._id]&&void 0!==n.visibleInstances[t._id],a=t.getMaterial();if(a&&a.isReady(this,s)){var h=o.getDepthWrite();this.renderOutline&&(o.setDepthWrite(!1),r.getOutlineRenderer().render(t,n),o.setDepthWrite(h)),a._preBind();var c=a.getEffect(),l=r.forcePointsCloud?e.Material.PointFillMode:r.forceWireframe?e.Material.WireFrameFillMode:a.fillMode;this._bind(t,c,l);var u=this.getWorldMatrix();if(a.bind(u,this),i&&o.setAlphaMode(a.alphaMode),this._processRendering(t,c,l,n,s,function(e,t){e&&a.bindOnlyWorldMatrix(t)}),a.unbind(),this.renderOutline&&h&&(o.setDepthWrite(!0),o.setColorWrite(!1),r.getOutlineRenderer().render(t,n),o.setColorWrite(!0)),this.renderOverlay){var f=o.getAlphaMode();o.setAlphaMode(e.Engine.ALPHA_COMBINE),r.getOutlineRenderer().render(t,n,!0),o.setAlphaMode(f)}this.onAfterRenderObservable.notifyObservers(this)}}},r.prototype.getEmittedParticleSystems=function(){for(var e=new Array,t=0;t<this.getScene().particleSystems.length;t++){var i=this.getScene().particleSystems[t];i.emitter===this&&e.push(i)}return e},r.prototype.getHierarchyEmittedParticleSystems=function(){var e=new Array,t=this.getDescendants();t.push(this);for(var i=0;i<this.getScene().particleSystems.length;i++){var r=this.getScene().particleSystems[i];-1!==t.indexOf(r.emitter)&&e.push(r)}return e},r.prototype._checkDelayState=function(){var t=this,i=this,r=this.getScene();if(this._geometry)this._geometry.load(r);else if(i.delayLoadState===e.Engine.DELAYLOADSTATE_NOTLOADED){i.delayLoadState=e.Engine.DELAYLOADSTATE_LOADING,r._addPendingData(i);var n=-1!==this.delayLoadingFile.indexOf(".babylonbinarymeshdata");e.Tools.LoadFile(this.delayLoadingFile,function(i){i instanceof ArrayBuffer?t._delayLoadingFunction(i,t):t._delayLoadingFunction(JSON.parse(i),t),t.delayLoadState=e.Engine.DELAYLOADSTATE_LOADED,r._removePendingData(t)},function(){},r.database,n)}},r.prototype.isInFrustum=function(t){return this.delayLoadState===e.Engine.DELAYLOADSTATE_LOADING?!1:i.prototype.isInFrustum.call(this,t)?(this._checkDelayState(),!0):!1},r.prototype.setMaterialByID=function(e){var t,i=this.getScene().materials;for(t=0;t<i.length;t++)if(i[t].id===e)return void(this.material=i[t]);var r=this.getScene().multiMaterials;for(t=0;t<r.length;t++)if(r[t].id===e)return void(this.material=r[t])},r.prototype.getAnimatables=function(){var e=[];return this.material&&e.push(this.material),this.skeleton&&e.push(this.skeleton),e},r.prototype.bakeTransformIntoVertices=function(t){if(this.isVerticesDataPresent(e.VertexBuffer.PositionKind)){var i=this.subMeshes.splice(0);this._resetPointsArrayCache();var r,n=this.getVerticesData(e.VertexBuffer.PositionKind),o=[];for(r=0;r<n.length;r+=3)e.Vector3.TransformCoordinates(e.Vector3.FromArray(n,r),t).toArray(o,r);if(this.setVerticesData(e.VertexBuffer.PositionKind,o,this.getVertexBuffer(e.VertexBuffer.PositionKind).isUpdatable()),this.isVerticesDataPresent(e.VertexBuffer.NormalKind)){for(n=this.getVerticesData(e.VertexBuffer.NormalKind),o=[],r=0;r<n.length;r+=3)e.Vector3.TransformNormal(e.Vector3.FromArray(n,r),t).normalize().toArray(o,r);this.setVerticesData(e.VertexBuffer.NormalKind,o,this.getVertexBuffer(e.VertexBuffer.NormalKind).isUpdatable()),t.m[0]*t.m[5]*t.m[10]<0&&this.flipFaces(),this.releaseSubMeshes(),this.subMeshes=i}}},r.prototype.bakeCurrentTransformIntoVertices=function(){this.bakeTransformIntoVertices(this.computeWorldMatrix(!0)),this.scaling.copyFromFloats(1,1,1),this.position.copyFromFloats(0,0,0),this.rotation.copyFromFloats(0,0,0),this.rotationQuaternion&&(this.rotationQuaternion=e.Quaternion.Identity()),this._worldMatrix=e.Matrix.Identity()},r.prototype._resetPointsArrayCache=function(){this._positions=null},r.prototype._generatePointsArray=function(){if(this._positions)return!0;this._positions=[];var t=this.getVerticesData(e.VertexBuffer.PositionKind);if(!t)return!1;for(var i=0;i<t.length;i+=3)this._positions.push(e.Vector3.FromArray(t,i));return!0},r.prototype.clone=function(e,t,i,n){return void 0===n&&(n=!0),new r(e,this.getScene(),t,this,i,n)},r.prototype.dispose=function(e){for(this._geometry&&this._geometry.releaseForMesh(this,!0),this._instancesBuffer&&(this._instancesBuffer.dispose(),this._instancesBuffer=null);this.instances.length;)this.instances[0].dispose();i.prototype.dispose.call(this,e)},r.prototype.applyDisplacementMap=function(t,i,r,n){var o=this,s=this.getScene(),a=function(e){var t=document.createElement("canvas"),s=t.getContext("2d"),a=e.width,h=e.height;t.width=a,t.height=h,s.drawImage(e,0,0);var c=s.getImageData(0,0,a,h).data;o.applyDisplacementMapFromBuffer(c,a,h,i,r),n&&n(o)};e.Tools.LoadImage(t,a,function(){},s.database)},r.prototype.applyDisplacementMapFromBuffer=function(t,i,r,n,o){if(!this.isVerticesDataPresent(e.VertexBuffer.PositionKind)||!this.isVerticesDataPresent(e.VertexBuffer.NormalKind)||!this.isVerticesDataPresent(e.VertexBuffer.UVKind))return void e.Tools.Warn("Cannot call applyDisplacementMap: Given mesh is not complete. Position, Normal or UV are missing");for(var s=this.getVerticesData(e.VertexBuffer.PositionKind),a=this.getVerticesData(e.VertexBuffer.NormalKind),h=this.getVerticesData(e.VertexBuffer.UVKind),c=e.Vector3.Zero(),l=e.Vector3.Zero(),u=e.Vector2.Zero(),f=0;f<s.length;f+=3){e.Vector3.FromArrayToRef(s,f,c),e.Vector3.FromArrayToRef(a,f,l),e.Vector2.FromArrayToRef(h,f/3*2,u);var d=Math.abs(u.x)*i%i|0,p=Math.abs(u.y)*r%r|0,_=4*(d+p*i),m=t[_]/255,g=t[_+1]/255,v=t[_+2]/255,y=.3*m+.59*g+.11*v;l.normalize(),l.scaleInPlace(n+(o-n)*y),c=c.add(l),c.toArray(s,f)}e.VertexData.ComputeNormals(s,this.getIndices(),a),this.updateVerticesData(e.VertexBuffer.PositionKind,s),this.updateVerticesData(e.VertexBuffer.NormalKind,a)},r.prototype.convertToFlatShadedMesh=function(){var t,i,r=this.getVerticesDataKinds(),n=[],o=[],s=[],a=!1;for(t=0;t<r.length;t++){i=r[t];var h=this.getVertexBuffer(i);i!==e.VertexBuffer.NormalKind?(n[i]=h,o[i]=n[i].getData(),s[i]=[]):(a=h.isUpdatable(),r.splice(t,1),t--)}var c,l=this.subMeshes.slice(0),u=this.getIndices(),f=this.getTotalIndices();for(c=0;f>c;c++){var d=u[c];for(t=0;t<r.length;t++){i=r[t];for(var p=n[i].getStrideSize(),_=0;p>_;_++)s[i].push(o[i][d*p+_])}}var m=[],g=s[e.VertexBuffer.PositionKind];for(c=0;f>c;c+=3){u[c]=c,u[c+1]=c+1,u[c+2]=c+2;for(var v=e.Vector3.FromArray(g,3*c),y=e.Vector3.FromArray(g,3*(c+1)),x=e.Vector3.FromArray(g,3*(c+2)),b=v.subtract(y),P=x.subtract(y),A=e.Vector3.Normalize(e.Vector3.Cross(b,P)),T=0;3>T;T++)m.push(A.x),m.push(A.y),m.push(A.z)}for(this.setIndices(u),this.setVerticesData(e.VertexBuffer.NormalKind,m,a),t=0;t<r.length;t++)i=r[t],this.setVerticesData(i,s[i],n[i].isUpdatable());this.releaseSubMeshes();for(var E=0;E<l.length;E++){var C=l[E];new e.SubMesh(C.materialIndex,C.indexStart,C.indexCount,C.indexStart,C.indexCount,this)}this.synchronizeInstances()},r.prototype.convertToUnIndexedMesh=function(){var t,i,r=this.getVerticesDataKinds(),n=[],o=[],s=[];for(t=0;t<r.length;t++){i=r[t];var a=this.getVertexBuffer(i);n[i]=a,o[i]=n[i].getData(),s[i]=[]}var h,c=this.subMeshes.slice(0),l=this.getIndices(),u=this.getTotalIndices();for(h=0;u>h;h++){var f=l[h];for(t=0;t<r.length;t++){i=r[t];for(var d=n[i].getStrideSize(),p=0;d>p;p++)s[i].push(o[i][f*d+p])}}for(h=0;u>h;h+=3)l[h]=h,l[h+1]=h+1,l[h+2]=h+2;for(this.setIndices(l),t=0;t<r.length;t++)i=r[t],this.setVerticesData(i,s[i],n[i].isUpdatable());this.releaseSubMeshes();for(var _=0;_<c.length;_++){var m=c[_];new e.SubMesh(m.materialIndex,m.indexStart,m.indexCount,m.indexStart,m.indexCount,this)}this._unIndexed=!0,this.synchronizeInstances()},r.prototype.flipFaces=function(t){void 0===t&&(t=!1);var i,r=e.VertexData.ExtractFromMesh(this);if(t&&this.isVerticesDataPresent(e.VertexBuffer.NormalKind))for(i=0;i<r.normals.length;i++)r.normals[i]*=-1;var n;for(i=0;i<r.indices.length;i+=3)n=r.indices[i+1],r.indices[i+1]=r.indices[i+2],r.indices[i+2]=n;r.applyToMesh(this)},r.prototype.createInstance=function(t){return new e.InstancedMesh(t,this)},r.prototype.synchronizeInstances=function(){for(var e=0;e<this.instances.length;e++){var t=this.instances[e];t._syncSubMeshes()}},r.prototype.simplify=function(t,i,r,n){void 0===i&&(i=!0),void 0===r&&(r=e.SimplificationType.QUADRATIC),this.getScene().simplificationQueue.addTask({settings:t,parallelProcessing:i,mesh:this,simplificationType:r,successCallback:n})},r.prototype.optimizeIndices=function(t){for(var i=this,r=this.getIndices(),n=this.getVerticesData(e.VertexBuffer.PositionKind),o=[],s=0;s<n.length;s+=3)o.push(e.Vector3.FromArray(n,s));var a=[];e.AsyncLoop.SyncAsyncForLoop(o.length,40,function(e){for(var t=o.length-1-e,i=o[t],r=0;t>r;++r){var n=o[r];if(i.equals(n)){a[t]=r;break}}},function(){for(var e=0;e<r.length;++e)r[e]=a[r[e]]||r[e];var n=i.subMeshes.slice(0);i.setIndices(r),i.subMeshes=n,t&&t(i)})},r.Parse=function(t,i,n){var o=new r(t.name,i);if(o.id=t.id,e.Tags.AddTagsTo(o,t.tags),o.position=e.Vector3.FromArray(t.position),t.rotationQuaternion?o.rotationQuaternion=e.Quaternion.FromArray(t.rotationQuaternion):t.rotation&&(o.rotation=e.Vector3.FromArray(t.rotation)),o.scaling=e.Vector3.FromArray(t.scaling),t.localMatrix?o.setPivotMatrix(e.Matrix.FromArray(t.localMatrix)):t.pivotMatrix&&o.setPivotMatrix(e.Matrix.FromArray(t.pivotMatrix)),o.setEnabled(t.isEnabled),o.isVisible=t.isVisible,o.infiniteDistance=t.infiniteDistance,o.showBoundingBox=t.showBoundingBox,o.showSubMeshesBoundingBox=t.showSubMeshesBoundingBox,void 0!==t.applyFog&&(o.applyFog=t.applyFog),void 0!==t.pickable&&(o.isPickable=t.pickable),void 0!==t.alphaIndex&&(o.alphaIndex=t.alphaIndex),o.receiveShadows=t.receiveShadows,o.billboardMode=t.billboardMode,void 0!==t.visibility&&(o.visibility=t.visibility),o.checkCollisions=t.checkCollisions,o._shouldGenerateFlatShading=t.useFlatShading,t.freezeWorldMatrix&&(o._waitingFreezeWorldMatrix=t.freezeWorldMatrix),t.parentId&&(o._waitingParentId=t.parentId),void 0!==t.actions&&(o._waitingActions=t.actions),o.hasVertexAlpha=t.hasVertexAlpha,t.delayLoadingFile?(o.delayLoadState=e.Engine.DELAYLOADSTATE_NOTLOADED,o.delayLoadingFile=n+t.delayLoadingFile,o._boundingInfo=new e.BoundingInfo(e.Vector3.FromArray(t.boundingBoxMinimum),e.Vector3.FromArray(t.boundingBoxMaximum)),t._binaryInfo&&(o._binaryInfo=t._binaryInfo),o._delayInfo=[],t.hasUVs&&o._delayInfo.push(e.VertexBuffer.UVKind),t.hasUVs2&&o._delayInfo.push(e.VertexBuffer.UV2Kind),t.hasUVs3&&o._delayInfo.push(e.VertexBuffer.UV3Kind),t.hasUVs4&&o._delayInfo.push(e.VertexBuffer.UV4Kind),t.hasUVs5&&o._delayInfo.push(e.VertexBuffer.UV5Kind),t.hasUVs6&&o._delayInfo.push(e.VertexBuffer.UV6Kind),t.hasColors&&o._delayInfo.push(e.VertexBuffer.ColorKind),t.hasMatricesIndices&&o._delayInfo.push(e.VertexBuffer.MatricesIndicesKind),t.hasMatricesWeights&&o._delayInfo.push(e.VertexBuffer.MatricesWeightsKind),o._delayLoadingFunction=e.Geometry.ImportGeometry,e.SceneLoader.ForceFullSceneLoadingForIncremental&&o._checkDelayState()):e.Geometry.ImportGeometry(t,o),t.materialId?o.setMaterialByID(t.materialId):o.material=null,t.skeletonId>-1&&(o.skeleton=i.getLastSkeletonByID(t.skeletonId),t.numBoneInfluencers&&(o.numBoneInfluencers=t.numBoneInfluencers)),t.animations){for(var s=0;s<t.animations.length;s++){var a=t.animations[s];o.animations.push(e.Animation.Parse(a))}e.Node.ParseAnimationRanges(o,t,i)}if(t.autoAnimate&&i.beginAnimation(o,t.autoAnimateFrom,t.autoAnimateTo,t.autoAnimateLoop,t.autoAnimateSpeed||1),t.layerMask&&!isNaN(t.layerMask)?o.layerMask=Math.abs(parseInt(t.layerMask)):o.layerMask=268435455,t.physicsImpostor&&(o.physicsImpostor=new e.PhysicsImpostor(o,t.physicsImpostor,{mass:t.physicsMass,friction:t.physicsFriction,restitution:t.physicsRestitution},i)),t.instances)for(var h=0;h<t.instances.length;h++){var c=t.instances[h],l=o.createInstance(c.name);if(e.Tags.AddTagsTo(l,c.tags),l.position=e.Vector3.FromArray(c.position),c.rotationQuaternion?l.rotationQuaternion=e.Quaternion.FromArray(c.rotationQuaternion):c.rotation&&(l.rotation=e.Vector3.FromArray(c.rotation)),l.scaling=e.Vector3.FromArray(c.scaling),l.checkCollisions=o.checkCollisions,t.animations){for(s=0;s<t.animations.length;s++)a=t.animations[s],l.animations.push(e.Animation.Parse(a));e.Node.ParseAnimationRanges(l,t,i)}}return o},r.CreateRibbon=function(t,i,r,n,o,s,a,h,c){return e.MeshBuilder.CreateRibbon(t,{pathArray:i,closeArray:r,closePath:n,offset:o,updatable:a,sideOrientation:h,instance:c},s)},r.CreateDisc=function(t,i,r,n,o,s){var a={radius:i,tessellation:r,sideOrientation:s,updatable:o};return e.MeshBuilder.CreateDisc(t,a,n)},r.CreateBox=function(t,i,r,n,o){var s={size:i,sideOrientation:o,updatable:n};return e.MeshBuilder.CreateBox(t,s,r)},r.CreateSphere=function(t,i,r,n,o,s){var a={segments:i,diameterX:r,diameterY:r,diameterZ:r,sideOrientation:s,updatable:o};return e.MeshBuilder.CreateSphere(t,a,n)},r.CreateCylinder=function(t,i,n,o,s,a,h,c,l){void 0!==h&&h instanceof e.Scene||(void 0!==h&&(l=c||r.DEFAULTSIDE,c=h),h=a,a=1);var u={height:i,diameterTop:n,diameterBottom:o,tessellation:s,subdivisions:a,sideOrientation:l,updatable:c};return e.MeshBuilder.CreateCylinder(t,u,h)},r.CreateTorus=function(t,i,r,n,o,s,a){var h={diameter:i,thickness:r,tessellation:n,sideOrientation:a,updatable:s};return e.MeshBuilder.CreateTorus(t,h,o)},r.CreateTorusKnot=function(t,i,r,n,o,s,a,h,c,l){var u={radius:i,tube:r,radialSegments:n,tubularSegments:o,p:s,q:a,sideOrientation:l,updatable:c};return e.MeshBuilder.CreateTorusKnot(t,u,h)},r.CreateLines=function(t,i,r,n,o){var s={points:i,updatable:n,instance:o};return e.MeshBuilder.CreateLines(t,s,r)},r.CreateDashedLines=function(t,i,r,n,o,s,a,h){var c={points:i,dashSize:r,gapSize:n,dashNb:o,updatable:a};return e.MeshBuilder.CreateDashedLines(t,c,s)},r.ExtrudeShape=function(t,i,n,o,s,a,h,c,l,u){var f={shape:i,path:n,scale:o,rotation:s,cap:0===a?0:a||r.NO_CAP,sideOrientation:l,instance:u,updatable:c};return e.MeshBuilder.ExtrudeShape(t,f,h)},r.ExtrudeShapeCustom=function(t,i,n,o,s,a,h,c,l,u,f,d){var p={shape:i,path:n,scaleFunction:o,rotationFunction:s,ribbonCloseArray:a,ribbonClosePath:h,cap:0===c?0:c||r.NO_CAP,sideOrientation:f,instance:d,updatable:u};return e.MeshBuilder.ExtrudeShapeCustom(t,p,l)},r.CreateLathe=function(t,i,r,n,o,s,a){var h={shape:i,radius:r,tessellation:n,sideOrientation:a,updatable:s};return e.MeshBuilder.CreateLathe(t,h,o)},r.CreatePlane=function(t,i,r,n,o){var s={size:i,width:i,height:i,sideOrientation:o,updatable:n};return e.MeshBuilder.CreatePlane(t,s,r)},r.CreateGround=function(t,i,r,n,o,s){var a={width:i,height:r,subdivisions:n,updatable:s};return e.MeshBuilder.CreateGround(t,a,o)},r.CreateTiledGround=function(t,i,r,n,o,s,a,h,c){var l={xmin:i,zmin:r,xmax:n,zmax:o,subdivisions:s,precision:a,updatable:c};return e.MeshBuilder.CreateTiledGround(t,l,h)},r.CreateGroundFromHeightMap=function(t,i,r,n,o,s,a,h,c,l){var u={width:r,height:n,subdivisions:o,minHeight:s,maxHeight:a,updatable:c,onReady:l};return e.MeshBuilder.CreateGroundFromHeightMap(t,i,u,h)},r.CreateTube=function(t,i,r,n,o,s,a,h,c,l){var u={path:i,radius:r,tessellation:n,radiusFunction:o,arc:1,cap:s,updatable:h,sideOrientation:c,instance:l};return e.MeshBuilder.CreateTube(t,u,a)},r.CreatePolyhedron=function(t,i,r){return e.MeshBuilder.CreatePolyhedron(t,i,r)},r.CreateIcoSphere=function(t,i,r){return e.MeshBuilder.CreateIcoSphere(t,i,r)},r.CreateDecal=function(t,i,r,n,o,s){var a={position:r,normal:n,size:o,angle:s};return e.MeshBuilder.CreateDecal(t,i,a)},r.prototype.setPositionsForCPUSkinning=function(){var t;return this._sourcePositions||(t=this.getVerticesData(e.VertexBuffer.PositionKind),this._sourcePositions=new Float32Array(t),this.getVertexBuffer(e.VertexBuffer.PositionKind).isUpdatable()||this.setVerticesData(e.VertexBuffer.PositionKind,t,!0)),this._sourcePositions},r.prototype.setNormalsForCPUSkinning=function(){var t;return this._sourceNormals||(t=this.getVerticesData(e.VertexBuffer.NormalKind),this._sourceNormals=new Float32Array(t),this.getVertexBuffer(e.VertexBuffer.NormalKind).isUpdatable()||this.setVerticesData(e.VertexBuffer.NormalKind,t,!0)),this._sourceNormals},r.prototype.applySkeleton=function(t){if(this.geometry&&this.geometry._softwareSkinningRenderId!=this.getScene().getRenderId()){if(this.geometry._softwareSkinningRenderId=this.getScene().getRenderId(),!this.isVerticesDataPresent(e.VertexBuffer.PositionKind))return this;if(!this.isVerticesDataPresent(e.VertexBuffer.NormalKind))return this;if(!this.isVerticesDataPresent(e.VertexBuffer.MatricesIndicesKind))return this;if(!this.isVerticesDataPresent(e.VertexBuffer.MatricesWeightsKind))return this;this._sourcePositions||this.setPositionsForCPUSkinning(),this._sourceNormals||this.setNormalsForCPUSkinning();var i=this.getVerticesData(e.VertexBuffer.PositionKind);i instanceof Float32Array||(i=new Float32Array(i));var r=this.getVerticesData(e.VertexBuffer.NormalKind);r instanceof Float32Array||(r=new Float32Array(r));for(var n,o=this.getVerticesData(e.VertexBuffer.MatricesIndicesKind),s=this.getVerticesData(e.VertexBuffer.MatricesWeightsKind),a=this.numBoneInfluencers>4,h=a?this.getVerticesData(e.VertexBuffer.MatricesIndicesExtraKind):null,c=a?this.getVerticesData(e.VertexBuffer.MatricesWeightsExtraKind):null,l=t.getTransformMatrices(this),u=e.Vector3.Zero(),f=new e.Matrix,d=new e.Matrix,p=0,_=0;_<i.length;_+=3,p+=4){var m;for(n=0;4>n&&(m=s[p+n],m>0);n++)e.Matrix.FromFloat32ArrayToRefScaled(l,16*o[p+n],m,d),f.addToSelf(d);if(a)for(n=0;4>n&&(m=c[p+n],m>0);n++)e.Matrix.FromFloat32ArrayToRefScaled(l,16*h[p+n],m,d),f.addToSelf(d);e.Vector3.TransformCoordinatesFromFloatsToRef(this._sourcePositions[_],this._sourcePositions[_+1],this._sourcePositions[_+2],f,u),u.toArray(i,_),e.Vector3.TransformNormalFromFloatsToRef(this._sourceNormals[_],this._sourceNormals[_+1],this._sourceNormals[_+2],f,u),u.toArray(r,_),f.reset()}return this.updateVerticesData(e.VertexBuffer.PositionKind,i),this.updateVerticesData(e.VertexBuffer.NormalKind,r),this}},r.MinMax=function(e){var t=null,i=null;for(var r in e){var n=e[r],o=n.getBoundingInfo().boundingBox;t?(t.MinimizeInPlace(o.minimumWorld),i.MaximizeInPlace(o.maximumWorld)):(t=o.minimumWorld,i=o.maximumWorld)}return{min:t,max:i}},r.Center=function(t){var i=void 0!==t.min?t:r.MinMax(t);return e.Vector3.Center(i.min,i.max)},r.MergeMeshes=function(t,i,n,o){void 0===i&&(i=!0);var s;if(!n){var a=0;for(s=0;s<t.length;s++)if(t[s]&&(a+=t[s].getTotalVertices(),a>65536))return e.Tools.Warn("Cannot merge meshes because resulting mesh will have more than 65536 vertices. Please use allow32BitsIndices = true to use 32 bits indices"),null}var h,c,l;for(s=0;s<t.length;s++)t[s]&&(t[s].computeWorldMatrix(!0),c=e.VertexData.ExtractFromMesh(t[s],!0),c.transform(t[s].getWorldMatrix()),h?h.merge(c):(h=c,l=t[s]));if(o||(o=new r(l.name+"_merged",l.getScene())),h.applyToMesh(o),o.material=l.material,o.checkCollisions=l.checkCollisions,i)for(s=0;s<t.length;s++)t[s]&&t[s].dispose();return o},r._FRONTSIDE=0,r._BACKSIDE=1,r._DOUBLESIDE=2,r._DEFAULTSIDE=0,r._NO_CAP=0,r._CAP_START=1,r._CAP_END=2,r._CAP_ALL=3,r}(e.AbstractMesh);e.Mesh=i}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(e,t,i,r,n,o,s,a){void 0===a&&(a=!0),this.materialIndex=e,this.verticesStart=t,this.verticesCount=i,this.indexStart=r,this.indexCount=n,this._renderId=0,this._mesh=o,this._renderingMesh=s||o,o.subMeshes.push(this),this._trianglePlanes=[],this._id=o.subMeshes.length-1,a&&(this.refreshBoundingInfo(),o.computeWorldMatrix(!0))}return Object.defineProperty(t.prototype,"IsGlobal",{get:function(){return 0===this.verticesStart&&this.verticesCount==this._mesh.getTotalVertices()},enumerable:!0,configurable:!0}),t.prototype.getBoundingInfo=function(){return this.IsGlobal?this._mesh.getBoundingInfo():this._boundingInfo},t.prototype.getMesh=function(){return this._mesh},t.prototype.getRenderingMesh=function(){return this._renderingMesh},t.prototype.getMaterial=function(){var t=this._renderingMesh.material;if(t&&t instanceof e.MultiMaterial){var i=t;return i.getSubMaterial(this.materialIndex)}return t?t:this._mesh.getScene().defaultMaterial},t.prototype.refreshBoundingInfo=function(){if(this._lastColliderWorldVertices=null,!this.IsGlobal){var t=this._renderingMesh.getVerticesData(e.VertexBuffer.PositionKind);if(!t)return void(this._boundingInfo=this._mesh._boundingInfo);var i,r=this._renderingMesh.getIndices();i=0===this.indexStart&&this.indexCount===r.length?{minimum:this._renderingMesh.getBoundingInfo().minimum.clone(),maximum:this._renderingMesh.getBoundingInfo().maximum.clone()}:e.Tools.ExtractMinAndMaxIndexed(t,r,this.indexStart,this.indexCount,this._renderingMesh.geometry.boundingBias),this._boundingInfo=new e.BoundingInfo(i.minimum,i.maximum)}},t.prototype._checkCollision=function(e){return this.getBoundingInfo()._checkCollision(e)},t.prototype.updateBoundingInfo=function(e){this.getBoundingInfo()||this.refreshBoundingInfo(),this.getBoundingInfo().update(e)},t.prototype.isInFrustum=function(e){return this.getBoundingInfo().isInFrustum(e)},t.prototype.render=function(e){this._renderingMesh.render(this,e)},t.prototype.getLinesIndexBuffer=function(e,t){if(!this._linesIndexBuffer){for(var i=[],r=this.indexStart;r<this.indexStart+this.indexCount;r+=3)i.push(e[r],e[r+1],e[r+1],e[r+2],e[r+2],e[r]);this._linesIndexBuffer=t.createIndexBuffer(i),this.linesIndexCount=i.length}return this._linesIndexBuffer},t.prototype.canIntersects=function(e){return e.intersectsBox(this.getBoundingInfo().boundingBox)},t.prototype.intersects=function(t,i,r,n){var o=null;if(this._mesh instanceof e.LinesMesh)for(var s=this._mesh,a=this.indexStart;a<this.indexStart+this.indexCount;a+=2){var h=i[r[a]],c=i[r[a+1]],l=t.intersectionSegment(h,c,s.intersectionThreshold);if(!(0>l)&&(n||!o||l<o.distance)&&(o=new e.IntersectionInfo(null,null,l),n))break}else for(var a=this.indexStart;a<this.indexStart+this.indexCount;a+=3){var h=i[r[a]],c=i[r[a+1]],u=i[r[a+2]],f=t.intersectsTriangle(h,c,u);if(f){if(f.distance<0)continue;if((n||!o||f.distance<o.distance)&&(o=f,o.faceId=a/3,n))break}}return o},t.prototype.clone=function(i,r){var n=new t(this.materialIndex,this.verticesStart,this.verticesCount,this.indexStart,this.indexCount,i,r,!1);return this.IsGlobal||(n._boundingInfo=new e.BoundingInfo(this.getBoundingInfo().minimum,this.getBoundingInfo().maximum)),n},t.prototype.dispose=function(){this._linesIndexBuffer&&(this._mesh.getScene().getEngine()._releaseBuffer(this._linesIndexBuffer),this._linesIndexBuffer=null);var e=this._mesh.subMeshes.indexOf(this);this._mesh.subMeshes.splice(e,1)},t.CreateFromIndices=function(e,i,r,n,o){var s=Number.MAX_VALUE,a=-Number.MAX_VALUE;o=o||n;for(var h=o.getIndices(),c=i;i+r>c;c++){var l=h[c];s>l&&(s=l),l>a&&(a=l)}return new t(e,s,a-s+1,i,r,n,o)},t}();e.SubMesh=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(){}return t.CreateBox=function(t,i,r){var n=new e.Mesh(t,r),o=e.VertexData.CreateBox(i);return o.applyToMesh(n,i.updatable),n},t.CreateSphere=function(t,i,r){var n=new e.Mesh(t,r),o=e.VertexData.CreateSphere(i);return o.applyToMesh(n,i.updatable),n},t.CreateDisc=function(t,i,r){var n=new e.Mesh(t,r),o=e.VertexData.CreateDisc(i);return o.applyToMesh(n,i.updatable),n},t.CreateIcoSphere=function(t,i,r){var n=new e.Mesh(t,r),o=e.VertexData.CreateIcoSphere(i);return o.applyToMesh(n,i.updatable),n},t.CreateRibbon=function(t,i,r){var n=i.pathArray,o=i.closeArray,s=i.closePath,a=(i.offset,i.sideOrientation),h=i.instance,c=i.updatable;if(h){var l=function(t){for(var i=n[0].length,r=0,o=h.sideOrientation===e.Mesh.DOUBLESIDE?2:1,s=1;o>=s;s++)for(var a=0;a<n.length;a++){var c=n[a],l=c.length;i=l>i?i:l;for(var u=0;i>u;)t[r]=c[u].x,t[r+1]=c[u].y,t[r+2]=c[u].z,u++,r+=3;h._closePath&&(t[r]=c[0].x,t[r+1]=c[0].y,t[r+2]=c[0].z,r+=3)}},u=h.getVerticesData(e.VertexBuffer.PositionKind);if(l(u),h.updateVerticesData(e.VertexBuffer.PositionKind,u,!1,!1),!h.areNormalsFrozen){var f=h.getIndices(),d=h.getVerticesData(e.VertexBuffer.NormalKind);if(e.VertexData.ComputeNormals(u,f,d),h._closePath)for(var p=0,_=0,m=0;m<n.length;m++)p=3*h._idx[m],_=m+1<n.length?3*(h._idx[m+1]-1):d.length-3,d[p]=.5*(d[p]+d[_]),d[p+1]=.5*(d[p+1]+d[_+1]),d[p+2]=.5*(d[p+2]+d[_+2]),d[_]=d[p],d[_+1]=d[p+1],d[_+2]=d[p+2];h.updateVerticesData(e.VertexBuffer.NormalKind,d,!1,!1);
  13. }return h}var g=new e.Mesh(t,r);g.sideOrientation=a;var v=e.VertexData.CreateRibbon(i);return s&&(g._idx=v._idx),g._closePath=s,g._closeArray=o,v.applyToMesh(g,c),g},t.CreateCylinder=function(t,i,r){var n=new e.Mesh(t,r),o=e.VertexData.CreateCylinder(i);return o.applyToMesh(n,i.updatable),n},t.CreateTorus=function(t,i,r){var n=new e.Mesh(t,r),o=e.VertexData.CreateTorus(i);return o.applyToMesh(n,i.updatable),n},t.CreateTorusKnot=function(t,i,r){var n=new e.Mesh(t,r),o=e.VertexData.CreateTorusKnot(i);return o.applyToMesh(n,i.updatable),n},t.CreateLineSystem=function(t,i,r){var n=i.instance,o=i.lines;if(n){var s=function(e){for(var t=0,i=0;i<o.length;i++)for(var r=o[i],n=0;n<r.length;n++)e[t]=r[n].x,e[t+1]=r[n].y,e[t+2]=r[n].z,t+=3};return n.updateMeshPositions(s,!1),n}var a=new e.LinesMesh(t,r),h=e.VertexData.CreateLineSystem(i);return h.applyToMesh(a,i.updatable),a},t.CreateLines=function(e,i,r){var n=t.CreateLineSystem(e,{lines:[i.points],updatable:i.updatable,instance:i.instance},r);return n},t.CreateDashedLines=function(t,i,r){var n=i.points,o=i.instance,s=i.gapSize,a=(i.dashNb,i.dashSize);if(o){var h=function(t){var i=e.Vector3.Zero(),r=t.length/6,s=0,a=0,h=0,c=0,l=0,u=0,f=0,d=0;for(f=0;f<n.length-1;f++)n[f+1].subtractToRef(n[f],i),s+=i.length();for(h=s/r,c=o.dashSize*h/(o.dashSize+o.gapSize),f=0;f<n.length-1;f++)for(n[f+1].subtractToRef(n[f],i),a=Math.floor(i.length()/h),i.normalize(),d=0;a>d&&u<t.length;)l=h*d,t[u]=n[f].x+l*i.x,t[u+1]=n[f].y+l*i.y,t[u+2]=n[f].z+l*i.z,t[u+3]=n[f].x+(l+c)*i.x,t[u+4]=n[f].y+(l+c)*i.y,t[u+5]=n[f].z+(l+c)*i.z,u+=6,d++;for(;u<t.length;)t[u]=n[f].x,t[u+1]=n[f].y,t[u+2]=n[f].z,u+=3};return o.updateMeshPositions(h,!1),o}var c=new e.LinesMesh(t,r),l=e.VertexData.CreateDashedLines(i);return l.applyToMesh(c,i.updatable),c.dashSize=a,c.gapSize=s,c},t.ExtrudeShape=function(i,r,n){var o=r.path,s=r.shape,a=r.scale||1,h=r.rotation||0,c=0===r.cap?0:r.cap||e.Mesh.NO_CAP,l=r.updatable,u=0===r.sideOrientation?0:r.sideOrientation||e.Mesh.DEFAULTSIDE,f=r.instance;return t._ExtrudeShapeGeneric(i,s,o,a,h,null,null,!1,!1,c,!1,n,l,u,f)},t.ExtrudeShapeCustom=function(i,r,n){var o=r.path,s=r.shape,a=r.scaleFunction||function(){return 1},h=r.rotationFunction||function(){return 0},c=r.ribbonCloseArray||!1,l=r.ribbonClosePath||!1,u=0===r.cap?0:r.cap||e.Mesh.NO_CAP,f=r.updatable,d=0===r.sideOrientation?0:r.sideOrientation||e.Mesh.DEFAULTSIDE,p=r.instance;return t._ExtrudeShapeGeneric(i,s,o,null,null,a,h,c,l,u,!0,n,f,d,p)},t.CreateLathe=function(i,r,n){var o,s=r.arc<=0||r.arc>1?1:r.arc||1,a=void 0===r.closed?!0:r.closed,h=r.shape,c=r.radius||1,l=r.tessellation||64,u=r.updatable,f=0===r.sideOrientation?0:r.sideOrientation||e.Mesh.DEFAULTSIDE,d=r.cap||e.Mesh.NO_CAP,p=2*Math.PI,_=new Array,m=0,g=0,v=p/l*s,y=new Array;for(m=0;l>=m;m++){var y=[];for(d!=e.Mesh.CAP_START&&d!=e.Mesh.CAP_ALL||(y.push(new e.Vector3(0,h[0].y,0)),y.push(new e.Vector3(Math.cos(m*v)*h[0].x*c,h[0].y,Math.sin(m*v)*h[0].x*c))),g=0;g<h.length;g++)o=new e.Vector3(Math.cos(m*v)*h[g].x*c,h[g].y,Math.sin(m*v)*h[g].x*c),y.push(o);d!=e.Mesh.CAP_END&&d!=e.Mesh.CAP_ALL||(y.push(new e.Vector3(Math.cos(m*v)*h[h.length-1].x*c,h[h.length-1].y,Math.sin(m*v)*h[h.length-1].x*c)),y.push(new e.Vector3(0,h[h.length-1].y,0))),_.push(y)}var x=t.CreateRibbon(i,{pathArray:_,closeArray:a,sideOrientation:f,updatable:u},n);return x},t.CreatePlane=function(t,i,r){var n=new e.Mesh(t,r),o=e.VertexData.CreatePlane(i);if(o.applyToMesh(n,i.updatable),i.sourcePlane){n.translate(i.sourcePlane.normal,i.sourcePlane.d);var s=Math.acos(e.Vector3.Dot(i.sourcePlane.normal,e.Axis.Z)),a=e.Vector3.Cross(e.Axis.Z,i.sourcePlane.normal);n.rotate(a,s)}return n},t.CreateGround=function(t,i,r){var n=new e.GroundMesh(t,r);n._setReady(!1),n._subdivisions=i.subdivisions||1,n._width=i.width||1,n._height=i.height||1,n._maxX=n._width/2,n._maxZ=n._height/2,n._minX=-n._maxX,n._minZ=-n._maxZ;var o=e.VertexData.CreateGround(i);return o.applyToMesh(n,i.updatable),n._setReady(!0),n},t.CreateTiledGround=function(t,i,r){var n=new e.Mesh(t,r),o=e.VertexData.CreateTiledGround(i);return o.applyToMesh(n,i.updatable),n},t.CreateGroundFromHeightMap=function(t,i,r,n){var o=r.width||10,s=r.height||10,a=r.subdivisions||1,h=r.minHeight,c=r.maxHeight||10,l=r.updatable,u=r.onReady,f=new e.GroundMesh(t,n);f._subdivisions=a,f._width=o,f._height=s,f._maxX=f._width/2,f._maxZ=f._height/2,f._minX=-f._maxX,f._minZ=-f._maxZ,f._setReady(!1);var d=function(t){var i=document.createElement("canvas"),r=i.getContext("2d"),n=t.width,d=t.height;i.width=n,i.height=d,r.drawImage(t,0,0);var p=r.getImageData(0,0,n,d).data,_=e.VertexData.CreateGroundFromHeightMap({width:o,height:s,subdivisions:a,minHeight:h,maxHeight:c,buffer:p,bufferWidth:n,bufferHeight:d});_.applyToMesh(f,l),f._setReady(!0),u&&u(f)};return e.Tools.LoadImage(i,d,function(){},n.database),f},t.CreateTube=function(i,r,n){var o=r.path,s=r.radius||1,a=r.tessellation||64,h=r.radiusFunction,c=r.cap||e.Mesh.NO_CAP,l=r.updatable,u=r.sideOrientation||e.Mesh.DEFAULTSIDE,f=r.instance;r.arc=r.arc<=0||r.arc>1?1:r.arc||1;var d,p,_=function(t,i,r,n,o,s,a,h){for(var c,l,u,f,d=i.getTangents(),p=i.getNormals(),_=i.getDistances(),m=2*Math.PI,g=m/o*h,v=function(){return n},y=s||v,x=e.Tmp.Matrix[0],b=a===e.Mesh._NO_CAP||a===e.Mesh.CAP_END?0:2,P=0;P<t.length;P++){l=y(P,_[P]),c=Array(),u=p[P];for(var A=0;o>A;A++)e.Matrix.RotationAxisToRef(d[P],g*A,x),f=c[A]?c[A]:e.Vector3.Zero(),e.Vector3.TransformCoordinatesToRef(u,x,f),f.scaleInPlace(l).addInPlace(t[P]),c[A]=f;r[b]=c,b++}var T=function(e,i){for(var r=Array(),n=0;e>n;n++)r.push(t[i]);return r};switch(a){case e.Mesh.NO_CAP:break;case e.Mesh.CAP_START:r[0]=T(o,0),r[1]=r[2].slice(0);break;case e.Mesh.CAP_END:r[b]=r[b-1].slice(0),r[b+1]=T(o,t.length-1);break;case e.Mesh.CAP_ALL:r[0]=T(o,0),r[1]=r[2].slice(0),r[b]=r[b-1].slice(0),r[b+1]=T(o,t.length-1)}return r};if(f){var m=r.arc||f.arc;return d=f.path3D.update(o),p=_(o,d,f.pathArray,s,f.tessellation,h,f.cap,m),f=t.CreateRibbon(null,{pathArray:p,instance:f}),f.path3D=d,f.pathArray=p,f.arc=m,f}d=new e.Path3D(o);var g=new Array;c=0>c||c>3?0:c,p=_(o,d,g,s,a,h,c,r.arc);var v=t.CreateRibbon(i,{pathArray:p,closePath:!0,closeArray:!1,updatable:l,sideOrientation:u},n);return v.pathArray=p,v.path3D=d,v.tessellation=a,v.cap=c,v.arc=r.arc,v},t.CreatePolyhedron=function(t,i,r){var n=new e.Mesh(t,r),o=e.VertexData.CreatePolyhedron(i);return o.applyToMesh(n,i.updatable),n},t.CreateDecal=function(t,i,r){var n=i.getIndices(),o=i.getVerticesData(e.VertexBuffer.PositionKind),s=i.getVerticesData(e.VertexBuffer.NormalKind),a=r.position||e.Vector3.Zero(),h=r.normal||e.Vector3.Up(),c=r.size||new e.Vector3(1,1,1),l=r.angle||0;if(!h){var u=new e.Vector3(0,0,1),f=i.getScene().activeCamera,d=e.Vector3.TransformCoordinates(u,f.getWorldMatrix());h=f.globalPosition.subtract(d)}var p=-Math.atan2(h.z,h.x)-Math.PI/2,_=Math.sqrt(h.x*h.x+h.z*h.z),m=Math.atan2(h.y,_),g=e.Matrix.RotationYawPitchRoll(p,m,l).multiply(e.Matrix.Translation(a.x,a.y,a.z)),v=e.Matrix.Invert(g),y=i.getWorldMatrix(),x=y.multiply(v),b=new e.VertexData;b.indices=[],b.positions=[],b.normals=[],b.uvs=[];for(var P=0,A=function(t){var i=n[t],r=new e.PositionNormalVertex;return r.position=new e.Vector3(o[3*i],o[3*i+1],o[3*i+2]),r.position=e.Vector3.TransformCoordinates(r.position,x),r.normal=new e.Vector3(s[3*i],s[3*i+1],s[3*i+2]),r},T=function(t,i){if(0===t.length)return t;for(var r=.5*Math.abs(e.Vector3.Dot(c,i)),n=function(t,n){var o=e.Vector3.GetClipFactor(t.position,n.position,i,r);return new e.PositionNormalVertex(e.Vector3.Lerp(t.position,n.position,o),e.Vector3.Lerp(t.normal,n.normal,o))},o=new Array,s=0;s<t.length;s+=3){var a,h,l,u,f,d,p,_=0,m=e.Vector3.Dot(t[s].position,i)-r,g=e.Vector3.Dot(t[s+1].position,i)-r,v=e.Vector3.Dot(t[s+2].position,i)-r;switch(a=m>0,h=g>0,l=v>0,_=(a?1:0)+(h?1:0)+(l?1:0)){case 0:o.push(t[s]),o.push(t[s+1]),o.push(t[s+2]);break;case 1:if(a&&(u=t[s+1],f=t[s+2],d=n(t[s],u),p=n(t[s],f)),h){u=t[s],f=t[s+2],d=n(t[s+1],u),p=n(t[s+1],f),o.push(d),o.push(f.clone()),o.push(u.clone()),o.push(f.clone()),o.push(d.clone()),o.push(p);break}l&&(u=t[s],f=t[s+1],d=n(t[s+2],u),p=n(t[s+2],f)),o.push(u.clone()),o.push(f.clone()),o.push(d),o.push(p),o.push(d.clone()),o.push(f.clone());break;case 2:a||(u=t[s].clone(),f=n(u,t[s+1]),d=n(u,t[s+2]),o.push(u),o.push(f),o.push(d)),h||(u=t[s+1].clone(),f=n(u,t[s+2]),d=n(u,t[s]),o.push(u),o.push(f),o.push(d)),l||(u=t[s+2].clone(),f=n(u,t[s]),d=n(u,t[s+1]),o.push(u),o.push(f),o.push(d));break;case 3:}}return o},E=0;E<n.length;E+=3){var C=new Array;if(C.push(A(E)),C.push(A(E+1)),C.push(A(E+2)),C=T(C,new e.Vector3(1,0,0)),C=T(C,new e.Vector3(-1,0,0)),C=T(C,new e.Vector3(0,1,0)),C=T(C,new e.Vector3(0,-1,0)),C=T(C,new e.Vector3(0,0,1)),C=T(C,new e.Vector3(0,0,-1)),0!==C.length)for(var S=0;S<C.length;S++){var M=C[S];b.indices.push(P),M.position.toArray(b.positions,3*P),M.normal.toArray(b.normals,3*P),b.uvs.push(.5+M.position.x/c.x),b.uvs.push(.5+M.position.y/c.y),P++}}var I=new e.Mesh(t,i.getScene());return b.applyToMesh(I),I.position=a.clone(),I.rotation=new e.Vector3(m,p,l),I},t._ExtrudeShapeGeneric=function(t,i,r,n,o,s,a,h,c,l,u,f,d,p,_){var m,g,v=function(t,i,r,n,o,s,a,h,c,l){for(var u=r.getTangents(),f=r.getNormals(),d=r.getBinormals(),p=r.getDistances(),_=0,m=function(){return o},g=function(){return s},v=l?h:g,y=l?a:m,x=c===e.Mesh.NO_CAP||c===e.Mesh.CAP_END?0:2,b=e.Tmp.Matrix[0],P=0;P<i.length;P++){for(var A=new Array,T=v(P,p[P]),E=y(P,p[P]),C=0;C<t.length;C++){e.Matrix.RotationAxisToRef(u[P],_,b);var S=u[P].scale(t[C].z).add(f[P].scale(t[C].x)).add(d[P].scale(t[C].y)),M=A[C]?A[C]:e.Vector3.Zero();e.Vector3.TransformCoordinatesToRef(S,b,M),M.scaleInPlace(E).addInPlace(i[P]),A[C]=M}n[x]=A,_+=T,x++}var I=function(t){var i,r=Array(),n=e.Vector3.Zero();for(i=0;i<t.length;i++)n.addInPlace(t[i]);for(n.scaleInPlace(1/t.length),i=0;i<t.length;i++)r.push(n);return r};switch(c){case e.Mesh.NO_CAP:break;case e.Mesh.CAP_START:n[0]=I(n[2]),n[1]=n[2].slice(0);break;case e.Mesh.CAP_END:n[x]=n[x-1],n[x+1]=I(n[x-1]);break;case e.Mesh.CAP_ALL:n[0]=I(n[2]),n[1]=n[2].slice(0),n[x]=n[x-1],n[x+1]=I(n[x-1])}return n};if(_)return m=_.path3D.update(r),g=v(i,r,_.path3D,_.pathArray,n,o,s,a,_.cap,u),_=e.Mesh.CreateRibbon(null,g,null,null,null,null,null,null,_);m=new e.Path3D(r);var y=new Array;l=0>l||l>3?0:l,g=v(i,r,m,y,n,o,s,a,l,u);var x=e.Mesh.CreateRibbon(t,g,h,c,0,f,d,p);return x.pathArray=g,x.path3D=m,x.cap=l,x},t}();e.MeshBuilder=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(t){this.hasAlpha=!1,this.getAlphaFromRGB=!1,this.level=1,this.coordinatesIndex=0,this.coordinatesMode=e.Texture.EXPLICIT_MODE,this.wrapU=e.Texture.WRAP_ADDRESSMODE,this.wrapV=e.Texture.WRAP_ADDRESSMODE,this.anisotropicFilteringLevel=4,this.isCube=!1,this.isRenderTarget=!1,this.animations=new Array,this.onDisposeObservable=new e.Observable,this.delayLoadState=e.Engine.DELAYLOADSTATE_NONE,this._scene=t,this._scene.textures.push(this)}return t.prototype.toString=function(){return this.name},Object.defineProperty(t.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!0,configurable:!0}),t.prototype.getScene=function(){return this._scene},t.prototype.getTextureMatrix=function(){return null},t.prototype.getReflectionTextureMatrix=function(){return null},t.prototype.getInternalTexture=function(){return this._texture},t.prototype.isReady=function(){return this.delayLoadState===e.Engine.DELAYLOADSTATE_NOTLOADED?!0:this._texture?this._texture.isReady:!1},t.prototype.getSize=function(){return this._texture._width?{width:this._texture._width,height:this._texture._height}:this._texture._size?{width:this._texture._size,height:this._texture._size}:{width:0,height:0}},t.prototype.getBaseSize=function(){return this.isReady()&&this._texture?this._texture._size?{width:this._texture._size,height:this._texture._size}:{width:this._texture._baseWidth,height:this._texture._baseHeight}:{width:0,height:0}},t.prototype.scale=function(e){},Object.defineProperty(t.prototype,"canRescale",{get:function(){return!1},enumerable:!0,configurable:!0}),t.prototype._removeFromCache=function(e,t){for(var i=this._scene.getEngine().getLoadedTexturesCache(),r=0;r<i.length;r++){var n=i[r];if(n.url===e&&n.noMipmap===t)return void i.splice(r,1)}},t.prototype._getFromCache=function(e,t,i){for(var r=this._scene.getEngine().getLoadedTexturesCache(),n=0;n<r.length;n++){var o=r[n];if(o.url===e&&o.noMipmap===t&&(!i||i===o.samplingMode))return o.references++,o}return null},t.prototype.delayLoad=function(){},t.prototype.clone=function(){return null},t.prototype.releaseInternalTexture=function(){this._texture&&(this._scene.getEngine().releaseInternalTexture(this._texture),delete this._texture)},t.prototype.dispose=function(){this.getScene().stopAnimation(this);var e=this._scene.textures.indexOf(this);e>=0&&this._scene.textures.splice(e,1),void 0!==this._texture&&(this.releaseInternalTexture(),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear())},t.prototype.serialize=function(){if(!this.name)return null;var t=e.SerializationHelper.Serialize(this);return e.Animation.AppendSerializedAnimations(this,t),t},__decorate([e.serialize()],t.prototype,"name",void 0),__decorate([e.serialize()],t.prototype,"hasAlpha",void 0),__decorate([e.serialize()],t.prototype,"getAlphaFromRGB",void 0),__decorate([e.serialize()],t.prototype,"level",void 0),__decorate([e.serialize()],t.prototype,"coordinatesIndex",void 0),__decorate([e.serialize()],t.prototype,"coordinatesMode",void 0),__decorate([e.serialize()],t.prototype,"wrapU",void 0),__decorate([e.serialize()],t.prototype,"wrapV",void 0),__decorate([e.serialize()],t.prototype,"anisotropicFilteringLevel",void 0),__decorate([e.serialize()],t.prototype,"isCube",void 0),__decorate([e.serialize()],t.prototype,"isRenderTarget",void 0),t}();e.BaseTexture=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(t){function i(r,n,o,s,a,h,c,l,u){void 0===a&&(a=i.TRILINEAR_SAMPLINGMODE),void 0===h&&(h=null),void 0===c&&(c=null),void 0===l&&(l=null),void 0===u&&(u=!1),t.call(this,n),this.uOffset=0,this.vOffset=0,this.uScale=1,this.vScale=1,this.uAng=0,this.vAng=0,this.wAng=0,this.name=r,this.url=r,this._noMipmap=o,this._invertY=s,this._samplingMode=a,this._buffer=l,this._deleteBuffer=u,r&&(this._texture=this._getFromCache(r,o,a),this._texture?e.Tools.SetImmediate(function(){h&&h()}):n.useDelayedTextureLoading?(this.delayLoadState=e.Engine.DELAYLOADSTATE_NOTLOADED,this._delayedOnLoad=h,this._delayedOnError=c):(this._texture=n.getEngine().createTexture(r,o,s,n,this._samplingMode,h,c,this._buffer),u&&delete this._buffer))}return __extends(i,t),Object.defineProperty(i.prototype,"noMipmap",{get:function(){return this._noMipmap},enumerable:!0,configurable:!0}),i.prototype.delayLoad=function(){this.delayLoadState===e.Engine.DELAYLOADSTATE_NOTLOADED&&(this.delayLoadState=e.Engine.DELAYLOADSTATE_LOADED,this._texture=this._getFromCache(this.url,this._noMipmap,this._samplingMode),this._texture||(this._texture=this.getScene().getEngine().createTexture(this.url,this._noMipmap,this._invertY,this.getScene(),this._samplingMode,this._delayedOnLoad,this._delayedOnError,this._buffer),this._deleteBuffer&&delete this._buffer))},i.prototype.updateSamplingMode=function(e){this._texture&&(this._samplingMode=e,this.getScene().getEngine().updateTextureSamplingMode(e,this._texture))},i.prototype._prepareRowForTextureGeneration=function(t,i,r,n){t*=this.uScale,i*=this.vScale,t-=.5*this.uScale,i-=.5*this.vScale,r-=.5,e.Vector3.TransformCoordinatesFromFloatsToRef(t,i,r,this._rowGenerationMatrix,n),n.x+=.5*this.uScale+this.uOffset,n.y+=.5*this.vScale+this.vOffset,n.z+=.5},i.prototype.getTextureMatrix=function(){return this.uOffset===this._cachedUOffset&&this.vOffset===this._cachedVOffset&&this.uScale===this._cachedUScale&&this.vScale===this._cachedVScale&&this.uAng===this._cachedUAng&&this.vAng===this._cachedVAng&&this.wAng===this._cachedWAng?this._cachedTextureMatrix:(this._cachedUOffset=this.uOffset,this._cachedVOffset=this.vOffset,this._cachedUScale=this.uScale,this._cachedVScale=this.vScale,this._cachedUAng=this.uAng,this._cachedVAng=this.vAng,this._cachedWAng=this.wAng,this._cachedTextureMatrix||(this._cachedTextureMatrix=e.Matrix.Zero(),this._rowGenerationMatrix=new e.Matrix,this._t0=e.Vector3.Zero(),this._t1=e.Vector3.Zero(),this._t2=e.Vector3.Zero()),e.Matrix.RotationYawPitchRollToRef(this.vAng,this.uAng,this.wAng,this._rowGenerationMatrix),this._prepareRowForTextureGeneration(0,0,0,this._t0),this._prepareRowForTextureGeneration(1,0,0,this._t1),this._prepareRowForTextureGeneration(0,1,0,this._t2),this._t1.subtractInPlace(this._t0),this._t2.subtractInPlace(this._t0),e.Matrix.IdentityToRef(this._cachedTextureMatrix),this._cachedTextureMatrix.m[0]=this._t1.x,this._cachedTextureMatrix.m[1]=this._t1.y,this._cachedTextureMatrix.m[2]=this._t1.z,this._cachedTextureMatrix.m[4]=this._t2.x,this._cachedTextureMatrix.m[5]=this._t2.y,this._cachedTextureMatrix.m[6]=this._t2.z,this._cachedTextureMatrix.m[8]=this._t0.x,this._cachedTextureMatrix.m[9]=this._t0.y,this._cachedTextureMatrix.m[10]=this._t0.z,this._cachedTextureMatrix)},i.prototype.getReflectionTextureMatrix=function(){if(this.uOffset===this._cachedUOffset&&this.vOffset===this._cachedVOffset&&this.uScale===this._cachedUScale&&this.vScale===this._cachedVScale&&this.coordinatesMode===this._cachedCoordinatesMode)return this._cachedTextureMatrix;switch(this._cachedTextureMatrix||(this._cachedTextureMatrix=e.Matrix.Zero(),this._projectionModeMatrix=e.Matrix.Zero()),this._cachedCoordinatesMode=this.coordinatesMode,this.coordinatesMode){case i.PLANAR_MODE:e.Matrix.IdentityToRef(this._cachedTextureMatrix),this._cachedTextureMatrix[0]=this.uScale,this._cachedTextureMatrix[5]=this.vScale,this._cachedTextureMatrix[12]=this.uOffset,this._cachedTextureMatrix[13]=this.vOffset;break;case i.PROJECTION_MODE:e.Matrix.IdentityToRef(this._projectionModeMatrix),this._projectionModeMatrix.m[0]=.5,this._projectionModeMatrix.m[5]=-.5,this._projectionModeMatrix.m[10]=0,this._projectionModeMatrix.m[12]=.5,this._projectionModeMatrix.m[13]=.5,this._projectionModeMatrix.m[14]=1,this._projectionModeMatrix.m[15]=1,this.getScene().getProjectionMatrix().multiplyToRef(this._projectionModeMatrix,this._cachedTextureMatrix);break;default:e.Matrix.IdentityToRef(this._cachedTextureMatrix)}return this._cachedTextureMatrix},i.prototype.clone=function(){var t=this;return e.SerializationHelper.Clone(function(){return new i(t._texture.url,t.getScene(),t._noMipmap,t._invertY,t._samplingMode)},this)},i.CreateFromBase64String=function(e,t,r,n,o,s,a,h){return void 0===s&&(s=i.TRILINEAR_SAMPLINGMODE),void 0===a&&(a=null),void 0===h&&(h=null),new i("data:"+t,r,n,o,s,a,h,e)},i.Parse=function(t,r,n){if(t.isCube)return e.CubeTexture.Parse(t,r,n);if(!t.name&&!t.isRenderTarget)return null;var o=e.SerializationHelper.Parse(function(){if(t.mirrorPlane){var o=new e.MirrorTexture(t.name,t.renderTargetSize,r);return o._waitingRenderList=t.renderList,o.mirrorPlane=e.Plane.FromArray(t.mirrorPlane),o}if(t.isRenderTarget){var s=new e.RenderTargetTexture(t.name,t.renderTargetSize,r);return s._waitingRenderList=t.renderList,s}var a;return a=t.base64String?i.CreateFromBase64String(t.base64String,t.name,r):new i(n+t.name,r)},t,r);if(t.animations)for(var s=0;s<t.animations.length;s++){var a=t.animations[s];o.animations.push(e.Animation.Parse(a))}return o},i.NEAREST_SAMPLINGMODE=1,i.BILINEAR_SAMPLINGMODE=2,i.TRILINEAR_SAMPLINGMODE=3,i.EXPLICIT_MODE=0,i.SPHERICAL_MODE=1,i.PLANAR_MODE=2,i.CUBIC_MODE=3,i.PROJECTION_MODE=4,i.SKYBOX_MODE=5,i.INVCUBIC_MODE=6,i.EQUIRECTANGULAR_MODE=7,i.FIXED_EQUIRECTANGULAR_MODE=8,i.CLAMP_ADDRESSMODE=0,i.WRAP_ADDRESSMODE=1,i.MIRROR_ADDRESSMODE=2,__decorate([e.serialize()],i.prototype,"url",void 0),__decorate([e.serialize()],i.prototype,"uOffset",void 0),__decorate([e.serialize()],i.prototype,"vOffset",void 0),__decorate([e.serialize()],i.prototype,"uScale",void 0),__decorate([e.serialize()],i.prototype,"vScale",void 0),__decorate([e.serialize()],i.prototype,"uAng",void 0),__decorate([e.serialize()],i.prototype,"vAng",void 0),__decorate([e.serialize()],i.prototype,"wAng",void 0),i}(e.BaseTexture);e.Texture=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(t){function i(i,r,n,o,s){if(t.call(this,r),this.coordinatesMode=e.Texture.CUBIC_MODE,this.name=i,this.url=i,this._noMipmap=o,this.hasAlpha=!1,i||s){if(this._texture=this._getFromCache(i,o),!s){n||(n=["_px.jpg","_py.jpg","_pz.jpg","_nx.jpg","_ny.jpg","_nz.jpg"]),s=[];for(var a=0;a<n.length;a++)s.push(i+n[a]);this._extensions=n}this._files=s,this._texture||(r.useDelayedTextureLoading?this.delayLoadState=e.Engine.DELAYLOADSTATE_NOTLOADED:this._texture=r.getEngine().createCubeTexture(i,r,s,o)),this.isCube=!0,this._textureMatrix=e.Matrix.Identity()}}return __extends(i,t),i.CreateFromImages=function(e,t,r){return new i("",t,null,r,e)},i.prototype.delayLoad=function(){this.delayLoadState===e.Engine.DELAYLOADSTATE_NOTLOADED&&(this.delayLoadState=e.Engine.DELAYLOADSTATE_LOADED,this._texture=this._getFromCache(this.url,this._noMipmap),this._texture||(this._texture=this.getScene().getEngine().createCubeTexture(this.url,this.getScene(),this._extensions)))},i.prototype.getReflectionTextureMatrix=function(){return this._textureMatrix},i.Parse=function(t,i,r){var n=e.SerializationHelper.Parse(function(){return new e.CubeTexture(r+t.name,i,t.extensions)},t,i);if(t.animations)for(var o=0;o<t.animations.length;o++){var s=t.animations[o];n.animations.push(e.Animation.Parse(s))}return n},i.prototype.clone=function(){var t=this;return e.SerializationHelper.Clone(function(){return new i(t.url,t.getScene(),t._extensions,t._noMipmap,t._files)},this)},i}(e.BaseTexture);e.CubeTexture=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(t){function i(i,r,n,o,s,a,h,c){void 0===s&&(s=!0),void 0===a&&(a=e.Engine.TEXTURETYPE_UNSIGNED_INT),void 0===h&&(h=!1),void 0===c&&(c=e.Texture.TRILINEAR_SAMPLINGMODE),t.call(this,null,n,!o),this.isCube=h,this.renderList=new Array,this.renderParticles=!0,this.renderSprites=!1,this.coordinatesMode=e.Texture.PROJECTION_MODE,this.onAfterUnbindObservable=new e.Observable,this.onBeforeRenderObservable=new e.Observable,this.onAfterRenderObservable=new e.Observable,this.onClearObservable=new e.Observable,this._currentRefreshId=-1,this._refreshRate=1,this.name=i,this.isRenderTarget=!0,this._size=r,this._generateMipMaps=o,this._doNotChangeAspectRatio=s,c===e.Texture.NEAREST_SAMPLINGMODE&&(this.wrapU=e.Texture.CLAMP_ADDRESSMODE,this.wrapV=e.Texture.CLAMP_ADDRESSMODE),h?(this._texture=n.getEngine().createRenderTargetCubeTexture(r,{generateMipMaps:o,samplingMode:c}),this.coordinatesMode=e.Texture.INVCUBIC_MODE,this._textureMatrix=e.Matrix.Identity()):this._texture=n.getEngine().createRenderTargetTexture(r,{generateMipMaps:o,type:a,samplingMode:c}),this._renderingManager=new e.RenderingManager(n)}return __extends(i,t),Object.defineProperty(i,"REFRESHRATE_RENDER_ONCE",{get:function(){return i._REFRESHRATE_RENDER_ONCE},enumerable:!0,configurable:!0}),Object.defineProperty(i,"REFRESHRATE_RENDER_ONEVERYFRAME",{get:function(){return i._REFRESHRATE_RENDER_ONEVERYFRAME},enumerable:!0,configurable:!0}),Object.defineProperty(i,"REFRESHRATE_RENDER_ONEVERYTWOFRAMES",{get:function(){return i._REFRESHRATE_RENDER_ONEVERYTWOFRAMES},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"onAfterUnbind",{set:function(e){this._onAfterUnbindObserver&&this.onAfterUnbindObservable.remove(this._onAfterUnbindObserver),this._onAfterUnbindObserver=this.onAfterUnbindObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"onBeforeRender",{set:function(e){this._onBeforeRenderObserver&&this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),this._onBeforeRenderObserver=this.onBeforeRenderObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"onAfterRender",{set:function(e){this._onAfterRenderObserver&&this.onAfterRenderObservable.remove(this._onAfterRenderObserver),this._onAfterRenderObserver=this.onAfterRenderObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"onClear",{set:function(e){this._onClearObserver&&this.onClearObservable.remove(this._onClearObserver),this._onClearObserver=this.onClearObservable.add(e)},enumerable:!0,configurable:!0}),i.prototype.resetRefreshCounter=function(){this._currentRefreshId=-1},Object.defineProperty(i.prototype,"refreshRate",{get:function(){return this._refreshRate},set:function(e){this._refreshRate=e,this.resetRefreshCounter()},enumerable:!0,configurable:!0}),i.prototype._shouldRender=function(){return-1===this._currentRefreshId?(this._currentRefreshId=1,!0):this.refreshRate===this._currentRefreshId?(this._currentRefreshId=1,!0):(this._currentRefreshId++,!1)},i.prototype.isReady=function(){return this.getScene().renderTargetsEnabled?t.prototype.isReady.call(this):!1},i.prototype.getRenderSize=function(){return this._size},Object.defineProperty(i.prototype,"canRescale",{get:function(){return!0},enumerable:!0,configurable:!0}),i.prototype.scale=function(e){var t=this._size*e;this.resize(t,this._generateMipMaps)},i.prototype.getReflectionTextureMatrix=function(){return this.isCube?this._textureMatrix:t.prototype.getReflectionTextureMatrix.call(this)},i.prototype.resize=function(e,t){this.releaseInternalTexture(),this.isCube?this._texture=this.getScene().getEngine().createRenderTargetCubeTexture(e):this._texture=this.getScene().getEngine().createRenderTargetTexture(e,t)},i.prototype.render=function(e,t){var i=this.getScene();if(void 0!==this.useCameraPostProcesses&&(e=this.useCameraPostProcesses),this.activeCamera&&this.activeCamera!==i.activeCamera&&i.setTransformMatrix(this.activeCamera.getViewMatrix(),this.activeCamera.getProjectionMatrix(!0)),this._waitingRenderList){this.renderList=[];for(var r=0;r<this._waitingRenderList.length;r++){var n=this._waitingRenderList[r];this.renderList.push(i.getMeshByID(n))}delete this._waitingRenderList}if(this.renderListPredicate){this.renderList.splice(0);for(var o=this.getScene().meshes,r=0;r<o.length;r++){var s=o[r];this.renderListPredicate(s)&&this.renderList.push(s)}}if(!this.renderList||0!==this.renderList.length){this._renderingManager.reset();for(var a=this.renderList?this.renderList:i.getActiveMeshes().data,h=i.getRenderId(),c=0;c<a.length;c++){var s=a[c];if(s){if(!s.isReady()){this.resetRefreshCounter();continue}if(s._preActivateForIntermediateRendering(h),s.isEnabled()&&s.isVisible&&s.subMeshes&&0!==(s.layerMask&i.activeCamera.layerMask)){s._activate(h);for(var l=0;l<s.subMeshes.length;l++){var u=s.subMeshes[l];i._activeIndices+=u.indexCount,this._renderingManager.dispatch(u)}}}}if(this.isCube)for(var f=0;6>f;f++)this.renderToTarget(f,a,e,t),i.incrementRenderId(),i.resetCachedMaterial();else this.renderToTarget(0,a,e,t);this.onAfterUnbindObservable.notifyObservers(this),this.activeCamera&&this.activeCamera!==i.activeCamera&&i.setTransformMatrix(i.activeCamera.getViewMatrix(),i.activeCamera.getProjectionMatrix(!0)),i.resetCachedMaterial()}},i.prototype.renderToTarget=function(t,i,r,n){var o=this.getScene(),s=o.getEngine();r&&o.postProcessManager._prepareFrame(this._texture)||(this.isCube?s.bindFramebuffer(this._texture,t):s.bindFramebuffer(this._texture)),this.onBeforeRenderObservable.notifyObservers(t),this.onClearObservable.hasObservers()?this.onClearObservable.notifyObservers(s):s.clear(o.clearColor,!0,!0),this._doNotChangeAspectRatio||o.updateTransformMatrix(!0),this._renderingManager.render(this.customRenderFunction,i,this.renderParticles,this.renderSprites),r&&o.postProcessManager._finalizeFrame(!1,this._texture,t),this._doNotChangeAspectRatio||o.updateTransformMatrix(!0),this.onAfterRenderObservable.notifyObservers(t),n&&e.Tools.DumpFramebuffer(this._size,this._size,s),this.isCube&&5!==t||(this.isCube&&5===t&&s.generateMipMapsForCubemap(this._texture),s.unBindFramebuffer(this._texture,this.isCube))},i.prototype.clone=function(){var e=this.getSize(),t=new i(this.name,e.width,this.getScene(),this._generateMipMaps);return t.hasAlpha=this.hasAlpha,t.level=this.level,t.coordinatesMode=this.coordinatesMode,t.renderList=this.renderList.slice(0),t},i.prototype.serialize=function(){if(!this.name)return null;var e=t.prototype.serialize.call(this);e.renderTargetSize=this.getRenderSize(),e.renderList=[];for(var i=0;i<this.renderList.length;i++)e.renderList.push(this.renderList[i].id);return e},i._REFRESHRATE_RENDER_ONCE=0,i._REFRESHRATE_RENDER_ONEVERYFRAME=1,i._REFRESHRATE_RENDER_ONEVERYTWOFRAMES=2,i}(e.Texture);e.RenderTargetTexture=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(t){function i(i,r,n,o,s,a,h){void 0===a&&(a=!0),void 0===h&&(h=!1),t.call(this,null,o,!a),this.isCube=h,this.isEnabled=!0,this._currentRefreshId=-1,this._refreshRate=1,this._vertexBuffers={},this._uniforms=new Array,this._samplers=new Array,this._textures=new Array,this._floats=new Array,this._floatsArrays={},this._colors3=new Array,this._colors4=new Array,this._vectors2=new Array,this._vectors3=new Array,this._matrices=new Array,this._fallbackTextureUsed=!1,o._proceduralTextures.push(this),this.name=i,this.isRenderTarget=!0,this._size=r,this._generateMipMaps=a,this.setFragment(n),this._fallbackTexture=s;var c=o.getEngine();h?(this._texture=c.createRenderTargetCubeTexture(r,{generateMipMaps:a}),this.setFloat("face",0)):this._texture=c.createRenderTargetTexture(r,a);var l=[];l.push(1,1),l.push(-1,1),l.push(-1,-1),l.push(1,-1),this._vertexBuffers[e.VertexBuffer.PositionKind]=new e.VertexBuffer(c,l,e.VertexBuffer.PositionKind,!1,!1,2);var u=[];u.push(0),u.push(1),u.push(2),u.push(0),u.push(2),u.push(3),this._indexBuffer=c.createIndexBuffer(u)}return __extends(i,t),i.prototype.reset=function(){if(void 0!==this._effect){var e=this.getScene().getEngine();e._releaseEffect(this._effect)}},i.prototype.isReady=function(){var t,i=this,r=this.getScene().getEngine();return this._fragment?this._fallbackTextureUsed?!0:(t=void 0!==this._fragment.fragmentElement?{vertex:"procedural",fragmentElement:this._fragment.fragmentElement}:{vertex:"procedural",fragment:this._fragment},this._effect=r.createEffect(t,[e.VertexBuffer.PositionKind],this._uniforms,this._samplers,"",null,null,function(){i.releaseInternalTexture(),i._fallbackTexture&&(i._texture=i._fallbackTexture._texture,i._texture.references++),i._fallbackTextureUsed=!0}),this._effect.isReady()):!1},i.prototype.resetRefreshCounter=function(){this._currentRefreshId=-1},i.prototype.setFragment=function(e){this._fragment=e},Object.defineProperty(i.prototype,"refreshRate",{get:function(){return this._refreshRate},set:function(e){this._refreshRate=e,this.resetRefreshCounter()},enumerable:!0,configurable:!0}),i.prototype._shouldRender=function(){return this.isEnabled&&this.isReady()&&this._texture?this._fallbackTextureUsed?!1:-1===this._currentRefreshId?(this._currentRefreshId=1,!0):this.refreshRate===this._currentRefreshId?(this._currentRefreshId=1,!0):(this._currentRefreshId++,!1):!1},i.prototype.getRenderSize=function(){return this._size},i.prototype.resize=function(e,t){this._fallbackTextureUsed||(this.releaseInternalTexture(),this._texture=this.getScene().getEngine().createRenderTargetTexture(e,t))},i.prototype._checkUniform=function(e){-1===this._uniforms.indexOf(e)&&this._uniforms.push(e)},i.prototype.setTexture=function(e,t){return-1===this._samplers.indexOf(e)&&this._samplers.push(e),this._textures[e]=t,this},i.prototype.setFloat=function(e,t){return this._checkUniform(e),this._floats[e]=t,this},i.prototype.setFloats=function(e,t){return this._checkUniform(e),this._floatsArrays[e]=t,this},i.prototype.setColor3=function(e,t){return this._checkUniform(e),this._colors3[e]=t,this},i.prototype.setColor4=function(e,t){return this._checkUniform(e),this._colors4[e]=t,this},i.prototype.setVector2=function(e,t){return this._checkUniform(e),
  14. this._vectors2[e]=t,this},i.prototype.setVector3=function(e,t){return this._checkUniform(e),this._vectors3[e]=t,this},i.prototype.setMatrix=function(e,t){return this._checkUniform(e),this._matrices[e]=t,this},i.prototype.render=function(e){var t=this.getScene(),i=t.getEngine();i.enableEffect(this._effect),i.setState(!1);for(var r in this._textures)this._effect.setTexture(r,this._textures[r]);for(r in this._floats)this._effect.setFloat(r,this._floats[r]);for(r in this._floatsArrays)this._effect.setArray(r,this._floatsArrays[r]);for(r in this._colors3)this._effect.setColor3(r,this._colors3[r]);for(r in this._colors4){var n=this._colors4[r];this._effect.setFloat4(r,n.r,n.g,n.b,n.a)}for(r in this._vectors2)this._effect.setVector2(r,this._vectors2[r]);for(r in this._vectors3)this._effect.setVector3(r,this._vectors3[r]);for(r in this._matrices)this._effect.setMatrix(r,this._matrices[r]);if(i.bindBuffers(this._vertexBuffers,this._indexBuffer,this._effect),this.isCube)for(var o=0;6>o;o++)i.bindFramebuffer(this._texture,o),this._effect.setFloat("face",o),i.clear(t.clearColor,!0,!0),i.draw(!0,0,6),5===o&&i.generateMipMapsForCubemap(this._texture);else i.bindFramebuffer(this._texture),i.clear(t.clearColor,!0,!0),i.draw(!0,0,6);i.unBindFramebuffer(this._texture,this.isCube),this.onGenerated&&this.onGenerated()},i.prototype.clone=function(){var e=this.getSize(),t=new i(this.name,e.width,this._fragment,this.getScene(),this._fallbackTexture,this._generateMipMaps);return t.hasAlpha=this.hasAlpha,t.level=this.level,t.coordinatesMode=this.coordinatesMode,t},i.prototype.dispose=function(){var i=this.getScene()._proceduralTextures.indexOf(this);i>=0&&this.getScene()._proceduralTextures.splice(i,1);var r=this._vertexBuffers[e.VertexBuffer.PositionKind];r&&(r.dispose(),this._vertexBuffers[e.VertexBuffer.PositionKind]=null),this._indexBuffer&&this.getScene().getEngine()._releaseBuffer(this._indexBuffer)&&(this._indexBuffer=null),t.prototype.dispose.call(this)},i}(e.Texture);e.ProceduralTexture=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(t){function i(i,r,n,o){var s=this;t.call(this,i,r,n,o,!0),this.mirrorPlane=new e.Plane(0,1,0,1),this._transformMatrix=e.Matrix.Zero(),this._mirrorMatrix=e.Matrix.Zero(),this.onBeforeRenderObservable.add(function(){e.Matrix.ReflectionToRef(s.mirrorPlane,s._mirrorMatrix),s._savedViewMatrix=n.getViewMatrix(),s._mirrorMatrix.multiplyToRef(s._savedViewMatrix,s._transformMatrix),n.setTransformMatrix(s._transformMatrix,n.getProjectionMatrix()),n.clipPlane=s.mirrorPlane,n.getEngine().cullBackFaces=!1,n._mirroredCameraPosition=e.Vector3.TransformCoordinates(n.activeCamera.position,s._mirrorMatrix)}),this.onAfterRenderObservable.add(function(){n.setTransformMatrix(s._savedViewMatrix,n.getProjectionMatrix()),n.getEngine().cullBackFaces=!0,n._mirroredCameraPosition=null,delete n.clipPlane})}return __extends(i,t),i.prototype.clone=function(){var e=this.getSize(),t=new i(this.name,e.width,this.getScene(),this._generateMipMaps);return t.hasAlpha=this.hasAlpha,t.level=this.level,t.mirrorPlane=this.mirrorPlane.clone(),t.renderList=this.renderList.slice(0),t},i.prototype.serialize=function(){if(!this.name)return null;var e=t.prototype.serialize.call(this);return e.mirrorPlane=this.mirrorPlane.asArray(),e},i}(e.RenderTargetTexture);e.MirrorTexture=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(t){function i(i,r,n,o){var s=this;t.call(this,i,r,n,o,!0),this.refractionPlane=new e.Plane(0,1,0,1),this.depth=2,this.onBeforeRenderObservable.add(function(){n.clipPlane=s.refractionPlane}),this.onAfterRenderObservable.add(function(){delete n.clipPlane})}return __extends(i,t),i.prototype.clone=function(){var e=this.getSize(),t=new i(this.name,e.width,this.getScene(),this._generateMipMaps);return t.hasAlpha=this.hasAlpha,t.level=this.level,t.refractionPlane=this.refractionPlane.clone(),t.renderList=this.renderList.slice(0),t.depth=this.depth,t},i.prototype.serialize=function(){if(!this.name)return null;var e=t.prototype.serialize.call(this);return e.mirrorPlane=this.refractionPlane.asArray(),e.depth=this.depth,e},i}(e.RenderTargetTexture);e.RefractionTexture=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(t){function i(i,r,n,o,s){void 0===s&&(s=e.Texture.TRILINEAR_SAMPLINGMODE),t.call(this,null,n,!o),this.name=i,this.wrapU=e.Texture.CLAMP_ADDRESSMODE,this.wrapV=e.Texture.CLAMP_ADDRESSMODE,this._generateMipMaps=o,r.getContext?(this._canvas=r,this._texture=n.getEngine().createDynamicTexture(r.width,r.height,o,s)):(this._canvas=document.createElement("canvas"),r.width?this._texture=n.getEngine().createDynamicTexture(r.width,r.height,o,s):this._texture=n.getEngine().createDynamicTexture(r,r,o,s));var a=this.getSize();this._canvas.width=a.width,this._canvas.height=a.height,this._context=this._canvas.getContext("2d")}return __extends(i,t),Object.defineProperty(i.prototype,"canRescale",{get:function(){return!0},enumerable:!0,configurable:!0}),i.prototype.scale=function(e){var t=this.getSize();t.width*=e,t.height*=e,this._canvas.width=t.width,this._canvas.height=t.height,this.releaseInternalTexture(),this._texture=this.getScene().getEngine().createDynamicTexture(t.width,t.height,this._generateMipMaps,this._samplingMode)},i.prototype.getContext=function(){return this._context},i.prototype.clear=function(){var e=this.getSize();this._context.fillRect(0,0,e.width,e.height)},i.prototype.update=function(e){this.getScene().getEngine().updateDynamicTexture(this._texture,this._canvas,void 0===e?!0:e)},i.prototype.drawText=function(e,t,i,r,n,o,s,a){void 0===a&&(a=!0);var h=this.getSize();if(o&&(this._context.fillStyle=o,this._context.fillRect(0,0,h.width,h.height)),this._context.font=r,null===t){var c=this._context.measureText(e);t=(h.width-c.width)/2}this._context.fillStyle=n,this._context.fillText(e,t,i),a&&this.update(s)},i.prototype.clone=function(){var e=this.getSize(),t=new i(this.name,e,this.getScene(),this._generateMipMaps);return t.hasAlpha=this.hasAlpha,t.level=this.level,t.wrapU=this.wrapU,t.wrapV=this.wrapV,t},i}(e.Texture);e.DynamicTexture=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(t){function i(i,r,n,o,s,a){var h=this;void 0===o&&(o=!1),void 0===s&&(s=!1),void 0===a&&(a=e.Texture.TRILINEAR_SAMPLINGMODE),t.call(this,null,n,!o,s),this._autoLaunch=!0;var c;this.name=i,r instanceof HTMLVideoElement?this.video=r:(c=r,this.video=document.createElement("video"),this.video.autoplay=!1,this.video.loop=!0),this._generateMipMaps=o,this._samplingMode=a,e.Tools.IsExponentOfTwo(this.video.videoWidth)&&e.Tools.IsExponentOfTwo(this.video.videoHeight)?(this.wrapU=e.Texture.WRAP_ADDRESSMODE,this.wrapV=e.Texture.WRAP_ADDRESSMODE):(this.wrapU=e.Texture.CLAMP_ADDRESSMODE,this.wrapV=e.Texture.CLAMP_ADDRESSMODE,this._generateMipMaps=!1),c?(this.video.addEventListener("canplaythrough",function(){h._createTexture()}),c.forEach(function(e){var t=document.createElement("source");t.src=e,h.video.appendChild(t)})):this._createTexture(),this._lastUpdate=e.Tools.Now}return __extends(i,t),i.prototype._createTexture=function(){this._texture=this.getScene().getEngine().createDynamicTexture(this.video.videoWidth,this.video.videoHeight,this._generateMipMaps,this._samplingMode),this._texture.isReady=!0},i.prototype.update=function(){this._autoLaunch&&(this._autoLaunch=!1,this.video.play());var t=e.Tools.Now;return t-this._lastUpdate<15||this.video.readyState!==this.video.HAVE_ENOUGH_DATA?!1:(this._lastUpdate=t,this.getScene().getEngine().updateVideoTexture(this._texture,this.video,this._invertY),!0)},i}(e.Texture);e.VideoTexture=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(t){function i(e,i,r,n,o,s){t.call(this,e,r,null,n,o,s),this._animate=!0,this._time=0,this._texturePath=i,this.loadJson(i),this.refreshRate=1}return __extends(i,t),i.prototype.loadJson=function(t){function i(){e.Tools.Log("No config file found in "+t+" trying to use ShadersStore or DOM element");try{n.setFragment(n._texturePath)}catch(i){e.Tools.Error("No json or ShaderStore or DOM element found for CustomProceduralTexture")}}var r=this,n=this,o=t+"/config.json",s=new XMLHttpRequest;s.open("GET",o,!0),s.addEventListener("load",function(){if(200===s.status||e.Tools.ValidateXHRData(s,1))try{r._config=JSON.parse(s.response),r.updateShaderUniforms(),r.updateTextures(),r.setFragment(r._texturePath+"/custom"),r._animate=r._config.animate,r.refreshRate=r._config.refreshrate}catch(t){i()}else i()},!1),s.addEventListener("error",function(){i()},!1);try{s.send()}catch(a){e.Tools.Error("CustomProceduralTexture: Error on XHR send request.")}},i.prototype.isReady=function(){if(!t.prototype.isReady.call(this))return!1;for(var e in this._textures){var i=this._textures[e];if(!i.isReady())return!1}return!0},i.prototype.render=function(e){this._animate&&(this._time+=.03*this.getScene().getAnimationRatio(),this.updateShaderUniforms()),t.prototype.render.call(this,e)},i.prototype.updateTextures=function(){for(var t=0;t<this._config.sampler2Ds.length;t++)this.setTexture(this._config.sampler2Ds[t].sample2Dname,new e.Texture(this._texturePath+"/"+this._config.sampler2Ds[t].textureRelativeUrl,this.getScene()))},i.prototype.updateShaderUniforms=function(){if(this._config)for(var t=0;t<this._config.uniforms.length;t++){var i=this._config.uniforms[t];switch(i.type){case"float":this.setFloat(i.name,i.value);break;case"color3":this.setColor3(i.name,new e.Color3(i.r,i.g,i.b));break;case"color4":this.setColor4(i.name,new e.Color4(i.r,i.g,i.b,i.a));break;case"vector2":this.setVector2(i.name,new e.Vector2(i.x,i.y));break;case"vector3":this.setVector3(i.name,new e.Vector3(i.x,i.y,i.z))}}this.setFloat("time",this._time)},Object.defineProperty(i.prototype,"animate",{get:function(){return this._animate},set:function(e){this._animate=e},enumerable:!0,configurable:!0}),i}(e.ProceduralTexture);e.CustomProceduralTexture=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(){this._defines={},this._currentRank=32,this._maxRank=-1}return t.prototype.addFallback=function(e,t){this._defines[e]||(e<this._currentRank&&(this._currentRank=e),e>this._maxRank&&(this._maxRank=e),this._defines[e]=new Array),this._defines[e].push(t)},t.prototype.addCPUSkinningFallback=function(e,t){this._meshRank=e,this._mesh=t,e>this._maxRank&&(this._maxRank=e)},Object.defineProperty(t.prototype,"isMoreFallbacks",{get:function(){return this._currentRank<=this._maxRank},enumerable:!0,configurable:!0}),t.prototype.reduce=function(t){for(var i=this._defines[this._currentRank],r=0;r<i.length;r++)t=t.replace("#define "+i[r],"");return this._mesh&&this._currentRank===this._meshRank&&(this._mesh.computeBonesUsingShaders=!1,t=t.replace("#define NUM_BONE_INFLUENCERS "+this._mesh.numBoneInfluencers,"#define NUM_BONE_INFLUENCERS 0"),e.Tools.Log("Falling back to CPU skinning for "+this._mesh.name)),this._currentRank++,t},t}();e.EffectFallbacks=t;var i=function(){function t(e,t,i,r,n,o,s,a,h,c){var l=this;this._isReady=!1,this._compilationError="",this._valueCache=[],this._engine=n,this.name=e,this.defines=o,this._uniformsNames=i.concat(r),this._samplers=r,this._attributesNames=t,this.onError=h,this.onCompiled=a,this._indexParameters=c;var u,f;e.vertexElement?(u=document.getElementById(e.vertexElement),u||(u=e.vertexElement)):u=e.vertex||e,e.fragmentElement?(f=document.getElementById(e.fragmentElement),f||(f=e.fragmentElement)):f=e.fragment||e,this._loadVertexShader(u,function(e){l._processIncludes(e,function(e){l._loadFragmentShader(f,function(i){l._processIncludes(i,function(i){l._prepareEffect(e,i,t,o,s)})})})})}return t.prototype.isReady=function(){return this._isReady},t.prototype.getProgram=function(){return this._program},t.prototype.getAttributesNames=function(){return this._attributesNames},t.prototype.getAttributeLocation=function(e){return this._attributes[e]},t.prototype.getAttributeLocationByName=function(e){var t=this._attributesNames.indexOf(e);return this._attributes[t]},t.prototype.getAttributesCount=function(){return this._attributes.length},t.prototype.getUniformIndex=function(e){return this._uniformsNames.indexOf(e)},t.prototype.getUniform=function(e){return this._uniforms[this._uniformsNames.indexOf(e)]},t.prototype.getSamplers=function(){return this._samplers},t.prototype.getCompilationError=function(){return this._compilationError},t.prototype._loadVertexShader=function(i,r){if(i instanceof HTMLElement){var n=e.Tools.GetDOMTextContent(i);return void r(n)}if(t.ShadersStore[i+"VertexShader"])return void r(t.ShadersStore[i+"VertexShader"]);var o;o="."===i[0]||"/"===i[0]||i.indexOf("http")>-1?i:e.Engine.ShadersRepository+i,e.Tools.LoadFile(o+".vertex.fx",r)},t.prototype._loadFragmentShader=function(i,r){if(i instanceof HTMLElement){var n=e.Tools.GetDOMTextContent(i);return void r(n)}if(t.ShadersStore[i+"PixelShader"])return void r(t.ShadersStore[i+"PixelShader"]);if(t.ShadersStore[i+"FragmentShader"])return void r(t.ShadersStore[i+"FragmentShader"]);var o;o="."===i[0]||"/"===i[0]||i.indexOf("http")>-1?i:e.Engine.ShadersRepository+i,e.Tools.LoadFile(o+".fragment.fx",r)},t.prototype._dumpShadersName=function(){this.name.vertexElement?(e.Tools.Error("Vertex shader:"+this.name.vertexElement),e.Tools.Error("Fragment shader:"+this.name.fragmentElement)):this.name.vertex?(e.Tools.Error("Vertex shader:"+this.name.vertex),e.Tools.Error("Fragment shader:"+this.name.fragment)):(e.Tools.Error("Vertex shader:"+this.name),e.Tools.Error("Fragment shader:"+this.name))},t.prototype._processIncludes=function(i,r){for(var n=this,o=/#include<(.+)>(\((.*)\))*(\[(.*)\])*/g,s=o.exec(i),a=new String(i);null!=s;){var h=s[1];if(!t.IncludesShadersStore[h]){var c=e.Engine.ShadersRepository+"ShadersInclude/"+h+".fx";return void e.Tools.LoadFile(c,function(e){t.IncludesShadersStore[h]=e,n._processIncludes(a,r)})}var l=t.IncludesShadersStore[h];if(s[2])for(var u=s[3].split(","),f=0;f<u.length;f+=2){var d=new RegExp(u[f],"g"),p=u[f+1];l=l.replace(d,p)}if(s[4]){var _=s[5];if(-1!==_.indexOf("..")){var m=_.split(".."),g=parseInt(m[0]),v=parseInt(m[1]),y=l.slice(0);l="",isNaN(v)&&(v=this._indexParameters[m[1]]);for(var x=g;v>=x;x++)l+=y.replace(/\{X\}/g,x)+"\n"}else l=l.replace(/\{X\}/g,_)}a=a.replace(s[0],l),s=o.exec(i)}r(a)},t.prototype._processPrecision=function(e){return-1===e.indexOf("precision highp float")?e=this._engine.getCaps().highPrecisionShaderSupported?"precision highp float;\n"+e:"precision mediump float;\n"+e:this._engine.getCaps().highPrecisionShaderSupported||(e=e.replace("precision highp float","precision mediump float")),e},t.prototype._prepareEffect=function(t,i,r,n,o){try{var s=this._engine;t=this._processPrecision(t),i=this._processPrecision(i),this._program=s.createShaderProgram(t,i,n),this._uniforms=s.getUniforms(this._program,this._uniformsNames),this._attributes=s.getAttributes(this._program,r);for(var a=0;a<this._samplers.length;a++){var h=this.getUniform(this._samplers[a]);null==h&&(this._samplers.splice(a,1),a--)}s.bindSamplers(this),this._isReady=!0,this.onCompiled&&this.onCompiled(this)}catch(c){if(-1!==c.message.indexOf("highp"))return t=t.replace("precision highp float","precision mediump float"),i=i.replace("precision highp float","precision mediump float"),void this._prepareEffect(t,i,r,n,o);o&&o.isMoreFallbacks?(e.Tools.Error("Unable to compile effect with current defines. Trying next fallback."),this._dumpShadersName(),n=o.reduce(n),this._prepareEffect(t,i,r,n,o)):(e.Tools.Error("Unable to compile effect: "),this._dumpShadersName(),e.Tools.Error("Defines: "+n),e.Tools.Error("Error: "+c.message),this._compilationError=c.message,this.onError&&this.onError(this,this._compilationError))}},Object.defineProperty(t.prototype,"isSupported",{get:function(){return""===this._compilationError},enumerable:!0,configurable:!0}),t.prototype._bindTexture=function(e,t){this._engine._bindTexture(this._samplers.indexOf(e),t)},t.prototype.setTexture=function(e,t){this._engine.setTexture(this._samplers.indexOf(e),t)},t.prototype.setTextureFromPostProcess=function(e,t){this._engine.setTextureFromPostProcess(this._samplers.indexOf(e),t)},t.prototype._cacheMatrix=function(t,i){this._valueCache[t]||(this._valueCache[t]=new e.Matrix);for(var r=0;16>r;r++)this._valueCache[t].m[r]=i.m[r]},t.prototype._cacheFloat2=function(e,t,i){return this._valueCache[e]?(this._valueCache[e][0]=t,void(this._valueCache[e][1]=i)):void(this._valueCache[e]=[t,i])},t.prototype._cacheFloat3=function(e,t,i,r){return this._valueCache[e]?(this._valueCache[e][0]=t,this._valueCache[e][1]=i,void(this._valueCache[e][2]=r)):void(this._valueCache[e]=[t,i,r])},t.prototype._cacheFloat4=function(e,t,i,r,n){return this._valueCache[e]?(this._valueCache[e][0]=t,this._valueCache[e][1]=i,this._valueCache[e][2]=r,void(this._valueCache[e][3]=n)):void(this._valueCache[e]=[t,i,r,n])},t.prototype.setArray=function(e,t){return this._engine.setArray(this.getUniform(e),t),this},t.prototype.setArray2=function(e,t){return this._engine.setArray2(this.getUniform(e),t),this},t.prototype.setArray3=function(e,t){return this._engine.setArray3(this.getUniform(e),t),this},t.prototype.setArray4=function(e,t){return this._engine.setArray4(this.getUniform(e),t),this},t.prototype.setMatrices=function(e,t){return this._engine.setMatrices(this.getUniform(e),t),this},t.prototype.setMatrix=function(e,t){return this._engine.setMatrix(this.getUniform(e),t),this},t.prototype.setMatrix3x3=function(e,t){return this._engine.setMatrix3x3(this.getUniform(e),t),this},t.prototype.setMatrix2x2=function(e,t){return this._engine.setMatrix2x2(this.getUniform(e),t),this},t.prototype.setFloat=function(e,t){return this._valueCache[e]&&this._valueCache[e]===t?this:(this._valueCache[e]=t,this._engine.setFloat(this.getUniform(e),t),this)},t.prototype.setBool=function(e,t){return this._valueCache[e]&&this._valueCache[e]===t?this:(this._valueCache[e]=t,this._engine.setBool(this.getUniform(e),t?1:0),this)},t.prototype.setVector2=function(e,t){return this._valueCache[e]&&this._valueCache[e][0]===t.x&&this._valueCache[e][1]===t.y?this:(this._cacheFloat2(e,t.x,t.y),this._engine.setFloat2(this.getUniform(e),t.x,t.y),this)},t.prototype.setFloat2=function(e,t,i){return this._valueCache[e]&&this._valueCache[e][0]===t&&this._valueCache[e][1]===i?this:(this._cacheFloat2(e,t,i),this._engine.setFloat2(this.getUniform(e),t,i),this)},t.prototype.setVector3=function(e,t){return this._valueCache[e]&&this._valueCache[e][0]===t.x&&this._valueCache[e][1]===t.y&&this._valueCache[e][2]===t.z?this:(this._cacheFloat3(e,t.x,t.y,t.z),this._engine.setFloat3(this.getUniform(e),t.x,t.y,t.z),this)},t.prototype.setFloat3=function(e,t,i,r){return this._valueCache[e]&&this._valueCache[e][0]===t&&this._valueCache[e][1]===i&&this._valueCache[e][2]===r?this:(this._cacheFloat3(e,t,i,r),this._engine.setFloat3(this.getUniform(e),t,i,r),this)},t.prototype.setVector4=function(e,t){return this._valueCache[e]&&this._valueCache[e][0]===t.x&&this._valueCache[e][1]===t.y&&this._valueCache[e][2]===t.z&&this._valueCache[e][3]===t.w?this:(this._cacheFloat4(e,t.x,t.y,t.z,t.w),this._engine.setFloat4(this.getUniform(e),t.x,t.y,t.z,t.w),this)},t.prototype.setFloat4=function(e,t,i,r,n){return this._valueCache[e]&&this._valueCache[e][0]===t&&this._valueCache[e][1]===i&&this._valueCache[e][2]===r&&this._valueCache[e][3]===n?this:(this._cacheFloat4(e,t,i,r,n),this._engine.setFloat4(this.getUniform(e),t,i,r,n),this)},t.prototype.setColor3=function(e,t){return this._valueCache[e]&&this._valueCache[e][0]===t.r&&this._valueCache[e][1]===t.g&&this._valueCache[e][2]===t.b?this:(this._cacheFloat3(e,t.r,t.g,t.b),this._engine.setColor3(this.getUniform(e),t),this)},t.prototype.setColor4=function(e,t,i){return this._valueCache[e]&&this._valueCache[e][0]===t.r&&this._valueCache[e][1]===t.g&&this._valueCache[e][2]===t.b&&this._valueCache[e][3]===i?this:(this._cacheFloat4(e,t.r,t.g,t.b,i),this._engine.setColor4(this.getUniform(e),t,i),this)},t.ShadersStore={},t.IncludesShadersStore={},t}();e.Effect=i}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(){}return t.PrepareDefinesForLights=function(t,i,r,n){void 0===n&&(n=4);for(var o=0,s=!1,a=!1,h=0;h<t.lights.length;h++){var c=t.lights[h];if(c.isEnabled()){if(c._excludedMeshesIds.length>0){for(var l=0;l<c._excludedMeshesIds.length;l++){var u=t.getMeshByID(c._excludedMeshesIds[l]);u&&c.excludedMeshes.push(u)}c._excludedMeshesIds=[]}if(c._includedOnlyMeshesIds.length>0){for(var f=0;f<c._includedOnlyMeshesIds.length;f++){var d=t.getMeshByID(c._includedOnlyMeshesIds[f]);d&&c.includedOnlyMeshes.push(d)}c._includedOnlyMeshesIds=[]}if(c.canAffectMesh(i)){s=!0,void 0===r["LIGHT"+o]&&(a=!0),r["LIGHT"+o]=!0;var p;if(p=c instanceof e.SpotLight?"SPOTLIGHT"+o:c instanceof e.HemisphericLight?"HEMILIGHT"+o:c instanceof e.PointLight?"POINTLIGHT"+o:"DIRLIGHT"+o,void 0===r[p]&&(a=!0),r[p]=!0,c.specular.equalsFloats(0,0,0)||void 0===r.SPECULARTERM||(r.SPECULARTERM=!0),t.shadowsEnabled){var _=c.getShadowGenerator();i&&i.receiveShadows&&_&&(void 0===r["SHADOW"+o]&&(a=!0),r["SHADOW"+o]=!0,r.SHADOWS=!0,(_.useVarianceShadowMap||_.useBlurVarianceShadowMap)&&(void 0===r["SHADOWVSM"+o]&&(a=!0),r["SHADOWVSM"+o]=!0),_.usePoissonSampling&&(void 0===r["SHADOWPCF"+o]&&(a=!0),r["SHADOWPCF"+o]=!0))}if(o++,o===n)break}}}return a&&r.rebuild(),s},t.PrepareUniformsAndSamplersList=function(e,t,i,r){void 0===r&&(r=4);for(var n=0;r>n&&i["LIGHT"+n];n++)e.push("vLightData"+n,"vLightDiffuse"+n,"vLightSpecular"+n,"vLightDirection"+n,"vLightGround"+n,"lightMatrix"+n,"shadowsInfo"+n),t.push("shadowSampler"+n)},t.HandleFallbacksForShadows=function(e,t,i){void 0===i&&(i=4);for(var r=0;i>r&&e["LIGHT"+r];r++)r>0&&t.addFallback(r,"LIGHT"+r),e["SHADOW"+r]&&t.addFallback(0,"SHADOW"+r),e["SHADOWPCF"+r]&&t.addFallback(0,"SHADOWPCF"+r),e["SHADOWVSM"+r]&&t.addFallback(0,"SHADOWVSM"+r)},t.PrepareAttributesForBones=function(t,i,r,n){r.NUM_BONE_INFLUENCERS>0&&(n.addCPUSkinningFallback(0,i),t.push(e.VertexBuffer.MatricesIndicesKind),t.push(e.VertexBuffer.MatricesWeightsKind),r.NUM_BONE_INFLUENCERS>4&&(t.push(e.VertexBuffer.MatricesIndicesExtraKind),t.push(e.VertexBuffer.MatricesWeightsExtraKind)))},t.PrepareAttributesForInstances=function(e,t){t.INSTANCES&&(e.push("world0"),e.push("world1"),e.push("world2"),e.push("world3"))},t.BindLightShadow=function(e,t,i,r,n,o){var s=e.getShadowGenerator();return i.receiveShadows&&s&&(e.needCube()?o||(o=!0,n.setFloat2("depthValues",t.activeCamera.minZ,t.activeCamera.maxZ)):n.setMatrix("lightMatrix"+r,s.getTransformMatrix()),n.setTexture("shadowSampler"+r,s.getShadowMapForRendering()),n.setFloat3("shadowsInfo"+r,s.getDarkness(),s.blurScale/s.getShadowMap().getSize().width,s.bias)),o},t.BindLightProperties=function(t,i,r){t instanceof e.PointLight?t.transferToEffect(i,"vLightData"+r):t instanceof e.DirectionalLight?t.transferToEffect(i,"vLightData"+r):t instanceof e.SpotLight?t.transferToEffect(i,"vLightData"+r,"vLightDirection"+r):t instanceof e.HemisphericLight&&t.transferToEffect(i,"vLightData"+r,"vLightGround"+r)},t.BindLights=function(i,r,n,o,s){void 0===s&&(s=4);for(var a=0,h=!1,c=0;c<i.lights.length;c++){var l=i.lights[c];if(l.isEnabled()&&l.canAffectMesh(r)&&(t.BindLightProperties(l,n,a),l.diffuse.scaleToRef(l.intensity,e.Tmp.Color3[0]),n.setColor4("vLightDiffuse"+a,e.Tmp.Color3[0],l.range),o.SPECULARTERM&&(l.specular.scaleToRef(l.intensity,e.Tmp.Color3[1]),n.setColor3("vLightSpecular"+a,e.Tmp.Color3[1])),i.shadowsEnabled&&(h=this.BindLightShadow(l,i,r,a,n,h)),a++,a===s))break}},t.BindFogParameters=function(t,i,r){t.fogEnabled&&i.applyFog&&t.fogMode!==e.Scene.FOGMODE_NONE&&(r.setFloat4("vFogInfos",t.fogMode,t.fogStart,t.fogEnd,t.fogDensity),r.setColor3("vFogColor",t.fogColor))},t.BindBonesParameters=function(e,t){e&&e.useBones&&e.computeBonesUsingShaders&&t.setMatrices("mBones",e.skeleton.getTransformMatrices(e))},t.BindLogDepth=function(e,t,i){e.LOGARITHMICDEPTH&&t.setFloat("logarithmicDepthConstant",2/(Math.log(i.activeCamera.maxZ+1)/Math.LN2))},t.BindClipPlane=function(e,t){if(t.clipPlane){var i=t.clipPlane;e.setFloat4("vClipPlane",i.normal.x,i.normal.y,i.normal.z,i.d)}},t}();e.MaterialHelper=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(){this.isEnabled=!0,this.leftColor=e.Color3.White(),this.rightColor=e.Color3.Black(),this.bias=0,this.power=1}return t.prototype.clone=function(){var i=new t;return e.Tools.DeepCopy(this,i),new t},t.prototype.serialize=function(){var e={};return e.isEnabled=this.isEnabled,e.leftColor=this.leftColor,e.rightColor=this.rightColor,e.bias=this.bias,e.power=this.power,e},t.Parse=function(i){var r=new t;return r.isEnabled=i.isEnabled,r.leftColor=e.Color3.FromArray(i.leftColor),r.rightColor=e.Color3.FromArray(i.rightColor),r.bias=i.bias,r.power=i.power||1,r},t}();e.FresnelParameters=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function e(){}return e.prototype.rebuild=function(){this._keys&&delete this._keys,this._keys=Object.keys(this)},e.prototype.isEqual=function(e){if(this._keys.length!==e._keys.length)return!1;for(var t=0;t<this._keys.length;t++){var i=this._keys[t];if(this[i]!==e[i])return!1}return!0},e.prototype.cloneTo=function(e){this._keys.length!==e._keys.length&&(e._keys=this._keys.slice(0));for(var t=0;t<this._keys.length;t++){var i=this._keys[t];e[i]=this[i]}},e.prototype.reset=function(){for(var e=0;e<this._keys.length;e++){var t=this._keys[e];"number"==typeof this[t]?this[t]=0:this[t]=!1}},e.prototype.toString=function(){for(var e="",t=0;t<this._keys.length;t++){var i=this._keys[t];"number"==typeof this[i]?e+="#define "+i+" "+this[i]+"\n":this[i]&&(e+="#define "+i+"\n")}return e},e}();e.MaterialDefines=t;var i=function(){function t(i,r,n){this.name=i,this.checkReadyOnEveryCall=!1,this.checkReadyOnlyOnce=!1,this.state="",this.alpha=1,this.backFaceCulling=!0,this.sideOrientation=t.CounterClockWiseSideOrientation,this.onDisposeObservable=new e.Observable,this.onBindObservable=new e.Observable,this.alphaMode=e.Engine.ALPHA_COMBINE,this.disableDepthWrite=!1,this.fogEnabled=!0,this.pointSize=1,this.zOffset=0,this._wasPreviouslyReady=!1,this._fillMode=t.TriangleFillMode,this.id=i,this._scene=r,n||r.materials.push(this)}return Object.defineProperty(t,"TriangleFillMode",{get:function(){return t._TriangleFillMode},enumerable:!0,configurable:!0}),Object.defineProperty(t,"WireFrameFillMode",{get:function(){return t._WireFrameFillMode},enumerable:!0,configurable:!0}),Object.defineProperty(t,"PointFillMode",{get:function(){return t._PointFillMode},enumerable:!0,configurable:!0}),Object.defineProperty(t,"ClockWiseSideOrientation",{get:function(){return t._ClockWiseSideOrientation},enumerable:!0,configurable:!0}),Object.defineProperty(t,"CounterClockWiseSideOrientation",{get:function(){return t._CounterClockWiseSideOrientation},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onBind",{set:function(e){this._onBindObserver&&this.onBindObservable.remove(this._onBindObserver),this._onBindObserver=this.onBindObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"wireframe",{get:function(){return this._fillMode===t.WireFrameFillMode},set:function(e){this._fillMode=e?t.WireFrameFillMode:t.TriangleFillMode},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"pointsCloud",{get:function(){return this._fillMode===t.PointFillMode},set:function(e){this._fillMode=e?t.PointFillMode:t.TriangleFillMode},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"fillMode",{get:function(){return this._fillMode},set:function(e){this._fillMode=e},enumerable:!0,configurable:!0}),t.prototype.toString=function(e){var t="Name: "+this.name;return t},Object.defineProperty(t.prototype,"isFrozen",{get:function(){return this.checkReadyOnlyOnce},enumerable:!0,configurable:!0}),t.prototype.freeze=function(){this.checkReadyOnlyOnce=!0},t.prototype.unfreeze=function(){this.checkReadyOnlyOnce=!1},t.prototype.isReady=function(e,t){return!0},t.prototype.getEffect=function(){return this._effect},t.prototype.getScene=function(){return this._scene},t.prototype.needAlphaBlending=function(){return this.alpha<1},t.prototype.needAlphaTesting=function(){return!1},t.prototype.getAlphaTestTexture=function(){return null},t.prototype.markDirty=function(){this._wasPreviouslyReady=!1},t.prototype._preBind=function(){var e=this._scene.getEngine();e.enableEffect(this._effect),e.setState(this.backFaceCulling,this.zOffset,!1,this.sideOrientation===t.ClockWiseSideOrientation)},t.prototype.bind=function(e,t){if(this._scene._cachedMaterial=this,this.onBindObservable.notifyObservers(t),this.disableDepthWrite){var i=this._scene.getEngine();this._cachedDepthWriteState=i.getDepthWrite(),i.setDepthWrite(!1)}},t.prototype.bindOnlyWorldMatrix=function(e){},t.prototype.unbind=function(){if(this.disableDepthWrite){var e=this._scene.getEngine();e.setDepthWrite(this._cachedDepthWriteState)}},t.prototype.clone=function(e){return null},t.prototype.getBindedMeshes=function(){for(var e=new Array,t=0;t<this._scene.meshes.length;t++){var i=this._scene.meshes[t];i.material===this&&e.push(i)}return e},t.prototype.dispose=function(e,t){this.getScene().stopAnimation(this);var i=this._scene.materials.indexOf(this);for(i>=0&&this._scene.materials.splice(i,1),e&&this._effect&&(this._scene.getEngine()._releaseEffect(this._effect),this._effect=null),i=0;i<this._scene.meshes.length;i++){var r=this._scene.meshes[i];r.material===this&&(r.material=null)}this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this.onBindObservable.clear()},t.prototype.serialize=function(){return e.SerializationHelper.Serialize(this)},t.ParseMultiMaterial=function(t,i){var r=new e.MultiMaterial(t.name,i);r.id=t.id,e.Tags.AddTagsTo(r,t.tags);for(var n=0;n<t.materials.length;n++){var o=t.materials[n];o?r.subMaterials.push(i.getMaterialByID(o)):r.subMaterials.push(null)}return r},t.Parse=function(t,i,r){if(!t.customType)return e.StandardMaterial.Parse(t,i,r);var n=e.Tools.Instantiate(t.customType);return n.Parse(t,i,r)},t._TriangleFillMode=0,t._WireFrameFillMode=1,t._PointFillMode=2,t._ClockWiseSideOrientation=0,t._CounterClockWiseSideOrientation=1,__decorate([e.serialize()],t.prototype,"id",void 0),__decorate([e.serialize()],t.prototype,"checkReadyOnEveryCall",void 0),__decorate([e.serialize()],t.prototype,"checkReadyOnlyOnce",void 0),__decorate([e.serialize()],t.prototype,"state",void 0),__decorate([e.serialize()],t.prototype,"alpha",void 0),__decorate([e.serialize()],t.prototype,"backFaceCulling",void 0),__decorate([e.serialize()],t.prototype,"sideOrientation",void 0),__decorate([e.serialize()],t.prototype,"alphaMode",void 0),__decorate([e.serialize()],t.prototype,"disableDepthWrite",void 0),__decorate([e.serialize()],t.prototype,"fogEnabled",void 0),__decorate([e.serialize()],t.prototype,"pointSize",void 0),__decorate([e.serialize()],t.prototype,"zOffset",void 0),__decorate([e.serialize()],t.prototype,"wireframe",null),__decorate([e.serialize()],t.prototype,"pointsCloud",null),__decorate([e.serialize()],t.prototype,"fillMode",null),t}();e.Material=i}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(e){function t(){e.call(this),this.DIFFUSE=!1,this.AMBIENT=!1,this.OPACITY=!1,this.OPACITYRGB=!1,this.REFLECTION=!1,this.EMISSIVE=!1,this.SPECULAR=!1,this.BUMP=!1,this.PARALLAX=!1,this.PARALLAXOCCLUSION=!1,this.SPECULAROVERALPHA=!1,this.CLIPPLANE=!1,this.ALPHATEST=!1,this.ALPHAFROMDIFFUSE=!1,this.POINTSIZE=!1,this.FOG=!1,this.SPECULARTERM=!1,this.DIFFUSEFRESNEL=!1,this.OPACITYFRESNEL=!1,this.REFLECTIONFRESNEL=!1,this.REFRACTIONFRESNEL=!1,this.EMISSIVEFRESNEL=!1,this.FRESNEL=!1,this.NORMAL=!1,this.UV1=!1,this.UV2=!1,this.VERTEXCOLOR=!1,this.VERTEXALPHA=!1,this.NUM_BONE_INFLUENCERS=0,this.BonesPerMesh=0,this.INSTANCES=!1,this.GLOSSINESS=!1,
  15. this.ROUGHNESS=!1,this.EMISSIVEASILLUMINATION=!1,this.LINKEMISSIVEWITHDIFFUSE=!1,this.REFLECTIONFRESNELFROMSPECULAR=!1,this.LIGHTMAP=!1,this.USELIGHTMAPASSHADOWMAP=!1,this.REFLECTIONMAP_3D=!1,this.REFLECTIONMAP_SPHERICAL=!1,this.REFLECTIONMAP_PLANAR=!1,this.REFLECTIONMAP_CUBIC=!1,this.REFLECTIONMAP_PROJECTION=!1,this.REFLECTIONMAP_SKYBOX=!1,this.REFLECTIONMAP_EXPLICIT=!1,this.REFLECTIONMAP_EQUIRECTANGULAR=!1,this.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,this.INVERTCUBICMAP=!1,this.LOGARITHMICDEPTH=!1,this.REFRACTION=!1,this.REFRACTIONMAP_3D=!1,this.REFLECTIONOVERALPHA=!1,this.INVERTNORMALMAPX=!1,this.INVERTNORMALMAPY=!1,this.rebuild()}return __extends(t,e),t}(e.MaterialDefines),i=function(i){function r(r,n){var o=this;i.call(this,r,n),this.ambientColor=new e.Color3(0,0,0),this.diffuseColor=new e.Color3(1,1,1),this.specularColor=new e.Color3(1,1,1),this.emissiveColor=new e.Color3(0,0,0),this.specularPower=64,this.useAlphaFromDiffuseTexture=!1,this.useEmissiveAsIllumination=!1,this.linkEmissiveWithDiffuse=!1,this.useReflectionFresnelFromSpecular=!1,this.useSpecularOverAlpha=!1,this.useReflectionOverAlpha=!1,this.disableLighting=!1,this.useParallax=!1,this.useParallaxOcclusion=!1,this.parallaxScaleBias=.05,this.roughness=0,this.indexOfRefraction=.98,this.invertRefractionY=!0,this.useLightmapAsShadowmap=!1,this.useGlossinessFromSpecularMapAlpha=!1,this.maxSimultaneousLights=4,this.invertNormalMapX=!1,this.invertNormalMapY=!1,this._renderTargets=new e.SmartArray(16),this._worldViewProjectionMatrix=e.Matrix.Zero(),this._globalAmbientColor=new e.Color3(0,0,0),this._defines=new t,this._cachedDefines=new t,this._cachedDefines.BonesPerMesh=-1,this.getRenderTargetTextures=function(){return o._renderTargets.reset(),o.reflectionTexture&&o.reflectionTexture.isRenderTarget&&o._renderTargets.push(o.reflectionTexture),o.refractionTexture&&o.refractionTexture.isRenderTarget&&o._renderTargets.push(o.refractionTexture),o._renderTargets}}return __extends(r,i),Object.defineProperty(r.prototype,"useLogarithmicDepth",{get:function(){return this._useLogarithmicDepth},set:function(e){this._useLogarithmicDepth=e&&this.getScene().getEngine().getCaps().fragmentDepthSupported},enumerable:!0,configurable:!0}),r.prototype.needAlphaBlending=function(){return this.alpha<1||null!=this.opacityTexture||this._shouldUseAlphaFromDiffuseTexture()||this.opacityFresnelParameters&&this.opacityFresnelParameters.isEnabled},r.prototype.needAlphaTesting=function(){return null!=this.diffuseTexture&&this.diffuseTexture.hasAlpha},r.prototype._shouldUseAlphaFromDiffuseTexture=function(){return null!=this.diffuseTexture&&this.diffuseTexture.hasAlpha&&this.useAlphaFromDiffuseTexture},r.prototype.getAlphaTestTexture=function(){return this.diffuseTexture},r.prototype._checkCache=function(e,t,i){return t?this._defines.INSTANCES!==i?!1:!(!t._materialDefines||!t._materialDefines.isEqual(this._defines)):!0},r.prototype.isReady=function(i,n){if(this.isFrozen&&this._wasPreviouslyReady)return!0;var o=this.getScene();if(!this.checkReadyOnEveryCall&&this._renderId===o.getRenderId()&&this._checkCache(o,i,n))return!0;var s=o.getEngine(),a=!1,h=!1;if(this._defines.reset(),o.texturesEnabled){if(this.diffuseTexture&&r.DiffuseTextureEnabled){if(!this.diffuseTexture.isReady())return!1;h=!0,this._defines.DIFFUSE=!0}if(this.ambientTexture&&r.AmbientTextureEnabled){if(!this.ambientTexture.isReady())return!1;h=!0,this._defines.AMBIENT=!0}if(this.opacityTexture&&r.OpacityTextureEnabled){if(!this.opacityTexture.isReady())return!1;h=!0,this._defines.OPACITY=!0,this.opacityTexture.getAlphaFromRGB&&(this._defines.OPACITYRGB=!0)}if(this.reflectionTexture&&r.ReflectionTextureEnabled){if(!this.reflectionTexture.isReady())return!1;switch(a=!0,this._defines.REFLECTION=!0,this.roughness>0&&(this._defines.ROUGHNESS=!0),this.useReflectionOverAlpha&&(this._defines.REFLECTIONOVERALPHA=!0),this.reflectionTexture.coordinatesMode===e.Texture.INVCUBIC_MODE&&(this._defines.INVERTCUBICMAP=!0),this._defines.REFLECTIONMAP_3D=this.reflectionTexture.isCube,this.reflectionTexture.coordinatesMode){case e.Texture.CUBIC_MODE:case e.Texture.INVCUBIC_MODE:this._defines.REFLECTIONMAP_CUBIC=!0;break;case e.Texture.EXPLICIT_MODE:this._defines.REFLECTIONMAP_EXPLICIT=!0;break;case e.Texture.PLANAR_MODE:this._defines.REFLECTIONMAP_PLANAR=!0;break;case e.Texture.PROJECTION_MODE:this._defines.REFLECTIONMAP_PROJECTION=!0;break;case e.Texture.SKYBOX_MODE:this._defines.REFLECTIONMAP_SKYBOX=!0;break;case e.Texture.SPHERICAL_MODE:this._defines.REFLECTIONMAP_SPHERICAL=!0;break;case e.Texture.EQUIRECTANGULAR_MODE:this._defines.REFLECTIONMAP_EQUIRECTANGULAR=!0;break;case e.Texture.FIXED_EQUIRECTANGULAR_MODE:this._defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!0}}if(this.emissiveTexture&&r.EmissiveTextureEnabled){if(!this.emissiveTexture.isReady())return!1;h=!0,this._defines.EMISSIVE=!0}if(this.lightmapTexture&&r.LightmapTextureEnabled){if(!this.lightmapTexture.isReady())return!1;h=!0,this._defines.LIGHTMAP=!0,this._defines.USELIGHTMAPASSHADOWMAP=this.useLightmapAsShadowmap}if(this.specularTexture&&r.SpecularTextureEnabled){if(!this.specularTexture.isReady())return!1;h=!0,this._defines.SPECULAR=!0,this._defines.GLOSSINESS=this.useGlossinessFromSpecularMapAlpha}if(o.getEngine().getCaps().standardDerivatives&&this.bumpTexture&&r.BumpTextureEnabled){if(!this.bumpTexture.isReady())return!1;h=!0,this._defines.BUMP=!0,this.useParallax&&(this._defines.PARALLAX=!0,this.useParallaxOcclusion&&(this._defines.PARALLAXOCCLUSION=!0)),this.invertNormalMapX&&(this._defines.INVERTNORMALMAPX=!0),this.invertNormalMapY&&(this._defines.INVERTNORMALMAPY=!0)}if(this.refractionTexture&&r.RefractionTextureEnabled){if(!this.refractionTexture.isReady())return!1;h=!0,this._defines.REFRACTION=!0,this._defines.REFRACTIONMAP_3D=this.refractionTexture.isCube}}if(o.clipPlane&&(this._defines.CLIPPLANE=!0),s.getAlphaTesting()&&(this._defines.ALPHATEST=!0),this._shouldUseAlphaFromDiffuseTexture()&&(this._defines.ALPHAFROMDIFFUSE=!0),this.useEmissiveAsIllumination&&(this._defines.EMISSIVEASILLUMINATION=!0),this.linkEmissiveWithDiffuse&&(this._defines.LINKEMISSIVEWITHDIFFUSE=!0),this.useLogarithmicDepth&&(this._defines.LOGARITHMICDEPTH=!0),(this.pointsCloud||o.forcePointsCloud)&&(this._defines.POINTSIZE=!0),o.fogEnabled&&i&&i.applyFog&&o.fogMode!==e.Scene.FOGMODE_NONE&&this.fogEnabled&&(this._defines.FOG=!0),o.lightsEnabled&&!this.disableLighting&&(a=e.MaterialHelper.PrepareDefinesForLights(o,i,this._defines,this.maxSimultaneousLights)),r.FresnelEnabled&&(this.diffuseFresnelParameters&&this.diffuseFresnelParameters.isEnabled||this.opacityFresnelParameters&&this.opacityFresnelParameters.isEnabled||this.emissiveFresnelParameters&&this.emissiveFresnelParameters.isEnabled||this.refractionFresnelParameters&&this.refractionFresnelParameters.isEnabled||this.reflectionFresnelParameters&&this.reflectionFresnelParameters.isEnabled)&&(this.diffuseFresnelParameters&&this.diffuseFresnelParameters.isEnabled&&(this._defines.DIFFUSEFRESNEL=!0),this.opacityFresnelParameters&&this.opacityFresnelParameters.isEnabled&&(this._defines.OPACITYFRESNEL=!0),this.reflectionFresnelParameters&&this.reflectionFresnelParameters.isEnabled&&(this._defines.REFLECTIONFRESNEL=!0,this.useReflectionFresnelFromSpecular&&(this._defines.REFLECTIONFRESNELFROMSPECULAR=!0)),this.refractionFresnelParameters&&this.refractionFresnelParameters.isEnabled&&(this._defines.REFRACTIONFRESNEL=!0),this.emissiveFresnelParameters&&this.emissiveFresnelParameters.isEnabled&&(this._defines.EMISSIVEFRESNEL=!0),a=!0,this._defines.FRESNEL=!0),this._defines.SPECULARTERM&&this.useSpecularOverAlpha&&(this._defines.SPECULAROVERALPHA=!0),i&&(a&&i.isVerticesDataPresent(e.VertexBuffer.NormalKind)&&(this._defines.NORMAL=!0),h&&(i.isVerticesDataPresent(e.VertexBuffer.UVKind)&&(this._defines.UV1=!0),i.isVerticesDataPresent(e.VertexBuffer.UV2Kind)&&(this._defines.UV2=!0)),i.useVertexColors&&i.isVerticesDataPresent(e.VertexBuffer.ColorKind)&&(this._defines.VERTEXCOLOR=!0,i.hasVertexAlpha&&(this._defines.VERTEXALPHA=!0)),i.useBones&&i.computeBonesUsingShaders&&(this._defines.NUM_BONE_INFLUENCERS=i.numBoneInfluencers,this._defines.BonesPerMesh=i.skeleton.bones.length+1),n&&(this._defines.INSTANCES=!0)),!this._defines.isEqual(this._cachedDefines)){this._defines.cloneTo(this._cachedDefines),o.resetCachedMaterial();var c=new e.EffectFallbacks;this._defines.REFLECTION&&c.addFallback(0,"REFLECTION"),this._defines.SPECULAR&&c.addFallback(0,"SPECULAR"),this._defines.BUMP&&c.addFallback(0,"BUMP"),this._defines.PARALLAX&&c.addFallback(1,"PARALLAX"),this._defines.PARALLAXOCCLUSION&&c.addFallback(0,"PARALLAXOCCLUSION"),this._defines.SPECULAROVERALPHA&&c.addFallback(0,"SPECULAROVERALPHA"),this._defines.FOG&&c.addFallback(1,"FOG"),this._defines.POINTSIZE&&c.addFallback(0,"POINTSIZE"),this._defines.LOGARITHMICDEPTH&&c.addFallback(0,"LOGARITHMICDEPTH"),e.MaterialHelper.HandleFallbacksForShadows(this._defines,c,this.maxSimultaneousLights),this._defines.SPECULARTERM&&c.addFallback(0,"SPECULARTERM"),this._defines.DIFFUSEFRESNEL&&c.addFallback(1,"DIFFUSEFRESNEL"),this._defines.OPACITYFRESNEL&&c.addFallback(2,"OPACITYFRESNEL"),this._defines.REFLECTIONFRESNEL&&c.addFallback(3,"REFLECTIONFRESNEL"),this._defines.EMISSIVEFRESNEL&&c.addFallback(4,"EMISSIVEFRESNEL"),this._defines.FRESNEL&&c.addFallback(4,"FRESNEL");var l=[e.VertexBuffer.PositionKind];this._defines.NORMAL&&l.push(e.VertexBuffer.NormalKind),this._defines.UV1&&l.push(e.VertexBuffer.UVKind),this._defines.UV2&&l.push(e.VertexBuffer.UV2Kind),this._defines.VERTEXCOLOR&&l.push(e.VertexBuffer.ColorKind),e.MaterialHelper.PrepareAttributesForBones(l,i,this._defines,c),e.MaterialHelper.PrepareAttributesForInstances(l,this._defines);var u="default";o.getEngine().getCaps().standardDerivatives||(u="legacydefault");var f=this._defines.toString(),d=["world","view","viewProjection","vEyePosition","vLightsType","vAmbientColor","vDiffuseColor","vSpecularColor","vEmissiveColor","vFogInfos","vFogColor","pointSize","vDiffuseInfos","vAmbientInfos","vOpacityInfos","vReflectionInfos","vEmissiveInfos","vSpecularInfos","vBumpInfos","vLightmapInfos","vRefractionInfos","mBones","vClipPlane","diffuseMatrix","ambientMatrix","opacityMatrix","reflectionMatrix","emissiveMatrix","specularMatrix","bumpMatrix","lightmapMatrix","refractionMatrix","depthValues","diffuseLeftColor","diffuseRightColor","opacityParts","reflectionLeftColor","reflectionRightColor","emissiveLeftColor","emissiveRightColor","refractionLeftColor","refractionRightColor","logarithmicDepthConstant"],p=["diffuseSampler","ambientSampler","opacitySampler","reflectionCubeSampler","reflection2DSampler","emissiveSampler","specularSampler","bumpSampler","lightmapSampler","refractionCubeSampler","refraction2DSampler"];e.MaterialHelper.PrepareUniformsAndSamplersList(d,p,this._defines,this.maxSimultaneousLights),this._effect=o.getEngine().createEffect(u,l,d,p,f,c,this.onCompiled,this.onError,{maxSimultaneousLights:this.maxSimultaneousLights-1})}return this._effect.isReady()?(this._renderId=o.getRenderId(),this._wasPreviouslyReady=!0,i&&(i._materialDefines||(i._materialDefines=new t),this._defines.cloneTo(i._materialDefines)),!0):!1},r.prototype.unbind=function(){this.reflectionTexture&&this.reflectionTexture.isRenderTarget&&this._effect.setTexture("reflection2DSampler",null),this.refractionTexture&&this.refractionTexture.isRenderTarget&&this._effect.setTexture("refraction2DSampler",null),i.prototype.unbind.call(this)},r.prototype.bindOnlyWorldMatrix=function(e){this._effect.setMatrix("world",e)},r.prototype.bind=function(t,n){var o=this.getScene();if(this.bindOnlyWorldMatrix(t),e.MaterialHelper.BindBonesParameters(n,this._effect),o.getCachedMaterial()!==this){if(this._effect.setMatrix("viewProjection",o.getTransformMatrix()),r.FresnelEnabled&&(this.diffuseFresnelParameters&&this.diffuseFresnelParameters.isEnabled&&(this._effect.setColor4("diffuseLeftColor",this.diffuseFresnelParameters.leftColor,this.diffuseFresnelParameters.power),this._effect.setColor4("diffuseRightColor",this.diffuseFresnelParameters.rightColor,this.diffuseFresnelParameters.bias)),this.opacityFresnelParameters&&this.opacityFresnelParameters.isEnabled&&this._effect.setColor4("opacityParts",new e.Color3(this.opacityFresnelParameters.leftColor.toLuminance(),this.opacityFresnelParameters.rightColor.toLuminance(),this.opacityFresnelParameters.bias),this.opacityFresnelParameters.power),this.reflectionFresnelParameters&&this.reflectionFresnelParameters.isEnabled&&(this._effect.setColor4("reflectionLeftColor",this.reflectionFresnelParameters.leftColor,this.reflectionFresnelParameters.power),this._effect.setColor4("reflectionRightColor",this.reflectionFresnelParameters.rightColor,this.reflectionFresnelParameters.bias)),this.refractionFresnelParameters&&this.refractionFresnelParameters.isEnabled&&(this._effect.setColor4("refractionLeftColor",this.refractionFresnelParameters.leftColor,this.refractionFresnelParameters.power),this._effect.setColor4("refractionRightColor",this.refractionFresnelParameters.rightColor,this.refractionFresnelParameters.bias)),this.emissiveFresnelParameters&&this.emissiveFresnelParameters.isEnabled&&(this._effect.setColor4("emissiveLeftColor",this.emissiveFresnelParameters.leftColor,this.emissiveFresnelParameters.power),this._effect.setColor4("emissiveRightColor",this.emissiveFresnelParameters.rightColor,this.emissiveFresnelParameters.bias))),o.texturesEnabled&&(this.diffuseTexture&&r.DiffuseTextureEnabled&&(this._effect.setTexture("diffuseSampler",this.diffuseTexture),this._effect.setFloat2("vDiffuseInfos",this.diffuseTexture.coordinatesIndex,this.diffuseTexture.level),this._effect.setMatrix("diffuseMatrix",this.diffuseTexture.getTextureMatrix())),this.ambientTexture&&r.AmbientTextureEnabled&&(this._effect.setTexture("ambientSampler",this.ambientTexture),this._effect.setFloat2("vAmbientInfos",this.ambientTexture.coordinatesIndex,this.ambientTexture.level),this._effect.setMatrix("ambientMatrix",this.ambientTexture.getTextureMatrix())),this.opacityTexture&&r.OpacityTextureEnabled&&(this._effect.setTexture("opacitySampler",this.opacityTexture),this._effect.setFloat2("vOpacityInfos",this.opacityTexture.coordinatesIndex,this.opacityTexture.level),this._effect.setMatrix("opacityMatrix",this.opacityTexture.getTextureMatrix())),this.reflectionTexture&&r.ReflectionTextureEnabled&&(this.reflectionTexture.isCube?this._effect.setTexture("reflectionCubeSampler",this.reflectionTexture):this._effect.setTexture("reflection2DSampler",this.reflectionTexture),this._effect.setMatrix("reflectionMatrix",this.reflectionTexture.getReflectionTextureMatrix()),this._effect.setFloat2("vReflectionInfos",this.reflectionTexture.level,this.roughness)),this.emissiveTexture&&r.EmissiveTextureEnabled&&(this._effect.setTexture("emissiveSampler",this.emissiveTexture),this._effect.setFloat2("vEmissiveInfos",this.emissiveTexture.coordinatesIndex,this.emissiveTexture.level),this._effect.setMatrix("emissiveMatrix",this.emissiveTexture.getTextureMatrix())),this.lightmapTexture&&r.LightmapTextureEnabled&&(this._effect.setTexture("lightmapSampler",this.lightmapTexture),this._effect.setFloat2("vLightmapInfos",this.lightmapTexture.coordinatesIndex,this.lightmapTexture.level),this._effect.setMatrix("lightmapMatrix",this.lightmapTexture.getTextureMatrix())),this.specularTexture&&r.SpecularTextureEnabled&&(this._effect.setTexture("specularSampler",this.specularTexture),this._effect.setFloat2("vSpecularInfos",this.specularTexture.coordinatesIndex,this.specularTexture.level),this._effect.setMatrix("specularMatrix",this.specularTexture.getTextureMatrix())),this.bumpTexture&&o.getEngine().getCaps().standardDerivatives&&r.BumpTextureEnabled&&(this._effect.setTexture("bumpSampler",this.bumpTexture),this._effect.setFloat3("vBumpInfos",this.bumpTexture.coordinatesIndex,1/this.bumpTexture.level,this.parallaxScaleBias),this._effect.setMatrix("bumpMatrix",this.bumpTexture.getTextureMatrix())),this.refractionTexture&&r.RefractionTextureEnabled)){var s=1;this.refractionTexture.isCube?this._effect.setTexture("refractionCubeSampler",this.refractionTexture):(this._effect.setTexture("refraction2DSampler",this.refractionTexture),this._effect.setMatrix("refractionMatrix",this.refractionTexture.getReflectionTextureMatrix()),this.refractionTexture.depth&&(s=this.refractionTexture.depth)),this._effect.setFloat4("vRefractionInfos",this.refractionTexture.level,this.indexOfRefraction,s,this.invertRefractionY?-1:1)}e.MaterialHelper.BindClipPlane(this._effect,o),this.pointsCloud&&this._effect.setFloat("pointSize",this.pointSize),o.ambientColor.multiplyToRef(this.ambientColor,this._globalAmbientColor),this._effect.setVector3("vEyePosition",o._mirroredCameraPosition?o._mirroredCameraPosition:o.activeCamera.position),this._effect.setColor3("vAmbientColor",this._globalAmbientColor),this._defines.SPECULARTERM&&this._effect.setColor4("vSpecularColor",this.specularColor,this.specularPower),this._effect.setColor3("vEmissiveColor",this.emissiveColor)}o.getCachedMaterial()===this&&this.isFrozen||(this._effect.setColor4("vDiffuseColor",this.diffuseColor,this.alpha*n.visibility),o.lightsEnabled&&!this.disableLighting&&e.MaterialHelper.BindLights(o,n,this._effect,this._defines,this.maxSimultaneousLights),(o.fogEnabled&&n.applyFog&&o.fogMode!==e.Scene.FOGMODE_NONE||this.reflectionTexture||this.refractionTexture)&&this._effect.setMatrix("view",o.getViewMatrix()),e.MaterialHelper.BindFogParameters(o,n,this._effect),e.MaterialHelper.BindLogDepth(this._defines,this._effect,o)),i.prototype.bind.call(this,t,n)},r.prototype.getAnimatables=function(){var e=[];return this.diffuseTexture&&this.diffuseTexture.animations&&this.diffuseTexture.animations.length>0&&e.push(this.diffuseTexture),this.ambientTexture&&this.ambientTexture.animations&&this.ambientTexture.animations.length>0&&e.push(this.ambientTexture),this.opacityTexture&&this.opacityTexture.animations&&this.opacityTexture.animations.length>0&&e.push(this.opacityTexture),this.reflectionTexture&&this.reflectionTexture.animations&&this.reflectionTexture.animations.length>0&&e.push(this.reflectionTexture),this.emissiveTexture&&this.emissiveTexture.animations&&this.emissiveTexture.animations.length>0&&e.push(this.emissiveTexture),this.specularTexture&&this.specularTexture.animations&&this.specularTexture.animations.length>0&&e.push(this.specularTexture),this.bumpTexture&&this.bumpTexture.animations&&this.bumpTexture.animations.length>0&&e.push(this.bumpTexture),this.lightmapTexture&&this.lightmapTexture.animations&&this.lightmapTexture.animations.length>0&&e.push(this.lightmapTexture),this.refractionTexture&&this.refractionTexture.animations&&this.refractionTexture.animations.length>0&&e.push(this.refractionTexture),e},r.prototype.dispose=function(e,t){t&&(this.diffuseTexture&&this.diffuseTexture.dispose(),this.ambientTexture&&this.ambientTexture.dispose(),this.opacityTexture&&this.opacityTexture.dispose(),this.reflectionTexture&&this.reflectionTexture.dispose(),this.emissiveTexture&&this.emissiveTexture.dispose(),this.specularTexture&&this.specularTexture.dispose(),this.bumpTexture&&this.bumpTexture.dispose(),this.lightmapTexture&&this.lightmapTexture.dispose(),this.refractionTexture&&this.refractionTexture.dispose()),i.prototype.dispose.call(this,e,t)},r.prototype.clone=function(t){var i=this;return e.SerializationHelper.Clone(function(){return new r(t,i.getScene())},this)},r.prototype.serialize=function(){return e.SerializationHelper.Serialize(this)},r.Parse=function(t,i,n){return e.SerializationHelper.Parse(function(){return new r(t.name,i)},t,i,n)},r.DiffuseTextureEnabled=!0,r.AmbientTextureEnabled=!0,r.OpacityTextureEnabled=!0,r.ReflectionTextureEnabled=!0,r.EmissiveTextureEnabled=!0,r.SpecularTextureEnabled=!0,r.BumpTextureEnabled=!0,r.FresnelEnabled=!0,r.LightmapTextureEnabled=!0,r.RefractionTextureEnabled=!0,__decorate([e.serializeAsTexture()],r.prototype,"diffuseTexture",void 0),__decorate([e.serializeAsTexture()],r.prototype,"ambientTexture",void 0),__decorate([e.serializeAsTexture()],r.prototype,"opacityTexture",void 0),__decorate([e.serializeAsTexture()],r.prototype,"reflectionTexture",void 0),__decorate([e.serializeAsTexture()],r.prototype,"emissiveTexture",void 0),__decorate([e.serializeAsTexture()],r.prototype,"specularTexture",void 0),__decorate([e.serializeAsTexture()],r.prototype,"bumpTexture",void 0),__decorate([e.serializeAsTexture()],r.prototype,"lightmapTexture",void 0),__decorate([e.serializeAsTexture()],r.prototype,"refractionTexture",void 0),__decorate([e.serializeAsColor3("ambient")],r.prototype,"ambientColor",void 0),__decorate([e.serializeAsColor3("diffuse")],r.prototype,"diffuseColor",void 0),__decorate([e.serializeAsColor3("specular")],r.prototype,"specularColor",void 0),__decorate([e.serializeAsColor3("emissive")],r.prototype,"emissiveColor",void 0),__decorate([e.serialize()],r.prototype,"specularPower",void 0),__decorate([e.serialize()],r.prototype,"useAlphaFromDiffuseTexture",void 0),__decorate([e.serialize()],r.prototype,"useEmissiveAsIllumination",void 0),__decorate([e.serialize()],r.prototype,"linkEmissiveWithDiffuse",void 0),__decorate([e.serialize()],r.prototype,"useReflectionFresnelFromSpecular",void 0),__decorate([e.serialize()],r.prototype,"useSpecularOverAlpha",void 0),__decorate([e.serialize()],r.prototype,"useReflectionOverAlpha",void 0),__decorate([e.serialize()],r.prototype,"disableLighting",void 0),__decorate([e.serialize()],r.prototype,"useParallax",void 0),__decorate([e.serialize()],r.prototype,"useParallaxOcclusion",void 0),__decorate([e.serialize()],r.prototype,"parallaxScaleBias",void 0),__decorate([e.serialize()],r.prototype,"roughness",void 0),__decorate([e.serialize()],r.prototype,"indexOfRefraction",void 0),__decorate([e.serialize()],r.prototype,"invertRefractionY",void 0),__decorate([e.serialize()],r.prototype,"useLightmapAsShadowmap",void 0),__decorate([e.serializeAsFresnelParameters()],r.prototype,"diffuseFresnelParameters",void 0),__decorate([e.serializeAsFresnelParameters()],r.prototype,"opacityFresnelParameters",void 0),__decorate([e.serializeAsFresnelParameters()],r.prototype,"reflectionFresnelParameters",void 0),__decorate([e.serializeAsFresnelParameters()],r.prototype,"refractionFresnelParameters",void 0),__decorate([e.serializeAsFresnelParameters()],r.prototype,"emissiveFresnelParameters",void 0),__decorate([e.serialize()],r.prototype,"useGlossinessFromSpecularMapAlpha",void 0),__decorate([e.serialize()],r.prototype,"maxSimultaneousLights",void 0),__decorate([e.serialize()],r.prototype,"invertNormalMapX",void 0),__decorate([e.serialize()],r.prototype,"invertNormalMapY",void 0),__decorate([e.serialize()],r.prototype,"useLogarithmicDepth",null),r}(e.Material);e.StandardMaterial=i}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(t){function i(e,i){t.call(this,e,i,!0),this.subMaterials=new Array,i.multiMaterials.push(this)}return __extends(i,t),i.prototype.getSubMaterial=function(e){return 0>e||e>=this.subMaterials.length?this.getScene().defaultMaterial:this.subMaterials[e]},i.prototype.isReady=function(e){for(var t=0;t<this.subMaterials.length;t++){var i=this.subMaterials[t];if(i&&!this.subMaterials[t].isReady(e))return!1}return!0},i.prototype.clone=function(e,t){for(var r=new i(e,this.getScene()),n=0;n<this.subMaterials.length;n++){var o=null;o=t?this.subMaterials[n].clone(e+"-"+this.subMaterials[n].name):this.subMaterials[n],r.subMaterials.push(o)}return r},i.prototype.serialize=function(){var t={};t.name=this.name,t.id=this.id,t.tags=e.Tags.GetTags(this),t.materials=[];for(var i=0;i<this.subMaterials.length;i++){var r=this.subMaterials[i];r?t.materials.push(r.id):t.materials.push(null)}return t},i}(e.Material);e.MultiMaterial=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(){}return Object.defineProperty(t,"NO_LOGGING",{get:function(){return 0},enumerable:!0,configurable:!0}),Object.defineProperty(t,"MINIMAL_LOGGING",{get:function(){return 1},enumerable:!0,configurable:!0}),Object.defineProperty(t,"SUMMARY_LOGGING",{get:function(){return 2},enumerable:!0,configurable:!0}),Object.defineProperty(t,"DETAILED_LOGGING",{get:function(){return 3},enumerable:!0,configurable:!0}),Object.defineProperty(t,"ForceFullSceneLoadingForIncremental",{get:function(){return t._ForceFullSceneLoadingForIncremental},set:function(e){t._ForceFullSceneLoadingForIncremental=e},enumerable:!0,configurable:!0}),Object.defineProperty(t,"ShowLoadingScreen",{get:function(){return t._ShowLoadingScreen},set:function(e){t._ShowLoadingScreen=e},enumerable:!0,configurable:!0}),Object.defineProperty(t,"loggingLevel",{get:function(){return t._loggingLevel},set:function(e){t._loggingLevel=e},enumerable:!0,configurable:!0}),t._getPluginForFilename=function(e){var t=e.lastIndexOf("."),i=e.indexOf("?");-1===i&&(i=e.length);for(var r=e.substring(t,i).toLowerCase(),n=0;n<this._registeredPlugins.length;n++){var o=this._registeredPlugins[n];if(-1!==o.extensions.indexOf(r))return o}return this._registeredPlugins[0]},t.GetPluginForExtension=function(e){for(var t=0;t<this._registeredPlugins.length;t++){var i=this._registeredPlugins[t];if(-1!==i.extensions.indexOf(e))return i}return null},t.RegisterPlugin=function(e){e.extensions=e.extensions.toLowerCase(),t._registeredPlugins.push(e)},t.ImportMesh=function(i,r,n,o,s,a,h){if(n.substr&&"/"===n.substr(0,1))return void e.Tools.Error("Wrong sceneFilename parameter");if(n.substr&&"/"===n.substr(0,1))return void e.Tools.Error("Wrong sceneFilename parameter");var c={};o._addPendingData(c);var l=function(l){o.database=u;var f=t._getPluginForFilename(n),d=function(e){var t=[],a=[],l=[];try{if(f.importMesh){var u=f;if(!u.importMesh(i,o,e,r,t,a,l))return h&&h(o,"Unable to import meshes from "+r+n),void o._removePendingData(c);s&&(o.importedMeshesFiles.push(r+n),s(t,a,l),o._removePendingData(c))}else{var d=f;d.importMeshAsync(i,o,e,r,function(e,t,i){s&&(o.importedMeshesFiles.push(r+n),s(e,t,i),o._removePendingData(c))},function(){h&&h(o,"Unable to import meshes from "+r+n),o._removePendingData(c)})}}catch(p){h&&h(o,"Unable to import meshes from "+r+n,p),o._removePendingData(c)}};return n.substr&&"data:"===n.substr(0,5)?void d(n.substr(5)):void e.Tools.LoadFile(r+n,function(e){d(e)},a,u)};if(!o.getEngine().enableOfflineSupport||n.substr&&"data:"===n.substr(0,5))l(!0);else var u=new e.Database(r+n,l)},t.Load=function(i,r,n,o,s,a){t.Append(i,r,new e.Scene(n),o,s,a)},t.Append=function(i,r,n,o,s,a){if(r.substr&&"/"===r.substr(0,1))return void e.Tools.Error("Wrong sceneFilename parameter");var h,c=this._getPluginForFilename(r.name||r),l={};n._addPendingData(l),t.ShowLoadingScreen&&n.getEngine().displayLoadingUI();var u=function(e){if(n.database=h,c.load){var r=c;if(!r.load(n,e,i))return a&&a(n),n._removePendingData(l),void n.getEngine().hideLoadingUI();o&&o(n),n._removePendingData(l)}else{var s=c;s.loadAsync(n,e,i,function(){o&&o(n)},function(){a&&a(n),n._removePendingData(l),n.getEngine().hideLoadingUI()})}t.ShowLoadingScreen&&n.executeWhenReady(function(){n.getEngine().hideLoadingUI()})},f=function(t){e.Tools.LoadFile(i+r,u,s,h)};return r.substr&&"data:"===r.substr(0,5)?void u(r.substr(5)):void(-1===i.indexOf("file:")?n.getEngine().enableOfflineSupport?h=new e.Database(i+r,f):f(!0):e.Tools.ReadFile(r,u,s))},t._ForceFullSceneLoadingForIncremental=!1,t._ShowLoadingScreen=!0,t._loggingLevel=t.NO_LOGGING,t._registeredPlugins=new Array,t}();e.SceneLoader=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t;!function(t){var i=function(t,i,r,n){for(var o=0,s=i.materials.length;s>o;o++){var a=i.materials[o];if(a.id===t)return e.Material.Parse(a,r,n)}return null},r=function(e,t,i){t=t instanceof Array?t:[t];for(var r in t)if(e.name===t[r])return i.push(e.id),!0;return e.parentId&&-1!==i.indexOf(e.parentId)?(i.push(e.id),!0):!1},n=function(e,t){return e+" of "+(t?t.file+" from "+t.name+" version: "+t.version+", exporter version: "+t.exporter_version:"unknown")};e.SceneLoader.RegisterPlugin({extensions:".babylon",importMesh:function(t,o,s,a,h,c,l){var u="importMesh has failed JSON parse";try{var f=JSON.parse(s);u="";var d,p,_=e.SceneLoader.loggingLevel===e.SceneLoader.DETAILED_LOGGING,m=[],g=[],v=[];for(d=0,p=f.meshes.length;p>d;d++){var y=f.meshes[d];if(!t||r(y,t,v)){if(t instanceof Array&&delete t[t.indexOf(y.name)],y.geometryId&&f.geometries){var x=!1;["boxes","spheres","cylinders","toruses","grounds","planes","torusKnots","vertexData"].forEach(function(t){!x&&f.geometries[t]&&f.geometries[t]instanceof Array&&f.geometries[t].forEach(function(i){if(i.id===y.geometryId){switch(t){case"boxes":e.Geometry.Primitives.Box.Parse(i,o);break;case"spheres":e.Geometry.Primitives.Sphere.Parse(i,o);break;case"cylinders":e.Geometry.Primitives.Cylinder.Parse(i,o);break;case"toruses":e.Geometry.Primitives.Torus.Parse(i,o);break;case"grounds":e.Geometry.Primitives.Ground.Parse(i,o);break;case"planes":e.Geometry.Primitives.Plane.Parse(i,o);break;case"torusKnots":e.Geometry.Primitives.TorusKnot.Parse(i,o);break;case"vertexData":e.Geometry.Parse(i,o,a)}x=!0}})}),x||e.Tools.Warn("Geometry not found for mesh "+y.id)}if(y.materialId){var b=-1!==g.indexOf(y.materialId);if(!b&&f.multiMaterials)for(var P=0,A=f.multiMaterials.length;A>P;P++){var T=f.multiMaterials[P];if(T.id===y.materialId){for(var E=0,C=T.materials.length;C>E;E++){var S=T.materials[E];g.push(S);var M=i(S,f,o,a);u+="\n Material "+M.toString(_)}g.push(T.id);var I=e.Material.ParseMultiMaterial(T,o);b=!0,u+="\n Multi-Material "+I.toString(_);break}}if(!b){g.push(y.materialId);var M=i(y.materialId,f,o,a);M?u+="\n Material "+M.toString(_):e.Tools.Warn("Material not found for mesh "+y.id)}}if(y.skeletonId>-1&&o.skeletons){var D=m.indexOf(y.skeletonId)>-1;if(!D)for(var R=0,O=f.skeletons.length;O>R;R++){var w=f.skeletons[R];if(w.id===y.skeletonId){var L=e.Skeleton.Parse(w,o);l.push(L),m.push(w.id),u+="\n Skeleton "+L.toString(_)}}}var B=e.Mesh.Parse(y,o,a);h.push(B),u+="\n Mesh "+B.toString(_)}}var V;for(d=0,p=o.meshes.length;p>d;d++)V=o.meshes[d],V._waitingParentId&&(V.parent=o.getLastEntryByID(V._waitingParentId),V._waitingParentId=void 0);for(d=0,p=o.meshes.length;p>d;d++)V=o.meshes[d],V._waitingFreezeWorldMatrix?(V.freezeWorldMatrix(),V._waitingFreezeWorldMatrix=void 0):V.computeWorldMatrix(!0);if(f.particleSystems)for(d=0,p=f.particleSystems.length;p>d;d++){var F=f.particleSystems[d];-1!==v.indexOf(F.emitterId)&&c.push(e.ParticleSystem.Parse(F,o,a))}return!0}catch(N){throw e.Tools.Log(n("importMesh",f.producer)+u),u=null,N}finally{null!==u&&e.SceneLoader.loggingLevel!==e.SceneLoader.NO_LOGGING&&e.Tools.Log(n("importMesh",f.producer)+(e.SceneLoader.loggingLevel!==e.SceneLoader.MINIMAL_LOGGING?u:""))}},load:function(t,i,r){var o="importScene has failed JSON parse";try{var s=JSON.parse(i);o="";var a=e.SceneLoader.loggingLevel===e.SceneLoader.DETAILED_LOGGING;if(t.useDelayedTextureLoading=s.useDelayedTextureLoading&&!e.SceneLoader.ForceFullSceneLoadingForIncremental,t.autoClear=s.autoClear,t.clearColor=e.Color4.FromArray(s.clearColor),t.ambientColor=e.Color3.FromArray(s.ambientColor),s.gravity&&(t.gravity=e.Vector3.FromArray(s.gravity)),s.fogMode&&0!==s.fogMode)switch(t.fogMode=s.fogMode,t.fogColor=e.Color3.FromArray(s.fogColor),t.fogStart=s.fogStart,t.fogEnd=s.fogEnd,t.fogDensity=s.fogDensity,o+=" Fog mode for scene: ",t.fogMode){case 1:o+="exp\n";break;case 2:o+="exp2\n";break;case 3:o+="linear\n"}if(s.physicsEnabled){var h;"cannon"===s.physicsEngine?h=new e.CannonJSPlugin:"oimo"===s.physicsEngine&&(h=new e.OimoJSPlugin),o=" Physics engine "+(s.physicsEngine?s.physicsEngine:"oimo")+" enabled\n";var c=s.physicsGravity?e.Vector3.FromArray(s.physicsGravity):null;t.enablePhysics(c,h)}void 0!=s.collisionsEnabled&&(t.collisionsEnabled=s.collisionsEnabled),t.workerCollisions=!!s.workerCollisions;var l,u;for(l=0,u=s.lights.length;u>l;l++){var f=s.lights[l],d=e.Light.Parse(f,t);o+=0===l?"\n Lights:":"",o+="\n "+d.toString(a)}if(s.animations)for(l=0,u=s.animations.length;u>l;l++){var p=s.animations[l],_=e.Animation.Parse(p);
  16. t.animations.push(_),o+=0===l?"\n Animations:":"",o+="\n "+_.toString(a)}if(s.autoAnimate&&t.beginAnimation(t,s.autoAnimateFrom,s.autoAnimateTo,s.autoAnimateLoop,s.autoAnimateSpeed||1),s.materials)for(l=0,u=s.materials.length;u>l;l++){var m=s.materials[l],g=e.Material.Parse(m,t,r);o+=0===l?"\n Materials:":"",o+="\n "+g.toString(a)}if(s.multiMaterials)for(l=0,u=s.multiMaterials.length;u>l;l++){var v=s.multiMaterials[l],y=e.Material.ParseMultiMaterial(v,t);o+=0===l?"\n MultiMaterials:":"",o+="\n "+y.toString(a)}if(s.skeletons)for(l=0,u=s.skeletons.length;u>l;l++){var x=s.skeletons[l],b=e.Skeleton.Parse(x,t);o+=0===l?"\n Skeletons:":"",o+="\n "+b.toString(a)}var P=s.geometries;if(P){var A=P.boxes;if(A)for(l=0,u=A.length;u>l;l++){var T=A[l];e.Geometry.Primitives.Box.Parse(T,t)}var E=P.spheres;if(E)for(l=0,u=E.length;u>l;l++){var C=E[l];e.Geometry.Primitives.Sphere.Parse(C,t)}var S=P.cylinders;if(S)for(l=0,u=S.length;u>l;l++){var M=S[l];e.Geometry.Primitives.Cylinder.Parse(M,t)}var I=P.toruses;if(I)for(l=0,u=I.length;u>l;l++){var D=I[l];e.Geometry.Primitives.Torus.Parse(D,t)}var R=P.grounds;if(R)for(l=0,u=R.length;u>l;l++){var O=R[l];e.Geometry.Primitives.Ground.Parse(O,t)}var w=P.planes;if(w)for(l=0,u=w.length;u>l;l++){var L=w[l];e.Geometry.Primitives.Plane.Parse(L,t)}var B=P.torusKnots;if(B)for(l=0,u=B.length;u>l;l++){var V=B[l];e.Geometry.Primitives.TorusKnot.Parse(V,t)}var F=P.vertexData;if(F)for(l=0,u=F.length;u>l;l++){var N=F[l];e.Geometry.Parse(N,t,r)}}for(l=0,u=s.meshes.length;u>l;l++){var z=s.meshes[l],k=e.Mesh.Parse(z,t,r);o+=0===l?"\n Meshes:":"",o+="\n "+k.toString(a)}for(l=0,u=s.cameras.length;u>l;l++){var U=s.cameras[l],G=e.Camera.Parse(U,t);o+=0===l?"\n Cameras:":"",o+="\n "+G.toString(a)}for(s.activeCameraID&&t.setActiveCameraByID(s.activeCameraID),l=0,u=t.cameras.length;u>l;l++){var G=t.cameras[l];G._waitingParentId&&(G.parent=t.getLastEntryByID(G._waitingParentId),G._waitingParentId=void 0)}for(l=0,u=t.lights.length;u>l;l++){var d=t.lights[l];d._waitingParentId&&(d.parent=t.getLastEntryByID(d._waitingParentId),d._waitingParentId=void 0)}var W,Y=[];if(e.AudioEngine&&s.sounds)for(l=0,u=s.sounds.length;u>l;l++){var H=s.sounds[l];if(e.Engine.audioEngine.canUseWebAudio)H.url||(H.url=H.name),Y[H.url]?e.Sound.Parse(H,t,r,Y[H.url]):(W=e.Sound.Parse(H,t,r),Y[H.url]=W);else{new e.Sound(H.name,null,t)}}for(Y=[],l=0,u=t.meshes.length;u>l;l++){var k=t.meshes[l];k._waitingParentId&&(k.parent=t.getLastEntryByID(k._waitingParentId),k._waitingParentId=void 0),k._waitingActions&&(e.ActionManager.Parse(k._waitingActions,k,t),k._waitingActions=void 0)}for(l=0,u=t.meshes.length;u>l;l++){var j=t.meshes[l];j._waitingFreezeWorldMatrix?(j.freezeWorldMatrix(),j._waitingFreezeWorldMatrix=void 0):j.computeWorldMatrix(!0)}if(s.particleSystems)for(l=0,u=s.particleSystems.length;u>l;l++){var X=s.particleSystems[l];e.ParticleSystem.Parse(X,t,r)}if(s.lensFlareSystems)for(l=0,u=s.lensFlareSystems.length;u>l;l++){var K=s.lensFlareSystems[l];e.LensFlareSystem.Parse(K,t,r)}if(s.shadowGenerators)for(l=0,u=s.shadowGenerators.length;u>l;l++){var Z=s.shadowGenerators[l];e.ShadowGenerator.Parse(Z,t)}return s.actions&&e.ActionManager.Parse(s.actions,null,t),!0}catch(q){throw e.Tools.Log(n("importScene",s.producer)+o),o=null,q}finally{null!==o&&e.SceneLoader.loggingLevel!==e.SceneLoader.NO_LOGGING&&e.Tools.Log(n("importScene",s.producer)+(e.SceneLoader.loggingLevel!==e.SceneLoader.MINIMAL_LOGGING?o:""))}}})}(t=e.Internals||(e.Internals={}))}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(t,i,r,n,o,s,a){void 0===a&&(a=e.Texture.TRILINEAR_SAMPLINGMODE),this.name=t,this.cellSize=n,this.sprites=new Array,this.renderingGroupId=0,this.layerMask=268435455,this.fogEnabled=!0,this.isPickable=!1,this.onDisposeObservable=new e.Observable,this._vertexBuffers={},this._capacity=r,this._spriteTexture=new e.Texture(i,o,!0,!1,a),this._spriteTexture.wrapU=e.Texture.CLAMP_ADDRESSMODE,this._spriteTexture.wrapV=e.Texture.CLAMP_ADDRESSMODE,this._epsilon=void 0===s?.01:s,this._scene=o,this._scene.spriteManagers.push(this);for(var h=[],c=0,l=0;r>l;l++)h.push(c),h.push(c+1),h.push(c+2),h.push(c),h.push(c+2),h.push(c+3),c+=4;this._indexBuffer=o.getEngine().createIndexBuffer(h),this._vertexData=new Float32Array(16*r*4),this._buffer=new e.Buffer(o.getEngine(),this._vertexData,!0,16);var u=this._buffer.createVertexBuffer(e.VertexBuffer.PositionKind,0,4),f=this._buffer.createVertexBuffer("options",4,4),d=this._buffer.createVertexBuffer("cellInfo",8,4),p=this._buffer.createVertexBuffer(e.VertexBuffer.ColorKind,12,4);this._vertexBuffers[e.VertexBuffer.PositionKind]=u,this._vertexBuffers.options=f,this._vertexBuffers.cellInfo=d,this._vertexBuffers[e.VertexBuffer.ColorKind]=p,this._effectBase=this._scene.getEngine().createEffect("sprites",[e.VertexBuffer.PositionKind,"options","cellInfo",e.VertexBuffer.ColorKind],["view","projection","textureInfos","alphaTest"],["diffuseSampler"],""),this._effectFog=this._scene.getEngine().createEffect("sprites",[e.VertexBuffer.PositionKind,"options","cellInfo",e.VertexBuffer.ColorKind],["view","projection","textureInfos","alphaTest","vFogInfos","vFogColor"],["diffuseSampler"],"#define FOG")}return Object.defineProperty(t.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"texture",{get:function(){return this._spriteTexture},set:function(e){this._spriteTexture=e},enumerable:!0,configurable:!0}),t.prototype._appendSpriteVertex=function(e,t,i,r,n){var o=16*e;0===i?i=this._epsilon:1===i&&(i=1-this._epsilon),0===r?r=this._epsilon:1===r&&(r=1-this._epsilon),this._vertexData[o]=t.position.x,this._vertexData[o+1]=t.position.y,this._vertexData[o+2]=t.position.z,this._vertexData[o+3]=t.angle,this._vertexData[o+4]=t.width,this._vertexData[o+5]=t.height,this._vertexData[o+6]=i,this._vertexData[o+7]=r,this._vertexData[o+8]=t.invertU?1:0,this._vertexData[o+9]=t.invertV?1:0;var s=t.cellIndex/n>>0;this._vertexData[o+10]=t.cellIndex-s*n,this._vertexData[o+11]=s,this._vertexData[o+12]=t.color.r,this._vertexData[o+13]=t.color.g,this._vertexData[o+14]=t.color.b,this._vertexData[o+15]=t.color.a},t.prototype.intersects=function(t,i,r,n){for(var o,s=Math.min(this._capacity,this.sprites.length),a=e.Vector3.Zero(),h=e.Vector3.Zero(),c=Number.MAX_VALUE,l=e.Vector3.Zero(),u=i.getViewMatrix(),f=0;s>f;f++){var d=this.sprites[f];if(d){if(r){if(!r(d))continue}else if(!d.isPickable)continue;if(e.Vector3.TransformCoordinatesToRef(d.position,u,l),a.copyFromFloats(l.x-d.width/2,l.y-d.height/2,l.z),h.copyFromFloats(l.x+d.width/2,l.y+d.height/2,l.z),t.intersectsBoxMinMax(a,h)){var p=e.Vector3.Distance(l,t.origin);if(c>p&&(c=p,o=d,n))break}}}if(o){var _=new e.PickingInfo;return _.hit=!0,_.pickedSprite=o,_.distance=c,_}return null},t.prototype.render=function(){if(this._effectBase.isReady()&&this._effectFog.isReady()&&this._spriteTexture&&this._spriteTexture.isReady()){for(var t=this._scene.getEngine(),i=this._spriteTexture.getBaseSize(),r=t.getDeltaTime(),n=Math.min(this._capacity,this.sprites.length),o=i.width/this.cellSize,s=0,a=0;n>a;a++){var h=this.sprites[a];h&&(h._animate(r),this._appendSpriteVertex(s++,h,0,0,o),this._appendSpriteVertex(s++,h,1,0,o),this._appendSpriteVertex(s++,h,1,1,o),this._appendSpriteVertex(s++,h,0,1,o))}this._buffer.update(this._vertexData);var c=this._effectBase;this._scene.fogEnabled&&this._scene.fogMode!==e.Scene.FOGMODE_NONE&&this.fogEnabled&&(c=this._effectFog),t.enableEffect(c);var l=this._scene.getViewMatrix();c.setTexture("diffuseSampler",this._spriteTexture),c.setMatrix("view",l),c.setMatrix("projection",this._scene.getProjectionMatrix()),c.setFloat2("textureInfos",this.cellSize/i.width,this.cellSize/i.height),this._scene.fogEnabled&&this._scene.fogMode!==e.Scene.FOGMODE_NONE&&this.fogEnabled&&(c.setFloat4("vFogInfos",this._scene.fogMode,this._scene.fogStart,this._scene.fogEnd,this._scene.fogDensity),c.setColor3("vFogColor",this._scene.fogColor)),t.bindBuffers(this._vertexBuffers,this._indexBuffer,c),t.setDepthFunctionToLessOrEqual(),c.setBool("alphaTest",!0),t.setColorWrite(!1),t.draw(!0,0,6*n),t.setColorWrite(!0),c.setBool("alphaTest",!1),t.setAlphaMode(e.Engine.ALPHA_COMBINE),t.draw(!0,0,6*n),t.setAlphaMode(e.Engine.ALPHA_DISABLE)}},t.prototype.dispose=function(){this._buffer&&(this._buffer.dispose(),this._buffer=null),this._indexBuffer&&(this._scene.getEngine()._releaseBuffer(this._indexBuffer),this._indexBuffer=null),this._spriteTexture&&(this._spriteTexture.dispose(),this._spriteTexture=null);var e=this._scene.spriteManagers.indexOf(this);this._scene.spriteManagers.splice(e,1),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear()},t}();e.SpriteManager=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(t,i){this.name=t,this.color=new e.Color4(1,1,1,1),this.width=1,this.height=1,this.angle=0,this.cellIndex=0,this.invertU=0,this.invertV=0,this.animations=new Array,this.isPickable=!1,this._animationStarted=!1,this._loopAnimation=!1,this._fromIndex=0,this._toIndex=0,this._delay=0,this._direction=1,this._frameCount=0,this._time=0,this._manager=i,this._manager.sprites.push(this),this.position=e.Vector3.Zero()}return Object.defineProperty(t.prototype,"size",{get:function(){return this.width},set:function(e){this.width=e,this.height=e},enumerable:!0,configurable:!0}),t.prototype.playAnimation=function(e,t,i,r){this._fromIndex=e,this._toIndex=t,this._loopAnimation=i,this._delay=r,this._animationStarted=!0,this._direction=t>e?1:-1,this.cellIndex=e,this._time=0},t.prototype.stopAnimation=function(){this._animationStarted=!1},t.prototype._animate=function(e){this._animationStarted&&(this._time+=e,this._time>this._delay&&(this._time=this._time%this._delay,this.cellIndex+=this._direction,this.cellIndex==this._toIndex&&(this._loopAnimation?this.cellIndex=this._fromIndex:(this._animationStarted=!1,this.disposeWhenFinishedAnimating&&this.dispose()))))},t.prototype.dispose=function(){for(var e=0;e<this._manager.sprites.length;e++)this._manager.sprites[e]==this&&this._manager.sprites.splice(e,1)},t}();e.Sprite=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(t,i,r,n,o){this.name=t,this.scale=new e.Vector2(1,1),this.offset=new e.Vector2(0,0),this.alphaBlendingMode=e.Engine.ALPHA_COMBINE,this._vertexBuffers={},this.onDisposeObservable=new e.Observable,this.onBeforeRenderObservable=new e.Observable,this.onAfterRenderObservable=new e.Observable,this.texture=i?new e.Texture(i,r,!0):null,this.isBackground=void 0===n?!0:n,this.color=void 0===o?new e.Color4(1,1,1,1):o,this._scene=r,this._scene.layers.push(this);var s=r.getEngine(),a=[];a.push(1,1),a.push(-1,1),a.push(-1,-1),a.push(1,-1);var h=new e.VertexBuffer(s,a,e.VertexBuffer.PositionKind,!1,!1,2);this._vertexBuffers[e.VertexBuffer.PositionKind]=h;var c=[];c.push(0),c.push(1),c.push(2),c.push(0),c.push(2),c.push(3),this._indexBuffer=s.createIndexBuffer(c),this._effect=s.createEffect("layer",[e.VertexBuffer.PositionKind],["textureMatrix","color","scale","offset"],["textureSampler"],""),this._alphaTestEffect=s.createEffect("layer",[e.VertexBuffer.PositionKind],["textureMatrix","color","scale","offset"],["textureSampler"],"#define ALPHATEST")}return Object.defineProperty(t.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onBeforeRender",{set:function(e){this._onBeforeRenderObserver&&this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),this._onBeforeRenderObserver=this.onBeforeRenderObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onAfterRender",{set:function(e){this._onAfterRenderObserver&&this.onAfterRenderObservable.remove(this._onAfterRenderObserver),this._onAfterRenderObserver=this.onAfterRenderObservable.add(e)},enumerable:!0,configurable:!0}),t.prototype.render=function(){var t=this.alphaTest?this._alphaTestEffect:this._effect;if(t.isReady()&&this.texture&&this.texture.isReady()){var i=this._scene.getEngine();this.onBeforeRenderObservable.notifyObservers(this),i.enableEffect(t),i.setState(!1),t.setTexture("textureSampler",this.texture),t.setMatrix("textureMatrix",this.texture.getTextureMatrix()),t.setFloat4("color",this.color.r,this.color.g,this.color.b,this.color.a),t.setVector2("offset",this.offset),t.setVector2("scale",this.scale),i.bindBuffers(this._vertexBuffers,this._indexBuffer,t),this._alphaTestEffect?i.draw(!0,0,6):(i.setAlphaMode(this.alphaBlendingMode),i.draw(!0,0,6),i.setAlphaMode(e.Engine.ALPHA_DISABLE)),this.onAfterRenderObservable.notifyObservers(this)}},t.prototype.dispose=function(){var t=this._vertexBuffers[e.VertexBuffer.PositionKind];t&&(t.dispose(),this._vertexBuffers[e.VertexBuffer.PositionKind]=null),this._indexBuffer&&(this._scene.getEngine()._releaseBuffer(this._indexBuffer),this._indexBuffer=null),this.texture&&(this.texture.dispose(),this.texture=null);var i=this._scene.layers.indexOf(this);this._scene.layers.splice(i,1),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this.onAfterRenderObservable.clear(),this.onBeforeRenderObservable.clear()},t}();e.Layer=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(){this.position=e.Vector3.Zero(),this.direction=e.Vector3.Zero(),this.color=new e.Color4(0,0,0,0),this.colorStep=new e.Color4(0,0,0,0),this.lifeTime=1,this.age=0,this.size=0,this.angle=0,this.angularSpeed=0}return t.prototype.copyTo=function(e){e.position.copyFrom(this.position),e.direction.copyFrom(this.direction),e.color.copyFrom(this.color),e.colorStep.copyFrom(this.colorStep),e.lifeTime=this.lifeTime,e.age=this.age,e.size=this.size,e.angle=this.angle,e.angularSpeed=this.angularSpeed},t}();e.Particle=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(e,t){if(e===t)return e;var i=Math.random();return i*(t-e)+e},i=function(){function i(r,n,o,s){var a=this;this.name=r,this.animations=[],this.renderingGroupId=0,this.emitter=null,this.emitRate=10,this.manualEmitCount=-1,this.updateSpeed=.01,this.targetStopDuration=0,this.disposeOnStop=!1,this.minEmitPower=1,this.maxEmitPower=1,this.minLifeTime=1,this.maxLifeTime=1,this.minSize=1,this.maxSize=1,this.minAngularSpeed=0,this.maxAngularSpeed=0,this.layerMask=268435455,this.onDisposeObservable=new e.Observable,this.blendMode=i.BLENDMODE_ONEONE,this.forceDepthWrite=!1,this.gravity=e.Vector3.Zero(),this.direction1=new e.Vector3(0,1,0),this.direction2=new e.Vector3(0,1,0),this.minEmitBox=new e.Vector3(-.5,-.5,-.5),this.maxEmitBox=new e.Vector3(.5,.5,.5),this.color1=new e.Color4(1,1,1,1),this.color2=new e.Color4(1,1,1,1),this.colorDead=new e.Color4(0,0,0,1),this.textureMask=new e.Color4(1,1,1,1),this.particles=new Array,this._stockParticles=new Array,this._newPartsExcess=0,this._vertexBuffers={},this._scaledColorStep=new e.Color4(0,0,0,0),this._colorDiff=new e.Color4(0,0,0,0),this._scaledDirection=e.Vector3.Zero(),this._scaledGravity=e.Vector3.Zero(),this._currentRenderId=-1,this._started=!1,this._stopped=!1,this._actualFrame=0,this.id=r,this._capacity=n,this._scene=o,this._customEffect=s,o.particleSystems.push(this);for(var h=[],c=0,l=0;n>l;l++)h.push(c),h.push(c+1),h.push(c+2),h.push(c),h.push(c+2),h.push(c+3),c+=4;this._indexBuffer=o.getEngine().createIndexBuffer(h),this._vertexData=new Float32Array(11*n*4),this._vertexBuffer=new e.Buffer(o.getEngine(),this._vertexData,!0,11);var u=this._vertexBuffer.createVertexBuffer(e.VertexBuffer.PositionKind,0,3),f=this._vertexBuffer.createVertexBuffer(e.VertexBuffer.ColorKind,3,4),d=this._vertexBuffer.createVertexBuffer("options",7,4);this._vertexBuffers[e.VertexBuffer.PositionKind]=u,this._vertexBuffers[e.VertexBuffer.ColorKind]=f,this._vertexBuffers.options=d,this.startDirectionFunction=function(i,r,n,o){var s=t(a.direction1.x,a.direction2.x),h=t(a.direction1.y,a.direction2.y),c=t(a.direction1.z,a.direction2.z);e.Vector3.TransformNormalFromFloatsToRef(s*i,h*i,c*i,r,n)},this.startPositionFunction=function(i,r,n){var o=t(a.minEmitBox.x,a.maxEmitBox.x),s=t(a.minEmitBox.y,a.maxEmitBox.y),h=t(a.minEmitBox.z,a.maxEmitBox.z);e.Vector3.TransformCoordinatesFromFloatsToRef(o,s,h,i,r)},this.updateFunction=function(e){for(var t=0;t<e.length;t++){var i=e[t];i.age+=a._scaledUpdateSpeed,i.age>=i.lifeTime?(a.recycleParticle(i),t--):(i.colorStep.scaleToRef(a._scaledUpdateSpeed,a._scaledColorStep),i.color.addInPlace(a._scaledColorStep),i.color.a<0&&(i.color.a=0),i.angle+=i.angularSpeed*a._scaledUpdateSpeed,i.direction.scaleToRef(a._scaledUpdateSpeed,a._scaledDirection),i.position.addInPlace(a._scaledDirection),a.gravity.scaleToRef(a._scaledUpdateSpeed,a._scaledGravity),i.direction.addInPlace(a._scaledGravity))}}}return Object.defineProperty(i.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!0,configurable:!0}),i.prototype.recycleParticle=function(e){var t=this.particles.pop();t!==e&&(t.copyTo(e),this._stockParticles.push(t))},i.prototype.getCapacity=function(){return this._capacity},i.prototype.isAlive=function(){return this._alive},i.prototype.isStarted=function(){return this._started},i.prototype.start=function(){this._started=!0,this._stopped=!1,this._actualFrame=0},i.prototype.stop=function(){this._stopped=!0},i.prototype._appendParticleVertex=function(e,t,i,r){var n=11*e;this._vertexData[n]=t.position.x,this._vertexData[n+1]=t.position.y,this._vertexData[n+2]=t.position.z,this._vertexData[n+3]=t.color.r,this._vertexData[n+4]=t.color.g,this._vertexData[n+5]=t.color.b,this._vertexData[n+6]=t.color.a,this._vertexData[n+7]=t.angle,this._vertexData[n+8]=t.size,this._vertexData[n+9]=i,this._vertexData[n+10]=r},i.prototype._update=function(i){this._alive=this.particles.length>0,this.updateFunction(this.particles);var r;r=this.emitter.position?this.emitter.getWorldMatrix():e.Matrix.Translation(this.emitter.x,this.emitter.y,this.emitter.z);for(var n,o=0;i>o&&this.particles.length!==this._capacity;o++){0!==this._stockParticles.length?(n=this._stockParticles.pop(),n.age=0):n=new e.Particle,this.particles.push(n);var s=t(this.minEmitPower,this.maxEmitPower);this.startDirectionFunction(s,r,n.direction,n),n.lifeTime=t(this.minLifeTime,this.maxLifeTime),n.size=t(this.minSize,this.maxSize),n.angularSpeed=t(this.minAngularSpeed,this.maxAngularSpeed),this.startPositionFunction(r,n.position,n);var a=t(0,1);e.Color4.LerpToRef(this.color1,this.color2,a,n.color),this.colorDead.subtractToRef(n.color,this._colorDiff),this._colorDiff.scaleToRef(1/n.lifeTime,n.colorStep)}},i.prototype._getEffect=function(){if(this._customEffect)return this._customEffect;var t=[];this._scene.clipPlane&&t.push("#define CLIPPLANE");var i=t.join("\n");return this._cachedDefines!==i&&(this._cachedDefines=i,this._effect=this._scene.getEngine().createEffect("particles",[e.VertexBuffer.PositionKind,e.VertexBuffer.ColorKind,"options"],["invView","view","projection","vClipPlane","textureMask"],["diffuseSampler"],i)),this._effect},i.prototype.animate=function(){if(this._started){var e=this._getEffect();if(this.emitter&&e.isReady()&&this.particleTexture&&this.particleTexture.isReady()&&this._currentRenderId!==this._scene.getRenderId()){this._currentRenderId=this._scene.getRenderId(),this._scaledUpdateSpeed=this.updateSpeed*this._scene.getAnimationRatio();var t;this.manualEmitCount>-1?(t=this.manualEmitCount,this._newPartsExcess=0,this.manualEmitCount=0):(t=this.emitRate*this._scaledUpdateSpeed>>0,this._newPartsExcess+=this.emitRate*this._scaledUpdateSpeed-t),this._newPartsExcess>1&&(t+=this._newPartsExcess>>0,this._newPartsExcess-=this._newPartsExcess>>0),this._alive=!1,this._stopped?t=0:(this._actualFrame+=this._scaledUpdateSpeed,this.targetStopDuration&&this._actualFrame>=this.targetStopDuration&&this.stop()),this._update(t),this._stopped&&(this._alive||(this._started=!1,this.disposeOnStop&&this._scene._toBeDisposed.push(this)));for(var i=0,r=0;r<this.particles.length;r++){var n=this.particles[r];this._appendParticleVertex(i++,n,0,0),this._appendParticleVertex(i++,n,1,0),this._appendParticleVertex(i++,n,1,1),this._appendParticleVertex(i++,n,0,1)}this._vertexBuffer.update(this._vertexData)}}},i.prototype.render=function(){var t=this._getEffect();if(!(this.emitter&&t.isReady()&&this.particleTexture&&this.particleTexture.isReady()&&this.particles.length))return 0;var r=this._scene.getEngine();r.enableEffect(t),r.setState(!1);var n=this._scene.getViewMatrix();if(t.setTexture("diffuseSampler",this.particleTexture),t.setMatrix("view",n),t.setMatrix("projection",this._scene.getProjectionMatrix()),t.setFloat4("textureMask",this.textureMask.r,this.textureMask.g,this.textureMask.b,this.textureMask.a),this._scene.clipPlane){var o=this._scene.clipPlane,s=n.clone();s.invert(),t.setMatrix("invView",s),t.setFloat4("vClipPlane",o.normal.x,o.normal.y,o.normal.z,o.d)}return r.bindBuffers(this._vertexBuffers,this._indexBuffer,t),this.blendMode===i.BLENDMODE_ONEONE?r.setAlphaMode(e.Engine.ALPHA_ONEONE):r.setAlphaMode(e.Engine.ALPHA_COMBINE),this.forceDepthWrite&&r.setDepthWrite(!0),r.draw(!0,0,6*this.particles.length),r.setAlphaMode(e.Engine.ALPHA_DISABLE),this.particles.length},i.prototype.dispose=function(){this._vertexBuffer&&(this._vertexBuffer.dispose(),this._vertexBuffer=null),this._indexBuffer&&(this._scene.getEngine()._releaseBuffer(this._indexBuffer),this._indexBuffer=null),this.particleTexture&&(this.particleTexture.dispose(),this.particleTexture=null);var e=this._scene.particleSystems.indexOf(this);this._scene.particleSystems.splice(e,1),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear()},i.prototype.clone=function(t,r){var n=new i(t,this._capacity,this._scene);return e.Tools.DeepCopy(this,n,["particles"]),void 0===r&&(r=this.emitter),n.emitter=r,this.particleTexture&&(n.particleTexture=new e.Texture(this.particleTexture.url,this._scene)),n.start(),n},i.prototype.serialize=function(){var t={};return t.name=this.name,t.id=this.id,this.emitter.position?t.emitterId=this.emitter.id:t.emitter=this.emitter.asArray(),t.capacity=this.getCapacity(),this.particleTexture&&(t.textureName=this.particleTexture.name),e.Animation.AppendSerializedAnimations(this,t),t.minAngularSpeed=this.minAngularSpeed,t.maxAngularSpeed=this.maxAngularSpeed,t.minSize=this.minSize,t.maxSize=this.maxSize,t.minEmitPower=this.minEmitPower,t.maxEmitPower=this.maxEmitPower,t.minLifeTime=this.minLifeTime,t.maxLifeTime=this.maxLifeTime,t.emitRate=this.emitRate,t.minEmitBox=this.minEmitBox.asArray(),t.maxEmitBox=this.maxEmitBox.asArray(),t.gravity=this.gravity.asArray(),t.direction1=this.direction1.asArray(),t.direction2=this.direction2.asArray(),t.color1=this.color1.asArray(),t.color2=this.color2.asArray(),t.colorDead=this.colorDead.asArray(),t.updateSpeed=this.updateSpeed,t.targetStopDuration=this.targetStopDuration,t.textureMask=this.textureMask.asArray(),t.blendMode=this.blendMode,t},i.Parse=function(t,r,n){var o=t.name,s=new i(o,t.capacity,r);if(t.id&&(s.id=t.id),t.textureName&&(s.particleTexture=new e.Texture(n+t.textureName,r),s.particleTexture.name=t.textureName),t.emitterId?s.emitter=r.getLastMeshByID(t.emitterId):s.emitter=e.Vector3.FromArray(t.emitter),t.animations)for(var a=0;a<t.animations.length;a++){var h=t.animations[a];s.animations.push(e.Animation.Parse(h))}return t.autoAnimate&&r.beginAnimation(s,t.autoAnimateFrom,t.autoAnimateTo,t.autoAnimateLoop,t.autoAnimateSpeed||1),s.minAngularSpeed=t.minAngularSpeed,s.maxAngularSpeed=t.maxAngularSpeed,s.minSize=t.minSize,s.maxSize=t.maxSize,s.minLifeTime=t.minLifeTime,s.maxLifeTime=t.maxLifeTime,s.minEmitPower=t.minEmitPower,s.maxEmitPower=t.maxEmitPower,s.emitRate=t.emitRate,s.minEmitBox=e.Vector3.FromArray(t.minEmitBox),s.maxEmitBox=e.Vector3.FromArray(t.maxEmitBox),s.gravity=e.Vector3.FromArray(t.gravity),s.direction1=e.Vector3.FromArray(t.direction1),s.direction2=e.Vector3.FromArray(t.direction2),s.color1=e.Color4.FromArray(t.color1),s.color2=e.Color4.FromArray(t.color2),s.colorDead=e.Color4.FromArray(t.colorDead),s.updateSpeed=t.updateSpeed,s.targetStopDuration=t.targetStopDuration,s.textureMask=e.Color4.FromArray(t.textureMask),s.blendMode=t.blendMode,t.preventAutoStart||s.start(),s},i.BLENDMODE_ONEONE=0,i.BLENDMODE_STANDARD=1,i}();e.ParticleSystem=i}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function e(e,t,i){this.name=e,this.from=t,this.to=i}return e.prototype.clone=function(){return new e(this.name,this.from,this.to)},e}();e.AnimationRange=t;var i=function(){function e(e,t,i){this.frame=e,this.action=t,this.onlyOnce=i,this.isDone=!1}return e}();e.AnimationEvent=i;var r=function(){function t(e){this.path=e,this._onchange=new Array,this.value=0,this.animations=new Array}return t.prototype.getPoint=function(){var t=this.path.getPointAtLengthPosition(this.value);return new e.Vector3(t.x,0,t.y)},t.prototype.moveAhead=function(e){return void 0===e&&(e=.002),this.move(e),this},t.prototype.moveBack=function(e){return void 0===e&&(e=.002),this.move(-e),this},t.prototype.move=function(e){if(Math.abs(e)>1)throw"step size should be less than 1.";return this.value+=e,this.ensureLimits(),this.raiseOnChange(),this},t.prototype.ensureLimits=function(){for(;this.value>1;)this.value-=1;for(;this.value<0;)this.value+=1;return this},t.prototype.markAsDirty=function(e){return this.ensureLimits(),this.raiseOnChange(),this},t.prototype.raiseOnChange=function(){var e=this;return this._onchange.forEach(function(t){return t(e)}),this},t.prototype.onchange=function(e){return this._onchange.push(e),this},t}();e.PathCursor=r;var n=function(){function i(e,t,r,n,o,s){this.name=e,this.targetProperty=t,this.framePerSecond=r,this.dataType=n,this.loopMode=o,this.enableBlending=s,this._offsetsCache={},this._highLimitsCache={},this._stopped=!1,this._blendingFactor=0,this._events=new Array,this.allowMatricesInterpolation=!1,this.blendingSpeed=.01,this._ranges={},this.targetPropertyPath=t.split("."),this.dataType=n,this.loopMode=void 0===o?i.ANIMATIONLOOPMODE_CYCLE:o}return i._PrepareAnimation=function(t,r,n,o,s,a,h,c){var l=void 0;if(!isNaN(parseFloat(s))&&isFinite(s)?l=i.ANIMATIONTYPE_FLOAT:s instanceof e.Quaternion?l=i.ANIMATIONTYPE_QUATERNION:s instanceof e.Vector3?l=i.ANIMATIONTYPE_VECTOR3:s instanceof e.Vector2?l=i.ANIMATIONTYPE_VECTOR2:s instanceof e.Color3?l=i.ANIMATIONTYPE_COLOR3:s instanceof e.Size&&(l=i.ANIMATIONTYPE_SIZE),void 0==l)return null;var u=new i(t,r,n,l,h),f=[];return f.push({frame:0,value:s}),f.push({frame:o,value:a}),u.setKeys(f),void 0!==c&&u.setEasingFunction(c),u},i.CreateAndStartAnimation=function(e,t,r,n,o,s,a,h,c,l){var u=i._PrepareAnimation(e,r,n,o,s,a,h,c);return t.getScene().beginDirectAnimation(t,[u],0,o,1===u.loopMode,1,l)},i.CreateMergeAndStartAnimation=function(e,t,r,n,o,s,a,h,c,l){var u=i._PrepareAnimation(e,r,n,o,s,a,h,c);return t.animations.push(u),t.getScene().beginAnimation(t,0,o,1===u.loopMode,1,l)},i.prototype.toString=function(e){var t="Name: "+this.name+", property: "+this.targetProperty;if(t+=", datatype: "+["Float","Vector3","Quaternion","Matrix","Color3","Vector2"][this.dataType],t+=", nKeys: "+(this._keys?this._keys.length:"none"),t+=", nRanges: "+(this._ranges?Object.keys(this._ranges).length:"none"),e){t+=", Ranges: {";var i=!0;for(var r in this._ranges)i&&(t+=", ",i=!1),t+=r;t+="}"}return t},i.prototype.addEvent=function(e){this._events.push(e)},i.prototype.removeEvents=function(e){for(var t=0;t<this._events.length;t++)this._events[t].frame===e&&(this._events.splice(t,1),t--)},i.prototype.createRange=function(e,i,r){this._ranges[e]||(this._ranges[e]=new t(e,i,r))},i.prototype.deleteRange=function(e,t){if(void 0===t&&(t=!0),this._ranges[e]){if(t)for(var i=this._ranges[e].from,r=this._ranges[e].to,n=this._keys.length-1;n>=0;n--)this._keys[n].frame>=i&&this._keys[n].frame<=r&&this._keys.splice(n,1);this._ranges[e]=void 0}},i.prototype.getRange=function(e){return this._ranges[e]},i.prototype.reset=function(){this._offsetsCache={},this._highLimitsCache={},this.currentFrame=0,this._blendingFactor=0,this._originalBlendValue=null},i.prototype.isStopped=function(){return this._stopped},i.prototype.getKeys=function(){return this._keys},i.prototype.getHighestFrame=function(){for(var e=0,t=0,i=this._keys.length;i>t;t++)e<this._keys[t].frame&&(e=this._keys[t].frame);return e},i.prototype.getEasingFunction=function(){return this._easingFunction},i.prototype.setEasingFunction=function(e){this._easingFunction=e},i.prototype.floatInterpolateFunction=function(e,t,i){return e+(t-e)*i},i.prototype.quaternionInterpolateFunction=function(t,i,r){return e.Quaternion.Slerp(t,i,r)},i.prototype.vector3InterpolateFunction=function(t,i,r){return e.Vector3.Lerp(t,i,r)},i.prototype.vector2InterpolateFunction=function(t,i,r){return e.Vector2.Lerp(t,i,r)},i.prototype.sizeInterpolateFunction=function(t,i,r){return e.Size.Lerp(t,i,r)},i.prototype.color3InterpolateFunction=function(t,i,r){return e.Color3.Lerp(t,i,r)},i.prototype.matrixInterpolateFunction=function(t,i,r){return e.Matrix.Lerp(t,i,r)},i.prototype.clone=function(){var e=new i(this.name,this.targetPropertyPath.join("."),this.framePerSecond,this.dataType,this.loopMode);if(this._keys&&e.setKeys(this._keys),this._ranges){e._ranges={};for(var t in this._ranges)e._ranges[t]=this._ranges[t].clone()}return e},i.prototype.setKeys=function(e){this._keys=e.slice(0),this._offsetsCache={},this._highLimitsCache={}},i.prototype._getKeyValue=function(e){return"function"==typeof e?e():e},i.prototype._interpolate=function(e,t,r,n,o){if(r===i.ANIMATIONLOOPMODE_CONSTANT&&t>0)return o.clone?o.clone():o;this.currentFrame=e;var s=Math.max(0,Math.min(this._keys.length-1,Math.floor(this._keys.length*(e-this._keys[0].frame)/(this._keys[this._keys.length-1].frame-this._keys[0].frame))-1));if(this._keys[s].frame>=e)for(;s-1>=0&&this._keys[s].frame>=e;)s--;for(var a=s;a<this._keys.length;a++)if(this._keys[a+1].frame>=e){var h=this._getKeyValue(this._keys[a].value),c=this._getKeyValue(this._keys[a+1].value),l=(e-this._keys[a].frame)/(this._keys[a+1].frame-this._keys[a].frame);switch(null!=this._easingFunction&&(l=this._easingFunction.ease(l)),this.dataType){case i.ANIMATIONTYPE_FLOAT:switch(r){case i.ANIMATIONLOOPMODE_CYCLE:case i.ANIMATIONLOOPMODE_CONSTANT:return this.floatInterpolateFunction(h,c,l);case i.ANIMATIONLOOPMODE_RELATIVE:return n*t+this.floatInterpolateFunction(h,c,l)}break;case i.ANIMATIONTYPE_QUATERNION:var u=null;switch(r){case i.ANIMATIONLOOPMODE_CYCLE:case i.ANIMATIONLOOPMODE_CONSTANT:u=this.quaternionInterpolateFunction(h,c,l);break;case i.ANIMATIONLOOPMODE_RELATIVE:u=this.quaternionInterpolateFunction(h,c,l).add(n.scale(t))}return u;case i.ANIMATIONTYPE_VECTOR3:switch(r){case i.ANIMATIONLOOPMODE_CYCLE:case i.ANIMATIONLOOPMODE_CONSTANT:return this.vector3InterpolateFunction(h,c,l);case i.ANIMATIONLOOPMODE_RELATIVE:return this.vector3InterpolateFunction(h,c,l).add(n.scale(t))}case i.ANIMATIONTYPE_VECTOR2:switch(r){case i.ANIMATIONLOOPMODE_CYCLE:case i.ANIMATIONLOOPMODE_CONSTANT:return this.vector2InterpolateFunction(h,c,l);case i.ANIMATIONLOOPMODE_RELATIVE:return this.vector2InterpolateFunction(h,c,l).add(n.scale(t))}case i.ANIMATIONTYPE_SIZE:switch(r){case i.ANIMATIONLOOPMODE_CYCLE:case i.ANIMATIONLOOPMODE_CONSTANT:return this.sizeInterpolateFunction(h,c,l);case i.ANIMATIONLOOPMODE_RELATIVE:return this.sizeInterpolateFunction(h,c,l).add(n.scale(t))}case i.ANIMATIONTYPE_COLOR3:switch(r){case i.ANIMATIONLOOPMODE_CYCLE:case i.ANIMATIONLOOPMODE_CONSTANT:return this.color3InterpolateFunction(h,c,l);case i.ANIMATIONLOOPMODE_RELATIVE:return this.color3InterpolateFunction(h,c,l).add(n.scale(t))}case i.ANIMATIONTYPE_MATRIX:switch(r){case i.ANIMATIONLOOPMODE_CYCLE:case i.ANIMATIONLOOPMODE_CONSTANT:
  17. if(this.allowMatricesInterpolation)return this.matrixInterpolateFunction(h,c,l);case i.ANIMATIONLOOPMODE_RELATIVE:return h}}break}return this._getKeyValue(this._keys[this._keys.length-1].value)},i.prototype.setValue=function(t,i){void 0===i&&(i=!1);var r,n;if(this.targetPropertyPath.length>1){for(var o=this._target[this.targetPropertyPath[0]],s=1;s<this.targetPropertyPath.length-1;s++)o=o[this.targetPropertyPath[s]];r=this.targetPropertyPath[this.targetPropertyPath.length-1],n=o}else r=this.targetPropertyPath[0],n=this._target;this.enableBlending&&this._blendingFactor<=1?(this._originalBlendValue||(n[r].clone?this._originalBlendValue=n[r].clone():this._originalBlendValue=n[r]),this._originalBlendValue.prototype?this._originalBlendValue.prototype.Lerp?n[r]=this._originalBlendValue.construtor.prototype.Lerp(t,this._originalBlendValue,this._blendingFactor):n[r]=t:this._originalBlendValue.m?n[r]=e.Matrix.Lerp(this._originalBlendValue,t,this._blendingFactor):n[r]=this._originalBlendValue*(1-this._blendingFactor)+this._blendingFactor*t,this._blendingFactor+=this.blendingSpeed):n[r]=t,this._target.markAsDirty&&this._target.markAsDirty(this.targetProperty)},i.prototype.goToFrame=function(e){e<this._keys[0].frame?e=this._keys[0].frame:e>this._keys[this._keys.length-1].frame&&(e=this._keys[this._keys.length-1].frame);var t=this._interpolate(e,0,this.loopMode);this.setValue(t)},i.prototype.animate=function(t,r,n,o,s,a){if(void 0===a&&(a=!1),!this.targetPropertyPath||this.targetPropertyPath.length<1)return this._stopped=!0,!1;var h=!0;if(0!==this._keys[0].frame){var c={frame:0,value:this._keys[0].value};this._keys.splice(0,0,c)}(r<this._keys[0].frame||r>this._keys[this._keys.length-1].frame)&&(r=this._keys[0].frame),(n<this._keys[0].frame||n>this._keys[this._keys.length-1].frame)&&(n=this._keys[this._keys.length-1].frame);var l,u=n-r,f=t*(this.framePerSecond*s)/1e3,d=0;if(f>u&&!o)h=!1,d=this._getKeyValue(this._keys[this._keys.length-1].value);else if(this.loopMode!==i.ANIMATIONLOOPMODE_CYCLE){var p=n.toString()+r.toString();if(!this._offsetsCache[p]){var _=this._interpolate(r,0,i.ANIMATIONLOOPMODE_CYCLE),m=this._interpolate(n,0,i.ANIMATIONLOOPMODE_CYCLE);switch(this.dataType){case i.ANIMATIONTYPE_FLOAT:this._offsetsCache[p]=m-_;break;case i.ANIMATIONTYPE_QUATERNION:this._offsetsCache[p]=m.subtract(_);break;case i.ANIMATIONTYPE_VECTOR3:this._offsetsCache[p]=m.subtract(_);case i.ANIMATIONTYPE_VECTOR2:this._offsetsCache[p]=m.subtract(_);case i.ANIMATIONTYPE_SIZE:this._offsetsCache[p]=m.subtract(_);case i.ANIMATIONTYPE_COLOR3:this._offsetsCache[p]=m.subtract(_)}this._highLimitsCache[p]=m}d=this._highLimitsCache[p],l=this._offsetsCache[p]}if(void 0===l)switch(this.dataType){case i.ANIMATIONTYPE_FLOAT:l=0;break;case i.ANIMATIONTYPE_QUATERNION:l=new e.Quaternion(0,0,0,0);break;case i.ANIMATIONTYPE_VECTOR3:l=e.Vector3.Zero();break;case i.ANIMATIONTYPE_VECTOR2:l=e.Vector2.Zero();break;case i.ANIMATIONTYPE_SIZE:l=e.Size.Zero();break;case i.ANIMATIONTYPE_COLOR3:l=e.Color3.Black()}var g=f/u>>0,v=h?r+f%u:n,y=this._interpolate(v,g,this.loopMode,l,d);this.setValue(y);for(var x=0;x<this._events.length;x++)if(v>=this._events[x].frame){var b=this._events[x];b.isDone||(b.onlyOnce&&(this._events.splice(x,1),x--),b.isDone=!0,b.action())}else this._events[x].isDone&&!this._events[x].onlyOnce&&(this._events[x].isDone=!1);return h||(this._stopped=!0),h},i.prototype.serialize=function(){var e={};e.name=this.name,e.property=this.targetProperty,e.framePerSecond=this.framePerSecond,e.dataType=this.dataType,e.loopBehavior=this.loopMode;var t=this.dataType;e.keys=[];for(var r=this.getKeys(),n=0;n<r.length;n++){var o=r[n],s={};switch(s.frame=o.frame,t){case i.ANIMATIONTYPE_FLOAT:s.values=[o.value];break;case i.ANIMATIONTYPE_QUATERNION:case i.ANIMATIONTYPE_MATRIX:case i.ANIMATIONTYPE_VECTOR3:case i.ANIMATIONTYPE_COLOR3:s.values=o.value.asArray()}e.keys.push(s)}e.ranges=[];for(var a in this._ranges){var h={};h.name=a,h.from=this._ranges[a].from,h.to=this._ranges[a].to,e.ranges.push(h)}return e},Object.defineProperty(i,"ANIMATIONTYPE_FLOAT",{get:function(){return i._ANIMATIONTYPE_FLOAT},enumerable:!0,configurable:!0}),Object.defineProperty(i,"ANIMATIONTYPE_VECTOR3",{get:function(){return i._ANIMATIONTYPE_VECTOR3},enumerable:!0,configurable:!0}),Object.defineProperty(i,"ANIMATIONTYPE_VECTOR2",{get:function(){return i._ANIMATIONTYPE_VECTOR2},enumerable:!0,configurable:!0}),Object.defineProperty(i,"ANIMATIONTYPE_SIZE",{get:function(){return i._ANIMATIONTYPE_SIZE},enumerable:!0,configurable:!0}),Object.defineProperty(i,"ANIMATIONTYPE_QUATERNION",{get:function(){return i._ANIMATIONTYPE_QUATERNION},enumerable:!0,configurable:!0}),Object.defineProperty(i,"ANIMATIONTYPE_MATRIX",{get:function(){return i._ANIMATIONTYPE_MATRIX},enumerable:!0,configurable:!0}),Object.defineProperty(i,"ANIMATIONTYPE_COLOR3",{get:function(){return i._ANIMATIONTYPE_COLOR3},enumerable:!0,configurable:!0}),Object.defineProperty(i,"ANIMATIONLOOPMODE_RELATIVE",{get:function(){return i._ANIMATIONLOOPMODE_RELATIVE},enumerable:!0,configurable:!0}),Object.defineProperty(i,"ANIMATIONLOOPMODE_CYCLE",{get:function(){return i._ANIMATIONLOOPMODE_CYCLE},enumerable:!0,configurable:!0}),Object.defineProperty(i,"ANIMATIONLOOPMODE_CONSTANT",{get:function(){return i._ANIMATIONLOOPMODE_CONSTANT},enumerable:!0,configurable:!0}),i.Parse=function(t){var r,n,o=new i(t.name,t.property,t.framePerSecond,t.dataType,t.loopBehavior),s=t.dataType,a=[];for(n=0;n<t.keys.length;n++){var h=t.keys[n];switch(s){case i.ANIMATIONTYPE_FLOAT:r=h.values[0];break;case i.ANIMATIONTYPE_QUATERNION:r=e.Quaternion.FromArray(h.values);break;case i.ANIMATIONTYPE_MATRIX:r=e.Matrix.FromArray(h.values);break;case i.ANIMATIONTYPE_COLOR3:r=e.Color3.FromArray(h.values);break;case i.ANIMATIONTYPE_VECTOR3:default:r=e.Vector3.FromArray(h.values)}a.push({frame:h.frame,value:r})}if(o.setKeys(a),t.ranges)for(n=0;n<t.ranges.length;n++)r=t.ranges[n],o.createRange(r.name,r.from,r.to);return o},i.AppendSerializedAnimations=function(e,t){if(e.animations){t.animations=[];for(var i=0;i<e.animations.length;i++){var r=e.animations[i];t.animations.push(r.serialize())}}},i._ANIMATIONTYPE_FLOAT=0,i._ANIMATIONTYPE_VECTOR3=1,i._ANIMATIONTYPE_QUATERNION=2,i._ANIMATIONTYPE_MATRIX=3,i._ANIMATIONTYPE_COLOR3=4,i._ANIMATIONTYPE_VECTOR2=5,i._ANIMATIONTYPE_SIZE=6,i._ANIMATIONLOOPMODE_RELATIVE=0,i._ANIMATIONLOOPMODE_CYCLE=1,i._ANIMATIONLOOPMODE_CONSTANT=2,i}();e.Animation=n}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function e(e,t,i,r,n,o,s,a){void 0===i&&(i=0),void 0===r&&(r=100),void 0===n&&(n=!1),void 0===o&&(o=1),this.target=t,this.fromFrame=i,this.toFrame=r,this.loopAnimation=n,this.speedRatio=o,this.onAnimationEnd=s,this._animations=new Array,this._paused=!1,this.animationStarted=!1,a&&this.appendAnimations(t,a),this._scene=e,e._activeAnimatables.push(this)}return e.prototype.getAnimations=function(){return this._animations},e.prototype.appendAnimations=function(e,t){for(var i=0;i<t.length;i++){var r=t[i];r._target=e,this._animations.push(r)}},e.prototype.getAnimationByTargetProperty=function(e){for(var t=this._animations,i=0;i<t.length;i++)if(t[i].targetProperty===e)return t[i];return null},e.prototype.reset=function(){for(var e=this._animations,t=0;t<e.length;t++)e[t].reset();this._localDelayOffset=null,this._pausedDelay=null},e.prototype.enableBlending=function(e){for(var t=this._animations,i=0;i<t.length;i++)t[i].enableBlending=!0,t[i].blendingSpeed=e},e.prototype.disableBlending=function(){for(var e=this._animations,t=0;t<e.length;t++)e[t].enableBlending=!1},e.prototype.goToFrame=function(e){for(var t=this._animations,i=0;i<t.length;i++)t[i].goToFrame(e)},e.prototype.pause=function(){this._paused||(this._paused=!0)},e.prototype.restart=function(){this._paused=!1},e.prototype.stop=function(){var e=this._scene._activeAnimatables.indexOf(this);if(e>-1){this._scene._activeAnimatables.splice(e,1);for(var t=this._animations,e=0;e<t.length;e++)t[e].reset();this.onAnimationEnd&&this.onAnimationEnd()}},e.prototype._animate=function(e){if(this._paused)return this.animationStarted=!1,this._pausedDelay||(this._pausedDelay=e),!0;this._localDelayOffset?this._pausedDelay&&(this._localDelayOffset+=e-this._pausedDelay,this._pausedDelay=null):this._localDelayOffset=e;var t,i=!1,r=this._animations;for(t=0;t<r.length;t++){var n=r[t],o=n.animate(e-this._localDelayOffset,this.fromFrame,this.toFrame,this.loopAnimation,this.speedRatio);i=i||o}return this.animationStarted=i,i||(t=this._scene._activeAnimatables.indexOf(this),this._scene._activeAnimatables.splice(t,1)),!i&&this.onAnimationEnd&&(this.onAnimationEnd(),this.onAnimationEnd=null),i},e}();e.Animatable=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function e(){this._easingMode=e.EASINGMODE_EASEIN}return Object.defineProperty(e,"EASINGMODE_EASEIN",{get:function(){return e._EASINGMODE_EASEIN},enumerable:!0,configurable:!0}),Object.defineProperty(e,"EASINGMODE_EASEOUT",{get:function(){return e._EASINGMODE_EASEOUT},enumerable:!0,configurable:!0}),Object.defineProperty(e,"EASINGMODE_EASEINOUT",{get:function(){return e._EASINGMODE_EASEINOUT},enumerable:!0,configurable:!0}),e.prototype.setEasingMode=function(e){var t=Math.min(Math.max(e,0),2);this._easingMode=t},e.prototype.getEasingMode=function(){return this._easingMode},e.prototype.easeInCore=function(e){throw new Error("You must implement this method")},e.prototype.ease=function(t){switch(this._easingMode){case e.EASINGMODE_EASEIN:return this.easeInCore(t);case e.EASINGMODE_EASEOUT:return 1-this.easeInCore(1-t)}return t>=.5?.5*(1-this.easeInCore(2*(1-t)))+.5:.5*this.easeInCore(2*t)},e._EASINGMODE_EASEIN=0,e._EASINGMODE_EASEOUT=1,e._EASINGMODE_EASEINOUT=2,e}();e.EasingFunction=t;var i=function(e){function t(){e.apply(this,arguments)}return __extends(t,e),t.prototype.easeInCore=function(e){return e=Math.max(0,Math.min(1,e)),1-Math.sqrt(1-e*e)},t}(t);e.CircleEase=i;var r=function(e){function t(t){void 0===t&&(t=1),e.call(this),this.amplitude=t}return __extends(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.amplitude);return Math.pow(e,3)-e*t*Math.sin(3.141592653589793*e)},t}(t);e.BackEase=r;var n=function(e){function t(t,i){void 0===t&&(t=3),void 0===i&&(i=2),e.call(this),this.bounces=t,this.bounciness=i}return __extends(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.bounces),i=this.bounciness;1>=i&&(i=1.001);var r=Math.pow(i,t),n=1-i,o=(1-r)/n+.5*r,s=e*o,a=Math.log(-s*(1-i)+1)/Math.log(i),h=Math.floor(a),c=h+1,l=(1-Math.pow(i,h))/(n*o),u=(1-Math.pow(i,c))/(n*o),f=.5*(l+u),d=e-f,p=f-l;return-Math.pow(1/i,t-h)/(p*p)*(d-p)*(d+p)},t}(t);e.BounceEase=n;var o=function(e){function t(){e.apply(this,arguments)}return __extends(t,e),t.prototype.easeInCore=function(e){return e*e*e},t}(t);e.CubicEase=o;var s=function(e){function t(t,i){void 0===t&&(t=3),void 0===i&&(i=3),e.call(this),this.oscillations=t,this.springiness=i}return __extends(t,e),t.prototype.easeInCore=function(e){var t,i=Math.max(0,this.oscillations),r=Math.max(0,this.springiness);return t=0==r?e:(Math.exp(r*e)-1)/(Math.exp(r)-1),t*Math.sin((6.283185307179586*i+1.5707963267948966)*e)},t}(t);e.ElasticEase=s;var a=function(e){function t(t){void 0===t&&(t=2),e.call(this),this.exponent=t}return __extends(t,e),t.prototype.easeInCore=function(e){return this.exponent<=0?e:(Math.exp(this.exponent*e)-1)/(Math.exp(this.exponent)-1)},t}(t);e.ExponentialEase=a;var h=function(e){function t(t){void 0===t&&(t=2),e.call(this),this.power=t}return __extends(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.power);return Math.pow(e,t)},t}(t);e.PowerEase=h;var c=function(e){function t(){e.apply(this,arguments)}return __extends(t,e),t.prototype.easeInCore=function(e){return e*e},t}(t);e.QuadraticEase=c;var l=function(e){function t(){e.apply(this,arguments)}return __extends(t,e),t.prototype.easeInCore=function(e){return e*e*e*e},t}(t);e.QuarticEase=l;var u=function(e){function t(){e.apply(this,arguments)}return __extends(t,e),t.prototype.easeInCore=function(e){return e*e*e*e*e},t}(t);e.QuinticEase=u;var f=function(e){function t(){e.apply(this,arguments)}return __extends(t,e),t.prototype.easeInCore=function(e){return 1-Math.sin(1.5707963267948966*(1-e))},t}(t);e.SineEase=f;var d=function(t){function i(e,i,r,n){void 0===e&&(e=0),void 0===i&&(i=0),void 0===r&&(r=1),void 0===n&&(n=1),t.call(this),this.x1=e,this.y1=i,this.x2=r,this.y2=n}return __extends(i,t),i.prototype.easeInCore=function(t){return e.BezierCurve.interpolate(t,this.x1,this.y1,this.x2,this.y2)},i}(t);e.BezierCurveEase=d}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(t){function i(i,r,n,o,s){t.call(this,i,r.getScene()),this.name=i,this.children=new Array,this.animations=new Array,this._worldTransform=new e.Matrix,this._absoluteTransform=new e.Matrix,this._invertedAbsoluteTransform=new e.Matrix,this._skeleton=r,this._matrix=o,this._baseMatrix=o,this._restPose=s?s:o.clone(),r.bones.push(this),n?(this._parent=n,n.children.push(this)):this._parent=null,this._updateDifferenceMatrix()}return __extends(i,t),i.prototype.getParent=function(){return this._parent},i.prototype.getLocalMatrix=function(){return this._matrix},i.prototype.getBaseMatrix=function(){return this._baseMatrix},i.prototype.getRestPose=function(){return this._restPose},i.prototype.returnToRest=function(){this.updateMatrix(this._restPose.clone())},i.prototype.getWorldMatrix=function(){return this._worldTransform},i.prototype.getInvertedAbsoluteTransform=function(){return this._invertedAbsoluteTransform},i.prototype.getAbsoluteTransform=function(){return this._absoluteTransform},i.prototype.updateMatrix=function(e){this._baseMatrix=e.clone(),this._matrix=e.clone(),this._skeleton._markAsDirty(),this._updateDifferenceMatrix()},i.prototype._updateDifferenceMatrix=function(e){e||(e=this._baseMatrix),this._parent?e.multiplyToRef(this._parent._absoluteTransform,this._absoluteTransform):this._absoluteTransform.copyFrom(e),this._absoluteTransform.invertToRef(this._invertedAbsoluteTransform);for(var t=0;t<this.children.length;t++)this.children[t]._updateDifferenceMatrix()},i.prototype.markAsDirty=function(){this._currentRenderId++,this._skeleton._markAsDirty()},i.prototype.copyAnimationRange=function(t,i,r,n,o){void 0===n&&(n=!1),void 0===o&&(o=null),0===this.animations.length&&(this.animations.push(new e.Animation(this.name,"_matrix",t.animations[0].framePerSecond,e.Animation.ANIMATIONTYPE_MATRIX,0)),this.animations[0].setKeys([]));var s=t.animations[0].getRange(i);if(!s)return!1;for(var a,h,c,l=s.from,u=s.to,f=t.animations[0].getKeys(),d=t.length,p=t.getParent(),_=this.getParent(),m=n&&p&&d&&this.length&&d!==this.length,g=m?_.length/p.length:null,v=n&&!_&&o&&(1!==o.x||1!==o.y||1!==o.z),y=this.animations[0].getKeys(),x=0,b=f.length;b>x;x++)a=f[x],a.frame>=l&&a.frame<=u&&(n?(c=a.value.clone(),m?(h=c.getTranslation(),c.setTranslation(h.scaleInPlace(g))):v?(h=c.getTranslation(),c.setTranslation(h.multiplyInPlace(o))):c=a.value):c=a.value,y.push({frame:a.frame+r,value:c}));return this.animations[0].createRange(i,l+r,u+r),!0},i}(e.Node);e.Bone=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(t,i,r){this.name=t,this.id=i,this.bones=new Array,this.needInitialSkinMatrix=!1,this._isDirty=!0,this._meshesWithPoseMatrix=new Array,this._identity=e.Matrix.Identity(),this._ranges={},this.bones=[],this._scene=r,r.skeletons.push(this),this._isDirty=!0}return t.prototype.getTransformMatrices=function(e){return this.needInitialSkinMatrix&&e._bonesTransformMatrices?e._bonesTransformMatrices:this._transformMatrices},t.prototype.getScene=function(){return this._scene},t.prototype.toString=function(e){var t="Name: "+this.name+", nBones: "+this.bones.length;if(t+=", nAnimationRanges: "+(this._ranges?Object.keys(this._ranges).length:"none"),e){t+=", Ranges: {";var i=!0;for(var r in this._ranges)i&&(t+=", ",i=!1),t+=r;t+="}"}return t},t.prototype.getBoneIndexByName=function(e){for(var t=0,i=this.bones.length;i>t;t++)if(this.bones[t].name===e)return t;return-1},t.prototype.createAnimationRange=function(t,i,r){if(!this._ranges[t]){this._ranges[t]=new e.AnimationRange(t,i,r);for(var n=0,o=this.bones.length;o>n;n++)this.bones[n].animations[0]&&this.bones[n].animations[0].createRange(t,i,r)}},t.prototype.deleteAnimationRange=function(e,t){void 0===t&&(t=!0);for(var i=0,r=this.bones.length;r>i;i++)this.bones[i].animations[0]&&this.bones[i].animations[0].deleteRange(e,t);this._ranges[e]=void 0},t.prototype.getAnimationRange=function(e){return this._ranges[e]},t.prototype.getAnimationRanges=function(){var e,t=[],i=0;for(e in this._ranges)t[i]=this._ranges[e],i++;return t},t.prototype.copyAnimationRange=function(t,i,r){if(void 0===r&&(r=!1),this._ranges[i]||!t.getAnimationRange(i))return!1;var n,o,s=!0,a=this._getHighestAnimationFrame()+1,h={},c=t.bones;for(o=0,n=c.length;n>o;o++)h[c[o].name]=c[o];this.bones.length!==c.length&&(e.Tools.Warn("copyAnimationRange: this rig has "+this.bones.length+" bones, while source as "+c.length),s=!1);var l=r&&this.dimensionsAtRest&&t.dimensionsAtRest?this.dimensionsAtRest.divide(t.dimensionsAtRest):null;for(o=0,n=this.bones.length;n>o;o++){var u=this.bones[o].name,f=h[u];f?s=s&&this.bones[o].copyAnimationRange(f,i,a,r,l):(e.Tools.Warn("copyAnimationRange: not same rig, missing source bone "+u),s=!1)}var d=t.getAnimationRange(i);return this._ranges[i]=new e.AnimationRange(i,d.from+a,d.to+a),s},t.prototype.returnToRest=function(){for(var e=0;e<this.bones.length;e++)this.bones[e].returnToRest()},t.prototype._getHighestAnimationFrame=function(){for(var e=0,t=0,i=this.bones.length;i>t;t++)if(this.bones[t].animations[0]){var r=this.bones[t].animations[0].getHighestFrame();r>e&&(e=r)}return e},t.prototype.beginAnimation=function(e,t,i,r){var n=this.getAnimationRange(e);return n?this._scene.beginAnimation(this,n.from,n.to,t,i,r):null},t.prototype._markAsDirty=function(){this._isDirty=!0},t.prototype._registerMeshWithPoseMatrix=function(e){this._meshesWithPoseMatrix.push(e)},t.prototype._unregisterMeshWithPoseMatrix=function(e){var t=this._meshesWithPoseMatrix.indexOf(e);t>-1&&this._meshesWithPoseMatrix.splice(t,1)},t.prototype._computeTransformMatrices=function(e,t){for(var i=0;i<this.bones.length;i++){var r=this.bones[i],n=r.getParent();n?r.getLocalMatrix().multiplyToRef(n.getWorldMatrix(),r.getWorldMatrix()):t?r.getLocalMatrix().multiplyToRef(t,r.getWorldMatrix()):r.getWorldMatrix().copyFrom(r.getLocalMatrix()),r.getInvertedAbsoluteTransform().multiplyToArray(r.getWorldMatrix(),e,16*i)}this._identity.copyToArray(e,16*this.bones.length)},t.prototype.prepare=function(){if(this._isDirty){if(this.needInitialSkinMatrix)for(var t=0;t<this._meshesWithPoseMatrix.length;t++){var i=this._meshesWithPoseMatrix[t];i._bonesTransformMatrices&&i._bonesTransformMatrices.length===16*(this.bones.length+1)||(i._bonesTransformMatrices=new Float32Array(16*(this.bones.length+1)));for(var r=i.getPoseMatrix(),n=0;n<this.bones.length;n++){var o=this.bones[n];if(!o.getParent()){var s=o.getBaseMatrix();s.multiplyToRef(r,e.Tmp.Matrix[0]),o._updateDifferenceMatrix(e.Tmp.Matrix[0])}}this._computeTransformMatrices(i._bonesTransformMatrices,r)}else this._transformMatrices&&this._transformMatrices.length===16*(this.bones.length+1)||(this._transformMatrices=new Float32Array(16*(this.bones.length+1))),this._computeTransformMatrices(this._transformMatrices,null);this._isDirty=!1,this._scene._activeBones+=this.bones.length}},t.prototype.getAnimatables=function(){if(!this._animatables||this._animatables.length!==this.bones.length){this._animatables=[];for(var e=0;e<this.bones.length;e++)this._animatables.push(this.bones[e])}return this._animatables},t.prototype.clone=function(i,r){var n=new t(i,r||i,this._scene);n.needInitialSkinMatrix=this.needInitialSkinMatrix;for(var o=0;o<this.bones.length;o++){var s=this.bones[o],a=null;if(s.getParent()){var h=this.bones.indexOf(s.getParent());a=n.bones[h]}var c=new e.Bone(s.name,n,a,s.getBaseMatrix().clone(),s.getRestPose().clone());e.Tools.DeepCopy(s.animations,c.animations)}if(this._ranges){n._ranges={};for(var l in this._ranges)n._ranges[l]=this._ranges[l].clone()}return this._isDirty=!0,n},t.prototype.enableBlending=function(e){void 0===e&&(e=.01),this.bones.forEach(function(t){t.animations.forEach(function(t){t.enableBlending=!0,t.blendingSpeed=e})})},t.prototype.dispose=function(){this._meshesWithPoseMatrix=[],this.getScene().stopAnimation(this),this.getScene().removeSkeleton(this)},t.prototype.serialize=function(){var e={};e.name=this.name,e.id=this.id,e.dimensionsAtRest=this.dimensionsAtRest,e.bones=[],e.needInitialSkinMatrix=this.needInitialSkinMatrix;for(var t=0;t<this.bones.length;t++){var i=this.bones[t],r={parentBoneIndex:i.getParent()?this.bones.indexOf(i.getParent()):-1,name:i.name,matrix:i.getLocalMatrix().toArray(),rest:i.getRestPose().toArray()};e.bones.push(r),i.length&&(r.length=i.length),i.animations&&i.animations.length>0&&(r.animation=i.animations[0].serialize()),e.ranges=[];for(var n in this._ranges){var o={};o.name=n,o.from=this._ranges[n].from,o.to=this._ranges[n].to,e.ranges.push(o)}}return e},t.Parse=function(i,r){var n=new t(i.name,i.id,r);i.dimensionsAtRest&&(n.dimensionsAtRest=e.Vector3.FromArray(i.dimensionsAtRest)),n.needInitialSkinMatrix=i.needInitialSkinMatrix;var o;for(o=0;o<i.bones.length;o++){var s=i.bones[o],a=null;s.parentBoneIndex>-1&&(a=n.bones[s.parentBoneIndex]);var h=s.rest?e.Matrix.FromArray(s.rest):null,c=new e.Bone(s.name,n,a,e.Matrix.FromArray(s.matrix),h);s.length&&(c.length=s.length),s.animation&&c.animations.push(e.Animation.Parse(s.animation))}if(i.ranges)for(o=0;o<i.ranges.length;o++){var l=i.ranges[o];n.createAnimationRange(l.name,l.from,l.to)}return n},t}();e.Skeleton=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(t,i,r,n,o,s,a,h,c,l,u){void 0===a&&(a=e.Texture.NEAREST_SAMPLINGMODE),void 0===u&&(u=e.Engine.TEXTURETYPE_UNSIGNED_INT),this.name=t,this.width=-1,this.height=-1,this.enablePixelPerfectMode=!1,this._reusable=!1,this._textures=new e.SmartArray(2),this._currentRenderTextureInd=0,this._scaleRatio=new e.Vector2(1,1),this.onActivateObservable=new e.Observable,this.onSizeChangedObservable=new e.Observable,this.onApplyObservable=new e.Observable,this.onBeforeRenderObservable=new e.Observable,this.onAfterRenderObservable=new e.Observable,null!=s?(this._camera=s,this._scene=s.getScene(),s.attachPostProcess(this),this._engine=this._scene.getEngine()):this._engine=h,this._options=o,this.renderTargetSamplingMode=a?a:e.Texture.NEAREST_SAMPLINGMODE,this._reusable=c||!1,this._textureType=u,this._samplers=n||[],this._samplers.push("textureSampler"),this._fragmentUrl=i,this._parameters=r||[],this._parameters.push("scale"),this.updateEffect(l)}return Object.defineProperty(t.prototype,"onActivate",{set:function(e){this._onActivateObserver&&this.onActivateObservable.remove(this._onActivateObserver),this._onActivateObserver=this.onActivateObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onSizeChanged",{set:function(e){this._onSizeChangedObserver&&this.onSizeChangedObservable.remove(this._onSizeChangedObserver),this._onSizeChangedObserver=this.onSizeChangedObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onApply",{set:function(e){this._onApplyObserver&&this.onApplyObservable.remove(this._onApplyObserver),this._onApplyObserver=this.onApplyObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onBeforeRender",{set:function(e){this._onBeforeRenderObserver&&this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),this._onBeforeRenderObserver=this.onBeforeRenderObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onAfterRender",{set:function(e){this._onAfterRenderObserver&&this.onAfterRenderObservable.remove(this._onAfterRenderObserver),this._onAfterRenderObserver=this.onAfterRenderObservable.add(e)},enumerable:!0,configurable:!0}),t.prototype.updateEffect=function(e){this._effect=this._engine.createEffect({vertex:"postprocess",fragment:this._fragmentUrl},["position"],this._parameters,this._samplers,void 0!==e?e:"")},t.prototype.isReusable=function(){return this._reusable},t.prototype.markTextureDirty=function(){this.width=-1},t.prototype.activate=function(t,i){t=t||this._camera;var r=t.getScene(),n=t.getEngine().getCaps().maxTextureSize,o=(i?i._width:this._engine.getRenderingCanvas().width)*this._options|0,s=(i?i._height:this._engine.getRenderingCanvas().height)*this._options|0,a=this._options.width||o,h=this._options.height||s;if(this.renderTargetSamplingMode!==e.Texture.NEAREST_SAMPLINGMODE&&(this._options.width||(a=e.Tools.GetExponentOfTwo(a,n)),this._options.height||(h=e.Tools.GetExponentOfTwo(h,n))),this.width!==a||this.height!==h){if(this._textures.length>0){for(var c=0;c<this._textures.length;c++)this._engine._releaseTexture(this._textures.data[c]);this._textures.reset()}this.width=a,this.height=h,this._textures.push(this._engine.createRenderTargetTexture({width:this.width,height:this.height},{generateMipMaps:!1,generateDepthBuffer:0===t._postProcesses.indexOf(this),samplingMode:this.renderTargetSamplingMode,type:this._textureType})),this._reusable&&this._textures.push(this._engine.createRenderTargetTexture({width:this.width,height:this.height},{generateMipMaps:!1,generateDepthBuffer:0===t._postProcesses.indexOf(this),samplingMode:this.renderTargetSamplingMode,type:this._textureType})),this.onSizeChangedObservable.notifyObservers(this)}this.enablePixelPerfectMode?(this._scaleRatio.copyFromFloats(o/a,s/h),this._engine.bindFramebuffer(this._textures.data[this._currentRenderTextureInd],0,o,s)):(this._scaleRatio.copyFromFloats(1,1),this._engine.bindFramebuffer(this._textures.data[this._currentRenderTextureInd])),this.onActivateObservable.notifyObservers(t),this.clearColor?this._engine.clear(this.clearColor,!0,!0):this._engine.clear(r.clearColor,r.autoClear||r.forceWireframe,!0),this._reusable&&(this._currentRenderTextureInd=(this._currentRenderTextureInd+1)%2)},Object.defineProperty(t.prototype,"isSupported",{get:function(){return this._effect.isSupported},enumerable:!0,configurable:!0}),t.prototype.apply=function(){return this._effect.isReady()?(this._engine.enableEffect(this._effect),this._engine.setState(!1),this._engine.setAlphaMode(e.Engine.ALPHA_DISABLE),this._engine.setDepthBuffer(!1),this._engine.setDepthWrite(!1),this._effect._bindTexture("textureSampler",this._textures.data[this._currentRenderTextureInd]),this._effect.setVector2("scale",this._scaleRatio),this.onApplyObservable.notifyObservers(this._effect),this._effect):null},t.prototype.dispose=function(e){if(e=e||this._camera,this._textures.length>0){for(var t=0;t<this._textures.length;t++)this._engine._releaseTexture(this._textures.data[t]);this._textures.reset()}if(e){e.detachPostProcess(this);var i=e._postProcesses.indexOf(this);0===i&&e._postProcesses.length>0&&this._camera._postProcesses[0].markTextureDirty(),this.onActivateObservable.clear(),this.onAfterRenderObservable.clear(),this.onApplyObservable.clear(),this.onBeforeRenderObservable.clear(),this.onSizeChangedObservable.clear()}},t}();e.PostProcess=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(e){this._vertexBuffers={},this._scene=e}return t.prototype._prepareBuffers=function(){if(!this._vertexBuffers[e.VertexBuffer.PositionKind]){var t=[];t.push(1,1),t.push(-1,1),t.push(-1,-1),t.push(1,-1),this._vertexBuffers[e.VertexBuffer.PositionKind]=new e.VertexBuffer(this._scene.getEngine(),t,e.VertexBuffer.PositionKind,!1,!1,2);var i=[];i.push(0),i.push(1),i.push(2),i.push(0),i.push(2),i.push(3),this._indexBuffer=this._scene.getEngine().createIndexBuffer(i)}},t.prototype._prepareFrame=function(e){var t=this._scene.activeCamera._postProcesses;return 0!==t.length&&this._scene.postProcessesEnabled?(t[0].activate(this._scene.activeCamera,e),!0):!1},t.prototype.directRender=function(e,t){for(var i=this._scene.getEngine(),r=0;r<e.length;r++){r<e.length-1?e[r+1].activate(this._scene.activeCamera,t):t?i.bindFramebuffer(t):i.restoreDefaultFramebuffer();var n=e[r],o=n.apply();o&&(n.onBeforeRenderObservable.notifyObservers(o),this._prepareBuffers(),i.bindBuffers(this._vertexBuffers,this._indexBuffer,o),i.draw(!0,0,6),n.onAfterRenderObservable.notifyObservers(o))}i.setDepthBuffer(!0),i.setDepthWrite(!0)},t.prototype._finalizeFrame=function(e,t,i,r){if(r=r||this._scene.activeCamera._postProcesses,0!==r.length&&this._scene.postProcessesEnabled){for(var n=this._scene.getEngine(),o=0,s=r.length;s>o&&(s-1>o?r[o+1].activate(this._scene.activeCamera,t):t?n.bindFramebuffer(t,i):n.restoreDefaultFramebuffer(),!e);o++){var a=r[o],h=a.apply();h&&(a.onBeforeRenderObservable.notifyObservers(h),this._prepareBuffers(),n.bindBuffers(this._vertexBuffers,this._indexBuffer,h),n.draw(!0,0,6),a.onAfterRenderObservable.notifyObservers(h))}n.setDepthBuffer(!0),n.setDepthWrite(!0)}},t.prototype.dispose=function(){var t=this._vertexBuffers[e.VertexBuffer.PositionKind];t&&(t.dispose(),this._vertexBuffers[e.VertexBuffer.PositionKind]=null),this._indexBuffer&&(this._scene.getEngine()._releaseBuffer(this._indexBuffer),this._indexBuffer=null)},t}();e.PostProcessManager=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(e){function t(t,i,r,n,o,s){e.call(this,t,"pass",null,null,i,r,n,o,s)}return __extends(t,e),t}(e.PostProcess);e.PassPostProcess=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function e(e,t){this.type=e,this.jointData=t,t.nativeParams=t.nativeParams||{}}return Object.defineProperty(e.prototype,"physicsJoint",{get:function(){return this._physicsJoint},set:function(e){this._physicsJoint,this._physicsJoint=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"physicsPlugin",{set:function(e){this._physicsPlugin=e},enumerable:!0,configurable:!0}),e.prototype.executeNativeFunction=function(e){e(this._physicsPlugin.world,this._physicsJoint)},e.DistanceJoint=0,e.HingeJoint=1,e.BallAndSocketJoint=2,e.WheelJoint=3,e.SliderJoint=4,e.PrismaticJoint=5,e.UniversalJoint=6,e.Hinge2Joint=e.WheelJoint,e.PointToPointJoint=8,e.SpringJoint=9,e.LockJoint=10,e}();e.PhysicsJoint=t;var i=function(e){function i(i){e.call(this,t.DistanceJoint,i)}return __extends(i,e),i.prototype.updateDistance=function(e,t){this._physicsPlugin.updateDistanceJoint(this,e,t)},i}(t);e.DistanceJoint=i;var r=function(e){function t(t,i){e.call(this,t,i)}return __extends(t,e),t.prototype.setMotor=function(e,t){this._physicsPlugin.setMotor(this,e,t)},t.prototype.setLimit=function(e,t){this._physicsPlugin.setLimit(this,e,t)},t}(t);e.MotorEnabledJoint=r;var n=function(e){function i(i){e.call(this,t.HingeJoint,i)}return __extends(i,e),i.prototype.setMotor=function(e,t){this._physicsPlugin.setMotor(this,e,t)},i.prototype.setLimit=function(e,t){this._physicsPlugin.setLimit(this,e,t)},i}(r);e.HingeJoint=n;var o=function(e){function i(i){e.call(this,t.Hinge2Joint,i)}return __extends(i,e),i.prototype.setMotor=function(e,t,i){void 0===i&&(i=0),this._physicsPlugin.setMotor(this,e,t,i)},i.prototype.setLimit=function(e,t,i){void 0===i&&(i=0),this._physicsPlugin.setLimit(this,e,t,i)},i}(r);e.Hinge2Joint=o}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(t,i,r,n){var o=this;return void 0===r&&(r={mass:0}),this.object=t,this.type=i,this._options=r,this._scene=n,this._bodyUpdateRequired=!1,this._onBeforePhysicsStepCallbacks=new Array,this._onAfterPhysicsStepCallbacks=new Array,this._onPhysicsCollideCallbacks=[],this._deltaPosition=e.Vector3.Zero(),this._tmpPositionWithDelta=e.Vector3.Zero(),this._tmpRotationWithDelta=new e.Quaternion,this.beforeStep=function(){o.object.position.subtractToRef(o._deltaPosition,o._tmpPositionWithDelta),o._deltaRotationConjugated?o.object.rotationQuaternion.multiplyToRef(o._deltaRotationConjugated,o._tmpRotationWithDelta):o._tmpRotationWithDelta.copyFrom(o.object.rotationQuaternion),o._physicsEngine.getPhysicsPlugin().setPhysicsBodyTransformation(o,o._tmpPositionWithDelta,o._tmpRotationWithDelta),
  18. o._onBeforePhysicsStepCallbacks.forEach(function(e){e(o)})},this.afterStep=function(){o._onAfterPhysicsStepCallbacks.forEach(function(e){e(o)}),o._physicsEngine.getPhysicsPlugin().setTransformationFromPhysicsBody(o),o.object.position.addInPlace(o._deltaPosition),o._deltaRotation&&o.object.rotationQuaternion.multiplyInPlace(o._deltaRotation)},this.onCollide=function(e){if(o._onPhysicsCollideCallbacks.length){var t=o._physicsEngine.getImpostorWithPhysicsBody(e.body);t&&o._onPhysicsCollideCallbacks.filter(function(e){return-1!==e.otherImpostors.indexOf(t)}).forEach(function(e){e.callback(o,t)})}},this.object?(!this._scene&&t.getScene&&(this._scene=t.getScene()),this._physicsEngine=this._scene.getPhysicsEngine(),void(this._physicsEngine?(this.object.rotationQuaternion||(this.object.rotation?this.object.rotationQuaternion=e.Quaternion.RotationYawPitchRoll(this.object.rotation.y,this.object.rotation.x,this.object.rotation.z):this.object.rotationQuaternion=new e.Quaternion),this._options.mass=void 0===r.mass?0:r.mass,this._options.friction=void 0===r.friction?.2:r.friction,this._options.restitution=void 0===r.restitution?.2:r.restitution,this._joints=[],this.object.parent||this._init()):e.Tools.Error("Physics not enabled. Please use scene.enablePhysics(...) before creating impostors."))):void e.Tools.Error("No object was provided. A physics object is obligatory")}return t.prototype._init=function(){this._physicsEngine.removeImpostor(this),this.physicsBody=null,this._parent=this._parent||this._getPhysicsParent(),this.parent||this._physicsEngine.addImpostor(this)},t.prototype._getPhysicsParent=function(){if(this.object.parent instanceof e.AbstractMesh){var t=this.object.parent;return t.physicsImpostor}},t.prototype.isBodyInitRequired=function(){return this._bodyUpdateRequired||!this._physicsBody&&!this._parent},t.prototype.setScalingUpdated=function(e){this.forceUpdate()},t.prototype.forceUpdate=function(){this._init(),this.parent&&this.parent.forceUpdate()},Object.defineProperty(t.prototype,"physicsBody",{get:function(){return this._parent?this._parent.physicsBody:this._physicsBody},set:function(e){this._physicsBody&&this._physicsEngine.getPhysicsPlugin().removePhysicsBody(this),this._physicsBody=e,this.resetUpdateFlags()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"parent",{get:function(){return this._parent},enumerable:!0,configurable:!0}),t.prototype.resetUpdateFlags=function(){this._bodyUpdateRequired=!1},t.prototype.getObjectExtendSize=function(){return this.object.getBoundingInfo?(this.object.computeWorldMatrix&&this.object.computeWorldMatrix(!0),this.object.getBoundingInfo().boundingBox.extendSize.scale(2).multiply(this.object.scaling)):t.DEFAULT_OBJECT_SIZE},t.prototype.getObjectCenter=function(){return this.object.getBoundingInfo?this.object.getBoundingInfo().boundingBox.center:this.object.position},t.prototype.getParam=function(e){return this._options[e]},t.prototype.setParam=function(e,t){this._options[e]=t,this._bodyUpdateRequired=!0},t.prototype.setMass=function(e){this.getParam("mass")!==e&&this.setParam("mass",e),this._physicsEngine.getPhysicsPlugin().setBodyMass(this,e)},t.prototype.getLinearVelocity=function(){return this._physicsEngine.getPhysicsPlugin().getLinearVelocity(this)},t.prototype.setLinearVelocity=function(e){this._physicsEngine.getPhysicsPlugin().setLinearVelocity(this,e)},t.prototype.getAngularVelocity=function(){return this._physicsEngine.getPhysicsPlugin().getAngularVelocity(this)},t.prototype.setAngularVelocity=function(e){this._physicsEngine.getPhysicsPlugin().setAngularVelocity(this,e)},t.prototype.executeNativeFunction=function(e){e(this._physicsEngine.getPhysicsPlugin().world,this.physicsBody)},t.prototype.registerBeforePhysicsStep=function(e){this._onBeforePhysicsStepCallbacks.push(e)},t.prototype.unregisterBeforePhysicsStep=function(t){var i=this._onBeforePhysicsStepCallbacks.indexOf(t);i>-1?this._onBeforePhysicsStepCallbacks.splice(i,1):e.Tools.Warn("Function to remove was not found")},t.prototype.registerAfterPhysicsStep=function(e){this._onAfterPhysicsStepCallbacks.push(e)},t.prototype.unregisterAfterPhysicsStep=function(t){var i=this._onAfterPhysicsStepCallbacks.indexOf(t);i>-1?this._onAfterPhysicsStepCallbacks.splice(i,1):e.Tools.Warn("Function to remove was not found")},t.prototype.registerOnPhysicsCollide=function(e,t){var i=e instanceof Array?e:[e];this._onPhysicsCollideCallbacks.push({callback:t,otherImpostors:i})},t.prototype.unregisterOnPhysicsCollide=function(t,i){var r=t instanceof Array?t:[t],n=this._onPhysicsCollideCallbacks.indexOf({callback:i,otherImpostors:r});n>-1?this._onPhysicsCollideCallbacks.splice(n,1):e.Tools.Warn("Function to remove was not found")},t.prototype.applyForce=function(e,t){this._physicsEngine.getPhysicsPlugin().applyForce(this,e,t)},t.prototype.applyImpulse=function(e,t){this._physicsEngine.getPhysicsPlugin().applyImpulse(this,e,t)},t.prototype.createJoint=function(t,i,r){var n=new e.PhysicsJoint(i,r);this.addJoint(t,n)},t.prototype.addJoint=function(e,t){this._joints.push({otherImpostor:e,joint:t}),this._physicsEngine.addJoint(this,e,t)},t.prototype.sleep=function(){this._physicsEngine.getPhysicsPlugin().sleepBody(this)},t.prototype.wakeUp=function(){this._physicsEngine.getPhysicsPlugin().wakeUpBody(this)},t.prototype.clone=function(e){return e?new t(e,this.type,this._options,this._scene):null},t.prototype.dispose=function(){var e=this;this._physicsEngine&&(this._joints.forEach(function(t){e._physicsEngine.removeJoint(e,t.otherImpostor,t.joint)}),this._physicsEngine.removeImpostor(this),this.parent&&this.parent.forceUpdate())},t.prototype.setDeltaPosition=function(e){this._deltaPosition.copyFrom(e)},t.prototype.setDeltaRotation=function(t){this._deltaRotation||(this._deltaRotation=new e.Quaternion),this._deltaRotation.copyFrom(t),this._deltaRotationConjugated=this._deltaRotation.conjugate()},t.DEFAULT_OBJECT_SIZE=new e.Vector3(1,1,1),t.NoImpostor=0,t.SphereImpostor=1,t.BoxImpostor=2,t.PlaneImpostor=3,t.MeshImpostor=4,t.CylinderImpostor=7,t.ParticleImpostor=8,t.HeightmapImpostor=9,t}();e.PhysicsImpostor=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(t,i){if(void 0===i&&(i=new e.CannonJSPlugin),this._physicsPlugin=i,this._impostors=[],this._joints=[],!this._physicsPlugin.isSupported())throw new Error("Physics Engine "+this._physicsPlugin.name+" cannot be found. Please make sure it is included.");t=t||new e.Vector3(0,-9.807,0),this.setGravity(t),this.setTimeStep()}return t.prototype.setGravity=function(e){this.gravity=e,this._physicsPlugin.setGravity(this.gravity)},t.prototype.setTimeStep=function(e){void 0===e&&(e=1/60),this._physicsPlugin.setTimeStep(e)},t.prototype.dispose=function(){this._impostors.forEach(function(e){e.dispose()}),this._physicsPlugin.dispose()},t.prototype.getPhysicsPluginName=function(){return this._physicsPlugin.name},t.prototype.addImpostor=function(e){e.uniqueId=this._impostors.push(e),e.parent||this._physicsPlugin.generatePhysicsBody(e)},t.prototype.removeImpostor=function(e){var t=this._impostors.indexOf(e);if(t>-1){var i=this._impostors.splice(t,1);i.length&&(i[0].physicsBody=null)}},t.prototype.addJoint=function(e,t,i){var r={mainImpostor:e,connectedImpostor:t,joint:i};i.physicsPlugin=this._physicsPlugin,this._joints.push(r),this._physicsPlugin.generateJoint(r)},t.prototype.removeJoint=function(e,t,i){var r=this._joints.filter(function(r){return r.connectedImpostor===t&&r.joint===i&&r.mainImpostor===e});r.length&&this._physicsPlugin.removeJoint(r[0])},t.prototype._step=function(e){var t=this;this._impostors.forEach(function(e){e.isBodyInitRequired()&&t._physicsPlugin.generatePhysicsBody(e)}),e>.1?e=.1:0>=e&&(e=1/60),this._physicsPlugin.executeStep(e,this._impostors)},t.prototype.getPhysicsPlugin=function(){return this._physicsPlugin},t.prototype.getImpostorForPhysicsObject=function(e){for(var t=0;t<this._impostors.length;++t)if(this._impostors[t].object===e)return this._impostors[t]},t.prototype.getImpostorWithPhysicsBody=function(e){for(var t=0;t<this._impostors.length;++t)if(this._impostors[t].physicsBody===e)return this._impostors[t]},t.NoImpostor=e.PhysicsImpostor.NoImpostor,t.SphereImpostor=e.PhysicsImpostor.SphereImpostor,t.BoxImpostor=e.PhysicsImpostor.BoxImpostor,t.PlaneImpostor=e.PhysicsImpostor.PlaneImpostor,t.MeshImpostor=e.PhysicsImpostor.MeshImpostor,t.CylinderImpostor=e.PhysicsImpostor.CylinderImpostor,t.HeightmapImpostor=e.PhysicsImpostor.HeightmapImpostor,t.CapsuleImpostor=-1,t.ConeImpostor=-1,t.ConvexHullImpostor=-1,t.Epsilon=.001,t}();e.PhysicsEngine=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(){}return t.prototype.set=function(t,i){switch(i){case e.VertexBuffer.PositionKind:this.positions=t;break;case e.VertexBuffer.NormalKind:this.normals=t;break;case e.VertexBuffer.UVKind:this.uvs=t;break;case e.VertexBuffer.UV2Kind:this.uvs2=t;break;case e.VertexBuffer.UV3Kind:this.uvs3=t;break;case e.VertexBuffer.UV4Kind:this.uvs4=t;break;case e.VertexBuffer.UV5Kind:this.uvs5=t;break;case e.VertexBuffer.UV6Kind:this.uvs6=t;break;case e.VertexBuffer.ColorKind:this.colors=t;break;case e.VertexBuffer.MatricesIndicesKind:this.matricesIndices=t;break;case e.VertexBuffer.MatricesWeightsKind:this.matricesWeights=t;break;case e.VertexBuffer.MatricesIndicesExtraKind:this.matricesIndicesExtra=t;break;case e.VertexBuffer.MatricesWeightsExtraKind:this.matricesWeightsExtra=t}},t.prototype.applyToMesh=function(e,t){this._applyTo(e,t)},t.prototype.applyToGeometry=function(e,t){this._applyTo(e,t)},t.prototype.updateMesh=function(e,t,i){this._update(e)},t.prototype.updateGeometry=function(e,t,i){this._update(e)},t.prototype._applyTo=function(t,i){this.positions&&t.setVerticesData(e.VertexBuffer.PositionKind,this.positions,i),this.normals&&t.setVerticesData(e.VertexBuffer.NormalKind,this.normals,i),this.uvs&&t.setVerticesData(e.VertexBuffer.UVKind,this.uvs,i),this.uvs2&&t.setVerticesData(e.VertexBuffer.UV2Kind,this.uvs2,i),this.uvs3&&t.setVerticesData(e.VertexBuffer.UV3Kind,this.uvs3,i),this.uvs4&&t.setVerticesData(e.VertexBuffer.UV4Kind,this.uvs4,i),this.uvs5&&t.setVerticesData(e.VertexBuffer.UV5Kind,this.uvs5,i),this.uvs6&&t.setVerticesData(e.VertexBuffer.UV6Kind,this.uvs6,i),this.colors&&t.setVerticesData(e.VertexBuffer.ColorKind,this.colors,i),this.matricesIndices&&t.setVerticesData(e.VertexBuffer.MatricesIndicesKind,this.matricesIndices,i),this.matricesWeights&&t.setVerticesData(e.VertexBuffer.MatricesWeightsKind,this.matricesWeights,i),this.matricesIndicesExtra&&t.setVerticesData(e.VertexBuffer.MatricesIndicesExtraKind,this.matricesIndicesExtra,i),this.matricesWeightsExtra&&t.setVerticesData(e.VertexBuffer.MatricesWeightsExtraKind,this.matricesWeightsExtra,i),this.indices&&t.setIndices(this.indices)},t.prototype._update=function(t,i,r){this.positions&&t.updateVerticesData(e.VertexBuffer.PositionKind,this.positions,i,r),this.normals&&t.updateVerticesData(e.VertexBuffer.NormalKind,this.normals,i,r),this.uvs&&t.updateVerticesData(e.VertexBuffer.UVKind,this.uvs,i,r),this.uvs2&&t.updateVerticesData(e.VertexBuffer.UV2Kind,this.uvs2,i,r),this.uvs3&&t.updateVerticesData(e.VertexBuffer.UV3Kind,this.uvs3,i,r),this.uvs4&&t.updateVerticesData(e.VertexBuffer.UV4Kind,this.uvs4,i,r),this.uvs5&&t.updateVerticesData(e.VertexBuffer.UV5Kind,this.uvs5,i,r),this.uvs6&&t.updateVerticesData(e.VertexBuffer.UV6Kind,this.uvs6,i,r),this.colors&&t.updateVerticesData(e.VertexBuffer.ColorKind,this.colors,i,r),this.matricesIndices&&t.updateVerticesData(e.VertexBuffer.MatricesIndicesKind,this.matricesIndices,i,r),this.matricesWeights&&t.updateVerticesData(e.VertexBuffer.MatricesWeightsKind,this.matricesWeights,i,r),this.matricesIndicesExtra&&t.updateVerticesData(e.VertexBuffer.MatricesIndicesExtraKind,this.matricesIndicesExtra,i,r),this.matricesWeightsExtra&&t.updateVerticesData(e.VertexBuffer.MatricesWeightsExtraKind,this.matricesWeightsExtra,i,r),this.indices&&t.setIndices(this.indices)},t.prototype.transform=function(t){var i,r=e.Vector3.Zero();if(this.positions){var n=e.Vector3.Zero();for(i=0;i<this.positions.length;i+=3)e.Vector3.FromArrayToRef(this.positions,i,n),e.Vector3.TransformCoordinatesToRef(n,t,r),this.positions[i]=r.x,this.positions[i+1]=r.y,this.positions[i+2]=r.z}if(this.normals){var o=e.Vector3.Zero();for(i=0;i<this.normals.length;i+=3)e.Vector3.FromArrayToRef(this.normals,i,o),e.Vector3.TransformNormalToRef(o,t,r),this.normals[i]=r.x,this.normals[i+1]=r.y,this.normals[i+2]=r.z}},t.prototype.merge=function(e){if(e.indices){this.indices||(this.indices=[]);for(var t=this.positions?this.positions.length/3:0,i=0;i<e.indices.length;i++)this.indices.push(e.indices[i]+t)}this.positions=this._mergeElement(this.positions,e.positions),this.normals=this._mergeElement(this.normals,e.normals),this.uvs=this._mergeElement(this.uvs,e.uvs),this.uvs2=this._mergeElement(this.uvs2,e.uvs2),this.uvs3=this._mergeElement(this.uvs3,e.uvs3),this.uvs4=this._mergeElement(this.uvs4,e.uvs4),this.uvs5=this._mergeElement(this.uvs5,e.uvs5),this.uvs6=this._mergeElement(this.uvs6,e.uvs6),this.colors=this._mergeElement(this.colors,e.colors),this.matricesIndices=this._mergeElement(this.matricesIndices,e.matricesIndices),this.matricesWeights=this._mergeElement(this.matricesWeights,e.matricesWeights),this.matricesIndicesExtra=this._mergeElement(this.matricesIndicesExtra,e.matricesIndicesExtra),this.matricesWeightsExtra=this._mergeElement(this.matricesWeightsExtra,e.matricesWeightsExtra)},t.prototype._mergeElement=function(e,t){if(!t)return e;if(!e)return t;var i=t.length+e.length,r=e instanceof Float32Array,n=t instanceof Float32Array;if(r){var o=new Float32Array(i);return o.set(e),o.set(t,e.length),o}if(n){for(var s=e.slice(0),a=0,i=t.length;i>a;a++)s.push(t[a]);return s}return e.concat(t)},t.prototype.serialize=function(){var e=this.serialize();return this.positions&&(e.positions=this.positions),this.normals&&(e.normals=this.normals),this.uvs&&(e.uvs=this.uvs),this.uvs2&&(e.uvs2=this.uvs2),this.uvs3&&(e.uvs3=this.uvs3),this.uvs4&&(e.uvs4=this.uvs4),this.uvs5&&(e.uvs5=this.uvs5),this.uvs6&&(e.uvs6=this.uvs6),this.colors&&(e.colors=this.colors),this.matricesIndices&&(e.matricesIndices=this.matricesIndices,e.matricesIndices._isExpanded=!0),this.matricesWeights&&(e.matricesWeights=this.matricesWeights),this.matricesIndicesExtra&&(e.matricesIndicesExtra=this.matricesIndicesExtra,e.matricesIndicesExtra._isExpanded=!0),this.matricesWeightsExtra&&(e.matricesWeightsExtra=this.matricesWeightsExtra),e.indices=this.indices,e},t.ExtractFromMesh=function(e,i){return t._ExtractFrom(e,i)},t.ExtractFromGeometry=function(e,i){return t._ExtractFrom(e,i)},t._ExtractFrom=function(i,r){var n=new t;return i.isVerticesDataPresent(e.VertexBuffer.PositionKind)&&(n.positions=i.getVerticesData(e.VertexBuffer.PositionKind,r)),i.isVerticesDataPresent(e.VertexBuffer.NormalKind)&&(n.normals=i.getVerticesData(e.VertexBuffer.NormalKind,r)),i.isVerticesDataPresent(e.VertexBuffer.UVKind)&&(n.uvs=i.getVerticesData(e.VertexBuffer.UVKind,r)),i.isVerticesDataPresent(e.VertexBuffer.UV2Kind)&&(n.uvs2=i.getVerticesData(e.VertexBuffer.UV2Kind,r)),i.isVerticesDataPresent(e.VertexBuffer.UV3Kind)&&(n.uvs3=i.getVerticesData(e.VertexBuffer.UV3Kind,r)),i.isVerticesDataPresent(e.VertexBuffer.UV4Kind)&&(n.uvs4=i.getVerticesData(e.VertexBuffer.UV4Kind,r)),i.isVerticesDataPresent(e.VertexBuffer.UV5Kind)&&(n.uvs5=i.getVerticesData(e.VertexBuffer.UV5Kind,r)),i.isVerticesDataPresent(e.VertexBuffer.UV6Kind)&&(n.uvs6=i.getVerticesData(e.VertexBuffer.UV6Kind,r)),i.isVerticesDataPresent(e.VertexBuffer.ColorKind)&&(n.colors=i.getVerticesData(e.VertexBuffer.ColorKind,r)),i.isVerticesDataPresent(e.VertexBuffer.MatricesIndicesKind)&&(n.matricesIndices=i.getVerticesData(e.VertexBuffer.MatricesIndicesKind,r)),i.isVerticesDataPresent(e.VertexBuffer.MatricesWeightsKind)&&(n.matricesWeights=i.getVerticesData(e.VertexBuffer.MatricesWeightsKind,r)),i.isVerticesDataPresent(e.VertexBuffer.MatricesIndicesExtraKind)&&(n.matricesIndicesExtra=i.getVerticesData(e.VertexBuffer.MatricesIndicesExtraKind,r)),i.isVerticesDataPresent(e.VertexBuffer.MatricesWeightsExtraKind)&&(n.matricesWeightsExtra=i.getVerticesData(e.VertexBuffer.MatricesWeightsExtraKind,r)),n.indices=i.getIndices(r),n},t.CreateRibbon=function(i){var r=i.pathArray,n=i.closeArray||!1,o=i.closePath||!1,s=Math.floor(r[0].length/2),a=i.offset||s;a=a>s?s:Math.floor(a);var h,c,l,u,f=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,d=[],p=[],_=[],m=[],g=[],v=[],y=[],x=[],b=[],P=[];if(r.length<2){var A=[],T=[];for(l=0;l<r[0].length-a;l++)A.push(r[0][l]),T.push(r[0][l+a]);r=[A,T]}var E,C,S=0,M=o?1:0;h=r[0].length;var I,D;for(c=0;c<r.length;c++){for(y[c]=0,g[c]=[0],E=r[c],C=E.length,h=C>h?h:C,u=0;C>u;)d.push(E[u].x,E[u].y,E[u].z),u>0&&(I=E[u].subtract(E[u-1]).length(),D=I+y[c],g[c].push(D),y[c]=D),u++;o&&(u--,d.push(E[0].x,E[0].y,E[0].z),I=E[u].subtract(E[0]).length(),D=I+y[c],g[c].push(D),y[c]=D),b[c]=C+M,P[c]=S,S+=C+M}var R,O,w,L;for(l=0;h+M>l;l++){for(x[l]=0,v[l]=[0],c=0;c<r.length-1;c++)R=r[c],O=r[c+1],l===h?(w=R[0],L=O[0]):(w=R[l],L=O[l]),I=L.subtract(w).length(),D=I+x[l],v[l].push(D),x[l]=D;n&&(R=r[c],O=r[0],l===h&&(L=O[0]),I=L.subtract(w).length(),D=I+x[l],x[l]=D)}var B,V;for(c=0;c<r.length;c++)for(l=0;h+M>l;l++)B=g[c][l]/y[c],V=v[l][c]/x[l],m.push(B,V);c=0;for(var F=0,N=b[c]-1,z=b[c+1]-1,k=z>N?N:z,U=P[1]-P[0],G=n?b.length:b.length-1;k>=F&&G>c;)p.push(F,F+U,F+1),p.push(F+U+1,F+1,F+U),F+=1,F===k&&(c++,c===b.length-1?(U=P[0]-P[c],N=b[c]-1,z=b[0]-1):(U=P[c+1]-P[c],N=b[c]-1,z=b[c+1]-1),F=P[c],k=z>N?N+F:z+F);if(t.ComputeNormals(d,p,_),o){var W=0,Y=0;for(c=0;c<r.length;c++)W=3*P[c],Y=c+1<r.length?3*(P[c+1]-1):_.length-3,_[W]=.5*(_[W]+_[Y]),_[W+1]=.5*(_[W+1]+_[Y+1]),_[W+2]=.5*(_[W+2]+_[Y+2]),_[Y]=_[W],_[Y+1]=_[W+1],_[Y+2]=_[W+2]}t._ComputeSides(f,d,p,_,m);var H=new t;return H.indices=p,H.positions=d,H.normals=_,H.uvs=m,o&&(H._idx=P),H},t.CreateBox=function(i){for(var r=[new e.Vector3(0,0,1),new e.Vector3(0,0,-1),new e.Vector3(1,0,0),new e.Vector3(-1,0,0),new e.Vector3(0,1,0),new e.Vector3(0,-1,0)],n=[],o=[],s=[],a=[],h=i.width||i.size||1,c=i.height||i.size||1,l=i.depth||i.size||1,u=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,f=i.faceUV||new Array(6),d=i.faceColors,p=[],_=0;6>_;_++)void 0===f[_]&&(f[_]=new e.Vector4(0,0,1,1)),d&&void 0===d[_]&&(d[_]=new e.Color4(1,1,1,1));for(var m=new e.Vector3(h/2,c/2,l/2),g=0;g<r.length;g++){var v=r[g],y=new e.Vector3(v.y,v.z,v.x),x=e.Vector3.Cross(v,y),b=o.length/3;n.push(b),n.push(b+1),n.push(b+2),n.push(b),n.push(b+2),n.push(b+3);var P=v.subtract(y).subtract(x).multiply(m);o.push(P.x,P.y,P.z),s.push(v.x,v.y,v.z),a.push(f[g].z,f[g].w),d&&p.push(d[g].r,d[g].g,d[g].b,d[g].a),P=v.subtract(y).add(x).multiply(m),o.push(P.x,P.y,P.z),s.push(v.x,v.y,v.z),a.push(f[g].x,f[g].w),d&&p.push(d[g].r,d[g].g,d[g].b,d[g].a),P=v.add(y).add(x).multiply(m),o.push(P.x,P.y,P.z),s.push(v.x,v.y,v.z),a.push(f[g].x,f[g].y),d&&p.push(d[g].r,d[g].g,d[g].b,d[g].a),P=v.add(y).subtract(x).multiply(m),o.push(P.x,P.y,P.z),s.push(v.x,v.y,v.z),a.push(f[g].z,f[g].y),d&&p.push(d[g].r,d[g].g,d[g].b,d[g].a)}t._ComputeSides(u,o,n,s,a);var A=new t;if(A.indices=n,A.positions=o,A.normals=s,A.uvs=a,d){var T=u===e.Mesh.DOUBLESIDE?p.concat(p):p;A.colors=T}return A},t.CreateSphere=function(i){for(var r=i.segments||32,n=i.diameterX||i.diameter||1,o=i.diameterY||i.diameter||1,s=i.diameterZ||i.diameter||1,a=i.arc<=0||i.arc>1?1:i.arc||1,h=i.slice<=0?1:i.slice||1,c=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,l=new e.Vector3(n/2,o/2,s/2),u=2+r,f=2*u,d=[],p=[],_=[],m=[],g=0;u>=g;g++){for(var v=g/u,y=v*Math.PI*h,x=0;f>=x;x++){var b=x/f,P=b*Math.PI*2*a,A=e.Matrix.RotationZ(-y),T=e.Matrix.RotationY(P),E=e.Vector3.TransformCoordinates(e.Vector3.Up(),A),C=e.Vector3.TransformCoordinates(E,T),S=C.multiply(l),M=C.divide(l).normalize();p.push(S.x,S.y,S.z),_.push(M.x,M.y,M.z),m.push(b,v)}if(g>0)for(var I=p.length/3,D=I-2*(f+1);I>D+f+2;D++)d.push(D),d.push(D+1),d.push(D+f+1),d.push(D+f+1),d.push(D+1),d.push(D+f+2)}t._ComputeSides(c,p,d,_,m);var R=new t;return R.indices=d,R.positions=p,R.normals=_,R.uvs=m,R},t.CreateCylinder=function(i){var r,n=i.height||2,o=0===i.diameterTop?0:i.diameterTop||i.diameter||1,s=i.diameterBottom||i.diameter||1,a=i.tessellation||24,h=i.subdivisions||1,c=i.hasRings,l=i.enclose,u=i.arc<=0||i.arc>1?1:i.arc||1,f=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,d=i.faceUV||new Array(3),p=i.faceColors,_=1!==u&&l?2:0,m=c?h:1,g=2+(1+_)*m;for(r=0;g>r;r++)p&&void 0===p[r]&&(p[r]=new e.Color4(1,1,1,1));for(r=0;g>r;r++)d&&void 0===d[r]&&(d[r]=new e.Vector4(0,0,1,1));var v,y,x,b,P,A,T=[],E=[],C=[],S=[],M=[],I=2*Math.PI*u/a,D=(s-o)/2/n,R=e.Vector3.Zero(),O=e.Vector3.Zero(),w=e.Vector3.Zero(),L=e.Vector3.Zero(),B=e.Vector3.Zero(),V=e.Axis.Y,F=1,N=1,z=0,k=0;for(b=0;h>=b;b++)for(y=b/h,x=(y*(o-s)+s)/2,F=c&&0!==b&&b!==h?2:1,A=0;F>A;A++){for(c&&(N+=A),l&&(N+=2*A),P=0;a>=P;P++)v=P*I,R.x=Math.cos(-v)*x,R.y=-n/2+y*n,R.z=Math.sin(-v)*x,0===o&&b===h?(O.x=C[C.length-3*(a+1)],O.y=C[C.length-3*(a+1)+1],O.z=C[C.length-3*(a+1)+2]):(O.x=R.x,O.z=R.z,O.y=Math.sqrt(O.x*O.x+O.z*O.z)*D,O.normalize()),0===P&&(w.copyFrom(R),L.copyFrom(O)),E.push(R.x,R.y,R.z),C.push(O.x,O.y,O.z),k=c?z!==N?d[N].y:d[N].w:d[N].y+(d[N].w-d[N].y)*y,S.push(d[N].x+(d[N].z-d[N].x)*P/a,k),p&&M.push(p[N].r,p[N].g,p[N].b,p[N].a);1!==u&&l&&(E.push(R.x,R.y,R.z),E.push(0,R.y,0),E.push(0,R.y,0),E.push(w.x,w.y,w.z),e.Vector3.CrossToRef(V,O,B),B.normalize(),C.push(B.x,B.y,B.z,B.x,B.y,B.z),e.Vector3.CrossToRef(L,V,B),B.normalize(),C.push(B.x,B.y,B.z,B.x,B.y,B.z),k=c?z!==N?d[N+1].y:d[N+1].w:d[N+1].y+(d[N+1].w-d[N+1].y)*y,S.push(d[N+1].x,k),S.push(d[N+1].z,k),k=c?z!==N?d[N+2].y:d[N+2].w:d[N+2].y+(d[N+2].w-d[N+2].y)*y,S.push(d[N+2].x,k),S.push(d[N+2].z,k),p&&(M.push(p[N+1].r,p[N+1].g,p[N+1].b,p[N+1].a),M.push(p[N+1].r,p[N+1].g,p[N+1].b,p[N+1].a),M.push(p[N+2].r,p[N+2].g,p[N+2].b,p[N+2].a),M.push(p[N+2].r,p[N+2].g,p[N+2].b,p[N+2].a))),z!==N&&(z=N)}var N,U=1!==u&&l?a+4:a;for(b=0,N=0;h>N;N++){for(P=0;a>P;P++){var G=b*(U+1)+P,W=(b+1)*(U+1)+P,Y=b*(U+1)+(P+1),H=(b+1)*(U+1)+(P+1);T.push(G,W,Y),T.push(H,Y,W)}1!==u&&l&&(T.push(G+2,W+2,Y+2),T.push(H+2,Y+2,W+2),T.push(G+4,W+4,Y+4),T.push(H+4,Y+4,W+4)),b=c?b+2:b+1}var j=function(t){var i=t?o/2:s/2;if(0!==i){var r,h,c,l,f=t?d[g-1]:d[0];p&&(l=t?p[g-1]:p[0]);var _=E.length/3,m=t?n/2:-n/2,v=new e.Vector3(0,m,0);E.push(v.x,v.y,v.z),C.push(0,t?1:-1,0),S.push(f.x+.5*(f.z-f.x),f.y+.5*(f.w-f.y)),p&&M.push(l.r,l.g,l.b,l.a);var y=new e.Vector2(.5,.5);for(c=0;a>=c;c++){r=2*Math.PI*c*u/a;var x=Math.cos(-r),b=Math.sin(-r);h=new e.Vector3(x*i,m,b*i);var P=new e.Vector2(x*y.x+.5,b*y.y+.5);E.push(h.x,h.y,h.z),C.push(0,t?1:-1,0),S.push(f.x+(f.z-f.x)*P.x,f.y+(f.w-f.y)*P.y),p&&M.push(l.r,l.g,l.b,l.a)}for(c=0;a>c;c++)t?(T.push(_),T.push(_+(c+2)),T.push(_+(c+1))):(T.push(_),T.push(_+(c+1)),T.push(_+(c+2)))}};j(!1),j(!0),t._ComputeSides(f,E,T,C,S);var X=new t;return X.indices=T,X.positions=E,X.normals=C,X.uvs=S,p&&(X.colors=M),X},t.CreateTorus=function(i){for(var r=[],n=[],o=[],s=[],a=i.diameter||1,h=i.thickness||.5,c=i.tessellation||16,l=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,u=c+1,f=0;c>=f;f++)for(var d=f/c,p=f*Math.PI*2/c-Math.PI/2,_=e.Matrix.Translation(a/2,0,0).multiply(e.Matrix.RotationY(p)),m=0;c>=m;m++){var g=1-m/c,v=m*Math.PI*2/c+Math.PI,y=Math.cos(v),x=Math.sin(v),b=new e.Vector3(y,x,0),P=b.scale(h/2),A=new e.Vector2(d,g);P=e.Vector3.TransformCoordinates(P,_),b=e.Vector3.TransformNormal(b,_),n.push(P.x,P.y,P.z),o.push(b.x,b.y,b.z),s.push(A.x,A.y);var T=(f+1)%u,E=(m+1)%u;r.push(f*u+m),r.push(f*u+E),r.push(T*u+m),r.push(f*u+E),r.push(T*u+E),r.push(T*u+m)}t._ComputeSides(l,n,r,o,s);var C=new t;return C.indices=r,C.positions=n,C.normals=o,C.uvs=s,C},t.CreateLineSystem=function(e){for(var i=[],r=[],n=e.lines,o=0,s=0;s<n.length;s++)for(var a=n[s],h=0;h<a.length;h++)r.push(a[h].x,a[h].y,a[h].z),h>0&&(i.push(o-1),i.push(o)),o++;var c=new t;return c.indices=i,c.positions=r,c},t.CreateDashedLines=function(i){var r=i.dashSize||3,n=i.gapSize||1,o=i.dashNb||200,s=i.points,a=new Array,h=new Array,c=e.Vector3.Zero(),l=0,u=0,f=0,d=0,p=0,_=0,m=0;for(m=0;m<s.length-1;m++)s[m+1].subtractToRef(s[m],c),l+=c.length();for(f=l/o,d=r*f/(r+n),m=0;m<s.length-1;m++){s[m+1].subtractToRef(s[m],c),u=Math.floor(c.length()/f),c.normalize();for(var g=0;u>g;g++)p=f*g,a.push(s[m].x+p*c.x,s[m].y+p*c.y,s[m].z+p*c.z),a.push(s[m].x+(p+d)*c.x,s[m].y+(p+d)*c.y,s[m].z+(p+d)*c.z),h.push(_,_+1),_+=2}var v=new t;return v.positions=a,v.indices=h,v},t.CreateGround=function(i){var r,n,o=[],s=[],a=[],h=[],c=i.width||1,l=i.height||1,u=i.subdivisions||1;for(r=0;u>=r;r++)for(n=0;u>=n;n++){var f=new e.Vector3(n*c/u-c/2,0,(u-r)*l/u-l/2),d=new e.Vector3(0,1,0);s.push(f.x,f.y,f.z),a.push(d.x,d.y,d.z),h.push(n/u,1-r/u)}for(r=0;u>r;r++)for(n=0;u>n;n++)o.push(n+1+(r+1)*(u+1)),o.push(n+1+r*(u+1)),o.push(n+r*(u+1)),o.push(n+(r+1)*(u+1)),o.push(n+1+(r+1)*(u+1)),o.push(n+r*(u+1));var p=new t;return p.indices=o,p.positions=s,p.normals=a,p.uvs=h,p},t.CreateTiledGround=function(i){function r(t,i,r,s){var a=_.length/3,h=d.w+1;for(n=0;n<d.h;n++)for(o=0;o<d.w;o++){var c=[a+o+n*h,a+(o+1)+n*h,a+(o+1)+(n+1)*h,a+o+(n+1)*h];p.push(c[1]),p.push(c[2]),p.push(c[3]),p.push(c[0]),p.push(c[1]),p.push(c[3])}var l=e.Vector3.Zero(),u=new e.Vector3(0,1,0);for(n=0;n<=d.h;n++)for(l.z=n*(s-i)/d.h+i,o=0;o<=d.w;o++)l.x=o*(r-t)/d.w+t,l.y=0,_.push(l.x,l.y,l.z),m.push(u.x,u.y,u.z),g.push(o/d.w,n/d.h)}var n,o,s,a,h=i.xmin,c=i.zmin,l=i.xmax,u=i.zmax,f=i.subdivisions||{w:1,h:1},d=i.precision||{w:1,h:1},p=[],_=[],m=[],g=[];f.h=f.w<1?1:f.h,f.w=f.w<1?1:f.w,d.w=d.w<1?1:d.w,d.h=d.h<1?1:d.h;var v={w:(l-h)/f.w,h:(u-c)/f.h};for(s=0;s<f.h;s++)for(a=0;a<f.w;a++)r(h+a*v.w,c+s*v.h,h+(a+1)*v.w,c+(s+1)*v.h);var y=new t;return y.indices=p,y.positions=_,y.normals=m,y.uvs=g,y},t.CreateGroundFromHeightMap=function(i){var r,n,o=[],s=[],a=[],h=[];for(r=0;r<=i.subdivisions;r++)for(n=0;n<=i.subdivisions;n++){var c=new e.Vector3(n*i.width/i.subdivisions-i.width/2,0,(i.subdivisions-r)*i.height/i.subdivisions-i.height/2),l=(c.x+i.width/2)/i.width*(i.bufferWidth-1)|0,u=(1-(c.z+i.height/2)/i.height)*(i.bufferHeight-1)|0,f=4*(l+u*i.bufferWidth),d=i.buffer[f]/255,p=i.buffer[f+1]/255,_=i.buffer[f+2]/255,m=.3*d+.59*p+.11*_;c.y=i.minHeight+(i.maxHeight-i.minHeight)*m,s.push(c.x,c.y,c.z),a.push(0,0,0),h.push(n/i.subdivisions,1-r/i.subdivisions)}for(r=0;r<i.subdivisions;r++)for(n=0;n<i.subdivisions;n++)o.push(n+1+(r+1)*(i.subdivisions+1)),o.push(n+1+r*(i.subdivisions+1)),o.push(n+r*(i.subdivisions+1)),o.push(n+(r+1)*(i.subdivisions+1)),o.push(n+1+(r+1)*(i.subdivisions+1)),o.push(n+r*(i.subdivisions+1));t.ComputeNormals(s,o,a);var g=new t;return g.indices=o,g.positions=s,g.normals=a,g.uvs=h,g},t.CreatePlane=function(i){var r=[],n=[],o=[],s=[],a=i.width||i.size||1,h=i.height||i.size||1,c=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,l=a/2,u=h/2;n.push(-l,-u,0),o.push(0,0,-1),s.push(0,0),n.push(l,-u,0),o.push(0,0,-1),s.push(1,0),n.push(l,u,0),o.push(0,0,-1),s.push(1,1),n.push(-l,u,0),o.push(0,0,-1),s.push(0,1),r.push(0),r.push(1),r.push(2),r.push(0),r.push(2),r.push(3),t._ComputeSides(c,n,r,o,s);var f=new t;return f.indices=r,f.positions=n,f.normals=o,f.uvs=s,f},t.CreateDisc=function(i){var r=[],n=[],o=[],s=[],a=i.radius||.5,h=i.tessellation||64,c=i.arc<=0||i.arc>1?1:i.arc||1,l=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE;r.push(0,0,0),s.push(.5,.5);for(var u=2*Math.PI*c,f=u/h,d=0;u>d;d+=f){var p=Math.cos(d),_=Math.sin(d),m=(p+1)/2,g=(1-_)/2;r.push(a*p,a*_,0),s.push(m,g)}1===c&&(r.push(r[3],r[4],r[5]),s.push(s[2],s[3]));for(var v=r.length/3,y=1;v-1>y;y++)n.push(y+1,0,y);t.ComputeNormals(r,n,o),t._ComputeSides(l,r,n,o,s);var x=new t;return x.indices=n,x.positions=r,x.normals=o,x.uvs=s,x},t.CreateIcoSphere=function(i){var r,n=i.sideOrientation||e.Mesh.DEFAULTSIDE,o=i.radius||1,s=void 0===i.flat?!0:i.flat,a=i.subdivisions||4,h=i.radiusX||o,c=i.radiusY||o,l=i.radiusZ||o,u=(1+Math.sqrt(5))/2,f=[-1,u,-0,1,u,0,-1,-u,0,1,-u,0,0,-1,-u,0,1,-u,0,-1,u,0,1,u,u,0,1,u,0,-1,-u,0,1,-u,0,-1],d=[0,11,5,0,5,1,0,1,7,0,7,10,12,22,23,1,5,20,5,11,4,23,22,13,22,18,6,7,1,8,14,21,4,14,4,2,16,13,6,15,6,19,3,8,9,4,21,5,13,17,23,6,13,22,19,6,18,9,8,1],p=[0,1,2,3,4,5,6,7,8,9,10,11,0,2,3,3,3,4,7,8,9,9,10,11],_=[5,1,3,1,6,4,0,0,5,3,4,2,2,2,4,0,2,0,1,1,6,0,6,2,0,4,3,3,4,4,3,1,4,2,4,4,0,2,1,1,2,2,3,3,1,3,2,4],m=138/1024,g=239/1024,v=60/1024,y=26/1024,x=-40/1024,b=20/1024,P=[0,0,0,0,1,0,0,1,1,0,0,0,1,1,0,0,1,1,1,0],A=[],T=[],E=[],C=[],S=0,M=new Array(3),I=new Array(3);for(r=0;3>r;r++)M[r]=e.Vector3.Zero(),I[r]=e.Vector2.Zero();for(var D=0;20>D;D++){for(r=0;3>r;r++){var R=d[3*D+r];M[r].copyFromFloats(f[3*p[R]],f[3*p[R]+1],f[3*p[R]+2]),M[r].normalize().scaleInPlace(o),I[r].copyFromFloats(_[2*R]*m+v+P[D]*x,_[2*R+1]*g+y+P[D]*b)}for(var O=function(t,i,r,n){var o=e.Vector3.Lerp(M[0],M[2],i/a),u=e.Vector3.Lerp(M[1],M[2],i/a),f=a===i?M[2]:e.Vector3.Lerp(o,u,t/(a-i));f.normalize();var d;if(s){var p=e.Vector3.Lerp(M[0],M[2],n/a),_=e.Vector3.Lerp(M[1],M[2],n/a);d=e.Vector3.Lerp(p,_,r/(a-n))}else d=new e.Vector3(f.x,f.y,f.z);d.x/=h,d.y/=c,d.z/=l,d.normalize();var m=e.Vector2.Lerp(I[0],I[2],i/a),g=e.Vector2.Lerp(I[1],I[2],i/a),v=a===i?I[2]:e.Vector2.Lerp(m,g,t/(a-i));T.push(f.x*h,f.y*c,f.z*l),E.push(d.x,d.y,d.z),C.push(v.x,v.y),A.push(S),S++},w=0;a>w;w++)for(var L=0;a>L+w;L++)O(L,w,L+1/3,w+1/3),O(L+1,w,L+1/3,w+1/3),O(L,w+1,L+1/3,w+1/3),a>L+w+1&&(O(L+1,w,L+2/3,w+2/3),O(L+1,w+1,L+2/3,w+2/3),O(L,w+1,L+2/3,w+2/3))}t._ComputeSides(n,T,A,E,C);var B=new t;return B.indices=A,B.positions=T,B.normals=E,B.uvs=C,B},t.CreatePolyhedron=function(i){var r=[];r[0]={vertex:[[0,0,1.732051],[1.632993,0,-.5773503],[-.8164966,1.414214,-.5773503],[-.8164966,-1.414214,-.5773503]],face:[[0,1,2],[0,2,3],[0,3,1],[1,3,2]]},r[1]={vertex:[[0,0,1.414214],[1.414214,0,0],[0,1.414214,0],[-1.414214,0,0],[0,-1.414214,0],[0,0,-1.414214]],face:[[0,1,2],[0,2,3],[0,3,4],[0,4,1],[1,4,5],[1,5,2],[2,5,3],[3,5,4]]},r[2]={vertex:[[0,0,1.070466],[.7136442,0,.7978784],[-.3568221,.618034,.7978784],[-.3568221,-.618034,.7978784],[.7978784,.618034,.3568221],[.7978784,-.618034,.3568221],[-.9341724,.381966,.3568221],[.1362939,1,.3568221],[.1362939,-1,.3568221],[-.9341724,-.381966,.3568221],[.9341724,.381966,-.3568221],[.9341724,-.381966,-.3568221],[-.7978784,.618034,-.3568221],[-.1362939,1,-.3568221],[-.1362939,-1,-.3568221],[-.7978784,-.618034,-.3568221],[.3568221,.618034,-.7978784],[.3568221,-.618034,-.7978784],[-.7136442,0,-.7978784],[0,0,-1.070466]],face:[[0,1,4,7,2],[0,2,6,9,3],[0,3,8,5,1],[1,5,11,10,4],[2,7,13,12,6],[3,9,15,14,8],[4,10,16,13,7],[5,8,14,17,11],[6,12,18,15,9],[10,11,17,19,16],[12,13,16,19,18],[14,15,18,19,17]]},r[3]={vertex:[[0,0,1.175571],[1.051462,0,.5257311],[.3249197,1,.5257311],[-.8506508,.618034,.5257311],[-.8506508,-.618034,.5257311],[.3249197,-1,.5257311],[.8506508,.618034,-.5257311],[.8506508,-.618034,-.5257311],[-.3249197,1,-.5257311],[-1.051462,0,-.5257311],[-.3249197,-1,-.5257311],[0,0,-1.175571]],face:[[0,1,2],[0,2,3],[0,3,4],[0,4,5],[0,5,1],[1,5,7],[1,7,6],[1,6,2],[2,6,8],[2,8,3],[3,8,9],[3,9,4],[4,9,10],[4,10,5],[5,10,7],[6,7,11],[6,11,8],[7,10,11],[8,11,9],[9,11,10]]},r[4]={vertex:[[0,0,1.070722],[.7148135,0,.7971752],[-.104682,.7071068,.7971752],[-.6841528,.2071068,.7971752],[-.104682,-.7071068,.7971752],[.6101315,.7071068,.5236279],[1.04156,.2071068,.1367736],[.6101315,-.7071068,.5236279],[-.3574067,1,.1367736],[-.7888348,-.5,.5236279],[-.9368776,.5,.1367736],[-.3574067,-1,.1367736],[.3574067,1,-.1367736],[.9368776,-.5,-.1367736],[.7888348,.5,-.5236279],[.3574067,-1,-.1367736],[-.6101315,.7071068,-.5236279],[-1.04156,-.2071068,-.1367736],[-.6101315,-.7071068,-.5236279],[.104682,.7071068,-.7971752],[.6841528,-.2071068,-.7971752],[.104682,-.7071068,-.7971752],[-.7148135,0,-.7971752],[0,0,-1.070722]],face:[[0,2,3],[1,6,5],[4,9,11],[7,15,13],[8,16,10],[12,14,19],[17,22,18],[20,21,23],[0,1,5,2],[0,3,9,4],[0,4,7,1],[1,7,13,6],[2,5,12,8],[2,8,10,3],[3,10,17,9],[4,11,15,7],[5,6,14,12],[6,13,20,14],[8,12,19,16],[9,17,18,11],[10,16,22,17],[11,18,21,15],[13,15,21,20],[14,20,23,19],[16,19,23,22],[18,22,23,21]]
  19. },r[5]={vertex:[[0,0,1.322876],[1.309307,0,.1889822],[-.9819805,.8660254,.1889822],[.1636634,-1.299038,.1889822],[.3273268,.8660254,-.9449112],[-.8183171,-.4330127,-.9449112]],face:[[0,3,1],[2,4,5],[0,1,4,2],[0,2,5,3],[1,3,5,4]]},r[6]={vertex:[[0,0,1.159953],[1.013464,0,.5642542],[-.3501431,.9510565,.5642542],[-.7715208,-.6571639,.5642542],[.6633206,.9510565,-.03144481],[.8682979,-.6571639,-.3996071],[-1.121664,.2938926,-.03144481],[-.2348831,-1.063314,-.3996071],[.5181548,.2938926,-.9953061],[-.5850262,-.112257,-.9953061]],face:[[0,1,4,2],[0,2,6,3],[1,5,8,4],[3,6,9,7],[5,7,9,8],[0,3,7,5,1],[2,4,8,9,6]]},r[7]={vertex:[[0,0,1.118034],[.8944272,0,.6708204],[-.2236068,.8660254,.6708204],[-.7826238,-.4330127,.6708204],[.6708204,.8660254,.2236068],[1.006231,-.4330127,-.2236068],[-1.006231,.4330127,.2236068],[-.6708204,-.8660254,-.2236068],[.7826238,.4330127,-.6708204],[.2236068,-.8660254,-.6708204],[-.8944272,0,-.6708204],[0,0,-1.118034]],face:[[0,1,4,2],[0,2,6,3],[1,5,8,4],[3,6,10,7],[5,9,11,8],[7,10,11,9],[0,3,7,9,5,1],[2,4,8,11,10,6]]},r[8]={vertex:[[-.729665,.670121,.319155],[-.655235,-.29213,-.754096],[-.093922,-.607123,.537818],[.702196,.595691,.485187],[.776626,-.36656,-.588064]],face:[[1,4,2],[0,1,2],[3,0,2],[4,3,2],[4,1,0,3]]},r[9]={vertex:[[-.868849,-.100041,.61257],[-.329458,.976099,.28078],[-.26629,-.013796,-.477654],[-.13392,-1.034115,.229829],[.738834,.707117,-.307018],[.859683,-.535264,-.338508]],face:[[3,0,2],[5,3,2],[4,5,2],[1,4,2],[0,1,2],[0,3,5,4,1]]},r[10]={vertex:[[-.610389,.243975,.531213],[-.187812,-.48795,-.664016],[-.187812,.9759,-.664016],[.187812,-.9759,.664016],[.798201,.243975,.132803]],face:[[1,3,0],[3,4,0],[3,1,4],[0,2,1],[0,4,2],[2,4,1]]},r[11]={vertex:[[-1.028778,.392027,-.048786],[-.640503,-.646161,.621837],[-.125162,-.395663,-.540059],[.004683,.888447,-.651988],[.125161,.395663,.540059],[.632925,-.791376,.433102],[1.031672,.157063,-.354165]],face:[[3,2,0],[2,1,0],[2,5,1],[0,4,3],[0,1,4],[4,1,5],[2,3,6],[3,4,6],[5,2,6],[4,5,6]]},r[12]={vertex:[[-.669867,.334933,-.529576],[-.669867,.334933,.529577],[-.4043,1.212901,0],[-.334933,-.669867,-.529576],[-.334933,-.669867,.529577],[.334933,.669867,-.529576],[.334933,.669867,.529577],[.4043,-1.212901,0],[.669867,-.334933,-.529576],[.669867,-.334933,.529577]],face:[[8,9,7],[6,5,2],[3,8,7],[5,0,2],[4,3,7],[0,1,2],[9,4,7],[1,6,2],[9,8,5,6],[8,3,0,5],[3,4,1,0],[4,9,6,1]]},r[13]={vertex:[[-.931836,.219976,-.264632],[-.636706,.318353,.692816],[-.613483,-.735083,-.264632],[-.326545,.979634,0],[-.318353,-.636706,.692816],[-.159176,.477529,-.856368],[.159176,-.477529,-.856368],[.318353,.636706,.692816],[.326545,-.979634,0],[.613482,.735082,-.264632],[.636706,-.318353,.692816],[.931835,-.219977,-.264632]],face:[[11,10,8],[7,9,3],[6,11,8],[9,5,3],[2,6,8],[5,0,3],[4,2,8],[0,1,3],[10,4,8],[1,7,3],[10,11,9,7],[11,6,5,9],[6,2,0,5],[2,4,1,0],[4,10,7,1]]},r[14]={vertex:[[-.93465,.300459,-.271185],[-.838689,-.260219,-.516017],[-.711319,.717591,.128359],[-.710334,-.156922,.080946],[-.599799,.556003,-.725148],[-.503838,-.004675,-.969981],[-.487004,.26021,.48049],[-.460089,-.750282,-.512622],[-.376468,.973135,-.325605],[-.331735,-.646985,.084342],[-.254001,.831847,.530001],[-.125239,-.494738,-.966586],[.029622,.027949,.730817],[.056536,-.982543,-.262295],[.08085,1.087391,.076037],[.125583,-.532729,.485984],[.262625,.599586,.780328],[.391387,-.726999,-.716259],[.513854,-.868287,.139347],[.597475,.85513,.326364],[.641224,.109523,.783723],[.737185,-.451155,.538891],[.848705,-.612742,-.314616],[.976075,.365067,.32976],[1.072036,-.19561,.084927]],face:[[15,18,21],[12,20,16],[6,10,2],[3,0,1],[9,7,13],[2,8,4,0],[0,4,5,1],[1,5,11,7],[7,11,17,13],[13,17,22,18],[18,22,24,21],[21,24,23,20],[20,23,19,16],[16,19,14,10],[10,14,8,2],[15,9,13,18],[12,15,21,20],[6,12,16,10],[3,6,2,0],[9,3,1,7],[9,15,12,6,3],[22,17,11,5,4,8,14,19,23,24]]};var n,o,s,a,h,c,l=i.type<0||i.type>=r.length?0:i.type||0,u=i.size,f=i.sizeX||u||1,d=i.sizeY||u||1,p=i.sizeZ||u||1,_=i.custom||r[l],m=_.face.length,g=i.faceUV||new Array(m),v=i.faceColors,y=void 0===i.flat?!0:i.flat,x=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,b=[],P=[],A=[],T=[],E=[],C=0,S=0,M=[],I=0,D=0;if(y)for(D=0;m>D;D++)v&&void 0===v[D]&&(v[D]=new e.Color4(1,1,1,1)),g&&void 0===g[D]&&(g[D]=new e.Vector4(0,0,1,1));if(y)for(D=0;m>D;D++){var R=_.face[D].length;for(s=2*Math.PI/R,a=.5*Math.tan(s/2),h=.5,I=0;R>I;I++)b.push(_.vertex[_.face[D][I]][0]*f,_.vertex[_.face[D][I]][1]*d,_.vertex[_.face[D][I]][2]*p),M.push(C),C++,n=g[D].x+(g[D].z-g[D].x)*(.5+a),o=g[D].y+(g[D].w-g[D].y)*(h-.5),T.push(n,o),c=a*Math.cos(s)-h*Math.sin(s),h=a*Math.sin(s)+h*Math.cos(s),a=c,v&&E.push(v[D].r,v[D].g,v[D].b,v[D].a);for(I=0;R-2>I;I++)P.push(M[0+S],M[I+2+S],M[I+1+S]);S+=R}else{for(I=0;I<_.vertex.length;I++)b.push(_.vertex[I][0]*f,_.vertex[I][1]*d,_.vertex[I][2]*p),T.push(0,0);for(D=0;m>D;D++)for(I=0;I<_.face[D].length-2;I++)P.push(_.face[D][0],_.face[D][I+2],_.face[D][I+1])}t.ComputeNormals(b,P,A),t._ComputeSides(x,b,P,A,T);var O=new t;return O.positions=b,O.indices=P,O.normals=A,O.uvs=T,v&&y&&(O.colors=E),O},t.CreateTorusKnot=function(i){var r,n,o=[],s=[],a=[],h=[],c=i.radius||2,l=i.tube||.5,u=i.radialSegments||32,f=i.tubularSegments||32,d=i.p||2,p=i.q||3,_=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,m=function(t){var i=Math.cos(t),r=Math.sin(t),n=p/d*t,o=Math.cos(n),s=c*(2+o)*.5*i,a=c*(2+o)*r*.5,h=c*Math.sin(n)*.5;return new e.Vector3(s,a,h)};for(r=0;u>=r;r++){var g=r%u,v=g/u*2*d*Math.PI,y=m(v),x=m(v+.01),b=x.subtract(y),P=x.add(y),A=e.Vector3.Cross(b,P);for(P=e.Vector3.Cross(A,b),A.normalize(),P.normalize(),n=0;f>n;n++){var T=n%f,E=T/f*2*Math.PI,C=-l*Math.cos(E),S=l*Math.sin(E);s.push(y.x+C*P.x+S*A.x),s.push(y.y+C*P.y+S*A.y),s.push(y.z+C*P.z+S*A.z),h.push(r/u),h.push(n/f)}}for(r=0;u>r;r++)for(n=0;f>n;n++){var M=(n+1)%f,I=r*f+n,D=(r+1)*f+n,R=(r+1)*f+M,O=r*f+M;o.push(O),o.push(D),o.push(I),o.push(O),o.push(R),o.push(D)}t.ComputeNormals(s,o,a),t._ComputeSides(_,s,o,a,h);var w=new t;return w.indices=o,w.positions=s,w.normals=a,w.uvs=h,w},t.ComputeNormals=function(e,t,i){var r=0,n=0,o=0,s=0,a=0,h=0,c=0,l=0,u=0,f=0,d=0,p=0,_=0,m=0;for(r=0;r<e.length;r++)i[r]=0;var g=t.length/3;for(r=0;g>r;r++)p=t[3*r],_=t[3*r+1],m=t[3*r+2],n=e[3*p]-e[3*_],o=e[3*p+1]-e[3*_+1],s=e[3*p+2]-e[3*_+2],a=e[3*m]-e[3*_],h=e[3*m+1]-e[3*_+1],c=e[3*m+2]-e[3*_+2],l=o*c-s*h,u=s*a-n*c,f=n*h-o*a,d=Math.sqrt(l*l+u*u+f*f),d=0===d?1:d,l/=d,u/=d,f/=d,i[3*p]+=l,i[3*p+1]+=u,i[3*p+2]+=f,i[3*_]+=l,i[3*_+1]+=u,i[3*_+2]+=f,i[3*m]+=l,i[3*m+1]+=u,i[3*m+2]+=f;for(r=0;r<i.length/3;r++)l=i[3*r],u=i[3*r+1],f=i[3*r+2],d=Math.sqrt(l*l+u*u+f*f),d=0===d?1:d,l/=d,u/=d,f/=d,i[3*r]=l,i[3*r+1]=u,i[3*r+2]=f},t._ComputeSides=function(t,i,r,n,o){var s,a,h=r.length,c=n.length;switch(t=t||e.Mesh.DEFAULTSIDE){case e.Mesh.FRONTSIDE:break;case e.Mesh.BACKSIDE:var l;for(s=0;h>s;s+=3)l=r[s],r[s]=r[s+2],r[s+2]=l;for(a=0;c>a;a++)n[a]=-n[a];break;case e.Mesh.DOUBLESIDE:for(var u=i.length,f=u/3,d=0;u>d;d++)i[u+d]=i[d];for(s=0;h>s;s+=3)r[s+h]=r[s+2]+f,r[s+1+h]=r[s+1]+f,r[s+2+h]=r[s]+f;for(a=0;c>a;a++)n[c+a]=-n[a];for(var p=o.length,_=0;p>_;_++)o[_+p]=o[_]}},t.ImportVertexData=function(i,r){var n=new t,o=i.positions;o&&n.set(o,e.VertexBuffer.PositionKind);var s=i.normals;s&&n.set(s,e.VertexBuffer.NormalKind);var a=i.uvs;a&&n.set(a,e.VertexBuffer.UVKind);var h=i.uv2s;h&&n.set(h,e.VertexBuffer.UV2Kind);var c=i.uv3s;c&&n.set(c,e.VertexBuffer.UV3Kind);var l=i.uv4s;l&&n.set(l,e.VertexBuffer.UV4Kind);var u=i.uv5s;u&&n.set(u,e.VertexBuffer.UV5Kind);var f=i.uv6s;f&&n.set(f,e.VertexBuffer.UV6Kind);var d=i.colors;d&&n.set(e.Color4.CheckColors4(d,o.length/3),e.VertexBuffer.ColorKind);var p=i.matricesIndices;p&&n.set(p,e.VertexBuffer.MatricesIndicesKind);var _=i.matricesWeights;_&&n.set(_,e.VertexBuffer.MatricesWeightsKind);var m=i.indices;m&&(n.indices=m),r.setAllVerticesData(n,i.updatable)},t}();e.VertexData=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(){}return t.EnableFor=function(e){e._tags=e._tags||{},e.hasTags=function(){return t.HasTags(e)},e.addTags=function(i){return t.AddTagsTo(e,i)},e.removeTags=function(i){return t.RemoveTagsFrom(e,i)},e.matchesTagsQuery=function(i){return t.MatchesQuery(e,i)}},t.DisableFor=function(e){delete e._tags,delete e.hasTags,delete e.addTags,delete e.removeTags,delete e.matchesTagsQuery},t.HasTags=function(t){return t._tags?!e.Tools.IsEmpty(t._tags):!1},t.GetTags=function(e,t){if(void 0===t&&(t=!0),!e._tags)return null;if(t){var i=[];for(var r in e._tags)e._tags.hasOwnProperty(r)&&e._tags[r]===!0&&i.push(r);return i.join(" ")}return e._tags},t.AddTagsTo=function(e,i){if(i&&"string"==typeof i){var r=i.split(" ");for(var n in r)t._AddTagTo(e,r[n])}},t._AddTagTo=function(e,i){i=i.trim(),""!==i&&"true"!==i&&"false"!==i&&(i.match(/[\s]/)||i.match(/^([!]|([|]|[&]){2})/)||(t.EnableFor(e),e._tags[i]=!0))},t.RemoveTagsFrom=function(e,i){if(t.HasTags(e)){var r=i.split(" ");for(var n in r)t._RemoveTagFrom(e,r[n])}},t._RemoveTagFrom=function(e,t){delete e._tags[t]},t.MatchesQuery=function(i,r){return void 0===r?!0:""===r?t.HasTags(i):e.Internals.AndOrNotEvaluator.Eval(r,function(e){return t.HasTags(i)&&i._tags[e]})},t}();e.Tags=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t;!function(e){var t=function(){function e(){}return e.Eval=function(t,i){return t=t.match(/\([^\(\)]*\)/g)?t.replace(/\([^\(\)]*\)/g,function(t){return t=t.slice(1,t.length-1),e._HandleParenthesisContent(t,i)}):e._HandleParenthesisContent(t,i),"true"===t?!0:"false"===t?!1:e.Eval(t,i)},e._HandleParenthesisContent=function(t,i){i=i||function(e){return"true"===e};var r,n=t.split("||");for(var o in n){var s=e._SimplifyNegation(n[o].trim()),a=s.split("&&");if(a.length>1)for(var h=0;h<a.length;++h){var c=e._SimplifyNegation(a[h].trim());if(r="true"!==c&&"false"!==c?"!"===c[0]?!i(c.substring(1)):i(c):"true"===c,!r){s="false";break}}if(r||"true"===s){r=!0;break}r="true"!==s&&"false"!==s?"!"===s[0]?!i(s.substring(1)):i(s):"true"===s}return r?"true":"false"},e._SimplifyNegation=function(e){return e=e.replace(/^[\s!]+/,function(e){return e=e.replace(/[\s]/g,function(){return""}),e.length%2?"!":""}),e=e.trim(),"!true"===e?e="false":"!false"===e&&(e="true"),e},e}();e.AndOrNotEvaluator=t}(t=e.Internals||(e.Internals={}))}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(t,i,r,n,o,s){this._enabled=!0,this._refCount=0,this._name=i,this._renderTexture=new e.RenderTargetTexture(i,r,t),this.setRenderList(n),this._renderTexture.onBeforeRenderObservable.add(o),this._renderTexture.onAfterRenderObservable.add(s),this._scene=t,this._renderList=n}return t.prototype._incRefCount=function(){return 0===this._refCount&&this._scene.customRenderTargets.push(this._renderTexture),++this._refCount},t.prototype._decRefCount=function(){return this._refCount--,this._refCount<=0&&this._scene.customRenderTargets.splice(this._scene.customRenderTargets.indexOf(this._renderTexture),1),this._refCount},t.prototype._update=function(){this.setRenderList(this._renderList)},t.prototype.setRenderList=function(e){this._renderTexture.renderList=e},t.prototype.getRenderTexture=function(){return this._renderTexture},t}();e.PostProcessRenderPass=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(e,t,i,r){this._engine=e,this._name=t,this._singleInstance=r||!0,this._getPostProcess=i,this._cameras=[],this._indicesForCamera=[],this._postProcesses={},this._renderPasses={},this._renderEffectAsPasses={}}return Object.defineProperty(t.prototype,"isSupported",{get:function(){for(var e in this._postProcesses)if(!this._postProcesses[e].isSupported)return!1;return!0},enumerable:!0,configurable:!0}),t.prototype._update=function(){for(var e in this._renderPasses)this._renderPasses[e]._update()},t.prototype.addPass=function(e){this._renderPasses[e._name]=e,this._linkParameters()},t.prototype.removePass=function(e){delete this._renderPasses[e._name],this._linkParameters()},t.prototype.addRenderEffectAsPass=function(e){this._renderEffectAsPasses[e._name]=e,this._linkParameters()},t.prototype.getPass=function(e){for(var t in this._renderPasses)if(t===e)return this._renderPasses[e]},t.prototype.emptyPasses=function(){this._renderPasses={},this._linkParameters()},t.prototype._attachCameras=function(t){for(var i,r=e.Tools.MakeArray(t||this._cameras),n=0;n<r.length;n++){var o=r[n],s=o.name;i=this._singleInstance?0:s,this._postProcesses[i]=this._postProcesses[i]||this._getPostProcess();var a=o.attachPostProcess(this._postProcesses[i]);this._indicesForCamera[s]||(this._indicesForCamera[s]=[]),this._indicesForCamera[s].push(a),-1===this._cameras.indexOf(o)&&(this._cameras[s]=o);for(var h in this._renderPasses)this._renderPasses[h]._incRefCount()}this._linkParameters()},t.prototype._detachCameras=function(t){for(var i=e.Tools.MakeArray(t||this._cameras),r=0;r<i.length;r++){var n=i[r],o=n.name;n.detachPostProcess(this._postProcesses[this._singleInstance?0:o],this._indicesForCamera[o]);var s=this._cameras.indexOf(o);this._indicesForCamera.splice(s,1),this._cameras.splice(s,1);for(var a in this._renderPasses)this._renderPasses[a]._decRefCount()}},t.prototype._enable=function(t){for(var i=e.Tools.MakeArray(t||this._cameras),r=0;r<i.length;r++){for(var n=i[r],o=n.name,s=0;s<this._indicesForCamera[o].length;s++)void 0===n._postProcesses[this._indicesForCamera[o][s]]&&t[r].attachPostProcess(this._postProcesses[this._singleInstance?0:o],this._indicesForCamera[o][s]);for(var a in this._renderPasses)this._renderPasses[a]._incRefCount()}},t.prototype._disable=function(t){for(var i=e.Tools.MakeArray(t||this._cameras),r=0;r<i.length;r++){var n=i[r],o=n.Name;n.detachPostProcess(this._postProcesses[this._singleInstance?0:o],this._indicesForCamera[o]);for(var s in this._renderPasses)this._renderPasses[s]._decRefCount()}},t.prototype.getPostProcess=function(e){return this._singleInstance?this._postProcesses[0]:this._postProcesses[e.name]},t.prototype._linkParameters=function(){var e=this;for(var t in this._postProcesses)this.applyParameters&&this.applyParameters(this._postProcesses[t]),this._postProcesses[t].onBeforeRenderObservable.add(function(t){e._linkTextures(t)})},t.prototype._linkTextures=function(e){for(var t in this._renderPasses)e.setTexture(t,this._renderPasses[t].getRenderTexture());for(var i in this._renderEffectAsPasses)e.setTextureFromPostProcess(i+"Sampler",this._renderEffectAsPasses[i].getPostProcess())},t}();e.PostProcessRenderEffect=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(e,t){this._engine=e,this._name=t,this._renderEffects={},this._renderEffectsForIsolatedPass={},this._cameras=[]}return Object.defineProperty(t.prototype,"isSupported",{get:function(){for(var e in this._renderEffects)if(!this._renderEffects[e].isSupported)return!1;return!0},enumerable:!0,configurable:!0}),t.prototype.addEffect=function(e){this._renderEffects[e._name]=e},t.prototype._enableEffect=function(t,i){var r=this._renderEffects[t];r&&r._enable(e.Tools.MakeArray(i||this._cameras))},t.prototype._disableEffect=function(t,i){var r=this._renderEffects[t];r&&r._disable(e.Tools.MakeArray(i||this._cameras))},t.prototype._attachCameras=function(t,i){var r,n=e.Tools.MakeArray(t||this._cameras),o=[];for(r=0;r<n.length;r++){var s=n[r],a=s.name;-1===this._cameras.indexOf(s)?this._cameras[a]=s:i&&o.push(r)}for(r=0;r<o.length;r++)t.splice(o[r],1);for(var h in this._renderEffects)this._renderEffects[h]._attachCameras(n)},t.prototype._detachCameras=function(t){var i=e.Tools.MakeArray(t||this._cameras);for(var r in this._renderEffects)this._renderEffects[r]._detachCameras(i);for(var n=0;n<i.length;n++)this._cameras.splice(this._cameras.indexOf(i[n]),1)},t.prototype._enableDisplayOnlyPass=function(i,r){var n,o=this,s=e.Tools.MakeArray(r||this._cameras),a=null;for(n in this._renderEffects)if(a=this._renderEffects[n].getPass(i),null!=a)break;if(null!==a){for(n in this._renderEffects)this._renderEffects[n]._disable(s);a._name=t.PASS_SAMPLER_NAME;for(var h=0;h<s.length;h++){var c=s[h],l=c.name;this._renderEffectsForIsolatedPass[l]=this._renderEffectsForIsolatedPass[l]||new e.PostProcessRenderEffect(this._engine,t.PASS_EFFECT_NAME,function(){return new e.DisplayPassPostProcess(t.PASS_EFFECT_NAME,1,null,null,o._engine,!0)}),this._renderEffectsForIsolatedPass[l].emptyPasses(),this._renderEffectsForIsolatedPass[l].addPass(a),this._renderEffectsForIsolatedPass[l]._attachCameras(c)}}},t.prototype._disableDisplayOnlyPass=function(i){for(var r=this,n=e.Tools.MakeArray(i||this._cameras),o=0;o<n.length;o++){var s=n[o],a=s.name;this._renderEffectsForIsolatedPass[a]=this._renderEffectsForIsolatedPass[a]||new e.PostProcessRenderEffect(this._engine,t.PASS_EFFECT_NAME,function(){return new e.DisplayPassPostProcess(t.PASS_EFFECT_NAME,1,null,null,r._engine,!0)}),this._renderEffectsForIsolatedPass[a]._disable(s)}for(var h in this._renderEffects)this._renderEffects[h]._enable(n)},t.prototype._update=function(){for(var e in this._renderEffects)this._renderEffects[e]._update();for(var t=0;t<this._cameras.length;t++){var i=this._cameras[t].name;this._renderEffectsForIsolatedPass[i]&&this._renderEffectsForIsolatedPass[i]._update()}},t.prototype.dispose=function(){},t.PASS_EFFECT_NAME="passEffect",t.PASS_SAMPLER_NAME="passSampler",t}();e.PostProcessRenderPipeline=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function e(){this._renderPipelines={}}return e.prototype.addPipeline=function(e){this._renderPipelines[e._name]=e},e.prototype.attachCamerasToRenderPipeline=function(e,t,i){var r=this._renderPipelines[e];r&&r._attachCameras(t,i)},e.prototype.detachCamerasFromRenderPipeline=function(e,t){var i=this._renderPipelines[e];i&&i._detachCameras(t)},e.prototype.enableEffectInPipeline=function(e,t,i){var r=this._renderPipelines[e];r&&r._enableEffect(t,i)},e.prototype.disableEffectInPipeline=function(e,t,i){var r=this._renderPipelines[e];r&&r._disableEffect(t,i)},e.prototype.enableDisplayOnlyPassInPipeline=function(e,t,i){var r=this._renderPipelines[e];r&&r._enableDisplayOnlyPass(t,i)},e.prototype.disableDisplayOnlyPassInPipeline=function(e,t){var i=this._renderPipelines[e];i&&i._disableDisplayOnlyPass(t)},e.prototype.update=function(){for(var e in this._renderPipelines){var t=this._renderPipelines[e];t.isSupported?t._update():(t.dispose(),delete this._renderPipelines[e])}},e}();e.PostProcessRenderPipelineManager=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(t){this.frontColor=new e.Color3(1,1,1),this.backColor=new e.Color3(.1,.1,.1),this.showBackLines=!0,this.renderList=new e.SmartArray(32),this._vertexBuffers={},this._scene=t}return t.prototype._prepareRessources=function(){if(!this._colorShader){this._colorShader=new e.ShaderMaterial("colorShader",this._scene,"color",{attributes:[e.VertexBuffer.PositionKind],uniforms:["worldViewProjection","color"]});var t=this._scene.getEngine(),i=e.VertexData.CreateBox(1);this._vertexBuffers[e.VertexBuffer.PositionKind]=new e.VertexBuffer(t,i.positions,e.VertexBuffer.PositionKind,!1),this._indexBuffer=t.createIndexBuffer([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,7,1,6,2,5,3,4])}},t.prototype.reset=function(){this.renderList.reset()},t.prototype.render=function(){if(0!==this.renderList.length&&(this._prepareRessources(),this._colorShader.isReady())){var t=this._scene.getEngine();t.setDepthWrite(!1),this._colorShader._preBind();for(var i=0;i<this.renderList.length;i++){var r=this.renderList.data[i],n=r.minimum,o=r.maximum,s=o.subtract(n),a=n.add(s.scale(.5)),h=e.Matrix.Scaling(s.x,s.y,s.z).multiply(e.Matrix.Translation(a.x,a.y,a.z)).multiply(r.getWorldMatrix());t.bindBuffers(this._vertexBuffers,this._indexBuffer,this._colorShader.getEffect()),this.showBackLines&&(t.setDepthFunctionToGreaterOrEqual(),this._scene.resetCachedMaterial(),this._colorShader.setColor4("color",this.backColor.toColor4()),this._colorShader.bind(h),t.draw(!1,0,24)),t.setDepthFunctionToLess(),this._scene.resetCachedMaterial(),this._colorShader.setColor4("color",this.frontColor.toColor4()),this._colorShader.bind(h),t.draw(!1,0,24)}this._colorShader.unbind(),t.setDepthFunctionToLessOrEqual(),t.setDepthWrite(!0)}},t.prototype.dispose=function(){if(this._colorShader){this._colorShader.dispose();var t=this._vertexBuffers[e.VertexBuffer.PositionKind];t&&(t.dispose(),this._vertexBuffers[e.VertexBuffer.PositionKind]=null),this._scene.getEngine()._releaseBuffer(this._indexBuffer)}},t}();e.BoundingBoxRenderer=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function e(e){this._actionManager=e}return e.prototype.isValid=function(){return!0},e.prototype._getProperty=function(e){return this._actionManager._getProperty(e)},e.prototype._getEffectiveTarget=function(e,t){return this._actionManager._getEffectiveTarget(e,t)},e.prototype.serialize=function(){},e.prototype._serialize=function(e){return{type:2,children:[],name:e.name,properties:e.properties}},e}();e.Condition=t;var i=function(t){function i(e,r,n,o,s){void 0===s&&(s=i.IsEqual),t.call(this,e),this.propertyPath=n,this.value=o,this.operator=s,this._target=r,this._effectiveTarget=this._getEffectiveTarget(r,this.propertyPath),this._property=this._getProperty(this.propertyPath)}return __extends(i,t),Object.defineProperty(i,"IsEqual",{get:function(){return i._IsEqual},enumerable:!0,configurable:!0}),Object.defineProperty(i,"IsDifferent",{get:function(){return i._IsDifferent},enumerable:!0,configurable:!0}),Object.defineProperty(i,"IsGreater",{get:function(){return i._IsGreater},enumerable:!0,configurable:!0}),Object.defineProperty(i,"IsLesser",{get:function(){return i._IsLesser},enumerable:!0,configurable:!0}),i.prototype.isValid=function(){switch(this.operator){case i.IsGreater:return this._effectiveTarget[this._property]>this.value;case i.IsLesser:return this._effectiveTarget[this._property]<this.value;case i.IsEqual:case i.IsDifferent:var e;return e=this.value.equals?this.value.equals(this._effectiveTarget[this._property]):this.value===this._effectiveTarget[this._property],this.operator===i.IsEqual?e:!e}return!1},i.prototype.serialize=function(){return this._serialize({name:"ValueCondition",properties:[e.Action._GetTargetProperty(this._target),{name:"propertyPath",value:this.propertyPath},{name:"value",value:e.Action._SerializeValueAsString(this.value)},{name:"operator",value:i.GetOperatorName(this.operator)}]})},i.GetOperatorName=function(e){switch(e){case i._IsEqual:return"IsEqual";case i._IsDifferent:return"IsDifferent";case i._IsGreater:return"IsGreater";case i._IsLesser:return"IsLesser";default:return""}},i._IsEqual=0,i._IsDifferent=1,i._IsGreater=2,i._IsLesser=3,i}(t);e.ValueCondition=i;var r=function(e){function t(t,i){e.call(this,t),this.predicate=i}return __extends(t,e),t.prototype.isValid=function(){return this.predicate()},t}(t);e.PredicateCondition=r;var n=function(t){function i(e,i,r){t.call(this,e),this.value=r,this._target=i}return __extends(i,t),i.prototype.isValid=function(){return this._target.state===this.value},i.prototype.serialize=function(){return this._serialize({name:"StateCondition",properties:[e.Action._GetTargetProperty(this._target),{name:"value",value:this.value}]})},i}(t);e.StateCondition=n}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(e,t){this.triggerOptions=e,e.parameter?(this.trigger=e.trigger,this._triggerParameter=e.parameter):this.trigger=e,this._nextActiveAction=this,this._condition=t}return t.prototype._prepare=function(){},t.prototype.getTriggerParameter=function(){return this._triggerParameter},t.prototype._executeCurrent=function(e){if(this._nextActiveAction._condition){var t=this._nextActiveAction._condition,i=this._actionManager.getScene().getRenderId();if(t._evaluationId===i){if(!t._currentResult)return}else{if(t._evaluationId=i,!t.isValid())return void(t._currentResult=!1);t._currentResult=!0}}this._nextActiveAction.execute(e),this.skipToNextActiveAction()},t.prototype.execute=function(e){},t.prototype.skipToNextActiveAction=function(){this._nextActiveAction._child?(this._nextActiveAction._child._actionManager||(this._nextActiveAction._child._actionManager=this._actionManager),this._nextActiveAction=this._nextActiveAction._child):this._nextActiveAction=this},t.prototype.then=function(e){return this._child=e,e._actionManager=this._actionManager,e._prepare(),e},t.prototype._getProperty=function(e){return this._actionManager._getProperty(e)},t.prototype._getEffectiveTarget=function(e,t){return this._actionManager._getEffectiveTarget(e,t)},t.prototype.serialize=function(e){},t.prototype._serialize=function(e,t){var i={type:1,children:[],name:e.name,properties:e.properties||[]};if(this._child&&this._child.serialize(i),this._condition){var r=this._condition.serialize();return r.children.push(i),t&&t.children.push(r),r}return t&&t.children.push(i),i},t._SerializeValueAsString=function(t){return"number"==typeof t?t.toString():"boolean"==typeof t?t?"true":"false":t instanceof e.Vector2?t.x+", "+t.y:t instanceof e.Vector3?t.x+", "+t.y+", "+t.z:t instanceof e.Color3?t.r+", "+t.g+", "+t.b:t instanceof e.Color4?t.r+", "+t.g+", "+t.b+", "+t.a:t},t._GetTargetProperty=function(t){return{name:"target",targetType:t instanceof e.Mesh?"MeshProperties":t instanceof e.Light?"LightProperties":t instanceof e.Camera?"CameraProperties":"SceneProperties",value:t instanceof e.Scene?"Scene":t.name}},t}();e.Action=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function e(e,t,i,r,n,o){this.source=e,this.pointerX=t,this.pointerY=i,this.meshUnderPointer=r,this.sourceEvent=n,this.additionalData=o}return e.CreateNew=function(t,i,r){var n=t.getScene();return new e(t,n.pointerX,n.pointerY,n.meshUnderPointer,i,r)},e.CreateNewFromSprite=function(t,i,r,n){return new e(t,i.pointerX,i.pointerY,i.meshUnderPointer,r,n)},e.CreateNewFromScene=function(t,i){return new e(null,t.pointerX,t.pointerY,t.meshUnderPointer,i)},e.CreateNewFromPrimitive=function(t,i,r,n){return new e(t,i.x,i.y,null,r,n)},e}();e.ActionEvent=t;var i=function(){function t(e){this.actions=new Array,this._scene=e,e._actionManagers.push(this)}return Object.defineProperty(t,"NothingTrigger",{get:function(){return t._NothingTrigger},enumerable:!0,configurable:!0}),Object.defineProperty(t,"OnPickTrigger",{get:function(){return t._OnPickTrigger},enumerable:!0,configurable:!0}),Object.defineProperty(t,"OnLeftPickTrigger",{get:function(){return t._OnLeftPickTrigger},enumerable:!0,configurable:!0}),Object.defineProperty(t,"OnRightPickTrigger",{get:function(){return t._OnRightPickTrigger},enumerable:!0,configurable:!0}),Object.defineProperty(t,"OnCenterPickTrigger",{get:function(){return t._OnCenterPickTrigger},enumerable:!0,configurable:!0}),Object.defineProperty(t,"OnPickDownTrigger",{get:function(){return t._OnPickDownTrigger},enumerable:!0,configurable:!0}),Object.defineProperty(t,"OnPickUpTrigger",{get:function(){return t._OnPickUpTrigger},enumerable:!0,configurable:!0}),Object.defineProperty(t,"OnPickOutTrigger",{get:function(){return t._OnPickOutTrigger},enumerable:!0,configurable:!0}),Object.defineProperty(t,"OnLongPressTrigger",{get:function(){return t._OnLongPressTrigger},enumerable:!0,configurable:!0}),Object.defineProperty(t,"OnPointerOverTrigger",{get:function(){return t._OnPointerOverTrigger},enumerable:!0,configurable:!0}),Object.defineProperty(t,"OnPointerOutTrigger",{get:function(){return t._OnPointerOutTrigger},enumerable:!0,configurable:!0}),Object.defineProperty(t,"OnEveryFrameTrigger",{get:function(){return t._OnEveryFrameTrigger},enumerable:!0,configurable:!0}),Object.defineProperty(t,"OnIntersectionEnterTrigger",{get:function(){return t._OnIntersectionEnterTrigger},enumerable:!0,configurable:!0}),Object.defineProperty(t,"OnIntersectionExitTrigger",{get:function(){return t._OnIntersectionExitTrigger},enumerable:!0,configurable:!0}),Object.defineProperty(t,"OnKeyDownTrigger",{get:function(){return t._OnKeyDownTrigger},enumerable:!0,configurable:!0}),Object.defineProperty(t,"OnKeyUpTrigger",{get:function(){return t._OnKeyUpTrigger},enumerable:!0,configurable:!0}),t.prototype.dispose=function(){var e=this._scene._actionManagers.indexOf(this);e>-1&&this._scene._actionManagers.splice(e,1)},t.prototype.getScene=function(){return this._scene},t.prototype.hasSpecificTriggers=function(e){for(var t=0;t<this.actions.length;t++){var i=this.actions[t];if(e.indexOf(i.trigger)>-1)return!0}return!1},t.prototype.hasSpecificTrigger=function(e){for(var t=0;t<this.actions.length;t++){var i=this.actions[t];if(i.trigger===e)return!0}return!1},Object.defineProperty(t.prototype,"hasPointerTriggers",{get:function(){for(var e=0;e<this.actions.length;e++){var i=this.actions[e];if(i.trigger>=t._OnPickTrigger&&i.trigger<=t._OnPointerOutTrigger)return!0}return!1},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"hasPickTriggers",{get:function(){for(var e=0;e<this.actions.length;e++){var i=this.actions[e];if(i.trigger>=t._OnPickTrigger&&i.trigger<=t._OnPickUpTrigger)return!0}return!1},enumerable:!0,configurable:!0}),t.prototype.registerAction=function(i){return i.trigger===t.OnEveryFrameTrigger&&this.getScene().actionManager!==this?(e.Tools.Warn("OnEveryFrameTrigger can only be used with scene.actionManager"),null):(this.actions.push(i),i._actionManager=this,i._prepare(),i)},t.prototype.processTrigger=function(e,i){for(var r=0;r<this.actions.length;r++){var n=this.actions[r];if(n.trigger===e){if(e===t.OnKeyUpTrigger||e===t.OnKeyDownTrigger){var o=n.getTriggerParameter();if(o){var s=i.sourceEvent.charCode?i.sourceEvent.charCode:i.sourceEvent.keyCode,a=String.fromCharCode(s).toLowerCase();if(a!==o.toLowerCase())continue}}n._executeCurrent(i)}}},t.prototype._getEffectiveTarget=function(e,t){for(var i=t.split("."),r=0;r<i.length-1;r++)e=e[i[r]];return e},t.prototype._getProperty=function(e){var t=e.split(".");return t[t.length-1]},t.prototype.serialize=function(i){for(var r={children:[],name:i,type:3,properties:[]},n=0;n<this.actions.length;n++){var o={type:0,children:[],name:t.GetTriggerName(this.actions[n].trigger),properties:[]},s=this.actions[n].triggerOptions;s&&"number"!=typeof s&&(s.parameter instanceof e.Node?o.properties.push(e.Action._GetTargetProperty(s.parameter)):o.properties.push({name:"parameter",targetType:null,value:s.parameter})),this.actions[n].serialize(o),r.children.push(o)}return r},t.Parse=function(i,r,n){var o=new e.ActionManager(n);null===r?n.actionManager=o:r.actionManager=o;for(var s=function(t,i){var r=Object.create(e[t].prototype);return r.constructor.apply(r,i),r},a=function(t,i,r,n){if(null===n){var o=parseFloat(i);return"true"===i||"false"===i?"true"===i:isNaN(o)?i:o}for(var s=n.split("."),a=i.split(","),h=0;h<s.length;h++)r=r[s[h]];if("boolean"==typeof r)return"true"===a[0];if("string"==typeof r)return a[0];for(var c=new Array,h=0;h<a.length;h++)c.push(parseFloat(a[h]));return r instanceof e.Vector3?e.Vector3.FromArray(c):r instanceof e.Vector4?e.Vector4.FromArray(c):r instanceof e.Color3?e.Color3.FromArray(c):r instanceof e.Color4?e.Color4.FromArray(c):parseFloat(a[0])},h=function(i,r,c,l,u){if(void 0===u&&(u=null),!i.detached){var f=new Array,d=null,p=null,_=i.combine&&i.combine.length>0;if(2===i.type?f.push(o):f.push(r),_){for(var m=new Array,g=0;g<i.combine.length;g++)h(i.combine[g],t.NothingTrigger,c,l,m);f.push(m)}else for(var v=0;v<i.properties.length;v++){var y=i.properties[v].value,x=i.properties[v].name,b=i.properties[v].targetType;"target"===x?y=d=null!==b&&"SceneProperties"===b?n:n.getNodeByName(y):"parent"===x?y=n.getNodeByName(y):"sound"===x?y=n.getSoundByName(y):"propertyPath"!==x?y=2===i.type&&"operator"===x?e.ValueCondition[y]:a(x,y,d,"value"===x?p:null):p=y,f.push(y)}if(null===u?f.push(c):f.push(null),"InterpolateValueAction"===i.name){var P=f[f.length-2];f[f.length-1]=P,f[f.length-2]=c}var A=s(i.name,f);if(A instanceof e.Condition&&null!==c){var T=new e.DoNothingAction(r,c);l?l.then(T):o.registerAction(T),l=T}null===u?A instanceof e.Condition?(c=A,A=l):(c=null,l?l.then(A):o.registerAction(A)):u.push(A);for(var v=0;v<i.children.length;v++)h(i.children[v],r,c,A,null);
  20. }},c=0;c<i.children.length;c++){var l,u=i.children[c];if(u.properties.length>0){var f=u.properties[0].value,d=null===u.properties[0].targetType?f:n.getMeshByName(f);l={trigger:e.ActionManager[u.name],parameter:d}}else l=e.ActionManager[u.name];for(var p=0;p<u.children.length;p++)u.detached||h(u.children[p],l,null,null)}},t.GetTriggerName=function(e){switch(e){case 0:return"NothingTrigger";case 1:return"OnPickTrigger";case 2:return"OnLeftPickTrigger";case 3:return"OnRightPickTrigger";case 4:return"OnCenterPickTrigger";case 5:return"OnPickDownTrigger";case 6:return"OnPickUpTrigger";case 7:return"OnLongPressTrigger";case 8:return"OnPointerOverTrigger";case 9:return"OnPointerOutTrigger";case 10:return"OnEveryFrameTrigger";case 11:return"OnIntersectionEnterTrigger";case 12:return"OnIntersectionExitTrigger";case 13:return"OnKeyDownTrigger";case 14:return"OnKeyUpTrigger";case 15:return"OnPickOutTrigger";default:return""}},t._NothingTrigger=0,t._OnPickTrigger=1,t._OnLeftPickTrigger=2,t._OnRightPickTrigger=3,t._OnCenterPickTrigger=4,t._OnPickDownTrigger=5,t._OnPickUpTrigger=6,t._OnLongPressTrigger=7,t._OnPointerOverTrigger=8,t._OnPointerOutTrigger=9,t._OnEveryFrameTrigger=10,t._OnIntersectionEnterTrigger=11,t._OnIntersectionExitTrigger=12,t._OnKeyDownTrigger=13,t._OnKeyUpTrigger=14,t._OnPickOutTrigger=15,t.DragMovementThreshold=10,t.LongPressDelay=500,t}();e.ActionManager=i}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(t){function i(e,i,r,n,o,s,a,h){void 0===o&&(o=1e3),t.call(this,e,s),this.propertyPath=r,this.value=n,this.duration=o,this.stopOtherAnimations=a,this.onInterpolationDone=h,this._target=this._effectiveTarget=i}return __extends(i,t),i.prototype._prepare=function(){this._effectiveTarget=this._getEffectiveTarget(this._effectiveTarget,this.propertyPath),this._property=this._getProperty(this.propertyPath)},i.prototype.execute=function(){var t,i=this._actionManager.getScene(),r=[{frame:0,value:this._effectiveTarget[this._property]},{frame:100,value:this.value}];if("number"==typeof this.value)t=e.Animation.ANIMATIONTYPE_FLOAT;else if(this.value instanceof e.Color3)t=e.Animation.ANIMATIONTYPE_COLOR3;else if(this.value instanceof e.Vector3)t=e.Animation.ANIMATIONTYPE_VECTOR3;else if(this.value instanceof e.Matrix)t=e.Animation.ANIMATIONTYPE_MATRIX;else{if(!(this.value instanceof e.Quaternion))return void e.Tools.Warn("InterpolateValueAction: Unsupported type ("+typeof this.value+")");t=e.Animation.ANIMATIONTYPE_QUATERNION}var n=new e.Animation("InterpolateValueAction",this._property,100*(1e3/this.duration),t,e.Animation.ANIMATIONLOOPMODE_CONSTANT);n.setKeys(r),this.stopOtherAnimations&&i.stopAnimation(this._effectiveTarget),i.beginDirectAnimation(this._effectiveTarget,[n],0,100,!1,1,this.onInterpolationDone)},i.prototype.serialize=function(i){return t.prototype._serialize.call(this,{name:"InterpolateValueAction",properties:[e.Action._GetTargetProperty(this._target),{name:"propertyPath",value:this.propertyPath},{name:"value",value:e.Action._SerializeValueAsString(this.value)},{name:"duration",value:e.Action._SerializeValueAsString(this.duration)},{name:"stopOtherAnimations",value:e.Action._SerializeValueAsString(this.stopOtherAnimations)||!1}]},i)},i}(e.Action);e.InterpolateValueAction=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(t){function i(e,i,r,n){t.call(this,e,n),this.propertyPath=r,this._target=this._effectiveTarget=i}return __extends(i,t),i.prototype._prepare=function(){this._effectiveTarget=this._getEffectiveTarget(this._effectiveTarget,this.propertyPath),this._property=this._getProperty(this.propertyPath)},i.prototype.execute=function(){this._effectiveTarget[this._property]=!this._effectiveTarget[this._property]},i.prototype.serialize=function(i){return t.prototype._serialize.call(this,{name:"SwitchBooleanAction",properties:[e.Action._GetTargetProperty(this._target),{name:"propertyPath",value:this.propertyPath}]},i)},i}(e.Action);e.SwitchBooleanAction=t;var i=function(t){function i(e,i,r,n){t.call(this,e,n),this.value=r,this._target=i}return __extends(i,t),i.prototype.execute=function(){this._target.state=this.value},i.prototype.serialize=function(i){return t.prototype._serialize.call(this,{name:"SetStateAction",properties:[e.Action._GetTargetProperty(this._target),{name:"value",value:this.value}]},i)},i}(e.Action);e.SetStateAction=i;var r=function(t){function i(e,i,r,n,o){t.call(this,e,o),this.propertyPath=r,this.value=n,this._target=this._effectiveTarget=i}return __extends(i,t),i.prototype._prepare=function(){this._effectiveTarget=this._getEffectiveTarget(this._effectiveTarget,this.propertyPath),this._property=this._getProperty(this.propertyPath)},i.prototype.execute=function(){this._effectiveTarget[this._property]=this.value,this._target.markAsDirty&&this._target.markAsDirty(this._property)},i.prototype.serialize=function(i){return t.prototype._serialize.call(this,{name:"SetValueAction",properties:[e.Action._GetTargetProperty(this._target),{name:"propertyPath",value:this.propertyPath},{name:"value",value:e.Action._SerializeValueAsString(this.value)}]},i)},i}(e.Action);e.SetValueAction=r;var n=function(t){function i(e,i,r,n,o){t.call(this,e,o),this.propertyPath=r,this.value=n,this._target=this._effectiveTarget=i}return __extends(i,t),i.prototype._prepare=function(){this._effectiveTarget=this._getEffectiveTarget(this._effectiveTarget,this.propertyPath),this._property=this._getProperty(this.propertyPath),"number"!=typeof this._effectiveTarget[this._property]&&e.Tools.Warn("Warning: IncrementValueAction can only be used with number values")},i.prototype.execute=function(){this._effectiveTarget[this._property]+=this.value,this._target.markAsDirty&&this._target.markAsDirty(this._property)},i.prototype.serialize=function(i){return t.prototype._serialize.call(this,{name:"IncrementValueAction",properties:[e.Action._GetTargetProperty(this._target),{name:"propertyPath",value:this.propertyPath},{name:"value",value:e.Action._SerializeValueAsString(this.value)}]},i)},i}(e.Action);e.IncrementValueAction=n;var o=function(t){function i(e,i,r,n,o,s){t.call(this,e,s),this.from=r,this.to=n,this.loop=o,this._target=i}return __extends(i,t),i.prototype._prepare=function(){},i.prototype.execute=function(){var e=this._actionManager.getScene();e.beginAnimation(this._target,this.from,this.to,this.loop)},i.prototype.serialize=function(i){return t.prototype._serialize.call(this,{name:"PlayAnimationAction",properties:[e.Action._GetTargetProperty(this._target),{name:"from",value:String(this.from)},{name:"to",value:String(this.to)},{name:"loop",value:e.Action._SerializeValueAsString(this.loop)||!1}]},i)},i}(e.Action);e.PlayAnimationAction=o;var s=function(t){function i(e,i,r){t.call(this,e,r),this._target=i}return __extends(i,t),i.prototype._prepare=function(){},i.prototype.execute=function(){var e=this._actionManager.getScene();e.stopAnimation(this._target)},i.prototype.serialize=function(i){return t.prototype._serialize.call(this,{name:"StopAnimationAction",properties:[e.Action._GetTargetProperty(this._target)]},i)},i}(e.Action);e.StopAnimationAction=s;var a=function(t){function i(i,r){void 0===i&&(i=e.ActionManager.NothingTrigger),t.call(this,i,r)}return __extends(i,t),i.prototype.execute=function(){},i.prototype.serialize=function(e){return t.prototype._serialize.call(this,{name:"DoNothingAction",properties:[]},e)},i}(e.Action);e.DoNothingAction=a;var h=function(e){function t(t,i,r){e.call(this,t,r),this.children=i}return __extends(t,e),t.prototype._prepare=function(){for(var e=0;e<this.children.length;e++)this.children[e]._actionManager=this._actionManager,this.children[e]._prepare()},t.prototype.execute=function(e){for(var t=0;t<this.children.length;t++)this.children[t].execute(e)},t.prototype.serialize=function(t){for(var i=e.prototype._serialize.call(this,{name:"CombineAction",properties:[],combine:[]},t),r=0;r<this.children.length;r++)i.combine.push(this.children[r].serialize(null));return i},t}(e.Action);e.CombineAction=h;var c=function(e){function t(t,i,r){e.call(this,t,r),this.func=i}return __extends(t,e),t.prototype.execute=function(e){this.func(e)},t}(e.Action);e.ExecuteCodeAction=c;var l=function(t){function i(e,i,r,n){t.call(this,e,n),this._target=i,this._parent=r}return __extends(i,t),i.prototype._prepare=function(){},i.prototype.execute=function(){if(this._target.parent!==this._parent){var t=this._parent.getWorldMatrix().clone();t.invert(),this._target.position=e.Vector3.TransformCoordinates(this._target.position,t),this._target.parent=this._parent}},i.prototype.serialize=function(i){return t.prototype._serialize.call(this,{name:"SetParentAction",properties:[e.Action._GetTargetProperty(this._target),e.Action._GetTargetProperty(this._parent)]},i)},i}(e.Action);e.SetParentAction=l;var u=function(e){function t(t,i,r){e.call(this,t,r),this._sound=i}return __extends(t,e),t.prototype._prepare=function(){},t.prototype.execute=function(){void 0!==this._sound&&this._sound.play()},t.prototype.serialize=function(t){return e.prototype._serialize.call(this,{name:"PlaySoundAction",properties:[{name:"sound",value:this._sound.name}]},t)},t}(e.Action);e.PlaySoundAction=u;var f=function(e){function t(t,i,r){e.call(this,t,r),this._sound=i}return __extends(t,e),t.prototype._prepare=function(){},t.prototype.execute=function(){void 0!==this._sound&&this._sound.stop()},t.prototype.serialize=function(t){return e.prototype._serialize.call(this,{name:"StopSoundAction",properties:[{name:"sound",value:this._sound.name}]},t)},t}(e.Action);e.StopSoundAction=f}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(t,i,r,n,o){this.delayLoadState=e.Engine.DELAYLOADSTATE_NONE,this._totalVertices=0,this._isDisposed=!1,this.id=t,this._engine=i.getEngine(),this._meshes=[],this._scene=i,this._vertexBuffers={},this._indices=[],r?this.setAllVerticesData(r,n):(this._totalVertices=0,this._indices=[]),o&&(o instanceof e.LinesMesh&&(this.boundingBias=new e.Vector2(0,o.intersectionThreshold),this.updateExtend()),this.applyToMesh(o),o.computeWorldMatrix(!0))}return Object.defineProperty(t.prototype,"boundingBias",{get:function(){return this._boundingBias},set:function(e){this._boundingBias&&this._boundingBias.equals(e)||(this._boundingBias=e.clone(),this.updateBoundingInfo(!0,null))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"extend",{get:function(){return this._extend},enumerable:!0,configurable:!0}),t.prototype.getScene=function(){return this._scene},t.prototype.getEngine=function(){return this._engine},t.prototype.isReady=function(){return this.delayLoadState===e.Engine.DELAYLOADSTATE_LOADED||this.delayLoadState===e.Engine.DELAYLOADSTATE_NONE},t.prototype.setAllVerticesData=function(e,t){e.applyToGeometry(this,t),this.notifyUpdate()},t.prototype.setVerticesData=function(t,i,r,n){var o=new e.VertexBuffer(this._engine,i,t,r,0===this._meshes.length,n);this.setVerticesBuffer(o)},t.prototype.setVerticesBuffer=function(t){var i=t.getKind();if(this._vertexBuffers[i]&&this._vertexBuffers[i].dispose(),this._vertexBuffers[i]=t,i===e.VertexBuffer.PositionKind){var r=t.getData(),n=t.getStrideSize();this._totalVertices=r.length/n,this.updateExtend(r,n);for(var o=this._meshes,s=o.length,a=0;s>a;a++){var h=o[a];h._resetPointsArrayCache(),h._boundingInfo=new e.BoundingInfo(this._extend.minimum,this._extend.maximum),h._createGlobalSubMesh(),h.computeWorldMatrix(!0)}}this.notifyUpdate(i)},t.prototype.updateVerticesDataDirectly=function(e,t,i){var r=this.getVertexBuffer(e);r&&(r.updateDirectly(t,i),this.notifyUpdate(e))},t.prototype.updateVerticesData=function(t,i,r){var n=this.getVertexBuffer(t);if(n){if(n.update(i),t===e.VertexBuffer.PositionKind){var o=n.getStrideSize();this._totalVertices=i.length/o,this.updateBoundingInfo(r,i)}this.notifyUpdate(t)}},t.prototype.updateBoundingInfo=function(t,i){t&&this.updateExtend(i);for(var r=this._meshes,n=r.length,o=0;n>o;o++){var s=r[o];if(s._resetPointsArrayCache(),t){s._boundingInfo=new e.BoundingInfo(this._extend.minimum,this._extend.maximum);for(var a=0;a<s.subMeshes.length;a++){var h=s.subMeshes[a];h.refreshBoundingInfo()}}}},t.prototype.getTotalVertices=function(){return this.isReady()?this._totalVertices:0},t.prototype.getVerticesData=function(e,t){var i=this.getVertexBuffer(e);if(!i)return null;var r=i.getData();if(t&&1!==this._meshes.length){for(var n=r.length,o=[],s=0;n>s;s++)o.push(r[s]);return o}return r},t.prototype.getVertexBuffer=function(e){return this.isReady()?this._vertexBuffers[e]:null},t.prototype.getVertexBuffers=function(){return this.isReady()?this._vertexBuffers:null},t.prototype.isVerticesDataPresent=function(e){return this._vertexBuffers?void 0!==this._vertexBuffers[e]:this._delayInfo?-1!==this._delayInfo.indexOf(e):!1},t.prototype.getVerticesDataKinds=function(){var e,t=[];if(!this._vertexBuffers&&this._delayInfo)for(e in this._delayInfo)t.push(e);else for(e in this._vertexBuffers)t.push(e);return t},t.prototype.setIndices=function(e,t){this._indexBuffer&&this._engine._releaseBuffer(this._indexBuffer),this._indices=e,0!==this._meshes.length&&this._indices&&(this._indexBuffer=this._engine.createIndexBuffer(this._indices)),void 0!==t&&(this._totalVertices=t);for(var i=this._meshes,r=i.length,n=0;r>n;n++)i[n]._createGlobalSubMesh();this.notifyUpdate()},t.prototype.getTotalIndices=function(){return this.isReady()?this._indices.length:0},t.prototype.getIndices=function(e){if(!this.isReady())return null;var t=this._indices;if(e&&1!==this._meshes.length){for(var i=t.length,r=[],n=0;i>n;n++)r.push(t[n]);return r}return t},t.prototype.getIndexBuffer=function(){return this.isReady()?this._indexBuffer:null},t.prototype.releaseForMesh=function(e,t){var i=this._meshes,r=i.indexOf(e);if(-1!==r){for(var n in this._vertexBuffers)this._vertexBuffers[n].dispose();this._indexBuffer&&this._engine._releaseBuffer(this._indexBuffer)&&(this._indexBuffer=null),i.splice(r,1),e._geometry=null,0===i.length&&t&&this.dispose()}},t.prototype.applyToMesh=function(e){if(e._geometry!==this){var t=e._geometry;t&&t.releaseForMesh(e);var i=this._meshes;e._geometry=this,this._scene.pushGeometry(this),i.push(e),this.isReady()?this._applyToMesh(e):e._boundingInfo=this._boundingInfo}},t.prototype.updateExtend=function(t,i){void 0===t&&(t=null),t||(t=this._vertexBuffers[e.VertexBuffer.PositionKind].getData()),this._extend=e.Tools.ExtractMinAndMax(t,0,this._totalVertices,this.boundingBias,i)},t.prototype._applyToMesh=function(t){var i=this._meshes.length;for(var r in this._vertexBuffers)1===i&&this._vertexBuffers[r].create(),this._vertexBuffers[r].getBuffer().references=i,r===e.VertexBuffer.PositionKind&&(t._resetPointsArrayCache(),this._extend||this.updateExtend(this._vertexBuffers[r].getData()),t._boundingInfo=new e.BoundingInfo(this._extend.minimum,this._extend.maximum),t._createGlobalSubMesh(),t._updateBoundingInfo());1===i&&this._indices&&this._indices.length>0&&(this._indexBuffer=this._engine.createIndexBuffer(this._indices)),this._indexBuffer&&(this._indexBuffer.references=i)},t.prototype.notifyUpdate=function(e){this.onGeometryUpdated&&this.onGeometryUpdated(this,e)},t.prototype.load=function(t,i){var r=this;if(this.delayLoadState!==e.Engine.DELAYLOADSTATE_LOADING){if(this.isReady())return void(i&&i());this.delayLoadState=e.Engine.DELAYLOADSTATE_LOADING,t._addPendingData(this),e.Tools.LoadFile(this.delayLoadingFile,function(n){r._delayLoadingFunction(JSON.parse(n),r),r.delayLoadState=e.Engine.DELAYLOADSTATE_LOADED,r._delayInfo=[],t._removePendingData(r);for(var o=r._meshes,s=o.length,a=0;s>a;a++)r._applyToMesh(o[a]);i&&i()},function(){},t.database)}},t.prototype.toLeftHanded=function(){var t=this.getIndices(!1);if(null!=t&&t.length>0){for(var i=0;i<t.length;i+=3){var r=t[i+0];t[i+0]=t[i+2],t[i+2]=r}this.setIndices(t)}var n=this.getVerticesData(e.VertexBuffer.PositionKind,!1);if(null!=n&&n.length>0){for(var i=0;i<n.length;i+=3)n[i+2]=-n[i+2];this.setVerticesData(e.VertexBuffer.PositionKind,n,!1)}var o=this.getVerticesData(e.VertexBuffer.NormalKind,!1);if(null!=o&&o.length>0){for(var i=0;i<o.length;i+=3)o[i+2]=-o[i+2];this.setVerticesData(e.VertexBuffer.NormalKind,o,!1)}},t.prototype.isDisposed=function(){return this._isDisposed},t.prototype.dispose=function(){var t,i=this._meshes,r=i.length;for(t=0;r>t;t++)this.releaseForMesh(i[t]);this._meshes=[];for(var n in this._vertexBuffers)this._vertexBuffers[n].dispose();this._vertexBuffers={},this._totalVertices=0,this._indexBuffer&&this._engine._releaseBuffer(this._indexBuffer),this._indexBuffer=null,this._indices=[],this.delayLoadState=e.Engine.DELAYLOADSTATE_NONE,this.delayLoadingFile=null,this._delayLoadingFunction=null,this._delayInfo=[],this._boundingInfo=null,this._scene.removeGeometry(this),this._isDisposed=!0},t.prototype.copy=function(i){var r=new e.VertexData;r.indices=[];for(var n=this.getIndices(),o=0;o<n.length;o++)r.indices.push(n[o]);var s,a=!1,h=!1;for(s in this._vertexBuffers){var c=this.getVerticesData(s);c instanceof Float32Array?r.set(new Float32Array(c),s):r.set(c.slice(0),s),h||(a=this.getVertexBuffer(s).isUpdatable(),h=!a)}var l=new t(i,this._scene,r,a,null);l.delayLoadState=this.delayLoadState,l.delayLoadingFile=this.delayLoadingFile,l._delayLoadingFunction=this._delayLoadingFunction;for(s in this._delayInfo)l._delayInfo=l._delayInfo||[],l._delayInfo.push(s);return l._boundingInfo=new e.BoundingInfo(this._extend.minimum,this._extend.maximum),l},t.prototype.serialize=function(){var t={};return t.id=this.id,e.Tags.HasTags(this)&&(t.tags=e.Tags.GetTags(this)),t},t.prototype.serializeVerticeData=function(){var t=this.serialize();return this.isVerticesDataPresent(e.VertexBuffer.PositionKind)&&(t.positions=this.getVerticesData(e.VertexBuffer.PositionKind)),this.isVerticesDataPresent(e.VertexBuffer.NormalKind)&&(t.normals=this.getVerticesData(e.VertexBuffer.NormalKind)),this.isVerticesDataPresent(e.VertexBuffer.UVKind)&&(t.uvs=this.getVerticesData(e.VertexBuffer.UVKind)),this.isVerticesDataPresent(e.VertexBuffer.UV2Kind)&&(t.uvs2=this.getVerticesData(e.VertexBuffer.UV2Kind)),this.isVerticesDataPresent(e.VertexBuffer.UV3Kind)&&(t.uvs3=this.getVerticesData(e.VertexBuffer.UV3Kind)),this.isVerticesDataPresent(e.VertexBuffer.UV4Kind)&&(t.uvs4=this.getVerticesData(e.VertexBuffer.UV4Kind)),this.isVerticesDataPresent(e.VertexBuffer.UV5Kind)&&(t.uvs5=this.getVerticesData(e.VertexBuffer.UV5Kind)),this.isVerticesDataPresent(e.VertexBuffer.UV6Kind)&&(t.uvs6=this.getVerticesData(e.VertexBuffer.UV6Kind)),this.isVerticesDataPresent(e.VertexBuffer.ColorKind)&&(t.colors=this.getVerticesData(e.VertexBuffer.ColorKind)),this.isVerticesDataPresent(e.VertexBuffer.MatricesIndicesKind)&&(t.matricesIndices=this.getVerticesData(e.VertexBuffer.MatricesIndicesKind),t.matricesIndices._isExpanded=!0),this.isVerticesDataPresent(e.VertexBuffer.MatricesWeightsKind)&&(t.matricesWeights=this.getVerticesData(e.VertexBuffer.MatricesWeightsKind)),t.indices=this.getIndices(),t},t.ExtractFromMesh=function(e,t){var i=e._geometry;return i?i.copy(t):null},t.RandomId=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0,i="x"===e?t:3&t|8;return i.toString(16)})},t.ImportGeometry=function(t,i){var r=i.getScene(),n=t.geometryId;if(n){var o=r.getGeometryByID(n);o&&o.applyToMesh(i)}else if(t instanceof ArrayBuffer){var s=i._binaryInfo;if(s.positionsAttrDesc&&s.positionsAttrDesc.count>0){var a=new Float32Array(t,s.positionsAttrDesc.offset,s.positionsAttrDesc.count);i.setVerticesData(e.VertexBuffer.PositionKind,a,!1)}if(s.normalsAttrDesc&&s.normalsAttrDesc.count>0){var h=new Float32Array(t,s.normalsAttrDesc.offset,s.normalsAttrDesc.count);i.setVerticesData(e.VertexBuffer.NormalKind,h,!1)}if(s.uvsAttrDesc&&s.uvsAttrDesc.count>0){var c=new Float32Array(t,s.uvsAttrDesc.offset,s.uvsAttrDesc.count);i.setVerticesData(e.VertexBuffer.UVKind,c,!1)}if(s.uvs2AttrDesc&&s.uvs2AttrDesc.count>0){var l=new Float32Array(t,s.uvs2AttrDesc.offset,s.uvs2AttrDesc.count);i.setVerticesData(e.VertexBuffer.UV2Kind,l,!1)}if(s.uvs3AttrDesc&&s.uvs3AttrDesc.count>0){var u=new Float32Array(t,s.uvs3AttrDesc.offset,s.uvs3AttrDesc.count);i.setVerticesData(e.VertexBuffer.UV3Kind,u,!1)}if(s.uvs4AttrDesc&&s.uvs4AttrDesc.count>0){var f=new Float32Array(t,s.uvs4AttrDesc.offset,s.uvs4AttrDesc.count);i.setVerticesData(e.VertexBuffer.UV4Kind,f,!1)}if(s.uvs5AttrDesc&&s.uvs5AttrDesc.count>0){var d=new Float32Array(t,s.uvs5AttrDesc.offset,s.uvs5AttrDesc.count);i.setVerticesData(e.VertexBuffer.UV5Kind,d,!1)}if(s.uvs6AttrDesc&&s.uvs6AttrDesc.count>0){var p=new Float32Array(t,s.uvs6AttrDesc.offset,s.uvs6AttrDesc.count);i.setVerticesData(e.VertexBuffer.UV6Kind,p,!1)}if(s.colorsAttrDesc&&s.colorsAttrDesc.count>0){var _=new Float32Array(t,s.colorsAttrDesc.offset,s.colorsAttrDesc.count);i.setVerticesData(e.VertexBuffer.ColorKind,_,!1,s.colorsAttrDesc.stride)}if(s.matricesIndicesAttrDesc&&s.matricesIndicesAttrDesc.count>0){var m=new Int32Array(t,s.matricesIndicesAttrDesc.offset,s.matricesIndicesAttrDesc.count);i.setVerticesData(e.VertexBuffer.MatricesIndicesKind,m,!1)}if(s.matricesWeightsAttrDesc&&s.matricesWeightsAttrDesc.count>0){var g=new Float32Array(t,s.matricesWeightsAttrDesc.offset,s.matricesWeightsAttrDesc.count);i.setVerticesData(e.VertexBuffer.MatricesWeightsKind,g,!1)}if(s.indicesAttrDesc&&s.indicesAttrDesc.count>0){var v=new Int32Array(t,s.indicesAttrDesc.offset,s.indicesAttrDesc.count);i.setIndices(v)}if(s.subMeshesAttrDesc&&s.subMeshesAttrDesc.count>0){var y=new Int32Array(t,s.subMeshesAttrDesc.offset,5*s.subMeshesAttrDesc.count);i.subMeshes=[];for(var x=0;x<s.subMeshesAttrDesc.count;x++){var b=y[5*x+0],P=y[5*x+1],A=y[5*x+2],T=y[5*x+3],E=y[5*x+4];new e.SubMesh(b,P,A,T,E,i)}}}else if(t.positions&&t.normals&&t.indices){if(i.setVerticesData(e.VertexBuffer.PositionKind,t.positions,!1),i.setVerticesData(e.VertexBuffer.NormalKind,t.normals,!1),t.uvs&&i.setVerticesData(e.VertexBuffer.UVKind,t.uvs,!1),t.uvs2&&i.setVerticesData(e.VertexBuffer.UV2Kind,t.uvs2,!1),t.uvs3&&i.setVerticesData(e.VertexBuffer.UV3Kind,t.uvs3,!1),t.uvs4&&i.setVerticesData(e.VertexBuffer.UV4Kind,t.uvs4,!1),t.uvs5&&i.setVerticesData(e.VertexBuffer.UV5Kind,t.uvs5,!1),t.uvs6&&i.setVerticesData(e.VertexBuffer.UV6Kind,t.uvs6,!1),t.colors&&i.setVerticesData(e.VertexBuffer.ColorKind,e.Color4.CheckColors4(t.colors,t.positions.length/3),!1),t.matricesIndices)if(t.matricesIndices._isExpanded)delete t.matricesIndices._isExpanded,i.setVerticesData(e.VertexBuffer.MatricesIndicesKind,t.matricesIndices,!1);else{for(var C=[],x=0;x<t.matricesIndices.length;x++){var S=t.matricesIndices[x];C.push(255&S),C.push((65280&S)>>8),C.push((16711680&S)>>16),C.push(S>>24)}i.setVerticesData(e.VertexBuffer.MatricesIndicesKind,C,!1)}if(t.matricesIndicesExtra)if(t.matricesIndicesExtra._isExpanded)delete t.matricesIndices._isExpanded,i.setVerticesData(e.VertexBuffer.MatricesIndicesExtraKind,t.matricesIndicesExtra,!1);else{for(var C=[],x=0;x<t.matricesIndicesExtra.length;x++){var S=t.matricesIndicesExtra[x];C.push(255&S),C.push((65280&S)>>8),C.push((16711680&S)>>16),C.push(S>>24)}i.setVerticesData(e.VertexBuffer.MatricesIndicesExtraKind,C,!1)}t.matricesWeights&&i.setVerticesData(e.VertexBuffer.MatricesWeightsKind,t.matricesWeights,!1),t.matricesWeightsExtra&&i.setVerticesData(e.VertexBuffer.MatricesWeightsExtraKind,t.matricesWeightsExtra,!1),i.setIndices(t.indices)}if(t.subMeshes){i.subMeshes=[];for(var M=0;M<t.subMeshes.length;M++){var I=t.subMeshes[M];new e.SubMesh(I.materialIndex,I.verticesStart,I.verticesCount,I.indexStart,I.indexCount,i)}}i._shouldGenerateFlatShading&&(i.convertToFlatShadedMesh(),delete i._shouldGenerateFlatShading),i.computeWorldMatrix(!0),r._selectionOctree&&r._selectionOctree.addMesh(i)},t.Parse=function(i,r,n){if(r.getGeometryByID(i.id))return null;var o=new t(i.id,r);return e.Tags.AddTagsTo(o,i.tags),i.delayLoadingFile?(o.delayLoadState=e.Engine.DELAYLOADSTATE_NOTLOADED,o.delayLoadingFile=n+i.delayLoadingFile,o._boundingInfo=new e.BoundingInfo(e.Vector3.FromArray(i.boundingBoxMinimum),e.Vector3.FromArray(i.boundingBoxMaximum)),o._delayInfo=[],i.hasUVs&&o._delayInfo.push(e.VertexBuffer.UVKind),i.hasUVs2&&o._delayInfo.push(e.VertexBuffer.UV2Kind),i.hasUVs3&&o._delayInfo.push(e.VertexBuffer.UV3Kind),i.hasUVs4&&o._delayInfo.push(e.VertexBuffer.UV4Kind),i.hasUVs5&&o._delayInfo.push(e.VertexBuffer.UV5Kind),i.hasUVs6&&o._delayInfo.push(e.VertexBuffer.UV6Kind),i.hasColors&&o._delayInfo.push(e.VertexBuffer.ColorKind),i.hasMatricesIndices&&o._delayInfo.push(e.VertexBuffer.MatricesIndicesKind),i.hasMatricesWeights&&o._delayInfo.push(e.VertexBuffer.MatricesWeightsKind),o._delayLoadingFunction=e.VertexData.ImportVertexData):e.VertexData.ImportVertexData(i,o),r.pushGeometry(o,!0),o},t}();e.Geometry=t;var t;!function(t){var i;!function(i){var r=function(e){function t(t,i,r,n){e.call(this,t,i,null,!1,n),this._canBeRegenerated=r,this._beingRegenerated=!0,this.regenerate(),this._beingRegenerated=!1}return __extends(t,e),t.prototype.canBeRegenerated=function(){return this._canBeRegenerated},t.prototype.regenerate=function(){this._canBeRegenerated&&(this._beingRegenerated=!0,this.setAllVerticesData(this._regenerateVertexData(),!1),this._beingRegenerated=!1)},t.prototype.asNewGeometry=function(t){return e.prototype.copy.call(this,t)},t.prototype.setAllVerticesData=function(t,i){this._beingRegenerated&&e.prototype.setAllVerticesData.call(this,t,!1)},t.prototype.setVerticesData=function(t,i,r){this._beingRegenerated&&e.prototype.setVerticesData.call(this,t,i,!1)},t.prototype._regenerateVertexData=function(){throw new Error("Abstract method")},t.prototype.copy=function(e){throw new Error("Must be overriden in sub-classes.")},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return t.canBeRegenerated=this.canBeRegenerated(),t},t}(t);i._Primitive=r;var n=function(t){function i(i,r,n,o,s,a,h,c,l){void 0===l&&(l=e.Mesh.DEFAULTSIDE),t.call(this,i,r,h,c),this.pathArray=n,this.closeArray=o,this.closePath=s,this.offset=a,this.side=l}return __extends(i,t),i.prototype._regenerateVertexData=function(){return e.VertexData.CreateRibbon({pathArray:this.pathArray,closeArray:this.closeArray,closePath:this.closePath,offset:this.offset,sideOrientation:this.side})},i.prototype.copy=function(e){return new i(e,this.getScene(),this.pathArray,this.closeArray,this.closePath,this.offset,this.canBeRegenerated(),null,this.side)},i}(r);i.Ribbon=n;var o=function(i){function r(t,r,n,o,s,a){void 0===a&&(a=e.Mesh.DEFAULTSIDE),i.call(this,t,r,o,s),this.size=n,this.side=a}return __extends(r,i),r.prototype._regenerateVertexData=function(){return e.VertexData.CreateBox({size:this.size,sideOrientation:this.side})},r.prototype.copy=function(e){return new r(e,this.getScene(),this.size,this.canBeRegenerated(),null,this.side)},r.prototype.serialize=function(){var e=i.prototype.serialize.call(this);return e.size=this.size,e},r.Parse=function(i,r){if(r.getGeometryByID(i.id))return null;var n=new t.Primitives.Box(i.id,r,i.size,i.canBeRegenerated,null);return e.Tags.AddTagsTo(n,i.tags),r.pushGeometry(n,!0),n},r}(r);i.Box=o;var s=function(i){function r(t,r,n,o,s,a,h){void 0===h&&(h=e.Mesh.DEFAULTSIDE),i.call(this,t,r,s,a),this.segments=n,this.diameter=o,this.side=h}return __extends(r,i),r.prototype._regenerateVertexData=function(){return e.VertexData.CreateSphere({segments:this.segments,diameter:this.diameter,sideOrientation:this.side})},r.prototype.copy=function(e){return new r(e,this.getScene(),this.segments,this.diameter,this.canBeRegenerated(),null,this.side)},r.prototype.serialize=function(){var e=i.prototype.serialize.call(this);return e.segments=this.segments,e.diameter=this.diameter,e},r.Parse=function(i,r){if(r.getGeometryByID(i.id))return null;var n=new t.Primitives.Sphere(i.id,r,i.segments,i.diameter,i.canBeRegenerated,null);return e.Tags.AddTagsTo(n,i.tags),r.pushGeometry(n,!0),n},r}(r);i.Sphere=s;var a=function(t){function i(i,r,n,o,s,a,h){void 0===h&&(h=e.Mesh.DEFAULTSIDE),t.call(this,i,r,s,a),this.radius=n,this.tessellation=o,this.side=h}return __extends(i,t),i.prototype._regenerateVertexData=function(){return e.VertexData.CreateDisc({radius:this.radius,tessellation:this.tessellation,sideOrientation:this.side})},i.prototype.copy=function(e){return new i(e,this.getScene(),this.radius,this.tessellation,this.canBeRegenerated(),null,this.side)},i}(r);i.Disc=a;var h=function(i){function r(t,r,n,o,s,a,h,c,l,u){void 0===h&&(h=1),void 0===u&&(u=e.Mesh.DEFAULTSIDE),i.call(this,t,r,c,l),this.height=n,this.diameterTop=o,this.diameterBottom=s,this.tessellation=a,this.subdivisions=h,this.side=u}return __extends(r,i),r.prototype._regenerateVertexData=function(){return e.VertexData.CreateCylinder({height:this.height,diameterTop:this.diameterTop,diameterBottom:this.diameterBottom,tessellation:this.tessellation,subdivisions:this.subdivisions,sideOrientation:this.side})},r.prototype.copy=function(e){return new r(e,this.getScene(),this.height,this.diameterTop,this.diameterBottom,this.tessellation,this.subdivisions,this.canBeRegenerated(),null,this.side)},r.prototype.serialize=function(){var e=i.prototype.serialize.call(this);return e.height=this.height,e.diameterTop=this.diameterTop,e.diameterBottom=this.diameterBottom,e.tessellation=this.tessellation,e},r.Parse=function(i,r){if(r.getGeometryByID(i.id))return null;var n=new t.Primitives.Cylinder(i.id,r,i.height,i.diameterTop,i.diameterBottom,i.tessellation,i.subdivisions,i.canBeRegenerated,null);return e.Tags.AddTagsTo(n,i.tags),r.pushGeometry(n,!0),n},r}(r);i.Cylinder=h;var c=function(i){function r(t,r,n,o,s,a,h,c){void 0===c&&(c=e.Mesh.DEFAULTSIDE),i.call(this,t,r,a,h),this.diameter=n,this.thickness=o,this.tessellation=s,this.side=c}return __extends(r,i),r.prototype._regenerateVertexData=function(){return e.VertexData.CreateTorus({diameter:this.diameter,thickness:this.thickness,tessellation:this.tessellation,sideOrientation:this.side})},r.prototype.copy=function(e){return new r(e,this.getScene(),this.diameter,this.thickness,this.tessellation,this.canBeRegenerated(),null,this.side)},r.prototype.serialize=function(){var e=i.prototype.serialize.call(this);return e.diameter=this.diameter,e.thickness=this.thickness,e.tessellation=this.tessellation,e},r.Parse=function(i,r){if(r.getGeometryByID(i.id))return null;var n=new t.Primitives.Torus(i.id,r,i.diameter,i.thickness,i.tessellation,i.canBeRegenerated,null);return e.Tags.AddTagsTo(n,i.tags),r.pushGeometry(n,!0),n},r}(r);i.Torus=c;var l=function(i){function r(e,t,r,n,o,s,a){i.call(this,e,t,s,a),this.width=r,this.height=n,this.subdivisions=o}return __extends(r,i),r.prototype._regenerateVertexData=function(){return e.VertexData.CreateGround({width:this.width,height:this.height,subdivisions:this.subdivisions})},r.prototype.copy=function(e){return new r(e,this.getScene(),this.width,this.height,this.subdivisions,this.canBeRegenerated(),null)},r.prototype.serialize=function(){var e=i.prototype.serialize.call(this);return e.width=this.width,e.height=this.height,e.subdivisions=this.subdivisions,e},r.Parse=function(i,r){if(r.getGeometryByID(i.id))return null;var n=new t.Primitives.Ground(i.id,r,i.width,i.height,i.subdivisions,i.canBeRegenerated,null);return e.Tags.AddTagsTo(n,i.tags),r.pushGeometry(n,!0),n},r}(r);i.Ground=l;var u=function(t){function i(e,i,r,n,o,s,a,h,c,l){t.call(this,e,i,c,l),this.xmin=r,this.zmin=n,this.xmax=o,this.zmax=s,this.subdivisions=a,this.precision=h}return __extends(i,t),i.prototype._regenerateVertexData=function(){return e.VertexData.CreateTiledGround({xmin:this.xmin,zmin:this.zmin,xmax:this.xmax,zmax:this.zmax,subdivisions:this.subdivisions,precision:this.precision})},i.prototype.copy=function(e){return new i(e,this.getScene(),this.xmin,this.zmin,this.xmax,this.zmax,this.subdivisions,this.precision,this.canBeRegenerated(),null)},i}(r);i.TiledGround=u;var f=function(i){function r(t,r,n,o,s,a){void 0===a&&(a=e.Mesh.DEFAULTSIDE),i.call(this,t,r,o,s),this.size=n,this.side=a}return __extends(r,i),r.prototype._regenerateVertexData=function(){return e.VertexData.CreatePlane({size:this.size,
  21. sideOrientation:this.side})},r.prototype.copy=function(e){return new r(e,this.getScene(),this.size,this.canBeRegenerated(),null,this.side)},r.prototype.serialize=function(){var e=i.prototype.serialize.call(this);return e.size=this.size,e},r.Parse=function(i,r){if(r.getGeometryByID(i.id))return null;var n=new t.Primitives.Plane(i.id,r,i.size,i.canBeRegenerated,null);return e.Tags.AddTagsTo(n,i.tags),r.pushGeometry(n,!0),n},r}(r);i.Plane=f;var d=function(i){function r(t,r,n,o,s,a,h,c,l,u,f){void 0===f&&(f=e.Mesh.DEFAULTSIDE),i.call(this,t,r,l,u),this.radius=n,this.tube=o,this.radialSegments=s,this.tubularSegments=a,this.p=h,this.q=c,this.side=f}return __extends(r,i),r.prototype._regenerateVertexData=function(){return e.VertexData.CreateTorusKnot({radius:this.radius,tube:this.tube,radialSegments:this.radialSegments,tubularSegments:this.tubularSegments,p:this.p,q:this.q,sideOrientation:this.side})},r.prototype.copy=function(e){return new r(e,this.getScene(),this.radius,this.tube,this.radialSegments,this.tubularSegments,this.p,this.q,this.canBeRegenerated(),null,this.side)},r.prototype.serialize=function(){var e=i.prototype.serialize.call(this);return e.radius=this.radius,e.tube=this.tube,e.radialSegments=this.radialSegments,e.tubularSegments=this.tubularSegments,e.p=this.p,e.q=this.q,e},r.Parse=function(i,r){if(r.getGeometryByID(i.id))return null;var n=new t.Primitives.TorusKnot(i.id,r,i.radius,i.tube,i.radialSegments,i.tubularSegments,i.p,i.q,i.canBeRegenerated,null);return e.Tags.AddTagsTo(n,i.tags),r.pushGeometry(n,!0),n},r}(r);i.TorusKnot=d}(i=t.Primitives||(t.Primitives={}))}(t=e.Geometry||(e.Geometry={}))}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(t){function i(i,r){t.call(this,i,r),this.generateOctree=!1,this._worldInverse=new e.Matrix}return __extends(i,t),Object.defineProperty(i.prototype,"subdivisions",{get:function(){return this._subdivisions},enumerable:!0,configurable:!0}),i.prototype.optimize=function(e,t){void 0===t&&(t=32),this._subdivisions=e,this.subdivide(this._subdivisions),this.createOrUpdateSubmeshesOctree(t)},i.prototype.getHeightAtCoordinates=function(e,t){if(e-=this.position.x,t-=this.position.z,e/=this.scaling.x,t/=this.scaling.z,e<this._minX||e>this._maxX||t<this._minZ||t>this._maxZ)return this.position.y;this._heightQuads&&0!=this._heightQuads.length||(this._initHeightQuads(),this._computeHeightQuads());var i=this._getFacetAt(e,t),r=-(i.x*e+i.z*t+i.w)/i.y;return r*this.scaling.y+this.position.y},i.prototype.getNormalAtCoordinates=function(t,i){var r=new e.Vector3(0,1,0);return this.getNormalAtCoordinatesToRef(t,i,r),r},i.prototype.getNormalAtCoordinatesToRef=function(e,t,i){if(e-=this.position.x,t-=this.position.z,e/=this.scaling.x,t/=this.scaling.z,!(e<this._minX||e>this._maxX||t<this._minZ||t>this._maxZ)){this._heightQuads&&0!=this._heightQuads.length||(this._initHeightQuads(),this._computeHeightQuads());var r=this._getFacetAt(e,t);i.x=r.x,i.y=r.y,i.z=r.z}},i.prototype.updateCoordinateHeights=function(){this._heightQuads&&0!=this._heightQuads.length||this._initHeightQuads(),this._computeHeightQuads()},i.prototype._getFacetAt=function(e,t){var i,r=Math.floor((e+this._maxX)*this._subdivisions/this._width),n=Math.floor(-(t+this._maxZ)*this._subdivisions/this._height+this._subdivisions),o=this._heightQuads[n*this._subdivisions+r];return i=t<o.slope.x*e+o.slope.y?o.facet1:o.facet2},i.prototype._initHeightQuads=function(){this._heightQuads=new Array;for(var t=0;t<this._subdivisions;t++)for(var i=0;i<this._subdivisions;i++){var r={slope:e.Vector2.Zero(),facet1:new e.Vector4(0,0,0,0),facet2:new e.Vector4(0,0,0,0)};this._heightQuads[t*this._subdivisions+i]=r}},i.prototype._computeHeightQuads=function(){for(var t=this.getVerticesData(e.VertexBuffer.PositionKind),i=e.Tmp.Vector3[0],r=e.Tmp.Vector3[1],n=e.Tmp.Vector3[2],o=e.Tmp.Vector3[3],s=e.Tmp.Vector3[4],a=e.Tmp.Vector3[5],h=e.Tmp.Vector3[6],c=e.Tmp.Vector3[7],l=e.Tmp.Vector3[8],u=0,f=0,d=0,p=0,_=0,m=0,g=0,v=0;v<this._subdivisions;v++)for(var y=0;y<this._subdivisions;y++){u=3*y,f=v*(this._subdivisions+1)*3,d=(v+1)*(this._subdivisions+1)*3,i.x=t[f+u],i.y=t[f+u+1],i.z=t[f+u+2],r.x=t[f+u+3],r.y=t[f+u+4],r.z=t[f+u+5],n.x=t[d+u],n.y=t[d+u+1],n.z=t[d+u+2],o.x=t[d+u+3],o.y=t[d+u+4],o.z=t[d+u+5],p=(o.z-i.z)/(o.x-i.x),_=i.z-p*i.x,r.subtractToRef(i,s),n.subtractToRef(i,a),o.subtractToRef(i,h),e.Vector3.CrossToRef(h,a,c),e.Vector3.CrossToRef(s,h,l),c.normalize(),l.normalize(),m=-(c.x*i.x+c.y*i.y+c.z*i.z),g=-(l.x*r.x+l.y*r.y+l.z*r.z);var x=this._heightQuads[v*this._subdivisions+y];x.slope.copyFromFloats(p,_),x.facet1.copyFromFloats(c.x,c.y,c.z,m),x.facet2.copyFromFloats(l.x,l.y,l.z,g)}},i}(e.Mesh);e.GroundMesh=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(t){function i(i,r,n,o,s){void 0===n&&(n=null),t.call(this,i,r,n,o,s),this.color=new e.Color3(1,1,1),this.alpha=1,this._positionBuffer={},o&&(this.color=o.color.clone(),this.alpha=o.alpha),this._intersectionThreshold=.1,this._colorShader=new e.ShaderMaterial("colorShader",r,"color",{attributes:[e.VertexBuffer.PositionKind],uniforms:["worldViewProjection","color"],needAlphaBlending:!0}),this._positionBuffer[e.VertexBuffer.PositionKind]=null}return __extends(i,t),Object.defineProperty(i.prototype,"intersectionThreshold",{get:function(){return this._intersectionThreshold},set:function(t){this._intersectionThreshold!==t&&(this._intersectionThreshold=t,this.geometry&&(this.geometry.boundingBias=new e.Vector2(0,t)))},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"material",{get:function(){return this._colorShader},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"checkCollisions",{get:function(){return!1},enumerable:!0,configurable:!0}),i.prototype.createInstance=function(t){return e.Tools.Log("LinesMeshes do not support createInstance."),null},i.prototype._bind=function(t,i,r){var n=this.getScene().getEngine();this._positionBuffer[e.VertexBuffer.PositionKind]=this._geometry.getVertexBuffer(e.VertexBuffer.PositionKind),n.bindBuffers(this._positionBuffer,this._geometry.getIndexBuffer(),this._colorShader.getEffect()),this._colorShader.setColor4("color",this.color.toColor4(this.alpha))},i.prototype._draw=function(e,t,i){if(this._geometry&&this._geometry.getVertexBuffers()&&this._geometry.getIndexBuffer()){var r=this.getScene().getEngine();r.draw(!1,e.indexStart,e.indexCount)}},i.prototype.dispose=function(e){this._colorShader.dispose(),t.prototype.dispose.call(this,e)},i.prototype.clone=function(e,t,r){return new i(e,this.getScene(),t,this,r)},i}(e.Mesh);e.LinesMesh=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function e(e,t,i){var r=this;void 0===t&&(t=""),void 0===i&&(i="black"),this._renderingCanvas=e,this._loadingText=t,this._loadingDivBackgroundColor=i,this._resizeLoadingUI=function(){var e=r._renderingCanvas.getBoundingClientRect();r._loadingDiv.style.position="absolute",r._loadingDiv.style.left=e.left+"px",r._loadingDiv.style.top=e.top+"px",r._loadingDiv.style.width=e.width+"px",r._loadingDiv.style.height=e.height+"px"}}return e.prototype.displayLoadingUI=function(){var e=this;if(!this._loadingDiv){this._loadingDiv=document.createElement("div"),this._loadingDiv.id="babylonjsLoadingDiv",this._loadingDiv.style.opacity="0",this._loadingDiv.style.transition="opacity 1.5s ease",this._loadingTextDiv=document.createElement("div"),this._loadingTextDiv.style.position="absolute",this._loadingTextDiv.style.left="0",this._loadingTextDiv.style.top="50%",this._loadingTextDiv.style.marginTop="80px",this._loadingTextDiv.style.width="100%",this._loadingTextDiv.style.height="20px",this._loadingTextDiv.style.fontFamily="Arial",this._loadingTextDiv.style.fontSize="14px",this._loadingTextDiv.style.color="white",this._loadingTextDiv.style.textAlign="center",this._loadingTextDiv.innerHTML="Loading",this._loadingDiv.appendChild(this._loadingTextDiv),this._loadingTextDiv.innerHTML=this._loadingText;var t=new Image;t.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAYAAABw4pVUAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAYdEVYdFNvZnR3YXJlAHBhaW50Lm5ldCA0LjAuM4zml1AAAARbSURBVHhe7Z09aFNRFMc716kuLrq4FdyLq4Wi4CAoRQcR0UJBUBdRiuLSIYMo6CA4FF2sgw6CFAdFUOpSQYcWO4hD26UQCfXrIQrx/JJzw1OSWq3NPeL/B4Fy+0jg/HO+7j3vpUcI8b/Q39+/49ihfWdPHT94Yf/e3Se3bd263f8lus218TPn6vV6Ya8Wi/MzNRNmj18iusX9W1evmP1/EKNEIVG6CMbG6E3bt+fT++pHha8NoHdT72bLE8NDg7tGU64gLLndV4Wc4m8j/pS+vr4tGB/DT16v3Fyr8dvBe/jbit8BL0AES9LX1iPAz+BR/hFiLVCynj95dPzNy6fv3IZ/k4L3948Sq7FzYGBg4vLFGxitabuOFCbWNKGrMnbiUuo18KaV6tIHv6YtvL9/nOgE31jCktmrY7k6+/zhE4yP4Vf7hiNqh/BWWEl8mzDol4p22Lf7cIdvdUMEvv0Y2S9fE5S1hLzpqTsPkiep//gFGPnR3Yl7GL5p/xYFBrTwM+iXio3GqpwDGL5p/xYNIX7XG8Q6IJRgdIzf1KBBgafII7oMidhyQtVFaMA2Bt7il4huQRhaXphbcR2g4RXqBzKAGHiCCwGFVUAj/m/RTRDj29cvn10I0PZ3LghH5f4CL1EFlQmqqXK3jDDKFxmhQ3Yt6oQseUZGKmMnTpsOqc8o1F9kBOMjQlOLeqEeIyOc6JV6jYLJD/+XyIFvnzdgl9aXRQ5I2qZDK1SpospMqaoqON/wZZGDciLnMMiXRS7IF4hhqMTNTdk7CFu+LHLhR7BQqBvPDJUUQqCGvCMATHUgBmhWNgApmdOda9YpM+VwRYfuyyIXDK8hBlilNerLIheMZCKGwlUAyru6GlwOgPUbRxADdJ9FAChxXY864viyyEXqPxhc0M2TAfAbatSdRyHtXymhByEdRnE3ky+JnHAIhSA0h74kckETmHoQbSgGwJrCIRMEPSRIBCRIMAhZaYhaggQhJXUJEoRU9mofKwh+F22dLRRfEjlJM7w6KQwCoQpBOKTyJZETjmwRxKqtGV8SOSkNOGjKPQppBEgDDkFgpxdBVGkFgaYQQXRIFQSObk0P5ZFIpAZRHXsQ0r0hCluBWKkuvVbYCkQaCdL5ehBScudJP4yY+rLISdps1NBDEJKXMMmoSfggWC4ZQRR17oFYXph7hSiquIKQ+hJGTX1J5MYSPD/GVdNzsgLBwZVCVyAQAkF0ohiI/c1fS6tNXq9UfEnkhudmIQolsS+J3Hh/UtNDzQLhj42VKJFInqLwFYiUU5ToA+HdfI0JevUpQUAIn+vSz2lHIuUV/dJOIHhOY/IWVWGBIHQtzs88s9zyWBuTgcBLzGOmeNnfF/QslSDgMeQW85i3DOQxuipxAkCyZ8SIm4Omp+7MMlCB59j6sKZcMoM4iIEoeI2J9AKxrFobZx0v4vYInuHFS4J1GQRCAGaLEYQXfyMML5XSQgghhBBCCCH+cXp6vgNhKpSKX/XdOAAAAABJRU5ErkJggg==",t.style.position="absolute",t.style.left="50%",t.style.top="50%",t.style.marginLeft="-50px",t.style.marginTop="-50px",t.style.transition="transform 1.0s ease",t.style.webkitTransition="-webkit-transform 1.0s ease";var i=360,r=function(){i+=360,t.style.transform="rotateZ("+i+"deg)",t.style.webkitTransform="rotateZ("+i+"deg)"};t.addEventListener("transitionend",r),t.addEventListener("webkitTransitionEnd",r),this._loadingDiv.appendChild(t);var n=new Image;n.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAYAAABw4pVUAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAYdEVYdFNvZnR3YXJlAHBhaW50Lm5ldCA0LjAuM4zml1AAAAYJSURBVHhe7Zy/qx1FFMff/2Av2Nvbi4WFiiAEY/OQ2IgQsbCJQoqkCAgpFLXyoZURLfwBIiIpgqZJoYQYlWelNsIrNOxDJcrzfHe+G97dnTl75u7euzv7zgcWHrlnZmfOmXPmzI/NjuM4juM4juM4juM4juM4juM4juM4juM45fPic08/uHf5/CvffH7lnT8PfrtxdHS0n3p+/fHGl5+89/prr5599iEWd8bg0rkXHoFyqehKnlxQpjYSDHTm9JMPsGrHylOPPXofvICKXMcIGtXdf/76AYbm6xyNW9e/eAtKC7rbKLXnvHHx5Sf4auc4Ek7OQkFU1Dap/vv37k/wSjblZANFiFIGzw98hhizwqBgs04mCBdQRNCHidoAEtY+lLIvtSdoGFeyql2ZH57HBH4sE7O+o/r9l+8/ZXUni68+2jsHBQQ9qNRGeP/tSxdSYQX/roUcpL4/f3vtM9TD+jTq92n1LQ7jxF1hhGPtwWL3gGccy8JuS1r8sVWBGXNVdSKMYjBGPUJjCzooiGuSpnwlnnOGP2dhHRSLNgpHp2oMKIriK8TmG4Qh/rwW8D6pps9b9im+LDDipXOqMVJrAngBfg9i98gevWKA+/nnCod3Dr5GfaHaDgidVym6HKRjGIkpqthcAVKGxNqBImbEo66kjCih8AOpNmkUmbMuUrR8kEqiU6FvHZLGAPJ71JCYSyhiBqmwFE2GoD6jLGIfDHtG6EzoU4dK21PCqIRMEF0FGRjFzGDtIkXVAdATvsqfT9CJ0JcOFdYiFIsiMlqYy1YOFpQo2OddqBtyEaq9y+efoVh5oPHoROjLKn0j3JIE5Ka8UqZRtGrMnneX6yVofOhDh94MSbznTcpqmDOt1vyQzOgaJAF4F3JBfIXesrNEGWWmjIX7UBZ6jRJbBMLg/DmJiKUGVHleIpnVNTa+jakzkAviJqLhi4MC9XQGBrZeKJZESSrKy7ik0VGFWhQBRDTHIACKQ5l9nAjy75gya4a2w+Jhs0FJdc0xX/GwUbAqFBkZi7QpJ2w16WUbjFyK9MJF3KaoEM74KhVtLrQOrsmRxkbdHEqmSC/c+EuGnIFkjW7Ih2Kr4CCMIvNG2hrrgLpCjiFloooYCjyYrzCRyvhyBthkIPuQtsZGdnbMTezyDiU71KTC5zr7aVsHbsz2tllrEkS5UHwU1tq1HbtPW4UbeB0O7xx8R5EsMJql+BheUmHjkNVmIRP7LutoM3+D4O4tG7vCkNO9ESZ4lL3J6rKRMPx4qKbD/A0icf8CG7tC7kTahnMTwleuYSrsS7GatRAvfZh1tTm5BmmQCdZ8a0Sefe28xUrRBkmFLKy8KTIKUDRX0Y1xagPgwbaIdeFnQULmKak3xvwNMkVGgok/N5XNoehJvejRlCDl9escI28dJU0tZ++nBTJE9mEF647x5Ehbo4s5hDOKFIU0PdofeA5F5k1q63zIWmQqNI/P3ZubjFTqKxQ3jyjHAOX0RdlgVO9hzRFpczRcjZ3Gbxxpc7Qj6+5pTYF2OFXawNI+yDGf1k2NcvOlzBQeDQ/t7zD7DsEDpJ2xATXaNtDWUS4IzP4DS2ljajAVu57SUkYw245ptxZxA5JiZaJ0DswudGn3kYUy54426EjoT4dZfYbccxC2nI92cDkZHQr96jD4AGkMDKeSy/COBsRe6VTSKFN6irLeaCh3IteQjt1E5+oudsG/b/2DfZ5AqsYo8vMDK9LB1HzSsLWvlGThdxXvC6+NsqyPPWP0pMINtbdsajfVeC6f/GZ+cdAofQoB1d+Hf9waY98I7+RXWab3Lt4zYkjHtTnlOLXHYMsCh1zWeQYehu1zfNPOOiys/d91LAKEBSgh6MJMbSA82AaHofDgAIwbgvVvlLNS11nModMm4UZergLHZBZrodmBuA3lBB1thdorSjkOmATMDwg/UBQVtglqQyx6fbEJ+H3IWIapjYAjAfeIgeCMHldueJvFaqDaAHhwf8qNsEEQ1iQbOoUUGIbCLRc8+Bvfp4jyd2FEijuO4ziO4ziO4ziO4ziO4ziO4ziO4ziOUzw7O/8D0P7rcZ/GEboAAAAASUVORK5CYII=",n.style.position="absolute",n.style.left="50%",n.style.top="50%",n.style.marginLeft="-50px",n.style.marginTop="-50px",this._loadingDiv.appendChild(n),this._resizeLoadingUI(),window.addEventListener("resize",this._resizeLoadingUI),this._loadingDiv.style.backgroundColor=this._loadingDivBackgroundColor,document.body.appendChild(this._loadingDiv),setTimeout(function(){e._loadingDiv.style.opacity="1",t.style.transform="rotateZ(360deg)",t.style.webkitTransform="rotateZ(360deg)"},0)}},e.prototype.hideLoadingUI=function(){var e=this;if(this._loadingDiv){var t=function(){e._loadingDiv&&(document.body.removeChild(e._loadingDiv),window.removeEventListener("resize",e._resizeLoadingUI),e._loadingDiv=null)};this._loadingDiv.style.opacity="0",this._loadingDiv.addEventListener("transitionend",t)}},Object.defineProperty(e.prototype,"loadingUIText",{set:function(e){this._loadingText=e,this._loadingTextDiv&&(this._loadingTextDiv.innerHTML=this._loadingText)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"loadingUIBackgroundColor",{get:function(){return this._loadingDivBackgroundColor},set:function(e){this._loadingDivBackgroundColor=e,this._loadingDiv&&(this._loadingDiv.style.backgroundColor=this._loadingDivBackgroundColor)},enumerable:!0,configurable:!0}),e}();e.DefaultLoadingScreen=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(){this._audioContext=null,this._audioContextInitialized=!1,this.canUseWebAudio=!1,this.WarnedWebAudioUnsupported=!1,this.unlocked=!1,"undefined"==typeof window.AudioContext&&"undefined"==typeof window.webkitAudioContext||(window.AudioContext=window.AudioContext||window.webkitAudioContext,this.canUseWebAudio=!0),/iPad|iPhone|iPod/.test(navigator.platform)?this._unlockiOSaudio():this.unlocked=!0}return Object.defineProperty(t.prototype,"audioContext",{get:function(){return this._audioContextInitialized||this._initializeAudioContext(),this._audioContext},enumerable:!0,configurable:!0}),t.prototype._unlockiOSaudio=function(){var e=this,t=function(){var i=e.audioContext.createBuffer(1,1,22050),r=e.audioContext.createBufferSource();r.buffer=i,r.connect(e.audioContext.destination),r.start(0),setTimeout(function(){r.playbackState!==r.PLAYING_STATE&&r.playbackState!==r.FINISHED_STATE||(e.unlocked=!0,window.removeEventListener("touchend",t,!1),e.onAudioUnlocked&&e.onAudioUnlocked())},0)};window.addEventListener("touchend",t,!1)},t.prototype._initializeAudioContext=function(){try{this.canUseWebAudio&&(this._audioContext=new AudioContext,this.masterGain=this._audioContext.createGain(),this.masterGain.gain.value=1,this.masterGain.connect(this._audioContext.destination),this._audioContextInitialized=!0)}catch(t){this.canUseWebAudio=!1,e.Tools.Error("Web Audio: "+t.message)}},t.prototype.dispose=function(){this.canUseWebAudio&&this._audioContextInitialized&&(this._connectedAnalyser&&(this._connectedAnalyser.stopDebugCanvas(),this._connectedAnalyser.dispose(),this.masterGain.disconnect(),this.masterGain.connect(this._audioContext.destination),this._connectedAnalyser=null),this.masterGain.gain.value=1),this.WarnedWebAudioUnsupported=!1},t.prototype.getGlobalVolume=function(){return this.canUseWebAudio&&this._audioContextInitialized?this.masterGain.gain.value:-1},t.prototype.setGlobalVolume=function(e){this.canUseWebAudio&&this._audioContextInitialized&&(this.masterGain.gain.value=e)},t.prototype.connectToAnalyser=function(e){this._connectedAnalyser&&this._connectedAnalyser.stopDebugCanvas(),this.canUseWebAudio&&this._audioContextInitialized&&(this._connectedAnalyser=e,this.masterGain.disconnect(),this._connectedAnalyser.connectAudioNodes(this.masterGain,this._audioContext.destination))},t}();e.AudioEngine=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(t,i,r,n,o){var s=this;this.autoplay=!1,this.loop=!1,this.useCustomAttenuation=!1,this.spatialSound=!1,this.refDistance=1,this.rolloffFactor=1,this.maxDistance=100,this.distanceModel="linear",this._panningModel="equalpower",this._playbackRate=1,this._streaming=!1,this._startTime=0,this._startOffset=0,this._position=e.Vector3.Zero(),this._localDirection=new e.Vector3(1,0,0),this._volume=1,this._isLoaded=!1,this._isReadyToPlay=!1,this.isPlaying=!1,this.isPaused=!1,this._isDirectional=!1,this._coneInnerAngle=360,this._coneOuterAngle=360,this._coneOuterGain=0,this._isOutputConnected=!1,this.name=t,this._scene=r,this._readyToPlayCallback=n,this._customAttenuationFunction=function(e,t,i,r,n){return i>t?e*(1-t/i):0},o&&(this.autoplay=o.autoplay||!1,this.loop=o.loop||!1,void 0!==o.volume&&(this._volume=o.volume),this.spatialSound=o.spatialSound||!1,this.maxDistance=o.maxDistance||100,this.useCustomAttenuation=o.useCustomAttenuation||!1,this.rolloffFactor=o.rolloffFactor||1,this.refDistance=o.refDistance||1,this.distanceModel=o.distanceModel||"linear",this._playbackRate=o.playbackRate||1,this._streaming=o.streaming||!1),e.Engine.audioEngine.canUseWebAudio?(this._soundGain=e.Engine.audioEngine.audioContext.createGain(),this._soundGain.gain.value=this._volume,this._inputAudioNode=this._soundGain,this._ouputAudioNode=this._soundGain,this.spatialSound&&this._createSpatialParameters(),this._scene.mainSoundTrack.AddSound(this),i&&("string"==typeof i?this._streaming?(this._htmlAudioElement=new Audio(i),this._htmlAudioElement.controls=!1,this._htmlAudioElement.loop=this.loop,this._htmlAudioElement.crossOrigin="anonymous",this._htmlAudioElement.preload="auto",this._htmlAudioElement.addEventListener("canplaythrough",function(){s._isReadyToPlay=!0,s.autoplay&&s.play(),s._readyToPlayCallback&&s._readyToPlayCallback()}),document.body.appendChild(this._htmlAudioElement)):e.Tools.LoadFile(i,function(e){s._soundLoaded(e)},null,this._scene.database,!0):i instanceof ArrayBuffer?i.byteLength>0&&this._soundLoaded(i):e.Tools.Error("Parameter must be a URL to the sound or an ArrayBuffer of the sound."))):(this._scene.mainSoundTrack.AddSound(this),e.Engine.audioEngine.WarnedWebAudioUnsupported||(e.Tools.Error("Web Audio is not supported by your browser."),e.Engine.audioEngine.WarnedWebAudioUnsupported=!0),this._readyToPlayCallback&&window.setTimeout(function(){s._readyToPlayCallback()},1e3))}return t.prototype.dispose=function(){e.Engine.audioEngine.canUseWebAudio&&this._isReadyToPlay&&(this.isPlaying&&this.stop(),this._isReadyToPlay=!1,-1===this.soundTrackId?this._scene.mainSoundTrack.RemoveSound(this):this._scene.soundTracks[this.soundTrackId].RemoveSound(this),this._soundGain&&(this._soundGain.disconnect(),this._soundGain=null),this._soundPanner&&(this._soundPanner.disconnect(),this._soundPanner=null),this._soundSource&&(this._soundSource.disconnect(),this._soundSource=null),this._audioBuffer=null,this._htmlAudioElement&&(this._htmlAudioElement.pause(),this._htmlAudioElement.src="",document.body.removeChild(this._htmlAudioElement)),this._connectedMesh&&(this._connectedMesh.unregisterAfterWorldMatrixUpdate(this._registerFunc),this._connectedMesh=null))},t.prototype._soundLoaded=function(t){var i=this;this._isLoaded=!0,e.Engine.audioEngine.audioContext.decodeAudioData(t,function(e){i._audioBuffer=e,i._isReadyToPlay=!0,i.autoplay&&i.play(),i._readyToPlayCallback&&i._readyToPlayCallback()},function(){e.Tools.Error("Error while decoding audio data for: "+i.name)})},t.prototype.setAudioBuffer=function(t){e.Engine.audioEngine.canUseWebAudio&&(this._audioBuffer=t,this._isReadyToPlay=!0)},t.prototype.updateOptions=function(e){e&&(this.loop=e.loop||this.loop,this.maxDistance=e.maxDistance||this.maxDistance,this.useCustomAttenuation=e.useCustomAttenuation||this.useCustomAttenuation,this.rolloffFactor=e.rolloffFactor||this.rolloffFactor,this.refDistance=e.refDistance||this.refDistance,this.distanceModel=e.distanceModel||this.distanceModel,this._playbackRate=e.playbackRate||this._playbackRate,this._updateSpatialParameters(),this.isPlaying&&(this._streaming?this._htmlAudioElement.playbackRate=this._playbackRate:this._soundSource.playbackRate.value=this._playbackRate))},t.prototype._createSpatialParameters=function(){e.Engine.audioEngine.canUseWebAudio&&(this._scene.headphone&&(this._panningModel="HRTF"),this._soundPanner=e.Engine.audioEngine.audioContext.createPanner(),this._updateSpatialParameters(),this._soundPanner.connect(this._ouputAudioNode),this._inputAudioNode=this._soundPanner)},t.prototype._updateSpatialParameters=function(){this.spatialSound&&(this.useCustomAttenuation?(this._soundPanner.distanceModel="linear",this._soundPanner.maxDistance=Number.MAX_VALUE,this._soundPanner.refDistance=1,this._soundPanner.rolloffFactor=1,this._soundPanner.panningModel=this._panningModel):(this._soundPanner.distanceModel=this.distanceModel,this._soundPanner.maxDistance=this.maxDistance,this._soundPanner.refDistance=this.refDistance,this._soundPanner.rolloffFactor=this.rolloffFactor,this._soundPanner.panningModel=this._panningModel))},t.prototype.switchPanningModelToHRTF=function(){this._panningModel="HRTF",this._switchPanningModel()},t.prototype.switchPanningModelToEqualPower=function(){this._panningModel="equalpower",this._switchPanningModel()},t.prototype._switchPanningModel=function(){e.Engine.audioEngine.canUseWebAudio&&this.spatialSound&&(this._soundPanner.panningModel=this._panningModel)},t.prototype.connectToSoundTrackAudioNode=function(t){e.Engine.audioEngine.canUseWebAudio&&(this._isOutputConnected&&this._ouputAudioNode.disconnect(),this._ouputAudioNode.connect(t),this._isOutputConnected=!0)},t.prototype.setDirectionalCone=function(t,i,r){return t>i?void e.Tools.Error("setDirectionalCone(): outer angle of the cone must be superior or equal to the inner angle."):(this._coneInnerAngle=t,this._coneOuterAngle=i,this._coneOuterGain=r,this._isDirectional=!0,void(this.isPlaying&&this.loop&&(this.stop(),this.play())))},t.prototype.setPosition=function(t){this._position=t,e.Engine.audioEngine.canUseWebAudio&&this.spatialSound&&this._soundPanner.setPosition(this._position.x,this._position.y,this._position.z)},t.prototype.setLocalDirectionToMesh=function(t){this._localDirection=t,e.Engine.audioEngine.canUseWebAudio&&this._connectedMesh&&this.isPlaying&&this._updateDirection()},t.prototype._updateDirection=function(){var t=this._connectedMesh.getWorldMatrix(),i=e.Vector3.TransformNormal(this._localDirection,t);i.normalize(),this._soundPanner.setOrientation(i.x,i.y,i.z)},t.prototype.updateDistanceFromListener=function(){if(e.Engine.audioEngine.canUseWebAudio&&this._connectedMesh&&this.useCustomAttenuation){var t=this._connectedMesh.getDistanceToCamera(this._scene.activeCamera);this._soundGain.gain.value=this._customAttenuationFunction(this._volume,t,this.maxDistance,this.refDistance,this.rolloffFactor)}},t.prototype.setAttenuationFunction=function(e){this._customAttenuationFunction=e},t.prototype.play=function(t){var i=this;if(this._isReadyToPlay&&this._scene.audioEnabled)try{this._startOffset<0&&(t=-this._startOffset,this._startOffset=0);var r=t?e.Engine.audioEngine.audioContext.currentTime+t:e.Engine.audioEngine.audioContext.currentTime;this._soundSource&&this._streamingSource||this.spatialSound&&(this._soundPanner.setPosition(this._position.x,this._position.y,this._position.z),this._isDirectional&&(this._soundPanner.coneInnerAngle=this._coneInnerAngle,this._soundPanner.coneOuterAngle=this._coneOuterAngle,this._soundPanner.coneOuterGain=this._coneOuterGain,this._connectedMesh?this._updateDirection():this._soundPanner.setOrientation(this._localDirection.x,this._localDirection.y,this._localDirection.z))),this._streaming?(this._streamingSource||(this._streamingSource=e.Engine.audioEngine.audioContext.createMediaElementSource(this._htmlAudioElement),this._htmlAudioElement.onended=function(){i._onended()},this._htmlAudioElement.playbackRate=this._playbackRate),this._streamingSource.disconnect(),this._streamingSource.connect(this._inputAudioNode),this._htmlAudioElement.play()):(this._soundSource=e.Engine.audioEngine.audioContext.createBufferSource(),this._soundSource.buffer=this._audioBuffer,this._soundSource.connect(this._inputAudioNode),this._soundSource.loop=this.loop,this._soundSource.playbackRate.value=this._playbackRate,this._soundSource.onended=function(){i._onended()},this._soundSource.start(r,this.isPaused?this._startOffset%this._soundSource.buffer.duration:0)),this._startTime=r,this.isPlaying=!0,this.isPaused=!1}catch(n){e.Tools.Error("Error while trying to play audio: "+this.name+", "+n.message)}},t.prototype._onended=function(){this.isPlaying=!1,this.onended&&this.onended()},t.prototype.stop=function(t){if(this.isPlaying){if(this._streaming)this._htmlAudioElement.pause(),this._htmlAudioElement.currentTime>0&&(this._htmlAudioElement.currentTime=0);else{var i=t?e.Engine.audioEngine.audioContext.currentTime+t:e.Engine.audioEngine.audioContext.currentTime;this._soundSource.stop(i),this._soundSource.onended=null,this.isPaused||(this._startOffset=0)}this.isPlaying=!1}},t.prototype.pause=function(){this.isPlaying&&(this.isPaused=!0,this._streaming?this._htmlAudioElement.pause():(this.stop(0),this._startOffset+=e.Engine.audioEngine.audioContext.currentTime-this._startTime))},t.prototype.setVolume=function(t,i){e.Engine.audioEngine.canUseWebAudio&&(i?(this._soundGain.gain.cancelScheduledValues(e.Engine.audioEngine.audioContext.currentTime),this._soundGain.gain.setValueAtTime(this._soundGain.gain.value,e.Engine.audioEngine.audioContext.currentTime),this._soundGain.gain.linearRampToValueAtTime(t,e.Engine.audioEngine.audioContext.currentTime+i)):this._soundGain.gain.value=t),this._volume=t},t.prototype.setPlaybackRate=function(e){this._playbackRate=e,this.isPlaying&&(this._streaming?this._htmlAudioElement.playbackRate=this._playbackRate:this._soundSource.playbackRate.value=this._playbackRate)},t.prototype.getVolume=function(){return this._volume},t.prototype.attachToMesh=function(e){var t=this;this._connectedMesh&&(this._connectedMesh.unregisterAfterWorldMatrixUpdate(this._registerFunc),this._registerFunc=null),this._connectedMesh=e,this.spatialSound||(this.spatialSound=!0,this._createSpatialParameters(),this.isPlaying&&this.loop&&(this.stop(),this.play())),this._onRegisterAfterWorldMatrixUpdate(this._connectedMesh),this._registerFunc=function(e){return t._onRegisterAfterWorldMatrixUpdate(e)},e.registerAfterWorldMatrixUpdate(this._registerFunc)},t.prototype.detachFromMesh=function(){this._connectedMesh&&(this._connectedMesh.unregisterAfterWorldMatrixUpdate(this._registerFunc),this._registerFunc=null,this._connectedMesh=null)},t.prototype._onRegisterAfterWorldMatrixUpdate=function(t){this.setPosition(t.getBoundingInfo().boundingSphere.centerWorld),e.Engine.audioEngine.canUseWebAudio&&this._isDirectional&&this.isPlaying&&this._updateDirection()},t.prototype.clone=function(){var e=this;if(this._streaming)return null;var i=function(){e._isReadyToPlay?(n._audioBuffer=e.getAudioBuffer(),n._isReadyToPlay=!0,n.autoplay&&n.play()):window.setTimeout(i,300)},r={autoplay:this.autoplay,loop:this.loop,volume:this._volume,spatialSound:this.spatialSound,maxDistance:this.maxDistance,useCustomAttenuation:this.useCustomAttenuation,rolloffFactor:this.rolloffFactor,refDistance:this.refDistance,distanceModel:this.distanceModel},n=new t(this.name+"_cloned",new ArrayBuffer(0),this._scene,null,r);return this.useCustomAttenuation&&n.setAttenuationFunction(this._customAttenuationFunction),n.setPosition(this._position),n.setPlaybackRate(this._playbackRate),i(),n},t.prototype.getAudioBuffer=function(){return this._audioBuffer},t.Parse=function(i,r,n,o){var s,a=i.name;s=i.url?n+i.url:n+a;var h,c={autoplay:i.autoplay,loop:i.loop,volume:i.volume,spatialSound:i.spatialSound,maxDistance:i.maxDistance,rolloffFactor:i.rolloffFactor,refDistance:i.refDistance,distanceModel:i.distanceModel,playbackRate:i.playbackRate};if(o){var l=function(){o._isReadyToPlay?(h._audioBuffer=o.getAudioBuffer(),h._isReadyToPlay=!0,h.autoplay&&h.play()):window.setTimeout(l,300)};h=new t(a,new ArrayBuffer(0),r,null,c),l()}else h=new t(a,s,r,function(){r._removePendingData(h)},c),r._addPendingData(h);if(i.position){var u=e.Vector3.FromArray(i.position);h.setPosition(u)}if(i.isDirectional&&(h.setDirectionalCone(i.coneInnerAngle||360,i.coneOuterAngle||360,i.coneOuterGain||0),i.localDirectionToMesh)){var f=e.Vector3.FromArray(i.localDirectionToMesh);h.setLocalDirectionToMesh(f)}if(i.connectedMeshId){var d=r.getMeshByID(i.connectedMeshId);d&&h.attachToMesh(d)}return h},t}();e.Sound=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(e,t){this.id=-1,this._isMainTrack=!1,this._isInitialized=!1,this._scene=e,this.soundCollection=new Array,this._options=t,this._isMainTrack||(this._scene.soundTracks.push(this),this.id=this._scene.soundTracks.length-1)}return t.prototype._initializeSoundTrackAudioGraph=function(){e.Engine.audioEngine.canUseWebAudio&&(this._outputAudioNode=e.Engine.audioEngine.audioContext.createGain(),this._outputAudioNode.connect(e.Engine.audioEngine.masterGain),this._options&&(this._options.volume&&(this._outputAudioNode.gain.value=this._options.volume),this._options.mainTrack&&(this._isMainTrack=this._options.mainTrack)),this._isInitialized=!0)},t.prototype.dispose=function(){if(e.Engine.audioEngine.canUseWebAudio){for(this._connectedAnalyser&&this._connectedAnalyser.stopDebugCanvas();this.soundCollection.length;)this.soundCollection[0].dispose();this._outputAudioNode&&this._outputAudioNode.disconnect(),this._outputAudioNode=null}},t.prototype.AddSound=function(t){this._isInitialized||this._initializeSoundTrackAudioGraph(),e.Engine.audioEngine.canUseWebAudio&&t.connectToSoundTrackAudioNode(this._outputAudioNode),t.soundTrackId&&(-1===t.soundTrackId?this._scene.mainSoundTrack.RemoveSound(t):this._scene.soundTracks[t.soundTrackId].RemoveSound(t)),this.soundCollection.push(t),t.soundTrackId=this.id},t.prototype.RemoveSound=function(e){var t=this.soundCollection.indexOf(e);-1!==t&&this.soundCollection.splice(t,1)},t.prototype.setVolume=function(t){e.Engine.audioEngine.canUseWebAudio&&(this._outputAudioNode.gain.value=t)},t.prototype.switchPanningModelToHRTF=function(){if(e.Engine.audioEngine.canUseWebAudio)for(var t=0;t<this.soundCollection.length;t++)this.soundCollection[t].switchPanningModelToHRTF()},t.prototype.switchPanningModelToEqualPower=function(){if(e.Engine.audioEngine.canUseWebAudio)for(var t=0;t<this.soundCollection.length;t++)this.soundCollection[t].switchPanningModelToEqualPower()},t.prototype.connectToAnalyser=function(t){this._connectedAnalyser&&this._connectedAnalyser.stopDebugCanvas(),this._connectedAnalyser=t,e.Engine.audioEngine.canUseWebAudio&&(this._outputAudioNode.disconnect(),this._connectedAnalyser.connectAudioNodes(this._outputAudioNode,e.Engine.audioEngine.masterGain))},t}();e.SoundTrack=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function e(){}return e.TransformCoordinatesToRefSIMD=function(e,t,i){var r=SIMD.float32x4.loadXYZ(e._data,0),n=SIMD.float32x4.load(t.m,0),o=SIMD.float32x4.load(t.m,4),s=SIMD.float32x4.load(t.m,8),a=SIMD.float32x4.load(t.m,12),h=SIMD.float32x4.add(SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(r,0,0,0,0),n),SIMD.float32x4.mul(SIMD.float32x4.swizzle(r,1,1,1,1),o)),SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(r,2,2,2,2),s),a));h=SIMD.float32x4.div(h,SIMD.float32x4.swizzle(h,3,3,3,3)),SIMD.float32x4.storeXYZ(i._data,0,h)},e.TransformCoordinatesFromFloatsToRefSIMD=function(e,t,i,r,n){var o=SIMD.float32x4.splat(e),s=SIMD.float32x4.splat(t),a=SIMD.float32x4.splat(i),h=SIMD.float32x4.load(r.m,0),c=SIMD.float32x4.load(r.m,4),l=SIMD.float32x4.load(r.m,8),u=SIMD.float32x4.load(r.m,12),f=SIMD.float32x4.add(SIMD.float32x4.add(SIMD.float32x4.mul(o,h),SIMD.float32x4.mul(s,c)),SIMD.float32x4.add(SIMD.float32x4.mul(a,l),u));
  22. f=SIMD.float32x4.div(f,SIMD.float32x4.swizzle(f,3,3,3,3)),SIMD.float32x4.storeXYZ(n._data,0,f)},e}();e.SIMDVector3=t;var i=function(){function e(){}return e.prototype.multiplyToArraySIMD=function(e,t,i){void 0===i&&(i=0);var r=this.m,n=e.m,o=SIMD.float32x4.load(n,0),s=SIMD.float32x4.load(n,4),a=SIMD.float32x4.load(n,8),h=SIMD.float32x4.load(n,12),c=SIMD.float32x4.load(r,0);SIMD.float32x4.store(t,i+0,SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(c,0,0,0,0),o),SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(c,1,1,1,1),s),SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(c,2,2,2,2),a),SIMD.float32x4.mul(SIMD.float32x4.swizzle(c,3,3,3,3),h)))));var l=SIMD.float32x4.load(r,4);SIMD.float32x4.store(t,i+4,SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(l,0,0,0,0),o),SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(l,1,1,1,1),s),SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(l,2,2,2,2),a),SIMD.float32x4.mul(SIMD.float32x4.swizzle(l,3,3,3,3),h)))));var u=SIMD.float32x4.load(r,8);SIMD.float32x4.store(t,i+8,SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(u,0,0,0,0),o),SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(u,1,1,1,1),s),SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(u,2,2,2,2),a),SIMD.float32x4.mul(SIMD.float32x4.swizzle(u,3,3,3,3),h)))));var f=SIMD.float32x4.load(r,12);SIMD.float32x4.store(t,i+12,SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(f,0,0,0,0),o),SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(f,1,1,1,1),s),SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(f,2,2,2,2),a),SIMD.float32x4.mul(SIMD.float32x4.swizzle(f,3,3,3,3),h)))))},e.prototype.invertToRefSIMD=function(e){var t,i,r,n,o,s,a,h,c,l,u=this.m,f=e.m,d=SIMD.float32x4.load(u,0),p=SIMD.float32x4.load(u,4),_=SIMD.float32x4.load(u,8),m=SIMD.float32x4.load(u,12);return o=SIMD.float32x4.shuffle(d,p,0,1,4,5),i=SIMD.float32x4.shuffle(_,m,0,1,4,5),t=SIMD.float32x4.shuffle(o,i,0,2,4,6),i=SIMD.float32x4.shuffle(i,o,1,3,5,7),o=SIMD.float32x4.shuffle(d,p,2,3,6,7),n=SIMD.float32x4.shuffle(_,m,2,3,6,7),r=SIMD.float32x4.shuffle(o,n,0,2,4,6),n=SIMD.float32x4.shuffle(n,o,1,3,5,7),o=SIMD.float32x4.mul(r,n),o=SIMD.float32x4.swizzle(o,1,0,3,2),s=SIMD.float32x4.mul(i,o),a=SIMD.float32x4.mul(t,o),o=SIMD.float32x4.swizzle(o,2,3,0,1),s=SIMD.float32x4.sub(SIMD.float32x4.mul(i,o),s),a=SIMD.float32x4.sub(SIMD.float32x4.mul(t,o),a),a=SIMD.float32x4.swizzle(a,2,3,0,1),o=SIMD.float32x4.mul(i,r),o=SIMD.float32x4.swizzle(o,1,0,3,2),s=SIMD.float32x4.add(SIMD.float32x4.mul(n,o),s),c=SIMD.float32x4.mul(t,o),o=SIMD.float32x4.swizzle(o,2,3,0,1),s=SIMD.float32x4.sub(s,SIMD.float32x4.mul(n,o)),c=SIMD.float32x4.sub(SIMD.float32x4.mul(t,o),c),c=SIMD.float32x4.swizzle(c,2,3,0,1),o=SIMD.float32x4.mul(SIMD.float32x4.swizzle(i,2,3,0,1),n),o=SIMD.float32x4.swizzle(o,1,0,3,2),r=SIMD.float32x4.swizzle(r,2,3,0,1),s=SIMD.float32x4.add(SIMD.float32x4.mul(r,o),s),h=SIMD.float32x4.mul(t,o),o=SIMD.float32x4.swizzle(o,2,3,0,1),s=SIMD.float32x4.sub(s,SIMD.float32x4.mul(r,o)),h=SIMD.float32x4.sub(SIMD.float32x4.mul(t,o),h),h=SIMD.float32x4.swizzle(h,2,3,0,1),o=SIMD.float32x4.mul(t,i),o=SIMD.float32x4.swizzle(o,1,0,3,2),h=SIMD.float32x4.add(SIMD.float32x4.mul(n,o),h),c=SIMD.float32x4.sub(SIMD.float32x4.mul(r,o),c),o=SIMD.float32x4.swizzle(o,2,3,0,1),h=SIMD.float32x4.sub(SIMD.float32x4.mul(n,o),h),c=SIMD.float32x4.sub(c,SIMD.float32x4.mul(r,o)),o=SIMD.float32x4.mul(t,n),o=SIMD.float32x4.swizzle(o,1,0,3,2),a=SIMD.float32x4.sub(a,SIMD.float32x4.mul(r,o)),h=SIMD.float32x4.add(SIMD.float32x4.mul(i,o),h),o=SIMD.float32x4.swizzle(o,2,3,0,1),a=SIMD.float32x4.add(SIMD.float32x4.mul(r,o),a),h=SIMD.float32x4.sub(h,SIMD.float32x4.mul(i,o)),o=SIMD.float32x4.mul(t,r),o=SIMD.float32x4.swizzle(o,1,0,3,2),a=SIMD.float32x4.add(SIMD.float32x4.mul(n,o),a),c=SIMD.float32x4.sub(c,SIMD.float32x4.mul(i,o)),o=SIMD.float32x4.swizzle(o,2,3,0,1),a=SIMD.float32x4.sub(a,SIMD.float32x4.mul(n,o)),c=SIMD.float32x4.add(SIMD.float32x4.mul(i,o),c),l=SIMD.float32x4.mul(t,s),l=SIMD.float32x4.add(SIMD.float32x4.swizzle(l,2,3,0,1),l),l=SIMD.float32x4.add(SIMD.float32x4.swizzle(l,1,0,3,2),l),o=SIMD.float32x4.reciprocalApproximation(l),l=SIMD.float32x4.sub(SIMD.float32x4.add(o,o),SIMD.float32x4.mul(l,SIMD.float32x4.mul(o,o))),l=SIMD.float32x4.swizzle(l,0,0,0,0),s=SIMD.float32x4.mul(l,s),a=SIMD.float32x4.mul(l,a),h=SIMD.float32x4.mul(l,h),c=SIMD.float32x4.mul(l,c),SIMD.float32x4.store(f,0,s),SIMD.float32x4.store(f,4,a),SIMD.float32x4.store(f,8,h),SIMD.float32x4.store(f,12,c),this},e.LookAtLHToRefSIMD=function(e,t,i,r){var n=r.m,o=SIMD.float32x4(t.x,t.y,t.z,0),s=SIMD.float32x4(e.x,e.y,e.z,0),a=SIMD.float32x4(i.x,i.y,i.z,0),h=SIMD.float32x4.sub(o,s),c=SIMD.float32x4.mul(h,h);c=SIMD.float32x4.add(c,SIMD.float32x4.add(SIMD.float32x4.swizzle(c,1,2,0,3),SIMD.float32x4.swizzle(c,2,0,1,3))),h=SIMD.float32x4.mul(h,SIMD.float32x4.reciprocalSqrtApproximation(c)),c=SIMD.float32x4.mul(a,a),c=SIMD.float32x4.add(c,SIMD.float32x4.add(SIMD.float32x4.swizzle(c,1,2,0,3),SIMD.float32x4.swizzle(c,2,0,1,3))),a=SIMD.float32x4.mul(a,SIMD.float32x4.reciprocalSqrtApproximation(c));var l=SIMD.float32x4.sub(SIMD.float32x4.mul(SIMD.float32x4.swizzle(h,1,2,0,3),SIMD.float32x4.swizzle(a,2,0,1,3)),SIMD.float32x4.mul(SIMD.float32x4.swizzle(h,2,0,1,3),SIMD.float32x4.swizzle(a,1,2,0,3)));c=SIMD.float32x4.mul(l,l),c=SIMD.float32x4.add(c,SIMD.float32x4.add(SIMD.float32x4.swizzle(c,1,2,0,3),SIMD.float32x4.swizzle(c,2,0,1,3))),l=SIMD.float32x4.mul(l,SIMD.float32x4.reciprocalSqrtApproximation(c));var u=SIMD.float32x4.sub(SIMD.float32x4.mul(SIMD.float32x4.swizzle(l,1,2,0,3),SIMD.float32x4.swizzle(h,2,0,1,3)),SIMD.float32x4.mul(SIMD.float32x4.swizzle(l,2,0,1,3),SIMD.float32x4.swizzle(h,1,2,0,3)));c=SIMD.float32x4.mul(l,l),c=SIMD.float32x4.add(c,SIMD.float32x4.add(SIMD.float32x4.swizzle(c,1,2,0,3),SIMD.float32x4.swizzle(c,2,0,1,3))),l=SIMD.float32x4.mul(l,SIMD.float32x4.reciprocalSqrtApproximation(c));var f=SIMD.float32x4.splat(0);l=SIMD.float32x4.neg(l);var d=SIMD.float32x4.shuffle(l,u,0,1,4,5),p=SIMD.float32x4.shuffle(h,f,0,1,4,5),_=SIMD.float32x4.shuffle(d,p,0,2,4,6),m=SIMD.float32x4.shuffle(d,p,1,3,5,7);d=SIMD.float32x4.shuffle(l,u,2,3,6,7),p=SIMD.float32x4.shuffle(h,f,2,3,6,7);var g=SIMD.float32x4.shuffle(d,p,0,2,4,6),v=SIMD.float32x4(0,0,0,1),y=SIMD.float32x4(1,0,0,0),x=SIMD.float32x4(0,1,0,0),b=SIMD.float32x4(0,0,1,0),P=SIMD.float32x4.neg(s);P=SIMD.float32x4.withW(P,1),SIMD.float32x4.store(n,0,SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(y,0,0,0,0),_),SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(y,1,1,1,1),m),SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(y,2,2,2,2),g),SIMD.float32x4.mul(SIMD.float32x4.swizzle(y,3,3,3,3),v))))),SIMD.float32x4.store(n,4,SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(x,0,0,0,0),_),SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(x,1,1,1,1),m),SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(x,2,2,2,2),g),SIMD.float32x4.mul(SIMD.float32x4.swizzle(x,3,3,3,3),v))))),SIMD.float32x4.store(n,8,SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(b,0,0,0,0),_),SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(b,1,1,1,1),m),SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(b,2,2,2,2),g),SIMD.float32x4.mul(SIMD.float32x4.swizzle(b,3,3,3,3),v))))),SIMD.float32x4.store(n,12,SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(P,0,0,0,0),_),SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(P,1,1,1,1),m),SIMD.float32x4.add(SIMD.float32x4.mul(SIMD.float32x4.swizzle(P,2,2,2,2),g),SIMD.float32x4.mul(SIMD.float32x4.swizzle(P,3,3,3,3),v)))))},e}();e.SIMDMatrix=i;var r=e.Matrix.prototype.multiplyToArray,n=e.Matrix.prototype.invertToRef,o=e.Matrix.LookAtLHToRef,s=e.Vector3.TransformCoordinatesToRef,a=e.Vector3.TransformCoordinatesFromFloatsToRef,h=function(){function h(){}return Object.defineProperty(h,"IsEnabled",{get:function(){return h._isEnabled},enumerable:!0,configurable:!0}),h.DisableSIMD=function(){e.Matrix.prototype.multiplyToArray=r,e.Matrix.prototype.invertToRef=n,e.Matrix.LookAtLHToRef=o,e.Vector3.TransformCoordinatesToRef=s,e.Vector3.TransformCoordinatesFromFloatsToRef=a,h._isEnabled=!1},h.EnableSIMD=function(){void 0!==window.SIMD&&(e.Matrix.prototype.multiplyToArray=i.prototype.multiplyToArraySIMD,e.Matrix.prototype.invertToRef=i.prototype.invertToRefSIMD,e.Matrix.LookAtLHToRef=i.LookAtLHToRefSIMD,e.Vector3.TransformCoordinatesToRef=t.TransformCoordinatesToRefSIMD,e.Vector3.TransformCoordinatesFromFloatsToRef=t.TransformCoordinatesFromFloatsToRefSIMD,Object.defineProperty(e.Vector3.prototype,"x",{get:function(){return this._data[0]},set:function(e){this._data||(this._data=new Float32Array(3)),this._data[0]=e}}),Object.defineProperty(e.Vector3.prototype,"y",{get:function(){return this._data[1]},set:function(e){this._data[1]=e}}),Object.defineProperty(e.Vector3.prototype,"z",{get:function(){return this._data[2]},set:function(e){this._data[2]=e}}),h._isEnabled=!0)},h._isEnabled=!1,h}();e.SIMDHelper=h}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(e,t,i,r){this._pos=i,this._size=r,this._root=e,this._parent=t}return Object.defineProperty(t.prototype,"pos",{get:function(){return this._pos},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"contentSize",{get:function(){return this._contentSize},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"UVs",{get:function(){var t=this._root._size.width,i=this._root._size.height,r=new e.Vector2(this._pos.x/t,this._pos.y/i),n=new e.Vector2((this._pos.x+this._contentSize.width-1)/t,(this._pos.y+this._contentSize.height-1)/i),o=new Array;return o.push(r),o.push(new e.Vector2(n.x,r.y)),o.push(n),o.push(new e.Vector2(r.x,n.y)),o},enumerable:!0,configurable:!0}),t.prototype.freeContent=function(){this.contentSize&&(this._contentSize=null,this.attemptDefrag())},Object.defineProperty(t.prototype,"isUsed",{get:function(){return null!=this._contentSize||null!=this._leftNode},enumerable:!0,configurable:!0}),t.prototype.findAndSplitNode=function(e){var t=this.findNode(e);return t?(t.splitNode(e),t):null},t.prototype.findNode=function(e){var t=null;return this.isUsed?(this._leftNode&&(t=this._leftNode.findNode(e)),!t&&this._rightNode&&(t=this._rightNode.findNode(e)),!t&&this._bottomNode&&(t=this._bottomNode.findNode(e))):this._initialSize&&e.width<=this._initialSize.width&&e.height<=this._initialSize.height?t=this:e.width<=this._size.width&&e.height<=this._size.height&&(t=this),t},t.prototype.splitNode=function(i){return!this._contentSize&&this._initialSize?(this._leftNode=new t(this._root,this,new e.Vector2(this._pos.x,this._pos.y),new e.Size(this._initialSize.width,this._initialSize.height)),this._leftNode.splitNode(i)):(this._contentSize=i.clone(),this._initialSize=i.clone(),i.width!==this._size.width&&(this._rightNode=new t(this._root,this,new e.Vector2(this._pos.x+i.width,this._pos.y),new e.Size(this._size.width-i.width,i.height))),i.height!==this._size.height&&(this._bottomNode=new t(this._root,this,new e.Vector2(this._pos.x,this._pos.y+i.height),new e.Size(this._size.width,this._size.height-i.height))),this)},t.prototype.attemptDefrag=function(){!this.isUsed&&this.isRecursiveFree&&(this.clearNode(),this._parent&&this._parent.attemptDefrag())},t.prototype.clearNode=function(){this._initialSize=null,this._rightNode=null,this._bottomNode=null},Object.defineProperty(t.prototype,"isRecursiveFree",{get:function(){return!this.contentSize&&(!this._leftNode||this._leftNode.isRecursiveFree)&&(!this._rightNode||this._rightNode.isRecursiveFree)&&(!this._bottomNode||this._bottomNode.isRecursiveFree)},enumerable:!0,configurable:!0}),t.prototype.evalFreeSize=function(e){var t=0;return this.isUsed||(t=this._initialSize?this._initialSize.surface:this._size.surface),this._rightNode&&(t+=this._rightNode.evalFreeSize(0)),this._bottomNode&&(t+=this._bottomNode.evalFreeSize(0)),t+e},t}();e.PackedRect=t;var i=function(t){function i(i){t.call(this,null,null,e.Vector2.Zero(),i),this._root=this}return __extends(i,t),i.prototype.addRect=function(e){var t=this.findAndSplitNode(e);return t},Object.defineProperty(i.prototype,"freeSpace",{get:function(){var e=0;return e=this.evalFreeSize(e),e/(this._size.width*this._size.height)},enumerable:!0,configurable:!0}),i}(t);e.RectPackingMap=i}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function e(){}return e}();e.DynamicFloatArrayElementInfo=t;var i=function(){function e(e,i){this.compareValueOffset=null,this.sortingAscending=!0,this._stride=e,this.buffer=new Float32Array(e*i),this._lastUsed=0,this._firstFree=0,this._allEntries=new Array(i),this._freeEntries=new Array(i);for(var r=0;i>r;r++){var n=new t;n.offset=r*e,this._allEntries[r]=n,this._freeEntries[i-r-1]=n}}return e.prototype.allocElement=function(){0===this._freeEntries.length&&this._growBuffer();var e=this._freeEntries.pop();return this._lastUsed=Math.max(e.offset,this._lastUsed),e.offset===this._firstFree&&(this._freeEntries.length>0?this._firstFree=this._freeEntries[this._freeEntries.length-1].offset:this._firstFree+=this._stride),e},e.prototype.freeElement=function(e){this._firstFree=Math.min(e.offset,this._firstFree),this._freeEntries.push(e)},e.prototype.pack=function(){if(0===this._freeEntries.length)return this.buffer;if(this._lastUsed<this._firstFree){var e=this.buffer.subarray(0,this._lastUsed+this._stride);return e}var i=this._stride,r=new t;r.offset=this.totalElementCount*i,this._freeEntries.push(r);for(var n=this._freeEntries.sort(function(e,t){return e.offset-t.offset}),o=this._allEntries.sort(function(e,t){return e.offset-t.offset}),s=n[0].offset,a=1,h=(this.usedElementCount+1)*i,c=n[0].offset,l=1;l<n.length&&!(s>=h);l++){var u=n[l],f=u.offset,d=f-c;if(d!==i){for(var p=d/i-1,_=f-i,m=Math.min(a,p),g=0;m>g;g++){var v=s/i,y=_/i,x=o[y];this._moveElement(x,s);var b=o[v];b.offset=_,o[v]=x,o[y]=b,_-=i,s+=i}p>=a?(s=_+i,a=1+m):a=(f-s)/i+1,c=f}else++a,c=f}var P=this.buffer.subarray(0,s);return this._lastUsed=s-i,this._firstFree=s,n.pop(),this._freeEntries=n.sort(function(e,t){return t.offset-e.offset}),this._allEntries=o,P},e.prototype._moveElement=function(e,t){for(var i=0;i<this._stride;i++)this.buffer[t+i]=this.buffer[e.offset+i];e.offset=t},e.prototype._growBuffer=function(){var e=Math.floor(1.5*this.totalElementCount),i=new Float32Array(e*this._stride);i.set(this.buffer);for(var r=this.totalElementCount,n=e-this.totalElementCount,o=0;n>o;o++){var s=new t;s.offset=(r+o)*this.stride,this._allEntries.push(s),this._freeEntries[n-o-1]=s}this._firstFree=r*this.stride,this.buffer=i},Object.defineProperty(e.prototype,"totalElementCount",{get:function(){return this._allEntries.length},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"freeElementCount",{get:function(){return this._freeEntries.length},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"usedElementCount",{get:function(){return this._allEntries.length-this._freeEntries.length},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"stride",{get:function(){return this._stride},enumerable:!0,configurable:!0}),e.prototype.sort=function(){var e=this;if(!this.compareValueOffset)throw new Error("The DynamicFloatArray.sort() method needs a valid 'compareValueOffset' property");var t=this.usedElementCount;if(!this._sortTable||this._sortTable.length<t){var i=Math.min(this.totalElementCount,2*t);this._sortTable=new Array(i),this._sortedTable=new Array(i)}this.pack();for(var n=0,o=this.stride,s=0;t>s;s++,n+=o){var a=this._sortTable[s];a||(a=new r,this._sortTable[s]=a),a.compareData=this.buffer[n+this.compareValueOffset],a.offset=n,a.swapedOffset=null,this._sortedTable[s]=a}this.sortingAscending?this._sortedTable.sort(function(e,t){return e.compareData-t.compareData}):this._sortedTable.sort(function(e,t){return t.compareData-e.compareData});for(var h=function(t,i){for(var r=0;o>r;r++){var n=e.buffer[i+r];e.buffer[i+r]=e.buffer[t+r],e.buffer[t+r]=n}},s=0;t>s;s++){var c=this._sortedTable[s],l=this._sortTable[s],u=c.offset;if(c.swapedOffset){for(var f=c;f.swapedOffset;)f=this._sortTable[f.swapedOffset/o];u=f.offset}l.swapedOffset=u,u!==l.offset&&h(u,l.offset),this._allEntries[c.offset/o].offset=l.offset}return this._allEntries.sort(function(e,t){return e.offset-t.offset}),!0},e}();e.DynamicFloatArray=i;var r=function(){function e(){this.compareData=this.offset=this.swapedOffset=null}return e}()}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function e(){}return e}();e.CharInfo=t;var i=function(i){function r(t,r,n,o,s){void 0===o&&(o=200),void 0===s&&(s=e.Texture.TRILINEAR_SAMPLINGMODE),i.call(this,null,n,!0,!1,s),this._charInfos={},this._curCharCount=0,this._lastUpdateCharCount=-1,this._usedCounter=1,this.name=t,this.wrapU=e.Texture.CLAMP_ADDRESSMODE,this.wrapV=e.Texture.CLAMP_ADDRESSMODE,this._canvas=document.createElement("canvas"),this._context=this._canvas.getContext("2d"),this._context.font=r,this._context.fillStyle="white";var a=this.getFontHeight(r);this._lineHeight=a.height,this._offset=a.offset-1;var h=this._context.measureText("W").width;this._spaceWidth=this._context.measureText(" ").width;var c=this._lineHeight*h*o,l=Math.sqrt(c),u=Math.pow(2,Math.ceil(Math.log(l)/Math.log(2)));this._texture=n.getEngine().createDynamicTexture(u,u,!1,s);var f=this.getSize();this._canvas=document.createElement("canvas"),this._canvas.width=f.width,this._canvas.height=f.height,this._context=this._canvas.getContext("2d"),this._context.textBaseline="top",this._context.font=r,this._context.fillStyle="white",this._context.imageSmoothingEnabled=!1,this._currentFreePosition=e.Vector2.Zero();for(var d=32;127>d;d++){var p=String.fromCharCode(d);this.getChar(p)}this.update()}return __extends(r,i),Object.defineProperty(r.prototype,"spaceWidth",{get:function(){return this._spaceWidth},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"lineHeight",{get:function(){return this._lineHeight},enumerable:!0,configurable:!0}),r.GetCachedFontTexture=function(t,i){var n=t;n.__fontTextureCache__||(n.__fontTextureCache__=new e.StringDictionary);var o=n.__fontTextureCache__,s=i.toLocaleLowerCase(),a=o.get(s);return a?(++a._usedCounter,a):(a=new r(null,s,t,200,e.Texture.NEAREST_SAMPLINGMODE),o.add(s,a),a)},r.ReleaseCachedFontTexture=function(e,t){var i=e,r=i.__fontTextureCache__;if(r){var n=t.toLocaleLowerCase(),o=r.get(n);0===--o._usedCounter&&(r.remove(n),o.dispose())}},r.prototype.getChar=function(i){if(1!==i.length)return null;var r=this._charInfos[i];if(r)return r;r=new t;var n=this._context.measureText(i),o=this.getSize(),s=2,a=2,h=n.width;return this._currentFreePosition.x+h+s>o.width&&(this._currentFreePosition.x=0,this._currentFreePosition.y+=this._lineHeight+a,this._currentFreePosition.y>o.height)?this.getChar("!"):(this._context.fillText(i,this._currentFreePosition.x-.5,this._currentFreePosition.y-this._offset-.5),r.topLeftUV=new e.Vector2(this._currentFreePosition.x/o.width,this._currentFreePosition.y/o.height),r.bottomRightUV=new e.Vector2(r.topLeftUV.x+h/o.width,r.topLeftUV.y+(this._lineHeight+2)/o.height),r.charWidth=h,this._charInfos[i]=r,this._curCharCount++,this._currentFreePosition.x+=h+s,r)},r.prototype.measureText=function(t,i){void 0===i&&(i=4);for(var r=0,n=0,o=1,s=0,a=0;a<t.length;a++){var h=t[a];if("\n"!==h)if(" "!==h)" ">h||(n+=this.getChar(h).charWidth,++s);else{var c=s+i;c-=c%i,n+=(c-s)*this.spaceWidth,s=c}else r=Math.max(r,n),s=0,n=0,++o}return r=Math.max(r,n),new e.Size(r,o*this._lineHeight)},r.prototype.getFontHeight=function(e){var t=document.createElement("canvas"),i=t.getContext("2d");i.fillRect(0,0,t.width,t.height),i.textBaseline="top",i.fillStyle="white",i.font=e,i.fillText("jH|",0,0);for(var r=i.getImageData(0,0,t.width,t.height).data,n=-1,o=-1,s=0;s<t.height;s++)for(var a=0;a<t.width;a++){var h=4*(s*t.width+a);{if(0!==r[h]){-1===n&&(n=s);break}if(a===t.width-1&&-1!==n){o=s,s=t.height;break}}}return{height:o-n,offset:n-1}},Object.defineProperty(r.prototype,"canRescale",{get:function(){return!1},enumerable:!0,configurable:!0}),r.prototype.getContext=function(){return this._context},r.prototype.update=function(){this._lastUpdateCharCount<this._curCharCount&&(this.getScene().getEngine().updateDynamicTexture(this._texture,this._canvas,!1,!0),this._lastUpdateCharCount=this._curCharCount)},r.prototype.clone=function(){return null},r}(e.Texture);e.FontTexture=i}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(t){function i(i,r,n,o){void 0===o&&(o=e.Texture.TRILINEAR_SAMPLINGMODE),t.call(this,null,r,!0,!1,o),this.name=i,this._size=n,this.wrapU=e.Texture.CLAMP_ADDRESSMODE,this.wrapV=e.Texture.CLAMP_ADDRESSMODE,this._rectPackingMap=new e.RectPackingMap(new e.Size(n.width,n.height)),this._texture=r.getEngine().createRenderTargetTexture(n,{generateMipMaps:!this.noMipmap,type:e.Engine.TEXTURETYPE_UNSIGNED_INT})}return __extends(i,t),i.prototype.allocateRect=function(e){return this._rectPackingMap.addRect(e)},i.prototype.freeRect=function(e){e&&e.freeContent()},Object.defineProperty(i.prototype,"freeSpace",{get:function(){return this._rectPackingMap.freeSpace},enumerable:!0,configurable:!0}),i.prototype.bindTextureForRect=function(e,t){return this.bindTextureForPosSize(e.pos,e.contentSize,t)},i.prototype.bindTextureForPosSize=function(t,i,r){var n=this.getScene().getEngine();n.bindFramebuffer(this._texture),this._replacedViewport=n.setDirectViewport(t.x,t.y,i.width,i.height),r&&n.scissorClear(t.x,t.y,i.width,i.height,new e.Color4(0,0,0,0))},i.prototype.unbindTexture=function(t){t&&e.Tools.DumpFramebuffer(this._size.width,this._size.height,this.getScene().getEngine());var i=this.getScene().getEngine();this._replacedViewport&&(i.setViewport(this._replacedViewport),this._replacedViewport=null),i.unBindFramebuffer(this._texture)},Object.defineProperty(i.prototype,"canRescale",{get:function(){return!1},enumerable:!0,configurable:!0}),i.prototype.clone=function(){return null},i}(e.Texture);e.MapTexture=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(){this.radius=0,this.center=e.Vector2.Zero(),this.extent=e.Vector2.Zero()}return t.CreateFromSize=function(e){var i=new t;return t.CreateFromSizeToRef(e,i),i},t.CreateFromRadius=function(e){var i=new t;return t.CreateFromRadiusToRef(e,i),i},t.CreateFromPoints=function(e){var i=new t;return t.CreateFromPointsToRef(e,i),i},t.CreateFromSizeToRef=function(t,i){t||(t=e.Size.Zero()),i.center.x=+t.width/2,i.center.y=+t.height/2,i.extent.x=i.center.x,i.extent.y=i.center.y,i.radius=i.extent.length()},t.CreateFromRadiusToRef=function(e,t){t.center.x=t.center.y=0;var i=+e;t.extent.x=i,t.extent.y=i,t.radius=i},t.CreateFromPointsToRef=function(e,i){for(var r=Number.MAX_VALUE,n=Number.MAX_VALUE,o=Number.MIN_VALUE,s=Number.MIN_VALUE,a=0;a<e.length;a++){var h=e[a];r=Math.min(h.x,r),o=Math.max(h.x,o),n=Math.min(h.y,n),s=Math.max(h.y,s)}t.CreateFromMinMaxToRef(r,o,n,s,i)},t.CreateFromMinMaxToRef=function(t,i,r,n,o){var s=i-t,a=n-r;o.center=new e.Vector2(t+s/2,r+a/2),o.extent=new e.Vector2(i-o.center.x,n-o.center.y),o.radius=o.extent.length()},t.prototype.clone=function(){var e=new t;return e.center=this.center.clone(),e.radius=this.radius,e.extent=this.extent.clone(),e},t.prototype.max=function(){var t=e.Vector2.Zero();return this.maxToRef(t),t},t.prototype.maxToRef=function(e){e.x=this.center.x+this.extent.x,e.y=this.center.y+this.extent.y},t.prototype.transform=function(e){var i=new t;return this.transformToRef(e,i),i},t.prototype.union=function(e){var i=new t;return this.unionToRef(e,i),i},t.prototype.transformToRef=function(i,r){var n=t._transform;n[0].x=this.center.x+this.extent.x,n[0].y=this.center.y+this.extent.y,n[1].x=this.center.x+this.extent.x,n[1].y=this.center.y-this.extent.y,n[2].x=this.center.x-this.extent.x,n[2].y=this.center.y-this.extent.y,n[3].x=this.center.x-this.extent.x,n[3].y=this.center.y+this.extent.y;for(var o=0;4>o;o++)e.Vector2.TransformToRef(n[o],i,n[o]);t.CreateFromPointsToRef(n,r)},t.prototype.unionToRef=function(e,i){var r=Math.max(this.center.x+this.extent.x,e.center.x+e.extent.x),n=Math.max(this.center.y+this.extent.y,e.center.y+e.extent.y),o=Math.min(this.center.x-this.extent.x,e.center.x-e.extent.x),s=Math.min(this.center.y-this.extent.y,e.center.y-e.extent.y);t.CreateFromMinMaxToRef(o,r,s,n,i)},t.prototype.doesIntersect=function(e){var t=e.subtract(this.center);return t.lengthSquared()<=this.radius*this.radius?Math.abs(t.x)<=this.extent.x&&Math.abs(t.y)<=this.extent.y:!1},t._transform=new Array(e.Vector2.Zero(),e.Vector2.Zero(),e.Vector2.Zero(),e.Vector2.Zero()),t}();e.BoundingInfo2D=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function e(){}return e.prototype.isLocked=function(){return this._isLocked},e.prototype.lock=function(){return this._isLocked?!0:(this.onLock(),this._isLocked=!0,!1)},e.prototype.onLock=function(){},e}();e.LockableBase=t;var i=function(t){function i(e,i){void 0===i&&(i=!1),t.call(this),this._color=e,i&&this.lock()}return __extends(i,t),i.prototype.isTransparent=function(){return this._color&&this._color.a<1},Object.defineProperty(i.prototype,"color",{get:function(){return this._color},set:function(e){this.isLocked()||(this._color=e)},enumerable:!0,configurable:!0}),i.prototype.toString=function(){return this._color.toHexString()},i=__decorate([e.className("SolidColorBrush2D")],i)}(t);e.SolidColorBrush2D=i;var r=function(t){function i(i,r,n,o,s,a){void 0===n&&(n=e.Vector2.Zero()),void 0===o&&(o=0),void 0===s&&(s=1),void 0===a&&(a=!1),t.call(this),this._color1=i,this._color2=r,this._translation=n,this._rotation=o,this._scale=s,a&&this.lock()}return __extends(i,t),i.prototype.isTransparent=function(){return this._color1&&this._color1.a<1||this._color2&&this._color2.a<1},Object.defineProperty(i.prototype,"color1",{get:function(){return this._color1},set:function(e){this.isLocked()||(this._color1=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"color2",{get:function(){return this._color2},set:function(e){this.isLocked()||(this._color2=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"translation",{get:function(){return this._translation},set:function(e){this.isLocked()||(this._translation=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"rotation",{get:function(){return this._rotation},set:function(e){this.isLocked()||(this._rotation=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"scale",{get:function(){return this._scale},set:function(e){this.isLocked()||(this._scale=e)},enumerable:!0,configurable:!0}),i.prototype.toString=function(){return"C1:"+this._color1+";C2:"+this._color2+";T:"+this._translation.toString()+";R:"+this._rotation+";S:"+this._scale+";"},i.BuildKey=function(e,t,i,r,n){return"C1:"+e+";C2:"+t+";T:"+i.toString()+";R:"+r+";S:"+n+";"},i=__decorate([e.className("GradientColorBrush2D")],i)}(t);e.GradientColorBrush2D=r}(BABYLON||(BABYLON={}));var BABYLON;!function(e){function t(e,t,i,r){return void 0===i&&(i=!1),void 0===r&&(r=!1),h._hookProperty(e,t,i,r,o.PROPKIND_MODEL)}function i(e,t,i,r){return void 0===i&&(i=!1),void 0===r&&(r=!1),h._hookProperty(e,t,i,r,o.PROPKIND_INSTANCE)}function r(e,t,i,r){return void 0===i&&(i=!1),void 0===r&&(r=!1),h._hookProperty(e,t,i,r,o.PROPKIND_DYNAMIC)}var n=function(){function e(){}return e}();e.Prim2DClassInfo=n;var o=function(){function e(){}return e.PROPKIND_MODEL=1,e.PROPKIND_INSTANCE=2,e.PROPKIND_DYNAMIC=3,e}();e.Prim2DPropInfo=o;var s=function(){function e(){}return e}();e.PropertyChangedInfo=s;var a=function(){function t(t,i,r){this._baseClass=t,this._type=i,this._subClasses=new Array,this._levelContent=new e.StringDictionary,this._classContentFactory=r}return Object.defineProperty(t.prototype,"classContent",{get:function(){return this._classContent||(this._classContent=this._classContentFactory(this._baseClass?this._baseClass.classContent:null)),this._classContent},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"type",{get:function(){return this._type},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"levelContent",{get:function(){return this._levelContent},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"fullContent",{get:function(){if(!this._fullContent){for(var t=new e.StringDictionary,i=this;i;)i.levelContent.forEach(function(e,i){return t.add(e,i)}),i=i._baseClass;this._fullContent=t}return this._fullContent},enumerable:!0,configurable:!0}),t.prototype.getLevelOf=function(e){if(e===this._type)return this;var t=Object.getPrototypeOf(e),i=this.getOrAddType(Object.getPrototypeOf(t),t);return i||this.getLevelOf(t),this.getOrAddType(t,e)},t.prototype.getOrAddType=function(e,i){if(e===this._type){for(var r=0,n=this._subClasses;r<n.length;r++){var o=n[r];if(o.type===i)return o.node}var s=new t(this,i,this._classContentFactory),a={type:i,node:s};return this._subClasses.push(a),a.node}for(var h=0,c=this._subClasses;h<c.length;h++){var o=c[h],a=o.node.getOrAddType(e,i);if(a)return a}return null},t.get=function(e){var t=e.__classTreeInfo;return t?t.getLevelOf(e):null},t.getOrRegister=function(e,i){var r=e.__classTreeInfo;return r||(r=new t(null,e,i),e.__classTreeInfo=r),r},t}();e.ClassTreeInfo=a;var h=function(){function t(){this._flags=0,this._modelKey=null,this._instanceDirtyFlags=0,this._levelBoundingInfo=new e.BoundingInfo2D,this.animations=new Array}return Object.defineProperty(t.prototype,"isDisposed",{get:function(){return this._isFlagSet(t.flagIsDisposed)},enumerable:!0,configurable:!0}),t.prototype.dispose=function(){return this.isDisposed?!1:(this.animations.splice(0),this._setFlags(t.flagIsDisposed),!0)},t.prototype.getAnimatables=function(){return new Array},Object.defineProperty(t.prototype,"modelKey",{get:function(){var i=this;if(!this._isFlagSet(t.flagModelDirty)&&this._modelKey)return this._modelKey;var r="Class:"+e.Tools.getClassName(this)+";",n=this.propDic;return n.forEach(function(t,n){if(n.kind===o.PROPKIND_MODEL){var s=i[n.name];if(s&&s.constructor===Array){var a=s[0];s=a?e.Tools.hashCodeFromStream(e.Tools.arrayOrStringFeeder(s)):0}r+=n.name+":"+(null!=s?n.typeLevelCompare?e.Tools.getClassName(s):s.toString():"[null]")+";"}}),this._clearFlags(t.flagModelDirty),this._modelKey=r,r},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isDirty",{get:function(){return 0!==this._instanceDirtyFlags||this._areSomeFlagsSet(t.flagModelDirty|t.flagPositioningDirty|t.flagLayoutDirty)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"propDic",{get:function(){if(!this._propInfo){var e=a.get(Object.getPrototypeOf(this));if(!e)throw new Error("Can't access the propDic member in class definition, is this class SmartPropertyPrim based?");this._propInfo=e.fullContent}return this._propInfo},enumerable:!0,configurable:!0}),t._createPropInfo=function(e,t,i,r,s,h){var c=a.getOrRegister(e,function(){return new n}),l=c.getLevelOf(e),u=l.levelContent.get(i.toString());if(u)throw new Error("The ID "+i+" is already taken by another property declaration named: "+u.name);return u=new o,u.id=i,u.flagId=Math.pow(2,i),u.kind=h,u.name=t,u.dirtyBoundingInfo=r,u.typeLevelCompare=s,l.levelContent.add(t,u),u},t._checkUnchanged=function(e,t){if(null===e&&null===t||void 0===e&&void 0===t)return!0;if(null!=e&&null!=t)if("function"==typeof e.equals){if(e.equals(t))return!0}else if(e===t)return!0;return!1},t.prototype.markAsDirty=function(e){if(!this.isDisposed){var t=e.indexOf(".");-1!==t&&(e=e.substr(0,t));var i=this.propDic.get(e);if(i){var r=this[e];this._handlePropChanged(void 0,r,e,i,i.typeLevelCompare)}}},t.prototype._boundingBoxDirty=function(){if(this._setFlags(t.flagLevelBoundingInfoDirty),this instanceof e.Prim2DBase)for(var i=this;i&&(i._boundingSize=null,i._setFlags(t.flagBoundingInfoDirty),i.isSizeAuto&&i.onPrimitivePropertyDirty(e.Prim2DBase.sizeProperty.flagId),!(i instanceof e.Group2D&&i.isRenderableGroup));)i=i.parent;
  23. },t.prototype._handlePropChanged=function(i,r,n,s,a){s.dirtyBoundingInfo&&this._boundingBoxDirty();var h=t.propChangedInfo;h.oldValue=i,h.newValue=r,h.propertyName=n;var c=s.flagId;if(this.propertyChanged.notifyObservers(h,c),this instanceof e.Group2D&&this.handleGroupChanged(s),this instanceof e.Prim2DBase){var l=this._parent;null!=l&&l.layoutEngine&&0!==(l.layoutEngine.layoutDirtyOnPropertyChangedMask&s.flagId)&&l._setLayoutDirty()}var u=!1;if(a&&null!=i&&null!=r){var f=i.__proto__,d=r.__proto__;u=f===d}u||s.kind!==o.PROPKIND_MODEL?(u||s.kind===o.PROPKIND_INSTANCE||s.kind===o.PROPKIND_DYNAMIC)&&this.onPrimitivePropertyDirty(c):this.onPrimitivePropertyDirty(t.flagModelDirty)},t.prototype.onPrimitivePropertyDirty=function(e){this.isDirty||this.onPrimBecomesDirty(),this._instanceDirtyFlags|=e},t.prototype.handleGroupChanged=function(e){},t.prototype.checkPropertiesDirty=function(e){return 0!==(this._instanceDirtyFlags&e)},t.prototype.clearPropertiesDirty=function(e){return this._instanceDirtyFlags&=~e,this._instanceDirtyFlags},t.prototype._resetPropertiesDirty=function(){this._instanceDirtyFlags=0},Object.defineProperty(t.prototype,"levelBoundingInfo",{get:function(){return this._isFlagSet(t.flagLevelBoundingInfoDirty)&&(this.updateLevelBoundingInfo(),this._clearFlags(t.flagLevelBoundingInfoDirty)),this._levelBoundingInfo},enumerable:!0,configurable:!0}),t.prototype.updateLevelBoundingInfo=function(){},t.prototype.onPrimBecomesDirty=function(){},t._hookProperty=function(e,i,r,n,o){return function(s,a,h){var c=t._createPropInfo(s,a,e,n,r,o);i&&i(c);var l=h.get,u=h.set;h.set=function(e){if(!this.isDisposed){var i=l.call(this);if(!t._checkUnchanged(i,e)){var n=this;u.call(this,e),n._handlePropChanged(i,e,a,c,r)}}}}},t.prototype.addExternalData=function(t,i){return this._externalData||(this._externalData=new e.StringDictionary),this._externalData.add(t,i)},t.prototype.getExternalData=function(e){return this._externalData?this._externalData.get(e):null},t.prototype.getOrAddExternalDataWithFactory=function(t,i){return this._externalData||(this._externalData=new e.StringDictionary),this._externalData.getOrAddWithFactory(t,i)},t.prototype.removeExternalData=function(e){return this._externalData?this._externalData.remove(e):!1},t.prototype._isFlagSet=function(e){return 0!==(this._flags&e)},t.prototype._areAllFlagsSet=function(e){return(this._flags&e)===e},t.prototype._areSomeFlagsSet=function(e){return 0!==(this._flags&e)},t.prototype._clearFlags=function(e){this._flags&=~e},t.prototype._setFlags=function(e){var t=this._flags;return this._flags|=e,t},t.prototype._changeFlags=function(e,t){t?this._flags|=e:this._flags&=~e},t.propChangedInfo=new s,t.flagIsDisposed=1,t.flagLevelBoundingInfoDirty=2,t.flagModelDirty=4,t.flagLayoutDirty=8,t.flagLevelVisible=16,t.flagBoundingInfoDirty=32,t.flagIsPickable=64,t.flagIsVisible=128,t.flagVisibilityChanged=256,t.flagPositioningDirty=512,t.flagTrackedGroup=1024,t=__decorate([e.className("SmartPropertyPrim")],t)}();e.SmartPropertyPrim=h,e.modelLevelProperty=t,e.instanceLevelProperty=i,e.dynamicLevelProperty=r}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function e(){this.forceRefreshPrimitive=!1}return e}();e.PrepareRender2DContext=t;var i=function(){function e(e){this._renderMode=e,this.useInstancing=!1,this.groupInfoPartData=null,this.partDataStartIndex=this.partDataEndIndex=null}return Object.defineProperty(e.prototype,"renderMode",{get:function(){return this._renderMode},enumerable:!0,configurable:!0}),Object.defineProperty(e,"RenderModeOpaque",{get:function(){return e._renderModeOpaque},enumerable:!0,configurable:!0}),Object.defineProperty(e,"RenderModeAlphaTest",{get:function(){return e._renderModeAlphaTest},enumerable:!0,configurable:!0}),Object.defineProperty(e,"RenderModeTransparent",{get:function(){return e._renderModeTransparent},enumerable:!0,configurable:!0}),e._renderModeOpaque=1,e._renderModeAlphaTest=2,e._renderModeTransparent=3,e}();e.Render2DContext=i;var r=function(){function t(){this.primitivePointerPos=e.Vector2.Zero(),this.tilt=e.Vector2.Zero(),this.cancelBubble=!1}return Object.defineProperty(t,"PointerOver",{get:function(){return t._pointerOver},enumerable:!0,configurable:!0}),Object.defineProperty(t,"PointerEnter",{get:function(){return t._pointerEnter},enumerable:!0,configurable:!0}),Object.defineProperty(t,"PointerDown",{get:function(){return t._pointerDown},enumerable:!0,configurable:!0}),Object.defineProperty(t,"PointerMouseWheel",{get:function(){return t._pointerMouseWheel},enumerable:!0,configurable:!0}),Object.defineProperty(t,"PointerMove",{get:function(){return t._pointerMove},enumerable:!0,configurable:!0}),Object.defineProperty(t,"PointerUp",{get:function(){return t._pointerUp},enumerable:!0,configurable:!0}),Object.defineProperty(t,"PointerOut",{get:function(){return t._pointerOut},enumerable:!0,configurable:!0}),Object.defineProperty(t,"PointerLeave",{get:function(){return t._pointerLeave},enumerable:!0,configurable:!0}),Object.defineProperty(t,"PointerGotCapture",{get:function(){return t._pointerGotCapture},enumerable:!0,configurable:!0}),Object.defineProperty(t,"PointerLostCapture",{get:function(){return t._pointerLostCapture},enumerable:!0,configurable:!0}),Object.defineProperty(t,"MouseWheelPrecision",{get:function(){return t._mouseWheelPrecision},enumerable:!0,configurable:!0}),t.prototype.updateRelatedTarget=function(e,t){this.relatedTarget=e,this.relatedTargetPointerPos=t},t.getEventTypeName=function(e){switch(e){case t.PointerOver:return"PointerOver";case t.PointerEnter:return"PointerEnter";case t.PointerDown:return"PointerDown";case t.PointerMouseWheel:return"PointerMouseWheel";case t.PointerMove:return"PointerMove";case t.PointerUp:return"PointerUp";case t.PointerOut:return"PointerOut";case t.PointerLeave:return"PointerLeave";case t.PointerGotCapture:return"PointerGotCapture";case t.PointerLostCapture:return"PointerLostCapture"}},t._pointerOver=1,t._pointerEnter=2,t._pointerDown=4,t._pointerMouseWheel=8,t._pointerMove=16,t._pointerUp=32,t._pointerOut=64,t._pointerLeave=128,t._pointerGotCapture=256,t._pointerLostCapture=512,t._mouseWheelPrecision=3,t}();e.PrimitivePointerInfo=r;var n=function(){function e(t){this._changedCallback=t,this._horizontal=e.AlignLeft,this._vertical=e.AlignBottom}return Object.defineProperty(e,"AlignLeft",{get:function(){return e._AlignLeft},enumerable:!0,configurable:!0}),Object.defineProperty(e,"AlignTop",{get:function(){return e._AlignTop},enumerable:!0,configurable:!0}),Object.defineProperty(e,"AlignRight",{get:function(){return e._AlignRight},enumerable:!0,configurable:!0}),Object.defineProperty(e,"AlignBottom",{get:function(){return e._AlignBottom},enumerable:!0,configurable:!0}),Object.defineProperty(e,"AlignCenter",{get:function(){return e._AlignCenter},enumerable:!0,configurable:!0}),Object.defineProperty(e,"AlignStretch",{get:function(){return e._AlignStretch},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"horizontal",{get:function(){return this._horizontal},set:function(e){this._horizontal!==e&&(this._horizontal=e,this._changedCallback())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"vertical",{get:function(){return this._vertical},set:function(e){this._vertical!==e&&(this._vertical=e,this._changedCallback())},enumerable:!0,configurable:!0}),e.prototype.setHorizontal=function(t){var i=t.trim().toLocaleLowerCase();switch(i){case"left":return void(this.horizontal=e.AlignLeft);case"right":return void(this.horizontal=e.AlignRight);case"center":return void(this.horizontal=e.AlignCenter);case"stretch":return void(this.horizontal=e.AlignStretch)}},e.prototype.setVertical=function(t){var i=t.trim().toLocaleLowerCase();switch(i){case"top":return void(this.vertical=e.AlignTop);case"bottom":return void(this.vertical=e.AlignBottom);case"center":return void(this.vertical=e.AlignCenter);case"stretch":return void(this.vertical=e.AlignStretch)}},e.prototype.fromString=function(e){for(var t=e.trim().split(","),i=0;i<t.length;i++){var r=t[i];r=r.toLocaleLowerCase().trim();var n=r.indexOf("h:");-1===n&&(n=r.indexOf("horizontal:")),-1===n?(n=r.indexOf("v:"),-1===n&&(n=r.indexOf("vertical:")),-1===n||(r=r.substr(r.indexOf(":")+1),this.setVertical(r))):(r=r.substr(r.indexOf(":")+1),this.setHorizontal(r))}},e._AlignLeft=1,e._AlignTop=1,e._AlignRight=2,e._AlignBottom=2,e._AlignCenter=3,e._AlignStretch=4,e}();e.PrimitiveAlignment=n;var o=function(){function e(e,t){this.prim=e,this.intersectionLocation=t}return e}();e.PrimitiveIntersectedInfo=o;var s=function(){function e(t,i){this._parentAccess=t,this._changedCallback=i,this._pixels=new Array(4),this._percentages=new Array(4),this._setType(0,e.Auto),this._setType(1,e.Auto),this._setType(2,e.Auto),this._setType(3,e.Auto),this._pixels[0]=0,this._pixels[1]=0,this._pixels[2]=0,this._pixels[3]=0}return e.prototype.fromString=function(t){this._clear();for(var i=t.trim().split(","),r=!1,n=0;n<i.length;n++){var o=i[n];r=this._extractString(o,!1)||r}if(!r)throw new Error("Can't parse the string to create a PrimitiveMargin object, format must be: 'top: <value>, left:<value>, right:<value>, bottom:<value>");0===(15&this._flags)&&(this._flags|=e.Pixel<<0),0===(240&this._flags)&&(this._flags|=e.Pixel<<4),0===(3840&this._flags)&&(this._flags|=e.Pixel<<8),0===(61440&this._flags)&&(this._flags|=e.Pixel<<12),this._changedCallback()},e.prototype.fromStrings=function(e,t,i,r){return this._clear(),this._setStringValue(e,0,!1),this._setStringValue(t,1,!1),this._setStringValue(i,2,!1),this._setStringValue(r,3,!1),this._changedCallback(),this},e.prototype.fromPixels=function(e,t,i,r){return this._clear(),this._pixels[0]=e,this._pixels[1]=t,this._pixels[2]=i,this._pixels[3]=r,this._changedCallback(),this},e.prototype.fromUniformPixels=function(e){return this._clear(),this._pixels[0]=e,this._pixels[1]=e,this._pixels[2]=e,this._pixels[3]=e,this._changedCallback(),this},e.prototype.auto=function(){return this._clear(),this._flags=e.Auto<<0|e.Auto<<4|e.Auto<<8|e.Auto<<12,this._pixels[0]=0,this._pixels[1]=0,this._pixels[2]=0,this._pixels[3]=0,this._changedCallback(),this},e.prototype._clear=function(){this._flags=0,this._pixels[0]=0,this._pixels[1]=0,this._pixels[2]=0,this._pixels[3]=0,this._percentages[0]=null,this._percentages[1]=null,this._percentages[2]=null,this._percentages[3]=null},e.prototype._extractString=function(e,t){var i=e.trim().toLocaleLowerCase();return 0===i.indexOf("top:")?(i=i.substr(4).trim(),this._setStringValue(i,0,t)):0===i.indexOf("left:")?(i=i.substr(5).trim(),this._setStringValue(i,1,t)):0===i.indexOf("right:")?(i=i.substr(6).trim(),this._setStringValue(i,2,t)):0===i.indexOf("bottom:")?(i=i.substr(7).trim(),this._setStringValue(i,3,t)):!1},e.prototype._setStringValue=function(t,i,r){var n=t.trim().toLocaleLowerCase();if("auto"===n){if(this._isType(i,e.Auto))return!0;this._setType(i,e.Auto),this._pixels[i]=0,r&&this._changedCallback()}else{if("inherit"!==n){var o=n.indexOf("%");if(-1!==o){var s=n.substr(0,o),a=Math.round(Number(s))/100;return this._isType(i,e.Percentage)&&this._percentages[i]===a?!0:(this._setType(i,e.Percentage),isNaN(a)?!1:(this._percentages[i]=a,r&&this._changedCallback(),!0))}var h;o=n.indexOf("px"),h=-1!==o?n.substr(0,o).trim():n;var c=Number(h);return this._isType(i,e.Pixel)&&this._pixels[i]===c?!0:isNaN(c)?!1:(this._pixels[i]=c,this._setType(i,e.Pixel),r&&this._changedCallback(),!0)}if(this._isType(i,e.Inherit))return!0;this._setType(i,e.Inherit),this._pixels[i]=null,r&&this._changedCallback()}},e.prototype._setPixels=function(t,i,r){t=Math.round(t),this._isType(i,e.Pixel)&&this._pixels[i]===t||(this._setType(i,e.Pixel),this._pixels[i]=t,r&&this._changedCallback())},e.prototype._setPercentage=function(t,i,r){t=Math.min(1,t),t=Math.max(0,t),t=Math.round(100*t)/100,this._isType(i,e.Percentage)&&this._percentages[i]===t||(this._setType(i,e.Percentage),this._percentages[i]=t,r&&this._changedCallback())},e.prototype._getStringValue=function(t){var i=this._flags>>4*t&15;switch(i){case e.Auto:return"auto";case e.Pixel:return this._pixels[t]+"px";case e.Percentage:return 100*this._percentages[t]+"%";case e.Inherit:return"inherit"}return""},e.prototype._isType=function(e,t){var i=this._flags>>4*e&15;return i===t},e.prototype._getType=function(t,i){var r=this._flags>>4*t&15;if(i&&r===e.Inherit){var n=this._parentAccess();return n?n._getType(t,!0):e.Auto}return r},e.prototype._setType=function(e,t){this._flags&=~(15<<4*e),this._flags|=t<<4*e},e.prototype.setTop=function(e){"string"==typeof e?this._setStringValue(e,0,!0):this.topPixels=e},e.prototype.setLeft=function(e){"string"==typeof e?this._setStringValue(e,1,!0):this.leftPixels=e},e.prototype.setRight=function(e){"string"==typeof e?this._setStringValue(e,2,!0):this.rightPixels=e},e.prototype.setBottom=function(e){"string"==typeof e?this._setStringValue(e,3,!0):this.bottomPixels=e},Object.defineProperty(e.prototype,"top",{get:function(){return this._getStringValue(0)},set:function(e){this._setStringValue(e,0,!0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"left",{get:function(){return this._getStringValue(1)},set:function(e){this._setStringValue(e,1,!0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"right",{get:function(){return this._getStringValue(2)},set:function(e){this._setStringValue(e,2,!0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"bottom",{get:function(){return this._getStringValue(3)},set:function(e){this._setStringValue(e,3,!0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"topPixels",{get:function(){return this._pixels[0]},set:function(e){this._setPixels(e,0,!0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"leftPixels",{get:function(){return this._pixels[1]},set:function(e){this._setPixels(e,1,!0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rightPixels",{get:function(){return this._pixels[2]},set:function(e){this._setPixels(e,2,!0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"bottomPixels",{get:function(){return this._pixels[3]},set:function(e){this._setPixels(e,3,!0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"topPercentage",{get:function(){return this._percentages[0]},set:function(e){this._setPercentage(e,0,!0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"leftPercentage",{get:function(){return this._percentages[1]},set:function(e){this._setPercentage(e,1,!0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rightPercentage",{get:function(){return this._percentages[2]},set:function(e){this._setPercentage(e,2,!0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"bottomPercentage",{get:function(){return this._percentages[3]},set:function(e){this._setPercentage(e,3,!0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"topMode",{get:function(){return this._getType(0,!1)},set:function(e){this._setType(0,e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"leftMode",{get:function(){return this._getType(1,!1)},set:function(e){this._setType(1,e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rightMode",{get:function(){return this._getType(2,!1)},set:function(e){this._setType(2,e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"bottomMode",{get:function(){return this._getType(3,!1)},set:function(e){this._setType(3,e)},enumerable:!0,configurable:!0}),e.prototype._computePixels=function(t,i,r){var n=this._getType(t,!1);if(n===e.Inherit)return void this._parentAccess()._computePixels(t,i,r);if(n===e.Percentage){var o=(0===t||3===t?i.height:i.width)*this._percentages[t];this._pixels[t]=o,r&&this._changedCallback()}},e.prototype.computeWithAlignment=function(t,i,r,o,s){var a=this._getType(0,!0),h=this._getType(1,!0),c=this._getType(2,!0),l=this._getType(3,!0),u=i&&null!=i.width,f=i&&null!=i.height,d=u?i.width:0,p=f?i.height:0,_=a===e.Auto,m=h===e.Auto,g=c===e.Auto,v=l===e.Auto;switch(r.horizontal){case n.AlignLeft:m?o.x=0:(this._computePixels(1,t,!0),o.x=this.leftPixels),s.width=d;break;case n.AlignRight:g?o.x=Math.round(t.width-d):(this._computePixels(2,t,!0),o.x=Math.round(t.width-(d+this.rightPixels))),s.width=d;break;case n.AlignStretch:m?o.x=0:(this._computePixels(1,t,!0),o.x=this.leftPixels);var y=0;g||(this._computePixels(2,t,!0),y=this.rightPixels),s.width=t.width-(o.x+y);break;case n.AlignCenter:m||this._computePixels(1,t,!0),g||this._computePixels(2,t,!0);var x=(m?0:this.leftPixels)-(g?0:this.rightPixels);o.x=Math.round((t.width-d)/2+x),s.width=d}switch(r.vertical){case n.AlignTop:_?o.y=t.height-p:(this._computePixels(0,t,!0),o.y=Math.round(t.height-(p+this.topPixels))),s.height=p;break;case n.AlignBottom:v?o.y=0:(this._computePixels(3,t,!0),o.y=this.bottomPixels),s.height=p;break;case n.AlignStretch:v?o.y=0:(this._computePixels(3,t,!0),o.y=this.bottomPixels);var b=0;_||(this._computePixels(0,t,!0),b=this.topPixels),s.height=t.height-(o.y+b);break;case n.AlignCenter:_||this._computePixels(0,t,!0),v||this._computePixels(3,t,!0);var x=(v?0:this.bottomPixels)-(_?0:this.topPixels);o.y=Math.round((t.height-p)/2+x),s.height=p}},e.prototype.compute=function(e,t,i){this._computePixels(0,e,!0),this._computePixels(1,e,!0),this._computePixels(2,e,!0),this._computePixels(3,e,!0),t.x=this.leftPixels,i.width=e.width-(t.x+this.rightPixels),t.y=this.bottomPixels,i.height=e.height-(t.y+this.topPixels)},e.prototype.computeArea=function(e,t){this._computePixels(0,e,!0),this._computePixels(1,e,!0),this._computePixels(2,e,!0),this._computePixels(3,e,!0),t.width=this.leftPixels+e.width+this.rightPixels,t.height=this.bottomPixels+e.height+this.topPixels},e.Auto=1,e.Inherit=2,e.Percentage=4,e.Pixel=8,e}();e.PrimitiveThickness=s;var a=function(){function t(){this.findFirstOnly=!1,this.intersectHidden=!1,this.pickPosition=e.Vector2.Zero()}return Object.defineProperty(t.prototype,"isIntersected",{get:function(){return this.intersectedPrimitives&&this.intersectedPrimitives.length>0},enumerable:!0,configurable:!0}),t.prototype.isPrimIntersected=function(e){for(var t=0,i=this.intersectedPrimitives;t<i.length;t++){var r=i[t];if(r.prim===e)return r.intersectionLocation}return null},t.prototype._exit=function(e){e&&(this._globalPickPosition=null)},t}();e.IntersectInfo2D=a;var h=function(t){function i(r){null==r&&(r={}),t.call(this);var n,o;if(i._isCanvasInit)n=this,o=null,this._canvasPreInit(r);else if(null!=r.parent){if(o=r.parent,n=r.parent.owner,!n)throw new Error("Parent "+o.id+" of "+r.id+" doesn't have a valid owner!");if(!(this instanceof e.Group2D||this instanceof e.Sprite2D&&null!==r.id&&0===r.id.indexOf("__cachedSpriteOfGroup__")||n.cachingStrategy!==e.Canvas2D.CACHESTRATEGY_TOPLEVELGROUPS||o!==n))throw new Error("Can't create a primitive with the canvas as direct parent when the caching strategy is TOPLEVELGROUPS. You need to create a Group below the canvas and use it as the parent for the primitive")}if(this._layoutEngine=e.CanvasLayoutEngine.Singleton,this._size=null,this._actualSize=null,this._boundingSize=null,this._layoutArea=e.Size.Zero(),this._layoutAreaPos=e.Vector2.Zero(),this._marginOffset=e.Vector2.Zero(),this._parentMargingOffset=e.Vector2.Zero(),this._parentContentArea=e.Size.Zero(),this._contentArea=new e.Size(null,null),this._pointerEventObservable=new e.Observable,this._siblingDepthOffset=this._hierarchyDepthOffset=0,this._boundingInfo=new e.BoundingInfo2D,this._owner=n,this._parent=null,this._margin=null,this._padding=null,this._marginAlignment=null,this._id=r.id,this.propertyChanged=new e.Observable,this._children=new Array,this._localTransform=new e.Matrix,this._globalTransform=null,this._invGlobalTransform=null,this._globalTransformProcessStep=0,this._globalTransformStep=0,this._hierarchyDepth=0,this._renderGroup=null,this._setFlags(e.SmartPropertyPrim.flagIsPickable|e.SmartPropertyPrim.flagBoundingInfoDirty),null!=o&&(o.addChild(this),this._patchHierarchy(o.owner)),this.owner&&this instanceof e.Group2D){var s=this;s.detectGroupStates()}if(null!=r.children)for(var a=0,h=r.children;a<h.length;a++){var c=h[a];this.addChild(c),c._patchHierarchy(this.owner)}if(null!=r.position?this.position=r.position:null!=r.x||null!=r.y?this.position=new e.Vector2(r.x||0,r.y||0):this._position=null,this.rotation=null==r.rotation?0:r.rotation,this.scale=null==r.scale?1:r.scale,this.levelVisible=null==r.isVisible?!0:r.isVisible,this.origin=r.origin||new e.Vector2(.5,.5),null!=r.layoutEngine)if("string"==typeof r.layoutEngine){var l=r.layoutEngine.toLocaleLowerCase().trim();"canvas"===l||"canvaslayoutengine"===l?this.layoutEngine=e.CanvasLayoutEngine.Singleton:0===l.indexOf("stackpanel")||0===l.indexOf("horizontalstackpanel")?this.layoutEngine=e.StackPanelLayoutEngine.Horizontal:0===l.indexOf("verticalstackpanel")&&(this.layoutEngine=e.StackPanelLayoutEngine.Vertical)}else r.layoutEngine instanceof e.LayoutEngineBase&&(this.layoutEngine=r.layoutEngine);r.marginTop&&this.margin.setTop(r.marginTop),r.marginLeft&&this.margin.setLeft(r.marginLeft),r.marginRight&&this.margin.setRight(r.marginRight),r.marginBottom&&this.margin.setBottom(r.marginBottom),r.margin&&("string"==typeof r.margin?this.margin.fromString(r.margin):this.margin.fromUniformPixels(r.margin)),r.marginHAlignment&&(this.marginAlignment.horizontal=r.marginHAlignment),r.marginVAlignment&&(this.marginAlignment.vertical=r.marginVAlignment),r.marginAlignment&&this.marginAlignment.fromString(r.marginAlignment),r.paddingTop&&this.padding.setTop(r.paddingTop),r.paddingLeft&&this.padding.setLeft(r.paddingLeft),r.paddingRight&&this.padding.setRight(r.paddingRight),r.paddingBottom&&this.padding.setBottom(r.paddingBottom),r.padding&&this.padding.fromString(r.padding),this._parentLayoutDirty(),this._positioningDirty()}return __extends(i,t),Object.defineProperty(i.prototype,"actionManager",{get:function(){return this._actionManager||(this._actionManager=new e.ActionManager(this.owner.scene)),this._actionManager},enumerable:!0,configurable:!0}),i.prototype.traverseUp=function(e){for(var t=this;null!=t;){if(e(t))return t;t=t._parent}return null},Object.defineProperty(i.prototype,"owner",{get:function(){return this._owner},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"parent",{get:function(){return this._parent},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"children",{get:function(){return this._children},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"id",{get:function(){return this._id},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"actualPosition",{get:function(){return null!=this._actualPosition?this._actualPosition:null!=this._position?this._position:i._nullPosition},set:function(e){this._actualPosition=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"actualX",{get:function(){return this.actualPosition.x},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"actualY",{get:function(){return this.actualPosition.y},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"position",{get:function(){return this._position},set:function(e){this._checkPositionChange()&&(this._position=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"x",{get:function(){return this._position?this._position.x:null},set:function(t){this._checkPositionChange()&&(this._position||(this._position=e.Vector2.Zero()),this._position.x!==t&&(this._position.x=t,this.markAsDirty("position")))},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"y",{get:function(){return this._position?this._position.y:null},set:function(t){this._checkPositionChange()&&(this._position||(this._position=e.Vector2.Zero()),this._position.y!==t&&(this._position.y=t,this.markAsDirty("position")))},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"size",{get:function(){if(!this._size||null==this._size.width||null==this._size.height){if(i.boundinbBoxReentrency)return i.nullSize;if(this._boundingSize)return this._boundingSize;i.boundinbBoxReentrency=!0;this.boundingInfo;return i.boundinbBoxReentrency=!1,this._boundingSize}return this._size},set:function(e){this._size=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"width",{get:function(){return this.size?this.size.width:null},set:function(t){return this.size?void(this.size.width!==t&&(this.size.width=t,this.markAsDirty("size"),this._positioningDirty())):void(this.size=new e.Size(t,0))},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"height",{get:function(){return this.size?this.size.height:null},set:function(t){return this.size?void(this.size.height!==t&&(this.size.height=t,this.markAsDirty("size"),this._positioningDirty())):void(this.size=new e.Size(0,t))},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"rotation",{get:function(){return this._rotation},set:function(e){this._rotation=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"scale",{get:function(){return this._scale},set:function(e){this._scale=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"actualSize",{get:function(){return this._actualSize?this._actualSize:this._size},set:function(e){this._actualSize.equals(e)||(this._actualSize=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"actualZOffset",{get:function(){return this._zOrder||1-this._hierarchyDepthOffset},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"minSize",{get:function(){return this._minSize},set:function(e){this._minSize&&e&&this._minSize.equals(e)||(this._minSize=e,this._parentLayoutDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"maxSize",{get:function(){return this._maxSize},set:function(e){this._maxSize&&e&&this._maxSize.equals(e)||(this._maxSize=e,this._parentLayoutDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"origin",{get:function(){return this._origin},set:function(e){this._origin=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"levelVisible",{get:function(){return this._isFlagSet(e.SmartPropertyPrim.flagLevelVisible)},set:function(t){this._changeFlags(e.SmartPropertyPrim.flagLevelVisible,t)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"isVisible",{get:function(){return this._isFlagSet(e.SmartPropertyPrim.flagIsVisible)},set:function(t){this._changeFlags(e.SmartPropertyPrim.flagIsVisible,t)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"zOrder",{get:function(){return this._zOrder},set:function(e){this._zOrder=e,this.onZOrderChanged()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"margin",{get:function(){var e=this;return this._margin||(this._margin=new s(function(){return e.parent?e.parent.margin:null},function(){return e._positioningDirty()})),this._margin},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"_hasMargin",{get:function(){return null!==this._margin||null!==this._marginAlignment},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"padding",{get:function(){var e=this;return this._padding||(this._padding=new s(function(){return e.parent?e.parent.padding:null},function(){return e._positioningDirty()})),this._padding},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"_hasPadding",{get:function(){return null!==this._padding},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"marginAlignment",{get:function(){var e=this;return this._marginAlignment||(this._marginAlignment=new n(function(){return e._positioningDirty()})),this._marginAlignment},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"layoutEngine",{get:function(){return this._layoutEngine||(this._layoutEngine=e.CanvasLayoutEngine.Singleton),this._layoutEngine},set:function(e){this._layoutEngine!==e&&this._changeLayoutEngine(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"layoutArea",{get:function(){return this._layoutArea},set:function(e){this._layoutArea.equals(e)||(this._positioningDirty(),this._layoutArea=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"layoutAreaPos",{get:function(){return this._layoutAreaPos},set:function(e){this._layoutAreaPos.equals(e)||(this._positioningDirty(),this._layoutAreaPos=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"isPickable",{get:function(){return this._isFlagSet(e.SmartPropertyPrim.flagIsPickable)},set:function(t){this._changeFlags(e.SmartPropertyPrim.flagIsPickable,t)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"hierarchyDepth",{get:function(){return this._hierarchyDepth},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"renderGroup",{get:function(){return this._renderGroup},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"globalTransform",{get:function(){return this._globalTransform},enumerable:!0,configurable:!0}),i.prototype.getGlobalPosition=function(){var t=new e.Vector2(0,0);return this.getGlobalPositionByRef(t),t},i.prototype.getGlobalPositionByRef=function(e){e.x=this.globalTransform.m[12],e.y=this.globalTransform.m[13]},Object.defineProperty(i.prototype,"invGlobalTransform",{get:function(){return this._invGlobalTransform},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"localTransform",{get:function(){return this._updateLocalTransform(),this._localTransform},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"boundingInfo",{get:function(){if(this._isFlagSet(e.SmartPropertyPrim.flagBoundingInfoDirty)){this._boundingInfo=this.levelBoundingInfo.clone();for(var t=this._boundingInfo,i=new e.BoundingInfo2D,r=0,n=this._children;r<n.length;r++){var o=n[r];o.boundingInfo.transformToRef(o.localTransform,i),t.unionToRef(i,t)}this._boundingSize=e.Size.Zero();var s=this._boundingInfo.max();this._boundingSize=new e.Size(this._size&&null!=this._size.width?this._size.width:Math.ceil(s.x),this._size&&null!=this._size.height?this._size.height:Math.ceil(s.y)),this._clearFlags(e.SmartPropertyPrim.flagBoundingInfoDirty)}return this._boundingInfo},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"isSizeAuto",{get:function(){return null==this._size},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"isPositionAuto",{get:function(){return null==this._position},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"pointerEventObservable",{get:function(){return this._pointerEventObservable},enumerable:!0,configurable:!0}),i.prototype.findById=function(e){if(this._id===e)return this;for(var t=0,i=this._children;t<i.length;t++){var r=i[t],n=r.findById(e);if(null!=n)return n}},i.prototype.onZOrderChanged=function(){},i.prototype.levelIntersect=function(e){return!1},i.prototype.setPointerEventCapture=function(e){return this.owner._setPointerCapture(e,this)},i.prototype.releasePointerEventsCapture=function(e){return this.owner._releasePointerCapture(e,this)},i.prototype.intersect=function(t){if(!t)return!1;var i=!t._globalPickPosition;if(i&&(t._globalPickPosition=e.Vector2.Zero(),e.Vector2.TransformToRef(t.pickPosition,this.globalTransform,t._globalPickPosition),t._localPickPosition=t.pickPosition.clone(),t.intersectedPrimitives=new Array,t.topMostIntersectedPrimitive=null),!t.intersectHidden&&!this.isVisible)return!1;if(this.isPickable&&!this.boundingInfo.doesIntersect(t._localPickPosition))return t._exit(i),!1;var r=!1;if(this.isPickable&&(r=this.levelIntersect(t))){var n=new o(this,t._localPickPosition.clone());if(t.intersectedPrimitives.push(n),(!t.topMostIntersectedPrimitive||t.topMostIntersectedPrimitive.prim.actualZOffset>n.prim.actualZOffset)&&(t.topMostIntersectedPrimitive=n),t.findFirstOnly)return t._exit(i),!0}if(!r||!t.findFirstOnly)for(var s=0,a=this._children;s<a.length;s++){var h=a[s];if(h.isPickable&&(t.intersectHidden||h.isVisible)&&(e.Vector2.TransformToRef(t._globalPickPosition,h.invGlobalTransform,t._localPickPosition),
  24. h.intersect(t)&&t.findFirstOnly))return t._exit(i),!0}return t._exit(i),t.isIntersected},i.prototype.moveChild=function(e,t){if(e.parent!==this)return!1;var i,r,n=this._children.indexOf(e),o=t?this._children.indexOf(t):-1;t?(i=this._children[o]._siblingDepthOffset,r=this._children[o+1]._siblingDepthOffset):(i=1,r=this._children[1]._siblingDepthOffset),e._siblingDepthOffset=(r-i)/2,this._children.splice(o+1,0,this._children.splice(n,1)[0])},i.prototype.addChild=function(e){e._parent=this,this._boundingBoxDirty(),this._patchHierarchyDepth(e),this._children.push(e)},i.prototype.dispose=function(){if(!t.prototype.dispose.call(this))return!1;if(this._actionManager&&(this._actionManager.dispose(),this._actionManager=null),this._parent){var e=this._parent._children.indexOf(this);void 0!==e&&this._parent._children.splice(e,1),this._parent=null}if(this._children)for(;this._children.length>0;)this._children[this._children.length-1].dispose();return!0},i.prototype.onPrimBecomesDirty=function(){this._renderGroup&&this._renderGroup._addPrimToDirtyList(this)},i.prototype._needPrepare=function(){return this._areSomeFlagsSet(e.SmartPropertyPrim.flagVisibilityChanged|e.SmartPropertyPrim.flagModelDirty)||0!==this._instanceDirtyFlags||this._globalTransformProcessStep!==this._globalTransformStep},i.prototype._prepareRender=function(e){this._prepareRenderPre(e),this._prepareRenderPost(e)},i.prototype._prepareRenderPre=function(e){},i.prototype._prepareRenderPost=function(t){if(this instanceof e.Group2D){var r=this;if(r.isRenderableGroup)return}this._children.length>0&&(this._globalTransformProcessStep!==this._globalTransformStep||this.checkPropertiesDirty(i.isVisibleProperty.flagId))&&this._children.forEach(function(i){i instanceof e.Group2D&&i.isRenderableGroup||i._prepareRender(t)}),this._clearFlags(e.SmartPropertyPrim.flagModelDirty),this._instanceDirtyFlags=0},i.prototype._canvasPreInit=function(e){},i.CheckParent=function(e){},i.prototype.updateCachedStatesOf=function(e,t){for(var i=0;i<e.length;i++){var r=e[i];r.updateCachedStates(t)}},i.prototype._parentLayoutDirty=function(){this._parent&&!this._parent.isDisposed&&this._parent._setLayoutDirty()},i.prototype._setLayoutDirty=function(){this.isDirty||this.onPrimBecomesDirty(),this._setFlags(e.SmartPropertyPrim.flagLayoutDirty)},i.prototype._checkPositionChange=function(){return this.parent&&this.parent.layoutEngine.isChildPositionAllowed===!1?(console.log("Can't manually set the position of "+this.id+", the Layout Engine of its parent doesn't allow it"),!1):!0},i.prototype._positioningDirty=function(){this.isDirty||this.onPrimBecomesDirty(),this._setFlags(e.SmartPropertyPrim.flagPositioningDirty)},i.prototype._changeLayoutEngine=function(e){this._layoutEngine=e},i.prototype._updateLocalTransform=function(){var t=!1,r=null;this._parent?(r=this._parent._marginOffset,t=!r.equals(this._parentMargingOffset),this._parentMargingOffset.copyFrom(r)):r=i._v0;var n=i.actualPositionProperty.flagId|i.rotationProperty.flagId|i.scaleProperty.flagId|i.originProperty.flagId;if(t||this.checkPropertiesDirty(n)){var o,s=e.Quaternion.RotationAxis(new e.Vector3(0,0,1),this._rotation);if(0===this._origin.x&&0===this._origin.y)o=e.Matrix.Compose(new e.Vector3(this._scale,this._scale,1),s,new e.Vector3(this.actualPosition.x+r.x,this.actualPosition.y+r.y,0)),this._localTransform=o;else{var a=this.actualSize;e.Matrix.TranslationToRef(-a.width*this._origin.x,-a.height*this._origin.y,0,i._t0),s.toRotationMatrix(i._t1),i._t0.multiplyToRef(i._t1,i._t2),e.Matrix.ScalingToRef(this._scale,this._scale,1,i._t0),i._t2.multiplyToRef(i._t0,i._t1),e.Matrix.TranslationToRef(a.width*this._origin.x+this.actualPosition.x+r.x,a.height*this._origin.y+this.actualPosition.y+r.y,0,i._t2),i._t1.multiplyToRef(i._t2,this._localTransform)}return this.clearPropertiesDirty(n),!0}return!1},i.prototype.updateCachedStates=function(t){if(!this.isDisposed){this._parent&&(this._parent._globalTransformProcessStep!==this.owner._globalTransformProcessStep||this._parent._areSomeFlagsSet(e.SmartPropertyPrim.flagLayoutDirty|e.SmartPropertyPrim.flagPositioningDirty))&&this._parent.updateCachedStates(!1);var r=this.checkPropertiesDirty(i.sizeProperty.flagId);if(!this._isFlagSet(e.SmartPropertyPrim.flagLayoutDirty)&&r){var n=this.size;n&&(null!=this.size.width&&(this.actualSize.width=this.size.width),null!=this.size.height&&(this.actualSize.height=this.size.height),this.clearPropertiesDirty(i.sizeProperty.flagId))}var o=this._isFlagSet(e.SmartPropertyPrim.flagPositioningDirty);this._isFlagSet(e.SmartPropertyPrim.flagLayoutDirty)&&(this._layoutEngine.updateLayout(this),this._clearFlags(e.SmartPropertyPrim.flagLayoutDirty));var s=o&&!this._isFlagSet(e.SmartPropertyPrim.flagPositioningDirty);if(!s&&(r||this._isFlagSet(e.SmartPropertyPrim.flagPositioningDirty)||this._parent&&!this._parent.contentArea.equals(this._parentContentArea))&&(this._updatePositioning(),this._clearFlags(e.SmartPropertyPrim.flagPositioningDirty),s=!0),s&&this._parent&&this._parentContentArea.copyFrom(this._parent.contentArea),this===this.owner||this._globalTransformProcessStep!==this.owner._globalTransformProcessStep){var a=this.isVisible;this.isVisible=(!this._parent||this._parent.isVisible)&&this.levelVisible,this._changeFlags(e.SmartPropertyPrim.flagVisibilityChanged,a!==this.isVisible);var h=this._updateLocalTransform(),c=null!=this._parent?this._parent._globalTransformStep!==this._parentTransformStep:!1;if(!this._globalTransform||h||c){var l=this._parent?this._parent._globalTransform:null;this._globalTransform=this._parent?this._localTransform.multiply(l):this._localTransform,this._invGlobalTransform=e.Matrix.Invert(this._globalTransform),this._globalTransformStep=this.owner._globalTransformProcessStep+1,this._parentTransformStep=this._parent?this._parent._globalTransformStep:0}this._globalTransformProcessStep=this.owner._globalTransformProcessStep}if(t)for(var u=0,f=this._children;u<f.length;u++){var d=f[u];d.updateCachedStates(!(d instanceof e.Group2D&&d.isRenderableGroup))}}},i.prototype._updatePositioning=function(){this._hasMargin||null!=this.actualSize.width&&null!=this.actualSize.height||(null==this.actualSize.width&&(this.marginAlignment.horizontal=n.AlignStretch),null==this.actualSize.height&&(this.marginAlignment.vertical=n.AlignStretch)),this._hasMargin&&(this.margin.computeWithAlignment(this.layoutArea,this.size,this.marginAlignment,this._marginOffset,i._size),this.actualPosition=this._marginOffset.add(this._layoutAreaPos),null!=this.size.width&&(this.size.width=i._size.width),null!=this.size.height&&(this.size.height=i._size.height),this.actualSize.copyFrom(i._size.clone())),this._hasPadding?(this._getInitialContentAreaToRef(this.actualSize,i._icPos,i._icArea),i._icArea.width=Math.max(0,i._icArea.width),i._icArea.height=Math.max(0,i._icArea.height),this.padding.compute(i._icArea,this._marginOffset,i._size),this._marginOffset.x+=i._icPos.x,this._marginOffset.y+=i._icPos.y,this._contentArea.copyFrom(i._size)):(this._getInitialContentAreaToRef(this.actualSize,i._icPos,i._icArea),i._icArea.width=Math.max(0,i._icArea.width),i._icArea.height=Math.max(0,i._icArea.height),this._marginOffset.copyFrom(i._icPos),this._contentArea.copyFrom(i._icArea))},Object.defineProperty(i.prototype,"contentArea",{get:function(){return this._isFlagSet(e.SmartPropertyPrim.flagPositioningDirty)&&(this._updatePositioning(),this._clearFlags(e.SmartPropertyPrim.flagPositioningDirty)),this._contentArea},enumerable:!0,configurable:!0}),i.prototype._patchHierarchy=function(t){if(this._owner=t,null==this._renderGroup){if(this instanceof e.Group2D){var i=this;i.detectGroupStates(),i._trackedNode&&!i._isFlagSet(e.SmartPropertyPrim.flagTrackedGroup)&&i.owner._registerTrackedNode(this)}if(this._parent&&(this._renderGroup=this.parent.traverseUp(function(t){return t instanceof e.Group2D&&t.isRenderableGroup}),this._parentLayoutDirty()),this._renderGroup&&this.isDirty){var r=this._renderGroup._renderableData._primDirtyList,n=r.indexOf(this);-1===n&&r.push(this)}for(var o=0,s=this._children;o<s.length;o++){var a=s[o];this._patchHierarchyDepth(a),a._patchHierarchy(t)}}},i.prototype._patchHierarchyDepth=function(t){t._hierarchyDepth=this._hierarchyDepth+1,t._hierarchyDepthOffset=this._hierarchyDepthOffset+(this._children.length+1)*this._siblingDepthOffset,t._siblingDepthOffset=this._siblingDepthOffset/e.Canvas2D.hierarchyLevelMaxSiblingCount},i.prototype._getInitialContentAreaToRef=function(e,t,i){i.width=e.width,i.height=e.height,t.x=t.y=0},i.PRIM2DBASE_PROPCOUNT=15,i._nullPosition=e.Vector2.Zero(),i.boundinbBoxReentrency=!1,i.nullSize=e.Size.Zero(),i._isCanvasInit=!1,i._t0=new e.Matrix,i._t1=new e.Matrix,i._t2=new e.Matrix,i._v0=e.Vector2.Zero(),i._icPos=e.Vector2.Zero(),i._icArea=e.Size.Zero(),i._size=e.Size.Zero(),__decorate([e.instanceLevelProperty(1,function(e){return i.actualPositionProperty=e},!1,!0)],i.prototype,"actualPosition",null),__decorate([e.dynamicLevelProperty(1,function(e){return i.positionProperty=e},!1,!0)],i.prototype,"position",null),__decorate([e.dynamicLevelProperty(2,function(e){return i.sizeProperty=e},!1,!0)],i.prototype,"size",null),__decorate([e.instanceLevelProperty(3,function(e){return i.rotationProperty=e},!1,!0)],i.prototype,"rotation",null),__decorate([e.instanceLevelProperty(4,function(e){return i.scaleProperty=e},!1,!0)],i.prototype,"scale",null),__decorate([e.dynamicLevelProperty(5,function(e){return i.originProperty=e},!1,!0)],i.prototype,"origin",null),__decorate([e.dynamicLevelProperty(6,function(e){return i.levelVisibleProperty=e})],i.prototype,"levelVisible",null),__decorate([e.instanceLevelProperty(7,function(e){return i.isVisibleProperty=e})],i.prototype,"isVisible",null),__decorate([e.instanceLevelProperty(8,function(e){return i.zOrderProperty=e})],i.prototype,"zOrder",null),__decorate([e.dynamicLevelProperty(9,function(e){return i.marginProperty=e})],i.prototype,"margin",null),__decorate([e.dynamicLevelProperty(10,function(e){return i.paddingProperty=e})],i.prototype,"padding",null),__decorate([e.dynamicLevelProperty(11,function(e){return i.marginAlignmentProperty=e})],i.prototype,"marginAlignment",null),i=__decorate([e.className("Prim2DBase")],i)}(e.SmartPropertyPrim);e.Prim2DBase=h}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(t,i,r){this._partCount=r,this.owner=t,this.modelRenderCache=i,this.modelRenderCache.addRef(),this.partIndexFromId=new e.StringDictionary,this._usedShaderCategories=new Array(r),this._strides=new Array(r),this._opaqueData=null,this._alphaTestData=null,this._transparentData=null,this.opaqueDirty=this.alphaTestDirty=this.transparentDirty=this.transparentOrderDirty=!1}return t.prototype.dispose=function(){if(this._isDisposed)return!1;this.modelRenderCache&&this.modelRenderCache.dispose();var e=this.owner.owner.engine;return this.opaqueData&&(this.opaqueData.forEach(function(t){return t.dispose(e)}),this.opaqueData=null),this.partIndexFromId=null,this._isDisposed=!0,!0},Object.defineProperty(t.prototype,"hasOpaqueData",{get:function(){return null!=this._opaqueData},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"hasAlphaTestData",{get:function(){return null!=this._alphaTestData},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"hasTransparentData",{get:function(){return null!=this._transparentData},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"opaqueData",{get:function(){if(!this._opaqueData){this._opaqueData=new Array(this._partCount);for(var e=0;e<this._partCount;e++)this._opaqueData[e]=new r(this._strides[e])}return this._opaqueData},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"alphaTestData",{get:function(){if(!this._alphaTestData){this._alphaTestData=new Array(this._partCount);for(var e=0;e<this._partCount;e++)this._alphaTestData[e]=new r(this._strides[e])}return this._alphaTestData},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"transparentData",{get:function(){if(!this._transparentData){this._transparentData=new Array(this._partCount);for(var e=0;e<this._partCount;e++){var t=this.modelRenderCache._partData[e]._zBiasOffset;this._transparentData[e]=new n(this._strides[e],t)}}return this._transparentData},enumerable:!0,configurable:!0}),t.prototype.sortTransparentData=function(){if(this.transparentOrderDirty){for(var e=0;e<this._transparentData.length;e++){var t=this._transparentData[e];t._partData.sort()}this.transparentOrderDirty=!1}},Object.defineProperty(t.prototype,"usedShaderCategories",{get:function(){return this._usedShaderCategories},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"strides",{get:function(){return this._strides},enumerable:!0,configurable:!0}),t}();e.GroupInstanceInfo=t;var i=function(){function e(){}return e}();e.TransparentSegment=i;var r=function(){function t(t){this._partData=null,this._partBuffer=null,this._partBufferSize=0,this._partData=new e.DynamicFloatArray(t/4,50),this._isDisposed=!1}return t.prototype.dispose=function(e){return this._isDisposed?!1:(this._partBuffer&&(e._releaseBuffer(this._partBuffer),this._partBuffer=null),this._partData=null,void(this._isDisposed=!0))},t}();e.GroupInfoPartData=r;var n=function(e){function t(t,i){e.call(this,t),this._partData.compareValueOffset=i,this._partData.sortingAscending=!1}return __extends(t,e),t}(r);e.TransparentGroupInfoPartData=n;var o=function(){function t(t,i){this._engine=t,this._modelKey=i,this._nextKey=1,this._refCounter=1,this._instancesData=new e.StringDictionary,this._partData=null}return t.prototype.dispose=function(){if(0!==--this._refCounter)return!1;var e=this._engine.getExternalData("__BJSCANVAS2D__");return e&&e.DisposeModelRenderCache(this),!0},Object.defineProperty(t.prototype,"isDisposed",{get:function(){return this._refCounter<=0},enumerable:!0,configurable:!0}),t.prototype.addRef=function(){return++this._refCounter},Object.defineProperty(t.prototype,"modelKey",{get:function(){return this._modelKey},enumerable:!0,configurable:!0}),t.prototype.render=function(e,t){return!0},t.prototype.addInstanceDataParts=function(e){var t=this._nextKey.toString();if(!this._instancesData.add(t,e))throw Error("Key: "+t+" is already allocated");return++this._nextKey,t},t.prototype.removeInstanceData=function(e){this._instancesData.remove(e)},t.prototype.getPartIndexFromId=function(e){for(var t=0;t<this._partData.length;t++)if(this._partData[t]._partId===e)return t;return null},t.prototype.loadInstancingAttributes=function(e,t){var i=this.getPartIndexFromId(e);if(null===i)return null;var r=this._partsClassInfo[i],n=this._partData[i]._partUsedCategories,o=r.classContent.getInstancingAttributeInfos(t,n);return o},t.prototype.setupUniforms=function(e,i,r,n){var o=this._partData[i],s=o._partDataStride/4*n,a=this._partsClassInfo[i];a.fullContent.forEach(function(i,n){if(!n.category||-1!==o._partUsedCategories.indexOf(n.category))switch(n.dataType){case 4:var a=n.instanceOffset.get(o._partJoinedUsedCategories);e.setFloat(n.attributeName,r.buffer[s+a]);break;case 0:var a=n.instanceOffset.get(o._partJoinedUsedCategories);t.v2.x=r.buffer[s+a+0],t.v2.y=r.buffer[s+a+1],e.setVector2(n.attributeName,t.v2);break;case 5:case 1:var a=n.instanceOffset.get(o._partJoinedUsedCategories);t.v3.x=r.buffer[s+a+0],t.v3.y=r.buffer[s+a+1],t.v3.z=r.buffer[s+a+2],e.setVector3(n.attributeName,t.v3);break;case 6:case 2:var a=n.instanceOffset.get(o._partJoinedUsedCategories);t.v4.x=r.buffer[s+a+0],t.v4.y=r.buffer[s+a+1],t.v4.z=r.buffer[s+a+2],t.v4.w=r.buffer[s+a+3],e.setVector4(n.attributeName,t.v4)}})},t.v2=e.Vector2.Zero(),t.v3=e.Vector3.Zero(),t.v4=e.Vector4.Zero(),t}();e.ModelRenderCache=o;var s=function(){function e(){}return e}();e.ModelRenderCachePartData=s}(BABYLON||(BABYLON={}));var BABYLON;!function(e){function t(t,n){return function(o,s,a){var h=e.ClassTreeInfo.getOrRegister(o,function(e){return new i(e)}),c=h.getLevelOf(o),l=s;n=n||l;var u=c.levelContent.get(l);if(u)throw new Error("The ID "+l+" is already taken by another instance data");u=new r,u.attributeName=n,u.category=t||null,u.category&&(u.delimitedCategory=";"+u.category+";"),c.levelContent.add(l,u),a.get=function(){return null},a.set=function(e){if(!u.category||-1!==i._CurCategories.indexOf(u.delimitedCategory)){u.size?u.instanceOffset.contains(i._CurCategories)||c.classContent.mapProperty(u,!1):(u.setSize(e),c.classContent.mapProperty(u,!0));var t=this;if(t.dataBuffer&&t.dataElements){var r=t.dataElements[t.curElement].offset+u.instanceOffset.get(i._CurCategories);u.writeData(t.dataBuffer.buffer,r,e)}}}}}var i=function(){function t(t){this._baseInfo=t,this._nextOffset=new e.StringDictionary,this._attributes=new Array}return t.prototype.mapProperty=function(e,i){var r=this._nextOffset.getOrAdd(t._CurCategories,0);e.instanceOffset.add(t._CurCategories,this._getBaseOffset(t._CurCategories)+r),this._nextOffset.set(t._CurCategories,r+e.size/4),i&&this._attributes.push(e)},t.prototype.getInstancingAttributeInfos=function(t,i){for(var r=";"+i.join(";")+";",n=new Array,o=this;o;){for(var s=0,a=o._attributes;s<a.length;s++){var h=a[s];if(!h.category||-1!==i.indexOf(h.category)){var c=t.getAttributeLocationByName(h.attributeName),l=new e.InstancingAttributeInfo;l.index=c,l.attributeSize=h.size/4,l.offset=4*h.instanceOffset.get(r),l.attributeName=h.attributeName,n.push(l)}}o=o._baseInfo}return n},t.prototype.getShaderAttributes=function(e){for(var t=new Array,i=this;i;){for(var r=0,n=i._attributes;r<n.length;r++){var o=n[r];o.category&&-1===e.indexOf(o.category)||t.push(o.attributeName)}i=i._baseInfo}return t},t.prototype._getBaseOffset=function(e){for(var t=0,i=this._baseInfo;i;)t+=i._nextOffset.getOrAdd(e,0),i=i._baseInfo;return t},t}();e.InstanceClassInfo=i;var r=function(){function t(){this.instanceOffset=new e.StringDictionary}return t.prototype.setSize=function(t){if(t instanceof e.Vector2)return this.size=8,void(this.dataType=0);if(t instanceof e.Vector3)return this.size=12,void(this.dataType=1);if(t instanceof e.Vector4)return this.size=16,void(this.dataType=2);if(t instanceof e.Matrix)throw new Error("Matrix type is not supported by WebGL Instance Buffer, you have to use four Vector4 properties instead");return"number"==typeof t?(this.size=4,void(this.dataType=4)):t instanceof e.Color3?(this.size=12,void(this.dataType=5)):t instanceof e.Color4?(this.size=16,void(this.dataType=6)):t instanceof e.Size?(this.size=8,void(this.dataType=7)):void 0},t.prototype.writeData=function(e,t,i){switch(this.dataType){case 0:var r=i;e[t+0]=r.x,e[t+1]=r.y;break;case 1:var r=i;e[t+0]=r.x,e[t+1]=r.y,e[t+2]=r.z;break;case 2:var r=i;e[t+0]=r.x,e[t+1]=r.y,e[t+2]=r.z,e[t+3]=r.w;break;case 5:var r=i;e[t+0]=r.r,e[t+1]=r.g,e[t+2]=r.b;break;case 6:var r=i;e[t+0]=r.r,e[t+1]=r.g,e[t+2]=r.b,e[t+3]=r.a;break;case 4:var r=i;e[t]=r;break;case 3:for(var r=i,n=0;16>n;n++)e[t+n]=r.m[n];break;case 7:var o=i;e[t+0]=o.width,e[t+1]=o.height}},t}();e.InstancePropInfo=r,e.instanceData=t;var n=function(){function i(e,t){this.id=e,this.curElement=0,this.dataElementCount=t}return Object.defineProperty(i.prototype,"zBias",{get:function(){return null},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"transformX",{get:function(){return null},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"transformY",{get:function(){return null},enumerable:!0,configurable:!0}),i.prototype.getClassTreeInfo=function(){return this.typeInfo||(this.typeInfo=e.ClassTreeInfo.get(Object.getPrototypeOf(this))),this.typeInfo},i.prototype.allocElements=function(){if(this.dataBuffer){for(var e=new Array(this.dataElementCount),t=0;t<this.dataElementCount;t++)e[t]=this.dataBuffer.allocElement();this.dataElements=e}},i.prototype.freeElements=function(){if(this.dataElements){for(var e=0,t=this.dataElements;e<t.length;e++){var i=t[e];this.dataBuffer.freeElement(i)}this.dataElements=null}},Object.defineProperty(i.prototype,"dataElementCount",{get:function(){return this._dataElementCount},set:function(e){e!==this._dataElementCount&&(this.freeElements(),this._dataElementCount=e,this.allocElements())},enumerable:!0,configurable:!0}),__decorate([t()],i.prototype,"zBias",null),__decorate([t()],i.prototype,"transformX",null),__decorate([t()],i.prototype,"transformY",null),i}();e.InstanceDataBase=n;var o=function(t){function r(e){t.call(this,e),this._isTransparent=!1,this._isAlphaTest=!1,this._transparentPrimitiveInfo=null}return __extends(r,t),Object.defineProperty(r.prototype,"isAlphaTest",{get:function(){return this._isAlphaTest},set:function(e){this._isAlphaTest=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"isTransparent",{get:function(){return this._isTransparent},set:function(e){this._isTransparent=e},enumerable:!0,configurable:!0}),r.prototype.dispose=function(){return t.prototype.dispose.call(this)?(this._transparentPrimitiveInfo&&(this.renderGroup._renderableData.removeTransparentPrimitiveInfo(this._transparentPrimitiveInfo),this._transparentPrimitiveInfo=null),this._modelRenderInstanceID&&(this._modelRenderCache.removeInstanceData(this._modelRenderInstanceID),this._modelRenderInstanceID=null),this._modelRenderCache&&(this._modelRenderCache.dispose(),this._modelRenderCache=null),this._instanceDataParts&&(this._instanceDataParts.forEach(function(e){e.freeElements()}),this._instanceDataParts=null),!0):!1},r.prototype._prepareRenderPre=function(i){t.prototype._prepareRenderPre.call(this,i),this._isFlagSet(e.SmartPropertyPrim.flagModelDirty)&&this._modelRenderInstanceID&&(this._modelRenderCache.removeInstanceData(this._modelRenderInstanceID),this._modelRenderInstanceID=null);var r=!1;this._modelRenderCache&&!this._isFlagSet(e.SmartPropertyPrim.flagModelDirty)||(r=this._createModelRenderCache());var n=null,o=!1;this._modelRenderInstanceID||(o=!0,n=this._createModelDataParts()),r&&this.setupModelRenderCache(this._modelRenderCache),(this._isFlagSet(e.SmartPropertyPrim.flagVisibilityChanged)||i.forceRefreshPrimitive||o||0!==this._instanceDirtyFlags||this._globalTransformProcessStep!==this._globalTransformStep)&&(this.isTransparent,this._updateInstanceDataParts(n))},r.prototype._createModelRenderCache=function(){var t=this,i=!1;return this._modelRenderCache&&this._modelRenderCache.dispose(),this._modelRenderCache=this.owner._engineData.GetOrAddModelCache(this.modelKey,function(e){var r=t.createModelRenderCache(e);return i=!0,r}),this._clearFlags(e.SmartPropertyPrim.flagModelDirty),i||this._modelRenderCache.addRef(),i},r.prototype._createModelDataParts=function(){var t=this,i=this.createInstanceDataParts();this._instanceDataParts=i,this._modelRenderCache._partData||this._setupModelRenderCache(i);var r=this.renderGroup._renderableData._renderGroupInstancesInfo.getOrAddWithFactory(this.modelKey,function(i){for(var r=new e.GroupInstanceInfo(t.renderGroup,t._modelRenderCache,t._modelRenderCache._partData.length),n=0;n<t._modelRenderCache._partData.length;n++){var o=t._instanceDataParts[n];r.partIndexFromId.add(o.id.toString(),n),r.usedShaderCategories[n]=";"+t.getUsedShaderCategories(o).join(";")+";",r.strides[n]=t._modelRenderCache._partData[n]._partDataStride}return r}),n=null;n=this.isTransparent?r.transparentData:this.isAlphaTest?r.alphaTestData:r.opaqueData;for(var o=0;o<i.length;o++){var s=i[o];s.dataBuffer=n[o]._partData,s.allocElements()}return this._modelRenderInstanceID=this._modelRenderCache.addInstanceDataParts(this._instanceDataParts),r},r.prototype._setupModelRenderCache=function(t){var r=new Array;this._modelRenderCache._partData=new Array;for(var n=0;n<t.length;n++){var o=t[n],s=new e.ModelRenderCachePartData;this._modelRenderCache._partData.push(s);var a=this.getUsedShaderCategories(o),h=o.getClassTreeInfo(),c=this.isVisible;this.isVisible=!0;var l=";"+a.join(";")+";";s._partJoinedUsedCategories=l,i._CurCategories=l;var u=this.beforeRefreshForLayoutConstruction(o);this.refreshInstanceDataPart(o),this.afterRefreshForLayoutConstruction(o,u),this.isVisible=c;var f=0;h.fullContent.forEach(function(t,i){i.category&&-1===a.indexOf(i.category)||("zBias"===i.attributeName&&(s._zBiasOffset=i.instanceOffset.get(l)),i.size?f+=i.size:console.log("ERROR: Couldn't detect the size of the Property "+i.attributeName+" from type "+e.Tools.getClassName(h.type)+". Property is ignored."))}),s._partDataStride=f,s._partUsedCategories=a,s._partId=o.id,r.push(h)}this._modelRenderCache._partsClassInfo=r},r.prototype.onZOrderChanged=function(){if(this.isTransparent&&this._transparentPrimitiveInfo){this.renderGroup._renderableData.transparentPrimitiveZChanged(this._transparentPrimitiveInfo);var e=this.renderGroup._renderableData._renderGroupInstancesInfo.get(this.modelKey);e.transparentOrderDirty=!0}},r.prototype._updateInstanceDataParts=function(t){t||(t=this.renderGroup._renderableData._renderGroupInstancesInfo.get(this.modelKey)),this.isTransparent&&this._isFlagSet(e.SmartPropertyPrim.flagVisibilityChanged)&&(this.isVisible?this._transparentPrimitiveInfo||(this._transparentPrimitiveInfo=this.renderGroup._renderableData.addNewTransparentPrimitiveInfo(this,t)):this._transparentPrimitiveInfo&&(this.renderGroup._renderableData.removeTransparentPrimitiveInfo(this._transparentPrimitiveInfo),this._transparentPrimitiveInfo=null),t.transparentOrderDirty=!0);for(var r=0,n=this._instanceDataParts;r<n.length;r++){var o=n[r];this._isFlagSet(e.SmartPropertyPrim.flagVisibilityChanged)&&!o.dataElements&&o.allocElements(),i._CurCategories=t.usedShaderCategories[t.partIndexFromId.get(o.id.toString())],this.refreshInstanceDataPart(o)||o.dataElements&&o.freeElements()}this._instanceDirtyFlags=0,this.isTransparent?t.transparentDirty=!0:this.isAlphaTest?t.alphaTestDirty=!0:t.opaqueDirty=!0,this._clearFlags(e.SmartPropertyPrim.flagVisibilityChanged)},r.prototype._getFirstIndexInDataBuffer=function(){for(var e=0,t=this._instanceDataParts;e<t.length;e++){var i=t[e];if(i)return i.dataElements[0].offset/i.dataBuffer.stride}return null},r.prototype._getLastIndexInDataBuffer=function(){for(var e=0,t=this._instanceDataParts;e<t.length;e++){var i=t[e];if(i)return i.dataElements[i.dataElements.length-1].offset/i.dataBuffer.stride}return null},r.prototype._getNextPrimZOrder=function(){for(var e=this._instanceDataParts.length,t=0;e>t;t++){var i=this._instanceDataParts[t];if(i){var r=i.dataBuffer.stride,n=i.dataElements[i.dataElements.length-1].offset;return i.dataBuffer.totalElementCount*r<=n?null:i.dataBuffer[n+r+this.modelRenderCache._partData[t]._zBiasOffset]}}return null},r.prototype._getPrevPrimZOrder=function(){for(var e=this._instanceDataParts.length,t=0;e>t;t++){var i=this._instanceDataParts[t];if(i){var r=i.dataBuffer.stride,n=i.dataElements[0].offset;return 0===n?null:i.dataBuffer[n-r+this.modelRenderCache._partData[t]._zBiasOffset]}}return null},r.prototype.transformPointWithOriginByRef=function(e,t,i){var r=this.actualSize;i.x=e.x-(this.origin.x+(t?t.x:0))*r.width,i.y=e.y-(this.origin.y+(t?t.y:0))*r.height},r.prototype.transformPointWithOriginToRef=function(e,t,i){return this.transformPointWithOriginByRef(e,t,i),i},r.prototype.getDataPartEffectInfo=function(t,i,r){void 0===r&&(r=null);var n=e.Tools.first(this._instanceDataParts,function(e){return e.id===t});if(!n)return null;var o=this.owner.supportInstancedArray;if(null!=r){if(r&&o===!1)return null;o=r}var s=n.getClassTreeInfo(),a=this.getUsedShaderCategories(n),h=s.classContent.getShaderAttributes(a),c="";return a.forEach(function(e){c+="#define "+e+"\n"}),o&&(c+="#define Instanced\n"),{attributes:o?i.concat(h):i,uniforms:o?[]:h,defines:c}},Object.defineProperty(r.prototype,"modelRenderCache",{get:function(){return this._modelRenderCache},enumerable:!0,configurable:!0}),r.prototype.createModelRenderCache=function(e){return null},r.prototype.setupModelRenderCache=function(e){},r.prototype.createInstanceDataParts=function(){return null},r.prototype.getUsedShaderCategories=function(e){return[]},r.prototype.beforeRefreshForLayoutConstruction=function(e){},r.prototype.afterRefreshForLayoutConstruction=function(e,t){},r.prototype.refreshInstanceDataPart=function(e){return this.isVisible?(e.isVisible=this.isVisible,1===e.dataElementCount&&(e.curElement=0,this.updateInstanceDataPart(e)),!0):!1},r.prototype.updateInstanceDataPart=function(t,i){void 0===i&&(i=null);var r=this._globalTransform.multiply(this.renderGroup.invGlobalTransform),n=this.renderGroup.viewportSize,o=this.actualZOffset,s=0,a=0;i&&(s=i.x*r.m[0]+i.y*r.m[4],a=i.x*r.m[1]+i.y*r.m[5]);var h=n.width,c=n.height,l=1/o,u=new e.Vector4(2*r.m[0]/h,2*r.m[4]/h,0,2*(r.m[12]+s)/h-1),f=new e.Vector4(2*r.m[1]/c,2*r.m[5]/c,0,2*(r.m[13]+a)/c-1);t.transformX=u,t.transformY=f,t.zBias=new e.Vector2(o,l)},r.RENDERABLEPRIM2D_PROPCOUNT=e.Prim2DBase.PRIM2DBASE_PROPCOUNT+5,__decorate([e.dynamicLevelProperty(e.Prim2DBase.PRIM2DBASE_PROPCOUNT+0,function(e){return r.isAlphaTestProperty=e})],r.prototype,"isAlphaTest",null),__decorate([e.dynamicLevelProperty(e.Prim2DBase.PRIM2DBASE_PROPCOUNT+1,function(e){return r.isTransparentProperty=e})],r.prototype,"isTransparent",null),r=__decorate([e.className("RenderablePrim2D")],r)}(e.Prim2DBase);e.RenderablePrim2D=o}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(t){function i(i){t.call(this,i),i||(i={});var r=null;i.border&&(r="string"==typeof i.border?e.Canvas2D.GetBrushFromString(i.border):i.border);var n=null;i.fill&&(n="string"==typeof i.fill?e.Canvas2D.GetBrushFromString(i.fill):i.fill),this.border=r,this.fill=n,this.borderThickness=i.borderThickness}return __extends(i,t),Object.defineProperty(i.prototype,"border",{get:function(){return this._border},set:function(e){this._border=e,this._updateTransparencyStatus()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"fill",{get:function(){return this._fill},set:function(e){this._fill=e,this._updateTransparencyStatus()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"borderThickness",{get:function(){return this._borderThickness},set:function(e){this._borderThickness=e},enumerable:!0,configurable:!0}),i.prototype.getUsedShaderCategories=function(r){var n=t.prototype.getUsedShaderCategories.call(this,r);if(r.id===i.SHAPE2D_FILLPARTID){var o=this.fill;o instanceof e.SolidColorBrush2D&&n.push(i.SHAPE2D_CATEGORY_FILLSOLID),o instanceof e.GradientColorBrush2D&&n.push(i.SHAPE2D_CATEGORY_FILLGRADIENT)}if(r.id===i.SHAPE2D_BORDERPARTID){n.push(i.SHAPE2D_CATEGORY_BORDER);var s=this.border;s instanceof e.SolidColorBrush2D&&n.push(i.SHAPE2D_CATEGORY_BORDERSOLID),s instanceof e.GradientColorBrush2D&&n.push(i.SHAPE2D_CATEGORY_BORDERGRADIENT)}return n},i.prototype.refreshInstanceDataPart=function(r){if(!t.prototype.refreshInstanceDataPart.call(this,r))return!1;if(r.id===i.SHAPE2D_FILLPARTID){var n=r;if(this.fill){var o=this.fill;if(o instanceof e.SolidColorBrush2D)n.fillSolidColor=o.color;else if(o instanceof e.GradientColorBrush2D){n.fillGradientColor1=o.color1,n.fillGradientColor2=o.color2;var s=e.Matrix.Compose(new e.Vector3(o.scale,o.scale,o.scale),e.Quaternion.RotationAxis(new e.Vector3(0,0,1),o.rotation),new e.Vector3(o.translation.x,o.translation.y,0)),a=new e.Vector4(s.m[1],s.m[5],s.m[9],s.m[13]);n.fillGradientTY=a}}}else if(r.id===i.SHAPE2D_BORDERPARTID){var n=r;if(this.border){n.borderThickness=this.borderThickness;var h=this.border;if(h instanceof e.SolidColorBrush2D)n.borderSolidColor=h.color;else if(h instanceof e.GradientColorBrush2D){n.borderGradientColor1=h.color1,n.borderGradientColor2=h.color2;var s=e.Matrix.Compose(new e.Vector3(h.scale,h.scale,h.scale),e.Quaternion.RotationAxis(new e.Vector3(0,0,1),h.rotation),new e.Vector3(h.translation.x,h.translation.y,0)),a=new e.Vector4(s.m[1],s.m[5],s.m[9],s.m[13]);n.borderGradientTY=a}}}return!0},i.prototype._updateTransparencyStatus=function(){this.isTransparent=this._border&&this._border.isTransparent()||this._fill&&this._fill.isTransparent()},i.SHAPE2D_BORDERPARTID=1,i.SHAPE2D_FILLPARTID=2,i.SHAPE2D_CATEGORY_BORDER="Border",i.SHAPE2D_CATEGORY_BORDERSOLID="BorderSolid",i.SHAPE2D_CATEGORY_BORDERGRADIENT="BorderGradient",i.SHAPE2D_CATEGORY_FILLSOLID="FillSolid",
  25. i.SHAPE2D_CATEGORY_FILLGRADIENT="FillGradient",i.SHAPE2D_PROPCOUNT=e.RenderablePrim2D.RENDERABLEPRIM2D_PROPCOUNT+5,__decorate([e.modelLevelProperty(e.RenderablePrim2D.RENDERABLEPRIM2D_PROPCOUNT+1,function(e){return i.borderProperty=e},!0)],i.prototype,"border",null),__decorate([e.modelLevelProperty(e.RenderablePrim2D.RENDERABLEPRIM2D_PROPCOUNT+2,function(e){return i.fillProperty=e},!0)],i.prototype,"fill",null),__decorate([e.instanceLevelProperty(e.RenderablePrim2D.RENDERABLEPRIM2D_PROPCOUNT+3,function(e){return i.borderThicknessProperty=e})],i.prototype,"borderThickness",null),i=__decorate([e.className("Shape2D")],i)}(e.RenderablePrim2D);e.Shape2D=t;var i=function(i){function r(){i.apply(this,arguments)}return __extends(r,i),Object.defineProperty(r.prototype,"fillSolidColor",{get:function(){return null},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"fillGradientColor1",{get:function(){return null},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"fillGradientColor2",{get:function(){return null},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"fillGradientTY",{get:function(){return null},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"borderThickness",{get:function(){return null},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"borderSolidColor",{get:function(){return null},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"borderGradientColor1",{get:function(){return null},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"borderGradientColor2",{get:function(){return null},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"borderGradientTY",{get:function(){return null},enumerable:!0,configurable:!0}),__decorate([e.instanceData(t.SHAPE2D_CATEGORY_FILLSOLID)],r.prototype,"fillSolidColor",null),__decorate([e.instanceData(t.SHAPE2D_CATEGORY_FILLGRADIENT)],r.prototype,"fillGradientColor1",null),__decorate([e.instanceData(t.SHAPE2D_CATEGORY_FILLGRADIENT)],r.prototype,"fillGradientColor2",null),__decorate([e.instanceData(t.SHAPE2D_CATEGORY_FILLGRADIENT)],r.prototype,"fillGradientTY",null),__decorate([e.instanceData(t.SHAPE2D_CATEGORY_BORDER)],r.prototype,"borderThickness",null),__decorate([e.instanceData(t.SHAPE2D_CATEGORY_BORDERSOLID)],r.prototype,"borderSolidColor",null),__decorate([e.instanceData(t.SHAPE2D_CATEGORY_BORDERGRADIENT)],r.prototype,"borderGradientColor1",null),__decorate([e.instanceData(t.SHAPE2D_CATEGORY_BORDERGRADIENT)],r.prototype,"borderGradientColor2",null),__decorate([e.instanceData(t.SHAPE2D_CATEGORY_BORDERGRADIENT)],r.prototype,"borderGradientTY",null),r}(e.InstanceDataBase);e.Shape2DInstanceData=i}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(t){function r(i){null==i&&(i={}),null==i.origin&&(i.origin=new e.Vector2(0,0)),t.call(this,i);var n=i.size||i.width||i.height?i.size||new e.Size(i.width||0,i.height||0):null;this._trackedNode=null==i.trackNode?null:i.trackNode,this._trackedNode&&this.owner&&this.owner._registerTrackedNode(this),this._cacheBehavior=null==i.cacheBehavior?r.GROUPCACHEBEHAVIOR_FOLLOWCACHESTRATEGY:i.cacheBehavior,this.size=n,this._viewportPosition=e.Vector2.Zero()}return __extends(r,t),r._createCachedCanvasGroup=function(t){var i=new r({parent:t,id:"__cachedCanvasGroup__",position:e.Vector2.Zero(),origin:e.Vector2.Zero(),size:null,isVisible:!0});return i},r.prototype.applyCachedTexture=function(t,i){if(this._bindCacheTarget(),t)for(var r=t.uvs,n=this._renderableData._cacheNode.UVs,o=0;4>o;o++)r[2*o+0]=n[o].x,r[2*o+1]=n[o].y;i&&(i.diffuseTexture=this._renderableData._cacheTexture,i.emissiveColor=new e.Color3(1,1,1)),this._renderableData._cacheTexture.hasAlpha=!0,this._unbindCacheTarget()},Object.defineProperty(r.prototype,"cachedRect",{get:function(){return this._renderableData?this._renderableData._cacheNode:null},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"cacheTexture",{get:function(){return this._renderableData?this._renderableData._cacheTexture:null},enumerable:!0,configurable:!0}),r.prototype.dispose=function(){return t.prototype.dispose.call(this)?(null!=this._trackedNode&&(this.owner._unregisterTrackedNode(this),this._trackedNode=null),this._renderableData&&(this._renderableData.dispose(),this._renderableData=null),!0):!1},Object.defineProperty(r.prototype,"isRenderableGroup",{get:function(){return this._isRenderableGroup},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"isCachedGroup",{get:function(){return this._isCachedGroup},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"size",{get:function(){return this._size},set:function(e){this._size=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"viewportSize",{get:function(){return this._viewportSize},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"actualSize",{get:function(){var t;if(this._size)t=new e.Size(Math.ceil(this._size.width),Math.ceil(this._size.height));else{var i=this.boundingInfo.max();t=new e.Size(Math.ceil(i.x),Math.ceil(i.y))}return t.equals(this._actualSize)||(this.onPrimitivePropertyDirty(r.actualSizeProperty.flagId),this._actualSize=t,this.handleGroupChanged(r.actualSizeProperty)),t},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"cacheBehavior",{get:function(){return this._cacheBehavior},enumerable:!0,configurable:!0}),r.prototype._addPrimToDirtyList=function(e){this._renderableData._primDirtyList.push(e)},r.prototype._renderCachedCanvas=function(){this.updateCachedStates(!0);var t=new e.PrepareRender2DContext;this._prepareGroupRender(t),this._groupRender()},Object.defineProperty(r.prototype,"trackedNode",{get:function(){return this._trackedNode},set:function(t){null!=t?(this._isFlagSet(e.SmartPropertyPrim.flagTrackedGroup)||this.owner._registerTrackedNode(this),this._trackedNode=t):(this._isFlagSet(e.SmartPropertyPrim.flagTrackedGroup)&&this.owner._unregisterTrackedNode(this),this._trackedNode=null)},enumerable:!0,configurable:!0}),r.prototype.levelIntersect=function(e){return!0},r.prototype.updateLevelBoundingInfo=function(){var t;t=this.size?this.size:new e.Size(0,0),e.BoundingInfo2D.CreateFromSizeToRef(t,this._levelBoundingInfo)},r.prototype._prepareGroupRender=function(t){var i=null;if((this._renderableData._primDirtyList.length>0||t.forceRefreshPrimitive)&&(i=this._renderableData._primDirtyList.sort(function(e,t){return e.hierarchyDepth-t.hierarchyDepth}),this.updateCachedStatesOf(i,!0)),this._isCachedGroup){var r=this.actualSize.clone();r.equals(this._viewportSize)||(t.forceRefreshPrimitive=!0),this._viewportSize=r}else{var n=this._globalTransform.getTranslation(),o=this.actualSize.clone(),s=this.owner._renderingSize;o.height=Math.min(o.height,s.height-n.y),o.width=Math.min(o.width,s.width-n.x);var a=n.x,h=n.y;this._viewportPosition.x=a,this._viewportPosition.y=h;var c=o.width,l=o.height;this._viewportSize?(this._viewportSize.width===c&&this._viewportSize.height===l||(t.forceRefreshPrimitive=!0),this._viewportSize.width=c,this._viewportSize.height=l):this._viewportSize=new e.Size(c,l)}if(this._renderableData._primDirtyList.length>0||t.forceRefreshPrimitive)if(this._cacheGroupDirty=this._isCachedGroup,t.forceRefreshPrimitive)for(var u=0,f=this._children;u<f.length;u++){var d=f[u];d._prepareRender(t)}else i||(i=this._renderableData._primDirtyList.sort(function(e,t){return e.hierarchyDepth-t.hierarchyDepth})),i.forEach(function(e){!e.isDisposed&&e._needPrepare()&&e._prepareRender(t)}),this._renderableData._primDirtyList.forEach(function(e){return e._resetPropertiesDirty()}),this._renderableData._primDirtyList.splice(0);this._renderableData._childrenRenderableGroups.forEach(function(e){e._prepareGroupRender(t)})},r.prototype._groupRender=function(){for(var t=this,i=this.owner.engine,r=0,n=0,o=this._renderableData._childrenRenderableGroups;n<o.length;n++){var s=o[n];s._groupRender()}if(!this.isCachedGroup||this._cacheGroupDirty){if(this.isCachedGroup)this._bindCacheTarget();else var a=i.setDirectViewport(this._viewportPosition.x,this._viewportPosition.y,this._viewportSize.width,this._viewportSize.height);var h=i.getAlphaTesting()===!0,c=i.getDepthWrite()===!0;i.setAlphaTesting(!1),i.setDepthWrite(!0);var l=new e.Render2DContext(e.Render2DContext.RenderModeOpaque);this._renderableData._renderGroupInstancesInfo.forEach(function(e,n){var o=t._prepareContext(i,l,n);if(null!==o&&(!t.owner.supportInstancedArray||o>0)){var s=!n.modelRenderCache.render(n,l);n.opaqueDirty=s,r+=s?1:0}}),i.setAlphaTesting(!0),i.setDepthWrite(!0),l=new e.Render2DContext(e.Render2DContext.RenderModeAlphaTest),this._renderableData._renderGroupInstancesInfo.forEach(function(e,n){var o=t._prepareContext(i,l,n);if(null!==o&&(!t.owner.supportInstancedArray||o>0)){var s=!n.modelRenderCache.render(n,l);n.opaqueDirty=s,r+=s?1:0}}),i.setAlphaTesting(!0),i.setDepthWrite(!1),this._renderableData._transparentListChanged&&this._updateTransparentData(),r+=this._renderTransparentData(),this._cacheGroupDirty=0!==r,this.isCachedGroup?this._unbindCacheTarget():a&&i.setViewport(a),i.setAlphaTesting(h),i.setDepthWrite(c)}},r.prototype._updateTransparentData=function(){var t=this._renderableData;if(null!==t._firstChangedPrim){t._transparentPrimitives.sort(function(e,t){return t._primitive.actualZOffset-e._primitive.actualZOffset});var i=function(e,i){var r=t._transparentPrimitives[i];if(e.groupInsanceInfo!==r._groupInstanceInfo)return!1;var n=r._primitive.actualZOffset;return r._transparentSegment=e,n<e.endZ&&(e.endZ=n,e.endDataIndex=r._primitive._getLastIndexInDataBuffer()+1),!0};t._transparentSegments.splice(0);for(var r=null,n=0;n<t._transparentPrimitives.length;n++){var o=t._transparentPrimitives[n];if(o._groupInstanceInfo.transparentOrderDirty&&o._groupInstanceInfo.sortTransparentData(),o._transparentSegment=null,r&&i(r,n),!o._transparentSegment){var s=new e.TransparentSegment;s.groupInsanceInfo=o._groupInstanceInfo;var a=o._primitive;s.startZ=a.actualZOffset,s.startDataIndex=a._getFirstIndexInDataBuffer(),s.endDataIndex=a._getLastIndexInDataBuffer()+1,s.endZ=s.startZ,o._transparentSegment=s,t._transparentSegments.push(s)}r=o._transparentSegment}t._firstChangedPrim=null,t._transparentListChanged=!1}},r.prototype._renderTransparentData=function(){for(var t=0,i=new e.Render2DContext(e.Render2DContext.RenderModeTransparent),r=this._renderableData,n=r._transparentSegments.length,o=0;n>o;o++){var s=r._transparentSegments[o],a=s.groupInsanceInfo,h=a.modelRenderCache;i.useInstancing=!1,i.partDataStartIndex=s.startDataIndex,i.partDataEndIndex=s.endDataIndex,i.groupInfoPartData=a.transparentData;var c=!h.render(a,i);t+=c?1:0}return t},r.prototype._prepareContext=function(t,i,r){var n,o,s=null;switch(i.renderMode){case e.Render2DContext.RenderModeOpaque:if(!r.hasOpaqueData)return null;n=function(e){r.opaqueDirty=e},o=function(){return r.opaqueDirty},i.groupInfoPartData=r.opaqueData,s=r.opaqueData;break;case e.Render2DContext.RenderModeAlphaTest:if(!r.hasAlphaTestData)return null;n=function(e){r.alphaTestDirty=e},o=function(){return r.alphaTestDirty},i.groupInfoPartData=r.alphaTestData,s=r.alphaTestData;break;default:throw new Error("_prepareContext is only for opaque or alphaTest")}var a=0;if(this.owner.supportInstancedArray){i.useInstancing=!0;for(var h=0;h<s.length;h++){var c=s[h],l=c._partData,u=l.pack();a+=l.usedElementCount;var f=l.usedElementCount*l.stride*4;!c._partBuffer||c._partBufferSize<f?(c._partBuffer&&t.deleteInstancesBuffer(c._partBuffer),c._partBuffer=t.createInstancesBuffer(f),c._partBufferSize=f,n(!1),t.updateArrayBuffer(u)):o()&&(t.bindArrayBuffer(c._partBuffer),t.updateArrayBuffer(u))}n(!1)}else{i.partDataStartIndex=0;for(var h=0;!i.groupInfoPartData[h];)h++;i.partDataEndIndex=i.groupInfoPartData[h]._partData.usedElementCount}return a},r.prototype._bindCacheTarget=function(){var t,i,r=this._renderableData;if(r._cacheNode){var n=r._cacheNode.contentSize,o=Math.ceil(this.actualSize.width),s=Math.ceil(this.actualSize.height);(n.width<o||n.height<s)&&(t=Math.floor(1.07*n.width),i=Math.floor(1.07*n.height),r._cacheTexture.freeRect(r._cacheNode),r._cacheNode=null)}if(!r._cacheNode){var a=this.owner._allocateGroupCache(this,this.renderGroup,t?new e.Size(t,i):null);r._cacheNode=a.node,r._cacheTexture=a.texture,r._cacheRenderSprite=a.sprite;var n=r._cacheNode.contentSize}var h=r._cacheNode;r._cacheTexture.bindTextureForPosSize(h.pos,this.actualSize,!0)},r.prototype._unbindCacheTarget=function(){this._renderableData._cacheTexture&&this._renderableData._cacheTexture.unbindTexture()},r.prototype.handleGroupChanged=function(t){var i=this._renderableData;this.isCachedGroup&&i._cacheRenderSprite&&(t.id===e.Prim2DBase.actualPositionProperty.id?i._cacheRenderSprite.actualPosition=this.actualPosition.clone():t.id===e.Prim2DBase.rotationProperty.id?i._cacheRenderSprite.rotation=this.rotation:t.id===e.Prim2DBase.scaleProperty.id?i._cacheRenderSprite.scale=this.scale:t.id===e.Prim2DBase.originProperty.id?i._cacheRenderSprite.origin=this.origin.clone():t.id===r.actualSizeProperty.id&&(i._cacheRenderSprite.size=this.actualSize.clone()))},r.prototype.detectGroupStates=function(){var t=this instanceof e.Canvas2D,n=this.owner.cachingStrategy;if(n===e.Canvas2D.CACHESTRATEGY_DONTCACHE)this._isRenderableGroup=t,this._isCachedGroup=!1;else if(n===e.Canvas2D.CACHESTRATEGY_CANVAS)t?(this._isRenderableGroup=!0,this._isCachedGroup=!0):(this._isRenderableGroup="__cachedCanvasGroup__"===this.id,this._isCachedGroup=!1);else if(n===e.Canvas2D.CACHESTRATEGY_TOPLEVELGROUPS)t?(this._isRenderableGroup=!0,this._isCachedGroup=!1):1===this.hierarchyDepth?(this._isRenderableGroup=!0,this._isCachedGroup=!0):(this._isRenderableGroup=!1,this._isCachedGroup=!1);else if(n===e.Canvas2D.CACHESTRATEGY_ALLGROUPS){var o=this.cacheBehavior;o!==r.GROUPCACHEBEHAVIOR_DONTCACHEOVERRIDE&&o!==r.GROUPCACHEBEHAVIOR_CACHEINPARENTGROUP||(this._isRenderableGroup=o===r.GROUPCACHEBEHAVIOR_DONTCACHEOVERRIDE,this._isCachedGroup=!1),o===r.GROUPCACHEBEHAVIOR_FOLLOWCACHESTRATEGY&&(this._isRenderableGroup=!0,this._isCachedGroup=!0)}if(this._isRenderableGroup&&(this._renderableData||(this._renderableData=new i)),this._isCachedGroup)for(var s=this.parent;s;){if(s instanceof r&&s._isRenderableGroup){-1===s._renderableData._childrenRenderableGroups.indexOf(this)&&s._renderableData._childrenRenderableGroups.push(this);break}s=s.parent}},r.GROUP2D_PROPCOUNT=e.Prim2DBase.PRIM2DBASE_PROPCOUNT+5,r.GROUPCACHEBEHAVIOR_FOLLOWCACHESTRATEGY=0,r.GROUPCACHEBEHAVIOR_DONTCACHEOVERRIDE=1,r.GROUPCACHEBEHAVIOR_CACHEINPARENTGROUP=2,__decorate([e.instanceLevelProperty(e.Prim2DBase.PRIM2DBASE_PROPCOUNT+1,function(e){return r.sizeProperty=e},!1,!0)],r.prototype,"size",null),__decorate([e.instanceLevelProperty(e.Prim2DBase.PRIM2DBASE_PROPCOUNT+2,function(e){return r.actualSizeProperty=e})],r.prototype,"actualSize",null),r=__decorate([e.className("Group2D")],r)}(e.Prim2DBase);e.Group2D=t;var i=function(){function t(){this._primDirtyList=new Array,this._childrenRenderableGroups=new Array,this._renderGroupInstancesInfo=new e.StringDictionary,this._transparentPrimitives=new Array,this._transparentSegments=new Array,this._firstChangedPrim=null,this._transparentListChanged=!1,this._cacheNode=null,this._cacheTexture=null,this._cacheRenderSprite=null}return t.prototype.dispose=function(){this._cacheRenderSprite&&(this._cacheRenderSprite.dispose(),this._cacheRenderSprite=null),this._cacheTexture&&this._cacheNode&&(this._cacheTexture.freeRect(this._cacheNode),this._cacheTexture=null,this._cacheNode=null),this._primDirtyList&&(this._primDirtyList.splice(0),this._primDirtyList=null),this._renderGroupInstancesInfo&&(this._renderGroupInstancesInfo.forEach(function(e,t){t.dispose()}),this._renderGroupInstancesInfo=null)},t.prototype.addNewTransparentPrimitiveInfo=function(e,t){var i=new r;return i._primitive=e,i._groupInstanceInfo=t,i._transparentSegment=null,this._transparentPrimitives.push(i),this._transparentListChanged=!0,this.updateSmallestZChangedPrim(i),i},t.prototype.removeTransparentPrimitiveInfo=function(e){var t=this._transparentPrimitives.indexOf(e);-1!==t&&(this._transparentPrimitives.splice(t,1),this._transparentListChanged=!0,this.updateSmallestZChangedPrim(e))},t.prototype.transparentPrimitiveZChanged=function(e){this._transparentListChanged=!0,this.updateSmallestZChangedPrim(e)},t.prototype.updateSmallestZChangedPrim=function(e){if(e._primitive){var t=e._primitive.actualZOffset,i=this._firstChangedPrim?this._firstChangedPrim._primitive.actualZOffset:Number.MIN_VALUE;t>i&&(this._firstChangedPrim=e)}},t}();e.RenderableGroupData=i;var r=function(){function e(){}return e}();e.TransparentPrimitiveInfo=r}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(t){function i(e,i){t.call(this,e,i),this.effectsReady=!1,this.fillVB=null,this.fillIB=null,this.fillIndicesCount=0,this.instancingFillAttributes=null,this.effectFill=null,this.effectFillInstanced=null,this.borderVB=null,this.borderIB=null,this.borderIndicesCount=0,this.instancingBorderAttributes=null,this.effectBorder=null,this.effectBorderInstanced=null}return __extends(i,t),i.prototype.render=function(t,i){if(!this.effectsReady){if(this.effectFill&&(!this.effectFill.isReady()||this.effectFillInstanced&&!this.effectFillInstanced.isReady())||this.effectBorder&&(!this.effectBorder.isReady()||this.effectBorderInstanced&&!this.effectBorderInstanced.isReady()))return!1;this.effectsReady=!0}var r=t.owner.owner.engine,n=0;this.effectFill&&this.effectBorder&&(n=r.getDepthFunction(),r.setDepthFunctionToLessOrEqual());var o=r.getAlphaMode();if(this.effectFill){var s=t.partIndexFromId.get(e.Shape2D.SHAPE2D_FILLPARTID.toString()),a=i.groupInfoPartData[s];i.renderMode!==e.Render2DContext.RenderModeOpaque&&r.setAlphaMode(e.Engine.ALPHA_COMBINE);var h=i.useInstancing?this.effectFillInstanced:this.effectFill;if(r.enableEffect(h),r.bindBuffersDirectly(this.fillVB,this.fillIB,[1],4,h),i.useInstancing)this.instancingFillAttributes||(this.instancingFillAttributes=this.loadInstancingAttributes(e.Shape2D.SHAPE2D_FILLPARTID,h)),r.updateAndBindInstancesBuffer(a._partBuffer,null,this.instancingFillAttributes),r.draw(!0,0,this.fillIndicesCount,a._partData.usedElementCount),r.unbindInstanceAttributes();else for(var c=i.partDataStartIndex;c<i.partDataEndIndex;c++)this.setupUniforms(h,s,a._partData,c),r.draw(!0,0,this.fillIndicesCount)}if(this.effectBorder){var s=t.partIndexFromId.get(e.Shape2D.SHAPE2D_BORDERPARTID.toString()),a=i.groupInfoPartData[s];i.renderMode!==e.Render2DContext.RenderModeOpaque&&r.setAlphaMode(e.Engine.ALPHA_COMBINE);var h=i.useInstancing?this.effectBorderInstanced:this.effectBorder;if(r.enableEffect(h),r.bindBuffersDirectly(this.borderVB,this.borderIB,[1],4,h),i.useInstancing)this.instancingBorderAttributes||(this.instancingBorderAttributes=this.loadInstancingAttributes(e.Shape2D.SHAPE2D_BORDERPARTID,h)),r.updateAndBindInstancesBuffer(a._partBuffer,null,this.instancingBorderAttributes),r.draw(!0,0,this.borderIndicesCount,a._partData.usedElementCount),r.unbindInstanceAttributes();else for(var c=i.partDataStartIndex;c<i.partDataEndIndex;c++)this.setupUniforms(h,s,a._partData,c),r.draw(!0,0,this.borderIndicesCount)}return r.setAlphaMode(o),this.effectFill&&this.effectBorder&&r.setDepthFunction(n),!0},i.prototype.dispose=function(){return t.prototype.dispose.call(this)?(this.fillVB&&(this._engine._releaseBuffer(this.fillVB),this.fillVB=null),this.fillIB&&(this._engine._releaseBuffer(this.fillIB),this.fillIB=null),this.effectFill&&(this._engine._releaseEffect(this.effectFill),this.effectFill=null),this.effectFillInstanced&&(this._engine._releaseEffect(this.effectFillInstanced),this.effectFillInstanced=null),this.borderVB&&(this._engine._releaseBuffer(this.borderVB),this.borderVB=null),this.borderIB&&(this._engine._releaseBuffer(this.borderIB),this.borderIB=null),this.effectBorder&&(this._engine._releaseEffect(this.effectBorder),this.effectBorder=null),this.effectBorderInstanced&&(this._engine._releaseEffect(this.effectBorderInstanced),this.effectBorderInstanced=null),!0):!1},i}(e.ModelRenderCache);e.Rectangle2DRenderCache=t;var i=function(t){function i(e){t.call(this,e,1)}return __extends(i,t),Object.defineProperty(i.prototype,"properties",{get:function(){return null},enumerable:!0,configurable:!0}),__decorate([e.instanceData()],i.prototype,"properties",null),i}(e.Shape2DInstanceData);e.Rectangle2DInstanceData=i;var r=function(r){function n(t){if(null==t&&(t={}),r.call(this,t),null!=t.size)this.size=t.size;else if(t.width||t.height){var i=new e.Size(t.width,t.height);this.size=i}var n=null==t.roundRadius?0:t.roundRadius,o=null==t.borderThickness?1:t.borderThickness;this.roundRadius=n,this.borderThickness=o}return __extends(n,r),Object.defineProperty(n.prototype,"actualSize",{get:function(){return this._actualSize?this._actualSize:this.size},set:function(e){this._actualSize=e},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"notRounded",{get:function(){return this._notRounded},set:function(e){this._notRounded=e},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"roundRadius",{get:function(){return this._roundRadius},set:function(e){this._roundRadius=e,this.notRounded=0===e,this._positioningDirty()},enumerable:!0,configurable:!0}),n.prototype.levelIntersect=function(e){if(this.notRounded)return!0;var t=this.size;n._i0.x=e._localPickPosition.x,n._i0.y=e._localPickPosition.y;var i=this.roundRadius,r=i*i;return n._i1.x=i,n._i1.y=i,n._i0.x<=n._i1.x&&n._i0.y<=n._i1.y?(n._i2.x=n._i0.x-n._i1.x,n._i2.y=n._i0.y-n._i1.y,n._i2.lengthSquared()<=r):(n._i1.x=i,n._i1.y=t.height-i,n._i0.x<=n._i1.x&&n._i0.y>=n._i1.y?(n._i2.x=n._i0.x-n._i1.x,n._i2.y=n._i0.y-n._i1.y,n._i2.lengthSquared()<=r):(n._i1.x=t.width-i,n._i1.y=t.height-i,n._i0.x>=n._i1.x&&n._i0.y>=n._i1.y?(n._i2.x=n._i0.x-n._i1.x,n._i2.y=n._i0.y-n._i1.y,n._i2.lengthSquared()<=r):(n._i1.x=t.width-i,n._i1.y=i,n._i0.x>=n._i1.x&&n._i0.y<=n._i1.y?(n._i2.x=n._i0.x-n._i1.x,n._i2.y=n._i0.y-n._i1.y,n._i2.lengthSquared()<=r):!0)))},n.prototype.updateLevelBoundingInfo=function(){e.BoundingInfo2D.CreateFromSizeToRef(this.actualSize,this._levelBoundingInfo)},n.prototype.createModelRenderCache=function(e){var i=new t(this.owner.engine,e);return i},n.prototype.setupModelRenderCache=function(t){var i=t,r=this.owner.engine;if(this.fill){for(var o=4*(this.notRounded?1:n.roundSubdivisions)+1,s=new Float32Array(o),a=0;o>a;a++)s[a]=a;i.fillVB=r.createVertexBuffer(s);for(var h=o-1,c=new Float32Array(3*h),a=0;h>a;a++)c[3*a+0]=0,c[3*a+2]=a+1,c[3*a+1]=a+2;c[3*h-2]=1,i.fillIB=r.createIndexBuffer(c),i.fillIndicesCount=3*h;var l=this.getDataPartEffectInfo(e.Shape2D.SHAPE2D_FILLPARTID,["index"],!0);l&&(i.effectFillInstanced=r.createEffect("rect2d",l.attributes,l.uniforms,[],l.defines,null)),l=this.getDataPartEffectInfo(e.Shape2D.SHAPE2D_FILLPARTID,["index"],!1),i.effectFill=r.createEffect("rect2d",l.attributes,l.uniforms,[],l.defines,null)}if(this.border){for(var o=4*(this.notRounded?1:n.roundSubdivisions)*2,s=new Float32Array(o),a=0;o>a;a++)s[a]=a;i.borderVB=r.createVertexBuffer(s);for(var h=o,u=h/2,c=new Float32Array(3*h),a=0;u>a;a++){var f=a,d=(a+1)%u;c[6*a+0]=u+d,c[6*a+1]=u+f,c[6*a+2]=f,c[6*a+3]=d,c[6*a+4]=u+d,c[6*a+5]=f}i.borderIB=r.createIndexBuffer(c),i.borderIndicesCount=3*h;var l=this.getDataPartEffectInfo(e.Shape2D.SHAPE2D_BORDERPARTID,["index"],!0);l&&(i.effectBorderInstanced=r.createEffect("rect2d",l.attributes,l.uniforms,[],l.defines,null)),l=this.getDataPartEffectInfo(e.Shape2D.SHAPE2D_BORDERPARTID,["index"],!1),i.effectBorder=r.createEffect("rect2d",l.attributes,l.uniforms,[],l.defines,null)}return i},n.prototype._getInitialContentAreaToRef=function(e,t,i){if(this._notRounded)r.prototype._getInitialContentAreaToRef.call(this,e,t,i);else{var n=Math.round(1.3*(this.roundRadius-this.roundRadius/Math.sqrt(2)));t.x=t.y=n,i.width=Math.max(0,e.width-2*n),i.height=Math.max(0,e.height-2*n)}},n.prototype.createInstanceDataParts=function(){var t=new Array;return this.border&&t.push(new i(e.Shape2D.SHAPE2D_BORDERPARTID)),this.fill&&t.push(new i(e.Shape2D.SHAPE2D_FILLPARTID)),t},n.prototype.refreshInstanceDataPart=function(t){if(!r.prototype.refreshInstanceDataPart.call(this,t))return!1;if(t.id===e.Shape2D.SHAPE2D_BORDERPARTID){var i=t,n=this.actualSize;i.properties=new e.Vector3(n.width,n.height,this.roundRadius||0)}else if(t.id===e.Shape2D.SHAPE2D_FILLPARTID){var i=t,n=this.actualSize;i.properties=new e.Vector3(n.width,n.height,this.roundRadius||0)}return!0},n._i0=e.Vector2.Zero(),n._i1=e.Vector2.Zero(),n._i2=e.Vector2.Zero(),n.roundSubdivisions=16,__decorate([e.instanceLevelProperty(e.Shape2D.SHAPE2D_PROPCOUNT+1,function(e){return n.actualSizeProperty=e},!1,!0)],n.prototype,"actualSize",null),__decorate([e.modelLevelProperty(e.Shape2D.SHAPE2D_PROPCOUNT+2,function(e){return n.notRoundedProperty=e})],n.prototype,"notRounded",null),__decorate([e.instanceLevelProperty(e.Shape2D.SHAPE2D_PROPCOUNT+3,function(e){return n.roundRadiusProperty=e})],n.prototype,"roundRadius",null),n=__decorate([e.className("Rectangle2D")],n)}(e.Shape2D);e.Rectangle2D=r}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(t){function i(e,i){t.call(this,e,i),this.effectsReady=!1,this.fillVB=null,this.fillIB=null,this.fillIndicesCount=0,this.instancingFillAttributes=null,this.effectFillInstanced=null,this.effectFill=null,this.borderVB=null,this.borderIB=null,this.borderIndicesCount=0,this.instancingBorderAttributes=null,this.effectBorderInstanced=null,this.effectBorder=null}return __extends(i,t),i.prototype.render=function(t,i){if(!this.effectsReady){if(this.effectFill&&(!this.effectFill.isReady()||this.effectFillInstanced&&!this.effectFillInstanced.isReady())||this.effectBorder&&(!this.effectBorder.isReady()||this.effectBorderInstanced&&!this.effectBorderInstanced.isReady()))return!1;this.effectsReady=!0}var r=t.owner.owner.engine,n=0;this.effectFill&&this.effectBorder&&(n=r.getDepthFunction(),r.setDepthFunctionToLessOrEqual());var o=r.getAlphaMode();if(this.effectFill){var s=t.partIndexFromId.get(e.Shape2D.SHAPE2D_FILLPARTID.toString()),a=i.groupInfoPartData[s];i.renderMode!==e.Render2DContext.RenderModeOpaque&&r.setAlphaMode(e.Engine.ALPHA_COMBINE);var h=i.useInstancing?this.effectFillInstanced:this.effectFill;if(r.enableEffect(h),r.bindBuffersDirectly(this.fillVB,this.fillIB,[1],4,h),i.useInstancing)this.instancingFillAttributes||(this.instancingFillAttributes=this.loadInstancingAttributes(e.Shape2D.SHAPE2D_FILLPARTID,h)),r.updateAndBindInstancesBuffer(a._partBuffer,null,this.instancingFillAttributes),r.draw(!0,0,this.fillIndicesCount,a._partData.usedElementCount),r.unbindInstanceAttributes();else for(var c=i.partDataStartIndex;c<i.partDataEndIndex;c++)this.setupUniforms(h,s,a._partData,c),r.draw(!0,0,this.fillIndicesCount)}if(this.effectBorder){var s=t.partIndexFromId.get(e.Shape2D.SHAPE2D_BORDERPARTID.toString()),a=i.groupInfoPartData[s];i.renderMode!==e.Render2DContext.RenderModeOpaque&&r.setAlphaMode(e.Engine.ALPHA_COMBINE);var h=i.useInstancing?this.effectBorderInstanced:this.effectBorder;if(r.enableEffect(h),r.bindBuffersDirectly(this.borderVB,this.borderIB,[1],4,h),i.useInstancing)this.instancingBorderAttributes||(this.instancingBorderAttributes=this.loadInstancingAttributes(e.Shape2D.SHAPE2D_BORDERPARTID,h)),r.updateAndBindInstancesBuffer(a._partBuffer,null,this.instancingBorderAttributes),r.draw(!0,0,this.borderIndicesCount,a._partData.usedElementCount),r.unbindInstanceAttributes();else for(var c=i.partDataStartIndex;c<i.partDataEndIndex;c++)this.setupUniforms(h,s,a._partData,c),r.draw(!0,0,this.borderIndicesCount)}return r.setAlphaMode(o),this.effectFill&&this.effectBorder&&r.setDepthFunction(n),!0},i.prototype.dispose=function(){return t.prototype.dispose.call(this)?(this.fillVB&&(this._engine._releaseBuffer(this.fillVB),this.fillVB=null),this.fillIB&&(this._engine._releaseBuffer(this.fillIB),this.fillIB=null),this.effectFill&&(this._engine._releaseEffect(this.effectFill),this.effectFill=null),this.effectFillInstanced&&(this._engine._releaseEffect(this.effectFillInstanced),this.effectFillInstanced=null),this.borderVB&&(this._engine._releaseBuffer(this.borderVB),this.borderVB=null),this.borderIB&&(this._engine._releaseBuffer(this.borderIB),this.borderIB=null),this.effectBorder&&(this._engine._releaseEffect(this.effectBorder),this.effectBorder=null),this.effectBorderInstanced&&(this._engine._releaseEffect(this.effectBorderInstanced),this.effectBorderInstanced=null),!0):!1},i}(e.ModelRenderCache);e.Ellipse2DRenderCache=t;var i=function(t){function i(e){t.call(this,e,1)}return __extends(i,t),Object.defineProperty(i.prototype,"properties",{get:function(){return null},enumerable:!0,configurable:!0}),__decorate([e.instanceData()],i.prototype,"properties",null),i}(e.Shape2DInstanceData);e.Ellipse2DInstanceData=i;var r=function(r){function n(t){if(null==t&&(t={}),r.call(this,t),null!=t.size)this.size=t.size;else if(t.width||t.height){var i=new e.Size(t.width,t.height);this.size=i}var n=null==t.subdivisions?64:t.subdivisions;this.subdivisions=n}return __extends(n,r),Object.defineProperty(n.prototype,"actualSize",{get:function(){return this._actualSize?this._actualSize:this.size},set:function(e){this._actualSize=e},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"subdivisions",{get:function(){return this._subdivisions},set:function(e){this._subdivisions=e},enumerable:!0,configurable:!0}),n.prototype.levelIntersect=function(e){var t=this.size.width/2,i=this.size.height/2,r=e._localPickPosition.x-t,n=e._localPickPosition.y-i;return 1>=r*r/(t*t)+n*n/(i*i)},n.prototype.updateLevelBoundingInfo=function(){e.BoundingInfo2D.CreateFromSizeToRef(this.actualSize,this._levelBoundingInfo)},n.prototype.createModelRenderCache=function(e){var i=new t(this.owner.engine,e);return i},n.prototype.setupModelRenderCache=function(t){var i=t,r=this.owner.engine;if(this.fill){for(var n=this.subdivisions+1,o=new Float32Array(n),s=0;n>s;s++)o[s]=s;i.fillVB=r.createVertexBuffer(o);for(var a=n-1,h=new Float32Array(3*a),s=0;a>s;s++)h[3*s+0]=0,h[3*s+2]=s+1,h[3*s+1]=s+2;h[3*a-2]=1,i.fillIB=r.createIndexBuffer(h),i.fillIndicesCount=3*a;var c=this.getDataPartEffectInfo(e.Shape2D.SHAPE2D_FILLPARTID,["index"],!0);c&&(i.effectFillInstanced=r.createEffect({vertex:"ellipse2d",fragment:"ellipse2d"},c.attributes,c.uniforms,[],c.defines,null)),c=this.getDataPartEffectInfo(e.Shape2D.SHAPE2D_FILLPARTID,["index"],!1),i.effectFill=r.createEffect({vertex:"ellipse2d",fragment:"ellipse2d"},c.attributes,c.uniforms,[],c.defines,null)}if(this.border){for(var n=2*this.subdivisions,o=new Float32Array(n),s=0;n>s;s++)o[s]=s;i.borderVB=r.createVertexBuffer(o);for(var a=n,l=a/2,h=new Float32Array(3*a),s=0;l>s;s++){var u=s,f=(s+1)%l;h[6*s+0]=l+f,h[6*s+1]=l+u,h[6*s+2]=u,h[6*s+3]=f,h[6*s+4]=l+f,h[6*s+5]=u}i.borderIB=r.createIndexBuffer(h),i.borderIndicesCount=3*a;var c=this.getDataPartEffectInfo(e.Shape2D.SHAPE2D_BORDERPARTID,["index"],!0);c&&(i.effectBorderInstanced=r.createEffect("ellipse2d",c.attributes,c.uniforms,[],c.defines,null)),c=this.getDataPartEffectInfo(e.Shape2D.SHAPE2D_BORDERPARTID,["index"],!1),i.effectBorder=r.createEffect("ellipse2d",c.attributes,c.uniforms,[],c.defines,null)}return i},n.prototype.createInstanceDataParts=function(){var t=new Array;return this.border&&t.push(new i(e.Shape2D.SHAPE2D_BORDERPARTID)),this.fill&&t.push(new i(e.Shape2D.SHAPE2D_FILLPARTID)),t},n.prototype.refreshInstanceDataPart=function(t){if(!r.prototype.refreshInstanceDataPart.call(this,t))return!1;if(t.id===e.Shape2D.SHAPE2D_BORDERPARTID){var i=t,n=this.actualSize;i.properties=new e.Vector3(n.width,n.height,this.subdivisions)}else if(t.id===e.Shape2D.SHAPE2D_FILLPARTID){var i=t,n=this.actualSize;i.properties=new e.Vector3(n.width,n.height,this.subdivisions)}return!0},__decorate([e.instanceLevelProperty(e.Shape2D.SHAPE2D_PROPCOUNT+1,function(e){return n.acutalSizeProperty=e},!1,!0)],n.prototype,"actualSize",null),__decorate([e.modelLevelProperty(e.Shape2D.SHAPE2D_PROPCOUNT+2,function(e){return n.subdivisionsProperty=e;
  26. })],n.prototype,"subdivisions",null),n=__decorate([e.className("Ellipse2D")],n)}(e.Shape2D);e.Ellipse2D=r}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(t){function i(){t.apply(this,arguments),this.effectsReady=!1,this.vb=null,this.ib=null,this.instancingAttributes=null,this.texture=null,this.effect=null,this.effectInstanced=null}return __extends(i,t),i.prototype.render=function(t,i){if(!this.effectsReady){if(this.effect&&(!this.effect.isReady()||this.effectInstanced&&!this.effectInstanced.isReady()))return!1;this.effectsReady=!0}var n=t.owner.owner.engine,o=i.useInstancing?this.effectInstanced:this.effect;n.enableEffect(o),o.setTexture("diffuseSampler",this.texture),n.bindBuffersDirectly(this.vb,this.ib,[1],4,o);var s=n.getAlphaMode();i.renderMode!==e.Render2DContext.RenderModeOpaque&&n.setAlphaMode(e.Engine.ALPHA_COMBINE);var a=i.groupInfoPartData[0];if(i.useInstancing)this.instancingAttributes||(this.instancingAttributes=this.loadInstancingAttributes(r.SPRITE2D_MAINPARTID,o)),n.updateAndBindInstancesBuffer(a._partBuffer,null,this.instancingAttributes),n.draw(!0,0,6,a._partData.usedElementCount),n.unbindInstanceAttributes();else for(var h=i.partDataStartIndex;h<i.partDataEndIndex;h++)this.setupUniforms(o,0,a._partData,h),n.draw(!0,0,6);return n.setAlphaMode(s),!0},i.prototype.dispose=function(){return t.prototype.dispose.call(this)?(this.vb&&(this._engine._releaseBuffer(this.vb),this.vb=null),this.ib&&(this._engine._releaseBuffer(this.ib),this.ib=null),this.texture&&(this.texture.dispose(),this.texture=null),this.effect&&(this._engine._releaseEffect(this.effect),this.effect=null),this.effectInstanced&&(this._engine._releaseEffect(this.effectInstanced),this.effectInstanced=null),!0):!1},i}(e.ModelRenderCache);e.Sprite2DRenderCache=t;var i=function(t){function i(e){t.call(this,e,1)}return __extends(i,t),Object.defineProperty(i.prototype,"topLeftUV",{get:function(){return null},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"sizeUV",{get:function(){return null},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"textureSize",{get:function(){return null},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"properties",{get:function(){return null},enumerable:!0,configurable:!0}),__decorate([e.instanceData()],i.prototype,"topLeftUV",null),__decorate([e.instanceData()],i.prototype,"sizeUV",null),__decorate([e.instanceData()],i.prototype,"textureSize",null),__decorate([e.instanceData()],i.prototype,"properties",null),i}(e.InstanceDataBase);e.Sprite2DInstanceData=i;var r=function(r){function n(t,i){if(i||(i={}),r.call(this,i),this.texture=t,this.texture.wrapU=e.Texture.CLAMP_ADDRESSMODE,this.texture.wrapV=e.Texture.CLAMP_ADDRESSMODE,this.size=i.spriteSize||null,this.spriteLocation=i.spriteLocation||new e.Vector2(0,0),this.spriteFrame=0,this.invertY=null==i.invertY?!1:i.invertY,this.alignToPixel=null==i.alignToPixel?!0:i.alignToPixel,this._isTransparent=!0,!this.size){var n=t.getSize();this.size=new e.Size(n.width,n.height)}}return __extends(n,r),Object.defineProperty(n.prototype,"texture",{get:function(){return this._texture},set:function(e){this._texture=e},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"actualSize",{get:function(){return this._actualSize?this._actualSize:this.size},set:function(e){this._actualSize=e},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"spriteLocation",{get:function(){return this._location},set:function(e){this._location=e},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"spriteFrame",{get:function(){return this._spriteFrame},set:function(e){this._spriteFrame=e},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"invertY",{get:function(){return this._invertY},set:function(e){this._invertY=e},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"alignToPixel",{get:function(){return this._alignToPixel},set:function(e){this._alignToPixel=e},enumerable:!0,configurable:!0}),n.prototype.updateLevelBoundingInfo=function(){e.BoundingInfo2D.CreateFromSizeToRef(this.size,this._levelBoundingInfo)},n.prototype.getAnimatables=function(){var e=new Array;return this.texture&&this.texture.animations&&this.texture.animations.length>0&&e.push(this.texture),e},n.prototype.levelIntersect=function(e){return!0},n._createCachedCanvasSprite=function(t,i,r,o){var s=new n(i,{parent:t,id:"__cachedCanvasSprite__",position:e.Vector2.Zero(),origin:e.Vector2.Zero(),spriteSize:r,spriteLocation:o,alignToPixel:!0});return s},n.prototype.createModelRenderCache=function(e){var i=new t(this.owner.engine,e);return i},n.prototype.setupModelRenderCache=function(e){for(var t=e,i=this.owner.engine,r=new Float32Array(4),o=0;4>o;o++)r[o]=o;t.vb=i.createVertexBuffer(r);var s=new Float32Array(6);s[0]=0,s[1]=2,s[2]=1,s[3]=0,s[4]=3,s[5]=2,t.ib=i.createIndexBuffer(s),t.texture=this.texture;var a=this.getDataPartEffectInfo(n.SPRITE2D_MAINPARTID,["index"],!0);return a&&(t.effectInstanced=i.createEffect("sprite2d",a.attributes,a.uniforms,["diffuseSampler"],a.defines,null)),a=this.getDataPartEffectInfo(n.SPRITE2D_MAINPARTID,["index"],!1),t.effect=i.createEffect("sprite2d",a.attributes,a.uniforms,["diffuseSampler"],a.defines,null),t},n.prototype.createInstanceDataParts=function(){return[new i(n.SPRITE2D_MAINPARTID)]},n.prototype.refreshInstanceDataPart=function(t){if(!r.prototype.refreshInstanceDataPart.call(this,t))return!1;if(t.id===n.SPRITE2D_MAINPARTID){var i=this._instanceDataParts[0],o=this.texture.getBaseSize(),s=this.spriteLocation,a=this.actualSize;i.topLeftUV=new e.Vector2(s.x/o.width,s.y/o.height);var h=new e.Vector2(a.width/o.width,a.height/o.height);i.sizeUV=h,n._prop.x=this.spriteFrame,n._prop.y=this.invertY?1:0,n._prop.z=this.alignToPixel?1:0,i.properties=n._prop,i.textureSize=new e.Vector2(o.width,o.height)}return!0},n.SPRITE2D_MAINPARTID=1,n._prop=e.Vector3.Zero(),__decorate([e.modelLevelProperty(e.RenderablePrim2D.RENDERABLEPRIM2D_PROPCOUNT+1,function(e){return n.textureProperty=e})],n.prototype,"texture",null),__decorate([e.instanceLevelProperty(e.RenderablePrim2D.RENDERABLEPRIM2D_PROPCOUNT+2,function(e){return n.actualSizeProperty=e},!1,!0)],n.prototype,"actualSize",null),__decorate([e.instanceLevelProperty(e.RenderablePrim2D.RENDERABLEPRIM2D_PROPCOUNT+3,function(e){return n.spriteLocationProperty=e})],n.prototype,"spriteLocation",null),__decorate([e.instanceLevelProperty(e.RenderablePrim2D.RENDERABLEPRIM2D_PROPCOUNT+4,function(e){return n.spriteFrameProperty=e})],n.prototype,"spriteFrame",null),__decorate([e.instanceLevelProperty(e.RenderablePrim2D.RENDERABLEPRIM2D_PROPCOUNT+5,function(e){return n.invertYProperty=e})],n.prototype,"invertY",null),n=__decorate([e.className("Sprite2D")],n)}(e.RenderablePrim2D);e.Sprite2D=r}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(t){function i(){t.apply(this,arguments),this.effectsReady=!1,this.vb=null,this.ib=null,this.instancingAttributes=null,this.fontTexture=null,this.effect=null,this.effectInstanced=null}return __extends(i,t),i.prototype.render=function(t,i){if(!this.effectsReady){if(this.effect&&(!this.effect.isReady()||this.effectInstanced&&!this.effectInstanced.isReady()))return!1;this.effectsReady=!0}var n=t.owner.owner.engine;this.fontTexture.update();var o=i.useInstancing?this.effectInstanced:this.effect;n.enableEffect(o),o.setTexture("diffuseSampler",this.fontTexture),n.bindBuffersDirectly(this.vb,this.ib,[1],4,o);var s=n.getAlphaMode();n.setAlphaMode(e.Engine.ALPHA_COMBINE,!0);var a=i.groupInfoPartData[0];if(i.useInstancing)this.instancingAttributes||(this.instancingAttributes=this.loadInstancingAttributes(r.TEXT2D_MAINPARTID,o)),n.updateAndBindInstancesBuffer(a._partBuffer,null,this.instancingAttributes),n.draw(!0,0,6,a._partData.usedElementCount),n.unbindInstanceAttributes();else for(var h=i.partDataStartIndex;h<i.partDataEndIndex;h++)this.setupUniforms(o,0,a._partData,h),n.draw(!0,0,6);return n.setAlphaMode(s),!0},i.prototype.dispose=function(){return t.prototype.dispose.call(this)?(this.vb&&(this._engine._releaseBuffer(this.vb),this.vb=null),this.ib&&(this._engine._releaseBuffer(this.ib),this.ib=null),this.fontTexture&&(this.fontTexture.dispose(),this.fontTexture=null),this.effect&&(this._engine._releaseEffect(this.effect),this.effect=null),this.effectInstanced&&(this._engine._releaseEffect(this.effectInstanced),this.effectInstanced=null),!0):!1},i}(e.ModelRenderCache);e.Text2DRenderCache=t;var i=function(t){function i(e,i){t.call(this,e,i)}return __extends(i,t),Object.defineProperty(i.prototype,"topLeftUV",{get:function(){return null},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"sizeUV",{get:function(){return null},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"textureSize",{get:function(){return null},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"color",{get:function(){return null},enumerable:!0,configurable:!0}),__decorate([e.instanceData()],i.prototype,"topLeftUV",null),__decorate([e.instanceData()],i.prototype,"sizeUV",null),__decorate([e.instanceData()],i.prototype,"textureSize",null),__decorate([e.instanceData()],i.prototype,"color",null),i}(e.InstanceDataBase);e.Text2DInstanceData=i;var r=function(r){function n(t,i){i||(i={}),r.call(this,i),this.fontName=null==i.fontName?"12pt Arial":i.fontName,this.defaultFontColor=null==i.defaultFontColor?new e.Color4(1,1,1,1):i.defaultFontColor,this._tabulationSize=null==i.tabulationSize?4:i.tabulationSize,this._textSize=null,this.text=t,this.size=null==i.size?null:i.size,this.isAlphaTest=!0}return __extends(n,r),Object.defineProperty(n.prototype,"fontName",{get:function(){return this._fontName},set:function(e){if(this._fontName)throw new Error("Font Name change is not supported right now.");this._fontName=e},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"defaultFontColor",{get:function(){return this._defaultFontColor},set:function(e){this._defaultFontColor=e},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"text",{get:function(){return this._text},set:function(e){this._text=e,this._textSize=null,this._size=null,this._updateCharCount();this.textSize},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"size",{get:function(){return null!=this._size?this._size:this.textSize},set:function(e){this._size=e},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"actualSize",{get:function(){return this._actualSize?this._actualSize:this.size},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"textSize",{get:function(){if(!this._textSize){if(!this.owner)return n.nullSize;var t=this.fontTexture.measureText(this._text,this._tabulationSize);t.equals(this._textSize)||(this.onPrimitivePropertyDirty(e.Prim2DBase.sizeProperty.flagId),this._positioningDirty()),this._textSize=t}return this._textSize},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"fontTexture",{get:function(){return this._fontTexture?this._fontTexture:(this._fontTexture=e.FontTexture.GetCachedFontTexture(this.owner.scene,this.fontName),this._fontTexture)},enumerable:!0,configurable:!0}),n.prototype.dispose=function(){return r.prototype.dispose.call(this)?(this._fontTexture&&(e.FontTexture.ReleaseCachedFontTexture(this.owner.scene,this.fontName),this._fontTexture=null),!0):!1},n.prototype.updateLevelBoundingInfo=function(){e.BoundingInfo2D.CreateFromSizeToRef(this.actualSize,this._levelBoundingInfo)},n.prototype.levelIntersect=function(e){return!0},n.prototype.createModelRenderCache=function(e){var i=new t(this.owner.engine,e);return i},n.prototype.setupModelRenderCache=function(e){var t=e,i=this.owner.engine;t.fontTexture=this.fontTexture;for(var r=new Float32Array(4),o=0;4>o;o++)r[o]=o;t.vb=i.createVertexBuffer(r);var s=new Float32Array(6);s[0]=0,s[1]=2,s[2]=1,s[3]=0,s[4]=3,s[5]=2,t.ib=i.createIndexBuffer(s);var a=this.getDataPartEffectInfo(n.TEXT2D_MAINPARTID,["index"],!0);return a&&(t.effectInstanced=i.createEffect("text2d",a.attributes,a.uniforms,["diffuseSampler"],a.defines,null)),a=this.getDataPartEffectInfo(n.TEXT2D_MAINPARTID,["index"],!1),t.effect=i.createEffect("text2d",a.attributes,a.uniforms,["diffuseSampler"],a.defines,null),t},n.prototype.createInstanceDataParts=function(){return[new i(n.TEXT2D_MAINPARTID,this._charCount)]},n.prototype.beforeRefreshForLayoutConstruction=function(e){if(!this._charCount){var t=this._text;return this.text="A",t}},n.prototype.afterRefreshForLayoutConstruction=function(e,t){void 0!==t&&(this.text=t)},n.prototype.refreshInstanceDataPart=function(t){if(!r.prototype.refreshInstanceDataPart.call(this,t))return!1;if(t.id===n.TEXT2D_MAINPARTID){var i=t,o=this.fontTexture,s=o.getSize(),a=e.Vector2.Zero(),h=this.fontTexture.lineHeight;a.y=(this.textSize.height/h-1)*h;var c=0;i.dataElementCount=this._charCount,i.curElement=0;for(var l=0,u=this.text;l<u.length;l++){var f=u[l];if("\n"===f&&(a.x=0,a.y-=o.lineHeight)," "!==f){if(!(" ">f)){this.updateInstanceDataPart(i,a);var d=o.getChar(f);a.x+=d.charWidth,i.topLeftUV=d.topLeftUV;var p=d.bottomRightUV.subtract(d.topLeftUV);i.sizeUV=p,i.textureSize=new e.Vector2(s.width,s.height),i.color=this.defaultFontColor,++i.curElement}}else{var _=c+this._tabulationSize;_-=_%this._tabulationSize,a.x+=(_-c)*o.spaceWidth,c=_}}}return!0},n.prototype._updateCharCount=function(){for(var e=0,t=0,i=this._text;t<i.length;t++){var r=i[t];"\r"===r||"\n"===r||" "===r||" ">r||++e}this._charCount=e},n.TEXT2D_MAINPARTID=1,__decorate([e.modelLevelProperty(e.RenderablePrim2D.RENDERABLEPRIM2D_PROPCOUNT+1,function(e){return n.fontProperty=e},!1,!0)],n.prototype,"fontName",null),__decorate([e.dynamicLevelProperty(e.RenderablePrim2D.RENDERABLEPRIM2D_PROPCOUNT+2,function(e){return n.defaultFontColorProperty=e})],n.prototype,"defaultFontColor",null),__decorate([e.instanceLevelProperty(e.RenderablePrim2D.RENDERABLEPRIM2D_PROPCOUNT+3,function(e){return n.textProperty=e},!1,!0)],n.prototype,"text",null),__decorate([e.instanceLevelProperty(e.RenderablePrim2D.RENDERABLEPRIM2D_PROPCOUNT+4,function(e){return n.sizeProperty=e})],n.prototype,"size",null),n=__decorate([e.className("Text2D")],n)}(e.RenderablePrim2D);e.Text2D=r}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(t){function i(e,i){t.call(this,e,i),this.effectsReady=!1,this.fillVB=null,this.fillIB=null,this.fillIndicesCount=0,this.instancingFillAttributes=null,this.effectFill=null,this.effectFillInstanced=null,this.borderVB=null,this.borderIB=null,this.borderIndicesCount=0,this.instancingBorderAttributes=null,this.effectBorder=null,this.effectBorderInstanced=null}return __extends(i,t),i.prototype.render=function(t,i){if(!this.effectsReady){if(this.effectFill&&(!this.effectFill.isReady()||this.effectFillInstanced&&!this.effectFillInstanced.isReady())||this.effectBorder&&(!this.effectBorder.isReady()||this.effectBorderInstanced&&!this.effectBorderInstanced.isReady()))return!1;this.effectsReady=!0}var r=t.owner.owner.engine,n=0;this.effectFill&&this.effectBorder&&(n=r.getDepthFunction(),r.setDepthFunctionToLessOrEqual());var o=r.getAlphaMode();if(this.effectFill){var s=t.partIndexFromId.get(e.Shape2D.SHAPE2D_FILLPARTID.toString()),a=i.groupInfoPartData[s];i.renderMode!==e.Render2DContext.RenderModeOpaque&&r.setAlphaMode(e.Engine.ALPHA_COMBINE);var h=i.useInstancing?this.effectFillInstanced:this.effectFill;if(r.enableEffect(h),r.bindBuffersDirectly(this.fillVB,this.fillIB,[2],8,h),i.useInstancing)this.instancingFillAttributes||(this.instancingFillAttributes=this.loadInstancingAttributes(e.Shape2D.SHAPE2D_FILLPARTID,h)),r.updateAndBindInstancesBuffer(a._partBuffer,null,this.instancingFillAttributes),r.draw(!0,0,this.fillIndicesCount,a._partData.usedElementCount),r.unbindInstanceAttributes();else for(var c=i.partDataStartIndex;c<i.partDataEndIndex;c++)this.setupUniforms(h,s,a._partData,c),r.draw(!0,0,this.fillIndicesCount)}if(this.effectBorder){var s=t.partIndexFromId.get(e.Shape2D.SHAPE2D_BORDERPARTID.toString()),a=i.groupInfoPartData[s];i.renderMode!==e.Render2DContext.RenderModeOpaque&&r.setAlphaMode(e.Engine.ALPHA_COMBINE);var h=i.useInstancing?this.effectBorderInstanced:this.effectBorder;if(r.enableEffect(h),r.bindBuffersDirectly(this.borderVB,this.borderIB,[2],8,h),i.useInstancing)this.instancingBorderAttributes||(this.instancingBorderAttributes=this.loadInstancingAttributes(e.Shape2D.SHAPE2D_BORDERPARTID,h)),r.updateAndBindInstancesBuffer(a._partBuffer,null,this.instancingBorderAttributes),r.draw(!0,0,this.borderIndicesCount,a._partData.usedElementCount),r.unbindInstanceAttributes();else for(var c=i.partDataStartIndex;c<i.partDataEndIndex;c++)this.setupUniforms(h,s,a._partData,c),r.draw(!0,0,this.borderIndicesCount)}return r.setAlphaMode(o),this.effectFill&&this.effectBorder&&r.setDepthFunction(n),!0},i.prototype.dispose=function(){return t.prototype.dispose.call(this)?(this.fillVB&&(this._engine._releaseBuffer(this.fillVB),this.fillVB=null),this.fillIB&&(this._engine._releaseBuffer(this.fillIB),this.fillIB=null),this.effectFill&&(this._engine._releaseEffect(this.effectFill),this.effectFill=null),this.effectFillInstanced&&(this._engine._releaseEffect(this.effectFillInstanced),this.effectFillInstanced=null),this.borderVB&&(this._engine._releaseBuffer(this.borderVB),this.borderVB=null),this.borderIB&&(this._engine._releaseBuffer(this.borderIB),this.borderIB=null),this.effectBorder&&(this._engine._releaseEffect(this.effectBorder),this.effectBorder=null),this.effectBorderInstanced&&(this._engine._releaseEffect(this.effectBorderInstanced),this.effectBorderInstanced=null),!0):!1},i}(e.ModelRenderCache);e.Lines2DRenderCache=t;var i=function(t){function i(e){t.call(this,e,1)}return __extends(i,t),Object.defineProperty(i.prototype,"boundingMin",{get:function(){return null},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"boundingMax",{get:function(){return null},enumerable:!0,configurable:!0}),__decorate([e.instanceData(e.Shape2D.SHAPE2D_CATEGORY_FILLGRADIENT)],i.prototype,"boundingMin",null),__decorate([e.instanceData(e.Shape2D.SHAPE2D_CATEGORY_FILLGRADIENT)],i.prototype,"boundingMax",null),i}(e.Shape2DInstanceData);e.Lines2DInstanceData=i;var r=function(r){function n(t,i){i||(i={}),r.call(this,i),this._fillVB=null,this._fillIB=null,this._borderVB=null,this._borderIB=null,this._size=e.Size.Zero(),this._boundingMin=null,this._boundingMax=null;var n=null==i.fillThickness?1:i.fillThickness,o=null==i.startCap?0:i.startCap,s=null==i.endCap?0:i.endCap,a=null==i.closed?!1:i.closed;this.points=t,this.fillThickness=n,this.startCap=o,this.endCap=s,this.closed=a}return __extends(n,r),Object.defineProperty(n,"NoCap",{get:function(){return n._noCap},enumerable:!0,configurable:!0}),Object.defineProperty(n,"RoundCap",{get:function(){return n._roundCap},enumerable:!0,configurable:!0}),Object.defineProperty(n,"TriangleCap",{get:function(){return n._triangleCap},enumerable:!0,configurable:!0}),Object.defineProperty(n,"SquareAnchorCap",{get:function(){return n._squareAnchorCap},enumerable:!0,configurable:!0}),Object.defineProperty(n,"RoundAnchorCap",{get:function(){return n._roundAnchorCap},enumerable:!0,configurable:!0}),Object.defineProperty(n,"DiamondAnchorCap",{get:function(){return n._diamondAnchorCap},enumerable:!0,configurable:!0}),Object.defineProperty(n,"ArrowCap",{get:function(){return n._arrowCap},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"points",{get:function(){return this._points},set:function(e){this._points=e,this._boundingBoxDirty()},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"fillThickness",{get:function(){return this._fillThickness},set:function(e){this._fillThickness=e},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"closed",{get:function(){return this._closed},set:function(e){this._closed=e},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"startCap",{get:function(){return this._startCap},set:function(e){this._startCap=e},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"endCap",{get:function(){return this._endCap},set:function(e){this._endCap=e},enumerable:!0,configurable:!0}),n.prototype.levelIntersect=function(t){var i=this;null==this._contour&&this._computeLines2D();var r=this.points.length,o=this.closed?r+1:r,s=t._localPickPosition;this.transformPointWithOriginToRef(this._contour[0],null,n._prevA),this.transformPointWithOriginToRef(this._contour[1],null,n._prevB);for(var a=1;o>a;a++){if(this.transformPointWithOriginToRef(this._contour[a%r*2+0],null,n._curA),this.transformPointWithOriginToRef(this._contour[a%r*2+1],null,n._curB),e.Vector2.PointInTriangle(s,n._prevA,n._prevB,n._curA))return!0;if(e.Vector2.PointInTriangle(s,n._curA,n._prevB,n._curB))return!0;n._prevA.x=n._curA.x,n._prevA.y=n._curA.y,n._prevB.x=n._curB.x,n._prevB.y=n._curB.y}var h=function(t,r){for(var o=t.length,a=0;o>a;a+=3)if(n._curA.x=r[2*t[a+0]+0],n._curA.y=r[2*t[a+0]+1],i.transformPointWithOriginToRef(n._curA,null,n._curB),n._curA.x=r[2*t[a+1]+0],n._curA.y=r[2*t[a+1]+1],i.transformPointWithOriginToRef(n._curA,null,n._prevA),n._curA.x=r[2*t[a+2]+0],n._curA.y=r[2*t[a+2]+1],i.transformPointWithOriginToRef(n._curA,null,n._prevB),e.Vector2.PointInTriangle(s,n._prevA,n._prevB,n._curB))return!0;return!1};if(this._startCapTriIndices){if(h(this._startCapTriIndices,this._startCapContour))return!0;if(h(this._endCapTriIndices,this._endCapContour))return!0}return!1},Object.defineProperty(n.prototype,"boundingMin",{get:function(){return this._boundingMin||this._computeLines2D(),this._boundingMin},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"boundingMax",{get:function(){return this._boundingMax||this._computeLines2D(),this._boundingMax},enumerable:!0,configurable:!0}),n.prototype.getUsedShaderCategories=function(t){var i=r.prototype.getUsedShaderCategories.call(this,t),n=i.indexOf(e.Shape2D.SHAPE2D_CATEGORY_BORDER);return-1!==n&&i.splice(n,1),i},n.prototype.updateLevelBoundingInfo=function(){this._boundingMin||this._computeLines2D(),e.BoundingInfo2D.CreateFromMinMaxToRef(this._boundingMin.x,this._boundingMax.x,this._boundingMin.y,this._boundingMax.y,this._levelBoundingInfo)},n.prototype.createModelRenderCache=function(e){var i=new t(this.owner.engine,e);return i},n.prototype._perp=function(e,t){t.x=e.y,t.y=-e.x},n.prototype._direction=function(e,t,i){e.subtractToRef(t,i),i.normalize()},n.prototype._computeMiter=function(t,i,r,o){return r.addToRef(o,t),t.normalize(),i.x=-t.y,i.y=t.x,n._miterTps.x=-r.y,n._miterTps.y=r.x,1/e.Vector2.Dot(i,n._miterTps)},n.prototype._intersect=function(e,t,i,r,n,o,s,a){var h=(e-i)*(o-a)-(t-r)*(n-s);if(0===h)return!1;var c=((n-s)*(e*r-t*i)-(e-i)*(n*a-o*s))/h;return c<Math.min(e,i)||c>Math.max(e,i)?!1:!(c<Math.min(n,s)||c>Math.max(n,s))},n.prototype._updateMinMax=function(e,t){t>=e.length||(this._boundingMin.x=Math.min(this._boundingMin.x,e[t]),this._boundingMax.x=Math.max(this._boundingMax.x,e[t]),this._boundingMin.y=Math.min(this._boundingMin.y,e[t+1]),this._boundingMax.y=Math.max(this._boundingMax.y,e[t+1]))},n.prototype._store=function(t,i,r,o,s,a,h,c,l){var u=null!=c&&!isNaN(c),f=r*(u?8:4);if(!(f>=t.length)){0===r?this._perp(a,n._startDir):r===o-1&&(this._perp(a,n._endDir),n._endDir.x*=-1,n._endDir.y*=-1);var d=!1;if(t[f+0]=s.x+a.x*h,t[f+1]=s.y+a.y*h,t[f+2]=s.x+a.x*-h,t[f+3]=s.y+a.y*-h,this._updateMinMax(t,f),this._updateMinMax(t,f+2),void 0!==l){var p=l*(u?8:4);if(this._intersect(t[f+0],t[f+1],t[p+0],t[p+1],t[f+2],t[f+3],t[p+2],t[p+3])){d=!0;var _=t[f+0];t[f+0]=t[f+2],t[f+2]=_,_=t[f+1],t[f+1]=t[f+3],t[f+3]=_}}if(u){var m=h+c;t[f+4]=s.x+a.x*(d?-m:m),t[f+5]=s.y+a.y*(d?-m:m),t[f+6]=s.x+a.x*(d?m:-m),t[f+7]=s.y+a.y*(d?m:-m),this._updateMinMax(t,f+4),this._updateMinMax(t,f+6)}i&&(f+=u?4:0,i.push(new e.Vector2(t[f+0],t[f+1])),i.push(new e.Vector2(t[f+2],t[f+3])))}},n.prototype._getCapSize=function(e,t){void 0===t&&(t=!1);var i=n._roundCapSubDiv,r=0,o=0;switch(e){case n.NoCap:!this.closed&&t?(r=4,o=6):r=o=0;break;case n.RoundCap:t?(r=i,o=3*(i-2)):(r=i/2+1,o=i/2*3);break;case n.ArrowCap:t?(r=12,o=24):(r=3,o=3);break;case n.TriangleCap:t?(r=6,o=12):(r=3,o=3);break;case n.DiamondAnchorCap:t?(r=10,o=24):(r=5,o=9);break;case n.SquareAnchorCap:t?(r=12,o=30):(r=4,o=6);break;case n.RoundAnchorCap:t?(r=2*i,o=6*(i-1)):(r=i+1,o=3*(i+1))}return{vbsize:2*r,ibsize:o}},n.prototype._storeVertex=function(e,t,i,r,o,s,a){var h=Math.cos(o),c=Math.sin(o);n._tpsV.x=h*s.x+-c*s.y+r.x,n._tpsV.y=c*s.x+h*s.y+r.y;var l=t+2*i;return e[l+0]=n._tpsV.x,e[l+1]=n._tpsV.y,a&&(a.push(n._tpsV.x),a.push(n._tpsV.y)),this._updateMinMax(e,l),(t+2*i)/2},n.prototype._storeIndex=function(e,t,i,r){e[t+i]=r},n.prototype._buildCap=function(t,i,r,o,s,a,h,c,l,u){var f=n._roundCapSubDiv,d=new e.Vector2(1,0),p=Math.atan2(l.y,l.x)-Math.atan2(d.y,d.x),_=a/2,m=a,g=null!=h,v=h;switch(c){case n.NoCap:if(g&&!this.closed){var y=0,x=0,b=this._storeVertex(t,i,y++,s,p,new e.Vector2(0,_+v),u),P=this._storeVertex(t,i,y++,s,p,new e.Vector2(v,_+v),u),A=this._storeVertex(t,i,y++,s,p,new e.Vector2(v,-(_+v)),u),T=this._storeVertex(t,i,y++,s,p,new e.Vector2(0,-(_+v)),u);this._storeIndex(r,o,x++,b),this._storeIndex(r,o,x++,P),this._storeIndex(r,o,x++,A),this._storeIndex(r,o,x++,b),this._storeIndex(r,o,x++,A),this._storeIndex(r,o,x++,T)}break;case n.ArrowCap:_*=2;case n.TriangleCap:if(g){var E=c===n.TriangleCap?v:Math.sqrt(v*v*2),b=this._storeVertex(t,i,0,s,p,new e.Vector2(0,_),null),P=this._storeVertex(t,i,1,s,p,new e.Vector2(_,0),null),A=this._storeVertex(t,i,2,s,p,new e.Vector2(0,-_),null),T=this._storeVertex(t,i,3,s,p,new e.Vector2(0,_+E),u),C=this._storeVertex(t,i,4,s,p,new e.Vector2(_+E,0),u),S=this._storeVertex(t,i,5,s,p,new e.Vector2(0,-(_+E)),u),x=0;if(this._storeIndex(r,o,x++,b),this._storeIndex(r,o,x++,T),this._storeIndex(r,o,x++,C),this._storeIndex(r,o,x++,b),this._storeIndex(r,o,x++,C),this._storeIndex(r,o,x++,P),this._storeIndex(r,o,x++,S),this._storeIndex(r,o,x++,A),this._storeIndex(r,o,x++,P),this._storeIndex(r,o,x++,S),this._storeIndex(r,o,x++,P),this._storeIndex(r,o,x++,C),c===n.ArrowCap){var M=a/2,I=this._storeVertex(t,i,9,s,p,new e.Vector2(0,-(M+v)),null),D=this._storeVertex(t,i,11,s,p,new e.Vector2(-v,-(_+E)),u),R=this._storeVertex(t,i,10,s,p,new e.Vector2(-v,-(M+v)),u),O=this._storeVertex(t,i,6,s,p,new e.Vector2(0,M+v),null),w=this._storeVertex(t,i,7,s,p,new e.Vector2(-v,M+v),u),L=this._storeVertex(t,i,8,s,p,new e.Vector2(-v,_+E),u);this._storeIndex(r,o,x++,O),this._storeIndex(r,o,x++,w),this._storeIndex(r,o,x++,L),this._storeIndex(r,o,x++,O),this._storeIndex(r,o,x++,L),this._storeIndex(r,o,x++,T),this._storeIndex(r,o,x++,I),this._storeIndex(r,o,x++,D),this._storeIndex(r,o,x++,R),this._storeIndex(r,o,x++,I),this._storeIndex(r,o,x++,S),this._storeIndex(r,o,x++,D)}}else{var b=this._storeVertex(t,i,0,s,p,new e.Vector2(0,_),u),P=this._storeVertex(t,i,1,s,p,new e.Vector2(_,0),u),A=this._storeVertex(t,i,2,s,p,new e.Vector2(0,-_),u);this._storeIndex(r,o,0,b),this._storeIndex(r,o,1,P),this._storeIndex(r,o,2,A)}break;case n.RoundCap:if(g)for(var B=-Math.PI/2,V=Math.PI/(f/2-1),x=0,F=0;f/2>F;F++){var b=this._storeVertex(t,i,2*F+0,s,p,new e.Vector2(Math.cos(B)*_,Math.sin(B)*_),null),P=this._storeVertex(t,i,2*F+1,s,p,new e.Vector2(Math.cos(B)*(_+v),Math.sin(B)*(_+v)),u);F>0&&(this._storeIndex(r,o,x++,b-2),this._storeIndex(r,o,x++,P-2),this._storeIndex(r,o,x++,P),this._storeIndex(r,o,x++,b-2),this._storeIndex(r,o,x++,P),this._storeIndex(r,o,x++,b)),B+=V}else{var N=this._storeVertex(t,i,0,s,p,new e.Vector2(0,0),null),B=-Math.PI/2,V=Math.PI/(f/2-1);this._storeVertex(t,i,1,s,p,new e.Vector2(Math.cos(B)*_,Math.sin(B)*_),null),B+=V;for(var F=1;f/2>F;F++){var P=this._storeVertex(t,i,F+1,s,p,new e.Vector2(Math.cos(B)*_,Math.sin(B)*_),u);this._storeIndex(r,o,3*F+0,N),this._storeIndex(r,o,3*F+1,P-1),this._storeIndex(r,o,3*F+2,P),B+=V}}break;case n.SquareAnchorCap:var y=0,N=g?null:u,b=this._storeVertex(t,i,y++,s,p,new e.Vector2(0,m),N),P=this._storeVertex(t,i,y++,s,p,new e.Vector2(2*m,m),N),A=this._storeVertex(t,i,y++,s,p,new e.Vector2(2*m,-m),N),T=this._storeVertex(t,i,y++,s,p,new e.Vector2(0,-m),N);if(g){var C=this._storeVertex(t,i,y++,s,p,new e.Vector2(0,_+v),null),S=this._storeVertex(t,i,y++,s,p,new e.Vector2(-v,_+v),u),O=this._storeVertex(t,i,y++,s,p,new e.Vector2(-v,m+v),u),w=this._storeVertex(t,i,y++,s,p,new e.Vector2(2*m+v,m+v),u),L=this._storeVertex(t,i,y++,s,p,new e.Vector2(2*m+v,-(m+v)),u),I=this._storeVertex(t,i,y++,s,p,new e.Vector2(-v,-(m+v)),u),R=this._storeVertex(t,i,y++,s,p,new e.Vector2(-v,-(_+v)),u),D=this._storeVertex(t,i,y++,s,p,new e.Vector2(0,-(_+v)),null),x=0;this._storeIndex(r,o,x++,S),this._storeIndex(r,o,x++,b),this._storeIndex(r,o,x++,C),this._storeIndex(r,o,x++,S),this._storeIndex(r,o,x++,O),this._storeIndex(r,o,x++,b),this._storeIndex(r,o,x++,b),this._storeIndex(r,o,x++,O),this._storeIndex(r,o,x++,w),this._storeIndex(r,o,x++,b),this._storeIndex(r,o,x++,w),this._storeIndex(r,o,x++,P),this._storeIndex(r,o,x++,P),this._storeIndex(r,o,x++,w),this._storeIndex(r,o,x++,L),this._storeIndex(r,o,x++,P),this._storeIndex(r,o,x++,L),this._storeIndex(r,o,x++,A),this._storeIndex(r,o,x++,A),this._storeIndex(r,o,x++,L),this._storeIndex(r,o,x++,I),this._storeIndex(r,o,x++,A),this._storeIndex(r,o,x++,I),this._storeIndex(r,o,x++,T),this._storeIndex(r,o,x++,I),this._storeIndex(r,o,x++,R),this._storeIndex(r,o,x++,T),this._storeIndex(r,o,x++,R),this._storeIndex(r,o,x++,D),this._storeIndex(r,o,x++,T)}else this._storeIndex(r,o,0,b),this._storeIndex(r,o,1,P),this._storeIndex(r,o,2,A),this._storeIndex(r,o,3,b),this._storeIndex(r,o,4,A),this._storeIndex(r,o,5,T);break;case n.RoundAnchorCap:var z=Math.sqrt(m*m-_*_),k=new e.Vector2(z,0),B=e.Tools.ToRadians(-150),V=e.Tools.ToRadians(300)/(f-1);if(g)for(var x=0,F=0;f>F;F++){var b=this._storeVertex(t,i,2*F+0,s,p,new e.Vector2(z+Math.cos(B)*m,Math.sin(B)*m),null),P=this._storeVertex(t,i,2*F+1,s,p,new e.Vector2(z+Math.cos(B)*(m+v),Math.sin(B)*(m+v)),u);F>0&&(this._storeIndex(r,o,x++,b-2),this._storeIndex(r,o,x++,P-2),this._storeIndex(r,o,x++,P),this._storeIndex(r,o,x++,b-2),this._storeIndex(r,o,x++,P),this._storeIndex(r,o,x++,b)),B+=V}else{var N=this._storeVertex(t,i,0,s,p,k,null);this._storeVertex(t,i,1,s,p,new e.Vector2(z+Math.cos(B)*m,Math.sin(B)*m),null),B+=V;for(var F=1;f>F;F++){var P=this._storeVertex(t,i,F+1,s,p,new e.Vector2(z+Math.cos(B)*m,Math.sin(B)*m),u);this._storeIndex(r,o,3*F+0,N),this._storeIndex(r,o,3*F+1,P-1),this._storeIndex(r,o,3*F+2,P),B+=V}this._storeIndex(r,o,3*f+0,N),this._storeIndex(r,o,3*f+1,N+1),this._storeIndex(r,o,3*f+2,N+f)}break;case n.DiamondAnchorCap:var y=0,N=g?null:u,b=this._storeVertex(t,i,y++,s,p,new e.Vector2(0,_),N),P=this._storeVertex(t,i,y++,s,p,new e.Vector2(_,m),N),A=this._storeVertex(t,i,y++,s,p,new e.Vector2(3*_,0),N),T=this._storeVertex(t,i,y++,s,p,new e.Vector2(_,-m),N),C=this._storeVertex(t,i,y++,s,p,new e.Vector2(0,-_),N);if(g){var E=Math.sqrt(v*v*2),S=this._storeVertex(t,i,y++,s,p,new e.Vector2(-E,_),u),O=this._storeVertex(t,i,y++,s,p,new e.Vector2(_,m+E),u),w=this._storeVertex(t,i,y++,s,p,new e.Vector2(3*_+E,0),u),L=this._storeVertex(t,i,y++,s,p,new e.Vector2(_,-(m+E)),u),I=this._storeVertex(t,i,y++,s,p,new e.Vector2(-E,-_),u),x=0;this._storeIndex(r,o,x++,S),this._storeIndex(r,o,x++,O),this._storeIndex(r,o,x++,b),this._storeIndex(r,o,x++,b),this._storeIndex(r,o,x++,O),this._storeIndex(r,o,x++,P),this._storeIndex(r,o,x++,P),this._storeIndex(r,o,x++,O),this._storeIndex(r,o,x++,w),this._storeIndex(r,o,x++,P),this._storeIndex(r,o,x++,w),this._storeIndex(r,o,x++,A),this._storeIndex(r,o,x++,A),this._storeIndex(r,o,x++,w),this._storeIndex(r,o,x++,L),this._storeIndex(r,o,x++,A),this._storeIndex(r,o,x++,L),this._storeIndex(r,o,x++,T),this._storeIndex(r,o,x++,T),this._storeIndex(r,o,x++,L),this._storeIndex(r,o,x++,I),this._storeIndex(r,o,x++,T),this._storeIndex(r,o,x++,I),this._storeIndex(r,o,x++,C)}else this._storeIndex(r,o,0,b),this._storeIndex(r,o,1,P),this._storeIndex(r,o,2,A),this._storeIndex(r,o,3,b),this._storeIndex(r,o,4,A),this._storeIndex(r,o,5,C),this._storeIndex(r,o,6,C),
  27. this._storeIndex(r,o,7,A),this._storeIndex(r,o,8,T)}return null},n.prototype._buildLine=function(t,i,r,n){var o=e.Vector2.Zero(),s=e.Vector2.Zero(),a=e.Vector2.Zero(),h=e.Vector2.Zero(),c=null;this.closed&&this.points.push(this.points[0]);for(var l=this.points.length,u=1;l>u;u++){var f=this.points[u-1],d=this.points[u],p=u<this.points.length-1?this.points[u+1]:null;if(this._direction(d,f,o),c||(c=e.Vector2.Zero(),this._perp(o,c)),1===u&&this._store(t,i,0,l,this.points[0],c,r,n),p){this._direction(p,d,s);var _=this._computeMiter(a,h,o,s);this._store(t,i,u,l,this.points[u],h,_*r,_*n,u-1)}else this._perp(o,c),this._store(t,i,u,l,this.points[u],c,r,n,u-1)}if(this.points.length>2&&this.closed){var m=this.points[l-2],g=this.points[0],v=this.points[1];this._direction(g,m,o),this._direction(v,g,s),this._perp(o,c);var y=this._computeMiter(a,h,o,s);if(this._store(t,null,0,l,this.points[0],h,y*r,y*n,1),i){var x=null==n?0:4;i[0].x=t[x+0],i[0].y=t[x+1],i[1].x=t[x+2],i[1].y=t[x+3]}}this.closed&&this.points.splice(l-1)},n.prototype.setupModelRenderCache=function(t){var i=t,r=this.owner.engine;if(null===this._fillVB&&this._computeLines2D(),this.fill){i.fillVB=r.createVertexBuffer(this._fillVB),i.fillIB=r.createIndexBuffer(this._fillIB),i.fillIndicesCount=this._fillIB.length;var n=this.getDataPartEffectInfo(e.Shape2D.SHAPE2D_FILLPARTID,["position"],!0);n&&(i.effectFillInstanced=r.createEffect("lines2d",n.attributes,n.uniforms,[],n.defines,null)),n=this.getDataPartEffectInfo(e.Shape2D.SHAPE2D_FILLPARTID,["position"],!1),i.effectFill=r.createEffect("lines2d",n.attributes,n.uniforms,[],n.defines,null)}if(this.border){i.borderVB=r.createVertexBuffer(this._borderVB),i.borderIB=r.createIndexBuffer(this._borderIB),i.borderIndicesCount=this._borderIB.length;var n=this.getDataPartEffectInfo(e.Shape2D.SHAPE2D_BORDERPARTID,["position"],!0);n&&(i.effectBorderInstanced=r.createEffect({vertex:"lines2d",fragment:"lines2d"},n.attributes,n.uniforms,[],n.defines,null)),n=this.getDataPartEffectInfo(e.Shape2D.SHAPE2D_BORDERPARTID,["position"],!1),i.effectBorder=r.createEffect({vertex:"lines2d",fragment:"lines2d"},n.attributes,n.uniforms,[],n.defines,null)}return this._fillVB=null,this._fillIB=null,this._borderVB=null,this._borderIB=null,i},n.prototype._computeLines2D=function(){this._boundingMin=new e.Vector2(Number.MAX_VALUE,Number.MAX_VALUE),this._boundingMax=new e.Vector2(Number.MIN_VALUE,Number.MIN_VALUE);var t=new Array,i=new Array,r=new Array;if(this.fill){var o=this._getCapSize(this.startCap),s=this._getCapSize(this.endCap),a=this.points.length,h=2*a*2+o.vbsize+s.vbsize;this._fillVB=new Float32Array(h);var c=this._fillVB,l=this.fillThickness/2,u=this.points.length;this._buildLine(c,this.border?null:t,l);var f=2*u,d=2*(a-(this.closed?0:1));this._fillIB=new Float32Array(3*d+o.ibsize+s.ibsize);for(var p=this._fillIB,_=0;d>_;_+=2)p[3*_+0]=_+0,p[3*_+1]=_+1,p[3*_+2]=(_+2)%f,p[3*_+3]=_+1,p[3*_+4]=(_+3)%f,p[3*_+5]=(_+2)%f;this._buildCap(c,2*a*2,p,3*d,this.points[0],this.fillThickness,null,this.startCap,n._startDir,this.border?null:i),this._buildCap(c,2*a*2+o.vbsize,p,3*d+o.ibsize,this.points[u-1],this.fillThickness,null,this.endCap,n._endDir,this.border?null:i)}if(this.border){var o=this._getCapSize(this.startCap,!0),s=this._getCapSize(this.endCap,!0),a=this.points.length,h=2*a*2*2+o.vbsize+s.vbsize;this._borderVB=new Float32Array(h);var c=this._borderVB,l=this.fillThickness/2,m=this.borderThickness,u=this.points.length;this._buildLine(c,t,l,m);var f=2*u*2,d=2*(a-(this.closed?0:1))*2;this._borderIB=new Float32Array(3*d+o.ibsize+s.ibsize);for(var p=this._borderIB,_=0;d>_;_+=4)p[3*_+0]=_+0,p[3*_+1]=_+2,p[3*_+2]=(_+6)%f,p[3*_+3]=_+0,p[3*_+4]=(_+6)%f,p[3*_+5]=(_+4)%f,p[3*_+6]=_+3,p[3*_+7]=_+1,p[3*_+8]=(_+5)%f,p[3*_+9]=_+3,p[3*_+10]=(_+5)%f,p[3*_+11]=(_+7)%f;this._buildCap(c,2*a*2*2,p,3*d,this.points[0],this.fillThickness,this.borderThickness,this.startCap,n._startDir,i),this._buildCap(c,2*a*2*2+o.vbsize,p,3*d+o.ibsize,this.points[u-1],this.fillThickness,this.borderThickness,this.endCap,n._endDir,r)}if(this._contour=t,i.length>0){var g=Earcut.earcut(i,null,2);this._startCapTriIndices=g,this._startCapContour=i}if(r.length>0){var v=Earcut.earcut(r,null,2);this._endCapContour=r,this._endCapTriIndices=v}var y=this._boundingMax.subtract(this._boundingMin);this._size.width=y.x,this._size.height=y.y},Object.defineProperty(n.prototype,"size",{get:function(){return null==this._size&&this._computeLines2D(),this._size},enumerable:!0,configurable:!0}),n.prototype.createInstanceDataParts=function(){var t=new Array;return this.border&&t.push(new i(e.Shape2D.SHAPE2D_BORDERPARTID)),this.fill&&t.push(new i(e.Shape2D.SHAPE2D_FILLPARTID)),t},n.prototype.refreshInstanceDataPart=function(t){if(!r.prototype.refreshInstanceDataPart.call(this,t))return!1;if(t.id===e.Shape2D.SHAPE2D_BORDERPARTID){var i=t;this.border instanceof e.GradientColorBrush2D&&(i.boundingMin=this.boundingMin,i.boundingMax=this.boundingMax)}else if(t.id===e.Shape2D.SHAPE2D_FILLPARTID){var i=t;this.fill instanceof e.GradientColorBrush2D&&(i.boundingMin=this.boundingMin,i.boundingMax=this.boundingMax)}return!0},n._prevA=e.Vector2.Zero(),n._prevB=e.Vector2.Zero(),n._curA=e.Vector2.Zero(),n._curB=e.Vector2.Zero(),n._miterTps=e.Vector2.Zero(),n._startDir=e.Vector2.Zero(),n._endDir=e.Vector2.Zero(),n._tpsV=e.Vector2.Zero(),n._noCap=0,n._roundCap=1,n._triangleCap=2,n._squareAnchorCap=3,n._roundAnchorCap=4,n._diamondAnchorCap=5,n._arrowCap=6,n._roundCapSubDiv=36,__decorate([e.modelLevelProperty(e.Shape2D.SHAPE2D_PROPCOUNT+1,function(e){return n.pointsProperty=e})],n.prototype,"points",null),__decorate([e.modelLevelProperty(e.Shape2D.SHAPE2D_PROPCOUNT+2,function(e){return n.fillThicknessProperty=e})],n.prototype,"fillThickness",null),__decorate([e.modelLevelProperty(e.Shape2D.SHAPE2D_PROPCOUNT+3,function(e){return n.closedProperty=e})],n.prototype,"closed",null),__decorate([e.modelLevelProperty(e.Shape2D.SHAPE2D_PROPCOUNT+4,function(e){return n.startCapProperty=e})],n.prototype,"startCap",null),__decorate([e.modelLevelProperty(e.Shape2D.SHAPE2D_PROPCOUNT+5,function(e){return n.endCapProperty=e})],n.prototype,"endCap",null),n=__decorate([e.className("Lines2D")],n)}(e.Shape2D);e.Lines2D=r}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(){this._modelCache=new e.StringDictionary}return t.prototype.GetOrAddModelCache=function(e,t){return this._modelCache.getOrAddWithFactory(e,t)},t.prototype.DisposeModelRenderCache=function(e){return e.isDisposed?(this._modelCache.remove(e.modelKey),!0):!1},t}();e.Canvas2DEngineBoundData=t;var i=function(i){function r(n,o){var s=this;i.call(this,o),this.worldSpaceToNodeLocal=function(t){var i=s._worldSpaceNode;if(i){var r=i.getWorldMatrix().clone();r.invert();var n=e.Vector3.TransformCoordinates(t,r),o=s._renderScaleFactor,a=new e.Vector2(n.x*o,n.y*o),h=s.actualSize;s.origin;return a.x+=.5*h.width,a.y+=.5*h.width,a}},this._notifDebugMode=!1,this._mapCounter=0,e.Prim2DBase._isCanvasInit=!1,o||(o={});var a=null==o.renderScaleFactor?1:o.renderScaleFactor;this._cachingStrategy!==r.CACHESTRATEGY_TOPLEVELGROUPS&&(this._background=new e.Rectangle2D({parent:this,id:"###CANVAS BACKGROUND###",size:o.size}),this._background.zOrder=1,this._background.isPickable=!1,this._background.origin=e.Vector2.Zero(),this._background.levelVisible=!1,null!=o.backgroundRoundRadius&&(this.backgroundRoundRadius=o.backgroundRoundRadius),null!=o.backgroundBorder&&("string"==typeof o.backgroundBorder?this.backgroundBorder=r.GetBrushFromString(o.backgroundBorder):this.backgroundBorder=o.backgroundBorder),null!=o.backgroundBorderThickNess&&(this.backgroundBorderThickness=o.backgroundBorderThickNess),null!=o.backgroundFill&&("string"==typeof o.backgroundFill?this.backgroundFill=r.GetBrushFromString(o.backgroundFill):this.backgroundFill=o.backgroundFill),this._background._patchHierarchy(this));var h=n.getEngine();this.__engineData=h.getOrAddExternalDataWithFactory("__BJSCANVAS2D__",function(e){return new t}),this._renderScaleFactor=a,this._primPointerInfo=new e.PrimitivePointerInfo,this._capturedPointers=new e.StringDictionary,this._pickStartingPosition=e.Vector2.Zero(),this._hierarchyLevelMaxSiblingCount=50,this._hierarchyDepthOffset=0,this._siblingDepthOffset=1/this._hierarchyLevelMaxSiblingCount,this._scene=n,this._engine=h,this._renderingSize=new e.Size(0,0),this._trackedGroups=new Array,this._patchHierarchy(this);var c=null==o.enableInteraction?!0:o.enableInteraction;this._fitRenderingDevice=!o.size,o.size?(o.size.height*=a,o.size.width*=a):o.size=new e.Size(h.getRenderWidth(),h.getRenderHeight()),n.onDisposeObservable.add(function(e,t){s.dispose()}),this._isScreenSpace?this._afterRenderObserver=this._scene.onAfterRenderObservable.add(function(e,t){s._engine.clear(null,!1,!0),s._render()}):this._beforeRenderObserver=this._scene.onBeforeRenderObservable.add(function(e,t){s._render()}),this._supprtInstancedArray=null!==this._engine.getCaps().instancedArrays,this._setupInteraction(c)}return __extends(r,i),r.prototype._canvasPreInit=function(e){var t=null==e.cachingStrategy?r.CACHESTRATEGY_DONTCACHE:e.cachingStrategy;this._cachingStrategy=t,this._isScreenSpace=null==e.isScreenSpace?!0:e.isScreenSpace},r.prototype._setupInteraction=function(e){var t=this;if(e!==this._interactionEnabled)if(this._interactionEnabled=e,this._isScreenSpace){if(!e)return void(this._scenePrePointerObserver&&(this.scene.onPrePointerObservable.remove(this._scenePrePointerObserver),this._scenePrePointerObserver=null));this._scenePrePointerObserver=this.scene.onPrePointerObservable.add(function(e,i){var r=1/t.engine.getHardwareScalingLevel(),n=e.localPosition.multiplyByFloats(r,r);t._handlePointerEventForInteraction(e,n,i)})}else{var i=this.scene;e?(i.constantlyUpdateMeshUnderPointer=!0,this._scenePointerObserver=i.onPointerObservable.add(function(e,i){if(e.pickInfo.hit&&e.pickInfo.pickedMesh===t._worldSpaceNode&&t.worldSpaceToNodeLocal){var r=t.worldSpaceToNodeLocal(e.pickInfo.pickedPoint);t._handlePointerEventForInteraction(e,r,i)}})):this._scenePointerObserver&&(this.scene.onPointerObservable.remove(this._scenePointerObserver),this._scenePointerObserver=null)}},r.prototype._setPointerCapture=function(t,i){if(this.isPointerCaptured(t))return!1;try{this.engine.getRenderingCanvas().setPointerCapture(t)}catch(r){}return this._primPointerInfo.updateRelatedTarget(i,e.Vector2.Zero()),this._bubbleNotifyPrimPointerObserver(i,e.PrimitivePointerInfo.PointerGotCapture,null),this._capturedPointers.add(t.toString(),i),!0},r.prototype._releasePointerCapture=function(t,i){if(this._capturedPointers.get(t.toString())!==i)return!1;try{this.engine.getRenderingCanvas().releasePointerCapture(t)}catch(r){}return this._primPointerInfo.updateRelatedTarget(i,e.Vector2.Zero()),this._bubbleNotifyPrimPointerObserver(i,e.PrimitivePointerInfo.PointerLostCapture,null),this._capturedPointers.remove(t.toString()),!0},r.prototype.isPointerCaptured=function(e){return this._capturedPointers.contains(e.toString())},r.prototype.getCapturedPrimitive=function(e){return 0===this._capturedPointers.count?null:this._capturedPointers.get(e.toString())},r.prototype._handlePointerEventForInteraction=function(t,i,r){if(!this.isDisposed){this._updatePointerInfo(t,i);var n=this.getCapturedPrimitive(this._primPointerInfo.pointerId);if(this._updateIntersectionList(this._primPointerInfo.canvasPointerPos,null!==n),this._updateOverStatus(),this._actualOverPrimitive||n){var o=n||this._actualOverPrimitive.prim,s=n?this._primPointerInfo.canvasPointerPos.subtract(new e.Vector2(o.globalTransform.m[12],o.globalTransform.m[13])):this._actualOverPrimitive.intersectionLocation;this._primPointerInfo.updateRelatedTarget(o,s),t.type===e.PointerEventTypes.POINTERWHEEL?this._bubbleNotifyPrimPointerObserver(o,e.PrimitivePointerInfo.PointerMouseWheel,t.event):t.type===e.PointerEventTypes.POINTERMOVE?this._bubbleNotifyPrimPointerObserver(o,e.PrimitivePointerInfo.PointerMove,t.event):t.type===e.PointerEventTypes.POINTERDOWN?this._bubbleNotifyPrimPointerObserver(o,e.PrimitivePointerInfo.PointerDown,t.event):t.type===e.PointerEventTypes.POINTERUP&&this._bubbleNotifyPrimPointerObserver(o,e.PrimitivePointerInfo.PointerUp,t.event)}}},r.prototype._updatePointerInfo=function(t,i){var r=this._primPointerInfo;r.canvasPointerPos||(r.canvasPointerPos=e.Vector2.Zero());var n=this._scene.cameraToUseForPointers||this._scene.activeCamera,o=this._scene.getEngine();if(this._isScreenSpace){var s=n.viewport,a=s.toGlobal(o.getRenderWidth(),o.getRenderHeight()),h=i.x-a.x,c=i.y-a.y;r.canvasPointerPos.x=h-this.actualPosition.x,r.canvasPointerPos.y=o.getRenderHeight()-c-this.actualPosition.y}else r.canvasPointerPos.x=i.x,r.canvasPointerPos.y=i.y;if(r.mouseWheelDelta=0,t.type===e.PointerEventTypes.POINTERWHEEL){var l=t.event;l.wheelDelta?r.mouseWheelDelta=l.wheelDelta/(40*e.PrimitivePointerInfo.MouseWheelPrecision):l.detail&&(r.mouseWheelDelta=-l.detail/e.PrimitivePointerInfo.MouseWheelPrecision)}else{var u=t.event;r.ctrlKey=u.ctrlKey,r.altKey=u.altKey,r.shiftKey=u.shiftKey,r.metaKey=u.metaKey,r.button=u.button,r.buttons=u.buttons,r.pointerId=u.pointerId,r.width=u.width,r.height=u.height,r.presssure=u.pressure,r.tilt.x=u.tiltX,r.tilt.y=u.tiltY,r.isCaptured=null!==this.getCapturedPrimitive(u.pointerId)}},r.prototype._updateIntersectionList=function(e,t){if(this.scene.getRenderId()!==this._intersectionRenderId){this._globalTransform||this.updateCachedStates(!0);var i=r._interInfo;if(i.pickPosition.x=e.x,i.pickPosition.y=e.y,i.findFirstOnly=!1,!t&&!this.boundingInfo.doesIntersect(i.pickPosition))return this._previousIntersectionList=this._actualIntersectionList,this._actualIntersectionList=null,this._previousOverPrimitive=this._actualOverPrimitive,void(this._actualOverPrimitive=null);this.intersect(i),this._previousIntersectionList=this._actualIntersectionList,this._actualIntersectionList=i.intersectedPrimitives,this._previousOverPrimitive=this._actualOverPrimitive,this._actualOverPrimitive=i.topMostIntersectedPrimitive,this._intersectionRenderId=this.scene.getRenderId()}},r.prototype._updateOverStatus=function(){if(this.scene.getRenderId()!==this._hoverStatusRenderId&&this._previousIntersectionList&&this._actualIntersectionList){var t=this._previousOverPrimitive?this._previousOverPrimitive.prim:null,i=this._actualOverPrimitive?this._actualOverPrimitive.prim:null;if(t!==i){var r=this.getCapturedPrimitive(this._primPointerInfo.pointerId);(r&&r===t||!r&&t)&&(this._primPointerInfo.updateRelatedTarget(t,this._previousOverPrimitive.intersectionLocation),this._bubbleNotifyPrimPointerObserver(t,e.PrimitivePointerInfo.PointerOut,null)),(r&&r===i||!r&&i)&&(this._primPointerInfo.updateRelatedTarget(i,this._actualOverPrimitive.intersectionLocation),this._bubbleNotifyPrimPointerObserver(i,e.PrimitivePointerInfo.PointerOver,null))}this._hoverStatusRenderId=this.scene.getRenderId()}},r.prototype._updatePrimPointerPos=function(e){if(this._primPointerInfo.isCaptured)this._primPointerInfo.primitivePointerPos=this._primPointerInfo.relatedTargetPointerPos;else for(var t=0,i=this._actualIntersectionList;t<i.length;t++){var r=i[t];if(r.prim===e)return void(this._primPointerInfo.primitivePointerPos=r.intersectionLocation)}},r.prototype._debugExecObserver=function(t,i){if(this._notifDebugMode){for(var r="",n=0;n<t.hierarchyDepth;n++)r+=" ";var o=this._primPointerInfo;r+="[RID:"+this.scene.getRenderId()+"] ["+t.hierarchyDepth+"] event:"+e.PrimitivePointerInfo.getEventTypeName(i)+", id: "+t.id+" ("+e.Tools.getClassName(t)+"), primPos: "+o.primitivePointerPos.toString()+", canvasPos: "+o.canvasPointerPos.toString(),console.log(r)}},r.prototype._bubbleNotifyPrimPointerObserver=function(t,i,r){var n=this._primPointerInfo;0!==(i&(e.PrimitivePointerInfo.PointerOver|e.PrimitivePointerInfo.PointerOut))&&this._notifParents(t,i);for(var o=!1,s=t;s;){if(!o&&(this._updatePrimPointerPos(s),this._debugExecObserver(s,i),s._pointerEventObservable.notifyObservers(n,i),this._triggerActionManager(s,n,i,r),n.cancelBubble)){if(0===(i&(e.PrimitivePointerInfo.PointerOver|e.PrimitivePointerInfo.PointerOut)))return;o=!0}o&&this._updatePrimPointerPos(s),i===e.PrimitivePointerInfo.PointerOver?(this._debugExecObserver(s,e.PrimitivePointerInfo.PointerEnter),s._pointerEventObservable.notifyObservers(n,e.PrimitivePointerInfo.PointerEnter)):i===e.PrimitivePointerInfo.PointerOut&&(this._debugExecObserver(s,e.PrimitivePointerInfo.PointerLeave),s._pointerEventObservable.notifyObservers(n,e.PrimitivePointerInfo.PointerLeave)),s=s.parent}},r.prototype._triggerActionManager=function(t,i,r,n){var o=this;if(this._globalTransform||this.updateCachedStates(!0),0!==(r&e.PrimitivePointerInfo.PointerDown)){if(this._pickStartingPosition=i.primitivePointerPos.clone(),this._pickStartingTime=(new Date).getTime(),this._pickedDownPrim=null,t.actionManager){if(this._pickedDownPrim=t,t.actionManager.hasPickTriggers){var s=e.ActionEvent.CreateNewFromPrimitive(t,i.primitivePointerPos,n);switch(n.button){case 0:t.actionManager.processTrigger(e.ActionManager.OnLeftPickTrigger,s);break;case 1:t.actionManager.processTrigger(e.ActionManager.OnCenterPickTrigger,s);break;case 2:t.actionManager.processTrigger(e.ActionManager.OnRightPickTrigger,s)}t.actionManager.processTrigger(e.ActionManager.OnPickDownTrigger,s)}t.actionManager.hasSpecificTrigger(e.ActionManager.OnLongPressTrigger)&&window.setTimeout(function(){var i=o._primPointerInfo,r=o.getCapturedPrimitive(i.pointerId);o._updateIntersectionList(i.canvasPointerPos,null!==r);var s=new e.IntersectInfo2D;s.pickPosition=i.canvasPointerPos.clone(),s.findFirstOnly=!1,o.intersect(s),null!==s.isPrimIntersected(t)&&t.actionManager&&0!==o._pickStartingTime&&(new Date).getTime()-o._pickStartingTime>e.ActionManager.LongPressDelay&&Math.abs(o._pickStartingPosition.x-s.pickPosition.x)<e.ActionManager.DragMovementThreshold&&Math.abs(o._pickStartingPosition.y-s.pickPosition.y)<e.ActionManager.DragMovementThreshold&&(o._pickStartingTime=0,t.actionManager.processTrigger(e.ActionManager.OnLongPressTrigger,e.ActionEvent.CreateNewFromPrimitive(t,i.primitivePointerPos,n)))},e.ActionManager.LongPressDelay)}}else if(0!==(r&e.PrimitivePointerInfo.PointerUp)){this._pickStartingTime=0;var s=e.ActionEvent.CreateNewFromPrimitive(t,i.primitivePointerPos,n);t.actionManager&&(t.actionManager.processTrigger(e.ActionManager.OnPickUpTrigger,s),Math.abs(this._pickStartingPosition.x-i.canvasPointerPos.x)<e.ActionManager.DragMovementThreshold&&Math.abs(this._pickStartingPosition.y-i.canvasPointerPos.y)<e.ActionManager.DragMovementThreshold&&t.actionManager.processTrigger(e.ActionManager.OnPickTrigger,s)),this._pickedDownPrim&&this._pickedDownPrim.actionManager&&this._pickedDownPrim!==t&&this._pickedDownPrim.actionManager.processTrigger(e.ActionManager.OnPickOutTrigger,s)}else if(0!==(r&e.PrimitivePointerInfo.PointerOver)){if(t.actionManager){var s=e.ActionEvent.CreateNewFromPrimitive(t,i.primitivePointerPos,n);t.actionManager.processTrigger(e.ActionManager.OnPointerOverTrigger,s)}}else if(0!==(r&e.PrimitivePointerInfo.PointerOut)&&t.actionManager){var s=e.ActionEvent.CreateNewFromPrimitive(t,i.primitivePointerPos,n);t.actionManager.processTrigger(e.ActionManager.OnPointerOutTrigger,s)}},r.prototype._notifParents=function(t,i){for(var r=this._primPointerInfo,n=this;n;)this._updatePrimPointerPos(n),i===e.PrimitivePointerInfo.PointerOver?(this._debugExecObserver(n,e.PrimitivePointerInfo.PointerEnter),n._pointerEventObservable.notifyObservers(r,e.PrimitivePointerInfo.PointerEnter)):i===e.PrimitivePointerInfo.PointerOut&&(this._debugExecObserver(n,e.PrimitivePointerInfo.PointerLeave),n._pointerEventObservable.notifyObservers(r,e.PrimitivePointerInfo.PointerLeave)),n=n.parent},r.prototype.dispose=function(){return i.prototype.dispose.call(this)?(this.interactionEnabled&&this._setupInteraction(!1),this._beforeRenderObserver&&(this._scene.onBeforeRenderObservable.remove(this._beforeRenderObserver),this._beforeRenderObserver=null),this._afterRenderObserver&&(this._scene.onAfterRenderObservable.remove(this._afterRenderObserver),this._afterRenderObserver=null),void(this._groupCacheMaps&&(this._groupCacheMaps.forEach(function(e){return e.dispose()}),this._groupCacheMaps=null))):!1},Object.defineProperty(r.prototype,"scene",{get:function(){return this._scene},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"engine",{get:function(){return this._engine},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"cachingStrategy",{get:function(){return this._cachingStrategy},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"worldSpaceCanvasNode",{get:function(){return this._worldSpaceNode},set:function(e){this._worldSpaceNode=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"supportInstancedArray",{get:function(){return this._supprtInstancedArray},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"backgroundFill",{get:function(){return this._background&&this._background.isVisible?this._background.fill:null},set:function(e){this.checkBackgroundAvailability(),e!==this._background.fill&&(this._background.fill=e,this._background.levelVisible=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"backgroundBorder",{get:function(){return this._background&&this._background.isVisible?this._background.border:null},set:function(e){this.checkBackgroundAvailability(),e!==this._background.border&&(this._background.border=e,this._background.levelVisible=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"backgroundBorderThickness",{get:function(){return this._background&&this._background.isVisible?this._background.borderThickness:null},set:function(e){this.checkBackgroundAvailability(),e!==this._background.borderThickness&&(this._background.borderThickness=e)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"backgroundRoundRadius",{get:function(){return this._background&&this._background.isVisible?this._background.roundRadius:null},set:function(e){this.checkBackgroundAvailability(),e!==this._background.roundRadius&&(this._background.roundRadius=e,this._background.levelVisible=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"interactionEnabled",{get:function(){return this._interactionEnabled},set:function(e){this._setupInteraction(e)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"_engineData",{get:function(){return this.__engineData},enumerable:!0,configurable:!0}),r.prototype.checkBackgroundAvailability=function(){if(this._cachingStrategy===r.CACHESTRATEGY_TOPLEVELGROUPS)throw Error("Can't use Canvas Background with the caching strategy TOPLEVELGROUPS")},r.prototype.onPrimBecomesDirty=function(){this._addPrimToDirtyList(this)},r.prototype._updateTrackedNodes=function(){var t=this.scene.cameraToUseForPointers||this.scene.activeCamera;t.getViewMatrix().multiplyToRef(t.getProjectionMatrix(),r._m);for(var i=this.engine.getRenderHeight(),n=t.viewport.toGlobal(this.engine.getRenderWidth(),i),o=0,s=this._trackedGroups;o<s.length;o++){var a=s[o];if(!a.isDisposed&&a.isVisible){var h=a.trackedNode,c=h.getWorldMatrix(),l=e.Vector3.Project(r._v,c,r._m,n);a.x=Math.round(l.x),a.y=Math.round(i-l.y)}}},r.prototype._updateCanvasState=function(){if(this.scene.getRenderId()!==this._updateRenderId){var t=!1,i=this.engine.getRenderWidth();i!==this._renderingSize.width&&(t=!0),this._renderingSize.width=i;var r=this.engine.getRenderHeight();r!==this._renderingSize.height&&(t=!0),this._renderingSize.height=r,t&&this._fitRenderingDevice&&(this.size=this._renderingSize,this._background&&(this._background.size=this.size),this._setLayoutDirty());var n=new e.PrepareRender2DContext;++this._globalTransformProcessStep,this.updateCachedStates(!1),this._prepareGroupRender(n),this._updateRenderId=this.scene.getRenderId()}},r.prototype._render=function(){this._updateTrackedNodes(),this._updateCanvasState(),this._primPointerInfo.canvasPointerPos&&(this._updateIntersectionList(this._primPointerInfo.canvasPointerPos,!1),this._updateOverStatus()),this.engine.setState(!1),this._groupRender(),this._cachingStrategy===r.CACHESTRATEGY_CANVAS&&this._cachedCanvasGroup&&this._cachedCanvasGroup._renderCachedCanvas()},r.prototype._allocateGroupCache=function(t,i,n){var o=t.actualSize;o=new e.Size(Math.ceil(o.width),Math.ceil(o.height)),n&&(o.width=Math.max(n.width,o.width),o.height=Math.max(n.height,o.height)),this._groupCacheMaps||(this._groupCacheMaps=new Array);for(var s=null,a=0,h=this._groupCacheMaps;a<h.length;a++){var c=h[a],l=c.allocateRect(o);if(l){s={node:l,texture:c};break}}if(!s){var u=new e.Size(r._groupTextureCacheSize,r._groupTextureCacheSize);(o.width>u.width||o.height>u.height)&&(u.width=Math.pow(2,Math.ceil(Math.log(o.width)/Math.log(2))),u.height=Math.pow(2,Math.ceil(Math.log(o.height)/Math.log(2))));var f="groupsMapChache"+this._mapCounter+"forCanvas"+this.id;c=new e.MapTexture(f,this._scene,u),this._groupCacheMaps.push(c);var l=c.allocateRect(o);s={node:l,texture:c}}if(t!==this||this._isScreenSpace){var l=s.node;if(this._cachingStrategy===r.CACHESTRATEGY_CANVAS){this._cachedCanvasGroup=e.Group2D._createCachedCanvasGroup(this);var d=new e.Sprite2D(c,{parent:this._cachedCanvasGroup,id:"__cachedCanvasSprite__",spriteSize:l.contentSize,spriteLocation:l.pos});d.zOrder=1,d.origin=e.Vector2.Zero()}else{var d=new e.Sprite2D(c,{parent:i,id:"__cachedSpriteOfGroup__"+t.id,x:t.actualPosition.x,y:t.actualPosition.y,spriteSize:l.contentSize,spriteLocation:l.pos});d.origin=t.origin.clone(),s.sprite=d}}return s},r.prototype._registerTrackedNode=function(t){t._isFlagSet(e.SmartPropertyPrim.flagTrackedGroup)||(this._trackedGroups.push(t),t._setFlags(e.SmartPropertyPrim.flagTrackedGroup))},r.prototype._unregisterTrackedNode=function(t){if(t._isFlagSet(e.SmartPropertyPrim.flagTrackedGroup)){var i=this._trackedGroups.indexOf(t);-1!==i&&this._trackedGroups.splice(i,1),t._clearFlags(e.SmartPropertyPrim.flagTrackedGroup)}},r.GetSolidColorBrush=function(t){return r._solidColorBrushes.getOrAddWithFactory(t.toHexString(),function(){return new e.SolidColorBrush2D(t.clone(),!0)})},r.GetSolidColorBrushFromHex=function(t){return r._solidColorBrushes.getOrAddWithFactory(t,function(){return new e.SolidColorBrush2D(e.Color4.FromHexString(t),!0)})},r.GetGradientColorBrush=function(t,i,n,o,s){return void 0===n&&(n=e.Vector2.Zero()),void 0===o&&(o=0),void 0===s&&(s=1),r._gradientColorBrushes.getOrAddWithFactory(e.GradientColorBrush2D.BuildKey(t,i,n,o,s),function(){return new e.GradientColorBrush2D(t,i,n,o,s,!0)})},r.GetBrushFromString=function(t){t=t.trim();var i=t.split(",");if(1===i.length){var n=null;if(0===t.indexOf("solid:"))n=t.substr(6).trim();else{if(0!==t.indexOf("#"))return null;n=t}return r.GetSolidColorBrushFromHex(n)}0===i[0].indexOf("gradient:")&&(i[0]=i[0].substr(9).trim());try{var o=e.Color4.FromHexString(i[0].trim()),s=e.Color4.FromHexString(i[1].trim()),a=e.Vector2.Zero();if(i.length>2){var h=i[2].trim();if("["!==h.charAt(0)||"]"!==h.charAt(h.length-1))return null;var c=h.indexOf(":"),l=parseFloat(h.substr(1,c)),u=parseFloat(h.substr(c+1,h.length-(c+1)));a=new e.Vector2(l,u)}var f=0;i.length>3&&(f=e.Tools.ToRadians(parseFloat(i[3].trim())));var d=1;return i.length>4&&(d=parseFloat(i[4].trim())),r.GetGradientColorBrush(o,s,a,f,d)}catch(p){return null}},r.CACHESTRATEGY_TOPLEVELGROUPS=1,r.CACHESTRATEGY_ALLGROUPS=2,r.CACHESTRATEGY_CANVAS=3,r.CACHESTRATEGY_DONTCACHE=4,r.hierarchyLevelMaxSiblingCount=50,r._interInfo=new e.IntersectInfo2D,r._v=e.Vector3.Zero(),r._m=e.Matrix.Identity(),r._groupTextureCacheSize=1024,r._solidColorBrushes=new e.StringDictionary,r._gradientColorBrushes=new e.StringDictionary,r=__decorate([e.className("Canvas2D")],r)}(e.Group2D);e.Canvas2D=i;var r=function(t){function r(r,n,o){e.Prim2DBase._isCanvasInit=!0;var s=o;if(s.isScreenSpace=!1,s.size=n.clone(),o.cachingStrategy=null==o.cachingStrategy?i.CACHESTRATEGY_CANVAS:o.cachingStrategy,o.cachingStrategy!==i.CACHESTRATEGY_CANVAS)throw new Error("Right now only the CACHESTRATEGY_CANVAS cache Strategy is supported for WorldSpace Canvas. More will come soon!");t.call(this,r,o),e.Prim2DBase._isCanvasInit=!1;var a=!o||null==o.customWorldSpaceNode,h=o?o.id||null:null;if(a){var c=new e.WorldSpaceCanvas2DNode(h,r,this),l=e.VertexData.CreatePlane({width:n.width,height:n.height,sideOrientation:o&&o.sideOrientation||e.Mesh.DEFAULTSIDE}),u=new e.StandardMaterial(h+"_Material",r);this.applyCachedTexture(l,u),l.applyToMesh(c,!1),u.specularColor=new e.Color3(0,0,0),u.disableLighting=!0,u.useAlphaFromDiffuseTexture=!0,c.position=o&&o.worldPosition||e.Vector3.Zero(),c.rotationQuaternion=o&&o.worldRotation||e.Quaternion.Identity(),c.material=u,this._worldSpaceNode=c}else this._worldSpaceNode=o.customWorldSpaceNode,this.applyCachedTexture(null,null)}return __extends(r,t),r=__decorate([e.className("WorldSpaceCanvas2D")],r)}(i);e.WorldSpaceCanvas2D=r;var n=function(t){function i(i,r){e.Prim2DBase._isCanvasInit=!0,t.call(this,i,r)}return __extends(i,t),i=__decorate([e.className("ScreenSpaceCanvas2D")],i)}(i);e.ScreenSpaceCanvas2D=n}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(e){function t(t,i,r){e.call(this,t,i),this._canvas=r}return __extends(t,e),t.prototype.dispose=function(){e.prototype.dispose.call(this),this._canvas&&(this._canvas.dispose(),this._canvas=null)},t}(e.Mesh);e.WorldSpaceCanvas2DNode=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(){this.layoutDirtyOnPropertyChangedMask=0}return t.prototype.updateLayout=function(e){},Object.defineProperty(t.prototype,"isChildPositionAllowed",{get:function(){return!1},enumerable:!0,configurable:!0}),t.prototype.isLocked=function(){return this._isLocked},t.prototype.lock=function(){return this._isLocked?!1:(this._isLocked=!0,!0)},t=__decorate([e.className("LayoutEngineBase")],t)}();e.LayoutEngineBase=t;var i=function(t){function i(){t.apply(this,arguments)}return __extends(i,t),i.prototype.updateLayout=function(t){if(t._isFlagSet(e.SmartPropertyPrim.flagLayoutDirty)){for(var i=0,r=t.children;i<r.length;i++){var n=r[i];this._doUpdate(n)}t._clearFlags(e.SmartPropertyPrim.flagLayoutDirty)}},i.prototype._doUpdate=function(t){t instanceof e.Canvas2D?t.layoutArea=t.actualSize:t.parent instanceof e.Canvas2D?t.layoutArea=t.owner.actualSize:t.layoutArea=t.parent.contentArea},Object.defineProperty(i.prototype,"isChildPositionAllowed",{get:function(){return!0},enumerable:!0,configurable:!0}),i.Singleton=new i,i=__decorate([e.className("CanvasLayoutEngine")],i)}(t);e.CanvasLayoutEngine=i;var r=function(t){function i(){t.call(this),this._isHorizontal=!0,this.layoutDirtyOnPropertyChangedMask=e.Prim2DBase.sizeProperty.flagId}return __extends(i,t),Object.defineProperty(i,"Horizontal",{get:function(){return i._horizontal||(i._horizontal=new i,i._horizontal.isHorizontal=!0,i._horizontal.lock()),i._horizontal},enumerable:!0,configurable:!0}),Object.defineProperty(i,"Vertical",{get:function(){return i._vertical||(i._vertical=new i,i._vertical.isHorizontal=!1,i._vertical.lock()),i._vertical},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"isHorizontal",{get:function(){return this._isHorizontal},set:function(e){this.isLocked()||(this._isHorizontal=e)},enumerable:!0,configurable:!0}),i.prototype.updateLayout=function(t){if(t._isFlagSet(e.SmartPropertyPrim.flagLayoutDirty)){for(var i=0,r=0,n=this.isHorizontal,o=0,s=0,a=t.children;s<a.length;s++){var h=a[s],c=h.layoutArea;h.margin.computeArea(h.actualSize,c),o=Math.max(o,n?c.height:c.width)}for(var l=0,u=t.children;l<u.length;l++){var h=u[l];h.layoutAreaPos=new e.Vector2(i,r);var c=h.layoutArea;n?(i+=c.width,h.layoutArea=new e.Size(c.width,o)):(r+=c.height,h.layoutArea=new e.Size(o,c.height))}t._clearFlags(e.SmartPropertyPrim.flagLayoutDirty)}},Object.defineProperty(i.prototype,"isChildPositionAllowed",{get:function(){return!1},enumerable:!0,configurable:!0}),i._horizontal=null,i._vertical=null,i=__decorate([e.className("StackPanelLayoutEngine")],i)}(t);e.StackPanelLayoutEngine=r;
  28. }(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(t){function i(i,r,n,o){t.call(this,i,r),this._textures={},this._floats={},this._floatsArrays={},this._colors3={},this._colors4={},this._vectors2={},this._vectors3={},this._vectors4={},this._matrices={},this._matrices3x3={},this._matrices2x2={},this._cachedWorldViewMatrix=new e.Matrix,this._shaderPath=n,o.needAlphaBlending=o.needAlphaBlending||!1,o.needAlphaTesting=o.needAlphaTesting||!1,o.attributes=o.attributes||["position","normal","uv"],o.uniforms=o.uniforms||["worldViewProjection"],o.samplers=o.samplers||[],o.defines=o.defines||[],this._options=o}return __extends(i,t),i.prototype.needAlphaBlending=function(){return this._options.needAlphaBlending},i.prototype.needAlphaTesting=function(){return this._options.needAlphaTesting},i.prototype._checkUniform=function(e){-1===this._options.uniforms.indexOf(e)&&this._options.uniforms.push(e)},i.prototype.setTexture=function(e,t){return-1===this._options.samplers.indexOf(e)&&this._options.samplers.push(e),this._textures[e]=t,this},i.prototype.setFloat=function(e,t){return this._checkUniform(e),this._floats[e]=t,this},i.prototype.setFloats=function(e,t){return this._checkUniform(e),this._floatsArrays[e]=t,this},i.prototype.setColor3=function(e,t){return this._checkUniform(e),this._colors3[e]=t,this},i.prototype.setColor4=function(e,t){return this._checkUniform(e),this._colors4[e]=t,this},i.prototype.setVector2=function(e,t){return this._checkUniform(e),this._vectors2[e]=t,this},i.prototype.setVector3=function(e,t){return this._checkUniform(e),this._vectors3[e]=t,this},i.prototype.setVector4=function(e,t){return this._checkUniform(e),this._vectors4[e]=t,this},i.prototype.setMatrix=function(e,t){return this._checkUniform(e),this._matrices[e]=t,this},i.prototype.setMatrix3x3=function(e,t){return this._checkUniform(e),this._matrices3x3[e]=t,this},i.prototype.setMatrix2x2=function(e,t){return this._checkUniform(e),this._matrices2x2[e]=t,this},i.prototype.isReady=function(t,i){var r=this.getScene(),n=r.getEngine();if(!this.checkReadyOnEveryCall&&this._renderId===r.getRenderId())return!0;var o=[],s=new e.EffectFallbacks;i&&o.push("#define INSTANCES");for(var a=0;a<this._options.defines.length;a++)o.push(this._options.defines[a]);t&&t.useBones&&t.computeBonesUsingShaders&&(o.push("#define NUM_BONE_INFLUENCERS "+t.numBoneInfluencers),o.push("#define BonesPerMesh "+(t.skeleton.bones.length+1)),s.addCPUSkinningFallback(0,t)),n.getAlphaTesting()&&o.push("#define ALPHATEST");var h=this._effect,c=o.join("\n");return this._effect=n.createEffect(this._shaderPath,this._options.attributes,this._options.uniforms,this._options.samplers,c,s,this.onCompiled,this.onError),this._effect.isReady()?(h!==this._effect&&r.resetCachedMaterial(),this._renderId=r.getRenderId(),!0):!1},i.prototype.bindOnlyWorldMatrix=function(e){var t=this.getScene();-1!==this._options.uniforms.indexOf("world")&&this._effect.setMatrix("world",e),-1!==this._options.uniforms.indexOf("worldView")&&(e.multiplyToRef(t.getViewMatrix(),this._cachedWorldViewMatrix),this._effect.setMatrix("worldView",this._cachedWorldViewMatrix)),-1!==this._options.uniforms.indexOf("worldViewProjection")&&this._effect.setMatrix("worldViewProjection",e.multiply(t.getTransformMatrix()))},i.prototype.bind=function(e,i){if(this.bindOnlyWorldMatrix(e),this.getScene().getCachedMaterial()!==this){-1!==this._options.uniforms.indexOf("view")&&this._effect.setMatrix("view",this.getScene().getViewMatrix()),-1!==this._options.uniforms.indexOf("projection")&&this._effect.setMatrix("projection",this.getScene().getProjectionMatrix()),-1!==this._options.uniforms.indexOf("viewProjection")&&this._effect.setMatrix("viewProjection",this.getScene().getTransformMatrix()),i&&i.useBones&&i.computeBonesUsingShaders&&this._effect.setMatrices("mBones",i.skeleton.getTransformMatrices(i));for(var r in this._textures)this._effect.setTexture(r,this._textures[r]);for(r in this._floats)this._effect.setFloat(r,this._floats[r]);for(r in this._floatsArrays)this._effect.setArray(r,this._floatsArrays[r]);for(r in this._colors3)this._effect.setColor3(r,this._colors3[r]);for(r in this._colors4){var n=this._colors4[r];this._effect.setFloat4(r,n.r,n.g,n.b,n.a)}for(r in this._vectors2)this._effect.setVector2(r,this._vectors2[r]);for(r in this._vectors3)this._effect.setVector3(r,this._vectors3[r]);for(r in this._vectors4)this._effect.setVector4(r,this._vectors4[r]);for(r in this._matrices)this._effect.setMatrix(r,this._matrices[r]);for(r in this._matrices3x3)this._effect.setMatrix3x3(r,this._matrices3x3[r]);for(r in this._matrices2x2)this._effect.setMatrix2x2(r,this._matrices2x2[r])}t.prototype.bind.call(this,e,i)},i.prototype.clone=function(e){var t=new i(e,this.getScene(),this._shaderPath,this._options);return t},i.prototype.dispose=function(e,i){if(i)for(var r in this._textures)this._textures[r].dispose();this._textures={},t.prototype.dispose.call(this,e,i)},i.prototype.serialize=function(){var t=e.SerializationHelper.Serialize(this);t.customType="BABYLON.ShaderMaterial",t.options=this._options,t.shaderPath=this._shaderPath,t.textures={};for(var i in this._textures)t.textures[i]=this._textures[i].serialize();t.floats={};for(i in this._floats)t.floats[i]=this._floats[i];t.floatArrays={};for(i in this._floatsArrays)t.floatArrays[i]=this._floatsArrays[i];t.colors3={};for(i in this._colors3)t.colors3[i]=this._colors3[i].asArray();t.colors4={};for(i in this._colors4)t.colors4[i]=this._colors4[i].asArray();t.vectors2={};for(i in this._vectors2)t.vectors2[i]=this._vectors2[i].asArray();t.vectors3={};for(i in this._vectors3)t.vectors3[i]=this._vectors3[i].asArray();t.vectors4={};for(i in this._vectors4)t.vectors4[i]=this._vectors4[i].asArray();t.matrices={};for(i in this._matrices)t.matrices[i]=this._matrices[i].asArray();t.matrices3x3={};for(i in this._matrices3x3)t.matrices3x3[i]=this._matrices3x3[i];t.matrices2x2={};for(i in this._matrices2x2)t.matrices2x2[i]=this._matrices2x2[i];return t},i.Parse=function(t,r,n){var o=e.SerializationHelper.Parse(function(){return new i(t.name,r,t.shaderPath,t.options)},t,r,n);for(var s in t.textures)o.setTexture(s,e.Texture.Parse(t.textures[s],r,n));for(s in t.floats)o.setFloat(s,t.floats[s]);for(s in t.floatsArrays)o.setFloats(s,t.floatsArrays[s]);for(s in t.colors3)o.setColor3(s,e.Color3.FromArray(t.colors3[s]));for(s in t.colors4)o.setColor4(s,e.Color4.FromArray(t.colors4[s]));for(s in t.vectors2)o.setVector2(s,e.Vector2.FromArray(t.vectors2[s]));for(s in t.vectors3)o.setVector3(s,e.Vector3.FromArray(t.vectors3[s]));for(s in t.vectors4)o.setVector4(s,e.Vector4.FromArray(t.vectors4[s]));for(s in t.matrices)o.setMatrix(s,e.Matrix.FromArray(t.matrices[s]));for(s in t.matrices3x3)o.setMatrix3x3(s,t.matrices3x3[s]);for(s in t.matrices2x2)o.setMatrix2x2(s,t.matrices2x2[s]);return o},i}(e.Material);e.ShaderMaterial=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t;!function(t){function i(e){return e.charCodeAt(0)+(e.charCodeAt(1)<<8)+(e.charCodeAt(2)<<16)+(e.charCodeAt(3)<<24)}function r(e){return String.fromCharCode(255&e,e>>8&255,e>>16&255,e>>24&255)}var n=542327876,o=131072,s=512,a=4,h=64,c=131072,l=i("DXT1"),u=i("DXT3"),f=i("DXT5"),d=31,p=0,_=1,m=2,g=3,v=4,y=7,x=20,b=21,P=22,A=28,T=function(){function t(){}return t.GetDDSInfo=function(e){var t=new Int32Array(e,0,d),i=1;return t[m]&o&&(i=Math.max(1,t[y])),{width:t[v],height:t[g],mipmapCount:i,isFourCC:(t[x]&a)===a,isRGB:(t[x]&h)===h,isLuminance:(t[x]&c)===c,isCube:(t[A]&s)===s}},t.GetRGBAArrayBuffer=function(e,t,i,r,n){for(var o=new Uint8Array(r),s=new Uint8Array(n),a=0,h=t-1;h>=0;h--)for(var c=0;e>c;c++){var l=i+4*(c+h*e);o[a+2]=s[l],o[a+1]=s[l+1],o[a]=s[l+2],o[a+3]=s[l+3],a+=4}return o},t.GetRGBArrayBuffer=function(e,t,i,r,n){for(var o=new Uint8Array(r),s=new Uint8Array(n),a=0,h=t-1;h>=0;h--)for(var c=0;e>c;c++){var l=i+3*(c+h*e);o[a+2]=s[l],o[a+1]=s[l+1],o[a]=s[l+2],a+=3}return o},t.GetLuminanceArrayBuffer=function(e,t,i,r,n){for(var o=new Uint8Array(r),s=new Uint8Array(n),a=0,h=t-1;h>=0;h--)for(var c=0;e>c;c++){var l=i+(c+h*e);o[a]=s[l],a++}return o},t.UploadDDSLevels=function(i,s,a,h,c,x){var A,T,E,C,S,M,I,D,R,O,w=new Int32Array(a,0,d);if(w[p]!=n)return void e.Tools.Error("Invalid magic number in DDS header");if(!h.isFourCC&&!h.isRGB&&!h.isLuminance)return void e.Tools.Error("Unsupported format, must contain a FourCC, RGB or LUMINANCE code");if(h.isFourCC)switch(A=w[b]){case l:T=8,E=s.COMPRESSED_RGBA_S3TC_DXT1_EXT;break;case u:T=16,E=s.COMPRESSED_RGBA_S3TC_DXT3_EXT;break;case f:T=16,E=s.COMPRESSED_RGBA_S3TC_DXT5_EXT;break;default:return void console.error("Unsupported FourCC code:",r(A))}R=1,w[m]&o&&c!==!1&&(R=Math.max(1,w[y]));for(var L=w[P],B=0;x>B;B++){var V=1===x?i.TEXTURE_2D:i.TEXTURE_CUBE_MAP_POSITIVE_X+B;for(C=w[v],S=w[g],I=w[_]+4,O=0;R>O;++O){if(h.isRGB)24===L?(M=C*S*3,D=t.GetRGBArrayBuffer(C,S,I,M,a),i.texImage2D(V,O,i.RGB,C,S,0,i.RGB,i.UNSIGNED_BYTE,D)):(M=C*S*4,D=t.GetRGBAArrayBuffer(C,S,I,M,a),i.texImage2D(V,O,i.RGBA,C,S,0,i.RGBA,i.UNSIGNED_BYTE,D));else if(h.isLuminance){var F=i.getParameter(i.UNPACK_ALIGNMENT),N=C,z=Math.floor((C+F-1)/F)*F;M=z*(S-1)+N,D=t.GetLuminanceArrayBuffer(C,S,I,M,a),i.texImage2D(V,O,i.LUMINANCE,C,S,0,i.LUMINANCE,i.UNSIGNED_BYTE,D)}else M=Math.max(4,C)/4*Math.max(4,S)/4*T,D=new Uint8Array(a,I,M),i.compressedTexImage2D(V,O,E,C,S,0,D);I+=M,C*=.5,S*=.5,C=Math.max(1,C),S=Math.max(1,S)}}},t}();t.DDSTools=T}(t=e.Internals||(e.Internals={}))}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(t,i){return void 0===t&&(t=!0),void 0===i&&(i=10),this._useDeltaForWorldStep=t,this.name="CannonJSPlugin",this._physicsMaterials=[],this._fixedTimeStep=1/60,this._currentCollisionGroup=2,this._minus90X=new e.Quaternion(-.7071067811865475,0,0,.7071067811865475),this._plus90X=new e.Quaternion(.7071067811865475,0,0,.7071067811865475),this._tmpPosition=e.Vector3.Zero(),this._tmpQuaternion=new e.Quaternion,this._tmpDeltaPosition=e.Vector3.Zero(),this._tmpDeltaRotation=new e.Quaternion,this._tmpUnityRotation=new e.Quaternion,this.isSupported()?(this.world=new CANNON.World,this.world.broadphase=new CANNON.NaiveBroadphase,void(this.world.solver.iterations=i)):void e.Tools.Error("CannonJS is not available. Please make sure you included the js file.")}return t.prototype.setGravity=function(e){this.world.gravity.copy(e)},t.prototype.setTimeStep=function(e){this._fixedTimeStep=e},t.prototype.executeStep=function(e,t){this.world.step(this._fixedTimeStep,this._useDeltaForWorldStep?1e3*e:0,3)},t.prototype.applyImpulse=function(e,t,i){var r=new CANNON.Vec3(i.x,i.y,i.z),n=new CANNON.Vec3(t.x,t.y,t.z);e.physicsBody.applyImpulse(n,r)},t.prototype.applyForce=function(e,t,i){var r=new CANNON.Vec3(i.x,i.y,i.z),n=new CANNON.Vec3(t.x,t.y,t.z);e.physicsBody.applyImpulse(n,r)},t.prototype.generatePhysicsBody=function(e){if(e.parent)return void(e.physicsBody&&(this.removePhysicsBody(e),e.forceUpdate()));if(e.isBodyInitRequired()){var t=this._createShape(e),i=e.physicsBody;i&&this.removePhysicsBody(e);var r=this._addMaterial("mat-"+e.uniqueId,e.getParam("friction"),e.getParam("restitution")),n={mass:e.getParam("mass"),material:r},o=e.getParam("nativeOptions");for(var s in o)o.hasOwnProperty(s)&&(n[s]=o[s]);e.physicsBody=new CANNON.Body(n),e.physicsBody.addEventListener("collide",e.onCollide),this.world.addEventListener("preStep",e.beforeStep),this.world.addEventListener("postStep",e.afterStep),e.physicsBody.addShape(t),this.world.add(e.physicsBody),i&&["force","torque","velocity","angularVelocity"].forEach(function(t){e.physicsBody[t].copy(i[t])}),this._processChildMeshes(e)}this._updatePhysicsBodyTransformation(e)},t.prototype._processChildMeshes=function(t){var i=this,r=t.object.getChildMeshes?t.object.getChildMeshes():[];if(r.length){var n=function(e,r){var o=r.getPhysicsImpostor();if(o){var s=o.parent;if(s!==t){var e=r.position;o.physicsBody&&(i.removePhysicsBody(o),o.physicsBody=null),o.parent=t,o.resetUpdateFlags(),t.physicsBody.addShape(i._createShape(o),new CANNON.Vec3(e.x,e.y,e.z)),t.physicsBody.mass+=o.getParam("mass")}}r.getChildMeshes().forEach(n.bind(i,r.position))};r.forEach(n.bind(this,e.Vector3.Zero()))}},t.prototype.removePhysicsBody=function(e){e.physicsBody.removeEventListener("collide",e.onCollide),this.world.removeEventListener("preStep",e.beforeStep),this.world.removeEventListener("postStep",e.afterStep),this.world.remove(e.physicsBody)},t.prototype.generateJoint=function(t){var i=t.mainImpostor.physicsBody,r=t.connectedImpostor.physicsBody;if(i&&r){var n,o=t.joint.jointData,s={pivotA:o.mainPivot?(new CANNON.Vec3).copy(o.mainPivot):null,pivotB:o.connectedPivot?(new CANNON.Vec3).copy(o.connectedPivot):null,axisA:o.mainAxis?(new CANNON.Vec3).copy(o.mainAxis):null,axisB:o.connectedAxis?(new CANNON.Vec3).copy(o.connectedAxis):null,maxForce:o.nativeParams.maxForce,collideConnected:!!o.collision};switch(t.joint.type){case e.PhysicsJoint.HingeJoint:case e.PhysicsJoint.Hinge2Joint:n=new CANNON.HingeConstraint(i,r,s);break;case e.PhysicsJoint.DistanceJoint:n=new CANNON.DistanceConstraint(i,r,o.maxDistance||2);break;case e.PhysicsJoint.SpringJoint:var a=o;n=new CANNON.Spring(i,r,{restLength:a.length,stiffness:a.stiffness,damping:a.damping,localAnchorA:s.pivotA,localAnchorB:s.pivotB});break;case e.PhysicsJoint.LockJoint:n=new CANNON.LockConstraint(i,r,s);break;case e.PhysicsJoint.PointToPointJoint:case e.PhysicsJoint.BallAndSocketJoint:default:n=new CANNON.PointToPointConstraint(i,s.pivotA,r,s.pivotA,s.maxForce)}n.collideConnected=!!o.collision,t.joint.physicsJoint=n,t.joint.type!==e.PhysicsJoint.SpringJoint?this.world.addConstraint(n):t.mainImpostor.registerAfterPhysicsStep(function(){n.applyForce()})}},t.prototype.removeJoint=function(e){this.world.removeConstraint(e.joint.physicsJoint)},t.prototype._addMaterial=function(e,t,i){var r,n;for(r=0;r<this._physicsMaterials.length;r++)if(n=this._physicsMaterials[r],n.friction===t&&n.restitution===i)return n;var o=new CANNON.Material(e);return o.friction=t,o.restitution=i,this._physicsMaterials.push(o),o},t.prototype._checkWithEpsilon=function(t){return t<e.PhysicsEngine.Epsilon?e.PhysicsEngine.Epsilon:t},t.prototype._createShape=function(t){var i,r=t.object,n=t.getObjectExtendSize();switch(t.type){case e.PhysicsEngine.SphereImpostor:var o=n.x,s=n.y,a=n.z;i=new CANNON.Sphere(Math.max(this._checkWithEpsilon(o),this._checkWithEpsilon(s),this._checkWithEpsilon(a))/2);break;case e.PhysicsImpostor.CylinderImpostor:i=new CANNON.Cylinder(this._checkWithEpsilon(n.x)/2,this._checkWithEpsilon(n.x)/2,this._checkWithEpsilon(n.y),16);break;case e.PhysicsImpostor.BoxImpostor:var h=n.scale(.5);i=new CANNON.Box(new CANNON.Vec3(this._checkWithEpsilon(h.x),this._checkWithEpsilon(h.y),this._checkWithEpsilon(h.z)));break;case e.PhysicsImpostor.PlaneImpostor:e.Tools.Warn("Attention, PlaneImposter might not behave as you expect. Consider using BoxImposter instead"),i=new CANNON.Plane;break;case e.PhysicsImpostor.MeshImpostor:var c=r.getVerticesData?r.getVerticesData(e.VertexBuffer.PositionKind):[],l=r.getIndices?r.getIndices():[];e.Tools.Warn("MeshImpostor only collides against spheres."),i=new CANNON.Trimesh(c,l);break;case e.PhysicsImpostor.HeightmapImpostor:i=this._createHeightmap(r);break;case e.PhysicsImpostor.ParticleImpostor:i=new CANNON.Particle}return i},t.prototype._createHeightmap=function(t,i){for(var r=t.getVerticesData(e.VertexBuffer.PositionKind),n=[],o=i||~~(Math.sqrt(r.length/3)-1),s=Math.min(t.getBoundingInfo().boundingBox.extendSize.x,t.getBoundingInfo().boundingBox.extendSize.z),a=2*s/o,h=t.getBoundingInfo().boundingBox.extendSize.y,c=0;c<r.length;c+=3){var l=Math.round(r[c+0]/a+o/2),u=Math.round(-1*(r[c+2]/a-o/2)),f=r[c+1]+h;n[l]||(n[l]=[]),n[l][u]||(n[l][u]=f),n[l][u]=Math.max(f,n[l][u])}for(var l=0;o>=l;++l){if(!n[l]){for(var d=1;!n[(l+d)%o];)d++;n[l]=n[(l+d)%o].slice()}for(var u=0;o>=u;++u)if(!n[l][u]){for(var p,d=1;void 0===p;)p=n[l][(u+d++)%o];n[l][u]=p}}var _=new CANNON.Heightfield(n,{elementSize:a});return _.minY=h,_},t.prototype._updatePhysicsBodyTransformation=function(t){var i=t.object;i.computeWorldMatrix&&i.computeWorldMatrix(!0);var r=t.getObjectCenter();t.getObjectExtendSize();this._tmpDeltaPosition.copyFrom(i.position.subtract(r)),this._tmpPosition.copyFrom(r);var n=i.rotationQuaternion;if(t.type!==e.PhysicsImpostor.PlaneImpostor&&t.type!==e.PhysicsImpostor.HeightmapImpostor&&t.type!==e.PhysicsImpostor.CylinderImpostor||(n=n.multiply(this._minus90X),t.setDeltaRotation(this._plus90X)),t.type===e.PhysicsEngine.HeightmapImpostor){var o=i,s=o.rotationQuaternion;o.rotationQuaternion=this._tmpUnityRotation,o.computeWorldMatrix(!0);var a=r.clone(),h=o.getPivotMatrix()||e.Matrix.Translation(0,0,0);o.rotationQuaternion=s;var c=e.Matrix.Translation(o.getBoundingInfo().boundingBox.extendSize.x,0,-o.getBoundingInfo().boundingBox.extendSize.z);o.setPivotMatrix(c),o.computeWorldMatrix(!0);var l=o.getBoundingInfo().boundingBox.center.subtract(r).subtract(o.position).negate();this._tmpPosition.copyFromFloats(l.x,l.y-o.getBoundingInfo().boundingBox.extendSize.y,l.z),this._tmpDeltaPosition.copyFrom(o.getBoundingInfo().boundingBox.center.subtract(a)),this._tmpDeltaPosition.y+=o.getBoundingInfo().boundingBox.extendSize.y,o.setPivotMatrix(h),o.computeWorldMatrix(!0)}else t.type===e.PhysicsEngine.MeshImpostor&&(this._tmpDeltaPosition.copyFromFloats(0,0,0),this._tmpPosition.copyFrom(i.position));t.setDeltaPosition(this._tmpDeltaPosition),t.physicsBody.position.copy(this._tmpPosition),t.physicsBody.quaternion.copy(n)},t.prototype.setTransformationFromPhysicsBody=function(e){e.object.position.copyFrom(e.physicsBody.position),e.object.rotationQuaternion.copyFrom(e.physicsBody.quaternion)},t.prototype.setPhysicsBodyTransformation=function(e,t,i){e.physicsBody.position.copy(t),e.physicsBody.quaternion.copy(i)},t.prototype.isSupported=function(){return void 0!==window.CANNON},t.prototype.setLinearVelocity=function(e,t){e.physicsBody.velocity.copy(t)},t.prototype.setAngularVelocity=function(e,t){e.physicsBody.angularVelocity.copy(t)},t.prototype.getLinearVelocity=function(t){var i=t.physicsBody.velocity;return i?new e.Vector3(i.x,i.y,i.z):null},t.prototype.getAngularVelocity=function(t){var i=t.physicsBody.angularVelocity;return i?new e.Vector3(i.x,i.y,i.z):null},t.prototype.setBodyMass=function(e,t){e.physicsBody.mass=t,e.physicsBody.updateMassProperties()},t.prototype.sleepBody=function(e){e.physicsBody.sleep()},t.prototype.wakeUpBody=function(e){e.physicsBody.wakeUp()},t.prototype.updateDistanceJoint=function(e,t,i){e.physicsJoint.distance=t},t.prototype.enableMotor=function(e,t){t||e.physicsJoint.enableMotor()},t.prototype.disableMotor=function(e,t){t||e.physicsJoint.disableMotor()},t.prototype.setMotor=function(e,t,i,r){r||(e.physicsJoint.enableMotor(),e.physicsJoint.setMotorSpeed(t),i&&this.setLimit(e,i))},t.prototype.setLimit=function(e,t,i){e.physicsJoint.motorEquation.maxForce=t,e.physicsJoint.motorEquation.minForce=void 0===i?-t:i},t.prototype.dispose=function(){},t}();e.CannonJSPlugin=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(t){this.name="OimoJSPlugin",this._tmpImpostorsArray=[],this._tmpPositionVector=e.Vector3.Zero(),this.world=new OIMO.World(1/60,2,t,!0),this.world.clear(),this.world.isNoStat=!0}return t.prototype.setGravity=function(e){this.world.gravity.copy(e)},t.prototype.setTimeStep=function(e){this.world.timeStep=e},t.prototype.executeStep=function(e,t){var i=this;t.forEach(function(e){e.beforeStep()}),this.world.step(),t.forEach(function(e){e.afterStep(),i._tmpImpostorsArray[e.uniqueId]=e});for(var r=this.world.contacts;null!==r;)if(!r.touching||r.body1.sleeping||r.body2.sleeping){var n=this._tmpImpostorsArray[+r.body1.name],o=this._tmpImpostorsArray[+r.body2.name];n&&o?(n.onCollide({body:o.physicsBody}),o.onCollide({body:n.physicsBody}),r=r.next):r=r.next}else r=r.next},t.prototype.applyImpulse=function(e,t,i){var r=e.physicsBody.massInfo.mass;e.physicsBody.applyImpulse(i.scale(OIMO.INV_SCALE),t.scale(OIMO.INV_SCALE*r))},t.prototype.applyForce=function(t,i,r){e.Tools.Warn("Oimo doesn't support applying force. Using impule instead."),this.applyImpulse(t,i,r)},t.prototype.generatePhysicsBody=function(t){function i(e){e.getChildMeshes&&e.getChildMeshes().forEach(function(e){e.physicsImpostor&&(s.push(e.physicsImpostor),e.physicsImpostor._init())})}function r(t){return Math.max(t,e.PhysicsEngine.Epsilon)}var n=this;if(t.parent)return void(t.physicsBody&&(this.removePhysicsBody(t),t.forceUpdate()));if(t.isBodyInitRequired()){var o={name:t.uniqueId,config:[t.getParam("mass")||1,t.getParam("friction"),t.getParam("restitution")],size:[],type:[],pos:[],rot:[],move:0!==t.getParam("mass"),world:this.world},s=[t];i(t.object),s.forEach(function(i){var s=i.object.rotationQuaternion,a=(new OIMO.Euler).setFromQuaternion({x:t.object.rotationQuaternion.x,y:t.object.rotationQuaternion.y,z:t.object.rotationQuaternion.z,s:t.object.rotationQuaternion.w}),h=i.getObjectExtendSize();if(i===t){var c=t.getObjectCenter();t.object.position.subtractToRef(c,n._tmpPositionVector),o.pos.push(c.x),o.pos.push(c.y),o.pos.push(c.z),o.rot.push(a.x/(OIMO.degtorad||OIMO.TO_RAD)),o.rot.push(a.y/(OIMO.degtorad||OIMO.TO_RAD)),o.rot.push(a.z/(OIMO.degtorad||OIMO.TO_RAD))}else o.pos.push(i.object.position.x),o.pos.push(i.object.position.y),o.pos.push(i.object.position.z),o.rot.push(0),o.rot.push(0),o.rot.push(0);switch(i.type){case e.PhysicsImpostor.ParticleImpostor:e.Tools.Warn("No Particle support in Oimo.js. using SphereImpostor instead");case e.PhysicsImpostor.SphereImpostor:var l=h.x,u=h.y,f=h.z,d=Math.max(r(l),r(u),r(f))/2;o.type.push("sphere"),o.size.push(d),o.size.push(d),o.size.push(d);break;case e.PhysicsImpostor.CylinderImpostor:var p=r(h.x)/2,_=r(h.y);o.type.push("cylinder"),o.size.push(p),o.size.push(_),o.size.push(_);break;case e.PhysicsImpostor.PlaneImpostor:case e.PhysicsImpostor.BoxImpostor:default:var p=r(h.x),_=r(h.y),m=r(h.z);o.type.push("box"),o.size.push(p),o.size.push(_),o.size.push(m)}i.object.rotationQuaternion=s}),t.physicsBody=new OIMO.Body(o).body}else this._tmpPositionVector.copyFromFloats(0,0,0);t.setDeltaPosition(this._tmpPositionVector)},t.prototype.removePhysicsBody=function(e){this.world.removeRigidBody(e.physicsBody)},t.prototype.generateJoint=function(t){var i=t.mainImpostor.physicsBody,r=t.connectedImpostor.physicsBody;if(i&&r){var n,o=t.joint.jointData,s=o.nativeParams||{},a={body1:i,body2:r,axe1:s.axe1||(o.mainAxis?o.mainAxis.asArray():null),axe2:s.axe2||(o.connectedAxis?o.connectedAxis.asArray():null),pos1:s.pos1||(o.mainPivot?o.mainPivot.asArray():null),pos2:s.pos2||(o.connectedPivot?o.connectedPivot.asArray():null),min:s.min,max:s.max,collision:s.collision||o.collision,spring:s.spring,world:this.world};switch(t.joint.type){case e.PhysicsJoint.BallAndSocketJoint:n="jointBall";break;case e.PhysicsJoint.SpringJoint:e.Tools.Warn("Oimo.js doesn't support Spring Constraint. Simulating using DistanceJoint instead");var h=o;a.min=h.length||a.min,a.max=Math.max(a.min,a.max);case e.PhysicsJoint.DistanceJoint:n="jointDistance",a.max=o.maxDistance;break;case e.PhysicsJoint.PrismaticJoint:n="jointPrisme";break;case e.PhysicsJoint.SliderJoint:n="jointSlide";break;case e.PhysicsJoint.WheelJoint:n="jointWheel";break;case e.PhysicsJoint.HingeJoint:default:n="jointHinge"}a.type=n,t.joint.physicsJoint=new OIMO.Link(a).joint}},t.prototype.removeJoint=function(t){try{this.world.removeJoint(t.joint.physicsJoint)}catch(i){e.Tools.Warn(i)}},t.prototype.isSupported=function(){return void 0!==OIMO},t.prototype.setTransformationFromPhysicsBody=function(e){if(!e.physicsBody.sleeping){if(e.physicsBody.shapes.next){var t=this._getLastShape(e.physicsBody);e.object.position.x=t.position.x*OIMO.WORLD_SCALE,e.object.position.y=t.position.y*OIMO.WORLD_SCALE,e.object.position.z=t.position.z*OIMO.WORLD_SCALE}else e.object.position.copyFrom(e.physicsBody.getPosition());e.object.rotationQuaternion.copyFrom(e.physicsBody.getQuaternion()),e.object.rotationQuaternion.normalize()}},t.prototype.setPhysicsBodyTransformation=function(e,t,i){var r=e.physicsBody;r.position.init(t.x*OIMO.INV_SCALE,t.y*OIMO.INV_SCALE,t.z*OIMO.INV_SCALE),r.orientation.init(i.w,i.x,i.y,i.z),r.syncShapes(),r.awake()},t.prototype._getLastShape=function(e){for(var t=e.shapes;t.next;)t=t.next;return t},t.prototype.setLinearVelocity=function(e,t){e.physicsBody.linearVelocity.init(t.x,t.y,t.z)},t.prototype.setAngularVelocity=function(e,t){e.physicsBody.angularVelocity.init(t.x,t.y,t.z)},t.prototype.getLinearVelocity=function(t){var i=t.physicsBody.linearVelocity;return i?new e.Vector3(i.x,i.y,i.z):null},t.prototype.getAngularVelocity=function(t){var i=t.physicsBody.angularVelocity;return i?new e.Vector3(i.x,i.y,i.z):null},t.prototype.setBodyMass=function(e,t){var i=0===t;e.physicsBody.shapes.density=i?1:t,e.physicsBody.setupMass(i?2:1)},t.prototype.sleepBody=function(e){e.physicsBody.sleep()},t.prototype.wakeUpBody=function(e){e.physicsBody.awake()},t.prototype.updateDistanceJoint=function(e,t,i){e.physicsJoint.limitMotoe.upperLimit=t,void 0!==i&&(e.physicsJoint.limitMotoe.lowerLimit=i)},t.prototype.setMotor=function(e,t,i,r){var n=r?e.physicsJoint.rotationalLimitMotor2:e.physicsJoint.rotationalLimitMotor1||e.physicsJoint.rotationalLimitMotor||e.physicsJoint.limitMotor;n&&n.setMotor(t,i)},t.prototype.setLimit=function(e,t,i,r){var n=r?e.physicsJoint.rotationalLimitMotor2:e.physicsJoint.rotationalLimitMotor1||e.physicsJoint.rotationalLimitMotor||e.physicsJoint.limitMotor;n&&n.setLimit(t,void 0===i?-t:i)},t.prototype.dispose=function(){this.world.clear()},t}();e.OimoJSPlugin=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(e){function t(t,i,r,n,o,s){e.call(this,t,"displayPass",["passSampler"],["passSampler"],i,r,n,o,s)}return __extends(t,e),t}(e.PostProcess);e.DisplayPassPostProcess=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function e(e,t,i){this.quality=e,this.distance=t,this.optimizeMesh=i}return e}();e.SimplificationSettings=t;var i=function(){function t(){this.running=!1,this._simplificationArray=[]}return t.prototype.addTask=function(e){this._simplificationArray.push(e)},t.prototype.executeNext=function(){var e=this._simplificationArray.pop();e?(this.running=!0,this.runSimplification(e)):this.running=!1},t.prototype.runSimplification=function(t){var i=this;if(t.parallelProcessing)t.settings.forEach(function(e){var r=i.getSimplifier(t);r.simplify(e,function(r){t.mesh.addLODLevel(e.distance,r),r.isVisible=!0,e.quality===t.settings[t.settings.length-1].quality&&t.successCallback&&t.successCallback(),i.executeNext()})});else{var r=this.getSimplifier(t),n=function(e,i){r.simplify(e,function(r){t.mesh.addLODLevel(e.distance,r),r.isVisible=!0,i()})};e.AsyncLoop.Run(t.settings.length,function(e){n(t.settings[e.index],function(){e.executeNext()})},function(){t.successCallback&&t.successCallback(),i.executeNext()})}},t.prototype.getSimplifier=function(e){switch(e.simplificationType){case r.QUADRATIC:default:return new h(e.mesh)}},t}();e.SimplificationQueue=i,function(e){e[e.QUADRATIC=0]="QUADRATIC"}(e.SimplificationType||(e.SimplificationType={}));var r=e.SimplificationType,n=function(){function e(e){this.vertices=e,this.error=new Array(4),this.deleted=!1,this.isDirty=!1,this.deletePending=!1,this.borderFactor=0}return e}();e.DecimationTriangle=n;var o=function(){function e(e,t){this.position=e,this.id=t,this.isBorder=!0,this.q=new s,this.triangleCount=0,this.triangleStart=0,this.originalOffsets=[]}return e.prototype.updatePosition=function(e){this.position.copyFrom(e)},e}();e.DecimationVertex=o;var s=function(){function e(e){this.data=new Array(10);for(var t=0;10>t;++t)e&&e[t]?this.data[t]=e[t]:this.data[t]=0}return e.prototype.det=function(e,t,i,r,n,o,s,a,h){var c=this.data[e]*this.data[n]*this.data[h]+this.data[i]*this.data[r]*this.data[a]+this.data[t]*this.data[o]*this.data[s]-this.data[i]*this.data[n]*this.data[s]-this.data[e]*this.data[o]*this.data[a]-this.data[t]*this.data[r]*this.data[h];return c},e.prototype.addInPlace=function(e){for(var t=0;10>t;++t)this.data[t]+=e.data[t]},e.prototype.addArrayInPlace=function(e){for(var t=0;10>t;++t)this.data[t]+=e[t]},e.prototype.add=function(t){for(var i=new e,r=0;10>r;++r)i.data[r]=this.data[r]+t.data[r];return i},e.FromData=function(t,i,r,n){return new e(e.DataFromNumbers(t,i,r,n))},e.DataFromNumbers=function(e,t,i,r){return[e*e,e*t,e*i,e*r,t*t,t*i,t*r,i*i,i*r,r*r]},e}();e.QuadraticMatrix=s;var a=function(){function e(e,t){this.vertexId=e,this.triangleId=t}return e}();e.Reference=a;var h=function(){function t(t){this._mesh=t,this.initialized=!1,this.syncIterations=5e3,this.aggressiveness=7,this.decimationIterations=100,this.boundingBoxEpsilon=e.Epsilon}return t.prototype.simplify=function(t,i){var r=this;this.initDecimatedMesh(),e.AsyncLoop.Run(this._mesh.subMeshes.length,function(e){r.initWithMesh(e.index,function(){r.runDecimation(t,e.index,function(){e.executeNext()})},t.optimizeMesh)},function(){setTimeout(function(){i(r._reconstructedMesh)},0)})},t.prototype.isTriangleOnBoundingBox=function(e){var t=this,i=0;return e.vertices.forEach(function(e){var r=0,n=e.position,o=t._mesh.getBoundingInfo().boundingBox;(o.maximum.x-n.x<t.boundingBoxEpsilon||n.x-o.minimum.x>t.boundingBoxEpsilon)&&++r,o.maximum.y!==n.y&&n.y!==o.minimum.y||++r,o.maximum.z!==n.z&&n.z!==o.minimum.z||++r,r>1&&++i}),i>1&&console.log(e,i),i>1},t.prototype.runDecimation=function(t,i,r){var n=this,o=~~(this.triangles.length*t.quality),s=0,a=this.triangles.length,h=function(t,i){setTimeout(function(){t%5===0&&n.updateMesh(0===t);for(var r=0;r<n.triangles.length;++r)n.triangles[r].isDirty=!1;var h=1e-9*Math.pow(t+3,n.aggressiveness),c=function(t){var i=~~((n.triangles.length/2+t)%n.triangles.length),r=n.triangles[i];if(r&&!(r.error[3]>h||r.deleted||r.isDirty))for(var o=0;3>o;++o)if(r.error[o]<h){var a=[],c=[],l=r.vertices[o],u=r.vertices[(o+1)%3];if(l.isBorder||u.isBorder)continue;var f=e.Vector3.Zero(),d=e.Vector3.Zero(),p=e.Vector2.Zero(),_=new e.Color4(0,0,0,1);n.calculateError(l,u,f,d,p,_);var m=[];if(n.isFlipped(l,u,f,a,r.borderFactor,m))continue;if(n.isFlipped(u,l,f,c,r.borderFactor,m))continue;if(a.indexOf(!0)<0||c.indexOf(!0)<0)continue;var g=[];if(m.forEach(function(e){-1===g.indexOf(e)&&(e.deletePending=!0,g.push(e))}),g.length%2!==0)continue;l.q=u.q.add(l.q),l.updatePosition(f);var v=n.references.length;s=n.updateTriangles(l,l,a,s),s=n.updateTriangles(l,u,c,s);var y=n.references.length-v;if(y<=l.triangleCount){if(y)for(var x=0;y>x;x++)n.references[l.triangleStart+x]=n.references[v+x]}else l.triangleStart=v;l.triangleCount=y;break}};e.AsyncLoop.SyncAsyncForLoop(n.triangles.length,n.syncIterations,c,i,function(){return o>=a-s})},0)};e.AsyncLoop.Run(this.decimationIterations,function(e){o>=a-s?e.breakLoop():h(e.index,function(){e.executeNext()})},function(){setTimeout(function(){n.reconstructMesh(i),r()},0)})},t.prototype.initWithMesh=function(t,i,r){var s=this;this.vertices=[],this.triangles=[];var a=this._mesh.getVerticesData(e.VertexBuffer.PositionKind),h=this._mesh.getIndices(),c=this._mesh.subMeshes[t],l=function(e){if(r)for(var t=0;t<s.vertices.length;++t)if(s.vertices[t].position.equals(e))return s.vertices[t];return null},u=[],f=function(t){var i=t+c.verticesStart,r=e.Vector3.FromArray(a,3*i),n=l(r)||new o(r,s.vertices.length);n.originalOffsets.push(i),n.id===s.vertices.length&&s.vertices.push(n),u.push(n.id)},d=c.verticesCount;e.AsyncLoop.SyncAsyncForLoop(d,this.syncIterations/4>>0,f,function(){var t=function(e){var t=c.indexStart/3+e,i=3*t,r=h[i+0],o=h[i+1],a=h[i+2],l=s.vertices[u[r-c.verticesStart]],f=s.vertices[u[o-c.verticesStart]],d=s.vertices[u[a-c.verticesStart]],p=new n([l,f,d]);p.originalOffset=i,s.triangles.push(p)};e.AsyncLoop.SyncAsyncForLoop(c.indexCount/3,s.syncIterations,t,function(){s.init(i)})})},t.prototype.init=function(t){var i=this,r=function(t){var r=i.triangles[t];r.normal=e.Vector3.Cross(r.vertices[1].position.subtract(r.vertices[0].position),r.vertices[2].position.subtract(r.vertices[0].position)).normalize();
  29. for(var n=0;3>n;n++)r.vertices[n].q.addArrayInPlace(s.DataFromNumbers(r.normal.x,r.normal.y,r.normal.z,-e.Vector3.Dot(r.normal,r.vertices[0].position)))};e.AsyncLoop.SyncAsyncForLoop(this.triangles.length,this.syncIterations,r,function(){var r=function(e){for(var t=i.triangles[e],r=0;3>r;++r)t.error[r]=i.calculateError(t.vertices[r],t.vertices[(r+1)%3]);t.error[3]=Math.min(t.error[0],t.error[1],t.error[2])};e.AsyncLoop.SyncAsyncForLoop(i.triangles.length,i.syncIterations,r,function(){i.initialized=!0,t()})})},t.prototype.reconstructMesh=function(t){var i,r=[];for(i=0;i<this.vertices.length;++i)this.vertices[i].triangleCount=0;var n,o;for(i=0;i<this.triangles.length;++i)if(!this.triangles[i].deleted){for(n=this.triangles[i],o=0;3>o;++o)n.vertices[o].triangleCount=1;r.push(n)}var s=this._reconstructedMesh.getVerticesData(e.VertexBuffer.PositionKind)||[],a=this._reconstructedMesh.getVerticesData(e.VertexBuffer.NormalKind)||[],h=this._reconstructedMesh.getVerticesData(e.VertexBuffer.UVKind)||[],c=this._reconstructedMesh.getVerticesData(e.VertexBuffer.ColorKind)||[],l=this._mesh.getVerticesData(e.VertexBuffer.NormalKind),u=this._mesh.getVerticesData(e.VertexBuffer.UVKind),f=this._mesh.getVerticesData(e.VertexBuffer.ColorKind),d=0;for(i=0;i<this.vertices.length;++i){var p=this.vertices[i];p.id=d,p.triangleCount&&p.originalOffsets.forEach(function(e){s.push(p.position.x),s.push(p.position.y),s.push(p.position.z),a.push(l[3*e]),a.push(l[3*e+1]),a.push(l[3*e+2]),u&&u.length?(h.push(u[2*e]),h.push(u[2*e+1])):f&&f.length&&(c.push(f[4*e]),c.push(f[4*e+1]),c.push(f[4*e+2]),c.push(f[4*e+3])),++d})}var _=this._reconstructedMesh.getTotalIndices(),m=this._reconstructedMesh.getTotalVertices(),g=this._reconstructedMesh.subMeshes;this._reconstructedMesh.subMeshes=[];var v=this._reconstructedMesh.getIndices(),y=this._mesh.getIndices();for(i=0;i<r.length;++i)n=r[i],[0,1,2].forEach(function(e){var t=y[n.originalOffset+e],i=n.vertices[e].originalOffsets.indexOf(t);0>i&&(i=0),v.push(n.vertices[e].id+i+m)});this._reconstructedMesh.setIndices(v),this._reconstructedMesh.setVerticesData(e.VertexBuffer.PositionKind,s),this._reconstructedMesh.setVerticesData(e.VertexBuffer.NormalKind,a),h.length>0&&this._reconstructedMesh.setVerticesData(e.VertexBuffer.UVKind,h),c.length>0&&this._reconstructedMesh.setVerticesData(e.VertexBuffer.ColorKind,c);var x=this._mesh.subMeshes[t];if(t>0){this._reconstructedMesh.subMeshes=[],g.forEach(function(t){new e.SubMesh(t.materialIndex,t.verticesStart,t.verticesCount,t.indexStart,t.indexCount,t.getMesh())});new e.SubMesh(x.materialIndex,m,d,_,3*r.length,this._reconstructedMesh)}},t.prototype.initDecimatedMesh=function(){this._reconstructedMesh=new e.Mesh(this._mesh.name+"Decimated",this._mesh.getScene()),this._reconstructedMesh.material=this._mesh.material,this._reconstructedMesh.parent=this._mesh.parent,this._reconstructedMesh.isVisible=!1,this._reconstructedMesh.renderingGroupId=this._mesh.renderingGroupId},t.prototype.isFlipped=function(t,i,r,n,o,s){for(var a=0;a<t.triangleCount;++a){var h=this.triangles[this.references[t.triangleStart+a].triangleId];if(!h.deleted){var c=this.references[t.triangleStart+a].vertexId,l=h.vertices[(c+1)%3],u=h.vertices[(c+2)%3];if(l!==i&&u!==i){var f=l.position.subtract(r);f=f.normalize();var d=u.position.subtract(r);if(d=d.normalize(),Math.abs(e.Vector3.Dot(f,d))>.999)return!0;var p=e.Vector3.Cross(f,d).normalize();if(n[a]=!1,e.Vector3.Dot(p,h.normal)<.2)return!0}else n[a]=!0,s.push(h)}}return!1},t.prototype.updateTriangles=function(e,t,i,r){for(var n=r,o=0;o<t.triangleCount;++o){var s=this.references[t.triangleStart+o],a=this.triangles[s.triangleId];a.deleted||(i[o]&&a.deletePending?(a.deleted=!0,n++):(a.vertices[s.vertexId]=e,a.isDirty=!0,a.error[0]=this.calculateError(a.vertices[0],a.vertices[1])+a.borderFactor/2,a.error[1]=this.calculateError(a.vertices[1],a.vertices[2])+a.borderFactor/2,a.error[2]=this.calculateError(a.vertices[2],a.vertices[0])+a.borderFactor/2,a.error[3]=Math.min(a.error[0],a.error[1],a.error[2]),this.references.push(s)))}return n},t.prototype.identifyBorder=function(){for(var e=0;e<this.vertices.length;++e){var t,i=[],r=[],n=this.vertices[e];for(t=0;t<n.triangleCount;++t)for(var o=this.triangles[this.references[n.triangleStart+t].triangleId],s=0;3>s;s++){for(var a=0,h=o.vertices[s];a<i.length&&r[a]!==h.id;)++a;a===i.length?(i.push(1),r.push(h.id)):i[a]++}for(t=0;t<i.length;++t)1===i[t]?this.vertices[r[t]].isBorder=!0:this.vertices[r[t]].isBorder=!1}},t.prototype.updateMesh=function(e){void 0===e&&(e=!1);var t;if(!e){var i=[];for(t=0;t<this.triangles.length;++t)this.triangles[t].deleted||i.push(this.triangles[t]);this.triangles=i}for(t=0;t<this.vertices.length;++t)this.vertices[t].triangleCount=0,this.vertices[t].triangleStart=0;var r,n,o;for(t=0;t<this.triangles.length;++t)for(r=this.triangles[t],n=0;3>n;++n)o=r.vertices[n],o.triangleCount++;var s=0;for(t=0;t<this.vertices.length;++t)this.vertices[t].triangleStart=s,s+=this.vertices[t].triangleCount,this.vertices[t].triangleCount=0;var h=new Array(3*this.triangles.length);for(t=0;t<this.triangles.length;++t)for(r=this.triangles[t],n=0;3>n;++n)o=r.vertices[n],h[o.triangleStart+o.triangleCount]=new a(n,t),o.triangleCount++;this.references=h,e&&this.identifyBorder()},t.prototype.vertexError=function(e,t){var i=t.x,r=t.y,n=t.z;return e.data[0]*i*i+2*e.data[1]*i*r+2*e.data[2]*i*n+2*e.data[3]*i+e.data[4]*r*r+2*e.data[5]*r*n+2*e.data[6]*r+e.data[7]*n*n+2*e.data[8]*n+e.data[9]},t.prototype.calculateError=function(t,i,r,n,o,s){var a=t.q.add(i.q),h=t.isBorder&&i.isBorder,c=0,l=a.det(0,1,2,1,4,5,2,5,7);if(0===l||h){var u=t.position.add(i.position).divide(new e.Vector3(2,2,2)),f=this.vertexError(a,t.position),d=this.vertexError(a,i.position),p=this.vertexError(a,u);c=Math.min(f,d,p),c===f?r&&r.copyFrom(t.position):c===d?r&&r.copyFrom(i.position):r&&r.copyFrom(u)}else r||(r=e.Vector3.Zero()),r.x=-1/l*a.det(1,2,3,4,5,6,5,7,8),r.y=1/l*a.det(0,2,3,1,5,6,2,7,8),r.z=-1/l*a.det(0,1,3,1,4,6,2,5,8),c=this.vertexError(a,r);return c},t}();e.QuadraticErrorSimplification=h}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=[],i=function(i,r){if(!t[i.id]){if(i instanceof e.Geometry.Primitives.Box)r.boxes.push(i.serialize());else if(i instanceof e.Geometry.Primitives.Sphere)r.spheres.push(i.serialize());else if(i instanceof e.Geometry.Primitives.Cylinder)r.cylinders.push(i.serialize());else if(i instanceof e.Geometry.Primitives.Torus)r.toruses.push(i.serialize());else if(i instanceof e.Geometry.Primitives.Ground)r.grounds.push(i.serialize());else if(i instanceof e.Geometry.Primitives.Plane)r.planes.push(i.serialize());else if(i instanceof e.Geometry.Primitives.TorusKnot)r.torusKnots.push(i.serialize());else{if(i instanceof e.Geometry.Primitives._Primitive)throw new Error("Unknown primitive type");r.vertexData.push(i.serializeVerticeData())}t[i.id]=!0}},r=function(t,r){var n={};n.name=t.name,n.id=t.id,e.Tags.HasTags(t)&&(n.tags=e.Tags.GetTags(t)),n.position=t.position.asArray(),t.rotationQuaternion?n.rotationQuaternion=t.rotationQuaternion.asArray():t.rotation&&(n.rotation=t.rotation.asArray()),n.scaling=t.scaling.asArray(),n.localMatrix=t.getPivotMatrix().asArray(),n.isEnabled=t.isEnabled(),n.isVisible=t.isVisible,n.infiniteDistance=t.infiniteDistance,n.pickable=t.isPickable,n.receiveShadows=t.receiveShadows,n.billboardMode=t.billboardMode,n.visibility=t.visibility,n.checkCollisions=t.checkCollisions,t.parent&&(n.parentId=t.parent.id);var o=t._geometry;if(o){var s=o.id;n.geometryId=s,t.getScene().getGeometryByID(s)||i(o,r.geometries),n.subMeshes=[];for(var a=0;a<t.subMeshes.length;a++){var h=t.subMeshes[a];n.subMeshes.push({materialIndex:h.materialIndex,verticesStart:h.verticesStart,verticesCount:h.verticesCount,indexStart:h.indexStart,indexCount:h.indexCount})}}t.material?n.materialId=t.material.id:t.material=null,t.skeleton&&(n.skeletonId=t.skeleton.id),t.getPhysicsImpostor()&&(n.physicsMass=t.getPhysicsMass(),n.physicsFriction=t.getPhysicsFriction(),n.physicsRestitution=t.getPhysicsRestitution(),n.physicsImpostor=t.getPhysicsImpostor().type),n.instances=[];for(var c=0;c<t.instances.length;c++){var l=t.instances[c],u={name:l.name,position:l.position.asArray(),scaling:l.scaling.asArray()};l.rotationQuaternion?u.rotationQuaternion=l.rotationQuaternion.asArray():l.rotation&&(u.rotation=l.rotation.asArray()),n.instances.push(u),e.Animation.AppendSerializedAnimations(l,u),u.ranges=l.serializeAnimationRanges()}return e.Animation.AppendSerializedAnimations(t,n),n.ranges=t.serializeAnimationRanges(),n.layerMask=t.layerMask,t.actionManager&&(n.actions=t.actionManager.serialize(t.name)),n},n=function(t,n){if(t.delayLoadState===e.Engine.DELAYLOADSTATE_LOADED||t.delayLoadState===e.Engine.DELAYLOADSTATE_NONE){t.material&&(t.material instanceof e.StandardMaterial?(n.materials=n.materials||[],n.materials.some(function(e){return e.id===t.material.id})||n.materials.push(t.material.serialize())):t.material instanceof e.MultiMaterial&&(n.multiMaterials=n.multiMaterials||[],n.multiMaterials.some(function(e){return e.id===t.material.id})||n.multiMaterials.push(t.material.serialize())));var o=t._geometry;o&&(n.geometries||(n.geometries={},n.geometries.boxes=[],n.geometries.spheres=[],n.geometries.cylinders=[],n.geometries.toruses=[],n.geometries.grounds=[],n.geometries.planes=[],n.geometries.torusKnots=[],n.geometries.vertexData=[]),i(o,n.geometries)),t.skeleton&&(n.skeletons=n.skeletons||[],n.skeletons.push(t.skeleton.serialize())),n.meshes=n.meshes||[],n.meshes.push(r(t,n))}},o=function(){function o(){}return o.ClearCache=function(){t=[]},o.Serialize=function(n){var o={};o.useDelayedTextureLoading=n.useDelayedTextureLoading,o.autoClear=n.autoClear,o.clearColor=n.clearColor.asArray(),o.ambientColor=n.ambientColor.asArray(),o.gravity=n.gravity.asArray(),o.collisionsEnabled=n.collisionsEnabled,o.workerCollisions=n.workerCollisions,n.fogMode&&0!==n.fogMode&&(o.fogMode=n.fogMode,o.fogColor=n.fogColor.asArray(),o.fogStart=n.fogStart,o.fogEnd=n.fogEnd,o.fogDensity=n.fogDensity),n.isPhysicsEnabled()&&(o.physicsEnabled=!0,o.physicsGravity=n.getPhysicsEngine().gravity.asArray(),o.physicsEngine=n.getPhysicsEngine().getPhysicsPluginName()),o.lights=[];var s,a;for(s=0;s<n.lights.length;s++)a=n.lights[s],o.lights.push(a.serialize());for(o.cameras=[],s=0;s<n.cameras.length;s++){var h=n.cameras[s];o.cameras.push(h.serialize())}n.activeCamera&&(o.activeCameraID=n.activeCamera.id),e.Animation.AppendSerializedAnimations(n,o),o.materials=[],o.multiMaterials=[];var c;for(s=0;s<n.materials.length;s++)c=n.materials[s],o.materials.push(c.serialize());for(o.multiMaterials=[],s=0;s<n.multiMaterials.length;s++){var l=n.multiMaterials[s];o.multiMaterials.push(l.serialize())}for(o.skeletons=[],s=0;s<n.skeletons.length;s++)o.skeletons.push(n.skeletons[s].serialize());o.geometries={},o.geometries.boxes=[],o.geometries.spheres=[],o.geometries.cylinders=[],o.geometries.toruses=[],o.geometries.grounds=[],o.geometries.planes=[],o.geometries.torusKnots=[],o.geometries.vertexData=[],t=[];var u=n.getGeometries();for(s=0;s<u.length;s++){var f=u[s];f.isReady()&&i(f,o.geometries)}for(o.meshes=[],s=0;s<n.meshes.length;s++){var d=n.meshes[s];if(d instanceof e.Mesh){var p=d;p.delayLoadState!==e.Engine.DELAYLOADSTATE_LOADED&&p.delayLoadState!==e.Engine.DELAYLOADSTATE_NONE||o.meshes.push(r(p,o))}}for(o.particleSystems=[],s=0;s<n.particleSystems.length;s++)o.particleSystems.push(n.particleSystems[s].serialize());for(o.lensFlareSystems=[],s=0;s<n.lensFlareSystems.length;s++)o.lensFlareSystems.push(n.lensFlareSystems[s].serialize());for(o.shadowGenerators=[],s=0;s<n.lights.length;s++)a=n.lights[s],a.getShadowGenerator()&&o.shadowGenerators.push(a.getShadowGenerator().serialize());return n.actionManager&&(o.actions=n.actionManager.serialize("scene")),o},o.SerializeMesh=function(t,i,r){void 0===i&&(i=!1),void 0===r&&(r=!1);var o={};if(t=t instanceof Array?t:[t],i||r)for(var s=0;s<t.length;++s)r&&t[s].getDescendants().forEach(function(i){i instanceof e.Mesh&&t.indexOf(i)<0&&t.push(i)}),i&&t[s].parent&&t.indexOf(t[s].parent)<0&&t.push(t[s].parent);return t.forEach(function(e){n(e,o)}),o},o}();e.SceneSerializer=o}(BABYLON||(BABYLON={}));var Earcut;!function(e){function t(e,t,r){r=r||2;var o=t&&t.length,s=o?t[0]*r:e.length,a=i(e,0,s,r,!0),h=[];if(!a)return h;var l,u,f,d,p,_,m;if(o&&(a=c(e,t,a,r)),e.length>80*r){l=f=e[0],u=d=e[1];for(var g=r;s>g;g+=r)p=e[g],_=e[g+1],l>p&&(l=p),u>_&&(u=_),p>f&&(f=p),_>d&&(d=_);m=Math.max(f-l,d-u)}return n(a,h,r,l,u,m,void 0),h}function i(e,t,i,r,n){var o,s;if(n===D(e,t,i,r)>0)for(o=t;i>o;o+=r)s=C(o,e[o],e[o+1],s);else for(o=i-r;o>=t;o-=r)s=C(o,e[o],e[o+1],s);return s&&x(s,s.next)&&(S(s),s=s.next),s}function r(e,t){if(!e)return e;t||(t=e);var i,r=e;do if(i=!1,r.steiner||!x(r,r.next)&&0!==y(r.prev,r,r.next))r=r.next;else{if(S(r),r=t=r.prev,r===r.next)return null;i=!0}while(i||r!==t);return t}function n(e,t,i,c,l,u,f){if(e){!f&&u&&d(e,c,l,u);for(var p,_,m=e;e.prev!==e.next;)if(p=e.prev,_=e.next,u?s(e,c,l,u):o(e))t.push(p.i/i),t.push(e.i/i),t.push(_.i/i),S(e),e=_.next,m=_.next;else if(e=_,e===m){f?1===f?(e=a(e,t,i),n(e,t,i,c,l,u,2)):2===f&&h(e,t,i,c,l,u):n(r(e,void 0),t,i,c,l,u,1);break}}}function o(e){var t=e.prev,i=e,r=e.next;if(y(t,i,r)>=0)return!1;for(var n=e.next.next;n!==e.prev;){if(g(t.x,t.y,i.x,i.y,r.x,r.y,n.x,n.y)&&y(n.prev,n,n.next)>=0)return!1;n=n.next}return!0}function s(e,t,i,r){var n=e.prev,o=e,s=e.next;if(y(n,o,s)>=0)return!1;for(var a=n.x<o.x?n.x<s.x?n.x:s.x:o.x<s.x?o.x:s.x,h=n.y<o.y?n.y<s.y?n.y:s.y:o.y<s.y?o.y:s.y,c=n.x>o.x?n.x>s.x?n.x:s.x:o.x>s.x?o.x:s.x,l=n.y>o.y?n.y>s.y?n.y:s.y:o.y>s.y?o.y:s.y,u=_(a,h,t,i,r),f=_(c,l,t,i,r),d=e.nextZ;d&&d.z<=f;){if(d!==e.prev&&d!==e.next&&g(n.x,n.y,o.x,o.y,s.x,s.y,d.x,d.y)&&y(d.prev,d,d.next)>=0)return!1;d=d.nextZ}for(d=e.prevZ;d&&d.z>=u;){if(d!==e.prev&&d!==e.next&&g(n.x,n.y,o.x,o.y,s.x,s.y,d.x,d.y)&&y(d.prev,d,d.next)>=0)return!1;d=d.prevZ}return!0}function a(e,t,i){var r=e;do{var n=r.prev,o=r.next.next;!x(n,o)&&b(n,r,r.next,o)&&A(n,o)&&A(o,n)&&(t.push(n.i/i),t.push(r.i/i),t.push(o.i/i),S(r),S(r.next),r=e=o),r=r.next}while(r!==e);return r}function h(e,t,i,o,s,a){var h=e;do{for(var c=h.next.next;c!==h.prev;){if(h.i!==c.i&&v(h,c)){var l=E(h,c);return h=r(h,h.next),l=r(l,l.next),n(h,t,i,o,s,a,void 0),void n(l,t,i,o,s,a,void 0)}c=c.next}h=h.next}while(h!==e)}function c(e,t,n,o){var s,a,h,c,f,d=[];for(s=0,a=t.length;a>s;s++)h=t[s]*o,c=a-1>s?t[s+1]*o:e.length,f=i(e,h,c,o,!1),f===f.next&&(f.steiner=!0),d.push(m(f));for(d.sort(l),s=0;s<d.length;s++)u(d[s],n),n=r(n,n.next);return n}function l(e,t){return e.x-t.x}function u(e,t){if(t=f(e,t)){var i=E(t,e);r(i,i.next)}}function f(e,t){var i,r=t,n=e.x,o=e.y,s=-(1/0);do{if(o<=r.y&&o>=r.next.y){var a=r.x+(o-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(n>=a&&a>s){if(s=a,a===n){if(o===r.y)return r;if(o===r.next.y)return r.next}i=r.x<r.next.x?r:r.next}}r=r.next}while(r!==t);if(!i)return null;if(n===s)return i.prev;var h,c=i,l=i.x,u=i.y,f=1/0;for(r=i.next;r!==c;)n>=r.x&&r.x>=l&&g(u>o?n:s,o,l,u,u>o?s:n,o,r.x,r.y)&&(h=Math.abs(o-r.y)/(n-r.x),(f>h||h===f&&r.x>i.x)&&A(r,e)&&(i=r,f=h)),r=r.next;return i}function d(e,t,i,r){var n=e;do null===n.z&&(n.z=_(n.x,n.y,t,i,r)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next;while(n!==e);n.prevZ.nextZ=null,n.prevZ=null,p(n)}function p(e){var t,i,r,n,o,s,a,h,c=1;do{for(i=e,e=null,o=null,s=0;i;){for(s++,r=i,a=0,t=0;c>t&&(a++,r=r.nextZ,r);t++);for(h=c;a>0||h>0&&r;)0===a?(n=r,r=r.nextZ,h--):0!==h&&r?i.z<=r.z?(n=i,i=i.nextZ,a--):(n=r,r=r.nextZ,h--):(n=i,i=i.nextZ,a--),o?o.nextZ=n:e=n,n.prevZ=o,o=n;i=r}o.nextZ=null,c*=2}while(s>1);return e}function _(e,t,i,r,n){return e=32767*(e-i)/n,t=32767*(t-r)/n,e=16711935&(e|e<<8),e=252645135&(e|e<<4),e=858993459&(e|e<<2),e=1431655765&(e|e<<1),t=16711935&(t|t<<8),t=252645135&(t|t<<4),t=858993459&(t|t<<2),t=1431655765&(t|t<<1),e|t<<1}function m(e){var t=e,i=e;do t.x<i.x&&(i=t),t=t.next;while(t!==e);return i}function g(e,t,i,r,n,o,s,a){return(n-s)*(t-a)-(e-s)*(o-a)>=0&&(e-s)*(r-a)-(i-s)*(t-a)>=0&&(i-s)*(o-a)-(n-s)*(r-a)>=0}function v(e,t){return e.next.i!==t.i&&e.prev.i!==t.i&&!P(e,t)&&A(e,t)&&A(t,e)&&T(e,t)}function y(e,t,i){return(t.y-e.y)*(i.x-t.x)-(t.x-e.x)*(i.y-t.y)}function x(e,t){return e.x===t.x&&e.y===t.y}function b(e,t,i,r){return x(e,t)&&x(i,r)||x(e,r)&&x(i,t)?!0:y(e,t,i)>0!=y(e,t,r)>0&&y(i,r,e)>0!=y(i,r,t)>0}function P(e,t){var i=e;do{if(i.i!==e.i&&i.next.i!==e.i&&i.i!==t.i&&i.next.i!==t.i&&b(i,i.next,e,t))return!0;i=i.next}while(i!==e);return!1}function A(e,t){return y(e.prev,e,e.next)<0?y(e,t,e.next)>=0&&y(e,e.prev,t)>=0:y(e,t,e.prev)<0||y(e,e.next,t)<0}function T(e,t){var i=e,r=!1,n=(e.x+t.x)/2,o=(e.y+t.y)/2;do i.y>o!=i.next.y>o&&n<(i.next.x-i.x)*(o-i.y)/(i.next.y-i.y)+i.x&&(r=!r),i=i.next;while(i!==e);return r}function E(e,t){var i=new M(e.i,e.x,e.y),r=new M(t.i,t.x,t.y),n=e.next,o=t.prev;return e.next=t,t.prev=e,i.next=n,n.prev=i,r.next=i,i.prev=r,o.next=r,r.prev=o,r}function C(e,t,i,r){var n=new M(e,t,i);return r?(n.next=r.next,n.prev=r,r.next.prev=n,r.next=n):(n.prev=n,n.next=n),n}function S(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function M(e,t,i){this.i=e,this.x=t,this.y=i,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function I(e,t,i,r){var n=t&&t.length,o=n?t[0]*i:e.length,s=Math.abs(D(e,0,o,i));if(n)for(var a=0,h=t.length;h>a;a++){var c=t[a]*i,l=h-1>a?t[a+1]*i:e.length;s-=Math.abs(D(e,c,l,i))}var u=0;for(a=0;a<r.length;a+=3){var f=r[a]*i,d=r[a+1]*i,p=r[a+2]*i;u+=Math.abs((e[f]-e[p])*(e[d+1]-e[f+1])-(e[f]-e[d])*(e[p+1]-e[f+1]))}return 0===s&&0===u?0:Math.abs((u-s)/s)}function D(e,t,i,r){for(var n=0,o=t,s=i-r;i>o;o+=r)n+=(e[s]-e[o])*(e[o+1]+e[s+1]),s=o;return n}function R(e){for(var t=e[0][0].length,i={vertices:[],holes:[],dimensions:t},r=0,n=0;n<e.length;n++){for(var o=0;o<e[n].length;o++)for(var s=0;t>s;s++)i.vertices.push(e[n][o][s]);n>0&&(r+=e[n-1].length,i.holes.push(r))}return i}e.earcut=t,e.deviation=I,e.flatten=R}(Earcut||(Earcut={}));var BABYLON;!function(e){var t=0,i=function(){function t(e,t,i){this.pos=e,this.normal=t,this.uv=i}return t.prototype.clone=function(){return new t(this.pos.clone(),this.normal.clone(),this.uv.clone())},t.prototype.flip=function(){this.normal=this.normal.scale(-1)},t.prototype.interpolate=function(i,r){return new t(e.Vector3.Lerp(this.pos,i.pos,r),e.Vector3.Lerp(this.normal,i.normal,r),e.Vector2.Lerp(this.uv,i.uv,r))},t}(),r=function(){function t(e,t){this.normal=e,this.w=t}return t.FromPoints=function(i,r,n){var o=n.subtract(i),s=r.subtract(i);if(0===o.lengthSquared()||0===s.lengthSquared())return null;var a=e.Vector3.Normalize(e.Vector3.Cross(o,s));return new t(a,e.Vector3.Dot(a,i))},t.prototype.clone=function(){return new t(this.normal.clone(),this.w)},t.prototype.flip=function(){this.normal.scaleInPlace(-1),this.w=-this.w},t.prototype.splitPolygon=function(i,r,o,s,a){var h,c,l=0,u=1,f=2,d=3,p=0,_=[];for(h=0;h<i.vertices.length;h++){c=e.Vector3.Dot(this.normal,i.vertices[h].pos)-this.w;var m=c<-t.EPSILON?f:c>t.EPSILON?u:l;p|=m,_.push(m)}switch(p){case l:(e.Vector3.Dot(this.normal,i.plane.normal)>0?r:o).push(i);break;case u:s.push(i);break;case f:a.push(i);break;case d:var g=[],v=[];for(h=0;h<i.vertices.length;h++){var y=(h+1)%i.vertices.length,x=_[h],b=_[y],P=i.vertices[h],A=i.vertices[y];if(x!==f&&g.push(P),x!==u&&v.push(x!==f?P.clone():P),(x|b)===d){c=(this.w-e.Vector3.Dot(this.normal,P.pos))/e.Vector3.Dot(this.normal,A.pos.subtract(P.pos));var T=P.interpolate(A,c);g.push(T),v.push(T.clone())}}var E;g.length>=3&&(E=new n(g,i.shared),E.plane&&s.push(E)),v.length>=3&&(E=new n(v,i.shared),E.plane&&a.push(E))}},t.EPSILON=1e-5,t}(),n=function(){function e(e,t){this.vertices=e,this.shared=t,this.plane=r.FromPoints(e[0].pos,e[1].pos,e[2].pos)}return e.prototype.clone=function(){var t=this.vertices.map(function(e){return e.clone()});return new e(t,this.shared)},e.prototype.flip=function(){this.vertices.reverse().map(function(e){e.flip()}),this.plane.flip()},e}(),o=function(){function e(e){this.plane=null,this.front=null,this.back=null,this.polygons=[],e&&this.build(e)}return e.prototype.clone=function(){var t=new e;return t.plane=this.plane&&this.plane.clone(),t.front=this.front&&this.front.clone(),t.back=this.back&&this.back.clone(),t.polygons=this.polygons.map(function(e){return e.clone()}),t},e.prototype.invert=function(){for(var e=0;e<this.polygons.length;e++)this.polygons[e].flip();this.plane&&this.plane.flip(),this.front&&this.front.invert(),this.back&&this.back.invert();var t=this.front;this.front=this.back,this.back=t},e.prototype.clipPolygons=function(e){if(!this.plane)return e.slice();for(var t=[],i=[],r=0;r<e.length;r++)this.plane.splitPolygon(e[r],t,i,t,i);return this.front&&(t=this.front.clipPolygons(t)),i=this.back?this.back.clipPolygons(i):[],t.concat(i)},e.prototype.clipTo=function(e){this.polygons=e.clipPolygons(this.polygons),this.front&&this.front.clipTo(e),this.back&&this.back.clipTo(e)},e.prototype.allPolygons=function(){var e=this.polygons.slice();return this.front&&(e=e.concat(this.front.allPolygons())),this.back&&(e=e.concat(this.back.allPolygons())),e},e.prototype.build=function(t){if(t.length){this.plane||(this.plane=t[0].plane.clone());for(var i=[],r=[],n=0;n<t.length;n++)this.plane.splitPolygon(t[n],this.polygons,this.polygons,i,r);i.length&&(this.front||(this.front=new e),this.front.build(i)),r.length&&(this.back||(this.back=new e),this.back.build(r))}},e}(),s=function(){function r(){this.polygons=new Array}return r.FromMesh=function(o){var s,a,h,c,l,u,f,d,p,_,m,g=new Array;if(!(o instanceof e.Mesh))throw"BABYLON.CSG: Wrong Mesh type, must be BABYLON.Mesh";o.computeWorldMatrix(!0),f=o.getWorldMatrix(),d=o.position.clone(),p=o.rotation.clone(),o.rotationQuaternion&&(_=o.rotationQuaternion.clone()),m=o.scaling.clone();for(var v=o.getIndices(),y=o.getVerticesData(e.VertexBuffer.PositionKind),x=o.getVerticesData(e.VertexBuffer.NormalKind),b=o.getVerticesData(e.VertexBuffer.UVKind),P=o.subMeshes,A=0,T=P.length;T>A;A++)for(var E=P[A].indexStart,C=P[A].indexCount+P[A].indexStart;C>E;E+=3){u=[];for(var S=0;3>S;S++){var M=new e.Vector3(x[3*v[E+S]],x[3*v[E+S]+1],x[3*v[E+S]+2]);h=new e.Vector2(b[2*v[E+S]],b[2*v[E+S]+1]);var I=new e.Vector3(y[3*v[E+S]],y[3*v[E+S]+1],y[3*v[E+S]+2]);c=e.Vector3.TransformCoordinates(I,f),a=e.Vector3.TransformNormal(M,f),s=new i(c,a,h),u.push(s)}l=new n(u,{subMeshId:A,meshId:t,materialIndex:P[A].materialIndex}),l.plane&&g.push(l)}var D=r.FromPolygons(g);return D.matrix=f,D.position=d,D.rotation=p,D.scaling=m,D.rotationQuaternion=_,t++,D},r.FromPolygons=function(e){var t=new r;return t.polygons=e,t},r.prototype.clone=function(){var e=new r;return e.polygons=this.polygons.map(function(e){return e.clone()}),e.copyTransformAttributes(this),e},r.prototype.toPolygons=function(){return this.polygons},r.prototype.union=function(e){var t=new o(this.clone().polygons),i=new o(e.clone().polygons);return t.clipTo(i),i.clipTo(t),i.invert(),i.clipTo(t),i.invert(),t.build(i.allPolygons()),r.FromPolygons(t.allPolygons()).copyTransformAttributes(this)},r.prototype.unionInPlace=function(e){var t=new o(this.polygons),i=new o(e.polygons);t.clipTo(i),i.clipTo(t),i.invert(),i.clipTo(t),i.invert(),t.build(i.allPolygons()),this.polygons=t.allPolygons()},r.prototype.subtract=function(e){var t=new o(this.clone().polygons),i=new o(e.clone().polygons);return t.invert(),t.clipTo(i),i.clipTo(t),i.invert(),i.clipTo(t),i.invert(),t.build(i.allPolygons()),t.invert(),r.FromPolygons(t.allPolygons()).copyTransformAttributes(this)},r.prototype.subtractInPlace=function(e){var t=new o(this.polygons),i=new o(e.polygons);t.invert(),t.clipTo(i),i.clipTo(t),i.invert(),i.clipTo(t),i.invert(),t.build(i.allPolygons()),t.invert(),this.polygons=t.allPolygons()},r.prototype.intersect=function(e){var t=new o(this.clone().polygons),i=new o(e.clone().polygons);return t.invert(),i.clipTo(t),i.invert(),t.clipTo(i),i.clipTo(t),t.build(i.allPolygons()),t.invert(),r.FromPolygons(t.allPolygons()).copyTransformAttributes(this)},r.prototype.intersectInPlace=function(e){var t=new o(this.polygons),i=new o(e.polygons);t.invert(),i.clipTo(t),i.invert(),t.clipTo(i),i.clipTo(t),t.build(i.allPolygons()),t.invert(),this.polygons=t.allPolygons()},r.prototype.inverse=function(){var e=this.clone();return e.inverseInPlace(),e},r.prototype.inverseInPlace=function(){this.polygons.map(function(e){e.flip()})},r.prototype.copyTransformAttributes=function(e){return this.matrix=e.matrix,this.position=e.position,this.rotation=e.rotation,this.scaling=e.scaling,this.rotationQuaternion=e.rotationQuaternion,this},r.prototype.buildMeshGeometry=function(t,i,r){var n=this.matrix.clone();n.invert();var o,s,a,h=new e.Mesh(t,i),c=[],l=[],u=[],f=[],d=e.Vector3.Zero(),p=e.Vector3.Zero(),_=e.Vector2.Zero(),m=this.polygons,g=[0,0,0],v={},y=0,x={};r&&m.sort(function(e,t){return e.shared.meshId===t.shared.meshId?e.shared.subMeshId-t.shared.subMeshId:e.shared.meshId-t.shared.meshId});for(var b=0,P=m.length;P>b;b++){o=m[b],x[o.shared.meshId]||(x[o.shared.meshId]={}),x[o.shared.meshId][o.shared.subMeshId]||(x[o.shared.meshId][o.shared.subMeshId]={indexStart:+(1/0),indexEnd:-(1/0),materialIndex:o.shared.materialIndex}),a=x[o.shared.meshId][o.shared.subMeshId];for(var A=2,T=o.vertices.length;T>A;A++){g[0]=0,g[1]=A-1,g[2]=A;for(var E=0;3>E;E++){d.copyFrom(o.vertices[g[E]].pos),p.copyFrom(o.vertices[g[E]].normal),_.copyFrom(o.vertices[g[E]].uv);var C=e.Vector3.TransformCoordinates(d,n),S=e.Vector3.TransformNormal(p,n);s=v[C.x+","+C.y+","+C.z],"undefined"!=typeof s&&u[3*s]===S.x&&u[3*s+1]===S.y&&u[3*s+2]===S.z&&f[2*s]===_.x&&f[2*s+1]===_.y||(c.push(C.x,C.y,C.z),f.push(_.x,_.y),u.push(p.x,p.y,p.z),s=v[C.x+","+C.y+","+C.z]=c.length/3-1),l.push(s),a.indexStart=Math.min(y,a.indexStart),a.indexEnd=Math.max(y,a.indexEnd),y++}}}if(h.setVerticesData(e.VertexBuffer.PositionKind,c),h.setVerticesData(e.VertexBuffer.NormalKind,u),h.setVerticesData(e.VertexBuffer.UVKind,f),h.setIndices(l),r){var M,I=0;h.subMeshes=new Array;for(var D in x){M=-1;for(var R in x[D])a=x[D][R],e.SubMesh.CreateFromIndices(a.materialIndex+I,a.indexStart,a.indexEnd-a.indexStart+1,h),M=Math.max(a.materialIndex,M);I+=++M}}return h},r.prototype.toMesh=function(e,t,i,r){var n=this.buildMeshGeometry(e,i,r);return n.material=t,n.position.copyFrom(this.position),n.rotation.copyFrom(this.rotation),this.rotationQuaternion&&(n.rotationQuaternion=this.rotationQuaternion.clone()),n.scaling.copyFrom(this.scaling),n.computeWorldMatrix(!0),n},r}();e.CSG=s}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(t){function i(i,r,n,o){var s=this;t.call(this,i,"vrDistortionCorrection",["LensCenter","Scale","ScaleIn","HmdWarpParam"],null,o.postProcessScaleFactor,r,e.Texture.BILINEAR_SAMPLINGMODE,null,null),this._isRightEye=n,this._distortionFactors=o.distortionK,this._postProcessScaleFactor=o.postProcessScaleFactor,this._lensCenterOffset=o.lensCenterOffset,this.onSizeChangedObservable.add(function(){s.aspectRatio=.5*s.width/s.height,s._scaleIn=new e.Vector2(2,2/s.aspectRatio),s._scaleFactor=new e.Vector2(.5*(1/s._postProcessScaleFactor),.5*(1/s._postProcessScaleFactor)*s.aspectRatio),s._lensCenter=new e.Vector2(s._isRightEye?.5-.5*s._lensCenterOffset:.5+.5*s._lensCenterOffset,.5)}),this.onApplyObservable.add(function(e){e.setFloat2("LensCenter",s._lensCenter.x,s._lensCenter.y),e.setFloat2("Scale",s._scaleFactor.x,s._scaleFactor.y),e.setFloat2("ScaleIn",s._scaleIn.x,s._scaleIn.y),e.setFloat4("HmdWarpParam",s._distortionFactors[0],s._distortionFactors[1],s._distortionFactors[2],s._distortionFactors[3])})}return __extends(i,t),i}(e.PostProcess);e.VRDistortionCorrectionPostProcess=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){!function(e){e[e.X=0]="X",e[e.Y=1]="Y",e[e.Z=2]="Z"}(e.JoystickAxis||(e.JoystickAxis={}));var t=e.JoystickAxis,i=function(){function i(r){var n=this;r?this._leftJoystick=!0:this._leftJoystick=!1,this._joystickIndex=i._globalJoystickIndex,i._globalJoystickIndex++,this._axisTargetedByLeftAndRight=t.X,this._axisTargetedByUpAndDown=t.Y,this.reverseLeftRight=!1,this.reverseUpDown=!1,this._touches=new e.StringDictionary,this.deltaPosition=e.Vector3.Zero(),this._joystickSensibility=25,this._inversedSensibility=1/(this._joystickSensibility/1e3),this._rotationSpeed=25,this._inverseRotationSpeed=1/(this._rotationSpeed/1e3),this._rotateOnAxisRelativeToMesh=!1,this._onResize=function(e){i.vjCanvasWidth=window.innerWidth,i.vjCanvasHeight=window.innerHeight,i.vjCanvas.width=i.vjCanvasWidth,i.vjCanvas.height=i.vjCanvasHeight,i.halfWidth=i.vjCanvasWidth/2,i.halfHeight=i.vjCanvasHeight/2},i.vjCanvas||(window.addEventListener("resize",this._onResize,!1),i.vjCanvas=document.createElement("canvas"),i.vjCanvasWidth=window.innerWidth,i.vjCanvasHeight=window.innerHeight,i.vjCanvas.width=window.innerWidth,i.vjCanvas.height=window.innerHeight,i.vjCanvas.style.width="100%",i.vjCanvas.style.height="100%",i.vjCanvas.style.position="absolute",i.vjCanvas.style.backgroundColor="transparent",i.vjCanvas.style.top="0px",i.vjCanvas.style.left="0px",i.vjCanvas.style.zIndex="5",i.vjCanvas.style.msTouchAction="none",i.vjCanvas.setAttribute("touch-action","none"),i.vjCanvasContext=i.vjCanvas.getContext("2d"),i.vjCanvasContext.strokeStyle="#ffffff",i.vjCanvasContext.lineWidth=2,document.body.appendChild(i.vjCanvas)),i.halfWidth=i.vjCanvas.width/2,i.halfHeight=i.vjCanvas.height/2,this.pressed=!1,this._joystickColor="cyan",this._joystickPointerID=-1,this._joystickPointerPos=new e.Vector2(0,0),this._joystickPreviousPointerPos=new e.Vector2(0,0),this._joystickPointerStartPos=new e.Vector2(0,0),this._deltaJoystickVector=new e.Vector2(0,0),this._onPointerDownHandlerRef=function(e){n._onPointerDown(e)},this._onPointerMoveHandlerRef=function(e){n._onPointerMove(e)},this._onPointerOutHandlerRef=function(e){n._onPointerUp(e)},this._onPointerUpHandlerRef=function(e){n._onPointerUp(e)},i.vjCanvas.addEventListener("pointerdown",this._onPointerDownHandlerRef,!1),i.vjCanvas.addEventListener("pointermove",this._onPointerMoveHandlerRef,!1),i.vjCanvas.addEventListener("pointerup",this._onPointerUpHandlerRef,!1),i.vjCanvas.addEventListener("pointerout",this._onPointerUpHandlerRef,!1),i.vjCanvas.addEventListener("contextmenu",function(e){e.preventDefault()},!1),requestAnimationFrame(function(){n._drawVirtualJoystick()})}return i.prototype.setJoystickSensibility=function(e){this._joystickSensibility=e,this._inversedSensibility=1/(this._joystickSensibility/1e3)},i.prototype._onPointerDown=function(e){var t;e.preventDefault(),t=this._leftJoystick===!0?e.clientX<i.halfWidth:e.clientX>i.halfWidth,t&&this._joystickPointerID<0?(this._joystickPointerID=e.pointerId,this._joystickPointerStartPos.x=e.clientX,this._joystickPointerStartPos.y=e.clientY,this._joystickPointerPos=this._joystickPointerStartPos.clone(),this._joystickPreviousPointerPos=this._joystickPointerStartPos.clone(),this._deltaJoystickVector.x=0,this._deltaJoystickVector.y=0,this.pressed=!0,this._touches.add(e.pointerId.toString(),e)):i._globalJoystickIndex<2&&this._action&&(this._action(),this._touches.add(e.pointerId.toString(),{x:e.clientX,y:e.clientY,prevX:e.clientX,prevY:e.clientY}))},i.prototype._onPointerMove=function(e){if(this._joystickPointerID==e.pointerId){this._joystickPointerPos.x=e.clientX,this._joystickPointerPos.y=e.clientY,this._deltaJoystickVector=this._joystickPointerPos.clone(),this._deltaJoystickVector=this._deltaJoystickVector.subtract(this._joystickPointerStartPos);var i=this.reverseLeftRight?-1:1,r=i*this._deltaJoystickVector.x/this._inversedSensibility;switch(this._axisTargetedByLeftAndRight){case t.X:this.deltaPosition.x=Math.min(1,Math.max(-1,r));break;case t.Y:this.deltaPosition.y=Math.min(1,Math.max(-1,r));break;case t.Z:this.deltaPosition.z=Math.min(1,Math.max(-1,r))}var n=this.reverseUpDown?1:-1,o=n*this._deltaJoystickVector.y/this._inversedSensibility;switch(this._axisTargetedByUpAndDown){case t.X:this.deltaPosition.x=Math.min(1,Math.max(-1,o));break;case t.Y:this.deltaPosition.y=Math.min(1,Math.max(-1,o));
  30. break;case t.Z:this.deltaPosition.z=Math.min(1,Math.max(-1,o))}}else{var s=this._touches.get(e.pointerId.toString());s&&(s.x=e.clientX,s.y=e.clientY)}},i.prototype._onPointerUp=function(e){if(this._joystickPointerID==e.pointerId)i.vjCanvasContext.clearRect(this._joystickPointerStartPos.x-63,this._joystickPointerStartPos.y-63,126,126),i.vjCanvasContext.clearRect(this._joystickPreviousPointerPos.x-41,this._joystickPreviousPointerPos.y-41,82,82),this._joystickPointerID=-1,this.pressed=!1;else{var t=this._touches.get(e.pointerId.toString());t&&i.vjCanvasContext.clearRect(t.prevX-43,t.prevY-43,86,86)}this._deltaJoystickVector.x=0,this._deltaJoystickVector.y=0,this._touches.remove(e.pointerId.toString())},i.prototype.setJoystickColor=function(e){this._joystickColor=e},i.prototype.setActionOnTouch=function(e){this._action=e},i.prototype.setAxisForLeftRight=function(e){switch(e){case t.X:case t.Y:case t.Z:this._axisTargetedByLeftAndRight=e;break;default:this._axisTargetedByLeftAndRight=t.X}},i.prototype.setAxisForUpDown=function(e){switch(e){case t.X:case t.Y:case t.Z:this._axisTargetedByUpAndDown=e;break;default:this._axisTargetedByUpAndDown=t.Y}},i.prototype._clearCanvas=function(){this._leftJoystick?i.vjCanvasContext.clearRect(0,0,i.vjCanvasWidth/2,i.vjCanvasHeight):i.vjCanvasContext.clearRect(i.vjCanvasWidth/2,0,i.vjCanvasWidth,i.vjCanvasHeight)},i.prototype._drawVirtualJoystick=function(){var e=this;this.pressed&&this._touches.forEach(function(t){t.pointerId===e._joystickPointerID?(i.vjCanvasContext.clearRect(e._joystickPointerStartPos.x-63,e._joystickPointerStartPos.y-63,126,126),i.vjCanvasContext.clearRect(e._joystickPreviousPointerPos.x-41,e._joystickPreviousPointerPos.y-41,82,82),i.vjCanvasContext.beginPath(),i.vjCanvasContext.lineWidth=6,i.vjCanvasContext.strokeStyle=e._joystickColor,i.vjCanvasContext.arc(e._joystickPointerStartPos.x,e._joystickPointerStartPos.y,40,0,2*Math.PI,!0),i.vjCanvasContext.stroke(),i.vjCanvasContext.closePath(),i.vjCanvasContext.beginPath(),i.vjCanvasContext.strokeStyle=e._joystickColor,i.vjCanvasContext.lineWidth=2,i.vjCanvasContext.arc(e._joystickPointerStartPos.x,e._joystickPointerStartPos.y,60,0,2*Math.PI,!0),i.vjCanvasContext.stroke(),i.vjCanvasContext.closePath(),i.vjCanvasContext.beginPath(),i.vjCanvasContext.strokeStyle=e._joystickColor,i.vjCanvasContext.arc(e._joystickPointerPos.x,e._joystickPointerPos.y,40,0,2*Math.PI,!0),i.vjCanvasContext.stroke(),i.vjCanvasContext.closePath(),e._joystickPreviousPointerPos=e._joystickPointerPos.clone()):(i.vjCanvasContext.clearRect(t.prevX-43,t.prevY-43,86,86),i.vjCanvasContext.beginPath(),i.vjCanvasContext.fillStyle="white",i.vjCanvasContext.beginPath(),i.vjCanvasContext.strokeStyle="red",i.vjCanvasContext.lineWidth=6,i.vjCanvasContext.arc(t.x,t.y,40,0,2*Math.PI,!0),i.vjCanvasContext.stroke(),i.vjCanvasContext.closePath(),t.prevX=t.x,t.prevY=t.y)}),requestAnimationFrame(function(){e._drawVirtualJoystick()})},i.prototype.releaseCanvas=function(){i.vjCanvas&&(i.vjCanvas.removeEventListener("pointerdown",this._onPointerDownHandlerRef),i.vjCanvas.removeEventListener("pointermove",this._onPointerMoveHandlerRef),i.vjCanvas.removeEventListener("pointerup",this._onPointerUpHandlerRef),i.vjCanvas.removeEventListener("pointerout",this._onPointerUpHandlerRef),window.removeEventListener("resize",this._onResize),document.body.removeChild(i.vjCanvas),i.vjCanvas=null)},i._globalJoystickIndex=0,i}();e.VirtualJoystick=i}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(e){function t(t,i,r){e.call(this,t,i,r),this.inputs.addVirtualJoystick()}return __extends(t,e),t}(e.FreeCamera);e.VirtualJoysticksCamera=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(){}return t.prototype.getLeftJoystick=function(){return this._leftjoystick},t.prototype.getRightJoystick=function(){return this._rightjoystick},t.prototype.checkInputs=function(){if(this._leftjoystick){var t=this.camera,i=50*t._computeLocalCameraSpeed(),r=e.Matrix.RotationYawPitchRoll(t.rotation.y,t.rotation.x,0),n=e.Vector3.TransformCoordinates(new e.Vector3(this._leftjoystick.deltaPosition.x*i,this._leftjoystick.deltaPosition.y*i,this._leftjoystick.deltaPosition.z*i),r);t.cameraDirection=t.cameraDirection.add(n),t.cameraRotation=t.cameraRotation.addVector3(this._rightjoystick.deltaPosition),this._leftjoystick.pressed||(this._leftjoystick.deltaPosition=this._leftjoystick.deltaPosition.scale(.9)),this._rightjoystick.pressed||(this._rightjoystick.deltaPosition=this._rightjoystick.deltaPosition.scale(.9))}},t.prototype.attachControl=function(t,i){this._leftjoystick=new e.VirtualJoystick(!0),this._leftjoystick.setAxisForUpDown(e.JoystickAxis.Z),this._leftjoystick.setAxisForLeftRight(e.JoystickAxis.X),this._leftjoystick.setJoystickSensibility(.15),this._rightjoystick=new e.VirtualJoystick(!1),this._rightjoystick.setAxisForUpDown(e.JoystickAxis.X),this._rightjoystick.setAxisForLeftRight(e.JoystickAxis.Y),this._rightjoystick.reverseUpDown=!0,this._rightjoystick.setJoystickSensibility(.05),this._rightjoystick.setJoystickColor("yellow")},t.prototype.detachControl=function(e){this._leftjoystick.releaseCanvas(),this._rightjoystick.releaseCanvas()},t.prototype.getTypeName=function(){return"FreeCameraVirtualJoystickInput"},t.prototype.getSimpleName=function(){return"virtualJoystick"},t}();e.FreeCameraVirtualJoystickInput=t,e.CameraInputTypes.FreeCameraVirtualJoystickInput=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(e){function t(t,i,r,n,o,s){var a=this;e.call(this,t,"anaglyph",null,["leftSampler"],i,r[1],n,o,s),this._passedProcess=r[0]._rigPostProcess,this.onApplyObservable.add(function(e){e.setTextureFromPostProcess("leftSampler",a._passedProcess)})}return __extends(t,e),t}(e.PostProcess);e.AnaglyphPostProcess=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(e){this._scene=e}return t.prototype.render=function(t,i,r){var n=this;void 0===r&&(r=!1);var o=this._scene,s=this._scene.getEngine(),a=null!==s.getCaps().instancedArrays&&null!==i.visibleInstances[t._id]&&void 0!==i.visibleInstances[t._id];if(this.isReady(t,a)){var h=t.getRenderingMesh(),c=t.getMaterial();if(s.enableEffect(this._effect),this._effect.setFloat("offset",r?0:h.outlineWidth),this._effect.setColor4("color",r?h.overlayColor:h.outlineColor,r?h.overlayAlpha:1),this._effect.setMatrix("viewProjection",o.getTransformMatrix()),h.useBones&&h.computeBonesUsingShaders&&this._effect.setMatrices("mBones",h.skeleton.getTransformMatrices(h)),h._bind(t,this._effect,e.Material.TriangleFillMode),c&&c.needAlphaTesting()){var l=c.getAlphaTestTexture();this._effect.setTexture("diffuseSampler",l),this._effect.setMatrix("diffuseMatrix",l.getTextureMatrix())}h._processRendering(t,this._effect,e.Material.TriangleFillMode,i,a,function(e,t){n._effect.setMatrix("world",t)})}},t.prototype.isReady=function(t,i){var r=[],n=[e.VertexBuffer.PositionKind,e.VertexBuffer.NormalKind],o=t.getMesh(),s=t.getMaterial();s&&s.needAlphaTesting()&&(r.push("#define ALPHATEST"),o.isVerticesDataPresent(e.VertexBuffer.UVKind)&&(n.push(e.VertexBuffer.UVKind),r.push("#define UV1")),o.isVerticesDataPresent(e.VertexBuffer.UV2Kind)&&(n.push(e.VertexBuffer.UV2Kind),r.push("#define UV2"))),o.useBones&&o.computeBonesUsingShaders?(n.push(e.VertexBuffer.MatricesIndicesKind),n.push(e.VertexBuffer.MatricesWeightsKind),o.numBoneInfluencers>4&&(n.push(e.VertexBuffer.MatricesIndicesExtraKind),n.push(e.VertexBuffer.MatricesWeightsExtraKind)),r.push("#define NUM_BONE_INFLUENCERS "+o.numBoneInfluencers),r.push("#define BonesPerMesh "+(o.skeleton.bones.length+1))):r.push("#define NUM_BONE_INFLUENCERS 0"),i&&(r.push("#define INSTANCES"),n.push("world0"),n.push("world1"),n.push("world2"),n.push("world3"));var a=r.join("\n");return this._cachedDefines!==a&&(this._cachedDefines=a,this._effect=this._scene.getEngine().createEffect("outline",n,["world","mBones","viewProjection","diffuseMatrix","offset","color"],["diffuseSampler"],a)),this._effect.isReady()},t}();e.OutlineRenderer=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(e,t,i,r){this.name=e,this.meshesNames=t,this.rootUrl=i,this.sceneFilename=r,this.isCompleted=!1}return t.prototype.run=function(t,i,r){var n=this;e.SceneLoader.ImportMesh(this.meshesNames,this.rootUrl,this.sceneFilename,t,function(e,t,r){n.loadedMeshes=e,n.loadedParticleSystems=t,n.loadedSkeletons=r,n.isCompleted=!0,n.onSuccess&&n.onSuccess(n),i()},null,function(){n.onError&&n.onError(n),r()})},t}();e.MeshAssetTask=t;var i=function(){function t(e,t){this.name=e,this.url=t,this.isCompleted=!1}return t.prototype.run=function(t,i,r){var n=this;e.Tools.LoadFile(this.url,function(e){n.text=e,n.isCompleted=!0,n.onSuccess&&n.onSuccess(n),i()},null,t.database,!1,function(){n.onError&&n.onError(n),r()})},t}();e.TextFileAssetTask=i;var r=function(){function t(e,t){this.name=e,this.url=t,this.isCompleted=!1}return t.prototype.run=function(t,i,r){var n=this;e.Tools.LoadFile(this.url,function(e){n.data=e,n.isCompleted=!0,n.onSuccess&&n.onSuccess(n),i()},null,t.database,!0,function(){n.onError&&n.onError(n),r()})},t}();e.BinaryFileAssetTask=r;var n=function(){function e(e,t){this.name=e,this.url=t,this.isCompleted=!1}return e.prototype.run=function(e,t,i){var r=this,n=new Image;n.onload=function(){r.image=n,r.isCompleted=!0,r.onSuccess&&r.onSuccess(r),t()},n.onerror=function(){r.onError&&r.onError(r),i()},n.src=this.url},e}();e.ImageAssetTask=n;var o=function(){function t(t,i,r,n,o){void 0===o&&(o=e.Texture.TRILINEAR_SAMPLINGMODE),this.name=t,this.url=i,this.noMipmap=r,this.invertY=n,this.samplingMode=o,this.isCompleted=!1}return t.prototype.run=function(t,i,r){var n=this,o=function(){n.isCompleted=!0,n.onSuccess&&n.onSuccess(n),i()},s=function(){n.onError&&n.onError(n),r()};this.texture=new e.Texture(this.url,t,this.noMipmap,this.invertY,this.samplingMode,o,s)},t}();e.TextureAssetTask=o;var s=function(){function s(e){this._tasks=new Array,this._waitingTasksCount=0,this.useDefaultLoadingScreen=!0,this._scene=e}return s.prototype.addMeshTask=function(e,i,r,n){var o=new t(e,i,r,n);return this._tasks.push(o),o},s.prototype.addTextFileTask=function(e,t){var r=new i(e,t);return this._tasks.push(r),r},s.prototype.addBinaryFileTask=function(e,t){var i=new r(e,t);return this._tasks.push(i),i},s.prototype.addImageTask=function(e,t){var i=new n(e,t);return this._tasks.push(i),i},s.prototype.addTextureTask=function(t,i,r,n,s){void 0===s&&(s=e.Texture.TRILINEAR_SAMPLINGMODE);var a=new o(t,i,r,n,s);return this._tasks.push(a),a},s.prototype._decreaseWaitingTasksCount=function(){this._waitingTasksCount--,0===this._waitingTasksCount&&(this.onFinish&&this.onFinish(this._tasks),this._scene.getEngine().hideLoadingUI())},s.prototype._runTask=function(e){var t=this;e.run(this._scene,function(){t.onTaskSuccess&&t.onTaskSuccess(e),t._decreaseWaitingTasksCount()},function(){t.onTaskError&&t.onTaskError(e),t._decreaseWaitingTasksCount()})},s.prototype.reset=function(){return this._tasks=new Array,this},s.prototype.load=function(){if(this._waitingTasksCount=this._tasks.length,0===this._waitingTasksCount)return this.onFinish&&this.onFinish(this._tasks),this;this.useDefaultLoadingScreen&&this._scene.getEngine().displayLoadingUI();for(var e=0;e<this._tasks.length;e++){var t=this._tasks[e];this._runTask(t)}return this},s}();e.AssetsManager=s}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(){this.compensateDistortion=!0}return Object.defineProperty(t.prototype,"aspectRatio",{get:function(){return this.hResolution/(2*this.vResolution)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"aspectRatioFov",{get:function(){return 2*Math.atan(this.postProcessScaleFactor*this.vScreenSize/(2*this.eyeToScreenDistance))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"leftHMatrix",{get:function(){var t=this.hScreenSize/4-this.lensSeparationDistance/2,i=4*t/this.hScreenSize;return e.Matrix.Translation(i,0,0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"rightHMatrix",{get:function(){var t=this.hScreenSize/4-this.lensSeparationDistance/2,i=4*t/this.hScreenSize;return e.Matrix.Translation(-i,0,0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"leftPreViewMatrix",{get:function(){return e.Matrix.Translation(.5*this.interpupillaryDistance,0,0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"rightPreViewMatrix",{get:function(){return e.Matrix.Translation(-.5*this.interpupillaryDistance,0,0)},enumerable:!0,configurable:!0}),t.GetDefault=function(){var e=new t;return e.hResolution=1280,e.vResolution=800,e.hScreenSize=.149759993,e.vScreenSize=.0935999975,e.vScreenCenter=.0467999987,e.eyeToScreenDistance=.0410000011,e.lensSeparationDistance=.063500002,e.interpupillaryDistance=.064000003,e.distortionK=[1,.219999999,.239999995,0],e.chromaAbCorrection=[.995999992,-.00400000019,1.01400006,0],e.postProcessScaleFactor=1.714605507808412,e.lensCenterOffset=.151976421,e},t}();e.VRCameraMetrics=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(t){function i(i,r,n,o){void 0===o&&(o=!0),t.call(this,i,r,n),this.rotationQuaternion=new e.Quaternion;var s=e.VRCameraMetrics.GetDefault();s.compensateDistortion=o,this.setCameraRigMode(e.Camera.RIG_MODE_VR,{vrCameraMetrics:s}),this.inputs.addDeviceOrientation()}return __extends(i,t),i.prototype.getTypeName=function(){return"VRDeviceOrientationFreeCamera"},i}(e.FreeCamera);e.VRDeviceOrientationFreeCamera=t;var i=function(t){function i(i,r,n,o,s,a,h){void 0===h&&(h=!0),t.call(this,i,r,n,o,s,a);var c=e.VRCameraMetrics.GetDefault();c.compensateDistortion=h,this.setCameraRigMode(e.Camera.RIG_MODE_VR,{vrCameraMetrics:c}),this.inputs.addVRDeviceOrientation()}return __extends(i,t),i.prototype.getTypeName=function(){return"VRDeviceOrientationArcRotateCamera"},i}(e.ArcRotateCamera);e.VRDeviceOrientationArcRotateCamera=i}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(t){function i(i,r,n,o){void 0===o&&(o=!0),t.call(this,i,r,n),this._hmdDevice=null,this._sensorDevice=null,this._cacheState=null,this._vrEnabled=!1;var s=e.VRCameraMetrics.GetDefault();s.compensateDistortion=o,this.setCameraRigMode(e.Camera.RIG_MODE_VR,{vrCameraMetrics:s}),this._getWebVRDevices=this._getWebVRDevices.bind(this),this.rotationQuaternion=new e.Quaternion}return __extends(i,t),i.prototype._getWebVRDevices=function(e){var t=e.length,i=0;for(this._sensorDevice=null,this._hmdDevice=null;t>i&&null===this._hmdDevice;)e[i]instanceof HMDVRDevice&&(this._hmdDevice=e[i]),i++;for(i=0;t>i&&null===this._sensorDevice;)e[i]instanceof PositionSensorVRDevice&&(!this._hmdDevice||e[i].hardwareUnitId===this._hmdDevice.hardwareUnitId)&&(this._sensorDevice=e[i]),i++;this._vrEnabled=!(!this._sensorDevice||!this._hmdDevice)},i.prototype._checkInputs=function(){this._vrEnabled&&(this._cacheState=this._sensorDevice.getState(),this.rotationQuaternion.copyFrom(this._cacheState.orientation),this.rotationQuaternion.z*=-1,this.rotationQuaternion.w*=-1),t.prototype._checkInputs.call(this)},i.prototype.attachControl=function(i,r){t.prototype.attachControl.call(this,i,r),r=e.Camera.ForceAttachControlToAlwaysPreventDefault?!1:r,navigator.getVRDevices?navigator.getVRDevices().then(this._getWebVRDevices):navigator.mozGetVRDevices&&navigator.mozGetVRDevices(this._getWebVRDevices)},i.prototype.detachControl=function(e){t.prototype.detachControl.call(this,e),this._vrEnabled=!1},i.prototype.requestVRFullscreen=function(e){this._hmdDevice&&this.getEngine().switchFullscreen(e,{vrDisplay:this._hmdDevice})},i.prototype.getTypeName=function(){return"WebVRFreeCamera"},i}(e.FreeCamera);e.WebVRFreeCamera=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function e(e){void 0===e&&(e=0),this.priority=e,this.apply=function(e){return!0}}return e}();e.SceneOptimization=t;var i=function(e){function t(t,i){var r=this;void 0===t&&(t=0),void 0===i&&(i=1024),e.call(this,t),this.priority=t,this.maximumSize=i,this.apply=function(e){for(var t=!0,i=0;i<e.textures.length;i++){var n=e.textures[i];if(n.canRescale){var o=n.getSize(),s=Math.max(o.width,o.height);s>r.maximumSize&&(n.scale(.5),t=!1)}}return t}}return __extends(t,e),t}(t);e.TextureOptimization=i;var r=function(e){function t(t,i){var r=this;void 0===t&&(t=0),void 0===i&&(i=2),e.call(this,t),this.priority=t,this.maximumScale=i,this._currentScale=1,this.apply=function(e){return r._currentScale++,e.getEngine().setHardwareScalingLevel(r._currentScale),r._currentScale>=r.maximumScale}}return __extends(t,e),t}(t);e.HardwareScalingOptimization=r;var n=function(e){function t(){e.apply(this,arguments),this.apply=function(e){return e.shadowsEnabled=!1,!0}}return __extends(t,e),t}(t);e.ShadowsOptimization=n;var o=function(e){function t(){e.apply(this,arguments),this.apply=function(e){return e.postProcessesEnabled=!1,!0}}return __extends(t,e),t}(t);e.PostProcessesOptimization=o;var s=function(e){function t(){e.apply(this,arguments),this.apply=function(e){return e.lensFlaresEnabled=!1,!0}}return __extends(t,e),t}(t);e.LensFlaresOptimization=s;var a=function(e){function t(){e.apply(this,arguments),this.apply=function(e){return e.particlesEnabled=!1,!0}}return __extends(t,e),t}(t);e.ParticlesOptimization=a;var h=function(e){function t(){e.apply(this,arguments),this.apply=function(e){return e.renderTargetsEnabled=!1,!0}}return __extends(t,e),t}(t);e.RenderTargetsOptimization=h;var c=function(t){function i(){var r=this;t.apply(this,arguments),this._canBeMerged=function(t){if(!(t instanceof e.Mesh))return!1;var i=t;return i.isVisible&&i.isEnabled()?i.instances.length>0?!1:i.skeleton||i.hasLODLevels?!1:!i.parent:!1},this.apply=function(t,n){for(var o=t.meshes.slice(0),s=o.length,a=0;s>a;a++){var h=new Array,c=o[a];if(r._canBeMerged(c)){h.push(c);for(var l=a+1;s>l;l++){var u=o[l];r._canBeMerged(u)&&u.material===c.material&&u.checkCollisions===c.checkCollisions&&(h.push(u),s--,o.splice(l,1),l--)}h.length<2||e.Mesh.MergeMeshes(h)}}return void 0!=n?n&&t.createOrUpdateSelectionOctree():i.UpdateSelectionTree&&t.createOrUpdateSelectionOctree(),!0}}return __extends(i,t),Object.defineProperty(i,"UpdateSelectionTree",{get:function(){return i._UpdateSelectionTree},set:function(e){i._UpdateSelectionTree=e},enumerable:!0,configurable:!0}),i._UpdateSelectionTree=!1,i}(t);e.MergeMeshesOptimization=c;var l=function(){function e(e,t){void 0===e&&(e=60),void 0===t&&(t=2e3),this.targetFrameRate=e,this.trackerDuration=t,this.optimizations=new Array}return e.LowDegradationAllowed=function(t){var r=new e(t),h=0;return r.optimizations.push(new c(h)),r.optimizations.push(new n(h)),r.optimizations.push(new s(h)),h++,r.optimizations.push(new o(h)),r.optimizations.push(new a(h)),h++,r.optimizations.push(new i(h,1024)),r},e.ModerateDegradationAllowed=function(t){var l=new e(t),u=0;return l.optimizations.push(new c(u)),l.optimizations.push(new n(u)),l.optimizations.push(new s(u)),u++,l.optimizations.push(new o(u)),l.optimizations.push(new a(u)),u++,l.optimizations.push(new i(u,512)),u++,l.optimizations.push(new h(u)),u++,l.optimizations.push(new r(u,2)),l},e.HighDegradationAllowed=function(t){var l=new e(t),u=0;return l.optimizations.push(new c(u)),l.optimizations.push(new n(u)),l.optimizations.push(new s(u)),u++,l.optimizations.push(new o(u)),l.optimizations.push(new a(u)),u++,l.optimizations.push(new i(u,256)),u++,l.optimizations.push(new h(u)),u++,l.optimizations.push(new r(u,4)),l},e}();e.SceneOptimizerOptions=l;var u=function(){function e(){}return e._CheckCurrentState=function(t,i,r,n,o){if(t.getEngine().getFps()>=i.targetFrameRate)return void(n&&n());for(var s=!0,a=!0,h=0;h<i.optimizations.length;h++){var c=i.optimizations[h];c.priority===r&&(a=!1,s=s&&c.apply(t))}return a?void(o&&o()):(s&&r++,void t.executeWhenReady(function(){setTimeout(function(){e._CheckCurrentState(t,i,r,n,o)},i.trackerDuration)}))},e.OptimizeAsync=function(t,i,r,n){i||(i=l.ModerateDegradationAllowed()),t.executeWhenReady(function(){setTimeout(function(){e._CheckCurrentState(t,i,0,r,n)},i.trackerDuration)})},e}();e.SceneOptimizer=u}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t;!function(e){var t=function(){function e(e,t){this.distance=e,this.mesh=t}return e}();e.MeshLODLevel=t}(t=e.Internals||(e.Internals={}))}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(t){function i(i,r,n,o,s,a,h,c){void 0===a&&(a=!0),void 0===h&&(h=!1),void 0===c&&(c=e.Texture.TRILINEAR_SAMPLINGMODE),t.call(this,null,s,!a,h),this.format=o,this._texture=s.getEngine().createRawTexture(i,r,n,o,a,h,c),this.wrapU=e.Texture.CLAMP_ADDRESSMODE,this.wrapV=e.Texture.CLAMP_ADDRESSMODE}return __extends(i,t),i.prototype.update=function(e){this.getScene().getEngine().updateRawTexture(this._texture,e,this.format,this._invertY)},i.CreateLuminanceTexture=function(t,r,n,o,s,a,h){return void 0===s&&(s=!0),void 0===a&&(a=!1),void 0===h&&(h=e.Texture.TRILINEAR_SAMPLINGMODE),new i(t,r,n,e.Engine.TEXTUREFORMAT_LUMINANCE,o,s,a,h)},i.CreateLuminanceAlphaTexture=function(t,r,n,o,s,a,h){return void 0===s&&(s=!0),void 0===a&&(a=!1),void 0===h&&(h=e.Texture.TRILINEAR_SAMPLINGMODE),new i(t,r,n,e.Engine.TEXTUREFORMAT_LUMINANCE_ALPHA,o,s,a,h)},i.CreateAlphaTexture=function(t,r,n,o,s,a,h){return void 0===s&&(s=!0),void 0===a&&(a=!1),void 0===h&&(h=e.Texture.TRILINEAR_SAMPLINGMODE),new i(t,r,n,e.Engine.TEXTUREFORMAT_ALPHA,o,s,a,h)},i.CreateRGBTexture=function(t,r,n,o,s,a,h){return void 0===s&&(s=!0),void 0===a&&(a=!1),void 0===h&&(h=e.Texture.TRILINEAR_SAMPLINGMODE),new i(t,r,n,e.Engine.TEXTUREFORMAT_RGB,o,s,a,h)},i.CreateRGBATexture=function(t,r,n,o,s,a,h){return void 0===s&&(s=!0),void 0===a&&(a=!1),void 0===h&&(h=e.Texture.TRILINEAR_SAMPLINGMODE),new i(t,r,n,e.Engine.TEXTUREFORMAT_RGBA,o,s,a,h)},i}(e.Texture);e.RawTexture=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(e){function t(t,i){e.call(this,t.x,t.y),this.index=i}return __extends(t,e),t}(e.Vector2),i=function(){function i(){this.elements=new Array}return i.prototype.add=function(e){var i=this,r=new Array;return e.forEach(function(e){if(0===r.length||!e.equalsWithEpsilon(r[0])){var n=new t(e,i.elements.length);r.push(n),i.elements.push(n)}}),r},i.prototype.computeBounds=function(){var t=new e.Vector2(this.elements[0].x,this.elements[0].y),i=new e.Vector2(this.elements[0].x,this.elements[0].y);return this.elements.forEach(function(e){e.x<t.x?t.x=e.x:e.x>i.x&&(i.x=e.x),e.y<t.y?t.y=e.y:e.y>i.y&&(i.y=e.y)}),{min:t,max:i,width:i.x-t.x,height:i.y-t.y}},i}(),r=function(){function t(){}return t.Rectangle=function(t,i,r,n){return[new e.Vector2(t,i),new e.Vector2(r,i),new e.Vector2(r,n),new e.Vector2(t,n)]},t.Circle=function(t,i,r,n){void 0===i&&(i=0),void 0===r&&(r=0),void 0===n&&(n=32);for(var o=new Array,s=0,a=2*Math.PI/n,h=0;n>h;h++)o.push(new e.Vector2(i+Math.cos(s)*t,r+Math.sin(s)*t)),s-=a;return o},t.Parse=function(t){var i,r=t.split(/[^-+eE\.\d]+/).map(parseFloat).filter(function(e){return!isNaN(e)}),n=[];for(i=0;i<(2147483646&r.length);i+=2)n.push(new e.Vector2(r[i],r[i+1]));return n},t.StartingAt=function(t,i){return e.Path2.StartingAt(t,i)},t}();e.Polygon=r;var n=function(){function t(t,r,n){this._points=new i,this._outlinepoints=new i,this._holes=[],this._epoints=new Array,this._eholes=new Array,this._name=t,this._scene=n;var o;o=r instanceof e.Path2?r.getPoints():r,this._addToepoint(o),this._points.add(o),this._outlinepoints.add(o)}return t.prototype._addToepoint=function(e){for(var t=0;t<e.length;t++){var i=e[t];this._epoints.push(i.x,i.y)}},t.prototype.addHole=function(e){this._points.add(e);var t=new i;return t.add(e),this._holes.push(t),this._eholes.push(this._epoints.length/2),this._addToepoint(e),this},t.prototype.build=function(t,i){var r=this;void 0===t&&(t=!1);var n=new e.Mesh(this._name,this._scene),o=[],s=[],a=[],h=this._points.computeBounds();this._points.elements.forEach(function(e){o.push(0,1,0),s.push(e.x,0,e.y),a.push((e.x-h.min.x)/h.width,(e.y-h.min.y)/h.height)});for(var c=[],l=Earcut.earcut(this._epoints,this._eholes,2),u=0;u<l.length;u++)c.push(l[u]);if(i>0){var f=s.length/3;this._points.elements.forEach(function(e){o.push(0,-1,0),s.push(e.x,-i,e.y),a.push(1-(e.x-h.min.x)/h.width,1-(e.y-h.min.y)/h.height)});for(var d=c.length,u=0;d>u;u+=3){var p=c[u+0],_=c[u+1],m=c[u+2];c.push(m+f),c.push(_+f),c.push(p+f)}this.addSide(s,o,a,c,h,this._outlinepoints,i,!1),this._holes.forEach(function(e){r.addSide(s,o,a,c,h,e,i,!0)})}return n.setVerticesData(e.VertexBuffer.PositionKind,s,t),n.setVerticesData(e.VertexBuffer.NormalKind,o,t),n.setVerticesData(e.VertexBuffer.UVKind,a,t),n.setIndices(c),n},t.prototype.addSide=function(t,i,r,n,o,s,a,h){for(var c=t.length/3,l=0,u=0;u<s.elements.length;u++){var f,d=s.elements[u];f=u+1>s.elements.length-1?s.elements[0]:s.elements[u+1],t.push(d.x,0,d.y),t.push(d.x,-a,d.y),t.push(f.x,0,f.y),t.push(f.x,-a,f.y);var p=new e.Vector3(d.x,0,d.y),_=new e.Vector3(f.x,0,f.y),m=_.subtract(p),g=new e.Vector3(0,1,0),v=e.Vector3.Cross(m,g);v=v.normalize(),r.push(l/o.width,0),r.push(l/o.width,1),l+=m.length(),r.push(l/o.width,0),r.push(l/o.width,1),h?(i.push(v.x,v.y,v.z),i.push(v.x,v.y,v.z),i.push(v.x,v.y,v.z),i.push(v.x,v.y,v.z),n.push(c),n.push(c+2),n.push(c+1),n.push(c+1),n.push(c+2),n.push(c+3)):(i.push(-v.x,-v.y,-v.z),i.push(-v.x,-v.y,-v.z),i.push(-v.x,-v.y,-v.z),i.push(-v.x,-v.y,-v.z),n.push(c),n.push(c+1),n.push(c+2),n.push(c+1),n.push(c+3),n.push(c+2)),c+=4}},t}();e.PolygonMeshBuilder=n}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(t,i,r){void 0===r&&(r=2),this.maxDepth=r,this.dynamicContent=new Array,this._maxBlockCapacity=i||64,this._selectionContent=new e.SmartArray(1024),this._creationFunc=t}return t.prototype.update=function(e,i,r){t._CreateBlocks(e,i,r,this._maxBlockCapacity,0,this.maxDepth,this,this._creationFunc)},t.prototype.addMesh=function(e){for(var t=0;t<this.blocks.length;t++){var i=this.blocks[t];i.addEntry(e)}},t.prototype.select=function(e,t){this._selectionContent.reset();for(var i=0;i<this.blocks.length;i++){var r=this.blocks[i];r.select(e,this._selectionContent,t)}return t?this._selectionContent.concat(this.dynamicContent):this._selectionContent.concatWithNoDuplicate(this.dynamicContent),this._selectionContent},t.prototype.intersects=function(e,t,i){this._selectionContent.reset();for(var r=0;r<this.blocks.length;r++){var n=this.blocks[r];n.intersects(e,t,this._selectionContent,i)}return i?this._selectionContent.concat(this.dynamicContent):this._selectionContent.concatWithNoDuplicate(this.dynamicContent),this._selectionContent},t.prototype.intersectsRay=function(e){this._selectionContent.reset();for(var t=0;t<this.blocks.length;t++){var i=this.blocks[t];i.intersectsRay(e,this._selectionContent)}return this._selectionContent.concatWithNoDuplicate(this.dynamicContent),this._selectionContent},t._CreateBlocks=function(t,i,r,n,o,s,a,h){a.blocks=new Array;for(var c=new e.Vector3((i.x-t.x)/2,(i.y-t.y)/2,(i.z-t.z)/2),l=0;2>l;l++)for(var u=0;2>u;u++)for(var f=0;2>f;f++){var d=t.add(c.multiplyByFloats(l,u,f)),p=t.add(c.multiplyByFloats(l+1,u+1,f+1)),_=new e.OctreeBlock(d,p,n,o+1,s,h);_.addEntries(r),a.blocks.push(_)}},t.CreationFuncForMeshes=function(e,t){!e.isBlocked&&e.getBoundingInfo().boundingBox.intersectsMinMax(t.minPoint,t.maxPoint)&&t.entries.push(e)},t.CreationFuncForSubMeshes=function(e,t){e.getBoundingInfo().boundingBox.intersectsMinMax(t.minPoint,t.maxPoint)&&t.entries.push(e)},t}();e.Octree=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(e,t,i,r,n,o){this.entries=new Array,this._boundingVectors=new Array,this._capacity=i,this._depth=r,this._maxDepth=n,this._creationFunc=o,this._minPoint=e,this._maxPoint=t,this._boundingVectors.push(e.clone()),this._boundingVectors.push(t.clone()),this._boundingVectors.push(e.clone()),this._boundingVectors[2].x=t.x,this._boundingVectors.push(e.clone()),this._boundingVectors[3].y=t.y,this._boundingVectors.push(e.clone()),this._boundingVectors[4].z=t.z,this._boundingVectors.push(t.clone()),this._boundingVectors[5].z=e.z,this._boundingVectors.push(t.clone()),this._boundingVectors[6].x=e.x,this._boundingVectors.push(t.clone()),this._boundingVectors[7].y=e.y}return Object.defineProperty(t.prototype,"capacity",{get:function(){return this._capacity},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"minPoint",{get:function(){return this._minPoint},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"maxPoint",{get:function(){return this._maxPoint},enumerable:!0,configurable:!0}),t.prototype.addEntry=function(e){if(this.blocks)for(var t=0;t<this.blocks.length;t++){var i=this.blocks[t];i.addEntry(e)}else this._creationFunc(e,this),this.entries.length>this.capacity&&this._depth<this._maxDepth&&this.createInnerBlocks()},t.prototype.addEntries=function(e){for(var t=0;t<e.length;t++){var i=e[t];this.addEntry(i)}},t.prototype.select=function(t,i,r){if(e.BoundingBox.IsInFrustum(this._boundingVectors,t)){if(this.blocks){for(var n=0;n<this.blocks.length;n++){var o=this.blocks[n];o.select(t,i,r)}return}r?i.concat(this.entries):i.concatWithNoDuplicate(this.entries)}},t.prototype.intersects=function(t,i,r,n){if(e.BoundingBox.IntersectsSphere(this._minPoint,this._maxPoint,t,i)){if(this.blocks){for(var o=0;o<this.blocks.length;o++){var s=this.blocks[o];s.intersects(t,i,r,n)}return}n?r.concat(this.entries):r.concatWithNoDuplicate(this.entries)}},t.prototype.intersectsRay=function(e,t){if(e.intersectsBoxMinMax(this._minPoint,this._maxPoint)){if(this.blocks){for(var i=0;i<this.blocks.length;i++){var r=this.blocks[i];r.intersectsRay(e,t)}return}t.concatWithNoDuplicate(this.entries)}},t.prototype.createInnerBlocks=function(){e.Octree._CreateBlocks(this._minPoint,this._maxPoint,this.entries,this._capacity,this._depth,this._maxDepth,this,this._creationFunc)},t}();e.OctreeBlock=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(t){function i(i,r,n,o,s,a,h,c){var l=this;void 0===a&&(a=e.Texture.BILINEAR_SAMPLINGMODE),t.call(this,i,"blur",["screenSize","direction","blurWidth"],null,o,s,a,h,c),this.direction=r,this.blurWidth=n,this.onApplyObservable.add(function(e){e.setFloat2("screenSize",l.width,l.height),e.setVector2("direction",l.direction),e.setFloat("blurWidth",l.blurWidth)})}return __extends(i,t),i}(e.PostProcess);e.BlurPostProcess=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(t){function i(i,r,n,o,s,a,h,c,l,u){var f=this;t.call(this,i,"refraction",["baseColor","depth","colorLevel"],["refractionSampler"],a,h,c,l,u),this.color=n,this.depth=o,this.colorLevel=s,this.onActivateObservable.add(function(t){f._refRexture=f._refRexture||new e.Texture(r,t.getScene())}),this.onApplyObservable.add(function(e){e.setColor3("baseColor",f.color),e.setFloat("depth",f.depth),e.setFloat("colorLevel",f.colorLevel),e.setTexture("refractionSampler",f._refRexture)})}return __extends(i,t),i.prototype.dispose=function(e){this._refRexture&&this._refRexture.dispose(),t.prototype.dispose.call(this,e)},i}(e.PostProcess);e.RefractionPostProcess=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(e){function t(t,i,r,n,o,s){e.call(this,t,"blackAndWhite",null,null,i,r,n,o,s)}return __extends(t,e),t}(e.PostProcess);e.BlackAndWhitePostProcess=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(e){function t(t,i,r,n,o,s,a){var h=this;e.call(this,t,"convolution",["kernel","screenSize"],null,r,n,o,s,a),this.kernel=i,this.onApply=function(e){e.setFloat2("screenSize",h.width,h.height),e.setArray("kernel",h.kernel)}}return __extends(t,e),t.EdgeDetect0Kernel=[1,0,-1,0,0,0,-1,0,1],t.EdgeDetect1Kernel=[0,1,0,1,-4,1,0,1,0],t.EdgeDetect2Kernel=[-1,-1,-1,-1,8,-1,-1,-1,-1],t.SharpenKernel=[0,-1,0,-1,5,-1,0,-1,0],t.EmbossKernel=[-2,-1,0,-1,1,1,0,1,2],t.GaussianKernel=[0,1,0,1,1,1,0,1,0],t}(e.PostProcess);e.ConvolutionPostProcess=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(e){function t(t,i,r,n,o,s,a){var h=this;e.call(this,t,"filter",["kernelMatrix"],null,r,n,o,s,a),this.kernelMatrix=i,
  31. this.onApply=function(e){e.setMatrix("kernelMatrix",h.kernelMatrix)}}return __extends(t,e),t}(e.PostProcess);e.FilterPostProcess=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(e){function t(t,i,r,n,o,s){var a=this;e.call(this,t,"fxaa",["texelSize"],null,i,r,n,o,s),this.onSizeChangedObservable.add(function(){a.texelWidth=1/a.width,a.texelHeight=1/a.height}),this.onApplyObservable.add(function(e){e.setFloat2("texelSize",a.texelWidth,a.texelHeight)})}return __extends(t,e),t}(e.PostProcess);e.FxaaPostProcess=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(t){function i(i,r,n,o,s,a){var h=this;t.call(this,i,"stereoscopicInterlace",["stepSize"],["camASampler"],1,r[1],o,s,a,n?"#define IS_STEREOSCOPIC_HORIZ 1":void 0),this._passedProcess=r[0]._rigPostProcess,this._stepSize=new e.Vector2(1/this.width,1/this.height),this.onSizeChangedObservable.add(function(){h._stepSize=new e.Vector2(1/h.width,1/h.height)}),this.onApplyObservable.add(function(e){e.setTextureFromPostProcess("camASampler",h._passedProcess),e.setFloat2("stepSize",h._stepSize.x,h._stepSize.y)})}return __extends(i,t),i}(e.PostProcess);e.StereoscopicInterlacePostProcess=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(t,i,r,n,o){this.size=t,this.position=i,this.dispose=function(){this.texture&&this.texture.dispose();var e=this._system.lensFlares.indexOf(this);this._system.lensFlares.splice(e,1)},this.color=r||new e.Color3(1,1,1),this.texture=n?new e.Texture(n,o.getScene(),!0):null,this._system=o,o.lensFlares.push(this)}return t}();e.LensFlare=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(t,i,r){this.name=t,this.lensFlares=new Array,this.borderLimit=300,this.layerMask=268435455,this._vertexBuffers={},this._isEnabled=!0,this._scene=r,this._emitter=i,this.id=t,r.lensFlareSystems.push(this),this.meshesSelectionPredicate=function(e){return e.material&&e.isVisible&&e.isEnabled()&&e.isBlocker&&0!=(e.layerMask&r.activeCamera.layerMask)};var n=r.getEngine(),o=[];o.push(1,1),o.push(-1,1),o.push(-1,-1),o.push(1,-1),this._vertexBuffers[e.VertexBuffer.PositionKind]=new e.VertexBuffer(n,o,e.VertexBuffer.PositionKind,!1,!1,2);var s=[];s.push(0),s.push(1),s.push(2),s.push(0),s.push(2),s.push(3),this._indexBuffer=n.createIndexBuffer(s),this._effect=n.createEffect("lensFlare",[e.VertexBuffer.PositionKind],["color","viewportMatrix"],["textureSampler"],"")}return Object.defineProperty(t.prototype,"isEnabled",{get:function(){return this._isEnabled},set:function(e){this._isEnabled=e},enumerable:!0,configurable:!0}),t.prototype.getScene=function(){return this._scene},t.prototype.getEmitter=function(){return this._emitter},t.prototype.setEmitter=function(e){this._emitter=e},t.prototype.getEmitterPosition=function(){return this._emitter.getAbsolutePosition?this._emitter.getAbsolutePosition():this._emitter.position},t.prototype.computeEffectivePosition=function(t){var i=this.getEmitterPosition();return i=e.Vector3.Project(i,e.Matrix.Identity(),this._scene.getTransformMatrix(),t),this._positionX=i.x,this._positionY=i.y,i=e.Vector3.TransformCoordinates(this.getEmitterPosition(),this._scene.getViewMatrix()),i.z>0&&this._positionX>t.x&&this._positionX<t.x+t.width&&this._positionY>t.y&&this._positionY<t.y+t.height},t.prototype._isVisible=function(){if(!this._isEnabled)return!1;var t=this.getEmitterPosition(),i=t.subtract(this._scene.activeCamera.position),r=i.length();i.normalize();var n=new e.Ray(this._scene.activeCamera.position,i),o=this._scene.pickWithRay(n,this.meshesSelectionPredicate,!0);return!o.hit||o.distance>r},t.prototype.render=function(){if(!this._effect.isReady())return!1;var t=this._scene.getEngine(),i=this._scene.activeCamera.viewport,r=i.toGlobal(t.getRenderWidth(!0),t.getRenderHeight(!0));if(!this.computeEffectivePosition(r))return!1;if(!this._isVisible())return!1;var n,o;n=this._positionX<this.borderLimit+r.x?this.borderLimit+r.x-this._positionX:this._positionX>r.x+r.width-this.borderLimit?this._positionX-r.x-r.width+this.borderLimit:0,o=this._positionY<this.borderLimit+r.y?this.borderLimit+r.y-this._positionY:this._positionY>r.y+r.height-this.borderLimit?this._positionY-r.y-r.height+this.borderLimit:0;var s=n>o?n:o;s>this.borderLimit&&(s=this.borderLimit);var a=1-s/this.borderLimit;if(0>a)return!1;a>1&&(a=1);var h=r.x+r.width/2,c=r.y+r.height/2,l=h-this._positionX,u=c-this._positionY;t.enableEffect(this._effect),t.setState(!1),t.setDepthBuffer(!1),t.setAlphaMode(e.Engine.ALPHA_ONEONE),t.bindBuffers(this._vertexBuffers,this._indexBuffer,this._effect);for(var f=0;f<this.lensFlares.length;f++){var d=this.lensFlares[f],p=h-l*d.position,_=c-u*d.position,m=d.size,g=d.size*t.getAspectRatio(this._scene.activeCamera,!0),v=2*(p/r.width)-1,y=1-2*(_/r.height),x=e.Matrix.FromValues(m/2,0,0,0,0,g/2,0,0,0,0,1,0,v,y,0,1);this._effect.setMatrix("viewportMatrix",x),this._effect.setTexture("textureSampler",d.texture),this._effect.setFloat4("color",d.color.r*a,d.color.g*a,d.color.b*a,1),t.draw(!0,0,6)}return t.setDepthBuffer(!0),t.setAlphaMode(e.Engine.ALPHA_DISABLE),!0},t.prototype.dispose=function(){var t=this._vertexBuffers[e.VertexBuffer.PositionKind];for(t&&(t.dispose(),this._vertexBuffers[e.VertexBuffer.PositionKind]=null),this._indexBuffer&&(this._scene.getEngine()._releaseBuffer(this._indexBuffer),this._indexBuffer=null);this.lensFlares.length;)this.lensFlares[0].dispose();var i=this._scene.lensFlareSystems.indexOf(this);this._scene.lensFlareSystems.splice(i,1)},t.Parse=function(i,r,n){var o=r.getLastEntryByID(i.emitterId),s=i.name||"lensFlareSystem#"+i.emitterId,a=new t(s,o,r);a.id=i.id||s,a.borderLimit=i.borderLimit;for(var h=0;h<i.flares.length;h++){var c=i.flares[h];new e.LensFlare(c.size,c.position,e.Color3.FromArray(c.color),n+c.textureName,a)}return a},t.prototype.serialize=function(){var t={};t.id=this.id,t.name=this.name,t.emitterId=this.getEmitter().id,t.borderLimit=this.borderLimit,t.flares=[];for(var i=0;i<this.lensFlares.length;i++){var r=this.lensFlares[i];t.flares.push({size:r.size,position:r.position,color:r.color.asArray(),textureName:e.Tools.GetFilename(r.texture.name)})}return t},t}();e.LensFlareSystem=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(e){function t(t,i,r){e.call(this,t,i,r),this.inputs.addDeviceOrientation()}return __extends(t,e),Object.defineProperty(t.prototype,"angularSensibility",{get:function(){return 0},set:function(e){},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"moveSensibility",{get:function(){return 0},set:function(e){},enumerable:!0,configurable:!0}),t.prototype.getTypeName=function(){return"DeviceOrientationCamera"},t}(e.FreeCamera);e.DeviceOrientationCamera=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(e){function t(t,i,r){e.call(this,t,i,r),this.inputs.addGamepad()}return __extends(t,e),Object.defineProperty(t.prototype,"gamepadAngularSensibility",{get:function(){var e=this.inputs.attached.gamepad;return e?e.gamepadAngularSensibility:void 0},set:function(e){var t=this.inputs.attached.gamepad;t&&(t.gamepadAngularSensibility=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"gamepadMoveSensibility",{get:function(){var e=this.inputs.attached.gamepad;return e?e.gamepadMoveSensibility:void 0},set:function(e){var t=this.inputs.attached.gamepad;t&&(t.gamepadMoveSensibility=e)},enumerable:!0,configurable:!0}),t.prototype.getTypeName=function(){return"UniversalCamera"},t}(e.TouchCamera);e.UniversalCamera=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function e(e){var t=this;this.babylonGamepads=[],this.oneGamepadConnected=!1,this.isMonitoring=!1,this.gamepadEventSupported="GamepadEvent"in window,this.gamepadSupportAvailable=navigator.getGamepads||!!navigator.webkitGetGamepads||!!navigator.msGetGamepads||!!navigator.webkitGamepads,this._callbackGamepadConnected=e,this.gamepadSupportAvailable&&(this.gamepadEventSupported?(this._onGamepadConnectedEvent=function(e){t._onGamepadConnected(e)},this._onGamepadDisonnectedEvent=function(e){t._onGamepadDisconnected(e)},window.addEventListener("gamepadconnected",this._onGamepadConnectedEvent,!1),window.addEventListener("gamepaddisconnected",this._onGamepadDisonnectedEvent,!1)):this._startMonitoringGamepads())}return e.prototype.dispose=function(){e.gamepadDOMInfo&&document.body.removeChild(e.gamepadDOMInfo),this._onGamepadConnectedEvent&&(window.removeEventListener("gamepadconnected",this._onGamepadConnectedEvent,!1),window.removeEventListener("gamepaddisconnected",this._onGamepadDisonnectedEvent,!1),this._onGamepadConnectedEvent=null,this._onGamepadDisonnectedEvent=null)},e.prototype._onGamepadConnected=function(e){var t=this._addNewGamepad(e.gamepad);this._callbackGamepadConnected&&this._callbackGamepadConnected(t),this._startMonitoringGamepads()},e.prototype._addNewGamepad=function(t){this.oneGamepadConnected||(this.oneGamepadConnected=!0,e.gamepadDOMInfo&&(document.body.removeChild(e.gamepadDOMInfo),e.gamepadDOMInfo=null));var i;return i=-1!==t.id.search("Xbox 360")||-1!==t.id.search("xinput")?new a(t.id,t.index,t):new n(t.id,t.index,t),this.babylonGamepads.push(i),i},e.prototype._onGamepadDisconnected=function(e){for(var t in this.babylonGamepads)if(this.babylonGamepads[t].index==e.gamepad.index){this.babylonGamepads.splice(+t,1);break}0==this.babylonGamepads.length&&this._stopMonitoringGamepads()},e.prototype._startMonitoringGamepads=function(){this.isMonitoring||(this.isMonitoring=!0,this._checkGamepadsStatus())},e.prototype._stopMonitoringGamepads=function(){this.isMonitoring=!1},e.prototype._checkGamepadsStatus=function(){var e=this;this._updateGamepadObjects();for(var t in this.babylonGamepads)this.babylonGamepads[t].update();this.isMonitoring&&(window.requestAnimationFrame?window.requestAnimationFrame(function(){e._checkGamepadsStatus()}):window.mozRequestAnimationFrame?window.mozRequestAnimationFrame(function(){e._checkGamepadsStatus()}):window.webkitRequestAnimationFrame&&window.webkitRequestAnimationFrame(function(){e._checkGamepadsStatus()}))},e.prototype._updateGamepadObjects=function(){for(var e=navigator.getGamepads?navigator.getGamepads():navigator.webkitGetGamepads?navigator.webkitGetGamepads():[],t=0;t<e.length;t++)if(e[t])if(e[t].index in this.babylonGamepads)this.babylonGamepads[t].browserGamepad=e[t];else{var i=this._addNewGamepad(e[t]);this._callbackGamepadConnected&&this._callbackGamepadConnected(i)}},e}();e.Gamepads=t;var i=function(){function e(e,t){this.x=e,this.y=t}return e}();e.StickValues=i;var r=function(){function e(e,t,i){this.id=e,this.index=t,this.browserGamepad=i,this.browserGamepad.axes.length>=2&&(this._leftStick={x:this.browserGamepad.axes[0],y:this.browserGamepad.axes[1]}),this.browserGamepad.axes.length>=4&&(this._rightStick={x:this.browserGamepad.axes[2],y:this.browserGamepad.axes[3]})}return e.prototype.onleftstickchanged=function(e){this._onleftstickchanged=e},e.prototype.onrightstickchanged=function(e){this._onrightstickchanged=e},Object.defineProperty(e.prototype,"leftStick",{get:function(){return this._leftStick},set:function(e){!this._onleftstickchanged||this._leftStick.x===e.x&&this._leftStick.y===e.y||this._onleftstickchanged(e),this._leftStick=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rightStick",{get:function(){return this._rightStick},set:function(e){!this._onrightstickchanged||this._rightStick.x===e.x&&this._rightStick.y===e.y||this._onrightstickchanged(e),this._rightStick=e},enumerable:!0,configurable:!0}),e.prototype.update=function(){this._leftStick&&(this.leftStick={x:this.browserGamepad.axes[0],y:this.browserGamepad.axes[1]}),this._rightStick&&(this.rightStick={x:this.browserGamepad.axes[2],y:this.browserGamepad.axes[3]})},e}();e.Gamepad=r;var n=function(e){function t(t,i,r){e.call(this,t,i,r),this.id=t,this.index=i,this.gamepad=r,this._buttons=new Array(r.buttons.length)}return __extends(t,e),t.prototype.onbuttondown=function(e){this._onbuttondown=e},t.prototype.onbuttonup=function(e){this._onbuttonup=e},t.prototype._setButtonValue=function(e,t,i){return e!==t&&(this._onbuttondown&&1===e&&this._onbuttondown(i),this._onbuttonup&&0===e&&this._onbuttonup(i)),e},t.prototype.update=function(){e.prototype.update.call(this);for(var t=0;t<this._buttons.length;t++)this._buttons[t]=this._setButtonValue(this.gamepad.buttons[t].value,this._buttons[t],t)},t}(r);e.GenericPad=n,function(e){e[e.A=0]="A",e[e.B=1]="B",e[e.X=2]="X",e[e.Y=3]="Y",e[e.Start=4]="Start",e[e.Back=5]="Back",e[e.LB=6]="LB",e[e.RB=7]="RB",e[e.LeftStick=8]="LeftStick",e[e.RightStick=9]="RightStick"}(e.Xbox360Button||(e.Xbox360Button={}));var o=e.Xbox360Button;!function(e){e[e.Up=0]="Up",e[e.Down=1]="Down",e[e.Left=2]="Left",e[e.Right=3]="Right"}(e.Xbox360Dpad||(e.Xbox360Dpad={}));var s=e.Xbox360Dpad,a=function(e){function t(){e.apply(this,arguments),this._leftTrigger=0,this._rightTrigger=0,this._buttonA=0,this._buttonB=0,this._buttonX=0,this._buttonY=0,this._buttonBack=0,this._buttonStart=0,this._buttonLB=0,this._buttonRB=0,this._buttonLeftStick=0,this._buttonRightStick=0,this._dPadUp=0,this._dPadDown=0,this._dPadLeft=0,this._dPadRight=0}return __extends(t,e),t.prototype.onlefttriggerchanged=function(e){this._onlefttriggerchanged=e},t.prototype.onrighttriggerchanged=function(e){this._onrighttriggerchanged=e},Object.defineProperty(t.prototype,"leftTrigger",{get:function(){return this._leftTrigger},set:function(e){this._onlefttriggerchanged&&this._leftTrigger!==e&&this._onlefttriggerchanged(e),this._leftTrigger=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"rightTrigger",{get:function(){return this._rightTrigger},set:function(e){this._onrighttriggerchanged&&this._rightTrigger!==e&&this._onrighttriggerchanged(e),this._rightTrigger=e},enumerable:!0,configurable:!0}),t.prototype.onbuttondown=function(e){this._onbuttondown=e},t.prototype.onbuttonup=function(e){this._onbuttonup=e},t.prototype.ondpaddown=function(e){this._ondpaddown=e},t.prototype.ondpadup=function(e){this._ondpadup=e},t.prototype._setButtonValue=function(e,t,i){return e!==t&&(this._onbuttondown&&1===e&&this._onbuttondown(i),this._onbuttonup&&0===e&&this._onbuttonup(i)),e},t.prototype._setDPadValue=function(e,t,i){return e!==t&&(this._ondpaddown&&1===e&&this._ondpaddown(i),this._ondpadup&&0===e&&this._ondpadup(i)),e},Object.defineProperty(t.prototype,"buttonA",{get:function(){return this._buttonA},set:function(e){this._buttonA=this._setButtonValue(e,this._buttonA,o.A)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"buttonB",{get:function(){return this._buttonB},set:function(e){this._buttonB=this._setButtonValue(e,this._buttonB,o.B)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"buttonX",{get:function(){return this._buttonX},set:function(e){this._buttonX=this._setButtonValue(e,this._buttonX,o.X)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"buttonY",{get:function(){return this._buttonY},set:function(e){this._buttonY=this._setButtonValue(e,this._buttonY,o.Y)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"buttonStart",{get:function(){return this._buttonStart},set:function(e){this._buttonStart=this._setButtonValue(e,this._buttonStart,o.Start)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"buttonBack",{get:function(){return this._buttonBack},set:function(e){this._buttonBack=this._setButtonValue(e,this._buttonBack,o.Back)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"buttonLB",{get:function(){return this._buttonLB},set:function(e){this._buttonLB=this._setButtonValue(e,this._buttonLB,o.LB)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"buttonRB",{get:function(){return this._buttonRB},set:function(e){this._buttonRB=this._setButtonValue(e,this._buttonRB,o.RB)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"buttonLeftStick",{get:function(){return this._buttonLeftStick},set:function(e){this._buttonLeftStick=this._setButtonValue(e,this._buttonLeftStick,o.LeftStick)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"buttonRightStick",{get:function(){return this._buttonRightStick},set:function(e){this._buttonRightStick=this._setButtonValue(e,this._buttonRightStick,o.RightStick)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"dPadUp",{get:function(){return this._dPadUp},set:function(e){this._dPadUp=this._setDPadValue(e,this._dPadUp,s.Up)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"dPadDown",{get:function(){return this._dPadDown},set:function(e){this._dPadDown=this._setDPadValue(e,this._dPadDown,s.Down)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"dPadLeft",{get:function(){return this._dPadLeft},set:function(e){this._dPadLeft=this._setDPadValue(e,this._dPadLeft,s.Left)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"dPadRight",{get:function(){return this._dPadRight},set:function(e){this._dPadRight=this._setDPadValue(e,this._dPadRight,s.Right)},enumerable:!0,configurable:!0}),t.prototype.update=function(){e.prototype.update.call(this),this.buttonA=this.browserGamepad.buttons[0].value,this.buttonB=this.browserGamepad.buttons[1].value,this.buttonX=this.browserGamepad.buttons[2].value,this.buttonY=this.browserGamepad.buttons[3].value,this.buttonLB=this.browserGamepad.buttons[4].value,this.buttonRB=this.browserGamepad.buttons[5].value,this.leftTrigger=this.browserGamepad.buttons[6].value,this.rightTrigger=this.browserGamepad.buttons[7].value,this.buttonBack=this.browserGamepad.buttons[8].value,this.buttonStart=this.browserGamepad.buttons[9].value,this.buttonLeftStick=this.browserGamepad.buttons[10].value,this.buttonRightStick=this.browserGamepad.buttons[11].value,this.dPadUp=this.browserGamepad.buttons[12].value,this.dPadDown=this.browserGamepad.buttons[13].value,this.dPadLeft=this.browserGamepad.buttons[14].value,this.dPadRight=this.browserGamepad.buttons[15].value},t}(r);e.Xbox360Pad=a}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(t){function i(i,r,n){e.Tools.Warn("Deprecated. Please use Universal Camera instead."),t.call(this,i,r,n)}return __extends(i,t),Object.defineProperty(i.prototype,"gamepadAngularSensibility",{get:function(){var e=this.inputs.attached.gamepad;return e?e.gamepadAngularSensibility:void 0},set:function(e){var t=this.inputs.attached.gamepad;t&&(t.gamepadAngularSensibility=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"gamepadMoveSensibility",{get:function(){var e=this.inputs.attached.gamepad;return e?e.gamepadMoveSensibility:void 0},set:function(e){var t=this.inputs.attached.gamepad;t&&(t.gamepadMoveSensibility=e)},enumerable:!0,configurable:!0}),i.prototype.getTypeName=function(){return"GamepadCamera"},i}(e.UniversalCamera);e.GamepadCamera=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(t){this.SMOOTHING=.75,this.FFT_SIZE=512,this.BARGRAPHAMPLITUDE=256,this.DEBUGCANVASPOS={x:20,y:20},this.DEBUGCANVASSIZE={width:320,height:200},this._scene=t,this._audioEngine=e.Engine.audioEngine,this._audioEngine.canUseWebAudio&&(this._webAudioAnalyser=this._audioEngine.audioContext.createAnalyser(),this._webAudioAnalyser.minDecibels=-140,this._webAudioAnalyser.maxDecibels=0,this._byteFreqs=new Uint8Array(this._webAudioAnalyser.frequencyBinCount),this._byteTime=new Uint8Array(this._webAudioAnalyser.frequencyBinCount),this._floatFreqs=new Float32Array(this._webAudioAnalyser.frequencyBinCount))}return t.prototype.getFrequencyBinCount=function(){return this._audioEngine.canUseWebAudio?this._webAudioAnalyser.frequencyBinCount:0},t.prototype.getByteFrequencyData=function(){return this._audioEngine.canUseWebAudio&&(this._webAudioAnalyser.smoothingTimeConstant=this.SMOOTHING,this._webAudioAnalyser.fftSize=this.FFT_SIZE,this._webAudioAnalyser.getByteFrequencyData(this._byteFreqs)),this._byteFreqs},t.prototype.getByteTimeDomainData=function(){return this._audioEngine.canUseWebAudio&&(this._webAudioAnalyser.smoothingTimeConstant=this.SMOOTHING,this._webAudioAnalyser.fftSize=this.FFT_SIZE,this._webAudioAnalyser.getByteTimeDomainData(this._byteTime)),this._byteTime},t.prototype.getFloatFrequencyData=function(){return this._audioEngine.canUseWebAudio&&(this._webAudioAnalyser.smoothingTimeConstant=this.SMOOTHING,this._webAudioAnalyser.fftSize=this.FFT_SIZE,this._webAudioAnalyser.getFloatFrequencyData(this._floatFreqs)),this._floatFreqs},t.prototype.drawDebugCanvas=function(){var e=this;if(this._audioEngine.canUseWebAudio&&(this._debugCanvas||(this._debugCanvas=document.createElement("canvas"),this._debugCanvas.width=this.DEBUGCANVASSIZE.width,this._debugCanvas.height=this.DEBUGCANVASSIZE.height,this._debugCanvas.style.position="absolute",this._debugCanvas.style.top=this.DEBUGCANVASPOS.y+"px",this._debugCanvas.style.left=this.DEBUGCANVASPOS.x+"px",this._debugCanvasContext=this._debugCanvas.getContext("2d"),document.body.appendChild(this._debugCanvas),this._registerFunc=function(){e.drawDebugCanvas()},this._scene.registerBeforeRender(this._registerFunc)),this._registerFunc)){var t=this.getByteFrequencyData();this._debugCanvasContext.fillStyle="rgb(0, 0, 0)",this._debugCanvasContext.fillRect(0,0,this.DEBUGCANVASSIZE.width,this.DEBUGCANVASSIZE.height);for(var i=0;i<this.getFrequencyBinCount();i++){var r=t[i],n=r/this.BARGRAPHAMPLITUDE,o=this.DEBUGCANVASSIZE.height*n,s=this.DEBUGCANVASSIZE.height-o-1,a=this.DEBUGCANVASSIZE.width/this.getFrequencyBinCount(),h=i/this.getFrequencyBinCount()*360;this._debugCanvasContext.fillStyle="hsl("+h+", 100%, 50%)",this._debugCanvasContext.fillRect(i*a,s,a,o)}}},t.prototype.stopDebugCanvas=function(){this._debugCanvas&&(this._scene.unregisterBeforeRender(this._registerFunc),this._registerFunc=null,document.body.removeChild(this._debugCanvas),this._debugCanvas=null,this._debugCanvasContext=null)},t.prototype.connectAudioNodes=function(e,t){this._audioEngine.canUseWebAudio&&(e.connect(this._webAudioAnalyser),this._webAudioAnalyser.connect(t))},t.prototype.dispose=function(){this._audioEngine.canUseWebAudio&&this._webAudioAnalyser.disconnect()},t}();e.Analyser=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(t,i){var r=this;void 0===i&&(i=e.Engine.TEXTURETYPE_FLOAT),this._viewMatrix=e.Matrix.Zero(),this._projectionMatrix=e.Matrix.Zero(),this._transformMatrix=e.Matrix.Zero(),this._worldViewProjection=e.Matrix.Zero(),this._scene=t;var n=t.getEngine();this._depthMap=new e.RenderTargetTexture("depthMap",{width:n.getRenderWidth(),height:n.getRenderHeight()},this._scene,!1,!0,i),this._depthMap.wrapU=e.Texture.CLAMP_ADDRESSMODE,this._depthMap.wrapV=e.Texture.CLAMP_ADDRESSMODE,this._depthMap.refreshRate=1,this._depthMap.renderParticles=!1,this._depthMap.renderList=null,this._depthMap.onClearObservable.add(function(t){t.clear(new e.Color4(1,1,1,1),!0,!0)});var o=function(t){var i=t.getRenderingMesh(),n=r._scene,o=n.getEngine();o.setState(t.getMaterial().backFaceCulling);var s=i._getInstancesRenderList(t._id);if(!s.mustReturn){var a=null!==o.getCaps().instancedArrays&&null!==s.visibleInstances[t._id];if(r.isReady(t,a)){o.enableEffect(r._effect),i._bind(t,r._effect,e.Material.TriangleFillMode);var h=t.getMaterial();if(r._effect.setMatrix("viewProjection",n.getTransformMatrix()),r._effect.setFloat("far",n.activeCamera.maxZ),h&&h.needAlphaTesting()){var c=h.getAlphaTestTexture();r._effect.setTexture("diffuseSampler",c),r._effect.setMatrix("diffuseMatrix",c.getTextureMatrix())}i.useBones&&i.computeBonesUsingShaders&&r._effect.setMatrices("mBones",i.skeleton.getTransformMatrices(i)),i._processRendering(t,r._effect,e.Material.TriangleFillMode,s,a,function(e,t){return r._effect.setMatrix("world",t)})}}};this._depthMap.customRenderFunction=function(e,t){var i;for(i=0;i<e.length;i++)o(e.data[i]);for(i=0;i<t.length;i++)o(t.data[i])}}return t.prototype.isReady=function(t,i){var r=t.getMaterial();if(r.disableDepthWrite)return!1;var n=[],o=[e.VertexBuffer.PositionKind],s=t.getMesh();s.getScene();r&&r.needAlphaTesting()&&(n.push("#define ALPHATEST"),s.isVerticesDataPresent(e.VertexBuffer.UVKind)&&(o.push(e.VertexBuffer.UVKind),n.push("#define UV1")),s.isVerticesDataPresent(e.VertexBuffer.UV2Kind)&&(o.push(e.VertexBuffer.UV2Kind),n.push("#define UV2"))),s.useBones&&s.computeBonesUsingShaders?(o.push(e.VertexBuffer.MatricesIndicesKind),o.push(e.VertexBuffer.MatricesWeightsKind),s.numBoneInfluencers>4&&(o.push(e.VertexBuffer.MatricesIndicesExtraKind),o.push(e.VertexBuffer.MatricesWeightsExtraKind)),n.push("#define NUM_BONE_INFLUENCERS "+s.numBoneInfluencers),n.push("#define BonesPerMesh "+(s.skeleton.bones.length+1))):n.push("#define NUM_BONE_INFLUENCERS 0"),i&&(n.push("#define INSTANCES"),o.push("world0"),o.push("world1"),o.push("world2"),o.push("world3"));var a=n.join("\n");return this._cachedDefines!==a&&(this._cachedDefines=a,this._effect=this._scene.getEngine().createEffect("depth",o,["world","mBones","viewProjection","diffuseMatrix","far"],["diffuseSampler"],a)),this._effect.isReady()},t.prototype.getDepthMap=function(){return this._depthMap},t.prototype.dispose=function(){this._depthMap.dispose()},t}();e.DepthRenderer=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(t){function i(i,r,n,o){var s=this;t.call(this,r.getEngine(),i),this.SSAOOriginalSceneColorEffect="SSAOOriginalSceneColorEffect",this.SSAORenderEffect="SSAORenderEffect",this.SSAOBlurHRenderEffect="SSAOBlurHRenderEffect",this.SSAOBlurVRenderEffect="SSAOBlurVRenderEffect",this.SSAOCombineRenderEffect="SSAOCombineRenderEffect",this.totalStrength=1,this.radius=1e-4,this.area=.0075,this.fallOff=1e-6,this.base=.5,this._firstUpdate=!0,this._scene=r,this._createRandomTexture(),this._depthTexture=r.enableDepthRenderer().getDepthMap();var a=n.ssaoRatio||n,h=n.combineRatio||n;this._ratio={ssaoRatio:a,combineRatio:h},this._originalColorPostProcess=new e.PassPostProcess("SSAOOriginalSceneColor",h,null,e.Texture.BILINEAR_SAMPLINGMODE,r.getEngine(),!1),this._createSSAOPostProcess(a),this._createBlurPostProcess(a),this._createSSAOCombinePostProcess(h),this.addEffect(new e.PostProcessRenderEffect(r.getEngine(),this.SSAOOriginalSceneColorEffect,function(){return s._originalColorPostProcess},!0)),this.addEffect(new e.PostProcessRenderEffect(r.getEngine(),this.SSAORenderEffect,function(){return s._ssaoPostProcess},!0)),this.addEffect(new e.PostProcessRenderEffect(r.getEngine(),this.SSAOBlurHRenderEffect,function(){return s._blurHPostProcess},!0)),this.addEffect(new e.PostProcessRenderEffect(r.getEngine(),this.SSAOBlurVRenderEffect,function(){return s._blurVPostProcess},!0)),this.addEffect(new e.PostProcessRenderEffect(r.getEngine(),this.SSAOCombineRenderEffect,function(){return s._ssaoCombinePostProcess},!0)),r.postProcessRenderPipelineManager.addPipeline(this),o&&r.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(i,o)}return __extends(i,t),i.prototype.getBlurHPostProcess=function(){return e.Tools.Error("SSAORenderinPipeline.getBlurHPostProcess() is deprecated, no more blur post-process exists"),null},i.prototype.getBlurVPostProcess=function(){return e.Tools.Error("SSAORenderinPipeline.getBlurVPostProcess() is deprecated, no more blur post-process exists"),null},i.prototype.dispose=function(e){void 0===e&&(e=!1);for(var t=0;t<this._scene.cameras.length;t++){var i=this._scene.cameras[t];this._originalColorPostProcess.dispose(i),this._ssaoPostProcess.dispose(i),this._blurHPostProcess.dispose(i),this._blurVPostProcess.dispose(i),this._ssaoCombinePostProcess.dispose(i)}this._randomTexture.dispose(),e&&this._scene.disableDepthRenderer(),this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name,this._scene.cameras)},i.prototype._createBlurPostProcess=function(t){for(var i=this,r=[],n=-8;8>n;n++)r.push(2*n);this._blurHPostProcess=new e.PostProcess("BlurH","ssao",["outSize","samplerOffsets"],["depthSampler"],t,null,e.Texture.TRILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,"#define BILATERAL_BLUR\n#define BILATERAL_BLUR_H\n#define SAMPLES 16"),this._blurHPostProcess.onApply=function(e){e.setFloat("outSize",i._ssaoCombinePostProcess.width),e.setTexture("depthSampler",i._depthTexture),i._firstUpdate&&e.setArray("samplerOffsets",r)},this._blurVPostProcess=new e.PostProcess("BlurV","ssao",["outSize","samplerOffsets"],["depthSampler"],t,null,e.Texture.TRILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,"#define BILATERAL_BLUR\n#define SAMPLES 16"),this._blurVPostProcess.onApply=function(e){e.setFloat("outSize",i._ssaoCombinePostProcess.height),e.setTexture("depthSampler",i._depthTexture),i._firstUpdate&&(e.setArray("samplerOffsets",r),i._firstUpdate=!1)}},i.prototype._createSSAOPostProcess=function(t){var i=this,r=16,n=[.5381,.1856,-.4319,.1379,.2486,.443,.3371,.5679,-.0057,-.6999,-.0451,-.0019,.0689,-.1598,-.8547,.056,.0069,-.1843,-.0146,.1402,.0762,.01,-.1924,-.0344,-.3577,-.5301,-.4358,-.3169,.1063,.0158,.0103,-.5869,.0046,-.0897,-.494,.3287,.7119,-.0154,-.0918,-.0533,.0596,-.5411,.0352,-.0631,.546,-.4776,.2847,-.0271],o=1/r;this._ssaoPostProcess=new e.PostProcess("ssao","ssao",["sampleSphere","samplesFactor","randTextureTiles","totalStrength","radius","area","fallOff","base","range","viewport"],["randomSampler"],t,null,e.Texture.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,"#define SAMPLES "+r+"\n#define SSAO");new e.Vector2(0,0);this._ssaoPostProcess.onApply=function(e){i._firstUpdate&&(e.setArray3("sampleSphere",n),e.setFloat("samplesFactor",o),e.setFloat("randTextureTiles",4)),e.setFloat("totalStrength",i.totalStrength),e.setFloat("radius",i.radius),e.setFloat("area",i.area),e.setFloat("fallOff",i.fallOff),e.setFloat("base",i.base),e.setTexture("textureSampler",i._depthTexture),e.setTexture("randomSampler",i._randomTexture)}},i.prototype._createSSAOCombinePostProcess=function(t){var i=this;this._ssaoCombinePostProcess=new e.PostProcess("ssaoCombine","ssaoCombine",[],["originalColor"],t,null,e.Texture.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1),this._ssaoCombinePostProcess.onApply=function(e){e.setTextureFromPostProcess("originalColor",i._originalColorPostProcess)}},i.prototype._createRandomTexture=function(){var t=512;this._randomTexture=new e.DynamicTexture("SSAORandomTexture",t,this._scene,!1,e.Texture.TRILINEAR_SAMPLINGMODE),this._randomTexture.wrapU=e.Texture.WRAP_ADDRESSMODE,this._randomTexture.wrapV=e.Texture.WRAP_ADDRESSMODE;for(var i=this._randomTexture.getContext(),r=function(e,t){return Math.random()*(t-e)+e},n=e.Vector3.Zero(),o=0;t>o;o++)for(var s=0;t>s;s++)n.x=Math.floor(255*r(-1,1)),n.y=Math.floor(255*r(-1,1)),n.z=Math.floor(255*r(-1,1)),i.fillStyle="rgb("+n.x+", "+n.y+", "+n.z+")",i.fillRect(o,s,1,1);this._randomTexture.update(!1)},__decorate([e.serialize()],i.prototype,"totalStrength",void 0),__decorate([e.serialize()],i.prototype,"radius",void 0),__decorate([e.serialize()],i.prototype,"area",void 0),__decorate([e.serialize()],i.prototype,"fallOff",void 0),__decorate([e.serialize()],i.prototype,"base",void 0),__decorate([e.serialize()],i.prototype,"_ratio",void 0),i}(e.PostProcessRenderPipeline);e.SSAORenderingPipeline=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(t){function i(r,n,o,s,a,h,c,l,u){var f=this;void 0===a&&(a=100),void 0===h&&(h=e.Texture.BILINEAR_SAMPLINGMODE),t.call(this,r,"volumetricLightScattering",["decay","exposure","weight","meshPositionOnScreen","density"],["lightScatteringSampler"],n.postProcessRatio||n,o,h,c,l,"#define NUM_SAMPLES "+a),this._screenCoordinates=e.Vector2.Zero(),this.customMeshPosition=e.Vector3.Zero(),this.useCustomMeshPosition=!1,this.invert=!0,this.excludedMeshes=new Array,this.exposure=.3,this.decay=.96815,this.weight=.58767,this.density=.926,u=null===o?u:o.getScene();var c=u.getEngine();this._viewPort=new e.Viewport(0,0,1,1).toGlobal(c.getRenderWidth(),c.getRenderHeight()),this.mesh=null!==s?s:i.CreateDefaultMesh("VolumetricLightScatteringMesh",u),this._createPass(u,n.passRatio||n),this.onActivate=function(e){f.isSupported||f.dispose(e),
  32. f.onActivate=null},this.onApplyObservable.add(function(e){f._updateMeshScreenCoordinates(u),e.setTexture("lightScatteringSampler",f._volumetricLightScatteringRTT),e.setFloat("exposure",f.exposure),e.setFloat("decay",f.decay),e.setFloat("weight",f.weight),e.setFloat("density",f.density),e.setVector2("meshPositionOnScreen",f._screenCoordinates)})}return __extends(i,t),Object.defineProperty(i.prototype,"useDiffuseColor",{get:function(){return e.Tools.Warn("VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead"),!1},set:function(t){e.Tools.Warn("VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead")},enumerable:!0,configurable:!0}),i.prototype.isReady=function(t,i){var r=t.getMesh();if(r===this.mesh)return r.material.isReady(r);var n=[],o=[e.VertexBuffer.PositionKind],s=t.getMaterial();s&&(s.needAlphaTesting()&&n.push("#define ALPHATEST"),r.isVerticesDataPresent(e.VertexBuffer.UVKind)&&(o.push(e.VertexBuffer.UVKind),n.push("#define UV1")),r.isVerticesDataPresent(e.VertexBuffer.UV2Kind)&&(o.push(e.VertexBuffer.UV2Kind),n.push("#define UV2"))),r.useBones&&r.computeBonesUsingShaders?(o.push(e.VertexBuffer.MatricesIndicesKind),o.push(e.VertexBuffer.MatricesWeightsKind),n.push("#define NUM_BONE_INFLUENCERS "+r.numBoneInfluencers),n.push("#define BonesPerMesh "+(r.skeleton.bones.length+1))):n.push("#define NUM_BONE_INFLUENCERS 0"),i&&(n.push("#define INSTANCES"),o.push("world0"),o.push("world1"),o.push("world2"),o.push("world3"));var a=n.join("\n");return this._cachedDefines!==a&&(this._cachedDefines=a,this._volumetricLightScatteringPass=r.getScene().getEngine().createEffect({vertexElement:"depth",fragmentElement:"volumetricLightScatteringPass"},o,["world","mBones","viewProjection","diffuseMatrix"],["diffuseSampler"],a)),this._volumetricLightScatteringPass.isReady()},i.prototype.setCustomMeshPosition=function(e){this.customMeshPosition=e},i.prototype.getCustomMeshPosition=function(){return this.customMeshPosition},i.prototype.dispose=function(e){var i=e.getScene().customRenderTargets.indexOf(this._volumetricLightScatteringRTT);-1!==i&&e.getScene().customRenderTargets.splice(i,1),this._volumetricLightScatteringRTT.dispose(),t.prototype.dispose.call(this,e)},i.prototype.getPass=function(){return this._volumetricLightScatteringRTT},i.prototype._meshExcluded=function(e){return this.excludedMeshes.length>0&&-1!==this.excludedMeshes.indexOf(e)},i.prototype._createPass=function(t,i){var r=this,n=t.getEngine();this._volumetricLightScatteringRTT=new e.RenderTargetTexture("volumetricLightScatteringMap",{width:n.getRenderWidth()*i,height:n.getRenderHeight()*i},t,!1,!0,e.Engine.TEXTURETYPE_UNSIGNED_INT),this._volumetricLightScatteringRTT.wrapU=e.Texture.CLAMP_ADDRESSMODE,this._volumetricLightScatteringRTT.wrapV=e.Texture.CLAMP_ADDRESSMODE,this._volumetricLightScatteringRTT.renderList=null,this._volumetricLightScatteringRTT.renderParticles=!1,t.customRenderTargets.push(this._volumetricLightScatteringRTT);var o,s=function(t){var i=t.getRenderingMesh();if(!r._meshExcluded(i)){var n=i.getScene(),o=n.getEngine();o.setState(t.getMaterial().backFaceCulling);var s=i._getInstancesRenderList(t._id);if(!s.mustReturn){var a=null!==o.getCaps().instancedArrays&&null!==s.visibleInstances[t._id];if(r.isReady(t,a)){var h=r._volumetricLightScatteringPass;if(i===r.mesh&&(h=t.getMaterial().getEffect()),o.enableEffect(h),i._bind(t,h,e.Material.TriangleFillMode),i===r.mesh)t.getMaterial().bind(i.getWorldMatrix(),i);else{var c=t.getMaterial();if(r._volumetricLightScatteringPass.setMatrix("viewProjection",n.getTransformMatrix()),c&&c.needAlphaTesting()){var l=c.getAlphaTestTexture();r._volumetricLightScatteringPass.setTexture("diffuseSampler",l),l&&r._volumetricLightScatteringPass.setMatrix("diffuseMatrix",l.getTextureMatrix())}i.useBones&&i.computeBonesUsingShaders&&r._volumetricLightScatteringPass.setMatrices("mBones",i.skeleton.getTransformMatrices(i))}i._processRendering(t,r._volumetricLightScatteringPass,e.Material.TriangleFillMode,s,a,function(e,t){return h.setMatrix("world",t)})}}}},a=new e.Color4(0,0,0,1);this._volumetricLightScatteringRTT.onBeforeRenderObservable.add(function(){o=t.clearColor,t.clearColor=a}),this._volumetricLightScatteringRTT.onAfterRenderObservable.add(function(){t.clearColor=o}),this._volumetricLightScatteringRTT.customRenderFunction=function(i,r,n){var o,a=t.getEngine();for(o=0;o<i.length;o++)s(i.data[o]);for(a.setAlphaTesting(!0),o=0;o<r.length;o++)s(r.data[o]);if(a.setAlphaTesting(!1),n.length){for(o=0;o<n.length;o++){var h=n.data[o];h._alphaIndex=h.getMesh().alphaIndex,h._distanceToCamera=h.getBoundingInfo().boundingSphere.centerWorld.subtract(t.activeCamera.position).length()}var c=n.data.slice(0,n.length);for(c.sort(function(e,t){return e._alphaIndex>t._alphaIndex?1:e._alphaIndex<t._alphaIndex?-1:e._distanceToCamera<t._distanceToCamera?1:e._distanceToCamera>t._distanceToCamera?-1:0}),a.setAlphaMode(e.Engine.ALPHA_COMBINE),o=0;o<c.length;o++)s(c[o]);a.setAlphaMode(e.Engine.ALPHA_DISABLE)}}},i.prototype._updateMeshScreenCoordinates=function(t){var i,r=t.getTransformMatrix();i=this.useCustomMeshPosition?this.customMeshPosition:this.attachedNode?this.attachedNode.position:this.mesh.parent?this.mesh.getAbsolutePosition():this.mesh.position;var n=e.Vector3.Project(i,e.Matrix.Identity(),r,this._viewPort);this._screenCoordinates.x=n.x/this._viewPort.width,this._screenCoordinates.y=n.y/this._viewPort.height,this.invert&&(this._screenCoordinates.y=1-this._screenCoordinates.y)},i.CreateDefaultMesh=function(t,i){var r=e.Mesh.CreatePlane(t,1,i);r.billboardMode=e.AbstractMesh.BILLBOARDMODE_ALL;var n=new e.StandardMaterial(t+"Material",i);return n.emissiveColor=new e.Color3(1,1,1),r.material=n,r},__decorate([e.serializeAsVector3()],i.prototype,"customMeshPosition",void 0),__decorate([e.serialize()],i.prototype,"useCustomMeshPosition",void 0),__decorate([e.serialize()],i.prototype,"invert",void 0),__decorate([e.serializeAsMeshReference()],i.prototype,"mesh",void 0),__decorate([e.serialize()],i.prototype,"excludedMeshes",void 0),__decorate([e.serialize()],i.prototype,"exposure",void 0),__decorate([e.serialize()],i.prototype,"decay",void 0),__decorate([e.serialize()],i.prototype,"weight",void 0),__decorate([e.serialize()],i.prototype,"density",void 0),i}(e.PostProcess);e.VolumetricLightScatteringPostProcess=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(t){function i(i,r,n,o,s){var a=this;void 0===o&&(o=1),t.call(this,n.getEngine(),i),this.LensChromaticAberrationEffect="LensChromaticAberrationEffect",this.HighlightsEnhancingEffect="HighlightsEnhancingEffect",this.LensDepthOfFieldEffect="LensDepthOfFieldEffect",this._scene=n,this._depthTexture=n.enableDepthRenderer().getDepthMap(),r.grain_texture?this._grainTexture=r.grain_texture:this._createGrainTexture(),this._edgeBlur=r.edge_blur?r.edge_blur:0,this._grainAmount=r.grain_amount?r.grain_amount:0,this._chromaticAberration=r.chromatic_aberration?r.chromatic_aberration:0,this._distortion=r.distortion?r.distortion:0,this._highlightsGain=void 0!==r.dof_gain?r.dof_gain:-1,this._highlightsThreshold=r.dof_threshold?r.dof_threshold:1,this._dofDistance=void 0!==r.dof_focus_distance?r.dof_focus_distance:-1,this._dofAperture=r.dof_aperture?r.dof_aperture:1,this._dofDarken=r.dof_darken?r.dof_darken:0,this._dofPentagon=void 0!==r.dof_pentagon?r.dof_pentagon:!0,this._blurNoise=void 0!==r.blur_noise?r.blur_noise:!0,this._createChromaticAberrationPostProcess(o),this._createHighlightsPostProcess(o),this._createDepthOfFieldPostProcess(o/4),this.addEffect(new e.PostProcessRenderEffect(n.getEngine(),this.LensChromaticAberrationEffect,function(){return a._chromaticAberrationPostProcess},!0)),this.addEffect(new e.PostProcessRenderEffect(n.getEngine(),this.HighlightsEnhancingEffect,function(){return a._highlightsPostProcess},!0)),this.addEffect(new e.PostProcessRenderEffect(n.getEngine(),this.LensDepthOfFieldEffect,function(){return a._depthOfFieldPostProcess},!0)),-1===this._highlightsGain&&this._disableEffect(this.HighlightsEnhancingEffect,null),n.postProcessRenderPipelineManager.addPipeline(this),s&&n.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(i,s)}return __extends(i,t),i.prototype.setEdgeBlur=function(e){this._edgeBlur=e},i.prototype.disableEdgeBlur=function(){this._edgeBlur=0},i.prototype.setGrainAmount=function(e){this._grainAmount=e},i.prototype.disableGrain=function(){this._grainAmount=0},i.prototype.setChromaticAberration=function(e){this._chromaticAberration=e},i.prototype.disableChromaticAberration=function(){this._chromaticAberration=0},i.prototype.setEdgeDistortion=function(e){this._distortion=e},i.prototype.disableEdgeDistortion=function(){this._distortion=0},i.prototype.setFocusDistance=function(e){this._dofDistance=e},i.prototype.disableDepthOfField=function(){this._dofDistance=-1},i.prototype.setAperture=function(e){this._dofAperture=e},i.prototype.setDarkenOutOfFocus=function(e){this._dofDarken=e},i.prototype.enablePentagonBokeh=function(){this._highlightsPostProcess.updateEffect("#define PENTAGON\n")},i.prototype.disablePentagonBokeh=function(){this._highlightsPostProcess.updateEffect()},i.prototype.enableNoiseBlur=function(){this._blurNoise=!0},i.prototype.disableNoiseBlur=function(){this._blurNoise=!1},i.prototype.setHighlightsGain=function(e){this._highlightsGain=e},i.prototype.setHighlightsThreshold=function(e){-1===this._highlightsGain&&(this._highlightsGain=1),this._highlightsThreshold=e},i.prototype.disableHighlights=function(){this._highlightsGain=-1},i.prototype.dispose=function(e){void 0===e&&(e=!1),this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name,this._scene.cameras),this._chromaticAberrationPostProcess=void 0,this._highlightsPostProcess=void 0,this._depthOfFieldPostProcess=void 0,this._grainTexture.dispose(),e&&this._scene.disableDepthRenderer()},i.prototype._createChromaticAberrationPostProcess=function(t){var i=this;this._chromaticAberrationPostProcess=new e.PostProcess("LensChromaticAberration","chromaticAberration",["chromatic_aberration","screen_width","screen_height"],[],t,null,e.Texture.TRILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1),this._chromaticAberrationPostProcess.onApply=function(e){e.setFloat("chromatic_aberration",i._chromaticAberration),e.setFloat("screen_width",i._scene.getEngine().getRenderingCanvas().width),e.setFloat("screen_height",i._scene.getEngine().getRenderingCanvas().height)}},i.prototype._createHighlightsPostProcess=function(t){var i=this;this._highlightsPostProcess=new e.PostProcess("LensHighlights","lensHighlights",["gain","threshold","screen_width","screen_height"],[],t,null,e.Texture.TRILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,this._dofPentagon?"#define PENTAGON\n":""),this._highlightsPostProcess.onApply=function(e){e.setFloat("gain",i._highlightsGain),e.setFloat("threshold",i._highlightsThreshold),e.setTextureFromPostProcess("textureSampler",i._chromaticAberrationPostProcess),e.setFloat("screen_width",i._scene.getEngine().getRenderingCanvas().width),e.setFloat("screen_height",i._scene.getEngine().getRenderingCanvas().height)}},i.prototype._createDepthOfFieldPostProcess=function(t){var i=this;this._depthOfFieldPostProcess=new e.PostProcess("LensDepthOfField","depthOfField",["grain_amount","blur_noise","screen_width","screen_height","distortion","dof_enabled","screen_distance","aperture","darken","edge_blur","highlights","near","far"],["depthSampler","grainSampler","highlightsSampler"],t,null,e.Texture.TRILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1),this._depthOfFieldPostProcess.onApply=function(e){e.setTexture("depthSampler",i._depthTexture),e.setTexture("grainSampler",i._grainTexture),e.setTextureFromPostProcess("textureSampler",i._highlightsPostProcess),e.setTextureFromPostProcess("highlightsSampler",i._depthOfFieldPostProcess),e.setFloat("grain_amount",i._grainAmount),e.setBool("blur_noise",i._blurNoise),e.setFloat("screen_width",i._scene.getEngine().getRenderingCanvas().width),e.setFloat("screen_height",i._scene.getEngine().getRenderingCanvas().height),e.setFloat("distortion",i._distortion),e.setBool("dof_enabled",-1!==i._dofDistance),e.setFloat("screen_distance",1/(.1-1/i._dofDistance)),e.setFloat("aperture",i._dofAperture),e.setFloat("darken",i._dofDarken),e.setFloat("edge_blur",i._edgeBlur),e.setBool("highlights",-1!==i._highlightsGain),e.setFloat("near",i._scene.activeCamera.minZ),e.setFloat("far",i._scene.activeCamera.maxZ)}},i.prototype._createGrainTexture=function(){var t=512;this._grainTexture=new e.DynamicTexture("LensNoiseTexture",t,this._scene,!1,e.Texture.BILINEAR_SAMPLINGMODE),this._grainTexture.wrapU=e.Texture.WRAP_ADDRESSMODE,this._grainTexture.wrapV=e.Texture.WRAP_ADDRESSMODE;for(var i,r=this._grainTexture.getContext(),n=function(e,t){return Math.random()*(t-e)+e},o=0;t>o;o++)for(var s=0;t>s;s++)i=Math.floor(255*n(.42,.58)),r.fillStyle="rgb("+i+", "+i+", "+i+")",r.fillRect(o,s,1,1);this._grainTexture.update(!1)},i}(e.PostProcessRenderPipeline);e.LensRenderingPipeline=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(t){function i(i,r,n,o,s,a,h){var c=this;t.call(this,i,"colorCorrection",null,["colorTable"],n,o,s,a,h),this._colorTableTexture=new e.Texture(r,o.getScene(),!0,!1,e.Texture.TRILINEAR_SAMPLINGMODE),this._colorTableTexture.anisotropicFilteringLevel=1,this._colorTableTexture.wrapU=e.Texture.CLAMP_ADDRESSMODE,this._colorTableTexture.wrapV=e.Texture.CLAMP_ADDRESSMODE,this.onApply=function(e){e.setTexture("colorTable",c._colorTableTexture)}}return __extends(i,t),i}(e.PostProcess);e.ColorCorrectionPostProcess=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(t){function i(i,r,n,o){t.call(this,i,r,o),this.interaxialDistance=n,this.setCameraRigMode(e.Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH,{interaxialDistance:n})}return __extends(i,t),i.prototype.getTypeName=function(){return"AnaglyphFreeCamera"},i}(e.FreeCamera);e.AnaglyphFreeCamera=t;var i=function(t){function i(i,r,n,o,s,a,h){t.call(this,i,r,n,o,s,h),this.interaxialDistance=a,this.setCameraRigMode(e.Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH,{interaxialDistance:a})}return __extends(i,t),i.prototype.getTypeName=function(){return"AnaglyphArcRotateCamera"},i}(e.ArcRotateCamera);e.AnaglyphArcRotateCamera=i;var r=function(t){function i(i,r,n,o){t.call(this,i,r,o),this.interaxialDistance=n,this.setCameraRigMode(e.Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH,{interaxialDistance:n})}return __extends(i,t),i.prototype.getTypeName=function(){return"AnaglyphGamepadCamera"},i}(e.GamepadCamera);e.AnaglyphGamepadCamera=r;var n=function(t){function i(i,r,n,o){t.call(this,i,r,o),this.interaxialDistance=n,this.setCameraRigMode(e.Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH,{interaxialDistance:n})}return __extends(i,t),i.prototype.getTypeName=function(){return"AnaglyphUniversalCamera"},i}(e.UniversalCamera);e.AnaglyphUniversalCamera=n;var o=function(t){function i(i,r,n,o,s){t.call(this,i,r,s),this.interaxialDistance=n,this.isStereoscopicSideBySide=o,this.setCameraRigMode(o?e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:e.Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER,{interaxialDistance:n})}return __extends(i,t),i.prototype.getTypeName=function(){return"StereoscopicFreeCamera"},i}(e.FreeCamera);e.StereoscopicFreeCamera=o;var s=function(t){function i(i,r,n,o,s,a,h,c){t.call(this,i,r,n,o,s,c),this.interaxialDistance=a,this.isStereoscopicSideBySide=h,this.setCameraRigMode(h?e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:e.Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER,{interaxialDistance:a})}return __extends(i,t),i.prototype.getTypeName=function(){return"StereoscopicArcRotateCamera"},i}(e.ArcRotateCamera);e.StereoscopicArcRotateCamera=s;var a=function(t){function i(i,r,n,o,s){t.call(this,i,r,s),this.interaxialDistance=n,this.isStereoscopicSideBySide=o,this.setCameraRigMode(o?e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:e.Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER,{interaxialDistance:n})}return __extends(i,t),i.prototype.getTypeName=function(){return"StereoscopicGamepadCamera"},i}(e.GamepadCamera);e.StereoscopicGamepadCamera=a;var h=function(t){function i(i,r,n,o,s){t.call(this,i,r,s),this.interaxialDistance=n,this.isStereoscopicSideBySide=o,this.setCameraRigMode(o?e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:e.Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER,{interaxialDistance:n})}return __extends(i,t),i.prototype.getTypeName=function(){return"StereoscopicUniversalCamera"},i}(e.UniversalCamera);e.StereoscopicUniversalCamera=h}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(t){function i(r,n,o,s,a){var h=this;void 0===s&&(s=null),t.call(this,n.getEngine(),r),this.gaussCoeff=.3,this.gaussMean=1,this.gaussStandDev=.8,this.gaussMultiplier=4,this.exposure=1,this.minimumLuminance=1,this.maximumLuminance=1e20,this.luminanceIncreaserate=.5,this.luminanceDecreaseRate=.5,this.brightThreshold=.8,this._needUpdate=!0,this._scene=n,this._createBrightPassPostProcess(n,o),this._createDownSampleX4PostProcess(n,o),this._createGaussianBlurPostProcess(n,o),this._createTextureAdderPostProcess(n,o),this._createLuminanceGeneratorPostProcess(n),this._createHDRPostProcess(n,o),null===s?this._originalPostProcess=new e.PassPostProcess("hdr",o,null,e.Texture.BILINEAR_SAMPLINGMODE,n.getEngine(),!1):this._originalPostProcess=s,this.addEffect(new e.PostProcessRenderEffect(n.getEngine(),"HDRPassPostProcess",function(){return h._originalPostProcess},!0)),this.addEffect(new e.PostProcessRenderEffect(n.getEngine(),"HDRBrightPass",function(){return h._brightPassPostProcess},!0)),this.addEffect(new e.PostProcessRenderEffect(n.getEngine(),"HDRDownSampleX4",function(){return h._downSampleX4PostProcess},!0)),this.addEffect(new e.PostProcessRenderEffect(n.getEngine(),"HDRGaussianBlurH",function(){return h._guassianBlurHPostProcess},!0)),this.addEffect(new e.PostProcessRenderEffect(n.getEngine(),"HDRGaussianBlurV",function(){return h._guassianBlurVPostProcess},!0)),this.addEffect(new e.PostProcessRenderEffect(n.getEngine(),"HDRTextureAdder",function(){return h._textureAdderPostProcess},!0));for(var c=function(t){h.addEffect(new e.PostProcessRenderEffect(n.getEngine(),"HDRDownSampler"+t,function(){return h._downSamplePostProcesses[t]},!0))},l=i.LUM_STEPS-1;l>=0;l--)c(l);this.addEffect(new e.PostProcessRenderEffect(n.getEngine(),"HDR",function(){return h._hdrPostProcess},!0)),n.postProcessRenderPipelineManager.addPipeline(this),null!==a&&n.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(r,a),this.update()}return __extends(i,t),i.prototype.update=function(){this._needUpdate=!0},i.prototype.getCurrentLuminance=function(){return this._hdrCurrentLuminance},i.prototype.getOutputLuminance=function(){return this._hdrOutputLuminance},i.prototype.dispose=function(){this._originalPostProcess=void 0,this._brightPassPostProcess=void 0,this._downSampleX4PostProcess=void 0,this._guassianBlurHPostProcess=void 0,this._guassianBlurVPostProcess=void 0,this._textureAdderPostProcess=void 0;for(var e=i.LUM_STEPS-1;e>=0;e--)this._downSamplePostProcesses[e]=void 0;this._hdrPostProcess=void 0,this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name,this._scene.cameras)},i.prototype._createHDRPostProcess=function(t,i){var r=this,n=0;this._hdrOutputLuminance=-1,this._hdrCurrentLuminance=1,this._hdrPostProcess=new e.PostProcess("hdr","hdr",["exposure","avgLuminance"],["otherSampler"],i,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,"#define HDR"),this._hdrPostProcess.onApply=function(i){if(r._hdrOutputLuminance<0)r._hdrOutputLuminance=r._hdrCurrentLuminance;else{var o=(n-(n+t.getEngine().getDeltaTime()))/1e3;r._hdrCurrentLuminance<r._hdrOutputLuminance+r.luminanceDecreaseRate*o?r._hdrOutputLuminance+=r.luminanceDecreaseRate*o:r._hdrCurrentLuminance>r._hdrOutputLuminance-r.luminanceIncreaserate*o?r._hdrOutputLuminance-=r.luminanceIncreaserate*o:r._hdrOutputLuminance=r._hdrCurrentLuminance}r._hdrOutputLuminance=e.MathTools.Clamp(r._hdrOutputLuminance,r.minimumLuminance,r.maximumLuminance),n+=t.getEngine().getDeltaTime(),i.setTextureFromPostProcess("textureSampler",r._textureAdderPostProcess),i.setTextureFromPostProcess("otherSampler",r._originalPostProcess),i.setFloat("exposure",r.exposure),i.setFloat("avgLuminance",r._hdrOutputLuminance),r._needUpdate=!1}},i.prototype._createTextureAdderPostProcess=function(t,i){var r=this;this._textureAdderPostProcess=new e.PostProcess("hdr","hdr",[],["otherSampler"],i,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,"#define TEXTURE_ADDER"),this._textureAdderPostProcess.onApply=function(e){e.setTextureFromPostProcess("otherSampler",r._originalPostProcess)}},i.prototype._createDownSampleX4PostProcess=function(t,i){var r=this,n=new Array(32);this._downSampleX4PostProcess=new e.PostProcess("hdr","hdr",["dsOffsets"],[],i/4,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,"#define DOWN_SAMPLE_X4"),this._downSampleX4PostProcess.onApply=function(e){if(r._needUpdate)for(var t=0,i=-2;2>i;i++)for(var o=-2;2>o;o++)n[t]=(i+.5)*(1/r._downSampleX4PostProcess.width),n[t+1]=(o+.5)*(1/r._downSampleX4PostProcess.height),t+=2;e.setArray2("dsOffsets",n)}},i.prototype._createBrightPassPostProcess=function(t,i){var r=this,n=new Array(8),o=function(e){if(r._needUpdate){var t=1/r._brightPassPostProcess.width,i=1/r._brightPassPostProcess.height;n[0]=-.5*t,n[1]=.5*i,n[2]=.5*t,n[3]=.5*i,n[4]=-.5*t,n[5]=-.5*i,n[6]=.5*t,n[7]=-.5*i}e.setArray2("dsOffsets",n),e.setFloat("brightThreshold",r.brightThreshold)};this._brightPassPostProcess=new e.PostProcess("hdr","hdr",["dsOffsets","brightThreshold"],[],i,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,"#define BRIGHT_PASS"),this._brightPassPostProcess.onApply=o},i.prototype._createLuminanceGeneratorPostProcess=function(t){var r,n=this,o=i.LUM_STEPS,s=new Array(8),a=new Array(18);this._downSamplePostProcesses=new Array(o);var h=function(e,t){var i=1/e,r=1/t;s[0]=-.5*i,s[1]=.5*r,s[2]=.5*i,s[3]=.5*r,s[4]=-.5*i,s[5]=-.5*r,s[6]=.5*i,s[7]=-.5*r},c=function(e,t){for(var i=0,r=-1;2>r;r++)for(var n=-1;2>n;n++)a[i]=r/e,a[i+1]=n/t,i+=2},l=function(e){n._needUpdate&&h(n._textureAdderPostProcess.width,n._textureAdderPostProcess.height),e.setTextureFromPostProcess("textureSampler",n._textureAdderPostProcess),e.setArray2("lumOffsets",s)},u=function(e){var t=e;return function(e){h(n._downSamplePostProcesses[t].width,n._downSamplePostProcesses[t].height),c(n._downSamplePostProcesses[t].width,n._downSamplePostProcesses[t].height),r=.5/n._downSamplePostProcesses[t].width,e.setTextureFromPostProcess("textureSampler",n._downSamplePostProcesses[t+1]),e.setFloat("halfDestPixelSize",r),e.setArray2("dsOffsets",a)}},f=function(i){var r=t.getEngine().readPixels(0,0,1,1),o=new e.Vector4(1/16581375,1/65025,1/255,1);n._hdrCurrentLuminance=(r[0]*o.x+r[1]*o.y+r[2]*o.z+r[3]*o.w)/100},d={width:Math.pow(3,o-1),height:Math.pow(3,o-1)};this._downSamplePostProcesses[o-1]=new e.PostProcess("hdr","hdr",["lumOffsets"],[],d,null,e.Texture.NEAREST_SAMPLINGMODE,t.getEngine(),!1,"#define LUMINANCE_GENERATOR",e.Engine.TEXTURETYPE_FLOAT),this._downSamplePostProcesses[o-1].onApply=l;for(var p=o-2;p>=0;p--){var _=Math.pow(3,p);d={width:_,height:_};var m="#define DOWN_SAMPLE\n";0===p&&(m+="#define FINAL_DOWN_SAMPLE\n"),this._downSamplePostProcesses[p]=new e.PostProcess("hdr","hdr",["dsOffsets","halfDestPixelSize"],[],d,null,e.Texture.NEAREST_SAMPLINGMODE,t.getEngine(),!1,m,e.Engine.TEXTURETYPE_FLOAT),this._downSamplePostProcesses[p].onApply=u(p),0===p&&(this._downSamplePostProcesses[p].onAfterRender=f)}},i.prototype._createGaussianBlurPostProcess=function(t,i){var r=this,n=new Array(9),o=new Array(9),s=new Array(9),a=["blurOffsets","blurWeights","multiplier"],h=function(e){for(var i={width:t.getEngine().getRenderWidth(),height:t.getEngine().getRenderHeight()},r=0;9>r;r++){var s=(r-4)*(1/(e===!0?i.height:i.width));e?o[r]=s:n[r]=s}},c=function(){for(var e=0,t=0;9>t;t++)e=(t-4)/4,s[t]=r.gaussCoeff*(1/Math.sqrt(2*Math.PI*r.gaussStandDev))*Math.exp(-((e-r.gaussMean)*(e-r.gaussMean))/(2*r.gaussStandDev*r.gaussStandDev))},l=function(e){return function(t){r._needUpdate&&(c(),h(e)),t.setArray("blurOffsets",e?o:n),t.setArray("blurWeights",s),t.setFloat("multiplier",r.gaussMultiplier)}};this._guassianBlurHPostProcess=new e.PostProcess("hdr","hdr",a,[],i/4,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,"#define GAUSSIAN_BLUR_H"),this._guassianBlurHPostProcess.onApply=l(!1),this._guassianBlurVPostProcess=new e.PostProcess("hdr","hdr",a,[],i/4,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,"#define GAUSSIAN_BLUR_V"),this._guassianBlurVPostProcess.onApply=l(!0)},i.LUM_STEPS=6,i}(e.PostProcessRenderPipeline);e.HDRRenderingPipeline=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function e(){this.edges=new Array,this.edgesConnectedCount=0}return e}(),i=function(){function i(e,t,i){void 0===t&&(t=.95),void 0===i&&(i=!1),this.edgesWidthScalerForOrthographic=1e3,this.edgesWidthScalerForPerspective=50,this._linesPositions=new Array,this._linesNormals=new Array,this._linesIndices=new Array,this._buffers={},this._checkVerticesInsteadOfIndices=!1,this._source=e,this._checkVerticesInsteadOfIndices=i,this._epsilon=t,this._prepareRessources(),this._generateEdgesLines()}return i.prototype._prepareRessources=function(){this._lineShader||(this._lineShader=new e.ShaderMaterial("lineShader",this._source.getScene(),"line",{attributes:["position","normal"],uniforms:["worldViewProjection","color","width","aspectRatio"]}),this._lineShader.disableDepthWrite=!0,this._lineShader.backFaceCulling=!1)},i.prototype.dispose=function(){var t=this._buffers[e.VertexBuffer.PositionKind];t&&(t.dispose(),this._buffers[e.VertexBuffer.PositionKind]=null),t=this._buffers[e.VertexBuffer.NormalKind],t&&(t.dispose(),this._buffers[e.VertexBuffer.NormalKind]=null),this._source.getScene().getEngine()._releaseBuffer(this._ib),this._lineShader.dispose()},i.prototype._processEdgeForAdjacencies=function(e,t,i,r,n){return e===i&&t===r||e===r&&t===i?0:e===r&&t===n||e===n&&t===r?1:e===n&&t===i||e===i&&t===n?2:-1},i.prototype._processEdgeForAdjacenciesWithVertices=function(e,t,i,r,n){return e.equalsWithEpsilon(i)&&t.equalsWithEpsilon(r)||e.equalsWithEpsilon(r)&&t.equalsWithEpsilon(i)?0:e.equalsWithEpsilon(r)&&t.equalsWithEpsilon(n)||e.equalsWithEpsilon(n)&&t.equalsWithEpsilon(r)?1:e.equalsWithEpsilon(n)&&t.equalsWithEpsilon(i)||e.equalsWithEpsilon(i)&&t.equalsWithEpsilon(n)?2:-1},i.prototype._checkEdge=function(t,i,r,n,o){var s;if(void 0===i)s=!0;else{var a=e.Vector3.Dot(r[t],r[i]);s=a<this._epsilon}if(s){var h=this._linesPositions.length/3,c=n.subtract(o);c.normalize(),this._linesPositions.push(n.x),this._linesPositions.push(n.y),this._linesPositions.push(n.z),this._linesPositions.push(n.x),this._linesPositions.push(n.y),this._linesPositions.push(n.z),this._linesPositions.push(o.x),this._linesPositions.push(o.y),this._linesPositions.push(o.z),this._linesPositions.push(o.x),this._linesPositions.push(o.y),this._linesPositions.push(o.z),this._linesNormals.push(o.x),this._linesNormals.push(o.y),this._linesNormals.push(o.z),this._linesNormals.push(-1),this._linesNormals.push(o.x),this._linesNormals.push(o.y),this._linesNormals.push(o.z),this._linesNormals.push(1),this._linesNormals.push(n.x),this._linesNormals.push(n.y),this._linesNormals.push(n.z),this._linesNormals.push(-1),this._linesNormals.push(n.x),this._linesNormals.push(n.y),this._linesNormals.push(n.z),this._linesNormals.push(1),this._linesIndices.push(h),this._linesIndices.push(h+1),this._linesIndices.push(h+2),this._linesIndices.push(h),this._linesIndices.push(h+2),this._linesIndices.push(h+3)}},i.prototype._generateEdgesLines=function(){var i,r,n=this._source.getVerticesData(e.VertexBuffer.PositionKind),o=this._source.getIndices(),s=new Array,a=new Array;for(i=0;i<o.length;i+=3){r=new t;var h=o[i],c=o[i+1],l=o[i+2];r.p0=new e.Vector3(n[3*h],n[3*h+1],n[3*h+2]),r.p1=new e.Vector3(n[3*c],n[3*c+1],n[3*c+2]),r.p2=new e.Vector3(n[3*l],n[3*l+1],n[3*l+2]);var u=e.Vector3.Cross(r.p1.subtract(r.p0),r.p2.subtract(r.p1));u.normalize(),a.push(u),s.push(r)}for(i=0;i<s.length;i++){r=s[i];for(var f=i+1;f<s.length;f++){var d=s[f];if(3===r.edgesConnectedCount)break;if(3!==d.edgesConnectedCount)for(var p=o[3*f],_=o[3*f+1],m=o[3*f+2],g=0;3>g;g++){var v;if(void 0===r.edges[g]){switch(g){case 0:v=this._checkVerticesInsteadOfIndices?this._processEdgeForAdjacenciesWithVertices(r.p0,r.p1,d.p0,d.p1,d.p2):this._processEdgeForAdjacencies(o[3*i],o[3*i+1],p,_,m);break;case 1:v=this._checkVerticesInsteadOfIndices?this._processEdgeForAdjacenciesWithVertices(r.p1,r.p2,d.p0,d.p1,d.p2):this._processEdgeForAdjacencies(o[3*i+1],o[3*i+2],p,_,m);break;case 2:v=this._checkVerticesInsteadOfIndices?this._processEdgeForAdjacenciesWithVertices(r.p2,r.p0,d.p0,d.p1,d.p2):this._processEdgeForAdjacencies(o[3*i+2],o[3*i],p,_,m)}if(-1!==v&&(r.edges[g]=f,d.edges[v]=i,r.edgesConnectedCount++,d.edgesConnectedCount++,3===r.edgesConnectedCount))break}}}}for(i=0;i<s.length;i++){var y=s[i];this._checkEdge(i,y.edges[0],a,y.p0,y.p1),this._checkEdge(i,y.edges[1],a,y.p1,y.p2),this._checkEdge(i,y.edges[2],a,y.p2,y.p0)}var x=this._source.getScene().getEngine();this._buffers[e.VertexBuffer.PositionKind]=new e.VertexBuffer(x,this._linesPositions,e.VertexBuffer.PositionKind,!1),this._buffers[e.VertexBuffer.NormalKind]=new e.VertexBuffer(x,this._linesNormals,e.VertexBuffer.NormalKind,!1,!1,4),this._ib=x.createIndexBuffer(this._linesIndices),this._indicesCount=this._linesIndices.length},i.prototype.render=function(){if(this._lineShader.isReady()){var t=this._source.getScene(),i=t.getEngine();this._lineShader._preBind(),i.bindBuffers(this._buffers,this._ib,this._lineShader.getEffect()),t.resetCachedMaterial(),this._lineShader.setColor4("color",this._source.edgesColor),t.activeCamera.mode===e.Camera.ORTHOGRAPHIC_CAMERA?this._lineShader.setFloat("width",this._source.edgesWidth/this.edgesWidthScalerForOrthographic):this._lineShader.setFloat("width",this._source.edgesWidth/this.edgesWidthScalerForPerspective),this._lineShader.setFloat("aspectRatio",i.getAspectRatio(t.activeCamera)),this._lineShader.bind(this._source.getWorldMatrix()),i.draw(!0,0,this._indicesCount),this._lineShader.unbind(),i.setDepthWrite(!0)}},i}();e.EdgesRenderer=i}(BABYLON||(BABYLON={}));var BABYLON;!function(e){!function(e){e[e.Hable=0]="Hable",e[e.Reinhard=1]="Reinhard",e[e.HejiDawson=2]="HejiDawson",e[e.Photographic=3]="Photographic"}(e.TonemappingOperator||(e.TonemappingOperator={}));var t=e.TonemappingOperator,i=function(i){function r(r,n,o,s,a,h,c){var l=this;void 0===a&&(a=e.Texture.BILINEAR_SAMPLINGMODE),void 0===c&&(c=e.Engine.TEXTURETYPE_UNSIGNED_INT),i.call(this,r,"tonemap",["_ExposureAdjustment"],null,1,s,a,h,!0,u,c),this._operator=n,this.exposureAdjustment=o;var u="#define ";this._operator===t.Hable?u+="HABLE_TONEMAPPING":this._operator===t.Reinhard?u+="REINHARD_TONEMAPPING":this._operator===t.HejiDawson?u+="OPTIMIZED_HEJIDAWSON_TONEMAPPING":this._operator===t.Photographic&&(u+="PHOTOGRAPHIC_TONEMAPPING"),this.updateEffect(u),this.onApply=function(e){e.setFloat("_ExposureAdjustment",l.exposureAdjustment)}}return __extends(r,i),r}(e.PostProcess);e.TonemapPostProcess=i}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(t,i,r,n){var o=this;void 0===n&&(n=!0),this.name=t,this._viewMatrix=e.Matrix.Identity(),this._target=e.Vector3.Zero(),this._add=e.Vector3.Zero(),this.invertYAxis=!1,this.position=e.Vector3.Zero(),this._scene=r,this._scene.reflectionProbes.push(this),this._renderTargetTexture=new e.RenderTargetTexture(t,i,r,n,!0,e.Engine.TEXTURETYPE_UNSIGNED_INT,!0),this._renderTargetTexture.onBeforeRenderObservable.add(function(t){switch(t){case 0:o._add.copyFromFloats(1,0,0);break;case 1:o._add.copyFromFloats(-1,0,0);break;case 2:o._add.copyFromFloats(0,o.invertYAxis?1:-1,0);break;case 3:o._add.copyFromFloats(0,o.invertYAxis?-1:1,0);break;case 4:o._add.copyFromFloats(0,0,1);break;case 5:
  33. o._add.copyFromFloats(0,0,-1)}o._attachedMesh&&o.position.copyFrom(o._attachedMesh.getAbsolutePosition()),o.position.addToRef(o._add,o._target),e.Matrix.LookAtLHToRef(o.position,o._target,e.Vector3.Up(),o._viewMatrix),r.setTransformMatrix(o._viewMatrix,o._projectionMatrix)}),this._renderTargetTexture.onAfterUnbindObservable.add(function(){r.updateTransformMatrix(!0)}),this._projectionMatrix=e.Matrix.PerspectiveFovLH(Math.PI/2,1,r.activeCamera.minZ,r.activeCamera.maxZ)}return Object.defineProperty(t.prototype,"refreshRate",{get:function(){return this._renderTargetTexture.refreshRate},set:function(e){this._renderTargetTexture.refreshRate=e},enumerable:!0,configurable:!0}),t.prototype.getScene=function(){return this._scene},Object.defineProperty(t.prototype,"cubeTexture",{get:function(){return this._renderTargetTexture},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"renderList",{get:function(){return this._renderTargetTexture.renderList},enumerable:!0,configurable:!0}),t.prototype.attachToMesh=function(e){this._attachedMesh=e},t.prototype.dispose=function(){var e=this._scene.reflectionProbes.indexOf(this);-1!==e&&this._scene.reflectionProbes.splice(e,1),this._renderTargetTexture&&(this._renderTargetTexture.dispose(),this._renderTargetTexture=null)},t}();e.ReflectionProbe=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(t,i,r,n,o){this.color=new e.Color4(1,1,1,1),this.position=e.Vector3.Zero(),this.rotation=e.Vector3.Zero(),this.scaling=new e.Vector3(1,1,1),this.uvs=new e.Vector4(0,0,1,1),this.velocity=e.Vector3.Zero(),this.alive=!0,this.isVisible=!0,this.idx=t,this._pos=i,this._model=r,this.shapeId=n,this.idxInShape=o}return Object.defineProperty(t.prototype,"scale",{get:function(){return this.scaling},set:function(e){this.scaling=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"quaternion",{get:function(){return this.rotationQuaternion},set:function(e){this.rotationQuaternion=e},enumerable:!0,configurable:!0}),t}();e.SolidParticle=t;var i=function(){function e(e,t,i,r,n){this.shapeID=e,this._shape=t,this._shapeUV=i,this._positionFunction=r,this._vertexFunction=n}return e}();e.ModelShape=i}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(t,i,r){this.particles=new Array,this.nbParticles=0,this.billboard=!1,this.counter=0,this.vars={},this._positions=new Array,this._indices=new Array,this._normals=new Array,this._colors=new Array,this._uvs=new Array,this._index=0,this._updatable=!0,this._pickable=!1,this._isVisibilityBoxLocked=!1,this._alwaysVisible=!1,this._shapeCounter=0,this._copy=new e.SolidParticle(null,null,null,null,null),this._color=new e.Color4(0,0,0,0),this._computeParticleColor=!0,this._computeParticleTexture=!0,this._computeParticleRotation=!0,this._computeParticleVertex=!1,this._computeBoundingBox=!1,this._cam_axisZ=e.Vector3.Zero(),this._cam_axisY=e.Vector3.Zero(),this._cam_axisX=e.Vector3.Zero(),this._axisX=e.Axis.X,this._axisY=e.Axis.Y,this._axisZ=e.Axis.Z,this._fakeCamPos=e.Vector3.Zero(),this._rotMatrix=new e.Matrix,this._invertMatrix=new e.Matrix,this._rotated=e.Vector3.Zero(),this._quaternion=new e.Quaternion,this._vertex=e.Vector3.Zero(),this._normal=e.Vector3.Zero(),this._yaw=0,this._pitch=0,this._roll=0,this._halfroll=0,this._halfpitch=0,this._halfyaw=0,this._sinRoll=0,this._cosRoll=0,this._sinPitch=0,this._cosPitch=0,this._sinYaw=0,this._cosYaw=0,this._w=0,this._minimum=e.Tmp.Vector3[0],this._maximum=e.Tmp.Vector3[1],this.name=t,this._scene=i,this._camera=i.activeCamera,this._pickable=r?r.isPickable:!1,r&&r.updatable?this._updatable=r.updatable:this._updatable=!0,this._pickable&&(this.pickedParticles=[])}return t.prototype.buildMesh=function(){if(0===this.nbParticles){var t=e.MeshBuilder.CreateDisc("",{radius:1,tessellation:3},this._scene);this.addShape(t,1),t.dispose()}this._positions32=new Float32Array(this._positions),this._uvs32=new Float32Array(this._uvs),this._colors32=new Float32Array(this._colors),e.VertexData.ComputeNormals(this._positions32,this._indices,this._normals),this._normals32=new Float32Array(this._normals),this._fixedNormal32=new Float32Array(this._normals);var i=new e.VertexData;i.set(this._positions32,e.VertexBuffer.PositionKind),i.indices=this._indices,i.set(this._normals32,e.VertexBuffer.NormalKind),this._uvs32&&i.set(this._uvs32,e.VertexBuffer.UVKind),this._colors32&&i.set(this._colors32,e.VertexBuffer.ColorKind);var r=new e.Mesh(this.name,this._scene);return i.applyToMesh(r,this._updatable),this.mesh=r,this.mesh.isPickable=this._pickable,this._positions=null,this._normals=null,this._uvs=null,this._colors=null,this._updatable||(this.particles.length=0),r},t.prototype.digest=function(t,i){var r=i&&i.facetNb||1,n=i&&i.number,o=i&&i.delta||0,s=t.getVerticesData(e.VertexBuffer.PositionKind),a=t.getIndices(),h=t.getVerticesData(e.VertexBuffer.UVKind),c=t.getVerticesData(e.VertexBuffer.ColorKind),l=0,u=a.length/3;n?(n=n>u?u:n,r=Math.round(u/n),o=0):r=r>u?u:r;for(var f=[],d=[],p=[],_=[],m=e.Tmp.Vector3[0],g=r;u>l;){r=g+Math.floor((1+o)*Math.random()),l>u-r&&(r=u-l),f.length=0,d.length=0,p.length=0,_.length=0;for(var v=0,y=3*l;3*(l+r)>y;y++){d.push(v);var x=a[y];f.push(s[3*x],s[3*x+1],s[3*x+2]),h&&p.push(h[2*x],h[2*x+1]),c&&_.push(c[4*x],c[4*x+1],c[4*x+2],c[4*x+3]),v++}var b,P=this.nbParticles,A=this._posToShape(f),T=this._uvsToShapeUV(p);for(b=0;b<A.length;b++)m.addInPlace(A[b]);for(m.scaleInPlace(1/A.length),b=0;b<A.length;b++)A[b].subtractInPlace(m);var E=new e.ModelShape(this._shapeCounter,A,T,null,null);this._meshBuilder(this._index,A,this._positions,d,this._indices,p,this._uvs,_,this._colors,P,0,null),this._addParticle(P,this._positions.length,E,this._shapeCounter,0),this.particles[this.nbParticles].position.addInPlace(m),this._index+=A.length,P++,this.nbParticles++,this._shapeCounter++,l+=r}return this},t.prototype._resetCopy=function(){this._copy.position.x=0,this._copy.position.y=0,this._copy.position.z=0,this._copy.rotation.x=0,this._copy.rotation.y=0,this._copy.rotation.z=0,this._copy.rotationQuaternion=null,this._copy.scaling.x=1,this._copy.scaling.y=1,this._copy.scaling.z=1,this._copy.uvs.x=0,this._copy.uvs.y=0,this._copy.uvs.z=1,this._copy.uvs.w=1,this._copy.color=null},t.prototype._meshBuilder=function(t,i,r,n,o,s,a,h,c,l,u,f){var d,p=0,_=0;for(this._resetCopy(),f&&f.positionFunction&&f.positionFunction(this._copy,l,u),this._copy.rotationQuaternion?this._quaternion.copyFrom(this._copy.rotationQuaternion):(this._yaw=this._copy.rotation.y,this._pitch=this._copy.rotation.x,this._roll=this._copy.rotation.z,this._quaternionRotationYPR()),this._quaternionToRotationMatrix(),d=0;d<i.length;d++)this._vertex.x=i[d].x,this._vertex.y=i[d].y,this._vertex.z=i[d].z,f&&f.vertexFunction&&f.vertexFunction(this._copy,this._vertex,d),this._vertex.x*=this._copy.scaling.x,this._vertex.y*=this._copy.scaling.y,this._vertex.z*=this._copy.scaling.z,e.Vector3.TransformCoordinatesToRef(this._vertex,this._rotMatrix,this._rotated),r.push(this._copy.position.x+this._rotated.x,this._copy.position.y+this._rotated.y,this._copy.position.z+this._rotated.z),s&&(a.push((this._copy.uvs.z-this._copy.uvs.x)*s[p]+this._copy.uvs.x,(this._copy.uvs.w-this._copy.uvs.y)*s[p+1]+this._copy.uvs.y),p+=2),this._copy.color?this._color=this._copy.color:h&&h[_]?(this._color.r=h[_],this._color.g=h[_+1],this._color.b=h[_+2],this._color.a=h[_+3]):(this._color.r=1,this._color.g=1,this._color.b=1,this._color.a=1),c.push(this._color.r,this._color.g,this._color.b,this._color.a),_+=4;for(d=0;d<n.length;d++)o.push(t+n[d]);if(this._pickable){var m=n.length/3;for(d=0;m>d;d++)this.pickedParticles.push({idx:l,faceId:d})}},t.prototype._posToShape=function(t){for(var i=[],r=0;r<t.length;r+=3)i.push(new e.Vector3(t[r],t[r+1],t[r+2]));return i},t.prototype._uvsToShapeUV=function(e){var t=[];if(e)for(var i=0;i<e.length;i++)t.push(e[i]);return t},t.prototype._addParticle=function(t,i,r,n,o){this.particles.push(new e.SolidParticle(t,i,r,n,o))},t.prototype.addShape=function(t,i,r){for(var n=t.getVerticesData(e.VertexBuffer.PositionKind),o=t.getIndices(),s=t.getVerticesData(e.VertexBuffer.UVKind),a=t.getVerticesData(e.VertexBuffer.ColorKind),h=this._posToShape(n),c=this._uvsToShapeUV(s),l=r?r.positionFunction:null,u=r?r.vertexFunction:null,f=new e.ModelShape(this._shapeCounter,h,c,l,u),d=this.nbParticles,p=0;i>p;p++)this._meshBuilder(this._index,h,this._positions,o,this._indices,s,this._uvs,a,this._colors,d,p,r),this._updatable&&this._addParticle(d,this._positions.length,f,this._shapeCounter,p),this._index+=h.length,d++;return this.nbParticles+=i,this._shapeCounter++,this._shapeCounter-1},t.prototype._rebuildParticle=function(t){this._resetCopy(),t._model._positionFunction&&t._model._positionFunction(this._copy,t.idx,t.idxInShape),this._copy.rotationQuaternion?this._quaternion.copyFrom(this._copy.rotationQuaternion):(this._yaw=this._copy.rotation.y,this._pitch=this._copy.rotation.x,this._roll=this._copy.rotation.z,this._quaternionRotationYPR()),this._quaternionToRotationMatrix(),this._shape=t._model._shape;for(var i=0;i<this._shape.length;i++)this._vertex.x=this._shape[i].x,this._vertex.y=this._shape[i].y,this._vertex.z=this._shape[i].z,t._model._vertexFunction&&t._model._vertexFunction(this._copy,this._vertex,i),this._vertex.x*=this._copy.scaling.x,this._vertex.y*=this._copy.scaling.y,this._vertex.z*=this._copy.scaling.z,e.Vector3.TransformCoordinatesToRef(this._vertex,this._rotMatrix,this._rotated),this._positions32[t._pos+3*i]=this._copy.position.x+this._rotated.x,this._positions32[t._pos+3*i+1]=this._copy.position.y+this._rotated.y,this._positions32[t._pos+3*i+2]=this._copy.position.z+this._rotated.z;t.position.x=0,t.position.y=0,t.position.z=0,t.rotation.x=0,t.rotation.y=0,t.rotation.z=0,t.rotationQuaternion=null,t.scaling.x=1,t.scaling.y=1,t.scaling.z=1},t.prototype.rebuildMesh=function(){for(var t=0;t<this.particles.length;t++)this._rebuildParticle(this.particles[t]);this.mesh.updateVerticesData(e.VertexBuffer.PositionKind,this._positions32,!1,!1)},t.prototype.setParticles=function(t,i,r){if(void 0===t&&(t=0),void 0===i&&(i=this.nbParticles-1),void 0===r&&(r=!0),this._updatable){this.beforeUpdateParticles(t,i,r),this._cam_axisX.x=1,this._cam_axisX.y=0,this._cam_axisX.z=0,this._cam_axisY.x=0,this._cam_axisY.y=1,this._cam_axisY.z=0,this._cam_axisZ.x=0,this._cam_axisZ.y=0,this._cam_axisZ.z=1,this.billboard&&(this._yaw=this.mesh.rotation.y,this._pitch=this.mesh.rotation.x,this._roll=this.mesh.rotation.z,this._quaternionRotationYPR(),this._quaternionToRotationMatrix(),this._rotMatrix.invertToRef(this._invertMatrix),e.Vector3.TransformCoordinatesToRef(this._camera.globalPosition,this._invertMatrix,this._fakeCamPos),this._fakeCamPos.subtractToRef(this.mesh.position,this._cam_axisZ),e.Vector3.CrossToRef(this._cam_axisZ,this._axisX,this._cam_axisY),e.Vector3.CrossToRef(this._cam_axisZ,this._cam_axisY,this._cam_axisX),this._cam_axisY.normalize(),this._cam_axisX.normalize(),this._cam_axisZ.normalize()),e.Matrix.IdentityToRef(this._rotMatrix);var n=0,o=0,s=0,a=0,h=0,c=0,l=0;this._computeBoundingBox&&(e.Vector3.FromFloatsToRef(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,this._minimum),e.Vector3.FromFloatsToRef(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE,this._maximum)),i=i>this.nbParticles-1?this.nbParticles-1:i;for(var u=t;i>=u;u++){if(this._particle=this.particles[u],this._shape=this._particle._model._shape,this._shapeUV=this._particle._model._shapeUV,this.updateParticle(this._particle),this._particle.isVisible)for(this.billboard&&(this._particle.rotation.x=0,this._particle.rotation.y=0),this._computeParticleRotation&&(this._particle.rotationQuaternion?this._quaternion.copyFrom(this._particle.rotationQuaternion):(this._yaw=this._particle.rotation.y,this._pitch=this._particle.rotation.x,this._roll=this._particle.rotation.z,this._quaternionRotationYPR()),this._quaternionToRotationMatrix()),l=0;l<this._shape.length;l++)n=o+3*l,s=a+4*l,h=c+2*l,this._vertex.x=this._shape[l].x,this._vertex.y=this._shape[l].y,this._vertex.z=this._shape[l].z,this._computeParticleVertex&&this.updateParticleVertex(this._particle,this._vertex,l),this._vertex.x*=this._particle.scaling.x,this._vertex.y*=this._particle.scaling.y,this._vertex.z*=this._particle.scaling.z,this._w=this._vertex.x*this._rotMatrix.m[3]+this._vertex.y*this._rotMatrix.m[7]+this._vertex.z*this._rotMatrix.m[11]+this._rotMatrix.m[15],this._rotated.x=(this._vertex.x*this._rotMatrix.m[0]+this._vertex.y*this._rotMatrix.m[4]+this._vertex.z*this._rotMatrix.m[8]+this._rotMatrix.m[12])/this._w,this._rotated.y=(this._vertex.x*this._rotMatrix.m[1]+this._vertex.y*this._rotMatrix.m[5]+this._vertex.z*this._rotMatrix.m[9]+this._rotMatrix.m[13])/this._w,this._rotated.z=(this._vertex.x*this._rotMatrix.m[2]+this._vertex.y*this._rotMatrix.m[6]+this._vertex.z*this._rotMatrix.m[10]+this._rotMatrix.m[14])/this._w,this._positions32[n]=this._particle.position.x+this._cam_axisX.x*this._rotated.x+this._cam_axisY.x*this._rotated.y+this._cam_axisZ.x*this._rotated.z,this._positions32[n+1]=this._particle.position.y+this._cam_axisX.y*this._rotated.x+this._cam_axisY.y*this._rotated.y+this._cam_axisZ.y*this._rotated.z,this._positions32[n+2]=this._particle.position.z+this._cam_axisX.z*this._rotated.x+this._cam_axisY.z*this._rotated.y+this._cam_axisZ.z*this._rotated.z,this._computeBoundingBox&&(this._positions32[n]<this._minimum.x&&(this._minimum.x=this._positions32[n]),this._positions32[n]>this._maximum.x&&(this._maximum.x=this._positions32[n]),this._positions32[n+1]<this._minimum.y&&(this._minimum.y=this._positions32[n+1]),this._positions32[n+1]>this._maximum.y&&(this._maximum.y=this._positions32[n+1]),this._positions32[n+2]<this._minimum.z&&(this._minimum.z=this._positions32[n+2]),this._positions32[n+2]>this._maximum.z&&(this._maximum.z=this._positions32[n+2])),this._computeParticleVertex||this.billboard||(this._normal.x=this._fixedNormal32[n],this._normal.y=this._fixedNormal32[n+1],this._normal.z=this._fixedNormal32[n+2],this._w=this._normal.x*this._rotMatrix.m[3]+this._normal.y*this._rotMatrix.m[7]+this._normal.z*this._rotMatrix.m[11]+this._rotMatrix.m[15],this._rotated.x=(this._normal.x*this._rotMatrix.m[0]+this._normal.y*this._rotMatrix.m[4]+this._normal.z*this._rotMatrix.m[8]+this._rotMatrix.m[12])/this._w,this._rotated.y=(this._normal.x*this._rotMatrix.m[1]+this._normal.y*this._rotMatrix.m[5]+this._normal.z*this._rotMatrix.m[9]+this._rotMatrix.m[13])/this._w,this._rotated.z=(this._normal.x*this._rotMatrix.m[2]+this._normal.y*this._rotMatrix.m[6]+this._normal.z*this._rotMatrix.m[10]+this._rotMatrix.m[14])/this._w,this._normals32[n]=this._cam_axisX.x*this._rotated.x+this._cam_axisY.x*this._rotated.y+this._cam_axisZ.x*this._rotated.z,this._normals32[n+1]=this._cam_axisX.y*this._rotated.x+this._cam_axisY.y*this._rotated.y+this._cam_axisZ.y*this._rotated.z,this._normals32[n+2]=this._cam_axisX.z*this._rotated.x+this._cam_axisY.z*this._rotated.y+this._cam_axisZ.z*this._rotated.z),this._computeParticleColor&&(this._colors32[s]=this._particle.color.r,this._colors32[s+1]=this._particle.color.g,this._colors32[s+2]=this._particle.color.b,this._colors32[s+3]=this._particle.color.a),this._computeParticleTexture&&(this._uvs32[h]=this._shapeUV[2*l]*(this._particle.uvs.z-this._particle.uvs.x)+this._particle.uvs.x,this._uvs32[h+1]=this._shapeUV[2*l+1]*(this._particle.uvs.w-this._particle.uvs.y)+this._particle.uvs.y);else for(l=0;l<this._shape.length;l++)n=o+3*l,s=a+4*l,h=c+2*l,this._positions32[n]=this._camera.position.x,this._positions32[n+1]=this._camera.position.y,this._positions32[n+2]=this._camera.position.z,this._normals32[n]=0,this._normals32[n+1]=0,this._normals32[n+2]=0,this._computeParticleColor&&(this._colors32[s]=this._particle.color.r,this._colors32[s+1]=this._particle.color.g,this._colors32[s+2]=this._particle.color.b,this._colors32[s+3]=this._particle.color.a),this._computeParticleTexture&&(this._uvs32[h]=this._shapeUV[2*l]*(this._particle.uvs.z-this._particle.uvs.x)+this._particle.uvs.x,this._uvs32[h+1]=this._shapeUV[2*l+1]*(this._particle.uvs.w-this._particle.uvs.y)+this._particle.uvs.y);o=n+3,a=s+4,c=h+2}if(r&&(this._computeParticleColor&&this.mesh.updateVerticesData(e.VertexBuffer.ColorKind,this._colors32,!1,!1),this._computeParticleTexture&&this.mesh.updateVerticesData(e.VertexBuffer.UVKind,this._uvs32,!1,!1),this.mesh.updateVerticesData(e.VertexBuffer.PositionKind,this._positions32,!1,!1),!this.mesh.areNormalsFrozen)){if(this._computeParticleVertex||this.billboard){e.VertexData.ComputeNormals(this._positions32,this._indices,this._normals32);for(var f=0;f<this._normals32.length;f++)this._fixedNormal32[f]=this._normals32[f]}this.mesh.updateVerticesData(e.VertexBuffer.NormalKind,this._normals32,!1,!1)}this._computeBoundingBox&&(this.mesh._boundingInfo=new e.BoundingInfo(this._minimum,this._maximum),this.mesh._boundingInfo.update(this.mesh._worldMatrix)),this.afterUpdateParticles(t,i,r)}},t.prototype._quaternionRotationYPR=function(){this._halfroll=.5*this._roll,this._halfpitch=.5*this._pitch,this._halfyaw=.5*this._yaw,this._sinRoll=Math.sin(this._halfroll),this._cosRoll=Math.cos(this._halfroll),this._sinPitch=Math.sin(this._halfpitch),this._cosPitch=Math.cos(this._halfpitch),this._sinYaw=Math.sin(this._halfyaw),this._cosYaw=Math.cos(this._halfyaw),this._quaternion.x=this._cosYaw*this._sinPitch*this._cosRoll+this._sinYaw*this._cosPitch*this._sinRoll,this._quaternion.y=this._sinYaw*this._cosPitch*this._cosRoll-this._cosYaw*this._sinPitch*this._sinRoll,this._quaternion.z=this._cosYaw*this._cosPitch*this._sinRoll-this._sinYaw*this._sinPitch*this._cosRoll,this._quaternion.w=this._cosYaw*this._cosPitch*this._cosRoll+this._sinYaw*this._sinPitch*this._sinRoll},t.prototype._quaternionToRotationMatrix=function(){this._rotMatrix.m[0]=1-2*(this._quaternion.y*this._quaternion.y+this._quaternion.z*this._quaternion.z),this._rotMatrix.m[1]=2*(this._quaternion.x*this._quaternion.y+this._quaternion.z*this._quaternion.w),this._rotMatrix.m[2]=2*(this._quaternion.z*this._quaternion.x-this._quaternion.y*this._quaternion.w),this._rotMatrix.m[3]=0,this._rotMatrix.m[4]=2*(this._quaternion.x*this._quaternion.y-this._quaternion.z*this._quaternion.w),this._rotMatrix.m[5]=1-2*(this._quaternion.z*this._quaternion.z+this._quaternion.x*this._quaternion.x),this._rotMatrix.m[6]=2*(this._quaternion.y*this._quaternion.z+this._quaternion.x*this._quaternion.w),this._rotMatrix.m[7]=0,this._rotMatrix.m[8]=2*(this._quaternion.z*this._quaternion.x+this._quaternion.y*this._quaternion.w),this._rotMatrix.m[9]=2*(this._quaternion.y*this._quaternion.z-this._quaternion.x*this._quaternion.w),this._rotMatrix.m[10]=1-2*(this._quaternion.y*this._quaternion.y+this._quaternion.x*this._quaternion.x),this._rotMatrix.m[11]=0,this._rotMatrix.m[12]=0,this._rotMatrix.m[13]=0,this._rotMatrix.m[14]=0,this._rotMatrix.m[15]=1},t.prototype.dispose=function(){this.mesh.dispose(),this.vars=null,this._positions=null,this._indices=null,this._normals=null,this._uvs=null,this._colors=null,this._positions32=null,this._normals32=null,this._fixedNormal32=null,this._uvs32=null,this._colors32=null,this.pickedParticles=null},t.prototype.refreshVisibleSize=function(){this._isVisibilityBoxLocked||this.mesh.refreshBoundingInfo()},t.prototype.setVisibilityBox=function(t){var i=t/2;this.mesh._boundingInfo=new e.BoundingInfo(new e.Vector3(-i,-i,-i),new e.Vector3(i,i,i))},Object.defineProperty(t.prototype,"isAlwaysVisible",{get:function(){return this._alwaysVisible},set:function(e){this._alwaysVisible=e,this.mesh.alwaysSelectAsActiveMesh=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isVisibilityBoxLocked",{get:function(){return this._isVisibilityBoxLocked},set:function(e){this._isVisibilityBoxLocked=e,this.mesh.getBoundingInfo().isLocked=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"computeParticleRotation",{get:function(){return this._computeParticleRotation},set:function(e){this._computeParticleRotation=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"computeParticleColor",{get:function(){return this._computeParticleColor},set:function(e){this._computeParticleColor=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"computeParticleTexture",{get:function(){return this._computeParticleTexture},set:function(e){this._computeParticleTexture=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"computeParticleVertex",{get:function(){return this._computeParticleVertex},set:function(e){this._computeParticleVertex=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"computeBoundingBox",{get:function(){return this._computeBoundingBox},set:function(e){this._computeBoundingBox=e},enumerable:!0,configurable:!0}),t.prototype.initParticles=function(){},t.prototype.recycleParticle=function(e){return e},t.prototype.updateParticle=function(e){return e},t.prototype.updateParticleVertex=function(e,t,i){return t},t.prototype.beforeUpdateParticles=function(e,t,i){},t.prototype.afterUpdateParticles=function(e,t,i){},t}();e.SolidParticleSystem=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t;!function(t){var i=function(){function e(e,t,i,r){this.name=e,this.worldAxisForNormal=t,this.worldAxisForFileX=i,this.worldAxisForFileY=r}return e}(),r=function(){function t(){}return t.ConvertCubeMapToSphericalPolynomial=function(t){for(var i=new e.SphericalHarmonics,r=0,n=2/t.size,o=n,s=.5*n-1,a=0;6>a;a++)for(var h=this.FileFaces[a],c=t[h.name],l=s,u=0;u<t.size;u++){for(var f=s,d=0;d<t.size;d++){var p=h.worldAxisForFileX.scale(f).add(h.worldAxisForFileY.scale(l)).add(h.worldAxisForNormal);p.normalize();var _,m=Math.pow(1+f*f+l*l,-1.5),g=c[u*t.size*3+3*d+0],v=c[u*t.size*3+3*d+1],y=c[u*t.size*3+3*d+2],_=new e.Color3(g,v,y);i.addLight(p,_,m),r+=m,f+=n}l+=o}var x=4*Math.PI,b=x/r;return i.scale(b),i.scale(1/Math.PI),e.SphericalPolynomial.getSphericalPolynomialFromHarmonics(i)},t.FileFaces=[new i("right",new e.Vector3(1,0,0),new e.Vector3(0,0,-1),new e.Vector3(0,-1,0)),new i("left",new e.Vector3(-1,0,0),new e.Vector3(0,0,1),new e.Vector3(0,-1,0)),new i("up",new e.Vector3(0,1,0),new e.Vector3(1,0,0),new e.Vector3(0,0,1)),new i("down",new e.Vector3(0,-1,0),new e.Vector3(1,0,0),new e.Vector3(0,0,-1)),new i("front",new e.Vector3(0,0,1),new e.Vector3(1,0,0),new e.Vector3(0,-1,0)),new i("back",new e.Vector3(0,0,-1),new e.Vector3(-1,0,0),new e.Vector3(0,-1,0))],t}();t.CubeMapToSphericalPolynomialTools=r}(t=e.Internals||(e.Internals={}))}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t;!function(t){var i=function(){function t(){}return t.ConvertPanoramaToCubemap=function(e,t,i,r){if(!e)throw"ConvertPanoramaToCubemap: input cannot be null";if(e.length!=t*i*3)throw"ConvertPanoramaToCubemap: input size is wrong";var n=this.CreateCubemapTexture(r,this.FACE_FRONT,e,t,i),o=this.CreateCubemapTexture(r,this.FACE_BACK,e,t,i),s=this.CreateCubemapTexture(r,this.FACE_LEFT,e,t,i),a=this.CreateCubemapTexture(r,this.FACE_RIGHT,e,t,i),h=this.CreateCubemapTexture(r,this.FACE_UP,e,t,i),c=this.CreateCubemapTexture(r,this.FACE_DOWN,e,t,i);return{front:n,back:o,left:s,right:a,up:h,down:c,size:r}},t.CreateCubemapTexture=function(e,t,i,r,n){for(var o=new ArrayBuffer(e*e*4*3),s=new Float32Array(o),a=t[1].subtract(t[0]).scale(1/e),h=t[3].subtract(t[2]).scale(1/e),c=1/e,l=0,u=0;e>u;u++){for(var f=t[0],d=t[2],p=0;e>p;p++){var _=d.subtract(f).scale(l).add(f);_.normalize();var m=this.CalcProjectionSpherical(_,i,r,n);s[u*e*3+3*p+0]=m.r,s[u*e*3+3*p+1]=m.g,s[u*e*3+3*p+2]=m.b,f=f.add(a),d=d.add(h)}l+=c}return s},t.CalcProjectionSpherical=function(e,t,i,r){for(var n=Math.atan2(e.z,e.x),o=Math.acos(e.y);n<-Math.PI;)n+=2*Math.PI;for(;n>Math.PI;)n-=2*Math.PI;var s=n/Math.PI,a=o/Math.PI;s=.5*s+.5;var h=Math.round(s*i);0>h?h=0:h>=i&&(h=i-1);var c=Math.round(a*r);0>c?c=0:c>=r&&(c=r-1);var l=r-c-1,u=t[l*i*3+3*h+0],f=t[l*i*3+3*h+1],d=t[l*i*3+3*h+2];return{r:u,g:f,b:d}},t.FACE_FRONT=[new e.Vector3(-1,-1,-1),new e.Vector3(1,-1,-1),new e.Vector3(-1,1,-1),new e.Vector3(1,1,-1)],t.FACE_BACK=[new e.Vector3(1,-1,1),new e.Vector3(-1,-1,1),new e.Vector3(1,1,1),new e.Vector3(-1,1,1)],t.FACE_RIGHT=[new e.Vector3(1,-1,-1),new e.Vector3(1,-1,1),new e.Vector3(1,1,-1),new e.Vector3(1,1,1)],t.FACE_LEFT=[new e.Vector3(-1,-1,1),new e.Vector3(-1,-1,-1),new e.Vector3(-1,1,1),new e.Vector3(-1,1,-1)],t.FACE_DOWN=[new e.Vector3(-1,1,-1),new e.Vector3(1,1,-1),new e.Vector3(-1,1,1),new e.Vector3(1,1,1)],t.FACE_UP=[new e.Vector3(-1,-1,1),new e.Vector3(1,-1,1),new e.Vector3(-1,-1,-1),new e.Vector3(1,-1,-1)],t}();t.PanoramaToCubeMapTools=i}(t=e.Internals||(e.Internals={}))}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t;!function(e){var t=function(){function t(){}return t.Ldexp=function(e,t){return t>1023?e*Math.pow(2,1023)*Math.pow(2,t-1023):-1074>t?e*Math.pow(2,-1074)*Math.pow(2,t+1074):e*Math.pow(2,t)},t.Rgbe2float=function(e,t,i,r,n,o){n>0?(n=this.Ldexp(1,n-136),e[o+0]=t*n,e[o+1]=i*n,e[o+2]=r*n):(e[o+0]=0,e[o+1]=0,e[o+2]=0)},t.readStringLine=function(e,t){for(var i="",r="",n=t;n<e.length-t&&(r=String.fromCharCode(e[n]),"\n"!=r);n++)i+=r;return i},t.RGBE_ReadHeader=function(e){var t=0,i=0,r=this.readStringLine(e,0);if("#"!=r[0]||"?"!=r[1])throw"Bad HDR Format.";var n=!1,o=!1,s=0;do s+=r.length+1,r=this.readStringLine(e,s),"FORMAT=32-bit_rle_rgbe"==r?o=!0:0==r.length&&(n=!0);while(!n);if(!o)throw"HDR Bad header format, unsupported FORMAT";s+=r.length+1,r=this.readStringLine(e,s);var a=/^\-Y (.*) \+X (.*)$/g,h=a.exec(r);if(h.length<3)throw"HDR Bad header format, no size";if(i=parseInt(h[2]),t=parseInt(h[1]),8>i||i>32767)throw"HDR Bad header format, unsupported size";return s+=r.length+1,{height:t,width:i,dataPosition:s}},t.GetCubeMapTextureData=function(t,i){var r=new Uint8Array(t),n=this.RGBE_ReadHeader(r),o=this.RGBE_ReadPixels_RLE(r,n),s=e.PanoramaToCubeMapTools.ConvertPanoramaToCubemap(o,n.width,n.height,i);return s},t.RGBE_ReadPixels=function(e,t){return this.RGBE_ReadPixels_RLE(e,t)},t.RGBE_ReadPixels_RLE=function(e,t){for(var i,r,n,o,s,a=t.height,h=t.width,c=t.dataPosition,l=0,u=0,f=0,d=new ArrayBuffer(4*h),p=new Uint8Array(d),_=new ArrayBuffer(t.width*t.height*4*3),m=new Float32Array(_);a>0;){if(i=e[c++],r=e[c++],n=e[c++],o=e[c++],2!=i||2!=r||128&n)throw"HDR Bad header format, not RLE";if((n<<8|o)!=h)throw"HDR Bad header format, wrong scan line width";for(l=0,f=0;4>f;f++)for(u=(f+1)*h;u>l;)if(i=e[c++],r=e[c++],i>128){if(s=i-128,0==s||s>u-l)throw"HDR Bad Format, bad scanline data (run)";for(;s-- >0;)p[l++]=r}else{if(s=i,0==s||s>u-l)throw"HDR Bad Format, bad scanline data (non-run)";if(p[l++]=r,--s>0)for(var g=0;s>g;g++)p[l++]=e[c++]}for(f=0;h>f;f++)i=p[f],r=p[f+h],n=p[f+2*h],o=p[f+3*h],this.Rgbe2float(m,i,r,n,o,(t.height-a)*h*3+3*f);a--}return m},t}();e.HDRTools=t}(t=e.Internals||(e.Internals={}))}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t;!function(t){var i=function(){function t(){this.min=new e.Vector3(0,0,0),this.max=new e.Vector3(0,0,0),this.clear()}return t.prototype.clear=function(){this.min.x=t.MAX,this.min.y=t.MAX,this.min.z=t.MAX,this.max.x=t.MIN,this.max.y=t.MIN,this.max.z=t.MIN},t.prototype.augment=function(e,t,i){this.min.x=Math.min(this.min.x,e),this.min.y=Math.min(this.min.y,t),this.min.z=Math.min(this.min.z,i),this.max.x=Math.max(this.max.x,e),this.max.y=Math.max(this.max.y,t),this.max.z=Math.max(this.max.z,i)},t.prototype.clampMin=function(e,t,i){this.min.x=Math.max(this.min.x,e),this.min.y=Math.max(this.min.y,t),this.min.z=Math.max(this.min.z,i)},t.prototype.clampMax=function(e,t,i){this.max.x=Math.min(this.max.x,e),this.max.y=Math.min(this.max.y,t),this.max.z=Math.min(this.max.z,i)},t.prototype.empty=function(){return this.min.x>this.max.y||this.min.y>this.max.y||this.min.z>this.max.y},t.MAX=Number.MAX_VALUE,t.MIN=Number.MIN_VALUE,t}(),r=function(){function t(e,t,i,r,n,o,s,a,h,c){this.input=e,this.inputSize=t,this.outputSize=i,this.maxNumMipLevels=r,this.numChannels=n,this.isFloat=o,this.specularPower=s,this.cosinePowerDropPerMip=a,this.excludeBase=h,this.fixup=c,this._outputSurface=[],this._numMipLevels=0}return t.prototype.filterCubeMap=function(){return this.init(),this.filterCubeMapMipChain(),this._outputSurface},t.prototype.init=function(){var e,i,r;for(0==this.maxNumMipLevels&&(this.maxNumMipLevels=t.CP_MAX_MIPLEVELS),r=this.outputSize,i=0;i<this.maxNumMipLevels;i++){for(this._outputSurface.length++,this._outputSurface[i]=[],e=0;6>e;e++)this._outputSurface[i].length++,this.isFloat?this._outputSurface[i][e]=new Float32Array(r*r*this.numChannels):this._outputSurface[i][e]=new Uint32Array(r*r*this.numChannels);if(r>>=1,this._numMipLevels++,0==r)return void(this.maxNumMipLevels=i)}},t.prototype.filterCubeMapMipChain=function(){var e=this.specularPower;this.precomputeFilterLookupTables(this.inputSize);for(var t=0;t<this._numMipLevels;t++){this.excludeBase&&0==t&&(e=1e5);var i=this.input,r=this._outputSurface[t],n=this.outputSize>>t,o=this.getBaseFilterAngle(e);this.filterCubeSurfaces(i,this.inputSize,r,n,o,e),this.fixup&&this.fixupCubeEdges(r,n),this.excludeBase&&0==t&&(e=this.specularPower),e*=this.cosinePowerDropPerMip}},t.prototype.getBaseFilterAngle=function(e){var t=1e-6,i=180;return i=Math.acos(Math.pow(t,1/e)),i*=180/Math.PI,i*=2},t.prototype.precomputeFilterLookupTables=function(e){this._normCubeMap=[],this.buildNormalizerSolidAngleCubemap(e)},t.prototype.buildNormalizerSolidAngleCubemap=function(e){var t,i,r;for(t=0;6>t;t++){this._normCubeMap.push(new Float32Array(e*e*4));this.input[t];for(r=0;e>r;r++)for(i=0;e>i;i++){var n=this.texelCoordToVect(t,i,r,e,this.fixup);this._normCubeMap[t][4*(r*e+i)+0]=n.x,this._normCubeMap[t][4*(r*e+i)+1]=n.y,this._normCubeMap[t][4*(r*e+i)+2]=n.z;var o=this.texelCoordSolidAngle(t,i,r,e);this._normCubeMap[t][4*(r*e+i)+4]=o}}},t.prototype.texelCoordToVect=function(e,i,r,n,o){var s,a;if(s=2*(i+.5)/n-1,a=2*(r+.5)/n-1,o&&n>1){var h=Math.pow(n,2)/Math.pow(n-1,3);s=h*Math.pow(s,3)+s,a=h*Math.pow(a,3)+a}var c=t._sgFace2DMapping[e][t.CP_UDIR];t._vectorTemp.x=c[0]*s,t._vectorTemp.y=c[1]*s,t._vectorTemp.z=c[2]*s;var l=t._sgFace2DMapping[e][t.CP_VDIR];t._vectorTemp.x+=l[0]*a,t._vectorTemp.y+=l[1]*a,t._vectorTemp.z+=l[2]*a;var u=t._sgFace2DMapping[e][t.CP_FACEAXIS];return t._vectorTemp.x+=u[0],t._vectorTemp.y+=u[1],t._vectorTemp.z+=u[2],t._vectorTemp.normalize(),t._vectorTemp},t.prototype.vectToTexelCoord=function(e,i,r,n){var o,s,a=Math.abs(e),h=Math.abs(i),c=Math.abs(r);a>=h&&a>=c?(o=a,s=e>=0?t.CP_FACE_X_POS:t.CP_FACE_X_NEG):h>=a&&h>=c?(o=h,s=i>=0?t.CP_FACE_Y_POS:t.CP_FACE_Y_NEG):(o=c,s=r>=0?t.CP_FACE_Z_POS:t.CP_FACE_Z_NEG);var l=1/o;e*=l,i*=l,r*=l;var u=t._sgFace2DMapping[s][t.CP_UDIR],f=u[0]*e+u[1]*i+u[2]*r;u=t._sgFace2DMapping[s][t.CP_VDIR];var d=u[0]*e+u[1]*i+u[2]*r,p=Math.floor(.5*(n-1)*(f+1)),_=Math.floor(.5*(n-1)*(d+1));return t._vectorTemp.x=s,t._vectorTemp.y=p,t._vectorTemp.z=_,t._vectorTemp},t.prototype.areaElement=function(e,t){return Math.atan2(e*t,Math.sqrt(e*e+t*t+1))},t.prototype.texelCoordSolidAngle=function(e,t,i,r){t=2*(t+.5)/r-1,i=2*(i+.5)/r-1;var n=1/r,o=t-n,s=i-n,a=t+n,h=i+n,c=this.areaElement(o,s)-this.areaElement(o,h)-this.areaElement(a,s)+this.areaElement(a,h);return c},t.prototype.filterCubeSurfaces=function(e,t,r,n,o,s){var a,h,c,l=[];for(a=0;6>a;a++)l.push(new i);var u=180/Math.PI*Math.atan2(1,t),f=o/2;u>f&&(f=u),f>90&&(f=90);var d=Math.ceil(f/u);1>d&&(d=1);var p=Math.cos(Math.PI/180*f);for(a=0;6>a;a++)for(c=0;n>c;c++)for(h=0;n>h;h++){var _=this.texelCoordToVect(a,h,c,n,this.fixup).clone();this.clearFilterExtents(l),this.determineFilterExtents(_,t,d,l);var m=this.processFilterExtents(_,p,l,e,t,s);r[a][(c*n+h)*this.numChannels+0]=m.x,r[a][(c*n+h)*this.numChannels+1]=m.y,r[a][(c*n+h)*this.numChannels+2]=m.z}},t.prototype.clearFilterExtents=function(e){for(var t=0;6>t;t++)e[t].clear()},t.prototype.determineFilterExtents=function(e,i,r,n){var o,s,a,h=[0,0,0,0],c=[0,0,0,0],l=[0,0,0,0],u=this.vectToTexelCoord(e.x,e.y,e.z,i),f=u.x,d=u.y,p=u.z;n[f].augment(d-r,p-r,0),n[f].augment(d+r,p+r,0),n[f].clampMin(0,0,0),n[f].clampMax(i-1,i-1,0);var _=n[f].min.x,m=n[f].min.y,g=n[f].max.x,v=n[f].max.y;
  34. h[0]=r-d,c[0]=m,l[0]=v,h[1]=d+r-(i-1),c[1]=m,l[1]=v,h[2]=r-p,c[2]=_,l[2]=g,h[3]=p+r-(i-1),c[3]=_,l[3]=g;for(var y=0;4>y;y++){if(h[y]>0){switch(o=t._sgCubeNgh[f][y][0],s=t._sgCubeNgh[f][y][1],y!=s&&y+s!=3||(c[y]=i-1-c[y],l[y]=i-1-l[y]),t._sgCubeNgh[f][y][1]){case t.CP_EDGE_LEFT:n[o].augment(0,c[y],0),n[o].augment(h[y],l[y],0);break;case t.CP_EDGE_RIGHT:n[o].augment(i-1,c[y],0),n[o].augment(i-1-h[y],l[y],0);break;case t.CP_EDGE_TOP:n[o].augment(c[y],0,0),n[o].augment(l[y],h[y],0);break;case t.CP_EDGE_BOTTOM:n[o].augment(c[y],i-1,0),n[o].augment(l[y],i-1-h[y],0)}n[o].clampMin(0,0,0),n[o].clampMax(i-1,i-1,0)}if(h[y]>i){switch(f){case t.CP_FACE_X_POS:a=t.CP_FACE_X_NEG;break;case t.CP_FACE_X_NEG:a=t.CP_FACE_X_POS;break;case t.CP_FACE_Y_POS:a=t.CP_FACE_Y_NEG;break;case t.CP_FACE_Y_NEG:a=t.CP_FACE_Y_POS;break;case t.CP_FACE_Z_POS:a=t.CP_FACE_Z_NEG;break;case t.CP_FACE_Z_NEG:a=t.CP_FACE_Z_POS}n[a].augment(0,0,0),n[a].augment(i-1,i-1,0)}}},t.prototype.processFilterExtents=function(e,i,r,n,o,s){for(var a=[0,0,0,0],h=0,c=0,l=this.numChannels,u=o,f=4*u,d=u*this.numChannels,p=1,_=0;6>_;_++)if(!r[_].empty())for(var m=r[_].min.x,g=r[_].min.y,v=r[_].max.x,y=r[_].max.y,x=4*(g*u+m),b=this.numChannels*(g*u+m),P=g;y>=P;P++){for(var A=0,T=0,E=m;v>=E;E++){var C=this._normCubeMap[_][x+A+0],S=this._normCubeMap[_][x+A+1],M=this._normCubeMap[_][x+A+2],I=C*e.x+S*e.y+M*e.z;if(I>=i&&I>0){var D=this._normCubeMap[_][x+A+3];for(D*=Math.pow(I,s+p),c=0;l>c;c++)a[c]+=D*n[_][b+T],T++;h+=D}else T+=l;A+=4}x+=f,b+=d}if(0!=h)t._vectorTemp.x=a[0]/h,t._vectorTemp.y=a[1]/h,t._vectorTemp.z=a[2]/h,this.numChannels>3&&(t._vectorTemp.w=a[3]/h);else{var R=this.vectToTexelCoord(e.x,e.y,e.z,o).clone();t._vectorTemp.x=n[R.x][this.numChannels*(R.z*o+R.y)+0],t._vectorTemp.y=n[R.x][this.numChannels*(R.z*o+R.y)+1],t._vectorTemp.z=n[R.x][this.numChannels*(R.z*o+R.y)+2],this.numChannels>3&&(t._vectorTemp.z=n[R.x][this.numChannels*(R.z*o+R.y)+3])}return t._vectorTemp},t.prototype.fixupCubeEdges=function(e,i){var r,n,o,s,a=0,h=[0,0,0,0,0,0,0,0],c=[[],[],[],[]],l=[[[],[],[]],[[],[],[]],[[],[],[]],[[],[],[]],[[],[],[]],[[],[],[]],[[],[],[]],[[],[],[]]];if(!(1>i))if(1!=i){for(s=0;6>s;s++)for(c[0]=[s,0],c[1]=[s,(i-1)*this.numChannels],c[2]=[s,i*(i-1)*this.numChannels],c[3]=[s,(i*(i-1)+(i-1))*this.numChannels],a=0;4>a;a++){var u=t._sgCubeCornerList[s][a];l[u][h[u]]=c[a],h[u]++}for(a=0;8>a;a++)for(r=0;r<this.numChannels;r++){var f=0;for(o=0;3>o;o++)f+=e[l[a][o][0]][l[a][o][1]+r];for(f*=1/3,o=0;3>o;o++)e[l[a][o][0]][l[a][o][1]+r]=f}for(o=0;12>o;o++){var d=t._sgCubeEdgeList[o][0],p=t._sgCubeEdgeList[o][1],_=t._sgCubeNgh[d][p][0],m=t._sgCubeNgh[d][p][1],g=0,v=0,y=0,x=0;switch(p){case t.CP_EDGE_LEFT:y=this.numChannels*i;break;case t.CP_EDGE_RIGHT:g+=(i-1)*this.numChannels,y=this.numChannels*i;break;case t.CP_EDGE_TOP:y=this.numChannels;break;case t.CP_EDGE_BOTTOM:g+=i*(i-1)*this.numChannels,y=this.numChannels}if(p==m||p+m==3)switch(m){case t.CP_EDGE_LEFT:v+=(i-1)*i*this.numChannels,x=-(this.numChannels*i);break;case t.CP_EDGE_RIGHT:v+=((i-1)*i+(i-1))*this.numChannels,x=-(this.numChannels*i);break;case t.CP_EDGE_TOP:v+=(i-1)*this.numChannels,x=-this.numChannels;break;case t.CP_EDGE_BOTTOM:v+=((i-1)*i+(i-1))*this.numChannels,x=-this.numChannels}else switch(m){case t.CP_EDGE_LEFT:x=this.numChannels*i;break;case t.CP_EDGE_RIGHT:v+=(i-1)*this.numChannels,x=this.numChannels*i;break;case t.CP_EDGE_TOP:x=this.numChannels;break;case t.CP_EDGE_BOTTOM:v+=i*(i-1)*this.numChannels,x=this.numChannels}for(g+=y,v+=x,n=1;i-1>n;n++){for(r=0;r<this.numChannels;r++){var b=e[d][g+r],P=e[_][v+r],A=.5*(b+P);e[d][g+r]=A,e[_][v+r]=A}g+=y,v+=x}}}else for(r=0;r<this.numChannels;r++){var T=0;for(s=0;6>s;s++)T+=e[s][r];for(T/=6,s=0;6>s;s++)e[s][r]=T}},t.CP_MAX_MIPLEVELS=16,t.CP_UDIR=0,t.CP_VDIR=1,t.CP_FACEAXIS=2,t.CP_FACE_X_POS=0,t.CP_FACE_X_NEG=1,t.CP_FACE_Y_POS=2,t.CP_FACE_Y_NEG=3,t.CP_FACE_Z_POS=4,t.CP_FACE_Z_NEG=5,t.CP_EDGE_LEFT=0,t.CP_EDGE_RIGHT=1,t.CP_EDGE_TOP=2,t.CP_EDGE_BOTTOM=3,t.CP_CORNER_NNN=0,t.CP_CORNER_NNP=1,t.CP_CORNER_NPN=2,t.CP_CORNER_NPP=3,t.CP_CORNER_PNN=4,t.CP_CORNER_PNP=5,t.CP_CORNER_PPN=6,t.CP_CORNER_PPP=7,t._vectorTemp=new e.Vector4(0,0,0,0),t._sgFace2DMapping=[[[0,0,-1],[0,-1,0],[1,0,0]],[[0,0,1],[0,-1,0],[-1,0,0]],[[1,0,0],[0,0,1],[0,1,0]],[[1,0,0],[0,0,-1],[0,-1,0]],[[1,0,0],[0,-1,0],[0,0,1]],[[-1,0,0],[0,-1,0],[0,0,-1]]],t._sgCubeNgh=[[[t.CP_FACE_Z_POS,t.CP_EDGE_RIGHT],[t.CP_FACE_Z_NEG,t.CP_EDGE_LEFT],[t.CP_FACE_Y_POS,t.CP_EDGE_RIGHT],[t.CP_FACE_Y_NEG,t.CP_EDGE_RIGHT]],[[t.CP_FACE_Z_NEG,t.CP_EDGE_RIGHT],[t.CP_FACE_Z_POS,t.CP_EDGE_LEFT],[t.CP_FACE_Y_POS,t.CP_EDGE_LEFT],[t.CP_FACE_Y_NEG,t.CP_EDGE_LEFT]],[[t.CP_FACE_X_NEG,t.CP_EDGE_TOP],[t.CP_FACE_X_POS,t.CP_EDGE_TOP],[t.CP_FACE_Z_NEG,t.CP_EDGE_TOP],[t.CP_FACE_Z_POS,t.CP_EDGE_TOP]],[[t.CP_FACE_X_NEG,t.CP_EDGE_BOTTOM],[t.CP_FACE_X_POS,t.CP_EDGE_BOTTOM],[t.CP_FACE_Z_POS,t.CP_EDGE_BOTTOM],[t.CP_FACE_Z_NEG,t.CP_EDGE_BOTTOM]],[[t.CP_FACE_X_NEG,t.CP_EDGE_RIGHT],[t.CP_FACE_X_POS,t.CP_EDGE_LEFT],[t.CP_FACE_Y_POS,t.CP_EDGE_BOTTOM],[t.CP_FACE_Y_NEG,t.CP_EDGE_TOP]],[[t.CP_FACE_X_POS,t.CP_EDGE_RIGHT],[t.CP_FACE_X_NEG,t.CP_EDGE_LEFT],[t.CP_FACE_Y_POS,t.CP_EDGE_TOP],[t.CP_FACE_Y_NEG,t.CP_EDGE_BOTTOM]]],t._sgCubeEdgeList=[[t.CP_FACE_X_POS,t.CP_EDGE_LEFT],[t.CP_FACE_X_POS,t.CP_EDGE_RIGHT],[t.CP_FACE_X_POS,t.CP_EDGE_TOP],[t.CP_FACE_X_POS,t.CP_EDGE_BOTTOM],[t.CP_FACE_X_NEG,t.CP_EDGE_LEFT],[t.CP_FACE_X_NEG,t.CP_EDGE_RIGHT],[t.CP_FACE_X_NEG,t.CP_EDGE_TOP],[t.CP_FACE_X_NEG,t.CP_EDGE_BOTTOM],[t.CP_FACE_Z_POS,t.CP_EDGE_TOP],[t.CP_FACE_Z_POS,t.CP_EDGE_BOTTOM],[t.CP_FACE_Z_NEG,t.CP_EDGE_TOP],[t.CP_FACE_Z_NEG,t.CP_EDGE_BOTTOM]],t._sgCubeCornerList=[[t.CP_CORNER_PPP,t.CP_CORNER_PPN,t.CP_CORNER_PNP,t.CP_CORNER_PNN],[t.CP_CORNER_NPN,t.CP_CORNER_NPP,t.CP_CORNER_NNN,t.CP_CORNER_NNP],[t.CP_CORNER_NPN,t.CP_CORNER_PPN,t.CP_CORNER_NPP,t.CP_CORNER_PPP],[t.CP_CORNER_NNP,t.CP_CORNER_PNP,t.CP_CORNER_NNN,t.CP_CORNER_PNN],[t.CP_CORNER_NPP,t.CP_CORNER_PPP,t.CP_CORNER_NNP,t.CP_CORNER_PNP],[t.CP_CORNER_PPN,t.CP_CORNER_NPN,t.CP_CORNER_PNN,t.CP_CORNER_NNN]],t}();t.PMREMGenerator=r}(t=e.Internals||(e.Internals={}))}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(t){function i(i,r,n,o,s,a,h){void 0===o&&(o=!1),void 0===s&&(s=!0),void 0===a&&(a=!1),void 0===h&&(h=!1),t.call(this,r),this._useInGammaSpace=!1,this._generateHarmonics=!0,this._isBABYLONPreprocessed=!1,this.coordinatesMode=e.Texture.CUBIC_MODE,this.sphericalPolynomial=null,this.isPMREM=!1,i&&(this.name=i,this.url=i,this.hasAlpha=!1,this.isCube=!0,this._textureMatrix=e.Matrix.Identity(),n?(this._isBABYLONPreprocessed=!1,this._noMipmap=o,this._size=n,this._useInGammaSpace=a,this._usePMREMGenerator=h&&r.getEngine().getCaps().textureLOD&&this.getScene().getEngine().getCaps().textureFloat&&!this._useInGammaSpace):(this._isBABYLONPreprocessed=!0,this._noMipmap=!1,this._useInGammaSpace=!1,this._usePMREMGenerator=r.getEngine().getCaps().textureLOD&&this.getScene().getEngine().getCaps().textureFloat&&!this._useInGammaSpace),this.isPMREM=this._usePMREMGenerator,this._texture=this._getFromCache(i,this._noMipmap),this._texture||(r.useDelayedTextureLoading?this.delayLoadState=e.Engine.DELAYLOADSTATE_NOTLOADED:this.loadTexture()))}return __extends(i,t),i.prototype.loadBabylonTexture=function(){var t=this,i=0,r=null,n=!this._useInGammaSpace&&this.getScene().getEngine().getCaps().textureFloat?function(e){for(var n=[],o=30,s=0;i>s;s++){n.push([]);for(var a=3*Math.pow(t._size>>s,2),h=0;6>h;h++){var c=r.subarray(o,o+a);n[s].push(c),o+=a}}return n}:null,o=function(o){var s=new Int32Array(o);r=new Float32Array(o);s[0];t._size=s[1],t.getScene().getEngine().updateTextureSize(t._texture,t._size,t._size),t.sphericalPolynomial=new e.SphericalPolynomial,t.sphericalPolynomial.x.copyFromFloats(r[2],r[3],r[4]),t.sphericalPolynomial.y.copyFromFloats(r[5],r[6],r[7]),t.sphericalPolynomial.z.copyFromFloats(r[8],r[9],r[10]),t.sphericalPolynomial.xx.copyFromFloats(r[11],r[12],r[13]),t.sphericalPolynomial.yy.copyFromFloats(r[14],r[15],r[16]),t.sphericalPolynomial.zz.copyFromFloats(r[17],r[18],r[19]),t.sphericalPolynomial.xy.copyFromFloats(r[20],r[21],r[22]),t.sphericalPolynomial.yz.copyFromFloats(r[23],r[24],r[25]),t.sphericalPolynomial.zx.copyFromFloats(r[26],r[27],r[28]),i=s[29];for(var a=30,h=[],c=3*Math.pow(t._size,2),l=0;6>l;l++)h.push(r.subarray(a,a+c)),a+=c;for(var u=[],f=null,d=0;6>d;d++){var p=null;if(n)p=h[d];else{var _=[0,2,4,1,3,5][d];if(p=h[_],!t.getScene().getEngine().getCaps().textureFloat){var m=new ArrayBuffer(c);f=new Uint8Array(m)}for(var g=0;g<t._size*t._size;g++)if(t._useInGammaSpace&&(p[3*g+0]=Math.pow(p[3*g+0],e.ToGammaSpace),p[3*g+1]=Math.pow(p[3*g+1],e.ToGammaSpace),p[3*g+2]=Math.pow(p[3*g+2],e.ToGammaSpace)),f){var v=Math.max(255*p[3*g+0],0),y=Math.max(255*p[3*g+1],0),x=Math.max(255*p[3*g+2],0),b=Math.max(Math.max(v,y),x);if(b>255){var P=255/b;v*=P,y*=P,x*=P}f[3*g+0]=v,f[3*g+1]=y,f[3*g+2]=x}}f?u.push(f):u.push(p)}return u};this._texture=this.getScene().getEngine().createRawCubeTexture(this.url,this.getScene(),this._size,e.Engine.TEXTUREFORMAT_RGB,this.getScene().getEngine().getCaps().textureFloat?e.Engine.TEXTURETYPE_FLOAT:e.Engine.TEXTURETYPE_UNSIGNED_INT,this._noMipmap,o,n)},i.prototype.loadHDRTexture=function(){var t=this,r=function(r){var n=e.Internals.HDRTools.GetCubeMapTextureData(r,t._size);t._generateHarmonics&&(t.sphericalPolynomial=e.Internals.CubeMapToSphericalPolynomialTools.ConvertCubeMapToSphericalPolynomial(n));for(var o=[],s=null,a=0;6>a;a++){if(!t.getScene().getEngine().getCaps().textureFloat){var h=new ArrayBuffer(t._size*t._size*3);s=new Uint8Array(h)}var c=n[i._facesMapping[a]];if(t._useInGammaSpace||s)for(var l=0;l<t._size*t._size;l++)if(t._useInGammaSpace&&(c[3*l+0]=Math.pow(c[3*l+0],e.ToGammaSpace),c[3*l+1]=Math.pow(c[3*l+1],e.ToGammaSpace),c[3*l+2]=Math.pow(c[3*l+2],e.ToGammaSpace)),s){var u=Math.max(255*c[3*l+0],0),f=Math.max(255*c[3*l+1],0),d=Math.max(255*c[3*l+2],0),p=Math.max(Math.max(u,f),d);if(p>255){var _=255/p;u*=_,f*=_,d*=_}s[3*l+0]=u,s[3*l+1]=f,s[3*l+2]=d}s?o.push(s):o.push(c)}return o},n=null;!this._noMipmap&&this._usePMREMGenerator&&(n=function(i){var r=new e.Internals.PMREMGenerator(i,t._size,t._size,0,3,t.getScene().getEngine().getCaps().textureFloat,2048,.25,!1,!0);return r.filterCubeMap()}),this._texture=this.getScene().getEngine().createRawCubeTexture(this.url,this.getScene(),this._size,e.Engine.TEXTUREFORMAT_RGB,this.getScene().getEngine().getCaps().textureFloat?e.Engine.TEXTURETYPE_FLOAT:e.Engine.TEXTURETYPE_UNSIGNED_INT,this._noMipmap,r,n)},i.prototype.loadTexture=function(){this._isBABYLONPreprocessed?this.loadBabylonTexture():this.loadHDRTexture()},i.prototype.clone=function(){var e=this._isBABYLONPreprocessed?null:this._size,t=new i(this.url,this.getScene(),e,this._noMipmap,this._generateHarmonics,this._useInGammaSpace,this._usePMREMGenerator);return t.level=this.level,t.wrapU=this.wrapU,t.wrapV=this.wrapV,t.coordinatesIndex=this.coordinatesIndex,t.coordinatesMode=this.coordinatesMode,t},i.prototype.delayLoad=function(){this.delayLoadState===e.Engine.DELAYLOADSTATE_NOTLOADED&&(this.delayLoadState=e.Engine.DELAYLOADSTATE_LOADED,this._texture=this._getFromCache(this.url,this._noMipmap),this._texture||this.loadTexture())},i.prototype.getReflectionTextureMatrix=function(){return this._textureMatrix},i.Parse=function(t,i,r){var n=null;if(t.name&&!t.isRenderTarget){var o=t.isBABYLONPreprocessed?null:t.size;n=new e.HDRCubeTexture(r+t.name,i,o,n.generateHarmonics,n.useInGammaSpace,n.usePMREMGenerator),n.name=t.name,n.hasAlpha=t.hasAlpha,n.level=t.level,n.coordinatesMode=t.coordinatesMode}return n},i.prototype.serialize=function(){if(!this.name)return null;var e={};return e.name=this.name,e.hasAlpha=this.hasAlpha,e.isCube=!0,e.level=this.level,e.size=this._size,e.coordinatesMode=this.coordinatesMode,e.useInGammaSpace=this._useInGammaSpace,e.generateHarmonics=this._generateHarmonics,e.usePMREMGenerator=this._usePMREMGenerator,e.isBABYLONPreprocessed=this._isBABYLONPreprocessed,e},i.generateBabylonHDROnDisk=function(e,t,r){void 0===r&&(r=null);var n=function(e){var t=new Blob([e],{type:"application/octet-stream"}),i=window.URL.createObjectURL(t),r=document.createElement("a");document.body.appendChild(r),r.style.display="none",r.href=i,r.download="envmap.babylon.hdr",r.click()};i.generateBabylonHDR(e,t,n,r)},i.generateBabylonHDR=function(t,i,r,n){if(void 0===n&&(n=null),!t)return null;if(!e.Tools.IsExponentOfTwo(i))return null;var o=function(t){var n=e.Internals.HDRTools.GetCubeMapTextureData(t,i),o=e.Internals.CubeMapToSphericalPolynomialTools.ConvertCubeMapToSphericalPolynomial(n),s=[];s.push(n.right),s.push(n.left),s.push(n.up),s.push(n.down),s.push(n.front),s.push(n.back);var a=new e.Internals.PMREMGenerator(s,i,i,0,3,!0,2048,.25,!1,!0),h=a.filterCubeMap(),c=4;c+=4,c+=108,c+=4;for(var l=0;l<h.length;l++){var u=i>>l;c+=6*u*u*3*4}var f=new ArrayBuffer(c),d=new Int32Array(f),p=new Float32Array(f);d[0]=1,d[1]=i,o.x.toArray(p,2),o.y.toArray(p,5),o.z.toArray(p,8),o.xx.toArray(p,11),o.yy.toArray(p,14),o.zz.toArray(p,17),o.xy.toArray(p,20),o.yz.toArray(p,23),o.zx.toArray(p,26),d[29]=h.length;for(var _=30,l=0;l<h.length;l++)for(var m=3*Math.pow(i>>l,2),g=0;6>g;g++)p.set(h[l][g],_),_+=m;r(f)};e.Tools.LoadFile(t,function(e){o(e)},null,null,!0,n)},i._facesMapping=["right","up","front","left","down","back"],i}(e.BaseTexture);e.HDRCubeTexture=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t;!function(t){var i=function(){function t(t,i,r,n,o){void 0===n&&(n=!0),void 0===o&&(o=1),this.skeleton=t,this.mesh=i,this.autoUpdateBonesMatrices=n,this.renderingGroupId=o,this.color=e.Color3.White(),this._debugLines=[],this._isEnabled=!1,this._scene=r,this.update(),this._renderFunction=this.update.bind(this)}return Object.defineProperty(t.prototype,"isEnabled",{get:function(){return this._isEnabled},set:function(e){this._isEnabled!==e&&(this._isEnabled=e,e?this._scene.registerBeforeRender(this._renderFunction):this._scene.unregisterBeforeRender(this._renderFunction))},enumerable:!0,configurable:!0}),t.prototype._getBonePosition=function(t,i,r,n,o,s){void 0===n&&(n=0),void 0===o&&(o=0),void 0===s&&(s=0);var a=e.Tmp.Matrix[0],h=i.getParent();if(a.copyFrom(i.getLocalMatrix()),0!==n||0!==o||0!==s){var c=e.Tmp.Matrix[1];e.Matrix.IdentityToRef(c),c.m[12]=n,c.m[13]=o,c.m[14]=s,c.multiplyToRef(a,a)}h&&a.multiplyToRef(h.getAbsoluteTransform(),a),a.multiplyToRef(r,a),t.x=a.m[12],t.y=a.m[13],t.z=a.m[14]},t.prototype._getLinesForBonesWithLength=function(t,i){for(var r=t.length,n=0;r>n;n++){var o=t[n],s=this._debugLines[n];s||(s=[e.Vector3.Zero(),e.Vector3.Zero()],this._debugLines[n]=s),this._getBonePosition(s[0],o,i),this._getBonePosition(s[1],o,i,0,o.length,0)}},t.prototype._getLinesForBonesNoLength=function(t,i){for(var r=t.length,n=0,o=r-1;o>=0;o--){var s=t[o],a=s.getParent();if(a){var h=this._debugLines[n];h||(h=[e.Vector3.Zero(),e.Vector3.Zero()],this._debugLines[n]=h),this._getBonePosition(h[0],s,i),this._getBonePosition(h[1],a,i),n++}}},t.prototype.update=function(){this.autoUpdateBonesMatrices&&this._updateBoneMatrix(this.skeleton.bones[0]),void 0===this.skeleton.bones[0].length?this._getLinesForBonesNoLength(this.skeleton.bones,this.mesh.getWorldMatrix()):this._getLinesForBonesWithLength(this.skeleton.bones,this.mesh.getWorldMatrix()),this._debugMesh?e.MeshBuilder.CreateLineSystem(null,{lines:this._debugLines,updatable:!0,instance:this._debugMesh},this._scene):(this._debugMesh=e.MeshBuilder.CreateLineSystem(null,{lines:this._debugLines,updatable:!0},this._scene),this._debugMesh.renderingGroupId=this.renderingGroupId),this._debugMesh.color=this.color},t.prototype._updateBoneMatrix=function(e){e.getParent()&&e.getLocalMatrix().multiplyToRef(e.getParent().getAbsoluteTransform(),e.getAbsoluteTransform());for(var t=e.children,i=t.length,r=0;i>r;r++)this._updateBoneMatrix(t[r])},t.prototype.dispose=function(){this._debugMesh&&(this.isEnabled=!1,this._debugMesh.dispose(),this._debugMesh=null)},t}();t.SkeletonViewer=i}(t=e.Debug||(e.Debug={}))}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(){this._dirty=!0,this._tempColor=new e.Color4(0,0,0,0),this._globalCurve=new e.Color4(0,0,0,0),this._highlightsCurve=new e.Color4(0,0,0,0),this._midtonesCurve=new e.Color4(0,0,0,0),this._shadowsCurve=new e.Color4(0,0,0,0),this._positiveCurve=new e.Color4(0,0,0,0),this._negativeCurve=new e.Color4(0,0,0,0),this._globalHue=30,this._globalDensity=0,this._globalSaturation=0,this._globalExposure=0,this._highlightsHue=30,this._highlightsDensity=0,this._highlightsSaturation=0,this._highlightsExposure=0,this._midtonesHue=30,this._midtonesDensity=0,this._midtonesSaturation=0,this._midtonesExposure=0,this._shadowsHue=30,this._shadowsDensity=0,this._shadowsSaturation=0,this._shadowsExposure=0}return Object.defineProperty(t.prototype,"GlobalHue",{get:function(){return this._globalHue},set:function(e){this._globalHue=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"GlobalDensity",{get:function(){return this._globalDensity},set:function(e){this._globalDensity=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"GlobalSaturation",{get:function(){return this._globalSaturation},set:function(e){this._globalSaturation=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"HighlightsHue",{get:function(){return this._highlightsHue},set:function(e){this._highlightsHue=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"HighlightsDensity",{get:function(){return this._highlightsDensity},set:function(e){this._highlightsDensity=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"HighlightsSaturation",{get:function(){return this._highlightsSaturation},set:function(e){this._highlightsSaturation=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"HighlightsExposure",{get:function(){return this._highlightsExposure},set:function(e){this._highlightsExposure=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"MidtonesHue",{get:function(){return this._midtonesHue},set:function(e){this._midtonesHue=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"MidtonesDensity",{get:function(){return this._midtonesDensity},set:function(e){this._midtonesDensity=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"MidtonesSaturation",{get:function(){return this._midtonesSaturation},set:function(e){this._midtonesSaturation=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"MidtonesExposure",{get:function(){return this._midtonesExposure},set:function(e){this._midtonesExposure=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"ShadowsHue",{get:function(){return this._shadowsHue},set:function(e){this._shadowsHue=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"ShadowsDensity",{get:function(){return this._shadowsDensity},set:function(e){this._shadowsDensity=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"ShadowsSaturation",{get:function(){return this._shadowsSaturation},set:function(e){this._shadowsSaturation=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"ShadowsExposure",{get:function(){return this._shadowsExposure},set:function(e){this._shadowsExposure=e,this._dirty=!0},enumerable:!0,configurable:!0}),t.Bind=function(e,t){e._dirty&&(e._dirty=!1,e.getColorGradingDataToRef(e._globalHue,e._globalDensity,e._globalSaturation,e._globalExposure,e._globalCurve),e.getColorGradingDataToRef(e._highlightsHue,e._highlightsDensity,e._highlightsSaturation,e._highlightsExposure,e._tempColor),e._tempColor.multiplyToRef(e._globalCurve,e._highlightsCurve),e.getColorGradingDataToRef(e._midtonesHue,e._midtonesDensity,e._midtonesSaturation,e._midtonesExposure,e._tempColor),e._tempColor.multiplyToRef(e._globalCurve,e._midtonesCurve),e.getColorGradingDataToRef(e._shadowsHue,e._shadowsDensity,e._shadowsSaturation,e._shadowsExposure,e._tempColor),e._tempColor.multiplyToRef(e._globalCurve,e._shadowsCurve),e._highlightsCurve.subtractToRef(e._midtonesCurve,e._positiveCurve),e._midtonesCurve.subtractToRef(e._shadowsCurve,e._negativeCurve)),t.setFloat4("vCameraColorCurvePositive",e._positiveCurve.r,e._positiveCurve.g,e._positiveCurve.b,e._positiveCurve.a),t.setFloat4("vCameraColorCurveNeutral",e._midtonesCurve.r,e._midtonesCurve.g,e._midtonesCurve.b,e._midtonesCurve.a),t.setFloat4("vCameraColorCurveNegative",e._negativeCurve.r,e._negativeCurve.g,e._negativeCurve.b,e._negativeCurve.a)},t.PrepareUniforms=function(e){e.push("vCameraColorCurveNeutral","vCameraColorCurvePositive","vCameraColorCurveNegative")},t.prototype.getColorGradingDataToRef=function(e,i,r,n,o){null!=e&&(e=t.clamp(e,0,360),i=t.clamp(i,-100,100),r=t.clamp(r,-100,100),n=t.clamp(n,-100,100),i=t.applyColorGradingSliderNonlinear(i),i*=.5,n=t.applyColorGradingSliderNonlinear(n),0>i&&(i*=-1,e=(e+180)%360),t.fromHSBToRef(e,i,50+.25*n,o),o.scaleToRef(2,o),o.a=1+.01*r)},t.applyColorGradingSliderNonlinear=function(e){e/=100;var t=Math.abs(e);return t=Math.pow(t,2),0>e&&(t*=-1),t*=100},t.fromHSBToRef=function(e,i,r,n){var o=t.clamp(e,0,360),s=t.clamp(i/100,0,1),a=t.clamp(r/100,0,1);if(0===s)n.r=a,n.g=a,n.b=a;else{o/=60;var h=Math.floor(o),c=o-h,l=a*(1-s),u=a*(1-s*c),f=a*(1-s*(1-c));switch(h){case 0:n.r=a,n.g=f,n.b=l;break;case 1:n.r=u,n.g=a,n.b=l;break;case 2:n.r=l,n.g=a,n.b=f;break;case 3:n.r=l,n.g=u,n.b=a;break;case 4:n.r=f,n.g=l,n.b=a;break;default:n.r=a,n.g=l,n.b=u}}n.a=1},t.clamp=function(e,t,i){return Math.min(Math.max(e,t),i)},t.prototype.clone=function(){return e.SerializationHelper.Clone(function(){return new t},this)},t.prototype.serialize=function(){return e.SerializationHelper.Serialize(this)},t.Parse=function(i){return e.SerializationHelper.Parse(function(){return new t},i,null,null)},__decorate([e.serialize()],t.prototype,"_globalHue",void 0),__decorate([e.serialize()],t.prototype,"_globalDensity",void 0),__decorate([e.serialize()],t.prototype,"_globalSaturation",void 0),__decorate([e.serialize()],t.prototype,"_globalExposure",void 0),__decorate([e.serialize()],t.prototype,"_highlightsHue",void 0),__decorate([e.serialize()],t.prototype,"_highlightsDensity",void 0),__decorate([e.serialize()],t.prototype,"_highlightsSaturation",void 0),__decorate([e.serialize()],t.prototype,"_highlightsExposure",void 0),__decorate([e.serialize()],t.prototype,"_midtonesHue",void 0),__decorate([e.serialize()],t.prototype,"_midtonesDensity",void 0),__decorate([e.serialize()],t.prototype,"_midtonesSaturation",void 0),__decorate([e.serialize()],t.prototype,"_midtonesExposure",void 0),t}();e.ColorCurves=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(t){function i(i,r){t.call(this,r),i&&(this._textureMatrix=e.Matrix.Identity(),this.name=i,this.url=i,this.hasAlpha=!1,this.isCube=!1,this.wrapU=e.Texture.CLAMP_ADDRESSMODE,this.wrapV=e.Texture.CLAMP_ADDRESSMODE,this.anisotropicFilteringLevel=1,this._texture=this._getFromCache(i,!0),this._texture||(r.useDelayedTextureLoading?this.delayLoadState=e.Engine.DELAYLOADSTATE_NOTLOADED:this.loadTexture()))}return __extends(i,t),i.prototype.getTextureMatrix=function(){return this._textureMatrix},i.prototype.load3dlTexture=function(){var t=this,r=this.getScene().getEngine().createRawTexture(null,1,1,e.Engine.TEXTUREFORMAT_RGBA,!1,!1,e.Texture.BILINEAR_SAMPLINGMODE);this._texture=r;var n=function(n){for(var o,s,a,h=n.split("\n"),c=0,l=0,u=0,f=0,d=0,p=0;p<h.length;p++)if(a=h[p],i._noneEmptyLineRegex.test(a)&&0!==a.indexOf("#")){var _=a.split(" ");if(0!==c){if(0!=c){var m=Math.max(parseInt(_[0]),0),g=Math.max(parseInt(_[1]),0),v=Math.max(parseInt(_[2]),0);d=Math.max(m,d),d=Math.max(g,d),d=Math.max(v,d);var y=4*(l+f*c+u*c*c);s[y+0]=m,s[y+1]=g,s[y+2]=v,s[y+3]=0,f++,f%c==0&&(u++,f=0,u%c==0&&(l++,u=0))}}else c=_.length,o=new Uint8Array(c*c*c*4),s=new Float32Array(c*c*c*4)}for(var p=0;p<s.length;p++){var x=s[p];o[p]=x/d*255}t.getScene().getEngine().updateTextureSize(r,c*c,c),t.getScene().getEngine().updateRawTexture(r,o,e.Engine.TEXTUREFORMAT_RGBA,!1)};return e.Tools.LoadFile(this.url,n),this._texture},i.prototype.loadTexture=function(){this.url&&this.url.toLocaleLowerCase().indexOf(".3dl")==this.url.length-4&&this.load3dlTexture()},i.prototype.clone=function(){var e=new i(this.url,this.getScene());return e.level=this.level,e},i.prototype.delayLoad=function(){this.delayLoadState===e.Engine.DELAYLOADSTATE_NOTLOADED&&(this.delayLoadState=e.Engine.DELAYLOADSTATE_LOADED,this._texture=this._getFromCache(this.url,!0),this._texture||this.loadTexture())},i.Parse=function(t,i,r){var n=null;return t.name&&!t.isRenderTarget&&(n=new e.ColorGradingTexture(t.name,i),n.name=t.name,n.level=t.level),n},i.prototype.serialize=function(){if(!this.name)return null;var e={};return e.name=this.name,e.level=this.level,e},i._noneEmptyLineRegex=/\S+/,i}(e.BaseTexture);e.ColorGradingTexture=t}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(e){function t(){e.call(this),this.ALBEDO=!1,this.AMBIENT=!1,this.OPACITY=!1,this.OPACITYRGB=!1,this.REFLECTION=!1,this.EMISSIVE=!1,this.REFLECTIVITY=!1,this.BUMP=!1,this.PARALLAX=!1,this.PARALLAXOCCLUSION=!1,this.SPECULAROVERALPHA=!1,this.CLIPPLANE=!1,this.ALPHATEST=!1,this.ALPHAFROMALBEDO=!1,this.POINTSIZE=!1,this.FOG=!1,this.SPECULARTERM=!1,this.OPACITYFRESNEL=!1,this.EMISSIVEFRESNEL=!1,this.FRESNEL=!1,this.NORMAL=!1,this.UV1=!1,this.UV2=!1,this.VERTEXCOLOR=!1,this.VERTEXALPHA=!1,this.NUM_BONE_INFLUENCERS=0,this.BonesPerMesh=0,this.INSTANCES=!1,this.MICROSURFACEFROMREFLECTIVITYMAP=!1,this.MICROSURFACEAUTOMATIC=!1,this.EMISSIVEASILLUMINATION=!1,this.LINKEMISSIVEWITHALBEDO=!1,this.LIGHTMAP=!1,this.USELIGHTMAPASSHADOWMAP=!1,this.REFLECTIONMAP_3D=!1,this.REFLECTIONMAP_SPHERICAL=!1,this.REFLECTIONMAP_PLANAR=!1,this.REFLECTIONMAP_CUBIC=!1,this.REFLECTIONMAP_PROJECTION=!1,this.REFLECTIONMAP_SKYBOX=!1,this.REFLECTIONMAP_EXPLICIT=!1,this.REFLECTIONMAP_EQUIRECTANGULAR=!1,this.INVERTCUBICMAP=!1,this.LOGARITHMICDEPTH=!1,this.CAMERATONEMAP=!1,this.CAMERACONTRAST=!1,this.CAMERACOLORGRADING=!1,this.CAMERACOLORCURVES=!1,this.OVERLOADEDVALUES=!1,this.OVERLOADEDSHADOWVALUES=!1,this.USESPHERICALFROMREFLECTIONMAP=!1,this.REFRACTION=!1,this.REFRACTIONMAP_3D=!1,this.LINKREFRACTIONTOTRANSPARENCY=!1,this.REFRACTIONMAPINLINEARSPACE=!1,this.LODBASEDMICROSFURACE=!1,this.USEPHYSICALLIGHTFALLOFF=!1,this.RADIANCEOVERALPHA=!1,this.USEPMREMREFLECTION=!1,this.USEPMREMREFRACTION=!1,this.OPENGLNORMALMAP=!1,this.INVERTNORMALMAPX=!1,this.INVERTNORMALMAPY=!1,this.rebuild()}return __extends(t,e),t}(e.MaterialDefines),i=function(i){function r(r,n){var o=this;i.call(this,r,n),this.directIntensity=1,this.emissiveIntensity=1,this.environmentIntensity=1,this.specularIntensity=1,this._lightingInfos=new e.Vector4(this.directIntensity,this.emissiveIntensity,this.environmentIntensity,this.specularIntensity),this.disableBumpMap=!1,this.overloadedShadowIntensity=1,this.overloadedShadeIntensity=1,this._overloadedShadowInfos=new e.Vector4(this.overloadedShadowIntensity,this.overloadedShadeIntensity,0,0),this.cameraExposure=1,this.cameraContrast=1,this.cameraColorGradingTexture=null,this._cameraColorGradingScaleOffset=new e.Vector4(1,1,0,0),this._cameraColorGradingInfos=new e.Vector4(1,1,0,0),this.cameraColorCurves=null,this._cameraInfos=new e.Vector4(1,1,0,0),this._microsurfaceTextureLods=new e.Vector2(0,0),this.overloadedAmbient=e.Color3.White(),this.overloadedAmbientIntensity=0,this.overloadedAlbedo=e.Color3.White(),this.overloadedAlbedoIntensity=0,this.overloadedReflectivity=new e.Color3(.3,.3,.3),this.overloadedReflectivityIntensity=0,this.overloadedEmissive=e.Color3.White(),this.overloadedEmissiveIntensity=0,this._overloadedIntensity=new e.Vector4(this.overloadedAmbientIntensity,this.overloadedAlbedoIntensity,this.overloadedReflectivityIntensity,this.overloadedEmissiveIntensity),this.overloadedReflection=e.Color3.White(),this.overloadedReflectionIntensity=0,this.overloadedMicroSurface=0,this.overloadedMicroSurfaceIntensity=0,this._overloadedMicroSurface=new e.Vector3(this.overloadedMicroSurface,this.overloadedMicroSurfaceIntensity,this.overloadedReflectionIntensity),this.ambientColor=new e.Color3(0,0,0),this.albedoColor=new e.Color3(1,1,1),this.reflectivityColor=new e.Color3(1,1,1),this.reflectionColor=new e.Color3(.5,.5,.5),this.emissiveColor=new e.Color3(0,0,0),this.microSurface=.9,this.indexOfRefraction=.66,this.invertRefractionY=!1,this.linkRefractionWithTransparency=!1,this.linkEmissiveWithAlbedo=!1,this.useLightmapAsShadowmap=!1,this.useEmissiveAsIllumination=!1,this.useAlphaFromAlbedoTexture=!1,this.useSpecularOverAlpha=!0,this.useMicroSurfaceFromReflectivityMapAlpha=!1,this.useAutoMicroSurfaceFromReflectivityMap=!1,this.useScalarInLinearSpace=!1,this.usePhysicalLightFalloff=!0,this.useRadianceOverAlpha=!0,this.useParallax=!1,this.useParallaxOcclusion=!1,this.parallaxScaleBias=.05,this.disableLighting=!1,this.maxSimultaneousLights=4,this.invertNormalMapX=!1,this.invertNormalMapY=!1,this._renderTargets=new e.SmartArray(16),this._worldViewProjectionMatrix=e.Matrix.Zero(),this._globalAmbientColor=new e.Color3(0,0,0),this._tempColor=new e.Color3,this._defines=new t,this._cachedDefines=new t,this._myScene=null,this._myShadowGenerator=null,this._cachedDefines.BonesPerMesh=-1,this.getRenderTargetTextures=function(){return o._renderTargets.reset(),o.reflectionTexture&&o.reflectionTexture.isRenderTarget&&o._renderTargets.push(o.reflectionTexture),o.refractionTexture&&o.refractionTexture.isRenderTarget&&o._renderTargets.push(o.refractionTexture),o._renderTargets}}return __extends(r,i),Object.defineProperty(r.prototype,"useLogarithmicDepth",{get:function(){return this._useLogarithmicDepth},set:function(e){this._useLogarithmicDepth=e&&this.getScene().getEngine().getCaps().fragmentDepthSupported},enumerable:!0,configurable:!0}),r.prototype.needAlphaBlending=function(){return this.linkRefractionWithTransparency?!1:this.alpha<1||null!=this.opacityTexture||this._shouldUseAlphaFromAlbedoTexture()||this.opacityFresnelParameters&&this.opacityFresnelParameters.isEnabled},r.prototype.needAlphaTesting=function(){return this.linkRefractionWithTransparency?!1:null!=this.albedoTexture&&this.albedoTexture.hasAlpha},r.prototype._shouldUseAlphaFromAlbedoTexture=function(){return null!=this.albedoTexture&&this.albedoTexture.hasAlpha&&this.useAlphaFromAlbedoTexture},r.prototype.getAlphaTestTexture=function(){return this.albedoTexture},r.prototype._checkCache=function(e,t,i){return t?this._defines.INSTANCES!==i?!1:!(!t._materialDefines||!t._materialDefines.isEqual(this._defines)):!0},r.prototype.convertColorToLinearSpaceToRef=function(e,t){r.convertColorToLinearSpaceToRef(e,t,this.useScalarInLinearSpace)},r.convertColorToLinearSpaceToRef=function(e,t,i){i?(t.r=e.r,t.g=e.g,t.b=e.b):e.toLinearSpaceToRef(t)},r.BindLights=function(t,i,n,o,s,a,h){for(var c=0,l=!1,u=0;u<t.lights.length;u++){var f=t.lights[u];if(f.isEnabled()&&f.canAffectMesh(i)&&(e.MaterialHelper.BindLightProperties(f,n,c),this.convertColorToLinearSpaceToRef(f.diffuse,r._scaledAlbedo,s),r._scaledAlbedo.scaleToRef(f.intensity,r._scaledAlbedo),n.setColor4("vLightDiffuse"+c,r._scaledAlbedo,h?f.radius:f.range),o.SPECULARTERM&&(this.convertColorToLinearSpaceToRef(f.specular,r._scaledReflectivity,s),r._scaledReflectivity.scaleToRef(f.intensity,r._scaledReflectivity),n.setColor3("vLightSpecular"+c,r._scaledReflectivity)),t.shadowsEnabled&&(l=e.MaterialHelper.BindLightShadow(f,t,i,c,n,l)),c++,c===a))break}},r.prototype.isReady=function(i,r){if(this.checkReadyOnlyOnce&&this._wasPreviouslyReady)return!0;var n=this.getScene();if(!this.checkReadyOnEveryCall&&this._renderId===n.getRenderId()&&this._checkCache(n,i,r))return!0;var o=n.getEngine(),s=!1,a=!1;if(this._defines.reset(),n.texturesEnabled){if(n.texturesEnabled){if(n.getEngine().getCaps().textureLOD&&(this._defines.LODBASEDMICROSFURACE=!0),
  35. this.albedoTexture&&e.StandardMaterial.DiffuseTextureEnabled){if(!this.albedoTexture.isReady())return!1;a=!0,this._defines.ALBEDO=!0}if(this.ambientTexture&&e.StandardMaterial.AmbientTextureEnabled){if(!this.ambientTexture.isReady())return!1;a=!0,this._defines.AMBIENT=!0}if(this.opacityTexture&&e.StandardMaterial.OpacityTextureEnabled){if(!this.opacityTexture.isReady())return!1;a=!0,this._defines.OPACITY=!0,this.opacityTexture.getAlphaFromRGB&&(this._defines.OPACITYRGB=!0)}if(this.reflectionTexture&&e.StandardMaterial.ReflectionTextureEnabled){if(!this.reflectionTexture.isReady())return!1;switch(s=!0,this._defines.REFLECTION=!0,this.reflectionTexture.coordinatesMode===e.Texture.INVCUBIC_MODE&&(this._defines.INVERTCUBICMAP=!0),this._defines.REFLECTIONMAP_3D=this.reflectionTexture.isCube,this.reflectionTexture.coordinatesMode){case e.Texture.CUBIC_MODE:case e.Texture.INVCUBIC_MODE:this._defines.REFLECTIONMAP_CUBIC=!0;break;case e.Texture.EXPLICIT_MODE:this._defines.REFLECTIONMAP_EXPLICIT=!0;break;case e.Texture.PLANAR_MODE:this._defines.REFLECTIONMAP_PLANAR=!0;break;case e.Texture.PROJECTION_MODE:this._defines.REFLECTIONMAP_PROJECTION=!0;break;case e.Texture.SKYBOX_MODE:this._defines.REFLECTIONMAP_SKYBOX=!0;break;case e.Texture.SPHERICAL_MODE:this._defines.REFLECTIONMAP_SPHERICAL=!0;break;case e.Texture.EQUIRECTANGULAR_MODE:this._defines.REFLECTIONMAP_EQUIRECTANGULAR=!0}this.reflectionTexture instanceof e.HDRCubeTexture&&this.reflectionTexture&&(this._defines.USESPHERICALFROMREFLECTIONMAP=!0,s=!0,this.reflectionTexture.isPMREM&&(this._defines.USEPMREMREFLECTION=!0))}if(this.lightmapTexture&&e.StandardMaterial.LightmapTextureEnabled){if(!this.lightmapTexture.isReady())return!1;a=!0,this._defines.LIGHTMAP=!0,this._defines.USELIGHTMAPASSHADOWMAP=this.useLightmapAsShadowmap}if(this.emissiveTexture&&e.StandardMaterial.EmissiveTextureEnabled){if(!this.emissiveTexture.isReady())return!1;a=!0,this._defines.EMISSIVE=!0}if(this.reflectivityTexture&&e.StandardMaterial.SpecularTextureEnabled){if(!this.reflectivityTexture.isReady())return!1;a=!0,this._defines.REFLECTIVITY=!0,this._defines.MICROSURFACEFROMREFLECTIVITYMAP=this.useMicroSurfaceFromReflectivityMapAlpha,this._defines.MICROSURFACEAUTOMATIC=this.useAutoMicroSurfaceFromReflectivityMap}}if(n.getEngine().getCaps().standardDerivatives&&this.bumpTexture&&e.StandardMaterial.BumpTextureEnabled&&!this.disableBumpMap){if(!this.bumpTexture.isReady())return!1;a=!0,this._defines.BUMP=!0,this.useParallax&&(this._defines.PARALLAX=!0,this.useParallaxOcclusion&&(this._defines.PARALLAXOCCLUSION=!0)),this.invertNormalMapX&&(this._defines.INVERTNORMALMAPX=!0),this.invertNormalMapY&&(this._defines.INVERTNORMALMAPY=!0)}if(this.refractionTexture&&e.StandardMaterial.RefractionTextureEnabled){if(!this.refractionTexture.isReady())return!1;a=!0,this._defines.REFRACTION=!0,this._defines.REFRACTIONMAP_3D=this.refractionTexture.isCube,this.linkRefractionWithTransparency&&(this._defines.LINKREFRACTIONTOTRANSPARENCY=!0),this.refractionTexture instanceof e.HDRCubeTexture&&(this._defines.REFRACTIONMAPINLINEARSPACE=!0,this.refractionTexture.isPMREM&&(this._defines.USEPMREMREFRACTION=!0))}if(this.cameraColorGradingTexture){if(!this.cameraColorGradingTexture.isReady())return!1;this._defines.CAMERACOLORGRADING=!0}}if(n.clipPlane&&(this._defines.CLIPPLANE=!0),o.getAlphaTesting()&&(this._defines.ALPHATEST=!0),this._shouldUseAlphaFromAlbedoTexture()&&(this._defines.ALPHAFROMALBEDO=!0),this.useEmissiveAsIllumination&&(this._defines.EMISSIVEASILLUMINATION=!0),this.linkEmissiveWithAlbedo&&(this._defines.LINKEMISSIVEWITHALBEDO=!0),this.useLogarithmicDepth&&(this._defines.LOGARITHMICDEPTH=!0),1!=this.cameraContrast&&(this._defines.CAMERACONTRAST=!0),1!=this.cameraExposure&&(this._defines.CAMERATONEMAP=!0),this.cameraColorCurves&&(this._defines.CAMERACOLORCURVES=!0),1==this.overloadedShadeIntensity&&1==this.overloadedShadowIntensity||(this._defines.OVERLOADEDSHADOWVALUES=!0),(this.overloadedMicroSurfaceIntensity>0||this.overloadedEmissiveIntensity>0||this.overloadedReflectivityIntensity>0||this.overloadedAlbedoIntensity>0||this.overloadedAmbientIntensity>0||this.overloadedReflectionIntensity>0)&&(this._defines.OVERLOADEDVALUES=!0),(this.pointsCloud||n.forcePointsCloud)&&(this._defines.POINTSIZE=!0),n.fogEnabled&&i&&i.applyFog&&n.fogMode!==e.Scene.FOGMODE_NONE&&this.fogEnabled&&(this._defines.FOG=!0),n.lightsEnabled&&!this.disableLighting&&(s=e.MaterialHelper.PrepareDefinesForLights(n,i,this._defines,this.maxSimultaneousLights)||s),e.StandardMaterial.FresnelEnabled&&(this.opacityFresnelParameters&&this.opacityFresnelParameters.isEnabled||this.emissiveFresnelParameters&&this.emissiveFresnelParameters.isEnabled)&&(this.opacityFresnelParameters&&this.opacityFresnelParameters.isEnabled&&(this._defines.OPACITYFRESNEL=!0),this.emissiveFresnelParameters&&this.emissiveFresnelParameters.isEnabled&&(this._defines.EMISSIVEFRESNEL=!0),s=!0,this._defines.FRESNEL=!0),this._defines.SPECULARTERM&&this.useSpecularOverAlpha&&(this._defines.SPECULAROVERALPHA=!0),this.usePhysicalLightFalloff&&(this._defines.USEPHYSICALLIGHTFALLOFF=!0),this.useRadianceOverAlpha&&(this._defines.RADIANCEOVERALPHA=!0),i&&(s&&i.isVerticesDataPresent(e.VertexBuffer.NormalKind)&&(this._defines.NORMAL=!0),a&&(i.isVerticesDataPresent(e.VertexBuffer.UVKind)&&(this._defines.UV1=!0),i.isVerticesDataPresent(e.VertexBuffer.UV2Kind)&&(this._defines.UV2=!0)),i.useVertexColors&&i.isVerticesDataPresent(e.VertexBuffer.ColorKind)&&(this._defines.VERTEXCOLOR=!0,i.hasVertexAlpha&&(this._defines.VERTEXALPHA=!0)),i.useBones&&i.computeBonesUsingShaders&&(this._defines.NUM_BONE_INFLUENCERS=i.numBoneInfluencers,this._defines.BonesPerMesh=i.skeleton.bones.length+1),r&&(this._defines.INSTANCES=!0)),!this._defines.isEqual(this._cachedDefines)){this._defines.cloneTo(this._cachedDefines),n.resetCachedMaterial();var h=new e.EffectFallbacks;this._defines.REFLECTION&&h.addFallback(0,"REFLECTION"),this._defines.REFRACTION&&h.addFallback(0,"REFRACTION"),this._defines.REFLECTIVITY&&h.addFallback(0,"REFLECTIVITY"),this._defines.BUMP&&h.addFallback(0,"BUMP"),this._defines.PARALLAX&&h.addFallback(1,"PARALLAX"),this._defines.PARALLAXOCCLUSION&&h.addFallback(0,"PARALLAXOCCLUSION"),this._defines.SPECULAROVERALPHA&&h.addFallback(0,"SPECULAROVERALPHA"),this._defines.FOG&&h.addFallback(1,"FOG"),this._defines.POINTSIZE&&h.addFallback(0,"POINTSIZE"),this._defines.LOGARITHMICDEPTH&&h.addFallback(0,"LOGARITHMICDEPTH"),e.MaterialHelper.HandleFallbacksForShadows(this._defines,h,this.maxSimultaneousLights),this._defines.SPECULARTERM&&h.addFallback(0,"SPECULARTERM"),this._defines.OPACITYFRESNEL&&h.addFallback(1,"OPACITYFRESNEL"),this._defines.EMISSIVEFRESNEL&&h.addFallback(2,"EMISSIVEFRESNEL"),this._defines.FRESNEL&&h.addFallback(3,"FRESNEL"),this._defines.NUM_BONE_INFLUENCERS>0&&h.addCPUSkinningFallback(0,i);var c=[e.VertexBuffer.PositionKind];this._defines.NORMAL&&c.push(e.VertexBuffer.NormalKind),this._defines.UV1&&c.push(e.VertexBuffer.UVKind),this._defines.UV2&&c.push(e.VertexBuffer.UV2Kind),this._defines.VERTEXCOLOR&&c.push(e.VertexBuffer.ColorKind),e.MaterialHelper.PrepareAttributesForBones(c,i,this._defines,h),e.MaterialHelper.PrepareAttributesForInstances(c,this._defines);var l="pbr";n.getEngine().getCaps().standardDerivatives||(l="legacypbr");var u=this._defines.toString(),f=["world","view","viewProjection","vEyePosition","vLightsType","vAmbientColor","vAlbedoColor","vReflectivityColor","vEmissiveColor","vReflectionColor","vFogInfos","vFogColor","pointSize","vAlbedoInfos","vAmbientInfos","vOpacityInfos","vReflectionInfos","vEmissiveInfos","vReflectivityInfos","vBumpInfos","vLightmapInfos","vRefractionInfos","mBones","vClipPlane","albedoMatrix","ambientMatrix","opacityMatrix","reflectionMatrix","emissiveMatrix","reflectivityMatrix","bumpMatrix","lightmapMatrix","refractionMatrix","depthValues","opacityParts","emissiveLeftColor","emissiveRightColor","vLightingIntensity","vOverloadedShadowIntensity","vOverloadedIntensity","vOverloadedAlbedo","vOverloadedReflection","vOverloadedReflectivity","vOverloadedEmissive","vOverloadedMicroSurface","logarithmicDepthConstant","vSphericalX","vSphericalY","vSphericalZ","vSphericalXX","vSphericalYY","vSphericalZZ","vSphericalXY","vSphericalYZ","vSphericalZX","vMicrosurfaceTextureLods","vCameraInfos","vCameraColorGradingInfos","vCameraColorGradingScaleOffset"],d=["albedoSampler","ambientSampler","opacitySampler","reflectionCubeSampler","reflection2DSampler","emissiveSampler","reflectivitySampler","bumpSampler","lightmapSampler","refractionCubeSampler","refraction2DSampler","cameraColorGrading2DSampler"];e.ColorCurves.PrepareUniforms(f),e.MaterialHelper.PrepareUniformsAndSamplersList(f,d,this._defines,this.maxSimultaneousLights),this._effect=n.getEngine().createEffect(l,c,f,d,u,h,this.onCompiled,this.onError,{maxSimultaneousLights:this.maxSimultaneousLights})}return this._effect.isReady()?(this._renderId=n.getRenderId(),this._wasPreviouslyReady=!0,i&&(i._materialDefines||(i._materialDefines=new t),this._defines.cloneTo(i._materialDefines)),!0):!1},r.prototype.unbind=function(){this.reflectionTexture&&this.reflectionTexture.isRenderTarget&&this._effect.setTexture("reflection2DSampler",null),this.refractionTexture&&this.refractionTexture.isRenderTarget&&this._effect.setTexture("refraction2DSampler",null),i.prototype.unbind.call(this)},r.prototype.bindOnlyWorldMatrix=function(e){this._effect.setMatrix("world",e)},r.prototype.bind=function(t,n){if(this._myScene=this.getScene(),this.bindOnlyWorldMatrix(t),e.MaterialHelper.BindBonesParameters(n,this._effect),this._myScene.getCachedMaterial()!==this){if(this._effect.setMatrix("viewProjection",this._myScene.getTransformMatrix()),e.StandardMaterial.FresnelEnabled&&(this.opacityFresnelParameters&&this.opacityFresnelParameters.isEnabled&&this._effect.setColor4("opacityParts",new e.Color3(this.opacityFresnelParameters.leftColor.toLuminance(),this.opacityFresnelParameters.rightColor.toLuminance(),this.opacityFresnelParameters.bias),this.opacityFresnelParameters.power),this.emissiveFresnelParameters&&this.emissiveFresnelParameters.isEnabled&&(this._effect.setColor4("emissiveLeftColor",this.emissiveFresnelParameters.leftColor,this.emissiveFresnelParameters.power),this._effect.setColor4("emissiveRightColor",this.emissiveFresnelParameters.rightColor,this.emissiveFresnelParameters.bias))),this._myScene.texturesEnabled){if(this.albedoTexture&&e.StandardMaterial.DiffuseTextureEnabled&&(this._effect.setTexture("albedoSampler",this.albedoTexture),this._effect.setFloat2("vAlbedoInfos",this.albedoTexture.coordinatesIndex,this.albedoTexture.level),this._effect.setMatrix("albedoMatrix",this.albedoTexture.getTextureMatrix())),this.ambientTexture&&e.StandardMaterial.AmbientTextureEnabled&&(this._effect.setTexture("ambientSampler",this.ambientTexture),this._effect.setFloat2("vAmbientInfos",this.ambientTexture.coordinatesIndex,this.ambientTexture.level),this._effect.setMatrix("ambientMatrix",this.ambientTexture.getTextureMatrix())),this.opacityTexture&&e.StandardMaterial.OpacityTextureEnabled&&(this._effect.setTexture("opacitySampler",this.opacityTexture),this._effect.setFloat2("vOpacityInfos",this.opacityTexture.coordinatesIndex,this.opacityTexture.level),this._effect.setMatrix("opacityMatrix",this.opacityTexture.getTextureMatrix())),this.reflectionTexture&&e.StandardMaterial.ReflectionTextureEnabled&&(this._microsurfaceTextureLods.x=Math.round(Math.log(this.reflectionTexture.getSize().width)*Math.LOG2E),this.reflectionTexture.isCube?this._effect.setTexture("reflectionCubeSampler",this.reflectionTexture):this._effect.setTexture("reflection2DSampler",this.reflectionTexture),this._effect.setMatrix("reflectionMatrix",this.reflectionTexture.getReflectionTextureMatrix()),this._effect.setFloat2("vReflectionInfos",this.reflectionTexture.level,0),this._defines.USESPHERICALFROMREFLECTIONMAP&&(this._effect.setFloat3("vSphericalX",this.reflectionTexture.sphericalPolynomial.x.x,this.reflectionTexture.sphericalPolynomial.x.y,this.reflectionTexture.sphericalPolynomial.x.z),this._effect.setFloat3("vSphericalY",this.reflectionTexture.sphericalPolynomial.y.x,this.reflectionTexture.sphericalPolynomial.y.y,this.reflectionTexture.sphericalPolynomial.y.z),this._effect.setFloat3("vSphericalZ",this.reflectionTexture.sphericalPolynomial.z.x,this.reflectionTexture.sphericalPolynomial.z.y,this.reflectionTexture.sphericalPolynomial.z.z),this._effect.setFloat3("vSphericalXX",this.reflectionTexture.sphericalPolynomial.xx.x,this.reflectionTexture.sphericalPolynomial.xx.y,this.reflectionTexture.sphericalPolynomial.xx.z),this._effect.setFloat3("vSphericalYY",this.reflectionTexture.sphericalPolynomial.yy.x,this.reflectionTexture.sphericalPolynomial.yy.y,this.reflectionTexture.sphericalPolynomial.yy.z),this._effect.setFloat3("vSphericalZZ",this.reflectionTexture.sphericalPolynomial.zz.x,this.reflectionTexture.sphericalPolynomial.zz.y,this.reflectionTexture.sphericalPolynomial.zz.z),this._effect.setFloat3("vSphericalXY",this.reflectionTexture.sphericalPolynomial.xy.x,this.reflectionTexture.sphericalPolynomial.xy.y,this.reflectionTexture.sphericalPolynomial.xy.z),this._effect.setFloat3("vSphericalYZ",this.reflectionTexture.sphericalPolynomial.yz.x,this.reflectionTexture.sphericalPolynomial.yz.y,this.reflectionTexture.sphericalPolynomial.yz.z),this._effect.setFloat3("vSphericalZX",this.reflectionTexture.sphericalPolynomial.zx.x,this.reflectionTexture.sphericalPolynomial.zx.y,this.reflectionTexture.sphericalPolynomial.zx.z))),this.emissiveTexture&&e.StandardMaterial.EmissiveTextureEnabled&&(this._effect.setTexture("emissiveSampler",this.emissiveTexture),this._effect.setFloat2("vEmissiveInfos",this.emissiveTexture.coordinatesIndex,this.emissiveTexture.level),this._effect.setMatrix("emissiveMatrix",this.emissiveTexture.getTextureMatrix())),this.lightmapTexture&&e.StandardMaterial.LightmapTextureEnabled&&(this._effect.setTexture("lightmapSampler",this.lightmapTexture),this._effect.setFloat2("vLightmapInfos",this.lightmapTexture.coordinatesIndex,this.lightmapTexture.level),this._effect.setMatrix("lightmapMatrix",this.lightmapTexture.getTextureMatrix())),this.reflectivityTexture&&e.StandardMaterial.SpecularTextureEnabled&&(this._effect.setTexture("reflectivitySampler",this.reflectivityTexture),this._effect.setFloat2("vReflectivityInfos",this.reflectivityTexture.coordinatesIndex,this.reflectivityTexture.level),this._effect.setMatrix("reflectivityMatrix",this.reflectivityTexture.getTextureMatrix())),this.bumpTexture&&this._myScene.getEngine().getCaps().standardDerivatives&&e.StandardMaterial.BumpTextureEnabled&&!this.disableBumpMap&&(this._effect.setTexture("bumpSampler",this.bumpTexture),this._effect.setFloat3("vBumpInfos",this.bumpTexture.coordinatesIndex,1/this.bumpTexture.level,this.parallaxScaleBias),this._effect.setMatrix("bumpMatrix",this.bumpTexture.getTextureMatrix())),this.refractionTexture&&e.StandardMaterial.RefractionTextureEnabled){this._microsurfaceTextureLods.y=Math.round(Math.log(this.refractionTexture.getSize().width)*Math.LOG2E);var o=1;this.refractionTexture.isCube?this._effect.setTexture("refractionCubeSampler",this.refractionTexture):(this._effect.setTexture("refraction2DSampler",this.refractionTexture),this._effect.setMatrix("refractionMatrix",this.refractionTexture.getReflectionTextureMatrix()),this.refractionTexture.depth&&(o=this.refractionTexture.depth)),this._effect.setFloat4("vRefractionInfos",this.refractionTexture.level,this.indexOfRefraction,o,this.invertRefractionY?-1:1)}if((this.reflectionTexture||this.refractionTexture)&&this._effect.setFloat2("vMicrosurfaceTextureLods",this._microsurfaceTextureLods.x,this._microsurfaceTextureLods.y),this.cameraColorGradingTexture){this._effect.setTexture("cameraColorGrading2DSampler",this.cameraColorGradingTexture),this._cameraColorGradingInfos.x=this.cameraColorGradingTexture.level,this._cameraColorGradingInfos.y=this.cameraColorGradingTexture.getSize().height,this._cameraColorGradingInfos.z=this._cameraColorGradingInfos.y-1,this._cameraColorGradingInfos.w=1/this._cameraColorGradingInfos.y,this._effect.setFloat4("vCameraColorGradingInfos",this._cameraColorGradingInfos.x,this._cameraColorGradingInfos.y,this._cameraColorGradingInfos.z,this._cameraColorGradingInfos.w);var s=this._cameraColorGradingInfos.w/this._cameraColorGradingInfos.y,a=1/this._cameraColorGradingInfos.y;this._cameraColorGradingScaleOffset.x=this._cameraColorGradingInfos.z*s,this._cameraColorGradingScaleOffset.y=this._cameraColorGradingInfos.z/this._cameraColorGradingInfos.y,this._cameraColorGradingScaleOffset.z=.5*s,this._cameraColorGradingScaleOffset.w=.5*a,this._effect.setFloat4("vCameraColorGradingScaleOffset",this._cameraColorGradingScaleOffset.x,this._cameraColorGradingScaleOffset.y,this._cameraColorGradingScaleOffset.z,this._cameraColorGradingScaleOffset.w)}}e.MaterialHelper.BindClipPlane(this._effect,this._myScene),this.pointsCloud&&this._effect.setFloat("pointSize",this.pointSize),this._myScene.ambientColor.multiplyToRef(this.ambientColor,this._globalAmbientColor),this.convertColorToLinearSpaceToRef(this.reflectivityColor,r._scaledReflectivity),this._effect.setVector3("vEyePosition",this._myScene._mirroredCameraPosition?this._myScene._mirroredCameraPosition:this._myScene.activeCamera.position),this._effect.setColor3("vAmbientColor",this._globalAmbientColor),this._effect.setColor4("vReflectivityColor",r._scaledReflectivity,this.microSurface),this.convertColorToLinearSpaceToRef(this.emissiveColor,r._scaledEmissive),this._effect.setColor3("vEmissiveColor",r._scaledEmissive),this.convertColorToLinearSpaceToRef(this.reflectionColor,r._scaledReflection),this._effect.setColor3("vReflectionColor",r._scaledReflection)}this._myScene.getCachedMaterial()===this&&this.isFrozen||(this.convertColorToLinearSpaceToRef(this.albedoColor,r._scaledAlbedo),this._effect.setColor4("vAlbedoColor",r._scaledAlbedo,this.alpha*n.visibility),this._myScene.lightsEnabled&&!this.disableLighting&&r.BindLights(this._myScene,n,this._effect,this._defines,this.useScalarInLinearSpace,this.maxSimultaneousLights,this.usePhysicalLightFalloff),(this._myScene.fogEnabled&&n.applyFog&&this._myScene.fogMode!==e.Scene.FOGMODE_NONE||this.reflectionTexture)&&this._effect.setMatrix("view",this._myScene.getViewMatrix()),e.MaterialHelper.BindFogParameters(this._myScene,n,this._effect),this._lightingInfos.x=this.directIntensity,this._lightingInfos.y=this.emissiveIntensity,this._lightingInfos.z=this.environmentIntensity,this._lightingInfos.w=this.specularIntensity,this._effect.setVector4("vLightingIntensity",this._lightingInfos),this._overloadedShadowInfos.x=this.overloadedShadowIntensity,this._overloadedShadowInfos.y=this.overloadedShadeIntensity,this._effect.setVector4("vOverloadedShadowIntensity",this._overloadedShadowInfos),this._cameraInfos.x=this.cameraExposure,this._cameraInfos.y=this.cameraContrast,this._effect.setVector4("vCameraInfos",this._cameraInfos),this.cameraColorCurves&&e.ColorCurves.Bind(this.cameraColorCurves,this._effect),this._overloadedIntensity.x=this.overloadedAmbientIntensity,this._overloadedIntensity.y=this.overloadedAlbedoIntensity,this._overloadedIntensity.z=this.overloadedReflectivityIntensity,this._overloadedIntensity.w=this.overloadedEmissiveIntensity,this._effect.setVector4("vOverloadedIntensity",this._overloadedIntensity),this.convertColorToLinearSpaceToRef(this.overloadedAmbient,this._tempColor),this._effect.setColor3("vOverloadedAmbient",this._tempColor),this.convertColorToLinearSpaceToRef(this.overloadedAlbedo,this._tempColor),this._effect.setColor3("vOverloadedAlbedo",this._tempColor),this.convertColorToLinearSpaceToRef(this.overloadedReflectivity,this._tempColor),this._effect.setColor3("vOverloadedReflectivity",this._tempColor),this.convertColorToLinearSpaceToRef(this.overloadedEmissive,this._tempColor),this._effect.setColor3("vOverloadedEmissive",this._tempColor),this.convertColorToLinearSpaceToRef(this.overloadedReflection,this._tempColor),this._effect.setColor3("vOverloadedReflection",this._tempColor),this._overloadedMicroSurface.x=this.overloadedMicroSurface,this._overloadedMicroSurface.y=this.overloadedMicroSurfaceIntensity,this._overloadedMicroSurface.z=this.overloadedReflectionIntensity,this._effect.setVector3("vOverloadedMicroSurface",this._overloadedMicroSurface),e.MaterialHelper.BindLogDepth(this._defines,this._effect,this._myScene)),i.prototype.bind.call(this,t,n),this._myScene=null},r.prototype.getAnimatables=function(){var e=[];return this.albedoTexture&&this.albedoTexture.animations&&this.albedoTexture.animations.length>0&&e.push(this.albedoTexture),this.ambientTexture&&this.ambientTexture.animations&&this.ambientTexture.animations.length>0&&e.push(this.ambientTexture),this.opacityTexture&&this.opacityTexture.animations&&this.opacityTexture.animations.length>0&&e.push(this.opacityTexture),this.reflectionTexture&&this.reflectionTexture.animations&&this.reflectionTexture.animations.length>0&&e.push(this.reflectionTexture),this.emissiveTexture&&this.emissiveTexture.animations&&this.emissiveTexture.animations.length>0&&e.push(this.emissiveTexture),this.reflectivityTexture&&this.reflectivityTexture.animations&&this.reflectivityTexture.animations.length>0&&e.push(this.reflectivityTexture),this.bumpTexture&&this.bumpTexture.animations&&this.bumpTexture.animations.length>0&&e.push(this.bumpTexture),this.lightmapTexture&&this.lightmapTexture.animations&&this.lightmapTexture.animations.length>0&&e.push(this.lightmapTexture),this.refractionTexture&&this.refractionTexture.animations&&this.refractionTexture.animations.length>0&&e.push(this.refractionTexture),this.cameraColorGradingTexture&&this.cameraColorGradingTexture.animations&&this.cameraColorGradingTexture.animations.length>0&&e.push(this.cameraColorGradingTexture),e},r.prototype.dispose=function(e,t){t&&(this.albedoTexture&&this.albedoTexture.dispose(),this.ambientTexture&&this.ambientTexture.dispose(),this.opacityTexture&&this.opacityTexture.dispose(),this.reflectionTexture&&this.reflectionTexture.dispose(),this.emissiveTexture&&this.emissiveTexture.dispose(),this.reflectivityTexture&&this.reflectivityTexture.dispose(),this.bumpTexture&&this.bumpTexture.dispose(),this.lightmapTexture&&this.lightmapTexture.dispose(),this.refractionTexture&&this.refractionTexture.dispose(),this.cameraColorGradingTexture&&this.cameraColorGradingTexture.dispose()),i.prototype.dispose.call(this,e,t)},r.prototype.clone=function(t){var i=this;return e.SerializationHelper.Clone(function(){return new r(t,i.getScene())},this)},r.prototype.serialize=function(){var t=e.SerializationHelper.Serialize(this);return t.customType="BABYLON.PBRMaterial",t},r.Parse=function(t,i,n){return e.SerializationHelper.Parse(function(){return new r(t.name,i)},t,i,n)},r._scaledAlbedo=new e.Color3,r._scaledReflectivity=new e.Color3,r._scaledEmissive=new e.Color3,r._scaledReflection=new e.Color3,__decorate([e.serialize()],r.prototype,"directIntensity",void 0),__decorate([e.serialize()],r.prototype,"emissiveIntensity",void 0),__decorate([e.serialize()],r.prototype,"environmentIntensity",void 0),__decorate([e.serialize()],r.prototype,"specularIntensity",void 0),__decorate([e.serialize()],r.prototype,"disableBumpMap",void 0),__decorate([e.serialize()],r.prototype,"overloadedShadowIntensity",void 0),__decorate([e.serialize()],r.prototype,"overloadedShadeIntensity",void 0),__decorate([e.serialize()],r.prototype,"cameraExposure",void 0),__decorate([e.serialize()],r.prototype,"cameraContrast",void 0),__decorate([e.serializeAsTexture()],r.prototype,"cameraColorGradingTexture",void 0),__decorate([e.serializeAsColorCurves()],r.prototype,"cameraColorCurves",void 0),__decorate([e.serializeAsColor3()],r.prototype,"overloadedAmbient",void 0),__decorate([e.serialize()],r.prototype,"overloadedAmbientIntensity",void 0),__decorate([e.serializeAsColor3()],r.prototype,"overloadedAlbedo",void 0),__decorate([e.serialize()],r.prototype,"overloadedAlbedoIntensity",void 0),__decorate([e.serializeAsColor3()],r.prototype,"overloadedReflectivity",void 0),__decorate([e.serialize()],r.prototype,"overloadedReflectivityIntensity",void 0),__decorate([e.serializeAsColor3()],r.prototype,"overloadedEmissive",void 0),__decorate([e.serialize()],r.prototype,"overloadedEmissiveIntensity",void 0),__decorate([e.serializeAsColor3()],r.prototype,"overloadedReflection",void 0),__decorate([e.serialize()],r.prototype,"overloadedReflectionIntensity",void 0),__decorate([e.serialize()],r.prototype,"overloadedMicroSurface",void 0),__decorate([e.serialize()],r.prototype,"overloadedMicroSurfaceIntensity",void 0),__decorate([e.serializeAsTexture()],r.prototype,"albedoTexture",void 0),__decorate([e.serializeAsTexture()],r.prototype,"ambientTexture",void 0),__decorate([e.serializeAsTexture()],r.prototype,"opacityTexture",void 0),__decorate([e.serializeAsTexture()],r.prototype,"reflectionTexture",void 0),__decorate([e.serializeAsTexture()],r.prototype,"emissiveTexture",void 0),__decorate([e.serializeAsTexture()],r.prototype,"reflectivityTexture",void 0),__decorate([e.serializeAsTexture()],r.prototype,"bumpTexture",void 0),__decorate([e.serializeAsTexture()],r.prototype,"lightmapTexture",void 0),__decorate([e.serializeAsTexture()],r.prototype,"refractionTexture",void 0),__decorate([e.serializeAsColor3("ambient")],r.prototype,"ambientColor",void 0),__decorate([e.serializeAsColor3("albedo")],r.prototype,"albedoColor",void 0),__decorate([e.serializeAsColor3("reflectivity")],r.prototype,"reflectivityColor",void 0),__decorate([e.serializeAsColor3("reflection")],r.prototype,"reflectionColor",void 0),__decorate([e.serializeAsColor3("emissive")],r.prototype,"emissiveColor",void 0),__decorate([e.serialize()],r.prototype,"microSurface",void 0),__decorate([e.serialize()],r.prototype,"indexOfRefraction",void 0),__decorate([e.serialize()],r.prototype,"invertRefractionY",void 0),__decorate([e.serializeAsFresnelParameters()],r.prototype,"opacityFresnelParameters",void 0),__decorate([e.serializeAsFresnelParameters()],r.prototype,"emissiveFresnelParameters",void 0),__decorate([e.serialize()],r.prototype,"linkRefractionWithTransparency",void 0),__decorate([e.serialize()],r.prototype,"linkEmissiveWithAlbedo",void 0),__decorate([e.serialize()],r.prototype,"useLightmapAsShadowmap",void 0),__decorate([e.serialize()],r.prototype,"useEmissiveAsIllumination",void 0),__decorate([e.serialize()],r.prototype,"useAlphaFromAlbedoTexture",void 0),__decorate([e.serialize()],r.prototype,"useSpecularOverAlpha",void 0),__decorate([e.serialize()],r.prototype,"useMicroSurfaceFromReflectivityMapAlpha",void 0),__decorate([e.serialize()],r.prototype,"useAutoMicroSurfaceFromReflectivityMap",void 0),__decorate([e.serialize()],r.prototype,"useScalarInLinearSpace",void 0),__decorate([e.serialize()],r.prototype,"usePhysicalLightFalloff",void 0),__decorate([e.serialize()],r.prototype,"useRadianceOverAlpha",void 0),__decorate([e.serialize()],r.prototype,"useParallax",void 0),__decorate([e.serialize()],r.prototype,"useParallaxOcclusion",void 0),__decorate([e.serialize()],r.prototype,"parallaxScaleBias",void 0),__decorate([e.serialize()],r.prototype,"disableLighting",void 0),__decorate([e.serialize()],r.prototype,"maxSimultaneousLights",void 0),__decorate([e.serialize()],r.prototype,"invertNormalMapX",void 0),__decorate([e.serialize()],r.prototype,"invertNormalMapY",void 0),__decorate([e.serialize()],r.prototype,"useLogarithmicDepth",null),r}(e.Material);e.PBRMaterial=i}(BABYLON||(BABYLON={}));var BABYLON;!function(e){var t=function(){function t(t){var i=this;this._transformationMatrix=e.Matrix.Identity(),this._enabled=!1,this._labelsEnabled=!1,this._displayStatistics=!0,this._displayTree=!1,this._displayLogs=!1,this._skeletonViewers=new Array,this._identityMatrix=e.Matrix.Identity(),this.axisRatio=.02,this.accentColor="orange",this._scene=t,this._syncPositions=function(){var e=i._scene.getEngine(),t=e.getRenderingCanvasClientRect();i._showUI&&(i._statsDiv.style.left=t.width-410+"px",i._statsDiv.style.top=t.height-290+"px",i._statsDiv.style.width="400px",i._statsDiv.style.height="auto",i._statsSubsetDiv.style.maxHeight="240px",i._optionsDiv.style.left="0px",i._optionsDiv.style.top="10px",i._optionsDiv.style.width="200px",i._optionsDiv.style.height="auto",i._optionsSubsetDiv.style.maxHeight=t.height-225+"px",i._logDiv.style.left="0px",i._logDiv.style.top=t.height-170+"px",i._logDiv.style.width="600px",i._logDiv.style.height="160px",i._treeDiv.style.left=t.width-310+"px",i._treeDiv.style.top="10px",i._treeDiv.style.width="300px",i._treeDiv.style.height="auto",i._treeSubsetDiv.style.maxHeight=t.height-340+"px"),i._globalDiv.style.left=t.left+"px",i._globalDiv.style.top=t.top+"px",i._drawingCanvas.style.left="0px",i._drawingCanvas.style.top="0px",i._drawingCanvas.style.width=e.getRenderWidth()+"px",i._drawingCanvas.style.height=e.getRenderHeight()+"px";var r=window.devicePixelRatio||1,n=i._drawingContext,o=n.webkitBackingStorePixelRatio||n.mozBackingStorePixelRatio||n.msBackingStorePixelRatio||n.oBackingStorePixelRatio||n.backingStorePixelRatio||1;i._ratio=r/o,i._drawingCanvas.width=e.getRenderWidth()*i._ratio,i._drawingCanvas.height=e.getRenderHeight()*i._ratio},this._onCanvasClick=function(e){i._clickPosition={x:e.clientX*i._ratio,y:e.clientY*i._ratio}},this._syncUI=function(){i._showUI&&(i._displayStatistics?(i._displayStats(),i._statsDiv.style.display=""):i._statsDiv.style.display="none",i._displayLogs?i._logDiv.style.display="":i._logDiv.style.display="none",i._displayTree?(i._treeDiv.style.display="",i._needToRefreshMeshesTree&&(i._needToRefreshMeshesTree=!1,i._refreshMeshesTreeContent())):i._treeDiv.style.display="none")},this._syncData=function(){if(i._labelsEnabled||!i._showUI){i._camera.getViewMatrix().multiplyToRef(i._camera.getProjectionMatrix(),i._transformationMatrix),i._drawingContext.clearRect(0,0,i._drawingCanvas.width,i._drawingCanvas.height);var t,r,n=i._scene.getEngine(),o=i._camera.viewport,s=o.toGlobal(n.getRenderWidth(),n.getRenderHeight()),a=i._camera.getActiveMeshes();for(t=0;t<a.length;t++){var h=a.data[t],c=h.getBoundingInfo().boundingSphere.center;r=e.Vector3.Project(c,h.getWorldMatrix(),i._transformationMatrix,s),(h.renderOverlay||i.shouldDisplayAxis&&i.shouldDisplayAxis(h))&&i._renderAxis(r,h,s),i.shouldDisplayLabel&&!i.shouldDisplayLabel(h)||i._renderLabel(h.name,r,12,function(){h.renderOverlay=!h.renderOverlay},function(){return h.renderOverlay?"red":"black"})}var l=i._scene.cameras;for(t=0;t<l.length;t++){var u=l[t];u!==i._camera&&(r=e.Vector3.Project(e.Vector3.Zero(),u.getWorldMatrix(),i._transformationMatrix,s),i.shouldDisplayLabel&&!i.shouldDisplayLabel(u)||i._renderLabel(u.name,r,12,function(){i._camera.detachControl(n.getRenderingCanvas()),i._camera=u,i._camera.attachControl(n.getRenderingCanvas())},function(){return"purple"}))}var f=i._scene.lights;for(t=0;t<f.length;t++){var d=f[t];d.position&&(r=e.Vector3.Project(d.getAbsolutePosition(),i._identityMatrix,i._transformationMatrix,s),i.shouldDisplayLabel&&!i.shouldDisplayLabel(d)||i._renderLabel(d.name,r,-20,function(){d.setEnabled(!d.isEnabled())},function(){return d.isEnabled()?"orange":"gray"}))}}i._clickPosition=void 0}}return t.prototype._refreshMeshesTreeContent=function(){for(;this._treeSubsetDiv.hasChildNodes();)this._treeSubsetDiv.removeChild(this._treeSubsetDiv.lastChild);var e=this._scene.meshes.slice(0,this._scene.meshes.length);e.sort(function(e,t){return e.name===t.name?0:e.name>t.name?1:-1});for(var t=0;t<e.length;t++){var i=e[t];i.isEnabled()&&this._generateAdvancedCheckBox(this._treeSubsetDiv,i.name,i.getTotalVertices()+" verts",i.isVisible,function(e,t){t.isVisible=e.checked},i)}},t.prototype._renderSingleAxis=function(e,t,i,r,n){this._drawingContext.beginPath(),this._drawingContext.moveTo(e.x,e.y),this._drawingContext.lineTo(t.x,t.y),this._drawingContext.strokeStyle=n,this._drawingContext.lineWidth=4,this._drawingContext.stroke(),this._drawingContext.font="normal 14px Segoe UI",this._drawingContext.fillStyle=n,this._drawingContext.fillText(r,i.x,i.y);
  36. },t.prototype._renderAxis=function(t,i,r){var n=i.getBoundingInfo().boundingSphere.center,o=i.getWorldMatrix(),s=e.Vector3.UnprojectFromTransform(t.add(new e.Vector3(this._drawingCanvas.width*this.axisRatio,0,0)),r.width,r.height,o,this._transformationMatrix),a=s.subtract(n).length(),h=e.Vector3.Project(n.add(new e.Vector3(a,0,0)),o,this._transformationMatrix,r),c=e.Vector3.Project(n.add(new e.Vector3(1.5*a,0,0)),o,this._transformationMatrix,r);this._renderSingleAxis(t,h,c,"x","#FF0000");var l=e.Vector3.Project(n.add(new e.Vector3(0,a,0)),o,this._transformationMatrix,r),u=e.Vector3.Project(n.add(new e.Vector3(0,1.5*a,0)),o,this._transformationMatrix,r);this._renderSingleAxis(t,l,u,"y","#00FF00");var f=e.Vector3.Project(n.add(new e.Vector3(0,0,a)),o,this._transformationMatrix,r),d=e.Vector3.Project(n.add(new e.Vector3(0,0,1.5*a)),o,this._transformationMatrix,r);this._renderSingleAxis(t,f,d,"z","#0000FF")},t.prototype._renderLabel=function(e,t,i,r,n){if(t.z>0&&t.z<1){this._drawingContext.font="normal 12px Segoe UI";var o=this._drawingContext.measureText(e),s=t.x-o.width/2,a=t.y,h=this._drawingCanvas.getBoundingClientRect();this._showUI&&this._isClickInsideRect(h.left*this._ratio+s-5,h.top*this._ratio+a-i-12,o.width+10,17)&&r(),this._drawingContext.beginPath(),this._drawingContext.rect(s-5,a-i-12,o.width+10,17),this._drawingContext.fillStyle=n(),this._drawingContext.globalAlpha=.5,this._drawingContext.fill(),this._drawingContext.globalAlpha=1,this._drawingContext.strokeStyle="#FFFFFF",this._drawingContext.lineWidth=1,this._drawingContext.stroke(),this._drawingContext.fillStyle="#FFFFFF",this._drawingContext.fillText(e,s,a-i),this._drawingContext.beginPath(),this._drawingContext.arc(t.x,a,5,0,2*Math.PI,!1),this._drawingContext.fill()}},t.prototype._isClickInsideRect=function(e,t,i,r){return this._clickPosition?this._clickPosition.x<e||this._clickPosition.x>e+i?!1:!(this._clickPosition.y<t||this._clickPosition.y>t+r):!1},t.prototype.isVisible=function(){return this._enabled},t.prototype.hide=function(){if(this._enabled){this._enabled=!1;var t=this._scene.getEngine();this._scene.unregisterBeforeRender(this._syncData),this._scene.unregisterAfterRender(this._syncUI),this._rootElement.removeChild(this._globalDiv),this._scene.forceShowBoundingBoxes=!1,this._scene.forceWireframe=!1,e.StandardMaterial.DiffuseTextureEnabled=!0,e.StandardMaterial.AmbientTextureEnabled=!0,e.StandardMaterial.SpecularTextureEnabled=!0,e.StandardMaterial.EmissiveTextureEnabled=!0,e.StandardMaterial.BumpTextureEnabled=!0,e.StandardMaterial.OpacityTextureEnabled=!0,e.StandardMaterial.ReflectionTextureEnabled=!0,e.StandardMaterial.LightmapTextureEnabled=!0,e.StandardMaterial.RefractionTextureEnabled=!0,this._scene.shadowsEnabled=!0,this._scene.particlesEnabled=!0,this._scene.postProcessesEnabled=!0,this._scene.collisionsEnabled=!0,this._scene.lightsEnabled=!0,this._scene.texturesEnabled=!0,this._scene.lensFlaresEnabled=!0,this._scene.proceduralTexturesEnabled=!0,this._scene.renderTargetsEnabled=!0,this._scene.probesEnabled=!0,t.getRenderingCanvas().removeEventListener("click",this._onCanvasClick),this._clearSkeletonViewers()}},t.prototype._clearSkeletonViewers=function(){for(var e=0;e<this._skeletonViewers.length;e++)this._skeletonViewers[e].dispose();this._skeletonViewers=[]},t.prototype.show=function(e,t,i){if(void 0===e&&(e=!0),void 0===t&&(t=null),void 0===i&&(i=null),!this._enabled){this._enabled=!0,t?this._camera=t:this._camera=this._scene.activeCamera,this._showUI=e;var r=this._scene.getEngine();this._globalDiv=document.createElement("div"),this._rootElement=i||document.body,this._rootElement.appendChild(this._globalDiv),this._generateDOMelements(),r.getRenderingCanvas().addEventListener("click",this._onCanvasClick),this._syncPositions(),this._scene.registerBeforeRender(this._syncData),this._scene.registerAfterRender(this._syncUI)}},t.prototype._clearLabels=function(){this._drawingContext.clearRect(0,0,this._drawingCanvas.width,this._drawingCanvas.height);for(var e=0;e<this._scene.meshes.length;e++){var t=this._scene.meshes[e];t.renderOverlay=!1}},t.prototype._generateheader=function(e,t){var i=document.createElement("div");i.innerHTML=t+"&nbsp;",i.style.textAlign="right",i.style.width="100%",i.style.color="white",i.style.backgroundColor="Black",i.style.padding="5px 5px 4px 0px",i.style.marginLeft="-5px",i.style.fontWeight="bold",e.appendChild(i)},t.prototype._generateTexBox=function(e,t,i){var r=document.createElement("label");r.style.display="inline",r.innerHTML=t,r.style.color=i,e.appendChild(r),e.appendChild(document.createElement("br"))},t.prototype._generateAdvancedCheckBox=function(e,t,i,r,n,o){void 0===o&&(o=null);var s=document.createElement("label");s.style.display="inline";var a=document.createElement("input");a.type="checkbox",a.checked=r,a.style.display="inline",a.style.margin="0px 5px 0px 0px",a.style.verticalAlign="sub",a.addEventListener("change",function(e){n(e.target,o)}),s.appendChild(a);var h=document.createElement("span"),c=document.createElement("span"),l=document.createElement("span");l.style.cssFloat="right",c.innerHTML=t,l.innerHTML=i,l.style.fontSize="12px",l.style.maxWidth="200px",h.appendChild(c),h.appendChild(l),s.appendChild(h),e.appendChild(s),e.appendChild(document.createElement("br"))},t.prototype._generateCheckBox=function(e,t,i,r,n){void 0===n&&(n=null);var o=document.createElement("label");o.style.display="inline";var s=document.createElement("input");s.type="checkbox",s.checked=i,s.style.display="inline",s.style.margin="0px 5px 0px 0px",s.style.verticalAlign="sub",s.addEventListener("change",function(e){r(e.target,n)}),o.appendChild(s),o.appendChild(document.createTextNode(t)),e.appendChild(o),e.appendChild(document.createElement("br"))},t.prototype._generateButton=function(e,t,i,r){void 0===r&&(r=null);var n=document.createElement("button");n.innerHTML=t,n.style.height="24px",n.style.width="150px",n.style.marginBottom="5px",n.style.color="#444444",n.style.border="1px solid white",n.className="debugLayerButton",n.addEventListener("click",function(e){i(e.target,r)}),e.appendChild(n),e.appendChild(document.createElement("br"))},t.prototype._generateRadio=function(e,t,i,r,n,o){void 0===o&&(o=null);var s=document.createElement("label");s.style.display="inline";var a=document.createElement("input");a.type="radio",a.name=i,a.checked=r,a.style.display="inline",a.style.margin="0px 5px 0px 0px",a.style.verticalAlign="sub",a.addEventListener("change",function(e){n(e.target,o)}),s.appendChild(a),s.appendChild(document.createTextNode(t)),e.appendChild(s),e.appendChild(document.createElement("br"))},t.prototype._generateDOMelements=function(){var t=this;if(this._globalDiv.id="DebugLayer",this._globalDiv.style.position="absolute",this._globalDiv.style.fontFamily="Segoe UI, Arial",this._globalDiv.style.fontSize="14px",this._globalDiv.style.color="white",this._drawingCanvas=document.createElement("canvas"),this._drawingCanvas.id="DebugLayerDrawingCanvas",this._drawingCanvas.style.position="absolute",this._drawingCanvas.style.pointerEvents="none",this._drawingCanvas.style.backgroundColor="transparent",this._drawingContext=this._drawingCanvas.getContext("2d"),this._globalDiv.appendChild(this._drawingCanvas),this._showUI){var i="rgba(128, 128, 128, 0.4)",r="rgb(180, 180, 180) solid 1px";this._statsDiv=document.createElement("div"),this._statsDiv.id="DebugLayerStats",this._statsDiv.style.border=r,this._statsDiv.style.position="absolute",this._statsDiv.style.background=i,this._statsDiv.style.padding="0px 0px 0px 5px",this._generateheader(this._statsDiv,"STATISTICS"),this._statsSubsetDiv=document.createElement("div"),this._statsSubsetDiv.style.paddingTop="5px",this._statsSubsetDiv.style.paddingBottom="5px",this._statsSubsetDiv.style.overflowY="auto",this._statsDiv.appendChild(this._statsSubsetDiv),this._treeDiv=document.createElement("div"),this._treeDiv.id="DebugLayerTree",this._treeDiv.style.border=r,this._treeDiv.style.position="absolute",this._treeDiv.style.background=i,this._treeDiv.style.padding="0px 0px 0px 5px",this._treeDiv.style.display="none",this._generateheader(this._treeDiv,"MESHES TREE"),this._treeSubsetDiv=document.createElement("div"),this._treeSubsetDiv.style.paddingTop="5px",this._treeSubsetDiv.style.paddingRight="5px",this._treeSubsetDiv.style.overflowY="auto",this._treeSubsetDiv.style.maxHeight="300px",this._treeDiv.appendChild(this._treeSubsetDiv),this._needToRefreshMeshesTree=!0,this._logDiv=document.createElement("div"),this._logDiv.style.border=r,this._logDiv.id="DebugLayerLogs",this._logDiv.style.position="absolute",this._logDiv.style.background=i,this._logDiv.style.padding="0px 0px 0px 5px",this._logDiv.style.display="none",this._generateheader(this._logDiv,"LOGS"),this._logSubsetDiv=document.createElement("div"),this._logSubsetDiv.style.height="127px",this._logSubsetDiv.style.paddingTop="5px",this._logSubsetDiv.style.overflowY="auto",this._logSubsetDiv.style.fontSize="12px",this._logSubsetDiv.style.fontFamily="consolas",this._logSubsetDiv.innerHTML=e.Tools.LogCache,this._logDiv.appendChild(this._logSubsetDiv),e.Tools.OnNewCacheEntry=function(e){t._logSubsetDiv.innerHTML=e+t._logSubsetDiv.innerHTML},this._optionsDiv=document.createElement("div"),this._optionsDiv.id="DebugLayerOptions",this._optionsDiv.style.border=r,this._optionsDiv.style.position="absolute",this._optionsDiv.style.background=i,this._optionsDiv.style.padding="0px 0px 0px 5px",this._optionsDiv.style.overflowY="auto",this._generateheader(this._optionsDiv,"OPTIONS"),this._optionsSubsetDiv=document.createElement("div"),this._optionsSubsetDiv.style.paddingTop="5px",this._optionsSubsetDiv.style.paddingBottom="5px",this._optionsSubsetDiv.style.overflowY="auto",this._optionsSubsetDiv.style.maxHeight="200px",this._optionsDiv.appendChild(this._optionsSubsetDiv),this._generateTexBox(this._optionsSubsetDiv,"<b>Windows:</b>",this.accentColor),this._generateCheckBox(this._optionsSubsetDiv,"Statistics",this._displayStatistics,function(e){t._displayStatistics=e.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Logs",this._displayLogs,function(e){t._displayLogs=e.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Meshes tree",this._displayTree,function(e){t._displayTree=e.checked,t._needToRefreshMeshesTree=!0}),this._optionsSubsetDiv.appendChild(document.createElement("br")),this._generateTexBox(this._optionsSubsetDiv,"<b>General:</b>",this.accentColor),this._generateCheckBox(this._optionsSubsetDiv,"Bounding boxes",this._scene.forceShowBoundingBoxes,function(e){t._scene.forceShowBoundingBoxes=e.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Clickable labels",this._labelsEnabled,function(e){t._labelsEnabled=e.checked,t._labelsEnabled||t._clearLabels()}),this._generateCheckBox(this._optionsSubsetDiv,"Generate user marks (F12)",e.Tools.PerformanceLogLevel===e.Tools.PerformanceUserMarkLogLevel,function(t){t.checked?e.Tools.PerformanceLogLevel=e.Tools.PerformanceUserMarkLogLevel:e.Tools.PerformanceLogLevel=e.Tools.PerformanceNoneLogLevel}),this._optionsSubsetDiv.appendChild(document.createElement("br")),this._generateTexBox(this._optionsSubsetDiv,"<b>Rendering mode:</b>",this.accentColor),this._generateRadio(this._optionsSubsetDiv,"Solid","renderMode",!this._scene.forceWireframe&&!this._scene.forcePointsCloud,function(e){e.checked&&(t._scene.forceWireframe=!1,t._scene.forcePointsCloud=!1)}),this._generateRadio(this._optionsSubsetDiv,"Wireframe","renderMode",this._scene.forceWireframe,function(e){e.checked&&(t._scene.forceWireframe=!0,t._scene.forcePointsCloud=!1)}),this._generateRadio(this._optionsSubsetDiv,"Point","renderMode",this._scene.forcePointsCloud,function(e){e.checked&&(t._scene.forceWireframe=!1,t._scene.forcePointsCloud=!0)}),this._optionsSubsetDiv.appendChild(document.createElement("br")),this._generateTexBox(this._optionsSubsetDiv,"<b>Texture channels:</b>",this.accentColor),this._generateCheckBox(this._optionsSubsetDiv,"Diffuse",e.StandardMaterial.DiffuseTextureEnabled,function(t){e.StandardMaterial.DiffuseTextureEnabled=t.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Ambient",e.StandardMaterial.AmbientTextureEnabled,function(t){e.StandardMaterial.AmbientTextureEnabled=t.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Specular",e.StandardMaterial.SpecularTextureEnabled,function(t){e.StandardMaterial.SpecularTextureEnabled=t.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Emissive",e.StandardMaterial.EmissiveTextureEnabled,function(t){e.StandardMaterial.EmissiveTextureEnabled=t.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Bump",e.StandardMaterial.BumpTextureEnabled,function(t){e.StandardMaterial.BumpTextureEnabled=t.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Opacity",e.StandardMaterial.OpacityTextureEnabled,function(t){e.StandardMaterial.OpacityTextureEnabled=t.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Reflection",e.StandardMaterial.ReflectionTextureEnabled,function(t){e.StandardMaterial.ReflectionTextureEnabled=t.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Refraction",e.StandardMaterial.RefractionTextureEnabled,function(t){e.StandardMaterial.RefractionTextureEnabled=t.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Lightmap",e.StandardMaterial.LightmapTextureEnabled,function(t){e.StandardMaterial.LightmapTextureEnabled=t.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Fresnel",e.StandardMaterial.FresnelEnabled,function(t){e.StandardMaterial.FresnelEnabled=t.checked}),this._optionsSubsetDiv.appendChild(document.createElement("br")),this._generateTexBox(this._optionsSubsetDiv,"<b>Options:</b>",this.accentColor),this._generateCheckBox(this._optionsSubsetDiv,"Animations",this._scene.animationsEnabled,function(e){t._scene.animationsEnabled=e.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Collisions",this._scene.collisionsEnabled,function(e){t._scene.collisionsEnabled=e.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Fog",this._scene.fogEnabled,function(e){t._scene.fogEnabled=e.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Lens flares",this._scene.lensFlaresEnabled,function(e){t._scene.lensFlaresEnabled=e.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Lights",this._scene.lightsEnabled,function(e){t._scene.lightsEnabled=e.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Particles",this._scene.particlesEnabled,function(e){t._scene.particlesEnabled=e.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Post-processes",this._scene.postProcessesEnabled,function(e){t._scene.postProcessesEnabled=e.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Probes",this._scene.probesEnabled,function(e){t._scene.probesEnabled=e.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Procedural textures",this._scene.proceduralTexturesEnabled,function(e){t._scene.proceduralTexturesEnabled=e.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Render targets",this._scene.renderTargetsEnabled,function(e){t._scene.renderTargetsEnabled=e.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Shadows",this._scene.shadowsEnabled,function(e){t._scene.shadowsEnabled=e.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Skeletons",this._scene.skeletonsEnabled,function(e){t._scene.skeletonsEnabled=e.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Sprites",this._scene.spritesEnabled,function(e){t._scene.spritesEnabled=e.checked}),this._generateCheckBox(this._optionsSubsetDiv,"Textures",this._scene.texturesEnabled,function(e){t._scene.texturesEnabled=e.checked}),e.AudioEngine&&e.Engine.audioEngine.canUseWebAudio&&(this._optionsSubsetDiv.appendChild(document.createElement("br")),this._generateTexBox(this._optionsSubsetDiv,"<b>Audio:</b>",this.accentColor),this._generateRadio(this._optionsSubsetDiv,"Headphones","panningModel",this._scene.headphone,function(e){e.checked&&(t._scene.headphone=!0)}),this._generateRadio(this._optionsSubsetDiv,"Normal Speakers","panningModel",!this._scene.headphone,function(e){e.checked&&(t._scene.headphone=!1)}),this._generateCheckBox(this._optionsSubsetDiv,"Disable audio",!this._scene.audioEnabled,function(e){t._scene.audioEnabled=!e.checked})),this._optionsSubsetDiv.appendChild(document.createElement("br")),this._generateTexBox(this._optionsSubsetDiv,"<b>Viewers:</b>",this.accentColor),this._generateCheckBox(this._optionsSubsetDiv,"Skeletons",!1,function(i){if(!i.checked)return void t._clearSkeletonViewers();for(var r=0;r<t._scene.meshes.length;r++){var n=t._scene.meshes[r];if(n.skeleton){for(var o=!1,s=0;s<t._skeletonViewers.length;s++)if(t._skeletonViewers[s].skeleton===n.skeleton){o=!0;break}if(o)continue;var a=new e.Debug.SkeletonViewer(n.skeleton,n,t._scene);a.isEnabled=!0,t._skeletonViewers.push(a)}}}),this._optionsSubsetDiv.appendChild(document.createElement("br")),this._generateTexBox(this._optionsSubsetDiv,"<b>Tools:</b>",this.accentColor),this._generateButton(this._optionsSubsetDiv,"Dump rendertargets",function(e){t._scene.dumpNextRenderTargets=!0}),this._generateButton(this._optionsSubsetDiv,"Run SceneOptimizer",function(i){e.SceneOptimizer.OptimizeAsync(t._scene)}),this._generateButton(this._optionsSubsetDiv,"Log camera object",function(e){t._camera?console.log(t._camera):console.warn("No camera defined, or debug layer created before camera creation!")}),this._optionsSubsetDiv.appendChild(document.createElement("br")),this._globalDiv.appendChild(this._statsDiv),this._globalDiv.appendChild(this._logDiv),this._globalDiv.appendChild(this._optionsDiv),this._globalDiv.appendChild(this._treeDiv)}},t.prototype._displayStats=function(){var t=this._scene,i=t.getEngine(),r=i.getGlInfo();this._statsSubsetDiv.innerHTML="Babylon.js v"+e.Engine.Version+" - <b>"+e.Tools.Format(i.getFps(),0)+" fps</b><br><br><div style='column-count: 2;-moz-column-count:2;-webkit-column-count:2'><b>Count</b><br>Total meshes: "+t.meshes.length+"<br>Total lights: "+t.lights.length+"<br>Total vertices: "+t.getTotalVertices()+"<br>Total materials: "+t.materials.length+"<br>Total textures: "+t.textures.length+"<br>Active meshes: "+t.getActiveMeshes().length+"<br>Active indices: "+t.getActiveIndices()+"<br>Active bones: "+t.getActiveBones()+"<br>Active particles: "+t.getActiveParticles()+"<br><b>Draw calls: "+i.drawCalls+"</b><br><br><b>Duration</b><br>Meshes selection:</i> "+e.Tools.Format(t.getEvaluateActiveMeshesDuration())+" ms<br>Render Targets: "+e.Tools.Format(t.getRenderTargetsDuration())+" ms<br>Particles: "+e.Tools.Format(t.getParticlesDuration())+" ms<br>Sprites: "+e.Tools.Format(t.getSpritesDuration())+" ms<br><br>Render: <b>"+e.Tools.Format(t.getRenderDuration())+" ms</b><br>Frame: "+e.Tools.Format(t.getLastFrameDuration())+" ms<br>Potential FPS: "+e.Tools.Format(1e3/t.getLastFrameDuration(),0)+"<br>Resolution: "+i.getRenderWidth()+"x"+i.getRenderHeight()+"<br><br></div><div style='column-count: 2;-moz-column-count:2;-webkit-column-count:2'><b>Extensions</b><br>Std derivatives: "+(i.getCaps().standardDerivatives?"Yes":"No")+"<br>Compressed textures: "+(i.getCaps().s3tc?"Yes":"No")+"<br>Hardware instances: "+(i.getCaps().instancedArrays?"Yes":"No")+"<br>Texture float: "+(i.getCaps().textureFloat?"Yes":"No")+"<br><br>32bits indices: "+(i.getCaps().uintIndices?"Yes":"No")+"<br>Fragment depth: "+(i.getCaps().fragmentDepthSupported?"Yes":"No")+"<br>High precision shaders: "+(i.getCaps().highPrecisionShaderSupported?"Yes":"No")+"<br>Draw buffers: "+(i.getCaps().drawBuffersExtension?"Yes":"No")+"<br></div><br><div style='column-count: 2;-moz-column-count:2;-webkit-column-count:2'><b>Caps.</b><br>Max textures units: "+i.getCaps().maxTexturesImageUnits+"<br>Max textures size: "+i.getCaps().maxTextureSize+"<br>Max anisotropy: "+i.getCaps().maxAnisotropy+"<br><b>Info</b><br>WebGL feature level: "+i.webGLVersion+"<br>"+r.version+"<br></div><br>"+r.renderer+"<br>",this.customStatsFunction&&(this._statsSubsetDiv.innerHTML+=this.customStatsFunction())},t}();e.DebugLayer=t}(BABYLON||(BABYLON={})),BABYLON.Effect.ShadersStore={anaglyphPixelShader:"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform sampler2D leftSampler;\nvoid main(void)\n{\nvec4 leftFrag=texture2D(leftSampler,vUV);\nleftFrag=vec4(1.0,leftFrag.g,leftFrag.b,1.0);\nvec4 rightFrag=texture2D(textureSampler,vUV);\nrightFrag=vec4(rightFrag.r,1.0,1.0,1.0);\ngl_FragColor=vec4(rightFrag.rgb*leftFrag.rgb,1.0);\n}",blackAndWhitePixelShader:"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nvoid main(void) \n{\nfloat luminance=dot(texture2D(textureSampler,vUV).rgb,vec3(0.3,0.59,0.11));\ngl_FragColor=vec4(luminance,luminance,luminance,1.0);\n}",blurPixelShader:"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n\nuniform vec2 screenSize;\nuniform vec2 direction;\nuniform float blurWidth;\nvoid main(void)\n{\nfloat weights[7];\nweights[0]=0.05;\nweights[1]=0.1;\nweights[2]=0.2;\nweights[3]=0.3;\nweights[4]=0.2;\nweights[5]=0.1;\nweights[6]=0.05;\nvec2 texelSize=vec2(1.0/screenSize.x,1.0/screenSize.y);\nvec2 texelStep=texelSize*direction*blurWidth;\nvec2 start=vUV-3.0*texelStep;\nvec4 baseColor=vec4(0.,0.,0.,0.);\nvec2 texelOffset=vec2(0.,0.);\nfor (int i=0; i<7; i++)\n{\nbaseColor+=texture2D(textureSampler,start+texelOffset)*weights[i];\ntexelOffset+=texelStep;\n}\ngl_FragColor=baseColor;\n}",chromaticAberrationPixelShader:"\nuniform sampler2D textureSampler; \n\nuniform float chromatic_aberration;\nuniform float screen_width;\nuniform float screen_height;\n\nvarying vec2 vUV;\nvoid main(void)\n{\nvec2 centered_screen_pos=vec2(vUV.x-0.5,vUV.y-0.5);\nfloat radius2=centered_screen_pos.x*centered_screen_pos.x\n+centered_screen_pos.y*centered_screen_pos.y;\nfloat radius=sqrt(radius2);\nvec4 original=texture2D(textureSampler,vUV);\nif (chromatic_aberration>0.0) {\n\nvec3 ref_indices=vec3(-0.3,0.0,0.3);\nfloat ref_shiftX=chromatic_aberration*radius*17.0/screen_width;\nfloat ref_shiftY=chromatic_aberration*radius*17.0/screen_height;\n\nvec2 ref_coords_r=vec2(vUV.x+ref_indices.r*ref_shiftX,vUV.y+ref_indices.r*ref_shiftY*0.5);\nvec2 ref_coords_g=vec2(vUV.x+ref_indices.g*ref_shiftX,vUV.y+ref_indices.g*ref_shiftY*0.5);\nvec2 ref_coords_b=vec2(vUV.x+ref_indices.b*ref_shiftX,vUV.y+ref_indices.b*ref_shiftY*0.5);\noriginal.r=texture2D(textureSampler,ref_coords_r).r;\noriginal.g=texture2D(textureSampler,ref_coords_g).g;\noriginal.b=texture2D(textureSampler,ref_coords_b).b;\n}\ngl_FragColor=original;\n}",colorPixelShader:"uniform vec4 color;\nvoid main(void) {\ngl_FragColor=color;\n}",colorVertexShader:"\nattribute vec3 position;\n\nuniform mat4 worldViewProjection;\nvoid main(void) {\ngl_Position=worldViewProjection*vec4(position,1.0);\n}",colorCorrectionPixelShader:"\nuniform sampler2D textureSampler; \nuniform sampler2D colorTable; \n\nvarying vec2 vUV;\n\nconst float SLICE_COUNT=16.0; \n\nvec4 sampleAs3DTexture(sampler2D texture,vec3 uv,float width) {\nfloat sliceSize=1.0/width; \nfloat slicePixelSize=sliceSize/width; \nfloat sliceInnerSize=slicePixelSize*(width-1.0); \nfloat zSlice0=min(floor(uv.z*width),width-1.0);\nfloat zSlice1=min(zSlice0+1.0,width-1.0);\nfloat xOffset=slicePixelSize*0.5+uv.x*sliceInnerSize;\nfloat s0=xOffset+(zSlice0*sliceSize);\nfloat s1=xOffset+(zSlice1*sliceSize);\nvec4 slice0Color=texture2D(texture,vec2(s0,uv.y));\nvec4 slice1Color=texture2D(texture,vec2(s1,uv.y));\nfloat zOffset=mod(uv.z*width,1.0);\nvec4 result=mix(slice0Color,slice1Color,zOffset);\nreturn result;\n}\nvoid main(void)\n{\nvec4 screen_color=texture2D(textureSampler,vUV);\ngl_FragColor=sampleAs3DTexture(colorTable,screen_color.rgb,SLICE_COUNT);\n}",convolutionPixelShader:"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform vec2 screenSize;\nuniform float kernel[9];\nvoid main(void)\n{\nvec2 onePixel=vec2(1.0,1.0)/screenSize;\nvec4 colorSum =\ntexture2D(textureSampler,vUV+onePixel*vec2(-1,-1))*kernel[0] +\ntexture2D(textureSampler,vUV+onePixel*vec2(0,-1))*kernel[1] +\ntexture2D(textureSampler,vUV+onePixel*vec2(1,-1))*kernel[2] +\ntexture2D(textureSampler,vUV+onePixel*vec2(-1,0))*kernel[3] +\ntexture2D(textureSampler,vUV+onePixel*vec2(0,0))*kernel[4] +\ntexture2D(textureSampler,vUV+onePixel*vec2(1,0))*kernel[5] +\ntexture2D(textureSampler,vUV+onePixel*vec2(-1,1))*kernel[6] +\ntexture2D(textureSampler,vUV+onePixel*vec2(0,1))*kernel[7] +\ntexture2D(textureSampler,vUV+onePixel*vec2(1,1))*kernel[8];\nfloat kernelWeight =\nkernel[0] +\nkernel[1] +\nkernel[2] +\nkernel[3] +\nkernel[4] +\nkernel[5] +\nkernel[6] +\nkernel[7] +\nkernel[8];\nif (kernelWeight<=0.0) {\nkernelWeight=1.0;\n}\ngl_FragColor=vec4((colorSum/kernelWeight).rgb,1);\n}",defaultPixelShader:"#ifdef BUMP\n#extension GL_OES_standard_derivatives : enable\n#endif\n#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\n\n#define RECIPROCAL_PI2 0.15915494\nuniform vec3 vEyePosition;\nuniform vec3 vAmbientColor;\nuniform vec4 vDiffuseColor;\n#ifdef SPECULARTERM\nuniform vec4 vSpecularColor;\n#endif\nuniform vec3 vEmissiveColor;\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n\n#include<helperFunctions>\n\n#include<lightFragmentDeclaration>[0..maxSimultaneousLights]\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\nuniform sampler2D diffuseSampler;\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef AMBIENT\nvarying vec2 vAmbientUV;\nuniform sampler2D ambientSampler;\nuniform vec2 vAmbientInfos;\n#endif\n#ifdef OPACITY \nvarying vec2 vOpacityUV;\nuniform sampler2D opacitySampler;\nuniform vec2 vOpacityInfos;\n#endif\n#ifdef EMISSIVE\nvarying vec2 vEmissiveUV;\nuniform vec2 vEmissiveInfos;\nuniform sampler2D emissiveSampler;\n#endif\n#ifdef LIGHTMAP\nvarying vec2 vLightmapUV;\nuniform vec2 vLightmapInfos;\nuniform sampler2D lightmapSampler;\n#endif\n#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(REFRACTION)\nuniform mat4 view;\n#endif\n#ifdef REFRACTION\nuniform vec4 vRefractionInfos;\n#ifdef REFRACTIONMAP_3D\nuniform samplerCube refractionCubeSampler;\n#else\nuniform sampler2D refraction2DSampler;\nuniform mat4 refractionMatrix;\n#endif\n#ifdef REFRACTIONFRESNEL\nuniform vec4 refractionLeftColor;\nuniform vec4 refractionRightColor;\n#endif\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM)\nvarying vec2 vSpecularUV;\nuniform vec2 vSpecularInfos;\nuniform sampler2D specularSampler;\n#endif\n\n#include<fresnelFunction>\n#ifdef DIFFUSEFRESNEL\nuniform vec4 diffuseLeftColor;\nuniform vec4 diffuseRightColor;\n#endif\n#ifdef OPACITYFRESNEL\nuniform vec4 opacityParts;\n#endif\n#ifdef EMISSIVEFRESNEL\nuniform vec4 emissiveLeftColor;\nuniform vec4 emissiveRightColor;\n#endif\n\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\n#ifdef REFLECTIONMAP_3D\nuniform samplerCube reflectionCubeSampler;\n#else\nuniform sampler2D reflection2DSampler;\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#else\n#ifdef REFLECTIONMAP_EQUIRECTANGULAR_FIXED\nvarying vec3 vDirectionW;\n#endif\n#if defined(REFLECTIONMAP_PLANAR) || defined(REFLECTIONMAP_CUBIC) || defined(REFLECTIONMAP_PROJECTION)\nuniform mat4 reflectionMatrix;\n#endif\n#endif\n#include<reflectionFunction>\n#ifdef REFLECTIONFRESNEL\nuniform vec4 reflectionLeftColor;\nuniform vec4 reflectionRightColor;\n#endif\n#endif\n#include<bumpFragmentFunctions>\n#include<clipPlaneFragmentDeclaration>\n#include<logDepthDeclaration>\n#include<fogFragmentDeclaration>\nvoid main(void) {\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\nvec4 baseColor=vec4(1.,1.,1.,1.);\nvec3 diffuseColor=vDiffuseColor.rgb;\n\nfloat alpha=vDiffuseColor.a;\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\n#ifdef DIFFUSE\nvec2 diffuseUV=vDiffuseUV;\n#endif\n#include<bumpFragment>\n#ifdef DIFFUSE\nbaseColor=texture2D(diffuseSampler,diffuseUV);\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\n#ifdef ALPHAFROMDIFFUSE\nalpha*=baseColor.a;\n#endif\nbaseColor.rgb*=vDiffuseInfos.y;\n#endif\n#ifdef VERTEXCOLOR\nbaseColor.rgb*=vColor.rgb;\n#endif\n\nvec3 baseAmbientColor=vec3(1.,1.,1.);\n#ifdef AMBIENT\nbaseAmbientColor=texture2D(ambientSampler,vAmbientUV).rgb*vAmbientInfos.y;\n#endif\n\n#ifdef SPECULARTERM\nfloat glossiness=vSpecularColor.a;\nvec3 specularColor=vSpecularColor.rgb;\n#ifdef SPECULAR\nvec4 specularMapColor=texture2D(specularSampler,vSpecularUV);\nspecularColor=specularMapColor.rgb;\n#ifdef GLOSSINESS\nglossiness=glossiness*specularMapColor.a;\n#endif\n#endif\n#else\nfloat glossiness=0.;\n#endif\n\nvec3 diffuseBase=vec3(0.,0.,0.);\nlightingInfo info;\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif\nfloat shadow=1.;\n#include<lightFragment>[0..maxSimultaneousLights]\n\nvec3 refractionColor=vec3(0.,0.,0.);\n#ifdef REFRACTION\nvec3 refractionVector=normalize(refract(-viewDirectionW,normalW,vRefractionInfos.y));\n#ifdef REFRACTIONMAP_3D\nrefractionVector.y=refractionVector.y*vRefractionInfos.w;\nif (dot(refractionVector,viewDirectionW)<1.0)\n{\nrefractionColor=textureCube(refractionCubeSampler,refractionVector).rgb*vRefractionInfos.x;\n}\n#else\nvec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*vRefractionInfos.z,1.0)));\nvec2 refractionCoords=vRefractionUVW.xy/vRefractionUVW.z;\nrefractionCoords.y=1.0-refractionCoords.y;\nrefractionColor=texture2D(refraction2DSampler,refractionCoords).rgb*vRefractionInfos.x;\n#endif\n#endif\n\nvec3 reflectionColor=vec3(0.,0.,0.);\n#ifdef REFLECTION\nvec3 vReflectionUVW=computeReflectionCoords(vec4(vPositionW,1.0),normalW);\n#ifdef REFLECTIONMAP_3D\n#ifdef ROUGHNESS\nfloat bias=vReflectionInfos.y;\n#ifdef SPECULARTERM\n#ifdef SPECULAR\n#ifdef GLOSSINESS\nbias*=(1.0-specularMapColor.a);\n#endif\n#endif\n#endif\nreflectionColor=textureCube(reflectionCubeSampler,vReflectionUVW,bias).rgb*vReflectionInfos.x;\n#else\nreflectionColor=textureCube(reflectionCubeSampler,vReflectionUVW).rgb*vReflectionInfos.x;\n#endif\n#else\nvec2 coords=vReflectionUVW.xy;\n#ifdef REFLECTIONMAP_PROJECTION\ncoords/=vReflectionUVW.z;\n#endif\ncoords.y=1.0-coords.y;\nreflectionColor=texture2D(reflection2DSampler,coords).rgb*vReflectionInfos.x;\n#endif\n#ifdef REFLECTIONFRESNEL\nfloat reflectionFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,reflectionRightColor.a,reflectionLeftColor.a);\n#ifdef REFLECTIONFRESNELFROMSPECULAR\n#ifdef SPECULARTERM\nreflectionColor*=specularColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;\n#else\nreflectionColor*=reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;\n#endif\n#else\nreflectionColor*=reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;\n#endif\n#endif\n#endif\n#ifdef REFRACTIONFRESNEL\nfloat refractionFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,refractionRightColor.a,refractionLeftColor.a);\nrefractionColor*=refractionLeftColor.rgb*(1.0-refractionFresnelTerm)+refractionFresnelTerm*refractionRightColor.rgb;\n#endif\n#ifdef OPACITY\nvec4 opacityMap=texture2D(opacitySampler,vOpacityUV);\n#ifdef OPACITYRGB\nopacityMap.rgb=opacityMap.rgb*vec3(0.3,0.59,0.11);\nalpha*=(opacityMap.x+opacityMap.y+opacityMap.z)* vOpacityInfos.y;\n#else\nalpha*=opacityMap.a*vOpacityInfos.y;\n#endif\n#endif\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n#ifdef OPACITYFRESNEL\nfloat opacityFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,opacityParts.z,opacityParts.w);\nalpha+=opacityParts.x*(1.0-opacityFresnelTerm)+opacityFresnelTerm*opacityParts.y;\n#endif\n\nvec3 emissiveColor=vEmissiveColor;\n#ifdef EMISSIVE\nemissiveColor+=texture2D(emissiveSampler,vEmissiveUV).rgb*vEmissiveInfos.y;\n#endif\n#ifdef EMISSIVEFRESNEL\nfloat emissiveFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,emissiveRightColor.a,emissiveLeftColor.a);\nemissiveColor*=emissiveLeftColor.rgb*(1.0-emissiveFresnelTerm)+emissiveFresnelTerm*emissiveRightColor.rgb;\n#endif\n\n#ifdef DIFFUSEFRESNEL\nfloat diffuseFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,diffuseRightColor.a,diffuseLeftColor.a);\ndiffuseBase*=diffuseLeftColor.rgb*(1.0-diffuseFresnelTerm)+diffuseFresnelTerm*diffuseRightColor.rgb;\n#endif\n\n#ifdef EMISSIVEASILLUMINATION\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor+vAmbientColor,0.0,1.0)*baseColor.rgb;\n#else\n#ifdef LINKEMISSIVEWITHDIFFUSE\nvec3 finalDiffuse=clamp((diffuseBase+emissiveColor)*diffuseColor+vAmbientColor,0.0,1.0)*baseColor.rgb;\n#else\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor+emissiveColor+vAmbientColor,0.0,1.0)*baseColor.rgb;\n#endif\n#endif\n#ifdef SPECULARTERM\nvec3 finalSpecular=specularBase*specularColor;\n#else\nvec3 finalSpecular=vec3(0.0);\n#endif\n#ifdef SPECULAROVERALPHA\nalpha=clamp(alpha+dot(finalSpecular,vec3(0.3,0.59,0.11)),0.,1.);\n#endif\n#ifdef REFLECTIONOVERALPHA\nalpha=clamp(alpha+dot(reflectionColor,vec3(0.3,0.59,0.11)),0.,1.);\n#endif\n\n#ifdef EMISSIVEASILLUMINATION\nvec4 color=vec4(clamp(finalDiffuse*baseAmbientColor+finalSpecular+reflectionColor+emissiveColor+refractionColor,0.0,1.0),alpha);\n#else\nvec4 color=vec4(finalDiffuse*baseAmbientColor+finalSpecular+reflectionColor+refractionColor,alpha);\n#endif\n#ifdef LIGHTMAP\nvec3 lightmapColor=texture2D(lightmapSampler,vLightmapUV).rgb*vLightmapInfos.y;\n#ifdef USELIGHTMAPASSHADOWMAP\ncolor.rgb*=lightmapColor;\n#else\ncolor.rgb+=lightmapColor;\n#endif\n#endif\n#include<logDepthFragment>\n#include<fogFragment>\ngl_FragColor=color;\n}",
  37. defaultVertexShader:"\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\nuniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\nuniform mat4 diffuseMatrix;\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef AMBIENT\nvarying vec2 vAmbientUV;\nuniform mat4 ambientMatrix;\nuniform vec2 vAmbientInfos;\n#endif\n#ifdef OPACITY\nvarying vec2 vOpacityUV;\nuniform mat4 opacityMatrix;\nuniform vec2 vOpacityInfos;\n#endif\n#ifdef EMISSIVE\nvarying vec2 vEmissiveUV;\nuniform vec2 vEmissiveInfos;\nuniform mat4 emissiveMatrix;\n#endif\n#ifdef LIGHTMAP\nvarying vec2 vLightmapUV;\nuniform vec2 vLightmapInfos;\nuniform mat4 lightmapMatrix;\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM)\nvarying vec2 vSpecularUV;\nuniform vec2 vSpecularInfos;\nuniform mat4 specularMatrix;\n#endif\n#ifdef BUMP\nvarying vec2 vBumpUV;\nuniform vec3 vBumpInfos;\nuniform mat4 bumpMatrix;\n#endif\n#include<pointCloudVertexDeclaration>\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<shadowsVertexDeclaration>[0..maxSimultaneousLights]\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#endif\n#ifdef REFLECTIONMAP_EQUIRECTANGULAR_FIXED\nvarying vec3 vDirectionW;\n#endif\n#include<logDepthDeclaration>\nvoid main(void) {\n#ifdef REFLECTIONMAP_SKYBOX\nvPositionUVW=position;\n#endif \n#include<instancesVertex>\n#include<bonesVertex>\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\nvec4 worldPos=finalWorld*vec4(position,1.0);\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nvNormalW=normalize(vec3(finalWorld*vec4(normal,0.0)));\n#endif\n#ifdef REFLECTIONMAP_EQUIRECTANGULAR_FIXED\nvDirectionW=normalize(vec3(finalWorld*vec4(position,0.0)));\n#endif\n\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef DIFFUSE\nif (vDiffuseInfos.x == 0.)\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#ifdef AMBIENT\nif (vAmbientInfos.x == 0.)\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#ifdef OPACITY\nif (vOpacityInfos.x == 0.)\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#ifdef EMISSIVE\nif (vEmissiveInfos.x == 0.)\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#ifdef LIGHTMAP\nif (vLightmapInfos.x == 0.)\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM)\nif (vSpecularInfos.x == 0.)\n{\nvSpecularUV=vec2(specularMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvSpecularUV=vec2(specularMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#ifdef BUMP\nif (vBumpInfos.x == 0.)\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#include<clipPlaneVertex>\n#include<fogVertex>\n#include<shadowsVertex>[0..maxSimultaneousLights]\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n#include<pointCloudVertex>\n#include<logDepthVertex>\n}",depthPixelShader:"#ifdef ALPHATEST\nvarying vec2 vUV;\nuniform sampler2D diffuseSampler;\n#endif\nuniform float far;\nvoid main(void)\n{\n#ifdef ALPHATEST\nif (texture2D(diffuseSampler,vUV).a<0.4)\ndiscard;\n#endif\nfloat depth=(gl_FragCoord.z/gl_FragCoord.w)/far;\ngl_FragColor=vec4(depth,depth*depth,0.0,1.0);\n}",depthVertexShader:"\nattribute vec3 position;\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\nuniform mat4 viewProjection;\n#if defined(ALPHATEST) || defined(NEED_UV)\nvarying vec2 vUV;\nuniform mat4 diffuseMatrix;\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#endif\nvoid main(void)\n{\n#include<instancesVertex>\n#include<bonesVertex>\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\n#if defined(ALPHATEST) || defined(BASIC_RENDER)\n#ifdef UV1\nvUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n#endif\n#ifdef UV2\nvUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n}",depthBoxBlurPixelShader:"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n\nuniform vec2 screenSize;\nvoid main(void)\n{\nvec4 colorDepth=vec4(0.0);\nfor (int x=-OFFSET; x<=OFFSET; x++)\nfor (int y=-OFFSET; y<=OFFSET; y++)\ncolorDepth+=texture2D(textureSampler,vUV+vec2(x,y)/screenSize);\ngl_FragColor=(colorDepth/float((OFFSET*2+1)*(OFFSET*2+1)));\n}",depthOfFieldPixelShader:"\n\n\n\n\nuniform sampler2D textureSampler;\nuniform sampler2D highlightsSampler;\nuniform sampler2D depthSampler;\nuniform sampler2D grainSampler;\n\nuniform float grain_amount;\nuniform bool blur_noise;\nuniform float screen_width;\nuniform float screen_height;\nuniform float distortion;\nuniform bool dof_enabled;\n\nuniform float screen_distance; \nuniform float aperture;\nuniform float darken;\nuniform float edge_blur;\nuniform bool highlights;\n\nuniform float near;\nuniform float far;\n\nvarying vec2 vUV;\n\n#define PI 3.14159265\n#define TWOPI 6.28318530\n#define inverse_focal_length 0.1 \n\nvec2 centered_screen_pos;\nvec2 distorted_coords;\nfloat radius2;\nfloat radius;\n\nvec2 rand(vec2 co)\n{\nfloat noise1=(fract(sin(dot(co,vec2(12.9898,78.233)))*43758.5453));\nfloat noise2=(fract(sin(dot(co,vec2(12.9898,78.233)*2.0))*43758.5453));\nreturn clamp(vec2(noise1,noise2),0.0,1.0);\n}\n\nvec2 getDistortedCoords(vec2 coords) {\nif (distortion == 0.0) { return coords; }\nvec2 direction=1.0*normalize(centered_screen_pos);\nvec2 dist_coords=vec2(0.5,0.5);\ndist_coords.x=0.5+direction.x*radius2*1.0;\ndist_coords.y=0.5+direction.y*radius2*1.0;\nfloat dist_amount=clamp(distortion*0.23,0.0,1.0);\ndist_coords=mix(coords,dist_coords,dist_amount);\nreturn dist_coords;\n}\n\nfloat sampleScreen(inout vec4 color,const in vec2 offset,const in float weight) {\n\nvec2 coords=distorted_coords;\nfloat angle=rand(coords*100.0).x*TWOPI;\ncoords+=vec2(offset.x*cos(angle)-offset.y*sin(angle),offset.x*sin(angle)+offset.y*cos(angle));\ncolor+=texture2D(textureSampler,coords)*weight;\nreturn weight;\n}\n\nfloat getBlurLevel(float size) {\nreturn min(3.0,ceil(size/1.0));\n}\n\nvec4 getBlurColor(float size) {\nvec4 col=texture2D(textureSampler,distorted_coords);\nif (size == 0.0) { return col; }\n\n\nfloat blur_level=getBlurLevel(size);\nfloat w=(size/screen_width);\nfloat h=(size/screen_height);\nfloat total_weight=1.0;\nvec2 sample_coords;\ntotal_weight+=sampleScreen(col,vec2(-0.50*w,0.24*h),0.93);\ntotal_weight+=sampleScreen(col,vec2(0.30*w,-0.75*h),0.90);\ntotal_weight+=sampleScreen(col,vec2(0.36*w,0.96*h),0.87);\ntotal_weight+=sampleScreen(col,vec2(-1.08*w,-0.55*h),0.85);\ntotal_weight+=sampleScreen(col,vec2(1.33*w,-0.37*h),0.83);\ntotal_weight+=sampleScreen(col,vec2(-0.82*w,1.31*h),0.80);\ntotal_weight+=sampleScreen(col,vec2(-0.31*w,-1.67*h),0.78);\ntotal_weight+=sampleScreen(col,vec2(1.47*w,1.11*h),0.76);\ntotal_weight+=sampleScreen(col,vec2(-1.97*w,0.19*h),0.74);\ntotal_weight+=sampleScreen(col,vec2(1.42*w,-1.57*h),0.72);\nif (blur_level>1.0) {\ntotal_weight+=sampleScreen(col,vec2(0.01*w,2.25*h),0.70);\ntotal_weight+=sampleScreen(col,vec2(-1.62*w,-1.74*h),0.67);\ntotal_weight+=sampleScreen(col,vec2(2.49*w,0.20*h),0.65);\ntotal_weight+=sampleScreen(col,vec2(-2.07*w,1.61*h),0.63);\ntotal_weight+=sampleScreen(col,vec2(0.46*w,-2.70*h),0.61);\ntotal_weight+=sampleScreen(col,vec2(1.55*w,2.40*h),0.59);\ntotal_weight+=sampleScreen(col,vec2(-2.88*w,-0.75*h),0.56);\ntotal_weight+=sampleScreen(col,vec2(2.73*w,-1.44*h),0.54);\ntotal_weight+=sampleScreen(col,vec2(-1.08*w,3.02*h),0.52);\ntotal_weight+=sampleScreen(col,vec2(-1.28*w,-3.05*h),0.49);\n}\nif (blur_level>2.0) {\ntotal_weight+=sampleScreen(col,vec2(3.11*w,1.43*h),0.46);\ntotal_weight+=sampleScreen(col,vec2(-3.36*w,1.08*h),0.44);\ntotal_weight+=sampleScreen(col,vec2(1.80*w,-3.16*h),0.41);\ntotal_weight+=sampleScreen(col,vec2(0.83*w,3.65*h),0.38);\ntotal_weight+=sampleScreen(col,vec2(-3.16*w,-2.19*h),0.34);\ntotal_weight+=sampleScreen(col,vec2(3.92*w,-0.53*h),0.31);\ntotal_weight+=sampleScreen(col,vec2(-2.59*w,3.12*h),0.26);\ntotal_weight+=sampleScreen(col,vec2(-0.20*w,-4.15*h),0.22);\ntotal_weight+=sampleScreen(col,vec2(3.02*w,3.00*h),0.15);\n}\ncol/=total_weight; \n\nif (darken>0.0) {\ncol.rgb*=clamp(0.3,1.0,1.05-size*0.5*darken);\n}\n\n\n\n\nreturn col;\n}\nvoid main(void)\n{\n\ncentered_screen_pos=vec2(vUV.x-0.5,vUV.y-0.5);\nradius2=centered_screen_pos.x*centered_screen_pos.x+centered_screen_pos.y*centered_screen_pos.y;\nradius=sqrt(radius2);\ndistorted_coords=getDistortedCoords(vUV); \nvec2 texels_coords=vec2(vUV.x*screen_width,vUV.y*screen_height); \nfloat depth=texture2D(depthSampler,distorted_coords).r; \nfloat distance=near+(far-near)*depth; \nvec4 color=texture2D(textureSampler,vUV); \n\n\nfloat coc=abs(aperture*(screen_distance*(inverse_focal_length-1.0/distance)-1.0));\n\nif (dof_enabled == false || coc<0.07) { coc=0.0; }\n\nfloat edge_blur_amount=0.0;\nif (edge_blur>0.0) {\nedge_blur_amount=clamp((radius*2.0-1.0+0.15*edge_blur)*1.5,0.0,1.0)*1.3;\n}\n\nfloat blur_amount=max(edge_blur_amount,coc);\n\nif (blur_amount == 0.0) {\ngl_FragColor=texture2D(textureSampler,distorted_coords);\n}\nelse {\n\ngl_FragColor=getBlurColor(blur_amount*1.7);\n\nif (highlights) {\ngl_FragColor.rgb+=clamp(coc,0.0,1.0)*texture2D(highlightsSampler,distorted_coords).rgb;\n}\nif (blur_noise) {\n\nvec2 noise=rand(distorted_coords)*0.01*blur_amount;\nvec2 blurred_coord=vec2(distorted_coords.x+noise.x,distorted_coords.y+noise.y);\ngl_FragColor=0.04*texture2D(textureSampler,blurred_coord)+0.96*gl_FragColor;\n}\n}\n\nif (grain_amount>0.0) {\nvec4 grain_color=texture2D(grainSampler,texels_coords*0.003);\ngl_FragColor.rgb+=(-0.5+grain_color.rgb)*0.30*grain_amount;\n}\n}\n",displayPassPixelShader:"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform sampler2D passSampler;\nvoid main(void)\n{\ngl_FragColor=texture2D(passSampler,vUV);\n}",ellipse2dPixelShader:"varying vec4 vColor;\nvoid main(void) {\ngl_FragColor=vColor;\n}",ellipse2dVertexShader:"\n#ifdef Instanced\n#define att attribute\n#else\n#define att uniform\n#endif\nattribute float index;\natt vec2 zBias;\natt vec4 transformX;\natt vec4 transformY;\n#ifdef Border\natt float borderThickness;\n#endif\n#ifdef FillSolid\natt vec4 fillSolidColor;\n#endif\n#ifdef BorderSolid\natt vec4 borderSolidColor;\n#endif\n#ifdef FillGradient\natt vec4 fillGradientColor1;\natt vec4 fillGradientColor2;\natt vec4 fillGradientTY;\n#endif\n#ifdef BorderGradient\natt vec4 borderGradientColor1;\natt vec4 borderGradientColor2;\natt vec4 borderGradientTY;\n#endif\n\natt vec3 properties;\n#define TWOPI 6.28318530\n\nvarying vec2 vUV;\nvarying vec4 vColor;\nvoid main(void) {\nvec2 pos2;\n#ifdef Border\nfloat w=properties.x;\nfloat h=properties.y;\nfloat ms=properties.z;\nvec2 borderOffset=vec2(1.0,1.0);\nfloat segi=index;\nif (index<ms) {\nborderOffset=vec2(1.0-(borderThickness*2.0/w),1.0-(borderThickness*2.0/h));\n}\nelse {\nsegi-=ms;\n}\nfloat angle=TWOPI*segi/ms;\npos2.x=(cos(angle)/2.0)+0.5;\npos2.y=(sin(angle)/2.0)+0.5;\npos2.x=((pos2.x-0.5)*borderOffset.x)+0.5;\npos2.y=((pos2.y-0.5)*borderOffset.y)+0.5;\n#else\nif (index == 0.0) {\npos2=vec2(0.5,0.5);\n}\nelse {\nfloat ms=properties.z;\nfloat angle=TWOPI*(index-1.0)/ms;\npos2.x=(cos(angle)/2.0)+0.5;\npos2.y=(sin(angle)/2.0)+0.5;\n}\n#endif\n#ifdef FillSolid\nvColor=fillSolidColor;\n#endif\n#ifdef BorderSolid\nvColor=borderSolidColor;\n#endif\n#ifdef FillGradient\nfloat v=dot(vec4(pos2.xy,1,1),fillGradientTY);\nvColor=mix(fillGradientColor2,fillGradientColor1,v); \n#endif\n#ifdef BorderGradient\nfloat v=dot(vec4(pos2.xy,1,1),borderGradientTY);\nvColor=mix(borderGradientColor2,borderGradientColor1,v); \n#endif\nvec4 pos;\npos.xy=pos2.xy*properties.xy;\npos.z=1.0;\npos.w=1.0;\ngl_Position=vec4(dot(pos,transformX),dot(pos,transformY),zBias.x,1);\n}",filterPixelShader:"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform mat4 kernelMatrix;\nvoid main(void)\n{\nvec3 baseColor=texture2D(textureSampler,vUV).rgb;\nvec3 updatedColor=(kernelMatrix*vec4(baseColor,1.0)).rgb;\ngl_FragColor=vec4(updatedColor,1.0);\n}",fxaaPixelShader:"#define FXAA_REDUCE_MIN (1.0/128.0)\n#define FXAA_REDUCE_MUL (1.0/8.0)\n#define FXAA_SPAN_MAX 8.0\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform vec2 texelSize;\nvoid main(){\nvec2 localTexelSize=texelSize;\nvec4 rgbNW=texture2D(textureSampler,(vUV+vec2(-1.0,-1.0)*localTexelSize));\nvec4 rgbNE=texture2D(textureSampler,(vUV+vec2(1.0,-1.0)*localTexelSize));\nvec4 rgbSW=texture2D(textureSampler,(vUV+vec2(-1.0,1.0)*localTexelSize));\nvec4 rgbSE=texture2D(textureSampler,(vUV+vec2(1.0,1.0)*localTexelSize));\nvec4 rgbM=texture2D(textureSampler,vUV);\nvec4 luma=vec4(0.299,0.587,0.114,1.0);\nfloat lumaNW=dot(rgbNW,luma);\nfloat lumaNE=dot(rgbNE,luma);\nfloat lumaSW=dot(rgbSW,luma);\nfloat lumaSE=dot(rgbSE,luma);\nfloat lumaM=dot(rgbM,luma);\nfloat lumaMin=min(lumaM,min(min(lumaNW,lumaNE),min(lumaSW,lumaSE)));\nfloat lumaMax=max(lumaM,max(max(lumaNW,lumaNE),max(lumaSW,lumaSE)));\nvec2 dir=vec2(-((lumaNW+lumaNE)-(lumaSW+lumaSE)),((lumaNW+lumaSW)-(lumaNE+lumaSE)));\nfloat dirReduce=max(\n(lumaNW+lumaNE+lumaSW+lumaSE)*(0.25*FXAA_REDUCE_MUL),\nFXAA_REDUCE_MIN);\nfloat rcpDirMin=1.0/(min(abs(dir.x),abs(dir.y))+dirReduce);\ndir=min(vec2(FXAA_SPAN_MAX,FXAA_SPAN_MAX),\nmax(vec2(-FXAA_SPAN_MAX,-FXAA_SPAN_MAX),\ndir*rcpDirMin))*localTexelSize;\nvec4 rgbA=0.5*(\ntexture2D(textureSampler,vUV+dir*(1.0/3.0-0.5)) +\ntexture2D(textureSampler,vUV+dir*(2.0/3.0-0.5)));\nvec4 rgbB=rgbA*0.5+0.25*(\ntexture2D(textureSampler,vUV+dir*-0.5) +\ntexture2D(textureSampler,vUV+dir*0.5));\nfloat lumaB=dot(rgbB,luma);\nif ((lumaB<lumaMin) || (lumaB>lumaMax)) {\ngl_FragColor=rgbA;\n}\nelse {\ngl_FragColor=rgbB;\n}\n}",hdrPixelShader:"uniform sampler2D textureSampler;\nvarying vec2 vUV;\n#if defined(GAUSSIAN_BLUR_H) || defined(GAUSSIAN_BLUR_V)\nuniform float blurOffsets[9];\nuniform float blurWeights[9];\nuniform float multiplier;\nvoid main(void) {\nvec4 color=vec4(0.0,0.0,0.0,0.0);\nfor (int i=0; i<9; i++) {\n#ifdef GAUSSIAN_BLUR_H\ncolor+=(texture2D(textureSampler,vUV+vec2(blurOffsets[i]*multiplier,0.0))*blurWeights[i]);\n#else\ncolor+=(texture2D(textureSampler,vUV+vec2(0.0,blurOffsets[i]*multiplier))*blurWeights[i]);\n#endif\n}\ncolor.a=1.0;\ngl_FragColor=color;\n}\n#endif\n#if defined(TEXTURE_ADDER)\nuniform sampler2D otherSampler;\nvoid main() {\nvec4 sum=texture2D(textureSampler,vUV)+texture2D(otherSampler,vUV);\nsum.a=clamp(sum.a,0.0,1.0);\ngl_FragColor=sum;\n}\n#endif\n#if defined(LUMINANCE_GENERATOR)\nuniform vec2 lumOffsets[4];\nvoid main() {\nfloat average=0.0;\nvec4 color=vec4(0.0,0.0,0.0,0.0);\nfloat maximum=-1e20;\nfor (int i=0; i<4; i++) {\ncolor=texture2D(textureSampler,vUV+lumOffsets[i]);\nfloat GreyValue=length(color.rgb);\nmaximum=max(maximum,GreyValue);\naverage+=(0.25*log(1e-5+GreyValue));\n}\naverage=exp(average);\ngl_FragColor=vec4(average,maximum,0.0,1.0);\n}\n#endif\n#if defined(DOWN_SAMPLE)\nuniform vec2 dsOffsets[9];\nuniform float halfDestPixelSize;\n#ifdef FINAL_DOWN_SAMPLE\nvec4 pack(float value) {\nconst vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);\nconst vec4 bit_mask=vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);\nvec4 res=fract(value*bit_shift);\nres-=res.xxyz*bit_mask;\nreturn res;\n}\n#endif\nvoid main() {\nvec4 color=vec4(0.0,0.0,0.0,0.0);\nfloat average=0.0;\nfor (int i=0; i<9; i++) {\ncolor=texture2D(textureSampler,vUV+vec2(halfDestPixelSize,halfDestPixelSize)+dsOffsets[i]);\naverage+=color.r;\n}\naverage/=9.0;\n#ifndef FINAL_DOWN_SAMPLE\ngl_FragColor=vec4(average,average,0.0,1.0);\n#else\ngl_FragColor=pack(average);\n#endif\n}\n#endif\n#if defined(BRIGHT_PASS)\nuniform vec2 dsOffsets[4];\nuniform float brightThreshold;\nvoid main() {\nvec4 average=vec4(0.0,0.0,0.0,0.0);\naverage=texture2D(textureSampler,vUV+vec2(dsOffsets[0].x,dsOffsets[0].y));\naverage+=texture2D(textureSampler,vUV+vec2(dsOffsets[1].x,dsOffsets[1].y));\naverage+=texture2D(textureSampler,vUV+vec2(dsOffsets[2].x,dsOffsets[2].y));\naverage+=texture2D(textureSampler,vUV+vec2(dsOffsets[3].x,dsOffsets[3].y));\naverage*=0.25;\nfloat luminance=length(average.rgb);\nif (luminance<brightThreshold) {\naverage=vec4(0.0,0.0,0.0,1.0);\n}\ngl_FragColor=average;\n}\n#endif\n#if defined(DOWN_SAMPLE_X4)\nuniform vec2 dsOffsets[16];\nvoid main() {\nvec4 average=vec4(0.0,0.0,0.0,0.0);\naverage=texture2D(textureSampler,vUV+dsOffsets[0]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[1]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[2]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[3]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[4]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[5]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[6]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[7]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[8]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[9]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[10]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[11]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[12]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[13]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[14]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[15]);\naverage/=16.0;\ngl_FragColor=average;\n}\n#endif\n#if defined(HDR)\nuniform sampler2D otherSampler;\nuniform float exposure;\nuniform float avgLuminance;\nvoid main() {\nvec4 color=texture2D(textureSampler,vUV)+texture2D(otherSampler,vUV);\nvec4 adjustedColor=color/avgLuminance*exposure;\ncolor=adjustedColor;\ncolor.a=1.0;\ngl_FragColor=color;\n}\n#endif\n",layerPixelShader:"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n\nuniform vec4 color;\nvoid main(void) {\nvec4 baseColor=texture2D(textureSampler,vUV);\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\ngl_FragColor=baseColor*color;\n}",layerVertexShader:"\nattribute vec2 position;\n\nuniform vec2 scale;\nuniform vec2 offset;\nuniform mat4 textureMatrix;\n\nvarying vec2 vUV;\nconst vec2 madd=vec2(0.5,0.5);\nvoid main(void) { \nvec2 shiftedPosition=position*scale+offset;\nvUV=vec2(textureMatrix*vec4(shiftedPosition*madd+madd,1.0,0.0));\ngl_Position=vec4(shiftedPosition,0.0,1.0);\n}",legacydefaultPixelShader:"#define MAP_PROJECTION 4.\n\nuniform vec3 vEyePosition;\nuniform vec3 vAmbientColor;\nuniform vec4 vDiffuseColor;\n#ifdef SPECULARTERM\nuniform vec4 vSpecularColor;\n#endif\nuniform vec3 vEmissiveColor;\n\nvarying vec3 vPositionW;\nvarying vec3 vNormalW;\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n\n#include<lightFragmentDeclaration>[0..3]\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\nuniform sampler2D diffuseSampler;\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef AMBIENT\nvarying vec2 vAmbientUV;\nuniform sampler2D ambientSampler;\nuniform vec2 vAmbientInfos;\n#endif\n#ifdef OPACITY \nvarying vec2 vOpacityUV;\nuniform sampler2D opacitySampler;\nuniform vec2 vOpacityInfos;\n#endif\n#ifdef REFLECTION\nvarying vec3 vReflectionUVW;\n#ifdef REFLECTIONMAP_3D\nuniform samplerCube reflectionCubeSampler;\n#else\nuniform sampler2D reflection2DSampler;\n#endif\nuniform vec2 vReflectionInfos;\n#endif\n#ifdef EMISSIVE\nvarying vec2 vEmissiveUV;\nuniform vec2 vEmissiveInfos;\nuniform sampler2D emissiveSampler;\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM)\nvarying vec2 vSpecularUV;\nuniform vec2 vSpecularInfos;\nuniform sampler2D specularSampler;\n#endif\n\n#include<fresnelFunction>\n#ifdef DIFFUSEFRESNEL\nuniform vec4 diffuseLeftColor;\nuniform vec4 diffuseRightColor;\n#endif\n#ifdef OPACITYFRESNEL\nuniform vec4 opacityParts;\n#endif\n#ifdef REFLECTIONFRESNEL\nuniform vec4 reflectionLeftColor;\nuniform vec4 reflectionRightColor;\n#endif\n#ifdef EMISSIVEFRESNEL\nuniform vec4 emissiveLeftColor;\nuniform vec4 emissiveRightColor;\n#endif\n#include<clipPlaneFragmentDeclaration>\n#include<fogFragmentDeclaration>\nvoid main(void) {\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\nvec4 baseColor=vec4(1.,1.,1.,1.);\nvec3 diffuseColor=vDiffuseColor.rgb;\n#ifdef DIFFUSE\nbaseColor=texture2D(diffuseSampler,vDiffuseUV);\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\nbaseColor.rgb*=vDiffuseInfos.y;\n#endif\n#ifdef VERTEXCOLOR\nbaseColor.rgb*=vColor.rgb;\n#endif\n\nvec3 normalW=normalize(vNormalW);\n\nvec3 baseAmbientColor=vec3(1.,1.,1.);\n#ifdef AMBIENT\nbaseAmbientColor=texture2D(ambientSampler,vAmbientUV).rgb*vAmbientInfos.y;\n#endif\n\nvec3 diffuseBase=vec3(0.,0.,0.);\nlightingInfo info;\nfloat glossiness=0.;\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\nglossiness=vSpecularColor.a;\n#endif\nfloat shadow=1.;\n#include<lightFragment>[0..3]\n\nvec3 reflectionColor=vec3(0.,0.,0.);\n#ifdef REFLECTION\n#ifdef REFLECTIONMAP_3D\nreflectionColor=textureCube(reflectionCubeSampler,vReflectionUVW).rgb*vReflectionInfos.x;\n#else\nvec2 coords=vReflectionUVW.xy;\n#ifdef REFLECTIONMAP_PROJECTION\ncoords/=vReflectionUVW.z;\n#endif\ncoords.y=1.0-coords.y;\nreflectionColor=texture2D(reflection2DSampler,coords).rgb*vReflectionInfos.x;\n#endif\n#ifdef REFLECTIONFRESNEL\nfloat reflectionFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,reflectionRightColor.a,reflectionLeftColor.a);\nreflectionColor*=reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;\n#endif\n#endif\n\nfloat alpha=vDiffuseColor.a;\n#ifdef OPACITY\nvec4 opacityMap=texture2D(opacitySampler,vOpacityUV);\n#ifdef OPACITYRGB\nopacityMap.rgb=opacityMap.rgb*vec3(0.3,0.59,0.11);\nalpha*=(opacityMap.x+opacityMap.y+opacityMap.z)* vOpacityInfos.y;\n#else\nalpha*=opacityMap.a*vOpacityInfos.y;\n#endif\n#endif\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n#ifdef OPACITYFRESNEL\nfloat opacityFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,opacityParts.z,opacityParts.w);\nalpha+=opacityParts.x*(1.0-opacityFresnelTerm)+opacityFresnelTerm*opacityParts.y;\n#endif\n\nvec3 emissiveColor=vEmissiveColor;\n#ifdef EMISSIVE\nemissiveColor+=texture2D(emissiveSampler,vEmissiveUV).rgb*vEmissiveInfos.y;\n#endif\n#ifdef EMISSIVEFRESNEL\nfloat emissiveFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,emissiveRightColor.a,emissiveLeftColor.a);\nemissiveColor*=emissiveLeftColor.rgb*(1.0-emissiveFresnelTerm)+emissiveFresnelTerm*emissiveRightColor.rgb;\n#endif\n\n#ifdef SPECULARTERM\nvec3 specularColor=vSpecularColor.rgb;\n#ifdef SPECULAR\nspecularColor=texture2D(specularSampler,vSpecularUV).rgb*vSpecularInfos.y;\n#endif\n#endif\n\n#ifdef DIFFUSEFRESNEL\nfloat diffuseFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,diffuseRightColor.a,diffuseLeftColor.a);\ndiffuseBase*=diffuseLeftColor.rgb*(1.0-diffuseFresnelTerm)+diffuseFresnelTerm*diffuseRightColor.rgb;\n#endif\n\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor+emissiveColor+vAmbientColor,0.0,1.0)*baseColor.rgb;\n#ifdef SPECULARTERM\nvec3 finalSpecular=specularBase*specularColor;\n#else\nvec3 finalSpecular=vec3(0.0);\n#endif\nvec4 color=vec4(finalDiffuse*baseAmbientColor+finalSpecular+reflectionColor,alpha);\n#include<fogFragment>\ngl_FragColor=color;\n}",legacydefaultVertexShader:"\nattribute vec3 position;\nattribute vec3 normal;\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<bonesDeclaration>\n\nuniform mat4 world;\nuniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\nuniform mat4 diffuseMatrix;\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef AMBIENT\nvarying vec2 vAmbientUV;\nuniform mat4 ambientMatrix;\nuniform vec2 vAmbientInfos;\n#endif\n#ifdef OPACITY\nvarying vec2 vOpacityUV;\nuniform mat4 opacityMatrix;\nuniform vec2 vOpacityInfos;\n#endif\n#ifdef EMISSIVE\nvarying vec2 vEmissiveUV;\nuniform vec2 vEmissiveInfos;\nuniform mat4 emissiveMatrix;\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM)\nvarying vec2 vSpecularUV;\nuniform vec2 vSpecularInfos;\nuniform mat4 specularMatrix;\n#endif\n#ifdef BUMP\nvarying vec2 vBumpUV;\nuniform vec2 vBumpInfos;\nuniform mat4 bumpMatrix;\n#endif\n\nvarying vec3 vPositionW;\nvarying vec3 vNormalW;\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<shadowsVertexDeclaration>[0..maxSimultaneousLights]\n#ifdef REFLECTION\nuniform vec3 vEyePosition;\nvarying vec3 vReflectionUVW;\nuniform mat4 reflectionMatrix;\nvec3 computeReflectionCoords(vec4 worldPos,vec3 worldNormal)\n{\n#ifdef REFLECTIONMAP_SPHERICAL\nvec3 coords=vec3(view*vec4(worldNormal,0.0));\nreturn vec3(reflectionMatrix*vec4(coords,1.0));\n#endif\n#ifdef REFLECTIONMAP_PLANAR\nvec3 viewDir=worldPos.xyz-vEyePosition;\nvec3 coords=normalize(reflect(viewDir,worldNormal));\nreturn vec3(reflectionMatrix*vec4(coords,1));\n#endif\n#ifdef REFLECTIONMAP_CUBIC\nvec3 viewDir=worldPos.xyz-vEyePosition;\nvec3 coords=reflect(viewDir,worldNormal);\n#ifdef INVERTCUBICMAP\ncoords.y=1.0-coords.y;\n#endif\nreturn vec3(reflectionMatrix*vec4(coords,0));\n#endif\n#ifdef REFLECTIONMAP_PROJECTION\nreturn vec3(reflectionMatrix*(view*worldPos));\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nreturn position;\n#endif\n#ifdef REFLECTIONMAP_EXPLICIT\nreturn vec3(0,0,0);\n#endif\n}\n#endif\nvoid main(void) {\nmat4 finalWorld=world;\n#include<bonesVertex>\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\nvec4 worldPos=finalWorld*vec4(position,1.0);\nvPositionW=vec3(worldPos);\nvNormalW=normalize(vec3(finalWorld*vec4(normal,0.0)));\n\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef DIFFUSE\nif (vDiffuseInfos.x == 0.)\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#ifdef AMBIENT\nif (vAmbientInfos.x == 0.)\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#ifdef OPACITY\nif (vOpacityInfos.x == 0.)\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#ifdef REFLECTION\nvReflectionUVW=computeReflectionCoords(vec4(vPositionW,1.0),vNormalW);\n#endif\n#ifdef EMISSIVE\nif (vEmissiveInfos.x == 0.)\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM)\nif (vSpecularInfos.x == 0.)\n{\nvSpecularUV=vec2(specularMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvSpecularUV=vec2(specularMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#ifdef BUMP\nif (vBumpInfos.x == 0.)\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#include<clipPlaneVertex>\n#include<fogVertex>\n#include<shadowsVertex>[0..maxSimultaneousLights]\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n}",legacypbrPixelShader:"precision mediump float;\n\n#define RECIPROCAL_PI2 0.15915494\n#define FRESNEL_MAXIMUM_ON_ROUGH 0.25\nuniform vec3 vEyePosition;\nuniform vec3 vAmbientColor;\nuniform vec4 vAlbedoColor;\nuniform vec3 vReflectionColor;\n\nuniform vec4 vLightingIntensity;\nuniform vec4 vCameraInfos;\n#ifdef OVERLOADEDVALUES\nuniform vec4 vOverloadedIntensity;\nuniform vec3 vOverloadedAmbient;\nuniform vec3 vOverloadedAlbedo;\nuniform vec3 vOverloadedReflectivity;\nuniform vec3 vOverloadedEmissive;\nuniform vec3 vOverloadedReflection;\nuniform vec3 vOverloadedMicroSurface;\n#endif\n#ifdef OVERLOADEDSHADOWVALUES\nuniform vec4 vOverloadedShadowIntensity;\n#endif\nuniform vec4 vReflectivityColor;\nuniform vec3 vEmissiveColor;\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n\n#include<lightFragmentDeclaration>[0..maxSimultaneousLights]\n\n#ifdef ALBEDO\nvarying vec2 vAlbedoUV;\nuniform sampler2D albedoSampler;\nuniform vec2 vAlbedoInfos;\n#endif\n#ifdef AMBIENT\nvarying vec2 vAmbientUV;\nuniform sampler2D ambientSampler;\nuniform vec2 vAmbientInfos;\n#endif\n#ifdef OPACITY \nvarying vec2 vOpacityUV;\nuniform sampler2D opacitySampler;\nuniform vec2 vOpacityInfos;\n#endif\n#ifdef EMISSIVE\nvarying vec2 vEmissiveUV;\nuniform vec2 vEmissiveInfos;\nuniform sampler2D emissiveSampler;\n#endif\n#ifdef LIGHTMAP\nvarying vec2 vLightmapUV;\nuniform vec2 vLightmapInfos;\nuniform sampler2D lightmapSampler;\n#endif\n#if defined(REFLECTIVITY)\nvarying vec2 vReflectivityUV;\nuniform vec2 vReflectivityInfos;\nuniform sampler2D reflectivitySampler;\n#endif\n#include<clipPlaneFragmentDeclaration>\n#ifdef CAMERACOLORGRADING\nuniform sampler2D cameraColorGrading2DSampler;\nuniform vec4 vCameraColorGradingInfos;\nuniform vec4 vCameraColorGradingScaleOffset;\n#endif\n\n#include<pbrFunctions>\n#include<harmonicsFunctions>\n#include<pbrLightFunctions>\nvoid main(void) {\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\nvec4 surfaceAlbedo=vec4(1.,1.,1.,1.);\nvec3 surfaceAlbedoContribution=vAlbedoColor.rgb;\n\nfloat alpha=vAlbedoColor.a;\n#ifdef ALBEDO\nsurfaceAlbedo=texture2D(albedoSampler,vAlbedoUV);\nsurfaceAlbedo=vec4(toLinearSpace(surfaceAlbedo.rgb),surfaceAlbedo.a);\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\n#ifdef ALPHAFROMALBEDO\nalpha*=surfaceAlbedo.a;\n#endif\nsurfaceAlbedo.rgb*=vAlbedoInfos.y;\n#else\n\nsurfaceAlbedo.rgb=surfaceAlbedoContribution;\nsurfaceAlbedoContribution=vec3(1.,1.,1.);\n#endif\n#ifdef VERTEXCOLOR\nbaseColor.rgb*=vColor.rgb;\n#endif\n#ifdef OVERLOADEDVALUES\nsurfaceAlbedo.rgb=mix(surfaceAlbedo.rgb,vOverloadedAlbedo,vOverloadedIntensity.y);\n#endif\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\n\nvec3 ambientColor=vec3(1.,1.,1.);\n#ifdef AMBIENT\nambientColor=texture2D(ambientSampler,vAmbientUV).rgb*vAmbientInfos.y;\n#ifdef OVERLOADEDVALUES\nambientColor.rgb=mix(ambientColor.rgb,vOverloadedAmbient,vOverloadedIntensity.x);\n#endif\n#endif\n\nfloat microSurface=vReflectivityColor.a;\nvec3 surfaceReflectivityColor=vReflectivityColor.rgb;\n#ifdef OVERLOADEDVALUES\nsurfaceReflectivityColor.rgb=mix(surfaceReflectivityColor.rgb,vOverloadedReflectivity,vOverloadedIntensity.z);\n#endif\n#ifdef REFLECTIVITY\nvec4 surfaceReflectivityColorMap=texture2D(reflectivitySampler,vReflectivityUV);\nsurfaceReflectivityColor=surfaceReflectivityColorMap.rgb;\nsurfaceReflectivityColor=toLinearSpace(surfaceReflectivityColor);\n#ifdef OVERLOADEDVALUES\nsurfaceReflectivityColor=mix(surfaceReflectivityColor,vOverloadedReflectivity,vOverloadedIntensity.z);\n#endif\n#ifdef MICROSURFACEFROMREFLECTIVITYMAP\nmicroSurface=surfaceReflectivityColorMap.a;\n#else\n#ifdef MICROSURFACEAUTOMATIC\nmicroSurface=computeDefaultMicroSurface(microSurface,surfaceReflectivityColor);\n#endif\n#endif\n#endif\n#ifdef OVERLOADEDVALUES\nmicroSurface=mix(microSurface,vOverloadedMicroSurface.x,vOverloadedMicroSurface.y);\n#endif\n\nfloat NdotV=max(0.00000000001,dot(normalW,viewDirectionW));\n\nmicroSurface=clamp(microSurface,0.,1.)*0.98;\n\nfloat roughness=clamp(1.-microSurface,0.000001,1.0);\n\nvec3 lightDiffuseContribution=vec3(0.,0.,0.);\n#ifdef OVERLOADEDSHADOWVALUES\nvec3 shadowedOnlyLightDiffuseContribution=vec3(1.,1.,1.);\n#endif\n#ifdef SPECULARTERM\nvec3 lightSpecularContribution= vec3(0.,0.,0.);\n#endif\nfloat notShadowLevel=1.; \nfloat NdotL=-1.;\nlightingInfo info;\n#include<pbrLightFunctionsCall>[0..maxSimultaneousLights]\n#ifdef SPECULARTERM\nlightSpecularContribution*=vLightingIntensity.w;\n#endif\n#ifdef OPACITY\nvec4 opacityMap=texture2D(opacitySampler,vOpacityUV);\n#ifdef OPACITYRGB\nopacityMap.rgb=opacityMap.rgb*vec3(0.3,0.59,0.11);\nalpha*=(opacityMap.x+opacityMap.y+opacityMap.z)* vOpacityInfos.y;\n#else\nalpha*=opacityMap.a*vOpacityInfos.y;\n#endif\n#endif\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n\nvec3 environmentRadiance=vReflectionColor.rgb;\nvec3 environmentIrradiance=vReflectionColor.rgb;\n#ifdef OVERLOADEDVALUES\nenvironmentIrradiance=mix(environmentIrradiance,vOverloadedReflection,vOverloadedMicroSurface.z);\nenvironmentRadiance=mix(environmentRadiance,vOverloadedReflection,vOverloadedMicroSurface.z);\n#endif\nenvironmentRadiance*=vLightingIntensity.z;\nenvironmentIrradiance*=vLightingIntensity.z;\n\nvec3 specularEnvironmentR0=surfaceReflectivityColor.rgb;\nvec3 specularEnvironmentR90=vec3(1.0,1.0,1.0);\nvec3 specularEnvironmentReflectance=FresnelSchlickEnvironmentGGX(clamp(NdotV,0.,1.),specularEnvironmentR0,specularEnvironmentR90,sqrt(microSurface));\n\nfloat reflectance=max(max(surfaceReflectivityColor.r,surfaceReflectivityColor.g),surfaceReflectivityColor.b);\nsurfaceAlbedo.rgb=(1.-reflectance)*surfaceAlbedo.rgb;\nenvironmentRadiance*=specularEnvironmentReflectance;\n\nvec3 surfaceEmissiveColor=vEmissiveColor;\n#ifdef EMISSIVE\nvec3 emissiveColorTex=texture2D(emissiveSampler,vEmissiveUV).rgb;\nsurfaceEmissiveColor=toLinearSpace(emissiveColorTex.rgb)*surfaceEmissiveColor*vEmissiveInfos.y;\n#endif\n#ifdef OVERLOADEDVALUES\nsurfaceEmissiveColor=mix(surfaceEmissiveColor,vOverloadedEmissive,vOverloadedIntensity.w);\n#endif\n\n#ifdef EMISSIVEASILLUMINATION\nvec3 finalDiffuse=max(lightDiffuseContribution*surfaceAlbedoContribution+vAmbientColor,0.0)*surfaceAlbedo.rgb;\n#ifdef OVERLOADEDSHADOWVALUES\nshadowedOnlyLightDiffuseContribution=max(shadowedOnlyLightDiffuseContribution*surfaceAlbedoContribution+vAmbientColor,0.0)*surfaceAlbedo.rgb;\n#endif\n#else\n#ifdef LINKEMISSIVEWITHALBEDO\nvec3 finalDiffuse=max((lightDiffuseContribution+surfaceEmissiveColor)*surfaceAlbedoContribution+vAmbientColor,0.0)*surfaceAlbedo.rgb;\n#ifdef OVERLOADEDSHADOWVALUES\nshadowedOnlyLightDiffuseContribution=max((shadowedOnlyLightDiffuseContribution+surfaceEmissiveColor)*surfaceAlbedoContribution+vAmbientColor,0.0)*surfaceAlbedo.rgb;\n#endif\n#else\nvec3 finalDiffuse=max(lightDiffuseContribution*surfaceAlbedoContribution+surfaceEmissiveColor+vAmbientColor,0.0)*surfaceAlbedo.rgb;\n#ifdef OVERLOADEDSHADOWVALUES\nshadowedOnlyLightDiffuseContribution=max(shadowedOnlyLightDiffuseContribution*surfaceAlbedoContribution+surfaceEmissiveColor+vAmbientColor,0.0)*surfaceAlbedo.rgb;\n#endif\n#endif\n#endif\n#ifdef OVERLOADEDSHADOWVALUES\nfinalDiffuse=mix(finalDiffuse,shadowedOnlyLightDiffuseContribution,(1.0-vOverloadedShadowIntensity.y));\n#endif\n#ifdef SPECULARTERM\nvec3 finalSpecular=lightSpecularContribution*surfaceReflectivityColor;\n#else\nvec3 finalSpecular=vec3(0.0);\n#endif\n#ifdef SPECULAROVERALPHA\nalpha=clamp(alpha+getLuminance(finalSpecular),0.,1.);\n#endif\n#ifdef RADIANCEOVERALPHA\nalpha=clamp(alpha+getLuminance(environmentRadiance),0.,1.);\n#endif\n\n\n#ifdef EMISSIVEASILLUMINATION\nvec4 finalColor=vec4(finalDiffuse*ambientColor*vLightingIntensity.x+surfaceAlbedo.rgb*environmentIrradiance+finalSpecular*vLightingIntensity.x+environmentRadiance+surfaceEmissiveColor*vLightingIntensity.y,alpha);\n#else\nvec4 finalColor=vec4(finalDiffuse*ambientColor*vLightingIntensity.x+surfaceAlbedo.rgb*environmentIrradiance+finalSpecular*vLightingIntensity.x+environmentRadiance,alpha);\n#endif\nfinalColor=max(finalColor,0.0);\n#ifdef CAMERATONEMAP\nfinalColor.rgb=toneMaps(finalColor.rgb);\n#endif\nfinalColor.rgb=toGammaSpace(finalColor.rgb);\n#ifdef CAMERACONTRAST\nfinalColor=contrasts(finalColor);\n#endif\nfinalColor.rgb=clamp(finalColor.rgb,0.,1.);\n#ifdef CAMERACOLORGRADING\nfinalColor=colorGrades(finalColor,cameraColorGrading2DSampler,vCameraColorGradingInfos,vCameraColorGradingScaleOffset);\n#endif\ngl_FragColor=finalColor;\n}",
  38. legacypbrVertexShader:"precision mediump float;\n\nattribute vec3 position;\nattribute vec3 normal;\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<bonesDeclaration>\n\nuniform mat4 world;\nuniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef ALBEDO\nvarying vec2 vAlbedoUV;\nuniform mat4 albedoMatrix;\nuniform vec2 vAlbedoInfos;\n#endif\n#ifdef AMBIENT\nvarying vec2 vAmbientUV;\nuniform mat4 ambientMatrix;\nuniform vec2 vAmbientInfos;\n#endif\n#ifdef OPACITY\nvarying vec2 vOpacityUV;\nuniform mat4 opacityMatrix;\nuniform vec2 vOpacityInfos;\n#endif\n#ifdef EMISSIVE\nvarying vec2 vEmissiveUV;\nuniform vec2 vEmissiveInfos;\nuniform mat4 emissiveMatrix;\n#endif\n#if defined(REFLECTIVITY)\nvarying vec2 vReflectivityUV;\nuniform vec2 vReflectivityInfos;\nuniform mat4 reflectivityMatrix;\n#endif\n\nvarying vec3 vPositionW;\nvarying vec3 vNormalW;\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\nvoid main(void) {\nmat4 finalWorld=world;\n#include<bonesVertex>\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\nvec4 worldPos=finalWorld*vec4(position,1.0);\nvPositionW=vec3(worldPos);\nvNormalW=normalize(vec3(finalWorld*vec4(normal,0.0)));\n\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef ALBEDO\nif (vAlbedoInfos.x == 0.)\n{\nvAlbedoUV=vec2(albedoMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvAlbedoUV=vec2(albedoMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#ifdef AMBIENT\nif (vAmbientInfos.x == 0.)\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#ifdef OPACITY\nif (vOpacityInfos.x == 0.)\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#ifdef EMISSIVE\nif (vEmissiveInfos.x == 0.)\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(REFLECTIVITY)\nif (vReflectivityInfos.x == 0.)\n{\nvReflectivityUV=vec2(reflectivityMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvReflectivityUV=vec2(reflectivityMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#include<clipPlaneVertex>\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n}",lensFlarePixelShader:"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n\nuniform vec4 color;\nvoid main(void) {\nvec4 baseColor=texture2D(textureSampler,vUV);\ngl_FragColor=baseColor*color;\n}",lensFlareVertexShader:"\nattribute vec2 position;\n\nuniform mat4 viewportMatrix;\n\nvarying vec2 vUV;\nconst vec2 madd=vec2(0.5,0.5);\nvoid main(void) { \nvUV=position*madd+madd;\ngl_Position=viewportMatrix*vec4(position,0.0,1.0);\n}",lensHighlightsPixelShader:"\nuniform sampler2D textureSampler; \n\nuniform float gain;\nuniform float threshold;\nuniform float screen_width;\nuniform float screen_height;\n\nvarying vec2 vUV;\n\nvec4 highlightColor(vec4 color) {\nvec4 highlight=color;\nfloat luminance=dot(highlight.rgb,vec3(0.2125,0.7154,0.0721));\nfloat lum_threshold;\nif (threshold>1.0) { lum_threshold=0.94+0.01*threshold; }\nelse { lum_threshold=0.5+0.44*threshold; }\nluminance=clamp((luminance-lum_threshold)*(1.0/(1.0-lum_threshold)),0.0,1.0);\nhighlight*=luminance*gain;\nhighlight.a=1.0;\nreturn highlight;\n}\nvoid main(void)\n{\nvec4 original=texture2D(textureSampler,vUV);\n\nif (gain == -1.0) {\ngl_FragColor=vec4(0.0,0.0,0.0,1.0);\nreturn;\n}\nfloat w=2.0/screen_width;\nfloat h=2.0/screen_height;\nfloat weight=1.0;\n\nvec4 blurred=vec4(0.0,0.0,0.0,0.0);\n#ifdef PENTAGON\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.84*w,0.43*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.48*w,-1.29*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.61*w,1.51*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.55*w,-0.74*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.71*w,-0.52*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.94*w,1.59*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.40*w,-1.87*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.62*w,1.16*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.09*w,0.25*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.46*w,-1.71*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.08*w,2.42*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.85*w,-1.89*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.89*w,0.16*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.29*w,1.88*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.40*w,-2.81*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.54*w,2.26*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.60*w,-0.61*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.31*w,-1.30*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.83*w,2.53*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.12*w,-2.48*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.60*w,1.11*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.82*w,0.99*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.50*w,-2.81*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.85*w,3.33*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.94*w,-1.92*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.27*w,-0.53*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.95*w,2.48*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.23*w,-3.04*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.17*w,2.05*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.97*w,-0.04*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.25*w,-2.00*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.31*w,3.08*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.94*w,-2.59*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.37*w,0.64*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-3.13*w,1.93*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.03*w,-3.65*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.60*w,3.17*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-3.14*w,-1.19*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.00*w,-1.19*h)));\n#else\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.85*w,0.36*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.52*w,-1.14*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.46*w,1.42*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.46*w,-0.83*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.79*w,-0.42*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.11*w,1.62*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.29*w,-2.07*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.69*w,1.39*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.28*w,0.12*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.65*w,-1.69*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.08*w,2.44*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.63*w,-1.90*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.55*w,0.31*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.13*w,1.52*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.56*w,-2.61*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.38*w,2.34*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.64*w,-0.81*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.53*w,-1.21*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.06*w,2.63*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.00*w,-2.69*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.59*w,1.32*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.82*w,0.78*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.57*w,-2.50*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.54*w,2.93*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.39*w,-1.81*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.01*w,-0.28*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.04*w,2.25*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.02*w,-3.05*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.09*w,2.25*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-3.07*w,-0.25*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.44*w,-1.90*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.52*w,3.05*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.68*w,-2.61*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.01*w,0.79*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.76*w,1.46*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.05*w,-2.94*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.21*w,2.88*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.84*w,-1.30*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.98*w,-0.96*h)));\n#endif\nblurred/=39.0;\ngl_FragColor=blurred;\n\n}",linePixelShader:"uniform vec4 color;\nvoid main(void) {\ngl_FragColor=color;\n}",lineVertexShader:"\nattribute vec3 position;\nattribute vec4 normal;\n\nuniform mat4 worldViewProjection;\nuniform float width;\nuniform float aspectRatio;\nvoid main(void) {\nvec4 viewPosition=worldViewProjection*vec4(position,1.0);\nvec4 viewPositionNext=worldViewProjection*vec4(normal.xyz,1.0);\nvec2 currentScreen=viewPosition.xy/viewPosition.w;\nvec2 nextScreen=viewPositionNext.xy/viewPositionNext.w;\ncurrentScreen.x*=aspectRatio;\nnextScreen.x*=aspectRatio;\nvec2 dir=normalize(nextScreen-currentScreen);\nvec2 normalDir=vec2(-dir.y,dir.x);\nnormalDir*=width/2.0;\nnormalDir.x/=aspectRatio;\nvec4 offset=vec4(normalDir*normal.w,0.0,0.0);\ngl_Position=viewPosition+offset;\n}",lines2dPixelShader:"varying vec4 vColor;\nvoid main(void) {\ngl_FragColor=vColor;\n}",lines2dVertexShader:"\n#ifdef Instanced\n#define att attribute\n#else\n#define att uniform\n#endif\nattribute vec2 position;\natt vec2 zBias;\natt vec4 transformX;\natt vec4 transformY;\n#ifdef FillSolid\natt vec4 fillSolidColor;\n#endif\n#ifdef BorderSolid\natt vec4 borderSolidColor;\n#endif\n#ifdef FillGradient\natt vec2 boundingMin;\natt vec2 boundingMax;\natt vec4 fillGradientColor1;\natt vec4 fillGradientColor2;\natt vec4 fillGradientTY;\n#endif\n#ifdef BorderGradient\natt vec4 borderGradientColor1;\natt vec4 borderGradientColor2;\natt vec4 borderGradientTY;\n#endif\n#define TWOPI 6.28318530\n\nvarying vec2 vUV;\nvarying vec4 vColor;\nvoid main(void) {\n#ifdef FillSolid\nvColor=fillSolidColor;\n#endif\n#ifdef BorderSolid\nvColor=borderSolidColor;\n#endif\n#ifdef FillGradient\nfloat v=dot(vec4((position.xy-boundingMin)/(boundingMax-boundingMin),1,1),fillGradientTY);\nvColor=mix(fillGradientColor2,fillGradientColor1,v); \n#endif\n#ifdef BorderGradient\nfloat v=dot(vec4((position.xy-boundingMin)/(boundingMax-boundingMin),1,1),borderGradientTY);\nvColor=mix(borderGradientColor2,borderGradientColor1,v); \n#endif\nvec4 pos;\npos.xy=position.xy;\npos.z=1.0;\npos.w=1.0;\ngl_Position=vec4(dot(pos,transformX),dot(pos,transformY),zBias.x,1);\n}",outlinePixelShader:"uniform vec4 color;\n#ifdef ALPHATEST\nvarying vec2 vUV;\nuniform sampler2D diffuseSampler;\n#endif\nvoid main(void) {\n#ifdef ALPHATEST\nif (texture2D(diffuseSampler,vUV).a<0.4)\ndiscard;\n#endif\ngl_FragColor=color;\n}",outlineVertexShader:"\nattribute vec3 position;\nattribute vec3 normal;\n#include<bonesDeclaration>\n\nuniform float offset;\n#include<instancesDeclaration>\nuniform mat4 viewProjection;\n#ifdef ALPHATEST\nvarying vec2 vUV;\nuniform mat4 diffuseMatrix;\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#endif\nvoid main(void)\n{\nvec3 offsetPosition=position+normal*offset;\n#include<instancesVertex>\n#include<bonesVertex>\ngl_Position=viewProjection*finalWorld*vec4(offsetPosition,1.0);\n#ifdef ALPHATEST\n#ifdef UV1\nvUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n#endif\n#ifdef UV2\nvUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n}\n",particlesPixelShader:"\nvarying vec2 vUV;\nvarying vec4 vColor;\nuniform vec4 textureMask;\nuniform sampler2D diffuseSampler;\n#ifdef CLIPPLANE\nvarying float fClipDistance;\n#endif\nvoid main(void) {\n#ifdef CLIPPLANE\nif (fClipDistance>0.0)\ndiscard;\n#endif\nvec4 baseColor=texture2D(diffuseSampler,vUV);\ngl_FragColor=(baseColor*textureMask+(vec4(1.,1.,1.,1.)-textureMask))*vColor;\n}",particlesVertexShader:"\nattribute vec3 position;\nattribute vec4 color;\nattribute vec4 options;\n\nuniform mat4 view;\nuniform mat4 projection;\n\nvarying vec2 vUV;\nvarying vec4 vColor;\n#ifdef CLIPPLANE\nuniform vec4 vClipPlane;\nuniform mat4 invView;\nvarying float fClipDistance;\n#endif\nvoid main(void) { \nvec3 viewPos=(view*vec4(position,1.0)).xyz; \nvec3 cornerPos;\nfloat size=options.y;\nfloat angle=options.x;\nvec2 offset=options.zw;\ncornerPos=vec3(offset.x-0.5,offset.y-0.5,0.)*size;\n\nvec3 rotatedCorner;\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.z=0.;\n\nviewPos+=rotatedCorner;\ngl_Position=projection*vec4(viewPos,1.0); \nvColor=color;\nvUV=offset;\n\n#ifdef CLIPPLANE\nvec4 worldPos=invView*vec4(viewPos,1.0);\nfClipDistance=dot(worldPos,vClipPlane);\n#endif\n}",passPixelShader:"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nvoid main(void) \n{\ngl_FragColor=texture2D(textureSampler,vUV);\n}",pbrPixelShader:"#ifdef BUMP\n#extension GL_OES_standard_derivatives : enable\n#endif\n#ifdef LODBASEDMICROSFURACE\n#extension GL_EXT_shader_texture_lod : enable\n#endif\n#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\nprecision highp float;\nuniform vec3 vEyePosition;\nuniform vec3 vAmbientColor;\nuniform vec3 vReflectionColor;\nuniform vec4 vAlbedoColor;\n\nuniform vec4 vLightingIntensity;\nuniform vec4 vCameraInfos;\n#ifdef OVERLOADEDVALUES\nuniform vec4 vOverloadedIntensity;\nuniform vec3 vOverloadedAmbient;\nuniform vec3 vOverloadedAlbedo;\nuniform vec3 vOverloadedReflectivity;\nuniform vec3 vOverloadedEmissive;\nuniform vec3 vOverloadedReflection;\nuniform vec3 vOverloadedMicroSurface;\n#endif\n#ifdef OVERLOADEDSHADOWVALUES\nuniform vec4 vOverloadedShadowIntensity;\n#endif\n#if defined(REFLECTION) || defined(REFRACTION)\nuniform vec2 vMicrosurfaceTextureLods;\n#endif\nuniform vec4 vReflectivityColor;\nuniform vec3 vEmissiveColor;\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n\n#include<lightFragmentDeclaration>[0..maxSimultaneousLights]\n\n#ifdef ALBEDO\nvarying vec2 vAlbedoUV;\nuniform sampler2D albedoSampler;\nuniform vec2 vAlbedoInfos;\n#endif\n#ifdef AMBIENT\nvarying vec2 vAmbientUV;\nuniform sampler2D ambientSampler;\nuniform vec2 vAmbientInfos;\n#endif\n#ifdef OPACITY \nvarying vec2 vOpacityUV;\nuniform sampler2D opacitySampler;\nuniform vec2 vOpacityInfos;\n#endif\n#ifdef EMISSIVE\nvarying vec2 vEmissiveUV;\nuniform vec2 vEmissiveInfos;\nuniform sampler2D emissiveSampler;\n#endif\n#ifdef LIGHTMAP\nvarying vec2 vLightmapUV;\nuniform vec2 vLightmapInfos;\nuniform sampler2D lightmapSampler;\n#endif\n#if defined(REFLECTIVITY)\nvarying vec2 vReflectivityUV;\nuniform vec2 vReflectivityInfos;\nuniform sampler2D reflectivitySampler;\n#endif\n\n#include<fresnelFunction>\n#ifdef OPACITYFRESNEL\nuniform vec4 opacityParts;\n#endif\n#ifdef EMISSIVEFRESNEL\nuniform vec4 emissiveLeftColor;\nuniform vec4 emissiveRightColor;\n#endif\n\n#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(REFRACTION)\nuniform mat4 view;\n#endif\n\n#ifdef REFRACTION\nuniform vec4 vRefractionInfos;\n#ifdef REFRACTIONMAP_3D\nuniform samplerCube refractionCubeSampler;\n#else\nuniform sampler2D refraction2DSampler;\nuniform mat4 refractionMatrix;\n#endif\n#endif\n\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\n#ifdef REFLECTIONMAP_3D\nuniform samplerCube reflectionCubeSampler;\n#else\nuniform sampler2D reflection2DSampler;\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#else\n#ifdef REFLECTIONMAP_EQUIRECTANGULAR_FIXED\nvarying vec3 vDirectionW;\n#endif\n#if defined(REFLECTIONMAP_PLANAR) || defined(REFLECTIONMAP_CUBIC) || defined(REFLECTIONMAP_PROJECTION)\nuniform mat4 reflectionMatrix;\n#endif\n#endif\n#include<reflectionFunction>\n#endif\n#ifdef CAMERACOLORGRADING\n#include<colorGradingDefinition>\n#endif\n#ifdef CAMERACOLORCURVES\n#include<colorCurvesDefinition>\n#endif\n\n#include<pbrShadowFunctions>\n#include<pbrFunctions>\n#ifdef CAMERACOLORGRADING\n#include<colorGrading>\n#endif\n#ifdef CAMERACOLORCURVES\n#include<colorCurves>\n#endif\n#include<harmonicsFunctions>\n#include<pbrLightFunctions>\n#include<bumpFragmentFunctions>\n#include<clipPlaneFragmentDeclaration>\n#include<logDepthDeclaration>\n\n#include<fogFragmentDeclaration>\nvoid main(void) {\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\nvec4 surfaceAlbedo=vec4(1.,1.,1.,1.);\nvec3 surfaceAlbedoContribution=vAlbedoColor.rgb;\n\nfloat alpha=vAlbedoColor.a;\n#ifdef ALBEDO\nsurfaceAlbedo=texture2D(albedoSampler,vAlbedoUV);\nsurfaceAlbedo=vec4(toLinearSpace(surfaceAlbedo.rgb),surfaceAlbedo.a);\n#ifndef LINKREFRACTIONTOTRANSPARENCY\n#ifdef ALPHATEST\nif (surfaceAlbedo.a<0.4)\ndiscard;\n#endif\n#endif\n#ifdef ALPHAFROMALBEDO\nalpha*=surfaceAlbedo.a;\n#endif\nsurfaceAlbedo.rgb*=vAlbedoInfos.y;\n#else\n\nsurfaceAlbedo.rgb=surfaceAlbedoContribution;\nsurfaceAlbedoContribution=vec3(1.,1.,1.);\n#endif\n#ifdef VERTEXCOLOR\nsurfaceAlbedo.rgb*=vColor.rgb;\n#endif\n#ifdef OVERLOADEDVALUES\nsurfaceAlbedo.rgb=mix(surfaceAlbedo.rgb,vOverloadedAlbedo,vOverloadedIntensity.y);\n#endif\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\n#include<bumpFragment>\n\nvec3 ambientColor=vec3(1.,1.,1.);\n#ifdef AMBIENT\nambientColor=texture2D(ambientSampler,vAmbientUV).rgb*vAmbientInfos.y;\n#ifdef OVERLOADEDVALUES\nambientColor.rgb=mix(ambientColor.rgb,vOverloadedAmbient,vOverloadedIntensity.x);\n#endif\n#endif\n\nfloat microSurface=vReflectivityColor.a;\nvec3 surfaceReflectivityColor=vReflectivityColor.rgb;\n#ifdef OVERLOADEDVALUES\nsurfaceReflectivityColor.rgb=mix(surfaceReflectivityColor.rgb,vOverloadedReflectivity,vOverloadedIntensity.z);\n#endif\n#ifdef REFLECTIVITY\nvec4 surfaceReflectivityColorMap=texture2D(reflectivitySampler,vReflectivityUV);\nsurfaceReflectivityColor=surfaceReflectivityColorMap.rgb;\nsurfaceReflectivityColor=toLinearSpace(surfaceReflectivityColor);\n#ifdef OVERLOADEDVALUES\nsurfaceReflectivityColor=mix(surfaceReflectivityColor,vOverloadedReflectivity,vOverloadedIntensity.z);\n#endif\n#ifdef MICROSURFACEFROMREFLECTIVITYMAP\nmicroSurface=surfaceReflectivityColorMap.a;\n#else\n#ifdef MICROSURFACEAUTOMATIC\nmicroSurface=computeDefaultMicroSurface(microSurface,surfaceReflectivityColor);\n#endif\n#endif\n#endif\n#ifdef OVERLOADEDVALUES\nmicroSurface=mix(microSurface,vOverloadedMicroSurface.x,vOverloadedMicroSurface.y);\n#endif\n\nfloat NdotV=max(0.00000000001,dot(normalW,viewDirectionW));\n\nmicroSurface=clamp(microSurface,0.,1.)*0.98;\n\nfloat roughness=clamp(1.-microSurface,0.000001,1.0);\n\nvec3 lightDiffuseContribution=vec3(0.,0.,0.);\n#ifdef OVERLOADEDSHADOWVALUES\nvec3 shadowedOnlyLightDiffuseContribution=vec3(1.,1.,1.);\n#endif\n#ifdef SPECULARTERM\nvec3 lightSpecularContribution=vec3(0.,0.,0.);\n#endif\nfloat notShadowLevel=1.; \nfloat NdotL=-1.;\nlightingInfo info;\n\nfloat reflectance=max(max(surfaceReflectivityColor.r,surfaceReflectivityColor.g),surfaceReflectivityColor.b);\n\n\nfloat reflectance90=clamp(reflectance*25.0,0.0,1.0);\nvec3 specularEnvironmentR0=surfaceReflectivityColor.rgb;\nvec3 specularEnvironmentR90=vec3(1.0,1.0,1.0)*reflectance90;\n#include<pbrLightFunctionsCall>[0..maxSimultaneousLights]\n#ifdef SPECULARTERM\nlightSpecularContribution*=vLightingIntensity.w;\n#endif\n#ifdef OPACITY\nvec4 opacityMap=texture2D(opacitySampler,vOpacityUV);\n#ifdef OPACITYRGB\nopacityMap.rgb=opacityMap.rgb*vec3(0.3,0.59,0.11);\nalpha*=(opacityMap.x+opacityMap.y+opacityMap.z)* vOpacityInfos.y;\n#else\nalpha*=opacityMap.a*vOpacityInfos.y;\n#endif\n#endif\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n#ifdef OPACITYFRESNEL\nfloat opacityFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,opacityParts.z,opacityParts.w);\nalpha+=opacityParts.x*(1.0-opacityFresnelTerm)+opacityFresnelTerm*opacityParts.y;\n#endif\n\nvec3 surfaceRefractionColor=vec3(0.,0.,0.);\n\n#ifdef LODBASEDMICROSFURACE\nfloat alphaG=convertRoughnessToAverageSlope(roughness);\n#endif\n#ifdef REFRACTION\nvec3 refractionVector=refract(-viewDirectionW,normalW,vRefractionInfos.y);\n#ifdef LODBASEDMICROSFURACE\n#ifdef USEPMREMREFRACTION\nfloat lodRefraction=getMipMapIndexFromAverageSlopeWithPMREM(vMicrosurfaceTextureLods.y,alphaG);\n#else\nfloat lodRefraction=getMipMapIndexFromAverageSlope(vMicrosurfaceTextureLods.y,alphaG);\n#endif\n#else\nfloat biasRefraction=(vMicrosurfaceTextureLods.y+2.)*(1.0-microSurface);\n#endif\n#ifdef REFRACTIONMAP_3D\nrefractionVector.y=refractionVector.y*vRefractionInfos.w;\nif (dot(refractionVector,viewDirectionW)<1.0)\n{\n#ifdef LODBASEDMICROSFURACE\n#ifdef USEPMREMREFRACTION\n\nif ((vMicrosurfaceTextureLods.y-lodRefraction)>4.0)\n{\n\nfloat scaleRefraction=1.-exp2(lodRefraction)/exp2(vMicrosurfaceTextureLods.y); \nfloat maxRefraction=max(max(abs(refractionVector.x),abs(refractionVector.y)),abs(refractionVector.z));\nif (abs(refractionVector.x) != maxRefraction) refractionVector.x*=scaleRefraction;\nif (abs(refractionVector.y) != maxRefraction) refractionVector.y*=scaleRefraction;\nif (abs(refractionVector.z) != maxRefraction) refractionVector.z*=scaleRefraction;\n}\n#endif\nsurfaceRefractionColor=textureCubeLodEXT(refractionCubeSampler,refractionVector,lodRefraction).rgb*vRefractionInfos.x;\n#else\nsurfaceRefractionColor=textureCube(refractionCubeSampler,refractionVector,biasRefraction).rgb*vRefractionInfos.x;\n#endif\n}\n#ifndef REFRACTIONMAPINLINEARSPACE\nsurfaceRefractionColor=toLinearSpace(surfaceRefractionColor.rgb);\n#endif\n#else\nvec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*vRefractionInfos.z,1.0)));\nvec2 refractionCoords=vRefractionUVW.xy/vRefractionUVW.z;\nrefractionCoords.y=1.0-refractionCoords.y;\n#ifdef LODBASEDMICROSFURACE\nsurfaceRefractionColor=texture2DLodEXT(refraction2DSampler,refractionCoords,lodRefraction).rgb*vRefractionInfos.x;\n#else\nsurfaceRefractionColor=texture2D(refraction2DSampler,refractionCoords,biasRefraction).rgb*vRefractionInfos.x;\n#endif \nsurfaceRefractionColor=toLinearSpace(surfaceRefractionColor.rgb);\n#endif\n#endif\n\nvec3 environmentRadiance=vReflectionColor.rgb;\nvec3 environmentIrradiance=vReflectionColor.rgb;\n#ifdef REFLECTION\nvec3 vReflectionUVW=computeReflectionCoords(vec4(vPositionW,1.0),normalW);\n#ifdef LODBASEDMICROSFURACE\n#ifdef USEPMREMREFLECTION\nfloat lodReflection=getMipMapIndexFromAverageSlopeWithPMREM(vMicrosurfaceTextureLods.x,alphaG);\n#else\nfloat lodReflection=getMipMapIndexFromAverageSlope(vMicrosurfaceTextureLods.x,alphaG);\n#endif\n#else\nfloat biasReflection=(vMicrosurfaceTextureLods.x+2.)*(1.0-microSurface);\n#endif\n#ifdef REFLECTIONMAP_3D\n#ifdef LODBASEDMICROSFURACE\n#ifdef USEPMREMREFLECTION\n\nif ((vMicrosurfaceTextureLods.y-lodReflection)>4.0)\n{\n\nfloat scaleReflection=1.-exp2(lodReflection)/exp2(vMicrosurfaceTextureLods.x); \nfloat maxReflection=max(max(abs(vReflectionUVW.x),abs(vReflectionUVW.y)),abs(vReflectionUVW.z));\nif (abs(vReflectionUVW.x) != maxReflection) vReflectionUVW.x*=scaleReflection;\nif (abs(vReflectionUVW.y) != maxReflection) vReflectionUVW.y*=scaleReflection;\nif (abs(vReflectionUVW.z) != maxReflection) vReflectionUVW.z*=scaleReflection;\n}\n#endif\nenvironmentRadiance=textureCubeLodEXT(reflectionCubeSampler,vReflectionUVW,lodReflection).rgb*vReflectionInfos.x;\n#else\nenvironmentRadiance=textureCube(reflectionCubeSampler,vReflectionUVW,biasReflection).rgb*vReflectionInfos.x;\n#endif\n#ifdef USESPHERICALFROMREFLECTIONMAP\n#ifndef REFLECTIONMAP_SKYBOX\nvec3 normalEnvironmentSpace=(reflectionMatrix*vec4(normalW,1)).xyz;\nenvironmentIrradiance=EnvironmentIrradiance(normalEnvironmentSpace);\n#endif\n#else\nenvironmentRadiance=toLinearSpace(environmentRadiance.rgb);\nenvironmentIrradiance=textureCube(reflectionCubeSampler,normalW,20.).rgb*vReflectionInfos.x;\nenvironmentIrradiance=toLinearSpace(environmentIrradiance.rgb);\nenvironmentIrradiance*=0.2; \n#endif\n#else\nvec2 coords=vReflectionUVW.xy;\n#ifdef REFLECTIONMAP_PROJECTION\ncoords/=vReflectionUVW.z;\n#endif\ncoords.y=1.0-coords.y;\n#ifdef LODBASEDMICROSFURACE\nenvironmentRadiance=texture2DLodEXT(reflection2DSampler,coords,lodReflection).rgb*vReflectionInfos.x;\n#else\nenvironmentRadiance=texture2D(reflection2DSampler,coords,biasReflection).rgb*vReflectionInfos.x;\n#endif\nenvironmentRadiance=toLinearSpace(environmentRadiance.rgb);\nenvironmentIrradiance=texture2D(reflection2DSampler,coords,20.).rgb*vReflectionInfos.x;\nenvironmentIrradiance=toLinearSpace(environmentIrradiance.rgb);\n#endif\n#endif\n#ifdef OVERLOADEDVALUES\nenvironmentIrradiance=mix(environmentIrradiance,vOverloadedReflection,vOverloadedMicroSurface.z);\nenvironmentRadiance=mix(environmentRadiance,vOverloadedReflection,vOverloadedMicroSurface.z);\n#endif\nenvironmentRadiance*=vLightingIntensity.z;\nenvironmentIrradiance*=vLightingIntensity.z;\n\nvec3 specularEnvironmentReflectance=FresnelSchlickEnvironmentGGX(clamp(NdotV,0.,1.),specularEnvironmentR0,specularEnvironmentR90,sqrt(microSurface));\n\nvec3 refractance=vec3(0.0,0.0,0.0);\n#ifdef REFRACTION\nvec3 transmission=vec3(1.0,1.0,1.0);\n#ifdef LINKREFRACTIONTOTRANSPARENCY\n\ntransmission*=(1.0-alpha);\n\n\nvec3 mixedAlbedo=surfaceAlbedoContribution.rgb*surfaceAlbedo.rgb;\nfloat maxChannel=max(max(mixedAlbedo.r,mixedAlbedo.g),mixedAlbedo.b);\nvec3 tint=clamp(maxChannel*mixedAlbedo,0.0,1.0);\n\nsurfaceAlbedoContribution*=alpha;\n\nenvironmentIrradiance*=alpha;\n\nsurfaceRefractionColor*=tint;\n\nalpha=1.0;\n#endif\n\nvec3 bounceSpecularEnvironmentReflectance=(2.0*specularEnvironmentReflectance)/(1.0+specularEnvironmentReflectance);\nspecularEnvironmentReflectance=mix(bounceSpecularEnvironmentReflectance,specularEnvironmentReflectance,alpha);\n\ntransmission*=1.0-specularEnvironmentReflectance;\n\nrefractance=surfaceRefractionColor*transmission;\n#endif\n\nsurfaceAlbedo.rgb=(1.-reflectance)*surfaceAlbedo.rgb;\nrefractance*=vLightingIntensity.z;\nenvironmentRadiance*=specularEnvironmentReflectance;\n\nvec3 surfaceEmissiveColor=vEmissiveColor;\n#ifdef EMISSIVE\nvec3 emissiveColorTex=texture2D(emissiveSampler,vEmissiveUV).rgb;\nsurfaceEmissiveColor=toLinearSpace(emissiveColorTex.rgb)*surfaceEmissiveColor*vEmissiveInfos.y;\n#endif\n#ifdef OVERLOADEDVALUES\nsurfaceEmissiveColor=mix(surfaceEmissiveColor,vOverloadedEmissive,vOverloadedIntensity.w);\n#endif\n#ifdef EMISSIVEFRESNEL\nfloat emissiveFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,emissiveRightColor.a,emissiveLeftColor.a);\nsurfaceEmissiveColor*=emissiveLeftColor.rgb*(1.0-emissiveFresnelTerm)+emissiveFresnelTerm*emissiveRightColor.rgb;\n#endif\n\n#ifdef EMISSIVEASILLUMINATION\nvec3 finalDiffuse=max(lightDiffuseContribution*surfaceAlbedoContribution+vAmbientColor,0.0)*surfaceAlbedo.rgb;\n#ifdef OVERLOADEDSHADOWVALUES\nshadowedOnlyLightDiffuseContribution=max(shadowedOnlyLightDiffuseContribution*surfaceAlbedoContribution+vAmbientColor,0.0)*surfaceAlbedo.rgb;\n#endif\n#else\n#ifdef LINKEMISSIVEWITHALBEDO\nvec3 finalDiffuse=max((lightDiffuseContribution+surfaceEmissiveColor)*surfaceAlbedoContribution+vAmbientColor,0.0)*surfaceAlbedo.rgb;\n#ifdef OVERLOADEDSHADOWVALUES\nshadowedOnlyLightDiffuseContribution=max((shadowedOnlyLightDiffuseContribution+surfaceEmissiveColor)*surfaceAlbedoContribution+vAmbientColor,0.0)*surfaceAlbedo.rgb;\n#endif\n#else\nvec3 finalDiffuse=max(lightDiffuseContribution*surfaceAlbedoContribution+surfaceEmissiveColor+vAmbientColor,0.0)*surfaceAlbedo.rgb;\n#ifdef OVERLOADEDSHADOWVALUES\nshadowedOnlyLightDiffuseContribution=max(shadowedOnlyLightDiffuseContribution*surfaceAlbedoContribution+surfaceEmissiveColor+vAmbientColor,0.0)*surfaceAlbedo.rgb;\n#endif\n#endif\n#endif\n#ifdef OVERLOADEDSHADOWVALUES\nfinalDiffuse=mix(finalDiffuse,shadowedOnlyLightDiffuseContribution,(1.0-vOverloadedShadowIntensity.y));\n#endif\n#ifdef SPECULARTERM\nvec3 finalSpecular=lightSpecularContribution*surfaceReflectivityColor;\n#else\nvec3 finalSpecular=vec3(0.0);\n#endif\n#ifdef SPECULAROVERALPHA\nalpha=clamp(alpha+getLuminance(finalSpecular),0.,1.);\n#endif\n#ifdef RADIANCEOVERALPHA\nalpha=clamp(alpha+getLuminance(environmentRadiance),0.,1.);\n#endif\n\n\n#ifdef EMISSIVEASILLUMINATION\nvec4 finalColor=vec4(finalDiffuse*ambientColor*vLightingIntensity.x+surfaceAlbedo.rgb*environmentIrradiance+finalSpecular*vLightingIntensity.x+environmentRadiance+surfaceEmissiveColor*vLightingIntensity.y+refractance,alpha);\n#else\nvec4 finalColor=vec4(finalDiffuse*ambientColor*vLightingIntensity.x+surfaceAlbedo.rgb*environmentIrradiance+finalSpecular*vLightingIntensity.x+environmentRadiance+refractance,alpha);\n#endif\n#ifdef LIGHTMAP\nvec3 lightmapColor=texture2D(lightmapSampler,vLightmapUV).rgb*vLightmapInfos.y;\n#ifdef USELIGHTMAPASSHADOWMAP\nfinalColor.rgb*=lightmapColor;\n#else\nfinalColor.rgb+=lightmapColor;\n#endif\n#endif\nfinalColor=max(finalColor,0.0);\n#ifdef CAMERATONEMAP\nfinalColor.rgb=toneMaps(finalColor.rgb);\n#endif\nfinalColor.rgb=toGammaSpace(finalColor.rgb);\n#include<logDepthFragment>\n#include<fogFragment>(color,finalColor)\n#ifdef CAMERACONTRAST\nfinalColor=contrasts(finalColor);\n#endif\nfinalColor.rgb=clamp(finalColor.rgb,0.,1.);\n#ifdef CAMERACOLORGRADING\nfinalColor=colorGrades(finalColor);\n#endif\n#ifdef CAMERACOLORCURVES\nfinalColor.rgb=applyColorCurves(finalColor.rgb);\n#endif\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\ngl_FragColor=finalColor;\n}",pbrVertexShader:"precision highp float;\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\nuniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef ALBEDO\nvarying vec2 vAlbedoUV;\nuniform mat4 albedoMatrix;\nuniform vec2 vAlbedoInfos;\n#endif\n#ifdef AMBIENT\nvarying vec2 vAmbientUV;\nuniform mat4 ambientMatrix;\nuniform vec2 vAmbientInfos;\n#endif\n#ifdef OPACITY\nvarying vec2 vOpacityUV;\nuniform mat4 opacityMatrix;\nuniform vec2 vOpacityInfos;\n#endif\n#ifdef EMISSIVE\nvarying vec2 vEmissiveUV;\nuniform vec2 vEmissiveInfos;\nuniform mat4 emissiveMatrix;\n#endif\n#ifdef LIGHTMAP\nvarying vec2 vLightmapUV;\nuniform vec2 vLightmapInfos;\nuniform mat4 lightmapMatrix;\n#endif\n#if defined(REFLECTIVITY)\nvarying vec2 vReflectivityUV;\nuniform vec2 vReflectivityInfos;\nuniform mat4 reflectivityMatrix;\n#endif\n#ifdef BUMP\nvarying vec2 vBumpUV;\nuniform vec3 vBumpInfos;\nuniform mat4 bumpMatrix;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<shadowsVertexDeclaration>[0..maxSimultaneousLights]\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#endif\n#ifdef REFLECTIONMAP_EQUIRECTANGULAR_FIXED\nvarying vec3 vDirectionW;\n#endif\n#include<logDepthDeclaration>\nvoid main(void) {\n#ifdef REFLECTIONMAP_SKYBOX\nvPositionUVW=position;\n#endif \n#include<instancesVertex>\n#include<bonesVertex>\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\nvec4 worldPos=finalWorld*vec4(position,1.0);\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nvNormalW=normalize(vec3(finalWorld*vec4(normal,0.0)));\n#endif\n#ifdef REFLECTIONMAP_EQUIRECTANGULAR_FIXED\nvDirectionW=normalize(vec3(finalWorld*vec4(position,0.0)));\n#endif\n\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef ALBEDO\nif (vAlbedoInfos.x == 0.)\n{\nvAlbedoUV=vec2(albedoMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvAlbedoUV=vec2(albedoMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#ifdef AMBIENT\nif (vAmbientInfos.x == 0.)\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#ifdef OPACITY\nif (vOpacityInfos.x == 0.)\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#ifdef EMISSIVE\nif (vEmissiveInfos.x == 0.)\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#ifdef LIGHTMAP\nif (vLightmapInfos.x == 0.)\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(REFLECTIVITY)\nif (vReflectivityInfos.x == 0.)\n{\nvReflectivityUV=vec2(reflectivityMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvReflectivityUV=vec2(reflectivityMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#ifdef BUMP\nif (vBumpInfos.x == 0.)\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n\n#include<clipPlaneVertex>\n\n#include<fogVertex>\n\n#include<shadowsVertex>[0..maxSimultaneousLights]\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n\n#include<logDepthVertex>\n}",
  39. postprocessVertexShader:"\nattribute vec2 position;\nuniform vec2 scale;\n\nvarying vec2 vUV;\nconst vec2 madd=vec2(0.5,0.5);\nvoid main(void) { \nvUV=(position*madd+madd)*scale;\ngl_Position=vec4(position,0.0,1.0);\n}",proceduralVertexShader:"\nattribute vec2 position;\n\nvarying vec2 vPosition;\nvarying vec2 vUV;\nconst vec2 madd=vec2(0.5,0.5);\nvoid main(void) { \nvPosition=position;\nvUV=position*madd+madd;\ngl_Position=vec4(position,0.0,1.0);\n}",rect2dPixelShader:"varying vec4 vColor;\nvoid main(void) {\ngl_FragColor=vColor;\n}",rect2dVertexShader:"\n#ifdef Instanced\n#define att attribute\n#else\n#define att uniform\n#endif\nattribute float index;\natt vec2 zBias;\natt vec4 transformX;\natt vec4 transformY;\n#ifdef Border\natt float borderThickness;\n#endif\n#ifdef FillSolid\natt vec4 fillSolidColor;\n#endif\n#ifdef BorderSolid\natt vec4 borderSolidColor;\n#endif\n#ifdef FillGradient\natt vec4 fillGradientColor1;\natt vec4 fillGradientColor2;\natt vec4 fillGradientTY;\n#endif\n#ifdef BorderGradient\natt vec4 borderGradientColor1;\natt vec4 borderGradientColor2;\natt vec4 borderGradientTY;\n#endif\n\natt vec3 properties;\n\n#define rsub0 17.0\n#define rsub1 33.0\n#define rsub2 49.0\n#define rsub3 65.0\n#define rsub 64.0\n#define TWOPI 6.28318530\n\nvarying vec2 vUV;\nvarying vec4 vColor;\nvoid main(void) {\nvec2 pos2;\n\nif (properties.z == 0.0) {\n#ifdef Border\nfloat w=properties.x;\nfloat h=properties.y;\nvec2 borderOffset=vec2(1.0,1.0);\nfloat segi=index;\nif (index<4.0) {\nborderOffset=vec2(1.0-(borderThickness*2.0/w),1.0-(borderThickness*2.0/h));\n}\nelse {\nsegi-=4.0;\n}\nif (segi == 0.0) {\npos2=vec2(1.0,1.0);\n} \nelse if (segi == 1.0) {\npos2=vec2(1.0,0.0);\n}\nelse if (segi == 2.0) {\npos2=vec2(0.0,0.0);\n} \nelse {\npos2=vec2(0.0,1.0);\n}\npos2.x=((pos2.x-0.5)*borderOffset.x)+0.5;\npos2.y=((pos2.y-0.5)*borderOffset.y)+0.5;\n#else\nif (index == 0.0) {\npos2=vec2(0.5,0.5);\n}\nelse if (index == 1.0) {\npos2=vec2(1.0,1.0);\n}\nelse if (index == 2.0) {\npos2=vec2(1.0,0.0);\n}\nelse if (index == 3.0) {\npos2=vec2(0.0,0.0);\n}\nelse {\npos2=vec2(0.0,1.0);\n}\n#endif\n}\nelse\n{\n#ifdef Border\nfloat w=properties.x;\nfloat h=properties.y;\nfloat r=properties.z;\nfloat nru=r/w;\nfloat nrv=r/h;\nvec2 borderOffset=vec2(1.0,1.0);\nfloat segi=index;\nif (index<rsub) {\nborderOffset=vec2(1.0-(borderThickness*2.0/w),1.0-(borderThickness*2.0/h));\n}\nelse {\nsegi-=rsub;\n}\n\nif (segi<rsub0) {\npos2=vec2(1.0-nru,nrv);\n}\n\nelse if (segi<rsub1) {\npos2=vec2(nru,nrv);\n}\n\nelse if (segi<rsub2) {\npos2=vec2(nru,1.0-nrv);\n}\n\nelse {\npos2=vec2(1.0-nru,1.0-nrv);\n}\nfloat angle=TWOPI-((index-1.0)*TWOPI/(rsub-0.5));\npos2.x+=cos(angle)*nru;\npos2.y+=sin(angle)*nrv;\npos2.x=((pos2.x-0.5)*borderOffset.x)+0.5;\npos2.y=((pos2.y-0.5)*borderOffset.y)+0.5;\n#else\nif (index == 0.0) {\npos2=vec2(0.5,0.5);\n}\nelse {\nfloat w=properties.x;\nfloat h=properties.y;\nfloat r=properties.z;\nfloat nru=r/w;\nfloat nrv=r/h;\n\nif (index<rsub0) {\npos2=vec2(1.0-nru,nrv);\n}\n\nelse if (index<rsub1) {\npos2=vec2(nru,nrv);\n}\n\nelse if (index<rsub2) {\npos2=vec2(nru,1.0-nrv);\n}\n\nelse {\npos2=vec2(1.0-nru,1.0-nrv);\n}\nfloat angle=TWOPI-((index-1.0)*TWOPI/(rsub-0.5));\npos2.x+=cos(angle)*nru;\npos2.y+=sin(angle)*nrv;\n}\n#endif\n}\n#ifdef FillSolid\nvColor=fillSolidColor;\n#endif\n#ifdef BorderSolid\nvColor=borderSolidColor;\n#endif\n#ifdef FillGradient\nfloat v=dot(vec4(pos2.xy,1,1),fillGradientTY);\nvColor=mix(fillGradientColor2,fillGradientColor1,v); \n#endif\n#ifdef BorderGradient\nfloat v=dot(vec4(pos2.xy,1,1),borderGradientTY);\nvColor=mix(borderGradientColor2,borderGradientColor1,v); \n#endif\nvec4 pos;\npos.xy=pos2.xy*properties.xy;\npos.z=1.0;\npos.w=1.0;\ngl_Position=vec4(dot(pos,transformX),dot(pos,transformY),zBias.x,1);\n}",refractionPixelShader:"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform sampler2D refractionSampler;\n\nuniform vec3 baseColor;\nuniform float depth;\nuniform float colorLevel;\nvoid main() {\nfloat ref=1.0-texture2D(refractionSampler,vUV).r;\nvec2 uv=vUV-vec2(0.5);\nvec2 offset=uv*depth*ref;\nvec3 sourceColor=texture2D(textureSampler,vUV-offset).rgb;\ngl_FragColor=vec4(sourceColor+sourceColor*ref*colorLevel,1.0);\n}",shadowMapPixelShader:"vec4 pack(float depth)\n{\nconst vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);\nconst vec4 bit_mask=vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);\nvec4 res=fract(depth*bit_shift);\nres-=res.xxyz*bit_mask;\nreturn res;\n}\n\nvec2 packHalf(float depth) \n{ \nconst vec2 bitOffset=vec2(1.0/255.,0.);\nvec2 color=vec2(depth,fract(depth*255.));\nreturn color-(color.yy*bitOffset);\n}\nvarying vec4 vPosition;\n#ifdef ALPHATEST\nvarying vec2 vUV;\nuniform sampler2D diffuseSampler;\n#endif\n#ifdef CUBEMAP\nuniform vec3 lightPosition;\nuniform vec2 depthValues;\n#endif\nvoid main(void)\n{\n#ifdef ALPHATEST\nif (texture2D(diffuseSampler,vUV).a<0.4)\ndiscard;\n#endif\n#ifdef CUBEMAP\nvec3 directionToLight=vPosition.xyz-lightPosition;\nfloat depth=length(directionToLight);\ndepth=(depth-depthValues.x)/(depthValues.y-depthValues.x);\ndepth=clamp(depth,0.,1.0);\n#else\nfloat depth=vPosition.z/vPosition.w;\ndepth=depth*0.5+0.5;\n#endif\n#ifdef VSM\nfloat moment1=depth;\nfloat moment2=moment1*moment1;\ngl_FragColor=vec4(packHalf(moment1),packHalf(moment2));\n#else\ngl_FragColor=pack(depth);\n#endif\n}",shadowMapVertexShader:"\nattribute vec3 position;\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\nuniform mat4 viewProjection;\nvarying vec4 vPosition;\n#ifdef ALPHATEST\nvarying vec2 vUV;\nuniform mat4 diffuseMatrix;\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#endif\nvoid main(void)\n{\n#include<instancesVertex>\n#include<bonesVertex>\n#ifdef CUBEMAP\nvPosition=finalWorld*vec4(position,1.0);\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\n#else\nvPosition=viewProjection*finalWorld*vec4(position,1.0);\ngl_Position=vPosition;\n#endif\n#ifdef ALPHATEST\n#ifdef UV1\nvUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n#endif\n#ifdef UV2\nvUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n}",sprite2dPixelShader:"varying vec2 vUV;\nuniform sampler2D diffuseSampler;\nvoid main(void) {\nvec4 color=texture2D(diffuseSampler,vUV);\nif (color.a == 0.05) {\ndiscard;\n}\ngl_FragColor=color;\n}",sprite2dVertexShader:"\n#ifdef Instanced\n#define att attribute\n#else\n#define att uniform\n#endif\n\nattribute float index;\natt vec2 topLeftUV;\natt vec2 sizeUV;\natt vec2 textureSize;\n\natt vec3 properties;\natt vec2 zBias;\natt vec4 transformX;\natt vec4 transformY;\n\n\nvarying vec2 vUV;\nvarying vec4 vColor;\nvoid main(void) {\nvec2 pos2;\n\nvec2 off=vec2(0.0,0.0);\nfloat frame=properties.x;\nfloat invertY=properties.y;\nfloat alignToPixel=properties.z;\n\nif (index == 0.0) {\npos2=vec2(0.0,0.0);\nvUV=vec2(topLeftUV.x+(frame*sizeUV.x)+off.x,topLeftUV.y-off.y);\n}\n\nelse if (index == 1.0) {\npos2=vec2(0.0,1.0);\nvUV=vec2(topLeftUV.x+(frame*sizeUV.x)+off.x,(topLeftUV.y+sizeUV.y));\n}\n\nelse if (index == 2.0) {\npos2=vec2( 1.0,1.0);\nvUV=vec2(topLeftUV.x+sizeUV.x+(frame*sizeUV.x),(topLeftUV.y+sizeUV.y));\n}\n\nelse if (index == 3.0) {\npos2=vec2( 1.0,0.0);\nvUV=vec2(topLeftUV.x+sizeUV.x+(frame*sizeUV.x),topLeftUV.y-off.y);\n}\nif (invertY == 1.0) {\nvUV.y=1.0-vUV.y;\n}\nvec4 pos;\nif (alignToPixel == 1.0)\n{\npos.xy=floor(pos2.xy*sizeUV*textureSize);\n} else {\npos.xy=pos2.xy*sizeUV*textureSize;\n}\npos.z=1.0;\npos.w=1.0;\ngl_Position=vec4(dot(pos,transformX),dot(pos,transformY),zBias.x,1);\n} ",spritesPixelShader:"uniform bool alphaTest;\nvarying vec4 vColor;\n\nvarying vec2 vUV;\nuniform sampler2D diffuseSampler;\n\n#include<fogFragmentDeclaration>\nvoid main(void) {\nvec4 color=texture2D(diffuseSampler,vUV);\nif (alphaTest) \n{\nif (color.a<0.95)\ndiscard;\n}\ncolor*=vColor;\n#include<fogFragment>\ngl_FragColor=color;\n}",spritesVertexShader:"\nattribute vec4 position;\nattribute vec4 options;\nattribute vec4 cellInfo;\nattribute vec4 color;\n\nuniform vec2 textureInfos;\nuniform mat4 view;\nuniform mat4 projection;\n\nvarying vec2 vUV;\nvarying vec4 vColor;\n#include<fogVertexDeclaration>\nvoid main(void) { \nvec3 viewPos=(view*vec4(position.xyz,1.0)).xyz; \nvec2 cornerPos;\nfloat angle=position.w;\nvec2 size=vec2(options.x,options.y);\nvec2 offset=options.zw;\nvec2 uvScale=textureInfos.xy;\ncornerPos=vec2(offset.x-0.5,offset.y-0.5)*size;\n\nvec3 rotatedCorner;\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.z=0.;\n\nviewPos+=rotatedCorner;\ngl_Position=projection*vec4(viewPos,1.0); \n\nvColor=color;\n\nvec2 uvOffset=vec2(abs(offset.x-cellInfo.x),1.0-abs(offset.y-cellInfo.y));\nvUV=(uvOffset+cellInfo.zw)*uvScale;\n\n#ifdef FOG\nfFogDistance=viewPos.z;\n#endif\n}",ssaoPixelShader:"\nuniform sampler2D textureSampler;\nvarying vec2 vUV;\n#ifdef SSAO\nuniform sampler2D randomSampler;\nuniform float randTextureTiles;\nuniform float samplesFactor;\nuniform vec3 sampleSphere[SAMPLES];\nuniform float totalStrength;\nuniform float radius;\nuniform float area;\nuniform float fallOff;\nuniform float base;\nvec3 normalFromDepth(float depth,vec2 coords)\n{\nvec2 offset1=vec2(0.0,radius);\nvec2 offset2=vec2(radius,0.0);\nfloat depth1=texture2D(textureSampler,coords+offset1).r;\nfloat depth2=texture2D(textureSampler,coords+offset2).r;\nvec3 p1=vec3(offset1,depth1-depth);\nvec3 p2=vec3(offset2,depth2-depth);\nvec3 normal=cross(p1,p2);\nnormal.z=-normal.z;\nreturn normalize(normal);\n}\nvoid main()\n{\nvec3 random=normalize(texture2D(randomSampler,vUV*randTextureTiles).rgb);\nfloat depth=texture2D(textureSampler,vUV).r;\nvec3 position=vec3(vUV,depth);\nvec3 normal=normalFromDepth(depth,vUV);\nfloat radiusDepth=radius/depth;\nfloat occlusion=0.0;\nvec3 ray;\nvec3 hemiRay;\nfloat occlusionDepth;\nfloat difference;\nfor (int i=0; i<SAMPLES; i++)\n{\nray=radiusDepth*reflect(sampleSphere[i],random);\nhemiRay=position+sign(dot(ray,normal))*ray;\nocclusionDepth=texture2D(textureSampler,clamp(hemiRay.xy,vec2(0.001,0.001),vec2(0.999,0.999))).r;\ndifference=depth-occlusionDepth;\nocclusion+=step(fallOff,difference)*(1.0-smoothstep(fallOff,area,difference));\n}\nfloat ao=1.0-totalStrength*occlusion*samplesFactor;\nfloat result=clamp(ao+base,0.0,1.0);\ngl_FragColor.r=result;\ngl_FragColor.g=result;\ngl_FragColor.b=result;\ngl_FragColor.a=1.0;\n}\n#endif\n#ifdef BILATERAL_BLUR\nuniform sampler2D depthSampler;\nuniform float outSize;\nuniform float samplerOffsets[SAMPLES];\nvoid main()\n{\nfloat texelsize=1.0/outSize;\nfloat compareDepth=texture2D(depthSampler,vUV).r;\nfloat result=0.0;\nfloat weightSum=0.0;\nfor (int i=0; i<SAMPLES; ++i)\n{\n#ifdef BILATERAL_BLUR_H\nvec2 sampleOffset=vec2(texelsize*samplerOffsets[i],0.0);\n#else\nvec2 sampleOffset=vec2(0.0,texelsize*samplerOffsets[i]);\n#endif\nvec2 samplePos=vUV+sampleOffset;\nfloat sampleDepth=texture2D(depthSampler,samplePos).r;\nfloat weight=(1.0/(0.0001+abs(compareDepth-sampleDepth)));\nresult+=texture2D(textureSampler,samplePos).r*weight;\nweightSum+=weight;\n}\nresult/=weightSum;\ngl_FragColor.rgb=vec3(result);\ngl_FragColor.a=1.0;\n}\n#endif\n",ssaoCombinePixelShader:"uniform sampler2D textureSampler;\nuniform sampler2D originalColor;\nvarying vec2 vUV;\nvoid main(void) {\nvec4 ssaoColor=texture2D(textureSampler,vUV);\nvec4 sceneColor=texture2D(originalColor,vUV);\ngl_FragColor=sceneColor*ssaoColor;\n}\n",stereoscopicInterlacePixelShader:"const vec3 TWO=vec3(2.0,2.0,2.0);\nvarying vec2 vUV;\nuniform sampler2D camASampler;\nuniform sampler2D textureSampler;\nuniform vec2 stepSize;\nvoid main(void)\n{\nbool useCamB;\nvec2 texCoord1;\nvec2 texCoord2;\nvec3 frag1;\nvec3 frag2;\n#ifdef IS_STEREOSCOPIC_HORIZ\nuseCamB=vUV.x>0.5;\ntexCoord1=vec2(useCamB ? (vUV.x-0.5)*2.0 : vUV.x*2.0,vUV.y);\ntexCoord2=vec2(texCoord1.x+stepSize.x,vUV.y);\n#else\nuseCamB=vUV.y>0.5;\ntexCoord1=vec2(vUV.x,useCamB ? (vUV.y-0.5)*2.0 : vUV.y*2.0);\ntexCoord2=vec2(vUV.x,texCoord1.y+stepSize.y);\n#endif\n\nif (useCamB){\nfrag1=texture2D(textureSampler,texCoord1).rgb;\nfrag2=texture2D(textureSampler,texCoord2).rgb;\n}else{\nfrag1=texture2D(camASampler ,texCoord1).rgb;\nfrag2=texture2D(camASampler ,texCoord2).rgb;\n}\ngl_FragColor=vec4((frag1+frag2)/TWO,1.0);\n}",text2dPixelShader:"varying vec4 vColor;\nvarying vec2 vUV;\n\nuniform sampler2D diffuseSampler;\nvoid main(void) {\nvec4 color=texture2D(diffuseSampler,vUV);\nif (color.a<0.05)\ndiscard;\ngl_FragColor=color*vColor;\n}",text2dVertexShader:"\n#ifdef Instanced\n#define att attribute\n#else\n#define att uniform\n#endif\n\nattribute float index;\natt vec2 zBias;\natt vec4 transformX;\natt vec4 transformY;\natt vec2 topLeftUV;\natt vec2 sizeUV;\natt vec2 textureSize;\natt vec4 color;\n\nvarying vec2 vUV;\nvarying vec4 vColor;\nvoid main(void) {\nvec2 pos2;\n\nif (index == 0.0) {\npos2=vec2(0.0,0.0);\nvUV=vec2(topLeftUV.x,topLeftUV.y+sizeUV.y);\n}\n\nelse if (index == 1.0) {\npos2=vec2(0.0,1.0);\nvUV=vec2(topLeftUV.x,topLeftUV.y);\n}\n\nelse if (index == 2.0) {\npos2=vec2(1.0,1.0);\nvUV=vec2(topLeftUV.x+sizeUV.x,topLeftUV.y);\n}\n\nelse if (index == 3.0) {\npos2=vec2(1.0,0.0);\nvUV=vec2(topLeftUV.x+sizeUV.x,topLeftUV.y+sizeUV.y);\n}\n\nvUV=(floor(vUV*textureSize)+vec2(0.0,0.0))/textureSize;\nvColor=color;\nvec4 pos;\npos.xy=floor(pos2.xy*sizeUV*textureSize); \npos.z=1.0;\npos.w=1.0;\ngl_Position=vec4(dot(pos,transformX),dot(pos,transformY),zBias.x,1);\n}",tonemapPixelShader:"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n\nuniform float _ExposureAdjustment;\n#if defined(HABLE_TONEMAPPING)\nconst float A=0.15;\nconst float B=0.50;\nconst float C=0.10;\nconst float D=0.20;\nconst float E=0.02;\nconst float F=0.30;\nconst float W=11.2;\n#endif\nfloat Luminance(vec3 c)\n{\nreturn dot(c,vec3(0.22,0.707,0.071));\n}\nvoid main(void) \n{\nvec3 colour=texture2D(textureSampler,vUV).rgb;\n#if defined(REINHARD_TONEMAPPING)\nfloat lum=Luminance(colour.rgb); \nfloat lumTm=lum*_ExposureAdjustment;\nfloat scale=lumTm/(1.0+lumTm); \ncolour*=scale/lum;\n#elif defined(HABLE_TONEMAPPING)\ncolour*=_ExposureAdjustment;\nconst float ExposureBias=2.0;\nvec3 x=ExposureBias*colour;\nvec3 curr=((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;\nx=vec3(W,W,W);\nvec3 whiteScale=1.0/(((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F);\ncolour=curr*whiteScale;\n#elif defined(OPTIMIZED_HEJIDAWSON_TONEMAPPING)\ncolour*=_ExposureAdjustment;\nvec3 X=max(vec3(0.0,0.0,0.0),colour-0.004);\nvec3 retColor=(X*(6.2*X+0.5))/(X*(6.2*X+1.7)+0.06);\ncolour=retColor*retColor;\n#elif defined(PHOTOGRAPHIC_TONEMAPPING)\ncolour=vec3(1.0,1.0,1.0)-exp2(-_ExposureAdjustment*colour);\n#endif\ngl_FragColor=vec4(colour.rgb,1.0);\n}",volumetricLightScatteringPixelShader:"uniform sampler2D textureSampler;\nuniform sampler2D lightScatteringSampler;\nuniform float decay;\nuniform float exposure;\nuniform float weight;\nuniform float density;\nuniform vec2 meshPositionOnScreen;\nvarying vec2 vUV;\nvoid main(void) {\nvec2 tc=vUV;\nvec2 deltaTexCoord=(tc-meshPositionOnScreen.xy);\ndeltaTexCoord*=1.0/float(NUM_SAMPLES)*density;\nfloat illuminationDecay=1.0;\nvec4 color=texture2D(lightScatteringSampler,tc)*0.4;\nfor(int i=0; i<NUM_SAMPLES; i++) {\ntc-=deltaTexCoord;\nvec4 sample=texture2D(lightScatteringSampler,tc)*0.4;\nsample*=illuminationDecay*weight;\ncolor+=sample;\nilluminationDecay*=decay;\n}\nvec4 realColor=texture2D(textureSampler,vUV);\ngl_FragColor=((vec4((vec3(color.r,color.g,color.b)*exposure),1))+(realColor*(1.5-0.4)));\n}\n",volumetricLightScatteringPassPixelShader:"#if defined(ALPHATEST) || defined(NEED_UV)\nvarying vec2 vUV;\n#endif\n#if defined(ALPHATEST)\nuniform sampler2D diffuseSampler;\n#endif\nvoid main(void)\n{\n#if defined(ALPHATEST)\nvec4 diffuseColor=texture2D(diffuseSampler,vUV);\nif (diffuseColor.a<0.4)\ndiscard;\n#endif\ngl_FragColor=vec4(0.0,0.0,0.0,1.0);\n}\n",vrDistortionCorrectionPixelShader:"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform vec2 LensCenter;\nuniform vec2 Scale;\nuniform vec2 ScaleIn;\nuniform vec4 HmdWarpParam;\nvec2 HmdWarp(vec2 in01) {\nvec2 theta=(in01-LensCenter)*ScaleIn; \nfloat rSq=theta.x*theta.x+theta.y*theta.y;\nvec2 rvector=theta*(HmdWarpParam.x+HmdWarpParam.y*rSq+HmdWarpParam.z*rSq*rSq+HmdWarpParam.w*rSq*rSq*rSq);\nreturn LensCenter+Scale*rvector;\n}\nvoid main(void)\n{\nvec2 tc=HmdWarp(vUV);\nif (tc.x <0.0 || tc.x>1.0 || tc.y<0.0 || tc.y>1.0)\ngl_FragColor=vec4(0.0,0.0,0.0,1.0);\nelse{\ngl_FragColor=vec4(texture2D(textureSampler,tc).rgb,1.0);\n}\n}"},BABYLON.Effect.IncludesShadersStore={bonesDeclaration:"#if NUM_BONE_INFLUENCERS>0\nuniform mat4 mBones[BonesPerMesh];\nattribute vec4 matricesIndices;\nattribute vec4 matricesWeights;\n#if NUM_BONE_INFLUENCERS>4\nattribute vec4 matricesIndicesExtra;\nattribute vec4 matricesWeightsExtra;\n#endif\n#endif",bonesVertex:"#if NUM_BONE_INFLUENCERS>0\nmat4 influence;\ninfluence=mBones[int(matricesIndices[0])]*matricesWeights[0];\n#if NUM_BONE_INFLUENCERS>1\ninfluence+=mBones[int(matricesIndices[1])]*matricesWeights[1];\n#endif \n#if NUM_BONE_INFLUENCERS>2\ninfluence+=mBones[int(matricesIndices[2])]*matricesWeights[2];\n#endif \n#if NUM_BONE_INFLUENCERS>3\ninfluence+=mBones[int(matricesIndices[3])]*matricesWeights[3];\n#endif \n#if NUM_BONE_INFLUENCERS>4\ninfluence+=mBones[int(matricesIndicesExtra[0])]*matricesWeightsExtra[0];\n#endif \n#if NUM_BONE_INFLUENCERS>5\ninfluence+=mBones[int(matricesIndicesExtra[1])]*matricesWeightsExtra[1];\n#endif \n#if NUM_BONE_INFLUENCERS>6\ninfluence+=mBones[int(matricesIndicesExtra[2])]*matricesWeightsExtra[2];\n#endif \n#if NUM_BONE_INFLUENCERS>7\ninfluence+=mBones[int(matricesIndicesExtra[3])]*matricesWeightsExtra[3];\n#endif \nfinalWorld=finalWorld*influence;\n#endif",bumpFragment:"#ifdef BUMP\nvec2 bumpUV=vBumpUV;\n#endif\n#if defined(BUMP) || defined(PARALLAX)\nmat3 TBN=cotangent_frame(normalW*vBumpInfos.y,-viewDirectionW,bumpUV);\n#endif\n#ifdef PARALLAX\nmat3 invTBN=transposeMat3(TBN);\n#ifdef PARALLAXOCCLUSION\nvec2 uvOffset=parallaxOcclusion(invTBN*-viewDirectionW,invTBN*normalW,bumpUV,vBumpInfos.z);\n#else\nvec2 uvOffset=parallaxOffset(invTBN*viewDirectionW,vBumpInfos.z);\n#endif\ndiffuseUV+=uvOffset;\nbumpUV+=uvOffset;\n#endif\n#ifdef BUMP\nnormalW=perturbNormal(viewDirectionW,TBN,bumpUV);\n#endif",bumpFragmentFunctions:"#ifdef BUMP\nvarying vec2 vBumpUV;\nuniform vec3 vBumpInfos;\nuniform sampler2D bumpSampler;\n\nmat3 cotangent_frame(vec3 normal,vec3 p,vec2 uv)\n{\n\nvec3 dp1=dFdx(p);\nvec3 dp2=dFdy(p);\nvec2 duv1=dFdx(uv);\nvec2 duv2=dFdy(uv);\n\nvec3 dp2perp=cross(dp2,normal);\nvec3 dp1perp=cross(normal,dp1);\nvec3 tangent=dp2perp*duv1.x+dp1perp*duv2.x;\nvec3 binormal=dp2perp*duv1.y+dp1perp*duv2.y;\n\nfloat invmax=inversesqrt(max(dot(tangent,tangent),dot(binormal,binormal)));\nreturn mat3(tangent*invmax,binormal*invmax,normal);\n}\nvec3 perturbNormal(vec3 viewDir,mat3 cotangentFrame,vec2 uv)\n{\nvec3 map=texture2D(bumpSampler,uv).xyz;\n#ifdef INVERTNORMALMAPX\nmap.x=1.0-map.x;\n#endif\n#ifdef INVERTNORMALMAPY\nmap.y=1.0-map.y;\n#endif\nmap=map*255./127.-128./127.;\nreturn normalize(cotangentFrame*map);\n}\n#ifdef PARALLAX\nconst float minSamples=4.;\nconst float maxSamples=15.;\nconst int iMaxSamples=15;\n\nvec2 parallaxOcclusion(vec3 vViewDirCoT,vec3 vNormalCoT,vec2 texCoord,float parallaxScale) {\nfloat parallaxLimit=length(vViewDirCoT.xy)/vViewDirCoT.z;\nparallaxLimit*=parallaxScale;\nvec2 vOffsetDir=normalize(vViewDirCoT.xy);\nvec2 vMaxOffset=vOffsetDir*parallaxLimit;\nfloat numSamples=maxSamples+(dot(vViewDirCoT,vNormalCoT)*(minSamples-maxSamples));\nfloat stepSize=1.0/numSamples;\n\nfloat currRayHeight=1.0;\nvec2 vCurrOffset=vec2(0,0);\nvec2 vLastOffset=vec2(0,0);\nfloat lastSampledHeight=1.0;\nfloat currSampledHeight=1.0;\nfor (int i=0; i<iMaxSamples; i++)\n{\ncurrSampledHeight=texture2D(bumpSampler,vBumpUV+vCurrOffset).w;\n\nif (currSampledHeight>currRayHeight)\n{\nfloat delta1=currSampledHeight-currRayHeight;\nfloat delta2=(currRayHeight+stepSize)-lastSampledHeight;\nfloat ratio=delta1/(delta1+delta2);\nvCurrOffset=(ratio)* vLastOffset+(1.0-ratio)*vCurrOffset;\n\nbreak;\n}\nelse\n{\ncurrRayHeight-=stepSize;\nvLastOffset=vCurrOffset;\nvCurrOffset+=stepSize*vMaxOffset;\nlastSampledHeight=currSampledHeight;\n}\n}\nreturn vCurrOffset;\n}\nvec2 parallaxOffset(vec3 viewDir,float heightScale)\n{\n\nfloat height=texture2D(bumpSampler,vBumpUV).w;\nvec2 texCoordOffset=heightScale*viewDir.xy*height;\nreturn -texCoordOffset;\n}\n#endif\n#endif",clipPlaneFragment:"#ifdef CLIPPLANE\nif (fClipDistance>0.0)\n{\ndiscard;\n}\n#endif",clipPlaneFragmentDeclaration:"#ifdef CLIPPLANE\nvarying float fClipDistance;\n#endif",clipPlaneVertex:"#ifdef CLIPPLANE\nfClipDistance=dot(worldPos,vClipPlane);\n#endif",clipPlaneVertexDeclaration:"#ifdef CLIPPLANE\nuniform vec4 vClipPlane;\nvarying float fClipDistance;\n#endif",colorCurves:"const vec3 HDTVRec709_RGBLuminanceCoefficients=vec3(0.2126,0.7152,0.0722);\nvec3 applyColorCurves(vec3 original) {\nvec3 result=original;\n\n\n\nfloat luma=dot(result.rgb,HDTVRec709_RGBLuminanceCoefficients);\nvec2 curveMix=clamp(vec2(luma*3.0-1.5,luma*-3.0+1.5),vec2(0.0,0.0),vec2(1.0,1.0));\nvec4 colorCurve=vCameraColorCurveNeutral+curveMix.x*vCameraColorCurvePositive-curveMix.y*vCameraColorCurveNegative;\nresult.rgb*=colorCurve.rgb;\nresult.rgb=mix(vec3(luma,luma,luma),result.rgb,colorCurve.a);\nreturn result;\n}",colorCurvesDefinition:"uniform vec4 vCameraColorCurveNeutral;\nuniform vec4 vCameraColorCurvePositive;\nuniform vec4 vCameraColorCurveNegative;",colorGrading:"vec4 colorGrades(vec4 color) \n{ \n\nfloat sliceContinuous=color.z*vCameraColorGradingInfos.z;\nfloat sliceInteger=floor(sliceContinuous);\n\n\nfloat sliceFraction=sliceContinuous-sliceInteger; \n\nvec2 sliceUV=color.xy*vCameraColorGradingScaleOffset.xy+vCameraColorGradingScaleOffset.zw;\n\n\nsliceUV.x+=sliceInteger*vCameraColorGradingInfos.w;\nvec4 slice0Color=texture2D(cameraColorGrading2DSampler,sliceUV);\nsliceUV.x+=vCameraColorGradingInfos.w;\nvec4 slice1Color=texture2D(cameraColorGrading2DSampler,sliceUV);\nvec3 result=mix(slice0Color.rgb,slice1Color.rgb,sliceFraction);\ncolor.rgb=mix(color.rgb,result,vCameraColorGradingInfos.x);\nreturn color;\n}",colorGradingDefinition:"uniform sampler2D cameraColorGrading2DSampler;\nuniform vec4 vCameraColorGradingInfos;\nuniform vec4 vCameraColorGradingScaleOffset;",fogFragment:"#ifdef FOG\nfloat fog=CalcFogFactor();\ncolor.rgb=fog*color.rgb+(1.0-fog)*vFogColor;\n#endif",fogFragmentDeclaration:"#ifdef FOG\n#define FOGMODE_NONE 0.\n#define FOGMODE_EXP 1.\n#define FOGMODE_EXP2 2.\n#define FOGMODE_LINEAR 3.\n#define E 2.71828\nuniform vec4 vFogInfos;\nuniform vec3 vFogColor;\nvarying float fFogDistance;\nfloat CalcFogFactor()\n{\nfloat fogCoeff=1.0;\nfloat fogStart=vFogInfos.y;\nfloat fogEnd=vFogInfos.z;\nfloat fogDensity=vFogInfos.w;\nif (FOGMODE_LINEAR == vFogInfos.x)\n{\nfogCoeff=(fogEnd-fFogDistance)/(fogEnd-fogStart);\n}\nelse if (FOGMODE_EXP == vFogInfos.x)\n{\nfogCoeff=1.0/pow(E,fFogDistance*fogDensity);\n}\nelse if (FOGMODE_EXP2 == vFogInfos.x)\n{\nfogCoeff=1.0/pow(E,fFogDistance*fFogDistance*fogDensity*fogDensity);\n}\nreturn clamp(fogCoeff,0.0,1.0);\n}\n#endif",fogVertex:"#ifdef FOG\nfFogDistance=(view*worldPos).z;\n#endif",fogVertexDeclaration:"#ifdef FOG\nvarying float fFogDistance;\n#endif",fresnelFunction:"#ifdef FRESNEL\nfloat computeFresnelTerm(vec3 viewDirection,vec3 worldNormal,float bias,float power)\n{\nfloat fresnelTerm=pow(bias+abs(dot(viewDirection,worldNormal)),power);\nreturn clamp(fresnelTerm,0.,1.);\n}\n#endif",harmonicsFunctions:"#ifdef USESPHERICALFROMREFLECTIONMAP\nuniform vec3 vSphericalX;\nuniform vec3 vSphericalY;\nuniform vec3 vSphericalZ;\nuniform vec3 vSphericalXX;\nuniform vec3 vSphericalYY;\nuniform vec3 vSphericalZZ;\nuniform vec3 vSphericalXY;\nuniform vec3 vSphericalYZ;\nuniform vec3 vSphericalZX;\nvec3 EnvironmentIrradiance(vec3 normal)\n{\n\n\n\nvec3 result =\nvSphericalX*normal.x +\nvSphericalY*normal.y +\nvSphericalZ*normal.z +\nvSphericalXX*normal.x*normal.x +\nvSphericalYY*normal.y*normal.y +\nvSphericalZZ*normal.z*normal.z +\nvSphericalYZ*normal.y*normal.z +\nvSphericalZX*normal.z*normal.x +\nvSphericalXY*normal.x*normal.y;\nreturn result.rgb;\n}\n#endif",helperFunctions:"mat3 transposeMat3(mat3 inMatrix) {\nvec3 i0=inMatrix[0];\nvec3 i1=inMatrix[1];\nvec3 i2=inMatrix[2];\nmat3 outMatrix=mat3(\nvec3(i0.x,i1.x,i2.x),\nvec3(i0.y,i1.y,i2.y),\nvec3(i0.z,i1.z,i2.z)\n);\nreturn outMatrix;\n}",instancesDeclaration:"#ifdef INSTANCES\nattribute vec4 world0;\nattribute vec4 world1;\nattribute vec4 world2;\nattribute vec4 world3;\n#else\nuniform mat4 world;\n#endif",instancesVertex:"#ifdef INSTANCES\nmat4 finalWorld=mat4(world0,world1,world2,world3);\n#else\nmat4 finalWorld=world;\n#endif",lightFragment:"#ifdef LIGHT{X}\n#ifndef SPECULARTERM\nvec3 vLightSpecular{X}=vec3(0.);\n#endif\n#ifdef SPOTLIGHT{X}\ninfo=computeSpotLighting(viewDirectionW,normalW,vLightData{X},vLightDirection{X},vLightDiffuse{X}.rgb,vLightSpecular{X},vLightDiffuse{X}.a,glossiness);\n#endif\n#ifdef HEMILIGHT{X}\ninfo=computeHemisphericLighting(viewDirectionW,normalW,vLightData{X},vLightDiffuse{X}.rgb,vLightSpecular{X},vLightGround{X},glossiness);\n#endif\n#if defined(POINTLIGHT{X}) || defined(DIRLIGHT{X})\ninfo=computeLighting(viewDirectionW,normalW,vLightData{X},vLightDiffuse{X}.rgb,vLightSpecular{X},vLightDiffuse{X}.a,glossiness);\n#endif\n#ifdef SHADOW{X}\n#ifdef SHADOWVSM{X}\nshadow=computeShadowWithVSM(vPositionFromLight{X},shadowSampler{X},shadowsInfo{X}.z,shadowsInfo{X}.x);\n#else\n#ifdef SHADOWPCF{X}\n#if defined(POINTLIGHT{X})\nshadow=computeShadowWithPCFCube(vLightData{X}.xyz,shadowSampler{X},shadowsInfo{X}.y,shadowsInfo{X}.z,shadowsInfo{X}.x);\n#else\nshadow=computeShadowWithPCF(vPositionFromLight{X},shadowSampler{X},shadowsInfo{X}.y,shadowsInfo{X}.z,shadowsInfo{X}.x);\n#endif\n#else\n#if defined(POINTLIGHT{X})\nshadow=computeShadowCube(vLightData{X}.xyz,shadowSampler{X},shadowsInfo{X}.x,shadowsInfo{X}.z);\n#else\nshadow=computeShadow(vPositionFromLight{X},shadowSampler{X},shadowsInfo{X}.x,shadowsInfo{X}.z);\n#endif\n#endif\n#endif\n#else\nshadow=1.;\n#endif\ndiffuseBase+=info.diffuse*shadow;\n#ifdef SPECULARTERM\nspecularBase+=info.specular*shadow;\n#endif\n#endif",lightFragmentDeclaration:"#ifdef LIGHT{X}\nuniform vec4 vLightData{X};\nuniform vec4 vLightDiffuse{X};\n#ifdef SPECULARTERM\nuniform vec3 vLightSpecular{X};\n#endif\n#ifdef SHADOW{X}\n#if defined(SPOTLIGHT{X}) || defined(DIRLIGHT{X})\nvarying vec4 vPositionFromLight{X};\nuniform sampler2D shadowSampler{X};\n#else\nuniform samplerCube shadowSampler{X};\n#endif\nuniform vec3 shadowsInfo{X};\n#endif\n#ifdef SPOTLIGHT{X}\nuniform vec4 vLightDirection{X};\n#endif\n#ifdef HEMILIGHT{X}\nuniform vec3 vLightGround{X};\n#endif\n#endif",lightsFragmentFunctions:"\nstruct lightingInfo\n{\nvec3 diffuse;\n#ifdef SPECULARTERM\nvec3 specular;\n#endif\n};\nlightingInfo computeLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec3 diffuseColor,vec3 specularColor,float range,float glossiness) {\nlightingInfo result;\nvec3 lightVectorW;\nfloat attenuation=1.0;\nif (lightData.w == 0.)\n{\nvec3 direction=lightData.xyz-vPositionW;\nattenuation=max(0.,1.0-length(direction)/range);\nlightVectorW=normalize(direction);\n}\nelse\n{\nlightVectorW=normalize(-lightData.xyz);\n}\n\nfloat ndl=max(0.,dot(vNormal,lightVectorW));\nresult.diffuse=ndl*diffuseColor*attenuation;\n#ifdef SPECULARTERM\n\nvec3 angleW=normalize(viewDirectionW+lightVectorW);\nfloat specComp=max(0.,dot(vNormal,angleW));\nspecComp=pow(specComp,max(1.,glossiness));\nresult.specular=specComp*specularColor*attenuation;\n#endif\nreturn result;\n}\nlightingInfo computeSpotLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec4 lightDirection,vec3 diffuseColor,vec3 specularColor,float range,float glossiness) {\nlightingInfo result;\nvec3 direction=lightData.xyz-vPositionW;\nvec3 lightVectorW=normalize(direction);\nfloat attenuation=max(0.,1.0-length(direction)/range);\n\nfloat cosAngle=max(0.,dot(-lightDirection.xyz,lightVectorW));\nif (cosAngle>=lightDirection.w)\n{\ncosAngle=max(0.,pow(cosAngle,lightData.w));\nattenuation*=cosAngle;\n\nfloat ndl=max(0.,dot(vNormal,-lightDirection.xyz));\nresult.diffuse=ndl*diffuseColor*attenuation;\n#ifdef SPECULARTERM\n\nvec3 angleW=normalize(viewDirectionW-lightDirection.xyz);\nfloat specComp=max(0.,dot(vNormal,angleW));\nspecComp=pow(specComp,max(1.,glossiness));\nresult.specular=specComp*specularColor*attenuation;\n#endif\nreturn result;\n}\nresult.diffuse=vec3(0.);\n#ifdef SPECULARTERM\nresult.specular=vec3(0.);\n#endif\nreturn result;\n}\nlightingInfo computeHemisphericLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec3 diffuseColor,vec3 specularColor,vec3 groundColor,float glossiness) {\nlightingInfo result;\n\nfloat ndl=dot(vNormal,lightData.xyz)*0.5+0.5;\nresult.diffuse=mix(groundColor,diffuseColor,ndl);\n#ifdef SPECULARTERM\n\nvec3 angleW=normalize(viewDirectionW+lightData.xyz);\nfloat specComp=max(0.,dot(vNormal,angleW));\nspecComp=pow(specComp,max(1.,glossiness));\nresult.specular=specComp*specularColor;\n#endif\nreturn result;\n}\n",logDepthDeclaration:"#ifdef LOGARITHMICDEPTH\nuniform float logarithmicDepthConstant;\nvarying float vFragmentDepth;\n#endif",logDepthFragment:"#ifdef LOGARITHMICDEPTH\ngl_FragDepthEXT=log2(vFragmentDepth)*logarithmicDepthConstant*0.5;\n#endif",logDepthVertex:"#ifdef LOGARITHMICDEPTH\nvFragmentDepth=1.0+gl_Position.w;\ngl_Position.z=log2(max(0.000001,vFragmentDepth))*logarithmicDepthConstant;\n#endif",pbrFunctions:"\n#define RECIPROCAL_PI2 0.15915494\n#define FRESNEL_MAXIMUM_ON_ROUGH 0.25\n\nconst float kPi=3.1415926535897932384626433832795;\nconst float kRougnhessToAlphaScale=0.1;\nconst float kRougnhessToAlphaOffset=0.29248125;\nfloat Square(float value)\n{\nreturn value*value;\n}\nfloat getLuminance(vec3 color)\n{\nreturn clamp(dot(color,vec3(0.2126,0.7152,0.0722)),0.,1.);\n}\nfloat convertRoughnessToAverageSlope(float roughness)\n{\n\nconst float kMinimumVariance=0.0005;\nfloat alphaG=Square(roughness)+kMinimumVariance;\nreturn alphaG;\n}\n\nfloat getMipMapIndexFromAverageSlope(float maxMipLevel,float alpha)\n{\n\n\n\n\n\n\n\nfloat mip=kRougnhessToAlphaOffset+maxMipLevel+(maxMipLevel*kRougnhessToAlphaScale*log2(alpha));\nreturn clamp(mip,0.,maxMipLevel);\n}\nfloat getMipMapIndexFromAverageSlopeWithPMREM(float maxMipLevel,float alphaG)\n{\nfloat specularPower=clamp(2./alphaG-2.,0.000001,2048.);\n\nreturn clamp(- 0.5*log2(specularPower)+5.5,0.,maxMipLevel);\n}\n\nfloat smithVisibilityG1_TrowbridgeReitzGGX(float dot,float alphaG)\n{\nfloat tanSquared=(1.0-dot*dot)/(dot*dot);\nreturn 2.0/(1.0+sqrt(1.0+alphaG*alphaG*tanSquared));\n}\nfloat smithVisibilityG_TrowbridgeReitzGGX_Walter(float NdotL,float NdotV,float alphaG)\n{\nreturn smithVisibilityG1_TrowbridgeReitzGGX(NdotL,alphaG)*smithVisibilityG1_TrowbridgeReitzGGX(NdotV,alphaG);\n}\n\n\nfloat normalDistributionFunction_TrowbridgeReitzGGX(float NdotH,float alphaG)\n{\n\n\n\nfloat a2=Square(alphaG);\nfloat d=NdotH*NdotH*(a2-1.0)+1.0;\nreturn a2/(kPi*d*d);\n}\nvec3 fresnelSchlickGGX(float VdotH,vec3 reflectance0,vec3 reflectance90)\n{\nreturn reflectance0+(reflectance90-reflectance0)*pow(clamp(1.0-VdotH,0.,1.),5.0);\n}\nvec3 FresnelSchlickEnvironmentGGX(float VdotN,vec3 reflectance0,vec3 reflectance90,float smoothness)\n{\n\nfloat weight=mix(FRESNEL_MAXIMUM_ON_ROUGH,1.0,smoothness);\nreturn reflectance0+weight*(reflectance90-reflectance0)*pow(clamp(1.0-VdotN,0.,1.),5.0);\n}\n\nvec3 computeSpecularTerm(float NdotH,float NdotL,float NdotV,float VdotH,float roughness,vec3 specularColor,vec3 reflectance90)\n{\nfloat alphaG=convertRoughnessToAverageSlope(roughness);\nfloat distribution=normalDistributionFunction_TrowbridgeReitzGGX(NdotH,alphaG);\nfloat visibility=smithVisibilityG_TrowbridgeReitzGGX_Walter(NdotL,NdotV,alphaG);\nvisibility/=(4.0*NdotL*NdotV); \nvec3 fresnel=fresnelSchlickGGX(VdotH,specularColor,reflectance90);\nfloat specTerm=max(0.,visibility*distribution)*NdotL;\nreturn fresnel*specTerm*kPi; \n}\nfloat computeDiffuseTerm(float NdotL,float NdotV,float VdotH,float roughness)\n{\n\n\nfloat diffuseFresnelNV=pow(clamp(1.0-NdotL,0.000001,1.),5.0);\nfloat diffuseFresnelNL=pow(clamp(1.0-NdotV,0.000001,1.),5.0);\nfloat diffuseFresnel90=0.5+2.0*VdotH*VdotH*roughness;\nfloat diffuseFresnelTerm =\n(1.0+(diffuseFresnel90-1.0)*diffuseFresnelNL) *\n(1.0+(diffuseFresnel90-1.0)*diffuseFresnelNV);\nreturn diffuseFresnelTerm*NdotL;\n\n\n}\nfloat adjustRoughnessFromLightProperties(float roughness,float lightRadius,float lightDistance)\n{\n#ifdef USEPHYSICALLIGHTFALLOFF\n\nfloat lightRoughness=lightRadius/lightDistance;\n\nfloat totalRoughness=clamp(lightRoughness+roughness,0.,1.);\nreturn totalRoughness;\n#else\nreturn roughness;\n#endif\n}\nfloat computeDefaultMicroSurface(float microSurface,vec3 reflectivityColor)\n{\nfloat kReflectivityNoAlphaWorkflow_SmoothnessMax=0.95;\nfloat reflectivityLuminance=getLuminance(reflectivityColor);\nfloat reflectivityLuma=sqrt(reflectivityLuminance);\nmicroSurface=reflectivityLuma*kReflectivityNoAlphaWorkflow_SmoothnessMax;\nreturn microSurface;\n}\nvec3 toLinearSpace(vec3 color)\n{\nreturn vec3(pow(color.r,2.2),pow(color.g,2.2),pow(color.b,2.2));\n}\nvec3 toGammaSpace(vec3 color)\n{\nreturn vec3(pow(color.r,1.0/2.2),pow(color.g,1.0/2.2),pow(color.b,1.0/2.2));\n}\n#ifdef CAMERATONEMAP\nvec3 toneMaps(vec3 color)\n{\ncolor=max(color,0.0);\n\ncolor.rgb=color.rgb*vCameraInfos.x;\nfloat tuning=1.5; \n\n\nvec3 tonemapped=1.0-exp2(-color.rgb*tuning); \ncolor.rgb=mix(color.rgb,tonemapped,1.0);\nreturn color;\n}\n#endif\n#ifdef CAMERACONTRAST\nvec4 contrasts(vec4 color)\n{\ncolor=clamp(color,0.0,1.0);\nvec3 resultHighContrast=color.rgb*color.rgb*(3.0-2.0*color.rgb);\nfloat contrast=vCameraInfos.y;\nif (contrast<1.0)\n{\n\ncolor.rgb=mix(vec3(0.5,0.5,0.5),color.rgb,contrast);\n}\nelse\n{\n\ncolor.rgb=mix(color.rgb,resultHighContrast,contrast-1.0);\n}\nreturn color;\n}\n#endif",
  40. pbrLightFunctions:"\nstruct lightingInfo\n{\nvec3 diffuse;\n#ifdef SPECULARTERM\nvec3 specular;\n#endif\n};\nfloat computeDistanceLightFalloff(vec3 lightOffset,float lightDistanceSquared,float range)\n{ \n#ifdef USEPHYSICALLIGHTFALLOFF\nfloat lightDistanceFalloff=1.0/((lightDistanceSquared+0.0001));\n#else\nfloat lightDistanceFalloff=max(0.,1.0-length(lightOffset)/range);\n#endif\nreturn lightDistanceFalloff;\n}\nfloat computeDirectionalLightFalloff(vec3 lightDirection,vec3 directionToLightCenterW,float lightAngle,float exponent)\n{\nfloat falloff=0.0;\n#ifdef USEPHYSICALLIGHTFALLOFF\nfloat cosHalfAngle=cos(lightAngle*0.5);\nconst float kMinusLog2ConeAngleIntensityRatio=6.64385618977; \n\n\n\n\n\nfloat concentrationKappa=kMinusLog2ConeAngleIntensityRatio/(1.0-cosHalfAngle);\n\n\nvec4 lightDirectionSpreadSG=vec4(-lightDirection*concentrationKappa,-concentrationKappa);\nfalloff=exp2(dot(vec4(directionToLightCenterW,1.0),lightDirectionSpreadSG));\n#else\nfloat cosAngle=max(0.000000000000001,dot(-lightDirection,directionToLightCenterW));\nif (cosAngle>=lightAngle)\n{\nfalloff=max(0.,pow(cosAngle,exponent));\n}\n#endif\nreturn falloff;\n}\nlightingInfo computeLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec3 diffuseColor,vec3 specularColor,float rangeRadius,float roughness,float NdotV,vec3 reflectance90,out float NdotL) {\nlightingInfo result;\nvec3 lightDirection;\nfloat attenuation=1.0;\nfloat lightDistance;\n\nif (lightData.w == 0.)\n{\nvec3 lightOffset=lightData.xyz-vPositionW;\nfloat lightDistanceSquared=dot(lightOffset,lightOffset);\nattenuation=computeDistanceLightFalloff(lightOffset,lightDistanceSquared,rangeRadius);\nlightDistance=sqrt(lightDistanceSquared);\nlightDirection=normalize(lightOffset);\n}\n\nelse\n{\nlightDistance=length(-lightData.xyz);\nlightDirection=normalize(-lightData.xyz);\n}\n\nroughness=adjustRoughnessFromLightProperties(roughness,rangeRadius,lightDistance);\n\nvec3 H=normalize(viewDirectionW+lightDirection);\nNdotL=max(0.00000000001,dot(vNormal,lightDirection));\nfloat VdotH=clamp(0.00000000001,1.0,dot(viewDirectionW,H));\nfloat diffuseTerm=computeDiffuseTerm(NdotL,NdotV,VdotH,roughness);\nresult.diffuse=diffuseTerm*diffuseColor*attenuation;\n#ifdef SPECULARTERM\n\nfloat NdotH=max(0.00000000001,dot(vNormal,H));\nvec3 specTerm=computeSpecularTerm(NdotH,NdotL,NdotV,VdotH,roughness,specularColor,reflectance90);\nresult.specular=specTerm*attenuation;\n#endif\nreturn result;\n}\nlightingInfo computeSpotLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec4 lightDirection,vec3 diffuseColor,vec3 specularColor,float rangeRadius,float roughness,float NdotV,vec3 reflectance90,out float NdotL) {\nlightingInfo result;\nvec3 lightOffset=lightData.xyz-vPositionW;\nvec3 directionToLightCenterW=normalize(lightOffset);\n\nfloat lightDistanceSquared=dot(lightOffset,lightOffset);\nfloat attenuation=computeDistanceLightFalloff(lightOffset,lightDistanceSquared,rangeRadius);\n\nfloat directionalAttenuation=computeDirectionalLightFalloff(lightDirection.xyz,directionToLightCenterW,lightDirection.w,lightData.w);\nattenuation*=directionalAttenuation;\n\nfloat lightDistance=sqrt(lightDistanceSquared);\nroughness=adjustRoughnessFromLightProperties(roughness,rangeRadius,lightDistance);\n\nvec3 H=normalize(viewDirectionW-lightDirection.xyz);\nNdotL=max(0.00000000001,dot(vNormal,-lightDirection.xyz));\nfloat VdotH=clamp(dot(viewDirectionW,H),0.00000000001,1.0);\nfloat diffuseTerm=computeDiffuseTerm(NdotL,NdotV,VdotH,roughness);\nresult.diffuse=diffuseTerm*diffuseColor*attenuation;\n#ifdef SPECULARTERM\n\nfloat NdotH=max(0.00000000001,dot(vNormal,H));\nvec3 specTerm=computeSpecularTerm(NdotH,NdotL,NdotV,VdotH,roughness,specularColor,reflectance90);\nresult.specular=specTerm*attenuation;\n#endif\nreturn result;\n}\nlightingInfo computeHemisphericLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec3 diffuseColor,vec3 specularColor,vec3 groundColor,float roughness,float NdotV,vec3 reflectance90,out float NdotL) {\nlightingInfo result;\n\n\n\nNdotL=dot(vNormal,lightData.xyz)*0.5+0.5;\nresult.diffuse=mix(groundColor,diffuseColor,NdotL);\n#ifdef SPECULARTERM\n\nvec3 lightVectorW=normalize(lightData.xyz);\nvec3 H=normalize(viewDirectionW+lightVectorW);\nfloat NdotH=max(0.00000000001,dot(vNormal,H));\nNdotL=max(0.00000000001,NdotL);\nfloat VdotH=clamp(0.00000000001,1.0,dot(viewDirectionW,H));\nvec3 specTerm=computeSpecularTerm(NdotH,NdotL,NdotV,VdotH,roughness,specularColor,reflectance90);\nresult.specular=specTerm;\n#endif\nreturn result;\n}",pbrLightFunctionsCall:"#ifdef LIGHT{X}\n#ifndef SPECULARTERM\nvec3 vLightSpecular{X}=vec3(0.0);\n#endif\n#ifdef SPOTLIGHT{X}\ninfo=computeSpotLighting(viewDirectionW,normalW,vLightData{X},vLightDirection{X},vLightDiffuse{X}.rgb,vLightSpecular{X},vLightDiffuse{X}.a,roughness,NdotV,specularEnvironmentR90,NdotL);\n#endif\n#ifdef HEMILIGHT{X}\ninfo=computeHemisphericLighting(viewDirectionW,normalW,vLightData{X},vLightDiffuse{X}.rgb,vLightSpecular{X},vLightGround{X},roughness,NdotV,specularEnvironmentR90,NdotL);\n#endif\n#if defined(POINTLIGHT{X}) || defined(DIRLIGHT{X})\ninfo=computeLighting(viewDirectionW,normalW,vLightData{X},vLightDiffuse{X}.rgb,vLightSpecular{X},vLightDiffuse{X}.a,roughness,NdotV,specularEnvironmentR90,NdotL);\n#endif\n#ifdef SHADOW{X}\n#ifdef SHADOWVSM{X}\nnotShadowLevel=computeShadowWithVSM(vPositionFromLight{X},shadowSampler{X},shadowsInfo{X}.z,shadowsInfo{X}.x);\n#else\n#ifdef SHADOWPCF{X}\n#if defined(POINTLIGHT{X})\nnotShadowLevel=computeShadowWithPCFCube(vLightData{X}.xyz,shadowSampler{X},shadowsInfo{X}.y,shadowsInfo{X}.z,shadowsInfo{X}.x);\n#else\nnotShadowLevel=computeShadowWithPCF(vPositionFromLight{X},shadowSampler{X},shadowsInfo{X}.y,shadowsInfo{X}.z,shadowsInfo{X}.x);\n#endif\n#else\n#if defined(POINTLIGHT{X})\nnotShadowLevel=computeShadowCube(vLightData{X}.xyz,shadowSampler{X},shadowsInfo{X}.x,shadowsInfo{X}.z);\n#else\nnotShadowLevel=computeShadow(vPositionFromLight{X},shadowSampler{X},shadowsInfo{X}.x,shadowsInfo{X}.z);\n#endif\n#endif\n#endif\n#else\nnotShadowLevel=1.;\n#endif\nlightDiffuseContribution+=info.diffuse*notShadowLevel;\n#ifdef OVERLOADEDSHADOWVALUES\nif (NdotL<0.000000000011)\n{\nnotShadowLevel=1.;\n}\nshadowedOnlyLightDiffuseContribution*=notShadowLevel;\n#endif\n#ifdef SPECULARTERM\nlightSpecularContribution+=info.specular*notShadowLevel;\n#endif\n#endif",pbrShadowFunctions:"\n#ifdef SHADOWS\nfloat unpack(vec4 color)\n{\nconst vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);\nreturn dot(color,bit_shift);\n}\nuniform vec2 depthValues;\nfloat computeShadowCube(vec3 lightPosition,samplerCube shadowSampler,float darkness,float bias)\n{\nvec3 directionToLight=vPositionW-lightPosition;\nfloat depth=length(directionToLight);\ndepth=clamp(depth,0.,1.0);\ndirectionToLight=normalize(directionToLight);\ndirectionToLight.y =-directionToLight.y;\nfloat shadow=unpack(textureCube(shadowSampler,directionToLight))+bias;\nif (depth>shadow)\n{\n#ifdef OVERLOADEDSHADOWVALUES\nreturn mix(1.0,darkness,vOverloadedShadowIntensity.x);\n#else\nreturn darkness;\n#endif\n}\nreturn 1.0;\n}\nfloat computeShadowWithPCFCube(vec3 lightPosition,samplerCube shadowSampler,float mapSize,float bias,float darkness)\n{\nvec3 directionToLight=vPositionW-lightPosition;\nfloat depth=length(directionToLight);\ndepth=(depth-depthValues.x)/(depthValues.y-depthValues.x);\ndepth=clamp(depth,0.,1.0);\ndirectionToLight=normalize(directionToLight);\ndirectionToLight.y=-directionToLight.y;\nfloat visibility=1.;\nvec3 poissonDisk[4];\npoissonDisk[0]=vec3(-1.0,1.0,-1.0);\npoissonDisk[1]=vec3(1.0,-1.0,-1.0);\npoissonDisk[2]=vec3(-1.0,-1.0,-1.0);\npoissonDisk[3]=vec3(1.0,-1.0,1.0);\n\nfloat biasedDepth=depth-bias;\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[0]*mapSize))<biasedDepth) visibility-=0.25;\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[1]*mapSize))<biasedDepth) visibility-=0.25;\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[2]*mapSize))<biasedDepth) visibility-=0.25;\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[3]*mapSize))<biasedDepth) visibility-=0.25;\n#ifdef OVERLOADEDSHADOWVALUES\nreturn min(1.0,mix(1.0,visibility+darkness,vOverloadedShadowIntensity.x));\n#else\nreturn min(1.0,visibility+darkness);\n#endif\n}\nfloat computeShadow(vec4 vPositionFromLight,sampler2D shadowSampler,float darkness,float bias)\n{\nvec3 depth=vPositionFromLight.xyz/vPositionFromLight.w;\ndepth=0.5*depth+vec3(0.5);\nvec2 uv=depth.xy;\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nfloat shadow=unpack(texture2D(shadowSampler,uv))+bias;\nif (depth.z>shadow)\n{\n#ifdef OVERLOADEDSHADOWVALUES\nreturn mix(1.0,darkness,vOverloadedShadowIntensity.x);\n#else\nreturn darkness;\n#endif\n}\nreturn 1.;\n}\nfloat computeShadowWithPCF(vec4 vPositionFromLight,sampler2D shadowSampler,float mapSize,float bias,float darkness)\n{\nvec3 depth=vPositionFromLight.xyz/vPositionFromLight.w;\ndepth=0.5*depth+vec3(0.5);\nvec2 uv=depth.xy;\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nfloat visibility=1.;\nvec2 poissonDisk[4];\npoissonDisk[0]=vec2(-0.94201624,-0.39906216);\npoissonDisk[1]=vec2(0.94558609,-0.76890725);\npoissonDisk[2]=vec2(-0.094184101,-0.92938870);\npoissonDisk[3]=vec2(0.34495938,0.29387760);\n\nfloat biasedDepth=depth.z-bias;\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[0]*mapSize))<biasedDepth) visibility-=0.25;\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[1]*mapSize))<biasedDepth) visibility-=0.25;\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[2]*mapSize))<biasedDepth) visibility-=0.25;\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[3]*mapSize))<biasedDepth) visibility-=0.25;\n#ifdef OVERLOADEDSHADOWVALUES\nreturn min(1.0,mix(1.0,visibility+darkness,vOverloadedShadowIntensity.x));\n#else\nreturn min(1.0,visibility+darkness);\n#endif\n}\n\nfloat unpackHalf(vec2 color)\n{\nreturn color.x+(color.y/255.0);\n}\nfloat linstep(float low,float high,float v) {\nreturn clamp((v-low)/(high-low),0.0,1.0);\n}\nfloat ChebychevInequality(vec2 moments,float compare,float bias)\n{\nfloat p=smoothstep(compare-bias,compare,moments.x);\nfloat variance=max(moments.y-moments.x*moments.x,0.02);\nfloat d=compare-moments.x;\nfloat p_max=linstep(0.2,1.0,variance/(variance+d*d));\nreturn clamp(max(p,p_max),0.0,1.0);\n}\nfloat computeShadowWithVSM(vec4 vPositionFromLight,sampler2D shadowSampler,float bias,float darkness)\n{\nvec3 depth=vPositionFromLight.xyz/vPositionFromLight.w;\ndepth=0.5*depth+vec3(0.5);\nvec2 uv=depth.xy;\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0 || depth.z>=1.0)\n{\nreturn 1.0;\n}\nvec4 texel=texture2D(shadowSampler,uv);\nvec2 moments=vec2(unpackHalf(texel.xy),unpackHalf(texel.zw));\n#ifdef OVERLOADEDSHADOWVALUES\nreturn min(1.0,mix(1.0,1.0-ChebychevInequality(moments,depth.z,bias)+darkness,vOverloadedShadowIntensity.x));\n#else\nreturn min(1.0,1.0-ChebychevInequality(moments,depth.z,bias)+darkness);\n#endif\n}\n#endif",pointCloudVertex:"#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif",pointCloudVertexDeclaration:"#ifdef POINTSIZE\nuniform float pointSize;\n#endif",reflectionFunction:"vec3 computeReflectionCoords(vec4 worldPos,vec3 worldNormal)\n{\n#ifdef REFLECTIONMAP_EQUIRECTANGULAR_FIXED\nvec3 direction=normalize(vDirectionW);\nfloat t=clamp(direction.y*-0.5+0.5,0.,1.0);\nfloat s=atan(direction.z,direction.x)*RECIPROCAL_PI2+0.5;\nreturn vec3(s,t,0);\n#endif\n#ifdef REFLECTIONMAP_EQUIRECTANGULAR\nvec3 cameraToVertex=normalize(worldPos.xyz-vEyePosition);\nvec3 r=reflect(cameraToVertex,worldNormal);\nfloat t=clamp(r.y*-0.5+0.5,0.,1.0);\nfloat s=atan(r.z,r.x)*RECIPROCAL_PI2+0.5;\nreturn vec3(s,t,0);\n#endif\n#ifdef REFLECTIONMAP_SPHERICAL\nvec3 viewDir=normalize(vec3(view*worldPos));\nvec3 viewNormal=normalize(vec3(view*vec4(worldNormal,0.0)));\nvec3 r=reflect(viewDir,viewNormal);\nr.z=r.z-1.0;\nfloat m=2.0*length(r);\nreturn vec3(r.x/m+0.5,1.0-r.y/m-0.5,0);\n#endif\n#ifdef REFLECTIONMAP_PLANAR\nvec3 viewDir=worldPos.xyz-vEyePosition;\nvec3 coords=normalize(reflect(viewDir,worldNormal));\nreturn vec3(reflectionMatrix*vec4(coords,1));\n#endif\n#ifdef REFLECTIONMAP_CUBIC\nvec3 viewDir=worldPos.xyz-vEyePosition;\nvec3 coords=reflect(viewDir,worldNormal);\n#ifdef INVERTCUBICMAP\ncoords.y=1.0-coords.y;\n#endif\nreturn vec3(reflectionMatrix*vec4(coords,0));\n#endif\n#ifdef REFLECTIONMAP_PROJECTION\nreturn vec3(reflectionMatrix*(view*worldPos));\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nreturn vPositionUVW;\n#endif\n#ifdef REFLECTIONMAP_EXPLICIT\nreturn vec3(0,0,0);\n#endif\n}",shadowsFragmentFunctions:"#ifdef SHADOWS\nfloat unpack(vec4 color)\n{\nconst vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);\nreturn dot(color,bit_shift);\n}\nuniform vec2 depthValues;\nfloat computeShadowCube(vec3 lightPosition,samplerCube shadowSampler,float darkness,float bias)\n{\nvec3 directionToLight=vPositionW-lightPosition;\nfloat depth=length(directionToLight);\ndepth=(depth-depthValues.x)/(depthValues.y-depthValues.x);\ndepth=clamp(depth,0.,1.0);\ndirectionToLight=normalize(directionToLight);\ndirectionToLight.y=-directionToLight.y;\nfloat shadow=unpack(textureCube(shadowSampler,directionToLight))+bias;\nif (depth>shadow)\n{\nreturn darkness;\n}\nreturn 1.0;\n}\nfloat computeShadowWithPCFCube(vec3 lightPosition,samplerCube shadowSampler,float mapSize,float bias,float darkness)\n{\nvec3 directionToLight=vPositionW-lightPosition;\nfloat depth=length(directionToLight);\ndepth=(depth-depthValues.x)/(depthValues.y-depthValues.x);\ndepth=clamp(depth,0.,1.0);\ndirectionToLight=normalize(directionToLight);\ndirectionToLight.y=-directionToLight.y;\nfloat visibility=1.;\nvec3 poissonDisk[4];\npoissonDisk[0]=vec3(-1.0,1.0,-1.0);\npoissonDisk[1]=vec3(1.0,-1.0,-1.0);\npoissonDisk[2]=vec3(-1.0,-1.0,-1.0);\npoissonDisk[3]=vec3(1.0,-1.0,1.0);\n\nfloat biasedDepth=depth-bias;\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[0]*mapSize))<biasedDepth) visibility-=0.25;\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[1]*mapSize))<biasedDepth) visibility-=0.25;\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[2]*mapSize))<biasedDepth) visibility-=0.25;\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[3]*mapSize))<biasedDepth) visibility-=0.25;\nreturn min(1.0,visibility+darkness);\n}\nfloat computeShadow(vec4 vPositionFromLight,sampler2D shadowSampler,float darkness,float bias)\n{\nvec3 depth=vPositionFromLight.xyz/vPositionFromLight.w;\ndepth=0.5*depth+vec3(0.5);\nvec2 uv=depth.xy;\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nfloat shadow=unpack(texture2D(shadowSampler,uv))+bias;\nif (depth.z>shadow)\n{\nreturn darkness;\n}\nreturn 1.;\n}\nfloat computeShadowWithPCF(vec4 vPositionFromLight,sampler2D shadowSampler,float mapSize,float bias,float darkness)\n{\nvec3 depth=vPositionFromLight.xyz/vPositionFromLight.w;\ndepth=0.5*depth+vec3(0.5);\nvec2 uv=depth.xy;\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nfloat visibility=1.;\nvec2 poissonDisk[4];\npoissonDisk[0]=vec2(-0.94201624,-0.39906216);\npoissonDisk[1]=vec2(0.94558609,-0.76890725);\npoissonDisk[2]=vec2(-0.094184101,-0.92938870);\npoissonDisk[3]=vec2(0.34495938,0.29387760);\n\nfloat biasedDepth=depth.z-bias;\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[0]*mapSize))<biasedDepth) visibility-=0.25;\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[1]*mapSize))<biasedDepth) visibility-=0.25;\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[2]*mapSize))<biasedDepth) visibility-=0.25;\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[3]*mapSize))<biasedDepth) visibility-=0.25;\nreturn min(1.0,visibility+darkness);\n}\n\nfloat unpackHalf(vec2 color)\n{\nreturn color.x+(color.y/255.0);\n}\nfloat linstep(float low,float high,float v) {\nreturn clamp((v-low)/(high-low),0.0,1.0);\n}\nfloat ChebychevInequality(vec2 moments,float compare,float bias)\n{\nfloat p=smoothstep(compare-bias,compare,moments.x);\nfloat variance=max(moments.y-moments.x*moments.x,0.02);\nfloat d=compare-moments.x;\nfloat p_max=linstep(0.2,1.0,variance/(variance+d*d));\nreturn clamp(max(p,p_max),0.0,1.0);\n}\nfloat computeShadowWithVSM(vec4 vPositionFromLight,sampler2D shadowSampler,float bias,float darkness)\n{\nvec3 depth=vPositionFromLight.xyz/vPositionFromLight.w;\ndepth=0.5*depth+vec3(0.5);\nvec2 uv=depth.xy;\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0 || depth.z>=1.0)\n{\nreturn 1.0;\n}\nvec4 texel=texture2D(shadowSampler,uv);\nvec2 moments=vec2(unpackHalf(texel.xy),unpackHalf(texel.zw));\nreturn min(1.0,1.0-ChebychevInequality(moments,depth.z,bias)+darkness);\n}\n#endif",shadowsVertex:"#ifdef SHADOWS\n#if defined(SPOTLIGHT{X}) || defined(DIRLIGHT{X})\nvPositionFromLight{X}=lightMatrix{X}*worldPos;\n#endif\n#endif",shadowsVertexDeclaration:"#ifdef SHADOWS\n#if defined(SPOTLIGHT{X}) || defined(DIRLIGHT{X})\nuniform mat4 lightMatrix{X};\nvarying vec4 vPositionFromLight{X};\n#endif\n#endif\n"},BABYLON.CollisionWorker='var BABYLON;!function(t){var e=function(t,e,o,i){return t.x>o.x+i?!1:o.x-i>e.x?!1:t.y>o.y+i?!1:o.y-i>e.y?!1:t.z>o.z+i?!1:!(o.z-i>e.z)},o=function(t,e,o,i){var s=e*e-4*t*o,r={root:0,found:!1};if(0>s)return r;var n=Math.sqrt(s),c=(-e-n)/(2*t),h=(-e+n)/(2*t);if(c>h){var a=h;h=c,c=a}return c>0&&i>c?(r.root=c,r.found=!0,r):h>0&&i>h?(r.root=h,r.found=!0,r):r},i=function(){function i(){this.radius=new t.Vector3(1,1,1),this.retry=0,this.basePointWorld=t.Vector3.Zero(),this.velocityWorld=t.Vector3.Zero(),this.normalizedVelocity=t.Vector3.Zero(),this._collisionPoint=t.Vector3.Zero(),this._planeIntersectionPoint=t.Vector3.Zero(),this._tempVector=t.Vector3.Zero(),this._tempVector2=t.Vector3.Zero(),this._tempVector3=t.Vector3.Zero(),this._tempVector4=t.Vector3.Zero(),this._edge=t.Vector3.Zero(),this._baseToVertex=t.Vector3.Zero(),this._destinationPoint=t.Vector3.Zero(),this._slidePlaneNormal=t.Vector3.Zero(),this._displacementVector=t.Vector3.Zero()}return i.prototype._initialize=function(e,o,i){this.velocity=o,t.Vector3.NormalizeToRef(o,this.normalizedVelocity),this.basePoint=e,e.multiplyToRef(this.radius,this.basePointWorld),o.multiplyToRef(this.radius,this.velocityWorld),this.velocityWorldLength=this.velocityWorld.length(),this.epsilon=i,this.collisionFound=!1},i.prototype._checkPointInTriangle=function(e,o,i,s,r){o.subtractToRef(e,this._tempVector),i.subtractToRef(e,this._tempVector2),t.Vector3.CrossToRef(this._tempVector,this._tempVector2,this._tempVector4);var n=t.Vector3.Dot(this._tempVector4,r);return 0>n?!1:(s.subtractToRef(e,this._tempVector3),t.Vector3.CrossToRef(this._tempVector2,this._tempVector3,this._tempVector4),n=t.Vector3.Dot(this._tempVector4,r),0>n?!1:(t.Vector3.CrossToRef(this._tempVector3,this._tempVector,this._tempVector4),n=t.Vector3.Dot(this._tempVector4,r),n>=0))},i.prototype._canDoCollision=function(o,i,s,r){var n=t.Vector3.Distance(this.basePointWorld,o),c=Math.max(this.radius.x,this.radius.y,this.radius.z);return n>this.velocityWorldLength+c+i?!1:!!e(s,r,this.basePointWorld,this.velocityWorldLength+c)},i.prototype._testTriangle=function(e,i,s,r,n,c){var h,a=!1;i||(i=[]),i[e]||(i[e]=new t.Plane(0,0,0,0),i[e].copyFromPoints(s,r,n));var l=i[e];if(c||l.isFrontFacingTo(this.normalizedVelocity,0)){var _=l.signedDistanceTo(this.basePoint),d=t.Vector3.Dot(l.normal,this.velocity);if(0==d){if(Math.abs(_)>=1)return;a=!0,h=0}else{h=(-1-_)/d;var V=(1-_)/d;if(h>V){var u=V;V=h,h=u}if(h>1||0>V)return;0>h&&(h=0),h>1&&(h=1)}this._collisionPoint.copyFromFloats(0,0,0);var P=!1,p=1;if(a||(this.basePoint.subtractToRef(l.normal,this._planeIntersectionPoint),this.velocity.scaleToRef(h,this._tempVector),this._planeIntersectionPoint.addInPlace(this._tempVector),this._checkPointInTriangle(this._planeIntersectionPoint,s,r,n,l.normal)&&(P=!0,p=h,this._collisionPoint.copyFrom(this._planeIntersectionPoint))),!P){var m=this.velocity.lengthSquared(),f=m;this.basePoint.subtractToRef(s,this._tempVector);var T=2*t.Vector3.Dot(this.velocity,this._tempVector),b=this._tempVector.lengthSquared()-1,y=o(f,T,b,p);y.found&&(p=y.root,P=!0,this._collisionPoint.copyFrom(s)),this.basePoint.subtractToRef(r,this._tempVector),T=2*t.Vector3.Dot(this.velocity,this._tempVector),b=this._tempVector.lengthSquared()-1,y=o(f,T,b,p),y.found&&(p=y.root,P=!0,this._collisionPoint.copyFrom(r)),this.basePoint.subtractToRef(n,this._tempVector),T=2*t.Vector3.Dot(this.velocity,this._tempVector),b=this._tempVector.lengthSquared()-1,y=o(f,T,b,p),y.found&&(p=y.root,P=!0,this._collisionPoint.copyFrom(n)),r.subtractToRef(s,this._edge),s.subtractToRef(this.basePoint,this._baseToVertex);var g=this._edge.lengthSquared(),v=t.Vector3.Dot(this._edge,this.velocity),R=t.Vector3.Dot(this._edge,this._baseToVertex);if(f=g*-m+v*v,T=g*(2*t.Vector3.Dot(this.velocity,this._baseToVertex))-2*v*R,b=g*(1-this._baseToVertex.lengthSquared())+R*R,y=o(f,T,b,p),y.found){var D=(v*y.root-R)/g;D>=0&&1>=D&&(p=y.root,P=!0,this._edge.scaleInPlace(D),s.addToRef(this._edge,this._collisionPoint))}n.subtractToRef(r,this._edge),r.subtractToRef(this.basePoint,this._baseToVertex),g=this._edge.lengthSquared(),v=t.Vector3.Dot(this._edge,this.velocity),R=t.Vector3.Dot(this._edge,this._baseToVertex),f=g*-m+v*v,T=g*(2*t.Vector3.Dot(this.velocity,this._baseToVertex))-2*v*R,b=g*(1-this._baseToVertex.lengthSquared())+R*R,y=o(f,T,b,p),y.found&&(D=(v*y.root-R)/g,D>=0&&1>=D&&(p=y.root,P=!0,this._edge.scaleInPlace(D),r.addToRef(this._edge,this._collisionPoint))),s.subtractToRef(n,this._edge),n.subtractToRef(this.basePoint,this._baseToVertex),g=this._edge.lengthSquared(),v=t.Vector3.Dot(this._edge,this.velocity),R=t.Vector3.Dot(this._edge,this._baseToVertex),f=g*-m+v*v,T=g*(2*t.Vector3.Dot(this.velocity,this._baseToVertex))-2*v*R,b=g*(1-this._baseToVertex.lengthSquared())+R*R,y=o(f,T,b,p),y.found&&(D=(v*y.root-R)/g,D>=0&&1>=D&&(p=y.root,P=!0,this._edge.scaleInPlace(D),n.addToRef(this._edge,this._collisionPoint)))}if(P){var x=p*this.velocity.length();(!this.collisionFound||x<this.nearestDistance)&&(this.intersectionPoint?this.intersectionPoint.copyFrom(this._collisionPoint):this.intersectionPoint=this._collisionPoint.clone(),this.nearestDistance=x,this.collisionFound=!0)}}},i.prototype._collide=function(t,e,o,i,s,r,n){for(var c=i;s>c;c+=3){var h=e[o[c]-r],a=e[o[c+1]-r],l=e[o[c+2]-r];this._testTriangle(c,t,l,a,h,n)}},i.prototype._getResponse=function(e,o){e.addToRef(o,this._destinationPoint),o.scaleInPlace(this.nearestDistance/o.length()),this.basePoint.addToRef(o,e),e.subtractToRef(this.intersectionPoint,this._slidePlaneNormal),this._slidePlaneNormal.normalize(),this._slidePlaneNormal.scaleToRef(this.epsilon,this._displacementVector),e.addInPlace(this._displacementVector),this.intersectionPoint.addInPlace(this._displacementVector),this._slidePlaneNormal.scaleInPlace(t.Plane.SignedDistanceToPlaneFromPositionAndNormal(this.intersectionPoint,this._slidePlaneNormal,this._destinationPoint)),this._destinationPoint.subtractInPlace(this._slidePlaneNormal),this._destinationPoint.subtractToRef(this.intersectionPoint,o)},i}();t.Collider=i}(BABYLON||(BABYLON={}));var BABYLON;!function(o){o.WorkerIncluded=!0;var e=function(){function o(){this._meshes={},this._geometries={}}return o.prototype.getMeshes=function(){return this._meshes},o.prototype.getGeometries=function(){return this._geometries},o.prototype.getMesh=function(o){return this._meshes[o]},o.prototype.addMesh=function(o){this._meshes[o.uniqueId]=o},o.prototype.removeMesh=function(o){delete this._meshes[o]},o.prototype.getGeometry=function(o){return this._geometries[o]},o.prototype.addGeometry=function(o){this._geometries[o.id]=o},o.prototype.removeGeometry=function(o){delete this._geometries[o]},o}();o.CollisionCache=e;var i=function(){function e(e,i,r){this.collider=e,this._collisionCache=i,this.finalPosition=r,this.collisionsScalingMatrix=o.Matrix.Zero(),this.collisionTranformationMatrix=o.Matrix.Zero()}return e.prototype.collideWithWorld=function(o,e,i,r){var t=.01;if(this.collider.retry>=i)return void this.finalPosition.copyFrom(o);this.collider._initialize(o,e,t);for(var s,l=this._collisionCache.getMeshes(),n=Object.keys(l),a=n.length,c=0;a>c;++c)if(s=n[c],parseInt(s)!=r){var d=l[s];d.checkCollisions&&this.checkCollision(d)}return this.collider.collisionFound?(0===e.x&&0===e.y&&0===e.z||this.collider._getResponse(o,e),e.length()<=t?void this.finalPosition.copyFrom(o):(this.collider.retry++,void this.collideWithWorld(o,e,i,r))):void o.addToRef(e,this.finalPosition)},e.prototype.checkCollision=function(e){if(this.collider._canDoCollision(o.Vector3.FromArray(e.sphereCenter),e.sphereRadius,o.Vector3.FromArray(e.boxMinimum),o.Vector3.FromArray(e.boxMaximum))){o.Matrix.ScalingToRef(1/this.collider.radius.x,1/this.collider.radius.y,1/this.collider.radius.z,this.collisionsScalingMatrix);var i=o.Matrix.FromArray(e.worldMatrixFromCache);i.multiplyToRef(this.collisionsScalingMatrix,this.collisionTranformationMatrix),this.processCollisionsForSubMeshes(this.collisionTranformationMatrix,e)}},e.prototype.processCollisionsForSubMeshes=function(o,e){var i=e.subMeshes,r=i.length;if(!e.geometryId)return void console.log("no mesh geometry id");var t=this._collisionCache.getGeometry(e.geometryId);if(!t)return void console.log("couldn\'t find geometry",e.geometryId);for(var s=0;r>s;s++){var l=i[s];r>1&&!this.checkSubmeshCollision(l)||(this.collideForSubMesh(l,o,t),this.collider.collisionFound&&(this.collider.collidedMesh=e.uniqueId))}},e.prototype.collideForSubMesh=function(e,i,r){if(!r.positionsArray){r.positionsArray=[];for(var t=0,s=r.positions.length;s>t;t+=3){var l=o.Vector3.FromArray([r.positions[t],r.positions[t+1],r.positions[t+2]]);r.positionsArray.push(l)}}if(!e._lastColliderWorldVertices||!e._lastColliderTransformMatrix.equals(i)){e._lastColliderTransformMatrix=i.clone(),e._lastColliderWorldVertices=[],e._trianglePlanes=[];for(var n=e.verticesStart,a=e.verticesStart+e.verticesCount,t=n;a>t;t++)e._lastColliderWorldVertices.push(o.Vector3.TransformCoordinates(r.positionsArray[t],i))}this.collider._collide(e._trianglePlanes,e._lastColliderWorldVertices,r.indices,e.indexStart,e.indexStart+e.indexCount,e.verticesStart,e.hasMaterial)},e.prototype.checkSubmeshCollision=function(e){return this.collider._canDoCollision(o.Vector3.FromArray(e.sphereCenter),e.sphereRadius,o.Vector3.FromArray(e.boxMinimum),o.Vector3.FromArray(e.boxMaximum))},e}();o.CollideWorker=i;var r=function(){function r(){}return r.prototype.onInit=function(i){this._collisionCache=new e;var r={error:o.WorkerReplyType.SUCCESS,taskType:o.WorkerTaskType.INIT};postMessage(r,void 0)},r.prototype.onUpdate=function(e){var i=this,r={error:o.WorkerReplyType.SUCCESS,taskType:o.WorkerTaskType.UPDATE};try{for(var t in e.updatedGeometries)e.updatedGeometries.hasOwnProperty(t)&&this._collisionCache.addGeometry(e.updatedGeometries[t]);for(var s in e.updatedMeshes)e.updatedMeshes.hasOwnProperty(s)&&this._collisionCache.addMesh(e.updatedMeshes[s]);e.removedGeometries.forEach(function(o){i._collisionCache.removeGeometry(o)}),e.removedMeshes.forEach(function(o){i._collisionCache.removeMesh(o)})}catch(l){r.error=o.WorkerReplyType.UNKNOWN_ERROR}postMessage(r,void 0)},r.prototype.onCollision=function(e){var r=o.Vector3.Zero(),t=new o.Collider;t.radius=o.Vector3.FromArray(e.collider.radius);var s=new i(t,this._collisionCache,r);s.collideWithWorld(o.Vector3.FromArray(e.collider.position),o.Vector3.FromArray(e.collider.velocity),e.maximumRetry,e.excludedMeshUniqueId);var l={collidedMeshUniqueId:t.collidedMesh,collisionId:e.collisionId,newPosition:r.asArray()},n={error:o.WorkerReplyType.SUCCESS,taskType:o.WorkerTaskType.COLLIDE,payload:l};postMessage(n,void 0)},r}();o.CollisionDetectorTransferable=r;try{if(self&&self instanceof WorkerGlobalScope){window={},o.Collider||(importScripts("./babylon.collisionCoordinator.js"),importScripts("./babylon.collider.js"),importScripts("../Math/babylon.math.js"));var t=new r,s=function(e){var i=e.data;switch(i.taskType){case o.WorkerTaskType.INIT:t.onInit(i.payload);break;case o.WorkerTaskType.COLLIDE:t.onCollision(i.payload);break;case o.WorkerTaskType.UPDATE:t.onUpdate(i.payload)}};self.onmessage=s}}catch(l){console.log("single worker init")}}(BABYLON||(BABYLON={}));var BABYLON;!function(e){e.CollisionWorker="",function(e){e[e.INIT=0]="INIT",e[e.UPDATE=1]="UPDATE",e[e.COLLIDE=2]="COLLIDE"}(e.WorkerTaskType||(e.WorkerTaskType={}));var o=e.WorkerTaskType;!function(e){e[e.SUCCESS=0]="SUCCESS",e[e.UNKNOWN_ERROR=1]="UNKNOWN_ERROR"}(e.WorkerReplyType||(e.WorkerReplyType={}));var i=e.WorkerReplyType,t=function(){function t(){var r=this;this._scaledPosition=e.Vector3.Zero(),this._scaledVelocity=e.Vector3.Zero(),this.onMeshUpdated=function(e){r._addUpdateMeshesList[e.uniqueId]=t.SerializeMesh(e)},this.onGeometryUpdated=function(e){r._addUpdateGeometriesList[e.id]=t.SerializeGeometry(e)},this._afterRender=function(){if(r._init&&!(0==r._toRemoveGeometryArray.length&&0==r._toRemoveMeshesArray.length&&0==Object.keys(r._addUpdateGeometriesList).length&&0==Object.keys(r._addUpdateMeshesList).length||r._runningUpdated>4)){++r._runningUpdated;var e={updatedMeshes:r._addUpdateMeshesList,updatedGeometries:r._addUpdateGeometriesList,removedGeometries:r._toRemoveGeometryArray,removedMeshes:r._toRemoveMeshesArray},i={payload:e,taskType:o.UPDATE},t=[];for(var s in e.updatedGeometries)e.updatedGeometries.hasOwnProperty(s)&&(t.push(i.payload.updatedGeometries[s].indices.buffer),t.push(i.payload.updatedGeometries[s].normals.buffer),t.push(i.payload.updatedGeometries[s].positions.buffer));r._worker.postMessage(i,t),r._addUpdateMeshesList={},r._addUpdateGeometriesList={},r._toRemoveGeometryArray=[],r._toRemoveMeshesArray=[]}},this._onMessageFromWorker=function(t){var s=t.data;if(s.error!=i.SUCCESS)return void e.Tools.Warn("error returned from worker!");switch(s.taskType){case o.INIT:r._init=!0,r._scene.meshes.forEach(function(e){r.onMeshAdded(e)}),r._scene.getGeometries().forEach(function(e){r.onGeometryAdded(e)});break;case o.UPDATE:r._runningUpdated--;break;case o.COLLIDE:r._runningCollisionTask=!1;var n=s.payload;if(!r._collisionsCallbackArray[n.collisionId])return;r._collisionsCallbackArray[n.collisionId](n.collisionId,e.Vector3.FromArray(n.newPosition),r._scene.getMeshByUniqueID(n.collidedMeshUniqueId)),r._collisionsCallbackArray[n.collisionId]=void 0}},this._collisionsCallbackArray=[],this._init=!1,this._runningUpdated=0,this._runningCollisionTask=!1,this._addUpdateMeshesList={},this._addUpdateGeometriesList={},this._toRemoveGeometryArray=[],this._toRemoveMeshesArray=[]}return t.prototype.getNewPosition=function(e,i,t,r,s,n,a){if(this._init&&!this._collisionsCallbackArray[a]&&!this._collisionsCallbackArray[a+1e5]){e.divideToRef(t.radius,this._scaledPosition),i.divideToRef(t.radius,this._scaledVelocity),this._collisionsCallbackArray[a]=n;var d={collider:{position:this._scaledPosition.asArray(),velocity:this._scaledVelocity.asArray(),radius:t.radius.asArray()},collisionId:a,excludedMeshUniqueId:s?s.uniqueId:null,maximumRetry:r},l={payload:d,taskType:o.COLLIDE};this._worker.postMessage(l)}},t.prototype.init=function(i){this._scene=i,this._scene.registerAfterRender(this._afterRender);var t=e.WorkerIncluded?e.Engine.CodeRepository+"Collisions/babylon.collisionWorker.js":URL.createObjectURL(new Blob([e.CollisionWorker],{type:"application/javascript"}));this._worker=new Worker(t),this._worker.onmessage=this._onMessageFromWorker;var r={payload:{},taskType:o.INIT};this._worker.postMessage(r)},t.prototype.destroy=function(){this._scene.unregisterAfterRender(this._afterRender),this._worker.terminate()},t.prototype.onMeshAdded=function(e){e.registerAfterWorldMatrixUpdate(this.onMeshUpdated),this.onMeshUpdated(e)},t.prototype.onMeshRemoved=function(e){this._toRemoveMeshesArray.push(e.uniqueId)},t.prototype.onGeometryAdded=function(e){e.onGeometryUpdated=this.onGeometryUpdated,this.onGeometryUpdated(e)},t.prototype.onGeometryDeleted=function(e){this._toRemoveGeometryArray.push(e.id)},t.SerializeMesh=function(o){var i=[];o.subMeshes&&(i=o.subMeshes.map(function(e,o){return{position:o,verticesStart:e.verticesStart,verticesCount:e.verticesCount,indexStart:e.indexStart,indexCount:e.indexCount,hasMaterial:!!e.getMaterial(),sphereCenter:e.getBoundingInfo().boundingSphere.centerWorld.asArray(),sphereRadius:e.getBoundingInfo().boundingSphere.radiusWorld,boxMinimum:e.getBoundingInfo().boundingBox.minimumWorld.asArray(),boxMaximum:e.getBoundingInfo().boundingBox.maximumWorld.asArray()}}));var t=null;return o instanceof e.Mesh?t=o.geometry?o.geometry.id:null:o instanceof e.InstancedMesh&&(t=o.sourceMesh&&o.sourceMesh.geometry?o.sourceMesh.geometry.id:null),{uniqueId:o.uniqueId,id:o.id,name:o.name,geometryId:t,sphereCenter:o.getBoundingInfo().boundingSphere.centerWorld.asArray(),sphereRadius:o.getBoundingInfo().boundingSphere.radiusWorld,boxMinimum:o.getBoundingInfo().boundingBox.minimumWorld.asArray(),boxMaximum:o.getBoundingInfo().boundingBox.maximumWorld.asArray(),worldMatrixFromCache:o.worldMatrixFromCache.asArray(),subMeshes:i,checkCollisions:o.checkCollisions}},t.SerializeGeometry=function(o){return{id:o.id,positions:new Float32Array(o.getVerticesData(e.VertexBuffer.PositionKind)||[]),normals:new Float32Array(o.getVerticesData(e.VertexBuffer.NormalKind)||[]),indices:new Int32Array(o.getIndices()||[])}},t}();e.CollisionCoordinatorWorker=t;var r=function(){function o(){this._scaledPosition=e.Vector3.Zero(),this._scaledVelocity=e.Vector3.Zero(),this._finalPosition=e.Vector3.Zero()}return o.prototype.getNewPosition=function(e,o,i,t,r,s,n){e.divideToRef(i.radius,this._scaledPosition),o.divideToRef(i.radius,this._scaledVelocity),i.collidedMesh=null,i.retry=0,i.initialVelocity=this._scaledVelocity,i.initialPosition=this._scaledPosition,this._collideWithWorld(this._scaledPosition,this._scaledVelocity,i,t,this._finalPosition,r),this._finalPosition.multiplyInPlace(i.radius),s(n,this._finalPosition,i.collidedMesh)},o.prototype.init=function(e){this._scene=e},o.prototype.destroy=function(){},o.prototype.onMeshAdded=function(e){},o.prototype.onMeshUpdated=function(e){},o.prototype.onMeshRemoved=function(e){},o.prototype.onGeometryAdded=function(e){},o.prototype.onGeometryUpdated=function(e){},o.prototype.onGeometryDeleted=function(e){},o.prototype._collideWithWorld=function(o,i,t,r,s,n){void 0===n&&(n=null);var a=10*e.Engine.CollisionsEpsilon;if(t.retry>=r)return void s.copyFrom(o);t._initialize(o,i,a);for(var d=0;d<this._scene.meshes.length;d++){var l=this._scene.meshes[d];l.isEnabled()&&l.checkCollisions&&l.subMeshes&&l!==n&&l._checkCollision(t)}return t.collisionFound?(0===i.x&&0===i.y&&0===i.z||t._getResponse(o,i),i.length()<=a?void s.copyFrom(o):(t.retry++,void this._collideWithWorld(o,i,t,r,s,n))):void o.addToRef(i,s)},o}();e.CollisionCoordinatorLegacy=r}(BABYLON||(BABYLON={}));var BABYLON;!function(t){t.ToGammaSpace=1/2.2,t.ToLinearSpace=2.2,t.Epsilon=.001;var i=function(){function t(){}return t.WithinEpsilon=function(t,i,n){void 0===n&&(n=1.401298e-45);var r=t-i;return r>=-n&&n>=r},t.ToHex=function(t){var i=t.toString(16);return 15>=t?("0"+i).toUpperCase():i.toUpperCase()},t.Sign=function(t){return t=+t,0===t||isNaN(t)?t:t>0?1:-1},t.Clamp=function(t,i,n){return void 0===i&&(i=0),void 0===n&&(n=1),Math.min(n,Math.max(i,t))},t}();t.MathTools=i;var n=function(){function n(t,i,n){void 0===t&&(t=0),void 0===i&&(i=0),void 0===n&&(n=0),this.r=t,this.g=i,this.b=n}return n.prototype.toString=function(){return"{R: "+this.r+" G:"+this.g+" B:"+this.b+"}"},n.prototype.getClassName=function(){return"Color3"},n.prototype.getHashCode=function(){var t=this.r||0;return t=397*t^(this.g||0),t=397*t^(this.b||0)},n.prototype.toArray=function(t,i){return void 0===i&&(i=0),t[i]=this.r,t[i+1]=this.g,t[i+2]=this.b,this},n.prototype.toColor4=function(t){return void 0===t&&(t=1),new r(this.r,this.g,this.b,t)},n.prototype.asArray=function(){var t=[];return this.toArray(t,0),t},n.prototype.toLuminance=function(){return.3*this.r+.59*this.g+.11*this.b},n.prototype.multiply=function(t){return new n(this.r*t.r,this.g*t.g,this.b*t.b)},n.prototype.multiplyToRef=function(t,i){return i.r=this.r*t.r,i.g=this.g*t.g,i.b=this.b*t.b,this},n.prototype.equals=function(t){return t&&this.r===t.r&&this.g===t.g&&this.b===t.b},n.prototype.equalsFloats=function(t,i,n){return this.r===t&&this.g===i&&this.b===n},n.prototype.scale=function(t){return new n(this.r*t,this.g*t,this.b*t)},n.prototype.scaleToRef=function(t,i){return i.r=this.r*t,i.g=this.g*t,i.b=this.b*t,this},n.prototype.add=function(t){return new n(this.r+t.r,this.g+t.g,this.b+t.b)},n.prototype.addToRef=function(t,i){return i.r=this.r+t.r,i.g=this.g+t.g,i.b=this.b+t.b,this},n.prototype.subtract=function(t){return new n(this.r-t.r,this.g-t.g,this.b-t.b)},n.prototype.subtractToRef=function(t,i){return i.r=this.r-t.r,i.g=this.g-t.g,i.b=this.b-t.b,this},n.prototype.clone=function(){return new n(this.r,this.g,this.b)},n.prototype.copyFrom=function(t){return this.r=t.r,this.g=t.g,this.b=t.b,this},n.prototype.copyFromFloats=function(t,i,n){return this.r=t,this.g=i,this.b=n,this},n.prototype.toHexString=function(){var t=255*this.r|0,n=255*this.g|0,r=255*this.b|0;return"#"+i.ToHex(t)+i.ToHex(n)+i.ToHex(r)},n.prototype.toLinearSpace=function(){var t=new n;return this.toLinearSpaceToRef(t),t},n.prototype.toLinearSpaceToRef=function(i){return i.r=Math.pow(this.r,t.ToLinearSpace),i.g=Math.pow(this.g,t.ToLinearSpace),i.b=Math.pow(this.b,t.ToLinearSpace),this},n.prototype.toGammaSpace=function(){var t=new n;return this.toGammaSpaceToRef(t),t},n.prototype.toGammaSpaceToRef=function(i){return i.r=Math.pow(this.r,t.ToGammaSpace),i.g=Math.pow(this.g,t.ToGammaSpace),i.b=Math.pow(this.b,t.ToGammaSpace),this},n.FromHexString=function(t){if("#"!==t.substring(0,1)||7!==t.length)return new n(0,0,0);var i=parseInt(t.substring(1,3),16),r=parseInt(t.substring(3,5),16),o=parseInt(t.substring(5,7),16);return n.FromInts(i,r,o)},n.FromArray=function(t,i){return void 0===i&&(i=0),new n(t[i],t[i+1],t[i+2])},n.FromInts=function(t,i,r){return new n(t/255,i/255,r/255)},n.Lerp=function(t,i,r){var o=t.r+(i.r-t.r)*r,s=t.g+(i.g-t.g)*r,e=t.b+(i.b-t.b)*r;return new n(o,s,e)},n.Red=function(){return new n(1,0,0)},n.Green=function(){return new n(0,1,0)},n.Blue=function(){return new n(0,0,1)},n.Black=function(){return new n(0,0,0)},n.White=function(){return new n(1,1,1)},n.Purple=function(){return new n(.5,0,.5)},n.Magenta=function(){return new n(1,0,1)},n.Yellow=function(){return new n(1,1,0)},n.Gray=function(){return new n(.5,.5,.5)},n}();t.Color3=n;var r=function(){function t(t,i,n,r){this.r=t,this.g=i,this.b=n,this.a=r}return t.prototype.addInPlace=function(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this.a+=t.a,this},t.prototype.asArray=function(){var t=[];return this.toArray(t,0),t},t.prototype.toArray=function(t,i){return void 0===i&&(i=0),t[i]=this.r,t[i+1]=this.g,t[i+2]=this.b,t[i+3]=this.a,this},t.prototype.add=function(i){return new t(this.r+i.r,this.g+i.g,this.b+i.b,this.a+i.a)},t.prototype.subtract=function(i){return new t(this.r-i.r,this.g-i.g,this.b-i.b,this.a-i.a)},t.prototype.subtractToRef=function(t,i){return i.r=this.r-t.r,i.g=this.g-t.g,i.b=this.b-t.b,i.a=this.a-t.a,this},t.prototype.scale=function(i){return new t(this.r*i,this.g*i,this.b*i,this.a*i)},t.prototype.scaleToRef=function(t,i){return i.r=this.r*t,i.g=this.g*t,i.b=this.b*t,i.a=this.a*t,this},t.prototype.multiply=function(i){return new t(this.r*i.r,this.g*i.g,this.b*i.b,this.a*i.a)},t.prototype.multiplyToRef=function(t,i){return i.r=this.r*t.r,i.g=this.g*t.g,i.b=this.b*t.b,i.a=this.a*t.a,i},t.prototype.toString=function(){return"{R: "+this.r+" G:"+this.g+" B:"+this.b+" A:"+this.a+"}"},t.prototype.getClassName=function(){return"Color4"},t.prototype.getHashCode=function(){var t=this.r||0;return t=397*t^(this.g||0),t=397*t^(this.b||0),t=397*t^(this.a||0)},t.prototype.clone=function(){return new t(this.r,this.g,this.b,this.a)},t.prototype.copyFrom=function(t){return this.r=t.r,this.g=t.g,this.b=t.b,this.a=t.a,this},t.prototype.toHexString=function(){var t=255*this.r|0,n=255*this.g|0,r=255*this.b|0,o=255*this.a|0;return"#"+i.ToHex(t)+i.ToHex(n)+i.ToHex(r)+i.ToHex(o)},t.FromHexString=function(i){if("#"!==i.substring(0,1)||9!==i.length)return new t(0,0,0,0);var n=parseInt(i.substring(1,3),16),r=parseInt(i.substring(3,5),16),o=parseInt(i.substring(5,7),16),s=parseInt(i.substring(7,9),16);return t.FromInts(n,r,o,s)},t.Lerp=function(i,n,r){var o=new t(0,0,0,0);return t.LerpToRef(i,n,r,o),o},t.LerpToRef=function(t,i,n,r){r.r=t.r+(i.r-t.r)*n,r.g=t.g+(i.g-t.g)*n,r.b=t.b+(i.b-t.b)*n,r.a=t.a+(i.a-t.a)*n},t.FromArray=function(i,n){return void 0===n&&(n=0),new t(i[n],i[n+1],i[n+2],i[n+3])},t.FromInts=function(i,n,r,o){return new t(i/255,n/255,r/255,o/255)},t.CheckColors4=function(t,i){if(t.length===3*i){for(var n=[],r=0;r<t.length;r+=3){var o=r/3*4;n[o]=t[r],n[o+1]=t[r+1],n[o+2]=t[r+2],n[o+3]=1}return n}return t},t}();t.Color4=r;var o=function(){function n(t,i){this.x=t,this.y=i}return n.prototype.toString=function(){return"{X: "+this.x+" Y:"+this.y+"}"},n.prototype.getClassName=function(){return"Vector2"},n.prototype.getHashCode=function(){var t=this.x||0;return t=397*t^(this.y||0)},n.prototype.toArray=function(t,i){return void 0===i&&(i=0),t[i]=this.x,t[i+1]=this.y,this},n.prototype.asArray=function(){var t=[];return this.toArray(t,0),t},n.prototype.copyFrom=function(t){return this.x=t.x,this.y=t.y,this},n.prototype.copyFromFloats=function(t,i){return this.x=t,this.y=i,this},n.prototype.add=function(t){return new n(this.x+t.x,this.y+t.y)},n.prototype.addToRef=function(t,i){return i.x=this.x+t.x,i.y=this.y+t.y,this},n.prototype.addVector3=function(t){return new n(this.x+t.x,this.y+t.y)},n.prototype.subtract=function(t){return new n(this.x-t.x,this.y-t.y)},n.prototype.subtractToRef=function(t,i){return i.x=this.x-t.x,i.y=this.y-t.y,this},n.prototype.subtractInPlace=function(t){return this.x-=t.x,this.y-=t.y,this},n.prototype.multiplyInPlace=function(t){return this.x*=t.x,this.y*=t.y,this},n.prototype.multiply=function(t){return new n(this.x*t.x,this.y*t.y)},n.prototype.multiplyToRef=function(t,i){return i.x=this.x*t.x,i.y=this.y*t.y,this},n.prototype.multiplyByFloats=function(t,i){return new n(this.x*t,this.y*i)},n.prototype.divide=function(t){return new n(this.x/t.x,this.y/t.y)},n.prototype.divideToRef=function(t,i){return i.x=this.x/t.x,i.y=this.y/t.y,this},n.prototype.negate=function(){return new n(-this.x,-this.y)},n.prototype.scaleInPlace=function(t){return this.x*=t,this.y*=t,this},n.prototype.scale=function(t){return new n(this.x*t,this.y*t)},n.prototype.equals=function(t){return t&&this.x===t.x&&this.y===t.y},n.prototype.equalsWithEpsilon=function(n,r){return void 0===r&&(r=t.Epsilon),n&&i.WithinEpsilon(this.x,n.x,r)&&i.WithinEpsilon(this.y,n.y,r)},n.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y)},n.prototype.lengthSquared=function(){return this.x*this.x+this.y*this.y},n.prototype.normalize=function(){var t=this.length();if(0===t)return this;var i=1/t;return this.x*=i,this.y*=i,this},n.prototype.clone=function(){return new n(this.x,this.y)},n.Zero=function(){return new n(0,0)},n.FromArray=function(t,i){return void 0===i&&(i=0),new n(t[i],t[i+1])},n.FromArrayToRef=function(t,i,n){n.x=t[i],n.y=t[i+1]},n.CatmullRom=function(t,i,r,o,s){var e=s*s,h=s*e,a=.5*(2*i.x+(-t.x+r.x)*s+(2*t.x-5*i.x+4*r.x-o.x)*e+(-t.x+3*i.x-3*r.x+o.x)*h),u=.5*(2*i.y+(-t.y+r.y)*s+(2*t.y-5*i.y+4*r.y-o.y)*e+(-t.y+3*i.y-3*r.y+o.y)*h);return new n(a,u)},n.Clamp=function(t,i,r){var o=t.x;o=o>r.x?r.x:o,o=o<i.x?i.x:o;var s=t.y;return s=s>r.y?r.y:s,s=s<i.y?i.y:s,new n(o,s)},n.Hermite=function(t,i,r,o,s){var e=s*s,h=s*e,a=2*h-3*e+1,u=-2*h+3*e,m=h-2*e+s,y=h-e,c=t.x*a+r.x*u+i.x*m+o.x*y,p=t.y*a+r.y*u+i.y*m+o.y*y;return new n(c,p)},n.Lerp=function(t,i,r){var o=t.x+(i.x-t.x)*r,s=t.y+(i.y-t.y)*r;return new n(o,s)},n.Dot=function(t,i){return t.x*i.x+t.y*i.y},n.Normalize=function(t){var i=t.clone();return i.normalize(),i},n.Minimize=function(t,i){var r=t.x<i.x?t.x:i.x,o=t.y<i.y?t.y:i.y;return new n(r,o)},n.Maximize=function(t,i){var r=t.x>i.x?t.x:i.x,o=t.y>i.y?t.y:i.y;return new n(r,o)},n.Transform=function(t,i){var r=n.Zero();return n.TransformToRef(t,i,r),r},n.TransformToRef=function(t,i,n){var r=t.x*i.m[0]+t.y*i.m[4]+i.m[12],o=t.x*i.m[1]+t.y*i.m[5]+i.m[13];n.x=r,n.y=o},n.PointInTriangle=function(t,i,n,r){var o=.5*(-n.y*r.x+i.y*(-n.x+r.x)+i.x*(n.y-r.y)+n.x*r.y),s=0>o?-1:1,e=(i.y*r.x-i.x*r.y+(r.y-i.y)*t.x+(i.x-r.x)*t.y)*s,h=(i.x*n.y-i.y*n.x+(i.y-n.y)*t.x+(n.x-i.x)*t.y)*s;return e>0&&h>0&&2*o*s>e+h},n.Distance=function(t,i){return Math.sqrt(n.DistanceSquared(t,i))},n.DistanceSquared=function(t,i){var n=t.x-i.x,r=t.y-i.y;return n*n+r*r},n.DistanceOfPointFromSegment=function(t,i,r){var o=n.DistanceSquared(i,r);if(0===o)return n.Distance(t,i);var s=r.subtract(i),e=Math.max(0,Math.min(1,n.Dot(t.subtract(i),s)/o)),h=i.add(s.multiplyByFloats(e,e));return n.Distance(t,h)},n}();t.Vector2=o;var s=function(){function n(t,i,n){this.x=t,this.y=i,this.z=n}return n.prototype.toString=function(){return"{X: "+this.x+" Y:"+this.y+" Z:"+this.z+"}"},n.prototype.getClassName=function(){return"Vector3"},n.prototype.getHashCode=function(){var t=this.x||0;return t=397*t^(this.y||0),t=397*t^(this.z||0)},n.prototype.asArray=function(){var t=[];return this.toArray(t,0),t},n.prototype.toArray=function(t,i){return void 0===i&&(i=0),t[i]=this.x,t[i+1]=this.y,t[i+2]=this.z,this},n.prototype.toQuaternion=function(){var t=new a(0,0,0,1),i=Math.cos(.5*(this.x+this.z)),n=Math.sin(.5*(this.x+this.z)),r=Math.cos(.5*(this.z-this.x)),o=Math.sin(.5*(this.z-this.x)),s=Math.cos(.5*this.y),e=Math.sin(.5*this.y);return t.x=r*e,t.y=-o*e,t.z=n*s,t.w=i*s,t},n.prototype.addInPlace=function(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this},n.prototype.add=function(t){return new n(this.x+t.x,this.y+t.y,this.z+t.z)},n.prototype.addToRef=function(t,i){return i.x=this.x+t.x,i.y=this.y+t.y,i.z=this.z+t.z,this},n.prototype.subtractInPlace=function(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this},n.prototype.subtract=function(t){return new n(this.x-t.x,this.y-t.y,this.z-t.z)},n.prototype.subtractToRef=function(t,i){return i.x=this.x-t.x,i.y=this.y-t.y,i.z=this.z-t.z,this},n.prototype.subtractFromFloats=function(t,i,r){return new n(this.x-t,this.y-i,this.z-r)},n.prototype.subtractFromFloatsToRef=function(t,i,n,r){return r.x=this.x-t,r.y=this.y-i,r.z=this.z-n,this},n.prototype.negate=function(){return new n(-this.x,-this.y,-this.z)},n.prototype.scaleInPlace=function(t){return this.x*=t,this.y*=t,this.z*=t,this},n.prototype.scale=function(t){return new n(this.x*t,this.y*t,this.z*t)},n.prototype.scaleToRef=function(t,i){i.x=this.x*t,i.y=this.y*t,i.z=this.z*t},n.prototype.equals=function(t){return t&&this.x===t.x&&this.y===t.y&&this.z===t.z},n.prototype.equalsWithEpsilon=function(n,r){return void 0===r&&(r=t.Epsilon),n&&i.WithinEpsilon(this.x,n.x,r)&&i.WithinEpsilon(this.y,n.y,r)&&i.WithinEpsilon(this.z,n.z,r)},n.prototype.equalsToFloats=function(t,i,n){return this.x===t&&this.y===i&&this.z===n},n.prototype.multiplyInPlace=function(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this},n.prototype.multiply=function(t){return new n(this.x*t.x,this.y*t.y,this.z*t.z)},n.prototype.multiplyToRef=function(t,i){return i.x=this.x*t.x,i.y=this.y*t.y,i.z=this.z*t.z,this},n.prototype.multiplyByFloats=function(t,i,r){return new n(this.x*t,this.y*i,this.z*r)},n.prototype.divide=function(t){return new n(this.x/t.x,this.y/t.y,this.z/t.z)},n.prototype.divideToRef=function(t,i){return i.x=this.x/t.x,i.y=this.y/t.y,i.z=this.z/t.z,this},n.prototype.MinimizeInPlace=function(t){return t.x<this.x&&(this.x=t.x),t.y<this.y&&(this.y=t.y),t.z<this.z&&(this.z=t.z),this},n.prototype.MaximizeInPlace=function(t){return t.x>this.x&&(this.x=t.x),t.y>this.y&&(this.y=t.y),t.z>this.z&&(this.z=t.z),this},n.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},n.prototype.lengthSquared=function(){return this.x*this.x+this.y*this.y+this.z*this.z},n.prototype.normalize=function(){var t=this.length();if(0===t||1===t)return this;var i=1/t;return this.x*=i,this.y*=i,this.z*=i,this},n.prototype.clone=function(){return new n(this.x,this.y,this.z)},n.prototype.copyFrom=function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this},n.prototype.copyFromFloats=function(t,i,n){return this.x=t,this.y=i,this.z=n,this},n.GetClipFactor=function(t,i,r,o){var s=n.Dot(t,r)-o,e=n.Dot(i,r)-o,h=s/(s-e);return h},n.FromArray=function(t,i){return i||(i=0),new n(t[i],t[i+1],t[i+2])},n.FromFloatArray=function(t,i){return i||(i=0),new n(t[i],t[i+1],t[i+2])},n.FromArrayToRef=function(t,i,n){n.x=t[i],n.y=t[i+1],n.z=t[i+2]},n.FromFloatArrayToRef=function(t,i,n){n.x=t[i],n.y=t[i+1],n.z=t[i+2]},n.FromFloatsToRef=function(t,i,n,r){r.x=t,r.y=i,r.z=n},n.Zero=function(){return new n(0,0,0)},n.Up=function(){return new n(0,1,0)},n.TransformCoordinates=function(t,i){var r=n.Zero();return n.TransformCoordinatesToRef(t,i,r),r},n.TransformCoordinatesToRef=function(t,i,n){var r=t.x*i.m[0]+t.y*i.m[4]+t.z*i.m[8]+i.m[12],o=t.x*i.m[1]+t.y*i.m[5]+t.z*i.m[9]+i.m[13],s=t.x*i.m[2]+t.y*i.m[6]+t.z*i.m[10]+i.m[14],e=t.x*i.m[3]+t.y*i.m[7]+t.z*i.m[11]+i.m[15];n.x=r/e,n.y=o/e,n.z=s/e},n.TransformCoordinatesFromFloatsToRef=function(t,i,n,r,o){var s=t*r.m[0]+i*r.m[4]+n*r.m[8]+r.m[12],e=t*r.m[1]+i*r.m[5]+n*r.m[9]+r.m[13],h=t*r.m[2]+i*r.m[6]+n*r.m[10]+r.m[14],a=t*r.m[3]+i*r.m[7]+n*r.m[11]+r.m[15];o.x=s/a,o.y=e/a,o.z=h/a},n.TransformNormal=function(t,i){var r=n.Zero();return n.TransformNormalToRef(t,i,r),r},n.TransformNormalToRef=function(t,i,n){n.x=t.x*i.m[0]+t.y*i.m[4]+t.z*i.m[8],n.y=t.x*i.m[1]+t.y*i.m[5]+t.z*i.m[9],n.z=t.x*i.m[2]+t.y*i.m[6]+t.z*i.m[10]},n.TransformNormalFromFloatsToRef=function(t,i,n,r,o){o.x=t*r.m[0]+i*r.m[4]+n*r.m[8],o.y=t*r.m[1]+i*r.m[5]+n*r.m[9],o.z=t*r.m[2]+i*r.m[6]+n*r.m[10]},n.CatmullRom=function(t,i,r,o,s){var e=s*s,h=s*e,a=.5*(2*i.x+(-t.x+r.x)*s+(2*t.x-5*i.x+4*r.x-o.x)*e+(-t.x+3*i.x-3*r.x+o.x)*h),u=.5*(2*i.y+(-t.y+r.y)*s+(2*t.y-5*i.y+4*r.y-o.y)*e+(-t.y+3*i.y-3*r.y+o.y)*h),m=.5*(2*i.z+(-t.z+r.z)*s+(2*t.z-5*i.z+4*r.z-o.z)*e+(-t.z+3*i.z-3*r.z+o.z)*h);return new n(a,u,m)},n.Clamp=function(t,i,r){var o=t.x;o=o>r.x?r.x:o,o=o<i.x?i.x:o;var s=t.y;s=s>r.y?r.y:s,s=s<i.y?i.y:s;var e=t.z;return e=e>r.z?r.z:e,e=e<i.z?i.z:e,new n(o,s,e)},n.Hermite=function(t,i,r,o,s){var e=s*s,h=s*e,a=2*h-3*e+1,u=-2*h+3*e,m=h-2*e+s,y=h-e,c=t.x*a+r.x*u+i.x*m+o.x*y,p=t.y*a+r.y*u+i.y*m+o.y*y,f=t.z*a+r.z*u+i.z*m+o.z*y;return new n(c,p,f)},n.Lerp=function(t,i,r){var o=t.x+(i.x-t.x)*r,s=t.y+(i.y-t.y)*r,e=t.z+(i.z-t.z)*r;return new n(o,s,e)},n.Dot=function(t,i){return t.x*i.x+t.y*i.y+t.z*i.z},n.Cross=function(t,i){var r=n.Zero();return n.CrossToRef(t,i,r),r},n.CrossToRef=function(t,i,n){M.Vector3[0].x=t.y*i.z-t.z*i.y,M.Vector3[0].y=t.z*i.x-t.x*i.z,M.Vector3[0].z=t.x*i.y-t.y*i.x,n.copyFrom(M.Vector3[0])},n.Normalize=function(t){var i=n.Zero();return n.NormalizeToRef(t,i),i},n.NormalizeToRef=function(t,i){i.copyFrom(t),i.normalize()},n.Project=function(t,i,r,o){var s=o.width,e=o.height,h=o.x,a=o.y,m=u.FromValues(s/2,0,0,0,0,-e/2,0,0,0,0,1,0,h+s/2,e/2+a,0,1),y=i.multiply(r).multiply(m);return n.TransformCoordinates(t,y)},n.UnprojectFromTransform=function(t,r,o,s,e){var h=s.multiply(e);h.invert(),t.x=t.x/r*2-1,t.y=-(t.y/o*2-1);var a=n.TransformCoordinates(t,h),u=t.x*h.m[3]+t.y*h.m[7]+t.z*h.m[11]+h.m[15];return i.WithinEpsilon(u,1)&&(a=a.scale(1/u)),a},n.Unproject=function(t,r,o,s,e,h){var a=s.multiply(e).multiply(h);a.invert();var u=new n(t.x/r*2-1,-(t.y/o*2-1),t.z),m=n.TransformCoordinates(u,a),y=u.x*a.m[3]+u.y*a.m[7]+u.z*a.m[11]+a.m[15];return i.WithinEpsilon(y,1)&&(m=m.scale(1/y)),m},n.Minimize=function(t,i){var n=t.clone();return n.MinimizeInPlace(i),n},n.Maximize=function(t,i){var n=t.clone();return n.MaximizeInPlace(i),n},n.Distance=function(t,i){return Math.sqrt(n.DistanceSquared(t,i))},n.DistanceSquared=function(t,i){var n=t.x-i.x,r=t.y-i.y,o=t.z-i.z;return n*n+r*r+o*o},n.Center=function(t,i){var n=t.add(i);return n.scaleInPlace(.5),n},n.RotationFromAxis=function(t,i,r){var o=n.Zero();return n.RotationFromAxisToRef(t,i,r,o),o},n.RotationFromAxisToRef=function(r,o,s,e){var h=r.normalize(),a=s.normalize(),u=p.X,m=p.Y,y=0,c=0,f=0,l=0,x=0,z=0,w=0,v=-1,d=0,g=M.Vector3[0],T=0,R=M.Vector3[1];i.WithinEpsilon(a.z,0,t.Epsilon)?z=1:i.WithinEpsilon(a.x,0,t.Epsilon)?l=1:(w=a.z/a.x,l=-w*Math.sqrt(1/(1+w*w)),z=Math.sqrt(1/(1+w*w))),R.x=l,R.y=x,R.z=z,R.normalize(),n.CrossToRef(h,R,g),g.normalize(),n.Dot(a,g)<0&&(v=1),T=n.Dot(h,R),T=Math.min(1,Math.max(-1,T)),f=Math.acos(T)*v,n.Dot(R,u)<0&&(f=Math.PI+f,R=R.scaleInPlace(-1),d++);var _=M.Vector3[2],b=M.Vector3[3];l=0,x=0,z=0,v=-1,i.WithinEpsilon(a.z,0,t.Epsilon)?l=1:(w=R.z/R.x,l=-w*Math.sqrt(1/(1+w*w)),z=Math.sqrt(1/(1+w*w))),_.x=l,_.y=x,_.z=z,_.normalize(),n.CrossToRef(_,R,b),b.normalize(),n.CrossToRef(a,_,g),g.normalize(),n.Dot(R,g)<0&&(v=1),T=n.Dot(a,_),T=Math.min(1,Math.max(-1,T)),c=Math.acos(T)*v,n.Dot(b,m)<0&&(c=Math.PI+c,d++),v=-1,n.CrossToRef(u,R,g),g.normalize(),n.Dot(g,m)<0&&(v=1),T=n.Dot(R,u),T=Math.min(1,Math.max(-1,T)),y=-Math.acos(T)*v,0>T&&2>d&&(y=Math.PI+y),e.x=c,e.y=y,e.z=f},n}();t.Vector3=s;var e=function(){function n(t,i,n,r){this.x=t,this.y=i,this.z=n,this.w=r}return n.prototype.toString=function(){return"{X: "+this.x+" Y:"+this.y+" Z:"+this.z+"W:"+this.w+"}"},n.prototype.getClassName=function(){return"Vector4"},n.prototype.getHashCode=function(){var t=this.x||0;return t=397*t^(this.y||0),t=397*t^(this.z||0),t=397*t^(this.w||0)},n.prototype.asArray=function(){var t=[];return this.toArray(t,0),t},n.prototype.toArray=function(t,i){return void 0===i&&(i=0),t[i]=this.x,t[i+1]=this.y,t[i+2]=this.z,t[i+3]=this.w,this},n.prototype.addInPlace=function(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this},n.prototype.add=function(t){return new n(this.x+t.x,this.y+t.y,this.z+t.z,this.w+t.w)},n.prototype.addToRef=function(t,i){return i.x=this.x+t.x,i.y=this.y+t.y,i.z=this.z+t.z,i.w=this.w+t.w,this},n.prototype.subtractInPlace=function(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this},n.prototype.subtract=function(t){return new n(this.x-t.x,this.y-t.y,this.z-t.z,this.w-t.w)},n.prototype.subtractToRef=function(t,i){return i.x=this.x-t.x,i.y=this.y-t.y,i.z=this.z-t.z,i.w=this.w-t.w,this},n.prototype.subtractFromFloats=function(t,i,r,o){return new n(this.x-t,this.y-i,this.z-r,this.w-o)},n.prototype.subtractFromFloatsToRef=function(t,i,n,r,o){return o.x=this.x-t,o.y=this.y-i,o.z=this.z-n,o.w=this.w-r,this},n.prototype.negate=function(){return new n(-this.x,-this.y,-this.z,-this.w)},n.prototype.scaleInPlace=function(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this},n.prototype.scale=function(t){return new n(this.x*t,this.y*t,this.z*t,this.w*t)},n.prototype.scaleToRef=function(t,i){i.x=this.x*t,i.y=this.y*t,i.z=this.z*t,i.w=this.w*t},n.prototype.equals=function(t){return t&&this.x===t.x&&this.y===t.y&&this.z===t.z&&this.w===t.w},n.prototype.equalsWithEpsilon=function(n,r){return void 0===r&&(r=t.Epsilon),n&&i.WithinEpsilon(this.x,n.x,r)&&i.WithinEpsilon(this.y,n.y,r)&&i.WithinEpsilon(this.z,n.z,r)&&i.WithinEpsilon(this.w,n.w,r)},n.prototype.equalsToFloats=function(t,i,n,r){return this.x===t&&this.y===i&&this.z===n&&this.w===r},n.prototype.multiplyInPlace=function(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this},n.prototype.multiply=function(t){return new n(this.x*t.x,this.y*t.y,this.z*t.z,this.w*t.w)},n.prototype.multiplyToRef=function(t,i){return i.x=this.x*t.x,i.y=this.y*t.y,i.z=this.z*t.z,i.w=this.w*t.w,this},n.prototype.multiplyByFloats=function(t,i,r,o){return new n(this.x*t,this.y*i,this.z*r,this.w*o)},n.prototype.divide=function(t){return new n(this.x/t.x,this.y/t.y,this.z/t.z,this.w/t.w)},n.prototype.divideToRef=function(t,i){return i.x=this.x/t.x,i.y=this.y/t.y,i.z=this.z/t.z,i.w=this.w/t.w,this},n.prototype.MinimizeInPlace=function(t){return t.x<this.x&&(this.x=t.x),t.y<this.y&&(this.y=t.y),t.z<this.z&&(this.z=t.z),t.w<this.w&&(this.w=t.w),this},n.prototype.MaximizeInPlace=function(t){return t.x>this.x&&(this.x=t.x),t.y>this.y&&(this.y=t.y),t.z>this.z&&(this.z=t.z),t.w>this.w&&(this.w=t.w),this},n.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},n.prototype.lengthSquared=function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},n.prototype.normalize=function(){var t=this.length();if(0===t)return this;var i=1/t;return this.x*=i,this.y*=i,this.z*=i,this.w*=i,this},n.prototype.toVector3=function(){return new s(this.x,this.y,this.z)},n.prototype.clone=function(){return new n(this.x,this.y,this.z,this.w)},n.prototype.copyFrom=function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w,this},n.prototype.copyFromFloats=function(t,i,n,r){return this.x=t,this.y=i,this.z=n,this.w=r,this},n.FromArray=function(t,i){return i||(i=0),new n(t[i],t[i+1],t[i+2],t[i+3])},n.FromArrayToRef=function(t,i,n){n.x=t[i],n.y=t[i+1],n.z=t[i+2],n.w=t[i+3]},n.FromFloatArrayToRef=function(t,i,n){n.x=t[i],n.y=t[i+1],n.z=t[i+2],n.w=t[i+3]},n.FromFloatsToRef=function(t,i,n,r,o){o.x=t,o.y=i,o.z=n,o.w=r},n.Zero=function(){return new n(0,0,0,0)},n.Normalize=function(t){var i=n.Zero();return n.NormalizeToRef(t,i),i},n.NormalizeToRef=function(t,i){i.copyFrom(t),i.normalize()},n.Minimize=function(t,i){var n=t.clone();return n.MinimizeInPlace(i),n},n.Maximize=function(t,i){var n=t.clone();return n.MaximizeInPlace(i),n},n.Distance=function(t,i){return Math.sqrt(n.DistanceSquared(t,i))},n.DistanceSquared=function(t,i){var n=t.x-i.x,r=t.y-i.y,o=t.z-i.z,s=t.w-i.w;return n*n+r*r+o*o+s*s},n.Center=function(t,i){var n=t.add(i);return n.scaleInPlace(.5),n},n}();t.Vector4=e;var h=function(){function t(t,i){this.width=t,this.height=i}return t.prototype.toString=function(){return"{W: "+this.width+", H: "+this.height+"}"},t.prototype.getClassName=function(){return"Size"},t.prototype.getHashCode=function(){var t=this.width||0;return t=397*t^(this.height||0)},t.prototype.copyFrom=function(t){this.width=t.width,this.height=t.height},t.prototype.clone=function(){return new t(this.width,this.height)},t.prototype.equals=function(t){return t?this.width===t.width&&this.height===t.height:!1},Object.defineProperty(t.prototype,"surface",{get:function(){return this.width*this.height},enumerable:!0,configurable:!0}),t.Zero=function(){return new t(0,0)},t.prototype.add=function(i){var n=new t(this.width+i.width,this.height+i.height);return n},t.prototype.substract=function(i){var n=new t(this.width-i.width,this.height-i.height);return n},t.Lerp=function(i,n,r){var o=i.width+(n.width-i.width)*r,s=i.height+(n.height-i.height)*r;return new t(o,s)},t}();t.Size=h;var a=function(){function t(t,i,n,r){void 0===t&&(t=0),void 0===i&&(i=0),void 0===n&&(n=0),void 0===r&&(r=1),this.x=t,this.y=i,this.z=n,this.w=r}return t.prototype.toString=function(){return"{X: "+this.x+" Y:"+this.y+" Z:"+this.z+" W:"+this.w+"}"},t.prototype.getClassName=function(){return"Quaternion"},t.prototype.getHashCode=function(){var t=this.x||0;return t=397*t^(this.y||0),t=397*t^(this.z||0),t=397*t^(this.w||0)},t.prototype.asArray=function(){return[this.x,this.y,this.z,this.w]},t.prototype.equals=function(t){return t&&this.x===t.x&&this.y===t.y&&this.z===t.z&&this.w===t.w},t.prototype.clone=function(){return new t(this.x,this.y,this.z,this.w)},t.prototype.copyFrom=function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w,this},t.prototype.copyFromFloats=function(t,i,n,r){return this.x=t,this.y=i,this.z=n,this.w=r,this},t.prototype.add=function(i){return new t(this.x+i.x,this.y+i.y,this.z+i.z,this.w+i.w)},t.prototype.subtract=function(i){return new t(this.x-i.x,this.y-i.y,this.z-i.z,this.w-i.w)},t.prototype.scale=function(i){return new t(this.x*i,this.y*i,this.z*i,this.w*i)},t.prototype.multiply=function(i){var n=new t(0,0,0,1);return this.multiplyToRef(i,n),n},t.prototype.multiplyToRef=function(t,i){var n=this.x*t.w+this.y*t.z-this.z*t.y+this.w*t.x,r=-this.x*t.z+this.y*t.w+this.z*t.x+this.w*t.y,o=this.x*t.y-this.y*t.x+this.z*t.w+this.w*t.z,s=-this.x*t.x-this.y*t.y-this.z*t.z+this.w*t.w;return i.copyFromFloats(n,r,o,s),this},t.prototype.multiplyInPlace=function(t){return this.multiplyToRef(t,this),this},t.prototype.conjugateToRef=function(t){return t.copyFromFloats(-this.x,-this.y,-this.z,this.w),this},t.prototype.conjugateInPlace=function(){return this.x*=-1,this.y*=-1,this.z*=-1,this},t.prototype.conjugate=function(){var i=new t(-this.x,-this.y,-this.z,this.w);return i},t.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},t.prototype.normalize=function(){var t=1/this.length();return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this},t.prototype.toEulerAngles=function(t){void 0===t&&(t="YZX");var i=s.Zero();return this.toEulerAnglesToRef(i,t),i},t.prototype.toEulerAnglesToRef=function(t,i){void 0===i&&(i="YZX");var n,r,o,s=this.x,e=this.y,h=this.z,a=this.w;switch(i){case"YZX":var u=s*e+h*a;if(u>.499&&(n=2*Math.atan2(s,a),r=Math.PI/2,o=0),-.499>u&&(n=-2*Math.atan2(s,a),r=-Math.PI/2,o=0),isNaN(n)){var m=s*s,y=e*e,c=h*h;n=Math.atan2(2*e*a-2*s*h,1-2*y-2*c),r=Math.asin(2*u),o=Math.atan2(2*s*a-2*e*h,1-2*m-2*c)}break;default:throw new Error("Euler order "+i+" not supported yet.")}return t.y=n,t.z=r,t.x=o,this},t.prototype.toRotationMatrix=function(t){var i=this.x*this.x,n=this.y*this.y,r=this.z*this.z,o=this.x*this.y,s=this.z*this.w,e=this.z*this.x,h=this.y*this.w,a=this.y*this.z,u=this.x*this.w;return t.m[0]=1-2*(n+r),t.m[1]=2*(o+s),t.m[2]=2*(e-h),t.m[3]=0,t.m[4]=2*(o-s),t.m[5]=1-2*(r+i),t.m[6]=2*(a+u),t.m[7]=0,t.m[8]=2*(e+h),t.m[9]=2*(a-u),t.m[10]=1-2*(n+i),t.m[11]=0,t.m[12]=0,t.m[13]=0,t.m[14]=0,t.m[15]=1,this},t.prototype.fromRotationMatrix=function(i){return t.FromRotationMatrixToRef(i,this),this},t.FromRotationMatrix=function(i){var n=new t;return t.FromRotationMatrixToRef(i,n),n},t.FromRotationMatrixToRef=function(t,i){var n,r=t.m,o=r[0],s=r[4],e=r[8],h=r[1],a=r[5],u=r[9],m=r[2],y=r[6],c=r[10],p=o+a+c;p>0?(n=.5/Math.sqrt(p+1),i.w=.25/n,i.x=(y-u)*n,i.y=(e-m)*n,i.z=(h-s)*n):o>a&&o>c?(n=2*Math.sqrt(1+o-a-c),i.w=(y-u)/n,i.x=.25*n,i.y=(s+h)/n,i.z=(e+m)/n):a>c?(n=2*Math.sqrt(1+a-o-c),i.w=(e-m)/n,i.x=(s+h)/n,i.y=.25*n,i.z=(u+y)/n):(n=2*Math.sqrt(1+c-o-a),i.w=(h-s)/n,i.x=(e+m)/n,i.y=(u+y)/n,i.z=.25*n)},t.Inverse=function(i){return new t(-i.x,-i.y,-i.z,i.w)},t.Identity=function(){return new t(0,0,0,1)},t.RotationAxis=function(i,n){var r=new t,o=Math.sin(n/2);return i.normalize(),r.w=Math.cos(n/2),r.x=i.x*o,r.y=i.y*o,r.z=i.z*o,r},t.FromArray=function(i,n){return n||(n=0),new t(i[n],i[n+1],i[n+2],i[n+3])},t.RotationYawPitchRoll=function(i,n,r){var o=new t;return t.RotationYawPitchRollToRef(i,n,r,o),o},t.RotationYawPitchRollToRef=function(t,i,n,r){var o=.5*n,s=.5*i,e=.5*t,h=Math.sin(o),a=Math.cos(o),u=Math.sin(s),m=Math.cos(s),y=Math.sin(e),c=Math.cos(e);r.x=c*u*a+y*m*h,r.y=y*m*a-c*u*h,r.z=c*m*h-y*u*a,r.w=c*m*a+y*u*h},t.RotationAlphaBetaGamma=function(i,n,r){var o=new t;return t.RotationAlphaBetaGammaToRef(i,n,r,o),o},t.RotationAlphaBetaGammaToRef=function(t,i,n,r){var o=.5*(n+t),s=.5*(n-t),e=.5*i;r.x=Math.cos(s)*Math.sin(e),r.y=Math.sin(s)*Math.sin(e),r.z=Math.sin(o)*Math.cos(e),r.w=Math.cos(o)*Math.cos(e)},t.Slerp=function(i,n,r){var o,s,e=r,h=i.x*n.x+i.y*n.y+i.z*n.z+i.w*n.w,a=!1;if(0>h&&(a=!0,h=-h),h>.999999)s=1-e,o=a?-e:e;else{var u=Math.acos(h),m=1/Math.sin(u);s=Math.sin((1-e)*u)*m,o=a?-Math.sin(e*u)*m:Math.sin(e*u)*m}return new t(s*i.x+o*n.x,s*i.y+o*n.y,s*i.z+o*n.z,s*i.w+o*n.w)},t}();t.Quaternion=a;var u=function(){function t(){this.m=new Float32Array(16)}return t.prototype.isIdentity=function(){return 1!==this.m[0]||1!==this.m[5]||1!==this.m[10]||1!==this.m[15]?!1:0===this.m[1]&&0===this.m[2]&&0===this.m[3]&&0===this.m[4]&&0===this.m[6]&&0===this.m[7]&&0===this.m[8]&&0===this.m[9]&&0===this.m[11]&&0===this.m[12]&&0===this.m[13]&&0===this.m[14]},t.prototype.determinant=function(){var t=this.m[10]*this.m[15]-this.m[11]*this.m[14],i=this.m[9]*this.m[15]-this.m[11]*this.m[13],n=this.m[9]*this.m[14]-this.m[10]*this.m[13],r=this.m[8]*this.m[15]-this.m[11]*this.m[12],o=this.m[8]*this.m[14]-this.m[10]*this.m[12],s=this.m[8]*this.m[13]-this.m[9]*this.m[12];return this.m[0]*(this.m[5]*t-this.m[6]*i+this.m[7]*n)-this.m[1]*(this.m[4]*t-this.m[6]*r+this.m[7]*o)+this.m[2]*(this.m[4]*i-this.m[5]*r+this.m[7]*s)-this.m[3]*(this.m[4]*n-this.m[5]*o+this.m[6]*s)},t.prototype.toArray=function(){return this.m},t.prototype.asArray=function(){return this.toArray()},t.prototype.invert=function(){return this.invertToRef(this),this},t.prototype.reset=function(){for(var t=0;16>t;t++)this.m[t]=0;return this},t.prototype.add=function(i){var n=new t;return this.addToRef(i,n),n},t.prototype.addToRef=function(t,i){for(var n=0;16>n;n++)i.m[n]=this.m[n]+t.m[n];return this},t.prototype.addToSelf=function(t){for(var i=0;16>i;i++)this.m[i]+=t.m[i];return this},t.prototype.invertToRef=function(t){var i=this.m[0],n=this.m[1],r=this.m[2],o=this.m[3],s=this.m[4],e=this.m[5],h=this.m[6],a=this.m[7],u=this.m[8],m=this.m[9],y=this.m[10],c=this.m[11],p=this.m[12],f=this.m[13],l=this.m[14],x=this.m[15],z=y*x-c*l,w=m*x-c*f,v=m*l-y*f,d=u*x-c*p,g=u*l-y*p,T=u*f-m*p,R=e*z-h*w+a*v,_=-(s*z-h*d+a*g),M=s*w-e*d+a*T,b=-(s*v-e*g+h*T),F=1/(i*R+n*_+r*M+o*b),A=h*x-a*l,L=e*x-a*f,P=e*l-h*f,C=s*x-a*p,Z=s*l-h*p,S=s*f-e*p,I=h*c-a*y,q=e*c-a*m,H=e*y-h*m,N=s*c-a*u,V=s*y-h*u,D=s*m-e*u;return t.m[0]=R*F,t.m[4]=_*F,t.m[8]=M*F,t.m[12]=b*F,t.m[1]=-(n*z-r*w+o*v)*F,t.m[5]=(i*z-r*d+o*g)*F,t.m[9]=-(i*w-n*d+o*T)*F,t.m[13]=(i*v-n*g+r*T)*F,t.m[2]=(n*A-r*L+o*P)*F,t.m[6]=-(i*A-r*C+o*Z)*F,t.m[10]=(i*L-n*C+o*S)*F,t.m[14]=-(i*P-n*Z+r*S)*F,t.m[3]=-(n*I-r*q+o*H)*F,t.m[7]=(i*I-r*N+o*V)*F,t.m[11]=-(i*q-n*N+o*D)*F,t.m[15]=(i*H-n*V+r*D)*F,this},t.prototype.setTranslation=function(t){return this.m[12]=t.x,this.m[13]=t.y,this.m[14]=t.z,this},t.prototype.getTranslation=function(){return new s(this.m[12],this.m[13],this.m[14])},t.prototype.multiply=function(i){var n=new t;return this.multiplyToRef(i,n),n},t.prototype.copyFrom=function(t){for(var i=0;16>i;i++)this.m[i]=t.m[i];return this},t.prototype.copyToArray=function(t,i){void 0===i&&(i=0);for(var n=0;16>n;n++)t[i+n]=this.m[n];return this},t.prototype.multiplyToRef=function(t,i){return this.multiplyToArray(t,i.m,0),this},t.prototype.multiplyToArray=function(t,i,n){var r=this.m[0],o=this.m[1],s=this.m[2],e=this.m[3],h=this.m[4],a=this.m[5],u=this.m[6],m=this.m[7],y=this.m[8],c=this.m[9],p=this.m[10],f=this.m[11],l=this.m[12],x=this.m[13],z=this.m[14],w=this.m[15],v=t.m[0],d=t.m[1],g=t.m[2],T=t.m[3],R=t.m[4],_=t.m[5],M=t.m[6],b=t.m[7],F=t.m[8],A=t.m[9],L=t.m[10],P=t.m[11],C=t.m[12],Z=t.m[13],S=t.m[14],I=t.m[15];return i[n]=r*v+o*R+s*F+e*C,i[n+1]=r*d+o*_+s*A+e*Z,i[n+2]=r*g+o*M+s*L+e*S,i[n+3]=r*T+o*b+s*P+e*I,i[n+4]=h*v+a*R+u*F+m*C,i[n+5]=h*d+a*_+u*A+m*Z,i[n+6]=h*g+a*M+u*L+m*S,i[n+7]=h*T+a*b+u*P+m*I,i[n+8]=y*v+c*R+p*F+f*C,\ni[n+9]=y*d+c*_+p*A+f*Z,i[n+10]=y*g+c*M+p*L+f*S,i[n+11]=y*T+c*b+p*P+f*I,i[n+12]=l*v+x*R+z*F+w*C,i[n+13]=l*d+x*_+z*A+w*Z,i[n+14]=l*g+x*M+z*L+w*S,i[n+15]=l*T+x*b+z*P+w*I,this},t.prototype.equals=function(t){return t&&this.m[0]===t.m[0]&&this.m[1]===t.m[1]&&this.m[2]===t.m[2]&&this.m[3]===t.m[3]&&this.m[4]===t.m[4]&&this.m[5]===t.m[5]&&this.m[6]===t.m[6]&&this.m[7]===t.m[7]&&this.m[8]===t.m[8]&&this.m[9]===t.m[9]&&this.m[10]===t.m[10]&&this.m[11]===t.m[11]&&this.m[12]===t.m[12]&&this.m[13]===t.m[13]&&this.m[14]===t.m[14]&&this.m[15]===t.m[15]},t.prototype.clone=function(){return t.FromValues(this.m[0],this.m[1],this.m[2],this.m[3],this.m[4],this.m[5],this.m[6],this.m[7],this.m[8],this.m[9],this.m[10],this.m[11],this.m[12],this.m[13],this.m[14],this.m[15])},t.prototype.getClassName=function(){return"Matrix"},t.prototype.getHashCode=function(){for(var t=this.m[0]||0,i=1;16>i;i++)t=397*t^(this.m[i]||0);return t},t.prototype.decompose=function(n,r,o){o.x=this.m[12],o.y=this.m[13],o.z=this.m[14];var s=i.Sign(this.m[0]*this.m[1]*this.m[2]*this.m[3])<0?-1:1,e=i.Sign(this.m[4]*this.m[5]*this.m[6]*this.m[7])<0?-1:1,h=i.Sign(this.m[8]*this.m[9]*this.m[10]*this.m[11])<0?-1:1;if(n.x=s*Math.sqrt(this.m[0]*this.m[0]+this.m[1]*this.m[1]+this.m[2]*this.m[2]),n.y=e*Math.sqrt(this.m[4]*this.m[4]+this.m[5]*this.m[5]+this.m[6]*this.m[6]),n.z=h*Math.sqrt(this.m[8]*this.m[8]+this.m[9]*this.m[9]+this.m[10]*this.m[10]),0===n.x||0===n.y||0===n.z)return r.x=0,r.y=0,r.z=0,r.w=1,!1;var u=t.FromValues(this.m[0]/n.x,this.m[1]/n.x,this.m[2]/n.x,0,this.m[4]/n.y,this.m[5]/n.y,this.m[6]/n.y,0,this.m[8]/n.z,this.m[9]/n.z,this.m[10]/n.z,0,0,0,0,1);return a.FromRotationMatrixToRef(u,r),!0},t.FromArray=function(i,n){var r=new t;return n||(n=0),t.FromArrayToRef(i,n,r),r},t.FromArrayToRef=function(t,i,n){for(var r=0;16>r;r++)n.m[r]=t[r+i]},t.FromFloat32ArrayToRefScaled=function(t,i,n,r){for(var o=0;16>o;o++)r.m[o]=t[o+i]*n},t.FromValuesToRef=function(t,i,n,r,o,s,e,h,a,u,m,y,c,p,f,l,x){x.m[0]=t,x.m[1]=i,x.m[2]=n,x.m[3]=r,x.m[4]=o,x.m[5]=s,x.m[6]=e,x.m[7]=h,x.m[8]=a,x.m[9]=u,x.m[10]=m,x.m[11]=y,x.m[12]=c,x.m[13]=p,x.m[14]=f,x.m[15]=l},t.prototype.getRow=function(t){if(0>t||t>3)return null;var i=4*t;return new e(this.m[i+0],this.m[i+1],this.m[i+2],this.m[i+3])},t.prototype.setRow=function(t,i){if(0>t||t>3)return this;var n=4*t;return this.m[n+0]=i.x,this.m[n+1]=i.y,this.m[n+2]=i.z,this.m[n+3]=i.w,this},t.FromValues=function(i,n,r,o,s,e,h,a,u,m,y,c,p,f,l,x){var z=new t;return z.m[0]=i,z.m[1]=n,z.m[2]=r,z.m[3]=o,z.m[4]=s,z.m[5]=e,z.m[6]=h,z.m[7]=a,z.m[8]=u,z.m[9]=m,z.m[10]=y,z.m[11]=c,z.m[12]=p,z.m[13]=f,z.m[14]=l,z.m[15]=x,z},t.Compose=function(i,n,r){var o=t.FromValues(i.x,0,0,0,0,i.y,0,0,0,0,i.z,0,0,0,0,1),s=t.Identity();return n.toRotationMatrix(s),o=o.multiply(s),o.setTranslation(r),o},t.Identity=function(){return t.FromValues(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1)},t.IdentityToRef=function(i){t.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,i)},t.Zero=function(){return t.FromValues(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)},t.RotationX=function(i){var n=new t;return t.RotationXToRef(i,n),n},t.Invert=function(i){var n=new t;return i.invertToRef(n),n},t.RotationXToRef=function(t,i){var n=Math.sin(t),r=Math.cos(t);i.m[0]=1,i.m[15]=1,i.m[5]=r,i.m[10]=r,i.m[9]=-n,i.m[6]=n,i.m[1]=0,i.m[2]=0,i.m[3]=0,i.m[4]=0,i.m[7]=0,i.m[8]=0,i.m[11]=0,i.m[12]=0,i.m[13]=0,i.m[14]=0},t.RotationY=function(i){var n=new t;return t.RotationYToRef(i,n),n},t.RotationYToRef=function(t,i){var n=Math.sin(t),r=Math.cos(t);i.m[5]=1,i.m[15]=1,i.m[0]=r,i.m[2]=-n,i.m[8]=n,i.m[10]=r,i.m[1]=0,i.m[3]=0,i.m[4]=0,i.m[6]=0,i.m[7]=0,i.m[9]=0,i.m[11]=0,i.m[12]=0,i.m[13]=0,i.m[14]=0},t.RotationZ=function(i){var n=new t;return t.RotationZToRef(i,n),n},t.RotationZToRef=function(t,i){var n=Math.sin(t),r=Math.cos(t);i.m[10]=1,i.m[15]=1,i.m[0]=r,i.m[1]=n,i.m[4]=-n,i.m[5]=r,i.m[2]=0,i.m[3]=0,i.m[6]=0,i.m[7]=0,i.m[8]=0,i.m[9]=0,i.m[11]=0,i.m[12]=0,i.m[13]=0,i.m[14]=0},t.RotationAxis=function(i,n){var r=t.Zero();return t.RotationAxisToRef(i,n,r),r},t.RotationAxisToRef=function(t,i,n){var r=Math.sin(-i),o=Math.cos(-i),s=1-o;t.normalize(),n.m[0]=t.x*t.x*s+o,n.m[1]=t.x*t.y*s-t.z*r,n.m[2]=t.x*t.z*s+t.y*r,n.m[3]=0,n.m[4]=t.y*t.x*s+t.z*r,n.m[5]=t.y*t.y*s+o,n.m[6]=t.y*t.z*s-t.x*r,n.m[7]=0,n.m[8]=t.z*t.x*s-t.y*r,n.m[9]=t.z*t.y*s+t.x*r,n.m[10]=t.z*t.z*s+o,n.m[11]=0,n.m[15]=1},t.RotationYawPitchRoll=function(i,n,r){var o=new t;return t.RotationYawPitchRollToRef(i,n,r,o),o},t.RotationYawPitchRollToRef=function(t,i,n,r){a.RotationYawPitchRollToRef(t,i,n,this._tempQuaternion),this._tempQuaternion.toRotationMatrix(r)},t.Scaling=function(i,n,r){var o=t.Zero();return t.ScalingToRef(i,n,r,o),o},t.ScalingToRef=function(t,i,n,r){r.m[0]=t,r.m[1]=0,r.m[2]=0,r.m[3]=0,r.m[4]=0,r.m[5]=i,r.m[6]=0,r.m[7]=0,r.m[8]=0,r.m[9]=0,r.m[10]=n,r.m[11]=0,r.m[12]=0,r.m[13]=0,r.m[14]=0,r.m[15]=1},t.Translation=function(i,n,r){var o=t.Identity();return t.TranslationToRef(i,n,r,o),o},t.TranslationToRef=function(i,n,r,o){t.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,i,n,r,1,o)},t.Lerp=function(i,n,r){for(var o=t.Zero(),s=0;16>s;s++)o.m[s]=i.m[s]*(1-r)+n.m[s]*r;return o},t.DecomposeLerp=function(i,n,r){var o=new s(0,0,0),e=new a,h=new s(0,0,0);i.decompose(o,e,h);var u=new s(0,0,0),m=new a,y=new s(0,0,0);n.decompose(u,m,y);var c=s.Lerp(o,u,r),p=a.Slerp(e,m,r),f=s.Lerp(h,y,r);return t.Compose(c,p,f)},t.LookAtLH=function(i,n,r){var o=t.Zero();return t.LookAtLHToRef(i,n,r,o),o},t.LookAtLHToRef=function(i,n,r,o){n.subtractToRef(i,this._zAxis),this._zAxis.normalize(),s.CrossToRef(r,this._zAxis,this._xAxis),0===this._xAxis.lengthSquared()?this._xAxis.x=1:this._xAxis.normalize(),s.CrossToRef(this._zAxis,this._xAxis,this._yAxis),this._yAxis.normalize();var e=-s.Dot(this._xAxis,i),h=-s.Dot(this._yAxis,i),a=-s.Dot(this._zAxis,i);return t.FromValuesToRef(this._xAxis.x,this._yAxis.x,this._zAxis.x,0,this._xAxis.y,this._yAxis.y,this._zAxis.y,0,this._xAxis.z,this._yAxis.z,this._zAxis.z,0,e,h,a,1,o)},t.OrthoLH=function(i,n,r,o){var s=t.Zero();return t.OrthoLHToRef(i,n,r,o,s),s},t.OrthoLHToRef=function(i,n,r,o,s){var e=2/i,h=2/n,a=1/(o-r),u=r/(r-o);t.FromValuesToRef(e,0,0,0,0,h,0,0,0,0,a,0,0,0,u,1,s)},t.OrthoOffCenterLH=function(i,n,r,o,s,e){var h=t.Zero();return t.OrthoOffCenterLHToRef(i,n,r,o,s,e,h),h},t.OrthoOffCenterLHToRef=function(t,i,n,r,o,s,e){e.m[0]=2/(i-t),e.m[1]=e.m[2]=e.m[3]=0,e.m[5]=2/(r-n),e.m[4]=e.m[6]=e.m[7]=0,e.m[10]=-1/(o-s),e.m[8]=e.m[9]=e.m[11]=0,e.m[12]=(t+i)/(t-i),e.m[13]=(r+n)/(n-r),e.m[14]=o/(o-s),e.m[15]=1},t.PerspectiveLH=function(i,n,r,o){var s=t.Zero();return s.m[0]=2*r/i,s.m[1]=s.m[2]=s.m[3]=0,s.m[5]=2*r/n,s.m[4]=s.m[6]=s.m[7]=0,s.m[10]=-o/(r-o),s.m[8]=s.m[9]=0,s.m[11]=1,s.m[12]=s.m[13]=s.m[15]=0,s.m[14]=r*o/(r-o),s},t.PerspectiveFovLH=function(i,n,r,o){var s=t.Zero();return t.PerspectiveFovLHToRef(i,n,r,o,s),s},t.PerspectiveFovLHToRef=function(t,i,n,r,o,s){void 0===s&&(s=!0);var e=1/Math.tan(.5*t);s?o.m[0]=e/i:o.m[0]=e,o.m[1]=o.m[2]=o.m[3]=0,s?o.m[5]=e:o.m[5]=e*i,o.m[4]=o.m[6]=o.m[7]=0,o.m[8]=o.m[9]=0,o.m[10]=-r/(n-r),o.m[11]=1,o.m[12]=o.m[13]=o.m[15]=0,o.m[14]=n*r/(n-r)},t.GetFinalMatrix=function(i,n,r,o,s,e){var h=i.width,a=i.height,u=i.x,m=i.y,y=t.FromValues(h/2,0,0,0,0,-a/2,0,0,0,0,e-s,0,u+h/2,a/2+m,s,1);return n.multiply(r).multiply(o).multiply(y)},t.GetAsMatrix2x2=function(t){return new Float32Array([t.m[0],t.m[1],t.m[4],t.m[5]])},t.GetAsMatrix3x3=function(t){return new Float32Array([t.m[0],t.m[1],t.m[2],t.m[4],t.m[5],t.m[6],t.m[8],t.m[9],t.m[10]])},t.Transpose=function(i){var n=new t;return n.m[0]=i.m[0],n.m[1]=i.m[4],n.m[2]=i.m[8],n.m[3]=i.m[12],n.m[4]=i.m[1],n.m[5]=i.m[5],n.m[6]=i.m[9],n.m[7]=i.m[13],n.m[8]=i.m[2],n.m[9]=i.m[6],n.m[10]=i.m[10],n.m[11]=i.m[14],n.m[12]=i.m[3],n.m[13]=i.m[7],n.m[14]=i.m[11],n.m[15]=i.m[15],n},t.Reflection=function(i){var n=new t;return t.ReflectionToRef(i,n),n},t.ReflectionToRef=function(t,i){t.normalize();var n=t.normal.x,r=t.normal.y,o=t.normal.z,s=-2*n,e=-2*r,h=-2*o;i.m[0]=s*n+1,i.m[1]=e*n,i.m[2]=h*n,i.m[3]=0,i.m[4]=s*r,i.m[5]=e*r+1,i.m[6]=h*r,i.m[7]=0,i.m[8]=s*o,i.m[9]=e*o,i.m[10]=h*o+1,i.m[11]=0,i.m[12]=s*t.d,i.m[13]=e*t.d,i.m[14]=h*t.d,i.m[15]=1},t._tempQuaternion=new a,t._xAxis=s.Zero(),t._yAxis=s.Zero(),t._zAxis=s.Zero(),t}();t.Matrix=u;var m=function(){function t(t,i,n,r){this.normal=new s(t,i,n),this.d=r}return t.prototype.asArray=function(){return[this.normal.x,this.normal.y,this.normal.z,this.d]},t.prototype.clone=function(){return new t(this.normal.x,this.normal.y,this.normal.z,this.d)},t.prototype.getClassName=function(){return"Plane"},t.prototype.getHashCode=function(){var t=this.normal.getHashCode();return t=397*t^(this.d||0)},t.prototype.normalize=function(){var t=Math.sqrt(this.normal.x*this.normal.x+this.normal.y*this.normal.y+this.normal.z*this.normal.z),i=0;return 0!==t&&(i=1/t),this.normal.x*=i,this.normal.y*=i,this.normal.z*=i,this.d*=i,this},t.prototype.transform=function(i){var n=u.Transpose(i),r=this.normal.x,o=this.normal.y,s=this.normal.z,e=this.d,h=r*n.m[0]+o*n.m[1]+s*n.m[2]+e*n.m[3],a=r*n.m[4]+o*n.m[5]+s*n.m[6]+e*n.m[7],m=r*n.m[8]+o*n.m[9]+s*n.m[10]+e*n.m[11],y=r*n.m[12]+o*n.m[13]+s*n.m[14]+e*n.m[15];return new t(h,a,m,y)},t.prototype.dotCoordinate=function(t){return this.normal.x*t.x+this.normal.y*t.y+this.normal.z*t.z+this.d},t.prototype.copyFromPoints=function(t,i,n){var r,o=i.x-t.x,s=i.y-t.y,e=i.z-t.z,h=n.x-t.x,a=n.y-t.y,u=n.z-t.z,m=s*u-e*a,y=e*h-o*u,c=o*a-s*h,p=Math.sqrt(m*m+y*y+c*c);return r=0!==p?1/p:0,this.normal.x=m*r,this.normal.y=y*r,this.normal.z=c*r,this.d=-(this.normal.x*t.x+this.normal.y*t.y+this.normal.z*t.z),this},t.prototype.isFrontFacingTo=function(t,i){var n=s.Dot(this.normal,t);return i>=n},t.prototype.signedDistanceTo=function(t){return s.Dot(t,this.normal)+this.d},t.FromArray=function(i){return new t(i[0],i[1],i[2],i[3])},t.FromPoints=function(i,n,r){var o=new t(0,0,0,0);return o.copyFromPoints(i,n,r),o},t.FromPositionAndNormal=function(i,n){var r=new t(0,0,0,0);return n.normalize(),r.normal=n,r.d=-(n.x*i.x+n.y*i.y+n.z*i.z),r},t.SignedDistanceToPlaneFromPositionAndNormal=function(t,i,n){var r=-(i.x*t.x+i.y*t.y+i.z*t.z);return s.Dot(n,i)+r},t}();t.Plane=m;var y=function(){function t(t,i,n,r){this.x=t,this.y=i,this.width=n,this.height=r}return t.prototype.toGlobal=function(i,n){return new t(this.x*i,this.y*n,this.width*i,this.height*n)},t}();t.Viewport=y;var c=function(){function t(){}return t.GetPlanes=function(i){for(var n=[],r=0;6>r;r++)n.push(new m(0,0,0,0));return t.GetPlanesToRef(i,n),n},t.GetPlanesToRef=function(t,i){i[0].normal.x=t.m[3]+t.m[2],i[0].normal.y=t.m[7]+t.m[6],i[0].normal.z=t.m[11]+t.m[10],i[0].d=t.m[15]+t.m[14],i[0].normalize(),i[1].normal.x=t.m[3]-t.m[2],i[1].normal.y=t.m[7]-t.m[6],i[1].normal.z=t.m[11]-t.m[10],i[1].d=t.m[15]-t.m[14],i[1].normalize(),i[2].normal.x=t.m[3]+t.m[0],i[2].normal.y=t.m[7]+t.m[4],i[2].normal.z=t.m[11]+t.m[8],i[2].d=t.m[15]+t.m[12],i[2].normalize(),i[3].normal.x=t.m[3]-t.m[0],i[3].normal.y=t.m[7]-t.m[4],i[3].normal.z=t.m[11]-t.m[8],i[3].d=t.m[15]-t.m[12],i[3].normalize(),i[4].normal.x=t.m[3]-t.m[1],i[4].normal.y=t.m[7]-t.m[5],i[4].normal.z=t.m[11]-t.m[9],i[4].d=t.m[15]-t.m[13],i[4].normalize(),i[5].normal.x=t.m[3]+t.m[1],i[5].normal.y=t.m[7]+t.m[5],i[5].normal.z=t.m[11]+t.m[9],i[5].d=t.m[15]+t.m[13],i[5].normalize()},t}();t.Frustum=c,function(t){t[t.LOCAL=0]="LOCAL",t[t.WORLD=1]="WORLD"}(t.Space||(t.Space={}));var p=(t.Space,function(){function t(){}return t.X=new s(1,0,0),t.Y=new s(0,1,0),t.Z=new s(0,0,1),t}());t.Axis=p;var f=function(){function t(){}return t.interpolate=function(t,i,n,r,o){for(var s=1-3*r+3*i,e=3*r-6*i,h=3*i,a=t,u=0;5>u;u++){var m=a*a,y=m*a,c=s*y+e*m+h*a,p=1/(3*s*m+2*e*a+h);a-=(c-t)*p,a=Math.min(1,Math.max(0,a))}return 3*Math.pow(1-a,2)*a*n+3*(1-a)*Math.pow(a,2)*o+Math.pow(a,3)},t}();t.BezierCurve=f,function(t){t[t.CW=0]="CW",t[t.CCW=1]="CCW"}(t.Orientation||(t.Orientation={}));var l=t.Orientation,x=function(){function t(t){var i=this;this.degrees=function(){return 180*i._radians/Math.PI},this.radians=function(){return i._radians},this._radians=t,this._radians<0&&(this._radians+=2*Math.PI)}return t.BetweenTwoPoints=function(i,n){var r=n.subtract(i),o=Math.atan2(r.y,r.x);return new t(o)},t.FromRadians=function(i){return new t(i)},t.FromDegrees=function(i){return new t(i*Math.PI/180)},t}();t.Angle=x;var z=function(){function t(t,i,n){this.startPoint=t,this.midPoint=i,this.endPoint=n;var r=Math.pow(i.x,2)+Math.pow(i.y,2),s=(Math.pow(t.x,2)+Math.pow(t.y,2)-r)/2,e=(r-Math.pow(n.x,2)-Math.pow(n.y,2))/2,h=(t.x-i.x)*(i.y-n.y)-(i.x-n.x)*(t.y-i.y);this.centerPoint=new o((s*(i.y-n.y)-e*(t.y-i.y))/h,((t.x-i.x)*e-(i.x-n.x)*s)/h),this.radius=this.centerPoint.subtract(this.startPoint).length(),this.startAngle=x.BetweenTwoPoints(this.centerPoint,this.startPoint);var a=this.startAngle.degrees(),u=x.BetweenTwoPoints(this.centerPoint,this.midPoint).degrees(),m=x.BetweenTwoPoints(this.centerPoint,this.endPoint).degrees();u-a>180&&(u-=360),-180>u-a&&(u+=360),m-u>180&&(m-=360),-180>m-u&&(m+=360),this.orientation=0>u-a?l.CW:l.CCW,this.angle=x.FromDegrees(this.orientation===l.CW?a-m:m-a)}return t}();t.Arc2=z;var w=function(){function t(t,i){this._points=new Array,this._length=0,this.closed=!1,this._points.push(new o(t,i))}return t.prototype.addLineTo=function(t,i){if(closed)return this;var n=new o(t,i),r=this._points[this._points.length-1];return this._points.push(n),this._length+=n.subtract(r).length(),this},t.prototype.addArcTo=function(t,i,n,r,s){if(void 0===s&&(s=36),closed)return this;var e=this._points[this._points.length-1],h=new o(t,i),a=new o(n,r),u=new z(e,h,a),m=u.angle.radians()/s;u.orientation===l.CW&&(m*=-1);for(var y=u.startAngle.radians()+m,c=0;s>c;c++){var p=Math.cos(y)*u.radius+u.centerPoint.x,f=Math.sin(y)*u.radius+u.centerPoint.y;this.addLineTo(p,f),y+=m}return this},t.prototype.close=function(){return this.closed=!0,this},t.prototype.length=function(){var t=this._length;if(!this.closed){var i=this._points[this._points.length-1],n=this._points[0];t+=n.subtract(i).length()}return t},t.prototype.getPoints=function(){return this._points},t.prototype.getPointAtLengthPosition=function(t){if(0>t||t>1)return o.Zero();for(var i=t*this.length(),n=0,r=0;r<this._points.length;r++){var s=(r+1)%this._points.length,e=this._points[r],h=this._points[s],a=h.subtract(e),u=a.length()+n;if(i>=n&&u>=i){var m=a.normalize(),y=i-n;return new o(e.x+m.x*y,e.y+m.y*y)}n=u}return o.Zero()},t.StartingAt=function(i,n){return new t(i,n)},t}();t.Path2=w;var v=function(){function n(t,i,n){this.path=t,this._curve=new Array,this._distances=new Array,this._tangents=new Array,this._normals=new Array,this._binormals=new Array;for(var r=0;r<t.length;r++)this._curve[r]=t[r].clone();this._raw=n||!1,this._compute(i)}return n.prototype.getCurve=function(){return this._curve},n.prototype.getTangents=function(){return this._tangents},n.prototype.getNormals=function(){return this._normals},n.prototype.getBinormals=function(){return this._binormals},n.prototype.getDistances=function(){return this._distances},n.prototype.update=function(t,i){for(var n=0;n<t.length;n++)this._curve[n].x=t[n].x,this._curve[n].y=t[n].y,this._curve[n].z=t[n].z;return this._compute(i),this},n.prototype._compute=function(t){var i=this._curve.length;this._tangents[0]=this._getFirstNonNullVector(0),this._raw||this._tangents[0].normalize(),this._tangents[i-1]=this._curve[i-1].subtract(this._curve[i-2]),this._raw||this._tangents[i-1].normalize();var n=this._tangents[0],r=this._normalVector(this._curve[0],n,t);this._normals[0]=r,this._raw||this._normals[0].normalize(),this._binormals[0]=s.Cross(n,this._normals[0]),this._raw||this._binormals[0].normalize(),this._distances[0]=0;for(var o,e,h,a,u=1;i>u;u++)o=this._getLastNonNullVector(u),i-1>u&&(e=this._getFirstNonNullVector(u),this._tangents[u]=o.add(e),this._tangents[u].normalize()),this._distances[u]=this._distances[u-1]+o.length(),h=this._tangents[u],a=this._binormals[u-1],this._normals[u]=s.Cross(a,h),this._raw||this._normals[u].normalize(),this._binormals[u]=s.Cross(h,this._normals[u]),this._raw||this._binormals[u].normalize()},n.prototype._getFirstNonNullVector=function(t){for(var i=1,n=this._curve[t+i].subtract(this._curve[t]);0===n.length()&&t+i+1<this._curve.length;)i++,n=this._curve[t+i].subtract(this._curve[t]);return n},n.prototype._getLastNonNullVector=function(t){for(var i=1,n=this._curve[t].subtract(this._curve[t-i]);0===n.length()&&t>i+1;)i++,n=this._curve[t].subtract(this._curve[t-i]);return n},n.prototype._normalVector=function(n,r,o){var e;if(void 0===o||null===o){var h;i.WithinEpsilon(r.y,1,t.Epsilon)?i.WithinEpsilon(r.x,1,t.Epsilon)?i.WithinEpsilon(r.z,1,t.Epsilon)||(h=new s(0,0,1)):h=new s(1,0,0):h=new s(0,-1,0),e=s.Cross(r,h)}else e=s.Cross(r,o),s.CrossToRef(e,r,e);return e.normalize(),e},n}();t.Path3D=v;var d=function(){function t(t){this._length=0,this._points=t,this._length=this._computeLength(t)}return t.CreateQuadraticBezier=function(i,n,r,o){o=o>2?o:3;for(var e=new Array,h=function(t,i,n,r){var o=(1-t)*(1-t)*i+2*t*(1-t)*n+t*t*r;return o},a=0;o>=a;a++)e.push(new s(h(a/o,i.x,n.x,r.x),h(a/o,i.y,n.y,r.y),h(a/o,i.z,n.z,r.z)));return new t(e)},t.CreateCubicBezier=function(i,n,r,o,e){e=e>3?e:4;for(var h=new Array,a=function(t,i,n,r,o){var s=(1-t)*(1-t)*(1-t)*i+3*t*(1-t)*(1-t)*n+3*t*t*(1-t)*r+t*t*t*o;return s},u=0;e>=u;u++)h.push(new s(a(u/e,i.x,n.x,r.x,o.x),a(u/e,i.y,n.y,r.y,o.y),a(u/e,i.z,n.z,r.z,o.z)));return new t(h)},t.CreateHermiteSpline=function(i,n,r,o,e){for(var h=new Array,a=1/e,u=0;e>=u;u++)h.push(s.Hermite(i,n,r,o,u*a));return new t(h)},t.prototype.getPoints=function(){return this._points},t.prototype.length=function(){return this._length},t.prototype["continue"]=function(i){for(var n=this._points[this._points.length-1],r=this._points.slice(),o=i.getPoints(),s=1;s<o.length;s++)r.push(o[s].subtract(o[0]).add(n));var e=new t(r);return e},t.prototype._computeLength=function(t){for(var i=0,n=1;n<t.length;n++)i+=t[n].subtract(t[n-1]).length();return i},t}();t.Curve3=d;var g=function(){function t(){this.L00=s.Zero(),this.L1_1=s.Zero(),this.L10=s.Zero(),this.L11=s.Zero(),this.L2_2=s.Zero(),this.L2_1=s.Zero(),this.L20=s.Zero(),this.L21=s.Zero(),this.L22=s.Zero()}return t.prototype.addLight=function(t,i,n){var r=new s(i.r,i.g,i.b),o=r.scale(n);this.L00=this.L00.add(o.scale(.282095)),this.L1_1=this.L1_1.add(o.scale(.488603*t.y)),this.L10=this.L10.add(o.scale(.488603*t.z)),this.L11=this.L11.add(o.scale(.488603*t.x)),this.L2_2=this.L2_2.add(o.scale(1.092548*t.x*t.y)),this.L2_1=this.L2_1.add(o.scale(1.092548*t.y*t.z)),this.L21=this.L21.add(o.scale(1.092548*t.x*t.z)),this.L20=this.L20.add(o.scale(.315392*(3*t.z*t.z-1))),this.L22=this.L22.add(o.scale(.546274*(t.x*t.x-t.y*t.y)))},t.prototype.scale=function(t){this.L00=this.L00.scale(t),this.L1_1=this.L1_1.scale(t),this.L10=this.L10.scale(t),this.L11=this.L11.scale(t),this.L2_2=this.L2_2.scale(t),this.L2_1=this.L2_1.scale(t),this.L20=this.L20.scale(t),this.L21=this.L21.scale(t),this.L22=this.L22.scale(t)},t}();t.SphericalHarmonics=g;var T=function(){function t(){this.x=s.Zero(),this.y=s.Zero(),this.z=s.Zero(),this.xx=s.Zero(),this.yy=s.Zero(),this.zz=s.Zero(),this.xy=s.Zero(),this.yz=s.Zero(),this.zx=s.Zero()}return t.prototype.addAmbient=function(t){var i=new s(t.r,t.g,t.b);this.xx=this.xx.add(i),this.yy=this.yy.add(i),this.zz=this.zz.add(i)},t.getSphericalPolynomialFromHarmonics=function(i){var n=new t;return n.x=i.L11.scale(1.02333),n.y=i.L1_1.scale(1.02333),n.z=i.L10.scale(1.02333),n.xx=i.L00.scale(.886277).subtract(i.L20.scale(.247708)).add(i.L22.scale(.429043)),n.yy=i.L00.scale(.886277).subtract(i.L20.scale(.247708)).subtract(i.L22.scale(.429043)),n.zz=i.L00.scale(.886277).add(i.L20.scale(.495417)),n.yz=i.L2_1.scale(.858086),n.zx=i.L21.scale(.858086),n.xy=i.L2_2.scale(.858086),n},t}();t.SphericalPolynomial=T;var R=function(){function t(t,i){void 0===t&&(t=s.Zero()),void 0===i&&(i=s.Up()),this.position=t,this.normal=i}return t.prototype.clone=function(){return new t(this.position.clone(),this.normal.clone())},t}();t.PositionNormalVertex=R;var _=function(){function t(t,i,n){void 0===t&&(t=s.Zero()),void 0===i&&(i=s.Up()),void 0===n&&(n=o.Zero()),this.position=t,this.normal=i,this.uv=n}return t.prototype.clone=function(){return new t(this.position.clone(),this.normal.clone(),this.uv.clone())},t}();t.PositionNormalTextureVertex=_;var M=function(){function t(){}return t.Color3=[n.Black(),n.Black(),n.Black()],t.Vector2=[o.Zero(),o.Zero(),o.Zero()],t.Vector3=[s.Zero(),s.Zero(),s.Zero(),s.Zero(),s.Zero(),s.Zero(),s.Zero(),s.Zero(),s.Zero()],t.Vector4=[e.Zero(),e.Zero(),e.Zero()],t.Quaternion=[new a(0,0,0,0)],t.Matrix=[u.Zero(),u.Zero(),u.Zero(),u.Zero(),u.Zero(),u.Zero(),u.Zero(),u.Zero()],t}();t.Tmp=M}(BABYLON||(BABYLON={}));',
  41. ("undefined"!=typeof window&&window.module||"undefined"!=typeof module)&&"undefined"!=typeof module.exports&&(module.exports=BABYLON);