From 622feae3affd6731ea83d2431fc77f5f72d5a397 Mon Sep 17 00:00:00 2001 From: davrous Date: Wed, 11 Jan 2017 14:11:50 +0100 Subject: [PATCH] Better error control on file: loading & VJ first fix --- Babylon.csproj | 2 +- dist/preview release/babylon.core.js | 44 +- dist/preview release/babylon.d.ts | 4522 +++++++++++----------- dist/preview release/babylon.js | 74 +- dist/preview release/babylon.max.js | 164 +- dist/preview release/babylon.noworker.js | 70 +- 6 files changed, 2519 insertions(+), 2357 deletions(-) diff --git a/Babylon.csproj b/Babylon.csproj index 7cc863c5cf3..0a7b14e0185 100644 --- a/Babylon.csproj +++ b/Babylon.csproj @@ -542,7 +542,7 @@ True 0 / - http://localhost:51793/ + http://localhost:10683/ False False diff --git a/dist/preview release/babylon.core.js b/dist/preview release/babylon.core.js index 603bfaae4a1..74934ba2bcd 100644 --- a/dist/preview release/babylon.core.js +++ b/dist/preview release/babylon.core.js @@ -1,27 +1,27 @@ var __decorate=this&&this.__decorate||function(e,t,i,r){var n,o=arguments.length,s=o<3?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=(o<3?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-i<=r&&r<=i},e.ToHex=function(e){var t=e.toString(16);return e<=15?("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;rr.x?r.x:n,n=nr.y?r.y:o,o=ot.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=n<0?-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&&s+a<2*n*o},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.Center=function(e,t){var i=e.add(t);return i.scaleInPlace(.5),i},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.xthis.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.Forward=function(){return new i(0,0,1)},i.Right=function(){return new i(1,0,0)},i.Left=function(){return new i((-1),0,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){var r=e.x*t.m[0]+e.y*t.m[4]+e.z*t.m[8],n=e.x*t.m[1]+e.y*t.m[5]+e.z*t.m[9],o=e.x*t.m[2]+e.y*t.m[6]+e.z*t.m[10];i.x=r,i.y=n,i.z=o},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=nr.y?r.y:o,o=or.z?r.z:s,s=sthis.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.copyFromFloats=function(e,t){this.width=e,this.height=t},e.prototype.multiplyByFloats=function(t,i){return new e(this.width*t,this.height*i)},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)},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=this.z,r=this.x,n=this.y,o=this.w,s=o*o,a=i*i,h=r*r,c=n*n,l=n*i-r*o,u=.4999999;return l<-u?(e.y=2*Math.atan2(n,o),e.x=Math.PI/2,e.z=0):l>u?(e.y=2*Math.atan2(n,o),e.x=-Math.PI/2,e.z=0):(e.z=Math.atan2(2*(r*n+i*o),-a-h+c+s),e.x=Math.asin(-2*(i*n-r*o)),e.y=Math.atan2(2*(i*r+n*o),a-h-c+s)),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){return e.RotationAxisToRef(t,i,new e)},e.RotationAxisToRef=function(e,t,i){var r=Math.sin(t/2);return e.normalize(),i.w=Math.cos(t/2),i.x=e.x*r,i.y=e.y*r,i.z=e.z*r,i},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=e.Identity();return e.SlerpToRef(t,i,r,n),n},e.SlerpToRef=function(e,t,i,r){var n,o,s=i,a=e.x*t.x+e.y*t.y+e.z*t.z+e.w*t.w,h=!1;if(a<0&&(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}r.x=o*e.x+n*t.x,r.y=o*e.y+n*t.y,r.z=o*e.z+n*t.z,r.w=o*e.w+n*t.w},e})();e.Quaternion=h;var c=(function(){function i(){this.m=new Float32Array(16)}return i.prototype.isIdentity=function(){return 1===this.m[0]&&1===this.m[5]&&1===this.m[10]&&1===this.m[15]&&(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])},i.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)},i.prototype.toArray=function(){return this.m},i.prototype.asArray=function(){return this.toArray()},i.prototype.invert=function(){return this.invertToRef(this),this},i.prototype.reset=function(){for(var e=0;e<16;e++)this.m[e]=0;return this},i.prototype.add=function(e){var t=new i;return this.addToRef(e,t),t},i.prototype.addToRef=function(e,t){for(var i=0;i<16;i++)t.m[i]=this.m[i]+e.m[i];return this},i.prototype.addToSelf=function(e){for(var t=0;t<16;t++)this.m[t]+=e.m[t];return this},i.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],m=this.m[14],g=this.m[15],_=u*g-f*m,v=l*g-f*p,y=l*m-u*p,x=c*g-f*d,b=c*m-u*d,A=c*p-l*d,T=s*_-a*v+h*y,E=-(o*_-a*x+h*b),M=o*v-s*x+h*A,P=-(o*y-s*b+a*A),S=1/(t*T+i*E+r*M+n*P),C=a*g-h*m,R=s*g-h*p,O=s*m-a*p,D=o*g-h*d,I=o*m-a*d,L=o*p-s*d,w=a*f-h*u,B=s*f-h*l,F=s*u-a*l,V=o*f-h*c,N=o*u-a*c,U=o*l-s*c;return e.m[0]=T*S,e.m[4]=E*S,e.m[8]=M*S,e.m[12]=P*S,e.m[1]=-(i*_-r*v+n*y)*S,e.m[5]=(t*_-r*x+n*b)*S, e.m[9]=-(t*v-i*x+n*A)*S,e.m[13]=(t*y-i*b+r*A)*S,e.m[2]=(i*C-r*R+n*O)*S,e.m[6]=-(t*C-r*D+n*I)*S,e.m[10]=(t*R-i*D+n*L)*S,e.m[14]=-(t*O-i*I+r*L)*S,e.m[3]=-(i*w-r*B+n*F)*S,e.m[7]=(t*w-r*V+n*N)*S,e.m[11]=-(t*B-i*V+n*U)*S,e.m[15]=(t*F-i*N+r*U)*S,this},i.prototype.setTranslation=function(e){return this.m[12]=e.x,this.m[13]=e.y,this.m[14]=e.z,this},i.prototype.getTranslation=function(){return new o(this.m[12],this.m[13],this.m[14])},i.prototype.multiply=function(e){var t=new i;return this.multiplyToRef(e,t),t},i.prototype.copyFrom=function(e){for(var t=0;t<16;t++)this.m[t]=e.m[t];return this},i.prototype.copyToArray=function(e,t){void 0===t&&(t=0);for(var i=0;i<16;i++)e[t+i]=this.m[i];return this},i.prototype.multiplyToRef=function(e,t){return this.multiplyToArray(e,t.m,0),this},i.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],m=this.m[12],g=this.m[13],_=this.m[14],v=this.m[15],y=e.m[0],x=e.m[1],b=e.m[2],A=e.m[3],T=e.m[4],E=e.m[5],M=e.m[6],P=e.m[7],S=e.m[8],C=e.m[9],R=e.m[10],O=e.m[11],D=e.m[12],I=e.m[13],L=e.m[14],w=e.m[15];return t[i]=r*y+n*T+o*S+s*D,t[i+1]=r*x+n*E+o*C+s*I,t[i+2]=r*b+n*M+o*R+s*L,t[i+3]=r*A+n*P+o*O+s*w,t[i+4]=a*y+h*T+c*S+l*D,t[i+5]=a*x+h*E+c*C+l*I,t[i+6]=a*b+h*M+c*R+l*L,t[i+7]=a*A+h*P+c*O+l*w,t[i+8]=u*y+f*T+d*S+p*D,t[i+9]=u*x+f*E+d*C+p*I,t[i+10]=u*b+f*M+d*R+p*L,t[i+11]=u*A+f*P+d*O+p*w,t[i+12]=m*y+g*T+_*S+v*D,t[i+13]=m*x+g*E+_*C+v*I,t[i+14]=m*b+g*M+_*R+v*L,t[i+15]=m*A+g*P+_*O+v*w,this},i.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]},i.prototype.clone=function(){return i.FromValues(this.m[0],this.m[1],this.m[2],this.m[3],this.m[4],this.m[5],this.m[6],this.m[7],this.m[8],this.m[9],this.m[10],this.m[11],this.m[12],this.m[13],this.m[14],this.m[15])},i.prototype.getClassName=function(){return"Matrix"},i.prototype.getHashCode=function(){for(var e=this.m[0]||0,t=1;t<16;t++)e=397*e^(this.m[t]||0);return e},i.prototype.decompose=function(e,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;return e.x=o*Math.sqrt(this.m[0]*this.m[0]+this.m[1]*this.m[1]+this.m[2]*this.m[2]),e.y=s*Math.sqrt(this.m[4]*this.m[4]+this.m[5]*this.m[5]+this.m[6]*this.m[6]),e.z=a*Math.sqrt(this.m[8]*this.m[8]+this.m[9]*this.m[9]+this.m[10]*this.m[10]),0===e.x||0===e.y||0===e.z?(r.x=0,r.y=0,r.z=0,r.w=1,!1):(i.FromValuesToRef(this.m[0]/e.x,this.m[1]/e.x,this.m[2]/e.x,0,this.m[4]/e.y,this.m[5]/e.y,this.m[6]/e.y,0,this.m[8]/e.z,this.m[9]/e.z,this.m[10]/e.z,0,0,0,0,1,P.Matrix[0]),h.FromRotationMatrixToRef(P.Matrix[0],r),!0)},i.prototype.getRotationMatrix=function(){var e=i.Identity();return this.getRotationMatrixToRef(e),e},i.prototype.getRotationMatrixToRef=function(e){var t=this.m,r=t[0]*t[1]*t[2]*t[3]<0?-1:1,n=t[4]*t[5]*t[6]*t[7]<0?-1:1,o=t[8]*t[9]*t[10]*t[11]<0?-1:1,s=r*Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]),a=n*Math.sqrt(t[4]*t[4]+t[5]*t[5]+t[6]*t[6]),h=o*Math.sqrt(t[8]*t[8]+t[9]*t[9]+t[10]*t[10]);i.FromValuesToRef(t[0]/s,t[1]/s,t[2]/s,0,t[4]/a,t[5]/a,t[6]/a,0,t[8]/h,t[9]/h,t[10]/h,0,0,0,0,1,e)},i.FromArray=function(e,t){var r=new i;return t||(t=0),i.FromArrayToRef(e,t,r),r},i.FromArrayToRef=function(e,t,i){for(var r=0;r<16;r++)i.m[r]=e[r+t]},i.FromFloat32ArrayToRefScaled=function(e,t,i,r){for(var n=0;n<16;n++)r.m[n]=e[n+t]*i},i.FromValuesToRef=function(e,t,i,r,n,o,s,a,h,c,l,u,f,d,p,m,g){g.m[0]=e,g.m[1]=t,g.m[2]=i,g.m[3]=r,g.m[4]=n,g.m[5]=o,g.m[6]=s,g.m[7]=a,g.m[8]=h,g.m[9]=c,g.m[10]=l,g.m[11]=u,g.m[12]=f,g.m[13]=d,g.m[14]=p,g.m[15]=m},i.prototype.getRow=function(e){if(e<0||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])},i.prototype.setRow=function(e,t){if(e<0||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},i.FromValues=function(e,t,r,n,o,s,a,h,c,l,u,f,d,p,m,g){var _=new i;return _.m[0]=e,_.m[1]=t,_.m[2]=r,_.m[3]=n,_.m[4]=o,_.m[5]=s,_.m[6]=a,_.m[7]=h,_.m[8]=c,_.m[9]=l,_.m[10]=u,_.m[11]=f,_.m[12]=d,_.m[13]=p,_.m[14]=m,_.m[15]=g,_},i.Compose=function(e,t,r){var n=i.FromValues(e.x,0,0,0,0,e.y,0,0,0,0,e.z,0,0,0,0,1),o=i.Identity();return t.toRotationMatrix(o),n=n.multiply(o),n.setTranslation(r),n},i.Identity=function(){return i.FromValues(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1)},i.IdentityToRef=function(e){i.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,e)},i.Zero=function(){return i.FromValues(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)},i.RotationX=function(e){var t=new i;return i.RotationXToRef(e,t),t},i.Invert=function(e){var t=new i;return e.invertToRef(t),t},i.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},i.RotationY=function(e){var t=new i;return i.RotationYToRef(e,t),t},i.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},i.RotationZ=function(e){var t=new i;return i.RotationZToRef(e,t),t},i.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},i.RotationAxis=function(e,t){var r=i.Zero();return i.RotationAxisToRef(e,t,r),r},i.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},i.RotationYawPitchRoll=function(e,t,r){var n=new i;return i.RotationYawPitchRollToRef(e,t,r,n),n},i.RotationYawPitchRollToRef=function(e,t,i,r){h.RotationYawPitchRollToRef(e,t,i,this._tempQuaternion),this._tempQuaternion.toRotationMatrix(r)},i.Scaling=function(e,t,r){var n=i.Zero();return i.ScalingToRef(e,t,r,n),n},i.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},i.Translation=function(e,t,r){var n=i.Identity();return i.TranslationToRef(e,t,r,n),n},i.TranslationToRef=function(e,t,r,n){i.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,e,t,r,1,n)},i.Lerp=function(e,t,r){for(var n=i.Zero(),o=0;o<16;o++)n.m[o]=e.m[o]*(1-r)+t.m[o]*r;return n},i.DecomposeLerp=function(e,t,r){var n=new o(0,0,0),s=new h,a=new o(0,0,0);e.decompose(n,s,a);var c=new o(0,0,0),l=new h,u=new o(0,0,0);t.decompose(c,l,u);var f=o.Lerp(n,c,r),d=h.Slerp(s,l,r),p=o.Lerp(a,u,r);return i.Compose(f,d,p)},i.LookAtLH=function(e,t,r){var n=i.Zero();return i.LookAtLHToRef(e,t,r,n),n},i.LookAtLHToRef=function(e,t,r,n){t.subtractToRef(e,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,e),a=-o.Dot(this._yAxis,e),h=-o.Dot(this._zAxis,e);return i.FromValuesToRef(this._xAxis.x,this._yAxis.x,this._zAxis.x,0,this._xAxis.y,this._yAxis.y,this._zAxis.y,0,this._xAxis.z,this._yAxis.z,this._zAxis.z,0,s,a,h,1,n)},i.LookAtRH=function(e,t,r){var n=i.Zero();return i.LookAtRHToRef(e,t,r,n),n},i.LookAtRHToRef=function(e,t,r,n){e.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,e),a=-o.Dot(this._yAxis,e),h=-o.Dot(this._zAxis,e);return i.FromValuesToRef(this._xAxis.x,this._yAxis.x,this._zAxis.x,0,this._xAxis.y,this._yAxis.y,this._zAxis.y,0,this._xAxis.z,this._yAxis.z,this._zAxis.z,0,s,a,h,1,n)},i.OrthoLH=function(e,t,r,n){var o=i.Zero();return i.OrthoLHToRef(e,t,r,n,o),o},i.OrthoLHToRef=function(t,i,r,n,o){var s=r,a=n,h=2/t,c=2/i,l=2/(a-s),u=-(a+s)/(a-s);e.Matrix.FromValuesToRef(h,0,0,0,0,c,0,0,0,0,l,0,0,0,u,1,o)},i.OrthoOffCenterLH=function(e,t,r,n,o,s){var a=i.Zero();return i.OrthoOffCenterLHToRef(e,t,r,n,o,s,a),a},i.OrthoOffCenterLHToRef=function(t,i,r,n,o,s,a){var h=o,c=s,l=2/(i-t),u=2/(n-r),f=2/(c-h),d=-(c+h)/(c-h),p=(t+i)/(t-i),m=(n+r)/(r-n);e.Matrix.FromValuesToRef(l,0,0,0,0,u,0,0,0,0,f,0,p,m,d,1,a)},i.OrthoOffCenterRH=function(e,t,r,n,o,s){var a=i.Zero();return i.OrthoOffCenterRHToRef(e,t,r,n,o,s,a),a},i.OrthoOffCenterRHToRef=function(e,t,r,n,o,s,a){i.OrthoOffCenterLHToRef(e,t,r,n,o,s,a),a.m[10]*=-1},i.PerspectiveLH=function(t,r,n,o){var s=i.Zero(),a=n,h=o,c=2*a/t,l=2*a/r,u=(h+a)/(h-a),f=-2*h*a/(h-a);return e.Matrix.FromValuesToRef(c,0,0,0,0,l,0,0,0,0,u,1,0,0,f,0,s),s},i.PerspectiveFovLH=function(e,t,r,n){var o=i.Zero();return i.PerspectiveFovLHToRef(e,t,r,n,o),o},i.PerspectiveFovLHToRef=function(t,i,r,n,o,s){void 0===s&&(s=!0);var a=r,h=n,c=1/Math.tan(.5*t),l=s?c/i:c,u=s?c:c*i,f=(h+a)/(h-a),d=-2*h*a/(h-a);e.Matrix.FromValuesToRef(l,0,0,0,0,u,0,0,0,0,f,1,0,0,d,0,o)},i.PerspectiveFovRH=function(e,t,r,n){var o=i.Zero();return i.PerspectiveFovRHToRef(e,t,r,n,o),o},i.PerspectiveFovRHToRef=function(t,i,r,n,o,s){void 0===s&&(s=!0);var a=r,h=n,c=1/Math.tan(.5*t),l=s?c/i:c,u=s?c:c*i,f=-(h+a)/(h-a),d=-2*h*a/(h-a);e.Matrix.FromValuesToRef(l,0,0,0,0,u,0,0,0,0,f,-1,0,0,d,0,o)},i.PerspectiveFovWebVRToRef=function(e,t,i,r,n){void 0===n&&(n=!0);var o=Math.tan(e.upDegrees*Math.PI/180),s=Math.tan(e.downDegrees*Math.PI/180),a=Math.tan(e.leftDegrees*Math.PI/180),h=Math.tan(e.rightDegrees*Math.PI/180),c=2/(a+h),l=2/(o+s);r.m[0]=c,r.m[1]=r.m[2]=r.m[3]=r.m[4]=0,r.m[5]=l,r.m[6]=r.m[7]=0,r.m[8]=(a-h)*c*.5,r.m[9]=-((o-s)*l*.5),r.m[10]=-(t+i)/(i-t),r.m[11]=1,r.m[12]=r.m[13]=r.m[15]=0,r.m[14]=-(2*i*t)/(i-t)},i.GetFinalMatrix=function(e,t,r,n,o,s){var a=e.width,h=e.height,c=e.x,l=e.y,u=i.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 t.multiply(r).multiply(n).multiply(u)},i.GetAsMatrix2x2=function(e){return new Float32Array([e.m[0],e.m[1],e.m[4],e.m[5]])},i.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]])},i.Transpose=function(e){var t=new i;return t.m[0]=e.m[0],t.m[1]=e.m[4],t.m[2]=e.m[8],t.m[3]=e.m[12],t.m[4]=e.m[1],t.m[5]=e.m[5],t.m[6]=e.m[9],t.m[7]=e.m[13],t.m[8]=e.m[2],t.m[9]=e.m[6],t.m[10]=e.m[10],t.m[11]=e.m[14],t.m[12]=e.m[3],t.m[13]=e.m[7],t.m[14]=e.m[11],t.m[15]=e.m[15],t},i.Reflection=function(e){var t=new i;return i.ReflectionToRef(e,t),t},i.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},i.FromXYZAxesToRef=function(e,t,i,r){r.m[0]=e.x,r.m[1]=e.y,r.m[2]=e.z,r.m[3]=0,r.m[4]=t.x,r.m[5]=t.y,r.m[6]=t.z,r.m[7]=0,r.m[8]=i.x,r.m[9]=i.y,r.m[10]=i.z,r.m[11]=0,r.m[12]=0,r.m[13]=0,r.m[14]=0,r.m[15]=1},i.FromQuaternionToRef=function(e,t){var i=e.x*e.x,r=e.y*e.y,n=e.z*e.z,o=e.x*e.y,s=e.z*e.w,a=e.z*e.x,h=e.y*e.w,c=e.y*e.z,l=e.x*e.w;t.m[0]=1-2*(r+n),t.m[1]=2*(o+s),t.m[2]=2*(a-h),t.m[3]=0,t.m[4]=2*(o-s),t.m[5]=1-2*(n+i),t.m[6]=2*(c+l),t.m[7]=0,t.m[8]=2*(a+h),t.m[9]=2*(c-l),t.m[10]=1-2*(r+i),t.m[11]=0,t.m[12]=0,t.m[13]=0,t.m[14]=0,t.m[15]=1},i})();c._tempQuaternion=new h,c._xAxis=o.Zero(),c._yAxis=o.Zero(),c._zAxis=o.Zero(),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 i<=t},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;r<6;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;var d;!(function(e){e[e.LOCAL=0]="LOCAL",e[e.WORLD=1]="WORLD"})(d=e.Space||(e.Space={}));var p=(function(){function e(){}return e})();p.X=new o(1,0,0),p.Y=new o(0,1,0),p.Z=new o(0,0,1),e.Axis=p;var m=(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;c<5;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=m;var g;!(function(e){e[e.CW=0]="CW",e[e.CCW=1]="CCW"})(g=e.Orientation||(e.Orientation={}));var _=(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=_;var v=(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=_.BetweenTwoPoints(this.centerPoint,this.startPoint);var h=this.startAngle.degrees(),c=_.BetweenTwoPoints(this.centerPoint,this.midPoint).degrees(),l=_.BetweenTwoPoints(this.centerPoint,this.endPoint).degrees();c-h>180&&(c-=360),c-h<-180&&(c+=360),l-c>180&&(l-=360),l-c<-180&&(l+=360),this.orientation=c-h<0?g.CW:g.CCW,this.angle=_.FromDegrees(this.orientation===g.CW?h-l:l-h)}return e})();e.Arc2=v;var y=(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 v(s,a,h),l=c.angle.radians()/o;c.orientation===g.CW&&(l*=-1);for(var u=c.startAngle.radians()+l,f=0;f1)return n.Zero();for(var t=e*this.length(),i=0,r=0;r=i&&t<=c){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=y;var x=(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;rt+1;)t++,i=this._curve[e].subtract(this._curve[e-t]);return i},i.prototype._normalVector=function(i,r,n){var s,a=r.length();if(0===a&&(a=1),void 0===n||null===n){var h;t.WithinEpsilon(Math.abs(r.y)/a,1,e.Epsilon)?t.WithinEpsilon(Math.abs(r.x)/a,1,e.Epsilon)?t.WithinEpsilon(Math.abs(r.z)/a,1,e.Epsilon)||(h=new o(0,0,1)):h=new o(1,0,0):h=new o(0,(-1),0),s=o.Cross(r,h)}else s=o.Cross(r,n),o.CrossToRef(s,r,s);return s.normalize(),s},i})();e.Path3D=x;var b=(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;h<=n;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;c<=s;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;c<=s;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;o0},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&&(n.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){e!==-1?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=t.indexOf(".babylon")!==-1?"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=t.indexOf(".babylon")!==-1?"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&&(o.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})();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 e.indexOf("http:/")===-1?t.parseURL(window.location.href)+e:e},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++],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);n>t._ORIGIN_SHIFT){default:case t._ORIGIN_UL:y=0,b=1,E=o.width,x=0,A=1,T=o.height;break;case t._ORIGIN_BL:y=0,b=1,E=o.width,x=o.height-1,A=-1,T=-1;break;case t._ORIGIN_UR:y=o.width-1,b=-1,E=-1,x=0,A=1,T=o.height;break;case t._ORIGIN_BR:y=o.width-1,b=-1,E=-1,x=o.height-1,A=-1,T=-1}var M="_getImageData"+(c?"Grey":"")+o.pixel_size+"bits",P=t[M](o,u,l,x,A,T,y,b,E);i.texImage2D(i.TEXTURE_2D,0,i.RGBA,o.width,o.height,0,i.RGBA,i.UNSIGNED_BYTE,P)},t._getImageData8bits=function(e,t,i,r,n,o,s,a,h){var c,l,u,f=i,d=t,p=e.width,m=e.height,g=0,_=new Uint8Array(p*m*4);for(u=r;u!==o;u+=n)for(l=s;l!==h;l+=a,g++)c=f[g],_[4*(l+p*u)+3]=255,_[4*(l+p*u)+2]=d[3*c+0],_[4*(l+p*u)+1]=d[3*c+1],_[4*(l+p*u)+0]=d[3*c+2];return _},t._getImageData16bits=function(e,t,i,r,n,o,s,a,h){var c,l,u,f=i,d=e.width,p=e.height,m=0,g=new Uint8Array(d*p*4);for(u=r;u!==o;u+=n)for(l=s;l!==h;l+=a,m+=2)c=f[m+0]+(f[m+1]<<8),g[4*(l+d*u)+0]=(31744&c)>>7,g[4*(l+d*u)+1]=(992&c)>>2,g[4*(l+d*u)+2]=(31&c)>>3,g[4*(l+d*u)+3]=32768&c?0:255;return g},t._getImageData24bits=function(e,t,i,r,n,o,s,a,h){var c,l,u=i,f=e.width,d=e.height,p=0,m=new Uint8Array(f*d*4);for(l=r;l!==o;l+=n)for(c=s;c!==h;c+=a,p+=3)m[4*(c+f*l)+3]=255,m[4*(c+f*l)+2]=u[p+0],m[4*(c+f*l)+1]=u[p+1],m[4*(c+f*l)+0]=u[p+2];return m},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,m=new Uint8Array(f*d*4);for(l=r;l!==o;l+=n)for(c=s;c!==h;c+=a,p+=4)m[4*(c+f*l)+2]=u[p+0],m[4*(c+f*l)+1]=u[p+1],m[4*(c+f*l)+0]=u[p+2],m[4*(c+f*l)+3]=u[p+3];return m},t._getImageDataGrey8bits=function(e,t,i,r,n,o,s,a,h){var c,l,u,f=i,d=e.width,p=e.height,m=0,g=new Uint8Array(d*p*4);for(u=r;u!==o;u+=n)for(l=s;l!==h;l+=a,m++)c=f[m],g[4*(l+d*u)+0]=c,g[4*(l+d*u)+1]=c,g[4*(l+d*u)+2]=c,g[4*(l+d*u)+3]=255;return g},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,m=new Uint8Array(f*d*4);for(l=r;l!==o;l+=n)for(c=s;c!==h;c+=a,p+=2)m[4*(c+f*l)+0]=u[p+0],m[4*(c+f*l)+1]=u[p+0],m[4*(c+f*l)+2]=u[p+0],m[4*(c+f*l)+3]=u[p+1];return m},t})();i._TYPE_NO_DATA=0,i._TYPE_INDEXED=1,i._TYPE_RGB=2,i._TYPE_GREY=3,i._TYPE_RLE_INDEXED=9,i._TYPE_RLE_RGB=10,i._TYPE_RLE_GREY=11,i._ORIGIN_MASK=48,i._ORIGIN_SHIFT=4,i._ORIGIN_BL=0,i._ORIGIN_BR=1,i._ORIGIN_UL=2,i._ORIGIN_UR=3,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)&&(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;tthis.data.length&&(this.data.length=2*(this.length+e.length));for(var t=0;t=this.length?-1:t},e})();t._GlobalId=0,e.SmartArray=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(){this._count=0,this._data={}}return e.prototype.copyFrom=function(e){var t=this;this.clear(),e.forEach((function(e,i){return t.add(e,i)}))},e.prototype.get=function(e){var t=this._data[e];if(void 0!==t)return t},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]&&(this._data[e]=t,++this._count,!0)},e.prototype.set=function(e,t){return void 0!==this._data[e]&&(this._data[e]=t,!0)},e.prototype.getAndRemove=function(e){var t=this.get(e);return void 0!==t?(delete this._data[e],--this._count,t):null},e.prototype.remove=function(e){return!!this.contains(e)&&(delete this._data[e],--this._count,!0)},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,t){return function(i){i.__bjsclassName__=e,i.__bjsmoduleName__=null!=t?t:null}}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;rt&&(i=t),i},t.GetFilename=function(e){var t=e.lastIndexOf("/");return t<0?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>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;h=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){if(t===!0||void 0!==e&&null!=e)return Array.isArray(e)?e:[e]},t.GetPointerPrefix=function(){var e="pointer";return window.PointerEvent||navigator.pointerEnabled||(e="mouse"),e},t.QueueNewFrame=function(e,t){void 0===t&&(t=window),t.requestAnimationFrame?t.requestAnimationFrame(e):t.msRequestAnimationFrame?t.msRequestAnimationFrame(e):t.webkitRequestAnimationFrame?t.webkitRequestAnimationFrame(e):t.mozRequestAnimationFrame?t.mozRequestAnimationFrame(e):t.oRequestAnimationFrame?t.oRequestAnimationFrame(e):window.setTimeout(e,16)},t.RequestFullscreen=function(e){var t=e.requestFullscreen||e.msRequestFullscreen||e.webkitRequestFullscreen||e.mozRequestFullScreen;t&&t.call(e)},t.ExitFullscreen=function(){document.exitFullscreen?document.exitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitCancelFullScreen?document.webkitCancelFullScreen():document.msCancelFullScreen&&document.msCancelFullScreen()},t.SetCorsBehavior=function(e,i){if(t.CorsBehavior)switch(typeof t.CorsBehavior){case"function":var r=t.CorsBehavior(e);if(r)return r;break;case"string":default:i.crossOrigin=t.CorsBehavior}},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;"data:"!==i.substr(0,5)&&t.SetCorsBehavior(i,s),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 a=function(){s.src=i},h=function(){o.loadImageFromDB(i,s)};if("data:"!==i.substr(0,5)&&o&&o.enableTexturesOffline&&e.Database.IsUASupportingBlobStorage)o.openAsync(h,a);else if(i.indexOf("file:")===-1)a();else try{var c,l=i.substring(5).toLowerCase();try{c=URL.createObjectURL(e.FilesInput.FilesTextures[l],{oneTimeOnly:!0})}catch(u){c=URL.createObjectURL(e.FilesInput.FilesTextures[l])}s.src=c}catch(f){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(e.onreadystatechange=null,e.status>=200&&e.status<300||navigator.isCocoonJS&&0===e.status)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(i.indexOf("file:")!==-1){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.LoadScript=function(e,t,i){var r=document.getElementsByTagName("head")[0],n=document.createElement("script");n.type="text/javascript",n.src=e;n.onload=function(){t&&t()},n.onerror=function(){i&&i()},r.appendChild(n)},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.xi.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&&n.indexOf(o)!==-1)&&(!i||i.indexOf(o)===-1)){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;hh&&(f=h,u=f*l);var d=Math.max(0,a-u)/2,p=Math.max(0,h-f)/2;c.fillStyle=r.getScene().clearColor.toHexString(),c.fillRect(0,0,a,h),c.drawImage(e.getRenderingCanvas(),d,p,u,f),t.EncodeScreenshotCanvasData(o,s)},t.CreateScreenshotUsingRenderTarget=function(i,r,n,o,s){void 0===s&&(s="image/png");var a,h;if(n.precision)a=Math.round(i.getRenderWidth()*n.precision),h=Math.round(a/i.getAspectRatio(r)),n={width:a,height:h};else if(n.width&&n.height)a=n.width,h=n.height;else if(n.width&&!n.height)a=n.width,h=Math.round(a/i.getAspectRatio(r)),n={width:a,height:h};else if(n.height&&!n.width)h=n.height,a=Math.round(h*i.getAspectRatio(r)),n={width:a,height:h};else{if(isNaN(n))return void t.Error("Invalid 'size' parameter !");h=n,a=n}var c=r.getScene(),l=null;c.activeCamera!==r&&(l=c.activeCamera,c.activeCamera=r);var u=new e.RenderTargetTexture("screenShot",n,c,(!1),(!1),e.Engine.TEXTURETYPE_UNSIGNED_INT,(!1),e.Texture.NEAREST_SAMPLINGMODE);u.renderList=c.meshes,u.onAfterRenderObservable.add((function(){t.DumpFramebuffer(a,h,i,o,s)})),c.incrementRenderId(),c.resetCachedMaterial(),u.render(!0),u.dispose(),l&&(c.activeCamera=l),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},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)}))},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 e<10?"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="
"+i+"

";t._AddLogEntry(r)},t._WarnDisabled=function(e){},t._WarnEnabled=function(e){var i=t._FormatMessage(e);console.warn("BJS - "+i);var r="
"+i+"

";t._AddLogEntry(r)},t._ErrorDisabled=function(e){},t._ErrorEnabled=function(e){t.errorsCount++;var i=t._FormatMessage(e);console.error("BJS - "+i);var r="
"+i+"

";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,r=e;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})();n.BaseUrl="",n.CorsBehavior="anonymous",n.UseFallbackTexture=!0,n._NoneLogLevel=0,n._MessageLogLevel=1,n._WarningLogLevel=2,n._ErrorLogLevel=4,n._LogCache="",n.errorsCount=0,n.Log=n._LogEnabled,n.Warn=n._WarnEnabled,n.Error=n._ErrorEnabled,n._PerformanceNoneLogLevel=0,n._PerformanceUserMarkLogLevel=1,n._PerformanceConsoleLogLevel=2,n._performance=window.performance,n.StartPerformanceCounter=n._StartPerformanceCounterDisabled,n.EndPerformanceCounter=n._EndPerformanceCounterDisabled,e.Tools=n;var o=(function(){function e(){this._startMonitoringTime=0,this._min=0,this._max=0,this._average=0,this._lastSecAverage=0,this._current=0,this._totalValueCount=0,this._totalAccumulated=0,this._lastSecAccumulated=0,this._lastSecTime=0,this._lastSecValueCount=0}return Object.defineProperty(e.prototype,"min",{get:function(){return this._min},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"max",{get:function(){return this._max},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"average",{get:function(){return this._average},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"lastSecAverage",{get:function(){return this._lastSecAverage},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"current",{get:function(){return this._current},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"total",{get:function(){return this._totalAccumulated},enumerable:!0,configurable:!0}),e.prototype.fetchNewFrame=function(){this._totalValueCount++,this._current=0,this._lastSecValueCount++},e.prototype.addCount=function(e,t){this._current+=e,t&&this._fetchResult()},e.prototype.beginMonitoring=function(){this._startMonitoringTime=n.Now},e.prototype.endMonitoring=function(e){void 0===e&&(e=!0),e&&this.fetchNewFrame();var t=n.Now;this._current=t-this._startMonitoringTime,e&&this._fetchResult()},e.prototype._fetchResult=function(){this._totalAccumulated+=this._current,this._lastSecAccumulated+=this._current,this._min=Math.min(this._min,this._current),this._max=Math.max(this._max,this._current),this._average=this._totalAccumulated/this._totalValueCount;var e=n.Now;e-this._lastSecTime>1e3&&(this._lastSecAverage=this._lastSecAccumulated/this._lastSecValueCount,this._lastSecTime=e,this._lastSecAccumulated=0,this._lastSecValueCount=0)},e})();e.PerfCounter=o,e.className=t;var s=(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=t)break;if(r(s),o&&o()){e.breakLoop();break}}e.executeNext()}),s)}),n)},e})();e.AsyncLoop=s})(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), -this.reset()}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,this.reset()}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(t){var i=(function(){function t(){this._isStencilTestDirty=!1,this._isStencilMaskDirty=!1,this._isStencilFuncDirty=!1,this._isStencilOpDirty=!1,this.reset()}return Object.defineProperty(t.prototype,"isDirty",{get:function(){return this._isStencilTestDirty||this._isStencilMaskDirty||this._isStencilFuncDirty||this._isStencilOpDirty},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stencilFunc",{get:function(){return this._stencilFunc},set:function(e){this._stencilFunc!==e&&(this._stencilFunc=e,this._isStencilFuncDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stencilFuncRef",{get:function(){return this._stencilFuncRef},set:function(e){this._stencilFuncRef!==e&&(this._stencilFuncRef=e,this._isStencilFuncDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stencilFuncMask",{get:function(){return this._stencilFuncMask},set:function(e){this._stencilFuncMask!==e&&(this._stencilFuncMask=e,this._isStencilFuncDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stencilOpStencilFail",{get:function(){return this._stencilOpStencilFail},set:function(e){this._stencilOpStencilFail!==e&&(this._stencilOpStencilFail=e,this._isStencilOpDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stencilOpDepthFail",{get:function(){return this._stencilOpDepthFail},set:function(e){this._stencilOpDepthFail!==e&&(this._stencilOpDepthFail=e,this._isStencilOpDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stencilOpStencilDepthPass",{get:function(){return this._stencilOpStencilDepthPass},set:function(e){this._stencilOpStencilDepthPass!==e&&(this._stencilOpStencilDepthPass=e,this._isStencilOpDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stencilMask",{get:function(){return this._stencilMask},set:function(e){this._stencilMask!==e&&(this._stencilMask=e,this._isStencilMaskDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stencilTest",{get:function(){return this._stencilTest},set:function(e){this._stencilTest!==e&&(this._stencilTest=e,this._isStencilTestDirty=!0)},enumerable:!0,configurable:!0}),t.prototype.reset=function(){this._stencilTest=!1,this._stencilMask=255,this._stencilFunc=e.Engine.ALWAYS,this._stencilFuncRef=1,this._stencilFuncMask=255,this._stencilOpStencilFail=e.Engine.KEEP,this._stencilOpDepthFail=e.Engine.KEEP,this._stencilOpStencilDepthPass=e.Engine.REPLACE,this._isStencilTestDirty=!0,this._isStencilMaskDirty=!0,this._isStencilFuncDirty=!0,this._isStencilOpDirty=!0},t.prototype.apply=function(e){this.isDirty&&(this._isStencilTestDirty&&(this.stencilTest?e.enable(e.STENCIL_TEST):e.disable(e.STENCIL_TEST),this._isStencilTestDirty=!1),this._isStencilMaskDirty&&(e.stencilMask(this.stencilMask),this._isStencilMaskDirty=!1),this._isStencilFuncDirty&&(e.stencilFunc(this.stencilFunc,this.stencilFuncRef,this.stencilFuncMask),this._isStencilFuncDirty=!1),this._isStencilOpDirty&&(e.stencilOp(this.stencilOpStencilFail,this.stencilOpDepthFail,this.stencilOpStencilDepthPass),this._isStencilOpDirty=!1))},t})();t._StencilState=i})(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=36193,r=function(e,t){return t===l.TEXTURETYPE_FLOAT?e.FLOAT:t===l.TEXTURETYPE_HALF_FLOAT?i:e.UNSIGNED_BYTE},n=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}},o=function(t,i,r,o,s,a,h,c,l,u){void 0===u&&(u=e.Texture.TRILINEAR_SAMPLINGMODE);var f=r.getEngine(),d=e.Tools.GetExponentOfTwo(o,f.getCaps().maxTextureSize),p=e.Tools.GetExponentOfTwo(s,f.getCaps().maxTextureSize);f._bindTextureDirectly(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=d,t._height=p,t.isReady=!0,l(d,p);var m=n(u,!h,i);i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,m.mag),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,m.min),h||c||i.generateMipmap(i.TEXTURE_2D),f._bindTextureDirectly(i.TEXTURE_2D,null),f.resetTextureCache(),r._removePendingData(t),t.onLoadedCallbacks.forEach((function(e){e()})),t.onLoadedCallbacks=[]},s=function(t,i,r,n,o,s){void 0===s&&(s=null);var a,h=function(){r[i]=a,r._internalCount++,n._removePendingData(a),6===r._internalCount&&o(r)},c=function(){n._removePendingData(a),s&&s()};a=e.Tools.LoadImage(t,h,c,n.database),n._addPendingData(a)},a=function(e,t,i,r,n){void 0===n&&(n=null);var o=[];o._internalCount=0;for(var a=0;a<6;a++)s(r[a],a,o,t,i,n)},h=(function(){function e(){}return e})();e.InstancingAttributeInfo=h;var c=(function(){function e(){}return e})();e.EngineCapabilities=c;var l=(function(){function s(t,i,r,n){void 0===n&&(n=!1);var o=this;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._badOS=!1,this._drawCalls=new e.PerfCounter,this._renderingQueueLaunched=!1,this._activeRenderLoops=[],this.fpsRange=60,this.previousFramesDuration=[],this.fps=60,this.deltaTime=0,this._depthCullingState=new e.Internals._DepthCullingState,this._stencilState=new e.Internals._StencilState,this._alphaState=new e.Internals._AlphaState,this._alphaMode=s.ALPHA_DISABLE,this._loadedTexturesCache=new Array,this._maxTextureChannels=16,this._activeTexturesCache=new Array(this._maxTextureChannels),this._compiledEffects={},this._vertexAttribArraysEnabled=[],this._uintIndicesCurrentlySet=!1,this._currentBoundBuffer=new Array,this._currentBufferPointers=[],this._currentInstanceLocations=new Array,this._currentInstanceBuffers=new Array,this._texturesSupported=new Array,this._onVRFullScreenTriggered=function(){if(o._vrDisplayEnabled&&o._vrDisplayEnabled.isPresenting){o._oldSize=new e.Size(o.getRenderWidth(),o.getRenderHeight()),o._oldHardwareScaleFactor=o.getHardwareScalingLevel();var t=o._vrDisplayEnabled.getEyeParameters("left");o.setHardwareScalingLevel(1),o.setSize(2*t.renderWidth,t.renderHeight)}else o.setHardwareScalingLevel(o._oldHardwareScaleFactor),o.setSize(o._oldSize.width,o._oldSize.height),o._vrDisplayEnabled=void 0},this._renderingCanvas=t,this._externalData=new e.StringDictionary,r=r||{},null!=i&&(r.antialias=i),void 0===r.preserveDrawingBuffer&&(r.preserveDrawingBuffer=!1);var a=this._canRenderToFloatTexture(),h=this._canRenderToHalfFloatTexture();try{this._gl=t.getContext("webgl2",r)||t.getContext("experimental-webgl2",r),this._gl&&(this._webGLVersion="2.0")}catch(l){}if(!this._gl){if(!t)throw new Error("The provided canvas is null or undefined.");try{this._gl=t.getContext("webgl",r)||t.getContext("experimental-webgl",r)}catch(l){throw new Error("WebGL not supported")}}if(!this._gl)throw new Error("WebGL not supported");this._onBlur=function(){o._windowIsBackground=!0},this._onFocus=function(){o._windowIsBackground=!1},window.addEventListener("blur",this._onBlur),window.addEventListener("focus",this._onFocus);var u=r.limitDeviceRatio||window.devicePixelRatio||1;this._hardwareScalingLevel=n?1/Math.min(u,window.devicePixelRatio||1):1,this.resize(),this._isStencilEnable=r.stencil,this._caps=new c,this._caps.maxTexturesImageUnits=this._gl.getParameter(this._gl.MAX_TEXTURE_IMAGE_UNITS),this._caps.maxTextureSize=this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE),this._caps.maxCubemapTextureSize=this._gl.getParameter(this._gl.MAX_CUBE_MAP_TEXTURE_SIZE),this._caps.maxRenderTextureSize=this._gl.getParameter(this._gl.MAX_RENDERBUFFER_SIZE),this._caps.maxVertexAttribs=this._gl.getParameter(this._gl.MAX_VERTEX_ATTRIBS),this._caps.maxVaryingVectors=this._gl.getParameter(this._gl.MAX_VARYING_VECTORS),this._caps.maxFragmentUniformVectors=this._gl.getParameter(this._gl.MAX_FRAGMENT_UNIFORM_VECTORS),this._caps.maxVertexUniformVectors=this._gl.getParameter(this._gl.MAX_VERTEX_UNIFORM_VECTORS),this._glVersion=this._gl.getParameter(this._gl.VERSION);var f=this._gl.getExtension("WEBGL_debug_renderer_info");if(null!=f&&(this._glRenderer=this._gl.getParameter(f.UNMASKED_RENDERER_WEBGL),this._glVendor=this._gl.getParameter(f.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.astc=this._gl.getExtension("WEBGL_compressed_texture_astc"),this._caps.s3tc=this._gl.getExtension("WEBGL_compressed_texture_s3tc"),this._caps.pvrtc=this._gl.getExtension("WEBGL_compressed_texture_pvrtc")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),this._caps.etc1=this._gl.getExtension("WEBGL_compressed_texture_etc1"),this._caps.etc2=this._gl.getExtension("WEBGL_compressed_texture_etc")||this._gl.getExtension("WEBGL_compressed_texture_es3_0"),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._caps.textureFloatRender=a,this._caps.textureHalfFloat=null!==this._gl.getExtension("OES_texture_half_float"),this._caps.textureHalfFloatLinearFiltering=this._gl.getExtension("OES_texture_half_float_linear"),this._caps.textureHalfFloatRender=h,this._caps.astc&&this.texturesSupported.push(".astc"),this._caps.s3tc&&this.texturesSupported.push(".dds"),this._caps.pvrtc&&this.texturesSupported.push(".pvr"),this._caps.etc2&&this.texturesSupported.push(".etc2"),this._caps.etc1&&this.texturesSupported.push(".etc1"),this._gl.getShaderPrecisionFormat){var d=this._gl.getShaderPrecisionFormat(this._gl.FRAGMENT_SHADER,this._gl.HIGH_FLOAT);this._caps.highPrecisionShaderSupported=0!==d.precision}this.setDepthBuffer(!0),this.setDepthFunctionToLessOrEqual(),this.setDepthWrite(!0),this._onFullscreenChange=function(){void 0!==document.fullscreen?o.isFullscreen=document.fullscreen:void 0!==document.mozFullScreen?o.isFullscreen=document.mozFullScreen:void 0!==document.webkitIsFullScreen?o.isFullscreen=document.webkitIsFullScreen:void 0!==document.msIsFullScreen&&(o.isFullscreen=document.msIsFullScreen),o.isFullscreen&&o._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(){o.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&&!s.audioEngine&&(s.audioEngine=new e.AudioEngine),this._loadingScreen=new e.DefaultLoadingScreen(this._renderingCanvas),r.autoEnableWebVR&&this.initWebVR();var p=/AppleWebKit.*10.[\d] Mobile/;this._badOS=p.test(navigator.userAgent),e.Tools.Log("Babylon.js engine (v"+s.Version+") launched")}return Object.defineProperty(s,"NEVER",{get:function(){return s._NEVER},enumerable:!0,configurable:!0}),Object.defineProperty(s,"ALWAYS",{get:function(){return s._ALWAYS},enumerable:!0,configurable:!0}),Object.defineProperty(s,"LESS",{get:function(){return s._LESS},enumerable:!0,configurable:!0}),Object.defineProperty(s,"EQUAL",{get:function(){return s._EQUAL},enumerable:!0,configurable:!0}),Object.defineProperty(s,"LEQUAL",{get:function(){return s._LEQUAL},enumerable:!0,configurable:!0}),Object.defineProperty(s,"GREATER",{get:function(){return s._GREATER},enumerable:!0,configurable:!0}),Object.defineProperty(s,"GEQUAL",{get:function(){return s._GEQUAL},enumerable:!0,configurable:!0}),Object.defineProperty(s,"NOTEQUAL",{get:function(){return s._NOTEQUAL},enumerable:!0,configurable:!0}),Object.defineProperty(s,"KEEP",{get:function(){return s._KEEP},enumerable:!0,configurable:!0}),Object.defineProperty(s,"REPLACE",{get:function(){return s._REPLACE},enumerable:!0,configurable:!0}),Object.defineProperty(s,"INCR",{get:function(){return s._INCR},enumerable:!0,configurable:!0}),Object.defineProperty(s,"DECR",{get:function(){return s._DECR},enumerable:!0,configurable:!0}),Object.defineProperty(s,"INVERT",{get:function(){return s._INVERT},enumerable:!0,configurable:!0}),Object.defineProperty(s,"INCR_WRAP",{get:function(){return s._INCR_WRAP},enumerable:!0,configurable:!0}),Object.defineProperty(s,"DECR_WRAP",{get:function(){return s._DECR_WRAP},enumerable:!0,configurable:!0}),Object.defineProperty(s,"ALPHA_DISABLE",{get:function(){return s._ALPHA_DISABLE},enumerable:!0,configurable:!0}),Object.defineProperty(s,"ALPHA_ONEONE",{get:function(){return s._ALPHA_ONEONE},enumerable:!0,configurable:!0}),Object.defineProperty(s,"ALPHA_ADD",{get:function(){return s._ALPHA_ADD},enumerable:!0,configurable:!0}),Object.defineProperty(s,"ALPHA_COMBINE",{get:function(){return s._ALPHA_COMBINE},enumerable:!0,configurable:!0}),Object.defineProperty(s,"ALPHA_SUBTRACT",{get:function(){return s._ALPHA_SUBTRACT},enumerable:!0,configurable:!0}),Object.defineProperty(s,"ALPHA_MULTIPLY",{get:function(){return s._ALPHA_MULTIPLY},enumerable:!0,configurable:!0}),Object.defineProperty(s,"ALPHA_MAXIMIZED",{get:function(){return s._ALPHA_MAXIMIZED},enumerable:!0,configurable:!0}),Object.defineProperty(s,"ALPHA_PREMULTIPLIED",{get:function(){return s._ALPHA_PREMULTIPLIED},enumerable:!0,configurable:!0}),Object.defineProperty(s,"DELAYLOADSTATE_NONE",{get:function(){return s._DELAYLOADSTATE_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(s,"DELAYLOADSTATE_LOADED",{get:function(){return s._DELAYLOADSTATE_LOADED},enumerable:!0,configurable:!0}),Object.defineProperty(s,"DELAYLOADSTATE_LOADING",{get:function(){return s._DELAYLOADSTATE_LOADING},enumerable:!0,configurable:!0}),Object.defineProperty(s,"DELAYLOADSTATE_NOTLOADED",{get:function(){return s._DELAYLOADSTATE_NOTLOADED},enumerable:!0,configurable:!0}),Object.defineProperty(s,"TEXTUREFORMAT_ALPHA",{get:function(){return s._TEXTUREFORMAT_ALPHA},enumerable:!0,configurable:!0}),Object.defineProperty(s,"TEXTUREFORMAT_LUMINANCE",{get:function(){return s._TEXTUREFORMAT_LUMINANCE},enumerable:!0,configurable:!0}),Object.defineProperty(s,"TEXTUREFORMAT_LUMINANCE_ALPHA",{get:function(){return s._TEXTUREFORMAT_LUMINANCE_ALPHA},enumerable:!0,configurable:!0}),Object.defineProperty(s,"TEXTUREFORMAT_RGB",{get:function(){return s._TEXTUREFORMAT_RGB},enumerable:!0,configurable:!0}),Object.defineProperty(s,"TEXTUREFORMAT_RGBA",{get:function(){return s._TEXTUREFORMAT_RGBA},enumerable:!0,configurable:!0}),Object.defineProperty(s,"TEXTURETYPE_UNSIGNED_INT",{get:function(){return s._TEXTURETYPE_UNSIGNED_INT},enumerable:!0,configurable:!0}),Object.defineProperty(s,"TEXTURETYPE_FLOAT",{get:function(){return s._TEXTURETYPE_FLOAT},enumerable:!0,configurable:!0}),Object.defineProperty(s,"TEXTURETYPE_HALF_FLOAT",{get:function(){return s._TEXTURETYPE_HALF_FLOAT},enumerable:!0,configurable:!0}),Object.defineProperty(s,"Version",{get:function(){return"2.6-alpha"},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"texturesSupported",{get:function(){return this._texturesSupported},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"textureFormatInUse",{get:function(){return this._textureFormatInUse},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"webGLVersion",{get:function(){return this._webGLVersion},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"isStencilEnable",{get:function(){return this._isStencilEnable},enumerable:!0,configurable:!0}),s.prototype._prepareWorkingCanvas=function(){this._workingCanvas||(this._workingCanvas=document.createElement("canvas"),this._workingContext=this._workingCanvas.getContext("2d"))},s.prototype.resetTextureCache=function(){for(var e=0;e=0&&this._activeRenderLoops.splice(t,1)},s.prototype._renderLoop=function(){var t=!0;if(!this.renderEvenInBackground&&this._windowIsBackground&&(t=!1),t){this.beginFrame();for(var i=0;i0?e.Tools.QueueNewFrame(this._bindedRenderFunction,this._vrDisplayEnabled):this._renderingQueueLaunched=!1},s.prototype.runRenderLoop=function(t){this._activeRenderLoops.indexOf(t)===-1&&(this._activeRenderLoops.push(t),this._renderingQueueLaunched||(this._renderingQueueLaunched=!0,this._bindedRenderFunction=this._renderLoop.bind(this),e.Tools.QueueNewFrame(this._bindedRenderFunction)))},s.prototype.switchFullscreen=function(t){this.isFullscreen?e.Tools.ExitFullscreen():(this._pointerLockRequested=t,e.Tools.RequestFullscreen(this._renderingCanvas))},s.prototype.clear=function(e,t,i,r){void 0===r&&(r=!1),this.applyStates();var n=0;t&&e&&(this._gl.clearColor(e.r,e.g,e.b,e.a),n|=this._gl.COLOR_BUFFER_BIT),i&&(this._gl.clearDepth(1),n|=this._gl.DEPTH_BUFFER_BIT),r&&(this._gl.clearStencil(0),n|=this._gl.STENCIL_BUFFER_BIT),this._gl.clear(n)},s.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,!0),o.scissor(a[0],a[1],a[2],a[3]),s===!0?o.enable(o.SCISSOR_TEST):o.disable(o.SCISSOR_TEST)},s.prototype.setViewport=function(e,t,i){var r=t||(navigator.isCocoonJS?window.innerWidth:this.getRenderWidth()),n=i||(navigator.isCocoonJS?window.innerHeight:this.getRenderHeight()),o=e.x||0,s=e.y||0;this._cachedViewport=e,this._gl.viewport(o*r,s*n,r*e.width,n*e.height)},s.prototype.setDirectViewport=function(e,t,i,r){var n=this._cachedViewport;return this._cachedViewport=null,this._gl.viewport(e,t,i,r),n},s.prototype.beginFrame=function(){this._measureFps()},s.prototype.endFrame=function(){this._badOS&&this.flushFramebuffer(),this._vrDisplayEnabled&&this._vrDisplayEnabled.isPresenting&&this._vrDisplayEnabled.submitFrame()},s.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)},s.prototype.setSize=function(e,t){this._renderingCanvas.width=e,this._renderingCanvas.height=t;for(var i=0;i65535){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},s.prototype.bindArrayBuffer=function(e){this.bindBuffer(e,this._gl.ARRAY_BUFFER)},s.prototype.bindIndexBuffer=function(e){this.bindBuffer(e,this._gl.ELEMENT_ARRAY_BUFFER)},s.prototype.bindBuffer=function(e,t){this._currentBoundBuffer[t]!==e&&(this._gl.bindBuffer(t,e),this._currentBoundBuffer[t]=e)},s.prototype.updateArrayBuffer=function(e){this._gl.bufferSubData(this._gl.ARRAY_BUFFER,0,e)},s.prototype.vertexAttribPointer=function(e,t,i,r,n,o,s){var a=this._currentBufferPointers[t],h=!1;a?(a.buffer!==e&&(a.buffer=e,h=!0),a.size!==i&&(a.size=i,h=!0),a.type!==r&&(a.type=r,h=!0),a.normalized!==n&&(a.normalized=n,h=!0),a.stride!==o&&(a.stride=o,h=!0),a.offset!==s&&(a.offset=s, -h=!0)):(h=!0,this._currentBufferPointers[t]={indx:t,size:i,type:r,normalized:n,stride:o,offset:s,buffer:e}),h&&(this.bindArrayBuffer(e),this._gl.vertexAttribPointer(t,i,r,n,o,s))},s.prototype.bindBuffersDirectly=function(e,t,i,r,n){if(this._cachedVertexBuffers!==e||this._cachedEffectForVertexBuffers!==n){this._cachedVertexBuffers=e,this._cachedEffectForVertexBuffers=n;var o=n.getAttributesCount();this.unbindAllAttributes();for(var s=0,a=0;a=0&&(this._gl.enableVertexAttribArray(h),this._vertexAttribArraysEnabled[h]=!0,this.vertexAttribPointer(e,h,i[a],this._gl.FLOAT,!1,r,s)),s+=4*i[a]}}this._cachedIndexBuffer!==t&&(this._cachedIndexBuffer=t,this.bindIndexBuffer(t),this._uintIndicesCurrentlySet=t.is32Bits)},s.prototype.bindBuffers=function(e,t,i){if(this._cachedVertexBuffers!==e||this._cachedEffectForVertexBuffers!==i){this._cachedVertexBuffers=e,this._cachedEffectForVertexBuffers=i;var r=i.getAttributesNames();this.unbindAllAttributes();for(var n=0;n=0){var s=e[r[n]];if(!s)continue;this._gl.enableVertexAttribArray(o),this._vertexAttribArraysEnabled[o]=!0;var a=s.getBuffer();this.vertexAttribPointer(a,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.bindIndexBuffer(t),this._uintIndicesCurrentlySet=t.is32Bits)},s.prototype.unbindInstanceAttributes=function(){for(var e,t=0,i=this._currentInstanceLocations.length;t1)&&!i&&a.width>>a.mipmapCount-1===1;o(f,l._gl,n,a.width,a.height,r,!h,a.isFourCC,(function(){e.Internals.DDSTools.UploadDDSLevels(l._gl,l.getCaps().s3tc,t,a,h,1)}),s)},d instanceof Array?v(c):e.Tools.LoadFile(t,(function(e){v(e)}),null,n.database,!0,y);else{var x=function(t){o(f,l._gl,n,t.width,t.height,r,i,!1,(function(i,r){var n=t.width===i&&t.height===r;n||(l._prepareWorkingCanvas(),l._workingCanvas.width=i,l._workingCanvas.height=r,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)}),s)};d instanceof Array?e.Tools.LoadImage(c,x,y,n.database):e.Tools.LoadImage(t,x,y,n.database)}return f},s.prototype._getInternalFormat=function(e){var t=this._gl.RGBA;switch(e){case s.TEXTUREFORMAT_ALPHA:t=this._gl.ALPHA;break;case s.TEXTUREFORMAT_LUMINANCE:t=this._gl.LUMINANCE;break;case s.TEXTUREFORMAT_LUMINANCE_ALPHA:t=this._gl.LUMINANCE_ALPHA;break;case s.TEXTUREFORMAT_RGB:t=this._gl.RGB;break;case s.TEXTUREFORMAT_RGBA:t=this._gl.RGBA}return t},s.prototype.updateRawTexture=function(e,t,i,r,n){void 0===n&&(n=null);var o=this._getInternalFormat(i);this._bindTextureDirectly(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._bindTextureDirectly(this._gl.TEXTURE_2D,null),this.resetTextureCache(),e.isReady=!0},s.prototype.createRawTexture=function(e,t,i,r,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,r,s,h),this._bindTextureDirectly(this._gl.TEXTURE_2D,c);var l=n(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),o&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(this._gl.TEXTURE_2D,null),c.samplingMode=a,this._loadedTexturesCache.push(c),c},s.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},s.prototype.updateTextureSamplingMode=function(e,t){var i=n(e,t.generateMipMaps,this._gl);t.isCube?(this._bindTextureDirectly(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._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null)):(this._bindTextureDirectly(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._bindTextureDirectly(this._gl.TEXTURE_2D,null))},s.prototype.updateDynamicTexture=function(e,t,i,r){void 0===r&&(r=!1),this._bindTextureDirectly(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._bindTextureDirectly(this._gl.TEXTURE_2D,null),r&&this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),this.resetTextureCache(),e.isReady=!0},s.prototype.updateVideoTexture=function(e,t,i){if(!e._isDisabled){this._bindTextureDirectly(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._bindTextureDirectly(this._gl.TEXTURE_2D,null),this.resetTextureCache(),e.isReady=!0}catch(r){e._isDisabled=!0}}},s.prototype.createRenderTargetTexture=function(t,i){var o=!1,a=!0,h=!1,c=s.TEXTURETYPE_UNSIGNED_INT,l=e.Texture.TRILINEAR_SAMPLINGMODE;void 0!==i&&(o=void 0===i.generateMipMaps?i:i.generateMipMaps,a=void 0===i.generateDepthBuffer||i.generateDepthBuffer,h=a&&i.generateStencilBuffer,c=void 0===i.type?c:i.type,void 0!==i.samplingMode&&(l=i.samplingMode),c!==s.TEXTURETYPE_FLOAT||this._caps.textureFloatLinearFiltering?c!==s.TEXTURETYPE_HALF_FLOAT||this._caps.textureHalfFloatLinearFiltering||(l=e.Texture.NEAREST_SAMPLINGMODE):l=e.Texture.NEAREST_SAMPLINGMODE);var u=this._gl,f=u.createTexture();this._bindTextureDirectly(u.TEXTURE_2D,f);var d=t.width||t,p=t.height||t,m=n(l,o,u);c!==s.TEXTURETYPE_FLOAT||this._caps.textureFloat||(c=s.TEXTURETYPE_UNSIGNED_INT,e.Tools.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type")),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_MAG_FILTER,m.mag),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_MIN_FILTER,m.min),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_WRAP_S,u.CLAMP_TO_EDGE),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_WRAP_T,u.CLAMP_TO_EDGE),u.texImage2D(u.TEXTURE_2D,0,u.RGBA,d,p,0,u.RGBA,r(u,c),null);var g;h?(g=u.createRenderbuffer(),u.bindRenderbuffer(u.RENDERBUFFER,g),u.renderbufferStorage(u.RENDERBUFFER,u.DEPTH_STENCIL,d,p)):a&&(g=u.createRenderbuffer(),u.bindRenderbuffer(u.RENDERBUFFER,g),u.renderbufferStorage(u.RENDERBUFFER,u.DEPTH_COMPONENT16,d,p));var _=u.createFramebuffer();return this.bindUnboundFramebuffer(_),h?u.framebufferRenderbuffer(u.FRAMEBUFFER,u.DEPTH_STENCIL_ATTACHMENT,u.RENDERBUFFER,g):a&&u.framebufferRenderbuffer(u.FRAMEBUFFER,u.DEPTH_ATTACHMENT,u.RENDERBUFFER,g),u.framebufferTexture2D(u.FRAMEBUFFER,u.COLOR_ATTACHMENT0,u.TEXTURE_2D,f,0),o&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(u.TEXTURE_2D,null),u.bindRenderbuffer(u.RENDERBUFFER,null),this.bindUnboundFramebuffer(null),f._framebuffer=_,a&&(f._depthBuffer=g),f._baseWidth=d,f._baseHeight=p,f._width=d,f._height=p,f.isReady=!0,f.generateMipMaps=o,f.references=1,f.samplingMode=l,f.type=c,this.resetTextureCache(),this._loadedTexturesCache.push(f),f},s.prototype.createRenderTargetCubeTexture=function(t,i){var r=this._gl,o=r.createTexture(),s=!0,a=!0,h=!1,c=e.Texture.TRILINEAR_SAMPLINGMODE;void 0!==i&&(s=void 0===i.generateMipMaps?i:i.generateMipMaps,a=void 0===i.generateDepthBuffer||i.generateDepthBuffer,h=a&&i.generateStencilBuffer,void 0!==i.samplingMode&&(c=i.samplingMode)),o.isCube=!0,o.references=1,o.generateMipMaps=s,o.references=1,o.samplingMode=c;var l=n(c,s,r);this._bindTextureDirectly(r.TEXTURE_CUBE_MAP,o);for(var u=0;u<6;u++)r.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+u,0,r.RGBA,t,t,0,r.RGBA,r.UNSIGNED_BYTE,null);r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_MAG_FILTER,l.mag),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_MIN_FILTER,l.min),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE);var f;h?(f=r.createRenderbuffer(),r.bindRenderbuffer(r.RENDERBUFFER,f),r.renderbufferStorage(r.RENDERBUFFER,r.DEPTH_STENCIL,t,t)):a&&(f=r.createRenderbuffer(),r.bindRenderbuffer(r.RENDERBUFFER,f),r.renderbufferStorage(r.RENDERBUFFER,r.DEPTH_COMPONENT16,t,t));var d=r.createFramebuffer();return this.bindUnboundFramebuffer(d),h?r.framebufferRenderbuffer(r.FRAMEBUFFER,r.DEPTH_STENCIL_ATTACHMENT,r.RENDERBUFFER,f):a&&r.framebufferRenderbuffer(r.FRAMEBUFFER,r.DEPTH_ATTACHMENT,r.RENDERBUFFER,f),o.generateMipMaps&&(this._bindTextureDirectly(r.TEXTURE_CUBE_MAP,o),r.generateMipmap(r.TEXTURE_CUBE_MAP)),this._bindTextureDirectly(r.TEXTURE_CUBE_MAP,null),r.bindRenderbuffer(r.RENDERBUFFER,null),this.bindUnboundFramebuffer(null),o._framebuffer=d,a&&(o._depthBuffer=f),o._width=t,o._height=t,o.isReady=!0,this.resetTextureCache(),this._loadedTexturesCache.push(o),o},s.prototype.createCubeTexture=function(t,i,r,n,o,s){var h=this;void 0===o&&(o=null),void 0===s&&(s=null);var c=this._gl,l=c.createTexture();l.isCube=!0,l.url=t,l.references=1,l.onLoadedCallbacks=[];var u=t.substr(t.length-4,4).toLowerCase(),f=this.getCaps().s3tc&&".dds"===u;return f?e.Tools.LoadFile(t,(function(t){var i=e.Internals.DDSTools.GetDDSInfo(t),r=(i.isRGB||i.isLuminance||i.mipmapCount>1)&&!n;h._bindTextureDirectly(c.TEXTURE_CUBE_MAP,l),c.pixelStorei(c.UNPACK_FLIP_Y_WEBGL,1),e.Internals.DDSTools.UploadDDSLevels(h._gl,h.getCaps().s3tc,t,i,r,6),n||i.isFourCC||1!==i.mipmapCount||c.generateMipmap(c.TEXTURE_CUBE_MAP),c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MAG_FILTER,c.LINEAR),c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MIN_FILTER,r?c.LINEAR_MIPMAP_LINEAR:c.LINEAR),c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE),c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE),h._bindTextureDirectly(c.TEXTURE_CUBE_MAP,null),h.resetTextureCache(),l._width=i.width,l._height=i.height,l.isReady=!0}),null,null,!0,s):a(t,i,(function(t){var i=e.Tools.GetExponentOfTwo(t[0].width,h._caps.maxCubemapTextureSize),r=i;h._prepareWorkingCanvas(),h._workingCanvas.width=i,h._workingCanvas.height=r;var s=[c.TEXTURE_CUBE_MAP_POSITIVE_X,c.TEXTURE_CUBE_MAP_POSITIVE_Y,c.TEXTURE_CUBE_MAP_POSITIVE_Z,c.TEXTURE_CUBE_MAP_NEGATIVE_X,c.TEXTURE_CUBE_MAP_NEGATIVE_Y,c.TEXTURE_CUBE_MAP_NEGATIVE_Z];h._bindTextureDirectly(c.TEXTURE_CUBE_MAP,l),c.pixelStorei(c.UNPACK_FLIP_Y_WEBGL,0);for(var a=0;a>y;f.texImage2D(o[0],y,p,x,x,0,p,m,a[y][0]),f.texImage2D(o[1],y,p,x,x,0,p,m,a[y][2]),f.texImage2D(o[2],y,p,x,x,0,p,m,a[y][4]),f.texImage2D(o[3],y,p,x,x,0,p,m,a[y][1]),f.texImage2D(o[4],y,p,x,x,0,p,m,a[y][3]),f.texImage2D(o[5],y,p,x,x,0,p,m,a[y][5])}}else{for(var b=0;b-1&&t.splice(i,1),this._releaseTexture(e)}},s.prototype.unbindAllAttributes=function(){for(var e=0,t=this._vertexAttribArraysEnabled.length;e=this._caps.maxVertexAttribs||!this._vertexAttribArraysEnabled[e]||this._vertexAttribArraysEnabled[e]&&(this._gl.disableVertexAttribArray(e),this._vertexAttribArraysEnabled[e]=!1)},s.prototype.dispose=function(){for(this.hideLoadingUI(),this.stopRenderLoop();this.scenes.length;)this.scenes[0].dispose();s.audioEngine.dispose();for(var e in this._compiledEffects)this._gl.deleteProgram(this._compiledEffects[e]._program);this.unbindAllAttributes(),this._gl=null,this.disableVR(),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)},s.prototype.displayLoadingUI=function(){this._loadingScreen.displayLoadingUI()},s.prototype.hideLoadingUI=function(){this._loadingScreen.hideLoadingUI()},Object.defineProperty(s.prototype,"loadingScreen",{get:function(){return this._loadingScreen},set:function(e){this._loadingScreen=e},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"loadingUIText",{set:function(e){this._loadingScreen.loadingUIText=e},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"loadingUIBackgroundColor",{set:function(e){this._loadingScreen.loadingUIBackgroundColor=e},enumerable:!0,configurable:!0}),s.prototype.attachContextLostEvent=function(e){this._renderingCanvas.addEventListener("webglcontextlost",e,!1)},s.prototype.attachContextRestoredEvent=function(e){this._renderingCanvas.addEventListener("webglcontextrestored",e,!1)},s.prototype.getVertexShaderSource=function(e){var t=this._gl.getAttachedShaders(e);return this._gl.getShaderSource(t[0])},s.prototype.getFragmentShaderSource=function(e){var t=this._gl.getAttachedShaders(e);return this._gl.getShaderSource(t[1])},s.prototype.getFps=function(){return this.fps},s.prototype.getDeltaTime=function(){return this.deltaTime},s.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;r0&&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;i0&&(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})();t.FilesTextures=new Array,t.FilesToLoad=new Array,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;t<6;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)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.xt.x-this.minimumWorld.x)&&(!(this.maximumWorld.y-t.yt.y-this.minimumWorld.y)&&!(this.maximumWorld.z-t.zt.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.xt.x)&&(!(this.maximumWorld.yt.y)&&!(this.maximumWorld.zt.z))},t.Intersects=function(e,t){return!(e.maximumWorld.xt.maximumWorld.x)&&(!(e.maximumWorld.yt.maximumWorld.y)&&!(e.maximumWorld.zt.maximumWorld.z))},t.IntersectsSphere=function(t,i,r,n){var o=e.Vector3.Clamp(r,t,i),s=e.Vector3.DistanceSquared(r,o);return s<=n*n},t.IsCompletelyInFrustum=function(e,t){for(var i=0;i<6;i++)for(var r=0;r<8;r++)if(t[i].dotCoordinate(e[r])<0)return!1;return!0},t.IsInFrustum=function(e,t){for(var i=0;i<6;i++){for(var r=8,n=0;n<8&&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)},t.prototype.isCompletelyInFrustum=function(e){return this.boundingBox.isCompletelyInFrustum(e)},t.prototype._checkCollision=function(e){return e._canDoCollision(this.boundingSphere.centerWorld,this.boundingSphere.radiusWorld,this.boundingBox.minimumWorld,this.boundingBox.maximumWorld)},t.prototype.intersectsPoint=function(e){return!!this.boundingSphere.centerWorld&&(!!this.boundingSphere.intersectsPoint(e)&&!!this.boundingBox.intersectsPoint(e))},t.prototype.intersects=function(t,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))))))))))))))},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,this._show=!1}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.xt.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.yt.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.zt.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(n<=o)return!0;var s=t*this.direction.x+i*this.direction.y+r*this.direction.z;if(s<0)return!1;var a=n-s*s;return a<=o},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(s<0||s>1)return null;e.Vector3.CrossToRef(this._tvec,this._edge1,this._qvec);var a=e.Vector3.Dot(this.direction,this._qvec)*o;if(a<0||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,i<0?i<-9.99999997475243e-7?null:0:i},t.prototype.intersectsMesh=function(i,r){var n=e.Tmp.Matrix[0];return i.getWorldMatrix().invertToRef(n),this._tmpRay?t.TransformToRef(this,n,this._tmpRay):this._tmpRay=t.Transform(this,n),i.intersects(this._tmpRay,r)},t.prototype.show=function(t,i){this._show||(this._renderFunction=this._render.bind(this),this._show=!0,this._scene=t,this._renderPoints=[this.origin,this.origin.add(this.direction.scale(this.length))],this._renderLine=e.Mesh.CreateLines("ray",this._renderPoints,t,!0),this._scene.registerBeforeRender(this._renderFunction)),i&&this._renderLine.color.copyFrom(i)},t.prototype.hide=function(){this._show&&(this._show=!1,this._scene.unregisterBeforeRender(this._renderFunction)),this._renderLine&&(this._renderLine.dispose(),this._renderLine=null,this._renderPoints=null)},t.prototype._render=function(){var t=this._renderPoints[1];t.copyFrom(this.direction),t.scaleInPlace(this.length),t.addInPlace(this.origin),e.Mesh.CreateLines("ray",this._renderPoints,this._scene,!0,this._renderLine)},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),m=e.Vector3.Dot(u,u),g=e.Vector3.Dot(l,f),_=e.Vector3.Dot(u,f),v=d*m-p*p,y=v,x=v;vy&&(s=y,h=_+p,x=m)),h<0?(h=0,-g<0?s=0:-g>d?s=y:(s=-g,y=d)):h>x&&(h=x,-g+p<0?s=0:-g+p>d?s=y:(s=-g+p,y=d)),o=Math.abs(s)0&&a<=this.length&&A.lengthSquared()e.Engine.CollisionsEpsilon&&o.position.addInPlace(o._diffPositionForCollisions),r&&o.onCollideObservable.notifyObservers(r),o.onCollisionPositionChangeObservable.notifyObservers(o.position)},n.addMesh(o),o}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,"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.getClassName=function(){return"AbstractMesh"},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)},i.prototype.setBoundingInfo=function(e){this._boundingInfo=e},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,r,n){t.normalize(),this.rotationQuaternion||(this.rotationQuaternion=e.Quaternion.RotationYawPitchRoll(this.rotation.y,this.rotation.x,this.rotation.z),this.rotation=e.Vector3.Zero());var o;if(n&&n!==e.Space.LOCAL){if(this.parent){var s=this.parent.getWorldMatrix().clone();s.invert(),t=e.Vector3.TransformNormal(t,s)}o=e.Quaternion.RotationAxisToRef(t,r,i._rotationAxisCache),o.multiplyToRef(this.rotationQuaternion,this.rotationQuaternion)}else o=e.Quaternion.RotationAxisToRef(t,r,i._rotationAxisCache),this.rotationQuaternion.multiplyToRef(o,this.rotationQuaternion)},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(){return!this._isDirty&&(this.billboardMode===this._cache.billboardMode&&this.billboardMode===i.BILLBOARDMODE_NONE&&(!this._cache.pivotMatrixUpdated&&(!this.infiniteDistance&&(!!this._cache.position.equals(this.position)&&(!(this.rotationQuaternion&&!this._cache.rotationQuaternion.equals(this.rotationQuaternion))&&(!!this._cache.rotation.equals(this.rotation)&&!!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;t1&&!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;c1)||l.canIntersects(t)){var u=l.intersects(t,this._positions,this.getIndices(),i);if(u&&(i||!s||u.distance0&&this.includedOnlyMeshes.indexOf(e)===-1)&&(!(this.excludedMeshes.length>0&&this.excludedMeshes.indexOf(e)!==-1)&&((0===this.includeOnlyWithLayerMask||0!==(this.includeOnlyWithLayerMask&e.layerMask))&&!(0!==this.excludeWithLayerMask&&this.excludeWithLayerMask&e.layerMask)))},i.prototype.getWorldMatrix=function(){this._currentRenderId=this.getScene().getRenderId();var t=this._getWorldMatrix();return this.parent&&this.parent.getWorldMatrix?(this._parentedWorldMatrix||(this._parentedWorldMatrix=e.Matrix.Identity()),t.multiplyToRef(this.parent.getWorldMatrix(),this._parentedWorldMatrix),this._markSyncedWithParent(),this._parentedWorldMatrix):t},i.prototype.dispose=function(){this._shadowGenerator&&(this._shadowGenerator.dispose(),this._shadowGenerator=null),this.getScene().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;othis._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)},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},i})(e.Light);__decorate([e.serializeAsVector3()],t.prototype,"position",void 0),__decorate([e.serializeAsVector3()],t.prototype,"direction",void 0), -__decorate([e.serialize()],t.prototype,"shadowOrthoScale",void 0),__decorate([e.serialize()],t.prototype,"autoUpdateExtends",void 0),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._useFullFloat=!0,this._light=r,this._scene=r.getScene(),this._mapSize=i,r._shadowGenerator=this;var o,s=this._scene.getEngine().getCaps();s.textureFloat&&s.textureFloatLinearFiltering&&s.textureFloatRender?(this._useFullFloat=!0,o=e.Engine.TEXTURETYPE_FLOAT):(this._useFullFloat=!1,o=e.Engine.TEXTURETYPE_UNSIGNED_INT),this._shadowMap=new e.RenderTargetTexture(r.name+"_shadowMap",i,this._scene,(!1),(!0),o,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),(!0),o),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 a=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;r4&&(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 h=r.join("\n");return this._cachedDefines!==h&&(this._cachedDefines=h,this._effect=this._scene.getEngine().createEffect("shadowMap",n,["world","mBones","viewProjection","diffuseMatrix","lightPosition","depthValues"],["diffuseSampler"],h)),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:e<=0?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;ti.x+r)&&(!(i.x-r>t.x)&&(!(e.y>i.y+r)&&(!(i.y-r>t.y)&&(!(e.z>i.z+r)&&!(i.z-r>t.z)))))},i=(function(){var e={root:0,found:!1};return function(t,i,r,n){e.root=0,e.found=!1;var o=i*i-4*t*r;if(o<0)return e;var s=Math.sqrt(o),a=(-i-s)/(2*t),h=(-i+s)/(2*t);if(a>h){var c=h;h=a,a=c}return a>0&&a0&&h=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)&&!!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||d<0)return;h<0&&(h=0),h>1&&(h=1)}this._collisionPoint.copyFromFloats(0,0,0);var m=!1,g=1;if(c||(this.basePoint.subtractToRef(l.normal,this._planeIntersectionPoint),this.velocity.scaleToRef(h,this._tempVector),this._planeIntersectionPoint.addInPlace(this._tempVector),this._checkPointInTriangle(this._planeIntersectionPoint,n,o,s,l.normal)&&(m=!0,g=h,this._collisionPoint.copyFrom(this._planeIntersectionPoint))),!m){var _=this.velocity.lengthSquared(),v=_;this.basePoint.subtractToRef(n,this._tempVector);var y=2*e.Vector3.Dot(this.velocity,this._tempVector),x=this._tempVector.lengthSquared()-1,b=i(v,y,x,g);b.found&&(g=b.root,m=!0,this._collisionPoint.copyFrom(n)),this.basePoint.subtractToRef(o,this._tempVector),y=2*e.Vector3.Dot(this.velocity,this._tempVector),x=this._tempVector.lengthSquared()-1,b=i(v,y,x,g),b.found&&(g=b.root,m=!0,this._collisionPoint.copyFrom(o)),this.basePoint.subtractToRef(s,this._tempVector),y=2*e.Vector3.Dot(this.velocity,this._tempVector),x=this._tempVector.lengthSquared()-1,b=i(v,y,x,g),b.found&&(g=b.root,m=!0,this._collisionPoint.copyFrom(s)),o.subtractToRef(n,this._edge),n.subtractToRef(this.basePoint,this._baseToVertex);var A=this._edge.lengthSquared(),T=e.Vector3.Dot(this._edge,this.velocity),E=e.Vector3.Dot(this._edge,this._baseToVertex);if(v=A*-_+T*T,y=A*(2*e.Vector3.Dot(this.velocity,this._baseToVertex))-2*T*E,x=A*(1-this._baseToVertex.lengthSquared())+E*E,b=i(v,y,x,g),b.found){var M=(T*b.root-E)/A;M>=0&&M<=1&&(g=b.root,m=!0,this._edge.scaleInPlace(M),n.addToRef(this._edge,this._collisionPoint))}s.subtractToRef(o,this._edge),o.subtractToRef(this.basePoint,this._baseToVertex),A=this._edge.lengthSquared(),T=e.Vector3.Dot(this._edge,this.velocity),E=e.Vector3.Dot(this._edge,this._baseToVertex),v=A*-_+T*T,y=A*(2*e.Vector3.Dot(this.velocity,this._baseToVertex))-2*T*E,x=A*(1-this._baseToVertex.lengthSquared())+E*E,b=i(v,y,x,g),b.found&&(M=(T*b.root-E)/A,M>=0&&M<=1&&(g=b.root,m=!0,this._edge.scaleInPlace(M),o.addToRef(this._edge,this._collisionPoint))),n.subtractToRef(s,this._edge),s.subtractToRef(this.basePoint,this._baseToVertex),A=this._edge.lengthSquared(),T=e.Vector3.Dot(this._edge,this.velocity),E=e.Vector3.Dot(this._edge,this._baseToVertex),v=A*-_+T*T,y=A*(2*e.Vector3.Dot(this.velocity,this._baseToVertex))-2*T*E,x=A*(1-this._baseToVertex.lengthSquared())+E*E,b=i(v,y,x,g),b.found&&(M=(T*b.root-E)/A,M>=0&&M<=1&&(g=b.root,m=!0,this._edge.scaleInPlace(M),s.addToRef(this._edge,this._collisionPoint)))}if(m){var P=g*this.velocity.length();(!this.collisionFound||P4)){++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})();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()||[])}},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;h0&&this._postProcesses[0].markTextureDirty();for(var t=0,i=this._rigCameras.length;t-1?(e.Tools.Error("You're trying to reuse a post process not defined as reusable."),0):(null==i||i<0?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);o!==-1&&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._refreshFrustumPlanes=!0,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.freezeProjectionMatrix=function(e){this._doNotComputeProjectionMatrix=!0,void 0!==e&&(this._projectionMatrix=e)},i.prototype.unfreezeProjectionMatrix=function(){this._doNotComputeProjectionMatrix=!1},i.prototype.getProjectionMatrix=function(t){if(this._doNotComputeProjectionMatrix||!t&&this._isSynchronizedProjectionMatrix())return this._projectionMatrix;this._refreshFrustumPlanes=!0;var r=this.getEngine(),n=this.getScene();if(this.mode===i.PERSPECTIVE_CAMERA)return this.minZ<=0&&(this.minZ=.1),n.useRightHandedSystem?e.Matrix.PerspectiveFovRHToRef(this.fov,r.getAspectRatio(this),this.minZ,this.maxZ,this._projectionMatrix,this.fovMode===i.FOVMODE_VERTICAL_FIXED):e.Matrix.PerspectiveFovLHToRef(this.fov,r.getAspectRatio(this),this.minZ,this.maxZ,this._projectionMatrix,this.fovMode===i.FOVMODE_VERTICAL_FIXED),this._projectionMatrix;var o=r.getRenderWidth()/2,s=r.getRenderHeight()/2;return n.useRightHandedSystem?e.Matrix.OrthoOffCenterRHToRef(this.orthoLeft||-o,this.orthoRight||o,this.orthoBottom||-s,this.orthoTop||s,this.minZ,this.maxZ,this._projectionMatrix):e.Matrix.OrthoOffCenterLHToRef(this.orthoLeft||-o,this.orthoRight||o,this.orthoBottom||-s,this.orthoTop||s,this.minZ,this.maxZ,this._projectionMatrix), -this._projectionMatrix},i.prototype.getTranformationMatrix=function(){return this._computedViewMatrix.multiplyToRef(this._projectionMatrix,this._transformMatrix),this._transformMatrix},i.prototype.updateFrustumPlanes=function(){this._refreshFrustumPlanes&&(this.getTranformationMatrix(),this._frustumPlanes?e.Frustum.GetPlanesToRef(this._transformMatrix,this._frustumPlanes):this._frustumPlanes=e.Frustum.GetPlanes(this._transformMatrix),this._refreshFrustumPlanes=!1)},i.prototype.isInFrustum=function(e){return this.updateFrustumPlanes(),e.isInFrustum(this._frustumPlanes)},i.prototype.isCompletelyInFrustum=function(e){return this.updateFrustumPlanes(),e.isCompletelyInFrustum(this._frustumPlanes)},i.prototype.dispose=function(){for(this.getScene().stopAnimation(this),this.getScene().removeCamera(this);this._rigCameras.length>0;)this._rigCameras.pop().dispose();for(var e=this._postProcesses.length;--e>=0;)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));break;case i.RIG_MODE_WEBVR:r.vrDisplay&&(this._rigCameras[0].viewport=new e.Viewport(0,0,.5,1),this._rigCameras[0].setCameraRigParameter("left",!0),this._rigCameras[0].setCameraRigParameter("frameData",r.frameData),this._rigCameras[0]._cameraRigParams.vrWorkMatrix=new e.Matrix,this._rigCameras[0].getProjectionMatrix=this._getWebVRProjectionMatrix,this._rigCameras[1].viewport=new e.Viewport(.5,0,.5,1),this._rigCameras[1].setCameraRigParameter("frameData",r.frameData),this._rigCameras[1]._cameraRigParams.vrWorkMatrix=new e.Matrix,this._rigCameras[1].getProjectionMatrix=this._getWebVRProjectionMatrix)}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._getWebVRProjectionMatrix=function(){var t=this._cameraRigParams.left?this._cameraRigParams.frameData.leftProjectionMatrix:this._cameraRigParams.frameData.rightProjectionMatrix;return[8,9,10,11].forEach((function(e){t[e]*=-1})),e.Matrix.FromArrayToRef(t,0,this._projectionMatrix),this._projectionMatrix},i.prototype._getWebVRViewMatrix=function(){var t=this._cameraRigParams.left?this._cameraRigParams.frameData.leftViewMatrix:this._cameraRigParams.frameData.rightViewMatrix;return[8,9,10,11].forEach((function(e){t[e]*=-1})),e.Matrix.FromArrayToRef(t,0,this._webvrViewMatrix),this._webvrViewMatrix},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=0&&r._keys.splice(t,1),i||e.preventDefault()}},t.addEventListener("keydown",this._onKeyDown,!1),t.addEventListener("keyup",this._onKeyUp,!1),e.Tools.RegisterTopRootEvents([{name:"blur",handler:this._onLostFocus}]))},t.prototype.detachControl=function(t){this._onKeyDown&&(t.removeEventListener("keydown",this._onKeyDown),t.removeEventListener("keyup",this._onKeyUp),e.Tools.UnregisterTopRootEvents([{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;i1)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"},t})();__decorate([e.serialize()],t.prototype,"touchAngularSensibility",void 0),__decorate([e.serialize()],t.prototype,"touchMoveSensibility",void 0),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),this._orientationChanged()},t.prototype.detachControl=function(e){window.removeEventListener("orientationchange",this._orientationChanged),window.removeEventListener("deviceorientation",this._deviceOrientation)},t.prototype.checkInputs=function(){this._alpha&&(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 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"},t})();__decorate([e.serialize()],t.prototype,"gamepadAngularSensibility",void 0),__decorate([e.serialize()],t.prototype,"gamepadMoveSensibility",void 0),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;t.tabIndex=1,this._onKeyDown=function(e){if(r.keysUp.indexOf(e.keyCode)!==-1||r.keysDown.indexOf(e.keyCode)!==-1||r.keysLeft.indexOf(e.keyCode)!==-1||r.keysRight.indexOf(e.keyCode)!==-1){var t=r._keys.indexOf(e.keyCode);t===-1&&r._keys.push(e.keyCode),e.preventDefault&&(i||e.preventDefault())}},this._onKeyUp=function(e){if(r.keysUp.indexOf(e.keyCode)!==-1||r.keysDown.indexOf(e.keyCode)!==-1||r.keysLeft.indexOf(e.keyCode)!==-1||r.keysRight.indexOf(e.keyCode)!==-1){var t=r._keys.indexOf(e.keyCode);t>=0&&r._keys.splice(t,1),e.preventDefault&&(i||e.preventDefault())}},this._onLostFocus=function(){r._keys=[]},t.addEventListener("keydown",this._onKeyDown,!1),t.addEventListener("keyup",this._onKeyUp,!1),e.Tools.RegisterTopRootEvents([{name:"blur",handler:this._onLostFocus}])},t.prototype.detachControl=function(t){t&&(t.removeEventListener("keydown",this._onKeyDown),t.removeEventListener("keyup",this._onKeyUp)),e.Tools.UnregisterTopRootEvents([{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.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"},t})();__decorate([e.serialize()],t.prototype,"gamepadRotationSensibility",void 0),__decorate([e.serialize()],t.prototype,"gamepadMoveSensibility",void 0),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){var o=t.call(this,i,r,n)||this;return o.cameraDirection=new e.Vector3(0,0,0),o.cameraRotation=new e.Vector2(0,0),o.rotation=new e.Vector3(0,0,0),o.speed=2,o.noRotationConstraint=!1,o.lockedTarget=null,o._currentTarget=e.Vector3.Zero(),o._viewMatrix=e.Matrix.Zero(),o._camMatrix=e.Matrix.Zero(),o._cameraTransformMatrix=e.Matrix.Zero(),o._cameraRotationMatrix=e.Matrix.Zero(),o._referencePoint=new e.Vector3(0,0,1),o._defaultUpVector=new e.Vector3(0,1,0),o._transformedReferencePoint=e.Vector3.Zero(),o._lookAtTemp=e.Matrix.Zero(),o._tempMatrix=e.Matrix.Zero(),o}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.absolutePosition&&this.lockedTarget.computeWorldMatrix(),this.lockedTarget.absolutePosition||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*Math.sqrt(e.getDeltaTime()/(100*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.Engine.CollisionsEpsilon&&(o.position.addInPlace(o._diffPosition),o.onCollide&&r&&o.onCollide(r))};n(i)},o.inputs=new e.FreeCameraInputsManager(o),o.inputs.addKeyboard().addMouse(),o}return __extends(i,t),Object.defineProperty(i.prototype,"angularSensibility",{get:function(){var e=this.inputs.attached.mouse;if(e)return e.angularSensibility},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;if(e)return e.keysUp},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;if(e)return e.keysDown},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;if(e)return e.keysLeft},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;if(e)return e.keysRight},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.getClassName=function(){return"FreeCamera"},i})(e.TargetCamera);__decorate([e.serializeAsVector3()],t.prototype,"ellipsoid",void 0),__decorate([e.serialize()],t.prototype,"checkCollisions",void 0),__decorate([e.serialize()],t.prototype,"applyGravity",void 0),e.FreeCamera=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(e){return t.call(this,e)||this}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.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){var o=t.call(this,e,i,r)||this;return o.radius=12,o.rotationOffset=0,o.heightOffset=4,o.cameraAcceleration=.05,o.maxCameraSpeed=20,o.lockedTarget=n,o}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=l<1?-this.maxCameraSpeed:this.maxCameraSpeed),(u>this.maxCameraSpeed||u<-this.maxCameraSpeed)&&(u=u<1?-this.maxCameraSpeed:this.maxCameraSpeed),(f>this.maxCameraSpeed||f<-this.maxCameraSpeed)&&(f=f<1?-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.lockedTarget)},i.prototype.getClassName=function(){return"FollowCamera"},i})(e.TargetCamera);__decorate([e.serialize()],t.prototype,"radius",void 0),__decorate([e.serialize()],t.prototype,"rotationOffset",void 0),__decorate([e.serialize()],t.prototype,"heightOffset",void 0),__decorate([e.serialize()],t.prototype,"cameraAcceleration",void 0),__decorate([e.serialize()],t.prototype,"maxCameraSpeed",void 0),__decorate([e.serializeAsMeshReference("lockedTargetId")],t.prototype,"lockedTarget",void 0),e.FollowCamera=t;var i=(function(t){function i(i,r,n,o,s,a){var h=t.call(this,i,e.Vector3.Zero(),a)||this;return h.alpha=r,h.beta=n,h.radius=o,h.target=s,h._cartesianCoordinates=e.Vector3.Zero(),h.follow(),h}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.getClassName=function(){return"ArcFollowCamera"},i})(e.TargetCamera);e.ArcFollowCamera=i})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(e){function t(t,i,r){var n=e.call(this,t,i,r)||this;return n.inputs.addTouch(),n._setupInputs(),n}return __extends(t,e),Object.defineProperty(t.prototype,"touchAngularSensibility",{get:function(){var e=this.inputs.attached.touch;if(e)return e.touchAngularSensibility},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;if(e)return e.touchMoveSensibility},set:function(e){var t=this.inputs.attached.touch;t&&(t.touchMoveSensibility=e)},enumerable:!0,configurable:!0}),t.prototype.getClassName=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=t.call(this,i,e.Vector3.Zero(),a)||this;return h.inertialAlphaOffset=0,h.inertialBetaOffset=0,h.inertialRadiusOffset=0,h.lowerAlphaLimit=null,h.upperAlphaLimit=null,h.lowerBetaLimit=.01,h.upperBetaLimit=Math.PI,h.lowerRadiusLimit=null,h.upperRadiusLimit=null,h.inertialPanningX=0,h.inertialPanningY=0,h.zoomOnFactor=1,h.targetScreenOffset=e.Vector2.Zero(),h.allowUpsideDown=!0,h._viewMatrix=new e.Matrix,h.panningAxis=new e.Vector3(1,1,0),h.checkCollisions=!1,h.collisionRadius=new e.Vector3(.5,.5,.5),h._collider=new e.Collider,h._previousPosition=e.Vector3.Zero(),h._collisionVelocity=e.Vector3.Zero(),h._newPosition=e.Vector3.Zero(),h._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?h.target=s:h.target=e.Vector3.Zero(),h.alpha=r,h.beta=n,h.radius=o,h.getViewMatrix(),h.inputs=new e.ArcRotateCameraInputsManager(h),h.inputs.addKeyboard().addMouseWheel().addPointers().addGamepad(),h}return __extends(i,t),Object.defineProperty(i.prototype,"angularSensibilityX",{get:function(){var e=this.inputs.attached.pointers;if(e)return e.angularSensibilityX},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;if(e)return e.angularSensibilityY},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;if(e)return e.pinchPrecision},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;if(e)return e.panningSensibility},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;if(e)return e.keysUp},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;if(e)return e.keysDown},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;if(e)return e.keysLeft},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;if(e)return e.keysRight},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;if(e)return e.wheelPrecision},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(){if(this.target.getAbsolutePosition){var e=this.target.getAbsolutePosition();return this._targetBoundingCenter?e.add(this._targetBoundingCenter):e}return 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))},i.prototype.attachControl=function(e,t,i,r){var n=this;void 0===i&&(i=!0),void 0===r&&(r=2),this._useCtrlForPanning=i,this._panningMouseButton=r,this.inputs.attachElement(e,t),this._reset=function(){n.inertialAlphaOffset=0,n.inertialBetaOffset=0,n.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.getScene().useRightHandedSystem?this.alpha-=this.beta<=0?-this.inertialAlphaOffset:this.inertialAlphaOffset: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)Math.PI&&(this.beta=this.beta-2*Math.PI):this.betathis.upperBetaLimit&&(this.beta=this.upperBetaLimit),this.lowerAlphaLimit&&this.alphathis.upperAlphaLimit&&(this.alpha=this.upperAlphaLimit),this.lowerRadiusLimit&&this.radiusthis.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.copyFrom(e),this.rebuildAnglesAndRadius())},i.prototype.setTarget=function(e,t){void 0===t&&(t=!1),this._getTargetPosition().equals(e)||(t&&e.getBoundingInfo?this._targetBoundingCenter=e.getBoundingInfo().boundingBox.center.clone():this._targetBoundingCenter=null,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()),this.getScene().useRightHandedSystem?e.Matrix.LookAtRHToRef(this.position,o,s,this._viewMatrix):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._currentTarget=o,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.getClassName=function(){return"ArcRotateCamera"},i})(e.TargetCamera);__decorate([e.serialize()],t.prototype,"alpha",void 0),__decorate([e.serialize()],t.prototype,"beta",void 0),__decorate([e.serialize()],t.prototype,"radius",void 0),__decorate([e.serializeAsVector3()],t.prototype,"target",void 0),__decorate([e.serialize()],t.prototype,"inertialAlphaOffset",void 0),__decorate([e.serialize()],t.prototype,"inertialBetaOffset",void 0),__decorate([e.serialize()],t.prototype,"inertialRadiusOffset",void 0),__decorate([e.serialize()],t.prototype,"lowerAlphaLimit",void 0),__decorate([e.serialize()],t.prototype,"upperAlphaLimit",void 0),__decorate([e.serialize()],t.prototype,"lowerBetaLimit",void 0),__decorate([e.serialize()],t.prototype,"upperBetaLimit",void 0),__decorate([e.serialize()],t.prototype,"lowerRadiusLimit",void 0),__decorate([e.serialize()],t.prototype,"upperRadiusLimit",void 0),__decorate([e.serialize()],t.prototype,"inertialPanningX",void 0),__decorate([e.serialize()],t.prototype,"inertialPanningY",void 0),__decorate([e.serialize()],t.prototype,"zoomOnFactor",void 0),__decorate([e.serialize()],t.prototype,"allowUpsideDown",void 0),e.ArcRotateCamera=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(e){return t.call(this,e)||this}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._autoClearDepthStencil={},this._customOpaqueSortCompareFn={},this._customAlphaTestSortCompareFn={},this._customTransparentSortCompareFn={},this._renderinGroupInfo=null,this._scene=e;for(var i=t.MIN_RENDERINGGROUPS;ii._alphaIndex?1:e._alphaIndext._distanceToCamera?-1:0},t.frontToBackSortCompare=function(e,t){return e._distanceToCamerat._distanceToCamera?1:0},t.prototype.prepare=function(){this._opaqueSubMeshes.reset(),this._transparentSubMeshes.reset(),this._alphaTestSubMeshes.reset(),this._particleSystems.reset(),this._spriteManagers.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.prototype.dispatchSprites=function(e){this._spriteManagers.push(e)},t.prototype.dispatchParticles=function(e){this._particleSystems.push(e)},t.prototype._renderParticles=function(e){if(0!==this._particleSystems.length){var t=this._scene.activeCamera;this._scene._particlesDuration.beginMonitoring();for(var i=0;ie.ActionManager.LongPressDelay&&Math.abs(l._startingPointerPosition.x-l._pointerX)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&&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(e){return e.isPickable&&e.isVisible&&e.isReady()});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)),c.pickedMesh.actionManager&&Math.abs(a._startingPointerPosition.x-a._pointerX)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)),c.pickedSprite.actionManager&&Math.abs(a._startingPointerPosition.x-a._pointerX)0)return!1;var t;for(t=0;t0)return;this._animationTimeLast=t}var i=(t-this._animationTimeLast)*this.animationTimeScale;this._animationTime+=i,this._animationTimeLast=t;for(var r=0;r0?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.switchActiveCamera=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-1&&(this._geometries.splice(t,1),this.collisionCoordinator.onGeometryDeleted(e),this.onGeometryRemovedObservable.notifyObservers(e),!0)},i.prototype.getGeometries=function(){return this._geometries},i.prototype.getMeshByID=function(e){for(var t=0;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=0;t--)if(this.skeletons[t].id===e)return this.skeletons[t];return null},i.prototype.getSkeletonById=function(e){for(var t=0;t0&&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(o,s)))}}this._particlesDuration.beginMonitoring();e.Tools.Now;if(this.particlesEnabled){e.Tools.StartPerformanceCounter("Particles",this.particleSystems.length>0);for(var a=0;a0)}this._particlesDuration.endMonitoring(!1)},i.prototype._activeMesh=function(e,t){if(t.skeleton&&this.skeletonsEnabled&&(this._activeSkeletons.pushNoDuplicate(t.skeleton)&&t.skeleton.prepare(),t.computeBonesUsingShaders||this._softwareSkinnedMeshes.pushNoDuplicate(t)),(e.showBoundingBox||this.forceShowBoundingBoxes)&&this._boundingBoxRenderer.renderList.push(e.getBoundingInfo().boundingBox),e._edgesRenderer&&this._edgesRenderers.push(e._edgesRenderer),t&&t.subMeshes){var i,r;if(t._submeshesOctree&&t.useOctreeForRenderingSelection){var n=t._submeshesOctree.select(this._frustumPlanes);i=n.length,r=n.data}else r=t.subMeshes,i=r.length;for(var o=0;o0){this._intermediateRendering=!0,e.Tools.StartPerformanceCounter("Render targets",this._renderTargets.length>0);for(var s=0;s0),this._intermediateRendering=!1,this._renderId++,o=!0}var c=this._engine.getStencilBuffer(),l=!1;if(this.renderTargetsEnabled&&this.highlightLayers&&this.highlightLayers.length>0){this._intermediateRendering=!0;for(var u=0;u-1)){l=!0;var a=f._mainTexture;a._shouldRender()&&(this._renderId++,a.render(!1,!1),o=!0)}}this._intermediateRendering=!1,this._renderId++}o&&i.restoreDefaultFramebuffer(),this._renderTargetsDuration.endMonitoring(!1),this.postProcessManager._prepareFrame(),this._renderDuration.beginMonitoring();var d,p;if(this.layers.length){for(i.setDepthBuffer(!1),d=0;d0);for(var g=0;g0)}if(this.layers.length){for(i.setDepthBuffer(!1),d=0;d-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(){this._lastFrameDuration.beginMonitoring(),this._particlesDuration.fetchNewFrame(),this._spritesDuration.fetchNewFrame(),this._activeParticles.fetchNewFrame(),this._renderDuration.fetchNewFrame(),this._renderTargetsDuration.fetchNewFrame(),this._evaluateActiveMeshesDuration.fetchNewFrame(),this._totalVertices.fetchNewFrame(),this._activeIndices.fetchNewFrame(),this._activeBones.fetchNewFrame(),this.getEngine().drawCallsPerfCounter.fetchNewFrame(),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 t=Math.max(i.MinDeltaTime,Math.min(this._engine.getDeltaTime(),i.MaxDeltaTime));this._animationRatio=.06*t,this._animate(),this._physicsEngine&&(e.Tools.StartPerformanceCounter("Physics"),this._physicsEngine._step(t/1e3),e.Tools.EndPerformanceCounter("Physics")),this.onBeforeRenderObservable.notifyObservers(this),this._renderTargetsDuration.beginMonitoring();var r=(e.Tools.Now,this.getEngine()),n=this.activeCamera;if(this.renderTargetsEnabled){e.Tools.StartPerformanceCounter("Custom render targets",this.customRenderTargets.length>0);for(var o=0;o0),this._renderId++}if(this.customRenderTargets.length>0&&r.restoreDefaultFramebuffer(),this._renderTargetsDuration.endMonitoring(),this.activeCamera=n,this.proceduralTexturesEnabled){e.Tools.StartPerformanceCounter("Procedural textures",this._proceduralTextures.length>0);for(var a=0;a0)}if(this._engine.clear(this.clearColor,this.autoClear||this.forceWireframe||this.forcePointsCloud,!0,!0),this.shadowsEnabled)for(var c=0;c0)for(var f=0;f0&&this._engine.clear(null,!1,!0,!0),this._processSubCameras(this.activeCameras[f]);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 d=0;d0?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-1&&this._engine.scenes.splice(t,1),this._engine.wipeCaches()},i.prototype.disposeSounds=function(){this.mainSoundTrack.dispose();for(var e=0;e=n.distance))&&(n=c,r))break}return n||new e.PickingInfo},i.prototype._internalMultiPick=function(e,t){for(var i=new Array,r=0;r0)for(var s=0;s=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.multiPick=function(e,t,i,r){var n=this;return this._internalMultiPick((function(i){return n.createPickingRay(e,t,i,r)}),i)},i.prototype.multiPickWithRay=function(t,i){var r=this;return this._internalMultiPick((function(i){return r._pickWithRayInverseMatrix||(r._pickWithRayInverseMatrix=e.Matrix.Identity()),i.invertToRef(r._pickWithRayInverseMatrix),e.Ray.Transform(t,r._pickWithRayInverseMatrix)}),i)},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;n0},enumerable:!0,configurable:!0}),r.prototype._sortLODLevels=function(){this._LODLevels.sort((function(e,t){return e.distancet.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;ti)return this.onLODLevelSelection&&this.onLODLevelSelection(i,this,this._LODLevels[this._LODLevels.length-1].mesh),this;for(var r=0;r=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,i=this._geometry.copy(e.Geometry.RandomId());t.releaseForMesh(this,!0),i.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-1&&(o.skeleton=i.getLastSkeletonByID(t.skeletonId),t.numBoneInfluencers&&(o.numBoneInfluencers=t.numBoneInfluencers)),t.animations){for(var s=0;s4,c=h?this.getVerticesData(e.VertexBuffer.MatricesIndicesExtraKind):null,l=h?this.getVerticesData(e.VertexBuffer.MatricesWeightsExtraKind):null,u=t.getTransformMatrices(this),f=e.Vector3.Zero(),d=new e.Matrix,p=new e.Matrix,m=0,g=0;g0);o++)e.Matrix.FromFloat32ArrayToRefScaled(u,16*s[m+o],_,p),d.addToSelf(p);if(h)for(o=0;o<4&&(_=l[m+o],_>0);o++)e.Matrix.FromFloat32ArrayToRefScaled(u,16*c[m+o],_,p),d.addToSelf(p);e.Vector3.TransformCoordinatesFromFloatsToRef(this._sourcePositions[g],this._sourcePositions[g+1],this._sourcePositions[g+2],d,f),f.toArray(r,g),e.Vector3.TransformNormalFromFloatsToRef(this._sourceNormals[g],this._sourceNormals[g+1],this._sourceNormals[g+2],d,f),f.toArray(n,g),d.reset()}return this.updateVerticesData(e.VertexBuffer.PositionKind,r),this.updateVerticesData(e.VertexBuffer.NormalKind,n),this}},r.MinMax=function(e){var t=null,i=null;return e.forEach((function(e,r,n){var o=e.getBoundingInfo().boundingBox;t?(t.MinimizeInPlace(o.minimumWorld),i.MaximizeInPlace(o.maximumWorld)):(t=o.minimumWorld,i=o.maximumWorld)})),{min:t,max:i}},r.Center=function(t){var i=t instanceof Array?e.Mesh.MinMax(t):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;s65536))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;sa&&(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.updateSideOrientation=function(t,i){return t==e.Mesh.DOUBLESIDE?e.Mesh.DOUBLESIDE:void 0===t||null===t?e.Mesh.FRONTSIDE:t},t.CreateBox=function(t,i,r){var n=new e.Mesh(t,r);i.sideOrientation=this.updateSideOrientation(i.sideOrientation,r),n.sideOrientation=i.sideOrientation;var 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);i.sideOrientation=this.updateSideOrientation(i.sideOrientation,r),n.sideOrientation=i.sideOrientation;var 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);i.sideOrientation=this.updateSideOrientation(i.sideOrientation,r),n.sideOrientation=i.sideOrientation;var 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);i.sideOrientation=this.updateSideOrientation(i.sideOrientation,r),n.sideOrientation=i.sideOrientation;var 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,this.updateSideOrientation(i.sideOrientation,r)),h=i.instance,c=i.updatable;if(h){e.Vector3.FromFloatsToRef(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,e.Tmp.Vector3[0]),e.Vector3.FromFloatsToRef(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE,e.Tmp.Vector3[1]);var l=function(t){for(var i=n[0].length,r=0,o=h.sideOrientation===e.Mesh.DOUBLESIDE?2:1,s=1;s<=o;s++)for(var a=0;ae.Tmp.Vector3[1].x&&(e.Tmp.Vector3[1].x=c[u].x),c[u].ye.Tmp.Vector3[1].y&&(e.Tmp.Vector3[1].y=c[u].y),c[u].ze.Tmp.Vector3[1].z&&(e.Tmp.Vector3[1].z=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._boundingInfo=new e.BoundingInfo(e.Tmp.Vector3[0],e.Tmp.Vector3[1]),h._boundingInfo.update(h._worldMatrix),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,m=0,g=0;g1?1:r.arc:1,a=void 0===r.closed||r.closed,h=r.shape,c=r.radius||1,l=r.tessellation||64,u=r.updatable,f=this.updateSideOrientation(r.sideOrientation,n),d=r.cap||e.Mesh.NO_CAP,p=2*Math.PI,m=new Array,g=r.invertUV||!1,_=0,v=0,y=p/l*s,x=new Array;for(_=0;_<=l;_++){var x=[];for(d!=e.Mesh.CAP_START&&d!=e.Mesh.CAP_ALL||(x.push(new e.Vector3(0,h[0].y,0)),x.push(new e.Vector3(Math.cos(_*y)*h[0].x*c,h[0].y,Math.sin(_*y)*h[0].x*c))),v=0;v1?1:r.arc||1;var p,m,g=function(t,i,r,n,o,s,a,h){for(var c,l,u,f,d=i.getTangents(),p=i.getNormals(),m=i.getDistances(),g=2*Math.PI,_=g/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,A=0;A3?0:c,m=g(o,p,v,s,a,h,c,r.arc);var y=t.CreateRibbon(i,{pathArray:m,closePath:!0,closeArray:!1,updatable:u,sideOrientation:f,invertUV:l},n);return y.pathArray=m,y.path3D=p,y.tessellation=a,y.cap=c,y.arc=r.arc,y},t.CreatePolyhedron=function(t,i,r){var n=new e.Mesh(t,r);i.sideOrientation=this.updateSideOrientation(i.sideOrientation,r),n.sideOrientation=i.sideOrientation;var 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,m=Math.sqrt(h.x*h.x+h.z*h.z),g=Math.atan2(h.y,m),_=e.Matrix.RotationYawPitchRoll(p,g,l).multiply(e.Matrix.Translation(a.x,a.y,a.z)),v=e.Matrix.Invert(_),y=i.getWorldMatrix(),x=y.multiply(v),b=new e.VertexData;b.indices=[],b.positions=[],b.normals=[],b.uvs=[];for(var A=0,T=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},E=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;s0,h=_>0,l=v>0,m=(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},M=0;M3?0:u,y=x(r,n,v,b,o,s,a,h,u,f);var A=t.CreateRibbon(i,{pathArray:y,closeArray:c,closePath:l,updatable:p,sideOrientation:m,invertUV:_},d);return A.pathArray=y,A.path3D=v,A.cap=u,A},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),this._uid=null}return Object.defineProperty(t.prototype,"uid",{get:function(){return this._uid||(this._uid=e.Tools.RandomId()),this._uid},enumerable:!0,configurable:!0}),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||!!this._texture&&this._texture.isReady},t.prototype.getSize=function(){return this._texture._width?new e.Size(this._texture._width,this._texture._height):this._texture._size?new e.Size(this._texture._size,this._texture._size):e.Size.Zero()},t.prototype.getBaseSize=function(){return this.isReady()&&this._texture?this._texture._size?new e.Size(this._texture._size,this._texture._size):new e.Size(this._texture._baseWidth,this._texture._baseHeight):e.Size.Zero()},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=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},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),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===o&&(o=!1),void 0===s&&(s=!0),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);var f=t.call(this,n)||this;if(f.uOffset=0,f.vOffset=0,f.uScale=1,f.vScale=1,f.uAng=0,f.vAng=0,f.wAng=0,f.name=r,f.url=r,f._noMipmap=o,f._invertY=s,f._samplingMode=a,f._buffer=l,f._deleteBuffer=u,!r)return f;f._texture=f._getFromCache(r,o,a);var d=function(){f._onLoadObservarble&&f._onLoadObservarble.hasObservers()&&f.onLoadObservable.notifyObservers(!0),h&&h()};return f._texture?f._texture.isReady?e.Tools.SetImmediate((function(){return d()})):f._texture.onLoadedCallbacks.push(d):n.useDelayedTextureLoading?(f.delayLoadState=e.Engine.DELAYLOADSTATE_NOTLOADED,f._delayedOnLoad=d,f._delayedOnError=c):(f._texture=n.getEngine().createTexture(r,o,s,n,f._samplingMode,d,c,f._buffer),u&&delete f._buffer),f}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)},Object.defineProperty(i.prototype,"onLoadObservable",{get:function(){return this._onLoadObservarble||(this._onLoadObservarble=new e.Observable),this._onLoadObservarble},enumerable:!0,configurable:!0}),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.customType){var o=e.Tools.Instantiate(t.customType);return o.Parse(t,r,n)}if(t.isCube)return e.CubeTexture.Parse(t,r,n); -if(!t.name&&!t.isRenderTarget)return null;var s=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 a=0;a=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,s,a,h){void 0===s&&(s=e.Engine.TEXTURETYPE_UNSIGNED_INT),void 0===a&&(a=e.Texture.BILINEAR_SAMPLINGMODE),void 0===h&&(h=!0);var c=t.call(this,i,r,n,o,!0,s,!1,a,h)||this;return c.mirrorPlane=new e.Plane(0,1,0,1),c._transformMatrix=e.Matrix.Zero(),c._mirrorMatrix=e.Matrix.Zero(),c.onBeforeRenderObservable.add((function(){e.Matrix.ReflectionToRef(c.mirrorPlane,c._mirrorMatrix),c._savedViewMatrix=n.getViewMatrix(),c._mirrorMatrix.multiplyToRef(c._savedViewMatrix,c._transformMatrix),n.setTransformMatrix(c._transformMatrix,n.getProjectionMatrix()),n.clipPlane=c.mirrorPlane,n.getEngine().cullBackFaces=!1,n._mirroredCameraPosition=e.Vector3.TransformCoordinates(n.activeCamera.position,c._mirrorMatrix)})),c.onAfterRenderObservable.add((function(){n.setTransformMatrix(c._savedViewMatrix,n.getProjectionMatrix()),n.getEngine().cullBackFaces=!0,n._mirroredCameraPosition=null,delete n.clipPlane})),c}return __extends(i,t),i.prototype.clone=function(){var e=this.getSize(),t=new i(this.name,e.width,this.getScene(),this._renderTargetOptions.generateMipMaps,this._renderTargetOptions.type,this._renderTargetOptions.samplingMode,this._renderTargetOptions.generateDepthBuffer);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=t.call(this,i,r,n,o,!0)||this;return s.refractionPlane=new e.Plane(0,1,0,1),s.depth=2,s.onBeforeRenderObservable.add((function(){n.clipPlane=s.refractionPlane})),s.onAfterRenderObservable.add((function(){delete n.clipPlane})),s}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);var a=t.call(this,null,n,!o)||this;a.name=i,a.wrapU=e.Texture.CLAMP_ADDRESSMODE,a.wrapV=e.Texture.CLAMP_ADDRESSMODE,a._generateMipMaps=o,r.getContext?(a._canvas=r,a._texture=n.getEngine().createDynamicTexture(r.width,r.height,o,s)):(a._canvas=document.createElement("canvas"),r.width?a._texture=n.getEngine().createDynamicTexture(r.width,r.height,o,s):a._texture=n.getEngine().createDynamicTexture(r,r,o,s));var h=a.getSize();return a._canvas.width=h.width,a._canvas.height=h.height,a._context=a._canvas.getContext("2d"),a}return __extends(i,t),Object.defineProperty(i.prototype,"canRescale",{get:function(){return!0},enumerable:!0,configurable:!0}),i.prototype.scale=function(e){var t=this.getSize();t.width*=e,t.height*=e,this._canvas.width=t.width,this._canvas.height=t.height,this.releaseInternalTexture(),this._texture=this.getScene().getEngine().createDynamicTexture(t.width,t.height,this._generateMipMaps,this._samplingMode)},i.prototype.getContext=function(){return this._context},i.prototype.clear=function(){var e=this.getSize();this._context.fillRect(0,0,e.width,e.height)},i.prototype.update=function(e){this.getScene().getEngine().updateDynamicTexture(this._texture,this._canvas,void 0===e||e)},i.prototype.drawText=function(e,t,i,r,n,o,s,a){void 0===a&&(a=!0);var h=this.getSize();if(o&&(this._context.fillStyle=o,this._context.fillRect(0,0,h.width,h.height)),this._context.font=r,null===t){var c=this._context.measureText(e);t=(h.width-c.width)/2}this._context.fillStyle=n,this._context.fillText(e,t,i),a&&this.update(s)},i.prototype.clone=function(){var e=this.getSize(),t=new i(this.name,e,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){void 0===o&&(o=!1),void 0===s&&(s=!1),void 0===a&&(a=e.Texture.TRILINEAR_SAMPLINGMODE);var h=t.call(this,null,n,!o,s)||this;h._autoLaunch=!0;var c;return h.name=i,r instanceof HTMLVideoElement?h.video=r:(c=r,h.video=document.createElement("video"),h.video.autoplay=!1,h.video.loop=!0),h._generateMipMaps=o,h._samplingMode=a,e.Tools.IsExponentOfTwo(h.video.videoWidth)&&e.Tools.IsExponentOfTwo(h.video.videoHeight)?(h.wrapU=e.Texture.WRAP_ADDRESSMODE,h.wrapV=e.Texture.WRAP_ADDRESSMODE):(h.wrapU=e.Texture.CLAMP_ADDRESSMODE,h.wrapV=e.Texture.CLAMP_ADDRESSMODE,h._generateMipMaps=!1),c?(h.video.addEventListener("canplaythrough",(function(){h._createTexture()})),c.forEach((function(e){var t=document.createElement("source");t.src=e,h.video.appendChild(t)}))):h._createTexture(),h._lastUpdate=e.Tools.Now,h}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)&&(this._lastUpdate=t,this.getScene().getEngine().updateVideoTexture(this._texture,this.video,this._invertY),!0)},i.CreateFromWebCam=function(t,i,r){var n=document.createElement("video");navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia,window.URL=window.URL||window.webkitURL||window.mozURL||window.msURL,navigator.getUserMedia&&navigator.getUserMedia({video:{width:{min:r&&r.minWidth||256,max:r&&r.maxWidth||640},height:{min:r&&r.minHeight||256,max:r&&r.maxHeight||480}}},(function(r){void 0!==n.mozSrcObject?n.mozSrcObject=r:n.src=window.URL&&window.URL.createObjectURL(r)||r,n.play(),i&&i(new e.VideoTexture("video",n,t,(!0),(!0)))}),(function(t){e.Tools.Error(t.name)}))},i})(e.Texture);e.VideoTexture=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(e,i,r,n,o,s){var a=t.call(this,e,r,null,n,o,s)||this;return a._animate=!0,a._time=0,a._texturePath=i,a.loadJson(i),a.refreshRate=1,a}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;tthis._maxRank&&(this._maxRank=e),this._defines[e]=new Array),this._defines[e].push(t)},e.prototype.addCPUSkinningFallback=function(e,t){this._meshRank=e,this._mesh=t,e>this._maxRank&&(this._maxRank=e)},Object.defineProperty(e.prototype,"isMoreFallbacks",{get:function(){return this._currentRank<=this._maxRank},enumerable:!0,configurable:!0}),e.prototype.reduce=function(e){for(var t=this._defines[this._currentRank],i=0;i-1?e:BABYLON.Engine.ShadersRepository+e,BABYLON.Tools.LoadFile(n+".vertex.fx",t)},Effect.prototype._loadFragmentShader=function(e,t){if(e instanceof HTMLElement){var i=BABYLON.Tools.GetDOMTextContent(e);return void t(i)}if("base64:"===e.substr(0,7)){var r=window.atob(e.substr(7));return void t(r)}if(Effect.ShadersStore[e+"PixelShader"])return void t(Effect.ShadersStore[e+"PixelShader"]);if(Effect.ShadersStore[e+"FragmentShader"])return void t(Effect.ShadersStore[e+"FragmentShader"]);var n;n="."===e[0]||"/"===e[0]||e.indexOf("http")>-1?e:BABYLON.Engine.ShadersRepository+e,BABYLON.Tools.LoadFile(n+".fragment.fx",t)},Effect.prototype._dumpShadersName=function(){this.name.vertexElement?(BABYLON.Tools.Error("Vertex shader:"+this.name.vertexElement),BABYLON.Tools.Error("Fragment shader:"+this.name.fragmentElement)):this.name.vertex?(BABYLON.Tools.Error("Vertex shader:"+this.name.vertex),BABYLON.Tools.Error("Fragment shader:"+this.name.fragment)):(BABYLON.Tools.Error("Vertex shader:"+this.name),BABYLON.Tools.Error("Fragment shader:"+this.name))},Effect.prototype._processIncludes=function(e,t){for(var i=this,r=/#include<(.+)>(\((.*)\))*(\[(.*)\])*/g,n=r.exec(e),o=new String(e);null!=n;){var s=n[1];if(!Effect.IncludesShadersStore[s]){var a=BABYLON.Engine.ShadersRepository+"ShadersInclude/"+s+".fx";return void BABYLON.Tools.LoadFile(a,(function(e){Effect.IncludesShadersStore[s]=e,i._processIncludes(o,t)}))}var h=Effect.IncludesShadersStore[s];if(n[2])for(var c=n[3].split(","),l=0;l0&&(result+=line+"\r\n")}return result},Effect.prototype._evaluateDefinesOnString=function(e){for(var t={children:[]},i=t,r=e.split("\n"),n=0;n0){for(var f=0;f0){for(var p=0;p0&&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=0&&this._scene.materials.splice(i,1),e&&this._effect&&(this._scene.getEngine()._releaseEffect(this._effect),this._effect=null),i=0;i0&&(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;a=!0,this._defines.EMISSIVE=!0}if(this.lightmapTexture&&r.LightmapTextureEnabled){if(!this.lightmapTexture.isReady())return!1;a=!0,this._defines.LIGHTMAP=!0,this._defines.USELIGHTMAPASSHADOWMAP=this.useLightmapAsShadowmap}if(this.specularTexture&&r.SpecularTextureEnabled){if(!this.specularTexture.isReady())return!1;a=!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;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&&r.RefractionTextureEnabled){if(!this.refractionTexture.isReady())return!1;a=!0,this._defines.REFRACTION=!0,this._defines.REFRACTIONMAP_3D=this.refractionTexture.isCube}if(this.cameraColorGradingTexture&&r.ColorGradingTextureEnabled){if(!this.cameraColorGradingTexture.isReady())return!1;this._defines.CAMERACOLORGRADING=!0}}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.cameraColorCurves&&(this._defines.CAMERACOLORCURVES=!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),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),h=!0,this._defines.FRESNEL=!0),this._defines.SPECULARTERM&&this.useSpecularOverAlpha&&(this._defines.SPECULAROVERALPHA=!0),i&&(h&&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),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",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"];this._defines.CAMERACOLORCURVES&&e.ColorCurves.PrepareUniforms(d),this._defines.CAMERACOLORGRADING&&e.ColorGradingTexture.PrepareUniformsAndSamplers(d,p),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)},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){if(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)}this.cameraColorGradingTexture&&r.ColorGradingTextureEnabled&&e.ColorGradingTexture.Bind(this.cameraColorGradingTexture,this._effect)}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),this.cameraColorCurves&&e.ColorCurves.Bind(this.cameraColorCurves,this._effect)),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),this.cameraColorGradingTexture&&this.cameraColorGradingTexture.animations&&this.cameraColorGradingTexture.animations.length>0&&e.push(this.cameraColorGradingTexture),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(),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(){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})(e.Material);i.DiffuseTextureEnabled=!0,i.AmbientTextureEnabled=!0,i.OpacityTextureEnabled=!0,i.ReflectionTextureEnabled=!0,i.EmissiveTextureEnabled=!0,i.SpecularTextureEnabled=!0,i.BumpTextureEnabled=!0,i.FresnelEnabled=!0,i.LightmapTextureEnabled=!0,i.RefractionTextureEnabled=!0,i.ColorGradingTextureEnabled=!0,__decorate([e.serializeAsTexture()],i.prototype,"diffuseTexture",void 0),__decorate([e.serializeAsTexture()],i.prototype,"ambientTexture",void 0),__decorate([e.serializeAsTexture()],i.prototype,"opacityTexture",void 0),__decorate([e.serializeAsTexture()],i.prototype,"reflectionTexture",void 0),__decorate([e.serializeAsTexture()],i.prototype,"emissiveTexture",void 0),__decorate([e.serializeAsTexture()],i.prototype,"specularTexture",void 0),__decorate([e.serializeAsTexture()],i.prototype,"bumpTexture",void 0),__decorate([e.serializeAsTexture()],i.prototype,"lightmapTexture",void 0),__decorate([e.serializeAsTexture()],i.prototype,"refractionTexture",void 0),__decorate([e.serializeAsColor3("ambient")],i.prototype,"ambientColor",void 0),__decorate([e.serializeAsColor3("diffuse")],i.prototype,"diffuseColor",void 0),__decorate([e.serializeAsColor3("specular")],i.prototype,"specularColor",void 0),__decorate([e.serializeAsColor3("emissive")],i.prototype,"emissiveColor",void 0),__decorate([e.serialize()],i.prototype,"specularPower",void 0),__decorate([e.serialize()],i.prototype,"useAlphaFromDiffuseTexture",void 0),__decorate([e.serialize()],i.prototype,"useEmissiveAsIllumination",void 0),__decorate([e.serialize()],i.prototype,"linkEmissiveWithDiffuse",void 0),__decorate([e.serialize()],i.prototype,"useReflectionFresnelFromSpecular",void 0),__decorate([e.serialize()],i.prototype,"useSpecularOverAlpha",void 0),__decorate([e.serialize()],i.prototype,"useReflectionOverAlpha",void 0),__decorate([e.serialize()],i.prototype,"disableLighting",void 0),__decorate([e.serialize()],i.prototype,"useParallax",void 0),__decorate([e.serialize()],i.prototype,"useParallaxOcclusion",void 0),__decorate([e.serialize()],i.prototype,"parallaxScaleBias",void 0),__decorate([e.serialize()],i.prototype,"roughness",void 0),__decorate([e.serialize()],i.prototype,"indexOfRefraction",void 0),__decorate([e.serialize()],i.prototype,"invertRefractionY",void 0),__decorate([e.serialize()],i.prototype,"useLightmapAsShadowmap",void 0),__decorate([e.serializeAsFresnelParameters()],i.prototype,"diffuseFresnelParameters",void 0),__decorate([e.serializeAsFresnelParameters()],i.prototype,"opacityFresnelParameters",void 0),__decorate([e.serializeAsFresnelParameters()],i.prototype,"reflectionFresnelParameters",void 0),__decorate([e.serializeAsFresnelParameters()],i.prototype,"refractionFresnelParameters",void 0),__decorate([e.serializeAsFresnelParameters()],i.prototype,"emissiveFresnelParameters",void 0),__decorate([e.serialize()],i.prototype,"useGlossinessFromSpecularMapAlpha",void 0),__decorate([e.serialize()],i.prototype,"maxSimultaneousLights",void 0),__decorate([e.serialize()],i.prototype,"invertNormalMapX",void 0),__decorate([e.serialize()],i.prototype,"invertNormalMapY",void 0),__decorate([e.serializeAsTexture()],i.prototype,"cameraColorGradingTexture",void 0),__decorate([e.serializeAsColorCurves()],i.prototype,"cameraColorCurves",void 0),__decorate([e.serialize()],i.prototype,"useLogarithmicDepth",null),e.StandardMaterial=i})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(e,i){var r=t.call(this,e,i,!0)||this;return r.subMaterials=new Array,i.multiMaterials.push(r),r}return __extends(i,t),i.prototype.getSubMaterial=function(e){return e<0||e>=this.subMaterials.length?this.getScene().defaultMaterial:this.subMaterials[e]},i.prototype.getClassName=function(){return"MultiMaterial"},i.prototype.isReady=function(e){for(var t=0;t-1&&o.skeletons){var O=g.indexOf(y.skeletonId)>-1;if(!O)for(var D=0,I=f.skeletons.length;D>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;fp&&(c=p,o=d,n))break}}}if(o){var m=new e.PickingInfo;return m.hit=!0,m.pickedSprite=o,m.distance=c,m}return null},t.prototype.render=function(){if(this._effectBase.isReady()&&this._effectFog.isReady()&&this._spriteTexture&&this._spriteTexture.isReady()){for(var t=this._scene.getEngine(),i=this._spriteTexture.getBaseSize(),r=t.getDeltaTime(),n=Math.min(this._capacity,this.sprites.length),o=i.width/this.cellWidth,s=0,a=0;athis._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._onAnimationEnd&&this._onAnimationEnd(),this.disposeWhenFinishedAnimating&&this.dispose()))))},t.prototype.dispose=function(){for(var e=0;e=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;o-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;r1)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=[{frame:0,value:s},{frame:o,value:a}];return 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=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;t0)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=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: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;sthis._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)}(rthis._keys[this._keys.length-1].frame)&&(r=this._keys[0].frame),(nthis._keys[this._keys.length-1].frame)&&(n=this._keys[this._keys.length-1].frame),r===n&&r++;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 m=this._interpolate(r,0,i.ANIMATIONLOOPMODE_CYCLE),g=this._interpolate(n,0,i.ANIMATIONLOOPMODE_CYCLE);switch(this.dataType){case i.ANIMATIONTYPE_FLOAT:this._offsetsCache[p]=g-m;break;case i.ANIMATIONTYPE_QUATERNION:this._offsetsCache[p]=g.subtract(m);break;case i.ANIMATIONTYPE_VECTOR3:this._offsetsCache[p]=g.subtract(m);case i.ANIMATIONTYPE_VECTOR2:this._offsetsCache[p]=g.subtract(m);case i.ANIMATIONTYPE_SIZE:this._offsetsCache[p]=g.subtract(m);case i.ANIMATIONTYPE_COLOR3:this._offsetsCache[p]=g.subtract(m)}this._highLimitsCache[p]=g}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 _=f/u>>0,v=h?r+f%u:n,y=this._interpolate(v,_,this.loopMode,l,d);this.setValue(y);for(var x=0;x=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-1){for(var i=this._animations,r=0,t=i.length-1;t>=0;t--)"string"==typeof e&&i[t].name!=e||(i[t].reset(),i.splice(t,1),r++);i.length==r&&(this._scene._activeAnimatables.splice(t,1),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=.5?.5*(1-this.easeInCore(2*(1-t)))+.5:.5*this.easeInCore(2*t)},e})();t._EASINGMODE_EASEIN=0,t._EASINGMODE_EASEOUT=1,t._EASINGMODE_EASEINOUT=2,e.EasingFunction=t;var i=(function(e){function t(){return e.apply(this,arguments)||this}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);var i=e.call(this)||this;return i.amplitude=t,i}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);var r=e.call(this)||this;return r.bounces=t,r.bounciness=i,r}return __extends(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.bounces),i=this.bounciness;i<=1&&(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(){return e.apply(this,arguments)||this}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);var r=e.call(this)||this;return r.oscillations=t,r.springiness=i,r}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);var i=e.call(this)||this;return i.exponent=t,i}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);var i=e.call(this)||this;return i.power=t,i}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(){return e.apply(this,arguments)||this}return __extends(t,e),t.prototype.easeInCore=function(e){return e*e},t})(t);e.QuadraticEase=c;var l=(function(e){function t(){return e.apply(this,arguments)||this}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(){return e.apply(this,arguments)||this}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(){return e.apply(this,arguments)||this}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);var o=t.call(this)||this;return o.x1=e,o.y1=i,o.x2=r,o.y2=n,o}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){var a=t.call(this,i,r.getScene())||this;return a.name=i,a.children=new Array,a.animations=new Array,a._worldTransform=new e.Matrix,a._absoluteTransform=new e.Matrix,a._invertedAbsoluteTransform=new e.Matrix,a._scaleMatrix=e.Matrix.Identity(),a._scaleVector=new e.Vector3(1,1,1),a._negateScaleChildren=new e.Vector3(1,1,1),a._scalingDeterminant=1,a._syncScaleVector=function(){var t=this.getLocalMatrix(),i=t.m[0]*t.m[0]+t.m[1]*t.m[1]+t.m[2]*t.m[2],r=t.m[4]*t.m[4]+t.m[5]*t.m[5]+t.m[6]*t.m[6],n=t.m[8]*t.m[8]+t.m[9]*t.m[9]+t.m[10]*t.m[10],o=t.m[0]*t.m[1]*t.m[2]*t.m[3]<0?-1:1,s=t.m[4]*t.m[5]*t.m[6]*t.m[7]<0?-1:1,a=t.m[8]*t.m[9]*t.m[10]*t.m[11]<0?-1:1;this._scaleVector.x=o*Math.sqrt(i),this._scaleVector.y=s*Math.sqrt(r),this._scaleVector.z=a*Math.sqrt(n),this._parent&&(this._scaleVector.x/=this._parent._negateScaleChildren.x,this._scaleVector.y/=this._parent._negateScaleChildren.y,this._scaleVector.z/=this._parent._negateScaleChildren.z),e.Matrix.FromValuesToRef(this._scaleVector.x,0,0,0,0,this._scaleVector.y,0,0,0,0,this._scaleVector.z,0,0,0,0,1,this._scaleMatrix)},a._skeleton=r,a._matrix=o,a._baseMatrix=o,a._restPose=s?s:o.clone(),r.bones.push(a),n?(a._parent=n,n.children.push(a)):a._parent=null,a._updateDifferenceMatrix(),a.getAbsoluteTransform().determinant()<0&&(a._scalingDeterminant*=-1),a}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,t){void 0===t&&(t=!0),this._baseMatrix=e.clone(),this._matrix=e.clone(),this._skeleton._markAsDirty(),t&&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=l&&a.frame<=u&&(n?(c=a.value.clone(),g?(h=c.getTranslation(),c.setTranslation(h.scaleInPlace(_))):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.prototype.translate=function(t,i,r){void 0===i&&(i=e.Space.LOCAL);var n=this.getLocalMatrix();if(i==e.Space.LOCAL)n.m[12]+=t.x,n.m[13]+=t.y,n.m[14]+=t.z;else{this._skeleton.computeAbsoluteTransforms();var o=e.Tmp.Matrix[0],s=e.Tmp.Vector3[0];r?(o.copyFrom(this._parent.getAbsoluteTransform()),o.multiplyToRef(r.getWorldMatrix(),o)):o.copyFrom(this._parent.getAbsoluteTransform()),o.m[12]=0,o.m[13]=0,o.m[14]=0,o.invert(),e.Vector3.TransformCoordinatesToRef(t,o,s),n.m[12]+=s.x,n.m[13]+=s.y,n.m[14]+=s.z}this.markAsDirty()},i.prototype.setPosition=function(t,i,r){void 0===i&&(i=e.Space.LOCAL);var n=this.getLocalMatrix();if(i==e.Space.LOCAL)n.m[12]=t.x,n.m[13]=t.y,n.m[14]=t.z;else{this._skeleton.computeAbsoluteTransforms();var o=e.Tmp.Matrix[0],s=e.Tmp.Vector3[0];r?(o.copyFrom(this._parent.getAbsoluteTransform()),o.multiplyToRef(r.getWorldMatrix(),o)):o.copyFrom(this._parent.getAbsoluteTransform()),o.invert(),e.Vector3.TransformCoordinatesToRef(t,o,s),n.m[12]=s.x,n.m[13]=s.y,n.m[14]=s.z}this.markAsDirty()},i.prototype.setAbsolutePosition=function(t,i){this.setPosition(t,e.Space.WORLD,i)},i.prototype.setScale=function(e,t,i,r){void 0===r&&(r=!1),this.animations[0]&&!this.animations[0].isStopped()&&(r||(this._negateScaleChildren.x=1/e,this._negateScaleChildren.y=1/t,this._negateScaleChildren.z=1/i),this._syncScaleVector()),this.scale(e/this._scaleVector.x,t/this._scaleVector.y,i/this._scaleVector.z,r)},i.prototype.scale=function(t,i,r,n){void 0===n&&(n=!1);var o=this.getLocalMatrix(),s=e.Tmp.Matrix[0];s.copyFrom(o);var a=e.Tmp.Matrix[1];a.copyFrom(s),a.invert();var h=e.Tmp.Matrix[2];e.Matrix.FromValuesToRef(t,0,0,0,0,i,0,0,0,0,r,0,0,0,0,1,h),this._scaleMatrix.multiplyToRef(h,this._scaleMatrix),this._scaleVector.x*=t,this._scaleVector.y*=i,this._scaleVector.z*=r,o.multiplyToRef(a,o),o.multiplyToRef(h,o),o.multiplyToRef(s,o);var c=this.getParent();c?o.multiplyToRef(c.getAbsoluteTransform(),this.getAbsoluteTransform()):this.getAbsoluteTransform().copyFrom(o);var l=this.children.length;h.invert();for(var u=0;u0&&(this._rightHandedSystem=!0,this._bendAxis.x=0,this._bendAxis.y=0,this._bendAxis.z=1),this._bone1.length){var n=this._bone1.getScale(),o=this._bone2.getScale();this._bone1Length=this._bone1.length*n.y*this.mesh.scaling.y,this._bone2Length=this._bone2.length*o.y*this.mesh.scaling.y}else if(this._bone1.children[0]){t.computeWorldMatrix(!0);var s=this._bone2.children[0].getAbsolutePosition(t),a=this._bone2.getAbsolutePosition(t),h=this._bone1.getAbsolutePosition(t);this._bone1Length=e.Vector3.Distance(s,a),this._bone2Length=e.Vector3.Distance(a,h)}this._bone1.getRotationMatrixToRef(e.Space.WORLD,t,this._bone1Mat),this.maxAngle=Math.PI,r&&(r.targetMesh&&(this.targetMesh=r.targetMesh,this.targetMesh.computeWorldMatrix(!0)),r.poleTargetMesh?(this.poleTargetMesh=r.poleTargetMesh,this.poleTargetMesh.computeWorldMatrix(!0)):r.poleTargetBone?this.poleTargetBone=r.poleTargetBone:this._bone1.getParent()&&(this.poleTargetBone=this._bone1.getParent()),r.poleTargetLocalOffset&&this.poleTargetLocalOffset.copyFrom(r.poleTargetLocalOffset),r.poleAngle&&(this.poleAngle=r.poleAngle),r.bendAxis&&this._bendAxis.copyFrom(r.bendAxis),r.maxAngle&&(this.maxAngle=r.maxAngle),r.slerpAmount&&(this.slerpAmount=r.slerpAmount))}return Object.defineProperty(t.prototype,"maxAngle",{get:function(){return this._maxAngle},set:function(e){this._setMaxAngle(e)},enumerable:!0,configurable:!0}),t.prototype._setMaxAngle=function(e){e<0&&(e=0),(e>Math.PI||void 0==e)&&(e=Math.PI),this._maxAngle=e;var t=this._bone1Length,i=this._bone2Length;this._maxReach=Math.sqrt(t*t+i*i-2*t*i*Math.cos(e))},t.prototype.update=function(){var t=this._bone1,i=this.targetPosition,r=this.poleTargetPosition,n=this._tmpMat1,o=this._tmpMat2;this.targetMesh&&i.copyFrom(this.targetMesh.getAbsolutePosition()),this.poleTargetBone?this.poleTargetBone.getAbsolutePositionFromLocalToRef(this.poleTargetLocalOffset,this.mesh,r):this.poleTargetMesh&&e.Vector3.TransformCoordinatesToRef(this.poleTargetLocalOffset,this.poleTargetMesh.getWorldMatrix(),r);var s=this._tmpVec1,a=this._tmpVec2,h=this._tmpVec3,c=this._tmpVec4,l=this._tmpVec5;t.getAbsolutePositionToRef(this.mesh,s),r.subtractToRef(s,l),0==l.x&&0==l.y&&0==l.z?l.y=1:l.normalize(),i.subtractToRef(s,c),c.normalize(),e.Vector3.CrossToRef(c,l,a),a.normalize(),e.Vector3.CrossToRef(c,a,h),h.normalize(),e.Matrix.FromXYZAxesToRef(h,c,a,n);var u=this._bone1Length,f=this._bone2Length,d=e.Vector3.Distance(s,i);this._maxReach>0&&(d=Math.min(this._maxReach,d));var p=(f*f+d*d-u*u)/(2*f*d),m=(d*d+u*u-f*f)/(2*d*u);p>1&&(p=1),m>1&&(m=1),p<-1&&(p=-1),m<-1&&(m=-1);var g=Math.acos(p),_=Math.acos(m),v=-g-_;this._rightHandedSystem?(e.Matrix.RotationYawPitchRollToRef(0,0,.5*Math.PI,o),o.multiplyToRef(n,n),e.Matrix.RotationAxisToRef(this._bendAxis,_,o),o.multiplyToRef(n,n)):(this._tmpVec1.copyFrom(this._bendAxis),this._tmpVec1.x*=-1,e.Matrix.RotationAxisToRef(this._tmpVec1,-_,o),o.multiplyToRef(n,n)),this.poleAngle&&(e.Matrix.RotationAxisToRef(c,this.poleAngle,o),n.multiplyToRef(o,n)),this.slerpAmount<1?(this._slerping||e.Quaternion.FromRotationMatrixToRef(this._bone1Mat,this._bone1Quat),e.Quaternion.FromRotationMatrixToRef(n,this._tmpQuat1),e.Quaternion.SlerpToRef(this._bone1Quat,this._tmpQuat1,this.slerpAmount,this._bone1Quat),v=this._bone2Ang*(1-this.slerpAmount)+v*this.slerpAmount,this._bone1.setRotationQuaternion(this._bone1Quat,e.Space.WORLD,this.mesh),this._slerping=!0):(this._bone1.setRotationMatrix(n,e.Space.WORLD,this.mesh),this._bone1Mat.copyFrom(n),this._slerping=!1),this._bone2.setAxisAngle(this._bendAxis,v,e.Space.LOCAL),this._bone2Ang=v},t})();e.BoneIKController=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(t,i,r,n){this.upAxis=e.Vector3.Up(),this.adjustYaw=0,this.adjustPitch=0,this.adjustRoll=0,this._tmpVec1=e.Vector3.Zero(),this._tmpVec2=e.Vector3.Zero(),this._tmpVec3=e.Vector3.Zero(),this._tmpVec4=e.Vector3.Zero(),this._tmpMat1=e.Matrix.Identity(),this._tmpMat2=e.Matrix.Identity(),this.mesh=t,this.bone=i,this.target=r,n&&(n.adjustYaw&&(this.adjustYaw=n.adjustYaw),n.adjustPitch&&(this.adjustPitch=n.adjustPitch),n.adjustRoll&&(this.adjustRoll=n.adjustRoll))}return t.prototype.update=function(){var t=this.bone,i=this.target,r=this._tmpVec1,n=this._tmpVec2,o=this._tmpVec3,s=this._tmpVec4,a=this._tmpMat1,h=this._tmpMat2;t.getAbsolutePositionToRef(this.mesh,r),i.subtractToRef(r,n),n.normalize(),e.Vector3.CrossToRef(this.upAxis,n,o),o.normalize(),e.Vector3.CrossToRef(n,o,s),s.normalize(),e.Matrix.FromXYZAxesToRef(o,s,n,a),(this.adjustYaw||this.adjustPitch||this.adjustRoll)&&(e.Matrix.RotationYawPitchRollToRef(this.adjustYaw,this.adjustPitch,this.adjustRoll,h),h.multiplyToRef(a,a)),this.bone.setRotationMatrix(a,e.Space.WORLD,this.mesh)},t})();e.BoneLookController=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._lastAbsoluteTransformsUpdateId=-1,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||this.prepare(),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;t-1&&this._meshesWithPoseMatrix.splice(t,1)},t.prototype._computeTransformMatrices=function(e,t){for(var i=0;i0&&(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-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;o0&&(e=this._meshesWithPoseMatrix[0].getPoseMatrix()),e},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;c0){for(var t=0;t0&&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)},t.prototype.directRender=function(e,t){for(var i=this._scene.getEngine(),r=0;r-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})();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,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:e<=0&&(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;ta?a:Math.floor(h);var c,l,u,f,d=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,p=[],m=[],g=[],_=[],v=[],y=[],x=[],b=[],A=[],T=[];if(r.length<2){var E=[],M=[];for(u=0;u0&&(O=P[f].subtract(P[f-1]).length(),D=O+x[l],v[l].push(D),x[l]=D),f++;o&&(f--,p.push(P[0].x,P[0].y,P[0].z),O=P[f].subtract(P[0]).length(),D=O+x[l],v[l].push(D),x[l]=D),A[l]=S+R,T[l]=C,C+=S+R}var I,L,w,B;for(u=0;u1?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;_++){for(var v=_/u,y=v*Math.PI*h,x=0;x<=f;x++){var b=x/f,A=b*Math.PI*2*a,T=e.Matrix.RotationZ(-y),E=e.Matrix.RotationY(A),M=e.Vector3.TransformCoordinates(e.Vector3.Up(),T),P=e.Vector3.TransformCoordinates(M,E),S=P.multiply(l),C=P.divide(l).normalize();p.push(S.x,S.y,S.z),m.push(C.x,C.y,C.z),g.push(b,v)}if(_>0)for(var R=p.length/3,O=R-2*(f+1);O+f+21?1:i.arc||1,f=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,d=i.faceUV||new Array(3),p=i.faceColors,m=1!==u&&l?2:0,g=c?h:1,_=2+(1+m)*g;for(r=0;r<_;r++)p&&void 0===p[r]&&(p[r]=new e.Color4(1,1,1,1));for(r=0;r<_;r++)d&&void 0===d[r]&&(d[r]=new e.Vector4(0,0,1,1));var v,y,x,b,A,T,E=[],M=[],P=[],S=[],C=[],R=2*Math.PI*u/a,O=(s-o)/2/n,D=e.Vector3.Zero(),I=e.Vector3.Zero(),L=e.Vector3.Zero(),w=e.Vector3.Zero(),B=e.Vector3.Zero(),F=e.Axis.Y,V=1,N=1,U=0,z=0;for(b=0;b<=h;b++)for(y=b/h,x=(y*(o-s)+s)/2,V=c&&0!==b&&b!==h?2:1,T=0;T0&&(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,m=0,g=0;for(g=0;g1?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;d=r.length?0:i.type||0,u=i.size,f=i.sizeX||u||1,d=i.sizeY||u||1,p=i.sizeZ||u||1,m=i.custom||r[l],g=m.face.length,_=i.faceUV||new Array(g),v=i.faceColors,y=void 0===i.flat||i.flat,x=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,b=[],A=[],T=[],E=[],M=[],P=0,S=0,C=[],R=0,O=0;if(y)for(O=0;O1)for(var h=0;hthis.value;case i.IsLesser:return this._effectiveTarget[this._property]-1&&this._scene._actionManagers.splice(e,1)},t.prototype.getScene=function(){return this._scene},t.prototype.hasSpecificTriggers=function(e){for(var t=0;t-1)return!0}return!1},t.prototype.hasSpecificTrigger=function(e){for(var t=0;t=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=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;r0;if(2===i.type?f.push(o):f.push(r),m){for(var g=new Array,_=0;_0){var f=u.properties[0].value,d=null===u.properties[0].targetType?f:n.getMeshByName(f);d._meshId&&(d.mesh=n.getMeshByID(d._meshId)),l={trigger:e.ActionManager[u.name],parameter:d}}else l=e.ActionManager[u.name];for(var p=0;p0&&(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){if(this.delayLoadState!==e.Engine.DELAYLOADSTATE_LOADING){if(this.isReady())return void(i&&i());this.delayLoadState=e.Engine.DELAYLOADSTATE_LOADING,this._queueLoad(t,i)}},t.prototype._queueLoad=function(t,i){var r=this;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;a0){for(var i=0;i0){for(var i=0;i0){for(var i=0;i0){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 m=new Float32Array(t,s.colorsAttrDesc.offset,s.colorsAttrDesc.count);i.setVerticesData(e.VertexBuffer.ColorKind,m,!1,s.colorsAttrDesc.stride)}if(s.matricesIndicesAttrDesc&&s.matricesIndicesAttrDesc.count>0){var g=new Int32Array(t,s.matricesIndicesAttrDesc.offset,s.matricesIndicesAttrDesc.count);i.setVerticesData(e.VertexBuffer.MatricesIndicesKind,g,!1)}if(s.matricesWeightsAttrDesc&&s.matricesWeightsAttrDesc.count>0){var _=new Float32Array(t,s.matricesWeightsAttrDesc.offset,s.matricesWeightsAttrDesc.count);i.setVerticesData(e.VertexBuffer.MatricesWeightsKind,_,!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>8),P.push((16711680&S)>>16),P.push(S>>24)}i.setVerticesData(e.VertexBuffer.MatricesIndicesKind,P,!1)}if(t.matricesIndicesExtra)if(t.matricesIndicesExtra._isExpanded)delete t.matricesIndices._isExpanded,i.setVerticesData(e.VertexBuffer.MatricesIndicesExtraKind,t.matricesIndicesExtra,!1);else{for(var P=[],x=0;x>8),P.push((16711680&S)>>16),P.push(S>>24)}i.setVerticesData(e.VertexBuffer.MatricesIndicesExtraKind,P,!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 C=0;Cthis._maxX||tthis._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,!(ethis._maxX||tthis._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=(this._subdivisionsX,this._subdivisionsY,Math.floor((e+this._maxX)*this._subdivisionsX/this._width)),n=Math.floor(-(t+this._maxZ)*this._subdivisionsY/this._height+this._subdivisionsY),o=this._heightQuads[n*this._subdivisionsX+r];return i=t0&&(c=!0,this._soundLoaded(i));break;case"String":h.push(i);case"Array":0===h.length&&(h=i);for(var l=0;l0&&(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.prototype.serialize=function(){var e={name:this.name,url:this.name,autoplay:this.autoplay,loop:this.loop,volume:this._volume,spatialSound:this.spatialSound,maxDistance:this.maxDistance,rolloffFactor:this.rolloffFactor,refDistance:this.refDistance,distanceModel:this.distanceModel,playbackRate:this._playbackRate,panningModel:this._panningModel,soundTrackId:this.soundTrackId};return this.spatialSound&&(this._connectedMesh&&(e.connectedMeshId=this._connectedMesh.id),e.position=this._position.asArray(),e.refDistance=this.refDistance,e.distanceModel=this.distanceModel,e.isDirectional=this._isDirectional,e.localDirectionToMesh=this._localDirection.asArray(),e.coneInnerAngle=this._coneInnerAngle,e.coneOuterAngle=this._coneOuterAngle,e.coneOuterGain=this._coneOuterGain),e},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&&(t.soundTrackId===-1?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);t!==-1&&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;t4&&(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 u=n.join("\n");return this._cachedDefines!==u&&(this._cachedDefines=u,this._glowMapGenerationEffect=this._scene.getEngine().createEffect("glowMapGeneration",o,["world","mBones","viewProjection","diffuseMatrix","color","emissiveMatrix"],["diffuseSampler","emissiveSampler"],u)),this._glowMapGenerationEffect.isReady()},i.prototype.render=function(){var t=this._glowMapMergeEffect;if(t.isReady()&&this._blurTexture.isReady()){var i=this._scene.getEngine();this.onBeforeComposeObservable.notifyObservers(this),i.enableEffect(t),i.setState(!1);var r=i.getStencilBuffer(),n=i.getStencilFunction(),o=i.getStencilMask(),s=i.getAlphaMode();t.setTexture("textureSampler",this._blurTexture),i.bindBuffers(this._vertexBuffers,this._indexBuffer,t),i.setAlphaMode(this._options.alphaBlendingMode),i.setStencilMask(0),i.setStencilBuffer(!0),i.setStencilFunctionReference(this._instanceGlowingMeshStencilReference),this.outerGlow&&(t.setFloat("offset",0),i.setStencilFunction(e.Engine.NOTEQUAL),i.draw(!0,0,6)),this.innerGlow&&(t.setFloat("offset",1),i.setStencilFunction(e.Engine.EQUAL),i.draw(!0,0,6)),i.setStencilFunction(n),i.setStencilMask(o),i.setAlphaMode(s),i.setStencilBuffer(r),this.onAfterComposeObservable.notifyObservers(this);var a=this._mainTexture.getSize();this.setMainTextureSize(),a.width===this._mainTextureDesiredSize.width&&a.height===this._mainTextureDesiredSize.height||(this.onSizeChangedObservable.notifyObservers(this),this.disposeTextureAndPostProcesses(),this.createTextureAndPostProcesses())}},i.prototype.addExcludedMesh=function(e){var t=this._excludedMeshes[e.uniqueId];t||(this._excludedMeshes[e.uniqueId]={mesh:e,beforeRender:e.onBeforeRenderObservable.add((function(e){e.getEngine().setStencilBuffer(!1)})),afterRender:e.onAfterRenderObservable.add((function(e){e.getEngine().setStencilBuffer(!0)}))})},i.prototype.removeExcludedMesh=function(e){var t=this._excludedMeshes[e.uniqueId];t&&(e.onBeforeRenderObservable.remove(t.beforeRender),e.onAfterRenderObservable.remove(t.afterRender)),this._excludedMeshes[e.uniqueId]=void 0},i.prototype.addMesh=function(e,t,i){var r=this;void 0===i&&(i=!1);var n=this._meshes[e.uniqueId];n?n.color=t:this._meshes[e.uniqueId]={mesh:e,color:t,observerHighlight:e.onBeforeRenderObservable.add((function(e){r._excludedMeshes[e.uniqueId]?r.defaultStencilReference(e):e.getScene().getEngine().setStencilFunctionReference(r._instanceGlowingMeshStencilReference)})),observerDefault:e.onAfterRenderObservable.add(this.defaultStencilReference),glowEmissiveOnly:i},this._shouldRender=!0},i.prototype.removeMesh=function(e){var t=this._meshes[e.uniqueId];t&&(e.onBeforeRenderObservable.remove(t.observerHighlight),e.onAfterRenderObservable.remove(t.observerDefault)),this._meshes[e.uniqueId]=void 0,this._shouldRender=!1;for(var i in this._meshes)if(i){this._shouldRender=!0;break}},i.prototype.shouldRender=function(){return this.isEnabled&&this._shouldRender},i.prototype.setMainTextureSize=function(){this._options.mainTextureFixedSize?(this._mainTextureDesiredSize.width=this._options.mainTextureFixedSize,this._mainTextureDesiredSize.height=this._options.mainTextureFixedSize):(this._mainTextureDesiredSize.width=this._engine.getRenderingCanvas().width*this._options.mainTextureRatio,this._mainTextureDesiredSize.height=this._engine.getRenderingCanvas().height*this._options.mainTextureRatio,this._mainTextureDesiredSize.width=e.Tools.GetExponentOfTwo(this._mainTextureDesiredSize.width,this._maxSize),this._mainTextureDesiredSize.height=e.Tools.GetExponentOfTwo(this._mainTextureDesiredSize.height,this._maxSize))},i.prototype.defaultStencilReference=function(e){e.getScene().getEngine().setStencilFunctionReference(i.normalMeshStencilReference)},i.prototype.disposeTextureAndPostProcesses=function(){this._blurTexture.dispose(),this._mainTexture.dispose(),this._downSamplePostprocess.dispose(),this._horizontalBlurPostprocess.dispose(),this._verticalBlurPostprocess.dispose()},i.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.disposeTextureAndPostProcesses();for(var i in this._meshes){var r=this._meshes[i];r&&r.mesh&&(r.mesh.onBeforeRenderObservable.remove(r.observerHighlight),r.mesh.onAfterRenderObservable.remove(r.observerDefault))}this._meshes=null;for(var i in this._excludedMeshes){var r=this._excludedMeshes[i];r&&(r.mesh.onBeforeRenderObservable.remove(r.beforeRender),r.mesh.onAfterRenderObservable.remove(r.afterRender))}this._excludedMeshes=null;var n=this._scene.highlightLayers.indexOf(this,0);n>-1&&this._scene.highlightLayers.splice(n,1),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this.onBeforeRenderMainTextureObservable.clear(),this.onBeforeBlurObservable.clear(),this.onBeforeComposeObservable.clear(),this.onAfterComposeObservable.clear(),this.onSizeChangedObservable.clear()},i})();i.neutralColor=new e.Color4(0,0,0,0),i.glowingMeshStencilReference=2,i.normalMeshStencilReference=1,e.HighlightLayer=i})(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\n\n#include[0..maxSimultaneousLights]\n#include\n#include\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\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\n#ifdef REFLECTIONFRESNEL\nuniform vec4 reflectionLeftColor;\nuniform vec4 reflectionRightColor;\n#endif\n#endif\n#ifdef CAMERACOLORGRADING\n#include \n#include\n#endif\n#ifdef CAMERACOLORCURVES\n#include\n#include\n#endif\n#include\n#include\n#include\n#include\nvoid main(void) {\n#include\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#include\n#ifdef DIFFUSE\nbaseColor=texture2D(diffuseSampler,vDiffuseUV+uvOffset);\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+uvOffset).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+uvOffset);\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#ifdef LIGHTMAP\nvec3 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset).rgb*vLightmapInfos.y;\n#endif\n#include[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+uvOffset);\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+uvOffset).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\n#ifdef LIGHTMAP\n#ifndef LIGHTMAPEXCLUDED\n#ifdef USELIGHTMAPASSHADOWMAP\ncolor.rgb*=lightmapColor;\n#else\ncolor.rgb+=lightmapColor;\n#endif\n#endif\n#endif\n#include\n#include\n#ifdef CAMERACOLORGRADING\ncolor=colorGrades(color);\n#endif\n#ifdef CAMERACOLORCURVES\ncolor.rgb=applyColorCurves(color.rgb);\n#endif\ngl_FragColor=color;\n}", +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){e!==-1?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=t.indexOf(".babylon")!==-1?"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=t.indexOf(".babylon")!==-1?"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&&(o.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})();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 e.indexOf("http:/")===-1?t.parseURL(window.location.href)+e:e},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++],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);n>t._ORIGIN_SHIFT){default:case t._ORIGIN_UL:y=0,b=1,E=o.width,x=0,A=1,T=o.height;break;case t._ORIGIN_BL:y=0,b=1,E=o.width,x=o.height-1,A=-1,T=-1;break;case t._ORIGIN_UR:y=o.width-1,b=-1,E=-1,x=0,A=1,T=o.height;break;case t._ORIGIN_BR:y=o.width-1,b=-1,E=-1,x=o.height-1,A=-1,T=-1}var M="_getImageData"+(c?"Grey":"")+o.pixel_size+"bits",P=t[M](o,u,l,x,A,T,y,b,E);i.texImage2D(i.TEXTURE_2D,0,i.RGBA,o.width,o.height,0,i.RGBA,i.UNSIGNED_BYTE,P)},t._getImageData8bits=function(e,t,i,r,n,o,s,a,h){var c,l,u,f=i,d=t,p=e.width,m=e.height,g=0,_=new Uint8Array(p*m*4);for(u=r;u!==o;u+=n)for(l=s;l!==h;l+=a,g++)c=f[g],_[4*(l+p*u)+3]=255,_[4*(l+p*u)+2]=d[3*c+0],_[4*(l+p*u)+1]=d[3*c+1],_[4*(l+p*u)+0]=d[3*c+2];return _},t._getImageData16bits=function(e,t,i,r,n,o,s,a,h){var c,l,u,f=i,d=e.width,p=e.height,m=0,g=new Uint8Array(d*p*4);for(u=r;u!==o;u+=n)for(l=s;l!==h;l+=a,m+=2)c=f[m+0]+(f[m+1]<<8),g[4*(l+d*u)+0]=(31744&c)>>7,g[4*(l+d*u)+1]=(992&c)>>2,g[4*(l+d*u)+2]=(31&c)>>3,g[4*(l+d*u)+3]=32768&c?0:255;return g},t._getImageData24bits=function(e,t,i,r,n,o,s,a,h){var c,l,u=i,f=e.width,d=e.height,p=0,m=new Uint8Array(f*d*4);for(l=r;l!==o;l+=n)for(c=s;c!==h;c+=a,p+=3)m[4*(c+f*l)+3]=255,m[4*(c+f*l)+2]=u[p+0],m[4*(c+f*l)+1]=u[p+1],m[4*(c+f*l)+0]=u[p+2];return m},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,m=new Uint8Array(f*d*4);for(l=r;l!==o;l+=n)for(c=s;c!==h;c+=a,p+=4)m[4*(c+f*l)+2]=u[p+0],m[4*(c+f*l)+1]=u[p+1],m[4*(c+f*l)+0]=u[p+2],m[4*(c+f*l)+3]=u[p+3];return m},t._getImageDataGrey8bits=function(e,t,i,r,n,o,s,a,h){var c,l,u,f=i,d=e.width,p=e.height,m=0,g=new Uint8Array(d*p*4);for(u=r;u!==o;u+=n)for(l=s;l!==h;l+=a,m++)c=f[m],g[4*(l+d*u)+0]=c,g[4*(l+d*u)+1]=c,g[4*(l+d*u)+2]=c,g[4*(l+d*u)+3]=255;return g},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,m=new Uint8Array(f*d*4);for(l=r;l!==o;l+=n)for(c=s;c!==h;c+=a,p+=2)m[4*(c+f*l)+0]=u[p+0],m[4*(c+f*l)+1]=u[p+0],m[4*(c+f*l)+2]=u[p+0],m[4*(c+f*l)+3]=u[p+1];return m},t})();i._TYPE_NO_DATA=0,i._TYPE_INDEXED=1,i._TYPE_RGB=2,i._TYPE_GREY=3,i._TYPE_RLE_INDEXED=9,i._TYPE_RLE_RGB=10,i._TYPE_RLE_GREY=11,i._ORIGIN_MASK=48,i._ORIGIN_SHIFT=4,i._ORIGIN_BL=0,i._ORIGIN_BR=1,i._ORIGIN_UL=2,i._ORIGIN_UR=3,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)&&(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;tthis.data.length&&(this.data.length=2*(this.length+e.length));for(var t=0;t=this.length?-1:t},e})();t._GlobalId=0,e.SmartArray=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(){this._count=0,this._data={}}return e.prototype.copyFrom=function(e){var t=this;this.clear(),e.forEach((function(e,i){return t.add(e,i)}))},e.prototype.get=function(e){var t=this._data[e];if(void 0!==t)return t},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]&&(this._data[e]=t,++this._count,!0)},e.prototype.set=function(e,t){return void 0!==this._data[e]&&(this._data[e]=t,!0)},e.prototype.getAndRemove=function(e){var t=this.get(e);return void 0!==t?(delete this._data[e],--this._count,t):null},e.prototype.remove=function(e){return!!this.contains(e)&&(delete this._data[e],--this._count,!0)},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,t){return function(i){i.__bjsclassName__=e,i.__bjsmoduleName__=null!=t?t:null}}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;rt&&(i=t),i},t.GetFilename=function(e){var t=e.lastIndexOf("/");return t<0?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>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;h=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){if(t===!0||void 0!==e&&null!=e)return Array.isArray(e)?e:[e]},t.GetPointerPrefix=function(){var e="pointer";return window.PointerEvent||navigator.pointerEnabled||(e="mouse"),e},t.QueueNewFrame=function(e,t){void 0===t&&(t=window),t.requestAnimationFrame?t.requestAnimationFrame(e):t.msRequestAnimationFrame?t.msRequestAnimationFrame(e):t.webkitRequestAnimationFrame?t.webkitRequestAnimationFrame(e):t.mozRequestAnimationFrame?t.mozRequestAnimationFrame(e):t.oRequestAnimationFrame?t.oRequestAnimationFrame(e):window.setTimeout(e,16)},t.RequestFullscreen=function(e){var t=e.requestFullscreen||e.msRequestFullscreen||e.webkitRequestFullscreen||e.mozRequestFullScreen;t&&t.call(e)},t.ExitFullscreen=function(){document.exitFullscreen?document.exitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitCancelFullScreen?document.webkitCancelFullScreen():document.msCancelFullScreen&&document.msCancelFullScreen()},t.SetCorsBehavior=function(e,i){if(t.CorsBehavior)switch(typeof t.CorsBehavior){case"function":var r=t.CorsBehavior(e);if(r)return r;break;case"string":default:i.crossOrigin=t.CorsBehavior}},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;"data:"!==i.substr(0,5)&&t.SetCorsBehavior(i,s),s.onload=function(){r(s)},s.onerror=function(e){t.Error("Error while trying to load image: "+i),t.UseFallbackTexture?(s.src=t.fallbackTexture,r(s)):n()};var a=function(){s.src=i},h=function(){o.loadImageFromDB(i,s)};if("data:"!==i.substr(0,5)&&o&&o.enableTexturesOffline&&e.Database.IsUASupportingBlobStorage)o.openAsync(h,a);else if(i.indexOf("file:")===-1)a();else{var c=i.substring(5).toLowerCase();if(e.FilesInput.FilesTextures[c])try{var l;try{l=URL.createObjectURL(e.FilesInput.FilesTextures[c],{oneTimeOnly:!0})}catch(u){l=URL.createObjectURL(e.FilesInput.FilesTextures[c])}s.src=l}catch(f){s.src=null}else t.Error("Image: "+c+" not found. Did you forget to provide it?"),s.src=t.fallbackTexture}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(e.onreadystatechange=null,e.status>=200&&e.status<300||navigator.isCocoonJS&&0===e.status)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(i.indexOf("file:")!==-1){var l=i.substring(5).toLowerCase();e.FilesInput.FilesToLoad[l]?t.ReadFile(e.FilesInput.FilesToLoad[l],r,n,s):t.Error("File: "+l+" not found. Did you forget to provide it?")}else o&&o.enableSceneOffline?o.openAsync(c,h):h()},t.LoadScript=function(e,t,i){var r=document.getElementsByTagName("head")[0],n=document.createElement("script");n.type="text/javascript",n.src=e;n.onload=function(){t&&t()},n.onerror=function(){i&&i()},r.appendChild(n)},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.xi.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&&n.indexOf(o)!==-1)&&(!i||i.indexOf(o)===-1)){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;hh&&(f=h,u=f*l);var d=Math.max(0,a-u)/2,p=Math.max(0,h-f)/2;c.fillStyle=r.getScene().clearColor.toHexString(),c.fillRect(0,0,a,h),c.drawImage(e.getRenderingCanvas(),d,p,u,f),t.EncodeScreenshotCanvasData(o,s)},t.CreateScreenshotUsingRenderTarget=function(i,r,n,o,s){void 0===s&&(s="image/png");var a,h;if(n.precision)a=Math.round(i.getRenderWidth()*n.precision),h=Math.round(a/i.getAspectRatio(r)),n={width:a,height:h};else if(n.width&&n.height)a=n.width,h=n.height;else if(n.width&&!n.height)a=n.width,h=Math.round(a/i.getAspectRatio(r)),n={width:a,height:h};else if(n.height&&!n.width)h=n.height,a=Math.round(h*i.getAspectRatio(r)),n={width:a,height:h};else{if(isNaN(n))return void t.Error("Invalid 'size' parameter !");h=n,a=n}var c=r.getScene(),l=null;c.activeCamera!==r&&(l=c.activeCamera,c.activeCamera=r);var u=new e.RenderTargetTexture("screenShot",n,c,(!1),(!1),e.Engine.TEXTURETYPE_UNSIGNED_INT,(!1),e.Texture.NEAREST_SAMPLINGMODE);u.renderList=c.meshes,u.onAfterRenderObservable.add((function(){t.DumpFramebuffer(a,h,i,o,s)})),c.incrementRenderId(),c.resetCachedMaterial(),u.render(!0),u.dispose(),l&&(c.activeCamera=l),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},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)}))},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 e<10?"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="
"+i+"

";t._AddLogEntry(r)},t._WarnDisabled=function(e){},t._WarnEnabled=function(e){var i=t._FormatMessage(e);console.warn("BJS - "+i);var r="
"+i+"

";t._AddLogEntry(r)},t._ErrorDisabled=function(e){},t._ErrorEnabled=function(e){t.errorsCount++;var i=t._FormatMessage(e);console.error("BJS - "+i);var r="
"+i+"

";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,r=e;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})();n.BaseUrl="",n.CorsBehavior="anonymous",n.UseFallbackTexture=!0,n.fallbackTexture="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",n._NoneLogLevel=0,n._MessageLogLevel=1,n._WarningLogLevel=2,n._ErrorLogLevel=4,n._LogCache="",n.errorsCount=0,n.Log=n._LogEnabled,n.Warn=n._WarnEnabled,n.Error=n._ErrorEnabled,n._PerformanceNoneLogLevel=0,n._PerformanceUserMarkLogLevel=1,n._PerformanceConsoleLogLevel=2,n._performance=window.performance,n.StartPerformanceCounter=n._StartPerformanceCounterDisabled,n.EndPerformanceCounter=n._EndPerformanceCounterDisabled,e.Tools=n;var o=(function(){function e(){this._startMonitoringTime=0,this._min=0,this._max=0,this._average=0,this._lastSecAverage=0,this._current=0,this._totalValueCount=0,this._totalAccumulated=0,this._lastSecAccumulated=0,this._lastSecTime=0,this._lastSecValueCount=0}return Object.defineProperty(e.prototype,"min",{get:function(){return this._min},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"max",{get:function(){return this._max},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"average",{get:function(){return this._average},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"lastSecAverage",{get:function(){return this._lastSecAverage},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"current",{get:function(){return this._current},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"total",{get:function(){return this._totalAccumulated},enumerable:!0,configurable:!0}),e.prototype.fetchNewFrame=function(){this._totalValueCount++,this._current=0,this._lastSecValueCount++},e.prototype.addCount=function(e,t){this._current+=e,t&&this._fetchResult()},e.prototype.beginMonitoring=function(){this._startMonitoringTime=n.Now},e.prototype.endMonitoring=function(e){void 0===e&&(e=!0),e&&this.fetchNewFrame();var t=n.Now;this._current=t-this._startMonitoringTime,e&&this._fetchResult()},e.prototype._fetchResult=function(){this._totalAccumulated+=this._current,this._lastSecAccumulated+=this._current,this._min=Math.min(this._min,this._current),this._max=Math.max(this._max,this._current),this._average=this._totalAccumulated/this._totalValueCount;var e=n.Now;e-this._lastSecTime>1e3&&(this._lastSecAverage=this._lastSecAccumulated/this._lastSecValueCount,this._lastSecTime=e,this._lastSecAccumulated=0,this._lastSecValueCount=0)},e})();e.PerfCounter=o,e.className=t;var s=(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=t)break;if(r(s),o&&o()){ +e.breakLoop();break}}e.executeNext()}),s)}),n)},e})();e.AsyncLoop=s})(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),this.reset()}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,this.reset()}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(t){var i=(function(){function t(){this._isStencilTestDirty=!1,this._isStencilMaskDirty=!1,this._isStencilFuncDirty=!1,this._isStencilOpDirty=!1,this.reset()}return Object.defineProperty(t.prototype,"isDirty",{get:function(){return this._isStencilTestDirty||this._isStencilMaskDirty||this._isStencilFuncDirty||this._isStencilOpDirty},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stencilFunc",{get:function(){return this._stencilFunc},set:function(e){this._stencilFunc!==e&&(this._stencilFunc=e,this._isStencilFuncDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stencilFuncRef",{get:function(){return this._stencilFuncRef},set:function(e){this._stencilFuncRef!==e&&(this._stencilFuncRef=e,this._isStencilFuncDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stencilFuncMask",{get:function(){return this._stencilFuncMask},set:function(e){this._stencilFuncMask!==e&&(this._stencilFuncMask=e,this._isStencilFuncDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stencilOpStencilFail",{get:function(){return this._stencilOpStencilFail},set:function(e){this._stencilOpStencilFail!==e&&(this._stencilOpStencilFail=e,this._isStencilOpDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stencilOpDepthFail",{get:function(){return this._stencilOpDepthFail},set:function(e){this._stencilOpDepthFail!==e&&(this._stencilOpDepthFail=e,this._isStencilOpDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stencilOpStencilDepthPass",{get:function(){return this._stencilOpStencilDepthPass},set:function(e){this._stencilOpStencilDepthPass!==e&&(this._stencilOpStencilDepthPass=e,this._isStencilOpDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stencilMask",{get:function(){return this._stencilMask},set:function(e){this._stencilMask!==e&&(this._stencilMask=e,this._isStencilMaskDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stencilTest",{get:function(){return this._stencilTest},set:function(e){this._stencilTest!==e&&(this._stencilTest=e,this._isStencilTestDirty=!0)},enumerable:!0,configurable:!0}),t.prototype.reset=function(){this._stencilTest=!1,this._stencilMask=255,this._stencilFunc=e.Engine.ALWAYS,this._stencilFuncRef=1,this._stencilFuncMask=255,this._stencilOpStencilFail=e.Engine.KEEP,this._stencilOpDepthFail=e.Engine.KEEP,this._stencilOpStencilDepthPass=e.Engine.REPLACE,this._isStencilTestDirty=!0,this._isStencilMaskDirty=!0,this._isStencilFuncDirty=!0,this._isStencilOpDirty=!0},t.prototype.apply=function(e){this.isDirty&&(this._isStencilTestDirty&&(this.stencilTest?e.enable(e.STENCIL_TEST):e.disable(e.STENCIL_TEST),this._isStencilTestDirty=!1),this._isStencilMaskDirty&&(e.stencilMask(this.stencilMask),this._isStencilMaskDirty=!1),this._isStencilFuncDirty&&(e.stencilFunc(this.stencilFunc,this.stencilFuncRef,this.stencilFuncMask),this._isStencilFuncDirty=!1),this._isStencilOpDirty&&(e.stencilOp(this.stencilOpStencilFail,this.stencilOpDepthFail,this.stencilOpStencilDepthPass),this._isStencilOpDirty=!1))},t})();t._StencilState=i})(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=36193,r=function(e,t){return t===l.TEXTURETYPE_FLOAT?e.FLOAT:t===l.TEXTURETYPE_HALF_FLOAT?i:e.UNSIGNED_BYTE},n=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}},o=function(t,i,r,o,s,a,h,c,l,u){void 0===u&&(u=e.Texture.TRILINEAR_SAMPLINGMODE);var f=r.getEngine(),d=e.Tools.GetExponentOfTwo(o,f.getCaps().maxTextureSize),p=e.Tools.GetExponentOfTwo(s,f.getCaps().maxTextureSize);f._bindTextureDirectly(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=d,t._height=p,t.isReady=!0,l(d,p);var m=n(u,!h,i);i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,m.mag),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,m.min),h||c||i.generateMipmap(i.TEXTURE_2D),f._bindTextureDirectly(i.TEXTURE_2D,null),f.resetTextureCache(),r._removePendingData(t),t.onLoadedCallbacks.forEach((function(e){e()})),t.onLoadedCallbacks=[]},s=function(t,i,r,n,o,s){void 0===s&&(s=null);var a,h=function(){r[i]=a,r._internalCount++,n._removePendingData(a),6===r._internalCount&&o(r)},c=function(){n._removePendingData(a),s&&s()};a=e.Tools.LoadImage(t,h,c,n.database),n._addPendingData(a)},a=function(e,t,i,r,n){void 0===n&&(n=null);var o=[];o._internalCount=0;for(var a=0;a<6;a++)s(r[a],a,o,t,i,n)},h=(function(){function e(){}return e})();e.InstancingAttributeInfo=h;var c=(function(){function e(){}return e})();e.EngineCapabilities=c;var l=(function(){function s(t,i,r,n){void 0===n&&(n=!1);var o=this;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._badOS=!1,this._drawCalls=new e.PerfCounter,this._renderingQueueLaunched=!1,this._activeRenderLoops=[],this.fpsRange=60,this.previousFramesDuration=[],this.fps=60,this.deltaTime=0,this._depthCullingState=new e.Internals._DepthCullingState,this._stencilState=new e.Internals._StencilState,this._alphaState=new e.Internals._AlphaState,this._alphaMode=s.ALPHA_DISABLE,this._loadedTexturesCache=new Array,this._maxTextureChannels=16,this._activeTexturesCache=new Array(this._maxTextureChannels),this._compiledEffects={},this._vertexAttribArraysEnabled=[],this._uintIndicesCurrentlySet=!1,this._currentBoundBuffer=new Array,this._currentBufferPointers=[],this._currentInstanceLocations=new Array,this._currentInstanceBuffers=new Array,this._texturesSupported=new Array,this._onVRFullScreenTriggered=function(){if(o._vrDisplayEnabled&&o._vrDisplayEnabled.isPresenting){o._oldSize=new e.Size(o.getRenderWidth(),o.getRenderHeight()),o._oldHardwareScaleFactor=o.getHardwareScalingLevel();var t=o._vrDisplayEnabled.getEyeParameters("left");o.setHardwareScalingLevel(1),o.setSize(2*t.renderWidth,t.renderHeight)}else o.setHardwareScalingLevel(o._oldHardwareScaleFactor),o.setSize(o._oldSize.width,o._oldSize.height),o._vrDisplayEnabled=void 0},this._renderingCanvas=t,this._externalData=new e.StringDictionary,r=r||{},null!=i&&(r.antialias=i),void 0===r.preserveDrawingBuffer&&(r.preserveDrawingBuffer=!1);var a=this._canRenderToFloatTexture(),h=this._canRenderToHalfFloatTexture();try{this._gl=t.getContext("webgl2",r)||t.getContext("experimental-webgl2",r),this._gl&&(this._webGLVersion="2.0")}catch(l){}if(!this._gl){if(!t)throw new Error("The provided canvas is null or undefined.");try{this._gl=t.getContext("webgl",r)||t.getContext("experimental-webgl",r)}catch(l){throw new Error("WebGL not supported")}}if(!this._gl)throw new Error("WebGL not supported");this._onBlur=function(){o._windowIsBackground=!0},this._onFocus=function(){o._windowIsBackground=!1},window.addEventListener("blur",this._onBlur),window.addEventListener("focus",this._onFocus);var u=r.limitDeviceRatio||window.devicePixelRatio||1;this._hardwareScalingLevel=n?1/Math.min(u,window.devicePixelRatio||1):1,this.resize(),this._isStencilEnable=r.stencil,this._caps=new c,this._caps.maxTexturesImageUnits=this._gl.getParameter(this._gl.MAX_TEXTURE_IMAGE_UNITS),this._caps.maxTextureSize=this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE),this._caps.maxCubemapTextureSize=this._gl.getParameter(this._gl.MAX_CUBE_MAP_TEXTURE_SIZE),this._caps.maxRenderTextureSize=this._gl.getParameter(this._gl.MAX_RENDERBUFFER_SIZE),this._caps.maxVertexAttribs=this._gl.getParameter(this._gl.MAX_VERTEX_ATTRIBS),this._caps.maxVaryingVectors=this._gl.getParameter(this._gl.MAX_VARYING_VECTORS),this._caps.maxFragmentUniformVectors=this._gl.getParameter(this._gl.MAX_FRAGMENT_UNIFORM_VECTORS),this._caps.maxVertexUniformVectors=this._gl.getParameter(this._gl.MAX_VERTEX_UNIFORM_VECTORS),this._glVersion=this._gl.getParameter(this._gl.VERSION);var f=this._gl.getExtension("WEBGL_debug_renderer_info");if(null!=f&&(this._glRenderer=this._gl.getParameter(f.UNMASKED_RENDERER_WEBGL),this._glVendor=this._gl.getParameter(f.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.astc=this._gl.getExtension("WEBGL_compressed_texture_astc"),this._caps.s3tc=this._gl.getExtension("WEBGL_compressed_texture_s3tc"),this._caps.pvrtc=this._gl.getExtension("WEBGL_compressed_texture_pvrtc")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),this._caps.etc1=this._gl.getExtension("WEBGL_compressed_texture_etc1"),this._caps.etc2=this._gl.getExtension("WEBGL_compressed_texture_etc")||this._gl.getExtension("WEBGL_compressed_texture_es3_0"),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._caps.textureFloatRender=a,this._caps.textureHalfFloat=null!==this._gl.getExtension("OES_texture_half_float"),this._caps.textureHalfFloatLinearFiltering=this._gl.getExtension("OES_texture_half_float_linear"),this._caps.textureHalfFloatRender=h,this._caps.astc&&this.texturesSupported.push(".astc"),this._caps.s3tc&&this.texturesSupported.push(".dds"),this._caps.pvrtc&&this.texturesSupported.push(".pvr"),this._caps.etc2&&this.texturesSupported.push(".etc2"),this._caps.etc1&&this.texturesSupported.push(".etc1"),this._gl.getShaderPrecisionFormat){var d=this._gl.getShaderPrecisionFormat(this._gl.FRAGMENT_SHADER,this._gl.HIGH_FLOAT);this._caps.highPrecisionShaderSupported=0!==d.precision}this.setDepthBuffer(!0),this.setDepthFunctionToLessOrEqual(),this.setDepthWrite(!0),this._onFullscreenChange=function(){void 0!==document.fullscreen?o.isFullscreen=document.fullscreen:void 0!==document.mozFullScreen?o.isFullscreen=document.mozFullScreen:void 0!==document.webkitIsFullScreen?o.isFullscreen=document.webkitIsFullScreen:void 0!==document.msIsFullScreen&&(o.isFullscreen=document.msIsFullScreen),o.isFullscreen&&o._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(){o.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&&!s.audioEngine&&(s.audioEngine=new e.AudioEngine),this._loadingScreen=new e.DefaultLoadingScreen(this._renderingCanvas),r.autoEnableWebVR&&this.initWebVR();var p=/AppleWebKit.*10.[\d] Mobile/;this._badOS=p.test(navigator.userAgent),e.Tools.Log("Babylon.js engine (v"+s.Version+") launched")}return Object.defineProperty(s,"NEVER",{get:function(){return s._NEVER},enumerable:!0,configurable:!0}),Object.defineProperty(s,"ALWAYS",{get:function(){return s._ALWAYS},enumerable:!0,configurable:!0}),Object.defineProperty(s,"LESS",{get:function(){return s._LESS},enumerable:!0,configurable:!0}),Object.defineProperty(s,"EQUAL",{get:function(){return s._EQUAL},enumerable:!0,configurable:!0}),Object.defineProperty(s,"LEQUAL",{get:function(){return s._LEQUAL},enumerable:!0,configurable:!0}),Object.defineProperty(s,"GREATER",{get:function(){return s._GREATER},enumerable:!0,configurable:!0}),Object.defineProperty(s,"GEQUAL",{get:function(){return s._GEQUAL},enumerable:!0,configurable:!0}),Object.defineProperty(s,"NOTEQUAL",{get:function(){return s._NOTEQUAL},enumerable:!0,configurable:!0}),Object.defineProperty(s,"KEEP",{get:function(){return s._KEEP},enumerable:!0,configurable:!0}),Object.defineProperty(s,"REPLACE",{get:function(){return s._REPLACE},enumerable:!0,configurable:!0}),Object.defineProperty(s,"INCR",{get:function(){return s._INCR},enumerable:!0,configurable:!0}),Object.defineProperty(s,"DECR",{get:function(){return s._DECR},enumerable:!0,configurable:!0}),Object.defineProperty(s,"INVERT",{get:function(){return s._INVERT},enumerable:!0,configurable:!0}),Object.defineProperty(s,"INCR_WRAP",{get:function(){return s._INCR_WRAP},enumerable:!0,configurable:!0}),Object.defineProperty(s,"DECR_WRAP",{get:function(){return s._DECR_WRAP},enumerable:!0,configurable:!0}),Object.defineProperty(s,"ALPHA_DISABLE",{get:function(){return s._ALPHA_DISABLE},enumerable:!0,configurable:!0}),Object.defineProperty(s,"ALPHA_ONEONE",{get:function(){return s._ALPHA_ONEONE},enumerable:!0,configurable:!0}),Object.defineProperty(s,"ALPHA_ADD",{get:function(){return s._ALPHA_ADD},enumerable:!0,configurable:!0}),Object.defineProperty(s,"ALPHA_COMBINE",{get:function(){return s._ALPHA_COMBINE},enumerable:!0,configurable:!0}),Object.defineProperty(s,"ALPHA_SUBTRACT",{get:function(){return s._ALPHA_SUBTRACT},enumerable:!0,configurable:!0}),Object.defineProperty(s,"ALPHA_MULTIPLY",{get:function(){return s._ALPHA_MULTIPLY},enumerable:!0,configurable:!0}),Object.defineProperty(s,"ALPHA_MAXIMIZED",{get:function(){return s._ALPHA_MAXIMIZED},enumerable:!0,configurable:!0}),Object.defineProperty(s,"ALPHA_PREMULTIPLIED",{get:function(){return s._ALPHA_PREMULTIPLIED},enumerable:!0,configurable:!0}),Object.defineProperty(s,"DELAYLOADSTATE_NONE",{get:function(){return s._DELAYLOADSTATE_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(s,"DELAYLOADSTATE_LOADED",{get:function(){return s._DELAYLOADSTATE_LOADED},enumerable:!0,configurable:!0}),Object.defineProperty(s,"DELAYLOADSTATE_LOADING",{get:function(){return s._DELAYLOADSTATE_LOADING},enumerable:!0,configurable:!0}),Object.defineProperty(s,"DELAYLOADSTATE_NOTLOADED",{get:function(){return s._DELAYLOADSTATE_NOTLOADED},enumerable:!0,configurable:!0}),Object.defineProperty(s,"TEXTUREFORMAT_ALPHA",{get:function(){return s._TEXTUREFORMAT_ALPHA},enumerable:!0,configurable:!0}),Object.defineProperty(s,"TEXTUREFORMAT_LUMINANCE",{get:function(){return s._TEXTUREFORMAT_LUMINANCE},enumerable:!0,configurable:!0}),Object.defineProperty(s,"TEXTUREFORMAT_LUMINANCE_ALPHA",{get:function(){return s._TEXTUREFORMAT_LUMINANCE_ALPHA},enumerable:!0,configurable:!0}),Object.defineProperty(s,"TEXTUREFORMAT_RGB",{get:function(){return s._TEXTUREFORMAT_RGB},enumerable:!0,configurable:!0}),Object.defineProperty(s,"TEXTUREFORMAT_RGBA",{get:function(){return s._TEXTUREFORMAT_RGBA},enumerable:!0,configurable:!0}),Object.defineProperty(s,"TEXTURETYPE_UNSIGNED_INT",{get:function(){return s._TEXTURETYPE_UNSIGNED_INT},enumerable:!0,configurable:!0}),Object.defineProperty(s,"TEXTURETYPE_FLOAT",{get:function(){return s._TEXTURETYPE_FLOAT},enumerable:!0,configurable:!0}),Object.defineProperty(s,"TEXTURETYPE_HALF_FLOAT",{get:function(){return s._TEXTURETYPE_HALF_FLOAT},enumerable:!0,configurable:!0}),Object.defineProperty(s,"Version",{get:function(){return"2.6-alpha"},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"texturesSupported",{get:function(){return this._texturesSupported},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"textureFormatInUse",{get:function(){return this._textureFormatInUse},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"webGLVersion",{get:function(){return this._webGLVersion},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"isStencilEnable",{get:function(){return this._isStencilEnable},enumerable:!0,configurable:!0}),s.prototype._prepareWorkingCanvas=function(){this._workingCanvas||(this._workingCanvas=document.createElement("canvas"),this._workingContext=this._workingCanvas.getContext("2d"))},s.prototype.resetTextureCache=function(){for(var e=0;e=0&&this._activeRenderLoops.splice(t,1)},s.prototype._renderLoop=function(){var t=!0;if(!this.renderEvenInBackground&&this._windowIsBackground&&(t=!1),t){this.beginFrame();for(var i=0;i0?e.Tools.QueueNewFrame(this._bindedRenderFunction,this._vrDisplayEnabled):this._renderingQueueLaunched=!1},s.prototype.runRenderLoop=function(t){this._activeRenderLoops.indexOf(t)===-1&&(this._activeRenderLoops.push(t),this._renderingQueueLaunched||(this._renderingQueueLaunched=!0,this._bindedRenderFunction=this._renderLoop.bind(this),e.Tools.QueueNewFrame(this._bindedRenderFunction)))},s.prototype.switchFullscreen=function(t){this.isFullscreen?e.Tools.ExitFullscreen():(this._pointerLockRequested=t,e.Tools.RequestFullscreen(this._renderingCanvas))},s.prototype.clear=function(e,t,i,r){void 0===r&&(r=!1),this.applyStates();var n=0;t&&e&&(this._gl.clearColor(e.r,e.g,e.b,e.a),n|=this._gl.COLOR_BUFFER_BIT),i&&(this._gl.clearDepth(1),n|=this._gl.DEPTH_BUFFER_BIT),r&&(this._gl.clearStencil(0),n|=this._gl.STENCIL_BUFFER_BIT),this._gl.clear(n)},s.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,!0),o.scissor(a[0],a[1],a[2],a[3]),s===!0?o.enable(o.SCISSOR_TEST):o.disable(o.SCISSOR_TEST)},s.prototype.setViewport=function(e,t,i){var r=t||(navigator.isCocoonJS?window.innerWidth:this.getRenderWidth()),n=i||(navigator.isCocoonJS?window.innerHeight:this.getRenderHeight()),o=e.x||0,s=e.y||0;this._cachedViewport=e,this._gl.viewport(o*r,s*n,r*e.width,n*e.height)},s.prototype.setDirectViewport=function(e,t,i,r){var n=this._cachedViewport;return this._cachedViewport=null,this._gl.viewport(e,t,i,r),n},s.prototype.beginFrame=function(){this._measureFps()},s.prototype.endFrame=function(){this._badOS&&this.flushFramebuffer(),this._vrDisplayEnabled&&this._vrDisplayEnabled.isPresenting&&this._vrDisplayEnabled.submitFrame()},s.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)},s.prototype.setSize=function(e,t){this._renderingCanvas.width=e,this._renderingCanvas.height=t;for(var i=0;i65535){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},s.prototype.bindArrayBuffer=function(e){this.bindBuffer(e,this._gl.ARRAY_BUFFER)},s.prototype.bindIndexBuffer=function(e){this.bindBuffer(e,this._gl.ELEMENT_ARRAY_BUFFER)},s.prototype.bindBuffer=function(e,t){this._currentBoundBuffer[t]!==e&&(this._gl.bindBuffer(t,e),this._currentBoundBuffer[t]=e)},s.prototype.updateArrayBuffer=function(e){this._gl.bufferSubData(this._gl.ARRAY_BUFFER,0,e); +},s.prototype.vertexAttribPointer=function(e,t,i,r,n,o,s){var a=this._currentBufferPointers[t],h=!1;a?(a.buffer!==e&&(a.buffer=e,h=!0),a.size!==i&&(a.size=i,h=!0),a.type!==r&&(a.type=r,h=!0),a.normalized!==n&&(a.normalized=n,h=!0),a.stride!==o&&(a.stride=o,h=!0),a.offset!==s&&(a.offset=s,h=!0)):(h=!0,this._currentBufferPointers[t]={indx:t,size:i,type:r,normalized:n,stride:o,offset:s,buffer:e}),h&&(this.bindArrayBuffer(e),this._gl.vertexAttribPointer(t,i,r,n,o,s))},s.prototype.bindBuffersDirectly=function(e,t,i,r,n){if(this._cachedVertexBuffers!==e||this._cachedEffectForVertexBuffers!==n){this._cachedVertexBuffers=e,this._cachedEffectForVertexBuffers=n;var o=n.getAttributesCount();this.unbindAllAttributes();for(var s=0,a=0;a=0&&(this._gl.enableVertexAttribArray(h),this._vertexAttribArraysEnabled[h]=!0,this.vertexAttribPointer(e,h,i[a],this._gl.FLOAT,!1,r,s)),s+=4*i[a]}}this._cachedIndexBuffer!==t&&(this._cachedIndexBuffer=t,this.bindIndexBuffer(t),this._uintIndicesCurrentlySet=t.is32Bits)},s.prototype.bindBuffers=function(e,t,i){if(this._cachedVertexBuffers!==e||this._cachedEffectForVertexBuffers!==i){this._cachedVertexBuffers=e,this._cachedEffectForVertexBuffers=i;var r=i.getAttributesNames();this.unbindAllAttributes();for(var n=0;n=0){var s=e[r[n]];if(!s)continue;this._gl.enableVertexAttribArray(o),this._vertexAttribArraysEnabled[o]=!0;var a=s.getBuffer();this.vertexAttribPointer(a,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.bindIndexBuffer(t),this._uintIndicesCurrentlySet=t.is32Bits)},s.prototype.unbindInstanceAttributes=function(){for(var e,t=0,i=this._currentInstanceLocations.length;t1)&&!i&&a.width>>a.mipmapCount-1===1;o(f,l._gl,n,a.width,a.height,r,!h,a.isFourCC,(function(){e.Internals.DDSTools.UploadDDSLevels(l._gl,l.getCaps().s3tc,t,a,h,1)}),s)},d instanceof Array?v(c):e.Tools.LoadFile(t,(function(e){v(e)}),null,n.database,!0,y);else{var x=function(t){o(f,l._gl,n,t.width,t.height,r,i,!1,(function(i,r){var n=t.width===i&&t.height===r;n||(l._prepareWorkingCanvas(),l._workingCanvas.width=i,l._workingCanvas.height=r,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)}),s)};d instanceof Array?e.Tools.LoadImage(c,x,y,n.database):e.Tools.LoadImage(t,x,y,n.database)}return f},s.prototype._getInternalFormat=function(e){var t=this._gl.RGBA;switch(e){case s.TEXTUREFORMAT_ALPHA:t=this._gl.ALPHA;break;case s.TEXTUREFORMAT_LUMINANCE:t=this._gl.LUMINANCE;break;case s.TEXTUREFORMAT_LUMINANCE_ALPHA:t=this._gl.LUMINANCE_ALPHA;break;case s.TEXTUREFORMAT_RGB:t=this._gl.RGB;break;case s.TEXTUREFORMAT_RGBA:t=this._gl.RGBA}return t},s.prototype.updateRawTexture=function(e,t,i,r,n){void 0===n&&(n=null);var o=this._getInternalFormat(i);this._bindTextureDirectly(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._bindTextureDirectly(this._gl.TEXTURE_2D,null),this.resetTextureCache(),e.isReady=!0},s.prototype.createRawTexture=function(e,t,i,r,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,r,s,h),this._bindTextureDirectly(this._gl.TEXTURE_2D,c);var l=n(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),o&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(this._gl.TEXTURE_2D,null),c.samplingMode=a,this._loadedTexturesCache.push(c),c},s.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},s.prototype.updateTextureSamplingMode=function(e,t){var i=n(e,t.generateMipMaps,this._gl);t.isCube?(this._bindTextureDirectly(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._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null)):(this._bindTextureDirectly(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._bindTextureDirectly(this._gl.TEXTURE_2D,null))},s.prototype.updateDynamicTexture=function(e,t,i,r){void 0===r&&(r=!1),this._bindTextureDirectly(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._bindTextureDirectly(this._gl.TEXTURE_2D,null),r&&this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),this.resetTextureCache(),e.isReady=!0},s.prototype.updateVideoTexture=function(e,t,i){if(!e._isDisabled){this._bindTextureDirectly(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._bindTextureDirectly(this._gl.TEXTURE_2D,null),this.resetTextureCache(),e.isReady=!0}catch(r){e._isDisabled=!0}}},s.prototype.createRenderTargetTexture=function(t,i){var o=!1,a=!0,h=!1,c=s.TEXTURETYPE_UNSIGNED_INT,l=e.Texture.TRILINEAR_SAMPLINGMODE;void 0!==i&&(o=void 0===i.generateMipMaps?i:i.generateMipMaps,a=void 0===i.generateDepthBuffer||i.generateDepthBuffer,h=a&&i.generateStencilBuffer,c=void 0===i.type?c:i.type,void 0!==i.samplingMode&&(l=i.samplingMode),c!==s.TEXTURETYPE_FLOAT||this._caps.textureFloatLinearFiltering?c!==s.TEXTURETYPE_HALF_FLOAT||this._caps.textureHalfFloatLinearFiltering||(l=e.Texture.NEAREST_SAMPLINGMODE):l=e.Texture.NEAREST_SAMPLINGMODE);var u=this._gl,f=u.createTexture();this._bindTextureDirectly(u.TEXTURE_2D,f);var d=t.width||t,p=t.height||t,m=n(l,o,u);c!==s.TEXTURETYPE_FLOAT||this._caps.textureFloat||(c=s.TEXTURETYPE_UNSIGNED_INT,e.Tools.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type")),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_MAG_FILTER,m.mag),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_MIN_FILTER,m.min),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_WRAP_S,u.CLAMP_TO_EDGE),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_WRAP_T,u.CLAMP_TO_EDGE),u.texImage2D(u.TEXTURE_2D,0,u.RGBA,d,p,0,u.RGBA,r(u,c),null);var g;h?(g=u.createRenderbuffer(),u.bindRenderbuffer(u.RENDERBUFFER,g),u.renderbufferStorage(u.RENDERBUFFER,u.DEPTH_STENCIL,d,p)):a&&(g=u.createRenderbuffer(),u.bindRenderbuffer(u.RENDERBUFFER,g),u.renderbufferStorage(u.RENDERBUFFER,u.DEPTH_COMPONENT16,d,p));var _=u.createFramebuffer();return this.bindUnboundFramebuffer(_),h?u.framebufferRenderbuffer(u.FRAMEBUFFER,u.DEPTH_STENCIL_ATTACHMENT,u.RENDERBUFFER,g):a&&u.framebufferRenderbuffer(u.FRAMEBUFFER,u.DEPTH_ATTACHMENT,u.RENDERBUFFER,g),u.framebufferTexture2D(u.FRAMEBUFFER,u.COLOR_ATTACHMENT0,u.TEXTURE_2D,f,0),o&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(u.TEXTURE_2D,null),u.bindRenderbuffer(u.RENDERBUFFER,null),this.bindUnboundFramebuffer(null),f._framebuffer=_,a&&(f._depthBuffer=g),f._baseWidth=d,f._baseHeight=p,f._width=d,f._height=p,f.isReady=!0,f.generateMipMaps=o,f.references=1,f.samplingMode=l,f.type=c,this.resetTextureCache(),this._loadedTexturesCache.push(f),f},s.prototype.createRenderTargetCubeTexture=function(t,i){var r=this._gl,o=r.createTexture(),s=!0,a=!0,h=!1,c=e.Texture.TRILINEAR_SAMPLINGMODE;void 0!==i&&(s=void 0===i.generateMipMaps?i:i.generateMipMaps,a=void 0===i.generateDepthBuffer||i.generateDepthBuffer,h=a&&i.generateStencilBuffer,void 0!==i.samplingMode&&(c=i.samplingMode)),o.isCube=!0,o.references=1,o.generateMipMaps=s,o.references=1,o.samplingMode=c;var l=n(c,s,r);this._bindTextureDirectly(r.TEXTURE_CUBE_MAP,o);for(var u=0;u<6;u++)r.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+u,0,r.RGBA,t,t,0,r.RGBA,r.UNSIGNED_BYTE,null);r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_MAG_FILTER,l.mag),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_MIN_FILTER,l.min),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE);var f;h?(f=r.createRenderbuffer(),r.bindRenderbuffer(r.RENDERBUFFER,f),r.renderbufferStorage(r.RENDERBUFFER,r.DEPTH_STENCIL,t,t)):a&&(f=r.createRenderbuffer(),r.bindRenderbuffer(r.RENDERBUFFER,f),r.renderbufferStorage(r.RENDERBUFFER,r.DEPTH_COMPONENT16,t,t));var d=r.createFramebuffer();return this.bindUnboundFramebuffer(d),h?r.framebufferRenderbuffer(r.FRAMEBUFFER,r.DEPTH_STENCIL_ATTACHMENT,r.RENDERBUFFER,f):a&&r.framebufferRenderbuffer(r.FRAMEBUFFER,r.DEPTH_ATTACHMENT,r.RENDERBUFFER,f),o.generateMipMaps&&(this._bindTextureDirectly(r.TEXTURE_CUBE_MAP,o),r.generateMipmap(r.TEXTURE_CUBE_MAP)),this._bindTextureDirectly(r.TEXTURE_CUBE_MAP,null),r.bindRenderbuffer(r.RENDERBUFFER,null),this.bindUnboundFramebuffer(null),o._framebuffer=d,a&&(o._depthBuffer=f),o._width=t,o._height=t,o.isReady=!0,this.resetTextureCache(),this._loadedTexturesCache.push(o),o},s.prototype.createCubeTexture=function(t,i,r,n,o,s){var h=this;void 0===o&&(o=null),void 0===s&&(s=null);var c=this._gl,l=c.createTexture();l.isCube=!0,l.url=t,l.references=1,l.onLoadedCallbacks=[];var u=t.substr(t.length-4,4).toLowerCase(),f=this.getCaps().s3tc&&".dds"===u;return f?e.Tools.LoadFile(t,(function(t){var i=e.Internals.DDSTools.GetDDSInfo(t),r=(i.isRGB||i.isLuminance||i.mipmapCount>1)&&!n;h._bindTextureDirectly(c.TEXTURE_CUBE_MAP,l),c.pixelStorei(c.UNPACK_FLIP_Y_WEBGL,1),e.Internals.DDSTools.UploadDDSLevels(h._gl,h.getCaps().s3tc,t,i,r,6),n||i.isFourCC||1!==i.mipmapCount||c.generateMipmap(c.TEXTURE_CUBE_MAP),c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MAG_FILTER,c.LINEAR),c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MIN_FILTER,r?c.LINEAR_MIPMAP_LINEAR:c.LINEAR),c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE),c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE),h._bindTextureDirectly(c.TEXTURE_CUBE_MAP,null),h.resetTextureCache(),l._width=i.width,l._height=i.height,l.isReady=!0}),null,null,!0,s):a(t,i,(function(t){var i=e.Tools.GetExponentOfTwo(t[0].width,h._caps.maxCubemapTextureSize),r=i;h._prepareWorkingCanvas(),h._workingCanvas.width=i,h._workingCanvas.height=r;var s=[c.TEXTURE_CUBE_MAP_POSITIVE_X,c.TEXTURE_CUBE_MAP_POSITIVE_Y,c.TEXTURE_CUBE_MAP_POSITIVE_Z,c.TEXTURE_CUBE_MAP_NEGATIVE_X,c.TEXTURE_CUBE_MAP_NEGATIVE_Y,c.TEXTURE_CUBE_MAP_NEGATIVE_Z];h._bindTextureDirectly(c.TEXTURE_CUBE_MAP,l),c.pixelStorei(c.UNPACK_FLIP_Y_WEBGL,0);for(var a=0;a>y;f.texImage2D(o[0],y,p,x,x,0,p,m,a[y][0]),f.texImage2D(o[1],y,p,x,x,0,p,m,a[y][2]),f.texImage2D(o[2],y,p,x,x,0,p,m,a[y][4]),f.texImage2D(o[3],y,p,x,x,0,p,m,a[y][1]),f.texImage2D(o[4],y,p,x,x,0,p,m,a[y][3]),f.texImage2D(o[5],y,p,x,x,0,p,m,a[y][5])}}else{for(var b=0;b-1&&t.splice(i,1),this._releaseTexture(e)}},s.prototype.unbindAllAttributes=function(){for(var e=0,t=this._vertexAttribArraysEnabled.length;e=this._caps.maxVertexAttribs||!this._vertexAttribArraysEnabled[e]||this._vertexAttribArraysEnabled[e]&&(this._gl.disableVertexAttribArray(e),this._vertexAttribArraysEnabled[e]=!1)},s.prototype.dispose=function(){for(this.hideLoadingUI(),this.stopRenderLoop();this.scenes.length;)this.scenes[0].dispose();s.audioEngine.dispose();for(var e in this._compiledEffects)this._gl.deleteProgram(this._compiledEffects[e]._program);this.unbindAllAttributes(),this._gl=null,this.disableVR(),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)},s.prototype.displayLoadingUI=function(){this._loadingScreen.displayLoadingUI()},s.prototype.hideLoadingUI=function(){this._loadingScreen.hideLoadingUI()},Object.defineProperty(s.prototype,"loadingScreen",{get:function(){return this._loadingScreen},set:function(e){this._loadingScreen=e},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"loadingUIText",{set:function(e){this._loadingScreen.loadingUIText=e},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"loadingUIBackgroundColor",{set:function(e){this._loadingScreen.loadingUIBackgroundColor=e},enumerable:!0,configurable:!0}),s.prototype.attachContextLostEvent=function(e){this._renderingCanvas.addEventListener("webglcontextlost",e,!1)},s.prototype.attachContextRestoredEvent=function(e){this._renderingCanvas.addEventListener("webglcontextrestored",e,!1)},s.prototype.getVertexShaderSource=function(e){var t=this._gl.getAttachedShaders(e);return this._gl.getShaderSource(t[0])},s.prototype.getFragmentShaderSource=function(e){var t=this._gl.getAttachedShaders(e);return this._gl.getShaderSource(t[1])},s.prototype.getFps=function(){return this.fps},s.prototype.getDeltaTime=function(){return this.deltaTime},s.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;r0&&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;i0&&(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})();t.FilesTextures=new Array,t.FilesToLoad=new Array,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;t<6;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)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.xt.x-this.minimumWorld.x)&&(!(this.maximumWorld.y-t.yt.y-this.minimumWorld.y)&&!(this.maximumWorld.z-t.zt.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.xt.x)&&(!(this.maximumWorld.yt.y)&&!(this.maximumWorld.zt.z))},t.Intersects=function(e,t){return!(e.maximumWorld.xt.maximumWorld.x)&&(!(e.maximumWorld.yt.maximumWorld.y)&&!(e.maximumWorld.zt.maximumWorld.z))},t.IntersectsSphere=function(t,i,r,n){var o=e.Vector3.Clamp(r,t,i),s=e.Vector3.DistanceSquared(r,o);return s<=n*n},t.IsCompletelyInFrustum=function(e,t){for(var i=0;i<6;i++)for(var r=0;r<8;r++)if(t[i].dotCoordinate(e[r])<0)return!1;return!0},t.IsInFrustum=function(e,t){for(var i=0;i<6;i++){for(var r=8,n=0;n<8&&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)},t.prototype.isCompletelyInFrustum=function(e){return this.boundingBox.isCompletelyInFrustum(e)},t.prototype._checkCollision=function(e){return e._canDoCollision(this.boundingSphere.centerWorld,this.boundingSphere.radiusWorld,this.boundingBox.minimumWorld,this.boundingBox.maximumWorld)},t.prototype.intersectsPoint=function(e){return!!this.boundingSphere.centerWorld&&(!!this.boundingSphere.intersectsPoint(e)&&!!this.boundingBox.intersectsPoint(e))},t.prototype.intersects=function(t,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))))))))))))))},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,this._show=!1}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.xt.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.yt.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.zt.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(n<=o)return!0;var s=t*this.direction.x+i*this.direction.y+r*this.direction.z;if(s<0)return!1;var a=n-s*s;return a<=o},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(s<0||s>1)return null;e.Vector3.CrossToRef(this._tvec,this._edge1,this._qvec);var a=e.Vector3.Dot(this.direction,this._qvec)*o;if(a<0||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,i<0?i<-9.99999997475243e-7?null:0:i},t.prototype.intersectsMesh=function(i,r){var n=e.Tmp.Matrix[0];return i.getWorldMatrix().invertToRef(n),this._tmpRay?t.TransformToRef(this,n,this._tmpRay):this._tmpRay=t.Transform(this,n),i.intersects(this._tmpRay,r)},t.prototype.show=function(t,i){this._show||(this._renderFunction=this._render.bind(this),this._show=!0,this._scene=t,this._renderPoints=[this.origin,this.origin.add(this.direction.scale(this.length))],this._renderLine=e.Mesh.CreateLines("ray",this._renderPoints,t,!0),this._scene.registerBeforeRender(this._renderFunction)),i&&this._renderLine.color.copyFrom(i)},t.prototype.hide=function(){this._show&&(this._show=!1,this._scene.unregisterBeforeRender(this._renderFunction)),this._renderLine&&(this._renderLine.dispose(),this._renderLine=null,this._renderPoints=null)},t.prototype._render=function(){var t=this._renderPoints[1];t.copyFrom(this.direction),t.scaleInPlace(this.length),t.addInPlace(this.origin),e.Mesh.CreateLines("ray",this._renderPoints,this._scene,!0,this._renderLine)},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),m=e.Vector3.Dot(u,u),g=e.Vector3.Dot(l,f),_=e.Vector3.Dot(u,f),v=d*m-p*p,y=v,x=v;vy&&(s=y,h=_+p,x=m)),h<0?(h=0,-g<0?s=0:-g>d?s=y:(s=-g,y=d)):h>x&&(h=x,-g+p<0?s=0:-g+p>d?s=y:(s=-g+p,y=d)),o=Math.abs(s)0&&a<=this.length&&A.lengthSquared()e.Engine.CollisionsEpsilon&&o.position.addInPlace(o._diffPositionForCollisions),r&&o.onCollideObservable.notifyObservers(r),o.onCollisionPositionChangeObservable.notifyObservers(o.position)},n.addMesh(o),o}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,"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.getClassName=function(){return"AbstractMesh"},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)},i.prototype.setBoundingInfo=function(e){this._boundingInfo=e},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,r,n){t.normalize(),this.rotationQuaternion||(this.rotationQuaternion=e.Quaternion.RotationYawPitchRoll(this.rotation.y,this.rotation.x,this.rotation.z),this.rotation=e.Vector3.Zero());var o;if(n&&n!==e.Space.LOCAL){if(this.parent){var s=this.parent.getWorldMatrix().clone();s.invert(),t=e.Vector3.TransformNormal(t,s)}o=e.Quaternion.RotationAxisToRef(t,r,i._rotationAxisCache),o.multiplyToRef(this.rotationQuaternion,this.rotationQuaternion)}else o=e.Quaternion.RotationAxisToRef(t,r,i._rotationAxisCache),this.rotationQuaternion.multiplyToRef(o,this.rotationQuaternion)},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(){return!this._isDirty&&(this.billboardMode===this._cache.billboardMode&&this.billboardMode===i.BILLBOARDMODE_NONE&&(!this._cache.pivotMatrixUpdated&&(!this.infiniteDistance&&(!!this._cache.position.equals(this.position)&&(!(this.rotationQuaternion&&!this._cache.rotationQuaternion.equals(this.rotationQuaternion))&&(!!this._cache.rotation.equals(this.rotation)&&!!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;t1&&!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;c1)||l.canIntersects(t)){var u=l.intersects(t,this._positions,this.getIndices(),i);if(u&&(i||!s||u.distance0&&this.includedOnlyMeshes.indexOf(e)===-1)&&(!(this.excludedMeshes.length>0&&this.excludedMeshes.indexOf(e)!==-1)&&((0===this.includeOnlyWithLayerMask||0!==(this.includeOnlyWithLayerMask&e.layerMask))&&!(0!==this.excludeWithLayerMask&&this.excludeWithLayerMask&e.layerMask)))},i.prototype.getWorldMatrix=function(){this._currentRenderId=this.getScene().getRenderId();var t=this._getWorldMatrix();return this.parent&&this.parent.getWorldMatrix?(this._parentedWorldMatrix||(this._parentedWorldMatrix=e.Matrix.Identity()),t.multiplyToRef(this.parent.getWorldMatrix(),this._parentedWorldMatrix),this._markSyncedWithParent(),this._parentedWorldMatrix):t},i.prototype.dispose=function(){this._shadowGenerator&&(this._shadowGenerator.dispose(),this._shadowGenerator=null),this.getScene().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;othis._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)},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},i})(e.Light);__decorate([e.serializeAsVector3()],t.prototype,"position",void 0),__decorate([e.serializeAsVector3()],t.prototype,"direction",void 0),__decorate([e.serialize()],t.prototype,"shadowOrthoScale",void 0),__decorate([e.serialize()],t.prototype,"autoUpdateExtends",void 0),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._useFullFloat=!0,this._light=r,this._scene=r.getScene(),this._mapSize=i,r._shadowGenerator=this;var o,s=this._scene.getEngine().getCaps();s.textureFloat&&s.textureFloatLinearFiltering&&s.textureFloatRender?(this._useFullFloat=!0,o=e.Engine.TEXTURETYPE_FLOAT):(this._useFullFloat=!1,o=e.Engine.TEXTURETYPE_UNSIGNED_INT),this._shadowMap=new e.RenderTargetTexture(r.name+"_shadowMap",i,this._scene,(!1),(!0),o,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),(!0),o),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 a=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;r4&&(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 h=r.join("\n");return this._cachedDefines!==h&&(this._cachedDefines=h,this._effect=this._scene.getEngine().createEffect("shadowMap",n,["world","mBones","viewProjection","diffuseMatrix","lightPosition","depthValues"],["diffuseSampler"],h)),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:e<=0?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;ti.x+r)&&(!(i.x-r>t.x)&&(!(e.y>i.y+r)&&(!(i.y-r>t.y)&&(!(e.z>i.z+r)&&!(i.z-r>t.z)))))},i=(function(){var e={root:0,found:!1};return function(t,i,r,n){e.root=0,e.found=!1;var o=i*i-4*t*r;if(o<0)return e;var s=Math.sqrt(o),a=(-i-s)/(2*t),h=(-i+s)/(2*t);if(a>h){var c=h;h=a,a=c}return a>0&&a0&&h=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)&&!!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||d<0)return;h<0&&(h=0),h>1&&(h=1)}this._collisionPoint.copyFromFloats(0,0,0);var m=!1,g=1;if(c||(this.basePoint.subtractToRef(l.normal,this._planeIntersectionPoint),this.velocity.scaleToRef(h,this._tempVector),this._planeIntersectionPoint.addInPlace(this._tempVector),this._checkPointInTriangle(this._planeIntersectionPoint,n,o,s,l.normal)&&(m=!0,g=h,this._collisionPoint.copyFrom(this._planeIntersectionPoint))),!m){var _=this.velocity.lengthSquared(),v=_;this.basePoint.subtractToRef(n,this._tempVector);var y=2*e.Vector3.Dot(this.velocity,this._tempVector),x=this._tempVector.lengthSquared()-1,b=i(v,y,x,g);b.found&&(g=b.root,m=!0,this._collisionPoint.copyFrom(n)),this.basePoint.subtractToRef(o,this._tempVector),y=2*e.Vector3.Dot(this.velocity,this._tempVector),x=this._tempVector.lengthSquared()-1,b=i(v,y,x,g),b.found&&(g=b.root,m=!0,this._collisionPoint.copyFrom(o)),this.basePoint.subtractToRef(s,this._tempVector),y=2*e.Vector3.Dot(this.velocity,this._tempVector),x=this._tempVector.lengthSquared()-1,b=i(v,y,x,g),b.found&&(g=b.root,m=!0,this._collisionPoint.copyFrom(s)),o.subtractToRef(n,this._edge),n.subtractToRef(this.basePoint,this._baseToVertex);var A=this._edge.lengthSquared(),T=e.Vector3.Dot(this._edge,this.velocity),E=e.Vector3.Dot(this._edge,this._baseToVertex);if(v=A*-_+T*T,y=A*(2*e.Vector3.Dot(this.velocity,this._baseToVertex))-2*T*E,x=A*(1-this._baseToVertex.lengthSquared())+E*E,b=i(v,y,x,g),b.found){var M=(T*b.root-E)/A;M>=0&&M<=1&&(g=b.root,m=!0,this._edge.scaleInPlace(M),n.addToRef(this._edge,this._collisionPoint))}s.subtractToRef(o,this._edge),o.subtractToRef(this.basePoint,this._baseToVertex),A=this._edge.lengthSquared(),T=e.Vector3.Dot(this._edge,this.velocity),E=e.Vector3.Dot(this._edge,this._baseToVertex),v=A*-_+T*T,y=A*(2*e.Vector3.Dot(this.velocity,this._baseToVertex))-2*T*E,x=A*(1-this._baseToVertex.lengthSquared())+E*E,b=i(v,y,x,g),b.found&&(M=(T*b.root-E)/A,M>=0&&M<=1&&(g=b.root,m=!0,this._edge.scaleInPlace(M),o.addToRef(this._edge,this._collisionPoint))),n.subtractToRef(s,this._edge),s.subtractToRef(this.basePoint,this._baseToVertex),A=this._edge.lengthSquared(),T=e.Vector3.Dot(this._edge,this.velocity),E=e.Vector3.Dot(this._edge,this._baseToVertex),v=A*-_+T*T,y=A*(2*e.Vector3.Dot(this.velocity,this._baseToVertex))-2*T*E,x=A*(1-this._baseToVertex.lengthSquared())+E*E,b=i(v,y,x,g),b.found&&(M=(T*b.root-E)/A,M>=0&&M<=1&&(g=b.root,m=!0,this._edge.scaleInPlace(M),s.addToRef(this._edge,this._collisionPoint)))}if(m){var P=g*this.velocity.length();(!this.collisionFound||P4)){++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})();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()||[])}},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;h0&&this._postProcesses[0].markTextureDirty();for(var t=0,i=this._rigCameras.length;t-1?(e.Tools.Error("You're trying to reuse a post process not defined as reusable."),0):(null==i||i<0?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);o!==-1&&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._refreshFrustumPlanes=!0,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.freezeProjectionMatrix=function(e){this._doNotComputeProjectionMatrix=!0,void 0!==e&&(this._projectionMatrix=e)},i.prototype.unfreezeProjectionMatrix=function(){this._doNotComputeProjectionMatrix=!1},i.prototype.getProjectionMatrix=function(t){if(this._doNotComputeProjectionMatrix||!t&&this._isSynchronizedProjectionMatrix())return this._projectionMatrix;this._refreshFrustumPlanes=!0;var r=this.getEngine(),n=this.getScene();if(this.mode===i.PERSPECTIVE_CAMERA)return this.minZ<=0&&(this.minZ=.1),n.useRightHandedSystem?e.Matrix.PerspectiveFovRHToRef(this.fov,r.getAspectRatio(this),this.minZ,this.maxZ,this._projectionMatrix,this.fovMode===i.FOVMODE_VERTICAL_FIXED):e.Matrix.PerspectiveFovLHToRef(this.fov,r.getAspectRatio(this),this.minZ,this.maxZ,this._projectionMatrix,this.fovMode===i.FOVMODE_VERTICAL_FIXED), +this._projectionMatrix;var o=r.getRenderWidth()/2,s=r.getRenderHeight()/2;return n.useRightHandedSystem?e.Matrix.OrthoOffCenterRHToRef(this.orthoLeft||-o,this.orthoRight||o,this.orthoBottom||-s,this.orthoTop||s,this.minZ,this.maxZ,this._projectionMatrix):e.Matrix.OrthoOffCenterLHToRef(this.orthoLeft||-o,this.orthoRight||o,this.orthoBottom||-s,this.orthoTop||s,this.minZ,this.maxZ,this._projectionMatrix),this._projectionMatrix},i.prototype.getTranformationMatrix=function(){return this._computedViewMatrix.multiplyToRef(this._projectionMatrix,this._transformMatrix),this._transformMatrix},i.prototype.updateFrustumPlanes=function(){this._refreshFrustumPlanes&&(this.getTranformationMatrix(),this._frustumPlanes?e.Frustum.GetPlanesToRef(this._transformMatrix,this._frustumPlanes):this._frustumPlanes=e.Frustum.GetPlanes(this._transformMatrix),this._refreshFrustumPlanes=!1)},i.prototype.isInFrustum=function(e){return this.updateFrustumPlanes(),e.isInFrustum(this._frustumPlanes)},i.prototype.isCompletelyInFrustum=function(e){return this.updateFrustumPlanes(),e.isCompletelyInFrustum(this._frustumPlanes)},i.prototype.dispose=function(){for(this.getScene().stopAnimation(this),this.getScene().removeCamera(this);this._rigCameras.length>0;)this._rigCameras.pop().dispose();for(var e=this._postProcesses.length;--e>=0;)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));break;case i.RIG_MODE_WEBVR:r.vrDisplay&&(this._rigCameras[0].viewport=new e.Viewport(0,0,.5,1),this._rigCameras[0].setCameraRigParameter("left",!0),this._rigCameras[0].setCameraRigParameter("frameData",r.frameData),this._rigCameras[0]._cameraRigParams.vrWorkMatrix=new e.Matrix,this._rigCameras[0].getProjectionMatrix=this._getWebVRProjectionMatrix,this._rigCameras[1].viewport=new e.Viewport(.5,0,.5,1),this._rigCameras[1].setCameraRigParameter("frameData",r.frameData),this._rigCameras[1]._cameraRigParams.vrWorkMatrix=new e.Matrix,this._rigCameras[1].getProjectionMatrix=this._getWebVRProjectionMatrix)}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._getWebVRProjectionMatrix=function(){var t=this._cameraRigParams.left?this._cameraRigParams.frameData.leftProjectionMatrix:this._cameraRigParams.frameData.rightProjectionMatrix;return[8,9,10,11].forEach((function(e){t[e]*=-1})),e.Matrix.FromArrayToRef(t,0,this._projectionMatrix),this._projectionMatrix},i.prototype._getWebVRViewMatrix=function(){var t=this._cameraRigParams.left?this._cameraRigParams.frameData.leftViewMatrix:this._cameraRigParams.frameData.rightViewMatrix;return[8,9,10,11].forEach((function(e){t[e]*=-1})),e.Matrix.FromArrayToRef(t,0,this._webvrViewMatrix),this._webvrViewMatrix},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=0&&r._keys.splice(t,1),i||e.preventDefault()}},t.addEventListener("keydown",this._onKeyDown,!1),t.addEventListener("keyup",this._onKeyUp,!1),e.Tools.RegisterTopRootEvents([{name:"blur",handler:this._onLostFocus}]))},t.prototype.detachControl=function(t){this._onKeyDown&&(t.removeEventListener("keydown",this._onKeyDown),t.removeEventListener("keyup",this._onKeyUp),e.Tools.UnregisterTopRootEvents([{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;i1)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"},t})();__decorate([e.serialize()],t.prototype,"touchAngularSensibility",void 0),__decorate([e.serialize()],t.prototype,"touchMoveSensibility",void 0),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),this._orientationChanged()},t.prototype.detachControl=function(e){window.removeEventListener("orientationchange",this._orientationChanged),window.removeEventListener("deviceorientation",this._deviceOrientation)},t.prototype.checkInputs=function(){this._alpha&&(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 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"},t})();__decorate([e.serialize()],t.prototype,"gamepadAngularSensibility",void 0),__decorate([e.serialize()],t.prototype,"gamepadMoveSensibility",void 0),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;t.tabIndex=1,this._onKeyDown=function(e){if(r.keysUp.indexOf(e.keyCode)!==-1||r.keysDown.indexOf(e.keyCode)!==-1||r.keysLeft.indexOf(e.keyCode)!==-1||r.keysRight.indexOf(e.keyCode)!==-1){var t=r._keys.indexOf(e.keyCode);t===-1&&r._keys.push(e.keyCode),e.preventDefault&&(i||e.preventDefault())}},this._onKeyUp=function(e){if(r.keysUp.indexOf(e.keyCode)!==-1||r.keysDown.indexOf(e.keyCode)!==-1||r.keysLeft.indexOf(e.keyCode)!==-1||r.keysRight.indexOf(e.keyCode)!==-1){var t=r._keys.indexOf(e.keyCode);t>=0&&r._keys.splice(t,1),e.preventDefault&&(i||e.preventDefault())}},this._onLostFocus=function(){r._keys=[]},t.addEventListener("keydown",this._onKeyDown,!1),t.addEventListener("keyup",this._onKeyUp,!1),e.Tools.RegisterTopRootEvents([{name:"blur",handler:this._onLostFocus}])},t.prototype.detachControl=function(t){t&&(t.removeEventListener("keydown",this._onKeyDown),t.removeEventListener("keyup",this._onKeyUp)),e.Tools.UnregisterTopRootEvents([{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.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"},t})();__decorate([e.serialize()],t.prototype,"gamepadRotationSensibility",void 0),__decorate([e.serialize()],t.prototype,"gamepadMoveSensibility",void 0),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){var o=t.call(this,i,r,n)||this;return o.cameraDirection=new e.Vector3(0,0,0),o.cameraRotation=new e.Vector2(0,0),o.rotation=new e.Vector3(0,0,0),o.speed=2,o.noRotationConstraint=!1,o.lockedTarget=null,o._currentTarget=e.Vector3.Zero(),o._viewMatrix=e.Matrix.Zero(),o._camMatrix=e.Matrix.Zero(),o._cameraTransformMatrix=e.Matrix.Zero(),o._cameraRotationMatrix=e.Matrix.Zero(),o._referencePoint=new e.Vector3(0,0,1),o._defaultUpVector=new e.Vector3(0,1,0),o._transformedReferencePoint=e.Vector3.Zero(),o._lookAtTemp=e.Matrix.Zero(),o._tempMatrix=e.Matrix.Zero(),o}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.absolutePosition&&this.lockedTarget.computeWorldMatrix(),this.lockedTarget.absolutePosition||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*Math.sqrt(e.getDeltaTime()/(100*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.Engine.CollisionsEpsilon&&(o.position.addInPlace(o._diffPosition),o.onCollide&&r&&o.onCollide(r))};n(i)},o.inputs=new e.FreeCameraInputsManager(o),o.inputs.addKeyboard().addMouse(),o}return __extends(i,t),Object.defineProperty(i.prototype,"angularSensibility",{get:function(){var e=this.inputs.attached.mouse;if(e)return e.angularSensibility},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;if(e)return e.keysUp},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;if(e)return e.keysDown},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;if(e)return e.keysLeft},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;if(e)return e.keysRight},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.getClassName=function(){return"FreeCamera"},i})(e.TargetCamera);__decorate([e.serializeAsVector3()],t.prototype,"ellipsoid",void 0),__decorate([e.serialize()],t.prototype,"checkCollisions",void 0),__decorate([e.serialize()],t.prototype,"applyGravity",void 0),e.FreeCamera=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(e){return t.call(this,e)||this}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.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){var o=t.call(this,e,i,r)||this;return o.radius=12,o.rotationOffset=0,o.heightOffset=4,o.cameraAcceleration=.05,o.maxCameraSpeed=20,o.lockedTarget=n,o}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=l<1?-this.maxCameraSpeed:this.maxCameraSpeed),(u>this.maxCameraSpeed||u<-this.maxCameraSpeed)&&(u=u<1?-this.maxCameraSpeed:this.maxCameraSpeed),(f>this.maxCameraSpeed||f<-this.maxCameraSpeed)&&(f=f<1?-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.lockedTarget)},i.prototype.getClassName=function(){return"FollowCamera"},i})(e.TargetCamera);__decorate([e.serialize()],t.prototype,"radius",void 0),__decorate([e.serialize()],t.prototype,"rotationOffset",void 0),__decorate([e.serialize()],t.prototype,"heightOffset",void 0),__decorate([e.serialize()],t.prototype,"cameraAcceleration",void 0),__decorate([e.serialize()],t.prototype,"maxCameraSpeed",void 0),__decorate([e.serializeAsMeshReference("lockedTargetId")],t.prototype,"lockedTarget",void 0),e.FollowCamera=t;var i=(function(t){function i(i,r,n,o,s,a){var h=t.call(this,i,e.Vector3.Zero(),a)||this;return h.alpha=r,h.beta=n,h.radius=o,h.target=s,h._cartesianCoordinates=e.Vector3.Zero(),h.follow(),h}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.getClassName=function(){return"ArcFollowCamera"},i})(e.TargetCamera);e.ArcFollowCamera=i})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(e){function t(t,i,r){var n=e.call(this,t,i,r)||this;return n.inputs.addTouch(),n._setupInputs(),n}return __extends(t,e),Object.defineProperty(t.prototype,"touchAngularSensibility",{get:function(){var e=this.inputs.attached.touch;if(e)return e.touchAngularSensibility},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;if(e)return e.touchMoveSensibility},set:function(e){var t=this.inputs.attached.touch;t&&(t.touchMoveSensibility=e)},enumerable:!0,configurable:!0}),t.prototype.getClassName=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=t.call(this,i,e.Vector3.Zero(),a)||this;return h.inertialAlphaOffset=0,h.inertialBetaOffset=0,h.inertialRadiusOffset=0,h.lowerAlphaLimit=null,h.upperAlphaLimit=null,h.lowerBetaLimit=.01,h.upperBetaLimit=Math.PI,h.lowerRadiusLimit=null,h.upperRadiusLimit=null,h.inertialPanningX=0,h.inertialPanningY=0,h.zoomOnFactor=1,h.targetScreenOffset=e.Vector2.Zero(),h.allowUpsideDown=!0,h._viewMatrix=new e.Matrix,h.panningAxis=new e.Vector3(1,1,0),h.checkCollisions=!1,h.collisionRadius=new e.Vector3(.5,.5,.5),h._collider=new e.Collider,h._previousPosition=e.Vector3.Zero(),h._collisionVelocity=e.Vector3.Zero(),h._newPosition=e.Vector3.Zero(),h._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?h.target=s:h.target=e.Vector3.Zero(),h.alpha=r,h.beta=n,h.radius=o,h.getViewMatrix(),h.inputs=new e.ArcRotateCameraInputsManager(h),h.inputs.addKeyboard().addMouseWheel().addPointers().addGamepad(),h}return __extends(i,t),Object.defineProperty(i.prototype,"angularSensibilityX",{get:function(){var e=this.inputs.attached.pointers;if(e)return e.angularSensibilityX},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;if(e)return e.angularSensibilityY},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;if(e)return e.pinchPrecision},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;if(e)return e.panningSensibility},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;if(e)return e.keysUp},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;if(e)return e.keysDown},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;if(e)return e.keysLeft},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;if(e)return e.keysRight},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;if(e)return e.wheelPrecision},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(){if(this.target.getAbsolutePosition){var e=this.target.getAbsolutePosition();return this._targetBoundingCenter?e.add(this._targetBoundingCenter):e}return 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))},i.prototype.attachControl=function(e,t,i,r){var n=this;void 0===i&&(i=!0),void 0===r&&(r=2),this._useCtrlForPanning=i,this._panningMouseButton=r,this.inputs.attachElement(e,t),this._reset=function(){n.inertialAlphaOffset=0,n.inertialBetaOffset=0,n.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.getScene().useRightHandedSystem?this.alpha-=this.beta<=0?-this.inertialAlphaOffset:this.inertialAlphaOffset: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)Math.PI&&(this.beta=this.beta-2*Math.PI):this.betathis.upperBetaLimit&&(this.beta=this.upperBetaLimit),this.lowerAlphaLimit&&this.alphathis.upperAlphaLimit&&(this.alpha=this.upperAlphaLimit),this.lowerRadiusLimit&&this.radiusthis.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.copyFrom(e),this.rebuildAnglesAndRadius())},i.prototype.setTarget=function(e,t){void 0===t&&(t=!1),this._getTargetPosition().equals(e)||(t&&e.getBoundingInfo?this._targetBoundingCenter=e.getBoundingInfo().boundingBox.center.clone():this._targetBoundingCenter=null,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()),this.getScene().useRightHandedSystem?e.Matrix.LookAtRHToRef(this.position,o,s,this._viewMatrix):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._currentTarget=o,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.getClassName=function(){return"ArcRotateCamera"},i})(e.TargetCamera);__decorate([e.serialize()],t.prototype,"alpha",void 0),__decorate([e.serialize()],t.prototype,"beta",void 0),__decorate([e.serialize()],t.prototype,"radius",void 0),__decorate([e.serializeAsVector3()],t.prototype,"target",void 0),__decorate([e.serialize()],t.prototype,"inertialAlphaOffset",void 0),__decorate([e.serialize()],t.prototype,"inertialBetaOffset",void 0),__decorate([e.serialize()],t.prototype,"inertialRadiusOffset",void 0),__decorate([e.serialize()],t.prototype,"lowerAlphaLimit",void 0),__decorate([e.serialize()],t.prototype,"upperAlphaLimit",void 0),__decorate([e.serialize()],t.prototype,"lowerBetaLimit",void 0),__decorate([e.serialize()],t.prototype,"upperBetaLimit",void 0),__decorate([e.serialize()],t.prototype,"lowerRadiusLimit",void 0),__decorate([e.serialize()],t.prototype,"upperRadiusLimit",void 0),__decorate([e.serialize()],t.prototype,"inertialPanningX",void 0),__decorate([e.serialize()],t.prototype,"inertialPanningY",void 0),__decorate([e.serialize()],t.prototype,"zoomOnFactor",void 0),__decorate([e.serialize()],t.prototype,"allowUpsideDown",void 0),e.ArcRotateCamera=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(e){return t.call(this,e)||this}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._autoClearDepthStencil={},this._customOpaqueSortCompareFn={},this._customAlphaTestSortCompareFn={},this._customTransparentSortCompareFn={},this._renderinGroupInfo=null,this._scene=e;for(var i=t.MIN_RENDERINGGROUPS;ii._alphaIndex?1:e._alphaIndext._distanceToCamera?-1:0},t.frontToBackSortCompare=function(e,t){return e._distanceToCamerat._distanceToCamera?1:0},t.prototype.prepare=function(){this._opaqueSubMeshes.reset(),this._transparentSubMeshes.reset(),this._alphaTestSubMeshes.reset(),this._particleSystems.reset(),this._spriteManagers.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.prototype.dispatchSprites=function(e){this._spriteManagers.push(e)},t.prototype.dispatchParticles=function(e){this._particleSystems.push(e)},t.prototype._renderParticles=function(e){if(0!==this._particleSystems.length){var t=this._scene.activeCamera;this._scene._particlesDuration.beginMonitoring();for(var i=0;ie.ActionManager.LongPressDelay&&Math.abs(l._startingPointerPosition.x-l._pointerX)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&&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(e){return e.isPickable&&e.isVisible&&e.isReady()});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)),c.pickedMesh.actionManager&&Math.abs(a._startingPointerPosition.x-a._pointerX)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)),c.pickedSprite.actionManager&&Math.abs(a._startingPointerPosition.x-a._pointerX)0)return!1;var t;for(t=0;t0)return;this._animationTimeLast=t}var i=(t-this._animationTimeLast)*this.animationTimeScale;this._animationTime+=i,this._animationTimeLast=t;for(var r=0;r0?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.switchActiveCamera=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-1&&(this._geometries.splice(t,1),this.collisionCoordinator.onGeometryDeleted(e),this.onGeometryRemovedObservable.notifyObservers(e),!0)},i.prototype.getGeometries=function(){return this._geometries},i.prototype.getMeshByID=function(e){for(var t=0;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=0;t--)if(this.skeletons[t].id===e)return this.skeletons[t];return null},i.prototype.getSkeletonById=function(e){for(var t=0;t0&&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(o,s)))}}this._particlesDuration.beginMonitoring();e.Tools.Now;if(this.particlesEnabled){e.Tools.StartPerformanceCounter("Particles",this.particleSystems.length>0);for(var a=0;a0)}this._particlesDuration.endMonitoring(!1)},i.prototype._activeMesh=function(e,t){if(t.skeleton&&this.skeletonsEnabled&&(this._activeSkeletons.pushNoDuplicate(t.skeleton)&&t.skeleton.prepare(),t.computeBonesUsingShaders||this._softwareSkinnedMeshes.pushNoDuplicate(t)),(e.showBoundingBox||this.forceShowBoundingBoxes)&&this._boundingBoxRenderer.renderList.push(e.getBoundingInfo().boundingBox),e._edgesRenderer&&this._edgesRenderers.push(e._edgesRenderer),t&&t.subMeshes){var i,r;if(t._submeshesOctree&&t.useOctreeForRenderingSelection){var n=t._submeshesOctree.select(this._frustumPlanes);i=n.length,r=n.data}else r=t.subMeshes,i=r.length;for(var o=0;o0){this._intermediateRendering=!0,e.Tools.StartPerformanceCounter("Render targets",this._renderTargets.length>0);for(var s=0;s0),this._intermediateRendering=!1,this._renderId++,o=!0}var c=this._engine.getStencilBuffer(),l=!1;if(this.renderTargetsEnabled&&this.highlightLayers&&this.highlightLayers.length>0){this._intermediateRendering=!0;for(var u=0;u-1)){l=!0;var a=f._mainTexture;a._shouldRender()&&(this._renderId++,a.render(!1,!1),o=!0)}}this._intermediateRendering=!1,this._renderId++}o&&i.restoreDefaultFramebuffer(),this._renderTargetsDuration.endMonitoring(!1),this.postProcessManager._prepareFrame(),this._renderDuration.beginMonitoring();var d,p;if(this.layers.length){for(i.setDepthBuffer(!1),d=0;d0);for(var g=0;g0)}if(this.layers.length){for(i.setDepthBuffer(!1),d=0;d-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(){this._lastFrameDuration.beginMonitoring(),this._particlesDuration.fetchNewFrame(),this._spritesDuration.fetchNewFrame(),this._activeParticles.fetchNewFrame(),this._renderDuration.fetchNewFrame(),this._renderTargetsDuration.fetchNewFrame(),this._evaluateActiveMeshesDuration.fetchNewFrame(),this._totalVertices.fetchNewFrame(),this._activeIndices.fetchNewFrame(),this._activeBones.fetchNewFrame(),this.getEngine().drawCallsPerfCounter.fetchNewFrame(),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 t=Math.max(i.MinDeltaTime,Math.min(this._engine.getDeltaTime(),i.MaxDeltaTime));this._animationRatio=.06*t,this._animate(),this._physicsEngine&&(e.Tools.StartPerformanceCounter("Physics"),this._physicsEngine._step(t/1e3),e.Tools.EndPerformanceCounter("Physics")),this.onBeforeRenderObservable.notifyObservers(this),this._renderTargetsDuration.beginMonitoring();var r=(e.Tools.Now,this.getEngine()),n=this.activeCamera;if(this.renderTargetsEnabled){e.Tools.StartPerformanceCounter("Custom render targets",this.customRenderTargets.length>0);for(var o=0;o0),this._renderId++}if(this.customRenderTargets.length>0&&r.restoreDefaultFramebuffer(),this._renderTargetsDuration.endMonitoring(),this.activeCamera=n,this.proceduralTexturesEnabled){e.Tools.StartPerformanceCounter("Procedural textures",this._proceduralTextures.length>0);for(var a=0;a0)}if(this._engine.clear(this.clearColor,this.autoClear||this.forceWireframe||this.forcePointsCloud,!0,!0),this.shadowsEnabled)for(var c=0;c0)for(var f=0;f0&&this._engine.clear(null,!1,!0,!0),this._processSubCameras(this.activeCameras[f]);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 d=0;d0?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-1&&this._engine.scenes.splice(t,1),this._engine.wipeCaches()},i.prototype.disposeSounds=function(){this.mainSoundTrack.dispose();for(var e=0;e=n.distance))&&(n=c,r))break}return n||new e.PickingInfo},i.prototype._internalMultiPick=function(e,t){for(var i=new Array,r=0;r0)for(var s=0;s=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.multiPick=function(e,t,i,r){var n=this;return this._internalMultiPick((function(i){return n.createPickingRay(e,t,i,r)}),i)},i.prototype.multiPickWithRay=function(t,i){var r=this;return this._internalMultiPick((function(i){return r._pickWithRayInverseMatrix||(r._pickWithRayInverseMatrix=e.Matrix.Identity()),i.invertToRef(r._pickWithRayInverseMatrix),e.Ray.Transform(t,r._pickWithRayInverseMatrix)}),i)},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;n0},enumerable:!0,configurable:!0}),r.prototype._sortLODLevels=function(){this._LODLevels.sort((function(e,t){return e.distancet.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;ti)return this.onLODLevelSelection&&this.onLODLevelSelection(i,this,this._LODLevels[this._LODLevels.length-1].mesh),this;for(var r=0;r=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,i=this._geometry.copy(e.Geometry.RandomId());t.releaseForMesh(this,!0),i.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-1&&(o.skeleton=i.getLastSkeletonByID(t.skeletonId),t.numBoneInfluencers&&(o.numBoneInfluencers=t.numBoneInfluencers)),t.animations){for(var s=0;s4,c=h?this.getVerticesData(e.VertexBuffer.MatricesIndicesExtraKind):null,l=h?this.getVerticesData(e.VertexBuffer.MatricesWeightsExtraKind):null,u=t.getTransformMatrices(this),f=e.Vector3.Zero(),d=new e.Matrix,p=new e.Matrix,m=0,g=0;g0);o++)e.Matrix.FromFloat32ArrayToRefScaled(u,16*s[m+o],_,p),d.addToSelf(p);if(h)for(o=0;o<4&&(_=l[m+o],_>0);o++)e.Matrix.FromFloat32ArrayToRefScaled(u,16*c[m+o],_,p),d.addToSelf(p);e.Vector3.TransformCoordinatesFromFloatsToRef(this._sourcePositions[g],this._sourcePositions[g+1],this._sourcePositions[g+2],d,f),f.toArray(r,g),e.Vector3.TransformNormalFromFloatsToRef(this._sourceNormals[g],this._sourceNormals[g+1],this._sourceNormals[g+2],d,f),f.toArray(n,g),d.reset()}return this.updateVerticesData(e.VertexBuffer.PositionKind,r),this.updateVerticesData(e.VertexBuffer.NormalKind,n),this}},r.MinMax=function(e){var t=null,i=null;return e.forEach((function(e,r,n){var o=e.getBoundingInfo().boundingBox;t?(t.MinimizeInPlace(o.minimumWorld),i.MaximizeInPlace(o.maximumWorld)):(t=o.minimumWorld,i=o.maximumWorld)})),{min:t,max:i}},r.Center=function(t){var i=t instanceof Array?e.Mesh.MinMax(t):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;s65536))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;sa&&(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.updateSideOrientation=function(t,i){return t==e.Mesh.DOUBLESIDE?e.Mesh.DOUBLESIDE:void 0===t||null===t?e.Mesh.FRONTSIDE:t},t.CreateBox=function(t,i,r){var n=new e.Mesh(t,r);i.sideOrientation=this.updateSideOrientation(i.sideOrientation,r),n.sideOrientation=i.sideOrientation;var 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);i.sideOrientation=this.updateSideOrientation(i.sideOrientation,r),n.sideOrientation=i.sideOrientation;var 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);i.sideOrientation=this.updateSideOrientation(i.sideOrientation,r),n.sideOrientation=i.sideOrientation;var 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);i.sideOrientation=this.updateSideOrientation(i.sideOrientation,r),n.sideOrientation=i.sideOrientation;var 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,this.updateSideOrientation(i.sideOrientation,r)),h=i.instance,c=i.updatable;if(h){e.Vector3.FromFloatsToRef(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,e.Tmp.Vector3[0]),e.Vector3.FromFloatsToRef(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE,e.Tmp.Vector3[1]);var l=function(t){for(var i=n[0].length,r=0,o=h.sideOrientation===e.Mesh.DOUBLESIDE?2:1,s=1;s<=o;s++)for(var a=0;ae.Tmp.Vector3[1].x&&(e.Tmp.Vector3[1].x=c[u].x),c[u].ye.Tmp.Vector3[1].y&&(e.Tmp.Vector3[1].y=c[u].y),c[u].ze.Tmp.Vector3[1].z&&(e.Tmp.Vector3[1].z=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._boundingInfo=new e.BoundingInfo(e.Tmp.Vector3[0],e.Tmp.Vector3[1]),h._boundingInfo.update(h._worldMatrix),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,m=0,g=0;g1?1:r.arc:1,a=void 0===r.closed||r.closed,h=r.shape,c=r.radius||1,l=r.tessellation||64,u=r.updatable,f=this.updateSideOrientation(r.sideOrientation,n),d=r.cap||e.Mesh.NO_CAP,p=2*Math.PI,m=new Array,g=r.invertUV||!1,_=0,v=0,y=p/l*s,x=new Array;for(_=0;_<=l;_++){var x=[];for(d!=e.Mesh.CAP_START&&d!=e.Mesh.CAP_ALL||(x.push(new e.Vector3(0,h[0].y,0)),x.push(new e.Vector3(Math.cos(_*y)*h[0].x*c,h[0].y,Math.sin(_*y)*h[0].x*c))),v=0;v1?1:r.arc||1;var p,m,g=function(t,i,r,n,o,s,a,h){for(var c,l,u,f,d=i.getTangents(),p=i.getNormals(),m=i.getDistances(),g=2*Math.PI,_=g/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,A=0;A3?0:c,m=g(o,p,v,s,a,h,c,r.arc);var y=t.CreateRibbon(i,{pathArray:m,closePath:!0,closeArray:!1,updatable:u,sideOrientation:f,invertUV:l},n);return y.pathArray=m,y.path3D=p,y.tessellation=a,y.cap=c,y.arc=r.arc,y},t.CreatePolyhedron=function(t,i,r){var n=new e.Mesh(t,r);i.sideOrientation=this.updateSideOrientation(i.sideOrientation,r),n.sideOrientation=i.sideOrientation;var 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,m=Math.sqrt(h.x*h.x+h.z*h.z),g=Math.atan2(h.y,m),_=e.Matrix.RotationYawPitchRoll(p,g,l).multiply(e.Matrix.Translation(a.x,a.y,a.z)),v=e.Matrix.Invert(_),y=i.getWorldMatrix(),x=y.multiply(v),b=new e.VertexData;b.indices=[],b.positions=[],b.normals=[],b.uvs=[];for(var A=0,T=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},E=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;s0,h=_>0,l=v>0,m=(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},M=0;M3?0:u,y=x(r,n,v,b,o,s,a,h,u,f);var A=t.CreateRibbon(i,{pathArray:y,closeArray:c,closePath:l,updatable:p,sideOrientation:m,invertUV:_},d);return A.pathArray=y,A.path3D=v,A.cap=u,A},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),this._uid=null}return Object.defineProperty(t.prototype,"uid",{get:function(){return this._uid||(this._uid=e.Tools.RandomId()),this._uid},enumerable:!0,configurable:!0}),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||!!this._texture&&this._texture.isReady},t.prototype.getSize=function(){return this._texture._width?new e.Size(this._texture._width,this._texture._height):this._texture._size?new e.Size(this._texture._size,this._texture._size):e.Size.Zero()},t.prototype.getBaseSize=function(){return this.isReady()&&this._texture?this._texture._size?new e.Size(this._texture._size,this._texture._size):new e.Size(this._texture._baseWidth,this._texture._baseHeight):e.Size.Zero()},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=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},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),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===o&&(o=!1),void 0===s&&(s=!0),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);var f=t.call(this,n)||this;if(f.uOffset=0,f.vOffset=0,f.uScale=1,f.vScale=1,f.uAng=0,f.vAng=0,f.wAng=0,f.name=r,f.url=r,f._noMipmap=o,f._invertY=s,f._samplingMode=a,f._buffer=l,f._deleteBuffer=u,!r)return f;f._texture=f._getFromCache(r,o,a);var d=function(){f._onLoadObservarble&&f._onLoadObservarble.hasObservers()&&f.onLoadObservable.notifyObservers(!0),h&&h()};return f._texture?f._texture.isReady?e.Tools.SetImmediate((function(){return d()})):f._texture.onLoadedCallbacks.push(d):n.useDelayedTextureLoading?(f.delayLoadState=e.Engine.DELAYLOADSTATE_NOTLOADED,f._delayedOnLoad=d,f._delayedOnError=c):(f._texture=n.getEngine().createTexture(r,o,s,n,f._samplingMode,d,c,f._buffer),u&&delete f._buffer),f}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)},Object.defineProperty(i.prototype,"onLoadObservable",{get:function(){return this._onLoadObservarble||(this._onLoadObservarble=new e.Observable),this._onLoadObservarble},enumerable:!0,configurable:!0}),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.customType){var o=e.Tools.Instantiate(t.customType);return o.Parse(t,r,n)}if(t.isCube)return e.CubeTexture.Parse(t,r,n);if(!t.name&&!t.isRenderTarget)return null;var s=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 a=0;a=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,s,a,h){void 0===s&&(s=e.Engine.TEXTURETYPE_UNSIGNED_INT),void 0===a&&(a=e.Texture.BILINEAR_SAMPLINGMODE),void 0===h&&(h=!0);var c=t.call(this,i,r,n,o,!0,s,!1,a,h)||this;return c.mirrorPlane=new e.Plane(0,1,0,1),c._transformMatrix=e.Matrix.Zero(),c._mirrorMatrix=e.Matrix.Zero(),c.onBeforeRenderObservable.add((function(){e.Matrix.ReflectionToRef(c.mirrorPlane,c._mirrorMatrix),c._savedViewMatrix=n.getViewMatrix(),c._mirrorMatrix.multiplyToRef(c._savedViewMatrix,c._transformMatrix),n.setTransformMatrix(c._transformMatrix,n.getProjectionMatrix()),n.clipPlane=c.mirrorPlane,n.getEngine().cullBackFaces=!1,n._mirroredCameraPosition=e.Vector3.TransformCoordinates(n.activeCamera.position,c._mirrorMatrix)})),c.onAfterRenderObservable.add((function(){n.setTransformMatrix(c._savedViewMatrix,n.getProjectionMatrix()),n.getEngine().cullBackFaces=!0,n._mirroredCameraPosition=null,delete n.clipPlane})),c}return __extends(i,t),i.prototype.clone=function(){var e=this.getSize(),t=new i(this.name,e.width,this.getScene(),this._renderTargetOptions.generateMipMaps,this._renderTargetOptions.type,this._renderTargetOptions.samplingMode,this._renderTargetOptions.generateDepthBuffer);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=t.call(this,i,r,n,o,!0)||this;return s.refractionPlane=new e.Plane(0,1,0,1),s.depth=2,s.onBeforeRenderObservable.add((function(){n.clipPlane=s.refractionPlane})),s.onAfterRenderObservable.add((function(){delete n.clipPlane})),s}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);var a=t.call(this,null,n,!o)||this;a.name=i,a.wrapU=e.Texture.CLAMP_ADDRESSMODE,a.wrapV=e.Texture.CLAMP_ADDRESSMODE,a._generateMipMaps=o,r.getContext?(a._canvas=r,a._texture=n.getEngine().createDynamicTexture(r.width,r.height,o,s)):(a._canvas=document.createElement("canvas"),r.width?a._texture=n.getEngine().createDynamicTexture(r.width,r.height,o,s):a._texture=n.getEngine().createDynamicTexture(r,r,o,s));var h=a.getSize();return a._canvas.width=h.width,a._canvas.height=h.height,a._context=a._canvas.getContext("2d"),a}return __extends(i,t),Object.defineProperty(i.prototype,"canRescale",{get:function(){return!0},enumerable:!0,configurable:!0}),i.prototype.scale=function(e){var t=this.getSize();t.width*=e,t.height*=e,this._canvas.width=t.width,this._canvas.height=t.height,this.releaseInternalTexture(),this._texture=this.getScene().getEngine().createDynamicTexture(t.width,t.height,this._generateMipMaps,this._samplingMode)},i.prototype.getContext=function(){return this._context},i.prototype.clear=function(){var e=this.getSize();this._context.fillRect(0,0,e.width,e.height)},i.prototype.update=function(e){this.getScene().getEngine().updateDynamicTexture(this._texture,this._canvas,void 0===e||e)},i.prototype.drawText=function(e,t,i,r,n,o,s,a){void 0===a&&(a=!0);var h=this.getSize();if(o&&(this._context.fillStyle=o,this._context.fillRect(0,0,h.width,h.height)),this._context.font=r,null===t){var c=this._context.measureText(e);t=(h.width-c.width)/2}this._context.fillStyle=n,this._context.fillText(e,t,i),a&&this.update(s)},i.prototype.clone=function(){var e=this.getSize(),t=new i(this.name,e,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){void 0===o&&(o=!1),void 0===s&&(s=!1),void 0===a&&(a=e.Texture.TRILINEAR_SAMPLINGMODE);var h=t.call(this,null,n,!o,s)||this;h._autoLaunch=!0;var c;return h.name=i,r instanceof HTMLVideoElement?h.video=r:(c=r,h.video=document.createElement("video"),h.video.autoplay=!1,h.video.loop=!0),h._generateMipMaps=o,h._samplingMode=a,e.Tools.IsExponentOfTwo(h.video.videoWidth)&&e.Tools.IsExponentOfTwo(h.video.videoHeight)?(h.wrapU=e.Texture.WRAP_ADDRESSMODE,h.wrapV=e.Texture.WRAP_ADDRESSMODE):(h.wrapU=e.Texture.CLAMP_ADDRESSMODE,h.wrapV=e.Texture.CLAMP_ADDRESSMODE,h._generateMipMaps=!1),c?(h.video.addEventListener("canplaythrough",(function(){h._createTexture()})),c.forEach((function(e){var t=document.createElement("source");t.src=e,h.video.appendChild(t)}))):h._createTexture(),h._lastUpdate=e.Tools.Now,h}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)&&(this._lastUpdate=t,this.getScene().getEngine().updateVideoTexture(this._texture,this.video,this._invertY),!0)},i.CreateFromWebCam=function(t,i,r){var n=document.createElement("video");navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia,window.URL=window.URL||window.webkitURL||window.mozURL||window.msURL,navigator.getUserMedia&&navigator.getUserMedia({video:{width:{min:r&&r.minWidth||256,max:r&&r.maxWidth||640},height:{min:r&&r.minHeight||256,max:r&&r.maxHeight||480}}},(function(r){void 0!==n.mozSrcObject?n.mozSrcObject=r:n.src=window.URL&&window.URL.createObjectURL(r)||r,n.play(),i&&i(new e.VideoTexture("video",n,t,(!0),(!0)))}),(function(t){e.Tools.Error(t.name)}))},i})(e.Texture);e.VideoTexture=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(e,i,r,n,o,s){var a=t.call(this,e,r,null,n,o,s)||this;return a._animate=!0,a._time=0,a._texturePath=i,a.loadJson(i),a.refreshRate=1,a}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;tthis._maxRank&&(this._maxRank=e),this._defines[e]=new Array),this._defines[e].push(t)},e.prototype.addCPUSkinningFallback=function(e,t){this._meshRank=e,this._mesh=t,e>this._maxRank&&(this._maxRank=e)},Object.defineProperty(e.prototype,"isMoreFallbacks",{get:function(){return this._currentRank<=this._maxRank},enumerable:!0,configurable:!0}),e.prototype.reduce=function(e){for(var t=this._defines[this._currentRank],i=0;i-1?e:BABYLON.Engine.ShadersRepository+e,BABYLON.Tools.LoadFile(n+".vertex.fx",t)},Effect.prototype._loadFragmentShader=function(e,t){if(e instanceof HTMLElement){var i=BABYLON.Tools.GetDOMTextContent(e);return void t(i)}if("base64:"===e.substr(0,7)){var r=window.atob(e.substr(7));return void t(r)}if(Effect.ShadersStore[e+"PixelShader"])return void t(Effect.ShadersStore[e+"PixelShader"]);if(Effect.ShadersStore[e+"FragmentShader"])return void t(Effect.ShadersStore[e+"FragmentShader"]);var n;n="."===e[0]||"/"===e[0]||e.indexOf("http")>-1?e:BABYLON.Engine.ShadersRepository+e,BABYLON.Tools.LoadFile(n+".fragment.fx",t)},Effect.prototype._dumpShadersName=function(){this.name.vertexElement?(BABYLON.Tools.Error("Vertex shader:"+this.name.vertexElement),BABYLON.Tools.Error("Fragment shader:"+this.name.fragmentElement)):this.name.vertex?(BABYLON.Tools.Error("Vertex shader:"+this.name.vertex),BABYLON.Tools.Error("Fragment shader:"+this.name.fragment)):(BABYLON.Tools.Error("Vertex shader:"+this.name),BABYLON.Tools.Error("Fragment shader:"+this.name))},Effect.prototype._processIncludes=function(e,t){for(var i=this,r=/#include<(.+)>(\((.*)\))*(\[(.*)\])*/g,n=r.exec(e),o=new String(e);null!=n;){var s=n[1];if(!Effect.IncludesShadersStore[s]){var a=BABYLON.Engine.ShadersRepository+"ShadersInclude/"+s+".fx";return void BABYLON.Tools.LoadFile(a,(function(e){Effect.IncludesShadersStore[s]=e,i._processIncludes(o,t)}))}var h=Effect.IncludesShadersStore[s];if(n[2])for(var c=n[3].split(","),l=0;l0&&(result+=line+"\r\n")}return result},Effect.prototype._evaluateDefinesOnString=function(e){for(var t={children:[]},i=t,r=e.split("\n"),n=0;n0){for(var f=0;f0){for(var p=0;p0&&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=0&&this._scene.materials.splice(i,1),e&&this._effect&&(this._scene.getEngine()._releaseEffect(this._effect),this._effect=null),i=0;i0&&(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;a=!0,this._defines.EMISSIVE=!0}if(this.lightmapTexture&&r.LightmapTextureEnabled){if(!this.lightmapTexture.isReady())return!1;a=!0,this._defines.LIGHTMAP=!0,this._defines.USELIGHTMAPASSHADOWMAP=this.useLightmapAsShadowmap}if(this.specularTexture&&r.SpecularTextureEnabled){if(!this.specularTexture.isReady())return!1;a=!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;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&&r.RefractionTextureEnabled){if(!this.refractionTexture.isReady())return!1;a=!0,this._defines.REFRACTION=!0,this._defines.REFRACTIONMAP_3D=this.refractionTexture.isCube}if(this.cameraColorGradingTexture&&r.ColorGradingTextureEnabled){if(!this.cameraColorGradingTexture.isReady())return!1;this._defines.CAMERACOLORGRADING=!0}}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.cameraColorCurves&&(this._defines.CAMERACOLORCURVES=!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),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),h=!0,this._defines.FRESNEL=!0),this._defines.SPECULARTERM&&this.useSpecularOverAlpha&&(this._defines.SPECULAROVERALPHA=!0),i&&(h&&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),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",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"];this._defines.CAMERACOLORCURVES&&e.ColorCurves.PrepareUniforms(d),this._defines.CAMERACOLORGRADING&&e.ColorGradingTexture.PrepareUniformsAndSamplers(d,p),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)},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){if(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)}this.cameraColorGradingTexture&&r.ColorGradingTextureEnabled&&e.ColorGradingTexture.Bind(this.cameraColorGradingTexture,this._effect)}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),this.cameraColorCurves&&e.ColorCurves.Bind(this.cameraColorCurves,this._effect)),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),this.cameraColorGradingTexture&&this.cameraColorGradingTexture.animations&&this.cameraColorGradingTexture.animations.length>0&&e.push(this.cameraColorGradingTexture),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(),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(){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})(e.Material);i.DiffuseTextureEnabled=!0,i.AmbientTextureEnabled=!0,i.OpacityTextureEnabled=!0,i.ReflectionTextureEnabled=!0,i.EmissiveTextureEnabled=!0,i.SpecularTextureEnabled=!0,i.BumpTextureEnabled=!0,i.FresnelEnabled=!0,i.LightmapTextureEnabled=!0,i.RefractionTextureEnabled=!0,i.ColorGradingTextureEnabled=!0,__decorate([e.serializeAsTexture()],i.prototype,"diffuseTexture",void 0),__decorate([e.serializeAsTexture()],i.prototype,"ambientTexture",void 0),__decorate([e.serializeAsTexture()],i.prototype,"opacityTexture",void 0),__decorate([e.serializeAsTexture()],i.prototype,"reflectionTexture",void 0),__decorate([e.serializeAsTexture()],i.prototype,"emissiveTexture",void 0),__decorate([e.serializeAsTexture()],i.prototype,"specularTexture",void 0),__decorate([e.serializeAsTexture()],i.prototype,"bumpTexture",void 0),__decorate([e.serializeAsTexture()],i.prototype,"lightmapTexture",void 0),__decorate([e.serializeAsTexture()],i.prototype,"refractionTexture",void 0),__decorate([e.serializeAsColor3("ambient")],i.prototype,"ambientColor",void 0),__decorate([e.serializeAsColor3("diffuse")],i.prototype,"diffuseColor",void 0),__decorate([e.serializeAsColor3("specular")],i.prototype,"specularColor",void 0),__decorate([e.serializeAsColor3("emissive")],i.prototype,"emissiveColor",void 0),__decorate([e.serialize()],i.prototype,"specularPower",void 0),__decorate([e.serialize()],i.prototype,"useAlphaFromDiffuseTexture",void 0),__decorate([e.serialize()],i.prototype,"useEmissiveAsIllumination",void 0),__decorate([e.serialize()],i.prototype,"linkEmissiveWithDiffuse",void 0),__decorate([e.serialize()],i.prototype,"useReflectionFresnelFromSpecular",void 0),__decorate([e.serialize()],i.prototype,"useSpecularOverAlpha",void 0),__decorate([e.serialize()],i.prototype,"useReflectionOverAlpha",void 0),__decorate([e.serialize()],i.prototype,"disableLighting",void 0),__decorate([e.serialize()],i.prototype,"useParallax",void 0),__decorate([e.serialize()],i.prototype,"useParallaxOcclusion",void 0),__decorate([e.serialize()],i.prototype,"parallaxScaleBias",void 0),__decorate([e.serialize()],i.prototype,"roughness",void 0),__decorate([e.serialize()],i.prototype,"indexOfRefraction",void 0),__decorate([e.serialize()],i.prototype,"invertRefractionY",void 0),__decorate([e.serialize()],i.prototype,"useLightmapAsShadowmap",void 0),__decorate([e.serializeAsFresnelParameters()],i.prototype,"diffuseFresnelParameters",void 0),__decorate([e.serializeAsFresnelParameters()],i.prototype,"opacityFresnelParameters",void 0),__decorate([e.serializeAsFresnelParameters()],i.prototype,"reflectionFresnelParameters",void 0),__decorate([e.serializeAsFresnelParameters()],i.prototype,"refractionFresnelParameters",void 0),__decorate([e.serializeAsFresnelParameters()],i.prototype,"emissiveFresnelParameters",void 0),__decorate([e.serialize()],i.prototype,"useGlossinessFromSpecularMapAlpha",void 0),__decorate([e.serialize()],i.prototype,"maxSimultaneousLights",void 0),__decorate([e.serialize()],i.prototype,"invertNormalMapX",void 0),__decorate([e.serialize()],i.prototype,"invertNormalMapY",void 0),__decorate([e.serializeAsTexture()],i.prototype,"cameraColorGradingTexture",void 0),__decorate([e.serializeAsColorCurves()],i.prototype,"cameraColorCurves",void 0),__decorate([e.serialize()],i.prototype,"useLogarithmicDepth",null),e.StandardMaterial=i})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(e,i){var r=t.call(this,e,i,!0)||this;return r.subMaterials=new Array,i.multiMaterials.push(r),r}return __extends(i,t),i.prototype.getSubMaterial=function(e){return e<0||e>=this.subMaterials.length?this.getScene().defaultMaterial:this.subMaterials[e]},i.prototype.getClassName=function(){return"MultiMaterial"},i.prototype.isReady=function(e){for(var t=0;t-1&&o.skeletons){var O=g.indexOf(y.skeletonId)>-1;if(!O)for(var D=0,I=f.skeletons.length;D>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;fp&&(c=p,o=d,n))break}}}if(o){var m=new e.PickingInfo;return m.hit=!0,m.pickedSprite=o,m.distance=c,m}return null},t.prototype.render=function(){if(this._effectBase.isReady()&&this._effectFog.isReady()&&this._spriteTexture&&this._spriteTexture.isReady()){for(var t=this._scene.getEngine(),i=this._spriteTexture.getBaseSize(),r=t.getDeltaTime(),n=Math.min(this._capacity,this.sprites.length),o=i.width/this.cellWidth,s=0,a=0;athis._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._onAnimationEnd&&this._onAnimationEnd(),this.disposeWhenFinishedAnimating&&this.dispose()))))},t.prototype.dispose=function(){for(var e=0;e=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;o-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;r1)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=[{frame:0,value:s},{frame:o,value:a}];return 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=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;t0)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=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: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;sthis._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)}(rthis._keys[this._keys.length-1].frame)&&(r=this._keys[0].frame),(nthis._keys[this._keys.length-1].frame)&&(n=this._keys[this._keys.length-1].frame),r===n&&r++;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 m=this._interpolate(r,0,i.ANIMATIONLOOPMODE_CYCLE),g=this._interpolate(n,0,i.ANIMATIONLOOPMODE_CYCLE);switch(this.dataType){case i.ANIMATIONTYPE_FLOAT:this._offsetsCache[p]=g-m;break;case i.ANIMATIONTYPE_QUATERNION:this._offsetsCache[p]=g.subtract(m);break;case i.ANIMATIONTYPE_VECTOR3:this._offsetsCache[p]=g.subtract(m);case i.ANIMATIONTYPE_VECTOR2:this._offsetsCache[p]=g.subtract(m);case i.ANIMATIONTYPE_SIZE:this._offsetsCache[p]=g.subtract(m);case i.ANIMATIONTYPE_COLOR3:this._offsetsCache[p]=g.subtract(m)}this._highLimitsCache[p]=g}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 _=f/u>>0,v=h?r+f%u:n,y=this._interpolate(v,_,this.loopMode,l,d);this.setValue(y);for(var x=0;x=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-1){for(var i=this._animations,r=0,t=i.length-1;t>=0;t--)"string"==typeof e&&i[t].name!=e||(i[t].reset(),i.splice(t,1),r++);i.length==r&&(this._scene._activeAnimatables.splice(t,1),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=.5?.5*(1-this.easeInCore(2*(1-t)))+.5:.5*this.easeInCore(2*t)},e})();t._EASINGMODE_EASEIN=0,t._EASINGMODE_EASEOUT=1,t._EASINGMODE_EASEINOUT=2,e.EasingFunction=t;var i=(function(e){function t(){return e.apply(this,arguments)||this}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);var i=e.call(this)||this;return i.amplitude=t,i}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);var r=e.call(this)||this;return r.bounces=t,r.bounciness=i,r}return __extends(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.bounces),i=this.bounciness;i<=1&&(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(){return e.apply(this,arguments)||this}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);var r=e.call(this)||this;return r.oscillations=t,r.springiness=i,r}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);var i=e.call(this)||this;return i.exponent=t,i}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);var i=e.call(this)||this;return i.power=t,i}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(){return e.apply(this,arguments)||this}return __extends(t,e),t.prototype.easeInCore=function(e){return e*e},t})(t);e.QuadraticEase=c;var l=(function(e){function t(){return e.apply(this,arguments)||this}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(){return e.apply(this,arguments)||this}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(){return e.apply(this,arguments)||this}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);var o=t.call(this)||this;return o.x1=e,o.y1=i,o.x2=r,o.y2=n,o}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){var a=t.call(this,i,r.getScene())||this;return a.name=i,a.children=new Array,a.animations=new Array,a._worldTransform=new e.Matrix,a._absoluteTransform=new e.Matrix,a._invertedAbsoluteTransform=new e.Matrix,a._scaleMatrix=e.Matrix.Identity(),a._scaleVector=new e.Vector3(1,1,1),a._negateScaleChildren=new e.Vector3(1,1,1),a._scalingDeterminant=1,a._syncScaleVector=function(){var t=this.getLocalMatrix(),i=t.m[0]*t.m[0]+t.m[1]*t.m[1]+t.m[2]*t.m[2],r=t.m[4]*t.m[4]+t.m[5]*t.m[5]+t.m[6]*t.m[6],n=t.m[8]*t.m[8]+t.m[9]*t.m[9]+t.m[10]*t.m[10],o=t.m[0]*t.m[1]*t.m[2]*t.m[3]<0?-1:1,s=t.m[4]*t.m[5]*t.m[6]*t.m[7]<0?-1:1,a=t.m[8]*t.m[9]*t.m[10]*t.m[11]<0?-1:1;this._scaleVector.x=o*Math.sqrt(i),this._scaleVector.y=s*Math.sqrt(r),this._scaleVector.z=a*Math.sqrt(n),this._parent&&(this._scaleVector.x/=this._parent._negateScaleChildren.x,this._scaleVector.y/=this._parent._negateScaleChildren.y,this._scaleVector.z/=this._parent._negateScaleChildren.z),e.Matrix.FromValuesToRef(this._scaleVector.x,0,0,0,0,this._scaleVector.y,0,0,0,0,this._scaleVector.z,0,0,0,0,1,this._scaleMatrix)},a._skeleton=r,a._matrix=o,a._baseMatrix=o,a._restPose=s?s:o.clone(),r.bones.push(a),n?(a._parent=n,n.children.push(a)):a._parent=null,a._updateDifferenceMatrix(),a.getAbsoluteTransform().determinant()<0&&(a._scalingDeterminant*=-1),a}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,t){void 0===t&&(t=!0),this._baseMatrix=e.clone(),this._matrix=e.clone(),this._skeleton._markAsDirty(),t&&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=l&&a.frame<=u&&(n?(c=a.value.clone(),g?(h=c.getTranslation(),c.setTranslation(h.scaleInPlace(_))):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.prototype.translate=function(t,i,r){void 0===i&&(i=e.Space.LOCAL);var n=this.getLocalMatrix();if(i==e.Space.LOCAL)n.m[12]+=t.x,n.m[13]+=t.y,n.m[14]+=t.z;else{this._skeleton.computeAbsoluteTransforms();var o=e.Tmp.Matrix[0],s=e.Tmp.Vector3[0];r?(o.copyFrom(this._parent.getAbsoluteTransform()),o.multiplyToRef(r.getWorldMatrix(),o)):o.copyFrom(this._parent.getAbsoluteTransform()),o.m[12]=0,o.m[13]=0,o.m[14]=0,o.invert(),e.Vector3.TransformCoordinatesToRef(t,o,s),n.m[12]+=s.x,n.m[13]+=s.y,n.m[14]+=s.z}this.markAsDirty()},i.prototype.setPosition=function(t,i,r){void 0===i&&(i=e.Space.LOCAL);var n=this.getLocalMatrix();if(i==e.Space.LOCAL)n.m[12]=t.x,n.m[13]=t.y,n.m[14]=t.z;else{this._skeleton.computeAbsoluteTransforms();var o=e.Tmp.Matrix[0],s=e.Tmp.Vector3[0];r?(o.copyFrom(this._parent.getAbsoluteTransform()),o.multiplyToRef(r.getWorldMatrix(),o)):o.copyFrom(this._parent.getAbsoluteTransform()),o.invert(),e.Vector3.TransformCoordinatesToRef(t,o,s),n.m[12]=s.x,n.m[13]=s.y,n.m[14]=s.z}this.markAsDirty()},i.prototype.setAbsolutePosition=function(t,i){this.setPosition(t,e.Space.WORLD,i)},i.prototype.setScale=function(e,t,i,r){void 0===r&&(r=!1),this.animations[0]&&!this.animations[0].isStopped()&&(r||(this._negateScaleChildren.x=1/e,this._negateScaleChildren.y=1/t,this._negateScaleChildren.z=1/i),this._syncScaleVector()),this.scale(e/this._scaleVector.x,t/this._scaleVector.y,i/this._scaleVector.z,r)},i.prototype.scale=function(t,i,r,n){void 0===n&&(n=!1);var o=this.getLocalMatrix(),s=e.Tmp.Matrix[0];s.copyFrom(o);var a=e.Tmp.Matrix[1];a.copyFrom(s),a.invert();var h=e.Tmp.Matrix[2];e.Matrix.FromValuesToRef(t,0,0,0,0,i,0,0,0,0,r,0,0,0,0,1,h),this._scaleMatrix.multiplyToRef(h,this._scaleMatrix),this._scaleVector.x*=t,this._scaleVector.y*=i,this._scaleVector.z*=r,o.multiplyToRef(a,o),o.multiplyToRef(h,o),o.multiplyToRef(s,o);var c=this.getParent();c?o.multiplyToRef(c.getAbsoluteTransform(),this.getAbsoluteTransform()):this.getAbsoluteTransform().copyFrom(o);var l=this.children.length;h.invert();for(var u=0;u0&&(this._rightHandedSystem=!0,this._bendAxis.x=0,this._bendAxis.y=0,this._bendAxis.z=1),this._bone1.length){var n=this._bone1.getScale(),o=this._bone2.getScale();this._bone1Length=this._bone1.length*n.y*this.mesh.scaling.y,this._bone2Length=this._bone2.length*o.y*this.mesh.scaling.y}else if(this._bone1.children[0]){t.computeWorldMatrix(!0);var s=this._bone2.children[0].getAbsolutePosition(t),a=this._bone2.getAbsolutePosition(t),h=this._bone1.getAbsolutePosition(t);this._bone1Length=e.Vector3.Distance(s,a),this._bone2Length=e.Vector3.Distance(a,h)}this._bone1.getRotationMatrixToRef(e.Space.WORLD,t,this._bone1Mat),this.maxAngle=Math.PI,r&&(r.targetMesh&&(this.targetMesh=r.targetMesh,this.targetMesh.computeWorldMatrix(!0)),r.poleTargetMesh?(this.poleTargetMesh=r.poleTargetMesh,this.poleTargetMesh.computeWorldMatrix(!0)):r.poleTargetBone?this.poleTargetBone=r.poleTargetBone:this._bone1.getParent()&&(this.poleTargetBone=this._bone1.getParent()),r.poleTargetLocalOffset&&this.poleTargetLocalOffset.copyFrom(r.poleTargetLocalOffset),r.poleAngle&&(this.poleAngle=r.poleAngle),r.bendAxis&&this._bendAxis.copyFrom(r.bendAxis),r.maxAngle&&(this.maxAngle=r.maxAngle),r.slerpAmount&&(this.slerpAmount=r.slerpAmount))}return Object.defineProperty(t.prototype,"maxAngle",{get:function(){return this._maxAngle},set:function(e){this._setMaxAngle(e)},enumerable:!0,configurable:!0}),t.prototype._setMaxAngle=function(e){e<0&&(e=0),(e>Math.PI||void 0==e)&&(e=Math.PI),this._maxAngle=e;var t=this._bone1Length,i=this._bone2Length;this._maxReach=Math.sqrt(t*t+i*i-2*t*i*Math.cos(e))},t.prototype.update=function(){var t=this._bone1,i=this.targetPosition,r=this.poleTargetPosition,n=this._tmpMat1,o=this._tmpMat2;this.targetMesh&&i.copyFrom(this.targetMesh.getAbsolutePosition()),this.poleTargetBone?this.poleTargetBone.getAbsolutePositionFromLocalToRef(this.poleTargetLocalOffset,this.mesh,r):this.poleTargetMesh&&e.Vector3.TransformCoordinatesToRef(this.poleTargetLocalOffset,this.poleTargetMesh.getWorldMatrix(),r);var s=this._tmpVec1,a=this._tmpVec2,h=this._tmpVec3,c=this._tmpVec4,l=this._tmpVec5;t.getAbsolutePositionToRef(this.mesh,s),r.subtractToRef(s,l),0==l.x&&0==l.y&&0==l.z?l.y=1:l.normalize(),i.subtractToRef(s,c),c.normalize(),e.Vector3.CrossToRef(c,l,a),a.normalize(),e.Vector3.CrossToRef(c,a,h),h.normalize(),e.Matrix.FromXYZAxesToRef(h,c,a,n);var u=this._bone1Length,f=this._bone2Length,d=e.Vector3.Distance(s,i);this._maxReach>0&&(d=Math.min(this._maxReach,d));var p=(f*f+d*d-u*u)/(2*f*d),m=(d*d+u*u-f*f)/(2*d*u);p>1&&(p=1),m>1&&(m=1),p<-1&&(p=-1),m<-1&&(m=-1);var g=Math.acos(p),_=Math.acos(m),v=-g-_;this._rightHandedSystem?(e.Matrix.RotationYawPitchRollToRef(0,0,.5*Math.PI,o),o.multiplyToRef(n,n),e.Matrix.RotationAxisToRef(this._bendAxis,_,o),o.multiplyToRef(n,n)):(this._tmpVec1.copyFrom(this._bendAxis),this._tmpVec1.x*=-1,e.Matrix.RotationAxisToRef(this._tmpVec1,-_,o),o.multiplyToRef(n,n)),this.poleAngle&&(e.Matrix.RotationAxisToRef(c,this.poleAngle,o),n.multiplyToRef(o,n)),this.slerpAmount<1?(this._slerping||e.Quaternion.FromRotationMatrixToRef(this._bone1Mat,this._bone1Quat),e.Quaternion.FromRotationMatrixToRef(n,this._tmpQuat1),e.Quaternion.SlerpToRef(this._bone1Quat,this._tmpQuat1,this.slerpAmount,this._bone1Quat),v=this._bone2Ang*(1-this.slerpAmount)+v*this.slerpAmount,this._bone1.setRotationQuaternion(this._bone1Quat,e.Space.WORLD,this.mesh),this._slerping=!0):(this._bone1.setRotationMatrix(n,e.Space.WORLD,this.mesh),this._bone1Mat.copyFrom(n),this._slerping=!1),this._bone2.setAxisAngle(this._bendAxis,v,e.Space.LOCAL),this._bone2Ang=v},t})();e.BoneIKController=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(t,i,r,n){this.upAxis=e.Vector3.Up(),this.adjustYaw=0,this.adjustPitch=0,this.adjustRoll=0,this._tmpVec1=e.Vector3.Zero(),this._tmpVec2=e.Vector3.Zero(),this._tmpVec3=e.Vector3.Zero(),this._tmpVec4=e.Vector3.Zero(),this._tmpMat1=e.Matrix.Identity(),this._tmpMat2=e.Matrix.Identity(),this.mesh=t,this.bone=i,this.target=r,n&&(n.adjustYaw&&(this.adjustYaw=n.adjustYaw),n.adjustPitch&&(this.adjustPitch=n.adjustPitch),n.adjustRoll&&(this.adjustRoll=n.adjustRoll))}return t.prototype.update=function(){var t=this.bone,i=this.target,r=this._tmpVec1,n=this._tmpVec2,o=this._tmpVec3,s=this._tmpVec4,a=this._tmpMat1,h=this._tmpMat2;t.getAbsolutePositionToRef(this.mesh,r),i.subtractToRef(r,n),n.normalize(),e.Vector3.CrossToRef(this.upAxis,n,o),o.normalize(),e.Vector3.CrossToRef(n,o,s),s.normalize(),e.Matrix.FromXYZAxesToRef(o,s,n,a),(this.adjustYaw||this.adjustPitch||this.adjustRoll)&&(e.Matrix.RotationYawPitchRollToRef(this.adjustYaw,this.adjustPitch,this.adjustRoll,h),h.multiplyToRef(a,a)),this.bone.setRotationMatrix(a,e.Space.WORLD,this.mesh)},t})();e.BoneLookController=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._lastAbsoluteTransformsUpdateId=-1,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||this.prepare(),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;t-1&&this._meshesWithPoseMatrix.splice(t,1)},t.prototype._computeTransformMatrices=function(e,t){for(var i=0;i0&&(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-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;o0&&(e=this._meshesWithPoseMatrix[0].getPoseMatrix()),e},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;c0){for(var t=0;t0&&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)},t.prototype.directRender=function(e,t){for(var i=this._scene.getEngine(),r=0;r-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})();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,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:e<=0&&(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;ta?a:Math.floor(h);var c,l,u,f,d=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,p=[],m=[],g=[],_=[],v=[],y=[],x=[],b=[],A=[],T=[];if(r.length<2){var E=[],M=[];for(u=0;u0&&(O=P[f].subtract(P[f-1]).length(),D=O+x[l],v[l].push(D),x[l]=D),f++;o&&(f--,p.push(P[0].x,P[0].y,P[0].z),O=P[f].subtract(P[0]).length(),D=O+x[l],v[l].push(D),x[l]=D),A[l]=S+R,T[l]=C,C+=S+R}var I,L,w,B;for(u=0;u1?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;_++){for(var v=_/u,y=v*Math.PI*h,x=0;x<=f;x++){var b=x/f,A=b*Math.PI*2*a,T=e.Matrix.RotationZ(-y),E=e.Matrix.RotationY(A),M=e.Vector3.TransformCoordinates(e.Vector3.Up(),T),P=e.Vector3.TransformCoordinates(M,E),S=P.multiply(l),C=P.divide(l).normalize();p.push(S.x,S.y,S.z),m.push(C.x,C.y,C.z),g.push(b,v)}if(_>0)for(var R=p.length/3,O=R-2*(f+1);O+f+21?1:i.arc||1,f=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,d=i.faceUV||new Array(3),p=i.faceColors,m=1!==u&&l?2:0,g=c?h:1,_=2+(1+m)*g;for(r=0;r<_;r++)p&&void 0===p[r]&&(p[r]=new e.Color4(1,1,1,1));for(r=0;r<_;r++)d&&void 0===d[r]&&(d[r]=new e.Vector4(0,0,1,1));var v,y,x,b,A,T,E=[],M=[],P=[],S=[],C=[],R=2*Math.PI*u/a,O=(s-o)/2/n,D=e.Vector3.Zero(),I=e.Vector3.Zero(),L=e.Vector3.Zero(),w=e.Vector3.Zero(),B=e.Vector3.Zero(),F=e.Axis.Y,V=1,N=1,U=0,z=0;for(b=0;b<=h;b++)for(y=b/h,x=(y*(o-s)+s)/2,V=c&&0!==b&&b!==h?2:1,T=0;T0&&(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,m=0,g=0;for(g=0;g1?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;d=r.length?0:i.type||0,u=i.size,f=i.sizeX||u||1,d=i.sizeY||u||1,p=i.sizeZ||u||1,m=i.custom||r[l],g=m.face.length,_=i.faceUV||new Array(g),v=i.faceColors,y=void 0===i.flat||i.flat,x=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,b=[],A=[],T=[],E=[],M=[],P=0,S=0,C=[],R=0,O=0;if(y)for(O=0;O1)for(var h=0;hthis.value;case i.IsLesser:return this._effectiveTarget[this._property]-1&&this._scene._actionManagers.splice(e,1)},t.prototype.getScene=function(){return this._scene},t.prototype.hasSpecificTriggers=function(e){for(var t=0;t-1)return!0}return!1},t.prototype.hasSpecificTrigger=function(e){for(var t=0;t=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=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;r0;if(2===i.type?f.push(o):f.push(r),m){for(var g=new Array,_=0;_0){var f=u.properties[0].value,d=null===u.properties[0].targetType?f:n.getMeshByName(f);d._meshId&&(d.mesh=n.getMeshByID(d._meshId)),l={trigger:e.ActionManager[u.name],parameter:d}}else l=e.ActionManager[u.name];for(var p=0;p0&&(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){if(this.delayLoadState!==e.Engine.DELAYLOADSTATE_LOADING){if(this.isReady())return void(i&&i());this.delayLoadState=e.Engine.DELAYLOADSTATE_LOADING,this._queueLoad(t,i)}},t.prototype._queueLoad=function(t,i){var r=this;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;a0){for(var i=0;i0){for(var i=0;i0){for(var i=0;i0){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 m=new Float32Array(t,s.colorsAttrDesc.offset,s.colorsAttrDesc.count);i.setVerticesData(e.VertexBuffer.ColorKind,m,!1,s.colorsAttrDesc.stride)}if(s.matricesIndicesAttrDesc&&s.matricesIndicesAttrDesc.count>0){var g=new Int32Array(t,s.matricesIndicesAttrDesc.offset,s.matricesIndicesAttrDesc.count);i.setVerticesData(e.VertexBuffer.MatricesIndicesKind,g,!1)}if(s.matricesWeightsAttrDesc&&s.matricesWeightsAttrDesc.count>0){var _=new Float32Array(t,s.matricesWeightsAttrDesc.offset,s.matricesWeightsAttrDesc.count);i.setVerticesData(e.VertexBuffer.MatricesWeightsKind,_,!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>8),P.push((16711680&S)>>16),P.push(S>>24)}i.setVerticesData(e.VertexBuffer.MatricesIndicesKind,P,!1)}if(t.matricesIndicesExtra)if(t.matricesIndicesExtra._isExpanded)delete t.matricesIndices._isExpanded,i.setVerticesData(e.VertexBuffer.MatricesIndicesExtraKind,t.matricesIndicesExtra,!1);else{for(var P=[],x=0;x>8),P.push((16711680&S)>>16),P.push(S>>24)}i.setVerticesData(e.VertexBuffer.MatricesIndicesExtraKind,P,!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 C=0;Cthis._maxX||tthis._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,!(ethis._maxX||tthis._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=(this._subdivisionsX,this._subdivisionsY,Math.floor((e+this._maxX)*this._subdivisionsX/this._width)),n=Math.floor(-(t+this._maxZ)*this._subdivisionsY/this._height+this._subdivisionsY),o=this._heightQuads[n*this._subdivisionsX+r];return i=t0&&(c=!0,this._soundLoaded(i));break;case"String":h.push(i);case"Array":0===h.length&&(h=i);for(var l=0;l0&&(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.prototype.serialize=function(){var e={name:this.name,url:this.name,autoplay:this.autoplay,loop:this.loop,volume:this._volume,spatialSound:this.spatialSound,maxDistance:this.maxDistance,rolloffFactor:this.rolloffFactor,refDistance:this.refDistance,distanceModel:this.distanceModel,playbackRate:this._playbackRate,panningModel:this._panningModel,soundTrackId:this.soundTrackId};return this.spatialSound&&(this._connectedMesh&&(e.connectedMeshId=this._connectedMesh.id),e.position=this._position.asArray(),e.refDistance=this.refDistance,e.distanceModel=this.distanceModel,e.isDirectional=this._isDirectional,e.localDirectionToMesh=this._localDirection.asArray(),e.coneInnerAngle=this._coneInnerAngle,e.coneOuterAngle=this._coneOuterAngle,e.coneOuterGain=this._coneOuterGain),e},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&&(t.soundTrackId===-1?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);t!==-1&&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;t4&&(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 u=n.join("\n");return this._cachedDefines!==u&&(this._cachedDefines=u,this._glowMapGenerationEffect=this._scene.getEngine().createEffect("glowMapGeneration",o,["world","mBones","viewProjection","diffuseMatrix","color","emissiveMatrix"],["diffuseSampler","emissiveSampler"],u)),this._glowMapGenerationEffect.isReady()},i.prototype.render=function(){var t=this._glowMapMergeEffect;if(t.isReady()&&this._blurTexture.isReady()){var i=this._scene.getEngine();this.onBeforeComposeObservable.notifyObservers(this),i.enableEffect(t),i.setState(!1);var r=i.getStencilBuffer(),n=i.getStencilFunction(),o=i.getStencilMask(),s=i.getAlphaMode();t.setTexture("textureSampler",this._blurTexture),i.bindBuffers(this._vertexBuffers,this._indexBuffer,t),i.setAlphaMode(this._options.alphaBlendingMode),i.setStencilMask(0),i.setStencilBuffer(!0),i.setStencilFunctionReference(this._instanceGlowingMeshStencilReference),this.outerGlow&&(t.setFloat("offset",0),i.setStencilFunction(e.Engine.NOTEQUAL),i.draw(!0,0,6)),this.innerGlow&&(t.setFloat("offset",1),i.setStencilFunction(e.Engine.EQUAL),i.draw(!0,0,6)),i.setStencilFunction(n),i.setStencilMask(o),i.setAlphaMode(s),i.setStencilBuffer(r),this.onAfterComposeObservable.notifyObservers(this);var a=this._mainTexture.getSize();this.setMainTextureSize(),a.width===this._mainTextureDesiredSize.width&&a.height===this._mainTextureDesiredSize.height||(this.onSizeChangedObservable.notifyObservers(this),this.disposeTextureAndPostProcesses(),this.createTextureAndPostProcesses())}},i.prototype.addExcludedMesh=function(e){var t=this._excludedMeshes[e.uniqueId];t||(this._excludedMeshes[e.uniqueId]={mesh:e,beforeRender:e.onBeforeRenderObservable.add((function(e){e.getEngine().setStencilBuffer(!1)})),afterRender:e.onAfterRenderObservable.add((function(e){e.getEngine().setStencilBuffer(!0)}))})},i.prototype.removeExcludedMesh=function(e){var t=this._excludedMeshes[e.uniqueId];t&&(e.onBeforeRenderObservable.remove(t.beforeRender),e.onAfterRenderObservable.remove(t.afterRender)),this._excludedMeshes[e.uniqueId]=void 0},i.prototype.addMesh=function(e,t,i){var r=this;void 0===i&&(i=!1);var n=this._meshes[e.uniqueId];n?n.color=t:this._meshes[e.uniqueId]={mesh:e,color:t,observerHighlight:e.onBeforeRenderObservable.add((function(e){r._excludedMeshes[e.uniqueId]?r.defaultStencilReference(e):e.getScene().getEngine().setStencilFunctionReference(r._instanceGlowingMeshStencilReference)})),observerDefault:e.onAfterRenderObservable.add(this.defaultStencilReference),glowEmissiveOnly:i},this._shouldRender=!0},i.prototype.removeMesh=function(e){var t=this._meshes[e.uniqueId];t&&(e.onBeforeRenderObservable.remove(t.observerHighlight),e.onAfterRenderObservable.remove(t.observerDefault)),this._meshes[e.uniqueId]=void 0,this._shouldRender=!1;for(var i in this._meshes)if(i){this._shouldRender=!0;break}},i.prototype.shouldRender=function(){return this.isEnabled&&this._shouldRender},i.prototype.setMainTextureSize=function(){this._options.mainTextureFixedSize?(this._mainTextureDesiredSize.width=this._options.mainTextureFixedSize,this._mainTextureDesiredSize.height=this._options.mainTextureFixedSize):(this._mainTextureDesiredSize.width=this._engine.getRenderingCanvas().width*this._options.mainTextureRatio,this._mainTextureDesiredSize.height=this._engine.getRenderingCanvas().height*this._options.mainTextureRatio,this._mainTextureDesiredSize.width=e.Tools.GetExponentOfTwo(this._mainTextureDesiredSize.width,this._maxSize),this._mainTextureDesiredSize.height=e.Tools.GetExponentOfTwo(this._mainTextureDesiredSize.height,this._maxSize))},i.prototype.defaultStencilReference=function(e){e.getScene().getEngine().setStencilFunctionReference(i.normalMeshStencilReference)},i.prototype.disposeTextureAndPostProcesses=function(){this._blurTexture.dispose(),this._mainTexture.dispose(),this._downSamplePostprocess.dispose(),this._horizontalBlurPostprocess.dispose(),this._verticalBlurPostprocess.dispose()},i.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.disposeTextureAndPostProcesses();for(var i in this._meshes){var r=this._meshes[i];r&&r.mesh&&(r.mesh.onBeforeRenderObservable.remove(r.observerHighlight),r.mesh.onAfterRenderObservable.remove(r.observerDefault))}this._meshes=null;for(var i in this._excludedMeshes){var r=this._excludedMeshes[i];r&&(r.mesh.onBeforeRenderObservable.remove(r.beforeRender),r.mesh.onAfterRenderObservable.remove(r.afterRender))}this._excludedMeshes=null;var n=this._scene.highlightLayers.indexOf(this,0);n>-1&&this._scene.highlightLayers.splice(n,1),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this.onBeforeRenderMainTextureObservable.clear(),this.onBeforeBlurObservable.clear(),this.onBeforeComposeObservable.clear(),this.onAfterComposeObservable.clear(),this.onSizeChangedObservable.clear()},i})();i.neutralColor=new e.Color4(0,0,0,0),i.glowingMeshStencilReference=2,i.normalMeshStencilReference=1,e.HighlightLayer=i})(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\n\n#include[0..maxSimultaneousLights]\n#include\n#include\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\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\n#ifdef REFLECTIONFRESNEL\nuniform vec4 reflectionLeftColor;\nuniform vec4 reflectionRightColor;\n#endif\n#endif\n#ifdef CAMERACOLORGRADING\n#include \n#include\n#endif\n#ifdef CAMERACOLORCURVES\n#include\n#include\n#endif\n#include\n#include\n#include\n#include\nvoid main(void) {\n#include\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#include\n#ifdef DIFFUSE\nbaseColor=texture2D(diffuseSampler,vDiffuseUV+uvOffset);\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+uvOffset).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+uvOffset);\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#ifdef LIGHTMAP\nvec3 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset).rgb*vLightmapInfos.y;\n#endif\n#include[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+uvOffset);\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+uvOffset).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\n#ifdef LIGHTMAP\n#ifndef LIGHTMAPEXCLUDED\n#ifdef USELIGHTMAPASSHADOWMAP\ncolor.rgb*=lightmapColor;\n#else\ncolor.rgb+=lightmapColor;\n#endif\n#endif\n#endif\n#include\n#include\n#ifdef CAMERACOLORGRADING\ncolor=colorGrades(color);\n#endif\n#ifdef CAMERACOLORCURVES\ncolor.rgb=applyColorCurves(color.rgb);\n#endif\ngl_FragColor=color;\n}", 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\n\n#include\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\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include\n#include\n#include[0..maxSimultaneousLights]\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#endif\n#ifdef REFLECTIONMAP_EQUIRECTANGULAR_FIXED\nvarying vec3 vDirectionW;\n#endif\n#include\nvoid main(void) {\n#ifdef REFLECTIONMAP_SKYBOX\nvPositionUVW=position;\n#endif \n#include\n#include\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\n#include\n#include[0..maxSimultaneousLights]\n#ifdef VERTEXCOLOR\n\nvColor=color;\n#endif\n#include\n#include\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\n\n#include\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\n#include\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}",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 ((lumaBlumaMax)) {\ngl_FragColor=rgbA;\n}\nelse {\ngl_FragColor=rgbB;\n}\n}",glowBlurPostProcessPixelShader:"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n\nuniform vec2 screenSize;\nuniform vec2 direction;\nuniform float blurWidth;\n\nfloat getLuminance(vec3 color)\n{\nreturn dot(color,vec3(0.2126,0.7152,0.0722));\n}\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{\n\nvec4 texel=texture2D(textureSampler,start+texelOffset);\nbaseColor.a+=texel.a*weights[i];\n\nfloat luminance=getLuminance(baseColor.rgb);\nfloat luminanceTexel=getLuminance(texel.rgb);\nfloat choice=step(luminanceTexel,luminance);\nbaseColor.rgb=choice*baseColor.rgb+(1.0-choice)*texel.rgb;\ntexelOffset+=texelStep;\n}\ngl_FragColor=baseColor;\n}",glowMapGenerationPixelShader:"#ifdef ALPHATEST\nvarying vec2 vUVDiffuse;\nuniform sampler2D diffuseSampler;\n#endif\n#ifdef EMISSIVE\nvarying vec2 vUVEmissive;\nuniform sampler2D emissiveSampler;\n#endif\nuniform vec4 color;\nvoid main(void)\n{\n#ifdef ALPHATEST\nif (texture2D(diffuseSampler,vUVDiffuse).a<0.4)\ndiscard;\n#endif\n#ifdef EMISSIVE\ngl_FragColor=texture2D(emissiveSampler,vUVEmissive);\n#else\ngl_FragColor=color;\n#endif\n}",glowMapGenerationVertexShader:"\nattribute vec3 position;\n#include\n\n#include\nuniform mat4 viewProjection;\nvarying vec4 vPosition;\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef ALPHATEST\nvarying vec2 vUVDiffuse;\nuniform mat4 diffuseMatrix;\n#endif\n#ifdef EMISSIVE\nvarying vec2 vUVEmissive;\nuniform mat4 emissiveMatrix;\n#endif\nvoid main(void)\n{\n#include\n#include\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 DIFFUSEUV1\nvUVDiffuse=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n#endif\n#ifdef DIFFUSEUV2\nvUVDiffuse=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n#ifdef EMISSIVE\n#ifdef EMISSIVEUV1\nvUVEmissive=vec2(emissiveMatrix*vec4(uv,1.0,0.0));\n#endif\n#ifdef EMISSIVEUV2\nvUVEmissive=vec2(emissiveMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n}",glowMapMergePixelShader:"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n\nuniform float offset;\nvoid main(void) {\nvec4 baseColor=texture2D(textureSampler,vUV);\nbaseColor.a=abs(offset-baseColor.a);\ngl_FragColor=baseColor;\n}",glowMapMergeVertexShader:"\nattribute vec2 position;\n\nvarying vec2 vUV;\nconst vec2 madd=vec2(0.5,0.5);\nvoid main(void) {\nvUV=position*madd+madd;\ngl_Position=vec4(position,0.0,1.0);\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 (luminance1.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}",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\n\nuniform float offset;\n#include\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\n#include\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[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 vec3 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) || defined(METALLICWORKFLOW) \nvarying vec2 vReflectivityUV;\nuniform vec2 vReflectivityInfos;\nuniform sampler2D reflectivitySampler;\n#endif\n\n#include\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\n#endif\n#ifdef CAMERACOLORGRADING\n#include\n#endif\n#ifdef CAMERACOLORCURVES\n#include\n#endif\n\n#include\n#include\n#ifdef CAMERACOLORGRADING\n#include\n#endif\n#ifdef CAMERACOLORCURVES\n#include\n#endif\n#include\n#include\n#include\n#include\n#include\n#include\n\n#include\nvoid main(void) {\n#include\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\n#include\n\nvec4 surfaceAlbedo=vec4(1.,1.,1.,1.);\nvec3 surfaceAlbedoContribution=vAlbedoColor.rgb;\n\nfloat alpha=vAlbedoColor.a;\n#ifdef ALBEDO\nsurfaceAlbedo=texture2D(albedoSampler,vAlbedoUV+uvOffset);\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\nvec3 ambientColor=vec3(1.,1.,1.);\n#ifdef AMBIENT\nambientColor=texture2D(ambientSampler,vAmbientUV+uvOffset).rgb*vAmbientInfos.y;\nambientColor=vec3(1.,1.,1.)-((vec3(1.,1.,1.)-ambientColor)*vAmbientInfos.z);\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+uvOffset);\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 METALLICWORKFLOW\nvec2 metallicRoughness=surfaceReflectivityColor.rg;\n#ifdef METALLICROUGHNESSMAP\nvec4 surfaceMetallicColorMap=texture2D(reflectivitySampler,vReflectivityUV+uvOffset);\n\nmetallicRoughness.r*=surfaceMetallicColorMap.r;\n#ifdef METALLICROUGHNESSGSTOREINALPHA\nmetallicRoughness.g*=surfaceMetallicColorMap.a;\n#else\n#ifdef METALLICROUGHNESSGSTOREINGREEN\nmetallicRoughness.g*=surfaceMetallicColorMap.g;\n#endif\n#endif\n#endif\n\nvec3 baseColor=surfaceAlbedo.rgb;\n\nsurfaceAlbedo.rgb*=(1.0-metallicRoughness.r);\n\n\nconst vec3 DefaultSpecularReflectanceDielectric=vec3(0.04,0.04,0.04);\n\nsurfaceReflectivityColor=mix(DefaultSpecularReflectanceDielectric,baseColor,metallicRoughness.r);\n#ifdef OVERLOADEDVALUES\nsurfaceReflectivityColor=mix(surfaceReflectivityColor,vOverloadedReflectivity,vOverloadedIntensity.z);\n#endif\nmicroSurface=1.0-metallicRoughness.g;\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.; \n#ifdef LIGHTMAP\nvec3 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset).rgb*vLightmapInfos.y;\n#endif\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[0..maxSimultaneousLights]\n#ifdef SPECULARTERM\nlightSpecularContribution*=vLightingIntensity.w;\n#endif\n#ifdef OPACITY\nvec4 opacityMap=texture2D(opacitySampler,vOpacityUV+uvOffset);\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+uvOffset).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\n#ifndef LIGHTMAPEXCLUDED\n#ifdef USELIGHTMAPASSHADOWMAP\nfinalColor.rgb*=lightmapColor;\n#else\nfinalColor.rgb+=lightmapColor;\n#endif\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\n#include(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\n\n#include\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 vec3 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) || defined(METALLICWORKFLOW) \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\n#include\n#include[0..maxSimultaneousLights]\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#endif\n#ifdef REFLECTIONMAP_EQUIRECTANGULAR_FIXED\nvarying vec3 vDirectionW;\n#endif\n#include\nvoid main(void) {\n#ifdef REFLECTIONMAP_SKYBOX\nvPositionUVW=position;\n#endif \n#include\n#include\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) || defined(METALLICWORKFLOW) \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\n\n#include\n\n#include[0..maxSimultaneousLights]\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n\n#include\n}",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}",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:"#ifndef FULLFLOAT\nvec4 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}\n#endif\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;\n#ifndef FULLFLOAT\ngl_FragColor=vec4(packHalf(moment1),packHalf(moment2));\n#else\ngl_FragColor=vec4(moment1,moment2,1.0,1.0);\n#endif\n#else\n#ifndef FULLFLOAT\ngl_FragColor=pack(depth);\n#else\ngl_FragColor=vec4(depth,1.0,1.0,1.0);\n#endif\n#endif\n}",shadowMapVertexShader:"\nattribute vec3 position;\n#include\n\n#include\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\n#include\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}",spritesPixelShader:"uniform bool alphaTest;\nvarying vec4 vColor;\n\nvarying vec2 vUV;\nuniform sampler2D diffuseSampler;\n\n#include\nvoid main(void) {\nvec4 color=texture2D(diffuseSampler,vUV);\nif (alphaTest) \n{\nif (color.a<0.95)\ndiscard;\n}\ncolor*=vColor;\n#include\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\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; i0.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}",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; i1.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:"vec2 uvOffset=vec2(0.0,0.0);\n#if defined(BUMP) || defined(PARALLAX)\nmat3 TBN=cotangent_frame(normalW*vBumpInfos.y,-viewDirectionW,vBumpUV);\n#endif\n#ifdef PARALLAX\nmat3 invTBN=transposeMat3(TBN);\n#ifdef PARALLAXOCCLUSION\nuvOffset=parallaxOcclusion(invTBN*-viewDirectionW,invTBN*normalW,vBumpUV,vBumpInfos.z);\n#else\nuvOffset=parallaxOffset(invTBN*viewDirectionW,vBumpInfos.z);\n#endif\n#endif\n#ifdef BUMP\nnormalW=perturbNormal(viewDirectionW,TBN,vBumpUV+uvOffset);\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; icurrRayHeight)\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#if defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X}) && defined(LIGHTMAPNOSPECULAR{X})\n\n#else\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#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\n#if defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X})\ndiffuseBase+=lightmapColor*shadow;\n#ifdef SPECULARTERM\n#ifndef LIGHTMAPNOSPECULAR{X}\nspecularBase+=info.specular*shadow*lightmapColor;\n#endif\n#endif\n#else\ndiffuseBase+=info.diffuse*shadow;\n#ifdef SPECULARTERM\nspecularBase+=info.specular*shadow;\n#endif\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",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#if defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X}) && defined(LIGHTMAPNOSPECULAR{X})\n\n#else\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#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\n#if defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X})\nlightDiffuseContribution+=lightmapColor*notShadowLevel;\n#ifdef SPECULARTERM\n#ifndef LIGHTMAPNOSPECULAR{X}\nlightSpecularContribution+=info.specular*notShadowLevel*lightmapColor;\n#endif\n#endif\n#else\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\n#endif",pbrShadowFunctions:"\n#ifdef SHADOWS\n#ifndef SHADOWFULLFLOAT\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}\n#endif\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;\n#ifndef SHADOWFULLFLOAT\nfloat shadow=unpack(textureCube(shadowSampler,directionToLight))+bias;\n#else\nfloat shadow=textureCube(shadowSampler,directionToLight).x+bias;\n#endif\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;\n#ifndef SHADOWFULLFLOAT\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[0]*mapSize))1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\n#ifndef SHADOWFULLFLOAT\nfloat shadow=unpack(texture2D(shadowSampler,uv))+bias;\n#else\nfloat shadow=texture2D(shadowSampler,uv).x+bias;\n#endif\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;\n#ifndef SHADOWFULLFLOAT\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[0]*mapSize))1.0 || uv.y<0. || uv.y>1.0 || depth.z>=1.0)\n{\nreturn 1.0;\n}\nvec4 texel=texture2D(shadowSampler,uv);\n#ifndef SHADOWFULLFLOAT\nvec2 moments=vec2(unpackHalf(texel.xy),unpackHalf(texel.zw));\n#else\nvec2 moments=texel.xy;\n#endif\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\n#ifndef SHADOWFULLFLOAT\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}\n#endif\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;\n#ifndef SHADOWFULLFLOAT\nfloat shadow=unpack(textureCube(shadowSampler,directionToLight))+bias;\n#else\nfloat shadow=textureCube(shadowSampler,directionToLight).x+bias;\n#endif\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;\n#ifndef SHADOWFULLFLOAT\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[0]*mapSize))1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\n#ifndef SHADOWFULLFLOAT\nfloat shadow=unpack(texture2D(shadowSampler,uv))+bias;\n#else\nfloat shadow=texture2D(shadowSampler,uv).x+bias;\n#endif\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;\n#ifndef SHADOWFULLFLOAT\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[0]*mapSize))1.0 || uv.y<0. || uv.y>1.0 || depth.z>=1.0)\n{\nreturn 1.0;\n}\nvec4 texel=texture2D(shadowSampler,uv);\n#ifndef SHADOWFULLFLOAT\nvec2 moments=vec2(unpackHalf(texel.xy),unpackHalf(texel.zw));\n#else\nvec2 moments=texel.xy;\n#endif\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"},("undefined"!=typeof window&&window.module||"undefined"!=typeof module)&&"undefined"!=typeof module.exports&&(module.exports=BABYLON); \ No newline at end of file diff --git a/dist/preview release/babylon.d.ts b/dist/preview release/babylon.d.ts index 628bc01535e..dccdc151bcc 100644 --- a/dist/preview release/babylon.d.ts +++ b/dist/preview release/babylon.d.ts @@ -1477,6 +1477,7 @@ declare module BABYLON { private _viewMatrix; private _projectionMatrix; private _frustumPlanes; + readonly frustumPlanes: Plane[]; private _selectionOctree; private _pointerOverMesh; private _pointerOverSprite; @@ -2172,187 +2173,6 @@ declare module BABYLON { } } -declare module BABYLON { - class Analyser { - SMOOTHING: number; - FFT_SIZE: number; - BARGRAPHAMPLITUDE: number; - DEBUGCANVASPOS: { - x: number; - y: number; - }; - DEBUGCANVASSIZE: { - width: number; - height: number; - }; - private _byteFreqs; - private _byteTime; - private _floatFreqs; - private _webAudioAnalyser; - private _debugCanvas; - private _debugCanvasContext; - private _scene; - private _registerFunc; - private _audioEngine; - constructor(scene: Scene); - getFrequencyBinCount(): number; - getByteFrequencyData(): Uint8Array; - getByteTimeDomainData(): Uint8Array; - getFloatFrequencyData(): Uint8Array; - drawDebugCanvas(): void; - stopDebugCanvas(): void; - connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void; - dispose(): void; - } -} - -declare module BABYLON { - class AudioEngine { - private _audioContext; - private _audioContextInitialized; - canUseWebAudio: boolean; - masterGain: GainNode; - private _connectedAnalyser; - WarnedWebAudioUnsupported: boolean; - unlocked: boolean; - onAudioUnlocked: () => any; - isMP3supported: boolean; - isOGGsupported: boolean; - readonly audioContext: AudioContext; - constructor(); - private _unlockiOSaudio(); - private _initializeAudioContext(); - dispose(): void; - getGlobalVolume(): number; - setGlobalVolume(newVolume: number): void; - connectToAnalyser(analyser: Analyser): void; - } -} - -declare module BABYLON { - class Sound { - name: string; - autoplay: boolean; - loop: boolean; - useCustomAttenuation: boolean; - soundTrackId: number; - spatialSound: boolean; - refDistance: number; - rolloffFactor: number; - maxDistance: number; - distanceModel: string; - private _panningModel; - onended: () => any; - private _playbackRate; - private _streaming; - private _startTime; - private _startOffset; - private _position; - private _localDirection; - private _volume; - private _isLoaded; - private _isReadyToPlay; - isPlaying: boolean; - isPaused: boolean; - private _isDirectional; - private _readyToPlayCallback; - private _audioBuffer; - private _soundSource; - private _streamingSource; - private _soundPanner; - private _soundGain; - private _inputAudioNode; - private _ouputAudioNode; - private _coneInnerAngle; - private _coneOuterAngle; - private _coneOuterGain; - private _scene; - private _connectedMesh; - private _customAttenuationFunction; - private _registerFunc; - private _isOutputConnected; - private _htmlAudioElement; - private _urlType; - /** - * Create a sound and attach it to a scene - * @param name Name of your sound - * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer - * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played - * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming - */ - constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: () => void, options?: any); - dispose(): void; - private _soundLoaded(audioData); - setAudioBuffer(audioBuffer: AudioBuffer): void; - updateOptions(options: any): void; - private _createSpatialParameters(); - private _updateSpatialParameters(); - switchPanningModelToHRTF(): void; - switchPanningModelToEqualPower(): void; - private _switchPanningModel(); - connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void; - /** - * Transform this sound into a directional source - * @param coneInnerAngle Size of the inner cone in degree - * @param coneOuterAngle Size of the outer cone in degree - * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0) - */ - setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void; - setPosition(newPosition: Vector3): void; - setLocalDirectionToMesh(newLocalDirection: Vector3): void; - private _updateDirection(); - updateDistanceFromListener(): void; - setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void; - /** - * Play the sound - * @param time (optional) Start the sound after X seconds. Start immediately (0) by default. - * @param offset (optional) Start the sound setting it at a specific time - */ - play(time?: number, offset?: number): void; - private _onended(); - /** - * Stop the sound - * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default. - */ - stop(time?: number): void; - pause(): void; - setVolume(newVolume: number, time?: number): void; - setPlaybackRate(newPlaybackRate: number): void; - getVolume(): number; - attachToMesh(meshToConnectTo: AbstractMesh): void; - detachFromMesh(): void; - private _onRegisterAfterWorldMatrixUpdate(connectedMesh); - clone(): Sound; - getAudioBuffer(): AudioBuffer; - serialize(): any; - static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound; - } -} - -declare module BABYLON { - class SoundTrack { - private _outputAudioNode; - private _inputAudioNode; - private _trackConvolver; - private _scene; - id: number; - soundCollection: Array; - private _isMainTrack; - private _connectedAnalyser; - private _options; - private _isInitialized; - constructor(scene: Scene, options?: any); - private _initializeSoundTrackAudioGraph(); - dispose(): void; - AddSound(sound: Sound): void; - RemoveSound(sound: Sound): void; - setVolume(newVolume: number): void; - switchPanningModelToHRTF(): void; - switchPanningModelToEqualPower(): void; - connectToAnalyser(analyser: Analyser): void; - } -} - declare module BABYLON { class Animatable { target: any; @@ -2581,24 +2401,205 @@ declare module BABYLON { } declare module BABYLON { - class Bone extends Node { + class Analyser { + SMOOTHING: number; + FFT_SIZE: number; + BARGRAPHAMPLITUDE: number; + DEBUGCANVASPOS: { + x: number; + y: number; + }; + DEBUGCANVASSIZE: { + width: number; + height: number; + }; + private _byteFreqs; + private _byteTime; + private _floatFreqs; + private _webAudioAnalyser; + private _debugCanvas; + private _debugCanvasContext; + private _scene; + private _registerFunc; + private _audioEngine; + constructor(scene: Scene); + getFrequencyBinCount(): number; + getByteFrequencyData(): Uint8Array; + getByteTimeDomainData(): Uint8Array; + getFloatFrequencyData(): Uint8Array; + drawDebugCanvas(): void; + stopDebugCanvas(): void; + connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void; + dispose(): void; + } +} + +declare module BABYLON { + class AudioEngine { + private _audioContext; + private _audioContextInitialized; + canUseWebAudio: boolean; + masterGain: GainNode; + private _connectedAnalyser; + WarnedWebAudioUnsupported: boolean; + unlocked: boolean; + onAudioUnlocked: () => any; + isMP3supported: boolean; + isOGGsupported: boolean; + readonly audioContext: AudioContext; + constructor(); + private _unlockiOSaudio(); + private _initializeAudioContext(); + dispose(): void; + getGlobalVolume(): number; + setGlobalVolume(newVolume: number): void; + connectToAnalyser(analyser: Analyser): void; + } +} + +declare module BABYLON { + class Sound { name: string; - children: Bone[]; - animations: Animation[]; - length: number; - private _skeleton; - _matrix: Matrix; - private _restPose; - private _baseMatrix; - private _worldTransform; - private _absoluteTransform; - private _invertedAbsoluteTransform; - private _parent; - private _scaleMatrix; - private _scaleVector; - private _negateScaleChildren; - private _scalingDeterminant; - constructor(name: string, skeleton: Skeleton, parentBone: Bone, matrix: Matrix, restPose?: Matrix); + autoplay: boolean; + loop: boolean; + useCustomAttenuation: boolean; + soundTrackId: number; + spatialSound: boolean; + refDistance: number; + rolloffFactor: number; + maxDistance: number; + distanceModel: string; + private _panningModel; + onended: () => any; + private _playbackRate; + private _streaming; + private _startTime; + private _startOffset; + private _position; + private _localDirection; + private _volume; + private _isLoaded; + private _isReadyToPlay; + isPlaying: boolean; + isPaused: boolean; + private _isDirectional; + private _readyToPlayCallback; + private _audioBuffer; + private _soundSource; + private _streamingSource; + private _soundPanner; + private _soundGain; + private _inputAudioNode; + private _ouputAudioNode; + private _coneInnerAngle; + private _coneOuterAngle; + private _coneOuterGain; + private _scene; + private _connectedMesh; + private _customAttenuationFunction; + private _registerFunc; + private _isOutputConnected; + private _htmlAudioElement; + private _urlType; + /** + * Create a sound and attach it to a scene + * @param name Name of your sound + * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer + * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played + * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming + */ + constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: () => void, options?: any); + dispose(): void; + private _soundLoaded(audioData); + setAudioBuffer(audioBuffer: AudioBuffer): void; + updateOptions(options: any): void; + private _createSpatialParameters(); + private _updateSpatialParameters(); + switchPanningModelToHRTF(): void; + switchPanningModelToEqualPower(): void; + private _switchPanningModel(); + connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void; + /** + * Transform this sound into a directional source + * @param coneInnerAngle Size of the inner cone in degree + * @param coneOuterAngle Size of the outer cone in degree + * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0) + */ + setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void; + setPosition(newPosition: Vector3): void; + setLocalDirectionToMesh(newLocalDirection: Vector3): void; + private _updateDirection(); + updateDistanceFromListener(): void; + setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void; + /** + * Play the sound + * @param time (optional) Start the sound after X seconds. Start immediately (0) by default. + * @param offset (optional) Start the sound setting it at a specific time + */ + play(time?: number, offset?: number): void; + private _onended(); + /** + * Stop the sound + * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default. + */ + stop(time?: number): void; + pause(): void; + setVolume(newVolume: number, time?: number): void; + setPlaybackRate(newPlaybackRate: number): void; + getVolume(): number; + attachToMesh(meshToConnectTo: AbstractMesh): void; + detachFromMesh(): void; + private _onRegisterAfterWorldMatrixUpdate(connectedMesh); + clone(): Sound; + getAudioBuffer(): AudioBuffer; + serialize(): any; + static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound; + } +} + +declare module BABYLON { + class SoundTrack { + private _outputAudioNode; + private _inputAudioNode; + private _trackConvolver; + private _scene; + id: number; + soundCollection: Array; + private _isMainTrack; + private _connectedAnalyser; + private _options; + private _isInitialized; + constructor(scene: Scene, options?: any); + private _initializeSoundTrackAudioGraph(); + dispose(): void; + AddSound(sound: Sound): void; + RemoveSound(sound: Sound): void; + setVolume(newVolume: number): void; + switchPanningModelToHRTF(): void; + switchPanningModelToEqualPower(): void; + connectToAnalyser(analyser: Analyser): void; + } +} + +declare module BABYLON { + class Bone extends Node { + name: string; + children: Bone[]; + animations: Animation[]; + length: number; + private _skeleton; + _matrix: Matrix; + private _restPose; + private _baseMatrix; + private _worldTransform; + private _absoluteTransform; + private _invertedAbsoluteTransform; + private _parent; + private _scaleMatrix; + private _scaleVector; + private _negateScaleChildren; + private _scalingDeterminant; + constructor(name: string, skeleton: Skeleton, parentBone: Bone, matrix: Matrix, restPose?: Matrix); getParent(): Bone; getLocalMatrix(): Matrix; getBaseMatrix(): Matrix; @@ -2776,143 +2777,517 @@ declare module BABYLON { } } -declare module BABYLON.Debug { - class AxesViewer { - private _xline; - private _yline; - private _zline; - private _xmesh; - private _ymesh; - private _zmesh; - scene: Scene; - scaleLines: number; - constructor(scene: Scene, scaleLines?: number); - update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void; +declare module BABYLON { + class ArcRotateCamera extends TargetCamera { + alpha: number; + beta: number; + radius: number; + target: Vector3; + inertialAlphaOffset: number; + inertialBetaOffset: number; + inertialRadiusOffset: number; + lowerAlphaLimit: any; + upperAlphaLimit: any; + lowerBetaLimit: number; + upperBetaLimit: number; + lowerRadiusLimit: any; + upperRadiusLimit: any; + inertialPanningX: number; + inertialPanningY: number; + angularSensibilityX: number; + angularSensibilityY: number; + pinchPrecision: number; + panningSensibility: number; + keysUp: number[]; + keysDown: number[]; + keysLeft: number[]; + keysRight: number[]; + wheelPrecision: number; + zoomOnFactor: number; + targetScreenOffset: Vector2; + allowUpsideDown: boolean; + _viewMatrix: Matrix; + _useCtrlForPanning: boolean; + _panningMouseButton: number; + inputs: ArcRotateCameraInputsManager; + _reset: () => void; + panningAxis: Vector3; + private _localDirection; + private _transformedDirection; + onCollide: (collidedMesh: AbstractMesh) => void; + checkCollisions: boolean; + collisionRadius: Vector3; + private _collider; + private _previousPosition; + private _collisionVelocity; + private _newPosition; + private _previousAlpha; + private _previousBeta; + private _previousRadius; + private _collisionTriggered; + private _targetBoundingCenter; + constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene); + _initCache(): void; + _updateCache(ignoreParentClass?: boolean): void; + private _getTargetPosition(); + _isSynchronizedViewMatrix(): boolean; + attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void; + detachControl(element: HTMLElement): void; + _checkInputs(): void; + private _checkLimits(); + rebuildAnglesAndRadius(): void; + setPosition(position: Vector3): void; + setTarget(target: Vector3, toBoundingCenter?: boolean): void; + _getViewMatrix(): Matrix; + private _onCollisionPositionChange; + zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void; + focusOn(meshesOrMinMaxVectorAndDistance: any, doNotUpdateMaxZ?: boolean): void; + /** + * @override + * Override Camera.createRigCamera + */ + createRigCamera(name: string, cameraIndex: number): Camera; + /** + * @override + * Override Camera._updateRigCameras + */ + _updateRigCameras(): void; dispose(): void; + getClassName(): string; } } -declare module BABYLON.Debug { - class BoneAxesViewer extends Debug.AxesViewer { - mesh: Mesh; - bone: Bone; - pos: Vector3; - xaxis: Vector3; - yaxis: Vector3; - zaxis: Vector3; - constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number); - update(): void; - dispose(): void; +declare module BABYLON { + class ArcRotateCameraInputsManager extends CameraInputsManager { + constructor(camera: ArcRotateCamera); + addMouseWheel(): ArcRotateCameraInputsManager; + addPointers(): ArcRotateCameraInputsManager; + addKeyboard(): ArcRotateCameraInputsManager; + addGamepad(): ArcRotateCameraInputsManager; + addVRDeviceOrientation(): ArcRotateCameraInputsManager; } } declare module BABYLON { - class DebugLayer { - private _scene; - static InspectorURL: string; - private _inspector; - constructor(scene: Scene); - /** Creates the inspector window. */ - private _createInspector(popup?); - isVisible(): boolean; - hide(): void; - show(popup?: boolean): void; + class Camera extends Node { + inputs: CameraInputsManager; + private static _PERSPECTIVE_CAMERA; + private static _ORTHOGRAPHIC_CAMERA; + private static _FOVMODE_VERTICAL_FIXED; + private static _FOVMODE_HORIZONTAL_FIXED; + private static _RIG_MODE_NONE; + private static _RIG_MODE_STEREOSCOPIC_ANAGLYPH; + private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL; + private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED; + private static _RIG_MODE_STEREOSCOPIC_OVERUNDER; + private static _RIG_MODE_VR; + private static _RIG_MODE_WEBVR; + static readonly PERSPECTIVE_CAMERA: number; + static readonly ORTHOGRAPHIC_CAMERA: number; + static readonly FOVMODE_VERTICAL_FIXED: number; + static readonly FOVMODE_HORIZONTAL_FIXED: number; + static readonly RIG_MODE_NONE: number; + static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number; + static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number; + static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number; + static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number; + static readonly RIG_MODE_VR: number; + static readonly RIG_MODE_WEBVR: number; + static ForceAttachControlToAlwaysPreventDefault: boolean; + position: Vector3; + upVector: Vector3; + orthoLeft: any; + orthoRight: any; + orthoBottom: any; + orthoTop: any; + fov: number; + minZ: number; + maxZ: number; + inertia: number; + mode: number; + isIntermediate: boolean; + viewport: Viewport; + layerMask: number; + fovMode: number; + cameraRigMode: number; + interaxialDistance: number; + isStereoscopicSideBySide: boolean; + _cameraRigParams: any; + _rigCameras: Camera[]; + _rigPostProcess: PostProcess; + private _computedViewMatrix; + _projectionMatrix: Matrix; + private _doNotComputeProjectionMatrix; + private _worldMatrix; + _postProcesses: PostProcess[]; + private _transformMatrix; + private _webvrViewMatrix; + _activeMeshes: SmartArray; + private _globalPosition; + private _frustumPlanes; + private _refreshFrustumPlanes; + constructor(name: string, position: Vector3, scene: Scene); + getClassName(): string; + /** + * @param {boolean} fullDetails - support for multiple levels of logging within scene loading + */ + toString(fullDetails?: boolean): string; + readonly globalPosition: Vector3; + getActiveMeshes(): SmartArray; + isActiveMesh(mesh: Mesh): boolean; + _initCache(): void; + _updateCache(ignoreParentClass?: boolean): void; + _updateFromScene(): void; + _isSynchronized(): boolean; + _isSynchronizedViewMatrix(): boolean; + _isSynchronizedProjectionMatrix(): boolean; + attachControl(element: HTMLElement, noPreventDefault?: boolean): void; + detachControl(element: HTMLElement): void; + update(): void; + _checkInputs(): void; + private _cascadePostProcessesToRigCams(); + attachPostProcess(postProcess: PostProcess, insertAt?: number): number; + detachPostProcess(postProcess: PostProcess, atIndices?: any): number[]; + getWorldMatrix(): Matrix; + _getViewMatrix(): Matrix; + getViewMatrix(force?: boolean): Matrix; + _computeViewMatrix(force?: boolean): Matrix; + freezeProjectionMatrix(projection?: Matrix): void; + unfreezeProjectionMatrix(): void; + getProjectionMatrix(force?: boolean): Matrix; + getTranformationMatrix(): Matrix; + private updateFrustumPlanes(); + isInFrustum(target: ICullable): boolean; + isCompletelyInFrustum(target: ICullable): boolean; + dispose(): void; + setCameraRigMode(mode: number, rigParams: any): void; + private _getVRProjectionMatrix(); + private _getWebVRProjectionMatrix(); + private _getWebVRViewMatrix(); + setCameraRigParameter(name: string, value: any): void; + /** + * needs to be overridden by children so sub has required properties to be copied + */ + createRigCamera(name: string, cameraIndex: number): Camera; + /** + * May need to be overridden by children + */ + _updateRigCameras(): void; + _setupInputs(): void; + serialize(): any; + clone(name: string): Camera; + getDirection(localAxis: Vector3): Vector3; + getDirectionToRef(localAxis: Vector3, result: Vector3): void; + static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera; + static Parse(parsedCamera: any, scene: Scene): Camera; } } -declare module BABYLON.Debug { - /** - * Demo available here: http://www.babylonjs-playground.com/#1BZJVJ#8 - */ - class SkeletonViewer { - skeleton: Skeleton; - mesh: AbstractMesh; - autoUpdateBonesMatrices: boolean; - renderingGroupId: number; - color: Color3; - private _scene; - private _debugLines; - private _debugMesh; - private _isEnabled; - private _renderFunction; - constructor(skeleton: Skeleton, mesh: AbstractMesh, scene: Scene, autoUpdateBonesMatrices?: boolean, renderingGroupId?: number); - isEnabled: boolean; - private _getBonePosition(position, bone, meshMat, x?, y?, z?); - private _getLinesForBonesWithLength(bones, meshMat); - private _getLinesForBonesNoLength(bones, meshMat); - update(): void; - dispose(): void; +declare module BABYLON { + var CameraInputTypes: {}; + interface ICameraInput { + camera: TCamera; + getTypeName(): string; + getSimpleName(): string; + attachControl: (element: HTMLElement, noPreventDefault?: boolean) => void; + detachControl: (element: HTMLElement) => void; + checkInputs?: () => void; + } + interface CameraInputsMap { + [name: string]: ICameraInput; + [idx: number]: ICameraInput; + } + class CameraInputsManager { + attached: CameraInputsMap; + attachedElement: HTMLElement; + noPreventDefault: boolean; + camera: TCamera; + checkInputs: () => void; + constructor(camera: TCamera); + add(input: ICameraInput): void; + remove(inputToRemove: ICameraInput): void; + removeByType(inputType: string): void; + private _addCheckInputs(fn); + attachInput(input: ICameraInput): void; + attachElement(element: HTMLElement, noPreventDefault?: boolean): void; + detachElement(element: HTMLElement): void; + rebuildInputCheck(): void; + clear(): void; + serialize(serializedCamera: any): void; + parse(parsedCamera: any): void; } } declare module BABYLON { - class Collider { - radius: Vector3; - retry: number; - velocity: Vector3; - basePoint: Vector3; - epsilon: number; - collisionFound: boolean; - velocityWorldLength: number; - basePointWorld: Vector3; - velocityWorld: Vector3; - normalizedVelocity: Vector3; - initialVelocity: Vector3; - initialPosition: Vector3; - nearestDistance: number; - intersectionPoint: Vector3; - collidedMesh: AbstractMesh; - private _collisionPoint; - private _planeIntersectionPoint; - private _tempVector; - private _tempVector2; - private _tempVector3; - private _tempVector4; - private _edge; - private _baseToVertex; - private _destinationPoint; - private _slidePlaneNormal; - private _displacementVector; - _initialize(source: Vector3, dir: Vector3, e: number): void; - _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean; - _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean; - _testTriangle(faceIndex: number, trianglePlaneArray: Array, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void; - _collide(trianglePlaneArray: Array, pts: Vector3[], indices: number[] | Int32Array, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void; - _getResponse(pos: Vector3, vel: Vector3): void; + class DeviceOrientationCamera extends FreeCamera { + private _initialQuaternion; + private _quaternionCache; + constructor(name: string, position: Vector3, scene: Scene); + getClassName(): string; + _checkInputs(): void; + resetToCurrentRotation(axis?: Axis): void; } } declare module BABYLON { - var CollisionWorker: string; - interface ICollisionCoordinator { - getNewPosition(position: Vector3, velocity: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh?: AbstractMesh) => void, collisionIndex: number): void; - init(scene: Scene): void; - destroy(): void; - onMeshAdded(mesh: AbstractMesh): any; - onMeshUpdated(mesh: AbstractMesh): any; - onMeshRemoved(mesh: AbstractMesh): any; - onGeometryAdded(geometry: Geometry): any; - onGeometryUpdated(geometry: Geometry): any; - onGeometryDeleted(geometry: Geometry): any; + class FollowCamera extends TargetCamera { + radius: number; + rotationOffset: number; + heightOffset: number; + cameraAcceleration: number; + maxCameraSpeed: number; + lockedTarget: AbstractMesh; + constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: AbstractMesh); + private getRadians(degrees); + private follow(cameraTarget); + _checkInputs(): void; + getClassName(): string; } - interface SerializedMesh { - id: string; - name: string; - uniqueId: number; - geometryId: string; - sphereCenter: Array; - sphereRadius: number; - boxMinimum: Array; - boxMaximum: Array; - worldMatrixFromCache: any; - subMeshes: Array; - checkCollisions: boolean; + class ArcFollowCamera extends TargetCamera { + alpha: number; + beta: number; + radius: number; + target: AbstractMesh; + private _cartesianCoordinates; + constructor(name: string, alpha: number, beta: number, radius: number, target: AbstractMesh, scene: Scene); + private follow(); + _checkInputs(): void; + getClassName(): string; } - interface SerializedSubMesh { - position: number; - verticesStart: number; - verticesCount: number; - indexStart: number; +} + +declare module BABYLON { + class FreeCamera extends TargetCamera { + ellipsoid: Vector3; + checkCollisions: boolean; + applyGravity: boolean; + inputs: FreeCameraInputsManager; + angularSensibility: number; + keysUp: number[]; + keysDown: number[]; + keysLeft: number[]; + keysRight: number[]; + onCollide: (collidedMesh: AbstractMesh) => void; + private _collider; + private _needMoveForGravity; + private _oldPosition; + private _diffPosition; + private _newPosition; + _localDirection: Vector3; + _transformedDirection: Vector3; + constructor(name: string, position: Vector3, scene: Scene); + attachControl(element: HTMLElement, noPreventDefault?: boolean): void; + detachControl(element: HTMLElement): void; + _collideWithWorld(velocity: Vector3): void; + private _onCollisionPositionChange; + _checkInputs(): void; + _decideIfNeedsToMove(): boolean; + _updatePosition(): void; + dispose(): void; + getClassName(): string; + } +} + +declare module BABYLON { + class FreeCameraInputsManager extends CameraInputsManager { + constructor(camera: FreeCamera); + addKeyboard(): FreeCameraInputsManager; + addMouse(touchEnabled?: boolean): FreeCameraInputsManager; + addGamepad(): FreeCameraInputsManager; + addDeviceOrientation(): FreeCameraInputsManager; + addTouch(): FreeCameraInputsManager; + addVirtualJoystick(): FreeCameraInputsManager; + } +} + +declare module BABYLON { + class GamepadCamera extends UniversalCamera { + gamepadAngularSensibility: number; + gamepadMoveSensibility: number; + constructor(name: string, position: Vector3, scene: Scene); + getClassName(): string; + } +} + +declare module BABYLON { + class AnaglyphFreeCamera extends FreeCamera { + constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene); + getClassName(): string; + } + class AnaglyphArcRotateCamera extends ArcRotateCamera { + constructor(name: string, alpha: number, beta: number, radius: number, target: any, interaxialDistance: number, scene: Scene); + getClassName(): string; + } + class AnaglyphGamepadCamera extends GamepadCamera { + constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene); + getClassName(): string; + } + class AnaglyphUniversalCamera extends UniversalCamera { + constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene); + getClassName(): string; + } + class StereoscopicFreeCamera extends FreeCamera { + constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene); + getClassName(): string; + } + class StereoscopicArcRotateCamera extends ArcRotateCamera { + constructor(name: string, alpha: number, beta: number, radius: number, target: any, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene); + getClassName(): string; + } + class StereoscopicGamepadCamera extends GamepadCamera { + constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene); + getClassName(): string; + } + class StereoscopicUniversalCamera extends UniversalCamera { + constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene); + getClassName(): string; + } +} + +declare module BABYLON { + class TargetCamera extends Camera { + cameraDirection: Vector3; + cameraRotation: Vector2; + rotation: Vector3; + rotationQuaternion: Quaternion; + speed: number; + noRotationConstraint: boolean; + lockedTarget: any; + _currentTarget: Vector3; + _viewMatrix: Matrix; + _camMatrix: Matrix; + _cameraTransformMatrix: Matrix; + _cameraRotationMatrix: Matrix; + private _rigCamTransformMatrix; + _referencePoint: Vector3; + private _defaultUpVector; + _transformedReferencePoint: Vector3; + _lookAtTemp: Matrix; + _tempMatrix: Matrix; + _reset: () => void; + constructor(name: string, position: Vector3, scene: Scene); + getFrontPosition(distance: number): Vector3; + _getLockedTargetPosition(): Vector3; + _initCache(): void; + _updateCache(ignoreParentClass?: boolean): void; + _isSynchronizedViewMatrix(): boolean; + _computeLocalCameraSpeed(): number; + setTarget(target: Vector3): void; + getTarget(): Vector3; + _decideIfNeedsToMove(): boolean; + _updatePosition(): void; + _checkInputs(): void; + private _updateCameraRotationMatrix(); + _getViewMatrix(): Matrix; + /** + * @override + * Override Camera.createRigCamera + */ + createRigCamera(name: string, cameraIndex: number): Camera; + /** + * @override + * Override Camera._updateRigCameras + */ + _updateRigCameras(): void; + private _getRigCamPosition(halfSpace, result); + getClassName(): string; + } +} + +declare module BABYLON { + class TouchCamera extends FreeCamera { + touchAngularSensibility: number; + touchMoveSensibility: number; + constructor(name: string, position: Vector3, scene: Scene); + getClassName(): string; + _setupInputs(): void; + } +} + +declare module BABYLON { + class UniversalCamera extends TouchCamera { + gamepadAngularSensibility: number; + gamepadMoveSensibility: number; + constructor(name: string, position: Vector3, scene: Scene); + getClassName(): string; + } +} + +declare module BABYLON { + class VirtualJoysticksCamera extends FreeCamera { + constructor(name: string, position: Vector3, scene: Scene); + getClassName(): string; + } +} + +declare module BABYLON { + class Collider { + radius: Vector3; + retry: number; + velocity: Vector3; + basePoint: Vector3; + epsilon: number; + collisionFound: boolean; + velocityWorldLength: number; + basePointWorld: Vector3; + velocityWorld: Vector3; + normalizedVelocity: Vector3; + initialVelocity: Vector3; + initialPosition: Vector3; + nearestDistance: number; + intersectionPoint: Vector3; + collidedMesh: AbstractMesh; + private _collisionPoint; + private _planeIntersectionPoint; + private _tempVector; + private _tempVector2; + private _tempVector3; + private _tempVector4; + private _edge; + private _baseToVertex; + private _destinationPoint; + private _slidePlaneNormal; + private _displacementVector; + _initialize(source: Vector3, dir: Vector3, e: number): void; + _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean; + _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean; + _testTriangle(faceIndex: number, trianglePlaneArray: Array, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void; + _collide(trianglePlaneArray: Array, pts: Vector3[], indices: number[] | Int32Array, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void; + _getResponse(pos: Vector3, vel: Vector3): void; + } +} + +declare module BABYLON { + var CollisionWorker: string; + interface ICollisionCoordinator { + getNewPosition(position: Vector3, velocity: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh?: AbstractMesh) => void, collisionIndex: number): void; + init(scene: Scene): void; + destroy(): void; + onMeshAdded(mesh: AbstractMesh): any; + onMeshUpdated(mesh: AbstractMesh): any; + onMeshRemoved(mesh: AbstractMesh): any; + onGeometryAdded(geometry: Geometry): any; + onGeometryUpdated(geometry: Geometry): any; + onGeometryDeleted(geometry: Geometry): any; + } + interface SerializedMesh { + id: string; + name: string; + uniqueId: number; + geometryId: string; + sphereCenter: Array; + sphereRadius: number; + boxMinimum: Array; + boxMaximum: Array; + worldMatrixFromCache: any; + subMeshes: Array; + checkCollisions: boolean; + } + interface SerializedSubMesh { + position: number; + verticesStart: number; + verticesCount: number; + indexStart: number; indexCount: number; hasMaterial: boolean; sphereCenter: Array; @@ -3087,28 +3462,214 @@ declare module BABYLON { } declare module BABYLON { - /** - * Highlight layer options. This helps customizing the behaviour - * of the highlight layer. - */ - interface IHighlightLayerOptions { - /** - * Multiplication factor apply to the canvas size to compute the render target size - * used to generated the glowing objects (the smaller the faster). - */ - mainTextureRatio?: number; - /** - * Enforces a fixed size texture to ensure resize independant blur. - */ - mainTextureFixedSize?: number; - /** - * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size - * of the picture to blur (the smaller the faster). - */ - blurTextureSizeRatio?: number; - /** - * How big in texel of the blur texture is the vertical blur. - */ + class BoundingBox implements ICullable { + minimum: Vector3; + maximum: Vector3; + vectors: Vector3[]; + center: Vector3; + extendSize: Vector3; + directions: Vector3[]; + vectorsWorld: Vector3[]; + minimumWorld: Vector3; + maximumWorld: Vector3; + private _worldMatrix; + constructor(minimum: Vector3, maximum: Vector3); + getWorldMatrix(): Matrix; + setWorldMatrix(matrix: Matrix): BoundingBox; + _update(world: Matrix): void; + isInFrustum(frustumPlanes: Plane[]): boolean; + isCompletelyInFrustum(frustumPlanes: Plane[]): boolean; + intersectsPoint(point: Vector3): boolean; + intersectsSphere(sphere: BoundingSphere): boolean; + intersectsMinMax(min: Vector3, max: Vector3): boolean; + static Intersects(box0: BoundingBox, box1: BoundingBox): boolean; + static IntersectsSphere(minPoint: Vector3, maxPoint: Vector3, sphereCenter: Vector3, sphereRadius: number): boolean; + static IsCompletelyInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean; + static IsInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean; + } +} + +declare module BABYLON { + interface ICullable { + isInFrustum(frustumPlanes: Plane[]): boolean; + isCompletelyInFrustum(frustumPlanes: Plane[]): boolean; + } + class BoundingInfo implements ICullable { + minimum: Vector3; + maximum: Vector3; + boundingBox: BoundingBox; + boundingSphere: BoundingSphere; + private _isLocked; + constructor(minimum: Vector3, maximum: Vector3); + isLocked: boolean; + update(world: Matrix): void; + isInFrustum(frustumPlanes: Plane[]): boolean; + isCompletelyInFrustum(frustumPlanes: Plane[]): boolean; + _checkCollision(collider: Collider): boolean; + intersectsPoint(point: Vector3): boolean; + intersects(boundingInfo: BoundingInfo, precise: boolean): boolean; + } +} + +declare module BABYLON { + class BoundingSphere { + minimum: Vector3; + maximum: Vector3; + center: Vector3; + radius: number; + centerWorld: Vector3; + radiusWorld: number; + private _tempRadiusVector; + constructor(minimum: Vector3, maximum: Vector3); + _update(world: Matrix): void; + isInFrustum(frustumPlanes: Plane[]): boolean; + intersectsPoint(point: Vector3): boolean; + static Intersects(sphere0: BoundingSphere, sphere1: BoundingSphere): boolean; + } +} + +declare module BABYLON { + class Ray { + origin: Vector3; + direction: Vector3; + length: number; + private _edge1; + private _edge2; + private _pvec; + private _tvec; + private _qvec; + private _renderPoints; + private _renderLine; + private _renderFunction; + private _scene; + private _show; + private _tmpRay; + constructor(origin: Vector3, direction: Vector3, length?: number); + intersectsBoxMinMax(minimum: Vector3, maximum: Vector3): boolean; + intersectsBox(box: BoundingBox): boolean; + intersectsSphere(sphere: BoundingSphere): boolean; + intersectsTriangle(vertex0: Vector3, vertex1: Vector3, vertex2: Vector3): IntersectionInfo; + intersectsPlane(plane: Plane): number; + intersectsMesh(mesh: AbstractMesh, fastCheck?: boolean): PickingInfo; + show(scene: Scene, color: Color3): void; + hide(): void; + private _render(); + private static smallnum; + private static rayl; + /** + * Intersection test between the ray and a given segment whithin a given tolerance (threshold) + * @param sega the first point of the segment to test the intersection against + * @param segb the second point of the segment to test the intersection against + * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful + * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection + */ + intersectionSegment(sega: Vector3, segb: Vector3, threshold: number): number; + static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray; + /** + * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be + * transformed to the given world matrix. + * @param origin The origin point + * @param end The end point + * @param world a matrix to transform the ray to. Default is the identity matrix. + */ + static CreateNewFromTo(origin: Vector3, end: Vector3, world?: Matrix): Ray; + static Transform(ray: Ray, matrix: Matrix): Ray; + static TransformToRef(ray: Ray, matrix: Matrix, result: Ray): void; + } +} + +declare module BABYLON.Debug { + class AxesViewer { + private _xline; + private _yline; + private _zline; + private _xmesh; + private _ymesh; + private _zmesh; + scene: Scene; + scaleLines: number; + constructor(scene: Scene, scaleLines?: number); + update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void; + dispose(): void; + } +} + +declare module BABYLON.Debug { + class BoneAxesViewer extends Debug.AxesViewer { + mesh: Mesh; + bone: Bone; + pos: Vector3; + xaxis: Vector3; + yaxis: Vector3; + zaxis: Vector3; + constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number); + update(): void; + dispose(): void; + } +} + +declare module BABYLON { + class DebugLayer { + private _scene; + static InspectorURL: string; + private _inspector; + constructor(scene: Scene); + /** Creates the inspector window. */ + private _createInspector(popup?); + isVisible(): boolean; + hide(): void; + show(popup?: boolean): void; + } +} + +declare module BABYLON.Debug { + /** + * Demo available here: http://www.babylonjs-playground.com/#1BZJVJ#8 + */ + class SkeletonViewer { + skeleton: Skeleton; + mesh: AbstractMesh; + autoUpdateBonesMatrices: boolean; + renderingGroupId: number; + color: Color3; + private _scene; + private _debugLines; + private _debugMesh; + private _isEnabled; + private _renderFunction; + constructor(skeleton: Skeleton, mesh: AbstractMesh, scene: Scene, autoUpdateBonesMatrices?: boolean, renderingGroupId?: number); + isEnabled: boolean; + private _getBonePosition(position, bone, meshMat, x?, y?, z?); + private _getLinesForBonesWithLength(bones, meshMat); + private _getLinesForBonesNoLength(bones, meshMat); + update(): void; + dispose(): void; + } +} + +declare module BABYLON { + /** + * Highlight layer options. This helps customizing the behaviour + * of the highlight layer. + */ + interface IHighlightLayerOptions { + /** + * Multiplication factor apply to the canvas size to compute the render target size + * used to generated the glowing objects (the smaller the faster). + */ + mainTextureRatio?: number; + /** + * Enforces a fixed size texture to ensure resize independant blur. + */ + mainTextureFixedSize?: number; + /** + * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size + * of the picture to blur (the smaller the faster). + */ + blurTextureSizeRatio?: number; + /** + * How big in texel of the blur texture is the vertical blur. + */ blurVerticalSize?: number; /** * How big in texel of the blur texture is the horizontal blur. @@ -3341,1605 +3902,373 @@ declare module BABYLON { } declare module BABYLON { - class BoundingBox implements ICullable { - minimum: Vector3; - maximum: Vector3; - vectors: Vector3[]; - center: Vector3; - extendSize: Vector3; - directions: Vector3[]; - vectorsWorld: Vector3[]; - minimumWorld: Vector3; - maximumWorld: Vector3; - private _worldMatrix; - constructor(minimum: Vector3, maximum: Vector3); - getWorldMatrix(): Matrix; - setWorldMatrix(matrix: Matrix): BoundingBox; - _update(world: Matrix): void; - isInFrustum(frustumPlanes: Plane[]): boolean; - isCompletelyInFrustum(frustumPlanes: Plane[]): boolean; - intersectsPoint(point: Vector3): boolean; - intersectsSphere(sphere: BoundingSphere): boolean; - intersectsMinMax(min: Vector3, max: Vector3): boolean; - static Intersects(box0: BoundingBox, box1: BoundingBox): boolean; - static IntersectsSphere(minPoint: Vector3, maxPoint: Vector3, sphereCenter: Vector3, sphereRadius: number): boolean; - static IsCompletelyInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean; - static IsInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean; + class LensFlare { + size: number; + position: number; + color: Color3; + texture: Texture; + alphaMode: number; + private _system; + constructor(size: number, position: number, color: any, imgUrl: string, system: LensFlareSystem); + dispose: () => void; } } declare module BABYLON { - interface ICullable { - isInFrustum(frustumPlanes: Plane[]): boolean; - isCompletelyInFrustum(frustumPlanes: Plane[]): boolean; - } - class BoundingInfo implements ICullable { - minimum: Vector3; - maximum: Vector3; - boundingBox: BoundingBox; - boundingSphere: BoundingSphere; - private _isLocked; - constructor(minimum: Vector3, maximum: Vector3); - isLocked: boolean; - update(world: Matrix): void; - isInFrustum(frustumPlanes: Plane[]): boolean; - isCompletelyInFrustum(frustumPlanes: Plane[]): boolean; - _checkCollision(collider: Collider): boolean; - intersectsPoint(point: Vector3): boolean; - intersects(boundingInfo: BoundingInfo, precise: boolean): boolean; + class LensFlareSystem { + name: string; + lensFlares: LensFlare[]; + borderLimit: number; + viewportBorder: number; + meshesSelectionPredicate: (mesh: Mesh) => boolean; + layerMask: number; + id: string; + private _scene; + private _emitter; + private _vertexBuffers; + private _indexBuffer; + private _effect; + private _positionX; + private _positionY; + private _isEnabled; + constructor(name: string, emitter: any, scene: Scene); + isEnabled: boolean; + getScene(): Scene; + getEmitter(): any; + setEmitter(newEmitter: any): void; + getEmitterPosition(): Vector3; + computeEffectivePosition(globalViewport: Viewport): boolean; + _isVisible(): boolean; + render(): boolean; + dispose(): void; + static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem; + serialize(): any; } } declare module BABYLON { - class BoundingSphere { - minimum: Vector3; - maximum: Vector3; - center: Vector3; - radius: number; - centerWorld: Vector3; - radiusWorld: number; - private _tempRadiusVector; - constructor(minimum: Vector3, maximum: Vector3); - _update(world: Matrix): void; - isInFrustum(frustumPlanes: Plane[]): boolean; - intersectsPoint(point: Vector3): boolean; - static Intersects(sphere0: BoundingSphere, sphere1: BoundingSphere): boolean; + class DirectionalLight extends Light implements IShadowLight { + position: Vector3; + direction: Vector3; + private _transformedDirection; + transformedPosition: Vector3; + private _worldMatrix; + shadowOrthoScale: number; + autoUpdateExtends: boolean; + private _orthoLeft; + private _orthoRight; + private _orthoTop; + private _orthoBottom; + constructor(name: string, direction: Vector3, scene: Scene); + getClassName(): string; + getAbsolutePosition(): Vector3; + setDirectionToTarget(target: Vector3): Vector3; + setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array): void; + supportsVSM(): boolean; + needRefreshPerFrame(): boolean; + needCube(): boolean; + getShadowDirection(faceIndex?: number): Vector3; + computeTransformedPosition(): boolean; + transferToEffect(effect: Effect, directionUniformName: string): void; + _getWorldMatrix(): Matrix; + getTypeID(): number; } } declare module BABYLON { - class Ray { - origin: Vector3; + class HemisphericLight extends Light { + groundColor: Color3; direction: Vector3; - length: number; - private _edge1; - private _edge2; - private _pvec; - private _tvec; - private _qvec; - private _renderPoints; - private _renderLine; - private _renderFunction; - private _scene; - private _show; - private _tmpRay; - constructor(origin: Vector3, direction: Vector3, length?: number); - intersectsBoxMinMax(minimum: Vector3, maximum: Vector3): boolean; - intersectsBox(box: BoundingBox): boolean; - intersectsSphere(sphere: BoundingSphere): boolean; - intersectsTriangle(vertex0: Vector3, vertex1: Vector3, vertex2: Vector3): IntersectionInfo; - intersectsPlane(plane: Plane): number; - intersectsMesh(mesh: AbstractMesh, fastCheck?: boolean): PickingInfo; - show(scene: Scene, color: Color3): void; - hide(): void; - private _render(); - private static smallnum; - private static rayl; - /** - * Intersection test between the ray and a given segment whithin a given tolerance (threshold) - * @param sega the first point of the segment to test the intersection against - * @param segb the second point of the segment to test the intersection against - * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful - * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection - */ - intersectionSegment(sega: Vector3, segb: Vector3, threshold: number): number; - static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray; - /** - * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be - * transformed to the given world matrix. - * @param origin The origin point - * @param end The end point - * @param world a matrix to transform the ray to. Default is the identity matrix. - */ - static CreateNewFromTo(origin: Vector3, end: Vector3, world?: Matrix): Ray; - static Transform(ray: Ray, matrix: Matrix): Ray; - static TransformToRef(ray: Ray, matrix: Matrix, result: Ray): void; + private _worldMatrix; + constructor(name: string, direction: Vector3, scene: Scene); + getClassName(): string; + setDirectionToTarget(target: Vector3): Vector3; + getShadowGenerator(): ShadowGenerator; + transferToEffect(effect: Effect, directionUniformName: string, groundColorUniformName: string): void; + _getWorldMatrix(): Matrix; + getTypeID(): number; } } declare module BABYLON { - class ArcRotateCamera extends TargetCamera { - alpha: number; - beta: number; - radius: number; - target: Vector3; - inertialAlphaOffset: number; - inertialBetaOffset: number; - inertialRadiusOffset: number; - lowerAlphaLimit: any; - upperAlphaLimit: any; - lowerBetaLimit: number; - upperBetaLimit: number; - lowerRadiusLimit: any; - upperRadiusLimit: any; - inertialPanningX: number; - inertialPanningY: number; - angularSensibilityX: number; - angularSensibilityY: number; - pinchPrecision: number; - panningSensibility: number; - keysUp: number[]; - keysDown: number[]; - keysLeft: number[]; - keysRight: number[]; - wheelPrecision: number; - zoomOnFactor: number; - targetScreenOffset: Vector2; - allowUpsideDown: boolean; - _viewMatrix: Matrix; - _useCtrlForPanning: boolean; - _panningMouseButton: number; - inputs: ArcRotateCameraInputsManager; - _reset: () => void; - panningAxis: Vector3; - private _localDirection; - private _transformedDirection; - onCollide: (collidedMesh: AbstractMesh) => void; - checkCollisions: boolean; - collisionRadius: Vector3; - private _collider; - private _previousPosition; - private _collisionVelocity; - private _newPosition; - private _previousAlpha; - private _previousBeta; - private _previousRadius; - private _collisionTriggered; - private _targetBoundingCenter; - constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene); - _initCache(): void; - _updateCache(ignoreParentClass?: boolean): void; - private _getTargetPosition(); - _isSynchronizedViewMatrix(): boolean; - attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void; - detachControl(element: HTMLElement): void; - _checkInputs(): void; - private _checkLimits(); - rebuildAnglesAndRadius(): void; - setPosition(position: Vector3): void; - setTarget(target: Vector3, toBoundingCenter?: boolean): void; - _getViewMatrix(): Matrix; - private _onCollisionPositionChange; - zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void; - focusOn(meshesOrMinMaxVectorAndDistance: any, doNotUpdateMaxZ?: boolean): void; + interface IShadowLight { + id: string; + position: Vector3; + transformedPosition: Vector3; + name: string; + computeTransformedPosition(): boolean; + getScene(): Scene; + setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array): void; + supportsVSM(): boolean; + needRefreshPerFrame(): boolean; + needCube(): boolean; + getShadowDirection(faceIndex?: number): Vector3; + _shadowGenerator: IShadowGenerator; + } + class Light extends Node { + private static _LIGHTMAP_DEFAULT; + private static _LIGHTMAP_SPECULAR; + private static _LIGHTMAP_SHADOWSONLY; /** - * @override - * Override Camera.createRigCamera + * If every light affecting the material is in this lightmapMode, + * material.lightmapTexture adds or multiplies + * (depends on material.useLightmapAsShadowmap) + * after every other light calculations. */ - createRigCamera(name: string, cameraIndex: number): Camera; + static readonly LIGHTMAP_DEFAULT: number; /** - * @override - * Override Camera._updateRigCameras + * material.lightmapTexture as only diffuse lighting from this light + * adds pnly specular lighting from this light + * adds dynamic shadows */ - _updateRigCameras(): void; - dispose(): void; - getClassName(): string; - } -} - -declare module BABYLON { - class ArcRotateCameraInputsManager extends CameraInputsManager { - constructor(camera: ArcRotateCamera); - addMouseWheel(): ArcRotateCameraInputsManager; - addPointers(): ArcRotateCameraInputsManager; - addKeyboard(): ArcRotateCameraInputsManager; - addGamepad(): ArcRotateCameraInputsManager; - addVRDeviceOrientation(): ArcRotateCameraInputsManager; - } -} - -declare module BABYLON { - class Camera extends Node { - inputs: CameraInputsManager; - private static _PERSPECTIVE_CAMERA; - private static _ORTHOGRAPHIC_CAMERA; - private static _FOVMODE_VERTICAL_FIXED; - private static _FOVMODE_HORIZONTAL_FIXED; - private static _RIG_MODE_NONE; - private static _RIG_MODE_STEREOSCOPIC_ANAGLYPH; - private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL; - private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED; - private static _RIG_MODE_STEREOSCOPIC_OVERUNDER; - private static _RIG_MODE_VR; - private static _RIG_MODE_WEBVR; - static readonly PERSPECTIVE_CAMERA: number; - static readonly ORTHOGRAPHIC_CAMERA: number; - static readonly FOVMODE_VERTICAL_FIXED: number; - static readonly FOVMODE_HORIZONTAL_FIXED: number; - static readonly RIG_MODE_NONE: number; - static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number; - static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number; - static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number; - static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number; - static readonly RIG_MODE_VR: number; - static readonly RIG_MODE_WEBVR: number; - static ForceAttachControlToAlwaysPreventDefault: boolean; - position: Vector3; - upVector: Vector3; - orthoLeft: any; - orthoRight: any; - orthoBottom: any; - orthoTop: any; - fov: number; - minZ: number; - maxZ: number; - inertia: number; - mode: number; - isIntermediate: boolean; - viewport: Viewport; - layerMask: number; - fovMode: number; - cameraRigMode: number; - interaxialDistance: number; - isStereoscopicSideBySide: boolean; - _cameraRigParams: any; - _rigCameras: Camera[]; - _rigPostProcess: PostProcess; - private _computedViewMatrix; - _projectionMatrix: Matrix; - private _doNotComputeProjectionMatrix; - private _worldMatrix; - _postProcesses: PostProcess[]; - private _transformMatrix; - private _webvrViewMatrix; - _activeMeshes: SmartArray; - private _globalPosition; - private _frustumPlanes; - private _refreshFrustumPlanes; - constructor(name: string, position: Vector3, scene: Scene); + static readonly LIGHTMAP_SPECULAR: number; + /** + * material.lightmapTexture as only lighting + * no light calculation from this light + * only adds dynamic shadows from this light + */ + static readonly LIGHTMAP_SHADOWSONLY: number; + diffuse: Color3; + specular: Color3; + intensity: number; + range: number; + includeOnlyWithLayerMask: number; + includedOnlyMeshes: AbstractMesh[]; + excludedMeshes: AbstractMesh[]; + excludeWithLayerMask: number; + lightmapMode: number; + radius: number; + _shadowGenerator: IShadowGenerator; + private _parentedWorldMatrix; + _excludedMeshesIds: string[]; + _includedOnlyMeshesIds: string[]; + constructor(name: string, scene: Scene); getClassName(): string; /** * @param {boolean} fullDetails - support for multiple levels of logging within scene loading */ toString(fullDetails?: boolean): string; - readonly globalPosition: Vector3; - getActiveMeshes(): SmartArray; - isActiveMesh(mesh: Mesh): boolean; - _initCache(): void; - _updateCache(ignoreParentClass?: boolean): void; - _updateFromScene(): void; - _isSynchronized(): boolean; - _isSynchronizedViewMatrix(): boolean; - _isSynchronizedProjectionMatrix(): boolean; - attachControl(element: HTMLElement, noPreventDefault?: boolean): void; - detachControl(element: HTMLElement): void; - update(): void; - _checkInputs(): void; - private _cascadePostProcessesToRigCams(); - attachPostProcess(postProcess: PostProcess, insertAt?: number): number; - detachPostProcess(postProcess: PostProcess, atIndices?: any): number[]; + getShadowGenerator(): IShadowGenerator; + getAbsolutePosition(): Vector3; + transferToEffect(effect: Effect, uniformName0?: string, uniformName1?: string): void; + _getWorldMatrix(): Matrix; + canAffectMesh(mesh: AbstractMesh): boolean; getWorldMatrix(): Matrix; - _getViewMatrix(): Matrix; - getViewMatrix(force?: boolean): Matrix; - _computeViewMatrix(force?: boolean): Matrix; - freezeProjectionMatrix(projection?: Matrix): void; - unfreezeProjectionMatrix(): void; - getProjectionMatrix(force?: boolean): Matrix; - getTranformationMatrix(): Matrix; - private updateFrustumPlanes(); - isInFrustum(target: ICullable): boolean; - isCompletelyInFrustum(target: ICullable): boolean; dispose(): void; - setCameraRigMode(mode: number, rigParams: any): void; - private _getVRProjectionMatrix(); - private _getWebVRProjectionMatrix(); - private _getWebVRViewMatrix(); - setCameraRigParameter(name: string, value: any): void; - /** - * needs to be overridden by children so sub has required properties to be copied - */ - createRigCamera(name: string, cameraIndex: number): Camera; - /** - * May need to be overridden by children - */ - _updateRigCameras(): void; - _setupInputs(): void; + getTypeID(): number; + clone(name: string): Light; serialize(): any; - clone(name: string): Camera; - getDirection(localAxis: Vector3): Vector3; - getDirectionToRef(localAxis: Vector3, result: Vector3): void; - static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera; - static Parse(parsedCamera: any, scene: Scene): Camera; - } -} - -declare module BABYLON { - var CameraInputTypes: {}; - interface ICameraInput { - camera: TCamera; - getTypeName(): string; - getSimpleName(): string; - attachControl: (element: HTMLElement, noPreventDefault?: boolean) => void; - detachControl: (element: HTMLElement) => void; - checkInputs?: () => void; - } - interface CameraInputsMap { - [name: string]: ICameraInput; - [idx: number]: ICameraInput; - } - class CameraInputsManager { - attached: CameraInputsMap; - attachedElement: HTMLElement; - noPreventDefault: boolean; - camera: TCamera; - checkInputs: () => void; - constructor(camera: TCamera); - add(input: ICameraInput): void; - remove(inputToRemove: ICameraInput): void; - removeByType(inputType: string): void; - private _addCheckInputs(fn); - attachInput(input: ICameraInput): void; - attachElement(element: HTMLElement, noPreventDefault?: boolean): void; - detachElement(element: HTMLElement): void; - rebuildInputCheck(): void; - clear(): void; - serialize(serializedCamera: any): void; - parse(parsedCamera: any): void; + static GetConstructorFromName(type: number, name: string, scene: Scene): () => Light; + static Parse(parsedLight: any, scene: Scene): Light; } } declare module BABYLON { - class DeviceOrientationCamera extends FreeCamera { - private _initialQuaternion; - private _quaternionCache; + class PointLight extends Light implements IShadowLight { + private _worldMatrix; + transformedPosition: Vector3; + position: Vector3; constructor(name: string, position: Vector3, scene: Scene); getClassName(): string; - _checkInputs(): void; - resetToCurrentRotation(axis?: Axis): void; - } -} - -declare module BABYLON { - class FollowCamera extends TargetCamera { - radius: number; - rotationOffset: number; - heightOffset: number; - cameraAcceleration: number; - maxCameraSpeed: number; - lockedTarget: AbstractMesh; - constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: AbstractMesh); - private getRadians(degrees); - private follow(cameraTarget); - _checkInputs(): void; - getClassName(): string; - } - class ArcFollowCamera extends TargetCamera { - alpha: number; - beta: number; - radius: number; - target: AbstractMesh; - private _cartesianCoordinates; - constructor(name: string, alpha: number, beta: number, radius: number, target: AbstractMesh, scene: Scene); - private follow(); - _checkInputs(): void; - getClassName(): string; + getAbsolutePosition(): Vector3; + computeTransformedPosition(): boolean; + transferToEffect(effect: Effect, positionUniformName: string): void; + needCube(): boolean; + supportsVSM(): boolean; + needRefreshPerFrame(): boolean; + getShadowDirection(faceIndex?: number): Vector3; + setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array): void; + _getWorldMatrix(): Matrix; + getTypeID(): number; } } declare module BABYLON { - class FreeCamera extends TargetCamera { - ellipsoid: Vector3; - checkCollisions: boolean; - applyGravity: boolean; - inputs: FreeCameraInputsManager; - angularSensibility: number; - keysUp: number[]; - keysDown: number[]; - keysLeft: number[]; - keysRight: number[]; - onCollide: (collidedMesh: AbstractMesh) => void; - private _collider; - private _needMoveForGravity; - private _oldPosition; - private _diffPosition; - private _newPosition; - _localDirection: Vector3; - _transformedDirection: Vector3; - constructor(name: string, position: Vector3, scene: Scene); - attachControl(element: HTMLElement, noPreventDefault?: boolean): void; - detachControl(element: HTMLElement): void; - _collideWithWorld(velocity: Vector3): void; - private _onCollisionPositionChange; - _checkInputs(): void; - _decideIfNeedsToMove(): boolean; - _updatePosition(): void; - dispose(): void; + class SpotLight extends Light implements IShadowLight { + position: Vector3; + direction: Vector3; + angle: number; + exponent: number; + transformedPosition: Vector3; + private _transformedDirection; + private _worldMatrix; + constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene); getClassName(): string; + getAbsolutePosition(): Vector3; + setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array): void; + needCube(): boolean; + supportsVSM(): boolean; + needRefreshPerFrame(): boolean; + getShadowDirection(faceIndex?: number): Vector3; + setDirectionToTarget(target: Vector3): Vector3; + computeTransformedPosition(): boolean; + transferToEffect(effect: Effect, positionUniformName: string, directionUniformName: string): void; + _getWorldMatrix(): Matrix; + getTypeID(): number; + getRotation(): Vector3; } } declare module BABYLON { - class FreeCameraInputsManager extends CameraInputsManager { - constructor(camera: FreeCamera); - addKeyboard(): FreeCameraInputsManager; - addMouse(touchEnabled?: boolean): FreeCameraInputsManager; - addGamepad(): FreeCameraInputsManager; - addDeviceOrientation(): FreeCameraInputsManager; - addTouch(): FreeCameraInputsManager; - addVirtualJoystick(): FreeCameraInputsManager; + interface ISceneLoaderPluginExtensions { + [extension: string]: { + isBinary: boolean; + }; } -} - -declare module BABYLON { - class GamepadCamera extends UniversalCamera { - gamepadAngularSensibility: number; - gamepadMoveSensibility: number; - constructor(name: string, position: Vector3, scene: Scene); - getClassName(): string; - } -} - -declare module BABYLON { - class AnaglyphFreeCamera extends FreeCamera { - constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene); - getClassName(): string; - } - class AnaglyphArcRotateCamera extends ArcRotateCamera { - constructor(name: string, alpha: number, beta: number, radius: number, target: any, interaxialDistance: number, scene: Scene); - getClassName(): string; - } - class AnaglyphGamepadCamera extends GamepadCamera { - constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene); - getClassName(): string; - } - class AnaglyphUniversalCamera extends UniversalCamera { - constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene); - getClassName(): string; - } - class StereoscopicFreeCamera extends FreeCamera { - constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene); - getClassName(): string; - } - class StereoscopicArcRotateCamera extends ArcRotateCamera { - constructor(name: string, alpha: number, beta: number, radius: number, target: any, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene); - getClassName(): string; + interface ISceneLoaderPlugin { + extensions: string | ISceneLoaderPluginExtensions; + importMesh: (meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => boolean; + load: (scene: Scene, data: string, rootUrl: string) => boolean; } - class StereoscopicGamepadCamera extends GamepadCamera { - constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene); - getClassName(): string; + interface ISceneLoaderPluginAsync { + extensions: string | ISceneLoaderPluginExtensions; + importMeshAsync: (meshesNames: any, scene: Scene, data: any, rootUrl: string, onsuccess?: (meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => void, onerror?: () => void) => void; + loadAsync: (scene: Scene, data: string, rootUrl: string, onsuccess: () => void, onerror: () => void) => boolean; } - class StereoscopicUniversalCamera extends UniversalCamera { - constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene); - getClassName(): string; + class SceneLoader { + private static _ForceFullSceneLoadingForIncremental; + private static _ShowLoadingScreen; + static readonly NO_LOGGING: number; + static readonly MINIMAL_LOGGING: number; + static readonly SUMMARY_LOGGING: number; + static readonly DETAILED_LOGGING: number; + private static _loggingLevel; + static ForceFullSceneLoadingForIncremental: boolean; + static ShowLoadingScreen: boolean; + static loggingLevel: number; + private static _registeredPlugins; + private static _getDefaultPlugin(); + private static _getPluginForExtension(extension); + private static _getPluginForFilename(sceneFilename); + private static _getDirectLoad(sceneFilename); + static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync; + static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void; + static ImportMesh(meshesNames: any, rootUrl: string, sceneFilename: string, scene: Scene, onsuccess?: (meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => void, progressCallBack?: () => void, onerror?: (scene: Scene, message: string, exception?: any) => void): void; + /** + * Load a scene + * @param rootUrl a string that defines the root url for scene and resources + * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene + * @param engine is the instance of BABYLON.Engine to use to create the scene + */ + static Load(rootUrl: string, sceneFilename: any, engine: Engine, onsuccess?: (scene: Scene) => void, progressCallBack?: any, onerror?: (scene: Scene) => void): void; + /** + * Append a scene + * @param rootUrl a string that defines the root url for scene and resources + * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene + * @param scene is the instance of BABYLON.Scene to append to + */ + static Append(rootUrl: string, sceneFilename: any, scene: Scene, onsuccess?: (scene: Scene) => void, progressCallBack?: any, onerror?: (scene: Scene) => void): void; } } declare module BABYLON { - class TargetCamera extends Camera { - cameraDirection: Vector3; - cameraRotation: Vector2; - rotation: Vector3; - rotationQuaternion: Quaternion; - speed: number; - noRotationConstraint: boolean; - lockedTarget: any; - _currentTarget: Vector3; - _viewMatrix: Matrix; - _camMatrix: Matrix; - _cameraTransformMatrix: Matrix; - _cameraRotationMatrix: Matrix; - private _rigCamTransformMatrix; - _referencePoint: Vector3; - private _defaultUpVector; - _transformedReferencePoint: Vector3; - _lookAtTemp: Matrix; - _tempMatrix: Matrix; - _reset: () => void; - constructor(name: string, position: Vector3, scene: Scene); - getFrontPosition(distance: number): Vector3; - _getLockedTargetPosition(): Vector3; - _initCache(): void; - _updateCache(ignoreParentClass?: boolean): void; - _isSynchronizedViewMatrix(): boolean; - _computeLocalCameraSpeed(): number; - setTarget(target: Vector3): void; - getTarget(): Vector3; - _decideIfNeedsToMove(): boolean; - _updatePosition(): void; - _checkInputs(): void; - private _updateCameraRotationMatrix(); - _getViewMatrix(): Matrix; + /** + * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT). + * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects. + * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image; + * corresponding to low luminance, medium luminance, and high luminance areas respectively. + */ + class ColorCurves { + private _dirty; + private _tempColor; + private _globalCurve; + private _highlightsCurve; + private _midtonesCurve; + private _shadowsCurve; + private _positiveCurve; + private _negativeCurve; + private _globalHue; + private _globalDensity; + private _globalSaturation; + private _globalExposure; /** - * @override - * Override Camera.createRigCamera + * Gets the global Hue value. + * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange). */ - createRigCamera(name: string, cameraIndex: number): Camera; /** - * @override - * Override Camera._updateRigCameras + * Sets the global Hue value. + * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange). */ - _updateRigCameras(): void; - private _getRigCamPosition(halfSpace, result); - getClassName(): string; - } -} - -declare module BABYLON { - class TouchCamera extends FreeCamera { - touchAngularSensibility: number; - touchMoveSensibility: number; - constructor(name: string, position: Vector3, scene: Scene); - getClassName(): string; - _setupInputs(): void; - } -} - -declare module BABYLON { - class UniversalCamera extends TouchCamera { - gamepadAngularSensibility: number; - gamepadMoveSensibility: number; - constructor(name: string, position: Vector3, scene: Scene); - getClassName(): string; - } -} - -declare module BABYLON { - class VirtualJoysticksCamera extends FreeCamera { - constructor(name: string, position: Vector3, scene: Scene); - getClassName(): string; - } -} - -declare module BABYLON { - class LensFlare { - size: number; - position: number; - color: Color3; - texture: Texture; - alphaMode: number; - private _system; - constructor(size: number, position: number, color: any, imgUrl: string, system: LensFlareSystem); - dispose: () => void; - } -} - -declare module BABYLON { - class LensFlareSystem { - name: string; - lensFlares: LensFlare[]; - borderLimit: number; - viewportBorder: number; - meshesSelectionPredicate: (mesh: Mesh) => boolean; - layerMask: number; - id: string; - private _scene; - private _emitter; - private _vertexBuffers; - private _indexBuffer; - private _effect; - private _positionX; - private _positionY; - private _isEnabled; - constructor(name: string, emitter: any, scene: Scene); - isEnabled: boolean; - getScene(): Scene; - getEmitter(): any; - setEmitter(newEmitter: any): void; - getEmitterPosition(): Vector3; - computeEffectivePosition(globalViewport: Viewport): boolean; - _isVisible(): boolean; - render(): boolean; - dispose(): void; - static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem; - serialize(): any; - } -} - -declare module BABYLON { - class DirectionalLight extends Light implements IShadowLight { - position: Vector3; - direction: Vector3; - private _transformedDirection; - transformedPosition: Vector3; - private _worldMatrix; - shadowOrthoScale: number; - autoUpdateExtends: boolean; - private _orthoLeft; - private _orthoRight; - private _orthoTop; - private _orthoBottom; - constructor(name: string, direction: Vector3, scene: Scene); - getClassName(): string; - getAbsolutePosition(): Vector3; - setDirectionToTarget(target: Vector3): Vector3; - setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array): void; - supportsVSM(): boolean; - needRefreshPerFrame(): boolean; - needCube(): boolean; - getShadowDirection(faceIndex?: number): Vector3; - computeTransformedPosition(): boolean; - transferToEffect(effect: Effect, directionUniformName: string): void; - _getWorldMatrix(): Matrix; - getTypeID(): number; - } -} - -declare module BABYLON { - class HemisphericLight extends Light { - groundColor: Color3; - direction: Vector3; - private _worldMatrix; - constructor(name: string, direction: Vector3, scene: Scene); - getClassName(): string; - setDirectionToTarget(target: Vector3): Vector3; - getShadowGenerator(): ShadowGenerator; - transferToEffect(effect: Effect, directionUniformName: string, groundColorUniformName: string): void; - _getWorldMatrix(): Matrix; - getTypeID(): number; - } -} - -declare module BABYLON { - interface IShadowLight { - id: string; - position: Vector3; - transformedPosition: Vector3; - name: string; - computeTransformedPosition(): boolean; - getScene(): Scene; - setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array): void; - supportsVSM(): boolean; - needRefreshPerFrame(): boolean; - needCube(): boolean; - getShadowDirection(faceIndex?: number): Vector3; - _shadowGenerator: IShadowGenerator; - } - class Light extends Node { - private static _LIGHTMAP_DEFAULT; - private static _LIGHTMAP_SPECULAR; - private static _LIGHTMAP_SHADOWSONLY; + GlobalHue: number; /** - * If every light affecting the material is in this lightmapMode, - * material.lightmapTexture adds or multiplies - * (depends on material.useLightmapAsShadowmap) - * after every other light calculations. + * Gets the global Density value. + * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect. + * Values less than zero provide a filter of opposite hue. */ - static readonly LIGHTMAP_DEFAULT: number; /** - * material.lightmapTexture as only diffuse lighting from this light - * adds pnly specular lighting from this light - * adds dynamic shadows + * Sets the global Density value. + * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect. + * Values less than zero provide a filter of opposite hue. */ - static readonly LIGHTMAP_SPECULAR: number; + GlobalDensity: number; /** - * material.lightmapTexture as only lighting - * no light calculation from this light - * only adds dynamic shadows from this light + * Gets the global Saturation value. + * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation. */ - static readonly LIGHTMAP_SHADOWSONLY: number; - diffuse: Color3; - specular: Color3; - intensity: number; - range: number; - includeOnlyWithLayerMask: number; - includedOnlyMeshes: AbstractMesh[]; - excludedMeshes: AbstractMesh[]; - excludeWithLayerMask: number; - lightmapMode: number; - radius: number; - _shadowGenerator: IShadowGenerator; - private _parentedWorldMatrix; - _excludedMeshesIds: string[]; - _includedOnlyMeshesIds: string[]; - constructor(name: string, scene: Scene); - getClassName(): string; /** - * @param {boolean} fullDetails - support for multiple levels of logging within scene loading + * Sets the global Saturation value. + * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation. */ - toString(fullDetails?: boolean): string; - getShadowGenerator(): IShadowGenerator; - getAbsolutePosition(): Vector3; - transferToEffect(effect: Effect, uniformName0?: string, uniformName1?: string): void; - _getWorldMatrix(): Matrix; - canAffectMesh(mesh: AbstractMesh): boolean; - getWorldMatrix(): Matrix; - dispose(): void; - getTypeID(): number; - clone(name: string): Light; - serialize(): any; - static GetConstructorFromName(type: number, name: string, scene: Scene): () => Light; - static Parse(parsedLight: any, scene: Scene): Light; - } -} - -declare module BABYLON { - class PointLight extends Light implements IShadowLight { - private _worldMatrix; - transformedPosition: Vector3; - position: Vector3; - constructor(name: string, position: Vector3, scene: Scene); - getClassName(): string; - getAbsolutePosition(): Vector3; - computeTransformedPosition(): boolean; - transferToEffect(effect: Effect, positionUniformName: string): void; - needCube(): boolean; - supportsVSM(): boolean; - needRefreshPerFrame(): boolean; - getShadowDirection(faceIndex?: number): Vector3; - setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array): void; - _getWorldMatrix(): Matrix; - getTypeID(): number; - } -} - -declare module BABYLON { - class SpotLight extends Light implements IShadowLight { - position: Vector3; - direction: Vector3; - angle: number; - exponent: number; - transformedPosition: Vector3; - private _transformedDirection; - private _worldMatrix; - constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene); - getClassName(): string; - getAbsolutePosition(): Vector3; - setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array): void; - needCube(): boolean; - supportsVSM(): boolean; - needRefreshPerFrame(): boolean; - getShadowDirection(faceIndex?: number): Vector3; - setDirectionToTarget(target: Vector3): Vector3; - computeTransformedPosition(): boolean; - transferToEffect(effect: Effect, positionUniformName: string, directionUniformName: string): void; - _getWorldMatrix(): Matrix; - getTypeID(): number; - getRotation(): Vector3; - } -} - -declare module BABYLON { - interface ISceneLoaderPluginExtensions { - [extension: string]: { - isBinary: boolean; - }; - } - interface ISceneLoaderPlugin { - extensions: string | ISceneLoaderPluginExtensions; - importMesh: (meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => boolean; - load: (scene: Scene, data: string, rootUrl: string) => boolean; - } - interface ISceneLoaderPluginAsync { - extensions: string | ISceneLoaderPluginExtensions; - importMeshAsync: (meshesNames: any, scene: Scene, data: any, rootUrl: string, onsuccess?: (meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => void, onerror?: () => void) => void; - loadAsync: (scene: Scene, data: string, rootUrl: string, onsuccess: () => void, onerror: () => void) => boolean; - } - class SceneLoader { - private static _ForceFullSceneLoadingForIncremental; - private static _ShowLoadingScreen; - static readonly NO_LOGGING: number; - static readonly MINIMAL_LOGGING: number; - static readonly SUMMARY_LOGGING: number; - static readonly DETAILED_LOGGING: number; - private static _loggingLevel; - static ForceFullSceneLoadingForIncremental: boolean; - static ShowLoadingScreen: boolean; - static loggingLevel: number; - private static _registeredPlugins; - private static _getDefaultPlugin(); - private static _getPluginForExtension(extension); - private static _getPluginForFilename(sceneFilename); - private static _getDirectLoad(sceneFilename); - static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync; - static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void; - static ImportMesh(meshesNames: any, rootUrl: string, sceneFilename: string, scene: Scene, onsuccess?: (meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => void, progressCallBack?: () => void, onerror?: (scene: Scene, message: string, exception?: any) => void): void; + GlobalSaturation: number; + private _highlightsHue; + private _highlightsDensity; + private _highlightsSaturation; + private _highlightsExposure; /** - * Load a scene - * @param rootUrl a string that defines the root url for scene and resources - * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene - * @param engine is the instance of BABYLON.Engine to use to create the scene - */ - static Load(rootUrl: string, sceneFilename: any, engine: Engine, onsuccess?: (scene: Scene) => void, progressCallBack?: any, onerror?: (scene: Scene) => void): void; + * Gets the highlights Hue value. + * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange). + */ /** - * Append a scene - * @param rootUrl a string that defines the root url for scene and resources - * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene - * @param scene is the instance of BABYLON.Scene to append to - */ - static Append(rootUrl: string, sceneFilename: any, scene: Scene, onsuccess?: (scene: Scene) => void, progressCallBack?: any, onerror?: (scene: Scene) => void): void; - } -} - -declare module BABYLON { - class SIMDHelper { - private static _isEnabled; - static readonly IsEnabled: boolean; - static DisableSIMD(): void; - static EnableSIMD(): void; - } -} - -declare module BABYLON { - const ToGammaSpace: number; - const ToLinearSpace = 2.2; - const Epsilon = 0.001; - class MathTools { - static WithinEpsilon(a: number, b: number, epsilon?: number): boolean; - static ToHex(i: number): string; - static Sign(value: number): number; - static Clamp(value: number, min?: number, max?: number): number; - } - class Color3 { - r: number; - g: number; - b: number; - constructor(r?: number, g?: number, b?: number); - toString(): string; - getClassName(): string; - getHashCode(): number; - toArray(array: number[], index?: number): Color3; - toColor4(alpha?: number): Color4; - asArray(): number[]; - toLuminance(): number; - multiply(otherColor: Color3): Color3; - multiplyToRef(otherColor: Color3, result: Color3): Color3; - equals(otherColor: Color3): boolean; - equalsFloats(r: number, g: number, b: number): boolean; - scale(scale: number): Color3; - scaleToRef(scale: number, result: Color3): Color3; - add(otherColor: Color3): Color3; - addToRef(otherColor: Color3, result: Color3): Color3; - subtract(otherColor: Color3): Color3; - subtractToRef(otherColor: Color3, result: Color3): Color3; - clone(): Color3; - copyFrom(source: Color3): Color3; - copyFromFloats(r: number, g: number, b: number): Color3; - toHexString(): string; - toLinearSpace(): Color3; - toLinearSpaceToRef(convertedColor: Color3): Color3; - toGammaSpace(): Color3; - toGammaSpaceToRef(convertedColor: Color3): Color3; - static FromHexString(hex: string): Color3; - static FromArray(array: number[], offset?: number): Color3; - static FromInts(r: number, g: number, b: number): Color3; - static Lerp(start: Color3, end: Color3, amount: number): Color3; - static Red(): Color3; - static Green(): Color3; - static Blue(): Color3; - static Black(): Color3; - static White(): Color3; - static Purple(): Color3; - static Magenta(): Color3; - static Yellow(): Color3; - static Gray(): Color3; - } - class Color4 { - r: number; - g: number; - b: number; - a: number; - constructor(r: number, g: number, b: number, a: number); - addInPlace(right: any): Color4; - asArray(): number[]; - toArray(array: number[], index?: number): Color4; - add(right: Color4): Color4; - subtract(right: Color4): Color4; - subtractToRef(right: Color4, result: Color4): Color4; - scale(scale: number): Color4; - scaleToRef(scale: number, result: Color4): Color4; + * Sets the highlights Hue value. + * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange). + */ + HighlightsHue: number; /** - * Multipy an RGBA Color4 value by another and return a new Color4 object - * @param color The Color4 (RGBA) value to multiply by - * @returns A new Color4. - */ - multiply(color: Color4): Color4; + * Gets the highlights Density value. + * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect. + * Values less than zero provide a filter of opposite hue. + */ /** - * Multipy an RGBA Color4 value by another and push the result in a reference value - * @param color The Color4 (RGBA) value to multiply by - * @param result The Color4 (RGBA) to fill the result in - * @returns the result Color4. + * Sets the highlights Density value. + * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect. + * Values less than zero provide a filter of opposite hue. */ - multiplyToRef(color: Color4, result: Color4): Color4; - toString(): string; - getClassName(): string; - getHashCode(): number; - clone(): Color4; - copyFrom(source: Color4): Color4; - toHexString(): string; - static FromHexString(hex: string): Color4; - static Lerp(left: Color4, right: Color4, amount: number): Color4; - static LerpToRef(left: Color4, right: Color4, amount: number, result: Color4): void; - static FromArray(array: number[], offset?: number): Color4; - static FromInts(r: number, g: number, b: number, a: number): Color4; - static CheckColors4(colors: number[], count: number): number[]; - } - class Vector2 { - x: number; - y: number; - constructor(x: number, y: number); - toString(): string; - getClassName(): string; - getHashCode(): number; - toArray(array: number[] | Float32Array, index?: number): Vector2; - asArray(): number[]; - copyFrom(source: Vector2): Vector2; - copyFromFloats(x: number, y: number): Vector2; - add(otherVector: Vector2): Vector2; - addToRef(otherVector: Vector2, result: Vector2): Vector2; - addInPlace(otherVector: Vector2): Vector2; - addVector3(otherVector: Vector3): Vector2; - subtract(otherVector: Vector2): Vector2; - subtractToRef(otherVector: Vector2, result: Vector2): Vector2; - subtractInPlace(otherVector: Vector2): Vector2; - multiplyInPlace(otherVector: Vector2): Vector2; - multiply(otherVector: Vector2): Vector2; - multiplyToRef(otherVector: Vector2, result: Vector2): Vector2; - multiplyByFloats(x: number, y: number): Vector2; - divide(otherVector: Vector2): Vector2; - divideToRef(otherVector: Vector2, result: Vector2): Vector2; - negate(): Vector2; - scaleInPlace(scale: number): Vector2; - scale(scale: number): Vector2; - equals(otherVector: Vector2): boolean; - equalsWithEpsilon(otherVector: Vector2, epsilon?: number): boolean; - length(): number; - lengthSquared(): number; - normalize(): Vector2; - clone(): Vector2; - static Zero(): Vector2; - static FromArray(array: number[] | Float32Array, offset?: number): Vector2; - static FromArrayToRef(array: number[] | Float32Array, offset: number, result: Vector2): void; - static CatmullRom(value1: Vector2, value2: Vector2, value3: Vector2, value4: Vector2, amount: number): Vector2; - static Clamp(value: Vector2, min: Vector2, max: Vector2): Vector2; - static Hermite(value1: Vector2, tangent1: Vector2, value2: Vector2, tangent2: Vector2, amount: number): Vector2; - static Lerp(start: Vector2, end: Vector2, amount: number): Vector2; - static Dot(left: Vector2, right: Vector2): number; - static Normalize(vector: Vector2): Vector2; - static Minimize(left: Vector2, right: Vector2): Vector2; - static Maximize(left: Vector2, right: Vector2): Vector2; - static Transform(vector: Vector2, transformation: Matrix): Vector2; - static TransformToRef(vector: Vector2, transformation: Matrix, result: Vector2): void; - static PointInTriangle(p: Vector2, p0: Vector2, p1: Vector2, p2: Vector2): boolean; - static Distance(value1: Vector2, value2: Vector2): number; - static DistanceSquared(value1: Vector2, value2: Vector2): number; - static Center(value1: Vector2, value2: Vector2): Vector2; - static DistanceOfPointFromSegment(p: Vector2, segA: Vector2, segB: Vector2): number; - } - class Vector3 { - x: number; - y: number; - z: number; - constructor(x: number, y: number, z: number); - toString(): string; - getClassName(): string; - getHashCode(): number; - asArray(): number[]; - toArray(array: number[] | Float32Array, index?: number): Vector3; - toQuaternion(): Quaternion; - addInPlace(otherVector: Vector3): Vector3; - add(otherVector: Vector3): Vector3; - addToRef(otherVector: Vector3, result: Vector3): Vector3; - subtractInPlace(otherVector: Vector3): Vector3; - subtract(otherVector: Vector3): Vector3; - subtractToRef(otherVector: Vector3, result: Vector3): Vector3; - subtractFromFloats(x: number, y: number, z: number): Vector3; - subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3; - negate(): Vector3; - scaleInPlace(scale: number): Vector3; - scale(scale: number): Vector3; - scaleToRef(scale: number, result: Vector3): void; - equals(otherVector: Vector3): boolean; - equalsWithEpsilon(otherVector: Vector3, epsilon?: number): boolean; - equalsToFloats(x: number, y: number, z: number): boolean; - multiplyInPlace(otherVector: Vector3): Vector3; - multiply(otherVector: Vector3): Vector3; - multiplyToRef(otherVector: Vector3, result: Vector3): Vector3; - multiplyByFloats(x: number, y: number, z: number): Vector3; - divide(otherVector: Vector3): Vector3; - divideToRef(otherVector: Vector3, result: Vector3): Vector3; - MinimizeInPlace(other: Vector3): Vector3; - MaximizeInPlace(other: Vector3): Vector3; - length(): number; - lengthSquared(): number; - normalize(): Vector3; - clone(): Vector3; - copyFrom(source: Vector3): Vector3; - copyFromFloats(x: number, y: number, z: number): Vector3; - static GetClipFactor(vector0: Vector3, vector1: Vector3, axis: Vector3, size: any): number; - static FromArray(array: number[] | Float32Array, offset?: number): Vector3; - static FromFloatArray(array: Float32Array, offset?: number): Vector3; - static FromArrayToRef(array: number[] | Float32Array, offset: number, result: Vector3): void; - static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector3): void; - static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void; - static Zero(): Vector3; - static Up(): Vector3; - static Forward(): Vector3; - static Right(): Vector3; - static Left(): Vector3; - static TransformCoordinates(vector: Vector3, transformation: Matrix): Vector3; - static TransformCoordinatesToRef(vector: Vector3, transformation: Matrix, result: Vector3): void; - static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void; - static TransformNormal(vector: Vector3, transformation: Matrix): Vector3; - static TransformNormalToRef(vector: Vector3, transformation: Matrix, result: Vector3): void; - static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void; - static CatmullRom(value1: Vector3, value2: Vector3, value3: Vector3, value4: Vector3, amount: number): Vector3; - static Clamp(value: Vector3, min: Vector3, max: Vector3): Vector3; - static Hermite(value1: Vector3, tangent1: Vector3, value2: Vector3, tangent2: Vector3, amount: number): Vector3; - static Lerp(start: Vector3, end: Vector3, amount: number): Vector3; - static LerpToRef(start: Vector3, end: Vector3, amount: number, result: Vector3): void; - static Dot(left: Vector3, right: Vector3): number; - static Cross(left: Vector3, right: Vector3): Vector3; - static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void; - static Normalize(vector: Vector3): Vector3; - static NormalizeToRef(vector: Vector3, result: Vector3): void; - private static _viewportMatrixCache; - private static _matrixCache; - static Project(vector: Vector3, world: Matrix, transform: Matrix, viewport: Viewport): Vector3; - static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, transform: Matrix): Vector3; - static Unproject(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Vector3; - static Minimize(left: Vector3, right: Vector3): Vector3; - static Maximize(left: Vector3, right: Vector3): Vector3; - static Distance(value1: Vector3, value2: Vector3): number; - static DistanceSquared(value1: Vector3, value2: Vector3): number; - static Center(value1: Vector3, value2: Vector3): Vector3; + HighlightsDensity: number; /** - * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system), - * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply - * to something in order to rotate it from its local system to the given target system. + * Gets the highlights Saturation value. + * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation. */ - static RotationFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Vector3; /** - * The same than RotationFromAxis but updates the passed ref Vector3 parameter. + * Sets the highlights Saturation value. + * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation. */ - static RotationFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Vector3): void; - } - class Vector4 { - x: number; - y: number; - z: number; - w: number; - constructor(x: number, y: number, z: number, w: number); - toString(): string; - getClassName(): string; - getHashCode(): number; - asArray(): number[]; - toArray(array: number[], index?: number): Vector4; - addInPlace(otherVector: Vector4): Vector4; - add(otherVector: Vector4): Vector4; - addToRef(otherVector: Vector4, result: Vector4): Vector4; - subtractInPlace(otherVector: Vector4): Vector4; - subtract(otherVector: Vector4): Vector4; - subtractToRef(otherVector: Vector4, result: Vector4): Vector4; - subtractFromFloats(x: number, y: number, z: number, w: number): Vector4; - subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4; - negate(): Vector4; - scaleInPlace(scale: number): Vector4; - scale(scale: number): Vector4; - scaleToRef(scale: number, result: Vector4): void; - equals(otherVector: Vector4): boolean; - equalsWithEpsilon(otherVector: Vector4, epsilon?: number): boolean; - equalsToFloats(x: number, y: number, z: number, w: number): boolean; - multiplyInPlace(otherVector: Vector4): Vector4; - multiply(otherVector: Vector4): Vector4; - multiplyToRef(otherVector: Vector4, result: Vector4): Vector4; - multiplyByFloats(x: number, y: number, z: number, w: number): Vector4; - divide(otherVector: Vector4): Vector4; - divideToRef(otherVector: Vector4, result: Vector4): Vector4; - MinimizeInPlace(other: Vector4): Vector4; - MaximizeInPlace(other: Vector4): Vector4; - length(): number; - lengthSquared(): number; - normalize(): Vector4; - toVector3(): Vector3; - clone(): Vector4; - copyFrom(source: Vector4): Vector4; - copyFromFloats(x: number, y: number, z: number, w: number): Vector4; - static FromArray(array: number[], offset?: number): Vector4; - static FromArrayToRef(array: number[], offset: number, result: Vector4): void; - static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector4): void; - static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void; - static Zero(): Vector4; - static Normalize(vector: Vector4): Vector4; - static NormalizeToRef(vector: Vector4, result: Vector4): void; - static Minimize(left: Vector4, right: Vector4): Vector4; - static Maximize(left: Vector4, right: Vector4): Vector4; - static Distance(value1: Vector4, value2: Vector4): number; - static DistanceSquared(value1: Vector4, value2: Vector4): number; - static Center(value1: Vector4, value2: Vector4): Vector4; - } - interface ISize { - width: number; - height: number; - } - class Size implements ISize { - width: number; - height: number; - constructor(width: number, height: number); - toString(): string; - getClassName(): string; - getHashCode(): number; - copyFrom(src: Size): void; - copyFromFloats(width: number, height: number): void; - multiplyByFloats(w: number, h: number): Size; - clone(): Size; - equals(other: Size): boolean; - readonly surface: number; - static Zero(): Size; - add(otherSize: Size): Size; - substract(otherSize: Size): Size; - static Lerp(start: Size, end: Size, amount: number): Size; - } - class Quaternion { - x: number; - y: number; - z: number; - w: number; - constructor(x?: number, y?: number, z?: number, w?: number); - toString(): string; - getClassName(): string; - getHashCode(): number; - asArray(): number[]; - equals(otherQuaternion: Quaternion): boolean; - clone(): Quaternion; - copyFrom(other: Quaternion): Quaternion; - copyFromFloats(x: number, y: number, z: number, w: number): Quaternion; - add(other: Quaternion): Quaternion; - subtract(other: Quaternion): Quaternion; - scale(value: number): Quaternion; - multiply(q1: Quaternion): Quaternion; - multiplyToRef(q1: Quaternion, result: Quaternion): Quaternion; - multiplyInPlace(q1: Quaternion): Quaternion; - conjugateToRef(ref: Quaternion): Quaternion; - conjugateInPlace(): Quaternion; - conjugate(): Quaternion; - length(): number; - normalize(): Quaternion; - toEulerAngles(order?: string): Vector3; - toEulerAnglesToRef(result: Vector3, order?: string): Quaternion; - toRotationMatrix(result: Matrix): Quaternion; - fromRotationMatrix(matrix: Matrix): Quaternion; - static FromRotationMatrix(matrix: Matrix): Quaternion; - static FromRotationMatrixToRef(matrix: Matrix, result: Quaternion): void; - static Inverse(q: Quaternion): Quaternion; - static Identity(): Quaternion; - static RotationAxis(axis: Vector3, angle: number): Quaternion; - static RotationAxisToRef(axis: Vector3, angle: number, result: Quaternion): Quaternion; - static FromArray(array: number[], offset?: number): Quaternion; - static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion; - static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void; - static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion; - static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void; - static Slerp(left: Quaternion, right: Quaternion, amount: number): Quaternion; - static SlerpToRef(left: Quaternion, right: Quaternion, amount: number, result: Quaternion): void; - } - class Matrix { - private static _tempQuaternion; - private static _xAxis; - private static _yAxis; - private static _zAxis; - m: Float32Array; - isIdentity(): boolean; - determinant(): number; - toArray(): Float32Array; - asArray(): Float32Array; - invert(): Matrix; - reset(): Matrix; - add(other: Matrix): Matrix; - addToRef(other: Matrix, result: Matrix): Matrix; - addToSelf(other: Matrix): Matrix; - invertToRef(other: Matrix): Matrix; - setTranslation(vector3: Vector3): Matrix; - getTranslation(): Vector3; - multiply(other: Matrix): Matrix; - copyFrom(other: Matrix): Matrix; - copyToArray(array: Float32Array, offset?: number): Matrix; - multiplyToRef(other: Matrix, result: Matrix): Matrix; - multiplyToArray(other: Matrix, result: Float32Array, offset: number): Matrix; - equals(value: Matrix): boolean; - clone(): Matrix; - getClassName(): string; - getHashCode(): number; - decompose(scale: Vector3, rotation: Quaternion, translation: Vector3): boolean; - getRotationMatrix(): Matrix; - getRotationMatrixToRef(result: Matrix): void; - static FromArray(array: number[], offset?: number): Matrix; - static FromArrayToRef(array: number[], offset: number, result: Matrix): void; - static FromFloat32ArrayToRefScaled(array: Float32Array, offset: number, scale: number, result: Matrix): void; - static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void; - getRow(index: number): Vector4; - setRow(index: number, row: Vector4): Matrix; - static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix; - static Compose(scale: Vector3, rotation: Quaternion, translation: Vector3): Matrix; - static Identity(): Matrix; - static IdentityToRef(result: Matrix): void; - static Zero(): Matrix; - static RotationX(angle: number): Matrix; - static Invert(source: Matrix): Matrix; - static RotationXToRef(angle: number, result: Matrix): void; - static RotationY(angle: number): Matrix; - static RotationYToRef(angle: number, result: Matrix): void; - static RotationZ(angle: number): Matrix; - static RotationZToRef(angle: number, result: Matrix): void; - static RotationAxis(axis: Vector3, angle: number): Matrix; - static RotationAxisToRef(axis: Vector3, angle: number, result: Matrix): void; - static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix; - static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void; - static Scaling(x: number, y: number, z: number): Matrix; - static ScalingToRef(x: number, y: number, z: number, result: Matrix): void; - static Translation(x: number, y: number, z: number): Matrix; - static TranslationToRef(x: number, y: number, z: number, result: Matrix): void; - static Lerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix; - static DecomposeLerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix; - static LookAtLH(eye: Vector3, target: Vector3, up: Vector3): Matrix; - static LookAtLHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void; - static LookAtRH(eye: Vector3, target: Vector3, up: Vector3): Matrix; - static LookAtRHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void; - static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix; - static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void; - static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix; - static OrthoOffCenterLHToRef(left: number, right: any, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void; - static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix; - static OrthoOffCenterRHToRef(left: number, right: any, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void; - static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix; - static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix; - static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void; - static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix; - static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void; - static PerspectiveFovWebVRToRef(fov: any, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void; - static GetFinalMatrix(viewport: Viewport, world: Matrix, view: Matrix, projection: Matrix, zmin: number, zmax: number): Matrix; - static GetAsMatrix2x2(matrix: Matrix): Float32Array; - static GetAsMatrix3x3(matrix: Matrix): Float32Array; - static Transpose(matrix: Matrix): Matrix; - static Reflection(plane: Plane): Matrix; - static ReflectionToRef(plane: Plane, result: Matrix): void; - static FromXYZAxesToRef(xaxis: Vector3, yaxis: Vector3, zaxis: Vector3, mat: Matrix): void; - static FromQuaternionToRef(quat: Quaternion, result: Matrix): void; - } - class Plane { - normal: Vector3; - d: number; - constructor(a: number, b: number, c: number, d: number); - asArray(): number[]; - clone(): Plane; - getClassName(): string; - getHashCode(): number; - normalize(): Plane; - transform(transformation: Matrix): Plane; - dotCoordinate(point: any): number; - copyFromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane; - isFrontFacingTo(direction: Vector3, epsilon: number): boolean; - signedDistanceTo(point: Vector3): number; - static FromArray(array: number[]): Plane; - static FromPoints(point1: any, point2: any, point3: any): Plane; - static FromPositionAndNormal(origin: Vector3, normal: Vector3): Plane; - static SignedDistanceToPlaneFromPositionAndNormal(origin: Vector3, normal: Vector3, point: Vector3): number; - } - class Viewport { - x: number; - y: number; - width: number; - height: number; - constructor(x: number, y: number, width: number, height: number); - toGlobal(renderWidth: number, renderHeight: number): Viewport; - } - class Frustum { - static GetPlanes(transform: Matrix): Plane[]; - static GetPlanesToRef(transform: Matrix, frustumPlanes: Plane[]): void; - } - enum Space { - LOCAL = 0, - WORLD = 1, - } - class Axis { - static X: Vector3; - static Y: Vector3; - static Z: Vector3; - } - class BezierCurve { - static interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number; - } - enum Orientation { - CW = 0, - CCW = 1, - } - class Angle { - private _radians; - constructor(radians: number); - degrees: () => number; - radians: () => number; - static BetweenTwoPoints(a: Vector2, b: Vector2): Angle; - static FromRadians(radians: number): Angle; - static FromDegrees(degrees: number): Angle; - } - class Arc2 { - startPoint: Vector2; - midPoint: Vector2; - endPoint: Vector2; - centerPoint: Vector2; - radius: number; - angle: Angle; - startAngle: Angle; - orientation: Orientation; - constructor(startPoint: Vector2, midPoint: Vector2, endPoint: Vector2); - } - class Path2 { - private _points; - private _length; - closed: boolean; - constructor(x: number, y: number); - addLineTo(x: number, y: number): Path2; - addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2; - close(): Path2; - length(): number; - getPoints(): Vector2[]; - getPointAtLengthPosition(normalizedLengthPosition: number): Vector2; - static StartingAt(x: number, y: number): Path2; - } - class Path3D { - path: Vector3[]; - private _curve; - private _distances; - private _tangents; - private _normals; - private _binormals; - private _raw; - /** - * new Path3D(path, normal, raw) - * Creates a Path3D. A Path3D is a logical math object, so not a mesh. - * please read the description in the tutorial : http://doc.babylonjs.com/tutorials/How_to_use_Path3D - * path : an array of Vector3, the curve axis of the Path3D - * normal (optional) : Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal. - * raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed. - */ - constructor(path: Vector3[], firstNormal?: Vector3, raw?: boolean); + HighlightsSaturation: number; /** - * Returns the Path3D array of successive Vector3 designing its curve. + * Gets the highlights Exposure value. + * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure. */ - getCurve(): Vector3[]; /** - * Returns an array populated with tangent vectors on each Path3D curve point. + * Sets the highlights Exposure value. + * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure. */ - getTangents(): Vector3[]; + HighlightsExposure: number; + private _midtonesHue; + private _midtonesDensity; + private _midtonesSaturation; + private _midtonesExposure; /** - * Returns an array populated with normal vectors on each Path3D curve point. + * Gets the midtones Hue value. + * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange). */ - getNormals(): Vector3[]; /** - * Returns an array populated with binormal vectors on each Path3D curve point. + * Sets the midtones Hue value. + * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange). */ - getBinormals(): Vector3[]; + MidtonesHue: number; /** - * Returns an array populated with distances (float) of the i-th point from the first curve point. - */ - getDistances(): number[]; - /** - * Forces the Path3D tangent, normal, binormal and distance recomputation. - * Returns the same object updated. - */ - update(path: Vector3[], firstNormal?: Vector3): Path3D; - private _compute(firstNormal); - private _getFirstNonNullVector(index); - private _getLastNonNullVector(index); - private _normalVector(v0, vt, va); - } - class Curve3 { - private _points; - private _length; - /** - * Returns a Curve3 object along a Quadratic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#quadratic-bezier-curve - * @param v0 (Vector3) the origin point of the Quadratic Bezier - * @param v1 (Vector3) the control point - * @param v2 (Vector3) the end point of the Quadratic Bezier - * @param nbPoints (integer) the wanted number of points in the curve - */ - static CreateQuadraticBezier(v0: Vector3, v1: Vector3, v2: Vector3, nbPoints: number): Curve3; - /** - * Returns a Curve3 object along a Cubic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#cubic-bezier-curve - * @param v0 (Vector3) the origin point of the Cubic Bezier - * @param v1 (Vector3) the first control point - * @param v2 (Vector3) the second control point - * @param v3 (Vector3) the end point of the Cubic Bezier - * @param nbPoints (integer) the wanted number of points in the curve - */ - static CreateCubicBezier(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, nbPoints: number): Curve3; - /** - * Returns a Curve3 object along a Hermite Spline curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#hermite-spline - * @param p1 (Vector3) the origin point of the Hermite Spline - * @param t1 (Vector3) the tangent vector at the origin point - * @param p2 (Vector3) the end point of the Hermite Spline - * @param t2 (Vector3) the tangent vector at the end point - * @param nbPoints (integer) the wanted number of points in the curve - */ - static CreateHermiteSpline(p1: Vector3, t1: Vector3, p2: Vector3, t2: Vector3, nbPoints: number): Curve3; - /** - * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space. - * A Curve3 is designed from a series of successive Vector3. - * Tuto : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#curve3-object - */ - constructor(points: Vector3[]); - /** - * Returns the Curve3 stored array of successive Vector3 - */ - getPoints(): Vector3[]; - /** - * Returns the computed length (float) of the curve. - */ - length(): number; - /** - * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB); - * This new Curve3 is built by translating and sticking the curveB at the end of the curveA. - * curveA and curveB keep unchanged. - */ - continue(curve: Curve3): Curve3; - private _computeLength(path); - } - class SphericalHarmonics { - L00: Vector3; - L1_1: Vector3; - L10: Vector3; - L11: Vector3; - L2_2: Vector3; - L2_1: Vector3; - L20: Vector3; - L21: Vector3; - L22: Vector3; - addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void; - scale(scale: number): void; - } - class SphericalPolynomial { - x: Vector3; - y: Vector3; - z: Vector3; - xx: Vector3; - yy: Vector3; - zz: Vector3; - xy: Vector3; - yz: Vector3; - zx: Vector3; - addAmbient(color: Color3): void; - static getSphericalPolynomialFromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial; - } - class PositionNormalVertex { - position: Vector3; - normal: Vector3; - constructor(position?: Vector3, normal?: Vector3); - clone(): PositionNormalVertex; - } - class PositionNormalTextureVertex { - position: Vector3; - normal: Vector3; - uv: Vector2; - constructor(position?: Vector3, normal?: Vector3, uv?: Vector2); - clone(): PositionNormalTextureVertex; - } - class Tmp { - static Color3: Color3[]; - static Vector2: Vector2[]; - static Vector3: Vector3[]; - static Vector4: Vector4[]; - static Quaternion: Quaternion[]; - static Matrix: Matrix[]; - } -} - -declare module BABYLON { - /** - * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT). - * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects. - * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image; - * corresponding to low luminance, medium luminance, and high luminance areas respectively. - */ - class ColorCurves { - private _dirty; - private _tempColor; - private _globalCurve; - private _highlightsCurve; - private _midtonesCurve; - private _shadowsCurve; - private _positiveCurve; - private _negativeCurve; - private _globalHue; - private _globalDensity; - private _globalSaturation; - private _globalExposure; - /** - * Gets the global Hue value. - * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange). - */ - /** - * Sets the global Hue value. - * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange). - */ - GlobalHue: number; - /** - * Gets the global Density value. - * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect. - * Values less than zero provide a filter of opposite hue. - */ - /** - * Sets the global Density value. - * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect. - * Values less than zero provide a filter of opposite hue. - */ - GlobalDensity: number; - /** - * Gets the global Saturation value. - * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation. - */ - /** - * Sets the global Saturation value. - * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation. - */ - GlobalSaturation: number; - private _highlightsHue; - private _highlightsDensity; - private _highlightsSaturation; - private _highlightsExposure; - /** - * Gets the highlights Hue value. - * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange). - */ - /** - * Sets the highlights Hue value. - * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange). - */ - HighlightsHue: number; - /** - * Gets the highlights Density value. - * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect. - * Values less than zero provide a filter of opposite hue. - */ - /** - * Sets the highlights Density value. - * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect. - * Values less than zero provide a filter of opposite hue. - */ - HighlightsDensity: number; - /** - * Gets the highlights Saturation value. - * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation. - */ - /** - * Sets the highlights Saturation value. - * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation. - */ - HighlightsSaturation: number; - /** - * Gets the highlights Exposure value. - * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure. - */ - /** - * Sets the highlights Exposure value. - * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure. - */ - HighlightsExposure: number; - private _midtonesHue; - private _midtonesDensity; - private _midtonesSaturation; - private _midtonesExposure; - /** - * Gets the midtones Hue value. - * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange). - */ - /** - * Sets the midtones Hue value. - * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange). - */ - MidtonesHue: number; - /** - * Gets the midtones Density value. - * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect. - * Values less than zero provide a filter of opposite hue. + * Gets the midtones Density value. + * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect. + * Values less than zero provide a filter of opposite hue. */ /** * Sets the midtones Density value. @@ -5529,227 +4858,899 @@ declare module BABYLON { */ useScalarInLinearSpace: boolean; /** - * BJS is using an harcoded light falloff based on a manually sets up range. - * In PBR, one way to represents the fallof is to use the inverse squared root algorythm. - * This parameter can help you switch back to the BJS mode in order to create scenes using both materials. - */ - usePhysicalLightFalloff: boolean; + * BJS is using an harcoded light falloff based on a manually sets up range. + * In PBR, one way to represents the fallof is to use the inverse squared root algorythm. + * This parameter can help you switch back to the BJS mode in order to create scenes using both materials. + */ + usePhysicalLightFalloff: boolean; + /** + * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones). + * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind. + */ + useRadianceOverAlpha: boolean; + /** + * Allows using the bump map in parallax mode. + */ + useParallax: boolean; + /** + * Allows using the bump map in parallax occlusion mode. + */ + useParallaxOcclusion: boolean; + /** + * Controls the scale bias of the parallax mode. + */ + parallaxScaleBias: number; + /** + * If sets to true, disables all the lights affecting the material. + */ + disableLighting: boolean; + /** + * Number of Simultaneous lights allowed on the material. + */ + maxSimultaneousLights: number; + /** + * If sets to true, x component of normal map value will invert (x = 1.0 - x). + */ + invertNormalMapX: boolean; + /** + * If sets to true, y component of normal map value will invert (y = 1.0 - y). + */ + invertNormalMapY: boolean; + private _renderTargets; + private _worldViewProjectionMatrix; + private _globalAmbientColor; + private _tempColor; + private _renderId; + private _defines; + private _cachedDefines; + private _useLogarithmicDepth; + /** + * Instantiates a new PBRMaterial instance. + * + * @param name The material name + * @param scene The scene the material will be use in. + */ + constructor(name: string, scene: Scene); + getClassName(): string; + useLogarithmicDepth: boolean; + needAlphaBlending(): boolean; + needAlphaTesting(): boolean; + private _shouldUseAlphaFromAlbedoTexture(); + getAlphaTestTexture(): BaseTexture; + private _checkCache(scene, mesh?, useInstances?); + private convertColorToLinearSpaceToRef(color, ref); + private static convertColorToLinearSpaceToRef(color, ref, useScalarInLinear); + private static _scaledAlbedo; + private static _scaledReflectivity; + private static _scaledEmissive; + private static _scaledReflection; + static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: MaterialDefines, useScalarInLinearSpace: boolean, maxSimultaneousLights: number, usePhysicalLightFalloff: boolean): void; + isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean; + unbind(): void; + bindOnlyWorldMatrix(world: Matrix): void; + private _myScene; + private _myShadowGenerator; + bind(world: Matrix, mesh?: Mesh): void; + getAnimatables(): IAnimatable[]; + dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void; + clone(name: string): PBRMaterial; + serialize(): any; + static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial; + } +} + +declare module BABYLON { + class ShaderMaterial extends Material { + private _shaderPath; + private _options; + private _textures; + private _textureArrays; + private _floats; + private _floatsArrays; + private _colors3; + private _colors4; + private _vectors2; + private _vectors3; + private _vectors4; + private _matrices; + private _matrices3x3; + private _matrices2x2; + private _vectors3Arrays; + private _cachedWorldViewMatrix; + private _renderId; + constructor(name: string, scene: Scene, shaderPath: any, options: any); + getClassName(): string; + needAlphaBlending(): boolean; + needAlphaTesting(): boolean; + private _checkUniform(uniformName); + setTexture(name: string, texture: Texture): ShaderMaterial; + setTextureArray(name: string, textures: Texture[]): ShaderMaterial; + setFloat(name: string, value: number): ShaderMaterial; + setFloats(name: string, value: number[]): ShaderMaterial; + setColor3(name: string, value: Color3): ShaderMaterial; + setColor4(name: string, value: Color4): ShaderMaterial; + setVector2(name: string, value: Vector2): ShaderMaterial; + setVector3(name: string, value: Vector3): ShaderMaterial; + setVector4(name: string, value: Vector4): ShaderMaterial; + setMatrix(name: string, value: Matrix): ShaderMaterial; + setMatrix3x3(name: string, value: Float32Array): ShaderMaterial; + setMatrix2x2(name: string, value: Float32Array): ShaderMaterial; + setArray3(name: string, value: number[]): ShaderMaterial; + private _checkCache(scene, mesh?, useInstances?); + isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean; + bindOnlyWorldMatrix(world: Matrix): void; + bind(world: Matrix, mesh?: Mesh): void; + clone(name: string): ShaderMaterial; + dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void; + serialize(): any; + static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial; + } +} + +declare module BABYLON { + class StandardMaterial extends Material { + diffuseTexture: BaseTexture; + ambientTexture: BaseTexture; + opacityTexture: BaseTexture; + reflectionTexture: BaseTexture; + emissiveTexture: BaseTexture; + specularTexture: BaseTexture; + bumpTexture: BaseTexture; + lightmapTexture: BaseTexture; + refractionTexture: BaseTexture; + ambientColor: Color3; + diffuseColor: Color3; + specularColor: Color3; + emissiveColor: Color3; + specularPower: number; + useAlphaFromDiffuseTexture: boolean; + useEmissiveAsIllumination: boolean; + linkEmissiveWithDiffuse: boolean; + useReflectionFresnelFromSpecular: boolean; + useSpecularOverAlpha: boolean; + useReflectionOverAlpha: boolean; + disableLighting: boolean; + useParallax: boolean; + useParallaxOcclusion: boolean; + parallaxScaleBias: number; + roughness: number; + indexOfRefraction: number; + invertRefractionY: boolean; + useLightmapAsShadowmap: boolean; + diffuseFresnelParameters: FresnelParameters; + opacityFresnelParameters: FresnelParameters; + reflectionFresnelParameters: FresnelParameters; + refractionFresnelParameters: FresnelParameters; + emissiveFresnelParameters: FresnelParameters; + useGlossinessFromSpecularMapAlpha: boolean; + maxSimultaneousLights: number; + /** + * If sets to true, x component of normal map value will invert (x = 1.0 - x). + */ + invertNormalMapX: boolean; + /** + * If sets to true, y component of normal map value will invert (y = 1.0 - y). + */ + invertNormalMapY: boolean; + /** + * Color Grading 2D Lookup Texture. + * This allows special effects like sepia, black and white to sixties rendering style. + */ + cameraColorGradingTexture: BaseTexture; + /** + * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT). + * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects. + * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image; + * corresponding to low luminance, medium luminance, and high luminance areas respectively. + */ + cameraColorCurves: ColorCurves; + private _renderTargets; + private _worldViewProjectionMatrix; + private _globalAmbientColor; + private _renderId; + private _defines; + private _cachedDefines; + private _useLogarithmicDepth; + constructor(name: string, scene: Scene); + getClassName(): string; + useLogarithmicDepth: boolean; + needAlphaBlending(): boolean; + needAlphaTesting(): boolean; + private _shouldUseAlphaFromDiffuseTexture(); + getAlphaTestTexture(): BaseTexture; + private _checkCache(scene, mesh?, useInstances?); + isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean; + unbind(): void; + bindOnlyWorldMatrix(world: Matrix): void; + bind(world: Matrix, mesh?: Mesh): void; + getAnimatables(): IAnimatable[]; + dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void; + clone(name: string): StandardMaterial; + serialize(): any; + static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial; + static DiffuseTextureEnabled: boolean; + static AmbientTextureEnabled: boolean; + static OpacityTextureEnabled: boolean; + static ReflectionTextureEnabled: boolean; + static EmissiveTextureEnabled: boolean; + static SpecularTextureEnabled: boolean; + static BumpTextureEnabled: boolean; + static FresnelEnabled: boolean; + static LightmapTextureEnabled: boolean; + static RefractionTextureEnabled: boolean; + static ColorGradingTextureEnabled: boolean; + } +} + +declare module BABYLON { + class SIMDHelper { + private static _isEnabled; + static readonly IsEnabled: boolean; + static DisableSIMD(): void; + static EnableSIMD(): void; + } +} + +declare module BABYLON { + const ToGammaSpace: number; + const ToLinearSpace = 2.2; + const Epsilon = 0.001; + class MathTools { + static WithinEpsilon(a: number, b: number, epsilon?: number): boolean; + static ToHex(i: number): string; + static Sign(value: number): number; + static Clamp(value: number, min?: number, max?: number): number; + } + class Color3 { + r: number; + g: number; + b: number; + constructor(r?: number, g?: number, b?: number); + toString(): string; + getClassName(): string; + getHashCode(): number; + toArray(array: number[], index?: number): Color3; + toColor4(alpha?: number): Color4; + asArray(): number[]; + toLuminance(): number; + multiply(otherColor: Color3): Color3; + multiplyToRef(otherColor: Color3, result: Color3): Color3; + equals(otherColor: Color3): boolean; + equalsFloats(r: number, g: number, b: number): boolean; + scale(scale: number): Color3; + scaleToRef(scale: number, result: Color3): Color3; + add(otherColor: Color3): Color3; + addToRef(otherColor: Color3, result: Color3): Color3; + subtract(otherColor: Color3): Color3; + subtractToRef(otherColor: Color3, result: Color3): Color3; + clone(): Color3; + copyFrom(source: Color3): Color3; + copyFromFloats(r: number, g: number, b: number): Color3; + toHexString(): string; + toLinearSpace(): Color3; + toLinearSpaceToRef(convertedColor: Color3): Color3; + toGammaSpace(): Color3; + toGammaSpaceToRef(convertedColor: Color3): Color3; + static FromHexString(hex: string): Color3; + static FromArray(array: number[], offset?: number): Color3; + static FromInts(r: number, g: number, b: number): Color3; + static Lerp(start: Color3, end: Color3, amount: number): Color3; + static Red(): Color3; + static Green(): Color3; + static Blue(): Color3; + static Black(): Color3; + static White(): Color3; + static Purple(): Color3; + static Magenta(): Color3; + static Yellow(): Color3; + static Gray(): Color3; + } + class Color4 { + r: number; + g: number; + b: number; + a: number; + constructor(r: number, g: number, b: number, a: number); + addInPlace(right: any): Color4; + asArray(): number[]; + toArray(array: number[], index?: number): Color4; + add(right: Color4): Color4; + subtract(right: Color4): Color4; + subtractToRef(right: Color4, result: Color4): Color4; + scale(scale: number): Color4; + scaleToRef(scale: number, result: Color4): Color4; + /** + * Multipy an RGBA Color4 value by another and return a new Color4 object + * @param color The Color4 (RGBA) value to multiply by + * @returns A new Color4. + */ + multiply(color: Color4): Color4; + /** + * Multipy an RGBA Color4 value by another and push the result in a reference value + * @param color The Color4 (RGBA) value to multiply by + * @param result The Color4 (RGBA) to fill the result in + * @returns the result Color4. + */ + multiplyToRef(color: Color4, result: Color4): Color4; + toString(): string; + getClassName(): string; + getHashCode(): number; + clone(): Color4; + copyFrom(source: Color4): Color4; + toHexString(): string; + static FromHexString(hex: string): Color4; + static Lerp(left: Color4, right: Color4, amount: number): Color4; + static LerpToRef(left: Color4, right: Color4, amount: number, result: Color4): void; + static FromArray(array: number[], offset?: number): Color4; + static FromInts(r: number, g: number, b: number, a: number): Color4; + static CheckColors4(colors: number[], count: number): number[]; + } + class Vector2 { + x: number; + y: number; + constructor(x: number, y: number); + toString(): string; + getClassName(): string; + getHashCode(): number; + toArray(array: number[] | Float32Array, index?: number): Vector2; + asArray(): number[]; + copyFrom(source: Vector2): Vector2; + copyFromFloats(x: number, y: number): Vector2; + add(otherVector: Vector2): Vector2; + addToRef(otherVector: Vector2, result: Vector2): Vector2; + addInPlace(otherVector: Vector2): Vector2; + addVector3(otherVector: Vector3): Vector2; + subtract(otherVector: Vector2): Vector2; + subtractToRef(otherVector: Vector2, result: Vector2): Vector2; + subtractInPlace(otherVector: Vector2): Vector2; + multiplyInPlace(otherVector: Vector2): Vector2; + multiply(otherVector: Vector2): Vector2; + multiplyToRef(otherVector: Vector2, result: Vector2): Vector2; + multiplyByFloats(x: number, y: number): Vector2; + divide(otherVector: Vector2): Vector2; + divideToRef(otherVector: Vector2, result: Vector2): Vector2; + negate(): Vector2; + scaleInPlace(scale: number): Vector2; + scale(scale: number): Vector2; + equals(otherVector: Vector2): boolean; + equalsWithEpsilon(otherVector: Vector2, epsilon?: number): boolean; + length(): number; + lengthSquared(): number; + normalize(): Vector2; + clone(): Vector2; + static Zero(): Vector2; + static FromArray(array: number[] | Float32Array, offset?: number): Vector2; + static FromArrayToRef(array: number[] | Float32Array, offset: number, result: Vector2): void; + static CatmullRom(value1: Vector2, value2: Vector2, value3: Vector2, value4: Vector2, amount: number): Vector2; + static Clamp(value: Vector2, min: Vector2, max: Vector2): Vector2; + static Hermite(value1: Vector2, tangent1: Vector2, value2: Vector2, tangent2: Vector2, amount: number): Vector2; + static Lerp(start: Vector2, end: Vector2, amount: number): Vector2; + static Dot(left: Vector2, right: Vector2): number; + static Normalize(vector: Vector2): Vector2; + static Minimize(left: Vector2, right: Vector2): Vector2; + static Maximize(left: Vector2, right: Vector2): Vector2; + static Transform(vector: Vector2, transformation: Matrix): Vector2; + static TransformToRef(vector: Vector2, transformation: Matrix, result: Vector2): void; + static PointInTriangle(p: Vector2, p0: Vector2, p1: Vector2, p2: Vector2): boolean; + static Distance(value1: Vector2, value2: Vector2): number; + static DistanceSquared(value1: Vector2, value2: Vector2): number; + static Center(value1: Vector2, value2: Vector2): Vector2; + static DistanceOfPointFromSegment(p: Vector2, segA: Vector2, segB: Vector2): number; + } + class Vector3 { + x: number; + y: number; + z: number; + constructor(x: number, y: number, z: number); + toString(): string; + getClassName(): string; + getHashCode(): number; + asArray(): number[]; + toArray(array: number[] | Float32Array, index?: number): Vector3; + toQuaternion(): Quaternion; + addInPlace(otherVector: Vector3): Vector3; + add(otherVector: Vector3): Vector3; + addToRef(otherVector: Vector3, result: Vector3): Vector3; + subtractInPlace(otherVector: Vector3): Vector3; + subtract(otherVector: Vector3): Vector3; + subtractToRef(otherVector: Vector3, result: Vector3): Vector3; + subtractFromFloats(x: number, y: number, z: number): Vector3; + subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3; + negate(): Vector3; + scaleInPlace(scale: number): Vector3; + scale(scale: number): Vector3; + scaleToRef(scale: number, result: Vector3): void; + equals(otherVector: Vector3): boolean; + equalsWithEpsilon(otherVector: Vector3, epsilon?: number): boolean; + equalsToFloats(x: number, y: number, z: number): boolean; + multiplyInPlace(otherVector: Vector3): Vector3; + multiply(otherVector: Vector3): Vector3; + multiplyToRef(otherVector: Vector3, result: Vector3): Vector3; + multiplyByFloats(x: number, y: number, z: number): Vector3; + divide(otherVector: Vector3): Vector3; + divideToRef(otherVector: Vector3, result: Vector3): Vector3; + MinimizeInPlace(other: Vector3): Vector3; + MaximizeInPlace(other: Vector3): Vector3; + length(): number; + lengthSquared(): number; + normalize(): Vector3; + clone(): Vector3; + copyFrom(source: Vector3): Vector3; + copyFromFloats(x: number, y: number, z: number): Vector3; + static GetClipFactor(vector0: Vector3, vector1: Vector3, axis: Vector3, size: any): number; + static FromArray(array: number[] | Float32Array, offset?: number): Vector3; + static FromFloatArray(array: Float32Array, offset?: number): Vector3; + static FromArrayToRef(array: number[] | Float32Array, offset: number, result: Vector3): void; + static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector3): void; + static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void; + static Zero(): Vector3; + static Up(): Vector3; + static Forward(): Vector3; + static Right(): Vector3; + static Left(): Vector3; + static TransformCoordinates(vector: Vector3, transformation: Matrix): Vector3; + static TransformCoordinatesToRef(vector: Vector3, transformation: Matrix, result: Vector3): void; + static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void; + static TransformNormal(vector: Vector3, transformation: Matrix): Vector3; + static TransformNormalToRef(vector: Vector3, transformation: Matrix, result: Vector3): void; + static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void; + static CatmullRom(value1: Vector3, value2: Vector3, value3: Vector3, value4: Vector3, amount: number): Vector3; + static Clamp(value: Vector3, min: Vector3, max: Vector3): Vector3; + static Hermite(value1: Vector3, tangent1: Vector3, value2: Vector3, tangent2: Vector3, amount: number): Vector3; + static Lerp(start: Vector3, end: Vector3, amount: number): Vector3; + static LerpToRef(start: Vector3, end: Vector3, amount: number, result: Vector3): void; + static Dot(left: Vector3, right: Vector3): number; + static Cross(left: Vector3, right: Vector3): Vector3; + static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void; + static Normalize(vector: Vector3): Vector3; + static NormalizeToRef(vector: Vector3, result: Vector3): void; + private static _viewportMatrixCache; + private static _matrixCache; + static Project(vector: Vector3, world: Matrix, transform: Matrix, viewport: Viewport): Vector3; + static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, transform: Matrix): Vector3; + static Unproject(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Vector3; + static Minimize(left: Vector3, right: Vector3): Vector3; + static Maximize(left: Vector3, right: Vector3): Vector3; + static Distance(value1: Vector3, value2: Vector3): number; + static DistanceSquared(value1: Vector3, value2: Vector3): number; + static Center(value1: Vector3, value2: Vector3): Vector3; + /** + * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system), + * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply + * to something in order to rotate it from its local system to the given target system. + */ + static RotationFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Vector3; + /** + * The same than RotationFromAxis but updates the passed ref Vector3 parameter. + */ + static RotationFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Vector3): void; + } + class Vector4 { + x: number; + y: number; + z: number; + w: number; + constructor(x: number, y: number, z: number, w: number); + toString(): string; + getClassName(): string; + getHashCode(): number; + asArray(): number[]; + toArray(array: number[], index?: number): Vector4; + addInPlace(otherVector: Vector4): Vector4; + add(otherVector: Vector4): Vector4; + addToRef(otherVector: Vector4, result: Vector4): Vector4; + subtractInPlace(otherVector: Vector4): Vector4; + subtract(otherVector: Vector4): Vector4; + subtractToRef(otherVector: Vector4, result: Vector4): Vector4; + subtractFromFloats(x: number, y: number, z: number, w: number): Vector4; + subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4; + negate(): Vector4; + scaleInPlace(scale: number): Vector4; + scale(scale: number): Vector4; + scaleToRef(scale: number, result: Vector4): void; + equals(otherVector: Vector4): boolean; + equalsWithEpsilon(otherVector: Vector4, epsilon?: number): boolean; + equalsToFloats(x: number, y: number, z: number, w: number): boolean; + multiplyInPlace(otherVector: Vector4): Vector4; + multiply(otherVector: Vector4): Vector4; + multiplyToRef(otherVector: Vector4, result: Vector4): Vector4; + multiplyByFloats(x: number, y: number, z: number, w: number): Vector4; + divide(otherVector: Vector4): Vector4; + divideToRef(otherVector: Vector4, result: Vector4): Vector4; + MinimizeInPlace(other: Vector4): Vector4; + MaximizeInPlace(other: Vector4): Vector4; + length(): number; + lengthSquared(): number; + normalize(): Vector4; + toVector3(): Vector3; + clone(): Vector4; + copyFrom(source: Vector4): Vector4; + copyFromFloats(x: number, y: number, z: number, w: number): Vector4; + static FromArray(array: number[], offset?: number): Vector4; + static FromArrayToRef(array: number[], offset: number, result: Vector4): void; + static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector4): void; + static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void; + static Zero(): Vector4; + static Normalize(vector: Vector4): Vector4; + static NormalizeToRef(vector: Vector4, result: Vector4): void; + static Minimize(left: Vector4, right: Vector4): Vector4; + static Maximize(left: Vector4, right: Vector4): Vector4; + static Distance(value1: Vector4, value2: Vector4): number; + static DistanceSquared(value1: Vector4, value2: Vector4): number; + static Center(value1: Vector4, value2: Vector4): Vector4; + } + interface ISize { + width: number; + height: number; + } + class Size implements ISize { + width: number; + height: number; + constructor(width: number, height: number); + toString(): string; + getClassName(): string; + getHashCode(): number; + copyFrom(src: Size): void; + copyFromFloats(width: number, height: number): void; + multiplyByFloats(w: number, h: number): Size; + clone(): Size; + equals(other: Size): boolean; + readonly surface: number; + static Zero(): Size; + add(otherSize: Size): Size; + substract(otherSize: Size): Size; + static Lerp(start: Size, end: Size, amount: number): Size; + } + class Quaternion { + x: number; + y: number; + z: number; + w: number; + constructor(x?: number, y?: number, z?: number, w?: number); + toString(): string; + getClassName(): string; + getHashCode(): number; + asArray(): number[]; + equals(otherQuaternion: Quaternion): boolean; + clone(): Quaternion; + copyFrom(other: Quaternion): Quaternion; + copyFromFloats(x: number, y: number, z: number, w: number): Quaternion; + add(other: Quaternion): Quaternion; + subtract(other: Quaternion): Quaternion; + scale(value: number): Quaternion; + multiply(q1: Quaternion): Quaternion; + multiplyToRef(q1: Quaternion, result: Quaternion): Quaternion; + multiplyInPlace(q1: Quaternion): Quaternion; + conjugateToRef(ref: Quaternion): Quaternion; + conjugateInPlace(): Quaternion; + conjugate(): Quaternion; + length(): number; + normalize(): Quaternion; + toEulerAngles(order?: string): Vector3; + toEulerAnglesToRef(result: Vector3, order?: string): Quaternion; + toRotationMatrix(result: Matrix): Quaternion; + fromRotationMatrix(matrix: Matrix): Quaternion; + static FromRotationMatrix(matrix: Matrix): Quaternion; + static FromRotationMatrixToRef(matrix: Matrix, result: Quaternion): void; + static Inverse(q: Quaternion): Quaternion; + static Identity(): Quaternion; + static RotationAxis(axis: Vector3, angle: number): Quaternion; + static RotationAxisToRef(axis: Vector3, angle: number, result: Quaternion): Quaternion; + static FromArray(array: number[], offset?: number): Quaternion; + static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion; + static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void; + static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion; + static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void; + static Slerp(left: Quaternion, right: Quaternion, amount: number): Quaternion; + static SlerpToRef(left: Quaternion, right: Quaternion, amount: number, result: Quaternion): void; + } + class Matrix { + private static _tempQuaternion; + private static _xAxis; + private static _yAxis; + private static _zAxis; + m: Float32Array; + isIdentity(): boolean; + determinant(): number; + toArray(): Float32Array; + asArray(): Float32Array; + invert(): Matrix; + reset(): Matrix; + add(other: Matrix): Matrix; + addToRef(other: Matrix, result: Matrix): Matrix; + addToSelf(other: Matrix): Matrix; + invertToRef(other: Matrix): Matrix; + setTranslation(vector3: Vector3): Matrix; + getTranslation(): Vector3; + multiply(other: Matrix): Matrix; + copyFrom(other: Matrix): Matrix; + copyToArray(array: Float32Array, offset?: number): Matrix; + multiplyToRef(other: Matrix, result: Matrix): Matrix; + multiplyToArray(other: Matrix, result: Float32Array, offset: number): Matrix; + equals(value: Matrix): boolean; + clone(): Matrix; + getClassName(): string; + getHashCode(): number; + decompose(scale: Vector3, rotation: Quaternion, translation: Vector3): boolean; + getRotationMatrix(): Matrix; + getRotationMatrixToRef(result: Matrix): void; + static FromArray(array: number[], offset?: number): Matrix; + static FromArrayToRef(array: number[], offset: number, result: Matrix): void; + static FromFloat32ArrayToRefScaled(array: Float32Array, offset: number, scale: number, result: Matrix): void; + static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void; + getRow(index: number): Vector4; + setRow(index: number, row: Vector4): Matrix; + static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix; + static Compose(scale: Vector3, rotation: Quaternion, translation: Vector3): Matrix; + static Identity(): Matrix; + static IdentityToRef(result: Matrix): void; + static Zero(): Matrix; + static RotationX(angle: number): Matrix; + static Invert(source: Matrix): Matrix; + static RotationXToRef(angle: number, result: Matrix): void; + static RotationY(angle: number): Matrix; + static RotationYToRef(angle: number, result: Matrix): void; + static RotationZ(angle: number): Matrix; + static RotationZToRef(angle: number, result: Matrix): void; + static RotationAxis(axis: Vector3, angle: number): Matrix; + static RotationAxisToRef(axis: Vector3, angle: number, result: Matrix): void; + static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix; + static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void; + static Scaling(x: number, y: number, z: number): Matrix; + static ScalingToRef(x: number, y: number, z: number, result: Matrix): void; + static Translation(x: number, y: number, z: number): Matrix; + static TranslationToRef(x: number, y: number, z: number, result: Matrix): void; + static Lerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix; + static DecomposeLerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix; + static LookAtLH(eye: Vector3, target: Vector3, up: Vector3): Matrix; + static LookAtLHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void; + static LookAtRH(eye: Vector3, target: Vector3, up: Vector3): Matrix; + static LookAtRHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void; + static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix; + static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void; + static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix; + static OrthoOffCenterLHToRef(left: number, right: any, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void; + static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix; + static OrthoOffCenterRHToRef(left: number, right: any, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void; + static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix; + static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix; + static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void; + static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix; + static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void; + static PerspectiveFovWebVRToRef(fov: any, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void; + static GetFinalMatrix(viewport: Viewport, world: Matrix, view: Matrix, projection: Matrix, zmin: number, zmax: number): Matrix; + static GetAsMatrix2x2(matrix: Matrix): Float32Array; + static GetAsMatrix3x3(matrix: Matrix): Float32Array; + static Transpose(matrix: Matrix): Matrix; + static Reflection(plane: Plane): Matrix; + static ReflectionToRef(plane: Plane, result: Matrix): void; + static FromXYZAxesToRef(xaxis: Vector3, yaxis: Vector3, zaxis: Vector3, mat: Matrix): void; + static FromQuaternionToRef(quat: Quaternion, result: Matrix): void; + } + class Plane { + normal: Vector3; + d: number; + constructor(a: number, b: number, c: number, d: number); + asArray(): number[]; + clone(): Plane; + getClassName(): string; + getHashCode(): number; + normalize(): Plane; + transform(transformation: Matrix): Plane; + dotCoordinate(point: any): number; + copyFromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane; + isFrontFacingTo(direction: Vector3, epsilon: number): boolean; + signedDistanceTo(point: Vector3): number; + static FromArray(array: number[]): Plane; + static FromPoints(point1: any, point2: any, point3: any): Plane; + static FromPositionAndNormal(origin: Vector3, normal: Vector3): Plane; + static SignedDistanceToPlaneFromPositionAndNormal(origin: Vector3, normal: Vector3, point: Vector3): number; + } + class Viewport { + x: number; + y: number; + width: number; + height: number; + constructor(x: number, y: number, width: number, height: number); + toGlobal(renderWidth: number, renderHeight: number): Viewport; + } + class Frustum { + static GetPlanes(transform: Matrix): Plane[]; + static GetPlanesToRef(transform: Matrix, frustumPlanes: Plane[]): void; + } + enum Space { + LOCAL = 0, + WORLD = 1, + } + class Axis { + static X: Vector3; + static Y: Vector3; + static Z: Vector3; + } + class BezierCurve { + static interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number; + } + enum Orientation { + CW = 0, + CCW = 1, + } + class Angle { + private _radians; + constructor(radians: number); + degrees: () => number; + radians: () => number; + static BetweenTwoPoints(a: Vector2, b: Vector2): Angle; + static FromRadians(radians: number): Angle; + static FromDegrees(degrees: number): Angle; + } + class Arc2 { + startPoint: Vector2; + midPoint: Vector2; + endPoint: Vector2; + centerPoint: Vector2; + radius: number; + angle: Angle; + startAngle: Angle; + orientation: Orientation; + constructor(startPoint: Vector2, midPoint: Vector2, endPoint: Vector2); + } + class Path2 { + private _points; + private _length; + closed: boolean; + constructor(x: number, y: number); + addLineTo(x: number, y: number): Path2; + addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2; + close(): Path2; + length(): number; + getPoints(): Vector2[]; + getPointAtLengthPosition(normalizedLengthPosition: number): Vector2; + static StartingAt(x: number, y: number): Path2; + } + class Path3D { + path: Vector3[]; + private _curve; + private _distances; + private _tangents; + private _normals; + private _binormals; + private _raw; + /** + * new Path3D(path, normal, raw) + * Creates a Path3D. A Path3D is a logical math object, so not a mesh. + * please read the description in the tutorial : http://doc.babylonjs.com/tutorials/How_to_use_Path3D + * path : an array of Vector3, the curve axis of the Path3D + * normal (optional) : Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal. + * raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed. + */ + constructor(path: Vector3[], firstNormal?: Vector3, raw?: boolean); /** - * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones). - * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind. + * Returns the Path3D array of successive Vector3 designing its curve. */ - useRadianceOverAlpha: boolean; + getCurve(): Vector3[]; /** - * Allows using the bump map in parallax mode. + * Returns an array populated with tangent vectors on each Path3D curve point. */ - useParallax: boolean; + getTangents(): Vector3[]; /** - * Allows using the bump map in parallax occlusion mode. + * Returns an array populated with normal vectors on each Path3D curve point. */ - useParallaxOcclusion: boolean; + getNormals(): Vector3[]; /** - * Controls the scale bias of the parallax mode. + * Returns an array populated with binormal vectors on each Path3D curve point. */ - parallaxScaleBias: number; + getBinormals(): Vector3[]; /** - * If sets to true, disables all the lights affecting the material. + * Returns an array populated with distances (float) of the i-th point from the first curve point. */ - disableLighting: boolean; + getDistances(): number[]; /** - * Number of Simultaneous lights allowed on the material. + * Forces the Path3D tangent, normal, binormal and distance recomputation. + * Returns the same object updated. */ - maxSimultaneousLights: number; + update(path: Vector3[], firstNormal?: Vector3): Path3D; + private _compute(firstNormal); + private _getFirstNonNullVector(index); + private _getLastNonNullVector(index); + private _normalVector(v0, vt, va); + } + class Curve3 { + private _points; + private _length; /** - * If sets to true, x component of normal map value will invert (x = 1.0 - x). + * Returns a Curve3 object along a Quadratic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#quadratic-bezier-curve + * @param v0 (Vector3) the origin point of the Quadratic Bezier + * @param v1 (Vector3) the control point + * @param v2 (Vector3) the end point of the Quadratic Bezier + * @param nbPoints (integer) the wanted number of points in the curve */ - invertNormalMapX: boolean; + static CreateQuadraticBezier(v0: Vector3, v1: Vector3, v2: Vector3, nbPoints: number): Curve3; /** - * If sets to true, y component of normal map value will invert (y = 1.0 - y). + * Returns a Curve3 object along a Cubic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#cubic-bezier-curve + * @param v0 (Vector3) the origin point of the Cubic Bezier + * @param v1 (Vector3) the first control point + * @param v2 (Vector3) the second control point + * @param v3 (Vector3) the end point of the Cubic Bezier + * @param nbPoints (integer) the wanted number of points in the curve */ - invertNormalMapY: boolean; - private _renderTargets; - private _worldViewProjectionMatrix; - private _globalAmbientColor; - private _tempColor; - private _renderId; - private _defines; - private _cachedDefines; - private _useLogarithmicDepth; + static CreateCubicBezier(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, nbPoints: number): Curve3; /** - * Instantiates a new PBRMaterial instance. - * - * @param name The material name - * @param scene The scene the material will be use in. + * Returns a Curve3 object along a Hermite Spline curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#hermite-spline + * @param p1 (Vector3) the origin point of the Hermite Spline + * @param t1 (Vector3) the tangent vector at the origin point + * @param p2 (Vector3) the end point of the Hermite Spline + * @param t2 (Vector3) the tangent vector at the end point + * @param nbPoints (integer) the wanted number of points in the curve */ - constructor(name: string, scene: Scene); - getClassName(): string; - useLogarithmicDepth: boolean; - needAlphaBlending(): boolean; - needAlphaTesting(): boolean; - private _shouldUseAlphaFromAlbedoTexture(); - getAlphaTestTexture(): BaseTexture; - private _checkCache(scene, mesh?, useInstances?); - private convertColorToLinearSpaceToRef(color, ref); - private static convertColorToLinearSpaceToRef(color, ref, useScalarInLinear); - private static _scaledAlbedo; - private static _scaledReflectivity; - private static _scaledEmissive; - private static _scaledReflection; - static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: MaterialDefines, useScalarInLinearSpace: boolean, maxSimultaneousLights: number, usePhysicalLightFalloff: boolean): void; - isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean; - unbind(): void; - bindOnlyWorldMatrix(world: Matrix): void; - private _myScene; - private _myShadowGenerator; - bind(world: Matrix, mesh?: Mesh): void; - getAnimatables(): IAnimatable[]; - dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void; - clone(name: string): PBRMaterial; - serialize(): any; - static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial; - } -} - -declare module BABYLON { - class ShaderMaterial extends Material { - private _shaderPath; - private _options; - private _textures; - private _textureArrays; - private _floats; - private _floatsArrays; - private _colors3; - private _colors4; - private _vectors2; - private _vectors3; - private _vectors4; - private _matrices; - private _matrices3x3; - private _matrices2x2; - private _vectors3Arrays; - private _cachedWorldViewMatrix; - private _renderId; - constructor(name: string, scene: Scene, shaderPath: any, options: any); - getClassName(): string; - needAlphaBlending(): boolean; - needAlphaTesting(): boolean; - private _checkUniform(uniformName); - setTexture(name: string, texture: Texture): ShaderMaterial; - setTextureArray(name: string, textures: Texture[]): ShaderMaterial; - setFloat(name: string, value: number): ShaderMaterial; - setFloats(name: string, value: number[]): ShaderMaterial; - setColor3(name: string, value: Color3): ShaderMaterial; - setColor4(name: string, value: Color4): ShaderMaterial; - setVector2(name: string, value: Vector2): ShaderMaterial; - setVector3(name: string, value: Vector3): ShaderMaterial; - setVector4(name: string, value: Vector4): ShaderMaterial; - setMatrix(name: string, value: Matrix): ShaderMaterial; - setMatrix3x3(name: string, value: Float32Array): ShaderMaterial; - setMatrix2x2(name: string, value: Float32Array): ShaderMaterial; - setArray3(name: string, value: number[]): ShaderMaterial; - private _checkCache(scene, mesh?, useInstances?); - isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean; - bindOnlyWorldMatrix(world: Matrix): void; - bind(world: Matrix, mesh?: Mesh): void; - clone(name: string): ShaderMaterial; - dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void; - serialize(): any; - static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial; - } -} - -declare module BABYLON { - class StandardMaterial extends Material { - diffuseTexture: BaseTexture; - ambientTexture: BaseTexture; - opacityTexture: BaseTexture; - reflectionTexture: BaseTexture; - emissiveTexture: BaseTexture; - specularTexture: BaseTexture; - bumpTexture: BaseTexture; - lightmapTexture: BaseTexture; - refractionTexture: BaseTexture; - ambientColor: Color3; - diffuseColor: Color3; - specularColor: Color3; - emissiveColor: Color3; - specularPower: number; - useAlphaFromDiffuseTexture: boolean; - useEmissiveAsIllumination: boolean; - linkEmissiveWithDiffuse: boolean; - useReflectionFresnelFromSpecular: boolean; - useSpecularOverAlpha: boolean; - useReflectionOverAlpha: boolean; - disableLighting: boolean; - useParallax: boolean; - useParallaxOcclusion: boolean; - parallaxScaleBias: number; - roughness: number; - indexOfRefraction: number; - invertRefractionY: boolean; - useLightmapAsShadowmap: boolean; - diffuseFresnelParameters: FresnelParameters; - opacityFresnelParameters: FresnelParameters; - reflectionFresnelParameters: FresnelParameters; - refractionFresnelParameters: FresnelParameters; - emissiveFresnelParameters: FresnelParameters; - useGlossinessFromSpecularMapAlpha: boolean; - maxSimultaneousLights: number; + static CreateHermiteSpline(p1: Vector3, t1: Vector3, p2: Vector3, t2: Vector3, nbPoints: number): Curve3; /** - * If sets to true, x component of normal map value will invert (x = 1.0 - x). + * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space. + * A Curve3 is designed from a series of successive Vector3. + * Tuto : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#curve3-object */ - invertNormalMapX: boolean; + constructor(points: Vector3[]); /** - * If sets to true, y component of normal map value will invert (y = 1.0 - y). + * Returns the Curve3 stored array of successive Vector3 */ - invertNormalMapY: boolean; + getPoints(): Vector3[]; /** - * Color Grading 2D Lookup Texture. - * This allows special effects like sepia, black and white to sixties rendering style. + * Returns the computed length (float) of the curve. */ - cameraColorGradingTexture: BaseTexture; + length(): number; /** - * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT). - * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects. - * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image; - * corresponding to low luminance, medium luminance, and high luminance areas respectively. + * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB); + * This new Curve3 is built by translating and sticking the curveB at the end of the curveA. + * curveA and curveB keep unchanged. */ - cameraColorCurves: ColorCurves; - private _renderTargets; - private _worldViewProjectionMatrix; - private _globalAmbientColor; - private _renderId; - private _defines; - private _cachedDefines; - private _useLogarithmicDepth; - constructor(name: string, scene: Scene); - getClassName(): string; - useLogarithmicDepth: boolean; - needAlphaBlending(): boolean; - needAlphaTesting(): boolean; - private _shouldUseAlphaFromDiffuseTexture(); - getAlphaTestTexture(): BaseTexture; - private _checkCache(scene, mesh?, useInstances?); - isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean; - unbind(): void; - bindOnlyWorldMatrix(world: Matrix): void; - bind(world: Matrix, mesh?: Mesh): void; - getAnimatables(): IAnimatable[]; - dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void; - clone(name: string): StandardMaterial; - serialize(): any; - static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial; - static DiffuseTextureEnabled: boolean; - static AmbientTextureEnabled: boolean; - static OpacityTextureEnabled: boolean; - static ReflectionTextureEnabled: boolean; - static EmissiveTextureEnabled: boolean; - static SpecularTextureEnabled: boolean; - static BumpTextureEnabled: boolean; - static FresnelEnabled: boolean; - static LightmapTextureEnabled: boolean; - static RefractionTextureEnabled: boolean; - static ColorGradingTextureEnabled: boolean; + continue(curve: Curve3): Curve3; + private _computeLength(path); + } + class SphericalHarmonics { + L00: Vector3; + L1_1: Vector3; + L10: Vector3; + L11: Vector3; + L2_2: Vector3; + L2_1: Vector3; + L20: Vector3; + L21: Vector3; + L22: Vector3; + addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void; + scale(scale: number): void; + } + class SphericalPolynomial { + x: Vector3; + y: Vector3; + z: Vector3; + xx: Vector3; + yy: Vector3; + zz: Vector3; + xy: Vector3; + yz: Vector3; + zx: Vector3; + addAmbient(color: Color3): void; + static getSphericalPolynomialFromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial; + } + class PositionNormalVertex { + position: Vector3; + normal: Vector3; + constructor(position?: Vector3, normal?: Vector3); + clone(): PositionNormalVertex; + } + class PositionNormalTextureVertex { + position: Vector3; + normal: Vector3; + uv: Vector2; + constructor(position?: Vector3, normal?: Vector3, uv?: Vector2); + clone(): PositionNormalTextureVertex; + } + class Tmp { + static Color3: Color3[]; + static Vector2: Vector2[]; + static Vector3: Vector3[]; + static Vector4: Vector4[]; + static Quaternion: Quaternion[]; + static Matrix: Matrix[]; } } @@ -9005,6 +9006,28 @@ declare module BABYLON { } } +declare module BABYLON { + class ReflectionProbe { + name: string; + private _scene; + private _renderTargetTexture; + private _projectionMatrix; + private _viewMatrix; + private _target; + private _add; + private _attachedMesh; + invertYAxis: boolean; + position: Vector3; + constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean); + refreshRate: number; + getScene(): Scene; + readonly cubeTexture: RenderTargetTexture; + readonly renderList: AbstractMesh[]; + attachToMesh(mesh: AbstractMesh): void; + dispose(): void; + } +} + declare module BABYLON { class AnaglyphPostProcess extends PostProcess { private _passedProcess; @@ -9680,98 +9703,6 @@ declare module BABYLON { } } -declare module BABYLON { - class ReflectionProbe { - name: string; - private _scene; - private _renderTargetTexture; - private _projectionMatrix; - private _viewMatrix; - private _target; - private _add; - private _attachedMesh; - invertYAxis: boolean; - position: Vector3; - constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean); - refreshRate: number; - getScene(): Scene; - readonly cubeTexture: RenderTargetTexture; - readonly renderList: AbstractMesh[]; - attachToMesh(mesh: AbstractMesh): void; - dispose(): void; - } -} - -declare module BABYLON { - class Sprite { - name: string; - position: Vector3; - color: Color4; - width: number; - height: number; - angle: number; - cellIndex: number; - invertU: number; - invertV: number; - disposeWhenFinishedAnimating: boolean; - animations: Animation[]; - isPickable: boolean; - actionManager: ActionManager; - private _animationStarted; - private _loopAnimation; - private _fromIndex; - private _toIndex; - private _delay; - private _direction; - private _frameCount; - private _manager; - private _time; - private _onAnimationEnd; - size: number; - constructor(name: string, manager: SpriteManager); - playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void; - stopAnimation(): void; - _animate(deltaTime: number): void; - dispose(): void; - } -} - -declare module BABYLON { - class SpriteManager { - name: string; - sprites: Sprite[]; - renderingGroupId: number; - layerMask: number; - fogEnabled: boolean; - isPickable: boolean; - cellWidth: number; - cellHeight: number; - /** - * An event triggered when the manager is disposed. - * @type {BABYLON.Observable} - */ - onDisposeObservable: Observable; - private _onDisposeObserver; - onDispose: () => void; - private _capacity; - private _spriteTexture; - private _epsilon; - private _scene; - private _vertexData; - private _buffer; - private _vertexBuffers; - private _indexBuffer; - private _effectBase; - private _effectFog; - texture: Texture; - constructor(name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number); - private _appendSpriteVertex(index, sprite, offsetX, offsetY, rowSize); - intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): PickingInfo; - render(): void; - dispose(): void; - } -} - declare module BABYLON { class BoundingBoxRenderer { frontColor: Color3; @@ -10009,6 +9940,76 @@ declare module BABYLON { } } +declare module BABYLON { + class Sprite { + name: string; + position: Vector3; + color: Color4; + width: number; + height: number; + angle: number; + cellIndex: number; + invertU: number; + invertV: number; + disposeWhenFinishedAnimating: boolean; + animations: Animation[]; + isPickable: boolean; + actionManager: ActionManager; + private _animationStarted; + private _loopAnimation; + private _fromIndex; + private _toIndex; + private _delay; + private _direction; + private _frameCount; + private _manager; + private _time; + private _onAnimationEnd; + size: number; + constructor(name: string, manager: SpriteManager); + playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void; + stopAnimation(): void; + _animate(deltaTime: number): void; + dispose(): void; + } +} + +declare module BABYLON { + class SpriteManager { + name: string; + sprites: Sprite[]; + renderingGroupId: number; + layerMask: number; + fogEnabled: boolean; + isPickable: boolean; + cellWidth: number; + cellHeight: number; + /** + * An event triggered when the manager is disposed. + * @type {BABYLON.Observable} + */ + onDisposeObservable: Observable; + private _onDisposeObserver; + onDispose: () => void; + private _capacity; + private _spriteTexture; + private _epsilon; + private _scene; + private _vertexData; + private _buffer; + private _vertexBuffers; + private _indexBuffer; + private _effectBase; + private _effectFog; + texture: Texture; + constructor(name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number); + private _appendSpriteVertex(index, sprite, offsetX, offsetY, rowSize); + intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): PickingInfo; + render(): void; + dispose(): void; + } +} + declare module BABYLON.Internals { class _AlphaState { private _isAlphaBlendDirty; @@ -10907,6 +10908,7 @@ declare module BABYLON { static BaseUrl: string; static CorsBehavior: any; static UseFallbackTexture: boolean; + private static fallbackTexture; static Instantiate(className: string): any; static SetImmediate(action: () => void): void; static IsExponentOfTwo(value: number): boolean; @@ -11218,50 +11220,107 @@ declare module BABYLON { } } +interface Window { + holographicViewMatrix: boolean; + getViewMatrix(): Float32Array; + getCameraPositionVector(): Float32Array; +} declare module BABYLON { - interface IOctreeContainer { - blocks: Array>; + class HolographicCamera extends Camera { + private _identityProjection; + private _scriptProjection; + private _scriptViewProjection; + private _holographicViewMatrix; + private _onBeforeRenderObserver; + private _onBeforeCameraRenderObserver; + constructor(name: string, scene: Scene); + getTypeName(): string; + getProjectionMatrix(): Matrix; + getViewMatrix(): Matrix; + setViewMatrix(view: Matrix): void; + _initCache(): void; + _updateCache(): void; + _updateFromScene(): void; + _isSynchronizedViewMatrix(): boolean; + _isSynchronizedProjectionMatrix(): boolean; + private getFrustumPlanesToRef(result); + dispose(): void; } - class Octree { - maxDepth: number; - blocks: Array>; - dynamicContent: T[]; - private _maxBlockCapacity; - private _selectionContent; - private _creationFunc; - constructor(creationFunc: (entry: T, block: OctreeBlock) => void, maxBlockCapacity?: number, maxDepth?: number); - update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void; - addMesh(entry: T): void; - select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray; - intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray; - intersectsRay(ray: Ray): SmartArray; - static _CreateBlocks(worldMin: Vector3, worldMax: Vector3, entries: T[], maxBlockCapacity: number, currentDepth: number, maxDepth: number, target: IOctreeContainer, creationFunc: (entry: T, block: OctreeBlock) => void): void; - static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock) => void; - static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock) => void; +} + +declare module BABYLON { + class VRCameraMetrics { + hResolution: number; + vResolution: number; + hScreenSize: number; + vScreenSize: number; + vScreenCenter: number; + eyeToScreenDistance: number; + lensSeparationDistance: number; + interpupillaryDistance: number; + distortionK: number[]; + chromaAbCorrection: number[]; + postProcessScaleFactor: number; + lensCenterOffset: number; + compensateDistortion: boolean; + readonly aspectRatio: number; + readonly aspectRatioFov: number; + readonly leftHMatrix: Matrix; + readonly rightHMatrix: Matrix; + readonly leftPreViewMatrix: Matrix; + readonly rightPreViewMatrix: Matrix; + static GetDefault(): VRCameraMetrics; } } declare module BABYLON { - class OctreeBlock { - entries: T[]; - blocks: Array>; - private _depth; - private _maxDepth; - private _capacity; - private _minPoint; - private _maxPoint; - private _boundingVectors; - private _creationFunc; - constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock) => void); - readonly capacity: number; - readonly minPoint: Vector3; - readonly maxPoint: Vector3; - addEntry(entry: T): void; - addEntries(entries: T[]): void; - select(frustumPlanes: Plane[], selection: SmartArray, allowDuplicate?: boolean): void; - intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArray, allowDuplicate?: boolean): void; - intersectsRay(ray: Ray, selection: SmartArray): void; - createInnerBlocks(): void; + class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera { + constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics); + getClassName(): string; + } + class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera { + constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics); + getClassName(): string; + } +} + +declare var HMDVRDevice: any; +declare var VRDisplay: any; +declare var VRFrameData: any; +declare module BABYLON { + interface WebVROptions { + trackPosition?: boolean; + positionScale?: number; + displayName?: string; + } + class WebVRFreeCamera extends FreeCamera { + private webVROptions; + _vrDevice: any; + private _cacheState; + private _vrEnabled; + private _attached; + private _oldSize; + private _oldHardwareScaleFactor; + private _frameData; + private _quaternionCache; + private _positionOffset; + constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, webVROptions?: WebVROptions); + _checkInputs(): void; + attachControl(element: HTMLElement, noPreventDefault?: boolean): void; + detachControl(element: HTMLElement): void; + requestVRFullscreen(requestPointerlock: boolean): void; + getClassName(): string; + resetToCurrentRotation(): void; + /** + * + * Set the position offset of the VR camera + * The offset will be added to the WebVR pose, after scaling it (if set). + * + * @param {Vector3} [newPosition] an optional new position. if not provided, the current camera position will be used. + * + * @memberOf WebVRFreeCamera + */ + setPositionOffset(newPosition?: Vector3): void; } } @@ -11472,78 +11531,49 @@ declare module BABYLON { } declare module BABYLON { - class VRCameraMetrics { - hResolution: number; - vResolution: number; - hScreenSize: number; - vScreenSize: number; - vScreenCenter: number; - eyeToScreenDistance: number; - lensSeparationDistance: number; - interpupillaryDistance: number; - distortionK: number[]; - chromaAbCorrection: number[]; - postProcessScaleFactor: number; - lensCenterOffset: number; - compensateDistortion: boolean; - readonly aspectRatio: number; - readonly aspectRatioFov: number; - readonly leftHMatrix: Matrix; - readonly rightHMatrix: Matrix; - readonly leftPreViewMatrix: Matrix; - readonly rightPreViewMatrix: Matrix; - static GetDefault(): VRCameraMetrics; - } -} - -declare module BABYLON { - class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera { - constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics); - getClassName(): string; + interface IOctreeContainer { + blocks: Array>; } - class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera { - constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics); - getClassName(): string; + class Octree { + maxDepth: number; + blocks: Array>; + dynamicContent: T[]; + private _maxBlockCapacity; + private _selectionContent; + private _creationFunc; + constructor(creationFunc: (entry: T, block: OctreeBlock) => void, maxBlockCapacity?: number, maxDepth?: number); + update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void; + addMesh(entry: T): void; + select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray; + intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray; + intersectsRay(ray: Ray): SmartArray; + static _CreateBlocks(worldMin: Vector3, worldMax: Vector3, entries: T[], maxBlockCapacity: number, currentDepth: number, maxDepth: number, target: IOctreeContainer, creationFunc: (entry: T, block: OctreeBlock) => void): void; + static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock) => void; + static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock) => void; } } -declare var HMDVRDevice: any; -declare var VRDisplay: any; -declare var VRFrameData: any; declare module BABYLON { - interface WebVROptions { - trackPosition?: boolean; - positionScale?: number; - displayName?: string; - } - class WebVRFreeCamera extends FreeCamera { - private webVROptions; - _vrDevice: any; - private _cacheState; - private _vrEnabled; - private _attached; - private _oldSize; - private _oldHardwareScaleFactor; - private _frameData; - private _quaternionCache; - private _positionOffset; - constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, webVROptions?: WebVROptions); - _checkInputs(): void; - attachControl(element: HTMLElement, noPreventDefault?: boolean): void; - detachControl(element: HTMLElement): void; - requestVRFullscreen(requestPointerlock: boolean): void; - getClassName(): string; - resetToCurrentRotation(): void; - /** - * - * Set the position offset of the VR camera - * The offset will be added to the WebVR pose, after scaling it (if set). - * - * @param {Vector3} [newPosition] an optional new position. if not provided, the current camera position will be used. - * - * @memberOf WebVRFreeCamera - */ - setPositionOffset(newPosition?: Vector3): void; + class OctreeBlock { + entries: T[]; + blocks: Array>; + private _depth; + private _maxDepth; + private _capacity; + private _minPoint; + private _maxPoint; + private _boundingVectors; + private _creationFunc; + constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock) => void); + readonly capacity: number; + readonly minPoint: Vector3; + readonly maxPoint: Vector3; + addEntry(entry: T): void; + addEntries(entries: T[]): void; + select(frustumPlanes: Plane[], selection: SmartArray, allowDuplicate?: boolean): void; + intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArray, allowDuplicate?: boolean): void; + intersectsRay(ray: Ray, selection: SmartArray): void; + createInnerBlocks(): void; } } diff --git a/dist/preview release/babylon.js b/dist/preview release/babylon.js index 29f3904bd70..4cdd9e1157d 100644 --- a/dist/preview release/babylon.js +++ b/dist/preview release/babylon.js @@ -1,38 +1,38 @@ -var __decorate=this&&this.__decorate||function(e,t,i,r){var n,o=arguments.length,s=o<3?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=(o<3?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-i<=r&&r<=i},e.ToHex=function(e){var t=e.toString(16);return e<=15?("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;rr.x?r.x:n,n=nr.y?r.y:o,o=ot.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=n<0?-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&&s+a<2*n*o},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.Center=function(e,t){var i=e.add(t);return i.scaleInPlace(.5),i},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.xthis.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.Forward=function(){return new i(0,0,1)},i.Right=function(){return new i(1,0,0)},i.Left=function(){return new i((-1),0,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){var r=e.x*t.m[0]+e.y*t.m[4]+e.z*t.m[8],n=e.x*t.m[1]+e.y*t.m[5]+e.z*t.m[9],o=e.x*t.m[2]+e.y*t.m[6]+e.z*t.m[10];i.x=r,i.y=n,i.z=o},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=nr.y?r.y:o,o=or.z?r.z:s,s=sthis.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.copyFromFloats=function(e,t){this.width=e,this.height=t},e.prototype.multiplyByFloats=function(t,i){return new e(this.width*t,this.height*i)},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)},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=this.z,r=this.x,n=this.y,o=this.w,s=o*o,a=i*i,h=r*r,c=n*n,l=n*i-r*o,u=.4999999;return l<-u?(e.y=2*Math.atan2(n,o),e.x=Math.PI/2,e.z=0):l>u?(e.y=2*Math.atan2(n,o),e.x=-Math.PI/2,e.z=0):(e.z=Math.atan2(2*(r*n+i*o),-a-h+c+s),e.x=Math.asin(-2*(i*n-r*o)),e.y=Math.atan2(2*(i*r+n*o),a-h-c+s)),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){return e.RotationAxisToRef(t,i,new e)},e.RotationAxisToRef=function(e,t,i){var r=Math.sin(t/2);return e.normalize(),i.w=Math.cos(t/2),i.x=e.x*r,i.y=e.y*r,i.z=e.z*r,i},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=e.Identity();return e.SlerpToRef(t,i,r,n),n},e.SlerpToRef=function(e,t,i,r){var n,o,s=i,a=e.x*t.x+e.y*t.y+e.z*t.z+e.w*t.w,h=!1;if(a<0&&(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}r.x=o*e.x+n*t.x,r.y=o*e.y+n*t.y,r.z=o*e.z+n*t.z,r.w=o*e.w+n*t.w},e})();e.Quaternion=h;var c=(function(){function i(){this.m=new Float32Array(16)}return i.prototype.isIdentity=function(){return 1===this.m[0]&&1===this.m[5]&&1===this.m[10]&&1===this.m[15]&&(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])},i.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)},i.prototype.toArray=function(){return this.m},i.prototype.asArray=function(){return this.toArray()},i.prototype.invert=function(){return this.invertToRef(this),this},i.prototype.reset=function(){for(var e=0;e<16;e++)this.m[e]=0;return this},i.prototype.add=function(e){var t=new i;return this.addToRef(e,t),t},i.prototype.addToRef=function(e,t){for(var i=0;i<16;i++)t.m[i]=this.m[i]+e.m[i];return this},i.prototype.addToSelf=function(e){for(var t=0;t<16;t++)this.m[t]+=e.m[t];return this},i.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],m=this.m[14],_=this.m[15],g=u*_-f*m,v=l*_-f*p,y=l*m-u*p,x=c*_-f*d,b=c*m-u*d,A=c*p-l*d,T=s*g-a*v+h*y,E=-(o*g-a*x+h*b),P=o*v-s*x+h*A,M=-(o*y-s*b+a*A),S=1/(t*T+i*E+r*P+n*M),C=a*_-h*m,R=s*_-h*p,O=s*m-a*p,I=o*_-h*d,D=o*m-a*d,L=o*p-s*d,w=a*f-h*u,B=s*f-h*l,F=s*u-a*l,V=o*f-h*c,N=o*u-a*c,z=o*l-s*c;return e.m[0]=T*S,e.m[4]=E*S,e.m[8]=P*S,e.m[12]=M*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*A)*S,e.m[13]=(t*y-i*b+r*A)*S,e.m[2]=(i*C-r*R+n*O)*S,e.m[6]=-(t*C-r*I+n*D)*S,e.m[10]=(t*R-i*I+n*L)*S,e.m[14]=-(t*O-i*D+r*L)*S,e.m[3]=-(i*w-r*B+n*F)*S,e.m[7]=(t*w-r*V+n*N)*S,e.m[11]=-(t*B-i*V+n*z)*S,e.m[15]=(t*F-i*N+r*z)*S,this},i.prototype.setTranslation=function(e){return this.m[12]=e.x,this.m[13]=e.y,this.m[14]=e.z,this},i.prototype.getTranslation=function(){return new o(this.m[12],this.m[13],this.m[14])},i.prototype.multiply=function(e){var t=new i;return this.multiplyToRef(e,t),t},i.prototype.copyFrom=function(e){for(var t=0;t<16;t++)this.m[t]=e.m[t];return this},i.prototype.copyToArray=function(e,t){void 0===t&&(t=0);for(var i=0;i<16;i++)e[t+i]=this.m[i];return this},i.prototype.multiplyToRef=function(e,t){return this.multiplyToArray(e,t.m,0),this},i.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],m=this.m[12],_=this.m[13],g=this.m[14],v=this.m[15],y=e.m[0],x=e.m[1],b=e.m[2],A=e.m[3],T=e.m[4],E=e.m[5],P=e.m[6],M=e.m[7],S=e.m[8],C=e.m[9],R=e.m[10],O=e.m[11],I=e.m[12],D=e.m[13],L=e.m[14],w=e.m[15];return t[i]=r*y+n*T+o*S+s*I,t[i+1]=r*x+n*E+o*C+s*D,t[i+2]=r*b+n*P+o*R+s*L,t[i+3]=r*A+n*M+o*O+s*w,t[i+4]=a*y+h*T+c*S+l*I,t[i+5]=a*x+h*E+c*C+l*D,t[i+6]=a*b+h*P+c*R+l*L,t[i+7]=a*A+h*M+c*O+l*w,t[i+8]=u*y+f*T+d*S+p*I,t[i+9]=u*x+f*E+d*C+p*D,t[i+10]=u*b+f*P+d*R+p*L,t[i+11]=u*A+f*M+d*O+p*w,t[i+12]=m*y+_*T+g*S+v*I,t[i+13]=m*x+_*E+g*C+v*D,t[i+14]=m*b+_*P+g*R+v*L,t[i+15]=m*A+_*M+g*O+v*w,this},i.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]},i.prototype.clone=function(){return i.FromValues(this.m[0],this.m[1],this.m[2],this.m[3],this.m[4],this.m[5],this.m[6],this.m[7],this.m[8],this.m[9],this.m[10],this.m[11],this.m[12],this.m[13],this.m[14],this.m[15])},i.prototype.getClassName=function(){return"Matrix"},i.prototype.getHashCode=function(){for(var e=this.m[0]||0,t=1;t<16;t++)e=397*e^(this.m[t]||0);return e},i.prototype.decompose=function(e,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;return e.x=o*Math.sqrt(this.m[0]*this.m[0]+this.m[1]*this.m[1]+this.m[2]*this.m[2]),e.y=s*Math.sqrt(this.m[4]*this.m[4]+this.m[5]*this.m[5]+this.m[6]*this.m[6]),e.z=a*Math.sqrt(this.m[8]*this.m[8]+this.m[9]*this.m[9]+this.m[10]*this.m[10]),0===e.x||0===e.y||0===e.z?(r.x=0,r.y=0,r.z=0,r.w=1,!1):(i.FromValuesToRef(this.m[0]/e.x,this.m[1]/e.x,this.m[2]/e.x,0,this.m[4]/e.y,this.m[5]/e.y,this.m[6]/e.y,0,this.m[8]/e.z,this.m[9]/e.z,this.m[10]/e.z,0,0,0,0,1,M.Matrix[0]),h.FromRotationMatrixToRef(M.Matrix[0],r),!0)},i.prototype.getRotationMatrix=function(){var e=i.Identity();return this.getRotationMatrixToRef(e),e},i.prototype.getRotationMatrixToRef=function(e){var t=this.m,r=t[0]*t[1]*t[2]*t[3]<0?-1:1,n=t[4]*t[5]*t[6]*t[7]<0?-1:1,o=t[8]*t[9]*t[10]*t[11]<0?-1:1,s=r*Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]),a=n*Math.sqrt(t[4]*t[4]+t[5]*t[5]+t[6]*t[6]),h=o*Math.sqrt(t[8]*t[8]+t[9]*t[9]+t[10]*t[10]);i.FromValuesToRef(t[0]/s,t[1]/s,t[2]/s,0,t[4]/a,t[5]/a,t[6]/a,0,t[8]/h,t[9]/h,t[10]/h,0,0,0,0,1,e)},i.FromArray=function(e,t){var r=new i;return t||(t=0),i.FromArrayToRef(e,t,r),r},i.FromArrayToRef=function(e,t,i){for(var r=0;r<16;r++)i.m[r]=e[r+t]},i.FromFloat32ArrayToRefScaled=function(e,t,i,r){for(var n=0;n<16;n++)r.m[n]=e[n+t]*i},i.FromValuesToRef=function(e,t,i,r,n,o,s,a,h,c,l,u,f,d,p,m,_){_.m[0]=e,_.m[1]=t,_.m[2]=i,_.m[3]=r,_.m[4]=n,_.m[5]=o,_.m[6]=s,_.m[7]=a,_.m[8]=h,_.m[9]=c,_.m[10]=l,_.m[11]=u,_.m[12]=f,_.m[13]=d,_.m[14]=p,_.m[15]=m},i.prototype.getRow=function(e){if(e<0||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])},i.prototype.setRow=function(e,t){if(e<0||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},i.FromValues=function(e,t,r,n,o,s,a,h,c,l,u,f,d,p,m,_){var g=new i;return g.m[0]=e,g.m[1]=t,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]=m,g.m[15]=_,g},i.Compose=function(e,t,r){var n=i.FromValues(e.x,0,0,0,0,e.y,0,0,0,0,e.z,0,0,0,0,1),o=i.Identity();return t.toRotationMatrix(o),n=n.multiply(o),n.setTranslation(r),n},i.Identity=function(){return i.FromValues(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1)},i.IdentityToRef=function(e){i.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,e)},i.Zero=function(){return i.FromValues(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)},i.RotationX=function(e){var t=new i;return i.RotationXToRef(e,t),t},i.Invert=function(e){var t=new i;return e.invertToRef(t),t},i.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},i.RotationY=function(e){var t=new i;return i.RotationYToRef(e,t),t},i.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},i.RotationZ=function(e){var t=new i;return i.RotationZToRef(e,t),t},i.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},i.RotationAxis=function(e,t){var r=i.Zero();return i.RotationAxisToRef(e,t,r),r},i.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},i.RotationYawPitchRoll=function(e,t,r){var n=new i;return i.RotationYawPitchRollToRef(e,t,r,n),n},i.RotationYawPitchRollToRef=function(e,t,i,r){h.RotationYawPitchRollToRef(e,t,i,this._tempQuaternion),this._tempQuaternion.toRotationMatrix(r)},i.Scaling=function(e,t,r){var n=i.Zero();return i.ScalingToRef(e,t,r,n),n},i.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},i.Translation=function(e,t,r){var n=i.Identity();return i.TranslationToRef(e,t,r,n),n},i.TranslationToRef=function(e,t,r,n){i.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,e,t,r,1,n)},i.Lerp=function(e,t,r){for(var n=i.Zero(),o=0;o<16;o++)n.m[o]=e.m[o]*(1-r)+t.m[o]*r;return n},i.DecomposeLerp=function(e,t,r){var n=new o(0,0,0),s=new h,a=new o(0,0,0);e.decompose(n,s,a);var c=new o(0,0,0),l=new h,u=new o(0,0,0);t.decompose(c,l,u);var f=o.Lerp(n,c,r),d=h.Slerp(s,l,r),p=o.Lerp(a,u,r);return i.Compose(f,d,p)},i.LookAtLH=function(e,t,r){var n=i.Zero();return i.LookAtLHToRef(e,t,r,n),n},i.LookAtLHToRef=function(e,t,r,n){t.subtractToRef(e,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,e),a=-o.Dot(this._yAxis,e),h=-o.Dot(this._zAxis,e);return i.FromValuesToRef(this._xAxis.x,this._yAxis.x,this._zAxis.x,0,this._xAxis.y,this._yAxis.y,this._zAxis.y,0,this._xAxis.z,this._yAxis.z,this._zAxis.z,0,s,a,h,1,n)},i.LookAtRH=function(e,t,r){var n=i.Zero();return i.LookAtRHToRef(e,t,r,n),n},i.LookAtRHToRef=function(e,t,r,n){e.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,e),a=-o.Dot(this._yAxis,e),h=-o.Dot(this._zAxis,e);return i.FromValuesToRef(this._xAxis.x,this._yAxis.x,this._zAxis.x,0,this._xAxis.y,this._yAxis.y,this._zAxis.y,0,this._xAxis.z,this._yAxis.z,this._zAxis.z,0,s,a,h,1,n)},i.OrthoLH=function(e,t,r,n){var o=i.Zero();return i.OrthoLHToRef(e,t,r,n,o),o},i.OrthoLHToRef=function(t,i,r,n,o){var s=r,a=n,h=2/t,c=2/i,l=2/(a-s),u=-(a+s)/(a-s);e.Matrix.FromValuesToRef(h,0,0,0,0,c,0,0,0,0,l,0,0,0,u,1,o)},i.OrthoOffCenterLH=function(e,t,r,n,o,s){var a=i.Zero();return i.OrthoOffCenterLHToRef(e,t,r,n,o,s,a),a},i.OrthoOffCenterLHToRef=function(t,i,r,n,o,s,a){var h=o,c=s,l=2/(i-t),u=2/(n-r),f=2/(c-h),d=-(c+h)/(c-h),p=(t+i)/(t-i),m=(n+r)/(r-n);e.Matrix.FromValuesToRef(l,0,0,0,0,u,0,0,0,0,f,0,p,m,d,1,a)},i.OrthoOffCenterRH=function(e,t,r,n,o,s){var a=i.Zero();return i.OrthoOffCenterRHToRef(e,t,r,n,o,s,a),a},i.OrthoOffCenterRHToRef=function(e,t,r,n,o,s,a){i.OrthoOffCenterLHToRef(e,t,r,n,o,s,a),a.m[10]*=-1},i.PerspectiveLH=function(t,r,n,o){var s=i.Zero(),a=n,h=o,c=2*a/t,l=2*a/r,u=(h+a)/(h-a),f=-2*h*a/(h-a);return e.Matrix.FromValuesToRef(c,0,0,0,0,l,0,0,0,0,u,1,0,0,f,0,s),s},i.PerspectiveFovLH=function(e,t,r,n){var o=i.Zero();return i.PerspectiveFovLHToRef(e,t,r,n,o),o},i.PerspectiveFovLHToRef=function(t,i,r,n,o,s){void 0===s&&(s=!0);var a=r,h=n,c=1/Math.tan(.5*t),l=s?c/i:c,u=s?c:c*i,f=(h+a)/(h-a),d=-2*h*a/(h-a);e.Matrix.FromValuesToRef(l,0,0,0,0,u,0,0,0,0,f,1,0,0,d,0,o)},i.PerspectiveFovRH=function(e,t,r,n){var o=i.Zero();return i.PerspectiveFovRHToRef(e,t,r,n,o),o},i.PerspectiveFovRHToRef=function(t,i,r,n,o,s){void 0===s&&(s=!0);var a=r,h=n,c=1/Math.tan(.5*t),l=s?c/i:c,u=s?c:c*i,f=-(h+a)/(h-a),d=-2*h*a/(h-a);e.Matrix.FromValuesToRef(l,0,0,0,0,u,0,0,0,0,f,-1,0,0,d,0,o)},i.PerspectiveFovWebVRToRef=function(e,t,i,r,n){void 0===n&&(n=!0);var o=Math.tan(e.upDegrees*Math.PI/180),s=Math.tan(e.downDegrees*Math.PI/180),a=Math.tan(e.leftDegrees*Math.PI/180),h=Math.tan(e.rightDegrees*Math.PI/180),c=2/(a+h),l=2/(o+s);r.m[0]=c,r.m[1]=r.m[2]=r.m[3]=r.m[4]=0,r.m[5]=l,r.m[6]=r.m[7]=0,r.m[8]=(a-h)*c*.5,r.m[9]=-((o-s)*l*.5),r.m[10]=-(t+i)/(i-t),r.m[11]=1,r.m[12]=r.m[13]=r.m[15]=0,r.m[14]=-(2*i*t)/(i-t)},i.GetFinalMatrix=function(e,t,r,n,o,s){var a=e.width,h=e.height,c=e.x,l=e.y,u=i.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 t.multiply(r).multiply(n).multiply(u)},i.GetAsMatrix2x2=function(e){return new Float32Array([e.m[0],e.m[1],e.m[4],e.m[5]])},i.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]])},i.Transpose=function(e){var t=new i;return t.m[0]=e.m[0],t.m[1]=e.m[4],t.m[2]=e.m[8],t.m[3]=e.m[12],t.m[4]=e.m[1],t.m[5]=e.m[5],t.m[6]=e.m[9],t.m[7]=e.m[13],t.m[8]=e.m[2],t.m[9]=e.m[6],t.m[10]=e.m[10],t.m[11]=e.m[14],t.m[12]=e.m[3],t.m[13]=e.m[7],t.m[14]=e.m[11],t.m[15]=e.m[15],t},i.Reflection=function(e){var t=new i;return i.ReflectionToRef(e,t),t},i.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},i.FromXYZAxesToRef=function(e,t,i,r){r.m[0]=e.x,r.m[1]=e.y,r.m[2]=e.z,r.m[3]=0,r.m[4]=t.x,r.m[5]=t.y,r.m[6]=t.z,r.m[7]=0,r.m[8]=i.x,r.m[9]=i.y,r.m[10]=i.z,r.m[11]=0,r.m[12]=0,r.m[13]=0,r.m[14]=0,r.m[15]=1},i.FromQuaternionToRef=function(e,t){var i=e.x*e.x,r=e.y*e.y,n=e.z*e.z,o=e.x*e.y,s=e.z*e.w,a=e.z*e.x,h=e.y*e.w,c=e.y*e.z,l=e.x*e.w;t.m[0]=1-2*(r+n),t.m[1]=2*(o+s),t.m[2]=2*(a-h),t.m[3]=0,t.m[4]=2*(o-s),t.m[5]=1-2*(n+i),t.m[6]=2*(c+l),t.m[7]=0,t.m[8]=2*(a+h),t.m[9]=2*(c-l),t.m[10]=1-2*(r+i),t.m[11]=0,t.m[12]=0,t.m[13]=0,t.m[14]=0,t.m[15]=1},i})();c._tempQuaternion=new h,c._xAxis=o.Zero(),c._yAxis=o.Zero(),c._zAxis=o.Zero(),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 i<=t},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;r<6;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;var d;!(function(e){e[e.LOCAL=0]="LOCAL",e[e.WORLD=1]="WORLD"})(d=e.Space||(e.Space={}));var p=(function(){function e(){}return e})();p.X=new o(1,0,0),p.Y=new o(0,1,0),p.Z=new o(0,0,1),e.Axis=p;var m=(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;c<5;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=m;var _;!(function(e){e[e.CW=0]="CW",e[e.CCW=1]="CCW"})(_=e.Orientation||(e.Orientation={}));var g=(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=g;var v=(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=g.BetweenTwoPoints(this.centerPoint,this.startPoint);var h=this.startAngle.degrees(),c=g.BetweenTwoPoints(this.centerPoint,this.midPoint).degrees(),l=g.BetweenTwoPoints(this.centerPoint,this.endPoint).degrees();c-h>180&&(c-=360),c-h<-180&&(c+=360),l-c>180&&(l-=360),l-c<-180&&(l+=360),this.orientation=c-h<0?_.CW:_.CCW,this.angle=g.FromDegrees(this.orientation===_.CW?h-l:l-h)}return e})();e.Arc2=v;var y=(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 v(s,a,h),l=c.angle.radians()/o;c.orientation===_.CW&&(l*=-1);for(var u=c.startAngle.radians()+l,f=0;f1)return n.Zero();for(var t=e*this.length(),i=0,r=0;r=i&&t<=c){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=y;var x=(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;rt+1;)t++,i=this._curve[e].subtract(this._curve[e-t]);return i},i.prototype._normalVector=function(i,r,n){var s,a=r.length();if(0===a&&(a=1),void 0===n||null===n){var h;t.WithinEpsilon(Math.abs(r.y)/a,1,e.Epsilon)?t.WithinEpsilon(Math.abs(r.x)/a,1,e.Epsilon)?t.WithinEpsilon(Math.abs(r.z)/a,1,e.Epsilon)||(h=new o(0,0,1)):h=new o(1,0,0):h=new o(0,(-1),0),s=o.Cross(r,h)}else s=o.Cross(r,n),o.CrossToRef(s,r,s);return s.normalize(),s},i})();e.Path3D=x;var b=(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;h<=n;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;c<=s;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;c<=s;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;o0},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&&(n.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){e!==-1?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=t.indexOf(".babylon")!==-1?"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=t.indexOf(".babylon")!==-1?"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&&(o.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})();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 e.indexOf("http:/")===-1?t.parseURL(window.location.href)+e:e},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++],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);n>t._ORIGIN_SHIFT){default:case t._ORIGIN_UL:y=0,b=1,E=o.width,x=0,A=1,T=o.height;break;case t._ORIGIN_BL:y=0,b=1,E=o.width,x=o.height-1,A=-1,T=-1;break;case t._ORIGIN_UR:y=o.width-1,b=-1,E=-1,x=0,A=1,T=o.height;break;case t._ORIGIN_BR:y=o.width-1,b=-1,E=-1,x=o.height-1,A=-1,T=-1}var P="_getImageData"+(c?"Grey":"")+o.pixel_size+"bits",M=t[P](o,u,l,x,A,T,y,b,E);i.texImage2D(i.TEXTURE_2D,0,i.RGBA,o.width,o.height,0,i.RGBA,i.UNSIGNED_BYTE,M)},t._getImageData8bits=function(e,t,i,r,n,o,s,a,h){var c,l,u,f=i,d=t,p=e.width,m=e.height,_=0,g=new Uint8Array(p*m*4);for(u=r;u!==o;u+=n)for(l=s;l!==h;l+=a,_++)c=f[_],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,m=0,_=new Uint8Array(d*p*4);for(u=r;u!==o;u+=n)for(l=s;l!==h;l+=a,m+=2)c=f[m+0]+(f[m+1]<<8),_[4*(l+d*u)+0]=(31744&c)>>7,_[4*(l+d*u)+1]=(992&c)>>2,_[4*(l+d*u)+2]=(31&c)>>3,_[4*(l+d*u)+3]=32768&c?0:255;return _},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,m=new Uint8Array(f*d*4);for(l=r;l!==o;l+=n)for(c=s;c!==h;c+=a,p+=3)m[4*(c+f*l)+3]=255,m[4*(c+f*l)+2]=u[p+0],m[4*(c+f*l)+1]=u[p+1],m[4*(c+f*l)+0]=u[p+2];return m},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,m=new Uint8Array(f*d*4);for(l=r;l!==o;l+=n)for(c=s;c!==h;c+=a,p+=4)m[4*(c+f*l)+2]=u[p+0],m[4*(c+f*l)+1]=u[p+1],m[4*(c+f*l)+0]=u[p+2],m[4*(c+f*l)+3]=u[p+3];return m},t._getImageDataGrey8bits=function(e,t,i,r,n,o,s,a,h){var c,l,u,f=i,d=e.width,p=e.height,m=0,_=new Uint8Array(d*p*4);for(u=r;u!==o;u+=n)for(l=s;l!==h;l+=a,m++)c=f[m],_[4*(l+d*u)+0]=c,_[4*(l+d*u)+1]=c,_[4*(l+d*u)+2]=c,_[4*(l+d*u)+3]=255;return _},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,m=new Uint8Array(f*d*4);for(l=r;l!==o;l+=n)for(c=s;c!==h;c+=a,p+=2)m[4*(c+f*l)+0]=u[p+0],m[4*(c+f*l)+1]=u[p+0],m[4*(c+f*l)+2]=u[p+0],m[4*(c+f*l)+3]=u[p+1];return m},t})();i._TYPE_NO_DATA=0,i._TYPE_INDEXED=1,i._TYPE_RGB=2,i._TYPE_GREY=3,i._TYPE_RLE_INDEXED=9,i._TYPE_RLE_RGB=10,i._TYPE_RLE_GREY=11,i._ORIGIN_MASK=48,i._ORIGIN_SHIFT=4,i._ORIGIN_BL=0,i._ORIGIN_BR=1,i._ORIGIN_UL=2,i._ORIGIN_UR=3,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)&&(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;tthis.data.length&&(this.data.length=2*(this.length+e.length));for(var t=0;t=this.length?-1:t},e})();t._GlobalId=0,e.SmartArray=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(){this._count=0,this._data={}}return e.prototype.copyFrom=function(e){var t=this;this.clear(),e.forEach((function(e,i){return t.add(e,i)}))},e.prototype.get=function(e){var t=this._data[e];if(void 0!==t)return t},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]&&(this._data[e]=t,++this._count,!0)},e.prototype.set=function(e,t){return void 0!==this._data[e]&&(this._data[e]=t,!0)},e.prototype.getAndRemove=function(e){var t=this.get(e);return void 0!==t?(delete this._data[e],--this._count,t):null},e.prototype.remove=function(e){return!!this.contains(e)&&(delete this._data[e],--this._count,!0)},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,t){return function(i){i.__bjsclassName__=e,i.__bjsmoduleName__=null!=t?t:null}}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;rt&&(i=t),i},t.GetFilename=function(e){var t=e.lastIndexOf("/");return t<0?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>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;h=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){if(t===!0||void 0!==e&&null!=e)return Array.isArray(e)?e:[e]},t.GetPointerPrefix=function(){var e="pointer";return window.PointerEvent||navigator.pointerEnabled||(e="mouse"),e},t.QueueNewFrame=function(e,t){void 0===t&&(t=window),t.requestAnimationFrame?t.requestAnimationFrame(e):t.msRequestAnimationFrame?t.msRequestAnimationFrame(e):t.webkitRequestAnimationFrame?t.webkitRequestAnimationFrame(e):t.mozRequestAnimationFrame?t.mozRequestAnimationFrame(e):t.oRequestAnimationFrame?t.oRequestAnimationFrame(e):window.setTimeout(e,16)},t.RequestFullscreen=function(e){var t=e.requestFullscreen||e.msRequestFullscreen||e.webkitRequestFullscreen||e.mozRequestFullScreen;t&&t.call(e)},t.ExitFullscreen=function(){document.exitFullscreen?document.exitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitCancelFullScreen?document.webkitCancelFullScreen():document.msCancelFullScreen&&document.msCancelFullScreen()},t.SetCorsBehavior=function(e,i){if(t.CorsBehavior)switch(typeof t.CorsBehavior){case"function":var r=t.CorsBehavior(e);if(r)return r;break;case"string":default:i.crossOrigin=t.CorsBehavior}},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;"data:"!==i.substr(0,5)&&t.SetCorsBehavior(i,s),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 a=function(){s.src=i},h=function(){o.loadImageFromDB(i,s)};if("data:"!==i.substr(0,5)&&o&&o.enableTexturesOffline&&e.Database.IsUASupportingBlobStorage)o.openAsync(h,a);else if(i.indexOf("file:")===-1)a();else try{var c,l=i.substring(5).toLowerCase();try{c=URL.createObjectURL(e.FilesInput.FilesTextures[l],{oneTimeOnly:!0})}catch(u){c=URL.createObjectURL(e.FilesInput.FilesTextures[l])}s.src=c}catch(f){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(e.onreadystatechange=null,e.status>=200&&e.status<300||navigator.isCocoonJS&&0===e.status)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(i.indexOf("file:")!==-1){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.LoadScript=function(e,t,i){var r=document.getElementsByTagName("head")[0],n=document.createElement("script");n.type="text/javascript",n.src=e;n.onload=function(){t&&t()},n.onerror=function(){i&&i()},r.appendChild(n)},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.xi.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&&n.indexOf(o)!==-1)&&(!i||i.indexOf(o)===-1)){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;hh&&(f=h,u=f*l);var d=Math.max(0,a-u)/2,p=Math.max(0,h-f)/2;c.fillStyle=r.getScene().clearColor.toHexString(),c.fillRect(0,0,a,h),c.drawImage(e.getRenderingCanvas(),d,p,u,f),t.EncodeScreenshotCanvasData(o,s)},t.CreateScreenshotUsingRenderTarget=function(i,r,n,o,s){void 0===s&&(s="image/png");var a,h;if(n.precision)a=Math.round(i.getRenderWidth()*n.precision),h=Math.round(a/i.getAspectRatio(r)),n={width:a,height:h};else if(n.width&&n.height)a=n.width,h=n.height;else if(n.width&&!n.height)a=n.width,h=Math.round(a/i.getAspectRatio(r)),n={width:a,height:h};else if(n.height&&!n.width)h=n.height,a=Math.round(h*i.getAspectRatio(r)),n={width:a,height:h};else{if(isNaN(n))return void t.Error("Invalid 'size' parameter !");h=n,a=n}var c=r.getScene(),l=null;c.activeCamera!==r&&(l=c.activeCamera,c.activeCamera=r);var u=new e.RenderTargetTexture("screenShot",n,c,(!1),(!1),e.Engine.TEXTURETYPE_UNSIGNED_INT,(!1),e.Texture.NEAREST_SAMPLINGMODE);u.renderList=c.meshes,u.onAfterRenderObservable.add((function(){t.DumpFramebuffer(a,h,i,o,s)})),c.incrementRenderId(),c.resetCachedMaterial(),u.render(!0),u.dispose(),l&&(c.activeCamera=l),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},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)}))},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 e<10?"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="
"+i+"

";t._AddLogEntry(r)},t._WarnDisabled=function(e){},t._WarnEnabled=function(e){var i=t._FormatMessage(e);console.warn("BJS - "+i);var r="
"+i+"

";t._AddLogEntry(r)},t._ErrorDisabled=function(e){},t._ErrorEnabled=function(e){t.errorsCount++;var i=t._FormatMessage(e);console.error("BJS - "+i);var r="
"+i+"

";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,r=e;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})();n.BaseUrl="",n.CorsBehavior="anonymous",n.UseFallbackTexture=!0,n._NoneLogLevel=0,n._MessageLogLevel=1,n._WarningLogLevel=2,n._ErrorLogLevel=4,n._LogCache="",n.errorsCount=0,n.Log=n._LogEnabled,n.Warn=n._WarnEnabled,n.Error=n._ErrorEnabled,n._PerformanceNoneLogLevel=0,n._PerformanceUserMarkLogLevel=1,n._PerformanceConsoleLogLevel=2,n._performance=window.performance,n.StartPerformanceCounter=n._StartPerformanceCounterDisabled,n.EndPerformanceCounter=n._EndPerformanceCounterDisabled,e.Tools=n;var o=(function(){function e(){this._startMonitoringTime=0,this._min=0,this._max=0,this._average=0,this._lastSecAverage=0,this._current=0,this._totalValueCount=0,this._totalAccumulated=0,this._lastSecAccumulated=0,this._lastSecTime=0,this._lastSecValueCount=0}return Object.defineProperty(e.prototype,"min",{get:function(){return this._min},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"max",{get:function(){return this._max},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"average",{get:function(){return this._average},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"lastSecAverage",{get:function(){return this._lastSecAverage},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"current",{get:function(){return this._current},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"total",{get:function(){return this._totalAccumulated},enumerable:!0,configurable:!0}),e.prototype.fetchNewFrame=function(){this._totalValueCount++,this._current=0,this._lastSecValueCount++},e.prototype.addCount=function(e,t){this._current+=e,t&&this._fetchResult()},e.prototype.beginMonitoring=function(){this._startMonitoringTime=n.Now},e.prototype.endMonitoring=function(e){void 0===e&&(e=!0),e&&this.fetchNewFrame();var t=n.Now;this._current=t-this._startMonitoringTime,e&&this._fetchResult()},e.prototype._fetchResult=function(){this._totalAccumulated+=this._current,this._lastSecAccumulated+=this._current,this._min=Math.min(this._min,this._current),this._max=Math.max(this._max,this._current),this._average=this._totalAccumulated/this._totalValueCount;var e=n.Now;e-this._lastSecTime>1e3&&(this._lastSecAverage=this._lastSecAccumulated/this._lastSecValueCount,this._lastSecTime=e,this._lastSecAccumulated=0,this._lastSecValueCount=0)},e})();e.PerfCounter=o,e.className=t;var s=(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=t)break;if(r(s),o&&o()){e.breakLoop();break}}e.executeNext()}),s)}),n)},e})();e.AsyncLoop=s})(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), -this.reset()}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,this.reset()}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(t){var i=(function(){function t(){this._isStencilTestDirty=!1,this._isStencilMaskDirty=!1,this._isStencilFuncDirty=!1,this._isStencilOpDirty=!1,this.reset()}return Object.defineProperty(t.prototype,"isDirty",{get:function(){return this._isStencilTestDirty||this._isStencilMaskDirty||this._isStencilFuncDirty||this._isStencilOpDirty},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stencilFunc",{get:function(){return this._stencilFunc},set:function(e){this._stencilFunc!==e&&(this._stencilFunc=e,this._isStencilFuncDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stencilFuncRef",{get:function(){return this._stencilFuncRef},set:function(e){this._stencilFuncRef!==e&&(this._stencilFuncRef=e,this._isStencilFuncDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stencilFuncMask",{get:function(){return this._stencilFuncMask},set:function(e){this._stencilFuncMask!==e&&(this._stencilFuncMask=e,this._isStencilFuncDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stencilOpStencilFail",{get:function(){return this._stencilOpStencilFail},set:function(e){this._stencilOpStencilFail!==e&&(this._stencilOpStencilFail=e,this._isStencilOpDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stencilOpDepthFail",{get:function(){return this._stencilOpDepthFail},set:function(e){this._stencilOpDepthFail!==e&&(this._stencilOpDepthFail=e,this._isStencilOpDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stencilOpStencilDepthPass",{get:function(){return this._stencilOpStencilDepthPass},set:function(e){this._stencilOpStencilDepthPass!==e&&(this._stencilOpStencilDepthPass=e,this._isStencilOpDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stencilMask",{get:function(){return this._stencilMask},set:function(e){this._stencilMask!==e&&(this._stencilMask=e,this._isStencilMaskDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stencilTest",{get:function(){return this._stencilTest},set:function(e){this._stencilTest!==e&&(this._stencilTest=e,this._isStencilTestDirty=!0)},enumerable:!0,configurable:!0}),t.prototype.reset=function(){this._stencilTest=!1,this._stencilMask=255,this._stencilFunc=e.Engine.ALWAYS,this._stencilFuncRef=1,this._stencilFuncMask=255,this._stencilOpStencilFail=e.Engine.KEEP,this._stencilOpDepthFail=e.Engine.KEEP,this._stencilOpStencilDepthPass=e.Engine.REPLACE,this._isStencilTestDirty=!0,this._isStencilMaskDirty=!0,this._isStencilFuncDirty=!0,this._isStencilOpDirty=!0},t.prototype.apply=function(e){this.isDirty&&(this._isStencilTestDirty&&(this.stencilTest?e.enable(e.STENCIL_TEST):e.disable(e.STENCIL_TEST),this._isStencilTestDirty=!1),this._isStencilMaskDirty&&(e.stencilMask(this.stencilMask),this._isStencilMaskDirty=!1),this._isStencilFuncDirty&&(e.stencilFunc(this.stencilFunc,this.stencilFuncRef,this.stencilFuncMask),this._isStencilFuncDirty=!1),this._isStencilOpDirty&&(e.stencilOp(this.stencilOpStencilFail,this.stencilOpDepthFail,this.stencilOpStencilDepthPass),this._isStencilOpDirty=!1))},t})();t._StencilState=i})(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=36193,r=function(e,t){return t===l.TEXTURETYPE_FLOAT?e.FLOAT:t===l.TEXTURETYPE_HALF_FLOAT?i:e.UNSIGNED_BYTE},n=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}},o=function(t,i,r,o,s,a,h,c,l,u){void 0===u&&(u=e.Texture.TRILINEAR_SAMPLINGMODE);var f=r.getEngine(),d=e.Tools.GetExponentOfTwo(o,f.getCaps().maxTextureSize),p=e.Tools.GetExponentOfTwo(s,f.getCaps().maxTextureSize);f._bindTextureDirectly(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=d,t._height=p,t.isReady=!0,l(d,p);var m=n(u,!h,i);i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,m.mag),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,m.min),h||c||i.generateMipmap(i.TEXTURE_2D),f._bindTextureDirectly(i.TEXTURE_2D,null),f.resetTextureCache(),r._removePendingData(t),t.onLoadedCallbacks.forEach((function(e){e()})),t.onLoadedCallbacks=[]},s=function(t,i,r,n,o,s){void 0===s&&(s=null);var a,h=function(){r[i]=a,r._internalCount++,n._removePendingData(a),6===r._internalCount&&o(r)},c=function(){n._removePendingData(a),s&&s()};a=e.Tools.LoadImage(t,h,c,n.database),n._addPendingData(a)},a=function(e,t,i,r,n){void 0===n&&(n=null);var o=[];o._internalCount=0;for(var a=0;a<6;a++)s(r[a],a,o,t,i,n)},h=(function(){function e(){}return e})();e.InstancingAttributeInfo=h;var c=(function(){function e(){}return e})();e.EngineCapabilities=c;var l=(function(){function s(t,i,r,n){void 0===n&&(n=!1);var o=this;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._badOS=!1,this._drawCalls=new e.PerfCounter,this._renderingQueueLaunched=!1,this._activeRenderLoops=[],this.fpsRange=60,this.previousFramesDuration=[],this.fps=60,this.deltaTime=0,this._depthCullingState=new e.Internals._DepthCullingState,this._stencilState=new e.Internals._StencilState,this._alphaState=new e.Internals._AlphaState,this._alphaMode=s.ALPHA_DISABLE,this._loadedTexturesCache=new Array,this._maxTextureChannels=16,this._activeTexturesCache=new Array(this._maxTextureChannels),this._compiledEffects={},this._vertexAttribArraysEnabled=[],this._uintIndicesCurrentlySet=!1,this._currentBoundBuffer=new Array,this._currentBufferPointers=[],this._currentInstanceLocations=new Array,this._currentInstanceBuffers=new Array,this._texturesSupported=new Array,this._onVRFullScreenTriggered=function(){if(o._vrDisplayEnabled&&o._vrDisplayEnabled.isPresenting){o._oldSize=new e.Size(o.getRenderWidth(),o.getRenderHeight()),o._oldHardwareScaleFactor=o.getHardwareScalingLevel();var t=o._vrDisplayEnabled.getEyeParameters("left");o.setHardwareScalingLevel(1),o.setSize(2*t.renderWidth,t.renderHeight)}else o.setHardwareScalingLevel(o._oldHardwareScaleFactor),o.setSize(o._oldSize.width,o._oldSize.height),o._vrDisplayEnabled=void 0},this._renderingCanvas=t,this._externalData=new e.StringDictionary,r=r||{},null!=i&&(r.antialias=i),void 0===r.preserveDrawingBuffer&&(r.preserveDrawingBuffer=!1);var a=this._canRenderToFloatTexture(),h=this._canRenderToHalfFloatTexture();try{this._gl=t.getContext("webgl2",r)||t.getContext("experimental-webgl2",r),this._gl&&(this._webGLVersion="2.0")}catch(l){}if(!this._gl){if(!t)throw new Error("The provided canvas is null or undefined.");try{this._gl=t.getContext("webgl",r)||t.getContext("experimental-webgl",r)}catch(l){throw new Error("WebGL not supported")}}if(!this._gl)throw new Error("WebGL not supported");this._onBlur=function(){o._windowIsBackground=!0},this._onFocus=function(){o._windowIsBackground=!1},window.addEventListener("blur",this._onBlur),window.addEventListener("focus",this._onFocus);var u=r.limitDeviceRatio||window.devicePixelRatio||1;this._hardwareScalingLevel=n?1/Math.min(u,window.devicePixelRatio||1):1,this.resize(),this._isStencilEnable=r.stencil,this._caps=new c,this._caps.maxTexturesImageUnits=this._gl.getParameter(this._gl.MAX_TEXTURE_IMAGE_UNITS),this._caps.maxTextureSize=this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE),this._caps.maxCubemapTextureSize=this._gl.getParameter(this._gl.MAX_CUBE_MAP_TEXTURE_SIZE),this._caps.maxRenderTextureSize=this._gl.getParameter(this._gl.MAX_RENDERBUFFER_SIZE),this._caps.maxVertexAttribs=this._gl.getParameter(this._gl.MAX_VERTEX_ATTRIBS),this._caps.maxVaryingVectors=this._gl.getParameter(this._gl.MAX_VARYING_VECTORS),this._caps.maxFragmentUniformVectors=this._gl.getParameter(this._gl.MAX_FRAGMENT_UNIFORM_VECTORS),this._caps.maxVertexUniformVectors=this._gl.getParameter(this._gl.MAX_VERTEX_UNIFORM_VECTORS),this._glVersion=this._gl.getParameter(this._gl.VERSION);var f=this._gl.getExtension("WEBGL_debug_renderer_info");if(null!=f&&(this._glRenderer=this._gl.getParameter(f.UNMASKED_RENDERER_WEBGL),this._glVendor=this._gl.getParameter(f.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.astc=this._gl.getExtension("WEBGL_compressed_texture_astc"),this._caps.s3tc=this._gl.getExtension("WEBGL_compressed_texture_s3tc"),this._caps.pvrtc=this._gl.getExtension("WEBGL_compressed_texture_pvrtc")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),this._caps.etc1=this._gl.getExtension("WEBGL_compressed_texture_etc1"),this._caps.etc2=this._gl.getExtension("WEBGL_compressed_texture_etc")||this._gl.getExtension("WEBGL_compressed_texture_es3_0"),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._caps.textureFloatRender=a,this._caps.textureHalfFloat=null!==this._gl.getExtension("OES_texture_half_float"),this._caps.textureHalfFloatLinearFiltering=this._gl.getExtension("OES_texture_half_float_linear"),this._caps.textureHalfFloatRender=h,this._caps.astc&&this.texturesSupported.push(".astc"),this._caps.s3tc&&this.texturesSupported.push(".dds"),this._caps.pvrtc&&this.texturesSupported.push(".pvr"),this._caps.etc2&&this.texturesSupported.push(".etc2"),this._caps.etc1&&this.texturesSupported.push(".etc1"),this._gl.getShaderPrecisionFormat){var d=this._gl.getShaderPrecisionFormat(this._gl.FRAGMENT_SHADER,this._gl.HIGH_FLOAT);this._caps.highPrecisionShaderSupported=0!==d.precision}this.setDepthBuffer(!0),this.setDepthFunctionToLessOrEqual(),this.setDepthWrite(!0),this._onFullscreenChange=function(){void 0!==document.fullscreen?o.isFullscreen=document.fullscreen:void 0!==document.mozFullScreen?o.isFullscreen=document.mozFullScreen:void 0!==document.webkitIsFullScreen?o.isFullscreen=document.webkitIsFullScreen:void 0!==document.msIsFullScreen&&(o.isFullscreen=document.msIsFullScreen),o.isFullscreen&&o._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(){o.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&&!s.audioEngine&&(s.audioEngine=new e.AudioEngine),this._loadingScreen=new e.DefaultLoadingScreen(this._renderingCanvas),r.autoEnableWebVR&&this.initWebVR();var p=/AppleWebKit.*10.[\d] Mobile/;this._badOS=p.test(navigator.userAgent),e.Tools.Log("Babylon.js engine (v"+s.Version+") launched")}return Object.defineProperty(s,"NEVER",{get:function(){return s._NEVER},enumerable:!0,configurable:!0}),Object.defineProperty(s,"ALWAYS",{get:function(){return s._ALWAYS},enumerable:!0,configurable:!0}),Object.defineProperty(s,"LESS",{get:function(){return s._LESS},enumerable:!0,configurable:!0}),Object.defineProperty(s,"EQUAL",{get:function(){return s._EQUAL},enumerable:!0,configurable:!0}),Object.defineProperty(s,"LEQUAL",{get:function(){return s._LEQUAL},enumerable:!0,configurable:!0}),Object.defineProperty(s,"GREATER",{get:function(){return s._GREATER},enumerable:!0,configurable:!0}),Object.defineProperty(s,"GEQUAL",{get:function(){return s._GEQUAL},enumerable:!0,configurable:!0}),Object.defineProperty(s,"NOTEQUAL",{get:function(){return s._NOTEQUAL},enumerable:!0,configurable:!0}),Object.defineProperty(s,"KEEP",{get:function(){return s._KEEP},enumerable:!0,configurable:!0}),Object.defineProperty(s,"REPLACE",{get:function(){return s._REPLACE},enumerable:!0,configurable:!0}),Object.defineProperty(s,"INCR",{get:function(){return s._INCR},enumerable:!0,configurable:!0}),Object.defineProperty(s,"DECR",{get:function(){return s._DECR},enumerable:!0,configurable:!0}),Object.defineProperty(s,"INVERT",{get:function(){return s._INVERT},enumerable:!0,configurable:!0}),Object.defineProperty(s,"INCR_WRAP",{get:function(){return s._INCR_WRAP},enumerable:!0,configurable:!0}),Object.defineProperty(s,"DECR_WRAP",{get:function(){return s._DECR_WRAP},enumerable:!0,configurable:!0}),Object.defineProperty(s,"ALPHA_DISABLE",{get:function(){return s._ALPHA_DISABLE},enumerable:!0,configurable:!0}),Object.defineProperty(s,"ALPHA_ONEONE",{get:function(){return s._ALPHA_ONEONE},enumerable:!0,configurable:!0}),Object.defineProperty(s,"ALPHA_ADD",{get:function(){return s._ALPHA_ADD},enumerable:!0,configurable:!0}),Object.defineProperty(s,"ALPHA_COMBINE",{get:function(){return s._ALPHA_COMBINE},enumerable:!0,configurable:!0}),Object.defineProperty(s,"ALPHA_SUBTRACT",{get:function(){return s._ALPHA_SUBTRACT},enumerable:!0,configurable:!0}),Object.defineProperty(s,"ALPHA_MULTIPLY",{get:function(){return s._ALPHA_MULTIPLY},enumerable:!0,configurable:!0}),Object.defineProperty(s,"ALPHA_MAXIMIZED",{get:function(){return s._ALPHA_MAXIMIZED},enumerable:!0,configurable:!0}),Object.defineProperty(s,"ALPHA_PREMULTIPLIED",{get:function(){return s._ALPHA_PREMULTIPLIED},enumerable:!0,configurable:!0}),Object.defineProperty(s,"DELAYLOADSTATE_NONE",{get:function(){return s._DELAYLOADSTATE_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(s,"DELAYLOADSTATE_LOADED",{get:function(){return s._DELAYLOADSTATE_LOADED},enumerable:!0,configurable:!0}),Object.defineProperty(s,"DELAYLOADSTATE_LOADING",{get:function(){return s._DELAYLOADSTATE_LOADING},enumerable:!0,configurable:!0}),Object.defineProperty(s,"DELAYLOADSTATE_NOTLOADED",{get:function(){return s._DELAYLOADSTATE_NOTLOADED},enumerable:!0,configurable:!0}),Object.defineProperty(s,"TEXTUREFORMAT_ALPHA",{get:function(){return s._TEXTUREFORMAT_ALPHA},enumerable:!0,configurable:!0}),Object.defineProperty(s,"TEXTUREFORMAT_LUMINANCE",{get:function(){return s._TEXTUREFORMAT_LUMINANCE},enumerable:!0,configurable:!0}),Object.defineProperty(s,"TEXTUREFORMAT_LUMINANCE_ALPHA",{get:function(){return s._TEXTUREFORMAT_LUMINANCE_ALPHA},enumerable:!0,configurable:!0}),Object.defineProperty(s,"TEXTUREFORMAT_RGB",{get:function(){return s._TEXTUREFORMAT_RGB},enumerable:!0,configurable:!0}),Object.defineProperty(s,"TEXTUREFORMAT_RGBA",{get:function(){return s._TEXTUREFORMAT_RGBA},enumerable:!0,configurable:!0}),Object.defineProperty(s,"TEXTURETYPE_UNSIGNED_INT",{get:function(){return s._TEXTURETYPE_UNSIGNED_INT},enumerable:!0,configurable:!0}),Object.defineProperty(s,"TEXTURETYPE_FLOAT",{get:function(){return s._TEXTURETYPE_FLOAT},enumerable:!0,configurable:!0}),Object.defineProperty(s,"TEXTURETYPE_HALF_FLOAT",{get:function(){return s._TEXTURETYPE_HALF_FLOAT},enumerable:!0,configurable:!0}),Object.defineProperty(s,"Version",{get:function(){return"2.6-alpha"},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"texturesSupported",{get:function(){return this._texturesSupported},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"textureFormatInUse",{get:function(){return this._textureFormatInUse},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"webGLVersion",{get:function(){return this._webGLVersion},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"isStencilEnable",{get:function(){return this._isStencilEnable},enumerable:!0,configurable:!0}),s.prototype._prepareWorkingCanvas=function(){this._workingCanvas||(this._workingCanvas=document.createElement("canvas"),this._workingContext=this._workingCanvas.getContext("2d"))},s.prototype.resetTextureCache=function(){for(var e=0;e=0&&this._activeRenderLoops.splice(t,1)},s.prototype._renderLoop=function(){var t=!0;if(!this.renderEvenInBackground&&this._windowIsBackground&&(t=!1),t){this.beginFrame();for(var i=0;i0?e.Tools.QueueNewFrame(this._bindedRenderFunction,this._vrDisplayEnabled):this._renderingQueueLaunched=!1},s.prototype.runRenderLoop=function(t){this._activeRenderLoops.indexOf(t)===-1&&(this._activeRenderLoops.push(t),this._renderingQueueLaunched||(this._renderingQueueLaunched=!0,this._bindedRenderFunction=this._renderLoop.bind(this),e.Tools.QueueNewFrame(this._bindedRenderFunction)))},s.prototype.switchFullscreen=function(t){this.isFullscreen?e.Tools.ExitFullscreen():(this._pointerLockRequested=t,e.Tools.RequestFullscreen(this._renderingCanvas))},s.prototype.clear=function(e,t,i,r){void 0===r&&(r=!1),this.applyStates();var n=0;t&&e&&(this._gl.clearColor(e.r,e.g,e.b,e.a),n|=this._gl.COLOR_BUFFER_BIT),i&&(this._gl.clearDepth(1),n|=this._gl.DEPTH_BUFFER_BIT),r&&(this._gl.clearStencil(0),n|=this._gl.STENCIL_BUFFER_BIT),this._gl.clear(n)},s.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,!0),o.scissor(a[0],a[1],a[2],a[3]),s===!0?o.enable(o.SCISSOR_TEST):o.disable(o.SCISSOR_TEST)},s.prototype.setViewport=function(e,t,i){var r=t||(navigator.isCocoonJS?window.innerWidth:this.getRenderWidth()),n=i||(navigator.isCocoonJS?window.innerHeight:this.getRenderHeight()),o=e.x||0,s=e.y||0;this._cachedViewport=e,this._gl.viewport(o*r,s*n,r*e.width,n*e.height)},s.prototype.setDirectViewport=function(e,t,i,r){var n=this._cachedViewport;return this._cachedViewport=null,this._gl.viewport(e,t,i,r),n},s.prototype.beginFrame=function(){this._measureFps()},s.prototype.endFrame=function(){this._badOS&&this.flushFramebuffer(),this._vrDisplayEnabled&&this._vrDisplayEnabled.isPresenting&&this._vrDisplayEnabled.submitFrame()},s.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)},s.prototype.setSize=function(e,t){this._renderingCanvas.width=e,this._renderingCanvas.height=t;for(var i=0;i65535){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},s.prototype.bindArrayBuffer=function(e){this.bindBuffer(e,this._gl.ARRAY_BUFFER)},s.prototype.bindIndexBuffer=function(e){this.bindBuffer(e,this._gl.ELEMENT_ARRAY_BUFFER)},s.prototype.bindBuffer=function(e,t){this._currentBoundBuffer[t]!==e&&(this._gl.bindBuffer(t,e),this._currentBoundBuffer[t]=e)},s.prototype.updateArrayBuffer=function(e){this._gl.bufferSubData(this._gl.ARRAY_BUFFER,0,e)},s.prototype.vertexAttribPointer=function(e,t,i,r,n,o,s){var a=this._currentBufferPointers[t],h=!1;a?(a.buffer!==e&&(a.buffer=e,h=!0),a.size!==i&&(a.size=i,h=!0),a.type!==r&&(a.type=r,h=!0),a.normalized!==n&&(a.normalized=n,h=!0),a.stride!==o&&(a.stride=o,h=!0),a.offset!==s&&(a.offset=s, -h=!0)):(h=!0,this._currentBufferPointers[t]={indx:t,size:i,type:r,normalized:n,stride:o,offset:s,buffer:e}),h&&(this.bindArrayBuffer(e),this._gl.vertexAttribPointer(t,i,r,n,o,s))},s.prototype.bindBuffersDirectly=function(e,t,i,r,n){if(this._cachedVertexBuffers!==e||this._cachedEffectForVertexBuffers!==n){this._cachedVertexBuffers=e,this._cachedEffectForVertexBuffers=n;var o=n.getAttributesCount();this.unbindAllAttributes();for(var s=0,a=0;a=0&&(this._gl.enableVertexAttribArray(h),this._vertexAttribArraysEnabled[h]=!0,this.vertexAttribPointer(e,h,i[a],this._gl.FLOAT,!1,r,s)),s+=4*i[a]}}this._cachedIndexBuffer!==t&&(this._cachedIndexBuffer=t,this.bindIndexBuffer(t),this._uintIndicesCurrentlySet=t.is32Bits)},s.prototype.bindBuffers=function(e,t,i){if(this._cachedVertexBuffers!==e||this._cachedEffectForVertexBuffers!==i){this._cachedVertexBuffers=e,this._cachedEffectForVertexBuffers=i;var r=i.getAttributesNames();this.unbindAllAttributes();for(var n=0;n=0){var s=e[r[n]];if(!s)continue;this._gl.enableVertexAttribArray(o),this._vertexAttribArraysEnabled[o]=!0;var a=s.getBuffer();this.vertexAttribPointer(a,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.bindIndexBuffer(t),this._uintIndicesCurrentlySet=t.is32Bits)},s.prototype.unbindInstanceAttributes=function(){for(var e,t=0,i=this._currentInstanceLocations.length;t1)&&!i&&a.width>>a.mipmapCount-1===1;o(f,l._gl,n,a.width,a.height,r,!h,a.isFourCC,(function(){e.Internals.DDSTools.UploadDDSLevels(l._gl,l.getCaps().s3tc,t,a,h,1)}),s)},d instanceof Array?v(c):e.Tools.LoadFile(t,(function(e){v(e)}),null,n.database,!0,y);else{var x=function(t){o(f,l._gl,n,t.width,t.height,r,i,!1,(function(i,r){var n=t.width===i&&t.height===r;n||(l._prepareWorkingCanvas(),l._workingCanvas.width=i,l._workingCanvas.height=r,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)}),s)};d instanceof Array?e.Tools.LoadImage(c,x,y,n.database):e.Tools.LoadImage(t,x,y,n.database)}return f},s.prototype._getInternalFormat=function(e){var t=this._gl.RGBA;switch(e){case s.TEXTUREFORMAT_ALPHA:t=this._gl.ALPHA;break;case s.TEXTUREFORMAT_LUMINANCE:t=this._gl.LUMINANCE;break;case s.TEXTUREFORMAT_LUMINANCE_ALPHA:t=this._gl.LUMINANCE_ALPHA;break;case s.TEXTUREFORMAT_RGB:t=this._gl.RGB;break;case s.TEXTUREFORMAT_RGBA:t=this._gl.RGBA}return t},s.prototype.updateRawTexture=function(e,t,i,r,n){void 0===n&&(n=null);var o=this._getInternalFormat(i);this._bindTextureDirectly(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._bindTextureDirectly(this._gl.TEXTURE_2D,null),this.resetTextureCache(),e.isReady=!0},s.prototype.createRawTexture=function(e,t,i,r,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,r,s,h),this._bindTextureDirectly(this._gl.TEXTURE_2D,c);var l=n(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),o&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(this._gl.TEXTURE_2D,null),c.samplingMode=a,this._loadedTexturesCache.push(c),c},s.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},s.prototype.updateTextureSamplingMode=function(e,t){var i=n(e,t.generateMipMaps,this._gl);t.isCube?(this._bindTextureDirectly(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._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null)):(this._bindTextureDirectly(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._bindTextureDirectly(this._gl.TEXTURE_2D,null))},s.prototype.updateDynamicTexture=function(e,t,i,r){void 0===r&&(r=!1),this._bindTextureDirectly(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._bindTextureDirectly(this._gl.TEXTURE_2D,null),r&&this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),this.resetTextureCache(),e.isReady=!0},s.prototype.updateVideoTexture=function(e,t,i){if(!e._isDisabled){this._bindTextureDirectly(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._bindTextureDirectly(this._gl.TEXTURE_2D,null),this.resetTextureCache(),e.isReady=!0}catch(r){e._isDisabled=!0}}},s.prototype.createRenderTargetTexture=function(t,i){var o=!1,a=!0,h=!1,c=s.TEXTURETYPE_UNSIGNED_INT,l=e.Texture.TRILINEAR_SAMPLINGMODE;void 0!==i&&(o=void 0===i.generateMipMaps?i:i.generateMipMaps,a=void 0===i.generateDepthBuffer||i.generateDepthBuffer,h=a&&i.generateStencilBuffer,c=void 0===i.type?c:i.type,void 0!==i.samplingMode&&(l=i.samplingMode),c!==s.TEXTURETYPE_FLOAT||this._caps.textureFloatLinearFiltering?c!==s.TEXTURETYPE_HALF_FLOAT||this._caps.textureHalfFloatLinearFiltering||(l=e.Texture.NEAREST_SAMPLINGMODE):l=e.Texture.NEAREST_SAMPLINGMODE);var u=this._gl,f=u.createTexture();this._bindTextureDirectly(u.TEXTURE_2D,f);var d=t.width||t,p=t.height||t,m=n(l,o,u);c!==s.TEXTURETYPE_FLOAT||this._caps.textureFloat||(c=s.TEXTURETYPE_UNSIGNED_INT,e.Tools.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type")),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_MAG_FILTER,m.mag),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_MIN_FILTER,m.min),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_WRAP_S,u.CLAMP_TO_EDGE),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_WRAP_T,u.CLAMP_TO_EDGE),u.texImage2D(u.TEXTURE_2D,0,u.RGBA,d,p,0,u.RGBA,r(u,c),null);var _;h?(_=u.createRenderbuffer(),u.bindRenderbuffer(u.RENDERBUFFER,_),u.renderbufferStorage(u.RENDERBUFFER,u.DEPTH_STENCIL,d,p)):a&&(_=u.createRenderbuffer(),u.bindRenderbuffer(u.RENDERBUFFER,_),u.renderbufferStorage(u.RENDERBUFFER,u.DEPTH_COMPONENT16,d,p));var g=u.createFramebuffer();return this.bindUnboundFramebuffer(g),h?u.framebufferRenderbuffer(u.FRAMEBUFFER,u.DEPTH_STENCIL_ATTACHMENT,u.RENDERBUFFER,_):a&&u.framebufferRenderbuffer(u.FRAMEBUFFER,u.DEPTH_ATTACHMENT,u.RENDERBUFFER,_),u.framebufferTexture2D(u.FRAMEBUFFER,u.COLOR_ATTACHMENT0,u.TEXTURE_2D,f,0),o&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(u.TEXTURE_2D,null),u.bindRenderbuffer(u.RENDERBUFFER,null),this.bindUnboundFramebuffer(null),f._framebuffer=g,a&&(f._depthBuffer=_),f._baseWidth=d,f._baseHeight=p,f._width=d,f._height=p,f.isReady=!0,f.generateMipMaps=o,f.references=1,f.samplingMode=l,f.type=c,this.resetTextureCache(),this._loadedTexturesCache.push(f),f},s.prototype.createRenderTargetCubeTexture=function(t,i){var r=this._gl,o=r.createTexture(),s=!0,a=!0,h=!1,c=e.Texture.TRILINEAR_SAMPLINGMODE;void 0!==i&&(s=void 0===i.generateMipMaps?i:i.generateMipMaps,a=void 0===i.generateDepthBuffer||i.generateDepthBuffer,h=a&&i.generateStencilBuffer,void 0!==i.samplingMode&&(c=i.samplingMode)),o.isCube=!0,o.references=1,o.generateMipMaps=s,o.references=1,o.samplingMode=c;var l=n(c,s,r);this._bindTextureDirectly(r.TEXTURE_CUBE_MAP,o);for(var u=0;u<6;u++)r.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+u,0,r.RGBA,t,t,0,r.RGBA,r.UNSIGNED_BYTE,null);r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_MAG_FILTER,l.mag),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_MIN_FILTER,l.min),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE);var f;h?(f=r.createRenderbuffer(),r.bindRenderbuffer(r.RENDERBUFFER,f),r.renderbufferStorage(r.RENDERBUFFER,r.DEPTH_STENCIL,t,t)):a&&(f=r.createRenderbuffer(),r.bindRenderbuffer(r.RENDERBUFFER,f),r.renderbufferStorage(r.RENDERBUFFER,r.DEPTH_COMPONENT16,t,t));var d=r.createFramebuffer();return this.bindUnboundFramebuffer(d),h?r.framebufferRenderbuffer(r.FRAMEBUFFER,r.DEPTH_STENCIL_ATTACHMENT,r.RENDERBUFFER,f):a&&r.framebufferRenderbuffer(r.FRAMEBUFFER,r.DEPTH_ATTACHMENT,r.RENDERBUFFER,f),o.generateMipMaps&&(this._bindTextureDirectly(r.TEXTURE_CUBE_MAP,o),r.generateMipmap(r.TEXTURE_CUBE_MAP)),this._bindTextureDirectly(r.TEXTURE_CUBE_MAP,null),r.bindRenderbuffer(r.RENDERBUFFER,null),this.bindUnboundFramebuffer(null),o._framebuffer=d,a&&(o._depthBuffer=f),o._width=t,o._height=t,o.isReady=!0,this.resetTextureCache(),this._loadedTexturesCache.push(o),o},s.prototype.createCubeTexture=function(t,i,r,n,o,s){var h=this;void 0===o&&(o=null),void 0===s&&(s=null);var c=this._gl,l=c.createTexture();l.isCube=!0,l.url=t,l.references=1,l.onLoadedCallbacks=[];var u=t.substr(t.length-4,4).toLowerCase(),f=this.getCaps().s3tc&&".dds"===u;return f?e.Tools.LoadFile(t,(function(t){var i=e.Internals.DDSTools.GetDDSInfo(t),r=(i.isRGB||i.isLuminance||i.mipmapCount>1)&&!n;h._bindTextureDirectly(c.TEXTURE_CUBE_MAP,l),c.pixelStorei(c.UNPACK_FLIP_Y_WEBGL,1),e.Internals.DDSTools.UploadDDSLevels(h._gl,h.getCaps().s3tc,t,i,r,6),n||i.isFourCC||1!==i.mipmapCount||c.generateMipmap(c.TEXTURE_CUBE_MAP),c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MAG_FILTER,c.LINEAR),c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MIN_FILTER,r?c.LINEAR_MIPMAP_LINEAR:c.LINEAR),c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE),c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE),h._bindTextureDirectly(c.TEXTURE_CUBE_MAP,null),h.resetTextureCache(),l._width=i.width,l._height=i.height,l.isReady=!0}),null,null,!0,s):a(t,i,(function(t){var i=e.Tools.GetExponentOfTwo(t[0].width,h._caps.maxCubemapTextureSize),r=i;h._prepareWorkingCanvas(),h._workingCanvas.width=i,h._workingCanvas.height=r;var s=[c.TEXTURE_CUBE_MAP_POSITIVE_X,c.TEXTURE_CUBE_MAP_POSITIVE_Y,c.TEXTURE_CUBE_MAP_POSITIVE_Z,c.TEXTURE_CUBE_MAP_NEGATIVE_X,c.TEXTURE_CUBE_MAP_NEGATIVE_Y,c.TEXTURE_CUBE_MAP_NEGATIVE_Z];h._bindTextureDirectly(c.TEXTURE_CUBE_MAP,l),c.pixelStorei(c.UNPACK_FLIP_Y_WEBGL,0);for(var a=0;a>y;f.texImage2D(o[0],y,p,x,x,0,p,m,a[y][0]),f.texImage2D(o[1],y,p,x,x,0,p,m,a[y][2]),f.texImage2D(o[2],y,p,x,x,0,p,m,a[y][4]),f.texImage2D(o[3],y,p,x,x,0,p,m,a[y][1]),f.texImage2D(o[4],y,p,x,x,0,p,m,a[y][3]),f.texImage2D(o[5],y,p,x,x,0,p,m,a[y][5])}}else{for(var b=0;b-1&&t.splice(i,1),this._releaseTexture(e)}},s.prototype.unbindAllAttributes=function(){for(var e=0,t=this._vertexAttribArraysEnabled.length;e=this._caps.maxVertexAttribs||!this._vertexAttribArraysEnabled[e]||this._vertexAttribArraysEnabled[e]&&(this._gl.disableVertexAttribArray(e),this._vertexAttribArraysEnabled[e]=!1)},s.prototype.dispose=function(){for(this.hideLoadingUI(),this.stopRenderLoop();this.scenes.length;)this.scenes[0].dispose();s.audioEngine.dispose();for(var e in this._compiledEffects)this._gl.deleteProgram(this._compiledEffects[e]._program);this.unbindAllAttributes(),this._gl=null,this.disableVR(),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)},s.prototype.displayLoadingUI=function(){this._loadingScreen.displayLoadingUI()},s.prototype.hideLoadingUI=function(){this._loadingScreen.hideLoadingUI()},Object.defineProperty(s.prototype,"loadingScreen",{get:function(){return this._loadingScreen},set:function(e){this._loadingScreen=e},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"loadingUIText",{set:function(e){this._loadingScreen.loadingUIText=e},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"loadingUIBackgroundColor",{set:function(e){this._loadingScreen.loadingUIBackgroundColor=e},enumerable:!0,configurable:!0}),s.prototype.attachContextLostEvent=function(e){this._renderingCanvas.addEventListener("webglcontextlost",e,!1)},s.prototype.attachContextRestoredEvent=function(e){this._renderingCanvas.addEventListener("webglcontextrestored",e,!1)},s.prototype.getVertexShaderSource=function(e){var t=this._gl.getAttachedShaders(e);return this._gl.getShaderSource(t[0])},s.prototype.getFragmentShaderSource=function(e){var t=this._gl.getAttachedShaders(e);return this._gl.getShaderSource(t[1])},s.prototype.getFps=function(){return this.fps},s.prototype.getDeltaTime=function(){return this.deltaTime},s.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;r0&&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;i0&&(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})();t.FilesTextures=new Array,t.FilesToLoad=new Array,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;t<6;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)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.xt.x-this.minimumWorld.x)&&(!(this.maximumWorld.y-t.yt.y-this.minimumWorld.y)&&!(this.maximumWorld.z-t.zt.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.xt.x)&&(!(this.maximumWorld.yt.y)&&!(this.maximumWorld.zt.z))},t.Intersects=function(e,t){return!(e.maximumWorld.xt.maximumWorld.x)&&(!(e.maximumWorld.yt.maximumWorld.y)&&!(e.maximumWorld.zt.maximumWorld.z))},t.IntersectsSphere=function(t,i,r,n){var o=e.Vector3.Clamp(r,t,i),s=e.Vector3.DistanceSquared(r,o);return s<=n*n},t.IsCompletelyInFrustum=function(e,t){for(var i=0;i<6;i++)for(var r=0;r<8;r++)if(t[i].dotCoordinate(e[r])<0)return!1;return!0},t.IsInFrustum=function(e,t){for(var i=0;i<6;i++){for(var r=8,n=0;n<8&&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)},t.prototype.isCompletelyInFrustum=function(e){return this.boundingBox.isCompletelyInFrustum(e)},t.prototype._checkCollision=function(e){return e._canDoCollision(this.boundingSphere.centerWorld,this.boundingSphere.radiusWorld,this.boundingBox.minimumWorld,this.boundingBox.maximumWorld)},t.prototype.intersectsPoint=function(e){return!!this.boundingSphere.centerWorld&&(!!this.boundingSphere.intersectsPoint(e)&&!!this.boundingBox.intersectsPoint(e))},t.prototype.intersects=function(t,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))))))))))))))},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,this._show=!1}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.xt.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.yt.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.zt.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(n<=o)return!0;var s=t*this.direction.x+i*this.direction.y+r*this.direction.z;if(s<0)return!1;var a=n-s*s;return a<=o},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(s<0||s>1)return null;e.Vector3.CrossToRef(this._tvec,this._edge1,this._qvec);var a=e.Vector3.Dot(this.direction,this._qvec)*o;if(a<0||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,i<0?i<-9.99999997475243e-7?null:0:i},t.prototype.intersectsMesh=function(i,r){var n=e.Tmp.Matrix[0];return i.getWorldMatrix().invertToRef(n),this._tmpRay?t.TransformToRef(this,n,this._tmpRay):this._tmpRay=t.Transform(this,n),i.intersects(this._tmpRay,r)},t.prototype.show=function(t,i){this._show||(this._renderFunction=this._render.bind(this),this._show=!0,this._scene=t,this._renderPoints=[this.origin,this.origin.add(this.direction.scale(this.length))],this._renderLine=e.Mesh.CreateLines("ray",this._renderPoints,t,!0),this._scene.registerBeforeRender(this._renderFunction)),i&&this._renderLine.color.copyFrom(i)},t.prototype.hide=function(){this._show&&(this._show=!1,this._scene.unregisterBeforeRender(this._renderFunction)),this._renderLine&&(this._renderLine.dispose(),this._renderLine=null,this._renderPoints=null)},t.prototype._render=function(){var t=this._renderPoints[1];t.copyFrom(this.direction),t.scaleInPlace(this.length),t.addInPlace(this.origin),e.Mesh.CreateLines("ray",this._renderPoints,this._scene,!0,this._renderLine)},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),m=e.Vector3.Dot(u,u),_=e.Vector3.Dot(l,f),g=e.Vector3.Dot(u,f),v=d*m-p*p,y=v,x=v;vy&&(s=y,h=g+p,x=m)),h<0?(h=0,-_<0?s=0:-_>d?s=y:(s=-_,y=d)):h>x&&(h=x,-_+p<0?s=0:-_+p>d?s=y:(s=-_+p,y=d)),o=Math.abs(s)0&&a<=this.length&&A.lengthSquared()e.Engine.CollisionsEpsilon&&o.position.addInPlace(o._diffPositionForCollisions),r&&o.onCollideObservable.notifyObservers(r),o.onCollisionPositionChangeObservable.notifyObservers(o.position)},n.addMesh(o),o}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,"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.getClassName=function(){return"AbstractMesh"},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)},i.prototype.setBoundingInfo=function(e){this._boundingInfo=e},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,r,n){t.normalize(),this.rotationQuaternion||(this.rotationQuaternion=e.Quaternion.RotationYawPitchRoll(this.rotation.y,this.rotation.x,this.rotation.z),this.rotation=e.Vector3.Zero());var o;if(n&&n!==e.Space.LOCAL){if(this.parent){var s=this.parent.getWorldMatrix().clone();s.invert(),t=e.Vector3.TransformNormal(t,s)}o=e.Quaternion.RotationAxisToRef(t,r,i._rotationAxisCache),o.multiplyToRef(this.rotationQuaternion,this.rotationQuaternion)}else o=e.Quaternion.RotationAxisToRef(t,r,i._rotationAxisCache),this.rotationQuaternion.multiplyToRef(o,this.rotationQuaternion)},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(){return!this._isDirty&&(this.billboardMode===this._cache.billboardMode&&this.billboardMode===i.BILLBOARDMODE_NONE&&(!this._cache.pivotMatrixUpdated&&(!this.infiniteDistance&&(!!this._cache.position.equals(this.position)&&(!(this.rotationQuaternion&&!this._cache.rotationQuaternion.equals(this.rotationQuaternion))&&(!!this._cache.rotation.equals(this.rotation)&&!!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;t1&&!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;c1)||l.canIntersects(t)){var u=l.intersects(t,this._positions,this.getIndices(),i);if(u&&(i||!s||u.distance0&&this.includedOnlyMeshes.indexOf(e)===-1)&&(!(this.excludedMeshes.length>0&&this.excludedMeshes.indexOf(e)!==-1)&&((0===this.includeOnlyWithLayerMask||0!==(this.includeOnlyWithLayerMask&e.layerMask))&&!(0!==this.excludeWithLayerMask&&this.excludeWithLayerMask&e.layerMask)))},i.prototype.getWorldMatrix=function(){this._currentRenderId=this.getScene().getRenderId();var t=this._getWorldMatrix();return this.parent&&this.parent.getWorldMatrix?(this._parentedWorldMatrix||(this._parentedWorldMatrix=e.Matrix.Identity()),t.multiplyToRef(this.parent.getWorldMatrix(),this._parentedWorldMatrix),this._markSyncedWithParent(),this._parentedWorldMatrix):t},i.prototype.dispose=function(){this._shadowGenerator&&(this._shadowGenerator.dispose(),this._shadowGenerator=null),this.getScene().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;othis._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)},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},i})(e.Light);__decorate([e.serializeAsVector3()],t.prototype,"position",void 0),__decorate([e.serializeAsVector3()],t.prototype,"direction",void 0), -__decorate([e.serialize()],t.prototype,"shadowOrthoScale",void 0),__decorate([e.serialize()],t.prototype,"autoUpdateExtends",void 0),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._useFullFloat=!0,this._light=r,this._scene=r.getScene(),this._mapSize=i,r._shadowGenerator=this;var o,s=this._scene.getEngine().getCaps();s.textureFloat&&s.textureFloatLinearFiltering&&s.textureFloatRender?(this._useFullFloat=!0,o=e.Engine.TEXTURETYPE_FLOAT):(this._useFullFloat=!1,o=e.Engine.TEXTURETYPE_UNSIGNED_INT),this._shadowMap=new e.RenderTargetTexture(r.name+"_shadowMap",i,this._scene,(!1),(!0),o,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),(!0),o),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 a=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;r4&&(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 h=r.join("\n");return this._cachedDefines!==h&&(this._cachedDefines=h,this._effect=this._scene.getEngine().createEffect("shadowMap",n,["world","mBones","viewProjection","diffuseMatrix","lightPosition","depthValues"],["diffuseSampler"],h)),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:e<=0?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;ti.x+r)&&(!(i.x-r>t.x)&&(!(e.y>i.y+r)&&(!(i.y-r>t.y)&&(!(e.z>i.z+r)&&!(i.z-r>t.z)))))},i=(function(){var e={root:0,found:!1};return function(t,i,r,n){e.root=0,e.found=!1;var o=i*i-4*t*r;if(o<0)return e;var s=Math.sqrt(o),a=(-i-s)/(2*t),h=(-i+s)/(2*t);if(a>h){var c=h;h=a,a=c}return a>0&&a0&&h=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)&&!!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||d<0)return;h<0&&(h=0),h>1&&(h=1)}this._collisionPoint.copyFromFloats(0,0,0);var m=!1,_=1;if(c||(this.basePoint.subtractToRef(l.normal,this._planeIntersectionPoint),this.velocity.scaleToRef(h,this._tempVector),this._planeIntersectionPoint.addInPlace(this._tempVector),this._checkPointInTriangle(this._planeIntersectionPoint,n,o,s,l.normal)&&(m=!0,_=h,this._collisionPoint.copyFrom(this._planeIntersectionPoint))),!m){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,_);b.found&&(_=b.root,m=!0,this._collisionPoint.copyFrom(n)),this.basePoint.subtractToRef(o,this._tempVector),y=2*e.Vector3.Dot(this.velocity,this._tempVector),x=this._tempVector.lengthSquared()-1,b=i(v,y,x,_),b.found&&(_=b.root,m=!0,this._collisionPoint.copyFrom(o)),this.basePoint.subtractToRef(s,this._tempVector),y=2*e.Vector3.Dot(this.velocity,this._tempVector),x=this._tempVector.lengthSquared()-1,b=i(v,y,x,_),b.found&&(_=b.root,m=!0,this._collisionPoint.copyFrom(s)),o.subtractToRef(n,this._edge),n.subtractToRef(this.basePoint,this._baseToVertex);var A=this._edge.lengthSquared(),T=e.Vector3.Dot(this._edge,this.velocity),E=e.Vector3.Dot(this._edge,this._baseToVertex);if(v=A*-g+T*T,y=A*(2*e.Vector3.Dot(this.velocity,this._baseToVertex))-2*T*E,x=A*(1-this._baseToVertex.lengthSquared())+E*E,b=i(v,y,x,_),b.found){var P=(T*b.root-E)/A;P>=0&&P<=1&&(_=b.root,m=!0,this._edge.scaleInPlace(P),n.addToRef(this._edge,this._collisionPoint))}s.subtractToRef(o,this._edge),o.subtractToRef(this.basePoint,this._baseToVertex),A=this._edge.lengthSquared(),T=e.Vector3.Dot(this._edge,this.velocity),E=e.Vector3.Dot(this._edge,this._baseToVertex),v=A*-g+T*T,y=A*(2*e.Vector3.Dot(this.velocity,this._baseToVertex))-2*T*E,x=A*(1-this._baseToVertex.lengthSquared())+E*E,b=i(v,y,x,_),b.found&&(P=(T*b.root-E)/A,P>=0&&P<=1&&(_=b.root,m=!0,this._edge.scaleInPlace(P),o.addToRef(this._edge,this._collisionPoint))),n.subtractToRef(s,this._edge),s.subtractToRef(this.basePoint,this._baseToVertex),A=this._edge.lengthSquared(),T=e.Vector3.Dot(this._edge,this.velocity),E=e.Vector3.Dot(this._edge,this._baseToVertex),v=A*-g+T*T,y=A*(2*e.Vector3.Dot(this.velocity,this._baseToVertex))-2*T*E,x=A*(1-this._baseToVertex.lengthSquared())+E*E,b=i(v,y,x,_),b.found&&(P=(T*b.root-E)/A,P>=0&&P<=1&&(_=b.root,m=!0,this._edge.scaleInPlace(P),s.addToRef(this._edge,this._collisionPoint)))}if(m){var M=_*this.velocity.length();(!this.collisionFound||M4)){++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})();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()||[])}},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;h0&&this._postProcesses[0].markTextureDirty();for(var t=0,i=this._rigCameras.length;t-1?(e.Tools.Error("You're trying to reuse a post process not defined as reusable."),0):(null==i||i<0?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);o!==-1&&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._refreshFrustumPlanes=!0,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.freezeProjectionMatrix=function(e){this._doNotComputeProjectionMatrix=!0,void 0!==e&&(this._projectionMatrix=e)},i.prototype.unfreezeProjectionMatrix=function(){this._doNotComputeProjectionMatrix=!1},i.prototype.getProjectionMatrix=function(t){if(this._doNotComputeProjectionMatrix||!t&&this._isSynchronizedProjectionMatrix())return this._projectionMatrix;this._refreshFrustumPlanes=!0;var r=this.getEngine(),n=this.getScene();if(this.mode===i.PERSPECTIVE_CAMERA)return this.minZ<=0&&(this.minZ=.1),n.useRightHandedSystem?e.Matrix.PerspectiveFovRHToRef(this.fov,r.getAspectRatio(this),this.minZ,this.maxZ,this._projectionMatrix,this.fovMode===i.FOVMODE_VERTICAL_FIXED):e.Matrix.PerspectiveFovLHToRef(this.fov,r.getAspectRatio(this),this.minZ,this.maxZ,this._projectionMatrix,this.fovMode===i.FOVMODE_VERTICAL_FIXED),this._projectionMatrix;var o=r.getRenderWidth()/2,s=r.getRenderHeight()/2;return n.useRightHandedSystem?e.Matrix.OrthoOffCenterRHToRef(this.orthoLeft||-o,this.orthoRight||o,this.orthoBottom||-s,this.orthoTop||s,this.minZ,this.maxZ,this._projectionMatrix):e.Matrix.OrthoOffCenterLHToRef(this.orthoLeft||-o,this.orthoRight||o,this.orthoBottom||-s,this.orthoTop||s,this.minZ,this.maxZ,this._projectionMatrix), -this._projectionMatrix},i.prototype.getTranformationMatrix=function(){return this._computedViewMatrix.multiplyToRef(this._projectionMatrix,this._transformMatrix),this._transformMatrix},i.prototype.updateFrustumPlanes=function(){this._refreshFrustumPlanes&&(this.getTranformationMatrix(),this._frustumPlanes?e.Frustum.GetPlanesToRef(this._transformMatrix,this._frustumPlanes):this._frustumPlanes=e.Frustum.GetPlanes(this._transformMatrix),this._refreshFrustumPlanes=!1)},i.prototype.isInFrustum=function(e){return this.updateFrustumPlanes(),e.isInFrustum(this._frustumPlanes)},i.prototype.isCompletelyInFrustum=function(e){return this.updateFrustumPlanes(),e.isCompletelyInFrustum(this._frustumPlanes)},i.prototype.dispose=function(){for(this.getScene().stopAnimation(this),this.getScene().removeCamera(this);this._rigCameras.length>0;)this._rigCameras.pop().dispose();for(var e=this._postProcesses.length;--e>=0;)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));break;case i.RIG_MODE_WEBVR:r.vrDisplay&&(this._rigCameras[0].viewport=new e.Viewport(0,0,.5,1),this._rigCameras[0].setCameraRigParameter("left",!0),this._rigCameras[0].setCameraRigParameter("frameData",r.frameData),this._rigCameras[0]._cameraRigParams.vrWorkMatrix=new e.Matrix,this._rigCameras[0].getProjectionMatrix=this._getWebVRProjectionMatrix,this._rigCameras[1].viewport=new e.Viewport(.5,0,.5,1),this._rigCameras[1].setCameraRigParameter("frameData",r.frameData),this._rigCameras[1]._cameraRigParams.vrWorkMatrix=new e.Matrix,this._rigCameras[1].getProjectionMatrix=this._getWebVRProjectionMatrix)}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._getWebVRProjectionMatrix=function(){var t=this._cameraRigParams.left?this._cameraRigParams.frameData.leftProjectionMatrix:this._cameraRigParams.frameData.rightProjectionMatrix;return[8,9,10,11].forEach((function(e){t[e]*=-1})),e.Matrix.FromArrayToRef(t,0,this._projectionMatrix),this._projectionMatrix},i.prototype._getWebVRViewMatrix=function(){var t=this._cameraRigParams.left?this._cameraRigParams.frameData.leftViewMatrix:this._cameraRigParams.frameData.rightViewMatrix;return[8,9,10,11].forEach((function(e){t[e]*=-1})),e.Matrix.FromArrayToRef(t,0,this._webvrViewMatrix),this._webvrViewMatrix},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=0&&r._keys.splice(t,1),i||e.preventDefault()}},t.addEventListener("keydown",this._onKeyDown,!1),t.addEventListener("keyup",this._onKeyUp,!1),e.Tools.RegisterTopRootEvents([{name:"blur",handler:this._onLostFocus}]))},t.prototype.detachControl=function(t){this._onKeyDown&&(t.removeEventListener("keydown",this._onKeyDown),t.removeEventListener("keyup",this._onKeyUp),e.Tools.UnregisterTopRootEvents([{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;i1)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"},t})();__decorate([e.serialize()],t.prototype,"touchAngularSensibility",void 0),__decorate([e.serialize()],t.prototype,"touchMoveSensibility",void 0),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),this._orientationChanged()},t.prototype.detachControl=function(e){window.removeEventListener("orientationchange",this._orientationChanged),window.removeEventListener("deviceorientation",this._deviceOrientation)},t.prototype.checkInputs=function(){this._alpha&&(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 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"},t})();__decorate([e.serialize()],t.prototype,"gamepadAngularSensibility",void 0),__decorate([e.serialize()],t.prototype,"gamepadMoveSensibility",void 0),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;t.tabIndex=1,this._onKeyDown=function(e){if(r.keysUp.indexOf(e.keyCode)!==-1||r.keysDown.indexOf(e.keyCode)!==-1||r.keysLeft.indexOf(e.keyCode)!==-1||r.keysRight.indexOf(e.keyCode)!==-1){var t=r._keys.indexOf(e.keyCode);t===-1&&r._keys.push(e.keyCode),e.preventDefault&&(i||e.preventDefault())}},this._onKeyUp=function(e){if(r.keysUp.indexOf(e.keyCode)!==-1||r.keysDown.indexOf(e.keyCode)!==-1||r.keysLeft.indexOf(e.keyCode)!==-1||r.keysRight.indexOf(e.keyCode)!==-1){var t=r._keys.indexOf(e.keyCode);t>=0&&r._keys.splice(t,1),e.preventDefault&&(i||e.preventDefault())}},this._onLostFocus=function(){r._keys=[]},t.addEventListener("keydown",this._onKeyDown,!1),t.addEventListener("keyup",this._onKeyUp,!1),e.Tools.RegisterTopRootEvents([{name:"blur",handler:this._onLostFocus}])},t.prototype.detachControl=function(t){t&&(t.removeEventListener("keydown",this._onKeyDown),t.removeEventListener("keyup",this._onKeyUp)),e.Tools.UnregisterTopRootEvents([{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.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"},t})();__decorate([e.serialize()],t.prototype,"gamepadRotationSensibility",void 0),__decorate([e.serialize()],t.prototype,"gamepadMoveSensibility",void 0),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){var o=t.call(this,i,r,n)||this;return o.cameraDirection=new e.Vector3(0,0,0),o.cameraRotation=new e.Vector2(0,0),o.rotation=new e.Vector3(0,0,0),o.speed=2,o.noRotationConstraint=!1,o.lockedTarget=null,o._currentTarget=e.Vector3.Zero(),o._viewMatrix=e.Matrix.Zero(),o._camMatrix=e.Matrix.Zero(),o._cameraTransformMatrix=e.Matrix.Zero(),o._cameraRotationMatrix=e.Matrix.Zero(),o._referencePoint=new e.Vector3(0,0,1),o._defaultUpVector=new e.Vector3(0,1,0),o._transformedReferencePoint=e.Vector3.Zero(),o._lookAtTemp=e.Matrix.Zero(),o._tempMatrix=e.Matrix.Zero(),o}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.absolutePosition&&this.lockedTarget.computeWorldMatrix(),this.lockedTarget.absolutePosition||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*Math.sqrt(e.getDeltaTime()/(100*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.Engine.CollisionsEpsilon&&(o.position.addInPlace(o._diffPosition),o.onCollide&&r&&o.onCollide(r))};n(i)},o.inputs=new e.FreeCameraInputsManager(o),o.inputs.addKeyboard().addMouse(),o}return __extends(i,t),Object.defineProperty(i.prototype,"angularSensibility",{get:function(){var e=this.inputs.attached.mouse;if(e)return e.angularSensibility},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;if(e)return e.keysUp},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;if(e)return e.keysDown},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;if(e)return e.keysLeft},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;if(e)return e.keysRight},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.getClassName=function(){return"FreeCamera"},i})(e.TargetCamera);__decorate([e.serializeAsVector3()],t.prototype,"ellipsoid",void 0),__decorate([e.serialize()],t.prototype,"checkCollisions",void 0),__decorate([e.serialize()],t.prototype,"applyGravity",void 0),e.FreeCamera=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(e){return t.call(this,e)||this}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.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){var o=t.call(this,e,i,r)||this;return o.radius=12,o.rotationOffset=0,o.heightOffset=4,o.cameraAcceleration=.05,o.maxCameraSpeed=20,o.lockedTarget=n,o}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=l<1?-this.maxCameraSpeed:this.maxCameraSpeed),(u>this.maxCameraSpeed||u<-this.maxCameraSpeed)&&(u=u<1?-this.maxCameraSpeed:this.maxCameraSpeed),(f>this.maxCameraSpeed||f<-this.maxCameraSpeed)&&(f=f<1?-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.lockedTarget)},i.prototype.getClassName=function(){return"FollowCamera"},i})(e.TargetCamera);__decorate([e.serialize()],t.prototype,"radius",void 0),__decorate([e.serialize()],t.prototype,"rotationOffset",void 0),__decorate([e.serialize()],t.prototype,"heightOffset",void 0),__decorate([e.serialize()],t.prototype,"cameraAcceleration",void 0),__decorate([e.serialize()],t.prototype,"maxCameraSpeed",void 0),__decorate([e.serializeAsMeshReference("lockedTargetId")],t.prototype,"lockedTarget",void 0),e.FollowCamera=t;var i=(function(t){function i(i,r,n,o,s,a){var h=t.call(this,i,e.Vector3.Zero(),a)||this;return h.alpha=r,h.beta=n,h.radius=o,h.target=s,h._cartesianCoordinates=e.Vector3.Zero(),h.follow(),h}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.getClassName=function(){return"ArcFollowCamera"},i})(e.TargetCamera);e.ArcFollowCamera=i})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(e){function t(t,i,r){var n=e.call(this,t,i,r)||this;return n.inputs.addTouch(),n._setupInputs(),n}return __extends(t,e),Object.defineProperty(t.prototype,"touchAngularSensibility",{get:function(){var e=this.inputs.attached.touch;if(e)return e.touchAngularSensibility},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;if(e)return e.touchMoveSensibility},set:function(e){var t=this.inputs.attached.touch;t&&(t.touchMoveSensibility=e)},enumerable:!0,configurable:!0}),t.prototype.getClassName=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=t.call(this,i,e.Vector3.Zero(),a)||this;return h.inertialAlphaOffset=0,h.inertialBetaOffset=0,h.inertialRadiusOffset=0,h.lowerAlphaLimit=null,h.upperAlphaLimit=null,h.lowerBetaLimit=.01,h.upperBetaLimit=Math.PI,h.lowerRadiusLimit=null,h.upperRadiusLimit=null,h.inertialPanningX=0,h.inertialPanningY=0,h.zoomOnFactor=1,h.targetScreenOffset=e.Vector2.Zero(),h.allowUpsideDown=!0,h._viewMatrix=new e.Matrix,h.panningAxis=new e.Vector3(1,1,0),h.checkCollisions=!1,h.collisionRadius=new e.Vector3(.5,.5,.5),h._collider=new e.Collider,h._previousPosition=e.Vector3.Zero(),h._collisionVelocity=e.Vector3.Zero(),h._newPosition=e.Vector3.Zero(),h._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?h.target=s:h.target=e.Vector3.Zero(),h.alpha=r,h.beta=n,h.radius=o,h.getViewMatrix(),h.inputs=new e.ArcRotateCameraInputsManager(h),h.inputs.addKeyboard().addMouseWheel().addPointers().addGamepad(),h}return __extends(i,t),Object.defineProperty(i.prototype,"angularSensibilityX",{get:function(){var e=this.inputs.attached.pointers;if(e)return e.angularSensibilityX},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;if(e)return e.angularSensibilityY},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;if(e)return e.pinchPrecision},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;if(e)return e.panningSensibility},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;if(e)return e.keysUp},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;if(e)return e.keysDown},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;if(e)return e.keysLeft},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;if(e)return e.keysRight},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;if(e)return e.wheelPrecision},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(){if(this.target.getAbsolutePosition){var e=this.target.getAbsolutePosition();return this._targetBoundingCenter?e.add(this._targetBoundingCenter):e}return 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))},i.prototype.attachControl=function(e,t,i,r){var n=this;void 0===i&&(i=!0),void 0===r&&(r=2),this._useCtrlForPanning=i,this._panningMouseButton=r,this.inputs.attachElement(e,t),this._reset=function(){n.inertialAlphaOffset=0,n.inertialBetaOffset=0,n.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.getScene().useRightHandedSystem?this.alpha-=this.beta<=0?-this.inertialAlphaOffset:this.inertialAlphaOffset: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)Math.PI&&(this.beta=this.beta-2*Math.PI):this.betathis.upperBetaLimit&&(this.beta=this.upperBetaLimit),this.lowerAlphaLimit&&this.alphathis.upperAlphaLimit&&(this.alpha=this.upperAlphaLimit),this.lowerRadiusLimit&&this.radiusthis.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.copyFrom(e),this.rebuildAnglesAndRadius())},i.prototype.setTarget=function(e,t){void 0===t&&(t=!1),this._getTargetPosition().equals(e)||(t&&e.getBoundingInfo?this._targetBoundingCenter=e.getBoundingInfo().boundingBox.center.clone():this._targetBoundingCenter=null,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()),this.getScene().useRightHandedSystem?e.Matrix.LookAtRHToRef(this.position,o,s,this._viewMatrix):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._currentTarget=o,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.getClassName=function(){return"ArcRotateCamera"},i})(e.TargetCamera);__decorate([e.serialize()],t.prototype,"alpha",void 0),__decorate([e.serialize()],t.prototype,"beta",void 0),__decorate([e.serialize()],t.prototype,"radius",void 0),__decorate([e.serializeAsVector3()],t.prototype,"target",void 0),__decorate([e.serialize()],t.prototype,"inertialAlphaOffset",void 0),__decorate([e.serialize()],t.prototype,"inertialBetaOffset",void 0),__decorate([e.serialize()],t.prototype,"inertialRadiusOffset",void 0),__decorate([e.serialize()],t.prototype,"lowerAlphaLimit",void 0),__decorate([e.serialize()],t.prototype,"upperAlphaLimit",void 0),__decorate([e.serialize()],t.prototype,"lowerBetaLimit",void 0),__decorate([e.serialize()],t.prototype,"upperBetaLimit",void 0),__decorate([e.serialize()],t.prototype,"lowerRadiusLimit",void 0),__decorate([e.serialize()],t.prototype,"upperRadiusLimit",void 0),__decorate([e.serialize()],t.prototype,"inertialPanningX",void 0),__decorate([e.serialize()],t.prototype,"inertialPanningY",void 0),__decorate([e.serialize()],t.prototype,"zoomOnFactor",void 0),__decorate([e.serialize()],t.prototype,"allowUpsideDown",void 0),e.ArcRotateCamera=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(e){return t.call(this,e)||this}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._autoClearDepthStencil={},this._customOpaqueSortCompareFn={},this._customAlphaTestSortCompareFn={},this._customTransparentSortCompareFn={},this._renderinGroupInfo=null,this._scene=e;for(var i=t.MIN_RENDERINGGROUPS;ii._alphaIndex?1:e._alphaIndext._distanceToCamera?-1:0},t.frontToBackSortCompare=function(e,t){return e._distanceToCamerat._distanceToCamera?1:0},t.prototype.prepare=function(){this._opaqueSubMeshes.reset(),this._transparentSubMeshes.reset(),this._alphaTestSubMeshes.reset(),this._particleSystems.reset(),this._spriteManagers.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.prototype.dispatchSprites=function(e){this._spriteManagers.push(e)},t.prototype.dispatchParticles=function(e){this._particleSystems.push(e)},t.prototype._renderParticles=function(e){if(0!==this._particleSystems.length){var t=this._scene.activeCamera;this._scene._particlesDuration.beginMonitoring();for(var i=0;ie.ActionManager.LongPressDelay&&Math.abs(l._startingPointerPosition.x-l._pointerX)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&&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(e){return e.isPickable&&e.isVisible&&e.isReady()});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)),c.pickedMesh.actionManager&&Math.abs(a._startingPointerPosition.x-a._pointerX)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)),c.pickedSprite.actionManager&&Math.abs(a._startingPointerPosition.x-a._pointerX)0)return!1;var t;for(t=0;t0)return;this._animationTimeLast=t}var i=(t-this._animationTimeLast)*this.animationTimeScale;this._animationTime+=i,this._animationTimeLast=t;for(var r=0;r0?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.switchActiveCamera=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-1&&(this._geometries.splice(t,1),this.collisionCoordinator.onGeometryDeleted(e),this.onGeometryRemovedObservable.notifyObservers(e),!0)},i.prototype.getGeometries=function(){return this._geometries},i.prototype.getMeshByID=function(e){for(var t=0;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=0;t--)if(this.skeletons[t].id===e)return this.skeletons[t];return null},i.prototype.getSkeletonById=function(e){for(var t=0;t0&&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(o,s)))}}this._particlesDuration.beginMonitoring();e.Tools.Now;if(this.particlesEnabled){e.Tools.StartPerformanceCounter("Particles",this.particleSystems.length>0);for(var a=0;a0)}this._particlesDuration.endMonitoring(!1)},i.prototype._activeMesh=function(e,t){if(t.skeleton&&this.skeletonsEnabled&&(this._activeSkeletons.pushNoDuplicate(t.skeleton)&&t.skeleton.prepare(),t.computeBonesUsingShaders||this._softwareSkinnedMeshes.pushNoDuplicate(t)),(e.showBoundingBox||this.forceShowBoundingBoxes)&&this._boundingBoxRenderer.renderList.push(e.getBoundingInfo().boundingBox),e._edgesRenderer&&this._edgesRenderers.push(e._edgesRenderer),t&&t.subMeshes){var i,r;if(t._submeshesOctree&&t.useOctreeForRenderingSelection){var n=t._submeshesOctree.select(this._frustumPlanes);i=n.length,r=n.data}else r=t.subMeshes,i=r.length;for(var o=0;o0){this._intermediateRendering=!0,e.Tools.StartPerformanceCounter("Render targets",this._renderTargets.length>0);for(var s=0;s0),this._intermediateRendering=!1,this._renderId++,o=!0}var c=this._engine.getStencilBuffer(),l=!1;if(this.renderTargetsEnabled&&this.highlightLayers&&this.highlightLayers.length>0){this._intermediateRendering=!0;for(var u=0;u-1)){l=!0;var a=f._mainTexture;a._shouldRender()&&(this._renderId++,a.render(!1,!1),o=!0)}}this._intermediateRendering=!1,this._renderId++}o&&i.restoreDefaultFramebuffer(),this._renderTargetsDuration.endMonitoring(!1),this.postProcessManager._prepareFrame(),this._renderDuration.beginMonitoring();var d,p;if(this.layers.length){for(i.setDepthBuffer(!1),d=0;d0);for(var _=0;_0)}if(this.layers.length){for(i.setDepthBuffer(!1),d=0;d-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(){this._lastFrameDuration.beginMonitoring(),this._particlesDuration.fetchNewFrame(),this._spritesDuration.fetchNewFrame(),this._activeParticles.fetchNewFrame(),this._renderDuration.fetchNewFrame(),this._renderTargetsDuration.fetchNewFrame(),this._evaluateActiveMeshesDuration.fetchNewFrame(),this._totalVertices.fetchNewFrame(),this._activeIndices.fetchNewFrame(),this._activeBones.fetchNewFrame(),this.getEngine().drawCallsPerfCounter.fetchNewFrame(),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 t=Math.max(i.MinDeltaTime,Math.min(this._engine.getDeltaTime(),i.MaxDeltaTime));this._animationRatio=.06*t,this._animate(),this._physicsEngine&&(e.Tools.StartPerformanceCounter("Physics"),this._physicsEngine._step(t/1e3),e.Tools.EndPerformanceCounter("Physics")),this.onBeforeRenderObservable.notifyObservers(this),this._renderTargetsDuration.beginMonitoring();var r=(e.Tools.Now,this.getEngine()),n=this.activeCamera;if(this.renderTargetsEnabled){e.Tools.StartPerformanceCounter("Custom render targets",this.customRenderTargets.length>0);for(var o=0;o0),this._renderId++}if(this.customRenderTargets.length>0&&r.restoreDefaultFramebuffer(),this._renderTargetsDuration.endMonitoring(),this.activeCamera=n,this.proceduralTexturesEnabled){e.Tools.StartPerformanceCounter("Procedural textures",this._proceduralTextures.length>0);for(var a=0;a0)}if(this._engine.clear(this.clearColor,this.autoClear||this.forceWireframe||this.forcePointsCloud,!0,!0),this.shadowsEnabled)for(var c=0;c0)for(var f=0;f0&&this._engine.clear(null,!1,!0,!0),this._processSubCameras(this.activeCameras[f]);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 d=0;d0?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-1&&this._engine.scenes.splice(t,1),this._engine.wipeCaches()},i.prototype.disposeSounds=function(){this.mainSoundTrack.dispose();for(var e=0;e=n.distance))&&(n=c,r))break}return n||new e.PickingInfo},i.prototype._internalMultiPick=function(e,t){for(var i=new Array,r=0;r0)for(var s=0;s=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.multiPick=function(e,t,i,r){var n=this;return this._internalMultiPick((function(i){return n.createPickingRay(e,t,i,r)}),i)},i.prototype.multiPickWithRay=function(t,i){var r=this;return this._internalMultiPick((function(i){return r._pickWithRayInverseMatrix||(r._pickWithRayInverseMatrix=e.Matrix.Identity()),i.invertToRef(r._pickWithRayInverseMatrix),e.Ray.Transform(t,r._pickWithRayInverseMatrix)}),i)},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;n0},enumerable:!0,configurable:!0}),r.prototype._sortLODLevels=function(){this._LODLevels.sort((function(e,t){return e.distancet.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;ti)return this.onLODLevelSelection&&this.onLODLevelSelection(i,this,this._LODLevels[this._LODLevels.length-1].mesh),this;for(var r=0;r=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,i=this._geometry.copy(e.Geometry.RandomId());t.releaseForMesh(this,!0),i.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-1&&(o.skeleton=i.getLastSkeletonByID(t.skeletonId),t.numBoneInfluencers&&(o.numBoneInfluencers=t.numBoneInfluencers)),t.animations){for(var s=0;s4,c=h?this.getVerticesData(e.VertexBuffer.MatricesIndicesExtraKind):null,l=h?this.getVerticesData(e.VertexBuffer.MatricesWeightsExtraKind):null,u=t.getTransformMatrices(this),f=e.Vector3.Zero(),d=new e.Matrix,p=new e.Matrix,m=0,_=0;_0);o++)e.Matrix.FromFloat32ArrayToRefScaled(u,16*s[m+o],g,p),d.addToSelf(p);if(h)for(o=0;o<4&&(g=l[m+o],g>0);o++)e.Matrix.FromFloat32ArrayToRefScaled(u,16*c[m+o],g,p),d.addToSelf(p);e.Vector3.TransformCoordinatesFromFloatsToRef(this._sourcePositions[_],this._sourcePositions[_+1],this._sourcePositions[_+2],d,f),f.toArray(r,_),e.Vector3.TransformNormalFromFloatsToRef(this._sourceNormals[_],this._sourceNormals[_+1],this._sourceNormals[_+2],d,f),f.toArray(n,_),d.reset()}return this.updateVerticesData(e.VertexBuffer.PositionKind,r),this.updateVerticesData(e.VertexBuffer.NormalKind,n),this}},r.MinMax=function(e){var t=null,i=null;return e.forEach((function(e,r,n){var o=e.getBoundingInfo().boundingBox;t?(t.MinimizeInPlace(o.minimumWorld),i.MaximizeInPlace(o.maximumWorld)):(t=o.minimumWorld,i=o.maximumWorld)})),{min:t,max:i}},r.Center=function(t){var i=t instanceof Array?e.Mesh.MinMax(t):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;s65536))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;sa&&(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.updateSideOrientation=function(t,i){return t==e.Mesh.DOUBLESIDE?e.Mesh.DOUBLESIDE:void 0===t||null===t?e.Mesh.FRONTSIDE:t},t.CreateBox=function(t,i,r){var n=new e.Mesh(t,r);i.sideOrientation=this.updateSideOrientation(i.sideOrientation,r),n.sideOrientation=i.sideOrientation;var 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);i.sideOrientation=this.updateSideOrientation(i.sideOrientation,r),n.sideOrientation=i.sideOrientation;var 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);i.sideOrientation=this.updateSideOrientation(i.sideOrientation,r),n.sideOrientation=i.sideOrientation;var 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);i.sideOrientation=this.updateSideOrientation(i.sideOrientation,r),n.sideOrientation=i.sideOrientation;var 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,this.updateSideOrientation(i.sideOrientation,r)),h=i.instance,c=i.updatable;if(h){e.Vector3.FromFloatsToRef(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,e.Tmp.Vector3[0]),e.Vector3.FromFloatsToRef(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE,e.Tmp.Vector3[1]);var l=function(t){for(var i=n[0].length,r=0,o=h.sideOrientation===e.Mesh.DOUBLESIDE?2:1,s=1;s<=o;s++)for(var a=0;ae.Tmp.Vector3[1].x&&(e.Tmp.Vector3[1].x=c[u].x),c[u].ye.Tmp.Vector3[1].y&&(e.Tmp.Vector3[1].y=c[u].y),c[u].ze.Tmp.Vector3[1].z&&(e.Tmp.Vector3[1].z=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._boundingInfo=new e.BoundingInfo(e.Tmp.Vector3[0],e.Tmp.Vector3[1]),h._boundingInfo.update(h._worldMatrix),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,m=0,_=0;_1?1:r.arc:1,a=void 0===r.closed||r.closed,h=r.shape,c=r.radius||1,l=r.tessellation||64,u=r.updatable,f=this.updateSideOrientation(r.sideOrientation,n),d=r.cap||e.Mesh.NO_CAP,p=2*Math.PI,m=new Array,_=r.invertUV||!1,g=0,v=0,y=p/l*s,x=new Array;for(g=0;g<=l;g++){var x=[];for(d!=e.Mesh.CAP_START&&d!=e.Mesh.CAP_ALL||(x.push(new e.Vector3(0,h[0].y,0)),x.push(new e.Vector3(Math.cos(g*y)*h[0].x*c,h[0].y,Math.sin(g*y)*h[0].x*c))),v=0;v1?1:r.arc||1;var p,m,_=function(t,i,r,n,o,s,a,h){for(var c,l,u,f,d=i.getTangents(),p=i.getNormals(),m=i.getDistances(),_=2*Math.PI,g=_/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,A=0;A3?0:c,m=_(o,p,v,s,a,h,c,r.arc);var y=t.CreateRibbon(i,{pathArray:m,closePath:!0,closeArray:!1,updatable:u,sideOrientation:f,invertUV:l},n);return y.pathArray=m,y.path3D=p,y.tessellation=a,y.cap=c,y.arc=r.arc,y},t.CreatePolyhedron=function(t,i,r){var n=new e.Mesh(t,r);i.sideOrientation=this.updateSideOrientation(i.sideOrientation,r),n.sideOrientation=i.sideOrientation;var 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,m=Math.sqrt(h.x*h.x+h.z*h.z),_=Math.atan2(h.y,m),g=e.Matrix.RotationYawPitchRoll(p,_,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 A=0,T=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},E=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;s0,h=g>0,l=v>0,m=(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},P=0;P3?0:u,y=x(r,n,v,b,o,s,a,h,u,f);var A=t.CreateRibbon(i,{pathArray:y,closeArray:c,closePath:l,updatable:p,sideOrientation:m,invertUV:g},d);return A.pathArray=y,A.path3D=v,A.cap=u,A},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),this._uid=null}return Object.defineProperty(t.prototype,"uid",{get:function(){return this._uid||(this._uid=e.Tools.RandomId()),this._uid},enumerable:!0,configurable:!0}),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||!!this._texture&&this._texture.isReady},t.prototype.getSize=function(){return this._texture._width?new e.Size(this._texture._width,this._texture._height):this._texture._size?new e.Size(this._texture._size,this._texture._size):e.Size.Zero()},t.prototype.getBaseSize=function(){return this.isReady()&&this._texture?this._texture._size?new e.Size(this._texture._size,this._texture._size):new e.Size(this._texture._baseWidth,this._texture._baseHeight):e.Size.Zero()},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=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},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),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===o&&(o=!1),void 0===s&&(s=!0),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);var f=t.call(this,n)||this;if(f.uOffset=0,f.vOffset=0,f.uScale=1,f.vScale=1,f.uAng=0,f.vAng=0,f.wAng=0,f.name=r,f.url=r,f._noMipmap=o,f._invertY=s,f._samplingMode=a,f._buffer=l,f._deleteBuffer=u,!r)return f;f._texture=f._getFromCache(r,o,a);var d=function(){f._onLoadObservarble&&f._onLoadObservarble.hasObservers()&&f.onLoadObservable.notifyObservers(!0),h&&h()};return f._texture?f._texture.isReady?e.Tools.SetImmediate((function(){return d()})):f._texture.onLoadedCallbacks.push(d):n.useDelayedTextureLoading?(f.delayLoadState=e.Engine.DELAYLOADSTATE_NOTLOADED,f._delayedOnLoad=d,f._delayedOnError=c):(f._texture=n.getEngine().createTexture(r,o,s,n,f._samplingMode,d,c,f._buffer),u&&delete f._buffer),f}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)},Object.defineProperty(i.prototype,"onLoadObservable",{get:function(){return this._onLoadObservarble||(this._onLoadObservarble=new e.Observable),this._onLoadObservarble},enumerable:!0,configurable:!0}),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.customType){var o=e.Tools.Instantiate(t.customType);return o.Parse(t,r,n)}if(t.isCube)return e.CubeTexture.Parse(t,r,n); -if(!t.name&&!t.isRenderTarget)return null;var s=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 a=0;a=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,s,a,h){void 0===s&&(s=e.Engine.TEXTURETYPE_UNSIGNED_INT),void 0===a&&(a=e.Texture.BILINEAR_SAMPLINGMODE),void 0===h&&(h=!0);var c=t.call(this,i,r,n,o,!0,s,!1,a,h)||this;return c.mirrorPlane=new e.Plane(0,1,0,1),c._transformMatrix=e.Matrix.Zero(),c._mirrorMatrix=e.Matrix.Zero(),c.onBeforeRenderObservable.add((function(){e.Matrix.ReflectionToRef(c.mirrorPlane,c._mirrorMatrix),c._savedViewMatrix=n.getViewMatrix(),c._mirrorMatrix.multiplyToRef(c._savedViewMatrix,c._transformMatrix),n.setTransformMatrix(c._transformMatrix,n.getProjectionMatrix()),n.clipPlane=c.mirrorPlane,n.getEngine().cullBackFaces=!1,n._mirroredCameraPosition=e.Vector3.TransformCoordinates(n.activeCamera.position,c._mirrorMatrix)})),c.onAfterRenderObservable.add((function(){n.setTransformMatrix(c._savedViewMatrix,n.getProjectionMatrix()),n.getEngine().cullBackFaces=!0,n._mirroredCameraPosition=null,delete n.clipPlane})),c}return __extends(i,t),i.prototype.clone=function(){var e=this.getSize(),t=new i(this.name,e.width,this.getScene(),this._renderTargetOptions.generateMipMaps,this._renderTargetOptions.type,this._renderTargetOptions.samplingMode,this._renderTargetOptions.generateDepthBuffer);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=t.call(this,i,r,n,o,!0)||this;return s.refractionPlane=new e.Plane(0,1,0,1),s.depth=2,s.onBeforeRenderObservable.add((function(){n.clipPlane=s.refractionPlane})),s.onAfterRenderObservable.add((function(){delete n.clipPlane})),s}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);var a=t.call(this,null,n,!o)||this;a.name=i,a.wrapU=e.Texture.CLAMP_ADDRESSMODE,a.wrapV=e.Texture.CLAMP_ADDRESSMODE,a._generateMipMaps=o,r.getContext?(a._canvas=r,a._texture=n.getEngine().createDynamicTexture(r.width,r.height,o,s)):(a._canvas=document.createElement("canvas"),r.width?a._texture=n.getEngine().createDynamicTexture(r.width,r.height,o,s):a._texture=n.getEngine().createDynamicTexture(r,r,o,s));var h=a.getSize();return a._canvas.width=h.width,a._canvas.height=h.height,a._context=a._canvas.getContext("2d"),a}return __extends(i,t),Object.defineProperty(i.prototype,"canRescale",{get:function(){return!0},enumerable:!0,configurable:!0}),i.prototype.scale=function(e){var t=this.getSize();t.width*=e,t.height*=e,this._canvas.width=t.width,this._canvas.height=t.height,this.releaseInternalTexture(),this._texture=this.getScene().getEngine().createDynamicTexture(t.width,t.height,this._generateMipMaps,this._samplingMode)},i.prototype.getContext=function(){return this._context},i.prototype.clear=function(){var e=this.getSize();this._context.fillRect(0,0,e.width,e.height)},i.prototype.update=function(e){this.getScene().getEngine().updateDynamicTexture(this._texture,this._canvas,void 0===e||e)},i.prototype.drawText=function(e,t,i,r,n,o,s,a){void 0===a&&(a=!0);var h=this.getSize();if(o&&(this._context.fillStyle=o,this._context.fillRect(0,0,h.width,h.height)),this._context.font=r,null===t){var c=this._context.measureText(e);t=(h.width-c.width)/2}this._context.fillStyle=n,this._context.fillText(e,t,i),a&&this.update(s)},i.prototype.clone=function(){var e=this.getSize(),t=new i(this.name,e,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){void 0===o&&(o=!1),void 0===s&&(s=!1),void 0===a&&(a=e.Texture.TRILINEAR_SAMPLINGMODE);var h=t.call(this,null,n,!o,s)||this;h._autoLaunch=!0;var c;return h.name=i,r instanceof HTMLVideoElement?h.video=r:(c=r,h.video=document.createElement("video"),h.video.autoplay=!1,h.video.loop=!0),h._generateMipMaps=o,h._samplingMode=a,e.Tools.IsExponentOfTwo(h.video.videoWidth)&&e.Tools.IsExponentOfTwo(h.video.videoHeight)?(h.wrapU=e.Texture.WRAP_ADDRESSMODE,h.wrapV=e.Texture.WRAP_ADDRESSMODE):(h.wrapU=e.Texture.CLAMP_ADDRESSMODE,h.wrapV=e.Texture.CLAMP_ADDRESSMODE,h._generateMipMaps=!1),c?(h.video.addEventListener("canplaythrough",(function(){h._createTexture()})),c.forEach((function(e){var t=document.createElement("source");t.src=e,h.video.appendChild(t)}))):h._createTexture(),h._lastUpdate=e.Tools.Now,h}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)&&(this._lastUpdate=t,this.getScene().getEngine().updateVideoTexture(this._texture,this.video,this._invertY),!0)},i.CreateFromWebCam=function(t,i,r){var n=document.createElement("video");navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia,window.URL=window.URL||window.webkitURL||window.mozURL||window.msURL,navigator.getUserMedia&&navigator.getUserMedia({video:{width:{min:r&&r.minWidth||256,max:r&&r.maxWidth||640},height:{min:r&&r.minHeight||256,max:r&&r.maxHeight||480}}},(function(r){void 0!==n.mozSrcObject?n.mozSrcObject=r:n.src=window.URL&&window.URL.createObjectURL(r)||r,n.play(),i&&i(new e.VideoTexture("video",n,t,(!0),(!0)))}),(function(t){e.Tools.Error(t.name)}))},i})(e.Texture);e.VideoTexture=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(e,i,r,n,o,s){var a=t.call(this,e,r,null,n,o,s)||this;return a._animate=!0,a._time=0,a._texturePath=i,a.loadJson(i),a.refreshRate=1,a}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;tthis._maxRank&&(this._maxRank=e),this._defines[e]=new Array),this._defines[e].push(t)},e.prototype.addCPUSkinningFallback=function(e,t){this._meshRank=e,this._mesh=t,e>this._maxRank&&(this._maxRank=e)},Object.defineProperty(e.prototype,"isMoreFallbacks",{get:function(){return this._currentRank<=this._maxRank},enumerable:!0,configurable:!0}),e.prototype.reduce=function(e){for(var t=this._defines[this._currentRank],i=0;i-1?e:BABYLON.Engine.ShadersRepository+e,BABYLON.Tools.LoadFile(n+".vertex.fx",t)},Effect.prototype._loadFragmentShader=function(e,t){if(e instanceof HTMLElement){var i=BABYLON.Tools.GetDOMTextContent(e);return void t(i)}if("base64:"===e.substr(0,7)){var r=window.atob(e.substr(7));return void t(r)}if(Effect.ShadersStore[e+"PixelShader"])return void t(Effect.ShadersStore[e+"PixelShader"]);if(Effect.ShadersStore[e+"FragmentShader"])return void t(Effect.ShadersStore[e+"FragmentShader"]);var n;n="."===e[0]||"/"===e[0]||e.indexOf("http")>-1?e:BABYLON.Engine.ShadersRepository+e,BABYLON.Tools.LoadFile(n+".fragment.fx",t)},Effect.prototype._dumpShadersName=function(){this.name.vertexElement?(BABYLON.Tools.Error("Vertex shader:"+this.name.vertexElement),BABYLON.Tools.Error("Fragment shader:"+this.name.fragmentElement)):this.name.vertex?(BABYLON.Tools.Error("Vertex shader:"+this.name.vertex),BABYLON.Tools.Error("Fragment shader:"+this.name.fragment)):(BABYLON.Tools.Error("Vertex shader:"+this.name),BABYLON.Tools.Error("Fragment shader:"+this.name))},Effect.prototype._processIncludes=function(e,t){for(var i=this,r=/#include<(.+)>(\((.*)\))*(\[(.*)\])*/g,n=r.exec(e),o=new String(e);null!=n;){var s=n[1];if(!Effect.IncludesShadersStore[s]){var a=BABYLON.Engine.ShadersRepository+"ShadersInclude/"+s+".fx";return void BABYLON.Tools.LoadFile(a,(function(e){Effect.IncludesShadersStore[s]=e,i._processIncludes(o,t)}))}var h=Effect.IncludesShadersStore[s];if(n[2])for(var c=n[3].split(","),l=0;l0&&(result+=line+"\r\n")}return result},Effect.prototype._evaluateDefinesOnString=function(e){for(var t={children:[]},i=t,r=e.split("\n"),n=0;n0){for(var f=0;f0){for(var p=0;p0&&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=0&&this._scene.materials.splice(i,1),e&&this._effect&&(this._scene.getEngine()._releaseEffect(this._effect),this._effect=null),i=0;i0&&(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;a=!0,this._defines.EMISSIVE=!0}if(this.lightmapTexture&&r.LightmapTextureEnabled){if(!this.lightmapTexture.isReady())return!1;a=!0,this._defines.LIGHTMAP=!0,this._defines.USELIGHTMAPASSHADOWMAP=this.useLightmapAsShadowmap}if(this.specularTexture&&r.SpecularTextureEnabled){if(!this.specularTexture.isReady())return!1;a=!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;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&&r.RefractionTextureEnabled){if(!this.refractionTexture.isReady())return!1;a=!0,this._defines.REFRACTION=!0,this._defines.REFRACTIONMAP_3D=this.refractionTexture.isCube}if(this.cameraColorGradingTexture&&r.ColorGradingTextureEnabled){if(!this.cameraColorGradingTexture.isReady())return!1;this._defines.CAMERACOLORGRADING=!0}}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.cameraColorCurves&&(this._defines.CAMERACOLORCURVES=!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),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),h=!0,this._defines.FRESNEL=!0),this._defines.SPECULARTERM&&this.useSpecularOverAlpha&&(this._defines.SPECULAROVERALPHA=!0),i&&(h&&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),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",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"];this._defines.CAMERACOLORCURVES&&e.ColorCurves.PrepareUniforms(d),this._defines.CAMERACOLORGRADING&&e.ColorGradingTexture.PrepareUniformsAndSamplers(d,p),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)},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){if(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)}this.cameraColorGradingTexture&&r.ColorGradingTextureEnabled&&e.ColorGradingTexture.Bind(this.cameraColorGradingTexture,this._effect)}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),this.cameraColorCurves&&e.ColorCurves.Bind(this.cameraColorCurves,this._effect)),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),this.cameraColorGradingTexture&&this.cameraColorGradingTexture.animations&&this.cameraColorGradingTexture.animations.length>0&&e.push(this.cameraColorGradingTexture),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(),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(){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})(e.Material);i.DiffuseTextureEnabled=!0,i.AmbientTextureEnabled=!0,i.OpacityTextureEnabled=!0,i.ReflectionTextureEnabled=!0,i.EmissiveTextureEnabled=!0,i.SpecularTextureEnabled=!0,i.BumpTextureEnabled=!0,i.FresnelEnabled=!0,i.LightmapTextureEnabled=!0,i.RefractionTextureEnabled=!0,i.ColorGradingTextureEnabled=!0,__decorate([e.serializeAsTexture()],i.prototype,"diffuseTexture",void 0),__decorate([e.serializeAsTexture()],i.prototype,"ambientTexture",void 0),__decorate([e.serializeAsTexture()],i.prototype,"opacityTexture",void 0),__decorate([e.serializeAsTexture()],i.prototype,"reflectionTexture",void 0),__decorate([e.serializeAsTexture()],i.prototype,"emissiveTexture",void 0),__decorate([e.serializeAsTexture()],i.prototype,"specularTexture",void 0),__decorate([e.serializeAsTexture()],i.prototype,"bumpTexture",void 0),__decorate([e.serializeAsTexture()],i.prototype,"lightmapTexture",void 0),__decorate([e.serializeAsTexture()],i.prototype,"refractionTexture",void 0),__decorate([e.serializeAsColor3("ambient")],i.prototype,"ambientColor",void 0),__decorate([e.serializeAsColor3("diffuse")],i.prototype,"diffuseColor",void 0),__decorate([e.serializeAsColor3("specular")],i.prototype,"specularColor",void 0),__decorate([e.serializeAsColor3("emissive")],i.prototype,"emissiveColor",void 0),__decorate([e.serialize()],i.prototype,"specularPower",void 0),__decorate([e.serialize()],i.prototype,"useAlphaFromDiffuseTexture",void 0),__decorate([e.serialize()],i.prototype,"useEmissiveAsIllumination",void 0),__decorate([e.serialize()],i.prototype,"linkEmissiveWithDiffuse",void 0),__decorate([e.serialize()],i.prototype,"useReflectionFresnelFromSpecular",void 0),__decorate([e.serialize()],i.prototype,"useSpecularOverAlpha",void 0),__decorate([e.serialize()],i.prototype,"useReflectionOverAlpha",void 0),__decorate([e.serialize()],i.prototype,"disableLighting",void 0),__decorate([e.serialize()],i.prototype,"useParallax",void 0),__decorate([e.serialize()],i.prototype,"useParallaxOcclusion",void 0),__decorate([e.serialize()],i.prototype,"parallaxScaleBias",void 0),__decorate([e.serialize()],i.prototype,"roughness",void 0),__decorate([e.serialize()],i.prototype,"indexOfRefraction",void 0),__decorate([e.serialize()],i.prototype,"invertRefractionY",void 0),__decorate([e.serialize()],i.prototype,"useLightmapAsShadowmap",void 0),__decorate([e.serializeAsFresnelParameters()],i.prototype,"diffuseFresnelParameters",void 0),__decorate([e.serializeAsFresnelParameters()],i.prototype,"opacityFresnelParameters",void 0),__decorate([e.serializeAsFresnelParameters()],i.prototype,"reflectionFresnelParameters",void 0),__decorate([e.serializeAsFresnelParameters()],i.prototype,"refractionFresnelParameters",void 0),__decorate([e.serializeAsFresnelParameters()],i.prototype,"emissiveFresnelParameters",void 0),__decorate([e.serialize()],i.prototype,"useGlossinessFromSpecularMapAlpha",void 0),__decorate([e.serialize()],i.prototype,"maxSimultaneousLights",void 0),__decorate([e.serialize()],i.prototype,"invertNormalMapX",void 0),__decorate([e.serialize()],i.prototype,"invertNormalMapY",void 0),__decorate([e.serializeAsTexture()],i.prototype,"cameraColorGradingTexture",void 0),__decorate([e.serializeAsColorCurves()],i.prototype,"cameraColorCurves",void 0),__decorate([e.serialize()],i.prototype,"useLogarithmicDepth",null),e.StandardMaterial=i})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(e,i){var r=t.call(this,e,i,!0)||this;return r.subMaterials=new Array,i.multiMaterials.push(r),r}return __extends(i,t),i.prototype.getSubMaterial=function(e){return e<0||e>=this.subMaterials.length?this.getScene().defaultMaterial:this.subMaterials[e]},i.prototype.getClassName=function(){return"MultiMaterial"},i.prototype.isReady=function(e){for(var t=0;t-1&&o.skeletons){var O=_.indexOf(y.skeletonId)>-1;if(!O)for(var I=0,D=f.skeletons.length;I>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;fp&&(c=p,o=d,n))break}}}if(o){var m=new e.PickingInfo;return m.hit=!0,m.pickedSprite=o,m.distance=c,m}return null},t.prototype.render=function(){if(this._effectBase.isReady()&&this._effectFog.isReady()&&this._spriteTexture&&this._spriteTexture.isReady()){for(var t=this._scene.getEngine(),i=this._spriteTexture.getBaseSize(),r=t.getDeltaTime(),n=Math.min(this._capacity,this.sprites.length),o=i.width/this.cellWidth,s=0,a=0;athis._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._onAnimationEnd&&this._onAnimationEnd(),this.disposeWhenFinishedAnimating&&this.dispose()))))},t.prototype.dispose=function(){for(var e=0;e=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;o-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;r1)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=[{frame:0,value:s},{frame:o,value:a}];return 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=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;t0)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=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: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;sthis._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)}(rthis._keys[this._keys.length-1].frame)&&(r=this._keys[0].frame),(nthis._keys[this._keys.length-1].frame)&&(n=this._keys[this._keys.length-1].frame),r===n&&r++;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 m=this._interpolate(r,0,i.ANIMATIONLOOPMODE_CYCLE),_=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]=_.subtract(m);break;case i.ANIMATIONTYPE_VECTOR3:this._offsetsCache[p]=_.subtract(m);case i.ANIMATIONTYPE_VECTOR2:this._offsetsCache[p]=_.subtract(m);case i.ANIMATIONTYPE_SIZE:this._offsetsCache[p]=_.subtract(m);case i.ANIMATIONTYPE_COLOR3:this._offsetsCache[p]=_.subtract(m)}this._highLimitsCache[p]=_}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[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-1){for(var i=this._animations,r=0,t=i.length-1;t>=0;t--)"string"==typeof e&&i[t].name!=e||(i[t].reset(),i.splice(t,1),r++);i.length==r&&(this._scene._activeAnimatables.splice(t,1),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=.5?.5*(1-this.easeInCore(2*(1-t)))+.5:.5*this.easeInCore(2*t)},e})();t._EASINGMODE_EASEIN=0,t._EASINGMODE_EASEOUT=1,t._EASINGMODE_EASEINOUT=2,e.EasingFunction=t;var i=(function(e){function t(){return e.apply(this,arguments)||this}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);var i=e.call(this)||this;return i.amplitude=t,i}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);var r=e.call(this)||this;return r.bounces=t,r.bounciness=i,r}return __extends(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.bounces),i=this.bounciness;i<=1&&(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(){return e.apply(this,arguments)||this}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);var r=e.call(this)||this;return r.oscillations=t,r.springiness=i,r}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);var i=e.call(this)||this;return i.exponent=t,i}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);var i=e.call(this)||this;return i.power=t,i}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(){return e.apply(this,arguments)||this}return __extends(t,e),t.prototype.easeInCore=function(e){return e*e},t})(t);e.QuadraticEase=c;var l=(function(e){function t(){return e.apply(this,arguments)||this}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(){return e.apply(this,arguments)||this}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(){return e.apply(this,arguments)||this}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);var o=t.call(this)||this;return o.x1=e,o.y1=i,o.x2=r,o.y2=n,o}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){var a=t.call(this,i,r.getScene())||this;return a.name=i,a.children=new Array,a.animations=new Array,a._worldTransform=new e.Matrix,a._absoluteTransform=new e.Matrix,a._invertedAbsoluteTransform=new e.Matrix,a._scaleMatrix=e.Matrix.Identity(),a._scaleVector=new e.Vector3(1,1,1),a._negateScaleChildren=new e.Vector3(1,1,1),a._scalingDeterminant=1,a._syncScaleVector=function(){var t=this.getLocalMatrix(),i=t.m[0]*t.m[0]+t.m[1]*t.m[1]+t.m[2]*t.m[2],r=t.m[4]*t.m[4]+t.m[5]*t.m[5]+t.m[6]*t.m[6],n=t.m[8]*t.m[8]+t.m[9]*t.m[9]+t.m[10]*t.m[10],o=t.m[0]*t.m[1]*t.m[2]*t.m[3]<0?-1:1,s=t.m[4]*t.m[5]*t.m[6]*t.m[7]<0?-1:1,a=t.m[8]*t.m[9]*t.m[10]*t.m[11]<0?-1:1;this._scaleVector.x=o*Math.sqrt(i),this._scaleVector.y=s*Math.sqrt(r),this._scaleVector.z=a*Math.sqrt(n),this._parent&&(this._scaleVector.x/=this._parent._negateScaleChildren.x,this._scaleVector.y/=this._parent._negateScaleChildren.y,this._scaleVector.z/=this._parent._negateScaleChildren.z),e.Matrix.FromValuesToRef(this._scaleVector.x,0,0,0,0,this._scaleVector.y,0,0,0,0,this._scaleVector.z,0,0,0,0,1,this._scaleMatrix)},a._skeleton=r,a._matrix=o,a._baseMatrix=o,a._restPose=s?s:o.clone(),r.bones.push(a),n?(a._parent=n,n.children.push(a)):a._parent=null,a._updateDifferenceMatrix(),a.getAbsoluteTransform().determinant()<0&&(a._scalingDeterminant*=-1),a}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,t){void 0===t&&(t=!0),this._baseMatrix=e.clone(),this._matrix=e.clone(),this._skeleton._markAsDirty(),t&&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=l&&a.frame<=u&&(n?(c=a.value.clone(),_?(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.prototype.translate=function(t,i,r){void 0===i&&(i=e.Space.LOCAL);var n=this.getLocalMatrix();if(i==e.Space.LOCAL)n.m[12]+=t.x,n.m[13]+=t.y,n.m[14]+=t.z;else{this._skeleton.computeAbsoluteTransforms();var o=e.Tmp.Matrix[0],s=e.Tmp.Vector3[0];r?(o.copyFrom(this._parent.getAbsoluteTransform()),o.multiplyToRef(r.getWorldMatrix(),o)):o.copyFrom(this._parent.getAbsoluteTransform()),o.m[12]=0,o.m[13]=0,o.m[14]=0,o.invert(),e.Vector3.TransformCoordinatesToRef(t,o,s),n.m[12]+=s.x,n.m[13]+=s.y,n.m[14]+=s.z}this.markAsDirty()},i.prototype.setPosition=function(t,i,r){void 0===i&&(i=e.Space.LOCAL);var n=this.getLocalMatrix();if(i==e.Space.LOCAL)n.m[12]=t.x,n.m[13]=t.y,n.m[14]=t.z;else{this._skeleton.computeAbsoluteTransforms();var o=e.Tmp.Matrix[0],s=e.Tmp.Vector3[0];r?(o.copyFrom(this._parent.getAbsoluteTransform()),o.multiplyToRef(r.getWorldMatrix(),o)):o.copyFrom(this._parent.getAbsoluteTransform()),o.invert(),e.Vector3.TransformCoordinatesToRef(t,o,s),n.m[12]=s.x,n.m[13]=s.y,n.m[14]=s.z}this.markAsDirty()},i.prototype.setAbsolutePosition=function(t,i){this.setPosition(t,e.Space.WORLD,i)},i.prototype.setScale=function(e,t,i,r){void 0===r&&(r=!1),this.animations[0]&&!this.animations[0].isStopped()&&(r||(this._negateScaleChildren.x=1/e,this._negateScaleChildren.y=1/t,this._negateScaleChildren.z=1/i),this._syncScaleVector()),this.scale(e/this._scaleVector.x,t/this._scaleVector.y,i/this._scaleVector.z,r)},i.prototype.scale=function(t,i,r,n){void 0===n&&(n=!1);var o=this.getLocalMatrix(),s=e.Tmp.Matrix[0];s.copyFrom(o);var a=e.Tmp.Matrix[1];a.copyFrom(s),a.invert();var h=e.Tmp.Matrix[2];e.Matrix.FromValuesToRef(t,0,0,0,0,i,0,0,0,0,r,0,0,0,0,1,h),this._scaleMatrix.multiplyToRef(h,this._scaleMatrix),this._scaleVector.x*=t,this._scaleVector.y*=i,this._scaleVector.z*=r,o.multiplyToRef(a,o),o.multiplyToRef(h,o),o.multiplyToRef(s,o);var c=this.getParent();c?o.multiplyToRef(c.getAbsoluteTransform(),this.getAbsoluteTransform()):this.getAbsoluteTransform().copyFrom(o);var l=this.children.length;h.invert();for(var u=0;u0&&(this._rightHandedSystem=!0,this._bendAxis.x=0,this._bendAxis.y=0,this._bendAxis.z=1),this._bone1.length){var n=this._bone1.getScale(),o=this._bone2.getScale();this._bone1Length=this._bone1.length*n.y*this.mesh.scaling.y,this._bone2Length=this._bone2.length*o.y*this.mesh.scaling.y}else if(this._bone1.children[0]){t.computeWorldMatrix(!0);var s=this._bone2.children[0].getAbsolutePosition(t),a=this._bone2.getAbsolutePosition(t),h=this._bone1.getAbsolutePosition(t);this._bone1Length=e.Vector3.Distance(s,a),this._bone2Length=e.Vector3.Distance(a,h)}this._bone1.getRotationMatrixToRef(e.Space.WORLD,t,this._bone1Mat),this.maxAngle=Math.PI,r&&(r.targetMesh&&(this.targetMesh=r.targetMesh,this.targetMesh.computeWorldMatrix(!0)),r.poleTargetMesh?(this.poleTargetMesh=r.poleTargetMesh,this.poleTargetMesh.computeWorldMatrix(!0)):r.poleTargetBone?this.poleTargetBone=r.poleTargetBone:this._bone1.getParent()&&(this.poleTargetBone=this._bone1.getParent()),r.poleTargetLocalOffset&&this.poleTargetLocalOffset.copyFrom(r.poleTargetLocalOffset),r.poleAngle&&(this.poleAngle=r.poleAngle),r.bendAxis&&this._bendAxis.copyFrom(r.bendAxis),r.maxAngle&&(this.maxAngle=r.maxAngle),r.slerpAmount&&(this.slerpAmount=r.slerpAmount))}return Object.defineProperty(t.prototype,"maxAngle",{get:function(){return this._maxAngle},set:function(e){this._setMaxAngle(e)},enumerable:!0,configurable:!0}),t.prototype._setMaxAngle=function(e){e<0&&(e=0),(e>Math.PI||void 0==e)&&(e=Math.PI),this._maxAngle=e;var t=this._bone1Length,i=this._bone2Length;this._maxReach=Math.sqrt(t*t+i*i-2*t*i*Math.cos(e))},t.prototype.update=function(){var t=this._bone1,i=this.targetPosition,r=this.poleTargetPosition,n=this._tmpMat1,o=this._tmpMat2;this.targetMesh&&i.copyFrom(this.targetMesh.getAbsolutePosition()),this.poleTargetBone?this.poleTargetBone.getAbsolutePositionFromLocalToRef(this.poleTargetLocalOffset,this.mesh,r):this.poleTargetMesh&&e.Vector3.TransformCoordinatesToRef(this.poleTargetLocalOffset,this.poleTargetMesh.getWorldMatrix(),r);var s=this._tmpVec1,a=this._tmpVec2,h=this._tmpVec3,c=this._tmpVec4,l=this._tmpVec5;t.getAbsolutePositionToRef(this.mesh,s),r.subtractToRef(s,l),0==l.x&&0==l.y&&0==l.z?l.y=1:l.normalize(),i.subtractToRef(s,c),c.normalize(),e.Vector3.CrossToRef(c,l,a),a.normalize(),e.Vector3.CrossToRef(c,a,h),h.normalize(),e.Matrix.FromXYZAxesToRef(h,c,a,n);var u=this._bone1Length,f=this._bone2Length,d=e.Vector3.Distance(s,i);this._maxReach>0&&(d=Math.min(this._maxReach,d));var p=(f*f+d*d-u*u)/(2*f*d),m=(d*d+u*u-f*f)/(2*d*u);p>1&&(p=1),m>1&&(m=1),p<-1&&(p=-1),m<-1&&(m=-1);var _=Math.acos(p),g=Math.acos(m),v=-_-g;this._rightHandedSystem?(e.Matrix.RotationYawPitchRollToRef(0,0,.5*Math.PI,o),o.multiplyToRef(n,n),e.Matrix.RotationAxisToRef(this._bendAxis,g,o),o.multiplyToRef(n,n)):(this._tmpVec1.copyFrom(this._bendAxis),this._tmpVec1.x*=-1,e.Matrix.RotationAxisToRef(this._tmpVec1,-g,o),o.multiplyToRef(n,n)),this.poleAngle&&(e.Matrix.RotationAxisToRef(c,this.poleAngle,o),n.multiplyToRef(o,n)),this.slerpAmount<1?(this._slerping||e.Quaternion.FromRotationMatrixToRef(this._bone1Mat,this._bone1Quat),e.Quaternion.FromRotationMatrixToRef(n,this._tmpQuat1),e.Quaternion.SlerpToRef(this._bone1Quat,this._tmpQuat1,this.slerpAmount,this._bone1Quat),v=this._bone2Ang*(1-this.slerpAmount)+v*this.slerpAmount,this._bone1.setRotationQuaternion(this._bone1Quat,e.Space.WORLD,this.mesh),this._slerping=!0):(this._bone1.setRotationMatrix(n,e.Space.WORLD,this.mesh),this._bone1Mat.copyFrom(n),this._slerping=!1),this._bone2.setAxisAngle(this._bendAxis,v,e.Space.LOCAL),this._bone2Ang=v},t})();e.BoneIKController=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(t,i,r,n){this.upAxis=e.Vector3.Up(),this.adjustYaw=0,this.adjustPitch=0,this.adjustRoll=0,this._tmpVec1=e.Vector3.Zero(),this._tmpVec2=e.Vector3.Zero(),this._tmpVec3=e.Vector3.Zero(),this._tmpVec4=e.Vector3.Zero(),this._tmpMat1=e.Matrix.Identity(),this._tmpMat2=e.Matrix.Identity(),this.mesh=t,this.bone=i,this.target=r,n&&(n.adjustYaw&&(this.adjustYaw=n.adjustYaw),n.adjustPitch&&(this.adjustPitch=n.adjustPitch),n.adjustRoll&&(this.adjustRoll=n.adjustRoll))}return t.prototype.update=function(){var t=this.bone,i=this.target,r=this._tmpVec1,n=this._tmpVec2,o=this._tmpVec3,s=this._tmpVec4,a=this._tmpMat1,h=this._tmpMat2;t.getAbsolutePositionToRef(this.mesh,r),i.subtractToRef(r,n),n.normalize(),e.Vector3.CrossToRef(this.upAxis,n,o),o.normalize(),e.Vector3.CrossToRef(n,o,s),s.normalize(),e.Matrix.FromXYZAxesToRef(o,s,n,a),(this.adjustYaw||this.adjustPitch||this.adjustRoll)&&(e.Matrix.RotationYawPitchRollToRef(this.adjustYaw,this.adjustPitch,this.adjustRoll,h),h.multiplyToRef(a,a)),this.bone.setRotationMatrix(a,e.Space.WORLD,this.mesh)},t})();e.BoneLookController=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._lastAbsoluteTransformsUpdateId=-1,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||this.prepare(),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;t-1&&this._meshesWithPoseMatrix.splice(t,1)},t.prototype._computeTransformMatrices=function(e,t){for(var i=0;i0&&(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-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;o0&&(e=this._meshesWithPoseMatrix[0].getPoseMatrix()),e},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;c0){for(var t=0;t0&&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)},t.prototype.directRender=function(e,t){for(var i=this._scene.getEngine(),r=0;r-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})();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,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:e<=0&&(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;ta?a:Math.floor(h);var c,l,u,f,d=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,p=[],m=[],_=[],g=[],v=[],y=[],x=[],b=[],A=[],T=[];if(r.length<2){var E=[],P=[];for(u=0;u0&&(O=M[f].subtract(M[f-1]).length(),I=O+x[l],v[l].push(I),x[l]=I),f++;o&&(f--,p.push(M[0].x,M[0].y,M[0].z),O=M[f].subtract(M[0]).length(),I=O+x[l],v[l].push(I),x[l]=I),A[l]=S+R,T[l]=C,C+=S+R}var D,L,w,B;for(u=0;u1?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;g<=u;g++){for(var v=g/u,y=v*Math.PI*h,x=0;x<=f;x++){var b=x/f,A=b*Math.PI*2*a,T=e.Matrix.RotationZ(-y),E=e.Matrix.RotationY(A),P=e.Vector3.TransformCoordinates(e.Vector3.Up(),T),M=e.Vector3.TransformCoordinates(P,E),S=M.multiply(l),C=M.divide(l).normalize();p.push(S.x,S.y,S.z),m.push(C.x,C.y,C.z),_.push(b,v)}if(g>0)for(var R=p.length/3,O=R-2*(f+1);O+f+21?1:i.arc||1,f=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,d=i.faceUV||new Array(3),p=i.faceColors,m=1!==u&&l?2:0,_=c?h:1,g=2+(1+m)*_;for(r=0;r0&&(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,m=0,_=0;for(_=0;_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;d=r.length?0:i.type||0,u=i.size,f=i.sizeX||u||1,d=i.sizeY||u||1,p=i.sizeZ||u||1,m=i.custom||r[l],_=m.face.length,g=i.faceUV||new Array(_),v=i.faceColors,y=void 0===i.flat||i.flat,x=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,b=[],A=[],T=[],E=[],P=[],M=0,S=0,C=[],R=0,O=0;if(y)for(O=0;O<_;O++)v&&void 0===v[O]&&(v[O]=new e.Color4(1,1,1,1)),g&&void 0===g[O]&&(g[O]=new e.Vector4(0,0,1,1));if(y)for(O=0;O<_;O++){var I=m.face[O].length;for(s=2*Math.PI/I,a=.5*Math.tan(s/2),h=.5,R=0;R1)for(var h=0;hthis.value;case i.IsLesser:return this._effectiveTarget[this._property]-1&&this._scene._actionManagers.splice(e,1)},t.prototype.getScene=function(){return this._scene},t.prototype.hasSpecificTriggers=function(e){for(var t=0;t-1)return!0}return!1},t.prototype.hasSpecificTrigger=function(e){for(var t=0;t=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=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;r0;if(2===i.type?f.push(o):f.push(r),m){for(var _=new Array,g=0;g0){var f=u.properties[0].value,d=null===u.properties[0].targetType?f:n.getMeshByName(f);d._meshId&&(d.mesh=n.getMeshByID(d._meshId)),l={trigger:e.ActionManager[u.name],parameter:d}}else l=e.ActionManager[u.name];for(var p=0;p0&&(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){if(this.delayLoadState!==e.Engine.DELAYLOADSTATE_LOADING){if(this.isReady())return void(i&&i());this.delayLoadState=e.Engine.DELAYLOADSTATE_LOADING,this._queueLoad(t,i)}},t.prototype._queueLoad=function(t,i){var r=this;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;a0){for(var i=0;i0){for(var i=0;i0){for(var i=0;i0){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 m=new Float32Array(t,s.colorsAttrDesc.offset,s.colorsAttrDesc.count);i.setVerticesData(e.VertexBuffer.ColorKind,m,!1,s.colorsAttrDesc.stride)}if(s.matricesIndicesAttrDesc&&s.matricesIndicesAttrDesc.count>0){var _=new Int32Array(t,s.matricesIndicesAttrDesc.offset,s.matricesIndicesAttrDesc.count);i.setVerticesData(e.VertexBuffer.MatricesIndicesKind,_,!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>8),M.push((16711680&S)>>16),M.push(S>>24)}i.setVerticesData(e.VertexBuffer.MatricesIndicesKind,M,!1)}if(t.matricesIndicesExtra)if(t.matricesIndicesExtra._isExpanded)delete t.matricesIndices._isExpanded,i.setVerticesData(e.VertexBuffer.MatricesIndicesExtraKind,t.matricesIndicesExtra,!1);else{for(var M=[],x=0;x>8),M.push((16711680&S)>>16),M.push(S>>24)}i.setVerticesData(e.VertexBuffer.MatricesIndicesExtraKind,M,!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 C=0;Cthis._maxX||tthis._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,!(ethis._maxX||tthis._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=(this._subdivisionsX,this._subdivisionsY,Math.floor((e+this._maxX)*this._subdivisionsX/this._width)),n=Math.floor(-(t+this._maxZ)*this._subdivisionsY/this._height+this._subdivisionsY),o=this._heightQuads[n*this._subdivisionsX+r];return i=t0&&(c=!0,this._soundLoaded(i));break;case"String":h.push(i);case"Array":0===h.length&&(h=i);for(var l=0;l0&&(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.prototype.serialize=function(){var e={name:this.name,url:this.name,autoplay:this.autoplay,loop:this.loop,volume:this._volume,spatialSound:this.spatialSound,maxDistance:this.maxDistance,rolloffFactor:this.rolloffFactor,refDistance:this.refDistance,distanceModel:this.distanceModel,playbackRate:this._playbackRate,panningModel:this._panningModel,soundTrackId:this.soundTrackId};return this.spatialSound&&(this._connectedMesh&&(e.connectedMeshId=this._connectedMesh.id),e.position=this._position.asArray(),e.refDistance=this.refDistance,e.distanceModel=this.distanceModel,e.isDirectional=this._isDirectional,e.localDirectionToMesh=this._localDirection.asArray(),e.coneInnerAngle=this._coneInnerAngle,e.coneOuterAngle=this._coneOuterAngle,e.coneOuterGain=this._coneOuterGain),e},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&&(t.soundTrackId===-1?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);t!==-1&&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;t4&&(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 u=n.join("\n");return this._cachedDefines!==u&&(this._cachedDefines=u,this._glowMapGenerationEffect=this._scene.getEngine().createEffect("glowMapGeneration",o,["world","mBones","viewProjection","diffuseMatrix","color","emissiveMatrix"],["diffuseSampler","emissiveSampler"],u)),this._glowMapGenerationEffect.isReady()},i.prototype.render=function(){var t=this._glowMapMergeEffect;if(t.isReady()&&this._blurTexture.isReady()){var i=this._scene.getEngine();this.onBeforeComposeObservable.notifyObservers(this),i.enableEffect(t),i.setState(!1);var r=i.getStencilBuffer(),n=i.getStencilFunction(),o=i.getStencilMask(),s=i.getAlphaMode();t.setTexture("textureSampler",this._blurTexture),i.bindBuffers(this._vertexBuffers,this._indexBuffer,t),i.setAlphaMode(this._options.alphaBlendingMode),i.setStencilMask(0),i.setStencilBuffer(!0),i.setStencilFunctionReference(this._instanceGlowingMeshStencilReference),this.outerGlow&&(t.setFloat("offset",0),i.setStencilFunction(e.Engine.NOTEQUAL),i.draw(!0,0,6)),this.innerGlow&&(t.setFloat("offset",1),i.setStencilFunction(e.Engine.EQUAL),i.draw(!0,0,6)),i.setStencilFunction(n),i.setStencilMask(o),i.setAlphaMode(s),i.setStencilBuffer(r),this.onAfterComposeObservable.notifyObservers(this);var a=this._mainTexture.getSize();this.setMainTextureSize(),a.width===this._mainTextureDesiredSize.width&&a.height===this._mainTextureDesiredSize.height||(this.onSizeChangedObservable.notifyObservers(this),this.disposeTextureAndPostProcesses(),this.createTextureAndPostProcesses())}},i.prototype.addExcludedMesh=function(e){var t=this._excludedMeshes[e.uniqueId];t||(this._excludedMeshes[e.uniqueId]={mesh:e,beforeRender:e.onBeforeRenderObservable.add((function(e){e.getEngine().setStencilBuffer(!1)})),afterRender:e.onAfterRenderObservable.add((function(e){e.getEngine().setStencilBuffer(!0)}))})},i.prototype.removeExcludedMesh=function(e){var t=this._excludedMeshes[e.uniqueId];t&&(e.onBeforeRenderObservable.remove(t.beforeRender),e.onAfterRenderObservable.remove(t.afterRender)),this._excludedMeshes[e.uniqueId]=void 0},i.prototype.addMesh=function(e,t,i){var r=this;void 0===i&&(i=!1);var n=this._meshes[e.uniqueId];n?n.color=t:this._meshes[e.uniqueId]={mesh:e,color:t,observerHighlight:e.onBeforeRenderObservable.add((function(e){r._excludedMeshes[e.uniqueId]?r.defaultStencilReference(e):e.getScene().getEngine().setStencilFunctionReference(r._instanceGlowingMeshStencilReference)})),observerDefault:e.onAfterRenderObservable.add(this.defaultStencilReference),glowEmissiveOnly:i},this._shouldRender=!0},i.prototype.removeMesh=function(e){var t=this._meshes[e.uniqueId];t&&(e.onBeforeRenderObservable.remove(t.observerHighlight),e.onAfterRenderObservable.remove(t.observerDefault)),this._meshes[e.uniqueId]=void 0,this._shouldRender=!1;for(var i in this._meshes)if(i){this._shouldRender=!0;break}},i.prototype.shouldRender=function(){return this.isEnabled&&this._shouldRender},i.prototype.setMainTextureSize=function(){this._options.mainTextureFixedSize?(this._mainTextureDesiredSize.width=this._options.mainTextureFixedSize,this._mainTextureDesiredSize.height=this._options.mainTextureFixedSize):(this._mainTextureDesiredSize.width=this._engine.getRenderingCanvas().width*this._options.mainTextureRatio,this._mainTextureDesiredSize.height=this._engine.getRenderingCanvas().height*this._options.mainTextureRatio,this._mainTextureDesiredSize.width=e.Tools.GetExponentOfTwo(this._mainTextureDesiredSize.width,this._maxSize),this._mainTextureDesiredSize.height=e.Tools.GetExponentOfTwo(this._mainTextureDesiredSize.height,this._maxSize))},i.prototype.defaultStencilReference=function(e){e.getScene().getEngine().setStencilFunctionReference(i.normalMeshStencilReference)},i.prototype.disposeTextureAndPostProcesses=function(){this._blurTexture.dispose(),this._mainTexture.dispose(),this._downSamplePostprocess.dispose(),this._horizontalBlurPostprocess.dispose(),this._verticalBlurPostprocess.dispose()},i.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.disposeTextureAndPostProcesses();for(var i in this._meshes){var r=this._meshes[i];r&&r.mesh&&(r.mesh.onBeforeRenderObservable.remove(r.observerHighlight),r.mesh.onAfterRenderObservable.remove(r.observerDefault))}this._meshes=null;for(var i in this._excludedMeshes){var r=this._excludedMeshes[i];r&&(r.mesh.onBeforeRenderObservable.remove(r.beforeRender),r.mesh.onAfterRenderObservable.remove(r.afterRender))}this._excludedMeshes=null;var n=this._scene.highlightLayers.indexOf(this,0);n>-1&&this._scene.highlightLayers.splice(n,1),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this.onBeforeRenderMainTextureObservable.clear(),this.onBeforeBlurObservable.clear(),this.onBeforeComposeObservable.clear(),this.onAfterComposeObservable.clear(),this.onSizeChangedObservable.clear()},i})();i.neutralColor=new e.Color4(0,0,0,0),i.glowingMeshStencilReference=2,i.normalMeshStencilReference=1,e.HighlightLayer=i})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(){}return e.TransformCoordinatesToRefSIMD=function(t,i,r){e.TransformCoordinatesFromFloatsToRefSIMD(t.x,t.y,t.z,i,r)},e.TransformCoordinatesFromFloatsToRefSIMD=function(e,t,i,r,n){var o=r.m,s=SIMD.Float32x4.load(o,0),a=SIMD.Float32x4.load(o,4),h=SIMD.Float32x4.load(o,8),c=SIMD.Float32x4.load(o,12),l=SIMD.Float32x4.add(SIMD.Float32x4.add(SIMD.Float32x4.mul(SIMD.Float32x4.splat(e),s),SIMD.Float32x4.mul(SIMD.Float32x4.splat(t),a)),SIMD.Float32x4.add(SIMD.Float32x4.mul(SIMD.Float32x4.splat(i),h),c));l=SIMD.Float32x4.div(l,SIMD.Float32x4.swizzle(l,3,3,3,3)),n.x=SIMD.Float32x4.extractLane(l,0),n.y=SIMD.Float32x4.extractLane(l,1),n.z=SIMD.Float32x4.extractLane(l,2)},e})(),i=(function(){function e(){}return e.prototype.multiplyToArraySIMD=function(e,t,i){for(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=0;c<16;c+=4)SIMD.Float32x4.store(t,c+i,SIMD.Float32x4.add(SIMD.Float32x4.mul(SIMD.Float32x4.splat(r[c]),o),SIMD.Float32x4.add(SIMD.Float32x4.mul(SIMD.Float32x4.splat(r[c+1]),s),SIMD.Float32x4.add(SIMD.Float32x4.mul(SIMD.Float32x4.splat(r[c+2]),a),SIMD.Float32x4.mul(SIMD.Float32x4.splat(r[c+3]),h)))));return this},e.prototype.invertToRefSIMD=function(e){var t=this.m,i=e.m,r=SIMD.Float32x4.load(t,0),n=SIMD.Float32x4.load(t,4),o=SIMD.Float32x4.load(t,8),s=SIMD.Float32x4.load(t,12),a=SIMD.Float32x4.shuffle(r,n,0,1,4,5),h=SIMD.Float32x4.shuffle(o,s,0,1,4,5),c=SIMD.Float32x4.shuffle(a,h,0,2,4,6);h=SIMD.Float32x4.shuffle(h,a,1,3,5,7),a=SIMD.Float32x4.shuffle(r,n,2,3,6,7);var l=SIMD.Float32x4.shuffle(o,s,2,3,6,7),u=SIMD.Float32x4.shuffle(a,l,0,2,4,6);l=SIMD.Float32x4.shuffle(l,a,1,3,5,7),a=SIMD.Float32x4.mul(u,l),a=SIMD.Float32x4.swizzle(a,1,0,3,2);var f=SIMD.Float32x4.mul(h,a),d=SIMD.Float32x4.mul(c,a);a=SIMD.Float32x4.swizzle(a,2,3,0,1),f=SIMD.Float32x4.sub(SIMD.Float32x4.mul(h,a),f),d=SIMD.Float32x4.sub(SIMD.Float32x4.mul(c,a),d),d=SIMD.Float32x4.swizzle(d,2,3,0,1),a=SIMD.Float32x4.mul(h,u),a=SIMD.Float32x4.swizzle(a,1,0,3,2),f=SIMD.Float32x4.add(SIMD.Float32x4.mul(l,a),f);var p=SIMD.Float32x4.mul(c,a);a=SIMD.Float32x4.swizzle(a,2,3,0,1),f=SIMD.Float32x4.sub(f,SIMD.Float32x4.mul(l,a)),p=SIMD.Float32x4.sub(SIMD.Float32x4.mul(c,a),p),p=SIMD.Float32x4.swizzle(p,2,3,0,1),a=SIMD.Float32x4.mul(SIMD.Float32x4.swizzle(h,2,3,0,1),l),a=SIMD.Float32x4.swizzle(a,1,0,3,2),u=SIMD.Float32x4.swizzle(u,2,3,0,1),f=SIMD.Float32x4.add(SIMD.Float32x4.mul(u,a),f);var m=SIMD.Float32x4.mul(c,a);a=SIMD.Float32x4.swizzle(a,2,3,0,1),f=SIMD.Float32x4.sub(f,SIMD.Float32x4.mul(u,a)),m=SIMD.Float32x4.sub(SIMD.Float32x4.mul(c,a),m),m=SIMD.Float32x4.swizzle(m,2,3,0,1),a=SIMD.Float32x4.mul(c,h),a=SIMD.Float32x4.swizzle(a,1,0,3,2),m=SIMD.Float32x4.add(SIMD.Float32x4.mul(l,a),m),p=SIMD.Float32x4.sub(SIMD.Float32x4.mul(u,a),p),a=SIMD.Float32x4.swizzle(a,2,3,0,1),m=SIMD.Float32x4.sub(SIMD.Float32x4.mul(l,a),m),p=SIMD.Float32x4.sub(p,SIMD.Float32x4.mul(u,a)),a=SIMD.Float32x4.mul(c,l),a=SIMD.Float32x4.swizzle(a,1,0,3,2),d=SIMD.Float32x4.sub(d,SIMD.Float32x4.mul(u,a)),m=SIMD.Float32x4.add(SIMD.Float32x4.mul(h,a),m),a=SIMD.Float32x4.swizzle(a,2,3,0,1),d=SIMD.Float32x4.add(SIMD.Float32x4.mul(u,a),d),m=SIMD.Float32x4.sub(m,SIMD.Float32x4.mul(h,a)),a=SIMD.Float32x4.mul(c,u),a=SIMD.Float32x4.swizzle(a,1,0,3,2),d=SIMD.Float32x4.add(SIMD.Float32x4.mul(l,a),d),p=SIMD.Float32x4.sub(p,SIMD.Float32x4.mul(h,a)),a=SIMD.Float32x4.swizzle(a,2,3,0,1),d=SIMD.Float32x4.sub(d,SIMD.Float32x4.mul(l,a)),p=SIMD.Float32x4.add(SIMD.Float32x4.mul(h,a),p);var _=SIMD.Float32x4.mul(c,f);return _=SIMD.Float32x4.add(SIMD.Float32x4.swizzle(_,2,3,0,1),_),_=SIMD.Float32x4.add(SIMD.Float32x4.swizzle(_,1,0,3,2),_),a=SIMD.Float32x4.reciprocalApproximation(_),_=SIMD.Float32x4.sub(SIMD.Float32x4.add(a,a),SIMD.Float32x4.mul(_,SIMD.Float32x4.mul(a,a))),_=SIMD.Float32x4.swizzle(_,0,0,0,0),SIMD.Float32x4.store(i,0,SIMD.Float32x4.mul(_,f)),SIMD.Float32x4.store(i,4,SIMD.Float32x4.mul(_,d)),SIMD.Float32x4.store(i,8,m=SIMD.Float32x4.mul(_,m)),SIMD.Float32x4.store(i,12,SIMD.Float32x4.mul(_,p)),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),m=SIMD.Float32x4.shuffle(d,p,0,2,4,6),_=SIMD.Float32x4.shuffle(d,p,1,3,5,7),g=SIMD.Float32x4.shuffle(SIMD.Float32x4.shuffle(l,u,2,3,6,7),SIMD.Float32x4.shuffle(h,f,2,3,6,7),0,2,4,6),v=SIMD.Float32x4(0,0,0,1),y=SIMD.Float32x4(1,0,0,0);SIMD.Float32x4.store(n,0,SIMD.Float32x4.add(SIMD.Float32x4.mul(SIMD.Float32x4.swizzle(y,0,0,0,0),m),SIMD.Float32x4.add(SIMD.Float32x4.mul(SIMD.Float32x4.swizzle(y,1,1,1,1),_),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))))),y=SIMD.Float32x4(0,1,0,0),SIMD.Float32x4.store(n,4,SIMD.Float32x4.add(SIMD.Float32x4.mul(SIMD.Float32x4.swizzle(y,0,0,0,0),m),SIMD.Float32x4.add(SIMD.Float32x4.mul(SIMD.Float32x4.swizzle(y,1,1,1,1),_),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))))),y=SIMD.Float32x4(0,0,1,0),SIMD.Float32x4.store(n,8,SIMD.Float32x4.add(SIMD.Float32x4.mul(SIMD.Float32x4.swizzle(y,0,0,0,0),m),SIMD.Float32x4.add(SIMD.Float32x4.mul(SIMD.Float32x4.swizzle(y,1,1,1,1),_),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))))),y=SIMD.Float32x4.replaceLane(SIMD.Float32x4.neg(s),3,1),SIMD.Float32x4.store(n,12,SIMD.Float32x4.add(SIMD.Float32x4.mul(SIMD.Float32x4.swizzle(y,0,0,0,0),m),SIMD.Float32x4.add(SIMD.Float32x4.mul(SIMD.Float32x4.swizzle(y,1,1,1,1),_),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)))))},e})(),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!==self.SIMD&&(self.Math.fround||(self.Math.fround=(function(e){return function(t){return e[0]=t,e[0]}})(new Float32Array(1))),self.Math.imul||(self.Math.imul=function(e,t){var i=e>>>16&65535,r=65535&e,n=t>>>16&65535,o=65535&t;return r*o+(i*o+r*n<<16>>>0)|0}),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,h._isEnabled=!0)},h})();h._isEnabled=!1,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,this._contentSize=null,this._bottomNode=null,this._leftNode=null,this._initialSize=null,this._rightNode=null}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(){return this.getUVsForCustomSize(this._root._size)},enumerable:!0,configurable:!0}),t.prototype.getUVsForCustomSize=function(t){var i=this._root._size.width,r=this._root._size.height,n=new e.Vector2(this._pos.x/i,this._pos.y/r),o=new e.Vector2((this._pos.x+t.width-1)/i,(this._pos.y+t.height-1)/r),s=new Array;return s.push(n),s.push(new e.Vector2(o.x,n.y)),s.push(o),s.push(new e.Vector2(n.x,o.y)),s},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;if(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));else if(this._initialSize){if(!(e.width<=this._initialSize.width&&e.height<=this._initialSize.height))return null;t=this}else e.width<=this._size.width&&e.height<=this._size.height&&(t=this);return t},t.prototype.splitNode=function(i){return!this._contentSize&&this._initialSize?(this._contentSize=i.clone(),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){var r=t.call(this,null,null,e.Vector2.Zero(),i)||this;return r._root=r,r}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;r0?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=h);l++){var u=n[l],f=u.offset,d=f-c;if(d!==i){for(var p=d/i-1,m=f-i,_=Math.min(a,p),g=0;g<_;g++){var v=s/i,y=m/i,x=o[y];this._moveElement(x,s);var b=o[v];b.offset=m,o[v]=x,o[y]=b,m-=i,s+=i}a<=p?(s=m+i,a=1+_):a=(f-s)/i+1,c=f}else++a,c=f}var A=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,A},e.prototype._moveElement=function(e,t){for(var i=0;io.width&&(this._currentFreePosition.x=0,this._currentFreePosition.y+=this._lineHeightSuper+this._yMargin,this._currentFreePosition.y>o.height))return this.getChar("!");if(this._signedDistanceField){this._sdfContext.clearRect(0,0,this._sdfCanvas.width,this._sdfCanvas.height),this._sdfContext.fillText(i,0,-this._offset);var a=this._sdfContext.getImageData(0,0,s*this._sdfScale,this._sdfCanvas.height),h=this._computeSDFChar(a);this._context.putImageData(h,this._currentFreePosition.x,this._currentFreePosition.y)}else this._context.fillText(i,this._currentFreePosition.x,this._currentFreePosition.y-this._offset);if(r.topLeftUV=new e.Vector2(this._currentFreePosition.x/o.width,this._currentFreePosition.y/o.height),r.bottomRightUV=new e.Vector2((this._currentFreePosition.x+s)/o.width,r.topLeftUV.y+(this._lineHeightSuper+2)/o.height),this._signedDistanceField){var c=1/o.width;r.topLeftUV.addInPlace(new e.Vector2(c,c)),r.bottomRightUV.addInPlace(new e.Vector2(c,c))}return r.charWidth=this._superSample?s/2:s,this._charInfos[i]=r,this._curCharCount++,this._currentFreePosition.x+=s+this._xMargin,r},r.prototype._computeSDFChar=function(e){for(var t=this._sdfScale,i=e.width,r=e.height,n=i/t,o=r/t,s=0,a=0,h=t,c=h-1,l=function(n,o,h,c,l){var u=n*t,f=o*t;if(u+h<0||u+h>=i||f+c<0||f+c>=r)return!0;var d=e.data[4*((f+c)*i+(u+h))],p=d>0===l;return p||(s=h,a=c),p},u=function(e,t,i){if(l(e,t,0,c,i)&&l(e,t,0,-c,i)&&l(e,t,-c,0,i)&&l(e,t,c,0,i))return 0;for(var r=1;r<=h;r++){if(!(l(e,t,0,r,i)&&l(e,t,0,-r,i)&&l(e,t,-r,0,i)&&l(e,t,r,0,i)))return r*r;for(var n=1;n<=r;n++)if(!(l(e,t,-n,r,i)&&l(e,t,n,r,i)&&l(e,t,r,-n,i)&&l(e,t,r,n,i)&&l(e,t,-n,-r,i)&&l(e,t,n,-r,i)&&l(e,t,-r,-n,i)&&l(e,t,-r,n,i))){var o=r*r+n*n,u=1;return l(e,t,s-1,a,i)||(o+=(s-1)*(s-1)+a*a,++u),l(e,t,s+1,a,i)||(o+=(s+1)*(s+1)+a*a,++u),l(e,t,s,a-1,i)||(o+=s*s+(a-1)*(a-1),++u),l(e,t,s,a+1,i)||(o+=s*s+(a+1)*(a+1),++u),l(e,t,s-1,a-1,i)||(o+=(s-1)*(s-1)+(a-1)*(a-1),++u),l(e,t,s+1,a+1,i)||(o+=(s+1)*(s+1)+(a+1)*(a+1),++u),l(e,t,s+1,a-1,i)||(o+=(s+1)*(s+1)+(a-1)*(a-1),++u),l(e,t,s-1,a+1,i)||(o+=(s-1)*(s-1)+(a+1)*(a+1),++u),o/u}}return 0},f=new Array(n*o),d=0;d255&&(_=255),_+=.5,g.data[4*y+0]=_,g.data[4*y+1]=_,g.data[4*y+2]=_,g.data[4*y+3]=255}return g},r.prototype.measureText=function(t,i){void 0===i&&(i=4);for(var r=0,n=0,o=1,s=0,a=0,h=t;a>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,m=1,_=2,g=3,v=4,y=7,x=20,b=21,A=22,T=28,E=(function(){function t(){}return t.GetDDSInfo=function(e){var t=new Int32Array(e,0,d),i=1;return t[_]&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[T]&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;c=0;h--)for(var c=0;c=0;h--)for(var c=0;ct.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;rh||r.deleted||r.isDirty))for(var o=0;o<3;++o)if(r.error[o]>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();for(var n=0;n<3;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;r<3;++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;i0&&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,_,d,m,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.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;o80*r){l=f=e[0],u=d=e[1];for(var g=r;gf&&(f=p),m>d&&(d=m);_=Math.max(f-l,d-u)}return n(a,h,r,l,u,_,void 0),h}function i(e,t,i,r,n){var o,s;if(n===O(e,t,i,r)>0)for(o=t;o=t;o-=r)s=M(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,m=e.next,u?s(e,c,l,u):o(e))t.push(p.i/i),t.push(e.i/i),t.push(m.i/i),S(e),e=m.next,_=m.next;else if(e=m,e===_){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.xo.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=m(a,h,t,i,r),f=m(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)&&T(n,o)&&T(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=P(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;s=r.next.y){var a=r.x+(o-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(a<=n&&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.x&&r.x>=l&&g(oi.x)&&T(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=m(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;t0||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 m(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 _(e){var t=e,i=e;do t.x=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&&!A(e,t)&&T(e,t)&&T(t,e)&&E(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))||y(e,t,i)>0!=y(e,t,r)>0&&y(i,r,e)>0!=y(i,r,t)>0}function A(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 T(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 E(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 P(e,t){var i=new C(e.i,e.x,e.y),r=new C(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 M(e,t,i,r){var n=new C(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 C(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 R(e,t,i,r){var n=t&&t.length,o=n?t[0]*i:e.length,s=Math.abs(O(e,0,o,i));if(n)for(var a=0,h=t.length;a0&&(r+=e[n-1].length,i.holes.push(r))}return i}e.earcut=t,e.deviation=R,e.flatten=I})(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,m=[];for(h=0;ht.EPSILON?u:l;p|=_,m.push(_)}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=3&&(P=new n(g,i.shared),P.plane&&s.push(P)),v.length>=3&&(P=new n(v,i.shared),P.plane&&a.push(P))}},t})();r.EPSILON=1e-5;var 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;ei.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));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})();i._globalJoystickIndex=0,e.VirtualJoystick=i})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(e){function t(t,i,r){var n=e.call(this,t,i,r)||this;return n.inputs.addVirtualJoystick(),n}return __extends(t,e),t.prototype.getClassName=function(){return"VirtualJoysticksCamera"},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=e.call(this,t,"anaglyph",null,["leftSampler"],i,r[1],n,o,s)||this;return a._passedProcess=r[0]._rigPostProcess,a.onApplyObservable.add((function(e){e.setTextureFromPostProcess("leftSampler",a._passedProcess)})),a}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 t(e,t){this.name=e,this.url=t,this.isCompleted=!1}return t.prototype.run=function(t,i,r){var n=this,o=new Image;e.Tools.SetCorsBehavior(this.url,o),o.onload=function(){n.image=o,n.isCompleted=!0,n.onSuccess&&n.onSuccess(n),i()},o.onerror=function(){n.onError&&n.onError(n),r()},o.src=this.url},t})();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 t(e,t,i,r,n){this.name=e,this.url=t,this.extensions=i,this.noMipmap=r,this.files=n,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.CubeTexture(this.url,t,this.extensions,this.noMipmap,this.files,o,s)},t})();e.CubeTextureAssetTask=s;var a=(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;e0){if(a._vrEnabled=!0,a.webVROptions.displayName){var i=t.some((function(e){return e.displayName===a.webVROptions.displayName&&(a._vrDevice=e,!0)}));i||(a._vrDevice=t[0],e.Tools.Warn("Display "+a.webVROptions.displayName+" was not found. Using "+a._vrDevice.displayName))}else a._vrDevice=t[0];a.setCameraRigMode(e.Camera.RIG_MODE_WEBVR,{vrDisplay:a._vrDevice,frameData:a._frameData}),a._attached&&a.getEngine().enableVR(a._vrDevice)}else e.Tools.Error("No WebVR devices found!")}))):e.Tools.Error("WebVR is not enabled on your browser"),a.rotationQuaternion=new e.Quaternion,a._quaternionCache=new e.Quaternion,a}return __extends(i,t),i.prototype._checkInputs=function(){if(this._vrEnabled&&this._vrDevice.getFrameData(this._frameData)){var e=this._frameData.pose;e&&e.orientation&&(this._cacheState=e,this.rotationQuaternion.copyFromFloats(this._cacheState.orientation[0],this._cacheState.orientation[1],-this._cacheState.orientation[2],-this._cacheState.orientation[3]),this.webVROptions.trackPosition&&this._cacheState.position&&(this.position.copyFromFloats(this._cacheState.position[0],this._cacheState.position[1],-this._cacheState.position[2]),this.webVROptions.positionScale&&this.position.scaleInPlace(this.webVROptions.positionScale),this.position.addInPlace(this._positionOffset)))}t.prototype._checkInputs.call(this)},i.prototype.attachControl=function(i,r){t.prototype.attachControl.call(this,i,r),this._attached=!0,r=!e.Camera.ForceAttachControlToAlwaysPreventDefault&&r,this._vrEnabled&&this.getEngine().enableVR(this._vrDevice)},i.prototype.detachControl=function(e){t.prototype.detachControl.call(this,e),this._vrEnabled=!1,this._attached=!1,this.getEngine().disableVR()},i.prototype.requestVRFullscreen=function(t){e.Tools.Warn("requestVRFullscreen is deprecated. call attachControl() to start sending frames to the VR display.")},i.prototype.getClassName=function(){return"WebVRFreeCamera"; -},i.prototype.resetToCurrentRotation=function(){this._vrDevice.resetPose()},i.prototype.setPositionOffset=function(e){e?this._positionOffset=e:this._positionOffset.copyFrom(this.position)},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){void 0===t&&(t=0),void 0===i&&(i=1024);var r=e.call(this,t)||this;return r.priority=t,r.maximumSize=i,r.apply=function(e){for(var t=!0,i=0;ir.maximumSize&&(n.scale(.5),t=!1)}}return t},r}return __extends(t,e),t})(t);e.TextureOptimization=i;var r=(function(e){function t(t,i){void 0===t&&(t=0),void 0===i&&(i=2);var r=e.call(this,t)||this;return r.priority=t,r.maximumScale=i,r._currentScale=1,r.apply=function(e){return r._currentScale++,e.getEngine().setHardwareScalingLevel(r._currentScale),r._currentScale>=r.maximumScale},r}return __extends(t,e),t})(t);e.HardwareScalingOptimization=r;var n=(function(e){function t(){var t=e.apply(this,arguments)||this;return t.apply=function(e){return e.shadowsEnabled=!1,!0},t}return __extends(t,e),t})(t);e.ShadowsOptimization=n;var o=(function(e){function t(){var t=e.apply(this,arguments)||this;return t.apply=function(e){return e.postProcessesEnabled=!1,!0},t}return __extends(t,e),t})(t);e.PostProcessesOptimization=o;var s=(function(e){function t(){var t=e.apply(this,arguments)||this;return t.apply=function(e){return e.lensFlaresEnabled=!1,!0},t}return __extends(t,e),t})(t);e.LensFlaresOptimization=s;var a=(function(e){function t(){var t=e.apply(this,arguments)||this;return t.apply=function(e){return e.particlesEnabled=!1,!0},t}return __extends(t,e),t})(t);e.ParticlesOptimization=a;var h=(function(e){function t(){var t=e.apply(this,arguments)||this;return t.apply=function(e){return e.renderTargetsEnabled=!1,!0},t}return __extends(t,e),t})(t);e.RenderTargetsOptimization=h;var c=(function(t){function i(){var r=t.apply(this,arguments)||this;return r._canBeMerged=function(t){if(!(t instanceof e.Mesh))return!1;var i=t;return!(!i.isVisible||!i.isEnabled())&&(!(i.instances.length>0)&&(!i.skeleton&&!i.hasLODLevels&&!i.parent))},r.apply=function(t,n){for(var o=t.meshes.slice(0),s=o.length,a=0;a=i.targetFrameRate)return void(n&&n());for(var s=!0,a=!0,h=0;hi.x&&(i.x=e.x),e.yi.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;h0){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;us.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),m=new e.Vector3(f.x,0,f.y),_=m.subtract(p),g=new e.Vector3(0,1,0),v=e.Vector3.Cross(_,g);v=v.normalize(),r.push(l/o.width,0),r.push(l/o.width,1),l+=_.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;tthis.capacity&&this._depth0&&(t.x-=this.viewportBorder,t.y-=this.viewportBorder,t.width+=2*this.viewportBorder,t.height+=2*this.viewportBorder,i.x+=this.viewportBorder,i.y+=this.viewportBorder,this._positionX+=this.viewportBorder,this._positionY+=this.viewportBorder),i.z>0&&(this._positionX>t.x&&this._positionXt.y&&this._positionYr},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._positionXr.x+r.width-this.borderLimit?this._positionX-r.x-r.width+this.borderLimit:0,o=this._positionYr.y+r.height-this.borderLimit?this._positionY-r.y-r.height+this.borderLimit:0;var s=n>o?n:o;s-=this.viewportBorder,s>this.borderLimit&&(s=this.borderLimit);var a=1-s/this.borderLimit;if(a<0)return!1;a>1&&(a=1),this.viewportBorder>0&&(r.x+=this.viewportBorder,r.y+=this.viewportBorder,r.width-=2*this.viewportBorder,r.height-=2*this.viewportBorder,this._positionX-=this.viewportBorder,this._positionY-=this.viewportBorder);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.bindBuffers(this._vertexBuffers,this._indexBuffer,this._effect);for(var f=0;f=2&&(this._leftStick={x:this.browserGamepad.axes[this._leftStickAxisX],y:this.browserGamepad.axes[this._leftStickAxisY]}),this.browserGamepad.axes.length>=4&&(this._rightStick={x:this.browserGamepad.axes[this._rightStickAxisX],y:this.browserGamepad.axes[this._rightStickAxisY]})}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[this._leftStickAxisX],y:this.browserGamepad.axes[this._leftStickAxisY]}),this._rightStick&&(this.rightStick={x:this.browserGamepad.axes[this._rightStickAxisX],y:this.browserGamepad.axes[this._rightStickAxisY]})},e})();e.Gamepad=r;var n=(function(e){function t(t,i,r){var n=e.call(this,t,i,r)||this;return n.id=t,n.index=i,n.gamepad=r,n._buttons=new Array(r.buttons.length),n}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;t4&&(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=t.call(this,r.getEngine(),i)||this;s.SSAOOriginalSceneColorEffect="SSAOOriginalSceneColorEffect",s.SSAORenderEffect="SSAORenderEffect",s.SSAOBlurHRenderEffect="SSAOBlurHRenderEffect",s.SSAOBlurVRenderEffect="SSAOBlurVRenderEffect",s.SSAOCombineRenderEffect="SSAOCombineRenderEffect",s.totalStrength=1,s.radius=1e-4,s.area=.0075,s.fallOff=1e-6,s.base=.5,s._firstUpdate=!0,s._scene=r,s._createRandomTexture(),s._depthTexture=r.enableDepthRenderer().getDepthMap();var a=n.ssaoRatio||n,h=n.combineRatio||n;return s._ratio={ssaoRatio:a,combineRatio:h},s._originalColorPostProcess=new e.PassPostProcess("SSAOOriginalSceneColor",h,null,e.Texture.BILINEAR_SAMPLINGMODE,r.getEngine(),(!1)),s._createSSAOPostProcess(a),s._createBlurPostProcess(a),s._createSSAOCombinePostProcess(h),s.addEffect(new e.PostProcessRenderEffect(r.getEngine(),s.SSAOOriginalSceneColorEffect,function(){return s._originalColorPostProcess},(!0))),s.addEffect(new e.PostProcessRenderEffect(r.getEngine(),s.SSAORenderEffect,function(){return s._ssaoPostProcess},(!0))),s.addEffect(new e.PostProcessRenderEffect(r.getEngine(),s.SSAOBlurHRenderEffect,function(){return s._blurHPostProcess},(!0))),s.addEffect(new e.PostProcessRenderEffect(r.getEngine(),s.SSAOBlurVRenderEffect,function(){return s._blurVPostProcess},(!0))),s.addEffect(new e.PostProcessRenderEffect(r.getEngine(),s.SSAOCombineRenderEffect,function(){return s._ssaoCombinePostProcess},(!0))),r.postProcessRenderPipelineManager.addPipeline(s),o&&r.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(i,o),s}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;t0&&this.excludedMeshes.indexOf(e)!==-1},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;ot._alphaIndex?1:e._alphaIndext._distanceToCamera?-1:0})),a.setAlphaMode(e.Engine.ALPHA_COMBINE),o=0;o=0;l--)c(l);return h.addEffect(new e.PostProcessRenderEffect(n.getEngine(),"HDR",function(){return h._hdrPostProcess},(!0))),n.postProcessRenderPipelineManager.addPipeline(h),null!==a&&n.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(r,a),h.update(),h}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._hdrCurrentLuminancer._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;i<2;i++)for(var o=-2;o<2;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;r<2;r++)for(var n=-1;n<2;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 m=Math.pow(3,p);d={width:m,height:m};var _="#define DOWN_SAMPLE\n";0===p&&(_+="#define FINAL_DOWN_SAMPLE\n"),this._downSamplePostProcesses[p]=new e.PostProcess("hdr","hdr",["dsOffsets","halfDestPixelSize"],[],d,null,e.Texture.NEAREST_SAMPLINGMODE,t.getEngine(),(!1),_,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;r<9;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;t<9;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})(e.PostProcessRenderPipeline);t.LUM_STEPS=6,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=af?f:n,r=Math.round(f/n),o=0):r=r>f?f:r;for(var d=[],p=[],m=[],_=[],g=e.Tmp.Vector3[0],v=r;uf-r&&(r=f-u),d.length=0,p.length=0,m.length=0,_.length=0;for(var y=0,x=3*u;x<3*(u+r);x++){p.push(y);var b=a[x];d.push(s[3*b],s[3*b+1],s[3*b+2]),h&&m.push(h[2*b],h[2*b+1]),c&&_.push(c[4*b],c[4*b+1],c[4*b+2],c[4*b+3]),y++}var A,T=this.nbParticles,E=this._posToShape(d),P=this._uvsToShapeUV(m);for(A=0;Athis.nbParticles-1?this.nbParticles-1:i;for(var u=t;u<=i;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.billboard)&&(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;lthis._maximum.x&&(this._maximum.x=this._positions32[n]),this._positions32[n+1]this._maximum.y&&(this._maximum.y=this._positions32[n+1]),this._positions32[n+2]this._maximum.z&&(this._maximum.z=this._positions32[n+2])),this._computeParticleVertex||(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;lMath.PI;)n-=2*Math.PI;var s=n/Math.PI,a=o/Math.PI;s=.5*s+.5;var h=Math.round(s*i);h<0?h=0:h>=i&&(h=i-1);var c=Math.round(a*r);c<0?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}},e})();i.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))],i.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)],i.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)],i.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))],i.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)],i.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.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):t<-1074?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;n32767)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),m=new ArrayBuffer(t.width*t.height*4*3),_=new Float32Array(m);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;f<4;f++)for(u=(f+1)*h;l128){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;gthis.max.y||this.min.y>this.max.y||this.min.z>this.max.y},t})();i.MAX=Number.MAX_VALUE,i.MIN=Number.MIN_VALUE;var r=(function(){function e(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 e.prototype.filterCubeMap=function(){return this.init(),this.filterCubeMapMipChain(),this._outputSurface},e.prototype.init=function(){var t,i,r;for(0==this.maxNumMipLevels&&(this.maxNumMipLevels=e.CP_MAX_MIPLEVELS),r=this.outputSize,i=0;i>=1,this._numMipLevels++,0==r)return void(this.maxNumMipLevels=i)}},e.prototype.filterCubeMapMipChain=function(){var e=this.specularPower;this.precomputeFilterLookupTables(this.inputSize);for(var t=0;t>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}},e.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},e.prototype.precomputeFilterLookupTables=function(e){this._normCubeMap=[],this.buildNormalizerSolidAngleCubemap(e)},e.prototype.buildNormalizerSolidAngleCubemap=function(e){var t,i,r;for(t=0;t<6;t++){this._normCubeMap.push(new Float32Array(e*e*4));this.input[t];for(r=0;r1){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=e._sgFace2DMapping[t][e.CP_UDIR];e._vectorTemp.x=c[0]*s,e._vectorTemp.y=c[1]*s,e._vectorTemp.z=c[2]*s;var l=e._sgFace2DMapping[t][e.CP_VDIR];e._vectorTemp.x+=l[0]*a,e._vectorTemp.y+=l[1]*a,e._vectorTemp.z+=l[2]*a;var u=e._sgFace2DMapping[t][e.CP_FACEAXIS];return e._vectorTemp.x+=u[0],e._vectorTemp.y+=u[1],e._vectorTemp.z+=u[2],e._vectorTemp.normalize(),e._vectorTemp},e.prototype.vectToTexelCoord=function(t,i,r,n){var o,s,a=Math.abs(t),h=Math.abs(i),c=Math.abs(r);a>=h&&a>=c?(o=a,s=t>=0?e.CP_FACE_X_POS:e.CP_FACE_X_NEG):h>=a&&h>=c?(o=h,s=i>=0?e.CP_FACE_Y_POS:e.CP_FACE_Y_NEG):(o=c,s=r>=0?e.CP_FACE_Z_POS:e.CP_FACE_Z_NEG);var l=1/o;t*=l,i*=l,r*=l;var u=e._sgFace2DMapping[s][e.CP_UDIR],f=u[0]*t+u[1]*i+u[2]*r;u=e._sgFace2DMapping[s][e.CP_VDIR];var d=u[0]*t+u[1]*i+u[2]*r,p=Math.floor(.5*(n-1)*(f+1)),m=Math.floor(.5*(n-1)*(d+1));return e._vectorTemp.x=s,e._vectorTemp.y=p,e._vectorTemp.z=m,e._vectorTemp},e.prototype.areaElement=function(e,t){return Math.atan2(e*t,Math.sqrt(e*e+t*t+1))},e.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},e.prototype.filterCubeSurfaces=function(e,t,r,n,o,s){var a,h,c,l=[];for(a=0;a<6;a++)l.push(new i);var u=180/Math.PI*Math.atan2(1,t),f=o/2;f90&&(f=90);var d=Math.ceil(f/u);d<1&&(d=1);var p=Math.cos(Math.PI/180*f);for(a=0;a<6;a++)for(c=0;c0){switch(o=e._sgCubeNgh[f][y][0],s=e._sgCubeNgh[f][y][1],y!=s&&y+s!=3||(c[y]=i-1-c[y],l[y]=i-1-l[y]),e._sgCubeNgh[f][y][1]){case e.CP_EDGE_LEFT:n[o].augment(0,c[y],0),n[o].augment(h[y],l[y],0);break;case e.CP_EDGE_RIGHT:n[o].augment(i-1,c[y],0),n[o].augment(i-1-h[y],l[y],0);break;case e.CP_EDGE_TOP:n[o].augment(c[y],0,0),n[o].augment(l[y],h[y],0);break;case e.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 e.CP_FACE_X_POS:a=e.CP_FACE_X_NEG;break;case e.CP_FACE_X_NEG:a=e.CP_FACE_X_POS;break;case e.CP_FACE_Y_POS:a=e.CP_FACE_Y_NEG;break;case e.CP_FACE_Y_NEG:a=e.CP_FACE_Y_POS;break;case e.CP_FACE_Z_POS:a=e.CP_FACE_Z_NEG;break;case e.CP_FACE_Z_NEG:a=e.CP_FACE_Z_POS}n[a].augment(0,0,0),n[a].augment(i-1,i-1,0)}}},e.prototype.processFilterExtents=function(t,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,m=0;m<6;m++)if(!r[m].empty())for(var _=r[m].min.x,g=r[m].min.y,v=r[m].max.x,y=r[m].max.y,x=4*(g*u+_),b=this.numChannels*(g*u+_),A=g;A<=y;A++){for(var T=0,E=0,P=_;P<=v;P++){var M=this._normCubeMap[m][x+T+0],S=this._normCubeMap[m][x+T+1],C=this._normCubeMap[m][x+T+2],R=M*t.x+S*t.y+C*t.z;if(R>=i&&R>0){var O=this._normCubeMap[m][x+T+3];for(O*=Math.pow(R,s+p),c=0;c3&&(e._vectorTemp.w=a[3]/h);else{var I=this.vectToTexelCoord(t.x,t.y,t.z,o).clone();e._vectorTemp.x=n[I.x][this.numChannels*(I.z*o+I.y)+0],e._vectorTemp.y=n[I.x][this.numChannels*(I.z*o+I.y)+1],e._vectorTemp.z=n[I.x][this.numChannels*(I.z*o+I.y)+2],this.numChannels>3&&(e._vectorTemp.z=n[I.x][this.numChannels*(I.z*o+I.y)+3])}return e._vectorTemp},e.prototype.fixupCubeEdges=function(t,i){var r,n,o,s,a=0,h=[0,0,0,0,0,0,0,0],c=[[],[],[],[]],l=[[[],[],[]],[[],[],[]],[[],[],[]],[[],[],[]],[[],[],[]],[[],[],[]],[[],[],[]],[[],[],[]]];if(!(i<1))if(1!=i){for(s=0;s<6;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;a<4;a++){var u=e._sgCubeCornerList[s][a];l[u][h[u]]=c[a],h[u]++}for(a=0;a<8;a++)for(r=0;r>s,2),h=0;h<6;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;l<6;l++)h.push(r.subarray(a,a+c)),a+=c;for(var u=[],f=null,d=0;d<6;d++){ -var p=null;if(n)p=h[d];else{var m=[0,2,4,1,3,5][d];if(p=h[m],!t.getScene().getEngine().getCaps().textureFloat){var _=new ArrayBuffer(c);f=new Uint8Array(_)}for(var g=0;g255){var A=255/b;v*=A,y*=A,x*=A}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;a<6;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;l255){var m=255/p;u*=m,f*=m,d*=m}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,t.generateHarmonics,t.useInGammaSpace,t.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.customType="BABYLON.HDRCubeTexture",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>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 m=30,l=0;l>l,2),g=0;g<6;g++)p.set(h[l][g],m),m+=_;r(f)};e.Tools.LoadFile(t,(function(e){o(e)}),null,null,!0,n)},i})(e.BaseTexture);t._facesMapping=["right","up","front","left","down","back"],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;n=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),s.getAbsolutePositionToRef(this.mesh,h[0]),a.getAbsolutePositionToRef(this.mesh,h[1]),n++}}},t.prototype.update=function(){this.autoUpdateBonesMatrices&&this.skeleton.computeAbsoluteTransforms(),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.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(t){var i=(function(){function t(t,i){void 0===i&&(i=1),this._xline=[e.Vector3.Zero(),e.Vector3.Zero()],this._yline=[e.Vector3.Zero(),e.Vector3.Zero()],this._zline=[e.Vector3.Zero(),e.Vector3.Zero()],this.scaleLines=1,this.scaleLines=i,this._xmesh=e.Mesh.CreateLines("xline",this._xline,t,!0),this._ymesh=e.Mesh.CreateLines("yline",this._yline,t,!0),this._zmesh=e.Mesh.CreateLines("zline",this._zline,t,!0),this._xmesh.renderingGroupId=2,this._ymesh.renderingGroupId=2,this._zmesh.renderingGroupId=2,this._xmesh.material.checkReadyOnlyOnce=!0,this._xmesh.color=new e.Color3(1,0,0),this._ymesh.material.checkReadyOnlyOnce=!0,this._ymesh.color=new e.Color3(0,1,0),this._zmesh.material.checkReadyOnlyOnce=!0,this._zmesh.color=new e.Color3(0,0,1),this.scene=t}return t.prototype.update=function(t,i,r,n){var o=this.scaleLines,s=this._xline[0],a=this._xline[1];s.x=t.x,s.y=t.y,s.z=t.z,a.x=s.x+i.x*o,a.y=s.y+i.y*o,a.z=s.z+i.z*o,e.Mesh.CreateLines(null,this._xline,null,null,this._xmesh),s=this._yline[0],a=this._yline[1],s.x=t.x,s.y=t.y,s.z=t.z,a.x=s.x+r.x*o,a.y=s.y+r.y*o,a.z=s.z+r.z*o,e.Mesh.CreateLines(null,this._yline,null,null,this._ymesh),s=this._zline[0],a=this._zline[1],s.x=t.x,s.y=t.y,s.z=t.z,a.x=s.x+n.x*o,a.y=s.y+n.y*o,a.z=s.z+n.z*o,e.Mesh.CreateLines(null,this._zline,null,null,this._zmesh)},t.prototype.dispose=function(){this._xmesh&&(this._xmesh.dispose(),this._ymesh.dispose(),this._zmesh.dispose(),this._xmesh=null,this._ymesh=null,this._zmesh=null,this._xline=null,this._yline=null,this._zline=null,this.scene=null)},t})();t.AxesViewer=i})(t=e.Debug||(e.Debug={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t;!(function(t){var i=(function(t){function i(i,r,n,o){void 0===o&&(o=1);var s=t.call(this,i,o)||this;return s.pos=e.Vector3.Zero(),s.xaxis=e.Vector3.Zero(),s.yaxis=e.Vector3.Zero(),s.zaxis=e.Vector3.Zero(),s.mesh=n,s.bone=r,s}return __extends(i,t),i.prototype.update=function(){var i=this.bone;i.getAbsolutePositionToRef(this.mesh,this.pos),i.getDirectionToRef(e.Axis.X,this.mesh,this.xaxis),i.getDirectionToRef(e.Axis.Y,this.mesh,this.yaxis),i.getDirectionToRef(e.Axis.Z,this.mesh,this.zaxis),t.prototype.update.call(this,this.pos,this.xaxis,this.yaxis,this.zaxis)},i.prototype.dispose=function(){this.pos&&(this.pos=null,this.xaxis=null,this.yaxis=null,this.zaxis=null,this.mesh=null,this.bone=null,t.prototype.dispose.call(this))},i})(t.AxesViewer);t.BoneAxesViewer=i})(t=e.Debug||(e.Debug={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r){var n=t.call(this,r)||this;return i?(n._textureMatrix=e.Matrix.Identity(),n.name=i,n.url=i,n.hasAlpha=!1,n.isCube=!1,n.wrapU=e.Texture.CLAMP_ADDRESSMODE,n.wrapV=e.Texture.CLAMP_ADDRESSMODE,n.anisotropicFilteringLevel=1,n._texture=n._getFromCache(i,!0),n._texture||(r.useDelayedTextureLoading?n.delayLoadState=e.Engine.DELAYLOADSTATE_NOTLOADED:n.loadTexture()),n):n}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;p0||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),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),void 0===this.metallic&&void 0===this.roughness||(this._defines.METALLICWORKFLOW=!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=this._defines.toString(),u=["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"],f=["albedoSampler","ambientSampler","opacitySampler","reflectionCubeSampler","reflection2DSampler","emissiveSampler","reflectivitySampler","bumpSampler","lightmapSampler","refractionCubeSampler","refraction2DSampler"];e.ColorCurves.PrepareUniforms(u),e.ColorGradingTexture.PrepareUniformsAndSamplers(u,f),e.MaterialHelper.PrepareUniformsAndSamplersList(u,f,this._defines,this.maxSimultaneousLights),this._effect=n.getEngine().createEffect("pbr",c,u,f,l,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)},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.setFloat3("vAmbientInfos",this.ambientTexture.coordinatesIndex,this.ambientTexture.level,this.ambientTextureStrength),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())),e.StandardMaterial.SpecularTextureEnabled&&(this.metallicTexture?(this._effect.setTexture("reflectivitySampler",this.metallicTexture),this._effect.setFloat2("vReflectivityInfos",this.metallicTexture.coordinatesIndex,this.metallicTexture.level),this._effect.setMatrix("reflectivityMatrix",this.metallicTexture.getTextureMatrix())):this.reflectivityTexture&&(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)}(this.reflectionTexture||this.refractionTexture)&&this._effect.setFloat2("vMicrosurfaceTextureLods",this._microsurfaceTextureLods.x,this._microsurfaceTextureLods.y),this.cameraColorGradingTexture&&e.StandardMaterial.ColorGradingTextureEnabled&&e.ColorGradingTexture.Bind(this.cameraColorGradingTexture,this._effect)}e.MaterialHelper.BindClipPlane(this._effect,this._myScene),this.pointsCloud&&this._effect.setFloat("pointSize",this.pointSize),this._myScene.ambientColor.multiplyToRef(this.ambientColor,this._globalAmbientColor),this._defines.METALLICWORKFLOW?(r._scaledReflectivity.r=void 0===this.metallic?1:this.metallic,r._scaledReflectivity.g=void 0===this.roughness?1:this.roughness,this._effect.setColor4("vReflectivityColor",r._scaledReflectivity,0)):(this.convertColorToLinearSpaceToRef(this.reflectivityColor,r._scaledReflectivity),this._effect.setColor4("vReflectivityColor",r._scaledReflectivity,this.microSurface)),this._effect.setVector3("vEyePosition",this._myScene._mirroredCameraPosition?this._myScene._mirroredCameraPosition:this._myScene.activeCamera.position),this._effect.setColor3("vAmbientColor",this._globalAmbientColor),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._effect.setColor3("vOverloadedAmbient",this.overloadedAmbient),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.metallicTexture&&this.metallicTexture.animations&&this.metallicTexture.animations.length>0?e.push(this.metallicTexture):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.metallicTexture&&this.metallicTexture.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})(e.Material);i._scaledAlbedo=new e.Color3,i._scaledReflectivity=new e.Color3,i._scaledEmissive=new e.Color3,i._scaledReflection=new e.Color3,__decorate([e.serialize()],i.prototype,"directIntensity",void 0),__decorate([e.serialize()],i.prototype,"emissiveIntensity",void 0),__decorate([e.serialize()],i.prototype,"environmentIntensity",void 0),__decorate([e.serialize()],i.prototype,"specularIntensity",void 0),__decorate([e.serialize()],i.prototype,"disableBumpMap",void 0),__decorate([e.serialize()],i.prototype,"overloadedShadowIntensity",void 0),__decorate([e.serialize()],i.prototype,"overloadedShadeIntensity",void 0),__decorate([e.serialize()],i.prototype,"cameraExposure",void 0),__decorate([e.serialize()],i.prototype,"cameraContrast",void 0),__decorate([e.serializeAsTexture()],i.prototype,"cameraColorGradingTexture",void 0),__decorate([e.serializeAsColorCurves()],i.prototype,"cameraColorCurves",void 0),__decorate([e.serializeAsColor3()],i.prototype,"overloadedAmbient",void 0),__decorate([e.serialize()],i.prototype,"overloadedAmbientIntensity",void 0),__decorate([e.serializeAsColor3()],i.prototype,"overloadedAlbedo",void 0),__decorate([e.serialize()],i.prototype,"overloadedAlbedoIntensity",void 0),__decorate([e.serializeAsColor3()],i.prototype,"overloadedReflectivity",void 0),__decorate([e.serialize()],i.prototype,"overloadedReflectivityIntensity",void 0),__decorate([e.serializeAsColor3()],i.prototype,"overloadedEmissive",void 0),__decorate([e.serialize()],i.prototype,"overloadedEmissiveIntensity",void 0),__decorate([e.serializeAsColor3()],i.prototype,"overloadedReflection",void 0),__decorate([e.serialize()],i.prototype,"overloadedReflectionIntensity",void 0),__decorate([e.serialize()],i.prototype,"overloadedMicroSurface",void 0),__decorate([e.serialize()],i.prototype,"overloadedMicroSurfaceIntensity",void 0),__decorate([e.serializeAsTexture()],i.prototype,"albedoTexture",void 0),__decorate([e.serializeAsTexture()],i.prototype,"ambientTexture",void 0),__decorate([e.serialize()],i.prototype,"ambientTextureStrength",void 0),__decorate([e.serializeAsTexture()],i.prototype,"opacityTexture",void 0),__decorate([e.serializeAsTexture()],i.prototype,"reflectionTexture",void 0),__decorate([e.serializeAsTexture()],i.prototype,"emissiveTexture",void 0),__decorate([e.serializeAsTexture()],i.prototype,"reflectivityTexture",void 0),__decorate([e.serializeAsTexture()],i.prototype,"metallicTexture",void 0),__decorate([e.serialize()],i.prototype,"metallic",void 0),__decorate([e.serialize()],i.prototype,"roughness",void 0),__decorate([e.serializeAsTexture()],i.prototype,"bumpTexture",void 0),__decorate([e.serializeAsTexture()],i.prototype,"lightmapTexture",void 0),__decorate([e.serializeAsTexture()],i.prototype,"refractionTexture",void 0),__decorate([e.serializeAsColor3("ambient")],i.prototype,"ambientColor",void 0),__decorate([e.serializeAsColor3("albedo")],i.prototype,"albedoColor",void 0),__decorate([e.serializeAsColor3("reflectivity")],i.prototype,"reflectivityColor",void 0),__decorate([e.serializeAsColor3("reflection")],i.prototype,"reflectionColor",void 0),__decorate([e.serializeAsColor3("emissive")],i.prototype,"emissiveColor",void 0),__decorate([e.serialize()],i.prototype,"microSurface",void 0),__decorate([e.serialize()],i.prototype,"indexOfRefraction",void 0),__decorate([e.serialize()],i.prototype,"invertRefractionY",void 0),__decorate([e.serializeAsFresnelParameters()],i.prototype,"opacityFresnelParameters",void 0),__decorate([e.serializeAsFresnelParameters()],i.prototype,"emissiveFresnelParameters",void 0),__decorate([e.serialize()],i.prototype,"linkRefractionWithTransparency",void 0),__decorate([e.serialize()],i.prototype,"linkEmissiveWithAlbedo",void 0),__decorate([e.serialize()],i.prototype,"useLightmapAsShadowmap",void 0),__decorate([e.serialize()],i.prototype,"useEmissiveAsIllumination",void 0),__decorate([e.serialize()],i.prototype,"useAlphaFromAlbedoTexture",void 0),__decorate([e.serialize()],i.prototype,"useSpecularOverAlpha",void 0),__decorate([e.serialize()],i.prototype,"useMicroSurfaceFromReflectivityMapAlpha",void 0),__decorate([e.serialize()],i.prototype,"useRoughnessFromMetallicTextureAlpha",void 0),__decorate([e.serialize()],i.prototype,"useRoughnessFromMetallicTextureGreen",void 0),__decorate([e.serialize()],i.prototype,"useAutoMicroSurfaceFromReflectivityMap",void 0),__decorate([e.serialize()],i.prototype,"useScalarInLinearSpace",void 0),__decorate([e.serialize()],i.prototype,"usePhysicalLightFalloff",void 0),__decorate([e.serialize()],i.prototype,"useRadianceOverAlpha",void 0),__decorate([e.serialize()],i.prototype,"useParallax",void 0),__decorate([e.serialize()],i.prototype,"useParallaxOcclusion",void 0),__decorate([e.serialize()],i.prototype,"parallaxScaleBias",void 0),__decorate([e.serialize()],i.prototype,"disableLighting",void 0),__decorate([e.serialize()],i.prototype,"maxSimultaneousLights",void 0),__decorate([e.serialize()],i.prototype,"invertNormalMapX",void 0),__decorate([e.serialize()],i.prototype,"invertNormalMapY",void 0),__decorate([e.serialize()],i.prototype,"useLogarithmicDepth",null),e.PBRMaterial=i})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(e){this._scene=e}return t.prototype._createInspector=function(e){this._inspector||(this._inspector=new INSPECTOR.Inspector(this._scene,e))},t.prototype.isVisible=function(){return!1},t.prototype.hide=function(){this._inspector&&(this._inspector.dispose(),this._inspector=null)},t.prototype.show=function(i){"undefined"==typeof INSPECTOR?e.Tools.LoadScript(t.InspectorURL,this._createInspector.bind(this,i)):this._createInspector(i)},t})();t.InspectorURL="http://www.babylonjs.com/babylon.inspector.bundle.js",e.DebugLayer=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,o,s){void 0===o&&(o=null);var a=t.call(this,r.getEngine(),i)||this;return a.downSampleX4PostProcess=null,a.brightPassPostProcess=null,a.gaussianBlurHPostProcesses=[],a.gaussianBlurVPostProcesses=[],a.textureAdderPostProcess=null,a.textureAdderFinalPostProcess=null,a.lensFlarePostProcess=null,a.lensFlareComposePostProcess=null,a.depthOfFieldPostProcess=null,a.brightThreshold=1,a.blurWidth=2,a.gaussianCoefficient=.25,a.gaussianMean=1,a.gaussianStandardDeviation=1,a.exposure=1,a.lensTexture=null,a.lensColorTexture=null,a.lensFlareStrength=20,a.lensFlareGhostDispersal=1.4,a.lensFlareHaloWidth=.7,a.lensFlareDistortionStrength=16,a.lensStarTexture=null,a.lensFlareDirtTexture=null,a.depthOfFieldDistance=10,a.animations=[],a._depthRenderer=null,a._depthOfFieldEnabled=!0,a._lensFlareEnabled=!0,a._scene=r,o?a.originalPostProcess=o:a.originalPostProcess=new e.PostProcess("HDRPass","standard",[],[],n,null,e.Texture.BILINEAR_SAMPLINGMODE,r.getEngine(),(!0),"#define PASS_POST_PROCESS",e.Engine.TEXTURETYPE_FLOAT),a.addEffect(new e.PostProcessRenderEffect(r.getEngine(),"HDRPassPostProcess",function(){return a.originalPostProcess},(!0))),a._createDownSampleX4PostProcess(r,n/2),a._createBrightPassPostProcess(r,n/2),a._createGaussianBlurPostProcesses(r,n/2,0),a._createGaussianBlurPostProcesses(r,n/4,1),a._createGaussianBlurPostProcesses(r,n/8,2),a._createGaussianBlurPostProcesses(r,n/16,3),a._createTextureAdderPostProcess(r,n),a.textureAdderFinalPostProcess=new e.PostProcess("HDRDepthOfFieldSource","standard",[],[],n,null,e.Texture.BILINEAR_SAMPLINGMODE,r.getEngine(),(!0),"#define PASS_POST_PROCESS",e.Engine.TEXTURETYPE_UNSIGNED_INT),a.addEffect(new e.PostProcessRenderEffect(r.getEngine(),"HDRDepthOfFieldSource",function(){return a.textureAdderFinalPostProcess},(!0))),a._createLensFlarePostProcess(r,n),a._createGaussianBlurPostProcesses(r,n/2,5),a._createDepthOfFieldPostProcess(r,n),r.postProcessRenderPipelineManager.addPipeline(a),null!==s&&r.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(i,s),a.LensFlareEnabled=!1,a.DepthOfFieldEnabled=!1,a}return __extends(i,t),Object.defineProperty(i.prototype,"DepthOfFieldEnabled",{get:function(){return this._depthOfFieldEnabled},set:function(e){var t=this.gaussianBlurHPostProcesses.length-1;e&&!this._depthOfFieldEnabled?(this._scene.postProcessRenderPipelineManager.enableEffectInPipeline(this._name,"HDRGaussianBlurH"+t,this._scene.cameras),this._scene.postProcessRenderPipelineManager.enableEffectInPipeline(this._name,"HDRGaussianBlurV"+t,this._scene.cameras),this._scene.postProcessRenderPipelineManager.enableEffectInPipeline(this._name,"HDRDepthOfField",this._scene.cameras),this._depthRenderer=this._scene.enableDepthRenderer()):!e&&this._depthOfFieldEnabled&&(this._scene.postProcessRenderPipelineManager.disableEffectInPipeline(this._name,"HDRGaussianBlurH"+t,this._scene.cameras),this._scene.postProcessRenderPipelineManager.disableEffectInPipeline(this._name,"HDRGaussianBlurV"+t,this._scene.cameras),this._scene.postProcessRenderPipelineManager.disableEffectInPipeline(this._name,"HDRDepthOfField",this._scene.cameras)),this._depthOfFieldEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"LensFlareEnabled",{get:function(){return this._lensFlareEnabled},set:function(e){var t=this.gaussianBlurHPostProcesses.length-2;e&&!this._lensFlareEnabled?(this._scene.postProcessRenderPipelineManager.enableEffectInPipeline(this._name,"HDRLensFlare",this._scene.cameras),this._scene.postProcessRenderPipelineManager.enableEffectInPipeline(this._name,"HDRLensFlareShift",this._scene.cameras),this._scene.postProcessRenderPipelineManager.enableEffectInPipeline(this._name,"HDRGaussianBlurH"+t,this._scene.cameras),this._scene.postProcessRenderPipelineManager.enableEffectInPipeline(this._name,"HDRGaussianBlurV"+t,this._scene.cameras),this._scene.postProcessRenderPipelineManager.enableEffectInPipeline(this._name,"HDRLensFlareCompose",this._scene.cameras)):!e&&this._lensFlareEnabled&&(this._scene.postProcessRenderPipelineManager.disableEffectInPipeline(this._name,"HDRLensFlare",this._scene.cameras),this._scene.postProcessRenderPipelineManager.disableEffectInPipeline(this._name,"HDRLensFlareShift",this._scene.cameras),this._scene.postProcessRenderPipelineManager.disableEffectInPipeline(this._name,"HDRGaussianBlurH"+t,this._scene.cameras),this._scene.postProcessRenderPipelineManager.disableEffectInPipeline(this._name,"HDRGaussianBlurV"+t,this._scene.cameras),this._scene.postProcessRenderPipelineManager.disableEffectInPipeline(this._name,"HDRLensFlareCompose",this._scene.cameras)),this._lensFlareEnabled=e},enumerable:!0,configurable:!0}),i.prototype._createDownSampleX4PostProcess=function(t,i){var r=this,n=new Array(32);this.downSampleX4PostProcess=new e.PostProcess("HDRDownSampleX4","standard",["dsOffsets"],[],i,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),(!1),"#define DOWN_SAMPLE_X4",e.Engine.TEXTURETYPE_UNSIGNED_INT),this.downSampleX4PostProcess.onApply=function(e){for(var t=0,i=-2;i<2;i++)for(var o=-2;o<2;o++)n[t]=(i+.5)*(1/r.downSampleX4PostProcess.width),n[t+1]=(o+.5)*(1/r.downSampleX4PostProcess.height),t+=2;e.setArray2("dsOffsets",n)},this.addEffect(new e.PostProcessRenderEffect(t.getEngine(),"HDRDownSampleX4",function(){return r.downSampleX4PostProcess},(!0)))},i.prototype._createBrightPassPostProcess=function(t,i){var r=this,n=new Array(8);this.brightPassPostProcess=new e.PostProcess("HDRBrightPass","standard",["dsOffsets","brightThreshold"],[],i,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),(!1),"#define BRIGHT_PASS",e.Engine.TEXTURETYPE_UNSIGNED_INT),this.brightPassPostProcess.onApply=function(e){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.addEffect(new e.PostProcessRenderEffect(t.getEngine(),"HDRBrightPass",function(){return r.brightPassPostProcess},(!0)))},i.prototype._createGaussianBlurPostProcesses=function(t,i,r){var n=this,o=new Array(9),s=new Array(9),a=["blurOffsets","blurWeights","blurWidth"],h=function(e){return function(i){for(var r=0,a=0;a<9;a++)r=(a-4)/4,s[a]=n.gaussianCoefficient*(1/Math.sqrt(2*Math.PI*n.gaussianStandardDeviation))*Math.exp(-((r-n.gaussianMean)*(r-n.gaussianMean))/(2*n.gaussianStandardDeviation*n.gaussianStandardDeviation));for(var h={width:t.getEngine().getRenderWidth(),height:t.getEngine().getRenderHeight()},a=0;a<9;a++){var c=(a-4)*(1/(e===!0?h.height:h.width));o[a]=c}i.setArray("blurOffsets",o),i.setArray("blurWeights",s),i.setFloat("blurWidth",n.blurWidth)}},c=new e.PostProcess("HDRGaussianBlurH"+i,"standard",a,[],i,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),(!1),"#define GAUSSIAN_BLUR_H",e.Engine.TEXTURETYPE_UNSIGNED_INT);c.onApply=h(!1);var l=new e.PostProcess("HDRGaussianBlurV"+i,"standard",a,[],i,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),(!1),"#define GAUSSIAN_BLUR_V",e.Engine.TEXTURETYPE_UNSIGNED_INT);l.onApply=h(!0),this.addEffect(new e.PostProcessRenderEffect(t.getEngine(),"HDRGaussianBlurH"+r,function(){return c},(!0))),this.addEffect(new e.PostProcessRenderEffect(t.getEngine(),"HDRGaussianBlurV"+r,function(){return l},(!0))),this.gaussianBlurHPostProcesses.push(c),this.gaussianBlurVPostProcesses.push(l)},i.prototype._createTextureAdderPostProcess=function(t,i){var r=this;this.gaussianBlurVPostProcesses[3];this.textureAdderPostProcess=new e.PostProcess("HDRTextureAdder","standard",["exposure"],["otherSampler","lensSampler"],i,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),(!1),"#define TEXTURE_ADDER",e.Engine.TEXTURETYPE_UNSIGNED_INT),this.textureAdderPostProcess.onApply=function(e){e.setTextureFromPostProcess("otherSampler",r.originalPostProcess),e.setTexture("lensSampler",r.lensTexture),e.setFloat("exposure",r.exposure)},this.addEffect(new e.PostProcessRenderEffect(t.getEngine(),"HDRTextureAdder",function(){return r.textureAdderPostProcess},(!0)))},i.prototype._createLensFlarePostProcess=function(t,i){var r=this;this.lensFlarePostProcess=new e.PostProcess("HDRLensFlare","standard",["strength","ghostDispersal","haloWidth","resolution","distortionStrength"],["lensColorSampler"],i/2,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),(!0),"#define LENS_FLARE",e.Engine.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new e.PostProcessRenderEffect(t.getEngine(),"HDRLensFlare",function(){return r.lensFlarePostProcess},(!1))),this._createGaussianBlurPostProcesses(t,i/4,4),this.lensFlareComposePostProcess=new e.PostProcess("HDRLensFlareCompose","standard",["lensStarMatrix"],["otherSampler","lensDirtSampler","lensStarSampler"],i,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),(!1),"#define LENS_FLARE_COMPOSE",e.Engine.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new e.PostProcessRenderEffect(t.getEngine(),"HDRLensFlareCompose",function(){return r.lensFlareComposePostProcess},(!1)));var n=new e.Vector2(0,0);this.lensFlarePostProcess.onApply=function(e){e.setTextureFromPostProcess("textureSampler",r.gaussianBlurHPostProcesses[0]),e.setTexture("lensColorSampler",r.lensColorTexture), -e.setFloat("strength",r.lensFlareStrength),e.setFloat("ghostDispersal",r.lensFlareGhostDispersal),e.setFloat("haloWidth",r.lensFlareHaloWidth),n.x=r.lensFlarePostProcess.width,n.y=r.lensFlarePostProcess.height,e.setVector2("resolution",n),e.setFloat("distortionStrength",r.lensFlareDistortionStrength)};var o=e.Matrix.FromValues(2,0,-1,0,0,2,-1,0,0,0,1,0,0,0,0,1),s=e.Matrix.FromValues(.5,0,.5,0,0,.5,.5,0,0,0,1,0,0,0,0,1);this.lensFlareComposePostProcess.onApply=function(t){t.setTextureFromPostProcess("otherSampler",r.textureAdderFinalPostProcess),t.setTexture("lensDirtSampler",r.lensFlareDirtTexture),t.setTexture("lensStarSampler",r.lensStarTexture);var i=r._scene.activeCamera.getViewMatrix().getRow(0),n=r._scene.activeCamera.getViewMatrix().getRow(2),a=e.Vector3.Dot(i.toVector3(),new e.Vector3(1,0,0))+e.Vector3.Dot(n.toVector3(),new e.Vector3(0,0,1));a*=4;var h=e.Matrix.FromValues(.5*Math.cos(a),-Math.sin(a),0,0,Math.sin(a),.5*Math.cos(a),0,0,0,0,1,0,0,0,0,1),c=s.multiply(h).multiply(o);t.setMatrix("lensStarMatrix",c)}},i.prototype._createDepthOfFieldPostProcess=function(t,i){var r=this;this.depthOfFieldPostProcess=new e.PostProcess("HDRDepthOfField","standard",["distance"],["otherSampler","depthSampler"],i,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),(!1),"#define DEPTH_OF_FIELD",e.Engine.TEXTURETYPE_UNSIGNED_INT),this.depthOfFieldPostProcess.onApply=function(e){e.setTextureFromPostProcess("otherSampler",r.textureAdderFinalPostProcess),e.setTexture("depthSampler",r._depthRenderer.getDepthMap()),e.setFloat("distance",r.depthOfFieldDistance)},this.addEffect(new e.PostProcessRenderEffect(t.getEngine(),"HDRDepthOfField",function(){return r.depthOfFieldPostProcess},(!0)))},i.prototype.dispose=function(){for(var e=0;e0.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\n\n#include[0..maxSimultaneousLights]\n#include\n#include\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\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\n#ifdef REFLECTIONFRESNEL\nuniform vec4 reflectionLeftColor;\nuniform vec4 reflectionRightColor;\n#endif\n#endif\n#ifdef CAMERACOLORGRADING\n#include \n#include\n#endif\n#ifdef CAMERACOLORCURVES\n#include\n#include\n#endif\n#include\n#include\n#include\n#include\nvoid main(void) {\n#include\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#include\n#ifdef DIFFUSE\nbaseColor=texture2D(diffuseSampler,vDiffuseUV+uvOffset);\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+uvOffset).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+uvOffset);\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#ifdef LIGHTMAP\nvec3 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset).rgb*vLightmapInfos.y;\n#endif\n#include[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+uvOffset);\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+uvOffset).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\n#ifdef LIGHTMAP\n#ifndef LIGHTMAPEXCLUDED\n#ifdef USELIGHTMAPASSHADOWMAP\ncolor.rgb*=lightmapColor;\n#else\ncolor.rgb+=lightmapColor;\n#endif\n#endif\n#endif\n#include\n#include\n#ifdef CAMERACOLORGRADING\ncolor=colorGrades(color);\n#endif\n#ifdef CAMERACOLORCURVES\ncolor.rgb=applyColorCurves(color.rgb);\n#endif\ngl_FragColor=color;\n}",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\n\n#include\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\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include\n#include\n#include[0..maxSimultaneousLights]\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#endif\n#ifdef REFLECTIONMAP_EQUIRECTANGULAR_FIXED\nvarying vec3 vDirectionW;\n#endif\n#include\nvoid main(void) {\n#ifdef REFLECTIONMAP_SKYBOX\nvPositionUVW=position;\n#endif \n#include\n#include\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\n#include\n#include[0..maxSimultaneousLights]\n#ifdef VERTEXCOLOR\n\nvColor=color;\n#endif\n#include\n#include\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\n\n#include\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\n#include\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}",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 ((lumaBlumaMax)) {\ngl_FragColor=rgbA;\n}\nelse {\ngl_FragColor=rgbB;\n}\n}",glowBlurPostProcessPixelShader:"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n\nuniform vec2 screenSize;\nuniform vec2 direction;\nuniform float blurWidth;\n\nfloat getLuminance(vec3 color)\n{\nreturn dot(color,vec3(0.2126,0.7152,0.0722));\n}\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{\n\nvec4 texel=texture2D(textureSampler,start+texelOffset);\nbaseColor.a+=texel.a*weights[i];\n\nfloat luminance=getLuminance(baseColor.rgb);\nfloat luminanceTexel=getLuminance(texel.rgb);\nfloat choice=step(luminanceTexel,luminance);\nbaseColor.rgb=choice*baseColor.rgb+(1.0-choice)*texel.rgb;\ntexelOffset+=texelStep;\n}\ngl_FragColor=baseColor;\n}",glowMapGenerationPixelShader:"#ifdef ALPHATEST\nvarying vec2 vUVDiffuse;\nuniform sampler2D diffuseSampler;\n#endif\n#ifdef EMISSIVE\nvarying vec2 vUVEmissive;\nuniform sampler2D emissiveSampler;\n#endif\nuniform vec4 color;\nvoid main(void)\n{\n#ifdef ALPHATEST\nif (texture2D(diffuseSampler,vUVDiffuse).a<0.4)\ndiscard;\n#endif\n#ifdef EMISSIVE\ngl_FragColor=texture2D(emissiveSampler,vUVEmissive);\n#else\ngl_FragColor=color;\n#endif\n}",glowMapGenerationVertexShader:"\nattribute vec3 position;\n#include\n\n#include\nuniform mat4 viewProjection;\nvarying vec4 vPosition;\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef ALPHATEST\nvarying vec2 vUVDiffuse;\nuniform mat4 diffuseMatrix;\n#endif\n#ifdef EMISSIVE\nvarying vec2 vUVEmissive;\nuniform mat4 emissiveMatrix;\n#endif\nvoid main(void)\n{\n#include\n#include\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 DIFFUSEUV1\nvUVDiffuse=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n#endif\n#ifdef DIFFUSEUV2\nvUVDiffuse=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n#ifdef EMISSIVE\n#ifdef EMISSIVEUV1\nvUVEmissive=vec2(emissiveMatrix*vec4(uv,1.0,0.0));\n#endif\n#ifdef EMISSIVEUV2\nvUVEmissive=vec2(emissiveMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n}",glowMapMergePixelShader:"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n\nuniform float offset;\nvoid main(void) {\nvec4 baseColor=texture2D(textureSampler,vUV);\nbaseColor.a=abs(offset-baseColor.a);\ngl_FragColor=baseColor;\n}",glowMapMergeVertexShader:"\nattribute vec2 position;\n\nvarying vec2 vUV;\nconst vec2 madd=vec2(0.5,0.5);\nvoid main(void) {\nvUV=position*madd+madd;\ngl_Position=vec4(position,0.0,1.0);\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 (luminance1.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}",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\n\nuniform float offset;\n#include\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\n#include\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[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 vec3 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) || defined(METALLICWORKFLOW) \nvarying vec2 vReflectivityUV;\nuniform vec2 vReflectivityInfos;\nuniform sampler2D reflectivitySampler;\n#endif\n\n#include\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\n#endif\n#ifdef CAMERACOLORGRADING\n#include\n#endif\n#ifdef CAMERACOLORCURVES\n#include\n#endif\n\n#include\n#include\n#ifdef CAMERACOLORGRADING\n#include\n#endif\n#ifdef CAMERACOLORCURVES\n#include\n#endif\n#include\n#include\n#include\n#include\n#include\n#include\n\n#include\nvoid main(void) {\n#include\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\n#include\n\nvec4 surfaceAlbedo=vec4(1.,1.,1.,1.);\nvec3 surfaceAlbedoContribution=vAlbedoColor.rgb;\n\nfloat alpha=vAlbedoColor.a;\n#ifdef ALBEDO\nsurfaceAlbedo=texture2D(albedoSampler,vAlbedoUV+uvOffset);\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\nvec3 ambientColor=vec3(1.,1.,1.);\n#ifdef AMBIENT\nambientColor=texture2D(ambientSampler,vAmbientUV+uvOffset).rgb*vAmbientInfos.y;\nambientColor=vec3(1.,1.,1.)-((vec3(1.,1.,1.)-ambientColor)*vAmbientInfos.z);\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+uvOffset);\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 METALLICWORKFLOW\nvec2 metallicRoughness=surfaceReflectivityColor.rg;\n#ifdef METALLICROUGHNESSMAP\nvec4 surfaceMetallicColorMap=texture2D(reflectivitySampler,vReflectivityUV+uvOffset);\n\nmetallicRoughness.r*=surfaceMetallicColorMap.r;\n#ifdef METALLICROUGHNESSGSTOREINALPHA\nmetallicRoughness.g*=surfaceMetallicColorMap.a;\n#else\n#ifdef METALLICROUGHNESSGSTOREINGREEN\nmetallicRoughness.g*=surfaceMetallicColorMap.g;\n#endif\n#endif\n#endif\n\nvec3 baseColor=surfaceAlbedo.rgb;\n\nsurfaceAlbedo.rgb*=(1.0-metallicRoughness.r);\n\n\nconst vec3 DefaultSpecularReflectanceDielectric=vec3(0.04,0.04,0.04);\n\nsurfaceReflectivityColor=mix(DefaultSpecularReflectanceDielectric,baseColor,metallicRoughness.r);\n#ifdef OVERLOADEDVALUES\nsurfaceReflectivityColor=mix(surfaceReflectivityColor,vOverloadedReflectivity,vOverloadedIntensity.z);\n#endif\nmicroSurface=1.0-metallicRoughness.g;\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.; \n#ifdef LIGHTMAP\nvec3 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset).rgb*vLightmapInfos.y;\n#endif\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[0..maxSimultaneousLights]\n#ifdef SPECULARTERM\nlightSpecularContribution*=vLightingIntensity.w;\n#endif\n#ifdef OPACITY\nvec4 opacityMap=texture2D(opacitySampler,vOpacityUV+uvOffset);\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+uvOffset).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\n#ifndef LIGHTMAPEXCLUDED\n#ifdef USELIGHTMAPASSHADOWMAP\nfinalColor.rgb*=lightmapColor;\n#else\nfinalColor.rgb+=lightmapColor;\n#endif\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\n#include(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\n\n#include\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 vec3 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) || defined(METALLICWORKFLOW) \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\n#include\n#include[0..maxSimultaneousLights]\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#endif\n#ifdef REFLECTIONMAP_EQUIRECTANGULAR_FIXED\nvarying vec3 vDirectionW;\n#endif\n#include\nvoid main(void) {\n#ifdef REFLECTIONMAP_SKYBOX\nvPositionUVW=position;\n#endif \n#include\n#include\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) || defined(METALLICWORKFLOW) \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\n\n#include\n\n#include[0..maxSimultaneousLights]\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n\n#include\n}", -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}",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:"#ifndef FULLFLOAT\nvec4 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}\n#endif\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;\n#ifndef FULLFLOAT\ngl_FragColor=vec4(packHalf(moment1),packHalf(moment2));\n#else\ngl_FragColor=vec4(moment1,moment2,1.0,1.0);\n#endif\n#else\n#ifndef FULLFLOAT\ngl_FragColor=pack(depth);\n#else\ngl_FragColor=vec4(depth,1.0,1.0,1.0);\n#endif\n#endif\n}",shadowMapVertexShader:"\nattribute vec3 position;\n#include\n\n#include\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\n#include\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}",spritesPixelShader:"uniform bool alphaTest;\nvarying vec4 vColor;\n\nvarying vec2 vUV;\nuniform sampler2D diffuseSampler;\n\n#include\nvoid main(void) {\nvec4 color=texture2D(diffuseSampler,vUV);\nif (alphaTest) \n{\nif (color.a<0.95)\ndiscard;\n}\ncolor*=vColor;\n#include\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\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; i0.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}",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; i1.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:"vec2 uvOffset=vec2(0.0,0.0);\n#if defined(BUMP) || defined(PARALLAX)\nmat3 TBN=cotangent_frame(normalW*vBumpInfos.y,-viewDirectionW,vBumpUV);\n#endif\n#ifdef PARALLAX\nmat3 invTBN=transposeMat3(TBN);\n#ifdef PARALLAXOCCLUSION\nuvOffset=parallaxOcclusion(invTBN*-viewDirectionW,invTBN*normalW,vBumpUV,vBumpInfos.z);\n#else\nuvOffset=parallaxOffset(invTBN*viewDirectionW,vBumpInfos.z);\n#endif\n#endif\n#ifdef BUMP\nnormalW=perturbNormal(viewDirectionW,TBN,vBumpUV+uvOffset);\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; icurrRayHeight)\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#if defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X}) && defined(LIGHTMAPNOSPECULAR{X})\n\n#else\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#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\n#if defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X})\ndiffuseBase+=lightmapColor*shadow;\n#ifdef SPECULARTERM\n#ifndef LIGHTMAPNOSPECULAR{X}\nspecularBase+=info.specular*shadow*lightmapColor;\n#endif\n#endif\n#else\ndiffuseBase+=info.diffuse*shadow;\n#ifdef SPECULARTERM\nspecularBase+=info.specular*shadow;\n#endif\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", -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#if defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X}) && defined(LIGHTMAPNOSPECULAR{X})\n\n#else\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#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\n#if defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X})\nlightDiffuseContribution+=lightmapColor*notShadowLevel;\n#ifdef SPECULARTERM\n#ifndef LIGHTMAPNOSPECULAR{X}\nlightSpecularContribution+=info.specular*notShadowLevel*lightmapColor;\n#endif\n#endif\n#else\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\n#endif",pbrShadowFunctions:"\n#ifdef SHADOWS\n#ifndef SHADOWFULLFLOAT\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}\n#endif\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;\n#ifndef SHADOWFULLFLOAT\nfloat shadow=unpack(textureCube(shadowSampler,directionToLight))+bias;\n#else\nfloat shadow=textureCube(shadowSampler,directionToLight).x+bias;\n#endif\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;\n#ifndef SHADOWFULLFLOAT\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[0]*mapSize))1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\n#ifndef SHADOWFULLFLOAT\nfloat shadow=unpack(texture2D(shadowSampler,uv))+bias;\n#else\nfloat shadow=texture2D(shadowSampler,uv).x+bias;\n#endif\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;\n#ifndef SHADOWFULLFLOAT\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[0]*mapSize))1.0 || uv.y<0. || uv.y>1.0 || depth.z>=1.0)\n{\nreturn 1.0;\n}\nvec4 texel=texture2D(shadowSampler,uv);\n#ifndef SHADOWFULLFLOAT\nvec2 moments=vec2(unpackHalf(texel.xy),unpackHalf(texel.zw));\n#else\nvec2 moments=texel.xy;\n#endif\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\n#ifndef SHADOWFULLFLOAT\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}\n#endif\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;\n#ifndef SHADOWFULLFLOAT\nfloat shadow=unpack(textureCube(shadowSampler,directionToLight))+bias;\n#else\nfloat shadow=textureCube(shadowSampler,directionToLight).x+bias;\n#endif\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;\n#ifndef SHADOWFULLFLOAT\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[0]*mapSize))1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\n#ifndef SHADOWFULLFLOAT\nfloat shadow=unpack(texture2D(shadowSampler,uv))+bias;\n#else\nfloat shadow=texture2D(shadowSampler,uv).x+bias;\n#endif\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;\n#ifndef SHADOWFULLFLOAT\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[0]*mapSize))1.0 || uv.y<0. || uv.y>1.0 || depth.z>=1.0)\n{\nreturn 1.0;\n}\nvec4 texel=texture2D(shadowSampler,uv);\n#ifndef SHADOWFULLFLOAT\nvec2 moments=vec2(unpackHalf(texel.xy),unpackHalf(texel.zw));\n#else\nvec2 moments=texel.xy;\n#endif\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)&&(!(o.x-i>e.x)&&(!(t.y>o.y+i)&&(!(o.y-i>e.y)&&(!(t.z>o.z+i)&&!(o.z-i>e.z)))))},o=function(){var t={root:0,found:!1};return function(e,o,i,s){t.root=0,t.found=!1;var r=o*o-4*e*i;if(r<0)return t;var n=Math.sqrt(r),c=(-o-n)/(2*e),h=(-o+n)/(2*e);if(c>h){var a=h;h=c,c=a}return c>0&&c0&&h=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)&&!!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||V<0)return;h<0&&(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 f=this.velocity.lengthSquared(),m=f;this.basePoint.subtractToRef(s,this._tempVector);var T=2*t.Vector3.Dot(this.velocity,this._tempVector),b=this._tempVector.lengthSquared()-1,y=o(m,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(m,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(m,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(m=g*-f+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(m,T,b,p),y.found){var D=(v*y.root-R)/g;D>=0&&D<=1&&(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),m=g*-f+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(m,T,b,p),y.found&&(D=(v*y.root-R)/g,D>=0&&D<=1&&(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),m=g*-f+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(m,T,b,p),y.found&&(D=(v*y.root-R)/g,D>=0&&D<=1&&(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=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;c1&&!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;t4)){++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}();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()||[])}},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;d0?1:-1},t.Clamp=function(t,i,r){return void 0===i&&(i=0),void 0===r&&(r=1),Math.min(r,Math.max(i,t))},t}();t.MathTools=i;var r=function(){function r(t,i,r){void 0===t&&(t=0),void 0===i&&(i=0),void 0===r&&(r=0),this.r=t,this.g=i,this.b=r}return r.prototype.toString=function(){return"{R: "+this.r+" G:"+this.g+" B:"+this.b+"}"},r.prototype.getClassName=function(){return"Color3"},r.prototype.getHashCode=function(){var t=this.r||0;return t=397*t^(this.g||0),t=397*t^(this.b||0)},r.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},r.prototype.toColor4=function(t){return void 0===t&&(t=1),new n(this.r,this.g,this.b,t)},r.prototype.asArray=function(){var t=[];return this.toArray(t,0),t},r.prototype.toLuminance=function(){return.3*this.r+.59*this.g+.11*this.b},r.prototype.multiply=function(t){return new r(this.r*t.r,this.g*t.g,this.b*t.b)},r.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},r.prototype.equals=function(t){return t&&this.r===t.r&&this.g===t.g&&this.b===t.b},r.prototype.equalsFloats=function(t,i,r){return this.r===t&&this.g===i&&this.b===r},r.prototype.scale=function(t){return new r(this.r*t,this.g*t,this.b*t)},r.prototype.scaleToRef=function(t,i){return i.r=this.r*t,i.g=this.g*t,i.b=this.b*t,this},r.prototype.add=function(t){return new r(this.r+t.r,this.g+t.g,this.b+t.b)},r.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},r.prototype.subtract=function(t){return new r(this.r-t.r,this.g-t.g,this.b-t.b)},r.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},r.prototype.clone=function(){return new r(this.r,this.g,this.b)},r.prototype.copyFrom=function(t){return this.r=t.r,this.g=t.g,this.b=t.b,this},r.prototype.copyFromFloats=function(t,i,r){return this.r=t,this.g=i,this.b=r,this},r.prototype.toHexString=function(){var t=255*this.r|0,r=255*this.g|0,n=255*this.b|0;return"#"+i.ToHex(t)+i.ToHex(r)+i.ToHex(n)},r.prototype.toLinearSpace=function(){var t=new r;return this.toLinearSpaceToRef(t),t},r.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},r.prototype.toGammaSpace=function(){var t=new r;return this.toGammaSpaceToRef(t),t},r.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},r.FromHexString=function(t){if("#"!==t.substring(0,1)||7!==t.length)return new r(0,0,0);var i=parseInt(t.substring(1,3),16),n=parseInt(t.substring(3,5),16),o=parseInt(t.substring(5,7),16);return r.FromInts(i,n,o)},r.FromArray=function(t,i){return void 0===i&&(i=0),new r(t[i],t[i+1],t[i+2])},r.FromInts=function(t,i,n){return new r(t/255,i/255,n/255)},r.Lerp=function(t,i,n){var o=t.r+(i.r-t.r)*n,e=t.g+(i.g-t.g)*n,s=t.b+(i.b-t.b)*n;return new r(o,e,s)},r.Red=function(){return new r(1,0,0)},r.Green=function(){return new r(0,1,0)},r.Blue=function(){return new r(0,0,1)},r.Black=function(){return new r(0,0,0)},r.White=function(){return new r(1,1,1)},r.Purple=function(){return new r(.5,0,.5)},r.Magenta=function(){return new r(1,0,1)},r.Yellow=function(){return new r(1,1,0)},r.Gray=function(){return new r(.5,.5,.5)},r}();t.Color3=r;var n=function(){function t(t,i,r,n){this.r=t,this.g=i,this.b=r,this.a=n}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,r=255*this.g|0,n=255*this.b|0,o=255*this.a|0;return"#"+i.ToHex(t)+i.ToHex(r)+i.ToHex(n)+i.ToHex(o)},t.FromHexString=function(i){if("#"!==i.substring(0,1)||9!==i.length)return new t(0,0,0,0);var r=parseInt(i.substring(1,3),16),n=parseInt(i.substring(3,5),16),o=parseInt(i.substring(5,7),16),e=parseInt(i.substring(7,9),16);return t.FromInts(r,n,o,e)},t.Lerp=function(i,r,n){var o=new t(0,0,0,0);return t.LerpToRef(i,r,n,o),o},t.LerpToRef=function(t,i,r,n){n.r=t.r+(i.r-t.r)*r,n.g=t.g+(i.g-t.g)*r,n.b=t.b+(i.b-t.b)*r,n.a=t.a+(i.a-t.a)*r},t.FromArray=function(i,r){return void 0===r&&(r=0),new t(i[r],i[r+1],i[r+2],i[r+3])},t.FromInts=function(i,r,n,o){return new t(i/255,r/255,n/255,o/255)},t.CheckColors4=function(t,i){if(t.length===3*i){for(var r=[],n=0;nn.x?n.x:o,o=on.y?n.y:e,e=ei.x?t.x:i.x,o=t.y>i.y?t.y:i.y;return new r(n,o)},r.Transform=function(t,i){var n=r.Zero();return r.TransformToRef(t,i,n),n},r.TransformToRef=function(t,i,r){var n=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];r.x=n,r.y=o},r.PointInTriangle=function(t,i,r,n){var o=.5*(-r.y*n.x+i.y*(-r.x+n.x)+i.x*(r.y-n.y)+r.x*n.y),e=o<0?-1:1,s=(i.y*n.x-i.x*n.y+(n.y-i.y)*t.x+(i.x-n.x)*t.y)*e,h=(i.x*r.y-i.y*r.x+(i.y-r.y)*t.x+(r.x-i.x)*t.y)*e;return s>0&&h>0&&s+h<2*o*e},r.Distance=function(t,i){return Math.sqrt(r.DistanceSquared(t,i))},r.DistanceSquared=function(t,i){var r=t.x-i.x,n=t.y-i.y;return r*r+n*n},r.Center=function(t,i){var r=t.add(i);return r.scaleInPlace(.5),r},r.DistanceOfPointFromSegment=function(t,i,n){var o=r.DistanceSquared(i,n);if(0===o)return r.Distance(t,i);var e=n.subtract(i),s=Math.max(0,Math.min(1,r.Dot(t.subtract(i),e)/o)),h=i.add(e.multiplyByFloats(s,s));return r.Distance(t,h)},r}();t.Vector2=o;var e=function(){function r(t,i,r){this.x=t,this.y=i,this.z=r}return r.prototype.toString=function(){return"{X: "+this.x+" Y:"+this.y+" Z:"+this.z+"}"},r.prototype.getClassName=function(){return"Vector3"},r.prototype.getHashCode=function(){var t=this.x||0;return t=397*t^(this.y||0),t=397*t^(this.z||0)},r.prototype.asArray=function(){var t=[];return this.toArray(t,0),t},r.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},r.prototype.toQuaternion=function(){var t=new a(0,0,0,1),i=Math.cos(.5*(this.x+this.z)),r=Math.sin(.5*(this.x+this.z)),n=Math.cos(.5*(this.z-this.x)),o=Math.sin(.5*(this.z-this.x)),e=Math.cos(.5*this.y),s=Math.sin(.5*this.y);return t.x=n*s,t.y=-o*s,t.z=r*e,t.w=i*e,t},r.prototype.addInPlace=function(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this},r.prototype.add=function(t){return new r(this.x+t.x,this.y+t.y,this.z+t.z)},r.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},r.prototype.subtractInPlace=function(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this},r.prototype.subtract=function(t){return new r(this.x-t.x,this.y-t.y,this.z-t.z)},r.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},r.prototype.subtractFromFloats=function(t,i,n){return new r(this.x-t,this.y-i,this.z-n)},r.prototype.subtractFromFloatsToRef=function(t,i,r,n){return n.x=this.x-t,n.y=this.y-i,n.z=this.z-r,this},r.prototype.negate=function(){return new r((-this.x),(-this.y),(-this.z))},r.prototype.scaleInPlace=function(t){return this.x*=t,this.y*=t,this.z*=t,this},r.prototype.scale=function(t){return new r(this.x*t,this.y*t,this.z*t)},r.prototype.scaleToRef=function(t,i){i.x=this.x*t,i.y=this.y*t,i.z=this.z*t},r.prototype.equals=function(t){return t&&this.x===t.x&&this.y===t.y&&this.z===t.z},r.prototype.equalsWithEpsilon=function(r,n){return void 0===n&&(n=t.Epsilon),r&&i.WithinEpsilon(this.x,r.x,n)&&i.WithinEpsilon(this.y,r.y,n)&&i.WithinEpsilon(this.z,r.z,n)},r.prototype.equalsToFloats=function(t,i,r){return this.x===t&&this.y===i&&this.z===r},r.prototype.multiplyInPlace=function(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this},r.prototype.multiply=function(t){return new r(this.x*t.x,this.y*t.y,this.z*t.z)},r.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},r.prototype.multiplyByFloats=function(t,i,n){return new r(this.x*t,this.y*i,this.z*n)},r.prototype.divide=function(t){return new r(this.x/t.x,this.y/t.y,this.z/t.z)},r.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},r.prototype.MinimizeInPlace=function(t){return t.xthis.x&&(this.x=t.x),t.y>this.y&&(this.y=t.y),t.z>this.z&&(this.z=t.z),this},r.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},r.prototype.lengthSquared=function(){return this.x*this.x+this.y*this.y+this.z*this.z},r.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},r.prototype.clone=function(){return new r(this.x,this.y,this.z)},r.prototype.copyFrom=function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this},r.prototype.copyFromFloats=function(t,i,r){return this.x=t,this.y=i,this.z=r,this},r.GetClipFactor=function(t,i,n,o){var e=r.Dot(t,n)-o,s=r.Dot(i,n)-o,h=e/(e-s);return h},r.FromArray=function(t,i){return i||(i=0),new r(t[i],t[i+1],t[i+2])},r.FromFloatArray=function(t,i){return i||(i=0),new r(t[i],t[i+1],t[i+2])},r.FromArrayToRef=function(t,i,r){r.x=t[i],r.y=t[i+1],r.z=t[i+2]},r.FromFloatArrayToRef=function(t,i,r){r.x=t[i],r.y=t[i+1],r.z=t[i+2]},r.FromFloatsToRef=function(t,i,r,n){n.x=t,n.y=i,n.z=r},r.Zero=function(){return new r(0,0,0)},r.Up=function(){return new r(0,1,0)},r.Forward=function(){return new r(0,0,1)},r.Right=function(){return new r(1,0,0)},r.Left=function(){return new r((-1),0,0)},r.TransformCoordinates=function(t,i){var n=r.Zero();return r.TransformCoordinatesToRef(t,i,n),n},r.TransformCoordinatesToRef=function(t,i,r){var n=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],e=t.x*i.m[2]+t.y*i.m[6]+t.z*i.m[10]+i.m[14],s=t.x*i.m[3]+t.y*i.m[7]+t.z*i.m[11]+i.m[15];r.x=n/s,r.y=o/s,r.z=e/s},r.TransformCoordinatesFromFloatsToRef=function(t,i,r,n,o){var e=t*n.m[0]+i*n.m[4]+r*n.m[8]+n.m[12],s=t*n.m[1]+i*n.m[5]+r*n.m[9]+n.m[13],h=t*n.m[2]+i*n.m[6]+r*n.m[10]+n.m[14],a=t*n.m[3]+i*n.m[7]+r*n.m[11]+n.m[15];o.x=e/a,o.y=s/a,o.z=h/a},r.TransformNormal=function(t,i){var n=r.Zero();return r.TransformNormalToRef(t,i,n),n},r.TransformNormalToRef=function(t,i,r){var n=t.x*i.m[0]+t.y*i.m[4]+t.z*i.m[8],o=t.x*i.m[1]+t.y*i.m[5]+t.z*i.m[9],e=t.x*i.m[2]+t.y*i.m[6]+t.z*i.m[10];r.x=n,r.y=o,r.z=e},r.TransformNormalFromFloatsToRef=function(t,i,r,n,o){o.x=t*n.m[0]+i*n.m[4]+r*n.m[8],o.y=t*n.m[1]+i*n.m[5]+r*n.m[9],o.z=t*n.m[2]+i*n.m[6]+r*n.m[10]},r.CatmullRom=function(t,i,n,o,e){var s=e*e,h=e*s,a=.5*(2*i.x+(-t.x+n.x)*e+(2*t.x-5*i.x+4*n.x-o.x)*s+(-t.x+3*i.x-3*n.x+o.x)*h),u=.5*(2*i.y+(-t.y+n.y)*e+(2*t.y-5*i.y+4*n.y-o.y)*s+(-t.y+3*i.y-3*n.y+o.y)*h),m=.5*(2*i.z+(-t.z+n.z)*e+(2*t.z-5*i.z+4*n.z-o.z)*s+(-t.z+3*i.z-3*n.z+o.z)*h);return new r(a,u,m)},r.Clamp=function(t,i,n){var o=t.x;o=o>n.x?n.x:o,o=on.y?n.y:e,e=en.z?n.z:s,s=sthis.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},r.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},r.prototype.lengthSquared=function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},r.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},r.prototype.toVector3=function(){return new e(this.x,this.y,this.z)},r.prototype.clone=function(){return new r(this.x,this.y,this.z,this.w)},r.prototype.copyFrom=function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w,this},r.prototype.copyFromFloats=function(t,i,r,n){return this.x=t,this.y=i,this.z=r,this.w=n,this},r.FromArray=function(t,i){return i||(i=0),new r(t[i],t[i+1],t[i+2],t[i+3])},r.FromArrayToRef=function(t,i,r){r.x=t[i],r.y=t[i+1],r.z=t[i+2],r.w=t[i+3]},r.FromFloatArrayToRef=function(t,i,r){r.x=t[i],r.y=t[i+1],r.z=t[i+2],r.w=t[i+3]},r.FromFloatsToRef=function(t,i,r,n,o){o.x=t,o.y=i,o.z=r,o.w=n},r.Zero=function(){return new r(0,0,0,0)},r.Normalize=function(t){var i=r.Zero();return r.NormalizeToRef(t,i),i},r.NormalizeToRef=function(t,i){i.copyFrom(t),i.normalize()},r.Minimize=function(t,i){var r=t.clone();return r.MinimizeInPlace(i),r},r.Maximize=function(t,i){var r=t.clone();return r.MaximizeInPlace(i),r},r.Distance=function(t,i){return Math.sqrt(r.DistanceSquared(t,i))},r.DistanceSquared=function(t,i){var r=t.x-i.x,n=t.y-i.y,o=t.z-i.z,e=t.w-i.w;return r*r+n*n+o*o+e*e},r.Center=function(t,i){var r=t.add(i);return r.scaleInPlace(.5),r},r}();t.Vector4=s;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.copyFromFloats=function(t,i){this.width=t,this.height=i},t.prototype.multiplyByFloats=function(i,r){return new t(this.width*i,this.height*r)},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)},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 r=new t(this.width+i.width,this.height+i.height);return r},t.prototype.substract=function(i){var r=new t(this.width-i.width,this.height-i.height);return r},t.Lerp=function(i,r,n){var o=i.width+(r.width-i.width)*n,e=i.height+(r.height-i.height)*n;return new t(o,e)},t}();t.Size=h;var a=function(){function t(t,i,r,n){void 0===t&&(t=0),void 0===i&&(i=0),void 0===r&&(r=0),void 0===n&&(n=1),this.x=t,this.y=i,this.z=r,this.w=n}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,r,n){return this.x=t,this.y=i,this.z=r,this.w=n,this},t.prototype.add=function(i){return new t(this.x+i.x,this.y+i.y,this.z+i.z,this.w+i.w)},t.prototype.subtract=function(i){return new t(this.x-i.x,this.y-i.y,this.z-i.z,this.w-i.w)},t.prototype.scale=function(i){return new t(this.x*i,this.y*i,this.z*i,this.w*i)},t.prototype.multiply=function(i){var r=new t(0,0,0,1);return this.multiplyToRef(i,r),r},t.prototype.multiplyToRef=function(t,i){var r=this.x*t.w+this.y*t.z-this.z*t.y+this.w*t.x,n=-this.x*t.z+this.y*t.w+this.z*t.x+this.w*t.y,o=this.x*t.y-this.y*t.x+this.z*t.w+this.w*t.z,e=-this.x*t.x-this.y*t.y-this.z*t.z+this.w*t.w;return i.copyFromFloats(r,n,o,e),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=e.Zero();return this.toEulerAnglesToRef(i,t),i},t.prototype.toEulerAnglesToRef=function(t,i){void 0===i&&(i="YZX");var r=this.z,n=this.x,o=this.y,e=this.w,s=e*e,h=r*r,a=n*n,u=o*o,m=o*r-n*e,y=.4999999;return m<-y?(t.y=2*Math.atan2(o,e),t.x=Math.PI/2,t.z=0):m>y?(t.y=2*Math.atan2(o,e),t.x=-Math.PI/2,t.z=0):(t.z=Math.atan2(2*(n*o+r*e),-h-a+u+s),t.x=Math.asin(-2*(r*o-n*e)),t.y=Math.atan2(2*(r*n+o*e),h-a-u+s)),this},t.prototype.toRotationMatrix=function(t){var i=this.x*this.x,r=this.y*this.y,n=this.z*this.z,o=this.x*this.y,e=this.z*this.w,s=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*(r+n),t.m[1]=2*(o+e),t.m[2]=2*(s-h),t.m[3]=0,t.m[4]=2*(o-e),t.m[5]=1-2*(n+i),t.m[6]=2*(a+u),t.m[7]=0,t.m[8]=2*(s+h),t.m[9]=2*(a-u),t.m[10]=1-2*(r+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 r=new t;return t.FromRotationMatrixToRef(i,r),r},t.FromRotationMatrixToRef=function(t,i){var r,n=t.m,o=n[0],e=n[4],s=n[8],h=n[1],a=n[5],u=n[9],m=n[2],y=n[6],c=n[10],p=o+a+c;p>0?(r=.5/Math.sqrt(p+1),i.w=.25/r,i.x=(y-u)*r,i.y=(s-m)*r,i.z=(h-e)*r):o>a&&o>c?(r=2*Math.sqrt(1+o-a-c),i.w=(y-u)/r,i.x=.25*r,i.y=(e+h)/r,i.z=(s+m)/r):a>c?(r=2*Math.sqrt(1+a-o-c),i.w=(s-m)/r,i.x=(e+h)/r,i.y=.25*r,i.z=(u+y)/r):(r=2*Math.sqrt(1+c-o-a),i.w=(h-e)/r,i.x=(s+m)/r,i.y=(u+y)/r,i.z=.25*r)},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,r){return t.RotationAxisToRef(i,r,new t)},t.RotationAxisToRef=function(t,i,r){var 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},t.FromArray=function(i,r){return r||(r=0),new t(i[r],i[r+1],i[r+2],i[r+3])},t.RotationYawPitchRoll=function(i,r,n){var o=new t;return t.RotationYawPitchRollToRef(i,r,n,o),o},t.RotationYawPitchRollToRef=function(t,i,r,n){var o=.5*r,e=.5*i,s=.5*t,h=Math.sin(o),a=Math.cos(o),u=Math.sin(e),m=Math.cos(e),y=Math.sin(s),c=Math.cos(s);n.x=c*u*a+y*m*h,n.y=y*m*a-c*u*h,n.z=c*m*h-y*u*a,n.w=c*m*a+y*u*h},t.RotationAlphaBetaGamma=function(i,r,n){var o=new t;return t.RotationAlphaBetaGammaToRef(i,r,n,o),o},t.RotationAlphaBetaGammaToRef=function(t,i,r,n){var o=.5*(r+t),e=.5*(r-t),s=.5*i;n.x=Math.cos(e)*Math.sin(s),n.y=Math.sin(e)*Math.sin(s),n.z=Math.sin(o)*Math.cos(s),n.w=Math.cos(o)*Math.cos(s)},t.Slerp=function(i,r,n){var o=t.Identity();return t.SlerpToRef(i,r,n,o),o},t.SlerpToRef=function(t,i,r,n){var o,e,s=r,h=t.x*i.x+t.y*i.y+t.z*i.z+t.w*i.w,a=!1;if(h<0&&(a=!0,h=-h),h>.999999)e=1-s,o=a?-s:s;else{var u=Math.acos(h),m=1/Math.sin(u);e=Math.sin((1-s)*u)*m,o=a?-Math.sin(s*u)*m:Math.sin(s*u)*m}n.x=e*t.x+o*i.x,n.y=e*t.y+o*i.y,n.z=e*t.z+o*i.z,n.w=e*t.w+o*i.w},t}();t.Quaternion=a;var u=function(){function r(){this.m=new Float32Array(16)}return r.prototype.isIdentity=function(){return 1===this.m[0]&&1===this.m[5]&&1===this.m[10]&&1===this.m[15]&&(0===this.m[1]&&0===this.m[2]&&0===this.m[3]&&0===this.m[4]&&0===this.m[6]&&0===this.m[7]&&0===this.m[8]&&0===this.m[9]&&0===this.m[11]&&0===this.m[12]&&0===this.m[13]&&0===this.m[14])},r.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],r=this.m[9]*this.m[14]-this.m[10]*this.m[13],n=this.m[8]*this.m[15]-this.m[11]*this.m[12],o=this.m[8]*this.m[14]-this.m[10]*this.m[12],e=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]*r)-this.m[1]*(this.m[4]*t-this.m[6]*n+this.m[7]*o)+this.m[2]*(this.m[4]*i-this.m[5]*n+this.m[7]*e)-this.m[3]*(this.m[4]*r-this.m[5]*o+this.m[6]*e)},r.prototype.toArray=function(){return this.m},r.prototype.asArray=function(){return this.toArray()},r.prototype.invert=function(){return this.invertToRef(this),this},r.prototype.reset=function(){for(var t=0;t<16;t++)this.m[t]=0;return this},r.prototype.add=function(t){var i=new r;return this.addToRef(t,i),i},r.prototype.addToRef=function(t,i){for(var r=0;r<16;r++)i.m[r]=this.m[r]+t.m[r];return this},r.prototype.addToSelf=function(t){for(var i=0;i<16;i++)this.m[i]+=t.m[i];return this},r.prototype.invertToRef=function(t){var i=this.m[0],r=this.m[1],n=this.m[2],o=this.m[3],e=this.m[4],s=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],x=this.m[14],l=this.m[15],z=y*l-c*x,w=m*l-c*f,v=m*x-y*f,d=u*l-c*p,g=u*x-y*p,R=u*f-m*p,T=s*z-h*w+a*v,_=-(e*z-h*d+a*g),M=e*w-s*d+a*R,A=-(e*v-s*g+h*R),F=1/(i*T+r*_+n*M+o*A),b=h*l-a*x,L=s*l-a*f,C=s*x-h*f,P=e*l-a*p,Z=e*x-h*p,S=e*f-s*p,I=h*c-a*y,H=s*c-a*m,V=s*y-h*m,q=e*c-a*u,D=e*y-h*u,N=e*m-s*u;return t.m[0]=T*F,t.m[4]=_*F,t.m[8]=M*F,t.m[12]=A*F,t.m[1]=-(r*z-n*w+o*v)*F,t.m[5]=(i*z-n*d+o*g)*F,t.m[9]=-(i*w-r*d+o*R)*F,t.m[13]=(i*v-r*g+n*R)*F,t.m[2]=(r*b-n*L+o*C)*F,t.m[6]=-(i*b-n*P+o*Z)*F,t.m[10]=(i*L-r*P+o*S)*F,t.m[14]=-(i*C-r*Z+n*S)*F,t.m[3]=-(r*I-n*H+o*V)*F,t.m[7]=(i*I-n*q+o*D)*F,t.m[11]=-(i*H-r*q+o*N)*F,t.m[15]=(i*V-r*D+n*N)*F,this},r.prototype.setTranslation=function(t){return this.m[12]=t.x,this.m[13]=t.y,this.m[14]=t.z,this},r.prototype.getTranslation=function(){return new e(this.m[12],this.m[13],this.m[14])},r.prototype.multiply=function(t){var i=new r;return this.multiplyToRef(t,i),i},r.prototype.copyFrom=function(t){\nfor(var i=0;i<16;i++)this.m[i]=t.m[i];return this},r.prototype.copyToArray=function(t,i){void 0===i&&(i=0);for(var r=0;r<16;r++)t[i+r]=this.m[r];return this},r.prototype.multiplyToRef=function(t,i){return this.multiplyToArray(t,i.m,0),this},r.prototype.multiplyToArray=function(t,i,r){var n=this.m[0],o=this.m[1],e=this.m[2],s=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],x=this.m[12],l=this.m[13],z=this.m[14],w=this.m[15],v=t.m[0],d=t.m[1],g=t.m[2],R=t.m[3],T=t.m[4],_=t.m[5],M=t.m[6],A=t.m[7],F=t.m[8],b=t.m[9],L=t.m[10],C=t.m[11],P=t.m[12],Z=t.m[13],S=t.m[14],I=t.m[15];return i[r]=n*v+o*T+e*F+s*P,i[r+1]=n*d+o*_+e*b+s*Z,i[r+2]=n*g+o*M+e*L+s*S,i[r+3]=n*R+o*A+e*C+s*I,i[r+4]=h*v+a*T+u*F+m*P,i[r+5]=h*d+a*_+u*b+m*Z,i[r+6]=h*g+a*M+u*L+m*S,i[r+7]=h*R+a*A+u*C+m*I,i[r+8]=y*v+c*T+p*F+f*P,i[r+9]=y*d+c*_+p*b+f*Z,i[r+10]=y*g+c*M+p*L+f*S,i[r+11]=y*R+c*A+p*C+f*I,i[r+12]=x*v+l*T+z*F+w*P,i[r+13]=x*d+l*_+z*b+w*Z,i[r+14]=x*g+l*M+z*L+w*S,i[r+15]=x*R+l*A+z*C+w*I,this},r.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]},r.prototype.clone=function(){return r.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])},r.prototype.getClassName=function(){return"Matrix"},r.prototype.getHashCode=function(){for(var t=this.m[0]||0,i=1;i<16;i++)t=397*t^(this.m[i]||0);return t},r.prototype.decompose=function(t,n,o){o.x=this.m[12],o.y=this.m[13],o.z=this.m[14];var e=i.Sign(this.m[0]*this.m[1]*this.m[2]*this.m[3])<0?-1:1,s=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;return t.x=e*Math.sqrt(this.m[0]*this.m[0]+this.m[1]*this.m[1]+this.m[2]*this.m[2]),t.y=s*Math.sqrt(this.m[4]*this.m[4]+this.m[5]*this.m[5]+this.m[6]*this.m[6]),t.z=h*Math.sqrt(this.m[8]*this.m[8]+this.m[9]*this.m[9]+this.m[10]*this.m[10]),0===t.x||0===t.y||0===t.z?(n.x=0,n.y=0,n.z=0,n.w=1,!1):(r.FromValuesToRef(this.m[0]/t.x,this.m[1]/t.x,this.m[2]/t.x,0,this.m[4]/t.y,this.m[5]/t.y,this.m[6]/t.y,0,this.m[8]/t.z,this.m[9]/t.z,this.m[10]/t.z,0,0,0,0,1,A.Matrix[0]),a.FromRotationMatrixToRef(A.Matrix[0],n),!0)},r.prototype.getRotationMatrix=function(){var t=r.Identity();return this.getRotationMatrixToRef(t),t},r.prototype.getRotationMatrixToRef=function(t){var i=this.m,n=i[0]*i[1]*i[2]*i[3]<0?-1:1,o=i[4]*i[5]*i[6]*i[7]<0?-1:1,e=i[8]*i[9]*i[10]*i[11]<0?-1:1,s=n*Math.sqrt(i[0]*i[0]+i[1]*i[1]+i[2]*i[2]),h=o*Math.sqrt(i[4]*i[4]+i[5]*i[5]+i[6]*i[6]),a=e*Math.sqrt(i[8]*i[8]+i[9]*i[9]+i[10]*i[10]);r.FromValuesToRef(i[0]/s,i[1]/s,i[2]/s,0,i[4]/h,i[5]/h,i[6]/h,0,i[8]/a,i[9]/a,i[10]/a,0,0,0,0,1,t)},r.FromArray=function(t,i){var n=new r;return i||(i=0),r.FromArrayToRef(t,i,n),n},r.FromArrayToRef=function(t,i,r){for(var n=0;n<16;n++)r.m[n]=t[n+i]},r.FromFloat32ArrayToRefScaled=function(t,i,r,n){for(var o=0;o<16;o++)n.m[o]=t[o+i]*r},r.FromValuesToRef=function(t,i,r,n,o,e,s,h,a,u,m,y,c,p,f,x,l){l.m[0]=t,l.m[1]=i,l.m[2]=r,l.m[3]=n,l.m[4]=o,l.m[5]=e,l.m[6]=s,l.m[7]=h,l.m[8]=a,l.m[9]=u,l.m[10]=m,l.m[11]=y,l.m[12]=c,l.m[13]=p,l.m[14]=f,l.m[15]=x},r.prototype.getRow=function(t){if(t<0||t>3)return null;var i=4*t;return new s(this.m[i+0],this.m[i+1],this.m[i+2],this.m[i+3])},r.prototype.setRow=function(t,i){if(t<0||t>3)return this;var r=4*t;return this.m[r+0]=i.x,this.m[r+1]=i.y,this.m[r+2]=i.z,this.m[r+3]=i.w,this},r.FromValues=function(t,i,n,o,e,s,h,a,u,m,y,c,p,f,x,l){var z=new r;return z.m[0]=t,z.m[1]=i,z.m[2]=n,z.m[3]=o,z.m[4]=e,z.m[5]=s,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]=x,z.m[15]=l,z},r.Compose=function(t,i,n){var o=r.FromValues(t.x,0,0,0,0,t.y,0,0,0,0,t.z,0,0,0,0,1),e=r.Identity();return i.toRotationMatrix(e),o=o.multiply(e),o.setTranslation(n),o},r.Identity=function(){return r.FromValues(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1)},r.IdentityToRef=function(t){r.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,t)},r.Zero=function(){return r.FromValues(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)},r.RotationX=function(t){var i=new r;return r.RotationXToRef(t,i),i},r.Invert=function(t){var i=new r;return t.invertToRef(i),i},r.RotationXToRef=function(t,i){var r=Math.sin(t),n=Math.cos(t);i.m[0]=1,i.m[15]=1,i.m[5]=n,i.m[10]=n,i.m[9]=-r,i.m[6]=r,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},r.RotationY=function(t){var i=new r;return r.RotationYToRef(t,i),i},r.RotationYToRef=function(t,i){var r=Math.sin(t),n=Math.cos(t);i.m[5]=1,i.m[15]=1,i.m[0]=n,i.m[2]=-r,i.m[8]=r,i.m[10]=n,i.m[1]=0,i.m[3]=0,i.m[4]=0,i.m[6]=0,i.m[7]=0,i.m[9]=0,i.m[11]=0,i.m[12]=0,i.m[13]=0,i.m[14]=0},r.RotationZ=function(t){var i=new r;return r.RotationZToRef(t,i),i},r.RotationZToRef=function(t,i){var r=Math.sin(t),n=Math.cos(t);i.m[10]=1,i.m[15]=1,i.m[0]=n,i.m[1]=r,i.m[4]=-r,i.m[5]=n,i.m[2]=0,i.m[3]=0,i.m[6]=0,i.m[7]=0,i.m[8]=0,i.m[9]=0,i.m[11]=0,i.m[12]=0,i.m[13]=0,i.m[14]=0},r.RotationAxis=function(t,i){var n=r.Zero();return r.RotationAxisToRef(t,i,n),n},r.RotationAxisToRef=function(t,i,r){var n=Math.sin(-i),o=Math.cos(-i),e=1-o;t.normalize(),r.m[0]=t.x*t.x*e+o,r.m[1]=t.x*t.y*e-t.z*n,r.m[2]=t.x*t.z*e+t.y*n,r.m[3]=0,r.m[4]=t.y*t.x*e+t.z*n,r.m[5]=t.y*t.y*e+o,r.m[6]=t.y*t.z*e-t.x*n,r.m[7]=0,r.m[8]=t.z*t.x*e-t.y*n,r.m[9]=t.z*t.y*e+t.x*n,r.m[10]=t.z*t.z*e+o,r.m[11]=0,r.m[15]=1},r.RotationYawPitchRoll=function(t,i,n){var o=new r;return r.RotationYawPitchRollToRef(t,i,n,o),o},r.RotationYawPitchRollToRef=function(t,i,r,n){a.RotationYawPitchRollToRef(t,i,r,this._tempQuaternion),this._tempQuaternion.toRotationMatrix(n)},r.Scaling=function(t,i,n){var o=r.Zero();return r.ScalingToRef(t,i,n,o),o},r.ScalingToRef=function(t,i,r,n){n.m[0]=t,n.m[1]=0,n.m[2]=0,n.m[3]=0,n.m[4]=0,n.m[5]=i,n.m[6]=0,n.m[7]=0,n.m[8]=0,n.m[9]=0,n.m[10]=r,n.m[11]=0,n.m[12]=0,n.m[13]=0,n.m[14]=0,n.m[15]=1},r.Translation=function(t,i,n){var o=r.Identity();return r.TranslationToRef(t,i,n,o),o},r.TranslationToRef=function(t,i,n,o){r.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,t,i,n,1,o)},r.Lerp=function(t,i,n){for(var o=r.Zero(),e=0;e<16;e++)o.m[e]=t.m[e]*(1-n)+i.m[e]*n;return o},r.DecomposeLerp=function(t,i,n){var o=new e(0,0,0),s=new a,h=new e(0,0,0);t.decompose(o,s,h);var u=new e(0,0,0),m=new a,y=new e(0,0,0);i.decompose(u,m,y);var c=e.Lerp(o,u,n),p=a.Slerp(s,m,n),f=e.Lerp(h,y,n);return r.Compose(c,p,f)},r.LookAtLH=function(t,i,n){var o=r.Zero();return r.LookAtLHToRef(t,i,n,o),o},r.LookAtLHToRef=function(t,i,n,o){i.subtractToRef(t,this._zAxis),this._zAxis.normalize(),e.CrossToRef(n,this._zAxis,this._xAxis),0===this._xAxis.lengthSquared()?this._xAxis.x=1:this._xAxis.normalize(),e.CrossToRef(this._zAxis,this._xAxis,this._yAxis),this._yAxis.normalize();var s=-e.Dot(this._xAxis,t),h=-e.Dot(this._yAxis,t),a=-e.Dot(this._zAxis,t);return r.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,h,a,1,o)},r.LookAtRH=function(t,i,n){var o=r.Zero();return r.LookAtRHToRef(t,i,n,o),o},r.LookAtRHToRef=function(t,i,n,o){t.subtractToRef(i,this._zAxis),this._zAxis.normalize(),e.CrossToRef(n,this._zAxis,this._xAxis),0===this._xAxis.lengthSquared()?this._xAxis.x=1:this._xAxis.normalize(),e.CrossToRef(this._zAxis,this._xAxis,this._yAxis),this._yAxis.normalize();var s=-e.Dot(this._xAxis,t),h=-e.Dot(this._yAxis,t),a=-e.Dot(this._zAxis,t);return r.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,h,a,1,o)},r.OrthoLH=function(t,i,n,o){var e=r.Zero();return r.OrthoLHToRef(t,i,n,o,e),e},r.OrthoLHToRef=function(i,r,n,o,e){var s=n,h=o,a=2/i,u=2/r,m=2/(h-s),y=-(h+s)/(h-s);t.Matrix.FromValuesToRef(a,0,0,0,0,u,0,0,0,0,m,0,0,0,y,1,e)},r.OrthoOffCenterLH=function(t,i,n,o,e,s){var h=r.Zero();return r.OrthoOffCenterLHToRef(t,i,n,o,e,s,h),h},r.OrthoOffCenterLHToRef=function(i,r,n,o,e,s,h){var a=e,u=s,m=2/(r-i),y=2/(o-n),c=2/(u-a),p=-(u+a)/(u-a),f=(i+r)/(i-r),x=(o+n)/(n-o);t.Matrix.FromValuesToRef(m,0,0,0,0,y,0,0,0,0,c,0,f,x,p,1,h)},r.OrthoOffCenterRH=function(t,i,n,o,e,s){var h=r.Zero();return r.OrthoOffCenterRHToRef(t,i,n,o,e,s,h),h},r.OrthoOffCenterRHToRef=function(t,i,n,o,e,s,h){r.OrthoOffCenterLHToRef(t,i,n,o,e,s,h),h.m[10]*=-1},r.PerspectiveLH=function(i,n,o,e){var s=r.Zero(),h=o,a=e,u=2*h/i,m=2*h/n,y=(a+h)/(a-h),c=-2*a*h/(a-h);return t.Matrix.FromValuesToRef(u,0,0,0,0,m,0,0,0,0,y,1,0,0,c,0,s),s},r.PerspectiveFovLH=function(t,i,n,o){var e=r.Zero();return r.PerspectiveFovLHToRef(t,i,n,o,e),e},r.PerspectiveFovLHToRef=function(i,r,n,o,e,s){void 0===s&&(s=!0);var h=n,a=o,u=1/Math.tan(.5*i),m=s?u/r:u,y=s?u:u*r,c=(a+h)/(a-h),p=-2*a*h/(a-h);t.Matrix.FromValuesToRef(m,0,0,0,0,y,0,0,0,0,c,1,0,0,p,0,e)},r.PerspectiveFovRH=function(t,i,n,o){var e=r.Zero();return r.PerspectiveFovRHToRef(t,i,n,o,e),e},r.PerspectiveFovRHToRef=function(i,r,n,o,e,s){void 0===s&&(s=!0);var h=n,a=o,u=1/Math.tan(.5*i),m=s?u/r:u,y=s?u:u*r,c=-(a+h)/(a-h),p=-2*a*h/(a-h);t.Matrix.FromValuesToRef(m,0,0,0,0,y,0,0,0,0,c,-1,0,0,p,0,e)},r.PerspectiveFovWebVRToRef=function(t,i,r,n,o){void 0===o&&(o=!0);var e=Math.tan(t.upDegrees*Math.PI/180),s=Math.tan(t.downDegrees*Math.PI/180),h=Math.tan(t.leftDegrees*Math.PI/180),a=Math.tan(t.rightDegrees*Math.PI/180),u=2/(h+a),m=2/(e+s);n.m[0]=u,n.m[1]=n.m[2]=n.m[3]=n.m[4]=0,n.m[5]=m,n.m[6]=n.m[7]=0,n.m[8]=(h-a)*u*.5,n.m[9]=-((e-s)*m*.5),n.m[10]=-(i+r)/(r-i),n.m[11]=1,n.m[12]=n.m[13]=n.m[15]=0,n.m[14]=-(2*r*i)/(r-i)},r.GetFinalMatrix=function(t,i,n,o,e,s){var h=t.width,a=t.height,u=t.x,m=t.y,y=r.FromValues(h/2,0,0,0,0,-a/2,0,0,0,0,s-e,0,u+h/2,a/2+m,e,1);return i.multiply(n).multiply(o).multiply(y)},r.GetAsMatrix2x2=function(t){return new Float32Array([t.m[0],t.m[1],t.m[4],t.m[5]])},r.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]])},r.Transpose=function(t){var i=new r;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},r.Reflection=function(t){var i=new r;return r.ReflectionToRef(t,i),i},r.ReflectionToRef=function(t,i){t.normalize();var r=t.normal.x,n=t.normal.y,o=t.normal.z,e=-2*r,s=-2*n,h=-2*o;i.m[0]=e*r+1,i.m[1]=s*r,i.m[2]=h*r,i.m[3]=0,i.m[4]=e*n,i.m[5]=s*n+1,i.m[6]=h*n,i.m[7]=0,i.m[8]=e*o,i.m[9]=s*o,i.m[10]=h*o+1,i.m[11]=0,i.m[12]=e*t.d,i.m[13]=s*t.d,i.m[14]=h*t.d,i.m[15]=1},r.FromXYZAxesToRef=function(t,i,r,n){n.m[0]=t.x,n.m[1]=t.y,n.m[2]=t.z,n.m[3]=0,n.m[4]=i.x,n.m[5]=i.y,n.m[6]=i.z,n.m[7]=0,n.m[8]=r.x,n.m[9]=r.y,n.m[10]=r.z,n.m[11]=0,n.m[12]=0,n.m[13]=0,n.m[14]=0,n.m[15]=1},r.FromQuaternionToRef=function(t,i){var r=t.x*t.x,n=t.y*t.y,o=t.z*t.z,e=t.x*t.y,s=t.z*t.w,h=t.z*t.x,a=t.y*t.w,u=t.y*t.z,m=t.x*t.w;i.m[0]=1-2*(n+o),i.m[1]=2*(e+s),i.m[2]=2*(h-a),i.m[3]=0,i.m[4]=2*(e-s),i.m[5]=1-2*(o+r),i.m[6]=2*(u+m),i.m[7]=0,i.m[8]=2*(h+a),i.m[9]=2*(u-m),i.m[10]=1-2*(n+r),i.m[11]=0,i.m[12]=0,i.m[13]=0,i.m[14]=0,i.m[15]=1},r}();u._tempQuaternion=new a,u._xAxis=e.Zero(),u._yAxis=e.Zero(),u._zAxis=e.Zero(),t.Matrix=u;var m=function(){function t(t,i,r,n){this.normal=new e(t,i,r),this.d=n}return t.prototype.asArray=function(){return[this.normal.x,this.normal.y,this.normal.z,this.d]},t.prototype.clone=function(){return new t(this.normal.x,this.normal.y,this.normal.z,this.d)},t.prototype.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 r=u.Transpose(i),n=this.normal.x,o=this.normal.y,e=this.normal.z,s=this.d,h=n*r.m[0]+o*r.m[1]+e*r.m[2]+s*r.m[3],a=n*r.m[4]+o*r.m[5]+e*r.m[6]+s*r.m[7],m=n*r.m[8]+o*r.m[9]+e*r.m[10]+s*r.m[11],y=n*r.m[12]+o*r.m[13]+e*r.m[14]+s*r.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,r){var n,o=i.x-t.x,e=i.y-t.y,s=i.z-t.z,h=r.x-t.x,a=r.y-t.y,u=r.z-t.z,m=e*u-s*a,y=s*h-o*u,c=o*a-e*h,p=Math.sqrt(m*m+y*y+c*c);return n=0!==p?1/p:0,this.normal.x=m*n,this.normal.y=y*n,this.normal.z=c*n,this.d=-(this.normal.x*t.x+this.normal.y*t.y+this.normal.z*t.z),this},t.prototype.isFrontFacingTo=function(t,i){var r=e.Dot(this.normal,t);return r<=i},t.prototype.signedDistanceTo=function(t){return e.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,r,n){var o=new t(0,0,0,0);return o.copyFromPoints(i,r,n),o},t.FromPositionAndNormal=function(i,r){var n=new t(0,0,0,0);return r.normalize(),n.normal=r,n.d=-(r.x*i.x+r.y*i.y+r.z*i.z),n},t.SignedDistanceToPlaneFromPositionAndNormal=function(t,i,r){var n=-(i.x*t.x+i.y*t.y+i.z*t.z);return e.Dot(r,i)+n},t}();t.Plane=m;var y=function(){function t(t,i,r,n){this.x=t,this.y=i,this.width=r,this.height=n}return t.prototype.toGlobal=function(i,r){return new t(this.x*i,this.y*r,this.width*i,this.height*r)},t}();t.Viewport=y;var c=function(){function t(){}return t.GetPlanes=function(i){for(var r=[],n=0;n<6;n++)r.push(new m(0,0,0,0));return t.GetPlanesToRef(i,r),r},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;var p;!function(t){t[t.LOCAL=0]="LOCAL",t[t.WORLD=1]="WORLD"}(p=t.Space||(t.Space={}));var f=function(){function t(){}return t}();f.X=new e(1,0,0),f.Y=new e(0,1,0),f.Z=new e(0,0,1),t.Axis=f;var x=function(){function t(){}return t.interpolate=function(t,i,r,n,o){for(var e=1-3*n+3*i,s=3*n-6*i,h=3*i,a=t,u=0;u<5;u++){var m=a*a,y=m*a,c=e*y+s*m+h*a,p=1/(3*e*m+2*s*a+h);a-=(c-t)*p,a=Math.min(1,Math.max(0,a))}return 3*Math.pow(1-a,2)*a*r+3*(1-a)*Math.pow(a,2)*o+Math.pow(a,3)},t}();t.BezierCurve=x;var l;!function(t){t[t.CW=0]="CW",t[t.CCW=1]="CCW"}(l=t.Orientation||(t.Orientation={}));var z=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,r){var n=r.subtract(i),o=Math.atan2(n.y,n.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=z;var w=function(){function t(t,i,r){this.startPoint=t,this.midPoint=i,this.endPoint=r;var n=Math.pow(i.x,2)+Math.pow(i.y,2),e=(Math.pow(t.x,2)+Math.pow(t.y,2)-n)/2,s=(n-Math.pow(r.x,2)-Math.pow(r.y,2))/2,h=(t.x-i.x)*(i.y-r.y)-(i.x-r.x)*(t.y-i.y);this.centerPoint=new o((e*(i.y-r.y)-s*(t.y-i.y))/h,((t.x-i.x)*s-(i.x-r.x)*e)/h),this.radius=this.centerPoint.subtract(this.startPoint).length(),this.startAngle=z.BetweenTwoPoints(this.centerPoint,this.startPoint);var a=this.startAngle.degrees(),u=z.BetweenTwoPoints(this.centerPoint,this.midPoint).degrees(),m=z.BetweenTwoPoints(this.centerPoint,this.endPoint).degrees();u-a>180&&(u-=360),u-a<-180&&(u+=360),m-u>180&&(m-=360),m-u<-180&&(m+=360),this.orientation=u-a<0?l.CW:l.CCW,this.angle=z.FromDegrees(this.orientation===l.CW?a-m:m-a)}return t}();t.Arc2=w;var v=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 r=new o(t,i),n=this._points[this._points.length-1];return this._points.push(r),this._length+=r.subtract(n).length(),this},t.prototype.addArcTo=function(t,i,r,n,e){if(void 0===e&&(e=36),closed)return this;var s=this._points[this._points.length-1],h=new o(t,i),a=new o(r,n),u=new w(s,h,a),m=u.angle.radians()/e;u.orientation===l.CW&&(m*=-1);for(var y=u.startAngle.radians()+m,c=0;c1)return o.Zero();for(var i=t*this.length(),r=0,n=0;n=r&&i<=u){var m=a.normalize(),y=i-r;return new o(s.x+m.x*y,s.y+m.y*y)}r=u}return o.Zero()},t.StartingAt=function(i,r){return new t(i,r)},t}();t.Path2=v;var d=function(){function r(t,i,r){this.path=t,this._curve=new Array,this._distances=new Array,this._tangents=new Array,this._normals=new Array,this._binormals=new Array;for(var n=0;ni+1;)i++,r=this._curve[t].subtract(this._curve[t-i]);return r},r.prototype._normalVector=function(r,n,o){var s,h=n.length();if(0===h&&(h=1),void 0===o||null===o){var a;i.WithinEpsilon(Math.abs(n.y)/h,1,t.Epsilon)?i.WithinEpsilon(Math.abs(n.x)/h,1,t.Epsilon)?i.WithinEpsilon(Math.abs(n.z)/h,1,t.Epsilon)||(a=new e(0,0,1)):a=new e(1,0,0):a=new e(0,(-1),0),s=e.Cross(n,a)}else s=e.Cross(n,o),e.CrossToRef(s,n,s);return s.normalize(),s},r}();t.Path3D=d;var g=function(){function t(t){this._length=0,this._points=t,this._length=this._computeLength(t)}return t.CreateQuadraticBezier=function(i,r,n,o){o=o>2?o:3;for(var s=new Array,h=function(t,i,r,n){var o=(1-t)*(1-t)*i+2*t*(1-t)*r+t*t*n;return o},a=0;a<=o;a++)s.push(new e(h(a/o,i.x,r.x,n.x),h(a/o,i.y,r.y,n.y),h(a/o,i.z,r.z,n.z)));return new t(s)},t.CreateCubicBezier=function(i,r,n,o,s){s=s>3?s:4;for(var h=new Array,a=function(t,i,r,n,o){var e=(1-t)*(1-t)*(1-t)*i+3*t*(1-t)*(1-t)*r+3*t*t*(1-t)*n+t*t*t*o;return e},u=0;u<=s;u++)h.push(new e(a(u/s,i.x,r.x,n.x,o.x),a(u/s,i.y,r.y,n.y,o.y),a(u/s,i.z,r.z,n.z,o.z)));return new t(h)},t.CreateHermiteSpline=function(i,r,n,o,s){for(var h=new Array,a=1/s,u=0;u<=s;u++)h.push(e.Hermite(i,r,n,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 r=this._points[this._points.length-1],n=this._points.slice(),o=i.getPoints(),e=1;e=0;a--)(n=e[a])&&(s=(o<3?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-i<=r&&r<=i},e.ToHex=function(e){var t=e.toString(16);return e<=15?("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;rr.x?r.x:n,n=nr.y?r.y:o,o=ot.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=n<0?-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&&s+a<2*n*o},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.Center=function(e,t){var i=e.add(t);return i.scaleInPlace(.5),i},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.xthis.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.Forward=function(){return new i(0,0,1)},i.Right=function(){return new i(1,0,0)},i.Left=function(){return new i((-1),0,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){var r=e.x*t.m[0]+e.y*t.m[4]+e.z*t.m[8],n=e.x*t.m[1]+e.y*t.m[5]+e.z*t.m[9],o=e.x*t.m[2]+e.y*t.m[6]+e.z*t.m[10];i.x=r,i.y=n,i.z=o},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=nr.y?r.y:o,o=or.z?r.z:s,s=sthis.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.copyFromFloats=function(e,t){this.width=e,this.height=t},e.prototype.multiplyByFloats=function(t,i){return new e(this.width*t,this.height*i)},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)},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=this.z,r=this.x,n=this.y,o=this.w,s=o*o,a=i*i,h=r*r,c=n*n,l=n*i-r*o,u=.4999999;return l<-u?(e.y=2*Math.atan2(n,o),e.x=Math.PI/2,e.z=0):l>u?(e.y=2*Math.atan2(n,o),e.x=-Math.PI/2,e.z=0):(e.z=Math.atan2(2*(r*n+i*o),-a-h+c+s),e.x=Math.asin(-2*(i*n-r*o)),e.y=Math.atan2(2*(i*r+n*o),a-h-c+s)),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){return e.RotationAxisToRef(t,i,new e)},e.RotationAxisToRef=function(e,t,i){var r=Math.sin(t/2);return e.normalize(),i.w=Math.cos(t/2),i.x=e.x*r,i.y=e.y*r,i.z=e.z*r,i},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=e.Identity();return e.SlerpToRef(t,i,r,n),n},e.SlerpToRef=function(e,t,i,r){var n,o,s=i,a=e.x*t.x+e.y*t.y+e.z*t.z+e.w*t.w,h=!1;if(a<0&&(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}r.x=o*e.x+n*t.x,r.y=o*e.y+n*t.y,r.z=o*e.z+n*t.z,r.w=o*e.w+n*t.w},e})();e.Quaternion=h;var c=(function(){function i(){this.m=new Float32Array(16)}return i.prototype.isIdentity=function(){return 1===this.m[0]&&1===this.m[5]&&1===this.m[10]&&1===this.m[15]&&(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])},i.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)},i.prototype.toArray=function(){return this.m},i.prototype.asArray=function(){return this.toArray()},i.prototype.invert=function(){return this.invertToRef(this),this},i.prototype.reset=function(){for(var e=0;e<16;e++)this.m[e]=0;return this},i.prototype.add=function(e){var t=new i;return this.addToRef(e,t),t},i.prototype.addToRef=function(e,t){for(var i=0;i<16;i++)t.m[i]=this.m[i]+e.m[i];return this},i.prototype.addToSelf=function(e){for(var t=0;t<16;t++)this.m[t]+=e.m[t];return this},i.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],m=this.m[14],_=this.m[15],g=u*_-f*m,v=l*_-f*p,y=l*m-u*p,x=c*_-f*d,b=c*m-u*d,A=c*p-l*d,T=s*g-a*v+h*y,E=-(o*g-a*x+h*b),P=o*v-s*x+h*A,M=-(o*y-s*b+a*A),S=1/(t*T+i*E+r*P+n*M),C=a*_-h*m,R=s*_-h*p,O=s*m-a*p,I=o*_-h*d,D=o*m-a*d,w=o*p-s*d,L=a*f-h*u,B=s*f-h*l,F=s*u-a*l,V=o*f-h*c,N=o*u-a*c,z=o*l-s*c;return e.m[0]=T*S,e.m[4]=E*S,e.m[8]=P*S,e.m[12]=M*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*A)*S,e.m[13]=(t*y-i*b+r*A)*S,e.m[2]=(i*C-r*R+n*O)*S,e.m[6]=-(t*C-r*I+n*D)*S,e.m[10]=(t*R-i*I+n*w)*S,e.m[14]=-(t*O-i*D+r*w)*S,e.m[3]=-(i*L-r*B+n*F)*S,e.m[7]=(t*L-r*V+n*N)*S,e.m[11]=-(t*B-i*V+n*z)*S,e.m[15]=(t*F-i*N+r*z)*S,this},i.prototype.setTranslation=function(e){return this.m[12]=e.x,this.m[13]=e.y,this.m[14]=e.z,this},i.prototype.getTranslation=function(){return new o(this.m[12],this.m[13],this.m[14])},i.prototype.multiply=function(e){var t=new i;return this.multiplyToRef(e,t),t},i.prototype.copyFrom=function(e){for(var t=0;t<16;t++)this.m[t]=e.m[t];return this},i.prototype.copyToArray=function(e,t){void 0===t&&(t=0);for(var i=0;i<16;i++)e[t+i]=this.m[i];return this},i.prototype.multiplyToRef=function(e,t){return this.multiplyToArray(e,t.m,0),this},i.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],m=this.m[12],_=this.m[13],g=this.m[14],v=this.m[15],y=e.m[0],x=e.m[1],b=e.m[2],A=e.m[3],T=e.m[4],E=e.m[5],P=e.m[6],M=e.m[7],S=e.m[8],C=e.m[9],R=e.m[10],O=e.m[11],I=e.m[12],D=e.m[13],w=e.m[14],L=e.m[15];return t[i]=r*y+n*T+o*S+s*I,t[i+1]=r*x+n*E+o*C+s*D,t[i+2]=r*b+n*P+o*R+s*w,t[i+3]=r*A+n*M+o*O+s*L,t[i+4]=a*y+h*T+c*S+l*I,t[i+5]=a*x+h*E+c*C+l*D,t[i+6]=a*b+h*P+c*R+l*w,t[i+7]=a*A+h*M+c*O+l*L,t[i+8]=u*y+f*T+d*S+p*I,t[i+9]=u*x+f*E+d*C+p*D,t[i+10]=u*b+f*P+d*R+p*w,t[i+11]=u*A+f*M+d*O+p*L,t[i+12]=m*y+_*T+g*S+v*I,t[i+13]=m*x+_*E+g*C+v*D,t[i+14]=m*b+_*P+g*R+v*w,t[i+15]=m*A+_*M+g*O+v*L,this},i.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]},i.prototype.clone=function(){return i.FromValues(this.m[0],this.m[1],this.m[2],this.m[3],this.m[4],this.m[5],this.m[6],this.m[7],this.m[8],this.m[9],this.m[10],this.m[11],this.m[12],this.m[13],this.m[14],this.m[15])},i.prototype.getClassName=function(){return"Matrix"},i.prototype.getHashCode=function(){for(var e=this.m[0]||0,t=1;t<16;t++)e=397*e^(this.m[t]||0);return e},i.prototype.decompose=function(e,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;return e.x=o*Math.sqrt(this.m[0]*this.m[0]+this.m[1]*this.m[1]+this.m[2]*this.m[2]),e.y=s*Math.sqrt(this.m[4]*this.m[4]+this.m[5]*this.m[5]+this.m[6]*this.m[6]),e.z=a*Math.sqrt(this.m[8]*this.m[8]+this.m[9]*this.m[9]+this.m[10]*this.m[10]),0===e.x||0===e.y||0===e.z?(r.x=0,r.y=0,r.z=0,r.w=1,!1):(i.FromValuesToRef(this.m[0]/e.x,this.m[1]/e.x,this.m[2]/e.x,0,this.m[4]/e.y,this.m[5]/e.y,this.m[6]/e.y,0,this.m[8]/e.z,this.m[9]/e.z,this.m[10]/e.z,0,0,0,0,1,M.Matrix[0]),h.FromRotationMatrixToRef(M.Matrix[0],r),!0)},i.prototype.getRotationMatrix=function(){var e=i.Identity();return this.getRotationMatrixToRef(e),e},i.prototype.getRotationMatrixToRef=function(e){var t=this.m,r=t[0]*t[1]*t[2]*t[3]<0?-1:1,n=t[4]*t[5]*t[6]*t[7]<0?-1:1,o=t[8]*t[9]*t[10]*t[11]<0?-1:1,s=r*Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]),a=n*Math.sqrt(t[4]*t[4]+t[5]*t[5]+t[6]*t[6]),h=o*Math.sqrt(t[8]*t[8]+t[9]*t[9]+t[10]*t[10]);i.FromValuesToRef(t[0]/s,t[1]/s,t[2]/s,0,t[4]/a,t[5]/a,t[6]/a,0,t[8]/h,t[9]/h,t[10]/h,0,0,0,0,1,e)},i.FromArray=function(e,t){var r=new i;return t||(t=0),i.FromArrayToRef(e,t,r),r},i.FromArrayToRef=function(e,t,i){for(var r=0;r<16;r++)i.m[r]=e[r+t]},i.FromFloat32ArrayToRefScaled=function(e,t,i,r){for(var n=0;n<16;n++)r.m[n]=e[n+t]*i},i.FromValuesToRef=function(e,t,i,r,n,o,s,a,h,c,l,u,f,d,p,m,_){_.m[0]=e,_.m[1]=t,_.m[2]=i,_.m[3]=r,_.m[4]=n,_.m[5]=o,_.m[6]=s,_.m[7]=a,_.m[8]=h,_.m[9]=c,_.m[10]=l,_.m[11]=u,_.m[12]=f,_.m[13]=d,_.m[14]=p,_.m[15]=m},i.prototype.getRow=function(e){if(e<0||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])},i.prototype.setRow=function(e,t){if(e<0||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},i.FromValues=function(e,t,r,n,o,s,a,h,c,l,u,f,d,p,m,_){var g=new i;return g.m[0]=e,g.m[1]=t,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]=m,g.m[15]=_,g},i.Compose=function(e,t,r){var n=i.FromValues(e.x,0,0,0,0,e.y,0,0,0,0,e.z,0,0,0,0,1),o=i.Identity();return t.toRotationMatrix(o),n=n.multiply(o),n.setTranslation(r),n},i.Identity=function(){return i.FromValues(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1)},i.IdentityToRef=function(e){i.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,e)},i.Zero=function(){return i.FromValues(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)},i.RotationX=function(e){var t=new i;return i.RotationXToRef(e,t),t},i.Invert=function(e){var t=new i;return e.invertToRef(t),t},i.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},i.RotationY=function(e){var t=new i;return i.RotationYToRef(e,t),t},i.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},i.RotationZ=function(e){var t=new i;return i.RotationZToRef(e,t),t},i.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},i.RotationAxis=function(e,t){var r=i.Zero();return i.RotationAxisToRef(e,t,r),r},i.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},i.RotationYawPitchRoll=function(e,t,r){var n=new i;return i.RotationYawPitchRollToRef(e,t,r,n),n},i.RotationYawPitchRollToRef=function(e,t,i,r){h.RotationYawPitchRollToRef(e,t,i,this._tempQuaternion),this._tempQuaternion.toRotationMatrix(r)},i.Scaling=function(e,t,r){var n=i.Zero();return i.ScalingToRef(e,t,r,n),n},i.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},i.Translation=function(e,t,r){var n=i.Identity();return i.TranslationToRef(e,t,r,n),n},i.TranslationToRef=function(e,t,r,n){i.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,e,t,r,1,n)},i.Lerp=function(e,t,r){for(var n=i.Zero(),o=0;o<16;o++)n.m[o]=e.m[o]*(1-r)+t.m[o]*r;return n},i.DecomposeLerp=function(e,t,r){var n=new o(0,0,0),s=new h,a=new o(0,0,0);e.decompose(n,s,a);var c=new o(0,0,0),l=new h,u=new o(0,0,0);t.decompose(c,l,u);var f=o.Lerp(n,c,r),d=h.Slerp(s,l,r),p=o.Lerp(a,u,r);return i.Compose(f,d,p)},i.LookAtLH=function(e,t,r){var n=i.Zero();return i.LookAtLHToRef(e,t,r,n),n},i.LookAtLHToRef=function(e,t,r,n){t.subtractToRef(e,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,e),a=-o.Dot(this._yAxis,e),h=-o.Dot(this._zAxis,e);return i.FromValuesToRef(this._xAxis.x,this._yAxis.x,this._zAxis.x,0,this._xAxis.y,this._yAxis.y,this._zAxis.y,0,this._xAxis.z,this._yAxis.z,this._zAxis.z,0,s,a,h,1,n)},i.LookAtRH=function(e,t,r){var n=i.Zero();return i.LookAtRHToRef(e,t,r,n),n},i.LookAtRHToRef=function(e,t,r,n){e.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,e),a=-o.Dot(this._yAxis,e),h=-o.Dot(this._zAxis,e);return i.FromValuesToRef(this._xAxis.x,this._yAxis.x,this._zAxis.x,0,this._xAxis.y,this._yAxis.y,this._zAxis.y,0,this._xAxis.z,this._yAxis.z,this._zAxis.z,0,s,a,h,1,n)},i.OrthoLH=function(e,t,r,n){var o=i.Zero();return i.OrthoLHToRef(e,t,r,n,o),o},i.OrthoLHToRef=function(t,i,r,n,o){var s=r,a=n,h=2/t,c=2/i,l=2/(a-s),u=-(a+s)/(a-s);e.Matrix.FromValuesToRef(h,0,0,0,0,c,0,0,0,0,l,0,0,0,u,1,o)},i.OrthoOffCenterLH=function(e,t,r,n,o,s){var a=i.Zero();return i.OrthoOffCenterLHToRef(e,t,r,n,o,s,a),a},i.OrthoOffCenterLHToRef=function(t,i,r,n,o,s,a){var h=o,c=s,l=2/(i-t),u=2/(n-r),f=2/(c-h),d=-(c+h)/(c-h),p=(t+i)/(t-i),m=(n+r)/(r-n);e.Matrix.FromValuesToRef(l,0,0,0,0,u,0,0,0,0,f,0,p,m,d,1,a)},i.OrthoOffCenterRH=function(e,t,r,n,o,s){var a=i.Zero();return i.OrthoOffCenterRHToRef(e,t,r,n,o,s,a),a},i.OrthoOffCenterRHToRef=function(e,t,r,n,o,s,a){i.OrthoOffCenterLHToRef(e,t,r,n,o,s,a),a.m[10]*=-1},i.PerspectiveLH=function(t,r,n,o){var s=i.Zero(),a=n,h=o,c=2*a/t,l=2*a/r,u=(h+a)/(h-a),f=-2*h*a/(h-a);return e.Matrix.FromValuesToRef(c,0,0,0,0,l,0,0,0,0,u,1,0,0,f,0,s),s},i.PerspectiveFovLH=function(e,t,r,n){var o=i.Zero();return i.PerspectiveFovLHToRef(e,t,r,n,o),o},i.PerspectiveFovLHToRef=function(t,i,r,n,o,s){void 0===s&&(s=!0);var a=r,h=n,c=1/Math.tan(.5*t),l=s?c/i:c,u=s?c:c*i,f=(h+a)/(h-a),d=-2*h*a/(h-a);e.Matrix.FromValuesToRef(l,0,0,0,0,u,0,0,0,0,f,1,0,0,d,0,o)},i.PerspectiveFovRH=function(e,t,r,n){var o=i.Zero();return i.PerspectiveFovRHToRef(e,t,r,n,o),o},i.PerspectiveFovRHToRef=function(t,i,r,n,o,s){void 0===s&&(s=!0);var a=r,h=n,c=1/Math.tan(.5*t),l=s?c/i:c,u=s?c:c*i,f=-(h+a)/(h-a),d=-2*h*a/(h-a);e.Matrix.FromValuesToRef(l,0,0,0,0,u,0,0,0,0,f,-1,0,0,d,0,o)},i.PerspectiveFovWebVRToRef=function(e,t,i,r,n){void 0===n&&(n=!0);var o=Math.tan(e.upDegrees*Math.PI/180),s=Math.tan(e.downDegrees*Math.PI/180),a=Math.tan(e.leftDegrees*Math.PI/180),h=Math.tan(e.rightDegrees*Math.PI/180),c=2/(a+h),l=2/(o+s);r.m[0]=c,r.m[1]=r.m[2]=r.m[3]=r.m[4]=0,r.m[5]=l,r.m[6]=r.m[7]=0,r.m[8]=(a-h)*c*.5,r.m[9]=-((o-s)*l*.5),r.m[10]=-(t+i)/(i-t),r.m[11]=1,r.m[12]=r.m[13]=r.m[15]=0,r.m[14]=-(2*i*t)/(i-t)},i.GetFinalMatrix=function(e,t,r,n,o,s){var a=e.width,h=e.height,c=e.x,l=e.y,u=i.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 t.multiply(r).multiply(n).multiply(u)},i.GetAsMatrix2x2=function(e){return new Float32Array([e.m[0],e.m[1],e.m[4],e.m[5]])},i.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]])},i.Transpose=function(e){var t=new i;return t.m[0]=e.m[0],t.m[1]=e.m[4],t.m[2]=e.m[8],t.m[3]=e.m[12],t.m[4]=e.m[1],t.m[5]=e.m[5],t.m[6]=e.m[9],t.m[7]=e.m[13],t.m[8]=e.m[2],t.m[9]=e.m[6],t.m[10]=e.m[10],t.m[11]=e.m[14],t.m[12]=e.m[3],t.m[13]=e.m[7],t.m[14]=e.m[11],t.m[15]=e.m[15],t},i.Reflection=function(e){var t=new i;return i.ReflectionToRef(e,t),t},i.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},i.FromXYZAxesToRef=function(e,t,i,r){r.m[0]=e.x,r.m[1]=e.y,r.m[2]=e.z,r.m[3]=0,r.m[4]=t.x,r.m[5]=t.y,r.m[6]=t.z,r.m[7]=0,r.m[8]=i.x,r.m[9]=i.y,r.m[10]=i.z,r.m[11]=0,r.m[12]=0,r.m[13]=0,r.m[14]=0,r.m[15]=1},i.FromQuaternionToRef=function(e,t){var i=e.x*e.x,r=e.y*e.y,n=e.z*e.z,o=e.x*e.y,s=e.z*e.w,a=e.z*e.x,h=e.y*e.w,c=e.y*e.z,l=e.x*e.w;t.m[0]=1-2*(r+n),t.m[1]=2*(o+s),t.m[2]=2*(a-h),t.m[3]=0,t.m[4]=2*(o-s),t.m[5]=1-2*(n+i),t.m[6]=2*(c+l),t.m[7]=0,t.m[8]=2*(a+h),t.m[9]=2*(c-l),t.m[10]=1-2*(r+i),t.m[11]=0,t.m[12]=0,t.m[13]=0,t.m[14]=0,t.m[15]=1},i})();c._tempQuaternion=new h,c._xAxis=o.Zero(),c._yAxis=o.Zero(),c._zAxis=o.Zero(),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 i<=t},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;r<6;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;var d;!(function(e){e[e.LOCAL=0]="LOCAL",e[e.WORLD=1]="WORLD"})(d=e.Space||(e.Space={}));var p=(function(){function e(){}return e})();p.X=new o(1,0,0),p.Y=new o(0,1,0),p.Z=new o(0,0,1),e.Axis=p;var m=(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;c<5;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=m;var _;!(function(e){e[e.CW=0]="CW",e[e.CCW=1]="CCW"})(_=e.Orientation||(e.Orientation={}));var g=(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=g;var v=(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=g.BetweenTwoPoints(this.centerPoint,this.startPoint);var h=this.startAngle.degrees(),c=g.BetweenTwoPoints(this.centerPoint,this.midPoint).degrees(),l=g.BetweenTwoPoints(this.centerPoint,this.endPoint).degrees();c-h>180&&(c-=360),c-h<-180&&(c+=360),l-c>180&&(l-=360),l-c<-180&&(l+=360),this.orientation=c-h<0?_.CW:_.CCW,this.angle=g.FromDegrees(this.orientation===_.CW?h-l:l-h)}return e})();e.Arc2=v;var y=(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 v(s,a,h),l=c.angle.radians()/o;c.orientation===_.CW&&(l*=-1);for(var u=c.startAngle.radians()+l,f=0;f1)return n.Zero();for(var t=e*this.length(),i=0,r=0;r=i&&t<=c){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=y;var x=(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;rt+1;)t++,i=this._curve[e].subtract(this._curve[e-t]);return i},i.prototype._normalVector=function(i,r,n){var s,a=r.length();if(0===a&&(a=1),void 0===n||null===n){var h;t.WithinEpsilon(Math.abs(r.y)/a,1,e.Epsilon)?t.WithinEpsilon(Math.abs(r.x)/a,1,e.Epsilon)?t.WithinEpsilon(Math.abs(r.z)/a,1,e.Epsilon)||(h=new o(0,0,1)):h=new o(1,0,0):h=new o(0,(-1),0),s=o.Cross(r,h)}else s=o.Cross(r,n),o.CrossToRef(s,r,s);return s.normalize(),s},i})();e.Path3D=x;var b=(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;h<=n;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;c<=s;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;c<=s;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;o0},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&&(n.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){e!==-1?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=t.indexOf(".babylon")!==-1?"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=t.indexOf(".babylon")!==-1?"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&&(o.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})();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 e.indexOf("http:/")===-1?t.parseURL(window.location.href)+e:e},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++],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);n>t._ORIGIN_SHIFT){default:case t._ORIGIN_UL:y=0,b=1,E=o.width,x=0,A=1,T=o.height;break;case t._ORIGIN_BL:y=0,b=1,E=o.width,x=o.height-1,A=-1,T=-1;break;case t._ORIGIN_UR:y=o.width-1,b=-1,E=-1,x=0,A=1,T=o.height;break;case t._ORIGIN_BR:y=o.width-1,b=-1,E=-1,x=o.height-1,A=-1,T=-1}var P="_getImageData"+(c?"Grey":"")+o.pixel_size+"bits",M=t[P](o,u,l,x,A,T,y,b,E);i.texImage2D(i.TEXTURE_2D,0,i.RGBA,o.width,o.height,0,i.RGBA,i.UNSIGNED_BYTE,M)},t._getImageData8bits=function(e,t,i,r,n,o,s,a,h){var c,l,u,f=i,d=t,p=e.width,m=e.height,_=0,g=new Uint8Array(p*m*4);for(u=r;u!==o;u+=n)for(l=s;l!==h;l+=a,_++)c=f[_],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,m=0,_=new Uint8Array(d*p*4);for(u=r;u!==o;u+=n)for(l=s;l!==h;l+=a,m+=2)c=f[m+0]+(f[m+1]<<8),_[4*(l+d*u)+0]=(31744&c)>>7,_[4*(l+d*u)+1]=(992&c)>>2,_[4*(l+d*u)+2]=(31&c)>>3,_[4*(l+d*u)+3]=32768&c?0:255;return _},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,m=new Uint8Array(f*d*4);for(l=r;l!==o;l+=n)for(c=s;c!==h;c+=a,p+=3)m[4*(c+f*l)+3]=255,m[4*(c+f*l)+2]=u[p+0],m[4*(c+f*l)+1]=u[p+1],m[4*(c+f*l)+0]=u[p+2];return m},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,m=new Uint8Array(f*d*4);for(l=r;l!==o;l+=n)for(c=s;c!==h;c+=a,p+=4)m[4*(c+f*l)+2]=u[p+0],m[4*(c+f*l)+1]=u[p+1],m[4*(c+f*l)+0]=u[p+2],m[4*(c+f*l)+3]=u[p+3];return m},t._getImageDataGrey8bits=function(e,t,i,r,n,o,s,a,h){var c,l,u,f=i,d=e.width,p=e.height,m=0,_=new Uint8Array(d*p*4);for(u=r;u!==o;u+=n)for(l=s;l!==h;l+=a,m++)c=f[m],_[4*(l+d*u)+0]=c,_[4*(l+d*u)+1]=c,_[4*(l+d*u)+2]=c,_[4*(l+d*u)+3]=255;return _},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,m=new Uint8Array(f*d*4);for(l=r;l!==o;l+=n)for(c=s;c!==h;c+=a,p+=2)m[4*(c+f*l)+0]=u[p+0],m[4*(c+f*l)+1]=u[p+0],m[4*(c+f*l)+2]=u[p+0],m[4*(c+f*l)+3]=u[p+1];return m},t})();i._TYPE_NO_DATA=0,i._TYPE_INDEXED=1,i._TYPE_RGB=2,i._TYPE_GREY=3,i._TYPE_RLE_INDEXED=9,i._TYPE_RLE_RGB=10,i._TYPE_RLE_GREY=11,i._ORIGIN_MASK=48,i._ORIGIN_SHIFT=4,i._ORIGIN_BL=0,i._ORIGIN_BR=1,i._ORIGIN_UL=2,i._ORIGIN_UR=3,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)&&(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;tthis.data.length&&(this.data.length=2*(this.length+e.length));for(var t=0;t=this.length?-1:t},e})();t._GlobalId=0,e.SmartArray=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(){this._count=0,this._data={}}return e.prototype.copyFrom=function(e){var t=this;this.clear(),e.forEach((function(e,i){return t.add(e,i)}))},e.prototype.get=function(e){var t=this._data[e];if(void 0!==t)return t},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]&&(this._data[e]=t,++this._count,!0)},e.prototype.set=function(e,t){return void 0!==this._data[e]&&(this._data[e]=t,!0)},e.prototype.getAndRemove=function(e){var t=this.get(e);return void 0!==t?(delete this._data[e],--this._count,t):null},e.prototype.remove=function(e){return!!this.contains(e)&&(delete this._data[e],--this._count,!0)},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,t){return function(i){i.__bjsclassName__=e,i.__bjsmoduleName__=null!=t?t:null}}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;rt&&(i=t),i},t.GetFilename=function(e){var t=e.lastIndexOf("/");return t<0?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>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;h=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){if(t===!0||void 0!==e&&null!=e)return Array.isArray(e)?e:[e]},t.GetPointerPrefix=function(){var e="pointer";return window.PointerEvent||navigator.pointerEnabled||(e="mouse"),e},t.QueueNewFrame=function(e,t){void 0===t&&(t=window),t.requestAnimationFrame?t.requestAnimationFrame(e):t.msRequestAnimationFrame?t.msRequestAnimationFrame(e):t.webkitRequestAnimationFrame?t.webkitRequestAnimationFrame(e):t.mozRequestAnimationFrame?t.mozRequestAnimationFrame(e):t.oRequestAnimationFrame?t.oRequestAnimationFrame(e):window.setTimeout(e,16)},t.RequestFullscreen=function(e){var t=e.requestFullscreen||e.msRequestFullscreen||e.webkitRequestFullscreen||e.mozRequestFullScreen;t&&t.call(e)},t.ExitFullscreen=function(){document.exitFullscreen?document.exitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitCancelFullScreen?document.webkitCancelFullScreen():document.msCancelFullScreen&&document.msCancelFullScreen()},t.SetCorsBehavior=function(e,i){if(t.CorsBehavior)switch(typeof t.CorsBehavior){case"function":var r=t.CorsBehavior(e);if(r)return r;break;case"string":default:i.crossOrigin=t.CorsBehavior}},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;"data:"!==i.substr(0,5)&&t.SetCorsBehavior(i,s),s.onload=function(){r(s)},s.onerror=function(e){t.Error("Error while trying to load image: "+i),t.UseFallbackTexture?(s.src=t.fallbackTexture,r(s)):n()};var a=function(){s.src=i},h=function(){o.loadImageFromDB(i,s)};if("data:"!==i.substr(0,5)&&o&&o.enableTexturesOffline&&e.Database.IsUASupportingBlobStorage)o.openAsync(h,a);else if(i.indexOf("file:")===-1)a();else{var c=i.substring(5).toLowerCase();if(e.FilesInput.FilesTextures[c])try{var l;try{l=URL.createObjectURL(e.FilesInput.FilesTextures[c],{oneTimeOnly:!0})}catch(u){l=URL.createObjectURL(e.FilesInput.FilesTextures[c])}s.src=l}catch(f){s.src=null}else t.Error("Image: "+c+" not found. Did you forget to provide it?"),s.src=t.fallbackTexture}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(e.onreadystatechange=null,e.status>=200&&e.status<300||navigator.isCocoonJS&&0===e.status)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(i.indexOf("file:")!==-1){var l=i.substring(5).toLowerCase();e.FilesInput.FilesToLoad[l]?t.ReadFile(e.FilesInput.FilesToLoad[l],r,n,s):t.Error("File: "+l+" not found. Did you forget to provide it?")}else o&&o.enableSceneOffline?o.openAsync(c,h):h()},t.LoadScript=function(e,t,i){var r=document.getElementsByTagName("head")[0],n=document.createElement("script");n.type="text/javascript",n.src=e;n.onload=function(){t&&t()},n.onerror=function(){i&&i()},r.appendChild(n)},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.xi.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&&n.indexOf(o)!==-1)&&(!i||i.indexOf(o)===-1)){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;hh&&(f=h,u=f*l);var d=Math.max(0,a-u)/2,p=Math.max(0,h-f)/2;c.fillStyle=r.getScene().clearColor.toHexString(),c.fillRect(0,0,a,h),c.drawImage(e.getRenderingCanvas(),d,p,u,f),t.EncodeScreenshotCanvasData(o,s)},t.CreateScreenshotUsingRenderTarget=function(i,r,n,o,s){void 0===s&&(s="image/png");var a,h;if(n.precision)a=Math.round(i.getRenderWidth()*n.precision),h=Math.round(a/i.getAspectRatio(r)),n={width:a,height:h};else if(n.width&&n.height)a=n.width,h=n.height;else if(n.width&&!n.height)a=n.width,h=Math.round(a/i.getAspectRatio(r)),n={width:a,height:h};else if(n.height&&!n.width)h=n.height,a=Math.round(h*i.getAspectRatio(r)),n={width:a,height:h};else{if(isNaN(n))return void t.Error("Invalid 'size' parameter !");h=n,a=n}var c=r.getScene(),l=null;c.activeCamera!==r&&(l=c.activeCamera,c.activeCamera=r);var u=new e.RenderTargetTexture("screenShot",n,c,(!1),(!1),e.Engine.TEXTURETYPE_UNSIGNED_INT,(!1),e.Texture.NEAREST_SAMPLINGMODE);u.renderList=c.meshes,u.onAfterRenderObservable.add((function(){t.DumpFramebuffer(a,h,i,o,s)})),c.incrementRenderId(),c.resetCachedMaterial(),u.render(!0),u.dispose(),l&&(c.activeCamera=l),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},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)}))},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 e<10?"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="
"+i+"

";t._AddLogEntry(r)},t._WarnDisabled=function(e){},t._WarnEnabled=function(e){var i=t._FormatMessage(e);console.warn("BJS - "+i);var r="
"+i+"

";t._AddLogEntry(r)},t._ErrorDisabled=function(e){},t._ErrorEnabled=function(e){t.errorsCount++;var i=t._FormatMessage(e);console.error("BJS - "+i);var r="
"+i+"

";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,r=e;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})();n.BaseUrl="",n.CorsBehavior="anonymous",n.UseFallbackTexture=!0,n.fallbackTexture="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",n._NoneLogLevel=0,n._MessageLogLevel=1,n._WarningLogLevel=2,n._ErrorLogLevel=4,n._LogCache="",n.errorsCount=0,n.Log=n._LogEnabled,n.Warn=n._WarnEnabled,n.Error=n._ErrorEnabled,n._PerformanceNoneLogLevel=0,n._PerformanceUserMarkLogLevel=1,n._PerformanceConsoleLogLevel=2,n._performance=window.performance,n.StartPerformanceCounter=n._StartPerformanceCounterDisabled,n.EndPerformanceCounter=n._EndPerformanceCounterDisabled,e.Tools=n;var o=(function(){function e(){this._startMonitoringTime=0,this._min=0,this._max=0,this._average=0,this._lastSecAverage=0,this._current=0,this._totalValueCount=0,this._totalAccumulated=0,this._lastSecAccumulated=0,this._lastSecTime=0,this._lastSecValueCount=0}return Object.defineProperty(e.prototype,"min",{get:function(){return this._min},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"max",{get:function(){return this._max},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"average",{get:function(){return this._average},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"lastSecAverage",{get:function(){return this._lastSecAverage},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"current",{get:function(){return this._current},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"total",{get:function(){return this._totalAccumulated},enumerable:!0,configurable:!0}),e.prototype.fetchNewFrame=function(){this._totalValueCount++,this._current=0,this._lastSecValueCount++},e.prototype.addCount=function(e,t){this._current+=e,t&&this._fetchResult()},e.prototype.beginMonitoring=function(){this._startMonitoringTime=n.Now},e.prototype.endMonitoring=function(e){void 0===e&&(e=!0),e&&this.fetchNewFrame();var t=n.Now;this._current=t-this._startMonitoringTime,e&&this._fetchResult()},e.prototype._fetchResult=function(){this._totalAccumulated+=this._current,this._lastSecAccumulated+=this._current,this._min=Math.min(this._min,this._current),this._max=Math.max(this._max,this._current),this._average=this._totalAccumulated/this._totalValueCount;var e=n.Now;e-this._lastSecTime>1e3&&(this._lastSecAverage=this._lastSecAccumulated/this._lastSecValueCount,this._lastSecTime=e,this._lastSecAccumulated=0,this._lastSecValueCount=0)},e})();e.PerfCounter=o,e.className=t;var s=(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=t)break;if(r(s),o&&o()){ +e.breakLoop();break}}e.executeNext()}),s)}),n)},e})();e.AsyncLoop=s})(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),this.reset()}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,this.reset()}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(t){var i=(function(){function t(){this._isStencilTestDirty=!1,this._isStencilMaskDirty=!1,this._isStencilFuncDirty=!1,this._isStencilOpDirty=!1,this.reset()}return Object.defineProperty(t.prototype,"isDirty",{get:function(){return this._isStencilTestDirty||this._isStencilMaskDirty||this._isStencilFuncDirty||this._isStencilOpDirty},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stencilFunc",{get:function(){return this._stencilFunc},set:function(e){this._stencilFunc!==e&&(this._stencilFunc=e,this._isStencilFuncDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stencilFuncRef",{get:function(){return this._stencilFuncRef},set:function(e){this._stencilFuncRef!==e&&(this._stencilFuncRef=e,this._isStencilFuncDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stencilFuncMask",{get:function(){return this._stencilFuncMask},set:function(e){this._stencilFuncMask!==e&&(this._stencilFuncMask=e,this._isStencilFuncDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stencilOpStencilFail",{get:function(){return this._stencilOpStencilFail},set:function(e){this._stencilOpStencilFail!==e&&(this._stencilOpStencilFail=e,this._isStencilOpDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stencilOpDepthFail",{get:function(){return this._stencilOpDepthFail},set:function(e){this._stencilOpDepthFail!==e&&(this._stencilOpDepthFail=e,this._isStencilOpDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stencilOpStencilDepthPass",{get:function(){return this._stencilOpStencilDepthPass},set:function(e){this._stencilOpStencilDepthPass!==e&&(this._stencilOpStencilDepthPass=e,this._isStencilOpDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stencilMask",{get:function(){return this._stencilMask},set:function(e){this._stencilMask!==e&&(this._stencilMask=e,this._isStencilMaskDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stencilTest",{get:function(){return this._stencilTest},set:function(e){this._stencilTest!==e&&(this._stencilTest=e,this._isStencilTestDirty=!0)},enumerable:!0,configurable:!0}),t.prototype.reset=function(){this._stencilTest=!1,this._stencilMask=255,this._stencilFunc=e.Engine.ALWAYS,this._stencilFuncRef=1,this._stencilFuncMask=255,this._stencilOpStencilFail=e.Engine.KEEP,this._stencilOpDepthFail=e.Engine.KEEP,this._stencilOpStencilDepthPass=e.Engine.REPLACE,this._isStencilTestDirty=!0,this._isStencilMaskDirty=!0,this._isStencilFuncDirty=!0,this._isStencilOpDirty=!0},t.prototype.apply=function(e){this.isDirty&&(this._isStencilTestDirty&&(this.stencilTest?e.enable(e.STENCIL_TEST):e.disable(e.STENCIL_TEST),this._isStencilTestDirty=!1),this._isStencilMaskDirty&&(e.stencilMask(this.stencilMask),this._isStencilMaskDirty=!1),this._isStencilFuncDirty&&(e.stencilFunc(this.stencilFunc,this.stencilFuncRef,this.stencilFuncMask),this._isStencilFuncDirty=!1),this._isStencilOpDirty&&(e.stencilOp(this.stencilOpStencilFail,this.stencilOpDepthFail,this.stencilOpStencilDepthPass),this._isStencilOpDirty=!1))},t})();t._StencilState=i})(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=36193,r=function(e,t){return t===l.TEXTURETYPE_FLOAT?e.FLOAT:t===l.TEXTURETYPE_HALF_FLOAT?i:e.UNSIGNED_BYTE},n=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}},o=function(t,i,r,o,s,a,h,c,l,u){void 0===u&&(u=e.Texture.TRILINEAR_SAMPLINGMODE);var f=r.getEngine(),d=e.Tools.GetExponentOfTwo(o,f.getCaps().maxTextureSize),p=e.Tools.GetExponentOfTwo(s,f.getCaps().maxTextureSize);f._bindTextureDirectly(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=d,t._height=p,t.isReady=!0,l(d,p);var m=n(u,!h,i);i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,m.mag),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,m.min),h||c||i.generateMipmap(i.TEXTURE_2D),f._bindTextureDirectly(i.TEXTURE_2D,null),f.resetTextureCache(),r._removePendingData(t),t.onLoadedCallbacks.forEach((function(e){e()})),t.onLoadedCallbacks=[]},s=function(t,i,r,n,o,s){void 0===s&&(s=null);var a,h=function(){r[i]=a,r._internalCount++,n._removePendingData(a),6===r._internalCount&&o(r)},c=function(){n._removePendingData(a),s&&s()};a=e.Tools.LoadImage(t,h,c,n.database),n._addPendingData(a)},a=function(e,t,i,r,n){void 0===n&&(n=null);var o=[];o._internalCount=0;for(var a=0;a<6;a++)s(r[a],a,o,t,i,n)},h=(function(){function e(){}return e})();e.InstancingAttributeInfo=h;var c=(function(){function e(){}return e})();e.EngineCapabilities=c;var l=(function(){function s(t,i,r,n){void 0===n&&(n=!1);var o=this;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._badOS=!1,this._drawCalls=new e.PerfCounter,this._renderingQueueLaunched=!1,this._activeRenderLoops=[],this.fpsRange=60,this.previousFramesDuration=[],this.fps=60,this.deltaTime=0,this._depthCullingState=new e.Internals._DepthCullingState,this._stencilState=new e.Internals._StencilState,this._alphaState=new e.Internals._AlphaState,this._alphaMode=s.ALPHA_DISABLE,this._loadedTexturesCache=new Array,this._maxTextureChannels=16,this._activeTexturesCache=new Array(this._maxTextureChannels),this._compiledEffects={},this._vertexAttribArraysEnabled=[],this._uintIndicesCurrentlySet=!1,this._currentBoundBuffer=new Array,this._currentBufferPointers=[],this._currentInstanceLocations=new Array,this._currentInstanceBuffers=new Array,this._texturesSupported=new Array,this._onVRFullScreenTriggered=function(){if(o._vrDisplayEnabled&&o._vrDisplayEnabled.isPresenting){o._oldSize=new e.Size(o.getRenderWidth(),o.getRenderHeight()),o._oldHardwareScaleFactor=o.getHardwareScalingLevel();var t=o._vrDisplayEnabled.getEyeParameters("left");o.setHardwareScalingLevel(1),o.setSize(2*t.renderWidth,t.renderHeight)}else o.setHardwareScalingLevel(o._oldHardwareScaleFactor),o.setSize(o._oldSize.width,o._oldSize.height),o._vrDisplayEnabled=void 0},this._renderingCanvas=t,this._externalData=new e.StringDictionary,r=r||{},null!=i&&(r.antialias=i),void 0===r.preserveDrawingBuffer&&(r.preserveDrawingBuffer=!1);var a=this._canRenderToFloatTexture(),h=this._canRenderToHalfFloatTexture();try{this._gl=t.getContext("webgl2",r)||t.getContext("experimental-webgl2",r),this._gl&&(this._webGLVersion="2.0")}catch(l){}if(!this._gl){if(!t)throw new Error("The provided canvas is null or undefined.");try{this._gl=t.getContext("webgl",r)||t.getContext("experimental-webgl",r)}catch(l){throw new Error("WebGL not supported")}}if(!this._gl)throw new Error("WebGL not supported");this._onBlur=function(){o._windowIsBackground=!0},this._onFocus=function(){o._windowIsBackground=!1},window.addEventListener("blur",this._onBlur),window.addEventListener("focus",this._onFocus);var u=r.limitDeviceRatio||window.devicePixelRatio||1;this._hardwareScalingLevel=n?1/Math.min(u,window.devicePixelRatio||1):1,this.resize(),this._isStencilEnable=r.stencil,this._caps=new c,this._caps.maxTexturesImageUnits=this._gl.getParameter(this._gl.MAX_TEXTURE_IMAGE_UNITS),this._caps.maxTextureSize=this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE),this._caps.maxCubemapTextureSize=this._gl.getParameter(this._gl.MAX_CUBE_MAP_TEXTURE_SIZE),this._caps.maxRenderTextureSize=this._gl.getParameter(this._gl.MAX_RENDERBUFFER_SIZE),this._caps.maxVertexAttribs=this._gl.getParameter(this._gl.MAX_VERTEX_ATTRIBS),this._caps.maxVaryingVectors=this._gl.getParameter(this._gl.MAX_VARYING_VECTORS),this._caps.maxFragmentUniformVectors=this._gl.getParameter(this._gl.MAX_FRAGMENT_UNIFORM_VECTORS),this._caps.maxVertexUniformVectors=this._gl.getParameter(this._gl.MAX_VERTEX_UNIFORM_VECTORS),this._glVersion=this._gl.getParameter(this._gl.VERSION);var f=this._gl.getExtension("WEBGL_debug_renderer_info");if(null!=f&&(this._glRenderer=this._gl.getParameter(f.UNMASKED_RENDERER_WEBGL),this._glVendor=this._gl.getParameter(f.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.astc=this._gl.getExtension("WEBGL_compressed_texture_astc"),this._caps.s3tc=this._gl.getExtension("WEBGL_compressed_texture_s3tc"),this._caps.pvrtc=this._gl.getExtension("WEBGL_compressed_texture_pvrtc")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),this._caps.etc1=this._gl.getExtension("WEBGL_compressed_texture_etc1"),this._caps.etc2=this._gl.getExtension("WEBGL_compressed_texture_etc")||this._gl.getExtension("WEBGL_compressed_texture_es3_0"),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._caps.textureFloatRender=a,this._caps.textureHalfFloat=null!==this._gl.getExtension("OES_texture_half_float"),this._caps.textureHalfFloatLinearFiltering=this._gl.getExtension("OES_texture_half_float_linear"),this._caps.textureHalfFloatRender=h,this._caps.astc&&this.texturesSupported.push(".astc"),this._caps.s3tc&&this.texturesSupported.push(".dds"),this._caps.pvrtc&&this.texturesSupported.push(".pvr"),this._caps.etc2&&this.texturesSupported.push(".etc2"),this._caps.etc1&&this.texturesSupported.push(".etc1"),this._gl.getShaderPrecisionFormat){var d=this._gl.getShaderPrecisionFormat(this._gl.FRAGMENT_SHADER,this._gl.HIGH_FLOAT);this._caps.highPrecisionShaderSupported=0!==d.precision}this.setDepthBuffer(!0),this.setDepthFunctionToLessOrEqual(),this.setDepthWrite(!0),this._onFullscreenChange=function(){void 0!==document.fullscreen?o.isFullscreen=document.fullscreen:void 0!==document.mozFullScreen?o.isFullscreen=document.mozFullScreen:void 0!==document.webkitIsFullScreen?o.isFullscreen=document.webkitIsFullScreen:void 0!==document.msIsFullScreen&&(o.isFullscreen=document.msIsFullScreen),o.isFullscreen&&o._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(){o.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&&!s.audioEngine&&(s.audioEngine=new e.AudioEngine),this._loadingScreen=new e.DefaultLoadingScreen(this._renderingCanvas),r.autoEnableWebVR&&this.initWebVR();var p=/AppleWebKit.*10.[\d] Mobile/;this._badOS=p.test(navigator.userAgent),e.Tools.Log("Babylon.js engine (v"+s.Version+") launched")}return Object.defineProperty(s,"NEVER",{get:function(){return s._NEVER},enumerable:!0,configurable:!0}),Object.defineProperty(s,"ALWAYS",{get:function(){return s._ALWAYS},enumerable:!0,configurable:!0}),Object.defineProperty(s,"LESS",{get:function(){return s._LESS},enumerable:!0,configurable:!0}),Object.defineProperty(s,"EQUAL",{get:function(){return s._EQUAL},enumerable:!0,configurable:!0}),Object.defineProperty(s,"LEQUAL",{get:function(){return s._LEQUAL},enumerable:!0,configurable:!0}),Object.defineProperty(s,"GREATER",{get:function(){return s._GREATER},enumerable:!0,configurable:!0}),Object.defineProperty(s,"GEQUAL",{get:function(){return s._GEQUAL},enumerable:!0,configurable:!0}),Object.defineProperty(s,"NOTEQUAL",{get:function(){return s._NOTEQUAL},enumerable:!0,configurable:!0}),Object.defineProperty(s,"KEEP",{get:function(){return s._KEEP},enumerable:!0,configurable:!0}),Object.defineProperty(s,"REPLACE",{get:function(){return s._REPLACE},enumerable:!0,configurable:!0}),Object.defineProperty(s,"INCR",{get:function(){return s._INCR},enumerable:!0,configurable:!0}),Object.defineProperty(s,"DECR",{get:function(){return s._DECR},enumerable:!0,configurable:!0}),Object.defineProperty(s,"INVERT",{get:function(){return s._INVERT},enumerable:!0,configurable:!0}),Object.defineProperty(s,"INCR_WRAP",{get:function(){return s._INCR_WRAP},enumerable:!0,configurable:!0}),Object.defineProperty(s,"DECR_WRAP",{get:function(){return s._DECR_WRAP},enumerable:!0,configurable:!0}),Object.defineProperty(s,"ALPHA_DISABLE",{get:function(){return s._ALPHA_DISABLE},enumerable:!0,configurable:!0}),Object.defineProperty(s,"ALPHA_ONEONE",{get:function(){return s._ALPHA_ONEONE},enumerable:!0,configurable:!0}),Object.defineProperty(s,"ALPHA_ADD",{get:function(){return s._ALPHA_ADD},enumerable:!0,configurable:!0}),Object.defineProperty(s,"ALPHA_COMBINE",{get:function(){return s._ALPHA_COMBINE},enumerable:!0,configurable:!0}),Object.defineProperty(s,"ALPHA_SUBTRACT",{get:function(){return s._ALPHA_SUBTRACT},enumerable:!0,configurable:!0}),Object.defineProperty(s,"ALPHA_MULTIPLY",{get:function(){return s._ALPHA_MULTIPLY},enumerable:!0,configurable:!0}),Object.defineProperty(s,"ALPHA_MAXIMIZED",{get:function(){return s._ALPHA_MAXIMIZED},enumerable:!0,configurable:!0}),Object.defineProperty(s,"ALPHA_PREMULTIPLIED",{get:function(){return s._ALPHA_PREMULTIPLIED},enumerable:!0,configurable:!0}),Object.defineProperty(s,"DELAYLOADSTATE_NONE",{get:function(){return s._DELAYLOADSTATE_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(s,"DELAYLOADSTATE_LOADED",{get:function(){return s._DELAYLOADSTATE_LOADED},enumerable:!0,configurable:!0}),Object.defineProperty(s,"DELAYLOADSTATE_LOADING",{get:function(){return s._DELAYLOADSTATE_LOADING},enumerable:!0,configurable:!0}),Object.defineProperty(s,"DELAYLOADSTATE_NOTLOADED",{get:function(){return s._DELAYLOADSTATE_NOTLOADED},enumerable:!0,configurable:!0}),Object.defineProperty(s,"TEXTUREFORMAT_ALPHA",{get:function(){return s._TEXTUREFORMAT_ALPHA},enumerable:!0,configurable:!0}),Object.defineProperty(s,"TEXTUREFORMAT_LUMINANCE",{get:function(){return s._TEXTUREFORMAT_LUMINANCE},enumerable:!0,configurable:!0}),Object.defineProperty(s,"TEXTUREFORMAT_LUMINANCE_ALPHA",{get:function(){return s._TEXTUREFORMAT_LUMINANCE_ALPHA},enumerable:!0,configurable:!0}),Object.defineProperty(s,"TEXTUREFORMAT_RGB",{get:function(){return s._TEXTUREFORMAT_RGB},enumerable:!0,configurable:!0}),Object.defineProperty(s,"TEXTUREFORMAT_RGBA",{get:function(){return s._TEXTUREFORMAT_RGBA},enumerable:!0,configurable:!0}),Object.defineProperty(s,"TEXTURETYPE_UNSIGNED_INT",{get:function(){return s._TEXTURETYPE_UNSIGNED_INT},enumerable:!0,configurable:!0}),Object.defineProperty(s,"TEXTURETYPE_FLOAT",{get:function(){return s._TEXTURETYPE_FLOAT},enumerable:!0,configurable:!0}),Object.defineProperty(s,"TEXTURETYPE_HALF_FLOAT",{get:function(){return s._TEXTURETYPE_HALF_FLOAT},enumerable:!0,configurable:!0}),Object.defineProperty(s,"Version",{get:function(){return"2.6-alpha"},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"texturesSupported",{get:function(){return this._texturesSupported},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"textureFormatInUse",{get:function(){return this._textureFormatInUse},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"webGLVersion",{get:function(){return this._webGLVersion},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"isStencilEnable",{get:function(){return this._isStencilEnable},enumerable:!0,configurable:!0}),s.prototype._prepareWorkingCanvas=function(){this._workingCanvas||(this._workingCanvas=document.createElement("canvas"),this._workingContext=this._workingCanvas.getContext("2d"))},s.prototype.resetTextureCache=function(){for(var e=0;e=0&&this._activeRenderLoops.splice(t,1)},s.prototype._renderLoop=function(){var t=!0;if(!this.renderEvenInBackground&&this._windowIsBackground&&(t=!1),t){this.beginFrame();for(var i=0;i0?e.Tools.QueueNewFrame(this._bindedRenderFunction,this._vrDisplayEnabled):this._renderingQueueLaunched=!1},s.prototype.runRenderLoop=function(t){this._activeRenderLoops.indexOf(t)===-1&&(this._activeRenderLoops.push(t),this._renderingQueueLaunched||(this._renderingQueueLaunched=!0,this._bindedRenderFunction=this._renderLoop.bind(this),e.Tools.QueueNewFrame(this._bindedRenderFunction)))},s.prototype.switchFullscreen=function(t){this.isFullscreen?e.Tools.ExitFullscreen():(this._pointerLockRequested=t,e.Tools.RequestFullscreen(this._renderingCanvas))},s.prototype.clear=function(e,t,i,r){void 0===r&&(r=!1),this.applyStates();var n=0;t&&e&&(this._gl.clearColor(e.r,e.g,e.b,e.a),n|=this._gl.COLOR_BUFFER_BIT),i&&(this._gl.clearDepth(1),n|=this._gl.DEPTH_BUFFER_BIT),r&&(this._gl.clearStencil(0),n|=this._gl.STENCIL_BUFFER_BIT),this._gl.clear(n)},s.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,!0),o.scissor(a[0],a[1],a[2],a[3]),s===!0?o.enable(o.SCISSOR_TEST):o.disable(o.SCISSOR_TEST)},s.prototype.setViewport=function(e,t,i){var r=t||(navigator.isCocoonJS?window.innerWidth:this.getRenderWidth()),n=i||(navigator.isCocoonJS?window.innerHeight:this.getRenderHeight()),o=e.x||0,s=e.y||0;this._cachedViewport=e,this._gl.viewport(o*r,s*n,r*e.width,n*e.height)},s.prototype.setDirectViewport=function(e,t,i,r){var n=this._cachedViewport;return this._cachedViewport=null,this._gl.viewport(e,t,i,r),n},s.prototype.beginFrame=function(){this._measureFps()},s.prototype.endFrame=function(){this._badOS&&this.flushFramebuffer(),this._vrDisplayEnabled&&this._vrDisplayEnabled.isPresenting&&this._vrDisplayEnabled.submitFrame()},s.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)},s.prototype.setSize=function(e,t){this._renderingCanvas.width=e,this._renderingCanvas.height=t;for(var i=0;i65535){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},s.prototype.bindArrayBuffer=function(e){this.bindBuffer(e,this._gl.ARRAY_BUFFER)},s.prototype.bindIndexBuffer=function(e){this.bindBuffer(e,this._gl.ELEMENT_ARRAY_BUFFER)},s.prototype.bindBuffer=function(e,t){this._currentBoundBuffer[t]!==e&&(this._gl.bindBuffer(t,e),this._currentBoundBuffer[t]=e)},s.prototype.updateArrayBuffer=function(e){this._gl.bufferSubData(this._gl.ARRAY_BUFFER,0,e); +},s.prototype.vertexAttribPointer=function(e,t,i,r,n,o,s){var a=this._currentBufferPointers[t],h=!1;a?(a.buffer!==e&&(a.buffer=e,h=!0),a.size!==i&&(a.size=i,h=!0),a.type!==r&&(a.type=r,h=!0),a.normalized!==n&&(a.normalized=n,h=!0),a.stride!==o&&(a.stride=o,h=!0),a.offset!==s&&(a.offset=s,h=!0)):(h=!0,this._currentBufferPointers[t]={indx:t,size:i,type:r,normalized:n,stride:o,offset:s,buffer:e}),h&&(this.bindArrayBuffer(e),this._gl.vertexAttribPointer(t,i,r,n,o,s))},s.prototype.bindBuffersDirectly=function(e,t,i,r,n){if(this._cachedVertexBuffers!==e||this._cachedEffectForVertexBuffers!==n){this._cachedVertexBuffers=e,this._cachedEffectForVertexBuffers=n;var o=n.getAttributesCount();this.unbindAllAttributes();for(var s=0,a=0;a=0&&(this._gl.enableVertexAttribArray(h),this._vertexAttribArraysEnabled[h]=!0,this.vertexAttribPointer(e,h,i[a],this._gl.FLOAT,!1,r,s)),s+=4*i[a]}}this._cachedIndexBuffer!==t&&(this._cachedIndexBuffer=t,this.bindIndexBuffer(t),this._uintIndicesCurrentlySet=t.is32Bits)},s.prototype.bindBuffers=function(e,t,i){if(this._cachedVertexBuffers!==e||this._cachedEffectForVertexBuffers!==i){this._cachedVertexBuffers=e,this._cachedEffectForVertexBuffers=i;var r=i.getAttributesNames();this.unbindAllAttributes();for(var n=0;n=0){var s=e[r[n]];if(!s)continue;this._gl.enableVertexAttribArray(o),this._vertexAttribArraysEnabled[o]=!0;var a=s.getBuffer();this.vertexAttribPointer(a,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.bindIndexBuffer(t),this._uintIndicesCurrentlySet=t.is32Bits)},s.prototype.unbindInstanceAttributes=function(){for(var e,t=0,i=this._currentInstanceLocations.length;t1)&&!i&&a.width>>a.mipmapCount-1===1;o(f,l._gl,n,a.width,a.height,r,!h,a.isFourCC,(function(){e.Internals.DDSTools.UploadDDSLevels(l._gl,l.getCaps().s3tc,t,a,h,1)}),s)},d instanceof Array?v(c):e.Tools.LoadFile(t,(function(e){v(e)}),null,n.database,!0,y);else{var x=function(t){o(f,l._gl,n,t.width,t.height,r,i,!1,(function(i,r){var n=t.width===i&&t.height===r;n||(l._prepareWorkingCanvas(),l._workingCanvas.width=i,l._workingCanvas.height=r,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)}),s)};d instanceof Array?e.Tools.LoadImage(c,x,y,n.database):e.Tools.LoadImage(t,x,y,n.database)}return f},s.prototype._getInternalFormat=function(e){var t=this._gl.RGBA;switch(e){case s.TEXTUREFORMAT_ALPHA:t=this._gl.ALPHA;break;case s.TEXTUREFORMAT_LUMINANCE:t=this._gl.LUMINANCE;break;case s.TEXTUREFORMAT_LUMINANCE_ALPHA:t=this._gl.LUMINANCE_ALPHA;break;case s.TEXTUREFORMAT_RGB:t=this._gl.RGB;break;case s.TEXTUREFORMAT_RGBA:t=this._gl.RGBA}return t},s.prototype.updateRawTexture=function(e,t,i,r,n){void 0===n&&(n=null);var o=this._getInternalFormat(i);this._bindTextureDirectly(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._bindTextureDirectly(this._gl.TEXTURE_2D,null),this.resetTextureCache(),e.isReady=!0},s.prototype.createRawTexture=function(e,t,i,r,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,r,s,h),this._bindTextureDirectly(this._gl.TEXTURE_2D,c);var l=n(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),o&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(this._gl.TEXTURE_2D,null),c.samplingMode=a,this._loadedTexturesCache.push(c),c},s.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},s.prototype.updateTextureSamplingMode=function(e,t){var i=n(e,t.generateMipMaps,this._gl);t.isCube?(this._bindTextureDirectly(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._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null)):(this._bindTextureDirectly(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._bindTextureDirectly(this._gl.TEXTURE_2D,null))},s.prototype.updateDynamicTexture=function(e,t,i,r){void 0===r&&(r=!1),this._bindTextureDirectly(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._bindTextureDirectly(this._gl.TEXTURE_2D,null),r&&this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),this.resetTextureCache(),e.isReady=!0},s.prototype.updateVideoTexture=function(e,t,i){if(!e._isDisabled){this._bindTextureDirectly(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._bindTextureDirectly(this._gl.TEXTURE_2D,null),this.resetTextureCache(),e.isReady=!0}catch(r){e._isDisabled=!0}}},s.prototype.createRenderTargetTexture=function(t,i){var o=!1,a=!0,h=!1,c=s.TEXTURETYPE_UNSIGNED_INT,l=e.Texture.TRILINEAR_SAMPLINGMODE;void 0!==i&&(o=void 0===i.generateMipMaps?i:i.generateMipMaps,a=void 0===i.generateDepthBuffer||i.generateDepthBuffer,h=a&&i.generateStencilBuffer,c=void 0===i.type?c:i.type,void 0!==i.samplingMode&&(l=i.samplingMode),c!==s.TEXTURETYPE_FLOAT||this._caps.textureFloatLinearFiltering?c!==s.TEXTURETYPE_HALF_FLOAT||this._caps.textureHalfFloatLinearFiltering||(l=e.Texture.NEAREST_SAMPLINGMODE):l=e.Texture.NEAREST_SAMPLINGMODE);var u=this._gl,f=u.createTexture();this._bindTextureDirectly(u.TEXTURE_2D,f);var d=t.width||t,p=t.height||t,m=n(l,o,u);c!==s.TEXTURETYPE_FLOAT||this._caps.textureFloat||(c=s.TEXTURETYPE_UNSIGNED_INT,e.Tools.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type")),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_MAG_FILTER,m.mag),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_MIN_FILTER,m.min),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_WRAP_S,u.CLAMP_TO_EDGE),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_WRAP_T,u.CLAMP_TO_EDGE),u.texImage2D(u.TEXTURE_2D,0,u.RGBA,d,p,0,u.RGBA,r(u,c),null);var _;h?(_=u.createRenderbuffer(),u.bindRenderbuffer(u.RENDERBUFFER,_),u.renderbufferStorage(u.RENDERBUFFER,u.DEPTH_STENCIL,d,p)):a&&(_=u.createRenderbuffer(),u.bindRenderbuffer(u.RENDERBUFFER,_),u.renderbufferStorage(u.RENDERBUFFER,u.DEPTH_COMPONENT16,d,p));var g=u.createFramebuffer();return this.bindUnboundFramebuffer(g),h?u.framebufferRenderbuffer(u.FRAMEBUFFER,u.DEPTH_STENCIL_ATTACHMENT,u.RENDERBUFFER,_):a&&u.framebufferRenderbuffer(u.FRAMEBUFFER,u.DEPTH_ATTACHMENT,u.RENDERBUFFER,_),u.framebufferTexture2D(u.FRAMEBUFFER,u.COLOR_ATTACHMENT0,u.TEXTURE_2D,f,0),o&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(u.TEXTURE_2D,null),u.bindRenderbuffer(u.RENDERBUFFER,null),this.bindUnboundFramebuffer(null),f._framebuffer=g,a&&(f._depthBuffer=_),f._baseWidth=d,f._baseHeight=p,f._width=d,f._height=p,f.isReady=!0,f.generateMipMaps=o,f.references=1,f.samplingMode=l,f.type=c,this.resetTextureCache(),this._loadedTexturesCache.push(f),f},s.prototype.createRenderTargetCubeTexture=function(t,i){var r=this._gl,o=r.createTexture(),s=!0,a=!0,h=!1,c=e.Texture.TRILINEAR_SAMPLINGMODE;void 0!==i&&(s=void 0===i.generateMipMaps?i:i.generateMipMaps,a=void 0===i.generateDepthBuffer||i.generateDepthBuffer,h=a&&i.generateStencilBuffer,void 0!==i.samplingMode&&(c=i.samplingMode)),o.isCube=!0,o.references=1,o.generateMipMaps=s,o.references=1,o.samplingMode=c;var l=n(c,s,r);this._bindTextureDirectly(r.TEXTURE_CUBE_MAP,o);for(var u=0;u<6;u++)r.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+u,0,r.RGBA,t,t,0,r.RGBA,r.UNSIGNED_BYTE,null);r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_MAG_FILTER,l.mag),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_MIN_FILTER,l.min),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE);var f;h?(f=r.createRenderbuffer(),r.bindRenderbuffer(r.RENDERBUFFER,f),r.renderbufferStorage(r.RENDERBUFFER,r.DEPTH_STENCIL,t,t)):a&&(f=r.createRenderbuffer(),r.bindRenderbuffer(r.RENDERBUFFER,f),r.renderbufferStorage(r.RENDERBUFFER,r.DEPTH_COMPONENT16,t,t));var d=r.createFramebuffer();return this.bindUnboundFramebuffer(d),h?r.framebufferRenderbuffer(r.FRAMEBUFFER,r.DEPTH_STENCIL_ATTACHMENT,r.RENDERBUFFER,f):a&&r.framebufferRenderbuffer(r.FRAMEBUFFER,r.DEPTH_ATTACHMENT,r.RENDERBUFFER,f),o.generateMipMaps&&(this._bindTextureDirectly(r.TEXTURE_CUBE_MAP,o),r.generateMipmap(r.TEXTURE_CUBE_MAP)),this._bindTextureDirectly(r.TEXTURE_CUBE_MAP,null),r.bindRenderbuffer(r.RENDERBUFFER,null),this.bindUnboundFramebuffer(null),o._framebuffer=d,a&&(o._depthBuffer=f),o._width=t,o._height=t,o.isReady=!0,this.resetTextureCache(),this._loadedTexturesCache.push(o),o},s.prototype.createCubeTexture=function(t,i,r,n,o,s){var h=this;void 0===o&&(o=null),void 0===s&&(s=null);var c=this._gl,l=c.createTexture();l.isCube=!0,l.url=t,l.references=1,l.onLoadedCallbacks=[];var u=t.substr(t.length-4,4).toLowerCase(),f=this.getCaps().s3tc&&".dds"===u;return f?e.Tools.LoadFile(t,(function(t){var i=e.Internals.DDSTools.GetDDSInfo(t),r=(i.isRGB||i.isLuminance||i.mipmapCount>1)&&!n;h._bindTextureDirectly(c.TEXTURE_CUBE_MAP,l),c.pixelStorei(c.UNPACK_FLIP_Y_WEBGL,1),e.Internals.DDSTools.UploadDDSLevels(h._gl,h.getCaps().s3tc,t,i,r,6),n||i.isFourCC||1!==i.mipmapCount||c.generateMipmap(c.TEXTURE_CUBE_MAP),c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MAG_FILTER,c.LINEAR),c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MIN_FILTER,r?c.LINEAR_MIPMAP_LINEAR:c.LINEAR),c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE),c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE),h._bindTextureDirectly(c.TEXTURE_CUBE_MAP,null),h.resetTextureCache(),l._width=i.width,l._height=i.height,l.isReady=!0}),null,null,!0,s):a(t,i,(function(t){var i=e.Tools.GetExponentOfTwo(t[0].width,h._caps.maxCubemapTextureSize),r=i;h._prepareWorkingCanvas(),h._workingCanvas.width=i,h._workingCanvas.height=r;var s=[c.TEXTURE_CUBE_MAP_POSITIVE_X,c.TEXTURE_CUBE_MAP_POSITIVE_Y,c.TEXTURE_CUBE_MAP_POSITIVE_Z,c.TEXTURE_CUBE_MAP_NEGATIVE_X,c.TEXTURE_CUBE_MAP_NEGATIVE_Y,c.TEXTURE_CUBE_MAP_NEGATIVE_Z];h._bindTextureDirectly(c.TEXTURE_CUBE_MAP,l),c.pixelStorei(c.UNPACK_FLIP_Y_WEBGL,0);for(var a=0;a>y;f.texImage2D(o[0],y,p,x,x,0,p,m,a[y][0]),f.texImage2D(o[1],y,p,x,x,0,p,m,a[y][2]),f.texImage2D(o[2],y,p,x,x,0,p,m,a[y][4]),f.texImage2D(o[3],y,p,x,x,0,p,m,a[y][1]),f.texImage2D(o[4],y,p,x,x,0,p,m,a[y][3]),f.texImage2D(o[5],y,p,x,x,0,p,m,a[y][5])}}else{for(var b=0;b-1&&t.splice(i,1),this._releaseTexture(e)}},s.prototype.unbindAllAttributes=function(){for(var e=0,t=this._vertexAttribArraysEnabled.length;e=this._caps.maxVertexAttribs||!this._vertexAttribArraysEnabled[e]||this._vertexAttribArraysEnabled[e]&&(this._gl.disableVertexAttribArray(e),this._vertexAttribArraysEnabled[e]=!1)},s.prototype.dispose=function(){for(this.hideLoadingUI(),this.stopRenderLoop();this.scenes.length;)this.scenes[0].dispose();s.audioEngine.dispose();for(var e in this._compiledEffects)this._gl.deleteProgram(this._compiledEffects[e]._program);this.unbindAllAttributes(),this._gl=null,this.disableVR(),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)},s.prototype.displayLoadingUI=function(){this._loadingScreen.displayLoadingUI()},s.prototype.hideLoadingUI=function(){this._loadingScreen.hideLoadingUI()},Object.defineProperty(s.prototype,"loadingScreen",{get:function(){return this._loadingScreen},set:function(e){this._loadingScreen=e},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"loadingUIText",{set:function(e){this._loadingScreen.loadingUIText=e},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"loadingUIBackgroundColor",{set:function(e){this._loadingScreen.loadingUIBackgroundColor=e},enumerable:!0,configurable:!0}),s.prototype.attachContextLostEvent=function(e){this._renderingCanvas.addEventListener("webglcontextlost",e,!1)},s.prototype.attachContextRestoredEvent=function(e){this._renderingCanvas.addEventListener("webglcontextrestored",e,!1)},s.prototype.getVertexShaderSource=function(e){var t=this._gl.getAttachedShaders(e);return this._gl.getShaderSource(t[0])},s.prototype.getFragmentShaderSource=function(e){var t=this._gl.getAttachedShaders(e);return this._gl.getShaderSource(t[1])},s.prototype.getFps=function(){return this.fps},s.prototype.getDeltaTime=function(){return this.deltaTime},s.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;r0&&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;i0&&(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})();t.FilesTextures=new Array,t.FilesToLoad=new Array,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;t<6;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)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.xt.x-this.minimumWorld.x)&&(!(this.maximumWorld.y-t.yt.y-this.minimumWorld.y)&&!(this.maximumWorld.z-t.zt.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.xt.x)&&(!(this.maximumWorld.yt.y)&&!(this.maximumWorld.zt.z))},t.Intersects=function(e,t){return!(e.maximumWorld.xt.maximumWorld.x)&&(!(e.maximumWorld.yt.maximumWorld.y)&&!(e.maximumWorld.zt.maximumWorld.z))},t.IntersectsSphere=function(t,i,r,n){var o=e.Vector3.Clamp(r,t,i),s=e.Vector3.DistanceSquared(r,o);return s<=n*n},t.IsCompletelyInFrustum=function(e,t){for(var i=0;i<6;i++)for(var r=0;r<8;r++)if(t[i].dotCoordinate(e[r])<0)return!1;return!0},t.IsInFrustum=function(e,t){for(var i=0;i<6;i++){for(var r=8,n=0;n<8&&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)},t.prototype.isCompletelyInFrustum=function(e){return this.boundingBox.isCompletelyInFrustum(e)},t.prototype._checkCollision=function(e){return e._canDoCollision(this.boundingSphere.centerWorld,this.boundingSphere.radiusWorld,this.boundingBox.minimumWorld,this.boundingBox.maximumWorld)},t.prototype.intersectsPoint=function(e){return!!this.boundingSphere.centerWorld&&(!!this.boundingSphere.intersectsPoint(e)&&!!this.boundingBox.intersectsPoint(e))},t.prototype.intersects=function(t,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))))))))))))))},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,this._show=!1}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.xt.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.yt.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.zt.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(n<=o)return!0;var s=t*this.direction.x+i*this.direction.y+r*this.direction.z;if(s<0)return!1;var a=n-s*s;return a<=o},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(s<0||s>1)return null;e.Vector3.CrossToRef(this._tvec,this._edge1,this._qvec);var a=e.Vector3.Dot(this.direction,this._qvec)*o;if(a<0||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,i<0?i<-9.99999997475243e-7?null:0:i},t.prototype.intersectsMesh=function(i,r){var n=e.Tmp.Matrix[0];return i.getWorldMatrix().invertToRef(n),this._tmpRay?t.TransformToRef(this,n,this._tmpRay):this._tmpRay=t.Transform(this,n),i.intersects(this._tmpRay,r)},t.prototype.show=function(t,i){this._show||(this._renderFunction=this._render.bind(this),this._show=!0,this._scene=t,this._renderPoints=[this.origin,this.origin.add(this.direction.scale(this.length))],this._renderLine=e.Mesh.CreateLines("ray",this._renderPoints,t,!0),this._scene.registerBeforeRender(this._renderFunction)),i&&this._renderLine.color.copyFrom(i)},t.prototype.hide=function(){this._show&&(this._show=!1,this._scene.unregisterBeforeRender(this._renderFunction)),this._renderLine&&(this._renderLine.dispose(),this._renderLine=null,this._renderPoints=null)},t.prototype._render=function(){var t=this._renderPoints[1];t.copyFrom(this.direction),t.scaleInPlace(this.length),t.addInPlace(this.origin),e.Mesh.CreateLines("ray",this._renderPoints,this._scene,!0,this._renderLine)},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),m=e.Vector3.Dot(u,u),_=e.Vector3.Dot(l,f),g=e.Vector3.Dot(u,f),v=d*m-p*p,y=v,x=v;vy&&(s=y,h=g+p,x=m)),h<0?(h=0,-_<0?s=0:-_>d?s=y:(s=-_,y=d)):h>x&&(h=x,-_+p<0?s=0:-_+p>d?s=y:(s=-_+p,y=d)),o=Math.abs(s)0&&a<=this.length&&A.lengthSquared()e.Engine.CollisionsEpsilon&&o.position.addInPlace(o._diffPositionForCollisions),r&&o.onCollideObservable.notifyObservers(r),o.onCollisionPositionChangeObservable.notifyObservers(o.position)},n.addMesh(o),o}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,"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.getClassName=function(){return"AbstractMesh"},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)},i.prototype.setBoundingInfo=function(e){this._boundingInfo=e},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,r,n){t.normalize(),this.rotationQuaternion||(this.rotationQuaternion=e.Quaternion.RotationYawPitchRoll(this.rotation.y,this.rotation.x,this.rotation.z),this.rotation=e.Vector3.Zero());var o;if(n&&n!==e.Space.LOCAL){if(this.parent){var s=this.parent.getWorldMatrix().clone();s.invert(),t=e.Vector3.TransformNormal(t,s)}o=e.Quaternion.RotationAxisToRef(t,r,i._rotationAxisCache),o.multiplyToRef(this.rotationQuaternion,this.rotationQuaternion)}else o=e.Quaternion.RotationAxisToRef(t,r,i._rotationAxisCache),this.rotationQuaternion.multiplyToRef(o,this.rotationQuaternion)},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(){return!this._isDirty&&(this.billboardMode===this._cache.billboardMode&&this.billboardMode===i.BILLBOARDMODE_NONE&&(!this._cache.pivotMatrixUpdated&&(!this.infiniteDistance&&(!!this._cache.position.equals(this.position)&&(!(this.rotationQuaternion&&!this._cache.rotationQuaternion.equals(this.rotationQuaternion))&&(!!this._cache.rotation.equals(this.rotation)&&!!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;t1&&!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;c1)||l.canIntersects(t)){var u=l.intersects(t,this._positions,this.getIndices(),i);if(u&&(i||!s||u.distance0&&this.includedOnlyMeshes.indexOf(e)===-1)&&(!(this.excludedMeshes.length>0&&this.excludedMeshes.indexOf(e)!==-1)&&((0===this.includeOnlyWithLayerMask||0!==(this.includeOnlyWithLayerMask&e.layerMask))&&!(0!==this.excludeWithLayerMask&&this.excludeWithLayerMask&e.layerMask)))},i.prototype.getWorldMatrix=function(){this._currentRenderId=this.getScene().getRenderId();var t=this._getWorldMatrix();return this.parent&&this.parent.getWorldMatrix?(this._parentedWorldMatrix||(this._parentedWorldMatrix=e.Matrix.Identity()),t.multiplyToRef(this.parent.getWorldMatrix(),this._parentedWorldMatrix),this._markSyncedWithParent(),this._parentedWorldMatrix):t},i.prototype.dispose=function(){this._shadowGenerator&&(this._shadowGenerator.dispose(),this._shadowGenerator=null),this.getScene().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;othis._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)},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},i})(e.Light);__decorate([e.serializeAsVector3()],t.prototype,"position",void 0),__decorate([e.serializeAsVector3()],t.prototype,"direction",void 0),__decorate([e.serialize()],t.prototype,"shadowOrthoScale",void 0),__decorate([e.serialize()],t.prototype,"autoUpdateExtends",void 0),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._useFullFloat=!0,this._light=r,this._scene=r.getScene(),this._mapSize=i,r._shadowGenerator=this;var o,s=this._scene.getEngine().getCaps();s.textureFloat&&s.textureFloatLinearFiltering&&s.textureFloatRender?(this._useFullFloat=!0,o=e.Engine.TEXTURETYPE_FLOAT):(this._useFullFloat=!1,o=e.Engine.TEXTURETYPE_UNSIGNED_INT),this._shadowMap=new e.RenderTargetTexture(r.name+"_shadowMap",i,this._scene,(!1),(!0),o,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),(!0),o),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 a=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;r4&&(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 h=r.join("\n");return this._cachedDefines!==h&&(this._cachedDefines=h,this._effect=this._scene.getEngine().createEffect("shadowMap",n,["world","mBones","viewProjection","diffuseMatrix","lightPosition","depthValues"],["diffuseSampler"],h)),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:e<=0?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;ti.x+r)&&(!(i.x-r>t.x)&&(!(e.y>i.y+r)&&(!(i.y-r>t.y)&&(!(e.z>i.z+r)&&!(i.z-r>t.z)))))},i=(function(){var e={root:0,found:!1};return function(t,i,r,n){e.root=0,e.found=!1;var o=i*i-4*t*r;if(o<0)return e;var s=Math.sqrt(o),a=(-i-s)/(2*t),h=(-i+s)/(2*t);if(a>h){var c=h;h=a,a=c}return a>0&&a0&&h=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)&&!!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||d<0)return;h<0&&(h=0),h>1&&(h=1)}this._collisionPoint.copyFromFloats(0,0,0);var m=!1,_=1;if(c||(this.basePoint.subtractToRef(l.normal,this._planeIntersectionPoint),this.velocity.scaleToRef(h,this._tempVector),this._planeIntersectionPoint.addInPlace(this._tempVector),this._checkPointInTriangle(this._planeIntersectionPoint,n,o,s,l.normal)&&(m=!0,_=h,this._collisionPoint.copyFrom(this._planeIntersectionPoint))),!m){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,_);b.found&&(_=b.root,m=!0,this._collisionPoint.copyFrom(n)),this.basePoint.subtractToRef(o,this._tempVector),y=2*e.Vector3.Dot(this.velocity,this._tempVector),x=this._tempVector.lengthSquared()-1,b=i(v,y,x,_),b.found&&(_=b.root,m=!0,this._collisionPoint.copyFrom(o)),this.basePoint.subtractToRef(s,this._tempVector),y=2*e.Vector3.Dot(this.velocity,this._tempVector),x=this._tempVector.lengthSquared()-1,b=i(v,y,x,_),b.found&&(_=b.root,m=!0,this._collisionPoint.copyFrom(s)),o.subtractToRef(n,this._edge),n.subtractToRef(this.basePoint,this._baseToVertex);var A=this._edge.lengthSquared(),T=e.Vector3.Dot(this._edge,this.velocity),E=e.Vector3.Dot(this._edge,this._baseToVertex);if(v=A*-g+T*T,y=A*(2*e.Vector3.Dot(this.velocity,this._baseToVertex))-2*T*E,x=A*(1-this._baseToVertex.lengthSquared())+E*E,b=i(v,y,x,_),b.found){var P=(T*b.root-E)/A;P>=0&&P<=1&&(_=b.root,m=!0,this._edge.scaleInPlace(P),n.addToRef(this._edge,this._collisionPoint))}s.subtractToRef(o,this._edge),o.subtractToRef(this.basePoint,this._baseToVertex),A=this._edge.lengthSquared(),T=e.Vector3.Dot(this._edge,this.velocity),E=e.Vector3.Dot(this._edge,this._baseToVertex),v=A*-g+T*T,y=A*(2*e.Vector3.Dot(this.velocity,this._baseToVertex))-2*T*E,x=A*(1-this._baseToVertex.lengthSquared())+E*E,b=i(v,y,x,_),b.found&&(P=(T*b.root-E)/A,P>=0&&P<=1&&(_=b.root,m=!0,this._edge.scaleInPlace(P),o.addToRef(this._edge,this._collisionPoint))),n.subtractToRef(s,this._edge),s.subtractToRef(this.basePoint,this._baseToVertex),A=this._edge.lengthSquared(),T=e.Vector3.Dot(this._edge,this.velocity),E=e.Vector3.Dot(this._edge,this._baseToVertex),v=A*-g+T*T,y=A*(2*e.Vector3.Dot(this.velocity,this._baseToVertex))-2*T*E,x=A*(1-this._baseToVertex.lengthSquared())+E*E,b=i(v,y,x,_),b.found&&(P=(T*b.root-E)/A,P>=0&&P<=1&&(_=b.root,m=!0,this._edge.scaleInPlace(P),s.addToRef(this._edge,this._collisionPoint)))}if(m){var M=_*this.velocity.length();(!this.collisionFound||M4)){++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})();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()||[])}},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;h0&&this._postProcesses[0].markTextureDirty();for(var t=0,i=this._rigCameras.length;t-1?(e.Tools.Error("You're trying to reuse a post process not defined as reusable."),0):(null==i||i<0?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);o!==-1&&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._refreshFrustumPlanes=!0,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.freezeProjectionMatrix=function(e){this._doNotComputeProjectionMatrix=!0,void 0!==e&&(this._projectionMatrix=e)},i.prototype.unfreezeProjectionMatrix=function(){this._doNotComputeProjectionMatrix=!1},i.prototype.getProjectionMatrix=function(t){if(this._doNotComputeProjectionMatrix||!t&&this._isSynchronizedProjectionMatrix())return this._projectionMatrix;this._refreshFrustumPlanes=!0;var r=this.getEngine(),n=this.getScene();if(this.mode===i.PERSPECTIVE_CAMERA)return this.minZ<=0&&(this.minZ=.1),n.useRightHandedSystem?e.Matrix.PerspectiveFovRHToRef(this.fov,r.getAspectRatio(this),this.minZ,this.maxZ,this._projectionMatrix,this.fovMode===i.FOVMODE_VERTICAL_FIXED):e.Matrix.PerspectiveFovLHToRef(this.fov,r.getAspectRatio(this),this.minZ,this.maxZ,this._projectionMatrix,this.fovMode===i.FOVMODE_VERTICAL_FIXED), +this._projectionMatrix;var o=r.getRenderWidth()/2,s=r.getRenderHeight()/2;return n.useRightHandedSystem?e.Matrix.OrthoOffCenterRHToRef(this.orthoLeft||-o,this.orthoRight||o,this.orthoBottom||-s,this.orthoTop||s,this.minZ,this.maxZ,this._projectionMatrix):e.Matrix.OrthoOffCenterLHToRef(this.orthoLeft||-o,this.orthoRight||o,this.orthoBottom||-s,this.orthoTop||s,this.minZ,this.maxZ,this._projectionMatrix),this._projectionMatrix},i.prototype.getTranformationMatrix=function(){return this._computedViewMatrix.multiplyToRef(this._projectionMatrix,this._transformMatrix),this._transformMatrix},i.prototype.updateFrustumPlanes=function(){this._refreshFrustumPlanes&&(this.getTranformationMatrix(),this._frustumPlanes?e.Frustum.GetPlanesToRef(this._transformMatrix,this._frustumPlanes):this._frustumPlanes=e.Frustum.GetPlanes(this._transformMatrix),this._refreshFrustumPlanes=!1)},i.prototype.isInFrustum=function(e){return this.updateFrustumPlanes(),e.isInFrustum(this._frustumPlanes)},i.prototype.isCompletelyInFrustum=function(e){return this.updateFrustumPlanes(),e.isCompletelyInFrustum(this._frustumPlanes)},i.prototype.dispose=function(){for(this.getScene().stopAnimation(this),this.getScene().removeCamera(this);this._rigCameras.length>0;)this._rigCameras.pop().dispose();for(var e=this._postProcesses.length;--e>=0;)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));break;case i.RIG_MODE_WEBVR:r.vrDisplay&&(this._rigCameras[0].viewport=new e.Viewport(0,0,.5,1),this._rigCameras[0].setCameraRigParameter("left",!0),this._rigCameras[0].setCameraRigParameter("frameData",r.frameData),this._rigCameras[0]._cameraRigParams.vrWorkMatrix=new e.Matrix,this._rigCameras[0].getProjectionMatrix=this._getWebVRProjectionMatrix,this._rigCameras[1].viewport=new e.Viewport(.5,0,.5,1),this._rigCameras[1].setCameraRigParameter("frameData",r.frameData),this._rigCameras[1]._cameraRigParams.vrWorkMatrix=new e.Matrix,this._rigCameras[1].getProjectionMatrix=this._getWebVRProjectionMatrix)}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._getWebVRProjectionMatrix=function(){var t=this._cameraRigParams.left?this._cameraRigParams.frameData.leftProjectionMatrix:this._cameraRigParams.frameData.rightProjectionMatrix;return[8,9,10,11].forEach((function(e){t[e]*=-1})),e.Matrix.FromArrayToRef(t,0,this._projectionMatrix),this._projectionMatrix},i.prototype._getWebVRViewMatrix=function(){var t=this._cameraRigParams.left?this._cameraRigParams.frameData.leftViewMatrix:this._cameraRigParams.frameData.rightViewMatrix;return[8,9,10,11].forEach((function(e){t[e]*=-1})),e.Matrix.FromArrayToRef(t,0,this._webvrViewMatrix),this._webvrViewMatrix},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=0&&r._keys.splice(t,1),i||e.preventDefault()}},t.addEventListener("keydown",this._onKeyDown,!1),t.addEventListener("keyup",this._onKeyUp,!1),e.Tools.RegisterTopRootEvents([{name:"blur",handler:this._onLostFocus}]))},t.prototype.detachControl=function(t){this._onKeyDown&&(t.removeEventListener("keydown",this._onKeyDown),t.removeEventListener("keyup",this._onKeyUp),e.Tools.UnregisterTopRootEvents([{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;i1)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"},t})();__decorate([e.serialize()],t.prototype,"touchAngularSensibility",void 0),__decorate([e.serialize()],t.prototype,"touchMoveSensibility",void 0),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),this._orientationChanged()},t.prototype.detachControl=function(e){window.removeEventListener("orientationchange",this._orientationChanged),window.removeEventListener("deviceorientation",this._deviceOrientation)},t.prototype.checkInputs=function(){this._alpha&&(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 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"},t})();__decorate([e.serialize()],t.prototype,"gamepadAngularSensibility",void 0),__decorate([e.serialize()],t.prototype,"gamepadMoveSensibility",void 0),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;t.tabIndex=1,this._onKeyDown=function(e){if(r.keysUp.indexOf(e.keyCode)!==-1||r.keysDown.indexOf(e.keyCode)!==-1||r.keysLeft.indexOf(e.keyCode)!==-1||r.keysRight.indexOf(e.keyCode)!==-1){var t=r._keys.indexOf(e.keyCode);t===-1&&r._keys.push(e.keyCode),e.preventDefault&&(i||e.preventDefault())}},this._onKeyUp=function(e){if(r.keysUp.indexOf(e.keyCode)!==-1||r.keysDown.indexOf(e.keyCode)!==-1||r.keysLeft.indexOf(e.keyCode)!==-1||r.keysRight.indexOf(e.keyCode)!==-1){var t=r._keys.indexOf(e.keyCode);t>=0&&r._keys.splice(t,1),e.preventDefault&&(i||e.preventDefault())}},this._onLostFocus=function(){r._keys=[]},t.addEventListener("keydown",this._onKeyDown,!1),t.addEventListener("keyup",this._onKeyUp,!1),e.Tools.RegisterTopRootEvents([{name:"blur",handler:this._onLostFocus}])},t.prototype.detachControl=function(t){t&&(t.removeEventListener("keydown",this._onKeyDown),t.removeEventListener("keyup",this._onKeyUp)),e.Tools.UnregisterTopRootEvents([{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.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"},t})();__decorate([e.serialize()],t.prototype,"gamepadRotationSensibility",void 0),__decorate([e.serialize()],t.prototype,"gamepadMoveSensibility",void 0),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){var o=t.call(this,i,r,n)||this;return o.cameraDirection=new e.Vector3(0,0,0),o.cameraRotation=new e.Vector2(0,0),o.rotation=new e.Vector3(0,0,0),o.speed=2,o.noRotationConstraint=!1,o.lockedTarget=null,o._currentTarget=e.Vector3.Zero(),o._viewMatrix=e.Matrix.Zero(),o._camMatrix=e.Matrix.Zero(),o._cameraTransformMatrix=e.Matrix.Zero(),o._cameraRotationMatrix=e.Matrix.Zero(),o._referencePoint=new e.Vector3(0,0,1),o._defaultUpVector=new e.Vector3(0,1,0),o._transformedReferencePoint=e.Vector3.Zero(),o._lookAtTemp=e.Matrix.Zero(),o._tempMatrix=e.Matrix.Zero(),o}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.absolutePosition&&this.lockedTarget.computeWorldMatrix(),this.lockedTarget.absolutePosition||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*Math.sqrt(e.getDeltaTime()/(100*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.Engine.CollisionsEpsilon&&(o.position.addInPlace(o._diffPosition),o.onCollide&&r&&o.onCollide(r))};n(i)},o.inputs=new e.FreeCameraInputsManager(o),o.inputs.addKeyboard().addMouse(),o}return __extends(i,t),Object.defineProperty(i.prototype,"angularSensibility",{get:function(){var e=this.inputs.attached.mouse;if(e)return e.angularSensibility},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;if(e)return e.keysUp},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;if(e)return e.keysDown},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;if(e)return e.keysLeft},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;if(e)return e.keysRight},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.getClassName=function(){return"FreeCamera"},i})(e.TargetCamera);__decorate([e.serializeAsVector3()],t.prototype,"ellipsoid",void 0),__decorate([e.serialize()],t.prototype,"checkCollisions",void 0),__decorate([e.serialize()],t.prototype,"applyGravity",void 0),e.FreeCamera=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(e){return t.call(this,e)||this}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.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){var o=t.call(this,e,i,r)||this;return o.radius=12,o.rotationOffset=0,o.heightOffset=4,o.cameraAcceleration=.05,o.maxCameraSpeed=20,o.lockedTarget=n,o}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=l<1?-this.maxCameraSpeed:this.maxCameraSpeed),(u>this.maxCameraSpeed||u<-this.maxCameraSpeed)&&(u=u<1?-this.maxCameraSpeed:this.maxCameraSpeed),(f>this.maxCameraSpeed||f<-this.maxCameraSpeed)&&(f=f<1?-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.lockedTarget)},i.prototype.getClassName=function(){return"FollowCamera"},i})(e.TargetCamera);__decorate([e.serialize()],t.prototype,"radius",void 0),__decorate([e.serialize()],t.prototype,"rotationOffset",void 0),__decorate([e.serialize()],t.prototype,"heightOffset",void 0),__decorate([e.serialize()],t.prototype,"cameraAcceleration",void 0),__decorate([e.serialize()],t.prototype,"maxCameraSpeed",void 0),__decorate([e.serializeAsMeshReference("lockedTargetId")],t.prototype,"lockedTarget",void 0),e.FollowCamera=t;var i=(function(t){function i(i,r,n,o,s,a){var h=t.call(this,i,e.Vector3.Zero(),a)||this;return h.alpha=r,h.beta=n,h.radius=o,h.target=s,h._cartesianCoordinates=e.Vector3.Zero(),h.follow(),h}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.getClassName=function(){return"ArcFollowCamera"},i})(e.TargetCamera);e.ArcFollowCamera=i})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(e){function t(t,i,r){var n=e.call(this,t,i,r)||this;return n.inputs.addTouch(),n._setupInputs(),n}return __extends(t,e),Object.defineProperty(t.prototype,"touchAngularSensibility",{get:function(){var e=this.inputs.attached.touch;if(e)return e.touchAngularSensibility},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;if(e)return e.touchMoveSensibility},set:function(e){var t=this.inputs.attached.touch;t&&(t.touchMoveSensibility=e)},enumerable:!0,configurable:!0}),t.prototype.getClassName=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=t.call(this,i,e.Vector3.Zero(),a)||this;return h.inertialAlphaOffset=0,h.inertialBetaOffset=0,h.inertialRadiusOffset=0,h.lowerAlphaLimit=null,h.upperAlphaLimit=null,h.lowerBetaLimit=.01,h.upperBetaLimit=Math.PI,h.lowerRadiusLimit=null,h.upperRadiusLimit=null,h.inertialPanningX=0,h.inertialPanningY=0,h.zoomOnFactor=1,h.targetScreenOffset=e.Vector2.Zero(),h.allowUpsideDown=!0,h._viewMatrix=new e.Matrix,h.panningAxis=new e.Vector3(1,1,0),h.checkCollisions=!1,h.collisionRadius=new e.Vector3(.5,.5,.5),h._collider=new e.Collider,h._previousPosition=e.Vector3.Zero(),h._collisionVelocity=e.Vector3.Zero(),h._newPosition=e.Vector3.Zero(),h._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?h.target=s:h.target=e.Vector3.Zero(),h.alpha=r,h.beta=n,h.radius=o,h.getViewMatrix(),h.inputs=new e.ArcRotateCameraInputsManager(h),h.inputs.addKeyboard().addMouseWheel().addPointers().addGamepad(),h}return __extends(i,t),Object.defineProperty(i.prototype,"angularSensibilityX",{get:function(){var e=this.inputs.attached.pointers;if(e)return e.angularSensibilityX},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;if(e)return e.angularSensibilityY},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;if(e)return e.pinchPrecision},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;if(e)return e.panningSensibility},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;if(e)return e.keysUp},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;if(e)return e.keysDown},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;if(e)return e.keysLeft},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;if(e)return e.keysRight},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;if(e)return e.wheelPrecision},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(){if(this.target.getAbsolutePosition){var e=this.target.getAbsolutePosition();return this._targetBoundingCenter?e.add(this._targetBoundingCenter):e}return 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))},i.prototype.attachControl=function(e,t,i,r){var n=this;void 0===i&&(i=!0),void 0===r&&(r=2),this._useCtrlForPanning=i,this._panningMouseButton=r,this.inputs.attachElement(e,t),this._reset=function(){n.inertialAlphaOffset=0,n.inertialBetaOffset=0,n.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.getScene().useRightHandedSystem?this.alpha-=this.beta<=0?-this.inertialAlphaOffset:this.inertialAlphaOffset: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)Math.PI&&(this.beta=this.beta-2*Math.PI):this.betathis.upperBetaLimit&&(this.beta=this.upperBetaLimit),this.lowerAlphaLimit&&this.alphathis.upperAlphaLimit&&(this.alpha=this.upperAlphaLimit),this.lowerRadiusLimit&&this.radiusthis.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.copyFrom(e),this.rebuildAnglesAndRadius())},i.prototype.setTarget=function(e,t){void 0===t&&(t=!1),this._getTargetPosition().equals(e)||(t&&e.getBoundingInfo?this._targetBoundingCenter=e.getBoundingInfo().boundingBox.center.clone():this._targetBoundingCenter=null,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()),this.getScene().useRightHandedSystem?e.Matrix.LookAtRHToRef(this.position,o,s,this._viewMatrix):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._currentTarget=o,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.getClassName=function(){return"ArcRotateCamera"},i})(e.TargetCamera);__decorate([e.serialize()],t.prototype,"alpha",void 0),__decorate([e.serialize()],t.prototype,"beta",void 0),__decorate([e.serialize()],t.prototype,"radius",void 0),__decorate([e.serializeAsVector3()],t.prototype,"target",void 0),__decorate([e.serialize()],t.prototype,"inertialAlphaOffset",void 0),__decorate([e.serialize()],t.prototype,"inertialBetaOffset",void 0),__decorate([e.serialize()],t.prototype,"inertialRadiusOffset",void 0),__decorate([e.serialize()],t.prototype,"lowerAlphaLimit",void 0),__decorate([e.serialize()],t.prototype,"upperAlphaLimit",void 0),__decorate([e.serialize()],t.prototype,"lowerBetaLimit",void 0),__decorate([e.serialize()],t.prototype,"upperBetaLimit",void 0),__decorate([e.serialize()],t.prototype,"lowerRadiusLimit",void 0),__decorate([e.serialize()],t.prototype,"upperRadiusLimit",void 0),__decorate([e.serialize()],t.prototype,"inertialPanningX",void 0),__decorate([e.serialize()],t.prototype,"inertialPanningY",void 0),__decorate([e.serialize()],t.prototype,"zoomOnFactor",void 0),__decorate([e.serialize()],t.prototype,"allowUpsideDown",void 0),e.ArcRotateCamera=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(e){return t.call(this,e)||this}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._autoClearDepthStencil={},this._customOpaqueSortCompareFn={},this._customAlphaTestSortCompareFn={},this._customTransparentSortCompareFn={},this._renderinGroupInfo=null,this._scene=e;for(var i=t.MIN_RENDERINGGROUPS;ii._alphaIndex?1:e._alphaIndext._distanceToCamera?-1:0},t.frontToBackSortCompare=function(e,t){return e._distanceToCamerat._distanceToCamera?1:0},t.prototype.prepare=function(){this._opaqueSubMeshes.reset(),this._transparentSubMeshes.reset(),this._alphaTestSubMeshes.reset(),this._particleSystems.reset(),this._spriteManagers.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.prototype.dispatchSprites=function(e){this._spriteManagers.push(e)},t.prototype.dispatchParticles=function(e){this._particleSystems.push(e)},t.prototype._renderParticles=function(e){if(0!==this._particleSystems.length){var t=this._scene.activeCamera;this._scene._particlesDuration.beginMonitoring();for(var i=0;ie.ActionManager.LongPressDelay&&Math.abs(l._startingPointerPosition.x-l._pointerX)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&&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(e){return e.isPickable&&e.isVisible&&e.isReady()});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)),c.pickedMesh.actionManager&&Math.abs(a._startingPointerPosition.x-a._pointerX)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)),c.pickedSprite.actionManager&&Math.abs(a._startingPointerPosition.x-a._pointerX)0)return!1;var t;for(t=0;t0)return;this._animationTimeLast=t}var i=(t-this._animationTimeLast)*this.animationTimeScale;this._animationTime+=i,this._animationTimeLast=t;for(var r=0;r0?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.switchActiveCamera=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-1&&(this._geometries.splice(t,1),this.collisionCoordinator.onGeometryDeleted(e),this.onGeometryRemovedObservable.notifyObservers(e),!0)},i.prototype.getGeometries=function(){return this._geometries},i.prototype.getMeshByID=function(e){for(var t=0;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=0;t--)if(this.skeletons[t].id===e)return this.skeletons[t];return null},i.prototype.getSkeletonById=function(e){for(var t=0;t0&&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(o,s)))}}this._particlesDuration.beginMonitoring();e.Tools.Now;if(this.particlesEnabled){e.Tools.StartPerformanceCounter("Particles",this.particleSystems.length>0);for(var a=0;a0)}this._particlesDuration.endMonitoring(!1)},i.prototype._activeMesh=function(e,t){if(t.skeleton&&this.skeletonsEnabled&&(this._activeSkeletons.pushNoDuplicate(t.skeleton)&&t.skeleton.prepare(),t.computeBonesUsingShaders||this._softwareSkinnedMeshes.pushNoDuplicate(t)),(e.showBoundingBox||this.forceShowBoundingBoxes)&&this._boundingBoxRenderer.renderList.push(e.getBoundingInfo().boundingBox),e._edgesRenderer&&this._edgesRenderers.push(e._edgesRenderer),t&&t.subMeshes){var i,r;if(t._submeshesOctree&&t.useOctreeForRenderingSelection){var n=t._submeshesOctree.select(this._frustumPlanes);i=n.length,r=n.data}else r=t.subMeshes,i=r.length;for(var o=0;o0){this._intermediateRendering=!0,e.Tools.StartPerformanceCounter("Render targets",this._renderTargets.length>0);for(var s=0;s0),this._intermediateRendering=!1,this._renderId++,o=!0}var c=this._engine.getStencilBuffer(),l=!1;if(this.renderTargetsEnabled&&this.highlightLayers&&this.highlightLayers.length>0){this._intermediateRendering=!0;for(var u=0;u-1)){l=!0;var a=f._mainTexture;a._shouldRender()&&(this._renderId++,a.render(!1,!1),o=!0)}}this._intermediateRendering=!1,this._renderId++}o&&i.restoreDefaultFramebuffer(),this._renderTargetsDuration.endMonitoring(!1),this.postProcessManager._prepareFrame(),this._renderDuration.beginMonitoring();var d,p;if(this.layers.length){for(i.setDepthBuffer(!1),d=0;d0);for(var _=0;_0)}if(this.layers.length){for(i.setDepthBuffer(!1),d=0;d-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(){this._lastFrameDuration.beginMonitoring(),this._particlesDuration.fetchNewFrame(),this._spritesDuration.fetchNewFrame(),this._activeParticles.fetchNewFrame(),this._renderDuration.fetchNewFrame(),this._renderTargetsDuration.fetchNewFrame(),this._evaluateActiveMeshesDuration.fetchNewFrame(),this._totalVertices.fetchNewFrame(),this._activeIndices.fetchNewFrame(),this._activeBones.fetchNewFrame(),this.getEngine().drawCallsPerfCounter.fetchNewFrame(),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 t=Math.max(i.MinDeltaTime,Math.min(this._engine.getDeltaTime(),i.MaxDeltaTime));this._animationRatio=.06*t,this._animate(),this._physicsEngine&&(e.Tools.StartPerformanceCounter("Physics"),this._physicsEngine._step(t/1e3),e.Tools.EndPerformanceCounter("Physics")),this.onBeforeRenderObservable.notifyObservers(this),this._renderTargetsDuration.beginMonitoring();var r=(e.Tools.Now,this.getEngine()),n=this.activeCamera;if(this.renderTargetsEnabled){e.Tools.StartPerformanceCounter("Custom render targets",this.customRenderTargets.length>0);for(var o=0;o0),this._renderId++}if(this.customRenderTargets.length>0&&r.restoreDefaultFramebuffer(),this._renderTargetsDuration.endMonitoring(),this.activeCamera=n,this.proceduralTexturesEnabled){e.Tools.StartPerformanceCounter("Procedural textures",this._proceduralTextures.length>0);for(var a=0;a0)}if(this._engine.clear(this.clearColor,this.autoClear||this.forceWireframe||this.forcePointsCloud,!0,!0),this.shadowsEnabled)for(var c=0;c0)for(var f=0;f0&&this._engine.clear(null,!1,!0,!0),this._processSubCameras(this.activeCameras[f]);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 d=0;d0?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-1&&this._engine.scenes.splice(t,1),this._engine.wipeCaches()},i.prototype.disposeSounds=function(){this.mainSoundTrack.dispose();for(var e=0;e=n.distance))&&(n=c,r))break}return n||new e.PickingInfo},i.prototype._internalMultiPick=function(e,t){for(var i=new Array,r=0;r0)for(var s=0;s=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.multiPick=function(e,t,i,r){var n=this;return this._internalMultiPick((function(i){return n.createPickingRay(e,t,i,r)}),i)},i.prototype.multiPickWithRay=function(t,i){var r=this;return this._internalMultiPick((function(i){return r._pickWithRayInverseMatrix||(r._pickWithRayInverseMatrix=e.Matrix.Identity()),i.invertToRef(r._pickWithRayInverseMatrix),e.Ray.Transform(t,r._pickWithRayInverseMatrix)}),i)},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;n0},enumerable:!0,configurable:!0}),r.prototype._sortLODLevels=function(){this._LODLevels.sort((function(e,t){return e.distancet.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;ti)return this.onLODLevelSelection&&this.onLODLevelSelection(i,this,this._LODLevels[this._LODLevels.length-1].mesh),this;for(var r=0;r=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,i=this._geometry.copy(e.Geometry.RandomId());t.releaseForMesh(this,!0),i.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-1&&(o.skeleton=i.getLastSkeletonByID(t.skeletonId),t.numBoneInfluencers&&(o.numBoneInfluencers=t.numBoneInfluencers)),t.animations){for(var s=0;s4,c=h?this.getVerticesData(e.VertexBuffer.MatricesIndicesExtraKind):null,l=h?this.getVerticesData(e.VertexBuffer.MatricesWeightsExtraKind):null,u=t.getTransformMatrices(this),f=e.Vector3.Zero(),d=new e.Matrix,p=new e.Matrix,m=0,_=0;_0);o++)e.Matrix.FromFloat32ArrayToRefScaled(u,16*s[m+o],g,p),d.addToSelf(p);if(h)for(o=0;o<4&&(g=l[m+o],g>0);o++)e.Matrix.FromFloat32ArrayToRefScaled(u,16*c[m+o],g,p),d.addToSelf(p);e.Vector3.TransformCoordinatesFromFloatsToRef(this._sourcePositions[_],this._sourcePositions[_+1],this._sourcePositions[_+2],d,f),f.toArray(r,_),e.Vector3.TransformNormalFromFloatsToRef(this._sourceNormals[_],this._sourceNormals[_+1],this._sourceNormals[_+2],d,f),f.toArray(n,_),d.reset()}return this.updateVerticesData(e.VertexBuffer.PositionKind,r),this.updateVerticesData(e.VertexBuffer.NormalKind,n),this}},r.MinMax=function(e){var t=null,i=null;return e.forEach((function(e,r,n){var o=e.getBoundingInfo().boundingBox;t?(t.MinimizeInPlace(o.minimumWorld),i.MaximizeInPlace(o.maximumWorld)):(t=o.minimumWorld,i=o.maximumWorld)})),{min:t,max:i}},r.Center=function(t){var i=t instanceof Array?e.Mesh.MinMax(t):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;s65536))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;sa&&(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.updateSideOrientation=function(t,i){return t==e.Mesh.DOUBLESIDE?e.Mesh.DOUBLESIDE:void 0===t||null===t?e.Mesh.FRONTSIDE:t},t.CreateBox=function(t,i,r){var n=new e.Mesh(t,r);i.sideOrientation=this.updateSideOrientation(i.sideOrientation,r),n.sideOrientation=i.sideOrientation;var 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);i.sideOrientation=this.updateSideOrientation(i.sideOrientation,r),n.sideOrientation=i.sideOrientation;var 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);i.sideOrientation=this.updateSideOrientation(i.sideOrientation,r),n.sideOrientation=i.sideOrientation;var 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);i.sideOrientation=this.updateSideOrientation(i.sideOrientation,r),n.sideOrientation=i.sideOrientation;var 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,this.updateSideOrientation(i.sideOrientation,r)),h=i.instance,c=i.updatable;if(h){e.Vector3.FromFloatsToRef(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,e.Tmp.Vector3[0]),e.Vector3.FromFloatsToRef(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE,e.Tmp.Vector3[1]);var l=function(t){for(var i=n[0].length,r=0,o=h.sideOrientation===e.Mesh.DOUBLESIDE?2:1,s=1;s<=o;s++)for(var a=0;ae.Tmp.Vector3[1].x&&(e.Tmp.Vector3[1].x=c[u].x),c[u].ye.Tmp.Vector3[1].y&&(e.Tmp.Vector3[1].y=c[u].y),c[u].ze.Tmp.Vector3[1].z&&(e.Tmp.Vector3[1].z=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._boundingInfo=new e.BoundingInfo(e.Tmp.Vector3[0],e.Tmp.Vector3[1]),h._boundingInfo.update(h._worldMatrix),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,m=0,_=0;_1?1:r.arc:1,a=void 0===r.closed||r.closed,h=r.shape,c=r.radius||1,l=r.tessellation||64,u=r.updatable,f=this.updateSideOrientation(r.sideOrientation,n),d=r.cap||e.Mesh.NO_CAP,p=2*Math.PI,m=new Array,_=r.invertUV||!1,g=0,v=0,y=p/l*s,x=new Array;for(g=0;g<=l;g++){var x=[];for(d!=e.Mesh.CAP_START&&d!=e.Mesh.CAP_ALL||(x.push(new e.Vector3(0,h[0].y,0)),x.push(new e.Vector3(Math.cos(g*y)*h[0].x*c,h[0].y,Math.sin(g*y)*h[0].x*c))),v=0;v1?1:r.arc||1;var p,m,_=function(t,i,r,n,o,s,a,h){for(var c,l,u,f,d=i.getTangents(),p=i.getNormals(),m=i.getDistances(),_=2*Math.PI,g=_/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,A=0;A3?0:c,m=_(o,p,v,s,a,h,c,r.arc);var y=t.CreateRibbon(i,{pathArray:m,closePath:!0,closeArray:!1,updatable:u,sideOrientation:f,invertUV:l},n);return y.pathArray=m,y.path3D=p,y.tessellation=a,y.cap=c,y.arc=r.arc,y},t.CreatePolyhedron=function(t,i,r){var n=new e.Mesh(t,r);i.sideOrientation=this.updateSideOrientation(i.sideOrientation,r),n.sideOrientation=i.sideOrientation;var 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,m=Math.sqrt(h.x*h.x+h.z*h.z),_=Math.atan2(h.y,m),g=e.Matrix.RotationYawPitchRoll(p,_,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 A=0,T=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},E=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;s0,h=g>0,l=v>0,m=(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},P=0;P3?0:u,y=x(r,n,v,b,o,s,a,h,u,f);var A=t.CreateRibbon(i,{pathArray:y,closeArray:c,closePath:l,updatable:p,sideOrientation:m,invertUV:g},d);return A.pathArray=y,A.path3D=v,A.cap=u,A},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),this._uid=null}return Object.defineProperty(t.prototype,"uid",{get:function(){return this._uid||(this._uid=e.Tools.RandomId()),this._uid},enumerable:!0,configurable:!0}),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||!!this._texture&&this._texture.isReady},t.prototype.getSize=function(){return this._texture._width?new e.Size(this._texture._width,this._texture._height):this._texture._size?new e.Size(this._texture._size,this._texture._size):e.Size.Zero()},t.prototype.getBaseSize=function(){return this.isReady()&&this._texture?this._texture._size?new e.Size(this._texture._size,this._texture._size):new e.Size(this._texture._baseWidth,this._texture._baseHeight):e.Size.Zero()},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=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},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),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===o&&(o=!1),void 0===s&&(s=!0),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);var f=t.call(this,n)||this;if(f.uOffset=0,f.vOffset=0,f.uScale=1,f.vScale=1,f.uAng=0,f.vAng=0,f.wAng=0,f.name=r,f.url=r,f._noMipmap=o,f._invertY=s,f._samplingMode=a,f._buffer=l,f._deleteBuffer=u,!r)return f;f._texture=f._getFromCache(r,o,a);var d=function(){f._onLoadObservarble&&f._onLoadObservarble.hasObservers()&&f.onLoadObservable.notifyObservers(!0),h&&h()};return f._texture?f._texture.isReady?e.Tools.SetImmediate((function(){return d()})):f._texture.onLoadedCallbacks.push(d):n.useDelayedTextureLoading?(f.delayLoadState=e.Engine.DELAYLOADSTATE_NOTLOADED,f._delayedOnLoad=d,f._delayedOnError=c):(f._texture=n.getEngine().createTexture(r,o,s,n,f._samplingMode,d,c,f._buffer),u&&delete f._buffer),f}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)},Object.defineProperty(i.prototype,"onLoadObservable",{get:function(){return this._onLoadObservarble||(this._onLoadObservarble=new e.Observable),this._onLoadObservarble},enumerable:!0,configurable:!0}),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.customType){var o=e.Tools.Instantiate(t.customType);return o.Parse(t,r,n)}if(t.isCube)return e.CubeTexture.Parse(t,r,n);if(!t.name&&!t.isRenderTarget)return null;var s=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 a=0;a=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,s,a,h){void 0===s&&(s=e.Engine.TEXTURETYPE_UNSIGNED_INT),void 0===a&&(a=e.Texture.BILINEAR_SAMPLINGMODE),void 0===h&&(h=!0);var c=t.call(this,i,r,n,o,!0,s,!1,a,h)||this;return c.mirrorPlane=new e.Plane(0,1,0,1),c._transformMatrix=e.Matrix.Zero(),c._mirrorMatrix=e.Matrix.Zero(),c.onBeforeRenderObservable.add((function(){e.Matrix.ReflectionToRef(c.mirrorPlane,c._mirrorMatrix),c._savedViewMatrix=n.getViewMatrix(),c._mirrorMatrix.multiplyToRef(c._savedViewMatrix,c._transformMatrix),n.setTransformMatrix(c._transformMatrix,n.getProjectionMatrix()),n.clipPlane=c.mirrorPlane,n.getEngine().cullBackFaces=!1,n._mirroredCameraPosition=e.Vector3.TransformCoordinates(n.activeCamera.position,c._mirrorMatrix)})),c.onAfterRenderObservable.add((function(){n.setTransformMatrix(c._savedViewMatrix,n.getProjectionMatrix()),n.getEngine().cullBackFaces=!0,n._mirroredCameraPosition=null,delete n.clipPlane})),c}return __extends(i,t),i.prototype.clone=function(){var e=this.getSize(),t=new i(this.name,e.width,this.getScene(),this._renderTargetOptions.generateMipMaps,this._renderTargetOptions.type,this._renderTargetOptions.samplingMode,this._renderTargetOptions.generateDepthBuffer);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=t.call(this,i,r,n,o,!0)||this;return s.refractionPlane=new e.Plane(0,1,0,1),s.depth=2,s.onBeforeRenderObservable.add((function(){n.clipPlane=s.refractionPlane})),s.onAfterRenderObservable.add((function(){delete n.clipPlane})),s}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);var a=t.call(this,null,n,!o)||this;a.name=i,a.wrapU=e.Texture.CLAMP_ADDRESSMODE,a.wrapV=e.Texture.CLAMP_ADDRESSMODE,a._generateMipMaps=o,r.getContext?(a._canvas=r,a._texture=n.getEngine().createDynamicTexture(r.width,r.height,o,s)):(a._canvas=document.createElement("canvas"),r.width?a._texture=n.getEngine().createDynamicTexture(r.width,r.height,o,s):a._texture=n.getEngine().createDynamicTexture(r,r,o,s));var h=a.getSize();return a._canvas.width=h.width,a._canvas.height=h.height,a._context=a._canvas.getContext("2d"),a}return __extends(i,t),Object.defineProperty(i.prototype,"canRescale",{get:function(){return!0},enumerable:!0,configurable:!0}),i.prototype.scale=function(e){var t=this.getSize();t.width*=e,t.height*=e,this._canvas.width=t.width,this._canvas.height=t.height,this.releaseInternalTexture(),this._texture=this.getScene().getEngine().createDynamicTexture(t.width,t.height,this._generateMipMaps,this._samplingMode)},i.prototype.getContext=function(){return this._context},i.prototype.clear=function(){var e=this.getSize();this._context.fillRect(0,0,e.width,e.height)},i.prototype.update=function(e){this.getScene().getEngine().updateDynamicTexture(this._texture,this._canvas,void 0===e||e)},i.prototype.drawText=function(e,t,i,r,n,o,s,a){void 0===a&&(a=!0);var h=this.getSize();if(o&&(this._context.fillStyle=o,this._context.fillRect(0,0,h.width,h.height)),this._context.font=r,null===t){var c=this._context.measureText(e);t=(h.width-c.width)/2}this._context.fillStyle=n,this._context.fillText(e,t,i),a&&this.update(s)},i.prototype.clone=function(){var e=this.getSize(),t=new i(this.name,e,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){void 0===o&&(o=!1),void 0===s&&(s=!1),void 0===a&&(a=e.Texture.TRILINEAR_SAMPLINGMODE);var h=t.call(this,null,n,!o,s)||this;h._autoLaunch=!0;var c;return h.name=i,r instanceof HTMLVideoElement?h.video=r:(c=r,h.video=document.createElement("video"),h.video.autoplay=!1,h.video.loop=!0),h._generateMipMaps=o,h._samplingMode=a,e.Tools.IsExponentOfTwo(h.video.videoWidth)&&e.Tools.IsExponentOfTwo(h.video.videoHeight)?(h.wrapU=e.Texture.WRAP_ADDRESSMODE,h.wrapV=e.Texture.WRAP_ADDRESSMODE):(h.wrapU=e.Texture.CLAMP_ADDRESSMODE,h.wrapV=e.Texture.CLAMP_ADDRESSMODE,h._generateMipMaps=!1),c?(h.video.addEventListener("canplaythrough",(function(){h._createTexture()})),c.forEach((function(e){var t=document.createElement("source");t.src=e,h.video.appendChild(t)}))):h._createTexture(),h._lastUpdate=e.Tools.Now,h}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)&&(this._lastUpdate=t,this.getScene().getEngine().updateVideoTexture(this._texture,this.video,this._invertY),!0)},i.CreateFromWebCam=function(t,i,r){var n=document.createElement("video");navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia,window.URL=window.URL||window.webkitURL||window.mozURL||window.msURL,navigator.getUserMedia&&navigator.getUserMedia({video:{width:{min:r&&r.minWidth||256,max:r&&r.maxWidth||640},height:{min:r&&r.minHeight||256,max:r&&r.maxHeight||480}}},(function(r){void 0!==n.mozSrcObject?n.mozSrcObject=r:n.src=window.URL&&window.URL.createObjectURL(r)||r,n.play(),i&&i(new e.VideoTexture("video",n,t,(!0),(!0)))}),(function(t){e.Tools.Error(t.name)}))},i})(e.Texture);e.VideoTexture=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(e,i,r,n,o,s){var a=t.call(this,e,r,null,n,o,s)||this;return a._animate=!0,a._time=0,a._texturePath=i,a.loadJson(i),a.refreshRate=1,a}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;tthis._maxRank&&(this._maxRank=e),this._defines[e]=new Array),this._defines[e].push(t)},e.prototype.addCPUSkinningFallback=function(e,t){this._meshRank=e,this._mesh=t,e>this._maxRank&&(this._maxRank=e)},Object.defineProperty(e.prototype,"isMoreFallbacks",{get:function(){return this._currentRank<=this._maxRank},enumerable:!0,configurable:!0}),e.prototype.reduce=function(e){for(var t=this._defines[this._currentRank],i=0;i-1?e:BABYLON.Engine.ShadersRepository+e,BABYLON.Tools.LoadFile(n+".vertex.fx",t)},Effect.prototype._loadFragmentShader=function(e,t){if(e instanceof HTMLElement){var i=BABYLON.Tools.GetDOMTextContent(e);return void t(i)}if("base64:"===e.substr(0,7)){var r=window.atob(e.substr(7));return void t(r)}if(Effect.ShadersStore[e+"PixelShader"])return void t(Effect.ShadersStore[e+"PixelShader"]);if(Effect.ShadersStore[e+"FragmentShader"])return void t(Effect.ShadersStore[e+"FragmentShader"]);var n;n="."===e[0]||"/"===e[0]||e.indexOf("http")>-1?e:BABYLON.Engine.ShadersRepository+e,BABYLON.Tools.LoadFile(n+".fragment.fx",t)},Effect.prototype._dumpShadersName=function(){this.name.vertexElement?(BABYLON.Tools.Error("Vertex shader:"+this.name.vertexElement),BABYLON.Tools.Error("Fragment shader:"+this.name.fragmentElement)):this.name.vertex?(BABYLON.Tools.Error("Vertex shader:"+this.name.vertex),BABYLON.Tools.Error("Fragment shader:"+this.name.fragment)):(BABYLON.Tools.Error("Vertex shader:"+this.name),BABYLON.Tools.Error("Fragment shader:"+this.name))},Effect.prototype._processIncludes=function(e,t){for(var i=this,r=/#include<(.+)>(\((.*)\))*(\[(.*)\])*/g,n=r.exec(e),o=new String(e);null!=n;){var s=n[1];if(!Effect.IncludesShadersStore[s]){var a=BABYLON.Engine.ShadersRepository+"ShadersInclude/"+s+".fx";return void BABYLON.Tools.LoadFile(a,(function(e){Effect.IncludesShadersStore[s]=e,i._processIncludes(o,t)}))}var h=Effect.IncludesShadersStore[s];if(n[2])for(var c=n[3].split(","),l=0;l0&&(result+=line+"\r\n")}return result},Effect.prototype._evaluateDefinesOnString=function(e){for(var t={children:[]},i=t,r=e.split("\n"),n=0;n0){for(var f=0;f0){for(var p=0;p0&&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=0&&this._scene.materials.splice(i,1),e&&this._effect&&(this._scene.getEngine()._releaseEffect(this._effect),this._effect=null),i=0;i0&&(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;a=!0,this._defines.EMISSIVE=!0}if(this.lightmapTexture&&r.LightmapTextureEnabled){if(!this.lightmapTexture.isReady())return!1;a=!0,this._defines.LIGHTMAP=!0,this._defines.USELIGHTMAPASSHADOWMAP=this.useLightmapAsShadowmap}if(this.specularTexture&&r.SpecularTextureEnabled){if(!this.specularTexture.isReady())return!1;a=!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;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&&r.RefractionTextureEnabled){if(!this.refractionTexture.isReady())return!1;a=!0,this._defines.REFRACTION=!0,this._defines.REFRACTIONMAP_3D=this.refractionTexture.isCube}if(this.cameraColorGradingTexture&&r.ColorGradingTextureEnabled){if(!this.cameraColorGradingTexture.isReady())return!1;this._defines.CAMERACOLORGRADING=!0}}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.cameraColorCurves&&(this._defines.CAMERACOLORCURVES=!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),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),h=!0,this._defines.FRESNEL=!0),this._defines.SPECULARTERM&&this.useSpecularOverAlpha&&(this._defines.SPECULAROVERALPHA=!0),i&&(h&&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),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",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"];this._defines.CAMERACOLORCURVES&&e.ColorCurves.PrepareUniforms(d),this._defines.CAMERACOLORGRADING&&e.ColorGradingTexture.PrepareUniformsAndSamplers(d,p),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)},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){if(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)}this.cameraColorGradingTexture&&r.ColorGradingTextureEnabled&&e.ColorGradingTexture.Bind(this.cameraColorGradingTexture,this._effect)}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),this.cameraColorCurves&&e.ColorCurves.Bind(this.cameraColorCurves,this._effect)),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),this.cameraColorGradingTexture&&this.cameraColorGradingTexture.animations&&this.cameraColorGradingTexture.animations.length>0&&e.push(this.cameraColorGradingTexture),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(),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(){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})(e.Material);i.DiffuseTextureEnabled=!0,i.AmbientTextureEnabled=!0,i.OpacityTextureEnabled=!0,i.ReflectionTextureEnabled=!0,i.EmissiveTextureEnabled=!0,i.SpecularTextureEnabled=!0,i.BumpTextureEnabled=!0,i.FresnelEnabled=!0,i.LightmapTextureEnabled=!0,i.RefractionTextureEnabled=!0,i.ColorGradingTextureEnabled=!0,__decorate([e.serializeAsTexture()],i.prototype,"diffuseTexture",void 0),__decorate([e.serializeAsTexture()],i.prototype,"ambientTexture",void 0),__decorate([e.serializeAsTexture()],i.prototype,"opacityTexture",void 0),__decorate([e.serializeAsTexture()],i.prototype,"reflectionTexture",void 0),__decorate([e.serializeAsTexture()],i.prototype,"emissiveTexture",void 0),__decorate([e.serializeAsTexture()],i.prototype,"specularTexture",void 0),__decorate([e.serializeAsTexture()],i.prototype,"bumpTexture",void 0),__decorate([e.serializeAsTexture()],i.prototype,"lightmapTexture",void 0),__decorate([e.serializeAsTexture()],i.prototype,"refractionTexture",void 0),__decorate([e.serializeAsColor3("ambient")],i.prototype,"ambientColor",void 0),__decorate([e.serializeAsColor3("diffuse")],i.prototype,"diffuseColor",void 0),__decorate([e.serializeAsColor3("specular")],i.prototype,"specularColor",void 0),__decorate([e.serializeAsColor3("emissive")],i.prototype,"emissiveColor",void 0),__decorate([e.serialize()],i.prototype,"specularPower",void 0),__decorate([e.serialize()],i.prototype,"useAlphaFromDiffuseTexture",void 0),__decorate([e.serialize()],i.prototype,"useEmissiveAsIllumination",void 0),__decorate([e.serialize()],i.prototype,"linkEmissiveWithDiffuse",void 0),__decorate([e.serialize()],i.prototype,"useReflectionFresnelFromSpecular",void 0),__decorate([e.serialize()],i.prototype,"useSpecularOverAlpha",void 0),__decorate([e.serialize()],i.prototype,"useReflectionOverAlpha",void 0),__decorate([e.serialize()],i.prototype,"disableLighting",void 0),__decorate([e.serialize()],i.prototype,"useParallax",void 0),__decorate([e.serialize()],i.prototype,"useParallaxOcclusion",void 0),__decorate([e.serialize()],i.prototype,"parallaxScaleBias",void 0),__decorate([e.serialize()],i.prototype,"roughness",void 0),__decorate([e.serialize()],i.prototype,"indexOfRefraction",void 0),__decorate([e.serialize()],i.prototype,"invertRefractionY",void 0),__decorate([e.serialize()],i.prototype,"useLightmapAsShadowmap",void 0),__decorate([e.serializeAsFresnelParameters()],i.prototype,"diffuseFresnelParameters",void 0),__decorate([e.serializeAsFresnelParameters()],i.prototype,"opacityFresnelParameters",void 0),__decorate([e.serializeAsFresnelParameters()],i.prototype,"reflectionFresnelParameters",void 0),__decorate([e.serializeAsFresnelParameters()],i.prototype,"refractionFresnelParameters",void 0),__decorate([e.serializeAsFresnelParameters()],i.prototype,"emissiveFresnelParameters",void 0),__decorate([e.serialize()],i.prototype,"useGlossinessFromSpecularMapAlpha",void 0),__decorate([e.serialize()],i.prototype,"maxSimultaneousLights",void 0),__decorate([e.serialize()],i.prototype,"invertNormalMapX",void 0),__decorate([e.serialize()],i.prototype,"invertNormalMapY",void 0),__decorate([e.serializeAsTexture()],i.prototype,"cameraColorGradingTexture",void 0),__decorate([e.serializeAsColorCurves()],i.prototype,"cameraColorCurves",void 0),__decorate([e.serialize()],i.prototype,"useLogarithmicDepth",null),e.StandardMaterial=i})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(e,i){var r=t.call(this,e,i,!0)||this;return r.subMaterials=new Array,i.multiMaterials.push(r),r}return __extends(i,t),i.prototype.getSubMaterial=function(e){return e<0||e>=this.subMaterials.length?this.getScene().defaultMaterial:this.subMaterials[e]},i.prototype.getClassName=function(){return"MultiMaterial"},i.prototype.isReady=function(e){for(var t=0;t-1&&o.skeletons){var O=_.indexOf(y.skeletonId)>-1;if(!O)for(var I=0,D=f.skeletons.length;I>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;fp&&(c=p,o=d,n))break}}}if(o){var m=new e.PickingInfo;return m.hit=!0,m.pickedSprite=o,m.distance=c,m}return null},t.prototype.render=function(){if(this._effectBase.isReady()&&this._effectFog.isReady()&&this._spriteTexture&&this._spriteTexture.isReady()){for(var t=this._scene.getEngine(),i=this._spriteTexture.getBaseSize(),r=t.getDeltaTime(),n=Math.min(this._capacity,this.sprites.length),o=i.width/this.cellWidth,s=0,a=0;athis._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._onAnimationEnd&&this._onAnimationEnd(),this.disposeWhenFinishedAnimating&&this.dispose()))))},t.prototype.dispose=function(){for(var e=0;e=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;o-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;r1)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=[{frame:0,value:s},{frame:o,value:a}];return 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=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;t0)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=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: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;sthis._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)}(rthis._keys[this._keys.length-1].frame)&&(r=this._keys[0].frame),(nthis._keys[this._keys.length-1].frame)&&(n=this._keys[this._keys.length-1].frame),r===n&&r++;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 m=this._interpolate(r,0,i.ANIMATIONLOOPMODE_CYCLE),_=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]=_.subtract(m);break;case i.ANIMATIONTYPE_VECTOR3:this._offsetsCache[p]=_.subtract(m);case i.ANIMATIONTYPE_VECTOR2:this._offsetsCache[p]=_.subtract(m);case i.ANIMATIONTYPE_SIZE:this._offsetsCache[p]=_.subtract(m);case i.ANIMATIONTYPE_COLOR3:this._offsetsCache[p]=_.subtract(m)}this._highLimitsCache[p]=_}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[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-1){for(var i=this._animations,r=0,t=i.length-1;t>=0;t--)"string"==typeof e&&i[t].name!=e||(i[t].reset(),i.splice(t,1),r++);i.length==r&&(this._scene._activeAnimatables.splice(t,1),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=.5?.5*(1-this.easeInCore(2*(1-t)))+.5:.5*this.easeInCore(2*t)},e})();t._EASINGMODE_EASEIN=0,t._EASINGMODE_EASEOUT=1,t._EASINGMODE_EASEINOUT=2,e.EasingFunction=t;var i=(function(e){function t(){return e.apply(this,arguments)||this}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);var i=e.call(this)||this;return i.amplitude=t,i}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);var r=e.call(this)||this;return r.bounces=t,r.bounciness=i,r}return __extends(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.bounces),i=this.bounciness;i<=1&&(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(){return e.apply(this,arguments)||this}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);var r=e.call(this)||this;return r.oscillations=t,r.springiness=i,r}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);var i=e.call(this)||this;return i.exponent=t,i}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);var i=e.call(this)||this;return i.power=t,i}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(){return e.apply(this,arguments)||this}return __extends(t,e),t.prototype.easeInCore=function(e){return e*e},t})(t);e.QuadraticEase=c;var l=(function(e){function t(){return e.apply(this,arguments)||this}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(){return e.apply(this,arguments)||this}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(){return e.apply(this,arguments)||this}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);var o=t.call(this)||this;return o.x1=e,o.y1=i,o.x2=r,o.y2=n,o}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){var a=t.call(this,i,r.getScene())||this;return a.name=i,a.children=new Array,a.animations=new Array,a._worldTransform=new e.Matrix,a._absoluteTransform=new e.Matrix,a._invertedAbsoluteTransform=new e.Matrix,a._scaleMatrix=e.Matrix.Identity(),a._scaleVector=new e.Vector3(1,1,1),a._negateScaleChildren=new e.Vector3(1,1,1),a._scalingDeterminant=1,a._syncScaleVector=function(){var t=this.getLocalMatrix(),i=t.m[0]*t.m[0]+t.m[1]*t.m[1]+t.m[2]*t.m[2],r=t.m[4]*t.m[4]+t.m[5]*t.m[5]+t.m[6]*t.m[6],n=t.m[8]*t.m[8]+t.m[9]*t.m[9]+t.m[10]*t.m[10],o=t.m[0]*t.m[1]*t.m[2]*t.m[3]<0?-1:1,s=t.m[4]*t.m[5]*t.m[6]*t.m[7]<0?-1:1,a=t.m[8]*t.m[9]*t.m[10]*t.m[11]<0?-1:1;this._scaleVector.x=o*Math.sqrt(i),this._scaleVector.y=s*Math.sqrt(r),this._scaleVector.z=a*Math.sqrt(n),this._parent&&(this._scaleVector.x/=this._parent._negateScaleChildren.x,this._scaleVector.y/=this._parent._negateScaleChildren.y,this._scaleVector.z/=this._parent._negateScaleChildren.z),e.Matrix.FromValuesToRef(this._scaleVector.x,0,0,0,0,this._scaleVector.y,0,0,0,0,this._scaleVector.z,0,0,0,0,1,this._scaleMatrix)},a._skeleton=r,a._matrix=o,a._baseMatrix=o,a._restPose=s?s:o.clone(),r.bones.push(a),n?(a._parent=n,n.children.push(a)):a._parent=null,a._updateDifferenceMatrix(),a.getAbsoluteTransform().determinant()<0&&(a._scalingDeterminant*=-1),a}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,t){void 0===t&&(t=!0),this._baseMatrix=e.clone(),this._matrix=e.clone(),this._skeleton._markAsDirty(),t&&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=l&&a.frame<=u&&(n?(c=a.value.clone(),_?(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.prototype.translate=function(t,i,r){void 0===i&&(i=e.Space.LOCAL);var n=this.getLocalMatrix();if(i==e.Space.LOCAL)n.m[12]+=t.x,n.m[13]+=t.y,n.m[14]+=t.z;else{this._skeleton.computeAbsoluteTransforms();var o=e.Tmp.Matrix[0],s=e.Tmp.Vector3[0];r?(o.copyFrom(this._parent.getAbsoluteTransform()),o.multiplyToRef(r.getWorldMatrix(),o)):o.copyFrom(this._parent.getAbsoluteTransform()),o.m[12]=0,o.m[13]=0,o.m[14]=0,o.invert(),e.Vector3.TransformCoordinatesToRef(t,o,s),n.m[12]+=s.x,n.m[13]+=s.y,n.m[14]+=s.z}this.markAsDirty()},i.prototype.setPosition=function(t,i,r){void 0===i&&(i=e.Space.LOCAL);var n=this.getLocalMatrix();if(i==e.Space.LOCAL)n.m[12]=t.x,n.m[13]=t.y,n.m[14]=t.z;else{this._skeleton.computeAbsoluteTransforms();var o=e.Tmp.Matrix[0],s=e.Tmp.Vector3[0];r?(o.copyFrom(this._parent.getAbsoluteTransform()),o.multiplyToRef(r.getWorldMatrix(),o)):o.copyFrom(this._parent.getAbsoluteTransform()),o.invert(),e.Vector3.TransformCoordinatesToRef(t,o,s),n.m[12]=s.x,n.m[13]=s.y,n.m[14]=s.z}this.markAsDirty()},i.prototype.setAbsolutePosition=function(t,i){this.setPosition(t,e.Space.WORLD,i)},i.prototype.setScale=function(e,t,i,r){void 0===r&&(r=!1),this.animations[0]&&!this.animations[0].isStopped()&&(r||(this._negateScaleChildren.x=1/e,this._negateScaleChildren.y=1/t,this._negateScaleChildren.z=1/i),this._syncScaleVector()),this.scale(e/this._scaleVector.x,t/this._scaleVector.y,i/this._scaleVector.z,r)},i.prototype.scale=function(t,i,r,n){void 0===n&&(n=!1);var o=this.getLocalMatrix(),s=e.Tmp.Matrix[0];s.copyFrom(o);var a=e.Tmp.Matrix[1];a.copyFrom(s),a.invert();var h=e.Tmp.Matrix[2];e.Matrix.FromValuesToRef(t,0,0,0,0,i,0,0,0,0,r,0,0,0,0,1,h),this._scaleMatrix.multiplyToRef(h,this._scaleMatrix),this._scaleVector.x*=t,this._scaleVector.y*=i,this._scaleVector.z*=r,o.multiplyToRef(a,o),o.multiplyToRef(h,o),o.multiplyToRef(s,o);var c=this.getParent();c?o.multiplyToRef(c.getAbsoluteTransform(),this.getAbsoluteTransform()):this.getAbsoluteTransform().copyFrom(o);var l=this.children.length;h.invert();for(var u=0;u0&&(this._rightHandedSystem=!0,this._bendAxis.x=0,this._bendAxis.y=0,this._bendAxis.z=1),this._bone1.length){var n=this._bone1.getScale(),o=this._bone2.getScale();this._bone1Length=this._bone1.length*n.y*this.mesh.scaling.y,this._bone2Length=this._bone2.length*o.y*this.mesh.scaling.y}else if(this._bone1.children[0]){t.computeWorldMatrix(!0);var s=this._bone2.children[0].getAbsolutePosition(t),a=this._bone2.getAbsolutePosition(t),h=this._bone1.getAbsolutePosition(t);this._bone1Length=e.Vector3.Distance(s,a),this._bone2Length=e.Vector3.Distance(a,h)}this._bone1.getRotationMatrixToRef(e.Space.WORLD,t,this._bone1Mat),this.maxAngle=Math.PI,r&&(r.targetMesh&&(this.targetMesh=r.targetMesh,this.targetMesh.computeWorldMatrix(!0)),r.poleTargetMesh?(this.poleTargetMesh=r.poleTargetMesh,this.poleTargetMesh.computeWorldMatrix(!0)):r.poleTargetBone?this.poleTargetBone=r.poleTargetBone:this._bone1.getParent()&&(this.poleTargetBone=this._bone1.getParent()),r.poleTargetLocalOffset&&this.poleTargetLocalOffset.copyFrom(r.poleTargetLocalOffset),r.poleAngle&&(this.poleAngle=r.poleAngle),r.bendAxis&&this._bendAxis.copyFrom(r.bendAxis),r.maxAngle&&(this.maxAngle=r.maxAngle),r.slerpAmount&&(this.slerpAmount=r.slerpAmount))}return Object.defineProperty(t.prototype,"maxAngle",{get:function(){return this._maxAngle},set:function(e){this._setMaxAngle(e)},enumerable:!0,configurable:!0}),t.prototype._setMaxAngle=function(e){e<0&&(e=0),(e>Math.PI||void 0==e)&&(e=Math.PI),this._maxAngle=e;var t=this._bone1Length,i=this._bone2Length;this._maxReach=Math.sqrt(t*t+i*i-2*t*i*Math.cos(e))},t.prototype.update=function(){var t=this._bone1,i=this.targetPosition,r=this.poleTargetPosition,n=this._tmpMat1,o=this._tmpMat2;this.targetMesh&&i.copyFrom(this.targetMesh.getAbsolutePosition()),this.poleTargetBone?this.poleTargetBone.getAbsolutePositionFromLocalToRef(this.poleTargetLocalOffset,this.mesh,r):this.poleTargetMesh&&e.Vector3.TransformCoordinatesToRef(this.poleTargetLocalOffset,this.poleTargetMesh.getWorldMatrix(),r);var s=this._tmpVec1,a=this._tmpVec2,h=this._tmpVec3,c=this._tmpVec4,l=this._tmpVec5;t.getAbsolutePositionToRef(this.mesh,s),r.subtractToRef(s,l),0==l.x&&0==l.y&&0==l.z?l.y=1:l.normalize(),i.subtractToRef(s,c),c.normalize(),e.Vector3.CrossToRef(c,l,a),a.normalize(),e.Vector3.CrossToRef(c,a,h),h.normalize(),e.Matrix.FromXYZAxesToRef(h,c,a,n);var u=this._bone1Length,f=this._bone2Length,d=e.Vector3.Distance(s,i);this._maxReach>0&&(d=Math.min(this._maxReach,d));var p=(f*f+d*d-u*u)/(2*f*d),m=(d*d+u*u-f*f)/(2*d*u);p>1&&(p=1),m>1&&(m=1),p<-1&&(p=-1),m<-1&&(m=-1);var _=Math.acos(p),g=Math.acos(m),v=-_-g;this._rightHandedSystem?(e.Matrix.RotationYawPitchRollToRef(0,0,.5*Math.PI,o),o.multiplyToRef(n,n),e.Matrix.RotationAxisToRef(this._bendAxis,g,o),o.multiplyToRef(n,n)):(this._tmpVec1.copyFrom(this._bendAxis),this._tmpVec1.x*=-1,e.Matrix.RotationAxisToRef(this._tmpVec1,-g,o),o.multiplyToRef(n,n)),this.poleAngle&&(e.Matrix.RotationAxisToRef(c,this.poleAngle,o),n.multiplyToRef(o,n)),this.slerpAmount<1?(this._slerping||e.Quaternion.FromRotationMatrixToRef(this._bone1Mat,this._bone1Quat),e.Quaternion.FromRotationMatrixToRef(n,this._tmpQuat1),e.Quaternion.SlerpToRef(this._bone1Quat,this._tmpQuat1,this.slerpAmount,this._bone1Quat),v=this._bone2Ang*(1-this.slerpAmount)+v*this.slerpAmount,this._bone1.setRotationQuaternion(this._bone1Quat,e.Space.WORLD,this.mesh),this._slerping=!0):(this._bone1.setRotationMatrix(n,e.Space.WORLD,this.mesh),this._bone1Mat.copyFrom(n),this._slerping=!1),this._bone2.setAxisAngle(this._bendAxis,v,e.Space.LOCAL),this._bone2Ang=v},t})();e.BoneIKController=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(t,i,r,n){this.upAxis=e.Vector3.Up(),this.adjustYaw=0,this.adjustPitch=0,this.adjustRoll=0,this._tmpVec1=e.Vector3.Zero(),this._tmpVec2=e.Vector3.Zero(),this._tmpVec3=e.Vector3.Zero(),this._tmpVec4=e.Vector3.Zero(),this._tmpMat1=e.Matrix.Identity(),this._tmpMat2=e.Matrix.Identity(),this.mesh=t,this.bone=i,this.target=r,n&&(n.adjustYaw&&(this.adjustYaw=n.adjustYaw),n.adjustPitch&&(this.adjustPitch=n.adjustPitch),n.adjustRoll&&(this.adjustRoll=n.adjustRoll))}return t.prototype.update=function(){var t=this.bone,i=this.target,r=this._tmpVec1,n=this._tmpVec2,o=this._tmpVec3,s=this._tmpVec4,a=this._tmpMat1,h=this._tmpMat2;t.getAbsolutePositionToRef(this.mesh,r),i.subtractToRef(r,n),n.normalize(),e.Vector3.CrossToRef(this.upAxis,n,o),o.normalize(),e.Vector3.CrossToRef(n,o,s),s.normalize(),e.Matrix.FromXYZAxesToRef(o,s,n,a),(this.adjustYaw||this.adjustPitch||this.adjustRoll)&&(e.Matrix.RotationYawPitchRollToRef(this.adjustYaw,this.adjustPitch,this.adjustRoll,h),h.multiplyToRef(a,a)),this.bone.setRotationMatrix(a,e.Space.WORLD,this.mesh)},t})();e.BoneLookController=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._lastAbsoluteTransformsUpdateId=-1,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||this.prepare(),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;t-1&&this._meshesWithPoseMatrix.splice(t,1)},t.prototype._computeTransformMatrices=function(e,t){for(var i=0;i0&&(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-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;o0&&(e=this._meshesWithPoseMatrix[0].getPoseMatrix()),e},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;c0){for(var t=0;t0&&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)},t.prototype.directRender=function(e,t){for(var i=this._scene.getEngine(),r=0;r-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})();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,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:e<=0&&(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;ta?a:Math.floor(h);var c,l,u,f,d=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,p=[],m=[],_=[],g=[],v=[],y=[],x=[],b=[],A=[],T=[];if(r.length<2){var E=[],P=[];for(u=0;u0&&(O=M[f].subtract(M[f-1]).length(),I=O+x[l],v[l].push(I),x[l]=I),f++;o&&(f--,p.push(M[0].x,M[0].y,M[0].z),O=M[f].subtract(M[0]).length(),I=O+x[l],v[l].push(I),x[l]=I),A[l]=S+R,T[l]=C,C+=S+R}var D,w,L,B;for(u=0;u1?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;g<=u;g++){for(var v=g/u,y=v*Math.PI*h,x=0;x<=f;x++){var b=x/f,A=b*Math.PI*2*a,T=e.Matrix.RotationZ(-y),E=e.Matrix.RotationY(A),P=e.Vector3.TransformCoordinates(e.Vector3.Up(),T),M=e.Vector3.TransformCoordinates(P,E),S=M.multiply(l),C=M.divide(l).normalize();p.push(S.x,S.y,S.z),m.push(C.x,C.y,C.z),_.push(b,v)}if(g>0)for(var R=p.length/3,O=R-2*(f+1);O+f+21?1:i.arc||1,f=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,d=i.faceUV||new Array(3),p=i.faceColors,m=1!==u&&l?2:0,_=c?h:1,g=2+(1+m)*_;for(r=0;r0&&(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,m=0,_=0;for(_=0;_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;d=r.length?0:i.type||0,u=i.size,f=i.sizeX||u||1,d=i.sizeY||u||1,p=i.sizeZ||u||1,m=i.custom||r[l],_=m.face.length,g=i.faceUV||new Array(_),v=i.faceColors,y=void 0===i.flat||i.flat,x=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,b=[],A=[],T=[],E=[],P=[],M=0,S=0,C=[],R=0,O=0;if(y)for(O=0;O<_;O++)v&&void 0===v[O]&&(v[O]=new e.Color4(1,1,1,1)),g&&void 0===g[O]&&(g[O]=new e.Vector4(0,0,1,1));if(y)for(O=0;O<_;O++){var I=m.face[O].length;for(s=2*Math.PI/I,a=.5*Math.tan(s/2),h=.5,R=0;R1)for(var h=0;hthis.value;case i.IsLesser:return this._effectiveTarget[this._property]-1&&this._scene._actionManagers.splice(e,1)},t.prototype.getScene=function(){return this._scene},t.prototype.hasSpecificTriggers=function(e){for(var t=0;t-1)return!0}return!1},t.prototype.hasSpecificTrigger=function(e){for(var t=0;t=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=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;r0;if(2===i.type?f.push(o):f.push(r),m){for(var _=new Array,g=0;g0){var f=u.properties[0].value,d=null===u.properties[0].targetType?f:n.getMeshByName(f);d._meshId&&(d.mesh=n.getMeshByID(d._meshId)),l={trigger:e.ActionManager[u.name],parameter:d}}else l=e.ActionManager[u.name];for(var p=0;p0&&(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){if(this.delayLoadState!==e.Engine.DELAYLOADSTATE_LOADING){if(this.isReady())return void(i&&i());this.delayLoadState=e.Engine.DELAYLOADSTATE_LOADING,this._queueLoad(t,i)}},t.prototype._queueLoad=function(t,i){var r=this;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;a0){for(var i=0;i0){for(var i=0;i0){for(var i=0;i0){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 m=new Float32Array(t,s.colorsAttrDesc.offset,s.colorsAttrDesc.count);i.setVerticesData(e.VertexBuffer.ColorKind,m,!1,s.colorsAttrDesc.stride)}if(s.matricesIndicesAttrDesc&&s.matricesIndicesAttrDesc.count>0){var _=new Int32Array(t,s.matricesIndicesAttrDesc.offset,s.matricesIndicesAttrDesc.count);i.setVerticesData(e.VertexBuffer.MatricesIndicesKind,_,!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>8),M.push((16711680&S)>>16),M.push(S>>24)}i.setVerticesData(e.VertexBuffer.MatricesIndicesKind,M,!1)}if(t.matricesIndicesExtra)if(t.matricesIndicesExtra._isExpanded)delete t.matricesIndices._isExpanded,i.setVerticesData(e.VertexBuffer.MatricesIndicesExtraKind,t.matricesIndicesExtra,!1);else{for(var M=[],x=0;x>8),M.push((16711680&S)>>16),M.push(S>>24)}i.setVerticesData(e.VertexBuffer.MatricesIndicesExtraKind,M,!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 C=0;Cthis._maxX||tthis._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,!(ethis._maxX||tthis._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=(this._subdivisionsX,this._subdivisionsY,Math.floor((e+this._maxX)*this._subdivisionsX/this._width)),n=Math.floor(-(t+this._maxZ)*this._subdivisionsY/this._height+this._subdivisionsY),o=this._heightQuads[n*this._subdivisionsX+r];return i=t0&&(c=!0,this._soundLoaded(i));break;case"String":h.push(i);case"Array":0===h.length&&(h=i);for(var l=0;l0&&(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.prototype.serialize=function(){var e={name:this.name,url:this.name,autoplay:this.autoplay,loop:this.loop,volume:this._volume,spatialSound:this.spatialSound,maxDistance:this.maxDistance,rolloffFactor:this.rolloffFactor,refDistance:this.refDistance,distanceModel:this.distanceModel,playbackRate:this._playbackRate,panningModel:this._panningModel,soundTrackId:this.soundTrackId};return this.spatialSound&&(this._connectedMesh&&(e.connectedMeshId=this._connectedMesh.id),e.position=this._position.asArray(),e.refDistance=this.refDistance,e.distanceModel=this.distanceModel,e.isDirectional=this._isDirectional,e.localDirectionToMesh=this._localDirection.asArray(),e.coneInnerAngle=this._coneInnerAngle,e.coneOuterAngle=this._coneOuterAngle,e.coneOuterGain=this._coneOuterGain),e},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&&(t.soundTrackId===-1?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);t!==-1&&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;t4&&(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 u=n.join("\n");return this._cachedDefines!==u&&(this._cachedDefines=u,this._glowMapGenerationEffect=this._scene.getEngine().createEffect("glowMapGeneration",o,["world","mBones","viewProjection","diffuseMatrix","color","emissiveMatrix"],["diffuseSampler","emissiveSampler"],u)),this._glowMapGenerationEffect.isReady()},i.prototype.render=function(){var t=this._glowMapMergeEffect;if(t.isReady()&&this._blurTexture.isReady()){var i=this._scene.getEngine();this.onBeforeComposeObservable.notifyObservers(this),i.enableEffect(t),i.setState(!1);var r=i.getStencilBuffer(),n=i.getStencilFunction(),o=i.getStencilMask(),s=i.getAlphaMode();t.setTexture("textureSampler",this._blurTexture),i.bindBuffers(this._vertexBuffers,this._indexBuffer,t),i.setAlphaMode(this._options.alphaBlendingMode),i.setStencilMask(0),i.setStencilBuffer(!0),i.setStencilFunctionReference(this._instanceGlowingMeshStencilReference),this.outerGlow&&(t.setFloat("offset",0),i.setStencilFunction(e.Engine.NOTEQUAL),i.draw(!0,0,6)),this.innerGlow&&(t.setFloat("offset",1),i.setStencilFunction(e.Engine.EQUAL),i.draw(!0,0,6)),i.setStencilFunction(n),i.setStencilMask(o),i.setAlphaMode(s),i.setStencilBuffer(r),this.onAfterComposeObservable.notifyObservers(this);var a=this._mainTexture.getSize();this.setMainTextureSize(),a.width===this._mainTextureDesiredSize.width&&a.height===this._mainTextureDesiredSize.height||(this.onSizeChangedObservable.notifyObservers(this),this.disposeTextureAndPostProcesses(),this.createTextureAndPostProcesses())}},i.prototype.addExcludedMesh=function(e){var t=this._excludedMeshes[e.uniqueId];t||(this._excludedMeshes[e.uniqueId]={mesh:e,beforeRender:e.onBeforeRenderObservable.add((function(e){e.getEngine().setStencilBuffer(!1)})),afterRender:e.onAfterRenderObservable.add((function(e){e.getEngine().setStencilBuffer(!0)}))})},i.prototype.removeExcludedMesh=function(e){var t=this._excludedMeshes[e.uniqueId];t&&(e.onBeforeRenderObservable.remove(t.beforeRender),e.onAfterRenderObservable.remove(t.afterRender)),this._excludedMeshes[e.uniqueId]=void 0},i.prototype.addMesh=function(e,t,i){var r=this;void 0===i&&(i=!1);var n=this._meshes[e.uniqueId];n?n.color=t:this._meshes[e.uniqueId]={mesh:e,color:t,observerHighlight:e.onBeforeRenderObservable.add((function(e){r._excludedMeshes[e.uniqueId]?r.defaultStencilReference(e):e.getScene().getEngine().setStencilFunctionReference(r._instanceGlowingMeshStencilReference)})),observerDefault:e.onAfterRenderObservable.add(this.defaultStencilReference),glowEmissiveOnly:i},this._shouldRender=!0},i.prototype.removeMesh=function(e){var t=this._meshes[e.uniqueId];t&&(e.onBeforeRenderObservable.remove(t.observerHighlight),e.onAfterRenderObservable.remove(t.observerDefault)),this._meshes[e.uniqueId]=void 0,this._shouldRender=!1;for(var i in this._meshes)if(i){this._shouldRender=!0;break}},i.prototype.shouldRender=function(){return this.isEnabled&&this._shouldRender},i.prototype.setMainTextureSize=function(){this._options.mainTextureFixedSize?(this._mainTextureDesiredSize.width=this._options.mainTextureFixedSize,this._mainTextureDesiredSize.height=this._options.mainTextureFixedSize):(this._mainTextureDesiredSize.width=this._engine.getRenderingCanvas().width*this._options.mainTextureRatio,this._mainTextureDesiredSize.height=this._engine.getRenderingCanvas().height*this._options.mainTextureRatio,this._mainTextureDesiredSize.width=e.Tools.GetExponentOfTwo(this._mainTextureDesiredSize.width,this._maxSize),this._mainTextureDesiredSize.height=e.Tools.GetExponentOfTwo(this._mainTextureDesiredSize.height,this._maxSize))},i.prototype.defaultStencilReference=function(e){e.getScene().getEngine().setStencilFunctionReference(i.normalMeshStencilReference)},i.prototype.disposeTextureAndPostProcesses=function(){this._blurTexture.dispose(),this._mainTexture.dispose(),this._downSamplePostprocess.dispose(),this._horizontalBlurPostprocess.dispose(),this._verticalBlurPostprocess.dispose()},i.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.disposeTextureAndPostProcesses();for(var i in this._meshes){var r=this._meshes[i];r&&r.mesh&&(r.mesh.onBeforeRenderObservable.remove(r.observerHighlight),r.mesh.onAfterRenderObservable.remove(r.observerDefault))}this._meshes=null;for(var i in this._excludedMeshes){var r=this._excludedMeshes[i];r&&(r.mesh.onBeforeRenderObservable.remove(r.beforeRender),r.mesh.onAfterRenderObservable.remove(r.afterRender))}this._excludedMeshes=null;var n=this._scene.highlightLayers.indexOf(this,0);n>-1&&this._scene.highlightLayers.splice(n,1),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this.onBeforeRenderMainTextureObservable.clear(),this.onBeforeBlurObservable.clear(),this.onBeforeComposeObservable.clear(),this.onAfterComposeObservable.clear(),this.onSizeChangedObservable.clear()},i})();i.neutralColor=new e.Color4(0,0,0,0),i.glowingMeshStencilReference=2,i.normalMeshStencilReference=1,e.HighlightLayer=i})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(){}return e.TransformCoordinatesToRefSIMD=function(t,i,r){e.TransformCoordinatesFromFloatsToRefSIMD(t.x,t.y,t.z,i,r)},e.TransformCoordinatesFromFloatsToRefSIMD=function(e,t,i,r,n){var o=r.m,s=SIMD.Float32x4.load(o,0),a=SIMD.Float32x4.load(o,4),h=SIMD.Float32x4.load(o,8),c=SIMD.Float32x4.load(o,12),l=SIMD.Float32x4.add(SIMD.Float32x4.add(SIMD.Float32x4.mul(SIMD.Float32x4.splat(e),s),SIMD.Float32x4.mul(SIMD.Float32x4.splat(t),a)),SIMD.Float32x4.add(SIMD.Float32x4.mul(SIMD.Float32x4.splat(i),h),c));l=SIMD.Float32x4.div(l,SIMD.Float32x4.swizzle(l,3,3,3,3)),n.x=SIMD.Float32x4.extractLane(l,0),n.y=SIMD.Float32x4.extractLane(l,1),n.z=SIMD.Float32x4.extractLane(l,2)},e})(),i=(function(){function e(){}return e.prototype.multiplyToArraySIMD=function(e,t,i){for(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=0;c<16;c+=4)SIMD.Float32x4.store(t,c+i,SIMD.Float32x4.add(SIMD.Float32x4.mul(SIMD.Float32x4.splat(r[c]),o),SIMD.Float32x4.add(SIMD.Float32x4.mul(SIMD.Float32x4.splat(r[c+1]),s),SIMD.Float32x4.add(SIMD.Float32x4.mul(SIMD.Float32x4.splat(r[c+2]),a),SIMD.Float32x4.mul(SIMD.Float32x4.splat(r[c+3]),h)))));return this},e.prototype.invertToRefSIMD=function(e){var t=this.m,i=e.m,r=SIMD.Float32x4.load(t,0),n=SIMD.Float32x4.load(t,4),o=SIMD.Float32x4.load(t,8),s=SIMD.Float32x4.load(t,12),a=SIMD.Float32x4.shuffle(r,n,0,1,4,5),h=SIMD.Float32x4.shuffle(o,s,0,1,4,5),c=SIMD.Float32x4.shuffle(a,h,0,2,4,6);h=SIMD.Float32x4.shuffle(h,a,1,3,5,7),a=SIMD.Float32x4.shuffle(r,n,2,3,6,7);var l=SIMD.Float32x4.shuffle(o,s,2,3,6,7),u=SIMD.Float32x4.shuffle(a,l,0,2,4,6);l=SIMD.Float32x4.shuffle(l,a,1,3,5,7),a=SIMD.Float32x4.mul(u,l),a=SIMD.Float32x4.swizzle(a,1,0,3,2);var f=SIMD.Float32x4.mul(h,a),d=SIMD.Float32x4.mul(c,a);a=SIMD.Float32x4.swizzle(a,2,3,0,1),f=SIMD.Float32x4.sub(SIMD.Float32x4.mul(h,a),f),d=SIMD.Float32x4.sub(SIMD.Float32x4.mul(c,a),d),d=SIMD.Float32x4.swizzle(d,2,3,0,1),a=SIMD.Float32x4.mul(h,u),a=SIMD.Float32x4.swizzle(a,1,0,3,2),f=SIMD.Float32x4.add(SIMD.Float32x4.mul(l,a),f);var p=SIMD.Float32x4.mul(c,a);a=SIMD.Float32x4.swizzle(a,2,3,0,1),f=SIMD.Float32x4.sub(f,SIMD.Float32x4.mul(l,a)),p=SIMD.Float32x4.sub(SIMD.Float32x4.mul(c,a),p),p=SIMD.Float32x4.swizzle(p,2,3,0,1),a=SIMD.Float32x4.mul(SIMD.Float32x4.swizzle(h,2,3,0,1),l),a=SIMD.Float32x4.swizzle(a,1,0,3,2),u=SIMD.Float32x4.swizzle(u,2,3,0,1),f=SIMD.Float32x4.add(SIMD.Float32x4.mul(u,a),f);var m=SIMD.Float32x4.mul(c,a);a=SIMD.Float32x4.swizzle(a,2,3,0,1),f=SIMD.Float32x4.sub(f,SIMD.Float32x4.mul(u,a)),m=SIMD.Float32x4.sub(SIMD.Float32x4.mul(c,a),m),m=SIMD.Float32x4.swizzle(m,2,3,0,1),a=SIMD.Float32x4.mul(c,h),a=SIMD.Float32x4.swizzle(a,1,0,3,2),m=SIMD.Float32x4.add(SIMD.Float32x4.mul(l,a),m),p=SIMD.Float32x4.sub(SIMD.Float32x4.mul(u,a),p),a=SIMD.Float32x4.swizzle(a,2,3,0,1),m=SIMD.Float32x4.sub(SIMD.Float32x4.mul(l,a),m),p=SIMD.Float32x4.sub(p,SIMD.Float32x4.mul(u,a)),a=SIMD.Float32x4.mul(c,l),a=SIMD.Float32x4.swizzle(a,1,0,3,2),d=SIMD.Float32x4.sub(d,SIMD.Float32x4.mul(u,a)),m=SIMD.Float32x4.add(SIMD.Float32x4.mul(h,a),m),a=SIMD.Float32x4.swizzle(a,2,3,0,1),d=SIMD.Float32x4.add(SIMD.Float32x4.mul(u,a),d),m=SIMD.Float32x4.sub(m,SIMD.Float32x4.mul(h,a)),a=SIMD.Float32x4.mul(c,u),a=SIMD.Float32x4.swizzle(a,1,0,3,2),d=SIMD.Float32x4.add(SIMD.Float32x4.mul(l,a),d),p=SIMD.Float32x4.sub(p,SIMD.Float32x4.mul(h,a)),a=SIMD.Float32x4.swizzle(a,2,3,0,1),d=SIMD.Float32x4.sub(d,SIMD.Float32x4.mul(l,a)),p=SIMD.Float32x4.add(SIMD.Float32x4.mul(h,a),p);var _=SIMD.Float32x4.mul(c,f);return _=SIMD.Float32x4.add(SIMD.Float32x4.swizzle(_,2,3,0,1),_),_=SIMD.Float32x4.add(SIMD.Float32x4.swizzle(_,1,0,3,2),_),a=SIMD.Float32x4.reciprocalApproximation(_),_=SIMD.Float32x4.sub(SIMD.Float32x4.add(a,a),SIMD.Float32x4.mul(_,SIMD.Float32x4.mul(a,a))),_=SIMD.Float32x4.swizzle(_,0,0,0,0),SIMD.Float32x4.store(i,0,SIMD.Float32x4.mul(_,f)),SIMD.Float32x4.store(i,4,SIMD.Float32x4.mul(_,d)),SIMD.Float32x4.store(i,8,m=SIMD.Float32x4.mul(_,m)),SIMD.Float32x4.store(i,12,SIMD.Float32x4.mul(_,p)),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),m=SIMD.Float32x4.shuffle(d,p,0,2,4,6),_=SIMD.Float32x4.shuffle(d,p,1,3,5,7),g=SIMD.Float32x4.shuffle(SIMD.Float32x4.shuffle(l,u,2,3,6,7),SIMD.Float32x4.shuffle(h,f,2,3,6,7),0,2,4,6),v=SIMD.Float32x4(0,0,0,1),y=SIMD.Float32x4(1,0,0,0);SIMD.Float32x4.store(n,0,SIMD.Float32x4.add(SIMD.Float32x4.mul(SIMD.Float32x4.swizzle(y,0,0,0,0),m),SIMD.Float32x4.add(SIMD.Float32x4.mul(SIMD.Float32x4.swizzle(y,1,1,1,1),_),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))))),y=SIMD.Float32x4(0,1,0,0),SIMD.Float32x4.store(n,4,SIMD.Float32x4.add(SIMD.Float32x4.mul(SIMD.Float32x4.swizzle(y,0,0,0,0),m),SIMD.Float32x4.add(SIMD.Float32x4.mul(SIMD.Float32x4.swizzle(y,1,1,1,1),_),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))))),y=SIMD.Float32x4(0,0,1,0),SIMD.Float32x4.store(n,8,SIMD.Float32x4.add(SIMD.Float32x4.mul(SIMD.Float32x4.swizzle(y,0,0,0,0),m),SIMD.Float32x4.add(SIMD.Float32x4.mul(SIMD.Float32x4.swizzle(y,1,1,1,1),_),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))))),y=SIMD.Float32x4.replaceLane(SIMD.Float32x4.neg(s),3,1),SIMD.Float32x4.store(n,12,SIMD.Float32x4.add(SIMD.Float32x4.mul(SIMD.Float32x4.swizzle(y,0,0,0,0),m),SIMD.Float32x4.add(SIMD.Float32x4.mul(SIMD.Float32x4.swizzle(y,1,1,1,1),_),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)))))},e})(),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!==self.SIMD&&(self.Math.fround||(self.Math.fround=(function(e){return function(t){return e[0]=t,e[0]}})(new Float32Array(1))),self.Math.imul||(self.Math.imul=function(e,t){var i=e>>>16&65535,r=65535&e,n=t>>>16&65535,o=65535&t;return r*o+(i*o+r*n<<16>>>0)|0}),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,h._isEnabled=!0)},h})();h._isEnabled=!1,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,this._contentSize=null,this._bottomNode=null,this._leftNode=null,this._initialSize=null,this._rightNode=null}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(){return this.getUVsForCustomSize(this._root._size)},enumerable:!0,configurable:!0}),t.prototype.getUVsForCustomSize=function(t){var i=this._root._size.width,r=this._root._size.height,n=new e.Vector2(this._pos.x/i,this._pos.y/r),o=new e.Vector2((this._pos.x+t.width-1)/i,(this._pos.y+t.height-1)/r),s=new Array;return s.push(n),s.push(new e.Vector2(o.x,n.y)),s.push(o),s.push(new e.Vector2(n.x,o.y)),s},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;if(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));else if(this._initialSize){if(!(e.width<=this._initialSize.width&&e.height<=this._initialSize.height))return null;t=this}else e.width<=this._size.width&&e.height<=this._size.height&&(t=this);return t},t.prototype.splitNode=function(i){return!this._contentSize&&this._initialSize?(this._contentSize=i.clone(),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){var r=t.call(this,null,null,e.Vector2.Zero(),i)||this;return r._root=r,r}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;r0?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=h);l++){var u=n[l],f=u.offset,d=f-c;if(d!==i){for(var p=d/i-1,m=f-i,_=Math.min(a,p),g=0;g<_;g++){var v=s/i,y=m/i,x=o[y];this._moveElement(x,s);var b=o[v];b.offset=m,o[v]=x,o[y]=b,m-=i,s+=i}a<=p?(s=m+i,a=1+_):a=(f-s)/i+1,c=f}else++a,c=f}var A=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,A},e.prototype._moveElement=function(e,t){for(var i=0;io.width&&(this._currentFreePosition.x=0,this._currentFreePosition.y+=this._lineHeightSuper+this._yMargin,this._currentFreePosition.y>o.height))return this.getChar("!");if(this._signedDistanceField){this._sdfContext.clearRect(0,0,this._sdfCanvas.width,this._sdfCanvas.height),this._sdfContext.fillText(i,0,-this._offset);var a=this._sdfContext.getImageData(0,0,s*this._sdfScale,this._sdfCanvas.height),h=this._computeSDFChar(a);this._context.putImageData(h,this._currentFreePosition.x,this._currentFreePosition.y)}else this._context.fillText(i,this._currentFreePosition.x,this._currentFreePosition.y-this._offset);if(r.topLeftUV=new e.Vector2(this._currentFreePosition.x/o.width,this._currentFreePosition.y/o.height),r.bottomRightUV=new e.Vector2((this._currentFreePosition.x+s)/o.width,r.topLeftUV.y+(this._lineHeightSuper+2)/o.height),this._signedDistanceField){var c=1/o.width;r.topLeftUV.addInPlace(new e.Vector2(c,c)),r.bottomRightUV.addInPlace(new e.Vector2(c,c))}return r.charWidth=this._superSample?s/2:s,this._charInfos[i]=r,this._curCharCount++,this._currentFreePosition.x+=s+this._xMargin,r},r.prototype._computeSDFChar=function(e){for(var t=this._sdfScale,i=e.width,r=e.height,n=i/t,o=r/t,s=0,a=0,h=t,c=h-1,l=function(n,o,h,c,l){var u=n*t,f=o*t;if(u+h<0||u+h>=i||f+c<0||f+c>=r)return!0;var d=e.data[4*((f+c)*i+(u+h))],p=d>0===l;return p||(s=h,a=c),p},u=function(e,t,i){if(l(e,t,0,c,i)&&l(e,t,0,-c,i)&&l(e,t,-c,0,i)&&l(e,t,c,0,i))return 0;for(var r=1;r<=h;r++){if(!(l(e,t,0,r,i)&&l(e,t,0,-r,i)&&l(e,t,-r,0,i)&&l(e,t,r,0,i)))return r*r;for(var n=1;n<=r;n++)if(!(l(e,t,-n,r,i)&&l(e,t,n,r,i)&&l(e,t,r,-n,i)&&l(e,t,r,n,i)&&l(e,t,-n,-r,i)&&l(e,t,n,-r,i)&&l(e,t,-r,-n,i)&&l(e,t,-r,n,i))){var o=r*r+n*n,u=1;return l(e,t,s-1,a,i)||(o+=(s-1)*(s-1)+a*a,++u),l(e,t,s+1,a,i)||(o+=(s+1)*(s+1)+a*a,++u),l(e,t,s,a-1,i)||(o+=s*s+(a-1)*(a-1),++u),l(e,t,s,a+1,i)||(o+=s*s+(a+1)*(a+1),++u),l(e,t,s-1,a-1,i)||(o+=(s-1)*(s-1)+(a-1)*(a-1),++u),l(e,t,s+1,a+1,i)||(o+=(s+1)*(s+1)+(a+1)*(a+1),++u),l(e,t,s+1,a-1,i)||(o+=(s+1)*(s+1)+(a-1)*(a-1),++u),l(e,t,s-1,a+1,i)||(o+=(s-1)*(s-1)+(a+1)*(a+1),++u),o/u}}return 0},f=new Array(n*o),d=0;d255&&(_=255),_+=.5,g.data[4*y+0]=_,g.data[4*y+1]=_,g.data[4*y+2]=_,g.data[4*y+3]=255}return g},r.prototype.measureText=function(t,i){void 0===i&&(i=4);for(var r=0,n=0,o=1,s=0,a=0,h=t;a>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,m=1,_=2,g=3,v=4,y=7,x=20,b=21,A=22,T=28,E=(function(){function t(){}return t.GetDDSInfo=function(e){var t=new Int32Array(e,0,d),i=1;return t[_]&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[T]&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;c=0;h--)for(var c=0;c=0;h--)for(var c=0;ct.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;rh||r.deleted||r.isDirty))for(var o=0;o<3;++o)if(r.error[o]>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();for(var n=0;n<3;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;r<3;++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;i0&&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,_,d,m,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.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;o80*r){l=f=e[0],u=d=e[1];for(var g=r;gf&&(f=p),m>d&&(d=m);_=Math.max(f-l,d-u)}return n(a,h,r,l,u,_,void 0),h}function i(e,t,i,r,n){var o,s;if(n===O(e,t,i,r)>0)for(o=t;o=t;o-=r)s=M(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,m=e.next,u?s(e,c,l,u):o(e))t.push(p.i/i),t.push(e.i/i),t.push(m.i/i),S(e),e=m.next,_=m.next;else if(e=m,e===_){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.xo.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=m(a,h,t,i,r),f=m(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)&&T(n,o)&&T(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=P(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;s=r.next.y){var a=r.x+(o-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(a<=n&&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.x&&r.x>=l&&g(oi.x)&&T(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=m(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;t0||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 m(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 _(e){var t=e,i=e;do t.x=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&&!A(e,t)&&T(e,t)&&T(t,e)&&E(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))||y(e,t,i)>0!=y(e,t,r)>0&&y(i,r,e)>0!=y(i,r,t)>0}function A(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 T(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 E(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 P(e,t){var i=new C(e.i,e.x,e.y),r=new C(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 M(e,t,i,r){var n=new C(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 C(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 R(e,t,i,r){var n=t&&t.length,o=n?t[0]*i:e.length,s=Math.abs(O(e,0,o,i));if(n)for(var a=0,h=t.length;a0&&(r+=e[n-1].length,i.holes.push(r))}return i}e.earcut=t,e.deviation=R,e.flatten=I})(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,m=[];for(h=0;ht.EPSILON?u:l;p|=_,m.push(_)}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=3&&(P=new n(g,i.shared),P.plane&&s.push(P)),v.length>=3&&(P=new n(v,i.shared),P.plane&&a.push(P))}},t})();r.EPSILON=1e-5;var 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;ei.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));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,r){r.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(r.prevX-43,r.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(r.x,r.y,40,0,2*Math.PI,!0),i.vjCanvasContext.stroke(),i.vjCanvasContext.closePath(),r.prevX=r.x,r.prevY=r.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})();i._globalJoystickIndex=0,e.VirtualJoystick=i})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(e){function t(t,i,r){var n=e.call(this,t,i,r)||this;return n.inputs.addVirtualJoystick(),n}return __extends(t,e),t.prototype.getClassName=function(){return"VirtualJoysticksCamera"},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=e.call(this,t,"anaglyph",null,["leftSampler"],i,r[1],n,o,s)||this;return a._passedProcess=r[0]._rigPostProcess,a.onApplyObservable.add((function(e){e.setTextureFromPostProcess("leftSampler",a._passedProcess)})),a}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 t(e,t){this.name=e,this.url=t,this.isCompleted=!1}return t.prototype.run=function(t,i,r){var n=this,o=new Image;e.Tools.SetCorsBehavior(this.url,o),o.onload=function(){n.image=o,n.isCompleted=!0,n.onSuccess&&n.onSuccess(n),i()},o.onerror=function(){n.onError&&n.onError(n),r()},o.src=this.url},t})();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 t(e,t,i,r,n){this.name=e,this.url=t,this.extensions=i,this.noMipmap=r,this.files=n,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.CubeTexture(this.url,t,this.extensions,this.noMipmap,this.files,o,s)},t})();e.CubeTextureAssetTask=s;var a=(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;e0){if(a._vrEnabled=!0,a.webVROptions.displayName){var i=t.some((function(e){return e.displayName===a.webVROptions.displayName&&(a._vrDevice=e,!0)}));i||(a._vrDevice=t[0],e.Tools.Warn("Display "+a.webVROptions.displayName+" was not found. Using "+a._vrDevice.displayName))}else a._vrDevice=t[0];a.setCameraRigMode(e.Camera.RIG_MODE_WEBVR,{vrDisplay:a._vrDevice,frameData:a._frameData}),a._attached&&a.getEngine().enableVR(a._vrDevice)}else e.Tools.Error("No WebVR devices found!")}))):e.Tools.Error("WebVR is not enabled on your browser"),a.rotationQuaternion=new e.Quaternion,a._quaternionCache=new e.Quaternion,a}return __extends(i,t),i.prototype._checkInputs=function(){if(this._vrEnabled&&this._vrDevice.getFrameData(this._frameData)){var e=this._frameData.pose;e&&e.orientation&&(this._cacheState=e,this.rotationQuaternion.copyFromFloats(this._cacheState.orientation[0],this._cacheState.orientation[1],-this._cacheState.orientation[2],-this._cacheState.orientation[3]),this.webVROptions.trackPosition&&this._cacheState.position&&(this.position.copyFromFloats(this._cacheState.position[0],this._cacheState.position[1],-this._cacheState.position[2]),this.webVROptions.positionScale&&this.position.scaleInPlace(this.webVROptions.positionScale),this.position.addInPlace(this._positionOffset)))}t.prototype._checkInputs.call(this)},i.prototype.attachControl=function(i,r){t.prototype.attachControl.call(this,i,r), +this._attached=!0,r=!e.Camera.ForceAttachControlToAlwaysPreventDefault&&r,this._vrEnabled&&this.getEngine().enableVR(this._vrDevice)},i.prototype.detachControl=function(e){t.prototype.detachControl.call(this,e),this._vrEnabled=!1,this._attached=!1,this.getEngine().disableVR()},i.prototype.requestVRFullscreen=function(t){e.Tools.Warn("requestVRFullscreen is deprecated. call attachControl() to start sending frames to the VR display.")},i.prototype.getClassName=function(){return"WebVRFreeCamera"},i.prototype.resetToCurrentRotation=function(){this._vrDevice.resetPose()},i.prototype.setPositionOffset=function(e){e?this._positionOffset=e:this._positionOffset.copyFrom(this.position)},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){void 0===t&&(t=0),void 0===i&&(i=1024);var r=e.call(this,t)||this;return r.priority=t,r.maximumSize=i,r.apply=function(e){for(var t=!0,i=0;ir.maximumSize&&(n.scale(.5),t=!1)}}return t},r}return __extends(t,e),t})(t);e.TextureOptimization=i;var r=(function(e){function t(t,i){void 0===t&&(t=0),void 0===i&&(i=2);var r=e.call(this,t)||this;return r.priority=t,r.maximumScale=i,r._currentScale=1,r.apply=function(e){return r._currentScale++,e.getEngine().setHardwareScalingLevel(r._currentScale),r._currentScale>=r.maximumScale},r}return __extends(t,e),t})(t);e.HardwareScalingOptimization=r;var n=(function(e){function t(){var t=e.apply(this,arguments)||this;return t.apply=function(e){return e.shadowsEnabled=!1,!0},t}return __extends(t,e),t})(t);e.ShadowsOptimization=n;var o=(function(e){function t(){var t=e.apply(this,arguments)||this;return t.apply=function(e){return e.postProcessesEnabled=!1,!0},t}return __extends(t,e),t})(t);e.PostProcessesOptimization=o;var s=(function(e){function t(){var t=e.apply(this,arguments)||this;return t.apply=function(e){return e.lensFlaresEnabled=!1,!0},t}return __extends(t,e),t})(t);e.LensFlaresOptimization=s;var a=(function(e){function t(){var t=e.apply(this,arguments)||this;return t.apply=function(e){return e.particlesEnabled=!1,!0},t}return __extends(t,e),t})(t);e.ParticlesOptimization=a;var h=(function(e){function t(){var t=e.apply(this,arguments)||this;return t.apply=function(e){return e.renderTargetsEnabled=!1,!0},t}return __extends(t,e),t})(t);e.RenderTargetsOptimization=h;var c=(function(t){function i(){var r=t.apply(this,arguments)||this;return r._canBeMerged=function(t){if(!(t instanceof e.Mesh))return!1;var i=t;return!(!i.isVisible||!i.isEnabled())&&(!(i.instances.length>0)&&(!i.skeleton&&!i.hasLODLevels&&!i.parent))},r.apply=function(t,n){for(var o=t.meshes.slice(0),s=o.length,a=0;a=i.targetFrameRate)return void(n&&n());for(var s=!0,a=!0,h=0;hi.x&&(i.x=e.x),e.yi.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;h0){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;us.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),m=new e.Vector3(f.x,0,f.y),_=m.subtract(p),g=new e.Vector3(0,1,0),v=e.Vector3.Cross(_,g);v=v.normalize(),r.push(l/o.width,0),r.push(l/o.width,1),l+=_.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;tthis.capacity&&this._depth0&&(t.x-=this.viewportBorder,t.y-=this.viewportBorder,t.width+=2*this.viewportBorder,t.height+=2*this.viewportBorder,i.x+=this.viewportBorder,i.y+=this.viewportBorder,this._positionX+=this.viewportBorder,this._positionY+=this.viewportBorder),i.z>0&&(this._positionX>t.x&&this._positionXt.y&&this._positionYr},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._positionXr.x+r.width-this.borderLimit?this._positionX-r.x-r.width+this.borderLimit:0,o=this._positionYr.y+r.height-this.borderLimit?this._positionY-r.y-r.height+this.borderLimit:0;var s=n>o?n:o;s-=this.viewportBorder,s>this.borderLimit&&(s=this.borderLimit);var a=1-s/this.borderLimit;if(a<0)return!1;a>1&&(a=1),this.viewportBorder>0&&(r.x+=this.viewportBorder,r.y+=this.viewportBorder,r.width-=2*this.viewportBorder,r.height-=2*this.viewportBorder,this._positionX-=this.viewportBorder,this._positionY-=this.viewportBorder);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.bindBuffers(this._vertexBuffers,this._indexBuffer,this._effect);for(var f=0;f=2&&(this._leftStick={x:this.browserGamepad.axes[this._leftStickAxisX],y:this.browserGamepad.axes[this._leftStickAxisY]}),this.browserGamepad.axes.length>=4&&(this._rightStick={x:this.browserGamepad.axes[this._rightStickAxisX],y:this.browserGamepad.axes[this._rightStickAxisY]})}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[this._leftStickAxisX],y:this.browserGamepad.axes[this._leftStickAxisY]}),this._rightStick&&(this.rightStick={x:this.browserGamepad.axes[this._rightStickAxisX],y:this.browserGamepad.axes[this._rightStickAxisY]})},e})();e.Gamepad=r;var n=(function(e){function t(t,i,r){var n=e.call(this,t,i,r)||this;return n.id=t,n.index=i,n.gamepad=r,n._buttons=new Array(r.buttons.length),n}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;t4&&(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=t.call(this,r.getEngine(),i)||this;s.SSAOOriginalSceneColorEffect="SSAOOriginalSceneColorEffect",s.SSAORenderEffect="SSAORenderEffect",s.SSAOBlurHRenderEffect="SSAOBlurHRenderEffect",s.SSAOBlurVRenderEffect="SSAOBlurVRenderEffect",s.SSAOCombineRenderEffect="SSAOCombineRenderEffect",s.totalStrength=1,s.radius=1e-4,s.area=.0075,s.fallOff=1e-6,s.base=.5,s._firstUpdate=!0,s._scene=r,s._createRandomTexture(),s._depthTexture=r.enableDepthRenderer().getDepthMap();var a=n.ssaoRatio||n,h=n.combineRatio||n;return s._ratio={ssaoRatio:a,combineRatio:h},s._originalColorPostProcess=new e.PassPostProcess("SSAOOriginalSceneColor",h,null,e.Texture.BILINEAR_SAMPLINGMODE,r.getEngine(),(!1)),s._createSSAOPostProcess(a),s._createBlurPostProcess(a),s._createSSAOCombinePostProcess(h),s.addEffect(new e.PostProcessRenderEffect(r.getEngine(),s.SSAOOriginalSceneColorEffect,function(){return s._originalColorPostProcess},(!0))),s.addEffect(new e.PostProcessRenderEffect(r.getEngine(),s.SSAORenderEffect,function(){return s._ssaoPostProcess},(!0))),s.addEffect(new e.PostProcessRenderEffect(r.getEngine(),s.SSAOBlurHRenderEffect,function(){return s._blurHPostProcess},(!0))),s.addEffect(new e.PostProcessRenderEffect(r.getEngine(),s.SSAOBlurVRenderEffect,function(){return s._blurVPostProcess},(!0))),s.addEffect(new e.PostProcessRenderEffect(r.getEngine(),s.SSAOCombineRenderEffect,function(){return s._ssaoCombinePostProcess},(!0))),r.postProcessRenderPipelineManager.addPipeline(s),o&&r.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(i,o),s}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;t0&&this.excludedMeshes.indexOf(e)!==-1},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;ot._alphaIndex?1:e._alphaIndext._distanceToCamera?-1:0})),a.setAlphaMode(e.Engine.ALPHA_COMBINE),o=0;o=0;l--)c(l);return h.addEffect(new e.PostProcessRenderEffect(n.getEngine(),"HDR",function(){return h._hdrPostProcess},(!0))),n.postProcessRenderPipelineManager.addPipeline(h),null!==a&&n.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(r,a),h.update(),h}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._hdrCurrentLuminancer._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;i<2;i++)for(var o=-2;o<2;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;r<2;r++)for(var n=-1;n<2;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 m=Math.pow(3,p);d={width:m,height:m};var _="#define DOWN_SAMPLE\n";0===p&&(_+="#define FINAL_DOWN_SAMPLE\n"),this._downSamplePostProcesses[p]=new e.PostProcess("hdr","hdr",["dsOffsets","halfDestPixelSize"],[],d,null,e.Texture.NEAREST_SAMPLINGMODE,t.getEngine(),(!1),_,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;r<9;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;t<9;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})(e.PostProcessRenderPipeline);t.LUM_STEPS=6,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=af?f:n,r=Math.round(f/n),o=0):r=r>f?f:r;for(var d=[],p=[],m=[],_=[],g=e.Tmp.Vector3[0],v=r;uf-r&&(r=f-u),d.length=0,p.length=0,m.length=0,_.length=0;for(var y=0,x=3*u;x<3*(u+r);x++){p.push(y);var b=a[x];d.push(s[3*b],s[3*b+1],s[3*b+2]),h&&m.push(h[2*b],h[2*b+1]),c&&_.push(c[4*b],c[4*b+1],c[4*b+2],c[4*b+3]),y++}var A,T=this.nbParticles,E=this._posToShape(d),P=this._uvsToShapeUV(m);for(A=0;Athis.nbParticles-1?this.nbParticles-1:i;for(var u=t;u<=i;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.billboard)&&(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;lthis._maximum.x&&(this._maximum.x=this._positions32[n]),this._positions32[n+1]this._maximum.y&&(this._maximum.y=this._positions32[n+1]),this._positions32[n+2]this._maximum.z&&(this._maximum.z=this._positions32[n+2])),this._computeParticleVertex||(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;lMath.PI;)n-=2*Math.PI;var s=n/Math.PI,a=o/Math.PI;s=.5*s+.5;var h=Math.round(s*i);h<0?h=0:h>=i&&(h=i-1);var c=Math.round(a*r);c<0?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}},e})();i.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))],i.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)],i.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)],i.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))],i.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)],i.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.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):t<-1074?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;n32767)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),m=new ArrayBuffer(t.width*t.height*4*3),_=new Float32Array(m);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;f<4;f++)for(u=(f+1)*h;l128){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;gthis.max.y||this.min.y>this.max.y||this.min.z>this.max.y},t})();i.MAX=Number.MAX_VALUE,i.MIN=Number.MIN_VALUE;var r=(function(){function e(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 e.prototype.filterCubeMap=function(){return this.init(),this.filterCubeMapMipChain(),this._outputSurface},e.prototype.init=function(){var t,i,r;for(0==this.maxNumMipLevels&&(this.maxNumMipLevels=e.CP_MAX_MIPLEVELS),r=this.outputSize,i=0;i>=1,this._numMipLevels++,0==r)return void(this.maxNumMipLevels=i)}},e.prototype.filterCubeMapMipChain=function(){var e=this.specularPower;this.precomputeFilterLookupTables(this.inputSize);for(var t=0;t>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}},e.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},e.prototype.precomputeFilterLookupTables=function(e){this._normCubeMap=[],this.buildNormalizerSolidAngleCubemap(e)},e.prototype.buildNormalizerSolidAngleCubemap=function(e){var t,i,r;for(t=0;t<6;t++){this._normCubeMap.push(new Float32Array(e*e*4));this.input[t];for(r=0;r1){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=e._sgFace2DMapping[t][e.CP_UDIR];e._vectorTemp.x=c[0]*s,e._vectorTemp.y=c[1]*s,e._vectorTemp.z=c[2]*s;var l=e._sgFace2DMapping[t][e.CP_VDIR];e._vectorTemp.x+=l[0]*a,e._vectorTemp.y+=l[1]*a,e._vectorTemp.z+=l[2]*a;var u=e._sgFace2DMapping[t][e.CP_FACEAXIS];return e._vectorTemp.x+=u[0],e._vectorTemp.y+=u[1],e._vectorTemp.z+=u[2],e._vectorTemp.normalize(),e._vectorTemp},e.prototype.vectToTexelCoord=function(t,i,r,n){var o,s,a=Math.abs(t),h=Math.abs(i),c=Math.abs(r);a>=h&&a>=c?(o=a,s=t>=0?e.CP_FACE_X_POS:e.CP_FACE_X_NEG):h>=a&&h>=c?(o=h,s=i>=0?e.CP_FACE_Y_POS:e.CP_FACE_Y_NEG):(o=c,s=r>=0?e.CP_FACE_Z_POS:e.CP_FACE_Z_NEG);var l=1/o;t*=l,i*=l,r*=l;var u=e._sgFace2DMapping[s][e.CP_UDIR],f=u[0]*t+u[1]*i+u[2]*r;u=e._sgFace2DMapping[s][e.CP_VDIR];var d=u[0]*t+u[1]*i+u[2]*r,p=Math.floor(.5*(n-1)*(f+1)),m=Math.floor(.5*(n-1)*(d+1));return e._vectorTemp.x=s,e._vectorTemp.y=p,e._vectorTemp.z=m,e._vectorTemp},e.prototype.areaElement=function(e,t){return Math.atan2(e*t,Math.sqrt(e*e+t*t+1))},e.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},e.prototype.filterCubeSurfaces=function(e,t,r,n,o,s){var a,h,c,l=[];for(a=0;a<6;a++)l.push(new i);var u=180/Math.PI*Math.atan2(1,t),f=o/2;f90&&(f=90);var d=Math.ceil(f/u);d<1&&(d=1);var p=Math.cos(Math.PI/180*f);for(a=0;a<6;a++)for(c=0;c0){switch(o=e._sgCubeNgh[f][y][0],s=e._sgCubeNgh[f][y][1],y!=s&&y+s!=3||(c[y]=i-1-c[y],l[y]=i-1-l[y]),e._sgCubeNgh[f][y][1]){case e.CP_EDGE_LEFT:n[o].augment(0,c[y],0),n[o].augment(h[y],l[y],0);break;case e.CP_EDGE_RIGHT:n[o].augment(i-1,c[y],0),n[o].augment(i-1-h[y],l[y],0);break;case e.CP_EDGE_TOP:n[o].augment(c[y],0,0),n[o].augment(l[y],h[y],0);break;case e.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 e.CP_FACE_X_POS:a=e.CP_FACE_X_NEG;break;case e.CP_FACE_X_NEG:a=e.CP_FACE_X_POS;break;case e.CP_FACE_Y_POS:a=e.CP_FACE_Y_NEG;break;case e.CP_FACE_Y_NEG:a=e.CP_FACE_Y_POS;break;case e.CP_FACE_Z_POS:a=e.CP_FACE_Z_NEG;break;case e.CP_FACE_Z_NEG:a=e.CP_FACE_Z_POS}n[a].augment(0,0,0),n[a].augment(i-1,i-1,0)}}},e.prototype.processFilterExtents=function(t,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,m=0;m<6;m++)if(!r[m].empty())for(var _=r[m].min.x,g=r[m].min.y,v=r[m].max.x,y=r[m].max.y,x=4*(g*u+_),b=this.numChannels*(g*u+_),A=g;A<=y;A++){for(var T=0,E=0,P=_;P<=v;P++){var M=this._normCubeMap[m][x+T+0],S=this._normCubeMap[m][x+T+1],C=this._normCubeMap[m][x+T+2],R=M*t.x+S*t.y+C*t.z;if(R>=i&&R>0){var O=this._normCubeMap[m][x+T+3];for(O*=Math.pow(R,s+p),c=0;c3&&(e._vectorTemp.w=a[3]/h);else{var I=this.vectToTexelCoord(t.x,t.y,t.z,o).clone();e._vectorTemp.x=n[I.x][this.numChannels*(I.z*o+I.y)+0],e._vectorTemp.y=n[I.x][this.numChannels*(I.z*o+I.y)+1],e._vectorTemp.z=n[I.x][this.numChannels*(I.z*o+I.y)+2],this.numChannels>3&&(e._vectorTemp.z=n[I.x][this.numChannels*(I.z*o+I.y)+3])}return e._vectorTemp},e.prototype.fixupCubeEdges=function(t,i){var r,n,o,s,a=0,h=[0,0,0,0,0,0,0,0],c=[[],[],[],[]],l=[[[],[],[]],[[],[],[]],[[],[],[]],[[],[],[]],[[],[],[]],[[],[],[]],[[],[],[]],[[],[],[]]];if(!(i<1))if(1!=i){for(s=0;s<6;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;a<4;a++){var u=e._sgCubeCornerList[s][a];l[u][h[u]]=c[a],h[u]++}for(a=0;a<8;a++)for(r=0;r>s,2),h=0;h<6;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;l<6;l++)h.push(r.subarray(a,a+c)),a+=c;for(var u=[],f=null,d=0;d<6;d++){var p=null;if(n)p=h[d];else{var m=[0,2,4,1,3,5][d];if(p=h[m],!t.getScene().getEngine().getCaps().textureFloat){var _=new ArrayBuffer(c);f=new Uint8Array(_)}for(var g=0;g255){var A=255/b;v*=A,y*=A,x*=A}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;a<6;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;l255){var m=255/p;u*=m,f*=m,d*=m}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,t.generateHarmonics,t.useInGammaSpace,t.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.customType="BABYLON.HDRCubeTexture",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>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 m=30,l=0;l>l,2),g=0;g<6;g++)p.set(h[l][g],m),m+=_;r(f)};e.Tools.LoadFile(t,(function(e){o(e)}),null,null,!0,n)},i})(e.BaseTexture);t._facesMapping=["right","up","front","left","down","back"],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;n=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),s.getAbsolutePositionToRef(this.mesh,h[0]),a.getAbsolutePositionToRef(this.mesh,h[1]),n++}}},t.prototype.update=function(){this.autoUpdateBonesMatrices&&this.skeleton.computeAbsoluteTransforms(),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.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(t){var i=(function(){function t(t,i){void 0===i&&(i=1),this._xline=[e.Vector3.Zero(),e.Vector3.Zero()],this._yline=[e.Vector3.Zero(),e.Vector3.Zero()],this._zline=[e.Vector3.Zero(),e.Vector3.Zero()],this.scaleLines=1,this.scaleLines=i,this._xmesh=e.Mesh.CreateLines("xline",this._xline,t,!0),this._ymesh=e.Mesh.CreateLines("yline",this._yline,t,!0),this._zmesh=e.Mesh.CreateLines("zline",this._zline,t,!0),this._xmesh.renderingGroupId=2,this._ymesh.renderingGroupId=2,this._zmesh.renderingGroupId=2,this._xmesh.material.checkReadyOnlyOnce=!0,this._xmesh.color=new e.Color3(1,0,0),this._ymesh.material.checkReadyOnlyOnce=!0,this._ymesh.color=new e.Color3(0,1,0),this._zmesh.material.checkReadyOnlyOnce=!0,this._zmesh.color=new e.Color3(0,0,1),this.scene=t}return t.prototype.update=function(t,i,r,n){var o=this.scaleLines,s=this._xline[0],a=this._xline[1];s.x=t.x,s.y=t.y,s.z=t.z,a.x=s.x+i.x*o,a.y=s.y+i.y*o,a.z=s.z+i.z*o,e.Mesh.CreateLines(null,this._xline,null,null,this._xmesh),s=this._yline[0],a=this._yline[1],s.x=t.x,s.y=t.y,s.z=t.z,a.x=s.x+r.x*o,a.y=s.y+r.y*o,a.z=s.z+r.z*o,e.Mesh.CreateLines(null,this._yline,null,null,this._ymesh),s=this._zline[0],a=this._zline[1],s.x=t.x,s.y=t.y,s.z=t.z,a.x=s.x+n.x*o,a.y=s.y+n.y*o,a.z=s.z+n.z*o,e.Mesh.CreateLines(null,this._zline,null,null,this._zmesh)},t.prototype.dispose=function(){this._xmesh&&(this._xmesh.dispose(),this._ymesh.dispose(),this._zmesh.dispose(),this._xmesh=null,this._ymesh=null,this._zmesh=null,this._xline=null,this._yline=null,this._zline=null,this.scene=null)},t})();t.AxesViewer=i})(t=e.Debug||(e.Debug={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t;!(function(t){var i=(function(t){function i(i,r,n,o){void 0===o&&(o=1);var s=t.call(this,i,o)||this;return s.pos=e.Vector3.Zero(),s.xaxis=e.Vector3.Zero(),s.yaxis=e.Vector3.Zero(),s.zaxis=e.Vector3.Zero(),s.mesh=n,s.bone=r,s}return __extends(i,t),i.prototype.update=function(){var i=this.bone;i.getAbsolutePositionToRef(this.mesh,this.pos),i.getDirectionToRef(e.Axis.X,this.mesh,this.xaxis),i.getDirectionToRef(e.Axis.Y,this.mesh,this.yaxis),i.getDirectionToRef(e.Axis.Z,this.mesh,this.zaxis),t.prototype.update.call(this,this.pos,this.xaxis,this.yaxis,this.zaxis)},i.prototype.dispose=function(){this.pos&&(this.pos=null,this.xaxis=null,this.yaxis=null,this.zaxis=null,this.mesh=null,this.bone=null,t.prototype.dispose.call(this))},i})(t.AxesViewer);t.BoneAxesViewer=i})(t=e.Debug||(e.Debug={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r){var n=t.call(this,r)||this;return i?(n._textureMatrix=e.Matrix.Identity(),n.name=i,n.url=i,n.hasAlpha=!1,n.isCube=!1,n.wrapU=e.Texture.CLAMP_ADDRESSMODE,n.wrapV=e.Texture.CLAMP_ADDRESSMODE,n.anisotropicFilteringLevel=1,n._texture=n._getFromCache(i,!0),n._texture||(r.useDelayedTextureLoading?n.delayLoadState=e.Engine.DELAYLOADSTATE_NOTLOADED:n.loadTexture()),n):n}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;p0||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),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),void 0===this.metallic&&void 0===this.roughness||(this._defines.METALLICWORKFLOW=!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=this._defines.toString(),u=["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"],f=["albedoSampler","ambientSampler","opacitySampler","reflectionCubeSampler","reflection2DSampler","emissiveSampler","reflectivitySampler","bumpSampler","lightmapSampler","refractionCubeSampler","refraction2DSampler"];e.ColorCurves.PrepareUniforms(u),e.ColorGradingTexture.PrepareUniformsAndSamplers(u,f),e.MaterialHelper.PrepareUniformsAndSamplersList(u,f,this._defines,this.maxSimultaneousLights),this._effect=n.getEngine().createEffect("pbr",c,u,f,l,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)},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.setFloat3("vAmbientInfos",this.ambientTexture.coordinatesIndex,this.ambientTexture.level,this.ambientTextureStrength),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())),e.StandardMaterial.SpecularTextureEnabled&&(this.metallicTexture?(this._effect.setTexture("reflectivitySampler",this.metallicTexture),this._effect.setFloat2("vReflectivityInfos",this.metallicTexture.coordinatesIndex,this.metallicTexture.level),this._effect.setMatrix("reflectivityMatrix",this.metallicTexture.getTextureMatrix())):this.reflectivityTexture&&(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)}(this.reflectionTexture||this.refractionTexture)&&this._effect.setFloat2("vMicrosurfaceTextureLods",this._microsurfaceTextureLods.x,this._microsurfaceTextureLods.y),this.cameraColorGradingTexture&&e.StandardMaterial.ColorGradingTextureEnabled&&e.ColorGradingTexture.Bind(this.cameraColorGradingTexture,this._effect)}e.MaterialHelper.BindClipPlane(this._effect,this._myScene),this.pointsCloud&&this._effect.setFloat("pointSize",this.pointSize),this._myScene.ambientColor.multiplyToRef(this.ambientColor,this._globalAmbientColor),this._defines.METALLICWORKFLOW?(r._scaledReflectivity.r=void 0===this.metallic?1:this.metallic,r._scaledReflectivity.g=void 0===this.roughness?1:this.roughness,this._effect.setColor4("vReflectivityColor",r._scaledReflectivity,0)):(this.convertColorToLinearSpaceToRef(this.reflectivityColor,r._scaledReflectivity),this._effect.setColor4("vReflectivityColor",r._scaledReflectivity,this.microSurface)),this._effect.setVector3("vEyePosition",this._myScene._mirroredCameraPosition?this._myScene._mirroredCameraPosition:this._myScene.activeCamera.position),this._effect.setColor3("vAmbientColor",this._globalAmbientColor),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._effect.setColor3("vOverloadedAmbient",this.overloadedAmbient),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.metallicTexture&&this.metallicTexture.animations&&this.metallicTexture.animations.length>0?e.push(this.metallicTexture):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.metallicTexture&&this.metallicTexture.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})(e.Material);i._scaledAlbedo=new e.Color3,i._scaledReflectivity=new e.Color3,i._scaledEmissive=new e.Color3,i._scaledReflection=new e.Color3,__decorate([e.serialize()],i.prototype,"directIntensity",void 0),__decorate([e.serialize()],i.prototype,"emissiveIntensity",void 0),__decorate([e.serialize()],i.prototype,"environmentIntensity",void 0),__decorate([e.serialize()],i.prototype,"specularIntensity",void 0),__decorate([e.serialize()],i.prototype,"disableBumpMap",void 0),__decorate([e.serialize()],i.prototype,"overloadedShadowIntensity",void 0),__decorate([e.serialize()],i.prototype,"overloadedShadeIntensity",void 0),__decorate([e.serialize()],i.prototype,"cameraExposure",void 0),__decorate([e.serialize()],i.prototype,"cameraContrast",void 0),__decorate([e.serializeAsTexture()],i.prototype,"cameraColorGradingTexture",void 0),__decorate([e.serializeAsColorCurves()],i.prototype,"cameraColorCurves",void 0),__decorate([e.serializeAsColor3()],i.prototype,"overloadedAmbient",void 0),__decorate([e.serialize()],i.prototype,"overloadedAmbientIntensity",void 0),__decorate([e.serializeAsColor3()],i.prototype,"overloadedAlbedo",void 0),__decorate([e.serialize()],i.prototype,"overloadedAlbedoIntensity",void 0),__decorate([e.serializeAsColor3()],i.prototype,"overloadedReflectivity",void 0),__decorate([e.serialize()],i.prototype,"overloadedReflectivityIntensity",void 0),__decorate([e.serializeAsColor3()],i.prototype,"overloadedEmissive",void 0),__decorate([e.serialize()],i.prototype,"overloadedEmissiveIntensity",void 0),__decorate([e.serializeAsColor3()],i.prototype,"overloadedReflection",void 0),__decorate([e.serialize()],i.prototype,"overloadedReflectionIntensity",void 0),__decorate([e.serialize()],i.prototype,"overloadedMicroSurface",void 0),__decorate([e.serialize()],i.prototype,"overloadedMicroSurfaceIntensity",void 0),__decorate([e.serializeAsTexture()],i.prototype,"albedoTexture",void 0),__decorate([e.serializeAsTexture()],i.prototype,"ambientTexture",void 0),__decorate([e.serialize()],i.prototype,"ambientTextureStrength",void 0),__decorate([e.serializeAsTexture()],i.prototype,"opacityTexture",void 0),__decorate([e.serializeAsTexture()],i.prototype,"reflectionTexture",void 0),__decorate([e.serializeAsTexture()],i.prototype,"emissiveTexture",void 0),__decorate([e.serializeAsTexture()],i.prototype,"reflectivityTexture",void 0),__decorate([e.serializeAsTexture()],i.prototype,"metallicTexture",void 0),__decorate([e.serialize()],i.prototype,"metallic",void 0),__decorate([e.serialize()],i.prototype,"roughness",void 0),__decorate([e.serializeAsTexture()],i.prototype,"bumpTexture",void 0),__decorate([e.serializeAsTexture()],i.prototype,"lightmapTexture",void 0),__decorate([e.serializeAsTexture()],i.prototype,"refractionTexture",void 0),__decorate([e.serializeAsColor3("ambient")],i.prototype,"ambientColor",void 0),__decorate([e.serializeAsColor3("albedo")],i.prototype,"albedoColor",void 0),__decorate([e.serializeAsColor3("reflectivity")],i.prototype,"reflectivityColor",void 0),__decorate([e.serializeAsColor3("reflection")],i.prototype,"reflectionColor",void 0),__decorate([e.serializeAsColor3("emissive")],i.prototype,"emissiveColor",void 0),__decorate([e.serialize()],i.prototype,"microSurface",void 0),__decorate([e.serialize()],i.prototype,"indexOfRefraction",void 0),__decorate([e.serialize()],i.prototype,"invertRefractionY",void 0),__decorate([e.serializeAsFresnelParameters()],i.prototype,"opacityFresnelParameters",void 0),__decorate([e.serializeAsFresnelParameters()],i.prototype,"emissiveFresnelParameters",void 0),__decorate([e.serialize()],i.prototype,"linkRefractionWithTransparency",void 0),__decorate([e.serialize()],i.prototype,"linkEmissiveWithAlbedo",void 0),__decorate([e.serialize()],i.prototype,"useLightmapAsShadowmap",void 0),__decorate([e.serialize()],i.prototype,"useEmissiveAsIllumination",void 0),__decorate([e.serialize()],i.prototype,"useAlphaFromAlbedoTexture",void 0),__decorate([e.serialize()],i.prototype,"useSpecularOverAlpha",void 0),__decorate([e.serialize()],i.prototype,"useMicroSurfaceFromReflectivityMapAlpha",void 0),__decorate([e.serialize()],i.prototype,"useRoughnessFromMetallicTextureAlpha",void 0),__decorate([e.serialize()],i.prototype,"useRoughnessFromMetallicTextureGreen",void 0),__decorate([e.serialize()],i.prototype,"useAutoMicroSurfaceFromReflectivityMap",void 0),__decorate([e.serialize()],i.prototype,"useScalarInLinearSpace",void 0),__decorate([e.serialize()],i.prototype,"usePhysicalLightFalloff",void 0),__decorate([e.serialize()],i.prototype,"useRadianceOverAlpha",void 0),__decorate([e.serialize()],i.prototype,"useParallax",void 0),__decorate([e.serialize()],i.prototype,"useParallaxOcclusion",void 0),__decorate([e.serialize()],i.prototype,"parallaxScaleBias",void 0),__decorate([e.serialize()],i.prototype,"disableLighting",void 0),__decorate([e.serialize()],i.prototype,"maxSimultaneousLights",void 0),__decorate([e.serialize()],i.prototype,"invertNormalMapX",void 0),__decorate([e.serialize()],i.prototype,"invertNormalMapY",void 0),__decorate([e.serialize()],i.prototype,"useLogarithmicDepth",null),e.PBRMaterial=i})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(e){this._scene=e}return t.prototype._createInspector=function(e){this._inspector||(this._inspector=new INSPECTOR.Inspector(this._scene,e))},t.prototype.isVisible=function(){return!1},t.prototype.hide=function(){this._inspector&&(this._inspector.dispose(),this._inspector=null)},t.prototype.show=function(i){"undefined"==typeof INSPECTOR?e.Tools.LoadScript(t.InspectorURL,this._createInspector.bind(this,i)):this._createInspector(i)},t})();t.InspectorURL="http://www.babylonjs.com/babylon.inspector.bundle.js",e.DebugLayer=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,o,s){void 0===o&&(o=null);var a=t.call(this,r.getEngine(),i)||this;return a.downSampleX4PostProcess=null,a.brightPassPostProcess=null,a.gaussianBlurHPostProcesses=[],a.gaussianBlurVPostProcesses=[],a.textureAdderPostProcess=null,a.textureAdderFinalPostProcess=null,a.lensFlarePostProcess=null,a.lensFlareComposePostProcess=null,a.depthOfFieldPostProcess=null,a.brightThreshold=1,a.blurWidth=2,a.gaussianCoefficient=.25,a.gaussianMean=1,a.gaussianStandardDeviation=1,a.exposure=1,a.lensTexture=null,a.lensColorTexture=null,a.lensFlareStrength=20,a.lensFlareGhostDispersal=1.4,a.lensFlareHaloWidth=.7,a.lensFlareDistortionStrength=16,a.lensStarTexture=null,a.lensFlareDirtTexture=null,a.depthOfFieldDistance=10,a.animations=[],a._depthRenderer=null,a._depthOfFieldEnabled=!0,a._lensFlareEnabled=!0,a._scene=r,o?a.originalPostProcess=o:a.originalPostProcess=new e.PostProcess("HDRPass","standard",[],[],n,null,e.Texture.BILINEAR_SAMPLINGMODE,r.getEngine(),(!0),"#define PASS_POST_PROCESS",e.Engine.TEXTURETYPE_FLOAT),a.addEffect(new e.PostProcessRenderEffect(r.getEngine(),"HDRPassPostProcess",function(){return a.originalPostProcess},(!0))),a._createDownSampleX4PostProcess(r,n/2),a._createBrightPassPostProcess(r,n/2),a._createGaussianBlurPostProcesses(r,n/2,0),a._createGaussianBlurPostProcesses(r,n/4,1),a._createGaussianBlurPostProcesses(r,n/8,2),a._createGaussianBlurPostProcesses(r,n/16,3),a._createTextureAdderPostProcess(r,n),a.textureAdderFinalPostProcess=new e.PostProcess("HDRDepthOfFieldSource","standard",[],[],n,null,e.Texture.BILINEAR_SAMPLINGMODE,r.getEngine(),(!0),"#define PASS_POST_PROCESS",e.Engine.TEXTURETYPE_UNSIGNED_INT),a.addEffect(new e.PostProcessRenderEffect(r.getEngine(),"HDRDepthOfFieldSource",function(){return a.textureAdderFinalPostProcess},(!0))),a._createLensFlarePostProcess(r,n),a._createGaussianBlurPostProcesses(r,n/2,5),a._createDepthOfFieldPostProcess(r,n),r.postProcessRenderPipelineManager.addPipeline(a),null!==s&&r.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(i,s),a.LensFlareEnabled=!1,a.DepthOfFieldEnabled=!1,a}return __extends(i,t),Object.defineProperty(i.prototype,"DepthOfFieldEnabled",{get:function(){return this._depthOfFieldEnabled},set:function(e){var t=this.gaussianBlurHPostProcesses.length-1;e&&!this._depthOfFieldEnabled?(this._scene.postProcessRenderPipelineManager.enableEffectInPipeline(this._name,"HDRGaussianBlurH"+t,this._scene.cameras),this._scene.postProcessRenderPipelineManager.enableEffectInPipeline(this._name,"HDRGaussianBlurV"+t,this._scene.cameras),this._scene.postProcessRenderPipelineManager.enableEffectInPipeline(this._name,"HDRDepthOfField",this._scene.cameras),this._depthRenderer=this._scene.enableDepthRenderer()):!e&&this._depthOfFieldEnabled&&(this._scene.postProcessRenderPipelineManager.disableEffectInPipeline(this._name,"HDRGaussianBlurH"+t,this._scene.cameras),this._scene.postProcessRenderPipelineManager.disableEffectInPipeline(this._name,"HDRGaussianBlurV"+t,this._scene.cameras),this._scene.postProcessRenderPipelineManager.disableEffectInPipeline(this._name,"HDRDepthOfField",this._scene.cameras)),this._depthOfFieldEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"LensFlareEnabled",{get:function(){return this._lensFlareEnabled},set:function(e){var t=this.gaussianBlurHPostProcesses.length-2;e&&!this._lensFlareEnabled?(this._scene.postProcessRenderPipelineManager.enableEffectInPipeline(this._name,"HDRLensFlare",this._scene.cameras),this._scene.postProcessRenderPipelineManager.enableEffectInPipeline(this._name,"HDRLensFlareShift",this._scene.cameras),this._scene.postProcessRenderPipelineManager.enableEffectInPipeline(this._name,"HDRGaussianBlurH"+t,this._scene.cameras),this._scene.postProcessRenderPipelineManager.enableEffectInPipeline(this._name,"HDRGaussianBlurV"+t,this._scene.cameras),this._scene.postProcessRenderPipelineManager.enableEffectInPipeline(this._name,"HDRLensFlareCompose",this._scene.cameras)):!e&&this._lensFlareEnabled&&(this._scene.postProcessRenderPipelineManager.disableEffectInPipeline(this._name,"HDRLensFlare",this._scene.cameras),this._scene.postProcessRenderPipelineManager.disableEffectInPipeline(this._name,"HDRLensFlareShift",this._scene.cameras),this._scene.postProcessRenderPipelineManager.disableEffectInPipeline(this._name,"HDRGaussianBlurH"+t,this._scene.cameras),this._scene.postProcessRenderPipelineManager.disableEffectInPipeline(this._name,"HDRGaussianBlurV"+t,this._scene.cameras),this._scene.postProcessRenderPipelineManager.disableEffectInPipeline(this._name,"HDRLensFlareCompose",this._scene.cameras)),this._lensFlareEnabled=e},enumerable:!0,configurable:!0}),i.prototype._createDownSampleX4PostProcess=function(t,i){var r=this,n=new Array(32);this.downSampleX4PostProcess=new e.PostProcess("HDRDownSampleX4","standard",["dsOffsets"],[],i,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),(!1),"#define DOWN_SAMPLE_X4",e.Engine.TEXTURETYPE_UNSIGNED_INT),this.downSampleX4PostProcess.onApply=function(e){for(var t=0,i=-2;i<2;i++)for(var o=-2;o<2;o++)n[t]=(i+.5)*(1/r.downSampleX4PostProcess.width),n[t+1]=(o+.5)*(1/r.downSampleX4PostProcess.height),t+=2;e.setArray2("dsOffsets",n)},this.addEffect(new e.PostProcessRenderEffect(t.getEngine(),"HDRDownSampleX4",function(){return r.downSampleX4PostProcess},(!0)))},i.prototype._createBrightPassPostProcess=function(t,i){var r=this,n=new Array(8);this.brightPassPostProcess=new e.PostProcess("HDRBrightPass","standard",["dsOffsets","brightThreshold"],[],i,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),(!1),"#define BRIGHT_PASS",e.Engine.TEXTURETYPE_UNSIGNED_INT),this.brightPassPostProcess.onApply=function(e){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.addEffect(new e.PostProcessRenderEffect(t.getEngine(),"HDRBrightPass",function(){return r.brightPassPostProcess},(!0)))},i.prototype._createGaussianBlurPostProcesses=function(t,i,r){var n=this,o=new Array(9),s=new Array(9),a=["blurOffsets","blurWeights","blurWidth"],h=function(e){return function(i){for(var r=0,a=0;a<9;a++)r=(a-4)/4,s[a]=n.gaussianCoefficient*(1/Math.sqrt(2*Math.PI*n.gaussianStandardDeviation))*Math.exp(-((r-n.gaussianMean)*(r-n.gaussianMean))/(2*n.gaussianStandardDeviation*n.gaussianStandardDeviation));for(var h={width:t.getEngine().getRenderWidth(), +height:t.getEngine().getRenderHeight()},a=0;a<9;a++){var c=(a-4)*(1/(e===!0?h.height:h.width));o[a]=c}i.setArray("blurOffsets",o),i.setArray("blurWeights",s),i.setFloat("blurWidth",n.blurWidth)}},c=new e.PostProcess("HDRGaussianBlurH"+i,"standard",a,[],i,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),(!1),"#define GAUSSIAN_BLUR_H",e.Engine.TEXTURETYPE_UNSIGNED_INT);c.onApply=h(!1);var l=new e.PostProcess("HDRGaussianBlurV"+i,"standard",a,[],i,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),(!1),"#define GAUSSIAN_BLUR_V",e.Engine.TEXTURETYPE_UNSIGNED_INT);l.onApply=h(!0),this.addEffect(new e.PostProcessRenderEffect(t.getEngine(),"HDRGaussianBlurH"+r,function(){return c},(!0))),this.addEffect(new e.PostProcessRenderEffect(t.getEngine(),"HDRGaussianBlurV"+r,function(){return l},(!0))),this.gaussianBlurHPostProcesses.push(c),this.gaussianBlurVPostProcesses.push(l)},i.prototype._createTextureAdderPostProcess=function(t,i){var r=this;this.gaussianBlurVPostProcesses[3];this.textureAdderPostProcess=new e.PostProcess("HDRTextureAdder","standard",["exposure"],["otherSampler","lensSampler"],i,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),(!1),"#define TEXTURE_ADDER",e.Engine.TEXTURETYPE_UNSIGNED_INT),this.textureAdderPostProcess.onApply=function(e){e.setTextureFromPostProcess("otherSampler",r.originalPostProcess),e.setTexture("lensSampler",r.lensTexture),e.setFloat("exposure",r.exposure)},this.addEffect(new e.PostProcessRenderEffect(t.getEngine(),"HDRTextureAdder",function(){return r.textureAdderPostProcess},(!0)))},i.prototype._createLensFlarePostProcess=function(t,i){var r=this;this.lensFlarePostProcess=new e.PostProcess("HDRLensFlare","standard",["strength","ghostDispersal","haloWidth","resolution","distortionStrength"],["lensColorSampler"],i/2,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),(!0),"#define LENS_FLARE",e.Engine.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new e.PostProcessRenderEffect(t.getEngine(),"HDRLensFlare",function(){return r.lensFlarePostProcess},(!1))),this._createGaussianBlurPostProcesses(t,i/4,4),this.lensFlareComposePostProcess=new e.PostProcess("HDRLensFlareCompose","standard",["lensStarMatrix"],["otherSampler","lensDirtSampler","lensStarSampler"],i,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),(!1),"#define LENS_FLARE_COMPOSE",e.Engine.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new e.PostProcessRenderEffect(t.getEngine(),"HDRLensFlareCompose",function(){return r.lensFlareComposePostProcess},(!1)));var n=new e.Vector2(0,0);this.lensFlarePostProcess.onApply=function(e){e.setTextureFromPostProcess("textureSampler",r.gaussianBlurHPostProcesses[0]),e.setTexture("lensColorSampler",r.lensColorTexture),e.setFloat("strength",r.lensFlareStrength),e.setFloat("ghostDispersal",r.lensFlareGhostDispersal),e.setFloat("haloWidth",r.lensFlareHaloWidth),n.x=r.lensFlarePostProcess.width,n.y=r.lensFlarePostProcess.height,e.setVector2("resolution",n),e.setFloat("distortionStrength",r.lensFlareDistortionStrength)};var o=e.Matrix.FromValues(2,0,-1,0,0,2,-1,0,0,0,1,0,0,0,0,1),s=e.Matrix.FromValues(.5,0,.5,0,0,.5,.5,0,0,0,1,0,0,0,0,1);this.lensFlareComposePostProcess.onApply=function(t){t.setTextureFromPostProcess("otherSampler",r.textureAdderFinalPostProcess),t.setTexture("lensDirtSampler",r.lensFlareDirtTexture),t.setTexture("lensStarSampler",r.lensStarTexture);var i=r._scene.activeCamera.getViewMatrix().getRow(0),n=r._scene.activeCamera.getViewMatrix().getRow(2),a=e.Vector3.Dot(i.toVector3(),new e.Vector3(1,0,0))+e.Vector3.Dot(n.toVector3(),new e.Vector3(0,0,1));a*=4;var h=e.Matrix.FromValues(.5*Math.cos(a),-Math.sin(a),0,0,Math.sin(a),.5*Math.cos(a),0,0,0,0,1,0,0,0,0,1),c=s.multiply(h).multiply(o);t.setMatrix("lensStarMatrix",c)}},i.prototype._createDepthOfFieldPostProcess=function(t,i){var r=this;this.depthOfFieldPostProcess=new e.PostProcess("HDRDepthOfField","standard",["distance"],["otherSampler","depthSampler"],i,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),(!1),"#define DEPTH_OF_FIELD",e.Engine.TEXTURETYPE_UNSIGNED_INT),this.depthOfFieldPostProcess.onApply=function(e){e.setTextureFromPostProcess("otherSampler",r.textureAdderFinalPostProcess),e.setTexture("depthSampler",r._depthRenderer.getDepthMap()),e.setFloat("distance",r.depthOfFieldDistance)},this.addEffect(new e.PostProcessRenderEffect(t.getEngine(),"HDRDepthOfField",function(){return r.depthOfFieldPostProcess},(!0)))},i.prototype.dispose=function(){for(var e=0;e0.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\n\n#include[0..maxSimultaneousLights]\n#include\n#include\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\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\n#ifdef REFLECTIONFRESNEL\nuniform vec4 reflectionLeftColor;\nuniform vec4 reflectionRightColor;\n#endif\n#endif\n#ifdef CAMERACOLORGRADING\n#include \n#include\n#endif\n#ifdef CAMERACOLORCURVES\n#include\n#include\n#endif\n#include\n#include\n#include\n#include\nvoid main(void) {\n#include\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#include\n#ifdef DIFFUSE\nbaseColor=texture2D(diffuseSampler,vDiffuseUV+uvOffset);\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+uvOffset).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+uvOffset);\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#ifdef LIGHTMAP\nvec3 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset).rgb*vLightmapInfos.y;\n#endif\n#include[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+uvOffset);\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+uvOffset).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\n#ifdef LIGHTMAP\n#ifndef LIGHTMAPEXCLUDED\n#ifdef USELIGHTMAPASSHADOWMAP\ncolor.rgb*=lightmapColor;\n#else\ncolor.rgb+=lightmapColor;\n#endif\n#endif\n#endif\n#include\n#include\n#ifdef CAMERACOLORGRADING\ncolor=colorGrades(color);\n#endif\n#ifdef CAMERACOLORCURVES\ncolor.rgb=applyColorCurves(color.rgb);\n#endif\ngl_FragColor=color;\n}",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\n\n#include\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\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include\n#include\n#include[0..maxSimultaneousLights]\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#endif\n#ifdef REFLECTIONMAP_EQUIRECTANGULAR_FIXED\nvarying vec3 vDirectionW;\n#endif\n#include\nvoid main(void) {\n#ifdef REFLECTIONMAP_SKYBOX\nvPositionUVW=position;\n#endif \n#include\n#include\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\n#include\n#include[0..maxSimultaneousLights]\n#ifdef VERTEXCOLOR\n\nvColor=color;\n#endif\n#include\n#include\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\n\n#include\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\n#include\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}",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 ((lumaBlumaMax)) {\ngl_FragColor=rgbA;\n}\nelse {\ngl_FragColor=rgbB;\n}\n}",glowBlurPostProcessPixelShader:"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n\nuniform vec2 screenSize;\nuniform vec2 direction;\nuniform float blurWidth;\n\nfloat getLuminance(vec3 color)\n{\nreturn dot(color,vec3(0.2126,0.7152,0.0722));\n}\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{\n\nvec4 texel=texture2D(textureSampler,start+texelOffset);\nbaseColor.a+=texel.a*weights[i];\n\nfloat luminance=getLuminance(baseColor.rgb);\nfloat luminanceTexel=getLuminance(texel.rgb);\nfloat choice=step(luminanceTexel,luminance);\nbaseColor.rgb=choice*baseColor.rgb+(1.0-choice)*texel.rgb;\ntexelOffset+=texelStep;\n}\ngl_FragColor=baseColor;\n}", +glowMapGenerationPixelShader:"#ifdef ALPHATEST\nvarying vec2 vUVDiffuse;\nuniform sampler2D diffuseSampler;\n#endif\n#ifdef EMISSIVE\nvarying vec2 vUVEmissive;\nuniform sampler2D emissiveSampler;\n#endif\nuniform vec4 color;\nvoid main(void)\n{\n#ifdef ALPHATEST\nif (texture2D(diffuseSampler,vUVDiffuse).a<0.4)\ndiscard;\n#endif\n#ifdef EMISSIVE\ngl_FragColor=texture2D(emissiveSampler,vUVEmissive);\n#else\ngl_FragColor=color;\n#endif\n}",glowMapGenerationVertexShader:"\nattribute vec3 position;\n#include\n\n#include\nuniform mat4 viewProjection;\nvarying vec4 vPosition;\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef ALPHATEST\nvarying vec2 vUVDiffuse;\nuniform mat4 diffuseMatrix;\n#endif\n#ifdef EMISSIVE\nvarying vec2 vUVEmissive;\nuniform mat4 emissiveMatrix;\n#endif\nvoid main(void)\n{\n#include\n#include\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 DIFFUSEUV1\nvUVDiffuse=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n#endif\n#ifdef DIFFUSEUV2\nvUVDiffuse=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n#ifdef EMISSIVE\n#ifdef EMISSIVEUV1\nvUVEmissive=vec2(emissiveMatrix*vec4(uv,1.0,0.0));\n#endif\n#ifdef EMISSIVEUV2\nvUVEmissive=vec2(emissiveMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n}",glowMapMergePixelShader:"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n\nuniform float offset;\nvoid main(void) {\nvec4 baseColor=texture2D(textureSampler,vUV);\nbaseColor.a=abs(offset-baseColor.a);\ngl_FragColor=baseColor;\n}",glowMapMergeVertexShader:"\nattribute vec2 position;\n\nvarying vec2 vUV;\nconst vec2 madd=vec2(0.5,0.5);\nvoid main(void) {\nvUV=position*madd+madd;\ngl_Position=vec4(position,0.0,1.0);\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 (luminance1.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}",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\n\nuniform float offset;\n#include\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\n#include\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[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 vec3 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) || defined(METALLICWORKFLOW) \nvarying vec2 vReflectivityUV;\nuniform vec2 vReflectivityInfos;\nuniform sampler2D reflectivitySampler;\n#endif\n\n#include\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\n#endif\n#ifdef CAMERACOLORGRADING\n#include\n#endif\n#ifdef CAMERACOLORCURVES\n#include\n#endif\n\n#include\n#include\n#ifdef CAMERACOLORGRADING\n#include\n#endif\n#ifdef CAMERACOLORCURVES\n#include\n#endif\n#include\n#include\n#include\n#include\n#include\n#include\n\n#include\nvoid main(void) {\n#include\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\n#include\n\nvec4 surfaceAlbedo=vec4(1.,1.,1.,1.);\nvec3 surfaceAlbedoContribution=vAlbedoColor.rgb;\n\nfloat alpha=vAlbedoColor.a;\n#ifdef ALBEDO\nsurfaceAlbedo=texture2D(albedoSampler,vAlbedoUV+uvOffset);\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\nvec3 ambientColor=vec3(1.,1.,1.);\n#ifdef AMBIENT\nambientColor=texture2D(ambientSampler,vAmbientUV+uvOffset).rgb*vAmbientInfos.y;\nambientColor=vec3(1.,1.,1.)-((vec3(1.,1.,1.)-ambientColor)*vAmbientInfos.z);\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+uvOffset);\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 METALLICWORKFLOW\nvec2 metallicRoughness=surfaceReflectivityColor.rg;\n#ifdef METALLICROUGHNESSMAP\nvec4 surfaceMetallicColorMap=texture2D(reflectivitySampler,vReflectivityUV+uvOffset);\n\nmetallicRoughness.r*=surfaceMetallicColorMap.r;\n#ifdef METALLICROUGHNESSGSTOREINALPHA\nmetallicRoughness.g*=surfaceMetallicColorMap.a;\n#else\n#ifdef METALLICROUGHNESSGSTOREINGREEN\nmetallicRoughness.g*=surfaceMetallicColorMap.g;\n#endif\n#endif\n#endif\n\nvec3 baseColor=surfaceAlbedo.rgb;\n\nsurfaceAlbedo.rgb*=(1.0-metallicRoughness.r);\n\n\nconst vec3 DefaultSpecularReflectanceDielectric=vec3(0.04,0.04,0.04);\n\nsurfaceReflectivityColor=mix(DefaultSpecularReflectanceDielectric,baseColor,metallicRoughness.r);\n#ifdef OVERLOADEDVALUES\nsurfaceReflectivityColor=mix(surfaceReflectivityColor,vOverloadedReflectivity,vOverloadedIntensity.z);\n#endif\nmicroSurface=1.0-metallicRoughness.g;\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.; \n#ifdef LIGHTMAP\nvec3 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset).rgb*vLightmapInfos.y;\n#endif\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[0..maxSimultaneousLights]\n#ifdef SPECULARTERM\nlightSpecularContribution*=vLightingIntensity.w;\n#endif\n#ifdef OPACITY\nvec4 opacityMap=texture2D(opacitySampler,vOpacityUV+uvOffset);\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+uvOffset).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\n#ifndef LIGHTMAPEXCLUDED\n#ifdef USELIGHTMAPASSHADOWMAP\nfinalColor.rgb*=lightmapColor;\n#else\nfinalColor.rgb+=lightmapColor;\n#endif\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\n#include(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\n\n#include\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 vec3 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) || defined(METALLICWORKFLOW) \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\n#include\n#include[0..maxSimultaneousLights]\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#endif\n#ifdef REFLECTIONMAP_EQUIRECTANGULAR_FIXED\nvarying vec3 vDirectionW;\n#endif\n#include\nvoid main(void) {\n#ifdef REFLECTIONMAP_SKYBOX\nvPositionUVW=position;\n#endif \n#include\n#include\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) || defined(METALLICWORKFLOW) \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\n\n#include\n\n#include[0..maxSimultaneousLights]\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n\n#include\n}",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}",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:"#ifndef FULLFLOAT\nvec4 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}\n#endif\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;\n#ifndef FULLFLOAT\ngl_FragColor=vec4(packHalf(moment1),packHalf(moment2));\n#else\ngl_FragColor=vec4(moment1,moment2,1.0,1.0);\n#endif\n#else\n#ifndef FULLFLOAT\ngl_FragColor=pack(depth);\n#else\ngl_FragColor=vec4(depth,1.0,1.0,1.0);\n#endif\n#endif\n}",shadowMapVertexShader:"\nattribute vec3 position;\n#include\n\n#include\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\n#include\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}",spritesPixelShader:"uniform bool alphaTest;\nvarying vec4 vColor;\n\nvarying vec2 vUV;\nuniform sampler2D diffuseSampler;\n\n#include\nvoid main(void) {\nvec4 color=texture2D(diffuseSampler,vUV);\nif (alphaTest) \n{\nif (color.a<0.95)\ndiscard;\n}\ncolor*=vColor;\n#include\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\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; i0.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}",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; i1.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:"vec2 uvOffset=vec2(0.0,0.0);\n#if defined(BUMP) || defined(PARALLAX)\nmat3 TBN=cotangent_frame(normalW*vBumpInfos.y,-viewDirectionW,vBumpUV);\n#endif\n#ifdef PARALLAX\nmat3 invTBN=transposeMat3(TBN);\n#ifdef PARALLAXOCCLUSION\nuvOffset=parallaxOcclusion(invTBN*-viewDirectionW,invTBN*normalW,vBumpUV,vBumpInfos.z);\n#else\nuvOffset=parallaxOffset(invTBN*viewDirectionW,vBumpInfos.z);\n#endif\n#endif\n#ifdef BUMP\nnormalW=perturbNormal(viewDirectionW,TBN,vBumpUV+uvOffset);\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; icurrRayHeight)\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#if defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X}) && defined(LIGHTMAPNOSPECULAR{X})\n\n#else\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#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\n#if defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X})\ndiffuseBase+=lightmapColor*shadow;\n#ifdef SPECULARTERM\n#ifndef LIGHTMAPNOSPECULAR{X}\nspecularBase+=info.specular*shadow*lightmapColor;\n#endif\n#endif\n#else\ndiffuseBase+=info.diffuse*shadow;\n#ifdef SPECULARTERM\nspecularBase+=info.specular*shadow;\n#endif\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",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#if defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X}) && defined(LIGHTMAPNOSPECULAR{X})\n\n#else\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#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\n#if defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X})\nlightDiffuseContribution+=lightmapColor*notShadowLevel;\n#ifdef SPECULARTERM\n#ifndef LIGHTMAPNOSPECULAR{X}\nlightSpecularContribution+=info.specular*notShadowLevel*lightmapColor;\n#endif\n#endif\n#else\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\n#endif",pbrShadowFunctions:"\n#ifdef SHADOWS\n#ifndef SHADOWFULLFLOAT\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}\n#endif\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;\n#ifndef SHADOWFULLFLOAT\nfloat shadow=unpack(textureCube(shadowSampler,directionToLight))+bias;\n#else\nfloat shadow=textureCube(shadowSampler,directionToLight).x+bias;\n#endif\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;\n#ifndef SHADOWFULLFLOAT\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[0]*mapSize))1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\n#ifndef SHADOWFULLFLOAT\nfloat shadow=unpack(texture2D(shadowSampler,uv))+bias;\n#else\nfloat shadow=texture2D(shadowSampler,uv).x+bias;\n#endif\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;\n#ifndef SHADOWFULLFLOAT\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[0]*mapSize))1.0 || uv.y<0. || uv.y>1.0 || depth.z>=1.0)\n{\nreturn 1.0;\n}\nvec4 texel=texture2D(shadowSampler,uv);\n#ifndef SHADOWFULLFLOAT\nvec2 moments=vec2(unpackHalf(texel.xy),unpackHalf(texel.zw));\n#else\nvec2 moments=texel.xy;\n#endif\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\n#ifndef SHADOWFULLFLOAT\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}\n#endif\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;\n#ifndef SHADOWFULLFLOAT\nfloat shadow=unpack(textureCube(shadowSampler,directionToLight))+bias;\n#else\nfloat shadow=textureCube(shadowSampler,directionToLight).x+bias;\n#endif\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;\n#ifndef SHADOWFULLFLOAT\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[0]*mapSize))1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\n#ifndef SHADOWFULLFLOAT\nfloat shadow=unpack(texture2D(shadowSampler,uv))+bias;\n#else\nfloat shadow=texture2D(shadowSampler,uv).x+bias;\n#endif\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;\n#ifndef SHADOWFULLFLOAT\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[0]*mapSize))1.0 || uv.y<0. || uv.y>1.0 || depth.z>=1.0)\n{\nreturn 1.0;\n}\nvec4 texel=texture2D(shadowSampler,uv);\n#ifndef SHADOWFULLFLOAT\nvec2 moments=vec2(unpackHalf(texel.xy),unpackHalf(texel.zw));\n#else\nvec2 moments=texel.xy;\n#endif\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)&&(!(o.x-i>e.x)&&(!(t.y>o.y+i)&&(!(o.y-i>e.y)&&(!(t.z>o.z+i)&&!(o.z-i>e.z)))))},o=function(){var t={root:0,found:!1};return function(e,o,i,s){t.root=0,t.found=!1;var r=o*o-4*e*i;if(r<0)return t;var n=Math.sqrt(r),c=(-o-n)/(2*e),h=(-o+n)/(2*e);if(c>h){var a=h;h=c,c=a}return c>0&&c0&&h=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)&&!!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||V<0)return;h<0&&(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 f=this.velocity.lengthSquared(),m=f;this.basePoint.subtractToRef(s,this._tempVector);var T=2*t.Vector3.Dot(this.velocity,this._tempVector),b=this._tempVector.lengthSquared()-1,y=o(m,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(m,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(m,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(m=g*-f+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(m,T,b,p),y.found){var D=(v*y.root-R)/g;D>=0&&D<=1&&(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),m=g*-f+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(m,T,b,p),y.found&&(D=(v*y.root-R)/g,D>=0&&D<=1&&(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),m=g*-f+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(m,T,b,p),y.found&&(D=(v*y.root-R)/g,D>=0&&D<=1&&(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=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;c1&&!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;t4)){++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}();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()||[])}},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;d0?1:-1},t.Clamp=function(t,i,r){return void 0===i&&(i=0),void 0===r&&(r=1),Math.min(r,Math.max(i,t))},t}();t.MathTools=i;var r=function(){function r(t,i,r){void 0===t&&(t=0),void 0===i&&(i=0),void 0===r&&(r=0),this.r=t,this.g=i,this.b=r}return r.prototype.toString=function(){return"{R: "+this.r+" G:"+this.g+" B:"+this.b+"}"},r.prototype.getClassName=function(){return"Color3"},r.prototype.getHashCode=function(){var t=this.r||0;return t=397*t^(this.g||0),t=397*t^(this.b||0)},r.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},r.prototype.toColor4=function(t){return void 0===t&&(t=1),new n(this.r,this.g,this.b,t)},r.prototype.asArray=function(){var t=[];return this.toArray(t,0),t},r.prototype.toLuminance=function(){return.3*this.r+.59*this.g+.11*this.b},r.prototype.multiply=function(t){return new r(this.r*t.r,this.g*t.g,this.b*t.b)},r.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},r.prototype.equals=function(t){return t&&this.r===t.r&&this.g===t.g&&this.b===t.b},r.prototype.equalsFloats=function(t,i,r){return this.r===t&&this.g===i&&this.b===r},r.prototype.scale=function(t){return new r(this.r*t,this.g*t,this.b*t)},r.prototype.scaleToRef=function(t,i){return i.r=this.r*t,i.g=this.g*t,i.b=this.b*t,this},r.prototype.add=function(t){return new r(this.r+t.r,this.g+t.g,this.b+t.b)},r.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},r.prototype.subtract=function(t){return new r(this.r-t.r,this.g-t.g,this.b-t.b)},r.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},r.prototype.clone=function(){return new r(this.r,this.g,this.b)},r.prototype.copyFrom=function(t){return this.r=t.r,this.g=t.g,this.b=t.b,this},r.prototype.copyFromFloats=function(t,i,r){return this.r=t,this.g=i,this.b=r,this},r.prototype.toHexString=function(){var t=255*this.r|0,r=255*this.g|0,n=255*this.b|0;return"#"+i.ToHex(t)+i.ToHex(r)+i.ToHex(n)},r.prototype.toLinearSpace=function(){var t=new r;return this.toLinearSpaceToRef(t),t},r.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},r.prototype.toGammaSpace=function(){var t=new r;return this.toGammaSpaceToRef(t),t},r.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},r.FromHexString=function(t){if("#"!==t.substring(0,1)||7!==t.length)return new r(0,0,0);var i=parseInt(t.substring(1,3),16),n=parseInt(t.substring(3,5),16),o=parseInt(t.substring(5,7),16);return r.FromInts(i,n,o)},r.FromArray=function(t,i){return void 0===i&&(i=0),new r(t[i],t[i+1],t[i+2])},r.FromInts=function(t,i,n){return new r(t/255,i/255,n/255)},r.Lerp=function(t,i,n){var o=t.r+(i.r-t.r)*n,e=t.g+(i.g-t.g)*n,s=t.b+(i.b-t.b)*n;return new r(o,e,s)},r.Red=function(){return new r(1,0,0)},r.Green=function(){return new r(0,1,0)},r.Blue=function(){return new r(0,0,1)},r.Black=function(){return new r(0,0,0)},r.White=function(){return new r(1,1,1)},r.Purple=function(){return new r(.5,0,.5)},r.Magenta=function(){return new r(1,0,1)},r.Yellow=function(){return new r(1,1,0)},r.Gray=function(){return new r(.5,.5,.5)},r}();t.Color3=r;var n=function(){function t(t,i,r,n){this.r=t,this.g=i,this.b=r,this.a=n}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,r=255*this.g|0,n=255*this.b|0,o=255*this.a|0;return"#"+i.ToHex(t)+i.ToHex(r)+i.ToHex(n)+i.ToHex(o)},t.FromHexString=function(i){if("#"!==i.substring(0,1)||9!==i.length)return new t(0,0,0,0);var r=parseInt(i.substring(1,3),16),n=parseInt(i.substring(3,5),16),o=parseInt(i.substring(5,7),16),e=parseInt(i.substring(7,9),16);return t.FromInts(r,n,o,e)},t.Lerp=function(i,r,n){var o=new t(0,0,0,0);return t.LerpToRef(i,r,n,o),o},t.LerpToRef=function(t,i,r,n){n.r=t.r+(i.r-t.r)*r,n.g=t.g+(i.g-t.g)*r,n.b=t.b+(i.b-t.b)*r,n.a=t.a+(i.a-t.a)*r},t.FromArray=function(i,r){return void 0===r&&(r=0),new t(i[r],i[r+1],i[r+2],i[r+3])},t.FromInts=function(i,r,n,o){return new t(i/255,r/255,n/255,o/255)},t.CheckColors4=function(t,i){if(t.length===3*i){for(var r=[],n=0;nn.x?n.x:o,o=on.y?n.y:e,e=ei.x?t.x:i.x,o=t.y>i.y?t.y:i.y;return new r(n,o)},r.Transform=function(t,i){var n=r.Zero();return r.TransformToRef(t,i,n),n},r.TransformToRef=function(t,i,r){var n=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];r.x=n,r.y=o},r.PointInTriangle=function(t,i,r,n){var o=.5*(-r.y*n.x+i.y*(-r.x+n.x)+i.x*(r.y-n.y)+r.x*n.y),e=o<0?-1:1,s=(i.y*n.x-i.x*n.y+(n.y-i.y)*t.x+(i.x-n.x)*t.y)*e,h=(i.x*r.y-i.y*r.x+(i.y-r.y)*t.x+(r.x-i.x)*t.y)*e;return s>0&&h>0&&s+h<2*o*e},r.Distance=function(t,i){return Math.sqrt(r.DistanceSquared(t,i))},r.DistanceSquared=function(t,i){var r=t.x-i.x,n=t.y-i.y;return r*r+n*n},r.Center=function(t,i){var r=t.add(i);return r.scaleInPlace(.5),r},r.DistanceOfPointFromSegment=function(t,i,n){var o=r.DistanceSquared(i,n);if(0===o)return r.Distance(t,i);var e=n.subtract(i),s=Math.max(0,Math.min(1,r.Dot(t.subtract(i),e)/o)),h=i.add(e.multiplyByFloats(s,s));return r.Distance(t,h)},r}();t.Vector2=o;var e=function(){function r(t,i,r){this.x=t,this.y=i,this.z=r}return r.prototype.toString=function(){return"{X: "+this.x+" Y:"+this.y+" Z:"+this.z+"}"},r.prototype.getClassName=function(){return"Vector3"},r.prototype.getHashCode=function(){var t=this.x||0;return t=397*t^(this.y||0),t=397*t^(this.z||0)},r.prototype.asArray=function(){var t=[];return this.toArray(t,0),t},r.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},r.prototype.toQuaternion=function(){var t=new a(0,0,0,1),i=Math.cos(.5*(this.x+this.z)),r=Math.sin(.5*(this.x+this.z)),n=Math.cos(.5*(this.z-this.x)),o=Math.sin(.5*(this.z-this.x)),e=Math.cos(.5*this.y),s=Math.sin(.5*this.y);return t.x=n*s,t.y=-o*s,t.z=r*e,t.w=i*e,t},r.prototype.addInPlace=function(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this},r.prototype.add=function(t){return new r(this.x+t.x,this.y+t.y,this.z+t.z)},r.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},r.prototype.subtractInPlace=function(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this},r.prototype.subtract=function(t){return new r(this.x-t.x,this.y-t.y,this.z-t.z)},r.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},r.prototype.subtractFromFloats=function(t,i,n){return new r(this.x-t,this.y-i,this.z-n)},r.prototype.subtractFromFloatsToRef=function(t,i,r,n){return n.x=this.x-t,n.y=this.y-i,n.z=this.z-r,this},r.prototype.negate=function(){return new r((-this.x),(-this.y),(-this.z))},r.prototype.scaleInPlace=function(t){return this.x*=t,this.y*=t,this.z*=t,this},r.prototype.scale=function(t){return new r(this.x*t,this.y*t,this.z*t)},r.prototype.scaleToRef=function(t,i){i.x=this.x*t,i.y=this.y*t,i.z=this.z*t},r.prototype.equals=function(t){return t&&this.x===t.x&&this.y===t.y&&this.z===t.z},r.prototype.equalsWithEpsilon=function(r,n){return void 0===n&&(n=t.Epsilon),r&&i.WithinEpsilon(this.x,r.x,n)&&i.WithinEpsilon(this.y,r.y,n)&&i.WithinEpsilon(this.z,r.z,n)},r.prototype.equalsToFloats=function(t,i,r){return this.x===t&&this.y===i&&this.z===r},r.prototype.multiplyInPlace=function(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this},r.prototype.multiply=function(t){return new r(this.x*t.x,this.y*t.y,this.z*t.z)},r.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},r.prototype.multiplyByFloats=function(t,i,n){return new r(this.x*t,this.y*i,this.z*n)},r.prototype.divide=function(t){return new r(this.x/t.x,this.y/t.y,this.z/t.z)},r.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},r.prototype.MinimizeInPlace=function(t){return t.xthis.x&&(this.x=t.x),t.y>this.y&&(this.y=t.y),t.z>this.z&&(this.z=t.z),this},r.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},r.prototype.lengthSquared=function(){return this.x*this.x+this.y*this.y+this.z*this.z},r.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},r.prototype.clone=function(){return new r(this.x,this.y,this.z)},r.prototype.copyFrom=function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this},r.prototype.copyFromFloats=function(t,i,r){return this.x=t,this.y=i,this.z=r,this},r.GetClipFactor=function(t,i,n,o){var e=r.Dot(t,n)-o,s=r.Dot(i,n)-o,h=e/(e-s);return h},r.FromArray=function(t,i){return i||(i=0),new r(t[i],t[i+1],t[i+2])},r.FromFloatArray=function(t,i){return i||(i=0),new r(t[i],t[i+1],t[i+2])},r.FromArrayToRef=function(t,i,r){r.x=t[i],r.y=t[i+1],r.z=t[i+2]},r.FromFloatArrayToRef=function(t,i,r){r.x=t[i],r.y=t[i+1],r.z=t[i+2]},r.FromFloatsToRef=function(t,i,r,n){n.x=t,n.y=i,n.z=r},r.Zero=function(){return new r(0,0,0)},r.Up=function(){return new r(0,1,0)},r.Forward=function(){return new r(0,0,1)},r.Right=function(){return new r(1,0,0)},r.Left=function(){return new r((-1),0,0)},r.TransformCoordinates=function(t,i){var n=r.Zero();return r.TransformCoordinatesToRef(t,i,n),n},r.TransformCoordinatesToRef=function(t,i,r){var n=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],e=t.x*i.m[2]+t.y*i.m[6]+t.z*i.m[10]+i.m[14],s=t.x*i.m[3]+t.y*i.m[7]+t.z*i.m[11]+i.m[15];r.x=n/s,r.y=o/s,r.z=e/s},r.TransformCoordinatesFromFloatsToRef=function(t,i,r,n,o){var e=t*n.m[0]+i*n.m[4]+r*n.m[8]+n.m[12],s=t*n.m[1]+i*n.m[5]+r*n.m[9]+n.m[13],h=t*n.m[2]+i*n.m[6]+r*n.m[10]+n.m[14],a=t*n.m[3]+i*n.m[7]+r*n.m[11]+n.m[15];o.x=e/a,o.y=s/a,o.z=h/a},r.TransformNormal=function(t,i){var n=r.Zero();return r.TransformNormalToRef(t,i,n),n},r.TransformNormalToRef=function(t,i,r){var n=t.x*i.m[0]+t.y*i.m[4]+t.z*i.m[8],o=t.x*i.m[1]+t.y*i.m[5]+t.z*i.m[9],e=t.x*i.m[2]+t.y*i.m[6]+t.z*i.m[10];r.x=n,r.y=o,r.z=e},r.TransformNormalFromFloatsToRef=function(t,i,r,n,o){o.x=t*n.m[0]+i*n.m[4]+r*n.m[8],o.y=t*n.m[1]+i*n.m[5]+r*n.m[9],o.z=t*n.m[2]+i*n.m[6]+r*n.m[10]},r.CatmullRom=function(t,i,n,o,e){var s=e*e,h=e*s,a=.5*(2*i.x+(-t.x+n.x)*e+(2*t.x-5*i.x+4*n.x-o.x)*s+(-t.x+3*i.x-3*n.x+o.x)*h),u=.5*(2*i.y+(-t.y+n.y)*e+(2*t.y-5*i.y+4*n.y-o.y)*s+(-t.y+3*i.y-3*n.y+o.y)*h),m=.5*(2*i.z+(-t.z+n.z)*e+(2*t.z-5*i.z+4*n.z-o.z)*s+(-t.z+3*i.z-3*n.z+o.z)*h);return new r(a,u,m)},r.Clamp=function(t,i,n){var o=t.x;o=o>n.x?n.x:o,o=on.y?n.y:e,e=en.z?n.z:s,s=sthis.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},r.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},r.prototype.lengthSquared=function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},r.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},r.prototype.toVector3=function(){return new e(this.x,this.y,this.z)},r.prototype.clone=function(){return new r(this.x,this.y,this.z,this.w)},r.prototype.copyFrom=function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w,this},r.prototype.copyFromFloats=function(t,i,r,n){return this.x=t,this.y=i,this.z=r,this.w=n,this},r.FromArray=function(t,i){return i||(i=0),new r(t[i],t[i+1],t[i+2],t[i+3])},r.FromArrayToRef=function(t,i,r){r.x=t[i],r.y=t[i+1],r.z=t[i+2],r.w=t[i+3]},r.FromFloatArrayToRef=function(t,i,r){r.x=t[i],r.y=t[i+1],r.z=t[i+2],r.w=t[i+3]},r.FromFloatsToRef=function(t,i,r,n,o){o.x=t,o.y=i,o.z=r,o.w=n},r.Zero=function(){return new r(0,0,0,0)},r.Normalize=function(t){var i=r.Zero();return r.NormalizeToRef(t,i),i},r.NormalizeToRef=function(t,i){i.copyFrom(t),i.normalize()},r.Minimize=function(t,i){var r=t.clone();return r.MinimizeInPlace(i),r},r.Maximize=function(t,i){var r=t.clone();return r.MaximizeInPlace(i),r},r.Distance=function(t,i){return Math.sqrt(r.DistanceSquared(t,i))},r.DistanceSquared=function(t,i){var r=t.x-i.x,n=t.y-i.y,o=t.z-i.z,e=t.w-i.w;return r*r+n*n+o*o+e*e},r.Center=function(t,i){var r=t.add(i);return r.scaleInPlace(.5),r},r}();t.Vector4=s;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.copyFromFloats=function(t,i){this.width=t,this.height=i},t.prototype.multiplyByFloats=function(i,r){return new t(this.width*i,this.height*r)},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)},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 r=new t(this.width+i.width,this.height+i.height);return r},t.prototype.substract=function(i){var r=new t(this.width-i.width,this.height-i.height);return r},t.Lerp=function(i,r,n){var o=i.width+(r.width-i.width)*n,e=i.height+(r.height-i.height)*n;return new t(o,e)},t}();t.Size=h;var a=function(){function t(t,i,r,n){void 0===t&&(t=0),void 0===i&&(i=0),void 0===r&&(r=0),void 0===n&&(n=1),this.x=t,this.y=i,this.z=r,this.w=n}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,r,n){return this.x=t,this.y=i,this.z=r,this.w=n,this},t.prototype.add=function(i){return new t(this.x+i.x,this.y+i.y,this.z+i.z,this.w+i.w)},t.prototype.subtract=function(i){return new t(this.x-i.x,this.y-i.y,this.z-i.z,this.w-i.w)},t.prototype.scale=function(i){return new t(this.x*i,this.y*i,this.z*i,this.w*i)},t.prototype.multiply=function(i){var r=new t(0,0,0,1);return this.multiplyToRef(i,r),r},t.prototype.multiplyToRef=function(t,i){var r=this.x*t.w+this.y*t.z-this.z*t.y+this.w*t.x,n=-this.x*t.z+this.y*t.w+this.z*t.x+this.w*t.y,o=this.x*t.y-this.y*t.x+this.z*t.w+this.w*t.z,e=-this.x*t.x-this.y*t.y-this.z*t.z+this.w*t.w;return i.copyFromFloats(r,n,o,e),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=e.Zero();return this.toEulerAnglesToRef(i,t),i},t.prototype.toEulerAnglesToRef=function(t,i){void 0===i&&(i="YZX");var r=this.z,n=this.x,o=this.y,e=this.w,s=e*e,h=r*r,a=n*n,u=o*o,m=o*r-n*e,y=.4999999;return m<-y?(t.y=2*Math.atan2(o,e),t.x=Math.PI/2,t.z=0):m>y?(t.y=2*Math.atan2(o,e),t.x=-Math.PI/2,t.z=0):(t.z=Math.atan2(2*(n*o+r*e),-h-a+u+s),t.x=Math.asin(-2*(r*o-n*e)),t.y=Math.atan2(2*(r*n+o*e),h-a-u+s)),this},t.prototype.toRotationMatrix=function(t){var i=this.x*this.x,r=this.y*this.y,n=this.z*this.z,o=this.x*this.y,e=this.z*this.w,s=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*(r+n),t.m[1]=2*(o+e),t.m[2]=2*(s-h),t.m[3]=0,t.m[4]=2*(o-e),t.m[5]=1-2*(n+i),t.m[6]=2*(a+u),t.m[7]=0,t.m[8]=2*(s+h),t.m[9]=2*(a-u),t.m[10]=1-2*(r+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 r=new t;return t.FromRotationMatrixToRef(i,r),r},t.FromRotationMatrixToRef=function(t,i){var r,n=t.m,o=n[0],e=n[4],s=n[8],h=n[1],a=n[5],u=n[9],m=n[2],y=n[6],c=n[10],p=o+a+c;p>0?(r=.5/Math.sqrt(p+1),i.w=.25/r,i.x=(y-u)*r,i.y=(s-m)*r,i.z=(h-e)*r):o>a&&o>c?(r=2*Math.sqrt(1+o-a-c),i.w=(y-u)/r,i.x=.25*r,i.y=(e+h)/r,i.z=(s+m)/r):a>c?(r=2*Math.sqrt(1+a-o-c),i.w=(s-m)/r,i.x=(e+h)/r,i.y=.25*r,i.z=(u+y)/r):(r=2*Math.sqrt(1+c-o-a),i.w=(h-e)/r,i.x=(s+m)/r,i.y=(u+y)/r,i.z=.25*r)},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,r){return t.RotationAxisToRef(i,r,new t)},t.RotationAxisToRef=function(t,i,r){var 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},t.FromArray=function(i,r){return r||(r=0),new t(i[r],i[r+1],i[r+2],i[r+3])},t.RotationYawPitchRoll=function(i,r,n){var o=new t;return t.RotationYawPitchRollToRef(i,r,n,o),o},t.RotationYawPitchRollToRef=function(t,i,r,n){var o=.5*r,e=.5*i,s=.5*t,h=Math.sin(o),a=Math.cos(o),u=Math.sin(e),m=Math.cos(e),y=Math.sin(s),c=Math.cos(s);n.x=c*u*a+y*m*h,n.y=y*m*a-c*u*h,n.z=c*m*h-y*u*a,n.w=c*m*a+y*u*h},t.RotationAlphaBetaGamma=function(i,r,n){var o=new t;return t.RotationAlphaBetaGammaToRef(i,r,n,o),o},t.RotationAlphaBetaGammaToRef=function(t,i,r,n){var o=.5*(r+t),e=.5*(r-t),s=.5*i;n.x=Math.cos(e)*Math.sin(s),n.y=Math.sin(e)*Math.sin(s),n.z=Math.sin(o)*Math.cos(s),n.w=Math.cos(o)*Math.cos(s)},t.Slerp=function(i,r,n){var o=t.Identity();return t.SlerpToRef(i,r,n,o),o},t.SlerpToRef=function(t,i,r,n){var o,e,s=r,h=t.x*i.x+t.y*i.y+t.z*i.z+t.w*i.w,a=!1;if(h<0&&(a=!0,h=-h),h>.999999)e=1-s,o=a?-s:s;else{var u=Math.acos(h),m=1/Math.sin(u);e=Math.sin((1-s)*u)*m,o=a?-Math.sin(s*u)*m:Math.sin(s*u)*m}n.x=e*t.x+o*i.x,n.y=e*t.y+o*i.y,n.z=e*t.z+o*i.z,n.w=e*t.w+o*i.w},t}();t.Quaternion=a;var u=function(){function r(){this.m=new Float32Array(16)}return r.prototype.isIdentity=function(){return 1===this.m[0]&&1===this.m[5]&&1===this.m[10]&&1===this.m[15]&&(0===this.m[1]&&0===this.m[2]&&0===this.m[3]&&0===this.m[4]&&0===this.m[6]&&0===this.m[7]&&0===this.m[8]&&0===this.m[9]&&0===this.m[11]&&0===this.m[12]&&0===this.m[13]&&0===this.m[14])},r.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],r=this.m[9]*this.m[14]-this.m[10]*this.m[13],n=this.m[8]*this.m[15]-this.m[11]*this.m[12],o=this.m[8]*this.m[14]-this.m[10]*this.m[12],e=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]*r)-this.m[1]*(this.m[4]*t-this.m[6]*n+this.m[7]*o)+this.m[2]*(this.m[4]*i-this.m[5]*n+this.m[7]*e)-this.m[3]*(this.m[4]*r-this.m[5]*o+this.m[6]*e)},r.prototype.toArray=function(){return this.m},r.prototype.asArray=function(){return this.toArray()},r.prototype.invert=function(){return this.invertToRef(this),this},r.prototype.reset=function(){for(var t=0;t<16;t++)this.m[t]=0;return this},r.prototype.add=function(t){var i=new r;return this.addToRef(t,i),i},r.prototype.addToRef=function(t,i){for(var r=0;r<16;r++)i.m[r]=this.m[r]+t.m[r];return this},r.prototype.addToSelf=function(t){for(var i=0;i<16;i++)this.m[i]+=t.m[i];return this},r.prototype.invertToRef=function(t){var i=this.m[0],r=this.m[1],n=this.m[2],o=this.m[3],e=this.m[4],s=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],x=this.m[14],l=this.m[15],z=y*l-c*x,w=m*l-c*f,v=m*x-y*f,d=u*l-c*p,g=u*x-y*p,R=u*f-m*p,T=s*z-h*w+a*v,_=-(e*z-h*d+a*g),M=e*w-s*d+a*R,A=-(e*v-s*g+h*R),F=1/(i*T+r*_+n*M+o*A),b=h*l-a*x,L=s*l-a*f,C=s*x-h*f,P=e*l-a*p,Z=e*x-h*p,S=e*f-s*p,I=h*c-a*y,H=s*c-a*m,V=s*y-h*m,q=e*c-a*u,D=e*y-h*u,N=e*m-s*u;return t.m[0]=T*F,t.m[4]=_*F,t.m[8]=M*F,t.m[12]=A*F,t.m[1]=-(r*z-n*w+o*v)*F,t.m[5]=(i*z-n*d+o*g)*F,t.m[9]=-(i*w-r*d+o*R)*F,t.m[13]=(i*v-r*g+n*R)*F,t.m[2]=(r*b-n*L+o*C)*F,t.m[6]=-(i*b-n*P+o*Z)*F,t.m[10]=(i*L-r*P+o*S)*F,t.m[14]=-(i*C-r*Z+n*S)*F,t.m[3]=-(r*I-n*H+o*V)*F,t.m[7]=(i*I-n*q+o*D)*F,t.m[11]=-(i*H-r*q+o*N)*F,t.m[15]=(i*V-r*D+n*N)*F,this},r.prototype.setTranslation=function(t){return this.m[12]=t.x,this.m[13]=t.y,this.m[14]=t.z,this},r.prototype.getTranslation=function(){return new e(this.m[12],this.m[13],this.m[14])},r.prototype.multiply=function(t){var i=new r;return this.multiplyToRef(t,i),i},r.prototype.copyFrom=function(t){\nfor(var i=0;i<16;i++)this.m[i]=t.m[i];return this},r.prototype.copyToArray=function(t,i){void 0===i&&(i=0);for(var r=0;r<16;r++)t[i+r]=this.m[r];return this},r.prototype.multiplyToRef=function(t,i){return this.multiplyToArray(t,i.m,0),this},r.prototype.multiplyToArray=function(t,i,r){var n=this.m[0],o=this.m[1],e=this.m[2],s=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],x=this.m[12],l=this.m[13],z=this.m[14],w=this.m[15],v=t.m[0],d=t.m[1],g=t.m[2],R=t.m[3],T=t.m[4],_=t.m[5],M=t.m[6],A=t.m[7],F=t.m[8],b=t.m[9],L=t.m[10],C=t.m[11],P=t.m[12],Z=t.m[13],S=t.m[14],I=t.m[15];return i[r]=n*v+o*T+e*F+s*P,i[r+1]=n*d+o*_+e*b+s*Z,i[r+2]=n*g+o*M+e*L+s*S,i[r+3]=n*R+o*A+e*C+s*I,i[r+4]=h*v+a*T+u*F+m*P,i[r+5]=h*d+a*_+u*b+m*Z,i[r+6]=h*g+a*M+u*L+m*S,i[r+7]=h*R+a*A+u*C+m*I,i[r+8]=y*v+c*T+p*F+f*P,i[r+9]=y*d+c*_+p*b+f*Z,i[r+10]=y*g+c*M+p*L+f*S,i[r+11]=y*R+c*A+p*C+f*I,i[r+12]=x*v+l*T+z*F+w*P,i[r+13]=x*d+l*_+z*b+w*Z,i[r+14]=x*g+l*M+z*L+w*S,i[r+15]=x*R+l*A+z*C+w*I,this},r.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]},r.prototype.clone=function(){return r.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])},r.prototype.getClassName=function(){return"Matrix"},r.prototype.getHashCode=function(){for(var t=this.m[0]||0,i=1;i<16;i++)t=397*t^(this.m[i]||0);return t},r.prototype.decompose=function(t,n,o){o.x=this.m[12],o.y=this.m[13],o.z=this.m[14];var e=i.Sign(this.m[0]*this.m[1]*this.m[2]*this.m[3])<0?-1:1,s=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;return t.x=e*Math.sqrt(this.m[0]*this.m[0]+this.m[1]*this.m[1]+this.m[2]*this.m[2]),t.y=s*Math.sqrt(this.m[4]*this.m[4]+this.m[5]*this.m[5]+this.m[6]*this.m[6]),t.z=h*Math.sqrt(this.m[8]*this.m[8]+this.m[9]*this.m[9]+this.m[10]*this.m[10]),0===t.x||0===t.y||0===t.z?(n.x=0,n.y=0,n.z=0,n.w=1,!1):(r.FromValuesToRef(this.m[0]/t.x,this.m[1]/t.x,this.m[2]/t.x,0,this.m[4]/t.y,this.m[5]/t.y,this.m[6]/t.y,0,this.m[8]/t.z,this.m[9]/t.z,this.m[10]/t.z,0,0,0,0,1,A.Matrix[0]),a.FromRotationMatrixToRef(A.Matrix[0],n),!0)},r.prototype.getRotationMatrix=function(){var t=r.Identity();return this.getRotationMatrixToRef(t),t},r.prototype.getRotationMatrixToRef=function(t){var i=this.m,n=i[0]*i[1]*i[2]*i[3]<0?-1:1,o=i[4]*i[5]*i[6]*i[7]<0?-1:1,e=i[8]*i[9]*i[10]*i[11]<0?-1:1,s=n*Math.sqrt(i[0]*i[0]+i[1]*i[1]+i[2]*i[2]),h=o*Math.sqrt(i[4]*i[4]+i[5]*i[5]+i[6]*i[6]),a=e*Math.sqrt(i[8]*i[8]+i[9]*i[9]+i[10]*i[10]);r.FromValuesToRef(i[0]/s,i[1]/s,i[2]/s,0,i[4]/h,i[5]/h,i[6]/h,0,i[8]/a,i[9]/a,i[10]/a,0,0,0,0,1,t)},r.FromArray=function(t,i){var n=new r;return i||(i=0),r.FromArrayToRef(t,i,n),n},r.FromArrayToRef=function(t,i,r){for(var n=0;n<16;n++)r.m[n]=t[n+i]},r.FromFloat32ArrayToRefScaled=function(t,i,r,n){for(var o=0;o<16;o++)n.m[o]=t[o+i]*r},r.FromValuesToRef=function(t,i,r,n,o,e,s,h,a,u,m,y,c,p,f,x,l){l.m[0]=t,l.m[1]=i,l.m[2]=r,l.m[3]=n,l.m[4]=o,l.m[5]=e,l.m[6]=s,l.m[7]=h,l.m[8]=a,l.m[9]=u,l.m[10]=m,l.m[11]=y,l.m[12]=c,l.m[13]=p,l.m[14]=f,l.m[15]=x},r.prototype.getRow=function(t){if(t<0||t>3)return null;var i=4*t;return new s(this.m[i+0],this.m[i+1],this.m[i+2],this.m[i+3])},r.prototype.setRow=function(t,i){if(t<0||t>3)return this;var r=4*t;return this.m[r+0]=i.x,this.m[r+1]=i.y,this.m[r+2]=i.z,this.m[r+3]=i.w,this},r.FromValues=function(t,i,n,o,e,s,h,a,u,m,y,c,p,f,x,l){var z=new r;return z.m[0]=t,z.m[1]=i,z.m[2]=n,z.m[3]=o,z.m[4]=e,z.m[5]=s,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]=x,z.m[15]=l,z},r.Compose=function(t,i,n){var o=r.FromValues(t.x,0,0,0,0,t.y,0,0,0,0,t.z,0,0,0,0,1),e=r.Identity();return i.toRotationMatrix(e),o=o.multiply(e),o.setTranslation(n),o},r.Identity=function(){return r.FromValues(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1)},r.IdentityToRef=function(t){r.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,t)},r.Zero=function(){return r.FromValues(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)},r.RotationX=function(t){var i=new r;return r.RotationXToRef(t,i),i},r.Invert=function(t){var i=new r;return t.invertToRef(i),i},r.RotationXToRef=function(t,i){var r=Math.sin(t),n=Math.cos(t);i.m[0]=1,i.m[15]=1,i.m[5]=n,i.m[10]=n,i.m[9]=-r,i.m[6]=r,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},r.RotationY=function(t){var i=new r;return r.RotationYToRef(t,i),i},r.RotationYToRef=function(t,i){var r=Math.sin(t),n=Math.cos(t);i.m[5]=1,i.m[15]=1,i.m[0]=n,i.m[2]=-r,i.m[8]=r,i.m[10]=n,i.m[1]=0,i.m[3]=0,i.m[4]=0,i.m[6]=0,i.m[7]=0,i.m[9]=0,i.m[11]=0,i.m[12]=0,i.m[13]=0,i.m[14]=0},r.RotationZ=function(t){var i=new r;return r.RotationZToRef(t,i),i},r.RotationZToRef=function(t,i){var r=Math.sin(t),n=Math.cos(t);i.m[10]=1,i.m[15]=1,i.m[0]=n,i.m[1]=r,i.m[4]=-r,i.m[5]=n,i.m[2]=0,i.m[3]=0,i.m[6]=0,i.m[7]=0,i.m[8]=0,i.m[9]=0,i.m[11]=0,i.m[12]=0,i.m[13]=0,i.m[14]=0},r.RotationAxis=function(t,i){var n=r.Zero();return r.RotationAxisToRef(t,i,n),n},r.RotationAxisToRef=function(t,i,r){var n=Math.sin(-i),o=Math.cos(-i),e=1-o;t.normalize(),r.m[0]=t.x*t.x*e+o,r.m[1]=t.x*t.y*e-t.z*n,r.m[2]=t.x*t.z*e+t.y*n,r.m[3]=0,r.m[4]=t.y*t.x*e+t.z*n,r.m[5]=t.y*t.y*e+o,r.m[6]=t.y*t.z*e-t.x*n,r.m[7]=0,r.m[8]=t.z*t.x*e-t.y*n,r.m[9]=t.z*t.y*e+t.x*n,r.m[10]=t.z*t.z*e+o,r.m[11]=0,r.m[15]=1},r.RotationYawPitchRoll=function(t,i,n){var o=new r;return r.RotationYawPitchRollToRef(t,i,n,o),o},r.RotationYawPitchRollToRef=function(t,i,r,n){a.RotationYawPitchRollToRef(t,i,r,this._tempQuaternion),this._tempQuaternion.toRotationMatrix(n)},r.Scaling=function(t,i,n){var o=r.Zero();return r.ScalingToRef(t,i,n,o),o},r.ScalingToRef=function(t,i,r,n){n.m[0]=t,n.m[1]=0,n.m[2]=0,n.m[3]=0,n.m[4]=0,n.m[5]=i,n.m[6]=0,n.m[7]=0,n.m[8]=0,n.m[9]=0,n.m[10]=r,n.m[11]=0,n.m[12]=0,n.m[13]=0,n.m[14]=0,n.m[15]=1},r.Translation=function(t,i,n){var o=r.Identity();return r.TranslationToRef(t,i,n,o),o},r.TranslationToRef=function(t,i,n,o){r.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,t,i,n,1,o)},r.Lerp=function(t,i,n){for(var o=r.Zero(),e=0;e<16;e++)o.m[e]=t.m[e]*(1-n)+i.m[e]*n;return o},r.DecomposeLerp=function(t,i,n){var o=new e(0,0,0),s=new a,h=new e(0,0,0);t.decompose(o,s,h);var u=new e(0,0,0),m=new a,y=new e(0,0,0);i.decompose(u,m,y);var c=e.Lerp(o,u,n),p=a.Slerp(s,m,n),f=e.Lerp(h,y,n);return r.Compose(c,p,f)},r.LookAtLH=function(t,i,n){var o=r.Zero();return r.LookAtLHToRef(t,i,n,o),o},r.LookAtLHToRef=function(t,i,n,o){i.subtractToRef(t,this._zAxis),this._zAxis.normalize(),e.CrossToRef(n,this._zAxis,this._xAxis),0===this._xAxis.lengthSquared()?this._xAxis.x=1:this._xAxis.normalize(),e.CrossToRef(this._zAxis,this._xAxis,this._yAxis),this._yAxis.normalize();var s=-e.Dot(this._xAxis,t),h=-e.Dot(this._yAxis,t),a=-e.Dot(this._zAxis,t);return r.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,h,a,1,o)},r.LookAtRH=function(t,i,n){var o=r.Zero();return r.LookAtRHToRef(t,i,n,o),o},r.LookAtRHToRef=function(t,i,n,o){t.subtractToRef(i,this._zAxis),this._zAxis.normalize(),e.CrossToRef(n,this._zAxis,this._xAxis),0===this._xAxis.lengthSquared()?this._xAxis.x=1:this._xAxis.normalize(),e.CrossToRef(this._zAxis,this._xAxis,this._yAxis),this._yAxis.normalize();var s=-e.Dot(this._xAxis,t),h=-e.Dot(this._yAxis,t),a=-e.Dot(this._zAxis,t);return r.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,h,a,1,o)},r.OrthoLH=function(t,i,n,o){var e=r.Zero();return r.OrthoLHToRef(t,i,n,o,e),e},r.OrthoLHToRef=function(i,r,n,o,e){var s=n,h=o,a=2/i,u=2/r,m=2/(h-s),y=-(h+s)/(h-s);t.Matrix.FromValuesToRef(a,0,0,0,0,u,0,0,0,0,m,0,0,0,y,1,e)},r.OrthoOffCenterLH=function(t,i,n,o,e,s){var h=r.Zero();return r.OrthoOffCenterLHToRef(t,i,n,o,e,s,h),h},r.OrthoOffCenterLHToRef=function(i,r,n,o,e,s,h){var a=e,u=s,m=2/(r-i),y=2/(o-n),c=2/(u-a),p=-(u+a)/(u-a),f=(i+r)/(i-r),x=(o+n)/(n-o);t.Matrix.FromValuesToRef(m,0,0,0,0,y,0,0,0,0,c,0,f,x,p,1,h)},r.OrthoOffCenterRH=function(t,i,n,o,e,s){var h=r.Zero();return r.OrthoOffCenterRHToRef(t,i,n,o,e,s,h),h},r.OrthoOffCenterRHToRef=function(t,i,n,o,e,s,h){r.OrthoOffCenterLHToRef(t,i,n,o,e,s,h),h.m[10]*=-1},r.PerspectiveLH=function(i,n,o,e){var s=r.Zero(),h=o,a=e,u=2*h/i,m=2*h/n,y=(a+h)/(a-h),c=-2*a*h/(a-h);return t.Matrix.FromValuesToRef(u,0,0,0,0,m,0,0,0,0,y,1,0,0,c,0,s),s},r.PerspectiveFovLH=function(t,i,n,o){var e=r.Zero();return r.PerspectiveFovLHToRef(t,i,n,o,e),e},r.PerspectiveFovLHToRef=function(i,r,n,o,e,s){void 0===s&&(s=!0);var h=n,a=o,u=1/Math.tan(.5*i),m=s?u/r:u,y=s?u:u*r,c=(a+h)/(a-h),p=-2*a*h/(a-h);t.Matrix.FromValuesToRef(m,0,0,0,0,y,0,0,0,0,c,1,0,0,p,0,e)},r.PerspectiveFovRH=function(t,i,n,o){var e=r.Zero();return r.PerspectiveFovRHToRef(t,i,n,o,e),e},r.PerspectiveFovRHToRef=function(i,r,n,o,e,s){void 0===s&&(s=!0);var h=n,a=o,u=1/Math.tan(.5*i),m=s?u/r:u,y=s?u:u*r,c=-(a+h)/(a-h),p=-2*a*h/(a-h);t.Matrix.FromValuesToRef(m,0,0,0,0,y,0,0,0,0,c,-1,0,0,p,0,e)},r.PerspectiveFovWebVRToRef=function(t,i,r,n,o){void 0===o&&(o=!0);var e=Math.tan(t.upDegrees*Math.PI/180),s=Math.tan(t.downDegrees*Math.PI/180),h=Math.tan(t.leftDegrees*Math.PI/180),a=Math.tan(t.rightDegrees*Math.PI/180),u=2/(h+a),m=2/(e+s);n.m[0]=u,n.m[1]=n.m[2]=n.m[3]=n.m[4]=0,n.m[5]=m,n.m[6]=n.m[7]=0,n.m[8]=(h-a)*u*.5,n.m[9]=-((e-s)*m*.5),n.m[10]=-(i+r)/(r-i),n.m[11]=1,n.m[12]=n.m[13]=n.m[15]=0,n.m[14]=-(2*r*i)/(r-i)},r.GetFinalMatrix=function(t,i,n,o,e,s){var h=t.width,a=t.height,u=t.x,m=t.y,y=r.FromValues(h/2,0,0,0,0,-a/2,0,0,0,0,s-e,0,u+h/2,a/2+m,e,1);return i.multiply(n).multiply(o).multiply(y)},r.GetAsMatrix2x2=function(t){return new Float32Array([t.m[0],t.m[1],t.m[4],t.m[5]])},r.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]])},r.Transpose=function(t){var i=new r;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},r.Reflection=function(t){var i=new r;return r.ReflectionToRef(t,i),i},r.ReflectionToRef=function(t,i){t.normalize();var r=t.normal.x,n=t.normal.y,o=t.normal.z,e=-2*r,s=-2*n,h=-2*o;i.m[0]=e*r+1,i.m[1]=s*r,i.m[2]=h*r,i.m[3]=0,i.m[4]=e*n,i.m[5]=s*n+1,i.m[6]=h*n,i.m[7]=0,i.m[8]=e*o,i.m[9]=s*o,i.m[10]=h*o+1,i.m[11]=0,i.m[12]=e*t.d,i.m[13]=s*t.d,i.m[14]=h*t.d,i.m[15]=1},r.FromXYZAxesToRef=function(t,i,r,n){n.m[0]=t.x,n.m[1]=t.y,n.m[2]=t.z,n.m[3]=0,n.m[4]=i.x,n.m[5]=i.y,n.m[6]=i.z,n.m[7]=0,n.m[8]=r.x,n.m[9]=r.y,n.m[10]=r.z,n.m[11]=0,n.m[12]=0,n.m[13]=0,n.m[14]=0,n.m[15]=1},r.FromQuaternionToRef=function(t,i){var r=t.x*t.x,n=t.y*t.y,o=t.z*t.z,e=t.x*t.y,s=t.z*t.w,h=t.z*t.x,a=t.y*t.w,u=t.y*t.z,m=t.x*t.w;i.m[0]=1-2*(n+o),i.m[1]=2*(e+s),i.m[2]=2*(h-a),i.m[3]=0,i.m[4]=2*(e-s),i.m[5]=1-2*(o+r),i.m[6]=2*(u+m),i.m[7]=0,i.m[8]=2*(h+a),i.m[9]=2*(u-m),i.m[10]=1-2*(n+r),i.m[11]=0,i.m[12]=0,i.m[13]=0,i.m[14]=0,i.m[15]=1},r}();u._tempQuaternion=new a,u._xAxis=e.Zero(),u._yAxis=e.Zero(),u._zAxis=e.Zero(),t.Matrix=u;var m=function(){function t(t,i,r,n){this.normal=new e(t,i,r),this.d=n}return t.prototype.asArray=function(){return[this.normal.x,this.normal.y,this.normal.z,this.d]},t.prototype.clone=function(){return new t(this.normal.x,this.normal.y,this.normal.z,this.d)},t.prototype.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 r=u.Transpose(i),n=this.normal.x,o=this.normal.y,e=this.normal.z,s=this.d,h=n*r.m[0]+o*r.m[1]+e*r.m[2]+s*r.m[3],a=n*r.m[4]+o*r.m[5]+e*r.m[6]+s*r.m[7],m=n*r.m[8]+o*r.m[9]+e*r.m[10]+s*r.m[11],y=n*r.m[12]+o*r.m[13]+e*r.m[14]+s*r.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,r){var n,o=i.x-t.x,e=i.y-t.y,s=i.z-t.z,h=r.x-t.x,a=r.y-t.y,u=r.z-t.z,m=e*u-s*a,y=s*h-o*u,c=o*a-e*h,p=Math.sqrt(m*m+y*y+c*c);return n=0!==p?1/p:0,this.normal.x=m*n,this.normal.y=y*n,this.normal.z=c*n,this.d=-(this.normal.x*t.x+this.normal.y*t.y+this.normal.z*t.z),this},t.prototype.isFrontFacingTo=function(t,i){var r=e.Dot(this.normal,t);return r<=i},t.prototype.signedDistanceTo=function(t){return e.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,r,n){var o=new t(0,0,0,0);return o.copyFromPoints(i,r,n),o},t.FromPositionAndNormal=function(i,r){var n=new t(0,0,0,0);return r.normalize(),n.normal=r,n.d=-(r.x*i.x+r.y*i.y+r.z*i.z),n},t.SignedDistanceToPlaneFromPositionAndNormal=function(t,i,r){var n=-(i.x*t.x+i.y*t.y+i.z*t.z);return e.Dot(r,i)+n},t}();t.Plane=m;var y=function(){function t(t,i,r,n){this.x=t,this.y=i,this.width=r,this.height=n}return t.prototype.toGlobal=function(i,r){return new t(this.x*i,this.y*r,this.width*i,this.height*r)},t}();t.Viewport=y;var c=function(){function t(){}return t.GetPlanes=function(i){for(var r=[],n=0;n<6;n++)r.push(new m(0,0,0,0));return t.GetPlanesToRef(i,r),r},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;var p;!function(t){t[t.LOCAL=0]="LOCAL",t[t.WORLD=1]="WORLD"}(p=t.Space||(t.Space={}));var f=function(){function t(){}return t}();f.X=new e(1,0,0),f.Y=new e(0,1,0),f.Z=new e(0,0,1),t.Axis=f;var x=function(){function t(){}return t.interpolate=function(t,i,r,n,o){for(var e=1-3*n+3*i,s=3*n-6*i,h=3*i,a=t,u=0;u<5;u++){var m=a*a,y=m*a,c=e*y+s*m+h*a,p=1/(3*e*m+2*s*a+h);a-=(c-t)*p,a=Math.min(1,Math.max(0,a))}return 3*Math.pow(1-a,2)*a*r+3*(1-a)*Math.pow(a,2)*o+Math.pow(a,3)},t}();t.BezierCurve=x;var l;!function(t){t[t.CW=0]="CW",t[t.CCW=1]="CCW"}(l=t.Orientation||(t.Orientation={}));var z=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,r){var n=r.subtract(i),o=Math.atan2(n.y,n.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=z;var w=function(){function t(t,i,r){this.startPoint=t,this.midPoint=i,this.endPoint=r;var n=Math.pow(i.x,2)+Math.pow(i.y,2),e=(Math.pow(t.x,2)+Math.pow(t.y,2)-n)/2,s=(n-Math.pow(r.x,2)-Math.pow(r.y,2))/2,h=(t.x-i.x)*(i.y-r.y)-(i.x-r.x)*(t.y-i.y);this.centerPoint=new o((e*(i.y-r.y)-s*(t.y-i.y))/h,((t.x-i.x)*s-(i.x-r.x)*e)/h),this.radius=this.centerPoint.subtract(this.startPoint).length(),this.startAngle=z.BetweenTwoPoints(this.centerPoint,this.startPoint);var a=this.startAngle.degrees(),u=z.BetweenTwoPoints(this.centerPoint,this.midPoint).degrees(),m=z.BetweenTwoPoints(this.centerPoint,this.endPoint).degrees();u-a>180&&(u-=360),u-a<-180&&(u+=360),m-u>180&&(m-=360),m-u<-180&&(m+=360),this.orientation=u-a<0?l.CW:l.CCW,this.angle=z.FromDegrees(this.orientation===l.CW?a-m:m-a)}return t}();t.Arc2=w;var v=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 r=new o(t,i),n=this._points[this._points.length-1];return this._points.push(r),this._length+=r.subtract(n).length(),this},t.prototype.addArcTo=function(t,i,r,n,e){if(void 0===e&&(e=36),closed)return this;var s=this._points[this._points.length-1],h=new o(t,i),a=new o(r,n),u=new w(s,h,a),m=u.angle.radians()/e;u.orientation===l.CW&&(m*=-1);for(var y=u.startAngle.radians()+m,c=0;c1)return o.Zero();for(var i=t*this.length(),r=0,n=0;n=r&&i<=u){var m=a.normalize(),y=i-r;return new o(s.x+m.x*y,s.y+m.y*y)}r=u}return o.Zero()},t.StartingAt=function(i,r){return new t(i,r)},t}();t.Path2=v;var d=function(){function r(t,i,r){this.path=t,this._curve=new Array,this._distances=new Array,this._tangents=new Array,this._normals=new Array,this._binormals=new Array;for(var n=0;ni+1;)i++,r=this._curve[t].subtract(this._curve[t-i]);return r},r.prototype._normalVector=function(r,n,o){var s,h=n.length();if(0===h&&(h=1),void 0===o||null===o){var a;i.WithinEpsilon(Math.abs(n.y)/h,1,t.Epsilon)?i.WithinEpsilon(Math.abs(n.x)/h,1,t.Epsilon)?i.WithinEpsilon(Math.abs(n.z)/h,1,t.Epsilon)||(a=new e(0,0,1)):a=new e(1,0,0):a=new e(0,(-1),0),s=e.Cross(n,a)}else s=e.Cross(n,o),e.CrossToRef(s,n,s);return s.normalize(),s},r}();t.Path3D=d;var g=function(){function t(t){this._length=0,this._points=t,this._length=this._computeLength(t)}return t.CreateQuadraticBezier=function(i,r,n,o){o=o>2?o:3;for(var s=new Array,h=function(t,i,r,n){var o=(1-t)*(1-t)*i+2*t*(1-t)*r+t*t*n;return o},a=0;a<=o;a++)s.push(new e(h(a/o,i.x,r.x,n.x),h(a/o,i.y,r.y,n.y),h(a/o,i.z,r.z,n.z)));return new t(s)},t.CreateCubicBezier=function(i,r,n,o,s){s=s>3?s:4;for(var h=new Array,a=function(t,i,r,n,o){var e=(1-t)*(1-t)*(1-t)*i+3*t*(1-t)*(1-t)*r+3*t*t*(1-t)*n+t*t*t*o;return e},u=0;u<=s;u++)h.push(new e(a(u/s,i.x,r.x,n.x,o.x),a(u/s,i.y,r.y,n.y,o.y),a(u/s,i.z,r.z,n.z,o.z)));return new t(h)},t.CreateHermiteSpline=function(i,r,n,o,s){for(var h=new Array,a=1/s,u=0;u<=s;u++)h.push(e.Hermite(i,r,n,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 r=this._points[this._points.length-1],n=this._points.slice(),o=i.getPoints(),e=1;e=0;a--)(n=e[a])&&(s=(o<3?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-i<=r&&r<=i},e.ToHex=function(e){var t=e.toString(16);return e<=15?("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;rr.x?r.x:n,n=nr.y?r.y:o,o=ot.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=n<0?-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&&s+a<2*n*o},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.Center=function(e,t){var i=e.add(t);return i.scaleInPlace(.5),i},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.xthis.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.Forward=function(){return new i(0,0,1)},i.Right=function(){return new i(1,0,0)},i.Left=function(){return new i((-1),0,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){var r=e.x*t.m[0]+e.y*t.m[4]+e.z*t.m[8],n=e.x*t.m[1]+e.y*t.m[5]+e.z*t.m[9],o=e.x*t.m[2]+e.y*t.m[6]+e.z*t.m[10];i.x=r,i.y=n,i.z=o},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=nr.y?r.y:o,o=or.z?r.z:s,s=sthis.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.copyFromFloats=function(e,t){this.width=e,this.height=t},e.prototype.multiplyByFloats=function(t,i){return new e(this.width*t,this.height*i)},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)},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=this.z,r=this.x,n=this.y,o=this.w,s=o*o,a=i*i,h=r*r,c=n*n,l=n*i-r*o,u=.4999999;return l<-u?(e.y=2*Math.atan2(n,o),e.x=Math.PI/2,e.z=0):l>u?(e.y=2*Math.atan2(n,o),e.x=-Math.PI/2,e.z=0):(e.z=Math.atan2(2*(r*n+i*o),-a-h+c+s),e.x=Math.asin(-2*(i*n-r*o)),e.y=Math.atan2(2*(i*r+n*o),a-h-c+s)),this},e.prototype.toRotationMatrix=function(e){var t=this.x*this.x,i=this.y*this.y,r=this.z*this.z,n=this.x*this.y,o=this.z*this.w,s=this.z*this.x,a=this.y*this.w,h=this.y*this.z,c=this.x*this.w;return e.m[0]=1-2*(i+r),e.m[1]=2*(n+o),e.m[2]=2*(s-a),e.m[3]=0,e.m[4]=2*(n-o),e.m[5]=1-2*(r+t),e.m[6]=2*(h+c),e.m[7]=0,e.m[8]=2*(s+a),e.m[9]=2*(h-c),e.m[10]=1-2*(i+t),e.m[11]=0,e.m[12]=0,e.m[13]=0,e.m[14]=0,e.m[15]=1,this},e.prototype.fromRotationMatrix=function(t){return e.FromRotationMatrixToRef(t,this),this},e.FromRotationMatrix=function(t){var i=new e;return e.FromRotationMatrixToRef(t,i),i},e.FromRotationMatrixToRef=function(e,t){var i,r=e.m,n=r[0],o=r[4],s=r[8],a=r[1],h=r[5],c=r[9],l=r[2],u=r[6],d=r[10],f=n+h+d;f>0?(i=.5/Math.sqrt(f+1),t.w=.25/i,t.x=(u-c)*i,t.y=(s-l)*i,t.z=(a-o)*i):n>h&&n>d?(i=2*Math.sqrt(1+n-h-d),t.w=(u-c)/i,t.x=.25*i,t.y=(o+a)/i,t.z=(s+l)/i):h>d?(i=2*Math.sqrt(1+h-n-d),t.w=(s-l)/i,t.x=(o+a)/i,t.y=.25*i,t.z=(c+u)/i):(i=2*Math.sqrt(1+d-n-h),t.w=(a-o)/i,t.x=(s+l)/i,t.y=(c+u)/i,t.z=.25*i)},e.Inverse=function(t){return new e((-t.x),(-t.y),(-t.z),t.w)},e.Identity=function(){return new e(0,0,0,1)},e.RotationAxis=function(t,i){return e.RotationAxisToRef(t,i,new e)},e.RotationAxisToRef=function(e,t,i){var r=Math.sin(t/2);return e.normalize(),i.w=Math.cos(t/2),i.x=e.x*r,i.y=e.y*r,i.z=e.z*r,i},e.FromArray=function(t,i){return i||(i=0),new e(t[i],t[i+1],t[i+2],t[i+3])},e.RotationYawPitchRoll=function(t,i,r){var n=new e;return e.RotationYawPitchRollToRef(t,i,r,n),n},e.RotationYawPitchRollToRef=function(e,t,i,r){var n=.5*i,o=.5*t,s=.5*e,a=Math.sin(n),h=Math.cos(n),c=Math.sin(o),l=Math.cos(o),u=Math.sin(s),d=Math.cos(s);r.x=d*c*h+u*l*a,r.y=u*l*h-d*c*a,r.z=d*l*a-u*c*h,r.w=d*l*h+u*c*a},e.RotationAlphaBetaGamma=function(t,i,r){var n=new e;return e.RotationAlphaBetaGammaToRef(t,i,r,n),n},e.RotationAlphaBetaGammaToRef=function(e,t,i,r){var n=.5*(i+e),o=.5*(i-e),s=.5*t;r.x=Math.cos(o)*Math.sin(s),r.y=Math.sin(o)*Math.sin(s),r.z=Math.sin(n)*Math.cos(s),r.w=Math.cos(n)*Math.cos(s)},e.Slerp=function(t,i,r){var n=e.Identity();return e.SlerpToRef(t,i,r,n),n},e.SlerpToRef=function(e,t,i,r){var n,o,s=i,a=e.x*t.x+e.y*t.y+e.z*t.z+e.w*t.w,h=!1;if(a<0&&(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}r.x=o*e.x+n*t.x,r.y=o*e.y+n*t.y,r.z=o*e.z+n*t.z,r.w=o*e.w+n*t.w},e})();e.Quaternion=h;var c=(function(){function i(){this.m=new Float32Array(16)}return i.prototype.isIdentity=function(){return 1===this.m[0]&&1===this.m[5]&&1===this.m[10]&&1===this.m[15]&&(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])},i.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)},i.prototype.toArray=function(){return this.m},i.prototype.asArray=function(){return this.toArray()},i.prototype.invert=function(){return this.invertToRef(this),this},i.prototype.reset=function(){for(var e=0;e<16;e++)this.m[e]=0;return this},i.prototype.add=function(e){var t=new i;return this.addToRef(e,t),t},i.prototype.addToRef=function(e,t){for(var i=0;i<16;i++)t.m[i]=this.m[i]+e.m[i];return this},i.prototype.addToSelf=function(e){for(var t=0;t<16;t++)this.m[t]+=e.m[t];return this},i.prototype.invertToRef=function(e){var t=this.m[0],i=this.m[1],r=this.m[2],n=this.m[3],o=this.m[4],s=this.m[5],a=this.m[6],h=this.m[7],c=this.m[8],l=this.m[9],u=this.m[10],d=this.m[11],f=this.m[12],p=this.m[13],_=this.m[14],m=this.m[15],g=u*m-d*_,v=l*m-d*p,y=l*_-u*p,x=c*m-d*f,b=c*_-u*f,A=c*p-l*f,E=s*g-a*v+h*y,T=-(o*g-a*x+h*b),P=o*v-s*x+h*A,M=-(o*y-s*b+a*A),S=1/(t*E+i*T+r*P+n*M),C=a*m-h*_,R=s*m-h*p,O=s*_-a*p,I=o*m-h*f,D=o*_-a*f,L=o*p-s*f,w=a*d-h*u,B=s*d-h*l,F=s*u-a*l,V=o*d-h*c,N=o*u-a*c,U=o*l-s*c;return e.m[0]=E*S,e.m[4]=T*S,e.m[8]=P*S,e.m[12]=M*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*A)*S,e.m[13]=(t*y-i*b+r*A)*S,e.m[2]=(i*C-r*R+n*O)*S,e.m[6]=-(t*C-r*I+n*D)*S,e.m[10]=(t*R-i*I+n*L)*S,e.m[14]=-(t*O-i*D+r*L)*S,e.m[3]=-(i*w-r*B+n*F)*S,e.m[7]=(t*w-r*V+n*N)*S,e.m[11]=-(t*B-i*V+n*U)*S,e.m[15]=(t*F-i*N+r*U)*S,this},i.prototype.setTranslation=function(e){return this.m[12]=e.x,this.m[13]=e.y,this.m[14]=e.z,this},i.prototype.getTranslation=function(){return new o(this.m[12],this.m[13],this.m[14])},i.prototype.multiply=function(e){var t=new i;return this.multiplyToRef(e,t),t},i.prototype.copyFrom=function(e){for(var t=0;t<16;t++)this.m[t]=e.m[t];return this},i.prototype.copyToArray=function(e,t){void 0===t&&(t=0);for(var i=0;i<16;i++)e[t+i]=this.m[i];return this},i.prototype.multiplyToRef=function(e,t){return this.multiplyToArray(e,t.m,0),this},i.prototype.multiplyToArray=function(e,t,i){var r=this.m[0],n=this.m[1],o=this.m[2],s=this.m[3],a=this.m[4],h=this.m[5],c=this.m[6],l=this.m[7],u=this.m[8],d=this.m[9],f=this.m[10],p=this.m[11],_=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],A=e.m[3],E=e.m[4],T=e.m[5],P=e.m[6],M=e.m[7],S=e.m[8],C=e.m[9],R=e.m[10],O=e.m[11],I=e.m[12],D=e.m[13],L=e.m[14],w=e.m[15];return t[i]=r*y+n*E+o*S+s*I,t[i+1]=r*x+n*T+o*C+s*D,t[i+2]=r*b+n*P+o*R+s*L,t[i+3]=r*A+n*M+o*O+s*w,t[i+4]=a*y+h*E+c*S+l*I,t[i+5]=a*x+h*T+c*C+l*D,t[i+6]=a*b+h*P+c*R+l*L,t[i+7]=a*A+h*M+c*O+l*w,t[i+8]=u*y+d*E+f*S+p*I,t[i+9]=u*x+d*T+f*C+p*D,t[i+10]=u*b+d*P+f*R+p*L,t[i+11]=u*A+d*M+f*O+p*w,t[i+12]=_*y+m*E+g*S+v*I,t[i+13]=_*x+m*T+g*C+v*D,t[i+14]=_*b+m*P+g*R+v*L,t[i+15]=_*A+m*M+g*O+v*w,this},i.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]},i.prototype.clone=function(){return i.FromValues(this.m[0],this.m[1],this.m[2],this.m[3],this.m[4],this.m[5],this.m[6],this.m[7],this.m[8],this.m[9],this.m[10],this.m[11],this.m[12],this.m[13],this.m[14],this.m[15])},i.prototype.getClassName=function(){return"Matrix"},i.prototype.getHashCode=function(){for(var e=this.m[0]||0,t=1;t<16;t++)e=397*e^(this.m[t]||0);return e},i.prototype.decompose=function(e,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;return e.x=o*Math.sqrt(this.m[0]*this.m[0]+this.m[1]*this.m[1]+this.m[2]*this.m[2]),e.y=s*Math.sqrt(this.m[4]*this.m[4]+this.m[5]*this.m[5]+this.m[6]*this.m[6]),e.z=a*Math.sqrt(this.m[8]*this.m[8]+this.m[9]*this.m[9]+this.m[10]*this.m[10]),0===e.x||0===e.y||0===e.z?(r.x=0,r.y=0,r.z=0,r.w=1,!1):(i.FromValuesToRef(this.m[0]/e.x,this.m[1]/e.x,this.m[2]/e.x,0,this.m[4]/e.y,this.m[5]/e.y,this.m[6]/e.y,0,this.m[8]/e.z,this.m[9]/e.z,this.m[10]/e.z,0,0,0,0,1,M.Matrix[0]),h.FromRotationMatrixToRef(M.Matrix[0],r),!0)},i.prototype.getRotationMatrix=function(){var e=i.Identity();return this.getRotationMatrixToRef(e),e},i.prototype.getRotationMatrixToRef=function(e){var t=this.m,r=t[0]*t[1]*t[2]*t[3]<0?-1:1,n=t[4]*t[5]*t[6]*t[7]<0?-1:1,o=t[8]*t[9]*t[10]*t[11]<0?-1:1,s=r*Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]),a=n*Math.sqrt(t[4]*t[4]+t[5]*t[5]+t[6]*t[6]),h=o*Math.sqrt(t[8]*t[8]+t[9]*t[9]+t[10]*t[10]);i.FromValuesToRef(t[0]/s,t[1]/s,t[2]/s,0,t[4]/a,t[5]/a,t[6]/a,0,t[8]/h,t[9]/h,t[10]/h,0,0,0,0,1,e)},i.FromArray=function(e,t){var r=new i;return t||(t=0),i.FromArrayToRef(e,t,r),r},i.FromArrayToRef=function(e,t,i){for(var r=0;r<16;r++)i.m[r]=e[r+t]},i.FromFloat32ArrayToRefScaled=function(e,t,i,r){for(var n=0;n<16;n++)r.m[n]=e[n+t]*i},i.FromValuesToRef=function(e,t,i,r,n,o,s,a,h,c,l,u,d,f,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]=d,m.m[13]=f,m.m[14]=p,m.m[15]=_},i.prototype.getRow=function(e){if(e<0||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])},i.prototype.setRow=function(e,t){if(e<0||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},i.FromValues=function(e,t,r,n,o,s,a,h,c,l,u,d,f,p,_,m){var g=new i;return g.m[0]=e,g.m[1]=t,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]=d,g.m[12]=f,g.m[13]=p,g.m[14]=_,g.m[15]=m,g},i.Compose=function(e,t,r){var n=i.FromValues(e.x,0,0,0,0,e.y,0,0,0,0,e.z,0,0,0,0,1),o=i.Identity();return t.toRotationMatrix(o),n=n.multiply(o),n.setTranslation(r),n},i.Identity=function(){return i.FromValues(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1)},i.IdentityToRef=function(e){i.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,e)},i.Zero=function(){return i.FromValues(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)},i.RotationX=function(e){var t=new i;return i.RotationXToRef(e,t),t},i.Invert=function(e){var t=new i;return e.invertToRef(t),t},i.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},i.RotationY=function(e){var t=new i;return i.RotationYToRef(e,t),t},i.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},i.RotationZ=function(e){var t=new i;return i.RotationZToRef(e,t),t},i.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},i.RotationAxis=function(e,t){var r=i.Zero();return i.RotationAxisToRef(e,t,r),r},i.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},i.RotationYawPitchRoll=function(e,t,r){var n=new i;return i.RotationYawPitchRollToRef(e,t,r,n),n},i.RotationYawPitchRollToRef=function(e,t,i,r){h.RotationYawPitchRollToRef(e,t,i,this._tempQuaternion),this._tempQuaternion.toRotationMatrix(r)},i.Scaling=function(e,t,r){var n=i.Zero();return i.ScalingToRef(e,t,r,n),n},i.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},i.Translation=function(e,t,r){var n=i.Identity();return i.TranslationToRef(e,t,r,n),n},i.TranslationToRef=function(e,t,r,n){i.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,e,t,r,1,n)},i.Lerp=function(e,t,r){for(var n=i.Zero(),o=0;o<16;o++)n.m[o]=e.m[o]*(1-r)+t.m[o]*r;return n},i.DecomposeLerp=function(e,t,r){var n=new o(0,0,0),s=new h,a=new o(0,0,0);e.decompose(n,s,a);var c=new o(0,0,0),l=new h,u=new o(0,0,0);t.decompose(c,l,u);var d=o.Lerp(n,c,r),f=h.Slerp(s,l,r),p=o.Lerp(a,u,r);return i.Compose(d,f,p)},i.LookAtLH=function(e,t,r){var n=i.Zero();return i.LookAtLHToRef(e,t,r,n),n},i.LookAtLHToRef=function(e,t,r,n){t.subtractToRef(e,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,e),a=-o.Dot(this._yAxis,e),h=-o.Dot(this._zAxis,e);return i.FromValuesToRef(this._xAxis.x,this._yAxis.x,this._zAxis.x,0,this._xAxis.y,this._yAxis.y,this._zAxis.y,0,this._xAxis.z,this._yAxis.z,this._zAxis.z,0,s,a,h,1,n)},i.LookAtRH=function(e,t,r){var n=i.Zero();return i.LookAtRHToRef(e,t,r,n),n},i.LookAtRHToRef=function(e,t,r,n){e.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,e),a=-o.Dot(this._yAxis,e),h=-o.Dot(this._zAxis,e);return i.FromValuesToRef(this._xAxis.x,this._yAxis.x,this._zAxis.x,0,this._xAxis.y,this._yAxis.y,this._zAxis.y,0,this._xAxis.z,this._yAxis.z,this._zAxis.z,0,s,a,h,1,n)},i.OrthoLH=function(e,t,r,n){var o=i.Zero();return i.OrthoLHToRef(e,t,r,n,o),o},i.OrthoLHToRef=function(t,i,r,n,o){var s=r,a=n,h=2/t,c=2/i,l=2/(a-s),u=-(a+s)/(a-s);e.Matrix.FromValuesToRef(h,0,0,0,0,c,0,0,0,0,l,0,0,0,u,1,o)},i.OrthoOffCenterLH=function(e,t,r,n,o,s){var a=i.Zero();return i.OrthoOffCenterLHToRef(e,t,r,n,o,s,a),a},i.OrthoOffCenterLHToRef=function(t,i,r,n,o,s,a){var h=o,c=s,l=2/(i-t),u=2/(n-r),d=2/(c-h),f=-(c+h)/(c-h),p=(t+i)/(t-i),_=(n+r)/(r-n);e.Matrix.FromValuesToRef(l,0,0,0,0,u,0,0,0,0,d,0,p,_,f,1,a)},i.OrthoOffCenterRH=function(e,t,r,n,o,s){var a=i.Zero();return i.OrthoOffCenterRHToRef(e,t,r,n,o,s,a),a},i.OrthoOffCenterRHToRef=function(e,t,r,n,o,s,a){i.OrthoOffCenterLHToRef(e,t,r,n,o,s,a),a.m[10]*=-1},i.PerspectiveLH=function(t,r,n,o){var s=i.Zero(),a=n,h=o,c=2*a/t,l=2*a/r,u=(h+a)/(h-a),d=-2*h*a/(h-a);return e.Matrix.FromValuesToRef(c,0,0,0,0,l,0,0,0,0,u,1,0,0,d,0,s),s},i.PerspectiveFovLH=function(e,t,r,n){var o=i.Zero();return i.PerspectiveFovLHToRef(e,t,r,n,o),o},i.PerspectiveFovLHToRef=function(t,i,r,n,o,s){void 0===s&&(s=!0);var a=r,h=n,c=1/Math.tan(.5*t),l=s?c/i:c,u=s?c:c*i,d=(h+a)/(h-a),f=-2*h*a/(h-a);e.Matrix.FromValuesToRef(l,0,0,0,0,u,0,0,0,0,d,1,0,0,f,0,o)},i.PerspectiveFovRH=function(e,t,r,n){var o=i.Zero();return i.PerspectiveFovRHToRef(e,t,r,n,o),o},i.PerspectiveFovRHToRef=function(t,i,r,n,o,s){void 0===s&&(s=!0);var a=r,h=n,c=1/Math.tan(.5*t),l=s?c/i:c,u=s?c:c*i,d=-(h+a)/(h-a),f=-2*h*a/(h-a);e.Matrix.FromValuesToRef(l,0,0,0,0,u,0,0,0,0,d,-1,0,0,f,0,o)},i.PerspectiveFovWebVRToRef=function(e,t,i,r,n){void 0===n&&(n=!0);var o=Math.tan(e.upDegrees*Math.PI/180),s=Math.tan(e.downDegrees*Math.PI/180),a=Math.tan(e.leftDegrees*Math.PI/180),h=Math.tan(e.rightDegrees*Math.PI/180),c=2/(a+h),l=2/(o+s);r.m[0]=c,r.m[1]=r.m[2]=r.m[3]=r.m[4]=0,r.m[5]=l,r.m[6]=r.m[7]=0,r.m[8]=(a-h)*c*.5,r.m[9]=-((o-s)*l*.5),r.m[10]=-(t+i)/(i-t),r.m[11]=1,r.m[12]=r.m[13]=r.m[15]=0,r.m[14]=-(2*i*t)/(i-t)},i.GetFinalMatrix=function(e,t,r,n,o,s){var a=e.width,h=e.height,c=e.x,l=e.y,u=i.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 t.multiply(r).multiply(n).multiply(u)},i.GetAsMatrix2x2=function(e){return new Float32Array([e.m[0],e.m[1],e.m[4],e.m[5]])},i.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]])},i.Transpose=function(e){var t=new i;return t.m[0]=e.m[0],t.m[1]=e.m[4],t.m[2]=e.m[8],t.m[3]=e.m[12],t.m[4]=e.m[1],t.m[5]=e.m[5],t.m[6]=e.m[9],t.m[7]=e.m[13],t.m[8]=e.m[2],t.m[9]=e.m[6],t.m[10]=e.m[10],t.m[11]=e.m[14],t.m[12]=e.m[3],t.m[13]=e.m[7],t.m[14]=e.m[11],t.m[15]=e.m[15],t},i.Reflection=function(e){var t=new i;return i.ReflectionToRef(e,t),t},i.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},i.FromXYZAxesToRef=function(e,t,i,r){r.m[0]=e.x,r.m[1]=e.y,r.m[2]=e.z,r.m[3]=0,r.m[4]=t.x,r.m[5]=t.y,r.m[6]=t.z,r.m[7]=0,r.m[8]=i.x,r.m[9]=i.y,r.m[10]=i.z,r.m[11]=0,r.m[12]=0,r.m[13]=0,r.m[14]=0,r.m[15]=1},i.FromQuaternionToRef=function(e,t){var i=e.x*e.x,r=e.y*e.y,n=e.z*e.z,o=e.x*e.y,s=e.z*e.w,a=e.z*e.x,h=e.y*e.w,c=e.y*e.z,l=e.x*e.w;t.m[0]=1-2*(r+n),t.m[1]=2*(o+s),t.m[2]=2*(a-h),t.m[3]=0,t.m[4]=2*(o-s),t.m[5]=1-2*(n+i),t.m[6]=2*(c+l),t.m[7]=0,t.m[8]=2*(a+h),t.m[9]=2*(c-l),t.m[10]=1-2*(r+i),t.m[11]=0,t.m[12]=0,t.m[13]=0,t.m[14]=0,t.m[15]=1},i})();c._tempQuaternion=new h,c._xAxis=o.Zero(),c._yAxis=o.Zero(),c._zAxis=o.Zero(),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,d=n*h-o*a,f=Math.sqrt(l*l+u*u+d*d);return r=0!==f?1/f:0,this.normal.x=l*r,this.normal.y=u*r,this.normal.z=d*r,this.d=-(this.normal.x*e.x+this.normal.y*e.y+this.normal.z*e.z),this},e.prototype.isFrontFacingTo=function(e,t){var i=o.Dot(this.normal,e);return i<=t},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 d=(function(){function e(){}return e.GetPlanes=function(t){for(var i=[],r=0;r<6;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=d;var f;!(function(e){e[e.LOCAL=0]="LOCAL",e[e.WORLD=1]="WORLD"})(f=e.Space||(e.Space={}));var p=(function(){function e(){}return e})();p.X=new o(1,0,0),p.Y=new o(0,1,0),p.Z=new o(0,0,1),e.Axis=p;var _=(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;c<5;c++){var l=h*h,u=l*h,d=o*u+s*l+a*h,f=1/(3*o*l+2*s*h+a);h-=(d-e)*f,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=_;var m;!(function(e){e[e.CW=0]="CW",e[e.CCW=1]="CCW"})(m=e.Orientation||(e.Orientation={}));var g=(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=g;var v=(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=g.BetweenTwoPoints(this.centerPoint,this.startPoint);var h=this.startAngle.degrees(),c=g.BetweenTwoPoints(this.centerPoint,this.midPoint).degrees(),l=g.BetweenTwoPoints(this.centerPoint,this.endPoint).degrees();c-h>180&&(c-=360),c-h<-180&&(c+=360),l-c>180&&(l-=360),l-c<-180&&(l+=360),this.orientation=c-h<0?m.CW:m.CCW,this.angle=g.FromDegrees(this.orientation===m.CW?h-l:l-h)}return e})();e.Arc2=v;var y=(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 v(s,a,h),l=c.angle.radians()/o;c.orientation===m.CW&&(l*=-1);for(var u=c.startAngle.radians()+l,d=0;d1)return n.Zero();for(var t=e*this.length(),i=0,r=0;r=i&&t<=c){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=y;var x=(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;rt+1;)t++,i=this._curve[e].subtract(this._curve[e-t]);return i},i.prototype._normalVector=function(i,r,n){var s,a=r.length();if(0===a&&(a=1),void 0===n||null===n){var h;t.WithinEpsilon(Math.abs(r.y)/a,1,e.Epsilon)?t.WithinEpsilon(Math.abs(r.x)/a,1,e.Epsilon)?t.WithinEpsilon(Math.abs(r.z)/a,1,e.Epsilon)||(h=new o(0,0,1)):h=new o(1,0,0):h=new o(0,(-1),0),s=o.Cross(r,h)}else s=o.Cross(r,n),o.CrossToRef(s,r,s);return s.normalize(),s},i})();e.Path3D=x;var b=(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;h<=n;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;c<=s;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;c<=s;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;o0},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&&(n.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){e!==-1?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=t.indexOf(".babylon")!==-1?"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=t.indexOf(".babylon")!==-1?"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&&(o.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})();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 e.indexOf("http:/")===-1?t.parseURL(window.location.href)+e:e},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++],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,d=(15&o.flags,o.pixel_size>>3),f=o.width*o.height*d;if(a&&(u=r.subarray(n,n+=o.colormap_length*(o.colormap_size>>3))),s){l=new Uint8Array(f);for(var p,_,m,g=0,v=new Uint8Array(d);n>t._ORIGIN_SHIFT){default:case t._ORIGIN_UL:y=0,b=1,T=o.width,x=0,A=1,E=o.height;break;case t._ORIGIN_BL:y=0,b=1,T=o.width,x=o.height-1,A=-1,E=-1;break;case t._ORIGIN_UR:y=o.width-1,b=-1,T=-1,x=0,A=1,E=o.height;break;case t._ORIGIN_BR:y=o.width-1,b=-1,T=-1,x=o.height-1,A=-1,E=-1}var P="_getImageData"+(c?"Grey":"")+o.pixel_size+"bits",M=t[P](o,u,l,x,A,E,y,b,T);i.texImage2D(i.TEXTURE_2D,0,i.RGBA,o.width,o.height,0,i.RGBA,i.UNSIGNED_BYTE,M)},t._getImageData8bits=function(e,t,i,r,n,o,s,a,h){var c,l,u,d=i,f=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=d[m],g[4*(l+p*u)+3]=255,g[4*(l+p*u)+2]=f[3*c+0],g[4*(l+p*u)+1]=f[3*c+1],g[4*(l+p*u)+0]=f[3*c+2];return g},t._getImageData16bits=function(e,t,i,r,n,o,s,a,h){var c,l,u,d=i,f=e.width,p=e.height,_=0,m=new Uint8Array(f*p*4);for(u=r;u!==o;u+=n)for(l=s;l!==h;l+=a,_+=2)c=d[_+0]+(d[_+1]<<8),m[4*(l+f*u)+0]=(31744&c)>>7,m[4*(l+f*u)+1]=(992&c)>>2,m[4*(l+f*u)+2]=(31&c)>>3,m[4*(l+f*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,d=e.width,f=e.height,p=0,_=new Uint8Array(d*f*4);for(l=r;l!==o;l+=n)for(c=s;c!==h;c+=a,p+=3)_[4*(c+d*l)+3]=255,_[4*(c+d*l)+2]=u[p+0],_[4*(c+d*l)+1]=u[p+1],_[4*(c+d*l)+0]=u[p+2];return _},t._getImageData32bits=function(e,t,i,r,n,o,s,a,h){var c,l,u=i,d=e.width,f=e.height,p=0,_=new Uint8Array(d*f*4);for(l=r;l!==o;l+=n)for(c=s;c!==h;c+=a,p+=4)_[4*(c+d*l)+2]=u[p+0],_[4*(c+d*l)+1]=u[p+1],_[4*(c+d*l)+0]=u[p+2],_[4*(c+d*l)+3]=u[p+3];return _},t._getImageDataGrey8bits=function(e,t,i,r,n,o,s,a,h){var c,l,u,d=i,f=e.width,p=e.height,_=0,m=new Uint8Array(f*p*4);for(u=r;u!==o;u+=n)for(l=s;l!==h;l+=a,_++)c=d[_],m[4*(l+f*u)+0]=c,m[4*(l+f*u)+1]=c,m[4*(l+f*u)+2]=c,m[4*(l+f*u)+3]=255;return m},t._getImageDataGrey16bits=function(e,t,i,r,n,o,s,a,h){var c,l,u=i,d=e.width,f=e.height,p=0,_=new Uint8Array(d*f*4);for(l=r;l!==o;l+=n)for(c=s;c!==h;c+=a,p+=2)_[4*(c+d*l)+0]=u[p+0],_[4*(c+d*l)+1]=u[p+0],_[4*(c+d*l)+2]=u[p+0],_[4*(c+d*l)+3]=u[p+1];return _},t})();i._TYPE_NO_DATA=0,i._TYPE_INDEXED=1,i._TYPE_RGB=2,i._TYPE_GREY=3,i._TYPE_RLE_INDEXED=9,i._TYPE_RLE_RGB=10,i._TYPE_RLE_GREY=11,i._ORIGIN_MASK=48,i._ORIGIN_SHIFT=4,i._ORIGIN_BL=0,i._ORIGIN_BR=1,i._ORIGIN_UL=2,i._ORIGIN_UR=3,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)&&(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;tthis.data.length&&(this.data.length=2*(this.length+e.length));for(var t=0;t=this.length?-1:t},e})();t._GlobalId=0,e.SmartArray=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(){this._count=0,this._data={}}return e.prototype.copyFrom=function(e){var t=this;this.clear(),e.forEach((function(e,i){return t.add(e,i)}))},e.prototype.get=function(e){var t=this._data[e];if(void 0!==t)return t},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]&&(this._data[e]=t,++this._count,!0)},e.prototype.set=function(e,t){return void 0!==this._data[e]&&(this._data[e]=t,!0)},e.prototype.getAndRemove=function(e){var t=this.get(e);return void 0!==t?(delete this._data[e],--this._count,t):null},e.prototype.remove=function(e){return!!this.contains(e)&&(delete this._data[e],--this._count,!0)},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,t){return function(i){i.__bjsclassName__=e,i.__bjsmoduleName__=null!=t?t:null}}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;rt&&(i=t),i},t.GetFilename=function(e){var t=e.lastIndexOf("/");return t<0?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>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;h=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){if(t===!0||void 0!==e&&null!=e)return Array.isArray(e)?e:[e]},t.GetPointerPrefix=function(){var e="pointer";return window.PointerEvent||navigator.pointerEnabled||(e="mouse"),e},t.QueueNewFrame=function(e,t){void 0===t&&(t=window),t.requestAnimationFrame?t.requestAnimationFrame(e):t.msRequestAnimationFrame?t.msRequestAnimationFrame(e):t.webkitRequestAnimationFrame?t.webkitRequestAnimationFrame(e):t.mozRequestAnimationFrame?t.mozRequestAnimationFrame(e):t.oRequestAnimationFrame?t.oRequestAnimationFrame(e):window.setTimeout(e,16)},t.RequestFullscreen=function(e){var t=e.requestFullscreen||e.msRequestFullscreen||e.webkitRequestFullscreen||e.mozRequestFullScreen;t&&t.call(e)},t.ExitFullscreen=function(){document.exitFullscreen?document.exitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitCancelFullScreen?document.webkitCancelFullScreen():document.msCancelFullScreen&&document.msCancelFullScreen()},t.SetCorsBehavior=function(e,i){if(t.CorsBehavior)switch(typeof t.CorsBehavior){case"function":var r=t.CorsBehavior(e);if(r)return r;break;case"string":default:i.crossOrigin=t.CorsBehavior}},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;"data:"!==i.substr(0,5)&&t.SetCorsBehavior(i,s),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 a=function(){s.src=i},h=function(){o.loadImageFromDB(i,s)};if("data:"!==i.substr(0,5)&&o&&o.enableTexturesOffline&&e.Database.IsUASupportingBlobStorage)o.openAsync(h,a);else if(i.indexOf("file:")===-1)a();else try{var c,l=i.substring(5).toLowerCase();try{c=URL.createObjectURL(e.FilesInput.FilesTextures[l],{oneTimeOnly:!0})}catch(u){c=URL.createObjectURL(e.FilesInput.FilesTextures[l])}s.src=c}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(e.onreadystatechange=null,e.status>=200&&e.status<300||navigator.isCocoonJS&&0===e.status)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(i.indexOf("file:")!==-1){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.LoadScript=function(e,t,i){var r=document.getElementsByTagName("head")[0],n=document.createElement("script");n.type="text/javascript",n.src=e;n.onload=function(){t&&t()},n.onerror=function(){i&&i()},r.appendChild(n)},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.xi.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&&n.indexOf(o)!==-1)&&(!i||i.indexOf(o)===-1)){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;hh&&(d=h,u=d*l);var f=Math.max(0,a-u)/2,p=Math.max(0,h-d)/2;c.fillStyle=r.getScene().clearColor.toHexString(),c.fillRect(0,0,a,h),c.drawImage(e.getRenderingCanvas(),f,p,u,d),t.EncodeScreenshotCanvasData(o,s)},t.CreateScreenshotUsingRenderTarget=function(i,r,n,o,s){void 0===s&&(s="image/png");var a,h;if(n.precision)a=Math.round(i.getRenderWidth()*n.precision),h=Math.round(a/i.getAspectRatio(r)),n={width:a,height:h};else if(n.width&&n.height)a=n.width,h=n.height;else if(n.width&&!n.height)a=n.width,h=Math.round(a/i.getAspectRatio(r)),n={width:a,height:h};else if(n.height&&!n.width)h=n.height,a=Math.round(h*i.getAspectRatio(r)),n={width:a,height:h};else{if(isNaN(n))return void t.Error("Invalid 'size' parameter !");h=n,a=n}var c=r.getScene(),l=null;c.activeCamera!==r&&(l=c.activeCamera,c.activeCamera=r);var u=new e.RenderTargetTexture("screenShot",n,c,(!1),(!1),e.Engine.TEXTURETYPE_UNSIGNED_INT,(!1),e.Texture.NEAREST_SAMPLINGMODE);u.renderList=c.meshes,u.onAfterRenderObservable.add((function(){t.DumpFramebuffer(a,h,i,o,s)})),c.incrementRenderId(),c.resetCachedMaterial(),u.render(!0),u.dispose(),l&&(c.activeCamera=l),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},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)}))},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 e<10?"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="
"+i+"

";t._AddLogEntry(r)},t._WarnDisabled=function(e){},t._WarnEnabled=function(e){var i=t._FormatMessage(e);console.warn("BJS - "+i);var r="
"+i+"

";t._AddLogEntry(r)},t._ErrorDisabled=function(e){},t._ErrorEnabled=function(e){t.errorsCount++;var i=t._FormatMessage(e);console.error("BJS - "+i);var r="
"+i+"

";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,r=e;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})();n.BaseUrl="",n.CorsBehavior="anonymous",n.UseFallbackTexture=!0,n._NoneLogLevel=0,n._MessageLogLevel=1,n._WarningLogLevel=2,n._ErrorLogLevel=4,n._LogCache="",n.errorsCount=0,n.Log=n._LogEnabled,n.Warn=n._WarnEnabled,n.Error=n._ErrorEnabled,n._PerformanceNoneLogLevel=0,n._PerformanceUserMarkLogLevel=1,n._PerformanceConsoleLogLevel=2,n._performance=window.performance,n.StartPerformanceCounter=n._StartPerformanceCounterDisabled,n.EndPerformanceCounter=n._EndPerformanceCounterDisabled,e.Tools=n;var o=(function(){function e(){this._startMonitoringTime=0,this._min=0,this._max=0,this._average=0,this._lastSecAverage=0,this._current=0,this._totalValueCount=0,this._totalAccumulated=0,this._lastSecAccumulated=0,this._lastSecTime=0,this._lastSecValueCount=0}return Object.defineProperty(e.prototype,"min",{get:function(){return this._min},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"max",{get:function(){return this._max},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"average",{get:function(){return this._average},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"lastSecAverage",{get:function(){return this._lastSecAverage},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"current",{get:function(){return this._current},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"total",{get:function(){return this._totalAccumulated},enumerable:!0,configurable:!0}),e.prototype.fetchNewFrame=function(){this._totalValueCount++,this._current=0,this._lastSecValueCount++},e.prototype.addCount=function(e,t){this._current+=e,t&&this._fetchResult()},e.prototype.beginMonitoring=function(){this._startMonitoringTime=n.Now},e.prototype.endMonitoring=function(e){void 0===e&&(e=!0),e&&this.fetchNewFrame();var t=n.Now;this._current=t-this._startMonitoringTime,e&&this._fetchResult()},e.prototype._fetchResult=function(){this._totalAccumulated+=this._current,this._lastSecAccumulated+=this._current,this._min=Math.min(this._min,this._current),this._max=Math.max(this._max,this._current),this._average=this._totalAccumulated/this._totalValueCount;var e=n.Now;e-this._lastSecTime>1e3&&(this._lastSecAverage=this._lastSecAccumulated/this._lastSecValueCount,this._lastSecTime=e,this._lastSecAccumulated=0,this._lastSecValueCount=0)},e})();e.PerfCounter=o,e.className=t;var s=(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=t)break;if(r(s),o&&o()){e.breakLoop();break}}e.executeNext()}),s)}),n)},e})();e.AsyncLoop=s})(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), -this.reset()}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,this.reset()}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(t){var i=(function(){function t(){this._isStencilTestDirty=!1,this._isStencilMaskDirty=!1,this._isStencilFuncDirty=!1,this._isStencilOpDirty=!1,this.reset()}return Object.defineProperty(t.prototype,"isDirty",{get:function(){return this._isStencilTestDirty||this._isStencilMaskDirty||this._isStencilFuncDirty||this._isStencilOpDirty},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stencilFunc",{get:function(){return this._stencilFunc},set:function(e){this._stencilFunc!==e&&(this._stencilFunc=e,this._isStencilFuncDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stencilFuncRef",{get:function(){return this._stencilFuncRef},set:function(e){this._stencilFuncRef!==e&&(this._stencilFuncRef=e,this._isStencilFuncDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stencilFuncMask",{get:function(){return this._stencilFuncMask},set:function(e){this._stencilFuncMask!==e&&(this._stencilFuncMask=e,this._isStencilFuncDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stencilOpStencilFail",{get:function(){return this._stencilOpStencilFail},set:function(e){this._stencilOpStencilFail!==e&&(this._stencilOpStencilFail=e,this._isStencilOpDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stencilOpDepthFail",{get:function(){return this._stencilOpDepthFail},set:function(e){this._stencilOpDepthFail!==e&&(this._stencilOpDepthFail=e,this._isStencilOpDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stencilOpStencilDepthPass",{get:function(){return this._stencilOpStencilDepthPass},set:function(e){this._stencilOpStencilDepthPass!==e&&(this._stencilOpStencilDepthPass=e,this._isStencilOpDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stencilMask",{get:function(){return this._stencilMask},set:function(e){this._stencilMask!==e&&(this._stencilMask=e,this._isStencilMaskDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stencilTest",{get:function(){return this._stencilTest},set:function(e){this._stencilTest!==e&&(this._stencilTest=e,this._isStencilTestDirty=!0)},enumerable:!0,configurable:!0}),t.prototype.reset=function(){this._stencilTest=!1,this._stencilMask=255,this._stencilFunc=e.Engine.ALWAYS,this._stencilFuncRef=1,this._stencilFuncMask=255,this._stencilOpStencilFail=e.Engine.KEEP,this._stencilOpDepthFail=e.Engine.KEEP,this._stencilOpStencilDepthPass=e.Engine.REPLACE,this._isStencilTestDirty=!0,this._isStencilMaskDirty=!0,this._isStencilFuncDirty=!0,this._isStencilOpDirty=!0},t.prototype.apply=function(e){this.isDirty&&(this._isStencilTestDirty&&(this.stencilTest?e.enable(e.STENCIL_TEST):e.disable(e.STENCIL_TEST),this._isStencilTestDirty=!1),this._isStencilMaskDirty&&(e.stencilMask(this.stencilMask),this._isStencilMaskDirty=!1),this._isStencilFuncDirty&&(e.stencilFunc(this.stencilFunc,this.stencilFuncRef,this.stencilFuncMask),this._isStencilFuncDirty=!1),this._isStencilOpDirty&&(e.stencilOp(this.stencilOpStencilFail,this.stencilOpDepthFail,this.stencilOpStencilDepthPass),this._isStencilOpDirty=!1))},t})();t._StencilState=i})(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=36193,r=function(e,t){return t===l.TEXTURETYPE_FLOAT?e.FLOAT:t===l.TEXTURETYPE_HALF_FLOAT?i:e.UNSIGNED_BYTE},n=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}},o=function(t,i,r,o,s,a,h,c,l,u){void 0===u&&(u=e.Texture.TRILINEAR_SAMPLINGMODE);var d=r.getEngine(),f=e.Tools.GetExponentOfTwo(o,d.getCaps().maxTextureSize),p=e.Tools.GetExponentOfTwo(s,d.getCaps().maxTextureSize);d._bindTextureDirectly(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=f,t._height=p,t.isReady=!0,l(f,p);var _=n(u,!h,i);i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,_.mag),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,_.min),h||c||i.generateMipmap(i.TEXTURE_2D),d._bindTextureDirectly(i.TEXTURE_2D,null),d.resetTextureCache(),r._removePendingData(t),t.onLoadedCallbacks.forEach((function(e){e()})),t.onLoadedCallbacks=[]},s=function(t,i,r,n,o,s){void 0===s&&(s=null);var a,h=function(){r[i]=a,r._internalCount++,n._removePendingData(a),6===r._internalCount&&o(r)},c=function(){n._removePendingData(a),s&&s()};a=e.Tools.LoadImage(t,h,c,n.database),n._addPendingData(a)},a=function(e,t,i,r,n){void 0===n&&(n=null);var o=[];o._internalCount=0;for(var a=0;a<6;a++)s(r[a],a,o,t,i,n)},h=(function(){function e(){}return e})();e.InstancingAttributeInfo=h;var c=(function(){function e(){}return e})();e.EngineCapabilities=c;var l=(function(){function s(t,i,r,n){void 0===n&&(n=!1);var o=this;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._badOS=!1,this._drawCalls=new e.PerfCounter,this._renderingQueueLaunched=!1,this._activeRenderLoops=[],this.fpsRange=60,this.previousFramesDuration=[],this.fps=60,this.deltaTime=0,this._depthCullingState=new e.Internals._DepthCullingState,this._stencilState=new e.Internals._StencilState,this._alphaState=new e.Internals._AlphaState,this._alphaMode=s.ALPHA_DISABLE,this._loadedTexturesCache=new Array,this._maxTextureChannels=16,this._activeTexturesCache=new Array(this._maxTextureChannels),this._compiledEffects={},this._vertexAttribArraysEnabled=[],this._uintIndicesCurrentlySet=!1,this._currentBoundBuffer=new Array,this._currentBufferPointers=[],this._currentInstanceLocations=new Array,this._currentInstanceBuffers=new Array,this._texturesSupported=new Array,this._onVRFullScreenTriggered=function(){if(o._vrDisplayEnabled&&o._vrDisplayEnabled.isPresenting){o._oldSize=new e.Size(o.getRenderWidth(),o.getRenderHeight()),o._oldHardwareScaleFactor=o.getHardwareScalingLevel();var t=o._vrDisplayEnabled.getEyeParameters("left");o.setHardwareScalingLevel(1),o.setSize(2*t.renderWidth,t.renderHeight)}else o.setHardwareScalingLevel(o._oldHardwareScaleFactor),o.setSize(o._oldSize.width,o._oldSize.height),o._vrDisplayEnabled=void 0},this._renderingCanvas=t,this._externalData=new e.StringDictionary,r=r||{},null!=i&&(r.antialias=i),void 0===r.preserveDrawingBuffer&&(r.preserveDrawingBuffer=!1);var a=this._canRenderToFloatTexture(),h=this._canRenderToHalfFloatTexture();try{this._gl=t.getContext("webgl2",r)||t.getContext("experimental-webgl2",r),this._gl&&(this._webGLVersion="2.0")}catch(l){}if(!this._gl){if(!t)throw new Error("The provided canvas is null or undefined.");try{this._gl=t.getContext("webgl",r)||t.getContext("experimental-webgl",r)}catch(l){throw new Error("WebGL not supported")}}if(!this._gl)throw new Error("WebGL not supported");this._onBlur=function(){o._windowIsBackground=!0},this._onFocus=function(){o._windowIsBackground=!1},window.addEventListener("blur",this._onBlur),window.addEventListener("focus",this._onFocus);var u=r.limitDeviceRatio||window.devicePixelRatio||1;this._hardwareScalingLevel=n?1/Math.min(u,window.devicePixelRatio||1):1,this.resize(),this._isStencilEnable=r.stencil,this._caps=new c,this._caps.maxTexturesImageUnits=this._gl.getParameter(this._gl.MAX_TEXTURE_IMAGE_UNITS),this._caps.maxTextureSize=this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE),this._caps.maxCubemapTextureSize=this._gl.getParameter(this._gl.MAX_CUBE_MAP_TEXTURE_SIZE),this._caps.maxRenderTextureSize=this._gl.getParameter(this._gl.MAX_RENDERBUFFER_SIZE),this._caps.maxVertexAttribs=this._gl.getParameter(this._gl.MAX_VERTEX_ATTRIBS),this._caps.maxVaryingVectors=this._gl.getParameter(this._gl.MAX_VARYING_VECTORS),this._caps.maxFragmentUniformVectors=this._gl.getParameter(this._gl.MAX_FRAGMENT_UNIFORM_VECTORS),this._caps.maxVertexUniformVectors=this._gl.getParameter(this._gl.MAX_VERTEX_UNIFORM_VECTORS),this._glVersion=this._gl.getParameter(this._gl.VERSION);var d=this._gl.getExtension("WEBGL_debug_renderer_info");if(null!=d&&(this._glRenderer=this._gl.getParameter(d.UNMASKED_RENDERER_WEBGL),this._glVendor=this._gl.getParameter(d.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.astc=this._gl.getExtension("WEBGL_compressed_texture_astc"),this._caps.s3tc=this._gl.getExtension("WEBGL_compressed_texture_s3tc"),this._caps.pvrtc=this._gl.getExtension("WEBGL_compressed_texture_pvrtc")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),this._caps.etc1=this._gl.getExtension("WEBGL_compressed_texture_etc1"),this._caps.etc2=this._gl.getExtension("WEBGL_compressed_texture_etc")||this._gl.getExtension("WEBGL_compressed_texture_es3_0"),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._caps.textureFloatRender=a,this._caps.textureHalfFloat=null!==this._gl.getExtension("OES_texture_half_float"),this._caps.textureHalfFloatLinearFiltering=this._gl.getExtension("OES_texture_half_float_linear"),this._caps.textureHalfFloatRender=h,this._caps.astc&&this.texturesSupported.push(".astc"),this._caps.s3tc&&this.texturesSupported.push(".dds"),this._caps.pvrtc&&this.texturesSupported.push(".pvr"),this._caps.etc2&&this.texturesSupported.push(".etc2"),this._caps.etc1&&this.texturesSupported.push(".etc1"),this._gl.getShaderPrecisionFormat){var f=this._gl.getShaderPrecisionFormat(this._gl.FRAGMENT_SHADER,this._gl.HIGH_FLOAT);this._caps.highPrecisionShaderSupported=0!==f.precision}this.setDepthBuffer(!0),this.setDepthFunctionToLessOrEqual(),this.setDepthWrite(!0),this._onFullscreenChange=function(){void 0!==document.fullscreen?o.isFullscreen=document.fullscreen:void 0!==document.mozFullScreen?o.isFullscreen=document.mozFullScreen:void 0!==document.webkitIsFullScreen?o.isFullscreen=document.webkitIsFullScreen:void 0!==document.msIsFullScreen&&(o.isFullscreen=document.msIsFullScreen),o.isFullscreen&&o._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(){o.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&&!s.audioEngine&&(s.audioEngine=new e.AudioEngine),this._loadingScreen=new e.DefaultLoadingScreen(this._renderingCanvas),r.autoEnableWebVR&&this.initWebVR();var p=/AppleWebKit.*10.[\d] Mobile/;this._badOS=p.test(navigator.userAgent),e.Tools.Log("Babylon.js engine (v"+s.Version+") launched")}return Object.defineProperty(s,"NEVER",{get:function(){return s._NEVER},enumerable:!0,configurable:!0}),Object.defineProperty(s,"ALWAYS",{get:function(){return s._ALWAYS},enumerable:!0,configurable:!0}),Object.defineProperty(s,"LESS",{get:function(){return s._LESS},enumerable:!0,configurable:!0}),Object.defineProperty(s,"EQUAL",{get:function(){return s._EQUAL},enumerable:!0,configurable:!0}),Object.defineProperty(s,"LEQUAL",{get:function(){return s._LEQUAL},enumerable:!0,configurable:!0}),Object.defineProperty(s,"GREATER",{get:function(){return s._GREATER},enumerable:!0,configurable:!0}),Object.defineProperty(s,"GEQUAL",{get:function(){return s._GEQUAL},enumerable:!0,configurable:!0}),Object.defineProperty(s,"NOTEQUAL",{get:function(){return s._NOTEQUAL},enumerable:!0,configurable:!0}),Object.defineProperty(s,"KEEP",{get:function(){return s._KEEP},enumerable:!0,configurable:!0}),Object.defineProperty(s,"REPLACE",{get:function(){return s._REPLACE},enumerable:!0,configurable:!0}),Object.defineProperty(s,"INCR",{get:function(){return s._INCR},enumerable:!0,configurable:!0}),Object.defineProperty(s,"DECR",{get:function(){return s._DECR},enumerable:!0,configurable:!0}),Object.defineProperty(s,"INVERT",{get:function(){return s._INVERT},enumerable:!0,configurable:!0}),Object.defineProperty(s,"INCR_WRAP",{get:function(){return s._INCR_WRAP},enumerable:!0,configurable:!0}),Object.defineProperty(s,"DECR_WRAP",{get:function(){return s._DECR_WRAP},enumerable:!0,configurable:!0}),Object.defineProperty(s,"ALPHA_DISABLE",{get:function(){return s._ALPHA_DISABLE},enumerable:!0,configurable:!0}),Object.defineProperty(s,"ALPHA_ONEONE",{get:function(){return s._ALPHA_ONEONE},enumerable:!0,configurable:!0}),Object.defineProperty(s,"ALPHA_ADD",{get:function(){return s._ALPHA_ADD},enumerable:!0,configurable:!0}),Object.defineProperty(s,"ALPHA_COMBINE",{get:function(){return s._ALPHA_COMBINE},enumerable:!0,configurable:!0}),Object.defineProperty(s,"ALPHA_SUBTRACT",{get:function(){return s._ALPHA_SUBTRACT},enumerable:!0,configurable:!0}),Object.defineProperty(s,"ALPHA_MULTIPLY",{get:function(){return s._ALPHA_MULTIPLY},enumerable:!0,configurable:!0}),Object.defineProperty(s,"ALPHA_MAXIMIZED",{get:function(){return s._ALPHA_MAXIMIZED},enumerable:!0,configurable:!0}),Object.defineProperty(s,"ALPHA_PREMULTIPLIED",{get:function(){return s._ALPHA_PREMULTIPLIED},enumerable:!0,configurable:!0}),Object.defineProperty(s,"DELAYLOADSTATE_NONE",{get:function(){return s._DELAYLOADSTATE_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(s,"DELAYLOADSTATE_LOADED",{get:function(){return s._DELAYLOADSTATE_LOADED},enumerable:!0,configurable:!0}),Object.defineProperty(s,"DELAYLOADSTATE_LOADING",{get:function(){return s._DELAYLOADSTATE_LOADING},enumerable:!0,configurable:!0}),Object.defineProperty(s,"DELAYLOADSTATE_NOTLOADED",{get:function(){return s._DELAYLOADSTATE_NOTLOADED},enumerable:!0,configurable:!0}),Object.defineProperty(s,"TEXTUREFORMAT_ALPHA",{get:function(){return s._TEXTUREFORMAT_ALPHA},enumerable:!0,configurable:!0}),Object.defineProperty(s,"TEXTUREFORMAT_LUMINANCE",{get:function(){return s._TEXTUREFORMAT_LUMINANCE},enumerable:!0,configurable:!0}),Object.defineProperty(s,"TEXTUREFORMAT_LUMINANCE_ALPHA",{get:function(){return s._TEXTUREFORMAT_LUMINANCE_ALPHA},enumerable:!0,configurable:!0}),Object.defineProperty(s,"TEXTUREFORMAT_RGB",{get:function(){return s._TEXTUREFORMAT_RGB},enumerable:!0,configurable:!0}),Object.defineProperty(s,"TEXTUREFORMAT_RGBA",{get:function(){return s._TEXTUREFORMAT_RGBA},enumerable:!0,configurable:!0}),Object.defineProperty(s,"TEXTURETYPE_UNSIGNED_INT",{get:function(){return s._TEXTURETYPE_UNSIGNED_INT},enumerable:!0,configurable:!0}),Object.defineProperty(s,"TEXTURETYPE_FLOAT",{get:function(){return s._TEXTURETYPE_FLOAT},enumerable:!0,configurable:!0}),Object.defineProperty(s,"TEXTURETYPE_HALF_FLOAT",{get:function(){return s._TEXTURETYPE_HALF_FLOAT},enumerable:!0,configurable:!0}),Object.defineProperty(s,"Version",{get:function(){return"2.6-alpha"},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"texturesSupported",{get:function(){return this._texturesSupported},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"textureFormatInUse",{get:function(){return this._textureFormatInUse},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"webGLVersion",{get:function(){return this._webGLVersion},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"isStencilEnable",{get:function(){return this._isStencilEnable},enumerable:!0,configurable:!0}),s.prototype._prepareWorkingCanvas=function(){this._workingCanvas||(this._workingCanvas=document.createElement("canvas"),this._workingContext=this._workingCanvas.getContext("2d"))},s.prototype.resetTextureCache=function(){for(var e=0;e=0&&this._activeRenderLoops.splice(t,1)},s.prototype._renderLoop=function(){var t=!0;if(!this.renderEvenInBackground&&this._windowIsBackground&&(t=!1),t){this.beginFrame();for(var i=0;i0?e.Tools.QueueNewFrame(this._bindedRenderFunction,this._vrDisplayEnabled):this._renderingQueueLaunched=!1},s.prototype.runRenderLoop=function(t){this._activeRenderLoops.indexOf(t)===-1&&(this._activeRenderLoops.push(t),this._renderingQueueLaunched||(this._renderingQueueLaunched=!0,this._bindedRenderFunction=this._renderLoop.bind(this),e.Tools.QueueNewFrame(this._bindedRenderFunction)))},s.prototype.switchFullscreen=function(t){this.isFullscreen?e.Tools.ExitFullscreen():(this._pointerLockRequested=t,e.Tools.RequestFullscreen(this._renderingCanvas))},s.prototype.clear=function(e,t,i,r){void 0===r&&(r=!1),this.applyStates();var n=0;t&&e&&(this._gl.clearColor(e.r,e.g,e.b,e.a),n|=this._gl.COLOR_BUFFER_BIT),i&&(this._gl.clearDepth(1),n|=this._gl.DEPTH_BUFFER_BIT),r&&(this._gl.clearStencil(0),n|=this._gl.STENCIL_BUFFER_BIT),this._gl.clear(n)},s.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,!0),o.scissor(a[0],a[1],a[2],a[3]),s===!0?o.enable(o.SCISSOR_TEST):o.disable(o.SCISSOR_TEST)},s.prototype.setViewport=function(e,t,i){var r=t||(navigator.isCocoonJS?window.innerWidth:this.getRenderWidth()),n=i||(navigator.isCocoonJS?window.innerHeight:this.getRenderHeight()),o=e.x||0,s=e.y||0;this._cachedViewport=e,this._gl.viewport(o*r,s*n,r*e.width,n*e.height)},s.prototype.setDirectViewport=function(e,t,i,r){var n=this._cachedViewport;return this._cachedViewport=null,this._gl.viewport(e,t,i,r),n},s.prototype.beginFrame=function(){this._measureFps()},s.prototype.endFrame=function(){this._badOS&&this.flushFramebuffer(),this._vrDisplayEnabled&&this._vrDisplayEnabled.isPresenting&&this._vrDisplayEnabled.submitFrame()},s.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)},s.prototype.setSize=function(e,t){this._renderingCanvas.width=e,this._renderingCanvas.height=t;for(var i=0;i65535){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},s.prototype.bindArrayBuffer=function(e){this.bindBuffer(e,this._gl.ARRAY_BUFFER)},s.prototype.bindIndexBuffer=function(e){this.bindBuffer(e,this._gl.ELEMENT_ARRAY_BUFFER)},s.prototype.bindBuffer=function(e,t){this._currentBoundBuffer[t]!==e&&(this._gl.bindBuffer(t,e),this._currentBoundBuffer[t]=e)},s.prototype.updateArrayBuffer=function(e){this._gl.bufferSubData(this._gl.ARRAY_BUFFER,0,e)},s.prototype.vertexAttribPointer=function(e,t,i,r,n,o,s){var a=this._currentBufferPointers[t],h=!1;a?(a.buffer!==e&&(a.buffer=e,h=!0),a.size!==i&&(a.size=i,h=!0),a.type!==r&&(a.type=r,h=!0),a.normalized!==n&&(a.normalized=n,h=!0),a.stride!==o&&(a.stride=o,h=!0),a.offset!==s&&(a.offset=s, -h=!0)):(h=!0,this._currentBufferPointers[t]={indx:t,size:i,type:r,normalized:n,stride:o,offset:s,buffer:e}),h&&(this.bindArrayBuffer(e),this._gl.vertexAttribPointer(t,i,r,n,o,s))},s.prototype.bindBuffersDirectly=function(e,t,i,r,n){if(this._cachedVertexBuffers!==e||this._cachedEffectForVertexBuffers!==n){this._cachedVertexBuffers=e,this._cachedEffectForVertexBuffers=n;var o=n.getAttributesCount();this.unbindAllAttributes();for(var s=0,a=0;a=0&&(this._gl.enableVertexAttribArray(h),this._vertexAttribArraysEnabled[h]=!0,this.vertexAttribPointer(e,h,i[a],this._gl.FLOAT,!1,r,s)),s+=4*i[a]}}this._cachedIndexBuffer!==t&&(this._cachedIndexBuffer=t,this.bindIndexBuffer(t),this._uintIndicesCurrentlySet=t.is32Bits)},s.prototype.bindBuffers=function(e,t,i){if(this._cachedVertexBuffers!==e||this._cachedEffectForVertexBuffers!==i){this._cachedVertexBuffers=e,this._cachedEffectForVertexBuffers=i;var r=i.getAttributesNames();this.unbindAllAttributes();for(var n=0;n=0){var s=e[r[n]];if(!s)continue;this._gl.enableVertexAttribArray(o),this._vertexAttribArraysEnabled[o]=!0;var a=s.getBuffer();this.vertexAttribPointer(a,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.bindIndexBuffer(t),this._uintIndicesCurrentlySet=t.is32Bits)},s.prototype.unbindInstanceAttributes=function(){for(var e,t=0,i=this._currentInstanceLocations.length;t1)&&!i&&a.width>>a.mipmapCount-1===1;o(d,l._gl,n,a.width,a.height,r,!h,a.isFourCC,(function(){e.Internals.DDSTools.UploadDDSLevels(l._gl,l.getCaps().s3tc,t,a,h,1)}),s)},f instanceof Array?v(c):e.Tools.LoadFile(t,(function(e){v(e)}),null,n.database,!0,y);else{var x=function(t){o(d,l._gl,n,t.width,t.height,r,i,!1,(function(i,r){var n=t.width===i&&t.height===r;n||(l._prepareWorkingCanvas(),l._workingCanvas.width=i,l._workingCanvas.height=r,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)}),s)};f instanceof Array?e.Tools.LoadImage(c,x,y,n.database):e.Tools.LoadImage(t,x,y,n.database)}return d},s.prototype._getInternalFormat=function(e){var t=this._gl.RGBA;switch(e){case s.TEXTUREFORMAT_ALPHA:t=this._gl.ALPHA;break;case s.TEXTUREFORMAT_LUMINANCE:t=this._gl.LUMINANCE;break;case s.TEXTUREFORMAT_LUMINANCE_ALPHA:t=this._gl.LUMINANCE_ALPHA;break;case s.TEXTUREFORMAT_RGB:t=this._gl.RGB;break;case s.TEXTUREFORMAT_RGBA:t=this._gl.RGBA}return t},s.prototype.updateRawTexture=function(e,t,i,r,n){void 0===n&&(n=null);var o=this._getInternalFormat(i);this._bindTextureDirectly(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._bindTextureDirectly(this._gl.TEXTURE_2D,null),this.resetTextureCache(),e.isReady=!0},s.prototype.createRawTexture=function(e,t,i,r,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,r,s,h),this._bindTextureDirectly(this._gl.TEXTURE_2D,c);var l=n(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),o&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(this._gl.TEXTURE_2D,null),c.samplingMode=a,this._loadedTexturesCache.push(c),c},s.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},s.prototype.updateTextureSamplingMode=function(e,t){var i=n(e,t.generateMipMaps,this._gl);t.isCube?(this._bindTextureDirectly(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._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null)):(this._bindTextureDirectly(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._bindTextureDirectly(this._gl.TEXTURE_2D,null))},s.prototype.updateDynamicTexture=function(e,t,i,r){void 0===r&&(r=!1),this._bindTextureDirectly(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._bindTextureDirectly(this._gl.TEXTURE_2D,null),r&&this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),this.resetTextureCache(),e.isReady=!0},s.prototype.updateVideoTexture=function(e,t,i){if(!e._isDisabled){this._bindTextureDirectly(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._bindTextureDirectly(this._gl.TEXTURE_2D,null),this.resetTextureCache(),e.isReady=!0}catch(r){e._isDisabled=!0}}},s.prototype.createRenderTargetTexture=function(t,i){var o=!1,a=!0,h=!1,c=s.TEXTURETYPE_UNSIGNED_INT,l=e.Texture.TRILINEAR_SAMPLINGMODE;void 0!==i&&(o=void 0===i.generateMipMaps?i:i.generateMipMaps,a=void 0===i.generateDepthBuffer||i.generateDepthBuffer,h=a&&i.generateStencilBuffer,c=void 0===i.type?c:i.type,void 0!==i.samplingMode&&(l=i.samplingMode),c!==s.TEXTURETYPE_FLOAT||this._caps.textureFloatLinearFiltering?c!==s.TEXTURETYPE_HALF_FLOAT||this._caps.textureHalfFloatLinearFiltering||(l=e.Texture.NEAREST_SAMPLINGMODE):l=e.Texture.NEAREST_SAMPLINGMODE);var u=this._gl,d=u.createTexture();this._bindTextureDirectly(u.TEXTURE_2D,d);var f=t.width||t,p=t.height||t,_=n(l,o,u);c!==s.TEXTURETYPE_FLOAT||this._caps.textureFloat||(c=s.TEXTURETYPE_UNSIGNED_INT,e.Tools.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type")),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_MAG_FILTER,_.mag),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_MIN_FILTER,_.min),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_WRAP_S,u.CLAMP_TO_EDGE),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_WRAP_T,u.CLAMP_TO_EDGE),u.texImage2D(u.TEXTURE_2D,0,u.RGBA,f,p,0,u.RGBA,r(u,c),null);var m;h?(m=u.createRenderbuffer(),u.bindRenderbuffer(u.RENDERBUFFER,m),u.renderbufferStorage(u.RENDERBUFFER,u.DEPTH_STENCIL,f,p)):a&&(m=u.createRenderbuffer(),u.bindRenderbuffer(u.RENDERBUFFER,m),u.renderbufferStorage(u.RENDERBUFFER,u.DEPTH_COMPONENT16,f,p));var g=u.createFramebuffer();return this.bindUnboundFramebuffer(g),h?u.framebufferRenderbuffer(u.FRAMEBUFFER,u.DEPTH_STENCIL_ATTACHMENT,u.RENDERBUFFER,m):a&&u.framebufferRenderbuffer(u.FRAMEBUFFER,u.DEPTH_ATTACHMENT,u.RENDERBUFFER,m),u.framebufferTexture2D(u.FRAMEBUFFER,u.COLOR_ATTACHMENT0,u.TEXTURE_2D,d,0),o&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(u.TEXTURE_2D,null),u.bindRenderbuffer(u.RENDERBUFFER,null),this.bindUnboundFramebuffer(null),d._framebuffer=g,a&&(d._depthBuffer=m),d._baseWidth=f,d._baseHeight=p,d._width=f,d._height=p,d.isReady=!0,d.generateMipMaps=o,d.references=1,d.samplingMode=l,d.type=c,this.resetTextureCache(),this._loadedTexturesCache.push(d),d},s.prototype.createRenderTargetCubeTexture=function(t,i){var r=this._gl,o=r.createTexture(),s=!0,a=!0,h=!1,c=e.Texture.TRILINEAR_SAMPLINGMODE;void 0!==i&&(s=void 0===i.generateMipMaps?i:i.generateMipMaps,a=void 0===i.generateDepthBuffer||i.generateDepthBuffer,h=a&&i.generateStencilBuffer,void 0!==i.samplingMode&&(c=i.samplingMode)),o.isCube=!0,o.references=1,o.generateMipMaps=s,o.references=1,o.samplingMode=c;var l=n(c,s,r);this._bindTextureDirectly(r.TEXTURE_CUBE_MAP,o);for(var u=0;u<6;u++)r.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+u,0,r.RGBA,t,t,0,r.RGBA,r.UNSIGNED_BYTE,null);r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_MAG_FILTER,l.mag),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_MIN_FILTER,l.min),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE);var d;h?(d=r.createRenderbuffer(),r.bindRenderbuffer(r.RENDERBUFFER,d),r.renderbufferStorage(r.RENDERBUFFER,r.DEPTH_STENCIL,t,t)):a&&(d=r.createRenderbuffer(),r.bindRenderbuffer(r.RENDERBUFFER,d),r.renderbufferStorage(r.RENDERBUFFER,r.DEPTH_COMPONENT16,t,t));var f=r.createFramebuffer();return this.bindUnboundFramebuffer(f),h?r.framebufferRenderbuffer(r.FRAMEBUFFER,r.DEPTH_STENCIL_ATTACHMENT,r.RENDERBUFFER,d):a&&r.framebufferRenderbuffer(r.FRAMEBUFFER,r.DEPTH_ATTACHMENT,r.RENDERBUFFER,d),o.generateMipMaps&&(this._bindTextureDirectly(r.TEXTURE_CUBE_MAP,o),r.generateMipmap(r.TEXTURE_CUBE_MAP)),this._bindTextureDirectly(r.TEXTURE_CUBE_MAP,null),r.bindRenderbuffer(r.RENDERBUFFER,null),this.bindUnboundFramebuffer(null),o._framebuffer=f,a&&(o._depthBuffer=d),o._width=t,o._height=t,o.isReady=!0,this.resetTextureCache(),this._loadedTexturesCache.push(o),o},s.prototype.createCubeTexture=function(t,i,r,n,o,s){var h=this;void 0===o&&(o=null),void 0===s&&(s=null);var c=this._gl,l=c.createTexture();l.isCube=!0,l.url=t,l.references=1,l.onLoadedCallbacks=[];var u=t.substr(t.length-4,4).toLowerCase(),d=this.getCaps().s3tc&&".dds"===u;return d?e.Tools.LoadFile(t,(function(t){var i=e.Internals.DDSTools.GetDDSInfo(t),r=(i.isRGB||i.isLuminance||i.mipmapCount>1)&&!n;h._bindTextureDirectly(c.TEXTURE_CUBE_MAP,l),c.pixelStorei(c.UNPACK_FLIP_Y_WEBGL,1),e.Internals.DDSTools.UploadDDSLevels(h._gl,h.getCaps().s3tc,t,i,r,6),n||i.isFourCC||1!==i.mipmapCount||c.generateMipmap(c.TEXTURE_CUBE_MAP),c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MAG_FILTER,c.LINEAR),c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MIN_FILTER,r?c.LINEAR_MIPMAP_LINEAR:c.LINEAR),c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE),c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE),h._bindTextureDirectly(c.TEXTURE_CUBE_MAP,null),h.resetTextureCache(),l._width=i.width,l._height=i.height,l.isReady=!0}),null,null,!0,s):a(t,i,(function(t){var i=e.Tools.GetExponentOfTwo(t[0].width,h._caps.maxCubemapTextureSize),r=i;h._prepareWorkingCanvas(),h._workingCanvas.width=i,h._workingCanvas.height=r;var s=[c.TEXTURE_CUBE_MAP_POSITIVE_X,c.TEXTURE_CUBE_MAP_POSITIVE_Y,c.TEXTURE_CUBE_MAP_POSITIVE_Z,c.TEXTURE_CUBE_MAP_NEGATIVE_X,c.TEXTURE_CUBE_MAP_NEGATIVE_Y,c.TEXTURE_CUBE_MAP_NEGATIVE_Z];h._bindTextureDirectly(c.TEXTURE_CUBE_MAP,l),c.pixelStorei(c.UNPACK_FLIP_Y_WEBGL,0);for(var a=0;a>y;d.texImage2D(o[0],y,p,x,x,0,p,_,a[y][0]),d.texImage2D(o[1],y,p,x,x,0,p,_,a[y][2]),d.texImage2D(o[2],y,p,x,x,0,p,_,a[y][4]),d.texImage2D(o[3],y,p,x,x,0,p,_,a[y][1]),d.texImage2D(o[4],y,p,x,x,0,p,_,a[y][3]),d.texImage2D(o[5],y,p,x,x,0,p,_,a[y][5])}}else{for(var b=0;b-1&&t.splice(i,1),this._releaseTexture(e)}},s.prototype.unbindAllAttributes=function(){for(var e=0,t=this._vertexAttribArraysEnabled.length;e=this._caps.maxVertexAttribs||!this._vertexAttribArraysEnabled[e]||this._vertexAttribArraysEnabled[e]&&(this._gl.disableVertexAttribArray(e),this._vertexAttribArraysEnabled[e]=!1)},s.prototype.dispose=function(){for(this.hideLoadingUI(),this.stopRenderLoop();this.scenes.length;)this.scenes[0].dispose();s.audioEngine.dispose();for(var e in this._compiledEffects)this._gl.deleteProgram(this._compiledEffects[e]._program);this.unbindAllAttributes(),this._gl=null,this.disableVR(),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)},s.prototype.displayLoadingUI=function(){this._loadingScreen.displayLoadingUI()},s.prototype.hideLoadingUI=function(){this._loadingScreen.hideLoadingUI()},Object.defineProperty(s.prototype,"loadingScreen",{get:function(){return this._loadingScreen},set:function(e){this._loadingScreen=e},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"loadingUIText",{set:function(e){this._loadingScreen.loadingUIText=e},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"loadingUIBackgroundColor",{set:function(e){this._loadingScreen.loadingUIBackgroundColor=e},enumerable:!0,configurable:!0}),s.prototype.attachContextLostEvent=function(e){this._renderingCanvas.addEventListener("webglcontextlost",e,!1)},s.prototype.attachContextRestoredEvent=function(e){this._renderingCanvas.addEventListener("webglcontextrestored",e,!1)},s.prototype.getVertexShaderSource=function(e){var t=this._gl.getAttachedShaders(e);return this._gl.getShaderSource(t[0])},s.prototype.getFragmentShaderSource=function(e){var t=this._gl.getAttachedShaders(e);return this._gl.getShaderSource(t[1])},s.prototype.getFps=function(){return this.fps},s.prototype.getDeltaTime=function(){return this.deltaTime},s.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;r0&&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;i0&&(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})();t.FilesTextures=new Array,t.FilesToLoad=new Array,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]),d=e.Vector3.FromArray(c,3*n[3*this.faceId+2]),f=l.subtract(u),p=d.subtract(u);r=e.Vector3.Cross(f,p)}return t&&(r=e.Vector3.TransformNormal(r,this.pickedMesh.getWorldMatrix())),e.Vector3.Normalize(r)},t.prototype.getTextureCoordinates=function(){if(!this.pickedMesh||!this.pickedMesh.isVerticesDataPresent(e.VertexBuffer.UVKind))return null;var t=this.pickedMesh.getIndices(),i=this.pickedMesh.getVerticesData(e.VertexBuffer.UVKind),r=e.Vector2.FromArray(i,2*t[3*this.faceId]),n=e.Vector2.FromArray(i,2*t[3*this.faceId+1]),o=e.Vector2.FromArray(i,2*t[3*this.faceId+2]);return r=r.scale(1-this.bu-this.bv),n=n.scale(this.bu),o=o.scale(this.bv),new e.Vector2(r.x+n.x+o.x,r.y+n.y+o.y)},t})();e.PickingInfo=i})(BABYLON||(BABYLON={}));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;t<6;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)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.xt.x-this.minimumWorld.x)&&(!(this.maximumWorld.y-t.yt.y-this.minimumWorld.y)&&!(this.maximumWorld.z-t.zt.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.xt.x)&&(!(this.maximumWorld.yt.y)&&!(this.maximumWorld.zt.z))},t.Intersects=function(e,t){return!(e.maximumWorld.xt.maximumWorld.x)&&(!(e.maximumWorld.yt.maximumWorld.y)&&!(e.maximumWorld.zt.maximumWorld.z))},t.IntersectsSphere=function(t,i,r,n){var o=e.Vector3.Clamp(r,t,i),s=e.Vector3.DistanceSquared(r,o);return s<=n*n},t.IsCompletelyInFrustum=function(e,t){for(var i=0;i<6;i++)for(var r=0;r<8;r++)if(t[i].dotCoordinate(e[r])<0)return!1;return!0},t.IsInFrustum=function(e,t){for(var i=0;i<6;i++){for(var r=8,n=0;n<8&&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)},t.prototype.isCompletelyInFrustum=function(e){return this.boundingBox.isCompletelyInFrustum(e)},t.prototype._checkCollision=function(e){return e._canDoCollision(this.boundingSphere.centerWorld,this.boundingSphere.radiusWorld,this.boundingBox.minimumWorld,this.boundingBox.maximumWorld)},t.prototype.intersectsPoint=function(e){return!!this.boundingSphere.centerWorld&&(!!this.boundingSphere.intersectsPoint(e)&&!!this.boundingBox.intersectsPoint(e))},t.prototype.intersects=function(t,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))))))))))))))},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,this._show=!1}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.xt.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.yt.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.zt.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(n<=o)return!0;var s=t*this.direction.x+i*this.direction.y+r*this.direction.z;if(s<0)return!1;var a=n-s*s;return a<=o},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(s<0||s>1)return null;e.Vector3.CrossToRef(this._tvec,this._edge1,this._qvec);var a=e.Vector3.Dot(this.direction,this._qvec)*o;if(a<0||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,i<0?i<-9.99999997475243e-7?null:0:i},t.prototype.intersectsMesh=function(i,r){var n=e.Tmp.Matrix[0];return i.getWorldMatrix().invertToRef(n),this._tmpRay?t.TransformToRef(this,n,this._tmpRay):this._tmpRay=t.Transform(this,n),i.intersects(this._tmpRay,r)},t.prototype.show=function(t,i){this._show||(this._renderFunction=this._render.bind(this),this._show=!0,this._scene=t,this._renderPoints=[this.origin,this.origin.add(this.direction.scale(this.length))],this._renderLine=e.Mesh.CreateLines("ray",this._renderPoints,t,!0),this._scene.registerBeforeRender(this._renderFunction)),i&&this._renderLine.color.copyFrom(i)},t.prototype.hide=function(){this._show&&(this._show=!1,this._scene.unregisterBeforeRender(this._renderFunction)),this._renderLine&&(this._renderLine.dispose(),this._renderLine=null,this._renderPoints=null)},t.prototype._render=function(){var t=this._renderPoints[1];t.copyFrom(this.direction),t.scaleInPlace(this.length),t.addInPlace(this.origin),e.Mesh.CreateLines("ray",this._renderPoints,this._scene,!0,this._renderLine)},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),d=i.subtract(this.origin),f=e.Vector3.Dot(l,l),p=e.Vector3.Dot(l,u),_=e.Vector3.Dot(u,u),m=e.Vector3.Dot(l,d),g=e.Vector3.Dot(u,d),v=f*_-p*p,y=v,x=v;vy&&(s=y,h=g+p,x=_)),h<0?(h=0,-m<0?s=0:-m>f?s=y:(s=-m,y=f)):h>x&&(h=x,-m+p<0?s=0:-m+p>f?s=y:(s=-m+p,y=f)),o=Math.abs(s)0&&a<=this.length&&A.lengthSquared()e.Engine.CollisionsEpsilon&&o.position.addInPlace(o._diffPositionForCollisions),r&&o.onCollideObservable.notifyObservers(r),o.onCollisionPositionChangeObservable.notifyObservers(o.position)},n.addMesh(o),o}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,"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.getClassName=function(){return"AbstractMesh"},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)},i.prototype.setBoundingInfo=function(e){this._boundingInfo=e},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,r,n){t.normalize(),this.rotationQuaternion||(this.rotationQuaternion=e.Quaternion.RotationYawPitchRoll(this.rotation.y,this.rotation.x,this.rotation.z),this.rotation=e.Vector3.Zero());var o;if(n&&n!==e.Space.LOCAL){if(this.parent){var s=this.parent.getWorldMatrix().clone();s.invert(),t=e.Vector3.TransformNormal(t,s)}o=e.Quaternion.RotationAxisToRef(t,r,i._rotationAxisCache),o.multiplyToRef(this.rotationQuaternion,this.rotationQuaternion)}else o=e.Quaternion.RotationAxisToRef(t,r,i._rotationAxisCache),this.rotationQuaternion.multiplyToRef(o,this.rotationQuaternion)},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(){return!this._isDirty&&(this.billboardMode===this._cache.billboardMode&&this.billboardMode===i.BILLBOARDMODE_NONE&&(!this._cache.pivotMatrixUpdated&&(!this.infiniteDistance&&(!!this._cache.position.equals(this.position)&&(!(this.rotationQuaternion&&!this._cache.rotationQuaternion.equals(this.rotationQuaternion))&&(!!this._cache.rotation.equals(this.rotation)&&!!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;t1&&!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;c1)||l.canIntersects(t)){var u=l.intersects(t,this._positions,this.getIndices(),i);if(u&&(i||!s||u.distance0&&this.includedOnlyMeshes.indexOf(e)===-1)&&(!(this.excludedMeshes.length>0&&this.excludedMeshes.indexOf(e)!==-1)&&((0===this.includeOnlyWithLayerMask||0!==(this.includeOnlyWithLayerMask&e.layerMask))&&!(0!==this.excludeWithLayerMask&&this.excludeWithLayerMask&e.layerMask)))},i.prototype.getWorldMatrix=function(){this._currentRenderId=this.getScene().getRenderId();var t=this._getWorldMatrix();return this.parent&&this.parent.getWorldMatrix?(this._parentedWorldMatrix||(this._parentedWorldMatrix=e.Matrix.Identity()),t.multiplyToRef(this.parent.getWorldMatrix(),this._parentedWorldMatrix),this._markSyncedWithParent(),this._parentedWorldMatrix):t},i.prototype.dispose=function(){this._shadowGenerator&&(this._shadowGenerator.dispose(),this._shadowGenerator=null),this.getScene().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;othis._orthoRight&&(this._orthoRight=o.x),o.y>this._orthoTop&&(this._orthoTop=o.y)}}}var u=this._orthoRight-this._orthoLeft,d=this._orthoTop-this._orthoBottom;e.Matrix.OrthoOffCenterLHToRef(this._orthoLeft-u*this.shadowOrthoScale,this._orthoRight+u*this.shadowOrthoScale,this._orthoBottom-d*this.shadowOrthoScale,this._orthoTop+d*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)},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},i})(e.Light);__decorate([e.serializeAsVector3()],t.prototype,"position",void 0),__decorate([e.serializeAsVector3()],t.prototype,"direction",void 0), -__decorate([e.serialize()],t.prototype,"shadowOrthoScale",void 0),__decorate([e.serialize()],t.prototype,"autoUpdateExtends",void 0),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._useFullFloat=!0,this._light=r,this._scene=r.getScene(),this._mapSize=i,r._shadowGenerator=this;var o,s=this._scene.getEngine().getCaps();s.textureFloat&&s.textureFloatLinearFiltering&&s.textureFloatRender?(this._useFullFloat=!0,o=e.Engine.TEXTURETYPE_FLOAT):(this._useFullFloat=!1,o=e.Engine.TEXTURETYPE_UNSIGNED_INT),this._shadowMap=new e.RenderTargetTexture(r.name+"_shadowMap",i,this._scene,(!1),(!0),o,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),(!0),o),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 a=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;r4&&(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 h=r.join("\n");return this._cachedDefines!==h&&(this._cachedDefines=h,this._effect=this._scene.getEngine().createEffect("shadowMap",n,["world","mBones","viewProjection","diffuseMatrix","lightPosition","depthValues"],["diffuseSampler"],h)),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:e<=0?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;ti.x+r)&&(!(i.x-r>t.x)&&(!(e.y>i.y+r)&&(!(i.y-r>t.y)&&(!(e.z>i.z+r)&&!(i.z-r>t.z)))))},i=(function(){var e={root:0,found:!1};return function(t,i,r,n){e.root=0,e.found=!1;var o=i*i-4*t*r;if(o<0)return e;var s=Math.sqrt(o),a=(-i-s)/(2*t),h=(-i+s)/(2*t);if(a>h){var c=h;h=a,a=c}return a>0&&a0&&h=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)&&!!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),d=e.Vector3.Dot(l.normal,this.velocity);if(0==d){if(Math.abs(u)>=1)return;c=!0,h=0}else{h=(-1-u)/d;var f=(1-u)/d;if(h>f){var p=f;f=h,h=p}if(h>1||f<0)return;h<0&&(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 A=this._edge.lengthSquared(),E=e.Vector3.Dot(this._edge,this.velocity),T=e.Vector3.Dot(this._edge,this._baseToVertex);if(v=A*-g+E*E,y=A*(2*e.Vector3.Dot(this.velocity,this._baseToVertex))-2*E*T,x=A*(1-this._baseToVertex.lengthSquared())+T*T,b=i(v,y,x,m),b.found){var P=(E*b.root-T)/A;P>=0&&P<=1&&(m=b.root,_=!0,this._edge.scaleInPlace(P),n.addToRef(this._edge,this._collisionPoint))}s.subtractToRef(o,this._edge),o.subtractToRef(this.basePoint,this._baseToVertex),A=this._edge.lengthSquared(),E=e.Vector3.Dot(this._edge,this.velocity),T=e.Vector3.Dot(this._edge,this._baseToVertex),v=A*-g+E*E,y=A*(2*e.Vector3.Dot(this.velocity,this._baseToVertex))-2*E*T,x=A*(1-this._baseToVertex.lengthSquared())+T*T,b=i(v,y,x,m),b.found&&(P=(E*b.root-T)/A,P>=0&&P<=1&&(m=b.root,_=!0,this._edge.scaleInPlace(P),o.addToRef(this._edge,this._collisionPoint))),n.subtractToRef(s,this._edge),s.subtractToRef(this.basePoint,this._baseToVertex),A=this._edge.lengthSquared(),E=e.Vector3.Dot(this._edge,this.velocity),T=e.Vector3.Dot(this._edge,this._baseToVertex),v=A*-g+E*E,y=A*(2*e.Vector3.Dot(this.velocity,this._baseToVertex))-2*E*T,x=A*(1-this._baseToVertex.lengthSquared())+T*T,b=i(v,y,x,m),b.found&&(P=(E*b.root-T)/A,P>=0&&P<=1&&(m=b.root,_=!0,this._edge.scaleInPlace(P),s.addToRef(this._edge,this._collisionPoint)))}if(_){var M=m*this.velocity.length();(!this.collisionFound||M4)){++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})();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()||[])}},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;h0&&this._postProcesses[0].markTextureDirty();for(var t=0,i=this._rigCameras.length;t-1?(e.Tools.Error("You're trying to reuse a post process not defined as reusable."),0):(null==i||i<0?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);o!==-1&&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._refreshFrustumPlanes=!0,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.freezeProjectionMatrix=function(e){this._doNotComputeProjectionMatrix=!0,void 0!==e&&(this._projectionMatrix=e)},i.prototype.unfreezeProjectionMatrix=function(){this._doNotComputeProjectionMatrix=!1},i.prototype.getProjectionMatrix=function(t){if(this._doNotComputeProjectionMatrix||!t&&this._isSynchronizedProjectionMatrix())return this._projectionMatrix;this._refreshFrustumPlanes=!0;var r=this.getEngine(),n=this.getScene();if(this.mode===i.PERSPECTIVE_CAMERA)return this.minZ<=0&&(this.minZ=.1),n.useRightHandedSystem?e.Matrix.PerspectiveFovRHToRef(this.fov,r.getAspectRatio(this),this.minZ,this.maxZ,this._projectionMatrix,this.fovMode===i.FOVMODE_VERTICAL_FIXED):e.Matrix.PerspectiveFovLHToRef(this.fov,r.getAspectRatio(this),this.minZ,this.maxZ,this._projectionMatrix,this.fovMode===i.FOVMODE_VERTICAL_FIXED),this._projectionMatrix;var o=r.getRenderWidth()/2,s=r.getRenderHeight()/2;return n.useRightHandedSystem?e.Matrix.OrthoOffCenterRHToRef(this.orthoLeft||-o,this.orthoRight||o,this.orthoBottom||-s,this.orthoTop||s,this.minZ,this.maxZ,this._projectionMatrix):e.Matrix.OrthoOffCenterLHToRef(this.orthoLeft||-o,this.orthoRight||o,this.orthoBottom||-s,this.orthoTop||s,this.minZ,this.maxZ,this._projectionMatrix), -this._projectionMatrix},i.prototype.getTranformationMatrix=function(){return this._computedViewMatrix.multiplyToRef(this._projectionMatrix,this._transformMatrix),this._transformMatrix},i.prototype.updateFrustumPlanes=function(){this._refreshFrustumPlanes&&(this.getTranformationMatrix(),this._frustumPlanes?e.Frustum.GetPlanesToRef(this._transformMatrix,this._frustumPlanes):this._frustumPlanes=e.Frustum.GetPlanes(this._transformMatrix),this._refreshFrustumPlanes=!1)},i.prototype.isInFrustum=function(e){return this.updateFrustumPlanes(),e.isInFrustum(this._frustumPlanes)},i.prototype.isCompletelyInFrustum=function(e){return this.updateFrustumPlanes(),e.isCompletelyInFrustum(this._frustumPlanes)},i.prototype.dispose=function(){for(this.getScene().stopAnimation(this),this.getScene().removeCamera(this);this._rigCameras.length>0;)this._rigCameras.pop().dispose();for(var e=this._postProcesses.length;--e>=0;)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));break;case i.RIG_MODE_WEBVR:r.vrDisplay&&(this._rigCameras[0].viewport=new e.Viewport(0,0,.5,1),this._rigCameras[0].setCameraRigParameter("left",!0),this._rigCameras[0].setCameraRigParameter("frameData",r.frameData),this._rigCameras[0]._cameraRigParams.vrWorkMatrix=new e.Matrix,this._rigCameras[0].getProjectionMatrix=this._getWebVRProjectionMatrix,this._rigCameras[1].viewport=new e.Viewport(.5,0,.5,1),this._rigCameras[1].setCameraRigParameter("frameData",r.frameData),this._rigCameras[1]._cameraRigParams.vrWorkMatrix=new e.Matrix,this._rigCameras[1].getProjectionMatrix=this._getWebVRProjectionMatrix)}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._getWebVRProjectionMatrix=function(){var t=this._cameraRigParams.left?this._cameraRigParams.frameData.leftProjectionMatrix:this._cameraRigParams.frameData.rightProjectionMatrix;return[8,9,10,11].forEach((function(e){t[e]*=-1})),e.Matrix.FromArrayToRef(t,0,this._projectionMatrix),this._projectionMatrix},i.prototype._getWebVRViewMatrix=function(){var t=this._cameraRigParams.left?this._cameraRigParams.frameData.leftViewMatrix:this._cameraRigParams.frameData.rightViewMatrix;return[8,9,10,11].forEach((function(e){t[e]*=-1})),e.Matrix.FromArrayToRef(t,0,this._webvrViewMatrix),this._webvrViewMatrix},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=0&&r._keys.splice(t,1),i||e.preventDefault()}},t.addEventListener("keydown",this._onKeyDown,!1),t.addEventListener("keyup",this._onKeyUp,!1),e.Tools.RegisterTopRootEvents([{name:"blur",handler:this._onLostFocus}]))},t.prototype.detachControl=function(t){this._onKeyDown&&(t.removeEventListener("keydown",this._onKeyDown),t.removeEventListener("keyup",this._onKeyUp),e.Tools.UnregisterTopRootEvents([{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;i1)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"},t})();__decorate([e.serialize()],t.prototype,"touchAngularSensibility",void 0),__decorate([e.serialize()],t.prototype,"touchMoveSensibility",void 0),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),this._orientationChanged()},t.prototype.detachControl=function(e){window.removeEventListener("orientationchange",this._orientationChanged),window.removeEventListener("deviceorientation",this._deviceOrientation)},t.prototype.checkInputs=function(){this._alpha&&(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 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"},t})();__decorate([e.serialize()],t.prototype,"gamepadAngularSensibility",void 0),__decorate([e.serialize()],t.prototype,"gamepadMoveSensibility",void 0),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;t.tabIndex=1,this._onKeyDown=function(e){if(r.keysUp.indexOf(e.keyCode)!==-1||r.keysDown.indexOf(e.keyCode)!==-1||r.keysLeft.indexOf(e.keyCode)!==-1||r.keysRight.indexOf(e.keyCode)!==-1){var t=r._keys.indexOf(e.keyCode);t===-1&&r._keys.push(e.keyCode),e.preventDefault&&(i||e.preventDefault())}},this._onKeyUp=function(e){if(r.keysUp.indexOf(e.keyCode)!==-1||r.keysDown.indexOf(e.keyCode)!==-1||r.keysLeft.indexOf(e.keyCode)!==-1||r.keysRight.indexOf(e.keyCode)!==-1){var t=r._keys.indexOf(e.keyCode);t>=0&&r._keys.splice(t,1),e.preventDefault&&(i||e.preventDefault())}},this._onLostFocus=function(){r._keys=[]},t.addEventListener("keydown",this._onKeyDown,!1),t.addEventListener("keyup",this._onKeyUp,!1),e.Tools.RegisterTopRootEvents([{name:"blur",handler:this._onLostFocus}])},t.prototype.detachControl=function(t){t&&(t.removeEventListener("keydown",this._onKeyDown),t.removeEventListener("keyup",this._onKeyUp)),e.Tools.UnregisterTopRootEvents([{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.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"},t})();__decorate([e.serialize()],t.prototype,"gamepadRotationSensibility",void 0),__decorate([e.serialize()],t.prototype,"gamepadMoveSensibility",void 0),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){var o=t.call(this,i,r,n)||this;return o.cameraDirection=new e.Vector3(0,0,0),o.cameraRotation=new e.Vector2(0,0),o.rotation=new e.Vector3(0,0,0),o.speed=2,o.noRotationConstraint=!1,o.lockedTarget=null,o._currentTarget=e.Vector3.Zero(),o._viewMatrix=e.Matrix.Zero(),o._camMatrix=e.Matrix.Zero(),o._cameraTransformMatrix=e.Matrix.Zero(),o._cameraRotationMatrix=e.Matrix.Zero(),o._referencePoint=new e.Vector3(0,0,1),o._defaultUpVector=new e.Vector3(0,1,0),o._transformedReferencePoint=e.Vector3.Zero(),o._lookAtTemp=e.Matrix.Zero(),o._tempMatrix=e.Matrix.Zero(),o}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.absolutePosition&&this.lockedTarget.computeWorldMatrix(),this.lockedTarget.absolutePosition||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*Math.sqrt(e.getDeltaTime()/(100*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.Engine.CollisionsEpsilon&&(o.position.addInPlace(o._diffPosition),o.onCollide&&r&&o.onCollide(r))};n(i)},o.inputs=new e.FreeCameraInputsManager(o),o.inputs.addKeyboard().addMouse(),o}return __extends(i,t),Object.defineProperty(i.prototype,"angularSensibility",{get:function(){var e=this.inputs.attached.mouse;if(e)return e.angularSensibility},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;if(e)return e.keysUp},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;if(e)return e.keysDown},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;if(e)return e.keysLeft},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;if(e)return e.keysRight},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.getClassName=function(){return"FreeCamera"},i})(e.TargetCamera);__decorate([e.serializeAsVector3()],t.prototype,"ellipsoid",void 0),__decorate([e.serialize()],t.prototype,"checkCollisions",void 0),__decorate([e.serialize()],t.prototype,"applyGravity",void 0),e.FreeCamera=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(e){return t.call(this,e)||this}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.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){var o=t.call(this,e,i,r)||this;return o.radius=12,o.rotationOffset=0,o.heightOffset=4,o.cameraAcceleration=.05,o.maxCameraSpeed=20,o.lockedTarget=n,o}return __extends(i,t),i.prototype.getRadians=function(e){return e*Math.PI/180},i.prototype.follow=function(t){if(t){var i;if(t.rotationQuaternion){var r=new e.Matrix;t.rotationQuaternion.toRotationMatrix(r),i=Math.atan2(r.m[8],r.m[10])}else i=t.rotation.y;var n=this.getRadians(this.rotationOffset)+i,o=t.position.x+Math.sin(n)*this.radius,s=t.position.z+Math.cos(n)*this.radius,a=o-this.position.x,h=t.position.y+this.heightOffset-this.position.y,c=s-this.position.z,l=a*this.cameraAcceleration*2,u=h*this.cameraAcceleration,d=c*this.cameraAcceleration*2;(l>this.maxCameraSpeed||l<-this.maxCameraSpeed)&&(l=l<1?-this.maxCameraSpeed:this.maxCameraSpeed),(u>this.maxCameraSpeed||u<-this.maxCameraSpeed)&&(u=u<1?-this.maxCameraSpeed:this.maxCameraSpeed),(d>this.maxCameraSpeed||d<-this.maxCameraSpeed)&&(d=d<1?-this.maxCameraSpeed:this.maxCameraSpeed),this.position=new e.Vector3(this.position.x+l,this.position.y+u,this.position.z+d),this.setTarget(t.position)}},i.prototype._checkInputs=function(){t.prototype._checkInputs.call(this),this.follow(this.lockedTarget)},i.prototype.getClassName=function(){return"FollowCamera"},i})(e.TargetCamera);__decorate([e.serialize()],t.prototype,"radius",void 0),__decorate([e.serialize()],t.prototype,"rotationOffset",void 0),__decorate([e.serialize()],t.prototype,"heightOffset",void 0),__decorate([e.serialize()],t.prototype,"cameraAcceleration",void 0),__decorate([e.serialize()],t.prototype,"maxCameraSpeed",void 0),__decorate([e.serializeAsMeshReference("lockedTargetId")],t.prototype,"lockedTarget",void 0),e.FollowCamera=t;var i=(function(t){function i(i,r,n,o,s,a){var h=t.call(this,i,e.Vector3.Zero(),a)||this;return h.alpha=r,h.beta=n,h.radius=o,h.target=s,h._cartesianCoordinates=e.Vector3.Zero(),h.follow(),h}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.getClassName=function(){return"ArcFollowCamera"},i})(e.TargetCamera);e.ArcFollowCamera=i})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(e){function t(t,i,r){var n=e.call(this,t,i,r)||this;return n.inputs.addTouch(),n._setupInputs(),n}return __extends(t,e),Object.defineProperty(t.prototype,"touchAngularSensibility",{get:function(){var e=this.inputs.attached.touch;if(e)return e.touchAngularSensibility},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;if(e)return e.touchMoveSensibility},set:function(e){var t=this.inputs.attached.touch;t&&(t.touchMoveSensibility=e)},enumerable:!0,configurable:!0}),t.prototype.getClassName=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=t.call(this,i,e.Vector3.Zero(),a)||this;return h.inertialAlphaOffset=0,h.inertialBetaOffset=0,h.inertialRadiusOffset=0,h.lowerAlphaLimit=null,h.upperAlphaLimit=null,h.lowerBetaLimit=.01,h.upperBetaLimit=Math.PI,h.lowerRadiusLimit=null,h.upperRadiusLimit=null,h.inertialPanningX=0,h.inertialPanningY=0,h.zoomOnFactor=1,h.targetScreenOffset=e.Vector2.Zero(),h.allowUpsideDown=!0,h._viewMatrix=new e.Matrix,h.panningAxis=new e.Vector3(1,1,0),h.checkCollisions=!1,h.collisionRadius=new e.Vector3(.5,.5,.5),h._collider=new e.Collider,h._previousPosition=e.Vector3.Zero(),h._collisionVelocity=e.Vector3.Zero(),h._newPosition=e.Vector3.Zero(),h._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?h.target=s:h.target=e.Vector3.Zero(),h.alpha=r,h.beta=n,h.radius=o,h.getViewMatrix(),h.inputs=new e.ArcRotateCameraInputsManager(h),h.inputs.addKeyboard().addMouseWheel().addPointers().addGamepad(),h}return __extends(i,t),Object.defineProperty(i.prototype,"angularSensibilityX",{get:function(){var e=this.inputs.attached.pointers;if(e)return e.angularSensibilityX},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;if(e)return e.angularSensibilityY},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;if(e)return e.pinchPrecision},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;if(e)return e.panningSensibility},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;if(e)return e.keysUp},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;if(e)return e.keysDown},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;if(e)return e.keysLeft},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;if(e)return e.keysRight},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;if(e)return e.wheelPrecision},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(){if(this.target.getAbsolutePosition){var e=this.target.getAbsolutePosition();return this._targetBoundingCenter?e.add(this._targetBoundingCenter):e}return 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))},i.prototype.attachControl=function(e,t,i,r){var n=this;void 0===i&&(i=!0),void 0===r&&(r=2),this._useCtrlForPanning=i,this._panningMouseButton=r,this.inputs.attachElement(e,t),this._reset=function(){n.inertialAlphaOffset=0,n.inertialBetaOffset=0,n.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.getScene().useRightHandedSystem?this.alpha-=this.beta<=0?-this.inertialAlphaOffset:this.inertialAlphaOffset: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)Math.PI&&(this.beta=this.beta-2*Math.PI):this.betathis.upperBetaLimit&&(this.beta=this.upperBetaLimit),this.lowerAlphaLimit&&this.alphathis.upperAlphaLimit&&(this.alpha=this.upperAlphaLimit),this.lowerRadiusLimit&&this.radiusthis.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.copyFrom(e),this.rebuildAnglesAndRadius())},i.prototype.setTarget=function(e,t){void 0===t&&(t=!1),this._getTargetPosition().equals(e)||(t&&e.getBoundingInfo?this._targetBoundingCenter=e.getBoundingInfo().boundingBox.center.clone():this._targetBoundingCenter=null,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()),this.getScene().useRightHandedSystem?e.Matrix.LookAtRHToRef(this.position,o,s,this._viewMatrix):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._currentTarget=o,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.getClassName=function(){return"ArcRotateCamera"},i})(e.TargetCamera);__decorate([e.serialize()],t.prototype,"alpha",void 0),__decorate([e.serialize()],t.prototype,"beta",void 0),__decorate([e.serialize()],t.prototype,"radius",void 0),__decorate([e.serializeAsVector3()],t.prototype,"target",void 0),__decorate([e.serialize()],t.prototype,"inertialAlphaOffset",void 0),__decorate([e.serialize()],t.prototype,"inertialBetaOffset",void 0),__decorate([e.serialize()],t.prototype,"inertialRadiusOffset",void 0),__decorate([e.serialize()],t.prototype,"lowerAlphaLimit",void 0),__decorate([e.serialize()],t.prototype,"upperAlphaLimit",void 0),__decorate([e.serialize()],t.prototype,"lowerBetaLimit",void 0),__decorate([e.serialize()],t.prototype,"upperBetaLimit",void 0),__decorate([e.serialize()],t.prototype,"lowerRadiusLimit",void 0),__decorate([e.serialize()],t.prototype,"upperRadiusLimit",void 0),__decorate([e.serialize()],t.prototype,"inertialPanningX",void 0),__decorate([e.serialize()],t.prototype,"inertialPanningY",void 0),__decorate([e.serialize()],t.prototype,"zoomOnFactor",void 0),__decorate([e.serialize()],t.prototype,"allowUpsideDown",void 0),e.ArcRotateCamera=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(e){return t.call(this,e)||this}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._autoClearDepthStencil={},this._customOpaqueSortCompareFn={},this._customAlphaTestSortCompareFn={},this._customTransparentSortCompareFn={},this._renderinGroupInfo=null,this._scene=e;for(var i=t.MIN_RENDERINGGROUPS;ii._alphaIndex?1:e._alphaIndext._distanceToCamera?-1:0},t.frontToBackSortCompare=function(e,t){return e._distanceToCamerat._distanceToCamera?1:0},t.prototype.prepare=function(){this._opaqueSubMeshes.reset(),this._transparentSubMeshes.reset(),this._alphaTestSubMeshes.reset(),this._particleSystems.reset(),this._spriteManagers.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.prototype.dispatchSprites=function(e){this._spriteManagers.push(e)},t.prototype.dispatchParticles=function(e){this._particleSystems.push(e)},t.prototype._renderParticles=function(e){if(0!==this._particleSystems.length){var t=this._scene.activeCamera;this._scene._particlesDuration.beginMonitoring();for(var i=0;ie.ActionManager.LongPressDelay&&Math.abs(l._startingPointerPosition.x-l._pointerX)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&&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(e){return e.isPickable&&e.isVisible&&e.isReady()});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)),c.pickedMesh.actionManager&&Math.abs(a._startingPointerPosition.x-a._pointerX)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)),c.pickedSprite.actionManager&&Math.abs(a._startingPointerPosition.x-a._pointerX)0)return!1;var t;for(t=0;t0)return;this._animationTimeLast=t}var i=(t-this._animationTimeLast)*this.animationTimeScale;this._animationTime+=i,this._animationTimeLast=t;for(var r=0;r0?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.switchActiveCamera=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-1&&(this._geometries.splice(t,1),this.collisionCoordinator.onGeometryDeleted(e),this.onGeometryRemovedObservable.notifyObservers(e),!0)},i.prototype.getGeometries=function(){return this._geometries},i.prototype.getMeshByID=function(e){for(var t=0;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=0;t--)if(this.skeletons[t].id===e)return this.skeletons[t];return null},i.prototype.getSkeletonById=function(e){for(var t=0;t0&&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(o,s)))}}this._particlesDuration.beginMonitoring();e.Tools.Now;if(this.particlesEnabled){e.Tools.StartPerformanceCounter("Particles",this.particleSystems.length>0);for(var a=0;a0)}this._particlesDuration.endMonitoring(!1)},i.prototype._activeMesh=function(e,t){if(t.skeleton&&this.skeletonsEnabled&&(this._activeSkeletons.pushNoDuplicate(t.skeleton)&&t.skeleton.prepare(),t.computeBonesUsingShaders||this._softwareSkinnedMeshes.pushNoDuplicate(t)),(e.showBoundingBox||this.forceShowBoundingBoxes)&&this._boundingBoxRenderer.renderList.push(e.getBoundingInfo().boundingBox),e._edgesRenderer&&this._edgesRenderers.push(e._edgesRenderer),t&&t.subMeshes){var i,r;if(t._submeshesOctree&&t.useOctreeForRenderingSelection){var n=t._submeshesOctree.select(this._frustumPlanes);i=n.length,r=n.data}else r=t.subMeshes,i=r.length;for(var o=0;o0){this._intermediateRendering=!0,e.Tools.StartPerformanceCounter("Render targets",this._renderTargets.length>0);for(var s=0;s0),this._intermediateRendering=!1,this._renderId++,o=!0}var c=this._engine.getStencilBuffer(),l=!1;if(this.renderTargetsEnabled&&this.highlightLayers&&this.highlightLayers.length>0){this._intermediateRendering=!0;for(var u=0;u-1)){l=!0;var a=d._mainTexture;a._shouldRender()&&(this._renderId++,a.render(!1,!1),o=!0)}}this._intermediateRendering=!1,this._renderId++}o&&i.restoreDefaultFramebuffer(),this._renderTargetsDuration.endMonitoring(!1),this.postProcessManager._prepareFrame(),this._renderDuration.beginMonitoring();var f,p;if(this.layers.length){for(i.setDepthBuffer(!1),f=0;f0);for(var m=0;m0)}if(this.layers.length){for(i.setDepthBuffer(!1),f=0;f-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(){this._lastFrameDuration.beginMonitoring(),this._particlesDuration.fetchNewFrame(),this._spritesDuration.fetchNewFrame(),this._activeParticles.fetchNewFrame(),this._renderDuration.fetchNewFrame(),this._renderTargetsDuration.fetchNewFrame(),this._evaluateActiveMeshesDuration.fetchNewFrame(),this._totalVertices.fetchNewFrame(),this._activeIndices.fetchNewFrame(),this._activeBones.fetchNewFrame(),this.getEngine().drawCallsPerfCounter.fetchNewFrame(),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 t=Math.max(i.MinDeltaTime,Math.min(this._engine.getDeltaTime(),i.MaxDeltaTime));this._animationRatio=.06*t,this._animate(),this._physicsEngine&&(e.Tools.StartPerformanceCounter("Physics"),this._physicsEngine._step(t/1e3),e.Tools.EndPerformanceCounter("Physics")),this.onBeforeRenderObservable.notifyObservers(this),this._renderTargetsDuration.beginMonitoring();var r=(e.Tools.Now,this.getEngine()),n=this.activeCamera;if(this.renderTargetsEnabled){e.Tools.StartPerformanceCounter("Custom render targets",this.customRenderTargets.length>0);for(var o=0;o0),this._renderId++}if(this.customRenderTargets.length>0&&r.restoreDefaultFramebuffer(),this._renderTargetsDuration.endMonitoring(),this.activeCamera=n,this.proceduralTexturesEnabled){e.Tools.StartPerformanceCounter("Procedural textures",this._proceduralTextures.length>0);for(var a=0;a0)}if(this._engine.clear(this.clearColor,this.autoClear||this.forceWireframe||this.forcePointsCloud,!0,!0),this.shadowsEnabled)for(var c=0;c0)for(var d=0;d0&&this._engine.clear(null,!1,!0,!0),this._processSubCameras(this.activeCameras[d]);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 f=0;f0?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-1&&this._engine.scenes.splice(t,1),this._engine.wipeCaches()},i.prototype.disposeSounds=function(){this.mainSoundTrack.dispose();for(var e=0;e=n.distance))&&(n=c,r))break}return n||new e.PickingInfo},i.prototype._internalMultiPick=function(e,t){for(var i=new Array,r=0;r0)for(var s=0;s=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.multiPick=function(e,t,i,r){var n=this;return this._internalMultiPick((function(i){return n.createPickingRay(e,t,i,r)}),i)},i.prototype.multiPickWithRay=function(t,i){var r=this;return this._internalMultiPick((function(i){return r._pickWithRayInverseMatrix||(r._pickWithRayInverseMatrix=e.Matrix.Identity()),i.invertToRef(r._pickWithRayInverseMatrix),e.Ray.Transform(t,r._pickWithRayInverseMatrix)}),i)},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;n0},enumerable:!0,configurable:!0}),r.prototype._sortLODLevels=function(){this._LODLevels.sort((function(e,t){return e.distancet.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;ti)return this.onLODLevelSelection&&this.onLODLevelSelection(i,this,this._LODLevels[this._LODLevels.length-1].mesh),this;for(var r=0;r=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,i=this._geometry.copy(e.Geometry.RandomId());t.releaseForMesh(this,!0),i.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-1&&(o.skeleton=i.getLastSkeletonByID(t.skeletonId),t.numBoneInfluencers&&(o.numBoneInfluencers=t.numBoneInfluencers)),t.animations){for(var s=0;s4,c=h?this.getVerticesData(e.VertexBuffer.MatricesIndicesExtraKind):null,l=h?this.getVerticesData(e.VertexBuffer.MatricesWeightsExtraKind):null,u=t.getTransformMatrices(this),d=e.Vector3.Zero(),f=new e.Matrix,p=new e.Matrix,_=0,m=0;m0);o++)e.Matrix.FromFloat32ArrayToRefScaled(u,16*s[_+o],g,p),f.addToSelf(p);if(h)for(o=0;o<4&&(g=l[_+o],g>0);o++)e.Matrix.FromFloat32ArrayToRefScaled(u,16*c[_+o],g,p),f.addToSelf(p);e.Vector3.TransformCoordinatesFromFloatsToRef(this._sourcePositions[m],this._sourcePositions[m+1],this._sourcePositions[m+2],f,d),d.toArray(r,m),e.Vector3.TransformNormalFromFloatsToRef(this._sourceNormals[m],this._sourceNormals[m+1],this._sourceNormals[m+2],f,d),d.toArray(n,m),f.reset()}return this.updateVerticesData(e.VertexBuffer.PositionKind,r),this.updateVerticesData(e.VertexBuffer.NormalKind,n),this}},r.MinMax=function(e){var t=null,i=null;return e.forEach((function(e,r,n){var o=e.getBoundingInfo().boundingBox;t?(t.MinimizeInPlace(o.minimumWorld),i.MaximizeInPlace(o.maximumWorld)):(t=o.minimumWorld,i=o.maximumWorld)})),{min:t,max:i}},r.Center=function(t){var i=t instanceof Array?e.Mesh.MinMax(t):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;s65536))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;sa&&(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.updateSideOrientation=function(t,i){return t==e.Mesh.DOUBLESIDE?e.Mesh.DOUBLESIDE:void 0===t||null===t?e.Mesh.FRONTSIDE:t},t.CreateBox=function(t,i,r){var n=new e.Mesh(t,r);i.sideOrientation=this.updateSideOrientation(i.sideOrientation,r),n.sideOrientation=i.sideOrientation;var 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);i.sideOrientation=this.updateSideOrientation(i.sideOrientation,r),n.sideOrientation=i.sideOrientation;var 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);i.sideOrientation=this.updateSideOrientation(i.sideOrientation,r),n.sideOrientation=i.sideOrientation;var 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);i.sideOrientation=this.updateSideOrientation(i.sideOrientation,r),n.sideOrientation=i.sideOrientation;var 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,this.updateSideOrientation(i.sideOrientation,r)),h=i.instance,c=i.updatable;if(h){e.Vector3.FromFloatsToRef(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,e.Tmp.Vector3[0]),e.Vector3.FromFloatsToRef(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE,e.Tmp.Vector3[1]);var l=function(t){for(var i=n[0].length,r=0,o=h.sideOrientation===e.Mesh.DOUBLESIDE?2:1,s=1;s<=o;s++)for(var a=0;ae.Tmp.Vector3[1].x&&(e.Tmp.Vector3[1].x=c[u].x),c[u].ye.Tmp.Vector3[1].y&&(e.Tmp.Vector3[1].y=c[u].y),c[u].ze.Tmp.Vector3[1].z&&(e.Tmp.Vector3[1].z=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._boundingInfo=new e.BoundingInfo(e.Tmp.Vector3[0],e.Tmp.Vector3[1]),h._boundingInfo.update(h._worldMatrix),h.updateVerticesData(e.VertexBuffer.PositionKind,u,!1,!1),!h.areNormalsFrozen){var d=h.getIndices(),f=h.getVerticesData(e.VertexBuffer.NormalKind);if(e.VertexData.ComputeNormals(u,d,f),h._closePath)for(var p=0,_=0,m=0;m1?1:r.arc:1,a=void 0===r.closed||r.closed,h=r.shape,c=r.radius||1,l=r.tessellation||64,u=r.updatable,d=this.updateSideOrientation(r.sideOrientation,n),f=r.cap||e.Mesh.NO_CAP,p=2*Math.PI,_=new Array,m=r.invertUV||!1,g=0,v=0,y=p/l*s,x=new Array;for(g=0;g<=l;g++){var x=[];for(f!=e.Mesh.CAP_START&&f!=e.Mesh.CAP_ALL||(x.push(new e.Vector3(0,h[0].y,0)),x.push(new e.Vector3(Math.cos(g*y)*h[0].x*c,h[0].y,Math.sin(g*y)*h[0].x*c))),v=0;v1?1:r.arc||1;var p,_,m=function(t,i,r,n,o,s,a,h){for(var c,l,u,d,f=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,A=0;A3?0:c,_=m(o,p,v,s,a,h,c,r.arc);var y=t.CreateRibbon(i,{pathArray:_,closePath:!0,closeArray:!1,updatable:u,sideOrientation:d,invertUV:l},n);return y.pathArray=_,y.path3D=p,y.tessellation=a,y.cap=c,y.arc=r.arc,y},t.CreatePolyhedron=function(t,i,r){var n=new e.Mesh(t,r);i.sideOrientation=this.updateSideOrientation(i.sideOrientation,r),n.sideOrientation=i.sideOrientation;var 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),d=i.getScene().activeCamera,f=e.Vector3.TransformCoordinates(u,d.getWorldMatrix());h=d.globalPosition.subtract(f)}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 A=0,E=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;s0,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],d=t[s+2],f=n(t[s],u),p=n(t[s],d)),h){u=t[s],d=t[s+2],f=n(t[s+1],u),p=n(t[s+1],d),o.push(f),o.push(d.clone()),o.push(u.clone()),o.push(d.clone()),o.push(f.clone()),o.push(p);break}l&&(u=t[s],d=t[s+1],f=n(t[s+2],u),p=n(t[s+2],d)),o.push(u.clone()),o.push(d.clone()),o.push(f),o.push(p),o.push(f.clone()),o.push(d.clone());break;case 2:a||(u=t[s].clone(),d=n(u,t[s+1]),f=n(u,t[s+2]),o.push(u),o.push(d),o.push(f)),h||(u=t[s+1].clone(),d=n(u,t[s+2]),f=n(u,t[s]),o.push(u),o.push(d),o.push(f)),l||(u=t[s+2].clone(),d=n(u,t[s]),f=n(u,t[s+1]),o.push(u),o.push(d),o.push(f));break;case 3:}}return o},P=0;P3?0:u,y=x(r,n,v,b,o,s,a,h,u,d);var A=t.CreateRibbon(i,{pathArray:y,closeArray:c,closePath:l,updatable:p,sideOrientation:_,invertUV:g},f);return A.pathArray=y,A.path3D=v,A.cap=u,A},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),this._uid=null}return Object.defineProperty(t.prototype,"uid",{get:function(){return this._uid||(this._uid=e.Tools.RandomId()),this._uid},enumerable:!0,configurable:!0}),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||!!this._texture&&this._texture.isReady},t.prototype.getSize=function(){return this._texture._width?new e.Size(this._texture._width,this._texture._height):this._texture._size?new e.Size(this._texture._size,this._texture._size):e.Size.Zero()},t.prototype.getBaseSize=function(){return this.isReady()&&this._texture?this._texture._size?new e.Size(this._texture._size,this._texture._size):new e.Size(this._texture._baseWidth,this._texture._baseHeight):e.Size.Zero()},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=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},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),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===o&&(o=!1),void 0===s&&(s=!0),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);var d=t.call(this,n)||this;if(d.uOffset=0,d.vOffset=0,d.uScale=1,d.vScale=1,d.uAng=0,d.vAng=0,d.wAng=0,d.name=r,d.url=r,d._noMipmap=o,d._invertY=s,d._samplingMode=a,d._buffer=l,d._deleteBuffer=u,!r)return d;d._texture=d._getFromCache(r,o,a);var f=function(){d._onLoadObservarble&&d._onLoadObservarble.hasObservers()&&d.onLoadObservable.notifyObservers(!0),h&&h()};return d._texture?d._texture.isReady?e.Tools.SetImmediate((function(){return f()})):d._texture.onLoadedCallbacks.push(f):n.useDelayedTextureLoading?(d.delayLoadState=e.Engine.DELAYLOADSTATE_NOTLOADED,d._delayedOnLoad=f,d._delayedOnError=c):(d._texture=n.getEngine().createTexture(r,o,s,n,d._samplingMode,f,c,d._buffer),u&&delete d._buffer),d}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)},Object.defineProperty(i.prototype,"onLoadObservable",{get:function(){return this._onLoadObservarble||(this._onLoadObservarble=new e.Observable),this._onLoadObservarble},enumerable:!0,configurable:!0}),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.customType){var o=e.Tools.Instantiate(t.customType);return o.Parse(t,r,n)}if(t.isCube)return e.CubeTexture.Parse(t,r,n); -if(!t.name&&!t.isRenderTarget)return null;var s=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 a=0;a=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,s,a,h){void 0===s&&(s=e.Engine.TEXTURETYPE_UNSIGNED_INT),void 0===a&&(a=e.Texture.BILINEAR_SAMPLINGMODE),void 0===h&&(h=!0);var c=t.call(this,i,r,n,o,!0,s,!1,a,h)||this;return c.mirrorPlane=new e.Plane(0,1,0,1),c._transformMatrix=e.Matrix.Zero(),c._mirrorMatrix=e.Matrix.Zero(),c.onBeforeRenderObservable.add((function(){e.Matrix.ReflectionToRef(c.mirrorPlane,c._mirrorMatrix),c._savedViewMatrix=n.getViewMatrix(),c._mirrorMatrix.multiplyToRef(c._savedViewMatrix,c._transformMatrix),n.setTransformMatrix(c._transformMatrix,n.getProjectionMatrix()),n.clipPlane=c.mirrorPlane,n.getEngine().cullBackFaces=!1,n._mirroredCameraPosition=e.Vector3.TransformCoordinates(n.activeCamera.position,c._mirrorMatrix)})),c.onAfterRenderObservable.add((function(){n.setTransformMatrix(c._savedViewMatrix,n.getProjectionMatrix()),n.getEngine().cullBackFaces=!0,n._mirroredCameraPosition=null,delete n.clipPlane})),c}return __extends(i,t),i.prototype.clone=function(){var e=this.getSize(),t=new i(this.name,e.width,this.getScene(),this._renderTargetOptions.generateMipMaps,this._renderTargetOptions.type,this._renderTargetOptions.samplingMode,this._renderTargetOptions.generateDepthBuffer);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=t.call(this,i,r,n,o,!0)||this;return s.refractionPlane=new e.Plane(0,1,0,1),s.depth=2,s.onBeforeRenderObservable.add((function(){n.clipPlane=s.refractionPlane})),s.onAfterRenderObservable.add((function(){delete n.clipPlane})),s}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);var a=t.call(this,null,n,!o)||this;a.name=i,a.wrapU=e.Texture.CLAMP_ADDRESSMODE,a.wrapV=e.Texture.CLAMP_ADDRESSMODE,a._generateMipMaps=o,r.getContext?(a._canvas=r,a._texture=n.getEngine().createDynamicTexture(r.width,r.height,o,s)):(a._canvas=document.createElement("canvas"),r.width?a._texture=n.getEngine().createDynamicTexture(r.width,r.height,o,s):a._texture=n.getEngine().createDynamicTexture(r,r,o,s));var h=a.getSize();return a._canvas.width=h.width,a._canvas.height=h.height,a._context=a._canvas.getContext("2d"),a}return __extends(i,t),Object.defineProperty(i.prototype,"canRescale",{get:function(){return!0},enumerable:!0,configurable:!0}),i.prototype.scale=function(e){var t=this.getSize();t.width*=e,t.height*=e,this._canvas.width=t.width,this._canvas.height=t.height,this.releaseInternalTexture(),this._texture=this.getScene().getEngine().createDynamicTexture(t.width,t.height,this._generateMipMaps,this._samplingMode)},i.prototype.getContext=function(){return this._context},i.prototype.clear=function(){var e=this.getSize();this._context.fillRect(0,0,e.width,e.height)},i.prototype.update=function(e){this.getScene().getEngine().updateDynamicTexture(this._texture,this._canvas,void 0===e||e)},i.prototype.drawText=function(e,t,i,r,n,o,s,a){void 0===a&&(a=!0);var h=this.getSize();if(o&&(this._context.fillStyle=o,this._context.fillRect(0,0,h.width,h.height)),this._context.font=r,null===t){var c=this._context.measureText(e);t=(h.width-c.width)/2}this._context.fillStyle=n,this._context.fillText(e,t,i),a&&this.update(s)},i.prototype.clone=function(){var e=this.getSize(),t=new i(this.name,e,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){void 0===o&&(o=!1),void 0===s&&(s=!1),void 0===a&&(a=e.Texture.TRILINEAR_SAMPLINGMODE);var h=t.call(this,null,n,!o,s)||this;h._autoLaunch=!0;var c;return h.name=i,r instanceof HTMLVideoElement?h.video=r:(c=r,h.video=document.createElement("video"),h.video.autoplay=!1,h.video.loop=!0),h._generateMipMaps=o,h._samplingMode=a,e.Tools.IsExponentOfTwo(h.video.videoWidth)&&e.Tools.IsExponentOfTwo(h.video.videoHeight)?(h.wrapU=e.Texture.WRAP_ADDRESSMODE,h.wrapV=e.Texture.WRAP_ADDRESSMODE):(h.wrapU=e.Texture.CLAMP_ADDRESSMODE,h.wrapV=e.Texture.CLAMP_ADDRESSMODE,h._generateMipMaps=!1),c?(h.video.addEventListener("canplaythrough",(function(){h._createTexture()})),c.forEach((function(e){var t=document.createElement("source");t.src=e,h.video.appendChild(t)}))):h._createTexture(),h._lastUpdate=e.Tools.Now,h}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)&&(this._lastUpdate=t,this.getScene().getEngine().updateVideoTexture(this._texture,this.video,this._invertY),!0)},i.CreateFromWebCam=function(t,i,r){var n=document.createElement("video");navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia,window.URL=window.URL||window.webkitURL||window.mozURL||window.msURL,navigator.getUserMedia&&navigator.getUserMedia({video:{width:{min:r&&r.minWidth||256,max:r&&r.maxWidth||640},height:{min:r&&r.minHeight||256,max:r&&r.maxHeight||480}}},(function(r){void 0!==n.mozSrcObject?n.mozSrcObject=r:n.src=window.URL&&window.URL.createObjectURL(r)||r,n.play(),i&&i(new e.VideoTexture("video",n,t,(!0),(!0)))}),(function(t){e.Tools.Error(t.name)}))},i})(e.Texture);e.VideoTexture=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(e,i,r,n,o,s){var a=t.call(this,e,r,null,n,o,s)||this;return a._animate=!0,a._time=0,a._texturePath=i,a.loadJson(i),a.refreshRate=1,a}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;tthis._maxRank&&(this._maxRank=e),this._defines[e]=new Array),this._defines[e].push(t)},e.prototype.addCPUSkinningFallback=function(e,t){this._meshRank=e,this._mesh=t,e>this._maxRank&&(this._maxRank=e)},Object.defineProperty(e.prototype,"isMoreFallbacks",{get:function(){return this._currentRank<=this._maxRank},enumerable:!0,configurable:!0}),e.prototype.reduce=function(e){for(var t=this._defines[this._currentRank],i=0;i-1?e:BABYLON.Engine.ShadersRepository+e,BABYLON.Tools.LoadFile(n+".vertex.fx",t)},Effect.prototype._loadFragmentShader=function(e,t){if(e instanceof HTMLElement){var i=BABYLON.Tools.GetDOMTextContent(e);return void t(i)}if("base64:"===e.substr(0,7)){var r=window.atob(e.substr(7));return void t(r)}if(Effect.ShadersStore[e+"PixelShader"])return void t(Effect.ShadersStore[e+"PixelShader"]);if(Effect.ShadersStore[e+"FragmentShader"])return void t(Effect.ShadersStore[e+"FragmentShader"]);var n;n="."===e[0]||"/"===e[0]||e.indexOf("http")>-1?e:BABYLON.Engine.ShadersRepository+e,BABYLON.Tools.LoadFile(n+".fragment.fx",t)},Effect.prototype._dumpShadersName=function(){this.name.vertexElement?(BABYLON.Tools.Error("Vertex shader:"+this.name.vertexElement),BABYLON.Tools.Error("Fragment shader:"+this.name.fragmentElement)):this.name.vertex?(BABYLON.Tools.Error("Vertex shader:"+this.name.vertex),BABYLON.Tools.Error("Fragment shader:"+this.name.fragment)):(BABYLON.Tools.Error("Vertex shader:"+this.name),BABYLON.Tools.Error("Fragment shader:"+this.name))},Effect.prototype._processIncludes=function(e,t){for(var i=this,r=/#include<(.+)>(\((.*)\))*(\[(.*)\])*/g,n=r.exec(e),o=new String(e);null!=n;){var s=n[1];if(!Effect.IncludesShadersStore[s]){var a=BABYLON.Engine.ShadersRepository+"ShadersInclude/"+s+".fx";return void BABYLON.Tools.LoadFile(a,(function(e){Effect.IncludesShadersStore[s]=e,i._processIncludes(o,t)}))}var h=Effect.IncludesShadersStore[s];if(n[2])for(var c=n[3].split(","),l=0;l0&&(result+=line+"\r\n")}return result},Effect.prototype._evaluateDefinesOnString=function(e){for(var t={children:[]},i=t,r=e.split("\n"),n=0;n0){for(var d=0;d0){for(var p=0;p0&&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=0&&this._scene.materials.splice(i,1),e&&this._effect&&(this._scene.getEngine()._releaseEffect(this._effect),this._effect=null),i=0;i0&&(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;a=!0,this._defines.EMISSIVE=!0}if(this.lightmapTexture&&r.LightmapTextureEnabled){if(!this.lightmapTexture.isReady())return!1;a=!0,this._defines.LIGHTMAP=!0,this._defines.USELIGHTMAPASSHADOWMAP=this.useLightmapAsShadowmap}if(this.specularTexture&&r.SpecularTextureEnabled){if(!this.specularTexture.isReady())return!1;a=!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;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&&r.RefractionTextureEnabled){if(!this.refractionTexture.isReady())return!1;a=!0,this._defines.REFRACTION=!0,this._defines.REFRACTIONMAP_3D=this.refractionTexture.isCube}if(this.cameraColorGradingTexture&&r.ColorGradingTextureEnabled){if(!this.cameraColorGradingTexture.isReady())return!1;this._defines.CAMERACOLORGRADING=!0}}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.cameraColorCurves&&(this._defines.CAMERACOLORCURVES=!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),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),h=!0,this._defines.FRESNEL=!0),this._defines.SPECULARTERM&&this.useSpecularOverAlpha&&(this._defines.SPECULAROVERALPHA=!0),i&&(h&&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),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",d=this._defines.toString(),f=["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"];this._defines.CAMERACOLORCURVES&&e.ColorCurves.PrepareUniforms(f),this._defines.CAMERACOLORGRADING&&e.ColorGradingTexture.PrepareUniformsAndSamplers(f,p),e.MaterialHelper.PrepareUniformsAndSamplersList(f,p,this._defines,this.maxSimultaneousLights),this._effect=o.getEngine().createEffect(u,l,f,p,d,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)},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){if(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)}this.cameraColorGradingTexture&&r.ColorGradingTextureEnabled&&e.ColorGradingTexture.Bind(this.cameraColorGradingTexture,this._effect)}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),this.cameraColorCurves&&e.ColorCurves.Bind(this.cameraColorCurves,this._effect)),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),this.cameraColorGradingTexture&&this.cameraColorGradingTexture.animations&&this.cameraColorGradingTexture.animations.length>0&&e.push(this.cameraColorGradingTexture),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(),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(){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})(e.Material);i.DiffuseTextureEnabled=!0,i.AmbientTextureEnabled=!0,i.OpacityTextureEnabled=!0,i.ReflectionTextureEnabled=!0,i.EmissiveTextureEnabled=!0,i.SpecularTextureEnabled=!0,i.BumpTextureEnabled=!0,i.FresnelEnabled=!0,i.LightmapTextureEnabled=!0,i.RefractionTextureEnabled=!0,i.ColorGradingTextureEnabled=!0,__decorate([e.serializeAsTexture()],i.prototype,"diffuseTexture",void 0),__decorate([e.serializeAsTexture()],i.prototype,"ambientTexture",void 0),__decorate([e.serializeAsTexture()],i.prototype,"opacityTexture",void 0),__decorate([e.serializeAsTexture()],i.prototype,"reflectionTexture",void 0),__decorate([e.serializeAsTexture()],i.prototype,"emissiveTexture",void 0),__decorate([e.serializeAsTexture()],i.prototype,"specularTexture",void 0),__decorate([e.serializeAsTexture()],i.prototype,"bumpTexture",void 0),__decorate([e.serializeAsTexture()],i.prototype,"lightmapTexture",void 0),__decorate([e.serializeAsTexture()],i.prototype,"refractionTexture",void 0),__decorate([e.serializeAsColor3("ambient")],i.prototype,"ambientColor",void 0),__decorate([e.serializeAsColor3("diffuse")],i.prototype,"diffuseColor",void 0),__decorate([e.serializeAsColor3("specular")],i.prototype,"specularColor",void 0),__decorate([e.serializeAsColor3("emissive")],i.prototype,"emissiveColor",void 0),__decorate([e.serialize()],i.prototype,"specularPower",void 0),__decorate([e.serialize()],i.prototype,"useAlphaFromDiffuseTexture",void 0),__decorate([e.serialize()],i.prototype,"useEmissiveAsIllumination",void 0),__decorate([e.serialize()],i.prototype,"linkEmissiveWithDiffuse",void 0),__decorate([e.serialize()],i.prototype,"useReflectionFresnelFromSpecular",void 0),__decorate([e.serialize()],i.prototype,"useSpecularOverAlpha",void 0),__decorate([e.serialize()],i.prototype,"useReflectionOverAlpha",void 0),__decorate([e.serialize()],i.prototype,"disableLighting",void 0),__decorate([e.serialize()],i.prototype,"useParallax",void 0),__decorate([e.serialize()],i.prototype,"useParallaxOcclusion",void 0),__decorate([e.serialize()],i.prototype,"parallaxScaleBias",void 0),__decorate([e.serialize()],i.prototype,"roughness",void 0),__decorate([e.serialize()],i.prototype,"indexOfRefraction",void 0),__decorate([e.serialize()],i.prototype,"invertRefractionY",void 0),__decorate([e.serialize()],i.prototype,"useLightmapAsShadowmap",void 0),__decorate([e.serializeAsFresnelParameters()],i.prototype,"diffuseFresnelParameters",void 0),__decorate([e.serializeAsFresnelParameters()],i.prototype,"opacityFresnelParameters",void 0),__decorate([e.serializeAsFresnelParameters()],i.prototype,"reflectionFresnelParameters",void 0),__decorate([e.serializeAsFresnelParameters()],i.prototype,"refractionFresnelParameters",void 0),__decorate([e.serializeAsFresnelParameters()],i.prototype,"emissiveFresnelParameters",void 0),__decorate([e.serialize()],i.prototype,"useGlossinessFromSpecularMapAlpha",void 0),__decorate([e.serialize()],i.prototype,"maxSimultaneousLights",void 0),__decorate([e.serialize()],i.prototype,"invertNormalMapX",void 0),__decorate([e.serialize()],i.prototype,"invertNormalMapY",void 0),__decorate([e.serializeAsTexture()],i.prototype,"cameraColorGradingTexture",void 0),__decorate([e.serializeAsColorCurves()],i.prototype,"cameraColorCurves",void 0),__decorate([e.serialize()],i.prototype,"useLogarithmicDepth",null),e.StandardMaterial=i})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(e,i){var r=t.call(this,e,i,!0)||this;return r.subMaterials=new Array,i.multiMaterials.push(r),r}return __extends(i,t),i.prototype.getSubMaterial=function(e){return e<0||e>=this.subMaterials.length?this.getScene().defaultMaterial:this.subMaterials[e]},i.prototype.getClassName=function(){return"MultiMaterial"},i.prototype.isReady=function(e){for(var t=0;t-1&&o.skeletons){var O=m.indexOf(y.skeletonId)>-1;if(!O)for(var I=0,D=d.skeletons.length;I>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(),d=0;dp&&(c=p,o=f,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.cellWidth,s=0,a=0;athis._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._onAnimationEnd&&this._onAnimationEnd(),this.disposeWhenFinishedAnimating&&this.dispose()))))},t.prototype.dispose=function(){for(var e=0;e=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;o-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;r1)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),d=[{frame:0,value:s},{frame:o,value:a}];return u.setKeys(d),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=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;t0)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=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: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;sthis._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)}(rthis._keys[this._keys.length-1].frame)&&(r=this._keys[0].frame),(nthis._keys[this._keys.length-1].frame)&&(n=this._keys[this._keys.length-1].frame),r===n&&r++;var l,u=n-r,d=t*(this.framePerSecond*s)/1e3,f=0;if(d>u&&!o)h=!1,f=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}f=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=d/u>>0,v=h?r+d%u:n,y=this._interpolate(v,g,this.loopMode,l,f);this.setValue(y);for(var x=0;x=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-1){for(var i=this._animations,r=0,t=i.length-1;t>=0;t--)"string"==typeof e&&i[t].name!=e||(i[t].reset(),i.splice(t,1),r++);i.length==r&&(this._scene._activeAnimatables.splice(t,1),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=.5?.5*(1-this.easeInCore(2*(1-t)))+.5:.5*this.easeInCore(2*t)},e})();t._EASINGMODE_EASEIN=0,t._EASINGMODE_EASEOUT=1,t._EASINGMODE_EASEINOUT=2,e.EasingFunction=t;var i=(function(e){function t(){return e.apply(this,arguments)||this}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);var i=e.call(this)||this;return i.amplitude=t,i}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);var r=e.call(this)||this;return r.bounces=t,r.bounciness=i,r}return __extends(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.bounces),i=this.bounciness;i<=1&&(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),d=.5*(l+u),f=e-d,p=d-l;return-Math.pow(1/i,t-h)/(p*p)*(f-p)*(f+p)},t})(t);e.BounceEase=n;var o=(function(e){function t(){return e.apply(this,arguments)||this}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);var r=e.call(this)||this;return r.oscillations=t,r.springiness=i,r}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);var i=e.call(this)||this;return i.exponent=t,i}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);var i=e.call(this)||this;return i.power=t,i}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(){return e.apply(this,arguments)||this}return __extends(t,e),t.prototype.easeInCore=function(e){return e*e},t})(t);e.QuadraticEase=c;var l=(function(e){function t(){return e.apply(this,arguments)||this}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(){return e.apply(this,arguments)||this}return __extends(t,e),t.prototype.easeInCore=function(e){return e*e*e*e*e},t})(t);e.QuinticEase=u;var d=(function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t.prototype.easeInCore=function(e){return 1-Math.sin(1.5707963267948966*(1-e))},t})(t);e.SineEase=d;var f=(function(t){function i(e,i,r,n){void 0===e&&(e=0),void 0===i&&(i=0),void 0===r&&(r=1),void 0===n&&(n=1);var o=t.call(this)||this;return o.x1=e,o.y1=i,o.x2=r,o.y2=n,o}return __extends(i,t),i.prototype.easeInCore=function(t){return e.BezierCurve.interpolate(t,this.x1,this.y1,this.x2,this.y2)},i})(t);e.BezierCurveEase=f})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,o,s){var a=t.call(this,i,r.getScene())||this;return a.name=i,a.children=new Array,a.animations=new Array,a._worldTransform=new e.Matrix,a._absoluteTransform=new e.Matrix,a._invertedAbsoluteTransform=new e.Matrix,a._scaleMatrix=e.Matrix.Identity(),a._scaleVector=new e.Vector3(1,1,1),a._negateScaleChildren=new e.Vector3(1,1,1),a._scalingDeterminant=1,a._syncScaleVector=function(){var t=this.getLocalMatrix(),i=t.m[0]*t.m[0]+t.m[1]*t.m[1]+t.m[2]*t.m[2],r=t.m[4]*t.m[4]+t.m[5]*t.m[5]+t.m[6]*t.m[6],n=t.m[8]*t.m[8]+t.m[9]*t.m[9]+t.m[10]*t.m[10],o=t.m[0]*t.m[1]*t.m[2]*t.m[3]<0?-1:1,s=t.m[4]*t.m[5]*t.m[6]*t.m[7]<0?-1:1,a=t.m[8]*t.m[9]*t.m[10]*t.m[11]<0?-1:1;this._scaleVector.x=o*Math.sqrt(i),this._scaleVector.y=s*Math.sqrt(r),this._scaleVector.z=a*Math.sqrt(n),this._parent&&(this._scaleVector.x/=this._parent._negateScaleChildren.x,this._scaleVector.y/=this._parent._negateScaleChildren.y,this._scaleVector.z/=this._parent._negateScaleChildren.z),e.Matrix.FromValuesToRef(this._scaleVector.x,0,0,0,0,this._scaleVector.y,0,0,0,0,this._scaleVector.z,0,0,0,0,1,this._scaleMatrix)},a._skeleton=r,a._matrix=o,a._baseMatrix=o,a._restPose=s?s:o.clone(),r.bones.push(a),n?(a._parent=n,n.children.push(a)):a._parent=null,a._updateDifferenceMatrix(),a.getAbsoluteTransform().determinant()<0&&(a._scalingDeterminant*=-1),a}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,t){void 0===t&&(t=!0),this._baseMatrix=e.clone(),this._matrix=e.clone(),this._skeleton._markAsDirty(),t&&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=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.prototype.translate=function(t,i,r){void 0===i&&(i=e.Space.LOCAL);var n=this.getLocalMatrix();if(i==e.Space.LOCAL)n.m[12]+=t.x,n.m[13]+=t.y,n.m[14]+=t.z;else{this._skeleton.computeAbsoluteTransforms();var o=e.Tmp.Matrix[0],s=e.Tmp.Vector3[0];r?(o.copyFrom(this._parent.getAbsoluteTransform()),o.multiplyToRef(r.getWorldMatrix(),o)):o.copyFrom(this._parent.getAbsoluteTransform()),o.m[12]=0,o.m[13]=0,o.m[14]=0,o.invert(),e.Vector3.TransformCoordinatesToRef(t,o,s),n.m[12]+=s.x,n.m[13]+=s.y,n.m[14]+=s.z}this.markAsDirty()},i.prototype.setPosition=function(t,i,r){void 0===i&&(i=e.Space.LOCAL);var n=this.getLocalMatrix();if(i==e.Space.LOCAL)n.m[12]=t.x,n.m[13]=t.y,n.m[14]=t.z;else{this._skeleton.computeAbsoluteTransforms();var o=e.Tmp.Matrix[0],s=e.Tmp.Vector3[0];r?(o.copyFrom(this._parent.getAbsoluteTransform()),o.multiplyToRef(r.getWorldMatrix(),o)):o.copyFrom(this._parent.getAbsoluteTransform()),o.invert(),e.Vector3.TransformCoordinatesToRef(t,o,s),n.m[12]=s.x,n.m[13]=s.y,n.m[14]=s.z}this.markAsDirty()},i.prototype.setAbsolutePosition=function(t,i){this.setPosition(t,e.Space.WORLD,i)},i.prototype.setScale=function(e,t,i,r){void 0===r&&(r=!1),this.animations[0]&&!this.animations[0].isStopped()&&(r||(this._negateScaleChildren.x=1/e,this._negateScaleChildren.y=1/t,this._negateScaleChildren.z=1/i),this._syncScaleVector()),this.scale(e/this._scaleVector.x,t/this._scaleVector.y,i/this._scaleVector.z,r)},i.prototype.scale=function(t,i,r,n){void 0===n&&(n=!1);var o=this.getLocalMatrix(),s=e.Tmp.Matrix[0];s.copyFrom(o);var a=e.Tmp.Matrix[1];a.copyFrom(s),a.invert();var h=e.Tmp.Matrix[2];e.Matrix.FromValuesToRef(t,0,0,0,0,i,0,0,0,0,r,0,0,0,0,1,h),this._scaleMatrix.multiplyToRef(h,this._scaleMatrix),this._scaleVector.x*=t,this._scaleVector.y*=i,this._scaleVector.z*=r,o.multiplyToRef(a,o),o.multiplyToRef(h,o),o.multiplyToRef(s,o);var c=this.getParent();c?o.multiplyToRef(c.getAbsoluteTransform(),this.getAbsoluteTransform()):this.getAbsoluteTransform().copyFrom(o);var l=this.children.length;h.invert();for(var u=0;u0&&(this._rightHandedSystem=!0,this._bendAxis.x=0,this._bendAxis.y=0,this._bendAxis.z=1),this._bone1.length){var n=this._bone1.getScale(),o=this._bone2.getScale();this._bone1Length=this._bone1.length*n.y*this.mesh.scaling.y,this._bone2Length=this._bone2.length*o.y*this.mesh.scaling.y}else if(this._bone1.children[0]){t.computeWorldMatrix(!0);var s=this._bone2.children[0].getAbsolutePosition(t),a=this._bone2.getAbsolutePosition(t),h=this._bone1.getAbsolutePosition(t);this._bone1Length=e.Vector3.Distance(s,a),this._bone2Length=e.Vector3.Distance(a,h)}this._bone1.getRotationMatrixToRef(e.Space.WORLD,t,this._bone1Mat),this.maxAngle=Math.PI,r&&(r.targetMesh&&(this.targetMesh=r.targetMesh,this.targetMesh.computeWorldMatrix(!0)),r.poleTargetMesh?(this.poleTargetMesh=r.poleTargetMesh,this.poleTargetMesh.computeWorldMatrix(!0)):r.poleTargetBone?this.poleTargetBone=r.poleTargetBone:this._bone1.getParent()&&(this.poleTargetBone=this._bone1.getParent()),r.poleTargetLocalOffset&&this.poleTargetLocalOffset.copyFrom(r.poleTargetLocalOffset),r.poleAngle&&(this.poleAngle=r.poleAngle),r.bendAxis&&this._bendAxis.copyFrom(r.bendAxis),r.maxAngle&&(this.maxAngle=r.maxAngle),r.slerpAmount&&(this.slerpAmount=r.slerpAmount))}return Object.defineProperty(t.prototype,"maxAngle",{get:function(){return this._maxAngle},set:function(e){this._setMaxAngle(e)},enumerable:!0,configurable:!0}),t.prototype._setMaxAngle=function(e){e<0&&(e=0),(e>Math.PI||void 0==e)&&(e=Math.PI),this._maxAngle=e;var t=this._bone1Length,i=this._bone2Length;this._maxReach=Math.sqrt(t*t+i*i-2*t*i*Math.cos(e))},t.prototype.update=function(){var t=this._bone1,i=this.targetPosition,r=this.poleTargetPosition,n=this._tmpMat1,o=this._tmpMat2;this.targetMesh&&i.copyFrom(this.targetMesh.getAbsolutePosition()),this.poleTargetBone?this.poleTargetBone.getAbsolutePositionFromLocalToRef(this.poleTargetLocalOffset,this.mesh,r):this.poleTargetMesh&&e.Vector3.TransformCoordinatesToRef(this.poleTargetLocalOffset,this.poleTargetMesh.getWorldMatrix(),r);var s=this._tmpVec1,a=this._tmpVec2,h=this._tmpVec3,c=this._tmpVec4,l=this._tmpVec5;t.getAbsolutePositionToRef(this.mesh,s),r.subtractToRef(s,l),0==l.x&&0==l.y&&0==l.z?l.y=1:l.normalize(),i.subtractToRef(s,c),c.normalize(),e.Vector3.CrossToRef(c,l,a),a.normalize(),e.Vector3.CrossToRef(c,a,h),h.normalize(),e.Matrix.FromXYZAxesToRef(h,c,a,n);var u=this._bone1Length,d=this._bone2Length,f=e.Vector3.Distance(s,i);this._maxReach>0&&(f=Math.min(this._maxReach,f));var p=(d*d+f*f-u*u)/(2*d*f),_=(f*f+u*u-d*d)/(2*f*u);p>1&&(p=1),_>1&&(_=1),p<-1&&(p=-1),_<-1&&(_=-1);var m=Math.acos(p),g=Math.acos(_),v=-m-g;this._rightHandedSystem?(e.Matrix.RotationYawPitchRollToRef(0,0,.5*Math.PI,o),o.multiplyToRef(n,n),e.Matrix.RotationAxisToRef(this._bendAxis,g,o),o.multiplyToRef(n,n)):(this._tmpVec1.copyFrom(this._bendAxis),this._tmpVec1.x*=-1,e.Matrix.RotationAxisToRef(this._tmpVec1,-g,o),o.multiplyToRef(n,n)),this.poleAngle&&(e.Matrix.RotationAxisToRef(c,this.poleAngle,o),n.multiplyToRef(o,n)),this.slerpAmount<1?(this._slerping||e.Quaternion.FromRotationMatrixToRef(this._bone1Mat,this._bone1Quat),e.Quaternion.FromRotationMatrixToRef(n,this._tmpQuat1),e.Quaternion.SlerpToRef(this._bone1Quat,this._tmpQuat1,this.slerpAmount,this._bone1Quat),v=this._bone2Ang*(1-this.slerpAmount)+v*this.slerpAmount,this._bone1.setRotationQuaternion(this._bone1Quat,e.Space.WORLD,this.mesh),this._slerping=!0):(this._bone1.setRotationMatrix(n,e.Space.WORLD,this.mesh),this._bone1Mat.copyFrom(n),this._slerping=!1),this._bone2.setAxisAngle(this._bendAxis,v,e.Space.LOCAL),this._bone2Ang=v},t})();e.BoneIKController=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(t,i,r,n){this.upAxis=e.Vector3.Up(),this.adjustYaw=0,this.adjustPitch=0,this.adjustRoll=0,this._tmpVec1=e.Vector3.Zero(),this._tmpVec2=e.Vector3.Zero(),this._tmpVec3=e.Vector3.Zero(),this._tmpVec4=e.Vector3.Zero(),this._tmpMat1=e.Matrix.Identity(),this._tmpMat2=e.Matrix.Identity(),this.mesh=t,this.bone=i,this.target=r,n&&(n.adjustYaw&&(this.adjustYaw=n.adjustYaw),n.adjustPitch&&(this.adjustPitch=n.adjustPitch),n.adjustRoll&&(this.adjustRoll=n.adjustRoll))}return t.prototype.update=function(){var t=this.bone,i=this.target,r=this._tmpVec1,n=this._tmpVec2,o=this._tmpVec3,s=this._tmpVec4,a=this._tmpMat1,h=this._tmpMat2;t.getAbsolutePositionToRef(this.mesh,r),i.subtractToRef(r,n),n.normalize(),e.Vector3.CrossToRef(this.upAxis,n,o),o.normalize(),e.Vector3.CrossToRef(n,o,s),s.normalize(),e.Matrix.FromXYZAxesToRef(o,s,n,a),(this.adjustYaw||this.adjustPitch||this.adjustRoll)&&(e.Matrix.RotationYawPitchRollToRef(this.adjustYaw,this.adjustPitch,this.adjustRoll,h),h.multiplyToRef(a,a)),this.bone.setRotationMatrix(a,e.Space.WORLD,this.mesh)},t})();e.BoneLookController=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._lastAbsoluteTransformsUpdateId=-1,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||this.prepare(),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;t-1&&this._meshesWithPoseMatrix.splice(t,1)},t.prototype._computeTransformMatrices=function(e,t){for(var i=0;i0&&(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-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;o0&&(e=this._meshesWithPoseMatrix[0].getPoseMatrix()),e},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;c0){for(var t=0;t0&&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)},t.prototype.directRender=function(e,t){for(var i=this._scene.getEngine(),r=0;r-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})();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,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:e<=0&&(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;ta?a:Math.floor(h);var c,l,u,d,f=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,p=[],_=[],m=[],g=[],v=[],y=[],x=[],b=[],A=[],E=[];if(r.length<2){var T=[],P=[];for(u=0;u0&&(O=M[d].subtract(M[d-1]).length(),I=O+x[l],v[l].push(I),x[l]=I),d++;o&&(d--,p.push(M[0].x,M[0].y,M[0].z),O=M[d].subtract(M[0]).length(),I=O+x[l],v[l].push(I),x[l]=I),A[l]=S+R,E[l]=C,C+=S+R}var D,L,w,B;for(u=0;u1?1:i.arc||1,h=i.slice<=0?1:i.slice||1,c=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,l=new e.Vector3(n/2,o/2,s/2),u=2+r,d=2*u,f=[],p=[],_=[],m=[],g=0;g<=u;g++){for(var v=g/u,y=v*Math.PI*h,x=0;x<=d;x++){var b=x/d,A=b*Math.PI*2*a,E=e.Matrix.RotationZ(-y),T=e.Matrix.RotationY(A),P=e.Vector3.TransformCoordinates(e.Vector3.Up(),E),M=e.Vector3.TransformCoordinates(P,T),S=M.multiply(l),C=M.divide(l).normalize();p.push(S.x,S.y,S.z),_.push(C.x,C.y,C.z),m.push(b,v)}if(g>0)for(var R=p.length/3,O=R-2*(d+1);O+d+21?1:i.arc||1,d=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,f=i.faceUV||new Array(3),p=i.faceColors,_=1!==u&&l?2:0,m=c?h:1,g=2+(1+_)*m;for(r=0;r0&&(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,d=0,f=0,p=0,_=0,m=0;for(m=0;m1?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,d=u/h,f=0;f=r.length?0:i.type||0,u=i.size,d=i.sizeX||u||1,f=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||i.flat,x=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,b=[],A=[],E=[],T=[],P=[],M=0,S=0,C=[],R=0,O=0;if(y)for(O=0;O1)for(var h=0;hthis.value;case i.IsLesser:return this._effectiveTarget[this._property]-1&&this._scene._actionManagers.splice(e,1)},t.prototype.getScene=function(){return this._scene},t.prototype.hasSpecificTriggers=function(e){for(var t=0;t-1)return!0}return!1},t.prototype.hasSpecificTrigger=function(e){for(var t=0;t=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=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;r0;if(2===i.type?d.push(o):d.push(r),_){for(var m=new Array,g=0;g0){var d=u.properties[0].value,f=null===u.properties[0].targetType?d:n.getMeshByName(d);f._meshId&&(f.mesh=n.getMeshByID(f._meshId)),l={trigger:e.ActionManager[u.name],parameter:f}}else l=e.ActionManager[u.name];for(var p=0;p0&&(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){if(this.delayLoadState!==e.Engine.DELAYLOADSTATE_LOADING){if(this.isReady())return void(i&&i());this.delayLoadState=e.Engine.DELAYLOADSTATE_LOADING,this._queueLoad(t,i)}},t.prototype._queueLoad=function(t,i){var r=this;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;a0){for(var i=0;i0){for(var i=0;i0){for(var i=0;i0){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 d=new Float32Array(t,s.uvs4AttrDesc.offset,s.uvs4AttrDesc.count);i.setVerticesData(e.VertexBuffer.UV4Kind,d,!1)}if(s.uvs5AttrDesc&&s.uvs5AttrDesc.count>0){var f=new Float32Array(t,s.uvs5AttrDesc.offset,s.uvs5AttrDesc.count);i.setVerticesData(e.VertexBuffer.UV5Kind,f,!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>8),M.push((16711680&S)>>16),M.push(S>>24)}i.setVerticesData(e.VertexBuffer.MatricesIndicesKind,M,!1)}if(t.matricesIndicesExtra)if(t.matricesIndicesExtra._isExpanded)delete t.matricesIndices._isExpanded,i.setVerticesData(e.VertexBuffer.MatricesIndicesExtraKind,t.matricesIndicesExtra,!1);else{for(var M=[],x=0;x>8),M.push((16711680&S)>>16),M.push(S>>24)}i.setVerticesData(e.VertexBuffer.MatricesIndicesExtraKind,M,!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 C=0;Cthis._maxX||tthis._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,!(ethis._maxX||tthis._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=(this._subdivisionsX,this._subdivisionsY,Math.floor((e+this._maxX)*this._subdivisionsX/this._width)),n=Math.floor(-(t+this._maxZ)*this._subdivisionsY/this._height+this._subdivisionsY),o=this._heightQuads[n*this._subdivisionsX+r];return i=t0&&(c=!0,this._soundLoaded(i));break;case"String":h.push(i);case"Array":0===h.length&&(h=i);for(var l=0;l0&&(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.prototype.serialize=function(){var e={name:this.name,url:this.name,autoplay:this.autoplay,loop:this.loop,volume:this._volume,spatialSound:this.spatialSound,maxDistance:this.maxDistance,rolloffFactor:this.rolloffFactor,refDistance:this.refDistance,distanceModel:this.distanceModel,playbackRate:this._playbackRate,panningModel:this._panningModel,soundTrackId:this.soundTrackId};return this.spatialSound&&(this._connectedMesh&&(e.connectedMeshId=this._connectedMesh.id),e.position=this._position.asArray(),e.refDistance=this.refDistance,e.distanceModel=this.distanceModel,e.isDirectional=this._isDirectional,e.localDirectionToMesh=this._localDirection.asArray(),e.coneInnerAngle=this._coneInnerAngle,e.coneOuterAngle=this._coneOuterAngle,e.coneOuterGain=this._coneOuterGain),e},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 d=e.Vector3.FromArray(i.localDirectionToMesh);h.setLocalDirectionToMesh(d)}if(i.connectedMeshId){var f=r.getMeshByID(i.connectedMeshId);f&&h.attachToMesh(f)}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&&(t.soundTrackId===-1?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);t!==-1&&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;t4&&(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 u=n.join("\n");return this._cachedDefines!==u&&(this._cachedDefines=u,this._glowMapGenerationEffect=this._scene.getEngine().createEffect("glowMapGeneration",o,["world","mBones","viewProjection","diffuseMatrix","color","emissiveMatrix"],["diffuseSampler","emissiveSampler"],u)),this._glowMapGenerationEffect.isReady()},i.prototype.render=function(){var t=this._glowMapMergeEffect;if(t.isReady()&&this._blurTexture.isReady()){var i=this._scene.getEngine();this.onBeforeComposeObservable.notifyObservers(this),i.enableEffect(t),i.setState(!1);var r=i.getStencilBuffer(),n=i.getStencilFunction(),o=i.getStencilMask(),s=i.getAlphaMode();t.setTexture("textureSampler",this._blurTexture),i.bindBuffers(this._vertexBuffers,this._indexBuffer,t),i.setAlphaMode(this._options.alphaBlendingMode),i.setStencilMask(0),i.setStencilBuffer(!0),i.setStencilFunctionReference(this._instanceGlowingMeshStencilReference),this.outerGlow&&(t.setFloat("offset",0),i.setStencilFunction(e.Engine.NOTEQUAL),i.draw(!0,0,6)),this.innerGlow&&(t.setFloat("offset",1),i.setStencilFunction(e.Engine.EQUAL),i.draw(!0,0,6)),i.setStencilFunction(n),i.setStencilMask(o),i.setAlphaMode(s),i.setStencilBuffer(r),this.onAfterComposeObservable.notifyObservers(this);var a=this._mainTexture.getSize();this.setMainTextureSize(),a.width===this._mainTextureDesiredSize.width&&a.height===this._mainTextureDesiredSize.height||(this.onSizeChangedObservable.notifyObservers(this),this.disposeTextureAndPostProcesses(),this.createTextureAndPostProcesses())}},i.prototype.addExcludedMesh=function(e){var t=this._excludedMeshes[e.uniqueId];t||(this._excludedMeshes[e.uniqueId]={mesh:e,beforeRender:e.onBeforeRenderObservable.add((function(e){e.getEngine().setStencilBuffer(!1)})),afterRender:e.onAfterRenderObservable.add((function(e){e.getEngine().setStencilBuffer(!0)}))})},i.prototype.removeExcludedMesh=function(e){var t=this._excludedMeshes[e.uniqueId];t&&(e.onBeforeRenderObservable.remove(t.beforeRender),e.onAfterRenderObservable.remove(t.afterRender)),this._excludedMeshes[e.uniqueId]=void 0},i.prototype.addMesh=function(e,t,i){var r=this;void 0===i&&(i=!1);var n=this._meshes[e.uniqueId];n?n.color=t:this._meshes[e.uniqueId]={mesh:e,color:t,observerHighlight:e.onBeforeRenderObservable.add((function(e){r._excludedMeshes[e.uniqueId]?r.defaultStencilReference(e):e.getScene().getEngine().setStencilFunctionReference(r._instanceGlowingMeshStencilReference)})),observerDefault:e.onAfterRenderObservable.add(this.defaultStencilReference),glowEmissiveOnly:i},this._shouldRender=!0},i.prototype.removeMesh=function(e){var t=this._meshes[e.uniqueId];t&&(e.onBeforeRenderObservable.remove(t.observerHighlight),e.onAfterRenderObservable.remove(t.observerDefault)),this._meshes[e.uniqueId]=void 0,this._shouldRender=!1;for(var i in this._meshes)if(i){this._shouldRender=!0;break}},i.prototype.shouldRender=function(){return this.isEnabled&&this._shouldRender},i.prototype.setMainTextureSize=function(){this._options.mainTextureFixedSize?(this._mainTextureDesiredSize.width=this._options.mainTextureFixedSize,this._mainTextureDesiredSize.height=this._options.mainTextureFixedSize):(this._mainTextureDesiredSize.width=this._engine.getRenderingCanvas().width*this._options.mainTextureRatio,this._mainTextureDesiredSize.height=this._engine.getRenderingCanvas().height*this._options.mainTextureRatio,this._mainTextureDesiredSize.width=e.Tools.GetExponentOfTwo(this._mainTextureDesiredSize.width,this._maxSize),this._mainTextureDesiredSize.height=e.Tools.GetExponentOfTwo(this._mainTextureDesiredSize.height,this._maxSize))},i.prototype.defaultStencilReference=function(e){e.getScene().getEngine().setStencilFunctionReference(i.normalMeshStencilReference)},i.prototype.disposeTextureAndPostProcesses=function(){this._blurTexture.dispose(),this._mainTexture.dispose(),this._downSamplePostprocess.dispose(),this._horizontalBlurPostprocess.dispose(),this._verticalBlurPostprocess.dispose()},i.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.disposeTextureAndPostProcesses();for(var i in this._meshes){var r=this._meshes[i];r&&r.mesh&&(r.mesh.onBeforeRenderObservable.remove(r.observerHighlight),r.mesh.onAfterRenderObservable.remove(r.observerDefault))}this._meshes=null;for(var i in this._excludedMeshes){var r=this._excludedMeshes[i];r&&(r.mesh.onBeforeRenderObservable.remove(r.beforeRender),r.mesh.onAfterRenderObservable.remove(r.afterRender))}this._excludedMeshes=null;var n=this._scene.highlightLayers.indexOf(this,0);n>-1&&this._scene.highlightLayers.splice(n,1),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this.onBeforeRenderMainTextureObservable.clear(),this.onBeforeBlurObservable.clear(),this.onBeforeComposeObservable.clear(),this.onAfterComposeObservable.clear(),this.onSizeChangedObservable.clear()},i})();i.neutralColor=new e.Color4(0,0,0,0),i.glowingMeshStencilReference=2,i.normalMeshStencilReference=1,e.HighlightLayer=i})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(){}return e.TransformCoordinatesToRefSIMD=function(t,i,r){e.TransformCoordinatesFromFloatsToRefSIMD(t.x,t.y,t.z,i,r)},e.TransformCoordinatesFromFloatsToRefSIMD=function(e,t,i,r,n){var o=r.m,s=SIMD.Float32x4.load(o,0),a=SIMD.Float32x4.load(o,4),h=SIMD.Float32x4.load(o,8),c=SIMD.Float32x4.load(o,12),l=SIMD.Float32x4.add(SIMD.Float32x4.add(SIMD.Float32x4.mul(SIMD.Float32x4.splat(e),s),SIMD.Float32x4.mul(SIMD.Float32x4.splat(t),a)),SIMD.Float32x4.add(SIMD.Float32x4.mul(SIMD.Float32x4.splat(i),h),c));l=SIMD.Float32x4.div(l,SIMD.Float32x4.swizzle(l,3,3,3,3)),n.x=SIMD.Float32x4.extractLane(l,0),n.y=SIMD.Float32x4.extractLane(l,1),n.z=SIMD.Float32x4.extractLane(l,2)},e})(),i=(function(){function e(){}return e.prototype.multiplyToArraySIMD=function(e,t,i){for(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=0;c<16;c+=4)SIMD.Float32x4.store(t,c+i,SIMD.Float32x4.add(SIMD.Float32x4.mul(SIMD.Float32x4.splat(r[c]),o),SIMD.Float32x4.add(SIMD.Float32x4.mul(SIMD.Float32x4.splat(r[c+1]),s),SIMD.Float32x4.add(SIMD.Float32x4.mul(SIMD.Float32x4.splat(r[c+2]),a),SIMD.Float32x4.mul(SIMD.Float32x4.splat(r[c+3]),h)))));return this},e.prototype.invertToRefSIMD=function(e){var t=this.m,i=e.m,r=SIMD.Float32x4.load(t,0),n=SIMD.Float32x4.load(t,4),o=SIMD.Float32x4.load(t,8),s=SIMD.Float32x4.load(t,12),a=SIMD.Float32x4.shuffle(r,n,0,1,4,5),h=SIMD.Float32x4.shuffle(o,s,0,1,4,5),c=SIMD.Float32x4.shuffle(a,h,0,2,4,6);h=SIMD.Float32x4.shuffle(h,a,1,3,5,7),a=SIMD.Float32x4.shuffle(r,n,2,3,6,7);var l=SIMD.Float32x4.shuffle(o,s,2,3,6,7),u=SIMD.Float32x4.shuffle(a,l,0,2,4,6);l=SIMD.Float32x4.shuffle(l,a,1,3,5,7),a=SIMD.Float32x4.mul(u,l),a=SIMD.Float32x4.swizzle(a,1,0,3,2);var d=SIMD.Float32x4.mul(h,a),f=SIMD.Float32x4.mul(c,a);a=SIMD.Float32x4.swizzle(a,2,3,0,1),d=SIMD.Float32x4.sub(SIMD.Float32x4.mul(h,a),d),f=SIMD.Float32x4.sub(SIMD.Float32x4.mul(c,a),f),f=SIMD.Float32x4.swizzle(f,2,3,0,1),a=SIMD.Float32x4.mul(h,u),a=SIMD.Float32x4.swizzle(a,1,0,3,2),d=SIMD.Float32x4.add(SIMD.Float32x4.mul(l,a),d);var p=SIMD.Float32x4.mul(c,a);a=SIMD.Float32x4.swizzle(a,2,3,0,1),d=SIMD.Float32x4.sub(d,SIMD.Float32x4.mul(l,a)),p=SIMD.Float32x4.sub(SIMD.Float32x4.mul(c,a),p),p=SIMD.Float32x4.swizzle(p,2,3,0,1),a=SIMD.Float32x4.mul(SIMD.Float32x4.swizzle(h,2,3,0,1),l),a=SIMD.Float32x4.swizzle(a,1,0,3,2),u=SIMD.Float32x4.swizzle(u,2,3,0,1),d=SIMD.Float32x4.add(SIMD.Float32x4.mul(u,a),d);var _=SIMD.Float32x4.mul(c,a);a=SIMD.Float32x4.swizzle(a,2,3,0,1),d=SIMD.Float32x4.sub(d,SIMD.Float32x4.mul(u,a)),_=SIMD.Float32x4.sub(SIMD.Float32x4.mul(c,a),_),_=SIMD.Float32x4.swizzle(_,2,3,0,1),a=SIMD.Float32x4.mul(c,h),a=SIMD.Float32x4.swizzle(a,1,0,3,2),_=SIMD.Float32x4.add(SIMD.Float32x4.mul(l,a),_),p=SIMD.Float32x4.sub(SIMD.Float32x4.mul(u,a),p),a=SIMD.Float32x4.swizzle(a,2,3,0,1),_=SIMD.Float32x4.sub(SIMD.Float32x4.mul(l,a),_),p=SIMD.Float32x4.sub(p,SIMD.Float32x4.mul(u,a)),a=SIMD.Float32x4.mul(c,l),a=SIMD.Float32x4.swizzle(a,1,0,3,2),f=SIMD.Float32x4.sub(f,SIMD.Float32x4.mul(u,a)),_=SIMD.Float32x4.add(SIMD.Float32x4.mul(h,a),_),a=SIMD.Float32x4.swizzle(a,2,3,0,1),f=SIMD.Float32x4.add(SIMD.Float32x4.mul(u,a),f),_=SIMD.Float32x4.sub(_,SIMD.Float32x4.mul(h,a)),a=SIMD.Float32x4.mul(c,u),a=SIMD.Float32x4.swizzle(a,1,0,3,2),f=SIMD.Float32x4.add(SIMD.Float32x4.mul(l,a),f),p=SIMD.Float32x4.sub(p,SIMD.Float32x4.mul(h,a)),a=SIMD.Float32x4.swizzle(a,2,3,0,1),f=SIMD.Float32x4.sub(f,SIMD.Float32x4.mul(l,a)),p=SIMD.Float32x4.add(SIMD.Float32x4.mul(h,a),p);var m=SIMD.Float32x4.mul(c,d);return m=SIMD.Float32x4.add(SIMD.Float32x4.swizzle(m,2,3,0,1),m),m=SIMD.Float32x4.add(SIMD.Float32x4.swizzle(m,1,0,3,2),m),a=SIMD.Float32x4.reciprocalApproximation(m),m=SIMD.Float32x4.sub(SIMD.Float32x4.add(a,a),SIMD.Float32x4.mul(m,SIMD.Float32x4.mul(a,a))),m=SIMD.Float32x4.swizzle(m,0,0,0,0),SIMD.Float32x4.store(i,0,SIMD.Float32x4.mul(m,d)),SIMD.Float32x4.store(i,4,SIMD.Float32x4.mul(m,f)),SIMD.Float32x4.store(i,8,_=SIMD.Float32x4.mul(m,_)),SIMD.Float32x4.store(i,12,SIMD.Float32x4.mul(m,p)),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 d=SIMD.Float32x4.splat(0);l=SIMD.Float32x4.neg(l);var f=SIMD.Float32x4.shuffle(l,u,0,1,4,5),p=SIMD.Float32x4.shuffle(h,d,0,1,4,5),_=SIMD.Float32x4.shuffle(f,p,0,2,4,6),m=SIMD.Float32x4.shuffle(f,p,1,3,5,7),g=SIMD.Float32x4.shuffle(SIMD.Float32x4.shuffle(l,u,2,3,6,7),SIMD.Float32x4.shuffle(h,d,2,3,6,7),0,2,4,6),v=SIMD.Float32x4(0,0,0,1),y=SIMD.Float32x4(1,0,0,0);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))))),y=SIMD.Float32x4(0,1,0,0),SIMD.Float32x4.store(n,4,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))))),y=SIMD.Float32x4(0,0,1,0),SIMD.Float32x4.store(n,8,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))))),y=SIMD.Float32x4.replaceLane(SIMD.Float32x4.neg(s),3,1),SIMD.Float32x4.store(n,12,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)))))},e})(),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!==self.SIMD&&(self.Math.fround||(self.Math.fround=(function(e){return function(t){return e[0]=t,e[0]}})(new Float32Array(1))),self.Math.imul||(self.Math.imul=function(e,t){var i=e>>>16&65535,r=65535&e,n=t>>>16&65535,o=65535&t;return r*o+(i*o+r*n<<16>>>0)|0}),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,h._isEnabled=!0)},h})();h._isEnabled=!1,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,this._contentSize=null,this._bottomNode=null,this._leftNode=null,this._initialSize=null,this._rightNode=null}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(){return this.getUVsForCustomSize(this._root._size)},enumerable:!0,configurable:!0}),t.prototype.getUVsForCustomSize=function(t){var i=this._root._size.width,r=this._root._size.height,n=new e.Vector2(this._pos.x/i,this._pos.y/r),o=new e.Vector2((this._pos.x+t.width-1)/i,(this._pos.y+t.height-1)/r),s=new Array;return s.push(n),s.push(new e.Vector2(o.x,n.y)),s.push(o),s.push(new e.Vector2(n.x,o.y)),s},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;if(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));else if(this._initialSize){if(!(e.width<=this._initialSize.width&&e.height<=this._initialSize.height))return null;t=this}else e.width<=this._size.width&&e.height<=this._size.height&&(t=this);return t},t.prototype.splitNode=function(i){return!this._contentSize&&this._initialSize?(this._contentSize=i.clone(),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){var r=t.call(this,null,null,e.Vector2.Zero(),i)||this;return r._root=r,r}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;r0?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=h);l++){var u=n[l],d=u.offset,f=d-c;if(f!==i){for(var p=f/i-1,_=d-i,m=Math.min(a,p),g=0;go.width&&(this._currentFreePosition.x=0,this._currentFreePosition.y+=this._lineHeightSuper+this._yMargin,this._currentFreePosition.y>o.height))return this.getChar("!");if(this._signedDistanceField){this._sdfContext.clearRect(0,0,this._sdfCanvas.width,this._sdfCanvas.height),this._sdfContext.fillText(i,0,-this._offset);var a=this._sdfContext.getImageData(0,0,s*this._sdfScale,this._sdfCanvas.height),h=this._computeSDFChar(a);this._context.putImageData(h,this._currentFreePosition.x,this._currentFreePosition.y)}else this._context.fillText(i,this._currentFreePosition.x,this._currentFreePosition.y-this._offset);if(r.topLeftUV=new e.Vector2(this._currentFreePosition.x/o.width,this._currentFreePosition.y/o.height),r.bottomRightUV=new e.Vector2((this._currentFreePosition.x+s)/o.width,r.topLeftUV.y+(this._lineHeightSuper+2)/o.height),this._signedDistanceField){var c=1/o.width;r.topLeftUV.addInPlace(new e.Vector2(c,c)),r.bottomRightUV.addInPlace(new e.Vector2(c,c))}return r.charWidth=this._superSample?s/2:s,this._charInfos[i]=r,this._curCharCount++,this._currentFreePosition.x+=s+this._xMargin,r},r.prototype._computeSDFChar=function(e){for(var t=this._sdfScale,i=e.width,r=e.height,n=i/t,o=r/t,s=0,a=0,h=t,c=h-1,l=function(n,o,h,c,l){var u=n*t,d=o*t;if(u+h<0||u+h>=i||d+c<0||d+c>=r)return!0;var f=e.data[4*((d+c)*i+(u+h))],p=f>0===l;return p||(s=h,a=c),p},u=function(e,t,i){if(l(e,t,0,c,i)&&l(e,t,0,-c,i)&&l(e,t,-c,0,i)&&l(e,t,c,0,i))return 0;for(var r=1;r<=h;r++){if(!(l(e,t,0,r,i)&&l(e,t,0,-r,i)&&l(e,t,-r,0,i)&&l(e,t,r,0,i)))return r*r;for(var n=1;n<=r;n++)if(!(l(e,t,-n,r,i)&&l(e,t,n,r,i)&&l(e,t,r,-n,i)&&l(e,t,r,n,i)&&l(e,t,-n,-r,i)&&l(e,t,n,-r,i)&&l(e,t,-r,-n,i)&&l(e,t,-r,n,i))){var o=r*r+n*n,u=1;return l(e,t,s-1,a,i)||(o+=(s-1)*(s-1)+a*a,++u),l(e,t,s+1,a,i)||(o+=(s+1)*(s+1)+a*a,++u),l(e,t,s,a-1,i)||(o+=s*s+(a-1)*(a-1),++u),l(e,t,s,a+1,i)||(o+=s*s+(a+1)*(a+1),++u),l(e,t,s-1,a-1,i)||(o+=(s-1)*(s-1)+(a-1)*(a-1),++u),l(e,t,s+1,a+1,i)||(o+=(s+1)*(s+1)+(a+1)*(a+1),++u),l(e,t,s+1,a-1,i)||(o+=(s+1)*(s+1)+(a-1)*(a-1),++u),l(e,t,s-1,a+1,i)||(o+=(s-1)*(s-1)+(a+1)*(a+1),++u),o/u}}return 0},d=new Array(n*o),f=0;f255&&(m=255),m+=.5,g.data[4*y+0]=m,g.data[4*y+1]=m,g.data[4*y+2]=m,g.data[4*y+3]=255}return g},r.prototype.measureText=function(t,i){void 0===i&&(i=4);for(var r=0,n=0,o=1,s=0,a=0,h=t;a>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"),d=i("DXT5"),f=31,p=0,_=1,m=2,g=3,v=4,y=7,x=20,b=21,A=22,E=28,T=(function(){function t(){}return t.GetDDSInfo=function(e){var t=new Int32Array(e,0,f),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[E]&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;c=0;h--)for(var c=0;c=0;h--)for(var c=0;ct.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;rh||r.deleted||r.isDirty))for(var o=0;o<3;++o)if(r.error[o]>0,d,(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]],d=s.vertices[u[o-c.verticesStart]],f=s.vertices[u[a-c.verticesStart]],p=new n([l,d,f]);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();for(var n=0;n<3;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;r<3;++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;i0&&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,f,_,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.999)return!0;var p=e.Vector3.Cross(d,f).normalize();if(n[a]=!1,e.Vector3.Dot(p,h.normal)<.2)return!0}else n[a]=!0,s.push(h)}}return!1},t.prototype.updateTriangles=function(e,t,i,r){for(var n=r,o=0;o80*r){l=d=e[0],u=f=e[1];for(var g=r;gd&&(d=p),_>f&&(f=_);m=Math.max(d-l,f-u)}return n(a,h,r,l,u,m,void 0),h}function i(e,t,i,r,n){var o,s;if(n===O(e,t,i,r)>0)for(o=t;o=t;o-=r)s=M(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,d){if(e){!d&&u&&f(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){d?1===d?(e=a(e,t,i),n(e,t,i,c,l,u,2)):2===d&&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.xo.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),d=_(c,l,t,i,r),f=e.nextZ;f&&f.z<=d;){if(f!==e.prev&&f!==e.next&&g(n.x,n.y,o.x,o.y,s.x,s.y,f.x,f.y)&&y(f.prev,f,f.next)>=0)return!1;f=f.nextZ}for(f=e.prevZ;f&&f.z>=u;){if(f!==e.prev&&f!==e.next&&g(n.x,n.y,o.x,o.y,s.x,s.y,f.x,f.y)&&y(f.prev,f,f.next)>=0)return!1;f=f.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)&&E(n,o)&&E(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=P(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,d,f=[];for(s=0,a=t.length;s=r.next.y){var a=r.x+(o-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(a<=n&&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.x&&r.x>=l&&g(oi.x)&&E(r,e)&&(i=r,d=h)),r=r.next;return i}function f(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;t0||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=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&&!A(e,t)&&E(e,t)&&E(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))||y(e,t,i)>0!=y(e,t,r)>0&&y(i,r,e)>0!=y(i,r,t)>0}function A(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 E(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 P(e,t){var i=new C(e.i,e.x,e.y),r=new C(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 M(e,t,i,r){var n=new C(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 C(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 R(e,t,i,r){var n=t&&t.length,o=n?t[0]*i:e.length,s=Math.abs(O(e,0,o,i));if(n)for(var a=0,h=t.length;a0&&(r+=e[n-1].length,i.holes.push(r))}return i}e.earcut=t,e.deviation=R,e.flatten=I})(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,d=2,f=3,p=0,_=[];for(h=0;ht.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 d:a.push(i);break;case f:var g=[],v=[];for(h=0;h=3&&(P=new n(g,i.shared),P.plane&&s.push(P)),v.length>=3&&(P=new n(v,i.shared),P.plane&&a.push(P))}},t})();r.EPSILON=1e-5;var 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;ei.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));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})();i._globalJoystickIndex=0,e.VirtualJoystick=i})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(e){function t(t,i,r){var n=e.call(this,t,i,r)||this;return n.inputs.addVirtualJoystick(),n}return __extends(t,e),t.prototype.getClassName=function(){return"VirtualJoysticksCamera"},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=e.call(this,t,"anaglyph",null,["leftSampler"],i,r[1],n,o,s)||this;return a._passedProcess=r[0]._rigPostProcess,a.onApplyObservable.add((function(e){e.setTextureFromPostProcess("leftSampler",a._passedProcess)})),a}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 t(e,t){this.name=e,this.url=t,this.isCompleted=!1}return t.prototype.run=function(t,i,r){var n=this,o=new Image;e.Tools.SetCorsBehavior(this.url,o),o.onload=function(){n.image=o,n.isCompleted=!0,n.onSuccess&&n.onSuccess(n),i()},o.onerror=function(){n.onError&&n.onError(n),r()},o.src=this.url},t})();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 t(e,t,i,r,n){this.name=e,this.url=t,this.extensions=i,this.noMipmap=r,this.files=n,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.CubeTexture(this.url,t,this.extensions,this.noMipmap,this.files,o,s)},t})();e.CubeTextureAssetTask=s;var a=(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;e0){if(a._vrEnabled=!0,a.webVROptions.displayName){var i=t.some((function(e){return e.displayName===a.webVROptions.displayName&&(a._vrDevice=e,!0)}));i||(a._vrDevice=t[0],e.Tools.Warn("Display "+a.webVROptions.displayName+" was not found. Using "+a._vrDevice.displayName))}else a._vrDevice=t[0];a.setCameraRigMode(e.Camera.RIG_MODE_WEBVR,{vrDisplay:a._vrDevice,frameData:a._frameData}),a._attached&&a.getEngine().enableVR(a._vrDevice)}else e.Tools.Error("No WebVR devices found!")}))):e.Tools.Error("WebVR is not enabled on your browser"),a.rotationQuaternion=new e.Quaternion,a._quaternionCache=new e.Quaternion,a}return __extends(i,t),i.prototype._checkInputs=function(){if(this._vrEnabled&&this._vrDevice.getFrameData(this._frameData)){var e=this._frameData.pose;e&&e.orientation&&(this._cacheState=e,this.rotationQuaternion.copyFromFloats(this._cacheState.orientation[0],this._cacheState.orientation[1],-this._cacheState.orientation[2],-this._cacheState.orientation[3]),this.webVROptions.trackPosition&&this._cacheState.position&&(this.position.copyFromFloats(this._cacheState.position[0],this._cacheState.position[1],-this._cacheState.position[2]),this.webVROptions.positionScale&&this.position.scaleInPlace(this.webVROptions.positionScale),this.position.addInPlace(this._positionOffset)))}t.prototype._checkInputs.call(this)},i.prototype.attachControl=function(i,r){t.prototype.attachControl.call(this,i,r),this._attached=!0,r=!e.Camera.ForceAttachControlToAlwaysPreventDefault&&r,this._vrEnabled&&this.getEngine().enableVR(this._vrDevice)},i.prototype.detachControl=function(e){t.prototype.detachControl.call(this,e),this._vrEnabled=!1,this._attached=!1,this.getEngine().disableVR()},i.prototype.requestVRFullscreen=function(t){e.Tools.Warn("requestVRFullscreen is deprecated. call attachControl() to start sending frames to the VR display.")},i.prototype.getClassName=function(){return"WebVRFreeCamera"; -},i.prototype.resetToCurrentRotation=function(){this._vrDevice.resetPose()},i.prototype.setPositionOffset=function(e){e?this._positionOffset=e:this._positionOffset.copyFrom(this.position)},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){void 0===t&&(t=0),void 0===i&&(i=1024);var r=e.call(this,t)||this;return r.priority=t,r.maximumSize=i,r.apply=function(e){for(var t=!0,i=0;ir.maximumSize&&(n.scale(.5),t=!1)}}return t},r}return __extends(t,e),t})(t);e.TextureOptimization=i;var r=(function(e){function t(t,i){void 0===t&&(t=0),void 0===i&&(i=2);var r=e.call(this,t)||this;return r.priority=t,r.maximumScale=i,r._currentScale=1,r.apply=function(e){return r._currentScale++,e.getEngine().setHardwareScalingLevel(r._currentScale),r._currentScale>=r.maximumScale},r}return __extends(t,e),t})(t);e.HardwareScalingOptimization=r;var n=(function(e){function t(){var t=e.apply(this,arguments)||this;return t.apply=function(e){return e.shadowsEnabled=!1,!0},t}return __extends(t,e),t})(t);e.ShadowsOptimization=n;var o=(function(e){function t(){var t=e.apply(this,arguments)||this;return t.apply=function(e){return e.postProcessesEnabled=!1,!0},t}return __extends(t,e),t})(t);e.PostProcessesOptimization=o;var s=(function(e){function t(){var t=e.apply(this,arguments)||this;return t.apply=function(e){return e.lensFlaresEnabled=!1,!0},t}return __extends(t,e),t})(t);e.LensFlaresOptimization=s;var a=(function(e){function t(){var t=e.apply(this,arguments)||this;return t.apply=function(e){return e.particlesEnabled=!1,!0},t}return __extends(t,e),t})(t);e.ParticlesOptimization=a;var h=(function(e){function t(){var t=e.apply(this,arguments)||this;return t.apply=function(e){return e.renderTargetsEnabled=!1,!0},t}return __extends(t,e),t})(t);e.RenderTargetsOptimization=h;var c=(function(t){function i(){var r=t.apply(this,arguments)||this;return r._canBeMerged=function(t){if(!(t instanceof e.Mesh))return!1;var i=t;return!(!i.isVisible||!i.isEnabled())&&(!(i.instances.length>0)&&(!i.skeleton&&!i.hasLODLevels&&!i.parent))},r.apply=function(t,n){for(var o=t.meshes.slice(0),s=o.length,a=0;a=i.targetFrameRate)return void(n&&n());for(var s=!0,a=!0,h=0;hi.x&&(i.x=e.x),e.yi.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;h0){var d=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 f=c.length,u=0;us.elements.length-1?s.elements[0]:s.elements[u+1],t.push(f.x,0,f.y),t.push(f.x,-a,f.y),t.push(d.x,0,d.y),t.push(d.x,-a,d.y);var p=new e.Vector3(f.x,0,f.y),_=new e.Vector3(d.x,0,d.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;tthis.capacity&&this._depth0&&(t.x-=this.viewportBorder,t.y-=this.viewportBorder,t.width+=2*this.viewportBorder,t.height+=2*this.viewportBorder,i.x+=this.viewportBorder,i.y+=this.viewportBorder,this._positionX+=this.viewportBorder,this._positionY+=this.viewportBorder),i.z>0&&(this._positionX>t.x&&this._positionXt.y&&this._positionYr},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._positionXr.x+r.width-this.borderLimit?this._positionX-r.x-r.width+this.borderLimit:0,o=this._positionYr.y+r.height-this.borderLimit?this._positionY-r.y-r.height+this.borderLimit:0;var s=n>o?n:o;s-=this.viewportBorder,s>this.borderLimit&&(s=this.borderLimit);var a=1-s/this.borderLimit;if(a<0)return!1;a>1&&(a=1),this.viewportBorder>0&&(r.x+=this.viewportBorder,r.y+=this.viewportBorder,r.width-=2*this.viewportBorder,r.height-=2*this.viewportBorder,this._positionX-=this.viewportBorder,this._positionY-=this.viewportBorder);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.bindBuffers(this._vertexBuffers,this._indexBuffer,this._effect);for(var d=0;d=2&&(this._leftStick={x:this.browserGamepad.axes[this._leftStickAxisX],y:this.browserGamepad.axes[this._leftStickAxisY]}),this.browserGamepad.axes.length>=4&&(this._rightStick={x:this.browserGamepad.axes[this._rightStickAxisX],y:this.browserGamepad.axes[this._rightStickAxisY]})}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[this._leftStickAxisX],y:this.browserGamepad.axes[this._leftStickAxisY]}),this._rightStick&&(this.rightStick={x:this.browserGamepad.axes[this._rightStickAxisX],y:this.browserGamepad.axes[this._rightStickAxisY]})},e})();e.Gamepad=r;var n=(function(e){function t(t,i,r){var n=e.call(this,t,i,r)||this;return n.id=t,n.index=i,n.gamepad=r,n._buttons=new Array(r.buttons.length),n}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;t4&&(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=t.call(this,r.getEngine(),i)||this;s.SSAOOriginalSceneColorEffect="SSAOOriginalSceneColorEffect",s.SSAORenderEffect="SSAORenderEffect",s.SSAOBlurHRenderEffect="SSAOBlurHRenderEffect",s.SSAOBlurVRenderEffect="SSAOBlurVRenderEffect",s.SSAOCombineRenderEffect="SSAOCombineRenderEffect",s.totalStrength=1,s.radius=1e-4,s.area=.0075,s.fallOff=1e-6,s.base=.5,s._firstUpdate=!0,s._scene=r,s._createRandomTexture(),s._depthTexture=r.enableDepthRenderer().getDepthMap();var a=n.ssaoRatio||n,h=n.combineRatio||n;return s._ratio={ssaoRatio:a,combineRatio:h},s._originalColorPostProcess=new e.PassPostProcess("SSAOOriginalSceneColor",h,null,e.Texture.BILINEAR_SAMPLINGMODE,r.getEngine(),(!1)),s._createSSAOPostProcess(a),s._createBlurPostProcess(a),s._createSSAOCombinePostProcess(h),s.addEffect(new e.PostProcessRenderEffect(r.getEngine(),s.SSAOOriginalSceneColorEffect,function(){return s._originalColorPostProcess},(!0))),s.addEffect(new e.PostProcessRenderEffect(r.getEngine(),s.SSAORenderEffect,function(){return s._ssaoPostProcess},(!0))),s.addEffect(new e.PostProcessRenderEffect(r.getEngine(),s.SSAOBlurHRenderEffect,function(){return s._blurHPostProcess},(!0))),s.addEffect(new e.PostProcessRenderEffect(r.getEngine(),s.SSAOBlurVRenderEffect,function(){return s._blurVPostProcess},(!0))),s.addEffect(new e.PostProcessRenderEffect(r.getEngine(),s.SSAOCombineRenderEffect,function(){return s._ssaoCombinePostProcess},(!0))),r.postProcessRenderPipelineManager.addPipeline(s),o&&r.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(i,o),s}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;t0&&this.excludedMeshes.indexOf(e)!==-1},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;ot._alphaIndex?1:e._alphaIndext._distanceToCamera?-1:0})),a.setAlphaMode(e.Engine.ALPHA_COMBINE),o=0;o=0;l--)c(l);return h.addEffect(new e.PostProcessRenderEffect(n.getEngine(),"HDR",function(){return h._hdrPostProcess},(!0))),n.postProcessRenderPipelineManager.addPipeline(h),null!==a&&n.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(r,a),h.update(),h}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._hdrCurrentLuminancer._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;i<2;i++)for(var o=-2;o<2;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;r<2;r++)for(var n=-1;n<2;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)}},d=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},f={width:Math.pow(3,o-1),height:Math.pow(3,o-1)};this._downSamplePostProcesses[o-1]=new e.PostProcess("hdr","hdr",["lumOffsets"],[],f,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);f={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"],[],f,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=d)}},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;r<9;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;t<9;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})(e.PostProcessRenderPipeline);t.LUM_STEPS=6,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=ad?d:n,r=Math.round(d/n),o=0):r=r>d?d:r;for(var f=[],p=[],_=[],m=[],g=e.Tmp.Vector3[0],v=r;ud-r&&(r=d-u),f.length=0,p.length=0,_.length=0,m.length=0;for(var y=0,x=3*u;x<3*(u+r);x++){p.push(y);var b=a[x];f.push(s[3*b],s[3*b+1],s[3*b+2]),h&&_.push(h[2*b],h[2*b+1]),c&&m.push(c[4*b],c[4*b+1],c[4*b+2],c[4*b+3]),y++}var A,E=this.nbParticles,T=this._posToShape(f),P=this._uvsToShapeUV(_);for(A=0;Athis.nbParticles-1?this.nbParticles-1:i;for(var u=t;u<=i;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.billboard)&&(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;lthis._maximum.x&&(this._maximum.x=this._positions32[n]),this._positions32[n+1]this._maximum.y&&(this._maximum.y=this._positions32[n+1]),this._positions32[n+2]this._maximum.z&&(this._maximum.z=this._positions32[n+2])),this._computeParticleVertex||(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;lMath.PI;)n-=2*Math.PI;var s=n/Math.PI,a=o/Math.PI;s=.5*s+.5;var h=Math.round(s*i);h<0?h=0:h>=i&&(h=i-1);var c=Math.round(a*r);c<0?c=0:c>=r&&(c=r-1);var l=r-c-1,u=t[l*i*3+3*h+0],d=t[l*i*3+3*h+1],f=t[l*i*3+3*h+2];return{r:u,g:d,b:f}},e})();i.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))],i.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)],i.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)],i.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))],i.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)],i.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.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):t<-1074?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;n32767)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,d=0,f=new ArrayBuffer(4*h),p=new Uint8Array(f),_=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,d=0;d<4;d++)for(u=(d+1)*h;l128){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;gthis.max.y||this.min.y>this.max.y||this.min.z>this.max.y},t})();i.MAX=Number.MAX_VALUE,i.MIN=Number.MIN_VALUE;var r=(function(){function e(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 e.prototype.filterCubeMap=function(){return this.init(),this.filterCubeMapMipChain(),this._outputSurface},e.prototype.init=function(){var t,i,r;for(0==this.maxNumMipLevels&&(this.maxNumMipLevels=e.CP_MAX_MIPLEVELS),r=this.outputSize,i=0;i>=1,this._numMipLevels++,0==r)return void(this.maxNumMipLevels=i)}},e.prototype.filterCubeMapMipChain=function(){var e=this.specularPower;this.precomputeFilterLookupTables(this.inputSize);for(var t=0;t>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}},e.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},e.prototype.precomputeFilterLookupTables=function(e){this._normCubeMap=[],this.buildNormalizerSolidAngleCubemap(e)},e.prototype.buildNormalizerSolidAngleCubemap=function(e){var t,i,r;for(t=0;t<6;t++){this._normCubeMap.push(new Float32Array(e*e*4));this.input[t];for(r=0;r1){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=e._sgFace2DMapping[t][e.CP_UDIR];e._vectorTemp.x=c[0]*s,e._vectorTemp.y=c[1]*s,e._vectorTemp.z=c[2]*s;var l=e._sgFace2DMapping[t][e.CP_VDIR];e._vectorTemp.x+=l[0]*a,e._vectorTemp.y+=l[1]*a,e._vectorTemp.z+=l[2]*a;var u=e._sgFace2DMapping[t][e.CP_FACEAXIS];return e._vectorTemp.x+=u[0],e._vectorTemp.y+=u[1],e._vectorTemp.z+=u[2],e._vectorTemp.normalize(),e._vectorTemp},e.prototype.vectToTexelCoord=function(t,i,r,n){var o,s,a=Math.abs(t),h=Math.abs(i),c=Math.abs(r);a>=h&&a>=c?(o=a,s=t>=0?e.CP_FACE_X_POS:e.CP_FACE_X_NEG):h>=a&&h>=c?(o=h,s=i>=0?e.CP_FACE_Y_POS:e.CP_FACE_Y_NEG):(o=c,s=r>=0?e.CP_FACE_Z_POS:e.CP_FACE_Z_NEG);var l=1/o;t*=l,i*=l,r*=l;var u=e._sgFace2DMapping[s][e.CP_UDIR],d=u[0]*t+u[1]*i+u[2]*r;u=e._sgFace2DMapping[s][e.CP_VDIR];var f=u[0]*t+u[1]*i+u[2]*r,p=Math.floor(.5*(n-1)*(d+1)),_=Math.floor(.5*(n-1)*(f+1));return e._vectorTemp.x=s,e._vectorTemp.y=p,e._vectorTemp.z=_,e._vectorTemp},e.prototype.areaElement=function(e,t){return Math.atan2(e*t,Math.sqrt(e*e+t*t+1))},e.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},e.prototype.filterCubeSurfaces=function(e,t,r,n,o,s){var a,h,c,l=[];for(a=0;a<6;a++)l.push(new i);var u=180/Math.PI*Math.atan2(1,t),d=o/2;d90&&(d=90);var f=Math.ceil(d/u);f<1&&(f=1);var p=Math.cos(Math.PI/180*d);for(a=0;a<6;a++)for(c=0;c0){switch(o=e._sgCubeNgh[d][y][0],s=e._sgCubeNgh[d][y][1],y!=s&&y+s!=3||(c[y]=i-1-c[y],l[y]=i-1-l[y]),e._sgCubeNgh[d][y][1]){case e.CP_EDGE_LEFT:n[o].augment(0,c[y],0),n[o].augment(h[y],l[y],0);break;case e.CP_EDGE_RIGHT:n[o].augment(i-1,c[y],0),n[o].augment(i-1-h[y],l[y],0);break;case e.CP_EDGE_TOP:n[o].augment(c[y],0,0),n[o].augment(l[y],h[y],0);break;case e.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(d){case e.CP_FACE_X_POS:a=e.CP_FACE_X_NEG;break;case e.CP_FACE_X_NEG:a=e.CP_FACE_X_POS;break;case e.CP_FACE_Y_POS:a=e.CP_FACE_Y_NEG;break;case e.CP_FACE_Y_NEG:a=e.CP_FACE_Y_POS;break;case e.CP_FACE_Z_POS:a=e.CP_FACE_Z_NEG;break;case e.CP_FACE_Z_NEG:a=e.CP_FACE_Z_POS}n[a].augment(0,0,0),n[a].augment(i-1,i-1,0)}}},e.prototype.processFilterExtents=function(t,i,r,n,o,s){for(var a=[0,0,0,0],h=0,c=0,l=this.numChannels,u=o,d=4*u,f=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),A=g;A<=y;A++){for(var E=0,T=0,P=m;P<=v;P++){var M=this._normCubeMap[_][x+E+0],S=this._normCubeMap[_][x+E+1],C=this._normCubeMap[_][x+E+2],R=M*t.x+S*t.y+C*t.z;if(R>=i&&R>0){var O=this._normCubeMap[_][x+E+3];for(O*=Math.pow(R,s+p),c=0;c3&&(e._vectorTemp.w=a[3]/h);else{var I=this.vectToTexelCoord(t.x,t.y,t.z,o).clone();e._vectorTemp.x=n[I.x][this.numChannels*(I.z*o+I.y)+0],e._vectorTemp.y=n[I.x][this.numChannels*(I.z*o+I.y)+1],e._vectorTemp.z=n[I.x][this.numChannels*(I.z*o+I.y)+2],this.numChannels>3&&(e._vectorTemp.z=n[I.x][this.numChannels*(I.z*o+I.y)+3])}return e._vectorTemp},e.prototype.fixupCubeEdges=function(t,i){var r,n,o,s,a=0,h=[0,0,0,0,0,0,0,0],c=[[],[],[],[]],l=[[[],[],[]],[[],[],[]],[[],[],[]],[[],[],[]],[[],[],[]],[[],[],[]],[[],[],[]],[[],[],[]]];if(!(i<1))if(1!=i){for(s=0;s<6;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;a<4;a++){var u=e._sgCubeCornerList[s][a];l[u][h[u]]=c[a],h[u]++}for(a=0;a<8;a++)for(r=0;r>s,2),h=0;h<6;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;l<6;l++)h.push(r.subarray(a,a+c)),a+=c;for(var u=[],d=null,f=0;f<6;f++){ -var p=null;if(n)p=h[f];else{var _=[0,2,4,1,3,5][f];if(p=h[_],!t.getScene().getEngine().getCaps().textureFloat){var m=new ArrayBuffer(c);d=new Uint8Array(m)}for(var g=0;g255){var A=255/b;v*=A,y*=A,x*=A}d[3*g+0]=v,d[3*g+1]=y,d[3*g+2]=x}}d?u.push(d):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;a<6;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;l255){var _=255/p;u*=_,d*=_,f*=_}s[3*l+0]=u,s[3*l+1]=d,s[3*l+2]=f}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,t.generateHarmonics,t.useInGammaSpace,t.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.customType="BABYLON.HDRCubeTexture",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>l;c+=6*u*u*3*4}var d=new ArrayBuffer(c),f=new Int32Array(d),p=new Float32Array(d);f[0]=1,f[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),f[29]=h.length;for(var _=30,l=0;l>l,2),g=0;g<6;g++)p.set(h[l][g],_),_+=m;r(d)};e.Tools.LoadFile(t,(function(e){o(e)}),null,null,!0,n)},i})(e.BaseTexture);t._facesMapping=["right","up","front","left","down","back"],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;n=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),s.getAbsolutePositionToRef(this.mesh,h[0]),a.getAbsolutePositionToRef(this.mesh,h[1]),n++}}},t.prototype.update=function(){this.autoUpdateBonesMatrices&&this.skeleton.computeAbsoluteTransforms(),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.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(t){var i=(function(){function t(t,i){void 0===i&&(i=1),this._xline=[e.Vector3.Zero(),e.Vector3.Zero()],this._yline=[e.Vector3.Zero(),e.Vector3.Zero()],this._zline=[e.Vector3.Zero(),e.Vector3.Zero()],this.scaleLines=1,this.scaleLines=i,this._xmesh=e.Mesh.CreateLines("xline",this._xline,t,!0),this._ymesh=e.Mesh.CreateLines("yline",this._yline,t,!0),this._zmesh=e.Mesh.CreateLines("zline",this._zline,t,!0),this._xmesh.renderingGroupId=2,this._ymesh.renderingGroupId=2,this._zmesh.renderingGroupId=2,this._xmesh.material.checkReadyOnlyOnce=!0,this._xmesh.color=new e.Color3(1,0,0),this._ymesh.material.checkReadyOnlyOnce=!0,this._ymesh.color=new e.Color3(0,1,0),this._zmesh.material.checkReadyOnlyOnce=!0,this._zmesh.color=new e.Color3(0,0,1),this.scene=t}return t.prototype.update=function(t,i,r,n){var o=this.scaleLines,s=this._xline[0],a=this._xline[1];s.x=t.x,s.y=t.y,s.z=t.z,a.x=s.x+i.x*o,a.y=s.y+i.y*o,a.z=s.z+i.z*o,e.Mesh.CreateLines(null,this._xline,null,null,this._xmesh),s=this._yline[0],a=this._yline[1],s.x=t.x,s.y=t.y,s.z=t.z,a.x=s.x+r.x*o,a.y=s.y+r.y*o,a.z=s.z+r.z*o,e.Mesh.CreateLines(null,this._yline,null,null,this._ymesh),s=this._zline[0],a=this._zline[1],s.x=t.x,s.y=t.y,s.z=t.z,a.x=s.x+n.x*o,a.y=s.y+n.y*o,a.z=s.z+n.z*o,e.Mesh.CreateLines(null,this._zline,null,null,this._zmesh)},t.prototype.dispose=function(){this._xmesh&&(this._xmesh.dispose(),this._ymesh.dispose(),this._zmesh.dispose(),this._xmesh=null,this._ymesh=null,this._zmesh=null,this._xline=null,this._yline=null,this._zline=null,this.scene=null)},t})();t.AxesViewer=i})(t=e.Debug||(e.Debug={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t;!(function(t){var i=(function(t){function i(i,r,n,o){void 0===o&&(o=1);var s=t.call(this,i,o)||this;return s.pos=e.Vector3.Zero(),s.xaxis=e.Vector3.Zero(),s.yaxis=e.Vector3.Zero(),s.zaxis=e.Vector3.Zero(),s.mesh=n,s.bone=r,s}return __extends(i,t),i.prototype.update=function(){var i=this.bone;i.getAbsolutePositionToRef(this.mesh,this.pos),i.getDirectionToRef(e.Axis.X,this.mesh,this.xaxis),i.getDirectionToRef(e.Axis.Y,this.mesh,this.yaxis),i.getDirectionToRef(e.Axis.Z,this.mesh,this.zaxis),t.prototype.update.call(this,this.pos,this.xaxis,this.yaxis,this.zaxis)},i.prototype.dispose=function(){this.pos&&(this.pos=null,this.xaxis=null,this.yaxis=null,this.zaxis=null,this.mesh=null,this.bone=null,t.prototype.dispose.call(this))},i})(t.AxesViewer);t.BoneAxesViewer=i})(t=e.Debug||(e.Debug={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r){var n=t.call(this,r)||this;return i?(n._textureMatrix=e.Matrix.Identity(),n.name=i,n.url=i,n.hasAlpha=!1,n.isCube=!1,n.wrapU=e.Texture.CLAMP_ADDRESSMODE,n.wrapV=e.Texture.CLAMP_ADDRESSMODE,n.anisotropicFilteringLevel=1,n._texture=n._getFromCache(i,!0),n._texture||(r.useDelayedTextureLoading?n.delayLoadState=e.Engine.DELAYLOADSTATE_NOTLOADED:n.loadTexture()),n):n}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,d=0,f=0,p=0;p0||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),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),void 0===this.metallic&&void 0===this.roughness||(this._defines.METALLICWORKFLOW=!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=this._defines.toString(),u=["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"],d=["albedoSampler","ambientSampler","opacitySampler","reflectionCubeSampler","reflection2DSampler","emissiveSampler","reflectivitySampler","bumpSampler","lightmapSampler","refractionCubeSampler","refraction2DSampler"];e.ColorCurves.PrepareUniforms(u),e.ColorGradingTexture.PrepareUniformsAndSamplers(u,d),e.MaterialHelper.PrepareUniformsAndSamplersList(u,d,this._defines,this.maxSimultaneousLights),this._effect=n.getEngine().createEffect("pbr",c,u,d,l,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)},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.setFloat3("vAmbientInfos",this.ambientTexture.coordinatesIndex,this.ambientTexture.level,this.ambientTextureStrength),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())),e.StandardMaterial.SpecularTextureEnabled&&(this.metallicTexture?(this._effect.setTexture("reflectivitySampler",this.metallicTexture),this._effect.setFloat2("vReflectivityInfos",this.metallicTexture.coordinatesIndex,this.metallicTexture.level),this._effect.setMatrix("reflectivityMatrix",this.metallicTexture.getTextureMatrix())):this.reflectivityTexture&&(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)}(this.reflectionTexture||this.refractionTexture)&&this._effect.setFloat2("vMicrosurfaceTextureLods",this._microsurfaceTextureLods.x,this._microsurfaceTextureLods.y),this.cameraColorGradingTexture&&e.StandardMaterial.ColorGradingTextureEnabled&&e.ColorGradingTexture.Bind(this.cameraColorGradingTexture,this._effect)}e.MaterialHelper.BindClipPlane(this._effect,this._myScene),this.pointsCloud&&this._effect.setFloat("pointSize",this.pointSize),this._myScene.ambientColor.multiplyToRef(this.ambientColor,this._globalAmbientColor),this._defines.METALLICWORKFLOW?(r._scaledReflectivity.r=void 0===this.metallic?1:this.metallic,r._scaledReflectivity.g=void 0===this.roughness?1:this.roughness,this._effect.setColor4("vReflectivityColor",r._scaledReflectivity,0)):(this.convertColorToLinearSpaceToRef(this.reflectivityColor,r._scaledReflectivity),this._effect.setColor4("vReflectivityColor",r._scaledReflectivity,this.microSurface)),this._effect.setVector3("vEyePosition",this._myScene._mirroredCameraPosition?this._myScene._mirroredCameraPosition:this._myScene.activeCamera.position),this._effect.setColor3("vAmbientColor",this._globalAmbientColor),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._effect.setColor3("vOverloadedAmbient",this.overloadedAmbient),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.metallicTexture&&this.metallicTexture.animations&&this.metallicTexture.animations.length>0?e.push(this.metallicTexture):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.metallicTexture&&this.metallicTexture.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})(e.Material);i._scaledAlbedo=new e.Color3,i._scaledReflectivity=new e.Color3,i._scaledEmissive=new e.Color3,i._scaledReflection=new e.Color3,__decorate([e.serialize()],i.prototype,"directIntensity",void 0),__decorate([e.serialize()],i.prototype,"emissiveIntensity",void 0),__decorate([e.serialize()],i.prototype,"environmentIntensity",void 0),__decorate([e.serialize()],i.prototype,"specularIntensity",void 0),__decorate([e.serialize()],i.prototype,"disableBumpMap",void 0),__decorate([e.serialize()],i.prototype,"overloadedShadowIntensity",void 0),__decorate([e.serialize()],i.prototype,"overloadedShadeIntensity",void 0),__decorate([e.serialize()],i.prototype,"cameraExposure",void 0),__decorate([e.serialize()],i.prototype,"cameraContrast",void 0),__decorate([e.serializeAsTexture()],i.prototype,"cameraColorGradingTexture",void 0),__decorate([e.serializeAsColorCurves()],i.prototype,"cameraColorCurves",void 0),__decorate([e.serializeAsColor3()],i.prototype,"overloadedAmbient",void 0),__decorate([e.serialize()],i.prototype,"overloadedAmbientIntensity",void 0),__decorate([e.serializeAsColor3()],i.prototype,"overloadedAlbedo",void 0),__decorate([e.serialize()],i.prototype,"overloadedAlbedoIntensity",void 0),__decorate([e.serializeAsColor3()],i.prototype,"overloadedReflectivity",void 0),__decorate([e.serialize()],i.prototype,"overloadedReflectivityIntensity",void 0),__decorate([e.serializeAsColor3()],i.prototype,"overloadedEmissive",void 0),__decorate([e.serialize()],i.prototype,"overloadedEmissiveIntensity",void 0),__decorate([e.serializeAsColor3()],i.prototype,"overloadedReflection",void 0),__decorate([e.serialize()],i.prototype,"overloadedReflectionIntensity",void 0),__decorate([e.serialize()],i.prototype,"overloadedMicroSurface",void 0),__decorate([e.serialize()],i.prototype,"overloadedMicroSurfaceIntensity",void 0),__decorate([e.serializeAsTexture()],i.prototype,"albedoTexture",void 0),__decorate([e.serializeAsTexture()],i.prototype,"ambientTexture",void 0),__decorate([e.serialize()],i.prototype,"ambientTextureStrength",void 0),__decorate([e.serializeAsTexture()],i.prototype,"opacityTexture",void 0),__decorate([e.serializeAsTexture()],i.prototype,"reflectionTexture",void 0),__decorate([e.serializeAsTexture()],i.prototype,"emissiveTexture",void 0),__decorate([e.serializeAsTexture()],i.prototype,"reflectivityTexture",void 0),__decorate([e.serializeAsTexture()],i.prototype,"metallicTexture",void 0),__decorate([e.serialize()],i.prototype,"metallic",void 0),__decorate([e.serialize()],i.prototype,"roughness",void 0),__decorate([e.serializeAsTexture()],i.prototype,"bumpTexture",void 0),__decorate([e.serializeAsTexture()],i.prototype,"lightmapTexture",void 0),__decorate([e.serializeAsTexture()],i.prototype,"refractionTexture",void 0),__decorate([e.serializeAsColor3("ambient")],i.prototype,"ambientColor",void 0),__decorate([e.serializeAsColor3("albedo")],i.prototype,"albedoColor",void 0),__decorate([e.serializeAsColor3("reflectivity")],i.prototype,"reflectivityColor",void 0),__decorate([e.serializeAsColor3("reflection")],i.prototype,"reflectionColor",void 0),__decorate([e.serializeAsColor3("emissive")],i.prototype,"emissiveColor",void 0),__decorate([e.serialize()],i.prototype,"microSurface",void 0),__decorate([e.serialize()],i.prototype,"indexOfRefraction",void 0),__decorate([e.serialize()],i.prototype,"invertRefractionY",void 0),__decorate([e.serializeAsFresnelParameters()],i.prototype,"opacityFresnelParameters",void 0),__decorate([e.serializeAsFresnelParameters()],i.prototype,"emissiveFresnelParameters",void 0),__decorate([e.serialize()],i.prototype,"linkRefractionWithTransparency",void 0),__decorate([e.serialize()],i.prototype,"linkEmissiveWithAlbedo",void 0),__decorate([e.serialize()],i.prototype,"useLightmapAsShadowmap",void 0),__decorate([e.serialize()],i.prototype,"useEmissiveAsIllumination",void 0),__decorate([e.serialize()],i.prototype,"useAlphaFromAlbedoTexture",void 0),__decorate([e.serialize()],i.prototype,"useSpecularOverAlpha",void 0),__decorate([e.serialize()],i.prototype,"useMicroSurfaceFromReflectivityMapAlpha",void 0),__decorate([e.serialize()],i.prototype,"useRoughnessFromMetallicTextureAlpha",void 0),__decorate([e.serialize()],i.prototype,"useRoughnessFromMetallicTextureGreen",void 0),__decorate([e.serialize()],i.prototype,"useAutoMicroSurfaceFromReflectivityMap",void 0),__decorate([e.serialize()],i.prototype,"useScalarInLinearSpace",void 0),__decorate([e.serialize()],i.prototype,"usePhysicalLightFalloff",void 0),__decorate([e.serialize()],i.prototype,"useRadianceOverAlpha",void 0),__decorate([e.serialize()],i.prototype,"useParallax",void 0),__decorate([e.serialize()],i.prototype,"useParallaxOcclusion",void 0),__decorate([e.serialize()],i.prototype,"parallaxScaleBias",void 0),__decorate([e.serialize()],i.prototype,"disableLighting",void 0),__decorate([e.serialize()],i.prototype,"maxSimultaneousLights",void 0),__decorate([e.serialize()],i.prototype,"invertNormalMapX",void 0),__decorate([e.serialize()],i.prototype,"invertNormalMapY",void 0),__decorate([e.serialize()],i.prototype,"useLogarithmicDepth",null),e.PBRMaterial=i})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(e){this._scene=e}return t.prototype._createInspector=function(e){this._inspector||(this._inspector=new INSPECTOR.Inspector(this._scene,e))},t.prototype.isVisible=function(){return!1},t.prototype.hide=function(){this._inspector&&(this._inspector.dispose(),this._inspector=null)},t.prototype.show=function(i){"undefined"==typeof INSPECTOR?e.Tools.LoadScript(t.InspectorURL,this._createInspector.bind(this,i)):this._createInspector(i)},t})();t.InspectorURL="http://www.babylonjs.com/babylon.inspector.bundle.js",e.DebugLayer=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,o,s){void 0===o&&(o=null);var a=t.call(this,r.getEngine(),i)||this;return a.downSampleX4PostProcess=null,a.brightPassPostProcess=null,a.gaussianBlurHPostProcesses=[],a.gaussianBlurVPostProcesses=[],a.textureAdderPostProcess=null,a.textureAdderFinalPostProcess=null,a.lensFlarePostProcess=null,a.lensFlareComposePostProcess=null,a.depthOfFieldPostProcess=null,a.brightThreshold=1,a.blurWidth=2,a.gaussianCoefficient=.25,a.gaussianMean=1,a.gaussianStandardDeviation=1,a.exposure=1,a.lensTexture=null,a.lensColorTexture=null,a.lensFlareStrength=20,a.lensFlareGhostDispersal=1.4,a.lensFlareHaloWidth=.7,a.lensFlareDistortionStrength=16,a.lensStarTexture=null,a.lensFlareDirtTexture=null,a.depthOfFieldDistance=10,a.animations=[],a._depthRenderer=null,a._depthOfFieldEnabled=!0,a._lensFlareEnabled=!0,a._scene=r,o?a.originalPostProcess=o:a.originalPostProcess=new e.PostProcess("HDRPass","standard",[],[],n,null,e.Texture.BILINEAR_SAMPLINGMODE,r.getEngine(),(!0),"#define PASS_POST_PROCESS",e.Engine.TEXTURETYPE_FLOAT),a.addEffect(new e.PostProcessRenderEffect(r.getEngine(),"HDRPassPostProcess",function(){return a.originalPostProcess},(!0))),a._createDownSampleX4PostProcess(r,n/2),a._createBrightPassPostProcess(r,n/2),a._createGaussianBlurPostProcesses(r,n/2,0),a._createGaussianBlurPostProcesses(r,n/4,1),a._createGaussianBlurPostProcesses(r,n/8,2),a._createGaussianBlurPostProcesses(r,n/16,3),a._createTextureAdderPostProcess(r,n),a.textureAdderFinalPostProcess=new e.PostProcess("HDRDepthOfFieldSource","standard",[],[],n,null,e.Texture.BILINEAR_SAMPLINGMODE,r.getEngine(),(!0),"#define PASS_POST_PROCESS",e.Engine.TEXTURETYPE_UNSIGNED_INT),a.addEffect(new e.PostProcessRenderEffect(r.getEngine(),"HDRDepthOfFieldSource",function(){return a.textureAdderFinalPostProcess},(!0))),a._createLensFlarePostProcess(r,n),a._createGaussianBlurPostProcesses(r,n/2,5),a._createDepthOfFieldPostProcess(r,n),r.postProcessRenderPipelineManager.addPipeline(a),null!==s&&r.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(i,s),a.LensFlareEnabled=!1,a.DepthOfFieldEnabled=!1,a}return __extends(i,t),Object.defineProperty(i.prototype,"DepthOfFieldEnabled",{get:function(){return this._depthOfFieldEnabled},set:function(e){var t=this.gaussianBlurHPostProcesses.length-1;e&&!this._depthOfFieldEnabled?(this._scene.postProcessRenderPipelineManager.enableEffectInPipeline(this._name,"HDRGaussianBlurH"+t,this._scene.cameras),this._scene.postProcessRenderPipelineManager.enableEffectInPipeline(this._name,"HDRGaussianBlurV"+t,this._scene.cameras),this._scene.postProcessRenderPipelineManager.enableEffectInPipeline(this._name,"HDRDepthOfField",this._scene.cameras),this._depthRenderer=this._scene.enableDepthRenderer()):!e&&this._depthOfFieldEnabled&&(this._scene.postProcessRenderPipelineManager.disableEffectInPipeline(this._name,"HDRGaussianBlurH"+t,this._scene.cameras),this._scene.postProcessRenderPipelineManager.disableEffectInPipeline(this._name,"HDRGaussianBlurV"+t,this._scene.cameras),this._scene.postProcessRenderPipelineManager.disableEffectInPipeline(this._name,"HDRDepthOfField",this._scene.cameras)),this._depthOfFieldEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"LensFlareEnabled",{get:function(){return this._lensFlareEnabled},set:function(e){var t=this.gaussianBlurHPostProcesses.length-2;e&&!this._lensFlareEnabled?(this._scene.postProcessRenderPipelineManager.enableEffectInPipeline(this._name,"HDRLensFlare",this._scene.cameras),this._scene.postProcessRenderPipelineManager.enableEffectInPipeline(this._name,"HDRLensFlareShift",this._scene.cameras),this._scene.postProcessRenderPipelineManager.enableEffectInPipeline(this._name,"HDRGaussianBlurH"+t,this._scene.cameras),this._scene.postProcessRenderPipelineManager.enableEffectInPipeline(this._name,"HDRGaussianBlurV"+t,this._scene.cameras),this._scene.postProcessRenderPipelineManager.enableEffectInPipeline(this._name,"HDRLensFlareCompose",this._scene.cameras)):!e&&this._lensFlareEnabled&&(this._scene.postProcessRenderPipelineManager.disableEffectInPipeline(this._name,"HDRLensFlare",this._scene.cameras),this._scene.postProcessRenderPipelineManager.disableEffectInPipeline(this._name,"HDRLensFlareShift",this._scene.cameras),this._scene.postProcessRenderPipelineManager.disableEffectInPipeline(this._name,"HDRGaussianBlurH"+t,this._scene.cameras),this._scene.postProcessRenderPipelineManager.disableEffectInPipeline(this._name,"HDRGaussianBlurV"+t,this._scene.cameras),this._scene.postProcessRenderPipelineManager.disableEffectInPipeline(this._name,"HDRLensFlareCompose",this._scene.cameras)),this._lensFlareEnabled=e},enumerable:!0,configurable:!0}),i.prototype._createDownSampleX4PostProcess=function(t,i){var r=this,n=new Array(32);this.downSampleX4PostProcess=new e.PostProcess("HDRDownSampleX4","standard",["dsOffsets"],[],i,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),(!1),"#define DOWN_SAMPLE_X4",e.Engine.TEXTURETYPE_UNSIGNED_INT),this.downSampleX4PostProcess.onApply=function(e){for(var t=0,i=-2;i<2;i++)for(var o=-2;o<2;o++)n[t]=(i+.5)*(1/r.downSampleX4PostProcess.width),n[t+1]=(o+.5)*(1/r.downSampleX4PostProcess.height),t+=2;e.setArray2("dsOffsets",n)},this.addEffect(new e.PostProcessRenderEffect(t.getEngine(),"HDRDownSampleX4",function(){return r.downSampleX4PostProcess},(!0)))},i.prototype._createBrightPassPostProcess=function(t,i){var r=this,n=new Array(8);this.brightPassPostProcess=new e.PostProcess("HDRBrightPass","standard",["dsOffsets","brightThreshold"],[],i,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),(!1),"#define BRIGHT_PASS",e.Engine.TEXTURETYPE_UNSIGNED_INT),this.brightPassPostProcess.onApply=function(e){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.addEffect(new e.PostProcessRenderEffect(t.getEngine(),"HDRBrightPass",function(){return r.brightPassPostProcess},(!0)))},i.prototype._createGaussianBlurPostProcesses=function(t,i,r){var n=this,o=new Array(9),s=new Array(9),a=["blurOffsets","blurWeights","blurWidth"],h=function(e){return function(i){for(var r=0,a=0;a<9;a++)r=(a-4)/4,s[a]=n.gaussianCoefficient*(1/Math.sqrt(2*Math.PI*n.gaussianStandardDeviation))*Math.exp(-((r-n.gaussianMean)*(r-n.gaussianMean))/(2*n.gaussianStandardDeviation*n.gaussianStandardDeviation));for(var h={width:t.getEngine().getRenderWidth(),height:t.getEngine().getRenderHeight()},a=0;a<9;a++){var c=(a-4)*(1/(e===!0?h.height:h.width));o[a]=c}i.setArray("blurOffsets",o),i.setArray("blurWeights",s),i.setFloat("blurWidth",n.blurWidth)}},c=new e.PostProcess("HDRGaussianBlurH"+i,"standard",a,[],i,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),(!1),"#define GAUSSIAN_BLUR_H",e.Engine.TEXTURETYPE_UNSIGNED_INT);c.onApply=h(!1);var l=new e.PostProcess("HDRGaussianBlurV"+i,"standard",a,[],i,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),(!1),"#define GAUSSIAN_BLUR_V",e.Engine.TEXTURETYPE_UNSIGNED_INT);l.onApply=h(!0),this.addEffect(new e.PostProcessRenderEffect(t.getEngine(),"HDRGaussianBlurH"+r,function(){return c},(!0))),this.addEffect(new e.PostProcessRenderEffect(t.getEngine(),"HDRGaussianBlurV"+r,function(){return l},(!0))),this.gaussianBlurHPostProcesses.push(c),this.gaussianBlurVPostProcesses.push(l)},i.prototype._createTextureAdderPostProcess=function(t,i){var r=this;this.gaussianBlurVPostProcesses[3];this.textureAdderPostProcess=new e.PostProcess("HDRTextureAdder","standard",["exposure"],["otherSampler","lensSampler"],i,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),(!1),"#define TEXTURE_ADDER",e.Engine.TEXTURETYPE_UNSIGNED_INT),this.textureAdderPostProcess.onApply=function(e){e.setTextureFromPostProcess("otherSampler",r.originalPostProcess),e.setTexture("lensSampler",r.lensTexture),e.setFloat("exposure",r.exposure)},this.addEffect(new e.PostProcessRenderEffect(t.getEngine(),"HDRTextureAdder",function(){return r.textureAdderPostProcess},(!0)))},i.prototype._createLensFlarePostProcess=function(t,i){var r=this;this.lensFlarePostProcess=new e.PostProcess("HDRLensFlare","standard",["strength","ghostDispersal","haloWidth","resolution","distortionStrength"],["lensColorSampler"],i/2,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),(!0),"#define LENS_FLARE",e.Engine.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new e.PostProcessRenderEffect(t.getEngine(),"HDRLensFlare",function(){return r.lensFlarePostProcess},(!1))),this._createGaussianBlurPostProcesses(t,i/4,4),this.lensFlareComposePostProcess=new e.PostProcess("HDRLensFlareCompose","standard",["lensStarMatrix"],["otherSampler","lensDirtSampler","lensStarSampler"],i,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),(!1),"#define LENS_FLARE_COMPOSE",e.Engine.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new e.PostProcessRenderEffect(t.getEngine(),"HDRLensFlareCompose",function(){return r.lensFlareComposePostProcess},(!1)));var n=new e.Vector2(0,0);this.lensFlarePostProcess.onApply=function(e){e.setTextureFromPostProcess("textureSampler",r.gaussianBlurHPostProcesses[0]),e.setTexture("lensColorSampler",r.lensColorTexture), -e.setFloat("strength",r.lensFlareStrength),e.setFloat("ghostDispersal",r.lensFlareGhostDispersal),e.setFloat("haloWidth",r.lensFlareHaloWidth),n.x=r.lensFlarePostProcess.width,n.y=r.lensFlarePostProcess.height,e.setVector2("resolution",n),e.setFloat("distortionStrength",r.lensFlareDistortionStrength)};var o=e.Matrix.FromValues(2,0,-1,0,0,2,-1,0,0,0,1,0,0,0,0,1),s=e.Matrix.FromValues(.5,0,.5,0,0,.5,.5,0,0,0,1,0,0,0,0,1);this.lensFlareComposePostProcess.onApply=function(t){t.setTextureFromPostProcess("otherSampler",r.textureAdderFinalPostProcess),t.setTexture("lensDirtSampler",r.lensFlareDirtTexture),t.setTexture("lensStarSampler",r.lensStarTexture);var i=r._scene.activeCamera.getViewMatrix().getRow(0),n=r._scene.activeCamera.getViewMatrix().getRow(2),a=e.Vector3.Dot(i.toVector3(),new e.Vector3(1,0,0))+e.Vector3.Dot(n.toVector3(),new e.Vector3(0,0,1));a*=4;var h=e.Matrix.FromValues(.5*Math.cos(a),-Math.sin(a),0,0,Math.sin(a),.5*Math.cos(a),0,0,0,0,1,0,0,0,0,1),c=s.multiply(h).multiply(o);t.setMatrix("lensStarMatrix",c)}},i.prototype._createDepthOfFieldPostProcess=function(t,i){var r=this;this.depthOfFieldPostProcess=new e.PostProcess("HDRDepthOfField","standard",["distance"],["otherSampler","depthSampler"],i,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),(!1),"#define DEPTH_OF_FIELD",e.Engine.TEXTURETYPE_UNSIGNED_INT),this.depthOfFieldPostProcess.onApply=function(e){e.setTextureFromPostProcess("otherSampler",r.textureAdderFinalPostProcess),e.setTexture("depthSampler",r._depthRenderer.getDepthMap()),e.setFloat("distance",r.depthOfFieldDistance)},this.addEffect(new e.PostProcessRenderEffect(t.getEngine(),"HDRDepthOfField",function(){return r.depthOfFieldPostProcess},(!0)))},i.prototype.dispose=function(){for(var e=0;e0.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\n\n#include[0..maxSimultaneousLights]\n#include\n#include\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\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\n#ifdef REFLECTIONFRESNEL\nuniform vec4 reflectionLeftColor;\nuniform vec4 reflectionRightColor;\n#endif\n#endif\n#ifdef CAMERACOLORGRADING\n#include \n#include\n#endif\n#ifdef CAMERACOLORCURVES\n#include\n#include\n#endif\n#include\n#include\n#include\n#include\nvoid main(void) {\n#include\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#include\n#ifdef DIFFUSE\nbaseColor=texture2D(diffuseSampler,vDiffuseUV+uvOffset);\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+uvOffset).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+uvOffset);\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#ifdef LIGHTMAP\nvec3 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset).rgb*vLightmapInfos.y;\n#endif\n#include[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+uvOffset);\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+uvOffset).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\n#ifdef LIGHTMAP\n#ifndef LIGHTMAPEXCLUDED\n#ifdef USELIGHTMAPASSHADOWMAP\ncolor.rgb*=lightmapColor;\n#else\ncolor.rgb+=lightmapColor;\n#endif\n#endif\n#endif\n#include\n#include\n#ifdef CAMERACOLORGRADING\ncolor=colorGrades(color);\n#endif\n#ifdef CAMERACOLORCURVES\ncolor.rgb=applyColorCurves(color.rgb);\n#endif\ngl_FragColor=color;\n}",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\n\n#include\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\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include\n#include\n#include[0..maxSimultaneousLights]\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#endif\n#ifdef REFLECTIONMAP_EQUIRECTANGULAR_FIXED\nvarying vec3 vDirectionW;\n#endif\n#include\nvoid main(void) {\n#ifdef REFLECTIONMAP_SKYBOX\nvPositionUVW=position;\n#endif \n#include\n#include\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\n#include\n#include[0..maxSimultaneousLights]\n#ifdef VERTEXCOLOR\n\nvColor=color;\n#endif\n#include\n#include\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\n\n#include\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\n#include\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}",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 ((lumaBlumaMax)) {\ngl_FragColor=rgbA;\n}\nelse {\ngl_FragColor=rgbB;\n}\n}",glowBlurPostProcessPixelShader:"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n\nuniform vec2 screenSize;\nuniform vec2 direction;\nuniform float blurWidth;\n\nfloat getLuminance(vec3 color)\n{\nreturn dot(color,vec3(0.2126,0.7152,0.0722));\n}\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{\n\nvec4 texel=texture2D(textureSampler,start+texelOffset);\nbaseColor.a+=texel.a*weights[i];\n\nfloat luminance=getLuminance(baseColor.rgb);\nfloat luminanceTexel=getLuminance(texel.rgb);\nfloat choice=step(luminanceTexel,luminance);\nbaseColor.rgb=choice*baseColor.rgb+(1.0-choice)*texel.rgb;\ntexelOffset+=texelStep;\n}\ngl_FragColor=baseColor;\n}",glowMapGenerationPixelShader:"#ifdef ALPHATEST\nvarying vec2 vUVDiffuse;\nuniform sampler2D diffuseSampler;\n#endif\n#ifdef EMISSIVE\nvarying vec2 vUVEmissive;\nuniform sampler2D emissiveSampler;\n#endif\nuniform vec4 color;\nvoid main(void)\n{\n#ifdef ALPHATEST\nif (texture2D(diffuseSampler,vUVDiffuse).a<0.4)\ndiscard;\n#endif\n#ifdef EMISSIVE\ngl_FragColor=texture2D(emissiveSampler,vUVEmissive);\n#else\ngl_FragColor=color;\n#endif\n}",glowMapGenerationVertexShader:"\nattribute vec3 position;\n#include\n\n#include\nuniform mat4 viewProjection;\nvarying vec4 vPosition;\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef ALPHATEST\nvarying vec2 vUVDiffuse;\nuniform mat4 diffuseMatrix;\n#endif\n#ifdef EMISSIVE\nvarying vec2 vUVEmissive;\nuniform mat4 emissiveMatrix;\n#endif\nvoid main(void)\n{\n#include\n#include\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 DIFFUSEUV1\nvUVDiffuse=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n#endif\n#ifdef DIFFUSEUV2\nvUVDiffuse=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n#ifdef EMISSIVE\n#ifdef EMISSIVEUV1\nvUVEmissive=vec2(emissiveMatrix*vec4(uv,1.0,0.0));\n#endif\n#ifdef EMISSIVEUV2\nvUVEmissive=vec2(emissiveMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n}",glowMapMergePixelShader:"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n\nuniform float offset;\nvoid main(void) {\nvec4 baseColor=texture2D(textureSampler,vUV);\nbaseColor.a=abs(offset-baseColor.a);\ngl_FragColor=baseColor;\n}",glowMapMergeVertexShader:"\nattribute vec2 position;\n\nvarying vec2 vUV;\nconst vec2 madd=vec2(0.5,0.5);\nvoid main(void) {\nvUV=position*madd+madd;\ngl_Position=vec4(position,0.0,1.0);\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 (luminance1.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}",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\n\nuniform float offset;\n#include\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\n#include\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[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 vec3 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) || defined(METALLICWORKFLOW) \nvarying vec2 vReflectivityUV;\nuniform vec2 vReflectivityInfos;\nuniform sampler2D reflectivitySampler;\n#endif\n\n#include\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\n#endif\n#ifdef CAMERACOLORGRADING\n#include\n#endif\n#ifdef CAMERACOLORCURVES\n#include\n#endif\n\n#include\n#include\n#ifdef CAMERACOLORGRADING\n#include\n#endif\n#ifdef CAMERACOLORCURVES\n#include\n#endif\n#include\n#include\n#include\n#include\n#include\n#include\n\n#include\nvoid main(void) {\n#include\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\n#include\n\nvec4 surfaceAlbedo=vec4(1.,1.,1.,1.);\nvec3 surfaceAlbedoContribution=vAlbedoColor.rgb;\n\nfloat alpha=vAlbedoColor.a;\n#ifdef ALBEDO\nsurfaceAlbedo=texture2D(albedoSampler,vAlbedoUV+uvOffset);\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\nvec3 ambientColor=vec3(1.,1.,1.);\n#ifdef AMBIENT\nambientColor=texture2D(ambientSampler,vAmbientUV+uvOffset).rgb*vAmbientInfos.y;\nambientColor=vec3(1.,1.,1.)-((vec3(1.,1.,1.)-ambientColor)*vAmbientInfos.z);\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+uvOffset);\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 METALLICWORKFLOW\nvec2 metallicRoughness=surfaceReflectivityColor.rg;\n#ifdef METALLICROUGHNESSMAP\nvec4 surfaceMetallicColorMap=texture2D(reflectivitySampler,vReflectivityUV+uvOffset);\n\nmetallicRoughness.r*=surfaceMetallicColorMap.r;\n#ifdef METALLICROUGHNESSGSTOREINALPHA\nmetallicRoughness.g*=surfaceMetallicColorMap.a;\n#else\n#ifdef METALLICROUGHNESSGSTOREINGREEN\nmetallicRoughness.g*=surfaceMetallicColorMap.g;\n#endif\n#endif\n#endif\n\nvec3 baseColor=surfaceAlbedo.rgb;\n\nsurfaceAlbedo.rgb*=(1.0-metallicRoughness.r);\n\n\nconst vec3 DefaultSpecularReflectanceDielectric=vec3(0.04,0.04,0.04);\n\nsurfaceReflectivityColor=mix(DefaultSpecularReflectanceDielectric,baseColor,metallicRoughness.r);\n#ifdef OVERLOADEDVALUES\nsurfaceReflectivityColor=mix(surfaceReflectivityColor,vOverloadedReflectivity,vOverloadedIntensity.z);\n#endif\nmicroSurface=1.0-metallicRoughness.g;\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.; \n#ifdef LIGHTMAP\nvec3 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset).rgb*vLightmapInfos.y;\n#endif\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[0..maxSimultaneousLights]\n#ifdef SPECULARTERM\nlightSpecularContribution*=vLightingIntensity.w;\n#endif\n#ifdef OPACITY\nvec4 opacityMap=texture2D(opacitySampler,vOpacityUV+uvOffset);\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+uvOffset).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\n#ifndef LIGHTMAPEXCLUDED\n#ifdef USELIGHTMAPASSHADOWMAP\nfinalColor.rgb*=lightmapColor;\n#else\nfinalColor.rgb+=lightmapColor;\n#endif\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\n#include(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\n\n#include\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 vec3 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) || defined(METALLICWORKFLOW) \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\n#include\n#include[0..maxSimultaneousLights]\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#endif\n#ifdef REFLECTIONMAP_EQUIRECTANGULAR_FIXED\nvarying vec3 vDirectionW;\n#endif\n#include\nvoid main(void) {\n#ifdef REFLECTIONMAP_SKYBOX\nvPositionUVW=position;\n#endif \n#include\n#include\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) || defined(METALLICWORKFLOW) \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\n\n#include\n\n#include[0..maxSimultaneousLights]\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n\n#include\n}", -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}",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:"#ifndef FULLFLOAT\nvec4 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}\n#endif\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;\n#ifndef FULLFLOAT\ngl_FragColor=vec4(packHalf(moment1),packHalf(moment2));\n#else\ngl_FragColor=vec4(moment1,moment2,1.0,1.0);\n#endif\n#else\n#ifndef FULLFLOAT\ngl_FragColor=pack(depth);\n#else\ngl_FragColor=vec4(depth,1.0,1.0,1.0);\n#endif\n#endif\n}",shadowMapVertexShader:"\nattribute vec3 position;\n#include\n\n#include\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\n#include\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}",spritesPixelShader:"uniform bool alphaTest;\nvarying vec4 vColor;\n\nvarying vec2 vUV;\nuniform sampler2D diffuseSampler;\n\n#include\nvoid main(void) {\nvec4 color=texture2D(diffuseSampler,vUV);\nif (alphaTest) \n{\nif (color.a<0.95)\ndiscard;\n}\ncolor*=vColor;\n#include\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\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; i0.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}",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; i1.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:"vec2 uvOffset=vec2(0.0,0.0);\n#if defined(BUMP) || defined(PARALLAX)\nmat3 TBN=cotangent_frame(normalW*vBumpInfos.y,-viewDirectionW,vBumpUV);\n#endif\n#ifdef PARALLAX\nmat3 invTBN=transposeMat3(TBN);\n#ifdef PARALLAXOCCLUSION\nuvOffset=parallaxOcclusion(invTBN*-viewDirectionW,invTBN*normalW,vBumpUV,vBumpInfos.z);\n#else\nuvOffset=parallaxOffset(invTBN*viewDirectionW,vBumpInfos.z);\n#endif\n#endif\n#ifdef BUMP\nnormalW=perturbNormal(viewDirectionW,TBN,vBumpUV+uvOffset);\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; icurrRayHeight)\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#if defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X}) && defined(LIGHTMAPNOSPECULAR{X})\n\n#else\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#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\n#if defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X})\ndiffuseBase+=lightmapColor*shadow;\n#ifdef SPECULARTERM\n#ifndef LIGHTMAPNOSPECULAR{X}\nspecularBase+=info.specular*shadow*lightmapColor;\n#endif\n#endif\n#else\ndiffuseBase+=info.diffuse*shadow;\n#ifdef SPECULARTERM\nspecularBase+=info.specular*shadow;\n#endif\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", -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#if defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X}) && defined(LIGHTMAPNOSPECULAR{X})\n\n#else\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#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\n#if defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X})\nlightDiffuseContribution+=lightmapColor*notShadowLevel;\n#ifdef SPECULARTERM\n#ifndef LIGHTMAPNOSPECULAR{X}\nlightSpecularContribution+=info.specular*notShadowLevel*lightmapColor;\n#endif\n#endif\n#else\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\n#endif",pbrShadowFunctions:"\n#ifdef SHADOWS\n#ifndef SHADOWFULLFLOAT\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}\n#endif\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;\n#ifndef SHADOWFULLFLOAT\nfloat shadow=unpack(textureCube(shadowSampler,directionToLight))+bias;\n#else\nfloat shadow=textureCube(shadowSampler,directionToLight).x+bias;\n#endif\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;\n#ifndef SHADOWFULLFLOAT\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[0]*mapSize))1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\n#ifndef SHADOWFULLFLOAT\nfloat shadow=unpack(texture2D(shadowSampler,uv))+bias;\n#else\nfloat shadow=texture2D(shadowSampler,uv).x+bias;\n#endif\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;\n#ifndef SHADOWFULLFLOAT\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[0]*mapSize))1.0 || uv.y<0. || uv.y>1.0 || depth.z>=1.0)\n{\nreturn 1.0;\n}\nvec4 texel=texture2D(shadowSampler,uv);\n#ifndef SHADOWFULLFLOAT\nvec2 moments=vec2(unpackHalf(texel.xy),unpackHalf(texel.zw));\n#else\nvec2 moments=texel.xy;\n#endif\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\n#ifndef SHADOWFULLFLOAT\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}\n#endif\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;\n#ifndef SHADOWFULLFLOAT\nfloat shadow=unpack(textureCube(shadowSampler,directionToLight))+bias;\n#else\nfloat shadow=textureCube(shadowSampler,directionToLight).x+bias;\n#endif\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;\n#ifndef SHADOWFULLFLOAT\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[0]*mapSize))1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\n#ifndef SHADOWFULLFLOAT\nfloat shadow=unpack(texture2D(shadowSampler,uv))+bias;\n#else\nfloat shadow=texture2D(shadowSampler,uv).x+bias;\n#endif\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;\n#ifndef SHADOWFULLFLOAT\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[0]*mapSize))1.0 || uv.y<0. || uv.y>1.0 || depth.z>=1.0)\n{\nreturn 1.0;\n}\nvec4 texel=texture2D(shadowSampler,uv);\n#ifndef SHADOWFULLFLOAT\nvec2 moments=vec2(unpackHalf(texel.xy),unpackHalf(texel.zw));\n#else\nvec2 moments=texel.xy;\n#endif\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"},("undefined"!=typeof window&&window.module||"undefined"!=typeof module)&&"undefined"!=typeof module.exports&&(module.exports=BABYLON); \ No newline at end of file +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){e!==-1?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=t.indexOf(".babylon")!==-1?"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=t.indexOf(".babylon")!==-1?"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&&(o.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})();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 e.indexOf("http:/")===-1?t.parseURL(window.location.href)+e:e},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++],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,d=(15&o.flags,o.pixel_size>>3),f=o.width*o.height*d;if(a&&(u=r.subarray(n,n+=o.colormap_length*(o.colormap_size>>3))),s){l=new Uint8Array(f);for(var p,_,m,g=0,v=new Uint8Array(d);n>t._ORIGIN_SHIFT){default:case t._ORIGIN_UL:y=0,b=1,T=o.width,x=0,A=1,E=o.height;break;case t._ORIGIN_BL:y=0,b=1,T=o.width,x=o.height-1,A=-1,E=-1;break;case t._ORIGIN_UR:y=o.width-1,b=-1,T=-1,x=0,A=1,E=o.height;break;case t._ORIGIN_BR:y=o.width-1,b=-1,T=-1,x=o.height-1,A=-1,E=-1}var P="_getImageData"+(c?"Grey":"")+o.pixel_size+"bits",M=t[P](o,u,l,x,A,E,y,b,T);i.texImage2D(i.TEXTURE_2D,0,i.RGBA,o.width,o.height,0,i.RGBA,i.UNSIGNED_BYTE,M)},t._getImageData8bits=function(e,t,i,r,n,o,s,a,h){var c,l,u,d=i,f=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=d[m],g[4*(l+p*u)+3]=255,g[4*(l+p*u)+2]=f[3*c+0],g[4*(l+p*u)+1]=f[3*c+1],g[4*(l+p*u)+0]=f[3*c+2];return g},t._getImageData16bits=function(e,t,i,r,n,o,s,a,h){var c,l,u,d=i,f=e.width,p=e.height,_=0,m=new Uint8Array(f*p*4);for(u=r;u!==o;u+=n)for(l=s;l!==h;l+=a,_+=2)c=d[_+0]+(d[_+1]<<8),m[4*(l+f*u)+0]=(31744&c)>>7,m[4*(l+f*u)+1]=(992&c)>>2,m[4*(l+f*u)+2]=(31&c)>>3,m[4*(l+f*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,d=e.width,f=e.height,p=0,_=new Uint8Array(d*f*4);for(l=r;l!==o;l+=n)for(c=s;c!==h;c+=a,p+=3)_[4*(c+d*l)+3]=255,_[4*(c+d*l)+2]=u[p+0],_[4*(c+d*l)+1]=u[p+1],_[4*(c+d*l)+0]=u[p+2];return _},t._getImageData32bits=function(e,t,i,r,n,o,s,a,h){var c,l,u=i,d=e.width,f=e.height,p=0,_=new Uint8Array(d*f*4);for(l=r;l!==o;l+=n)for(c=s;c!==h;c+=a,p+=4)_[4*(c+d*l)+2]=u[p+0],_[4*(c+d*l)+1]=u[p+1],_[4*(c+d*l)+0]=u[p+2],_[4*(c+d*l)+3]=u[p+3];return _},t._getImageDataGrey8bits=function(e,t,i,r,n,o,s,a,h){var c,l,u,d=i,f=e.width,p=e.height,_=0,m=new Uint8Array(f*p*4);for(u=r;u!==o;u+=n)for(l=s;l!==h;l+=a,_++)c=d[_],m[4*(l+f*u)+0]=c,m[4*(l+f*u)+1]=c,m[4*(l+f*u)+2]=c,m[4*(l+f*u)+3]=255;return m},t._getImageDataGrey16bits=function(e,t,i,r,n,o,s,a,h){var c,l,u=i,d=e.width,f=e.height,p=0,_=new Uint8Array(d*f*4);for(l=r;l!==o;l+=n)for(c=s;c!==h;c+=a,p+=2)_[4*(c+d*l)+0]=u[p+0],_[4*(c+d*l)+1]=u[p+0],_[4*(c+d*l)+2]=u[p+0],_[4*(c+d*l)+3]=u[p+1];return _},t})();i._TYPE_NO_DATA=0,i._TYPE_INDEXED=1,i._TYPE_RGB=2,i._TYPE_GREY=3,i._TYPE_RLE_INDEXED=9,i._TYPE_RLE_RGB=10,i._TYPE_RLE_GREY=11,i._ORIGIN_MASK=48,i._ORIGIN_SHIFT=4,i._ORIGIN_BL=0,i._ORIGIN_BR=1,i._ORIGIN_UL=2,i._ORIGIN_UR=3,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)&&(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;tthis.data.length&&(this.data.length=2*(this.length+e.length));for(var t=0;t=this.length?-1:t},e})();t._GlobalId=0,e.SmartArray=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(){this._count=0,this._data={}}return e.prototype.copyFrom=function(e){var t=this;this.clear(),e.forEach((function(e,i){return t.add(e,i)}))},e.prototype.get=function(e){var t=this._data[e];if(void 0!==t)return t},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]&&(this._data[e]=t,++this._count,!0)},e.prototype.set=function(e,t){return void 0!==this._data[e]&&(this._data[e]=t,!0)},e.prototype.getAndRemove=function(e){var t=this.get(e);return void 0!==t?(delete this._data[e],--this._count,t):null},e.prototype.remove=function(e){return!!this.contains(e)&&(delete this._data[e],--this._count,!0)},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,t){return function(i){i.__bjsclassName__=e,i.__bjsmoduleName__=null!=t?t:null}}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;rt&&(i=t),i},t.GetFilename=function(e){var t=e.lastIndexOf("/");return t<0?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>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;h=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){if(t===!0||void 0!==e&&null!=e)return Array.isArray(e)?e:[e]},t.GetPointerPrefix=function(){var e="pointer";return window.PointerEvent||navigator.pointerEnabled||(e="mouse"),e},t.QueueNewFrame=function(e,t){void 0===t&&(t=window),t.requestAnimationFrame?t.requestAnimationFrame(e):t.msRequestAnimationFrame?t.msRequestAnimationFrame(e):t.webkitRequestAnimationFrame?t.webkitRequestAnimationFrame(e):t.mozRequestAnimationFrame?t.mozRequestAnimationFrame(e):t.oRequestAnimationFrame?t.oRequestAnimationFrame(e):window.setTimeout(e,16)},t.RequestFullscreen=function(e){var t=e.requestFullscreen||e.msRequestFullscreen||e.webkitRequestFullscreen||e.mozRequestFullScreen;t&&t.call(e)},t.ExitFullscreen=function(){document.exitFullscreen?document.exitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitCancelFullScreen?document.webkitCancelFullScreen():document.msCancelFullScreen&&document.msCancelFullScreen()},t.SetCorsBehavior=function(e,i){if(t.CorsBehavior)switch(typeof t.CorsBehavior){case"function":var r=t.CorsBehavior(e);if(r)return r;break;case"string":default:i.crossOrigin=t.CorsBehavior}},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;"data:"!==i.substr(0,5)&&t.SetCorsBehavior(i,s),s.onload=function(){r(s)},s.onerror=function(e){t.Error("Error while trying to load image: "+i),t.UseFallbackTexture?(s.src=t.fallbackTexture,r(s)):n()};var a=function(){s.src=i},h=function(){o.loadImageFromDB(i,s)};if("data:"!==i.substr(0,5)&&o&&o.enableTexturesOffline&&e.Database.IsUASupportingBlobStorage)o.openAsync(h,a);else if(i.indexOf("file:")===-1)a();else{var c=i.substring(5).toLowerCase();if(e.FilesInput.FilesTextures[c])try{var l;try{l=URL.createObjectURL(e.FilesInput.FilesTextures[c],{oneTimeOnly:!0})}catch(u){l=URL.createObjectURL(e.FilesInput.FilesTextures[c])}s.src=l}catch(d){s.src=null}else t.Error("Image: "+c+" not found. Did you forget to provide it?"),s.src=t.fallbackTexture}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(e.onreadystatechange=null,e.status>=200&&e.status<300||navigator.isCocoonJS&&0===e.status)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(i.indexOf("file:")!==-1){var l=i.substring(5).toLowerCase();e.FilesInput.FilesToLoad[l]?t.ReadFile(e.FilesInput.FilesToLoad[l],r,n,s):t.Error("File: "+l+" not found. Did you forget to provide it?")}else o&&o.enableSceneOffline?o.openAsync(c,h):h()},t.LoadScript=function(e,t,i){var r=document.getElementsByTagName("head")[0],n=document.createElement("script");n.type="text/javascript",n.src=e;n.onload=function(){t&&t()},n.onerror=function(){i&&i()},r.appendChild(n)},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.xi.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&&n.indexOf(o)!==-1)&&(!i||i.indexOf(o)===-1)){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;hh&&(d=h,u=d*l);var f=Math.max(0,a-u)/2,p=Math.max(0,h-d)/2;c.fillStyle=r.getScene().clearColor.toHexString(),c.fillRect(0,0,a,h),c.drawImage(e.getRenderingCanvas(),f,p,u,d),t.EncodeScreenshotCanvasData(o,s)},t.CreateScreenshotUsingRenderTarget=function(i,r,n,o,s){void 0===s&&(s="image/png");var a,h;if(n.precision)a=Math.round(i.getRenderWidth()*n.precision),h=Math.round(a/i.getAspectRatio(r)),n={width:a,height:h};else if(n.width&&n.height)a=n.width,h=n.height;else if(n.width&&!n.height)a=n.width,h=Math.round(a/i.getAspectRatio(r)),n={width:a,height:h};else if(n.height&&!n.width)h=n.height,a=Math.round(h*i.getAspectRatio(r)),n={width:a,height:h};else{if(isNaN(n))return void t.Error("Invalid 'size' parameter !");h=n,a=n}var c=r.getScene(),l=null;c.activeCamera!==r&&(l=c.activeCamera,c.activeCamera=r);var u=new e.RenderTargetTexture("screenShot",n,c,(!1),(!1),e.Engine.TEXTURETYPE_UNSIGNED_INT,(!1),e.Texture.NEAREST_SAMPLINGMODE);u.renderList=c.meshes,u.onAfterRenderObservable.add((function(){t.DumpFramebuffer(a,h,i,o,s)})),c.incrementRenderId(),c.resetCachedMaterial(),u.render(!0),u.dispose(),l&&(c.activeCamera=l),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},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)}))},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 e<10?"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="
"+i+"

";t._AddLogEntry(r)},t._WarnDisabled=function(e){},t._WarnEnabled=function(e){var i=t._FormatMessage(e);console.warn("BJS - "+i);var r="
"+i+"

";t._AddLogEntry(r)},t._ErrorDisabled=function(e){},t._ErrorEnabled=function(e){t.errorsCount++;var i=t._FormatMessage(e);console.error("BJS - "+i);var r="
"+i+"

";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,r=e;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})();n.BaseUrl="",n.CorsBehavior="anonymous",n.UseFallbackTexture=!0,n.fallbackTexture="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",n._NoneLogLevel=0,n._MessageLogLevel=1,n._WarningLogLevel=2,n._ErrorLogLevel=4,n._LogCache="",n.errorsCount=0,n.Log=n._LogEnabled,n.Warn=n._WarnEnabled,n.Error=n._ErrorEnabled,n._PerformanceNoneLogLevel=0,n._PerformanceUserMarkLogLevel=1,n._PerformanceConsoleLogLevel=2,n._performance=window.performance,n.StartPerformanceCounter=n._StartPerformanceCounterDisabled,n.EndPerformanceCounter=n._EndPerformanceCounterDisabled,e.Tools=n;var o=(function(){function e(){this._startMonitoringTime=0,this._min=0,this._max=0,this._average=0,this._lastSecAverage=0,this._current=0,this._totalValueCount=0,this._totalAccumulated=0,this._lastSecAccumulated=0,this._lastSecTime=0,this._lastSecValueCount=0}return Object.defineProperty(e.prototype,"min",{get:function(){return this._min},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"max",{get:function(){return this._max},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"average",{get:function(){return this._average},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"lastSecAverage",{get:function(){return this._lastSecAverage},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"current",{get:function(){return this._current},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"total",{get:function(){return this._totalAccumulated},enumerable:!0,configurable:!0}),e.prototype.fetchNewFrame=function(){this._totalValueCount++,this._current=0,this._lastSecValueCount++},e.prototype.addCount=function(e,t){this._current+=e,t&&this._fetchResult()},e.prototype.beginMonitoring=function(){this._startMonitoringTime=n.Now},e.prototype.endMonitoring=function(e){void 0===e&&(e=!0),e&&this.fetchNewFrame();var t=n.Now;this._current=t-this._startMonitoringTime,e&&this._fetchResult()},e.prototype._fetchResult=function(){this._totalAccumulated+=this._current,this._lastSecAccumulated+=this._current,this._min=Math.min(this._min,this._current),this._max=Math.max(this._max,this._current),this._average=this._totalAccumulated/this._totalValueCount;var e=n.Now;e-this._lastSecTime>1e3&&(this._lastSecAverage=this._lastSecAccumulated/this._lastSecValueCount,this._lastSecTime=e,this._lastSecAccumulated=0,this._lastSecValueCount=0)},e})();e.PerfCounter=o,e.className=t;var s=(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=t)break;if(r(s),o&&o()){ +e.breakLoop();break}}e.executeNext()}),s)}),n)},e})();e.AsyncLoop=s})(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),this.reset()}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,this.reset()}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(t){var i=(function(){function t(){this._isStencilTestDirty=!1,this._isStencilMaskDirty=!1,this._isStencilFuncDirty=!1,this._isStencilOpDirty=!1,this.reset()}return Object.defineProperty(t.prototype,"isDirty",{get:function(){return this._isStencilTestDirty||this._isStencilMaskDirty||this._isStencilFuncDirty||this._isStencilOpDirty},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stencilFunc",{get:function(){return this._stencilFunc},set:function(e){this._stencilFunc!==e&&(this._stencilFunc=e,this._isStencilFuncDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stencilFuncRef",{get:function(){return this._stencilFuncRef},set:function(e){this._stencilFuncRef!==e&&(this._stencilFuncRef=e,this._isStencilFuncDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stencilFuncMask",{get:function(){return this._stencilFuncMask},set:function(e){this._stencilFuncMask!==e&&(this._stencilFuncMask=e,this._isStencilFuncDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stencilOpStencilFail",{get:function(){return this._stencilOpStencilFail},set:function(e){this._stencilOpStencilFail!==e&&(this._stencilOpStencilFail=e,this._isStencilOpDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stencilOpDepthFail",{get:function(){return this._stencilOpDepthFail},set:function(e){this._stencilOpDepthFail!==e&&(this._stencilOpDepthFail=e,this._isStencilOpDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stencilOpStencilDepthPass",{get:function(){return this._stencilOpStencilDepthPass},set:function(e){this._stencilOpStencilDepthPass!==e&&(this._stencilOpStencilDepthPass=e,this._isStencilOpDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stencilMask",{get:function(){return this._stencilMask},set:function(e){this._stencilMask!==e&&(this._stencilMask=e,this._isStencilMaskDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stencilTest",{get:function(){return this._stencilTest},set:function(e){this._stencilTest!==e&&(this._stencilTest=e,this._isStencilTestDirty=!0)},enumerable:!0,configurable:!0}),t.prototype.reset=function(){this._stencilTest=!1,this._stencilMask=255,this._stencilFunc=e.Engine.ALWAYS,this._stencilFuncRef=1,this._stencilFuncMask=255,this._stencilOpStencilFail=e.Engine.KEEP,this._stencilOpDepthFail=e.Engine.KEEP,this._stencilOpStencilDepthPass=e.Engine.REPLACE,this._isStencilTestDirty=!0,this._isStencilMaskDirty=!0,this._isStencilFuncDirty=!0,this._isStencilOpDirty=!0},t.prototype.apply=function(e){this.isDirty&&(this._isStencilTestDirty&&(this.stencilTest?e.enable(e.STENCIL_TEST):e.disable(e.STENCIL_TEST),this._isStencilTestDirty=!1),this._isStencilMaskDirty&&(e.stencilMask(this.stencilMask),this._isStencilMaskDirty=!1),this._isStencilFuncDirty&&(e.stencilFunc(this.stencilFunc,this.stencilFuncRef,this.stencilFuncMask),this._isStencilFuncDirty=!1),this._isStencilOpDirty&&(e.stencilOp(this.stencilOpStencilFail,this.stencilOpDepthFail,this.stencilOpStencilDepthPass),this._isStencilOpDirty=!1))},t})();t._StencilState=i})(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=36193,r=function(e,t){return t===l.TEXTURETYPE_FLOAT?e.FLOAT:t===l.TEXTURETYPE_HALF_FLOAT?i:e.UNSIGNED_BYTE},n=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}},o=function(t,i,r,o,s,a,h,c,l,u){void 0===u&&(u=e.Texture.TRILINEAR_SAMPLINGMODE);var d=r.getEngine(),f=e.Tools.GetExponentOfTwo(o,d.getCaps().maxTextureSize),p=e.Tools.GetExponentOfTwo(s,d.getCaps().maxTextureSize);d._bindTextureDirectly(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=f,t._height=p,t.isReady=!0,l(f,p);var _=n(u,!h,i);i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,_.mag),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,_.min),h||c||i.generateMipmap(i.TEXTURE_2D),d._bindTextureDirectly(i.TEXTURE_2D,null),d.resetTextureCache(),r._removePendingData(t),t.onLoadedCallbacks.forEach((function(e){e()})),t.onLoadedCallbacks=[]},s=function(t,i,r,n,o,s){void 0===s&&(s=null);var a,h=function(){r[i]=a,r._internalCount++,n._removePendingData(a),6===r._internalCount&&o(r)},c=function(){n._removePendingData(a),s&&s()};a=e.Tools.LoadImage(t,h,c,n.database),n._addPendingData(a)},a=function(e,t,i,r,n){void 0===n&&(n=null);var o=[];o._internalCount=0;for(var a=0;a<6;a++)s(r[a],a,o,t,i,n)},h=(function(){function e(){}return e})();e.InstancingAttributeInfo=h;var c=(function(){function e(){}return e})();e.EngineCapabilities=c;var l=(function(){function s(t,i,r,n){void 0===n&&(n=!1);var o=this;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._badOS=!1,this._drawCalls=new e.PerfCounter,this._renderingQueueLaunched=!1,this._activeRenderLoops=[],this.fpsRange=60,this.previousFramesDuration=[],this.fps=60,this.deltaTime=0,this._depthCullingState=new e.Internals._DepthCullingState,this._stencilState=new e.Internals._StencilState,this._alphaState=new e.Internals._AlphaState,this._alphaMode=s.ALPHA_DISABLE,this._loadedTexturesCache=new Array,this._maxTextureChannels=16,this._activeTexturesCache=new Array(this._maxTextureChannels),this._compiledEffects={},this._vertexAttribArraysEnabled=[],this._uintIndicesCurrentlySet=!1,this._currentBoundBuffer=new Array,this._currentBufferPointers=[],this._currentInstanceLocations=new Array,this._currentInstanceBuffers=new Array,this._texturesSupported=new Array,this._onVRFullScreenTriggered=function(){if(o._vrDisplayEnabled&&o._vrDisplayEnabled.isPresenting){o._oldSize=new e.Size(o.getRenderWidth(),o.getRenderHeight()),o._oldHardwareScaleFactor=o.getHardwareScalingLevel();var t=o._vrDisplayEnabled.getEyeParameters("left");o.setHardwareScalingLevel(1),o.setSize(2*t.renderWidth,t.renderHeight)}else o.setHardwareScalingLevel(o._oldHardwareScaleFactor),o.setSize(o._oldSize.width,o._oldSize.height),o._vrDisplayEnabled=void 0},this._renderingCanvas=t,this._externalData=new e.StringDictionary,r=r||{},null!=i&&(r.antialias=i),void 0===r.preserveDrawingBuffer&&(r.preserveDrawingBuffer=!1);var a=this._canRenderToFloatTexture(),h=this._canRenderToHalfFloatTexture();try{this._gl=t.getContext("webgl2",r)||t.getContext("experimental-webgl2",r),this._gl&&(this._webGLVersion="2.0")}catch(l){}if(!this._gl){if(!t)throw new Error("The provided canvas is null or undefined.");try{this._gl=t.getContext("webgl",r)||t.getContext("experimental-webgl",r)}catch(l){throw new Error("WebGL not supported")}}if(!this._gl)throw new Error("WebGL not supported");this._onBlur=function(){o._windowIsBackground=!0},this._onFocus=function(){o._windowIsBackground=!1},window.addEventListener("blur",this._onBlur),window.addEventListener("focus",this._onFocus);var u=r.limitDeviceRatio||window.devicePixelRatio||1;this._hardwareScalingLevel=n?1/Math.min(u,window.devicePixelRatio||1):1,this.resize(),this._isStencilEnable=r.stencil,this._caps=new c,this._caps.maxTexturesImageUnits=this._gl.getParameter(this._gl.MAX_TEXTURE_IMAGE_UNITS),this._caps.maxTextureSize=this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE),this._caps.maxCubemapTextureSize=this._gl.getParameter(this._gl.MAX_CUBE_MAP_TEXTURE_SIZE),this._caps.maxRenderTextureSize=this._gl.getParameter(this._gl.MAX_RENDERBUFFER_SIZE),this._caps.maxVertexAttribs=this._gl.getParameter(this._gl.MAX_VERTEX_ATTRIBS),this._caps.maxVaryingVectors=this._gl.getParameter(this._gl.MAX_VARYING_VECTORS),this._caps.maxFragmentUniformVectors=this._gl.getParameter(this._gl.MAX_FRAGMENT_UNIFORM_VECTORS),this._caps.maxVertexUniformVectors=this._gl.getParameter(this._gl.MAX_VERTEX_UNIFORM_VECTORS),this._glVersion=this._gl.getParameter(this._gl.VERSION);var d=this._gl.getExtension("WEBGL_debug_renderer_info");if(null!=d&&(this._glRenderer=this._gl.getParameter(d.UNMASKED_RENDERER_WEBGL),this._glVendor=this._gl.getParameter(d.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.astc=this._gl.getExtension("WEBGL_compressed_texture_astc"),this._caps.s3tc=this._gl.getExtension("WEBGL_compressed_texture_s3tc"),this._caps.pvrtc=this._gl.getExtension("WEBGL_compressed_texture_pvrtc")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),this._caps.etc1=this._gl.getExtension("WEBGL_compressed_texture_etc1"),this._caps.etc2=this._gl.getExtension("WEBGL_compressed_texture_etc")||this._gl.getExtension("WEBGL_compressed_texture_es3_0"),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._caps.textureFloatRender=a,this._caps.textureHalfFloat=null!==this._gl.getExtension("OES_texture_half_float"),this._caps.textureHalfFloatLinearFiltering=this._gl.getExtension("OES_texture_half_float_linear"),this._caps.textureHalfFloatRender=h,this._caps.astc&&this.texturesSupported.push(".astc"),this._caps.s3tc&&this.texturesSupported.push(".dds"),this._caps.pvrtc&&this.texturesSupported.push(".pvr"),this._caps.etc2&&this.texturesSupported.push(".etc2"),this._caps.etc1&&this.texturesSupported.push(".etc1"),this._gl.getShaderPrecisionFormat){var f=this._gl.getShaderPrecisionFormat(this._gl.FRAGMENT_SHADER,this._gl.HIGH_FLOAT);this._caps.highPrecisionShaderSupported=0!==f.precision}this.setDepthBuffer(!0),this.setDepthFunctionToLessOrEqual(),this.setDepthWrite(!0),this._onFullscreenChange=function(){void 0!==document.fullscreen?o.isFullscreen=document.fullscreen:void 0!==document.mozFullScreen?o.isFullscreen=document.mozFullScreen:void 0!==document.webkitIsFullScreen?o.isFullscreen=document.webkitIsFullScreen:void 0!==document.msIsFullScreen&&(o.isFullscreen=document.msIsFullScreen),o.isFullscreen&&o._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(){o.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&&!s.audioEngine&&(s.audioEngine=new e.AudioEngine),this._loadingScreen=new e.DefaultLoadingScreen(this._renderingCanvas),r.autoEnableWebVR&&this.initWebVR();var p=/AppleWebKit.*10.[\d] Mobile/;this._badOS=p.test(navigator.userAgent),e.Tools.Log("Babylon.js engine (v"+s.Version+") launched")}return Object.defineProperty(s,"NEVER",{get:function(){return s._NEVER},enumerable:!0,configurable:!0}),Object.defineProperty(s,"ALWAYS",{get:function(){return s._ALWAYS},enumerable:!0,configurable:!0}),Object.defineProperty(s,"LESS",{get:function(){return s._LESS},enumerable:!0,configurable:!0}),Object.defineProperty(s,"EQUAL",{get:function(){return s._EQUAL},enumerable:!0,configurable:!0}),Object.defineProperty(s,"LEQUAL",{get:function(){return s._LEQUAL},enumerable:!0,configurable:!0}),Object.defineProperty(s,"GREATER",{get:function(){return s._GREATER},enumerable:!0,configurable:!0}),Object.defineProperty(s,"GEQUAL",{get:function(){return s._GEQUAL},enumerable:!0,configurable:!0}),Object.defineProperty(s,"NOTEQUAL",{get:function(){return s._NOTEQUAL},enumerable:!0,configurable:!0}),Object.defineProperty(s,"KEEP",{get:function(){return s._KEEP},enumerable:!0,configurable:!0}),Object.defineProperty(s,"REPLACE",{get:function(){return s._REPLACE},enumerable:!0,configurable:!0}),Object.defineProperty(s,"INCR",{get:function(){return s._INCR},enumerable:!0,configurable:!0}),Object.defineProperty(s,"DECR",{get:function(){return s._DECR},enumerable:!0,configurable:!0}),Object.defineProperty(s,"INVERT",{get:function(){return s._INVERT},enumerable:!0,configurable:!0}),Object.defineProperty(s,"INCR_WRAP",{get:function(){return s._INCR_WRAP},enumerable:!0,configurable:!0}),Object.defineProperty(s,"DECR_WRAP",{get:function(){return s._DECR_WRAP},enumerable:!0,configurable:!0}),Object.defineProperty(s,"ALPHA_DISABLE",{get:function(){return s._ALPHA_DISABLE},enumerable:!0,configurable:!0}),Object.defineProperty(s,"ALPHA_ONEONE",{get:function(){return s._ALPHA_ONEONE},enumerable:!0,configurable:!0}),Object.defineProperty(s,"ALPHA_ADD",{get:function(){return s._ALPHA_ADD},enumerable:!0,configurable:!0}),Object.defineProperty(s,"ALPHA_COMBINE",{get:function(){return s._ALPHA_COMBINE},enumerable:!0,configurable:!0}),Object.defineProperty(s,"ALPHA_SUBTRACT",{get:function(){return s._ALPHA_SUBTRACT},enumerable:!0,configurable:!0}),Object.defineProperty(s,"ALPHA_MULTIPLY",{get:function(){return s._ALPHA_MULTIPLY},enumerable:!0,configurable:!0}),Object.defineProperty(s,"ALPHA_MAXIMIZED",{get:function(){return s._ALPHA_MAXIMIZED},enumerable:!0,configurable:!0}),Object.defineProperty(s,"ALPHA_PREMULTIPLIED",{get:function(){return s._ALPHA_PREMULTIPLIED},enumerable:!0,configurable:!0}),Object.defineProperty(s,"DELAYLOADSTATE_NONE",{get:function(){return s._DELAYLOADSTATE_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(s,"DELAYLOADSTATE_LOADED",{get:function(){return s._DELAYLOADSTATE_LOADED},enumerable:!0,configurable:!0}),Object.defineProperty(s,"DELAYLOADSTATE_LOADING",{get:function(){return s._DELAYLOADSTATE_LOADING},enumerable:!0,configurable:!0}),Object.defineProperty(s,"DELAYLOADSTATE_NOTLOADED",{get:function(){return s._DELAYLOADSTATE_NOTLOADED},enumerable:!0,configurable:!0}),Object.defineProperty(s,"TEXTUREFORMAT_ALPHA",{get:function(){return s._TEXTUREFORMAT_ALPHA},enumerable:!0,configurable:!0}),Object.defineProperty(s,"TEXTUREFORMAT_LUMINANCE",{get:function(){return s._TEXTUREFORMAT_LUMINANCE},enumerable:!0,configurable:!0}),Object.defineProperty(s,"TEXTUREFORMAT_LUMINANCE_ALPHA",{get:function(){return s._TEXTUREFORMAT_LUMINANCE_ALPHA},enumerable:!0,configurable:!0}),Object.defineProperty(s,"TEXTUREFORMAT_RGB",{get:function(){return s._TEXTUREFORMAT_RGB},enumerable:!0,configurable:!0}),Object.defineProperty(s,"TEXTUREFORMAT_RGBA",{get:function(){return s._TEXTUREFORMAT_RGBA},enumerable:!0,configurable:!0}),Object.defineProperty(s,"TEXTURETYPE_UNSIGNED_INT",{get:function(){return s._TEXTURETYPE_UNSIGNED_INT},enumerable:!0,configurable:!0}),Object.defineProperty(s,"TEXTURETYPE_FLOAT",{get:function(){return s._TEXTURETYPE_FLOAT},enumerable:!0,configurable:!0}),Object.defineProperty(s,"TEXTURETYPE_HALF_FLOAT",{get:function(){return s._TEXTURETYPE_HALF_FLOAT},enumerable:!0,configurable:!0}),Object.defineProperty(s,"Version",{get:function(){return"2.6-alpha"},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"texturesSupported",{get:function(){return this._texturesSupported},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"textureFormatInUse",{get:function(){return this._textureFormatInUse},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"webGLVersion",{get:function(){return this._webGLVersion},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"isStencilEnable",{get:function(){return this._isStencilEnable},enumerable:!0,configurable:!0}),s.prototype._prepareWorkingCanvas=function(){this._workingCanvas||(this._workingCanvas=document.createElement("canvas"),this._workingContext=this._workingCanvas.getContext("2d"))},s.prototype.resetTextureCache=function(){for(var e=0;e=0&&this._activeRenderLoops.splice(t,1)},s.prototype._renderLoop=function(){var t=!0;if(!this.renderEvenInBackground&&this._windowIsBackground&&(t=!1),t){this.beginFrame();for(var i=0;i0?e.Tools.QueueNewFrame(this._bindedRenderFunction,this._vrDisplayEnabled):this._renderingQueueLaunched=!1},s.prototype.runRenderLoop=function(t){this._activeRenderLoops.indexOf(t)===-1&&(this._activeRenderLoops.push(t),this._renderingQueueLaunched||(this._renderingQueueLaunched=!0,this._bindedRenderFunction=this._renderLoop.bind(this),e.Tools.QueueNewFrame(this._bindedRenderFunction)))},s.prototype.switchFullscreen=function(t){this.isFullscreen?e.Tools.ExitFullscreen():(this._pointerLockRequested=t,e.Tools.RequestFullscreen(this._renderingCanvas))},s.prototype.clear=function(e,t,i,r){void 0===r&&(r=!1),this.applyStates();var n=0;t&&e&&(this._gl.clearColor(e.r,e.g,e.b,e.a),n|=this._gl.COLOR_BUFFER_BIT),i&&(this._gl.clearDepth(1),n|=this._gl.DEPTH_BUFFER_BIT),r&&(this._gl.clearStencil(0),n|=this._gl.STENCIL_BUFFER_BIT),this._gl.clear(n)},s.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,!0),o.scissor(a[0],a[1],a[2],a[3]),s===!0?o.enable(o.SCISSOR_TEST):o.disable(o.SCISSOR_TEST)},s.prototype.setViewport=function(e,t,i){var r=t||(navigator.isCocoonJS?window.innerWidth:this.getRenderWidth()),n=i||(navigator.isCocoonJS?window.innerHeight:this.getRenderHeight()),o=e.x||0,s=e.y||0;this._cachedViewport=e,this._gl.viewport(o*r,s*n,r*e.width,n*e.height)},s.prototype.setDirectViewport=function(e,t,i,r){var n=this._cachedViewport;return this._cachedViewport=null,this._gl.viewport(e,t,i,r),n},s.prototype.beginFrame=function(){this._measureFps()},s.prototype.endFrame=function(){this._badOS&&this.flushFramebuffer(),this._vrDisplayEnabled&&this._vrDisplayEnabled.isPresenting&&this._vrDisplayEnabled.submitFrame()},s.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)},s.prototype.setSize=function(e,t){this._renderingCanvas.width=e,this._renderingCanvas.height=t;for(var i=0;i65535){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},s.prototype.bindArrayBuffer=function(e){this.bindBuffer(e,this._gl.ARRAY_BUFFER)},s.prototype.bindIndexBuffer=function(e){this.bindBuffer(e,this._gl.ELEMENT_ARRAY_BUFFER)},s.prototype.bindBuffer=function(e,t){this._currentBoundBuffer[t]!==e&&(this._gl.bindBuffer(t,e),this._currentBoundBuffer[t]=e)},s.prototype.updateArrayBuffer=function(e){this._gl.bufferSubData(this._gl.ARRAY_BUFFER,0,e); +},s.prototype.vertexAttribPointer=function(e,t,i,r,n,o,s){var a=this._currentBufferPointers[t],h=!1;a?(a.buffer!==e&&(a.buffer=e,h=!0),a.size!==i&&(a.size=i,h=!0),a.type!==r&&(a.type=r,h=!0),a.normalized!==n&&(a.normalized=n,h=!0),a.stride!==o&&(a.stride=o,h=!0),a.offset!==s&&(a.offset=s,h=!0)):(h=!0,this._currentBufferPointers[t]={indx:t,size:i,type:r,normalized:n,stride:o,offset:s,buffer:e}),h&&(this.bindArrayBuffer(e),this._gl.vertexAttribPointer(t,i,r,n,o,s))},s.prototype.bindBuffersDirectly=function(e,t,i,r,n){if(this._cachedVertexBuffers!==e||this._cachedEffectForVertexBuffers!==n){this._cachedVertexBuffers=e,this._cachedEffectForVertexBuffers=n;var o=n.getAttributesCount();this.unbindAllAttributes();for(var s=0,a=0;a=0&&(this._gl.enableVertexAttribArray(h),this._vertexAttribArraysEnabled[h]=!0,this.vertexAttribPointer(e,h,i[a],this._gl.FLOAT,!1,r,s)),s+=4*i[a]}}this._cachedIndexBuffer!==t&&(this._cachedIndexBuffer=t,this.bindIndexBuffer(t),this._uintIndicesCurrentlySet=t.is32Bits)},s.prototype.bindBuffers=function(e,t,i){if(this._cachedVertexBuffers!==e||this._cachedEffectForVertexBuffers!==i){this._cachedVertexBuffers=e,this._cachedEffectForVertexBuffers=i;var r=i.getAttributesNames();this.unbindAllAttributes();for(var n=0;n=0){var s=e[r[n]];if(!s)continue;this._gl.enableVertexAttribArray(o),this._vertexAttribArraysEnabled[o]=!0;var a=s.getBuffer();this.vertexAttribPointer(a,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.bindIndexBuffer(t),this._uintIndicesCurrentlySet=t.is32Bits)},s.prototype.unbindInstanceAttributes=function(){for(var e,t=0,i=this._currentInstanceLocations.length;t1)&&!i&&a.width>>a.mipmapCount-1===1;o(d,l._gl,n,a.width,a.height,r,!h,a.isFourCC,(function(){e.Internals.DDSTools.UploadDDSLevels(l._gl,l.getCaps().s3tc,t,a,h,1)}),s)},f instanceof Array?v(c):e.Tools.LoadFile(t,(function(e){v(e)}),null,n.database,!0,y);else{var x=function(t){o(d,l._gl,n,t.width,t.height,r,i,!1,(function(i,r){var n=t.width===i&&t.height===r;n||(l._prepareWorkingCanvas(),l._workingCanvas.width=i,l._workingCanvas.height=r,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)}),s)};f instanceof Array?e.Tools.LoadImage(c,x,y,n.database):e.Tools.LoadImage(t,x,y,n.database)}return d},s.prototype._getInternalFormat=function(e){var t=this._gl.RGBA;switch(e){case s.TEXTUREFORMAT_ALPHA:t=this._gl.ALPHA;break;case s.TEXTUREFORMAT_LUMINANCE:t=this._gl.LUMINANCE;break;case s.TEXTUREFORMAT_LUMINANCE_ALPHA:t=this._gl.LUMINANCE_ALPHA;break;case s.TEXTUREFORMAT_RGB:t=this._gl.RGB;break;case s.TEXTUREFORMAT_RGBA:t=this._gl.RGBA}return t},s.prototype.updateRawTexture=function(e,t,i,r,n){void 0===n&&(n=null);var o=this._getInternalFormat(i);this._bindTextureDirectly(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._bindTextureDirectly(this._gl.TEXTURE_2D,null),this.resetTextureCache(),e.isReady=!0},s.prototype.createRawTexture=function(e,t,i,r,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,r,s,h),this._bindTextureDirectly(this._gl.TEXTURE_2D,c);var l=n(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),o&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(this._gl.TEXTURE_2D,null),c.samplingMode=a,this._loadedTexturesCache.push(c),c},s.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},s.prototype.updateTextureSamplingMode=function(e,t){var i=n(e,t.generateMipMaps,this._gl);t.isCube?(this._bindTextureDirectly(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._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null)):(this._bindTextureDirectly(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._bindTextureDirectly(this._gl.TEXTURE_2D,null))},s.prototype.updateDynamicTexture=function(e,t,i,r){void 0===r&&(r=!1),this._bindTextureDirectly(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._bindTextureDirectly(this._gl.TEXTURE_2D,null),r&&this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),this.resetTextureCache(),e.isReady=!0},s.prototype.updateVideoTexture=function(e,t,i){if(!e._isDisabled){this._bindTextureDirectly(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._bindTextureDirectly(this._gl.TEXTURE_2D,null),this.resetTextureCache(),e.isReady=!0}catch(r){e._isDisabled=!0}}},s.prototype.createRenderTargetTexture=function(t,i){var o=!1,a=!0,h=!1,c=s.TEXTURETYPE_UNSIGNED_INT,l=e.Texture.TRILINEAR_SAMPLINGMODE;void 0!==i&&(o=void 0===i.generateMipMaps?i:i.generateMipMaps,a=void 0===i.generateDepthBuffer||i.generateDepthBuffer,h=a&&i.generateStencilBuffer,c=void 0===i.type?c:i.type,void 0!==i.samplingMode&&(l=i.samplingMode),c!==s.TEXTURETYPE_FLOAT||this._caps.textureFloatLinearFiltering?c!==s.TEXTURETYPE_HALF_FLOAT||this._caps.textureHalfFloatLinearFiltering||(l=e.Texture.NEAREST_SAMPLINGMODE):l=e.Texture.NEAREST_SAMPLINGMODE);var u=this._gl,d=u.createTexture();this._bindTextureDirectly(u.TEXTURE_2D,d);var f=t.width||t,p=t.height||t,_=n(l,o,u);c!==s.TEXTURETYPE_FLOAT||this._caps.textureFloat||(c=s.TEXTURETYPE_UNSIGNED_INT,e.Tools.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type")),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_MAG_FILTER,_.mag),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_MIN_FILTER,_.min),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_WRAP_S,u.CLAMP_TO_EDGE),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_WRAP_T,u.CLAMP_TO_EDGE),u.texImage2D(u.TEXTURE_2D,0,u.RGBA,f,p,0,u.RGBA,r(u,c),null);var m;h?(m=u.createRenderbuffer(),u.bindRenderbuffer(u.RENDERBUFFER,m),u.renderbufferStorage(u.RENDERBUFFER,u.DEPTH_STENCIL,f,p)):a&&(m=u.createRenderbuffer(),u.bindRenderbuffer(u.RENDERBUFFER,m),u.renderbufferStorage(u.RENDERBUFFER,u.DEPTH_COMPONENT16,f,p));var g=u.createFramebuffer();return this.bindUnboundFramebuffer(g),h?u.framebufferRenderbuffer(u.FRAMEBUFFER,u.DEPTH_STENCIL_ATTACHMENT,u.RENDERBUFFER,m):a&&u.framebufferRenderbuffer(u.FRAMEBUFFER,u.DEPTH_ATTACHMENT,u.RENDERBUFFER,m),u.framebufferTexture2D(u.FRAMEBUFFER,u.COLOR_ATTACHMENT0,u.TEXTURE_2D,d,0),o&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(u.TEXTURE_2D,null),u.bindRenderbuffer(u.RENDERBUFFER,null),this.bindUnboundFramebuffer(null),d._framebuffer=g,a&&(d._depthBuffer=m),d._baseWidth=f,d._baseHeight=p,d._width=f,d._height=p,d.isReady=!0,d.generateMipMaps=o,d.references=1,d.samplingMode=l,d.type=c,this.resetTextureCache(),this._loadedTexturesCache.push(d),d},s.prototype.createRenderTargetCubeTexture=function(t,i){var r=this._gl,o=r.createTexture(),s=!0,a=!0,h=!1,c=e.Texture.TRILINEAR_SAMPLINGMODE;void 0!==i&&(s=void 0===i.generateMipMaps?i:i.generateMipMaps,a=void 0===i.generateDepthBuffer||i.generateDepthBuffer,h=a&&i.generateStencilBuffer,void 0!==i.samplingMode&&(c=i.samplingMode)),o.isCube=!0,o.references=1,o.generateMipMaps=s,o.references=1,o.samplingMode=c;var l=n(c,s,r);this._bindTextureDirectly(r.TEXTURE_CUBE_MAP,o);for(var u=0;u<6;u++)r.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+u,0,r.RGBA,t,t,0,r.RGBA,r.UNSIGNED_BYTE,null);r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_MAG_FILTER,l.mag),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_MIN_FILTER,l.min),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE);var d;h?(d=r.createRenderbuffer(),r.bindRenderbuffer(r.RENDERBUFFER,d),r.renderbufferStorage(r.RENDERBUFFER,r.DEPTH_STENCIL,t,t)):a&&(d=r.createRenderbuffer(),r.bindRenderbuffer(r.RENDERBUFFER,d),r.renderbufferStorage(r.RENDERBUFFER,r.DEPTH_COMPONENT16,t,t));var f=r.createFramebuffer();return this.bindUnboundFramebuffer(f),h?r.framebufferRenderbuffer(r.FRAMEBUFFER,r.DEPTH_STENCIL_ATTACHMENT,r.RENDERBUFFER,d):a&&r.framebufferRenderbuffer(r.FRAMEBUFFER,r.DEPTH_ATTACHMENT,r.RENDERBUFFER,d),o.generateMipMaps&&(this._bindTextureDirectly(r.TEXTURE_CUBE_MAP,o),r.generateMipmap(r.TEXTURE_CUBE_MAP)),this._bindTextureDirectly(r.TEXTURE_CUBE_MAP,null),r.bindRenderbuffer(r.RENDERBUFFER,null),this.bindUnboundFramebuffer(null),o._framebuffer=f,a&&(o._depthBuffer=d),o._width=t,o._height=t,o.isReady=!0,this.resetTextureCache(),this._loadedTexturesCache.push(o),o},s.prototype.createCubeTexture=function(t,i,r,n,o,s){var h=this;void 0===o&&(o=null),void 0===s&&(s=null);var c=this._gl,l=c.createTexture();l.isCube=!0,l.url=t,l.references=1,l.onLoadedCallbacks=[];var u=t.substr(t.length-4,4).toLowerCase(),d=this.getCaps().s3tc&&".dds"===u;return d?e.Tools.LoadFile(t,(function(t){var i=e.Internals.DDSTools.GetDDSInfo(t),r=(i.isRGB||i.isLuminance||i.mipmapCount>1)&&!n;h._bindTextureDirectly(c.TEXTURE_CUBE_MAP,l),c.pixelStorei(c.UNPACK_FLIP_Y_WEBGL,1),e.Internals.DDSTools.UploadDDSLevels(h._gl,h.getCaps().s3tc,t,i,r,6),n||i.isFourCC||1!==i.mipmapCount||c.generateMipmap(c.TEXTURE_CUBE_MAP),c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MAG_FILTER,c.LINEAR),c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MIN_FILTER,r?c.LINEAR_MIPMAP_LINEAR:c.LINEAR),c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE),c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE),h._bindTextureDirectly(c.TEXTURE_CUBE_MAP,null),h.resetTextureCache(),l._width=i.width,l._height=i.height,l.isReady=!0}),null,null,!0,s):a(t,i,(function(t){var i=e.Tools.GetExponentOfTwo(t[0].width,h._caps.maxCubemapTextureSize),r=i;h._prepareWorkingCanvas(),h._workingCanvas.width=i,h._workingCanvas.height=r;var s=[c.TEXTURE_CUBE_MAP_POSITIVE_X,c.TEXTURE_CUBE_MAP_POSITIVE_Y,c.TEXTURE_CUBE_MAP_POSITIVE_Z,c.TEXTURE_CUBE_MAP_NEGATIVE_X,c.TEXTURE_CUBE_MAP_NEGATIVE_Y,c.TEXTURE_CUBE_MAP_NEGATIVE_Z];h._bindTextureDirectly(c.TEXTURE_CUBE_MAP,l),c.pixelStorei(c.UNPACK_FLIP_Y_WEBGL,0);for(var a=0;a>y;d.texImage2D(o[0],y,p,x,x,0,p,_,a[y][0]),d.texImage2D(o[1],y,p,x,x,0,p,_,a[y][2]),d.texImage2D(o[2],y,p,x,x,0,p,_,a[y][4]),d.texImage2D(o[3],y,p,x,x,0,p,_,a[y][1]),d.texImage2D(o[4],y,p,x,x,0,p,_,a[y][3]),d.texImage2D(o[5],y,p,x,x,0,p,_,a[y][5])}}else{for(var b=0;b-1&&t.splice(i,1),this._releaseTexture(e)}},s.prototype.unbindAllAttributes=function(){for(var e=0,t=this._vertexAttribArraysEnabled.length;e=this._caps.maxVertexAttribs||!this._vertexAttribArraysEnabled[e]||this._vertexAttribArraysEnabled[e]&&(this._gl.disableVertexAttribArray(e),this._vertexAttribArraysEnabled[e]=!1)},s.prototype.dispose=function(){for(this.hideLoadingUI(),this.stopRenderLoop();this.scenes.length;)this.scenes[0].dispose();s.audioEngine.dispose();for(var e in this._compiledEffects)this._gl.deleteProgram(this._compiledEffects[e]._program);this.unbindAllAttributes(),this._gl=null,this.disableVR(),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)},s.prototype.displayLoadingUI=function(){this._loadingScreen.displayLoadingUI()},s.prototype.hideLoadingUI=function(){this._loadingScreen.hideLoadingUI()},Object.defineProperty(s.prototype,"loadingScreen",{get:function(){return this._loadingScreen},set:function(e){this._loadingScreen=e},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"loadingUIText",{set:function(e){this._loadingScreen.loadingUIText=e},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"loadingUIBackgroundColor",{set:function(e){this._loadingScreen.loadingUIBackgroundColor=e},enumerable:!0,configurable:!0}),s.prototype.attachContextLostEvent=function(e){this._renderingCanvas.addEventListener("webglcontextlost",e,!1)},s.prototype.attachContextRestoredEvent=function(e){this._renderingCanvas.addEventListener("webglcontextrestored",e,!1)},s.prototype.getVertexShaderSource=function(e){var t=this._gl.getAttachedShaders(e);return this._gl.getShaderSource(t[0])},s.prototype.getFragmentShaderSource=function(e){var t=this._gl.getAttachedShaders(e);return this._gl.getShaderSource(t[1])},s.prototype.getFps=function(){return this.fps},s.prototype.getDeltaTime=function(){return this.deltaTime},s.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;r0&&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;i0&&(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})();t.FilesTextures=new Array,t.FilesToLoad=new Array,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]),d=e.Vector3.FromArray(c,3*n[3*this.faceId+2]),f=l.subtract(u),p=d.subtract(u);r=e.Vector3.Cross(f,p)}return t&&(r=e.Vector3.TransformNormal(r,this.pickedMesh.getWorldMatrix())),e.Vector3.Normalize(r)},t.prototype.getTextureCoordinates=function(){if(!this.pickedMesh||!this.pickedMesh.isVerticesDataPresent(e.VertexBuffer.UVKind))return null;var t=this.pickedMesh.getIndices(),i=this.pickedMesh.getVerticesData(e.VertexBuffer.UVKind),r=e.Vector2.FromArray(i,2*t[3*this.faceId]),n=e.Vector2.FromArray(i,2*t[3*this.faceId+1]),o=e.Vector2.FromArray(i,2*t[3*this.faceId+2]);return r=r.scale(1-this.bu-this.bv),n=n.scale(this.bu),o=o.scale(this.bv),new e.Vector2(r.x+n.x+o.x,r.y+n.y+o.y)},t})();e.PickingInfo=i})(BABYLON||(BABYLON={}));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;t<6;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)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.xt.x-this.minimumWorld.x)&&(!(this.maximumWorld.y-t.yt.y-this.minimumWorld.y)&&!(this.maximumWorld.z-t.zt.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.xt.x)&&(!(this.maximumWorld.yt.y)&&!(this.maximumWorld.zt.z))},t.Intersects=function(e,t){return!(e.maximumWorld.xt.maximumWorld.x)&&(!(e.maximumWorld.yt.maximumWorld.y)&&!(e.maximumWorld.zt.maximumWorld.z))},t.IntersectsSphere=function(t,i,r,n){var o=e.Vector3.Clamp(r,t,i),s=e.Vector3.DistanceSquared(r,o);return s<=n*n},t.IsCompletelyInFrustum=function(e,t){for(var i=0;i<6;i++)for(var r=0;r<8;r++)if(t[i].dotCoordinate(e[r])<0)return!1;return!0},t.IsInFrustum=function(e,t){for(var i=0;i<6;i++){for(var r=8,n=0;n<8&&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)},t.prototype.isCompletelyInFrustum=function(e){return this.boundingBox.isCompletelyInFrustum(e)},t.prototype._checkCollision=function(e){return e._canDoCollision(this.boundingSphere.centerWorld,this.boundingSphere.radiusWorld,this.boundingBox.minimumWorld,this.boundingBox.maximumWorld)},t.prototype.intersectsPoint=function(e){return!!this.boundingSphere.centerWorld&&(!!this.boundingSphere.intersectsPoint(e)&&!!this.boundingBox.intersectsPoint(e))},t.prototype.intersects=function(t,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))))))))))))))},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,this._show=!1}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.xt.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.yt.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.zt.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(n<=o)return!0;var s=t*this.direction.x+i*this.direction.y+r*this.direction.z;if(s<0)return!1;var a=n-s*s;return a<=o},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(s<0||s>1)return null;e.Vector3.CrossToRef(this._tvec,this._edge1,this._qvec);var a=e.Vector3.Dot(this.direction,this._qvec)*o;if(a<0||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,i<0?i<-9.99999997475243e-7?null:0:i},t.prototype.intersectsMesh=function(i,r){var n=e.Tmp.Matrix[0];return i.getWorldMatrix().invertToRef(n),this._tmpRay?t.TransformToRef(this,n,this._tmpRay):this._tmpRay=t.Transform(this,n),i.intersects(this._tmpRay,r)},t.prototype.show=function(t,i){this._show||(this._renderFunction=this._render.bind(this),this._show=!0,this._scene=t,this._renderPoints=[this.origin,this.origin.add(this.direction.scale(this.length))],this._renderLine=e.Mesh.CreateLines("ray",this._renderPoints,t,!0),this._scene.registerBeforeRender(this._renderFunction)),i&&this._renderLine.color.copyFrom(i)},t.prototype.hide=function(){this._show&&(this._show=!1,this._scene.unregisterBeforeRender(this._renderFunction)),this._renderLine&&(this._renderLine.dispose(),this._renderLine=null,this._renderPoints=null)},t.prototype._render=function(){var t=this._renderPoints[1];t.copyFrom(this.direction),t.scaleInPlace(this.length),t.addInPlace(this.origin),e.Mesh.CreateLines("ray",this._renderPoints,this._scene,!0,this._renderLine)},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),d=i.subtract(this.origin),f=e.Vector3.Dot(l,l),p=e.Vector3.Dot(l,u),_=e.Vector3.Dot(u,u),m=e.Vector3.Dot(l,d),g=e.Vector3.Dot(u,d),v=f*_-p*p,y=v,x=v;vy&&(s=y,h=g+p,x=_)),h<0?(h=0,-m<0?s=0:-m>f?s=y:(s=-m,y=f)):h>x&&(h=x,-m+p<0?s=0:-m+p>f?s=y:(s=-m+p,y=f)),o=Math.abs(s)0&&a<=this.length&&A.lengthSquared()e.Engine.CollisionsEpsilon&&o.position.addInPlace(o._diffPositionForCollisions),r&&o.onCollideObservable.notifyObservers(r),o.onCollisionPositionChangeObservable.notifyObservers(o.position)},n.addMesh(o),o}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,"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.getClassName=function(){return"AbstractMesh"},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)},i.prototype.setBoundingInfo=function(e){this._boundingInfo=e},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,r,n){t.normalize(),this.rotationQuaternion||(this.rotationQuaternion=e.Quaternion.RotationYawPitchRoll(this.rotation.y,this.rotation.x,this.rotation.z),this.rotation=e.Vector3.Zero());var o;if(n&&n!==e.Space.LOCAL){if(this.parent){var s=this.parent.getWorldMatrix().clone();s.invert(),t=e.Vector3.TransformNormal(t,s)}o=e.Quaternion.RotationAxisToRef(t,r,i._rotationAxisCache),o.multiplyToRef(this.rotationQuaternion,this.rotationQuaternion)}else o=e.Quaternion.RotationAxisToRef(t,r,i._rotationAxisCache),this.rotationQuaternion.multiplyToRef(o,this.rotationQuaternion)},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(){return!this._isDirty&&(this.billboardMode===this._cache.billboardMode&&this.billboardMode===i.BILLBOARDMODE_NONE&&(!this._cache.pivotMatrixUpdated&&(!this.infiniteDistance&&(!!this._cache.position.equals(this.position)&&(!(this.rotationQuaternion&&!this._cache.rotationQuaternion.equals(this.rotationQuaternion))&&(!!this._cache.rotation.equals(this.rotation)&&!!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;t1&&!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;c1)||l.canIntersects(t)){var u=l.intersects(t,this._positions,this.getIndices(),i);if(u&&(i||!s||u.distance0&&this.includedOnlyMeshes.indexOf(e)===-1)&&(!(this.excludedMeshes.length>0&&this.excludedMeshes.indexOf(e)!==-1)&&((0===this.includeOnlyWithLayerMask||0!==(this.includeOnlyWithLayerMask&e.layerMask))&&!(0!==this.excludeWithLayerMask&&this.excludeWithLayerMask&e.layerMask)))},i.prototype.getWorldMatrix=function(){this._currentRenderId=this.getScene().getRenderId();var t=this._getWorldMatrix();return this.parent&&this.parent.getWorldMatrix?(this._parentedWorldMatrix||(this._parentedWorldMatrix=e.Matrix.Identity()),t.multiplyToRef(this.parent.getWorldMatrix(),this._parentedWorldMatrix),this._markSyncedWithParent(),this._parentedWorldMatrix):t},i.prototype.dispose=function(){this._shadowGenerator&&(this._shadowGenerator.dispose(),this._shadowGenerator=null),this.getScene().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;othis._orthoRight&&(this._orthoRight=o.x),o.y>this._orthoTop&&(this._orthoTop=o.y)}}}var u=this._orthoRight-this._orthoLeft,d=this._orthoTop-this._orthoBottom;e.Matrix.OrthoOffCenterLHToRef(this._orthoLeft-u*this.shadowOrthoScale,this._orthoRight+u*this.shadowOrthoScale,this._orthoBottom-d*this.shadowOrthoScale,this._orthoTop+d*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)},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},i})(e.Light);__decorate([e.serializeAsVector3()],t.prototype,"position",void 0),__decorate([e.serializeAsVector3()],t.prototype,"direction",void 0),__decorate([e.serialize()],t.prototype,"shadowOrthoScale",void 0),__decorate([e.serialize()],t.prototype,"autoUpdateExtends",void 0),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._useFullFloat=!0,this._light=r,this._scene=r.getScene(),this._mapSize=i,r._shadowGenerator=this;var o,s=this._scene.getEngine().getCaps();s.textureFloat&&s.textureFloatLinearFiltering&&s.textureFloatRender?(this._useFullFloat=!0,o=e.Engine.TEXTURETYPE_FLOAT):(this._useFullFloat=!1,o=e.Engine.TEXTURETYPE_UNSIGNED_INT),this._shadowMap=new e.RenderTargetTexture(r.name+"_shadowMap",i,this._scene,(!1),(!0),o,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),(!0),o),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 a=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;r4&&(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 h=r.join("\n");return this._cachedDefines!==h&&(this._cachedDefines=h,this._effect=this._scene.getEngine().createEffect("shadowMap",n,["world","mBones","viewProjection","diffuseMatrix","lightPosition","depthValues"],["diffuseSampler"],h)),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:e<=0?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;ti.x+r)&&(!(i.x-r>t.x)&&(!(e.y>i.y+r)&&(!(i.y-r>t.y)&&(!(e.z>i.z+r)&&!(i.z-r>t.z)))))},i=(function(){var e={root:0,found:!1};return function(t,i,r,n){e.root=0,e.found=!1;var o=i*i-4*t*r;if(o<0)return e;var s=Math.sqrt(o),a=(-i-s)/(2*t),h=(-i+s)/(2*t);if(a>h){var c=h;h=a,a=c}return a>0&&a0&&h=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)&&!!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),d=e.Vector3.Dot(l.normal,this.velocity);if(0==d){if(Math.abs(u)>=1)return;c=!0,h=0}else{h=(-1-u)/d;var f=(1-u)/d;if(h>f){var p=f;f=h,h=p}if(h>1||f<0)return;h<0&&(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 A=this._edge.lengthSquared(),E=e.Vector3.Dot(this._edge,this.velocity),T=e.Vector3.Dot(this._edge,this._baseToVertex);if(v=A*-g+E*E,y=A*(2*e.Vector3.Dot(this.velocity,this._baseToVertex))-2*E*T,x=A*(1-this._baseToVertex.lengthSquared())+T*T,b=i(v,y,x,m),b.found){var P=(E*b.root-T)/A;P>=0&&P<=1&&(m=b.root,_=!0,this._edge.scaleInPlace(P),n.addToRef(this._edge,this._collisionPoint))}s.subtractToRef(o,this._edge),o.subtractToRef(this.basePoint,this._baseToVertex),A=this._edge.lengthSquared(),E=e.Vector3.Dot(this._edge,this.velocity),T=e.Vector3.Dot(this._edge,this._baseToVertex),v=A*-g+E*E,y=A*(2*e.Vector3.Dot(this.velocity,this._baseToVertex))-2*E*T,x=A*(1-this._baseToVertex.lengthSquared())+T*T,b=i(v,y,x,m),b.found&&(P=(E*b.root-T)/A,P>=0&&P<=1&&(m=b.root,_=!0,this._edge.scaleInPlace(P),o.addToRef(this._edge,this._collisionPoint))),n.subtractToRef(s,this._edge),s.subtractToRef(this.basePoint,this._baseToVertex),A=this._edge.lengthSquared(),E=e.Vector3.Dot(this._edge,this.velocity),T=e.Vector3.Dot(this._edge,this._baseToVertex),v=A*-g+E*E,y=A*(2*e.Vector3.Dot(this.velocity,this._baseToVertex))-2*E*T,x=A*(1-this._baseToVertex.lengthSquared())+T*T,b=i(v,y,x,m),b.found&&(P=(E*b.root-T)/A,P>=0&&P<=1&&(m=b.root,_=!0,this._edge.scaleInPlace(P),s.addToRef(this._edge,this._collisionPoint)))}if(_){var M=m*this.velocity.length();(!this.collisionFound||M4)){++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})();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()||[])}},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;h0&&this._postProcesses[0].markTextureDirty();for(var t=0,i=this._rigCameras.length;t-1?(e.Tools.Error("You're trying to reuse a post process not defined as reusable."),0):(null==i||i<0?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);o!==-1&&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._refreshFrustumPlanes=!0,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.freezeProjectionMatrix=function(e){this._doNotComputeProjectionMatrix=!0,void 0!==e&&(this._projectionMatrix=e)},i.prototype.unfreezeProjectionMatrix=function(){this._doNotComputeProjectionMatrix=!1},i.prototype.getProjectionMatrix=function(t){if(this._doNotComputeProjectionMatrix||!t&&this._isSynchronizedProjectionMatrix())return this._projectionMatrix;this._refreshFrustumPlanes=!0;var r=this.getEngine(),n=this.getScene();if(this.mode===i.PERSPECTIVE_CAMERA)return this.minZ<=0&&(this.minZ=.1),n.useRightHandedSystem?e.Matrix.PerspectiveFovRHToRef(this.fov,r.getAspectRatio(this),this.minZ,this.maxZ,this._projectionMatrix,this.fovMode===i.FOVMODE_VERTICAL_FIXED):e.Matrix.PerspectiveFovLHToRef(this.fov,r.getAspectRatio(this),this.minZ,this.maxZ,this._projectionMatrix,this.fovMode===i.FOVMODE_VERTICAL_FIXED), +this._projectionMatrix;var o=r.getRenderWidth()/2,s=r.getRenderHeight()/2;return n.useRightHandedSystem?e.Matrix.OrthoOffCenterRHToRef(this.orthoLeft||-o,this.orthoRight||o,this.orthoBottom||-s,this.orthoTop||s,this.minZ,this.maxZ,this._projectionMatrix):e.Matrix.OrthoOffCenterLHToRef(this.orthoLeft||-o,this.orthoRight||o,this.orthoBottom||-s,this.orthoTop||s,this.minZ,this.maxZ,this._projectionMatrix),this._projectionMatrix},i.prototype.getTranformationMatrix=function(){return this._computedViewMatrix.multiplyToRef(this._projectionMatrix,this._transformMatrix),this._transformMatrix},i.prototype.updateFrustumPlanes=function(){this._refreshFrustumPlanes&&(this.getTranformationMatrix(),this._frustumPlanes?e.Frustum.GetPlanesToRef(this._transformMatrix,this._frustumPlanes):this._frustumPlanes=e.Frustum.GetPlanes(this._transformMatrix),this._refreshFrustumPlanes=!1)},i.prototype.isInFrustum=function(e){return this.updateFrustumPlanes(),e.isInFrustum(this._frustumPlanes)},i.prototype.isCompletelyInFrustum=function(e){return this.updateFrustumPlanes(),e.isCompletelyInFrustum(this._frustumPlanes)},i.prototype.dispose=function(){for(this.getScene().stopAnimation(this),this.getScene().removeCamera(this);this._rigCameras.length>0;)this._rigCameras.pop().dispose();for(var e=this._postProcesses.length;--e>=0;)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));break;case i.RIG_MODE_WEBVR:r.vrDisplay&&(this._rigCameras[0].viewport=new e.Viewport(0,0,.5,1),this._rigCameras[0].setCameraRigParameter("left",!0),this._rigCameras[0].setCameraRigParameter("frameData",r.frameData),this._rigCameras[0]._cameraRigParams.vrWorkMatrix=new e.Matrix,this._rigCameras[0].getProjectionMatrix=this._getWebVRProjectionMatrix,this._rigCameras[1].viewport=new e.Viewport(.5,0,.5,1),this._rigCameras[1].setCameraRigParameter("frameData",r.frameData),this._rigCameras[1]._cameraRigParams.vrWorkMatrix=new e.Matrix,this._rigCameras[1].getProjectionMatrix=this._getWebVRProjectionMatrix)}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._getWebVRProjectionMatrix=function(){var t=this._cameraRigParams.left?this._cameraRigParams.frameData.leftProjectionMatrix:this._cameraRigParams.frameData.rightProjectionMatrix;return[8,9,10,11].forEach((function(e){t[e]*=-1})),e.Matrix.FromArrayToRef(t,0,this._projectionMatrix),this._projectionMatrix},i.prototype._getWebVRViewMatrix=function(){var t=this._cameraRigParams.left?this._cameraRigParams.frameData.leftViewMatrix:this._cameraRigParams.frameData.rightViewMatrix;return[8,9,10,11].forEach((function(e){t[e]*=-1})),e.Matrix.FromArrayToRef(t,0,this._webvrViewMatrix),this._webvrViewMatrix},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=0&&r._keys.splice(t,1),i||e.preventDefault()}},t.addEventListener("keydown",this._onKeyDown,!1),t.addEventListener("keyup",this._onKeyUp,!1),e.Tools.RegisterTopRootEvents([{name:"blur",handler:this._onLostFocus}]))},t.prototype.detachControl=function(t){this._onKeyDown&&(t.removeEventListener("keydown",this._onKeyDown),t.removeEventListener("keyup",this._onKeyUp),e.Tools.UnregisterTopRootEvents([{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;i1)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"},t})();__decorate([e.serialize()],t.prototype,"touchAngularSensibility",void 0),__decorate([e.serialize()],t.prototype,"touchMoveSensibility",void 0),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),this._orientationChanged()},t.prototype.detachControl=function(e){window.removeEventListener("orientationchange",this._orientationChanged),window.removeEventListener("deviceorientation",this._deviceOrientation)},t.prototype.checkInputs=function(){this._alpha&&(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 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"},t})();__decorate([e.serialize()],t.prototype,"gamepadAngularSensibility",void 0),__decorate([e.serialize()],t.prototype,"gamepadMoveSensibility",void 0),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;t.tabIndex=1,this._onKeyDown=function(e){if(r.keysUp.indexOf(e.keyCode)!==-1||r.keysDown.indexOf(e.keyCode)!==-1||r.keysLeft.indexOf(e.keyCode)!==-1||r.keysRight.indexOf(e.keyCode)!==-1){var t=r._keys.indexOf(e.keyCode);t===-1&&r._keys.push(e.keyCode),e.preventDefault&&(i||e.preventDefault())}},this._onKeyUp=function(e){if(r.keysUp.indexOf(e.keyCode)!==-1||r.keysDown.indexOf(e.keyCode)!==-1||r.keysLeft.indexOf(e.keyCode)!==-1||r.keysRight.indexOf(e.keyCode)!==-1){var t=r._keys.indexOf(e.keyCode);t>=0&&r._keys.splice(t,1),e.preventDefault&&(i||e.preventDefault())}},this._onLostFocus=function(){r._keys=[]},t.addEventListener("keydown",this._onKeyDown,!1),t.addEventListener("keyup",this._onKeyUp,!1),e.Tools.RegisterTopRootEvents([{name:"blur",handler:this._onLostFocus}])},t.prototype.detachControl=function(t){t&&(t.removeEventListener("keydown",this._onKeyDown),t.removeEventListener("keyup",this._onKeyUp)),e.Tools.UnregisterTopRootEvents([{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.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"},t})();__decorate([e.serialize()],t.prototype,"gamepadRotationSensibility",void 0),__decorate([e.serialize()],t.prototype,"gamepadMoveSensibility",void 0),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){var o=t.call(this,i,r,n)||this;return o.cameraDirection=new e.Vector3(0,0,0),o.cameraRotation=new e.Vector2(0,0),o.rotation=new e.Vector3(0,0,0),o.speed=2,o.noRotationConstraint=!1,o.lockedTarget=null,o._currentTarget=e.Vector3.Zero(),o._viewMatrix=e.Matrix.Zero(),o._camMatrix=e.Matrix.Zero(),o._cameraTransformMatrix=e.Matrix.Zero(),o._cameraRotationMatrix=e.Matrix.Zero(),o._referencePoint=new e.Vector3(0,0,1),o._defaultUpVector=new e.Vector3(0,1,0),o._transformedReferencePoint=e.Vector3.Zero(),o._lookAtTemp=e.Matrix.Zero(),o._tempMatrix=e.Matrix.Zero(),o}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.absolutePosition&&this.lockedTarget.computeWorldMatrix(),this.lockedTarget.absolutePosition||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*Math.sqrt(e.getDeltaTime()/(100*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.Engine.CollisionsEpsilon&&(o.position.addInPlace(o._diffPosition),o.onCollide&&r&&o.onCollide(r))};n(i)},o.inputs=new e.FreeCameraInputsManager(o),o.inputs.addKeyboard().addMouse(),o}return __extends(i,t),Object.defineProperty(i.prototype,"angularSensibility",{get:function(){var e=this.inputs.attached.mouse;if(e)return e.angularSensibility},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;if(e)return e.keysUp},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;if(e)return e.keysDown},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;if(e)return e.keysLeft},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;if(e)return e.keysRight},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.getClassName=function(){return"FreeCamera"},i})(e.TargetCamera);__decorate([e.serializeAsVector3()],t.prototype,"ellipsoid",void 0),__decorate([e.serialize()],t.prototype,"checkCollisions",void 0),__decorate([e.serialize()],t.prototype,"applyGravity",void 0),e.FreeCamera=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(e){return t.call(this,e)||this}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.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){var o=t.call(this,e,i,r)||this;return o.radius=12,o.rotationOffset=0,o.heightOffset=4,o.cameraAcceleration=.05,o.maxCameraSpeed=20,o.lockedTarget=n,o}return __extends(i,t),i.prototype.getRadians=function(e){return e*Math.PI/180},i.prototype.follow=function(t){if(t){var i;if(t.rotationQuaternion){var r=new e.Matrix;t.rotationQuaternion.toRotationMatrix(r),i=Math.atan2(r.m[8],r.m[10])}else i=t.rotation.y;var n=this.getRadians(this.rotationOffset)+i,o=t.position.x+Math.sin(n)*this.radius,s=t.position.z+Math.cos(n)*this.radius,a=o-this.position.x,h=t.position.y+this.heightOffset-this.position.y,c=s-this.position.z,l=a*this.cameraAcceleration*2,u=h*this.cameraAcceleration,d=c*this.cameraAcceleration*2;(l>this.maxCameraSpeed||l<-this.maxCameraSpeed)&&(l=l<1?-this.maxCameraSpeed:this.maxCameraSpeed),(u>this.maxCameraSpeed||u<-this.maxCameraSpeed)&&(u=u<1?-this.maxCameraSpeed:this.maxCameraSpeed),(d>this.maxCameraSpeed||d<-this.maxCameraSpeed)&&(d=d<1?-this.maxCameraSpeed:this.maxCameraSpeed),this.position=new e.Vector3(this.position.x+l,this.position.y+u,this.position.z+d),this.setTarget(t.position)}},i.prototype._checkInputs=function(){t.prototype._checkInputs.call(this),this.follow(this.lockedTarget)},i.prototype.getClassName=function(){return"FollowCamera"},i})(e.TargetCamera);__decorate([e.serialize()],t.prototype,"radius",void 0),__decorate([e.serialize()],t.prototype,"rotationOffset",void 0),__decorate([e.serialize()],t.prototype,"heightOffset",void 0),__decorate([e.serialize()],t.prototype,"cameraAcceleration",void 0),__decorate([e.serialize()],t.prototype,"maxCameraSpeed",void 0),__decorate([e.serializeAsMeshReference("lockedTargetId")],t.prototype,"lockedTarget",void 0),e.FollowCamera=t;var i=(function(t){function i(i,r,n,o,s,a){var h=t.call(this,i,e.Vector3.Zero(),a)||this;return h.alpha=r,h.beta=n,h.radius=o,h.target=s,h._cartesianCoordinates=e.Vector3.Zero(),h.follow(),h}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.getClassName=function(){return"ArcFollowCamera"},i})(e.TargetCamera);e.ArcFollowCamera=i})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(e){function t(t,i,r){var n=e.call(this,t,i,r)||this;return n.inputs.addTouch(),n._setupInputs(),n}return __extends(t,e),Object.defineProperty(t.prototype,"touchAngularSensibility",{get:function(){var e=this.inputs.attached.touch;if(e)return e.touchAngularSensibility},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;if(e)return e.touchMoveSensibility},set:function(e){var t=this.inputs.attached.touch;t&&(t.touchMoveSensibility=e)},enumerable:!0,configurable:!0}),t.prototype.getClassName=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=t.call(this,i,e.Vector3.Zero(),a)||this;return h.inertialAlphaOffset=0,h.inertialBetaOffset=0,h.inertialRadiusOffset=0,h.lowerAlphaLimit=null,h.upperAlphaLimit=null,h.lowerBetaLimit=.01,h.upperBetaLimit=Math.PI,h.lowerRadiusLimit=null,h.upperRadiusLimit=null,h.inertialPanningX=0,h.inertialPanningY=0,h.zoomOnFactor=1,h.targetScreenOffset=e.Vector2.Zero(),h.allowUpsideDown=!0,h._viewMatrix=new e.Matrix,h.panningAxis=new e.Vector3(1,1,0),h.checkCollisions=!1,h.collisionRadius=new e.Vector3(.5,.5,.5),h._collider=new e.Collider,h._previousPosition=e.Vector3.Zero(),h._collisionVelocity=e.Vector3.Zero(),h._newPosition=e.Vector3.Zero(),h._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?h.target=s:h.target=e.Vector3.Zero(),h.alpha=r,h.beta=n,h.radius=o,h.getViewMatrix(),h.inputs=new e.ArcRotateCameraInputsManager(h),h.inputs.addKeyboard().addMouseWheel().addPointers().addGamepad(),h}return __extends(i,t),Object.defineProperty(i.prototype,"angularSensibilityX",{get:function(){var e=this.inputs.attached.pointers;if(e)return e.angularSensibilityX},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;if(e)return e.angularSensibilityY},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;if(e)return e.pinchPrecision},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;if(e)return e.panningSensibility},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;if(e)return e.keysUp},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;if(e)return e.keysDown},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;if(e)return e.keysLeft},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;if(e)return e.keysRight},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;if(e)return e.wheelPrecision},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(){if(this.target.getAbsolutePosition){var e=this.target.getAbsolutePosition();return this._targetBoundingCenter?e.add(this._targetBoundingCenter):e}return 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))},i.prototype.attachControl=function(e,t,i,r){var n=this;void 0===i&&(i=!0),void 0===r&&(r=2),this._useCtrlForPanning=i,this._panningMouseButton=r,this.inputs.attachElement(e,t),this._reset=function(){n.inertialAlphaOffset=0,n.inertialBetaOffset=0,n.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.getScene().useRightHandedSystem?this.alpha-=this.beta<=0?-this.inertialAlphaOffset:this.inertialAlphaOffset: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)Math.PI&&(this.beta=this.beta-2*Math.PI):this.betathis.upperBetaLimit&&(this.beta=this.upperBetaLimit),this.lowerAlphaLimit&&this.alphathis.upperAlphaLimit&&(this.alpha=this.upperAlphaLimit),this.lowerRadiusLimit&&this.radiusthis.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.copyFrom(e),this.rebuildAnglesAndRadius())},i.prototype.setTarget=function(e,t){void 0===t&&(t=!1),this._getTargetPosition().equals(e)||(t&&e.getBoundingInfo?this._targetBoundingCenter=e.getBoundingInfo().boundingBox.center.clone():this._targetBoundingCenter=null,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()),this.getScene().useRightHandedSystem?e.Matrix.LookAtRHToRef(this.position,o,s,this._viewMatrix):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._currentTarget=o,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.getClassName=function(){return"ArcRotateCamera"},i})(e.TargetCamera);__decorate([e.serialize()],t.prototype,"alpha",void 0),__decorate([e.serialize()],t.prototype,"beta",void 0),__decorate([e.serialize()],t.prototype,"radius",void 0),__decorate([e.serializeAsVector3()],t.prototype,"target",void 0),__decorate([e.serialize()],t.prototype,"inertialAlphaOffset",void 0),__decorate([e.serialize()],t.prototype,"inertialBetaOffset",void 0),__decorate([e.serialize()],t.prototype,"inertialRadiusOffset",void 0),__decorate([e.serialize()],t.prototype,"lowerAlphaLimit",void 0),__decorate([e.serialize()],t.prototype,"upperAlphaLimit",void 0),__decorate([e.serialize()],t.prototype,"lowerBetaLimit",void 0),__decorate([e.serialize()],t.prototype,"upperBetaLimit",void 0),__decorate([e.serialize()],t.prototype,"lowerRadiusLimit",void 0),__decorate([e.serialize()],t.prototype,"upperRadiusLimit",void 0),__decorate([e.serialize()],t.prototype,"inertialPanningX",void 0),__decorate([e.serialize()],t.prototype,"inertialPanningY",void 0),__decorate([e.serialize()],t.prototype,"zoomOnFactor",void 0),__decorate([e.serialize()],t.prototype,"allowUpsideDown",void 0),e.ArcRotateCamera=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(e){return t.call(this,e)||this}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._autoClearDepthStencil={},this._customOpaqueSortCompareFn={},this._customAlphaTestSortCompareFn={},this._customTransparentSortCompareFn={},this._renderinGroupInfo=null,this._scene=e;for(var i=t.MIN_RENDERINGGROUPS;ii._alphaIndex?1:e._alphaIndext._distanceToCamera?-1:0},t.frontToBackSortCompare=function(e,t){return e._distanceToCamerat._distanceToCamera?1:0},t.prototype.prepare=function(){this._opaqueSubMeshes.reset(),this._transparentSubMeshes.reset(),this._alphaTestSubMeshes.reset(),this._particleSystems.reset(),this._spriteManagers.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.prototype.dispatchSprites=function(e){this._spriteManagers.push(e)},t.prototype.dispatchParticles=function(e){this._particleSystems.push(e)},t.prototype._renderParticles=function(e){if(0!==this._particleSystems.length){var t=this._scene.activeCamera;this._scene._particlesDuration.beginMonitoring();for(var i=0;ie.ActionManager.LongPressDelay&&Math.abs(l._startingPointerPosition.x-l._pointerX)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&&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(e){return e.isPickable&&e.isVisible&&e.isReady()});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)),c.pickedMesh.actionManager&&Math.abs(a._startingPointerPosition.x-a._pointerX)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)),c.pickedSprite.actionManager&&Math.abs(a._startingPointerPosition.x-a._pointerX)0)return!1;var t;for(t=0;t0)return;this._animationTimeLast=t}var i=(t-this._animationTimeLast)*this.animationTimeScale;this._animationTime+=i,this._animationTimeLast=t;for(var r=0;r0?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.switchActiveCamera=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-1&&(this._geometries.splice(t,1),this.collisionCoordinator.onGeometryDeleted(e),this.onGeometryRemovedObservable.notifyObservers(e),!0)},i.prototype.getGeometries=function(){return this._geometries},i.prototype.getMeshByID=function(e){for(var t=0;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=0;t--)if(this.skeletons[t].id===e)return this.skeletons[t];return null},i.prototype.getSkeletonById=function(e){for(var t=0;t0&&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(o,s)))}}this._particlesDuration.beginMonitoring();e.Tools.Now;if(this.particlesEnabled){e.Tools.StartPerformanceCounter("Particles",this.particleSystems.length>0);for(var a=0;a0)}this._particlesDuration.endMonitoring(!1)},i.prototype._activeMesh=function(e,t){if(t.skeleton&&this.skeletonsEnabled&&(this._activeSkeletons.pushNoDuplicate(t.skeleton)&&t.skeleton.prepare(),t.computeBonesUsingShaders||this._softwareSkinnedMeshes.pushNoDuplicate(t)),(e.showBoundingBox||this.forceShowBoundingBoxes)&&this._boundingBoxRenderer.renderList.push(e.getBoundingInfo().boundingBox),e._edgesRenderer&&this._edgesRenderers.push(e._edgesRenderer),t&&t.subMeshes){var i,r;if(t._submeshesOctree&&t.useOctreeForRenderingSelection){var n=t._submeshesOctree.select(this._frustumPlanes);i=n.length,r=n.data}else r=t.subMeshes,i=r.length;for(var o=0;o0){this._intermediateRendering=!0,e.Tools.StartPerformanceCounter("Render targets",this._renderTargets.length>0);for(var s=0;s0),this._intermediateRendering=!1,this._renderId++,o=!0}var c=this._engine.getStencilBuffer(),l=!1;if(this.renderTargetsEnabled&&this.highlightLayers&&this.highlightLayers.length>0){this._intermediateRendering=!0;for(var u=0;u-1)){l=!0;var a=d._mainTexture;a._shouldRender()&&(this._renderId++,a.render(!1,!1),o=!0)}}this._intermediateRendering=!1,this._renderId++}o&&i.restoreDefaultFramebuffer(),this._renderTargetsDuration.endMonitoring(!1),this.postProcessManager._prepareFrame(),this._renderDuration.beginMonitoring();var f,p;if(this.layers.length){for(i.setDepthBuffer(!1),f=0;f0);for(var m=0;m0)}if(this.layers.length){for(i.setDepthBuffer(!1),f=0;f-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(){this._lastFrameDuration.beginMonitoring(),this._particlesDuration.fetchNewFrame(),this._spritesDuration.fetchNewFrame(),this._activeParticles.fetchNewFrame(),this._renderDuration.fetchNewFrame(),this._renderTargetsDuration.fetchNewFrame(),this._evaluateActiveMeshesDuration.fetchNewFrame(),this._totalVertices.fetchNewFrame(),this._activeIndices.fetchNewFrame(),this._activeBones.fetchNewFrame(),this.getEngine().drawCallsPerfCounter.fetchNewFrame(),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 t=Math.max(i.MinDeltaTime,Math.min(this._engine.getDeltaTime(),i.MaxDeltaTime));this._animationRatio=.06*t,this._animate(),this._physicsEngine&&(e.Tools.StartPerformanceCounter("Physics"),this._physicsEngine._step(t/1e3),e.Tools.EndPerformanceCounter("Physics")),this.onBeforeRenderObservable.notifyObservers(this),this._renderTargetsDuration.beginMonitoring();var r=(e.Tools.Now,this.getEngine()),n=this.activeCamera;if(this.renderTargetsEnabled){e.Tools.StartPerformanceCounter("Custom render targets",this.customRenderTargets.length>0);for(var o=0;o0),this._renderId++}if(this.customRenderTargets.length>0&&r.restoreDefaultFramebuffer(),this._renderTargetsDuration.endMonitoring(),this.activeCamera=n,this.proceduralTexturesEnabled){e.Tools.StartPerformanceCounter("Procedural textures",this._proceduralTextures.length>0);for(var a=0;a0)}if(this._engine.clear(this.clearColor,this.autoClear||this.forceWireframe||this.forcePointsCloud,!0,!0),this.shadowsEnabled)for(var c=0;c0)for(var d=0;d0&&this._engine.clear(null,!1,!0,!0),this._processSubCameras(this.activeCameras[d]);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 f=0;f0?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-1&&this._engine.scenes.splice(t,1),this._engine.wipeCaches()},i.prototype.disposeSounds=function(){this.mainSoundTrack.dispose();for(var e=0;e=n.distance))&&(n=c,r))break}return n||new e.PickingInfo},i.prototype._internalMultiPick=function(e,t){for(var i=new Array,r=0;r0)for(var s=0;s=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.multiPick=function(e,t,i,r){var n=this;return this._internalMultiPick((function(i){return n.createPickingRay(e,t,i,r)}),i)},i.prototype.multiPickWithRay=function(t,i){var r=this;return this._internalMultiPick((function(i){return r._pickWithRayInverseMatrix||(r._pickWithRayInverseMatrix=e.Matrix.Identity()),i.invertToRef(r._pickWithRayInverseMatrix),e.Ray.Transform(t,r._pickWithRayInverseMatrix)}),i)},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;n0},enumerable:!0,configurable:!0}),r.prototype._sortLODLevels=function(){this._LODLevels.sort((function(e,t){return e.distancet.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;ti)return this.onLODLevelSelection&&this.onLODLevelSelection(i,this,this._LODLevels[this._LODLevels.length-1].mesh),this;for(var r=0;r=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,i=this._geometry.copy(e.Geometry.RandomId());t.releaseForMesh(this,!0),i.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-1&&(o.skeleton=i.getLastSkeletonByID(t.skeletonId),t.numBoneInfluencers&&(o.numBoneInfluencers=t.numBoneInfluencers)),t.animations){for(var s=0;s4,c=h?this.getVerticesData(e.VertexBuffer.MatricesIndicesExtraKind):null,l=h?this.getVerticesData(e.VertexBuffer.MatricesWeightsExtraKind):null,u=t.getTransformMatrices(this),d=e.Vector3.Zero(),f=new e.Matrix,p=new e.Matrix,_=0,m=0;m0);o++)e.Matrix.FromFloat32ArrayToRefScaled(u,16*s[_+o],g,p),f.addToSelf(p);if(h)for(o=0;o<4&&(g=l[_+o],g>0);o++)e.Matrix.FromFloat32ArrayToRefScaled(u,16*c[_+o],g,p),f.addToSelf(p);e.Vector3.TransformCoordinatesFromFloatsToRef(this._sourcePositions[m],this._sourcePositions[m+1],this._sourcePositions[m+2],f,d),d.toArray(r,m),e.Vector3.TransformNormalFromFloatsToRef(this._sourceNormals[m],this._sourceNormals[m+1],this._sourceNormals[m+2],f,d),d.toArray(n,m),f.reset()}return this.updateVerticesData(e.VertexBuffer.PositionKind,r),this.updateVerticesData(e.VertexBuffer.NormalKind,n),this}},r.MinMax=function(e){var t=null,i=null;return e.forEach((function(e,r,n){var o=e.getBoundingInfo().boundingBox;t?(t.MinimizeInPlace(o.minimumWorld),i.MaximizeInPlace(o.maximumWorld)):(t=o.minimumWorld,i=o.maximumWorld)})),{min:t,max:i}},r.Center=function(t){var i=t instanceof Array?e.Mesh.MinMax(t):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;s65536))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;sa&&(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.updateSideOrientation=function(t,i){return t==e.Mesh.DOUBLESIDE?e.Mesh.DOUBLESIDE:void 0===t||null===t?e.Mesh.FRONTSIDE:t},t.CreateBox=function(t,i,r){var n=new e.Mesh(t,r);i.sideOrientation=this.updateSideOrientation(i.sideOrientation,r),n.sideOrientation=i.sideOrientation;var 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);i.sideOrientation=this.updateSideOrientation(i.sideOrientation,r),n.sideOrientation=i.sideOrientation;var 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);i.sideOrientation=this.updateSideOrientation(i.sideOrientation,r),n.sideOrientation=i.sideOrientation;var 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);i.sideOrientation=this.updateSideOrientation(i.sideOrientation,r),n.sideOrientation=i.sideOrientation;var 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,this.updateSideOrientation(i.sideOrientation,r)),h=i.instance,c=i.updatable;if(h){e.Vector3.FromFloatsToRef(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,e.Tmp.Vector3[0]),e.Vector3.FromFloatsToRef(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE,e.Tmp.Vector3[1]);var l=function(t){for(var i=n[0].length,r=0,o=h.sideOrientation===e.Mesh.DOUBLESIDE?2:1,s=1;s<=o;s++)for(var a=0;ae.Tmp.Vector3[1].x&&(e.Tmp.Vector3[1].x=c[u].x),c[u].ye.Tmp.Vector3[1].y&&(e.Tmp.Vector3[1].y=c[u].y),c[u].ze.Tmp.Vector3[1].z&&(e.Tmp.Vector3[1].z=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._boundingInfo=new e.BoundingInfo(e.Tmp.Vector3[0],e.Tmp.Vector3[1]),h._boundingInfo.update(h._worldMatrix),h.updateVerticesData(e.VertexBuffer.PositionKind,u,!1,!1),!h.areNormalsFrozen){var d=h.getIndices(),f=h.getVerticesData(e.VertexBuffer.NormalKind);if(e.VertexData.ComputeNormals(u,d,f),h._closePath)for(var p=0,_=0,m=0;m1?1:r.arc:1,a=void 0===r.closed||r.closed,h=r.shape,c=r.radius||1,l=r.tessellation||64,u=r.updatable,d=this.updateSideOrientation(r.sideOrientation,n),f=r.cap||e.Mesh.NO_CAP,p=2*Math.PI,_=new Array,m=r.invertUV||!1,g=0,v=0,y=p/l*s,x=new Array;for(g=0;g<=l;g++){var x=[];for(f!=e.Mesh.CAP_START&&f!=e.Mesh.CAP_ALL||(x.push(new e.Vector3(0,h[0].y,0)),x.push(new e.Vector3(Math.cos(g*y)*h[0].x*c,h[0].y,Math.sin(g*y)*h[0].x*c))),v=0;v1?1:r.arc||1;var p,_,m=function(t,i,r,n,o,s,a,h){for(var c,l,u,d,f=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,A=0;A3?0:c,_=m(o,p,v,s,a,h,c,r.arc);var y=t.CreateRibbon(i,{pathArray:_,closePath:!0,closeArray:!1,updatable:u,sideOrientation:d,invertUV:l},n);return y.pathArray=_,y.path3D=p,y.tessellation=a,y.cap=c,y.arc=r.arc,y},t.CreatePolyhedron=function(t,i,r){var n=new e.Mesh(t,r);i.sideOrientation=this.updateSideOrientation(i.sideOrientation,r),n.sideOrientation=i.sideOrientation;var 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),d=i.getScene().activeCamera,f=e.Vector3.TransformCoordinates(u,d.getWorldMatrix());h=d.globalPosition.subtract(f)}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 A=0,E=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;s0,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],d=t[s+2],f=n(t[s],u),p=n(t[s],d)),h){u=t[s],d=t[s+2],f=n(t[s+1],u),p=n(t[s+1],d),o.push(f),o.push(d.clone()),o.push(u.clone()),o.push(d.clone()),o.push(f.clone()),o.push(p);break}l&&(u=t[s],d=t[s+1],f=n(t[s+2],u),p=n(t[s+2],d)),o.push(u.clone()),o.push(d.clone()),o.push(f),o.push(p),o.push(f.clone()),o.push(d.clone());break;case 2:a||(u=t[s].clone(),d=n(u,t[s+1]),f=n(u,t[s+2]),o.push(u),o.push(d),o.push(f)),h||(u=t[s+1].clone(),d=n(u,t[s+2]),f=n(u,t[s]),o.push(u),o.push(d),o.push(f)),l||(u=t[s+2].clone(),d=n(u,t[s]),f=n(u,t[s+1]),o.push(u),o.push(d),o.push(f));break;case 3:}}return o},P=0;P3?0:u,y=x(r,n,v,b,o,s,a,h,u,d);var A=t.CreateRibbon(i,{pathArray:y,closeArray:c,closePath:l,updatable:p,sideOrientation:_,invertUV:g},f);return A.pathArray=y,A.path3D=v,A.cap=u,A},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),this._uid=null}return Object.defineProperty(t.prototype,"uid",{get:function(){return this._uid||(this._uid=e.Tools.RandomId()),this._uid},enumerable:!0,configurable:!0}),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||!!this._texture&&this._texture.isReady},t.prototype.getSize=function(){return this._texture._width?new e.Size(this._texture._width,this._texture._height):this._texture._size?new e.Size(this._texture._size,this._texture._size):e.Size.Zero()},t.prototype.getBaseSize=function(){return this.isReady()&&this._texture?this._texture._size?new e.Size(this._texture._size,this._texture._size):new e.Size(this._texture._baseWidth,this._texture._baseHeight):e.Size.Zero()},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=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},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),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===o&&(o=!1),void 0===s&&(s=!0),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);var d=t.call(this,n)||this;if(d.uOffset=0,d.vOffset=0,d.uScale=1,d.vScale=1,d.uAng=0,d.vAng=0,d.wAng=0,d.name=r,d.url=r,d._noMipmap=o,d._invertY=s,d._samplingMode=a,d._buffer=l,d._deleteBuffer=u,!r)return d;d._texture=d._getFromCache(r,o,a);var f=function(){d._onLoadObservarble&&d._onLoadObservarble.hasObservers()&&d.onLoadObservable.notifyObservers(!0),h&&h()};return d._texture?d._texture.isReady?e.Tools.SetImmediate((function(){return f()})):d._texture.onLoadedCallbacks.push(f):n.useDelayedTextureLoading?(d.delayLoadState=e.Engine.DELAYLOADSTATE_NOTLOADED,d._delayedOnLoad=f,d._delayedOnError=c):(d._texture=n.getEngine().createTexture(r,o,s,n,d._samplingMode,f,c,d._buffer),u&&delete d._buffer),d}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)},Object.defineProperty(i.prototype,"onLoadObservable",{get:function(){return this._onLoadObservarble||(this._onLoadObservarble=new e.Observable),this._onLoadObservarble},enumerable:!0,configurable:!0}),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.customType){var o=e.Tools.Instantiate(t.customType);return o.Parse(t,r,n)}if(t.isCube)return e.CubeTexture.Parse(t,r,n);if(!t.name&&!t.isRenderTarget)return null;var s=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 a=0;a=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,s,a,h){void 0===s&&(s=e.Engine.TEXTURETYPE_UNSIGNED_INT),void 0===a&&(a=e.Texture.BILINEAR_SAMPLINGMODE),void 0===h&&(h=!0);var c=t.call(this,i,r,n,o,!0,s,!1,a,h)||this;return c.mirrorPlane=new e.Plane(0,1,0,1),c._transformMatrix=e.Matrix.Zero(),c._mirrorMatrix=e.Matrix.Zero(),c.onBeforeRenderObservable.add((function(){e.Matrix.ReflectionToRef(c.mirrorPlane,c._mirrorMatrix),c._savedViewMatrix=n.getViewMatrix(),c._mirrorMatrix.multiplyToRef(c._savedViewMatrix,c._transformMatrix),n.setTransformMatrix(c._transformMatrix,n.getProjectionMatrix()),n.clipPlane=c.mirrorPlane,n.getEngine().cullBackFaces=!1,n._mirroredCameraPosition=e.Vector3.TransformCoordinates(n.activeCamera.position,c._mirrorMatrix)})),c.onAfterRenderObservable.add((function(){n.setTransformMatrix(c._savedViewMatrix,n.getProjectionMatrix()),n.getEngine().cullBackFaces=!0,n._mirroredCameraPosition=null,delete n.clipPlane})),c}return __extends(i,t),i.prototype.clone=function(){var e=this.getSize(),t=new i(this.name,e.width,this.getScene(),this._renderTargetOptions.generateMipMaps,this._renderTargetOptions.type,this._renderTargetOptions.samplingMode,this._renderTargetOptions.generateDepthBuffer);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=t.call(this,i,r,n,o,!0)||this;return s.refractionPlane=new e.Plane(0,1,0,1),s.depth=2,s.onBeforeRenderObservable.add((function(){n.clipPlane=s.refractionPlane})),s.onAfterRenderObservable.add((function(){delete n.clipPlane})),s}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);var a=t.call(this,null,n,!o)||this;a.name=i,a.wrapU=e.Texture.CLAMP_ADDRESSMODE,a.wrapV=e.Texture.CLAMP_ADDRESSMODE,a._generateMipMaps=o,r.getContext?(a._canvas=r,a._texture=n.getEngine().createDynamicTexture(r.width,r.height,o,s)):(a._canvas=document.createElement("canvas"),r.width?a._texture=n.getEngine().createDynamicTexture(r.width,r.height,o,s):a._texture=n.getEngine().createDynamicTexture(r,r,o,s));var h=a.getSize();return a._canvas.width=h.width,a._canvas.height=h.height,a._context=a._canvas.getContext("2d"),a}return __extends(i,t),Object.defineProperty(i.prototype,"canRescale",{get:function(){return!0},enumerable:!0,configurable:!0}),i.prototype.scale=function(e){var t=this.getSize();t.width*=e,t.height*=e,this._canvas.width=t.width,this._canvas.height=t.height,this.releaseInternalTexture(),this._texture=this.getScene().getEngine().createDynamicTexture(t.width,t.height,this._generateMipMaps,this._samplingMode)},i.prototype.getContext=function(){return this._context},i.prototype.clear=function(){var e=this.getSize();this._context.fillRect(0,0,e.width,e.height)},i.prototype.update=function(e){this.getScene().getEngine().updateDynamicTexture(this._texture,this._canvas,void 0===e||e)},i.prototype.drawText=function(e,t,i,r,n,o,s,a){void 0===a&&(a=!0);var h=this.getSize();if(o&&(this._context.fillStyle=o,this._context.fillRect(0,0,h.width,h.height)),this._context.font=r,null===t){var c=this._context.measureText(e);t=(h.width-c.width)/2}this._context.fillStyle=n,this._context.fillText(e,t,i),a&&this.update(s)},i.prototype.clone=function(){var e=this.getSize(),t=new i(this.name,e,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){void 0===o&&(o=!1),void 0===s&&(s=!1),void 0===a&&(a=e.Texture.TRILINEAR_SAMPLINGMODE);var h=t.call(this,null,n,!o,s)||this;h._autoLaunch=!0;var c;return h.name=i,r instanceof HTMLVideoElement?h.video=r:(c=r,h.video=document.createElement("video"),h.video.autoplay=!1,h.video.loop=!0),h._generateMipMaps=o,h._samplingMode=a,e.Tools.IsExponentOfTwo(h.video.videoWidth)&&e.Tools.IsExponentOfTwo(h.video.videoHeight)?(h.wrapU=e.Texture.WRAP_ADDRESSMODE,h.wrapV=e.Texture.WRAP_ADDRESSMODE):(h.wrapU=e.Texture.CLAMP_ADDRESSMODE,h.wrapV=e.Texture.CLAMP_ADDRESSMODE,h._generateMipMaps=!1),c?(h.video.addEventListener("canplaythrough",(function(){h._createTexture()})),c.forEach((function(e){var t=document.createElement("source");t.src=e,h.video.appendChild(t)}))):h._createTexture(),h._lastUpdate=e.Tools.Now,h}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)&&(this._lastUpdate=t,this.getScene().getEngine().updateVideoTexture(this._texture,this.video,this._invertY),!0)},i.CreateFromWebCam=function(t,i,r){var n=document.createElement("video");navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia,window.URL=window.URL||window.webkitURL||window.mozURL||window.msURL,navigator.getUserMedia&&navigator.getUserMedia({video:{width:{min:r&&r.minWidth||256,max:r&&r.maxWidth||640},height:{min:r&&r.minHeight||256,max:r&&r.maxHeight||480}}},(function(r){void 0!==n.mozSrcObject?n.mozSrcObject=r:n.src=window.URL&&window.URL.createObjectURL(r)||r,n.play(),i&&i(new e.VideoTexture("video",n,t,(!0),(!0)))}),(function(t){e.Tools.Error(t.name)}))},i})(e.Texture);e.VideoTexture=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(e,i,r,n,o,s){var a=t.call(this,e,r,null,n,o,s)||this;return a._animate=!0,a._time=0,a._texturePath=i,a.loadJson(i),a.refreshRate=1,a}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;tthis._maxRank&&(this._maxRank=e),this._defines[e]=new Array),this._defines[e].push(t)},e.prototype.addCPUSkinningFallback=function(e,t){this._meshRank=e,this._mesh=t,e>this._maxRank&&(this._maxRank=e)},Object.defineProperty(e.prototype,"isMoreFallbacks",{get:function(){return this._currentRank<=this._maxRank},enumerable:!0,configurable:!0}),e.prototype.reduce=function(e){for(var t=this._defines[this._currentRank],i=0;i-1?e:BABYLON.Engine.ShadersRepository+e,BABYLON.Tools.LoadFile(n+".vertex.fx",t)},Effect.prototype._loadFragmentShader=function(e,t){if(e instanceof HTMLElement){var i=BABYLON.Tools.GetDOMTextContent(e);return void t(i)}if("base64:"===e.substr(0,7)){var r=window.atob(e.substr(7));return void t(r)}if(Effect.ShadersStore[e+"PixelShader"])return void t(Effect.ShadersStore[e+"PixelShader"]);if(Effect.ShadersStore[e+"FragmentShader"])return void t(Effect.ShadersStore[e+"FragmentShader"]);var n;n="."===e[0]||"/"===e[0]||e.indexOf("http")>-1?e:BABYLON.Engine.ShadersRepository+e,BABYLON.Tools.LoadFile(n+".fragment.fx",t)},Effect.prototype._dumpShadersName=function(){this.name.vertexElement?(BABYLON.Tools.Error("Vertex shader:"+this.name.vertexElement),BABYLON.Tools.Error("Fragment shader:"+this.name.fragmentElement)):this.name.vertex?(BABYLON.Tools.Error("Vertex shader:"+this.name.vertex),BABYLON.Tools.Error("Fragment shader:"+this.name.fragment)):(BABYLON.Tools.Error("Vertex shader:"+this.name),BABYLON.Tools.Error("Fragment shader:"+this.name))},Effect.prototype._processIncludes=function(e,t){for(var i=this,r=/#include<(.+)>(\((.*)\))*(\[(.*)\])*/g,n=r.exec(e),o=new String(e);null!=n;){var s=n[1];if(!Effect.IncludesShadersStore[s]){var a=BABYLON.Engine.ShadersRepository+"ShadersInclude/"+s+".fx";return void BABYLON.Tools.LoadFile(a,(function(e){Effect.IncludesShadersStore[s]=e,i._processIncludes(o,t)}))}var h=Effect.IncludesShadersStore[s];if(n[2])for(var c=n[3].split(","),l=0;l0&&(result+=line+"\r\n")}return result},Effect.prototype._evaluateDefinesOnString=function(e){for(var t={children:[]},i=t,r=e.split("\n"),n=0;n0){for(var d=0;d0){for(var p=0;p0&&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=0&&this._scene.materials.splice(i,1),e&&this._effect&&(this._scene.getEngine()._releaseEffect(this._effect),this._effect=null),i=0;i0&&(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;a=!0,this._defines.EMISSIVE=!0}if(this.lightmapTexture&&r.LightmapTextureEnabled){if(!this.lightmapTexture.isReady())return!1;a=!0,this._defines.LIGHTMAP=!0,this._defines.USELIGHTMAPASSHADOWMAP=this.useLightmapAsShadowmap}if(this.specularTexture&&r.SpecularTextureEnabled){if(!this.specularTexture.isReady())return!1;a=!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;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&&r.RefractionTextureEnabled){if(!this.refractionTexture.isReady())return!1;a=!0,this._defines.REFRACTION=!0,this._defines.REFRACTIONMAP_3D=this.refractionTexture.isCube}if(this.cameraColorGradingTexture&&r.ColorGradingTextureEnabled){if(!this.cameraColorGradingTexture.isReady())return!1;this._defines.CAMERACOLORGRADING=!0}}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.cameraColorCurves&&(this._defines.CAMERACOLORCURVES=!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),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),h=!0,this._defines.FRESNEL=!0),this._defines.SPECULARTERM&&this.useSpecularOverAlpha&&(this._defines.SPECULAROVERALPHA=!0),i&&(h&&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),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",d=this._defines.toString(),f=["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"];this._defines.CAMERACOLORCURVES&&e.ColorCurves.PrepareUniforms(f),this._defines.CAMERACOLORGRADING&&e.ColorGradingTexture.PrepareUniformsAndSamplers(f,p),e.MaterialHelper.PrepareUniformsAndSamplersList(f,p,this._defines,this.maxSimultaneousLights),this._effect=o.getEngine().createEffect(u,l,f,p,d,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)},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){if(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)}this.cameraColorGradingTexture&&r.ColorGradingTextureEnabled&&e.ColorGradingTexture.Bind(this.cameraColorGradingTexture,this._effect)}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),this.cameraColorCurves&&e.ColorCurves.Bind(this.cameraColorCurves,this._effect)),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),this.cameraColorGradingTexture&&this.cameraColorGradingTexture.animations&&this.cameraColorGradingTexture.animations.length>0&&e.push(this.cameraColorGradingTexture),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(),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(){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})(e.Material);i.DiffuseTextureEnabled=!0,i.AmbientTextureEnabled=!0,i.OpacityTextureEnabled=!0,i.ReflectionTextureEnabled=!0,i.EmissiveTextureEnabled=!0,i.SpecularTextureEnabled=!0,i.BumpTextureEnabled=!0,i.FresnelEnabled=!0,i.LightmapTextureEnabled=!0,i.RefractionTextureEnabled=!0,i.ColorGradingTextureEnabled=!0,__decorate([e.serializeAsTexture()],i.prototype,"diffuseTexture",void 0),__decorate([e.serializeAsTexture()],i.prototype,"ambientTexture",void 0),__decorate([e.serializeAsTexture()],i.prototype,"opacityTexture",void 0),__decorate([e.serializeAsTexture()],i.prototype,"reflectionTexture",void 0),__decorate([e.serializeAsTexture()],i.prototype,"emissiveTexture",void 0),__decorate([e.serializeAsTexture()],i.prototype,"specularTexture",void 0),__decorate([e.serializeAsTexture()],i.prototype,"bumpTexture",void 0),__decorate([e.serializeAsTexture()],i.prototype,"lightmapTexture",void 0),__decorate([e.serializeAsTexture()],i.prototype,"refractionTexture",void 0),__decorate([e.serializeAsColor3("ambient")],i.prototype,"ambientColor",void 0),__decorate([e.serializeAsColor3("diffuse")],i.prototype,"diffuseColor",void 0),__decorate([e.serializeAsColor3("specular")],i.prototype,"specularColor",void 0),__decorate([e.serializeAsColor3("emissive")],i.prototype,"emissiveColor",void 0),__decorate([e.serialize()],i.prototype,"specularPower",void 0),__decorate([e.serialize()],i.prototype,"useAlphaFromDiffuseTexture",void 0),__decorate([e.serialize()],i.prototype,"useEmissiveAsIllumination",void 0),__decorate([e.serialize()],i.prototype,"linkEmissiveWithDiffuse",void 0),__decorate([e.serialize()],i.prototype,"useReflectionFresnelFromSpecular",void 0),__decorate([e.serialize()],i.prototype,"useSpecularOverAlpha",void 0),__decorate([e.serialize()],i.prototype,"useReflectionOverAlpha",void 0),__decorate([e.serialize()],i.prototype,"disableLighting",void 0),__decorate([e.serialize()],i.prototype,"useParallax",void 0),__decorate([e.serialize()],i.prototype,"useParallaxOcclusion",void 0),__decorate([e.serialize()],i.prototype,"parallaxScaleBias",void 0),__decorate([e.serialize()],i.prototype,"roughness",void 0),__decorate([e.serialize()],i.prototype,"indexOfRefraction",void 0),__decorate([e.serialize()],i.prototype,"invertRefractionY",void 0),__decorate([e.serialize()],i.prototype,"useLightmapAsShadowmap",void 0),__decorate([e.serializeAsFresnelParameters()],i.prototype,"diffuseFresnelParameters",void 0),__decorate([e.serializeAsFresnelParameters()],i.prototype,"opacityFresnelParameters",void 0),__decorate([e.serializeAsFresnelParameters()],i.prototype,"reflectionFresnelParameters",void 0),__decorate([e.serializeAsFresnelParameters()],i.prototype,"refractionFresnelParameters",void 0),__decorate([e.serializeAsFresnelParameters()],i.prototype,"emissiveFresnelParameters",void 0),__decorate([e.serialize()],i.prototype,"useGlossinessFromSpecularMapAlpha",void 0),__decorate([e.serialize()],i.prototype,"maxSimultaneousLights",void 0),__decorate([e.serialize()],i.prototype,"invertNormalMapX",void 0),__decorate([e.serialize()],i.prototype,"invertNormalMapY",void 0),__decorate([e.serializeAsTexture()],i.prototype,"cameraColorGradingTexture",void 0),__decorate([e.serializeAsColorCurves()],i.prototype,"cameraColorCurves",void 0),__decorate([e.serialize()],i.prototype,"useLogarithmicDepth",null),e.StandardMaterial=i})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(e,i){var r=t.call(this,e,i,!0)||this;return r.subMaterials=new Array,i.multiMaterials.push(r),r}return __extends(i,t),i.prototype.getSubMaterial=function(e){return e<0||e>=this.subMaterials.length?this.getScene().defaultMaterial:this.subMaterials[e]},i.prototype.getClassName=function(){return"MultiMaterial"},i.prototype.isReady=function(e){for(var t=0;t-1&&o.skeletons){var O=m.indexOf(y.skeletonId)>-1;if(!O)for(var I=0,D=d.skeletons.length;I>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(),d=0;dp&&(c=p,o=f,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.cellWidth,s=0,a=0;athis._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._onAnimationEnd&&this._onAnimationEnd(),this.disposeWhenFinishedAnimating&&this.dispose()))))},t.prototype.dispose=function(){for(var e=0;e=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;o-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;r1)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),d=[{frame:0,value:s},{frame:o,value:a}];return u.setKeys(d),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=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;t0)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=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: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;sthis._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)}(rthis._keys[this._keys.length-1].frame)&&(r=this._keys[0].frame),(nthis._keys[this._keys.length-1].frame)&&(n=this._keys[this._keys.length-1].frame),r===n&&r++;var l,u=n-r,d=t*(this.framePerSecond*s)/1e3,f=0;if(d>u&&!o)h=!1,f=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}f=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=d/u>>0,v=h?r+d%u:n,y=this._interpolate(v,g,this.loopMode,l,f);this.setValue(y);for(var x=0;x=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-1){for(var i=this._animations,r=0,t=i.length-1;t>=0;t--)"string"==typeof e&&i[t].name!=e||(i[t].reset(),i.splice(t,1),r++);i.length==r&&(this._scene._activeAnimatables.splice(t,1),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=.5?.5*(1-this.easeInCore(2*(1-t)))+.5:.5*this.easeInCore(2*t)},e})();t._EASINGMODE_EASEIN=0,t._EASINGMODE_EASEOUT=1,t._EASINGMODE_EASEINOUT=2,e.EasingFunction=t;var i=(function(e){function t(){return e.apply(this,arguments)||this}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);var i=e.call(this)||this;return i.amplitude=t,i}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);var r=e.call(this)||this;return r.bounces=t,r.bounciness=i,r}return __extends(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.bounces),i=this.bounciness;i<=1&&(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),d=.5*(l+u),f=e-d,p=d-l;return-Math.pow(1/i,t-h)/(p*p)*(f-p)*(f+p)},t})(t);e.BounceEase=n;var o=(function(e){function t(){return e.apply(this,arguments)||this}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);var r=e.call(this)||this;return r.oscillations=t,r.springiness=i,r}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);var i=e.call(this)||this;return i.exponent=t,i}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);var i=e.call(this)||this;return i.power=t,i}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(){return e.apply(this,arguments)||this}return __extends(t,e),t.prototype.easeInCore=function(e){return e*e},t})(t);e.QuadraticEase=c;var l=(function(e){function t(){return e.apply(this,arguments)||this}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(){return e.apply(this,arguments)||this}return __extends(t,e),t.prototype.easeInCore=function(e){return e*e*e*e*e},t})(t);e.QuinticEase=u;var d=(function(e){function t(){return e.apply(this,arguments)||this}return __extends(t,e),t.prototype.easeInCore=function(e){return 1-Math.sin(1.5707963267948966*(1-e))},t})(t);e.SineEase=d;var f=(function(t){function i(e,i,r,n){void 0===e&&(e=0),void 0===i&&(i=0),void 0===r&&(r=1),void 0===n&&(n=1);var o=t.call(this)||this;return o.x1=e,o.y1=i,o.x2=r,o.y2=n,o}return __extends(i,t),i.prototype.easeInCore=function(t){return e.BezierCurve.interpolate(t,this.x1,this.y1,this.x2,this.y2)},i})(t);e.BezierCurveEase=f})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,o,s){var a=t.call(this,i,r.getScene())||this;return a.name=i,a.children=new Array,a.animations=new Array,a._worldTransform=new e.Matrix,a._absoluteTransform=new e.Matrix,a._invertedAbsoluteTransform=new e.Matrix,a._scaleMatrix=e.Matrix.Identity(),a._scaleVector=new e.Vector3(1,1,1),a._negateScaleChildren=new e.Vector3(1,1,1),a._scalingDeterminant=1,a._syncScaleVector=function(){var t=this.getLocalMatrix(),i=t.m[0]*t.m[0]+t.m[1]*t.m[1]+t.m[2]*t.m[2],r=t.m[4]*t.m[4]+t.m[5]*t.m[5]+t.m[6]*t.m[6],n=t.m[8]*t.m[8]+t.m[9]*t.m[9]+t.m[10]*t.m[10],o=t.m[0]*t.m[1]*t.m[2]*t.m[3]<0?-1:1,s=t.m[4]*t.m[5]*t.m[6]*t.m[7]<0?-1:1,a=t.m[8]*t.m[9]*t.m[10]*t.m[11]<0?-1:1;this._scaleVector.x=o*Math.sqrt(i),this._scaleVector.y=s*Math.sqrt(r),this._scaleVector.z=a*Math.sqrt(n),this._parent&&(this._scaleVector.x/=this._parent._negateScaleChildren.x,this._scaleVector.y/=this._parent._negateScaleChildren.y,this._scaleVector.z/=this._parent._negateScaleChildren.z),e.Matrix.FromValuesToRef(this._scaleVector.x,0,0,0,0,this._scaleVector.y,0,0,0,0,this._scaleVector.z,0,0,0,0,1,this._scaleMatrix)},a._skeleton=r,a._matrix=o,a._baseMatrix=o,a._restPose=s?s:o.clone(),r.bones.push(a),n?(a._parent=n,n.children.push(a)):a._parent=null,a._updateDifferenceMatrix(),a.getAbsoluteTransform().determinant()<0&&(a._scalingDeterminant*=-1),a}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,t){void 0===t&&(t=!0),this._baseMatrix=e.clone(),this._matrix=e.clone(),this._skeleton._markAsDirty(),t&&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=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.prototype.translate=function(t,i,r){void 0===i&&(i=e.Space.LOCAL);var n=this.getLocalMatrix();if(i==e.Space.LOCAL)n.m[12]+=t.x,n.m[13]+=t.y,n.m[14]+=t.z;else{this._skeleton.computeAbsoluteTransforms();var o=e.Tmp.Matrix[0],s=e.Tmp.Vector3[0];r?(o.copyFrom(this._parent.getAbsoluteTransform()),o.multiplyToRef(r.getWorldMatrix(),o)):o.copyFrom(this._parent.getAbsoluteTransform()),o.m[12]=0,o.m[13]=0,o.m[14]=0,o.invert(),e.Vector3.TransformCoordinatesToRef(t,o,s),n.m[12]+=s.x,n.m[13]+=s.y,n.m[14]+=s.z}this.markAsDirty()},i.prototype.setPosition=function(t,i,r){void 0===i&&(i=e.Space.LOCAL);var n=this.getLocalMatrix();if(i==e.Space.LOCAL)n.m[12]=t.x,n.m[13]=t.y,n.m[14]=t.z;else{this._skeleton.computeAbsoluteTransforms();var o=e.Tmp.Matrix[0],s=e.Tmp.Vector3[0];r?(o.copyFrom(this._parent.getAbsoluteTransform()),o.multiplyToRef(r.getWorldMatrix(),o)):o.copyFrom(this._parent.getAbsoluteTransform()),o.invert(),e.Vector3.TransformCoordinatesToRef(t,o,s),n.m[12]=s.x,n.m[13]=s.y,n.m[14]=s.z}this.markAsDirty()},i.prototype.setAbsolutePosition=function(t,i){this.setPosition(t,e.Space.WORLD,i)},i.prototype.setScale=function(e,t,i,r){void 0===r&&(r=!1),this.animations[0]&&!this.animations[0].isStopped()&&(r||(this._negateScaleChildren.x=1/e,this._negateScaleChildren.y=1/t,this._negateScaleChildren.z=1/i),this._syncScaleVector()),this.scale(e/this._scaleVector.x,t/this._scaleVector.y,i/this._scaleVector.z,r)},i.prototype.scale=function(t,i,r,n){void 0===n&&(n=!1);var o=this.getLocalMatrix(),s=e.Tmp.Matrix[0];s.copyFrom(o);var a=e.Tmp.Matrix[1];a.copyFrom(s),a.invert();var h=e.Tmp.Matrix[2];e.Matrix.FromValuesToRef(t,0,0,0,0,i,0,0,0,0,r,0,0,0,0,1,h),this._scaleMatrix.multiplyToRef(h,this._scaleMatrix),this._scaleVector.x*=t,this._scaleVector.y*=i,this._scaleVector.z*=r,o.multiplyToRef(a,o),o.multiplyToRef(h,o),o.multiplyToRef(s,o);var c=this.getParent();c?o.multiplyToRef(c.getAbsoluteTransform(),this.getAbsoluteTransform()):this.getAbsoluteTransform().copyFrom(o);var l=this.children.length;h.invert();for(var u=0;u0&&(this._rightHandedSystem=!0,this._bendAxis.x=0,this._bendAxis.y=0,this._bendAxis.z=1),this._bone1.length){var n=this._bone1.getScale(),o=this._bone2.getScale();this._bone1Length=this._bone1.length*n.y*this.mesh.scaling.y,this._bone2Length=this._bone2.length*o.y*this.mesh.scaling.y}else if(this._bone1.children[0]){t.computeWorldMatrix(!0);var s=this._bone2.children[0].getAbsolutePosition(t),a=this._bone2.getAbsolutePosition(t),h=this._bone1.getAbsolutePosition(t);this._bone1Length=e.Vector3.Distance(s,a),this._bone2Length=e.Vector3.Distance(a,h)}this._bone1.getRotationMatrixToRef(e.Space.WORLD,t,this._bone1Mat),this.maxAngle=Math.PI,r&&(r.targetMesh&&(this.targetMesh=r.targetMesh,this.targetMesh.computeWorldMatrix(!0)),r.poleTargetMesh?(this.poleTargetMesh=r.poleTargetMesh,this.poleTargetMesh.computeWorldMatrix(!0)):r.poleTargetBone?this.poleTargetBone=r.poleTargetBone:this._bone1.getParent()&&(this.poleTargetBone=this._bone1.getParent()),r.poleTargetLocalOffset&&this.poleTargetLocalOffset.copyFrom(r.poleTargetLocalOffset),r.poleAngle&&(this.poleAngle=r.poleAngle),r.bendAxis&&this._bendAxis.copyFrom(r.bendAxis),r.maxAngle&&(this.maxAngle=r.maxAngle),r.slerpAmount&&(this.slerpAmount=r.slerpAmount))}return Object.defineProperty(t.prototype,"maxAngle",{get:function(){return this._maxAngle},set:function(e){this._setMaxAngle(e)},enumerable:!0,configurable:!0}),t.prototype._setMaxAngle=function(e){e<0&&(e=0),(e>Math.PI||void 0==e)&&(e=Math.PI),this._maxAngle=e;var t=this._bone1Length,i=this._bone2Length;this._maxReach=Math.sqrt(t*t+i*i-2*t*i*Math.cos(e))},t.prototype.update=function(){var t=this._bone1,i=this.targetPosition,r=this.poleTargetPosition,n=this._tmpMat1,o=this._tmpMat2;this.targetMesh&&i.copyFrom(this.targetMesh.getAbsolutePosition()),this.poleTargetBone?this.poleTargetBone.getAbsolutePositionFromLocalToRef(this.poleTargetLocalOffset,this.mesh,r):this.poleTargetMesh&&e.Vector3.TransformCoordinatesToRef(this.poleTargetLocalOffset,this.poleTargetMesh.getWorldMatrix(),r);var s=this._tmpVec1,a=this._tmpVec2,h=this._tmpVec3,c=this._tmpVec4,l=this._tmpVec5;t.getAbsolutePositionToRef(this.mesh,s),r.subtractToRef(s,l),0==l.x&&0==l.y&&0==l.z?l.y=1:l.normalize(),i.subtractToRef(s,c),c.normalize(),e.Vector3.CrossToRef(c,l,a),a.normalize(),e.Vector3.CrossToRef(c,a,h),h.normalize(),e.Matrix.FromXYZAxesToRef(h,c,a,n);var u=this._bone1Length,d=this._bone2Length,f=e.Vector3.Distance(s,i);this._maxReach>0&&(f=Math.min(this._maxReach,f));var p=(d*d+f*f-u*u)/(2*d*f),_=(f*f+u*u-d*d)/(2*f*u);p>1&&(p=1),_>1&&(_=1),p<-1&&(p=-1),_<-1&&(_=-1);var m=Math.acos(p),g=Math.acos(_),v=-m-g;this._rightHandedSystem?(e.Matrix.RotationYawPitchRollToRef(0,0,.5*Math.PI,o),o.multiplyToRef(n,n),e.Matrix.RotationAxisToRef(this._bendAxis,g,o),o.multiplyToRef(n,n)):(this._tmpVec1.copyFrom(this._bendAxis),this._tmpVec1.x*=-1,e.Matrix.RotationAxisToRef(this._tmpVec1,-g,o),o.multiplyToRef(n,n)),this.poleAngle&&(e.Matrix.RotationAxisToRef(c,this.poleAngle,o),n.multiplyToRef(o,n)),this.slerpAmount<1?(this._slerping||e.Quaternion.FromRotationMatrixToRef(this._bone1Mat,this._bone1Quat),e.Quaternion.FromRotationMatrixToRef(n,this._tmpQuat1),e.Quaternion.SlerpToRef(this._bone1Quat,this._tmpQuat1,this.slerpAmount,this._bone1Quat),v=this._bone2Ang*(1-this.slerpAmount)+v*this.slerpAmount,this._bone1.setRotationQuaternion(this._bone1Quat,e.Space.WORLD,this.mesh),this._slerping=!0):(this._bone1.setRotationMatrix(n,e.Space.WORLD,this.mesh),this._bone1Mat.copyFrom(n),this._slerping=!1),this._bone2.setAxisAngle(this._bendAxis,v,e.Space.LOCAL),this._bone2Ang=v},t})();e.BoneIKController=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(t,i,r,n){this.upAxis=e.Vector3.Up(),this.adjustYaw=0,this.adjustPitch=0,this.adjustRoll=0,this._tmpVec1=e.Vector3.Zero(),this._tmpVec2=e.Vector3.Zero(),this._tmpVec3=e.Vector3.Zero(),this._tmpVec4=e.Vector3.Zero(),this._tmpMat1=e.Matrix.Identity(),this._tmpMat2=e.Matrix.Identity(),this.mesh=t,this.bone=i,this.target=r,n&&(n.adjustYaw&&(this.adjustYaw=n.adjustYaw),n.adjustPitch&&(this.adjustPitch=n.adjustPitch),n.adjustRoll&&(this.adjustRoll=n.adjustRoll))}return t.prototype.update=function(){var t=this.bone,i=this.target,r=this._tmpVec1,n=this._tmpVec2,o=this._tmpVec3,s=this._tmpVec4,a=this._tmpMat1,h=this._tmpMat2;t.getAbsolutePositionToRef(this.mesh,r),i.subtractToRef(r,n),n.normalize(),e.Vector3.CrossToRef(this.upAxis,n,o),o.normalize(),e.Vector3.CrossToRef(n,o,s),s.normalize(),e.Matrix.FromXYZAxesToRef(o,s,n,a),(this.adjustYaw||this.adjustPitch||this.adjustRoll)&&(e.Matrix.RotationYawPitchRollToRef(this.adjustYaw,this.adjustPitch,this.adjustRoll,h),h.multiplyToRef(a,a)),this.bone.setRotationMatrix(a,e.Space.WORLD,this.mesh)},t})();e.BoneLookController=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._lastAbsoluteTransformsUpdateId=-1,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||this.prepare(),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;t-1&&this._meshesWithPoseMatrix.splice(t,1)},t.prototype._computeTransformMatrices=function(e,t){for(var i=0;i0&&(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-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;o0&&(e=this._meshesWithPoseMatrix[0].getPoseMatrix()),e},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;c0){for(var t=0;t0&&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)},t.prototype.directRender=function(e,t){for(var i=this._scene.getEngine(),r=0;r-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})();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,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:e<=0&&(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;ta?a:Math.floor(h);var c,l,u,d,f=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,p=[],_=[],m=[],g=[],v=[],y=[],x=[],b=[],A=[],E=[];if(r.length<2){var T=[],P=[];for(u=0;u0&&(O=M[d].subtract(M[d-1]).length(),I=O+x[l],v[l].push(I),x[l]=I),d++;o&&(d--,p.push(M[0].x,M[0].y,M[0].z),O=M[d].subtract(M[0]).length(),I=O+x[l],v[l].push(I),x[l]=I),A[l]=S+R,E[l]=C,C+=S+R}var D,L,w,B;for(u=0;u1?1:i.arc||1,h=i.slice<=0?1:i.slice||1,c=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,l=new e.Vector3(n/2,o/2,s/2),u=2+r,d=2*u,f=[],p=[],_=[],m=[],g=0;g<=u;g++){for(var v=g/u,y=v*Math.PI*h,x=0;x<=d;x++){var b=x/d,A=b*Math.PI*2*a,E=e.Matrix.RotationZ(-y),T=e.Matrix.RotationY(A),P=e.Vector3.TransformCoordinates(e.Vector3.Up(),E),M=e.Vector3.TransformCoordinates(P,T),S=M.multiply(l),C=M.divide(l).normalize();p.push(S.x,S.y,S.z),_.push(C.x,C.y,C.z),m.push(b,v)}if(g>0)for(var R=p.length/3,O=R-2*(d+1);O+d+21?1:i.arc||1,d=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,f=i.faceUV||new Array(3),p=i.faceColors,_=1!==u&&l?2:0,m=c?h:1,g=2+(1+_)*m;for(r=0;r0&&(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,d=0,f=0,p=0,_=0,m=0;for(m=0;m1?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,d=u/h,f=0;f=r.length?0:i.type||0,u=i.size,d=i.sizeX||u||1,f=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||i.flat,x=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,b=[],A=[],E=[],T=[],P=[],M=0,S=0,C=[],R=0,O=0;if(y)for(O=0;O1)for(var h=0;hthis.value;case i.IsLesser:return this._effectiveTarget[this._property]-1&&this._scene._actionManagers.splice(e,1)},t.prototype.getScene=function(){return this._scene},t.prototype.hasSpecificTriggers=function(e){for(var t=0;t-1)return!0}return!1},t.prototype.hasSpecificTrigger=function(e){for(var t=0;t=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=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;r0;if(2===i.type?d.push(o):d.push(r),_){for(var m=new Array,g=0;g0){var d=u.properties[0].value,f=null===u.properties[0].targetType?d:n.getMeshByName(d);f._meshId&&(f.mesh=n.getMeshByID(f._meshId)),l={trigger:e.ActionManager[u.name],parameter:f}}else l=e.ActionManager[u.name];for(var p=0;p0&&(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){if(this.delayLoadState!==e.Engine.DELAYLOADSTATE_LOADING){if(this.isReady())return void(i&&i());this.delayLoadState=e.Engine.DELAYLOADSTATE_LOADING,this._queueLoad(t,i)}},t.prototype._queueLoad=function(t,i){var r=this;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;a0){for(var i=0;i0){for(var i=0;i0){for(var i=0;i0){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 d=new Float32Array(t,s.uvs4AttrDesc.offset,s.uvs4AttrDesc.count);i.setVerticesData(e.VertexBuffer.UV4Kind,d,!1)}if(s.uvs5AttrDesc&&s.uvs5AttrDesc.count>0){var f=new Float32Array(t,s.uvs5AttrDesc.offset,s.uvs5AttrDesc.count);i.setVerticesData(e.VertexBuffer.UV5Kind,f,!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>8),M.push((16711680&S)>>16),M.push(S>>24)}i.setVerticesData(e.VertexBuffer.MatricesIndicesKind,M,!1)}if(t.matricesIndicesExtra)if(t.matricesIndicesExtra._isExpanded)delete t.matricesIndices._isExpanded,i.setVerticesData(e.VertexBuffer.MatricesIndicesExtraKind,t.matricesIndicesExtra,!1);else{for(var M=[],x=0;x>8),M.push((16711680&S)>>16),M.push(S>>24)}i.setVerticesData(e.VertexBuffer.MatricesIndicesExtraKind,M,!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 C=0;Cthis._maxX||tthis._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,!(ethis._maxX||tthis._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=(this._subdivisionsX,this._subdivisionsY,Math.floor((e+this._maxX)*this._subdivisionsX/this._width)),n=Math.floor(-(t+this._maxZ)*this._subdivisionsY/this._height+this._subdivisionsY),o=this._heightQuads[n*this._subdivisionsX+r];return i=t0&&(c=!0,this._soundLoaded(i));break;case"String":h.push(i);case"Array":0===h.length&&(h=i);for(var l=0;l0&&(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.prototype.serialize=function(){var e={name:this.name,url:this.name,autoplay:this.autoplay,loop:this.loop,volume:this._volume,spatialSound:this.spatialSound,maxDistance:this.maxDistance,rolloffFactor:this.rolloffFactor,refDistance:this.refDistance,distanceModel:this.distanceModel,playbackRate:this._playbackRate,panningModel:this._panningModel,soundTrackId:this.soundTrackId};return this.spatialSound&&(this._connectedMesh&&(e.connectedMeshId=this._connectedMesh.id),e.position=this._position.asArray(),e.refDistance=this.refDistance,e.distanceModel=this.distanceModel,e.isDirectional=this._isDirectional,e.localDirectionToMesh=this._localDirection.asArray(),e.coneInnerAngle=this._coneInnerAngle,e.coneOuterAngle=this._coneOuterAngle,e.coneOuterGain=this._coneOuterGain),e},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 d=e.Vector3.FromArray(i.localDirectionToMesh);h.setLocalDirectionToMesh(d)}if(i.connectedMeshId){var f=r.getMeshByID(i.connectedMeshId);f&&h.attachToMesh(f)}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&&(t.soundTrackId===-1?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);t!==-1&&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;t4&&(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 u=n.join("\n");return this._cachedDefines!==u&&(this._cachedDefines=u,this._glowMapGenerationEffect=this._scene.getEngine().createEffect("glowMapGeneration",o,["world","mBones","viewProjection","diffuseMatrix","color","emissiveMatrix"],["diffuseSampler","emissiveSampler"],u)),this._glowMapGenerationEffect.isReady()},i.prototype.render=function(){var t=this._glowMapMergeEffect;if(t.isReady()&&this._blurTexture.isReady()){var i=this._scene.getEngine();this.onBeforeComposeObservable.notifyObservers(this),i.enableEffect(t),i.setState(!1);var r=i.getStencilBuffer(),n=i.getStencilFunction(),o=i.getStencilMask(),s=i.getAlphaMode();t.setTexture("textureSampler",this._blurTexture),i.bindBuffers(this._vertexBuffers,this._indexBuffer,t),i.setAlphaMode(this._options.alphaBlendingMode),i.setStencilMask(0),i.setStencilBuffer(!0),i.setStencilFunctionReference(this._instanceGlowingMeshStencilReference),this.outerGlow&&(t.setFloat("offset",0),i.setStencilFunction(e.Engine.NOTEQUAL),i.draw(!0,0,6)),this.innerGlow&&(t.setFloat("offset",1),i.setStencilFunction(e.Engine.EQUAL),i.draw(!0,0,6)),i.setStencilFunction(n),i.setStencilMask(o),i.setAlphaMode(s),i.setStencilBuffer(r),this.onAfterComposeObservable.notifyObservers(this);var a=this._mainTexture.getSize();this.setMainTextureSize(),a.width===this._mainTextureDesiredSize.width&&a.height===this._mainTextureDesiredSize.height||(this.onSizeChangedObservable.notifyObservers(this),this.disposeTextureAndPostProcesses(),this.createTextureAndPostProcesses())}},i.prototype.addExcludedMesh=function(e){var t=this._excludedMeshes[e.uniqueId];t||(this._excludedMeshes[e.uniqueId]={mesh:e,beforeRender:e.onBeforeRenderObservable.add((function(e){e.getEngine().setStencilBuffer(!1)})),afterRender:e.onAfterRenderObservable.add((function(e){e.getEngine().setStencilBuffer(!0)}))})},i.prototype.removeExcludedMesh=function(e){var t=this._excludedMeshes[e.uniqueId];t&&(e.onBeforeRenderObservable.remove(t.beforeRender),e.onAfterRenderObservable.remove(t.afterRender)),this._excludedMeshes[e.uniqueId]=void 0},i.prototype.addMesh=function(e,t,i){var r=this;void 0===i&&(i=!1);var n=this._meshes[e.uniqueId];n?n.color=t:this._meshes[e.uniqueId]={mesh:e,color:t,observerHighlight:e.onBeforeRenderObservable.add((function(e){r._excludedMeshes[e.uniqueId]?r.defaultStencilReference(e):e.getScene().getEngine().setStencilFunctionReference(r._instanceGlowingMeshStencilReference)})),observerDefault:e.onAfterRenderObservable.add(this.defaultStencilReference),glowEmissiveOnly:i},this._shouldRender=!0},i.prototype.removeMesh=function(e){var t=this._meshes[e.uniqueId];t&&(e.onBeforeRenderObservable.remove(t.observerHighlight),e.onAfterRenderObservable.remove(t.observerDefault)),this._meshes[e.uniqueId]=void 0,this._shouldRender=!1;for(var i in this._meshes)if(i){this._shouldRender=!0;break}},i.prototype.shouldRender=function(){return this.isEnabled&&this._shouldRender},i.prototype.setMainTextureSize=function(){this._options.mainTextureFixedSize?(this._mainTextureDesiredSize.width=this._options.mainTextureFixedSize,this._mainTextureDesiredSize.height=this._options.mainTextureFixedSize):(this._mainTextureDesiredSize.width=this._engine.getRenderingCanvas().width*this._options.mainTextureRatio,this._mainTextureDesiredSize.height=this._engine.getRenderingCanvas().height*this._options.mainTextureRatio,this._mainTextureDesiredSize.width=e.Tools.GetExponentOfTwo(this._mainTextureDesiredSize.width,this._maxSize),this._mainTextureDesiredSize.height=e.Tools.GetExponentOfTwo(this._mainTextureDesiredSize.height,this._maxSize))},i.prototype.defaultStencilReference=function(e){e.getScene().getEngine().setStencilFunctionReference(i.normalMeshStencilReference)},i.prototype.disposeTextureAndPostProcesses=function(){this._blurTexture.dispose(),this._mainTexture.dispose(),this._downSamplePostprocess.dispose(),this._horizontalBlurPostprocess.dispose(),this._verticalBlurPostprocess.dispose()},i.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.disposeTextureAndPostProcesses();for(var i in this._meshes){var r=this._meshes[i];r&&r.mesh&&(r.mesh.onBeforeRenderObservable.remove(r.observerHighlight),r.mesh.onAfterRenderObservable.remove(r.observerDefault))}this._meshes=null;for(var i in this._excludedMeshes){var r=this._excludedMeshes[i];r&&(r.mesh.onBeforeRenderObservable.remove(r.beforeRender),r.mesh.onAfterRenderObservable.remove(r.afterRender))}this._excludedMeshes=null;var n=this._scene.highlightLayers.indexOf(this,0);n>-1&&this._scene.highlightLayers.splice(n,1),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this.onBeforeRenderMainTextureObservable.clear(),this.onBeforeBlurObservable.clear(),this.onBeforeComposeObservable.clear(),this.onAfterComposeObservable.clear(),this.onSizeChangedObservable.clear()},i})();i.neutralColor=new e.Color4(0,0,0,0),i.glowingMeshStencilReference=2,i.normalMeshStencilReference=1,e.HighlightLayer=i})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(){}return e.TransformCoordinatesToRefSIMD=function(t,i,r){e.TransformCoordinatesFromFloatsToRefSIMD(t.x,t.y,t.z,i,r)},e.TransformCoordinatesFromFloatsToRefSIMD=function(e,t,i,r,n){var o=r.m,s=SIMD.Float32x4.load(o,0),a=SIMD.Float32x4.load(o,4),h=SIMD.Float32x4.load(o,8),c=SIMD.Float32x4.load(o,12),l=SIMD.Float32x4.add(SIMD.Float32x4.add(SIMD.Float32x4.mul(SIMD.Float32x4.splat(e),s),SIMD.Float32x4.mul(SIMD.Float32x4.splat(t),a)),SIMD.Float32x4.add(SIMD.Float32x4.mul(SIMD.Float32x4.splat(i),h),c));l=SIMD.Float32x4.div(l,SIMD.Float32x4.swizzle(l,3,3,3,3)),n.x=SIMD.Float32x4.extractLane(l,0),n.y=SIMD.Float32x4.extractLane(l,1),n.z=SIMD.Float32x4.extractLane(l,2)},e})(),i=(function(){function e(){}return e.prototype.multiplyToArraySIMD=function(e,t,i){for(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=0;c<16;c+=4)SIMD.Float32x4.store(t,c+i,SIMD.Float32x4.add(SIMD.Float32x4.mul(SIMD.Float32x4.splat(r[c]),o),SIMD.Float32x4.add(SIMD.Float32x4.mul(SIMD.Float32x4.splat(r[c+1]),s),SIMD.Float32x4.add(SIMD.Float32x4.mul(SIMD.Float32x4.splat(r[c+2]),a),SIMD.Float32x4.mul(SIMD.Float32x4.splat(r[c+3]),h)))));return this},e.prototype.invertToRefSIMD=function(e){var t=this.m,i=e.m,r=SIMD.Float32x4.load(t,0),n=SIMD.Float32x4.load(t,4),o=SIMD.Float32x4.load(t,8),s=SIMD.Float32x4.load(t,12),a=SIMD.Float32x4.shuffle(r,n,0,1,4,5),h=SIMD.Float32x4.shuffle(o,s,0,1,4,5),c=SIMD.Float32x4.shuffle(a,h,0,2,4,6);h=SIMD.Float32x4.shuffle(h,a,1,3,5,7),a=SIMD.Float32x4.shuffle(r,n,2,3,6,7);var l=SIMD.Float32x4.shuffle(o,s,2,3,6,7),u=SIMD.Float32x4.shuffle(a,l,0,2,4,6);l=SIMD.Float32x4.shuffle(l,a,1,3,5,7),a=SIMD.Float32x4.mul(u,l),a=SIMD.Float32x4.swizzle(a,1,0,3,2);var d=SIMD.Float32x4.mul(h,a),f=SIMD.Float32x4.mul(c,a);a=SIMD.Float32x4.swizzle(a,2,3,0,1),d=SIMD.Float32x4.sub(SIMD.Float32x4.mul(h,a),d),f=SIMD.Float32x4.sub(SIMD.Float32x4.mul(c,a),f),f=SIMD.Float32x4.swizzle(f,2,3,0,1),a=SIMD.Float32x4.mul(h,u),a=SIMD.Float32x4.swizzle(a,1,0,3,2),d=SIMD.Float32x4.add(SIMD.Float32x4.mul(l,a),d);var p=SIMD.Float32x4.mul(c,a);a=SIMD.Float32x4.swizzle(a,2,3,0,1),d=SIMD.Float32x4.sub(d,SIMD.Float32x4.mul(l,a)),p=SIMD.Float32x4.sub(SIMD.Float32x4.mul(c,a),p),p=SIMD.Float32x4.swizzle(p,2,3,0,1),a=SIMD.Float32x4.mul(SIMD.Float32x4.swizzle(h,2,3,0,1),l),a=SIMD.Float32x4.swizzle(a,1,0,3,2),u=SIMD.Float32x4.swizzle(u,2,3,0,1),d=SIMD.Float32x4.add(SIMD.Float32x4.mul(u,a),d);var _=SIMD.Float32x4.mul(c,a);a=SIMD.Float32x4.swizzle(a,2,3,0,1),d=SIMD.Float32x4.sub(d,SIMD.Float32x4.mul(u,a)),_=SIMD.Float32x4.sub(SIMD.Float32x4.mul(c,a),_),_=SIMD.Float32x4.swizzle(_,2,3,0,1),a=SIMD.Float32x4.mul(c,h),a=SIMD.Float32x4.swizzle(a,1,0,3,2),_=SIMD.Float32x4.add(SIMD.Float32x4.mul(l,a),_),p=SIMD.Float32x4.sub(SIMD.Float32x4.mul(u,a),p),a=SIMD.Float32x4.swizzle(a,2,3,0,1),_=SIMD.Float32x4.sub(SIMD.Float32x4.mul(l,a),_),p=SIMD.Float32x4.sub(p,SIMD.Float32x4.mul(u,a)),a=SIMD.Float32x4.mul(c,l),a=SIMD.Float32x4.swizzle(a,1,0,3,2),f=SIMD.Float32x4.sub(f,SIMD.Float32x4.mul(u,a)),_=SIMD.Float32x4.add(SIMD.Float32x4.mul(h,a),_),a=SIMD.Float32x4.swizzle(a,2,3,0,1),f=SIMD.Float32x4.add(SIMD.Float32x4.mul(u,a),f),_=SIMD.Float32x4.sub(_,SIMD.Float32x4.mul(h,a)),a=SIMD.Float32x4.mul(c,u),a=SIMD.Float32x4.swizzle(a,1,0,3,2),f=SIMD.Float32x4.add(SIMD.Float32x4.mul(l,a),f),p=SIMD.Float32x4.sub(p,SIMD.Float32x4.mul(h,a)),a=SIMD.Float32x4.swizzle(a,2,3,0,1),f=SIMD.Float32x4.sub(f,SIMD.Float32x4.mul(l,a)),p=SIMD.Float32x4.add(SIMD.Float32x4.mul(h,a),p);var m=SIMD.Float32x4.mul(c,d);return m=SIMD.Float32x4.add(SIMD.Float32x4.swizzle(m,2,3,0,1),m),m=SIMD.Float32x4.add(SIMD.Float32x4.swizzle(m,1,0,3,2),m),a=SIMD.Float32x4.reciprocalApproximation(m),m=SIMD.Float32x4.sub(SIMD.Float32x4.add(a,a),SIMD.Float32x4.mul(m,SIMD.Float32x4.mul(a,a))),m=SIMD.Float32x4.swizzle(m,0,0,0,0),SIMD.Float32x4.store(i,0,SIMD.Float32x4.mul(m,d)),SIMD.Float32x4.store(i,4,SIMD.Float32x4.mul(m,f)),SIMD.Float32x4.store(i,8,_=SIMD.Float32x4.mul(m,_)),SIMD.Float32x4.store(i,12,SIMD.Float32x4.mul(m,p)),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 d=SIMD.Float32x4.splat(0);l=SIMD.Float32x4.neg(l);var f=SIMD.Float32x4.shuffle(l,u,0,1,4,5),p=SIMD.Float32x4.shuffle(h,d,0,1,4,5),_=SIMD.Float32x4.shuffle(f,p,0,2,4,6),m=SIMD.Float32x4.shuffle(f,p,1,3,5,7),g=SIMD.Float32x4.shuffle(SIMD.Float32x4.shuffle(l,u,2,3,6,7),SIMD.Float32x4.shuffle(h,d,2,3,6,7),0,2,4,6),v=SIMD.Float32x4(0,0,0,1),y=SIMD.Float32x4(1,0,0,0);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))))),y=SIMD.Float32x4(0,1,0,0),SIMD.Float32x4.store(n,4,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))))),y=SIMD.Float32x4(0,0,1,0),SIMD.Float32x4.store(n,8,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))))),y=SIMD.Float32x4.replaceLane(SIMD.Float32x4.neg(s),3,1),SIMD.Float32x4.store(n,12,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)))))},e})(),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!==self.SIMD&&(self.Math.fround||(self.Math.fround=(function(e){return function(t){return e[0]=t,e[0]}})(new Float32Array(1))),self.Math.imul||(self.Math.imul=function(e,t){var i=e>>>16&65535,r=65535&e,n=t>>>16&65535,o=65535&t;return r*o+(i*o+r*n<<16>>>0)|0}),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,h._isEnabled=!0)},h})();h._isEnabled=!1,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,this._contentSize=null,this._bottomNode=null,this._leftNode=null,this._initialSize=null,this._rightNode=null}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(){return this.getUVsForCustomSize(this._root._size)},enumerable:!0,configurable:!0}),t.prototype.getUVsForCustomSize=function(t){var i=this._root._size.width,r=this._root._size.height,n=new e.Vector2(this._pos.x/i,this._pos.y/r),o=new e.Vector2((this._pos.x+t.width-1)/i,(this._pos.y+t.height-1)/r),s=new Array;return s.push(n),s.push(new e.Vector2(o.x,n.y)),s.push(o),s.push(new e.Vector2(n.x,o.y)),s},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;if(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));else if(this._initialSize){if(!(e.width<=this._initialSize.width&&e.height<=this._initialSize.height))return null;t=this}else e.width<=this._size.width&&e.height<=this._size.height&&(t=this);return t},t.prototype.splitNode=function(i){return!this._contentSize&&this._initialSize?(this._contentSize=i.clone(),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){var r=t.call(this,null,null,e.Vector2.Zero(),i)||this;return r._root=r,r}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;r0?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=h);l++){var u=n[l],d=u.offset,f=d-c;if(f!==i){for(var p=f/i-1,_=d-i,m=Math.min(a,p),g=0;go.width&&(this._currentFreePosition.x=0,this._currentFreePosition.y+=this._lineHeightSuper+this._yMargin,this._currentFreePosition.y>o.height))return this.getChar("!");if(this._signedDistanceField){this._sdfContext.clearRect(0,0,this._sdfCanvas.width,this._sdfCanvas.height),this._sdfContext.fillText(i,0,-this._offset);var a=this._sdfContext.getImageData(0,0,s*this._sdfScale,this._sdfCanvas.height),h=this._computeSDFChar(a);this._context.putImageData(h,this._currentFreePosition.x,this._currentFreePosition.y)}else this._context.fillText(i,this._currentFreePosition.x,this._currentFreePosition.y-this._offset);if(r.topLeftUV=new e.Vector2(this._currentFreePosition.x/o.width,this._currentFreePosition.y/o.height),r.bottomRightUV=new e.Vector2((this._currentFreePosition.x+s)/o.width,r.topLeftUV.y+(this._lineHeightSuper+2)/o.height),this._signedDistanceField){var c=1/o.width;r.topLeftUV.addInPlace(new e.Vector2(c,c)),r.bottomRightUV.addInPlace(new e.Vector2(c,c))}return r.charWidth=this._superSample?s/2:s,this._charInfos[i]=r,this._curCharCount++,this._currentFreePosition.x+=s+this._xMargin,r},r.prototype._computeSDFChar=function(e){for(var t=this._sdfScale,i=e.width,r=e.height,n=i/t,o=r/t,s=0,a=0,h=t,c=h-1,l=function(n,o,h,c,l){var u=n*t,d=o*t;if(u+h<0||u+h>=i||d+c<0||d+c>=r)return!0;var f=e.data[4*((d+c)*i+(u+h))],p=f>0===l;return p||(s=h,a=c),p},u=function(e,t,i){if(l(e,t,0,c,i)&&l(e,t,0,-c,i)&&l(e,t,-c,0,i)&&l(e,t,c,0,i))return 0;for(var r=1;r<=h;r++){if(!(l(e,t,0,r,i)&&l(e,t,0,-r,i)&&l(e,t,-r,0,i)&&l(e,t,r,0,i)))return r*r;for(var n=1;n<=r;n++)if(!(l(e,t,-n,r,i)&&l(e,t,n,r,i)&&l(e,t,r,-n,i)&&l(e,t,r,n,i)&&l(e,t,-n,-r,i)&&l(e,t,n,-r,i)&&l(e,t,-r,-n,i)&&l(e,t,-r,n,i))){var o=r*r+n*n,u=1;return l(e,t,s-1,a,i)||(o+=(s-1)*(s-1)+a*a,++u),l(e,t,s+1,a,i)||(o+=(s+1)*(s+1)+a*a,++u),l(e,t,s,a-1,i)||(o+=s*s+(a-1)*(a-1),++u),l(e,t,s,a+1,i)||(o+=s*s+(a+1)*(a+1),++u),l(e,t,s-1,a-1,i)||(o+=(s-1)*(s-1)+(a-1)*(a-1),++u),l(e,t,s+1,a+1,i)||(o+=(s+1)*(s+1)+(a+1)*(a+1),++u),l(e,t,s+1,a-1,i)||(o+=(s+1)*(s+1)+(a-1)*(a-1),++u),l(e,t,s-1,a+1,i)||(o+=(s-1)*(s-1)+(a+1)*(a+1),++u),o/u}}return 0},d=new Array(n*o),f=0;f255&&(m=255),m+=.5,g.data[4*y+0]=m,g.data[4*y+1]=m,g.data[4*y+2]=m,g.data[4*y+3]=255}return g},r.prototype.measureText=function(t,i){void 0===i&&(i=4);for(var r=0,n=0,o=1,s=0,a=0,h=t;a>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"),d=i("DXT5"),f=31,p=0,_=1,m=2,g=3,v=4,y=7,x=20,b=21,A=22,E=28,T=(function(){function t(){}return t.GetDDSInfo=function(e){var t=new Int32Array(e,0,f),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[E]&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;c=0;h--)for(var c=0;c=0;h--)for(var c=0;ct.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;rh||r.deleted||r.isDirty))for(var o=0;o<3;++o)if(r.error[o]>0,d,(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]],d=s.vertices[u[o-c.verticesStart]],f=s.vertices[u[a-c.verticesStart]],p=new n([l,d,f]);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();for(var n=0;n<3;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;r<3;++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;i0&&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,f,_,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.999)return!0;var p=e.Vector3.Cross(d,f).normalize();if(n[a]=!1,e.Vector3.Dot(p,h.normal)<.2)return!0}else n[a]=!0,s.push(h)}}return!1},t.prototype.updateTriangles=function(e,t,i,r){for(var n=r,o=0;o80*r){l=d=e[0],u=f=e[1];for(var g=r;gd&&(d=p),_>f&&(f=_);m=Math.max(d-l,f-u)}return n(a,h,r,l,u,m,void 0),h}function i(e,t,i,r,n){var o,s;if(n===O(e,t,i,r)>0)for(o=t;o=t;o-=r)s=M(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,d){if(e){!d&&u&&f(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){d?1===d?(e=a(e,t,i),n(e,t,i,c,l,u,2)):2===d&&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.xo.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),d=_(c,l,t,i,r),f=e.nextZ;f&&f.z<=d;){if(f!==e.prev&&f!==e.next&&g(n.x,n.y,o.x,o.y,s.x,s.y,f.x,f.y)&&y(f.prev,f,f.next)>=0)return!1;f=f.nextZ}for(f=e.prevZ;f&&f.z>=u;){if(f!==e.prev&&f!==e.next&&g(n.x,n.y,o.x,o.y,s.x,s.y,f.x,f.y)&&y(f.prev,f,f.next)>=0)return!1;f=f.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)&&E(n,o)&&E(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=P(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,d,f=[];for(s=0,a=t.length;s=r.next.y){var a=r.x+(o-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(a<=n&&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.x&&r.x>=l&&g(oi.x)&&E(r,e)&&(i=r,d=h)),r=r.next;return i}function f(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;t0||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=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&&!A(e,t)&&E(e,t)&&E(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))||y(e,t,i)>0!=y(e,t,r)>0&&y(i,r,e)>0!=y(i,r,t)>0}function A(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 E(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 P(e,t){var i=new C(e.i,e.x,e.y),r=new C(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 M(e,t,i,r){var n=new C(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 C(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 R(e,t,i,r){var n=t&&t.length,o=n?t[0]*i:e.length,s=Math.abs(O(e,0,o,i));if(n)for(var a=0,h=t.length;a0&&(r+=e[n-1].length,i.holes.push(r))}return i}e.earcut=t,e.deviation=R,e.flatten=I})(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,d=2,f=3,p=0,_=[];for(h=0;ht.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 d:a.push(i);break;case f:var g=[],v=[];for(h=0;h=3&&(P=new n(g,i.shared),P.plane&&s.push(P)),v.length>=3&&(P=new n(v,i.shared),P.plane&&a.push(P))}},t})();r.EPSILON=1e-5;var 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;ei.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));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,r){r.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(r.prevX-43,r.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(r.x,r.y,40,0,2*Math.PI,!0),i.vjCanvasContext.stroke(),i.vjCanvasContext.closePath(),r.prevX=r.x,r.prevY=r.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})();i._globalJoystickIndex=0,e.VirtualJoystick=i})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(e){function t(t,i,r){var n=e.call(this,t,i,r)||this;return n.inputs.addVirtualJoystick(),n}return __extends(t,e),t.prototype.getClassName=function(){return"VirtualJoysticksCamera"},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=e.call(this,t,"anaglyph",null,["leftSampler"],i,r[1],n,o,s)||this;return a._passedProcess=r[0]._rigPostProcess,a.onApplyObservable.add((function(e){e.setTextureFromPostProcess("leftSampler",a._passedProcess)})),a}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 t(e,t){this.name=e,this.url=t,this.isCompleted=!1}return t.prototype.run=function(t,i,r){var n=this,o=new Image;e.Tools.SetCorsBehavior(this.url,o),o.onload=function(){n.image=o,n.isCompleted=!0,n.onSuccess&&n.onSuccess(n),i()},o.onerror=function(){n.onError&&n.onError(n),r()},o.src=this.url},t})();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 t(e,t,i,r,n){this.name=e,this.url=t,this.extensions=i,this.noMipmap=r,this.files=n,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.CubeTexture(this.url,t,this.extensions,this.noMipmap,this.files,o,s)},t})();e.CubeTextureAssetTask=s;var a=(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;e0){if(a._vrEnabled=!0,a.webVROptions.displayName){var i=t.some((function(e){return e.displayName===a.webVROptions.displayName&&(a._vrDevice=e,!0)}));i||(a._vrDevice=t[0],e.Tools.Warn("Display "+a.webVROptions.displayName+" was not found. Using "+a._vrDevice.displayName))}else a._vrDevice=t[0];a.setCameraRigMode(e.Camera.RIG_MODE_WEBVR,{vrDisplay:a._vrDevice,frameData:a._frameData}),a._attached&&a.getEngine().enableVR(a._vrDevice)}else e.Tools.Error("No WebVR devices found!")}))):e.Tools.Error("WebVR is not enabled on your browser"),a.rotationQuaternion=new e.Quaternion,a._quaternionCache=new e.Quaternion,a}return __extends(i,t),i.prototype._checkInputs=function(){if(this._vrEnabled&&this._vrDevice.getFrameData(this._frameData)){var e=this._frameData.pose;e&&e.orientation&&(this._cacheState=e,this.rotationQuaternion.copyFromFloats(this._cacheState.orientation[0],this._cacheState.orientation[1],-this._cacheState.orientation[2],-this._cacheState.orientation[3]),this.webVROptions.trackPosition&&this._cacheState.position&&(this.position.copyFromFloats(this._cacheState.position[0],this._cacheState.position[1],-this._cacheState.position[2]),this.webVROptions.positionScale&&this.position.scaleInPlace(this.webVROptions.positionScale),this.position.addInPlace(this._positionOffset)))}t.prototype._checkInputs.call(this)},i.prototype.attachControl=function(i,r){t.prototype.attachControl.call(this,i,r), +this._attached=!0,r=!e.Camera.ForceAttachControlToAlwaysPreventDefault&&r,this._vrEnabled&&this.getEngine().enableVR(this._vrDevice)},i.prototype.detachControl=function(e){t.prototype.detachControl.call(this,e),this._vrEnabled=!1,this._attached=!1,this.getEngine().disableVR()},i.prototype.requestVRFullscreen=function(t){e.Tools.Warn("requestVRFullscreen is deprecated. call attachControl() to start sending frames to the VR display.")},i.prototype.getClassName=function(){return"WebVRFreeCamera"},i.prototype.resetToCurrentRotation=function(){this._vrDevice.resetPose()},i.prototype.setPositionOffset=function(e){e?this._positionOffset=e:this._positionOffset.copyFrom(this.position)},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){void 0===t&&(t=0),void 0===i&&(i=1024);var r=e.call(this,t)||this;return r.priority=t,r.maximumSize=i,r.apply=function(e){for(var t=!0,i=0;ir.maximumSize&&(n.scale(.5),t=!1)}}return t},r}return __extends(t,e),t})(t);e.TextureOptimization=i;var r=(function(e){function t(t,i){void 0===t&&(t=0),void 0===i&&(i=2);var r=e.call(this,t)||this;return r.priority=t,r.maximumScale=i,r._currentScale=1,r.apply=function(e){return r._currentScale++,e.getEngine().setHardwareScalingLevel(r._currentScale),r._currentScale>=r.maximumScale},r}return __extends(t,e),t})(t);e.HardwareScalingOptimization=r;var n=(function(e){function t(){var t=e.apply(this,arguments)||this;return t.apply=function(e){return e.shadowsEnabled=!1,!0},t}return __extends(t,e),t})(t);e.ShadowsOptimization=n;var o=(function(e){function t(){var t=e.apply(this,arguments)||this;return t.apply=function(e){return e.postProcessesEnabled=!1,!0},t}return __extends(t,e),t})(t);e.PostProcessesOptimization=o;var s=(function(e){function t(){var t=e.apply(this,arguments)||this;return t.apply=function(e){return e.lensFlaresEnabled=!1,!0},t}return __extends(t,e),t})(t);e.LensFlaresOptimization=s;var a=(function(e){function t(){var t=e.apply(this,arguments)||this;return t.apply=function(e){return e.particlesEnabled=!1,!0},t}return __extends(t,e),t})(t);e.ParticlesOptimization=a;var h=(function(e){function t(){var t=e.apply(this,arguments)||this;return t.apply=function(e){return e.renderTargetsEnabled=!1,!0},t}return __extends(t,e),t})(t);e.RenderTargetsOptimization=h;var c=(function(t){function i(){var r=t.apply(this,arguments)||this;return r._canBeMerged=function(t){if(!(t instanceof e.Mesh))return!1;var i=t;return!(!i.isVisible||!i.isEnabled())&&(!(i.instances.length>0)&&(!i.skeleton&&!i.hasLODLevels&&!i.parent))},r.apply=function(t,n){for(var o=t.meshes.slice(0),s=o.length,a=0;a=i.targetFrameRate)return void(n&&n());for(var s=!0,a=!0,h=0;hi.x&&(i.x=e.x),e.yi.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;h0){var d=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 f=c.length,u=0;us.elements.length-1?s.elements[0]:s.elements[u+1],t.push(f.x,0,f.y),t.push(f.x,-a,f.y),t.push(d.x,0,d.y),t.push(d.x,-a,d.y);var p=new e.Vector3(f.x,0,f.y),_=new e.Vector3(d.x,0,d.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;tthis.capacity&&this._depth0&&(t.x-=this.viewportBorder,t.y-=this.viewportBorder,t.width+=2*this.viewportBorder,t.height+=2*this.viewportBorder,i.x+=this.viewportBorder,i.y+=this.viewportBorder,this._positionX+=this.viewportBorder,this._positionY+=this.viewportBorder),i.z>0&&(this._positionX>t.x&&this._positionXt.y&&this._positionYr},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._positionXr.x+r.width-this.borderLimit?this._positionX-r.x-r.width+this.borderLimit:0,o=this._positionYr.y+r.height-this.borderLimit?this._positionY-r.y-r.height+this.borderLimit:0;var s=n>o?n:o;s-=this.viewportBorder,s>this.borderLimit&&(s=this.borderLimit);var a=1-s/this.borderLimit;if(a<0)return!1;a>1&&(a=1),this.viewportBorder>0&&(r.x+=this.viewportBorder,r.y+=this.viewportBorder,r.width-=2*this.viewportBorder,r.height-=2*this.viewportBorder,this._positionX-=this.viewportBorder,this._positionY-=this.viewportBorder);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.bindBuffers(this._vertexBuffers,this._indexBuffer,this._effect);for(var d=0;d=2&&(this._leftStick={x:this.browserGamepad.axes[this._leftStickAxisX],y:this.browserGamepad.axes[this._leftStickAxisY]}),this.browserGamepad.axes.length>=4&&(this._rightStick={x:this.browserGamepad.axes[this._rightStickAxisX],y:this.browserGamepad.axes[this._rightStickAxisY]})}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[this._leftStickAxisX],y:this.browserGamepad.axes[this._leftStickAxisY]}),this._rightStick&&(this.rightStick={x:this.browserGamepad.axes[this._rightStickAxisX],y:this.browserGamepad.axes[this._rightStickAxisY]})},e})();e.Gamepad=r;var n=(function(e){function t(t,i,r){var n=e.call(this,t,i,r)||this;return n.id=t,n.index=i,n.gamepad=r,n._buttons=new Array(r.buttons.length),n}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;t4&&(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=t.call(this,r.getEngine(),i)||this;s.SSAOOriginalSceneColorEffect="SSAOOriginalSceneColorEffect",s.SSAORenderEffect="SSAORenderEffect",s.SSAOBlurHRenderEffect="SSAOBlurHRenderEffect",s.SSAOBlurVRenderEffect="SSAOBlurVRenderEffect",s.SSAOCombineRenderEffect="SSAOCombineRenderEffect",s.totalStrength=1,s.radius=1e-4,s.area=.0075,s.fallOff=1e-6,s.base=.5,s._firstUpdate=!0,s._scene=r,s._createRandomTexture(),s._depthTexture=r.enableDepthRenderer().getDepthMap();var a=n.ssaoRatio||n,h=n.combineRatio||n;return s._ratio={ssaoRatio:a,combineRatio:h},s._originalColorPostProcess=new e.PassPostProcess("SSAOOriginalSceneColor",h,null,e.Texture.BILINEAR_SAMPLINGMODE,r.getEngine(),(!1)),s._createSSAOPostProcess(a),s._createBlurPostProcess(a),s._createSSAOCombinePostProcess(h),s.addEffect(new e.PostProcessRenderEffect(r.getEngine(),s.SSAOOriginalSceneColorEffect,function(){return s._originalColorPostProcess},(!0))),s.addEffect(new e.PostProcessRenderEffect(r.getEngine(),s.SSAORenderEffect,function(){return s._ssaoPostProcess},(!0))),s.addEffect(new e.PostProcessRenderEffect(r.getEngine(),s.SSAOBlurHRenderEffect,function(){return s._blurHPostProcess},(!0))),s.addEffect(new e.PostProcessRenderEffect(r.getEngine(),s.SSAOBlurVRenderEffect,function(){return s._blurVPostProcess},(!0))),s.addEffect(new e.PostProcessRenderEffect(r.getEngine(),s.SSAOCombineRenderEffect,function(){return s._ssaoCombinePostProcess},(!0))),r.postProcessRenderPipelineManager.addPipeline(s),o&&r.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(i,o),s}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;t0&&this.excludedMeshes.indexOf(e)!==-1},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;ot._alphaIndex?1:e._alphaIndext._distanceToCamera?-1:0})),a.setAlphaMode(e.Engine.ALPHA_COMBINE),o=0;o=0;l--)c(l);return h.addEffect(new e.PostProcessRenderEffect(n.getEngine(),"HDR",function(){return h._hdrPostProcess},(!0))),n.postProcessRenderPipelineManager.addPipeline(h),null!==a&&n.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(r,a),h.update(),h}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._hdrCurrentLuminancer._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;i<2;i++)for(var o=-2;o<2;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;r<2;r++)for(var n=-1;n<2;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)}},d=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},f={width:Math.pow(3,o-1),height:Math.pow(3,o-1)};this._downSamplePostProcesses[o-1]=new e.PostProcess("hdr","hdr",["lumOffsets"],[],f,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);f={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"],[],f,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=d)}},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;r<9;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;t<9;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})(e.PostProcessRenderPipeline);t.LUM_STEPS=6,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=ad?d:n,r=Math.round(d/n),o=0):r=r>d?d:r;for(var f=[],p=[],_=[],m=[],g=e.Tmp.Vector3[0],v=r;ud-r&&(r=d-u),f.length=0,p.length=0,_.length=0,m.length=0;for(var y=0,x=3*u;x<3*(u+r);x++){p.push(y);var b=a[x];f.push(s[3*b],s[3*b+1],s[3*b+2]),h&&_.push(h[2*b],h[2*b+1]),c&&m.push(c[4*b],c[4*b+1],c[4*b+2],c[4*b+3]),y++}var A,E=this.nbParticles,T=this._posToShape(f),P=this._uvsToShapeUV(_);for(A=0;Athis.nbParticles-1?this.nbParticles-1:i;for(var u=t;u<=i;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.billboard)&&(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;lthis._maximum.x&&(this._maximum.x=this._positions32[n]),this._positions32[n+1]this._maximum.y&&(this._maximum.y=this._positions32[n+1]),this._positions32[n+2]this._maximum.z&&(this._maximum.z=this._positions32[n+2])),this._computeParticleVertex||(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;lMath.PI;)n-=2*Math.PI;var s=n/Math.PI,a=o/Math.PI;s=.5*s+.5;var h=Math.round(s*i);h<0?h=0:h>=i&&(h=i-1);var c=Math.round(a*r);c<0?c=0:c>=r&&(c=r-1);var l=r-c-1,u=t[l*i*3+3*h+0],d=t[l*i*3+3*h+1],f=t[l*i*3+3*h+2];return{r:u,g:d,b:f}},e})();i.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))],i.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)],i.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)],i.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))],i.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)],i.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.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):t<-1074?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;n32767)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,d=0,f=new ArrayBuffer(4*h),p=new Uint8Array(f),_=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,d=0;d<4;d++)for(u=(d+1)*h;l128){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;gthis.max.y||this.min.y>this.max.y||this.min.z>this.max.y},t})();i.MAX=Number.MAX_VALUE,i.MIN=Number.MIN_VALUE;var r=(function(){function e(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 e.prototype.filterCubeMap=function(){return this.init(),this.filterCubeMapMipChain(),this._outputSurface},e.prototype.init=function(){var t,i,r;for(0==this.maxNumMipLevels&&(this.maxNumMipLevels=e.CP_MAX_MIPLEVELS),r=this.outputSize,i=0;i>=1,this._numMipLevels++,0==r)return void(this.maxNumMipLevels=i)}},e.prototype.filterCubeMapMipChain=function(){var e=this.specularPower;this.precomputeFilterLookupTables(this.inputSize);for(var t=0;t>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}},e.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},e.prototype.precomputeFilterLookupTables=function(e){this._normCubeMap=[],this.buildNormalizerSolidAngleCubemap(e)},e.prototype.buildNormalizerSolidAngleCubemap=function(e){var t,i,r;for(t=0;t<6;t++){this._normCubeMap.push(new Float32Array(e*e*4));this.input[t];for(r=0;r1){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=e._sgFace2DMapping[t][e.CP_UDIR];e._vectorTemp.x=c[0]*s,e._vectorTemp.y=c[1]*s,e._vectorTemp.z=c[2]*s;var l=e._sgFace2DMapping[t][e.CP_VDIR];e._vectorTemp.x+=l[0]*a,e._vectorTemp.y+=l[1]*a,e._vectorTemp.z+=l[2]*a;var u=e._sgFace2DMapping[t][e.CP_FACEAXIS];return e._vectorTemp.x+=u[0],e._vectorTemp.y+=u[1],e._vectorTemp.z+=u[2],e._vectorTemp.normalize(),e._vectorTemp},e.prototype.vectToTexelCoord=function(t,i,r,n){var o,s,a=Math.abs(t),h=Math.abs(i),c=Math.abs(r);a>=h&&a>=c?(o=a,s=t>=0?e.CP_FACE_X_POS:e.CP_FACE_X_NEG):h>=a&&h>=c?(o=h,s=i>=0?e.CP_FACE_Y_POS:e.CP_FACE_Y_NEG):(o=c,s=r>=0?e.CP_FACE_Z_POS:e.CP_FACE_Z_NEG);var l=1/o;t*=l,i*=l,r*=l;var u=e._sgFace2DMapping[s][e.CP_UDIR],d=u[0]*t+u[1]*i+u[2]*r;u=e._sgFace2DMapping[s][e.CP_VDIR];var f=u[0]*t+u[1]*i+u[2]*r,p=Math.floor(.5*(n-1)*(d+1)),_=Math.floor(.5*(n-1)*(f+1));return e._vectorTemp.x=s,e._vectorTemp.y=p,e._vectorTemp.z=_,e._vectorTemp},e.prototype.areaElement=function(e,t){return Math.atan2(e*t,Math.sqrt(e*e+t*t+1))},e.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},e.prototype.filterCubeSurfaces=function(e,t,r,n,o,s){var a,h,c,l=[];for(a=0;a<6;a++)l.push(new i);var u=180/Math.PI*Math.atan2(1,t),d=o/2;d90&&(d=90);var f=Math.ceil(d/u);f<1&&(f=1);var p=Math.cos(Math.PI/180*d);for(a=0;a<6;a++)for(c=0;c0){switch(o=e._sgCubeNgh[d][y][0],s=e._sgCubeNgh[d][y][1],y!=s&&y+s!=3||(c[y]=i-1-c[y],l[y]=i-1-l[y]),e._sgCubeNgh[d][y][1]){case e.CP_EDGE_LEFT:n[o].augment(0,c[y],0),n[o].augment(h[y],l[y],0);break;case e.CP_EDGE_RIGHT:n[o].augment(i-1,c[y],0),n[o].augment(i-1-h[y],l[y],0);break;case e.CP_EDGE_TOP:n[o].augment(c[y],0,0),n[o].augment(l[y],h[y],0);break;case e.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(d){case e.CP_FACE_X_POS:a=e.CP_FACE_X_NEG;break;case e.CP_FACE_X_NEG:a=e.CP_FACE_X_POS;break;case e.CP_FACE_Y_POS:a=e.CP_FACE_Y_NEG;break;case e.CP_FACE_Y_NEG:a=e.CP_FACE_Y_POS;break;case e.CP_FACE_Z_POS:a=e.CP_FACE_Z_NEG;break;case e.CP_FACE_Z_NEG:a=e.CP_FACE_Z_POS}n[a].augment(0,0,0),n[a].augment(i-1,i-1,0)}}},e.prototype.processFilterExtents=function(t,i,r,n,o,s){for(var a=[0,0,0,0],h=0,c=0,l=this.numChannels,u=o,d=4*u,f=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),A=g;A<=y;A++){for(var E=0,T=0,P=m;P<=v;P++){var M=this._normCubeMap[_][x+E+0],S=this._normCubeMap[_][x+E+1],C=this._normCubeMap[_][x+E+2],R=M*t.x+S*t.y+C*t.z;if(R>=i&&R>0){var O=this._normCubeMap[_][x+E+3];for(O*=Math.pow(R,s+p),c=0;c3&&(e._vectorTemp.w=a[3]/h);else{var I=this.vectToTexelCoord(t.x,t.y,t.z,o).clone();e._vectorTemp.x=n[I.x][this.numChannels*(I.z*o+I.y)+0],e._vectorTemp.y=n[I.x][this.numChannels*(I.z*o+I.y)+1],e._vectorTemp.z=n[I.x][this.numChannels*(I.z*o+I.y)+2],this.numChannels>3&&(e._vectorTemp.z=n[I.x][this.numChannels*(I.z*o+I.y)+3])}return e._vectorTemp},e.prototype.fixupCubeEdges=function(t,i){var r,n,o,s,a=0,h=[0,0,0,0,0,0,0,0],c=[[],[],[],[]],l=[[[],[],[]],[[],[],[]],[[],[],[]],[[],[],[]],[[],[],[]],[[],[],[]],[[],[],[]],[[],[],[]]];if(!(i<1))if(1!=i){for(s=0;s<6;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;a<4;a++){var u=e._sgCubeCornerList[s][a];l[u][h[u]]=c[a],h[u]++}for(a=0;a<8;a++)for(r=0;r>s,2),h=0;h<6;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;l<6;l++)h.push(r.subarray(a,a+c)),a+=c;for(var u=[],d=null,f=0;f<6;f++){var p=null;if(n)p=h[f];else{var _=[0,2,4,1,3,5][f];if(p=h[_],!t.getScene().getEngine().getCaps().textureFloat){var m=new ArrayBuffer(c);d=new Uint8Array(m)}for(var g=0;g255){var A=255/b;v*=A,y*=A,x*=A}d[3*g+0]=v,d[3*g+1]=y,d[3*g+2]=x}}d?u.push(d):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;a<6;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;l255){var _=255/p;u*=_,d*=_,f*=_}s[3*l+0]=u,s[3*l+1]=d,s[3*l+2]=f}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,t.generateHarmonics,t.useInGammaSpace,t.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.customType="BABYLON.HDRCubeTexture",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>l;c+=6*u*u*3*4}var d=new ArrayBuffer(c),f=new Int32Array(d),p=new Float32Array(d);f[0]=1,f[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),f[29]=h.length;for(var _=30,l=0;l>l,2),g=0;g<6;g++)p.set(h[l][g],_),_+=m;r(d)};e.Tools.LoadFile(t,(function(e){o(e)}),null,null,!0,n)},i})(e.BaseTexture);t._facesMapping=["right","up","front","left","down","back"],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;n=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),s.getAbsolutePositionToRef(this.mesh,h[0]),a.getAbsolutePositionToRef(this.mesh,h[1]),n++}}},t.prototype.update=function(){this.autoUpdateBonesMatrices&&this.skeleton.computeAbsoluteTransforms(),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.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(t){var i=(function(){function t(t,i){void 0===i&&(i=1),this._xline=[e.Vector3.Zero(),e.Vector3.Zero()],this._yline=[e.Vector3.Zero(),e.Vector3.Zero()],this._zline=[e.Vector3.Zero(),e.Vector3.Zero()],this.scaleLines=1,this.scaleLines=i,this._xmesh=e.Mesh.CreateLines("xline",this._xline,t,!0),this._ymesh=e.Mesh.CreateLines("yline",this._yline,t,!0),this._zmesh=e.Mesh.CreateLines("zline",this._zline,t,!0),this._xmesh.renderingGroupId=2,this._ymesh.renderingGroupId=2,this._zmesh.renderingGroupId=2,this._xmesh.material.checkReadyOnlyOnce=!0,this._xmesh.color=new e.Color3(1,0,0),this._ymesh.material.checkReadyOnlyOnce=!0,this._ymesh.color=new e.Color3(0,1,0),this._zmesh.material.checkReadyOnlyOnce=!0,this._zmesh.color=new e.Color3(0,0,1),this.scene=t}return t.prototype.update=function(t,i,r,n){var o=this.scaleLines,s=this._xline[0],a=this._xline[1];s.x=t.x,s.y=t.y,s.z=t.z,a.x=s.x+i.x*o,a.y=s.y+i.y*o,a.z=s.z+i.z*o,e.Mesh.CreateLines(null,this._xline,null,null,this._xmesh),s=this._yline[0],a=this._yline[1],s.x=t.x,s.y=t.y,s.z=t.z,a.x=s.x+r.x*o,a.y=s.y+r.y*o,a.z=s.z+r.z*o,e.Mesh.CreateLines(null,this._yline,null,null,this._ymesh),s=this._zline[0],a=this._zline[1],s.x=t.x,s.y=t.y,s.z=t.z,a.x=s.x+n.x*o,a.y=s.y+n.y*o,a.z=s.z+n.z*o,e.Mesh.CreateLines(null,this._zline,null,null,this._zmesh)},t.prototype.dispose=function(){this._xmesh&&(this._xmesh.dispose(),this._ymesh.dispose(),this._zmesh.dispose(),this._xmesh=null,this._ymesh=null,this._zmesh=null,this._xline=null,this._yline=null,this._zline=null,this.scene=null)},t})();t.AxesViewer=i})(t=e.Debug||(e.Debug={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t;!(function(t){var i=(function(t){function i(i,r,n,o){void 0===o&&(o=1);var s=t.call(this,i,o)||this;return s.pos=e.Vector3.Zero(),s.xaxis=e.Vector3.Zero(),s.yaxis=e.Vector3.Zero(),s.zaxis=e.Vector3.Zero(),s.mesh=n,s.bone=r,s}return __extends(i,t),i.prototype.update=function(){var i=this.bone;i.getAbsolutePositionToRef(this.mesh,this.pos),i.getDirectionToRef(e.Axis.X,this.mesh,this.xaxis),i.getDirectionToRef(e.Axis.Y,this.mesh,this.yaxis),i.getDirectionToRef(e.Axis.Z,this.mesh,this.zaxis),t.prototype.update.call(this,this.pos,this.xaxis,this.yaxis,this.zaxis)},i.prototype.dispose=function(){this.pos&&(this.pos=null,this.xaxis=null,this.yaxis=null,this.zaxis=null,this.mesh=null,this.bone=null,t.prototype.dispose.call(this))},i})(t.AxesViewer);t.BoneAxesViewer=i})(t=e.Debug||(e.Debug={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r){var n=t.call(this,r)||this;return i?(n._textureMatrix=e.Matrix.Identity(),n.name=i,n.url=i,n.hasAlpha=!1,n.isCube=!1,n.wrapU=e.Texture.CLAMP_ADDRESSMODE,n.wrapV=e.Texture.CLAMP_ADDRESSMODE,n.anisotropicFilteringLevel=1,n._texture=n._getFromCache(i,!0),n._texture||(r.useDelayedTextureLoading?n.delayLoadState=e.Engine.DELAYLOADSTATE_NOTLOADED:n.loadTexture()),n):n}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,d=0,f=0,p=0;p0||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),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),void 0===this.metallic&&void 0===this.roughness||(this._defines.METALLICWORKFLOW=!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=this._defines.toString(),u=["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"],d=["albedoSampler","ambientSampler","opacitySampler","reflectionCubeSampler","reflection2DSampler","emissiveSampler","reflectivitySampler","bumpSampler","lightmapSampler","refractionCubeSampler","refraction2DSampler"];e.ColorCurves.PrepareUniforms(u),e.ColorGradingTexture.PrepareUniformsAndSamplers(u,d),e.MaterialHelper.PrepareUniformsAndSamplersList(u,d,this._defines,this.maxSimultaneousLights),this._effect=n.getEngine().createEffect("pbr",c,u,d,l,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)},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.setFloat3("vAmbientInfos",this.ambientTexture.coordinatesIndex,this.ambientTexture.level,this.ambientTextureStrength),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())),e.StandardMaterial.SpecularTextureEnabled&&(this.metallicTexture?(this._effect.setTexture("reflectivitySampler",this.metallicTexture),this._effect.setFloat2("vReflectivityInfos",this.metallicTexture.coordinatesIndex,this.metallicTexture.level),this._effect.setMatrix("reflectivityMatrix",this.metallicTexture.getTextureMatrix())):this.reflectivityTexture&&(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)}(this.reflectionTexture||this.refractionTexture)&&this._effect.setFloat2("vMicrosurfaceTextureLods",this._microsurfaceTextureLods.x,this._microsurfaceTextureLods.y),this.cameraColorGradingTexture&&e.StandardMaterial.ColorGradingTextureEnabled&&e.ColorGradingTexture.Bind(this.cameraColorGradingTexture,this._effect)}e.MaterialHelper.BindClipPlane(this._effect,this._myScene),this.pointsCloud&&this._effect.setFloat("pointSize",this.pointSize),this._myScene.ambientColor.multiplyToRef(this.ambientColor,this._globalAmbientColor),this._defines.METALLICWORKFLOW?(r._scaledReflectivity.r=void 0===this.metallic?1:this.metallic,r._scaledReflectivity.g=void 0===this.roughness?1:this.roughness,this._effect.setColor4("vReflectivityColor",r._scaledReflectivity,0)):(this.convertColorToLinearSpaceToRef(this.reflectivityColor,r._scaledReflectivity),this._effect.setColor4("vReflectivityColor",r._scaledReflectivity,this.microSurface)),this._effect.setVector3("vEyePosition",this._myScene._mirroredCameraPosition?this._myScene._mirroredCameraPosition:this._myScene.activeCamera.position),this._effect.setColor3("vAmbientColor",this._globalAmbientColor),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._effect.setColor3("vOverloadedAmbient",this.overloadedAmbient),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.metallicTexture&&this.metallicTexture.animations&&this.metallicTexture.animations.length>0?e.push(this.metallicTexture):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.metallicTexture&&this.metallicTexture.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})(e.Material);i._scaledAlbedo=new e.Color3,i._scaledReflectivity=new e.Color3,i._scaledEmissive=new e.Color3,i._scaledReflection=new e.Color3,__decorate([e.serialize()],i.prototype,"directIntensity",void 0),__decorate([e.serialize()],i.prototype,"emissiveIntensity",void 0),__decorate([e.serialize()],i.prototype,"environmentIntensity",void 0),__decorate([e.serialize()],i.prototype,"specularIntensity",void 0),__decorate([e.serialize()],i.prototype,"disableBumpMap",void 0),__decorate([e.serialize()],i.prototype,"overloadedShadowIntensity",void 0),__decorate([e.serialize()],i.prototype,"overloadedShadeIntensity",void 0),__decorate([e.serialize()],i.prototype,"cameraExposure",void 0),__decorate([e.serialize()],i.prototype,"cameraContrast",void 0),__decorate([e.serializeAsTexture()],i.prototype,"cameraColorGradingTexture",void 0),__decorate([e.serializeAsColorCurves()],i.prototype,"cameraColorCurves",void 0),__decorate([e.serializeAsColor3()],i.prototype,"overloadedAmbient",void 0),__decorate([e.serialize()],i.prototype,"overloadedAmbientIntensity",void 0),__decorate([e.serializeAsColor3()],i.prototype,"overloadedAlbedo",void 0),__decorate([e.serialize()],i.prototype,"overloadedAlbedoIntensity",void 0),__decorate([e.serializeAsColor3()],i.prototype,"overloadedReflectivity",void 0),__decorate([e.serialize()],i.prototype,"overloadedReflectivityIntensity",void 0),__decorate([e.serializeAsColor3()],i.prototype,"overloadedEmissive",void 0),__decorate([e.serialize()],i.prototype,"overloadedEmissiveIntensity",void 0),__decorate([e.serializeAsColor3()],i.prototype,"overloadedReflection",void 0),__decorate([e.serialize()],i.prototype,"overloadedReflectionIntensity",void 0),__decorate([e.serialize()],i.prototype,"overloadedMicroSurface",void 0),__decorate([e.serialize()],i.prototype,"overloadedMicroSurfaceIntensity",void 0),__decorate([e.serializeAsTexture()],i.prototype,"albedoTexture",void 0),__decorate([e.serializeAsTexture()],i.prototype,"ambientTexture",void 0),__decorate([e.serialize()],i.prototype,"ambientTextureStrength",void 0),__decorate([e.serializeAsTexture()],i.prototype,"opacityTexture",void 0),__decorate([e.serializeAsTexture()],i.prototype,"reflectionTexture",void 0),__decorate([e.serializeAsTexture()],i.prototype,"emissiveTexture",void 0),__decorate([e.serializeAsTexture()],i.prototype,"reflectivityTexture",void 0),__decorate([e.serializeAsTexture()],i.prototype,"metallicTexture",void 0),__decorate([e.serialize()],i.prototype,"metallic",void 0),__decorate([e.serialize()],i.prototype,"roughness",void 0),__decorate([e.serializeAsTexture()],i.prototype,"bumpTexture",void 0),__decorate([e.serializeAsTexture()],i.prototype,"lightmapTexture",void 0),__decorate([e.serializeAsTexture()],i.prototype,"refractionTexture",void 0),__decorate([e.serializeAsColor3("ambient")],i.prototype,"ambientColor",void 0),__decorate([e.serializeAsColor3("albedo")],i.prototype,"albedoColor",void 0),__decorate([e.serializeAsColor3("reflectivity")],i.prototype,"reflectivityColor",void 0),__decorate([e.serializeAsColor3("reflection")],i.prototype,"reflectionColor",void 0),__decorate([e.serializeAsColor3("emissive")],i.prototype,"emissiveColor",void 0),__decorate([e.serialize()],i.prototype,"microSurface",void 0),__decorate([e.serialize()],i.prototype,"indexOfRefraction",void 0),__decorate([e.serialize()],i.prototype,"invertRefractionY",void 0),__decorate([e.serializeAsFresnelParameters()],i.prototype,"opacityFresnelParameters",void 0),__decorate([e.serializeAsFresnelParameters()],i.prototype,"emissiveFresnelParameters",void 0),__decorate([e.serialize()],i.prototype,"linkRefractionWithTransparency",void 0),__decorate([e.serialize()],i.prototype,"linkEmissiveWithAlbedo",void 0),__decorate([e.serialize()],i.prototype,"useLightmapAsShadowmap",void 0),__decorate([e.serialize()],i.prototype,"useEmissiveAsIllumination",void 0),__decorate([e.serialize()],i.prototype,"useAlphaFromAlbedoTexture",void 0),__decorate([e.serialize()],i.prototype,"useSpecularOverAlpha",void 0),__decorate([e.serialize()],i.prototype,"useMicroSurfaceFromReflectivityMapAlpha",void 0),__decorate([e.serialize()],i.prototype,"useRoughnessFromMetallicTextureAlpha",void 0),__decorate([e.serialize()],i.prototype,"useRoughnessFromMetallicTextureGreen",void 0),__decorate([e.serialize()],i.prototype,"useAutoMicroSurfaceFromReflectivityMap",void 0),__decorate([e.serialize()],i.prototype,"useScalarInLinearSpace",void 0),__decorate([e.serialize()],i.prototype,"usePhysicalLightFalloff",void 0),__decorate([e.serialize()],i.prototype,"useRadianceOverAlpha",void 0),__decorate([e.serialize()],i.prototype,"useParallax",void 0),__decorate([e.serialize()],i.prototype,"useParallaxOcclusion",void 0),__decorate([e.serialize()],i.prototype,"parallaxScaleBias",void 0),__decorate([e.serialize()],i.prototype,"disableLighting",void 0),__decorate([e.serialize()],i.prototype,"maxSimultaneousLights",void 0),__decorate([e.serialize()],i.prototype,"invertNormalMapX",void 0),__decorate([e.serialize()],i.prototype,"invertNormalMapY",void 0),__decorate([e.serialize()],i.prototype,"useLogarithmicDepth",null),e.PBRMaterial=i})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(e){this._scene=e}return t.prototype._createInspector=function(e){this._inspector||(this._inspector=new INSPECTOR.Inspector(this._scene,e))},t.prototype.isVisible=function(){return!1},t.prototype.hide=function(){this._inspector&&(this._inspector.dispose(),this._inspector=null)},t.prototype.show=function(i){"undefined"==typeof INSPECTOR?e.Tools.LoadScript(t.InspectorURL,this._createInspector.bind(this,i)):this._createInspector(i)},t})();t.InspectorURL="http://www.babylonjs.com/babylon.inspector.bundle.js",e.DebugLayer=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,o,s){void 0===o&&(o=null);var a=t.call(this,r.getEngine(),i)||this;return a.downSampleX4PostProcess=null,a.brightPassPostProcess=null,a.gaussianBlurHPostProcesses=[],a.gaussianBlurVPostProcesses=[],a.textureAdderPostProcess=null,a.textureAdderFinalPostProcess=null,a.lensFlarePostProcess=null,a.lensFlareComposePostProcess=null,a.depthOfFieldPostProcess=null,a.brightThreshold=1,a.blurWidth=2,a.gaussianCoefficient=.25,a.gaussianMean=1,a.gaussianStandardDeviation=1,a.exposure=1,a.lensTexture=null,a.lensColorTexture=null,a.lensFlareStrength=20,a.lensFlareGhostDispersal=1.4,a.lensFlareHaloWidth=.7,a.lensFlareDistortionStrength=16,a.lensStarTexture=null,a.lensFlareDirtTexture=null,a.depthOfFieldDistance=10,a.animations=[],a._depthRenderer=null,a._depthOfFieldEnabled=!0,a._lensFlareEnabled=!0,a._scene=r,o?a.originalPostProcess=o:a.originalPostProcess=new e.PostProcess("HDRPass","standard",[],[],n,null,e.Texture.BILINEAR_SAMPLINGMODE,r.getEngine(),(!0),"#define PASS_POST_PROCESS",e.Engine.TEXTURETYPE_FLOAT),a.addEffect(new e.PostProcessRenderEffect(r.getEngine(),"HDRPassPostProcess",function(){return a.originalPostProcess},(!0))),a._createDownSampleX4PostProcess(r,n/2),a._createBrightPassPostProcess(r,n/2),a._createGaussianBlurPostProcesses(r,n/2,0),a._createGaussianBlurPostProcesses(r,n/4,1),a._createGaussianBlurPostProcesses(r,n/8,2),a._createGaussianBlurPostProcesses(r,n/16,3),a._createTextureAdderPostProcess(r,n),a.textureAdderFinalPostProcess=new e.PostProcess("HDRDepthOfFieldSource","standard",[],[],n,null,e.Texture.BILINEAR_SAMPLINGMODE,r.getEngine(),(!0),"#define PASS_POST_PROCESS",e.Engine.TEXTURETYPE_UNSIGNED_INT),a.addEffect(new e.PostProcessRenderEffect(r.getEngine(),"HDRDepthOfFieldSource",function(){return a.textureAdderFinalPostProcess},(!0))),a._createLensFlarePostProcess(r,n),a._createGaussianBlurPostProcesses(r,n/2,5),a._createDepthOfFieldPostProcess(r,n),r.postProcessRenderPipelineManager.addPipeline(a),null!==s&&r.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(i,s),a.LensFlareEnabled=!1,a.DepthOfFieldEnabled=!1,a}return __extends(i,t),Object.defineProperty(i.prototype,"DepthOfFieldEnabled",{get:function(){return this._depthOfFieldEnabled},set:function(e){var t=this.gaussianBlurHPostProcesses.length-1;e&&!this._depthOfFieldEnabled?(this._scene.postProcessRenderPipelineManager.enableEffectInPipeline(this._name,"HDRGaussianBlurH"+t,this._scene.cameras),this._scene.postProcessRenderPipelineManager.enableEffectInPipeline(this._name,"HDRGaussianBlurV"+t,this._scene.cameras),this._scene.postProcessRenderPipelineManager.enableEffectInPipeline(this._name,"HDRDepthOfField",this._scene.cameras),this._depthRenderer=this._scene.enableDepthRenderer()):!e&&this._depthOfFieldEnabled&&(this._scene.postProcessRenderPipelineManager.disableEffectInPipeline(this._name,"HDRGaussianBlurH"+t,this._scene.cameras),this._scene.postProcessRenderPipelineManager.disableEffectInPipeline(this._name,"HDRGaussianBlurV"+t,this._scene.cameras),this._scene.postProcessRenderPipelineManager.disableEffectInPipeline(this._name,"HDRDepthOfField",this._scene.cameras)),this._depthOfFieldEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"LensFlareEnabled",{get:function(){return this._lensFlareEnabled},set:function(e){var t=this.gaussianBlurHPostProcesses.length-2;e&&!this._lensFlareEnabled?(this._scene.postProcessRenderPipelineManager.enableEffectInPipeline(this._name,"HDRLensFlare",this._scene.cameras),this._scene.postProcessRenderPipelineManager.enableEffectInPipeline(this._name,"HDRLensFlareShift",this._scene.cameras),this._scene.postProcessRenderPipelineManager.enableEffectInPipeline(this._name,"HDRGaussianBlurH"+t,this._scene.cameras),this._scene.postProcessRenderPipelineManager.enableEffectInPipeline(this._name,"HDRGaussianBlurV"+t,this._scene.cameras),this._scene.postProcessRenderPipelineManager.enableEffectInPipeline(this._name,"HDRLensFlareCompose",this._scene.cameras)):!e&&this._lensFlareEnabled&&(this._scene.postProcessRenderPipelineManager.disableEffectInPipeline(this._name,"HDRLensFlare",this._scene.cameras),this._scene.postProcessRenderPipelineManager.disableEffectInPipeline(this._name,"HDRLensFlareShift",this._scene.cameras),this._scene.postProcessRenderPipelineManager.disableEffectInPipeline(this._name,"HDRGaussianBlurH"+t,this._scene.cameras),this._scene.postProcessRenderPipelineManager.disableEffectInPipeline(this._name,"HDRGaussianBlurV"+t,this._scene.cameras),this._scene.postProcessRenderPipelineManager.disableEffectInPipeline(this._name,"HDRLensFlareCompose",this._scene.cameras)),this._lensFlareEnabled=e},enumerable:!0,configurable:!0}),i.prototype._createDownSampleX4PostProcess=function(t,i){var r=this,n=new Array(32);this.downSampleX4PostProcess=new e.PostProcess("HDRDownSampleX4","standard",["dsOffsets"],[],i,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),(!1),"#define DOWN_SAMPLE_X4",e.Engine.TEXTURETYPE_UNSIGNED_INT),this.downSampleX4PostProcess.onApply=function(e){for(var t=0,i=-2;i<2;i++)for(var o=-2;o<2;o++)n[t]=(i+.5)*(1/r.downSampleX4PostProcess.width),n[t+1]=(o+.5)*(1/r.downSampleX4PostProcess.height),t+=2;e.setArray2("dsOffsets",n)},this.addEffect(new e.PostProcessRenderEffect(t.getEngine(),"HDRDownSampleX4",function(){return r.downSampleX4PostProcess},(!0)))},i.prototype._createBrightPassPostProcess=function(t,i){var r=this,n=new Array(8);this.brightPassPostProcess=new e.PostProcess("HDRBrightPass","standard",["dsOffsets","brightThreshold"],[],i,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),(!1),"#define BRIGHT_PASS",e.Engine.TEXTURETYPE_UNSIGNED_INT),this.brightPassPostProcess.onApply=function(e){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.addEffect(new e.PostProcessRenderEffect(t.getEngine(),"HDRBrightPass",function(){return r.brightPassPostProcess},(!0)))},i.prototype._createGaussianBlurPostProcesses=function(t,i,r){var n=this,o=new Array(9),s=new Array(9),a=["blurOffsets","blurWeights","blurWidth"],h=function(e){return function(i){for(var r=0,a=0;a<9;a++)r=(a-4)/4,s[a]=n.gaussianCoefficient*(1/Math.sqrt(2*Math.PI*n.gaussianStandardDeviation))*Math.exp(-((r-n.gaussianMean)*(r-n.gaussianMean))/(2*n.gaussianStandardDeviation*n.gaussianStandardDeviation));for(var h={width:t.getEngine().getRenderWidth(), +height:t.getEngine().getRenderHeight()},a=0;a<9;a++){var c=(a-4)*(1/(e===!0?h.height:h.width));o[a]=c}i.setArray("blurOffsets",o),i.setArray("blurWeights",s),i.setFloat("blurWidth",n.blurWidth)}},c=new e.PostProcess("HDRGaussianBlurH"+i,"standard",a,[],i,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),(!1),"#define GAUSSIAN_BLUR_H",e.Engine.TEXTURETYPE_UNSIGNED_INT);c.onApply=h(!1);var l=new e.PostProcess("HDRGaussianBlurV"+i,"standard",a,[],i,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),(!1),"#define GAUSSIAN_BLUR_V",e.Engine.TEXTURETYPE_UNSIGNED_INT);l.onApply=h(!0),this.addEffect(new e.PostProcessRenderEffect(t.getEngine(),"HDRGaussianBlurH"+r,function(){return c},(!0))),this.addEffect(new e.PostProcessRenderEffect(t.getEngine(),"HDRGaussianBlurV"+r,function(){return l},(!0))),this.gaussianBlurHPostProcesses.push(c),this.gaussianBlurVPostProcesses.push(l)},i.prototype._createTextureAdderPostProcess=function(t,i){var r=this;this.gaussianBlurVPostProcesses[3];this.textureAdderPostProcess=new e.PostProcess("HDRTextureAdder","standard",["exposure"],["otherSampler","lensSampler"],i,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),(!1),"#define TEXTURE_ADDER",e.Engine.TEXTURETYPE_UNSIGNED_INT),this.textureAdderPostProcess.onApply=function(e){e.setTextureFromPostProcess("otherSampler",r.originalPostProcess),e.setTexture("lensSampler",r.lensTexture),e.setFloat("exposure",r.exposure)},this.addEffect(new e.PostProcessRenderEffect(t.getEngine(),"HDRTextureAdder",function(){return r.textureAdderPostProcess},(!0)))},i.prototype._createLensFlarePostProcess=function(t,i){var r=this;this.lensFlarePostProcess=new e.PostProcess("HDRLensFlare","standard",["strength","ghostDispersal","haloWidth","resolution","distortionStrength"],["lensColorSampler"],i/2,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),(!0),"#define LENS_FLARE",e.Engine.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new e.PostProcessRenderEffect(t.getEngine(),"HDRLensFlare",function(){return r.lensFlarePostProcess},(!1))),this._createGaussianBlurPostProcesses(t,i/4,4),this.lensFlareComposePostProcess=new e.PostProcess("HDRLensFlareCompose","standard",["lensStarMatrix"],["otherSampler","lensDirtSampler","lensStarSampler"],i,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),(!1),"#define LENS_FLARE_COMPOSE",e.Engine.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new e.PostProcessRenderEffect(t.getEngine(),"HDRLensFlareCompose",function(){return r.lensFlareComposePostProcess},(!1)));var n=new e.Vector2(0,0);this.lensFlarePostProcess.onApply=function(e){e.setTextureFromPostProcess("textureSampler",r.gaussianBlurHPostProcesses[0]),e.setTexture("lensColorSampler",r.lensColorTexture),e.setFloat("strength",r.lensFlareStrength),e.setFloat("ghostDispersal",r.lensFlareGhostDispersal),e.setFloat("haloWidth",r.lensFlareHaloWidth),n.x=r.lensFlarePostProcess.width,n.y=r.lensFlarePostProcess.height,e.setVector2("resolution",n),e.setFloat("distortionStrength",r.lensFlareDistortionStrength)};var o=e.Matrix.FromValues(2,0,-1,0,0,2,-1,0,0,0,1,0,0,0,0,1),s=e.Matrix.FromValues(.5,0,.5,0,0,.5,.5,0,0,0,1,0,0,0,0,1);this.lensFlareComposePostProcess.onApply=function(t){t.setTextureFromPostProcess("otherSampler",r.textureAdderFinalPostProcess),t.setTexture("lensDirtSampler",r.lensFlareDirtTexture),t.setTexture("lensStarSampler",r.lensStarTexture);var i=r._scene.activeCamera.getViewMatrix().getRow(0),n=r._scene.activeCamera.getViewMatrix().getRow(2),a=e.Vector3.Dot(i.toVector3(),new e.Vector3(1,0,0))+e.Vector3.Dot(n.toVector3(),new e.Vector3(0,0,1));a*=4;var h=e.Matrix.FromValues(.5*Math.cos(a),-Math.sin(a),0,0,Math.sin(a),.5*Math.cos(a),0,0,0,0,1,0,0,0,0,1),c=s.multiply(h).multiply(o);t.setMatrix("lensStarMatrix",c)}},i.prototype._createDepthOfFieldPostProcess=function(t,i){var r=this;this.depthOfFieldPostProcess=new e.PostProcess("HDRDepthOfField","standard",["distance"],["otherSampler","depthSampler"],i,null,e.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),(!1),"#define DEPTH_OF_FIELD",e.Engine.TEXTURETYPE_UNSIGNED_INT),this.depthOfFieldPostProcess.onApply=function(e){e.setTextureFromPostProcess("otherSampler",r.textureAdderFinalPostProcess),e.setTexture("depthSampler",r._depthRenderer.getDepthMap()),e.setFloat("distance",r.depthOfFieldDistance)},this.addEffect(new e.PostProcessRenderEffect(t.getEngine(),"HDRDepthOfField",function(){return r.depthOfFieldPostProcess},(!0)))},i.prototype.dispose=function(){for(var e=0;e0.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\n\n#include[0..maxSimultaneousLights]\n#include\n#include\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\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\n#ifdef REFLECTIONFRESNEL\nuniform vec4 reflectionLeftColor;\nuniform vec4 reflectionRightColor;\n#endif\n#endif\n#ifdef CAMERACOLORGRADING\n#include \n#include\n#endif\n#ifdef CAMERACOLORCURVES\n#include\n#include\n#endif\n#include\n#include\n#include\n#include\nvoid main(void) {\n#include\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#include\n#ifdef DIFFUSE\nbaseColor=texture2D(diffuseSampler,vDiffuseUV+uvOffset);\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+uvOffset).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+uvOffset);\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#ifdef LIGHTMAP\nvec3 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset).rgb*vLightmapInfos.y;\n#endif\n#include[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+uvOffset);\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+uvOffset).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\n#ifdef LIGHTMAP\n#ifndef LIGHTMAPEXCLUDED\n#ifdef USELIGHTMAPASSHADOWMAP\ncolor.rgb*=lightmapColor;\n#else\ncolor.rgb+=lightmapColor;\n#endif\n#endif\n#endif\n#include\n#include\n#ifdef CAMERACOLORGRADING\ncolor=colorGrades(color);\n#endif\n#ifdef CAMERACOLORCURVES\ncolor.rgb=applyColorCurves(color.rgb);\n#endif\ngl_FragColor=color;\n}",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\n\n#include\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\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include\n#include\n#include[0..maxSimultaneousLights]\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#endif\n#ifdef REFLECTIONMAP_EQUIRECTANGULAR_FIXED\nvarying vec3 vDirectionW;\n#endif\n#include\nvoid main(void) {\n#ifdef REFLECTIONMAP_SKYBOX\nvPositionUVW=position;\n#endif \n#include\n#include\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\n#include\n#include[0..maxSimultaneousLights]\n#ifdef VERTEXCOLOR\n\nvColor=color;\n#endif\n#include\n#include\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\n\n#include\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\n#include\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}",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 ((lumaBlumaMax)) {\ngl_FragColor=rgbA;\n}\nelse {\ngl_FragColor=rgbB;\n}\n}",glowBlurPostProcessPixelShader:"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n\nuniform vec2 screenSize;\nuniform vec2 direction;\nuniform float blurWidth;\n\nfloat getLuminance(vec3 color)\n{\nreturn dot(color,vec3(0.2126,0.7152,0.0722));\n}\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{\n\nvec4 texel=texture2D(textureSampler,start+texelOffset);\nbaseColor.a+=texel.a*weights[i];\n\nfloat luminance=getLuminance(baseColor.rgb);\nfloat luminanceTexel=getLuminance(texel.rgb);\nfloat choice=step(luminanceTexel,luminance);\nbaseColor.rgb=choice*baseColor.rgb+(1.0-choice)*texel.rgb;\ntexelOffset+=texelStep;\n}\ngl_FragColor=baseColor;\n}", +glowMapGenerationPixelShader:"#ifdef ALPHATEST\nvarying vec2 vUVDiffuse;\nuniform sampler2D diffuseSampler;\n#endif\n#ifdef EMISSIVE\nvarying vec2 vUVEmissive;\nuniform sampler2D emissiveSampler;\n#endif\nuniform vec4 color;\nvoid main(void)\n{\n#ifdef ALPHATEST\nif (texture2D(diffuseSampler,vUVDiffuse).a<0.4)\ndiscard;\n#endif\n#ifdef EMISSIVE\ngl_FragColor=texture2D(emissiveSampler,vUVEmissive);\n#else\ngl_FragColor=color;\n#endif\n}",glowMapGenerationVertexShader:"\nattribute vec3 position;\n#include\n\n#include\nuniform mat4 viewProjection;\nvarying vec4 vPosition;\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef ALPHATEST\nvarying vec2 vUVDiffuse;\nuniform mat4 diffuseMatrix;\n#endif\n#ifdef EMISSIVE\nvarying vec2 vUVEmissive;\nuniform mat4 emissiveMatrix;\n#endif\nvoid main(void)\n{\n#include\n#include\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 DIFFUSEUV1\nvUVDiffuse=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n#endif\n#ifdef DIFFUSEUV2\nvUVDiffuse=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n#ifdef EMISSIVE\n#ifdef EMISSIVEUV1\nvUVEmissive=vec2(emissiveMatrix*vec4(uv,1.0,0.0));\n#endif\n#ifdef EMISSIVEUV2\nvUVEmissive=vec2(emissiveMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n}",glowMapMergePixelShader:"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n\nuniform float offset;\nvoid main(void) {\nvec4 baseColor=texture2D(textureSampler,vUV);\nbaseColor.a=abs(offset-baseColor.a);\ngl_FragColor=baseColor;\n}",glowMapMergeVertexShader:"\nattribute vec2 position;\n\nvarying vec2 vUV;\nconst vec2 madd=vec2(0.5,0.5);\nvoid main(void) {\nvUV=position*madd+madd;\ngl_Position=vec4(position,0.0,1.0);\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 (luminance1.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}",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\n\nuniform float offset;\n#include\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\n#include\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[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 vec3 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) || defined(METALLICWORKFLOW) \nvarying vec2 vReflectivityUV;\nuniform vec2 vReflectivityInfos;\nuniform sampler2D reflectivitySampler;\n#endif\n\n#include\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\n#endif\n#ifdef CAMERACOLORGRADING\n#include\n#endif\n#ifdef CAMERACOLORCURVES\n#include\n#endif\n\n#include\n#include\n#ifdef CAMERACOLORGRADING\n#include\n#endif\n#ifdef CAMERACOLORCURVES\n#include\n#endif\n#include\n#include\n#include\n#include\n#include\n#include\n\n#include\nvoid main(void) {\n#include\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\n#include\n\nvec4 surfaceAlbedo=vec4(1.,1.,1.,1.);\nvec3 surfaceAlbedoContribution=vAlbedoColor.rgb;\n\nfloat alpha=vAlbedoColor.a;\n#ifdef ALBEDO\nsurfaceAlbedo=texture2D(albedoSampler,vAlbedoUV+uvOffset);\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\nvec3 ambientColor=vec3(1.,1.,1.);\n#ifdef AMBIENT\nambientColor=texture2D(ambientSampler,vAmbientUV+uvOffset).rgb*vAmbientInfos.y;\nambientColor=vec3(1.,1.,1.)-((vec3(1.,1.,1.)-ambientColor)*vAmbientInfos.z);\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+uvOffset);\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 METALLICWORKFLOW\nvec2 metallicRoughness=surfaceReflectivityColor.rg;\n#ifdef METALLICROUGHNESSMAP\nvec4 surfaceMetallicColorMap=texture2D(reflectivitySampler,vReflectivityUV+uvOffset);\n\nmetallicRoughness.r*=surfaceMetallicColorMap.r;\n#ifdef METALLICROUGHNESSGSTOREINALPHA\nmetallicRoughness.g*=surfaceMetallicColorMap.a;\n#else\n#ifdef METALLICROUGHNESSGSTOREINGREEN\nmetallicRoughness.g*=surfaceMetallicColorMap.g;\n#endif\n#endif\n#endif\n\nvec3 baseColor=surfaceAlbedo.rgb;\n\nsurfaceAlbedo.rgb*=(1.0-metallicRoughness.r);\n\n\nconst vec3 DefaultSpecularReflectanceDielectric=vec3(0.04,0.04,0.04);\n\nsurfaceReflectivityColor=mix(DefaultSpecularReflectanceDielectric,baseColor,metallicRoughness.r);\n#ifdef OVERLOADEDVALUES\nsurfaceReflectivityColor=mix(surfaceReflectivityColor,vOverloadedReflectivity,vOverloadedIntensity.z);\n#endif\nmicroSurface=1.0-metallicRoughness.g;\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.; \n#ifdef LIGHTMAP\nvec3 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset).rgb*vLightmapInfos.y;\n#endif\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[0..maxSimultaneousLights]\n#ifdef SPECULARTERM\nlightSpecularContribution*=vLightingIntensity.w;\n#endif\n#ifdef OPACITY\nvec4 opacityMap=texture2D(opacitySampler,vOpacityUV+uvOffset);\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+uvOffset).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\n#ifndef LIGHTMAPEXCLUDED\n#ifdef USELIGHTMAPASSHADOWMAP\nfinalColor.rgb*=lightmapColor;\n#else\nfinalColor.rgb+=lightmapColor;\n#endif\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\n#include(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\n\n#include\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 vec3 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) || defined(METALLICWORKFLOW) \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\n#include\n#include[0..maxSimultaneousLights]\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#endif\n#ifdef REFLECTIONMAP_EQUIRECTANGULAR_FIXED\nvarying vec3 vDirectionW;\n#endif\n#include\nvoid main(void) {\n#ifdef REFLECTIONMAP_SKYBOX\nvPositionUVW=position;\n#endif \n#include\n#include\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) || defined(METALLICWORKFLOW) \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\n\n#include\n\n#include[0..maxSimultaneousLights]\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n\n#include\n}",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}",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:"#ifndef FULLFLOAT\nvec4 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}\n#endif\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;\n#ifndef FULLFLOAT\ngl_FragColor=vec4(packHalf(moment1),packHalf(moment2));\n#else\ngl_FragColor=vec4(moment1,moment2,1.0,1.0);\n#endif\n#else\n#ifndef FULLFLOAT\ngl_FragColor=pack(depth);\n#else\ngl_FragColor=vec4(depth,1.0,1.0,1.0);\n#endif\n#endif\n}",shadowMapVertexShader:"\nattribute vec3 position;\n#include\n\n#include\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\n#include\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}",spritesPixelShader:"uniform bool alphaTest;\nvarying vec4 vColor;\n\nvarying vec2 vUV;\nuniform sampler2D diffuseSampler;\n\n#include\nvoid main(void) {\nvec4 color=texture2D(diffuseSampler,vUV);\nif (alphaTest) \n{\nif (color.a<0.95)\ndiscard;\n}\ncolor*=vColor;\n#include\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\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; i0.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}",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; i1.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:"vec2 uvOffset=vec2(0.0,0.0);\n#if defined(BUMP) || defined(PARALLAX)\nmat3 TBN=cotangent_frame(normalW*vBumpInfos.y,-viewDirectionW,vBumpUV);\n#endif\n#ifdef PARALLAX\nmat3 invTBN=transposeMat3(TBN);\n#ifdef PARALLAXOCCLUSION\nuvOffset=parallaxOcclusion(invTBN*-viewDirectionW,invTBN*normalW,vBumpUV,vBumpInfos.z);\n#else\nuvOffset=parallaxOffset(invTBN*viewDirectionW,vBumpInfos.z);\n#endif\n#endif\n#ifdef BUMP\nnormalW=perturbNormal(viewDirectionW,TBN,vBumpUV+uvOffset);\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; icurrRayHeight)\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#if defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X}) && defined(LIGHTMAPNOSPECULAR{X})\n\n#else\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#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\n#if defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X})\ndiffuseBase+=lightmapColor*shadow;\n#ifdef SPECULARTERM\n#ifndef LIGHTMAPNOSPECULAR{X}\nspecularBase+=info.specular*shadow*lightmapColor;\n#endif\n#endif\n#else\ndiffuseBase+=info.diffuse*shadow;\n#ifdef SPECULARTERM\nspecularBase+=info.specular*shadow;\n#endif\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",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#if defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X}) && defined(LIGHTMAPNOSPECULAR{X})\n\n#else\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#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\n#if defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X})\nlightDiffuseContribution+=lightmapColor*notShadowLevel;\n#ifdef SPECULARTERM\n#ifndef LIGHTMAPNOSPECULAR{X}\nlightSpecularContribution+=info.specular*notShadowLevel*lightmapColor;\n#endif\n#endif\n#else\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\n#endif",pbrShadowFunctions:"\n#ifdef SHADOWS\n#ifndef SHADOWFULLFLOAT\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}\n#endif\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;\n#ifndef SHADOWFULLFLOAT\nfloat shadow=unpack(textureCube(shadowSampler,directionToLight))+bias;\n#else\nfloat shadow=textureCube(shadowSampler,directionToLight).x+bias;\n#endif\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;\n#ifndef SHADOWFULLFLOAT\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[0]*mapSize))1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\n#ifndef SHADOWFULLFLOAT\nfloat shadow=unpack(texture2D(shadowSampler,uv))+bias;\n#else\nfloat shadow=texture2D(shadowSampler,uv).x+bias;\n#endif\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;\n#ifndef SHADOWFULLFLOAT\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[0]*mapSize))1.0 || uv.y<0. || uv.y>1.0 || depth.z>=1.0)\n{\nreturn 1.0;\n}\nvec4 texel=texture2D(shadowSampler,uv);\n#ifndef SHADOWFULLFLOAT\nvec2 moments=vec2(unpackHalf(texel.xy),unpackHalf(texel.zw));\n#else\nvec2 moments=texel.xy;\n#endif\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\n#ifndef SHADOWFULLFLOAT\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}\n#endif\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;\n#ifndef SHADOWFULLFLOAT\nfloat shadow=unpack(textureCube(shadowSampler,directionToLight))+bias;\n#else\nfloat shadow=textureCube(shadowSampler,directionToLight).x+bias;\n#endif\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;\n#ifndef SHADOWFULLFLOAT\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[0]*mapSize))1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\n#ifndef SHADOWFULLFLOAT\nfloat shadow=unpack(texture2D(shadowSampler,uv))+bias;\n#else\nfloat shadow=texture2D(shadowSampler,uv).x+bias;\n#endif\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;\n#ifndef SHADOWFULLFLOAT\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[0]*mapSize))1.0 || uv.y<0. || uv.y>1.0 || depth.z>=1.0)\n{\nreturn 1.0;\n}\nvec4 texel=texture2D(shadowSampler,uv);\n#ifndef SHADOWFULLFLOAT\nvec2 moments=vec2(unpackHalf(texel.xy),unpackHalf(texel.zw));\n#else\nvec2 moments=texel.xy;\n#endif\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"},("undefined"!=typeof window&&window.module||"undefined"!=typeof module)&&"undefined"!=typeof module.exports&&(module.exports=BABYLON); \ No newline at end of file