123456789101112131415161718192021222324252627282930313233343536 |
- var __decorate=this&&this.__decorate||function(e,t,r,i){var n,o=arguments.length,s=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,r,i);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(s=(o<3?n(s):o>3?n(t,r,s):n(t,r))||s);return o>3&&s&&Object.defineProperty(t,r,s),s},__extends=this&&this.__extends||(function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)t.hasOwnProperty(r)&&(e[r]=t[r])};return function(t,r){function i(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(i.prototype=r.prototype,new i)}})(),BABYLON;!(function(e){e.ToGammaSpace=1/2.2,e.ToLinearSpace=2.2,e.Epsilon=.001;var t=(function(){function t(e,t,r){void 0===e&&(e=0),void 0===t&&(t=0),void 0===r&&(r=0),this.r=e,this.g=t,this.b=r}return t.prototype.toString=function(){return"{R: "+this.r+" G:"+this.g+" B:"+this.b+"}"},t.prototype.getClassName=function(){return"Color3"},t.prototype.getHashCode=function(){var e=this.r||0;return e=397*e^(this.g||0),e=397*e^(this.b||0)},t.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},t.prototype.toColor4=function(e){return void 0===e&&(e=1),new r(this.r,this.g,this.b,e)},t.prototype.asArray=function(){var e=[];return this.toArray(e,0),e},t.prototype.toLuminance=function(){return.3*this.r+.59*this.g+.11*this.b},t.prototype.multiply=function(e){return new t(this.r*e.r,this.g*e.g,this.b*e.b)},t.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},t.prototype.equals=function(e){return e&&this.r===e.r&&this.g===e.g&&this.b===e.b},t.prototype.equalsFloats=function(e,t,r){return this.r===e&&this.g===t&&this.b===r},t.prototype.scale=function(e){return new t(this.r*e,this.g*e,this.b*e)},t.prototype.scaleToRef=function(e,t){return t.r=this.r*e,t.g=this.g*e,t.b=this.b*e,this},t.prototype.add=function(e){return new t(this.r+e.r,this.g+e.g,this.b+e.b)},t.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},t.prototype.subtract=function(e){return new t(this.r-e.r,this.g-e.g,this.b-e.b)},t.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},t.prototype.clone=function(){return new t(this.r,this.g,this.b)},t.prototype.copyFrom=function(e){return this.r=e.r,this.g=e.g,this.b=e.b,this},t.prototype.copyFromFloats=function(e,t,r){return this.r=e,this.g=t,this.b=r,this},t.prototype.set=function(e,t,r){return this.copyFromFloats(e,t,r)},t.prototype.toHexString=function(){var t=255*this.r|0,r=255*this.g|0,i=255*this.b|0;return"#"+e.Scalar.ToHex(t)+e.Scalar.ToHex(r)+e.Scalar.ToHex(i)},t.prototype.toLinearSpace=function(){var e=new t;return this.toLinearSpaceToRef(e),e},t.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},t.prototype.toGammaSpace=function(){var e=new t;return this.toGammaSpaceToRef(e),e},t.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},t.FromHexString=function(e){if("#"!==e.substring(0,1)||7!==e.length)return new t(0,0,0);var r=parseInt(e.substring(1,3),16),i=parseInt(e.substring(3,5),16),n=parseInt(e.substring(5,7),16);return t.FromInts(r,i,n)},t.FromArray=function(e,r){return void 0===r&&(r=0),new t(e[r],e[r+1],e[r+2])},t.FromInts=function(e,r,i){return new t(e/255,r/255,i/255)},t.Lerp=function(e,r,i){return new t(e.r+(r.r-e.r)*i,e.g+(r.g-e.g)*i,e.b+(r.b-e.b)*i)},t.Red=function(){return new t(1,0,0)},t.Green=function(){return new t(0,1,0)},t.Blue=function(){return new t(0,0,1)},t.Black=function(){return new t(0,0,0)},t.White=function(){return new t(1,1,1)},t.Purple=function(){return new t(.5,0,.5)},t.Magenta=function(){return new t(1,0,1)},t.Yellow=function(){return new t(1,1,0)},t.Gray=function(){return new t(.5,.5,.5)},t.Teal=function(){return new t(0,1,1)},t.Random=function(){return new t(Math.random(),Math.random(),Math.random())},t})();e.Color3=t;var r=(function(){function t(e,t,r,i){void 0===e&&(e=0),void 0===t&&(t=0),void 0===r&&(r=0),void 0===i&&(i=1),this.r=e,this.g=t,this.b=r,this.a=i}return t.prototype.addInPlace=function(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this.a+=e.a,this},t.prototype.asArray=function(){var e=[];return this.toArray(e,0),e},t.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},t.prototype.add=function(e){return new t(this.r+e.r,this.g+e.g,this.b+e.b,this.a+e.a)},t.prototype.subtract=function(e){return new t(this.r-e.r,this.g-e.g,this.b-e.b,this.a-e.a)},t.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},t.prototype.scale=function(e){return new t(this.r*e,this.g*e,this.b*e,this.a*e)},t.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},t.prototype.multiply=function(e){return new t(this.r*e.r,this.g*e.g,this.b*e.b,this.a*e.a)},t.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},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 e=this.r||0;return e=397*e^(this.g||0),e=397*e^(this.b||0),e=397*e^(this.a||0)},t.prototype.clone=function(){return new t(this.r,this.g,this.b,this.a)},t.prototype.copyFrom=function(e){return this.r=e.r,this.g=e.g,this.b=e.b,this.a=e.a,this},t.prototype.copyFromFloats=function(e,t,r,i){return this.r=e,this.g=t,this.b=r,this.a=i,this},t.prototype.set=function(e,t,r,i){return this.copyFromFloats(e,t,r,i)},t.prototype.toHexString=function(){var t=255*this.r|0,r=255*this.g|0,i=255*this.b|0,n=255*this.a|0;return"#"+e.Scalar.ToHex(t)+e.Scalar.ToHex(r)+e.Scalar.ToHex(i)+e.Scalar.ToHex(n)},t.prototype.toLinearSpace=function(){var e=new t;return this.toLinearSpaceToRef(e),e},t.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),t.a=this.a,this},t.prototype.toGammaSpace=function(){var e=new t;return this.toGammaSpaceToRef(e),e},t.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),t.a=this.a,this},t.FromHexString=function(e){if("#"!==e.substring(0,1)||9!==e.length)return new t(0,0,0,0);var r=parseInt(e.substring(1,3),16),i=parseInt(e.substring(3,5),16),n=parseInt(e.substring(5,7),16),o=parseInt(e.substring(7,9),16);return t.FromInts(r,i,n,o)},t.Lerp=function(e,r,i){var n=new t(0,0,0,0);return t.LerpToRef(e,r,i,n),n},t.LerpToRef=function(e,t,r,i){i.r=e.r+(t.r-e.r)*r,i.g=e.g+(t.g-e.g)*r,i.b=e.b+(t.b-e.b)*r,i.a=e.a+(t.a-e.a)*r},t.FromArray=function(e,r){return void 0===r&&(r=0),new t(e[r],e[r+1],e[r+2],e[r+3])},t.FromInts=function(e,r,i,n){return new t(e/255,r/255,i/255,n/255)},t.CheckColors4=function(e,t){if(e.length===3*t){for(var r=[],i=0;i<e.length;i+=3){var n=i/3*4;r[n]=e[i],r[n+1]=e[i+1],r[n+2]=e[i+2],r[n+3]=1}return r}return e},t})();e.Color4=r;var i=(function(){function t(e,t){this.x=e,this.y=t}return t.prototype.toString=function(){return"{X: "+this.x+" Y:"+this.y+"}"},t.prototype.getClassName=function(){return"Vector2"},t.prototype.getHashCode=function(){var e=this.x||0;return e=397*e^(this.y||0)},t.prototype.toArray=function(e,t){return void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,this},t.prototype.asArray=function(){var e=[];return this.toArray(e,0),e},t.prototype.copyFrom=function(e){return this.x=e.x,this.y=e.y,this},t.prototype.copyFromFloats=function(e,t){return this.x=e,this.y=t,this},t.prototype.set=function(e,t){return this.copyFromFloats(e,t)},t.prototype.add=function(e){return new t(this.x+e.x,this.y+e.y)},t.prototype.addToRef=function(e,t){return t.x=this.x+e.x,t.y=this.y+e.y,this},t.prototype.addInPlace=function(e){return this.x+=e.x,this.y+=e.y,this},t.prototype.addVector3=function(e){return new t(this.x+e.x,this.y+e.y)},t.prototype.subtract=function(e){return new t(this.x-e.x,this.y-e.y)},t.prototype.subtractToRef=function(e,t){return t.x=this.x-e.x,t.y=this.y-e.y,this},t.prototype.subtractInPlace=function(e){return this.x-=e.x,this.y-=e.y,this},t.prototype.multiplyInPlace=function(e){return this.x*=e.x,this.y*=e.y,this},t.prototype.multiply=function(e){return new t(this.x*e.x,this.y*e.y)},t.prototype.multiplyToRef=function(e,t){return t.x=this.x*e.x,t.y=this.y*e.y,this},t.prototype.multiplyByFloats=function(e,r){return new t(this.x*e,this.y*r)},t.prototype.divide=function(e){return new t(this.x/e.x,this.y/e.y)},t.prototype.divideToRef=function(e,t){return t.x=this.x/e.x,t.y=this.y/e.y,this},t.prototype.negate=function(){return new t(-this.x,-this.y)},t.prototype.scaleInPlace=function(e){return this.x*=e,this.y*=e,this},t.prototype.scale=function(e){return new t(this.x*e,this.y*e)},t.prototype.equals=function(e){return e&&this.x===e.x&&this.y===e.y},t.prototype.equalsWithEpsilon=function(t,r){return void 0===r&&(r=e.Epsilon),t&&e.Scalar.WithinEpsilon(this.x,t.x,r)&&e.Scalar.WithinEpsilon(this.y,t.y,r)},t.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y)},t.prototype.lengthSquared=function(){return this.x*this.x+this.y*this.y},t.prototype.normalize=function(){var e=this.length();if(0===e)return this;var t=1/e;return this.x*=t,this.y*=t,this},t.prototype.clone=function(){return new t(this.x,this.y)},t.Zero=function(){return new t(0,0)},t.One=function(){return new t(1,1)},t.FromArray=function(e,r){return void 0===r&&(r=0),new t(e[r],e[r+1])},t.FromArrayToRef=function(e,t,r){r.x=e[t],r.y=e[t+1]},t.CatmullRom=function(e,r,i,n,o){var s=o*o,a=o*s;return new t(.5*(2*r.x+(-e.x+i.x)*o+(2*e.x-5*r.x+4*i.x-n.x)*s+(-e.x+3*r.x-3*i.x+n.x)*a),.5*(2*r.y+(-e.y+i.y)*o+(2*e.y-5*r.y+4*i.y-n.y)*s+(-e.y+3*r.y-3*i.y+n.y)*a))},t.Clamp=function(e,r,i){var n=e.x;n=n>i.x?i.x:n,n=n<r.x?r.x:n;var o=e.y;return o=o>i.y?i.y:o,o=o<r.y?r.y:o,new t(n,o)},t.Hermite=function(e,r,i,n,o){var s=o*o,a=o*s,u=2*a-3*s+1,l=-2*a+3*s,h=a-2*s+o,c=a-s;return new t(e.x*u+i.x*l+r.x*h+n.x*c,e.y*u+i.y*l+r.y*h+n.y*c)},t.Lerp=function(e,r,i){return new t(e.x+(r.x-e.x)*i,e.y+(r.y-e.y)*i)},t.Dot=function(e,t){return e.x*t.x+e.y*t.y},t.Normalize=function(e){var t=e.clone();return t.normalize(),t},t.Minimize=function(e,r){return new t(e.x<r.x?e.x:r.x,e.y<r.y?e.y:r.y)},t.Maximize=function(e,r){return new t(e.x>r.x?e.x:r.x,e.y>r.y?e.y:r.y)},t.Transform=function(e,r){var i=t.Zero();return t.TransformToRef(e,r,i),i},t.TransformToRef=function(e,t,r){var i=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];r.x=i,r.y=n},t.PointInTriangle=function(e,t,r,i){var n=.5*(-r.y*i.x+t.y*(-r.x+i.x)+t.x*(r.y-i.y)+r.x*i.y),o=n<0?-1:1,s=(t.y*i.x-t.x*i.y+(i.y-t.y)*e.x+(t.x-i.x)*e.y)*o,a=(t.x*r.y-t.y*r.x+(t.y-r.y)*e.x+(r.x-t.x)*e.y)*o;return s>0&&a>0&&s+a<2*n*o},t.Distance=function(e,r){return Math.sqrt(t.DistanceSquared(e,r))},t.DistanceSquared=function(e,t){var r=e.x-t.x,i=e.y-t.y;return r*r+i*i},t.Center=function(e,t){var r=e.add(t);return r.scaleInPlace(.5),r},t.DistanceOfPointFromSegment=function(e,r,i){var n=t.DistanceSquared(r,i);if(0===n)return t.Distance(e,r);var o=i.subtract(r),s=Math.max(0,Math.min(1,t.Dot(e.subtract(r),o)/n)),a=r.add(o.multiplyByFloats(s,s));return t.Distance(e,a)},t})();e.Vector2=i;var n=(function(){function t(e,t,r){this.x=e,this.y=t,this.z=r}return t.prototype.toString=function(){return"{X: "+this.x+" Y:"+this.y+" Z:"+this.z+"}"},t.prototype.getClassName=function(){return"Vector3"},t.prototype.getHashCode=function(){var e=this.x||0;return e=397*e^(this.y||0),e=397*e^(this.z||0)},t.prototype.asArray=function(){var e=[];return this.toArray(e,0),e},t.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},t.prototype.toQuaternion=function(){var e=new a(0,0,0,1),t=Math.cos(.5*(this.x+this.z)),r=Math.sin(.5*(this.x+this.z)),i=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=i*s,e.y=-n*s,e.z=r*o,e.w=t*o,e},t.prototype.addInPlace=function(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this},t.prototype.add=function(e){return new t(this.x+e.x,this.y+e.y,this.z+e.z)},t.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},t.prototype.subtractInPlace=function(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this},t.prototype.subtract=function(e){return new t(this.x-e.x,this.y-e.y,this.z-e.z)},t.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},t.prototype.subtractFromFloats=function(e,r,i){return new t(this.x-e,this.y-r,this.z-i)},t.prototype.subtractFromFloatsToRef=function(e,t,r,i){return i.x=this.x-e,i.y=this.y-t,i.z=this.z-r,this},t.prototype.negate=function(){return new t(-this.x,-this.y,-this.z)},t.prototype.scaleInPlace=function(e){return this.x*=e,this.y*=e,this.z*=e,this},t.prototype.scale=function(e){return new t(this.x*e,this.y*e,this.z*e)},t.prototype.scaleToRef=function(e,t){return t.x=this.x*e,t.y=this.y*e,t.z=this.z*e,this},t.prototype.equals=function(e){return e&&this.x===e.x&&this.y===e.y&&this.z===e.z},t.prototype.equalsWithEpsilon=function(t,r){return void 0===r&&(r=e.Epsilon),t&&e.Scalar.WithinEpsilon(this.x,t.x,r)&&e.Scalar.WithinEpsilon(this.y,t.y,r)&&e.Scalar.WithinEpsilon(this.z,t.z,r)},t.prototype.equalsToFloats=function(e,t,r){return this.x===e&&this.y===t&&this.z===r},t.prototype.multiplyInPlace=function(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this},t.prototype.multiply=function(e){return new t(this.x*e.x,this.y*e.y,this.z*e.z)},t.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},t.prototype.multiplyByFloats=function(e,r,i){return new t(this.x*e,this.y*r,this.z*i)},t.prototype.divide=function(e){return new t(this.x/e.x,this.y/e.y,this.z/e.z)},t.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},t.prototype.MinimizeInPlace=function(e){return e.x<this.x&&(this.x=e.x),e.y<this.y&&(this.y=e.y),e.z<this.z&&(this.z=e.z),this},t.prototype.MaximizeInPlace=function(e){return e.x>this.x&&(this.x=e.x),e.y>this.y&&(this.y=e.y),e.z>this.z&&(this.z=e.z),this},t.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},t.prototype.lengthSquared=function(){return this.x*this.x+this.y*this.y+this.z*this.z},t.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},t.prototype.clone=function(){return new t(this.x,this.y,this.z)},t.prototype.copyFrom=function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this},t.prototype.copyFromFloats=function(e,t,r){return this.x=e,this.y=t,this.z=r,this},t.prototype.set=function(e,t,r){return this.copyFromFloats(e,t,r)},t.GetClipFactor=function(e,r,i,n){var o=t.Dot(e,i)-n;return o/(o-(t.Dot(r,i)-n))},t.FromArray=function(e,r){return r||(r=0),new t(e[r],e[r+1],e[r+2])},t.FromFloatArray=function(e,r){return t.FromArray(e,r)},t.FromArrayToRef=function(e,t,r){r.x=e[t],r.y=e[t+1],r.z=e[t+2]},t.FromFloatArrayToRef=function(e,r,i){return t.FromArrayToRef(e,r,i)},t.FromFloatsToRef=function(e,t,r,i){i.x=e,i.y=t,i.z=r},t.Zero=function(){return new t(0,0,0)},t.One=function(){return new t(1,1,1)},t.Up=function(){return new t(0,1,0)},t.Forward=function(){return new t(0,0,1)},t.Right=function(){return new t(1,0,0)},t.Left=function(){return new t(-1,0,0)},t.TransformCoordinates=function(e,r){var i=t.Zero();return t.TransformCoordinatesToRef(e,r,i),i},t.TransformCoordinatesToRef=function(e,t,r){var i=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];r.x=i/s,r.y=n/s,r.z=o/s},t.TransformCoordinatesFromFloatsToRef=function(e,t,r,i,n){var o=e*i.m[0]+t*i.m[4]+r*i.m[8]+i.m[12],s=e*i.m[1]+t*i.m[5]+r*i.m[9]+i.m[13],a=e*i.m[2]+t*i.m[6]+r*i.m[10]+i.m[14],u=e*i.m[3]+t*i.m[7]+r*i.m[11]+i.m[15];n.x=o/u,n.y=s/u,n.z=a/u},t.TransformNormal=function(e,r){var i=t.Zero();return t.TransformNormalToRef(e,r,i),i},t.TransformNormalToRef=function(e,t,r){var i=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];r.x=i,r.y=n,r.z=o},t.TransformNormalFromFloatsToRef=function(e,t,r,i,n){n.x=e*i.m[0]+t*i.m[4]+r*i.m[8],n.y=e*i.m[1]+t*i.m[5]+r*i.m[9],n.z=e*i.m[2]+t*i.m[6]+r*i.m[10]},t.CatmullRom=function(e,r,i,n,o){var s=o*o,a=o*s;return new t(.5*(2*r.x+(-e.x+i.x)*o+(2*e.x-5*r.x+4*i.x-n.x)*s+(-e.x+3*r.x-3*i.x+n.x)*a),.5*(2*r.y+(-e.y+i.y)*o+(2*e.y-5*r.y+4*i.y-n.y)*s+(-e.y+3*r.y-3*i.y+n.y)*a),.5*(2*r.z+(-e.z+i.z)*o+(2*e.z-5*r.z+4*i.z-n.z)*s+(-e.z+3*r.z-3*i.z+n.z)*a))},t.Clamp=function(e,r,i){var n=e.x;n=n>i.x?i.x:n,n=n<r.x?r.x:n;var o=e.y;o=o>i.y?i.y:o,o=o<r.y?r.y:o;var s=e.z;return s=s>i.z?i.z:s,s=s<r.z?r.z:s,new t(n,o,s)},t.Hermite=function(e,r,i,n,o){var s=o*o,a=o*s,u=2*a-3*s+1,l=-2*a+3*s,h=a-2*s+o,c=a-s;return new t(e.x*u+i.x*l+r.x*h+n.x*c,e.y*u+i.y*l+r.y*h+n.y*c,e.z*u+i.z*l+r.z*h+n.z*c)},t.Lerp=function(e,r,i){var n=new t(0,0,0);return t.LerpToRef(e,r,i,n),n},t.LerpToRef=function(e,t,r,i){i.x=e.x+(t.x-e.x)*r,i.y=e.y+(t.y-e.y)*r,i.z=e.z+(t.z-e.z)*r},t.Dot=function(e,t){return e.x*t.x+e.y*t.y+e.z*t.z},t.Cross=function(e,r){var i=t.Zero();return t.CrossToRef(e,r,i),i},t.CrossToRef=function(e,t,r){b.Vector3[0].x=e.y*t.z-e.z*t.y,b.Vector3[0].y=e.z*t.x-e.x*t.z,b.Vector3[0].z=e.x*t.y-e.y*t.x,r.copyFrom(b.Vector3[0])},t.Normalize=function(e){var r=t.Zero();return t.NormalizeToRef(e,r),r},t.NormalizeToRef=function(e,t){t.copyFrom(e),t.normalize()},t.Project=function(e,r,i,n){var o=n.width,s=n.height,a=n.x,l=n.y,h=t._viewportMatrixCache?t._viewportMatrixCache:t._viewportMatrixCache=new u;u.FromValuesToRef(o/2,0,0,0,0,-s/2,0,0,0,0,.5,0,a+o/2,s/2+l,.5,1,h);var c=b.Matrix[0];return r.multiplyToRef(i,c),c.multiplyToRef(h,c),t.TransformCoordinates(e,c)},t.UnprojectFromTransform=function(r,i,n,o,s){var a=b.Matrix[0];o.multiplyToRef(s,a),a.invert(),r.x=r.x/i*2-1,r.y=-(r.y/n*2-1);var u=t.TransformCoordinates(r,a),l=r.x*a.m[3]+r.y*a.m[7]+r.z*a.m[11]+a.m[15];return e.Scalar.WithinEpsilon(l,1)&&(u=u.scale(1/l)),u},t.Unproject=function(r,i,n,o,s,a){var u=b.Matrix[0];o.multiplyToRef(s,u),u.multiplyToRef(a,u),u.invert();var l=new t(r.x/i*2-1,-(r.y/n*2-1),2*r.z-1),h=t.TransformCoordinates(l,u),c=l.x*u.m[3]+l.y*u.m[7]+l.z*u.m[11]+u.m[15];return e.Scalar.WithinEpsilon(c,1)&&(h=h.scale(1/c)),h},t.Minimize=function(e,t){var r=e.clone();return r.MinimizeInPlace(t),r},t.Maximize=function(e,t){var r=e.clone();return r.MaximizeInPlace(t),r},t.Distance=function(e,r){return Math.sqrt(t.DistanceSquared(e,r))},t.DistanceSquared=function(e,t){var r=e.x-t.x,i=e.y-t.y,n=e.z-t.z;return r*r+i*i+n*n},t.Center=function(e,t){var r=e.add(t);return r.scaleInPlace(.5),r},t.RotationFromAxis=function(e,r,i){var n=t.Zero();return t.RotationFromAxisToRef(e,r,i,n),n},t.RotationFromAxisToRef=function(e,t,r,i){var n=b.Quaternion[0];a.RotationQuaternionFromAxisToRef(e,t,r,n),n.toEulerAnglesToRef(i)},t})();e.Vector3=n;var o=(function(){function t(e,t,r,i){this.x=e,this.y=t,this.z=r,this.w=i}return t.prototype.toString=function(){return"{X: "+this.x+" Y:"+this.y+" Z:"+this.z+" W:"+this.w+"}"},t.prototype.getClassName=function(){return"Vector4"},t.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)},t.prototype.asArray=function(){var e=[];return this.toArray(e,0),e},t.prototype.toArray=function(e,t){return void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,this},t.prototype.addInPlace=function(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this},t.prototype.add=function(e){return new t(this.x+e.x,this.y+e.y,this.z+e.z,this.w+e.w)},t.prototype.addToRef=function(e,t){return t.x=this.x+e.x,t.y=this.y+e.y,t.z=this.z+e.z,t.w=this.w+e.w,this},t.prototype.subtractInPlace=function(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this},t.prototype.subtract=function(e){return new t(this.x-e.x,this.y-e.y,this.z-e.z,this.w-e.w)},t.prototype.subtractToRef=function(e,t){return t.x=this.x-e.x,t.y=this.y-e.y,t.z=this.z-e.z,t.w=this.w-e.w,this},t.prototype.subtractFromFloats=function(e,r,i,n){return new t(this.x-e,this.y-r,this.z-i,this.w-n)},t.prototype.subtractFromFloatsToRef=function(e,t,r,i,n){return n.x=this.x-e,n.y=this.y-t,n.z=this.z-r,n.w=this.w-i,this},t.prototype.negate=function(){return new t(-this.x,-this.y,-this.z,-this.w)},t.prototype.scaleInPlace=function(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this},t.prototype.scale=function(e){return new t(this.x*e,this.y*e,this.z*e,this.w*e)},t.prototype.scaleToRef=function(e,t){return t.x=this.x*e,t.y=this.y*e,t.z=this.z*e,t.w=this.w*e,this},t.prototype.equals=function(e){return e&&this.x===e.x&&this.y===e.y&&this.z===e.z&&this.w===e.w},t.prototype.equalsWithEpsilon=function(t,r){return void 0===r&&(r=e.Epsilon),t&&e.Scalar.WithinEpsilon(this.x,t.x,r)&&e.Scalar.WithinEpsilon(this.y,t.y,r)&&e.Scalar.WithinEpsilon(this.z,t.z,r)&&e.Scalar.WithinEpsilon(this.w,t.w,r)},t.prototype.equalsToFloats=function(e,t,r,i){return this.x===e&&this.y===t&&this.z===r&&this.w===i},t.prototype.multiplyInPlace=function(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this},t.prototype.multiply=function(e){return new t(this.x*e.x,this.y*e.y,this.z*e.z,this.w*e.w)},t.prototype.multiplyToRef=function(e,t){return t.x=this.x*e.x,t.y=this.y*e.y,t.z=this.z*e.z,t.w=this.w*e.w,this},t.prototype.multiplyByFloats=function(e,r,i,n){return new t(this.x*e,this.y*r,this.z*i,this.w*n)},t.prototype.divide=function(e){return new t(this.x/e.x,this.y/e.y,this.z/e.z,this.w/e.w)},t.prototype.divideToRef=function(e,t){return t.x=this.x/e.x,t.y=this.y/e.y,t.z=this.z/e.z,t.w=this.w/e.w,this},t.prototype.MinimizeInPlace=function(e){return e.x<this.x&&(this.x=e.x),e.y<this.y&&(this.y=e.y),e.z<this.z&&(this.z=e.z),e.w<this.w&&(this.w=e.w),this},t.prototype.MaximizeInPlace=function(e){return e.x>this.x&&(this.x=e.x),e.y>this.y&&(this.y=e.y),e.z>this.z&&(this.z=e.z),e.w>this.w&&(this.w=e.w),this},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.lengthSquared=function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},t.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},t.prototype.toVector3=function(){return new n(this.x,this.y,this.z)},t.prototype.clone=function(){return new t(this.x,this.y,this.z,this.w)},t.prototype.copyFrom=function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w,this},t.prototype.copyFromFloats=function(e,t,r,i){return this.x=e,this.y=t,this.z=r,this.w=i,this},t.prototype.set=function(e,t,r,i){return this.copyFromFloats(e,t,r,i)},t.FromArray=function(e,r){return r||(r=0),new t(e[r],e[r+1],e[r+2],e[r+3])},t.FromArrayToRef=function(e,t,r){r.x=e[t],r.y=e[t+1],r.z=e[t+2],r.w=e[t+3]},t.FromFloatArrayToRef=function(e,r,i){t.FromArrayToRef(e,r,i)},t.FromFloatsToRef=function(e,t,r,i,n){n.x=e,n.y=t,n.z=r,n.w=i},t.Zero=function(){return new t(0,0,0,0)},t.One=function(){return new t(1,1,1,1)},t.Normalize=function(e){var r=t.Zero();return t.NormalizeToRef(e,r),r},t.NormalizeToRef=function(e,t){t.copyFrom(e),t.normalize()},t.Minimize=function(e,t){var r=e.clone();return r.MinimizeInPlace(t),r},t.Maximize=function(e,t){var r=e.clone();return r.MaximizeInPlace(t),r},t.Distance=function(e,r){return Math.sqrt(t.DistanceSquared(e,r))},t.DistanceSquared=function(e,t){var r=e.x-t.x,i=e.y-t.y,n=e.z-t.z,o=e.w-t.w;return r*r+i*i+n*n+o*o},t.Center=function(e,t){var r=e.add(t);return r.scaleInPlace(.5),r},t.TransformNormal=function(e,r){var i=t.Zero();return t.TransformNormalToRef(e,r,i),i},t.TransformNormalToRef=function(e,t,r){var i=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];r.x=i,r.y=n,r.z=o,r.w=e.w},t.TransformNormalFromFloatsToRef=function(e,t,r,i,n,o){o.x=e*n.m[0]+t*n.m[4]+r*n.m[8],o.y=e*n.m[1]+t*n.m[5]+r*n.m[9],o.z=e*n.m[2]+t*n.m[6]+r*n.m[10],o.w=i},t})();e.Vector4=o;var s=(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){return this.width=e,this.height=t,this},e.prototype.set=function(e,t){return this.copyFromFloats(e,t)},e.prototype.multiplyByFloats=function(t,r){return new e(this.width*t,this.height*r)},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){return new e(this.width+t.width,this.height+t.height)},e.prototype.subtract=function(t){return new e(this.width-t.width,this.height-t.height)},e.Lerp=function(t,r,i){return new e(t.width+(r.width-t.width)*i,t.height+(r.height-t.height)*i)},e})();e.Size=s;var a=(function(){function t(e,t,r,i){void 0===e&&(e=0),void 0===t&&(t=0),void 0===r&&(r=0),void 0===i&&(i=1),this.x=e,this.y=t,this.z=r,this.w=i}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 e=this.x||0;return e=397*e^(this.y||0),e=397*e^(this.z||0),e=397*e^(this.w||0)},t.prototype.asArray=function(){return[this.x,this.y,this.z,this.w]},t.prototype.equals=function(e){return e&&this.x===e.x&&this.y===e.y&&this.z===e.z&&this.w===e.w},t.prototype.clone=function(){return new t(this.x,this.y,this.z,this.w)},t.prototype.copyFrom=function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w,this},t.prototype.copyFromFloats=function(e,t,r,i){return this.x=e,this.y=t,this.z=r,this.w=i,this},t.prototype.set=function(e,t,r,i){return this.copyFromFloats(e,t,r,i)},t.prototype.add=function(e){return new t(this.x+e.x,this.y+e.y,this.z+e.z,this.w+e.w)},t.prototype.subtract=function(e){return new t(this.x-e.x,this.y-e.y,this.z-e.z,this.w-e.w)},t.prototype.scale=function(e){return new t(this.x*e,this.y*e,this.z*e,this.w*e)},t.prototype.multiply=function(e){var r=new t(0,0,0,1);return this.multiplyToRef(e,r),r},t.prototype.multiplyToRef=function(e,t){var r=this.x*e.w+this.y*e.z-this.z*e.y+this.w*e.x,i=-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(r,i,n,o),this},t.prototype.multiplyInPlace=function(e){return this.multiplyToRef(e,this),this},t.prototype.conjugateToRef=function(e){return e.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(){return new t(-this.x,-this.y,-this.z,this.w)},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 e=1/this.length();return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this},t.prototype.toEulerAngles=function(e){void 0===e&&(e="YZX");var t=n.Zero();return this.toEulerAnglesToRef(t,e),t},t.prototype.toEulerAnglesToRef=function(e,t){void 0===t&&(t="YZX");var r=this.z,i=this.x,n=this.y,o=this.w,s=o*o,a=r*r,u=i*i,l=n*n,h=n*r-i*o;return h<-.4999999?(e.y=2*Math.atan2(n,o),e.x=Math.PI/2,e.z=0):h>.4999999?(e.y=2*Math.atan2(n,o),e.x=-Math.PI/2,e.z=0):(e.z=Math.atan2(2*(i*n+r*o),-a-u+l+s),e.x=Math.asin(-2*(r*n-i*o)),e.y=Math.atan2(2*(r*i+n*o),a-u-l+s)),this},t.prototype.toRotationMatrix=function(e){var t=this.x*this.x,r=this.y*this.y,i=this.z*this.z,n=this.x*this.y,o=this.z*this.w,s=this.z*this.x,a=this.y*this.w,u=this.y*this.z,l=this.x*this.w;return e.m[0]=1-2*(r+i),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*(i+t),e.m[6]=2*(u+l),e.m[7]=0,e.m[8]=2*(s+a),e.m[9]=2*(u-l),e.m[10]=1-2*(r+t),e.m[11]=0,e.m[12]=0,e.m[13]=0,e.m[14]=0,e.m[15]=1,e._markAsUpdated(),this},t.prototype.fromRotationMatrix=function(e){return t.FromRotationMatrixToRef(e,this),this},t.FromRotationMatrix=function(e){var r=new t;return t.FromRotationMatrixToRef(e,r),r},t.FromRotationMatrixToRef=function(e,t){var r,i=e.m,n=i[0],o=i[4],s=i[8],a=i[1],u=i[5],l=i[9],h=i[2],c=i[6],f=i[10],d=n+u+f;d>0?(r=.5/Math.sqrt(d+1),t.w=.25/r,t.x=(c-l)*r,t.y=(s-h)*r,t.z=(a-o)*r):n>u&&n>f?(r=2*Math.sqrt(1+n-u-f),t.w=(c-l)/r,t.x=.25*r,t.y=(o+a)/r,t.z=(s+h)/r):u>f?(r=2*Math.sqrt(1+u-n-f),t.w=(s-h)/r,t.x=(o+a)/r,t.y=.25*r,t.z=(l+c)/r):(r=2*Math.sqrt(1+f-n-u),t.w=(a-o)/r,t.x=(s+h)/r,t.y=(l+c)/r,t.z=.25*r)},t.Zero=function(){return new t(0,0,0,0)},t.Inverse=function(e){return new t(-e.x,-e.y,-e.z,e.w)},t.Identity=function(){return new t(0,0,0,1)},t.IsIdentity=function(e){return e&&0===e.x&&0===e.y&&0===e.z&&1===e.w},t.RotationAxis=function(e,r){return t.RotationAxisToRef(e,r,new t)},t.RotationAxisToRef=function(e,t,r){var i=Math.sin(t/2);return e.normalize(),r.w=Math.cos(t/2),r.x=e.x*i,r.y=e.y*i,r.z=e.z*i,r},t.FromArray=function(e,r){return r||(r=0),new t(e[r],e[r+1],e[r+2],e[r+3])},t.RotationYawPitchRoll=function(e,r,i){var n=new t;return t.RotationYawPitchRollToRef(e,r,i,n),n},t.RotationYawPitchRollToRef=function(e,t,r,i){var n=.5*r,o=.5*t,s=.5*e,a=Math.sin(n),u=Math.cos(n),l=Math.sin(o),h=Math.cos(o),c=Math.sin(s),f=Math.cos(s);i.x=f*l*u+c*h*a,i.y=c*h*u-f*l*a,i.z=f*h*a-c*l*u,i.w=f*h*u+c*l*a},t.RotationAlphaBetaGamma=function(e,r,i){var n=new t;return t.RotationAlphaBetaGammaToRef(e,r,i,n),n},t.RotationAlphaBetaGammaToRef=function(e,t,r,i){var n=.5*(r+e),o=.5*(r-e),s=.5*t;i.x=Math.cos(o)*Math.sin(s),i.y=Math.sin(o)*Math.sin(s),i.z=Math.sin(n)*Math.cos(s),i.w=Math.cos(n)*Math.cos(s)},t.RotationQuaternionFromAxis=function(e,r,i,n){var o=new t(0,0,0,0);return t.RotationQuaternionFromAxisToRef(e,r,i,o),o},t.RotationQuaternionFromAxisToRef=function(t,r,i,n){var o=b.Matrix[0];e.Matrix.FromXYZAxesToRef(t.normalize(),r.normalize(),i.normalize(),o),e.Quaternion.FromRotationMatrixToRef(o,n)},t.Slerp=function(e,r,i){var n=t.Identity();return t.SlerpToRef(e,r,i,n),n},t.SlerpToRef=function(e,t,r,i){var n,o,s=r,a=e.x*t.x+e.y*t.y+e.z*t.z+e.w*t.w,u=!1;if(a<0&&(u=!0,a=-a),a>.999999)o=1-s,n=u?-s:s;else{var l=Math.acos(a),h=1/Math.sin(l);o=Math.sin((1-s)*l)*h,n=u?-Math.sin(s*l)*h:Math.sin(s*l)*h}i.x=o*e.x+n*t.x,i.y=o*e.y+n*t.y,i.z=o*e.z+n*t.z,i.w=o*e.w+n*t.w},t.Hermite=function(e,r,i,n,o){var s=o*o,a=o*s,u=2*a-3*s+1,l=-2*a+3*s,h=a-2*s+o,c=a-s;return new t(e.x*u+i.x*l+r.x*h+n.x*c,e.y*u+i.y*l+r.y*h+n.y*c,e.z*u+i.z*l+r.z*h+n.z*c,e.w*u+i.w*l+r.w*h+n.w*c)},t})();e.Quaternion=a;var u=(function(){function t(){this._isIdentity=!1,this._isIdentityDirty=!0,this.m=new Float32Array(16),this._markAsUpdated()}return t.prototype._markAsUpdated=function(){this.updateFlag=t._updateFlagSeed++,this._isIdentityDirty=!0},t.prototype.isIdentity=function(e){return void 0===e&&(e=!1),this._isIdentityDirty&&(this._isIdentityDirty=!1,1!==this.m[0]||1!==this.m[5]||1!==this.m[15]?this._isIdentity=!1:0!==this.m[1]||0!==this.m[2]||0!==this.m[3]||0!==this.m[4]||0!==this.m[6]||0!==this.m[7]||0!==this.m[8]||0!==this.m[9]||0!==this.m[11]||0!==this.m[12]||0!==this.m[13]||0!==this.m[14]?this._isIdentity=!1:this._isIdentity=!0,e||1===this.m[10]||(this._isIdentity=!1)),this._isIdentity},t.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],r=this.m[9]*this.m[14]-this.m[10]*this.m[13],i=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]*r)-this.m[1]*(this.m[4]*e-this.m[6]*i+this.m[7]*n)+this.m[2]*(this.m[4]*t-this.m[5]*i+this.m[7]*o)-this.m[3]*(this.m[4]*r-this.m[5]*n+this.m[6]*o)},t.prototype.toArray=function(){return this.m},t.prototype.asArray=function(){return this.toArray()},t.prototype.invert=function(){return this.invertToRef(this),this},t.prototype.reset=function(){for(var e=0;e<16;e++)this.m[e]=0;return this._markAsUpdated(),this},t.prototype.add=function(e){var r=new t;return this.addToRef(e,r),r},t.prototype.addToRef=function(e,t){for(var r=0;r<16;r++)t.m[r]=this.m[r]+e.m[r];return t._markAsUpdated(),this},t.prototype.addToSelf=function(e){for(var t=0;t<16;t++)this.m[t]+=e.m[t];return this._markAsUpdated(),this},t.prototype.invertToRef=function(e){var t=this.m[0],r=this.m[1],i=this.m[2],n=this.m[3],o=this.m[4],s=this.m[5],a=this.m[6],u=this.m[7],l=this.m[8],h=this.m[9],c=this.m[10],f=this.m[11],d=this.m[12],p=this.m[13],g=this.m[14],_=this.m[15],m=c*_-f*g,v=h*_-f*p,y=h*g-c*p,A=l*_-f*d,T=l*g-c*d,E=l*p-h*d,b=s*m-a*v+u*y,x=-(o*m-a*A+u*T),M=o*v-s*A+u*E,P=-(o*y-s*T+a*E),R=1/(t*b+r*x+i*M+n*P),C=a*_-u*g,O=s*_-u*p,S=s*g-a*p,I=o*_-u*d,L=o*g-a*d,D=o*p-s*d,B=a*f-u*c,N=s*f-u*h,F=s*c-a*h,w=o*f-u*l,V=o*c-a*l,U=o*h-s*l;return e.m[0]=b*R,e.m[4]=x*R,e.m[8]=M*R,e.m[12]=P*R,e.m[1]=-(r*m-i*v+n*y)*R,e.m[5]=(t*m-i*A+n*T)*R,e.m[9]=-(t*v-r*A+n*E)*R,e.m[13]=(t*y-r*T+i*E)*R,e.m[2]=(r*C-i*O+n*S)*R,e.m[6]=-(t*C-i*I+n*L)*R,e.m[10]=(t*O-r*I+n*D)*R,e.m[14]=-(t*S-r*L+i*D)*R,e.m[3]=-(r*B-i*N+n*F)*R,e.m[7]=(t*B-i*w+n*V)*R,e.m[11]=-(t*N-r*w+n*U)*R,e.m[15]=(t*F-r*V+i*U)*R,e._markAsUpdated(),this},t.prototype.setTranslationFromFloats=function(e,t,r){return this.m[12]=e,this.m[13]=t,this.m[14]=r,this._markAsUpdated(),this},t.prototype.setTranslation=function(e){return this.m[12]=e.x,this.m[13]=e.y,this.m[14]=e.z,this._markAsUpdated(),this},t.prototype.getTranslation=function(){return new n(this.m[12],this.m[13],this.m[14])},t.prototype.getTranslationToRef=function(e){return e.x=this.m[12],e.y=this.m[13],e.z=this.m[14],this},t.prototype.removeRotationAndScaling=function(){return this.setRowFromFloats(0,1,0,0,0),this.setRowFromFloats(1,0,1,0,0),this.setRowFromFloats(2,0,0,1,0),this},t.prototype.multiply=function(e){var r=new t;return this.multiplyToRef(e,r),r},t.prototype.copyFrom=function(e){for(var t=0;t<16;t++)this.m[t]=e.m[t];return this._markAsUpdated(),this},t.prototype.copyToArray=function(e,t){void 0===t&&(t=0);for(var r=0;r<16;r++)e[t+r]=this.m[r];return this},t.prototype.multiplyToRef=function(e,t){return this.multiplyToArray(e,t.m,0),t._markAsUpdated(),this},t.prototype.multiplyToArray=function(e,t,r){var i=this.m[0],n=this.m[1],o=this.m[2],s=this.m[3],a=this.m[4],u=this.m[5],l=this.m[6],h=this.m[7],c=this.m[8],f=this.m[9],d=this.m[10],p=this.m[11],g=this.m[12],_=this.m[13],m=this.m[14],v=this.m[15],y=e.m[0],A=e.m[1],T=e.m[2],E=e.m[3],b=e.m[4],x=e.m[5],M=e.m[6],P=e.m[7],R=e.m[8],C=e.m[9],O=e.m[10],S=e.m[11],I=e.m[12],L=e.m[13],D=e.m[14],B=e.m[15];return t[r]=i*y+n*b+o*R+s*I,t[r+1]=i*A+n*x+o*C+s*L,t[r+2]=i*T+n*M+o*O+s*D,t[r+3]=i*E+n*P+o*S+s*B,t[r+4]=a*y+u*b+l*R+h*I,t[r+5]=a*A+u*x+l*C+h*L,t[r+6]=a*T+u*M+l*O+h*D,t[r+7]=a*E+u*P+l*S+h*B,t[r+8]=c*y+f*b+d*R+p*I,t[r+9]=c*A+f*x+d*C+p*L,t[r+10]=c*T+f*M+d*O+p*D,t[r+11]=c*E+f*P+d*S+p*B,t[r+12]=g*y+_*b+m*R+v*I,t[r+13]=g*A+_*x+m*C+v*L,t[r+14]=g*T+_*M+m*O+v*D,t[r+15]=g*E+_*P+m*S+v*B,this},t.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]},t.prototype.clone=function(){return t.FromValues(this.m[0],this.m[1],this.m[2],this.m[3],this.m[4],this.m[5],this.m[6],this.m[7],this.m[8],this.m[9],this.m[10],this.m[11],this.m[12],this.m[13],this.m[14],this.m[15])},t.prototype.getClassName=function(){return"Matrix"},t.prototype.getHashCode=function(){for(var e=this.m[0]||0,t=1;t<16;t++)e=397*e^(this.m[t]||0);return e},t.prototype.decompose=function(e,r,i){return i.x=this.m[12],i.y=this.m[13],i.z=this.m[14],e.x=Math.sqrt(this.m[0]*this.m[0]+this.m[1]*this.m[1]+this.m[2]*this.m[2]),e.y=Math.sqrt(this.m[4]*this.m[4]+this.m[5]*this.m[5]+this.m[6]*this.m[6]),e.z=Math.sqrt(this.m[8]*this.m[8]+this.m[9]*this.m[9]+this.m[10]*this.m[10]),this.determinant()<=0&&(e.y*=-1),0===e.x||0===e.y||0===e.z?(r.x=0,r.y=0,r.z=0,r.w=1,!1):(t.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,b.Matrix[0]),a.FromRotationMatrixToRef(b.Matrix[0],r),!0)},t.prototype.getRotationMatrix=function(){var e=t.Identity();return this.getRotationMatrixToRef(e),e},t.prototype.getRotationMatrixToRef=function(e){var r=this.m,i=r[0]*r[1]*r[2]*r[3]<0?-1:1,n=r[4]*r[5]*r[6]*r[7]<0?-1:1,o=r[8]*r[9]*r[10]*r[11]<0?-1:1,s=i*Math.sqrt(r[0]*r[0]+r[1]*r[1]+r[2]*r[2]),a=n*Math.sqrt(r[4]*r[4]+r[5]*r[5]+r[6]*r[6]),u=o*Math.sqrt(r[8]*r[8]+r[9]*r[9]+r[10]*r[10]);return t.FromValuesToRef(r[0]/s,r[1]/s,r[2]/s,0,r[4]/a,r[5]/a,r[6]/a,0,r[8]/u,r[9]/u,r[10]/u,0,0,0,0,1,e),this},t.FromArray=function(e,r){var i=new t;return r||(r=0),t.FromArrayToRef(e,r,i),i},t.FromArrayToRef=function(e,t,r){for(var i=0;i<16;i++)r.m[i]=e[i+t];r._markAsUpdated()},t.FromFloat32ArrayToRefScaled=function(e,t,r,i){for(var n=0;n<16;n++)i.m[n]=e[n+t]*r;i._markAsUpdated()},t.FromValuesToRef=function(e,t,r,i,n,o,s,a,u,l,h,c,f,d,p,g,_){_.m[0]=e,_.m[1]=t,_.m[2]=r,_.m[3]=i,_.m[4]=n,_.m[5]=o,_.m[6]=s,_.m[7]=a,_.m[8]=u,_.m[9]=l,_.m[10]=h,_.m[11]=c,_.m[12]=f,_.m[13]=d,_.m[14]=p,_.m[15]=g,_._markAsUpdated()},t.prototype.getRow=function(e){if(e<0||e>3)return null;var t=4*e;return new o(this.m[t+0],this.m[t+1],this.m[t+2],this.m[t+3])},t.prototype.setRow=function(e,t){if(e<0||e>3)return this;var r=4*e;return this.m[r+0]=t.x,this.m[r+1]=t.y,this.m[r+2]=t.z,this.m[r+3]=t.w,this._markAsUpdated(),this},t.prototype.setRowFromFloats=function(e,t,r,i,n){if(e<0||e>3)return this;var o=4*e;return this.m[o+0]=t,this.m[o+1]=r,this.m[o+2]=i,this.m[o+3]=n,this._markAsUpdated(),this},t.FromValues=function(e,r,i,n,o,s,a,u,l,h,c,f,d,p,g,_){var m=new t;return m.m[0]=e,m.m[1]=r,m.m[2]=i,m.m[3]=n,m.m[4]=o,m.m[5]=s,m.m[6]=a,m.m[7]=u,m.m[8]=l,m.m[9]=h,m.m[10]=c,m.m[11]=f,m.m[12]=d,m.m[13]=p,m.m[14]=g,m.m[15]=_,m},t.Compose=function(e,r,i){var n=t.Identity();return t.ComposeToRef(e,r,i,n),n},t.ComposeToRef=function(e,r,i,n){t.FromValuesToRef(e.x,0,0,0,0,e.y,0,0,0,0,e.z,0,0,0,0,1,b.Matrix[1]),r.toRotationMatrix(b.Matrix[0]),b.Matrix[1].multiplyToRef(b.Matrix[0],n),n.setTranslation(i)},t.Identity=function(){return t.FromValues(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1)},t.IdentityToRef=function(e){t.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,e)},t.Zero=function(){return t.FromValues(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)},t.RotationX=function(e){var r=new t;return t.RotationXToRef(e,r),r},t.Invert=function(e){var r=new t;return e.invertToRef(r),r},t.RotationXToRef=function(e,t){var r=Math.sin(e),i=Math.cos(e);t.m[0]=1,t.m[15]=1,t.m[5]=i,t.m[10]=i,t.m[9]=-r,t.m[6]=r,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,t._markAsUpdated()},t.RotationY=function(e){var r=new t;return t.RotationYToRef(e,r),r},t.RotationYToRef=function(e,t){var r=Math.sin(e),i=Math.cos(e);t.m[5]=1,t.m[15]=1,t.m[0]=i,t.m[2]=-r,t.m[8]=r,t.m[10]=i,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,t._markAsUpdated()},t.RotationZ=function(e){var r=new t;return t.RotationZToRef(e,r),r},t.RotationZToRef=function(e,t){var r=Math.sin(e),i=Math.cos(e);t.m[10]=1,t.m[15]=1,t.m[0]=i,t.m[1]=r,t.m[4]=-r,t.m[5]=i,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,t._markAsUpdated()},t.RotationAxis=function(e,r){var i=t.Zero();return t.RotationAxisToRef(e,r,i),i},t.RotationAxisToRef=function(e,t,r){var i=Math.sin(-t),n=Math.cos(-t),o=1-n;e.normalize(),r.m[0]=e.x*e.x*o+n,r.m[1]=e.x*e.y*o-e.z*i,r.m[2]=e.x*e.z*o+e.y*i,r.m[3]=0,r.m[4]=e.y*e.x*o+e.z*i,r.m[5]=e.y*e.y*o+n,r.m[6]=e.y*e.z*o-e.x*i,r.m[7]=0,r.m[8]=e.z*e.x*o-e.y*i,r.m[9]=e.z*e.y*o+e.x*i,r.m[10]=e.z*e.z*o+n,r.m[11]=0,r.m[15]=1,r._markAsUpdated()},t.RotationYawPitchRoll=function(e,r,i){var n=new t;return t.RotationYawPitchRollToRef(e,r,i,n),n},t.RotationYawPitchRollToRef=function(e,t,r,i){a.RotationYawPitchRollToRef(e,t,r,this._tempQuaternion),this._tempQuaternion.toRotationMatrix(i)},t.Scaling=function(e,r,i){var n=t.Zero();return t.ScalingToRef(e,r,i,n),n},t.ScalingToRef=function(e,t,r,i){i.m[0]=e,i.m[1]=0,i.m[2]=0,i.m[3]=0,i.m[4]=0,i.m[5]=t,i.m[6]=0,i.m[7]=0,i.m[8]=0,i.m[9]=0,i.m[10]=r,i.m[11]=0,i.m[12]=0,i.m[13]=0,i.m[14]=0,i.m[15]=1,i._markAsUpdated()},t.Translation=function(e,r,i){var n=t.Identity();return t.TranslationToRef(e,r,i,n),n},t.TranslationToRef=function(e,r,i,n){t.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,e,r,i,1,n)},t.Lerp=function(e,r,i){for(var n=t.Zero(),o=0;o<16;o++)n.m[o]=e.m[o]*(1-i)+r.m[o]*i;return n._markAsUpdated(),n},t.DecomposeLerp=function(e,r,i){var o=new n(0,0,0),s=new a,u=new n(0,0,0);e.decompose(o,s,u);var l=new n(0,0,0),h=new a,c=new n(0,0,0);r.decompose(l,h,c);var f=n.Lerp(o,l,i),d=a.Slerp(s,h,i),p=n.Lerp(u,c,i);return t.Compose(f,d,p)},t.LookAtLH=function(e,r,i){var n=t.Zero();return t.LookAtLHToRef(e,r,i,n),n},t.LookAtLHToRef=function(e,r,i,o){r.subtractToRef(e,this._zAxis),this._zAxis.normalize(),n.CrossToRef(i,this._zAxis,this._xAxis),0===this._xAxis.lengthSquared()?this._xAxis.x=1:this._xAxis.normalize(),n.CrossToRef(this._zAxis,this._xAxis,this._yAxis),this._yAxis.normalize();var s=-n.Dot(this._xAxis,e),a=-n.Dot(this._yAxis,e),u=-n.Dot(this._zAxis,e);return t.FromValuesToRef(this._xAxis.x,this._yAxis.x,this._zAxis.x,0,this._xAxis.y,this._yAxis.y,this._zAxis.y,0,this._xAxis.z,this._yAxis.z,this._zAxis.z,0,s,a,u,1,o)},t.LookAtRH=function(e,r,i){var n=t.Zero();return t.LookAtRHToRef(e,r,i,n),n},t.LookAtRHToRef=function(e,r,i,o){e.subtractToRef(r,this._zAxis),this._zAxis.normalize(),n.CrossToRef(i,this._zAxis,this._xAxis),0===this._xAxis.lengthSquared()?this._xAxis.x=1:this._xAxis.normalize(),n.CrossToRef(this._zAxis,this._xAxis,this._yAxis),this._yAxis.normalize();var s=-n.Dot(this._xAxis,e),a=-n.Dot(this._yAxis,e),u=-n.Dot(this._zAxis,e);return t.FromValuesToRef(this._xAxis.x,this._yAxis.x,this._zAxis.x,0,this._xAxis.y,this._yAxis.y,this._zAxis.y,0,this._xAxis.z,this._yAxis.z,this._zAxis.z,0,s,a,u,1,o)},t.OrthoLH=function(e,r,i,n){var o=t.Zero();return t.OrthoLHToRef(e,r,i,n,o),o},t.OrthoLHToRef=function(t,r,i,n,o){var s=i,a=n,u=2/t,l=2/r,h=2/(a-s),c=-(a+s)/(a-s);e.Matrix.FromValuesToRef(u,0,0,0,0,l,0,0,0,0,h,0,0,0,c,1,o)},t.OrthoOffCenterLH=function(e,r,i,n,o,s){var a=t.Zero();return t.OrthoOffCenterLHToRef(e,r,i,n,o,s,a),a},t.OrthoOffCenterLHToRef=function(t,r,i,n,o,s,a){var u=o,l=s,h=2/(r-t),c=2/(n-i),f=2/(l-u),d=-(l+u)/(l-u),p=(t+r)/(t-r),g=(n+i)/(i-n);e.Matrix.FromValuesToRef(h,0,0,0,0,c,0,0,0,0,f,0,p,g,d,1,a)},t.OrthoOffCenterRH=function(e,r,i,n,o,s){var a=t.Zero();return t.OrthoOffCenterRHToRef(e,r,i,n,o,s,a),a},t.OrthoOffCenterRHToRef=function(e,r,i,n,o,s,a){t.OrthoOffCenterLHToRef(e,r,i,n,o,s,a),a.m[10]*=-1},t.PerspectiveLH=function(r,i,n,o){var s=t.Zero(),a=n,u=o,l=2*a/r,h=2*a/i,c=(u+a)/(u-a),f=-2*u*a/(u-a);return e.Matrix.FromValuesToRef(l,0,0,0,0,h,0,0,0,0,c,1,0,0,f,0,s),s},t.PerspectiveFovLH=function(e,r,i,n){var o=t.Zero();return t.PerspectiveFovLHToRef(e,r,i,n,o),o},t.PerspectiveFovLHToRef=function(t,r,i,n,o,s){void 0===s&&(s=!0);var a=i,u=n,l=1/Math.tan(.5*t),h=s?l/r:l,c=s?l:l*r,f=(u+a)/(u-a),d=-2*u*a/(u-a);e.Matrix.FromValuesToRef(h,0,0,0,0,c,0,0,0,0,f,1,0,0,d,0,o)},t.PerspectiveFovRH=function(e,r,i,n){var o=t.Zero();return t.PerspectiveFovRHToRef(e,r,i,n,o),o},t.PerspectiveFovRHToRef=function(t,r,i,n,o,s){void 0===s&&(s=!0);var a=i,u=n,l=1/Math.tan(.5*t),h=s?l/r:l,c=s?l:l*r,f=-(u+a)/(u-a),d=-2*u*a/(u-a);e.Matrix.FromValuesToRef(h,0,0,0,0,c,0,0,0,0,f,-1,0,0,d,0,o)},t.PerspectiveFovWebVRToRef=function(e,t,r,i,n){void 0===n&&(n=!1);var o=n?-1:1,s=Math.tan(e.upDegrees*Math.PI/180),a=Math.tan(e.downDegrees*Math.PI/180),u=Math.tan(e.leftDegrees*Math.PI/180),l=Math.tan(e.rightDegrees*Math.PI/180),h=2/(u+l),c=2/(s+a);i.m[0]=h,i.m[1]=i.m[2]=i.m[3]=i.m[4]=0,i.m[5]=c,i.m[6]=i.m[7]=0,i.m[8]=(u-l)*h*.5,i.m[9]=-(s-a)*c*.5,i.m[10]=-r/(t-r),i.m[11]=1*o,i.m[12]=i.m[13]=i.m[15]=0,i.m[14]=-2*r*t/(r-t),i._markAsUpdated()},t.GetFinalMatrix=function(e,r,i,n,o,s){var a=e.width,u=e.height,l=e.x,h=e.y,c=t.FromValues(a/2,0,0,0,0,-u/2,0,0,0,0,s-o,0,l+a/2,u/2+h,o,1);return r.multiply(i).multiply(n).multiply(c)},t.GetAsMatrix2x2=function(e){return new Float32Array([e.m[0],e.m[1],e.m[4],e.m[5]])},t.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]])},t.Transpose=function(e){var r=new t;return r.m[0]=e.m[0],r.m[1]=e.m[4],r.m[2]=e.m[8],r.m[3]=e.m[12],r.m[4]=e.m[1],r.m[5]=e.m[5],r.m[6]=e.m[9],r.m[7]=e.m[13],r.m[8]=e.m[2],r.m[9]=e.m[6],r.m[10]=e.m[10],r.m[11]=e.m[14],r.m[12]=e.m[3],r.m[13]=e.m[7],r.m[14]=e.m[11],r.m[15]=e.m[15],r},t.Reflection=function(e){var r=new t;return t.ReflectionToRef(e,r),r},t.ReflectionToRef=function(e,t){e.normalize();var r=e.normal.x,i=e.normal.y,n=e.normal.z,o=-2*r,s=-2*i,a=-2*n;t.m[0]=o*r+1,t.m[1]=s*r,t.m[2]=a*r,t.m[3]=0,t.m[4]=o*i,t.m[5]=s*i+1,t.m[6]=a*i,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,t._markAsUpdated()},t.FromXYZAxesToRef=function(e,t,r,i){i.m[0]=e.x,i.m[1]=e.y,i.m[2]=e.z,i.m[3]=0,i.m[4]=t.x,i.m[5]=t.y,i.m[6]=t.z,i.m[7]=0,i.m[8]=r.x,i.m[9]=r.y,i.m[10]=r.z,i.m[11]=0,i.m[12]=0,i.m[13]=0,i.m[14]=0,i.m[15]=1,i._markAsUpdated()},t.FromQuaternionToRef=function(e,t){var r=e.x*e.x,i=e.y*e.y,n=e.z*e.z,o=e.x*e.y,s=e.z*e.w,a=e.z*e.x,u=e.y*e.w,l=e.y*e.z,h=e.x*e.w;t.m[0]=1-2*(i+n),t.m[1]=2*(o+s),t.m[2]=2*(a-u),t.m[3]=0,t.m[4]=2*(o-s),t.m[5]=1-2*(n+r),t.m[6]=2*(l+h),t.m[7]=0,t.m[8]=2*(a+u),t.m[9]=2*(l-h),t.m[10]=1-2*(i+r),t.m[11]=0,t.m[12]=0,t.m[13]=0,t.m[14]=0,t.m[15]=1,t._markAsUpdated()},t._tempQuaternion=new a,t._xAxis=n.Zero(),t._yAxis=n.Zero(),t._zAxis=n.Zero(),t._updateFlagSeed=0,t})();e.Matrix=u;var l=(function(){function e(e,t,r,i){this.normal=new n(e,t,r),this.d=i}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 r=u.Transpose(t),i=this.normal.x,n=this.normal.y,o=this.normal.z,s=this.d;return new e(i*r.m[0]+n*r.m[1]+o*r.m[2]+s*r.m[3],i*r.m[4]+n*r.m[5]+o*r.m[6]+s*r.m[7],i*r.m[8]+n*r.m[9]+o*r.m[10]+s*r.m[11],i*r.m[12]+n*r.m[13]+o*r.m[14]+s*r.m[15])},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,r){var i,n=t.x-e.x,o=t.y-e.y,s=t.z-e.z,a=r.x-e.x,u=r.y-e.y,l=r.z-e.z,h=o*l-s*u,c=s*a-n*l,f=n*u-o*a,d=Math.sqrt(h*h+c*c+f*f);return i=0!==d?1/d:0,this.normal.x=h*i,this.normal.y=c*i,this.normal.z=f*i,this.d=-(this.normal.x*e.x+this.normal.y*e.y+this.normal.z*e.z),this},e.prototype.isFrontFacingTo=function(e,t){return n.Dot(this.normal,e)<=t},e.prototype.signedDistanceTo=function(e){return n.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,r,i){var n=new e(0,0,0,0);return n.copyFromPoints(t,r,i),n},e.FromPositionAndNormal=function(t,r){var i=new e(0,0,0,0);return r.normalize(),i.normal=r,i.d=-(r.x*t.x+r.y*t.y+r.z*t.z),i},e.SignedDistanceToPlaneFromPositionAndNormal=function(e,t,r){var i=-(t.x*e.x+t.y*e.y+t.z*e.z);return n.Dot(r,t)+i},e})();e.Plane=l;var h=(function(){function e(e,t,r,i){this.x=e,this.y=t,this.width=r,this.height=i}return e.prototype.toGlobal=function(t,r){if(t._gl){var i=t;return this.toGlobal(i.getRenderWidth(),i.getRenderHeight())}var n=t;return new e(this.x*n,this.y*r,this.width*n,this.height*r)},e.prototype.clone=function(){return new e(this.x,this.y,this.width,this.height)},e})();e.Viewport=h;var c=(function(){function e(){}return e.GetPlanes=function(t){for(var r=[],i=0;i<6;i++)r.push(new l(0,0,0,0));return e.GetPlanesToRef(t,r),r},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=c;!(function(e){e[e.LOCAL=0]="LOCAL",e[e.WORLD=1]="WORLD",e[e.BONE=2]="BONE"})(e.Space||(e.Space={}));var f=(function(){function e(){}return e.X=new n(1,0,0),e.Y=new n(0,1,0),e.Z=new n(0,0,1),e})();e.Axis=f;var d=(function(){function e(){}return e.interpolate=function(e,t,r,i,n){for(var o=1-3*i+3*t,s=3*i-6*t,a=3*t,u=e,l=0;l<5;l++){var h=u*u;u-=(o*(h*u)+s*h+a*u-e)*(1/(3*o*h+2*s*u+a)),u=Math.min(1,Math.max(0,u))}return 3*Math.pow(1-u,2)*u*r+3*(1-u)*Math.pow(u,2)*n+Math.pow(u,3)},e})();e.BezierCurve=d;var p;!(function(e){e[e.CW=0]="CW",e[e.CCW=1]="CCW"})(p=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,r){var i=r.subtract(t);return new e(Math.atan2(i.y,i.x))},e.FromRadians=function(t){return new e(t)},e.FromDegrees=function(t){return new e(t*Math.PI/180)},e})();e.Angle=g;var _=(function(){function e(e,t,r){this.startPoint=e,this.midPoint=t,this.endPoint=r;var n=Math.pow(t.x,2)+Math.pow(t.y,2),o=(Math.pow(e.x,2)+Math.pow(e.y,2)-n)/2,s=(n-Math.pow(r.x,2)-Math.pow(r.y,2))/2,a=(e.x-t.x)*(t.y-r.y)-(t.x-r.x)*(e.y-t.y);this.centerPoint=new i((o*(t.y-r.y)-s*(e.y-t.y))/a,((e.x-t.x)*s-(t.x-r.x)*o)/a),this.radius=this.centerPoint.subtract(this.startPoint).length(),this.startAngle=g.BetweenTwoPoints(this.centerPoint,this.startPoint);var u=this.startAngle.degrees(),l=g.BetweenTwoPoints(this.centerPoint,this.midPoint).degrees(),h=g.BetweenTwoPoints(this.centerPoint,this.endPoint).degrees();l-u>180&&(l-=360),l-u<-180&&(l+=360),h-l>180&&(h-=360),h-l<-180&&(h+=360),this.orientation=l-u<0?p.CW:p.CCW,this.angle=g.FromDegrees(this.orientation===p.CW?u-h:h-u)}return e})();e.Arc2=_;var m=(function(){function e(e,t){this._points=new Array,this._length=0,this.closed=!1,this._points.push(new i(e,t))}return e.prototype.addLineTo=function(e,t){if(closed)return this;var r=new i(e,t),n=this._points[this._points.length-1];return this._points.push(r),this._length+=r.subtract(n).length(),this},e.prototype.addArcTo=function(e,t,r,n,o){if(void 0===o&&(o=36),closed)return this;var s=this._points[this._points.length-1],a=new i(e,t),u=new i(r,n),l=new _(s,a,u),h=l.angle.radians()/o;l.orientation===p.CW&&(h*=-1);for(var c=l.startAngle.radians()+h,f=0;f<o;f++){var d=Math.cos(c)*l.radius+l.centerPoint.x,g=Math.sin(c)*l.radius+l.centerPoint.y;this.addLineTo(d,g),c+=h}return this},e.prototype.close=function(){return this.closed=!0,this},e.prototype.length=function(){var e=this._length;if(!this.closed){var t=this._points[this._points.length-1];e+=this._points[0].subtract(t).length()}return e},e.prototype.getPoints=function(){return this._points},e.prototype.getPointAtLengthPosition=function(e){if(e<0||e>1)return i.Zero();for(var t=e*this.length(),r=0,n=0;n<this._points.length;n++){var o=(n+1)%this._points.length,s=this._points[n],a=this._points[o],u=a.subtract(s),l=u.length()+r;if(t>=r&&t<=l){var h=u.normalize(),c=t-r;return new i(s.x+h.x*c,s.y+h.y*c)}r=l}return i.Zero()},e.StartingAt=function(t,r){return new e(t,r)},e})();e.Path2=m;var v=(function(){function t(e,t,r){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 i=0;i<e.length;i++)this._curve[i]=e[i].clone();this._raw=r||!1,this._compute(t)}return t.prototype.getCurve=function(){return this._curve},t.prototype.getTangents=function(){return this._tangents},t.prototype.getNormals=function(){return this._normals},t.prototype.getBinormals=function(){return this._binormals},t.prototype.getDistances=function(){return this._distances},t.prototype.update=function(e,t){for(var r=0;r<e.length;r++)this._curve[r].x=e[r].x,this._curve[r].y=e[r].y,this._curve[r].z=e[r].z;return this._compute(t),this},t.prototype._compute=function(e){var t=this._curve.length;this._tangents[0]=this._getFirstNonNullVector(0),this._raw||this._tangents[0].normalize(),this._tangents[t-1]=this._curve[t-1].subtract(this._curve[t-2]),this._raw||this._tangents[t-1].normalize();var r=this._tangents[0],i=this._normalVector(this._curve[0],r,e);this._normals[0]=i,this._raw||this._normals[0].normalize(),this._binormals[0]=n.Cross(r,this._normals[0]),this._raw||this._binormals[0].normalize(),this._distances[0]=0;for(var o,s,a,u,l=1;l<t;l++)o=this._getLastNonNullVector(l),l<t-1&&(s=this._getFirstNonNullVector(l),this._tangents[l]=o.add(s),this._tangents[l].normalize()),this._distances[l]=this._distances[l-1]+o.length(),a=this._tangents[l],u=this._binormals[l-1],this._normals[l]=n.Cross(u,a),this._raw||this._normals[l].normalize(),this._binormals[l]=n.Cross(a,this._normals[l]),this._raw||this._binormals[l].normalize()},t.prototype._getFirstNonNullVector=function(e){for(var t=1,r=this._curve[e+t].subtract(this._curve[e]);0===r.length()&&e+t+1<this._curve.length;)t++,r=this._curve[e+t].subtract(this._curve[e]);return r},t.prototype._getLastNonNullVector=function(e){for(var t=1,r=this._curve[e].subtract(this._curve[e-t]);0===r.length()&&e>t+1;)t++,r=this._curve[e].subtract(this._curve[e-t]);return r},t.prototype._normalVector=function(t,r,i){var o,s=r.length();if(0===s&&(s=1),void 0===i||null===i){var a;e.Scalar.WithinEpsilon(Math.abs(r.y)/s,1,e.Epsilon)?e.Scalar.WithinEpsilon(Math.abs(r.x)/s,1,e.Epsilon)?e.Scalar.WithinEpsilon(Math.abs(r.z)/s,1,e.Epsilon)||(a=new n(0,0,1)):a=new n(1,0,0):a=new n(0,-1,0),o=n.Cross(r,a)}else o=n.Cross(r,i),n.CrossToRef(o,r,o);return o.normalize(),o},t})();e.Path3D=v;var y=(function(){function e(e){this._length=0,this._points=e,this._length=this._computeLength(e)}return e.CreateQuadraticBezier=function(t,r,i,o){o=o>2?o:3;for(var s=new Array,a=function(e,t,r,i){return(1-e)*(1-e)*t+2*e*(1-e)*r+e*e*i},u=0;u<=o;u++)s.push(new n(a(u/o,t.x,r.x,i.x),a(u/o,t.y,r.y,i.y),a(u/o,t.z,r.z,i.z)));return new e(s)},e.CreateCubicBezier=function(t,r,i,o,s){s=s>3?s:4;for(var a=new Array,u=function(e,t,r,i,n){return(1-e)*(1-e)*(1-e)*t+3*e*(1-e)*(1-e)*r+3*e*e*(1-e)*i+e*e*e*n},l=0;l<=s;l++)a.push(new n(u(l/s,t.x,r.x,i.x,o.x),u(l/s,t.y,r.y,i.y,o.y),u(l/s,t.z,r.z,i.z,o.z)));return new e(a)},e.CreateHermiteSpline=function(t,r,i,o,s){for(var a=new Array,u=1/s,l=0;l<=s;l++)a.push(n.Hermite(t,r,i,o,l*u));return new e(a)},e.CreateCatmullRomSpline=function(t,r){var i=new Array;i.push(t[0].clone()),Array.prototype.push.apply(i,t),i.push(t[t.length-1].clone());for(var o=new Array,s=1/r,a=0;a<i.length-3;a++)for(var u=0,l=0;l<r;l++)o.push(n.CatmullRom(i[a],i[a+1],i[a+2],i[a+3],u)),u+=s;return a--,o.push(n.CatmullRom(i[a],i[a+1],i[a+2],i[a+3],u)),new e(o)},e.prototype.getPoints=function(){return this._points},e.prototype.length=function(){return this._length},e.prototype.continue=function(t){for(var r=this._points[this._points.length-1],i=this._points.slice(),n=t.getPoints(),o=1;o<n.length;o++)i.push(n[o].subtract(n[0]).add(r));return new e(i)},e.prototype._computeLength=function(e){for(var t=0,r=1;r<e.length;r++)t+=e[r].subtract(e[r-1]).length();return t},e})();e.Curve3=y;var A=(function(){function e(e,t){void 0===e&&(e=n.Zero()),void 0===t&&(t=n.Up()),this.position=e,this.normal=t}return e.prototype.clone=function(){return new e(this.position.clone(),this.normal.clone())},e})();e.PositionNormalVertex=A;var T=(function(){function e(e,t,r){void 0===e&&(e=n.Zero()),void 0===t&&(t=n.Up()),void 0===r&&(r=i.Zero()),this.position=e,this.normal=t,this.uv=r}return e.prototype.clone=function(){return new e(this.position.clone(),this.normal.clone(),this.uv.clone())},e})();e.PositionNormalTextureVertex=T;var E=(function(){function e(){}return e.Color3=[t.Black(),t.Black(),t.Black()],e.Vector2=[i.Zero(),i.Zero(),i.Zero()],e.Vector3=[n.Zero(),n.Zero(),n.Zero(),n.Zero(),n.Zero(),n.Zero(),n.Zero(),n.Zero(),n.Zero()],e.Vector4=[o.Zero(),o.Zero(),o.Zero()],e.Quaternion=[a.Zero(),a.Zero()],e.Matrix=[u.Zero(),u.Zero(),u.Zero(),u.Zero(),u.Zero(),u.Zero(),u.Zero(),u.Zero()],e})();e.Tmp=E;var b=(function(){function e(){}return e.Vector3=[n.Zero()],e.Matrix=[u.Zero(),u.Zero()],e.Quaternion=[a.Zero()],e})()})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(){}return e.WithinEpsilon=function(e,t,r){void 0===r&&(r=1.401298e-45);var i=e-t;return-r<=i&&i<=r},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,r){return void 0===t&&(t=0),void 0===r&&(r=1),Math.min(r,Math.max(t,e))},e.Log2=function(e){return Math.log(e)*Math.LOG2E},e.Repeat=function(e,t){return e-Math.floor(e/t)*t},e.Normalize=function(e,t,r){return(e-t)/(r-t)},e.Denormalize=function(e,t,r){return e*(r-t)+t},e.DeltaAngle=function(t,r){var i=e.Repeat(r-t,360);return i>180&&(i-=360),i},e.PingPong=function(t,r){var i=e.Repeat(t,2*r);return r-Math.abs(i-r)},e.SmoothStep=function(t,r,i){var n=e.Clamp(i);return n=-2*n*n*n+3*n*n,r*n+t*(1-n)},e.MoveTowards=function(t,r,i){return Math.abs(r-t)<=i?r:t+e.Sign(r-t)*i},e.MoveTowardsAngle=function(t,r,i){var n=e.DeltaAngle(t,r),o=0;return-i<n&&n<i?o=r:(r=t+n,o=e.MoveTowards(t,r,i)),o},e.Lerp=function(e,t,r){return e+(t-e)*r},e.LerpAngle=function(t,r,i){var n=e.Repeat(r-t,360);return n>180&&(n-=360),t+n*e.Clamp(i)},e.InverseLerp=function(t,r,i){return t!=r?e.Clamp((i-t)/(r-t)):0},e.Hermite=function(e,t,r,i,n){var o=n*n,s=n*o;return e*(2*s-3*o+1)+r*(-2*s+3*o)+t*(s-2*o+n)+i*(s-o)},e.RandomRange=function(e,t){return e===t?e:Math.random()*(t-e)+e},e.RangeToPercent=function(e,t,r){return(e-t)/(r-t)},e.PercentToRange=function(e,t,r){return(r-t)*e+t},e})();e.Scalar=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){function t(e){var t=e.getClassName();return _[t]||(_[t]={}),_[t]}function r(e){var t=e.getClassName();if(m[t])return m[t];m[t]={};for(var r=m[t],i=e,n=t;n;){var o=_[n];for(var s in o)r[s]=o[s];var a=void 0,u=!1;do{if(a=Object.getPrototypeOf(i),!a.getClassName){u=!0;break}if(a.getClassName()!==n)break;i=a}while(a);if(u)break;n=a.getClassName(),i=a}return r}function i(e,r){return function(i,n){var o=t(i);o[n]||(o[n]={type:e,sourceName:r})}}function n(e,t){return function(r,i){var n=t||"_"+i;Object.defineProperty(r,i,{get:function(){return this[n]},set:function(t){this[n]!==t&&(this[n]=t,r[e].apply(this))},enumerable:!0,configurable:!0})}}function o(e,t){return n(e,t)}function s(e){return i(0,e)}function a(e){return i(1,e)}function u(e){return i(2,e)}function l(e){return i(3,e)}function h(e){return i(4,e)}function c(e){return i(5,e)}function f(e){return i(6,e)}function d(e){return i(7,e)}function p(e){return i(8,e)}function g(e){return i(9,e)}var _={},m={},v=function(t,i,n){var o=t();e.Tags&&e.Tags.AddTagsTo(o,i.tags);var s=r(o);for(var a in s){var u=s[a],l=i[a],h=u.type;if(void 0!==l&&null!==l)switch(h){case 0:case 6:o[a]=l;break;case 1:case 2:case 3:case 4:case 5:case 7:o[a]=n?l:l.clone()}}return o};e.expandToProperty=o,e.serialize=s,e.serializeAsTexture=a,e.serializeAsColor3=u,e.serializeAsFresnelParameters=l,e.serializeAsVector2=h,e.serializeAsVector3=c,e.serializeAsMeshReference=f,e.serializeAsColorCurves=d,e.serializeAsColor4=p,e.serializeAsImageProcessingConfiguration=g;var y=(function(){function t(){}return t.Serialize=function(t,i){i||(i={}),e.Tags&&(i.tags=e.Tags.GetTags(t));var n=r(t);for(var o in n){var s=n[o],a=s.sourceName||o,u=s.type,l=t[o];if(void 0!==l&&null!==l)switch(u){case 0:i[a]=l;break;case 1:i[a]=l.serialize();break;case 2:i[a]=l.asArray();break;case 3:i[a]=l.serialize();break;case 4:case 5:i[a]=l.asArray();break;case 6:i[a]=l.id;break;case 7:i[a]=l.serialize();break;case 8:i[a]=l.asArray();break;case 9:i[a]=l.serialize()}}return i},t.Parse=function(t,i,n,o){var s=t();e.Tags&&e.Tags.AddTagsTo(s,i.tags);var a=r(s);for(var u in a){var l=a[u],h=i[l.sourceName||u],c=l.type;if(void 0!==h&&null!==h)switch(c){case 0:s[u]=h;break;case 1:s[u]=e.Texture.Parse(h,n,o);break;case 2:s[u]=e.Color3.FromArray(h);break;case 3:s[u]=e.FresnelParameters.Parse(h);break;case 4:s[u]=e.Vector2.FromArray(h);break;case 5:s[u]=e.Vector3.FromArray(h);break;case 6:s[u]=n.getLastMeshByID(h);break;case 7:s[u]=e.ColorCurves.Parse(h);break;case 8:s[u]=e.Color4.FromArray(h);break;case 9:s[u]=e.ImageProcessingConfiguration.Parse(h)}}return s},t.Clone=function(e,t){return v(e,t,!1)},t.Instanciate=function(e,t){return v(e,t,!0)},t})();e.SerializationHelper=y})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(e,t){void 0===t&&(t=!1),this.initalize(e,t)}return e.prototype.initalize=function(e,t){return void 0===t&&(t=!1),this.mask=e,this.skipNextObservers=t,this},e})();e.EventState=t;var r=(function(){function e(e,t){this.callback=e,this.mask=t}return e})();e.Observer=r;var i=(function(){function e(){this._observers=new Array,this._eventState=new t(0)}return e.prototype.add=function(e,t,i){if(void 0===t&&(t=-1),void 0===i&&(i=!1),!e)return null;var n=new r(e,t);return i?this._observers.unshift(n):this._observers.push(n),n},e.prototype.remove=function(e){var t=this._observers.indexOf(e);return-1!==t&&(this._observers.splice(t,1),!0)},e.prototype.removeCallback=function(e){for(var t=0;t<this._observers.length;t++)if(this._observers[t].callback===e)return this._observers.splice(t,1),!0;return!1},e.prototype.notifyObservers=function(e,t){void 0===t&&(t=-1);var r=this._eventState;r.mask=t,r.skipNextObservers=!1;for(var i=0,n=this._observers;i<n.length;i++){var o=n[i];if(o.mask&t&&o.callback(e,r),r.skipNextObservers)return!1}return!0},e.prototype.hasObservers=function(){return this._observers.length>0},e.prototype.clear=function(){this._observers=new Array},e.prototype.clone=function(){var t=new e;return t._observers=this._observers.slice(0),t},e.prototype.hasSpecificMask=function(e){void 0===e&&(e=-1);for(var t=0,r=this._observers;t<r.length;t++){var i=r[t];if(i.mask&e&&i.mask===e)return!0}return!1},e})();e.Observable=i})(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.forEach=function(e){for(var t=0;t<this.length;t++)e(this.data[t])},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.dispose=function(){this.reset(),this.data&&(this.data.length=0,this.data=null)},e.prototype.concat=function(e){if(0!==e.length){this.length+e.length>this.data.length&&(this.data.length=2*(this.length+e.length));for(var t=0;t<e.length;t++)this.data[this.length++]=(e.data||e)[t]}},e.prototype.concatWithNoDuplicate=function(e){if(0!==e.length){this.length+e.length>this.data.length&&(this.data.length=2*(this.length+e.length));for(var t=0;t<e.length;t++){var r=(e.data||e)[t];this.pushNoDuplicate(r)}}},e.prototype.indexOf=function(e){var t=this.data.indexOf(e);return t>=this.length?-1:t},e.prototype.contains=function(e){return-1!==this.data.indexOf(e)},e._GlobalId=0,e})();e.SmartArray=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){function t(e,t){return function(r){r.__bjsclassName__=e,r.__bjsmoduleName__=null!=t?t:null}}var r,i=function(t,r){return t?t instanceof e.Mesh?null:t instanceof e.SubMesh?t.clone(r):t.clone?t.clone():null:null},n=(function(){function t(){}return t.Mix=function(e,t,r){return e*(1-r)+t*r},t.Instantiate=function(e){for(var t=e.split("."),r=window||this,i=0,n=t.length;i<n;i++)r=r[t[i]];return"function"!=typeof r?null:r},t.SetImmediate=function(e){window.setImmediate?window.setImmediate(e):setTimeout(e,1)},t.IsExponentOfTwo=function(e){var t=1;do{t*=2}while(t<e);return t===e},t.CeilingPOT=function(e){return e--,e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,++e},t.FloorPOT=function(e){return e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,(e|=e>>16)-(e>>1)},t.NearestPOT=function(e){var r=t.CeilingPOT(e),i=t.FloorPOT(e);return r-e>e-i?i:r},t.GetExponentOfTwo=function(r,i,n){void 0===n&&(n=e.Engine.SCALEMODE_NEAREST);var o;switch(n){case e.Engine.SCALEMODE_FLOOR:o=t.FloorPOT(r);break;case e.Engine.SCALEMODE_NEAREST:o=t.NearestPOT(r);break;case e.Engine.SCALEMODE_CEILING:o=t.CeilingPOT(r)}return Math.min(o,i)},t.GetFilename=function(e){var t=e.lastIndexOf("/");return t<0?e:e.substring(t+1)},t.GetDOMTextContent=function(e){for(var t="",r=e.firstChild;r;)3===r.nodeType&&(t+=r.textContent),r=r.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,r,i,n,o,s,a,u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",l="",h=0,c=new Uint8Array(e);h<c.length;)t=c[h++],r=h<c.length?c[h++]:Number.NaN,i=h<c.length?c[h++]:Number.NaN,n=t>>2,o=(3&t)<<4|r>>4,s=(15&r)<<2|i>>6,a=63&i,isNaN(r)?s=a=64:isNaN(i)&&(a=64),l+=u.charAt(n)+u.charAt(o)+u.charAt(s)+u.charAt(a);return"data:image/png;base64,"+l},t.ExtractMinAndMaxIndexed=function(t,r,i,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),u=i;u<i+n;u++){var l=new e.Vector3(t[3*r[u]],t[3*r[u]+1],t[3*r[u]+2]);s=e.Vector3.Minimize(l,s),a=e.Vector3.Maximize(l,a)}return o&&(s.x-=s.x*o.x+o.y,s.y-=s.y*o.x+o.y,s.z-=s.z*o.x+o.y,a.x+=a.x*o.x+o.y,a.y+=a.y*o.x+o.y,a.z+=a.z*o.x+o.y),{minimum:s,maximum:a}},t.ExtractMinAndMax=function(t,r,i,n,o){void 0===n&&(n=null);var s=new e.Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),a=new e.Vector3(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);o||(o=3);for(var u=r;u<r+i;u++){var l=new e.Vector3(t[u*o],t[u*o+1],t[u*o+2]);s=e.Vector3.Minimize(l,s),a=e.Vector3.Maximize(l,a)}return n&&(s.x-=s.x*n.x+n.y,s.y-=s.y*n.x+n.y,s.z-=s.z*n.x+n.y,a.x+=a.x*n.x+n.y,a.y+=a.y*n.x+n.y,a.z+=a.z*n.x+n.y),{minimum:s,maximum:a}},t.Vector2ArrayFeeder=function(t){return function(r){var i=void 0!==t.BYTES_PER_ELEMENT;if(r>=(i?t.length/2:t.length))return null;if(i){var n=t;return new e.Vector2(n[2*r+0],n[2*r+1])}return t[r]}},t.ExtractMinAndMaxVector2=function(t,r){void 0===r&&(r=null);for(var i=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;)i=e.Vector2.Minimize(s,i),n=e.Vector2.Maximize(s,n),s=t(o++);return r&&(i.x-=i.x*r.x+r.y,i.y-=i.y*r.x+r.y,n.x+=n.x*r.x+r.y,n.y+=n.y*r.x+r.y),{minimum:i,maximum:n}},t.MakeArray=function(e,t){if(!0===t||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,r){if(t.CorsBehavior)switch(typeof t.CorsBehavior){case"function":var i=t.CorsBehavior(e);i&&(r.crossOrigin=i);break;case"string":default:r.crossOrigin=t.CorsBehavior}},t.CleanUrl=function(e){return e=e.replace(/#/gm,"%23")},t.LoadImage=function(r,i,n,o){r instanceof ArrayBuffer&&(r=t.EncodeArrayBufferTobase64(r)),r=t.CleanUrl(r);var s=new Image;"data:"!==r.substr(0,5)&&t.SetCorsBehavior(r,s),s.onload=function(){i(s)},s.onerror=function(e){t.Error("Error while trying to load image: "+r),t.UseFallbackTexture?(s.src=t.fallbackTexture,i(s)):n()};var a=function(){s.src=r},u=function(){o.loadImageFromDB(r,s)};if("data:"!==r.substr(0,5)&&o&&o.enableTexturesOffline&&e.Database.IsUASupportingBlobStorage)o.openAsync(u,a);else if(0!==r.indexOf("file:"))a();else{var l=decodeURIComponent(r.substring(5).toLowerCase());if(e.FilesInput.FilesToLoad[l])try{var h;try{h=URL.createObjectURL(e.FilesInput.FilesToLoad[l],{oneTimeOnly:!0})}catch(t){h=URL.createObjectURL(e.FilesInput.FilesToLoad[l])}s.src=h}catch(e){s.src=null}else t.Error("Image: "+l+" not found. Did you forget to provide it?"),s.src=t.fallbackTexture}return s},t.LoadFile=function(r,i,n,o,s,a){r=t.CleanUrl(r);var u=function(){var e=new XMLHttpRequest,o=t.BaseUrl+r;e.open("GET",o,!0),s&&(e.responseType="arraybuffer"),e.onprogress=n,e.onreadystatechange=function(){if(e.readyState===(XMLHttpRequest.DONE||4))if(e.onreadystatechange=null,e.status>=200&&e.status<300||navigator.isCocoonJS&&0===e.status)i(s?e.response:e.responseText);else{if(!a)throw new Error("Error status: "+e.status+" - Unable to load "+o);a(e)}},e.send(null)},l=function(){o.loadFileFromDB(r,i,n,u,s)};if(-1!==r.indexOf("file:")){var h=decodeURIComponent(r.substring(5).toLowerCase());e.FilesInput.FilesToLoad[h]?t.ReadFile(e.FilesInput.FilesToLoad[h],i,n,s):t.Error("File: "+h+" not found. Did you forget to provide it?")}else o&&o.enableSceneOffline?o.openAsync(l,u):u()},t.LoadScript=function(e,t,r){var i=document.getElementsByTagName("head")[0],n=document.createElement("script");n.type="text/javascript",n.src=e;n.onload=function(){t&&t()},n.onerror=function(){r&&r()},i.appendChild(n)},t.ReadFileAsDataURL=function(e,t,r){var i=new FileReader;i.onload=function(e){t(e.target.result)},i.onprogress=r,i.readAsDataURL(e)},t.ReadFile=function(e,r,i,n){var o=new FileReader;o.onerror=function(i){t.Log("Error while reading file: "+e.name),r(JSON.stringify({autoClear:!0,clearColor:[1,0,0],ambientColor:[0,0,0],gravity:[0,-9.807,0],meshes:[],cameras:[],lights:[]}))},o.onload=function(e){r(e.target.result)},o.onprogress=i,n?o.readAsArrayBuffer(e):o.readAsText(e)},t.FileAsURL=function(e){var t=new Blob([e]);return(window.URL||window.webkitURL).createObjectURL(t)},t.Format=function(e,t){return void 0===t&&(t=2),e.toFixed(t)},t.CheckExtends=function(e,t,r){e.x<t.x&&(t.x=e.x),e.y<t.y&&(t.y=e.y),e.z<t.z&&(t.z=e.z),e.x>r.x&&(r.x=e.x),e.y>r.y&&(r.y=e.y),e.z>r.z&&(r.z=e.z)},t.DeepCopy=function(e,t,r,n){for(var o in e)if(("_"!==o[0]||n&&-1!==n.indexOf(o))&&(!r||-1===r.indexOf(o))){var s=e[o],a=typeof s;if("function"!==a)if("object"===a)if(s instanceof Array){if(t[o]=[],s.length>0)if("object"==typeof s[0])for(var u=0;u<s.length;u++){var l=i(s[u],t);-1===t[o].indexOf(l)&&t[o].push(l)}else t[o]=s.slice(0)}else t[o]=i(s,t);else t[o]=s}},t.IsEmpty=function(e){for(var t in e)return!1;return!0},t.RegisterTopRootEvents=function(e){for(var t=0;t<e.length;t++){var r=e[t];window.addEventListener(r.name,r.handler,!1);try{window.parent&&window.parent.addEventListener(r.name,r.handler,!1)}catch(e){}}},t.UnregisterTopRootEvents=function(e){for(var t=0;t<e.length;t++){var r=e[t];window.removeEventListener(r.name,r.handler);try{window.parent&&window.parent.removeEventListener(r.name,r.handler)}catch(e){}}},t.DumpFramebuffer=function(e,i,n,o,s){void 0===s&&(s="image/png");for(var a=4*e,u=i/2,l=n.readPixels(0,0,e,i),h=0;h<u;h++)for(var c=0;c<a;c++){var f=c+h*a,d=i-h-1,p=c+d*a,g=l[f];l[f]=l[p],l[p]=g}r||(r=document.createElement("canvas")),r.width=e,r.height=i;var _=r.getContext("2d"),m=_.createImageData(e,i);m.data.set(l),_.putImageData(m,0,0),t.EncodeScreenshotCanvasData(o,s)},t.EncodeScreenshotCanvasData=function(e,t){void 0===t&&(t="image/png");var i=r.toDataURL(t);if(e)e(i);else if("download"in document.createElement("a")){var n=window.document.createElement("a");n.href=i;var o=new Date,s=(o.getFullYear()+"-"+(o.getMonth()+1)).slice(-2)+"-"+o.getDate()+"_"+o.getHours()+"-"+("0"+o.getMinutes()).slice(-2);n.setAttribute("download","screenshot_"+s+".png"),window.document.body.appendChild(n),n.addEventListener("click",(function(){n.parentElement.removeChild(n)})),n.click()}else{var a=window.open(""),u=a.document.createElement("img");u.src=i,a.document.body.appendChild(u)}},t.CreateScreenshot=function(e,i,n,o,s){void 0===s&&(s="image/png");var a,u;if(n.precision)a=Math.round(e.getRenderWidth()*n.precision),u=Math.round(a/e.getAspectRatio(i));else if(n.width&&n.height)a=n.width,u=n.height;else if(n.width&&!n.height)a=n.width,u=Math.round(a/e.getAspectRatio(i));else if(n.height&&!n.width)u=n.height,a=Math.round(u*e.getAspectRatio(i));else{if(isNaN(n))return void t.Error("Invalid 'size' parameter !");u=n,a=n}r||(r=document.createElement("canvas")),r.width=a,r.height=u;var l=r.getContext("2d"),h=e.getRenderWidth()/e.getRenderHeight(),c=a,f=c/h;f>u&&(f=u,c=f*h);var d=Math.max(0,a-c)/2,p=Math.max(0,u-f)/2;l.drawImage(e.getRenderingCanvas(),d,p,c,f),t.EncodeScreenshotCanvasData(o,s)},t.CreateScreenshotUsingRenderTarget=function(r,i,n,o,s,a){void 0===s&&(s="image/png"),void 0===a&&(a=1);var u,l;if(n.precision)u=Math.round(r.getRenderWidth()*n.precision),l=Math.round(u/r.getAspectRatio(i)),n={width:u,height:l};else if(n.width&&n.height)u=n.width,l=n.height;else if(n.width&&!n.height)u=n.width,l=Math.round(u/r.getAspectRatio(i)),n={width:u,height:l};else if(n.height&&!n.width)l=n.height,u=Math.round(l*r.getAspectRatio(i)),n={width:u,height:l};else{if(isNaN(n))return void t.Error("Invalid 'size' parameter !");l=n,u=n}var h=i.getScene(),c=null;h.activeCamera!==i&&(c=h.activeCamera,h.activeCamera=i);var f=new e.RenderTargetTexture("screenShot",n,h,!1,!1,e.Engine.TEXTURETYPE_UNSIGNED_INT,!1,e.Texture.NEAREST_SAMPLINGMODE);f.renderList=null,f.samples=a,f.onAfterRenderObservable.add((function(){t.DumpFramebuffer(u,l,r,o,s)})),h.incrementRenderId(),h.resetCachedMaterial(),f.render(!0),f.dispose(),c&&(h.activeCamera=c),i.getProjectionMatrix(!0)},t.ValidateXHRData=function(t,r){void 0===r&&(r=7);try{if(1&r){if(t.responseText&&t.responseText.length>0)return!0;if(1===r)return!1}if(2&r){var i=e.Internals.TGATools.GetTGAHeader(t.response);if(i.width&&i.height&&i.width>0&&i.height>0)return!0;if(2===r)return!1}if(4&r){var n=new Uint8Array(t.response,0,3);return 68===n[0]&&68===n[1]&&83===n[2]}}catch(e){}return!1},t.RandomId=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).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},r=new Date;return"["+t(r.getHours())+":"+t(r.getMinutes())+":"+t(r.getSeconds())+"]: "+e},t._LogDisabled=function(e){},t._LogEnabled=function(e){var r=t._FormatMessage(e);console.log("BJS - "+r);var i="<div style='color:white'>"+r+"</div><br>";t._AddLogEntry(i)},t._WarnDisabled=function(e){},t._WarnEnabled=function(e){var r=t._FormatMessage(e);console.warn("BJS - "+r);var i="<div style='color:orange'>"+r+"</div><br>";t._AddLogEntry(i)},t._ErrorDisabled=function(e){},t._ErrorEnabled=function(e){t.errorsCount++;var r=t._FormatMessage(e);console.error("BJS - "+r);var i="<div style='color:red'>"+r+"</div><br>";t._AddLogEntry(i)},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,r){void 0===r&&(r=!0),r&&t._performance.mark&&t._performance.mark(e+"-Begin")},t._EndUserMark=function(e,r){void 0===r&&(r=!0),r&&t._performance.mark&&(t._performance.mark(e+"-End"),t._performance.measure(e,e+"-Begin",e+"-End"))},t._StartPerformanceConsole=function(e,r){void 0===r&&(r=!0),r&&(t._StartUserMark(e,r),console.time&&console.time(e))},t._EndPerformanceConsole=function(e,r){void 0===r&&(r=!0),r&&(t._EndUserMark(e,r),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 r=null;if(!t&&e.getClassName)r=e.getClassName();else{if(e instanceof Object){r=(t?e:Object.getPrototypeOf(e)).constructor.__bjsclassName__}r||(r=typeof e)}return r},t.first=function(e,t){for(var r=0,i=e;r<i.length;r++){var n=i[r];if(t(n))return n}},t.getFullClassName=function(e,t){void 0===t&&(t=!1);var r=null,i=null;if(!t&&e.getClassName)r=e.getClassName();else{if(e instanceof Object){var n=t?e:Object.getPrototypeOf(e);r=n.constructor.__bjsclassName__,i=n.constructor.__bjsmoduleName__}r||(r=typeof e)}return r?(null!=i?i+".":"")+r:null},t.arrayOrStringFeeder=function(e){return function(r){if(r>=e.length)return null;var i=e.charCodeAt?e.charCodeAt(r):e[r];return i&&i.getHashCode&&(i=i.getHashCode()),"string"==typeof i?t.hashCodeFromStream(t.arrayOrStringFeeder(i)):i}},t.hashCodeFromStream=function(e){for(var t=0,r=0,i=e(r++);null!=i;)t=(t<<5)-t+i,t|=0,i=e(r++);return t},t.BaseUrl="",t.CorsBehavior="anonymous",t.UseFallbackTexture=!0,t.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",t._NoneLogLevel=0,t._MessageLogLevel=1,t._WarningLogLevel=2,t._ErrorLogLevel=4,t._LogCache="",t.errorsCount=0,t.Log=t._LogEnabled,t.Warn=t._WarnEnabled,t.Error=t._ErrorEnabled,t._PerformanceNoneLogLevel=0,t._PerformanceUserMarkLogLevel=1,t._PerformanceConsoleLogLevel=2,t._performance=window.performance,t.StartPerformanceCounter=t._StartPerformanceCounterDisabled,t.EndPerformanceCounter=t._EndPerformanceCounterDisabled,t})();e.Tools=n;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(t,r){e.Enabled&&(this._current+=t,r&&this._fetchResult())},e.prototype.beginMonitoring=function(){e.Enabled&&(this._startMonitoringTime=n.Now)},e.prototype.endMonitoring=function(t){if(void 0===t&&(t=!0),e.Enabled){t&&this.fetchNewFrame();var r=n.Now;this._current=r-this._startMonitoringTime,t&&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.Enabled=!0,e})();e.PerfCounter=o,e.className=t;var s=(function(){function e(e,t,r,i){void 0===i&&(i=0),this.iterations=e,this._fn=t,this._successCallback=r,this.index=i-1,this._done=!1}return e.prototype.executeNext=function(){this._done||(this.index+1<this.iterations?(++this.index,this._fn(this)):this.breakLoop())},e.prototype.breakLoop=function(){this._done=!0,this._successCallback()},e.Run=function(t,r,i,n){void 0===n&&(n=0);var o=new e(t,r,i,n);return o.executeNext(),o},e.SyncAsyncForLoop=function(t,r,i,n,o,s){void 0===s&&(s=0),e.Run(Math.ceil(t/r),(function(e){o&&o()?e.breakLoop():setTimeout((function(){for(var n=0;n<r;++n){var s=e.index*r+n;if(s>=t)break;if(i(s),o&&o()){e.breakLoop();break}}e.executeNext()}),s)}),n)},e})();e.AsyncLoop=s})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(e){var t=(function(){function e(){this._isAlphaBlendDirty=!1,this._isBlendFunctionParametersDirty=!1,this._isBlendEquationParametersDirty=!1,this._isBlendConstantsDirty=!1,this._alphaBlend=!1,this._blendFunctionParameters=new Array(4),this._blendEquationParameters=new Array(2),this._blendConstants=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.setAlphaBlendConstants=function(e,t,r,i){this._blendConstants[0]===e&&this._blendConstants[1]===t&&this._blendConstants[2]===r&&this._blendConstants[3]===i||(this._blendConstants[0]=e,this._blendConstants[1]=t,this._blendConstants[2]=r,this._blendConstants[3]=i,this._isBlendConstantsDirty=!0)},e.prototype.setAlphaBlendFunctionParameters=function(e,t,r,i){this._blendFunctionParameters[0]===e&&this._blendFunctionParameters[1]===t&&this._blendFunctionParameters[2]===r&&this._blendFunctionParameters[3]===i||(this._blendFunctionParameters[0]=e,this._blendFunctionParameters[1]=t,this._blendFunctionParameters[2]=r,this._blendFunctionParameters[3]=i,this._isBlendFunctionParametersDirty=!0)},e.prototype.setAlphaEquationParameters=function(e,t){this._blendEquationParameters[0]===e&&this._blendEquationParameters[1]===t||(this._blendEquationParameters[0]=e,this._blendEquationParameters[1]=t,this._isBlendEquationParametersDirty=!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._blendEquationParameters[0]=null,this._blendEquationParameters[1]=null,this._blendConstants[0]=null,this._blendConstants[1]=null,this._blendConstants[2]=null,this._blendConstants[3]=null,this._isAlphaBlendDirty=!0,this._isBlendFunctionParametersDirty=!1,this._isBlendEquationParametersDirty=!1,this._isBlendConstantsDirty=!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),this._isBlendEquationParametersDirty&&(e.blendEquationSeparate(this._isBlendEquationParametersDirty[0],this._isBlendEquationParametersDirty[1]),this._isBlendEquationParametersDirty=!1),this._isBlendConstantsDirty&&(e.blendColor(this._blendConstants[0],this._blendConstants[1],this._blendConstants[2],this._blendConstants[3]),this._isBlendConstantsDirty=!1))},e})();e._AlphaState=t})(e.Internals||(e.Internals={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(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})(e.Internals||(e.Internals={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(t){var r=(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=r})(e.Internals||(e.Internals={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=function(e,t,r,i,n){var o=e.createShader("vertex"===r?e.VERTEX_SHADER:e.FRAGMENT_SHADER);if(e.shaderSource(o,n+(i?i+"\n":"")+t),e.compileShader(o),!e.getShaderParameter(o,e.COMPILE_STATUS))throw new Error(e.getShaderInfoLog(o));return o},r=function(t,r,i){var n=i.NEAREST,o=i.NEAREST;switch(t){case e.Texture.BILINEAR_SAMPLINGMODE:n=i.LINEAR,o=r?i.LINEAR_MIPMAP_NEAREST:i.LINEAR;break;case e.Texture.TRILINEAR_SAMPLINGMODE:n=i.LINEAR,o=r?i.LINEAR_MIPMAP_LINEAR:i.LINEAR;break;case e.Texture.NEAREST_SAMPLINGMODE:n=i.NEAREST,o=r?i.NEAREST_MIPMAP_LINEAR:i.NEAREST;break;case e.Texture.NEAREST_NEAREST_MIPNEAREST:n=i.NEAREST,o=r?i.NEAREST_MIPMAP_NEAREST:i.NEAREST;break;case e.Texture.NEAREST_LINEAR_MIPNEAREST:n=i.NEAREST,o=r?i.LINEAR_MIPMAP_NEAREST:i.LINEAR;break;case e.Texture.NEAREST_LINEAR_MIPLINEAR:n=i.NEAREST,o=r?i.LINEAR_MIPMAP_LINEAR:i.LINEAR;break;case e.Texture.NEAREST_LINEAR:n=i.NEAREST,o=i.LINEAR;break;case e.Texture.NEAREST_NEAREST:n=i.NEAREST,o=i.NEAREST;break;case e.Texture.LINEAR_NEAREST_MIPNEAREST:n=i.LINEAR,o=r?i.NEAREST_MIPMAP_NEAREST:i.NEAREST;break;case e.Texture.LINEAR_NEAREST_MIPLINEAR:n=i.LINEAR,o=r?i.NEAREST_MIPMAP_LINEAR:i.NEAREST;break;case e.Texture.LINEAR_LINEAR:n=i.LINEAR,o=i.LINEAR;break;case e.Texture.LINEAR_NEAREST:n=i.LINEAR,o=i.NEAREST}return{min:o,mag:n}},i=function(t,r,i,n,o,s){void 0===s&&(s=null);var a,u=function(){i[r]=a,i._internalCount++,n._removePendingData(a),6===i._internalCount&&o(i)},l=function(){n._removePendingData(a),s&&s()};a=e.Tools.LoadImage(t,u,l,n.database),n._addPendingData(a)},n=function(e,t,r,n,o){void 0===o&&(o=null);var s=[];s._internalCount=0;for(var a=0;a<6;a++)i(n[a],a,s,t,r,o)},o=(function(){function e(){}return e})(),s=(function(){function e(){}return e})();e.InstancingAttributeInfo=s;var a=(function(){function e(){}return e})();e.EngineCapabilities=a;var u=(function(){function i(t,r,n,s){void 0===s&&(s=!1);var u=this;this.forcePOTTextures=!1,this.isFullscreen=!1,this.isPointerLock=!1,this.cullBackFaces=!0,this.renderEvenInBackground=!0,this.preventCacheWipeBetweenFrames=!1,this.enableOfflineSupport=!1,this.scenes=new Array,this.onResizeObservable=new e.Observable,this.onCanvasBlurObservable=new e.Observable,this._windowIsBackground=!1,this._webGLVersion=1,this._badOS=!1,this._badDesktopOS=!1,this._drawCalls=new e.PerfCounter,this._renderingQueueLaunched=!1,this._activeRenderLoops=[],this._deterministicLockstep=!1,this._lockstepMaxSteps=4,this._performanceMonitor=new e.PerformanceMonitor,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=i.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=new Array,this._currentInstanceLocations=new Array,this._currentInstanceBuffers=new Array,this._vaoRecordInProgress=!1,this._mustWipeVertexAttributes=!1,this._texturesSupported=new Array,this._onVRFullScreenTriggered=function(){if(u._vrDisplayEnabled&&u._vrDisplayEnabled.isPresenting){u._oldSize=new e.Size(u.getRenderWidth(),u.getRenderHeight()),u._oldHardwareScaleFactor=u.getHardwareScalingLevel();var t=u._vrDisplayEnabled.getEyeParameters("left");u.setHardwareScalingLevel(1),u.setSize(2*t.renderWidth,t.renderHeight)}else u.setHardwareScalingLevel(u._oldHardwareScaleFactor),u.setSize(u._oldSize.width,u._oldSize.height),u._vrDisplayEnabled=void 0};var l;if(i.Instances.push(this),n=n||{},t.getContext){if(l=t,this._renderingCanvas=l,null!=r&&(n.antialias=r),void 0===n.deterministicLockstep&&(n.deterministicLockstep=!1),void 0===n.lockstepMaxSteps&&(n.lockstepMaxSteps=4),void 0===n.preserveDrawingBuffer&&(n.preserveDrawingBuffer=!1),void 0===n.audioEngine&&(n.audioEngine=!0),void 0===n.stencil&&(n.stencil=!0),this._deterministicLockstep=n.deterministicLockstep,this._lockstepMaxSteps=n.lockstepMaxSteps,!n.disableWebGL2Support)try{this._gl=l.getContext("webgl2",n)||l.getContext("experimental-webgl2",n),this._gl&&(this._webGLVersion=2)}catch(e){}if(!this._gl){if(!l)throw new Error("The provided canvas is null or undefined.");try{this._gl=l.getContext("webgl",n)||l.getContext("experimental-webgl",n)}catch(e){throw new Error("WebGL not supported")}}if(!this._gl)throw new Error("WebGL not supported");this._onBlur=function(){u._performanceMonitor.disable(),u._windowIsBackground=!0},this._onFocus=function(){u._performanceMonitor.enable(),u._windowIsBackground=!1},this._onCanvasBlur=function(){u.onCanvasBlurObservable.notifyObservers(u)},window.addEventListener("blur",this._onBlur),window.addEventListener("focus",this._onFocus),l.addEventListener("pointerout",this._onCanvasBlur)}else this._gl=t,this._renderingCanvas=this._gl.canvas,this._gl.renderbufferStorageMultisample&&(this._webGLVersion=2),n.stencil=this._gl.getContextAttributes().stencil;var h=n.limitDeviceRatio||window.devicePixelRatio||1;this._hardwareScalingLevel=s?1/Math.min(h,window.devicePixelRatio||1):1,this.resize(),this._isStencilEnable=n.stencil,this._caps=new a,this._caps.maxTexturesImageUnits=this._gl.getParameter(this._gl.MAX_TEXTURE_IMAGE_UNITS),this._caps.maxVertexTextureImageUnits=this._gl.getParameter(this._gl.MAX_VERTEX_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 c=this._gl.getExtension("WEBGL_debug_renderer_info");if(null!=c&&(this._glRenderer=this._gl.getParameter(c.UNMASKED_RENDERER_WEBGL),this._glVendor=this._gl.getParameter(c.UNMASKED_VENDOR_WEBGL)),this._glVendor||(this._glVendor="Unknown vendor"),this._glRenderer||(this._glRenderer="Unknown renderer"),this._gl.HALF_FLOAT_OES=36193,this._gl.RGBA16F=34842,this._gl.RGBA32F=34836,this._gl.DEPTH24_STENCIL8=35056,this._caps.standardDerivatives=this._webGLVersion>1||null!==this._gl.getExtension("OES_standard_derivatives"),this._caps.astc=this._gl.getExtension("WEBGL_compressed_texture_astc")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_astc"),this._caps.s3tc=this._gl.getExtension("WEBGL_compressed_texture_s3tc")||this._gl.getExtension("WEBKIT_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._gl.getExtension("WEBKIT_WEBGL_compressed_texture_etc1"),this._caps.etc2=this._gl.getExtension("WEBGL_compressed_texture_etc")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_etc")||this._gl.getExtension("WEBGL_compressed_texture_es3_0"),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.uintIndices=this._webGLVersion>1||null!==this._gl.getExtension("OES_element_index_uint"),this._caps.fragmentDepthSupported=this._webGLVersion>1||null!==this._gl.getExtension("EXT_frag_depth"),this._caps.highPrecisionShaderSupported=!0,this._caps.drawBuffersExtension=this._webGLVersion>1||this._gl.getExtension("WEBGL_draw_buffers"),this._caps.colorBufferFloat=this._webGLVersion>1&&this._gl.getExtension("EXT_color_buffer_float"),this._caps.textureFloat=this._webGLVersion>1||this._gl.getExtension("OES_texture_float"),this._caps.textureFloatLinearFiltering=this._caps.textureFloat&&this._gl.getExtension("OES_texture_float_linear"),this._caps.textureFloatRender=this._caps.textureFloat&&this._canRenderToFloatFramebuffer(),this._caps.textureHalfFloat=this._webGLVersion>1||this._gl.getExtension("OES_texture_half_float"),this._caps.textureHalfFloatLinearFiltering=this._webGLVersion>1||this._caps.textureHalfFloat&&this._gl.getExtension("OES_texture_half_float_linear"),this._webGLVersion>1&&(this._gl.HALF_FLOAT_OES=5131),this._caps.textureHalfFloatRender=this._caps.textureHalfFloat&&this._canRenderToHalfFloatFramebuffer(),this._caps.textureLOD=this._webGLVersion>1||this._gl.getExtension("EXT_shader_texture_lod"),this._webGLVersion>1)this._caps.vertexArrayObject=!0;else{var f=this._gl.getExtension("OES_vertex_array_object");null!=f?(this._caps.vertexArrayObject=!0,this._gl.createVertexArray=f.createVertexArrayOES.bind(f),this._gl.bindVertexArray=f.bindVertexArrayOES.bind(f),this._gl.deleteVertexArray=f.deleteVertexArrayOES.bind(f)):this._caps.vertexArrayObject=!1}if(this._webGLVersion>1)this._caps.instancedArrays=!0;else{var d=this._gl.getExtension("ANGLE_instanced_arrays");null!=d?(this._caps.instancedArrays=!0,this._gl.drawArraysInstanced=d.drawArraysInstancedANGLE.bind(d),this._gl.drawElementsInstanced=d.drawElementsInstancedANGLE.bind(d),this._gl.vertexAttribDivisor=d.vertexAttribDivisorANGLE.bind(d)):this._caps.instancedArrays=!1}if(this._caps.astc&&this.texturesSupported.push("-astc.ktx"),this._caps.s3tc&&this.texturesSupported.push("-dxt.ktx"),this._caps.pvrtc&&this.texturesSupported.push("-pvrtc.ktx"),this._caps.etc2&&this.texturesSupported.push("-etc2.ktx"),this._caps.etc1&&this.texturesSupported.push("-etc1.ktx"),this._gl.getShaderPrecisionFormat){var p=this._gl.getShaderPrecisionFormat(this._gl.FRAGMENT_SHADER,this._gl.HIGH_FLOAT);this._caps.highPrecisionShaderSupported=0!==p.precision}this.setDepthBuffer(!0),this.setDepthFunctionToLessOrEqual(),this.setDepthWrite(!0),l&&(this._onFullscreenChange=function(){void 0!==document.fullscreen?u.isFullscreen=document.fullscreen:void 0!==document.mozFullScreen?u.isFullscreen=document.mozFullScreen:void 0!==document.webkitIsFullScreen?u.isFullscreen=document.webkitIsFullScreen:void 0!==document.msIsFullScreen&&(u.isFullscreen=document.msIsFullScreen),u.isFullscreen&&u._pointerLockRequested&&(l.requestPointerLock=l.requestPointerLock||l.msRequestPointerLock||l.mozRequestPointerLock||l.webkitRequestPointerLock,l.requestPointerLock&&l.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(){u.isPointerLock=document.mozPointerLockElement===l||document.webkitPointerLockElement===l||document.msPointerLockElement===l||document.pointerLockElement===l},document.addEventListener("pointerlockchange",this._onPointerLockChange,!1),document.addEventListener("mspointerlockchange",this._onPointerLockChange,!1),document.addEventListener("mozpointerlockchange",this._onPointerLockChange,!1),document.addEventListener("webkitpointerlockchange",this._onPointerLockChange,!1)),n.audioEngine&&e.AudioEngine&&!i.audioEngine&&(i.audioEngine=new e.AudioEngine);for(var g=0;g<this._caps.maxVertexAttribs;g++)this._currentBufferPointers[g]=new o;n.autoEnableWebVR&&this.initWebVR(),this._badOS=/iPad/i.test(navigator.userAgent)||/iPhone/i.test(navigator.userAgent),this._badDesktopOS=/^((?!chrome|android).)*safari/i.test(navigator.userAgent),e.Tools.Log("Babylon.js engine (v"+i.Version+") launched"),this.enableOfflineSupport=void 0!==e.Database}return Object.defineProperty(i,"LastCreatedEngine",{get:function(){return 0===i.Instances.length?null:i.Instances[i.Instances.length-1]},enumerable:!0,configurable:!0}),Object.defineProperty(i,"LastCreatedScene",{get:function(){var e=i.LastCreatedEngine;return e?0===e.scenes.length?null:e.scenes[e.scenes.length-1]:null},enumerable:!0,configurable:!0}),i.MarkAllMaterialsAsDirty=function(e,t){for(var r=0;r<i.Instances.length;r++)for(var n=i.Instances[r],o=0;o<n.scenes.length;o++)n.scenes[o].markAllMaterialsAsDirty(e,t)},Object.defineProperty(i,"NEVER",{get:function(){return i._NEVER},enumerable:!0,configurable:!0}),Object.defineProperty(i,"ALWAYS",{get:function(){return i._ALWAYS},enumerable:!0,configurable:!0}),Object.defineProperty(i,"LESS",{get:function(){return i._LESS},enumerable:!0,configurable:!0}),Object.defineProperty(i,"EQUAL",{get:function(){return i._EQUAL},enumerable:!0,configurable:!0}),Object.defineProperty(i,"LEQUAL",{get:function(){return i._LEQUAL},enumerable:!0,configurable:!0}),Object.defineProperty(i,"GREATER",{get:function(){return i._GREATER},enumerable:!0,configurable:!0}),Object.defineProperty(i,"GEQUAL",{get:function(){return i._GEQUAL},enumerable:!0,configurable:!0}),Object.defineProperty(i,"NOTEQUAL",{get:function(){return i._NOTEQUAL},enumerable:!0,configurable:!0}),Object.defineProperty(i,"KEEP",{get:function(){return i._KEEP},enumerable:!0,configurable:!0}),Object.defineProperty(i,"REPLACE",{get:function(){return i._REPLACE},enumerable:!0,configurable:!0}),Object.defineProperty(i,"INCR",{get:function(){return i._INCR},enumerable:!0,configurable:!0}),Object.defineProperty(i,"DECR",{get:function(){return i._DECR},enumerable:!0,configurable:!0}),Object.defineProperty(i,"INVERT",{get:function(){return i._INVERT},enumerable:!0,configurable:!0}),Object.defineProperty(i,"INCR_WRAP",{get:function(){return i._INCR_WRAP},enumerable:!0,configurable:!0}),Object.defineProperty(i,"DECR_WRAP",{get:function(){return i._DECR_WRAP},enumerable:!0,configurable:!0}),Object.defineProperty(i,"ALPHA_DISABLE",{get:function(){return i._ALPHA_DISABLE},enumerable:!0,configurable:!0}),Object.defineProperty(i,"ALPHA_ONEONE",{get:function(){return i._ALPHA_ONEONE},enumerable:!0,configurable:!0}),Object.defineProperty(i,"ALPHA_ADD",{get:function(){return i._ALPHA_ADD},enumerable:!0,configurable:!0}),Object.defineProperty(i,"ALPHA_COMBINE",{get:function(){return i._ALPHA_COMBINE},enumerable:!0,configurable:!0}),Object.defineProperty(i,"ALPHA_SUBTRACT",{get:function(){return i._ALPHA_SUBTRACT},enumerable:!0,configurable:!0}),Object.defineProperty(i,"ALPHA_MULTIPLY",{get:function(){return i._ALPHA_MULTIPLY},enumerable:!0,configurable:!0}),Object.defineProperty(i,"ALPHA_MAXIMIZED",{get:function(){return i._ALPHA_MAXIMIZED},enumerable:!0,configurable:!0}),Object.defineProperty(i,"ALPHA_PREMULTIPLIED",{get:function(){return i._ALPHA_PREMULTIPLIED},enumerable:!0,configurable:!0}),Object.defineProperty(i,"ALPHA_PREMULTIPLIED_PORTERDUFF",{get:function(){return i._ALPHA_PREMULTIPLIED_PORTERDUFF},enumerable:!0,configurable:!0}),Object.defineProperty(i,"ALPHA_INTERPOLATE",{get:function(){return i._ALPHA_INTERPOLATE},enumerable:!0,configurable:!0}),Object.defineProperty(i,"ALPHA_SCREENMODE",{get:function(){return i._ALPHA_SCREENMODE},enumerable:!0,configurable:!0}),Object.defineProperty(i,"DELAYLOADSTATE_NONE",{get:function(){return i._DELAYLOADSTATE_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(i,"DELAYLOADSTATE_LOADED",{get:function(){return i._DELAYLOADSTATE_LOADED},enumerable:!0,configurable:!0}),Object.defineProperty(i,"DELAYLOADSTATE_LOADING",{get:function(){return i._DELAYLOADSTATE_LOADING},enumerable:!0,configurable:!0}),Object.defineProperty(i,"DELAYLOADSTATE_NOTLOADED",{get:function(){return i._DELAYLOADSTATE_NOTLOADED},enumerable:!0,configurable:!0}),Object.defineProperty(i,"TEXTUREFORMAT_ALPHA",{get:function(){return i._TEXTUREFORMAT_ALPHA},enumerable:!0,configurable:!0}),Object.defineProperty(i,"TEXTUREFORMAT_LUMINANCE",{get:function(){return i._TEXTUREFORMAT_LUMINANCE},enumerable:!0,configurable:!0}),Object.defineProperty(i,"TEXTUREFORMAT_LUMINANCE_ALPHA",{get:function(){return i._TEXTUREFORMAT_LUMINANCE_ALPHA},enumerable:!0,configurable:!0}),Object.defineProperty(i,"TEXTUREFORMAT_RGB",{get:function(){return i._TEXTUREFORMAT_RGB},enumerable:!0,configurable:!0}),Object.defineProperty(i,"TEXTUREFORMAT_RGBA",{get:function(){return i._TEXTUREFORMAT_RGBA},enumerable:!0,configurable:!0}),Object.defineProperty(i,"TEXTURETYPE_UNSIGNED_INT",{get:function(){return i._TEXTURETYPE_UNSIGNED_INT},enumerable:!0,configurable:!0}),Object.defineProperty(i,"TEXTURETYPE_FLOAT",{get:function(){return i._TEXTURETYPE_FLOAT},enumerable:!0,configurable:!0}),Object.defineProperty(i,"TEXTURETYPE_HALF_FLOAT",{get:function(){return i._TEXTURETYPE_HALF_FLOAT},enumerable:!0,configurable:!0}),Object.defineProperty(i,"SCALEMODE_FLOOR",{get:function(){return i._SCALEMODE_FLOOR},enumerable:!0,configurable:!0}),Object.defineProperty(i,"SCALEMODE_NEAREST",{get:function(){return i._SCALEMODE_NEAREST},enumerable:!0,configurable:!0}),Object.defineProperty(i,"SCALEMODE_CEILING",{get:function(){return i._SCALEMODE_CEILING},enumerable:!0,configurable:!0}),Object.defineProperty(i,"Version",{get:function(){return"3.1-alpha"},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"needPOTTextures",{get:function(){return this._webGLVersion<2||this.forcePOTTextures},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"badOS",{get:function(){return this._badOS},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"badDesktopOS",{get:function(){return this._badDesktopOS},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"performanceMonitor",{get:function(){return this._performanceMonitor},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"texturesSupported",{get:function(){return this._texturesSupported},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"textureFormatInUse",{get:function(){return this._textureFormatInUse},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"emptyTexture",{get:function(){return this._emptyTexture||(this._emptyTexture=this.createRawTexture(new Uint8Array(4),1,1,e.Engine.TEXTUREFORMAT_RGBA,!1,!1,e.Texture.NEAREST_SAMPLINGMODE)),this._emptyTexture},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"emptyCubeTexture",{get:function(){if(!this._emptyCubeTexture){var t=new Uint8Array(4),r=[t,t,t,t,t,t];this._emptyCubeTexture=this.createRawCubeTexture(r,1,e.Engine.TEXTUREFORMAT_RGBA,e.Engine.TEXTURETYPE_UNSIGNED_INT,!1,!1,e.Texture.NEAREST_SAMPLINGMODE)}return this._emptyCubeTexture},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"webGLVersion",{get:function(){return this._webGLVersion},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"isStencilEnable",{get:function(){return this._isStencilEnable},enumerable:!0,configurable:!0}),i.prototype._prepareWorkingCanvas=function(){this._workingCanvas||(this._workingCanvas=document.createElement("canvas"),this._workingContext=this._workingCanvas.getContext("2d"))},i.prototype.resetTextureCache=function(){for(var e=0;e<this._maxTextureChannels;e++)this._activeTexturesCache[e]=null},i.prototype.isDeterministicLockStep=function(){return this._deterministicLockstep},i.prototype.getLockstepMaxSteps=function(){return this._lockstepMaxSteps},i.prototype.getGlInfo=function(){return{vendor:this._glVendor,renderer:this._glRenderer,version:this._glVersion}},i.prototype.getAspectRatio=function(e,t){void 0===t&&(t=!1);var r=e.viewport;return this.getRenderWidth(t)*r.width/(this.getRenderHeight(t)*r.height)},i.prototype.getRenderWidth=function(e){return void 0===e&&(e=!1),!e&&this._currentRenderTarget?this._currentRenderTarget._width:this._gl.drawingBufferWidth},i.prototype.getRenderHeight=function(e){return void 0===e&&(e=!1),!e&&this._currentRenderTarget?this._currentRenderTarget._height:this._gl.drawingBufferHeight},i.prototype.getRenderingCanvas=function(){return this._renderingCanvas},i.prototype.getRenderingCanvasClientRect=function(){return this._renderingCanvas.getBoundingClientRect()},i.prototype.setHardwareScalingLevel=function(e){this._hardwareScalingLevel=e,this.resize()},i.prototype.getHardwareScalingLevel=function(){return this._hardwareScalingLevel},i.prototype.getLoadedTexturesCache=function(){return this._loadedTexturesCache},i.prototype.getCaps=function(){return this._caps},Object.defineProperty(i.prototype,"drawCalls",{get:function(){return this._drawCalls.current},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"drawCallsPerfCounter",{get:function(){return this._drawCalls},enumerable:!0,configurable:!0}),i.prototype.getDepthFunction=function(){return this._depthCullingState.depthFunc},i.prototype.setDepthFunction=function(e){this._depthCullingState.depthFunc=e},i.prototype.setDepthFunctionToGreater=function(){this._depthCullingState.depthFunc=this._gl.GREATER},i.prototype.setDepthFunctionToGreaterOrEqual=function(){this._depthCullingState.depthFunc=this._gl.GEQUAL},i.prototype.setDepthFunctionToLess=function(){this._depthCullingState.depthFunc=this._gl.LESS},i.prototype.setDepthFunctionToLessOrEqual=function(){this._depthCullingState.depthFunc=this._gl.LEQUAL},i.prototype.getStencilBuffer=function(){return this._stencilState.stencilTest},i.prototype.setStencilBuffer=function(e){this._stencilState.stencilTest=e},i.prototype.getStencilMask=function(){return this._stencilState.stencilMask},i.prototype.setStencilMask=function(e){this._stencilState.stencilMask=e},i.prototype.getStencilFunction=function(){return this._stencilState.stencilFunc},i.prototype.getStencilFunctionReference=function(){return this._stencilState.stencilFuncRef},i.prototype.getStencilFunctionMask=function(){return this._stencilState.stencilFuncMask},i.prototype.setStencilFunction=function(e){this._stencilState.stencilFunc=e},i.prototype.setStencilFunctionReference=function(e){this._stencilState.stencilFuncRef=e},i.prototype.setStencilFunctionMask=function(e){this._stencilState.stencilFuncMask=e},i.prototype.getStencilOperationFail=function(){return this._stencilState.stencilOpStencilFail},i.prototype.getStencilOperationDepthFail=function(){return this._stencilState.stencilOpDepthFail},i.prototype.getStencilOperationPass=function(){return this._stencilState.stencilOpStencilDepthPass},i.prototype.setStencilOperationFail=function(e){this._stencilState.stencilOpStencilFail=e},i.prototype.setStencilOperationDepthFail=function(e){this._stencilState.stencilOpDepthFail=e},i.prototype.setStencilOperationPass=function(e){this._stencilState.stencilOpStencilDepthPass=e},i.prototype.setDitheringState=function(e){e?this._gl.enable(this._gl.DITHER):this._gl.disable(this._gl.DITHER)},i.prototype.stopRenderLoop=function(e){if(!e)return void(this._activeRenderLoops=[]);var t=this._activeRenderLoops.indexOf(e);t>=0&&this._activeRenderLoops.splice(t,1)},i.prototype._renderLoop=function(){var t=!0;if(!this.renderEvenInBackground&&this._windowIsBackground&&(t=!1),t){this.beginFrame();for(var r=0;r<this._activeRenderLoops.length;r++){(0,this._activeRenderLoops[r])()}this.endFrame()}this._activeRenderLoops.length>0?e.Tools.QueueNewFrame(this._bindedRenderFunction,this._vrDisplayEnabled):this._renderingQueueLaunched=!1},i.prototype.runRenderLoop=function(t){-1===this._activeRenderLoops.indexOf(t)&&(this._activeRenderLoops.push(t),this._renderingQueueLaunched||(this._renderingQueueLaunched=!0,this._bindedRenderFunction=this._renderLoop.bind(this),e.Tools.QueueNewFrame(this._bindedRenderFunction)))},i.prototype.switchFullscreen=function(t){this.isFullscreen?e.Tools.ExitFullscreen():(this._pointerLockRequested=t,e.Tools.RequestFullscreen(this._renderingCanvas))},i.prototype.clear=function(e,t,r,i){void 0===i&&(i=!1),this.applyStates();var n=0;t&&e&&(this._gl.clearColor(e.r,e.g,e.b,void 0!==e.a?e.a:1),n|=this._gl.COLOR_BUFFER_BIT),r&&(this._gl.clearDepth(1),n|=this._gl.DEPTH_BUFFER_BIT),i&&(this._gl.clearStencil(0),n|=this._gl.STENCIL_BUFFER_BIT),this._gl.clear(n)},i.prototype.scissorClear=function(e,t,r,i,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,r,i),this.clear(n,!0,!0,!0),o.scissor(a[0],a[1],a[2],a[3]),!0===s?o.enable(o.SCISSOR_TEST):o.disable(o.SCISSOR_TEST)},i.prototype.setViewport=function(e,t,r){var i=t||this.getRenderWidth(),n=r||this.getRenderHeight(),o=e.x||0,s=e.y||0;this._cachedViewport=e,this._gl.viewport(o*i,s*n,i*e.width,n*e.height)},i.prototype.setDirectViewport=function(e,t,r,i){var n=this._cachedViewport;return this._cachedViewport=null,this._gl.viewport(e,t,r,i),n},i.prototype.beginFrame=function(){this._measureFps()},i.prototype.endFrame=function(){this._badOS&&this.flushFramebuffer(),this._vrDisplayEnabled&&this._vrDisplayEnabled.isPresenting&&this._vrDisplayEnabled.submitFrame()},i.prototype.resize=function(){if(!this._vrDisplayEnabled||!this._vrDisplayEnabled.isPresenting){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)}},i.prototype.setSize=function(e,t){if(this._renderingCanvas.width!==e||this._renderingCanvas.height!==t){this._renderingCanvas.width=e,this._renderingCanvas.height=t;for(var r=0;r<this.scenes.length;r++)for(var i=this.scenes[r],n=0;n<i.cameras.length;n++){var o=i.cameras[n];o._currentRenderId=0}this.onResizeObservable.hasObservers&&this.onResizeObservable.notifyObservers(this)}},i.prototype.isVRDevicePresent=function(e){this.getVRDevice(null,(function(t){e(null!==t)}))},i.prototype.getVRDevice=function(t,r){if(!this.vrDisplaysPromise)return void r(null);this.vrDisplaysPromise.then((function(i){if(i.length>0)if(t){var n=i.some((function(e){return e.displayName===t&&(r(e),!0)}));n||(e.Tools.Warn("Display "+t+" was not found. Using "+i[0].displayName),r(i[0]))}else r(i[0]);else e.Tools.Error("No WebVR devices found!"),r(null)}))},i.prototype.initWebVR=function(){this.vrDisplaysPromise||this._getVRDisplays()},i.prototype.enableVR=function(e){this._vrDisplayEnabled=e,this._vrDisplayEnabled.requestPresent([{source:this.getRenderingCanvas()}]).then(this._onVRFullScreenTriggered)},i.prototype.disableVR=function(){this._vrDisplayEnabled&&this._vrDisplayEnabled.exitPresent().then(this._onVRFullScreenTriggered)},i.prototype._getVRDisplays=function(){var e=this,t=function(t){t.length;return e._vrDisplays=t.filter((function(e){return t[0]instanceof VRDisplay})),e._vrDisplays};navigator.getVRDisplays&&(this.vrDisplaysPromise=navigator.getVRDisplays().then(t))},i.prototype.bindFramebuffer=function(e,t,r,i,n){this._currentRenderTarget&&this.unBindFramebuffer(this._currentRenderTarget),this._currentRenderTarget=e,this.bindUnboundFramebuffer(e._MSAAFramebuffer?e._MSAAFramebuffer:e._framebuffer);var o=this._gl;e.isCube&&o.framebufferTexture2D(o.FRAMEBUFFER,o.COLOR_ATTACHMENT0,o.TEXTURE_CUBE_MAP_POSITIVE_X+t,e,0),this._cachedViewport&&!n?this.setViewport(this._cachedViewport,r,i):o.viewport(0,0,r||e._width,i||e._height),this.wipeCaches()},i.prototype.bindUnboundFramebuffer=function(e){this._currentFramebuffer!==e&&(this._gl.bindFramebuffer(this._gl.FRAMEBUFFER,e),this._currentFramebuffer=e)},i.prototype.unBindFramebuffer=function(e,t,r){void 0===t&&(t=!1),this._currentRenderTarget=null;var i=this._gl;e._MSAAFramebuffer&&(i.bindFramebuffer(i.READ_FRAMEBUFFER,e._MSAAFramebuffer),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,e._framebuffer),i.blitFramebuffer(0,0,e._width,e._height,0,0,e._width,e._height,i.COLOR_BUFFER_BIT,i.NEAREST)),!e.generateMipMaps||t||e.isCube||(this._bindTextureDirectly(i.TEXTURE_2D,e),i.generateMipmap(i.TEXTURE_2D),this._bindTextureDirectly(i.TEXTURE_2D,null)),r&&(e._MSAAFramebuffer&&this.bindUnboundFramebuffer(e._framebuffer),r()),this.bindUnboundFramebuffer(null)},i.prototype.generateMipMapsForCubemap=function(e){if(e.generateMipMaps){var t=this._gl;this._bindTextureDirectly(t.TEXTURE_CUBE_MAP,e),t.generateMipmap(t.TEXTURE_CUBE_MAP),this._bindTextureDirectly(t.TEXTURE_CUBE_MAP,null)}},i.prototype.flushFramebuffer=function(){this._gl.flush()},i.prototype.restoreDefaultFramebuffer=function(){this._currentRenderTarget?this.unBindFramebuffer(this._currentRenderTarget):this.bindUnboundFramebuffer(null),this._cachedViewport&&this.setViewport(this._cachedViewport),this.wipeCaches()},i.prototype.createUniformBuffer=function(e){var t=this._gl.createBuffer();return this.bindUniformBuffer(t),e instanceof Float32Array?this._gl.bufferData(this._gl.UNIFORM_BUFFER,e,this._gl.STATIC_DRAW):this._gl.bufferData(this._gl.UNIFORM_BUFFER,new Float32Array(e),this._gl.STATIC_DRAW),this.bindUniformBuffer(null),t.references=1,t},i.prototype.createDynamicUniformBuffer=function(e){var t=this._gl.createBuffer();return this.bindUniformBuffer(t),e instanceof Float32Array?this._gl.bufferData(this._gl.UNIFORM_BUFFER,e,this._gl.DYNAMIC_DRAW):this._gl.bufferData(this._gl.UNIFORM_BUFFER,new Float32Array(e),this._gl.DYNAMIC_DRAW),this.bindUniformBuffer(null),t.references=1,t},i.prototype.updateUniformBuffer=function(e,t,r,i){this.bindUniformBuffer(e),void 0===r&&(r=0),void 0===i?t instanceof Float32Array?this._gl.bufferSubData(this._gl.UNIFORM_BUFFER,r,t):this._gl.bufferSubData(this._gl.UNIFORM_BUFFER,r,new Float32Array(t)):t instanceof Float32Array?this._gl.bufferSubData(this._gl.UNIFORM_BUFFER,0,t.subarray(r,r+i)):this._gl.bufferSubData(this._gl.UNIFORM_BUFFER,0,new Float32Array(t).subarray(r,r+i)),this.bindUniformBuffer(null)},i.prototype._resetVertexBufferBinding=function(){this.bindArrayBuffer(null),this._cachedVertexBuffers=null},i.prototype.createVertexBuffer=function(e){var t=this._gl.createBuffer();return this.bindArrayBuffer(t),e instanceof Float32Array?this._gl.bufferData(this._gl.ARRAY_BUFFER,e,this._gl.STATIC_DRAW):this._gl.bufferData(this._gl.ARRAY_BUFFER,new Float32Array(e),this._gl.STATIC_DRAW),this._resetVertexBufferBinding(),t.references=1,t},i.prototype.createDynamicVertexBuffer=function(e){var t=this._gl.createBuffer();return this.bindArrayBuffer(t),e instanceof Float32Array?this._gl.bufferData(this._gl.ARRAY_BUFFER,e,this._gl.DYNAMIC_DRAW):this._gl.bufferData(this._gl.ARRAY_BUFFER,new Float32Array(e),this._gl.DYNAMIC_DRAW),this._resetVertexBufferBinding(),t.references=1,t},i.prototype.updateDynamicVertexBuffer=function(e,t,r,i){this.bindArrayBuffer(e),void 0===r&&(r=0),void 0===i?t instanceof Float32Array?this._gl.bufferSubData(this._gl.ARRAY_BUFFER,r,t):this._gl.bufferSubData(this._gl.ARRAY_BUFFER,r,new Float32Array(t)):t instanceof Float32Array?this._gl.bufferSubData(this._gl.ARRAY_BUFFER,0,t.subarray(r,r+i)):this._gl.bufferSubData(this._gl.ARRAY_BUFFER,0,new Float32Array(t).subarray(r,r+i)),this._resetVertexBufferBinding()},i.prototype._resetIndexBufferBinding=function(){this.bindIndexBuffer(null),this._cachedIndexBuffer=null},i.prototype.createIndexBuffer=function(e){var t=this._gl.createBuffer()
- ;this.bindIndexBuffer(t);var r,i=!1;if(e instanceof Uint16Array)r=e;else if(this._caps.uintIndices)if(e instanceof Uint32Array)r=e,i=!0;else{for(var n=0;n<e.length;n++)if(e[n]>65535){i=!0;break}r=i?new Uint32Array(e):new Uint16Array(e)}else r=new Uint16Array(e);return this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER,r,this._gl.STATIC_DRAW),this._resetIndexBufferBinding(),t.references=1,t.is32Bits=i,t},i.prototype.bindArrayBuffer=function(e){this._vaoRecordInProgress||this._unbindVertexArrayObject(),this.bindBuffer(e,this._gl.ARRAY_BUFFER)},i.prototype.bindUniformBuffer=function(e){this._gl.bindBuffer(this._gl.UNIFORM_BUFFER,e)},i.prototype.bindUniformBufferBase=function(e,t){this._gl.bindBufferBase(this._gl.UNIFORM_BUFFER,t,e)},i.prototype.bindUniformBlock=function(e,t,r){var i=this._gl.getUniformBlockIndex(e,t);this._gl.uniformBlockBinding(e,i,r)},i.prototype.bindIndexBuffer=function(e){this._vaoRecordInProgress||this._unbindVertexArrayObject(),this.bindBuffer(e,this._gl.ELEMENT_ARRAY_BUFFER)},i.prototype.bindBuffer=function(e,t){(this._vaoRecordInProgress||this._currentBoundBuffer[t]!==e)&&(this._gl.bindBuffer(t,e),this._currentBoundBuffer[t]=e)},i.prototype.updateArrayBuffer=function(e){this._gl.bufferSubData(this._gl.ARRAY_BUFFER,0,e)},i.prototype.vertexAttribPointer=function(e,t,r,i,n,o,s){var a=this._currentBufferPointers[t],u=!1;a.active?(a.buffer!==e&&(a.buffer=e,u=!0),a.size!==r&&(a.size=r,u=!0),a.type!==i&&(a.type=i,u=!0),a.normalized!==n&&(a.normalized=n,u=!0),a.stride!==o&&(a.stride=o,u=!0),a.offset!==s&&(a.offset=s,u=!0)):(u=!0,a.active=!0,a.index=t,a.size=r,a.type=i,a.normalized=n,a.stride=o,a.offset=s,a.buffer=e),(u||this._vaoRecordInProgress)&&(this.bindArrayBuffer(e),this._gl.vertexAttribPointer(t,r,i,n,o,s))},i.prototype._bindIndexBufferWithCache=function(e){null!=e&&this._cachedIndexBuffer!==e&&(this._cachedIndexBuffer=e,this.bindIndexBuffer(e),this._uintIndicesCurrentlySet=e.is32Bits)},i.prototype._bindVertexBuffersAttributes=function(e,t){var r=t.getAttributesNames();this._vaoRecordInProgress||this._unbindVertexArrayObject(),this.unbindAllAttributes();for(var i=0;i<r.length;i++){var n=t.getAttributeLocation(i);if(n>=0){var o=e[r[i]];if(!o)continue;this._gl.enableVertexAttribArray(n),this._vaoRecordInProgress||(this._vertexAttribArraysEnabled[n]=!0);var s=o.getBuffer();this.vertexAttribPointer(s,n,o.getSize(),this._gl.FLOAT,!1,4*o.getStrideSize(),4*o.getOffset()),o.getIsInstanced()&&(this._gl.vertexAttribDivisor(n,o.getInstanceDivisor()),this._vaoRecordInProgress||(this._currentInstanceLocations.push(n),this._currentInstanceBuffers.push(s)))}}},i.prototype.recordVertexArrayObject=function(e,t,r){var i=this._gl.createVertexArray();return this._vaoRecordInProgress=!0,this._gl.bindVertexArray(i),this._mustWipeVertexAttributes=!0,this._bindVertexBuffersAttributes(e,r),this.bindIndexBuffer(t),this._vaoRecordInProgress=!1,this._gl.bindVertexArray(null),i},i.prototype.bindVertexArrayObject=function(e,t){this._cachedVertexArrayObject!==e&&(this._cachedVertexArrayObject=e,this._gl.bindVertexArray(e),this._cachedVertexBuffers=null,this._cachedIndexBuffer=null,this._uintIndicesCurrentlySet=null!=t&&t.is32Bits,this._mustWipeVertexAttributes=!0)},i.prototype.bindBuffersDirectly=function(e,t,r,i,n){if(this._cachedVertexBuffers!==e||this._cachedEffectForVertexBuffers!==n){this._cachedVertexBuffers=e,this._cachedEffectForVertexBuffers=n;var o=n.getAttributesCount();this._unbindVertexArrayObject(),this.unbindAllAttributes();for(var s=0,a=0;a<o;a++)if(a<r.length){var u=n.getAttributeLocation(a);u>=0&&(this._gl.enableVertexAttribArray(u),this._vertexAttribArraysEnabled[u]=!0,this.vertexAttribPointer(e,u,r[a],this._gl.FLOAT,!1,i,s)),s+=4*r[a]}}this._bindIndexBufferWithCache(t)},i.prototype._unbindVertexArrayObject=function(){this._cachedVertexArrayObject&&(this._cachedVertexArrayObject=null,this._gl.bindVertexArray(null))},i.prototype.bindBuffers=function(e,t,r){this._cachedVertexBuffers===e&&this._cachedEffectForVertexBuffers===r||(this._cachedVertexBuffers=e,this._cachedEffectForVertexBuffers=r,this._bindVertexBuffersAttributes(e,r)),this._bindIndexBufferWithCache(t)},i.prototype.unbindInstanceAttributes=function(){for(var e,t=0,r=this._currentInstanceLocations.length;t<r;t++){var i=this._currentInstanceBuffers[t];e!=i&&i.references&&(e=i,this.bindArrayBuffer(i));var n=this._currentInstanceLocations[t];this._gl.vertexAttribDivisor(n,0)}this._currentInstanceBuffers.length=0,this._currentInstanceLocations.length=0},i.prototype.releaseVertexArrayObject=function(e){this._gl.deleteVertexArray(e)},i.prototype._releaseBuffer=function(e){return 0===--e.references&&(this._gl.deleteBuffer(e),!0)},i.prototype.createInstancesBuffer=function(e){var t=this._gl.createBuffer();return t.capacity=e,this.bindArrayBuffer(t),this._gl.bufferData(this._gl.ARRAY_BUFFER,e,this._gl.DYNAMIC_DRAW),t},i.prototype.deleteInstancesBuffer=function(e){this._gl.deleteBuffer(e)},i.prototype.updateAndBindInstancesBuffer=function(e,t,r){if(this.bindArrayBuffer(e),t&&this._gl.bufferSubData(this._gl.ARRAY_BUFFER,0,t),void 0!==r[0].index){for(var i=0,n=0;n<r.length;n++){var o=r[n];i+=4*o.attributeSize}for(var n=0;n<r.length;n++){var o=r[n];this._vertexAttribArraysEnabled[o.index]||(this._gl.enableVertexAttribArray(o.index),this._vertexAttribArraysEnabled[o.index]=!0),this.vertexAttribPointer(e,o.index,o.attributeSize,o.attribyteType||this._gl.FLOAT,o.normalized||!1,i,o.offset),this._gl.vertexAttribDivisor(o.index,1),this._currentInstanceLocations.push(o.index),this._currentInstanceBuffers.push(e)}}else for(var s=0;s<4;s++){var a=r[s];this._vertexAttribArraysEnabled[a]||(this._gl.enableVertexAttribArray(a),this._vertexAttribArraysEnabled[a]=!0),this.vertexAttribPointer(e,a,4,this._gl.FLOAT,!1,64,16*s),this._gl.vertexAttribDivisor(a,1),this._currentInstanceLocations.push(a),this._currentInstanceBuffers.push(e)}},i.prototype.applyStates=function(){this._depthCullingState.apply(this._gl),this._stencilState.apply(this._gl),this._alphaState.apply(this._gl)},i.prototype.draw=function(e,t,r,i){this.applyStates(),this._drawCalls.addCount(1,!1);var n=this._uintIndicesCurrentlySet?this._gl.UNSIGNED_INT:this._gl.UNSIGNED_SHORT,o=this._uintIndicesCurrentlySet?4:2;if(i)return void this._gl.drawElementsInstanced(e?this._gl.TRIANGLES:this._gl.LINES,r,n,t*o,i);this._gl.drawElements(e?this._gl.TRIANGLES:this._gl.LINES,r,n,t*o)},i.prototype.drawPointClouds=function(e,t,r){if(this.applyStates(),this._drawCalls.addCount(1,!1),r)return void this._gl.drawArraysInstanced(this._gl.POINTS,e,t,r);this._gl.drawArrays(this._gl.POINTS,e,t)},i.prototype.drawUnIndexed=function(e,t,r,i){if(this.applyStates(),this._drawCalls.addCount(1,!1),i)return void this._gl.drawArraysInstanced(e?this._gl.TRIANGLES:this._gl.LINES,t,r,i);this._gl.drawArrays(e?this._gl.TRIANGLES:this._gl.LINES,t,r)},i.prototype._releaseEffect=function(e){this._compiledEffects[e._key]&&(delete this._compiledEffects[e._key],e.getProgram()&&this._gl.deleteProgram(e.getProgram()))},i.prototype.createEffect=function(t,r,i,n,o,s,a,u,l){var h=t.vertexElement||t.vertex||t,c=t.fragmentElement||t.fragment||t,f=h+"+"+c+"@"+(o||r.defines);if(this._compiledEffects[f]){var d=this._compiledEffects[f];return a&&d.isReady()&&a(d),d}var p=new e.Effect(t,r,i,n,this,o,s,a,u,l);return p._key=f,this._compiledEffects[f]=p,p},i.prototype.createEffectForParticles=function(e,t,r,i,n,o,s){return void 0===t&&(t=[]),void 0===r&&(r=[]),void 0===i&&(i=""),this.createEffect({vertex:"particles",fragmentElement:e},["position","color","options"],["view","projection"].concat(t),["diffuseSampler"].concat(r),i,n,o,s)},i.prototype.createShaderProgram=function(e,r,i,n){n=n||this._gl;var o=this._webGLVersion>1?"#version 300 es\n":"",s=t(n,e,"vertex",i,o),a=t(n,r,"fragment",i,o),u=n.createProgram();if(n.attachShader(u,s),n.attachShader(u,a),n.linkProgram(u),!n.getProgramParameter(u,n.LINK_STATUS)){n.validateProgram(u);var l=n.getProgramInfoLog(u);if(l)throw new Error(l)}return n.deleteShader(s),n.deleteShader(a),u},i.prototype.getUniforms=function(e,t){for(var r=[],i=0;i<t.length;i++)r.push(this._gl.getUniformLocation(e,t[i]));return r},i.prototype.getAttributes=function(e,t){for(var r=[],i=0;i<t.length;i++)try{r.push(this._gl.getAttribLocation(e,t[i]))}catch(e){r.push(-1)}return r},i.prototype.enableEffect=function(e){this.setProgram(e.getProgram()),this._currentEffect=e,e.onBind&&e.onBind(e),e.onBindObservable.notifyObservers(e)},i.prototype.setIntArray=function(e,t){e&&this._gl.uniform1iv(e,t)},i.prototype.setIntArray2=function(e,t){e&&t.length%2==0&&this._gl.uniform2iv(e,t)},i.prototype.setIntArray3=function(e,t){e&&t.length%3==0&&this._gl.uniform3iv(e,t)},i.prototype.setIntArray4=function(e,t){e&&t.length%4==0&&this._gl.uniform4iv(e,t)},i.prototype.setFloatArray=function(e,t){e&&this._gl.uniform1fv(e,t)},i.prototype.setFloatArray2=function(e,t){e&&t.length%2==0&&this._gl.uniform2fv(e,t)},i.prototype.setFloatArray3=function(e,t){e&&t.length%3==0&&this._gl.uniform3fv(e,t)},i.prototype.setFloatArray4=function(e,t){e&&t.length%4==0&&this._gl.uniform4fv(e,t)},i.prototype.setArray=function(e,t){e&&this._gl.uniform1fv(e,t)},i.prototype.setArray2=function(e,t){e&&t.length%2==0&&this._gl.uniform2fv(e,t)},i.prototype.setArray3=function(e,t){e&&t.length%3==0&&this._gl.uniform3fv(e,t)},i.prototype.setArray4=function(e,t){e&&t.length%4==0&&this._gl.uniform4fv(e,t)},i.prototype.setMatrices=function(e,t){e&&this._gl.uniformMatrix4fv(e,!1,t)},i.prototype.setMatrix=function(e,t){e&&this._gl.uniformMatrix4fv(e,!1,t.toArray())},i.prototype.setMatrix3x3=function(e,t){e&&this._gl.uniformMatrix3fv(e,!1,t)},i.prototype.setMatrix2x2=function(e,t){e&&this._gl.uniformMatrix2fv(e,!1,t)},i.prototype.setFloat=function(e,t){e&&this._gl.uniform1f(e,t)},i.prototype.setFloat2=function(e,t,r){e&&this._gl.uniform2f(e,t,r)},i.prototype.setFloat3=function(e,t,r,i){e&&this._gl.uniform3f(e,t,r,i)},i.prototype.setBool=function(e,t){e&&this._gl.uniform1i(e,t)},i.prototype.setFloat4=function(e,t,r,i,n){e&&this._gl.uniform4f(e,t,r,i,n)},i.prototype.setColor3=function(e,t){e&&this._gl.uniform3f(e,t.r,t.g,t.b)},i.prototype.setColor4=function(e,t,r){e&&this._gl.uniform4f(e,t.r,t.g,t.b,r)},i.prototype.setState=function(e,t,r,i){void 0===t&&(t=0),void 0===i&&(i=!1);var n=i?this._gl.FRONT:this._gl.BACK,o=i?this._gl.BACK:this._gl.FRONT,s=this.cullBackFaces?n:o;(this._depthCullingState.cull!==e||r||this._depthCullingState.cullFace!==s)&&(e?(this._depthCullingState.cullFace=s,this._depthCullingState.cull=!0):this._depthCullingState.cull=!1),this.setZOffset(t)},i.prototype.setZOffset=function(e){this._depthCullingState.zOffset=e},i.prototype.getZOffset=function(){return this._depthCullingState.zOffset},i.prototype.setDepthBuffer=function(e){this._depthCullingState.depthTest=e},i.prototype.getDepthWrite=function(){return this._depthCullingState.depthMask},i.prototype.setDepthWrite=function(e){this._depthCullingState.depthMask=e},i.prototype.setColorWrite=function(e){this._gl.colorMask(e,e,e,e)},i.prototype.setAlphaConstants=function(e,t,r,i){this._alphaState.setAlphaBlendConstants(e,t,r,i)},i.prototype.setAlphaMode=function(e,t){if(void 0===t&&(t=!1),this._alphaMode!==e){switch(e){case i.ALPHA_DISABLE:this._alphaState.alphaBlend=!1;break;case i.ALPHA_PREMULTIPLIED:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE,this._gl.ONE_MINUS_SRC_ALPHA,this._gl.ONE,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case i.ALPHA_PREMULTIPLIED_PORTERDUFF:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE,this._gl.ONE_MINUS_SRC_ALPHA,this._gl.ONE,this._gl.ONE_MINUS_SRC_ALPHA),this._alphaState.alphaBlend=!0;break;case i.ALPHA_COMBINE:this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA,this._gl.ONE_MINUS_SRC_ALPHA,this._gl.ONE,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case i.ALPHA_ONEONE:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE,this._gl.ONE,this._gl.ZERO,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case i.ALPHA_ADD:this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA,this._gl.ONE,this._gl.ZERO,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case i.ALPHA_SUBTRACT:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ZERO,this._gl.ONE_MINUS_SRC_COLOR,this._gl.ONE,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case i.ALPHA_MULTIPLY:this._alphaState.setAlphaBlendFunctionParameters(this._gl.DST_COLOR,this._gl.ZERO,this._gl.ONE,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case i.ALPHA_MAXIMIZED:this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA,this._gl.ONE_MINUS_SRC_COLOR,this._gl.ONE,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case i.ALPHA_INTERPOLATE:this._alphaState.setAlphaBlendFunctionParameters(this._gl.CONSTANT_COLOR,this._gl.ONE_MINUS_CONSTANT_COLOR,this._gl.CONSTANT_ALPHA,this._gl.ONE_MINUS_CONSTANT_ALPHA),this._alphaState.alphaBlend=!0;break;case i.ALPHA_SCREENMODE:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE,this._gl.ONE_MINUS_SRC_COLOR,this._gl.ONE,this._gl.ONE_MINUS_SRC_ALPHA),this._alphaState.alphaBlend=!0}t||this.setDepthWrite(e===i.ALPHA_DISABLE),this._alphaMode=e}},i.prototype.getAlphaMode=function(){return this._alphaMode},i.prototype.setAlphaTesting=function(e){this._alphaTest=e},i.prototype.getAlphaTesting=function(){return!!this._alphaTest},i.prototype.wipeCaches=function(e){this.preventCacheWipeBetweenFrames||(this.resetTextureCache(),this._currentEffect=null,e&&(this._currentProgram=null,this._stencilState.reset(),this._depthCullingState.reset(),this.setDepthFunctionToLessOrEqual(),this._alphaState.reset()),this._cachedVertexBuffers=null,this._cachedIndexBuffer=null,this._cachedEffectForVertexBuffers=null,this._unbindVertexArrayObject(),this.bindIndexBuffer(null),this.bindArrayBuffer(null))},i.prototype.setTextureFormatToUse=function(e){for(var t=0,r=this.texturesSupported.length;t<r;t++)for(var i=0,n=e.length;i<n;i++)if(this._texturesSupported[t]===e[i].toLowerCase())return this._textureFormatInUse=this._texturesSupported[t];return this._textureFormatInUse=null},i.prototype.createTexture=function(t,r,i,n,o,s,a,u,l,h){var c=this;void 0===o&&(o=e.Texture.TRILINEAR_SAMPLINGMODE),void 0===s&&(s=null),void 0===a&&(a=null),void 0===u&&(u=null);var f=l||this._gl.createTexture(),d=String(t),p="data:"===d.substr(0,5),g=p&&-1!==d.indexOf("base64"),_=d.lastIndexOf("."),m=_>0?d.substring(_).toLowerCase():"",v=this.getCaps().s3tc&&".dds"===m,y=".tga"===m,A=!1;!this._textureFormatInUse||g||l||(d=d.substring(0,_)+this._textureFormatInUse,A=!0),n._addPendingData(f),f.url=d,f.generateMipMaps=!r,f.references=1,f.samplingMode=o,f.onLoadedCallbacks=[],s&&f.onLoadedCallbacks.push(s),l||this._loadedTexturesCache.push(f);var T,E=function(){n._removePendingData(f),A?c.createTexture(t,r,i,n,o,null,a,u,f):a&&a()};if(A||y||v)A?T=function(t){var s=new e.Internals.KhronosTextureContainer(t,1);c._prepareWebGLTexture(f,n,s.pixelWidth,s.pixelHeight,i,!1,!0,(function(){return s.uploadLevels(c._gl,!r),!1}),o)}:y?T=function(t){var s=new Uint8Array(t),a=e.Internals.TGATools.GetTGAHeader(s);c._prepareWebGLTexture(f,n,a.width,a.height,i,r,!1,(function(){return e.Internals.TGATools.UploadContent(c._gl,s),!1}),o)}:v&&(T=function(t){var s=e.Internals.DDSTools.GetDDSInfo(t),a=(s.isRGB||s.isLuminance||s.mipmapCount>1)&&!r&&s.width>>s.mipmapCount-1==1;c._prepareWebGLTexture(f,n,s.width,s.height,i,!a,s.isFourCC,(function(){return e.Internals.DDSTools.UploadDDSLevels(c,t,s,a,1),!1}),o)}),u?T(u):e.Tools.LoadFile(d,(function(e){T(e)}),null,n.database,!0,E);else{var b=function(e){c._prepareWebGLTexture(f,n,e.width,e.height,i,r,!1,(function(t,r,i){var o=c._gl,s=e.width===t&&e.height===r,a=h?c._getInternalFormat(h):".jpg"===m?o.RGB:o.RGBA;if(s)return o.texImage2D(o.TEXTURE_2D,0,a,a,o.UNSIGNED_BYTE,e),!1;var u=o.createTexture();return c._bindTextureDirectly(o.TEXTURE_2D,u),o.texImage2D(o.TEXTURE_2D,0,a,a,o.UNSIGNED_BYTE,e),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,o.LINEAR),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,o.LINEAR),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE),c._rescaleTexture(u,f,n,a,(function(){c._releaseTexture(u),c._bindTextureDirectly(o.TEXTURE_2D,f),i()})),!0}),o)};!p||g?e.Tools.LoadImage(d,b,E,n.database):u instanceof Array||"string"==typeof u?e.Tools.LoadImage(u,b,E,n.database):b(u)}return f},i.prototype._rescaleTexture=function(t,r,n,o,s){var a=this,u=this.createRenderTargetTexture({width:r._width,height:r._height},{generateMipMaps:!1,type:i.TEXTURETYPE_UNSIGNED_INT,samplingMode:e.Texture.BILINEAR_SAMPLINGMODE,generateDepthBuffer:!1,generateStencilBuffer:!1});this._rescalePostProcess||(this._rescalePostProcess=new e.PassPostProcess("rescale",1,null,e.Texture.BILINEAR_SAMPLINGMODE,this,!1,i.TEXTURETYPE_UNSIGNED_INT)),this._rescalePostProcess.getEffect().executeWhenCompiled((function(){a._rescalePostProcess.onApply=function(e){e._bindTexture("textureSampler",t)},n.postProcessManager.directRender([a._rescalePostProcess],u),a._bindTextureDirectly(a._gl.TEXTURE_2D,r),a._gl.copyTexImage2D(a._gl.TEXTURE_2D,0,o,0,0,r._width,r._height,0),a.unBindFramebuffer(u),a._releaseTexture(u),s&&s()}))},i.prototype._getInternalFormat=function(e){var t=this._gl.RGBA;switch(e){case i.TEXTUREFORMAT_ALPHA:t=this._gl.ALPHA;break;case i.TEXTUREFORMAT_LUMINANCE:t=this._gl.LUMINANCE;break;case i.TEXTUREFORMAT_LUMINANCE_ALPHA:t=this._gl.LUMINANCE_ALPHA;break;case i.TEXTUREFORMAT_RGB:t=this._gl.RGB;break;case i.TEXTUREFORMAT_RGBA:t=this._gl.RGBA}return t},i.prototype.updateRawTexture=function(e,t,r,i,n){void 0===n&&(n=null);var o=this._getInternalFormat(r);this._bindTextureDirectly(this._gl.TEXTURE_2D,e),this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL,void 0===i?1:i?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},i.prototype.createRawTexture=function(e,t,i,n,o,s,a,u){void 0===u&&(u=null);var l=this._gl.createTexture();l._baseWidth=t,l._baseHeight=i,l._width=t,l._height=i,l.references=1,this.updateRawTexture(l,e,n,s,u),this._bindTextureDirectly(this._gl.TEXTURE_2D,l);var h=r(a,o,this._gl);return this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MAG_FILTER,h.mag),this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MIN_FILTER,h.min),o&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(this._gl.TEXTURE_2D,null),l.samplingMode=a,this._loadedTexturesCache.push(l),l},i.prototype.createDynamicTexture=function(t,r,i,n){var o=this._gl.createTexture();return o._baseWidth=t,o._baseHeight=r,i&&(t=this.needPOTTextures?e.Tools.GetExponentOfTwo(t,this._caps.maxTextureSize):t,r=this.needPOTTextures?e.Tools.GetExponentOfTwo(r,this._caps.maxTextureSize):r),this.resetTextureCache(),o._width=t,o._height=r,o.isReady=!1,o.generateMipMaps=i,o.references=1,o.samplingMode=n,this.updateTextureSamplingMode(n,o),this._loadedTexturesCache.push(o),o},i.prototype.updateTextureSamplingMode=function(e,t){var i=r(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)),t.samplingMode=e},i.prototype.updateDynamicTexture=function(e,t,r,i,n){void 0===i&&(i=!1),this._bindTextureDirectly(this._gl.TEXTURE_2D,e),this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL,r?1:0),i&&this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,1);var o=n?this._getInternalFormat(n):this._gl.RGBA;this._gl.texImage2D(this._gl.TEXTURE_2D,0,o,o,this._gl.UNSIGNED_BYTE,t),e.generateMipMaps&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(this._gl.TEXTURE_2D,null),i&&this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),this.resetTextureCache(),e.isReady=!0},i.prototype.updateVideoTexture=function(e,t,r){if(!e._isDisabled){this._bindTextureDirectly(this._gl.TEXTURE_2D,e),this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL,r?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(t){e._isDisabled=!0}}},i.prototype.createRenderTargetTexture=function(t,n){var o=!1,s=!0,a=!1,u=i.TEXTURETYPE_UNSIGNED_INT,l=e.Texture.TRILINEAR_SAMPLINGMODE;void 0!==n&&(o=void 0===n.generateMipMaps?n:n.generateMipMaps,s=void 0===n.generateDepthBuffer||n.generateDepthBuffer,a=s&&n.generateStencilBuffer,u=void 0===n.type?u:n.type,void 0!==n.samplingMode&&(l=n.samplingMode),u!==i.TEXTURETYPE_FLOAT||this._caps.textureFloatLinearFiltering?u!==i.TEXTURETYPE_HALF_FLOAT||this._caps.textureHalfFloatLinearFiltering||(l=e.Texture.NEAREST_SAMPLINGMODE):l=e.Texture.NEAREST_SAMPLINGMODE);var h=this._gl,c=h.createTexture();this._bindTextureDirectly(h.TEXTURE_2D,c);var f=t.width||t,d=t.height||t,p=r(l,o,h);u!==i.TEXTURETYPE_FLOAT||this._caps.textureFloat||(u=i.TEXTURETYPE_UNSIGNED_INT,e.Tools.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type")),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MAG_FILTER,p.mag),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MIN_FILTER,p.min),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_S,h.CLAMP_TO_EDGE),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_T,h.CLAMP_TO_EDGE),h.texImage2D(h.TEXTURE_2D,0,this._getRGBABufferInternalSizedFormat(u),f,d,0,h.RGBA,this._getWebGLTextureType(u),null);var g=h.createFramebuffer();return this.bindUnboundFramebuffer(g),h.framebufferTexture2D(h.FRAMEBUFFER,h.COLOR_ATTACHMENT0,h.TEXTURE_2D,c,0),c._depthStencilBuffer=this._setupFramebufferDepthAttachments(a,s,f,d),o&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(h.TEXTURE_2D,null),h.bindRenderbuffer(h.RENDERBUFFER,null),this.bindUnboundFramebuffer(null),c._framebuffer=g,c._baseWidth=f,c._baseHeight=d,c._width=f,c._height=d,c.isReady=!0,c.samples=1,c.generateMipMaps=o,c.references=1,c.samplingMode=l,c.type=u,c._generateDepthBuffer=s,c._generateStencilBuffer=a,this.resetTextureCache(),this._loadedTexturesCache.push(c),c},i.prototype.createMultipleRenderTarget=function(t,n){var o=!1,s=!0,a=!1,u=!1,l=1,h=i.TEXTURETYPE_UNSIGNED_INT,c=e.Texture.TRILINEAR_SAMPLINGMODE,f=[],d=[];void 0!==n&&(o=n.generateMipMaps,s=void 0===n.generateDepthBuffer||n.generateDepthBuffer,a=n.generateStencilBuffer,u=n.generateDepthTexture,l=n.textureCount||1,n.types&&(f=n.types),n.samplingModes&&(d=n.samplingModes));var p=this._gl,g=p.createFramebuffer();this.bindUnboundFramebuffer(g);for(var _=t.width||t,m=t.height||t,v=[],y=[],A=this._setupFramebufferDepthAttachments(a,s,_,m),T=0;T<l;T++){var E=d[T]||c,b=f[T]||h;b!==i.TEXTURETYPE_FLOAT||this._caps.textureFloatLinearFiltering?b!==i.TEXTURETYPE_HALF_FLOAT||this._caps.textureHalfFloatLinearFiltering||(E=e.Texture.NEAREST_SAMPLINGMODE):E=e.Texture.NEAREST_SAMPLINGMODE;var x=r(E,o,p);b!==i.TEXTURETYPE_FLOAT||this._caps.textureFloat||(b=i.TEXTURETYPE_UNSIGNED_INT,e.Tools.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type"));var M=p.createTexture(),P=p["COLOR_ATTACHMENT"+T];v.push(M),y.push(P),p.activeTexture(p["TEXTURE"+T]),p.bindTexture(p.TEXTURE_2D,M),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MAG_FILTER,x.mag),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MIN_FILTER,x.min),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_S,p.CLAMP_TO_EDGE),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_T,p.CLAMP_TO_EDGE),p.texImage2D(p.TEXTURE_2D,0,this._getRGBABufferInternalSizedFormat(b),_,m,0,p.RGBA,this._getWebGLTextureType(b),null),p.framebufferTexture2D(p.DRAW_FRAMEBUFFER,P,p.TEXTURE_2D,M,0),o&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(p.TEXTURE_2D,null),M._framebuffer=g,M._depthStencilBuffer=A,M._baseWidth=_,M._baseHeight=m,M._width=_,M._height=m,M.isReady=!0,M.samples=1,M.generateMipMaps=o,M.references=1,M.samplingMode=E,M.type=b,M._generateDepthBuffer=s,M._generateStencilBuffer=a,this._loadedTexturesCache.push(M)}if(u){var R=p.createTexture();p.activeTexture(p.TEXTURE0),p.bindTexture(p.TEXTURE_2D,R),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MAG_FILTER,p.NEAREST),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MIN_FILTER,p.NEAREST),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_S,p.CLAMP_TO_EDGE),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_WRAP_T,p.CLAMP_TO_EDGE),p.texImage2D(p.TEXTURE_2D,0,p.DEPTH_COMPONENT16,_,m,0,p.DEPTH_COMPONENT,p.UNSIGNED_SHORT,null),p.framebufferTexture2D(p.FRAMEBUFFER,p.DEPTH_ATTACHMENT,p.TEXTURE_2D,R,0),R._framebuffer=g,R._baseWidth=_,R._baseHeight=m,R._width=_,R._height=m,R.isReady=!0,R.samples=1,R.generateMipMaps=o,R.references=1,R.samplingMode=p.NEAREST,R._generateDepthBuffer=s,R._generateStencilBuffer=a,v.push(R),this._loadedTexturesCache.push(R)}return p.drawBuffers(y),p.bindRenderbuffer(p.RENDERBUFFER,null),this.bindUnboundFramebuffer(null),this.resetTextureCache(),v},i.prototype._setupFramebufferDepthAttachments=function(e,t,r,i,n){void 0===n&&(n=1);var o=null,s=this._gl;return e?(o=s.createRenderbuffer(),s.bindRenderbuffer(s.RENDERBUFFER,o),n>1?s.renderbufferStorageMultisample(s.RENDERBUFFER,n,s.DEPTH24_STENCIL8,r,i):s.renderbufferStorage(s.RENDERBUFFER,s.DEPTH_STENCIL,r,i),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.DEPTH_STENCIL_ATTACHMENT,s.RENDERBUFFER,o)):t&&(o=s.createRenderbuffer(),s.bindRenderbuffer(s.RENDERBUFFER,o),n>1?s.renderbufferStorageMultisample(s.RENDERBUFFER,n,s.DEPTH_COMPONENT16,r,i):s.renderbufferStorage(s.RENDERBUFFER,s.DEPTH_COMPONENT16,r,i),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.DEPTH_ATTACHMENT,s.RENDERBUFFER,o)),o},i.prototype.updateRenderTargetTextureSampleCount=function(e,t){if(this.webGLVersion<2)return 1;if(e.samples===t)return t;var r=this._gl;if(t=Math.min(t,r.getParameter(r.MAX_SAMPLES)),e._depthStencilBuffer&&r.deleteRenderbuffer(e._depthStencilBuffer),e._MSAAFramebuffer&&r.deleteFramebuffer(e._MSAAFramebuffer),e._MSAARenderBuffer&&r.deleteRenderbuffer(e._MSAARenderBuffer),t>1){e._MSAAFramebuffer=r.createFramebuffer(),this.bindUnboundFramebuffer(e._MSAAFramebuffer);var i=r.createRenderbuffer();r.bindRenderbuffer(r.RENDERBUFFER,i),r.renderbufferStorageMultisample(r.RENDERBUFFER,t,r.RGBA8,e._width,e._height),r.framebufferRenderbuffer(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.RENDERBUFFER,i),e._MSAARenderBuffer=i}else this.bindUnboundFramebuffer(e._framebuffer);return e.samples=t,e._depthStencilBuffer=this._setupFramebufferDepthAttachments(e._generateStencilBuffer,e._generateDepthBuffer,e._width,e._height,t),r.bindRenderbuffer(r.RENDERBUFFER,null),this.bindUnboundFramebuffer(null),t},i.prototype._uploadDataToTexture=function(e,t,r,i,n,o,s,a){this._gl.texImage2D(e,t,r,i,n,0,o,s,a)},i.prototype._uploadCompressedDataToTexture=function(e,t,r,i,n,o){this._gl.compressedTexImage2D(e,t,r,i,n,0,o)},i.prototype.createRenderTargetCubeTexture=function(t,i){var n=this._gl,o=n.createTexture(),s=!0,a=!0,u=!1,l=e.Texture.TRILINEAR_SAMPLINGMODE;void 0!==i&&(s=void 0===i.generateMipMaps?i:i.generateMipMaps,a=void 0===i.generateDepthBuffer||i.generateDepthBuffer,u=a&&i.generateStencilBuffer,void 0!==i.samplingMode&&(l=i.samplingMode)),o.isCube=!0,o.references=1,o.generateMipMaps=s,o.references=1,o.samples=1,o.samplingMode=l;var h=r(l,s,n);this._bindTextureDirectly(n.TEXTURE_CUBE_MAP,o);for(var c=0;c<6;c++)n.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+c,0,n.RGBA,t,t,0,n.RGBA,n.UNSIGNED_BYTE,null);n.texParameteri(n.TEXTURE_CUBE_MAP,n.TEXTURE_MAG_FILTER,h.mag),n.texParameteri(n.TEXTURE_CUBE_MAP,n.TEXTURE_MIN_FILTER,h.min),n.texParameteri(n.TEXTURE_CUBE_MAP,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_CUBE_MAP,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE);var f=n.createFramebuffer();return this.bindUnboundFramebuffer(f),o._depthStencilBuffer=this._setupFramebufferDepthAttachments(u,a,t,t),o.generateMipMaps&&(this._bindTextureDirectly(n.TEXTURE_CUBE_MAP,o),n.generateMipmap(n.TEXTURE_CUBE_MAP)),this._bindTextureDirectly(n.TEXTURE_CUBE_MAP,null),n.bindRenderbuffer(n.RENDERBUFFER,null),this.bindUnboundFramebuffer(null),o._framebuffer=f,o._width=t,o._height=t,o.isReady=!0,this.resetTextureCache(),this._loadedTexturesCache.push(o),o},i.prototype.createPrefilteredCubeTexture=function(t,r,i,n,o,s,a,u){var l=this;void 0===s&&(s=null),void 0===u&&(u=null);var h=function(t){if(l._caps.textureLOD||!t)return void(o&&o());var s=l._gl,a=t.width;if(a){for(var u=[],h=0;h<3;h++){var c=h/2,f=1-c,d=n,p=e.Scalar.Log2(a)*i+n,g=d+(p-d)*f,_=Math.round(Math.min(Math.max(g,0),p)),m=s.createTexture();if(m.isCube=!0,l._bindTextureDirectly(s.TEXTURE_CUBE_MAP,m),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_MAG_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_MIN_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),t.isDDS){var v=t.info,y=t.data;s.pixelStorei(s.UNPACK_FLIP_Y_WEBGL,v.isCompressed?1:0),e.Internals.DDSTools.UploadDDSLevels(l,y,v,!0,6,_)}else e.Tools.Warn("DDS is the only prefiltered cube map supported so far.");l._bindTextureDirectly(s.TEXTURE_CUBE_MAP,null);var A=new e.BaseTexture(r);A.isCube=!0,A._texture=m,m.isReady=!0,u.push(A)}t.texture._lodTextureHigh=u[2],t.texture._lodTextureMid=u[1],t.texture._lodTextureLow=u[0],o&&o()}};return this.createCubeTexture(t,r,null,!1,h,s,a,u)},i.prototype.createCubeTexture=function(t,r,i,o,s,a,u,l){var h=this;void 0===s&&(s=null),void 0===a&&(a=null),void 0===l&&(l=null);var c=this._gl,f=c.createTexture();f.isCube=!0,f.url=t,f.references=1,f.onLoadedCallbacks=[],f.generateMipMaps=!o;var d=!1,p=!1,g=t.lastIndexOf("."),_=l||t.substring(g).toLowerCase();return this._textureFormatInUse?(_=this._textureFormatInUse,t=t.substring(0,g)+this._textureFormatInUse,d=!0):p=".dds"===_,d?e.Tools.LoadFile(t,(function(t){var r=new e.Internals.KhronosTextureContainer(t,6),i=r.numberOfMipmapLevels>1&&!o;h._bindTextureDirectly(c.TEXTURE_CUBE_MAP,f),c.pixelStorei(c.UNPACK_FLIP_Y_WEBGL,1),r.uploadLevels(h._gl,!o),c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MAG_FILTER,c.LINEAR),c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MIN_FILTER,i?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(),f._width=r.pixelWidth,f._height=r.pixelHeight,f.isReady=!0}),null,null,!0,a):p?e.Tools.LoadFile(t,(function(t){var r=e.Internals.DDSTools.GetDDSInfo(t),i=(r.isRGB||r.isLuminance||r.mipmapCount>1)&&!o;h._bindTextureDirectly(c.TEXTURE_CUBE_MAP,f),c.pixelStorei(c.UNPACK_FLIP_Y_WEBGL,r.isCompressed?1:0),
- e.Internals.DDSTools.UploadDDSLevels(h,t,r,i,6),o||r.isFourCC||1!==r.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,i?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(),f._width=r.width,f._height=r.height,f.isReady=!0,f.type=r.textureType,s&&s({isDDS:!0,width:r.width,info:r,data:t,texture:f})}),null,null,!0,a):n(0,r,(function(t){var r=h.needPOTTextures?e.Tools.GetExponentOfTwo(t[0].width,h._caps.maxCubemapTextureSize):t[0].width,i=r;h._prepareWorkingCanvas(),h._workingCanvas.width=r,h._workingCanvas.height=i;var n=[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,f),c.pixelStorei(c.UNPACK_FLIP_Y_WEBGL,0);for(var a=u?h._getInternalFormat(u):h._gl.RGBA,l=0;l<n.length;l++)h._workingContext.drawImage(t[l],0,0,t[l].width,t[l].height,0,0,r,i),c.texImage2D(n[l],0,a,a,c.UNSIGNED_BYTE,h._workingCanvas);o||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,o?c.LINEAR:c.LINEAR_MIPMAP_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(),f._width=r,f._height=i,f.isReady=!0,f.onLoadedCallbacks.forEach((function(e){e()})),s&&s()}),i,a),this._loadedTexturesCache.push(f),f},i.prototype.updateTextureSize=function(e,t,r){e._width=t,e._height=r,e._size=t*r,e._baseWidth=t,e._baseHeight=r},i.prototype.updateRawCubeTexture=function(t,r,i,n,o,s,a){void 0===s&&(s=null),void 0===a&&(a=0);var u=this._gl,l=this._getWebGLTextureType(n),h=this._getInternalFormat(i),c=this._getRGBABufferInternalSizedFormat(n),f=!1;h===u.RGB&&(h=u.RGBA,f=!0),this._bindTextureDirectly(u.TEXTURE_CUBE_MAP,t),u.pixelStorei(u.UNPACK_FLIP_Y_WEBGL,void 0===o?1:o?1:0),t._width%4!=0&&u.pixelStorei(u.UNPACK_ALIGNMENT,1);for(var d=0;d<6;d++){var p=r[d];s?u.compressedTexImage2D(u.TEXTURE_CUBE_MAP_POSITIVE_X+d,a,this.getCaps().s3tc[s],t._width,t._height,0,p):(f&&(p=this._convertRGBtoRGBATextureData(p,t._width,t._height,n)),u.texImage2D(u.TEXTURE_CUBE_MAP_POSITIVE_X+d,a,c,t._width,t._height,0,h,l,p))}(!this.needPOTTextures||e.Tools.IsExponentOfTwo(t._width)&&e.Tools.IsExponentOfTwo(t._height))&&t.generateMipMaps&&0===a&&this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP),this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null),this.resetTextureCache(),t.isReady=!0},i.prototype.createRawCubeTexture=function(t,i,n,o,s,a,u,l){void 0===l&&(l=null);var h=this._gl,c=h.createTexture();c.isCube=!0,c.references=1,c.generateMipMaps=s,c.format=n,c.type=o;var f=this._getWebGLTextureType(o),d=this._getInternalFormat(n);this._getRGBABufferInternalSizedFormat(o);d===h.RGB&&(d=h.RGBA);var p=i,g=p;if(c._width=p,c._height=g,!this.needPOTTextures||e.Tools.IsExponentOfTwo(c._width)&&e.Tools.IsExponentOfTwo(c._height)||(s=!1),t&&this.updateRawCubeTexture(c,t,n,o,a,l),this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,c),t&&s&&this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP),f!==h.FLOAT||this._caps.textureFloatLinearFiltering)if(f!==this._gl.HALF_FLOAT_OES||this._caps.textureHalfFloatLinearFiltering){var _=r(u,s,h);h.texParameteri(h.TEXTURE_CUBE_MAP,h.TEXTURE_MAG_FILTER,_.mag),h.texParameteri(h.TEXTURE_CUBE_MAP,h.TEXTURE_MIN_FILTER,_.min)}else h.texParameteri(h.TEXTURE_CUBE_MAP,h.TEXTURE_MAG_FILTER,h.NEAREST),h.texParameteri(h.TEXTURE_CUBE_MAP,h.TEXTURE_MIN_FILTER,h.NEAREST);else h.texParameteri(h.TEXTURE_CUBE_MAP,h.TEXTURE_MAG_FILTER,h.NEAREST),h.texParameteri(h.TEXTURE_CUBE_MAP,h.TEXTURE_MIN_FILTER,h.NEAREST);return h.texParameteri(h.TEXTURE_CUBE_MAP,h.TEXTURE_WRAP_S,h.CLAMP_TO_EDGE),h.texParameteri(h.TEXTURE_CUBE_MAP,h.TEXTURE_WRAP_T,h.CLAMP_TO_EDGE),this._bindTextureDirectly(h.TEXTURE_CUBE_MAP,null),c},i.prototype.createRawCubeTextureFromUrl=function(t,r,i,n,o,s,a,u,l,h,c,f){var d=this;void 0===l&&(l=null),void 0===h&&(h=null),void 0===c&&(c=e.Texture.TRILINEAR_SAMPLINGMODE),void 0===f&&(f=!1);var p=this._gl,g=this.createRawCubeTexture(null,i,n,o,!s,f,c);r._addPendingData(g),g.url=t,this._loadedTexturesCache.push(g);var _=function(){r._removePendingData(g),h&&h()},m=function(e){var t=g._width,i=(g._height,a(e));if(u){var h=d._getWebGLTextureType(o),c=d._getInternalFormat(n),_=d._getRGBABufferInternalSizedFormat(o),m=!1;c===p.RGB&&(c=p.RGBA,m=!0),d._bindTextureDirectly(p.TEXTURE_CUBE_MAP,g),p.pixelStorei(p.UNPACK_FLIP_Y_WEBGL,0);for(var v=u(i),y=0;y<v.length;y++)for(var A=t>>y,T=0;T<6;T++){var E=v[y][T];m&&(E=d._convertRGBtoRGBATextureData(E,A,A,o)),p.texImage2D(T,y,_,A,A,0,c,h,E)}d._bindTextureDirectly(p.TEXTURE_CUBE_MAP,null)}else g.generateMipMaps=!s,d.updateRawCubeTexture(g,i,n,o,f);g.isReady=!0,d.resetTextureCache(),r._removePendingData(g),l&&l()};return e.Tools.LoadFile(t,(function(e){m(e)}),_,r.database,!0),g},i.prototype._prepareWebGLTextureContinuation=function(e,t,i,n,o){var s=this._gl,a=r(o,!i,s);s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,a.mag),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,a.min),i||n||s.generateMipmap(s.TEXTURE_2D),this._bindTextureDirectly(s.TEXTURE_2D,null),this.resetTextureCache(),t._removePendingData(e),e.onLoadedCallbacks.forEach((function(e){e()})),e.onLoadedCallbacks=[]},i.prototype._prepareWebGLTexture=function(t,r,i,n,o,s,a,u,l){var h=this;void 0===l&&(l=e.Texture.TRILINEAR_SAMPLINGMODE);var c=this.needPOTTextures?e.Tools.GetExponentOfTwo(i,this.getCaps().maxTextureSize):i,f=this.needPOTTextures?e.Tools.GetExponentOfTwo(n,this.getCaps().maxTextureSize):n,d=this._gl;this._bindTextureDirectly(d.TEXTURE_2D,t),d.pixelStorei(d.UNPACK_FLIP_Y_WEBGL,void 0===o?1:o?1:0),t._baseWidth=i,t._baseHeight=n,t._width=c,t._height=f,t.isReady=!0,u(c,f,(function(){h._prepareWebGLTextureContinuation(t,r,s,a,l)}))||this._prepareWebGLTextureContinuation(t,r,s,a,l)},i.prototype._convertRGBtoRGBATextureData=function(e,t,r,n){var o;o=n===i.TEXTURETYPE_FLOAT?new Float32Array(t*r*4):new Uint32Array(t*r*4);for(var s=0;s<t;s++)for(var a=0;a<r;a++){var u=3*(a*t+s),l=4*(a*t+s);o[l+0]=e[u+0],o[l+1]=e[u+1],o[l+2]=e[u+2],o[l+3]=1}return o},i.prototype._releaseFramebufferObjects=function(e){var t=this._gl;e._framebuffer&&(t.deleteFramebuffer(e._framebuffer),e._framebuffer=null),e._depthStencilBuffer&&(t.deleteRenderbuffer(e._depthStencilBuffer),e._depthStencilBuffer=null),e._MSAAFramebuffer&&(t.deleteFramebuffer(e._MSAAFramebuffer),e._MSAAFramebuffer=null),e._MSAARenderBuffer&&(t.deleteRenderbuffer(e._MSAARenderBuffer),e._MSAARenderBuffer=null)},i.prototype._releaseTexture=function(e){var t=this._gl;this._releaseFramebufferObjects(e),t.deleteTexture(e),this.unbindAllTextures();var r=this._loadedTexturesCache.indexOf(e);-1!==r&&this._loadedTexturesCache.splice(r,1),e._lodTextureHigh&&e._lodTextureHigh.dispose(),e._lodTextureMid&&e._lodTextureMid.dispose(),e._lodTextureLow&&e._lodTextureLow.dispose()},i.prototype.setProgram=function(e){this._currentProgram!==e&&(this._gl.useProgram(e),this._currentProgram=e)},i.prototype.bindSamplers=function(e){this.setProgram(e.getProgram());for(var t=e.getSamplers(),r=0;r<t.length;r++){var i=e.getUniform(t[r]);this._gl.uniform1i(i,r)}this._currentEffect=null},i.prototype.activateTexture=function(e){this._activeTexture!==e&&(this._gl.activeTexture(e),this._activeTexture=e)},i.prototype._bindTextureDirectly=function(e,t){this._activeTexturesCache[this._activeTexture]!==t&&(this._gl.bindTexture(e,t),this._activeTexturesCache[this._activeTexture]=t)},i.prototype._bindTexture=function(e,t){e<0||(this.activateTexture(this._gl.TEXTURE0+e),this._bindTextureDirectly(this._gl.TEXTURE_2D,t))},i.prototype.setTextureFromPostProcess=function(e,t){this._bindTexture(e,t._textures.data[t._currentRenderTextureInd])},i.prototype.unbindAllTextures=function(){for(var e=0;e<this._caps.maxTexturesImageUnits;e++)this.activateTexture(this._gl["TEXTURE"+e]),this._bindTextureDirectly(this._gl.TEXTURE_2D,null),this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null)},i.prototype.setTexture=function(e,t,r){e<0||(this._gl.uniform1i(t,e),this._setTexture(e,r))},i.prototype._setTexture=function(t,r){if(!r)return void(null!=this._activeTexturesCache[t]&&(this.activateTexture(this._gl["TEXTURE"+t]),this._bindTextureDirectly(this._gl.TEXTURE_2D,null),this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null)));var n=!1;if(r.video)this.activateTexture(this._gl["TEXTURE"+t]),n=!0,r.update();else if(r.delayLoadState===i.DELAYLOADSTATE_NOTLOADED)return void r.delayLoad();var o=r.isReady()?r.getInternalTexture():r.isCube?this.emptyCubeTexture:this.emptyTexture;if(this._activeTexturesCache[t]!==o)if(n||this.activateTexture(this._gl["TEXTURE"+t]),o.isCube){if(this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,o),o._cachedCoordinatesMode!==r.coordinatesMode){o._cachedCoordinatesMode=r.coordinatesMode;var s=r.coordinatesMode!==e.Texture.CUBIC_MODE&&r.coordinatesMode!==e.Texture.SKYBOX_MODE?this._gl.REPEAT:this._gl.CLAMP_TO_EDGE;this._gl.texParameteri(this._gl.TEXTURE_CUBE_MAP,this._gl.TEXTURE_WRAP_S,s),this._gl.texParameteri(this._gl.TEXTURE_CUBE_MAP,this._gl.TEXTURE_WRAP_T,s)}this._setAnisotropicLevel(this._gl.TEXTURE_CUBE_MAP,r)}else{if(this._bindTextureDirectly(this._gl.TEXTURE_2D,o),o._cachedWrapU!==r.wrapU)switch(o._cachedWrapU=r.wrapU,r.wrapU){case e.Texture.WRAP_ADDRESSMODE:this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_WRAP_S,this._gl.REPEAT);break;case e.Texture.CLAMP_ADDRESSMODE:this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_WRAP_S,this._gl.CLAMP_TO_EDGE);break;case e.Texture.MIRROR_ADDRESSMODE:this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_WRAP_S,this._gl.MIRRORED_REPEAT)}if(o._cachedWrapV!==r.wrapV)switch(o._cachedWrapV=r.wrapV,r.wrapV){case e.Texture.WRAP_ADDRESSMODE:this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_WRAP_T,this._gl.REPEAT);break;case e.Texture.CLAMP_ADDRESSMODE:this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_WRAP_T,this._gl.CLAMP_TO_EDGE);break;case e.Texture.MIRROR_ADDRESSMODE:this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_WRAP_T,this._gl.MIRRORED_REPEAT)}this._setAnisotropicLevel(this._gl.TEXTURE_2D,r)}},i.prototype.setTextureArray=function(e,t,r){if(!(e<0)){this._textureUnits&&this._textureUnits.length===r.length||(this._textureUnits=new Int32Array(r.length));for(var i=0;i<r.length;i++)this._textureUnits[i]=e+i;this._gl.uniform1iv(t,this._textureUnits);for(var n=0;n<r.length;n++)this._setTexture(e+n,r[n])}},i.prototype._setAnisotropicLevel=function(t,r){var i=r.getInternalTexture();if(i){var n=this._caps.textureAnisotropicFilterExtension,o=r.anisotropicFilteringLevel;i.samplingMode===e.Texture.NEAREST_SAMPLINGMODE&&(o=1),n&&r._cachedAnisotropicFilteringLevel!==o&&(this._gl.texParameterf(t,n.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(o,this._caps.maxAnisotropy)),r._cachedAnisotropicFilteringLevel=o)}},i.prototype.readPixels=function(e,t,r,i){var n=new Uint8Array(i*r*4);return this._gl.readPixels(e,t,r,i,this._gl.RGBA,this._gl.UNSIGNED_BYTE,n),n},i.prototype.addExternalData=function(t,r){return this._externalData||(this._externalData=new e.StringDictionary),this._externalData.add(t,r)},i.prototype.getExternalData=function(t){return this._externalData||(this._externalData=new e.StringDictionary),this._externalData.get(t)},i.prototype.getOrAddExternalDataWithFactory=function(t,r){return this._externalData||(this._externalData=new e.StringDictionary),this._externalData.getOrAddWithFactory(t,r)},i.prototype.removeExternalData=function(t){return this._externalData||(this._externalData=new e.StringDictionary),this._externalData.remove(t)},i.prototype.releaseInternalTexture=function(e){if(e&&0===--e.references){var t=this.getLoadedTexturesCache(),r=t.indexOf(e);r>-1&&t.splice(r,1),this._releaseTexture(e)}},i.prototype.unbindAllAttributes=function(){if(this._mustWipeVertexAttributes){this._mustWipeVertexAttributes=!1;for(var e=0;e<this._caps.maxVertexAttribs;e++)this._gl.disableVertexAttribArray(e),this._vertexAttribArraysEnabled[e]=!1,this._currentBufferPointers[e].active=!1}else for(var e=0,t=this._vertexAttribArraysEnabled.length;e<t;e++)e>=this._caps.maxVertexAttribs||!this._vertexAttribArraysEnabled[e]||(this._gl.disableVertexAttribArray(e),this._vertexAttribArraysEnabled[e]=!1,this._currentBufferPointers[e].active=!1)},i.prototype.releaseEffects=function(){for(var e in this._compiledEffects)this._gl.deleteProgram(this._compiledEffects[e]._program);this._compiledEffects={}},i.prototype.dispose=function(){for(this.hideLoadingUI(),this.stopRenderLoop(),this._emptyTexture&&(this._releaseTexture(this._emptyTexture),this._emptyTexture=null),this._emptyCubeTexture&&(this._releaseTexture(this._emptyCubeTexture),this._emptyCubeTexture=null),this._rescalePostProcess&&this._rescalePostProcess.dispose();this.scenes.length;)this.scenes[0].dispose();i.audioEngine&&i.audioEngine.dispose(),this.releaseEffects(),this.unbindAllAttributes(),this._dummyFramebuffer&&this._gl.deleteFramebuffer(this._dummyFramebuffer),this._gl=null,this.disableVR(),window.removeEventListener("blur",this._onBlur),window.removeEventListener("focus",this._onFocus),this._renderingCanvas.removeEventListener("pointerout",this._onCanvasBlur),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);var t=i.Instances.indexOf(this);t>=0&&i.Instances.splice(t,1),this._workingCanvas=null,this._workingContext=null,this._currentBufferPointers=null,this._renderingCanvas=null,this._currentProgram=null,this.onResizeObservable.clear(),this.onCanvasBlurObservable.clear(),e.Effect.ResetCache()},i.prototype.displayLoadingUI=function(){var e=this.loadingScreen;e&&e.displayLoadingUI()},i.prototype.hideLoadingUI=function(){var e=this.loadingScreen;e&&e.hideLoadingUI()},Object.defineProperty(i.prototype,"loadingScreen",{get:function(){return!this._loadingScreen&&e.DefaultLoadingScreen&&(this._loadingScreen=new e.DefaultLoadingScreen(this._renderingCanvas)),this._loadingScreen},set:function(e){this._loadingScreen=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"loadingUIText",{set:function(e){this.loadingScreen.loadingUIText=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"loadingUIBackgroundColor",{set:function(e){this.loadingScreen.loadingUIBackgroundColor=e},enumerable:!0,configurable:!0}),i.prototype.attachContextLostEvent=function(e){this._renderingCanvas.addEventListener("webglcontextlost",e,!1)},i.prototype.attachContextRestoredEvent=function(e){this._renderingCanvas.addEventListener("webglcontextrestored",e,!1)},i.prototype.getVertexShaderSource=function(e){var t=this._gl.getAttachedShaders(e);return this._gl.getShaderSource(t[0])},i.prototype.getFragmentShaderSource=function(e){var t=this._gl.getAttachedShaders(e);return this._gl.getShaderSource(t[1])},i.prototype.getError=function(){return this._gl.getError()},i.prototype.getFps=function(){return this._fps},i.prototype.getDeltaTime=function(){return this._deltaTime},i.prototype._measureFps=function(){this._performanceMonitor.sampleFrame(),this._fps=this._performanceMonitor.averageFPS,this._deltaTime=this._performanceMonitor.instantaneousFrameTime||0},i.prototype._readTexturePixels=function(e,t,r,i){void 0===i&&(i=-1);var n=this._gl;this._dummyFramebuffer||(this._dummyFramebuffer=n.createFramebuffer()),n.bindFramebuffer(n.FRAMEBUFFER,this._dummyFramebuffer),i>-1?n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+i,e,0):n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,e,0);var o,s=void 0!==e.type?this._getWebGLTextureType(e.type):n.UNSIGNED_BYTE;switch(s){case n.UNSIGNED_BYTE:o=new Uint8Array(4*t*r),s=n.UNSIGNED_BYTE;break;default:o=new Float32Array(4*t*r),s=n.FLOAT}return n.readPixels(0,0,t,r,n.RGBA,s,o),n.bindFramebuffer(n.FRAMEBUFFER,this._currentFramebuffer),o},i.prototype._canRenderToFloatFramebuffer=function(){return this._webGLVersion>1?this._caps.colorBufferFloat:this._canRenderToFramebuffer(e.Engine.TEXTURETYPE_FLOAT)},i.prototype._canRenderToHalfFloatFramebuffer=function(){return this._webGLVersion>1?this._caps.colorBufferFloat:this._canRenderToFramebuffer(e.Engine.TEXTURETYPE_HALF_FLOAT)},i.prototype._canRenderToFramebuffer=function(e){for(var t=this._gl;t.getError()!==t.NO_ERROR;);var r=!0,i=t.createTexture();t.bindTexture(t.TEXTURE_2D,i),t.texImage2D(t.TEXTURE_2D,0,this._getRGBABufferInternalSizedFormat(e),1,1,0,t.RGBA,this._getWebGLTextureType(e),null),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST);var n=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,n),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,i,0);var o=t.checkFramebufferStatus(t.FRAMEBUFFER);if(r=r&&o===t.FRAMEBUFFER_COMPLETE,r=r&&t.getError()===t.NO_ERROR,r&&(t.clear(t.COLOR_BUFFER_BIT),r=r&&t.getError()===t.NO_ERROR),r){t.bindFramebuffer(t.FRAMEBUFFER,null);var s=t.RGBA,a=t.UNSIGNED_BYTE,u=new Uint8Array(4);t.readPixels(0,0,1,1,s,a,u),r=r&&t.getError()===t.NO_ERROR}for(t.deleteTexture(i),t.deleteFramebuffer(n),t.bindFramebuffer(t.FRAMEBUFFER,null);!r&&t.getError()!==t.NO_ERROR;);return r},i.prototype._getWebGLTextureType=function(e){return e===i.TEXTURETYPE_FLOAT?this._gl.FLOAT:e===i.TEXTURETYPE_HALF_FLOAT?this._gl.HALF_FLOAT_OES:this._gl.UNSIGNED_BYTE},i.prototype._getRGBABufferInternalSizedFormat=function(e){return 1===this._webGLVersion?this._gl.RGBA:e===i.TEXTURETYPE_FLOAT?this._gl.RGBA32F:e===i.TEXTURETYPE_HALF_FLOAT?this._gl.RGBA16F:this._gl.RGBA},i.isSupported=function(){try{if(navigator.isCocoonJS)return!0;var e=document.createElement("canvas");return null!=(e.getContext("webgl")||e.getContext("experimental-webgl"))&&!!window.WebGLRenderingContext}catch(e){return!1}},i.Instances=new Array,i._ALPHA_DISABLE=0,i._ALPHA_ADD=1,i._ALPHA_COMBINE=2,i._ALPHA_SUBTRACT=3,i._ALPHA_MULTIPLY=4,i._ALPHA_MAXIMIZED=5,i._ALPHA_ONEONE=6,i._ALPHA_PREMULTIPLIED=7,i._ALPHA_PREMULTIPLIED_PORTERDUFF=8,i._ALPHA_INTERPOLATE=9,i._ALPHA_SCREENMODE=10,i._DELAYLOADSTATE_NONE=0,i._DELAYLOADSTATE_LOADED=1,i._DELAYLOADSTATE_LOADING=2,i._DELAYLOADSTATE_NOTLOADED=4,i._TEXTUREFORMAT_ALPHA=0,i._TEXTUREFORMAT_LUMINANCE=1,i._TEXTUREFORMAT_LUMINANCE_ALPHA=2,i._TEXTUREFORMAT_RGB=4,i._TEXTUREFORMAT_RGBA=5,i._TEXTURETYPE_UNSIGNED_INT=0,i._TEXTURETYPE_FLOAT=1,i._TEXTURETYPE_HALF_FLOAT=2,i._NEVER=512,i._ALWAYS=519,i._LESS=513,i._EQUAL=514,i._LEQUAL=515,i._GREATER=516,i._GEQUAL=518,i._NOTEQUAL=517,i._KEEP=7680,i._REPLACE=7681,i._INCR=7682,i._DECR=7683,i._INVERT=5386,i._INCR_WRAP=34055,i._DECR_WRAP=34056,i._SCALEMODE_FLOOR=1,i._SCALEMODE_NEAREST=2,i._SCALEMODE_CEILING=3,i.CollisionsEpsilon=.001,i.CodeRepository="src/",i.ShadersRepository="src/Shaders/",i})();e.Engine=u})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(t,r){this.state="",this.metadata=null,this.doNotSerialize=!1,this.animations=new Array,this._ranges={},this._childrenFlag=-1,this._isEnabled=!0,this._isReady=!0,this._currentRenderId=-1,this._parentRenderId=-1,this.onDisposeObservable=new e.Observable,this._behaviors=new Array,this.name=t,this.id=t,this._scene=r||e.Engine.LastCreatedScene,this._initCache()}return Object.defineProperty(t.prototype,"parent",{get:function(){return this._parentNode},set:function(e){if(this._parentNode!==e){if(this._parentNode){var t=this._parentNode._children.indexOf(this);-1!==t&&this._parentNode._children.splice(t,1)}this._parentNode=e,this._parentNode&&(this._parentNode._children||(this._parentNode._children=new Array),this._parentNode._children.push(this))}},enumerable:!0,configurable:!0}),t.prototype.getClassName=function(){return"Node"},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.getEngine=function(){return this._scene.getEngine()},t.prototype.addBehavior=function(e){if(-1===this._behaviors.indexOf(e))return e.attach(this),this._behaviors.push(e),this},t.prototype.removeBehavior=function(e){var t=this._behaviors.indexOf(e);if(-1!==t)return this._behaviors[t].detach(this),this._behaviors.splice(t,1),this},Object.defineProperty(t.prototype,"behaviors",{get:function(){return this._behaviors},enumerable:!0,configurable:!0}),t.prototype.getBehaviorByName=function(e){for(var t=0,r=this._behaviors;t<r.length;t++){var i=r[t];if(i.name===e)return i}return null},t.prototype.getWorldMatrix=function(){return e.Matrix.Identity()},t.prototype._initCache=function(){this._cache={},this._cache.parent=void 0},t.prototype.updateCache=function(e){!e&&this.isSynchronized()||(this._cache.parent=this.parent,this._updateCache())},t.prototype._updateCache=function(e){},t.prototype._isSynchronized=function(){return!0},t.prototype._markSyncedWithParent=function(){this._parentRenderId=this.parent._currentRenderId},t.prototype.isSynchronizedWithParent=function(){return!this.parent||this._parentRenderId===this.parent._currentRenderId&&this.parent.isSynchronized()},t.prototype.isSynchronized=function(e){var t=this.hasNewParent();return t=t||!this.isSynchronizedWithParent(),t=t||!this._isSynchronized(),e&&this.updateCache(!0),!t},t.prototype.hasNewParent=function(e){return this._cache.parent!==this.parent&&(e&&(this._cache.parent=this.parent),!0)},t.prototype.isReady=function(){return this._isReady},t.prototype.isEnabled=function(){return!!this._isEnabled&&(!this.parent||this.parent.isEnabled())},t.prototype.setEnabled=function(e){this._isEnabled=e},t.prototype.isDescendantOf=function(e){return!!this.parent&&(this.parent===e||this.parent.isDescendantOf(e))},t.prototype._getDescendants=function(e,t,r){if(void 0===t&&(t=!1),this._children)for(var i=0;i<this._children.length;i++){var n=this._children[i];r&&!r(n)||e.push(n),t||n._getDescendants(e,!1,r)}},t.prototype.getDescendants=function(e,t){var r=[];return this._getDescendants(r,e,t),r},t.prototype.getChildMeshes=function(t,r){var i=[];return this._getDescendants(i,t,(function(t){return(!r||r(t))&&t instanceof e.AbstractMesh})),i},t.prototype.getChildren=function(e){return this.getDescendants(!0,e)},t.prototype._setReady=function(e){if(e!==this._isReady){if(!e)return void(this._isReady=!1);this._isReady=!0,this.onReady&&this.onReady(this)}},t.prototype.getAnimationByName=function(e){for(var t=0;t<this.animations.length;t++){var r=this.animations[t];if(r.name===e)return r}return null},t.prototype.createAnimationRange=function(t,r,i){if(!this._ranges[t]){this._ranges[t]=new e.AnimationRange(t,r,i);for(var n=0,o=this.animations.length;n<o;n++)this.animations[n]&&this.animations[n].createRange(t,r,i)}},t.prototype.deleteAnimationRange=function(e,t){void 0===t&&(t=!0);for(var r=0,i=this.animations.length;r<i;r++)this.animations[r]&&this.animations[r].deleteRange(e,t);this._ranges[e]=void 0},t.prototype.getAnimationRange=function(e){return this._ranges[e]},t.prototype.beginAnimation=function(e,t,r,i){var n=this.getAnimationRange(e);if(!n)return null;this._scene.beginAnimation(this,n.from,n.to,t,r,i)},t.prototype.serializeAnimationRanges=function(){var e=[];for(var t in this._ranges){var r={};r.name=t,r.from=this._ranges[t].from,r.to=this._ranges[t].to,e.push(r)}return e},t.prototype.dispose=function(){this.parent=null,this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear();for(var e=0,t=this._behaviors;e<t.length;e++){t[e].detach(this)}},t.ParseAnimationRanges=function(e,t,r){if(t.ranges)for(var i=0;i<t.ranges.length;i++){var n=t.ranges[i];e.createAnimationRange(n.name,n.from,n.to)}},__decorate([e.serialize()],t.prototype,"name",void 0),__decorate([e.serialize()],t.prototype,"id",void 0),__decorate([e.serialize()],t.prototype,"uniqueId",void 0),__decorate([e.serialize()],t.prototype,"state",void 0),__decorate([e.serialize()],t.prototype,"metadata",void 0),t})();e.Node=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(t,r){this.minimum=t,this.maximum=r,this._tempRadiusVector=e.Vector3.Zero();var i=e.Vector3.Distance(t,r);this.center=e.Vector3.Lerp(t,r,.5),this.radius=.5*i,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 r=this.centerWorld.x-t.x,i=this.centerWorld.y-t.y,n=this.centerWorld.z-t.z,o=Math.sqrt(r*r+i*i+n*n);return!(Math.abs(this.radiusWorld-o)<e.Epsilon)},t.Intersects=function(e,t){var r=e.centerWorld.x-t.centerWorld.x,i=e.centerWorld.y-t.centerWorld.y,n=e.centerWorld.z-t.centerWorld.z,o=Math.sqrt(r*r+i*i+n*n);return!(e.radiusWorld+t.radiusWorld<o)},t})();e.BoundingSphere=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(t,r){this.minimum=t,this.maximum=r,this.vectors=new Array,this.vectorsWorld=new Array,this.vectors.push(this.minimum.clone()),this.vectors.push(this.maximum.clone()),this.vectors.push(this.minimum.clone()),this.vectors[2].x=this.maximum.x,this.vectors.push(this.minimum.clone()),this.vectors[3].y=this.maximum.y,this.vectors.push(this.minimum.clone()),this.vectors[4].z=this.maximum.z,this.vectors.push(this.maximum.clone()),this.vectors[5].z=this.minimum.z,this.vectors.push(this.maximum.clone()),this.vectors[6].x=this.minimum.x,this.vectors.push(this.maximum.clone()),this.vectors[7].y=this.minimum.y,this.center=this.maximum.add(this.minimum).scale(.5),this.extendSize=this.maximum.subtract(this.minimum).scale(.5),this.directions=[e.Vector3.Zero(),e.Vector3.Zero(),e.Vector3.Zero()];for(var i=0;i<this.vectors.length;i++)this.vectorsWorld[i]=e.Vector3.Zero();this.minimumWorld=e.Vector3.Zero(),this.maximumWorld=e.Vector3.Zero(),this.centerWorld=e.Vector3.Zero(),this.extendSizeWorld=e.Vector3.Zero(),this._update(e.Matrix.Identity())}return t.prototype.getWorldMatrix=function(){return this._worldMatrix},t.prototype.setWorldMatrix=function(e){return this._worldMatrix.copyFrom(e),this},t.prototype._update=function(t){e.Vector3.FromFloatsToRef(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,this.minimumWorld),e.Vector3.FromFloatsToRef(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE,this.maximumWorld);for(var r=0;r<this.vectors.length;r++){var i=this.vectorsWorld[r];e.Vector3.TransformCoordinatesToRef(this.vectors[r],t,i),i.x<this.minimumWorld.x&&(this.minimumWorld.x=i.x),i.y<this.minimumWorld.y&&(this.minimumWorld.y=i.y),i.z<this.minimumWorld.z&&(this.minimumWorld.z=i.z),i.x>this.maximumWorld.x&&(this.maximumWorld.x=i.x),i.y>this.maximumWorld.y&&(this.maximumWorld.y=i.y),i.z>this.maximumWorld.z&&(this.maximumWorld.z=i.z)}this.maximumWorld.subtractToRef(this.minimumWorld,this.extendSizeWorld),this.extendSizeWorld.scaleInPlace(.5),this.maximumWorld.addToRef(this.minimumWorld,this.centerWorld),this.centerWorld.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 r=-e.Epsilon;return!(this.maximumWorld.x-t.x<r||r>t.x-this.minimumWorld.x)&&(!(this.maximumWorld.y-t.y<r||r>t.y-this.minimumWorld.y)&&!(this.maximumWorld.z-t.z<r||r>t.z-this.minimumWorld.z))},t.prototype.intersectsSphere=function(e){return t.IntersectsSphere(this.minimumWorld,this.maximumWorld,e.centerWorld,e.radiusWorld)},t.prototype.intersectsMinMax=function(e,t){return!(this.maximumWorld.x<e.x||this.minimumWorld.x>t.x)&&(!(this.maximumWorld.y<e.y||this.minimumWorld.y>t.y)&&!(this.maximumWorld.z<e.z||this.minimumWorld.z>t.z))},t.Intersects=function(e,t){return!(e.maximumWorld.x<t.minimumWorld.x||e.minimumWorld.x>t.maximumWorld.x)&&(!(e.maximumWorld.y<t.minimumWorld.y||e.minimumWorld.y>t.maximumWorld.y)&&!(e.maximumWorld.z<t.minimumWorld.z||e.minimumWorld.z>t.maximumWorld.z))},t.IntersectsSphere=function(t,r,i,n){var o=e.Vector3.Clamp(i,t,r);return e.Vector3.DistanceSquared(i,o)<=n*n},t.IsCompletelyInFrustum=function(e,t){for(var r=0;r<6;r++)for(var i=0;i<8;i++)if(t[r].dotCoordinate(e[i])<0)return!1;return!0},t.IsInFrustum=function(e,t){for(var r=0;r<6;r++){for(var i=8,n=0;n<8&&t[r].dotCoordinate(e[n])<0;n++)--i;if(0===i)return!1}return!0},t})();e.BoundingBox=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=function(t,r){var i=e.Vector3.Dot(r.centerWorld,t),n=Math.abs(e.Vector3.Dot(r.directions[0],t))*r.extendSize.x,o=Math.abs(e.Vector3.Dot(r.directions[1],t))*r.extendSize.y,s=Math.abs(e.Vector3.Dot(r.directions[2],t))*r.extendSize.z,a=n+o+s;return{min:i-a,max:i+a}},r=function(e,t,r,i){return!(e>i||r>t)},i=function(e,i,n){var o=t(e,i),s=t(e,n);return r(o.min,o.max,s.min,s.max)},n=(function(){function t(t,r){this.minimum=t,this.maximum=r,this._isLocked=!1,this.boundingBox=new e.BoundingBox(t,r),this.boundingSphere=new e.BoundingSphere(t,r)}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)},Object.defineProperty(t.prototype,"diagonalLength",{get:function(){var e=this.boundingBox;return e.maximumWorld.subtract(e.minimumWorld).length()},enumerable:!0,configurable:!0}),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,r){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(!r)return!0;var n=this.boundingBox,o=t.boundingBox
- ;return!!i(n.directions[0],n,o)&&(!!i(n.directions[1],n,o)&&(!!i(n.directions[2],n,o)&&(!!i(o.directions[0],n,o)&&(!!i(o.directions[1],n,o)&&(!!i(o.directions[2],n,o)&&(!!i(e.Vector3.Cross(n.directions[0],o.directions[0]),n,o)&&(!!i(e.Vector3.Cross(n.directions[0],o.directions[1]),n,o)&&(!!i(e.Vector3.Cross(n.directions[0],o.directions[2]),n,o)&&(!!i(e.Vector3.Cross(n.directions[1],o.directions[0]),n,o)&&(!!i(e.Vector3.Cross(n.directions[1],o.directions[1]),n,o)&&(!!i(e.Vector3.Cross(n.directions[1],o.directions[2]),n,o)&&(!!i(e.Vector3.Cross(n.directions[2],o.directions[0]),n,o)&&(!!i(e.Vector3.Cross(n.directions[2],o.directions[1]),n,o)&&!!i(e.Vector3.Cross(n.directions[2],o.directions[2]),n,o))))))))))))))},t})();e.BoundingInfo=n})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(i,n){var o=t.call(this,i,n)||this;return o._facetNb=0,o._partitioningSubdivisions=10,o._partitioningBBoxRatio=1.01,o._facetDataEnabled=!1,o._facetParameters={},o._bbSize=e.Vector3.Zero(),o._subDiv={max:1,X:1,Y:1,Z:1},o.onCollideObservable=new e.Observable,o.onCollisionPositionChangeObservable=new e.Observable,o.onAfterWorldMatrixUpdateObservable=new e.Observable,o.onMaterialChangedObservable=new e.Observable,o.definedFacingForward=!0,o.position=e.Vector3.Zero(),o._rotation=e.Vector3.Zero(),o._scaling=e.Vector3.One(),o.billboardMode=r.BILLBOARDMODE_NONE,o.visibility=1,o.alphaIndex=Number.MAX_VALUE,o.infiniteDistance=!1,o.isVisible=!0,o.isPickable=!0,o.showBoundingBox=!1,o.showSubMeshesBoundingBox=!1,o.isBlocker=!1,o.enablePointerMoveEvents=!1,o.renderingGroupId=0,o._receiveShadows=!1,o.renderOutline=!1,o.outlineColor=e.Color3.Red(),o.outlineWidth=.02,o.renderOverlay=!1,o.overlayColor=e.Color3.Red(),o.overlayAlpha=.5,o._hasVertexAlpha=!1,o._useVertexColors=!0,o._computeBonesUsingShaders=!0,o._numBoneInfluencers=4,o._applyFog=!0,o.scalingDeterminant=1,o.useOctreeForRenderingSelection=!0,o.useOctreeForPicking=!0,o.useOctreeForCollisions=!0,o._layerMask=268435455,o.alwaysSelectAsActiveMesh=!1,o._checkCollisions=!1,o._collisionMask=-1,o._collisionGroup=-1,o.ellipsoid=new e.Vector3(.5,1,.5),o.ellipsoidOffset=new e.Vector3(0,0,0),o._oldPositionForCollisions=new e.Vector3(0,0,0),o._diffPositionForCollisions=new e.Vector3(0,0,0),o._newPositionForCollisions=new e.Vector3(0,0,0),o.edgesWidth=1,o.edgesColor=new e.Color4(1,0,0,1),o._localWorld=e.Matrix.Zero(),o._worldMatrix=e.Matrix.Zero(),o._absolutePosition=e.Vector3.Zero(),o._collisionsTransformMatrix=e.Matrix.Zero(),o._collisionsScalingMatrix=e.Matrix.Zero(),o._isDirty=!1,o._pivotMatrix=e.Matrix.Identity(),o._isDisposed=!1,o._renderId=0,o._intersectionsInProgress=new Array,o._isWorldMatrixFrozen=!1,o._unIndexed=!1,o._lightSources=new Array,o._onCollisionPositionChange=function(t,r,i){void 0===i&&(i=null),o.getScene().workerCollisions&&r.multiplyInPlace(o._collider.radius),r.subtractToRef(o._oldPositionForCollisions,o._diffPositionForCollisions),o._diffPositionForCollisions.length()>e.Engine.CollisionsEpsilon&&o.position.addInPlace(o._diffPositionForCollisions),i&&o.onCollideObservable.notifyObservers(i),o.onCollisionPositionChangeObservable.notifyObservers(o.position)},o.getScene().addMesh(o),o._resyncLightSources(),o}return __extends(r,t),Object.defineProperty(r,"BILLBOARDMODE_NONE",{get:function(){return r._BILLBOARDMODE_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(r,"BILLBOARDMODE_X",{get:function(){return r._BILLBOARDMODE_X},enumerable:!0,configurable:!0}),Object.defineProperty(r,"BILLBOARDMODE_Y",{get:function(){return r._BILLBOARDMODE_Y},enumerable:!0,configurable:!0}),Object.defineProperty(r,"BILLBOARDMODE_Z",{get:function(){return r._BILLBOARDMODE_Z},enumerable:!0,configurable:!0}),Object.defineProperty(r,"BILLBOARDMODE_ALL",{get:function(){return r._BILLBOARDMODE_ALL},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"facetNb",{get:function(){return this._facetNb},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"partitioningSubdivisions",{get:function(){return this._partitioningSubdivisions},set:function(e){this._partitioningSubdivisions=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"partitioningBBoxRatio",{get:function(){return this._partitioningBBoxRatio},set:function(e){this._partitioningBBoxRatio=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"isFacetDataEnabled",{get:function(){return this._facetDataEnabled},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"onCollide",{set:function(e){this._onCollideObserver&&this.onCollideObservable.remove(this._onCollideObserver),this._onCollideObserver=this.onCollideObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"onCollisionPositionChange",{set:function(e){this._onCollisionPositionChangeObserver&&this.onCollisionPositionChangeObservable.remove(this._onCollisionPositionChangeObserver),this._onCollisionPositionChangeObserver=this.onCollisionPositionChangeObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"material",{get:function(){return this._material},set:function(e){if(this._material!==e&&(this._material=e,this.onMaterialChangedObservable.hasObservers&&this.onMaterialChangedObservable.notifyObservers(this),this.subMeshes))for(var t=0,r=this.subMeshes;t<r.length;t++){var i=r[t];i.setEffect(null)}},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"receiveShadows",{get:function(){return this._receiveShadows},set:function(e){this._receiveShadows!==e&&(this._receiveShadows=e,this._markSubMeshesAsLightDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"hasVertexAlpha",{get:function(){return this._hasVertexAlpha},set:function(e){this._hasVertexAlpha!==e&&(this._hasVertexAlpha=e,this._markSubMeshesAsAttributesDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"useVertexColors",{get:function(){return this._useVertexColors},set:function(e){this._useVertexColors!==e&&(this._useVertexColors=e,this._markSubMeshesAsAttributesDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"computeBonesUsingShaders",{get:function(){return this._computeBonesUsingShaders},set:function(e){this._computeBonesUsingShaders!==e&&(this._computeBonesUsingShaders=e,this._markSubMeshesAsAttributesDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"numBoneInfluencers",{get:function(){return this._numBoneInfluencers},set:function(e){this._numBoneInfluencers!==e&&(this._numBoneInfluencers=e,this._markSubMeshesAsAttributesDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"applyFog",{get:function(){return this._applyFog},set:function(e){this._applyFog!==e&&(this._applyFog=e,this._markSubMeshesAsMiscDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"layerMask",{get:function(){return this._layerMask},set:function(e){e!==this._layerMask&&(this._layerMask=e,this._resyncLightSources())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"collisionMask",{get:function(){return this._collisionMask},set:function(e){this._collisionMask=isNaN(e)?-1:e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"collisionGroup",{get:function(){return this._collisionGroup},set:function(e){this._collisionGroup=isNaN(e)?-1:e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"_positions",{get:function(){return null},enumerable:!0,configurable:!0}),Object.defineProperty(r.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),this._markSubMeshesAsAttributesDirty()},enumerable:!0,configurable:!0}),r.prototype.isDisposed=function(){return this._isDisposed},r.prototype.getClassName=function(){return"AbstractMesh"},r.prototype.toString=function(t){var r="Name: "+this.name+", isInstance: "+(this instanceof e.InstancedMesh?"YES":"NO");return r+=", # of submeshes: "+(this.subMeshes?this.subMeshes.length:0),this._skeleton&&(r+=", skeleton: "+this._skeleton.name),t&&(r+=", billboard mode: "+["NONE","X","Y",null,"Z",null,null,"ALL"][this.billboardMode],r+=", freeze wrld mat: "+(this._isWorldMatrixFrozen||this._waitingFreezeWorldMatrix?"YES":"NO")),r},r.prototype._resyncLightSources=function(){this._lightSources.length=0;for(var e=0,t=this.getScene().lights;e<t.length;e++){var r=t[e];r.isEnabled()&&(r.canAffectMesh(this)&&this._lightSources.push(r))}this._markSubMeshesAsLightDirty()},r.prototype._resyncLighSource=function(e){var t=e.isEnabled()&&e.canAffectMesh(this),r=this._lightSources.indexOf(e);if(-1===r){if(!t)return;this._lightSources.push(e)}else{if(t)return;this._lightSources.splice(r,1)}this._markSubMeshesAsLightDirty()},r.prototype._removeLightSource=function(e){var t=this._lightSources.indexOf(e);-1!==t&&this._lightSources.splice(t,1)},r.prototype._markSubMeshesAsDirty=function(e){if(this.subMeshes)for(var t=0,r=this.subMeshes;t<r.length;t++){var i=r[t];i._materialDefines&&e(i._materialDefines)}},r.prototype._markSubMeshesAsLightDirty=function(){this._markSubMeshesAsDirty((function(e){return e.markAsLightDirty()}))},r.prototype._markSubMeshesAsAttributesDirty=function(){this._markSubMeshesAsDirty((function(e){return e.markAsAttributesDirty()}))},r.prototype._markSubMeshesAsMiscDirty=function(){if(this.subMeshes)for(var t=0,r=this.subMeshes;t<r.length;t++){var i=r[t],n=i.getMaterial();n&&n.markAsDirty(e.Material.MiscDirtyFlag)}},Object.defineProperty(r.prototype,"rotation",{get:function(){return this._rotation},set:function(e){this._rotation=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"scaling",{get:function(){return this._scaling},set:function(e){this._scaling=e,this.physicsImpostor&&this.physicsImpostor.forceUpdate()},enumerable:!0,configurable:!0}),Object.defineProperty(r.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}),r.prototype.updatePoseMatrix=function(e){return this._poseMatrix.copyFrom(e),this},r.prototype.getPoseMatrix=function(){return this._poseMatrix},r.prototype.disableEdgesRendering=function(){return void 0!==this._edgesRenderer&&(this._edgesRenderer.dispose(),this._edgesRenderer=void 0),this},r.prototype.enableEdgesRendering=function(t,r){return void 0===t&&(t=.95),void 0===r&&(r=!1),this.disableEdgesRendering(),this._edgesRenderer=new e.EdgesRenderer(this,t,r),this},Object.defineProperty(r.prototype,"isBlocked",{get:function(){return!1},enumerable:!0,configurable:!0}),r.prototype.getLOD=function(e){return this},r.prototype.getTotalVertices=function(){return 0},r.prototype.getIndices=function(){return null},r.prototype.getVerticesData=function(e){return null},r.prototype.setVerticesData=function(e,t,r,i){return null},r.prototype.updateVerticesData=function(e,t,r,i){return null},r.prototype.setIndices=function(e,t){return null},r.prototype.isVerticesDataPresent=function(e){return!1},r.prototype.getBoundingInfo=function(){return this._masterMesh?this._masterMesh.getBoundingInfo():(this._boundingInfo||this._updateBoundingInfo(),this._boundingInfo)},r.prototype.setBoundingInfo=function(e){return this._boundingInfo=e,this},Object.defineProperty(r.prototype,"useBones",{get:function(){return this.skeleton&&this.getScene().skeletonsEnabled&&this.isVerticesDataPresent(e.VertexBuffer.MatricesIndicesKind)&&this.isVerticesDataPresent(e.VertexBuffer.MatricesWeightsKind)},enumerable:!0,configurable:!0}),r.prototype._preActivate=function(){},r.prototype._preActivateForIntermediateRendering=function(e){},r.prototype._activate=function(e){this._renderId=e},r.prototype.getWorldMatrix=function(){return this._masterMesh?this._masterMesh.getWorldMatrix():(this._currentRenderId===this.getScene().getRenderId()&&this.isSynchronized()||this.computeWorldMatrix(),this._worldMatrix)},Object.defineProperty(r.prototype,"worldMatrixFromCache",{get:function(){return this._worldMatrix},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"absolutePosition",{get:function(){return this._absolutePosition},enumerable:!0,configurable:!0}),r.prototype.freezeWorldMatrix=function(){return this._isWorldMatrixFrozen=!1,this.computeWorldMatrix(!0),this._isWorldMatrixFrozen=!0,this},r.prototype.unfreezeWorldMatrix=function(){return this._isWorldMatrixFrozen=!1,this.computeWorldMatrix(!0),this},Object.defineProperty(r.prototype,"isWorldMatrixFrozen",{get:function(){return this._isWorldMatrixFrozen},enumerable:!0,configurable:!0}),r.prototype.rotate=function(t,i,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,i,r._rotationAxisCache),o.multiplyToRef(this.rotationQuaternion,this.rotationQuaternion)}else o=e.Quaternion.RotationAxisToRef(t,i,r._rotationAxisCache),this.rotationQuaternion.multiplyToRef(o,this.rotationQuaternion);return this},r.prototype.rotateAround=function(t,r,i){return r.normalize(),this.rotationQuaternion||(this.rotationQuaternion=e.Quaternion.RotationYawPitchRoll(this.rotation.y,this.rotation.x,this.rotation.z),this.rotation.copyFromFloats(0,0,0)),t.subtractToRef(this.position,e.Tmp.Vector3[0]),e.Matrix.TranslationToRef(e.Tmp.Vector3[0].x,e.Tmp.Vector3[0].y,e.Tmp.Vector3[0].z,e.Tmp.Matrix[0]),e.Tmp.Matrix[0].invertToRef(e.Tmp.Matrix[2]),e.Matrix.RotationAxisToRef(r,i,e.Tmp.Matrix[1]),e.Tmp.Matrix[2].multiplyToRef(e.Tmp.Matrix[1],e.Tmp.Matrix[2]),e.Tmp.Matrix[2].multiplyToRef(e.Tmp.Matrix[0],e.Tmp.Matrix[2]),e.Tmp.Matrix[2].decompose(e.Tmp.Vector3[0],e.Tmp.Quaternion[0],e.Tmp.Vector3[1]),this.position.addInPlace(e.Tmp.Vector3[1]),this.rotationQuaternion.multiplyInPlace(e.Tmp.Quaternion[0]),this},r.prototype.translate=function(t,r,i){var n=t.scale(r);if(i&&i!==e.Space.LOCAL)this.setAbsolutePosition(this.getAbsolutePosition().add(n));else{var o=this.getPositionExpressedInLocalSpace().add(n);this.setPositionWithLocalVector(o)}return this},r.prototype.addRotation=function(t,r,i){var n;this.rotationQuaternion?n=this.rotationQuaternion:(n=e.Tmp.Quaternion[1],e.Quaternion.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,n));var o=e.Tmp.Quaternion[0];return e.Quaternion.RotationYawPitchRollToRef(r,t,i,o),n.multiplyInPlace(o),this.rotationQuaternion||n.toEulerAnglesToRef(this.rotation),this},r.prototype.getAbsolutePosition=function(){return this.computeWorldMatrix(),this._absolutePosition},r.prototype.setAbsolutePosition=function(t){if(t){var r,i,n;if(void 0===t.x){if(arguments.length<3)return;r=arguments[0],i=arguments[1],n=arguments[2]}else r=t.x,i=t.y,n=t.z;if(this.parent){var o=this.parent.getWorldMatrix().clone();o.invert();var s=new e.Vector3(r,i,n);this.position=e.Vector3.TransformCoordinates(s,o)}else this.position.x=r,this.position.y=i,this.position.z=n;return this}},r.prototype.movePOV=function(e,t,r){return this.position.addInPlace(this.calcMovePOV(e,t,r)),this},r.prototype.calcMovePOV=function(t,r,i){var n=new e.Matrix;(this.rotationQuaternion?this.rotationQuaternion:e.Quaternion.RotationYawPitchRoll(this.rotation.y,this.rotation.x,this.rotation.z)).toRotationMatrix(n);var o=e.Vector3.Zero(),s=this.definedFacingForward?-1:1;return e.Vector3.TransformCoordinatesFromFloatsToRef(t*s,r,i*s,n,o),o},r.prototype.rotatePOV=function(e,t,r){return this.rotation.addInPlace(this.calcRotatePOV(e,t,r)),this},r.prototype.calcRotatePOV=function(t,r,i){var n=this.definedFacingForward?1:-1;return new e.Vector3(t*n,r,i*n)},r.prototype.setPivotMatrix=function(e){return this._pivotMatrix=e,this._cache.pivotMatrixUpdated=!0,this},r.prototype.getPivotMatrix=function(){return this._pivotMatrix},r.prototype._isSynchronized=function(){return!this._isDirty&&(this.billboardMode===this._cache.billboardMode&&this.billboardMode===r.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)))))))},r.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},r.prototype.markAsDirty=function(e){return"rotation"===e&&(this.rotationQuaternion=null),this._currentRenderId=Number.MAX_VALUE,this._isDirty=!0,this},r.prototype._updateBoundingInfo=function(){return this._boundingInfo=this._boundingInfo||new e.BoundingInfo(this.absolutePosition,this.absolutePosition),this._boundingInfo.update(this.worldMatrixFromCache),this._updateSubMeshesBoundingInfo(this.worldMatrixFromCache),this},r.prototype._updateSubMeshesBoundingInfo=function(e){if(this.subMeshes){for(var t=0;t<this.subMeshes.length;t++){var r=this.subMeshes[t];r.IsGlobal||r.updateBoundingInfo(e)}return this}},r.prototype.computeWorldMatrix=function(t){if(this._isWorldMatrixFrozen)return this._worldMatrix;if(!t&&this.isSynchronized(!0))return this._currentRenderId=this.getScene().getRenderId(),this._worldMatrix;if(this._cache.position.copyFrom(this.position),this._cache.scaling.copyFrom(this.scaling),this._cache.pivotMatrixUpdated=!1,this._cache.billboardMode=this.billboardMode,this._currentRenderId=this.getScene().getRenderId(),this._isDirty=!1,e.Matrix.ScalingToRef(this.scaling.x*this.scalingDeterminant,this.scaling.y*this.scalingDeterminant,this.scaling.z*this.scalingDeterminant,e.Tmp.Matrix[1]),this.rotationQuaternion){this.rotation.length()&&(this.rotationQuaternion.multiplyInPlace(e.Quaternion.RotationYawPitchRoll(this.rotation.y,this.rotation.x,this.rotation.z)),this.rotation.copyFromFloats(0,0,0))}if(this.rotationQuaternion?(this.rotationQuaternion.toRotationMatrix(e.Tmp.Matrix[0]),this._cache.rotationQuaternion.copyFrom(this.rotationQuaternion)):(e.Matrix.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,e.Tmp.Matrix[0]),this._cache.rotation.copyFrom(this.rotation)),this.infiniteDistance&&!this.parent){var i=this.getScene().activeCamera;if(i){var n=i.getWorldMatrix(),o=new e.Vector3(n.m[12],n.m[13],n.m[14]);e.Matrix.TranslationToRef(this.position.x+o.x,this.position.y+o.y,this.position.z+o.z,e.Tmp.Matrix[2])}}else e.Matrix.TranslationToRef(this.position.x,this.position.y,this.position.z,e.Tmp.Matrix[2]);if(this._pivotMatrix.multiplyToRef(e.Tmp.Matrix[1],e.Tmp.Matrix[4]),e.Tmp.Matrix[4].multiplyToRef(e.Tmp.Matrix[0],e.Tmp.Matrix[5]),this.billboardMode!==r.BILLBOARDMODE_NONE&&this.getScene().activeCamera){if((this.billboardMode&r.BILLBOARDMODE_ALL)!==r.BILLBOARDMODE_ALL){var s=e.Tmp.Vector3[3];this.parent&&this.parent.getWorldMatrix?this._meshToBoneReferal?(this.parent.getWorldMatrix().multiplyToRef(this._meshToBoneReferal.getWorldMatrix(),e.Tmp.Matrix[6]),e.Vector3.TransformCoordinatesToRef(this.position,e.Tmp.Matrix[6],s)):e.Vector3.TransformCoordinatesToRef(this.position,this.parent.getWorldMatrix(),s):s.copyFrom(this.position),s.subtractInPlace(this.getScene().activeCamera.globalPosition);var a=e.Tmp.Vector3[4].copyFromFloats(0,0,0);(this.billboardMode&r.BILLBOARDMODE_X)===r.BILLBOARDMODE_X&&(a.x=Math.atan2(-s.y,s.z)),(this.billboardMode&r.BILLBOARDMODE_Y)===r.BILLBOARDMODE_Y&&(a.y=Math.atan2(s.x,s.z)),(this.billboardMode&r.BILLBOARDMODE_Z)===r.BILLBOARDMODE_Z&&(a.z=Math.atan2(s.y,s.x)),e.Matrix.RotationYawPitchRollToRef(a.y,a.x,a.z,e.Tmp.Matrix[0])}else e.Tmp.Matrix[1].copyFrom(this.getScene().activeCamera.getViewMatrix()),e.Tmp.Matrix[1].setTranslationFromFloats(0,0,0),e.Tmp.Matrix[1].invertToRef(e.Tmp.Matrix[0]);e.Tmp.Matrix[1].copyFrom(e.Tmp.Matrix[5]),e.Tmp.Matrix[1].multiplyToRef(e.Tmp.Matrix[0],e.Tmp.Matrix[5])}return e.Tmp.Matrix[5].multiplyToRef(e.Tmp.Matrix[2],this._localWorld),this.parent&&this.parent.getWorldMatrix?(this.billboardMode!==r.BILLBOARDMODE_NONE?(this._meshToBoneReferal?(this.parent.getWorldMatrix().multiplyToRef(this._meshToBoneReferal.getWorldMatrix(),e.Tmp.Matrix[6]),e.Tmp.Matrix[5].copyFrom(e.Tmp.Matrix[6])):e.Tmp.Matrix[5].copyFrom(this.parent.getWorldMatrix()),this._localWorld.getTranslationToRef(e.Tmp.Vector3[5]),e.Vector3.TransformCoordinatesToRef(e.Tmp.Vector3[5],e.Tmp.Matrix[5],e.Tmp.Vector3[5]),this._worldMatrix.copyFrom(this._localWorld),this._worldMatrix.setTranslation(e.Tmp.Vector3[5])):this._meshToBoneReferal?(this._localWorld.multiplyToRef(this.parent.getWorldMatrix(),e.Tmp.Matrix[6]),e.Tmp.Matrix[6].multiplyToRef(this._meshToBoneReferal.getWorldMatrix(),this._worldMatrix)):this._localWorld.multiplyToRef(this.parent.getWorldMatrix(),this._worldMatrix),this._markSyncedWithParent()):this._worldMatrix.copyFrom(this._localWorld),this._updateBoundingInfo(),this._absolutePosition.copyFromFloats(this._worldMatrix.m[12],this._worldMatrix.m[13],this._worldMatrix.m[14]),this.onAfterWorldMatrixUpdateObservable.notifyObservers(this),this._poseMatrix||(this._poseMatrix=e.Matrix.Invert(this._worldMatrix)),this._worldMatrix},r.prototype.registerAfterWorldMatrixUpdate=function(e){return this.onAfterWorldMatrixUpdateObservable.add(e),this},r.prototype.unregisterAfterWorldMatrixUpdate=function(e){return this.onAfterWorldMatrixUpdateObservable.removeCallback(e),this},r.prototype.setPositionWithLocalVector=function(t){return this.computeWorldMatrix(),this.position=e.Vector3.TransformNormal(t,this._localWorld),this},r.prototype.getPositionExpressedInLocalSpace=function(){this.computeWorldMatrix();var t=this._localWorld.clone();return t.invert(),e.Vector3.TransformNormal(this.position,t)},r.prototype.locallyTranslate=function(t){return this.computeWorldMatrix(!0),this.position=e.Vector3.TransformCoordinates(t,this._localWorld),this},r.prototype.lookAt=function(t,i,n,o,s){void 0===i&&(i=0),void 0===n&&(n=0),void 0===o&&(o=0),void 0===s&&(s=e.Space.LOCAL);var a=r._lookAtVectorCache,u=s===e.Space.LOCAL?this.position:this.getAbsolutePosition();t.subtractToRef(u,a);var l=-Math.atan2(a.z,a.x)-Math.PI/2,h=Math.sqrt(a.x*a.x+a.z*a.z),c=Math.atan2(a.y,h);return this.rotationQuaternion=this.rotationQuaternion||new e.Quaternion,e.Quaternion.RotationYawPitchRollToRef(l+i,c+n,o,this.rotationQuaternion),this},r.prototype.attachToBone=function(e,t){return this._meshToBoneReferal=t,this.parent=e,e.getWorldMatrix().determinant()<0&&(this.scalingDeterminant*=-1),this},r.prototype.detachFromBone=function(){return this.parent.getWorldMatrix().determinant()<0&&(this.scalingDeterminant*=-1),this._meshToBoneReferal=null,this.parent=null,this},r.prototype.isInFrustum=function(e){return this._boundingInfo.isInFrustum(e)},r.prototype.isCompletelyInFrustum=function(e){return this._boundingInfo.isCompletelyInFrustum(e)},r.prototype.intersectsMesh=function(e,t){return!(!this._boundingInfo||!e._boundingInfo)&&this._boundingInfo.intersects(e._boundingInfo,t)},r.prototype.intersectsPoint=function(e){return!!this._boundingInfo&&this._boundingInfo.intersectsPoint(e)},r.prototype.getPhysicsImpostor=function(){return this.physicsImpostor},r.prototype.getPositionInCameraSpace=function(t){return t||(t=this.getScene().activeCamera),e.Vector3.TransformCoordinates(this.absolutePosition,t.getViewMatrix())},r.prototype.getDistanceToCamera=function(e){return e||(e=this.getScene().activeCamera),this.absolutePosition.subtract(e.position).length()},r.prototype.applyImpulse=function(e,t){if(this.physicsImpostor)return this.physicsImpostor.applyImpulse(e,t),this},r.prototype.setPhysicsLinkWith=function(t,r,i,n){if(this.physicsImpostor&&t.physicsImpostor)return this.physicsImpostor.createJoint(t.physicsImpostor,e.PhysicsJoint.HingeJoint,{mainPivot:r,connectedPivot:i,nativeParams:n}),this},Object.defineProperty(r.prototype,"checkCollisions",{get:function(){return this._checkCollisions},set:function(e){this._checkCollisions=e,this.getScene().workerCollisions&&this.getScene().collisionCoordinator.onMeshUpdated(this)},enumerable:!0,configurable:!0}),r.prototype.moveWithCollisions=function(t){return this.getAbsolutePosition().subtractFromFloatsToRef(0,this.ellipsoid.y,0,this._oldPositionForCollisions),this._oldPositionForCollisions.addInPlace(this.ellipsoidOffset),this._collider||(this._collider=new e.Collider),this._collider.radius=this.ellipsoid,this.getScene().collisionCoordinator.getNewPosition(this._oldPositionForCollisions,t,this._collider,3,this,this._onCollisionPositionChange,this.uniqueId),this},r.prototype.createOrUpdateSubmeshesOctree=function(t,r){void 0===t&&(t=64),void 0===r&&(r=2),this._submeshesOctree||(this._submeshesOctree=new e.Octree(e.Octree.CreationFuncForSubMeshes,t,r)),this.computeWorldMatrix(!0);var i=this.getBoundingInfo().boundingBox;return this._submeshesOctree.update(i.minimumWorld,i.maximumWorld,this.subMeshes),this._submeshesOctree},r.prototype._collideForSubMesh=function(t,r,i){if(this._generatePointsArray(),!t._lastColliderWorldVertices||!t._lastColliderTransformMatrix.equals(r)){t._lastColliderTransformMatrix=r.clone(),t._lastColliderWorldVertices=[],t._trianglePlanes=[];for(var n=t.verticesStart,o=t.verticesStart+t.verticesCount,s=n;s<o;s++)t._lastColliderWorldVertices.push(e.Vector3.TransformCoordinates(this._positions[s],r))}return i._collide(t._trianglePlanes,t._lastColliderWorldVertices,this.getIndices(),t.indexStart,t.indexStart+t.indexCount,t.verticesStart,!!t.getMaterial()),i.collisionFound&&(i.collidedMesh=this),this},r.prototype._processCollisionsForSubMeshes=function(e,t){var r,i;if(this._submeshesOctree&&this.useOctreeForCollisions){var n=e.velocityWorldLength+Math.max(e.radius.x,e.radius.y,e.radius.z),o=this._submeshesOctree.intersects(e.basePointWorld,n);i=o.length,r=o.data}else r=this.subMeshes,i=r.length;for(var s=0;s<i;s++){var a=r[s];i>1&&!a._checkCollision(e)||this._collideForSubMesh(a,t,e)}return this},r.prototype._checkCollision=function(t){return 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),this):this},r.prototype._generatePointsArray=function(){return!1},r.prototype.intersects=function(t,r){var i=new e.PickingInfo;if(!(this.subMeshes&&this._boundingInfo&&t.intersectsSphere(this._boundingInfo.boundingSphere)&&t.intersectsBox(this._boundingInfo.boundingBox)))return i;if(!this._generatePointsArray())return i;var n,o,s=null;if(this._submeshesOctree&&this.useOctreeForPicking){var a=e.Ray.Transform(t,this.getWorldMatrix()),u=this._submeshesOctree.intersectsRay(a);o=u.length,n=u.data}else n=this.subMeshes,o=n.length;for(var l=0;l<o;l++){var h=n[l];if(!(o>1)||h.canIntersects(t)){var c=h.intersects(t,this._positions,this.getIndices(),r);if(c&&(r||!s||c.distance<s.distance)&&(s=c,s.subMeshId=l,r))break}}if(s){var f=this.getWorldMatrix(),d=e.Vector3.TransformCoordinates(t.origin,f),p=t.direction.clone();p=p.scale(s.distance);var g=e.Vector3.TransformNormal(p,f),_=d.add(g);return i.hit=!0,i.distance=e.Vector3.Distance(d,_),i.pickedPoint=_,i.pickedMesh=this,i.bu=s.bu,i.bv=s.bv,i.faceId=s.faceId,i.subMeshId=s.subMeshId,i}return i},r.prototype.clone=function(e,t,r){return null},r.prototype.releaseSubMeshes=function(){if(this.subMeshes)for(;this.subMeshes.length;)this.subMeshes[0].dispose();else this.subMeshes=new Array;return this},r.prototype.dispose=function(e){var r,i=this;for(this.actionManager&&(this.actionManager.dispose(),this.actionManager=null),this.skeleton=null,this.getScene().stopAnimation(this),this.physicsImpostor&&this.physicsImpostor.dispose(),r=0;r<this._intersectionsInProgress.length;r++){var n=this._intersectionsInProgress[r],o=n._intersectionsInProgress.indexOf(this);n._intersectionsInProgress.splice(o,1)}this._intersectionsInProgress=[],this.getScene().lights.forEach((function(e){var t=e.includedOnlyMeshes.indexOf(i);-1!==t&&e.includedOnlyMeshes.splice(t,1),-1!==(t=e.excludedMeshes.indexOf(i))&&e.excludedMeshes.splice(t,1);var r=e.getShadowGenerator();if(r){var n=r.getShadowMap();-1!==(t=n.renderList.indexOf(i))&&n.renderList.splice(t,1)}})),this._edgesRenderer&&(this._edgesRenderer.dispose(),this._edgesRenderer=null),"InstancedMesh"!==this.getClassName()&&this.releaseSubMeshes();var s=this.getScene().selectionOctree;if(s){var r=s.dynamicContent.indexOf(this);-1!==r&&s.dynamicContent.splice(r,1)}if(this.getScene().getEngine().wipeCaches(),this.getScene().removeMesh(this),e){var a=this.getChildMeshes(!0);for(r=0;r<a.length;r++){var u=a[r];u.parent=null,u.computeWorldMatrix(!0)}}else{for(r=0;r<this.getScene().particleSystems.length;r++)this.getScene().particleSystems[r].emitter===this&&(this.getScene().particleSystems[r].dispose(),r--);var l=this.getDescendants(!0);for(r=0;r<l.length;r++)l[r].dispose()}this._facetDataEnabled&&this.disableFacetData(),this.onAfterWorldMatrixUpdateObservable.clear(),this.onCollideObservable.clear(),this.onCollisionPositionChangeObservable.clear(),this._isDisposed=!0,t.prototype.dispose.call(this)},r.prototype.getDirection=function(t){var r=e.Vector3.Zero();return this.getDirectionToRef(t,r),r},r.prototype.getDirectionToRef=function(t,r){return e.Vector3.TransformNormalToRef(t,this.getWorldMatrix(),r),this},r.prototype.setPivotPoint=function(t,r){void 0===r&&(r=e.Space.LOCAL),0==this.getScene().getRenderId()&&this.computeWorldMatrix(!0);var i=this.getWorldMatrix();if(r==e.Space.WORLD){var n=e.Tmp.Matrix[0];i.invertToRef(n),t=e.Vector3.TransformCoordinates(t,n)}return e.Vector3.TransformCoordinatesToRef(t,i,this.position),this._pivotMatrix.m[12]=-t.x,this._pivotMatrix.m[13]=-t.y,this._pivotMatrix.m[14]=-t.z,this._cache.pivotMatrixUpdated=!0,this},r.prototype.getPivotPoint=function(){var t=e.Vector3.Zero();return this.getPivotPointToRef(t),t},r.prototype.getPivotPointToRef=function(e){return e.x=-this._pivotMatrix.m[12],e.y=-this._pivotMatrix.m[13],e.z=-this._pivotMatrix.m[14],this},r.prototype.getAbsolutePivotPoint=function(){var t=e.Vector3.Zero();return this.getAbsolutePivotPointToRef(t),t},r.prototype.setParent=function(t){var r=this,i=t;if(null==t){var n=e.Tmp.Quaternion[0],o=e.Tmp.Vector3[0],s=e.Tmp.Vector3[1];r.getWorldMatrix().decompose(s,n,o),r.rotationQuaternion?r.rotationQuaternion.copyFrom(n):n.toEulerAnglesToRef(r.rotation),r.position.x=o.x,r.position.y=o.y,r.position.z=o.z}else{var n=e.Tmp.Quaternion[0],o=e.Tmp.Vector3[0],s=e.Tmp.Vector3[1],a=e.Tmp.Matrix[0],u=e.Tmp.Matrix[1];i.getWorldMatrix().decompose(s,n,o),n.toRotationMatrix(a),u.setTranslation(o),u.multiplyToRef(a,a);var l=e.Matrix.Invert(a),h=r.getWorldMatrix().multiply(l);h.decompose(s,n,o),r.rotationQuaternion?r.rotationQuaternion.copyFrom(n):n.toEulerAnglesToRef(r.rotation),l=e.Matrix.Invert(i.getWorldMatrix());var h=r.getWorldMatrix().multiply(l);h.decompose(s,n,o),r.position.x=o.x,r.position.y=o.y,r.position.z=o.z}return r.parent=i,this},r.prototype.addChild=function(e){return e.setParent(this),this},r.prototype.removeChild=function(e){return e.setParent(null),this},r.prototype.getAbsolutePivotPointToRef=function(t){return t.x=this._pivotMatrix.m[12],t.y=this._pivotMatrix.m[13],t.z=this._pivotMatrix.m[14],this.getPivotPointToRef(t),e.Vector3.TransformCoordinatesToRef(t,this.getWorldMatrix(),t),this},r.prototype._initFacetData=function(){this._facetNormals||(this._facetNormals=new Array),this._facetPositions||(this._facetPositions=new Array),
- this._facetPartitioning||(this._facetPartitioning=new Array),this._facetNb=this.getIndices().length/3,this._partitioningSubdivisions=this._partitioningSubdivisions?this._partitioningSubdivisions:10,this._partitioningBBoxRatio=this._partitioningBBoxRatio?this._partitioningBBoxRatio:1.01;for(var t=0;t<this._facetNb;t++)this._facetNormals[t]=e.Vector3.Zero(),this._facetPositions[t]=e.Vector3.Zero();return this._facetDataEnabled=!0,this},r.prototype.updateFacetData=function(){this._facetDataEnabled||this._initFacetData();var t=this.getVerticesData(e.VertexBuffer.PositionKind),r=this.getIndices(),i=this.getVerticesData(e.VertexBuffer.NormalKind),n=this.getBoundingInfo();this._bbSize.x=n.maximum.x-n.minimum.x>e.Epsilon?n.maximum.x-n.minimum.x:e.Epsilon,this._bbSize.y=n.maximum.y-n.minimum.y>e.Epsilon?n.maximum.y-n.minimum.y:e.Epsilon,this._bbSize.z=n.maximum.z-n.minimum.z>e.Epsilon?n.maximum.z-n.minimum.z:e.Epsilon;var o=this._bbSize.x>this._bbSize.y?this._bbSize.x:this._bbSize.y;return o=o>this._bbSize.z?o:this._bbSize.z,this._subDiv.max=this._partitioningSubdivisions,this._subDiv.X=Math.floor(this._subDiv.max*this._bbSize.x/o),this._subDiv.Y=Math.floor(this._subDiv.max*this._bbSize.y/o),this._subDiv.Z=Math.floor(this._subDiv.max*this._bbSize.z/o),this._subDiv.X=this._subDiv.X<1?1:this._subDiv.X,this._subDiv.Y=this._subDiv.Y<1?1:this._subDiv.Y,this._subDiv.Z=this._subDiv.Z<1?1:this._subDiv.Z,this._facetParameters.facetNormals=this.getFacetLocalNormals(),this._facetParameters.facetPositions=this.getFacetLocalPositions(),this._facetParameters.facetPartitioning=this.getFacetLocalPartitioning(),this._facetParameters.bInfo=n,this._facetParameters.bbSize=this._bbSize,this._facetParameters.subDiv=this._subDiv,this._facetParameters.ratio=this.partitioningBBoxRatio,e.VertexData.ComputeNormals(t,r,i,this._facetParameters),this},r.prototype.getFacetLocalNormals=function(){return this._facetNormals||this.updateFacetData(),this._facetNormals},r.prototype.getFacetLocalPositions=function(){return this._facetPositions||this.updateFacetData(),this._facetPositions},r.prototype.getFacetLocalPartitioning=function(){return this._facetPartitioning||this.updateFacetData(),this._facetPartitioning},r.prototype.getFacetPosition=function(t){var r=e.Vector3.Zero();return this.getFacetPositionToRef(t,r),r},r.prototype.getFacetPositionToRef=function(t,r){var i=this.getFacetLocalPositions()[t],n=this.getWorldMatrix();return e.Vector3.TransformCoordinatesToRef(i,n,r),this},r.prototype.getFacetNormal=function(t){var r=e.Vector3.Zero();return this.getFacetNormalToRef(t,r),r},r.prototype.getFacetNormalToRef=function(t,r){var i=this.getFacetLocalNormals()[t];return e.Vector3.TransformNormalToRef(i,this.getWorldMatrix(),r),this},r.prototype.getFacetsAtLocalCoordinates=function(e,t,r){var i=this.getBoundingInfo(),n=Math.floor((e-i.minimum.x*this._partitioningBBoxRatio)*this._subDiv.X*this._partitioningBBoxRatio/this._bbSize.x),o=Math.floor((t-i.minimum.y*this._partitioningBBoxRatio)*this._subDiv.Y*this._partitioningBBoxRatio/this._bbSize.y),s=Math.floor((r-i.minimum.z*this._partitioningBBoxRatio)*this._subDiv.Z*this._partitioningBBoxRatio/this._bbSize.z);return n<0||n>this._subDiv.max||o<0||o>this._subDiv.max||s<0||s>this._subDiv.max?null:this._facetPartitioning[n+this._subDiv.max*o+this._subDiv.max*this._subDiv.max*s]},r.prototype.getClosestFacetAtCoordinates=function(t,r,i,n,o,s){void 0===o&&(o=!1),void 0===s&&(s=!0);var a=this.getWorldMatrix(),u=e.Tmp.Matrix[5];a.invertToRef(u);var l=e.Tmp.Vector3[8],h=null;return e.Vector3.TransformCoordinatesFromFloatsToRef(t,r,i,u,l),h=this.getClosestFacetAtLocalCoordinates(l.x,l.y,l.z,n,o,s),n&&e.Vector3.TransformCoordinatesFromFloatsToRef(n.x,n.y,n.z,a,n),h},r.prototype.getClosestFacetAtLocalCoordinates=function(e,t,r,i,n,o){void 0===n&&(n=!1),void 0===o&&(o=!0);var s=null,a=0,u=0,l=0,h=0,c=0,f=0,d=0,p=0,g=this.getFacetLocalPositions(),_=this.getFacetLocalNormals(),m=this.getFacetsAtLocalCoordinates(e,t,r);if(!m)return null;for(var v,y,A,T=Number.MAX_VALUE,E=T,b=0;b<m.length;b++)v=m[b],y=_[v],A=g[v],h=(e-A.x)*y.x+(t-A.y)*y.y+(r-A.z)*y.z,(!n||n&&o&&h>=0||n&&!o&&h<=0)&&(h=y.x*A.x+y.y*A.y+y.z*A.z,c=-(y.x*e+y.y*t+y.z*r-h)/(y.x*y.x+y.y*y.y+y.z*y.z),f=e+y.x*c,d=t+y.y*c,p=r+y.z*c,a=f-e,u=d-t,l=p-r,(E=a*a+u*u+l*l)<T&&(T=E,s=v,i&&(i.x=f,i.y=d,i.z=p)));return s},r.prototype.getFacetDataParameters=function(){return this._facetParameters},r.prototype.disableFacetData=function(){return this._facetDataEnabled&&(this._facetDataEnabled=!1,this._facetPositions=null,this._facetNormals=null,this._facetPartitioning=null,this._facetParameters=null),this},r.prototype.createNormals=function(t){var r,i=this.getVerticesData(e.VertexBuffer.PositionKind),n=this.getIndices();r=this.isVerticesDataPresent(e.VertexBuffer.NormalKind)?this.getVerticesData(e.VertexBuffer.NormalKind):[],e.VertexData.ComputeNormals(i,n,r,{useRightHandedSystem:this.getScene().useRightHandedSystem}),this.setVerticesData(e.VertexBuffer.NormalKind,r,t)},r._BILLBOARDMODE_NONE=0,r._BILLBOARDMODE_X=1,r._BILLBOARDMODE_Y=2,r._BILLBOARDMODE_Z=4,r._BILLBOARDMODE_ALL=7,r._rotationAxisCache=new e.Quaternion,r._lookAtVectorCache=new e.Vector3(0,0,0),r})(e.Node);e.AbstractMesh=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(i,n){var o=t.call(this,i,n)||this;return o.diffuse=new e.Color3(1,1,1),o.specular=new e.Color3(1,1,1),o.intensity=1,o.range=Number.MAX_VALUE,o._photometricScale=1,o._intensityMode=r.INTENSITYMODE_AUTOMATIC,o._radius=1e-5,o.renderPriority=0,o.shadowEnabled=!0,o._excludeWithLayerMask=0,o._includeOnlyWithLayerMask=0,o._lightmapMode=0,o._excludedMeshesIds=new Array,o._includedOnlyMeshesIds=new Array,o.getScene().addLight(o),o._uniformBuffer=new e.UniformBuffer(o.getScene().getEngine()),o._buildUniformLayout(),o.includedOnlyMeshes=new Array,o.excludedMeshes=new Array,o._resyncMeshes(),o}return __extends(r,t),Object.defineProperty(r,"LIGHTMAP_DEFAULT",{get:function(){return r._LIGHTMAP_DEFAULT},enumerable:!0,configurable:!0}),Object.defineProperty(r,"LIGHTMAP_SPECULAR",{get:function(){return r._LIGHTMAP_SPECULAR},enumerable:!0,configurable:!0}),Object.defineProperty(r,"LIGHTMAP_SHADOWSONLY",{get:function(){return r._LIGHTMAP_SHADOWSONLY},enumerable:!0,configurable:!0}),Object.defineProperty(r,"INTENSITYMODE_AUTOMATIC",{get:function(){return r._INTENSITYMODE_AUTOMATIC},enumerable:!0,configurable:!0}),Object.defineProperty(r,"INTENSITYMODE_LUMINOUSPOWER",{get:function(){return r._INTENSITYMODE_LUMINOUSPOWER},enumerable:!0,configurable:!0}),Object.defineProperty(r,"INTENSITYMODE_LUMINOUSINTENSITY",{get:function(){return r._INTENSITYMODE_LUMINOUSINTENSITY},enumerable:!0,configurable:!0}),Object.defineProperty(r,"INTENSITYMODE_ILLUMINANCE",{get:function(){return r._INTENSITYMODE_ILLUMINANCE},enumerable:!0,configurable:!0}),Object.defineProperty(r,"INTENSITYMODE_LUMINANCE",{get:function(){return r._INTENSITYMODE_LUMINANCE},enumerable:!0,configurable:!0}),Object.defineProperty(r,"LIGHTTYPEID_POINTLIGHT",{get:function(){return r._LIGHTTYPEID_POINTLIGHT},enumerable:!0,configurable:!0}),Object.defineProperty(r,"LIGHTTYPEID_DIRECTIONALLIGHT",{get:function(){return r._LIGHTTYPEID_DIRECTIONALLIGHT},enumerable:!0,configurable:!0}),Object.defineProperty(r,"LIGHTTYPEID_SPOTLIGHT",{get:function(){return r._LIGHTTYPEID_SPOTLIGHT},enumerable:!0,configurable:!0}),Object.defineProperty(r,"LIGHTTYPEID_HEMISPHERICLIGHT",{get:function(){return r._LIGHTTYPEID_HEMISPHERICLIGHT},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"intensityMode",{get:function(){return this._intensityMode},set:function(e){this._intensityMode=e,this._computePhotometricScale()},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"radius",{get:function(){return this._radius},set:function(e){this._radius=e,this._computePhotometricScale()},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"includedOnlyMeshes",{get:function(){return this._includedOnlyMeshes},set:function(e){this._includedOnlyMeshes=e,this._hookArrayForIncludedOnly(e)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"excludedMeshes",{get:function(){return this._excludedMeshes},set:function(e){this._excludedMeshes=e,this._hookArrayForExcluded(e)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"excludeWithLayerMask",{get:function(){return this._excludeWithLayerMask},set:function(e){this._excludeWithLayerMask=e,this._resyncMeshes()},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"includeOnlyWithLayerMask",{get:function(){return this._includeOnlyWithLayerMask},set:function(e){this._includeOnlyWithLayerMask=e,this._resyncMeshes()},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"lightmapMode",{get:function(){return this._lightmapMode},set:function(e){this._lightmapMode!==e&&(this._lightmapMode=e,this._markMeshesAsLightDirty())},enumerable:!0,configurable:!0}),r.prototype._buildUniformLayout=function(){},r.prototype.getClassName=function(){return"Light"},r.prototype.toString=function(e){var t="Name: "+this.name;if(t+=", type: "+["Point","Directional","Spot","Hemispheric"][this.getTypeID()],this.animations)for(var r=0;r<this.animations.length;r++)t+=", animation[0]: "+this.animations[r].toString(e);return t},r.prototype.setEnabled=function(e){t.prototype.setEnabled.call(this,e),this._resyncMeshes()},r.prototype.getShadowGenerator=function(){return this._shadowGenerator},r.prototype.getAbsolutePosition=function(){return e.Vector3.Zero()},r.prototype.transferToEffect=function(e,t){},r.prototype._getWorldMatrix=function(){return e.Matrix.Identity()},r.prototype.canAffectMesh=function(e){return!e||!(this.includedOnlyMeshes&&this.includedOnlyMeshes.length>0&&-1===this.includedOnlyMeshes.indexOf(e))&&(!(this.excludedMeshes&&this.excludedMeshes.length>0&&-1!==this.excludedMeshes.indexOf(e))&&((0===this.includeOnlyWithLayerMask||0!=(this.includeOnlyWithLayerMask&e.layerMask))&&!(0!==this.excludeWithLayerMask&&this.excludeWithLayerMask&e.layerMask)))},r.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},r.compareLightsPriority=function(e,t){return e.shadowEnabled!==t.shadowEnabled?(t.shadowEnabled?1:0)-(e.shadowEnabled?1:0):t.renderPriority-e.renderPriority},r.prototype.dispose=function(){this._shadowGenerator&&(this._shadowGenerator.dispose(),this._shadowGenerator=null),this.getScene().stopAnimation(this);for(var e=0,r=this.getScene().meshes;e<r.length;e++){r[e]._removeLightSource(this)}this._uniformBuffer.dispose(),this.getScene().removeLight(this),t.prototype.dispose.call(this)},r.prototype.getTypeID=function(){return 0},r.prototype.getScaledIntensity=function(){return this._photometricScale*this.intensity},r.prototype.clone=function(t){return e.SerializationHelper.Clone(r.GetConstructorFromName(this.getTypeID(),t,this.getScene()),this)},r.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},r.GetConstructorFromName=function(t,r,i){switch(t){case 0:return function(){return new e.PointLight(r,e.Vector3.Zero(),i)};case 1:return function(){return new e.DirectionalLight(r,e.Vector3.Zero(),i)};case 2:return function(){return new e.SpotLight(r,e.Vector3.Zero(),e.Vector3.Zero(),0,0,i)};case 3:return function(){return new e.HemisphericLight(r,e.Vector3.Zero(),i)}}},r.Parse=function(t,i){var n=e.SerializationHelper.Parse(r.GetConstructorFromName(t.type,t.name,i),t,i);if(t.excludedMeshesIds&&(n._excludedMeshesIds=t.excludedMeshesIds),t.includedOnlyMeshesIds&&(n._includedOnlyMeshesIds=t.includedOnlyMeshesIds),t.parentId&&(n._waitingParentId=t.parentId),t.animations){for(var o=0;o<t.animations.length;o++){var s=t.animations[o];n.animations.push(e.Animation.Parse(s))}e.Node.ParseAnimationRanges(n,t,i)}return t.autoAnimate&&i.beginAnimation(n,t.autoAnimateFrom,t.autoAnimateTo,t.autoAnimateLoop,t.autoAnimateSpeed||1),n},r.prototype._hookArrayForExcluded=function(e){var t=this,r=e.push;e.push=function(){for(var i=[],n=0;n<arguments.length;n++)i[n]=arguments[n];for(var o=r.apply(e,i),s=0,a=i;s<a.length;s++){a[s]._resyncLighSource(t)}return o};var i=e.splice;e.splice=function(r,n){for(var o=i.apply(e,[r,n]),s=0,a=o;s<a.length;s++){a[s]._resyncLighSource(t)}return o};for(var n=0,o=e;n<o.length;n++){o[n]._resyncLighSource(this)}},r.prototype._hookArrayForIncludedOnly=function(e){var t=this,r=e.push;e.push=function(){for(var i=[],n=0;n<arguments.length;n++)i[n]=arguments[n];var o=r.apply(e,i);return t._resyncMeshes(),o};var i=e.splice;e.splice=function(r,n){var o=i.apply(e,[r,n]);return t._resyncMeshes(),o},this._resyncMeshes()},r.prototype._resyncMeshes=function(){for(var e=0,t=this.getScene().meshes;e<t.length;e++){t[e]._resyncLighSource(this)}},r.prototype._markMeshesAsLightDirty=function(){for(var e=0,t=this.getScene().meshes;e<t.length;e++){var r=t[e];-1!==r._lightSources.indexOf(this)&&r._markSubMeshesAsLightDirty()}},r.prototype._computePhotometricScale=function(){this._photometricScale=this._getPhotometricScale(),this.getScene().resetCachedMaterial()},r.prototype._getPhotometricScale=function(){var e=0,t=this.getTypeID(),i=this.intensityMode;switch(i===r.INTENSITYMODE_AUTOMATIC&&(i=t===r.LIGHTTYPEID_DIRECTIONALLIGHT?r.INTENSITYMODE_ILLUMINANCE:r.INTENSITYMODE_LUMINOUSINTENSITY),t){case r.LIGHTTYPEID_POINTLIGHT:case r.LIGHTTYPEID_SPOTLIGHT:switch(i){case r.INTENSITYMODE_LUMINOUSPOWER:e=1/(4*Math.PI);break;case r.INTENSITYMODE_LUMINOUSINTENSITY:e=1;break;case r.INTENSITYMODE_LUMINANCE:e=this.radius*this.radius}break;case r.LIGHTTYPEID_DIRECTIONALLIGHT:switch(i){case r.INTENSITYMODE_ILLUMINANCE:e=1;break;case r.INTENSITYMODE_LUMINANCE:var n=this.radius;n=Math.max(n,.001);e=2*Math.PI*(1-Math.cos(n))}break;case r.LIGHTTYPEID_HEMISPHERICLIGHT:e=1}return e},r.prototype._reorderLightsInScene=function(){var e=this.getScene();0!=this.renderPriority&&(e.requireLightSorting=!0),this.getScene().sortLightsByPriority()},r._LIGHTMAP_DEFAULT=0,r._LIGHTMAP_SPECULAR=1,r._LIGHTMAP_SHADOWSONLY=2,r._INTENSITYMODE_AUTOMATIC=0,r._INTENSITYMODE_LUMINOUSPOWER=1,r._INTENSITYMODE_LUMINOUSINTENSITY=2,r._INTENSITYMODE_ILLUMINANCE=3,r._INTENSITYMODE_LUMINANCE=4,r._LIGHTTYPEID_POINTLIGHT=0,r._LIGHTTYPEID_DIRECTIONALLIGHT=1,r._LIGHTTYPEID_SPOTLIGHT=2,r._LIGHTTYPEID_HEMISPHERICLIGHT=3,__decorate([e.serializeAsColor3()],r.prototype,"diffuse",void 0),__decorate([e.serializeAsColor3()],r.prototype,"specular",void 0),__decorate([e.serialize()],r.prototype,"intensity",void 0),__decorate([e.serialize()],r.prototype,"range",void 0),__decorate([e.serialize()],r.prototype,"intensityMode",null),__decorate([e.serialize()],r.prototype,"radius",null),__decorate([e.serialize()],r.prototype,"_renderPriority",void 0),__decorate([e.expandToProperty("_reorderLightsInScene")],r.prototype,"renderPriority",void 0),__decorate([e.serialize()],r.prototype,"shadowEnabled",void 0),__decorate([e.serialize("excludeWithLayerMask")],r.prototype,"_excludeWithLayerMask",void 0),__decorate([e.serialize("includeOnlyWithLayerMask")],r.prototype,"_includeOnlyWithLayerMask",void 0),__decorate([e.serialize("lightmapMode")],r.prototype,"_lightmapMode",void 0),r})(e.Node);e.Light=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(i,n,o){var s=t.call(this,i,o)||this;return s.upVector=e.Vector3.Up(),s.orthoLeft=null,s.orthoRight=null,s.orthoBottom=null,s.orthoTop=null,s.fov=.8,s.minZ=1,s.maxZ=1e4,s.inertia=.9,s.mode=r.PERSPECTIVE_CAMERA,s.isIntermediate=!1,s.viewport=new e.Viewport(0,0,1,1),s.layerMask=268435455,s.fovMode=r.FOVMODE_VERTICAL_FIXED,s.cameraRigMode=r.RIG_MODE_NONE,s._rigCameras=new Array,s._webvrViewMatrix=e.Matrix.Identity(),s.customRenderTargets=new Array,s.onViewMatrixChangedObservable=new e.Observable,s.onProjectionMatrixChangedObservable=new e.Observable,s.onAfterCheckInputsObservable=new e.Observable,s._computedViewMatrix=e.Matrix.Identity(),s._projectionMatrix=new e.Matrix,s._doNotComputeProjectionMatrix=!1,s._postProcesses=new Array,s._transformMatrix=e.Matrix.Zero(),s._activeMeshes=new e.SmartArray(256),s._globalPosition=e.Vector3.Zero(),s._refreshFrustumPlanes=!0,s.getScene().addCamera(s),s.getScene().activeCamera||(s.getScene().activeCamera=s),s.position=n,s}return __extends(r,t),Object.defineProperty(r,"PERSPECTIVE_CAMERA",{get:function(){return r._PERSPECTIVE_CAMERA},enumerable:!0,configurable:!0}),Object.defineProperty(r,"ORTHOGRAPHIC_CAMERA",{get:function(){return r._ORTHOGRAPHIC_CAMERA},enumerable:!0,configurable:!0}),Object.defineProperty(r,"FOVMODE_VERTICAL_FIXED",{get:function(){return r._FOVMODE_VERTICAL_FIXED},enumerable:!0,configurable:!0}),Object.defineProperty(r,"FOVMODE_HORIZONTAL_FIXED",{get:function(){return r._FOVMODE_HORIZONTAL_FIXED},enumerable:!0,configurable:!0}),Object.defineProperty(r,"RIG_MODE_NONE",{get:function(){return r._RIG_MODE_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(r,"RIG_MODE_STEREOSCOPIC_ANAGLYPH",{get:function(){return r._RIG_MODE_STEREOSCOPIC_ANAGLYPH},enumerable:!0,configurable:!0}),Object.defineProperty(r,"RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL",{get:function(){return r._RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL},enumerable:!0,configurable:!0}),Object.defineProperty(r,"RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED",{get:function(){return r._RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED},enumerable:!0,configurable:!0}),Object.defineProperty(r,"RIG_MODE_STEREOSCOPIC_OVERUNDER",{get:function(){return r._RIG_MODE_STEREOSCOPIC_OVERUNDER},enumerable:!0,configurable:!0}),Object.defineProperty(r,"RIG_MODE_VR",{get:function(){return r._RIG_MODE_VR},enumerable:!0,configurable:!0}),Object.defineProperty(r,"RIG_MODE_WEBVR",{get:function(){return r._RIG_MODE_WEBVR},enumerable:!0,configurable:!0}),r.prototype.getClassName=function(){return"Camera"},r.prototype.toString=function(e){var t="Name: "+this.name;if(t+=", type: "+this.getClassName(),this.animations)for(var r=0;r<this.animations.length;r++)t+=", animation[0]: "+this.animations[r].toString(e);return t},Object.defineProperty(r.prototype,"globalPosition",{get:function(){return this._globalPosition},enumerable:!0,configurable:!0}),r.prototype.getActiveMeshes=function(){return this._activeMeshes},r.prototype.isActiveMesh=function(e){return-1!==this._activeMeshes.indexOf(e)},r.prototype._initCache=function(){t.prototype._initCache.call(this),this._cache.position=new e.Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.upVector=new e.Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.mode=void 0,this._cache.minZ=void 0,this._cache.maxZ=void 0,this._cache.fov=void 0,this._cache.fovMode=void 0,this._cache.aspectRatio=void 0,this._cache.orthoLeft=void 0,this._cache.orthoRight=void 0,this._cache.orthoBottom=void 0,this._cache.orthoTop=void 0,this._cache.renderWidth=void 0,this._cache.renderHeight=void 0},r.prototype._updateCache=function(e){e||t.prototype._updateCache.call(this);var r=this.getEngine();this._cache.position.copyFrom(this.position),this._cache.upVector.copyFrom(this.upVector),this._cache.mode=this.mode,this._cache.minZ=this.minZ,this._cache.maxZ=this.maxZ,this._cache.fov=this.fov,this._cache.fovMode=this.fovMode,this._cache.aspectRatio=r.getAspectRatio(this),this._cache.orthoLeft=this.orthoLeft,this._cache.orthoRight=this.orthoRight,this._cache.orthoBottom=this.orthoBottom,this._cache.orthoTop=this.orthoTop,this._cache.renderWidth=r.getRenderWidth(),this._cache.renderHeight=r.getRenderHeight()},r.prototype._updateFromScene=function(){this.updateCache(),this.update()},r.prototype._isSynchronized=function(){return this._isSynchronizedViewMatrix()&&this._isSynchronizedProjectionMatrix()},r.prototype._isSynchronizedViewMatrix=function(){return!!t.prototype._isSynchronized.call(this)&&(this._cache.position.equals(this.position)&&this._cache.upVector.equals(this.upVector)&&this.isSynchronizedWithParent())},r.prototype._isSynchronizedProjectionMatrix=function(){var e=this._cache.mode===this.mode&&this._cache.minZ===this.minZ&&this._cache.maxZ===this.maxZ;if(!e)return!1;var t=this.getEngine();return e=this.mode===r.PERSPECTIVE_CAMERA?this._cache.fov===this.fov&&this._cache.fovMode===this.fovMode&&this._cache.aspectRatio===t.getAspectRatio(this):this._cache.orthoLeft===this.orthoLeft&&this._cache.orthoRight===this.orthoRight&&this._cache.orthoBottom===this.orthoBottom&&this._cache.orthoTop===this.orthoTop&&this._cache.renderWidth===t.getRenderWidth()&&this._cache.renderHeight===t.getRenderHeight()},r.prototype.attachControl=function(e,t){},r.prototype.detachControl=function(e){},r.prototype.update=function(){this.cameraRigMode!==r.RIG_MODE_NONE&&this._updateRigCameras(),this._checkInputs()},r.prototype._checkInputs=function(){this.onAfterCheckInputsObservable.notifyObservers(this)},Object.defineProperty(r.prototype,"rigCameras",{get:function(){return this._rigCameras},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"rigPostProcess",{get:function(){return this._rigPostProcess},enumerable:!0,configurable:!0}),r.prototype._cascadePostProcessesToRigCams=function(){this._postProcesses.length>0&&this._postProcesses[0].markTextureDirty();for(var t=0,r=this._rigCameras.length;t<r;t++){var i=this._rigCameras[t],n=i._rigPostProcess;if(n){n instanceof e.PassPostProcess&&(i.isIntermediate=0===this._postProcesses.length),i._postProcesses=this._postProcesses.slice(0).concat(n),n.markTextureDirty()}else i._postProcesses=this._postProcesses.slice(0)}},r.prototype.attachPostProcess=function(t,r){return void 0===r&&(r=null),!t.isReusable()&&this._postProcesses.indexOf(t)>-1?(e.Tools.Error("You're trying to reuse a post process not defined as reusable."),0):(null==r||r<0?this._postProcesses.push(t):this._postProcesses.splice(r,0,t),this._cascadePostProcessesToRigCams(),this._postProcesses.indexOf(t))},r.prototype.detachPostProcess=function(e,t){void 0===t&&(t=null);var r,i,n=[];if(t)for(t=t instanceof Array?t:[t],r=t.length-1;r>=0;r--)this._postProcesses[t[r]]===e?(i=t[r],this._postProcesses.splice(i,1)):n.push(r);else{var o=this._postProcesses.indexOf(e);-1!==o&&this._postProcesses.splice(o,1)}return this._cascadePostProcessesToRigCams(),n},r.prototype.getWorldMatrix=function(){return this._worldMatrix||(this._worldMatrix=e.Matrix.Identity()),this.getViewMatrix().invertToRef(this._worldMatrix),this._worldMatrix},r.prototype._getViewMatrix=function(){return e.Matrix.Identity()},r.prototype.getViewMatrix=function(t){return!t&&this._isSynchronizedViewMatrix()?this._computedViewMatrix:(this._computedViewMatrix=this._getViewMatrix(),this._currentRenderId=this.getScene().getRenderId(),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._cameraRigParams&&this._cameraRigParams.vrPreViewMatrix&&this._computedViewMatrix.multiplyToRef(this._cameraRigParams.vrPreViewMatrix,this._computedViewMatrix),this.onViewMatrixChangedObservable.notifyObservers(this),this._computedViewMatrix)},r.prototype.freezeProjectionMatrix=function(e){this._doNotComputeProjectionMatrix=!0,void 0!==e&&(this._projectionMatrix=e)},r.prototype.unfreezeProjectionMatrix=function(){this._doNotComputeProjectionMatrix=!1},r.prototype.getProjectionMatrix=function(t){if(this._doNotComputeProjectionMatrix||!t&&this._isSynchronizedProjectionMatrix())return this._projectionMatrix;this._refreshFrustumPlanes=!0;var i=this.getEngine(),n=this.getScene();if(this.mode===r.PERSPECTIVE_CAMERA)this.minZ<=0&&(this.minZ=.1),n.useRightHandedSystem?e.Matrix.PerspectiveFovRHToRef(this.fov,i.getAspectRatio(this),this.minZ,this.maxZ,this._projectionMatrix,this.fovMode===r.FOVMODE_VERTICAL_FIXED):e.Matrix.PerspectiveFovLHToRef(this.fov,i.getAspectRatio(this),this.minZ,this.maxZ,this._projectionMatrix,this.fovMode===r.FOVMODE_VERTICAL_FIXED);else{var o=i.getRenderWidth()/2,s=i.getRenderHeight()/2;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)}return this.onProjectionMatrixChangedObservable.notifyObservers(this),this._projectionMatrix},r.prototype.getTranformationMatrix=function(){return this._computedViewMatrix.multiplyToRef(this._projectionMatrix,this._transformMatrix),this._transformMatrix},r.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)},r.prototype.isInFrustum=function(e){return this.updateFrustumPlanes(),e.isInFrustum(this._frustumPlanes)},r.prototype.isCompletelyInFrustum=function(e){return this.updateFrustumPlanes(),e.isCompletelyInFrustum(this._frustumPlanes)},r.prototype.getForwardRay=function(t,r,i){void 0===t&&(t=100),r||(r=this.getWorldMatrix()),i||(i=this.position);var n=new e.Vector3(0,0,1),o=e.Vector3.TransformNormal(n,r),s=e.Vector3.Normalize(o);return new e.Ray(i,s,t)},r.prototype.dispose=function(){for(this.onViewMatrixChangedObservable.clear(),this.onProjectionMatrixChangedObservable.clear(),this.onAfterCheckInputsObservable.clear(),this.inputs.clear(),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);for(var e=this.customRenderTargets.length;--e>=0;)this.customRenderTargets[e].dispose();this.customRenderTargets=[],this._activeMeshes.dispose(),t.prototype.dispose.call(this)},Object.defineProperty(r.prototype,"leftCamera",{get:function(){if(!(this._rigCameras.length<1))return this._rigCameras[0]},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"rightCamera",{get:function(){if(!(this._rigCameras.length<2))return this._rigCameras[1]},enumerable:!0,configurable:!0}),r.prototype.getLeftTarget=function(){if(!(this._rigCameras.length<1))return this._rigCameras[0].getTarget()},r.prototype.getRightTarget=function(){if(!(this._rigCameras.length<2))return this._rigCameras[1].getTarget()},r.prototype.setCameraRigMode=function(t,i){for(;this._rigCameras.length>0;)this._rigCameras.pop().dispose();switch(this.cameraRigMode=t,this._cameraRigParams={},this._cameraRigParams.interaxialDistance=i.interaxialDistance||.0637,this._cameraRigParams.stereoHalfAngle=e.Tools.ToRadians(this._cameraRigParams.interaxialDistance/.0637),this.cameraRigMode!==r.RIG_MODE_NONE&&(this._rigCameras.push(this.createRigCamera(this.name+"_L",0)),this._rigCameras.push(this.createRigCamera(this.name+"_R",1))),this.cameraRigMode){case r.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 r.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case r.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:case r.RIG_MODE_STEREOSCOPIC_OVERUNDER:var n=this.cameraRigMode===r.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL||this.cameraRigMode===r.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 r.RIG_MODE_VR:var o=i.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 r.RIG_MODE_WEBVR:if(i.vrDisplay){var s=i.vrDisplay.getEyeParameters("left"),a=i.vrDisplay.getEyeParameters("right");this._rigCameras[0].viewport=new e.Viewport(0,0,.5,1),this._rigCameras[0].setCameraRigParameter("left",!0),this._rigCameras[0].setCameraRigParameter("specs",i.specs),this._rigCameras[0].setCameraRigParameter("eyeParameters",s),this._rigCameras[0].setCameraRigParameter("frameData",i.frameData),this._rigCameras[0].setCameraRigParameter("parentCamera",i.parentCamera),this._rigCameras[0]._cameraRigParams.vrWorkMatrix=new e.Matrix,this._rigCameras[0].getProjectionMatrix=this._getWebVRProjectionMatrix,this._rigCameras[0].parent=this,this._rigCameras[0]._getViewMatrix=this._getWebVRViewMatrix,this._rigCameras[1].viewport=new e.Viewport(.5,0,.5,1),this._rigCameras[1].setCameraRigParameter("eyeParameters",a),this._rigCameras[1].setCameraRigParameter("specs",i.specs),this._rigCameras[1].setCameraRigParameter("frameData",i.frameData),this._rigCameras[1].setCameraRigParameter("parentCamera",i.parentCamera),this._rigCameras[1]._cameraRigParams.vrWorkMatrix=new e.Matrix,this._rigCameras[1].getProjectionMatrix=this._getWebVRProjectionMatrix,this._rigCameras[1].parent=this,this._rigCameras[1]._getViewMatrix=this._getWebVRViewMatrix}}this._cascadePostProcessesToRigCams(),this.update()},r.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},r.prototype._updateCameraRotationMatrix=function(){},r.prototype._updateWebVRCameraRotationMatrix=function(){},r.prototype._getWebVRProjectionMatrix=function(){return e.Matrix.Identity()},r.prototype._getWebVRViewMatrix=function(){return e.Matrix.Identity()},r.prototype.setCameraRigParameter=function(t,r){this._cameraRigParams||(this._cameraRigParams={}),this._cameraRigParams[t]=r,"interaxialDistance"===t&&(this._cameraRigParams.stereoHalfAngle=e.Tools.ToRadians(r/.0637))},r.prototype.createRigCamera=function(e,t){return null},
- r.prototype._updateRigCameras=function(){for(var e=0;e<this._rigCameras.length;e++)this._rigCameras[e].minZ=this.minZ,this._rigCameras[e].maxZ=this.maxZ,this._rigCameras[e].fov=this.fov;this.cameraRigMode===r.RIG_MODE_STEREOSCOPIC_ANAGLYPH&&(this._rigCameras[0].viewport=this._rigCameras[1].viewport=this.viewport)},r.prototype._setupInputs=function(){},r.prototype.serialize=function(){var t=e.SerializationHelper.Serialize(this);return t.type=this.getClassName(),this.parent&&(t.parentId=this.parent.id),this.inputs&&this.inputs.serialize(t),e.Animation.AppendSerializedAnimations(this,t),t.ranges=this.serializeAnimationRanges(),t},r.prototype.clone=function(t){return e.SerializationHelper.Clone(r.GetConstructorFromName(this.getClassName(),t,this.getScene(),this.interaxialDistance,this.isStereoscopicSideBySide),this)},r.prototype.getDirection=function(t){var r=e.Vector3.Zero();return this.getDirectionToRef(t,r),r},r.prototype.getDirectionToRef=function(t,r){e.Vector3.TransformNormalToRef(t,this.getWorldMatrix(),r)},r.GetConstructorFromName=function(t,r,i,n,o){switch(void 0===n&&(n=0),void 0===o&&(o=!0),t){case"ArcRotateCamera":return function(){return new e.ArcRotateCamera(r,0,0,1,e.Vector3.Zero(),i)};case"DeviceOrientationCamera":return function(){return new e.DeviceOrientationCamera(r,e.Vector3.Zero(),i)};case"FollowCamera":return function(){return new e.FollowCamera(r,e.Vector3.Zero(),i)};case"ArcFollowCamera":return function(){return new e.ArcFollowCamera(r,0,0,1,null,i)};case"GamepadCamera":return function(){return new e.GamepadCamera(r,e.Vector3.Zero(),i)};case"TouchCamera":return function(){return new e.TouchCamera(r,e.Vector3.Zero(),i)};case"VirtualJoysticksCamera":return function(){return new e.VirtualJoysticksCamera(r,e.Vector3.Zero(),i)};case"WebVRFreeCamera":case"WebVRGamepadCamera":return function(){return new e.WebVRFreeCamera(r,e.Vector3.Zero(),i)};case"VRDeviceOrientationFreeCamera":return function(){return new e.VRDeviceOrientationFreeCamera(r,e.Vector3.Zero(),i)};case"VRDeviceOrientationGamepadCamera":return function(){return new e.VRDeviceOrientationGamepadCamera(r,e.Vector3.Zero(),i)};case"AnaglyphArcRotateCamera":return function(){return new e.AnaglyphArcRotateCamera(r,0,0,1,e.Vector3.Zero(),n,i)};case"AnaglyphFreeCamera":return function(){return new e.AnaglyphFreeCamera(r,e.Vector3.Zero(),n,i)};case"AnaglyphGamepadCamera":return function(){return new e.AnaglyphGamepadCamera(r,e.Vector3.Zero(),n,i)};case"AnaglyphUniversalCamera":return function(){return new e.AnaglyphUniversalCamera(r,e.Vector3.Zero(),n,i)};case"StereoscopicArcRotateCamera":return function(){return new e.StereoscopicArcRotateCamera(r,0,0,1,e.Vector3.Zero(),n,o,i)};case"StereoscopicFreeCamera":return function(){return new e.StereoscopicFreeCamera(r,e.Vector3.Zero(),n,o,i)};case"StereoscopicGamepadCamera":return function(){return new e.StereoscopicGamepadCamera(r,e.Vector3.Zero(),n,o,i)};case"StereoscopicUniversalCamera":return function(){return new e.StereoscopicUniversalCamera(r,e.Vector3.Zero(),n,o,i)};case"FreeCamera":default:return function(){return new e.UniversalCamera(r,e.Vector3.Zero(),i)}}},r.Parse=function(t,i){var n=t.type,o=r.GetConstructorFromName(n,t.name,i,t.interaxial_distance,t.isStereoscopicSideBySide),s=e.SerializationHelper.Parse(o,t,i);if(t.parentId&&(s._waitingParentId=t.parentId),s.inputs&&(s.inputs.parse(t),s._setupInputs()),s.setPosition&&(s.position.copyFromFloats(0,0,0),s.setPosition(e.Vector3.FromArray(t.position))),t.target&&s.setTarget&&s.setTarget(e.Vector3.FromArray(t.target)),t.cameraRigMode){var a=t.interaxial_distance?{interaxialDistance:t.interaxial_distance}:{};s.setCameraRigMode(t.cameraRigMode,a)}if(t.animations){for(var u=0;u<t.animations.length;u++){var l=t.animations[u];s.animations.push(e.Animation.Parse(l))}e.Node.ParseAnimationRanges(s,t,i)}return t.autoAnimate&&i.beginAnimation(s,t.autoAnimateFrom,t.autoAnimateTo,t.autoAnimateLoop,t.autoAnimateSpeed||1),s},r._PERSPECTIVE_CAMERA=0,r._ORTHOGRAPHIC_CAMERA=1,r._FOVMODE_VERTICAL_FIXED=0,r._FOVMODE_HORIZONTAL_FIXED=1,r._RIG_MODE_NONE=0,r._RIG_MODE_STEREOSCOPIC_ANAGLYPH=10,r._RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL=11,r._RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED=12,r._RIG_MODE_STEREOSCOPIC_OVERUNDER=13,r._RIG_MODE_VR=20,r._RIG_MODE_WEBVR=21,r.ForceAttachControlToAlwaysPreventDefault=!1,__decorate([e.serializeAsVector3()],r.prototype,"position",void 0),__decorate([e.serializeAsVector3()],r.prototype,"upVector",void 0),__decorate([e.serialize()],r.prototype,"orthoLeft",void 0),__decorate([e.serialize()],r.prototype,"orthoRight",void 0),__decorate([e.serialize()],r.prototype,"orthoBottom",void 0),__decorate([e.serialize()],r.prototype,"orthoTop",void 0),__decorate([e.serialize()],r.prototype,"fov",void 0),__decorate([e.serialize()],r.prototype,"minZ",void 0),__decorate([e.serialize()],r.prototype,"maxZ",void 0),__decorate([e.serialize()],r.prototype,"inertia",void 0),__decorate([e.serialize()],r.prototype,"mode",void 0),__decorate([e.serialize()],r.prototype,"layerMask",void 0),__decorate([e.serialize()],r.prototype,"fovMode",void 0),__decorate([e.serialize()],r.prototype,"cameraRigMode",void 0),__decorate([e.serialize()],r.prototype,"interaxialDistance",void 0),__decorate([e.serialize()],r.prototype,"isStereoscopicSideBySide",void 0),r})(e.Node);e.Camera=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 r=t.MIN_RENDERINGGROUPS;r<t.MAX_RENDERINGGROUPS;r++)this._autoClearDepthStencil[r]={autoClear:!0,depth:!0,stencil:!0}}return t.prototype._clearDepthStencilBuffer=function(e,t){void 0===e&&(e=!0),void 0===t&&(t=!0),this._depthStencilBufferAlreadyCleaned||(this._scene.getEngine().clear(null,!1,e,t),this._depthStencilBufferAlreadyCleaned=!0)},t.prototype.render=function(r,i,n,o){var s=this._scene.onRenderingGroupObservable.hasObservers()?this._scene.onRenderingGroupObservable:null,a=null;if(s&&(this._renderinGroupInfo||(this._renderinGroupInfo=new e.RenderingGroupInfo),a=this._renderinGroupInfo,a.scene=this._scene,a.camera=this._scene.activeCamera),o)for(var u=0;u<this._scene.spriteManagers.length;u++){var l=this._scene.spriteManagers[u];this.dispatchSprites(l)}for(var u=t.MIN_RENDERINGGROUPS;u<t.MAX_RENDERINGGROUPS;u++){this._depthStencilBufferAlreadyCleaned=u===t.MIN_RENDERINGGROUPS;var h=this._renderingGroups[u];if(h||s){this._currentIndex=u;var c=0;if(s&&(c=Math.pow(2,u),a.renderStage=e.RenderingGroupInfo.STAGE_PRECLEAR,a.renderingGroupId=u,s.notifyObservers(a,c)),t.AUTOCLEAR){var f=this._autoClearDepthStencil[u];f&&f.autoClear&&this._clearDepthStencilBuffer(f.depth,f.stencil)}s&&(a.renderStage=e.RenderingGroupInfo.STAGE_PREOPAQUE,s.notifyObservers(a,c),a.renderStage=e.RenderingGroupInfo.STAGE_PRETRANSPARENT,s.notifyObservers(a,c)),h&&h.render(r,o,n,i),s&&(a.renderStage=e.RenderingGroupInfo.STAGE_POSTTRANSPARENT,s.notifyObservers(a,c))}}},t.prototype.reset=function(){for(var e=t.MIN_RENDERINGGROUPS;e<t.MAX_RENDERINGGROUPS;e++){var r=this._renderingGroups[e];r&&r.prepare()}},t.prototype.dispose=function(){for(var e=t.MIN_RENDERINGGROUPS;e<t.MAX_RENDERINGGROUPS;e++){var r=this._renderingGroups[e];r&&r.dispose()}this._renderingGroups.length=0},t.prototype._prepareRenderingGroup=function(t){this._renderingGroups[t]||(this._renderingGroups[t]=new e.RenderingGroup(t,this._scene,this._customOpaqueSortCompareFn[t],this._customAlphaTestSortCompareFn[t],this._customTransparentSortCompareFn[t]))},t.prototype.dispatchSprites=function(e){var t=e.renderingGroupId||0;this._prepareRenderingGroup(t),this._renderingGroups[t].dispatchSprites(e)},t.prototype.dispatchParticles=function(e){var t=e.renderingGroupId||0;this._prepareRenderingGroup(t),this._renderingGroups[t].dispatchParticles(e)},t.prototype.dispatch=function(e){var t=e.getMesh(),r=t.renderingGroupId||0;this._prepareRenderingGroup(r),this._renderingGroups[r].dispatch(e)},t.prototype.setRenderingOrder=function(e,t,r,i){if(void 0===t&&(t=null),void 0===r&&(r=null),void 0===i&&(i=null),this._customOpaqueSortCompareFn[e]=t,this._customAlphaTestSortCompareFn[e]=r,this._customTransparentSortCompareFn[e]=i,this._renderingGroups[e]){var n=this._renderingGroups[e];n.opaqueSortCompareFn=this._customOpaqueSortCompareFn[e],n.alphaTestSortCompareFn=this._customAlphaTestSortCompareFn[e],n.transparentSortCompareFn=this._customTransparentSortCompareFn[e]}},t.prototype.setRenderingAutoClearDepthStencil=function(e,t,r,i){void 0===r&&(r=!0),void 0===i&&(i=!0),this._autoClearDepthStencil[e]={autoClear:t,depth:r,stencil:i}},t.MAX_RENDERINGGROUPS=4,t.MIN_RENDERINGGROUPS=0,t.AUTOCLEAR=!0,t})();e.RenderingManager=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(t,r,i,n,o){void 0===i&&(i=null),void 0===n&&(n=null),void 0===o&&(o=null),this.index=t,this._opaqueSubMeshes=new e.SmartArray(256),this._transparentSubMeshes=new e.SmartArray(256),this._alphaTestSubMeshes=new e.SmartArray(256),this._particleSystems=new e.SmartArray(256),this._spriteManagers=new e.SmartArray(256),this._edgesRenderers=new e.SmartArray(16),this._scene=r,this.opaqueSortCompareFn=i,this.alphaTestSortCompareFn=n,this.transparentSortCompareFn=o}return Object.defineProperty(t.prototype,"opaqueSortCompareFn",{set:function(e){this._opaqueSortCompareFn=e,this._renderOpaque=e?this.renderOpaqueSorted:t.renderUnsorted},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"alphaTestSortCompareFn",{set:function(e){this._alphaTestSortCompareFn=e,this._renderAlphaTest=e?this.renderAlphaTestSorted:t.renderUnsorted},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"transparentSortCompareFn",{set:function(e){this._transparentSortCompareFn=e||t.defaultTransparentSortCompare,this._renderTransparent=this.renderTransparentSorted},enumerable:!0,configurable:!0}),t.prototype.render=function(t,r,i,n){if(t)return void t(this._opaqueSubMeshes,this._alphaTestSubMeshes,this._transparentSubMeshes);var o=this._scene.getEngine();0!==this._opaqueSubMeshes.length&&this._renderOpaque(this._opaqueSubMeshes),0!==this._alphaTestSubMeshes.length&&(o.setAlphaTesting(!0),this._renderAlphaTest(this._alphaTestSubMeshes),o.setAlphaTesting(!1));var s=o.getStencilBuffer();o.setStencilBuffer(!1),r&&this._renderSprites(),i&&this._renderParticles(n),this.onBeforeTransparentRendering&&this.onBeforeTransparentRendering(),0!==this._transparentSubMeshes.length&&(this._renderTransparent(this._transparentSubMeshes),o.setAlphaMode(e.Engine.ALPHA_DISABLE)),o.setStencilBuffer(!1);for(var a=0;a<this._edgesRenderers.length;a++)this._edgesRenderers.data[a].render();o.setStencilBuffer(s)},t.prototype.renderOpaqueSorted=function(e){return t.renderSorted(e,this._opaqueSortCompareFn,this._scene.activeCamera.globalPosition,!1)},t.prototype.renderAlphaTestSorted=function(e){return t.renderSorted(e,this._alphaTestSortCompareFn,this._scene.activeCamera.globalPosition,!1)},t.prototype.renderTransparentSorted=function(e){return t.renderSorted(e,this._transparentSortCompareFn,this._scene.activeCamera.globalPosition,!0)},t.renderSorted=function(e,t,r,i){for(var n,o=0;o<e.length;o++)n=e.data[o],n._alphaIndex=n.getMesh().alphaIndex,n._distanceToCamera=n.getBoundingInfo().boundingSphere.centerWorld.subtract(r).length();var s=e.data.slice(0,e.length);for(s.sort(t),o=0;o<s.length;o++)n=s[o],n.render(i)},t.renderUnsorted=function(e){for(var t=0;t<e.length;t++){e.data[t].render(!1)}},t.defaultTransparentSortCompare=function(e,r){return e._alphaIndex>r._alphaIndex?1:e._alphaIndex<r._alphaIndex?-1:t.backToFrontSortCompare(e,r)},t.backToFrontSortCompare=function(e,t){return e._distanceToCamera<t._distanceToCamera?1:e._distanceToCamera>t._distanceToCamera?-1:0},t.frontToBackSortCompare=function(e,t){return e._distanceToCamera<t._distanceToCamera?-1:e._distanceToCamera>t._distanceToCamera?1:0},t.prototype.prepare=function(){this._opaqueSubMeshes.reset(),this._transparentSubMeshes.reset(),this._alphaTestSubMeshes.reset(),this._particleSystems.reset(),this._spriteManagers.reset(),this._edgesRenderers.reset()},t.prototype.dispose=function(){this._opaqueSubMeshes.dispose(),this._transparentSubMeshes.dispose(),this._alphaTestSubMeshes.dispose(),this._particleSystems.dispose(),this._spriteManagers.dispose(),this._edgesRenderers.dispose()},t.prototype.dispatch=function(e){var t=e.getMaterial(),r=e.getMesh();t.needAlphaBlending()||r.visibility<1||r.hasVertexAlpha?this._transparentSubMeshes.push(e):t.needAlphaTesting()?this._alphaTestSubMeshes.push(e):this._opaqueSubMeshes.push(e),r._edgesRenderer&&this._edgesRenderers.push(r._edgesRenderer)},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 r=0;r<this._scene._activeParticleSystems.length;r++){var i=this._scene._activeParticleSystems.data[r];if(0!=(t.layerMask&i.layerMask)){var n=i.emitter;n.position&&e&&-1===e.indexOf(n)||this._scene._activeParticles.addCount(i.render(),!1)}}this._scene._particlesDuration.endMonitoring(!1)}},t.prototype._renderSprites=function(){if(this._scene.spritesEnabled&&0!==this._spriteManagers.length){var e=this._scene.activeCamera;this._scene._spritesDuration.beginMonitoring();for(var t=0;t<this._spriteManagers.length;t++){var r=this._spriteManagers.data[t];0!=(e.layerMask&r.layerMask)&&r.render()}this._scene._spritesDuration.endMonitoring(!1)}},t})();e.RenderingGroup=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(){this._singleClick=!1,this._doubleClick=!1,this._hasSwiped=!1,this._ignore=!1}return Object.defineProperty(e.prototype,"singleClick",{get:function(){return this._singleClick},set:function(e){this._singleClick=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"doubleClick",{get:function(){return this._doubleClick},set:function(e){this._doubleClick=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"hasSwiped",{get:function(){return this._hasSwiped},set:function(e){this._hasSwiped=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"ignore",{get:function(){return this._ignore},set:function(e){this._ignore=e},enumerable:!0,configurable:!0}),e})(),r=(function(){function e(){}return Object.defineProperty(e,"POINTERDOWN",{get:function(){return e._POINTERDOWN},enumerable:!0,configurable:!0}),Object.defineProperty(e,"POINTERUP",{get:function(){return e._POINTERUP},enumerable:!0,configurable:!0}),Object.defineProperty(e,"POINTERMOVE",{get:function(){return e._POINTERMOVE},enumerable:!0,configurable:!0}),Object.defineProperty(e,"POINTERWHEEL",{get:function(){return e._POINTERWHEEL},enumerable:!0,configurable:!0}),Object.defineProperty(e,"POINTERPICK",{get:function(){return e._POINTERPICK},enumerable:!0,configurable:!0}),Object.defineProperty(e,"POINTERTAP",{get:function(){return e._POINTERTAP},enumerable:!0,configurable:!0}),Object.defineProperty(e,"POINTERDOUBLETAP",{get:function(){return e._POINTERDOUBLETAP},enumerable:!0,configurable:!0}),e._POINTERDOWN=1,e._POINTERUP=2,e._POINTERMOVE=4,e._POINTERWHEEL=8,e._POINTERPICK=16,e._POINTERTAP=32,e._POINTERDOUBLETAP=64,e})();e.PointerEventTypes=r;var i=(function(){function e(e,t){this.type=e,this.event=t}return e})();e.PointerInfoBase=i;var n=(function(t){function r(r,i,n,o){var s=t.call(this,r,i)||this;return s.skipOnPointerObservable=!1,s.localPosition=new e.Vector2(n,o),s}return __extends(r,t),r})(i);e.PointerInfoPre=n;var o=(function(e){function t(t,r,i){var n=e.call(this,t,r)||this;return n.pickInfo=i,n}return __extends(t,e),t})(i);e.PointerInfo=o;var s=(function(){function e(){}return e.STAGE_PRECLEAR=1,e.STAGE_PREOPAQUE=2,e.STAGE_PRETRANSPARENT=3,e.STAGE_POSTTRANSPARENT=4,e})();e.RenderingGroupInfo=s;var a=(function(){function i(t){this.autoClear=!0,this.autoClearDepthAndStencil=!0,this.clearColor=new e.Color4(.2,.2,.3,1),this.ambientColor=new e.Color3(0,0,0),this.forceWireframe=!1,this._forcePointsCloud=!1,this.forceShowBoundingBoxes=!1,this.animationsEnabled=!0,this.constantlyUpdateMeshUnderPointer=!1,this.hoverCursor="pointer",this.defaultCursor="",this.metadata=null,this.onDisposeObservable=new e.Observable,this.onBeforeRenderObservable=new e.Observable,this.onAfterRenderObservable=new e.Observable,this.onReadyObservable=new e.Observable,this.onBeforeCameraRenderObservable=new e.Observable,this.onAfterCameraRenderObservable=new e.Observable,this.onNewCameraAddedObservable=new e.Observable,this.onCameraRemovedObservable=new e.Observable,this.onNewLightAddedObservable=new e.Observable,this.onLightRemovedObservable=new e.Observable,this.onNewGeometryAddedObservable=new e.Observable,this.onGeometryRemovedObservable=new e.Observable,this.onNewMeshAddedObservable=new e.Observable,this.onMeshRemovedObservable=new e.Observable,this.onBeforeStepObservable=new e.Observable,this.onAfterStepObservable=new e.Observable,this.onRenderingGroupObservable=new e.Observable,this.animations=[],this.onPrePointerObservable=new e.Observable,this.onPointerObservable=new e.Observable,this._meshPickProceed=!1,this._previousHasSwiped=!1,this._currentPickResult=null,this._previousPickResult=null,this._isButtonPressed=!1,this._doubleClickOccured=!1,this.cameraToUseForPointers=null,this._startingPointerPosition=new e.Vector2(0,0),this._previousStartingPointerPosition=new e.Vector2(0,0),this._startingPointerTime=0,this._previousStartingPointerTime=0,this._timeAccumulator=0,this._currentStepId=0,this._currentInternalStep=0,this._useRightHandedSystem=!1,this._fogEnabled=!0,this._fogMode=i.FOGMODE_NONE,this.fogColor=new e.Color3(.2,.2,.3),this.fogDensity=.1,this.fogStart=0,this.fogEnd=1e3,this._shadowsEnabled=!0,this._lightsEnabled=!0,this.lights=new Array,this.cameras=new Array,this.activeCameras=new Array,this.meshes=new Array,this._geometries=new Array,this.materials=new Array,this.multiMaterials=new Array,this._texturesEnabled=!0,this.textures=new Array,this.particlesEnabled=!0,this.particleSystems=new Array,this.spritesEnabled=!0,this.spriteManagers=new Array,this.layers=new Array,this.highlightLayers=new Array,this._skeletonsEnabled=!0,this.skeletons=new Array,this.morphTargetManagers=new Array,this.lensFlaresEnabled=!0,this.lensFlareSystems=new Array,this.collisionsEnabled=!0,this.gravity=new e.Vector3(0,-9.807,0),this.postProcessesEnabled=!0,this.renderTargetsEnabled=!0,this.dumpNextRenderTargets=!1,this.customRenderTargets=new Array,this.importedMeshesFiles=new Array,this.probesEnabled=!0,this.reflectionProbes=new Array,this._actionManagers=new Array,this._meshesForIntersections=new e.SmartArray(256),this.proceduralTexturesEnabled=!0,this._proceduralTextures=new Array,this.soundTracks=new Array,this._audioEnabled=!0,this._headphone=!1,this._totalMeshesCounter=new e.PerfCounter,this._totalLightsCounter=new e.PerfCounter,this._totalMaterialsCounter=new e.PerfCounter,this._totalTexturesCounter=new e.PerfCounter,this._totalVertices=new e.PerfCounter,this._activeIndices=new e.PerfCounter,this._activeParticles=new e.PerfCounter,this._lastFrameDuration=new e.PerfCounter,this._evaluateActiveMeshesDuration=new e.PerfCounter,this._renderTargetsDuration=new e.PerfCounter,this._particlesDuration=new e.PerfCounter,this._renderDuration=new e.PerfCounter,this._spritesDuration=new e.PerfCounter,this._activeBones=new e.PerfCounter,this._animationTime=0,this.animationTimeScale=1,this._renderId=0,this._executeWhenReadyTimeoutId=-1,this._intermediateRendering=!1,this._viewUpdateFlag=-1,this._projectionUpdateFlag=-1,this._toBeDisposed=new e.SmartArray(256),this._pendingData=[],this._activeMeshes=new e.SmartArray(256),this._processedMaterials=new e.SmartArray(256),this._renderTargets=new e.SmartArray(256),this._activeParticleSystems=new e.SmartArray(256),this._activeSkeletons=new e.SmartArray(32),this._softwareSkinnedMeshes=new e.SmartArray(32),this._activeAnimatables=new Array,this._transformMatrix=e.Matrix.Zero(),this.requireLightSorting=!1,this._uniqueIdCounter=0,this._engine=t||e.Engine.LastCreatedEngine,this._engine.scenes.push(this),this._uid=null,this._renderingManager=new e.RenderingManager(this),this.postProcessManager=new e.PostProcessManager(this),e.OutlineRenderer&&(this._outlineRenderer=new e.OutlineRenderer(this)),this.attachControl(),e.SoundTrack&&(this.mainSoundTrack=new e.SoundTrack(this,{mainTrack:!0})),e.SimplificationQueue&&(this.simplificationQueue=new e.SimplificationQueue),this.workerCollisions=!1,this._createUbo(),this._imageProcessingConfiguration=new e.ImageProcessingConfiguration}return Object.defineProperty(i,"FOGMODE_NONE",{get:function(){return i._FOGMODE_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(i,"FOGMODE_EXP",{get:function(){return i._FOGMODE_EXP},enumerable:!0,configurable:!0}),Object.defineProperty(i,"FOGMODE_EXP2",{get:function(){return i._FOGMODE_EXP2},enumerable:!0,configurable:!0}),Object.defineProperty(i,"FOGMODE_LINEAR",{get:function(){return i._FOGMODE_LINEAR},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"environmentTexture",{get:function(){return this._environmentTexture},set:function(t){this._environmentTexture=t,this.markAllMaterialsAsDirty(e.Material.TextureDirtyFlag)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"imageProcessingConfiguration",{get:function(){return this._imageProcessingConfiguration},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"forcePointsCloud",{get:function(){return this._forcePointsCloud},set:function(t){this._forcePointsCloud!==t&&(this._forcePointsCloud=t,this.markAllMaterialsAsDirty(e.Material.MiscDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"beforeRender",{set:function(e){this._onBeforeRenderObserver&&this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),this._onBeforeRenderObserver=this.onBeforeRenderObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"afterRender",{set:function(e){this._onAfterRenderObserver&&this.onAfterRenderObservable.remove(this._onAfterRenderObserver),this._onAfterRenderObserver=this.onAfterRenderObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"beforeCameraRender",{set:function(e){this._onBeforeCameraRenderObserver&&this.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver),this._onBeforeCameraRenderObserver=this.onBeforeCameraRenderObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"afterCameraRender",{set:function(e){this._onAfterCameraRenderObserver&&this.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver),this._onAfterCameraRenderObserver=this.onAfterCameraRenderObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"unTranslatedPointer",{get:function(){return new e.Vector2(this._unTranslatedPointerX,this._unTranslatedPointerY)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"useRightHandedSystem",{get:function(){return this._useRightHandedSystem},set:function(t){this._useRightHandedSystem!==t&&(this._useRightHandedSystem=t,this.markAllMaterialsAsDirty(e.Material.MiscDirtyFlag))},enumerable:!0,configurable:!0}),i.prototype.setStepId=function(e){this._currentStepId=e},i.prototype.getStepId=function(){return this._currentStepId},i.prototype.getInternalStep=function(){return this._currentInternalStep},Object.defineProperty(i.prototype,"fogEnabled",{get:function(){return this._fogEnabled},set:function(t){this._fogEnabled!==t&&(this._fogEnabled=t,this.markAllMaterialsAsDirty(e.Material.MiscDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"fogMode",{get:function(){return this._fogMode},set:function(t){this._fogMode!==t&&(this._fogMode=t,this.markAllMaterialsAsDirty(e.Material.MiscDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"shadowsEnabled",{get:function(){return this._shadowsEnabled},set:function(t){this._shadowsEnabled!==t&&(this._shadowsEnabled=t,this.markAllMaterialsAsDirty(e.Material.LightDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"lightsEnabled",{get:function(){return this._lightsEnabled},set:function(t){this._lightsEnabled!==t&&(this._lightsEnabled=t,this.markAllMaterialsAsDirty(e.Material.LightDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"defaultMaterial",{get:function(){return this._defaultMaterial||(this._defaultMaterial=new e.StandardMaterial("default material",this)),this._defaultMaterial},set:function(e){this._defaultMaterial=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"texturesEnabled",{get:function(){return this._texturesEnabled},set:function(t){this._texturesEnabled!==t&&(this._texturesEnabled=t,this.markAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"skeletonsEnabled",{get:function(){return this._skeletonsEnabled},set:function(t){this._skeletonsEnabled!==t&&(this._skeletonsEnabled=t,this.markAllMaterialsAsDirty(e.Material.AttributesDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"postProcessRenderPipelineManager",{get:function(){return this._postProcessRenderPipelineManager||(this._postProcessRenderPipelineManager=new e.PostProcessRenderPipelineManager),this._postProcessRenderPipelineManager},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"frustumPlanes",{get:function(){return this._frustumPlanes},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"debugLayer",{get:function(){return this._debugLayer||(this._debugLayer=new e.DebugLayer(this)),this._debugLayer},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"workerCollisions",{get:function(){return this._workerCollisions},set:function(t){e.CollisionCoordinatorLegacy&&(t=t&&!!Worker,this._workerCollisions=t,this.collisionCoordinator&&this.collisionCoordinator.destroy(),this.collisionCoordinator=t?new e.CollisionCoordinatorWorker:new e.CollisionCoordinatorLegacy,this.collisionCoordinator.init(this))},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"selectionOctree",{get:function(){return this._selectionOctree},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"meshUnderPointer",{get:function(){return this._pointerOverMesh},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"pointerX",{get:function(){return this._pointerX},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"pointerY",{get:function(){return this._pointerY},enumerable:!0,configurable:!0}),i.prototype.getCachedMaterial=function(){return this._cachedMaterial},i.prototype.getCachedEffect=function(){return this._cachedEffect},i.prototype.getCachedVisibility=function(){return this._cachedVisibility},i.prototype.isCachedMaterialInvalid=function(e,t,r){return void 0===r&&(r=1),this._cachedEffect!==t||this._cachedMaterial!==e||this._cachedVisibility!==r},i.prototype.getBoundingBoxRenderer=function(){return this._boundingBoxRenderer||(this._boundingBoxRenderer=new e.BoundingBoxRenderer(this)),this._boundingBoxRenderer},i.prototype.getOutlineRenderer=function(){return this._outlineRenderer},i.prototype.getEngine=function(){return this._engine},i.prototype.getTotalVertices=function(){return this._totalVertices.current},Object.defineProperty(i.prototype,"totalVerticesPerfCounter",{get:function(){return this._totalVertices},enumerable:!0,configurable:!0}),i.prototype.getActiveIndices=function(){return this._activeIndices.current},Object.defineProperty(i.prototype,"totalActiveIndicesPerfCounter",{get:function(){return this._activeIndices},enumerable:!0,configurable:!0}),i.prototype.getActiveParticles=function(){return this._activeParticles.current},Object.defineProperty(i.prototype,"activeParticlesPerfCounter",{get:function(){return this._activeParticles},enumerable:!0,configurable:!0}),i.prototype.getActiveBones=function(){return this._activeBones.current},Object.defineProperty(i.prototype,"activeBonesPerfCounter",{get:function(){return this._activeBones},enumerable:!0,configurable:!0}),i.prototype.getLastFrameDuration=function(){return this._lastFrameDuration.current},Object.defineProperty(i.prototype,"lastFramePerfCounter",{get:function(){return this._lastFrameDuration},enumerable:!0,configurable:!0}),i.prototype.getEvaluateActiveMeshesDuration=function(){return this._evaluateActiveMeshesDuration.current},Object.defineProperty(i.prototype,"evaluateActiveMeshesDurationPerfCounter",{get:function(){return this._evaluateActiveMeshesDuration},enumerable:!0,configurable:!0}),i.prototype.getActiveMeshes=function(){return this._activeMeshes},i.prototype.getRenderTargetsDuration=function(){return this._renderTargetsDuration.current},i.prototype.getRenderDuration=function(){return this._renderDuration.current},Object.defineProperty(i.prototype,"renderDurationPerfCounter",{get:function(){return this._renderDuration},enumerable:!0,configurable:!0}),i.prototype.getParticlesDuration=function(){return this._particlesDuration.current},Object.defineProperty(i.prototype,"particlesDurationPerfCounter",{get:function(){return this._particlesDuration},enumerable:!0,configurable:!0}),i.prototype.getSpritesDuration=function(){return this._spritesDuration.current},Object.defineProperty(i.prototype,"spriteDuractionPerfCounter",{get:function(){return this._spritesDuration},enumerable:!0,configurable:!0}),i.prototype.getAnimationRatio=function(){return this._animationRatio},i.prototype.getRenderId=function(){return this._renderId},i.prototype.incrementRenderId=function(){this._renderId++},i.prototype._updatePointerPosition=function(e){var t=this._engine.getRenderingCanvasClientRect();this._pointerX=e.clientX-t.left,this._pointerY=e.clientY-t.top,this._unTranslatedPointerX=this._pointerX,this._unTranslatedPointerY=this._pointerY},i.prototype._createUbo=function(){this._sceneUbo=new e.UniformBuffer(this._engine,null,!0),this._sceneUbo.addUniform("viewProjection",16),this._sceneUbo.addUniform("view",16)},i.prototype.attachControl=function(s,a,u){var l=this;void 0===s&&(s=!0),void 0===a&&(a=!0),void 0===u&&(u=!0),this._initActionManager=function(e,t){if(!l._meshPickProceed){var r=l.pick(l._unTranslatedPointerX,l._unTranslatedPointerY,l.pointerDownPredicate,!1,l.cameraToUseForPointers);l._currentPickResult=r,r&&(e=r.hit&&r.pickedMesh?r.pickedMesh.actionManager:null),l._meshPickProceed=!0}return e},this._delayedSimpleClick=function(e,t,r){((new Date).getTime()-l._previousStartingPointerTime>i.DoubleClickDelay&&!l._doubleClickOccured||e!==l._previousButtonPressed)&&(l._doubleClickOccured=!1,t.singleClick=!0,t.ignore=!1,r(t,l._currentPickResult))},this._initClickEvent=function(n,o,s,a){var u=new t;l._currentPickResult=null;var h,c=n.hasSpecificMask(r.POINTERPICK)||o.hasSpecificMask(r.POINTERPICK)||n.hasSpecificMask(r.POINTERTAP)||o.hasSpecificMask(r.POINTERTAP)||n.hasSpecificMask(r.POINTERDOUBLETAP)||o.hasSpecificMask(r.POINTERDOUBLETAP);if(!c&&e.ActionManager&&e.ActionManager.HasPickTriggers&&(h=l._initActionManager(h,u))&&(c=h.hasPickTriggers),c){var f=s.button;if(u.hasSwiped=Math.abs(l._startingPointerPosition.x-l._pointerX)>i.DragMovementThreshold||Math.abs(l._startingPointerPosition.y-l._pointerY)>i.DragMovementThreshold,!u.hasSwiped){var d=!i.ExclusiveDoubleClickMode
- ;d||(d=!n.hasSpecificMask(r.POINTERDOUBLETAP)&&!o.hasSpecificMask(r.POINTERDOUBLETAP))&&!e.ActionManager.HasSpecificTrigger(e.ActionManager.OnDoublePickTrigger)&&(h=l._initActionManager(h,u))&&(d=!h.hasSpecificTrigger(e.ActionManager.OnDoublePickTrigger)),d?((new Date).getTime()-l._previousStartingPointerTime>i.DoubleClickDelay||f!==l._previousButtonPressed)&&(u.singleClick=!0,a(u,l._currentPickResult)):(l._previousDelayedSimpleClickTimeout=l._delayedSimpleClickTimeout,l._delayedSimpleClickTimeout=window.setTimeout(l._delayedSimpleClick.bind(l,f,u,a),i.DoubleClickDelay));var p=n.hasSpecificMask(r.POINTERDOUBLETAP)||o.hasSpecificMask(r.POINTERDOUBLETAP);!p&&e.ActionManager.HasSpecificTrigger(e.ActionManager.OnDoublePickTrigger)&&(h=l._initActionManager(h,u))&&(p=h.hasSpecificTrigger(e.ActionManager.OnDoublePickTrigger)),p&&(f===l._previousButtonPressed&&(new Date).getTime()-l._previousStartingPointerTime<i.DoubleClickDelay&&!l._doubleClickOccured?!u.hasSwiped&&Math.abs(l._previousStartingPointerPosition.x-l._startingPointerPosition.x)<i.DragMovementThreshold&&Math.abs(l._previousStartingPointerPosition.y-l._startingPointerPosition.y)<i.DragMovementThreshold?(l._previousStartingPointerTime=0,l._doubleClickOccured=!0,u.doubleClick=!0,u.ignore=!1,i.ExclusiveDoubleClickMode&&l._previousDelayedSimpleClickTimeout&&l._previousDelayedSimpleClickTimeout.clearTimeout&&l._previousDelayedSimpleClickTimeout.clearTimeout(),l._previousDelayedSimpleClickTimeout=l._delayedSimpleClickTimeout,a(u,l._currentPickResult)):(l._doubleClickOccured=!1,l._previousStartingPointerTime=l._startingPointerTime,l._previousStartingPointerPosition.x=l._startingPointerPosition.x,l._previousStartingPointerPosition.y=l._startingPointerPosition.y,l._previousButtonPressed=f,l._previousHasSwiped=u.hasSwiped,i.ExclusiveDoubleClickMode?(l._previousDelayedSimpleClickTimeout&&l._previousDelayedSimpleClickTimeout.clearTimeout&&l._previousDelayedSimpleClickTimeout.clearTimeout(),l._previousDelayedSimpleClickTimeout=l._delayedSimpleClickTimeout,a(u,l._previousPickResult)):a(u,l._currentPickResult)):(l._doubleClickOccured=!1,l._previousStartingPointerTime=l._startingPointerTime,l._previousStartingPointerPosition.x=l._startingPointerPosition.x,l._previousStartingPointerPosition.y=l._startingPointerPosition.y,l._previousButtonPressed=f,l._previousHasSwiped=u.hasSwiped))}}u.ignore=!0,a(u,l._currentPickResult)};var h=function(e){return e.isPickable&&e.actionManager&&e.actionManager.hasPointerTriggers};this._onPointerMove=function(e){if(l._updatePointerPosition(e),l.onPrePointerObservable.hasObservers()){var t="mousewheel"===e.type||"DOMMouseScroll"===e.type?r.POINTERWHEEL:r.POINTERMOVE,i=new n(t,e,l._unTranslatedPointerX,l._unTranslatedPointerY);if(l.onPrePointerObservable.notifyObservers(i,t),i.skipOnPointerObservable)return}if(l.cameraToUseForPointers||l.activeCamera){var s=l._engine.getRenderingCanvas();l.pointerMovePredicate||(l.pointerMovePredicate=function(e){return e.isPickable&&e.isVisible&&e.isReady()&&e.isEnabled()&&(e.enablePointerMoveEvents||l.constantlyUpdateMeshUnderPointer||null!==e.actionManager&&void 0!==e.actionManager)});var a=l.pick(l._unTranslatedPointerX,l._unTranslatedPointerY,l.pointerMovePredicate,!1,l.cameraToUseForPointers);if(a&&a.hit&&a.pickedMesh?(l.setPointerOverSprite(null),l.setPointerOverMesh(a.pickedMesh),l._pointerOverMesh.actionManager&&l._pointerOverMesh.actionManager.hasPointerTriggers?l._pointerOverMesh.actionManager.hoverCursor?s.style.cursor=l._pointerOverMesh.actionManager.hoverCursor:s.style.cursor=l.hoverCursor:s.style.cursor=l.defaultCursor):(l.setPointerOverMesh(null),a=l.pickSprite(l._unTranslatedPointerX,l._unTranslatedPointerY,h,!1,l.cameraToUseForPointers),a&&a.hit&&a.pickedSprite?(l.setPointerOverSprite(a.pickedSprite),l._pointerOverSprite.actionManager&&l._pointerOverSprite.actionManager.hoverCursor?s.style.cursor=l._pointerOverSprite.actionManager.hoverCursor:s.style.cursor=l.hoverCursor):(l.setPointerOverSprite(null),s.style.cursor=l.defaultCursor)),l.onPointerMove&&l.onPointerMove(e,a),l.onPointerObservable.hasObservers()){var t="mousewheel"===e.type||"DOMMouseScroll"===e.type?r.POINTERWHEEL:r.POINTERMOVE,i=new o(t,e,a);l.onPointerObservable.notifyObservers(i,t)}}},this._onPointerDown=function(t){if(l._isButtonPressed=!0,l._pickedDownMesh=null,l._meshPickProceed=!1,l._updatePointerPosition(t),l.onPrePointerObservable.hasObservers()){var s=r.POINTERDOWN,a=new n(s,t,l._unTranslatedPointerX,l._unTranslatedPointerY);if(l.onPrePointerObservable.notifyObservers(a,s),a.skipOnPointerObservable)return}if(l.cameraToUseForPointers||l.activeCamera){l._startingPointerPosition.x=l._pointerX,l._startingPointerPosition.y=l._pointerY,l._startingPointerTime=(new Date).getTime(),l.pointerDownPredicate||(l.pointerDownPredicate=function(e){return e.isPickable&&e.isVisible&&e.isReady()&&e.isEnabled()}),l._pickedDownMesh=null;var u=l.pick(l._unTranslatedPointerX,l._unTranslatedPointerY,l.pointerDownPredicate,!1,l.cameraToUseForPointers);if(u&&u.hit&&u.pickedMesh){l._pickedDownMesh=u.pickedMesh;var c=u.pickedMesh.actionManager;if(c){if(c.hasPickTriggers)switch(c.processTrigger(e.ActionManager.OnPickDownTrigger,e.ActionEvent.CreateNew(u.pickedMesh,t)),t.button){case 0:c.processTrigger(e.ActionManager.OnLeftPickTrigger,e.ActionEvent.CreateNew(u.pickedMesh,t));break;case 1:c.processTrigger(e.ActionManager.OnCenterPickTrigger,e.ActionEvent.CreateNew(u.pickedMesh,t));break;case 2:c.processTrigger(e.ActionManager.OnRightPickTrigger,e.ActionEvent.CreateNew(u.pickedMesh,t))}c.hasSpecificTrigger(e.ActionManager.OnLongPressTrigger)&&window.setTimeout(function(){var r=this,n=this.pick(this._unTranslatedPointerX,this._unTranslatedPointerY,(function(t){return t.isPickable&&t.isVisible&&t.isReady()&&t.actionManager&&t.actionManager.hasSpecificTrigger(e.ActionManager.OnLongPressTrigger)&&t==r._pickedDownMesh}),!1,this.cameraToUseForPointers);n&&n.hit&&n.pickedMesh&&this._isButtonPressed&&(new Date).getTime()-this._startingPointerTime>i.LongPressDelay&&Math.abs(this._startingPointerPosition.x-this._pointerX)<i.DragMovementThreshold&&Math.abs(this._startingPointerPosition.y-this._pointerY)<i.DragMovementThreshold&&(this._startingPointerTime=0,c.processTrigger(e.ActionManager.OnLongPressTrigger,e.ActionEvent.CreateNew(n.pickedMesh,t)))}.bind(l),i.LongPressDelay)}}if(l.onPointerDown&&l.onPointerDown(t,u),l.onPointerObservable.hasObservers()){var s=r.POINTERDOWN,a=new o(s,t,u);l.onPointerObservable.notifyObservers(a,s)}if(l._pickedDownSprite=null,l.spriteManagers.length>0&&(u=l.pickSprite(l._unTranslatedPointerX,l._unTranslatedPointerY,h,!1,l.cameraToUseForPointers))&&u.hit&&u.pickedSprite&&u.pickedSprite.actionManager){switch(l._pickedDownSprite=u.pickedSprite,t.button){case 0:u.pickedSprite.actionManager.processTrigger(e.ActionManager.OnLeftPickTrigger,e.ActionEvent.CreateNewFromSprite(u.pickedSprite,l,t));break;case 1:u.pickedSprite.actionManager.processTrigger(e.ActionManager.OnCenterPickTrigger,e.ActionEvent.CreateNewFromSprite(u.pickedSprite,l,t));break;case 2:u.pickedSprite.actionManager.processTrigger(e.ActionManager.OnRightPickTrigger,e.ActionEvent.CreateNewFromSprite(u.pickedSprite,l,t))}u.pickedSprite.actionManager&&u.pickedSprite.actionManager.processTrigger(e.ActionManager.OnPickDownTrigger,e.ActionEvent.CreateNewFromSprite(u.pickedSprite,l,t))}}},this._onPointerUp=function(t){l._isButtonPressed=!1,l._pickedUpMesh=null,l._meshPickProceed=!1,l._updatePointerPosition(t),l._initClickEvent(l.onPrePointerObservable,l.onPointerObservable,t,function(s,a){if(this.onPrePointerObservable.hasObservers())if(s.ignore){var u=r.POINTERUP,l=new n(u,t,this._unTranslatedPointerX,this._unTranslatedPointerY);if(this.onPrePointerObservable.notifyObservers(l,u),l.skipOnPointerObservable)return}else if(!s.hasSwiped){if(s.singleClick&&this.onPrePointerObservable.hasSpecificMask(r.POINTERTAP)){var u=r.POINTERTAP,l=new n(u,t,this._unTranslatedPointerX,this._unTranslatedPointerY);if(this.onPrePointerObservable.notifyObservers(l,u),l.skipOnPointerObservable)return}if(s.doubleClick&&this.onPrePointerObservable.hasSpecificMask(r.POINTERDOUBLETAP)){var u=r.POINTERDOUBLETAP,l=new n(u,t,this._unTranslatedPointerX,this._unTranslatedPointerY);if(this.onPrePointerObservable.notifyObservers(l,u),l.skipOnPointerObservable)return}}if(this.cameraToUseForPointers||this.activeCamera){if(this.pointerUpPredicate||(this.pointerUpPredicate=function(e){return e.isPickable&&e.isVisible&&e.isReady()&&e.isEnabled()}),!this._meshPickProceed&&(e.ActionManager&&e.ActionManager.HasTriggers||this.onPointerObservable.hasObservers())&&this._initActionManager(null,s),a||(a=this._currentPickResult),a&&a&&a.pickedMesh){if(this._pickedUpMesh=a.pickedMesh,this._pickedDownMesh===this._pickedUpMesh&&(this.onPointerPick&&this.onPointerPick(t,a),s.singleClick&&!s.ignore&&this.onPointerObservable.hasObservers())){var u=r.POINTERPICK,l=new o(u,t,a);this.onPointerObservable.notifyObservers(l,u)}a.pickedMesh.actionManager&&(s.ignore&&a.pickedMesh.actionManager.processTrigger(e.ActionManager.OnPickUpTrigger,e.ActionEvent.CreateNew(a.pickedMesh,t)),s.hasSwiped||s.ignore||!s.singleClick||a.pickedMesh.actionManager.processTrigger(e.ActionManager.OnPickTrigger,e.ActionEvent.CreateNew(a.pickedMesh,t)),s.doubleClick&&!s.ignore&&a.pickedMesh.actionManager.hasSpecificTrigger(e.ActionManager.OnDoublePickTrigger)&&a.pickedMesh.actionManager.processTrigger(e.ActionManager.OnDoublePickTrigger,e.ActionEvent.CreateNew(a.pickedMesh,t)))}if(this._pickedDownMesh&&this._pickedDownMesh.actionManager&&this._pickedDownMesh.actionManager.hasSpecificTrigger(e.ActionManager.OnPickOutTrigger)&&this._pickedDownMesh!==this._pickedUpMesh&&this._pickedDownMesh.actionManager.processTrigger(e.ActionManager.OnPickOutTrigger,e.ActionEvent.CreateNew(this._pickedDownMesh,t)),this.onPointerUp&&this.onPointerUp(t,a),this.onPointerObservable.hasObservers())if(s.ignore){var u=r.POINTERUP,l=new o(u,t,a);this.onPointerObservable.notifyObservers(l,u)}else if(!s.hasSwiped){if(s.singleClick&&this.onPointerObservable.hasSpecificMask(r.POINTERTAP)){var u=r.POINTERTAP,l=new o(u,t,a);this.onPointerObservable.notifyObservers(l,u)}if(s.doubleClick&&this.onPointerObservable.hasSpecificMask(r.POINTERDOUBLETAP)){var u=r.POINTERDOUBLETAP,l=new o(u,t,a);this.onPointerObservable.notifyObservers(l,u)}}this.spriteManagers.length>0&&(a=this.pickSprite(this._unTranslatedPointerX,this._unTranslatedPointerY,h,!1,this.cameraToUseForPointers),a.hit&&a.pickedSprite&&a.pickedSprite.actionManager&&(a.pickedSprite.actionManager.processTrigger(e.ActionManager.OnPickUpTrigger,e.ActionEvent.CreateNewFromSprite(a.pickedSprite,this,t)),a.pickedSprite.actionManager&&Math.abs(this._startingPointerPosition.x-this._pointerX)<i.DragMovementThreshold&&Math.abs(this._startingPointerPosition.y-this._pointerY)<i.DragMovementThreshold&&a.pickedSprite.actionManager.processTrigger(e.ActionManager.OnPickTrigger,e.ActionEvent.CreateNewFromSprite(a.pickedSprite,this,t))),this._pickedDownSprite&&this._pickedDownSprite.actionManager&&this._pickedDownSprite!==a.pickedSprite&&this._pickedDownSprite.actionManager.processTrigger(e.ActionManager.OnPickOutTrigger,e.ActionEvent.CreateNewFromSprite(this._pickedDownSprite,this,t))),this._previousPickResult=this._currentPickResult}}.bind(l))},this._onKeyDown=function(t){l.actionManager&&l.actionManager.processTrigger(e.ActionManager.OnKeyDownTrigger,e.ActionEvent.CreateNewFromScene(l,t))},this._onKeyUp=function(t){l.actionManager&&l.actionManager.processTrigger(e.ActionManager.OnKeyUpTrigger,e.ActionEvent.CreateNewFromScene(l,t))};var c=e.Tools.GetPointerPrefix(),f=this._engine.getRenderingCanvas();u&&(f.addEventListener(c+"move",this._onPointerMove,!1),f.addEventListener("mousewheel",this._onPointerMove,!1),f.addEventListener("DOMMouseScroll",this._onPointerMove,!1)),a&&f.addEventListener(c+"down",this._onPointerDown,!1),s&&f.addEventListener(c+"up",this._onPointerUp,!1),f.tabIndex=1,f.addEventListener("keydown",this._onKeyDown,!1),f.addEventListener("keyup",this._onKeyUp,!1)},i.prototype.detachControl=function(){var t=e.Tools.GetPointerPrefix(),r=this._engine.getRenderingCanvas();r.removeEventListener(t+"move",this._onPointerMove),r.removeEventListener(t+"down",this._onPointerDown),r.removeEventListener(t+"up",this._onPointerUp),r.removeEventListener("mousewheel",this._onPointerMove),r.removeEventListener("DOMMouseScroll",this._onPointerMove),r.removeEventListener("keydown",this._onKeyDown),r.removeEventListener("keyup",this._onKeyUp)},i.prototype.isReady=function(){if(this._pendingData.length>0)return!1;var t;for(t=0;t<this._geometries.length;t++){if(this._geometries[t].delayLoadState===e.Engine.DELAYLOADSTATE_LOADING)return!1}for(t=0;t<this.meshes.length;t++){var r=this.meshes[t];if(r.isEnabled()&&(r.subMeshes&&0!==r.subMeshes.length)){if(!r.isReady())return!1;var i=r.material;if(i&&!i.isReady(r))return!1}}return!0},i.prototype.resetCachedMaterial=function(){this._cachedMaterial=null,this._cachedEffect=null,this._cachedVisibility=null},i.prototype.registerBeforeRender=function(e){this.onBeforeRenderObservable.add(e)},i.prototype.unregisterBeforeRender=function(e){this.onBeforeRenderObservable.removeCallback(e)},i.prototype.registerAfterRender=function(e){this.onAfterRenderObservable.add(e)},i.prototype.unregisterAfterRender=function(e){this.onAfterRenderObservable.removeCallback(e)},i.prototype._addPendingData=function(e){this._pendingData.push(e)},i.prototype._removePendingData=function(e){var t=this._pendingData.indexOf(e);-1!==t&&this._pendingData.splice(t,1)},i.prototype.getWaitingItemsCount=function(){return this._pendingData.length},i.prototype.executeWhenReady=function(e){var t=this;this.onReadyObservable.add(e),-1===this._executeWhenReadyTimeoutId&&(this._executeWhenReadyTimeoutId=setTimeout((function(){t._checkIsReady()}),150))},i.prototype._checkIsReady=function(){var e=this;if(this.isReady())return this.onReadyObservable.notifyObservers(this),this.onReadyObservable.clear(),void(this._executeWhenReadyTimeoutId=-1);this._executeWhenReadyTimeoutId=setTimeout((function(){e._checkIsReady()}),150)},i.prototype.beginAnimation=function(t,r,i,n,o,s,a){if(void 0===o&&(o=1),r>i&&o>0&&(o*=-1),this.stopAnimation(t),a||(a=new e.Animatable(this,t,r,i,n,o,s)),t.animations&&a.appendAnimations(t,t.animations),t.getAnimatables)for(var u=t.getAnimatables(),l=0;l<u.length;l++)this.beginAnimation(u[l],r,i,n,o,s,a);return a.reset(),a},i.prototype.beginDirectAnimation=function(t,r,i,n,o,s,a){return void 0===s&&(s=1),new e.Animatable(this,t,i,n,o,s,a,r)},i.prototype.getAnimatableByTarget=function(e){for(var t=0;t<this._activeAnimatables.length;t++)if(this._activeAnimatables[t].target===e)return this._activeAnimatables[t];return null},Object.defineProperty(i.prototype,"Animatables",{get:function(){return this._activeAnimatables},enumerable:!0,configurable:!0}),i.prototype.stopAnimation=function(e,t){var r=this.getAnimatableByTarget(e);r&&r.stop(t)},i.prototype._animate=function(){if(this.animationsEnabled&&0!==this._activeAnimatables.length){var t=e.Tools.Now;if(!this._animationTimeLast){if(this._pendingData.length>0)return;this._animationTimeLast=t}var r=(t-this._animationTimeLast)*this.animationTimeScale;this._animationTime+=r,this._animationTimeLast=t;for(var i=0;i<this._activeAnimatables.length;i++)this._activeAnimatables[i]._animate(this._animationTime)}},i.prototype.getViewMatrix=function(){return this._viewMatrix},i.prototype.getProjectionMatrix=function(){return this._projectionMatrix},i.prototype.getTransformMatrix=function(){return this._transformMatrix},i.prototype.setTransformMatrix=function(t,r){this._viewUpdateFlag===t.updateFlag&&this._projectionUpdateFlag===r.updateFlag||(this._viewUpdateFlag=t.updateFlag,this._projectionUpdateFlag=r.updateFlag,this._viewMatrix=t,this._projectionMatrix=r,this._viewMatrix.multiplyToRef(this._projectionMatrix,this._transformMatrix),this._frustumPlanes?e.Frustum.GetPlanesToRef(this._transformMatrix,this._frustumPlanes):this._frustumPlanes=e.Frustum.GetPlanes(this._transformMatrix),this._sceneUbo.useUbo&&(this._sceneUbo.updateMatrix("viewProjection",this._transformMatrix),this._sceneUbo.updateMatrix("view",this._viewMatrix),this._sceneUbo.update()))},i.prototype.getSceneUniformBuffer=function(){return this._sceneUbo},i.prototype.getUniqueId=function(){var e=this._uniqueIdCounter;return this._uniqueIdCounter++,e},i.prototype.addMesh=function(e){e.uniqueId=this.getUniqueId();this.meshes.push(e);this.collisionCoordinator&&this.collisionCoordinator.onMeshAdded(e),this.onNewMeshAddedObservable.notifyObservers(e)},i.prototype.removeMesh=function(e){var t=this.meshes.indexOf(e);return-1!==t&&this.meshes.splice(t,1),this.collisionCoordinator&&this.collisionCoordinator.onMeshRemoved(e),this.onMeshRemovedObservable.notifyObservers(e),t},i.prototype.removeSkeleton=function(e){var t=this.skeletons.indexOf(e);return-1!==t&&this.skeletons.splice(t,1),t},i.prototype.removeMorphTargetManager=function(e){var t=this.morphTargetManagers.indexOf(e);return-1!==t&&this.morphTargetManagers.splice(t,1),t},i.prototype.removeLight=function(e){var t=this.lights.indexOf(e);return-1!==t&&(this.lights.splice(t,1),this.sortLightsByPriority()),this.onLightRemovedObservable.notifyObservers(e),t},i.prototype.removeCamera=function(e){var t=this.cameras.indexOf(e);-1!==t&&this.cameras.splice(t,1);var r=this.activeCameras.indexOf(e);return-1!==r&&this.activeCameras.splice(r,1),this.activeCamera===e&&(this.cameras.length>0?this.activeCamera=this.cameras[0]:this.activeCamera=null),this.onCameraRemovedObservable.notifyObservers(e),t},i.prototype.addLight=function(e){e.uniqueId=this.getUniqueId(),this.lights.push(e),this.sortLightsByPriority(),this.onNewLightAddedObservable.notifyObservers(e)},i.prototype.sortLightsByPriority=function(){this.requireLightSorting&&this.lights.sort(e.Light.compareLightsPriority)},i.prototype.addCamera=function(e){e.uniqueId=this.getUniqueId();this.cameras.push(e);this.onNewCameraAddedObservable.notifyObservers(e)},i.prototype.switchActiveCamera=function(e,t){void 0===t&&(t=!0);var r=this._engine.getRenderingCanvas();this.activeCamera.detachControl(r),this.activeCamera=e,t&&e.attachControl(r)},i.prototype.setActiveCameraByID=function(e){var t=this.getCameraByID(e);return t?(this.activeCamera=t,t):null},i.prototype.setActiveCameraByName=function(e){var t=this.getCameraByName(e);return t?(this.activeCamera=t,t):null},i.prototype.getMaterialByID=function(e){for(var t=0;t<this.materials.length;t++)if(this.materials[t].id===e)return this.materials[t];return null},i.prototype.getMaterialByName=function(e){for(var t=0;t<this.materials.length;t++)if(this.materials[t].name===e)return this.materials[t];return null},i.prototype.getLensFlareSystemByName=function(e){for(var t=0;t<this.lensFlareSystems.length;t++)if(this.lensFlareSystems[t].name===e)return this.lensFlareSystems[t];return null},i.prototype.getLensFlareSystemByID=function(e){for(var t=0;t<this.lensFlareSystems.length;t++)if(this.lensFlareSystems[t].id===e)return this.lensFlareSystems[t];return null},i.prototype.getCameraByID=function(e){for(var t=0;t<this.cameras.length;t++)if(this.cameras[t].id===e)return this.cameras[t];return null},i.prototype.getCameraByUniqueID=function(e){for(var t=0;t<this.cameras.length;t++)if(this.cameras[t].uniqueId===e)return this.cameras[t];return null},i.prototype.getCameraByName=function(e){for(var t=0;t<this.cameras.length;t++)if(this.cameras[t].name===e)return this.cameras[t];return null},i.prototype.getBoneByID=function(e){for(var t=0;t<this.skeletons.length;t++)for(var r=this.skeletons[t],i=0;i<r.bones.length;i++)if(r.bones[i].id===e)return r.bones[i];return null},i.prototype.getBoneByName=function(e){for(var t=0;t<this.skeletons.length;t++)for(var r=this.skeletons[t],i=0;i<r.bones.length;i++)if(r.bones[i].name===e)return r.bones[i];return null},i.prototype.getLightByName=function(e){for(var t=0;t<this.lights.length;t++)if(this.lights[t].name===e)return this.lights[t];return null},i.prototype.getLightByID=function(e){for(var t=0;t<this.lights.length;t++)if(this.lights[t].id===e)return this.lights[t];return null},i.prototype.getLightByUniqueID=function(e){for(var t=0;t<this.lights.length;t++)if(this.lights[t].uniqueId===e)return this.lights[t];return null},i.prototype.getParticleSystemByID=function(e){for(var t=0;t<this.particleSystems.length;t++)if(this.particleSystems[t].id===e)return this.particleSystems[t];return null},i.prototype.getGeometryByID=function(e){for(var t=0;t<this._geometries.length;t++)if(this._geometries[t].id===e)return this._geometries[t];return null},i.prototype.pushGeometry=function(e,t){return!(!t&&this.getGeometryByID(e.id))&&(this._geometries.push(e),this.collisionCoordinator&&this.collisionCoordinator.onGeometryAdded(e),this.onNewGeometryAddedObservable.notifyObservers(e),!0)},i.prototype.removeGeometry=function(e){var t=this._geometries.indexOf(e);return t>-1&&(this._geometries.splice(t,1),this.collisionCoordinator&&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<this.meshes.length;t++)if(this.meshes[t].id===e)return this.meshes[t];return null},i.prototype.getMeshesByID=function(e){return this.meshes.filter((function(t){return t.id===e}))},i.prototype.getMeshByUniqueID=function(e){for(var t=0;t<this.meshes.length;t++)if(this.meshes[t].uniqueId===e)return this.meshes[t];return null},i.prototype.getLastMeshByID=function(e){for(var t=this.meshes.length-1;t>=0;t--)if(this.meshes[t].id===e)return this.meshes[t];return null},i.prototype.getLastEntryByID=function(e){var t;for(t=this.meshes.length-1;t>=0;t--)if(this.meshes[t].id===e)return this.meshes[t];for(t=this.cameras.length-1;t>=0;t--)if(this.cameras[t].id===e)return this.cameras[t];for(t=this.lights.length-1;t>=0;t--)if(this.lights[t].id===e)return this.lights[t];return null},i.prototype.getNodeByID=function(e){var t=this.getMeshByID(e);if(t)return t;var r=this.getLightByID(e);if(r)return r;var i=this.getCameraByID(e);return i||this.getBoneByID(e)},i.prototype.getNodeByName=function(e){var t=this.getMeshByName(e);if(t)return t;var r=this.getLightByName(e);if(r)return r;var i=this.getCameraByName(e);return i||this.getBoneByName(e)},i.prototype.getMeshByName=function(e){for(var t=0;t<this.meshes.length;t++)if(this.meshes[t].name===e)return this.meshes[t];return null},i.prototype.getSoundByName=function(t){var r;if(e.AudioEngine){for(r=0;r<this.mainSoundTrack.soundCollection.length;r++)if(this.mainSoundTrack.soundCollection[r].name===t)return this.mainSoundTrack.soundCollection[r];for(var i=0;i<this.soundTracks.length;i++)for(r=0;r<this.soundTracks[i].soundCollection.length;r++)if(this.soundTracks[i].soundCollection[r].name===t)return this.soundTracks[i].soundCollection[r]}return null},i.prototype.getLastSkeletonByID=function(e){for(var t=this.skeletons.length-1;t>=0;t--)if(this.skeletons[t].id===e)return this.skeletons[t];return null},i.prototype.getSkeletonById=function(e){for(var t=0;t<this.skeletons.length;t++)if(this.skeletons[t].id===e)return this.skeletons[t];return null},i.prototype.getSkeletonByName=function(e){for(var t=0;t<this.skeletons.length;t++)if(this.skeletons[t].name===e)return this.skeletons[t];return null},i.prototype.getMorphTargetManagerById=function(e){for(var t=0;t<this.morphTargetManagers.length;t++)if(this.morphTargetManagers[t].uniqueId===e)return this.morphTargetManagers[t];return null},i.prototype.isActiveMesh=function(e){return-1!==this._activeMeshes.indexOf(e)},i.prototype.getHighlightLayerByName=function(e){for(var t=0;t<this.highlightLayers.length;t++)if(this.highlightLayers[t].name===e)return this.highlightLayers[t];return null},Object.defineProperty(i.prototype,"uid",{get:function(){return this._uid||(this._uid=e.Tools.RandomId()),this._uid},enumerable:!0,configurable:!0}),i.prototype.addExternalData=function(t,r){return this._externalData||(this._externalData=new e.StringDictionary),this._externalData.add(t,r)},i.prototype.getExternalData=function(e){return this._externalData?this._externalData.get(e):null},i.prototype.getOrAddExternalDataWithFactory=function(t,r){return this._externalData||(this._externalData=new e.StringDictionary),this._externalData.getOrAddWithFactory(t,r)},i.prototype.removeExternalData=function(e){return this._externalData.remove(e)},i.prototype._evaluateSubMesh=function(e,t){if(t.alwaysSelectAsActiveMesh||1===t.subMeshes.length||e.isInFrustum(this._frustumPlanes)){var r=e.getMaterial();t.showSubMeshesBoundingBox&&this.getBoundingBoxRenderer().renderList.push(e.getBoundingInfo().boundingBox),r&&(r.getRenderTargetTextures&&-1===this._processedMaterials.indexOf(r)&&(this._processedMaterials.push(r),this._renderTargets.concatWithNoDuplicate(r.getRenderTargetTextures())),this._activeIndices.addCount(e.indexCount,!1),this._renderingManager.dispatch(e))}},i.prototype._isInIntermediateRendering=function(){return this._intermediateRendering},i.prototype._evaluateActiveMeshes=function(){this.activeCamera._activeMeshes.reset(),this._activeMeshes.reset(),this._renderingManager.reset(),this._processedMaterials.reset(),this._activeParticleSystems.reset(),this._activeSkeletons.reset(),this._softwareSkinnedMeshes.reset(),this._boundingBoxRenderer&&this._boundingBoxRenderer.reset();var t,r;if(this._selectionOctree){var i=this._selectionOctree.select(this._frustumPlanes);t=i.data,r=i.length}else r=this.meshes.length,t=this.meshes;for(var n=0;n<r;n++){var o=t[n];if(!o.isBlocked&&(this._totalVertices.addCount(o.getTotalVertices(),!1),o.isReady()&&o.isEnabled())){o.computeWorldMatrix(),o.actionManager&&o.actionManager.hasSpecificTriggers([e.ActionManager.OnIntersectionEnterTrigger,e.ActionManager.OnIntersectionExitTrigger])&&this._meshesForIntersections.pushNoDuplicate(o);var s=o.getLOD(this.activeCamera);s&&(o._preActivate(),(o.alwaysSelectAsActiveMesh||o.isVisible&&o.visibility>0&&0!=(o.layerMask&this.activeCamera.layerMask)&&o.isInFrustum(this._frustumPlanes))&&(this._activeMeshes.push(o),this.activeCamera._activeMeshes.push(o),o._activate(this._renderId),s!==o&&s._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;a<this.particleSystems.length;a++){var u=this.particleSystems[a];if(u.isStarted()&&u.emitter){var l=u.emitter;l.position&&!l.isEnabled()||(this._activeParticleSystems.push(u),u.animate(),this._renderingManager.dispatchParticles(u))}}e.Tools.EndPerformanceCounter("Particles",this.particleSystems.length>0)}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.getBoundingBoxRenderer().renderList.push(e.getBoundingInfo().boundingBox),t&&t.subMeshes){var r,i;if(t._submeshesOctree&&t.useOctreeForRenderingSelection){var n=t._submeshesOctree.select(this._frustumPlanes);r=n.length,i=n.data}else i=t.subMeshes,r=i.length;for(var o=0;o<r;o++){var s=i[o];this._evaluateSubMesh(s,t)}}},i.prototype.updateTransformMatrix=function(e){this.setTransformMatrix(this.activeCamera.getViewMatrix(),this.activeCamera.getProjectionMatrix(e))},i.prototype._renderForCamera=function(t){var r=this._engine;e.Tools.Now;if(this.activeCamera=t,!this.activeCamera)throw new Error("Active camera not set");e.Tools.StartPerformanceCounter("Rendering camera "+this.activeCamera.name),r.setViewport(this.activeCamera.viewport),this.resetCachedMaterial(),this._renderId++,this.updateTransformMatrix(),this.onBeforeCameraRenderObservable.notifyObservers(this.activeCamera),this._evaluateActiveMeshesDuration.beginMonitoring(),e.Tools.StartPerformanceCounter("Active meshes evaluation"),this._evaluateActiveMeshes(),this._evaluateActiveMeshesDuration.endMonitoring(!1),e.Tools.EndPerformanceCounter("Active meshes evaluation");for(var i=0;i<this._softwareSkinnedMeshes.length;i++){var n=this._softwareSkinnedMeshes.data[i];n.applySkeleton(n.skeleton)}this._renderTargetsDuration.beginMonitoring();var o=!1;e.Tools.Now;if(t.customRenderTargets&&t.customRenderTargets.length>0&&this._renderTargets.concatWithNoDuplicate(t.customRenderTargets),this.renderTargetsEnabled&&this._renderTargets.length>0){this._intermediateRendering=!0,e.Tools.StartPerformanceCounter("Render targets",this._renderTargets.length>0);for(var s=0;s<this._renderTargets.length;s++){var a=this._renderTargets.data[s];if(a._shouldRender()){this._renderId++;var u=a.activeCamera&&a.activeCamera!==this.activeCamera;a.render(u,this.dumpNextRenderTargets)}}e.Tools.EndPerformanceCounter("Render targets",this._renderTargets.length>0),this._intermediateRendering=!1,this._renderId++,o=!0}var l=this._engine.getStencilBuffer(),h=!1;if(this.renderTargetsEnabled&&this.highlightLayers&&this.highlightLayers.length>0){this._intermediateRendering=!0;for(var c=0;c<this.highlightLayers.length;c++){var f=this.highlightLayers[c];if(f.shouldRender()&&(!f.camera||f.camera.cameraRigMode===e.Camera.RIG_MODE_NONE&&t===f.camera||f.camera.cameraRigMode!==e.Camera.RIG_MODE_NONE&&f.camera._rigCameras.indexOf(t)>-1)){h=!0;var a=f._mainTexture;a._shouldRender()&&(this._renderId++,a.render(!1,!1),o=!0)}}this._intermediateRendering=!1,this._renderId++}o&&r.restoreDefaultFramebuffer(),this._renderTargetsDuration.endMonitoring(!1),this.postProcessManager._prepareFrame(),this._renderDuration.beginMonitoring();var d,p;if(this.layers.length){for(r.setDepthBuffer(!1),d=0;d<this.layers.length;d++)p=this.layers[d],p.isBackground&&0!=(p.layerMask&this.activeCamera.layerMask)&&p.render();r.setDepthBuffer(!0)}if(e.Tools.StartPerformanceCounter("Main render"),h&&this._engine.setStencilBuffer(!0),this._renderingManager.render(null,null,!0,!0),h&&this._engine.setStencilBuffer(l),e.Tools.EndPerformanceCounter("Main render"),this._boundingBoxRenderer&&this._boundingBoxRenderer.render(),this.lensFlaresEnabled){e.Tools.StartPerformanceCounter("Lens flares",this.lensFlareSystems.length>0);for(var g=0;g<this.lensFlareSystems.length;g++){var _=this.lensFlareSystems[g];0!=(t.layerMask&_.layerMask)&&_.render()}e.Tools.EndPerformanceCounter("Lens flares",this.lensFlareSystems.length>0)}if(this.layers.length){for(r.setDepthBuffer(!1),d=0;d<this.layers.length;d++)p=this.layers[d],p.isBackground||0==(p.layerMask&this.activeCamera.layerMask)||p.render();r.setDepthBuffer(!0)}if(h){r.setDepthBuffer(!1);for(var c=0;c<this.highlightLayers.length;c++)this.highlightLayers[c].shouldRender()&&this.highlightLayers[c].render();r.setDepthBuffer(!0)}this._renderDuration.endMonitoring(!1),this.postProcessManager._finalizeFrame(t.isIntermediate),this.activeCamera._updateFromScene(),this._renderTargets.reset(),this.onAfterCameraRenderObservable.notifyObservers(this.activeCamera),e.Tools.EndPerformanceCounter("Rendering camera "+this.activeCamera.name)},i.prototype._processSubCameras=function(t){if(t.cameraRigMode===e.Camera.RIG_MODE_NONE)return void this._renderForCamera(t);for(var r=0;r<t._rigCameras.length;r++)this._renderForCamera(t._rigCameras[r]);this.activeCamera=t,this.setTransformMatrix(this.activeCamera.getViewMatrix(),this.activeCamera.getProjectionMatrix()),this.activeCamera._updateFromScene()},i.prototype._checkIntersections=function(){for(var t=0;t<this._meshesForIntersections.length;t++)for(var r=this._meshesForIntersections.data[t],i=0;i<r.actionManager.actions.length;i++){var n=r.actionManager.actions[i];if(n.trigger===e.ActionManager.OnIntersectionEnterTrigger||n.trigger===e.ActionManager.OnIntersectionExitTrigger){
- var o=n.getTriggerParameter(),s=o instanceof e.AbstractMesh?o:o.mesh,a=s.intersectsMesh(r,o.usePreciseIntersection),u=r._intersectionsInProgress.indexOf(s);a&&-1===u?n.trigger===e.ActionManager.OnIntersectionEnterTrigger?(n._executeCurrent(e.ActionEvent.CreateNew(r,null,s)),r._intersectionsInProgress.push(s)):n.trigger===e.ActionManager.OnIntersectionExitTrigger&&r._intersectionsInProgress.push(s):!a&&u>-1&&(n.trigger===e.ActionManager.OnIntersectionExitTrigger&&n._executeCurrent(e.ActionEvent.CreateNew(r,null,s)),r.actionManager.hasSpecificTrigger(e.ActionManager.OnIntersectionExitTrigger)&&n.trigger!==e.ActionManager.OnIntersectionExitTrigger||r._intersectionsInProgress.splice(u,1))}}},i.prototype.render=function(){if(!this.isDisposed){if(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(),this._engine.isDeterministicLockStep()){var t=Math.max(i.MinDeltaTime,Math.min(this._engine.getDeltaTime(),i.MaxDeltaTime))/1e3,r=.06;this._physicsEngine&&(r=this._physicsEngine.getTimeStep());var n=this._engine.getLockstepMaxSteps();this._timeAccumulator+=t;var o=Math.floor(this._timeAccumulator/r);for(o=Math.min(o,n),this._currentInternalStep=0;this._currentInternalStep<o;this._currentInternalStep++)this.onBeforeStepObservable.notifyObservers(this),this._animationRatio=.06*r,this._animate(),this._physicsEngine&&(e.Tools.StartPerformanceCounter("Physics"),this._physicsEngine._step(r),e.Tools.EndPerformanceCounter("Physics")),this._timeAccumulator-=r,this.onAfterStepObservable.notifyObservers(this),this._currentStepId++,o>1&&this._currentInternalStep!=o-1&&this._evaluateActiveMeshes()}else{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 s=(e.Tools.Now,this.getEngine()),a=this.activeCamera;if(this.renderTargetsEnabled){e.Tools.StartPerformanceCounter("Custom render targets",this.customRenderTargets.length>0),this._intermediateRendering=!0;for(var u=0;u<this.customRenderTargets.length;u++){var l=this.customRenderTargets[u];if(l._shouldRender()){if(this._renderId++,this.activeCamera=l.activeCamera||this.activeCamera,!this.activeCamera)throw new Error("Active camera not set");s.setViewport(this.activeCamera.viewport),this.updateTransformMatrix(),l.render(a!==this.activeCamera,this.dumpNextRenderTargets)}}e.Tools.EndPerformanceCounter("Custom render targets",this.customRenderTargets.length>0),this._intermediateRendering=!1,this._renderId++}if(this.customRenderTargets.length>0&&s.restoreDefaultFramebuffer(),this._renderTargetsDuration.endMonitoring(),this.activeCamera=a,this.proceduralTexturesEnabled){e.Tools.StartPerformanceCounter("Procedural textures",this._proceduralTextures.length>0);for(var h=0;h<this._proceduralTextures.length;h++){var c=this._proceduralTextures[h];c._shouldRender()&&c.render()}e.Tools.EndPerformanceCounter("Procedural textures",this._proceduralTextures.length>0)}if((this.autoClearDepthAndStencil||this.autoClear)&&this._engine.clear(this.clearColor,this.autoClear||this.forceWireframe||this.forcePointsCloud,this.autoClearDepthAndStencil,this.autoClearDepthAndStencil),this.shadowsEnabled)for(var f=0;f<this.lights.length;f++){var d=this.lights[f],p=d.getShadowGenerator();if(d.isEnabled()&&d.shadowEnabled&&p){var g=p.getShadowMap();-1!==g.getScene().textures.indexOf(g)&&this._renderTargets.push(g)}}if(this._depthRenderer&&this._renderTargets.push(this._depthRenderer.getDepthMap()),this._geometryBufferRenderer&&this._renderTargets.push(this._geometryBufferRenderer.getGBuffer()),this._postProcessRenderPipelineManager&&this._postProcessRenderPipelineManager.update(),this.activeCameras.length>0)for(var _=0;_<this.activeCameras.length;_++)_>0&&this._engine.clear(null,!1,!0,!0),this._processSubCameras(this.activeCameras[_]);else{if(!this.activeCamera)throw new Error("No camera defined");this._processSubCameras(this.activeCamera)}this._checkIntersections(),e.AudioEngine&&this._updateAudioParameters(),this.afterRender&&this.afterRender(),this.onAfterRenderObservable.notifyObservers(this);for(var m=0;m<this._toBeDisposed.length;m++)this._toBeDisposed.data[m].dispose(),this._toBeDisposed[m]=null;this._toBeDisposed.reset(),this.dumpNextRenderTargets&&(this.dumpNextRenderTargets=!1),e.Tools.EndPerformanceCounter("Scene rendering"),this._lastFrameDuration.endMonitoring(),this._totalMeshesCounter.addCount(this.meshes.length,!0),this._totalLightsCounter.addCount(this.lights.length,!0),this._totalMaterialsCounter.addCount(this.materials.length,!0),this._totalTexturesCounter.addCount(this.textures.length,!0),this._activeBones.addCount(0,!0),this._activeIndices.addCount(0,!0),this._activeParticles.addCount(0,!0)}},i.prototype._updateAudioParameters=function(){if(this.audioEnabled&&(0!==this.mainSoundTrack.soundCollection.length||1!==this.soundTracks.length)){var t,r=e.Engine.audioEngine;if((t=this.activeCameras.length>0?this.activeCameras[0]:this.activeCamera)&&r.canUseWebAudio){r.audioContext.listener.setPosition(t.position.x,t.position.y,t.position.z),t.rigCameras&&t.rigCameras.length>0&&(t=t.rigCameras[0]);var i=e.Matrix.Invert(t.getViewMatrix()),n=e.Vector3.TransformNormal(new e.Vector3(0,0,-1),i);n.normalize(),isNaN(n.x)||isNaN(n.y)||isNaN(n.z)||r.audioContext.listener.setOrientation(n.x,n.y,n.z,0,1,0);var o;for(o=0;o<this.mainSoundTrack.soundCollection.length;o++){var s=this.mainSoundTrack.soundCollection[o];s.useCustomAttenuation&&s.updateDistanceFromListener()}for(o=0;o<this.soundTracks.length;o++)for(var a=0;a<this.soundTracks[o].soundCollection.length;a++)s=this.soundTracks[o].soundCollection[a],s.useCustomAttenuation&&s.updateDistanceFromListener()}}},Object.defineProperty(i.prototype,"audioEnabled",{get:function(){return this._audioEnabled},set:function(t){this._audioEnabled=t,e.AudioEngine&&(this._audioEnabled?this._enableAudio():this._disableAudio())},enumerable:!0,configurable:!0}),i.prototype._disableAudio=function(){var e;for(e=0;e<this.mainSoundTrack.soundCollection.length;e++)this.mainSoundTrack.soundCollection[e].pause();for(e=0;e<this.soundTracks.length;e++)for(var t=0;t<this.soundTracks[e].soundCollection.length;t++)this.soundTracks[e].soundCollection[t].pause()},i.prototype._enableAudio=function(){var e;for(e=0;e<this.mainSoundTrack.soundCollection.length;e++)this.mainSoundTrack.soundCollection[e].isPaused&&this.mainSoundTrack.soundCollection[e].play();for(e=0;e<this.soundTracks.length;e++)for(var t=0;t<this.soundTracks[e].soundCollection.length;t++)this.soundTracks[e].soundCollection[t].isPaused&&this.soundTracks[e].soundCollection[t].play()},Object.defineProperty(i.prototype,"headphone",{get:function(){return this._headphone},set:function(t){this._headphone=t,e.AudioEngine&&(this._headphone?this._switchAudioModeForHeadphones():this._switchAudioModeForNormalSpeakers())},enumerable:!0,configurable:!0}),i.prototype._switchAudioModeForHeadphones=function(){this.mainSoundTrack.switchPanningModelToHRTF();for(var e=0;e<this.soundTracks.length;e++)this.soundTracks[e].switchPanningModelToHRTF()},i.prototype._switchAudioModeForNormalSpeakers=function(){this.mainSoundTrack.switchPanningModelToEqualPower();for(var e=0;e<this.soundTracks.length;e++)this.soundTracks[e].switchPanningModelToEqualPower()},i.prototype.enableDepthRenderer=function(){return this._depthRenderer?this._depthRenderer:(this._depthRenderer=new e.DepthRenderer(this),this._depthRenderer)},i.prototype.disableDepthRenderer=function(){this._depthRenderer&&(this._depthRenderer.dispose(),this._depthRenderer=null)},i.prototype.enableGeometryBufferRenderer=function(t){return void 0===t&&(t=1),this._geometryBufferRenderer?this._geometryBufferRenderer:(this._geometryBufferRenderer=new e.GeometryBufferRenderer(this,t),this._geometryBufferRenderer.isSupported||(this._geometryBufferRenderer=null),this._geometryBufferRenderer)},i.prototype.disableGeometryBufferRenderer=function(){this._geometryBufferRenderer&&(this._geometryBufferRenderer.dispose(),this._geometryBufferRenderer=null)},i.prototype.freezeMaterials=function(){for(var e=0;e<this.materials.length;e++)this.materials[e].freeze()},i.prototype.unfreezeMaterials=function(){for(var e=0;e<this.materials.length;e++)this.materials[e].unfreeze()},i.prototype.dispose=function(){this.beforeRender=null,this.afterRender=null,this.skeletons=[],this.morphTargetManagers=[],this.importedMeshesFiles=new Array,this.resetCachedMaterial(),this._depthRenderer&&this._depthRenderer.dispose(),this.activeCamera&&(this.activeCamera._activeMeshes.dispose(),this.activeCamera=null),this._activeMeshes.dispose(),this._renderingManager.dispose(),this._processedMaterials.dispose(),this._activeParticleSystems.dispose(),this._activeSkeletons.dispose(),this._softwareSkinnedMeshes.dispose(),this._renderTargets.dispose(),this._boundingBoxRenderer&&this._boundingBoxRenderer.dispose(),this._meshesForIntersections.dispose(),this._toBeDisposed.dispose(),this._debugLayer&&this._debugLayer.hide(),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this.onBeforeRenderObservable.clear(),this.onAfterRenderObservable.clear(),this.detachControl(),e.AudioEngine&&this.disposeSounds(),this.VRHelper&&this.VRHelper.dispose();var t,r=this._engine.getRenderingCanvas();for(t=0;t<this.cameras.length;t++)this.cameras[t].detachControl(r);for(;this.lights.length;)this.lights[0].dispose();for(;this.meshes.length;)this.meshes[0].dispose(!0);for(;this.cameras.length;)this.cameras[0].dispose();for(this.defaultMaterial&&this.defaultMaterial.dispose();this.multiMaterials.length;)this.multiMaterials[0].dispose();for(;this.materials.length;)this.materials[0].dispose();for(;this.particleSystems.length;)this.particleSystems[0].dispose();for(;this.spriteManagers.length;)this.spriteManagers[0].dispose();for(;this.layers.length;)this.layers[0].dispose();for(;this.highlightLayers.length;)this.highlightLayers[0].dispose();for(;this.textures.length;)this.textures[0].dispose();this._sceneUbo.dispose(),this.postProcessManager.dispose(),this._physicsEngine&&this.disablePhysicsEngine(),t=this._engine.scenes.indexOf(this),t>-1&&this._engine.scenes.splice(t,1),this._engine.wipeCaches(),this._engine=null,this.defaultMaterial=null,this.multiMaterials=null,this.materials=null},Object.defineProperty(i.prototype,"isDisposed",{get:function(){return!this._engine},enumerable:!0,configurable:!0}),i.prototype.disposeSounds=function(){this.mainSoundTrack.dispose();for(var e=0;e<this.soundTracks.length;e++)this.soundTracks[e].dispose()},i.prototype.getWorldExtends=function(){for(var t=new e.Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),r=new e.Vector3(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),i=0;i<this.meshes.length;i++){var n=this.meshes[i];n.computeWorldMatrix(!0);var o=n.getBoundingInfo().boundingBox.minimumWorld,s=n.getBoundingInfo().boundingBox.maximumWorld;e.Tools.CheckExtends(o,t,r),e.Tools.CheckExtends(s,t,r)}return{min:t,max:r}},i.prototype.createOrUpdateSelectionOctree=function(t,r){void 0===t&&(t=64),void 0===r&&(r=2),this._selectionOctree||(this._selectionOctree=new e.Octree(e.Octree.CreationFuncForMeshes,t,r));var i=this.getWorldExtends();return this._selectionOctree.update(i.min,i.max,this.meshes),this._selectionOctree},i.prototype.createPickingRay=function(t,r,i,n,o){void 0===o&&(o=!1);var s=this._engine;if(!n){if(!this.activeCamera)throw new Error("Active camera not set");n=this.activeCamera}var a=n.viewport,u=a.toGlobal(s.getRenderWidth(),s.getRenderHeight());return t=t/this._engine.getHardwareScalingLevel()-u.x,r=r/this._engine.getHardwareScalingLevel()-(this._engine.getRenderHeight()-u.y-u.height),e.Ray.CreateNew(t,r,u.width,u.height,i||e.Matrix.Identity(),o?e.Matrix.Identity():n.getViewMatrix(),n.getProjectionMatrix())},i.prototype.createPickingRayInCameraSpace=function(t,r,i){if(!e.PickingInfo)return null;var n=this._engine;if(!i){if(!this.activeCamera)throw new Error("Active camera not set");i=this.activeCamera}var o=i.viewport,s=o.toGlobal(n.getRenderWidth(),n.getRenderHeight()),a=e.Matrix.Identity();return t=t/this._engine.getHardwareScalingLevel()-s.x,r=r/this._engine.getHardwareScalingLevel()-(this._engine.getRenderHeight()-s.y-s.height),e.Ray.CreateNew(t,r,s.width,s.height,a,a,i.getProjectionMatrix())},i.prototype._internalPick=function(t,r,i){if(!e.PickingInfo)return null;for(var n=null,o=0;o<this.meshes.length;o++){var s=this.meshes[o];if(r){if(!r(s))continue}else if(!s.isEnabled()||!s.isVisible||!s.isPickable)continue;var a=s.getWorldMatrix(),u=t(a),l=s.intersects(u,i);if(l&&l.hit&&((i||null==n||!(l.distance>=n.distance))&&(n=l,i)))break}return n||new e.PickingInfo},i.prototype._internalMultiPick=function(t,r){if(!e.PickingInfo)return null;for(var i=new Array,n=0;n<this.meshes.length;n++){var o=this.meshes[n];if(r){if(!r(o))continue}else if(!o.isEnabled()||!o.isVisible||!o.isPickable)continue;var s=o.getWorldMatrix(),a=t(s),u=o.intersects(a,!1);u&&u.hit&&i.push(u)}return i},i.prototype._internalPickSprites=function(t,r,i,n){if(!e.PickingInfo)return null;var o=null;if(n=n||this.activeCamera,this.spriteManagers.length>0)for(var s=0;s<this.spriteManagers.length;s++){var a=this.spriteManagers[s];if(a.isPickable){var u=a.intersects(t,n,r,i);if(u&&u.hit&&(i||null==o||!(u.distance>=o.distance))&&(o=u,i))break}}return o||new e.PickingInfo},i.prototype.pick=function(e,t,r,i,n){var o=this;return this._internalPick((function(r){return o.createPickingRay(e,t,r,n)}),r,i)},i.prototype.pickSprite=function(e,t,r,i,n){return this._internalPickSprites(this.createPickingRayInCameraSpace(e,t,n),r,i,n)},i.prototype.pickWithRay=function(t,r,i){var n=this;return this._internalPick((function(r){return n._pickWithRayInverseMatrix||(n._pickWithRayInverseMatrix=e.Matrix.Identity()),r.invertToRef(n._pickWithRayInverseMatrix),e.Ray.Transform(t,n._pickWithRayInverseMatrix)}),r,i)},i.prototype.multiPick=function(e,t,r,i){var n=this;return this._internalMultiPick((function(r){return n.createPickingRay(e,t,r,i)}),r)},i.prototype.multiPickWithRay=function(t,r){var i=this;return this._internalMultiPick((function(r){return i._pickWithRayInverseMatrix||(i._pickWithRayInverseMatrix=e.Matrix.Identity()),r.invertToRef(i._pickWithRayInverseMatrix),e.Ray.Transform(t,i._pickWithRayInverseMatrix)}),r)},i.prototype.setPointerOverMesh=function(t){this._pointerOverMesh!==t&&(this._pointerOverMesh&&this._pointerOverMesh.actionManager&&this._pointerOverMesh.actionManager.processTrigger(e.ActionManager.OnPointerOutTrigger,e.ActionEvent.CreateNew(this._pointerOverMesh)),this._pointerOverMesh=t,this._pointerOverMesh&&this._pointerOverMesh.actionManager&&this._pointerOverMesh.actionManager.processTrigger(e.ActionManager.OnPointerOverTrigger,e.ActionEvent.CreateNew(this._pointerOverMesh)))},i.prototype.getPointerOverMesh=function(){return this._pointerOverMesh},i.prototype.setPointerOverSprite=function(t){this._pointerOverSprite!==t&&(this._pointerOverSprite&&this._pointerOverSprite.actionManager&&this._pointerOverSprite.actionManager.processTrigger(e.ActionManager.OnPointerOutTrigger,e.ActionEvent.CreateNewFromSprite(this._pointerOverSprite,this)),this._pointerOverSprite=t,this._pointerOverSprite&&this._pointerOverSprite.actionManager&&this._pointerOverSprite.actionManager.processTrigger(e.ActionManager.OnPointerOverTrigger,e.ActionEvent.CreateNewFromSprite(this._pointerOverSprite,this)))},i.prototype.getPointerOverSprite=function(){return this._pointerOverSprite},i.prototype.getPhysicsEngine=function(){return this._physicsEngine},i.prototype.enablePhysics=function(t,r){if(this._physicsEngine)return!0;try{return this._physicsEngine=new e.PhysicsEngine(t,r),!0}catch(t){return e.Tools.Error(t.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.deleteCompoundImpostor=function(e){var t=e.parts[0].mesh;t.physicsImpostor.dispose(),t.physicsImpostor=null},i.prototype.createDefaultCameraOrLight=function(t,r,i){if(void 0===t&&(t=!1),void 0===r&&(r=!1),void 0===i&&(i=!1),r&&(this.activeCamera&&(this.activeCamera.dispose(),this.activeCamera=null),this.lights))for(var n=0;n<this.lights.length;n++)this.lights[n].dispose();if(0===this.lights.length&&new e.HemisphericLight("default light",e.Vector3.Up(),this),!this.activeCamera){var o,s=this.getWorldExtends(),a=s.max.subtract(s.min),u=s.min.add(a.scale(.5)),l=1.5*a.length();if(t){var h=new e.ArcRotateCamera("default camera",-Math.PI/2,Math.PI/2,l,u,this);h.lowerRadiusLimit=.01*l,h.wheelPrecision=100/l,o=h}else{var c=new e.FreeCamera("default camera",new e.Vector3(u.x,u.y,-l),this);c.setTarget(u),o=c}o.minZ=.01*l,o.maxZ=100*l,o.speed=.2*l,this.activeCamera=o,i&&o.attachControl(this.getEngine().getRenderingCanvas())}},i.prototype.createDefaultSkybox=function(t,r,i,n){if(void 0===r&&(r=!1),void 0===i&&(i=1e3),void 0===n&&(n=0),t&&(this.environmentTexture=t),!this.environmentTexture)return void e.Tools.Warn("Can not create default skybox without environment texture.");var o=e.Mesh.CreateBox("hdrSkyBox",i,this);if(r){var s=new e.PBRMaterial("skyBox",this);s.backFaceCulling=!1,s.reflectionTexture=this.environmentTexture.clone(),s.reflectionTexture.coordinatesMode=e.Texture.SKYBOX_MODE,s.microSurface=1-n,s.disableLighting=!0,s.twoSidedLighting=!0,o.infiniteDistance=!0,o.material=s}else{var a=new e.StandardMaterial("skyBox",this);a.backFaceCulling=!1,a.reflectionTexture=this.environmentTexture.clone(),a.reflectionTexture.coordinatesMode=e.Texture.SKYBOX_MODE,a.disableLighting=!0,o.infiniteDistance=!0,o.material=a}return o},i.prototype.createDefaultVRExperience=function(){this.VRHelper=new e.VRExperienceHelper(this,null)},i.prototype._getByTags=function(t,r,i){if(void 0===r)return t;var n=[];i=i||function(e){};for(var o in t){var s=t[o];e.Tags.MatchesQuery(s,r)&&(n.push(s),i(s))}return n},i.prototype.getMeshesByTags=function(e,t){return this._getByTags(this.meshes,e,t)},i.prototype.getCamerasByTags=function(e,t){return this._getByTags(this.cameras,e,t)},i.prototype.getLightsByTags=function(e,t){return this._getByTags(this.lights,e,t)},i.prototype.getMaterialByTags=function(e,t){return this._getByTags(this.materials,e,t).concat(this._getByTags(this.multiMaterials,e,t))},i.prototype.setRenderingOrder=function(e,t,r,i){void 0===t&&(t=null),void 0===r&&(r=null),void 0===i&&(i=null),this._renderingManager.setRenderingOrder(e,t,r,i)},i.prototype.setRenderingAutoClearDepthStencil=function(e,t,r,i){void 0===r&&(r=!0),void 0===i&&(i=!0),this._renderingManager.setRenderingAutoClearDepthStencil(e,t,r,i)},i.prototype.markAllMaterialsAsDirty=function(e,t){for(var r=0,i=this.materials;r<i.length;r++){var n=i[r];t&&!t(n)||n.markAsDirty(e)}},i._FOGMODE_NONE=0,i._FOGMODE_EXP=1,i._FOGMODE_EXP2=2,i._FOGMODE_LINEAR=3,i.MinDeltaTime=1,i.MaxDeltaTime=1e3,i.DragMovementThreshold=10,i.LongPressDelay=500,i.DoubleClickDelay=300,i.ExclusiveDoubleClickMode=!1,i})();e.Scene=a})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(t,r,i,n,o,s){t instanceof e.Mesh?this._engine=t.getScene().getEngine():this._engine=t,this._updatable=i,this._data=r,this._strideSize=n,o||this.create(),this._instanced=s,this._instanceDivisor=s?1:0}return t.prototype.createVertexBuffer=function(t,r,i,n){return new e.VertexBuffer(this._engine,this,t,this._updatable,!0,n||this._strideSize,this._instanced,r,i)},t.prototype.isUpdatable=function(){return this._updatable},t.prototype.getData=function(){return this._data},t.prototype.getBuffer=function(){return this._buffer},t.prototype.getStrideSize=function(){return this._strideSize},t.prototype.getIsInstanced=function(){return this._instanced},Object.defineProperty(t.prototype,"instanceDivisor",{get:function(){return this._instanceDivisor},set:function(e){this._instanceDivisor=e,this._instanced=0!=e},enumerable:!0,configurable:!0}),t.prototype.create=function(e){!e&&this._buffer||(e=e||this._data,this._buffer?this._updatable&&(this._engine.updateDynamicVertexBuffer(this._buffer,e),this._data=e):this._updatable?(this._buffer=this._engine.createDynamicVertexBuffer(e),this._data=e):this._buffer=this._engine.createVertexBuffer(e))},t.prototype.update=function(e){this.create(e)},t.prototype.updateDirectly=function(e,t,r){this._buffer&&this._updatable&&(this._engine.updateDynamicVertexBuffer(this._buffer,e,t,r?r*this.getStrideSize():void 0),this._data=null)},t.prototype.dispose=function(){this._buffer&&this._engine._releaseBuffer(this._buffer)&&(this._buffer=null)},t})();e.Buffer=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(r,i,n,o,s,a,u,l,h){if(!a)switch(n){case t.PositionKind:case t.NormalKind:a=3;break;case t.UVKind:case t.UV2Kind:case t.UV3Kind:case t.UV4Kind:case t.UV5Kind:case t.UV6Kind:a=2;break;case t.TangentKind:case t.ColorKind:a=4;break;case t.MatricesIndicesKind:case t.MatricesIndicesExtraKind:a=4;break;case t.MatricesWeightsKind:case t.MatricesWeightsExtraKind:a=4}i instanceof e.Buffer?(a||(a=i.getStrideSize()),this._buffer=i,this._ownsBuffer=!1):(this._buffer=new e.Buffer(r,i,o,a,s,u),this._ownsBuffer=!0),this._stride=a,this._offset=l||0,this._size=h||a,this._kind=n}return t.prototype.getKind=function(){return this._kind},t.prototype.isUpdatable=function(){return this._buffer.isUpdatable()},t.prototype.getData=function(){return this._buffer.getData()},t.prototype.getBuffer=function(){return this._buffer.getBuffer()},t.prototype.getStrideSize=function(){return this._stride},t.prototype.getOffset=function(){return this._offset},t.prototype.getSize=function(){return this._size},t.prototype.getIsInstanced=function(){return this._buffer.getIsInstanced()},t.prototype.getInstanceDivisor=function(){return this._buffer.instanceDivisor},t.prototype.create=function(e){return this._buffer.create(e)},t.prototype.update=function(e){return this._buffer.update(e)},t.prototype.updateDirectly=function(e,t){return this._buffer.updateDirectly(e,t)},t.prototype.dispose=function(){this._ownsBuffer&&this._buffer.dispose()},Object.defineProperty(t,"PositionKind",{get:function(){return t._PositionKind},enumerable:!0,configurable:!0}),Object.defineProperty(t,"NormalKind",{get:function(){return t._NormalKind},enumerable:!0,configurable:!0}),Object.defineProperty(t,"TangentKind",{get:function(){return t._TangentKind},enumerable:!0,configurable:!0}),Object.defineProperty(t,"UVKind",{get:function(){return t._UVKind},enumerable:!0,configurable:!0}),Object.defineProperty(t,"UV2Kind",{get:function(){return t._UV2Kind},enumerable:!0,configurable:!0}),Object.defineProperty(t,"UV3Kind",{get:function(){return t._UV3Kind},enumerable:!0,configurable:!0}),Object.defineProperty(t,"UV4Kind",{get:function(){return t._UV4Kind},enumerable:!0,configurable:!0}),Object.defineProperty(t,"UV5Kind",{get:function(){return t._UV5Kind},enumerable:!0,configurable:!0}),Object.defineProperty(t,"UV6Kind",{get:function(){return t._UV6Kind},enumerable:!0,configurable:!0}),Object.defineProperty(t,"ColorKind",{get:function(){return t._ColorKind},enumerable:!0,configurable:!0}),Object.defineProperty(t,"MatricesIndicesKind",{get:function(){return t._MatricesIndicesKind},enumerable:!0,configurable:!0}),Object.defineProperty(t,"MatricesWeightsKind",{get:function(){return t._MatricesWeightsKind},enumerable:!0,configurable:!0}),Object.defineProperty(t,"MatricesIndicesExtraKind",{get:function(){return t._MatricesIndicesExtraKind},enumerable:!0,configurable:!0}),Object.defineProperty(t,"MatricesWeightsExtraKind",{get:function(){return t._MatricesWeightsExtraKind},enumerable:!0,configurable:!0}),t._PositionKind="position",t._NormalKind="normal",t._TangentKind="tangent",t._UVKind="uv",t._UV2Kind="uv2",t._UV3Kind="uv3",t._UV4Kind="uv4",t._UV5Kind="uv5",t._UV6Kind="uv6",t._ColorKind="color",t._MatricesIndicesKind="matricesIndices",t._MatricesWeightsKind="matricesWeights",t._MatricesIndicesExtraKind="matricesIndicesExtra",t._MatricesWeightsExtraKind="matricesWeightsExtra",t})();e.VertexBuffer=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(r){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=t.DEFAULT_ANISOTROPIC_FILTERING_LEVEL,this.isCube=!1,this.gammaSpace=!0,this.invertZ=!1,this.lodLevelInAlpha=!1,this.lodGenerationOffset=0,this.lodGenerationScale=.8,this.isRenderTarget=!1,this.animations=new Array,this.onDisposeObservable=new e.Observable,this.delayLoadState=e.Engine.DELAYLOADSTATE_NONE,this._scene=r||e.Engine.LastCreatedScene,this._scene.textures.push(this),this._uid=null}return Object.defineProperty(t.prototype,"hasAlpha",{get:function(){return this._hasAlpha},set:function(t){this._hasAlpha!==t&&(this._hasAlpha=t,this._scene.markAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"coordinatesMode",{get:function(){return this._coordinatesMode},set:function(t){this._coordinatesMode!==t&&(this._coordinatesMode=t,this._scene.markAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),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},t.prototype.getClassName=function(){return"BaseTexture"},Object.defineProperty(t.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isBlocking",{get:function(){return!0},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.isReadyOrNotBlocking=function(){return!this.isBlocking||this.isReady()},t.prototype.isReady=function(){return this.delayLoadState===e.Engine.DELAYLOADSTATE_NOTLOADED?(this.delayLoad(),!1):!!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 r=this._scene.getEngine().getLoadedTexturesCache(),i=0;i<r.length;i++){var n=r[i];if(n.url===e&&n.generateMipMaps===!t)return void r.splice(i,1)}},t.prototype._getFromCache=function(e,t,r){for(var i=this._scene.getEngine().getLoadedTexturesCache(),n=0;n<i.length;n++){var o=i[n];if(o.url===e&&o.generateMipMaps===!t&&(!r||r===o.samplingMode))return o.references++,o}return null},t.prototype.delayLoad=function(){},t.prototype.clone=function(){return null},Object.defineProperty(t.prototype,"textureType",{get:function(){return this._texture&&void 0!==this._texture.type?this._texture.type:e.Engine.TEXTURETYPE_UNSIGNED_INT},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"textureFormat",{get:function(){return this._texture&&void 0!==this._texture.format?this._texture.format:e.Engine.TEXTUREFORMAT_RGBA},enumerable:!0,configurable:!0}),t.prototype.readPixels=function(e){if(void 0===e&&(e=0),!this._texture)return null;var t=this.getSize(),r=this.getScene().getEngine();return this._texture.isCube?r._readTexturePixels(this._texture,t.width,t.height,e):r._readTexturePixels(this._texture,t.width,t.height,-1)},t.prototype.releaseInternalTexture=function(){this._texture&&(this._scene.getEngine().releaseInternalTexture(this._texture),delete this._texture)},Object.defineProperty(t.prototype,"sphericalPolynomial",{get:function(){return this._texture&&e.Internals.CubeMapToSphericalPolynomialTools&&this.isReady()?(this._texture._sphericalPolynomial||(this._texture._sphericalPolynomial=e.Internals.CubeMapToSphericalPolynomialTools.ConvertCubeMapTextureToSphericalPolynomial(this)),this._texture._sphericalPolynomial):null},set:function(e){this._texture&&(this._texture._sphericalPolynomial=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"_lodTextureHigh",{get:function(){return this._texture?this._texture._lodTextureHigh:null},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"_lodTextureMid",{get:function(){return this._texture?this._texture._lodTextureMid:null},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"_lodTextureLow",{get:function(){return this._texture?this._texture._lodTextureLow:null},enumerable:!0,configurable:!0}),t.prototype.dispose=function(){this.getScene().stopAnimation(this),this._scene._removePendingData(this);var e=this._scene.textures.indexOf(this);e>=0&&this._scene.textures.splice(e,1),void 0!==this._texture&&(this.releaseInternalTexture(),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear())},t.prototype.serialize=function(){if(!this.name)return null;var t=e.SerializationHelper.Serialize(this);return e.Animation.AppendSerializedAnimations(this,t),t},t.WhenAllReady=function(e,t){var r=e.length;if(0===r)return void t();for(var i,n,o=0;o<e.length;o++)!(function(){if(i=e[o],i.isReady())0==--r&&t();else{n=i.onLoadObservable;var s=function(){n.removeCallback(s),0==--r&&t()};n.add(s)}})()},t.DEFAULT_ANISOTROPIC_FILTERING_LEVEL=4,__decorate([e.serialize()],t.prototype,"name",void 0),__decorate([e.serialize("hasAlpha")],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("coordinatesMode")],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,"gammaSpace",void 0),__decorate([e.serialize()],t.prototype,"invertZ",void 0),__decorate([e.serialize()],t.prototype,"lodLevelInAlpha",void 0),__decorate([e.serialize()],t.prototype,"lodGenerationOffset",void 0),__decorate([e.serialize()],t.prototype,"lodGenerationScale",void 0),__decorate([e.serialize()],t.prototype,"isRenderTarget",void 0),t})();e.BaseTexture=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(i,n,o,s,a,u,l,h,c,f){void 0===o&&(o=!1),void 0===s&&(s=!0),void 0===a&&(a=r.TRILINEAR_SAMPLINGMODE),
- void 0===u&&(u=null),void 0===l&&(l=null),void 0===h&&(h=null),void 0===c&&(c=!1);var d=t.call(this,n)||this;d.uOffset=0,d.vOffset=0,d.uScale=1,d.vScale=1,d.uAng=0,d.vAng=0,d.wAng=0,d._isBlocking=!0,d.name=i,d.url=i,d._noMipmap=o,d._invertY=s,d._samplingMode=a,d._buffer=h,d._deleteBuffer=c,d._format=f,n=d.getScene();var p=function(){d._onLoadObservable&&d._onLoadObservable.hasObservers()&&d.onLoadObservable.notifyObservers(d),u&&u(),d.isBlocking||n.resetCachedMaterial()};return i?(d._texture=d._getFromCache(i,o,a),d._texture?d._texture.isReady?e.Tools.SetImmediate((function(){return p()})):d._texture.onLoadedCallbacks.push(p):n.useDelayedTextureLoading?(d.delayLoadState=e.Engine.DELAYLOADSTATE_NOTLOADED,d._delayedOnLoad=p,d._delayedOnError=l):(d._texture=n.getEngine().createTexture(i,o,s,n,d._samplingMode,p,l,d._buffer,null,d._format),c&&delete d._buffer),d):(d._delayedOnLoad=p,d._delayedOnError=l,d)}return __extends(r,t),Object.defineProperty(r.prototype,"noMipmap",{get:function(){return this._noMipmap},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"isBlocking",{get:function(){return this._isBlocking},set:function(e){this._isBlocking=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"samplingMode",{get:function(){return this._samplingMode},enumerable:!0,configurable:!0}),r.prototype.updateURL=function(t){this.url=t,this.delayLoadState=e.Engine.DELAYLOADSTATE_NOTLOADED,this.delayLoad()},r.prototype.delayLoad=function(){var t=this;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.isReady?e.Tools.SetImmediate((function(){return t._delayedOnLoad()})):this._texture.onLoadedCallbacks.push(this._delayedOnLoad):(this._texture=this.getScene().getEngine().createTexture(this.url,this._noMipmap,this._invertY,this.getScene(),this._samplingMode,this._delayedOnLoad,this._delayedOnError,this._buffer,null,this._format),this._deleteBuffer&&delete this._buffer))},r.prototype.updateSamplingMode=function(e){this._texture&&(this._samplingMode=e,this.getScene().getEngine().updateTextureSamplingMode(e,this._texture))},r.prototype._prepareRowForTextureGeneration=function(t,r,i,n){t*=this.uScale,r*=this.vScale,t-=.5*this.uScale,r-=.5*this.vScale,i-=.5,e.Vector3.TransformCoordinatesFromFloatsToRef(t,r,i,this._rowGenerationMatrix,n),n.x+=.5*this.uScale+this.uOffset,n.y+=.5*this.vScale+this.vOffset,n.z+=.5},r.prototype.getTextureMatrix=function(){var t=this;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.getScene().markAllMaterialsAsDirty(e.Material.TextureDirtyFlag,(function(e){return e.hasTexture(t)})),this._cachedTextureMatrix)},r.prototype.getReflectionTextureMatrix=function(){var t=this,i=this.getScene();if(this.uOffset===this._cachedUOffset&&this.vOffset===this._cachedVOffset&&this.uScale===this._cachedUScale&&this.vScale===this._cachedVScale&&this.coordinatesMode===this._cachedCoordinatesMode){if(this.coordinatesMode!==r.PROJECTION_MODE)return this._cachedTextureMatrix;if(this._cachedProjectionMatrixId===i.getProjectionMatrix().updateFlag)return this._cachedTextureMatrix}switch(this._cachedTextureMatrix||(this._cachedTextureMatrix=e.Matrix.Zero(),this._projectionModeMatrix=e.Matrix.Zero()),this._cachedUOffset=this.uOffset,this._cachedVOffset=this.vOffset,this._cachedUScale=this.uScale,this._cachedVScale=this.vScale,this._cachedCoordinatesMode=this.coordinatesMode,this.coordinatesMode){case r.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 r.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;var n=i.getProjectionMatrix();this._cachedProjectionMatrixId=n.updateFlag,n.multiplyToRef(this._projectionModeMatrix,this._cachedTextureMatrix);break;default:e.Matrix.IdentityToRef(this._cachedTextureMatrix)}return i.markAllMaterialsAsDirty(e.Material.TextureDirtyFlag,(function(e){return-1!==e.getActiveTextures().indexOf(t)})),this._cachedTextureMatrix},r.prototype.clone=function(){var t=this;return e.SerializationHelper.Clone((function(){return new r(t._texture.url,t.getScene(),t._noMipmap,t._invertY,t._samplingMode)}),this)},Object.defineProperty(r.prototype,"onLoadObservable",{get:function(){return this._onLoadObservable||(this._onLoadObservable=new e.Observable),this._onLoadObservable},enumerable:!0,configurable:!0}),r.prototype.serialize=function(){var e=t.prototype.serialize.call(this);return"string"==typeof this._buffer&&"data:"===this._buffer.substr(0,5)&&(e.base64String=this._buffer,e.name=e.name.replace("data:","")),e},r.prototype.getClassName=function(){return"Texture"},r.prototype.dispose=function(){t.prototype.dispose.call(this),this.onLoadObservable&&(this.onLoadObservable.clear(),this._onLoadObservable=null),this._delayedOnLoad=null,this._delayedOnError=null},r.CreateFromBase64String=function(t,i,n,o,s,a,u,l,h){return void 0===a&&(a=r.TRILINEAR_SAMPLINGMODE),void 0===u&&(u=null),void 0===l&&(l=null),void 0===h&&(h=e.Engine.TEXTUREFORMAT_RGBA),new r("data:"+i,n,o,s,a,u,l,t,!1,h)},r.Parse=function(t,i,n){if(t.customType){var o=e.Tools.Instantiate(t.customType),s=o.Parse(t,i,n);return t.samplingMode&&s.updateSamplingMode&&s._samplingMode&&s._samplingMode!==t.samplingMode&&s.updateSamplingMode(t.samplingMode),s}if(t.isCube)return e.CubeTexture.Parse(t,i,n);if(!t.name&&!t.isRenderTarget)return null;var a=e.SerializationHelper.Parse((function(){if(t.mirrorPlane){var o=new e.MirrorTexture(t.name,t.renderTargetSize,i);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,i);return s._waitingRenderList=t.renderList,s}return t.base64String?r.CreateFromBase64String(t.base64String,t.name,i):new r(n+t.name,i)}),t,i);if(t.samplingMode){var u=t.samplingMode;a._samplingMode!==u&&a.updateSamplingMode(u)}if(t.animations)for(var l=0;l<t.animations.length;l++){var h=t.animations[l];a.animations.push(e.Animation.Parse(h))}return a},r.LoadFromDataString=function(t,i,n,o,s,a,u,l,h,c){return void 0===o&&(o=!1),void 0===s&&(s=!1),void 0===a&&(a=!0),void 0===u&&(u=r.TRILINEAR_SAMPLINGMODE),void 0===l&&(l=null),void 0===h&&(h=null),void 0===c&&(c=e.Engine.TEXTUREFORMAT_RGBA),"data:"!==t.substr(0,5)&&(t="data:"+t),new r(t,n,s,a,u,l,h,i,o,c)},r.NEAREST_SAMPLINGMODE=1,r.NEAREST_NEAREST_MIPLINEAR=1,r.BILINEAR_SAMPLINGMODE=2,r.LINEAR_LINEAR_MIPNEAREST=2,r.TRILINEAR_SAMPLINGMODE=3,r.LINEAR_LINEAR_MIPLINEAR=3,r.NEAREST_NEAREST_MIPNEAREST=4,r.NEAREST_LINEAR_MIPNEAREST=5,r.NEAREST_LINEAR_MIPLINEAR=6,r.NEAREST_LINEAR=7,r.NEAREST_NEAREST=8,r.LINEAR_NEAREST_MIPNEAREST=9,r.LINEAR_NEAREST_MIPLINEAR=10,r.LINEAR_LINEAR=11,r.LINEAR_NEAREST=12,r.EXPLICIT_MODE=0,r.SPHERICAL_MODE=1,r.PLANAR_MODE=2,r.CUBIC_MODE=3,r.PROJECTION_MODE=4,r.SKYBOX_MODE=5,r.INVCUBIC_MODE=6,r.EQUIRECTANGULAR_MODE=7,r.FIXED_EQUIRECTANGULAR_MODE=8,r.FIXED_EQUIRECTANGULAR_MIRRORED_MODE=9,r.CLAMP_ADDRESSMODE=0,r.WRAP_ADDRESSMODE=1,r.MIRROR_ADDRESSMODE=2,__decorate([e.serialize()],r.prototype,"url",void 0),__decorate([e.serialize()],r.prototype,"uOffset",void 0),__decorate([e.serialize()],r.prototype,"vOffset",void 0),__decorate([e.serialize()],r.prototype,"uScale",void 0),__decorate([e.serialize()],r.prototype,"vScale",void 0),__decorate([e.serialize()],r.prototype,"uAng",void 0),__decorate([e.serialize()],r.prototype,"vAng",void 0),__decorate([e.serialize()],r.prototype,"wAng",void 0),__decorate([e.serialize()],r.prototype,"isBlocking",null),r})(e.BaseTexture);e.Texture=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(){this.mustReturn=!1,this.visibleInstances=new Array,this.renderSelf=new Array}return e})();e._InstancesBatch=t;var r=(function(r){function i(n,o,s,a,u,l){void 0===s&&(s=null),void 0===l&&(l=!0);var h=r.call(this,n,o)||this;if(h.onBeforeRenderObservable=new e.Observable,h.onAfterRenderObservable=new e.Observable,h.onBeforeDrawObservable=new e.Observable,h.delayLoadState=e.Engine.DELAYLOADSTATE_NONE,h.instances=new Array,h._LODLevels=new Array,h._visibleInstances={},h._renderIdForInstances=new Array,h._batchCache=new t,h._instancesBufferSize=2048,h._sideOrientation=i._DEFAULTSIDE,h._areNormalsFrozen=!1,h._source=null,a){h._source=a,a._geometry&&a._geometry.applyToMesh(h),e.Tools.DeepCopy(a,h,["name","material","skeleton","instances","parent","uniqueId"],["_poseMatrix"]),h.parent=a.parent,h.setPivotMatrix(a.getPivotMatrix()),h.id=n+"."+a.id,h.material=a.material;var c;if(!u)for(c=0;c<o.meshes.length;c++){var f=o.meshes[c];if(f.parent===a){f.clone(n+"."+f.name,h,u)}}var d=h.getScene().getPhysicsEngine();if(l&&d){var p=d.getImpostorForPhysicsObject(a);p&&(h.physicsImpostor=p.clone(h))}for(c=0;c<o.particleSystems.length;c++){var g=o.particleSystems[c];g.emitter===a&&g.clone(g.name,h)}h.computeWorldMatrix(!0)}return null!==s&&(h.parent=s),h}return __extends(i,r),Object.defineProperty(i,"FRONTSIDE",{get:function(){return i._FRONTSIDE},enumerable:!0,configurable:!0}),Object.defineProperty(i,"BACKSIDE",{get:function(){return i._BACKSIDE},enumerable:!0,configurable:!0}),Object.defineProperty(i,"DOUBLESIDE",{get:function(){return i._DOUBLESIDE},enumerable:!0,configurable:!0}),Object.defineProperty(i,"DEFAULTSIDE",{get:function(){return i._DEFAULTSIDE},enumerable:!0,configurable:!0}),Object.defineProperty(i,"NO_CAP",{get:function(){return i._NO_CAP},enumerable:!0,configurable:!0}),Object.defineProperty(i,"CAP_START",{get:function(){return i._CAP_START},enumerable:!0,configurable:!0}),Object.defineProperty(i,"CAP_END",{get:function(){return i._CAP_END},enumerable:!0,configurable:!0}),Object.defineProperty(i,"CAP_ALL",{get:function(){return i._CAP_ALL},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"onBeforeDraw",{set:function(e){this._onBeforeDrawObserver&&this.onBeforeDrawObservable.remove(this._onBeforeDrawObserver),this._onBeforeDrawObserver=this.onBeforeDrawObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"morphTargetManager",{get:function(){return this._morphTargetManager},set:function(e){this._morphTargetManager!==e&&(this._morphTargetManager=e,this._syncGeometryWithMorphTargetManager())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"source",{get:function(){return this._source},enumerable:!0,configurable:!0}),i.prototype.getClassName=function(){return"Mesh"},i.prototype.toString=function(t){var i=r.prototype.toString.call(this,t);if(i+=", n vertices: "+this.getTotalVertices(),i+=", parent: "+(this._waitingParentId?this._waitingParentId:this.parent?this.parent.name:"NONE"),this.animations)for(var n=0;n<this.animations.length;n++)i+=", animation[0]: "+this.animations[n].toString(t);return t&&(i+=", flat shading: "+(this._geometry?this.getVerticesData(e.VertexBuffer.PositionKind).length/3===this.getIndices().length?"YES":"NO":"UNKNOWN")),i},Object.defineProperty(i.prototype,"hasLODLevels",{get:function(){return this._LODLevels.length>0},enumerable:!0,configurable:!0}),i.prototype._sortLODLevels=function(){this._LODLevels.sort((function(e,t){return e.distance<t.distance?1:e.distance>t.distance?-1:0}))},i.prototype.addLODLevel=function(t,r){if(r&&r._masterMesh)return e.Tools.Warn("You cannot use a mesh as LOD level twice"),this;var i=new e.Internals.MeshLODLevel(t,r);return this._LODLevels.push(i),r&&(r._masterMesh=this),this._sortLODLevels(),this},i.prototype.getLODLevelAtDistance=function(e){for(var t=0;t<this._LODLevels.length;t++){var r=this._LODLevels[t];if(r.distance===e)return r.mesh}return null},i.prototype.removeLODLevel=function(e){for(var t=0;t<this._LODLevels.length;t++)this._LODLevels[t].mesh===e&&(this._LODLevels.splice(t,1),e&&(e._masterMesh=null));return this._sortLODLevels(),this},i.prototype.getLOD=function(e,t){if(!this._LODLevels||0===this._LODLevels.length)return this;var r=(t||this.getBoundingInfo().boundingSphere).centerWorld.subtract(e.globalPosition).length();if(this._LODLevels[this._LODLevels.length-1].distance>r)return this.onLODLevelSelection&&this.onLODLevelSelection(r,this,this._LODLevels[this._LODLevels.length-1].mesh),this;for(var i=0;i<this._LODLevels.length;i++){var n=this._LODLevels[i];if(n.distance<r)return n.mesh&&(n.mesh._preActivate(),n.mesh._updateSubMeshesBoundingInfo(this.worldMatrixFromCache)),this.onLODLevelSelection&&this.onLODLevelSelection(r,this,n.mesh),n.mesh}return this.onLODLevelSelection&&this.onLODLevelSelection(r,this,this),this},Object.defineProperty(i.prototype,"geometry",{get:function(){return this._geometry},enumerable:!0,configurable:!0}),i.prototype.getTotalVertices=function(){return this._geometry?this._geometry.getTotalVertices():0},i.prototype.getVerticesData=function(e,t,r){return this._geometry?this._geometry.getVerticesData(e,t,r):null},i.prototype.getVertexBuffer=function(e){if(this._geometry)return this._geometry.getVertexBuffer(e)},i.prototype.isVerticesDataPresent=function(e){return this._geometry?this._geometry.isVerticesDataPresent(e):!!this._delayInfo&&-1!==this._delayInfo.indexOf(e)},i.prototype.getVerticesDataKinds=function(){if(!this._geometry){var e=[];return this._delayInfo&&this._delayInfo.forEach((function(t,r,i){e.push(t)})),e}return this._geometry.getVerticesDataKinds()},i.prototype.getTotalIndices=function(){return this._geometry?this._geometry.getTotalIndices():0},i.prototype.getIndices=function(e){return this._geometry?this._geometry.getIndices(e):[]},Object.defineProperty(i.prototype,"isBlocked",{get:function(){return null!==this._masterMesh&&void 0!==this._masterMesh},enumerable:!0,configurable:!0}),i.prototype.isReady=function(){return this.delayLoadState!==e.Engine.DELAYLOADSTATE_LOADING&&r.prototype.isReady.call(this)},Object.defineProperty(i.prototype,"sideOrientation",{get:function(){return this._sideOrientation},set:function(e){this._sideOrientation=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"areNormalsFrozen",{get:function(){return this._areNormalsFrozen},enumerable:!0,configurable:!0}),i.prototype.freezeNormals=function(){return this._areNormalsFrozen=!0,this},i.prototype.unfreezeNormals=function(){return this._areNormalsFrozen=!1,this},Object.defineProperty(i.prototype,"overridenInstanceCount",{set:function(e){this._overridenInstanceCount=e},enumerable:!0,configurable:!0}),i.prototype._preActivate=function(){var e=this.getScene().getRenderId();return this._preActivateId===e?this:(this._preActivateId=e,this._visibleInstances=null,this)},i.prototype._preActivateForIntermediateRendering=function(e){return this._visibleInstances&&(this._visibleInstances.intermediateDefaultRenderId=e),this},i.prototype._registerInstanceForRenderId=function(e,t){return this._visibleInstances||(this._visibleInstances={},this._visibleInstances.defaultRenderId=t,this._visibleInstances.selfDefaultRenderId=this._renderId),this._visibleInstances[t]||(this._visibleInstances[t]=new Array),this._visibleInstances[t].push(e),this},i.prototype.refreshBoundingInfo=function(){if(!this._boundingInfo.isLocked){var t=this.getVerticesData(e.VertexBuffer.PositionKind);if(t){var r=e.Tools.ExtractMinAndMax(t,0,this.getTotalVertices());this._boundingInfo=new e.BoundingInfo(r.minimum,r.maximum)}if(this.subMeshes)for(var i=0;i<this.subMeshes.length;i++)this.subMeshes[i].refreshBoundingInfo();return this._updateBoundingInfo(),this}},i.prototype._createGlobalSubMesh=function(t){var r=this.getTotalVertices();if(!r||!this.getIndices())return null;if(this.subMeshes&&this.subMeshes.length>0){var i=this.getIndices().length,n=!1;if(t)n=!0;else for(var o=0,s=this.subMeshes;o<s.length;o++){var a=s[o];if(a.indexStart+a.indexCount>=i){n=!0;break}if(a.verticesStart+a.verticesCount>=r){n=!0;break}}if(!n)return}return this.releaseSubMeshes(),new e.SubMesh(0,0,r,0,this.getTotalIndices(),this)},i.prototype.subdivide=function(t){if(!(t<1)){for(var r=this.getTotalIndices(),i=r/t|0,n=0;i%3!=0;)i++;this.releaseSubMeshes();for(var o=0;o<t&&!(n>=r);o++)e.SubMesh.CreateFromIndices(0,n,Math.min(i,r-n),this),n+=i;this.synchronizeInstances()}},i.prototype.setVerticesData=function(t,r,i,n){if(this._geometry)this._geometry.setVerticesData(t,r,i,n);else{var o=new e.VertexData;o.set(r,t);var s=this.getScene();new e.Geometry(e.Geometry.RandomId(),s,o,i,this)}return this},i.prototype.markVerticesDataAsUpdatable=function(e,t){void 0===t&&(t=!0),this.getVertexBuffer(e).isUpdatable()!==t&&this.setVerticesData(e,this.getVerticesData(e),t)},i.prototype.setVerticesBuffer=function(t){if(!this._geometry){var r=this.getScene();new e.Geometry(e.Geometry.RandomId(),r).applyToMesh(this)}return this._geometry.setVerticesBuffer(t),this},i.prototype.updateVerticesData=function(e,t,r,i){if(this._geometry)return i?(this.makeGeometryUnique(),this.updateVerticesData(e,t,r,!1)):this._geometry.updateVerticesData(e,t,r),this},i.prototype.updateMeshPositions=function(t,r){void 0===r&&(r=!0);var i=this.getVerticesData(e.VertexBuffer.PositionKind);if(t(i),this.updateVerticesData(e.VertexBuffer.PositionKind,i,!1,!1),r){var n=this.getIndices(),o=this.getVerticesData(e.VertexBuffer.NormalKind);e.VertexData.ComputeNormals(i,n,o),this.updateVerticesData(e.VertexBuffer.NormalKind,o,!1,!1)}return this},i.prototype.makeGeometryUnique=function(){if(this._geometry){var t=this._geometry,r=this._geometry.copy(e.Geometry.RandomId());return t.releaseForMesh(this,!0),r.applyToMesh(this),this}},i.prototype.setIndices=function(t,r){if(this._geometry)this._geometry.setIndices(t,r);else{var i=new e.VertexData;i.indices=t;var n=this.getScene();new e.Geometry(e.Geometry.RandomId(),n,i,!1,this)}return this},i.prototype.toLeftHanded=function(){if(this._geometry)return this._geometry.toLeftHanded(),this},i.prototype._bind=function(t,r,i){var n,o=this.getScene().getEngine();if(this._unIndexed)n=null;else switch(i){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()}return this._geometry._bind(r,n),this},i.prototype._draw=function(t,r,i){if(!this._geometry||!this._geometry.getVertexBuffers()||!this._geometry.getIndexBuffer())return this;this.onBeforeDrawObservable.notifyObservers(this);var n=this.getScene().getEngine();switch(r){case e.Material.PointFillMode:n.drawPointClouds(t.verticesStart,t.verticesCount,i);break;case e.Material.WireFrameFillMode:this._unIndexed?n.drawUnIndexed(!1,t.verticesStart,t.verticesCount,i):n.draw(!1,0,i>0?t.linesIndexCount/2:t.linesIndexCount,i);break;default:this._unIndexed?n.drawUnIndexed(!0,t.verticesStart,t.verticesCount,i):n.draw(!0,t.indexStart,t.indexCount,i)}return this},i.prototype.registerBeforeRender=function(e){return this.onBeforeRenderObservable.add(e),this},i.prototype.unregisterBeforeRender=function(e){return this.onBeforeRenderObservable.removeCallback(e),this},i.prototype.registerAfterRender=function(e){return this.onAfterRenderObservable.add(e),this},i.prototype.unregisterAfterRender=function(e){return this.onAfterRenderObservable.removeCallback(e),this},i.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 r=t.getRenderId(),i=t._isInIntermediateRendering()?this._visibleInstances.intermediateDefaultRenderId:this._visibleInstances.defaultRenderId;this._batchCache.visibleInstances[e]=this._visibleInstances[r];var n=this._renderId;if(!this._batchCache.visibleInstances[e]&&i&&(this._batchCache.visibleInstances[e]=this._visibleInstances[i],r=Math.max(i,r),n=Math.max(this._visibleInstances.selfDefaultRenderId,r)),this._batchCache.visibleInstances[e]&&this._batchCache.visibleInstances[e].length){if(this._renderIdForInstances[e]===r)return this._batchCache.mustReturn=!0,this._batchCache;r!==n&&(this._batchCache.renderSelf[e]=!1)}this._renderIdForInstances[e]=r}return this._batchCache},i.prototype._renderWithInstances=function(t,r,i,n,o){for(var s=i.visibleInstances[t._id],a=s.length+1,u=16*a*4,l=this._instancesBufferSize,h=this._instancesBuffer;this._instancesBufferSize<u;)this._instancesBufferSize*=2;this._instancesData&&l==this._instancesBufferSize||(this._instancesData=new Float32Array(this._instancesBufferSize/4));var c=0,f=0,d=this.getWorldMatrix();if(i.renderSelf[t._id]&&(d.copyToArray(this._instancesData,c),c+=16,f++),s)for(var p=0;p<s.length;p++){var g=s[p];g.getWorldMatrix().copyToArray(this._instancesData,c),c+=16,f++}return h&&l==this._instancesBufferSize?h.updateDirectly(this._instancesData,0,f):(h&&h.dispose(),h=new e.Buffer(o,this._instancesData,!0,16,!1,!0),this._instancesBuffer=h,this.setVerticesBuffer(h.createVertexBuffer("world0",0,4)),this.setVerticesBuffer(h.createVertexBuffer("world1",4,4)),this.setVerticesBuffer(h.createVertexBuffer("world2",8,4)),this.setVerticesBuffer(h.createVertexBuffer("world3",12,4))),this.geometry._bind(n),this._draw(t,r,f),o.unbindInstanceAttributes(),this},i.prototype._processRendering=function(e,t,r,i,n,o,s){var a=this.getScene(),u=a.getEngine();if(n)this._renderWithInstances(e,r,i,t,u);else if(i.renderSelf[e._id]&&(o&&o(!1,this.getWorldMatrix(),s),this._draw(e,r,this._overridenInstanceCount)),i.visibleInstances[e._id])for(var l=0;l<i.visibleInstances[e._id].length;l++){var h=i.visibleInstances[e._id][l],c=h.getWorldMatrix();o&&o(!0,c,s),this._draw(e,r)}return this},i.prototype.render=function(t,r){var i=this.getScene(),n=this._getInstancesRenderList(t._id);if(n.mustReturn)return this;if(!this._geometry||!this._geometry.getVertexBuffers()||!this._geometry.getIndexBuffer())return this;this.onBeforeRenderObservable.notifyObservers(this);var o=i.getEngine(),s=o.getCaps().instancedArrays&&null!==n.visibleInstances[t._id]&&void 0!==n.visibleInstances[t._id],a=t.getMaterial();if(!a)return this;if(a.storeEffectOnSubMeshes){if(!a.isReadyForSubMesh(this,t,s))return this}else if(!a.isReady(this,s))return this;r&&o.setAlphaMode(a.alphaMode);var u=o.getDepthWrite();this.renderOutline&&(o.setDepthWrite(!1),i.getOutlineRenderer().render(t,n),o.setDepthWrite(u));var l;l=a.storeEffectOnSubMeshes?t.effect:a.getEffect(),a._preBind(l);var h=i.forcePointsCloud?e.Material.PointFillMode:i.forceWireframe?e.Material.WireFrameFillMode:a.fillMode;this._bind(t,l,h);var c=this.getWorldMatrix();if(a.storeEffectOnSubMeshes?a.bindForSubMesh(c,this,t):a.bind(c,this),this._processRendering(t,l,h,n,s,this._onBeforeDraw,a),a.unbind(),this.renderOutline&&u&&(o.setDepthWrite(!0),o.setColorWrite(!1),i.getOutlineRenderer().render(t,n),o.setColorWrite(!0)),this.renderOverlay){var f=o.getAlphaMode();o.setAlphaMode(e.Engine.ALPHA_COMBINE),i.getOutlineRenderer().render(t,n,!0),o.setAlphaMode(f)}return this.onAfterRenderObservable.notifyObservers(this),this},i.prototype._onBeforeDraw=function(e,t,r){return e&&r.bindOnlyWorldMatrix(t),this},i.prototype.getEmittedParticleSystems=function(){for(var e=new Array,t=0;t<this.getScene().particleSystems.length;t++){var r=this.getScene().particleSystems[t];r.emitter===this&&e.push(r)}return e},i.prototype.getHierarchyEmittedParticleSystems=function(){var e=new Array,t=this.getDescendants();t.push(this);for(var r=0;r<this.getScene().particleSystems.length;r++){var i=this.getScene().particleSystems[r],n=i.emitter;n.position&&-1!==t.indexOf(n)&&e.push(i)}return e},i.prototype._checkDelayState=function(){var t=this.getScene();return this._geometry?this._geometry.load(t):this.delayLoadState===e.Engine.DELAYLOADSTATE_NOTLOADED&&(this.delayLoadState=e.Engine.DELAYLOADSTATE_LOADING,this._queueLoad(this,t)),this},i.prototype._queueLoad=function(t,r){var i=this;r._addPendingData(t);var n=-1!==this.delayLoadingFile.indexOf(".babylonbinarymeshdata");return e.Tools.LoadFile(this.delayLoadingFile,(function(t){t instanceof ArrayBuffer?i._delayLoadingFunction(t,i):i._delayLoadingFunction(JSON.parse(t),i),i.instances.forEach((function(e){e._syncSubMeshes()})),i.delayLoadState=e.Engine.DELAYLOADSTATE_LOADED,r._removePendingData(i)}),(function(){}),r.database,n),this},i.prototype.isInFrustum=function(t){return this.delayLoadState!==e.Engine.DELAYLOADSTATE_LOADING&&(!!r.prototype.isInFrustum.call(this,t)&&(this._checkDelayState(),!0))},i.prototype.setMaterialByID=function(e){var t,r=this.getScene().materials;for(t=r.length-1;t>-1;t--)if(r[t].id===e)return this.material=r[t],this;var i=this.getScene().multiMaterials;for(t=i.length-1;t>-1;t--)if(i[t].id===e)return this.material=i[t],this;return this},i.prototype.getAnimatables=function(){var e=[];return this.material&&e.push(this.material),this.skeleton&&e.push(this.skeleton),e},i.prototype.bakeTransformIntoVertices=function(t){if(!this.isVerticesDataPresent(e.VertexBuffer.PositionKind))return this;var r=this.subMeshes.splice(0);this._resetPointsArrayCache();var i,n=this.getVerticesData(e.VertexBuffer.PositionKind),o=[];for(i=0;i<n.length;i+=3)e.Vector3.TransformCoordinates(e.Vector3.FromArray(n,i),t).toArray(o,i);if(this.setVerticesData(e.VertexBuffer.PositionKind,o,this.getVertexBuffer(e.VertexBuffer.PositionKind).isUpdatable()),!this.isVerticesDataPresent(e.VertexBuffer.NormalKind))return this;for(n=this.getVerticesData(e.VertexBuffer.NormalKind),o=[],i=0;i<n.length;i+=3)e.Vector3.TransformNormal(e.Vector3.FromArray(n,i),t).normalize().toArray(o,i);return this.setVerticesData(e.VertexBuffer.NormalKind,o,this.getVertexBuffer(e.VertexBuffer.NormalKind).isUpdatable()),t.m[0]*t.m[5]*t.m[10]<0&&this.flipFaces(),this.releaseSubMeshes(),this.subMeshes=r,this},i.prototype.bakeCurrentTransformIntoVertices=function(){return this.bakeTransformIntoVertices(this.computeWorldMatrix(!0)),this.scaling.copyFromFloats(1,1,1),this.position.copyFromFloats(0,0,0),this.rotation.copyFromFloats(0,0,0),this.rotationQuaternion&&(this.rotationQuaternion=e.Quaternion.Identity()),this._worldMatrix=e.Matrix.Identity(),this},Object.defineProperty(i.prototype,"_positions",{get:function(){return this._geometry?this._geometry._positions:null},enumerable:!0,configurable:!0}),i.prototype._resetPointsArrayCache=function(){return this._geometry&&this._geometry._resetPointsArrayCache(),this},i.prototype._generatePointsArray=function(){return!!this._geometry&&this._geometry._generatePointsArray()},i.prototype.clone=function(e,t,r,n){return void 0===n&&(n=!0),new i(e,this.getScene(),t,this,r,n)},i.prototype.dispose=function(e){var t=this;this.morphTargetManager=void 0,this._geometry&&this._geometry.releaseForMesh(this,!0);var i=this.getScene().meshes;for(i.forEach((function(e){e._source&&e._source===t&&(e._source=null)})),this._source=null,this._instancesBuffer&&(this._instancesBuffer.dispose(),this._instancesBuffer=null);this.instances.length;)this.instances[0].dispose();for(var n=this.getScene().highlightLayers,o=0;o<n.length;o++){var s=n[o];s&&(s.removeMesh(this),s.removeExcludedMesh(this))}r.prototype.dispose.call(this,e)},i.prototype.applyDisplacementMap=function(t,r,i,n,o,s){var a=this,u=this.getScene(),l=function(e){var t=document.createElement("canvas"),u=t.getContext("2d"),l=e.width,h=e.height;t.width=l,t.height=h,u.drawImage(e,0,0);var c=u.getImageData(0,0,l,h).data;a.applyDisplacementMapFromBuffer(c,l,h,r,i,o,s),n&&n(a)};return e.Tools.LoadImage(t,l,(function(){}),u.database),this},i.prototype.applyDisplacementMapFromBuffer=function(t,r,i,n,o,s,a){if(!this.isVerticesDataPresent(e.VertexBuffer.PositionKind)||!this.isVerticesDataPresent(e.VertexBuffer.NormalKind)||!this.isVerticesDataPresent(e.VertexBuffer.UVKind))return e.Tools.Warn("Cannot call applyDisplacementMap: Given mesh is not complete. Position, Normal or UV are missing"),this;var u=this.getVerticesData(e.VertexBuffer.PositionKind),l=this.getVerticesData(e.VertexBuffer.NormalKind),h=this.getVerticesData(e.VertexBuffer.UVKind),c=e.Vector3.Zero(),f=e.Vector3.Zero(),d=e.Vector2.Zero();s=s||e.Vector2.Zero(),a=a||new e.Vector2(1,1);for(var p=0;p<u.length;p+=3){e.Vector3.FromArrayToRef(u,p,c),e.Vector3.FromArrayToRef(l,p,f),e.Vector2.FromArrayToRef(h,p/3*2,d);var g=Math.abs(d.x*a.x+s.x)*r%r|0,_=Math.abs(d.y*a.y+s.y)*i%i|0,m=4*(g+_*r),v=t[m]/255,y=t[m+1]/255,A=t[m+2]/255,T=.3*v+.59*y+.11*A;f.normalize(),f.scaleInPlace(n+(o-n)*T),c=c.add(f),c.toArray(u,p)}return e.VertexData.ComputeNormals(u,this.getIndices(),l),this.updateVerticesData(e.VertexBuffer.PositionKind,u),this.updateVerticesData(e.VertexBuffer.NormalKind,l),this},i.prototype.convertToFlatShadedMesh=function(){var t,r,i=this.getVerticesDataKinds(),n=[],o=[],s=[],a=!1;for(t=0;t<i.length;t++){r=i[t];var u=this.getVertexBuffer(r);r!==e.VertexBuffer.NormalKind?(n[r]=u,o[r]=n[r].getData(),s[r]=[]):(a=u.isUpdatable(),i.splice(t,1),t--)}var l,h=this.subMeshes.slice(0),c=this.getIndices(),f=this.getTotalIndices();for(l=0;l<f;l++){var d=c[l];for(t=0;t<i.length;t++){r=i[t];for(var p=n[r].getStrideSize(),g=0;g<p;g++)s[r].push(o[r][d*p+g])}}var _=[],m=s[e.VertexBuffer.PositionKind];for(l=0;l<f;l+=3){c[l]=l,c[l+1]=l+1,c[l+2]=l+2;for(var v=e.Vector3.FromArray(m,3*l),y=e.Vector3.FromArray(m,3*(l+1)),A=e.Vector3.FromArray(m,3*(l+2)),T=v.subtract(y),E=A.subtract(y),b=e.Vector3.Normalize(e.Vector3.Cross(T,E)),x=0;x<3;x++)_.push(b.x),_.push(b.y),_.push(b.z)}for(this.setIndices(c),this.setVerticesData(e.VertexBuffer.NormalKind,_,a),t=0;t<i.length;t++)r=i[t],this.setVerticesData(r,s[r],n[r].isUpdatable());this.releaseSubMeshes();for(var M=0;M<h.length;M++){var P=h[M];new e.SubMesh(P.materialIndex,P.indexStart,P.indexCount,P.indexStart,P.indexCount,this)}return this.synchronizeInstances(),this},i.prototype.convertToUnIndexedMesh=function(){var t,r,i=this.getVerticesDataKinds(),n=[],o=[],s=[];for(t=0;t<i.length;t++){r=i[t];var a=this.getVertexBuffer(r);n[r]=a,o[r]=n[r].getData(),s[r]=[]}var u,l=this.subMeshes.slice(0),h=this.getIndices(),c=this.getTotalIndices();for(u=0;u<c;u++){var f=h[u];for(t=0;t<i.length;t++){r=i[t];for(var d=n[r].getStrideSize(),p=0;p<d;p++)s[r].push(o[r][f*d+p])}}for(u=0;u<c;u+=3)h[u]=u,h[u+1]=u+1,h[u+2]=u+2;for(this.setIndices(h),t=0;t<i.length;t++)r=i[t],this.setVerticesData(r,s[r],n[r].isUpdatable());this.releaseSubMeshes();for(var g=0;g<l.length;g++){var _=l[g];new e.SubMesh(_.materialIndex,_.indexStart,_.indexCount,_.indexStart,_.indexCount,this)}
- return this._unIndexed=!0,this.synchronizeInstances(),this},i.prototype.flipFaces=function(t){void 0===t&&(t=!1);var r,i=e.VertexData.ExtractFromMesh(this);if(t&&this.isVerticesDataPresent(e.VertexBuffer.NormalKind))for(r=0;r<i.normals.length;r++)i.normals[r]*=-1;var n;for(r=0;r<i.indices.length;r+=3)n=i.indices[r+1],i.indices[r+1]=i.indices[r+2],i.indices[r+2]=n;return i.applyToMesh(this),this},i.prototype.createInstance=function(t){return new e.InstancedMesh(t,this)},i.prototype.synchronizeInstances=function(){for(var e=0;e<this.instances.length;e++){this.instances[e]._syncSubMeshes()}return this},i.prototype.simplify=function(t,r,i,n){return void 0===r&&(r=!0),void 0===i&&(i=e.SimplificationType.QUADRATIC),this.getScene().simplificationQueue.addTask({settings:t,parallelProcessing:r,mesh:this,simplificationType:i,successCallback:n}),this},i.prototype.optimizeIndices=function(t){for(var r=this,i=this.getIndices(),n=this.getVerticesData(e.VertexBuffer.PositionKind),o=[],s=0;s<n.length;s+=3)o.push(e.Vector3.FromArray(n,s));var a=[];return e.AsyncLoop.SyncAsyncForLoop(o.length,40,(function(e){for(var t=o.length-1-e,r=o[t],i=0;i<t;++i){var n=o[i];if(r.equals(n)){a[t]=i;break}}}),(function(){for(var e=0;e<i.length;++e)i[e]=a[i[e]]||i[e];var n=r.subMeshes.slice(0);r.setIndices(i),r.subMeshes=n,t&&t(r)})),this},i.prototype.serialize=function(t){t.name=this.name,t.id=this.id,t.type=this.getClassName(),e.Tags&&e.Tags.HasTags(this)&&(t.tags=e.Tags.GetTags(this)),t.position=this.position.asArray(),this.rotationQuaternion?t.rotationQuaternion=this.rotationQuaternion.asArray():this.rotation&&(t.rotation=this.rotation.asArray()),t.scaling=this.scaling.asArray(),t.localMatrix=this.getPivotMatrix().asArray(),t.isEnabled=this.isEnabled(),t.isVisible=this.isVisible,t.infiniteDistance=this.infiniteDistance,t.pickable=this.isPickable,t.receiveShadows=this.receiveShadows,t.billboardMode=this.billboardMode,t.visibility=this.visibility,t.checkCollisions=this.checkCollisions,t.isBlocker=this.isBlocker,this.parent&&(t.parentId=this.parent.id);var r=this._geometry;if(r){var i=r.id;t.geometryId=i,t.subMeshes=[];for(var n=0;n<this.subMeshes.length;n++){var o=this.subMeshes[n];t.subMeshes.push({materialIndex:o.materialIndex,verticesStart:o.verticesStart,verticesCount:o.verticesCount,indexStart:o.indexStart,indexCount:o.indexCount})}}if(this.material?t.materialId=this.material.id:this.material=null,this.morphTargetManager&&(t.morphTargetManagerId=this.morphTargetManager.uniqueId),this.skeleton&&(t.skeletonId=this.skeleton.id),this.getPhysicsImpostor()){var s=this.getPhysicsImpostor();t.physicsMass=s.getParam("mass"),t.physicsFriction=s.getParam("friction"),t.physicsRestitution=s.getParam("mass"),t.physicsImpostor=this.getPhysicsImpostor().type}this.metadata&&(t.metadata=this.metadata),t.instances=[];for(var a=0;a<this.instances.length;a++){var u=this.instances[a],l={name:u.name,position:u.position.asArray(),scaling:u.scaling.asArray()};u.rotationQuaternion?l.rotationQuaternion=u.rotationQuaternion.asArray():u.rotation&&(l.rotation=u.rotation.asArray()),t.instances.push(l),e.Animation.AppendSerializedAnimations(u,l),l.ranges=u.serializeAnimationRanges()}e.Animation.AppendSerializedAnimations(this,t),t.ranges=this.serializeAnimationRanges(),t.layerMask=this.layerMask,t.alphaIndex=this.alphaIndex,t.hasVertexAlpha=this.hasVertexAlpha,t.overlayAlpha=this.overlayAlpha,t.overlayColor=this.overlayColor.asArray(),t.renderOverlay=this.renderOverlay,t.applyFog=this.applyFog,this.actionManager&&(t.actions=this.actionManager.serialize(this.name))},i.prototype._syncGeometryWithMorphTargetManager=function(){if(this.geometry)if(this._markSubMeshesAsAttributesDirty(),this._morphTargetManager&&this._morphTargetManager.vertexCount){if(this._morphTargetManager.vertexCount!==this.getTotalVertices())return e.Tools.Error("Mesh is incompatible with morph targets. Targets and mesh must all have the same vertices count."),void(this.morphTargetManager=void 0);for(var t=0;t<this.morphTargetManager.numInfluencers;t++){var r=this.morphTargetManager.getActiveTarget(t);this.geometry.setVerticesData(e.VertexBuffer.PositionKind+t,r.getPositions(),!1,3),r.hasNormals&&this.geometry.setVerticesData(e.VertexBuffer.NormalKind+t,r.getNormals(),!1,3),r.hasTangents&&this.geometry.setVerticesData(e.VertexBuffer.TangentKind+t,r.getTangents(),!1,3)}}else for(var t=0;this.geometry.isVerticesDataPresent(e.VertexBuffer.PositionKind+t);)this.geometry.removeVerticesData(e.VertexBuffer.PositionKind+t),this.geometry.isVerticesDataPresent(e.VertexBuffer.NormalKind+t)&&this.geometry.removeVerticesData(e.VertexBuffer.NormalKind+t),this.geometry.isVerticesDataPresent(e.VertexBuffer.TangentKind+t)&&this.geometry.removeVerticesData(e.VertexBuffer.TangentKind+t),t++},i.Parse=function(t,r,n){var o;if(o=t.type&&"GroundMesh"===t.type?e.GroundMesh.Parse(t,r):new i(t.name,r),o.id=t.id,e.Tags&&e.Tags.AddTagsTo(o,t.tags),o.position=e.Vector3.FromArray(t.position),void 0!==t.metadata&&(o.metadata=t.metadata),t.rotationQuaternion?o.rotationQuaternion=e.Quaternion.FromArray(t.rotationQuaternion):t.rotation&&(o.rotation=e.Vector3.FromArray(t.rotation)),o.scaling=e.Vector3.FromArray(t.scaling),t.localMatrix?o.setPivotMatrix(e.Matrix.FromArray(t.localMatrix)):t.pivotMatrix&&o.setPivotMatrix(e.Matrix.FromArray(t.pivotMatrix)),o.setEnabled(t.isEnabled),o.isVisible=t.isVisible,o.infiniteDistance=t.infiniteDistance,o.showBoundingBox=t.showBoundingBox,o.showSubMeshesBoundingBox=t.showSubMeshesBoundingBox,void 0!==t.applyFog&&(o.applyFog=t.applyFog),void 0!==t.pickable&&(o.isPickable=t.pickable),void 0!==t.alphaIndex&&(o.alphaIndex=t.alphaIndex),o.receiveShadows=t.receiveShadows,o.billboardMode=t.billboardMode,void 0!==t.visibility&&(o.visibility=t.visibility),o.checkCollisions=t.checkCollisions,void 0!==t.isBlocker&&(o.isBlocker=t.isBlocker),o._shouldGenerateFlatShading=t.useFlatShading,t.freezeWorldMatrix&&(o._waitingFreezeWorldMatrix=t.freezeWorldMatrix),t.parentId&&(o._waitingParentId=t.parentId),void 0!==t.actions&&(o._waitingActions=t.actions),void 0!==t.overlayAlpha&&(o.overlayAlpha=t.overlayAlpha),void 0!==t.overlayColor&&(o.overlayColor=e.Color3.FromArray(t.overlayColor)),void 0!==t.renderOverlay&&(o.renderOverlay=t.renderOverlay),o.hasVertexAlpha=t.hasVertexAlpha,t.delayLoadingFile?(o.delayLoadState=e.Engine.DELAYLOADSTATE_NOTLOADED,o.delayLoadingFile=n+t.delayLoadingFile,o._boundingInfo=new e.BoundingInfo(e.Vector3.FromArray(t.boundingBoxMinimum),e.Vector3.FromArray(t.boundingBoxMaximum)),t._binaryInfo&&(o._binaryInfo=t._binaryInfo),o._delayInfo=[],t.hasUVs&&o._delayInfo.push(e.VertexBuffer.UVKind),t.hasUVs2&&o._delayInfo.push(e.VertexBuffer.UV2Kind),t.hasUVs3&&o._delayInfo.push(e.VertexBuffer.UV3Kind),t.hasUVs4&&o._delayInfo.push(e.VertexBuffer.UV4Kind),t.hasUVs5&&o._delayInfo.push(e.VertexBuffer.UV5Kind),t.hasUVs6&&o._delayInfo.push(e.VertexBuffer.UV6Kind),t.hasColors&&o._delayInfo.push(e.VertexBuffer.ColorKind),t.hasMatricesIndices&&o._delayInfo.push(e.VertexBuffer.MatricesIndicesKind),t.hasMatricesWeights&&o._delayInfo.push(e.VertexBuffer.MatricesWeightsKind),o._delayLoadingFunction=e.Geometry.ImportGeometry,e.SceneLoader.ForceFullSceneLoadingForIncremental&&o._checkDelayState()):e.Geometry.ImportGeometry(t,o),t.materialId?o.setMaterialByID(t.materialId):o.material=null,t.morphTargetManagerId>-1&&(o.morphTargetManager=r.getMorphTargetManagerById(t.morphTargetManagerId)),t.skeletonId>-1&&(o.skeleton=r.getLastSkeletonByID(t.skeletonId),t.numBoneInfluencers&&(o.numBoneInfluencers=t.numBoneInfluencers)),t.animations){for(var s=0;s<t.animations.length;s++){var a=t.animations[s];o.animations.push(e.Animation.Parse(a))}e.Node.ParseAnimationRanges(o,t,r)}if(t.autoAnimate&&r.beginAnimation(o,t.autoAnimateFrom,t.autoAnimateTo,t.autoAnimateLoop,t.autoAnimateSpeed||1),t.layerMask&&!isNaN(t.layerMask)?o.layerMask=Math.abs(parseInt(t.layerMask)):o.layerMask=268435455,t.physicsImpostor&&(o.physicsImpostor=new e.PhysicsImpostor(o,t.physicsImpostor,{mass:t.physicsMass,friction:t.physicsFriction,restitution:t.physicsRestitution},r)),t.instances)for(var u=0;u<t.instances.length;u++){var l=t.instances[u],h=o.createInstance(l.name);if(e.Tags&&e.Tags.AddTagsTo(h,l.tags),h.position=e.Vector3.FromArray(l.position),l.parentId&&(h._waitingParentId=l.parentId),l.rotationQuaternion?h.rotationQuaternion=e.Quaternion.FromArray(l.rotationQuaternion):l.rotation&&(h.rotation=e.Vector3.FromArray(l.rotation)),h.scaling=e.Vector3.FromArray(l.scaling),h.checkCollisions=o.checkCollisions,t.animations){for(s=0;s<t.animations.length;s++)a=t.animations[s],h.animations.push(e.Animation.Parse(a));e.Node.ParseAnimationRanges(h,t,r)}}return o},i.CreateRibbon=function(t,r,i,n,o,s,a,u,l){return e.MeshBuilder.CreateRibbon(t,{pathArray:r,closeArray:i,closePath:n,offset:o,updatable:a,sideOrientation:u,instance:l},s)},i.CreateDisc=function(t,r,i,n,o,s){var a={radius:r,tessellation:i,sideOrientation:s,updatable:o};return e.MeshBuilder.CreateDisc(t,a,n)},i.CreateBox=function(t,r,i,n,o){var s={size:r,sideOrientation:o,updatable:n};return e.MeshBuilder.CreateBox(t,s,i)},i.CreateSphere=function(t,r,i,n,o,s){var a={segments:r,diameterX:i,diameterY:i,diameterZ:i,sideOrientation:s,updatable:o};return e.MeshBuilder.CreateSphere(t,a,n)},i.CreateCylinder=function(t,r,n,o,s,a,u,l,h){void 0!==u&&u instanceof e.Scene||(void 0!==u&&(h=l||i.DEFAULTSIDE,l=u),u=a,a=1);var c={height:r,diameterTop:n,diameterBottom:o,tessellation:s,subdivisions:a,sideOrientation:h,updatable:l};return e.MeshBuilder.CreateCylinder(t,c,u)},i.CreateTorus=function(t,r,i,n,o,s,a){var u={diameter:r,thickness:i,tessellation:n,sideOrientation:a,updatable:s};return e.MeshBuilder.CreateTorus(t,u,o)},i.CreateTorusKnot=function(t,r,i,n,o,s,a,u,l,h){var c={radius:r,tube:i,radialSegments:n,tubularSegments:o,p:s,q:a,sideOrientation:h,updatable:l};return e.MeshBuilder.CreateTorusKnot(t,c,u)},i.CreateLines=function(t,r,i,n,o){var s={points:r,updatable:n,instance:o};return e.MeshBuilder.CreateLines(t,s,i)},i.CreateDashedLines=function(t,r,i,n,o,s,a,u){var l={points:r,dashSize:i,gapSize:n,dashNb:o,updatable:a,instance:u};return e.MeshBuilder.CreateDashedLines(t,l,s)},i.CreatePolygon=function(t,r,i,n,o,s){var a={shape:r,holes:n,updatable:o,sideOrientation:s};return e.MeshBuilder.CreatePolygon(t,a,i)},i.ExtrudePolygon=function(t,r,i,n,o,s,a){var u={shape:r,holes:o,depth:i,updatable:s,sideOrientation:a};return e.MeshBuilder.ExtrudePolygon(t,u,n)},i.ExtrudeShape=function(t,r,n,o,s,a,u,l,h,c){var f={shape:r,path:n,scale:o,rotation:s,cap:0===a?0:a||i.NO_CAP,sideOrientation:h,instance:c,updatable:l};return e.MeshBuilder.ExtrudeShape(t,f,u)},i.ExtrudeShapeCustom=function(t,r,n,o,s,a,u,l,h,c,f,d){var p={shape:r,path:n,scaleFunction:o,rotationFunction:s,ribbonCloseArray:a,ribbonClosePath:u,cap:0===l?0:l||i.NO_CAP,sideOrientation:f,instance:d,updatable:c};return e.MeshBuilder.ExtrudeShapeCustom(t,p,h)},i.CreateLathe=function(t,r,i,n,o,s,a){var u={shape:r,radius:i,tessellation:n,sideOrientation:a,updatable:s};return e.MeshBuilder.CreateLathe(t,u,o)},i.CreatePlane=function(t,r,i,n,o){var s={size:r,width:r,height:r,sideOrientation:o,updatable:n};return e.MeshBuilder.CreatePlane(t,s,i)},i.CreateGround=function(t,r,i,n,o,s){var a={width:r,height:i,subdivisions:n,updatable:s};return e.MeshBuilder.CreateGround(t,a,o)},i.CreateTiledGround=function(t,r,i,n,o,s,a,u,l){var h={xmin:r,zmin:i,xmax:n,zmax:o,subdivisions:s,precision:a,updatable:l};return e.MeshBuilder.CreateTiledGround(t,h,u)},i.CreateGroundFromHeightMap=function(t,r,i,n,o,s,a,u,l,h){var c={width:i,height:n,subdivisions:o,minHeight:s,maxHeight:a,updatable:l,onReady:h};return e.MeshBuilder.CreateGroundFromHeightMap(t,r,c,u)},i.CreateTube=function(t,r,i,n,o,s,a,u,l,h){var c={path:r,radius:i,tessellation:n,radiusFunction:o,arc:1,cap:s,updatable:u,sideOrientation:l,instance:h};return e.MeshBuilder.CreateTube(t,c,a)},i.CreatePolyhedron=function(t,r,i){return e.MeshBuilder.CreatePolyhedron(t,r,i)},i.CreateIcoSphere=function(t,r,i){return e.MeshBuilder.CreateIcoSphere(t,r,i)},i.CreateDecal=function(t,r,i,n,o,s){var a={position:i,normal:n,size:o,angle:s};return e.MeshBuilder.CreateDecal(t,r,a)},i.prototype.setPositionsForCPUSkinning=function(){var t;return this._sourcePositions||(t=this.getVerticesData(e.VertexBuffer.PositionKind),this._sourcePositions=new Float32Array(t),this.getVertexBuffer(e.VertexBuffer.PositionKind).isUpdatable()||this.setVerticesData(e.VertexBuffer.PositionKind,t,!0)),this._sourcePositions},i.prototype.setNormalsForCPUSkinning=function(){var t;return this._sourceNormals||(t=this.getVerticesData(e.VertexBuffer.NormalKind),this._sourceNormals=new Float32Array(t),this.getVertexBuffer(e.VertexBuffer.NormalKind).isUpdatable()||this.setVerticesData(e.VertexBuffer.NormalKind,t,!0)),this._sourceNormals},i.prototype.applySkeleton=function(t){if(!this.geometry)return this;if(this.geometry._softwareSkinningRenderId==this.getScene().getRenderId())return this;if(this.geometry._softwareSkinningRenderId=this.getScene().getRenderId(),!this.isVerticesDataPresent(e.VertexBuffer.PositionKind))return this;if(!this.isVerticesDataPresent(e.VertexBuffer.NormalKind))return this;if(!this.isVerticesDataPresent(e.VertexBuffer.MatricesIndicesKind))return this;if(!this.isVerticesDataPresent(e.VertexBuffer.MatricesWeightsKind))return this;if(!this._sourcePositions){var r=this.subMeshes.slice();this.setPositionsForCPUSkinning(),this.subMeshes=r}this._sourceNormals||this.setNormalsForCPUSkinning();var i=this.getVerticesData(e.VertexBuffer.PositionKind);i instanceof Float32Array||(i=new Float32Array(i));var n=this.getVerticesData(e.VertexBuffer.NormalKind);n instanceof Float32Array||(n=new Float32Array(n));for(var o,s=this.getVerticesData(e.VertexBuffer.MatricesIndicesKind),a=this.getVerticesData(e.VertexBuffer.MatricesWeightsKind),u=this.numBoneInfluencers>4,l=u?this.getVerticesData(e.VertexBuffer.MatricesIndicesExtraKind):null,h=u?this.getVerticesData(e.VertexBuffer.MatricesWeightsExtraKind):null,c=t.getTransformMatrices(this),f=e.Vector3.Zero(),d=new e.Matrix,p=new e.Matrix,g=0,_=0;_<i.length;_+=3,g+=4){var m;for(o=0;o<4&&(m=a[g+o])>0;o++)e.Matrix.FromFloat32ArrayToRefScaled(c,16*s[g+o],m,p),d.addToSelf(p);if(u)for(o=0;o<4&&(m=h[g+o])>0;o++)e.Matrix.FromFloat32ArrayToRefScaled(c,16*l[g+o],m,p),d.addToSelf(p);e.Vector3.TransformCoordinatesFromFloatsToRef(this._sourcePositions[_],this._sourcePositions[_+1],this._sourcePositions[_+2],d,f),f.toArray(i,_),e.Vector3.TransformNormalFromFloatsToRef(this._sourceNormals[_],this._sourceNormals[_+1],this._sourceNormals[_+2],d,f),f.toArray(n,_),d.reset()}return this.updateVerticesData(e.VertexBuffer.PositionKind,i),this.updateVerticesData(e.VertexBuffer.NormalKind,n),this},i.MinMax=function(e){var t=null,r=null;return e.forEach((function(e,i,n){var o=e.getBoundingInfo().boundingBox;t?(t.MinimizeInPlace(o.minimumWorld),r.MaximizeInPlace(o.maximumWorld)):(t=o.minimumWorld,r=o.maximumWorld)})),{min:t,max:r}},i.Center=function(t){var r=t instanceof Array?e.Mesh.MinMax(t):t;return e.Vector3.Center(r.min,r.max)},i.MergeMeshes=function(t,r,n,o,s){void 0===r&&(r=!0);var a;if(!n){var u=0;for(a=0;a<t.length;a++)if(t[a]&&(u+=t[a].getTotalVertices())>65536)return e.Tools.Warn("Cannot merge meshes because resulting mesh will have more than 65536 vertices. Please use allow32BitsIndices = true to use 32 bits indices"),null}var l,h,c,f=new Array;for(a=0;a<t.length;a++)t[a]&&(t[a].computeWorldMatrix(!0),h=e.VertexData.ExtractFromMesh(t[a],!0),h.transform(t[a].getWorldMatrix()),l?l.merge(h):(l=h,c=t[a]),s&&f.push(t[a].getTotalIndices()));if(o||(o=new i(c.name+"_merged",c.getScene())),l.applyToMesh(o),o.material=c.material,o.checkCollisions=c.checkCollisions,r)for(a=0;a<t.length;a++)t[a]&&t[a].dispose();if(s){o.releaseSubMeshes(),a=0;for(var d=0;a<f.length;)e.SubMesh.CreateFromIndices(0,d,f[a],o),d+=f[a],a++}return o},i._FRONTSIDE=0,i._BACKSIDE=1,i._DOUBLESIDE=2,i._DEFAULTSIDE=0,i._NO_CAP=0,i._CAP_START=1,i._CAP_END=2,i._CAP_ALL=3,i})(e.AbstractMesh);e.Mesh=r})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(){}return Object.defineProperty(e.prototype,"effect",{get:function(){return this._materialEffect},enumerable:!0,configurable:!0}),e.prototype.setEffect=function(e,t){if(this._materialEffect===e)return void(e||(this._materialDefines=void 0));this._materialDefines=t,this._materialEffect=e},e})();e.BaseSubMesh=t;var r=(function(t){function r(e,r,i,n,o,s,a,u){void 0===u&&(u=!0);var l=t.call(this)||this;return l.materialIndex=e,l.verticesStart=r,l.verticesCount=i,l.indexStart=n,l.indexCount=o,l._renderId=0,l._mesh=s,l._renderingMesh=a||s,s.subMeshes.push(l),l._trianglePlanes=[],l._id=s.subMeshes.length-1,u&&(l.refreshBoundingInfo(),s.computeWorldMatrix(!0)),l}return __extends(r,t),Object.defineProperty(r.prototype,"IsGlobal",{get:function(){return 0===this.verticesStart&&this.verticesCount==this._mesh.getTotalVertices()},enumerable:!0,configurable:!0}),r.prototype.getBoundingInfo=function(){return this.IsGlobal?this._mesh.getBoundingInfo():this._boundingInfo},r.prototype.setBoundingInfo=function(e){return this._boundingInfo=e,this},r.prototype.getMesh=function(){return this._mesh},r.prototype.getRenderingMesh=function(){return this._renderingMesh},r.prototype.getMaterial=function(){var e=this._renderingMesh.material;if(e&&e.getSubMaterial){var t=e,r=t.getSubMaterial(this.materialIndex);return this._currentMaterial!==r&&(this._currentMaterial=r,this._materialDefines=void 0),r}return e||this._mesh.getScene().defaultMaterial},r.prototype.refreshBoundingInfo=function(){if(this._lastColliderWorldVertices=null,!this.IsGlobal){var t=this._renderingMesh.getVerticesData(e.VertexBuffer.PositionKind);if(!t)return void(this._boundingInfo=this._mesh._boundingInfo);var r,i=this._renderingMesh.getIndices();return r=0===this.indexStart&&this.indexCount===i.length?{minimum:this._renderingMesh.getBoundingInfo().minimum.clone(),maximum:this._renderingMesh.getBoundingInfo().maximum.clone()}:e.Tools.ExtractMinAndMaxIndexed(t,i,this.indexStart,this.indexCount,this._renderingMesh.geometry.boundingBias),this._boundingInfo=new e.BoundingInfo(r.minimum,r.maximum),this}},r.prototype._checkCollision=function(e){return this.getBoundingInfo()._checkCollision(e)},r.prototype.updateBoundingInfo=function(e){return this.getBoundingInfo()||this.refreshBoundingInfo(),this.getBoundingInfo().update(e),this},r.prototype.isInFrustum=function(e){return this.getBoundingInfo().isInFrustum(e)},r.prototype.isCompletelyInFrustum=function(e){return this.getBoundingInfo().isCompletelyInFrustum(e)},r.prototype.render=function(e){return this._renderingMesh.render(this,e),this},r.prototype.getLinesIndexBuffer=function(e,t){if(!this._linesIndexBuffer){for(var r=[],i=this.indexStart;i<this.indexStart+this.indexCount;i+=3)r.push(e[i],e[i+1],e[i+1],e[i+2],e[i+2],e[i]);this._linesIndexBuffer=t.createIndexBuffer(r),this.linesIndexCount=r.length}return this._linesIndexBuffer},r.prototype.canIntersects=function(e){return e.intersectsBox(this.getBoundingInfo().boundingBox)},r.prototype.intersects=function(t,r,i,n){var o=null;if(this._mesh instanceof e.LinesMesh)for(var s=this._mesh,a=this.indexStart;a<this.indexStart+this.indexCount;a+=2){var u=r[i[a]],l=r[i[a+1]],h=t.intersectionSegment(u,l,s.intersectionThreshold);if(!(h<0)&&((n||!o||h<o.distance)&&(o=new e.IntersectionInfo(null,null,h),n)))break}else for(var a=this.indexStart;a<this.indexStart+this.indexCount;a+=3){var u=r[i[a]],l=r[i[a+1]],c=r[i[a+2]],f=t.intersectsTriangle(u,l,c);if(f){if(f.distance<0)continue;if((n||!o||f.distance<o.distance)&&(o=f,o.faceId=a/3,n))break}}return o},r.prototype.clone=function(t,i){var n=new r(this.materialIndex,this.verticesStart,this.verticesCount,this.indexStart,this.indexCount,t,i,!1);return this.IsGlobal||(n._boundingInfo=new e.BoundingInfo(this.getBoundingInfo().minimum,this.getBoundingInfo().maximum)),n},r.prototype.dispose=function(){this._linesIndexBuffer&&(this._mesh.getScene().getEngine()._releaseBuffer(this._linesIndexBuffer),this._linesIndexBuffer=null);var e=this._mesh.subMeshes.indexOf(this);this._mesh.subMeshes.splice(e,1)},r.CreateFromIndices=function(e,t,i,n,o){var s=Number.MAX_VALUE,a=-Number.MAX_VALUE;o=o||n;for(var u=o.getIndices(),l=t;l<t+i;l++){var h=u[l];h<s&&(s=h),h>a&&(a=h)}return new r(e,s,a-s+1,t,i,n,o)},r})(t);e.SubMesh=r})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){this._defines={},this._currentRank=32,this._maxRank=-1}return t.prototype.addFallback=function(e,t){this._defines[e]||(e<this._currentRank&&(this._currentRank=e),e>this._maxRank&&(this._maxRank=e),this._defines[e]=new Array),this._defines[e].push(t)},t.prototype.addCPUSkinningFallback=function(e,t){this._meshRank=e,this._mesh=t,e<this._currentRank&&(this._currentRank=e),e>this._maxRank&&(this._maxRank=e)},Object.defineProperty(t.prototype,"isMoreFallbacks",{get:function(){return this._currentRank<=this._maxRank},enumerable:!0,configurable:!0}),t.prototype.reduce=function(t){if(this._mesh&&this._mesh.computeBonesUsingShaders&&this._mesh.numBoneInfluencers>0){this._mesh.computeBonesUsingShaders=!1,t=t.replace("#define NUM_BONE_INFLUENCERS "+this._mesh.numBoneInfluencers,"#define NUM_BONE_INFLUENCERS 0"),e.Tools.Log("Falling back to CPU skinning for "+this._mesh.name);for(var r=this._mesh.getScene(),i=0;i<r.meshes.length;i++){var n=r.meshes[i];n.material===this._mesh.material&&n.computeBonesUsingShaders&&n.numBoneInfluencers>0&&(n.computeBonesUsingShaders=!1)}}else{var o=this._defines[this._currentRank];if(o)for(var i=0;i<o.length;i++)t=t.replace("#define "+o[i],"");this._currentRank++}return t},t})();e.EffectFallbacks=t;var r=(function(){function e(){}return e})();e.EffectCreationOptions=r;var i=(function(){function t(r,i,n,o,s,a,u,l,h,c){var f=this;if(this.uniqueId=0,this.onCompileObservable=new e.Observable,this.onErrorObservable=new e.Observable,this.onBindObservable=new e.Observable,this._uniformBuffersNames={},this._isReady=!1,this._compilationError="",this._valueCache={},this.name=r,i.attributes){var d=i;if(this._engine=n,this._attributesNames=d.attributes,this._uniformsNames=d.uniformsNames.concat(d.samplers),this._samplers=d.samplers,this.defines=d.defines,this.onError=d.onError,this.onCompiled=d.onCompiled,this._fallbacks=d.fallbacks,this._indexParameters=d.indexParameters,d.uniformBuffersNames)for(var p=0;p<d.uniformBuffersNames.length;p++)this._uniformBuffersNames[d.uniformBuffersNames[p]]=p}else this._engine=s,this.defines=a,this._uniformsNames=n.concat(o),this._samplers=o,this._attributesNames=i,this.onError=h,this.onCompiled=l,this._indexParameters=c,this._fallbacks=u;this.uniqueId=t._uniqueIdSeed++;var g,_;r.vertexElement?(g=document.getElementById(r.vertexElement))||(g=r.vertexElement):g=r.vertex||r,r.fragmentElement?(_=document.getElementById(r.fragmentElement))||(_=r.fragmentElement):_=r.fragment||r,this._loadVertexShader(g,(function(e){f._processIncludes(e,(function(e){f._processShaderConversion(e,!1,(function(e){f._loadFragmentShader(_,(function(t){f._processIncludes(t,(function(t){f._processShaderConversion(t,!0,(function(t){f._prepareEffect(e,t,f._attributesNames,f.defines,f._fallbacks,r)}))}))}))}))}))}))}return Object.defineProperty(t.prototype,"key",{get:function(){return this._key},enumerable:!0,configurable:!0}),t.prototype.isReady=function(){return this._isReady},t.prototype.getEngine=function(){return this._engine},t.prototype.getProgram=function(){return this._program},t.prototype.getAttributesNames=function(){return this._attributesNames},t.prototype.getAttributeLocation=function(e){return this._attributes[e]},t.prototype.getAttributeLocationByName=function(e){var t=this._attributesNames.indexOf(e);return this._attributes[t]},t.prototype.getAttributesCount=function(){return this._attributes.length},t.prototype.getUniformIndex=function(e){return this._uniformsNames.indexOf(e)},t.prototype.getUniform=function(e){return this._uniforms[this._uniformsNames.indexOf(e)]},t.prototype.getSamplers=function(){return this._samplers},t.prototype.getCompilationError=function(){return this._compilationError},t.prototype.executeWhenCompiled=function(e){if(this.isReady())return void e(this);this.onCompileObservable.add((function(t){e(t)}))},t.prototype._loadVertexShader=function(r,i){if(r instanceof HTMLElement){return void i(e.Tools.GetDOMTextContent(r))}if("base64:"===r.substr(0,7)){return void i(window.atob(r.substr(7)))}if(t.ShadersStore[r+"VertexShader"])return void i(t.ShadersStore[r+"VertexShader"]);var n;n="."===r[0]||"/"===r[0]||r.indexOf("http")>-1?r:e.Engine.ShadersRepository+r,e.Tools.LoadFile(n+".vertex.fx",i)},t.prototype._loadFragmentShader=function(r,i){if(r instanceof HTMLElement){return void i(e.Tools.GetDOMTextContent(r))}if("base64:"===r.substr(0,7)){return void i(window.atob(r.substr(7)))}if(t.ShadersStore[r+"PixelShader"])return void i(t.ShadersStore[r+"PixelShader"]);if(t.ShadersStore[r+"FragmentShader"])return void i(t.ShadersStore[r+"FragmentShader"]);var n;n="."===r[0]||"/"===r[0]||r.indexOf("http")>-1?r:e.Engine.ShadersRepository+r,e.Tools.LoadFile(n+".fragment.fx",i)},t.prototype._dumpShadersSource=function(t,r,i){var n=this._engine.webGLVersion>1?"#version 300 es\n":"",o=n+(i?i+"\n":"");t=o+t,r=o+r;var s=2,a="\n1\t"+t.replace(/\n/gm,(function(){return"\n"+s+++"\t"}));s=2;var u="\n1\t"+r.replace(/\n/gm,(function(){return"\n"+s+++"\t"}));this.name.vertexElement?(e.Tools.Error("Vertex shader: "+this.name.vertexElement+a),e.Tools.Error("Fragment shader: "+this.name.fragmentElement+u)):this.name.vertex?(e.Tools.Error("Vertex shader: "+this.name.vertex+a),e.Tools.Error("Fragment shader: "+this.name.fragment+u)):(e.Tools.Error("Vertex shader: "+this.name+a),e.Tools.Error("Fragment shader: "+this.name+u))},t.prototype._processShaderConversion=function(e,t,r){var i=this._processPrecision(e);if(1==this._engine.webGLVersion)return void r(i);if(-1!==i.indexOf("#version 3"))return void r(i.replace("#version 300 es",""));var n=i.replace(/#extension.+(GL_OES_standard_derivatives|GL_EXT_shader_texture_lod|GL_EXT_frag_depth).+enable/g,"");n=n.replace(/varying(?![\n\r])\s/g,t?"in ":"out "),n=n.replace(/attribute[ \t]/g,"in "),n=n.replace(/[ \t]attribute/g," in"),t&&(n=n.replace(/texture2DLodEXT\(/g,"textureLod("),n=n.replace(/textureCubeLodEXT\(/g,"textureLod("),n=n.replace(/texture2D\(/g,"texture("),n=n.replace(/textureCube\(/g,"texture("),n=n.replace(/gl_FragDepthEXT/g,"gl_FragDepth"),n=n.replace(/gl_FragColor/g,"glFragColor"),n=n.replace(/void\s+?main\(/g,"out vec4 glFragColor;\nvoid main(")),r(n)},t.prototype._processIncludes=function(r,i){for(var n=this,o=/#include<(.+)>(\((.*)\))*(\[(.*)\])*/g,s=o.exec(r),a=new String(r);null!=s;){var u=s[1];if(-1!==u.indexOf("__decl__")&&(u=u.replace(/__decl__/,""),1!=this._engine.webGLVersion&&(u=u.replace(/Vertex/,"Ubo"),u=u.replace(/Fragment/,"Ubo")),u+="Declaration"),!t.IncludesShadersStore[u]){var l=e.Engine.ShadersRepository+"ShadersInclude/"+u+".fx";return void e.Tools.LoadFile(l,(function(e){t.IncludesShadersStore[u]=e,n._processIncludes(a,i)}))}var h=t.IncludesShadersStore[u];if(s[2])for(var c=s[3].split(","),f=0;f<c.length;f+=2){var d=new RegExp(c[f],"g"),p=c[f+1];h=h.replace(d,p)}if(s[4]){var g=s[5];if(-1!==g.indexOf("..")){var _=g.split(".."),m=parseInt(_[0]),v=parseInt(_[1]),y=h.slice(0);h="",isNaN(v)&&(v=this._indexParameters[_[1]]);for(var A=m;A<v;A++)1===this._engine.webGLVersion&&(y=y.replace(/light\{X\}.(\w*)/g,(function(e,t){return t+"{X}"}))),h+=y.replace(/\{X\}/g,A)+"\n"}else 1===this._engine.webGLVersion&&(h=h.replace(/light\{X\}.(\w*)/g,(function(e,t){return t+"{X}"}))),h=h.replace(/\{X\}/g,g)}a=a.replace(s[0],h),s=o.exec(r)}i(a)},t.prototype._processPrecision=function(e){return-1===e.indexOf("precision highp float")?e=this._engine.getCaps().highPrecisionShaderSupported?"precision highp float;\n"+e:"precision mediump float;\n"+e:this._engine.getCaps().highPrecisionShaderSupported||(e=e.replace("precision highp float","precision mediump float")),e},t.prototype._prepareEffect=function(t,r,i,n,o,s){try{var a=this._engine;if(s&&(t="#define SHADER_NAME vertex:"+s+"\n"+t,r="#define SHADER_NAME fragment:"+s+"\n"+r),this._program=a.createShaderProgram(t,r,n),a.webGLVersion>1)for(var u in this._uniformBuffersNames)this.bindUniformBlock(u,this._uniformBuffersNames[u]);this._uniforms=a.getUniforms(this._program,this._uniformsNames),this._attributes=a.getAttributes(this._program,i);var l;for(l=0;l<this._samplers.length;l++){null==this.getUniform(this._samplers[l])&&(this._samplers.splice(l,1),l--)}a.bindSamplers(this),this._compilationError="",this._isReady=!0,this.onCompiled&&this.onCompiled(this),this.onCompileObservable.notifyObservers(this),this.onCompileObservable.clear()}catch(s){this._compilationError=s.message,e.Tools.Error("Unable to compile effect:"),e.Tools.Error("Uniforms: "+this._uniformsNames.map((function(e){return" "+e}))),e.Tools.Error("Attributes: "+i.map((function(e){return" "+e}))),this._dumpShadersSource(t,r,n),e.Tools.Error("Error: "+this._compilationError),o&&o.isMoreFallbacks?(e.Tools.Error("Trying next fallback."),n=o.reduce(n),this._prepareEffect(t,r,i,n,o)):(this.onError&&this.onError(this,this._compilationError),this.onErrorObservable.notifyObservers(this))}},Object.defineProperty(t.prototype,"isSupported",{get:function(){return""===this._compilationError},enumerable:!0,configurable:!0}),t.prototype._bindTexture=function(e,t){this._engine._bindTexture(this._samplers.indexOf(e),t)},t.prototype.setTexture=function(e,t){this._engine.setTexture(this._samplers.indexOf(e),this.getUniform(e),t)},t.prototype.setTextureArray=function(e,t){if(-1===this._samplers.indexOf(e+"Ex"))for(var r=this._samplers.indexOf(e),i=1;i<t.length;i++)this._samplers.splice(r+i,0,e+"Ex");this._engine.setTextureArray(this._samplers.indexOf(e),this.getUniform(e),t)},t.prototype.setTextureFromPostProcess=function(e,t){this._engine.setTextureFromPostProcess(this._samplers.indexOf(e),t)},t.prototype._cacheMatrix=function(e,t){var r=this._valueCache[e],i=t.updateFlag;return(void 0===r||r!==i)&&(this._valueCache[e]=i,!0)},t.prototype._cacheFloat2=function(e,t,r){var i=this._valueCache[e];if(!i)return i=[t,r],this._valueCache[e]=i,!0;var n=!1;return i[0]!==t&&(i[0]=t,n=!0),i[1]!==r&&(i[1]=r,n=!0),n},t.prototype._cacheFloat3=function(e,t,r,i){var n=this._valueCache[e];if(!n)return n=[t,r,i],this._valueCache[e]=n,!0;var o=!1;return n[0]!==t&&(n[0]=t,o=!0),n[1]!==r&&(n[1]=r,o=!0),n[2]!==i&&(n[2]=i,o=!0),o},t.prototype._cacheFloat4=function(e,t,r,i,n){var o=this._valueCache[e];if(!o)return o=[t,r,i,n],this._valueCache[e]=o,!0;var s=!1;return o[0]!==t&&(o[0]=t,s=!0),o[1]!==r&&(o[1]=r,s=!0),o[2]!==i&&(o[2]=i,s=!0),o[3]!==n&&(o[3]=n,s=!0),s},t.prototype.bindUniformBuffer=function(e,r){t._baseCache[this._uniformBuffersNames[r]]!==e&&(t._baseCache[this._uniformBuffersNames[r]]=e,this._engine.bindUniformBufferBase(e,this._uniformBuffersNames[r]))},t.prototype.bindUniformBlock=function(e,t){this._engine.bindUniformBlock(this._program,e,t)},t.prototype.setIntArray=function(e,t){return this._valueCache[e]=null,this._engine.setIntArray(this.getUniform(e),t),this},t.prototype.setIntArray2=function(e,t){return this._valueCache[e]=null,this._engine.setIntArray2(this.getUniform(e),t),this},t.prototype.setIntArray3=function(e,t){return this._valueCache[e]=null,this._engine.setIntArray3(this.getUniform(e),t),this},t.prototype.setIntArray4=function(e,t){return this._valueCache[e]=null,this._engine.setIntArray4(this.getUniform(e),t),this},t.prototype.setFloatArray=function(e,t){return this._valueCache[e]=null,this._engine.setFloatArray(this.getUniform(e),t),this},t.prototype.setFloatArray2=function(e,t){return this._valueCache[e]=null,this._engine.setFloatArray2(this.getUniform(e),t),this},t.prototype.setFloatArray3=function(e,t){return this._valueCache[e]=null,this._engine.setFloatArray3(this.getUniform(e),t),this},t.prototype.setFloatArray4=function(e,t){return this._valueCache[e]=null,this._engine.setFloatArray4(this.getUniform(e),t),this},
- t.prototype.setArray=function(e,t){return this._valueCache[e]=null,this._engine.setArray(this.getUniform(e),t),this},t.prototype.setArray2=function(e,t){return this._valueCache[e]=null,this._engine.setArray2(this.getUniform(e),t),this},t.prototype.setArray3=function(e,t){return this._valueCache[e]=null,this._engine.setArray3(this.getUniform(e),t),this},t.prototype.setArray4=function(e,t){return this._valueCache[e]=null,this._engine.setArray4(this.getUniform(e),t),this},t.prototype.setMatrices=function(e,t){if(t)return this._valueCache[e]=null,this._engine.setMatrices(this.getUniform(e),t),this},t.prototype.setMatrix=function(e,t){return this._cacheMatrix(e,t)&&this._engine.setMatrix(this.getUniform(e),t),this},t.prototype.setMatrix3x3=function(e,t){return this._valueCache[e]=null,this._engine.setMatrix3x3(this.getUniform(e),t),this},t.prototype.setMatrix2x2=function(e,t){return this._valueCache[e]=null,this._engine.setMatrix2x2(this.getUniform(e),t),this},t.prototype.setFloat=function(e,t){var r=this._valueCache[e];return void 0!==r&&r===t?this:(this._valueCache[e]=t,this._engine.setFloat(this.getUniform(e),t),this)},t.prototype.setBool=function(e,t){var r=this._valueCache[e];return void 0!==r&&r===t?this:(this._valueCache[e]=t,this._engine.setBool(this.getUniform(e),t?1:0),this)},t.prototype.setVector2=function(e,t){return this._cacheFloat2(e,t.x,t.y)&&this._engine.setFloat2(this.getUniform(e),t.x,t.y),this},t.prototype.setFloat2=function(e,t,r){return this._cacheFloat2(e,t,r)&&this._engine.setFloat2(this.getUniform(e),t,r),this},t.prototype.setVector3=function(e,t){return this._cacheFloat3(e,t.x,t.y,t.z)&&this._engine.setFloat3(this.getUniform(e),t.x,t.y,t.z),this},t.prototype.setFloat3=function(e,t,r,i){return this._cacheFloat3(e,t,r,i)&&this._engine.setFloat3(this.getUniform(e),t,r,i),this},t.prototype.setVector4=function(e,t){return this._cacheFloat4(e,t.x,t.y,t.z,t.w)&&this._engine.setFloat4(this.getUniform(e),t.x,t.y,t.z,t.w),this},t.prototype.setFloat4=function(e,t,r,i,n){return this._cacheFloat4(e,t,r,i,n)&&this._engine.setFloat4(this.getUniform(e),t,r,i,n),this},t.prototype.setColor3=function(e,t){return this._cacheFloat3(e,t.r,t.g,t.b)&&this._engine.setColor3(this.getUniform(e),t),this},t.prototype.setColor4=function(e,t,r){return this._cacheFloat4(e,t.r,t.g,t.b,r)&&this._engine.setColor4(this.getUniform(e),t,r),this},t.ResetCache=function(){t._baseCache={}},t._uniqueIdSeed=0,t._baseCache={},t.ShadersStore={},t.IncludesShadersStore={},t})();e.Effect=i})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){}return t.PrepareDefinesForMergedUV=function(e,t,r){t._needUVs=!0,t[r]=!0,e.getTextureMatrix().isIdentity(!0)?(t[r+"DIRECTUV"]=e.coordinatesIndex+1,0===e.coordinatesIndex?t.MAINUV1=!0:t.MAINUV2=!0):t[r+"DIRECTUV"]=0},t.BindTextureMatrix=function(e,t,r){var i=e.getTextureMatrix();i.isIdentity(!0)||t.updateMatrix(r+"Matrix",i)},t.PrepareDefinesForMisc=function(t,r,i,n,o,s){s._areMiscDirty&&(s.LOGARITHMICDEPTH=i,s.POINTSIZE=n||r.forcePointsCloud,s.FOG=r.fogEnabled&&t.applyFog&&r.fogMode!==e.Scene.FOGMODE_NONE&&o,s.USERIGHTHANDEDSYSTEM=r.useRightHandedSystem)},t.PrepareDefinesForFrameBoundValues=function(e,t,r,i,n){void 0===n&&(n=!1);var o=!1;r.CLIPPLANE!==(void 0!==e.clipPlane&&null!==e.clipPlane)&&(r.CLIPPLANE=!r.CLIPPLANE,o=!0),r.ALPHATEST!==(t.getAlphaTesting()||n)&&(r.ALPHATEST=!r.ALPHATEST,o=!0),r.INSTANCES!==i&&(r.INSTANCES=i,o=!0),o&&r.markAsUnprocessed()},t.PrepareDefinesForAttributes=function(t,r,i,n,o){if(void 0===o&&(o=!1),!r._areAttributesDirty&&r._needNormals===r._normals&&r._needUVs===r._uvs)return!1;if(r._normals=r._needNormals,r._uvs=r._needUVs,r.NORMAL=r._needNormals&&t.isVerticesDataPresent(e.VertexBuffer.NormalKind),r._needNormals&&t.isVerticesDataPresent(e.VertexBuffer.TangentKind)&&(r.TANGENT=!0),r._needUVs?(r.UV1=t.isVerticesDataPresent(e.VertexBuffer.UVKind),r.UV2=t.isVerticesDataPresent(e.VertexBuffer.UV2Kind)):(r.UV1=!1,r.UV2=!1),i&&(r.VERTEXCOLOR=t.useVertexColors&&t.isVerticesDataPresent(e.VertexBuffer.ColorKind),r.VERTEXALPHA=t.hasVertexAlpha),n&&(t.useBones&&t.computeBonesUsingShaders?(r.NUM_BONE_INFLUENCERS=t.numBoneInfluencers,r.BonesPerMesh=t.skeleton.bones.length+1):(r.NUM_BONE_INFLUENCERS=0,r.BonesPerMesh=0)),o)if(t.morphTargetManager){var s=t.morphTargetManager;r.MORPHTARGETS_TANGENT=s.supportsTangents&&r.TANGENT,r.MORPHTARGETS_NORMAL=s.supportsNormals&&r.NORMAL,r.MORPHTARGETS=s.numInfluencers>0,r.NUM_MORPH_INFLUENCERS=s.numInfluencers}else r.MORPHTARGETS_TANGENT=!1,r.MORPHTARGETS_NORMAL=!1,r.MORPHTARGETS=!1,r.NUM_MORPH_INFLUENCERS=0;return!0},t.PrepareDefinesForLights=function(t,r,i,n,o,s){if(void 0===o&&(o=4),void 0===s&&(s=!1),!i._areLightsDirty)return i._needNormals;var a=0,u=!1,l=!1,h=!1,c=!1,f=!1;if(t.lightsEnabled&&!s)for(var d=0,p=r._lightSources;d<p.length;d++){var g=p[d];u=!0,void 0===i["LIGHT"+a]&&(l=!0),i["LIGHT"+a]=!0,i["SPOTLIGHT"+a]=!1,i["HEMILIGHT"+a]=!1,i["POINTLIGHT"+a]=!1,i["DIRLIGHT"+a]=!1;var _;if(_=g.getTypeID()===e.Light.LIGHTTYPEID_SPOTLIGHT?"SPOTLIGHT"+a:g.getTypeID()===e.Light.LIGHTTYPEID_HEMISPHERICLIGHT?"HEMILIGHT"+a:g.getTypeID()===e.Light.LIGHTTYPEID_POINTLIGHT?"POINTLIGHT"+a:"DIRLIGHT"+a,i[_]=!0,n&&!g.specular.equalsFloats(0,0,0)&&(f=!0),i["SHADOW"+a]=!1,i["SHADOWPCF"+a]=!1,i["SHADOWESM"+a]=!1,i["SHADOWCUBE"+a]=!1,r&&r.receiveShadows&&t.shadowsEnabled&&g.shadowEnabled){var m=g.getShadowGenerator();m&&(c=!0,m.prepareDefines(i,a))}if(g.lightmapMode!=e.Light.LIGHTMAP_DEFAULT?(h=!0,i["LIGHTMAPEXCLUDED"+a]=!0,i["LIGHTMAPNOSPECULAR"+a]=g.lightmapMode==e.Light.LIGHTMAP_SHADOWSONLY):(i["LIGHTMAPEXCLUDED"+a]=!1,i["LIGHTMAPNOSPECULAR"+a]=!1),++a===o)break}i.SPECULARTERM=f,i.SHADOWS=c;for(var v=a;v<o;v++)void 0!==i["LIGHT"+v]&&(i["LIGHT"+v]=!1,i["HEMILIGHT"+a]=!1,i["POINTLIGHT"+a]=!1,i["DIRLIGHT"+a]=!1,i["SPOTLIGHT"+a]=!1,i["SHADOW"+a]=!1);var y=t.getEngine().getCaps();return void 0===i.SHADOWFLOAT&&(l=!0),i.SHADOWFLOAT=c&&(y.textureFloatRender&&y.textureFloatLinearFiltering||y.textureHalfFloatRender&&y.textureHalfFloatLinearFiltering),i.LIGHTMAPEXCLUDED=h,l&&i.rebuild(),u},t.PrepareUniformsAndSamplersList=function(e,t,r,i){void 0===i&&(i=4);var n,o,t,r;if(e.uniformsNames){var s=e;n=s.uniformsNames,o=s.uniformBuffersNames,t=s.samplers,r=s.defines,i=s.maxSimultaneousLights}else n=e;for(var a=0;a<i&&r["LIGHT"+a];a++)n.push("vLightData"+a,"vLightDiffuse"+a,"vLightSpecular"+a,"vLightDirection"+a,"vLightGround"+a,"lightMatrix"+a,"shadowsInfo"+a,"depthValues"+a),o&&o.push("Light"+a),t.push("shadowSampler"+a);r.NUM_MORPH_INFLUENCERS&&n.push("morphTargetInfluences")},t.HandleFallbacksForShadows=function(e,t,r){if(void 0===r&&(r=4),e.SHADOWS)for(var i=0;i<r&&e["LIGHT"+i];i++)i>0&&t.addFallback(i,"LIGHT"+i),e["SHADOW"+i]&&t.addFallback(0,"SHADOW"+i),e["SHADOWPCF"+i]&&t.addFallback(0,"SHADOWPCF"+i),e["SHADOWESM"+i]&&t.addFallback(0,"SHADOWESM"+i)},t.PrepareAttributesForMorphTargets=function(t,r,i){var n=i.NUM_MORPH_INFLUENCERS;if(n>0)for(var o=e.Engine.LastCreatedEngine.getCaps().maxVertexAttribs,s=r.morphTargetManager,a=s.supportsNormals&&i.NORMAL,u=s.supportsTangents&&i.TANGENT,l=0;l<n;l++)t.push(e.VertexBuffer.PositionKind+l),a&&t.push(e.VertexBuffer.NormalKind+l),u&&t.push(e.VertexBuffer.TangentKind+l),t.length>o&&e.Tools.Error("Cannot add more vertex attributes for mesh "+r.name)},t.PrepareAttributesForBones=function(t,r,i,n){i.NUM_BONE_INFLUENCERS>0&&(n.addCPUSkinningFallback(0,r),t.push(e.VertexBuffer.MatricesIndicesKind),t.push(e.VertexBuffer.MatricesWeightsKind),i.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,r,i,n){if(e.shadowEnabled&&r.receiveShadows){var o=e.getShadowGenerator();o&&o.bindShadowLight(i,n)}},t.BindLightProperties=function(e,t,r){e.transferToEffect(t,r+"")},t.BindLights=function(r,i,n,o,s,a){void 0===s&&(s=4),void 0===a&&(a=!1);for(var u=0,l=0,h=i._lightSources;l<h.length;l++){var c=h[l],f=c.getScaledIntensity();if(c._uniformBuffer.bindToEffect(n,"Light"+u),t.BindLightProperties(c,n,u),c.diffuse.scaleToRef(f,e.Tmp.Color3[0]),c._uniformBuffer.updateColor4("vLightDiffuse",e.Tmp.Color3[0],a?c.radius:c.range,u+""),o.SPECULARTERM&&(c.specular.scaleToRef(f,e.Tmp.Color3[1]),c._uniformBuffer.updateColor3("vLightSpecular",e.Tmp.Color3[1],u+"")),r.shadowsEnabled&&this.BindLightShadow(c,r,i,u+"",n),c._uniformBuffer.update(),++u===s)break}},t.BindFogParameters=function(t,r,i){t.fogEnabled&&r.applyFog&&t.fogMode!==e.Scene.FOGMODE_NONE&&(i.setFloat4("vFogInfos",t.fogMode,t.fogStart,t.fogEnd,t.fogDensity),i.setColor3("vFogColor",t.fogColor))},t.BindBonesParameters=function(e,t){if(e&&e.useBones&&e.computeBonesUsingShaders){var r=e.skeleton.getTransformMatrices(e);r&&t.setMatrices("mBones",r)}},t.BindMorphTargetParameters=function(e,t){e&&e.morphTargetManager&&t.setFloatArray("morphTargetInfluences",e.morphTargetManager.influences)},t.BindLogDepth=function(e,t,r){e.LOGARITHMICDEPTH&&t.setFloat("logarithmicDepthConstant",2/(Math.log(r.activeCamera.maxZ+1)/Math.LN2))},t.BindClipPlane=function(e,t){if(t.clipPlane){var r=t.clipPlane;e.setFloat4("vClipPlane",r.normal.x,r.normal.y,r.normal.z,r.d)}},t})();e.MaterialHelper=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(){this._isDirty=!0,this._areLightsDirty=!0,this._areAttributesDirty=!0,this._areTexturesDirty=!0,this._areFresnelDirty=!0,this._areMiscDirty=!0,this._areImageProcessingDirty=!0,this._normals=!1,this._uvs=!1,this._needNormals=!1,this._needUVs=!1}return Object.defineProperty(e.prototype,"isDirty",{get:function(){return this._isDirty},enumerable:!0,configurable:!0}),e.prototype.markAsProcessed=function(){this._isDirty=!1,this._areAttributesDirty=!1,this._areTexturesDirty=!1,this._areFresnelDirty=!1,this._areLightsDirty=!1,this._areMiscDirty=!1,this._areImageProcessingDirty=!1},e.prototype.markAsUnprocessed=function(){this._isDirty=!0},e.prototype.markAllAsDirty=function(){this._areTexturesDirty=!0,this._areAttributesDirty=!0,this._areLightsDirty=!0,this._areFresnelDirty=!0,this._areMiscDirty=!0,this._areImageProcessingDirty=!0,this._isDirty=!0},e.prototype.markAsImageProcessingDirty=function(){this._areImageProcessingDirty=!0,this._isDirty=!0},e.prototype.markAsLightDirty=function(){this._areLightsDirty=!0,this._isDirty=!0},e.prototype.markAsAttributesDirty=function(){this._areAttributesDirty=!0,this._isDirty=!0},e.prototype.markAsTexturesDirty=function(){this._areTexturesDirty=!0,this._isDirty=!0},e.prototype.markAsFresnelDirty=function(){this._areFresnelDirty=!0,this._isDirty=!0},e.prototype.markAsMiscDirty=function(){this._areMiscDirty=!0,this._isDirty=!0},e.prototype.rebuild=function(){this._keys&&delete this._keys,this._keys=[];for(var e=0,t=Object.keys(this);e<t.length;e++){var r=t[e];"_"!==r[0]&&this._keys.push(r)}},e.prototype.isEqual=function(e){if(this._keys.length!==e._keys.length)return!1;for(var t=0;t<this._keys.length;t++){var r=this._keys[t];if(this[r]!==e[r])return!1}return!0},e.prototype.cloneTo=function(e){this._keys.length!==e._keys.length&&(e._keys=this._keys.slice(0));for(var t=0;t<this._keys.length;t++){var r=this._keys[t];e[r]=this[r]}},e.prototype.reset=function(){for(var e=0;e<this._keys.length;e++){var t=this._keys[e];"number"==typeof this[t]?this[t]=0:this[t]=!1}},e.prototype.toString=function(){for(var e="",t=0;t<this._keys.length;t++){var r=this._keys[t],i=this[r];"number"==typeof i?e+="#define "+r+" "+this[r]+"\n":i&&(e+="#define "+r+"\n")}return e},e})();e.MaterialDefines=t;var r=(function(){function t(r,i,n){this.checkReadyOnEveryCall=!1,this.checkReadyOnlyOnce=!1,this.state="",this.alpha=1,this._backFaceCulling=!0,this.doNotSerialize=!1,this.storeEffectOnSubMeshes=!1,this.onDisposeObservable=new e.Observable,this.onBindObservable=new e.Observable,this.onUnBindObservable=new e.Observable,this.alphaMode=e.Engine.ALPHA_COMBINE,this.disableDepthWrite=!1,this._fogEnabled=!0,this.pointSize=1,this.zOffset=0,this._wasPreviouslyReady=!1,this._fillMode=t.TriangleFillMode,this.name=r,this.id=r||e.Tools.RandomId(),this._scene=i||e.Engine.LastCreatedScene,this._scene.useRightHandedSystem?this.sideOrientation=t.ClockWiseSideOrientation:this.sideOrientation=t.CounterClockWiseSideOrientation,this._uniformBuffer=new e.UniformBuffer(this._scene.getEngine()),this._useUBO=this.getScene().getEngine().webGLVersion>1,n||this._scene.materials.push(this)}return Object.defineProperty(t,"TriangleFillMode",{get:function(){return t._TriangleFillMode},enumerable:!0,configurable:!0}),Object.defineProperty(t,"WireFrameFillMode",{get:function(){return t._WireFrameFillMode},enumerable:!0,configurable:!0}),Object.defineProperty(t,"PointFillMode",{get:function(){return t._PointFillMode},enumerable:!0,configurable:!0}),Object.defineProperty(t,"ClockWiseSideOrientation",{get:function(){return t._ClockWiseSideOrientation},enumerable:!0,configurable:!0}),Object.defineProperty(t,"CounterClockWiseSideOrientation",{get:function(){return t._CounterClockWiseSideOrientation},enumerable:!0,configurable:!0}),Object.defineProperty(t,"TextureDirtyFlag",{get:function(){return t._TextureDirtyFlag},enumerable:!0,configurable:!0}),Object.defineProperty(t,"LightDirtyFlag",{get:function(){return t._LightDirtyFlag},enumerable:!0,configurable:!0}),Object.defineProperty(t,"FresnelDirtyFlag",{get:function(){return t._FresnelDirtyFlag},enumerable:!0,configurable:!0}),Object.defineProperty(t,"AttributesDirtyFlag",{get:function(){return t._AttributesDirtyFlag},enumerable:!0,configurable:!0}),Object.defineProperty(t,"MiscDirtyFlag",{get:function(){return t._MiscDirtyFlag},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"backFaceCulling",{get:function(){return this._backFaceCulling},set:function(e){this._backFaceCulling!==e&&(this._backFaceCulling=e,this.markAsDirty(t.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onBind",{set:function(e){this._onBindObserver&&this.onBindObservable.remove(this._onBindObserver),this._onBindObserver=this.onBindObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"fogEnabled",{get:function(){return this._fogEnabled},set:function(e){this._fogEnabled!==e&&(this._fogEnabled=e,this.markAsDirty(t.MiscDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"wireframe",{get:function(){return this._fillMode===t.WireFrameFillMode},set:function(e){this._fillMode=e?t.WireFrameFillMode:t.TriangleFillMode},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"pointsCloud",{get:function(){return this._fillMode===t.PointFillMode},set:function(e){this._fillMode=e?t.PointFillMode:t.TriangleFillMode},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"fillMode",{get:function(){return this._fillMode},set:function(e){this._fillMode!==e&&(this._fillMode=e,this.markAsDirty(t.MiscDirtyFlag))},enumerable:!0,configurable:!0}),t.prototype.toString=function(e){return"Name: "+this.name},t.prototype.getClassName=function(){return"Material"},Object.defineProperty(t.prototype,"isFrozen",{get:function(){return this.checkReadyOnlyOnce},enumerable:!0,configurable:!0}),t.prototype.freeze=function(){this.checkReadyOnlyOnce=!0},t.prototype.unfreeze=function(){this.checkReadyOnlyOnce=!1},t.prototype.isReady=function(e,t){return!0},t.prototype.isReadyForSubMesh=function(e,t,r){return!1},t.prototype.getEffect=function(){return this._effect},t.prototype.getScene=function(){return this._scene},t.prototype.needAlphaBlending=function(){return this.alpha<1},t.prototype.needAlphaTesting=function(){return!1},t.prototype.getAlphaTestTexture=function(){return null},t.prototype.markDirty=function(){this._wasPreviouslyReady=!1},t.prototype._preBind=function(e){var r=this._scene.getEngine(),i=this.sideOrientation===t.ClockWiseSideOrientation;r.enableEffect(e||this._effect),r.setState(this.backFaceCulling,this.zOffset,!1,i)},t.prototype.bind=function(e,t){},t.prototype.bindForSubMesh=function(e,t,r){},t.prototype.bindOnlyWorldMatrix=function(e){},t.prototype.bindSceneUniformBuffer=function(e,t){t.bindToEffect(e,"Scene")},t.prototype.bindView=function(e){this._useUBO?this.bindSceneUniformBuffer(e,this.getScene().getSceneUniformBuffer()):e.setMatrix("view",this.getScene().getViewMatrix())},t.prototype.bindViewProjection=function(e){this._useUBO?this.bindSceneUniformBuffer(e,this.getScene().getSceneUniformBuffer()):e.setMatrix("viewProjection",this.getScene().getTransformMatrix())},t.prototype._afterBind=function(e){if(this._scene._cachedMaterial=this,this._scene._cachedVisibility=e?e.visibility:1,this.onBindObservable.notifyObservers(e),this.disableDepthWrite){var t=this._scene.getEngine();this._cachedDepthWriteState=t.getDepthWrite(),t.setDepthWrite(!1)}},t.prototype.unbind=function(){if(this.onUnBindObservable.notifyObservers(this),this.disableDepthWrite){this._scene.getEngine().setDepthWrite(this._cachedDepthWriteState)}},t.prototype.getActiveTextures=function(){return[]},t.prototype.hasTexture=function(e){return!1},t.prototype.clone=function(e){return null},t.prototype.getBindedMeshes=function(){for(var e=new Array,t=0;t<this._scene.meshes.length;t++){var r=this._scene.meshes[t];r.material===this&&e.push(r)}return e},t.prototype.forceCompilation=function(t,r,i){var n=this,o=new e.BaseSubMesh,s=this.getScene(),a=s.getEngine(),u=function(){if(n._scene&&n._scene.getEngine()){o._materialDefines&&(o._materialDefines._renderId=-1);var l=a.getAlphaTesting(),h=s.clipPlane;a.setAlphaTesting(i?i.alphaTest:n.needAlphaTesting()),i&&i.clipPlane&&(s.clipPlane=new e.Plane(0,0,0,1)),n.storeEffectOnSubMeshes?n.isReadyForSubMesh(t,o)?r&&r(n):setTimeout(u,16):n.isReady(t)?r&&r(n):setTimeout(u,16),a.setAlphaTesting(l),i&&i.clipPlane&&(s.clipPlane=h)}};u()},t.prototype.markAsDirty=function(e){e&t.TextureDirtyFlag&&this._markAllSubMeshesAsTexturesDirty(),e&t.LightDirtyFlag&&this._markAllSubMeshesAsLightsDirty(),e&t.FresnelDirtyFlag&&this._markAllSubMeshesAsFresnelDirty(),e&t.AttributesDirtyFlag&&this._markAllSubMeshesAsAttributesDirty(),e&t.MiscDirtyFlag&&this._markAllSubMeshesAsMiscDirty(),this.getScene().resetCachedMaterial()},t.prototype._markAllSubMeshesAsDirty=function(e){for(var t=0,r=this.getScene().meshes;t<r.length;t++){var i=r[t];if(i.subMeshes)for(var n=0,o=i.subMeshes;n<o.length;n++){var s=o[n];s.getMaterial()===this&&(s._materialDefines&&e(s._materialDefines))}}},t.prototype._markAllSubMeshesAsImageProcessingDirty=function(){this._markAllSubMeshesAsDirty((function(e){return e.markAsImageProcessingDirty()}))},t.prototype._markAllSubMeshesAsTexturesDirty=function(){this._markAllSubMeshesAsDirty((function(e){return e.markAsTexturesDirty()}))},t.prototype._markAllSubMeshesAsFresnelDirty=function(){this._markAllSubMeshesAsDirty((function(e){return e.markAsFresnelDirty()}))},t.prototype._markAllSubMeshesAsLightsDirty=function(){this._markAllSubMeshesAsDirty((function(e){return e.markAsLightDirty()}))},t.prototype._markAllSubMeshesAsAttributesDirty=function(){this._markAllSubMeshesAsDirty((function(e){return e.markAsAttributesDirty()}))},t.prototype._markAllSubMeshesAsMiscDirty=function(){this._markAllSubMeshesAsDirty((function(e){return e.markAsMiscDirty()}))},t.prototype.dispose=function(e,t){this.getScene().stopAnimation(this);var r=this._scene.materials.indexOf(this);for(r>=0&&this._scene.materials.splice(r,1),r=0;r<this._scene.meshes.length;r++){var i=this._scene.meshes[r];if(i.material===this&&(i.material=null,i.geometry)){var n=i.geometry;if(this.storeEffectOnSubMeshes)for(var o=0,s=i.subMeshes;o<s.length;o++){var a=s[o];n._releaseVertexArrayObject(a._materialEffect)}else n._releaseVertexArrayObject(this._effect)}}if(this._uniformBuffer.dispose(),e&&this._effect){if(this.storeEffectOnSubMeshes)for(var u=0,l=i.subMeshes;u<l.length;u++){var a=l[u];this._scene.getEngine()._releaseEffect(a._materialEffect)}else this._scene.getEngine()._releaseEffect(this._effect);this._effect=null}this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this.onBindObservable.clear(),this.onUnBindObservable.clear()},t.prototype.serialize=function(){return e.SerializationHelper.Serialize(this)},t.ParseMultiMaterial=function(t,r){var i=new e.MultiMaterial(t.name,r);i.id=t.id,e.Tags&&e.Tags.AddTagsTo(i,t.tags);for(var n=0;n<t.materials.length;n++){var o=t.materials[n];o?i.subMaterials.push(r.getMaterialByID(o)):i.subMaterials.push(null)}return i},t.Parse=function(t,r,i){return t.customType?"BABYLON.PBRMaterial"===t.customType&&t.overloadedAlbedo&&(t.customType="BABYLON.LegacyPBRMaterial",!e.LegacyPBRMaterial)?void e.Tools.Error("Your scene is trying to load a legacy version of the PBRMaterial, please, include it from the materials library."):e.Tools.Instantiate(t.customType).Parse(t,r,i):e.StandardMaterial.Parse(t,r,i)},t._TriangleFillMode=0,t._WireFrameFillMode=1,t._PointFillMode=2,t._ClockWiseSideOrientation=0,t._CounterClockWiseSideOrientation=1,t._TextureDirtyFlag=1,t._LightDirtyFlag=2,t._FresnelDirtyFlag=4,t._AttributesDirtyFlag=8,t._MiscDirtyFlag=16,__decorate([e.serialize()],t.prototype,"id",void 0),__decorate([e.serialize()],t.prototype,"name",void 0),__decorate([e.serialize()],t.prototype,"checkReadyOnEveryCall",void 0),__decorate([e.serialize()],t.prototype,"checkReadyOnlyOnce",void 0),__decorate([e.serialize()],t.prototype,"state",void 0),__decorate([e.serialize()],t.prototype,"alpha",void 0),__decorate([e.serialize("backFaceCulling")],t.prototype,"_backFaceCulling",void 0),__decorate([e.serialize()],t.prototype,"sideOrientation",void 0),__decorate([e.serialize()],t.prototype,"alphaMode",void 0),__decorate([e.serialize()],t.prototype,"disableDepthWrite",void 0),__decorate([e.serialize("fogEnabled")],t.prototype,"_fogEnabled",void 0),__decorate([e.serialize()],t.prototype,"pointSize",void 0),__decorate([e.serialize()],t.prototype,"zOffset",void 0),__decorate([e.serialize()],t.prototype,"wireframe",null),__decorate([e.serialize()],t.prototype,"pointsCloud",null),__decorate([e.serialize()],t.prototype,"fillMode",null),t})();e.Material=r})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(e,t,r){this._engine=e,this._noUBO=1===e.webGLVersion,this._dynamic=r,this._data=t||[],this._uniformLocations={},this._uniformSizes={},this._uniformLocationPointer=0,this._needSync=!1,this._noUBO?(this.updateMatrix3x3=this._updateMatrix3x3ForEffect,this.updateMatrix2x2=this._updateMatrix2x2ForEffect,this.updateFloat=this._updateFloatForEffect,this.updateFloat2=this._updateFloat2ForEffect,this.updateFloat3=this._updateFloat3ForEffect,this.updateFloat4=this._updateFloat4ForEffect,this.updateMatrix=this._updateMatrixForEffect,this.updateVector3=this._updateVector3ForEffect,this.updateVector4=this._updateVector4ForEffect,this.updateColor3=this._updateColor3ForEffect,this.updateColor4=this._updateColor4ForEffect):(this.updateMatrix3x3=this._updateMatrix3x3ForUniform,this.updateMatrix2x2=this._updateMatrix2x2ForUniform,this.updateFloat=this._updateFloatForUniform,this.updateFloat2=this._updateFloat2ForUniform,this.updateFloat3=this._updateFloat3ForUniform,this.updateFloat4=this._updateFloat4ForUniform,this.updateMatrix=this._updateMatrixForUniform,this.updateVector3=this._updateVector3ForUniform,this.updateVector4=this._updateVector4ForUniform,this.updateColor3=this._updateColor3ForUniform,this.updateColor4=this._updateColor4ForUniform)}return Object.defineProperty(t.prototype,"useUbo",{get:function(){return!this._noUBO},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isSync",{get:function(){return!this._needSync},enumerable:!0,configurable:!0}),t.prototype.isDynamic=function(){return this._dynamic},t.prototype.getData=function(){return this._bufferData},t.prototype.getBuffer=function(){return this._buffer},t.prototype._fillAlignment=function(e){var t;if(t=e<=2?e:4,this._uniformLocationPointer%t!=0){var r=this._uniformLocationPointer;this._uniformLocationPointer+=t-this._uniformLocationPointer%t;for(var i=this._uniformLocationPointer-r,n=0;n<i;n++)this._data.push(0)}},t.prototype.addUniform=function(e,t){if(!this._noUBO&&void 0===this._uniformLocations[e]){var r;if(t instanceof Array)r=t,t=r.length;else{t=t,r=[];for(var i=0;i<t;i++)r.push(0)}this._fillAlignment(t),this._uniformSizes[e]=t,this._uniformLocations[e]=this._uniformLocationPointer,this._uniformLocationPointer+=t;for(var i=0;i<t;i++)this._data.push(r[i]);this._needSync=!0}},t.prototype.addMatrix=function(e,t){this.addUniform(e,Array.prototype.slice.call(t.toArray()))},t.prototype.addFloat2=function(e,t,r){var i=[t,r];this.addUniform(e,i)},t.prototype.addFloat3=function(e,t,r,i){var n=[t,r,i];this.addUniform(e,n)},t.prototype.addColor3=function(e,t){var r=[];t.toArray(r),this.addUniform(e,r)},t.prototype.addColor4=function(e,t,r){var i=[];t.toArray(i),i.push(r),this.addUniform(e,i)},t.prototype.addVector3=function(e,t){var r=[];t.toArray(r),this.addUniform(e,r)},t.prototype.addMatrix3x3=function(e){this.addUniform(e,12)},t.prototype.addMatrix2x2=function(e){this.addUniform(e,8)},t.prototype.create=function(){this._noUBO||this._buffer||(this._fillAlignment(4),this._bufferData=new Float32Array(this._data),this._dynamic?this._buffer=this._engine.createDynamicUniformBuffer(this._bufferData):this._buffer=this._engine.createUniformBuffer(this._bufferData),this._needSync=!0)},t.prototype.update=function(){if(!this._buffer)return void this.create();(this._dynamic||this._needSync)&&(this._engine.updateUniformBuffer(this._buffer,this._bufferData),this._needSync=!1)},t.prototype.updateUniform=function(t,r,i){var n=this._uniformLocations[t];if(void 0===n){if(this._buffer)return void e.Tools.Error("Cannot add an uniform after UBO has been created.");this.addUniform(t,i),n=this._uniformLocations[t]}if(this._buffer||this.create(),this._dynamic)for(var o=0;o<i;o++)this._bufferData[n+o]=r[o];else{for(var s=!1,o=0;o<i;o++)this._bufferData[n+o]!==r[o]&&(s=!0,this._bufferData[n+o]=r[o]);this._needSync=this._needSync||s}},t.prototype._updateMatrix3x3ForUniform=function(e,r){for(var i=0;i<3;i++)t._tempBuffer[4*i]=r[3*i],t._tempBuffer[4*i+1]=r[3*i+1],t._tempBuffer[4*i+2]=r[3*i+2],t._tempBuffer[4*i+3]=0;this.updateUniform(e,t._tempBuffer,12)},t.prototype._updateMatrix3x3ForEffect=function(e,t){this._currentEffect.setMatrix3x3(e,t)},t.prototype._updateMatrix2x2ForEffect=function(e,t){this._currentEffect.setMatrix2x2(e,t)},t.prototype._updateMatrix2x2ForUniform=function(e,r){for(var i=0;i<2;i++)t._tempBuffer[4*i]=r[2*i],t._tempBuffer[4*i+1]=r[2*i+1],t._tempBuffer[4*i+2]=0,t._tempBuffer[4*i+3]=0;this.updateUniform(e,t._tempBuffer,8)},t.prototype._updateFloatForEffect=function(e,t){this._currentEffect.setFloat(e,t)},t.prototype._updateFloatForUniform=function(e,r){t._tempBuffer[0]=r,this.updateUniform(e,t._tempBuffer,1)},t.prototype._updateFloat2ForEffect=function(e,t,r,i){void 0===i&&(i=""),this._currentEffect.setFloat2(e+i,t,r)},t.prototype._updateFloat2ForUniform=function(e,r,i,n){void 0===n&&(n=""),t._tempBuffer[0]=r,t._tempBuffer[1]=i,this.updateUniform(e,t._tempBuffer,2)},t.prototype._updateFloat3ForEffect=function(e,t,r,i,n){void 0===n&&(n=""),this._currentEffect.setFloat3(e+n,t,r,i)},t.prototype._updateFloat3ForUniform=function(e,r,i,n,o){void 0===o&&(o=""),t._tempBuffer[0]=r,t._tempBuffer[1]=i,t._tempBuffer[2]=n,this.updateUniform(e,t._tempBuffer,3)},t.prototype._updateFloat4ForEffect=function(e,t,r,i,n,o){void 0===o&&(o=""),this._currentEffect.setFloat4(e+o,t,r,i,n)},t.prototype._updateFloat4ForUniform=function(e,r,i,n,o,s){void 0===s&&(s=""),t._tempBuffer[0]=r,t._tempBuffer[1]=i,t._tempBuffer[2]=n,t._tempBuffer[3]=o,this.updateUniform(e,t._tempBuffer,4)},t.prototype._updateMatrixForEffect=function(e,t){this._currentEffect.setMatrix(e,t)},t.prototype._updateMatrixForUniform=function(e,t){this.updateUniform(e,t.toArray(),16)},t.prototype._updateVector3ForEffect=function(e,t){this._currentEffect.setVector3(e,t)},t.prototype._updateVector3ForUniform=function(e,r){r.toArray(t._tempBuffer),this.updateUniform(e,t._tempBuffer,3)},t.prototype._updateVector4ForEffect=function(e,t){this._currentEffect.setVector4(e,t)},t.prototype._updateVector4ForUniform=function(e,r){r.toArray(t._tempBuffer),this.updateUniform(e,t._tempBuffer,4)},t.prototype._updateColor3ForEffect=function(e,t,r){void 0===r&&(r=""),this._currentEffect.setColor3(e+r,t)},t.prototype._updateColor3ForUniform=function(e,r,i){void 0===i&&(i=""),r.toArray(t._tempBuffer),this.updateUniform(e,t._tempBuffer,3)},t.prototype._updateColor4ForEffect=function(e,t,r,i){void 0===i&&(i=""),this._currentEffect.setColor4(e+i,t,r)},t.prototype._updateColor4ForUniform=function(e,r,i,n){void 0===n&&(n=""),r.toArray(t._tempBuffer),t._tempBuffer[3]=i,this.updateUniform(e,t._tempBuffer,4)},t.prototype.setTexture=function(e,t){this._currentEffect.setTexture(e,t)},t.prototype.updateUniformDirectly=function(e,t){this.updateUniform(e,t,t.length),this.update()},t.prototype.bindToEffect=function(e,t){this._currentEffect=e,this._noUBO||e.bindUniformBuffer(this._buffer,t)},t.prototype.dispose=function(){this._buffer&&this._engine._releaseBuffer(this._buffer)&&(this._buffer=null)},t._MAX_UNIFORM_SIZE=256,t._tempBuffer=new Float32Array(t._MAX_UNIFORM_SIZE),t})();e.UniformBuffer=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(e){function t(t,r){var i=e.call(this,t,r)||this;return i.storeEffectOnSubMeshes=!0,i}return __extends(t,e),t.prototype.getEffect=function(){return this._activeEffect},t.prototype.isReady=function(e,t){return!!e&&(!e.subMeshes||0===e.subMeshes.length||this.isReadyForSubMesh(e,e.subMeshes[0],t))},t.prototype.bindOnlyWorldMatrix=function(e){this._activeEffect.setMatrix("world",e)},t.prototype.bind=function(e,t){t&&this.bindForSubMesh(e,t,t.subMeshes[0])},t.prototype._afterBind=function(t,r){e.prototype._afterBind.call(this,t),this.getScene()._cachedEffect=r},t.prototype._mustRebind=function(e,t,r){return void 0===r&&(r=1),e.isCachedMaterialInvalid(this,t,r)},t})(e.Material);e.PushMaterial=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){}return t.prototype.set=function(t,r){switch(r){case e.VertexBuffer.PositionKind:this.positions=t;break;case e.VertexBuffer.NormalKind:this.normals=t;break;case e.VertexBuffer.TangentKind:this.tangents=t;break;case e.VertexBuffer.UVKind:this.uvs=t;break;case e.VertexBuffer.UV2Kind:this.uvs2=t;break;case e.VertexBuffer.UV3Kind:this.uvs3=t;break;case e.VertexBuffer.UV4Kind:this.uvs4=t;break;case e.VertexBuffer.UV5Kind:this.uvs5=t;break;case e.VertexBuffer.UV6Kind:this.uvs6=t;break;case e.VertexBuffer.ColorKind:this.colors=t;break;case e.VertexBuffer.MatricesIndicesKind:this.matricesIndices=t;break;case e.VertexBuffer.MatricesWeightsKind:this.matricesWeights=t;break;case e.VertexBuffer.MatricesIndicesExtraKind:this.matricesIndicesExtra=t;break;case e.VertexBuffer.MatricesWeightsExtraKind:this.matricesWeightsExtra=t}},t.prototype.applyToMesh=function(e,t){return this._applyTo(e,t),this},t.prototype.applyToGeometry=function(e,t){return this._applyTo(e,t),this},t.prototype.updateMesh=function(e,t,r){return this._update(e),this},t.prototype.updateGeometry=function(e,t,r){return this._update(e),this},t.prototype._applyTo=function(t,r){return this.positions&&t.setVerticesData(e.VertexBuffer.PositionKind,this.positions,r),this.normals&&t.setVerticesData(e.VertexBuffer.NormalKind,this.normals,r),this.tangents&&t.setVerticesData(e.VertexBuffer.TangentKind,this.tangents,r),this.uvs&&t.setVerticesData(e.VertexBuffer.UVKind,this.uvs,r),this.uvs2&&t.setVerticesData(e.VertexBuffer.UV2Kind,this.uvs2,r),this.uvs3&&t.setVerticesData(e.VertexBuffer.UV3Kind,this.uvs3,r),
- this.uvs4&&t.setVerticesData(e.VertexBuffer.UV4Kind,this.uvs4,r),this.uvs5&&t.setVerticesData(e.VertexBuffer.UV5Kind,this.uvs5,r),this.uvs6&&t.setVerticesData(e.VertexBuffer.UV6Kind,this.uvs6,r),this.colors&&t.setVerticesData(e.VertexBuffer.ColorKind,this.colors,r),this.matricesIndices&&t.setVerticesData(e.VertexBuffer.MatricesIndicesKind,this.matricesIndices,r),this.matricesWeights&&t.setVerticesData(e.VertexBuffer.MatricesWeightsKind,this.matricesWeights,r),this.matricesIndicesExtra&&t.setVerticesData(e.VertexBuffer.MatricesIndicesExtraKind,this.matricesIndicesExtra,r),this.matricesWeightsExtra&&t.setVerticesData(e.VertexBuffer.MatricesWeightsExtraKind,this.matricesWeightsExtra,r),this.indices&&t.setIndices(this.indices),this},t.prototype._update=function(t,r,i){return this.positions&&t.updateVerticesData(e.VertexBuffer.PositionKind,this.positions,r,i),this.normals&&t.updateVerticesData(e.VertexBuffer.NormalKind,this.normals,r,i),this.tangents&&t.updateVerticesData(e.VertexBuffer.TangentKind,this.tangents,r,i),this.uvs&&t.updateVerticesData(e.VertexBuffer.UVKind,this.uvs,r,i),this.uvs2&&t.updateVerticesData(e.VertexBuffer.UV2Kind,this.uvs2,r,i),this.uvs3&&t.updateVerticesData(e.VertexBuffer.UV3Kind,this.uvs3,r,i),this.uvs4&&t.updateVerticesData(e.VertexBuffer.UV4Kind,this.uvs4,r,i),this.uvs5&&t.updateVerticesData(e.VertexBuffer.UV5Kind,this.uvs5,r,i),this.uvs6&&t.updateVerticesData(e.VertexBuffer.UV6Kind,this.uvs6,r,i),this.colors&&t.updateVerticesData(e.VertexBuffer.ColorKind,this.colors,r,i),this.matricesIndices&&t.updateVerticesData(e.VertexBuffer.MatricesIndicesKind,this.matricesIndices,r,i),this.matricesWeights&&t.updateVerticesData(e.VertexBuffer.MatricesWeightsKind,this.matricesWeights,r,i),this.matricesIndicesExtra&&t.updateVerticesData(e.VertexBuffer.MatricesIndicesExtraKind,this.matricesIndicesExtra,r,i),this.matricesWeightsExtra&&t.updateVerticesData(e.VertexBuffer.MatricesWeightsExtraKind,this.matricesWeightsExtra,r,i),this.indices&&t.setIndices(this.indices),this},t.prototype.transform=function(t){var r,i=e.Vector3.Zero();if(this.positions){var n=e.Vector3.Zero();for(r=0;r<this.positions.length;r+=3)e.Vector3.FromArrayToRef(this.positions,r,n),e.Vector3.TransformCoordinatesToRef(n,t,i),this.positions[r]=i.x,this.positions[r+1]=i.y,this.positions[r+2]=i.z}if(this.normals){var o=e.Vector3.Zero();for(r=0;r<this.normals.length;r+=3)e.Vector3.FromArrayToRef(this.normals,r,o),e.Vector3.TransformNormalToRef(o,t,i),this.normals[r]=i.x,this.normals[r+1]=i.y,this.normals[r+2]=i.z}if(this.tangents){var s=e.Vector4.Zero(),a=e.Vector4.Zero();for(r=0;r<this.tangents.length;r+=4)e.Vector4.FromArrayToRef(this.tangents,r,s),e.Vector4.TransformNormalToRef(s,t,a),this.tangents[r]=a.x,this.tangents[r+1]=a.y,this.tangents[r+2]=a.z,this.tangents[r+3]=a.w}return this},t.prototype.merge=function(e){if(e.indices){this.indices||(this.indices=[]);for(var t=this.positions?this.positions.length/3:0,r=0;r<e.indices.length;r++)this.indices.push(e.indices[r]+t)}return this.positions=this._mergeElement(this.positions,e.positions),this.normals=this._mergeElement(this.normals,e.normals),this.tangents=this._mergeElement(this.tangents,e.tangents),this.uvs=this._mergeElement(this.uvs,e.uvs),this.uvs2=this._mergeElement(this.uvs2,e.uvs2),this.uvs3=this._mergeElement(this.uvs3,e.uvs3),this.uvs4=this._mergeElement(this.uvs4,e.uvs4),this.uvs5=this._mergeElement(this.uvs5,e.uvs5),this.uvs6=this._mergeElement(this.uvs6,e.uvs6),this.colors=this._mergeElement(this.colors,e.colors),this.matricesIndices=this._mergeElement(this.matricesIndices,e.matricesIndices),this.matricesWeights=this._mergeElement(this.matricesWeights,e.matricesWeights),this.matricesIndicesExtra=this._mergeElement(this.matricesIndicesExtra,e.matricesIndicesExtra),this.matricesWeightsExtra=this._mergeElement(this.matricesWeightsExtra,e.matricesWeightsExtra),this},t.prototype._mergeElement=function(e,t){if(!t)return e;if(!e)return t;var r=t.length+e.length,i=e instanceof Float32Array,n=t instanceof Float32Array;if(i){var o=new Float32Array(r);return o.set(e),o.set(t,e.length),o}if(n){for(var s=e.slice(0),a=0,r=t.length;a<r;a++)s.push(t[a]);return s}return e.concat(t)},t.prototype.serialize=function(){var e=this.serialize();return this.positions&&(e.positions=this.positions),this.normals&&(e.normals=this.normals),this.tangents&&(e.tangents=this.tangents),this.uvs&&(e.uvs=this.uvs),this.uvs2&&(e.uvs2=this.uvs2),this.uvs3&&(e.uvs3=this.uvs3),this.uvs4&&(e.uvs4=this.uvs4),this.uvs5&&(e.uvs5=this.uvs5),this.uvs6&&(e.uvs6=this.uvs6),this.colors&&(e.colors=this.colors),this.matricesIndices&&(e.matricesIndices=this.matricesIndices,e.matricesIndices._isExpanded=!0),this.matricesWeights&&(e.matricesWeights=this.matricesWeights),this.matricesIndicesExtra&&(e.matricesIndicesExtra=this.matricesIndicesExtra,e.matricesIndicesExtra._isExpanded=!0),this.matricesWeightsExtra&&(e.matricesWeightsExtra=this.matricesWeightsExtra),e.indices=this.indices,e},t.ExtractFromMesh=function(e,r,i){return t._ExtractFrom(e,r,i)},t.ExtractFromGeometry=function(e,r,i){return t._ExtractFrom(e,r,i)},t._ExtractFrom=function(r,i,n){var o=new t;return r.isVerticesDataPresent(e.VertexBuffer.PositionKind)&&(o.positions=r.getVerticesData(e.VertexBuffer.PositionKind,i,n)),r.isVerticesDataPresent(e.VertexBuffer.NormalKind)&&(o.normals=r.getVerticesData(e.VertexBuffer.NormalKind,i,n)),r.isVerticesDataPresent(e.VertexBuffer.TangentKind)&&(o.tangents=r.getVerticesData(e.VertexBuffer.TangentKind,i,n)),r.isVerticesDataPresent(e.VertexBuffer.UVKind)&&(o.uvs=r.getVerticesData(e.VertexBuffer.UVKind,i,n)),r.isVerticesDataPresent(e.VertexBuffer.UV2Kind)&&(o.uvs2=r.getVerticesData(e.VertexBuffer.UV2Kind,i,n)),r.isVerticesDataPresent(e.VertexBuffer.UV3Kind)&&(o.uvs3=r.getVerticesData(e.VertexBuffer.UV3Kind,i,n)),r.isVerticesDataPresent(e.VertexBuffer.UV4Kind)&&(o.uvs4=r.getVerticesData(e.VertexBuffer.UV4Kind,i,n)),r.isVerticesDataPresent(e.VertexBuffer.UV5Kind)&&(o.uvs5=r.getVerticesData(e.VertexBuffer.UV5Kind,i,n)),r.isVerticesDataPresent(e.VertexBuffer.UV6Kind)&&(o.uvs6=r.getVerticesData(e.VertexBuffer.UV6Kind,i,n)),r.isVerticesDataPresent(e.VertexBuffer.ColorKind)&&(o.colors=r.getVerticesData(e.VertexBuffer.ColorKind,i,n)),r.isVerticesDataPresent(e.VertexBuffer.MatricesIndicesKind)&&(o.matricesIndices=r.getVerticesData(e.VertexBuffer.MatricesIndicesKind,i,n)),r.isVerticesDataPresent(e.VertexBuffer.MatricesWeightsKind)&&(o.matricesWeights=r.getVerticesData(e.VertexBuffer.MatricesWeightsKind,i,n)),r.isVerticesDataPresent(e.VertexBuffer.MatricesIndicesExtraKind)&&(o.matricesIndicesExtra=r.getVerticesData(e.VertexBuffer.MatricesIndicesExtraKind,i,n)),r.isVerticesDataPresent(e.VertexBuffer.MatricesWeightsExtraKind)&&(o.matricesWeightsExtra=r.getVerticesData(e.VertexBuffer.MatricesWeightsExtraKind,i,n)),o.indices=r.getIndices(i),o},t.CreateRibbon=function(r){var i=r.pathArray,n=r.closeArray||!1,o=r.closePath||!1,s=r.invertUV||!1,a=Math.floor(i[0].length/2),u=r.offset||a;u=u>a?a:Math.floor(u);var l,h,c,f,d=0===r.sideOrientation?0:r.sideOrientation||e.Mesh.DEFAULTSIDE,p=r.uvs,g=r.colors,_=[],m=[],v=[],y=[],A=[],T=[],E=[],b=[],x=[],M=[];if(i.length<2){var P=[],R=[];for(c=0;c<i[0].length-u;c++)P.push(i[0][c]),R.push(i[0][c+u]);i=[P,R]}var C,O,S=0,I=o?1:0;l=i[0].length;var L,D;for(h=0;h<i.length;h++){for(E[h]=0,A[h]=[0],C=i[h],O=C.length,l=l<O?l:O,f=0;f<O;)_.push(C[f].x,C[f].y,C[f].z),f>0&&(L=C[f].subtract(C[f-1]).length(),D=L+E[h],A[h].push(D),E[h]=D),f++;o&&(f--,_.push(C[0].x,C[0].y,C[0].z),L=C[f].subtract(C[0]).length(),D=L+E[h],A[h].push(D),E[h]=D),x[h]=O+I,M[h]=S,S+=O+I}var B,N,F,w;for(c=0;c<l+I;c++){for(b[c]=0,T[c]=[0],h=0;h<i.length-1;h++)B=i[h],N=i[h+1],c===l?(F=B[0],w=N[0]):(F=B[c],w=N[c]),L=w.subtract(F).length(),D=L+b[c],T[c].push(D),b[c]=D;n&&(B=i[h],N=i[0],c===l&&(w=N[0]),L=w.subtract(F).length(),D=L+b[c],b[c]=D)}var V,U;if(p)for(h=0;h<p.length;h++)y.push(p[h].x,p[h].y);else for(h=0;h<i.length;h++)for(c=0;c<l+I;c++)V=0!=E[h]?A[h][c]/E[h]:0,U=0!=b[c]?T[c][h]/b[c]:0,s?y.push(U,V):y.push(V,U);h=0;for(var k=0,z=x[h]-1,G=x[h+1]-1,H=z<G?z:G,Y=M[1]-M[0],W=n?x.length:x.length-1;k<=H&&h<W;)m.push(k,k+Y,k+1),m.push(k+Y+1,k+1,k+Y),(k+=1)===H&&(h++,h===x.length-1?(Y=M[0]-M[h],z=x[h]-1,G=x[0]-1):(Y=M[h+1]-M[h],z=x[h]-1,G=x[h+1]-1),k=M[h],H=z<G?z+k:G+k);if(t.ComputeNormals(_,m,v),o){var X=0,j=0;for(h=0;h<i.length;h++)X=3*M[h],j=h+1<i.length?3*(M[h+1]-1):v.length-3,v[X]=.5*(v[X]+v[j]),v[X+1]=.5*(v[X+1]+v[j+1]),v[X+2]=.5*(v[X+2]+v[j+2]),v[j]=v[X],v[j+1]=v[X+1],v[j+2]=v[X+2]}if(t._ComputeSides(d,_,m,v,y,r.frontUVs,r.backUVs),g)for(var K=new Float32Array(4*g.length),Q=0;Q<g.length;Q++)K[4*Q]=g[Q].r,K[4*Q+1]=g[Q].g,K[4*Q+2]=g[Q].b,K[4*Q+3]=g[Q].a;var Z=new t,q=new Float32Array(_),J=new Float32Array(v),$=new Float32Array(y);return Z.indices=m,Z.positions=q,Z.normals=J,Z.uvs=$,g&&Z.set(K,e.VertexBuffer.ColorKind),o&&(Z._idx=M),Z},t.CreateBox=function(r){for(var i=[new e.Vector3(0,0,1),new e.Vector3(0,0,-1),new e.Vector3(1,0,0),new e.Vector3(-1,0,0),new e.Vector3(0,1,0),new e.Vector3(0,-1,0)],n=[],o=[],s=[],a=[],u=r.width||r.size||1,l=r.height||r.size||1,h=r.depth||r.size||1,c=0===r.sideOrientation?0:r.sideOrientation||e.Mesh.DEFAULTSIDE,f=r.faceUV||new Array(6),d=r.faceColors,p=[],g=0;g<6;g++)void 0===f[g]&&(f[g]=new e.Vector4(0,0,1,1)),d&&void 0===d[g]&&(d[g]=new e.Color4(1,1,1,1));for(var _=new e.Vector3(u/2,l/2,h/2),m=0;m<i.length;m++){var v=i[m],y=new e.Vector3(v.y,v.z,v.x),A=e.Vector3.Cross(v,y),T=o.length/3;n.push(T),n.push(T+1),n.push(T+2),n.push(T),n.push(T+2),n.push(T+3);var E=v.subtract(y).subtract(A).multiply(_);o.push(E.x,E.y,E.z),s.push(v.x,v.y,v.z),a.push(f[m].z,f[m].w),d&&p.push(d[m].r,d[m].g,d[m].b,d[m].a),E=v.subtract(y).add(A).multiply(_),o.push(E.x,E.y,E.z),s.push(v.x,v.y,v.z),a.push(f[m].x,f[m].w),d&&p.push(d[m].r,d[m].g,d[m].b,d[m].a),E=v.add(y).add(A).multiply(_),o.push(E.x,E.y,E.z),s.push(v.x,v.y,v.z),a.push(f[m].x,f[m].y),d&&p.push(d[m].r,d[m].g,d[m].b,d[m].a),E=v.add(y).subtract(A).multiply(_),o.push(E.x,E.y,E.z),s.push(v.x,v.y,v.z),a.push(f[m].z,f[m].y),d&&p.push(d[m].r,d[m].g,d[m].b,d[m].a)}t._ComputeSides(c,o,n,s,a,r.frontUVs,r.backUVs);var b=new t;if(b.indices=n,b.positions=o,b.normals=s,b.uvs=a,d){var x=c===e.Mesh.DOUBLESIDE?p.concat(p):p;b.colors=x}return b},t.CreateSphere=function(r){for(var i=r.segments||32,n=r.diameterX||r.diameter||1,o=r.diameterY||r.diameter||1,s=r.diameterZ||r.diameter||1,a=r.arc<=0||r.arc>1?1:r.arc||1,u=r.slice<=0?1:r.slice||1,l=0===r.sideOrientation?0:r.sideOrientation||e.Mesh.DEFAULTSIDE,h=new e.Vector3(n/2,o/2,s/2),c=2+i,f=2*c,d=[],p=[],g=[],_=[],m=0;m<=c;m++){for(var v=m/c,y=v*Math.PI*u,A=0;A<=f;A++){var T=A/f,E=T*Math.PI*2*a,b=e.Matrix.RotationZ(-y),x=e.Matrix.RotationY(E),M=e.Vector3.TransformCoordinates(e.Vector3.Up(),b),P=e.Vector3.TransformCoordinates(M,x),R=P.multiply(h),C=P.divide(h).normalize();p.push(R.x,R.y,R.z),g.push(C.x,C.y,C.z),_.push(T,v)}if(m>0)for(var O=p.length/3,S=O-2*(f+1);S+f+2<O;S++)d.push(S),d.push(S+1),d.push(S+f+1),d.push(S+f+1),d.push(S+1),d.push(S+f+2)}t._ComputeSides(l,p,d,g,_,r.frontUVs,r.backUVs);var I=new t;return I.indices=d,I.positions=p,I.normals=g,I.uvs=_,I},t.CreateCylinder=function(r){var i,n=r.height||2,o=0===r.diameterTop?0:r.diameterTop||r.diameter||1,s=0===r.diameterBottom?0:r.diameterBottom||r.diameter||1,a=r.tessellation||24,u=r.subdivisions||1,l=r.hasRings,h=r.enclose,c=r.arc<=0||r.arc>1?1:r.arc||1,f=0===r.sideOrientation?0:r.sideOrientation||e.Mesh.DEFAULTSIDE,d=r.faceUV||new Array(3),p=r.faceColors,g=1!==c&&h?2:0,_=l?u:1,m=2+(1+g)*_;for(i=0;i<m;i++)p&&void 0===p[i]&&(p[i]=new e.Color4(1,1,1,1));for(i=0;i<m;i++)d&&void 0===d[i]&&(d[i]=new e.Vector4(0,0,1,1));var v,y,A,T,E,b,x=[],M=[],P=[],R=[],C=[],O=2*Math.PI*c/a,S=(s-o)/2/n,I=e.Vector3.Zero(),L=e.Vector3.Zero(),D=e.Vector3.Zero(),B=e.Vector3.Zero(),N=e.Vector3.Zero(),F=e.Axis.Y,w=1,V=1,U=0,k=0;for(T=0;T<=u;T++)for(y=T/u,A=(y*(o-s)+s)/2,w=l&&0!==T&&T!==u?2:1,b=0;b<w;b++){for(l&&(V+=b),h&&(V+=2*b),E=0;E<=a;E++)v=E*O,I.x=Math.cos(-v)*A,I.y=-n/2+y*n,I.z=Math.sin(-v)*A,0===o&&T===u?(L.x=P[P.length-3*(a+1)],L.y=P[P.length-3*(a+1)+1],L.z=P[P.length-3*(a+1)+2]):(L.x=I.x,L.z=I.z,L.y=Math.sqrt(L.x*L.x+L.z*L.z)*S,L.normalize()),0===E&&(D.copyFrom(I),B.copyFrom(L)),M.push(I.x,I.y,I.z),P.push(L.x,L.y,L.z),k=l?U!==V?d[V].y:d[V].w:d[V].y+(d[V].w-d[V].y)*y,R.push(d[V].x+(d[V].z-d[V].x)*E/a,k),p&&C.push(p[V].r,p[V].g,p[V].b,p[V].a);1!==c&&h&&(M.push(I.x,I.y,I.z),M.push(0,I.y,0),M.push(0,I.y,0),M.push(D.x,D.y,D.z),e.Vector3.CrossToRef(F,L,N),N.normalize(),P.push(N.x,N.y,N.z,N.x,N.y,N.z),e.Vector3.CrossToRef(B,F,N),N.normalize(),P.push(N.x,N.y,N.z,N.x,N.y,N.z),k=l?U!==V?d[V+1].y:d[V+1].w:d[V+1].y+(d[V+1].w-d[V+1].y)*y,R.push(d[V+1].x,k),R.push(d[V+1].z,k),k=l?U!==V?d[V+2].y:d[V+2].w:d[V+2].y+(d[V+2].w-d[V+2].y)*y,R.push(d[V+2].x,k),R.push(d[V+2].z,k),p&&(C.push(p[V+1].r,p[V+1].g,p[V+1].b,p[V+1].a),C.push(p[V+1].r,p[V+1].g,p[V+1].b,p[V+1].a),C.push(p[V+2].r,p[V+2].g,p[V+2].b,p[V+2].a),C.push(p[V+2].r,p[V+2].g,p[V+2].b,p[V+2].a))),U!==V&&(U=V)}var V,z=1!==c&&h?a+4:a;for(T=0,V=0;V<u;V++){for(E=0;E<a;E++){var G=T*(z+1)+E,H=(T+1)*(z+1)+E,Y=T*(z+1)+(E+1),W=(T+1)*(z+1)+(E+1);x.push(G,H,Y),x.push(W,Y,H)}1!==c&&h&&(x.push(G+2,H+2,Y+2),x.push(W+2,Y+2,H+2),x.push(G+4,H+4,Y+4),x.push(W+4,Y+4,H+4)),T=l?T+2:T+1}var X=function(t){var r=t?o/2:s/2;if(0!==r){var i,u,l,h,f=t?d[m-1]:d[0];p&&(h=t?p[m-1]:p[0]);var g=M.length/3,_=t?n/2:-n/2,v=new e.Vector3(0,_,0);M.push(v.x,v.y,v.z),P.push(0,t?1:-1,0),R.push(f.x+.5*(f.z-f.x),f.y+.5*(f.w-f.y)),p&&C.push(h.r,h.g,h.b,h.a);var y=new e.Vector2(.5,.5);for(l=0;l<=a;l++){i=2*Math.PI*l*c/a;var A=Math.cos(-i),T=Math.sin(-i);u=new e.Vector3(A*r,_,T*r);var E=new e.Vector2(A*y.x+.5,T*y.y+.5);M.push(u.x,u.y,u.z),P.push(0,t?1:-1,0),R.push(f.x+(f.z-f.x)*E.x,f.y+(f.w-f.y)*E.y),p&&C.push(h.r,h.g,h.b,h.a)}for(l=0;l<a;l++)t?(x.push(g),x.push(g+(l+2)),x.push(g+(l+1))):(x.push(g),x.push(g+(l+1)),x.push(g+(l+2)))}};X(!1),X(!0),t._ComputeSides(f,M,x,P,R,r.frontUVs,r.backUVs);var j=new t;return j.indices=x,j.positions=M,j.normals=P,j.uvs=R,p&&(j.colors=C),j},t.CreateTorus=function(r){for(var i=[],n=[],o=[],s=[],a=r.diameter||1,u=r.thickness||.5,l=r.tessellation||16,h=0===r.sideOrientation?0:r.sideOrientation||e.Mesh.DEFAULTSIDE,c=l+1,f=0;f<=l;f++)for(var d=f/l,p=f*Math.PI*2/l-Math.PI/2,g=e.Matrix.Translation(a/2,0,0).multiply(e.Matrix.RotationY(p)),_=0;_<=l;_++){var m=1-_/l,v=_*Math.PI*2/l+Math.PI,y=Math.cos(v),A=Math.sin(v),T=new e.Vector3(y,A,0),E=T.scale(u/2),b=new e.Vector2(d,m);E=e.Vector3.TransformCoordinates(E,g),T=e.Vector3.TransformNormal(T,g),n.push(E.x,E.y,E.z),o.push(T.x,T.y,T.z),s.push(b.x,b.y);var x=(f+1)%c,M=(_+1)%c;i.push(f*c+_),i.push(f*c+M),i.push(x*c+_),i.push(f*c+M),i.push(x*c+M),i.push(x*c+_)}t._ComputeSides(h,n,i,o,s,r.frontUVs,r.backUVs);var P=new t;return P.indices=i,P.positions=n,P.normals=o,P.uvs=s,P},t.CreateLineSystem=function(e){for(var r=[],i=[],n=e.lines,o=0,s=0;s<n.length;s++)for(var a=n[s],u=0;u<a.length;u++)i.push(a[u].x,a[u].y,a[u].z),u>0&&(r.push(o-1),r.push(o)),o++;var l=new t;return l.indices=r,l.positions=i,l},t.CreateDashedLines=function(r){var i=r.dashSize||3,n=r.gapSize||1,o=r.dashNb||200,s=r.points,a=new Array,u=new Array,l=e.Vector3.Zero(),h=0,c=0,f=0,d=0,p=0,g=0,_=0;for(_=0;_<s.length-1;_++)s[_+1].subtractToRef(s[_],l),h+=l.length();for(f=h/o,d=i*f/(i+n),_=0;_<s.length-1;_++){s[_+1].subtractToRef(s[_],l),c=Math.floor(l.length()/f),l.normalize();for(var m=0;m<c;m++)p=f*m,a.push(s[_].x+p*l.x,s[_].y+p*l.y,s[_].z+p*l.z),a.push(s[_].x+(p+d)*l.x,s[_].y+(p+d)*l.y,s[_].z+(p+d)*l.z),u.push(g,g+1),g+=2}var v=new t;return v.positions=a,v.indices=u,v},t.CreateGround=function(r){var i,n,o=[],s=[],a=[],u=[],l=r.width||1,h=r.height||1,c=r.subdivisionsX||r.subdivisions||1,f=r.subdivisionsY||r.subdivisions||1;for(i=0;i<=f;i++)for(n=0;n<=c;n++){var d=new e.Vector3(n*l/c-l/2,0,(f-i)*h/f-h/2),p=new e.Vector3(0,1,0);s.push(d.x,d.y,d.z),a.push(p.x,p.y,p.z),u.push(n/c,1-i/f)}for(i=0;i<f;i++)for(n=0;n<c;n++)o.push(n+1+(i+1)*(c+1)),o.push(n+1+i*(c+1)),o.push(n+i*(c+1)),o.push(n+(i+1)*(c+1)),o.push(n+1+(i+1)*(c+1)),o.push(n+i*(c+1));var g=new t;return g.indices=o,g.positions=s,g.normals=a,g.uvs=u,g},t.CreateTiledGround=function(r){var i,n,o,s,a=r.xmin||-1,u=r.zmin||-1,l=r.xmax||1,h=r.zmax||1,c=r.subdivisions||{w:1,h:1},f=r.precision||{w:1,h:1},d=[],p=[],g=[],_=[];c.h=c.h<1?1:c.h,c.w=c.w<1?1:c.w,f.w=f.w<1?1:f.w,f.h=f.h<1?1:f.h;var m={w:(l-a)/c.w,h:(h-u)/c.h};for(o=0;o<c.h;o++)for(s=0;s<c.w;s++)!(function(t,r,o,s){var a=p.length/3,u=f.w+1;for(i=0;i<f.h;i++)for(n=0;n<f.w;n++){var l=[a+n+i*u,a+(n+1)+i*u,a+(n+1)+(i+1)*u,a+n+(i+1)*u];d.push(l[1]),d.push(l[2]),d.push(l[3]),d.push(l[0]),d.push(l[1]),d.push(l[3])}var h=e.Vector3.Zero(),c=new e.Vector3(0,1,0);for(i=0;i<=f.h;i++)for(h.z=i*(s-r)/f.h+r,n=0;n<=f.w;n++)h.x=n*(o-t)/f.w+t,h.y=0,p.push(h.x,h.y,h.z),g.push(c.x,c.y,c.z),_.push(n/f.w,i/f.h)})(a+s*m.w,u+o*m.h,a+(s+1)*m.w,u+(o+1)*m.h);var v=new t;return v.indices=d,v.positions=p,v.normals=g,v.uvs=_,v},t.CreateGroundFromHeightMap=function(r){var i,n,o=[],s=[],a=[],u=[],l=r.colorFilter||new e.Color3(.3,.59,.11);for(i=0;i<=r.subdivisions;i++)for(n=0;n<=r.subdivisions;n++){var h=new e.Vector3(n*r.width/r.subdivisions-r.width/2,0,(r.subdivisions-i)*r.height/r.subdivisions-r.height/2),c=(h.x+r.width/2)/r.width*(r.bufferWidth-1)|0,f=(1-(h.z+r.height/2)/r.height)*(r.bufferHeight-1)|0,d=4*(c+f*r.bufferWidth),p=r.buffer[d]/255,g=r.buffer[d+1]/255,_=r.buffer[d+2]/255,m=p*l.r+g*l.g+_*l.b;h.y=r.minHeight+(r.maxHeight-r.minHeight)*m,s.push(h.x,h.y,h.z),a.push(0,0,0),u.push(n/r.subdivisions,1-i/r.subdivisions)}for(i=0;i<r.subdivisions;i++)for(n=0;n<r.subdivisions;n++)o.push(n+1+(i+1)*(r.subdivisions+1)),o.push(n+1+i*(r.subdivisions+1)),o.push(n+i*(r.subdivisions+1)),o.push(n+(i+1)*(r.subdivisions+1)),o.push(n+1+(i+1)*(r.subdivisions+1)),o.push(n+i*(r.subdivisions+1));t.ComputeNormals(s,o,a);var v=new t;return v.indices=o,v.positions=s,v.normals=a,v.uvs=u,v},t.CreatePlane=function(r){var i=[],n=[],o=[],s=[],a=r.width||r.size||1,u=r.height||r.size||1,l=0===r.sideOrientation?0:r.sideOrientation||e.Mesh.DEFAULTSIDE,h=a/2,c=u/2;n.push(-h,-c,0),o.push(0,0,-1),s.push(0,0),n.push(h,-c,0),o.push(0,0,-1),s.push(1,0),n.push(h,c,0),o.push(0,0,-1),s.push(1,1),n.push(-h,c,0),o.push(0,0,-1),s.push(0,1),i.push(0),i.push(1),i.push(2),i.push(0),i.push(2),i.push(3),t._ComputeSides(l,n,i,o,s,r.frontUVs,r.backUVs);var f=new t;return f.indices=i,f.positions=n,f.normals=o,f.uvs=s,f},t.CreateDisc=function(r){var i=[],n=[],o=[],s=[],a=r.radius||.5,u=r.tessellation||64,l=r.arc<=0||r.arc>1?1:r.arc||1,h=0===r.sideOrientation?0:r.sideOrientation||e.Mesh.DEFAULTSIDE;i.push(0,0,0),s.push(.5,.5);for(var c=2*Math.PI*l,f=c/u,d=0;d<c;d+=f){var p=Math.cos(d),g=Math.sin(d),_=(p+1)/2,m=(1-g)/2;i.push(a*p,a*g,0),s.push(_,m)}1===l&&(i.push(i[3],i[4],i[5]),s.push(s[2],s[3]));for(var v=i.length/3,y=1;y<v-1;y++)n.push(y+1,0,y);t.ComputeNormals(i,n,o),t._ComputeSides(h,i,n,o,s,r.frontUVs,r.backUVs);var A=new t;return A.indices=n,A.positions=i,A.normals=o,A.uvs=s,A},t.CreatePolygon=function(r,i,n,o,s,a){for(var u=n||new Array(3),l=o,h=[],c=0;c<3;c++)void 0===u[c]&&(u[c]=new e.Vector4(0,0,1,1)),l&&void 0===l[c]&&(l[c]=new e.Color4(1,1,1,1));for(var f=r.getVerticesData(e.VertexBuffer.PositionKind),d=r.getVerticesData(e.VertexBuffer.NormalKind),p=r.getVerticesData(e.VertexBuffer.UVKind),g=r.getIndices(),_=0,m=0,v=0;v<d.length;v+=3)Math.abs(d[v+1])<.001&&(m=1),Math.abs(d[v+1]-1)<.001&&(m=0),Math.abs(d[v+1]+1)<.001&&(m=2),_=v/3,p[2*_]=(1-p[2*_])*u[m].x+p[2*_]*u[m].z,p[2*_+1]=(1-p[2*_+1])*u[m].y+p[2*_+1]*u[m].w,l&&h.push(l[m].r,l[m].g,l[m].b,l[m].a);t._ComputeSides(i,f,g,d,p,s,a);var y=new t;if(y.indices=g,y.positions=f,y.normals=d,y.uvs=p,l){var A=i===e.Mesh.DOUBLESIDE?h.concat(h):h;y.colors=A}return y},t.CreateIcoSphere=function(r){var i,n=r.sideOrientation||e.Mesh.DEFAULTSIDE,o=r.radius||1,s=void 0===r.flat||r.flat,a=r.subdivisions||4,u=r.radiusX||o,l=r.radiusY||o,h=r.radiusZ||o,c=(1+Math.sqrt(5))/2,f=[-1,c,-0,1,c,0,-1,-c,0,1,-c,0,0,-1,-c,0,1,-c,0,-1,c,0,1,c,c,0,1,c,0,-1,-c,0,1,-c,0,-1],d=[0,11,5,0,5,1,0,1,7,0,7,10,12,22,23,1,5,20,5,11,4,23,22,13,22,18,6,7,1,8,14,21,4,14,4,2,16,13,6,15,6,19,3,8,9,4,21,5,13,17,23,6,13,22,19,6,18,9,8,1],p=[0,1,2,3,4,5,6,7,8,9,10,11,0,2,3,3,3,4,7,8,9,9,10,11],g=[5,1,3,1,6,4,0,0,5,3,4,2,2,2,4,0,2,0,1,1,6,0,6,2,0,4,3,3,4,4,3,1,4,2,4,4,0,2,1,1,2,2,3,3,1,3,2,4],_=[0,0,0,0,1,0,0,1,1,0,0,0,1,1,0,0,1,1,1,0],m=[],v=[],y=[],A=[],T=0,E=new Array(3),b=new Array(3);for(i=0;i<3;i++)E[i]=e.Vector3.Zero(),b[i]=e.Vector2.Zero();for(var x=0;x<20;x++){for(i=0;i<3;i++){var M=d[3*x+i];E[i].copyFromFloats(f[3*p[M]],f[3*p[M]+1],f[3*p[M]+2]),E[i].normalize().scaleInPlace(o),b[i].copyFromFloats(g[2*M]*(138/1024)+60/1024+_[x]*(-40/1024),g[2*M+1]*(239/1024)+26/1024+_[x]*(20/1024))}for(var P=function(t,r,i,n){var o=e.Vector3.Lerp(E[0],E[2],r/a),c=e.Vector3.Lerp(E[1],E[2],r/a),f=a===r?E[2]:e.Vector3.Lerp(o,c,t/(a-r));f.normalize();var d;if(s){var p=e.Vector3.Lerp(E[0],E[2],n/a),g=e.Vector3.Lerp(E[1],E[2],n/a);d=e.Vector3.Lerp(p,g,i/(a-n))}else d=new e.Vector3(f.x,f.y,f.z);d.x/=u,d.y/=l,d.z/=h,d.normalize();var _=e.Vector2.Lerp(b[0],b[2],r/a),x=e.Vector2.Lerp(b[1],b[2],r/a),M=a===r?b[2]:e.Vector2.Lerp(_,x,t/(a-r));v.push(f.x*u,f.y*l,f.z*h),y.push(d.x,d.y,d.z),A.push(M.x,M.y),m.push(T),T++},R=0;R<a;R++)for(var C=0;C+R<a;C++)P(C,R,C+1/3,R+1/3),P(C+1,R,C+1/3,R+1/3),P(C,R+1,C+1/3,R+1/3),C+R+1<a&&(P(C+1,R,C+2/3,R+2/3),P(C+1,R+1,C+2/3,R+2/3),P(C,R+1,C+2/3,R+2/3))}t._ComputeSides(n,v,m,y,A,r.frontUVs,r.backUVs);var O=new t;return O.indices=m,O.positions=v,O.normals=y,O.uvs=A,O},t.CreatePolyhedron=function(r){var i=[];i[0]={vertex:[[0,0,1.732051],[1.632993,0,-.5773503],[-.8164966,1.414214,-.5773503],[-.8164966,-1.414214,-.5773503]],face:[[0,1,2],[0,2,3],[0,3,1],[1,3,2]]},i[1]={vertex:[[0,0,1.414214],[1.414214,0,0],[0,1.414214,0],[-1.414214,0,0],[0,-1.414214,0],[0,0,-1.414214]],face:[[0,1,2],[0,2,3],[0,3,4],[0,4,1],[1,4,5],[1,5,2],[2,5,3],[3,5,4]]},i[2]={vertex:[[0,0,1.070466],[.7136442,0,.7978784],[-.3568221,.618034,.7978784],[-.3568221,-.618034,.7978784],[.7978784,.618034,.3568221],[.7978784,-.618034,.3568221],[-.9341724,.381966,.3568221],[.1362939,1,.3568221],[.1362939,-1,.3568221],[-.9341724,-.381966,.3568221],[.9341724,.381966,-.3568221],[.9341724,-.381966,-.3568221],[-.7978784,.618034,-.3568221],[-.1362939,1,-.3568221],[-.1362939,-1,-.3568221],[-.7978784,-.618034,-.3568221],[.3568221,.618034,-.7978784],[.3568221,-.618034,-.7978784],[-.7136442,0,-.7978784],[0,0,-1.070466]],face:[[0,1,4,7,2],[0,2,6,9,3],[0,3,8,5,1],[1,5,11,10,4],[2,7,13,12,6],[3,9,15,14,8],[4,10,16,13,7],[5,8,14,17,11],[6,12,18,15,9],[10,11,17,19,16],[12,13,16,19,18],[14,15,18,19,17]]},i[3]={vertex:[[0,0,1.175571],[1.051462,0,.5257311],[.3249197,1,.5257311],[-.8506508,.618034,.5257311],[-.8506508,-.618034,.5257311],[.3249197,-1,.5257311],[.8506508,.618034,-.5257311],[.8506508,-.618034,-.5257311],[-.3249197,1,-.5257311],[-1.051462,0,-.5257311],[-.3249197,-1,-.5257311],[0,0,-1.175571]],face:[[0,1,2],[0,2,3],[0,3,4],[0,4,5],[0,5,1],[1,5,7],[1,7,6],[1,6,2],[2,6,8],[2,8,3],[3,8,9],[3,9,4],[4,9,10],[4,10,5],[5,10,7],[6,7,11],[6,11,8],[7,10,11],[8,11,9],[9,11,10]]},i[4]={vertex:[[0,0,1.070722],[.7148135,0,.7971752],[-.104682,.7071068,.7971752],[-.6841528,.2071068,.7971752],[-.104682,-.7071068,.7971752],[.6101315,.7071068,.5236279],[1.04156,.2071068,.1367736],[.6101315,-.7071068,.5236279],[-.3574067,1,.1367736],[-.7888348,-.5,.5236279],[-.9368776,.5,.1367736],[-.3574067,-1,.1367736],[.3574067,1,-.1367736],[.9368776,-.5,-.1367736],[.7888348,.5,-.5236279],[.3574067,-1,-.1367736],[-.6101315,.7071068,-.5236279],[-1.04156,-.2071068,-.1367736],[-.6101315,-.7071068,-.5236279],[.104682,.7071068,-.7971752],[.6841528,-.2071068,-.7971752],[.104682,-.7071068,-.7971752],[-.7148135,0,-.7971752],[0,0,-1.070722]],face:[[0,2,3],[1,6,5],[4,9,11],[7,15,13],[8,16,10],[12,14,19],[17,22,18],[20,21,23],[0,1,5,2],[0,3,9,4],[0,4,7,1],[1,7,13,6],[2,5,12,8],[2,8,10,3],[3,10,17,9],[4,11,15,7],[5,6,14,12],[6,13,20,14],[8,12,19,16],[9,17,18,11],[10,16,22,17],[11,18,21,15],[13,15,21,20],[14,20,23,19],[16,19,23,22],[18,22,23,21]]},i[5]={vertex:[[0,0,1.322876],[1.309307,0,.1889822],[-.9819805,.8660254,.1889822],[.1636634,-1.299038,.1889822],[.3273268,.8660254,-.9449112],[-.8183171,-.4330127,-.9449112]],face:[[0,3,1],[2,4,5],[0,1,4,2],[0,2,5,3],[1,3,5,4]]},i[6]={vertex:[[0,0,1.159953],[1.013464,0,.5642542],[-.3501431,.9510565,.5642542],[-.7715208,-.6571639,.5642542],[.6633206,.9510565,-.03144481],[.8682979,-.6571639,-.3996071],[-1.121664,.2938926,-.03144481],[-.2348831,-1.063314,-.3996071],[.5181548,.2938926,-.9953061],[-.5850262,-.112257,-.9953061]],face:[[0,1,4,2],[0,2,6,3],[1,5,8,4],[3,6,9,7],[5,7,9,8],[0,3,7,5,1],[2,4,8,9,6]]},i[7]={vertex:[[0,0,1.118034],[.8944272,0,.6708204],[-.2236068,.8660254,.6708204],[-.7826238,-.4330127,.6708204],[.6708204,.8660254,.2236068],[1.006231,-.4330127,-.2236068],[-1.006231,.4330127,.2236068],[-.6708204,-.8660254,-.2236068],[.7826238,.4330127,-.6708204],[.2236068,-.8660254,-.6708204],[-.8944272,0,-.6708204],[0,0,-1.118034]],face:[[0,1,4,2],[0,2,6,3],[1,5,8,4],[3,6,10,7],[5,9,11,8],[7,10,11,9],[0,3,7,9,5,1],[2,4,8,11,10,6]]},i[8]={vertex:[[-.729665,.670121,.319155],[-.655235,-.29213,-.754096],[-.093922,-.607123,.537818],[.702196,.595691,.485187],[.776626,-.36656,-.588064]],face:[[1,4,2],[0,1,2],[3,0,2],[4,3,2],[4,1,0,3]]},i[9]={vertex:[[-.868849,-.100041,.61257],[-.329458,.976099,.28078],[-.26629,-.013796,-.477654],[-.13392,-1.034115,.229829],[.738834,.707117,-.307018],[.859683,-.535264,-.338508]],face:[[3,0,2],[5,3,2],[4,5,2],[1,4,2],[0,1,2],[0,3,5,4,1]]},i[10]={vertex:[[-.610389,.243975,.531213],[-.187812,-.48795,-.664016],[-.187812,.9759,-.664016],[.187812,-.9759,.664016],[.798201,.243975,.132803]],face:[[1,3,0],[3,4,0],[3,1,4],[0,2,1],[0,4,2],[2,4,1]]},i[11]={vertex:[[-1.028778,.392027,-.048786],[-.640503,-.646161,.621837],[-.125162,-.395663,-.540059],[.004683,.888447,-.651988],[.125161,.395663,.540059],[.632925,-.791376,.433102],[1.031672,.157063,-.354165]],face:[[3,2,0],[2,1,0],[2,5,1],[0,4,3],[0,1,4],[4,1,5],[2,3,6],[3,4,6],[5,2,6],[4,5,6]]},i[12]={vertex:[[-.669867,.334933,-.529576],[-.669867,.334933,.529577],[-.4043,1.212901,0],[-.334933,-.669867,-.529576],[-.334933,-.669867,.529577],[.334933,.669867,-.529576],[.334933,.669867,.529577],[.4043,-1.212901,0],[.669867,-.334933,-.529576],[.669867,-.334933,.529577]],face:[[8,9,7],[6,5,2],[3,8,7],[5,0,2],[4,3,7],[0,1,2],[9,4,7],[1,6,2],[9,8,5,6],[8,3,0,5],[3,4,1,0],[4,9,6,1]]},i[13]={vertex:[[-.931836,.219976,-.264632],[-.636706,.318353,.692816],[-.613483,-.735083,-.264632],[-.326545,.979634,0],[-.318353,-.636706,.692816],[-.159176,.477529,-.856368],[.159176,-.477529,-.856368],[.318353,.636706,.692816],[.326545,-.979634,0],[.613482,.735082,-.264632],[.636706,-.318353,.692816],[.931835,-.219977,-.264632]],face:[[11,10,8],[7,9,3],[6,11,8],[9,5,3],[2,6,8],[5,0,3],[4,2,8],[0,1,3],[10,4,8],[1,7,3],[10,11,9,7],[11,6,5,9],[6,2,0,5],[2,4,1,0],[4,10,7,1]]},i[14]={vertex:[[-.93465,.300459,-.271185],[-.838689,-.260219,-.516017],[-.711319,.717591,.128359],[-.710334,-.156922,.080946],[-.599799,.556003,-.725148],[-.503838,-.004675,-.969981],[-.487004,.26021,.48049],[-.460089,-.750282,-.512622],[-.376468,.973135,-.325605],[-.331735,-.646985,.084342],[-.254001,.831847,.530001],[-.125239,-.494738,-.966586],[.029622,.027949,.730817],[.056536,-.982543,-.262295],[.08085,1.087391,.076037],[.125583,-.532729,.485984],[.262625,.599586,.780328],[.391387,-.726999,-.716259],[.513854,-.868287,.139347],[.597475,.85513,.326364],[.641224,.109523,.783723],[.737185,-.451155,.538891],[.848705,-.612742,-.314616],[.976075,.365067,.32976],[1.072036,-.19561,.084927]],face:[[15,18,21],[12,20,16],[6,10,2],[3,0,1],[9,7,13],[2,8,4,0],[0,4,5,1],[1,5,11,7],[7,11,17,13],[13,17,22,18],[18,22,24,21],[21,24,23,20],[20,23,19,16],[16,19,14,10],[10,14,8,2],[15,9,13,18],[12,15,21,20],[6,12,16,10],[3,6,2,0],[9,3,1,7],[9,15,12,6,3],[22,17,11,5,4,8,14,19,23,24]]};var n,o,s,a,u,l,h=r.type<0||r.type>=i.length?0:r.type||0,c=r.size,f=r.sizeX||c||1,d=r.sizeY||c||1,p=r.sizeZ||c||1,g=r.custom||i[h],_=g.face.length,m=r.faceUV||new Array(_),v=r.faceColors,y=void 0===r.flat||r.flat,A=0===r.sideOrientation?0:r.sideOrientation||e.Mesh.DEFAULTSIDE,T=[],E=[],b=[],x=[],M=[],P=0,R=0,C=[],O=0,S=0;if(y)for(S=0;S<_;S++)v&&void 0===v[S]&&(v[S]=new e.Color4(1,1,1,1)),m&&void 0===m[S]&&(m[S]=new e.Vector4(0,0,1,1));if(y)for(S=0;S<_;S++){var I=g.face[S].length;for(s=2*Math.PI/I,a=.5*Math.tan(s/2),u=.5,O=0;O<I;O++)T.push(g.vertex[g.face[S][O]][0]*f,g.vertex[g.face[S][O]][1]*d,g.vertex[g.face[S][O]][2]*p),C.push(P),P++,n=m[S].x+(m[S].z-m[S].x)*(.5+a),o=m[S].y+(m[S].w-m[S].y)*(u-.5),x.push(n,o),l=a*Math.cos(s)-u*Math.sin(s),u=a*Math.sin(s)+u*Math.cos(s),a=l,v&&M.push(v[S].r,v[S].g,v[S].b,v[S].a);for(O=0;O<I-2;O++)E.push(C[0+R],C[O+2+R],C[O+1+R]);R+=I}else{for(O=0;O<g.vertex.length;O++)T.push(g.vertex[O][0]*f,g.vertex[O][1]*d,g.vertex[O][2]*p),x.push(0,0);for(S=0;S<_;S++)for(O=0;O<g.face[S].length-2;O++)E.push(g.face[S][0],g.face[S][O+2],g.face[S][O+1])}t.ComputeNormals(T,E,b),t._ComputeSides(A,T,E,b,x,r.frontUVs,r.backUVs);var L=new t;return L.positions=T,L.indices=E,L.normals=b,L.uvs=x,v&&y&&(L.colors=M),L},t.CreateTorusKnot=function(r){var i,n,o=[],s=[],a=[],u=[],l=r.radius||2,h=r.tube||.5,c=r.radialSegments||32,f=r.tubularSegments||32,d=r.p||2,p=r.q||3,g=0===r.sideOrientation?0:r.sideOrientation||e.Mesh.DEFAULTSIDE,_=function(t){var r=Math.cos(t),i=Math.sin(t),n=p/d*t,o=Math.cos(n),s=l*(2+o)*.5*r,a=l*(2+o)*i*.5,u=l*Math.sin(n)*.5;return new e.Vector3(s,a,u)};for(i=0;i<=c;i++){var m=i%c,v=m/c*2*d*Math.PI,y=_(v),A=_(v+.01),T=A.subtract(y),E=A.add(y),b=e.Vector3.Cross(T,E);for(E=e.Vector3.Cross(b,T),b.normalize(),E.normalize(),n=0;n<f;n++){var x=n%f,M=x/f*2*Math.PI,P=-h*Math.cos(M),R=h*Math.sin(M);s.push(y.x+P*E.x+R*b.x),s.push(y.y+P*E.y+R*b.y),s.push(y.z+P*E.z+R*b.z),u.push(i/c),u.push(n/f)}}for(i=0;i<c;i++)for(n=0;n<f;n++){var C=(n+1)%f,O=i*f+n,S=(i+1)*f+n,I=(i+1)*f+C,L=i*f+C;o.push(L),o.push(S),o.push(O),o.push(L),o.push(I),o.push(S)}t.ComputeNormals(s,o,a),t._ComputeSides(g,s,o,a,u,r.frontUVs,r.backUVs);var D=new t;return D.indices=o,D.positions=s,D.normals=a,D.uvs=u,D},t.ComputeNormals=function(e,t,r,i){var n=0,o=0,s=0,a=0,u=0,l=0,h=0,c=0,f=0,d=0,p=0,g=0,_=0,m=0,v=0,y=0,A=0,T=0,E=0,b=0,x=!1,M=!1,P=!1,R=1;if(i&&(x=!!i.facetNormals,M=!!i.facetPositions,P=!!i.facetPartitioning,R=!0===i.useRightHandedSystem?-1:1),P){var C=0,O=0,S=0,I=0,L=0,D=0,B=0,N=0,F=0,w=0,V=0,U=0,k=0,z=0,G=0,H=0,Y=i.bbSize.x>i.bbSize.y?i.bbSize.x:i.bbSize.y;Y=Y>i.bbSize.z?Y:i.bbSize.z;var W=i.subDiv.X*i.ratio/i.bbSize.x,X=i.subDiv.Y*i.ratio/i.bbSize.y,j=i.subDiv.Z*i.ratio/i.bbSize.z,K=i.subDiv.max*i.subDiv.max;i.facetPartitioning.length=0}for(n=0;n<e.length;n++)r[n]=0;var Q=t.length/3;for(n=0;n<Q;n++)g=3*t[3*n],_=g+1,m=g+2,v=3*t[3*n+1],y=v+1,A=v+2,T=3*t[3*n+2],E=T+1,b=T+2,o=e[g]-e[v],s=e[_]-e[y],a=e[m]-e[A],u=e[T]-e[v],l=e[E]-e[y],h=e[b]-e[A],c=R*(s*h-a*l),f=R*(a*u-o*h),d=R*(o*l-s*u),p=Math.sqrt(c*c+f*f+d*d),p=0===p?1:p,c/=p,f/=p,d/=p,x&&(i.facetNormals[n].x=c,i.facetNormals[n].y=f,i.facetNormals[n].z=d),M&&(i.facetPositions[n].x=(e[g]+e[v]+e[T])/3,i.facetPositions[n].y=(e[_]+e[y]+e[E])/3,i.facetPositions[n].z=(e[m]+e[A]+e[b])/3),P&&(C=Math.floor((i.facetPositions[n].x-i.bInfo.minimum.x*i.ratio)*W),O=Math.floor((i.facetPositions[n].y-i.bInfo.minimum.y*i.ratio)*X),S=Math.floor((i.facetPositions[n].z-i.bInfo.minimum.z*i.ratio)*j),I=Math.floor((e[g]-i.bInfo.minimum.x*i.ratio)*W),L=Math.floor((e[_]-i.bInfo.minimum.y*i.ratio)*X),D=Math.floor((e[m]-i.bInfo.minimum.z*i.ratio)*j),B=Math.floor((e[v]-i.bInfo.minimum.x*i.ratio)*W),N=Math.floor((e[y]-i.bInfo.minimum.y*i.ratio)*X),F=Math.floor((e[A]-i.bInfo.minimum.z*i.ratio)*j),w=Math.floor((e[T]-i.bInfo.minimum.x*i.ratio)*W),V=Math.floor((e[E]-i.bInfo.minimum.y*i.ratio)*X),U=Math.floor((e[b]-i.bInfo.minimum.z*i.ratio)*j),z=I+i.subDiv.max*L+K*D,G=B+i.subDiv.max*N+K*F,H=w+i.subDiv.max*V+K*U,k=C+i.subDiv.max*O+K*S,
- i.facetPartitioning[k]=i.facetPartitioning[k]?i.facetPartitioning[k]:new Array,i.facetPartitioning[z]=i.facetPartitioning[z]?i.facetPartitioning[z]:new Array,i.facetPartitioning[G]=i.facetPartitioning[G]?i.facetPartitioning[G]:new Array,i.facetPartitioning[H]=i.facetPartitioning[H]?i.facetPartitioning[H]:new Array,i.facetPartitioning[z].push(n),G!=z&&i.facetPartitioning[G].push(n),H!=G&&H!=z&&i.facetPartitioning[H].push(n),k!=z&&k!=G&&k!=H&&i.facetPartitioning[k].push(n)),r[g]+=c,r[_]+=f,r[m]+=d,r[v]+=c,r[y]+=f,r[A]+=d,r[T]+=c,r[E]+=f,r[b]+=d;for(n=0;n<r.length/3;n++)c=r[3*n],f=r[3*n+1],d=r[3*n+2],p=Math.sqrt(c*c+f*f+d*d),p=0===p?1:p,c/=p,f/=p,d/=p,r[3*n]=c,r[3*n+1]=f,r[3*n+2]=d},t._ComputeSides=function(t,r,i,n,o,s,a){var u,l,h=i.length,c=n.length;switch(t=t||e.Mesh.DEFAULTSIDE){case e.Mesh.FRONTSIDE:break;case e.Mesh.BACKSIDE:var f;for(u=0;u<h;u+=3)f=i[u],i[u]=i[u+2],i[u+2]=f;for(l=0;l<c;l++)n[l]=-n[l];break;case e.Mesh.DOUBLESIDE:for(var d=r.length,p=d/3,g=0;g<d;g++)r[d+g]=r[g];for(u=0;u<h;u+=3)i[u+h]=i[u+2]+p,i[u+1+h]=i[u+1]+p,i[u+2+h]=i[u]+p;for(l=0;l<c;l++)n[c+l]=-n[l];var _=o.length,m=0;for(m=0;m<_;m++)o[m+_]=o[m];var s=s||new e.Vector4(0,0,1,1),a=a||new e.Vector4(0,0,1,1);for(m=0,u=0;u<_/2;u++)o[m]=s.x+(s.z-s.x)*o[m],o[m+1]=s.y+(s.w-s.y)*o[m+1],o[m+_]=a.x+(a.z-a.x)*o[m+_],o[m+_+1]=a.y+(a.w-a.y)*o[m+_+1],m+=2}},t.ImportVertexData=function(r,i){var n=new t,o=r.positions;o&&n.set(o,e.VertexBuffer.PositionKind);var s=r.normals;s&&n.set(s,e.VertexBuffer.NormalKind);var a=r.tangents;a&&n.set(a,e.VertexBuffer.TangentKind);var u=r.uvs;u&&n.set(u,e.VertexBuffer.UVKind);var l=r.uv2s;l&&n.set(l,e.VertexBuffer.UV2Kind);var h=r.uv3s;h&&n.set(h,e.VertexBuffer.UV3Kind);var c=r.uv4s;c&&n.set(c,e.VertexBuffer.UV4Kind);var f=r.uv5s;f&&n.set(f,e.VertexBuffer.UV5Kind);var d=r.uv6s;d&&n.set(d,e.VertexBuffer.UV6Kind);var p=r.colors;p&&n.set(e.Color4.CheckColors4(p,o.length/3),e.VertexBuffer.ColorKind);var g=r.matricesIndices;g&&n.set(g,e.VertexBuffer.MatricesIndicesKind);var _=r.matricesWeights;_&&n.set(_,e.VertexBuffer.MatricesWeightsKind);var m=r.indices;m&&(n.indices=m),i.setAllVerticesData(n,r.updatable)},t})();e.VertexData=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(t,r,i,n,o){this.delayLoadState=e.Engine.DELAYLOADSTATE_NONE,this._totalVertices=0,this._isDisposed=!1,this.id=t,this._engine=r.getEngine(),this._meshes=[],this._scene=r,this._vertexBuffers={},this._indices=[],this._updatable=n,i?this.setAllVerticesData(i,n):(this._totalVertices=0,this._indices=[]),this._engine.getCaps().vertexArrayObject&&(this._vertexArrayObjects={}),o&&("LinesMesh"===o.getClassName()&&(this.boundingBias=new e.Vector2(0,o.intersectionThreshold),this.updateExtend()),this.applyToMesh(o),o.computeWorldMatrix(!0))}return Object.defineProperty(t.prototype,"boundingBias",{get:function(){return this._boundingBias},set:function(e){this._boundingBias&&this._boundingBias.equals(e)||(this._boundingBias=e.clone(),this.updateBoundingInfo(!0,null))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"extend",{get:function(){return this._extend},enumerable:!0,configurable:!0}),t.prototype.getScene=function(){return this._scene},t.prototype.getEngine=function(){return this._engine},t.prototype.isReady=function(){return this.delayLoadState===e.Engine.DELAYLOADSTATE_LOADED||this.delayLoadState===e.Engine.DELAYLOADSTATE_NONE},Object.defineProperty(t.prototype,"doNotSerialize",{get:function(){for(var e=0;e<this._meshes.length;e++)if(!this._meshes[e].doNotSerialize)return!1;return!0},enumerable:!0,configurable:!0}),t.prototype.setAllVerticesData=function(e,t){e.applyToGeometry(this,t),this.notifyUpdate()},t.prototype.setVerticesData=function(t,r,i,n){var o=new e.VertexBuffer(this._engine,r,t,i,0===this._meshes.length,n);this.setVerticesBuffer(o)},t.prototype.removeVerticesData=function(e){this._vertexBuffers[e]&&(this._vertexBuffers[e].dispose(),delete this._vertexBuffers[e])},t.prototype.setVerticesBuffer=function(t){var r=t.getKind();if(this._vertexBuffers[r]&&this._vertexBuffers[r].dispose(),this._vertexBuffers[r]=t,r===e.VertexBuffer.PositionKind){var i=t.getData(),n=t.getStrideSize();this._totalVertices=i.length/n,this.updateExtend(i,n),this._resetPointsArrayCache();for(var o=this._meshes,s=o.length,a=0;a<s;a++){var u=o[a];u._boundingInfo=new e.BoundingInfo(this._extend.minimum,this._extend.maximum),u._createGlobalSubMesh(!1),u.computeWorldMatrix(!0)}}this.notifyUpdate(r),this._vertexArrayObjects&&(this._disposeVertexArrayObjects(),this._vertexArrayObjects={})},t.prototype.updateVerticesDataDirectly=function(e,t,r){var i=this.getVertexBuffer(e);i&&(i.updateDirectly(t,r),this.notifyUpdate(e))},t.prototype.updateVerticesData=function(t,r,i){var n=this.getVertexBuffer(t);if(n){if(n.update(r),t===e.VertexBuffer.PositionKind){var o=n.getStrideSize();this._totalVertices=r.length/o,this.updateBoundingInfo(i,r)}this.notifyUpdate(t)}},t.prototype.updateBoundingInfo=function(t,r){t&&this.updateExtend(r);var i=this._meshes,n=i.length;this._resetPointsArrayCache();for(var o=0;o<n;o++){var s=i[o];if(t){s._boundingInfo=new e.BoundingInfo(this._extend.minimum,this._extend.maximum);for(var a=0;a<s.subMeshes.length;a++){s.subMeshes[a].refreshBoundingInfo()}}}},t.prototype._bind=function(e,t){if(void 0===t&&(t=void 0),void 0===t&&(t=this._indexBuffer),t!=this._indexBuffer||!this._vertexArrayObjects)return void this._engine.bindBuffers(this.getVertexBuffers(),t,e);this._vertexArrayObjects[e.key]||(this._vertexArrayObjects[e.key]=this._engine.recordVertexArrayObject(this.getVertexBuffers(),t,e)),this._engine.bindVertexArrayObject(this._vertexArrayObjects[e.key],t)},t.prototype.getTotalVertices=function(){return this.isReady()?this._totalVertices:0},t.prototype.getVerticesData=function(e,t,r){var i=this.getVertexBuffer(e);if(!i)return null;var n=i.getData();if(r||t&&1!==this._meshes.length){for(var o=n.length,s=[],a=0;a<o;a++)s.push(n[a]);return s}return n},t.prototype.getVertexBuffer=function(e){return this.isReady()?this._vertexBuffers[e]:null},t.prototype.getVertexBuffers=function(){return this.isReady()?this._vertexBuffers:null},t.prototype.isVerticesDataPresent=function(e){return this._vertexBuffers?void 0!==this._vertexBuffers[e]:!!this._delayInfo&&-1!==this._delayInfo.indexOf(e)},t.prototype.getVerticesDataKinds=function(){var e,t=[];if(!this._vertexBuffers&&this._delayInfo)for(e in this._delayInfo)t.push(e);else for(e in this._vertexBuffers)t.push(e);return t},t.prototype.setIndices=function(e,t){this._indexBuffer&&this._engine._releaseBuffer(this._indexBuffer),this._disposeVertexArrayObjects(),this._indices=e,0!==this._meshes.length&&this._indices&&(this._indexBuffer=this._engine.createIndexBuffer(this._indices)),void 0!==t&&(this._totalVertices=t);for(var r=this._meshes,i=r.length,n=0;n<i;n++)r[n]._createGlobalSubMesh(!0);this.notifyUpdate()},t.prototype.getTotalIndices=function(){return this.isReady()?this._indices.length:0},t.prototype.getIndices=function(e){if(!this.isReady())return null;var t=this._indices;if(e&&1!==this._meshes.length){for(var r=t.length,i=[],n=0;n<r;n++)i.push(t[n]);return i}return t},t.prototype.getIndexBuffer=function(){return this.isReady()?this._indexBuffer:null},t.prototype._releaseVertexArrayObject=function(e){e&&this._vertexArrayObjects&&this._vertexArrayObjects[e.key]&&(this._engine.releaseVertexArrayObject(this._vertexArrayObjects[e.key]),delete this._vertexArrayObjects[e.key])},t.prototype.releaseForMesh=function(e,t){var r=this._meshes,i=r.indexOf(e);-1!==i&&(r.splice(i,1),e._geometry=null,0===r.length&&t&&this.dispose())},t.prototype.applyToMesh=function(e){if(e._geometry!==this){var t=e._geometry;t&&t.releaseForMesh(e);var r=this._meshes;e._geometry=this,this._scene.pushGeometry(this),r.push(e),this.isReady()?this._applyToMesh(e):e._boundingInfo=this._boundingInfo}},t.prototype.updateExtend=function(t,r){void 0===t&&(t=null),t||(t=this._vertexBuffers[e.VertexBuffer.PositionKind].getData()),this._extend=e.Tools.ExtractMinAndMax(t,0,this._totalVertices,this.boundingBias,r)},t.prototype._applyToMesh=function(t){var r=this._meshes.length;for(var i in this._vertexBuffers){1===r&&this._vertexBuffers[i].create();var n=this._vertexBuffers[i].getBuffer();n&&(n.references=r),i===e.VertexBuffer.PositionKind&&(this._extend||this.updateExtend(this._vertexBuffers[i].getData()),t._boundingInfo=new e.BoundingInfo(this._extend.minimum,this._extend.maximum),t._createGlobalSubMesh(!1),t._updateBoundingInfo())}1===r&&this._indices&&this._indices.length>0&&(this._indexBuffer=this._engine.createIndexBuffer(this._indices)),this._indexBuffer&&(this._indexBuffer.references=r)},t.prototype.notifyUpdate=function(e){this.onGeometryUpdated&&this.onGeometryUpdated(this,e);for(var t=0,r=this._meshes;t<r.length;t++){r[t]._markSubMeshesAsAttributesDirty()}},t.prototype.load=function(t,r){if(this.delayLoadState!==e.Engine.DELAYLOADSTATE_LOADING){if(this.isReady())return void(r&&r());this.delayLoadState=e.Engine.DELAYLOADSTATE_LOADING,this._queueLoad(t,r)}},t.prototype._queueLoad=function(t,r){var i=this;t._addPendingData(this),e.Tools.LoadFile(this.delayLoadingFile,(function(n){i._delayLoadingFunction(JSON.parse(n),i),i.delayLoadState=e.Engine.DELAYLOADSTATE_LOADED,i._delayInfo=[],t._removePendingData(i);for(var o=i._meshes,s=o.length,a=0;a<s;a++)i._applyToMesh(o[a]);r&&r()}),(function(){}),t.database)},t.prototype.toLeftHanded=function(){var t=this.getIndices(!1);if(null!=t&&t.length>0){for(var r=0;r<t.length;r+=3){var i=t[r+0];t[r+0]=t[r+2],t[r+2]=i}this.setIndices(t)}var n=this.getVerticesData(e.VertexBuffer.PositionKind,!1);if(null!=n&&n.length>0){for(var r=0;r<n.length;r+=3)n[r+2]=-n[r+2];this.setVerticesData(e.VertexBuffer.PositionKind,n,!1)}var o=this.getVerticesData(e.VertexBuffer.NormalKind,!1);if(null!=o&&o.length>0){for(var r=0;r<o.length;r+=3)o[r+2]=-o[r+2];this.setVerticesData(e.VertexBuffer.NormalKind,o,!1)}},t.prototype._resetPointsArrayCache=function(){this._positions=null},t.prototype._generatePointsArray=function(){if(this._positions)return!0;this._positions=[];var t=this.getVerticesData(e.VertexBuffer.PositionKind);if(!t)return!1;for(var r=0;r<t.length;r+=3)this._positions.push(e.Vector3.FromArray(t,r));return!0},t.prototype.isDisposed=function(){return this._isDisposed},t.prototype._disposeVertexArrayObjects=function(){if(this._vertexArrayObjects){for(var e in this._vertexArrayObjects)this._engine.releaseVertexArrayObject(this._vertexArrayObjects[e]);this._vertexArrayObjects={}}},t.prototype.dispose=function(){var t,r=this._meshes,i=r.length;for(t=0;t<i;t++)this.releaseForMesh(r[t]);this._meshes=[],this._disposeVertexArrayObjects();for(var n in this._vertexBuffers)this._vertexBuffers[n].dispose();this._vertexBuffers={},this._totalVertices=0,this._indexBuffer&&this._engine._releaseBuffer(this._indexBuffer),this._indexBuffer=null,this._indices=[],this.delayLoadState=e.Engine.DELAYLOADSTATE_NONE,this.delayLoadingFile=null,this._delayLoadingFunction=null,this._delayInfo=[],this._boundingInfo=null,this._scene.removeGeometry(this),this._isDisposed=!0},t.prototype.copy=function(r){var i=new e.VertexData;i.indices=[];for(var n=this.getIndices(),o=0;o<n.length;o++)i.indices.push(n[o]);var s,a=!1,u=!1;for(s in this._vertexBuffers){var l=this.getVerticesData(s);l instanceof Float32Array?i.set(new Float32Array(l),s):i.set(l.slice(0),s),u||(a=this.getVertexBuffer(s).isUpdatable(),u=!a)}var h=new t(r,this._scene,i,a,null);h.delayLoadState=this.delayLoadState,h.delayLoadingFile=this.delayLoadingFile,h._delayLoadingFunction=this._delayLoadingFunction;for(s in this._delayInfo)h._delayInfo=h._delayInfo||[],h._delayInfo.push(s);return h._boundingInfo=new e.BoundingInfo(this._extend.minimum,this._extend.maximum),h},t.prototype.serialize=function(){var t={};return t.id=this.id,t.updatable=this._updatable,e.Tags&&e.Tags.HasTags(this)&&(t.tags=e.Tags.GetTags(this)),t},t.prototype.toNumberArray=function(e){return Array.isArray(e)?e:Array.prototype.slice.call(e)},t.prototype.serializeVerticeData=function(){var t=this.serialize();return this.isVerticesDataPresent(e.VertexBuffer.PositionKind)&&(t.positions=this.toNumberArray(this.getVerticesData(e.VertexBuffer.PositionKind)),this.getVertexBuffer(e.VertexBuffer.PositionKind).isUpdatable&&(t.positions._updatable=!0)),this.isVerticesDataPresent(e.VertexBuffer.NormalKind)&&(t.normals=this.toNumberArray(this.getVerticesData(e.VertexBuffer.NormalKind)),this.getVertexBuffer(e.VertexBuffer.NormalKind).isUpdatable&&(t.normals._updatable=!0)),this.isVerticesDataPresent(e.VertexBuffer.UVKind)&&(t.uvs=this.toNumberArray(this.getVerticesData(e.VertexBuffer.UVKind)),this.getVertexBuffer(e.VertexBuffer.UVKind).isUpdatable&&(t.uvs._updatable=!0)),this.isVerticesDataPresent(e.VertexBuffer.UV2Kind)&&(t.uv2s=this.toNumberArray(this.getVerticesData(e.VertexBuffer.UV2Kind)),this.getVertexBuffer(e.VertexBuffer.UV2Kind).isUpdatable&&(t.uv2s._updatable=!0)),this.isVerticesDataPresent(e.VertexBuffer.UV3Kind)&&(t.uv3s=this.toNumberArray(this.getVerticesData(e.VertexBuffer.UV3Kind)),this.getVertexBuffer(e.VertexBuffer.UV3Kind).isUpdatable&&(t.uv3s._updatable=!0)),this.isVerticesDataPresent(e.VertexBuffer.UV4Kind)&&(t.uv4s=this.toNumberArray(this.getVerticesData(e.VertexBuffer.UV4Kind)),this.getVertexBuffer(e.VertexBuffer.UV4Kind).isUpdatable&&(t.uv4s._updatable=!0)),this.isVerticesDataPresent(e.VertexBuffer.UV5Kind)&&(t.uv5s=this.toNumberArray(this.getVerticesData(e.VertexBuffer.UV5Kind)),this.getVertexBuffer(e.VertexBuffer.UV5Kind).isUpdatable&&(t.uv5s._updatable=!0)),this.isVerticesDataPresent(e.VertexBuffer.UV6Kind)&&(t.uv6s=this.toNumberArray(this.getVerticesData(e.VertexBuffer.UV6Kind)),this.getVertexBuffer(e.VertexBuffer.UV6Kind).isUpdatable&&(t.uv6s._updatable=!0)),this.isVerticesDataPresent(e.VertexBuffer.ColorKind)&&(t.colors=this.toNumberArray(this.getVerticesData(e.VertexBuffer.ColorKind)),this.getVertexBuffer(e.VertexBuffer.ColorKind).isUpdatable&&(t.colors._updatable=!0)),this.isVerticesDataPresent(e.VertexBuffer.MatricesIndicesKind)&&(t.matricesIndices=this.toNumberArray(this.getVerticesData(e.VertexBuffer.MatricesIndicesKind)),t.matricesIndices._isExpanded=!0,this.getVertexBuffer(e.VertexBuffer.MatricesIndicesKind).isUpdatable&&(t.matricesIndices._updatable=!0)),this.isVerticesDataPresent(e.VertexBuffer.MatricesWeightsKind)&&(t.matricesWeights=this.toNumberArray(this.getVerticesData(e.VertexBuffer.MatricesWeightsKind)),this.getVertexBuffer(e.VertexBuffer.MatricesWeightsKind).isUpdatable&&(t.matricesWeights._updatable=!0)),t.indices=this.toNumberArray(this.getIndices()),t},t.ExtractFromMesh=function(e,t){var r=e._geometry;return r?r.copy(t):null},t.RandomId=function(){return e.Tools.RandomId()},t.ImportGeometry=function(r,i){var n=i.getScene(),o=r.geometryId;if(o){var s=n.getGeometryByID(o);s&&s.applyToMesh(i)}else if(r instanceof ArrayBuffer){var a=i._binaryInfo;if(a.positionsAttrDesc&&a.positionsAttrDesc.count>0){var u=new Float32Array(r,a.positionsAttrDesc.offset,a.positionsAttrDesc.count);i.setVerticesData(e.VertexBuffer.PositionKind,u,!1)}if(a.normalsAttrDesc&&a.normalsAttrDesc.count>0){var l=new Float32Array(r,a.normalsAttrDesc.offset,a.normalsAttrDesc.count);i.setVerticesData(e.VertexBuffer.NormalKind,l,!1)}if(a.uvsAttrDesc&&a.uvsAttrDesc.count>0){var h=new Float32Array(r,a.uvsAttrDesc.offset,a.uvsAttrDesc.count);i.setVerticesData(e.VertexBuffer.UVKind,h,!1)}if(a.uvs2AttrDesc&&a.uvs2AttrDesc.count>0){var c=new Float32Array(r,a.uvs2AttrDesc.offset,a.uvs2AttrDesc.count);i.setVerticesData(e.VertexBuffer.UV2Kind,c,!1)}if(a.uvs3AttrDesc&&a.uvs3AttrDesc.count>0){var f=new Float32Array(r,a.uvs3AttrDesc.offset,a.uvs3AttrDesc.count);i.setVerticesData(e.VertexBuffer.UV3Kind,f,!1)}if(a.uvs4AttrDesc&&a.uvs4AttrDesc.count>0){var d=new Float32Array(r,a.uvs4AttrDesc.offset,a.uvs4AttrDesc.count);i.setVerticesData(e.VertexBuffer.UV4Kind,d,!1)}if(a.uvs5AttrDesc&&a.uvs5AttrDesc.count>0){var p=new Float32Array(r,a.uvs5AttrDesc.offset,a.uvs5AttrDesc.count);i.setVerticesData(e.VertexBuffer.UV5Kind,p,!1)}if(a.uvs6AttrDesc&&a.uvs6AttrDesc.count>0){var g=new Float32Array(r,a.uvs6AttrDesc.offset,a.uvs6AttrDesc.count);i.setVerticesData(e.VertexBuffer.UV6Kind,g,!1)}if(a.colorsAttrDesc&&a.colorsAttrDesc.count>0){var _=new Float32Array(r,a.colorsAttrDesc.offset,a.colorsAttrDesc.count);i.setVerticesData(e.VertexBuffer.ColorKind,_,!1,a.colorsAttrDesc.stride)}if(a.matricesIndicesAttrDesc&&a.matricesIndicesAttrDesc.count>0){var m=new Int32Array(r,a.matricesIndicesAttrDesc.offset,a.matricesIndicesAttrDesc.count);i.setVerticesData(e.VertexBuffer.MatricesIndicesKind,m,!1)}if(a.matricesWeightsAttrDesc&&a.matricesWeightsAttrDesc.count>0){var v=new Float32Array(r,a.matricesWeightsAttrDesc.offset,a.matricesWeightsAttrDesc.count);i.setVerticesData(e.VertexBuffer.MatricesWeightsKind,v,!1)}if(a.indicesAttrDesc&&a.indicesAttrDesc.count>0){var y=new Int32Array(r,a.indicesAttrDesc.offset,a.indicesAttrDesc.count);i.setIndices(y)}if(a.subMeshesAttrDesc&&a.subMeshesAttrDesc.count>0){var A=new Int32Array(r,a.subMeshesAttrDesc.offset,5*a.subMeshesAttrDesc.count);i.subMeshes=[];for(var T=0;T<a.subMeshesAttrDesc.count;T++){var E=A[5*T+0],b=A[5*T+1],x=A[5*T+2],M=A[5*T+3],P=A[5*T+4];new e.SubMesh(E,b,x,M,P,i)}}}else if(r.positions&&r.normals&&r.indices){if(i.setVerticesData(e.VertexBuffer.PositionKind,r.positions,r.positions._updatable),i.setVerticesData(e.VertexBuffer.NormalKind,r.normals,r.normals._updatable),r.uvs&&i.setVerticesData(e.VertexBuffer.UVKind,r.uvs,r.uvs._updatable),r.uvs2&&i.setVerticesData(e.VertexBuffer.UV2Kind,r.uvs2,r.uvs2._updatable),r.uvs3&&i.setVerticesData(e.VertexBuffer.UV3Kind,r.uvs3,r.uvs3._updatable),r.uvs4&&i.setVerticesData(e.VertexBuffer.UV4Kind,r.uvs4,r.uvs4._updatable),r.uvs5&&i.setVerticesData(e.VertexBuffer.UV5Kind,r.uvs5,r.uvs5._updatable),r.uvs6&&i.setVerticesData(e.VertexBuffer.UV6Kind,r.uvs6,r.uvs6._updatable),r.colors&&i.setVerticesData(e.VertexBuffer.ColorKind,e.Color4.CheckColors4(r.colors,r.positions.length/3),r.colors._updatable),r.matricesIndices)if(r.matricesIndices._isExpanded)delete r.matricesIndices._isExpanded,i.setVerticesData(e.VertexBuffer.MatricesIndicesKind,r.matricesIndices,r.matricesIndices._updatable);else{for(var R=[],T=0;T<r.matricesIndices.length;T++){var C=r.matricesIndices[T];R.push(255&C),R.push((65280&C)>>8),R.push((16711680&C)>>16),R.push(C>>24)}i.setVerticesData(e.VertexBuffer.MatricesIndicesKind,R,r.matricesIndices._updatable)}if(r.matricesIndicesExtra)if(r.matricesIndicesExtra._isExpanded)delete r.matricesIndices._isExpanded,i.setVerticesData(e.VertexBuffer.MatricesIndicesExtraKind,r.matricesIndicesExtra,r.matricesIndicesExtra._updatable);else{for(var R=[],T=0;T<r.matricesIndicesExtra.length;T++){var C=r.matricesIndicesExtra[T];R.push(255&C),R.push((65280&C)>>8),R.push((16711680&C)>>16),R.push(C>>24)}i.setVerticesData(e.VertexBuffer.MatricesIndicesExtraKind,R,r.matricesIndicesExtra._updatable)}r.matricesWeights&&(t._CleanMatricesWeights(r.matricesWeights,r.numBoneInfluencers),i.setVerticesData(e.VertexBuffer.MatricesWeightsKind,r.matricesWeights,r.matricesWeights._updatable)),r.matricesWeightsExtra&&(t._CleanMatricesWeights(r.matricesWeightsExtra,r.numBoneInfluencers),i.setVerticesData(e.VertexBuffer.MatricesWeightsExtraKind,r.matricesWeightsExtra,r.matricesWeights._updatable)),i.setIndices(r.indices)}if(r.subMeshes){i.subMeshes=[];for(var O=0;O<r.subMeshes.length;O++){var S=r.subMeshes[O];new e.SubMesh(S.materialIndex,S.verticesStart,S.verticesCount,S.indexStart,S.indexCount,i)}}i._shouldGenerateFlatShading&&(i.convertToFlatShadedMesh(),delete i._shouldGenerateFlatShading),i.computeWorldMatrix(!0),n._selectionOctree&&n._selectionOctree.addMesh(i)},t._CleanMatricesWeights=function(t,r){if(e.SceneLoader.CleanBoneMatrixWeights)for(var i=t.length,n=0;n<i;n+=r){for(var o=0,s=n,a=0,u=0;u<r-1;u++)o+=t[n+u],t[n+u]>a&&(a=t[n+u],s=n+u);t[s]+=Math.max(0,1-o)}},t.Parse=function(r,i,n){if(i.getGeometryByID(r.id))return null;var o=new t(r.id,i,null,r.updatable);return e.Tags&&e.Tags.AddTagsTo(o,r.tags),r.delayLoadingFile?(o.delayLoadState=e.Engine.DELAYLOADSTATE_NOTLOADED,o.delayLoadingFile=n+r.delayLoadingFile,o._boundingInfo=new e.BoundingInfo(e.Vector3.FromArray(r.boundingBoxMinimum),e.Vector3.FromArray(r.boundingBoxMaximum)),o._delayInfo=[],r.hasUVs&&o._delayInfo.push(e.VertexBuffer.UVKind),r.hasUVs2&&o._delayInfo.push(e.VertexBuffer.UV2Kind),r.hasUVs3&&o._delayInfo.push(e.VertexBuffer.UV3Kind),r.hasUVs4&&o._delayInfo.push(e.VertexBuffer.UV4Kind),r.hasUVs5&&o._delayInfo.push(e.VertexBuffer.UV5Kind),r.hasUVs6&&o._delayInfo.push(e.VertexBuffer.UV6Kind),r.hasColors&&o._delayInfo.push(e.VertexBuffer.ColorKind),r.hasMatricesIndices&&o._delayInfo.push(e.VertexBuffer.MatricesIndicesKind),r.hasMatricesWeights&&o._delayInfo.push(e.VertexBuffer.MatricesWeightsKind),o._delayLoadingFunction=e.VertexData.ImportVertexData):e.VertexData.ImportVertexData(r,o),i.pushGeometry(o,!0),o},t})();e.Geometry=t,(function(t){!(function(r){var i=(function(e){function t(t,r,i,n){var o=e.call(this,t,r,null,!1,n)||this;return o._canBeRegenerated=i,o._beingRegenerated=!0,o.regenerate(),o._beingRegenerated=!1,o}return __extends(t,e),t.prototype.canBeRegenerated=function(){return this._canBeRegenerated},t.prototype.regenerate=function(){this._canBeRegenerated&&(this._beingRegenerated=!0,this.setAllVerticesData(this._regenerateVertexData(),!1),this._beingRegenerated=!1)},t.prototype.asNewGeometry=function(t){return e.prototype.copy.call(this,t)},t.prototype.setAllVerticesData=function(t,r){this._beingRegenerated&&e.prototype.setAllVerticesData.call(this,t,!1)},t.prototype.setVerticesData=function(t,r,i){this._beingRegenerated&&e.prototype.setVerticesData.call(this,t,r,!1)},t.prototype._regenerateVertexData=function(){throw new Error("Abstract method")},t.prototype.copy=function(e){throw new Error("Must be overriden in sub-classes.")},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return t.canBeRegenerated=this.canBeRegenerated(),t},t})(t);r._Primitive=i;var n=(function(t){function r(r,i,n,o,s,a,u,l,h){void 0===h&&(h=e.Mesh.DEFAULTSIDE);var c=t.call(this,r,i,u,l)||this;return c.pathArray=n,c.closeArray=o,c.closePath=s,c.offset=a,c.side=h,c}return __extends(r,t),r.prototype._regenerateVertexData=function(){return e.VertexData.CreateRibbon({pathArray:this.pathArray,closeArray:this.closeArray,closePath:this.closePath,offset:this.offset,sideOrientation:this.side})},r.prototype.copy=function(e){return new r(e,this.getScene(),this.pathArray,this.closeArray,this.closePath,this.offset,this.canBeRegenerated(),null,this.side)},r})(i);r.Ribbon=n;var o=(function(r){function i(t,i,n,o,s,a){void 0===a&&(a=e.Mesh.DEFAULTSIDE);var u=r.call(this,t,i,o,s)||this;return u.size=n,u.side=a,u}return __extends(i,r),i.prototype._regenerateVertexData=function(){return e.VertexData.CreateBox({size:this.size,sideOrientation:this.side})},i.prototype.copy=function(e){return new i(e,this.getScene(),this.size,this.canBeRegenerated(),null,this.side)},i.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.size=this.size,e},i.Parse=function(r,i){if(i.getGeometryByID(r.id))return null;var n=new t.Primitives.Box(r.id,i,r.size,r.canBeRegenerated,null);return e.Tags&&e.Tags.AddTagsTo(n,r.tags),i.pushGeometry(n,!0),n},i})(i);r.Box=o;var s=(function(r){function i(t,i,n,o,s,a,u){void 0===u&&(u=e.Mesh.DEFAULTSIDE);var l=r.call(this,t,i,s,a)||this;return l.segments=n,l.diameter=o,l.side=u,l}return __extends(i,r),i.prototype._regenerateVertexData=function(){return e.VertexData.CreateSphere({segments:this.segments,diameter:this.diameter,sideOrientation:this.side})},i.prototype.copy=function(e){return new i(e,this.getScene(),this.segments,this.diameter,this.canBeRegenerated(),null,this.side)},i.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.segments=this.segments,e.diameter=this.diameter,e},i.Parse=function(r,i){if(i.getGeometryByID(r.id))return null;var n=new t.Primitives.Sphere(r.id,i,r.segments,r.diameter,r.canBeRegenerated,null);return e.Tags&&e.Tags.AddTagsTo(n,r.tags),i.pushGeometry(n,!0),n},i})(i);r.Sphere=s;var a=(function(t){function r(r,i,n,o,s,a,u){void 0===u&&(u=e.Mesh.DEFAULTSIDE);var l=t.call(this,r,i,s,a)||this;return l.radius=n,l.tessellation=o,l.side=u,l}return __extends(r,t),r.prototype._regenerateVertexData=function(){return e.VertexData.CreateDisc({radius:this.radius,tessellation:this.tessellation,sideOrientation:this.side})},r.prototype.copy=function(e){return new r(e,this.getScene(),this.radius,this.tessellation,this.canBeRegenerated(),null,this.side)},r})(i);r.Disc=a;var u=(function(r){function i(t,i,n,o,s,a,u,l,h,c){void 0===u&&(u=1),void 0===c&&(c=e.Mesh.DEFAULTSIDE);var f=r.call(this,t,i,l,h)||this;return f.height=n,f.diameterTop=o,f.diameterBottom=s,f.tessellation=a,f.subdivisions=u,f.side=c,f}return __extends(i,r),i.prototype._regenerateVertexData=function(){return e.VertexData.CreateCylinder({height:this.height,diameterTop:this.diameterTop,diameterBottom:this.diameterBottom,tessellation:this.tessellation,subdivisions:this.subdivisions,sideOrientation:this.side})},i.prototype.copy=function(e){return new i(e,this.getScene(),this.height,this.diameterTop,this.diameterBottom,this.tessellation,this.subdivisions,this.canBeRegenerated(),null,this.side)},i.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.height=this.height,e.diameterTop=this.diameterTop,e.diameterBottom=this.diameterBottom,e.tessellation=this.tessellation,e},i.Parse=function(r,i){if(i.getGeometryByID(r.id))return null;var n=new t.Primitives.Cylinder(r.id,i,r.height,r.diameterTop,r.diameterBottom,r.tessellation,r.subdivisions,r.canBeRegenerated,null);return e.Tags&&e.Tags.AddTagsTo(n,r.tags),i.pushGeometry(n,!0),n},i})(i);r.Cylinder=u;var l=(function(r){function i(t,i,n,o,s,a,u,l){void 0===l&&(l=e.Mesh.DEFAULTSIDE);var h=r.call(this,t,i,a,u)||this;return h.diameter=n,h.thickness=o,h.tessellation=s,h.side=l,h}return __extends(i,r),i.prototype._regenerateVertexData=function(){return e.VertexData.CreateTorus({diameter:this.diameter,thickness:this.thickness,tessellation:this.tessellation,sideOrientation:this.side})},i.prototype.copy=function(e){return new i(e,this.getScene(),this.diameter,this.thickness,this.tessellation,this.canBeRegenerated(),null,this.side)},i.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.diameter=this.diameter,e.thickness=this.thickness,e.tessellation=this.tessellation,e},i.Parse=function(r,i){if(i.getGeometryByID(r.id))return null;var n=new t.Primitives.Torus(r.id,i,r.diameter,r.thickness,r.tessellation,r.canBeRegenerated,null);return e.Tags&&e.Tags.AddTagsTo(n,r.tags),i.pushGeometry(n,!0),n},i})(i);r.Torus=l;var h=(function(r){function i(e,t,i,n,o,s,a){var u=r.call(this,e,t,s,a)||this;return u.width=i,u.height=n,u.subdivisions=o,u}return __extends(i,r),i.prototype._regenerateVertexData=function(){return e.VertexData.CreateGround({width:this.width,height:this.height,subdivisions:this.subdivisions})},i.prototype.copy=function(e){return new i(e,this.getScene(),this.width,this.height,this.subdivisions,this.canBeRegenerated(),null)},i.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.width=this.width,e.height=this.height,e.subdivisions=this.subdivisions,e},i.Parse=function(r,i){if(i.getGeometryByID(r.id))return null;var n=new t.Primitives.Ground(r.id,i,r.width,r.height,r.subdivisions,r.canBeRegenerated,null);return e.Tags&&e.Tags.AddTagsTo(n,r.tags),i.pushGeometry(n,!0),n},i})(i);r.Ground=h;var c=(function(t){function r(e,r,i,n,o,s,a,u,l,h){var c=t.call(this,e,r,l,h)||this;return c.xmin=i,c.zmin=n,c.xmax=o,c.zmax=s,c.subdivisions=a,c.precision=u,c}return __extends(r,t),r.prototype._regenerateVertexData=function(){return e.VertexData.CreateTiledGround({xmin:this.xmin,zmin:this.zmin,xmax:this.xmax,zmax:this.zmax,subdivisions:this.subdivisions,precision:this.precision})},r.prototype.copy=function(e){return new r(e,this.getScene(),this.xmin,this.zmin,this.xmax,this.zmax,this.subdivisions,this.precision,this.canBeRegenerated(),null)},r})(i);r.TiledGround=c;var f=(function(r){function i(t,i,n,o,s,a){void 0===a&&(a=e.Mesh.DEFAULTSIDE);var u=r.call(this,t,i,o,s)||this;return u.size=n,u.side=a,u}return __extends(i,r),i.prototype._regenerateVertexData=function(){return e.VertexData.CreatePlane({size:this.size,sideOrientation:this.side})},i.prototype.copy=function(e){return new i(e,this.getScene(),this.size,this.canBeRegenerated(),null,this.side)},i.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.size=this.size,e},i.Parse=function(r,i){if(i.getGeometryByID(r.id))return null;var n=new t.Primitives.Plane(r.id,i,r.size,r.canBeRegenerated,null);return e.Tags&&e.Tags.AddTagsTo(n,r.tags),i.pushGeometry(n,!0),n},i})(i);r.Plane=f;var d=(function(r){function i(t,i,n,o,s,a,u,l,h,c,f){void 0===f&&(f=e.Mesh.DEFAULTSIDE);var d=r.call(this,t,i,h,c)||this;return d.radius=n,d.tube=o,d.radialSegments=s,d.tubularSegments=a,d.p=u,d.q=l,d.side=f,d}return __extends(i,r),i.prototype._regenerateVertexData=function(){return e.VertexData.CreateTorusKnot({radius:this.radius,tube:this.tube,radialSegments:this.radialSegments,tubularSegments:this.tubularSegments,p:this.p,q:this.q,sideOrientation:this.side})},i.prototype.copy=function(e){return new i(e,this.getScene(),this.radius,this.tube,this.radialSegments,this.tubularSegments,this.p,this.q,this.canBeRegenerated(),null,this.side)},i.prototype.serialize=function(){var e=r.prototype.serialize.call(this);return e.radius=this.radius,e.tube=this.tube,e.radialSegments=this.radialSegments,e.tubularSegments=this.tubularSegments,e.p=this.p,e.q=this.q,e},i.Parse=function(r,i){if(i.getGeometryByID(r.id))return null;var n=new t.Primitives.TorusKnot(r.id,i,r.radius,r.tube,r.radialSegments,r.tubularSegments,r.p,r.q,r.canBeRegenerated,null);return e.Tags&&e.Tags.AddTagsTo(n,r.tags),i.pushGeometry(n,!0),n},i})(i);r.TorusKnot=d})(t.Primitives||(t.Primitives={}))})(t=e.Geometry||(e.Geometry={}))})(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 r=[];r.push(0),r.push(1),r.push(2),r.push(0),r.push(2),r.push(3),this._indexBuffer=this._scene.getEngine().createIndexBuffer(r)}},t.prototype._prepareFrame=function(e,t){var t=t||this._scene.activeCamera._postProcesses;return!(0===t.length||!this._scene.postProcessesEnabled)&&(t[0].activate(this._scene.activeCamera,e,null!==t&&void 0!==t),!0)},t.prototype.directRender=function(e,t){for(var r=this._scene.getEngine(),i=0;i<e.length;i++){i<e.length-1?e[i+1].activate(this._scene.activeCamera,t):t?r.bindFramebuffer(t):r.restoreDefaultFramebuffer();var n=e[i],o=n.apply();o&&(n.onBeforeRenderObservable.notifyObservers(o),this._prepareBuffers(),r.bindBuffers(this._vertexBuffers,this._indexBuffer,o),r.draw(!0,0,6),n.onAfterRenderObservable.notifyObservers(o))}r.setDepthBuffer(!0),r.setDepthWrite(!0)},t.prototype._finalizeFrame=function(t,r,i,n){if(n=n||this._scene.activeCamera._postProcesses,0!==n.length&&this._scene.postProcessesEnabled){for(var o=this._scene.getEngine(),s=0,a=n.length;s<a&&(s<a-1?n[s+1].activate(this._scene.activeCamera,r):r?o.bindFramebuffer(r,i):o.restoreDefaultFramebuffer(),!t);s++){var u=n[s],l=u.apply();l&&(u.onBeforeRenderObservable.notifyObservers(l),this._prepareBuffers(),o.bindBuffers(this._vertexBuffers,this._indexBuffer,l),o.draw(!0,0,6),u.onAfterRenderObservable.notifyObservers(l))}o.setDepthBuffer(!0),o.setDepthWrite(!0),o.setAlphaMode(e.Engine.ALPHA_DISABLE)}},t.prototype.dispose=function(){var t=this._vertexBuffers[e.VertexBuffer.PositionKind];t&&(t.dispose(),this._vertexBuffers[e.VertexBuffer.PositionKind]=null),
- this._indexBuffer&&(this._scene.getEngine()._releaseBuffer(this._indexBuffer),this._indexBuffer=null)},t})();e.PostProcessManager=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(e){void 0===e&&(e=30),this._enabled=!0,this._rollingFrameTime=new r(e)}return t.prototype.sampleFrame=function(t){if(void 0===t&&(t=e.Tools.Now),this._enabled){if(null!=this._lastFrameTimeMs){var r=t-this._lastFrameTimeMs;this._rollingFrameTime.add(r)}this._lastFrameTimeMs=t}},Object.defineProperty(t.prototype,"averageFrameTime",{get:function(){return this._rollingFrameTime.average},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"averageFrameTimeVariance",{get:function(){return this._rollingFrameTime.variance},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"instantaneousFrameTime",{get:function(){return this._rollingFrameTime.history(0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"averageFPS",{get:function(){return 1e3/this._rollingFrameTime.average},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"instantaneousFPS",{get:function(){return 1e3/this._rollingFrameTime.history(0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isSaturated",{get:function(){return this._rollingFrameTime.isSaturated()},enumerable:!0,configurable:!0}),t.prototype.enable=function(){this._enabled=!0},t.prototype.disable=function(){this._enabled=!1,this._lastFrameTimeMs=null,this._lastChangeTimeMs=null},Object.defineProperty(t.prototype,"isEnabled",{get:function(){return this._enabled},enumerable:!0,configurable:!0}),t.prototype.reset=function(){this._lastFrameTimeMs=null,this._lastChangeTimeMs=null,this._rollingFrameTime.reset()},t})();e.PerformanceMonitor=t;var r=(function(){function e(e){this._samples=new Array(e),this.reset()}return e.prototype.add=function(e){var t;if(this.isSaturated()){var r=this._samples[this._pos];t=r-this.average,this.average-=t/(this._sampleCount-1),this._m2-=t*(r-this.average)}else this._sampleCount++;t=e-this.average,this.average+=t/this._sampleCount,this._m2+=t*(e-this.average),this.variance=this._m2/(this._sampleCount-1),this._samples[this._pos]=e,this._pos++,this._pos%=this._samples.length},e.prototype.history=function(e){if(e>=this._sampleCount||e>=this._samples.length)return null;var t=this._wrapPosition(this._pos-1);return this._samples[this._wrapPosition(t-e)]},e.prototype.isSaturated=function(){return this._sampleCount>=this._samples.length},e.prototype.reset=function(){this.average=0,this.variance=0,this._sampleCount=0,this._pos=0,this._m2=0},e.prototype._wrapPosition=function(e){var t=this._samples.length;return(e%t+t)%t},e})();e.RollingAverage=r})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(e,t,r){this.name=e,this.from=t,this.to=r}return e.prototype.clone=function(){return new e(this.name,this.from,this.to)},e})();e.AnimationRange=t;var r=(function(){function e(e,t,r){this.frame=e,this.action=t,this.onlyOnce=r,this.isDone=!1}return e})();e.AnimationEvent=r;var i=(function(){function t(e){this.path=e,this._onchange=new Array,this.value=0,this.animations=new Array}return t.prototype.getPoint=function(){var t=this.path.getPointAtLengthPosition(this.value);return new e.Vector3(t.x,0,t.y)},t.prototype.moveAhead=function(e){return void 0===e&&(e=.002),this.move(e),this},t.prototype.moveBack=function(e){return void 0===e&&(e=.002),this.move(-e),this},t.prototype.move=function(e){if(Math.abs(e)>1)throw"step size should be less than 1.";return this.value+=e,this.ensureLimits(),this.raiseOnChange(),this},t.prototype.ensureLimits=function(){for(;this.value>1;)this.value-=1;for(;this.value<0;)this.value+=1;return this},t.prototype.markAsDirty=function(e){return this.ensureLimits(),this.raiseOnChange(),this},t.prototype.raiseOnChange=function(){var e=this;return this._onchange.forEach((function(t){return t(e)})),this},t.prototype.onchange=function(e){return this._onchange.push(e),this},t})();e.PathCursor=i;var n=(function(){function r(e,t,i,n,o,s){this.name=e,this.targetProperty=t,this.framePerSecond=i,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?r.ANIMATIONLOOPMODE_CYCLE:o}return r._PrepareAnimation=function(t,i,n,o,s,a,u,l){var h=void 0;if(!isNaN(parseFloat(s))&&isFinite(s)?h=r.ANIMATIONTYPE_FLOAT:s instanceof e.Quaternion?h=r.ANIMATIONTYPE_QUATERNION:s instanceof e.Vector3?h=r.ANIMATIONTYPE_VECTOR3:s instanceof e.Vector2?h=r.ANIMATIONTYPE_VECTOR2:s instanceof e.Color3?h=r.ANIMATIONTYPE_COLOR3:s instanceof e.Size&&(h=r.ANIMATIONTYPE_SIZE),void 0==h)return null;var c=new r(t,i,n,h,u),f=[{frame:0,value:s},{frame:o,value:a}];return c.setKeys(f),void 0!==l&&c.setEasingFunction(l),c},r.CreateAnimation=function(t,r,i,n){var o=new e.Animation(t+"Animation",t,i,r,e.Animation.ANIMATIONLOOPMODE_CONSTANT);return o.setEasingFunction(n),o},r.CreateAndStartAnimation=function(e,t,i,n,o,s,a,u,l,h){var c=r._PrepareAnimation(e,i,n,o,s,a,u,l);return t.getScene().beginDirectAnimation(t,[c],0,o,1===c.loopMode,1,h)},r.CreateMergeAndStartAnimation=function(e,t,i,n,o,s,a,u,l,h){var c=r._PrepareAnimation(e,i,n,o,s,a,u,l);return t.animations.push(c),t.getScene().beginAnimation(t,0,o,1===c.loopMode,1,h)},r.TransitionTo=function(e,t,r,i,n,o,s,a){if(void 0===a&&(a=null),s<=0)return r[e]=t,void(a&&a());var u=n*(s/1e3);o.setKeys([{frame:0,value:r[e]},{frame:u,value:t}]),r.animations||(r.animations=[]),r.animations.push(o);var l=i.beginAnimation(r,0,u,!1);return l.onAnimationEnd=a,l},r.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 r=!0;for(var i in this._ranges)r&&(t+=", ",r=!1),t+=i;t+="}"}return t},r.prototype.addEvent=function(e){this._events.push(e)},r.prototype.removeEvents=function(e){for(var t=0;t<this._events.length;t++)this._events[t].frame===e&&(this._events.splice(t,1),t--)},r.prototype.createRange=function(e,r,i){this._ranges[e]||(this._ranges[e]=new t(e,r,i))},r.prototype.deleteRange=function(e,t){if(void 0===t&&(t=!0),this._ranges[e]){if(t)for(var r=this._ranges[e].from,i=this._ranges[e].to,n=this._keys.length-1;n>=0;n--)this._keys[n].frame>=r&&this._keys[n].frame<=i&&this._keys.splice(n,1);this._ranges[e]=void 0}},r.prototype.getRange=function(e){return this._ranges[e]},r.prototype.reset=function(){this._offsetsCache={},this._highLimitsCache={},this.currentFrame=0,this._blendingFactor=0,this._originalBlendValue=null},r.prototype.isStopped=function(){return this._stopped},r.prototype.getKeys=function(){return this._keys},r.prototype.getHighestFrame=function(){for(var e=0,t=0,r=this._keys.length;t<r;t++)e<this._keys[t].frame&&(e=this._keys[t].frame);return e},r.prototype.getEasingFunction=function(){return this._easingFunction},r.prototype.setEasingFunction=function(e){this._easingFunction=e},r.prototype.floatInterpolateFunction=function(t,r,i){return e.Scalar.Lerp(t,r,i)},r.prototype.floatInterpolateFunctionWithTangents=function(t,r,i,n,o){return e.Scalar.Hermite(t,r,i,n,o)},r.prototype.quaternionInterpolateFunction=function(t,r,i){return e.Quaternion.Slerp(t,r,i)},r.prototype.quaternionInterpolateFunctionWithTangents=function(t,r,i,n,o){return e.Quaternion.Hermite(t,r,i,n,o).normalize()},r.prototype.vector3InterpolateFunction=function(t,r,i){return e.Vector3.Lerp(t,r,i)},r.prototype.vector3InterpolateFunctionWithTangents=function(t,r,i,n,o){return e.Vector3.Hermite(t,r,i,n,o)},r.prototype.vector2InterpolateFunction=function(t,r,i){return e.Vector2.Lerp(t,r,i)},r.prototype.vector2InterpolateFunctionWithTangents=function(t,r,i,n,o){return e.Vector2.Hermite(t,r,i,n,o)},r.prototype.sizeInterpolateFunction=function(t,r,i){return e.Size.Lerp(t,r,i)},r.prototype.color3InterpolateFunction=function(t,r,i){return e.Color3.Lerp(t,r,i)},r.prototype.matrixInterpolateFunction=function(t,r,i){return e.Matrix.Lerp(t,r,i)},r.prototype.clone=function(){var e=new r(this.name,this.targetPropertyPath.join("."),this.framePerSecond,this.dataType,this.loopMode);if(e.enableBlending=this.enableBlending,e.blendingSpeed=this.blendingSpeed,this._keys&&e.setKeys(this._keys),this._ranges){e._ranges={};for(var t in this._ranges)e._ranges[t]=this._ranges[t].clone()}return e},r.prototype.setKeys=function(e){this._keys=e.slice(0),this._offsetsCache={},this._highLimitsCache={}},r.prototype._getKeyValue=function(e){return"function"==typeof e?e():e},r.prototype._interpolate=function(e,t,i,n,o){if(i===r.ANIMATIONLOOPMODE_CONSTANT&&t>0)return o.clone?o.clone():o;this.currentFrame=e;var s=Math.max(0,Math.min(this._keys.length-1,Math.floor(this._keys.length*(e-this._keys[0].frame)/(this._keys[this._keys.length-1].frame-this._keys[0].frame))-1));if(this._keys[s].frame>=e)for(;s-1>=0&&this._keys[s].frame>=e;)s--;for(var a=s;a<this._keys.length;a++){var u=this._keys[a+1];if(u.frame>=e){var l=this._keys[a],h=this._getKeyValue(l.value),c=this._getKeyValue(u.value),f=void 0!==l.outTangent&&void 0!==u.inTangent,d=u.frame-l.frame,p=(e-l.frame)/d;switch(null!=this._easingFunction&&(p=this._easingFunction.ease(p)),this.dataType){case r.ANIMATIONTYPE_FLOAT:var g=f?this.floatInterpolateFunctionWithTangents(h,l.outTangent*d,c,u.inTangent*d,p):this.floatInterpolateFunction(h,c,p);switch(i){case r.ANIMATIONLOOPMODE_CYCLE:case r.ANIMATIONLOOPMODE_CONSTANT:return g;case r.ANIMATIONLOOPMODE_RELATIVE:return n*t+g}break;case r.ANIMATIONTYPE_QUATERNION:var _=f?this.quaternionInterpolateFunctionWithTangents(h,l.outTangent.scale(d),c,u.inTangent.scale(d),p):this.quaternionInterpolateFunction(h,c,p);switch(i){case r.ANIMATIONLOOPMODE_CYCLE:case r.ANIMATIONLOOPMODE_CONSTANT:return _;case r.ANIMATIONLOOPMODE_RELATIVE:return _.add(n.scale(t))}return _;case r.ANIMATIONTYPE_VECTOR3:var m=f?this.vector3InterpolateFunctionWithTangents(h,l.outTangent.scale(d),c,u.inTangent.scale(d),p):this.vector3InterpolateFunction(h,c,p);switch(i){case r.ANIMATIONLOOPMODE_CYCLE:case r.ANIMATIONLOOPMODE_CONSTANT:return m;case r.ANIMATIONLOOPMODE_RELATIVE:return m.add(n.scale(t))}case r.ANIMATIONTYPE_VECTOR2:var v=f?this.vector2InterpolateFunctionWithTangents(h,l.outTangent.scale(d),c,u.inTangent.scale(d),p):this.vector2InterpolateFunction(h,c,p);switch(i){case r.ANIMATIONLOOPMODE_CYCLE:case r.ANIMATIONLOOPMODE_CONSTANT:return v;case r.ANIMATIONLOOPMODE_RELATIVE:return v.add(n.scale(t))}case r.ANIMATIONTYPE_SIZE:switch(i){case r.ANIMATIONLOOPMODE_CYCLE:case r.ANIMATIONLOOPMODE_CONSTANT:return this.sizeInterpolateFunction(h,c,p);case r.ANIMATIONLOOPMODE_RELATIVE:return this.sizeInterpolateFunction(h,c,p).add(n.scale(t))}case r.ANIMATIONTYPE_COLOR3:switch(i){case r.ANIMATIONLOOPMODE_CYCLE:case r.ANIMATIONLOOPMODE_CONSTANT:return this.color3InterpolateFunction(h,c,p);case r.ANIMATIONLOOPMODE_RELATIVE:return this.color3InterpolateFunction(h,c,p).add(n.scale(t))}case r.ANIMATIONTYPE_MATRIX:switch(i){case r.ANIMATIONLOOPMODE_CYCLE:case r.ANIMATIONLOOPMODE_CONSTANT:if(this.allowMatricesInterpolation)return this.matrixInterpolateFunction(h,c,p);case r.ANIMATIONLOOPMODE_RELATIVE:return h}}break}}return this._getKeyValue(this._keys[this._keys.length-1].value)},r.prototype.setValue=function(t,r){void 0===r&&(r=!1);var i,n;if(this.targetPropertyPath.length>1){for(var o=this._target[this.targetPropertyPath[0]],s=1;s<this.targetPropertyPath.length-1;s++)o=o[this.targetPropertyPath[s]];i=this.targetPropertyPath[this.targetPropertyPath.length-1],n=o}else i=this.targetPropertyPath[0],n=this._target;this.enableBlending&&this._blendingFactor<=1?(this._originalBlendValue||(n[i].clone?this._originalBlendValue=n[i].clone():this._originalBlendValue=n[i]),this._originalBlendValue.prototype?this._originalBlendValue.prototype.Lerp?n[i]=this._originalBlendValue.construtor.prototype.Lerp(t,this._originalBlendValue,this._blendingFactor):n[i]=t:this._originalBlendValue.m?n[i]=e.Matrix.Lerp(this._originalBlendValue,t,this._blendingFactor):n[i]=this._originalBlendValue*(1-this._blendingFactor)+this._blendingFactor*t,this._blendingFactor+=this.blendingSpeed):n[i]=t,this._target.markAsDirty&&this._target.markAsDirty(this.targetProperty)},r.prototype.goToFrame=function(e){e<this._keys[0].frame?e=this._keys[0].frame:e>this._keys[this._keys.length-1].frame&&(e=this._keys[this._keys.length-1].frame);var t=this._interpolate(e,0,this.loopMode);this.setValue(t)},r.prototype.animate=function(t,i,n,o,s,a){if(void 0===a&&(a=!1),!this.targetPropertyPath||this.targetPropertyPath.length<1)return this._stopped=!0,!1;var u=!0;if(0!==this._keys[0].frame){var l={frame:0,value:this._keys[0].value};this._keys.splice(0,0,l)}(i<this._keys[0].frame||i>this._keys[this._keys.length-1].frame)&&(i=this._keys[0].frame),(n<this._keys[0].frame||n>this._keys[this._keys.length-1].frame)&&(n=this._keys[this._keys.length-1].frame),i===n&&i++;var h,c=n-i,f=t*(this.framePerSecond*s)/1e3,d=0;if((n>i&&f>c||i>n&&f<c)&&!o)u=!1,d=this._getKeyValue(this._keys[this._keys.length-1].value);else if(this.loopMode!==r.ANIMATIONLOOPMODE_CYCLE){var p=n.toString()+i.toString();if(!this._offsetsCache[p]){var g=this._interpolate(i,0,r.ANIMATIONLOOPMODE_CYCLE),_=this._interpolate(n,0,r.ANIMATIONLOOPMODE_CYCLE);switch(this.dataType){case r.ANIMATIONTYPE_FLOAT:this._offsetsCache[p]=_-g;break;case r.ANIMATIONTYPE_QUATERNION:this._offsetsCache[p]=_.subtract(g);break;case r.ANIMATIONTYPE_VECTOR3:this._offsetsCache[p]=_.subtract(g);case r.ANIMATIONTYPE_VECTOR2:this._offsetsCache[p]=_.subtract(g);case r.ANIMATIONTYPE_SIZE:this._offsetsCache[p]=_.subtract(g);case r.ANIMATIONTYPE_COLOR3:this._offsetsCache[p]=_.subtract(g)}this._highLimitsCache[p]=_}d=this._highLimitsCache[p],h=this._offsetsCache[p]}if(void 0===h)switch(this.dataType){case r.ANIMATIONTYPE_FLOAT:h=0;break;case r.ANIMATIONTYPE_QUATERNION:h=new e.Quaternion(0,0,0,0);break;case r.ANIMATIONTYPE_VECTOR3:h=e.Vector3.Zero();break;case r.ANIMATIONTYPE_VECTOR2:h=e.Vector2.Zero();break;case r.ANIMATIONTYPE_SIZE:h=e.Size.Zero();break;case r.ANIMATIONTYPE_COLOR3:h=e.Color3.Black()}var m=f/c>>0,v=u?i+f%c:n,y=this._interpolate(v,m,this.loopMode,h,d);this.setValue(y);for(var A=0;A<this._events.length;A++)if(c>0&&v>=this._events[A].frame&&this._events[A].frame>=i||c<0&&v<=this._events[A].frame&&this._events[A].frame<=i){var T=this._events[A];T.isDone||(T.onlyOnce&&(this._events.splice(A,1),A--),T.isDone=!0,T.action())}else this._events[A].isDone&&!this._events[A].onlyOnce&&(this._events[A].isDone=!1);return u||(this._stopped=!0),u},r.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,e.enableBlending=this.enableBlending,e.blendingSpeed=this.blendingSpeed;var t=this.dataType;e.keys=[];for(var i=this.getKeys(),n=0;n<i.length;n++){var o=i[n],s={};switch(s.frame=o.frame,t){case r.ANIMATIONTYPE_FLOAT:s.values=[o.value];break;case r.ANIMATIONTYPE_QUATERNION:case r.ANIMATIONTYPE_MATRIX:case r.ANIMATIONTYPE_VECTOR3:case r.ANIMATIONTYPE_COLOR3:s.values=o.value.asArray()}e.keys.push(s)}e.ranges=[];for(var a in this._ranges){var u={};u.name=a,u.from=this._ranges[a].from,u.to=this._ranges[a].to,e.ranges.push(u)}return e},Object.defineProperty(r,"ANIMATIONTYPE_FLOAT",{get:function(){return r._ANIMATIONTYPE_FLOAT},enumerable:!0,configurable:!0}),Object.defineProperty(r,"ANIMATIONTYPE_VECTOR3",{get:function(){return r._ANIMATIONTYPE_VECTOR3},enumerable:!0,configurable:!0}),Object.defineProperty(r,"ANIMATIONTYPE_VECTOR2",{get:function(){return r._ANIMATIONTYPE_VECTOR2},enumerable:!0,configurable:!0}),Object.defineProperty(r,"ANIMATIONTYPE_SIZE",{get:function(){return r._ANIMATIONTYPE_SIZE},enumerable:!0,configurable:!0}),Object.defineProperty(r,"ANIMATIONTYPE_QUATERNION",{get:function(){return r._ANIMATIONTYPE_QUATERNION},enumerable:!0,configurable:!0}),Object.defineProperty(r,"ANIMATIONTYPE_MATRIX",{get:function(){return r._ANIMATIONTYPE_MATRIX},enumerable:!0,configurable:!0}),Object.defineProperty(r,"ANIMATIONTYPE_COLOR3",{get:function(){return r._ANIMATIONTYPE_COLOR3},enumerable:!0,configurable:!0}),Object.defineProperty(r,"ANIMATIONLOOPMODE_RELATIVE",{get:function(){return r._ANIMATIONLOOPMODE_RELATIVE},enumerable:!0,configurable:!0}),Object.defineProperty(r,"ANIMATIONLOOPMODE_CYCLE",{get:function(){return r._ANIMATIONLOOPMODE_CYCLE},enumerable:!0,configurable:!0}),Object.defineProperty(r,"ANIMATIONLOOPMODE_CONSTANT",{get:function(){return r._ANIMATIONLOOPMODE_CONSTANT},enumerable:!0,configurable:!0}),r.Parse=function(t){var i,n,o=new r(t.name,t.property,t.framePerSecond,t.dataType,t.loopBehavior),s=t.dataType,a=[];for(t.enableBlending&&(o.enableBlending=t.enableBlending),t.blendingSpeed&&(o.blendingSpeed=t.blendingSpeed),n=0;n<t.keys.length;n++){var u=t.keys[n];switch(s){case r.ANIMATIONTYPE_FLOAT:i=u.values[0];break;case r.ANIMATIONTYPE_QUATERNION:i=e.Quaternion.FromArray(u.values);break;case r.ANIMATIONTYPE_MATRIX:i=e.Matrix.FromArray(u.values);break;case r.ANIMATIONTYPE_COLOR3:i=e.Color3.FromArray(u.values);break;case r.ANIMATIONTYPE_VECTOR3:default:i=e.Vector3.FromArray(u.values)}a.push({frame:u.frame,value:i})}if(o.setKeys(a),t.ranges)for(n=0;n<t.ranges.length;n++)i=t.ranges[n],o.createRange(i.name,i.from,i.to);return o},r.AppendSerializedAnimations=function(e,t){if(e.animations){t.animations=[];for(var r=0;r<e.animations.length;r++){var i=e.animations[r];t.animations.push(i.serialize())}}},r._ANIMATIONTYPE_FLOAT=0,r._ANIMATIONTYPE_VECTOR3=1,r._ANIMATIONTYPE_QUATERNION=2,r._ANIMATIONTYPE_MATRIX=3,r._ANIMATIONTYPE_COLOR3=4,r._ANIMATIONTYPE_VECTOR2=5,r._ANIMATIONTYPE_SIZE=6,r._ANIMATIONLOOPMODE_RELATIVE=0,r._ANIMATIONLOOPMODE_CYCLE=1,r._ANIMATIONLOOPMODE_CONSTANT=2,r})();e.Animation=n})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(e,t,r,i,n,o,s,a){void 0===r&&(r=0),void 0===i&&(i=100),void 0===n&&(n=!1),void 0===o&&(o=1),this.target=t,this.fromFrame=r,this.toFrame=i,this.loopAnimation=n,this.speedRatio=o,this.onAnimationEnd=s,this._localDelayOffset=null,this._pausedDelay=null,this._animations=new Array,this._paused=!1,this.animationStarted=!1,a&&this.appendAnimations(t,a),this._scene=e,e._activeAnimatables.push(this)}return e.prototype.getAnimations=function(){return this._animations},e.prototype.appendAnimations=function(e,t){for(var r=0;r<t.length;r++){var i=t[r];i._target=e,this._animations.push(i)}},e.prototype.getAnimationByTargetProperty=function(e){for(var t=this._animations,r=0;r<t.length;r++)if(t[r].targetProperty===e)return t[r];return null},e.prototype.reset=function(){for(var e=this._animations,t=0;t<e.length;t++)e[t].reset();this._localDelayOffset=null,this._pausedDelay=null},e.prototype.enableBlending=function(e){for(var t=this._animations,r=0;r<t.length;r++)t[r].enableBlending=!0,t[r].blendingSpeed=e},e.prototype.disableBlending=function(){for(var e=this._animations,t=0;t<e.length;t++)e[t].enableBlending=!1},e.prototype.goToFrame=function(e){var t=this._animations;if(t[0]){var r=t[0].framePerSecond,i=t[0].currentFrame,n=e-i,o=1e3*n/r;this._localDelayOffset-=o}for(var s=0;s<t.length;s++)t[s].goToFrame(e)},e.prototype.pause=function(){this._paused||(this._paused=!0)},e.prototype.restart=function(){this._paused=!1},e.prototype.stop=function(e){if(e){var t=this._scene._activeAnimatables.indexOf(this);if(t>-1){for(var r=this._animations,i=r.length-1;i>=0;i--)"string"==typeof e&&r[i].name!=e||(r[i].reset(),r.splice(i,1));0==r.length&&(this._scene._activeAnimatables.splice(t,1),this.onAnimationEnd&&this.onAnimationEnd())}}else{var i=this._scene._activeAnimatables.indexOf(this);if(i>-1){this._scene._activeAnimatables.splice(i,1);for(var r=this._animations,i=0;i<r.length;i++)r[i].reset();this.onAnimationEnd&&this.onAnimationEnd()}}},e.prototype._animate=function(e){if(this._paused)return this.animationStarted=!1,null===this._pausedDelay&&(this._pausedDelay=e),!0;null===this._localDelayOffset?this._localDelayOffset=e:null!==this._pausedDelay&&(this._localDelayOffset+=e-this._pausedDelay,this._pausedDelay=null);var t,r=!1,i=this._animations;for(t=0;t<i.length;t++){var n=i[t],o=n.animate(e-this._localDelayOffset,this.fromFrame,this.toFrame,this.loopAnimation,this.speedRatio);r=r||o}return this.animationStarted=r,r||(t=this._scene._activeAnimatables.indexOf(this),this._scene._activeAnimatables.splice(t,1)),!r&&this.onAnimationEnd&&(this.onAnimationEnd(),this.onAnimationEnd=null),r},e})();e.Animatable=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(){this._easingMode=e.EASINGMODE_EASEIN}return Object.defineProperty(e,"EASINGMODE_EASEIN",{get:function(){return e._EASINGMODE_EASEIN},enumerable:!0,configurable:!0}),Object.defineProperty(e,"EASINGMODE_EASEOUT",{get:function(){return e._EASINGMODE_EASEOUT},enumerable:!0,configurable:!0}),Object.defineProperty(e,"EASINGMODE_EASEINOUT",{get:function(){return e._EASINGMODE_EASEINOUT},enumerable:!0,configurable:!0}),e.prototype.setEasingMode=function(e){var t=Math.min(Math.max(e,0),2);this._easingMode=t},e.prototype.getEasingMode=function(){return this._easingMode},e.prototype.easeInCore=function(e){throw new Error("You must implement this method")},e.prototype.ease=function(t){switch(this._easingMode){case e.EASINGMODE_EASEIN:return this.easeInCore(t);case e.EASINGMODE_EASEOUT:return 1-this.easeInCore(1-t)}return t>=.5?.5*(1-this.easeInCore(2*(1-t)))+.5:.5*this.easeInCore(2*t)},e._EASINGMODE_EASEIN=0,e._EASINGMODE_EASEOUT=1,e._EASINGMODE_EASEINOUT=2,e})();e.EasingFunction=t;var r=(function(e){function t(){return null!==e&&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=r;var i=(function(e){function t(t){void 0===t&&(t=1);var r=e.call(this)||this;return r.amplitude=t,r}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=i;var n=(function(e){function t(t,r){void 0===t&&(t=3),void 0===r&&(r=2);var i=e.call(this)||this;return i.bounces=t,i.bounciness=r,i}return __extends(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.bounces),r=this.bounciness;r<=1&&(r=1.001);var i=Math.pow(r,t),n=1-r,o=(1-i)/n+.5*i,s=e*o,a=Math.log(-s*(1-r)+1)/Math.log(r),u=Math.floor(a),l=u+1,h=(1-Math.pow(r,u))/(n*o),c=(1-Math.pow(r,l))/(n*o),f=.5*(h+c),d=e-f,p=f-h;return-Math.pow(1/r,t-u)/(p*p)*(d-p)*(d+p)},t})(t);e.BounceEase=n;var o=(function(e){function t(){return null!==e&&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,r){void 0===t&&(t=3),void 0===r&&(r=3);var i=e.call(this)||this;return i.oscillations=t,i.springiness=r,i}return __extends(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.oscillations),r=Math.max(0,this.springiness);return(0==r?e:(Math.exp(r*e)-1)/(Math.exp(r)-1))*Math.sin((6.283185307179586*t+1.5707963267948966)*e)},t})(t);e.ElasticEase=s;var a=(function(e){function t(t){void 0===t&&(t=2);var r=e.call(this)||this;return r.exponent=t,r}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 u=(function(e){function t(t){void 0===t&&(t=2);var r=e.call(this)||this;return r.power=t,r}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=u;var l=(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.easeInCore=function(e){return e*e},t})(t);e.QuadraticEase=l;var h=(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.easeInCore=function(e){return e*e*e*e},t})(t);e.QuarticEase=h;var c=(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.easeInCore=function(e){return e*e*e*e*e},t})(t);e.QuinticEase=c;var f=(function(e){function t(){return null!==e&&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 r(e,r,i,n){void 0===e&&(e=0),void 0===r&&(r=0),void 0===i&&(i=1),void 0===n&&(n=1);var o=t.call(this)||this;return o.x1=e,o.y1=r,o.x2=i,o.y2=n,o}return __extends(r,t),r.prototype.easeInCore=function(t){return e.BezierCurve.interpolate(t,this.x1,this.y1,this.x2,this.y2)},r})(t);e.BezierCurveEase=d})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){e.CameraInputTypes={};var t=(function(){function t(e){this.attached={},this.camera=e,this.checkInputs=function(){}}return t.prototype.add=function(t){var r=t.getSimpleName();if(this.attached[r])return void e.Tools.Warn("camera input of type "+r+" already exists on camera");this.attached[r]=t,t.camera=this.camera,t.checkInputs&&(this.checkInputs=this._addCheckInputs(t.checkInputs.bind(t))),this.attachedElement&&t.attachControl(this.attachedElement)},t.prototype.remove=function(e){for(var t in this.attached){var r=this.attached[t];r===e&&(r.detachControl(this.attachedElement),r.camera=null,delete this.attached[t],this.rebuildInputCheck())}},t.prototype.removeByType=function(e){for(var t in this.attached){var r=this.attached[t];r.getClassName()===e&&(r.detachControl(this.attachedElement),r.camera=null,delete this.attached[t],this.rebuildInputCheck())}},t.prototype._addCheckInputs=function(e){var t=this.checkInputs;return function(){t(),e()}},t.prototype.attachInput=function(e){e.attachControl(this.attachedElement,this.noPreventDefault)},t.prototype.attachElement=function(t,r){if(!this.attachedElement){r=!e.Camera.ForceAttachControlToAlwaysPreventDefault&&r,this.attachedElement=t,this.noPreventDefault=r;for(var i in this.attached){this.attached[i];this.attached[i].attachControl(t,r)}}},t.prototype.detachElement=function(e,t){if(void 0===t&&(t=!1),this.attachedElement===e){for(var r in this.attached){this.attached[r];this.attached[r].detachControl(e),t&&(this.attached[r].camera=null)}this.attachedElement=null}},t.prototype.rebuildInputCheck=function(){this.checkInputs=function(){};for(var e in this.attached){var t=this.attached[e];t.checkInputs&&(this.checkInputs=this._addCheckInputs(t.checkInputs.bind(t)))}},t.prototype.clear=function(){this.attachedElement&&this.detachElement(this.attachedElement,!0),this.attached={},this.attachedElement=null,this.checkInputs=function(){}},t.prototype.serialize=function(t){var r={};for(var i in this.attached){var n=this.attached[i],o=e.SerializationHelper.Serialize(n);r[n.getClassName()]=o}t.inputsmgr=r},t.prototype.parse=function(t){var r=t.inputsmgr;if(r){this.clear();for(var i in r){var n=e.CameraInputTypes[i];if(n){var o=r[i],s=e.SerializationHelper.Parse((function(){return new n}),o,null);this.add(s)}}}else for(var i in this.attached){var n=e.CameraInputTypes[this.attached[i].getClassName()];if(n){var s=e.SerializationHelper.Parse((function(){return new n}),t,null);this.remove(this.attached[i]),this.add(s)}}},t})();e.CameraInputsManager=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(r,i,n){var o=t.call(this,r,i,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(r,t),r.prototype.getFrontPosition=function(e){var t=this.getTarget().subtract(this.position);return t.normalize(),t.scaleInPlace(e),this.globalPosition.add(t)},r.prototype._getLockedTargetPosition=function(){return this.lockedTarget?(this.lockedTarget.absolutePosition&&this.lockedTarget.computeWorldMatrix(),this.lockedTarget.absolutePosition||this.lockedTarget):null},r.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)},r.prototype._updateCache=function(e){e||t.prototype._updateCache.call(this);var r=this._getLockedTargetPosition();r?this._cache.lockedTarget?this._cache.lockedTarget.copyFrom(r):this._cache.lockedTarget=r.clone():this._cache.lockedTarget=null,this._cache.rotation.copyFrom(this.rotation),this.rotationQuaternion&&this._cache.rotationQuaternion.copyFrom(this.rotationQuaternion)},r.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))},r.prototype._computeLocalCameraSpeed=function(){var e=this.getEngine();return this.speed*Math.sqrt(e.getDeltaTime()/(100*e.getFps()))},r.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 r=t.subtract(this.position);r.x>=0?this.rotation.y=-Math.atan(r.z/r.x)+Math.PI/2:this.rotation.y=-Math.atan(r.z/r.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)},r.prototype.getTarget=function(){return this._currentTarget},r.prototype._decideIfNeedsToMove=function(){return Math.abs(this.cameraDirection.x)>0||Math.abs(this.cameraDirection.y)>0||Math.abs(this.cameraDirection.z)>0},r.prototype._updatePosition=function(){if(this.parent)return this.parent.getWorldMatrix().invertToRef(e.Tmp.Matrix[0]),e.Vector3.TransformNormalToRef(this.cameraDirection,e.Tmp.Matrix[0],e.Tmp.Vector3[0]),void this.position.addInPlace(e.Tmp.Vector3[0]);this.position.addInPlace(this.cameraDirection)},r.prototype._checkInputs=function(){var r=this._decideIfNeedsToMove(),i=Math.abs(this.cameraRotation.x)>0||Math.abs(this.cameraRotation.y)>0;if(r&&this._updatePosition(),i){if(this.rotation.x+=this.cameraRotation.x,this.rotation.y+=this.cameraRotation.y,this.rotationQuaternion){this.rotation.lengthSquared()&&e.Quaternion.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,this.rotationQuaternion)}if(!this.noRotationConstraint){var n=Math.PI/2*.95;this.rotation.x>n&&(this.rotation.x=n),this.rotation.x<-n&&(this.rotation.x=-n)}}r&&(Math.abs(this.cameraDirection.x)<this.speed*e.Epsilon&&(this.cameraDirection.x=0),Math.abs(this.cameraDirection.y)<this.speed*e.Epsilon&&(this.cameraDirection.y=0),Math.abs(this.cameraDirection.z)<this.speed*e.Epsilon&&(this.cameraDirection.z=0),this.cameraDirection.scaleInPlace(this.inertia)),i&&(Math.abs(this.cameraRotation.x)<this.speed*e.Epsilon&&(this.cameraRotation.x=0),Math.abs(this.cameraRotation.y)<this.speed*e.Epsilon&&(this.cameraRotation.y=0),this.cameraRotation.scaleInPlace(this.inertia)),t.prototype._checkInputs.call(this)},
- r.prototype._updateCameraRotationMatrix=function(){this.rotationQuaternion?(this.rotationQuaternion.toRotationMatrix(this._cameraRotationMatrix),e.Vector3.TransformNormalToRef(this._defaultUpVector,this._cameraRotationMatrix,this.upVector)):e.Matrix.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,this._cameraRotationMatrix)},r.prototype._getViewMatrix=function(){return this.lockedTarget?this._currentTarget.copyFrom(this._getLockedTargetPosition()):(this._updateCameraRotationMatrix(),e.Vector3.TransformCoordinatesToRef(this._referencePoint,this._cameraRotationMatrix,this._transformedReferencePoint),this.position.addToRef(this._transformedReferencePoint,this._currentTarget)),this.getScene().useRightHandedSystem?e.Matrix.LookAtRHToRef(this.position,this._currentTarget,this.upVector,this._viewMatrix):e.Matrix.LookAtLHToRef(this.position,this._currentTarget,this.upVector,this._viewMatrix),this._viewMatrix},r.prototype.createRigCamera=function(t,i){if(this.cameraRigMode!==e.Camera.RIG_MODE_NONE){var n=new r(t,this.position.clone(),this.getScene());return this.cameraRigMode!==e.Camera.RIG_MODE_VR&&this.cameraRigMode!==e.Camera.RIG_MODE_WEBVR||(this.rotationQuaternion||(this.rotationQuaternion=new e.Quaternion),n._cameraRigParams={},n.rotationQuaternion=new e.Quaternion),n}return null},r.prototype._updateRigCameras=function(){var r=this._rigCameras[0],i=this._rigCameras[1];switch(this.cameraRigMode){case e.Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:case e.Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER:var n=this.cameraRigMode===e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED?1:-1,o=this.cameraRigMode===e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED?-1:1;this._getRigCamPosition(this._cameraRigParams.stereoHalfAngle*n,r.position),this._getRigCamPosition(this._cameraRigParams.stereoHalfAngle*o,i.position),r.setTarget(this.getTarget()),i.setTarget(this.getTarget());break;case e.Camera.RIG_MODE_VR:r.rotationQuaternion?(r.rotationQuaternion.copyFrom(this.rotationQuaternion),i.rotationQuaternion.copyFrom(this.rotationQuaternion)):(r.rotation.copyFrom(this.rotation),i.rotation.copyFrom(this.rotation)),r.position.copyFrom(this.position),i.position.copyFrom(this.position)}t.prototype._updateRigCameras.call(this)},r.prototype._getRigCamPosition=function(t,r){this._rigCamTransformMatrix||(this._rigCamTransformMatrix=new e.Matrix);var i=this.getTarget();e.Matrix.Translation(-i.x,-i.y,-i.z).multiplyToRef(e.Matrix.RotationY(t),this._rigCamTransformMatrix),this._rigCamTransformMatrix=this._rigCamTransformMatrix.multiply(e.Matrix.Translation(i.x,i.y,i.z)),e.Vector3.TransformCoordinatesToRef(this.position,this._rigCamTransformMatrix,r)},r.prototype.getClassName=function(){return"TargetCamera"},__decorate([e.serializeAsVector3()],r.prototype,"rotation",void 0),__decorate([e.serialize()],r.prototype,"speed",void 0),__decorate([e.serializeAsMeshReference("lockedTargetId")],r.prototype,"lockedTarget",void 0),r})(e.Camera);e.TargetCamera=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,r){var i=this;t.tabIndex=1,this._onKeyDown=function(e){if(-1!==i.keysUp.indexOf(e.keyCode)||-1!==i.keysDown.indexOf(e.keyCode)||-1!==i.keysLeft.indexOf(e.keyCode)||-1!==i.keysRight.indexOf(e.keyCode)){-1===i._keys.indexOf(e.keyCode)&&i._keys.push(e.keyCode),e.preventDefault&&(r||e.preventDefault())}},this._onKeyUp=function(e){if(-1!==i.keysUp.indexOf(e.keyCode)||-1!==i.keysDown.indexOf(e.keyCode)||-1!==i.keysLeft.indexOf(e.keyCode)||-1!==i.keysRight.indexOf(e.keyCode)){var t=i._keys.indexOf(e.keyCode);t>=0&&i._keys.splice(t,1),e.preventDefault&&(r||e.preventDefault())}},this._onLostFocus=function(){i._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<this._keys.length;t++){var r=this._keys[t];-1!==this.keysLeft.indexOf(r)?e.inertialAlphaOffset-=.01:-1!==this.keysUp.indexOf(r)?e.inertialBetaOffset-=.01:-1!==this.keysRight.indexOf(r)?e.inertialAlphaOffset+=.01:-1!==this.keysDown.indexOf(r)&&(e.inertialBetaOffset+=.01)}},t.prototype.getClassName=function(){return"ArcRotateCameraKeyboardMoveInput"},t.prototype.getSimpleName=function(){return"keyboard"},__decorate([e.serialize()],t.prototype,"keysUp",void 0),__decorate([e.serialize()],t.prototype,"keysDown",void 0),__decorate([e.serialize()],t.prototype,"keysLeft",void 0),__decorate([e.serialize()],t.prototype,"keysRight",void 0),t})();e.ArcRotateCameraKeyboardMoveInput=t,e.CameraInputTypes.ArcRotateCameraKeyboardMoveInput=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){this.wheelPrecision=3}return t.prototype.attachControl=function(t,r){var i=this;this._wheel=function(t,n){if(t.type===e.PointerEventTypes.POINTERWHEEL){var o=t.event,s=0;o.wheelDelta?s=o.wheelDelta/(40*i.wheelPrecision):o.detail&&(s=-o.detail/i.wheelPrecision),s&&(i.camera.inertialRadiusOffset+=s),o.preventDefault&&(r||o.preventDefault())}},this._observer=this.camera.getScene().onPointerObservable.add(this._wheel,e.PointerEventTypes.POINTERWHEEL)},t.prototype.detachControl=function(e){this._observer&&e&&(this.camera.getScene().onPointerObservable.remove(this._observer),this._observer=null,this._wheel=null)},t.prototype.getClassName=function(){return"ArcRotateCameraMouseWheelInput"},t.prototype.getSimpleName=function(){return"mousewheel"},__decorate([e.serialize()],t.prototype,"wheelPrecision",void 0),t})();e.ArcRotateCameraMouseWheelInput=t,e.CameraInputTypes.ArcRotateCameraMouseWheelInput=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(e.Tools.GetPointerPrefix(),(function(){function t(){this.buttons=[0,1,2],this.angularSensibilityX=1e3,this.angularSensibilityY=1e3,this.pinchPrecision=6,this.panningSensibility=50,this._isPanClick=!1,this.pinchInwards=!0}return t.prototype.attachControl=function(t,r){var i,n,o,s=this,a=this.camera.getEngine(),u=0;this._pointerInput=function(a,l){var h=a.event;if(a.type===e.PointerEventTypes.POINTERMOVE||-1!==s.buttons.indexOf(h.button))if(a.type===e.PointerEventTypes.POINTERDOWN){try{h.srcElement.setPointerCapture(h.pointerId)}catch(e){}s._isPanClick=h.button===s.camera._panningMouseButton,i={x:h.clientX,y:h.clientY,pointerId:h.pointerId,type:h.pointerType},void 0===n?n=i:void 0===o&&(o=i),r||(h.preventDefault(),t.focus())}else if(a.type===e.PointerEventTypes.POINTERUP){try{h.srcElement.releasePointerCapture(h.pointerId)}catch(e){}i=null,u=0,n=o=void 0,r||h.preventDefault()}else if(a.type===e.PointerEventTypes.POINTERMOVE)if(r||h.preventDefault(),n&&void 0===o){if(0!==s.panningSensibility&&(h.ctrlKey&&s.camera._useCtrlForPanning||!s.camera._useCtrlForPanning&&s._isPanClick))s.camera.inertialPanningX+=-(h.clientX-i.x)/s.panningSensibility,s.camera.inertialPanningY+=(h.clientY-i.y)/s.panningSensibility;else{var c=h.clientX-i.x,f=h.clientY-i.y;s.camera.inertialAlphaOffset-=c/s.angularSensibilityX,s.camera.inertialBetaOffset-=f/s.angularSensibilityY}i.x=h.clientX,i.y=h.clientY}else if(n&&o){var d=n.pointerId===h.pointerId?n:o;d.x=h.clientX,d.y=h.clientY;var p=s.pinchInwards?1:-1,g=n.x-o.x,_=n.y-o.y,m=g*g+_*_;if(0===u)return void(u=m);m!==u&&(s.camera.inertialRadiusOffset+=(m-u)/(s.pinchPrecision*((s.angularSensibilityX+s.angularSensibilityY)/2)*p),u=m)}},this._observer=this.camera.getScene().onPointerObservable.add(this._pointerInput,e.PointerEventTypes.POINTERDOWN|e.PointerEventTypes.POINTERUP|e.PointerEventTypes.POINTERMOVE),this._onContextMenu=function(e){e.preventDefault()},this.camera._useCtrlForPanning||t.addEventListener("contextmenu",this._onContextMenu,!1),this._onLostFocus=function(){n=o=void 0,u=0,i=null},this._onMouseMove=function(e){if(a.isPointerLock){var t=e.movementX||e.mozMovementX||e.webkitMovementX||e.msMovementX||0,i=e.movementY||e.mozMovementY||e.webkitMovementY||e.msMovementY||0;s.camera.inertialAlphaOffset-=t/s.angularSensibilityX,s.camera.inertialBetaOffset-=i/s.angularSensibilityY,r||e.preventDefault()}},this._onGestureStart=function(e){void 0!==window.MSGesture&&(s._MSGestureHandler||(s._MSGestureHandler=new MSGesture,s._MSGestureHandler.target=t),s._MSGestureHandler.addPointer(e.pointerId))},this._onGesture=function(e){s.camera.radius*=e.scale,e.preventDefault&&(r||(e.stopPropagation(),e.preventDefault()))},t.addEventListener("mousemove",this._onMouseMove,!1),t.addEventListener("MSPointerDown",this._onGestureStart,!1),t.addEventListener("MSGestureChange",this._onGesture,!1),e.Tools.RegisterTopRootEvents([{name:"blur",handler:this._onLostFocus}])},t.prototype.detachControl=function(t){e.Tools.UnregisterTopRootEvents([{name:"blur",handler:this._onLostFocus}]),t&&this._observer&&(this.camera.getScene().onPointerObservable.remove(this._observer),this._observer=null,t.removeEventListener("contextmenu",this._onContextMenu),t.removeEventListener("mousemove",this._onMouseMove),t.removeEventListener("MSPointerDown",this._onGestureStart),t.removeEventListener("MSGestureChange",this._onGesture),this._isPanClick=!1,this.pinchInwards=!0,this._onMouseMove=null,this._onGestureStart=null,this._onGesture=null,this._MSGestureHandler=null,this._onLostFocus=null,this._onContextMenu=null)},t.prototype.getClassName=function(){return"ArcRotateCameraPointersInput"},t.prototype.getSimpleName=function(){return"pointers"},__decorate([e.serialize()],t.prototype,"buttons",void 0),__decorate([e.serialize()],t.prototype,"angularSensibilityX",void 0),__decorate([e.serialize()],t.prototype,"angularSensibilityY",void 0),__decorate([e.serialize()],t.prototype,"pinchPrecision",void 0),__decorate([e.serialize()],t.prototype,"panningSensibility",void 0),t})());e.ArcRotateCameraPointersInput=t,e.CameraInputTypes.ArcRotateCameraPointersInput=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(r,i,n,o,s,a){var u=t.call(this,r,e.Vector3.Zero(),a)||this;return u.inertialAlphaOffset=0,u.inertialBetaOffset=0,u.inertialRadiusOffset=0,u.lowerAlphaLimit=null,u.upperAlphaLimit=null,u.lowerBetaLimit=.01,u.upperBetaLimit=Math.PI,u.lowerRadiusLimit=null,u.upperRadiusLimit=null,u.inertialPanningX=0,u.inertialPanningY=0,u.panningInertia=.9,u.zoomOnFactor=1,u.targetScreenOffset=e.Vector2.Zero(),u.allowUpsideDown=!0,u._viewMatrix=new e.Matrix,u.panningAxis=new e.Vector3(1,1,0),u.onMeshTargetChangedObservable=new e.Observable,u.checkCollisions=!1,u.collisionRadius=new e.Vector3(.5,.5,.5),u._previousPosition=e.Vector3.Zero(),u._collisionVelocity=e.Vector3.Zero(),u._newPosition=e.Vector3.Zero(),u._onCollisionPositionChange=function(t,r,i){void 0===i&&(i=null),u.getScene().workerCollisions&&u.checkCollisions&&r.multiplyInPlace(u._collider.radius),i?(u.setPosition(r),u.onCollide&&u.onCollide(i)):u._previousPosition.copyFrom(u.position);var n=Math.cos(u.alpha),o=Math.sin(u.alpha),s=Math.cos(u.beta),a=Math.sin(u.beta);0===a&&(a=1e-4);var l=u._getTargetPosition();l.addToRef(new e.Vector3(u.radius*n*a,u.radius*s,u.radius*o*a),u._newPosition),u.position.copyFrom(u._newPosition);var h=u.upVector;u.allowUpsideDown&&u.beta<0&&(h=h.clone(),h=h.negate()),e.Matrix.LookAtLHToRef(u.position,l,h,u._viewMatrix),u._viewMatrix.m[12]+=u.targetScreenOffset.x,u._viewMatrix.m[13]+=u.targetScreenOffset.y,u._collisionTriggered=!1},u._target=e.Vector3.Zero(),s&&u.setTarget(s),u.alpha=i,u.beta=n,u.radius=o,u.getViewMatrix(),u.inputs=new e.ArcRotateCameraInputsManager(u),u.inputs.addKeyboard().addMouseWheel().addPointers(),u}return __extends(r,t),Object.defineProperty(r.prototype,"target",{get:function(){return this._target},set:function(e){this.setTarget(e)},enumerable:!0,configurable:!0}),Object.defineProperty(r.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(r.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(r.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(r.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(r.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(r.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(r.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(r.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(r.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}),Object.defineProperty(r.prototype,"useBouncingBehavior",{get:function(){return null!=this._bouncingBehavior},set:function(t){t!==this.useBouncingBehavior&&(t?(this._bouncingBehavior=new e.BouncingBehavior,this.addBehavior(this._bouncingBehavior)):(this.removeBehavior(this._bouncingBehavior),this._bouncingBehavior=null))},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"useFramingBehavior",{get:function(){return null!=this._framingBehavior},set:function(t){t!==this.useFramingBehavior&&(t?(this._framingBehavior=new e.FramingBehavior,this.addBehavior(this._framingBehavior)):(this.removeBehavior(this._framingBehavior),this._framingBehavior=null))},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"useAutoRotationBehavior",{get:function(){return null!=this._autoRotationBehavior},set:function(t){t!==this.useAutoRotationBehavior&&(t?(this._autoRotationBehavior=new e.AutoRotationBehavior,this.addBehavior(this._autoRotationBehavior)):(this.removeBehavior(this._autoRotationBehavior),this._autoRotationBehavior=null))},enumerable:!0,configurable:!0}),r.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()},r.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)},r.prototype._getTargetPosition=function(){if(this._targetHost&&this._targetHost.getAbsolutePosition){var e=this._targetHost.getAbsolutePosition();this._targetBoundingCenter?e.addToRef(this._targetBoundingCenter,this._target):this._target.copyFrom(e)}var t=this._getLockedTargetPosition();return t||this._target},r.prototype._isSynchronizedViewMatrix=function(){return!!t.prototype._isSynchronizedViewMatrix.call(this)&&(this._cache._target.equals(this._getTargetPosition())&&this._cache.alpha===this.alpha&&this._cache.beta===this.beta&&this._cache.radius===this.radius&&this._cache.targetScreenOffset.equals(this.targetScreenOffset))},r.prototype.attachControl=function(e,t,r,i){var n=this;void 0===r&&(r=!0),void 0===i&&(i=2),this._useCtrlForPanning=r,this._panningMouseButton=i,this.inputs.attachElement(e,t),this._reset=function(){n.inertialAlphaOffset=0,n.inertialBetaOffset=0,n.inertialRadiusOffset=0}},r.prototype.detachControl=function(e){this.inputs.detachElement(e),this._reset&&this._reset()},r.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)<e.Epsilon&&(this.inertialAlphaOffset=0),Math.abs(this.inertialBetaOffset)<e.Epsilon&&(this.inertialBetaOffset=0),Math.abs(this.inertialRadiusOffset)<this.speed*e.Epsilon&&(this.inertialRadiusOffset=0)),0===this.inertialPanningX&&0===this.inertialPanningY||(this._localDirection||(this._localDirection=e.Vector3.Zero(),this._transformedDirection=e.Vector3.Zero()),this._localDirection.copyFromFloats(this.inertialPanningX,this.inertialPanningY,this.inertialPanningY),this._localDirection.multiplyInPlace(this.panningAxis),this._viewMatrix.invertToRef(this._cameraTransformMatrix),e.Vector3.TransformNormalToRef(this._localDirection,this._cameraTransformMatrix,this._transformedDirection),this.panningAxis.y||(this._transformedDirection.y=0),this._targetHost||this._target.addInPlace(this._transformedDirection),this.inertialPanningX*=this.panningInertia,this.inertialPanningY*=this.panningInertia,Math.abs(this.inertialPanningX)<this.speed*e.Epsilon&&(this.inertialPanningX=0),Math.abs(this.inertialPanningY)<this.speed*e.Epsilon&&(this.inertialPanningY=0)),this._checkLimits(),t.prototype._checkInputs.call(this))},r.prototype._checkLimits=function(){null===this.lowerBetaLimit||void 0===this.lowerBetaLimit?this.allowUpsideDown&&this.beta>Math.PI&&(this.beta=this.beta-2*Math.PI):this.beta<this.lowerBetaLimit&&(this.beta=this.lowerBetaLimit),null===this.upperBetaLimit||void 0===this.upperBetaLimit?this.allowUpsideDown&&this.beta<-Math.PI&&(this.beta=this.beta+2*Math.PI):this.beta>this.upperBetaLimit&&(this.beta=this.upperBetaLimit),this.lowerAlphaLimit&&this.alpha<this.lowerAlphaLimit&&(this.alpha=this.lowerAlphaLimit),this.upperAlphaLimit&&this.alpha>this.upperAlphaLimit&&(this.alpha=this.upperAlphaLimit),this.lowerRadiusLimit&&this.radius<this.lowerRadiusLimit&&(this.radius=this.lowerRadiusLimit),this.upperRadiusLimit&&this.radius>this.upperRadiusLimit&&(this.radius=this.upperRadiusLimit)},r.prototype.rebuildAnglesAndRadius=function(){var e=this.position.subtract(this._getTargetPosition());this.radius=e.length(),0===this.radius&&(this.radius=1e-4),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()},r.prototype.setPosition=function(e){this.position.equals(e)||(this.position.copyFrom(e),this.rebuildAnglesAndRadius())},r.prototype.setTarget=function(e,t,r){if(void 0===t&&(t=!1),void 0===r&&(r=!1),e.getBoundingInfo)this._targetBoundingCenter=t?e.getBoundingInfo().boundingBox.centerWorld.clone():null,this._targetHost=e,this._target=this._getTargetPosition(),this.onMeshTargetChangedObservable.notifyObservers(this._targetHost);else{var i=e,n=this._getTargetPosition();if(n&&!r&&n.equals(i))return;this._targetHost=null,this._target=i,this._targetBoundingCenter=null,this.onMeshTargetChangedObservable.notifyObservers(null)}this.rebuildAnglesAndRadius()},r.prototype._getViewMatrix=function(){var t=Math.cos(this.alpha),r=Math.sin(this.alpha),i=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*i,this.radius*r*n),this._newPosition),this.getScene().collisionsEnabled&&this.checkCollisions)this._collider||(this._collider=new e.Collider),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&&n<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},r.prototype.zoomOn=function(t,r){void 0===r&&(r=!1),t=t||this.getScene().meshes;var i=e.Mesh.MinMax(t),n=e.Vector3.Distance(i.min,i.max);this.radius=n*this.zoomOnFactor,this.focusOn({min:i.min,max:i.max,distance:n},r)},r.prototype.focusOn=function(t,r){void 0===r&&(r=!1);var i,n;void 0===t.min?(i=t||this.getScene().meshes,i=e.Mesh.MinMax(i),n=e.Vector3.Distance(i.min,i.max)):(i=t,n=t.distance),this._target=e.Mesh.Center(i),r||(this.maxZ=2*n)},r.prototype.createRigCamera=function(t,i){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===i?1:-1);break;case e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:n=this._cameraRigParams.stereoHalfAngle*(0===i?-1:1)}var o=new r(t,this.alpha+n,this.beta,this.radius,this._target,this.getScene());return o._cameraRigParams={},o},r.prototype._updateRigCameras=function(){var r=this._rigCameras[0],i=this._rigCameras[1];switch(r.beta=i.beta=this.beta,r.radius=i.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:r.alpha=this.alpha-this._cameraRigParams.stereoHalfAngle,i.alpha=this.alpha+this._cameraRigParams.stereoHalfAngle;break;case e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:r.alpha=this.alpha+this._cameraRigParams.stereoHalfAngle,i.alpha=this.alpha-this._cameraRigParams.stereoHalfAngle}t.prototype._updateRigCameras.call(this)},r.prototype.dispose=function(){this.inputs.clear(),t.prototype.dispose.call(this)},r.prototype.getClassName=function(){return"ArcRotateCamera"},__decorate([e.serialize()],r.prototype,"alpha",void 0),__decorate([e.serialize()],r.prototype,"beta",void 0),__decorate([e.serialize()],r.prototype,"radius",void 0),__decorate([e.serializeAsVector3("target")],r.prototype,"_target",void 0),__decorate([e.serialize()],r.prototype,"inertialAlphaOffset",void 0),__decorate([e.serialize()],r.prototype,"inertialBetaOffset",void 0),__decorate([e.serialize()],r.prototype,"inertialRadiusOffset",void 0),__decorate([e.serialize()],r.prototype,"lowerAlphaLimit",void 0),__decorate([e.serialize()],r.prototype,"upperAlphaLimit",void 0),__decorate([e.serialize()],r.prototype,"lowerBetaLimit",void 0),__decorate([e.serialize()],r.prototype,"upperBetaLimit",void 0),__decorate([e.serialize()],r.prototype,"lowerRadiusLimit",void 0),__decorate([e.serialize()],r.prototype,"upperRadiusLimit",void 0),__decorate([e.serialize()],r.prototype,"inertialPanningX",void 0),__decorate([e.serialize()],r.prototype,"inertialPanningY",void 0),__decorate([e.serialize()],r.prototype,"panningInertia",void 0),__decorate([e.serialize()],r.prototype,"zoomOnFactor",void 0),__decorate([e.serialize()],r.prototype,"allowUpsideDown",void 0),r})(e.TargetCamera);e.ArcRotateCamera=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(e){return t.call(this,e)||this}return __extends(r,t),r.prototype.addMouseWheel=function(){return this.add(new e.ArcRotateCameraMouseWheelInput),this},r.prototype.addPointers=function(){return this.add(new e.ArcRotateCameraPointersInput),this},r.prototype.addKeyboard=function(){return this.add(new e.ArcRotateCameraKeyboardMoveInput),this},r.prototype.addGamepad=function(){return this.add(new e.ArcRotateCameraGamepadInput),this},r.prototype.addVRDeviceOrientation=function(){return this.add(new e.ArcRotateCameraVRDeviceOrientationInput),this},r})(e.CameraInputsManager);e.ArcRotateCameraInputsManager=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(r,i,n,o,s,a,u,l,h,c){void 0===a&&(a=null),void 0===u&&(u=null),void 0===l&&(l=e.Engine.TEXTUREFORMAT_RGBA),void 0===h&&(h=!1),void 0===c&&(c=null);var f=t.call(this,i)||this;if(f.coordinatesMode=e.Texture.CUBIC_MODE,f.name=r,f.url=r,f._noMipmap=o,f.hasAlpha=!1,f._format=l,f._prefiltered=h,f.isCube=!0,f._textureMatrix=e.Matrix.Identity(),h&&(f.gammaSpace=!1),!r&&!s)return f;if(f._texture=f._getFromCache(r,o),!s){n||(n=["_px.jpg","_py.jpg","_pz.jpg","_nx.jpg","_ny.jpg","_nz.jpg"]),s=[];for(var d=0;d<n.length;d++)s.push(r+n[d]);f._extensions=n}return f._files=s,f._texture?a&&(f._texture.isReady?e.Tools.SetImmediate((function(){return a()})):f._texture.onLoadedCallbacks.push(a)):i.useDelayedTextureLoading?f.delayLoadState=e.Engine.DELAYLOADSTATE_NOTLOADED:f._texture=h?i.getEngine().createPrefilteredCubeTexture(r,i,f.lodGenerationScale,f.lodGenerationOffset,a,u,l,c):i.getEngine().createCubeTexture(r,i,s,o,a,u,f._format,c),f}return __extends(r,t),r.CreateFromImages=function(e,t,i){return new r("",t,null,i,e)},r.CreateFromPrefilteredData=function(e,t,i){return void 0===i&&(i=null),new r(e,t,null,!1,null,null,null,void 0,!0,i)},r.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._prefiltered?this._texture=this.getScene().getEngine().createPrefilteredCubeTexture(this.url,this.getScene(),this.lodGenerationScale,this.lodGenerationOffset,void 0,void 0,this._format):this._texture=this.getScene().getEngine().createCubeTexture(this.url,this.getScene(),this._files,this._noMipmap,void 0,void 0,this._format)))},r.prototype.getReflectionTextureMatrix=function(){return this._textureMatrix},r.prototype.setReflectionTextureMatrix=function(e){this._textureMatrix=e},r.Parse=function(t,r,i){var n=e.SerializationHelper.Parse((function(){return new e.CubeTexture(i+t.name,r,t.extensions)}),t,r);if(t.animations)for(var o=0;o<t.animations.length;o++){var s=t.animations[o];n.animations.push(e.Animation.Parse(s))}return n},r.prototype.clone=function(){var t=this;return e.SerializationHelper.Clone((function(){return new r(t.url,t.getScene(),t._extensions,t._noMipmap,t._files)}),this)},r})(e.BaseTexture);e.CubeTexture=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(r,i,n,o,s,a,u,l,h,c,f){void 0===s&&(s=!0),void 0===a&&(a=e.Engine.TEXTURETYPE_UNSIGNED_INT),void 0===u&&(u=!1),void 0===l&&(l=e.Texture.TRILINEAR_SAMPLINGMODE),void 0===h&&(h=!0),void 0===c&&(c=!1),void 0===f&&(f=!1);var d=t.call(this,null,n,!o)||this;return d.isCube=u,d.renderList=new Array,d.renderParticles=!0,d.renderSprites=!1,d.coordinatesMode=e.Texture.PROJECTION_MODE,d.ignoreCameraViewport=!1,d.onBeforeBindObservable=new e.Observable,d.onAfterUnbindObservable=new e.Observable,d.onBeforeRenderObservable=new e.Observable,d.onAfterRenderObservable=new e.Observable,d.onClearObservable=new e.Observable,d._currentRefreshId=-1,d._refreshRate=1,d._samples=1,n=d.getScene(),d.name=r,d.isRenderTarget=!0,d._size=i,d._generateMipMaps=o,d._doNotChangeAspectRatio=s,d._renderingManager=new e.RenderingManager(n),f?d:(d._renderTargetOptions={generateMipMaps:o,type:a,samplingMode:l,generateDepthBuffer:h,generateStencilBuffer:c},l===e.Texture.NEAREST_SAMPLINGMODE&&(d.wrapU=e.Texture.CLAMP_ADDRESSMODE,d.wrapV=e.Texture.CLAMP_ADDRESSMODE),u?(d._texture=n.getEngine().createRenderTargetCubeTexture(i,d._renderTargetOptions),d.coordinatesMode=e.Texture.INVCUBIC_MODE,d._textureMatrix=e.Matrix.Identity()):d._texture=n.getEngine().createRenderTargetTexture(i,d._renderTargetOptions),d)}return __extends(r,t),Object.defineProperty(r,"REFRESHRATE_RENDER_ONCE",{get:function(){return r._REFRESHRATE_RENDER_ONCE},enumerable:!0,configurable:!0}),Object.defineProperty(r,"REFRESHRATE_RENDER_ONEVERYFRAME",{get:function(){return r._REFRESHRATE_RENDER_ONEVERYFRAME},enumerable:!0,configurable:!0}),Object.defineProperty(r,"REFRESHRATE_RENDER_ONEVERYTWOFRAMES",{get:function(){return r._REFRESHRATE_RENDER_ONEVERYTWOFRAMES},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"onAfterUnbind",{set:function(e){this._onAfterUnbindObserver&&this.onAfterUnbindObservable.remove(this._onAfterUnbindObserver),this._onAfterUnbindObserver=this.onAfterUnbindObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"onBeforeRender",{set:function(e){this._onBeforeRenderObserver&&this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),this._onBeforeRenderObserver=this.onBeforeRenderObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"onAfterRender",{set:function(e){this._onAfterRenderObserver&&this.onAfterRenderObservable.remove(this._onAfterRenderObserver),this._onAfterRenderObserver=this.onAfterRenderObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"onClear",{set:function(e){this._onClearObserver&&this.onClearObservable.remove(this._onClearObserver),this._onClearObserver=this.onClearObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"renderTargetOptions",{get:function(){return this._renderTargetOptions},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"samples",{get:function(){return this._samples},set:function(e){this._samples!==e&&(this._samples=this.getScene().getEngine().updateRenderTargetTextureSampleCount(this._texture,e))},enumerable:!0,configurable:!0}),r.prototype.resetRefreshCounter=function(){this._currentRefreshId=-1},Object.defineProperty(r.prototype,"refreshRate",{get:function(){return this._refreshRate},set:function(e){this._refreshRate=e,this.resetRefreshCounter()},enumerable:!0,configurable:!0}),r.prototype.addPostProcess=function(t){this._postProcessManager||(this._postProcessManager=new e.PostProcessManager(this.getScene()),this._postProcesses=new Array),this._postProcesses.push(t),this._postProcesses[0].autoClear=!1},r.prototype.clearPostProcesses=function(e){if(this._postProcesses){if(e)for(var t=0,r=this._postProcesses;t<r.length;t++){var i=r[t];i.dispose(),i=null}this._postProcesses=[]}},r.prototype.removePostProcess=function(e){if(this._postProcesses){var t=this._postProcesses.indexOf(e);-1!==t&&(this._postProcesses.splice(t,1),this._postProcesses.length>0&&(this._postProcesses[0].autoClear=!1))}},r.prototype._shouldRender=function(){return-1===this._currentRefreshId?(this._currentRefreshId=1,!0):this.refreshRate===this._currentRefreshId?(this._currentRefreshId=1,!0):(this._currentRefreshId++,!1)},r.prototype.isReady=function(){
- return!!this.getScene().renderTargetsEnabled&&t.prototype.isReady.call(this)},r.prototype.getRenderSize=function(){return this._size},Object.defineProperty(r.prototype,"canRescale",{get:function(){return!0},enumerable:!0,configurable:!0}),r.prototype.scale=function(e){var t=this._size*e;this.resize(t)},r.prototype.getReflectionTextureMatrix=function(){return this.isCube?this._textureMatrix:t.prototype.getReflectionTextureMatrix.call(this)},r.prototype.resize=function(e){this.releaseInternalTexture(),this.isCube?this._texture=this.getScene().getEngine().createRenderTargetCubeTexture(e,this._renderTargetOptions):this._texture=this.getScene().getEngine().createRenderTargetTexture(e,this._renderTargetOptions)},r.prototype.render=function(e,t){var r=this.getScene(),i=r.getEngine();if(void 0!==this.useCameraPostProcesses&&(e=this.useCameraPostProcesses),this._waitingRenderList){this.renderList=[];for(var n=0;n<this._waitingRenderList.length;n++){var o=this._waitingRenderList[n];this.renderList.push(r.getMeshByID(o))}delete this._waitingRenderList}if(this.renderListPredicate){this.renderList.splice(0);for(var s=this.getScene().meshes,n=0;n<s.length;n++){var a=s[n];this.renderListPredicate(a)&&this.renderList.push(a)}}if(!this.renderList||0!==this.renderList.length){this.onBeforeBindObservable.notifyObservers(this);var u;this.activeCamera?(u=this.activeCamera,i.setViewport(this.activeCamera.viewport,this._size,this._size),this.activeCamera!==r.activeCamera&&r.setTransformMatrix(this.activeCamera.getViewMatrix(),this.activeCamera.getProjectionMatrix(!0))):(u=r.activeCamera,i.setViewport(r.activeCamera.viewport,this._size,this._size)),this._renderingManager.reset();for(var l=this.renderList?this.renderList:r.getActiveMeshes().data,h=this.renderList?this.renderList.length:r.getActiveMeshes().length,c=r.getRenderId(),f=0;f<h;f++){var a=l[f];if(a){if(!a.isReady()){this.resetRefreshCounter();continue}a._preActivateForIntermediateRendering(c);var d=void 0;if(d=!this.renderList&&0==(a.layerMask&u.layerMask),a.isEnabled()&&a.isVisible&&a.subMeshes&&!d){a._activate(c);for(var p=0;p<a.subMeshes.length;p++){var g=a.subMeshes[p];r._activeIndices.addCount(g.indexCount,!1),this._renderingManager.dispatch(g)}}}}for(var _=0;_<r.particleSystems.length;_++){var m=r.particleSystems[_],v=m.emitter;m.isStarted()&&v&&v.position&&v.isEnabled()&&(l.indexOf(v)>=0&&this._renderingManager.dispatchParticles(m))}if(this.isCube)for(var y=0;y<6;y++)this.renderToTarget(y,l,h,e,t),r.incrementRenderId(),r.resetCachedMaterial();else this.renderToTarget(0,l,h,e,t);this.onAfterUnbindObservable.notifyObservers(this),this.activeCamera&&this.activeCamera!==r.activeCamera&&r.setTransformMatrix(r.activeCamera.getViewMatrix(),r.activeCamera.getProjectionMatrix(!0)),i.setViewport(r.activeCamera.viewport),r.resetCachedMaterial()}},r.prototype.renderToTarget=function(t,r,i,n,o){var s=this,a=this.getScene(),u=a.getEngine();this._postProcessManager?this._postProcessManager._prepareFrame(this._texture,this._postProcesses):n&&a.postProcessManager._prepareFrame(this._texture)||u.bindFramebuffer(this._texture,this.isCube?t:void 0,void 0,void 0,this.ignoreCameraViewport),this.onBeforeRenderObservable.notifyObservers(t),this.onClearObservable.hasObservers()?this.onClearObservable.notifyObservers(u):u.clear(a.clearColor,!0,!0,!0),this._doNotChangeAspectRatio||a.updateTransformMatrix(!0),this._renderingManager.render(this.customRenderFunction,r,this.renderParticles,this.renderSprites),this._postProcessManager?this._postProcessManager._finalizeFrame(!1,this._texture,t,this._postProcesses):n&&a.postProcessManager._finalizeFrame(!1,this._texture,t),this._doNotChangeAspectRatio||a.updateTransformMatrix(!0),o&&e.Tools.DumpFramebuffer(this._size,this._size,u),this.isCube&&5!==t?this.onAfterRenderObservable.notifyObservers(t):(this.isCube&&5===t&&u.generateMipMapsForCubemap(this._texture),u.unBindFramebuffer(this._texture,this.isCube,(function(){s.onAfterRenderObservable.notifyObservers(t)})))},r.prototype.setRenderingOrder=function(e,t,r,i){void 0===t&&(t=null),void 0===r&&(r=null),void 0===i&&(i=null),this._renderingManager.setRenderingOrder(e,t,r,i)},r.prototype.setRenderingAutoClearDepthStencil=function(e,t){this._renderingManager.setRenderingAutoClearDepthStencil(e,t)},r.prototype.clone=function(){var e=this.getSize(),t=new r(this.name,e.width,this.getScene(),this._renderTargetOptions.generateMipMaps,this._doNotChangeAspectRatio,this._renderTargetOptions.type,this.isCube,this._renderTargetOptions.samplingMode,this._renderTargetOptions.generateDepthBuffer,this._renderTargetOptions.generateStencilBuffer);return t.hasAlpha=this.hasAlpha,t.level=this.level,t.coordinatesMode=this.coordinatesMode,t.renderList=this.renderList.slice(0),t},r.prototype.serialize=function(){if(!this.name)return null;var e=t.prototype.serialize.call(this);e.renderTargetSize=this.getRenderSize(),e.renderList=[];for(var r=0;r<this.renderList.length;r++)e.renderList.push(this.renderList[r].id);return e},r.prototype.disposeFramebufferObjects=function(){this.getScene().getEngine()._releaseFramebufferObjects(this.getInternalTexture())},r.prototype.dispose=function(){this._postProcessManager&&(this._postProcessManager.dispose(),this._postProcessManager=null),this.clearPostProcesses(!0),this.renderList=null;var e=this.getScene(),r=e.customRenderTargets.indexOf(this);r>=0&&e.customRenderTargets.splice(r,1);for(var i=0,n=e.cameras;i<n.length;i++){var o=n[i];r=o.customRenderTargets.indexOf(this),r>=0&&o.customRenderTargets.splice(r,1)}t.prototype.dispose.call(this)},r._REFRESHRATE_RENDER_ONCE=0,r._REFRESHRATE_RENDER_ONEVERYFRAME=1,r._REFRESHRATE_RENDER_ONEVERYTWOFRAMES=2,r})(e.Texture);e.RenderTargetTexture=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(r,i,n,o,s){var a=this;s=s||{};var u=!!s.generateMipMaps&&s.generateMipMaps,l=!!s.generateDepthTexture&&s.generateDepthTexture,h=void 0===s.doNotChangeAspectRatio||s.doNotChangeAspectRatio;if(a=t.call(this,r,i,o,u,h)||this,!a.isSupported)return void a.dispose();for(var c=[],f=[],d=0;d<n;d++)s.types&&s.types[d]?c.push(s.types[d]):c.push(e.Engine.TEXTURETYPE_FLOAT),s.samplingModes&&s.samplingModes[d]?f.push(s.samplingModes[d]):f.push(e.Texture.BILINEAR_SAMPLINGMODE);var p=void 0===s.generateDepthBuffer||s.generateDepthBuffer,g=void 0!==s.generateStencilBuffer&&s.generateStencilBuffer;return a._count=n,a._size=i,a._multiRenderTargetOptions={samplingModes:f,generateMipMaps:u,generateDepthBuffer:p,generateStencilBuffer:g,generateDepthTexture:l,types:c,textureCount:n},a._webGLTextures=o.getEngine().createMultipleRenderTarget(i,a._multiRenderTargetOptions),a._createInternalTextures(),a}return __extends(r,t),Object.defineProperty(r.prototype,"isSupported",{get:function(){var e=this.getScene().getEngine();return e.webGLVersion>1||e.getCaps().drawBuffersExtension},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"textures",{get:function(){return this._textures},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"depthTexture",{get:function(){return this._textures[this._textures.length-1]},enumerable:!0,configurable:!0}),r.prototype._createInternalTextures=function(){this._textures=[];for(var t=0;t<this._webGLTextures.length;t++){var r=new e.Texture(null,this.getScene());r._texture=this._webGLTextures[t],this._textures.push(r)}this._texture=this._webGLTextures[0]},Object.defineProperty(r.prototype,"samples",{get:function(){return this._samples},set:function(e){if(this._samples!==e)for(var t=0;t<this._webGLTextures.length;t++)this._samples=this.getScene().getEngine().updateRenderTargetTextureSampleCount(this._webGLTextures[t],e)},enumerable:!0,configurable:!0}),r.prototype.resize=function(e){this.releaseInternalTextures(),this._webGLTextures=this.getScene().getEngine().createMultipleRenderTarget(e,this._multiRenderTargetOptions),this._createInternalTextures()},r.prototype.dispose=function(){this.releaseInternalTextures(),t.prototype.dispose.call(this)},r.prototype.releaseInternalTextures=function(){if(this._webGLTextures)for(var e=this._webGLTextures.length-1;e>=0;e--)void 0!==this._webGLTextures[e]&&(this.getScene().getEngine().releaseInternalTexture(this._webGLTextures[e]),this._webGLTextures.splice(e,1))},r})(e.RenderTargetTexture);e.MultiRenderTarget=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(r,i,n,o,s,a,u){void 0===s&&(s=e.Engine.TEXTURETYPE_UNSIGNED_INT),void 0===a&&(a=e.Texture.BILINEAR_SAMPLINGMODE),void 0===u&&(u=!0);var l=t.call(this,r,i,n,o,!0,s,!1,a,u)||this;return l.mirrorPlane=new e.Plane(0,1,0,1),l._transformMatrix=e.Matrix.Zero(),l._mirrorMatrix=e.Matrix.Zero(),l._blurKernelX=0,l._blurKernelY=0,l._blurRatio=1,l.onBeforeRenderObservable.add((function(){e.Matrix.ReflectionToRef(l.mirrorPlane,l._mirrorMatrix),l._savedViewMatrix=n.getViewMatrix(),l._mirrorMatrix.multiplyToRef(l._savedViewMatrix,l._transformMatrix),n.setTransformMatrix(l._transformMatrix,n.getProjectionMatrix()),n.clipPlane=l.mirrorPlane,n.getEngine().cullBackFaces=!1,n._mirroredCameraPosition=e.Vector3.TransformCoordinates(n.activeCamera.globalPosition,l._mirrorMatrix)})),l.onAfterRenderObservable.add((function(){n.setTransformMatrix(l._savedViewMatrix,n.getProjectionMatrix()),n.getEngine().cullBackFaces=!0,n._mirroredCameraPosition=null,delete n.clipPlane})),l}return __extends(r,t),Object.defineProperty(r.prototype,"blurRatio",{get:function(){return this._blurRatio},set:function(e){this._blurRatio!==e&&(this._blurRatio=e,this._preparePostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"blurKernel",{set:function(e){this.blurKernelX=e,this.blurKernelY=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"blurKernelX",{get:function(){return this._blurKernelX},set:function(e){this._blurKernelX!==e&&(this._blurKernelX=e,this._preparePostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"blurKernelY",{get:function(){return this._blurKernelY},set:function(e){this._blurKernelY!==e&&(this._blurKernelY=e,this._preparePostProcesses())},enumerable:!0,configurable:!0}),r.prototype._preparePostProcesses=function(){if(this.clearPostProcesses(!0),this._blurKernelX&&this._blurKernelY){var t=this.getScene().getEngine(),r=t.getCaps().textureFloatRender?e.Engine.TEXTURETYPE_FLOAT:e.Engine.TEXTURETYPE_HALF_FLOAT;this._blurX=new e.BlurPostProcess("horizontal blur",new e.Vector2(1,0),this._blurKernelX,this._blurRatio,null,e.Texture.BILINEAR_SAMPLINGMODE,t,!1,r),this._blurX.autoClear=!1,1===this._blurRatio&&this.samples<2?this._blurX.outputTexture=this._texture:this._blurX.alwaysForcePOT=!0,this._blurY=new e.BlurPostProcess("vertical blur",new e.Vector2(0,1),this._blurKernelY,this._blurRatio,null,e.Texture.BILINEAR_SAMPLINGMODE,t,!1,r),this._blurY.autoClear=!1,this._blurY.alwaysForcePOT=1!==this._blurRatio,this.addPostProcess(this._blurX),this.addPostProcess(this._blurY)}},r.prototype.clone=function(){var e=this.getSize(),t=new r(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},r.prototype.serialize=function(){if(!this.name)return null;var e=t.prototype.serialize.call(this);return e.mirrorPlane=this.mirrorPlane.asArray(),e},r})(e.RenderTargetTexture);e.MirrorTexture=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(r,i,n,o){var s=t.call(this,r,i,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(r,t),r.prototype.clone=function(){var e=this.getSize(),t=new r(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},r.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},r})(e.RenderTargetTexture);e.RefractionTexture=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(r,i,n,o,s,a){void 0===s&&(s=e.Texture.TRILINEAR_SAMPLINGMODE),void 0===a&&(a=e.Engine.TEXTUREFORMAT_RGBA);var u=t.call(this,null,n,!o,void 0,s,void 0,void 0,void 0,void 0,a)||this;u.name=r;var l=u.getScene().getEngine();u.wrapU=e.Texture.CLAMP_ADDRESSMODE,u.wrapV=e.Texture.CLAMP_ADDRESSMODE,u._generateMipMaps=o,i.getContext?(u._canvas=i,u._texture=l.createDynamicTexture(i.width,i.height,o,s)):(u._canvas=document.createElement("canvas"),i.width?u._texture=l.createDynamicTexture(i.width,i.height,o,s):u._texture=l.createDynamicTexture(i,i,o,s));var h=u.getSize();return u._canvas.width=h.width,u._canvas.height=h.height,u._context=u._canvas.getContext("2d"),u}return __extends(r,t),Object.defineProperty(r.prototype,"canRescale",{get:function(){return!0},enumerable:!0,configurable:!0}),r.prototype._recreate=function(e){this._canvas.width=e.width,this._canvas.height=e.height,this.releaseInternalTexture(),this._texture=this.getScene().getEngine().createDynamicTexture(e.width,e.height,this._generateMipMaps,this._samplingMode)},r.prototype.scale=function(e){var t=this.getSize();t.width*=e,t.height*=e,this._recreate(t)},r.prototype.scaleTo=function(e,t){var r=this.getSize();r.width=e,r.height=t,this._recreate(r)},r.prototype.getContext=function(){return this._context},r.prototype.clear=function(){var e=this.getSize();this._context.fillRect(0,0,e.width,e.height)},r.prototype.update=function(e){this.getScene().getEngine().updateDynamicTexture(this._texture,this._canvas,void 0===e||e,void 0,this._format)},r.prototype.drawText=function(e,t,r,i,n,o,s,a){void 0===a&&(a=!0);var u=this.getSize();if(o&&(this._context.fillStyle=o,this._context.fillRect(0,0,u.width,u.height)),this._context.font=i,null===t||void 0===t){var l=this._context.measureText(e);t=(u.width-l.width)/2}if(null===r||void 0===r){var h=parseInt(i.replace(/\D/g,""));r=u.height/2+h/3.65}this._context.fillStyle=n,this._context.fillText(e,t,r),a&&this.update(s)},r.prototype.clone=function(){var e=this.getSize(),t=new r(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},r})(e.Texture);e.DynamicTexture=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(r,i,n,o,s,a){void 0===o&&(o=!1),void 0===s&&(s=!1),void 0===a&&(a=e.Texture.TRILINEAR_SAMPLINGMODE);var u=t.call(this,null,n,!o,s)||this;u._autoLaunch=!0;var l;return u.name=r,i instanceof HTMLVideoElement?u.video=i:(l=i,u.video=document.createElement("video"),u.video.autoplay=!1,u.video.loop=!0),u._generateMipMaps=o,u._samplingMode=a,!u.getScene().getEngine().needPOTTextures||e.Tools.IsExponentOfTwo(u.video.videoWidth)&&e.Tools.IsExponentOfTwo(u.video.videoHeight)?(u.wrapU=e.Texture.WRAP_ADDRESSMODE,u.wrapV=e.Texture.WRAP_ADDRESSMODE):(u.wrapU=e.Texture.CLAMP_ADDRESSMODE,u.wrapV=e.Texture.CLAMP_ADDRESSMODE,u._generateMipMaps=!1),l?(u.video.addEventListener("canplay",(function(){u._createTexture()})),l.forEach((function(e){var t=document.createElement("source");t.src=e,u.video.appendChild(t)}))):u._createTexture(),u._lastUpdate=e.Tools.Now,u}return __extends(r,t),r.prototype.__setTextureReady=function(){this._texture.isReady=!0},r.prototype._createTexture=function(){this._texture=this.getScene().getEngine().createDynamicTexture(this.video.videoWidth,this.video.videoHeight,this._generateMipMaps,this._samplingMode),this._autoLaunch&&(this._autoLaunch=!1,this.video.play()),this._setTextureReady=this.__setTextureReady.bind(this),this.video.addEventListener("playing",this._setTextureReady)},r.prototype.update=function(){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)},r.prototype.dispose=function(){t.prototype.dispose.call(this),this.video.removeEventListener("playing",this._setTextureReady)},r.CreateFromWebCam=function(t,r,i){var n,o=document.createElement("video");i&&i.deviceId&&(n={exact:i.deviceId}),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:{deviceId:n,width:{min:i&&i.minWidth||256,max:i&&i.maxWidth||640},height:{min:i&&i.minHeight||256,max:i&&i.maxHeight||480}}},(function(i){void 0!==o.mozSrcObject?o.mozSrcObject=i:o.src=window.URL&&window.URL.createObjectURL(i)||i,o.play(),r&&r(new e.VideoTexture("video",o,t,!0,!0))}),(function(t){e.Tools.Error(t.name)}))},r})(e.Texture);e.VideoTexture=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(r,i,n,o,s,a,u,l){void 0===a&&(a=!0),void 0===u&&(u=!1),void 0===l&&(l=e.Texture.TRILINEAR_SAMPLINGMODE);var h=t.call(this,null,s,!a,u)||this;return h.format=o,h._texture=s.getEngine().createRawTexture(r,i,n,o,a,u,l),h.wrapU=e.Texture.CLAMP_ADDRESSMODE,h.wrapV=e.Texture.CLAMP_ADDRESSMODE,h}return __extends(r,t),r.prototype.update=function(e){this.getScene().getEngine().updateRawTexture(this._texture,e,this.format,this._invertY)},r.CreateLuminanceTexture=function(t,i,n,o,s,a,u){return void 0===s&&(s=!0),void 0===a&&(a=!1),void 0===u&&(u=e.Texture.TRILINEAR_SAMPLINGMODE),new r(t,i,n,e.Engine.TEXTUREFORMAT_LUMINANCE,o,s,a,u)},r.CreateLuminanceAlphaTexture=function(t,i,n,o,s,a,u){return void 0===s&&(s=!0),void 0===a&&(a=!1),void 0===u&&(u=e.Texture.TRILINEAR_SAMPLINGMODE),new r(t,i,n,e.Engine.TEXTUREFORMAT_LUMINANCE_ALPHA,o,s,a,u)},r.CreateAlphaTexture=function(t,i,n,o,s,a,u){return void 0===s&&(s=!0),void 0===a&&(a=!1),void 0===u&&(u=e.Texture.TRILINEAR_SAMPLINGMODE),new r(t,i,n,e.Engine.TEXTUREFORMAT_ALPHA,o,s,a,u)},r.CreateRGBTexture=function(t,i,n,o,s,a,u){return void 0===s&&(s=!0),void 0===a&&(a=!1),void 0===u&&(u=e.Texture.TRILINEAR_SAMPLINGMODE),new r(t,i,n,e.Engine.TEXTUREFORMAT_RGB,o,s,a,u)},r.CreateRGBATexture=function(t,i,n,o,s,a,u){return void 0===s&&(s=!0),void 0===a&&(a=!1),void 0===u&&(u=e.Texture.TRILINEAR_SAMPLINGMODE),new r(t,i,n,e.Engine.TEXTUREFORMAT_RGBA,o,s,a,u)},r})(e.Texture);e.RawTexture=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(t){var r=(function(){function t(){}return t.GetTGAHeader=function(e){var t=0;return{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++]}},t.UploadContent=function(r,i){if(i.length<19)return void e.Tools.Error("Unable to load TGA file - Not enough data to contain header");var n=18,o=t.GetTGAHeader(i);if(o.id_length+n>i.length)return void e.Tools.Error("Unable to load TGA file - Not enough data");n+=o.id_length;var s=!1,a=!1,u=!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:!0;break;case t._TYPE_RLE_GREY:s=!0;case t._TYPE_GREY:u=!0}var l,h,c=(o.flags,o.pixel_size>>3),f=o.width*o.height*c;if(a&&(h=i.subarray(n,n+=o.colormap_length*(o.colormap_size>>3))),s){l=new Uint8Array(f);for(var d,p,g,_=0,m=new Uint8Array(c);n<f&&_<f;)if(d=i[n++],p=1+(127&d),128&d){for(g=0;g<c;++g)m[g]=i[n++];for(g=0;g<p;++g)l.set(m,_+g*c);_+=c*p}else{for(p*=c,g=0;g<p;++g)l[_+g]=i[n++];_+=p}}else l=i.subarray(n,n+=a?o.width*o.height:f);var v,y,A,T,E,b;switch((o.flags&t._ORIGIN_MASK)>>t._ORIGIN_SHIFT){default:case t._ORIGIN_UL:v=0,A=1,b=o.width,y=0,T=1,E=o.height;break;case t._ORIGIN_BL:v=0,A=1,b=o.width,y=o.height-1,T=-1,E=-1;break;case t._ORIGIN_UR:v=o.width-1,A=-1,b=-1,y=0,T=1,E=o.height;break;case t._ORIGIN_BR:v=o.width-1,A=-1,b=-1,y=o.height-1,T=-1,E=-1}var x="_getImageData"+(u?"Grey":"")+o.pixel_size+"bits",M=t[x](o,h,l,y,T,E,v,A,b);r.texImage2D(r.TEXTURE_2D,0,r.RGBA,o.width,o.height,0,r.RGBA,r.UNSIGNED_BYTE,M)},t._getImageData8bits=function(e,t,r,i,n,o,s,a,u){var l,h,c,f=r,d=t,p=e.width,g=e.height,_=0,m=new Uint8Array(p*g*4);for(c=i;c!==o;c+=n)for(h=s;h!==u;h+=a,_++)l=f[_],m[4*(h+p*c)+3]=255,m[4*(h+p*c)+2]=d[3*l+0],m[4*(h+p*c)+1]=d[3*l+1],m[4*(h+p*c)+0]=d[3*l+2];return m},t._getImageData16bits=function(e,t,r,i,n,o,s,a,u){var l,h,c,f=r,d=e.width,p=e.height,g=0,_=new Uint8Array(d*p*4);for(c=i;c!==o;c+=n)for(h=s;h!==u;h+=a,g+=2)l=f[g+0]+(f[g+1]<<8),_[4*(h+d*c)+0]=(31744&l)>>7,_[4*(h+d*c)+1]=(992&l)>>2,_[4*(h+d*c)+2]=(31&l)>>3,_[4*(h+d*c)+3]=32768&l?0:255;return _},t._getImageData24bits=function(e,t,r,i,n,o,s,a,u){var l,h,c=r,f=e.width,d=e.height,p=0,g=new Uint8Array(f*d*4);for(h=i;h!==o;h+=n)for(l=s;l!==u;l+=a,p+=3)g[4*(l+f*h)+3]=255,g[4*(l+f*h)+2]=c[p+0],g[4*(l+f*h)+1]=c[p+1],g[4*(l+f*h)+0]=c[p+2];return g},t._getImageData32bits=function(e,t,r,i,n,o,s,a,u){var l,h,c=r,f=e.width,d=e.height,p=0,g=new Uint8Array(f*d*4);for(h=i;h!==o;h+=n)for(l=s;l!==u;l+=a,p+=4)g[4*(l+f*h)+2]=c[p+0],g[4*(l+f*h)+1]=c[p+1],g[4*(l+f*h)+0]=c[p+2],g[4*(l+f*h)+3]=c[p+3];return g},t._getImageDataGrey8bits=function(e,t,r,i,n,o,s,a,u){var l,h,c,f=r,d=e.width,p=e.height,g=0,_=new Uint8Array(d*p*4);for(c=i;c!==o;c+=n)for(h=s;h!==u;h+=a,g++)l=f[g],_[4*(h+d*c)+0]=l,_[4*(h+d*c)+1]=l,_[4*(h+d*c)+2]=l,_[4*(h+d*c)+3]=255;return _},t._getImageDataGrey16bits=function(e,t,r,i,n,o,s,a,u){var l,h,c=r,f=e.width,d=e.height,p=0,g=new Uint8Array(f*d*4);for(h=i;h!==o;h+=n)for(l=s;l!==u;l+=a,p+=2)g[4*(l+f*h)+0]=c[p+0],g[4*(l+f*h)+1]=c[p+0],g[4*(l+f*h)+2]=c[p+0],g[4*(l+f*h)+3]=c[p+1];return g},t._TYPE_NO_DATA=0,t._TYPE_INDEXED=1,t._TYPE_RGB=2,t._TYPE_GREY=3,t._TYPE_RLE_INDEXED=9,t._TYPE_RLE_RGB=10,t._TYPE_RLE_GREY=11,t._ORIGIN_MASK=48,t._ORIGIN_SHIFT=4,t._ORIGIN_BL=0,t._ORIGIN_BR=1,t._ORIGIN_UL=2,t._ORIGIN_UR=3,t})();t.TGATools=r})(e.Internals||(e.Internals={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(t){function r(e){return e.charCodeAt(0)+(e.charCodeAt(1)<<8)+(e.charCodeAt(2)<<16)+(e.charCodeAt(3)<<24)}function i(e){return String.fromCharCode(255&e,e>>8&255,e>>16&255,e>>24&255)}var n=r("DXT1"),o=r("DXT3"),s=r("DXT5"),a=r("DX10"),u=(function(){function t(){}return t.GetDDSInfo=function(t){var r=new Int32Array(t,0,31),i=new Int32Array(t,0,35),u=1;131072&r[2]&&(u=Math.max(1,r[7]));var l=r[21],h=l===a?i[32]:0,c=e.Engine.TEXTURETYPE_UNSIGNED_INT;switch(l){case 113:c=e.Engine.TEXTURETYPE_HALF_FLOAT;break;case 116:c=e.Engine.TEXTURETYPE_FLOAT;break;case a:if(10===h){c=e.Engine.TEXTURETYPE_HALF_FLOAT;break}}return{width:r[4],height:r[3],mipmapCount:u,isFourCC:4==(4&r[20]),isRGB:64==(64&r[20]),isLuminance:131072==(131072&r[20]),isCube:512==(512&r[28]),isCompressed:l===n||l===o||n===s,dxgiFormat:h,textureType:c}},t._ToHalfFloat=function(e){t._FloatView||(t._FloatView=new Float32Array(1),t._Int32View=new Int32Array(t._FloatView.buffer)),t._FloatView[0]=e;var r=t._Int32View[0],i=r>>16&32768,n=r>>12&2047,o=r>>23&255;return o<103?i:o>142?(i|=31744,i|=(255==o?0:1)&&8388607&r):o<113?(n|=2048,i|=(n>>114-o)+(n>>113-o&1)):(i|=o-112<<10|n>>1,i+=1&n)},t._FromHalfFloat=function(e){var t=(32768&e)>>15,r=(31744&e)>>10,i=1023&e;return 0===r?(t?-1:1)*Math.pow(2,-14)*(i/Math.pow(2,10)):31==r?i?NaN:1/0*(t?-1:1):(t?-1:1)*Math.pow(2,r-15)*(1+i/Math.pow(2,10))},t._GetHalfFloatAsFloatRGBAArrayBuffer=function(e,r,i,n,o,s){for(var a=new Float32Array(n),u=new Uint16Array(o,i),l=0,h=0;h<r;h++)for(var c=0;c<e;c++){var f=4*(c+h*e);a[l]=t._FromHalfFloat(u[f]),a[l+1]=t._FromHalfFloat(u[f+1]),a[l+2]=t._FromHalfFloat(u[f+2]),t.StoreLODInAlphaChannel?a[l+3]=s:a[l+3]=t._FromHalfFloat(u[f+3]),l+=4}return a},t._GetHalfFloatRGBAArrayBuffer=function(e,r,i,n,o,s){if(t.StoreLODInAlphaChannel){for(var a=new Uint16Array(n),u=new Uint16Array(o,i),l=0,h=0;h<r;h++)for(var c=0;c<e;c++){var f=4*(c+h*e);a[l]=u[f],a[l+1]=u[f+1],a[l+2]=u[f+2],a[l+3]=t._ToHalfFloat(s),l+=4}return a}return new Uint16Array(o,i,n)},t._GetFloatRGBAArrayBuffer=function(e,r,i,n,o,s){if(t.StoreLODInAlphaChannel){for(var a=new Float32Array(n),u=new Float32Array(o,i),l=0,h=0;h<r;h++)for(var c=0;c<e;c++){var f=4*(c+h*e);a[l]=u[f],a[l+1]=u[f+1],a[l+2]=u[f+2],a[l+3]=s,l+=4}return a}return new Float32Array(o,i,n)},t._GetFloatAsUIntRGBAArrayBuffer=function(r,i,n,o,s,a){for(var u=new Uint8Array(o),l=new Float32Array(s,n),h=0,c=0;c<i;c++)for(var f=0;f<r;f++){var d=4*(f+c*r);u[h]=255*e.Scalar.Clamp(l[d]),u[h+1]=255*e.Scalar.Clamp(l[d+1]),u[h+2]=255*e.Scalar.Clamp(l[d+2]),t.StoreLODInAlphaChannel?u[h+3]=a:u[h+3]=255*e.Scalar.Clamp(l[d+3]),h+=4}return u},t._GetHalfFloatAsUIntRGBAArrayBuffer=function(r,i,n,o,s,a){for(var u=new Uint8Array(o),l=new Uint16Array(s,n),h=0,c=0;c<i;c++)for(var f=0;f<r;f++){var d=4*(f+c*r);u[h]=255*e.Scalar.Clamp(t._FromHalfFloat(l[d])),u[h+1]=255*e.Scalar.Clamp(t._FromHalfFloat(l[d+1])),u[h+2]=255*e.Scalar.Clamp(t._FromHalfFloat(l[d+2])),t.StoreLODInAlphaChannel?u[h+3]=a:u[h+3]=255*e.Scalar.Clamp(t._FromHalfFloat(l[d+3])),h+=4}return u},t._GetRGBAArrayBuffer=function(e,t,r,i,n){for(var o=new Uint8Array(i),s=new Uint8Array(n,r),a=0,u=0;u<t;u++)for(var l=0;l<e;l++){var h=4*(l+u*e);o[a]=s[h+2],o[a+1]=s[h+1],o[a+2]=s[h],o[a+3]=s[h+3],a+=4}return o},t._GetRGBArrayBuffer=function(e,t,r,i,n){for(var o=new Uint8Array(i),s=new Uint8Array(n,r),a=0,u=0;u<t;u++)for(var l=0;l<e;l++){var h=3*(l+u*e);o[a]=s[h+2],o[a+1]=s[h+1],o[a+2]=s[h],a+=3}return o},t._GetLuminanceArrayBuffer=function(e,t,r,i,n){for(var o=new Uint8Array(i),s=new Uint8Array(n,r),a=0,u=0;u<t;u++)for(var l=0;l<e;l++){var h=l+u*e;o[a]=s[h],a++}return o},t.UploadDDSLevels=function(r,u,l,h,c,f){void 0===f&&(f=-1);var d,p,g,_,m,v,y,A,T,E,b,x=r._gl,M=r.getCaps().s3tc,P=new Int32Array(u,0,31);if(542327876!=P[0])return void e.Tools.Error("Invalid magic number in DDS header");if(!l.isFourCC&&!l.isRGB&&!l.isLuminance)return void e.Tools.Error("Unsupported format, must contain a FourCC, RGB or LUMINANCE code");if(l.isCompressed&&!M)return void e.Tools.Error("Compressed textures are not supported on this platform.");var R=P[22];A=P[1]+4;var C=!1;if(l.isFourCC)switch(d=P[21]){case n:p=8,g=M.COMPRESSED_RGBA_S3TC_DXT1_EXT;break;case o:p=16,g=M.COMPRESSED_RGBA_S3TC_DXT3_EXT;break;case s:p=16,g=M.COMPRESSED_RGBA_S3TC_DXT5_EXT;break;case 113:case 116:C=!0;break;case a:A+=20;var O=!1;switch(l.dxgiFormat){case 10:C=!0,O=!0;break;case 88:l.isRGB=!0,l.isFourCC=!1,R=32,O=!0}if(O)break;default:return void console.error("Unsupported FourCC code:",i(d))}C&&(_=r._getWebGLTextureType(l.textureType),g=r._getRGBABufferInternalSizedFormat(l.textureType)),E=1,131072&P[2]&&!1!==h&&(E=Math.max(1,P[7]));for(var S=0;S<c;S++){var I=1===c?x.TEXTURE_2D:x.TEXTURE_CUBE_MAP_POSITIVE_X+S;for(m=P[4],v=P[3],b=0;b<E;++b){if(-1===f||f===b){var L=-1===f?b:0;if(!l.isCompressed&&l.isFourCC){y=m*v*4;var D;r.badOS||r.badDesktopOS||!r.getCaps().textureHalfFloat&&!r.getCaps().textureFloat?(128===R?D=t._GetFloatAsUIntRGBAArrayBuffer(m,v,A,y,u,L):64===R&&(D=t._GetHalfFloatAsUIntRGBAArrayBuffer(m,v,A,y,u,L)),l.textureType=e.Engine.TEXTURETYPE_UNSIGNED_INT,_=r._getWebGLTextureType(l.textureType),g=r._getRGBABufferInternalSizedFormat(l.textureType)):128===R?D=t._GetFloatRGBAArrayBuffer(m,v,A,y,u,L):64!==R||r.getCaps().textureHalfFloat?D=t._GetHalfFloatRGBAArrayBuffer(m,v,A,y,u,L):(D=t._GetHalfFloatAsFloatRGBAArrayBuffer(m,v,A,y,u,L),l.textureType=e.Engine.TEXTURETYPE_FLOAT,_=r._getWebGLTextureType(l.textureType),g=r._getRGBABufferInternalSizedFormat(l.textureType)),r._uploadDataToTexture(I,L,g,m,v,x.RGBA,_,D)}else if(l.isRGB)24===R?(y=m*v*3,T=t._GetRGBArrayBuffer(m,v,A,y,u),r._uploadDataToTexture(I,L,x.RGB,m,v,x.RGB,x.UNSIGNED_BYTE,T)):(y=m*v*4,T=t._GetRGBAArrayBuffer(m,v,A,y,u),r._uploadDataToTexture(I,L,x.RGBA,m,v,x.RGBA,x.UNSIGNED_BYTE,T));else if(l.isLuminance){var B=x.getParameter(x.UNPACK_ALIGNMENT),N=m,F=Math.floor((m+B-1)/B)*B;y=F*(v-1)+N,T=t._GetLuminanceArrayBuffer(m,v,A,y,u),r._uploadDataToTexture(I,L,x.LUMINANCE,m,v,x.LUMINANCE,x.UNSIGNED_BYTE,T)}else y=Math.max(4,m)/4*Math.max(4,v)/4*p,T=new Uint8Array(u,A,y),r._uploadCompressedDataToTexture(I,L,g,m,v,T)}A+=m*v*(R/8),m*=.5,v*=.5,m=Math.max(1,m),v=Math.max(1,v)}}},t.StoreLODInAlphaChannel=!1,t})();t.DDSTools=u})(e.Internals||(e.Internals={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(t){var r=(function(){function t(r,i,n,o){this.arrayBuffer=r;var s=new Uint8Array(this.arrayBuffer,0,12);if(171!==s[0]||75!==s[1]||84!==s[2]||88!==s[3]||32!==s[4]||49!==s[5]||49!==s[6]||187!==s[7]||13!==s[8]||10!==s[9]||26!==s[10]||10!==s[11])return void e.Tools.Error("texture missing KTX identifier");var a=new Int32Array(this.arrayBuffer,12,13),u=16909060===a[0];return this.glType=u?this.switchEndainness(a[1]):a[1],this.glTypeSize=u?this.switchEndainness(a[2]):a[2],this.glFormat=u?this.switchEndainness(a[3]):a[3],this.glInternalFormat=u?this.switchEndainness(a[4]):a[4],this.glBaseInternalFormat=u?this.switchEndainness(a[5]):a[5],this.pixelWidth=u?this.switchEndainness(a[6]):a[6],this.pixelHeight=u?this.switchEndainness(a[7]):a[7],this.pixelDepth=u?this.switchEndainness(a[8]):a[8],this.numberOfArrayElements=u?this.switchEndainness(a[9]):a[9],this.numberOfFaces=u?this.switchEndainness(a[10]):a[10],this.numberOfMipmapLevels=u?this.switchEndainness(a[11]):a[11],this.bytesOfKeyValueData=u?this.switchEndainness(a[12]):a[12],0!==this.glType?void e.Tools.Error("only compressed formats currently supported"):(this.numberOfMipmapLevels=Math.max(1,this.numberOfMipmapLevels),0===this.pixelHeight||0!==this.pixelDepth?void e.Tools.Error("only 2D textures currently supported"):0!==this.numberOfArrayElements?void e.Tools.Error("texture arrays not currently supported"):this.numberOfFaces!==i?void e.Tools.Error("number of faces expected"+i+", but found "+this.numberOfFaces):void(this.loadType=t.COMPRESSED_2D))}return t.prototype.switchEndainness=function(e){return(255&e)<<24|(65280&e)<<8|e>>8&65280|e>>24&255},t.prototype.uploadLevels=function(e,r){switch(this.loadType){case t.COMPRESSED_2D:this._upload2DCompressedLevels(e,r);break;case t.TEX_2D:case t.COMPRESSED_3D:case t.TEX_3D:}},t.prototype._upload2DCompressedLevels=function(e,r){for(var i=t.HEADER_LEN+this.bytesOfKeyValueData,n=this.pixelWidth,o=this.pixelHeight,s=r?this.numberOfMipmapLevels:1,a=0;a<s;a++){for(var u=new Int32Array(this.arrayBuffer,i,1)[0],l=0;l<this.numberOfFaces;l++){var h=1===this.numberOfFaces?e.TEXTURE_2D:e.TEXTURE_CUBE_MAP_POSITIVE_X+l,c=new Uint8Array(this.arrayBuffer,i+4,u);e.compressedTexImage2D(h,a,this.glInternalFormat,n,o,0,c),i+=u+4,i+=3-(u+3)%4}n=Math.max(1,.5*n),o=Math.max(1,.5*o)}},t.HEADER_LEN=64,t.COMPRESSED_2D=0,t.COMPRESSED_3D=1,t.TEX_2D=2,t.TEX_3D=3,t})();t.KhronosTextureContainer=r})(e.Internals||(e.Internals={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(t,r,i,n,o,s,a,u,l,h,c,f,d,p){void 0===a&&(a=e.Texture.NEAREST_SAMPLINGMODE),void 0===c&&(c=e.Engine.TEXTURETYPE_UNSIGNED_INT),void 0===f&&(f="postprocess"),void 0===p&&(p=!1),this.name=t,this.width=-1,this.height=-1,this.autoClear=!0,this.alphaMode=e.Engine.ALPHA_DISABLE,this.enablePixelPerfectMode=!1,this.scaleMode=e.Engine.SCALEMODE_FLOOR,this.alwaysForcePOT=!1,this.samples=1,this._reusable=!1,this._textures=new e.SmartArray(2),this._currentRenderTextureInd=0,this._scaleRatio=new e.Vector2(1,1),this._texelSize=e.Vector2.Zero(),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=u,this._options=o,
- this.renderTargetSamplingMode=a||e.Texture.NEAREST_SAMPLINGMODE,this._reusable=l||!1,this._textureType=c,this._samplers=n||[],this._samplers.push("textureSampler"),this._fragmentUrl=r,this._vertexUrl=f,this._parameters=i||[],this._parameters.push("scale"),this._indexParameters=d,p||this.updateEffect(h)}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}),Object.defineProperty(t.prototype,"outputTexture",{get:function(){return this._textures.data[this._currentRenderTextureInd]},set:function(e){this._forcedOutputTexture=e},enumerable:!0,configurable:!0}),t.prototype.getCamera=function(){return this._camera},Object.defineProperty(t.prototype,"texelSize",{get:function(){return this._shareOutputWithPostProcess?this._shareOutputWithPostProcess.texelSize:(this._forcedOutputTexture&&this._texelSize.copyFromFloats(1/this._forcedOutputTexture._width,1/this._forcedOutputTexture._height),this._texelSize)},enumerable:!0,configurable:!0}),t.prototype.getEngine=function(){return this._engine},t.prototype.getEffect=function(){return this._effect},t.prototype.shareOutputWith=function(e){return this._disposeTextures(),this._shareOutputWithPostProcess=e,this},t.prototype.updateEffect=function(e,t,r,i,n,o){this._effect=this._engine.createEffect({vertex:this._vertexUrl,fragment:this._fragmentUrl},["position"],t||this._parameters,r||this._samplers,void 0!==e?e:"",null,n,o,i||this._indexParameters)},t.prototype.isReusable=function(){return this._reusable},t.prototype.markTextureDirty=function(){this.width=-1},t.prototype.activate=function(t,r,i){var n=this;if(!this._shareOutputWithPostProcess&&!this._forcedOutputTexture){t=t||this._camera;var o=t.getScene(),s=o.getEngine(),a=s.getCaps().maxTextureSize,u=(r?r._width:this._engine.getRenderingCanvas().width)*this._options|0,l=(r?r._height:this._engine.getRenderingCanvas().height)*this._options|0,h=this._options.width||u,c=this._options.height||l;if((this.renderTargetSamplingMode===e.Texture.TRILINEAR_SAMPLINGMODE||this.alwaysForcePOT)&&(this._options.width||(h=s.needPOTTextures?e.Tools.GetExponentOfTwo(h,a,this.scaleMode):h),this._options.height||(c=s.needPOTTextures?e.Tools.GetExponentOfTwo(c,a,this.scaleMode):c)),this.width!==h||this.height!==c){if(this._textures.length>0){for(var f=0;f<this._textures.length;f++)this._engine._releaseTexture(this._textures.data[f]);this._textures.reset()}this.width=h,this.height=c;var d={width:this.width,height:this.height},p={generateMipMaps:!1,generateDepthBuffer:i||0===t._postProcesses.indexOf(this),generateStencilBuffer:(i||0===t._postProcesses.indexOf(this))&&this._engine.isStencilEnable,samplingMode:this.renderTargetSamplingMode,type:this._textureType};this._textures.push(this._engine.createRenderTargetTexture(d,p)),this._reusable&&this._textures.push(this._engine.createRenderTargetTexture(d,p)),this._texelSize.copyFromFloats(1/this.width,1/this.height),this.onSizeChangedObservable.notifyObservers(this)}this._textures.forEach((function(e){e.samples!==n.samples&&n._engine.updateRenderTargetTextureSampleCount(e,n.samples)}))}var g;this._shareOutputWithPostProcess?g=this._shareOutputWithPostProcess.outputTexture:this._forcedOutputTexture?(g=this._forcedOutputTexture,this.width=this._forcedOutputTexture._width,this.height=this._forcedOutputTexture._height):g=this.outputTexture,this.enablePixelPerfectMode?(this._scaleRatio.copyFromFloats(u/h,l/c),this._engine.bindFramebuffer(g,0,u,l,!0)):(this._scaleRatio.copyFromFloats(1,1),this._engine.bindFramebuffer(g,0,void 0,void 0,!0)),this.onActivateObservable.notifyObservers(t),this.autoClear&&this.alphaMode===e.Engine.ALPHA_DISABLE&&this._engine.clear(this.clearColor?this.clearColor:o.clearColor,!0,!0,!0),this._reusable&&(this._currentRenderTextureInd=(this._currentRenderTextureInd+1)%2)},Object.defineProperty(t.prototype,"isSupported",{get:function(){return this._effect.isSupported},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"aspectRatio",{get:function(){if(this._shareOutputWithPostProcess)return this._shareOutputWithPostProcess.aspectRatio;if(this._forcedOutputTexture){this._forcedOutputTexture._width,this._forcedOutputTexture._height}return this.width/this.height},enumerable:!0,configurable:!0}),t.prototype.apply=function(){if(!this._effect||!this._effect.isReady())return null;this._engine.enableEffect(this._effect),this._engine.setState(!1),this._engine.setDepthBuffer(!1),this._engine.setDepthWrite(!1),this._engine.setAlphaMode(this.alphaMode),this.alphaConstants&&this.getEngine().setAlphaConstants(this.alphaConstants.r,this.alphaConstants.g,this.alphaConstants.b,this.alphaConstants.a);var e;return e=this._shareOutputWithPostProcess?this._shareOutputWithPostProcess.outputTexture:this._forcedOutputTexture?this._forcedOutputTexture:this.outputTexture,this._effect._bindTexture("textureSampler",e),this._effect.setVector2("scale",this._scaleRatio),this.onApplyObservable.notifyObservers(this._effect),this._effect},t.prototype._disposeTextures=function(){if(!this._shareOutputWithPostProcess&&!this._forcedOutputTexture){if(this._textures.length>0)for(var e=0;e<this._textures.length;e++)this._engine._releaseTexture(this._textures.data[e]);this._textures.dispose()}},t.prototype.dispose=function(e){if(e=e||this._camera,this._disposeTextures(),e){e.detachPostProcess(this);0===e._postProcesses.indexOf(this)&&e._postProcesses.length>0&&this._camera._postProcesses[0].markTextureDirty(),this.onActivateObservable.clear(),this.onAfterRenderObservable.clear(),this.onApplyObservable.clear(),this.onBeforeRenderObservable.clear(),this.onSizeChangedObservable.clear()}},t})();e.PostProcess=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(r,i,n,o,s,a,u){return void 0===u&&(u=e.Engine.TEXTURETYPE_UNSIGNED_INT),t.call(this,r,"pass",null,null,i,n,o,s,a,null,u)||this}return __extends(r,t),r})(e.PostProcess);e.PassPostProcess=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(r,i,n){this._bias=5e-5,this._blurBoxOffset=1,this._blurScale=2,this._blurKernel=1,this._useKernelBlur=!1,this._filter=t.FILTER_NONE,this._darkness=0,this._transparencyShadow=!1,this.frustumEdgeFalloff=0,this.forceBackFacesOnly=!1,this._lightDirection=e.Vector3.Zero(),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._isCube=!1,this._defaultTextureMatrix=e.Matrix.Identity(),this._mapSize=r,this._light=i,this._scene=i.getScene(),i._shadowGenerator=this;var o=this._scene.getEngine().getCaps();n?o.textureFloatRender&&o.textureFloatLinearFiltering?this._textureType=e.Engine.TEXTURETYPE_FLOAT:o.textureHalfFloatRender&&o.textureHalfFloatLinearFiltering?this._textureType=e.Engine.TEXTURETYPE_HALF_FLOAT:this._textureType=e.Engine.TEXTURETYPE_UNSIGNED_INT:o.textureHalfFloatRender&&o.textureHalfFloatLinearFiltering?this._textureType=e.Engine.TEXTURETYPE_HALF_FLOAT:o.textureFloatRender&&o.textureFloatLinearFiltering?this._textureType=e.Engine.TEXTURETYPE_FLOAT:this._textureType=e.Engine.TEXTURETYPE_UNSIGNED_INT,this._initializeGenerator()}return Object.defineProperty(t,"FILTER_NONE",{get:function(){return t._FILTER_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(t,"FILTER_POISSONSAMPLING",{get:function(){return t._FILTER_POISSONSAMPLING},enumerable:!0,configurable:!0}),Object.defineProperty(t,"FILTER_EXPONENTIALSHADOWMAP",{get:function(){return t._FILTER_EXPONENTIALSHADOWMAP},enumerable:!0,configurable:!0}),Object.defineProperty(t,"FILTER_BLUREXPONENTIALSHADOWMAP",{get:function(){return t._FILTER_BLUREXPONENTIALSHADOWMAP},enumerable:!0,configurable:!0}),Object.defineProperty(t,"FILTER_CLOSEEXPONENTIALSHADOWMAP",{get:function(){return t._FILTER_CLOSEEXPONENTIALSHADOWMAP},enumerable:!0,configurable:!0}),Object.defineProperty(t,"FILTER_BLURCLOSEEXPONENTIALSHADOWMAP",{get:function(){return t._FILTER_BLURCLOSEEXPONENTIALSHADOWMAP},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"bias",{get:function(){return this._bias},set:function(e){this._bias=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"blurBoxOffset",{get:function(){return this._blurBoxOffset},set:function(e){this._blurBoxOffset!==e&&(this._blurBoxOffset=e,this._disposeBlurPostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"blurScale",{get:function(){return this._blurScale},set:function(e){this._blurScale!==e&&(this._blurScale=e,this._disposeBlurPostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"blurKernel",{get:function(){return this._blurKernel},set:function(e){this._blurKernel!==e&&(this._blurKernel=e,this._disposeBlurPostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useKernelBlur",{get:function(){return this._useKernelBlur},set:function(e){this._useKernelBlur!==e&&(this._useKernelBlur=e,this._disposeBlurPostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"depthScale",{get:function(){return void 0!==this._depthScale?this._depthScale:this._light.getDepthScale()},set:function(e){this._depthScale=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"filter",{get:function(){return this._filter},set:function(e){if(this._light.needCube()){if(e===t.FILTER_BLUREXPONENTIALSHADOWMAP)return void(this.useExponentialShadowMap=!0);if(e===t.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP)return void(this.useCloseExponentialShadowMap=!0)}this._filter!==e&&(this._filter=e,this._disposeBlurPostProcesses(),this._applyFilterValues(),this._light._markMeshesAsLightDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"usePoissonSampling",{get:function(){return this.filter===t.FILTER_POISSONSAMPLING},set:function(e){this.filter=e?t.FILTER_POISSONSAMPLING:t.FILTER_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useVarianceShadowMap",{get:function(){return e.Tools.Warn("VSM are now replaced by ESM. Please use useExponentialShadowMap instead."),this.useExponentialShadowMap},set:function(t){e.Tools.Warn("VSM are now replaced by ESM. Please use useExponentialShadowMap instead."),this.useExponentialShadowMap=t},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useBlurVarianceShadowMap",{get:function(){return e.Tools.Warn("VSM are now replaced by ESM. Please use useBlurExponentialShadowMap instead."),this.useBlurExponentialShadowMap},set:function(t){e.Tools.Warn("VSM are now replaced by ESM. Please use useBlurExponentialShadowMap instead."),this.useBlurExponentialShadowMap=t},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useExponentialShadowMap",{get:function(){return this.filter===t.FILTER_EXPONENTIALSHADOWMAP},set:function(e){this.filter=e?t.FILTER_EXPONENTIALSHADOWMAP:t.FILTER_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useBlurExponentialShadowMap",{get:function(){return this.filter===t.FILTER_BLUREXPONENTIALSHADOWMAP},set:function(e){this.filter=e?t.FILTER_BLUREXPONENTIALSHADOWMAP:t.FILTER_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useCloseExponentialShadowMap",{get:function(){return this.filter===t.FILTER_CLOSEEXPONENTIALSHADOWMAP},set:function(e){this.filter=e?t.FILTER_CLOSEEXPONENTIALSHADOWMAP:t.FILTER_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useBlurCloseExponentialShadowMap",{get:function(){return this.filter===t.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP},set:function(e){this.filter=e?t.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP:t.FILTER_NONE},enumerable:!0,configurable:!0}),t.prototype.getDarkness=function(){return this._darkness},t.prototype.setDarkness=function(e){return this._darkness=e>=1?1:e<=0?0:e,this},t.prototype.setTransparencyShadow=function(e){return this._transparencyShadow=e,this},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._initializeGenerator=function(){this._light._markMeshesAsLightDirty(),this._initializeShadowMap()},t.prototype._initializeShadowMap=function(){var t=this;this._shadowMap=new e.RenderTargetTexture(this._light.name+"_shadowMap",this._mapSize,this._scene,!1,!0,this._textureType,this._light.needCube()),this._shadowMap.wrapU=e.Texture.CLAMP_ADDRESSMODE,this._shadowMap.wrapV=e.Texture.CLAMP_ADDRESSMODE,this._shadowMap.anisotropicFilteringLevel=1,this._shadowMap.updateSamplingMode(e.Texture.BILINEAR_SAMPLINGMODE),this._shadowMap.renderParticles=!1,this._shadowMap.onBeforeRenderObservable.add((function(e){t._currentFaceIndex=e})),this._shadowMap.customRenderFunction=this._renderForShadowMap.bind(this),this._shadowMap.onAfterUnbindObservable.add((function(){(t.useBlurExponentialShadowMap||t.useBlurCloseExponentialShadowMap)&&(t._blurPostProcesses||t._initializeBlurRTTAndPostProcesses(),t._scene.postProcessManager.directRender(t._blurPostProcesses,t.getShadowMapForRendering().getInternalTexture()))})),this._shadowMap.onClearObservable.add((function(r){t.useExponentialShadowMap||t.useBlurExponentialShadowMap?r.clear(new e.Color4(0,0,0,0),!0,!0,!0):r.clear(new e.Color4(1,1,1,1),!0,!0,!0)}))},t.prototype._initializeBlurRTTAndPostProcesses=function(){var t=this,r=this._scene.getEngine(),i=this._mapSize/this.blurScale;this.useKernelBlur&&1===this.blurScale||(this._shadowMap2=new e.RenderTargetTexture(this._light.name+"_shadowMap2",i,this._scene,!1,!0,this._textureType),this._shadowMap2.wrapU=e.Texture.CLAMP_ADDRESSMODE,this._shadowMap2.wrapV=e.Texture.CLAMP_ADDRESSMODE,this._shadowMap2.updateSamplingMode(e.Texture.BILINEAR_SAMPLINGMODE)),this.useKernelBlur?(this._kernelBlurXPostprocess=new e.BlurPostProcess(this._light.name+"KernelBlurX",new e.Vector2(1,0),this.blurKernel,1,null,e.Texture.BILINEAR_SAMPLINGMODE,r,!1,this._textureType),this._kernelBlurXPostprocess.width=i,this._kernelBlurXPostprocess.height=i,this._kernelBlurXPostprocess.onApplyObservable.add((function(e){e.setTexture("textureSampler",t._shadowMap)})),this._kernelBlurYPostprocess=new e.BlurPostProcess(this._light.name+"KernelBlurY",new e.Vector2(0,1),this.blurKernel,1,null,e.Texture.BILINEAR_SAMPLINGMODE,r,!1,this._textureType),this._kernelBlurXPostprocess.autoClear=!1,this._kernelBlurYPostprocess.autoClear=!1,this._textureType===e.Engine.TEXTURETYPE_UNSIGNED_INT&&(this._kernelBlurXPostprocess.packedFloat=!0,this._kernelBlurYPostprocess.packedFloat=!0),this._blurPostProcesses=[this._kernelBlurXPostprocess,this._kernelBlurYPostprocess]):(this._boxBlurPostprocess=new e.PostProcess(this._light.name+"DepthBoxBlur","depthBoxBlur",["screenSize","boxOffset"],[],1,null,e.Texture.BILINEAR_SAMPLINGMODE,r,!1,"#define OFFSET "+this._blurBoxOffset,this._textureType),this._boxBlurPostprocess.onApplyObservable.add((function(e){e.setFloat2("screenSize",i,i),e.setTexture("textureSampler",t._shadowMap)})),this._boxBlurPostprocess.autoClear=!1,this._blurPostProcesses=[this._boxBlurPostprocess])},t.prototype._renderForShadowMap=function(e,t,r){var i;for(i=0;i<e.length;i++)this._renderSubMeshForShadowMap(e.data[i]);for(i=0;i<t.length;i++)this._renderSubMeshForShadowMap(t.data[i]);if(this._transparencyShadow)for(i=0;i<r.length;i++)this._renderSubMeshForShadowMap(r.data[i])},t.prototype._renderSubMeshForShadowMap=function(t){var r=this,i=t.getRenderingMesh(),n=this._scene,o=n.getEngine();o.setState(t.getMaterial().backFaceCulling);var s=i._getInstancesRenderList(t._id);if(!s.mustReturn){var a=o.getCaps().instancedArrays&&null!==s.visibleInstances[t._id]&&void 0!==s.visibleInstances[t._id];if(this.isReady(t,a)){o.enableEffect(this._effect),i._bind(t,this._effect,e.Material.TriangleFillMode);var u=t.getMaterial();if(this._effect.setFloat2("biasAndScale",this.bias,this.depthScale),this._effect.setMatrix("viewProjection",this.getTransformMatrix()),this._effect.setVector3("lightPosition",this.getLight().position),this._effect.setFloat2("depthValues",this.getLight().getDepthMinZ(n.activeCamera),this.getLight().getDepthMinZ(n.activeCamera)+this.getLight().getDepthMaxZ(n.activeCamera)),u&&u.needAlphaTesting()){var l=u.getAlphaTestTexture();l&&(this._effect.setTexture("diffuseSampler",l),this._effect.setMatrix("diffuseMatrix",l.getTextureMatrix()||this._defaultTextureMatrix))}i.useBones&&i.computeBonesUsingShaders&&this._effect.setMatrices("mBones",i.skeleton.getTransformMatrices(i)),this.forceBackFacesOnly&&o.setState(!0,0,!1,!0),i._processRendering(t,this._effect,e.Material.TriangleFillMode,s,a,(function(e,t){return r._effect.setMatrix("world",t)})),this.forceBackFacesOnly&&o.setState(!0,0,!1,!1)}else this._shadowMap.resetRefreshCounter()}},t.prototype._applyFilterValues=function(){this.filter===t.FILTER_NONE?this._shadowMap.updateSamplingMode(e.Texture.NEAREST_SAMPLINGMODE):this._shadowMap.updateSamplingMode(e.Texture.BILINEAR_SAMPLINGMODE)},t.prototype.forceCompilation=function(e,t){for(var r=this,i=this._scene,n=(i.getEngine(),new Array),o=0,s=0,a=this.getShadowMap().renderList;s<a.length;s++){var u=a[s];n.push.apply(n,u.subMeshes)}var l=function(){if(r._scene&&r._scene.getEngine()){var i=n[o];if(r.isReady(i,!!t&&t.useInstances)&&++o>=n.length)return void(e&&e(r));setTimeout(l,16)}};n.length>0&&l()},t.prototype.isReady=function(t,r){var i=[];this._textureType!==e.Engine.TEXTURETYPE_UNSIGNED_INT&&i.push("#define FLOAT"),(this.useExponentialShadowMap||this.useBlurExponentialShadowMap)&&i.push("#define ESM");var n=[e.VertexBuffer.PositionKind],o=t.getMesh(),s=t.getMaterial();if(s&&s.needAlphaTesting()){var a=s.getAlphaTestTexture();a&&(i.push("#define ALPHATEST"),o.isVerticesDataPresent(e.VertexBuffer.UVKind)&&(n.push(e.VertexBuffer.UVKind),i.push("#define UV1")),o.isVerticesDataPresent(e.VertexBuffer.UV2Kind)&&1===a.coordinatesIndex&&(n.push(e.VertexBuffer.UV2Kind),i.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)),i.push("#define NUM_BONE_INFLUENCERS "+o.numBoneInfluencers),i.push("#define BonesPerMesh "+(o.skeleton.bones.length+1))):i.push("#define NUM_BONE_INFLUENCERS 0"),r&&(i.push("#define INSTANCES"),n.push("world0"),n.push("world1"),n.push("world2"),n.push("world3"));var u=i.join("\n");return this._cachedDefines!==u&&(this._cachedDefines=u,this._effect=this._scene.getEngine().createEffect("shadowMap",n,["world","mBones","viewProjection","diffuseMatrix","lightPosition","depthValues","biasAndScale"],["diffuseSampler"],u)),this._effect.isReady()},t.prototype.prepareDefines=function(e,t){var r=this._scene,i=this._light;r.shadowsEnabled&&i.shadowEnabled&&(e["SHADOW"+t]=!0,this.usePoissonSampling?e["SHADOWPCF"+t]=!0:this.useExponentialShadowMap||this.useBlurExponentialShadowMap?e["SHADOWESM"+t]=!0:(this.useCloseExponentialShadowMap||this.useBlurCloseExponentialShadowMap)&&(e["SHADOWCLOSEESM"+t]=!0),i.needCube()&&(e["SHADOWCUBE"+t]=!0))},t.prototype.bindShadowLight=function(e,t){var r=this._light,i=this._scene;i.shadowsEnabled&&r.shadowEnabled&&(r.needCube()||t.setMatrix("lightMatrix"+e,this.getTransformMatrix()),t.setTexture("shadowSampler"+e,this.getShadowMapForRendering()),r._uniformBuffer.updateFloat4("shadowsInfo",this.getDarkness(),this.blurScale/this.getShadowMap().getSize().width,this.depthScale,this.frustumEdgeFalloff,e),r._uniformBuffer.updateFloat2("depthValues",this.getLight().getDepthMinZ(i.activeCamera),this.getLight().getDepthMinZ(i.activeCamera)+this.getLight().getDepthMaxZ(i.activeCamera),e))},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 r=this._light.position;return this._light.computeTransformedInformation()&&(r=this._light.transformedPosition),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.needProjectionMatrixCompute()&&this._cachedPosition&&this._cachedDirection&&r.equals(this._cachedPosition)&&this._lightDirection.equals(this._cachedDirection)||(this._cachedPosition=r.clone(),this._cachedDirection=this._lightDirection.clone(),e.Matrix.LookAtLHToRef(r,r.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.recreateShadowMap=function(){var e=this._shadowMap.renderList;this._disposeRTTandPostProcesses(),this._initializeGenerator(),this.filter=this.filter,this._applyFilterValues(),this._shadowMap.renderList=e},t.prototype._disposeBlurPostProcesses=function(){this._shadowMap2&&(this._shadowMap2.dispose(),this._shadowMap2=null),this._downSamplePostprocess&&(this._downSamplePostprocess.dispose(),this._downSamplePostprocess=null),this._boxBlurPostprocess&&(this._boxBlurPostprocess.dispose(),this._boxBlurPostprocess=null),this._kernelBlurXPostprocess&&(this._kernelBlurXPostprocess.dispose(),this._kernelBlurXPostprocess=null),this._kernelBlurYPostprocess&&(this._kernelBlurYPostprocess.dispose(),this._kernelBlurYPostprocess=null),this._blurPostProcesses=null},t.prototype._disposeRTTandPostProcesses=function(){this._shadowMap&&(this._shadowMap.dispose(),this._shadowMap=null),this._disposeBlurPostProcesses()},t.prototype.dispose=function(){this._disposeRTTandPostProcesses(),this._light._shadowGenerator=null,this._light._markMeshesAsLightDirty()},t.prototype.serialize=function(){var e={},t=this.getShadowMap();e.lightId=this._light.id,e.mapSize=t.getRenderSize(),e.useExponentialShadowMap=this.useExponentialShadowMap,e.useBlurExponentialShadowMap=this.useBlurExponentialShadowMap,e.useCloseExponentialShadowMap=this.useBlurExponentialShadowMap,e.useBlurCloseExponentialShadowMap=this.useBlurExponentialShadowMap,e.usePoissonSampling=this.usePoissonSampling,e.forceBackFacesOnly=this.forceBackFacesOnly,e.depthScale=this.depthScale,e.darkness=this.getDarkness(),e.blurBoxOffset=this.blurBoxOffset,e.blurKernel=this.blurKernel,e.blurScale=this.blurScale,e.useKernelBlur=this.useKernelBlur,e.transparencyShadow=this._transparencyShadow,e.renderList=[];for(var r=0;r<t.renderList.length;r++){var i=t.renderList[r];e.renderList.push(i.id)}return e},t.Parse=function(e,r){for(var i=r.getLightByID(e.lightId),n=new t(e.mapSize,i),o=n.getShadowMap(),s=0;s<e.renderList.length;s++){r.getMeshesByID(e.renderList[s]).forEach((function(e){o.renderList.push(e)}))}return e.usePoissonSampling?n.usePoissonSampling=!0:e.useExponentialShadowMap?n.useExponentialShadowMap=!0:e.useBlurExponentialShadowMap?n.useBlurExponentialShadowMap=!0:e.useCloseExponentialShadowMap?n.useCloseExponentialShadowMap=!0:e.useBlurExponentialShadowMap?n.useBlurCloseExponentialShadowMap=!0:e.useVarianceShadowMap?n.useExponentialShadowMap=!0:e.useBlurVarianceShadowMap&&(n.useBlurExponentialShadowMap=!0),e.depthScale&&(n.depthScale=e.depthScale),e.blurScale&&(n.blurScale=e.blurScale),e.blurBoxOffset&&(n.blurBoxOffset=e.blurBoxOffset),e.useKernelBlur&&(n.useKernelBlur=e.useKernelBlur),e.blurKernel&&(n.blurKernel=e.blurKernel),void 0!==e.bias&&(n.bias=e.bias),e.darkness&&n.setDarkness(e.darkness),e.transparencyShadow&&n.setTransparencyShadow(!0),n.forceBackFacesOnly=e.forceBackFacesOnly,n},t._FILTER_NONE=0,t._FILTER_EXPONENTIALSHADOWMAP=1,t._FILTER_POISSONSAMPLING=2,t._FILTER_BLUREXPONENTIALSHADOWMAP=3,t._FILTER_CLOSEEXPONENTIALSHADOWMAP=4,t._FILTER_BLURCLOSEEXPONENTIALSHADOWMAP=5,t})();e.ShadowGenerator=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(){var e=null!==t&&t.apply(this,arguments)||this;return e._needProjectionMatrixCompute=!0,e}return __extends(r,t),Object.defineProperty(r.prototype,"direction",{get:function(){return this._direction},set:function(e){this._direction=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"shadowMinZ",{get:function(){return this._shadowMinZ},set:function(e){this._shadowMinZ=e,this.forceProjectionMatrixCompute()},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"shadowMaxZ",{get:function(){return this._shadowMaxZ},set:function(e){this._shadowMaxZ=e,this.forceProjectionMatrixCompute()},enumerable:!0,configurable:!0}),r.prototype.computeTransformedInformation=function(){return!(!this.parent||!this.parent.getWorldMatrix)&&(this.transformedPosition||(this.transformedPosition=e.Vector3.Zero()),e.Vector3.TransformCoordinatesToRef(this.position,this.parent.getWorldMatrix(),this.transformedPosition),this.direction&&(this.transformedDirection||(this.transformedDirection=e.Vector3.Zero()),e.Vector3.TransformNormalToRef(this.direction,this.parent.getWorldMatrix(),this.transformedDirection)),!0)},r.prototype.getDepthScale=function(){return 50},r.prototype.getShadowDirection=function(e){return this.transformedDirection?this.transformedDirection:this.direction},r.prototype.getAbsolutePosition=function(){return this.transformedPosition?this.transformedPosition:this.position},r.prototype.setDirectionToTarget=function(t){return this.direction=e.Vector3.Normalize(t.subtract(this.position)),this.direction},r.prototype.getRotation=function(){this.direction.normalize();var t=e.Vector3.Cross(this.direction,e.Axis.Y),r=e.Vector3.Cross(t,this.direction);return e.Vector3.RotationFromAxis(t,r,this.direction)},r.prototype.needCube=function(){return!1},r.prototype.needProjectionMatrixCompute=function(){return this._needProjectionMatrixCompute},r.prototype.forceProjectionMatrixCompute=function(){this._needProjectionMatrixCompute=!0},r.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},r.prototype.getDepthMinZ=function(e){return void 0!==this.shadowMinZ?this.shadowMinZ:e.minZ},r.prototype.getDepthMaxZ=function(e){return void 0!==this.shadowMaxZ?this.shadowMaxZ:e.maxZ},r.prototype.setShadowProjectionMatrix=function(e,t,r){return this.customProjectionMatrixBuilder?this.customProjectionMatrixBuilder(t,r,e):this._setDefaultShadowProjectionMatrix(e,t,r),this},__decorate([e.serializeAsVector3()],r.prototype,"position",void 0),__decorate([e.serializeAsVector3()],r.prototype,"direction",null),__decorate([e.serialize()],r.prototype,"shadowMinZ",null),__decorate([e.serialize()],r.prototype,"shadowMaxZ",null),r})(e.Light);e.ShadowLight=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(e,r,i){var n=t.call(this,e,i)||this;return n._shadowAngle=Math.PI/2,n.position=r,n}return __extends(r,t),Object.defineProperty(r.prototype,"shadowAngle",{get:function(){return this._shadowAngle},set:function(e){this._shadowAngle=e,this.forceProjectionMatrixCompute()},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"direction",{get:function(){return this._direction},set:function(e){var t=this.needCube();this._direction=e,this.needCube()!==t&&this._shadowGenerator&&this._shadowGenerator.recreateShadowMap()},enumerable:!0,configurable:!0}),r.prototype.getClassName=function(){return"PointLight"},r.prototype.getTypeID=function(){return e.Light.LIGHTTYPEID_POINTLIGHT},r.prototype.needCube=function(){return!this.direction},r.prototype.getShadowDirection=function(r){if(this.direction)return t.prototype.getShadowDirection.call(this,r);switch(r){case 0:return new e.Vector3(1,0,0);case 1:return new e.Vector3(-1,0,0);case 2:return new e.Vector3(0,-1,0);case 3:return new e.Vector3(0,1,0);case 4:return new e.Vector3(0,0,1);case 5:return new e.Vector3(0,0,-1)}return e.Vector3.Zero()},r.prototype._setDefaultShadowProjectionMatrix=function(t,r,i){var n=this.getScene().activeCamera;e.Matrix.PerspectiveFovLHToRef(this.shadowAngle,1,this.getDepthMinZ(n),this.getDepthMaxZ(n),t)},r.prototype._buildUniformLayout=function(){this._uniformBuffer.addUniform("vLightData",4),this._uniformBuffer.addUniform("vLightDiffuse",4),this._uniformBuffer.addUniform("vLightSpecular",3),this._uniformBuffer.addUniform("shadowsInfo",3),this._uniformBuffer.addUniform("depthValues",2),this._uniformBuffer.create()},r.prototype.transferToEffect=function(e,t){return this.computeTransformedInformation()?(this._uniformBuffer.updateFloat4("vLightData",this.transformedPosition.x,this.transformedPosition.y,this.transformedPosition.z,0,t),this):(this._uniformBuffer.updateFloat4("vLightData",this.position.x,this.position.y,this.position.z,0,t),this)},__decorate([e.serialize()],r.prototype,"shadowAngle",null),r})(e.ShadowLight);e.PointLight=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(e,r,i){var n=t.call(this,e,i)||this;return n._shadowFrustumSize=0,n._shadowOrthoScale=.5,n.autoUpdateExtends=!0,n._orthoLeft=Number.MAX_VALUE,n._orthoRight=Number.MIN_VALUE,n._orthoTop=Number.MIN_VALUE,n._orthoBottom=Number.MAX_VALUE,n.position=r.scale(-1),n.direction=r,n}return __extends(r,t),Object.defineProperty(r.prototype,"shadowFrustumSize",{get:function(){return this._shadowFrustumSize},set:function(e){this._shadowFrustumSize=e,this.forceProjectionMatrixCompute()},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"shadowOrthoScale",{get:function(){return this._shadowOrthoScale},set:function(e){this._shadowOrthoScale=e,this.forceProjectionMatrixCompute()},enumerable:!0,configurable:!0}),r.prototype.getClassName=function(){return"DirectionalLight"},r.prototype.getTypeID=function(){return e.Light.LIGHTTYPEID_DIRECTIONALLIGHT},r.prototype._setDefaultShadowProjectionMatrix=function(e,t,r){this.shadowFrustumSize>0?this._setDefaultFixedFrustumShadowProjectionMatrix(e,t):this._setDefaultAutoExtendShadowProjectionMatrix(e,t,r)},r.prototype._setDefaultFixedFrustumShadowProjectionMatrix=function(t,r){var i=this.getScene().activeCamera;e.Matrix.OrthoLHToRef(this.shadowFrustumSize,this.shadowFrustumSize,void 0!==this.shadowMinZ?this.shadowMinZ:i.minZ,void 0!==this.shadowMaxZ?this.shadowMaxZ:i.maxZ,t)},r.prototype._setDefaultAutoExtendShadowProjectionMatrix=function(t,r,i){var n=this.getScene().activeCamera;if(this.autoUpdateExtends||this._orthoLeft===Number.MAX_VALUE){var o=e.Vector3.Zero();this._orthoLeft=Number.MAX_VALUE,this._orthoRight=Number.MIN_VALUE,this._orthoTop=Number.MIN_VALUE,this._orthoBottom=Number.MAX_VALUE;for(var s=0;s<i.length;s++){var a=i[s];if(a){var u=a.getBoundingInfo()
- ;if(u)for(var l=u.boundingBox,h=0;h<l.vectorsWorld.length;h++)e.Vector3.TransformCoordinatesToRef(l.vectorsWorld[h],r,o),o.x<this._orthoLeft&&(this._orthoLeft=o.x),o.y<this._orthoBottom&&(this._orthoBottom=o.y),o.x>this._orthoRight&&(this._orthoRight=o.x),o.y>this._orthoTop&&(this._orthoTop=o.y)}}}var c=this._orthoRight-this._orthoLeft,f=this._orthoTop-this._orthoBottom;e.Matrix.OrthoOffCenterLHToRef(this._orthoLeft-c*this.shadowOrthoScale,this._orthoRight+c*this.shadowOrthoScale,this._orthoBottom-f*this.shadowOrthoScale,this._orthoTop+f*this.shadowOrthoScale,void 0!==this.shadowMinZ?this.shadowMinZ:n.minZ,void 0!==this.shadowMaxZ?this.shadowMaxZ:n.maxZ,t)},r.prototype._buildUniformLayout=function(){this._uniformBuffer.addUniform("vLightData",4),this._uniformBuffer.addUniform("vLightDiffuse",4),this._uniformBuffer.addUniform("vLightSpecular",3),this._uniformBuffer.addUniform("shadowsInfo",3),this._uniformBuffer.addUniform("depthValues",2),this._uniformBuffer.create()},r.prototype.transferToEffect=function(e,t){return this.computeTransformedInformation()?(this._uniformBuffer.updateFloat4("vLightData",this.transformedDirection.x,this.transformedDirection.y,this.transformedDirection.z,1,t),this):(this._uniformBuffer.updateFloat4("vLightData",this.direction.x,this.direction.y,this.direction.z,1,t),this)},r.prototype.getDepthMinZ=function(e){return 1},r.prototype.getDepthMaxZ=function(e){return 1},__decorate([e.serialize()],r.prototype,"shadowFrustumSize",null),__decorate([e.serialize()],r.prototype,"shadowOrthoScale",null),__decorate([e.serialize()],r.prototype,"autoUpdateExtends",void 0),r})(e.ShadowLight);e.DirectionalLight=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(e,r,i,n,o,s){var a=t.call(this,e,s)||this;return a.position=r,a.direction=i,a.angle=n,a.exponent=o,a}return __extends(r,t),Object.defineProperty(r.prototype,"angle",{get:function(){return this._angle},set:function(e){this._angle=e,this.forceProjectionMatrixCompute()},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"shadowAngleScale",{get:function(){return this._shadowAngleScale},set:function(e){this._shadowAngleScale=e,this.forceProjectionMatrixCompute()},enumerable:!0,configurable:!0}),r.prototype.getClassName=function(){return"SpotLight"},r.prototype.getTypeID=function(){return e.Light.LIGHTTYPEID_SPOTLIGHT},r.prototype._setDefaultShadowProjectionMatrix=function(t,r,i){var n=this.getScene().activeCamera;this._shadowAngleScale=this._shadowAngleScale||1;var o=this._shadowAngleScale*this._angle;e.Matrix.PerspectiveFovLHToRef(o,1,this.getDepthMinZ(n),this.getDepthMaxZ(n),t)},r.prototype._buildUniformLayout=function(){this._uniformBuffer.addUniform("vLightData",4),this._uniformBuffer.addUniform("vLightDiffuse",4),this._uniformBuffer.addUniform("vLightSpecular",3),this._uniformBuffer.addUniform("vLightDirection",3),this._uniformBuffer.addUniform("shadowsInfo",3),this._uniformBuffer.addUniform("depthValues",2),this._uniformBuffer.create()},r.prototype.transferToEffect=function(t,r){var i;return this.computeTransformedInformation()?(this._uniformBuffer.updateFloat4("vLightData",this.transformedPosition.x,this.transformedPosition.y,this.transformedPosition.z,this.exponent,r),i=e.Vector3.Normalize(this.transformedDirection)):(this._uniformBuffer.updateFloat4("vLightData",this.position.x,this.position.y,this.position.z,this.exponent,r),i=e.Vector3.Normalize(this.direction)),this._uniformBuffer.updateFloat4("vLightDirection",i.x,i.y,i.z,Math.cos(.5*this.angle),r),this},__decorate([e.serialize()],r.prototype,"angle",null),__decorate([e.serialize()],r.prototype,"shadowAngleScale",null),__decorate([e.serialize()],r.prototype,"exponent",void 0),r})(e.ShadowLight);e.SpotLight=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(e,r){var i=t.call(this,e,r,!0)||this;return r.multiMaterials.push(i),i.subMaterials=new Array,i.storeEffectOnSubMeshes=!0,i}return __extends(r,t),Object.defineProperty(r.prototype,"subMaterials",{get:function(){return this._subMaterials},set:function(e){this._subMaterials=e,this._hookArray(e)},enumerable:!0,configurable:!0}),r.prototype._hookArray=function(e){var t=this,r=e.push;e.push=function(){for(var i=[],n=0;n<arguments.length;n++)i[n]=arguments[n];var o=r.apply(e,i);return t._markAllSubMeshesAsTexturesDirty(),o};var i=e.splice;e.splice=function(r,n){var o=i.apply(e,[r,n]);return t._markAllSubMeshesAsTexturesDirty(),o}},r.prototype.getSubMaterial=function(e){return e<0||e>=this.subMaterials.length?this.getScene().defaultMaterial:this.subMaterials[e]},r.prototype.getActiveTextures=function(){return(e=t.prototype.getActiveTextures.call(this)).concat.apply(e,this.subMaterials.map((function(e){return e.getActiveTextures()})));var e},r.prototype.getClassName=function(){return"MultiMaterial"},r.prototype.isReadyForSubMesh=function(e,t,r){for(var i=0;i<this.subMaterials.length;i++){if(this.subMaterials[i]){if(this.subMaterials[i].storeEffectOnSubMeshes){if(!this.subMaterials[i].isReadyForSubMesh(e,t,r))return!1;continue}if(!this.subMaterials[i].isReady(e))return!1}}return!0},r.prototype.clone=function(e,t){for(var i=new r(e,this.getScene()),n=0;n<this.subMaterials.length;n++){var o=null;o=t?this.subMaterials[n].clone(e+"-"+this.subMaterials[n].name):this.subMaterials[n],i.subMaterials.push(o)}return i},r.prototype.serialize=function(){var t={};t.name=this.name,t.id=this.id,t.tags=e.Tags.GetTags(this),t.materials=[];for(var r=0;r<this.subMaterials.length;r++){var i=this.subMaterials[r];i?t.materials.push(i.id):t.materials.push(null)}return t},r.prototype.dispose=function(e,r){var i=this.getScene();if(i){var n=i.multiMaterials.indexOf(this);n>=0&&i.multiMaterials.splice(n,1),t.prototype.dispose.call(this,e,r)}},r})(e.Material);e.MultiMaterial=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(e){function t(){var t=e.call(this)||this;return t.PBR=!0,t.MAINUV1=!1,t.MAINUV2=!1,t.UV1=!1,t.UV2=!1,t.ALBEDO=!1,t.ALBEDODIRECTUV=0,t.VERTEXCOLOR=!1,t.AMBIENT=!1,t.AMBIENTDIRECTUV=0,t.AMBIENTINGRAYSCALE=!1,t.OPACITY=!1,t.VERTEXALPHA=!1,t.OPACITYDIRECTUV=0,t.OPACITYRGB=!1,t.ALPHATEST=!1,t.ALPHABLEND=!1,t.ALPHAFROMALBEDO=!1,t.ALPHATESTVALUE=.5,t.SPECULAROVERALPHA=!1,t.RADIANCEOVERALPHA=!1,t.ALPHAFRESNEL=!1,t.PREMULTIPLYALPHA=!1,t.EMISSIVE=!1,t.EMISSIVEDIRECTUV=0,t.REFLECTIVITY=!1,t.REFLECTIVITYDIRECTUV=0,t.SPECULARTERM=!1,t.MICROSURFACEFROMREFLECTIVITYMAP=!1,t.MICROSURFACEAUTOMATIC=!1,t.LODBASEDMICROSFURACE=!1,t.MICROSURFACEMAP=!1,t.MICROSURFACEMAPDIRECTUV=0,t.METALLICWORKFLOW=!1,t.ROUGHNESSSTOREINMETALMAPALPHA=!1,t.ROUGHNESSSTOREINMETALMAPGREEN=!1,t.METALLNESSSTOREINMETALMAPBLUE=!1,t.AOSTOREINMETALMAPRED=!1,t.ENVIRONMENTBRDF=!1,t.NORMAL=!1,t.TANGENT=!1,t.BUMP=!1,t.BUMPDIRECTUV=0,t.PARALLAX=!1,t.PARALLAXOCCLUSION=!1,t.NORMALXYSCALE=!0,t.LIGHTMAP=!1,t.LIGHTMAPDIRECTUV=0,t.USELIGHTMAPASSHADOWMAP=!1,t.REFLECTION=!1,t.REFLECTIONMAP_3D=!1,t.REFLECTIONMAP_SPHERICAL=!1,t.REFLECTIONMAP_PLANAR=!1,t.REFLECTIONMAP_CUBIC=!1,t.REFLECTIONMAP_PROJECTION=!1,t.REFLECTIONMAP_SKYBOX=!1,t.REFLECTIONMAP_EXPLICIT=!1,t.REFLECTIONMAP_EQUIRECTANGULAR=!1,t.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,t.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,t.INVERTCUBICMAP=!1,t.USESPHERICALFROMREFLECTIONMAP=!1,t.USESPHERICALINFRAGMENT=!1,t.REFLECTIONMAP_OPPOSITEZ=!1,t.LODINREFLECTIONALPHA=!1,t.GAMMAREFLECTION=!1,t.REFRACTION=!1,t.REFRACTIONMAP_3D=!1,t.REFRACTIONMAP_OPPOSITEZ=!1,t.LODINREFRACTIONALPHA=!1,t.GAMMAREFRACTION=!1,t.LINKREFRACTIONTOTRANSPARENCY=!1,t.INSTANCES=!1,t.NUM_BONE_INFLUENCERS=0,t.BonesPerMesh=0,t.MORPHTARGETS=!1,t.MORPHTARGETS_NORMAL=!1,t.MORPHTARGETS_TANGENT=!1,t.NUM_MORPH_INFLUENCERS=0,t.IMAGEPROCESSING=!1,t.VIGNETTE=!1,t.VIGNETTEBLENDMODEMULTIPLY=!1,t.VIGNETTEBLENDMODEOPAQUE=!1,t.TONEMAPPING=!1,t.CONTRAST=!1,t.COLORCURVES=!1,t.COLORGRADING=!1,t.SAMPLER3DGREENDEPTH=!1,t.SAMPLER3DBGRMAP=!1,t.IMAGEPROCESSINGPOSTPROCESS=!1,t.EXPOSURE=!1,t.USEPHYSICALLIGHTFALLOFF=!1,t.TWOSIDEDLIGHTING=!1,t.SHADOWFLOAT=!1,t.USERIGHTHANDEDSYSTEM=!1,t.CLIPPLANE=!1,t.POINTSIZE=!1,t.FOG=!1,t.LOGARITHMICDEPTH=!1,t.FORCENORMALFORWARD=!1,t.rebuild(),t}return __extends(t,e),t.prototype.reset=function(){e.prototype.reset.call(this),this.ALPHATESTVALUE=.5,this.PBR=!0},t})(e.MaterialDefines),r=(function(r){function i(t,i){var n=r.call(this,t,i)||this;return n._directIntensity=1,n._emissiveIntensity=1,n._environmentIntensity=1,n._specularIntensity=1,n._lightingInfos=new e.Vector4(n._directIntensity,n._emissiveIntensity,n._environmentIntensity,n._specularIntensity),n._disableBumpMap=!1,n._ambientTextureStrength=1,n._ambientColor=new e.Color3(0,0,0),n._albedoColor=new e.Color3(1,1,1),n._reflectivityColor=new e.Color3(1,1,1),n._reflectionColor=new e.Color3(1,1,1),n._emissiveColor=new e.Color3(0,0,0),n._microSurface=.9,n._indexOfRefraction=.66,n._invertRefractionY=!1,n._linkRefractionWithTransparency=!1,n._useLightmapAsShadowmap=!1,n._useAlphaFromAlbedoTexture=!1,n._useSpecularOverAlpha=!0,n._useMicroSurfaceFromReflectivityMapAlpha=!1,n._useRoughnessFromMetallicTextureAlpha=!0,n._useRoughnessFromMetallicTextureGreen=!1,n._useMetallnessFromMetallicTextureBlue=!1,n._useAmbientOcclusionFromMetallicTextureRed=!1,n._useAmbientInGrayScale=!1,n._useAutoMicroSurfaceFromReflectivityMap=!1,n._usePhysicalLightFalloff=!0,n._useRadianceOverAlpha=!0,n._useParallax=!1,n._useParallaxOcclusion=!1,n._parallaxScaleBias=.05,n._disableLighting=!1,n._maxSimultaneousLights=4,n._invertNormalMapX=!1,n._invertNormalMapY=!1,n._twoSidedLighting=!1,n._alphaCutOff=.4,n._forceAlphaTest=!1,n._preMultiplyAlpha=!1,n._useAlphaFresnel=!1,n._environmentBRDFTexture=null,n._forceIrradianceInFragment=!1,n._forceNormalForward=!1,n._renderTargets=new e.SmartArray(16),n._worldViewProjectionMatrix=e.Matrix.Zero(),n._globalAmbientColor=new e.Color3(0,0,0),n._tempColor=new e.Color3,n._attachImageProcessingConfiguration(null),n.getRenderTargetTextures=function(){return n._renderTargets.reset(),e.StandardMaterial.ReflectionTextureEnabled&&n._reflectionTexture&&n._reflectionTexture.isRenderTarget&&n._renderTargets.push(n._reflectionTexture),e.StandardMaterial.RefractionTextureEnabled&&n._refractionTexture&&n._refractionTexture.isRenderTarget&&n._renderTargets.push(n._refractionTexture),n._renderTargets},n._environmentBRDFTexture=e.TextureTools.GetEnvironmentBRDFTexture(i),n}return __extends(i,r),i.prototype._attachImageProcessingConfiguration=function(e){var t=this;e!==this._imageProcessingConfiguration&&(this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),this._imageProcessingConfiguration=e||this.getScene().imageProcessingConfiguration,this._imageProcessingObserver=this._imageProcessingConfiguration.onUpdateParameters.add((function(e){t._markAllSubMeshesAsImageProcessingDirty()})))},i.prototype.getClassName=function(){return"PBRBaseMaterial"},Object.defineProperty(i.prototype,"useLogarithmicDepth",{get:function(){return this._useLogarithmicDepth},set:function(e){this._useLogarithmicDepth=e&&this.getScene().getEngine().getCaps().fragmentDepthSupported},enumerable:!0,configurable:!0}),i.prototype.needAlphaBlending=function(){return!this._linkRefractionWithTransparency&&(this.alpha<1||null!=this._opacityTexture||this._shouldUseAlphaFromAlbedoTexture())},i.prototype.needAlphaTesting=function(){return!!this._forceAlphaTest||!this._linkRefractionWithTransparency&&(null!=this._albedoTexture&&this._albedoTexture.hasAlpha)},i.prototype._shouldUseAlphaFromAlbedoTexture=function(){return null!=this._albedoTexture&&this._albedoTexture.hasAlpha&&this._useAlphaFromAlbedoTexture},i.prototype.getAlphaTestTexture=function(){return this._albedoTexture},i.prototype.isReadyForSubMesh=function(r,i,n){if(this.isFrozen&&this._wasPreviouslyReady)return!0;i._materialDefines||(i._materialDefines=new t);var o=this.getScene(),s=i._materialDefines;if(!this.checkReadyOnEveryCall&&i.effect&&s._renderId===o.getRenderId())return!0;var a=o.getEngine();if(e.MaterialHelper.PrepareDefinesForLights(o,r,s,!0,this._maxSimultaneousLights,this._disableLighting),s._needNormals=!0,s._areTexturesDirty){if(s._needUVs=!1,o.texturesEnabled){if(o.getEngine().getCaps().textureLOD&&(s.LODBASEDMICROSFURACE=!0),this._albedoTexture&&e.StandardMaterial.DiffuseTextureEnabled){if(!this._albedoTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._albedoTexture,s,"ALBEDO")}else s.ALBEDO=!1;if(this._ambientTexture&&e.StandardMaterial.AmbientTextureEnabled){if(!this._ambientTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._ambientTexture,s,"AMBIENT"),s.AMBIENTINGRAYSCALE=this._useAmbientInGrayScale}else s.AMBIENT=!1;if(this._opacityTexture&&e.StandardMaterial.OpacityTextureEnabled){if(!this._opacityTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._opacityTexture,s,"OPACITY"),s.OPACITYRGB=this._opacityTexture.getAlphaFromRGB}else s.OPACITY=!1;var u=this._getReflectionTexture();if(u&&e.StandardMaterial.ReflectionTextureEnabled){if(!u.isReadyOrNotBlocking())return!1;switch(s.REFLECTION=!0,s.GAMMAREFLECTION=u.gammaSpace,s.REFLECTIONMAP_OPPOSITEZ=this.getScene().useRightHandedSystem?!u.invertZ:u.invertZ,s.LODINREFLECTIONALPHA=u.lodLevelInAlpha,u.coordinatesMode===e.Texture.INVCUBIC_MODE&&(s.INVERTCUBICMAP=!0),s.REFLECTIONMAP_3D=u.isCube,u.coordinatesMode){case e.Texture.CUBIC_MODE:case e.Texture.INVCUBIC_MODE:s.REFLECTIONMAP_CUBIC=!0;break;case e.Texture.EXPLICIT_MODE:s.REFLECTIONMAP_EXPLICIT=!0;break;case e.Texture.PLANAR_MODE:s.REFLECTIONMAP_PLANAR=!0;break;case e.Texture.PROJECTION_MODE:s.REFLECTIONMAP_PROJECTION=!0;break;case e.Texture.SKYBOX_MODE:s.REFLECTIONMAP_SKYBOX=!0;break;case e.Texture.SPHERICAL_MODE:s.REFLECTIONMAP_SPHERICAL=!0;break;case e.Texture.EQUIRECTANGULAR_MODE:s.REFLECTIONMAP_EQUIRECTANGULAR=!0;break;case e.Texture.FIXED_EQUIRECTANGULAR_MODE:s.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!0;break;case e.Texture.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:s.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!0}u.coordinatesMode!==e.Texture.SKYBOX_MODE&&u.sphericalPolynomial&&(s.USESPHERICALFROMREFLECTIONMAP=!0,(this._forceIrradianceInFragment||o.getEngine().getCaps().maxVaryingVectors<=8)&&(s.USESPHERICALINFRAGMENT=!0))}else s.REFLECTION=!1,s.REFLECTIONMAP_3D=!1,s.REFLECTIONMAP_SPHERICAL=!1,s.REFLECTIONMAP_PLANAR=!1,s.REFLECTIONMAP_CUBIC=!1,s.REFLECTIONMAP_PROJECTION=!1,s.REFLECTIONMAP_SKYBOX=!1,s.REFLECTIONMAP_EXPLICIT=!1,s.REFLECTIONMAP_EQUIRECTANGULAR=!1,s.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,s.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,s.INVERTCUBICMAP=!1,s.USESPHERICALFROMREFLECTIONMAP=!1,s.USESPHERICALINFRAGMENT=!1,s.REFLECTIONMAP_OPPOSITEZ=!1,s.LODINREFLECTIONALPHA=!1,s.GAMMAREFLECTION=!1;if(this._lightmapTexture&&e.StandardMaterial.LightmapTextureEnabled){if(!this._lightmapTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._lightmapTexture,s,"LIGHTMAP"),s.USELIGHTMAPASSHADOWMAP=this._useLightmapAsShadowmap}else s.LIGHTMAP=!1;if(this._emissiveTexture&&e.StandardMaterial.EmissiveTextureEnabled){if(!this._emissiveTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._emissiveTexture,s,"EMISSIVE")}else s.EMISSIVE=!1;if(e.StandardMaterial.SpecularTextureEnabled){if(this._metallicTexture){if(!this._metallicTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._metallicTexture,s,"REFLECTIVITY"),s.METALLICWORKFLOW=!0,s.ROUGHNESSSTOREINMETALMAPALPHA=this._useRoughnessFromMetallicTextureAlpha,s.ROUGHNESSSTOREINMETALMAPGREEN=!this._useRoughnessFromMetallicTextureAlpha&&this._useRoughnessFromMetallicTextureGreen,s.METALLNESSSTOREINMETALMAPBLUE=this._useMetallnessFromMetallicTextureBlue,s.AOSTOREINMETALMAPRED=this._useAmbientOcclusionFromMetallicTextureRed}else if(this._reflectivityTexture){if(!this._reflectivityTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._reflectivityTexture,s,"REFLECTIVITY"),s.MICROSURFACEFROMREFLECTIVITYMAP=this._useMicroSurfaceFromReflectivityMapAlpha,s.MICROSURFACEAUTOMATIC=this._useAutoMicroSurfaceFromReflectivityMap}else s.REFLECTIVITY=!1;if(this._microSurfaceTexture){if(!this._microSurfaceTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._microSurfaceTexture,s,"MICROSURFACEMAP")}else s.MICROSURFACEMAP=!1}else s.REFLECTIVITY=!1,s.MICROSURFACEMAP=!1;if(o.getEngine().getCaps().standardDerivatives&&this._bumpTexture&&e.StandardMaterial.BumpTextureEnabled&&!this._disableBumpMap){if(!this._bumpTexture.isReady())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._bumpTexture,s,"BUMP"),this._useParallax&&this._albedoTexture&&e.StandardMaterial.DiffuseTextureEnabled?(s.PARALLAX=!0,s.PARALLAXOCCLUSION=!!this._useParallaxOcclusion):s.PARALLAX=!1,s.USERIGHTHANDEDSYSTEM=o.useRightHandedSystem}else s.BUMP=!1;var l=this._getRefractionTexture();if(l&&e.StandardMaterial.RefractionTextureEnabled){if(!l.isReadyOrNotBlocking())return!1;s.REFRACTION=!0,s.REFRACTIONMAP_3D=l.isCube,s.GAMMAREFRACTION=l.gammaSpace,s.REFRACTIONMAP_OPPOSITEZ=u.invertZ,s.LODINREFRACTIONALPHA=u.lodLevelInAlpha,this._linkRefractionWithTransparency&&(s.LINKREFRACTIONTOTRANSPARENCY=!0)}else s.REFRACTION=!1;if(this._environmentBRDFTexture&&e.StandardMaterial.ReflectionTextureEnabled){if(!this._environmentBRDFTexture.isReady())return!1;s.ENVIRONMENTBRDF=!0}this._shouldUseAlphaFromAlbedoTexture()&&(s.ALPHAFROMALBEDO=!0)}this._useSpecularOverAlpha&&(s.SPECULAROVERALPHA=!0),this._usePhysicalLightFalloff&&(s.USEPHYSICALLIGHTFALLOFF=!0),this._useRadianceOverAlpha&&(s.RADIANCEOVERALPHA=!0),(void 0!==this._metallic&&null!==this._metallic||void 0!==this._roughness&&null!==this._roughness)&&(s.METALLICWORKFLOW=!0),!this.backFaceCulling&&this._twoSidedLighting&&(s.TWOSIDEDLIGHTING=!0),s.ALPHATESTVALUE=this._alphaCutOff,s.PREMULTIPLYALPHA=this._preMultiplyAlpha,s.ALPHABLEND=this.needAlphaBlending(),s.ALPHAFRESNEL=this._useAlphaFresnel}if(s._areImageProcessingDirty){if(!this._imageProcessingConfiguration.isReady())return!1;this._imageProcessingConfiguration.prepareDefines(s)}if(s.FORCENORMALFORWARD=this._forceNormalForward,e.MaterialHelper.PrepareDefinesForMisc(r,o,this._useLogarithmicDepth,this.pointsCloud,this.fogEnabled,s),e.MaterialHelper.PrepareDefinesForFrameBoundValues(o,a,s,n,this._forceAlphaTest),e.MaterialHelper.PrepareDefinesForAttributes(r,s,!0,!0,!0)&&r&&(o.getEngine().getCaps().standardDerivatives||r.isVerticesDataPresent(e.VertexBuffer.NormalKind)||(r.createNormals(!0),e.Tools.Warn("PBRMaterial: Normals have been created for the mesh: "+r.name))),s.isDirty){s.markAsProcessed(),o.resetCachedMaterial();var h=new e.EffectFallbacks;s.ENVIRONMENTBRDF&&h.addFallback(0,"ENVIRONMENTBRDF"),s.REFLECTION&&h.addFallback(0,"REFLECTION"),s.REFRACTION&&h.addFallback(0,"REFRACTION"),s.REFLECTIVITY&&h.addFallback(0,"REFLECTIVITY"),s.BUMP&&h.addFallback(0,"BUMP"),s.PARALLAX&&h.addFallback(1,"PARALLAX"),s.PARALLAXOCCLUSION&&h.addFallback(0,"PARALLAXOCCLUSION"),s.SPECULAROVERALPHA&&h.addFallback(0,"SPECULAROVERALPHA"),s.FOG&&h.addFallback(1,"FOG"),s.POINTSIZE&&h.addFallback(0,"POINTSIZE"),s.LOGARITHMICDEPTH&&h.addFallback(0,"LOGARITHMICDEPTH"),e.MaterialHelper.HandleFallbacksForShadows(s,h,this._maxSimultaneousLights),s.SPECULARTERM&&h.addFallback(0,"SPECULARTERM"),s.NUM_BONE_INFLUENCERS>0&&h.addCPUSkinningFallback(0,r);var c=[e.VertexBuffer.PositionKind];s.NORMAL&&c.push(e.VertexBuffer.NormalKind),s.TANGENT&&c.push(e.VertexBuffer.TangentKind),s.UV1&&c.push(e.VertexBuffer.UVKind),s.UV2&&c.push(e.VertexBuffer.UV2Kind),s.VERTEXCOLOR&&c.push(e.VertexBuffer.ColorKind),e.MaterialHelper.PrepareAttributesForBones(c,r,s,h),e.MaterialHelper.PrepareAttributesForInstances(c,s),e.MaterialHelper.PrepareAttributesForMorphTargets(c,r,s);var f=["world","view","viewProjection","vEyePosition","vLightsType","vAmbientColor","vAlbedoColor","vReflectivityColor","vEmissiveColor","vReflectionColor","vFogInfos","vFogColor","pointSize","vAlbedoInfos","vAmbientInfos","vOpacityInfos","vReflectionInfos","vEmissiveInfos","vReflectivityInfos","vMicroSurfaceSamplerInfos","vBumpInfos","vLightmapInfos","vRefractionInfos","mBones","vClipPlane","albedoMatrix","ambientMatrix","opacityMatrix","reflectionMatrix","emissiveMatrix","reflectivityMatrix","microSurfaceSamplerMatrix","bumpMatrix","lightmapMatrix","refractionMatrix","vLightingIntensity","logarithmicDepthConstant","vSphericalX","vSphericalY","vSphericalZ","vSphericalXX","vSphericalYY","vSphericalZZ","vSphericalXY","vSphericalYZ","vSphericalZX","vReflectionMicrosurfaceInfos","vRefractionMicrosurfaceInfos","vNormalReoderParams"],d=["albedoSampler","reflectivitySampler","ambientSampler","emissiveSampler","bumpSampler","lightmapSampler","opacitySampler","refractionSampler","refractionSamplerLow","refractionSamplerHigh","reflectionSampler","reflectionSamplerLow","reflectionSamplerHigh","microSurfaceSampler","environmentBrdfSampler"],p=["Material","Scene"];e.ImageProcessingConfiguration.PrepareUniforms(f,s),e.ImageProcessingConfiguration.PrepareSamplers(d,s),e.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:f,uniformBuffersNames:p,samplers:d,defines:s,maxSimultaneousLights:this._maxSimultaneousLights});var g=function(e){this.onCompiled&&this.onCompiled(e),this.bindSceneUniformBuffer(e,o.getSceneUniformBuffer())}.bind(this),_=s.toString();i.setEffect(o.getEngine().createEffect("pbr",{attributes:c,uniformsNames:f,uniformBuffersNames:p,samplers:d,defines:_,fallbacks:h,onCompiled:g,onError:this.onError,indexParameters:{maxSimultaneousLights:this._maxSimultaneousLights,maxSimultaneousMorphTargets:s.NUM_MORPH_INFLUENCERS}},a),s),this.buildUniformLayout()}return!!i.effect.isReady()&&(s._renderId=o.getRenderId(),this._wasPreviouslyReady=!0,!0)},i.prototype.buildUniformLayout=function(){this._uniformBuffer.addUniform("vAlbedoInfos",2),this._uniformBuffer.addUniform("vAmbientInfos",3),this._uniformBuffer.addUniform("vOpacityInfos",2),this._uniformBuffer.addUniform("vEmissiveInfos",2),this._uniformBuffer.addUniform("vLightmapInfos",2),this._uniformBuffer.addUniform("vReflectivityInfos",3),this._uniformBuffer.addUniform("vMicroSurfaceSamplerInfos",2),this._uniformBuffer.addUniform("vRefractionInfos",4),this._uniformBuffer.addUniform("vReflectionInfos",2),this._uniformBuffer.addUniform("vBumpInfos",3),this._uniformBuffer.addUniform("albedoMatrix",16),this._uniformBuffer.addUniform("ambientMatrix",16),this._uniformBuffer.addUniform("opacityMatrix",16),this._uniformBuffer.addUniform("emissiveMatrix",16),this._uniformBuffer.addUniform("lightmapMatrix",16),this._uniformBuffer.addUniform("reflectivityMatrix",16),this._uniformBuffer.addUniform("microSurfaceSamplerMatrix",16),this._uniformBuffer.addUniform("bumpMatrix",16),this._uniformBuffer.addUniform("vNormalReoderParams",4),this._uniformBuffer.addUniform("refractionMatrix",16),this._uniformBuffer.addUniform("reflectionMatrix",16),this._uniformBuffer.addUniform("vReflectionColor",3),this._uniformBuffer.addUniform("vAlbedoColor",4),this._uniformBuffer.addUniform("vLightingIntensity",4),this._uniformBuffer.addUniform("vRefractionMicrosurfaceInfos",3),this._uniformBuffer.addUniform("vReflectionMicrosurfaceInfos",3),this._uniformBuffer.addUniform("vReflectivityColor",4),this._uniformBuffer.addUniform("vEmissiveColor",3),this._uniformBuffer.addUniform("pointSize",1),this._uniformBuffer.create()},i.prototype.unbind=function(){this._reflectionTexture&&this._reflectionTexture.isRenderTarget&&this._uniformBuffer.setTexture("reflectionSampler",null),this._refractionTexture&&this._refractionTexture.isRenderTarget&&this._uniformBuffer.setTexture("refractionSampler",null),r.prototype.unbind.call(this)},i.prototype.bindOnlyWorldMatrix=function(e){this._activeEffect.setMatrix("world",e)},i.prototype.bindForSubMesh=function(t,r,i){var n=this.getScene(),o=i._materialDefines;if(o){var s=i.effect;this._activeEffect=s,this.bindOnlyWorldMatrix(t);var a=this._mustRebind(n,s,r.visibility);if(e.MaterialHelper.BindBonesParameters(r,this._activeEffect),a){if(this._uniformBuffer.bindToEffect(s,"Material"),this.bindViewProjection(s),!this._uniformBuffer.useUbo||!this.isFrozen||!this._uniformBuffer.isSync){if(n.texturesEnabled){this._albedoTexture&&e.StandardMaterial.DiffuseTextureEnabled&&(this._uniformBuffer.updateFloat2("vAlbedoInfos",this._albedoTexture.coordinatesIndex,this._albedoTexture.level),e.MaterialHelper.BindTextureMatrix(this._albedoTexture,this._uniformBuffer,"albedo")),this._ambientTexture&&e.StandardMaterial.AmbientTextureEnabled&&(this._uniformBuffer.updateFloat3("vAmbientInfos",this._ambientTexture.coordinatesIndex,this._ambientTexture.level,this._ambientTextureStrength),e.MaterialHelper.BindTextureMatrix(this._ambientTexture,this._uniformBuffer,"ambient")),this._opacityTexture&&e.StandardMaterial.OpacityTextureEnabled&&(this._uniformBuffer.updateFloat2("vOpacityInfos",this._opacityTexture.coordinatesIndex,this._opacityTexture.level),e.MaterialHelper.BindTextureMatrix(this._opacityTexture,this._uniformBuffer,"opacity"));var u=this._getReflectionTexture();if(u&&e.StandardMaterial.ReflectionTextureEnabled){if(this._uniformBuffer.updateMatrix("reflectionMatrix",u.getReflectionTextureMatrix()),this._uniformBuffer.updateFloat2("vReflectionInfos",u.level,0),o.USESPHERICALFROMREFLECTIONMAP){var l=u.sphericalPolynomial;this._activeEffect.setFloat3("vSphericalX",l.x.x,l.x.y,l.x.z),this._activeEffect.setFloat3("vSphericalY",l.y.x,l.y.y,l.y.z),this._activeEffect.setFloat3("vSphericalZ",l.z.x,l.z.y,l.z.z),this._activeEffect.setFloat3("vSphericalXX_ZZ",l.xx.x-l.zz.x,l.xx.y-l.zz.y,l.xx.z-l.zz.z),this._activeEffect.setFloat3("vSphericalYY_ZZ",l.yy.x-l.zz.x,l.yy.y-l.zz.y,l.yy.z-l.zz.z),this._activeEffect.setFloat3("vSphericalZZ",l.zz.x,l.zz.y,l.zz.z),this._activeEffect.setFloat3("vSphericalXY",l.xy.x,l.xy.y,l.xy.z),this._activeEffect.setFloat3("vSphericalYZ",l.yz.x,l.yz.y,l.yz.z),this._activeEffect.setFloat3("vSphericalZX",l.zx.x,l.zx.y,l.zx.z)}this._uniformBuffer.updateFloat3("vReflectionMicrosurfaceInfos",u.getSize().width,u.lodGenerationScale,u.lodGenerationOffset)}this._emissiveTexture&&e.StandardMaterial.EmissiveTextureEnabled&&(this._uniformBuffer.updateFloat2("vEmissiveInfos",this._emissiveTexture.coordinatesIndex,this._emissiveTexture.level),e.MaterialHelper.BindTextureMatrix(this._emissiveTexture,this._uniformBuffer,"emissive")),this._lightmapTexture&&e.StandardMaterial.LightmapTextureEnabled&&(this._uniformBuffer.updateFloat2("vLightmapInfos",this._lightmapTexture.coordinatesIndex,this._lightmapTexture.level),e.MaterialHelper.BindTextureMatrix(this._lightmapTexture,this._uniformBuffer,"lightmap")),e.StandardMaterial.SpecularTextureEnabled&&(this._metallicTexture?(this._uniformBuffer.updateFloat3("vReflectivityInfos",this._metallicTexture.coordinatesIndex,this._metallicTexture.level,this._ambientTextureStrength),e.MaterialHelper.BindTextureMatrix(this._metallicTexture,this._uniformBuffer,"reflectivity")):this._reflectivityTexture&&(this._uniformBuffer.updateFloat3("vReflectivityInfos",this._reflectivityTexture.coordinatesIndex,this._reflectivityTexture.level,1),e.MaterialHelper.BindTextureMatrix(this._reflectivityTexture,this._uniformBuffer,"reflectivity")),this._microSurfaceTexture&&(this._uniformBuffer.updateFloat2("vMicroSurfaceSamplerInfos",this._microSurfaceTexture.coordinatesIndex,this._microSurfaceTexture.level),e.MaterialHelper.BindTextureMatrix(this._microSurfaceTexture,this._uniformBuffer,"microSurfaceSampler"))),this._bumpTexture&&n.getEngine().getCaps().standardDerivatives&&e.StandardMaterial.BumpTextureEnabled&&!this._disableBumpMap&&(this._uniformBuffer.updateFloat3("vBumpInfos",this._bumpTexture.coordinatesIndex,this._bumpTexture.level,this._parallaxScaleBias),e.MaterialHelper.BindTextureMatrix(this._bumpTexture,this._uniformBuffer,"bump"),n._mirroredCameraPosition?this._uniformBuffer.updateFloat4("vNormalReoderParams",this._invertNormalMapX?0:1,this._invertNormalMapX?1:-1,this._invertNormalMapY?0:1,this._invertNormalMapY?1:-1):this._uniformBuffer.updateFloat4("vNormalReoderParams",this._invertNormalMapX?1:0,this._invertNormalMapX?-1:1,this._invertNormalMapY?1:0,this._invertNormalMapY?-1:1));var h=this._getRefractionTexture();if(h&&e.StandardMaterial.RefractionTextureEnabled){this._uniformBuffer.updateMatrix("refractionMatrix",h.getReflectionTextureMatrix());var c=1;h.isCube||h.depth&&(c=h.depth),this._uniformBuffer.updateFloat4("vRefractionInfos",h.level,this._indexOfRefraction,c,this._invertRefractionY?-1:1),this._uniformBuffer.updateFloat3("vRefractionMicrosurfaceInfos",h.getSize().width,h.lodGenerationScale,h.lodGenerationOffset)}}this.pointsCloud&&this._uniformBuffer.updateFloat("pointSize",this.pointSize),o.METALLICWORKFLOW?(e.PBRMaterial._scaledReflectivity.r=void 0===this._metallic||null===this._metallic?1:this._metallic,e.PBRMaterial._scaledReflectivity.g=void 0===this._roughness||null===this._roughness?1:this._roughness,this._uniformBuffer.updateColor4("vReflectivityColor",e.PBRMaterial._scaledReflectivity,0)):this._uniformBuffer.updateColor4("vReflectivityColor",this._reflectivityColor,this._microSurface),this._uniformBuffer.updateColor3("vEmissiveColor",this._emissiveColor),this._uniformBuffer.updateColor3("vReflectionColor",this._reflectionColor),this._uniformBuffer.updateColor4("vAlbedoColor",this._albedoColor,this.alpha*r.visibility),this._lightingInfos.x=this._directIntensity,this._lightingInfos.y=this._emissiveIntensity,this._lightingInfos.z=this._environmentIntensity,this._lightingInfos.w=this._specularIntensity,this._uniformBuffer.updateVector4("vLightingIntensity",this._lightingInfos)}n.texturesEnabled&&(this._albedoTexture&&e.StandardMaterial.DiffuseTextureEnabled&&this._uniformBuffer.setTexture("albedoSampler",this._albedoTexture),this._ambientTexture&&e.StandardMaterial.AmbientTextureEnabled&&this._uniformBuffer.setTexture("ambientSampler",this._ambientTexture),this._opacityTexture&&e.StandardMaterial.OpacityTextureEnabled&&this._uniformBuffer.setTexture("opacitySampler",this._opacityTexture),u&&e.StandardMaterial.ReflectionTextureEnabled&&(o.LODBASEDMICROSFURACE?this._uniformBuffer.setTexture("reflectionSampler",u):(this._uniformBuffer.setTexture("reflectionSampler",u._lodTextureMid||u),this._uniformBuffer.setTexture("reflectionSamplerLow",u._lodTextureLow||u),this._uniformBuffer.setTexture("reflectionSamplerHigh",u._lodTextureHigh||u))),o.ENVIRONMENTBRDF&&this._uniformBuffer.setTexture("environmentBrdfSampler",this._environmentBRDFTexture),h&&e.StandardMaterial.RefractionTextureEnabled&&(o.LODBASEDMICROSFURACE?this._uniformBuffer.setTexture("refractionSampler",h):(this._uniformBuffer.setTexture("refractionSampler",h._lodTextureMid||h),this._uniformBuffer.setTexture("refractionSamplerLow",h._lodTextureLow||h),this._uniformBuffer.setTexture("refractionSamplerHigh",h._lodTextureHigh||h))),this._emissiveTexture&&e.StandardMaterial.EmissiveTextureEnabled&&this._uniformBuffer.setTexture("emissiveSampler",this._emissiveTexture),this._lightmapTexture&&e.StandardMaterial.LightmapTextureEnabled&&this._uniformBuffer.setTexture("lightmapSampler",this._lightmapTexture),e.StandardMaterial.SpecularTextureEnabled&&(this._metallicTexture?this._uniformBuffer.setTexture("reflectivitySampler",this._metallicTexture):this._reflectivityTexture&&this._uniformBuffer.setTexture("reflectivitySampler",this._reflectivityTexture),this._microSurfaceTexture&&this._uniformBuffer.setTexture("microSurfaceSampler",this._microSurfaceTexture)),this._bumpTexture&&n.getEngine().getCaps().standardDerivatives&&e.StandardMaterial.BumpTextureEnabled&&!this._disableBumpMap&&this._uniformBuffer.setTexture("bumpSampler",this._bumpTexture)),e.MaterialHelper.BindClipPlane(this._activeEffect,n),n.ambientColor.multiplyToRef(this._ambientColor,this._globalAmbientColor);var f=n._mirroredCameraPosition?n._mirroredCameraPosition:n.activeCamera.globalPosition
- ;s.setFloat4("vEyePosition",f.x,f.y,f.z,n._mirroredCameraPosition?-1:1),s.setColor3("vAmbientColor",this._globalAmbientColor)}!a&&this.isFrozen||(n.lightsEnabled&&!this._disableLighting&&e.MaterialHelper.BindLights(n,r,this._activeEffect,o,this._maxSimultaneousLights,this._usePhysicalLightFalloff),(n.fogEnabled&&r.applyFog&&n.fogMode!==e.Scene.FOGMODE_NONE||u)&&this.bindView(s),e.MaterialHelper.BindFogParameters(n,r,this._activeEffect),o.NUM_MORPH_INFLUENCERS&&e.MaterialHelper.BindMorphTargetParameters(r,this._activeEffect),this._imageProcessingConfiguration.bind(this._activeEffect),e.MaterialHelper.BindLogDepth(o,this._activeEffect,n)),this._uniformBuffer.update(),this._afterBind(r),n=null}},i.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),e},i.prototype._getReflectionTexture=function(){return this._reflectionTexture?this._reflectionTexture:this.getScene().environmentTexture},i.prototype._getRefractionTexture=function(){return this._refractionTexture?this._refractionTexture:this._linkRefractionWithTransparency?this.getScene().environmentTexture:null},i.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._environmentBRDFTexture&&this._environmentBRDFTexture.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._renderTargets.dispose(),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),r.prototype.dispose.call(this,e,t)},i._scaledReflectivity=new e.Color3,__decorate([e.serializeAsImageProcessingConfiguration()],i.prototype,"_imageProcessingConfiguration",void 0),__decorate([e.serialize()],i.prototype,"useLogarithmicDepth",null),i})(e.PushMaterial);e.PBRBaseMaterial=r})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(t){var r=(function(t){function r(r,i){var n=t.call(this,r,i)||this;return n.maxSimultaneousLights=4,n.disableLighting=!1,n.invertNormalMapX=!1,n.invertNormalMapY=!1,n.emissiveColor=new e.Color3(0,0,0),n.occlusionStrength=1,n._transparencyMode=e.PBRMaterial.PBRMATERIAL_OPAQUE,n._useAmbientInGrayScale=!0,n}return __extends(r,t),Object.defineProperty(r.prototype,"transparencyMode",{get:function(){return this._transparencyMode},set:function(t){this._transparencyMode!==t&&(this._transparencyMode=t,t===e.PBRMaterial.PBRMATERIAL_ALPHATESTANDBLEND?this._forceAlphaTest=!0:this._forceAlphaTest=!1,this._markAllSubMeshesAsTexturesDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"doubleSided",{get:function(){return this._twoSidedLighting},set:function(e){this._twoSidedLighting!==e&&(this._twoSidedLighting=e,this.backFaceCulling=!e,this._markAllSubMeshesAsTexturesDirty())},enumerable:!0,configurable:!0}),r.prototype._shouldUseAlphaFromAlbedoTexture=function(){return this._albedoTexture&&this._albedoTexture.hasAlpha&&this._transparencyMode!==e.PBRMaterial.PBRMATERIAL_OPAQUE},r.prototype.needAlphaBlending=function(){return!this._linkRefractionWithTransparency&&(this.alpha<1||this._shouldUseAlphaFromAlbedoTexture()&&(this._transparencyMode===e.PBRMaterial.PBRMATERIAL_ALPHABLEND||this._transparencyMode===e.PBRMaterial.PBRMATERIAL_ALPHATESTANDBLEND))},r.prototype.needAlphaTesting=function(){return!this._linkRefractionWithTransparency&&(this._shouldUseAlphaFromAlbedoTexture()&&this._transparencyMode===e.PBRMaterial.PBRMATERIAL_ALPHATEST)},r.prototype.getActiveTextures=function(){var e=t.prototype.getActiveTextures.call(this);return this.environmentTexture&&e.push(this.environmentTexture),this.normalTexture&&e.push(this.normalTexture),this.emissiveTexture&&e.push(this.emissiveTexture),this.occlusionTexture&&e.push(this.occlusionTexture),e},r.prototype.getClassName=function(){return"PBRBaseSimpleMaterial"},__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsLightsDirty")],r.prototype,"maxSimultaneousLights",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsLightsDirty")],r.prototype,"disableLighting",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_reflectionTexture")],r.prototype,"environmentTexture",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"invertNormalMapX",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"invertNormalMapY",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_bumpTexture")],r.prototype,"normalTexture",void 0),__decorate([e.serializeAsColor3("emissive"),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"emissiveColor",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"emissiveTexture",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_ambientTextureStrength")],r.prototype,"occlusionStrength",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_ambientTexture")],r.prototype,"occlusionTexture",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_alphaCutOff")],r.prototype,"alphaCutOff",void 0),__decorate([e.serialize()],r.prototype,"transparencyMode",null),__decorate([e.serialize()],r.prototype,"doubleSided",null),r})(e.PBRBaseMaterial);t.PBRBaseSimpleMaterial=r})(e.Internals||(e.Internals={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(r,i){var n=t.call(this,r,i)||this;return n.directIntensity=1,n.emissiveIntensity=1,n.environmentIntensity=1,n.specularIntensity=1,n.disableBumpMap=!1,n.ambientTextureStrength=1,n.ambientColor=new e.Color3(0,0,0),n.albedoColor=new e.Color3(1,1,1),n.reflectivityColor=new e.Color3(1,1,1),n.reflectionColor=new e.Color3(1,1,1),n.emissiveColor=new e.Color3(0,0,0),n.microSurface=1,n.indexOfRefraction=.66,n.invertRefractionY=!1,n.linkRefractionWithTransparency=!1,n.useLightmapAsShadowmap=!1,n.useAlphaFromAlbedoTexture=!1,n.forceAlphaTest=!1,n.alphaCutOff=.4,n.useSpecularOverAlpha=!0,n.useMicroSurfaceFromReflectivityMapAlpha=!1,n.useRoughnessFromMetallicTextureAlpha=!0,n.useRoughnessFromMetallicTextureGreen=!1,n.useMetallnessFromMetallicTextureBlue=!1,n.useAmbientOcclusionFromMetallicTextureRed=!1,n.useAmbientInGrayScale=!1,n.useAutoMicroSurfaceFromReflectivityMap=!1,n.usePhysicalLightFalloff=!0,n.useRadianceOverAlpha=!0,n.useParallax=!1,n.useParallaxOcclusion=!1,n.parallaxScaleBias=.05,n.disableLighting=!1,n.forceIrradianceInFragment=!1,n.maxSimultaneousLights=4,n.invertNormalMapX=!1,n.invertNormalMapY=!1,n.twoSidedLighting=!1,n.preMultiplyAlpha=!1,n.useAlphaFresnel=!1,n.environmentBRDFTexture=null,n.forceNormalForward=!1,n._environmentBRDFTexture=e.TextureTools.GetEnvironmentBRDFTexture(i),n}return __extends(r,t),Object.defineProperty(r,"PBRMATERIAL_OPAQUE",{get:function(){return this._PBRMATERIAL_OPAQUE},enumerable:!0,configurable:!0}),Object.defineProperty(r,"PBRMATERIAL_ALPHATEST",{get:function(){return this._PBRMATERIAL_ALPHATEST},enumerable:!0,configurable:!0}),Object.defineProperty(r,"PBRMATERIAL_ALPHABLEND",{get:function(){return this._PBRMATERIAL_ALPHABLEND},enumerable:!0,configurable:!0}),Object.defineProperty(r,"PBRMATERIAL_ALPHATESTANDBLEND",{get:function(){return this._PBRMATERIAL_ALPHATESTANDBLEND},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"imageProcessingConfiguration",{get:function(){return this._imageProcessingConfiguration},set:function(e){this._attachImageProcessingConfiguration(e),this._markAllSubMeshesAsTexturesDirty()},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"cameraColorCurvesEnabled",{get:function(){return this.imageProcessingConfiguration.colorCurvesEnabled},set:function(e){this.imageProcessingConfiguration.colorCurvesEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"cameraColorGradingEnabled",{get:function(){return this.imageProcessingConfiguration.colorGradingEnabled},set:function(e){this.imageProcessingConfiguration.colorGradingEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"cameraToneMappingEnabled",{get:function(){return this._imageProcessingConfiguration.toneMappingEnabled},set:function(e){this._imageProcessingConfiguration.toneMappingEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"cameraExposure",{get:function(){return this._imageProcessingConfiguration.exposure},set:function(e){this._imageProcessingConfiguration.exposure=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"cameraContrast",{get:function(){return this._imageProcessingConfiguration.contrast},set:function(e){this._imageProcessingConfiguration.contrast=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"cameraColorGradingTexture",{get:function(){return this._imageProcessingConfiguration.colorGradingTexture},set:function(e){this._imageProcessingConfiguration.colorGradingTexture=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"cameraColorCurves",{get:function(){return this._imageProcessingConfiguration.colorCurves},set:function(e){this._imageProcessingConfiguration.colorCurves=e},enumerable:!0,configurable:!0}),r.prototype.getClassName=function(){return"PBRMaterial"},r.prototype.getActiveTextures=function(){var e=t.prototype.getActiveTextures.call(this);return this._albedoTexture&&e.push(this._albedoTexture),this._ambientTexture&&e.push(this._ambientTexture),this._opacityTexture&&e.push(this._opacityTexture),this._reflectionTexture&&e.push(this._reflectionTexture),this._emissiveTexture&&e.push(this._emissiveTexture),this._reflectivityTexture&&e.push(this._reflectivityTexture),this._metallicTexture&&e.push(this._metallicTexture),this._microSurfaceTexture&&e.push(this._microSurfaceTexture),this._bumpTexture&&e.push(this._bumpTexture),this._lightmapTexture&&e.push(this._lightmapTexture),this._refractionTexture&&e.push(this._refractionTexture),e},r.prototype.hasTexture=function(e){return!!t.prototype.hasTexture.call(this,e)||(this._albedoTexture===e||(this._ambientTexture===e||(this._opacityTexture===e||(this._reflectionTexture===e||(this._reflectivityTexture===e||(this._metallicTexture===e||(this._microSurfaceTexture===e||(this._bumpTexture===e||(this._lightmapTexture===e||this._refractionTexture===e)))))))))},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._PBRMATERIAL_OPAQUE=0,r._PBRMATERIAL_ALPHATEST=1,r._PBRMATERIAL_ALPHABLEND=2,r._PBRMATERIAL_ALPHATESTANDBLEND=3,__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"directIntensity",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"emissiveIntensity",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"environmentIntensity",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"specularIntensity",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"disableBumpMap",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"albedoTexture",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"ambientTexture",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"ambientTextureStrength",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"opacityTexture",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"reflectionTexture",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"emissiveTexture",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"reflectivityTexture",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"metallicTexture",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"metallic",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"roughness",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"microSurfaceTexture",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"bumpTexture",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty",null)],r.prototype,"lightmapTexture",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"refractionTexture",void 0),__decorate([e.serializeAsColor3("ambient"),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"ambientColor",void 0),__decorate([e.serializeAsColor3("albedo"),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"albedoColor",void 0),__decorate([e.serializeAsColor3("reflectivity"),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"reflectivityColor",void 0),__decorate([e.serializeAsColor3("reflection"),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"reflectionColor",void 0),__decorate([e.serializeAsColor3("emissive"),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"emissiveColor",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"microSurface",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"indexOfRefraction",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"invertRefractionY",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"linkRefractionWithTransparency",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"useLightmapAsShadowmap",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"useAlphaFromAlbedoTexture",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"forceAlphaTest",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"alphaCutOff",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"useSpecularOverAlpha",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"useMicroSurfaceFromReflectivityMapAlpha",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"useRoughnessFromMetallicTextureAlpha",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"useRoughnessFromMetallicTextureGreen",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"useMetallnessFromMetallicTextureBlue",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"useAmbientOcclusionFromMetallicTextureRed",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"useAmbientInGrayScale",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"useAutoMicroSurfaceFromReflectivityMap",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"usePhysicalLightFalloff",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"useRadianceOverAlpha",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"useParallax",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"useParallaxOcclusion",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"parallaxScaleBias",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsLightsDirty")],r.prototype,"disableLighting",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"forceIrradianceInFragment",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsLightsDirty")],r.prototype,"maxSimultaneousLights",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"invertNormalMapX",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"invertNormalMapY",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"twoSidedLighting",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"preMultiplyAlpha",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"useAlphaFresnel",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"environmentBRDFTexture",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"forceNormalForward",void 0),r})(e.PBRBaseMaterial);e.PBRMaterial=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(e,r){var i=t.call(this,e,r)||this;return i._useRoughnessFromMetallicTextureAlpha=!1,i._useRoughnessFromMetallicTextureGreen=!0,i._useMetallnessFromMetallicTextureBlue=!0,i}return __extends(r,t),r.prototype.getClassName=function(){return"PBRMetallicRoughnessMaterial"},r.prototype.getActiveTextures=function(){var e=t.prototype.getActiveTextures.call(this);return this.baseTexture&&e.push(this.baseTexture),this.metallicRoughnessTexture&&e.push(this.metallicRoughnessTexture),e},r.prototype.hasTexture=function(e){return!!t.prototype.hasTexture.call(this,e)||(this.baseTexture===e||this.metallicRoughnessTexture===e)},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.PBRMetallicRoughnessMaterial",t},r.Parse=function(t,i,n){return e.SerializationHelper.Parse((function(){return new r(t.name,i)}),t,i,n)},__decorate([e.serializeAsColor3(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_albedoColor")],r.prototype,"baseColor",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_albedoTexture")],r.prototype,"baseTexture",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"metallic",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"roughness",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_metallicTexture")],r.prototype,"metallicRoughnessTexture",void 0),r})(e.Internals.PBRBaseSimpleMaterial);e.PBRMetallicRoughnessMaterial=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(e,r){var i=t.call(this,e,r)||this;return i._useMicroSurfaceFromReflectivityMapAlpha=!0,i}return __extends(r,t),r.prototype.getClassName=function(){return"PBRSpecularGlossinessMaterial"},r.prototype.getActiveTextures=function(){var e=t.prototype.getActiveTextures.call(this);return this.diffuseTexture&&e.push(this.diffuseTexture),this.specularGlossinessTexture&&e.push(this.specularGlossinessTexture),e},r.prototype.hasTexture=function(e){return!!t.prototype.hasTexture.call(this,e)||(this.diffuseTexture===e||this.specularGlossinessTexture===e)},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.PBRSpecularGlossinessMaterial",t},r.Parse=function(t,i,n){return e.SerializationHelper.Parse((function(){return new r(t.name,i)}),t,i,n)},__decorate([e.serializeAsColor3("diffuse"),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_albedoColor")],r.prototype,"diffuseColor",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_albedoTexture")],r.prototype,"diffuseTexture",void 0),__decorate([e.serializeAsColor3("specular"),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_reflectivityColor")],r.prototype,"specularColor",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_microSurface")],r.prototype,"glossiness",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_reflectivityTexture")],r.prototype,"specularGlossinessTexture",void 0),r})(e.Internals.PBRBaseSimpleMaterial);e.PBRSpecularGlossinessMaterial=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(r,i,n,o){var s=t.call(this,r,i)||this;return s._textures={},s._textureArrays={},s._floats={},s._floatsArrays={},s._colors3={},s._colors3Arrays={},s._colors4={},s._vectors2={},s._vectors3={},s._vectors4={},s._matrices={},s._matrices3x3={},s._matrices2x2={},s._vectors3Arrays={},s._cachedWorldViewMatrix=new e.Matrix,s._shaderPath=n,o.needAlphaBlending=o.needAlphaBlending||!1,o.needAlphaTesting=o.needAlphaTesting||!1,o.attributes=o.attributes||["position","normal","uv"],o.uniforms=o.uniforms||["worldViewProjection"],o.uniformBuffers=o.uniformBuffers||[],o.samplers=o.samplers||[],o.defines=o.defines||[],s._options=o,s}return __extends(r,t),r.prototype.getClassName=function(){return"ShaderMaterial"},r.prototype.needAlphaBlending=function(){return this._options.needAlphaBlending},r.prototype.needAlphaTesting=function(){return this._options.needAlphaTesting},r.prototype._checkUniform=function(e){-1===this._options.uniforms.indexOf(e)&&this._options.uniforms.push(e)},r.prototype.setTexture=function(e,t){return-1===this._options.samplers.indexOf(e)&&this._options.samplers.push(e),this._textures[e]=t,this},r.prototype.setTextureArray=function(e,t){return-1===this._options.samplers.indexOf(e)&&this._options.samplers.push(e),this._checkUniform(e),this._textureArrays[e]=t,this},r.prototype.setFloat=function(e,t){return this._checkUniform(e),this._floats[e]=t,this},r.prototype.setFloats=function(e,t){return this._checkUniform(e),this._floatsArrays[e]=t,this},r.prototype.setColor3=function(e,t){return this._checkUniform(e),this._colors3[e]=t,this},r.prototype.setColor3Array=function(e,t){return this._checkUniform(e),this._colors3Arrays[e]=t.reduce((function(e,t){return t.toArray(e,e.length),e}),[]),this},r.prototype.setColor4=function(e,t){return this._checkUniform(e),this._colors4[e]=t,this},r.prototype.setVector2=function(e,t){return this._checkUniform(e),this._vectors2[e]=t,this},r.prototype.setVector3=function(e,t){return this._checkUniform(e),this._vectors3[e]=t,this},r.prototype.setVector4=function(e,t){return this._checkUniform(e),this._vectors4[e]=t,this},r.prototype.setMatrix=function(e,t){return this._checkUniform(e),this._matrices[e]=t,this},r.prototype.setMatrix3x3=function(e,t){return this._checkUniform(e),this._matrices3x3[e]=t,this},r.prototype.setMatrix2x2=function(e,t){return this._checkUniform(e),this._matrices2x2[e]=t,this},r.prototype.setArray3=function(e,t){return this._checkUniform(e),this._vectors3Arrays[e]=t,this},r.prototype._checkCache=function(e,t,r){return!t||(this._effect&&this._effect.defines.indexOf("#define INSTANCES"),!1)},r.prototype.isReady=function(t,r){var i=this.getScene(),n=i.getEngine();if(!this.checkReadyOnEveryCall&&this._renderId===i.getRenderId()&&this._checkCache(i,t,r))return!0;var o=[],s=[],a=new e.EffectFallbacks;r&&o.push("#define INSTANCES");for(var u=0;u<this._options.defines.length;u++)o.push(this._options.defines[u]);for(var u=0;u<this._options.attributes.length;u++)s.push(this._options.attributes[u]);t&&t.isVerticesDataPresent(e.VertexBuffer.ColorKind)&&(s.push(e.VertexBuffer.ColorKind),o.push("#define VERTEXCOLOR")),t&&t.useBones&&t.computeBonesUsingShaders?(s.push(e.VertexBuffer.MatricesIndicesKind),s.push(e.VertexBuffer.MatricesWeightsKind),t.numBoneInfluencers>4&&(s.push(e.VertexBuffer.MatricesIndicesExtraKind),s.push(e.VertexBuffer.MatricesWeightsExtraKind)),o.push("#define NUM_BONE_INFLUENCERS "+t.numBoneInfluencers),o.push("#define BonesPerMesh "+(t.skeleton.bones.length+1)),a.addCPUSkinningFallback(0,t),-1===this._options.uniforms.indexOf("mBones")&&this._options.uniforms.push("mBones")):o.push("#define NUM_BONE_INFLUENCERS 0");for(var l in this._textures)if(!this._textures[l].isReady())return!1;n.getAlphaTesting()&&o.push("#define ALPHATEST");var h=this._effect,c=o.join("\n");return this._effect=n.createEffect(this._shaderPath,{attributes:s,uniformsNames:this._options.uniforms,uniformBuffersNames:this._options.uniformBuffers,samplers:this._options.samplers,defines:c,fallbacks:a,onCompiled:this.onCompiled,onError:this.onError},n),!!this._effect.isReady()&&(h!==this._effect&&i.resetCachedMaterial(),this._renderId=i.getRenderId(),!0)},r.prototype.bindOnlyWorldMatrix=function(e){var t=this.getScene();-1!==this._options.uniforms.indexOf("world")&&this._effect.setMatrix("world",e),-1!==this._options.uniforms.indexOf("worldView")&&(e.multiplyToRef(t.getViewMatrix(),this._cachedWorldViewMatrix),this._effect.setMatrix("worldView",this._cachedWorldViewMatrix)),-1!==this._options.uniforms.indexOf("worldViewProjection")&&this._effect.setMatrix("worldViewProjection",e.multiply(t.getTransformMatrix()))},r.prototype.bind=function(t,r){if(this.bindOnlyWorldMatrix(t),this.getScene().getCachedMaterial()!==this){-1!==this._options.uniforms.indexOf("view")&&this._effect.setMatrix("view",this.getScene().getViewMatrix()),-1!==this._options.uniforms.indexOf("projection")&&this._effect.setMatrix("projection",this.getScene().getProjectionMatrix()),-1!==this._options.uniforms.indexOf("viewProjection")&&this._effect.setMatrix("viewProjection",this.getScene().getTransformMatrix()),e.MaterialHelper.BindBonesParameters(r,this._effect);var i;for(i in this._textures)this._effect.setTexture(i,this._textures[i]);for(i in this._textureArrays)this._effect.setTextureArray(i,this._textureArrays[i]);for(i in this._floats)this._effect.setFloat(i,this._floats[i]);for(i in this._floatsArrays)this._effect.setArray(i,this._floatsArrays[i]);for(i in this._colors3)this._effect.setColor3(i,this._colors3[i]);for(i in this._colors3Arrays)this._effect.setArray3(i,this._colors3Arrays[i]);for(i in this._colors4){var n=this._colors4[i];this._effect.setFloat4(i,n.r,n.g,n.b,n.a)}for(i in this._vectors2)this._effect.setVector2(i,this._vectors2[i]);for(i in this._vectors3)this._effect.setVector3(i,this._vectors3[i]);for(i in this._vectors4)this._effect.setVector4(i,this._vectors4[i]);for(i in this._matrices)this._effect.setMatrix(i,this._matrices[i]);for(i in this._matrices3x3)this._effect.setMatrix3x3(i,this._matrices3x3[i]);for(i in this._matrices2x2)this._effect.setMatrix2x2(i,this._matrices2x2[i]);for(i in this._vectors3Arrays)this._effect.setArray3(i,this._vectors3Arrays[i])}this._afterBind(r)},r.prototype.getActiveTextures=function(){var e=t.prototype.getActiveTextures.call(this);for(var r in this._textures)e.push(this._textures[r]);for(var r in this._textureArrays)for(var i=this._textureArrays[r],n=0;n<i.length;n++)e.push(i[n]);return e},r.prototype.hasTexture=function(e){if(t.prototype.hasTexture.call(this,e))return!0;for(var r in this._textures)if(this._textures[r]===e)return!0;for(var r in this._textureArrays)for(var i=this._textureArrays[r],n=0;n<i.length;n++)if(i[n]===e)return!0;return!1},r.prototype.clone=function(e){return new r(e,this.getScene(),this._shaderPath,this._options)},r.prototype.dispose=function(e,r){if(r){var i;for(i in this._textures)this._textures[i].dispose();for(i in this._textureArrays)for(var n=this._textureArrays[i],o=0;o<n.length;o++)n[o].dispose()}this._textures={},t.prototype.dispose.call(this,e,r)},r.prototype.serialize=function(){var t=e.SerializationHelper.Serialize(this);t.customType="BABYLON.ShaderMaterial",t.options=this._options,t.shaderPath=this._shaderPath;var r;t.textures={};for(r in this._textures)t.textures[r]=this._textures[r].serialize();t.textureArrays={};for(r in this._textureArrays){t.textureArrays[r]=[];for(var i=this._textureArrays[r],n=0;n<i.length;n++)t.textureArrays[r].push(i[n].serialize())}t.floats={};for(r in this._floats)t.floats[r]=this._floats[r];t.floatArrays={};for(r in this._floatsArrays)t.floatArrays[r]=this._floatsArrays[r];t.colors3={};for(r in this._colors3)t.colors3[r]=this._colors3[r].asArray();t.colors3Arrays={};for(r in this._colors3Arrays)t.colors3Arrays[r]=this._colors3Arrays[r];t.colors4={};for(r in this._colors4)t.colors4[r]=this._colors4[r].asArray();t.vectors2={};for(r in this._vectors2)t.vectors2[r]=this._vectors2[r].asArray();t.vectors3={};for(r in this._vectors3)t.vectors3[r]=this._vectors3[r].asArray();t.vectors4={};for(r in this._vectors4)t.vectors4[r]=this._vectors4[r].asArray();t.matrices={};for(r in this._matrices)t.matrices[r]=this._matrices[r].asArray();t.matrices3x3={};for(r in this._matrices3x3)t.matrices3x3[r]=this._matrices3x3[r];t.matrices2x2={};for(r in this._matrices2x2)t.matrices2x2[r]=this._matrices2x2[r];t.vectors3Arrays={};for(r in this._vectors3Arrays)t.vectors3Arrays[r]=this._vectors3Arrays[r];return t},r.Parse=function(t,i,n){var o,s=e.SerializationHelper.Parse((function(){return new r(t.name,i,t.shaderPath,t.options)}),t,i,n);for(o in t.textures)s.setTexture(o,e.Texture.Parse(t.textures[o],i,n))
- ;for(o in t.textureArrays){for(var a=t.textureArrays[o],u=new Array,l=0;l<a.length;l++)u.push(e.Texture.Parse(a[l],i,n));s.setTextureArray(o,u)}for(o in t.floats)s.setFloat(o,t.floats[o]);for(o in t.floatsArrays)s.setFloats(o,t.floatsArrays[o]);for(o in t.colors3)s.setColor3(o,e.Color3.FromArray(t.colors3[o]));for(o in t.colors3Arrays){var h=t.colors3Arrays[o].reduce((function(e,t,r){return r%3==0?e.push([t]):e[e.length-1].push(t),e}),[]).map((function(t){return e.Color3.FromArray(t)}));s.setColor3Array(o,h)}for(o in t.colors4)s.setColor4(o,e.Color4.FromArray(t.colors4[o]));for(o in t.vectors2)s.setVector2(o,e.Vector2.FromArray(t.vectors2[o]));for(o in t.vectors3)s.setVector3(o,e.Vector3.FromArray(t.vectors3[o]));for(o in t.vectors4)s.setVector4(o,e.Vector4.FromArray(t.vectors4[o]));for(o in t.matrices)s.setMatrix(o,e.Matrix.FromArray(t.matrices[o]));for(o in t.matrices3x3)s.setMatrix3x3(o,t.matrices3x3[o]);for(o in t.matrices2x2)s.setMatrix2x2(o,t.matrices2x2[o]);for(o in t.vectors3Arrays)s.setArray3(o,t.vectors3Arrays[o]);return s},r})(e.Material);e.ShaderMaterial=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){}return t.updateSideOrientation=function(t,r){return t==e.Mesh.DOUBLESIDE?e.Mesh.DOUBLESIDE:void 0===t||null===t?e.Mesh.FRONTSIDE:t},t.CreateBox=function(r,i,n){var o=new e.Mesh(r,n);return i.sideOrientation=t.updateSideOrientation(i.sideOrientation,n),o.sideOrientation=i.sideOrientation,e.VertexData.CreateBox(i).applyToMesh(o,i.updatable),o},t.CreateSphere=function(r,i,n){var o=new e.Mesh(r,n);return i.sideOrientation=t.updateSideOrientation(i.sideOrientation,n),o.sideOrientation=i.sideOrientation,e.VertexData.CreateSphere(i).applyToMesh(o,i.updatable),o},t.CreateDisc=function(r,i,n){var o=new e.Mesh(r,n);return i.sideOrientation=t.updateSideOrientation(i.sideOrientation,n),o.sideOrientation=i.sideOrientation,e.VertexData.CreateDisc(i).applyToMesh(o,i.updatable),o},t.CreateIcoSphere=function(r,i,n){var o=new e.Mesh(r,n);return i.sideOrientation=t.updateSideOrientation(i.sideOrientation,n),o.sideOrientation=i.sideOrientation,e.VertexData.CreateIcoSphere(i).applyToMesh(o,i.updatable),o},t.CreateRibbon=function(r,i,n){var o=i.pathArray,s=i.closeArray,a=i.closePath,u=(i.offset,t.updateSideOrientation(i.sideOrientation,n)),l=i.instance,h=i.updatable;if(l){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 c=l.getVerticesData(e.VertexBuffer.PositionKind);if(function(t){for(var r=o[0].length,i=0,n=l.sideOrientation===e.Mesh.DOUBLESIDE?2:1,s=1;s<=n;s++)for(var a=0;a<o.length;a++){var u=o[a],h=u.length;r=r<h?r:h;for(var c=0;c<r;)t[i]=u[c].x,t[i+1]=u[c].y,t[i+2]=u[c].z,u[c].x<e.Tmp.Vector3[0].x&&(e.Tmp.Vector3[0].x=u[c].x),u[c].x>e.Tmp.Vector3[1].x&&(e.Tmp.Vector3[1].x=u[c].x),u[c].y<e.Tmp.Vector3[0].y&&(e.Tmp.Vector3[0].y=u[c].y),u[c].y>e.Tmp.Vector3[1].y&&(e.Tmp.Vector3[1].y=u[c].y),u[c].z<e.Tmp.Vector3[0].z&&(e.Tmp.Vector3[0].z=u[c].z),u[c].z>e.Tmp.Vector3[1].z&&(e.Tmp.Vector3[1].z=u[c].z),c++,i+=3;l._closePath&&(t[i]=u[0].x,t[i+1]=u[0].y,t[i+2]=u[0].z,i+=3)}}(c),l._boundingInfo=new e.BoundingInfo(e.Tmp.Vector3[0],e.Tmp.Vector3[1]),l._boundingInfo.update(l._worldMatrix),l.updateVerticesData(e.VertexBuffer.PositionKind,c,!1,!1),i.colors){for(var f=l.getVerticesData(e.VertexBuffer.ColorKind),d=0;d<i.colors.length;d++)f[4*d]=i.colors[d].r,f[4*d+1]=i.colors[d].g,f[4*d+2]=i.colors[d].b,f[4*d+3]=i.colors[d].a;l.updateVerticesData(e.VertexBuffer.ColorKind,f,!1,!1)}if(i.uvs){for(var p=l.getVerticesData(e.VertexBuffer.UVKind),g=0;g<i.uvs.length;g++)p[2*g]=i.uvs[g].x,p[2*g+1]=i.uvs[g].y;l.updateVerticesData(e.VertexBuffer.UVKind,p,!1,!1)}if(!l.areNormalsFrozen||l.isFacetDataEnabled){var _=l.getIndices(),m=l.getVerticesData(e.VertexBuffer.NormalKind),v=l.isFacetDataEnabled?l.getFacetDataParameters():null;if(e.VertexData.ComputeNormals(c,_,m,v),l._closePath)for(var y=0,A=0,T=0;T<o.length;T++)y=3*l._idx[T],A=T+1<o.length?3*(l._idx[T+1]-1):m.length-3,m[y]=.5*(m[y]+m[A]),m[y+1]=.5*(m[y+1]+m[A+1]),m[y+2]=.5*(m[y+2]+m[A+2]),m[A]=m[y],m[A+1]=m[y+1],m[A+2]=m[y+2];l.areNormalsFrozen||l.updateVerticesData(e.VertexBuffer.NormalKind,m,!1,!1)}return l}var E=new e.Mesh(r,n);E.sideOrientation=u;var b=e.VertexData.CreateRibbon(i);return a&&(E._idx=b._idx),E._closePath=a,E._closeArray=s,b.applyToMesh(E,h),E},t.CreateCylinder=function(r,i,n){var o=new e.Mesh(r,n);return i.sideOrientation=t.updateSideOrientation(i.sideOrientation,n),o.sideOrientation=i.sideOrientation,e.VertexData.CreateCylinder(i).applyToMesh(o,i.updatable),o},t.CreateTorus=function(r,i,n){var o=new e.Mesh(r,n);return i.sideOrientation=t.updateSideOrientation(i.sideOrientation,n),o.sideOrientation=i.sideOrientation,e.VertexData.CreateTorus(i).applyToMesh(o,i.updatable),o},t.CreateTorusKnot=function(r,i,n){var o=new e.Mesh(r,n);return i.sideOrientation=t.updateSideOrientation(i.sideOrientation,n),o.sideOrientation=i.sideOrientation,e.VertexData.CreateTorusKnot(i).applyToMesh(o,i.updatable),o},t.CreateLineSystem=function(t,r,i){var n=r.instance,o=r.lines;if(n){var s=function(e){for(var t=0,r=0;r<o.length;r++)for(var i=o[r],n=0;n<i.length;n++)e[t]=i[n].x,e[t+1]=i[n].y,e[t+2]=i[n].z,t+=3};return n.updateMeshPositions(s,!1),n}var a=new e.LinesMesh(t,i);return e.VertexData.CreateLineSystem(r).applyToMesh(a,r.updatable),a},t.CreateLines=function(e,r,i){return t.CreateLineSystem(e,{lines:[r.points],updatable:r.updatable,instance:r.instance},i)},t.CreateDashedLines=function(t,r,i){var n=r.points,o=r.instance,s=r.gapSize,a=(r.dashNb,r.dashSize);if(o){var u=function(t){var r=e.Vector3.Zero(),i=t.length/6,s=0,a=0,u=0,l=0,h=0,c=0,f=0,d=0;for(f=0;f<n.length-1;f++)n[f+1].subtractToRef(n[f],r),s+=r.length();for(u=s/i,l=o.dashSize*u/(o.dashSize+o.gapSize),f=0;f<n.length-1;f++)for(n[f+1].subtractToRef(n[f],r),a=Math.floor(r.length()/u),r.normalize(),d=0;d<a&&c<t.length;)h=u*d,t[c]=n[f].x+h*r.x,t[c+1]=n[f].y+h*r.y,t[c+2]=n[f].z+h*r.z,t[c+3]=n[f].x+(h+l)*r.x,t[c+4]=n[f].y+(h+l)*r.y,t[c+5]=n[f].z+(h+l)*r.z,c+=6,d++;for(;c<t.length;)t[c]=n[f].x,t[c+1]=n[f].y,t[c+2]=n[f].z,c+=3};return o.updateMeshPositions(u,!1),o}var l=new e.LinesMesh(t,i);return e.VertexData.CreateDashedLines(r).applyToMesh(l,r.updatable),l.dashSize=a,l.gapSize=s,l},t.ExtrudeShape=function(r,i,n){var o=i.path,s=i.shape,a=i.scale||1,u=i.rotation||0,l=0===i.cap?0:i.cap||e.Mesh.NO_CAP,h=i.updatable,c=t.updateSideOrientation(i.sideOrientation,n),f=i.instance,d=i.invertUV||!1;return t._ExtrudeShapeGeneric(r,s,o,a,u,null,null,!1,!1,l,!1,n,h,c,f,d,i.frontUVs,i.backUVs)},t.ExtrudeShapeCustom=function(r,i,n){var o=i.path,s=i.shape,a=i.scaleFunction||function(){return 1},u=i.rotationFunction||function(){return 0},l=i.ribbonCloseArray||!1,h=i.ribbonClosePath||!1,c=0===i.cap?0:i.cap||e.Mesh.NO_CAP,f=i.updatable,d=t.updateSideOrientation(i.sideOrientation,n),p=i.instance,g=i.invertUV||!1;return t._ExtrudeShapeGeneric(r,s,o,null,null,a,u,l,h,c,!0,n,f,d,p,g,i.frontUVs,i.backUVs)},t.CreateLathe=function(r,i,n){var o,s=i.arc?i.arc<=0||i.arc>1?1:i.arc:1,a=void 0===i.closed||i.closed,u=i.shape,l=i.radius||1,h=i.tessellation||64,c=i.updatable,f=t.updateSideOrientation(i.sideOrientation,n),d=i.cap||e.Mesh.NO_CAP,p=2*Math.PI,g=new Array,_=i.invertUV||!1,m=0,v=0,y=p/h*s,A=new Array;for(m=0;m<=h;m++){var A=[];for(d!=e.Mesh.CAP_START&&d!=e.Mesh.CAP_ALL||(A.push(new e.Vector3(0,u[0].y,0)),A.push(new e.Vector3(Math.cos(m*y)*u[0].x*l,u[0].y,Math.sin(m*y)*u[0].x*l))),v=0;v<u.length;v++)o=new e.Vector3(Math.cos(m*y)*u[v].x*l,u[v].y,Math.sin(m*y)*u[v].x*l),A.push(o);d!=e.Mesh.CAP_END&&d!=e.Mesh.CAP_ALL||(A.push(new e.Vector3(Math.cos(m*y)*u[u.length-1].x*l,u[u.length-1].y,Math.sin(m*y)*u[u.length-1].x*l)),A.push(new e.Vector3(0,u[u.length-1].y,0))),g.push(A)}return t.CreateRibbon(r,{pathArray:g,closeArray:a,sideOrientation:f,updatable:c,invertUV:_,frontUVs:i.frontUVs,backUVs:i.backUVs},n)},t.CreatePlane=function(r,i,n){var o=new e.Mesh(r,n);if(i.sideOrientation=t.updateSideOrientation(i.sideOrientation,n),o.sideOrientation=i.sideOrientation,e.VertexData.CreatePlane(i).applyToMesh(o,i.updatable),i.sourcePlane){o.translate(i.sourcePlane.normal,i.sourcePlane.d);var s=Math.acos(e.Vector3.Dot(i.sourcePlane.normal,e.Axis.Z)),a=e.Vector3.Cross(e.Axis.Z,i.sourcePlane.normal);o.rotate(a,s)}return o},t.CreateGround=function(t,r,i){var n=new e.GroundMesh(t,i);return n._setReady(!1),n._subdivisionsX=r.subdivisionsX||r.subdivisions||1,n._subdivisionsY=r.subdivisionsY||r.subdivisions||1,n._width=r.width||1,n._height=r.height||1,n._maxX=n._width/2,n._maxZ=n._height/2,n._minX=-n._maxX,n._minZ=-n._maxZ,e.VertexData.CreateGround(r).applyToMesh(n,r.updatable),n._setReady(!0),n},t.CreateTiledGround=function(t,r,i){var n=new e.Mesh(t,i);return e.VertexData.CreateTiledGround(r).applyToMesh(n,r.updatable),n},t.CreateGroundFromHeightMap=function(t,r,i,n){var o=i.width||10,s=i.height||10,a=i.subdivisions||1,u=i.minHeight||0,l=i.maxHeight||10,h=i.colorFilter||new e.Color3(.3,.59,.11),c=i.updatable,f=i.onReady,d=new e.GroundMesh(t,n);d._subdivisionsX=a,d._subdivisionsY=a,d._width=o,d._height=s,d._maxX=d._width/2,d._maxZ=d._height/2,d._minX=-d._maxX,d._minZ=-d._maxZ,d._setReady(!1);var p=function(t){var r=document.createElement("canvas"),i=r.getContext("2d"),n=t.width,p=t.height;r.width=n,r.height=p,i.drawImage(t,0,0);var g=i.getImageData(0,0,n,p).data;e.VertexData.CreateGroundFromHeightMap({width:o,height:s,subdivisions:a,minHeight:u,maxHeight:l,colorFilter:h,buffer:g,bufferWidth:n,bufferHeight:p}).applyToMesh(d,c),d._setReady(!0),f&&f(d)};return e.Tools.LoadImage(r,p,(function(){}),n.database),d},t.CreatePolygon=function(r,i,n){i.sideOrientation=t.updateSideOrientation(i.sideOrientation,n);for(var o=i.shape,s=i.holes||[],a=i.depth||0,u=[],l=[],h=0;h<o.length;h++)u[h]=new e.Vector2(o[h].x,o[h].z);u[0].equalsWithEpsilon(u[u.length-1],1e-8)&&u.pop();for(var c=new e.PolygonMeshBuilder(r,u,n),f=0;f<s.length;f++){l=[];for(var d=0;d<s[f].length;d++)l.push(new e.Vector2(s[f][d].x,s[f][d].z));c.addHole(l)}var p=c.build(i.updatable,a);return p.sideOrientation=i.sideOrientation,e.VertexData.CreatePolygon(p,i.sideOrientation,i.faceUV,i.faceColors,i.frontUVs,i.backUVs).applyToMesh(p,i.updatable),p},t.ExtrudePolygon=function(e,r,i){return t.CreatePolygon(e,r,i)},t.CreateTube=function(r,i,n){var o=i.path,s=i.radius||1,a=i.tessellation||64,u=i.radiusFunction,l=i.cap||e.Mesh.NO_CAP,h=i.invertUV||!1,c=i.updatable,f=t.updateSideOrientation(i.sideOrientation,n),d=i.instance;i.arc=i.arc<=0||i.arc>1?1:i.arc||1;var p,g,_=function(t,r,i,n,o,s,a,u){for(var l,h,c,f,d=r.getTangents(),p=r.getNormals(),g=r.getDistances(),_=2*Math.PI,m=_/o*u,v=function(){return n},y=s||v,A=e.Tmp.Matrix[0],T=a===e.Mesh._NO_CAP||a===e.Mesh.CAP_END?0:2,E=0;E<t.length;E++){h=y(E,g[E]),l=Array(),c=p[E];for(var b=0;b<o;b++)e.Matrix.RotationAxisToRef(d[E],m*b,A),f=l[b]?l[b]:e.Vector3.Zero(),e.Vector3.TransformCoordinatesToRef(c,A,f),f.scaleInPlace(h).addInPlace(t[E]),l[b]=f;i[T]=l,T++}var x=function(e,r){for(var i=Array(),n=0;n<e;n++)i.push(t[r]);return i};switch(a){case e.Mesh.NO_CAP:break;case e.Mesh.CAP_START:i[0]=x(o,0),i[1]=i[2].slice(0);break;case e.Mesh.CAP_END:i[T]=i[T-1].slice(0),i[T+1]=x(o,t.length-1);break;case e.Mesh.CAP_ALL:i[0]=x(o,0),i[1]=i[2].slice(0),i[T]=i[T-1].slice(0),i[T+1]=x(o,t.length-1)}return i};if(d){var m=i.arc||d.arc;return p=d.path3D.update(o),g=_(o,p,d.pathArray,s,d.tessellation,u,d.cap,m),d=t.CreateRibbon(null,{pathArray:g,instance:d}),d.path3D=p,d.pathArray=g,d.arc=m,d}p=new e.Path3D(o);var v=new Array;l=l<0||l>3?0:l,g=_(o,p,v,s,a,u,l,i.arc);var y=t.CreateRibbon(r,{pathArray:g,closePath:!0,closeArray:!1,updatable:c,sideOrientation:f,invertUV:h,frontUVs:i.frontUVs,backUVs:i.backUVs},n);return y.pathArray=g,y.path3D=p,y.tessellation=a,y.cap=l,y.arc=i.arc,y},t.CreatePolyhedron=function(r,i,n){var o=new e.Mesh(r,n);return i.sideOrientation=t.updateSideOrientation(i.sideOrientation,n),o.sideOrientation=i.sideOrientation,e.VertexData.CreatePolyhedron(i).applyToMesh(o,i.updatable),o},t.CreateDecal=function(t,r,i){var n=r.getIndices(),o=r.getVerticesData(e.VertexBuffer.PositionKind),s=r.getVerticesData(e.VertexBuffer.NormalKind),a=i.position||e.Vector3.Zero(),u=i.normal||e.Vector3.Up(),l=i.size||e.Vector3.One(),h=i.angle||0;if(!u){var c=new e.Vector3(0,0,1),f=r.getScene().activeCamera,d=e.Vector3.TransformCoordinates(c,f.getWorldMatrix());u=f.globalPosition.subtract(d)}var p=-Math.atan2(u.z,u.x)-Math.PI/2,g=Math.sqrt(u.x*u.x+u.z*u.z),_=Math.atan2(u.y,g),m=e.Matrix.RotationYawPitchRoll(p,_,h).multiply(e.Matrix.Translation(a.x,a.y,a.z)),v=e.Matrix.Invert(m),y=r.getWorldMatrix(),A=y.multiply(v),T=new e.VertexData;T.indices=[],T.positions=[],T.normals=[],T.uvs=[];for(var E=0,b=function(t){var r=n[t],i=new e.PositionNormalVertex;return i.position=new e.Vector3(o[3*r],o[3*r+1],o[3*r+2]),i.position=e.Vector3.TransformCoordinates(i.position,A),i.normal=new e.Vector3(s[3*r],s[3*r+1],s[3*r+2]),i.normal=e.Vector3.TransformNormal(i.normal,A),i},x=function(t,r){if(0===t.length)return t;for(var i=.5*Math.abs(e.Vector3.Dot(l,r)),n=function(t,n){var o=e.Vector3.GetClipFactor(t.position,n.position,r,i);return new e.PositionNormalVertex(e.Vector3.Lerp(t.position,n.position,o),e.Vector3.Lerp(t.normal,n.normal,o))},o=new Array,s=0;s<t.length;s+=3){var a,u,h,c,f,d,p,g=e.Vector3.Dot(t[s].position,r)-i,_=e.Vector3.Dot(t[s+1].position,r)-i,m=e.Vector3.Dot(t[s+2].position,r)-i;switch(a=g>0,u=_>0,h=m>0,(a?1:0)+(u?1:0)+(h?1:0)){case 0:o.push(t[s]),o.push(t[s+1]),o.push(t[s+2]);break;case 1:if(a&&(c=t[s+1],f=t[s+2],d=n(t[s],c),p=n(t[s],f)),u){c=t[s],f=t[s+2],d=n(t[s+1],c),p=n(t[s+1],f),o.push(d),o.push(f.clone()),o.push(c.clone()),o.push(f.clone()),o.push(d.clone()),o.push(p);break}h&&(c=t[s],f=t[s+1],d=n(t[s+2],c),p=n(t[s+2],f)),o.push(c.clone()),o.push(f.clone()),o.push(d),o.push(p),o.push(d.clone()),o.push(f.clone());break;case 2:a||(c=t[s].clone(),f=n(c,t[s+1]),d=n(c,t[s+2]),o.push(c),o.push(f),o.push(d)),u||(c=t[s+1].clone(),f=n(c,t[s+2]),d=n(c,t[s]),o.push(c),o.push(f),o.push(d)),h||(c=t[s+2].clone(),f=n(c,t[s]),d=n(c,t[s+1]),o.push(c),o.push(f),o.push(d))}}return o},M=0;M<n.length;M+=3){var P=new Array;if(P.push(b(M)),P.push(b(M+1)),P.push(b(M+2)),P=x(P,new e.Vector3(1,0,0)),P=x(P,new e.Vector3(-1,0,0)),P=x(P,new e.Vector3(0,1,0)),P=x(P,new e.Vector3(0,-1,0)),P=x(P,new e.Vector3(0,0,1)),P=x(P,new e.Vector3(0,0,-1)),0!==P.length)for(var R=0;R<P.length;R++){var C=P[R];T.indices.push(E),C.position.toArray(T.positions,3*E),C.normal.toArray(T.normals,3*E),T.uvs.push(.5+C.position.x/l.x),T.uvs.push(.5+C.position.y/l.y),E++}}var O=new e.Mesh(t,r.getScene());return T.applyToMesh(O),O.position=a.clone(),O.rotation=new e.Vector3(_,p,h),O},t._ExtrudeShapeGeneric=function(r,i,n,o,s,a,u,l,h,c,f,d,p,g,_,m,v,y){var A,T,E=function(t,r,i,n,o,s,a,u,l,h){for(var c=i.getTangents(),f=i.getNormals(),d=i.getBinormals(),p=i.getDistances(),g=0,_=function(){return o},m=function(){return s},v=h?u:m,y=h?a:_,A=l===e.Mesh.NO_CAP||l===e.Mesh.CAP_END?0:2,T=e.Tmp.Matrix[0],E=0;E<r.length;E++){for(var b=new Array,x=v(E,p[E]),M=y(E,p[E]),P=0;P<t.length;P++){e.Matrix.RotationAxisToRef(c[E],g,T);var R=c[E].scale(t[P].z).add(f[E].scale(t[P].x)).add(d[E].scale(t[P].y)),C=b[P]?b[P]:e.Vector3.Zero();e.Vector3.TransformCoordinatesToRef(R,T,C),C.scaleInPlace(M).addInPlace(r[E]),b[P]=C}n[A]=b,g+=x,A++}var O=function(t){var r,i=Array(),n=e.Vector3.Zero();for(r=0;r<t.length;r++)n.addInPlace(t[r]);for(n.scaleInPlace(1/t.length),r=0;r<t.length;r++)i.push(n);return i};switch(l){case e.Mesh.NO_CAP:break;case e.Mesh.CAP_START:n[0]=O(n[2]),n[1]=n[2];break;case e.Mesh.CAP_END:n[A]=n[A-1],n[A+1]=O(n[A-1]);break;case e.Mesh.CAP_ALL:n[0]=O(n[2]),n[1]=n[2],n[A]=n[A-1],n[A+1]=O(n[A-1])}return n};if(_)return A=_.path3D.update(n),T=E(i,n,_.path3D,_.pathArray,o,s,a,u,_.cap,f),_=e.Mesh.CreateRibbon(null,T,null,null,null,d,null,null,_);A=new e.Path3D(n);var b=new Array;c=c<0||c>3?0:c,T=E(i,n,A,b,o,s,a,u,c,f);var x=t.CreateRibbon(r,{pathArray:T,closeArray:l,closePath:h,updatable:p,sideOrientation:g,invertUV:m,frontUVs:v,backUVs:y},d);return x.pathArray=T,x.path3D=A,x.cap=c,x},t})();e.MeshBuilder=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(t,r,i,n,o){this.name=t,this.scale=new e.Vector2(1,1),this.offset=new e.Vector2(0,0),this.alphaBlendingMode=e.Engine.ALPHA_COMBINE,this.layerMask=268435455,this._vertexBuffers={},this.onDisposeObservable=new e.Observable,this.onBeforeRenderObservable=new e.Observable,this.onAfterRenderObservable=new e.Observable,this.texture=r?new e.Texture(r,i,!0):null,this.isBackground=void 0===n||n,this.color=void 0===o?new e.Color4(1,1,1,1):o,this._scene=i||e.Engine.LastCreatedScene,this._scene.layers.push(this);var s=this._scene.getEngine(),a=[];a.push(1,1),a.push(-1,1),a.push(-1,-1),a.push(1,-1);var u=new e.VertexBuffer(s,a,e.VertexBuffer.PositionKind,!1,!1,2);this._vertexBuffers[e.VertexBuffer.PositionKind]=u;var l=[];l.push(0),l.push(1),l.push(2),l.push(0),l.push(2),l.push(3),this._indexBuffer=s.createIndexBuffer(l),this._effect=s.createEffect("layer",[e.VertexBuffer.PositionKind],["textureMatrix","color","scale","offset"],["textureSampler"],""),this._alphaTestEffect=s.createEffect("layer",[e.VertexBuffer.PositionKind],["textureMatrix","color","scale","offset"],["textureSampler"],"#define ALPHATEST")}return Object.defineProperty(t.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onBeforeRender",{set:function(e){this._onBeforeRenderObserver&&this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),this._onBeforeRenderObserver=this.onBeforeRenderObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onAfterRender",{set:function(e){this._onAfterRenderObserver&&this.onAfterRenderObservable.remove(this._onAfterRenderObserver),this._onAfterRenderObserver=this.onAfterRenderObservable.add(e)},enumerable:!0,configurable:!0}),t.prototype.render=function(){var t=this.alphaTest?this._alphaTestEffect:this._effect;if(t.isReady()&&this.texture&&this.texture.isReady()){var r=this._scene.getEngine();this.onBeforeRenderObservable.notifyObservers(this),r.enableEffect(t),r.setState(!1),t.setTexture("textureSampler",this.texture),t.setMatrix("textureMatrix",this.texture.getTextureMatrix()),t.setFloat4("color",this.color.r,this.color.g,this.color.b,this.color.a),t.setVector2("offset",this.offset),t.setVector2("scale",this.scale),r.bindBuffers(this._vertexBuffers,this._indexBuffer,t),this.alphaTest?r.draw(!0,0,6):(r.setAlphaMode(this.alphaBlendingMode),r.draw(!0,0,6),r.setAlphaMode(e.Engine.ALPHA_DISABLE)),this.onAfterRenderObservable.notifyObservers(this)}},t.prototype.dispose=function(){var t=this._vertexBuffers[e.VertexBuffer.PositionKind];t&&(t.dispose(),this._vertexBuffers[e.VertexBuffer.PositionKind]=null),this._indexBuffer&&(this._scene.getEngine()._releaseBuffer(this._indexBuffer),this._indexBuffer=null),this.texture&&(this.texture.dispose(),this.texture=null);var r=this._scene.layers.indexOf(this);this._scene.layers.splice(r,1),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this.onAfterRenderObservable.clear(),this.onBeforeRenderObservable.clear()},t})();e.Layer=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(r,i,n,o,s,a,u,l,h){void 0===a&&(a=e.Texture.BILINEAR_SAMPLINGMODE),void 0===h&&(h=e.Engine.TEXTURETYPE_UNSIGNED_INT);var c=t.call(this,r,"kernelBlur",["delta","direction"],null,o,s,a,u,l,null,h,"kernelBlur",{varyingCount:0,depCount:0},!0)||this;return c.direction=i,c._packedFloat=!1,c.onApplyObservable.add((function(e){e.setFloat2("delta",1/c.width*c.direction.x,1/c.height*c.direction.y)})),c.kernel=n,c}return __extends(r,t),Object.defineProperty(r.prototype,"kernel",{get:function(){return this._idealKernel},set:function(e){this._idealKernel!==e&&(e=Math.max(e,1),this._idealKernel=e,this._kernel=this._nearestBestKernel(e),this._updateParameters())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"packedFloat",{get:function(){return this._packedFloat},set:function(e){this._packedFloat!==e&&(this._packedFloat=e,this._updateParameters())},enumerable:!0,configurable:!0}),r.prototype._updateParameters=function(){for(var e=this._kernel,t=(e-1)/2,r=[],i=[],n=0,o=0;o<e;o++){var s=o/(e-1),a=this._gaussianWeight(2*s-1);r[o]=o-t,i[o]=a,n+=a}for(var o=0;o<i.length;o++)i[o]/=n;for(var u=[],l=[],h=[],o=0;o<=t;o+=2){var c=Math.min(o+1,Math.floor(t));if(o===c)h.push({o:r[o],w:i[o]});else{var f=c===t,d=i[o]+i[c]*(f?.5:1),p=r[o]+1/(1+i[o]/i[c]);0===p?(h.push({o:r[o],w:i[o]}),h.push({o:r[o+1],w:i[o+1]})):(h.push({o:p,w:d}),h.push({o:-p,w:d}))}}for(var o=0;o<h.length;o++)l[o]=h[o].o,u[o]=h[o].w;r=l,i=u;for(var g=this.getEngine().getCaps().maxVaryingVectors,_=Math.max(g,0)-1,m=Math.min(r.length,_),v="",o=0;o<m;o++)v+="#define KERNEL_OFFSET"+o+" "+this._glslFloat(r[o])+"\r\n",v+="#define KERNEL_WEIGHT"+o+" "+this._glslFloat(i[o])+"\r\n";for(var y=0,o=_;o<r.length;o++)v+="#define KERNEL_DEP_OFFSET"+y+" "+this._glslFloat(r[o])+"\r\n",v+="#define KERNEL_DEP_WEIGHT"+y+" "+this._glslFloat(i[o])+"\r\n",y++;this.packedFloat&&(v+="#define PACKEDFLOAT 1"),this.updateEffect(v,null,null,{varyingCount:m,depCount:y})},r.prototype._nearestBestKernel=function(e){for(var t=Math.round(e),r=0,i=[t,t-1,t+1,t-2,t+2];r<i.length;r++){var n=i[r];if(n%2!=0&&Math.floor(n/2)%2==0&&n>0)return Math.max(n,3)}return Math.max(t,3)},r.prototype._gaussianWeight=function(e){var t=Math.sqrt(2*Math.PI)*(1/3),r=-e*e/(1/3*2*(1/3));return 1/t*Math.exp(r)},r.prototype._glslFloat=function(e,t){return void 0===t&&(t=8),e.toFixed(t).replace(/0+$/,"")},r})(e.PostProcess);e.BlurPostProcess=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(r,i,n,o,s,a,u){void 0===u&&(u=e.Engine.TEXTURETYPE_UNSIGNED_INT);var l=t.call(this,r,"fxaa",["texelSize"],null,i,n,o||e.Texture.BILINEAR_SAMPLINGMODE,s,a,null,u,"fxaa")||this;return l.onApplyObservable.add((function(e){var t=l.texelSize;e.setFloat2("texelSize",t.x,t.y)})),l}return __extends(r,t),r})(e.PostProcess);e.FxaaPostProcess=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(r,i,n,o,s,a,u){return void 0===u&&(u=e.Engine.TEXTURETYPE_UNSIGNED_INT),t.call(this,r,"highlights",null,null,i,n,o,s,a,null,u)||this}return __extends(r,t),r})(e.PostProcess);e.HighlightsPostProcess=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(r,i,n,o,s,a,u){void 0===u&&(u=e.Engine.TEXTURETYPE_UNSIGNED_INT);var l=t.call(this,r,"imageProcessing",[],[],i,n,o,s,a,null,u,"postprocess",null,!0)||this;return l._fromLinearSpace=!0,l._defines={IMAGEPROCESSING:!1,VIGNETTE:!1,VIGNETTEBLENDMODEMULTIPLY:!1,VIGNETTEBLENDMODEOPAQUE:!1,TONEMAPPING:!1,CONTRAST:!1,COLORCURVES:!1,COLORGRADING:!1,FROMLINEARSPACE:!1,SAMPLER3DGREENDEPTH:!1,SAMPLER3DBGRMAP:!1,IMAGEPROCESSINGPOSTPROCESS:!1,EXPOSURE:!1},l._attachImageProcessingConfiguration(null,!0),l.imageProcessingConfiguration.applyByPostProcess=!0,l.onApply=function(e){l.imageProcessingConfiguration.bind(e,l.aspectRatio)},l}return __extends(r,t),Object.defineProperty(r.prototype,"imageProcessingConfiguration",{get:function(){return this._imageProcessingConfiguration},set:function(e){this._attachImageProcessingConfiguration(e)},enumerable:!0,configurable:!0}),r.prototype._attachImageProcessingConfiguration=function(t,r){var i=this;if(void 0===r&&(r=!1),t!==this._imageProcessingConfiguration){if(this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),t)this._imageProcessingConfiguration=t;else{var n=this.getCamera(),o=n?n.getScene():e.Engine.LastCreatedScene;this._imageProcessingConfiguration=o.imageProcessingConfiguration}this._imageProcessingObserver=this._imageProcessingConfiguration.onUpdateParameters.add((function(e){i._updateParameters()})),r||this._updateParameters()}},Object.defineProperty(r.prototype,"colorCurves",{get:function(){return this.imageProcessingConfiguration.colorCurves},set:function(e){this.imageProcessingConfiguration.colorCurves=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"colorCurvesEnabled",{get:function(){return this.imageProcessingConfiguration.colorCurvesEnabled},set:function(e){this.imageProcessingConfiguration.colorCurvesEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"colorGradingTexture",{get:function(){return this.imageProcessingConfiguration.colorGradingTexture},set:function(e){this.imageProcessingConfiguration.colorGradingTexture=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"colorGradingEnabled",{get:function(){return this.imageProcessingConfiguration.colorGradingEnabled},set:function(e){this.imageProcessingConfiguration.colorGradingEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"exposure",{get:function(){return this.imageProcessingConfiguration.exposure},set:function(e){this.imageProcessingConfiguration.exposure=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"toneMappingEnabled",{get:function(){return this._imageProcessingConfiguration.toneMappingEnabled},set:function(e){this._imageProcessingConfiguration.toneMappingEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"contrast",{get:function(){return this.imageProcessingConfiguration.contrast},set:function(e){this.imageProcessingConfiguration.contrast=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"vignetteStretch",{get:function(){return this.imageProcessingConfiguration.vignetteStretch},set:function(e){this.imageProcessingConfiguration.vignetteStretch=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"vignetteCentreX",{get:function(){return this.imageProcessingConfiguration.vignetteCentreX},set:function(e){this.imageProcessingConfiguration.vignetteCentreX=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"vignetteCentreY",{get:function(){return this.imageProcessingConfiguration.vignetteCentreY},set:function(e){this.imageProcessingConfiguration.vignetteCentreY=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"vignetteWeight",{get:function(){return this.imageProcessingConfiguration.vignetteWeight},set:function(e){this.imageProcessingConfiguration.vignetteWeight=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"vignetteColor",{get:function(){return this.imageProcessingConfiguration.vignetteColor},set:function(e){this.imageProcessingConfiguration.vignetteColor=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"vignetteCameraFov",{get:function(){return this.imageProcessingConfiguration.vignetteCameraFov},set:function(e){this.imageProcessingConfiguration.vignetteCameraFov=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"vignetteBlendMode",{get:function(){return this.imageProcessingConfiguration.vignetteBlendMode},set:function(e){this.imageProcessingConfiguration.vignetteBlendMode=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"vignetteEnabled",{get:function(){return this.imageProcessingConfiguration.vignetteEnabled},set:function(e){this.imageProcessingConfiguration.vignetteEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"fromLinearSpace",{get:function(){return this._fromLinearSpace},set:function(e){this._fromLinearSpace!==e&&(this._fromLinearSpace=e,this._updateParameters())},enumerable:!0,configurable:!0}),r.prototype.getClassName=function(){return"ImageProcessingPostProcess"},r.prototype._updateParameters=function(){this._defines.FROMLINEARSPACE=this._fromLinearSpace,this.imageProcessingConfiguration.prepareDefines(this._defines);var t="";for(var r in this._defines)this._defines[r]&&(t+="#define "+r+";\r\n");var i=["textureSampler"];e.ImageProcessingConfiguration.PrepareSamplers(i,this._defines);var n=["scale"];e.ImageProcessingConfiguration.PrepareUniforms(n,this._defines),this.updateEffect(t,n,i)},r.prototype.dispose=function(e){t.prototype.dispose.call(this,e),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),this.imageProcessingConfiguration.applyByPostProcess=!1},__decorate([e.serialize()],r.prototype,"_fromLinearSpace",void 0),r})(e.PostProcess);e.ImageProcessingPostProcess=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(r,i){var n=t.call(this,i)||this;return r?(n._textureMatrix=e.Matrix.Identity(),n.name=r,n.url=r,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(r,!0),n._texture||(i.useDelayedTextureLoading?n.delayLoadState=e.Engine.DELAYLOADSTATE_NOTLOADED:n.loadTexture()),n):n}return __extends(r,t),r.prototype.getTextureMatrix=function(){return this._textureMatrix},r.prototype.load3dlTexture=function(){var t=this,i=this.getScene().getEngine().createRawTexture(null,1,1,e.Engine.TEXTUREFORMAT_RGBA,!1,!1,e.Texture.BILINEAR_SAMPLINGMODE);this._texture=i;var n=function(n){for(var o,s,a,u=n.split("\n"),l=0,h=0,c=0,f=0,d=0,p=0;p<u.length;p++)if(a=u[p],r._noneEmptyLineRegex.test(a)&&0!==a.indexOf("#")){var g=a.split(" ");if(0!==l){if(0!=l){var _=Math.max(parseInt(g[0]),0),m=Math.max(parseInt(g[1]),0),v=Math.max(parseInt(g[2]),0);d=Math.max(_,d),d=Math.max(m,d),d=Math.max(v,d);var y=4*(h+f*l+c*l*l);s[y+0]=_,s[y+1]=m,s[y+2]=v,f++,f%l==0&&(c++,f=0,c%l==0&&(h++,c=0))}}else l=g.length,o=new Uint8Array(l*l*l*4),s=new Float32Array(l*l*l*4)}for(var p=0;p<s.length;p++)if(p>0&&(p+1)%4==0)o[p]=255;else{var A=s[p];o[p]=A/d*255}t.getScene().getEngine().updateTextureSize(i,l*l,l),t.getScene().getEngine().updateRawTexture(i,o,e.Engine.TEXTUREFORMAT_RGBA,!1)};return e.Tools.LoadFile(this.url,n),this._texture},r.prototype.loadTexture=function(){this.url&&this.url.toLocaleLowerCase().indexOf(".3dl")==this.url.length-4&&this.load3dlTexture()},r.prototype.clone=function(){var e=new r(this.url,this.getScene());return e.level=this.level,e},r.prototype.delayLoad=function(){this.delayLoadState===e.Engine.DELAYLOADSTATE_NOTLOADED&&(this.delayLoadState=e.Engine.DELAYLOADSTATE_LOADED,this._texture=this._getFromCache(this.url,!0),this._texture||this.loadTexture())},r.Parse=function(t,r,i){var n=null;return t.name&&!t.isRenderTarget&&(n=new e.ColorGradingTexture(t.name,r),n.name=t.name,n.level=t.level),n},r.prototype.serialize=function(){if(!this.name)return null;var e={};return e.name=this.name,e.level=this.level,e.customType="BABYLON.ColorGradingTexture",e},r._noneEmptyLineRegex=/\S+/,r})(e.BaseTexture);e.ColorGradingTexture=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){this._dirty=!0,this._tempColor=new e.Color4(0,0,0,0),this._globalCurve=new e.Color4(0,0,0,0),this._highlightsCurve=new e.Color4(0,0,0,0),this._midtonesCurve=new e.Color4(0,0,0,0),this._shadowsCurve=new e.Color4(0,0,0,0),this._positiveCurve=new e.Color4(0,0,0,0),this._negativeCurve=new e.Color4(0,0,0,0),this._globalHue=30,this._globalDensity=0,this._globalSaturation=0,this._globalExposure=0,this._highlightsHue=30,this._highlightsDensity=0,this._highlightsSaturation=0,this._highlightsExposure=0,this._midtonesHue=30,this._midtonesDensity=0,this._midtonesSaturation=0,this._midtonesExposure=0,this._shadowsHue=30,this._shadowsDensity=0,this._shadowsSaturation=0,this._shadowsExposure=0}return Object.defineProperty(t.prototype,"globalHue",{get:function(){return this._globalHue},set:function(e){this._globalHue=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"globalDensity",{get:function(){
- return this._globalDensity},set:function(e){this._globalDensity=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"globalSaturation",{get:function(){return this._globalSaturation},set:function(e){this._globalSaturation=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"highlightsHue",{get:function(){return this._highlightsHue},set:function(e){this._highlightsHue=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"highlightsDensity",{get:function(){return this._highlightsDensity},set:function(e){this._highlightsDensity=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"highlightsSaturation",{get:function(){return this._highlightsSaturation},set:function(e){this._highlightsSaturation=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"highlightsExposure",{get:function(){return this._highlightsExposure},set:function(e){this._highlightsExposure=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"midtonesHue",{get:function(){return this._midtonesHue},set:function(e){this._midtonesHue=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"midtonesDensity",{get:function(){return this._midtonesDensity},set:function(e){this._midtonesDensity=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"midtonesSaturation",{get:function(){return this._midtonesSaturation},set:function(e){this._midtonesSaturation=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"midtonesExposure",{get:function(){return this._midtonesExposure},set:function(e){this._midtonesExposure=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"shadowsHue",{get:function(){return this._shadowsHue},set:function(e){this._shadowsHue=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"shadowsDensity",{get:function(){return this._shadowsDensity},set:function(e){this._shadowsDensity=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"shadowsSaturation",{get:function(){return this._shadowsSaturation},set:function(e){this._shadowsSaturation=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"shadowsExposure",{get:function(){return this._shadowsExposure},set:function(e){this._shadowsExposure=e,this._dirty=!0},enumerable:!0,configurable:!0}),t.prototype.getClassName=function(){return"ColorCurves"},t.Bind=function(e,t,r,i,n){void 0===r&&(r="vCameraColorCurvePositive"),void 0===i&&(i="vCameraColorCurveNeutral"),void 0===n&&(n="vCameraColorCurveNegative"),e._dirty&&(e._dirty=!1,e.getColorGradingDataToRef(e._globalHue,e._globalDensity,e._globalSaturation,e._globalExposure,e._globalCurve),e.getColorGradingDataToRef(e._highlightsHue,e._highlightsDensity,e._highlightsSaturation,e._highlightsExposure,e._tempColor),e._tempColor.multiplyToRef(e._globalCurve,e._highlightsCurve),e.getColorGradingDataToRef(e._midtonesHue,e._midtonesDensity,e._midtonesSaturation,e._midtonesExposure,e._tempColor),e._tempColor.multiplyToRef(e._globalCurve,e._midtonesCurve),e.getColorGradingDataToRef(e._shadowsHue,e._shadowsDensity,e._shadowsSaturation,e._shadowsExposure,e._tempColor),e._tempColor.multiplyToRef(e._globalCurve,e._shadowsCurve),e._highlightsCurve.subtractToRef(e._midtonesCurve,e._positiveCurve),e._midtonesCurve.subtractToRef(e._shadowsCurve,e._negativeCurve)),t&&(t.setFloat4(r,e._positiveCurve.r,e._positiveCurve.g,e._positiveCurve.b,e._positiveCurve.a),t.setFloat4(i,e._midtonesCurve.r,e._midtonesCurve.g,e._midtonesCurve.b,e._midtonesCurve.a),t.setFloat4(n,e._negativeCurve.r,e._negativeCurve.g,e._negativeCurve.b,e._negativeCurve.a))},t.PrepareUniforms=function(e){e.push("vCameraColorCurveNeutral","vCameraColorCurvePositive","vCameraColorCurveNegative")},t.prototype.getColorGradingDataToRef=function(e,r,i,n,o){null!=e&&(e=t.clamp(e,0,360),r=t.clamp(r,-100,100),i=t.clamp(i,-100,100),n=t.clamp(n,-100,100),r=t.applyColorGradingSliderNonlinear(r),r*=.5,n=t.applyColorGradingSliderNonlinear(n),r<0&&(r*=-1,e=(e+180)%360),t.fromHSBToRef(e,r,50+.25*n,o),o.scaleToRef(2,o),o.a=1+.01*i)},t.applyColorGradingSliderNonlinear=function(e){e/=100;var t=Math.abs(e);return t=Math.pow(t,2),e<0&&(t*=-1),t*=100},t.fromHSBToRef=function(e,r,i,n){var o=t.clamp(e,0,360),s=t.clamp(r/100,0,1),a=t.clamp(i/100,0,1);if(0===s)n.r=a,n.g=a,n.b=a;else{o/=60;var u=Math.floor(o),l=o-u,h=a*(1-s),c=a*(1-s*l),f=a*(1-s*(1-l));switch(u){case 0:n.r=a,n.g=f,n.b=h;break;case 1:n.r=c,n.g=a,n.b=h;break;case 2:n.r=h,n.g=a,n.b=f;break;case 3:n.r=h,n.g=c,n.b=a;break;case 4:n.r=f,n.g=h,n.b=a;break;default:n.r=a,n.g=h,n.b=c}}n.a=1},t.clamp=function(e,t,r){return Math.min(Math.max(e,t),r)},t.prototype.clone=function(){return e.SerializationHelper.Clone((function(){return new t}),this)},t.prototype.serialize=function(){return e.SerializationHelper.Serialize(this)},t.Parse=function(r){return e.SerializationHelper.Parse((function(){return new t}),r,null,null)},__decorate([e.serialize()],t.prototype,"_globalHue",void 0),__decorate([e.serialize()],t.prototype,"_globalDensity",void 0),__decorate([e.serialize()],t.prototype,"_globalSaturation",void 0),__decorate([e.serialize()],t.prototype,"_globalExposure",void 0),__decorate([e.serialize()],t.prototype,"_highlightsHue",void 0),__decorate([e.serialize()],t.prototype,"_highlightsDensity",void 0),__decorate([e.serialize()],t.prototype,"_highlightsSaturation",void 0),__decorate([e.serialize()],t.prototype,"_highlightsExposure",void 0),__decorate([e.serialize()],t.prototype,"_midtonesHue",void 0),__decorate([e.serialize()],t.prototype,"_midtonesDensity",void 0),__decorate([e.serialize()],t.prototype,"_midtonesSaturation",void 0),__decorate([e.serialize()],t.prototype,"_midtonesExposure",void 0),t})();e.ColorCurves=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(){this._renderPipelines={}}return e.prototype.addPipeline=function(e){this._renderPipelines[e._name]=e},e.prototype.attachCamerasToRenderPipeline=function(e,t,r){var i=this._renderPipelines[e];i&&i._attachCameras(t,r)},e.prototype.detachCamerasFromRenderPipeline=function(e,t){var r=this._renderPipelines[e];r&&r._detachCameras(t)},e.prototype.enableEffectInPipeline=function(e,t,r){var i=this._renderPipelines[e];i&&i._enableEffect(t,r)},e.prototype.disableEffectInPipeline=function(e,t,r){var i=this._renderPipelines[e];i&&i._disableEffect(t,r)},e.prototype.enableDisplayOnlyPassInPipeline=function(e,t,r){var i=this._renderPipelines[e];i&&i._enableDisplayOnlyPass(t,r)},e.prototype.disableDisplayOnlyPassInPipeline=function(e,t){var r=this._renderPipelines[e];r&&r._disableDisplayOnlyPass(t)},e.prototype.update=function(){for(var e in this._renderPipelines){var t=this._renderPipelines[e];t.isSupported?t._update():(t.dispose(),delete this._renderPipelines[e])}},e})();e.PostProcessRenderPipelineManager=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(t,r,i,n,o,s){this._enabled=!0,this._refCount=0,this._name=r,this._renderTexture=new e.RenderTargetTexture(r,i,t),this.setRenderList(n),this._renderTexture.onBeforeRenderObservable.add(o),this._renderTexture.onAfterRenderObservable.add(s),this._scene=t,this._renderList=n}return t.prototype._incRefCount=function(){return 0===this._refCount&&this._scene.customRenderTargets.push(this._renderTexture),++this._refCount},t.prototype._decRefCount=function(){return this._refCount--,this._refCount<=0&&this._scene.customRenderTargets.splice(this._scene.customRenderTargets.indexOf(this._renderTexture),1),this._refCount},t.prototype._update=function(){this.setRenderList(this._renderList)},t.prototype.setRenderList=function(e){this._renderTexture.renderList=e},t.prototype.getRenderTexture=function(){return this._renderTexture},t})();e.PostProcessRenderPass=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(e,t,r,i){this._engine=e,this._name=t,this._singleInstance=i||!0,this._getPostProcess=r,this._cameras=[],this._indicesForCamera=[],this._postProcesses={},this._renderPasses={},this._renderEffectAsPasses={}}return Object.defineProperty(t.prototype,"isSupported",{get:function(){for(var e in this._postProcesses)if(!this._postProcesses[e].isSupported)return!1;return!0},enumerable:!0,configurable:!0}),t.prototype._update=function(){for(var e in this._renderPasses)this._renderPasses[e]._update()},t.prototype.addPass=function(e){this._renderPasses[e._name]=e,this._linkParameters()},t.prototype.removePass=function(e){delete this._renderPasses[e._name],this._linkParameters()},t.prototype.addRenderEffectAsPass=function(e){this._renderEffectAsPasses[e._name]=e,this._linkParameters()},t.prototype.getPass=function(e){for(var t in this._renderPasses)if(t===e)return this._renderPasses[e]},t.prototype.emptyPasses=function(){this._renderPasses={},this._linkParameters()},t.prototype._attachCameras=function(t){for(var r,i=e.Tools.MakeArray(t||this._cameras),n=0;n<i.length;n++){var o=i[n],s=o.name;r=this._singleInstance?0:s,this._postProcesses[r]=this._postProcesses[r]||this._getPostProcess();var a=o.attachPostProcess(this._postProcesses[r]);this._indicesForCamera[s]||(this._indicesForCamera[s]=[]),this._indicesForCamera[s].push(a),-1===this._cameras.indexOf(o)&&(this._cameras[s]=o);for(var u in this._renderPasses)this._renderPasses[u]._incRefCount()}this._linkParameters()},t.prototype._detachCameras=function(t){for(var r=e.Tools.MakeArray(t||this._cameras),i=0;i<r.length;i++){var n=r[i],o=n.name;n.detachPostProcess(this._postProcesses[this._singleInstance?0:o],this._indicesForCamera[o]);var s=this._cameras.indexOf(o);this._indicesForCamera.splice(s,1),this._cameras.splice(s,1);for(var a in this._renderPasses)this._renderPasses[a]._decRefCount()}},t.prototype._enable=function(t){for(var r=e.Tools.MakeArray(t||this._cameras),i=0;i<r.length;i++){for(var n=r[i],o=n.name,s=0;s<this._indicesForCamera[o].length;s++)void 0===n._postProcesses[this._indicesForCamera[o][s]]&&t[i].attachPostProcess(this._postProcesses[this._singleInstance?0:o],this._indicesForCamera[o][s]);for(var a in this._renderPasses)this._renderPasses[a]._incRefCount()}},t.prototype._disable=function(t){for(var r=e.Tools.MakeArray(t||this._cameras),i=0;i<r.length;i++){var n=r[i],o=n.Name;n.detachPostProcess(this._postProcesses[this._singleInstance?0:o],this._indicesForCamera[o]);for(var s in this._renderPasses)this._renderPasses[s]._decRefCount()}},t.prototype.getPostProcess=function(e){return this._singleInstance?this._postProcesses[0]:this._postProcesses[e.name]},t.prototype._linkParameters=function(){var e=this;for(var t in this._postProcesses)this.applyParameters&&this.applyParameters(this._postProcesses[t]),this._postProcesses[t].onBeforeRenderObservable.add((function(t){e._linkTextures(t)}))},t.prototype._linkTextures=function(e){for(var t in this._renderPasses)e.setTexture(t,this._renderPasses[t].getRenderTexture());for(var r in this._renderEffectAsPasses)e.setTextureFromPostProcess(r+"Sampler",this._renderEffectAsPasses[r].getPostProcess())},t})();e.PostProcessRenderEffect=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(e,t){this._engine=e,this._name=t,this._renderEffects=new Array,this._renderEffectsForIsolatedPass=new Array,this._cameras=[]}return t.prototype.getClassName=function(){return"PostProcessRenderPipeline"},Object.defineProperty(t.prototype,"isSupported",{get:function(){for(var e in this._renderEffects)if(!this._renderEffects[e].isSupported)return!1;return!0},enumerable:!0,configurable:!0}),t.prototype.addEffect=function(e){this._renderEffects[e._name]=e},t.prototype._enableEffect=function(t,r){var i=this._renderEffects[t];i&&i._enable(e.Tools.MakeArray(r||this._cameras))},t.prototype._disableEffect=function(t,r){var i=this._renderEffects[t];i&&i._disable(e.Tools.MakeArray(r||this._cameras))},t.prototype._attachCameras=function(t,r){var i,n=e.Tools.MakeArray(t||this._cameras),o=[];for(i=0;i<n.length;i++){var s=n[i],a=s.name;-1===this._cameras.indexOf(s)?this._cameras[a]=s:r&&o.push(i)}for(i=0;i<o.length;i++)t.splice(o[i],1);for(var u in this._renderEffects)this._renderEffects[u]._attachCameras(n)},t.prototype._detachCameras=function(t){var r=e.Tools.MakeArray(t||this._cameras);for(var i in this._renderEffects)this._renderEffects[i]._detachCameras(r);for(var n=0;n<r.length;n++)this._cameras.splice(this._cameras.indexOf(r[n]),1)},t.prototype._enableDisplayOnlyPass=function(r,i){var n,o=this,s=e.Tools.MakeArray(i||this._cameras),a=null;for(n in this._renderEffects)if(null!=(a=this._renderEffects[n].getPass(r)))break;if(null!==a){for(n in this._renderEffects)this._renderEffects[n]._disable(s);a._name=t.PASS_SAMPLER_NAME;for(var u=0;u<s.length;u++){var l=s[u],h=l.name;this._renderEffectsForIsolatedPass[h]=this._renderEffectsForIsolatedPass[h]||new e.PostProcessRenderEffect(this._engine,t.PASS_EFFECT_NAME,function(){return new e.DisplayPassPostProcess(t.PASS_EFFECT_NAME,1,null,null,o._engine,!0)}),this._renderEffectsForIsolatedPass[h].emptyPasses(),this._renderEffectsForIsolatedPass[h].addPass(a),this._renderEffectsForIsolatedPass[h]._attachCameras(l)}}},t.prototype._disableDisplayOnlyPass=function(r){for(var i=this,n=e.Tools.MakeArray(r||this._cameras),o=0;o<n.length;o++){var s=n[o],a=s.name;this._renderEffectsForIsolatedPass[a]=this._renderEffectsForIsolatedPass[a]||new e.PostProcessRenderEffect(this._engine,t.PASS_EFFECT_NAME,function(){return new e.DisplayPassPostProcess(t.PASS_EFFECT_NAME,1,null,null,i._engine,!0)}),this._renderEffectsForIsolatedPass[a]._disable(s)}for(var u in this._renderEffects)this._renderEffects[u]._enable(n)},t.prototype._update=function(){for(var e in this._renderEffects)this._renderEffects[e]._update();for(var t=0;t<this._cameras.length;t++){var r=this._cameras[t].name;this._renderEffectsForIsolatedPass[r]&&this._renderEffectsForIsolatedPass[r]._update()}},t.prototype._reset=function(){this._renderEffects=new Array,this._renderEffectsForIsolatedPass=new Array},t.prototype.dispose=function(){},t.PASS_EFFECT_NAME="passEffect",t.PASS_SAMPLER_NAME="passSampler",__decorate([e.serialize()],t.prototype,"_name",void 0),t})();e.PostProcessRenderPipeline=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(r,i,n,o,s){void 0===s&&(s=!0);var a=t.call(this,n.getEngine(),r)||this;a.PassPostProcessId="PassPostProcessEffect",a.HighLightsPostProcessId="HighLightsPostProcessEffect",a.BlurXPostProcessId="BlurXPostProcessEffect",a.BlurYPostProcessId="BlurYPostProcessEffect",a.CopyBackPostProcessId="CopyBackPostProcessEffect",a.ImageProcessingPostProcessId="ImageProcessingPostProcessEffect",a.FxaaPostProcessId="FxaaPostProcessEffect",a.FinalMergePostProcessId="FinalMergePostProcessEffect",a.animations=[],a._bloomEnabled=!1,a._fxaaEnabled=!1,a._imageProcessingEnabled=!0,a._bloomScale=.6,a._buildAllowed=!0,a.bloomKernel=64,a._bloomWeight=.15,a._cameras=o||[],a._buildAllowed=s,a._scene=n;var u=a._scene.getEngine().getCaps();return a._hdr=i&&(u.textureHalfFloatRender||u.textureFloatRender),a._hdr?u.textureHalfFloatRender?a._defaultPipelineTextureType=e.Engine.TEXTURETYPE_HALF_FLOAT:u.textureFloatRender&&(a._defaultPipelineTextureType=e.Engine.TEXTURETYPE_FLOAT):a._defaultPipelineTextureType=e.Engine.TEXTURETYPE_UNSIGNED_INT,n.postProcessRenderPipelineManager.addPipeline(a),a._buildPipeline(),a}return __extends(r,t),Object.defineProperty(r.prototype,"bloomWeight",{get:function(){return this._bloomWeight},set:function(t){this._bloomWeight!==t&&(this._bloomWeight=t,this._hdr&&this.copyBack&&(this.copyBack.alphaConstants=new e.Color4(t,t,t,t)))},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"bloomScale",{get:function(){return this._bloomScale},set:function(e){this._bloomScale!==e&&(this._bloomScale=e,this._buildPipeline())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"bloomEnabled",{get:function(){return this._bloomEnabled},set:function(e){this._bloomEnabled!==e&&(this._bloomEnabled=e,this._buildPipeline())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"fxaaEnabled",{get:function(){return this._fxaaEnabled},set:function(e){this._fxaaEnabled!==e&&(this._fxaaEnabled=e,this._buildPipeline())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"imageProcessingEnabled",{get:function(){return this._imageProcessingEnabled},set:function(e){this._imageProcessingEnabled!==e&&(this._imageProcessingEnabled=e,this._buildPipeline())},enumerable:!0,configurable:!0}),r.prototype.prepare=function(){var e=this._buildAllowed;this._buildAllowed=!0,this._buildPipeline(),this._buildAllowed=e},r.prototype._buildPipeline=function(){var t=this;if(this._buildAllowed){var r=this._scene.getEngine();if(this._disposePostProcesses(),this._reset(),this.bloomEnabled){if(this.pass=new e.PassPostProcess("sceneRenderTarget",1,null,e.Texture.BILINEAR_SAMPLINGMODE,r,!1,this._defaultPipelineTextureType),this.addEffect(new e.PostProcessRenderEffect(r,this.PassPostProcessId,function(){return t.pass},!0)),this._hdr||(this.highlights=new e.HighlightsPostProcess("highlights",this.bloomScale,null,e.Texture.BILINEAR_SAMPLINGMODE,r,!1,this._defaultPipelineTextureType),this.addEffect(new e.PostProcessRenderEffect(r,this.HighLightsPostProcessId,function(){return t.highlights},!0)),this.highlights.autoClear=!1,this.highlights.alwaysForcePOT=!0),this.blurX=new e.BlurPostProcess("horizontal blur",new e.Vector2(1,0),10,this.bloomScale,null,e.Texture.BILINEAR_SAMPLINGMODE,r,!1,this._defaultPipelineTextureType),this.addEffect(new e.PostProcessRenderEffect(r,this.BlurXPostProcessId,function(){return t.blurX},!0)),this.blurX.alwaysForcePOT=!0,this.blurX.autoClear=!1,this.blurX.onActivateObservable.add((function(){var e=t.blurX.width/r.getRenderingCanvas().width;t.blurX.kernel=t.bloomKernel*e})),this.blurY=new e.BlurPostProcess("vertical blur",new e.Vector2(0,1),10,this.bloomScale,null,e.Texture.BILINEAR_SAMPLINGMODE,r,!1,this._defaultPipelineTextureType),this.addEffect(new e.PostProcessRenderEffect(r,this.BlurYPostProcessId,function(){return t.blurY},!0)),this.blurY.alwaysForcePOT=!0,this.blurY.autoClear=!1,this.blurY.onActivateObservable.add((function(){var e=t.blurY.height/r.getRenderingCanvas().height;t.blurY.kernel=t.bloomKernel*e})),this.copyBack=new e.PassPostProcess("bloomBlendBlit",this.bloomScale,null,e.Texture.BILINEAR_SAMPLINGMODE,r,!1,this._defaultPipelineTextureType),this.addEffect(new e.PostProcessRenderEffect(r,this.CopyBackPostProcessId,function(){return t.copyBack},!0)),this.copyBack.alwaysForcePOT=!0,this._hdr){this.copyBack.alphaMode=e.Engine.ALPHA_INTERPOLATE;var i=this.bloomWeight;this.copyBack.alphaConstants=new e.Color4(i,i,i,i)}else this.copyBack.alphaMode=e.Engine.ALPHA_SCREENMODE;this.copyBack.autoClear=!1}this._imageProcessingEnabled&&(this.imageProcessing=new e.ImageProcessingPostProcess("imageProcessing",1,null,e.Texture.BILINEAR_SAMPLINGMODE,r,!1,this._defaultPipelineTextureType),this._hdr&&this.addEffect(new e.PostProcessRenderEffect(r,this.ImageProcessingPostProcessId,function(){return t.imageProcessing},!0))),this.fxaaEnabled?(this.fxaa=new e.FxaaPostProcess("fxaa",1,null,e.Texture.BILINEAR_SAMPLINGMODE,r,!1,this._defaultPipelineTextureType),this.addEffect(new e.PostProcessRenderEffect(r,this.FxaaPostProcessId,function(){return t.fxaa},!0)),this.fxaa.autoClear=!(this.bloomEnabled||this._hdr&&this.imageProcessing)):(this.finalMerge=new e.PassPostProcess("finalMerge",1,null,e.Texture.BILINEAR_SAMPLINGMODE,r,!1,this._defaultPipelineTextureType),this.addEffect(new e.PostProcessRenderEffect(r,this.FinalMergePostProcessId,function(){return t.finalMerge},!0)),this.finalMerge.autoClear=!(this.bloomEnabled||this._hdr&&this.imageProcessing)),this.bloomEnabled&&(this._hdr?(this.copyBack.shareOutputWith(this.blurX),this.imageProcessing?(this.imageProcessing.shareOutputWith(this.pass),this.imageProcessing.autoClear=!1):this.fxaa?this.fxaa.shareOutputWith(this.pass):this.finalMerge.shareOutputWith(this.pass)):this.fxaa?this.fxaa.shareOutputWith(this.pass):this.finalMerge.shareOutputWith(this.pass)),null!==this._cameras&&this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name,this._cameras)}},r.prototype._disposePostProcesses=function(){for(var e=0;e<this._cameras.length;e++){var t=this._cameras[e];this.pass&&this.pass.dispose(t),this.highlights&&this.highlights.dispose(t),this.blurX&&this.blurX.dispose(t),this.blurY&&this.blurY.dispose(t),this.copyBack&&this.copyBack.dispose(t),this.imageProcessing&&this.imageProcessing.dispose(t),this.fxaa&&this.fxaa.dispose(t),this.finalMerge&&this.finalMerge.dispose(t)}this.pass=null,this.highlights=null,this.blurX=null,this.blurY=null,this.copyBack=null,this.imageProcessing=null,this.fxaa=null,this.finalMerge=null},r.prototype.dispose=function(){this._disposePostProcesses(),this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name,this._cameras),t.prototype.dispose.call(this)},r.prototype.serialize=function(){var t=e.SerializationHelper.Serialize(this);return t.customType="DefaultRenderingPipeline",t},r.Parse=function(t,i,n){return e.SerializationHelper.Parse((function(){return new r(t._name,t._name._hdr,i)}),t,i,n)},__decorate([e.serialize()],r.prototype,"bloomKernel",void 0),__decorate([e.serialize()],r.prototype,"_bloomWeight",void 0),__decorate([e.serialize()],r.prototype,"_hdr",void 0),__decorate([e.serialize()],r.prototype,"bloomWeight",null),__decorate([e.serialize()],r.prototype,"bloomScale",null),__decorate([e.serialize()],r.prototype,"bloomEnabled",null),__decorate([e.serialize()],r.prototype,"fxaaEnabled",null),__decorate([e.serialize()],r.prototype,"imageProcessingEnabled",null),r})(e.PostProcessRenderPipeline);e.DefaultRenderingPipeline=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){this.colorCurves=new e.ColorCurves,this._colorCurvesEnabled=!1,this._colorGradingEnabled=!1,this._colorGradingWithGreenDepth=!1,this._colorGradingBGR=!1,this._exposure=1,this._toneMappingEnabled=!1,this._contrast=1,this.vignetteStretch=0,this.vignetteCentreX=0,this.vignetteCentreY=0,this.vignetteWeight=1.5,this.vignetteColor=new e.Color4(0,0,0,0),this.vignetteCameraFov=.5,this._vignetteBlendMode=t.VIGNETTEMODE_MULTIPLY,this._vignetteEnabled=!1,this._applyByPostProcess=!1,this.onUpdateParameters=new e.Observable}return Object.defineProperty(t.prototype,"colorCurvesEnabled",{get:function(){return this._colorCurvesEnabled},set:function(e){this._colorCurvesEnabled!==e&&(this._colorCurvesEnabled=e,this._updateParameters())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"colorGradingEnabled",{get:function(){return this._colorGradingEnabled},set:function(e){this._colorGradingEnabled!==e&&(this._colorGradingEnabled=e,this._updateParameters())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"colorGradingWithGreenDepth",{get:function(){return this._colorGradingWithGreenDepth},set:function(e){this._colorGradingWithGreenDepth!==e&&(this._colorGradingWithGreenDepth=e,this._updateParameters())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"colorGradingBGR",{get:function(){return this._colorGradingBGR},set:function(e){this._colorGradingBGR!==e&&(this._colorGradingBGR=e,this._updateParameters())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"exposure",{get:function(){return this._exposure},set:function(e){this._exposure!==e&&(this._exposure=e,this._updateParameters())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"toneMappingEnabled",{get:function(){return this._toneMappingEnabled},set:function(e){this._toneMappingEnabled!==e&&(this._toneMappingEnabled=e,this._updateParameters())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"contrast",{get:function(){return this._contrast},set:function(e){this._contrast!==e&&(this._contrast=e,this._updateParameters())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"vignetteBlendMode",{get:function(){return this._vignetteBlendMode},set:function(e){this._vignetteBlendMode!==e&&(this._vignetteBlendMode=e,this._updateParameters())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"vignetteEnabled",{get:function(){return this._vignetteEnabled},set:function(e){this._vignetteEnabled!==e&&(this._vignetteEnabled=e,this._updateParameters())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"applyByPostProcess",{get:function(){return this._applyByPostProcess},set:function(e){this._applyByPostProcess!==e&&(this._applyByPostProcess=e,this._updateParameters())},enumerable:!0,configurable:!0}),t.prototype._updateParameters=function(){this.onUpdateParameters.notifyObservers(this)},t.prototype.getClassName=function(){return"ImageProcessingConfiguration"},t.PrepareUniforms=function(t,r){r.EXPOSURE&&t.push("exposureLinear"),r.CONTRAST&&t.push("contrast"),r.COLORGRADING&&t.push("colorTransformSettings"),r.VIGNETTE&&(t.push("vInverseScreenSize"),t.push("vignetteSettings1"),t.push("vignetteSettings2")),r.COLORCURVES&&e.ColorCurves.PrepareUniforms(t)},t.PrepareSamplers=function(e,t){t.COLORGRADING&&e.push("txColorTransform")},t.prototype.prepareDefines=function(e){e.VIGNETTE=this.vignetteEnabled,e.VIGNETTEBLENDMODEMULTIPLY=this.vignetteBlendMode===t._VIGNETTEMODE_MULTIPLY,e.VIGNETTEBLENDMODEOPAQUE=!e.VIGNETTEBLENDMODEMULTIPLY,e.TONEMAPPING=this.toneMappingEnabled,e.CONTRAST=1!==this.contrast,e.EXPOSURE=1!==this.exposure,e.COLORCURVES=this.colorCurvesEnabled&&!!this.colorCurves,e.COLORGRADING=this.colorGradingEnabled&&!!this.colorGradingTexture,e.SAMPLER3DGREENDEPTH=this.colorGradingWithGreenDepth,e.SAMPLER3DBGRMAP=this.colorGradingBGR,e.IMAGEPROCESSINGPOSTPROCESS=this.applyByPostProcess,e.IMAGEPROCESSING=e.VIGNETTE||e.TONEMAPPING||e.CONTRAST||e.EXPOSURE||e.COLORCURVES||e.COLORGRADING},t.prototype.isReady=function(){return!this.colorGradingEnabled||!this.colorGradingTexture||this.colorGradingTexture.isReady()},t.prototype.bind=function(t,r){if(void 0===r&&(r=1),this._colorCurvesEnabled&&e.ColorCurves.Bind(this.colorCurves,t),this._vignetteEnabled){var i=1/t.getEngine().getRenderWidth(),n=1/t.getEngine().getRenderHeight();t.setFloat2("vInverseScreenSize",i,n);var o=Math.tan(.5*this.vignetteCameraFov),s=o*r,a=Math.sqrt(s*o);s=e.Tools.Mix(s,a,this.vignetteStretch),o=e.Tools.Mix(o,a,this.vignetteStretch),t.setFloat4("vignetteSettings1",s,o,-s*this.vignetteCentreX,-o*this.vignetteCentreY);var u=-2*this.vignetteWeight;t.setFloat4("vignetteSettings2",this.vignetteColor.r,this.vignetteColor.g,this.vignetteColor.b,u)}if(t.setFloat("exposureLinear",this.exposure),t.setFloat("contrast",this.contrast),this.colorGradingTexture){t.setTexture("txColorTransform",this.colorGradingTexture);var l=this.colorGradingTexture.getSize().height;t.setFloat4("colorTransformSettings",(l-1)/l,.5/l,l,this.colorGradingTexture.level)}},t.prototype.clone=function(){return e.SerializationHelper.Clone((function(){return new t}),this)},t.prototype.serialize=function(){return e.SerializationHelper.Serialize(this)},t.Parse=function(r){return e.SerializationHelper.Parse((function(){return new t}),r,null,null)},Object.defineProperty(t,"VIGNETTEMODE_MULTIPLY",{get:function(){return this._VIGNETTEMODE_MULTIPLY},enumerable:!0,configurable:!0}),Object.defineProperty(t,"VIGNETTEMODE_OPAQUE",{get:function(){return this._VIGNETTEMODE_OPAQUE},enumerable:!0,configurable:!0}),t._VIGNETTEMODE_MULTIPLY=0,t._VIGNETTEMODE_OPAQUE=1,__decorate([e.serializeAsColorCurves()],t.prototype,"colorCurves",void 0),__decorate([e.serialize()],t.prototype,"_colorCurvesEnabled",void 0),__decorate([e.serializeAsTexture()],t.prototype,"colorGradingTexture",void 0),__decorate([e.serialize()],t.prototype,"_colorGradingEnabled",void 0),__decorate([e.serialize()],t.prototype,"_colorGradingWithGreenDepth",void 0),__decorate([e.serialize()],t.prototype,"_colorGradingBGR",void 0),__decorate([e.serialize()],t.prototype,"_exposure",void 0),__decorate([e.serialize()],t.prototype,"_toneMappingEnabled",void 0),__decorate([e.serialize()],t.prototype,"_contrast",void 0),__decorate([e.serialize()],t.prototype,"vignetteStretch",void 0),__decorate([e.serialize()],t.prototype,"vignetteCentreX",void 0),__decorate([e.serialize()],t.prototype,"vignetteCentreY",void 0),__decorate([e.serialize()],t.prototype,"vignetteWeight",void 0),__decorate([e.serializeAsColor4()],t.prototype,"vignetteColor",void 0),__decorate([e.serialize()],t.prototype,"vignetteCameraFov",void 0),__decorate([e.serialize()],t.prototype,"_vignetteBlendMode",void 0),__decorate([e.serialize()],t.prototype,"_vignetteEnabled",void 0),__decorate([e.serialize()],t.prototype,"_applyByPostProcess",void 0),t})();e.ImageProcessingConfiguration=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(r,i){var n=t.call(this,r,i)||this;return n.generateOctree=!1,n._worldInverse=new e.Matrix,n}return __extends(r,t),r.prototype.getClassName=function(){return"GroundMesh"},Object.defineProperty(r.prototype,"subdivisions",{get:function(){return Math.min(this._subdivisionsX,this._subdivisionsY)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"subdivisionsX",{get:function(){return this._subdivisionsX},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"subdivisionsY",{get:function(){return this._subdivisionsY},enumerable:!0,configurable:!0}),r.prototype.optimize=function(e,t){void 0===t&&(t=32),this._subdivisionsX=e,this._subdivisionsY=e,this.subdivide(e),this.createOrUpdateSubmeshesOctree(t)},r.prototype.getHeightAtCoordinates=function(t,r){var i=this.getWorldMatrix(),n=e.Tmp.Matrix[5];i.invertToRef(n);var o=e.Tmp.Vector3[8];if(e.Vector3.TransformCoordinatesFromFloatsToRef(t,0,r,n,o),t=o.x,r=o.z,t<this._minX||t>this._maxX||r<this._minZ||r>this._maxZ)return this.position.y;this._heightQuads&&0!=this._heightQuads.length||(this._initHeightQuads(),this._computeHeightQuads());var s=this._getFacetAt(t,r),a=-(s.x*t+s.z*r+s.w)/s.y;return e.Vector3.TransformCoordinatesFromFloatsToRef(0,a,0,i,o),o.y},r.prototype.getNormalAtCoordinates=function(t,r){var i=new e.Vector3(0,1,0);return this.getNormalAtCoordinatesToRef(t,r,i),i},r.prototype.getNormalAtCoordinatesToRef=function(t,r,i){var n=this.getWorldMatrix(),o=e.Tmp.Matrix[5];n.invertToRef(o);var s=e.Tmp.Vector3[8];if(e.Vector3.TransformCoordinatesFromFloatsToRef(t,0,r,o,s),t=s.x,r=s.z,t<this._minX||t>this._maxX||r<this._minZ||r>this._maxZ)return this;this._heightQuads&&0!=this._heightQuads.length||(this._initHeightQuads(),this._computeHeightQuads());var a=this._getFacetAt(t,r);return e.Vector3.TransformNormalFromFloatsToRef(a.x,a.y,a.z,n,i),this},r.prototype.updateCoordinateHeights=function(){return this._heightQuads&&0!=this._heightQuads.length||this._initHeightQuads(),this._computeHeightQuads(),this},r.prototype._getFacetAt=function(e,t){var r=(this._subdivisionsX,this._subdivisionsY,Math.floor((e+this._maxX)*this._subdivisionsX/this._width)),i=Math.floor(-(t+this._maxZ)*this._subdivisionsY/this._height+this._subdivisionsY),n=this._heightQuads[i*this._subdivisionsX+r];return t<n.slope.x*e+n.slope.y?n.facet1:n.facet2},r.prototype._initHeightQuads=function(){var t=this._subdivisionsX,r=this._subdivisionsY;this._heightQuads=new Array;for(var i=0;i<r;i++)for(var n=0;n<t;n++){var o={slope:e.Vector2.Zero(),facet1:new e.Vector4(0,0,0,0),facet2:new e.Vector4(0,0,0,0)};this._heightQuads[i*t+n]=o}return this},r.prototype._computeHeightQuads=function(){for(var t=this.getVerticesData(e.VertexBuffer.PositionKind),r=e.Tmp.Vector3[3],i=e.Tmp.Vector3[2],n=e.Tmp.Vector3[1],o=e.Tmp.Vector3[0],s=e.Tmp.Vector3[4],a=e.Tmp.Vector3[5],u=e.Tmp.Vector3[6],l=e.Tmp.Vector3[7],h=e.Tmp.Vector3[8],c=0,f=0,d=0,p=0,g=0,_=0,m=0,v=this._subdivisionsX,y=this._subdivisionsY,A=0;A<y;A++)for(var T=0;T<v;T++){c=3*T,f=A*(v+1)*3,d=(A+1)*(v+1)*3,
- r.x=t[f+c],r.y=t[f+c+1],r.z=t[f+c+2],i.x=t[f+c+3],i.y=t[f+c+4],i.z=t[f+c+5],n.x=t[d+c],n.y=t[d+c+1],n.z=t[d+c+2],o.x=t[d+c+3],o.y=t[d+c+4],o.z=t[d+c+5],p=(o.z-r.z)/(o.x-r.x),g=r.z-p*r.x,i.subtractToRef(r,s),n.subtractToRef(r,a),o.subtractToRef(r,u),e.Vector3.CrossToRef(u,a,l),e.Vector3.CrossToRef(s,u,h),l.normalize(),h.normalize(),_=-(l.x*r.x+l.y*r.y+l.z*r.z),m=-(h.x*i.x+h.y*i.y+h.z*i.z);var E=this._heightQuads[A*v+T];E.slope.copyFromFloats(p,g),E.facet1.copyFromFloats(l.x,l.y,l.z,_),E.facet2.copyFromFloats(h.x,h.y,h.z,m)}return this},r.prototype.serialize=function(e){t.prototype.serialize.call(this,e),e.subdivisionsX=this._subdivisionsX,e.subdivisionsY=this._subdivisionsY,e.minX=this._minX,e.maxX=this._maxX,e.minZ=this._minZ,e.maxZ=this._maxZ,e.width=this._width,e.height=this._height},r.Parse=function(e,t){var i=new r(e.name,t);return i._subdivisionsX=e.subdivisionsX||1,i._subdivisionsY=e.subdivisionsY||1,i._minX=e.minX,i._maxX=e.maxX,i._minZ=e.minZ,i._maxZ=e.maxZ,i._width=e.width,i._height=e.height,i},r})(e.Mesh);e.GroundMesh=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(e,r){var i=t.call(this,e,r.getScene())||this;return r.instances.push(i),i._sourceMesh=r,i.position.copyFrom(r.position),i.rotation.copyFrom(r.rotation),i.scaling.copyFrom(r.scaling),r.rotationQuaternion&&(i.rotationQuaternion=r.rotationQuaternion.clone()),i.infiniteDistance=r.infiniteDistance,i.setPivotMatrix(r.getPivotMatrix()),i.refreshBoundingInfo(),i._syncSubMeshes(),i}return __extends(r,t),r.prototype.getClassName=function(){return"InstancedMesh"},Object.defineProperty(r.prototype,"receiveShadows",{get:function(){return this._sourceMesh.receiveShadows},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"material",{get:function(){return this._sourceMesh.material},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"visibility",{get:function(){return this._sourceMesh.visibility},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"skeleton",{get:function(){return this._sourceMesh.skeleton},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"renderingGroupId",{get:function(){return this._sourceMesh.renderingGroupId},enumerable:!0,configurable:!0}),r.prototype.getTotalVertices=function(){return this._sourceMesh.getTotalVertices()},Object.defineProperty(r.prototype,"sourceMesh",{get:function(){return this._sourceMesh},enumerable:!0,configurable:!0}),r.prototype.getVerticesData=function(e,t){return this._sourceMesh.getVerticesData(e,t)},r.prototype.setVerticesData=function(e,t,r,i){return this.sourceMesh&&this.sourceMesh.setVerticesData(e,t,r,i),this.sourceMesh},r.prototype.updateVerticesData=function(e,t,r,i){return this.sourceMesh&&this.sourceMesh.updateVerticesData(e,t,r,i),this.sourceMesh},r.prototype.setIndices=function(e,t){return this.sourceMesh&&this.sourceMesh.setIndices(e,t),this.sourceMesh},r.prototype.isVerticesDataPresent=function(e){return this._sourceMesh.isVerticesDataPresent(e)},r.prototype.getIndices=function(){return this._sourceMesh.getIndices()},Object.defineProperty(r.prototype,"_positions",{get:function(){return this._sourceMesh._positions},enumerable:!0,configurable:!0}),r.prototype.refreshBoundingInfo=function(){var t=this._sourceMesh.getBoundingInfo();return this._boundingInfo=new e.BoundingInfo(t.minimum.clone(),t.maximum.clone()),this._updateBoundingInfo(),this},r.prototype._preActivate=function(){return this._currentLOD&&this._currentLOD._preActivate(),this},r.prototype._activate=function(e){return this._currentLOD&&this._currentLOD._registerInstanceForRenderId(this,e),this},r.prototype.getLOD=function(e){return this._currentLOD=this.sourceMesh.getLOD(this.getScene().activeCamera,this.getBoundingInfo().boundingSphere),this._currentLOD===this.sourceMesh?this:this._currentLOD},r.prototype._syncSubMeshes=function(){if(this.releaseSubMeshes(),this._sourceMesh.subMeshes)for(var e=0;e<this._sourceMesh.subMeshes.length;e++)this._sourceMesh.subMeshes[e].clone(this,this._sourceMesh);return this},r.prototype._generatePointsArray=function(){return this._sourceMesh._generatePointsArray()},r.prototype.clone=function(t,r,i){var n=this._sourceMesh.createInstance(t);if(e.Tools.DeepCopy(this,n,["name","subMeshes","uniqueId"],[]),this.refreshBoundingInfo(),r&&(n.parent=r),!i)for(var o=0;o<this.getScene().meshes.length;o++){var s=this.getScene().meshes[o];s.parent===this&&s.clone(s.name,n)}return n.computeWorldMatrix(!0),n},r.prototype.dispose=function(e){var r=this._sourceMesh.instances.indexOf(this);this._sourceMesh.instances.splice(r,1),t.prototype.dispose.call(this,e)},r})(e.AbstractMesh);e.InstancedMesh=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(r,i,n,o,s,a){void 0===n&&(n=null);var u=t.call(this,r,i,n,o,s)||this;u.useVertexColor=a,u.color=new e.Color3(1,1,1),u.alpha=1,o&&(u.color=o.color.clone(),u.alpha=o.alpha,u.useVertexColor=o.useVertexColor),u._intersectionThreshold=.1;var l={attributes:[e.VertexBuffer.PositionKind],uniforms:["world","viewProjection"],needAlphaBlending:!1};return a||(l.uniforms.push("color"),l.needAlphaBlending=!0),u._colorShader=new e.ShaderMaterial("colorShader",i,"color",l),u}return __extends(r,t),Object.defineProperty(r.prototype,"intersectionThreshold",{get:function(){return this._intersectionThreshold},set:function(t){this._intersectionThreshold!==t&&(this._intersectionThreshold=t,this.geometry&&(this.geometry.boundingBias=new e.Vector2(0,t)))},enumerable:!0,configurable:!0}),r.prototype.getClassName=function(){return"LinesMesh"},Object.defineProperty(r.prototype,"material",{get:function(){return this._colorShader},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"checkCollisions",{get:function(){return!1},enumerable:!0,configurable:!0}),r.prototype.createInstance=function(t){return e.Tools.Log("LinesMeshes do not support createInstance."),null},r.prototype._bind=function(e,t,r){return this._geometry._bind(this._colorShader.getEffect()),this.useVertexColor||this._colorShader.setColor4("color",this.color.toColor4(this.alpha)),this},r.prototype._draw=function(e,t,r){return this._geometry&&this._geometry.getVertexBuffers()&&this._geometry.getIndexBuffer()?(this.getScene().getEngine().draw(!1,e.indexStart,e.indexCount),this):this},r.prototype.dispose=function(e){this._colorShader.dispose(),t.prototype.dispose.call(this,e)},r.prototype.clone=function(e,t,i){return new r(e,this.getScene(),t,this,i)},r})(e.Mesh);e.LinesMesh=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(e){function t(){var t=e.call(this)||this;return t.MAINUV1=!1,t.MAINUV2=!1,t.DIFFUSE=!1,t.DIFFUSEDIRECTUV=0,t.AMBIENT=!1,t.AMBIENTDIRECTUV=0,t.OPACITY=!1,t.OPACITYDIRECTUV=0,t.OPACITYRGB=!1,t.REFLECTION=!1,t.EMISSIVE=!1,t.EMISSIVEDIRECTUV=0,t.SPECULAR=!1,t.SPECULARDIRECTUV=0,t.BUMP=!1,t.BUMPDIRECTUV=0,t.PARALLAX=!1,t.PARALLAXOCCLUSION=!1,t.SPECULAROVERALPHA=!1,t.CLIPPLANE=!1,t.ALPHATEST=!1,t.ALPHAFROMDIFFUSE=!1,t.POINTSIZE=!1,t.FOG=!1,t.SPECULARTERM=!1,t.DIFFUSEFRESNEL=!1,t.OPACITYFRESNEL=!1,t.REFLECTIONFRESNEL=!1,t.REFRACTIONFRESNEL=!1,t.EMISSIVEFRESNEL=!1,t.FRESNEL=!1,t.NORMAL=!1,t.UV1=!1,t.UV2=!1,t.VERTEXCOLOR=!1,t.VERTEXALPHA=!1,t.NUM_BONE_INFLUENCERS=0,t.BonesPerMesh=0,t.INSTANCES=!1,t.GLOSSINESS=!1,t.ROUGHNESS=!1,t.EMISSIVEASILLUMINATION=!1,t.LINKEMISSIVEWITHDIFFUSE=!1,t.REFLECTIONFRESNELFROMSPECULAR=!1,t.LIGHTMAP=!1,t.LIGHTMAPDIRECTUV=0,t.USELIGHTMAPASSHADOWMAP=!1,t.REFLECTIONMAP_3D=!1,t.REFLECTIONMAP_SPHERICAL=!1,t.REFLECTIONMAP_PLANAR=!1,t.REFLECTIONMAP_CUBIC=!1,t.REFLECTIONMAP_PROJECTION=!1,t.REFLECTIONMAP_SKYBOX=!1,t.REFLECTIONMAP_EXPLICIT=!1,t.REFLECTIONMAP_EQUIRECTANGULAR=!1,t.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,t.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,t.INVERTCUBICMAP=!1,t.LOGARITHMICDEPTH=!1,t.REFRACTION=!1,t.REFRACTIONMAP_3D=!1,t.REFLECTIONOVERALPHA=!1,t.TWOSIDEDLIGHTING=!1,t.SHADOWFLOAT=!1,t.MORPHTARGETS=!1,t.MORPHTARGETS_NORMAL=!1,t.MORPHTARGETS_TANGENT=!1,t.NUM_MORPH_INFLUENCERS=0,t.USERIGHTHANDEDSYSTEM=!1,t.IMAGEPROCESSING=!1,t.VIGNETTE=!1,t.VIGNETTEBLENDMODEMULTIPLY=!1,t.VIGNETTEBLENDMODEOPAQUE=!1,t.TONEMAPPING=!1,t.CONTRAST=!1,t.COLORCURVES=!1,t.COLORGRADING=!1,t.SAMPLER3DGREENDEPTH=!1,t.SAMPLER3DBGRMAP=!1,t.IMAGEPROCESSINGPOSTPROCESS=!1,t.EXPOSURE=!1,t.rebuild(),t}return __extends(t,e),t.prototype.setReflectionMode=function(e){for(var t=["REFLECTIONMAP_CUBIC","REFLECTIONMAP_EXPLICIT","REFLECTIONMAP_PLANAR","REFLECTIONMAP_PROJECTION","REFLECTIONMAP_PROJECTION","REFLECTIONMAP_SKYBOX","REFLECTIONMAP_SPHERICAL","REFLECTIONMAP_EQUIRECTANGULAR","REFLECTIONMAP_EQUIRECTANGULAR_FIXED","REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED"],r=0,i=t;r<i.length;r++){var n=i[r];this[n]=n===e}},t})(e.MaterialDefines);e.StandardMaterialDefines=t;var r=(function(r){function i(t,n){var o=r.call(this,t,n)||this;return o.ambientColor=new e.Color3(0,0,0),o.diffuseColor=new e.Color3(1,1,1),o.specularColor=new e.Color3(1,1,1),o.emissiveColor=new e.Color3(0,0,0),o.specularPower=64,o._useAlphaFromDiffuseTexture=!1,o._useEmissiveAsIllumination=!1,o._linkEmissiveWithDiffuse=!1,o._useSpecularOverAlpha=!1,o._useReflectionOverAlpha=!1,o._disableLighting=!1,o._useParallax=!1,o._useParallaxOcclusion=!1,o.parallaxScaleBias=.05,o._roughness=0,o.indexOfRefraction=.98,o.invertRefractionY=!0,o._useLightmapAsShadowmap=!1,o._useReflectionFresnelFromSpecular=!1,o._useGlossinessFromSpecularMapAlpha=!1,o._maxSimultaneousLights=4,o._invertNormalMapX=!1,o._invertNormalMapY=!1,o._twoSidedLighting=!1,o._renderTargets=new e.SmartArray(16),o._worldViewProjectionMatrix=e.Matrix.Zero(),o._globalAmbientColor=new e.Color3(0,0,0),o._attachImageProcessingConfiguration(null),o.getRenderTargetTextures=function(){return o._renderTargets.reset(),i.ReflectionTextureEnabled&&o._reflectionTexture&&o._reflectionTexture.isRenderTarget&&o._renderTargets.push(o._reflectionTexture),i.RefractionTextureEnabled&&o._refractionTexture&&o._refractionTexture.isRenderTarget&&o._renderTargets.push(o._refractionTexture),o._renderTargets},o}return __extends(i,r),Object.defineProperty(i.prototype,"imageProcessingConfiguration",{get:function(){return this._imageProcessingConfiguration},set:function(e){this._attachImageProcessingConfiguration(e),this._markAllSubMeshesAsTexturesDirty()},enumerable:!0,configurable:!0}),i.prototype._attachImageProcessingConfiguration=function(e){var t=this;e!==this._imageProcessingConfiguration&&(this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),this._imageProcessingConfiguration=e||this.getScene().imageProcessingConfiguration,this._imageProcessingObserver=this._imageProcessingConfiguration.onUpdateParameters.add((function(e){t._markAllSubMeshesAsImageProcessingDirty()})))},Object.defineProperty(i.prototype,"cameraColorCurvesEnabled",{get:function(){return this.imageProcessingConfiguration.colorCurvesEnabled},set:function(e){this.imageProcessingConfiguration.colorCurvesEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"cameraColorGradingEnabled",{get:function(){return this.imageProcessingConfiguration.colorGradingEnabled},set:function(e){this.imageProcessingConfiguration.colorGradingEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"cameraToneMappingEnabled",{get:function(){return this._imageProcessingConfiguration.toneMappingEnabled},set:function(e){this._imageProcessingConfiguration.toneMappingEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"cameraExposure",{get:function(){return this._imageProcessingConfiguration.exposure},set:function(e){this._imageProcessingConfiguration.exposure=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"cameraContrast",{get:function(){return this._imageProcessingConfiguration.contrast},set:function(e){this._imageProcessingConfiguration.contrast=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"cameraColorGradingTexture",{get:function(){return this._imageProcessingConfiguration.colorGradingTexture},set:function(e){this._imageProcessingConfiguration.colorGradingTexture=e},enumerable:!0,configurable:!0}),i.prototype.getClassName=function(){return"StandardMaterial"},Object.defineProperty(i.prototype,"useLogarithmicDepth",{get:function(){return this._useLogarithmicDepth},set:function(e){this._useLogarithmicDepth=e&&this.getScene().getEngine().getCaps().fragmentDepthSupported,this._markAllSubMeshesAsMiscDirty()},enumerable:!0,configurable:!0}),i.prototype.needAlphaBlending=function(){return this.alpha<1||null!=this._opacityTexture||this._shouldUseAlphaFromDiffuseTexture()||this._opacityFresnelParameters&&this._opacityFresnelParameters.isEnabled},i.prototype.needAlphaTesting=function(){return null!=this._diffuseTexture&&this._diffuseTexture.hasAlpha},i.prototype._shouldUseAlphaFromDiffuseTexture=function(){return null!=this._diffuseTexture&&this._diffuseTexture.hasAlpha&&this._useAlphaFromDiffuseTexture},i.prototype.getAlphaTestTexture=function(){return this._diffuseTexture},i.prototype.isReadyForSubMesh=function(r,n,o){if(this.isFrozen&&this._wasPreviouslyReady&&n.effect)return!0;n._materialDefines||(n._materialDefines=new t);var s=this.getScene(),a=n._materialDefines;if(!this.checkReadyOnEveryCall&&n.effect&&a._renderId===s.getRenderId())return!0;var u=s.getEngine();if(a._needNormals=e.MaterialHelper.PrepareDefinesForLights(s,r,a,!0,this._maxSimultaneousLights,this._disableLighting),a._areTexturesDirty){if(a._needUVs=!1,a.MAINUV1=!1,a.MAINUV2=!1,s.texturesEnabled){if(this._diffuseTexture&&i.DiffuseTextureEnabled){if(!this._diffuseTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._diffuseTexture,a,"DIFFUSE")}else a.DIFFUSE=!1;if(this._ambientTexture&&i.AmbientTextureEnabled){if(!this._ambientTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._ambientTexture,a,"AMBIENT")}else a.AMBIENT=!1;if(this._opacityTexture&&i.OpacityTextureEnabled){if(!this._opacityTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._opacityTexture,a,"OPACITY"),a.OPACITYRGB=this._opacityTexture.getAlphaFromRGB}else a.OPACITY=!1;if(this._reflectionTexture&&i.ReflectionTextureEnabled){if(!this._reflectionTexture.isReadyOrNotBlocking())return!1;switch(a._needNormals=!0,a.REFLECTION=!0,a.ROUGHNESS=this._roughness>0,a.REFLECTIONOVERALPHA=this._useReflectionOverAlpha,a.INVERTCUBICMAP=this._reflectionTexture.coordinatesMode===e.Texture.INVCUBIC_MODE,a.REFLECTIONMAP_3D=this._reflectionTexture.isCube,this._reflectionTexture.coordinatesMode){case e.Texture.CUBIC_MODE:case e.Texture.INVCUBIC_MODE:a.setReflectionMode("REFLECTIONMAP_CUBIC");break;case e.Texture.EXPLICIT_MODE:a.setReflectionMode("REFLECTIONMAP_EXPLICIT");break;case e.Texture.PLANAR_MODE:a.setReflectionMode("REFLECTIONMAP_PLANAR");break;case e.Texture.PROJECTION_MODE:a.setReflectionMode("REFLECTIONMAP_PROJECTION");break;case e.Texture.SKYBOX_MODE:a.setReflectionMode("REFLECTIONMAP_SKYBOX");break;case e.Texture.SPHERICAL_MODE:a.setReflectionMode("REFLECTIONMAP_SPHERICAL");break;case e.Texture.EQUIRECTANGULAR_MODE:a.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR");break;case e.Texture.FIXED_EQUIRECTANGULAR_MODE:a.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR_FIXED");break;case e.Texture.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:a.setReflectionMode("REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED")}}else a.REFLECTION=!1;if(this._emissiveTexture&&i.EmissiveTextureEnabled){if(!this._emissiveTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._emissiveTexture,a,"EMISSIVE")}else a.EMISSIVE=!1;if(this._lightmapTexture&&i.LightmapTextureEnabled){if(!this._lightmapTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._lightmapTexture,a,"LIGHTMAP"),a.USELIGHTMAPASSHADOWMAP=this._useLightmapAsShadowmap}else a.LIGHTMAP=!1;if(this._specularTexture&&i.SpecularTextureEnabled){if(!this._specularTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._specularTexture,a,"SPECULAR"),a.GLOSSINESS=this._useGlossinessFromSpecularMapAlpha}else a.SPECULAR=!1;if(s.getEngine().getCaps().standardDerivatives&&this._bumpTexture&&i.BumpTextureEnabled){if(!this._bumpTexture.isReady())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._bumpTexture,a,"BUMP"),a.PARALLAX=this._useParallax,a.PARALLAXOCCLUSION=this._useParallaxOcclusion}else a.BUMP=!1;if(this._refractionTexture&&i.RefractionTextureEnabled){if(!this._refractionTexture.isReadyOrNotBlocking())return!1;a._needUVs=!0,a.REFRACTION=!0,a.REFRACTIONMAP_3D=this._refractionTexture.isCube}else a.REFRACTION=!1;a.TWOSIDEDLIGHTING=!this._backFaceCulling&&this._twoSidedLighting}else a.DIFFUSE=!1,a.AMBIENT=!1,a.OPACITY=!1,a.REFLECTION=!1,a.EMISSIVE=!1,a.LIGHTMAP=!1,a.BUMP=!1,a.REFRACTION=!1;a.ALPHAFROMDIFFUSE=this._shouldUseAlphaFromDiffuseTexture(),a.EMISSIVEASILLUMINATION=this._useEmissiveAsIllumination,a.LINKEMISSIVEWITHDIFFUSE=this._linkEmissiveWithDiffuse,a.SPECULAROVERALPHA=this._useSpecularOverAlpha}if(a._areImageProcessingDirty){if(!this._imageProcessingConfiguration.isReady())return!1;this._imageProcessingConfiguration.prepareDefines(a)}if(a._areFresnelDirty&&(i.FresnelEnabled?(this._diffuseFresnelParameters||this._opacityFresnelParameters||this._emissiveFresnelParameters||this._refractionFresnelParameters||this._reflectionFresnelParameters)&&(a.DIFFUSEFRESNEL=this._diffuseFresnelParameters&&this._diffuseFresnelParameters.isEnabled,a.OPACITYFRESNEL=this._opacityFresnelParameters&&this._opacityFresnelParameters.isEnabled,a.REFLECTIONFRESNEL=this._reflectionFresnelParameters&&this._reflectionFresnelParameters.isEnabled,a.REFLECTIONFRESNELFROMSPECULAR=this._useReflectionFresnelFromSpecular,a.REFRACTIONFRESNEL=this._refractionFresnelParameters&&this._refractionFresnelParameters.isEnabled,a.EMISSIVEFRESNEL=this._emissiveFresnelParameters&&this._emissiveFresnelParameters.isEnabled,a._needNormals=!0,a.FRESNEL=!0):a.FRESNEL=!1),e.MaterialHelper.PrepareDefinesForMisc(r,s,this._useLogarithmicDepth,this.pointsCloud,this.fogEnabled,a),e.MaterialHelper.PrepareDefinesForAttributes(r,a,!0,!0,!0),e.MaterialHelper.PrepareDefinesForFrameBoundValues(s,u,a,o),a.isDirty){a.markAsProcessed(),s.resetCachedMaterial();var l=new e.EffectFallbacks;a.REFLECTION&&l.addFallback(0,"REFLECTION"),a.SPECULAR&&l.addFallback(0,"SPECULAR"),a.BUMP&&l.addFallback(0,"BUMP"),a.PARALLAX&&l.addFallback(1,"PARALLAX"),a.PARALLAXOCCLUSION&&l.addFallback(0,"PARALLAXOCCLUSION"),a.SPECULAROVERALPHA&&l.addFallback(0,"SPECULAROVERALPHA"),a.FOG&&l.addFallback(1,"FOG"),a.POINTSIZE&&l.addFallback(0,"POINTSIZE"),a.LOGARITHMICDEPTH&&l.addFallback(0,"LOGARITHMICDEPTH"),e.MaterialHelper.HandleFallbacksForShadows(a,l,this._maxSimultaneousLights),a.SPECULARTERM&&l.addFallback(0,"SPECULARTERM"),a.DIFFUSEFRESNEL&&l.addFallback(1,"DIFFUSEFRESNEL"),a.OPACITYFRESNEL&&l.addFallback(2,"OPACITYFRESNEL"),a.REFLECTIONFRESNEL&&l.addFallback(3,"REFLECTIONFRESNEL"),a.EMISSIVEFRESNEL&&l.addFallback(4,"EMISSIVEFRESNEL"),a.FRESNEL&&l.addFallback(4,"FRESNEL");var h=[e.VertexBuffer.PositionKind];a.NORMAL&&h.push(e.VertexBuffer.NormalKind),a.UV1&&h.push(e.VertexBuffer.UVKind),a.UV2&&h.push(e.VertexBuffer.UV2Kind),a.VERTEXCOLOR&&h.push(e.VertexBuffer.ColorKind),e.MaterialHelper.PrepareAttributesForBones(h,r,a,l),e.MaterialHelper.PrepareAttributesForInstances(h,a),e.MaterialHelper.PrepareAttributesForMorphTargets(h,r,a);var c="default",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","diffuseLeftColor","diffuseRightColor","opacityParts","reflectionLeftColor","reflectionRightColor","emissiveLeftColor","emissiveRightColor","refractionLeftColor","refractionRightColor","logarithmicDepthConstant","vNormalReoderParams"],d=["diffuseSampler","ambientSampler","opacitySampler","reflectionCubeSampler","reflection2DSampler","emissiveSampler","specularSampler","bumpSampler","lightmapSampler","refractionCubeSampler","refraction2DSampler"],p=["Material","Scene"];e.ImageProcessingConfiguration.PrepareUniforms(f,a),e.ImageProcessingConfiguration.PrepareSamplers(d,a),e.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:f,uniformBuffersNames:p,samplers:d,defines:a,maxSimultaneousLights:this._maxSimultaneousLights}),this.customShaderNameResolve&&(c=this.customShaderNameResolve(c,f,p,d,a));var g=a.toString();n.setEffect(s.getEngine().createEffect(c,{attributes:h,uniformsNames:f,uniformBuffersNames:p,samplers:d,defines:g,fallbacks:l,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:this._maxSimultaneousLights,maxSimultaneousMorphTargets:a.NUM_MORPH_INFLUENCERS}},u),a),this.buildUniformLayout()}return!!n.effect.isReady()&&(a._renderId=s.getRenderId(),this._wasPreviouslyReady=!0,!0)},i.prototype.buildUniformLayout=function(){this._uniformBuffer.addUniform("diffuseLeftColor",4),this._uniformBuffer.addUniform("diffuseRightColor",4),this._uniformBuffer.addUniform("opacityParts",4),this._uniformBuffer.addUniform("reflectionLeftColor",4),this._uniformBuffer.addUniform("reflectionRightColor",4),this._uniformBuffer.addUniform("refractionLeftColor",4),this._uniformBuffer.addUniform("refractionRightColor",4),this._uniformBuffer.addUniform("emissiveLeftColor",4),this._uniformBuffer.addUniform("emissiveRightColor",4),this._uniformBuffer.addUniform("vDiffuseInfos",2),this._uniformBuffer.addUniform("vAmbientInfos",2),this._uniformBuffer.addUniform("vOpacityInfos",2),this._uniformBuffer.addUniform("vReflectionInfos",2),this._uniformBuffer.addUniform("vEmissiveInfos",2),this._uniformBuffer.addUniform("vLightmapInfos",2),this._uniformBuffer.addUniform("vSpecularInfos",2),this._uniformBuffer.addUniform("vBumpInfos",3),this._uniformBuffer.addUniform("diffuseMatrix",16),this._uniformBuffer.addUniform("ambientMatrix",16),this._uniformBuffer.addUniform("opacityMatrix",16),this._uniformBuffer.addUniform("reflectionMatrix",16),this._uniformBuffer.addUniform("emissiveMatrix",16),this._uniformBuffer.addUniform("lightmapMatrix",16),this._uniformBuffer.addUniform("specularMatrix",16),this._uniformBuffer.addUniform("bumpMatrix",16),this._uniformBuffer.addUniform("vNormalReoderParams",4),this._uniformBuffer.addUniform("refractionMatrix",16),this._uniformBuffer.addUniform("vRefractionInfos",4),this._uniformBuffer.addUniform("vSpecularColor",4),this._uniformBuffer.addUniform("vEmissiveColor",3),this._uniformBuffer.addUniform("vDiffuseColor",4),this._uniformBuffer.addUniform("pointSize",1),this._uniformBuffer.create()},i.prototype.unbind=function(){this._activeEffect&&(this._reflectionTexture&&this._reflectionTexture.isRenderTarget&&this._activeEffect.setTexture("reflection2DSampler",null),this._refractionTexture&&this._refractionTexture.isRenderTarget&&this._activeEffect.setTexture("refraction2DSampler",null)),r.prototype.unbind.call(this)},i.prototype.bindForSubMesh=function(t,r,n){var o=this.getScene(),s=n._materialDefines;if(s){var a=n.effect;this._activeEffect=a,this.bindOnlyWorldMatrix(t);var u=this._mustRebind(o,a,r.visibility);if(e.MaterialHelper.BindBonesParameters(r,a),u){if(this._uniformBuffer.bindToEffect(a,"Material"),this.bindViewProjection(a),!this._uniformBuffer.useUbo||!this.isFrozen||!this._uniformBuffer.isSync){if(i.FresnelEnabled&&s.FRESNEL&&(this.diffuseFresnelParameters&&this.diffuseFresnelParameters.isEnabled&&(this._uniformBuffer.updateColor4("diffuseLeftColor",this.diffuseFresnelParameters.leftColor,this.diffuseFresnelParameters.power),this._uniformBuffer.updateColor4("diffuseRightColor",this.diffuseFresnelParameters.rightColor,this.diffuseFresnelParameters.bias)),this.opacityFresnelParameters&&this.opacityFresnelParameters.isEnabled&&this._uniformBuffer.updateColor4("opacityParts",new e.Color3(this.opacityFresnelParameters.leftColor.toLuminance(),this.opacityFresnelParameters.rightColor.toLuminance(),this.opacityFresnelParameters.bias),this.opacityFresnelParameters.power),this.reflectionFresnelParameters&&this.reflectionFresnelParameters.isEnabled&&(this._uniformBuffer.updateColor4("reflectionLeftColor",this.reflectionFresnelParameters.leftColor,this.reflectionFresnelParameters.power),this._uniformBuffer.updateColor4("reflectionRightColor",this.reflectionFresnelParameters.rightColor,this.reflectionFresnelParameters.bias)),this.refractionFresnelParameters&&this.refractionFresnelParameters.isEnabled&&(this._uniformBuffer.updateColor4("refractionLeftColor",this.refractionFresnelParameters.leftColor,this.refractionFresnelParameters.power),this._uniformBuffer.updateColor4("refractionRightColor",this.refractionFresnelParameters.rightColor,this.refractionFresnelParameters.bias)),this.emissiveFresnelParameters&&this.emissiveFresnelParameters.isEnabled&&(this._uniformBuffer.updateColor4("emissiveLeftColor",this.emissiveFresnelParameters.leftColor,this.emissiveFresnelParameters.power),this._uniformBuffer.updateColor4("emissiveRightColor",this.emissiveFresnelParameters.rightColor,this.emissiveFresnelParameters.bias))),o.texturesEnabled&&(this._diffuseTexture&&i.DiffuseTextureEnabled&&(this._uniformBuffer.updateFloat2("vDiffuseInfos",this._diffuseTexture.coordinatesIndex,this._diffuseTexture.level),e.MaterialHelper.BindTextureMatrix(this._diffuseTexture,this._uniformBuffer,"diffuse")),this._ambientTexture&&i.AmbientTextureEnabled&&(this._uniformBuffer.updateFloat2("vAmbientInfos",this._ambientTexture.coordinatesIndex,this._ambientTexture.level),e.MaterialHelper.BindTextureMatrix(this._ambientTexture,this._uniformBuffer,"ambient")),this._opacityTexture&&i.OpacityTextureEnabled&&(this._uniformBuffer.updateFloat2("vOpacityInfos",this._opacityTexture.coordinatesIndex,this._opacityTexture.level),e.MaterialHelper.BindTextureMatrix(this._opacityTexture,this._uniformBuffer,"opacity")),this._reflectionTexture&&i.ReflectionTextureEnabled&&(this._uniformBuffer.updateFloat2("vReflectionInfos",this._reflectionTexture.level,this.roughness),this._uniformBuffer.updateMatrix("reflectionMatrix",this._reflectionTexture.getReflectionTextureMatrix())),this._emissiveTexture&&i.EmissiveTextureEnabled&&(this._uniformBuffer.updateFloat2("vEmissiveInfos",this._emissiveTexture.coordinatesIndex,this._emissiveTexture.level),e.MaterialHelper.BindTextureMatrix(this._emissiveTexture,this._uniformBuffer,"emissive")),this._lightmapTexture&&i.LightmapTextureEnabled&&(this._uniformBuffer.updateFloat2("vLightmapInfos",this._lightmapTexture.coordinatesIndex,this._lightmapTexture.level),e.MaterialHelper.BindTextureMatrix(this._lightmapTexture,this._uniformBuffer,"lightmap")),this._specularTexture&&i.SpecularTextureEnabled&&(this._uniformBuffer.updateFloat2("vSpecularInfos",this._specularTexture.coordinatesIndex,this._specularTexture.level),e.MaterialHelper.BindTextureMatrix(this._specularTexture,this._uniformBuffer,"specular")),this._bumpTexture&&o.getEngine().getCaps().standardDerivatives&&i.BumpTextureEnabled&&(this._uniformBuffer.updateFloat3("vBumpInfos",this._bumpTexture.coordinatesIndex,1/this._bumpTexture.level,this.parallaxScaleBias),e.MaterialHelper.BindTextureMatrix(this._bumpTexture,this._uniformBuffer,"bump"),o._mirroredCameraPosition?this._uniformBuffer.updateFloat4("vNormalReoderParams",this.invertNormalMapX?0:1,this.invertNormalMapX?1:-1,this.invertNormalMapY?0:1,this.invertNormalMapY?1:-1):this._uniformBuffer.updateFloat4("vNormalReoderParams",this.invertNormalMapX?1:0,this.invertNormalMapX?-1:1,this.invertNormalMapY?1:0,this.invertNormalMapY?-1:1)),this._refractionTexture&&i.RefractionTextureEnabled)){var l=1;this._refractionTexture.isCube||(this._uniformBuffer.updateMatrix("refractionMatrix",this._refractionTexture.getReflectionTextureMatrix()),this._refractionTexture.depth&&(l=this._refractionTexture.depth)),this._uniformBuffer.updateFloat4("vRefractionInfos",this._refractionTexture.level,this.indexOfRefraction,l,this.invertRefractionY?-1:1)}this.pointsCloud&&this._uniformBuffer.updateFloat("pointSize",this.pointSize),s.SPECULARTERM&&this._uniformBuffer.updateColor4("vSpecularColor",this.specularColor,this.specularPower),this._uniformBuffer.updateColor3("vEmissiveColor",this.emissiveColor),this._uniformBuffer.updateColor4("vDiffuseColor",this.diffuseColor,this.alpha*r.visibility)}if(o.texturesEnabled&&(this._diffuseTexture&&i.DiffuseTextureEnabled&&a.setTexture("diffuseSampler",this._diffuseTexture),this._ambientTexture&&i.AmbientTextureEnabled&&a.setTexture("ambientSampler",this._ambientTexture),this._opacityTexture&&i.OpacityTextureEnabled&&a.setTexture("opacitySampler",this._opacityTexture),this._reflectionTexture&&i.ReflectionTextureEnabled&&(this._reflectionTexture.isCube?a.setTexture("reflectionCubeSampler",this._reflectionTexture):a.setTexture("reflection2DSampler",this._reflectionTexture)),this._emissiveTexture&&i.EmissiveTextureEnabled&&a.setTexture("emissiveSampler",this._emissiveTexture),this._lightmapTexture&&i.LightmapTextureEnabled&&a.setTexture("lightmapSampler",this._lightmapTexture),this._specularTexture&&i.SpecularTextureEnabled&&a.setTexture("specularSampler",this._specularTexture),this._bumpTexture&&o.getEngine().getCaps().standardDerivatives&&i.BumpTextureEnabled&&a.setTexture("bumpSampler",this._bumpTexture),this._refractionTexture&&i.RefractionTextureEnabled)){var l=1;this._refractionTexture.isCube?a.setTexture("refractionCubeSampler",this._refractionTexture):a.setTexture("refraction2DSampler",this._refractionTexture)}e.MaterialHelper.BindClipPlane(a,o),o.ambientColor.multiplyToRef(this.ambientColor,this._globalAmbientColor),a.setVector3("vEyePosition",o._mirroredCameraPosition?o._mirroredCameraPosition:o.activeCamera.globalPosition),a.setColor3("vAmbientColor",this._globalAmbientColor)}!u&&this.isFrozen||(o.lightsEnabled&&!this._disableLighting&&e.MaterialHelper.BindLights(o,r,a,s,this._maxSimultaneousLights),(o.fogEnabled&&r.applyFog&&o.fogMode!==e.Scene.FOGMODE_NONE||this._reflectionTexture||this._refractionTexture)&&this.bindView(a),e.MaterialHelper.BindFogParameters(o,r,a),s.NUM_MORPH_INFLUENCERS&&e.MaterialHelper.BindMorphTargetParameters(r,a),e.MaterialHelper.BindLogDepth(s,a,o),this._imageProcessingConfiguration.bind(this._activeEffect)),this._uniformBuffer.update(),this._afterBind(r,this._activeEffect)}},i.prototype.getAnimatables=function(){var e=[];return this._diffuseTexture&&this._diffuseTexture.animations&&this._diffuseTexture.animations.length>0&&e.push(this._diffuseTexture),this._ambientTexture&&this._ambientTexture.animations&&this._ambientTexture.animations.length>0&&e.push(this._ambientTexture),this._opacityTexture&&this._opacityTexture.animations&&this._opacityTexture.animations.length>0&&e.push(this._opacityTexture),this._reflectionTexture&&this._reflectionTexture.animations&&this._reflectionTexture.animations.length>0&&e.push(this._reflectionTexture),this._emissiveTexture&&this._emissiveTexture.animations&&this._emissiveTexture.animations.length>0&&e.push(this._emissiveTexture),this._specularTexture&&this._specularTexture.animations&&this._specularTexture.animations.length>0&&e.push(this._specularTexture),this._bumpTexture&&this._bumpTexture.animations&&this._bumpTexture.animations.length>0&&e.push(this._bumpTexture),this._lightmapTexture&&this._lightmapTexture.animations&&this._lightmapTexture.animations.length>0&&e.push(this._lightmapTexture),this._refractionTexture&&this._refractionTexture.animations&&this._refractionTexture.animations.length>0&&e.push(this._refractionTexture),e},i.prototype.getActiveTextures=function(){var e=r.prototype.getActiveTextures.call(this)
- ;return this._diffuseTexture&&e.push(this._diffuseTexture),this._ambientTexture&&e.push(this._ambientTexture),this._opacityTexture&&e.push(this._opacityTexture),this._reflectionTexture&&e.push(this._reflectionTexture),this._emissiveTexture&&e.push(this._emissiveTexture),this._specularTexture&&e.push(this._specularTexture),this._bumpTexture&&e.push(this._bumpTexture),this._lightmapTexture&&e.push(this._lightmapTexture),this._refractionTexture&&e.push(this._refractionTexture),e},i.prototype.hasTexture=function(e){return!!r.prototype.hasTexture.call(this,e)||(this._diffuseTexture===e||(this._ambientTexture===e||(this._opacityTexture===e||(this._reflectionTexture===e||(this._emissiveTexture===e||(this._specularTexture===e||(this._bumpTexture===e||(this._lightmapTexture===e||this._refractionTexture===e))))))))},i.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._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),r.prototype.dispose.call(this,e,t)},i.prototype.clone=function(t){var r=this,n=e.SerializationHelper.Clone((function(){return new i(t,r.getScene())}),this);return n.name=t,n.id=t,n},i.prototype.serialize=function(){return e.SerializationHelper.Serialize(this)},i.Parse=function(t,r,n){return e.SerializationHelper.Parse((function(){return new i(t.name,r)}),t,r,n)},Object.defineProperty(i,"DiffuseTextureEnabled",{get:function(){return i._DiffuseTextureEnabled},set:function(t){i._DiffuseTextureEnabled!==t&&(i._DiffuseTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(i,"AmbientTextureEnabled",{get:function(){return i._AmbientTextureEnabled},set:function(t){i._AmbientTextureEnabled!==t&&(i._AmbientTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(i,"OpacityTextureEnabled",{get:function(){return i._OpacityTextureEnabled},set:function(t){i._OpacityTextureEnabled!==t&&(i._OpacityTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(i,"ReflectionTextureEnabled",{get:function(){return i._ReflectionTextureEnabled},set:function(t){i._ReflectionTextureEnabled!==t&&(i._ReflectionTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(i,"EmissiveTextureEnabled",{get:function(){return i._EmissiveTextureEnabled},set:function(t){i._EmissiveTextureEnabled!==t&&(i._EmissiveTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(i,"SpecularTextureEnabled",{get:function(){return i._SpecularTextureEnabled},set:function(t){i._SpecularTextureEnabled!==t&&(i._SpecularTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(i,"BumpTextureEnabled",{get:function(){return i._BumpTextureEnabled},set:function(t){i._BumpTextureEnabled!==t&&(i._BumpTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(i,"LightmapTextureEnabled",{get:function(){return i._LightmapTextureEnabled},set:function(t){i._LightmapTextureEnabled!==t&&(i._LightmapTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(i,"RefractionTextureEnabled",{get:function(){return i._RefractionTextureEnabled},set:function(t){i._RefractionTextureEnabled!==t&&(i._RefractionTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(i,"ColorGradingTextureEnabled",{get:function(){return i._ColorGradingTextureEnabled},set:function(t){i._ColorGradingTextureEnabled!==t&&(i._ColorGradingTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(i,"FresnelEnabled",{get:function(){return i._FresnelEnabled},set:function(t){i._FresnelEnabled!==t&&(i._FresnelEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.FresnelDirtyFlag))},enumerable:!0,configurable:!0}),i._DiffuseTextureEnabled=!0,i._AmbientTextureEnabled=!0,i._OpacityTextureEnabled=!0,i._ReflectionTextureEnabled=!0,i._EmissiveTextureEnabled=!0,i._SpecularTextureEnabled=!0,i._BumpTextureEnabled=!0,i._LightmapTextureEnabled=!0,i._RefractionTextureEnabled=!0,i._ColorGradingTextureEnabled=!0,i._FresnelEnabled=!0,__decorate([e.serializeAsTexture("diffuseTexture")],i.prototype,"_diffuseTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"diffuseTexture",void 0),__decorate([e.serializeAsTexture("ambientTexture")],i.prototype,"_ambientTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"ambientTexture",void 0),__decorate([e.serializeAsTexture("opacityTexture")],i.prototype,"_opacityTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"opacityTexture",void 0),__decorate([e.serializeAsTexture("reflectionTexture")],i.prototype,"_reflectionTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"reflectionTexture",void 0),__decorate([e.serializeAsTexture("emissiveTexture")],i.prototype,"_emissiveTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"emissiveTexture",void 0),__decorate([e.serializeAsTexture("specularTexture")],i.prototype,"_specularTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"specularTexture",void 0),__decorate([e.serializeAsTexture("bumpTexture")],i.prototype,"_bumpTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"bumpTexture",void 0),__decorate([e.serializeAsTexture("lightmapTexture")],i.prototype,"_lightmapTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"lightmapTexture",void 0),__decorate([e.serializeAsTexture("refractionTexture")],i.prototype,"_refractionTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],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("useAlphaFromDiffuseTexture")],i.prototype,"_useAlphaFromDiffuseTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useAlphaFromDiffuseTexture",void 0),__decorate([e.serialize("useEmissiveAsIllumination")],i.prototype,"_useEmissiveAsIllumination",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useEmissiveAsIllumination",void 0),__decorate([e.serialize("linkEmissiveWithDiffuse")],i.prototype,"_linkEmissiveWithDiffuse",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"linkEmissiveWithDiffuse",void 0),__decorate([e.serialize("useSpecularOverAlpha")],i.prototype,"_useSpecularOverAlpha",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useSpecularOverAlpha",void 0),__decorate([e.serialize("useReflectionOverAlpha")],i.prototype,"_useReflectionOverAlpha",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useReflectionOverAlpha",void 0),__decorate([e.serialize("disableLighting")],i.prototype,"_disableLighting",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsLightsDirty")],i.prototype,"disableLighting",void 0),__decorate([e.serialize("useParallax")],i.prototype,"_useParallax",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useParallax",void 0),__decorate([e.serialize("useParallaxOcclusion")],i.prototype,"_useParallaxOcclusion",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useParallaxOcclusion",void 0),__decorate([e.serialize()],i.prototype,"parallaxScaleBias",void 0),__decorate([e.serialize("roughness")],i.prototype,"_roughness",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"roughness",void 0),__decorate([e.serialize()],i.prototype,"indexOfRefraction",void 0),__decorate([e.serialize()],i.prototype,"invertRefractionY",void 0),__decorate([e.serialize("useLightmapAsShadowmap")],i.prototype,"_useLightmapAsShadowmap",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useLightmapAsShadowmap",void 0),__decorate([e.serializeAsFresnelParameters("diffuseFresnelParameters")],i.prototype,"_diffuseFresnelParameters",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsFresnelDirty")],i.prototype,"diffuseFresnelParameters",void 0),__decorate([e.serializeAsFresnelParameters("opacityFresnelParameters")],i.prototype,"_opacityFresnelParameters",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsFresnelDirty")],i.prototype,"opacityFresnelParameters",void 0),__decorate([e.serializeAsFresnelParameters("reflectionFresnelParameters")],i.prototype,"_reflectionFresnelParameters",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsFresnelDirty")],i.prototype,"reflectionFresnelParameters",void 0),__decorate([e.serializeAsFresnelParameters("refractionFresnelParameters")],i.prototype,"_refractionFresnelParameters",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsFresnelDirty")],i.prototype,"refractionFresnelParameters",void 0),__decorate([e.serializeAsFresnelParameters("emissiveFresnelParameters")],i.prototype,"_emissiveFresnelParameters",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsFresnelDirty")],i.prototype,"emissiveFresnelParameters",void 0),__decorate([e.serialize("useReflectionFresnelFromSpecular")],i.prototype,"_useReflectionFresnelFromSpecular",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsFresnelDirty")],i.prototype,"useReflectionFresnelFromSpecular",void 0),__decorate([e.serialize("useGlossinessFromSpecularMapAlpha")],i.prototype,"_useGlossinessFromSpecularMapAlpha",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useGlossinessFromSpecularMapAlpha",void 0),__decorate([e.serialize("maxSimultaneousLights")],i.prototype,"_maxSimultaneousLights",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsLightsDirty")],i.prototype,"maxSimultaneousLights",void 0),__decorate([e.serialize("invertNormalMapX")],i.prototype,"_invertNormalMapX",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"invertNormalMapX",void 0),__decorate([e.serialize("invertNormalMapY")],i.prototype,"_invertNormalMapY",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"invertNormalMapY",void 0),__decorate([e.serialize("twoSidedLighting")],i.prototype,"_twoSidedLighting",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"twoSidedLighting",void 0),__decorate([e.serialize()],i.prototype,"useLogarithmicDepth",null),i})(e.PushMaterial);e.StandardMaterial=r})(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,r){return t.add(e,r)}))},e.prototype.get=function(e){var t=this._data[e];if(void 0!==t)return t},e.prototype.getOrAddWithFactory=function(e,t){var r=this.get(e);return void 0!==r?r:(r=t(e),r&&this.add(e,r),r)},e.prototype.getOrAdd=function(e,t){var r=this.get(e);return void 0!==r?r:(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){e(t,this._data[t])}},e.prototype.first=function(e){for(var t in this._data){var r=this._data[t],i=e(t,r);if(i)return i}return null},e})();e.StringDictionary=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(){}return e})();e.DynamicFloatArrayElementInfo=t;var r=(function(){function e(e,r){this.compareValueOffset=null,this.sortingAscending=!0,this._stride=e,this.buffer=new Float32Array(e*r),this._lastUsed=0,this._firstFree=0,this._allEntries=new Array(r),this._freeEntries=new Array(r);for(var i=0;i<r;i++){var n=new t;n.offset=i*e,this._allEntries[i]=n,this._freeEntries[r-i-1]=n}}return e.prototype.allocElement=function(){0===this._freeEntries.length&&this._growBuffer();var e=this._freeEntries.pop();return this._lastUsed=Math.max(e.offset,this._lastUsed),e.offset===this._firstFree&&(this._freeEntries.length>0?this._firstFree=this._freeEntries[this._freeEntries.length-1].offset:this._firstFree+=this._stride),e},e.prototype.freeElement=function(e){this._firstFree=Math.min(e.offset,this._firstFree),this._freeEntries.push(e)},e.prototype.pack=function(){if(0===this._freeEntries.length)return this.buffer;if(this._lastUsed<this._firstFree){return this.buffer.subarray(0,this._lastUsed+this._stride)}var e=this._stride,r=new t;r.offset=this.totalElementCount*e,this._freeEntries.push(r);for(var i=this._freeEntries.sort((function(e,t){return e.offset-t.offset})),n=this._allEntries.sort((function(e,t){return e.offset-t.offset})),o=i[0].offset,s=1,a=(this.usedElementCount+1)*e,u=i[0].offset,l=1;l<i.length&&!(o>=a);l++){var h=i[l],c=h.offset,f=c-u;if(f!==e){for(var d=f/e-1,p=c-e,g=Math.min(s,d),_=0;_<g;_++){var m=o/e,v=p/e,y=n[v];this._moveElement(y,o);var A=n[m];A.offset=p,n[m]=y,n[v]=A,p-=e,o+=e}s<=d?(o=p+e,s=1+g):s=(c-o)/e+1,u=c}else++s,u=c}var T=this.buffer.subarray(0,o);return this._lastUsed=o-e,this._firstFree=o,i.pop(),this._freeEntries=i.sort((function(e,t){return t.offset-e.offset})),this._allEntries=n,T},e.prototype._moveElement=function(e,t){for(var r=0;r<this._stride;r++)this.buffer[t+r]=this.buffer[e.offset+r];e.offset=t},e.prototype._growBuffer=function(){var e=Math.floor(1.5*this.totalElementCount),r=new Float32Array(e*this._stride);r.set(this.buffer);for(var i=this.totalElementCount,n=e-this.totalElementCount,o=0;o<n;o++){var s=new t;s.offset=(i+o)*this.stride,this._allEntries.push(s),this._freeEntries[n-o-1]=s}this._firstFree=i*this.stride,this.buffer=r},Object.defineProperty(e.prototype,"totalElementCount",{get:function(){return this._allEntries.length},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"freeElementCount",{get:function(){return this._freeEntries.length},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"usedElementCount",{get:function(){return this._allEntries.length-this._freeEntries.length},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"stride",{get:function(){return this._stride},enumerable:!0,configurable:!0}),e.prototype.sort=function(){var e=this;if(!this.compareValueOffset)throw new Error("The DynamicFloatArray.sort() method needs a valid 'compareValueOffset' property");var t=this.usedElementCount;if(!this._sortTable||this._sortTable.length<t){var r=Math.min(this.totalElementCount,2*t);this._sortTable=new Array(r)}this._sortedTable&&this._sortedTable.length===t||(this._sortedTable=new Array(t)),this.pack();for(var n=0,o=this.stride,s=0;s<t;s++,n+=o){var a=this._sortTable[s];a||(a=new i,this._sortTable[s]=a),a.compareData=this.buffer[n+this.compareValueOffset],a.offset=n,a.swapedOffset=null,this._sortedTable[s]=a}this.sortingAscending?this._sortedTable.sort((function(e,t){return e.compareData-t.compareData})):this._sortedTable.sort((function(e,t){return t.compareData-e.compareData}));for(var s=0;s<t;s++){var u=this._sortedTable[s],l=this._sortTable[s],h=u.offset;if(u.swapedOffset){for(var c=u;c.swapedOffset;)c=this._sortTable[c.swapedOffset/o];h=c.offset}l.swapedOffset=h,h!==l.offset&&(function(t,r){for(var i=0;i<o;i++){var n=e.buffer[r+i];e.buffer[r+i]=e.buffer[t+i],e.buffer[t+i]=n}})(h,l.offset),this._allEntries[u.offset/o].offset=l.offset}return this._allEntries.sort((function(e,t){return e.offset-t.offset})),!0},e})();e.DynamicFloatArray=r;var i=(function(){function e(){this.compareData=this.offset=this.swapedOffset=null}return e})()})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(e){this._actionManager=e}return e.prototype.isValid=function(){return!0},e.prototype._getProperty=function(e){return this._actionManager._getProperty(e)},e.prototype._getEffectiveTarget=function(e,t){return this._actionManager._getEffectiveTarget(e,t)},e.prototype.serialize=function(){},e.prototype._serialize=function(e){return{type:2,children:[],name:e.name,properties:e.properties}},e})();e.Condition=t;var r=(function(t){function r(e,i,n,o,s){void 0===s&&(s=r.IsEqual);var a=t.call(this,e)||this;return a.propertyPath=n,a.value=o,a.operator=s,a._target=i,a._effectiveTarget=a._getEffectiveTarget(i,a.propertyPath),a._property=a._getProperty(a.propertyPath),a}return __extends(r,t),Object.defineProperty(r,"IsEqual",{get:function(){return r._IsEqual},enumerable:!0,configurable:!0}),Object.defineProperty(r,"IsDifferent",{get:function(){return r._IsDifferent},enumerable:!0,configurable:!0}),Object.defineProperty(r,"IsGreater",{get:function(){return r._IsGreater},enumerable:!0,configurable:!0}),Object.defineProperty(r,"IsLesser",{get:function(){return r._IsLesser},enumerable:!0,configurable:!0}),r.prototype.isValid=function(){switch(this.operator){case r.IsGreater:return this._effectiveTarget[this._property]>this.value;case r.IsLesser:return this._effectiveTarget[this._property]<this.value;case r.IsEqual:case r.IsDifferent:var e;return e=this.value.equals?this.value.equals(this._effectiveTarget[this._property]):this.value===this._effectiveTarget[this._property],this.operator===r.IsEqual?e:!e}return!1},r.prototype.serialize=function(){return this._serialize({name:"ValueCondition",properties:[e.Action._GetTargetProperty(this._target),{name:"propertyPath",value:this.propertyPath},{name:"value",value:e.Action._SerializeValueAsString(this.value)},{name:"operator",value:r.GetOperatorName(this.operator)}]})},r.GetOperatorName=function(e){switch(e){case r._IsEqual:return"IsEqual";case r._IsDifferent:return"IsDifferent";case r._IsGreater:return"IsGreater";case r._IsLesser:return"IsLesser";default:return""}},r._IsEqual=0,r._IsDifferent=1,r._IsGreater=2,r._IsLesser=3,r})(t);e.ValueCondition=r;var i=(function(e){function t(t,r){var i=e.call(this,t)||this;return i.predicate=r,i}return __extends(t,e),t.prototype.isValid=function(){return this.predicate()},t})(t);e.PredicateCondition=i;var n=(function(t){function r(e,r,i){var n=t.call(this,e)||this;return n.value=i,n._target=r,n}return __extends(r,t),r.prototype.isValid=function(){return this._target.state===this.value},r.prototype.serialize=function(){return this._serialize({name:"StateCondition",properties:[e.Action._GetTargetProperty(this._target),{name:"value",value:this.value}]})},r})(t);e.StateCondition=n})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(e,t){this.triggerOptions=e,e.parameter?(this.trigger=e.trigger,this._triggerParameter=e.parameter):this.trigger=e,this._nextActiveAction=this,this._condition=t}return t.prototype._prepare=function(){},t.prototype.getTriggerParameter=function(){return this._triggerParameter},t.prototype._executeCurrent=function(e){if(this._nextActiveAction._condition){var t=this._nextActiveAction._condition,r=this._actionManager.getScene().getRenderId();if(t._evaluationId===r){if(!t._currentResult)return}else{if(t._evaluationId=r,!t.isValid())return void(t._currentResult=!1);t._currentResult=!0}}this._nextActiveAction.execute(e),this.skipToNextActiveAction()},t.prototype.execute=function(e){},t.prototype.skipToNextActiveAction=function(){this._nextActiveAction._child?(this._nextActiveAction._child._actionManager||(this._nextActiveAction._child._actionManager=this._actionManager),this._nextActiveAction=this._nextActiveAction._child):this._nextActiveAction=this},t.prototype.then=function(e){return this._child=e,e._actionManager=this._actionManager,e._prepare(),e},t.prototype._getProperty=function(e){return this._actionManager._getProperty(e)},t.prototype._getEffectiveTarget=function(e,t){return this._actionManager._getEffectiveTarget(e,t)},t.prototype.serialize=function(e){},t.prototype._serialize=function(e,t){var r={type:1,children:[],name:e.name,properties:e.properties||[]};if(this._child&&this._child.serialize(r),this._condition){var i=this._condition.serialize();return i.children.push(r),t&&t.children.push(i),i}return t&&t.children.push(r),r},t._SerializeValueAsString=function(t){return"number"==typeof t?t.toString():"boolean"==typeof t?t?"true":"false":t instanceof e.Vector2?t.x+", "+t.y:t instanceof e.Vector3?t.x+", "+t.y+", "+t.z:t instanceof e.Color3?t.r+", "+t.g+", "+t.b:t instanceof e.Color4?t.r+", "+t.g+", "+t.b+", "+t.a:t},t._GetTargetProperty=function(t){return{name:"target",targetType:t instanceof e.Mesh?"MeshProperties":t instanceof e.Light?"LightProperties":t instanceof e.Camera?"CameraProperties":"SceneProperties",value:t instanceof e.Scene?"Scene":t.name}},t})();e.Action=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(e,t,r,i,n,o){this.source=e,this.pointerX=t,this.pointerY=r,this.meshUnderPointer=i,this.sourceEvent=n,this.additionalData=o}return e.CreateNew=function(t,r,i){var n=t.getScene();return new e(t,n.pointerX,n.pointerY,n.meshUnderPointer,r,i)},e.CreateNewFromSprite=function(t,r,i,n){return new e(t,r.pointerX,r.pointerY,r.meshUnderPointer,i,n)},e.CreateNewFromScene=function(t,r){return new e(null,t.pointerX,t.pointerY,t.meshUnderPointer,r)},e.CreateNewFromPrimitive=function(t,r,i,n){return new e(t,r.x,r.y,null,i,n)},e})();e.ActionEvent=t;var r=(function(){function t(e){this.actions=new Array,this.hoverCursor="",this._scene=e,e._actionManagers.push(this)}return Object.defineProperty(t,"NothingTrigger",{get:function(){return t._NothingTrigger},enumerable:!0,configurable:!0}),Object.defineProperty(t,"OnPickTrigger",{get:function(){return t._OnPickTrigger},enumerable:!0,configurable:!0}),Object.defineProperty(t,"OnLeftPickTrigger",{get:function(){return t._OnLeftPickTrigger},enumerable:!0,configurable:!0}),Object.defineProperty(t,"OnRightPickTrigger",{get:function(){return t._OnRightPickTrigger},enumerable:!0,configurable:!0}),Object.defineProperty(t,"OnCenterPickTrigger",{get:function(){return t._OnCenterPickTrigger},enumerable:!0,configurable:!0}),Object.defineProperty(t,"OnPickDownTrigger",{get:function(){return t._OnPickDownTrigger},enumerable:!0,configurable:!0}),Object.defineProperty(t,"OnDoublePickTrigger",{get:function(){return t._OnDoublePickTrigger},enumerable:!0,configurable:!0}),Object.defineProperty(t,"OnPickUpTrigger",{get:function(){return t._OnPickUpTrigger},enumerable:!0,configurable:!0}),Object.defineProperty(t,"OnPickOutTrigger",{get:function(){return t._OnPickOutTrigger},enumerable:!0,configurable:!0}),Object.defineProperty(t,"OnLongPressTrigger",{get:function(){return t._OnLongPressTrigger},enumerable:!0,configurable:!0}),Object.defineProperty(t,"OnPointerOverTrigger",{get:function(){return t._OnPointerOverTrigger},enumerable:!0,configurable:!0}),Object.defineProperty(t,"OnPointerOutTrigger",{get:function(){return t._OnPointerOutTrigger},enumerable:!0,configurable:!0}),Object.defineProperty(t,"OnEveryFrameTrigger",{get:function(){return t._OnEveryFrameTrigger},enumerable:!0,configurable:!0}),Object.defineProperty(t,"OnIntersectionEnterTrigger",{get:function(){return t._OnIntersectionEnterTrigger},enumerable:!0,configurable:!0}),Object.defineProperty(t,"OnIntersectionExitTrigger",{get:function(){return t._OnIntersectionExitTrigger},enumerable:!0,configurable:!0}),Object.defineProperty(t,"OnKeyDownTrigger",{get:function(){return t._OnKeyDownTrigger},enumerable:!0,configurable:!0}),Object.defineProperty(t,"OnKeyUpTrigger",{get:function(){return t._OnKeyUpTrigger},enumerable:!0,configurable:!0}),t.prototype.dispose=function(){for(var e=this._scene._actionManagers.indexOf(this),r=0;r<this.actions.length;r++){var i=this.actions[r];t.Triggers[i.trigger]--,0===t.Triggers[i.trigger]&&delete t.Triggers[i.trigger]}e>-1&&this._scene._actionManagers.splice(e,1)},t.prototype.getScene=function(){return this._scene},t.prototype.hasSpecificTriggers=function(e){for(var t=0;t<this.actions.length;t++){var r=this.actions[t];if(e.indexOf(r.trigger)>-1)return!0}return!1},t.prototype.hasSpecificTrigger=function(e){for(var t=0;t<this.actions.length;t++){if(this.actions[t].trigger===e)return!0}return!1},Object.defineProperty(t.prototype,"hasPointerTriggers",{get:function(){for(var e=0;e<this.actions.length;e++){var r=this.actions[e];if(r.trigger>=t._OnPickTrigger&&r.trigger<=t._OnPointerOutTrigger)return!0}return!1},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"hasPickTriggers",{get:function(){for(var e=0;e<this.actions.length;e++){var r=this.actions[e];if(r.trigger>=t._OnPickTrigger&&r.trigger<=t._OnPickUpTrigger)return!0}return!1},enumerable:!0,configurable:!0}),Object.defineProperty(t,"HasTriggers",{get:function(){for(var e in t.Triggers)if(t.Triggers.hasOwnProperty(e))return!0;return!1},enumerable:!0,configurable:!0}),Object.defineProperty(t,"HasPickTriggers",{get:function(){for(var e in t.Triggers)if(t.Triggers.hasOwnProperty(e)){var r=parseInt(e);if(r>=t._OnPickTrigger&&r<=t._OnPickUpTrigger)return!0}return!1},enumerable:!0,configurable:!0}),t.HasSpecificTrigger=function(e){for(var r in t.Triggers)if(t.Triggers.hasOwnProperty(r)){var i=parseInt(r);if(i===e)return!0}return!1},t.prototype.registerAction=function(r){return r.trigger===t.OnEveryFrameTrigger&&this.getScene().actionManager!==this?(e.Tools.Warn("OnEveryFrameTrigger can only be used with scene.actionManager"),null):(this.actions.push(r),t.Triggers[r.trigger]?t.Triggers[r.trigger]++:t.Triggers[r.trigger]=1,r._actionManager=this,r._prepare(),r)},t.prototype.processTrigger=function(e,r){for(var i=0;i<this.actions.length;i++){var n=this.actions[i];if(n.trigger===e){if(e===t.OnKeyUpTrigger||e===t.OnKeyDownTrigger){var o=n.getTriggerParameter();if(o&&o!==r.sourceEvent.keyCode){if(!o.toLowerCase)continue;var s=o.toLowerCase();if(s!==r.sourceEvent.key){var a=r.sourceEvent.charCode?r.sourceEvent.charCode:r.sourceEvent.keyCode;if(String.fromCharCode(a).toLowerCase()!==s)continue}}}n._executeCurrent(r)}}},t.prototype._getEffectiveTarget=function(e,t){for(var r=t.split("."),i=0;i<r.length-1;i++)e=e[r[i]];return e},t.prototype._getProperty=function(e){var t=e.split(".");return t[t.length-1]},t.prototype.serialize=function(r){for(var i={children:[],name:r,type:3,properties:[]},n=0;n<this.actions.length;n++){var o={type:0,children:[],name:t.GetTriggerName(this.actions[n].trigger),properties:[]},s=this.actions[n].triggerOptions;if(s&&"number"!=typeof s)if(s.parameter instanceof e.Node)o.properties.push(e.Action._GetTargetProperty(s.parameter));else{var a={};e.Tools.DeepCopy(s.parameter,a,["mesh"]),s.parameter.mesh&&(a._meshId=s.parameter.mesh.id),o.properties.push({name:"parameter",targetType:null,value:a})}this.actions[n].serialize(o),i.children.push(o)}return i},t.Parse=function(r,i,n){var o=new e.ActionManager(n);null===i?n.actionManager=o:i.actionManager=o;for(var s=function(t,r){var i=Object.create(e[t].prototype);return i.constructor.apply(i,r),i},a=function(t,r,i,n){if(null===n){var o=parseFloat(r);return"true"===r||"false"===r?"true"===r:isNaN(o)?r:o}for(var s=n.split("."),a=r.split(","),u=0;u<s.length;u++)i=i[s[u]];if("boolean"==typeof i)return"true"===a[0];if("string"==typeof i)return a[0];for(var l=new Array,u=0;u<a.length;u++)l.push(parseFloat(a[u]));return i instanceof e.Vector3?e.Vector3.FromArray(l):i instanceof e.Vector4?e.Vector4.FromArray(l):i instanceof e.Color3?e.Color3.FromArray(l):i instanceof e.Color4?e.Color4.FromArray(l):parseFloat(a[0])},u=function(r,i,l,h,c){if(void 0===c&&(c=null),!r.detached){var f=new Array,d=null,p=null,g=r.combine&&r.combine.length>0;if(2===r.type?f.push(o):f.push(i),g){for(var _=new Array,m=0;m<r.combine.length;m++)u(r.combine[m],t.NothingTrigger,l,h,_);f.push(_)}else for(var v=0;v<r.properties.length;v++){var y=r.properties[v].value,A=r.properties[v].name,T=r.properties[v].targetType;"target"===A?y=d=null!==T&&"SceneProperties"===T?n:n.getNodeByName(y):"parent"===A?y=n.getNodeByName(y):"sound"===A?y=n.getSoundByName(y):"propertyPath"!==A?y=2===r.type&&"operator"===A?e.ValueCondition[y]:a(0,y,d,"value"===A?p:null):p=y,f.push(y)}if(null===c?f.push(l):f.push(null),"InterpolateValueAction"===r.name){var E=f[f.length-2];f[f.length-1]=E,f[f.length-2]=l}var b=s(r.name,f);if(b instanceof e.Condition&&null!==l){var x=new e.DoNothingAction(i,l);h?h.then(x):o.registerAction(x),h=x}null===c?b instanceof e.Condition?(l=b,b=h):(l=null,h?h.then(b):o.registerAction(b)):c.push(b);for(var v=0;v<r.children.length;v++)u(r.children[v],i,l,b,null)}},l=0;l<r.children.length;l++){var h,c=r.children[l];if(c.properties.length>0){var f=c.properties[0].value,d=null===c.properties[0].targetType?f:n.getMeshByName(f);d._meshId&&(d.mesh=n.getMeshByID(d._meshId)),h={trigger:e.ActionManager[c.name],parameter:d}}else h=e.ActionManager[c.name];for(var p=0;p<c.children.length;p++)c.detached||u(c.children[p],h,null,null)}},t.GetTriggerName=function(e){switch(e){case 0:return"NothingTrigger";case 1:return"OnPickTrigger";case 2:return"OnLeftPickTrigger";case 3:return"OnRightPickTrigger";case 4:return"OnCenterPickTrigger";case 5:return"OnPickDownTrigger";case 6:return"OnPickUpTrigger";case 7:return"OnLongPressTrigger";case 8:return"OnPointerOverTrigger";case 9:return"OnPointerOutTrigger";case 10:return"OnEveryFrameTrigger";case 11:return"OnIntersectionEnterTrigger";case 12:return"OnIntersectionExitTrigger";case 13:return"OnKeyDownTrigger";case 14:return"OnKeyUpTrigger";case 15:return"OnPickOutTrigger";default:return""}},t._NothingTrigger=0,t._OnPickTrigger=1,t._OnLeftPickTrigger=2,t._OnRightPickTrigger=3,t._OnCenterPickTrigger=4,t._OnPickDownTrigger=5,t._OnDoublePickTrigger=6,t._OnPickUpTrigger=7,t._OnLongPressTrigger=8,t._OnPointerOverTrigger=9,t._OnPointerOutTrigger=10,t._OnEveryFrameTrigger=11,t._OnIntersectionEnterTrigger=12,t._OnIntersectionExitTrigger=13,t._OnKeyDownTrigger=14,t._OnKeyUpTrigger=15,t._OnPickOutTrigger=16,t.Triggers={},t})();e.ActionManager=r})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(e,r,i,n,o,s,a,u){void 0===o&&(o=1e3);var l=t.call(this,e,s)||this;return l.propertyPath=i,l.value=n,l.duration=o,l.stopOtherAnimations=a,l.onInterpolationDone=u,l._target=l._effectiveTarget=r,l}return __extends(r,t),r.prototype._prepare=function(){
- this._effectiveTarget=this._getEffectiveTarget(this._effectiveTarget,this.propertyPath),this._property=this._getProperty(this.propertyPath)},r.prototype.execute=function(){var t,r=this._actionManager.getScene(),i=[{frame:0,value:this._effectiveTarget[this._property]},{frame:100,value:this.value}];if("number"==typeof this.value)t=e.Animation.ANIMATIONTYPE_FLOAT;else if(this.value instanceof e.Color3)t=e.Animation.ANIMATIONTYPE_COLOR3;else if(this.value instanceof e.Vector3)t=e.Animation.ANIMATIONTYPE_VECTOR3;else if(this.value instanceof e.Matrix)t=e.Animation.ANIMATIONTYPE_MATRIX;else{if(!(this.value instanceof e.Quaternion))return void e.Tools.Warn("InterpolateValueAction: Unsupported type ("+typeof this.value+")");t=e.Animation.ANIMATIONTYPE_QUATERNION}var n=new e.Animation("InterpolateValueAction",this._property,1e3/this.duration*100,t,e.Animation.ANIMATIONLOOPMODE_CONSTANT);n.setKeys(i),this.stopOtherAnimations&&r.stopAnimation(this._effectiveTarget),r.beginDirectAnimation(this._effectiveTarget,[n],0,100,!1,1,this.onInterpolationDone)},r.prototype.serialize=function(r){return t.prototype._serialize.call(this,{name:"InterpolateValueAction",properties:[e.Action._GetTargetProperty(this._target),{name:"propertyPath",value:this.propertyPath},{name:"value",value:e.Action._SerializeValueAsString(this.value)},{name:"duration",value:e.Action._SerializeValueAsString(this.duration)},{name:"stopOtherAnimations",value:e.Action._SerializeValueAsString(this.stopOtherAnimations)||!1}]},r)},r})(e.Action);e.InterpolateValueAction=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(e,r,i,n){var o=t.call(this,e,n)||this;return o.propertyPath=i,o._target=o._effectiveTarget=r,o}return __extends(r,t),r.prototype._prepare=function(){this._effectiveTarget=this._getEffectiveTarget(this._effectiveTarget,this.propertyPath),this._property=this._getProperty(this.propertyPath)},r.prototype.execute=function(){this._effectiveTarget[this._property]=!this._effectiveTarget[this._property]},r.prototype.serialize=function(r){return t.prototype._serialize.call(this,{name:"SwitchBooleanAction",properties:[e.Action._GetTargetProperty(this._target),{name:"propertyPath",value:this.propertyPath}]},r)},r})(e.Action);e.SwitchBooleanAction=t;var r=(function(t){function r(e,r,i,n){var o=t.call(this,e,n)||this;return o.value=i,o._target=r,o}return __extends(r,t),r.prototype.execute=function(){this._target.state=this.value},r.prototype.serialize=function(r){return t.prototype._serialize.call(this,{name:"SetStateAction",properties:[e.Action._GetTargetProperty(this._target),{name:"value",value:this.value}]},r)},r})(e.Action);e.SetStateAction=r;var i=(function(t){function r(e,r,i,n,o){var s=t.call(this,e,o)||this;return s.propertyPath=i,s.value=n,s._target=s._effectiveTarget=r,s}return __extends(r,t),r.prototype._prepare=function(){this._effectiveTarget=this._getEffectiveTarget(this._effectiveTarget,this.propertyPath),this._property=this._getProperty(this.propertyPath)},r.prototype.execute=function(){this._effectiveTarget[this._property]=this.value,this._target.markAsDirty&&this._target.markAsDirty(this._property)},r.prototype.serialize=function(r){return t.prototype._serialize.call(this,{name:"SetValueAction",properties:[e.Action._GetTargetProperty(this._target),{name:"propertyPath",value:this.propertyPath},{name:"value",value:e.Action._SerializeValueAsString(this.value)}]},r)},r})(e.Action);e.SetValueAction=i;var n=(function(t){function r(e,r,i,n,o){var s=t.call(this,e,o)||this;return s.propertyPath=i,s.value=n,s._target=s._effectiveTarget=r,s}return __extends(r,t),r.prototype._prepare=function(){this._effectiveTarget=this._getEffectiveTarget(this._effectiveTarget,this.propertyPath),this._property=this._getProperty(this.propertyPath),"number"!=typeof this._effectiveTarget[this._property]&&e.Tools.Warn("Warning: IncrementValueAction can only be used with number values")},r.prototype.execute=function(){this._effectiveTarget[this._property]+=this.value,this._target.markAsDirty&&this._target.markAsDirty(this._property)},r.prototype.serialize=function(r){return t.prototype._serialize.call(this,{name:"IncrementValueAction",properties:[e.Action._GetTargetProperty(this._target),{name:"propertyPath",value:this.propertyPath},{name:"value",value:e.Action._SerializeValueAsString(this.value)}]},r)},r})(e.Action);e.IncrementValueAction=n;var o=(function(t){function r(e,r,i,n,o,s){var a=t.call(this,e,s)||this;return a.from=i,a.to=n,a.loop=o,a._target=r,a}return __extends(r,t),r.prototype._prepare=function(){},r.prototype.execute=function(){this._actionManager.getScene().beginAnimation(this._target,this.from,this.to,this.loop)},r.prototype.serialize=function(r){return t.prototype._serialize.call(this,{name:"PlayAnimationAction",properties:[e.Action._GetTargetProperty(this._target),{name:"from",value:String(this.from)},{name:"to",value:String(this.to)},{name:"loop",value:e.Action._SerializeValueAsString(this.loop)||!1}]},r)},r})(e.Action);e.PlayAnimationAction=o;var s=(function(t){function r(e,r,i){var n=t.call(this,e,i)||this;return n._target=r,n}return __extends(r,t),r.prototype._prepare=function(){},r.prototype.execute=function(){this._actionManager.getScene().stopAnimation(this._target)},r.prototype.serialize=function(r){return t.prototype._serialize.call(this,{name:"StopAnimationAction",properties:[e.Action._GetTargetProperty(this._target)]},r)},r})(e.Action);e.StopAnimationAction=s;var a=(function(t){function r(r,i){return void 0===r&&(r=e.ActionManager.NothingTrigger),t.call(this,r,i)||this}return __extends(r,t),r.prototype.execute=function(){},r.prototype.serialize=function(e){return t.prototype._serialize.call(this,{name:"DoNothingAction",properties:[]},e)},r})(e.Action);e.DoNothingAction=a;var u=(function(e){function t(t,r,i){var n=e.call(this,t,i)||this;return n.children=r,n}return __extends(t,e),t.prototype._prepare=function(){for(var e=0;e<this.children.length;e++)this.children[e]._actionManager=this._actionManager,this.children[e]._prepare()},t.prototype.execute=function(e){for(var t=0;t<this.children.length;t++)this.children[t].execute(e)},t.prototype.serialize=function(t){for(var r=e.prototype._serialize.call(this,{name:"CombineAction",properties:[],combine:[]},t),i=0;i<this.children.length;i++)r.combine.push(this.children[i].serialize(null));return r},t})(e.Action);e.CombineAction=u;var l=(function(e){function t(t,r,i){var n=e.call(this,t,i)||this;return n.func=r,n}return __extends(t,e),t.prototype.execute=function(e){this.func(e)},t})(e.Action);e.ExecuteCodeAction=l;var h=(function(t){function r(e,r,i,n){var o=t.call(this,e,n)||this;return o._target=r,o._parent=i,o}return __extends(r,t),r.prototype._prepare=function(){},r.prototype.execute=function(){if(this._target.parent!==this._parent){var t=this._parent.getWorldMatrix().clone();t.invert(),this._target.position=e.Vector3.TransformCoordinates(this._target.position,t),this._target.parent=this._parent}},r.prototype.serialize=function(r){return t.prototype._serialize.call(this,{name:"SetParentAction",properties:[e.Action._GetTargetProperty(this._target),e.Action._GetTargetProperty(this._parent)]},r)},r})(e.Action);e.SetParentAction=h;var c=(function(e){function t(t,r,i){var n=e.call(this,t,i)||this;return n._sound=r,n}return __extends(t,e),t.prototype._prepare=function(){},t.prototype.execute=function(){void 0!==this._sound&&this._sound.play()},t.prototype.serialize=function(t){return e.prototype._serialize.call(this,{name:"PlaySoundAction",properties:[{name:"sound",value:this._sound.name}]},t)},t})(e.Action);e.PlaySoundAction=c;var f=(function(e){function t(t,r,i){var n=e.call(this,t,i)||this;return n._sound=r,n}return __extends(t,e),t.prototype._prepare=function(){},t.prototype.execute=function(){void 0!==this._sound&&this._sound.stop()},t.prototype.serialize=function(t){return e.prototype._serialize.call(this,{name:"StopSoundAction",properties:[{name:"sound",value:this._sound.name}]},t)},t})(e.Action);e.StopSoundAction=f})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(t){var r=(function(){function t(t,r,i,n,o){void 0===n&&(n=!0),void 0===o&&(o=1),this.skeleton=t,this.mesh=r,this.autoUpdateBonesMatrices=n,this.renderingGroupId=o,this.color=e.Color3.White(),this._debugLines=[],this._isEnabled=!1,this._scene=i,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,r,i,n,o,s){void 0===n&&(n=0),void 0===o&&(o=0),void 0===s&&(s=0);var a=e.Tmp.Matrix[0],u=r.getParent();if(a.copyFrom(r.getLocalMatrix()),0!==n||0!==o||0!==s){var l=e.Tmp.Matrix[1];e.Matrix.IdentityToRef(l),l.m[12]=n,l.m[13]=o,l.m[14]=s,l.multiplyToRef(a,a)}u&&a.multiplyToRef(u.getAbsoluteTransform(),a),a.multiplyToRef(i,a),t.x=a.m[12],t.y=a.m[13],t.z=a.m[14]},t.prototype._getLinesForBonesWithLength=function(t,r){for(var i=t.length,n=this.mesh.position,o=0;o<i;o++){var s=t[o],a=this._debugLines[o];a||(a=[e.Vector3.Zero(),e.Vector3.Zero()],this._debugLines[o]=a),this._getBonePosition(a[0],s,r),this._getBonePosition(a[1],s,r,0,s.length,0),a[0].subtractInPlace(n),a[1].subtractInPlace(n)}},t.prototype._getLinesForBonesNoLength=function(t,r){for(var i=t.length,n=0,o=this.mesh.position,s=i-1;s>=0;s--){var a=t[s],u=a.getParent();if(u){var l=this._debugLines[n];l||(l=[e.Vector3.Zero(),e.Vector3.Zero()],this._debugLines[n]=l),a.getAbsolutePositionToRef(this.mesh,l[0]),u.getAbsolutePositionToRef(this.mesh,l[1]),l[0].subtractInPlace(o),l[1].subtractInPlace(o),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.position.copyFrom(this.mesh.position),this._debugMesh.color=this.color},t.prototype.dispose=function(){this._debugMesh&&(this.isEnabled=!1,this._debugMesh.dispose(),this._debugMesh=null)},t})();t.SkeletonViewer=r})(e.Debug||(e.Debug={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(t){var r=(function(){function t(t,r){void 0===r&&(r=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=r,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,r,i,n){var o=this.scaleLines;this._xmesh.position.copyFrom(t),this._ymesh.position.copyFrom(t),this._zmesh.position.copyFrom(t);var s=this._xline[1];s.x=r.x*o,s.y=r.y*o,s.z=r.z*o,e.Mesh.CreateLines(null,this._xline,null,null,this._xmesh),s=this._yline[1],s.x=i.x*o,s.y=i.y*o,s.z=i.z*o,e.Mesh.CreateLines(null,this._yline,null,null,this._ymesh),s=this._zline[1],s.x=n.x*o,s.y=n.y*o,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=r})(e.Debug||(e.Debug={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(t){var r=(function(t){function r(r,i,n,o){void 0===o&&(o=1);var s=t.call(this,r,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=i,s}return __extends(r,t),r.prototype.update=function(){var r=this.bone;r.getAbsolutePositionToRef(this.mesh,this.pos),r.getDirectionToRef(e.Axis.X,this.mesh,this.xaxis),r.getDirectionToRef(e.Axis.Y,this.mesh,this.yaxis),r.getDirectionToRef(e.Axis.Z,this.mesh,this.zaxis),t.prototype.update.call(this,this.pos,this.xaxis,this.yaxis,this.zaxis)},r.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))},r})(t.AxesViewer);t.BoneAxesViewer=r})(e.Debug||(e.Debug={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(e){this.ray=e}return t.CreateAndShow=function(e,r,i){var n=new t(e);return n.show(r,i),n},t.prototype.show=function(t,r){if(!this._renderFunction){var i=this.ray;this._renderFunction=this._render.bind(this),this._scene=t,this._renderPoints=[i.origin,i.origin.add(i.direction.scale(i.length))],this._renderLine=e.Mesh.CreateLines("ray",this._renderPoints,t,!0),this._scene.registerBeforeRender(this._renderFunction)}r&&this._renderLine.color.copyFrom(r)},t.prototype.hide=function(){this._renderFunction&&(this._scene.unregisterBeforeRender(this._renderFunction),this._scene=null,this._renderFunction=null,this._renderLine.dispose(),this._renderLine=null,this._renderPoints=null)},t.prototype._render=function(){var t=this.ray,r=this._renderPoints[1],i=Math.min(t.length,1e6);r.copyFrom(t.direction),r.scaleInPlace(i),r.addInPlace(t.origin),e.Mesh.CreateLines("ray",this._renderPoints,this._scene,!0,this._renderLine)},t.prototype.attachToMesh=function(t,r,i,n){this._attachedToMesh=t;var o=this.ray;o.direction||(o.direction=e.Vector3.Zero()),o.origin||(o.origin=e.Vector3.Zero()),n&&(o.length=n),i||(i=e.Vector3.Zero()),r||(r=new e.Vector3(0,0,-1)),this._meshSpaceDirection?(this._meshSpaceDirection.copyFrom(r),this._meshSpaceOrigin.copyFrom(i)):(this._meshSpaceDirection=r.clone(),this._meshSpaceOrigin=i.clone()),this._updateToMeshFunction||(this._updateToMeshFunction=this._updateToMesh.bind(this),this._attachedToMesh.getScene().registerBeforeRender(this._updateToMeshFunction)),this._updateToMesh()},t.prototype.detachFromMesh=function(){this._attachedToMesh&&(this._attachedToMesh.getScene().unregisterBeforeRender(this._updateToMeshFunction),this._attachedToMesh=null,this._updateToMeshFunction=null)},t.prototype._updateToMesh=function(){var t=this.ray;if(this._attachedToMesh._isDisposed)return void this.detachFromMesh();this._attachedToMesh.getDirectionToRef(this._meshSpaceDirection,t.direction),e.Vector3.TransformCoordinatesToRef(this._meshSpaceOrigin,this._attachedToMesh.getWorldMatrix(),t.origin)},t.prototype.dispose=function(){this.hide(),this.detachFromMesh(),this.ray=null},t})();e.RayHelper=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(e){this._scene=e}return t.prototype._createInspector=function(e){void 0===e&&(e={});var t=e.popup||!1,r=e.initialTab||0,i=e.parentElement||null;this._inspector||(this._inspector=new INSPECTOR.Inspector(this._scene,t,r,i,e.newColors))},t.prototype.isVisible=function(){return!!this._inspector},t.prototype.hide=function(){if(this._inspector){try{this._inspector.dispose()}catch(e){}this._inspector=null}},t.prototype.show=function(r){void 0===r&&(r={}),"undefined"==typeof INSPECTOR?e.Tools.LoadScript(t.InspectorURL,this._createInspector.bind(this,r)):this._createInspector(r)},t.InspectorURL=window.location.href.split("/")[0]+"//preview.babylonjs.com/inspector/babylon.inspector.bundle.js",t})();e.DebugLayer=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(t){var r=(function(){function t(t){this._impostors=[],this._meshes=[],this._numMeshes=0,this._scene=t||e.Engine.LastCreatedScene,this._physicsEnginePlugin=this._scene.getPhysicsEngine().getPhysicsPlugin()}return t.prototype._updateDebugMeshes=function(){for(var e=this._physicsEnginePlugin,t=0;t<this._numMeshes;t++)this._impostors[t].isDisposed?this.hideImpostor(this._impostors[t--]):e.syncMeshWithImpostor(this._meshes[t],this._impostors[t])},t.prototype.showImpostor=function(e){for(var t=0;t<this._numMeshes;t++)if(this._impostors[t]==e)return;var r=this._getDebugMesh(e,this._scene);r&&(this._impostors[this._numMeshes]=e,this._meshes[this._numMeshes]=r,0===this._numMeshes&&(this._renderFunction=this._updateDebugMeshes.bind(this),this._scene.registerBeforeRender(this._renderFunction)),this._numMeshes++)},t.prototype.hideImpostor=function(e){for(var t=!1,r=0;r<this._numMeshes;r++)if(this._impostors[r]==e){this._scene.removeMesh(this._meshes[r]),this._meshes[r].dispose(),this._numMeshes--,this._numMeshes>0?(this._meshes[r]=this._meshes[this._numMeshes],this._impostors[r]=this._impostors[this._numMeshes],this._meshes[this._numMeshes]=null,this._impostors[this._numMeshes]=null):(this._meshes[0]=null,this._impostors[0]=null),t=!0;break}t&&0===this._numMeshes&&this._scene.unregisterBeforeRender(this._renderFunction)},t.prototype._getDebugMaterial=function(t){return this._debugMaterial||(this._debugMaterial=new e.StandardMaterial("",t),this._debugMaterial.wireframe=!0),this._debugMaterial},t.prototype._getDebugBoxMesh=function(t){return this._debugBoxMesh||(this._debugBoxMesh=e.MeshBuilder.CreateBox("physicsBodyBoxViewMesh",{size:1},t),this._debugBoxMesh.renderingGroupId=1,this._debugBoxMesh.rotationQuaternion=e.Quaternion.Identity(),this._debugBoxMesh.material=this._getDebugMaterial(t),t.removeMesh(this._debugBoxMesh)),this._debugBoxMesh.createInstance("physicsBodyBoxViewInstance")},t.prototype._getDebugSphereMesh=function(t){return this._debugSphereMesh||(this._debugSphereMesh=e.MeshBuilder.CreateSphere("physicsBodySphereViewMesh",{diameter:1},t),this._debugSphereMesh.renderingGroupId=1,this._debugSphereMesh.rotationQuaternion=e.Quaternion.Identity(),this._debugSphereMesh.material=this._getDebugMaterial(t),t.removeMesh(this._debugSphereMesh)),this._debugSphereMesh.createInstance("physicsBodyBoxViewInstance")},t.prototype._getDebugMesh=function(t,r){var i,n=t.physicsBody;n.shapes[0];if(t.type==e.PhysicsImpostor.BoxImpostor)i=this._getDebugBoxMesh(r),t.getBoxSizeToRef(i.scaling);else if(t.type==e.PhysicsImpostor.SphereImpostor){i=this._getDebugSphereMesh(r);var o=t.getRadius();i.scaling.x=2*o,i.scaling.y=2*o,i.scaling.z=2*o}return i},t.prototype.dispose=function(){for(var e=0;e<this._numMeshes;e++)this.hideImpostor(this._impostors[e]);this._debugBoxMesh&&this._debugBoxMesh.dispose(),this._debugSphereMesh&&this._debugSphereMesh.dispose(),this._debugMaterial&&this._debugMaterial.dispose(),this._impostors.length=0,this._scene=null,this._physicsEnginePlugin=null},t})();t.PhysicsViewer=r})(e.Debug||(e.Debug={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(t){this.frontColor=new e.Color3(1,1,1),this.backColor=new e.Color3(.1,.1,.1),this.showBackLines=!0,this.renderList=new e.SmartArray(32),this._vertexBuffers={},this._scene=t}return t.prototype._prepareRessources=function(){if(!this._colorShader){this._colorShader=new e.ShaderMaterial("colorShader",this._scene,"color",{attributes:[e.VertexBuffer.PositionKind],uniforms:["world","viewProjection","color"]});var t=this._scene.getEngine(),r=e.VertexData.CreateBox({size:1});this._vertexBuffers[e.VertexBuffer.PositionKind]=new e.VertexBuffer(t,r.positions,e.VertexBuffer.PositionKind,!1),this._indexBuffer=t.createIndexBuffer([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,7,1,6,2,5,3,4])}},t.prototype.reset=function(){this.renderList.reset()},t.prototype.render=function(){if(0!==this.renderList.length&&(this._prepareRessources(),this._colorShader.isReady())){var t=this._scene.getEngine();t.setDepthWrite(!1),this._colorShader._preBind();for(var r=0;r<this.renderList.length;r++){var i=this.renderList.data[r],n=i.minimum,o=i.maximum,s=o.subtract(n),a=n.add(s.scale(.5)),u=e.Matrix.Scaling(s.x,s.y,s.z).multiply(e.Matrix.Translation(a.x,a.y,a.z)).multiply(i.getWorldMatrix());t.bindBuffers(this._vertexBuffers,this._indexBuffer,this._colorShader.getEffect()),this.showBackLines&&(t.setDepthFunctionToGreaterOrEqual(),this._scene.resetCachedMaterial(),this._colorShader.setColor4("color",this.backColor.toColor4()),this._colorShader.bind(u),t.draw(!1,0,24)),t.setDepthFunctionToLess(),this._scene.resetCachedMaterial(),this._colorShader.setColor4("color",this.frontColor.toColor4()),this._colorShader.bind(u),t.draw(!1,0,24)}this._colorShader.unbind(),t.setDepthFunctionToLessOrEqual(),t.setDepthWrite(!0)}},t.prototype.dispose=function(){if(this._colorShader){this.renderList.dispose(),this._colorShader.dispose();var t=this._vertexBuffers[e.VertexBuffer.PositionKind];t&&(t.dispose(),this._vertexBuffers[e.VertexBuffer.PositionKind]=null),this._scene.getEngine()._releaseBuffer(this._indexBuffer)}},t})();e.BoundingBoxRenderer=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){}return t.CreateResizedCopy=function(t,r,i,n){void 0===n&&(n=!0);var o=new e.RenderTargetTexture("resized"+t.name,{width:r,height:i},s,!t.noMipmap,!0,t._texture.type,!1,t._samplingMode,!1),s=t.getScene(),a=s.getEngine();o.wrapU=t.wrapU,o.wrapV=t.wrapV,o.uOffset=t.uOffset,o.vOffset=t.vOffset,o.uScale=t.uScale,o.vScale=t.vScale,o.uAng=t.uAng,o.vAng=t.vAng,o.wAng=t.wAng,o.coordinatesIndex=t.coordinatesIndex,o.level=t.level,o.anisotropicFilteringLevel=t.anisotropicFilteringLevel,o._texture.isReady=!1,t.wrapU=e.Texture.CLAMP_ADDRESSMODE,t.wrapV=e.Texture.CLAMP_ADDRESSMODE;var u=new e.PassPostProcess("pass",1,null,n?e.Texture.BILINEAR_SAMPLINGMODE:e.Texture.NEAREST_SAMPLINGMODE,a,!1,e.Engine.TEXTURETYPE_UNSIGNED_INT);return u.getEffect().executeWhenCompiled((function(){u.onApply=function(e){e.setTexture("textureSampler",t)},s.postProcessManager.directRender([u],o.getInternalTexture()),a.unBindFramebuffer(o.getInternalTexture()),o.disposeFramebufferObjects(),u.dispose(),o._texture.isReady=!0})),o},t.GetEnvironmentBRDFTexture=function(t){if(!t._environmentBRDFTexture){var r=e.Texture.CreateFromBase64String(this._environmentBRDFBase64Texture,"EnvironmentBRDFTexture",t,!0,!1,e.Texture.BILINEAR_SAMPLINGMODE);r.wrapU=e.Texture.CLAMP_ADDRESSMODE,r.wrapV=e.Texture.CLAMP_ADDRESSMODE,t._environmentBRDFTexture=r}return t._environmentBRDFTexture},
- t._environmentBRDFBase64Texture="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAYAAABccqhmAAAgAElEQVR4Xu19Z7PtTHbW1g3jMMbGmGDAZAMm5xxMLDAU0WSKWOQcCoqccw6eGdtgk4yNbZxnvvAL+Af8Af6AsQl+06ako9X36dXPSi3pnPu+cz/cOntL3S1pq5+w1mrpLs/eud9fvn27rf9evPPwFz+v22S7fGZ/n7/70G79J5/Xv/qzbLP+Pnvvoc/6Tz7jX/15/c62LfeH7fofbpfP3l/ct36Wf+u4+D37+XYb++G26LPsr/zFttnPuh37bm1bt0f7MvtlnOx4uv0H4fty8UUsz77rfn/57u32cgXvDv72eQf0tl0+G38b0Nf9K4Dl704MEfA16KsE8Gw9JgD+DQE8EA0DT2b7GwK4GHnF4a8iguXZt9/vL5/dbisJbEq/uwD5vIK/fbbAv4N9U/8nJIDNCazKvBLBGwdwu62OhajxmQSAx6gqNp5HCg9wPan2nwSNjhLD8ux/3u8vP3y7vbwDAYjtR8AzFyDqLu1Q+YEINnew23rPCYiKb+q/K7o4AVT4tg0t/h4ydJZfkQASQ/d5b9fZ/Z1ENmuPn/cwYCYEELBguKC3nRkCnE0AFOwOKCOAR/sH/L4hgFMpbSWP5dn/uN9ffs7t9mJ5cAHoBLTyszBAFJ/F/xIKdASw5wgaEWDMLySxAk4svf6L+4QAGPiJCziNAPb4f3UZ2dh/m+z7BK4SAPYrxf5FB6ABPgCUAfANAZwKyscc7IEA/vv9/uLzbreXzx9cQCMACAl00m8jAlF7ov6SCMQ8gJsMFFBnCECSg5H6TxJAU3vPAbwhgFfz9AABeOEDBcIbB3AqPzwQwH+731/8sNvt5Ydut5e3B2C/fG9P+jESgGz/RgxG9r9VAwTUUh0goQDafUz+DYnAnSha5l99Z1l/yQVswAZSGIAugNd/9xBgCw9E8aECkHUB22QPHIAVDlQdQAMWAibhBgZAasAVHUAI8Cqg96Tm0bj3VBS9jwd7IIBvuN9ffMHt9vLTbreXy+32QlwAhgMIeuNzKwOqCoB2Aa00KHE+EsIeDuj4H2N+Hf/TfAC6A4nhgQCQDDwiaKDXiq9KgBEJNPArAtCk0AEd2mpAizW3/lYIoANpBPg3BPA+hjs/9eXZV+0E8Bm32wsJA9aEoBCAuAABPiEAC/yDC4gSgRgKRHkAlgsI6v7iEFqJEMgBwb4BGkEfEEDnDlReoAP/SQRgOYIB+IYDMEE/SQBbXoLNr0jhq4qOZc0PHBSf5oKW519xvz//kbfby8+83V68ABfwniIBgwgQ/HoRUMv8w5qAoQqgk4DWQiCw+63eD8k/XAPQgK5s/5a5xzAAqgR6wY9k+ZEMtCOoJABb230hEHMFWQdgAl0Ap/+uc6tKBrrP/n0AuwfiNwTwNKguHHV5/qX3+/M1B/Ddb7cXax7g2e324vaQB3hhkMAW92tHoFb96cVAbimwkgQ0Vv7R+D8iACfuxzKfLvnNlAAjAsBwwP2MwLQAD9sbYJME0AFcg5uBPSAA0x0AobhtcDKDA0j3KYDhk7Hp8uKj9/vzH3C7vfget9uLT9nDgDUZuOYCLBJA8MNKPyGGIftPrL+4gy3eh5p/lwRUYYAs9Fn7tM/E9lvJwCH2DxJ/mPTr4nyyLiDtBgTAGCrgNuPzNuETgN+suEEAFhng9lkCoICMLH7V0isCeEMCxylrefkl9/uzz90J4NNUGLDmAnYXINUBrf5dCCAuQCcCvYVAYPk3G++VAveVfkIAFRLolgbr2F9ifP33pAqAV/fHRF4HcAS7AKlAAEIYFNwITOszs/wMsB6II4BXFZ0QwBsSOEYCDwTw2TsBfPrt9uLlqzCgcwFABI0EVCiANl8Uvq0JWNsi2JPZ/0YKsOiHxftsW4v51ZqAaBWgZf91PsBL/jFHwEqBR1cCiuJ3gAfCmCEA3cf8rmz8AMZHIoA3JDBPAsuHVgL4jNvt+UoCH34ggK0asIYBGArsAB7AD+reQgCl+GwZ8LaNlP3MEEDaSg4ACMGr/+ulwV4JsAEfLH42/vdKgWElAJ4QpBl+LAlKErHwt+oGMgTA2ngE4IUIOH3dGr/hAKT/m/UBdSJYPuVL7vflU26352sScCWAD+0EsCcDVxewKjfmAzAsENVn4EfgdySgnYB81yEAgL4RA8T8mTUASAAYBgylQAkL8K/+zL6rsl8qF6ArAeS7WRGoAB8Sf7isN/VZqTs6jQ5wXlweWfyqpQ8I4I0TmCCAT/3I/b48u92ef9bt9nwNAdZE4FoOFALYXcAGegkDMByAzzQEgJh+cAIs/legH0IA5QTCPADE+7ISkD0TgA/8sBIgLQfOgF/F9kPcr+J8fIYguyCILQRKgV4DNviOzoKqeJS0u4AA3pBAjQSWT//I/b5OmC0MWB3ASgBrGLA+IryvDNxCgRXo+wKhjgwk8bcTwUACsJ09ANRVAALwCxmEoFcrAUsuAJ4M1E8BDuHABAHomJ8RgACrZfQLyT9dBWi2OOEG9NJd/TDQ8HAQuBE97ZhjGKy6o+imnU+4gDckkCeB5cMfud/v6zr9Dz84gOdCAM/3JwQhF9CAD25gBWWz/8wNgMpj3K9Lfy0foMMBVffXyT4r+cceC9bvCcDFP0311QrATPkvWgosYQFLAuoqQEcQuw3v2si25F+M1RkZXLUU+CgBmCBOEsCbvECOBJbP+Oj9fv+u2+3Zp91uz9cy4Kfebs/3ROD6iPD2b10YJCXB+0PyrgsHdtBuRACfBeTN+uM+suJPSEDbfh3/oxPoHgwiC3/06j8Eutj69sAQqj++I0CUfvIpwCEvYCT90O4Pn1XsT5Ve1/+dcp9FBh3woqXBSEJkvjHHEOUPqJPAjUUCeOMGfCJYPvOj9/t7//d2e7YmAlcS2B3A8xcPYcBm/7ULEDIQew+5gS0EIEA31R8Uf6gAoBsgKwBd9ddvBBJAs6XARgLQXQ2o7T8+IETe+9eRACg7rhCMVgCiE8D4O9wOCb2ubOht1/vYd2ubzLlgKbBHEDSnAMfL6durVm8qBPwXWz7rY/f7/X/fbsvL2+3Zqv4QAjzfw4COAMAJbEC3wC8koBJ9lAhgxZ+4hi3Oh/f8dU8EqtV/JhHgWn9cC4CJQZXZp6GAk/1nawMkrrcqAiwPIIA2FwOB2oaAF5UkcX+GADBs0I5gsNbBQqCorJcFJjqWKvhNMjky0Aek7/LZH7vf3/vO2215vruAD91uz/dSYCOAPQzYkoD7vw34sFIQw4LNymNSUKk8Wv0hCYhkoJ74Q6BboO9eDKoWAHXvBiCvAdPZf4nt3QqA924AbfXV8t8uN4Bt2We029WkoErWpSoCSm11TM8AOYA5uRS4RAITIQDDavaYHxCcm5exfM7H7vd3v2N9McDt9uxDD//WKsAG/ue32/M1DEACuO3g1jkBsf57fqCL/7UbIISAio85AAG0VQEYiIC9DJTYfy/+Dx8HlpeDRK8G90IBHQbgWgD2WT8LoOJ7NyeA5JEkAwwxmuqzur5X6y+sBEwDMggrqoBNH7c68Puk/fI9Vwfwvx4e6H724oEA1iSg5AAaAewlweeyLmAnAHQCTfU1CTAH4GyTMt+QDMRFQFEYQB71lXUAOjHYlvTqh4N2xe5yASoh2PpaJUGDBDrLr9cGIDlY1l+vDlQOAQHckYMiA68KMFsGtOy65RCGsMIDT+QqJoD3yUwCy/f+6P3+7koAt50AXrwigM0FrIuEoBrwHMMAUhmQUKAlAwHo7VmAPURo9h/r//ozLv1V7/5v6wGMV4B3rwYPXEBqIZAQwp4TYDE+LQlqtQfw6my/LgsyZaeLg7wVgmDnWQ5AA5ZWCDRx7ECzyn3udgFptFCIgTlyFRMEUCKgA+O/jl2Xz/3o/f7Otz88QvpszQOsLmAPARoBSDVgud02AthdwPZ5BSxUBVr8L3kAVHrvs076KSLQi3/M9QCJ7H/G/rf4n8X41XIgcwHecuBMDgAe+BHA6uQgqnvbF5DB5hwUQM3vQgIWkKOVftH+gAC6cz0RXZ9MjmD5fh/ZCWCd1CsB7CSwhgArAUgIIC5AQoDOCewJwab+CH79WR4C0mQAZT4hEQS9DgfEztNkoEECDfi6FAhZflb6Q1XXqwHDEECpvZX4a0qP1l7bfAS98cQfzQUo9a4mASMC0CsIm6JGK/2i/QkCuFK9PxmIYPm8nQDu795uy3K7LTvwVyJAB7ARwJoAVLkA7QIkJ9A5AQS95Ad2YmgvAJWwQFcBpB38pUuB9wVKbAWgCXwV86Mz2ICKTwUWFgOxMEBicr0eoBwCGBUADfxsDsAiA+zflNay31ZcfnAdAAXgDGkcdAcfZCJYfuCX3O9vf/vtthHAmgcQF7ATwOoAtn9IACsRSDkQ/wqIIUGoXYEQQ/sL5IDJP539776DwodVAGlr5QBgP8sDdApP3gSUXQa8/rZsRaBeHmy+HwDyCI1MUNlZzX9iJSBO9igJGJYCo4RdIqMfJQ4Ztq8C7FXjHuSnQ92XH/yvdwJ4Z68ErOXAlQRW0O9/JRG42v9GBHsuAImAqv+uzDo30C3yAfVHoHeg9xyAp/7wlp+WFCSWv1sOTBb+0EoAZP5DImBrApAUMFHolQG19c+EAkbpjyUEdQ6gm/QEsCzZFxKDlWNwprJVWfBm/1WAvWrcQ0ie7Lz80H91v7/9v263+9sPI2zrAZAEdvXvXMBKBJIIFDcgyUAEvHICg/o7wA/Bvyt35wCc2F9Cg03RvRyAA34N8hD0xsIfXP7bQgDMFSgyYO8GsF4N/hQ5ALak1yUGRQDZZJ5VWXgKEsie8yQuH63b8vn/8oEA3lsJYJ2EQgD73xX4z9bs/74gaHMBQgA7+DsXAJWBBniHCLTtNx2AUnkG/LYNiUCpvX7wp6sIOHF/lwgkNf8UGagwYMgLMBdgLQCyVgOyciCGCs5nz/Jr8EXOQOcQZEbrfjjTU8qaCBseMyx4vxPB8iP+RU8A24Kg9R8Qgaj/av8lDBgcwApQ+QdVgW0bKr3+jsk//AztzBKgtv4K+Kj08rl7JFgt9BnCAIsQcD2AsQAolQj0CAGAqhOFCK5u3cA+84dyIJLCPm6buAgoBa5qDoDF6wzUkZ13iSDKKwTamSKZSf29cuzJUwq7LV/wz18RwH2Nl9dKABLArv6bC5B/+9OBGxmsIIR1AQ3w2gk4RECTfwBulgC0rP96/FYJUOv9SzkAB/xuKTBY/qsTgZ0LILF/s/RW9v81ywEwhbeAwUIH6hRwGp+wEOhqoF49fojqQoPlR/+z+/3t77jd3n3rdru999CzEYAQAYJfXACEAqL8W5lQgA5uoJUK9zxBB3ii9ALiYT2AjvuN72wFILP+XdlP8gLKFeg6f5QM3AC+VlMMZ9ABGuN+VePHWL6tHVD23or3tQPo2iWfBRgShDp0ELcBjmIAbwTWqEzIJvLM6kEDEFcD9erxCzg3my4/9p/e7299x+323lu32+oAtjwAhgE7Cazqv7mAvRLQcgG7A9B5AAwHus87CWBYsIKFfe+eCSBgt2J+7QBQ+VsogOU/9fIPBvLhASEF8AHwlhPQ2wVYFhmo/Wby74QyYLcmQAEbbbue2FcnAb28QTmHQKBwNVCvHv8IESw//h/f7299pyIA7QIE/LsTeIbqL59hPUADvHIBG8jBIWgn0L4rsKMj2Noomz8QgZELsCoAAnh0Caj8lup7ib9tX+ZBoKgUmFkWTGJ8S/UHZa/kAHT+QGaeoeQmMUC/CoAzVYAjYDvSNwPCq8fPnINus/zEfwQE8O7tdt8dwGZjIQQQ9Y9cwAB+RQIC4I4MdvvdLL+O//E7LgLykn6q3Efjf6X8bOUfkoNYcQZ8z/KzBUBYCqT/YQgjBuOBHxPs7JHh7JoAy/IzWz+xEtBKBEYg8fIGw+SeQQQ+CzHZP+oWXWPU/8z9y0/+h/f729/5kAN4791X/6/cpl4SCsDfLRQwHEBLCmJFYH92vssNgBPo7D8qv4CekIHpAjKgx1iffGbKb5UAQwdguIAtz2KsEWj7vIQggNON91lYoIFN2mznYKj9UBmwQgXLLcDstRTdBchEFWAWcLP9MgC9cuzM8aXN8lP//v3+9v/uCUDyAM0FIBFADqAjAsgFiAvYwK3/MfAL8InSd/Yfy37Qpyv3OSTgxf8C5vZXPfF3aB2AA3hJGg5LghMOgCUBo8SgEAyC3Irvh5xAwhW0cT1iQBKYWds/QQLdeVUQcrEjeGoiWH7633sggHfWJOAaAkglYL/wLQyQf3tYsCp9CwmgFIgOgIJ/JwMdBuB3cQTDX4z9wR2whN+WE9idh67761p/F/8bpb8O/OotQCsJDhZfji0qT9p0LsCI83X9H8E9KH8iCSiTrQO29bwAAbvlCipPAw4T/oRKQAVElbaMJ472t7jnqnEjrlt+1t+539/6P4oAxLquawIkF7Bb/40M9hAAHcD2GVzABmBYKSgxfyMGAbROCipl1w6gs/8ZF0Cy/UIOOr7vHAIu9iHP/2v77yX9ROUt29+AHVUCnDJgtvSn8wXsnQGzIUAW3F27qFS4z2CrD07wCogqbR8LtGecUwR4vX/5OX/7FQFsOYC9FCiToBGAEAH83ZwA5AM06BspiPKrNQIt/kcg69iffBegNqVXb/wdQgIMC0DltUuQ+L+Bmz0OrNTdK/91+4JVf15SEPMCYRkwEfc3stBxurMS0AoTMKRocaV8cKw6jpcFsdUn2/8qRT8buGeP55HC8vP+5v3+1v99cADvvfNQBZB4dO24Kv5GAntSUOz/+n1wAis4wAnoMAC/N9svSUKsBABgmwPAbQTwWzsW/2vAI6j14h+1CEjnBYZFQWSxj+sEVFyPjgBBrhf+aOtPY39vRaBVJlQ2vyOGIATQsb6etBguDMSQyAF4IMhUAmZANNNnUNSqBDvtzzif6HSWL/wbuwN4eycA4gDEBQgRYPzfSGC3/BYBdOCHxKBHBAJoAbdWfIz1I9XXsf5g9y0yAJB7iUDPCaC6e2EA2ngMGyIHwAgBldncf4ID0EDXVp1NYmbnrclOtyfDhiPOoCO4CEXB/rOBfOZ4yy/8a7sDAALY1gKAfWMEgOovoNdk0IArKr+7gwH02gWQ2L4t/sEEoLL2IQnoFX96HYC4CIz/jcSgAJSVAtu2RPZ/SPRBHkC7AkYEqceC2fqBfdKaCcHAAeAkpKVBCANcElBVgBQRTC4HngHOTJ+rQo2jhEbP6xf/VU4AmBza7L+EAZgLgGSgxP8dGQDwmQOQbS2xp6oEWAnQn1seIEMCJO4fsv8Q2w/JQU0IJMvPiCCT/NPuQP/noJ0rAFBa23VSr1N/vQhIgxzzB9odMMIAkGvFZPF6JkyIlJeFFl6IcRYYX0ciOOOcll/6l+/3t/7fngPYy4BSCmyT0SGAlgvY4/+BAET10fZjUhAWCg2AV8nBEPQ6D6DJgSUAoQ/G+Dr+T9l/pfg0HxAs/e3WBUhbsihIgHKkHGiGCQHYO/UHomDgdd0BcRkZlYtyAFlgZNtlzqkSJcwc1xr/6FjLL/tLPQG8t+YA3tuXBKPiqISgAB//bjZdkoNE/Rs5EAIYXIAKCwYHYJADlvhalp8RgS4PogNwFN8jgo1A2LoALxRw1gA09TbCAjckQHBZlQEFwEoS0Iv1S3mAYFGPlwOIJn+0v+ocPohEsHzRX9gJYM0BvPvwTyoB2gGsP6iEAowANsBJWAAVgRYeAPCb/WdkAKEAttNJwRbzM+UPQI8K36k9Kf3RagBTe2vhj3o8uAFXLxUGxTdXBrK1AIltTZ2JzUe7Lp/Ralvxvrb5kcWP9nv2fwBzIRF4FRFkx/XcwRljHCGm5Vf++fv9re+63d4xCABVRhOAJoOtRCguQKoCmghwv7L/mBPQwB/KfMQhCEF0ym8RAUkIToUAxrP/gxOwSoDGmn9WCjTzASw3kHQA5poA7Q4g3n+MEMAChiadiopXwHZV26usvB43e/7Lr/pznADakmBdDcB8AFj+5ggcF4AhgAlwwyUM6m+pPgF8U3BS6jOdAAkJ3HUAO5C7ZKBT99/IVDsGhwyY3e8qNfhCERXDa5BrlW/ftaoqe265Ar0U+PIQQCUzqwqYBYfnSK4AcuW8sjmHaMzl1/zZnQDeud3eXRcCrfH/ngNYbyxzAKL8nQNAMiC5gI0gBNz42XIBAnAkBACwqDyWByPlp2BPWP7WD0Crs/5ewq+1JaBnWX8rEajbDiVAlbNpwHRyAJ4D6EqECQcQWfxo/0wI4E3wcPJnUbSLXqH5A26qHaD9kb7ssKaj+nV/ZiSALRG4rwhsJLBfUKt/k3yAJMGwEtCFBGD/PTIY4n6d8ANyaEk/Q/nPUv8h+WeRgXYCVgIwSwbK3osKi4PonEGUC2C2Pngc2LL73Xanlj9bBTg7BIgAFe2vuoxZS14B7wy/DCT8xX/qfn/rrYccwLtrElA7AJkgkrDSJUHJfO/Z/wZ4Kx8g4IXyYKfm0i9QfkoSJK5HghALr51Ce2Jwv0ad9BvAj1WCidKfZf1x3UDnvPQ90HYf7o1WfSQMGbOpU1D3H6oCynpjPE7VfSccpoalMEHNdAxFKkDLgDzTRo5ZaXukz1E34f1Gy2/8kzEB6MUlsjCoCwWMEAAdgOcGTECrnECn+JYTgPyABn0U82vwt7hfJft0rK9DAlHooTSolH94GxBUAnTSL/reAbz6UBADt344SDkIJBIT5E62HgnEAwgFmjq3ChFkAJUFd7Zd9fwsdZ89nnX85Tf/8Z0A1hwAOgDJAxBbuU1usboYCoiCKvWX+L/lAUDlNUG0bD8Bt7dviP9Vf0v9LbV3XQCz/3qbZf2d0h8D+JAPYDb/RAfArL1l92W7Z/OjEICpOZvkw7bES0EisET7M0RxRNkzx78qJGj37rf+MUUA+zoAnQjs1gTAhJNyFy4X7kBtkYHKB0ifDMgrLiADfJMESGa/Cwe0/a+CHsmA5QQ8N6ByAzJZh1IhEobOAegsvwaVDhEKDkCre0cielYbau4SQfIZggyIM0DMtMkc6ywnMHMsduzlt/+R+/2tt2+3d8QBiAtQSUBaEVDxPyYB22cEuiYDQgJtLUFk7539ke1vgAeAR05gC3ekbAclwuaEjEVA3XoAAnLpT6sBCuStrUrIpqsBHhkwcBOVTecFJAteCAFSyk/GzapwBOJofwV0mbEQkNX2p/X9HX9IEcB7eyLw3q8IlPgSbV/LBThEIMreQJkhAeYOIsDrsELV8VmIgHX9ITGo1L+BnxGB5wQY6IvKLzZZCKD7nsj8m+sADjoAVHk9ga19tF1CzSk5GO8T9MCUAdpZbSqEUW17lpNYfucfvN/fBgfwLlQBcEnwdkA9cdGiCjCgGrCpZhACDMSA6wL28dewgKl6GzuI963EXwtf1Nr/wQ0YMb+bCJwAPgKc5gPIPeiImeUC4B5J2zbZnGXBQjI4Mdk2HFNPYqv9MNlJCJByAzPPEezIiUAe7a8ANjPWGYpePc52Db/799/vb7/zKgQQAnhvDwH0cwFWLqBluwkRYJ7AqgoMTiHjApTqR9ZfbLxbCbCUX1wOKQGiO8ASn7XdKgMimL2SoG4nkxGVnqk+OoeBDHR4AN87EmCWnlULBGiBuiNJMFC5RJB8HsACRgYwZ7WpEEY2pNEuYOoYv/f37Q7g3dvtnT3+39YC6BBAv3IK1wVA9p8SAYC5gRDBqz53QDasvag/dQboGMCy0zBA7e/CgoTyszX/VeA35QeH1YGc2Hwr2YchGn5mJNGVd8FdoEOIHEBo9VkeQc3cqFJgEkPhxSBHwoIMCVTAlx1vlggq4y+/7/fe72+tDuDdV2XARgD7isDtd95BpZWjKRUov4Acwa6BT5OEsEjICg1aBUAl8DpwA2kgQeCYbHsjL0zygfKbll9XC5xk3zYGgM1yA0IKERGgI2PJQJ20M13CAQfgWv1kEjBj+Yc2zlqAGdWPgBPtrwI2O16FXMrn8Ad+z04AaxVgTwDiasAtBNgnrK4E6HBgSApichCBBHkBCnQNbmb1iTPoSEXlDXCfTv6x0EAA2OUDtCPA70bMT6sAXjVAlf4sIhieC8BYXy0CYk5gIPKCA8CJGzoAI5QYJqoRzx8NAZ6KCLLgzra7igSWP/i79hzA6gCAAMQFrBMNSUCrFypUm+x78k/cQRffY45AqatOGDJy0CDHkh5dDERielFhWvrTIYHO+icy/jK+qe6sCkCAH70erLsXylXMWv5GFowQrLyACISU6HZ0W+RALX0Qz2ug4NgYUWScRNQ+q6IZ8GbaVMCdHS99jX/4dwIBCAmsoNd5AHAB1sRDArByAV1YgLkBnfRDF6AtPbP4LNY32lkOgMX/tPynSKFzC466Y2JP+mT+mk8BOiVAVP2MA9COgH4nQGcgHxyCAe5uMicqARTcJ+QBIlB5+6O+V4E7c9wMCSx/9HfkCEDyAMPDJiQZ2AABqtZUVwG7s+ZWMlCDO/F9iPFZso9l/IkDaMRgxPqe4g8JQa30yg14pdaM7TddgWHxXcUPVgLqvnqyWw6AqrlT0jPV33AekYJb4IlAdfX+6LwR0BVi8Yhg+WO//X5/e68AyLMAawlwCAEwF2BkpTfgqwlu5QU6G45KrdYNsNi9qwAQMgjBnyEDI77XYGcxfjXut1wAhlfSptsGoNHJPab6XkLwTAeAk1MIidp+mJlRJYCqPxCABwizr0aUDl3I/ogEMsDMjJEZp0oYjECWP/HbSA4ACEDWAbA8gJ6MjADWbYP6i5LqvyRROBBABHgjXEAV14k963s7d0koOkm/s+J+FiaERADqbjkAHKNNrsRCoE7lmYsQ0HjlPm+dgMzKRLmQkkgyBJhR/SPWPwPyTJuriWD5U78FHMB7eyJQ5QDaYiBhXL0mgGWumRNQAO/KbieTASMOL8bvVgUSq2/lAvAaOvDiwiEjs6/BThdZ6bUBJNvfuQN0Z+pzVzI09nXqrT3UMRMAACAASURBVJcKg+J6xKAnLao7Tvruc6ZcyBS6EDpUXUIEvgyAz2oTnQuqe+aYzT386d98v69rALZ1AEIAazVgz/4zBzC8aorlAdS2rkIgC4e8v2TxkOsGMLeA45I6vgZ7ygFg4g8JQhOdl+FPZv+ZnRey0CQhE4PtH1TfCBmkXQd+S+1ZXkCTiQZq0gG4sb6qMHSAKFYQHpsIMoDMtKla/syYy5/9Tb0DWGP/7R8QgOUA2NtnzEw3LhRS6hjlA9CK6/gfS4XU5rOk427p9bg02cfATtS9CwGcSsB6/taTf9Zvx0ItvQ2JgH7WgEYyMMA+5AwmHMBMDsAjAhrPTz5M9H4mggy4M65g+XO/YSeAXf1lLYAsBca/24D7MwKdakBIYOUBxKYyJ0BDAeIOTOW2QI75AgVkXNVH7b+VBFTgDisAQda/gd5LrCrlZpa/WXJrEVBk+cGxNWAkqwDMQWiFNq2/zNKgDOi6A2NFICULRAV8rrSN7HgEzmh/NH4G2MZlDi8qXf78Fz8QgNj/thjIcADtvw9HNcgQwGxIwPIGLHTQVj8BfszWmzkAlZsQwFrlPbcCYOUCjBwKKwl6pUBRWyFhukxY7LmO7414X8f61BVY4YLY9iDBhy6BTX6LPJCoPHtcAXelbQRUD+gZEojGZyCvjrv8hV/fOwArBGBLgnFpcGdJYUJ0gNknxLDNCwm8xKEV6xtqPwt4DWpm92kIQICN7bSNF2Xv/pLfUgNd5wxoCEAA34GbqL0VAmhSuMIBuIqv8wGJRUQWmCzAfNIQwV/8tff7O+9BEhBKgEMiUIUAXjLQinMbAAAcCIruFWMVgBPFX28iLhW2Yvzu+JCo06A21wAQm69XRVJwk+RpaiEQCxeQKEDlaWhgtEWQWEqvt7vhwoQDKAFfjR+5hytdgjf20X1HLH/kIpa//GtUCLATgE4CogOQz628IwzslKx0gosuG1bWnuUGotJhyzUYYUIjBSsnoJKVXZnPCAeYo3EBH1UDDIA38CniiBR/CA1I1r5VEQBUg/1XVt8jjG7iWZUD5WEz5UIK8sRagIhYquQQgfqI/a/aeBYKZMOD5a/86r0MCGsApAqQcQDbgTQBMNuqJ70GE/nuOgMSGjDFj7ZZhNABnxBTIxon459Vfa9yYpUEEfRU5RXounEUkJEgGJlEYNb9O2IQ16hsO07y9nk2ETjzJKG4JIKUSlgQKqyDzgzQM22ic/AcxPLXflXSAew30no8eDsJvBGWyhmJsKojQOAOi3R0yRFtPcvuqxo/tf7qeryYv2T/mZqT0IARgfzmG9Eg6erP8Jvr+4Tk4Sk6IwnWfgA/IxsCPhmfKWuk3ugcqENIgLwC+hl1j4Ac7c+CPDNOd4/++q/ccwCRA1iFHkqAtBrA3ICh/J46Yp7AjM+DHIK27t1aA0YIbKGPIisrw59NAOqSH/0NEKyMCBS4qwnAtNpnk4JGnN8pfKYKoIgiA2R2DEYglW1XE8FZQI6AHu1vv8nf+BUPBNDKgFYOgDkAsHdmQhAnkhP74kNDg72OwgMP0CRuN90GW+CTdCwWoVluQKv3EAYQ1cZjuOpv9JXJNyT49KIgliMwlByVu7kJUFwvPBjcQuaxYSuUOBAGZMjGIxEP1BEQn3z/3/oi4gA0CQD4uxAACMBLCKLNjFSPJd3Q7rtJOWu1oZNcHMgmE+8H5T3P3Xj7OlCzCgEeN+sEVDs8Rpu4Ol9ggd1ScuYWkAQIsDv1lrYqB+BZ/2FfsBqQAe3sbZG6Xwn2aGzr3Ja//cuJA8CnAXfr314SajgBkwBwAs6EAwmwWWFChThY0s8iI297B3DDPYRtCLi3Psb2AdRAHrKvqb9BCEyNtaKXS4OkoqAnomXjKUEo9e/GSjqAs0HvAS8C5WzfaNwKES1/95cZDmAlAbIacPudIRcgi4H0oqBuUirgU6WDSVtJsHnJw8gtZNyGWeJLEJNn61vZzYjzo/3dQ0Ea1DgmUXMWAqTAbil9UOaLynttQj+iAzibCCLQRfstUM+ShJiqqP/y937p7gDuex5gBz5bByD23woDMA9ACeCAG8jkCLTis+8ZUhjCAisZOKvwySw/OoWONFWMrmv4ZsWAqX+wrXMGbLkwnMvgIowEIWuHTsV1CTKz978WeViA88IKDzRnA/Ts8TyCcUng7/+SngC2twFZJLBPljIB4IQ1wgA9waPM+rCfJApN9Tae1beOGZ1LO06CEKj7UbF9A7CVB7AShIa9R3Uf1gOwhF9V6S1iEEQFDqFN3my14IJEYNYRTANNERd+PZMMIsXXp7H8g198v68VgHf2uP9dBX5xAtvbgaUUqEqCg/1HKweAlx9vsLeGIlqxchWojCyqY1RCgXK5jxGHofIsD9B+V92nSAgIxCEkgLEGBU8mAaO4PgoVmEJbOQQG1CzIs+08Msg6kAwRzJBOlgiWf/SLRgewksCq8l0YAKBveQAgBGb/t4vDhJQmAwf4a9dQeZPWnJbiHMfgOYeNlAKlx3BFOxs3L6B+LySS8EUg6rzwuEgQ3luBGugDqx/lCzyCGPbtCBBi05M9Io2OFB4hEXgmGLMgzZDEjIvYruUf/0I7BGgkAJWAbY46SUArGThMyAIZVADH2ppEkiCBir2n5xmpu5ME1I5pUH+LYEnFICKEDpiFEADPSSu0JhQX/MphTBFBIYnI3MRjgLviLs48H9OR/JNf4IcAK9bxPwoV9TerAXgj4T0BOJk9MhAQDZOfACUCNgIy0zbTJpPZpyGAQwTiKug7AYkr0L+N991Vf00gpGyHINbK3yZVMQQwVT2xEMh1BEZ/Nvk1EKsKmgXyGeOeTQQdEf/TL3wggNX2b/H//jqwLRGo1gC0HMCeD9AlQPw+WDqZJEZIoCdaNY6OgOmFAVq5u7ae3Y9AHam7sd8kApUsZHaekclAvrv86eoBcwkZkFvrA1hf1wU4Cu4Btu1T/c8G/hWgrxDEmSFDc0D//OdDCEAqADoPIMnA7a8wrv6LpSEFfJlkoQtAdfKShEmAWlUDN7xgOYYE6DPuBY+Lv0W0HRXdK/cN2X6l0jqcsICubbx2AVeFAK7Sy+zV1YDiasAjgH6MvqZth+vXH6sksfyLn/eKAFaw6yoA5gEE9FYScDsZZfsR8CwhSJNb2Tq5UVLsQO0lE5Pk4bqRiBDU/oEcHFVn9X1T4dFZ6TKhYfWZcltqbm6HsZm6D07QKuGRcqQGgEUKSF5N2QySYPutbZkw4SmJwCIIJIXIYSz/8uf2BEDXAWAosN/w7gUhAHwhge7GY2wGBKFtf5oMGKgcl1Cx/wKwKKQY2hWB3oHbqver7ab6J8t/2L9VbaR6sM8auk4gArlRNbBchQnSaBw5RyV7lRCAgSYCerS/otRZwqiMmSECc7x/9XNUDkCvAyB5AAwDtrlBQgG8KegCOsvolQgrgPKcQKTQSReBhOCquBP3a8LTToXF/vpY8ls2J6AdBFH/rNJfov4YDoL6UzVP5gDc8MBJBFbBnwHrWW08EEcqrvhw+5oNBZZ//bMLBCDqb7kAcAJtUQeyOuQDcGIPnzFeJQClSbJqngBULW3xIzKpkBYe3wGxkISn/u5zASwccLbh5NHhht43ELsFcGeFXwfmA1UAdBsZ9YxU/ej+zDkwJ+RtO5Mkmhh9yc+637cKwJ79lxyAlP/kKcC1IqBzAJgL0K4AQwC0m7hgyAsBrAVEaL0HJU6SQKeiyT6dWictOwsTsqW+9ttosAax/pA3AKJBEqEhQLX+T+J2PG9GEIxEPPC6ag/SNzhOtm/fZo3JABYpfLT/KBFU+leUvxHNR37mSAAC/lYBUDkA76EgIYWOAHASKnXHm4/hwaB8pIxIV8oFFpxlziNws/0diSgF91bwuQQmE7QQ+2fUvwO+pf7KkXRA9db6W6QB1+KCHu1qMgTQE70DoTOG24/Y5qMuIEMOFYBXQ4FM++WjP2MnAFUClGTg5gCEAMhy4M4F7JNou/eZ0qBWELD7qO6D0uNkZXmEwKqb4HXI4wzAa8ejLTYSjb5mfXz8jgCvlP86YrhC/ZH4lfpSFU4SgAfMo88TZFxAlRgyY1aI4Iy2zQF87KfbBLCVAAP199YCaBJAV9AlnAxX0NqwnIBSrHSSziAPa/VeJt/ACMp0AY6l1+CNvofqb6h6NikoJMMUHN2apayZNt3YxRwAPa6Tb2iTXj4cVP2MwkdkUQFz5njsGt1tX/rTHghArwHY7P++DBhdwDanYCWgzgPIfh2TtfUB+6QcJhcBedfGUXoGwAaOyXhdKy4rC1rxPAtlymqfjP0x5h6ArVSdARJdiQa6BWC8t3h8RhQ616AnY+cEigRQdREWUZ1NDBnFz4I5Y+OroMf2y5f9VE4ACH50AS4B7OD28gDtxyEVgW6yOIQwWGlg/Uz8bQLXcBoa/AM56Dq8FcMbCTyx/o3ISF3fsvaMWPRv7JLEPht08nC4TyTDb5UNI1VnwO3coaHQFPBKxa0QwAO/G1LAucwA+2oHkDkny2Vs27/8pygCANUXF9D+h2CdC1CA334rcQf7Z7yxsp8qiFpBOKhPQAiW6jIlN9UdzllAKQBjdtxT9eF8HJLQ5xNae6Lska1nSu+pfyMjb3GOlxwEYrHANwA6sO/abdBxyRiPAf4ZoGf6WOA9y0Es/+YnAwHs4JfsP4v/JSEoTgD/is1veYFZEsB+xAp7gDEX0yRU2asQaHX2wD8QjEEsCDKt0pZqM2LpSqaiiNpteCW7mQSgukc4UTWxsH0Z8EaKT/erRGIW/E/pAo6AOdt35+Pxvwf/t0gA8BKQFfzZMiDmAYakoJ4oUB2gE4UtHDLiYQSa9bnsDEhJj4HfdBYHF/V4Vn8gvh3sh9Rfk60ot7c9Uf+Xc80AkDnCNGng+RrnzCa/RS6Z8zXBJDv0ORnf9bHY96Pbov7LV/ykMQfQrQMgVQABvP67//60BKgXA7UTU9Z/mDgk+TeAndjrBtpCBcEF9Wz23on7j1p9TW74mzaH4jgC/Vtri20uDdakzvIDbTL0y1I9Gx+V8CJHgNeTBfIMEXhjz5LDU5HB8pU/ccwByBOAXQ6AxP9sQVBL5EJGF8uByPYDCehJE1UGAuB7JKD3MadA22iFx9DCiPPpeZAFOZWyH46Jk2cDPiZFRX1IvI7XrMdg2fsOvCRsYGMM25QadgC8KAeQIg5BblAajOL26v5Z4DPrb6m95wKWf/cTxhwAPgJskQAu/aUhAIB5+22J9aelQa0uOuFFQoRBCY2Soc4PNBDBMQVAGJ50amqVI8kYOH4F3FTZsyU9EvuLMs4q/NBP3SNT1Y2FPQyQcs0RYYT7JxYTZQgiAmoE/Ki/8E80DgO+RQYe8Nvx/v2P3wng9updALgAyEoEYrY/ejS4katyBegG2OfOEqpSX7s4K0QohgVUpSft+5VgR7BFsb/nEkxScByD/s31pB2IIOMSIETRE9YLF0wiOGMtwcUu4EoyyIAe79uyEsDwIhAsBSrrT6sAuyJ0i4KU6p9CAkpl9boBNuHT7iCw9vThJBJfe8erKrt2IZZjoWSIcTkLCTwVt6oC6nojwLKYvuoWIsUf1DsZRljn7m3PAPcMBY/GqIK8YU/IHTYs/+HHKQLYAd+tBCQkMIQA7L0AQAxo8bbjI1MXPiOIqMJNOgIEly4HmvsUIaUA7oQ0tD/LuBsAzTqC7XosUnAy/MwBZADtKTl1fjhB2aT19j9RCHAGOWTGyII/Gyos//HHAgEo5c8kAbv4X6m+lRDEmy73EtViSEA5pcFOIVTSMHIEAgTLVuvVceXVeFWwO3F+ByIW5zuxv1ZRRqL6d2TK64E1Y/9dIiDWfVB3veqPEcEThAARcDNgPKtNdC6Dw/lPP+Z+fxcWAOHbgM2FQKDsQ/wP+7TSo+qzsiAqk1apLmGoVUor4kTpcCCDALzZen1EQpbNp+QEjgNdiZWxN8t4pCKQUXeLOChZOFacEoFxTmzsYRIjEZwQAnjjRwCL7Hu0PxofLnVc1IM7gzxGE96vWgkAHwUWF8AWAuGDQOyhIAQ/KwPu+9t5KmVvJwXtMHSgE9BQfU0g7oMy2g4byb9ZMFtkwUCMhNDtJ2VDDVoNLBoSEBLpQBYB18kPpElkv9HM1XRzwFB85gzw2BaArX4uoRRAFYG7up+RQYYgKm5i+aof/RACiPK39wAAEbB3ArSq3v4Bl//qpcAa8Nt3QhAM7N0FE7DTSWc4goEUAAwm8Ky1CNYCG69syWr/BJBWLkArvWflL1H/iDwE2I6dH0hKJkeyYtCRFYCThSdZYLuEwo6hCGwGlE9FBsNx//OP2gkAwwBJBBoVgK4SsE8KyQWwuJ8RAoIdCQJvpMXqVnlQA3z4TpRdjsHA1IEo6hss7JFzQQDQYwaE0AHAUmMrSWgAmJKomuRH7D8DmOVWGMAjgHb7T8oBeORR2XcFOcyMyfps2776C/ocwPr7df8rkEMC23xS/0uQLgVm3IBOAHYni1ldneHVcSMJKdbJEYYOQU7BDR+M8VMZeQZUY1tHVNYxlQJnQgJNKNbk9tzGAFovx0CWDXurDkPF1+MVcgBZhzDbbgaoVWdQsftNaIHcNwLQIYCQgCh9SwaC2jfgQ/lPg92qAnQnokIB6gCUcrlVAqNsZqqco+xMtTM2/FTwVxyBofAsvGGgNe25UxqskgxV+ETIkCaCAgFEzkLmqdXuqZ1ARBam6gMAl6/5kSoEUPYfwa/fBNSeBQBi2MZW7wRox8skBgnYTUfgKLeA11O4KDk3gJ0pWzI00BOYxuhOeU9fhwXWqdg/Io7MfuJKKNhBfRrAJisAFJgH1wF4oPYAF4HxyP6oLwN6xhls/f7Lj7jf5dHf9hdeBNoRgJH5L4UB+2TSpBDmBADsCG5U9izYq+Sg25uKqqsJhnJ64JdrcC13Mfan14tAdDL76MhM0qmOFdh2fRxGJBZQoycKI7BkQZ5tFx0v2h+BPw30BrhXH7bweCOA/eWf+kUgFvjxKcChGqAAbuYADCLQ4N5O14j9I/DjftcGe1UDpn7Ogh2LhCrHfyzw098Hwews/aVkkMzkD8qd7JciggNJQItUjoC0CuAjxMLOMzz3r/3h4ADgLcDM+ktOwKwC4HJg9ZmV/RoXWaGBUv1TiYABO8ofWLHwRDLPBd8JCn8quLMWPeMkiPozK5/dNpBCkAPIgnwWiLP9QqAqBc8of6rN1/3wh4VA8gRg9AxARwI7iFgJUCcAKwlBFg50lQIdDoCbMC1rpYKQrBygW+kUMcjkR+CsxvHus/sReCPQRvsR0A74rPCBnXtK6ZVTsdzgYwK+ovaVthE5zCi/8MnydZ+vQgC1AIiFARveINHnJQMbNlHlAbDbiTj7NBmUiYCoNqsiDBNUT+YjoHaSh3Lz3BDBcivedkaSjvqa8X2ypBe+QEQBVl9vBHrmCCi4H7EKcJban00GFcJYvv6H9UlA+i4AXAuAZT/1WWf/LdXv8G6VAQkxlMHPMsJFJ3CJylugstTaU2FPdT3wZpQ9UZ4LiYvU/TswJ1xDRsWZ88v0a0oIFjtDNt7YEQCPEEc0dnX/AwGQ2P9oDkDCAvld9XdP9dEV4I3tbpaenMZ3V2lIn0yCSlv0wyTh1Nkz9p6ppxVGoFU2VV/UOqn+6NKiMbtzdQgmcgRv1P/hJlXdw/C7/dcfajsAifeFDESU27MB+wa5jzoUaOB3LD4SA4v9NVF4LgAnd3ehgeozAHugHianEx6wCR+FG2YeA294whVQYtjvWQRUMw9BlDIkG7b6j4VmVrusOp9s/y0ncJX6R+POAD4kiI0A4L8BQ+Uf3gfg2H/2MBBTfdP+C7vAzdaPAFfIwLSERHVoIoqUBjNKm3EDGVIwx8kAOFLuaL86hkkkxcU/jDgrSh8CUhG9B6iMzc+0iUB7xO6H4EWszLqBb/ghJARgTwKytwI7OYAhBHBcQDYckOtlTmFYABIA3XILbCEJ3QaE1ampsRItHTbsF+mqqpUryCzZzYA/QzJJN+ICPLFqLwPCI/F/aXy5N4YjiRT6akB7BGmd2/INP/ghBGjJPwL+1QnIfGf2X8CuQ4GGEZXoO9UFEOdwhAxYDiCtXE79ngKh2t7LFWTAHwAbSTEKEby2kaqznEHUJ6XmCUJJjaPUdFbFK4CvtI2IprJ/+caVAHQSkD0ObL0MxCgJbnNNqb7+XlX+KATYLlwdky4NZVaRxY/ZcMGLZwNHkCaXCPwZ1bbOBZXNyS0wkJruSKmll1w9CsrHdACzZOBdYwWwYj7CcAhcijf+8o0/KHYAkgzs/u4Trqm+/g7gKYUDRNG7F4jKhTlAbz+SbgNjdz+g0S5yA0wFO5AQAnHVzwOoZ/vPAn8yMeclKSMlPwOspm1nhO2oeRZEM+0qgH8q9d/O8ZtWAig4AMGQuRDIWQ48JAUBkO3eRcDWuQSi+pETQOBSdpxQ/kjJI7IYljkrVXaBlajpZxbqeGrOQEDzGqA8OoywfvdqHP5+IICznEKFSDJOYhjvm35g0QEkFwIh2Bm4w3AgcAJ6MrV5R+y9BpcmCFQl+oOz8MByE0qNu/EK4UDkJBihWHF7Bvz4m5jAJct+I8Wn+6+I1a8YE0k4+OwBtaLwlbYZwIfjrQQwrP4jK/82+6+2y8q/IQmolR2SiNvvqFUc3x/A9jOwESfAgB6BnxGJFR6E9tWbhJ499ey9FUbIhDT6ejadAjwKMbSVtkgxY7kvAOuZjwFn1fvq0CACeAhucGPycejzzT9gdABYERheCLqDUQhh+0qeC2iYNcBvWf4wMWgQhE7+CdHoC04TAlFy0zkY6+41udAJkyANar8JKVIHEBFEspYfOZLIxofkmSEOr82B+H9WvWcIoALaStuILNj+bdtKAF4JUKu+uQpQx/5AFKj6NBwQeiLOYCCxKEegCELb++GHcCoCA2taYHXU0IrtXTJhjsd5kKcDpziDBEEgQZkkg+MBWVigiYjA/T3gZofjGI4kC+azwTszXgTaqwlgHX/5ls97tRRYVL2tADRCgUH1yYKgDofE4nc4VqDG/EGbE0ZiziMIF/yGYlCHYJEKKzviJLaOEWTbQ5CQpN9AAhcoP5JWGaBA8lmyKYHZI+FgldwMeLNhgncNlX0RWczufyAAWQqcjP2tCgACV+Z+t0RYAUmIpAOxEdtHTmDbTybBsHaAnIMmiuHmatcBk9m8iexcEgrqVgP2c6cxvFL+LMii2HkYJ5Er8H6TaeL4ANj/CKSPofiIowcH8P23COBGnwHQhOBVALxHg1l4kCED0mbIEVjqTIhk+4GT26dJIXAF0yGBQR4U6MR5ZNsNTkIRS0mVsa8ir+o4LnF4ZKvPYXKV3xWK/1o4gG/9/ioJKC8E9dyAAXaM75sDANDp+N8LA7p3CyjF1Y5B3xxKEsZ6AVo5SIDYZHMvGRUlqqLseLCSbzunpBVGMsy6hTA0icAWXf9sIjC45irZyPzKuJUjIH4KxR8cwLd+v50A1PMAmOzTnwXTYvkld7Bth5uM+9uBo3yAodKR8uP4HUEQ5dFtGYEM25QCDwQQqVAEzAgcQdx/JvipC4jICX50Cpxk/wzoorCkAsrM8WbHM0WCEGXU9qr9y0oAWwiglH8LCYz1/w3wqvznqr5BDhqsUwuEqg5BkUwHdgOI2yGsx02tHIHcaGd/pMQIbArMRF7hCGAwFMqAxWwTEdys+sO9zJzfjBuoKPVVba8lgGISsFsApElivyE45wdXADdNhwUdlkm8nnYCCeWXY+l439tecgvG5OxuZqSMjnPoJnwWYJETYUoenWOkaBP9M2C2yDML8my72fg/Am2FLKKxZvZvfb7t+77KAWxOwEj8NXUHp7DNb3QBCvwSAnSCq0MAQhiitugOcCzcbsX71qrAri9OXEY21nMGHUu9GnG4oQVncMg2Z8FPSDEFNMcVHemf6ssIidw3a6wsyM9oVwXhUQLwznkQMVIKbQRAV/45RKDJoAHcIQMhiwjUQwjQscer3hYh0BWBxhhCNCzej/ZZx9FuIsolHLbMFUWfAXIUviAY2ecKOUVjMTIoXH8EmAwhRSA/Cuoj/c255pHot33uQw6A5QFku5cLQGAjMSDmLCcw4BImixUaCDCZkntuwGtPCcABCx6nHBJkVDg7qSuvwEoAcQDIBPi9MTIAKyt59rcKyGWWHCr9IvJ4kv2NAII8gIC1Wwqs1wUAoi0yEABrx82UP+sGziCFDsgkHLDyBN1N80gjqCLg+CkQJOPqdn4BUOhEniENVJtE/2x8TduRa/IAmT1WBMSzxomO8yj7P/65r1YCotIPn0m8j28BFpVvwGdkoCRf2/gOd1k3MNgImIEEyBZZYEKJugVrHYEoi3EsTSzu5HEIZCCFyuQPnMIl4If7kgVMtt0hUkOCMj5XgVex7VM2XU3IlEAQxyPDdP0//n3GlYAh+FWs370OXBbbqWSfblNxAlbbsuUPyMLLBeA9YLafTZruB8+AO2vps+32650Flqem4b4T1d881oyreWICqJLL1e2XjQDkjUDkmX+d5WffEVeWE0CBNJU/qfq6f0eQBdVv/Qw1tdyCBWzGsDJGqBIZgiCAzjqK0kQ6A1hnjOGBNUEwIUmd5AAqxyndB0PFw7nkOAY9R5ePf+9XSUBGBAJudAVt234Ttn37xi4ESGyTE0rnAIBtBqwfAD/+Zl68r8nGdA3RykEsy2TtfJYkKsfWk+wM4GavJwnA2fj/CDCPgqzSPwoLov1HSOUVAeBKwGgtgJH80+AfbL8OC9A66Od0gFy0UiuCa+Sjt0cKboYQRGmHsR0w4vmGE0GRltk+AapuIlTbG9dcDh8mxpkCauL6wt/eUcojfY8AUiv0Wd+tc3ogAA/8xsKfDuykTVP2/YO1GlCLNnUCiii0Cpu7LUfgjUf2WTG/JgXLORwFtbkE2VLQRNKPTgiHjNKASBw7PZZ2J0Vnc+Q4ugsk6gAAG0BJREFUVVKKQH/muZxKCp/4Xv3DQGLn0fI3sEerAPVTghAaaFyllgcDi1Asq43t6yzwI2IIKgHiOFKWjZyjZ3XZBMuAOJqYbTJVwwuDfIb/l8FR2cy5VX6Ts0HmZdunz90i7eClJZnjZdoMv1EjAMcFbLiYAT+x8TpX0DCeAHPXxAA5XTug7YiW7on9NPYPwgLtEEKiSNjcTg2y4YSehCeBv+xUZid98ne5khCmwHaQDGeOGfVZVgKwqgAiiBH4U2XAfTCco1qxNcAZxiOAm+J/kSvwEoYU4Anl325ath0hr5BYNPDYq9Sr4LzY+reJfBZZVa/vhPYRGGf2Z/p4bZZPfM++CmCFAF4YIETR/upnApw3AqUJAQ4ShQPD/ovA3wjdANDwwxvKZbVjN45uSwI427eqnIywpsbIKOT7iAAy4Ix+p5kxMn2kzSsCCKoA+AiwJoOOAJTtF8vPSAK3NSFLhAJdPwLuTKiwHc8jhsx+1YaGBSRxJdeadQgWETBVTJNG0mVEE3TbXww9yg6lmPzL/gapawNSitpXgIdcF40783tlzmUd94EAEiVAuc8m+HWOoCH61fxAy19R/mplAElHicqrryeD3wM1fVkpm1gBkOgxHEV0gZA4VnpiFlQ5MzHNNoXjpM+9APBozKuI59BvpgAwJgE/B0KA6CWgrP7vZP4bWcBJZJYEI1FYQuzlAtw8gTFg2jXs12I+diz7gQA9tu/2GaRkOQvrfYapiZgNR6znyMn1zQCkpG7GOZfG0PenQAAZIM6cS2bcq9osnxAC0C6AgH14+Ie9EIQQwoY5FRo0HAbbKY5In3Yf2QtHEGVWiGEAVhHow1cHPHgeJnAZqAIll3GrSUdKBkdyBmQF41WTsxv3LMK6mAAe5bdwSKt6/AcCMEIAmevrbz88A7Dv1CofVQQ66w9ftAJrMdSuAHD46ucIiEGDeRDcKCwgB43KgZYa47l4biIav0QyybjfOufhWGcRiQHK7nivKQFUATcQ+Ylgnhl7+cT3sEOARgDO038dATjZ/w74AKTM9q05AScjBY8YEHRVy4/Kr4mEKZXbRnaSa/IAvR3HISk3CZkkr3AMOPeM3c2SiTtWAfyzgDyz3+xYZ/6e6XPoCMBZ9tuAboB8cALKIbT5x54H2CeVBrkGOHUFHjFQNlBJ6wnVZ+AWgogA3Fg6cVymuJ1zME/kYQdT0CwgXTUpEFdmUodtCgQQjrVf2NXtMuNn2lTu18x4rxyACgO8sp+n+ts+A+Rs+a+0Z1jFfXS/ASLLGQxjJEAYlgpn1FwdN0UazloDD6wR4aQVH4GTPP+ZCUkn/MmhxtWgsu7H7O9x5fkun/hsFQKw5B+AGsGfjfc9UrDIYjukmmjatlv4taoAFduvyccFWYJIvOSdFvIo7s8Avps0ScBaE606VoVUdFvL9byO4Inc2PvhnEcC2CfL+mf7p+P//ar1dgTsEA7AmJ1gFrZ36k36tXEjV8CshFwT3tEsqBPt2rDQNqX68GNl2kfEUQGmpcQR+VSOkQJIQf2vUMorxkxdd1R+hbl6aLzmAMhCnuEZAKPmrxW+EYAFcGtpsLM9dATgUrSiMvLQbSruYArQCaKIAJxyCjgxnGN6hGLuyy55npicFuEcJZSjAD7aPwvOK46TGfPBAej4nz3959T8B8VXYMR5aK4HIACOLD8DLZvzlp2nZiAB1G1+J9pVbD8jrdR6Awts5PymQL+Pf6j6EBCCNVHN/7iV/lgq6XkWCcn1k2NmwX2UxLLHyQBeLkPGXD7x3cccQGbdP1P9UPmt5CAAqiMLOVvD8re2XkjggHXASALUWfAzl4BzKLT0wblk+kdt0vuNc6lMbBPkhtU9tMpRgfUogGaApfmi8lsdPd9S/44ASLyPQEelZwlATQqIPU/56ctB1MtEGI61slP1NybvU4LfELBXmxMZfzZGxnGkQY8HgB9rxkVM9XkK0imqfYUYqgRYAnHBEelxXzkAJwcg4EOFz9p+5hSasBPlZuGCMgIPIkwmiN50RjWg+22zDsFxHRnwR21cEKtzjADvTUx0OzMgjsY2VbEI/iq4ps+L3JiKslfPszJ2pS2exwMBZHMA+8Re709HAGxxELTtnACgWZNIa5ew/APY9c0xngno+qlBXHxfDP7tBlaOwSZjsn+GFLZJciAMOUQYRQI4dKxHBvWVJDAz9vKJz4rXAYjidiHA/sPRtQDWE4LGOwIt1e+2KxvgEsD7DPyotNPqXwQNO84ApIkxI3IJwXryMcPjnUAAVeCd1f6MaxsJgNX9WXjgKbzlCIwyX7vn3jJhpZCUAGBjRBCKTzjukoraOlfbp04iooTk04mFic4I6QiwvQkvp+XlL44cewYkZwF0uDZ1D2Ztu76VR8ZZPv5ZDxpOwwDr+X9P4ZV9b66B2HodRmgXnHEGrc8Tgz98B4GF4wJp0Bud7B+BqDu9fcxMn6hNaT+5llL/IsnNkMNMn9eZUDYC0M/5I2jXzxqowzaw9l1bZzsCl1p9I1zQJCHkhffeVH+HJBgA9HwysZYE4TA/Z/sZziECi+clPAXOKg62y5xLFHJMjZFU2ciVnA30GRJ4jD7Lxz/zVQ5AwFVa/rt3osAv5gIQ3A+25OFuenbefV6AlBLZeBb4U/hMNSLQC8gonPyzx7Xq7gapyObwfKJx4SfIOJmzjveYQM78VlW7PktU2eseCSCI9wegW5Y/SQwakDpksPYLM1juofVTQHFxE71NKGkJQmyGDTyt9qsFGeCYo8N5ZcfJtnMnsvo9smNm2mWBUHU50bFnjvvYY67H6wiAvvLLyQPgk3xWqKCFRZSdAbdti5KBilws8YrcAd70cgxfJYtAYQPI97uPEog62DbxCmNGE7UKJjx2duwz2kVjXLl/hiAihzEz5isCCFYByhzRCj0A37H92xjE1neuwtmP/V1nQBYKWfMbQ40MCKvtD5EMO6ErgBqMGQGBnWa6z37sdPujoUYUipy4f9a+R0A/c9zl277bXgXYRQABjsDUIK0Anym7DiW0m2CCaS0ZHsggafuzYO6GSwCQNkn0CwnojDESYUwFjDjcTL9osVHZTTwigCMgvu77txCAEkCy7s9IAcHI3IIGNoJwIAV0ppmwYD+4xgn9HoCpAuIQl0aDsF9nH0J6KDWo2v5DKk86zxy/QjCZtq9Tm+hcrtq/EUCn9M4LQIYwYL+x5mpABUgK8H0jgmH47IC/U38Sl1fBnwV+GryzuYILwd+GTl5ENPmyzNONkzx2xg7PklP2ujLtHqtNdJxov3YljQBEibW1t7Y34CVW/Wngt3vv9MXxB4sPd5w5CBY+6PESTvihCUzU7JzF68uCwzrnSnKudCx1MZmJUxo/itWTP+bMeWX7PEW7s46ZGSdq00IA+uYfou4DkEG9vX2W7Weqz8gBccjcAQNPRfnNuUjcCQPB6a7BZIMqBI32SfBVjhZNtm6sxPFL48HglX5XtM2OeWa7zFhWm+VbP6NPAgrYXOX3VH8fwFT9qEqg+rvq76izRxQZfEVlQXcOJ4nDBdgZY6TZKoZ6ZpLFo4iq8JZHj1Htf1X7K8bNjDnTZiCAyPLPxvs4LnUEiaW/HaifCPyReEXEkSGfM22/nO82OaKTTyP4QMOLQo/M5NdnfXWf6viZ9pk263Vm2m0hwOoAUK3NxUCBsrvEkFH9YI1AN3+zFYHki0M6UBog8bCDYcth0SUHOgW3pwxyAPiJ9wvMjp6Z7Gzsx+pXPU62/RntGgFYyt/IQVnS9au3DwHL6vc6RIjWASDIBntvOMvsSkAPwBZuuu0HQBuNUwUFPd+LwZ+diFc4kPSxyQ/52H2rx6u0z7bV7ZZvkRyAEddr694BP3IFmXyAE/NHlt8iAv2fjXju1wJ/Cvhq4AzOzDZO58y4mXxClUxObX/4IvqzyU547xqOjnGkf7VvpX2p7bd8eCIJKIpLXAFTfq322jl0feCOee00qC2HYIHfUt408GFgb26n5v0JawVmiOVUgHuDpX6E+GwqEzseLRcnXz3OzDVV+3jtl5UAEKAIOhO40WO+mZifOA5KBEG7DuCJhUADIcDkZPPUJIQDil21/dP4KXYsNs9g46HNgYGrkz1/UucRwHrMo+c527/abwwBdgLoSIAou1bjSNU98jD/81Ct/t7/IyAuRPocAH9F9be2pEM0x+l+tTEag03u11H55Zy2yTZzURUUH2xbBVDmcEfGfOy+yzfrEMBaCrzfTAbsiBwyYcGg/oSEAOu9sKi2oe2fUP3WJQnacN4XbH84lp6VB9xJZoKn25RPPD3yaQ2PAC5zEkfHP9I/03cjAAbgAegHFv9YBMEsPyqsPgcNbNaWgb+bh4QsNLHgjWV9Q4IxZoZFIubxghmWcRWZSVrgj/xwb8Df/VYZMEY/7hVjPBAAgIIqvKHGkfJ3Y0UEsl99+L4AaQcoxLmm593Z4Gfz2pvrw76kg5giBXIiV+EwHDdsEE336/efAaiZszzzuEfHWr7508k7ARXIEMjMGZhKnnkpKGnDxhu2ESWfAX8K0Jn/ZwBmgjn3E7Y/i5uIWDITM3uszFgdYV01cPVEgvZHwXP0dK46fmXc5Zs+nZcBN8BFqn10v7H8V5NMZ7kTVYHBoicBTMkgqaqhC3AaRHiJ9m8TccJZeBM4dUw2wIHrjABVmdjkJ2nDV8eJzuus/VeelzX2RgCDwnuLghxV74CbedQ3Uy5MvBQkUn53P7odreIJUFnzvdueGKdq+b3xLwF2NqE/zRxnweiDNc6VpLD+Uo0AGnjBWg92f6dVur2yNFhA59h4nEfb5+T6fw2MCPxU9ZV8mG3UXKNzn1yjnqIRZtz9RXIpinaIplkiCgd+08D9Bc4ihuUbMQRQkzXrDBAv4UNBcllR+IDK/Ejgb5MZZnVEIJ7V9J4M9EAdEUI7ZqZhVrkzZJawFslTegPvR/gFMiSxEYBW2PX7oPIROWTe+JsIHzoygS/6fDTwjiq/Bv8s8BmJAOfR2x6BxnMW1dDBIyxrTkbnt/VzGqX6PwIgjhxCX0MGXEeO9xh912t4IIAo5nfAj2o0kAaqeDLb341hHNcDf/QEoAvsI8lCA4nW5D/iAE5558ABxR/O/SDCD3a/DCuZ83q/E8HyDZ/mVAF2pCEoKcizdj5DJEIaVfAnlgJXwT/lApxS3wzoM2DLTNSK8mfHE+UvtS/A9apxM6fwlMeW81vJ5WrnsREAA/W2LQHsVMyfGKez/gr8Q1ignEXm8V8PzFXXYIHJUmY2mWbIwPq/EvWEzkzeTJuQNMgg2XEzIJwJb6rjHgp7zjrYI43D3MryX8EBWHZ+VvUtEmGAbseAGUSPWwT/2apvglntOAv0bRwDWRnAXdYmM/BkEvKpgZm8tEeC7nWH6QhgRvVdkColt9rKcT1ioC4gsP0V8LttjUnMwFkBvjXJhu2EFGcBEk3saL8cN5uHmD3PaMpnzzMax9v/GMc4cn5n9N0IANXXBWnmPQCi0Enwb8AO2mbAXwFw1fJXiKQBxLg7FYJAR8aGiyboZfvVwNFxMhN1ZoyZPplzie5hZYzXve3y9RICEBAOZJAEdQnQxpiuG3DWBWA//RnJhu5TdyskFTIDKwBPtU2qfwQGb3/Ut/utEo0TTUxczPSd6ZMF5pVjZ88hanfkHDcCiAC7HSAqFQJthi4icAlU8YMyImPtAcAOmLBtCHzCHikwR6GEvtMnVxQY6ZFD2vMt8TDTjFN5yj5Xgisa29t/BNSV4y5f/6nj04ADABNZfI8kqJor5XcVPwF+D7RybimSgF/PHDNQ5YhAPCC2vkl3EYF6VvlpP7VxZpJW+lTasntbAYLVduYcKse9evzoXJav+9RX6wBkMnUKfgH4U+VFDcTkcmANCAR/SBIF8M+CPOUUCDnijZwB9UyfDlSJmZpo0s3HTPtMm7McRMkNRcgK9s9e18HDDt03AugArx7qMfftQ0XKP+MmvD4U4HguhDi8PpV9mfUGTJFToJdrMGaGNWHO2u46iYCQjgAwC4RsuyxRZoA0c8xo3CvGjI7p3dvla4kD2Dqom06JIOsOEs8A4A9jOZCzwV9yBKpxBtSZNt01JY5h3cwzicA7p84VZGZech1AFhjZdjPneYTIop+iet7ReGed60YAFuBc9T8R/IPiF2N+Rh6RWtM+xEmIw/EmlEckacA6KnsGuL0JaO5LJv2ykztqF+2fBXV23LNApcc5cnyPCM4Yd/kv6ACyoM62q7wSTD+BaDiQlAuYLBNSIBeAGRGBSQbkTlZAf0bb4dySbqQ62TOTNtPGDVkIarJjnkkCR45Z/V1nHMPa5xUBwEQ/TfnhF3DHJC8TYa7gKPhLqg8Hi4Bd3W9ZbDZhzgB3ZYx2bs7szUzsqM3R/Y/pBqJzPZM0HgP4eD0bAaTi/WxeoBDvD6SQIAzG/K1bslJgEUF3o48+XUhi32EiFev8WYKYAjzOPBCDSFkicHj7o75Zlc+MQy4vurS2vzp+9ryvtveZ81i+5lPGMiBT3zRJ7J3Tig9UHvVxHYC6SxmQm22csVwC2q8lcgTbGGRWHQF4tq83KbYxjNkegWAW6NG4mUk84wYyx50Zt3K+FgFUzu2o+9gIIALeVeBHuxmdQxb8VeAP48IAEZCn9zvHsCZQFuDZdvQ4CeWPJudTE0F0fjNOoDLmEQKoHmfmWjRhLF8dOQA1KVygFpKDrwP4B7IwgDkNdOYIDJBlgXt2O7wPenJEE3IG7DN9qhM9Ou8rx5slgMo5zzoT5hY2AjBBfTL48cfZhs6+OhzOvANtArBpR5AA5mEiIHc5GjPrCLLEcIXyW5O3uj07sTNgybTJgjU7Vna8KtEebe/1X/6z5QAmwT+AnL1g9CD4hTzcsMAiDba9mPCLQEv3G2RlTfoMoDNtvEnZ+quBZlR6Buwzx7lCvTMAz7SZIYDsuFlyZCrvnddGAIMDCMDfgbxCFIkKgUcg2q6m1X3/VWj7yTUD7Ec1iSHhLrJEcAT0dLIVKxHRRKwSQQSAq/dH15PdX2030z76LRj4oz7LV2kHQJRqIAgB1GOD31DRChF0bR3lM8GcKO91fYvuwmJr73y8yeQSRlL5zwL1rOJHk/jo/oxyR8e4GtDZ41fPoyeAQhKvVBk4Q/kD8FdIYLvhCTLxQozIAWzDBwCLQB3tj87BnQwTyl8hgkrbzKSNAHD1/gxJZNtkrhfVPLo2rfyV9hsBlMH8RMpfBjn8MpbyZ8asEEEbT/1GFZWOgB/tD13EBcpfBfwVbiCa+FfvrwA7OpfKWLNksZ7D8p8+lFwI9AS2H1U0A1Rp47YlwLTaTwF/7xSB9Oj+I+pfeX15SCYGyWYm5etGAhlQPmabqxwFjrsRgAaO+f0k5ccTcI+dBGuaHJLjReByCSNQ16PAj/qHgIUBKqrN2h7tH6ncFQQRgSoCeLQ/Gj+65gxxasufPSZrt/zHrAN4jcCfBjyG4RPPCZQdgAOuCLgeqUSEFIIeZt0VQD46pjeBryCBCMRX788CNjqPCplYx9wIIHQAB8GfVvwT3gNAgTQBflflme0l7qJCIDMgzwCvtQmcSZpECi82rTiECBTVsWbHi/pl9kdtzgT20bGW/xA5gNcc/K4bOAh8D8DdD3/kPygplhVLoL9Q+TPnESlUFdTV9rPOIgLw0f1HQRv9rjpE8I63EYDpAF5D8LuAP2j5o7GpSkMn/UNXvlfaZtxCa3Oh8lcAWWk7C9yzjpEFmAes2X3ZY2dIKNNm+feWA3hC8FeASNuS9QxZNbeOTfur38i6edkxI2BnVFc7kyPWPnO8yvhntI0m9WOSwBGQRy7g6P4skWwEMDiASfDjzTFdxX5m3f4CYCNyyCzwicZIkQUBv6fiFYWvtDVB9cjKnyWLqrqfBehZsM4CcbZfFrjR+BFRynGWf6cdwCT4GahSJBCAPwJrtx++6GOnQK3icVO5T3p+oAL0qG13fYScvImVAW/p+CoIzYxfPb8qkUSAuIIgZseMzjWzP9NmPb+NABpYXgPwlwAPE02vZjwT8BHJsMn7ZG6AzLoMAM9qU7H5Z6j7GWNkVLd6nCwAFVe2r5HCn7V/+crVAVSeAUALbyjhrPJ7LsIC9NaHKN4lDsBQVtMpOI7CIyg2ebxjzKr/DOgzfSok8NhtI2CeCfQjID3SN7pG3L985cvEOgAE/ZFXfSceCio7AMO1uIShriflFhySqQL2DMKgx0yofwbAnnupALYCpsx5PUaY8H4ILSoAjxzG8hUvi88C7Ee3VB5PjrZJuA02BgVp4EBSwM7E/cn1BBVV90A2tQ86RQCOCCuz/ygRZAF/lETOBLSnypXz9Igssy8igIp7WP7tTgAhcCfVuyOBE8DfLq4A/shVuERhAGsKpBeFBNH/gmRNqogoov2PRQJHj/MYJDBDDkeAPHs8fcxGAJaiVwHMwLZtS4Df7Kst+8HKgQX44fj7hizYz24XKbH8rmjzItAe3R+dU9WmZ53AB5UEZoE8228ggH+TdQAFADMgpQhGAZ0SAlHkSOGj/VZ4MRNCZPvMtuv6JQgqA9gqKWTBmAV3tl32uGcpvgWy6vZZpT8L5CgQlAA85a2qtwZ6RflDB5AEfwT4aL+21Fb7LIhn+kfAzfzHIhVgR22j8zmq/BVQZc61SgKV41fH9n6bWXI4q9/y5SoJiAMfBb9Xm7ccwXB8cQVE7QayIW8groI0s5KwOmYEHm9Cm/suUP+MEp/V5oiaV8B6VdsZEphR9Jk+FXLYCMAE0oTtb2OpCZoBq+kAjLFMsgDP4x33TOsfugohMnJuEUEM56lmRaSIV+/PnP8RwGfHrxzjyrZnksPlBPBlRhlwxrpnwW8CnWXJC0RymBCS5b4zwV5Wf+hwBNhH+lqW9rHdwVF1P9r/dQZ6ljiWlQC0SjIbPLRRilYFv0cC7Yc9WOrLAFWf94y9n+ljnZurdie8YnzquMS9PAUJHAVshqCs63oMsFeuzzvPaB8eZ/lS7QCU4jJVNckgUGurH1XuiVJfilSYFTdUtUIgR0nA67/tU7OjouBll2GEKVnQZ4EWXUPFps8es3KM15EEskoPt3T7KP02AojUO0UCk+CnoCWAzII7Au2w3yG8o6COzoUBioKCnKPrFBjJqRlQcQLVY2WJIjNuBaCvIwlUVX0G0NVjdATwMXEAAYBdEnhC8Ecgc/efGPNH5xFNdhOQRdt/ptpHCh3tj675CFE8JTFUjv2UriFz7GUlgOp/DNKRwUHwdxPfUeMjDoCCq5BfOOoEZvpr2x+BLavolXEyAM6obnTMzHEqoMuc09HxKv2rbTPAVYZO/ydUbXfkKP4/BnecprBuissAAAAASUVORK5CYII=",t})();e.TextureTools=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){this.x=e.Vector3.Zero(),this.y=e.Vector3.Zero(),this.z=e.Vector3.Zero(),this.xx=e.Vector3.Zero(),this.yy=e.Vector3.Zero(),this.zz=e.Vector3.Zero(),this.xy=e.Vector3.Zero(),this.yz=e.Vector3.Zero(),this.zx=e.Vector3.Zero()}return t.prototype.addAmbient=function(t){var r=new e.Vector3(t.r,t.g,t.b);this.xx=this.xx.add(r),this.yy=this.yy.add(r),this.zz=this.zz.add(r)},t.getSphericalPolynomialFromHarmonics=function(e){var r=new t;return r.x=e.L11.scale(1.02333),r.y=e.L1_1.scale(1.02333),r.z=e.L10.scale(1.02333),
- r.xx=e.L00.scale(.886277).subtract(e.L20.scale(.247708)).add(e.L22.scale(.429043)),r.yy=e.L00.scale(.886277).subtract(e.L20.scale(.247708)).subtract(e.L22.scale(.429043)),r.zz=e.L00.scale(.886277).add(e.L20.scale(.495417)),r.yz=e.L2_1.scale(.858086),r.zx=e.L21.scale(.858086),r.xy=e.L2_2.scale(.858086),r.scale(1/Math.PI),r},t.prototype.scale=function(e){this.x=this.x.scale(e),this.y=this.y.scale(e),this.z=this.z.scale(e),this.xx=this.xx.scale(e),this.yy=this.yy.scale(e),this.zz=this.zz.scale(e),this.yz=this.yz.scale(e),this.zx=this.zx.scale(e),this.xy=this.xy.scale(e)},t})();e.SphericalPolynomial=t;var r=(function(){function t(){this.L00=e.Vector3.Zero(),this.L1_1=e.Vector3.Zero(),this.L10=e.Vector3.Zero(),this.L11=e.Vector3.Zero(),this.L2_2=e.Vector3.Zero(),this.L2_1=e.Vector3.Zero(),this.L20=e.Vector3.Zero(),this.L21=e.Vector3.Zero(),this.L22=e.Vector3.Zero()}return t.prototype.addLight=function(t,r,i){var n=new e.Vector3(r.r,r.g,r.b),o=n.scale(i);this.L00=this.L00.add(o.scale(.282095)),this.L1_1=this.L1_1.add(o.scale(.488603*t.y)),this.L10=this.L10.add(o.scale(.488603*t.z)),this.L11=this.L11.add(o.scale(.488603*t.x)),this.L2_2=this.L2_2.add(o.scale(1.092548*t.x*t.y)),this.L2_1=this.L2_1.add(o.scale(1.092548*t.y*t.z)),this.L21=this.L21.add(o.scale(1.092548*t.x*t.z)),this.L20=this.L20.add(o.scale(.315392*(3*t.z*t.z-1))),this.L22=this.L22.add(o.scale(.546274*(t.x*t.x-t.y*t.y)))},t.prototype.scale=function(e){this.L00=this.L00.scale(e),this.L1_1=this.L1_1.scale(e),this.L10=this.L10.scale(e),this.L11=this.L11.scale(e),this.L2_2=this.L2_2.scale(e),this.L2_1=this.L2_1.scale(e),this.L20=this.L20.scale(e),this.L21=this.L21.scale(e),this.L22=this.L22.scale(e)},t.prototype.convertIncidentRadianceToIrradiance=function(){this.L00=this.L00.scale(3.141593),this.L1_1=this.L1_1.scale(2.094395),this.L10=this.L10.scale(2.094395),this.L11=this.L11.scale(2.094395),this.L2_2=this.L2_2.scale(.785398),this.L2_1=this.L2_1.scale(.785398),this.L20=this.L20.scale(.785398),this.L21=this.L21.scale(.785398),this.L22=this.L22.scale(.785398)},t.prototype.convertIrradianceToLambertianRadiance=function(){this.scale(1/Math.PI)},t.getsphericalHarmonicsFromPolynomial=function(e){var r=new t;return r.L00=e.xx.scale(.376127).add(e.yy.scale(.376127)).add(e.zz.scale(.376126)),r.L1_1=e.y.scale(.977204),r.L10=e.z.scale(.977204),r.L11=e.x.scale(.977204),r.L2_2=e.xy.scale(1.16538),r.L2_1=e.yz.scale(1.16538),r.L20=e.zz.scale(1.34567).subtract(e.xx.scale(.672834)).subtract(e.yy.scale(.672834)),r.L21=e.zx.scale(1.16538),r.L22=e.xx.scale(1.16538).subtract(e.yy.scale(1.16538)),r.scale(Math.PI),r},t})();e.SphericalHarmonics=r})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(t){var r=(function(){function e(e,t,r,i){this.name=e,this.worldAxisForNormal=t,this.worldAxisForFileX=r,this.worldAxisForFileY=i}return e})(),i=(function(){function t(){}return t.ConvertCubeMapTextureToSphericalPolynomial=function(t){if(!t.isCube)return null;var r,i,n=t.getSize().width,o=t.readPixels(0),s=t.readPixels(1);t.isRenderTarget?(r=t.readPixels(3),i=t.readPixels(2)):(r=t.readPixels(2),i=t.readPixels(3));var a=t.readPixels(4),u=t.readPixels(5),l=t.gammaSpace,h=e.Engine.TEXTUREFORMAT_RGBA,c=e.Engine.TEXTURETYPE_UNSIGNED_INT;t.textureType&&t.textureType!==e.Engine.TEXTURETYPE_UNSIGNED_INT&&(c=e.Engine.TEXTURETYPE_FLOAT);var f={size:n,right:o,left:s,up:r,down:i,front:a,back:u,format:h,type:c,gammaSpace:l};return this.ConvertCubeMapToSphericalPolynomial(f)},t.ConvertCubeMapToSphericalPolynomial=function(t){for(var r=new e.SphericalHarmonics,i=0,n=2/t.size,o=n,s=.5*n-1,a=0;a<6;a++)for(var u=this.FileFaces[a],l=t[u.name],h=s,c=t.format===e.Engine.TEXTUREFORMAT_RGBA?4:3,f=0;f<t.size;f++){for(var d=s,p=0;p<t.size;p++){var g=u.worldAxisForFileX.scale(d).add(u.worldAxisForFileY.scale(h)).add(u.worldAxisForNormal);g.normalize();var _=Math.pow(1+d*d+h*h,-1.5),m=l[f*t.size*c+p*c+0],v=l[f*t.size*c+p*c+1],y=l[f*t.size*c+p*c+2];t.type===e.Engine.TEXTURETYPE_UNSIGNED_INT&&(m/=255,v/=255,y/=255),t.gammaSpace&&(m=Math.pow(e.Scalar.Clamp(m),e.ToLinearSpace),v=Math.pow(e.Scalar.Clamp(v),e.ToLinearSpace),y=Math.pow(e.Scalar.Clamp(y),e.ToLinearSpace));var A=new e.Color3(m,v,y);r.addLight(g,A,_),i+=_,d+=n}h+=o}var T=4*Math.PI,E=6*T/6,b=E/i;return r.scale(b),r.convertIncidentRadianceToIrradiance(),r.convertIrradianceToLambertianRadiance(),e.SphericalPolynomial.getSphericalPolynomialFromHarmonics(r)},t.FileFaces=[new r("right",new e.Vector3(1,0,0),new e.Vector3(0,0,-1),new e.Vector3(0,-1,0)),new r("left",new e.Vector3(-1,0,0),new e.Vector3(0,0,1),new e.Vector3(0,-1,0)),new r("up",new e.Vector3(0,1,0),new e.Vector3(1,0,0),new e.Vector3(0,0,1)),new r("down",new e.Vector3(0,-1,0),new e.Vector3(1,0,0),new e.Vector3(0,0,-1)),new r("front",new e.Vector3(0,0,1),new e.Vector3(1,0,0),new e.Vector3(0,-1,0)),new r("back",new e.Vector3(0,0,-1),new e.Vector3(-1,0,0),new e.Vector3(0,-1,0))],t})();t.CubeMapToSphericalPolynomialTools=i})(e.Internals||(e.Internals={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(t){var r=(function(){function t(){}return t.ConvertPanoramaToCubemap=function(t,r,i,n){if(!t)throw"ConvertPanoramaToCubemap: input cannot be null";if(t.length!=r*i*3)throw"ConvertPanoramaToCubemap: input size is wrong";return{front:this.CreateCubemapTexture(n,this.FACE_FRONT,t,r,i),back:this.CreateCubemapTexture(n,this.FACE_BACK,t,r,i),left:this.CreateCubemapTexture(n,this.FACE_LEFT,t,r,i),right:this.CreateCubemapTexture(n,this.FACE_RIGHT,t,r,i),up:this.CreateCubemapTexture(n,this.FACE_UP,t,r,i),down:this.CreateCubemapTexture(n,this.FACE_DOWN,t,r,i),size:n,type:e.Engine.TEXTURETYPE_FLOAT,format:e.Engine.TEXTUREFORMAT_RGB,gammaSpace:!1}},t.CreateCubemapTexture=function(e,t,r,i,n){for(var o=new ArrayBuffer(e*e*4*3),s=new Float32Array(o),a=t[1].subtract(t[0]).scale(1/e),u=t[3].subtract(t[2]).scale(1/e),l=1/e,h=0,c=0;c<e;c++){for(var f=t[0],d=t[2],p=0;p<e;p++){var g=d.subtract(f).scale(h).add(f);g.normalize();var _=this.CalcProjectionSpherical(g,r,i,n);s[c*e*3+3*p+0]=_.r,s[c*e*3+3*p+1]=_.g,s[c*e*3+3*p+2]=_.b,f=f.add(a),d=d.add(u)}h+=l}return s},t.CalcProjectionSpherical=function(e,t,r,i){for(var n=Math.atan2(e.z,e.x),o=Math.acos(e.y);n<-Math.PI;)n+=2*Math.PI;for(;n>Math.PI;)n-=2*Math.PI;var s=n/Math.PI,a=o/Math.PI;s=.5*s+.5;var u=Math.round(s*r);u<0?u=0:u>=r&&(u=r-1);var l=Math.round(a*i);l<0?l=0:l>=i&&(l=i-1);var h=i-l-1;return{r:t[h*r*3+3*u+0],g:t[h*r*3+3*u+1],b:t[h*r*3+3*u+2]}},t.FACE_FRONT=[new e.Vector3(-1,-1,-1),new e.Vector3(1,-1,-1),new e.Vector3(-1,1,-1),new e.Vector3(1,1,-1)],t.FACE_BACK=[new e.Vector3(1,-1,1),new e.Vector3(-1,-1,1),new e.Vector3(1,1,1),new e.Vector3(-1,1,1)],t.FACE_RIGHT=[new e.Vector3(1,-1,-1),new e.Vector3(1,-1,1),new e.Vector3(1,1,-1),new e.Vector3(1,1,1)],t.FACE_LEFT=[new e.Vector3(-1,-1,1),new e.Vector3(-1,-1,-1),new e.Vector3(-1,1,1),new e.Vector3(-1,1,-1)],t.FACE_DOWN=[new e.Vector3(-1,1,-1),new e.Vector3(1,1,-1),new e.Vector3(-1,1,1),new e.Vector3(1,1,1)],t.FACE_UP=[new e.Vector3(-1,-1,1),new e.Vector3(1,-1,1),new e.Vector3(-1,-1,-1),new e.Vector3(1,-1,-1)],t})();t.PanoramaToCubeMapTools=r})(e.Internals||(e.Internals={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(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,r,i,n,o){n>0?(n=this.Ldexp(1,n-136),e[o+0]=t*n,e[o+1]=r*n,e[o+2]=i*n):(e[o+0]=0,e[o+1]=0,e[o+2]=0)},t.readStringLine=function(e,t){for(var r="",i="",n=t;n<e.length-t&&"\n"!=(i=String.fromCharCode(e[n]));n++)r+=i;return r},t.RGBE_ReadHeader=function(e){var t=0,r=0,i=this.readStringLine(e,0);if("#"!=i[0]||"?"!=i[1])throw"Bad HDR Format.";var n=!1,o=!1,s=0;do{s+=i.length+1,i=this.readStringLine(e,s),"FORMAT=32-bit_rle_rgbe"==i?o=!0:0==i.length&&(n=!0)}while(!n);if(!o)throw"HDR Bad header format, unsupported FORMAT";s+=i.length+1,i=this.readStringLine(e,s);var a=/^\-Y (.*) \+X (.*)$/g,u=a.exec(i);if(u.length<3)throw"HDR Bad header format, no size";if(r=parseInt(u[2]),t=parseInt(u[1]),r<8||r>32767)throw"HDR Bad header format, unsupported size";return s+=i.length+1,{height:t,width:r,dataPosition:s}},t.GetCubeMapTextureData=function(t,r){var i=new Uint8Array(t),n=this.RGBE_ReadHeader(i),o=this.RGBE_ReadPixels_RLE(i,n);return e.PanoramaToCubeMapTools.ConvertPanoramaToCubemap(o,n.width,n.height,r)},t.RGBE_ReadPixels=function(e,t){return this.RGBE_ReadPixels_RLE(e,t)},t.RGBE_ReadPixels_RLE=function(e,t){for(var r,i,n,o,s,a=t.height,u=t.width,l=t.dataPosition,h=0,c=0,f=0,d=new ArrayBuffer(4*u),p=new Uint8Array(d),g=new ArrayBuffer(t.width*t.height*4*3),_=new Float32Array(g);a>0;){if(r=e[l++],i=e[l++],n=e[l++],o=e[l++],2!=r||2!=i||128&n)throw"HDR Bad header format, not RLE";if((n<<8|o)!=u)throw"HDR Bad header format, wrong scan line width";for(h=0,f=0;f<4;f++)for(c=(f+1)*u;h<c;)if(r=e[l++],i=e[l++],r>128){if(0==(s=r-128)||s>c-h)throw"HDR Bad Format, bad scanline data (run)";for(;s-- >0;)p[h++]=i}else{if(0==(s=r)||s>c-h)throw"HDR Bad Format, bad scanline data (non-run)";if(p[h++]=i,--s>0)for(var m=0;m<s;m++)p[h++]=e[l++]}for(f=0;f<u;f++)r=p[f],i=p[f+u],n=p[f+2*u],o=p[f+3*u],this.Rgbe2float(_,r,i,n,o,(t.height-a)*u*3+3*f);a--}return _},t})();e.HDRTools=t})(e.Internals||(e.Internals={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(r,i,n,o,s,a,u,l,h){void 0===o&&(o=!1),void 0===s&&(s=!0),void 0===a&&(a=!1),void 0===u&&(u=!1),void 0===l&&(l=null),void 0===h&&(h=null);var c=t.call(this,i)||this;return c._useInGammaSpace=!1,c._generateHarmonics=!0,c._isBABYLONPreprocessed=!1,c._onLoad=null,c._onError=null,c.coordinatesMode=e.Texture.CUBIC_MODE,c.isPMREM=!1,c._isBlocking=!0,r?(c.name=r,c.url=r,c.hasAlpha=!1,c.isCube=!0,c._textureMatrix=e.Matrix.Identity(),c._onLoad=l,c._onError=h,c.gammaSpace=!1,n?(c._isBABYLONPreprocessed=!1,c._noMipmap=o,c._size=n,c._useInGammaSpace=a,c._usePMREMGenerator=u&&i.getEngine().getCaps().textureLOD&&c.getScene().getEngine().getCaps().textureFloat&&!c._useInGammaSpace):(c._isBABYLONPreprocessed=!0,c._noMipmap=!1,c._useInGammaSpace=!1,c._usePMREMGenerator=i.getEngine().getCaps().textureLOD&&c.getScene().getEngine().getCaps().textureFloat&&!c._useInGammaSpace),c.isPMREM=c._usePMREMGenerator,c._texture=c._getFromCache(r,c._noMipmap),c._texture||(i.useDelayedTextureLoading?c.delayLoadState=e.Engine.DELAYLOADSTATE_NOTLOADED:c.loadTexture()),c):c}return __extends(r,t),Object.defineProperty(r.prototype,"isBlocking",{get:function(){return this._isBlocking},set:function(e){this._isBlocking=e},enumerable:!0,configurable:!0}),r.prototype.loadBabylonTexture=function(){var t=this,r=0,i=null,n=!this._useInGammaSpace&&this.getScene().getEngine().getCaps().textureFloat?function(e){for(var n=[],o=30,s=0;s<r;s++){n.push([]);for(var a=3*Math.pow(t._size>>s,2),u=0;u<6;u++){var l=i.subarray(o,o+a);n[s].push(l),o+=a}}return n}:null,o=function(o){var s=new Int32Array(o);i=new Float32Array(o);var a=s[0];t._size=s[1],t.getScene().getEngine().updateTextureSize(t._texture,t._size,t._size);var u=new e.SphericalPolynomial;u.x.copyFromFloats(i[2],i[3],i[4]),u.y.copyFromFloats(i[5],i[6],i[7]),u.z.copyFromFloats(i[8],i[9],i[10]),u.xx.copyFromFloats(i[11],i[12],i[13]),u.yy.copyFromFloats(i[14],i[15],i[16]),u.zz.copyFromFloats(i[17],i[18],i[19]),u.xy.copyFromFloats(i[20],i[21],i[22]),u.yz.copyFromFloats(i[23],i[24],i[25]),u.zx.copyFromFloats(i[26],i[27],i[28]),t.sphericalPolynomial=u,r=s[29];for(var l=30,h=[],c=3*Math.pow(t._size,2),f=0;f<6;f++)h.push(i.subarray(l,l+c)),l+=c;for(var d=[],p=null,g=0;g<6;g++){var _=null;if(1===a){_=h[[0,2,4,1,3,5][g]]}if(!n){if(!t.getScene().getEngine().getCaps().textureFloat){var m=new ArrayBuffer(c);p=new Uint8Array(m)}for(var v=0;v<t._size*t._size;v++)if(t._useInGammaSpace&&(_[3*v+0]=Math.pow(_[3*v+0],e.ToGammaSpace),_[3*v+1]=Math.pow(_[3*v+1],e.ToGammaSpace),_[3*v+2]=Math.pow(_[3*v+2],e.ToGammaSpace)),p){var y=Math.max(255*_[3*v+0],0),A=Math.max(255*_[3*v+1],0),T=Math.max(255*_[3*v+2],0),E=Math.max(Math.max(y,A),T);if(E>255){var b=255/E;y*=b,A*=b,T*=b}p[3*v+0]=y,p[3*v+1]=A,p[3*v+2]=T}}p?d.push(p):d.push(_)}return d};this._texture=this.getScene().getEngine().createRawCubeTextureFromUrl(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,this._onLoad,this._onError)},r.prototype.loadHDRTexture=function(){var t=this,i=function(i){var n=e.Internals.HDRTools.GetCubeMapTextureData(i,t._size);if(t._generateHarmonics){var o=e.Internals.CubeMapToSphericalPolynomialTools.ConvertCubeMapToSphericalPolynomial(n);t.sphericalPolynomial=o}for(var s=[],a=null,u=0;u<6;u++){if(!t.getScene().getEngine().getCaps().textureFloat){var l=new ArrayBuffer(t._size*t._size*3);a=new Uint8Array(l)}var h=n[r._facesMapping[u]];if(t._useInGammaSpace||a)for(var c=0;c<t._size*t._size;c++)if(t._useInGammaSpace&&(h[3*c+0]=Math.pow(h[3*c+0],e.ToGammaSpace),h[3*c+1]=Math.pow(h[3*c+1],e.ToGammaSpace),h[3*c+2]=Math.pow(h[3*c+2],e.ToGammaSpace)),a){var f=Math.max(255*h[3*c+0],0),d=Math.max(255*h[3*c+1],0),p=Math.max(255*h[3*c+2],0),g=Math.max(Math.max(f,d),p);if(g>255){var _=255/g;f*=_,d*=_,p*=_}a[3*c+0]=f,a[3*c+1]=d,a[3*c+2]=p}a?s.push(a):s.push(h)}return s};this._texture=this.getScene().getEngine().createRawCubeTextureFromUrl(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,i,null,this._onLoad,this._onError)},r.prototype.loadTexture=function(){this._isBABYLONPreprocessed?this.loadBabylonTexture():this.loadHDRTexture()},r.prototype.clone=function(){var e=this._isBABYLONPreprocessed?null:this._size,t=new r(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},r.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())},r.prototype.getReflectionTextureMatrix=function(){return this._textureMatrix},r.prototype.setReflectionTextureMatrix=function(e){this._textureMatrix=e},r.Parse=function(t,r,i){var n=null;if(t.name&&!t.isRenderTarget){var o=t.isBABYLONPreprocessed?null:t.size;n=new e.HDRCubeTexture(i+t.name,r,o,t.noMipmap,t.generateHarmonics,t.useInGammaSpace,t.usePMREMGenerator),n.name=t.name,n.hasAlpha=t.hasAlpha,n.level=t.level,n.coordinatesMode=t.coordinatesMode,n.isBlocking=t.isBlocking}return n},r.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.noMipmap=this._noMipmap,e.isBlocking=this._isBlocking,e},r.generateBabylonHDROnDisk=function(e,t,i){void 0===i&&(i=null);var n=function(e){var t=new Blob([e],{type:"application/octet-stream"}),r=window.URL.createObjectURL(t),i=document.createElement("a");document.body.appendChild(i),i.style.display="none",i.href=r,i.download="envmap.babylon.hdr",i.click()};r.generateBabylonHDR(e,t,n,i)},r.generateBabylonHDR=function(t,r,i,n){return void 0===n&&(n=null),t&&e.Tools.IsExponentOfTwo(r)?(e.Tools.Error("Generation of Babylon HDR is coming back in 3.1."),null):null},r._facesMapping=["right","left","up","down","front","back"],r})(e.BaseTexture);e.HDRCubeTexture=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(e,t,r){void 0===t&&(t=""),void 0===r&&(r="black");var i=this;this._renderingCanvas=e,this._loadingText=t,this._loadingDivBackgroundColor=r,this._resizeLoadingUI=function(){var e=i._renderingCanvas.getBoundingClientRect(),t=window.getComputedStyle(i._renderingCanvas).position;i._loadingDiv.style.position="fixed"===t?"fixed":"absolute",i._loadingDiv.style.left=e.left+"px",i._loadingDiv.style.top=e.top+"px",i._loadingDiv.style.width=e.width+"px",i._loadingDiv.style.height=e.height+"px"}}return e.prototype.displayLoadingUI=function(){if(!this._loadingDiv){this._loadingDiv=document.createElement("div"),this._loadingDiv.id="babylonjsLoadingDiv",this._loadingDiv.style.opacity="0",this._loadingDiv.style.transition="opacity 1.5s ease",this._loadingTextDiv=document.createElement("div"),this._loadingTextDiv.style.position="absolute",this._loadingTextDiv.style.left="0",this._loadingTextDiv.style.top="50%",this._loadingTextDiv.style.marginTop="80px",this._loadingTextDiv.style.width="100%",this._loadingTextDiv.style.height="20px",this._loadingTextDiv.style.fontFamily="Arial",this._loadingTextDiv.style.fontSize="14px",this._loadingTextDiv.style.color="white",this._loadingTextDiv.style.textAlign="center",this._loadingTextDiv.innerHTML="Loading",this._loadingDiv.appendChild(this._loadingTextDiv),this._loadingTextDiv.innerHTML=this._loadingText;var e=document.createElement("style");e.type="text/css";e.innerHTML="@-webkit-keyframes spin1 { 0% { -webkit-transform: rotate(0deg);}\n 100% { -webkit-transform: rotate(360deg);}\n } @keyframes spin1 { 0% { transform: rotate(0deg);}\n 100% { transform: rotate(360deg);}\n }",document.getElementsByTagName("head")[0].appendChild(e);var t=new Image;t.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAYAAAA5ZDbSAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAZdEVYdFNvZnR3YXJlAHBhaW50Lm5ldCA0LjAuMTZEaa/1AAAYq0lEQVR4Xu2dCZRcVZnHScAJUZSwjSOIbAJmEAZwQCCMoAInYRGIg8AwegQx7AFzUBBmzAFlE4EAwxz2GRk2w7AnAURZBiEOZgyEQDAQAjmEJqTpNd3V1V3Vmd+/6utKV7/1vnpVXd2p/zn3vOV+27vfu/fd/W3QQAPrBZqbm7fJZrN79vf3T+/r67uf4wO9vb37WXQDIwWtra0Tenp6voQTv5XP56/BkfcR3iLk1g6B7hEeI+zP5V+ZiAbqBZ2dnZ8lV+6Gg87CobfhpOc4byf0FjwYE9DneBkWcXrM2tmzNzTxDdQKJPyETCazI46YgiMuI9zJuXJltuChFIHsP/PSfIfTjU19A2mira1tcxy3ey6XO5vEnkV4kes11XBmENDVj97XOT2O03FmWgMuoNLzGRJva8IUnPkzjjcT/kLoKCZzfQB7XiX8M2G8md7AUJgzJ+Z6e88gZ1xGuj3HsY17PcVkrG9gp7CUF/F8PUvxqdZDrFq1ahNVfKjwTCYxZuDE2wjKlc2WViMePM+HPNsFPOdf22OPblD5OZQHvphnV65cjTMzxaQY3eA5V9OO/hmnm1lSjE7woFsQbiXki4++foHnXkW4mLC1JUl947333tsMY3emqfB9jtPJlXN5U0+bOXPmWCPxgOccSy4+AfqPio+9/oFnbyatbqVE28GSZfjQ1NT0KQzaHMcdyPfyaNoE12HcvdxT29K3Fkv8A2vWrPmcifAFZNtD91yRY+SBZ+9UsMtEgD+jTpeenp6JXI6xpKkuUDqRcA6Kr0Wpens+InQTnIpV6Fdi+BQT64ulS5eOIzefD62na7CeoGcnLCM8ykt5OWlzcPv772/BS/w3nP+K+xU11+DvQe5dcrQlTfWAwbNMb8XA8AyGX80xtLlA6TAJuteMbVhhia1v5VMcr+LWMeoZ4xiYw7q6urbhHbgG+paCkIRQehHu4pO3O5fVydEomF5Ulx548JfVD2wqfKE2I3R3ob/f2GoC1DWhdz7HG3i5j2pvb9+Z24m6HvVZQtYsZFWcowlzePEP4jJdR/OQhxTVpAs9NMXxmZxuZKo8IG4s+v8R2tUFphSBTBWzH+OAFwn/gS3TuN55xYoVqfc6dXd3fwHZ1xFaTX0iyGbwjJqXXAammxP00EXx6UMGEx7ram7+vKnzBZ/87Xiwp40tEdDTgYwlHG/CmadSjO7L+XiialOZAej7POFG2VK0Khngl6Pn8/LL0YEtlFh4n8oDAqvaAYH8tzH2iNDm1IIFn8Ax50G7xtgCAU07CfAG4RHOz+vLZL7e0dGxlYlKHaj8BHo25xgrsfV5wrYH4KmouxV+ZZDnCUdwmXxMGgFvFUVWD+jQuOot6rI0tb4gcfaG9v+MrcAn+wj38gL8C7cObmlp2ZRjOkWYD6ypuAf6zjFHLSJ0c/6YQ813DM/yZXgehreiVgP8cvSfsOeExYsXuzs6n8v9j8mqBRZQmdjXVPuira1NHSpn8UDf4Xu0vd2uCtDzacJOlDDf5ng94X8JTWarB8R1EK7ju7udiYgEz/v3pLFKm4oHUHhh3iZdfshpaEYpA4pvKLLXBujLYKRq71XLhUHg27z12rW9B6L/QhLrWWxRH7nzeDK8awi/5HRTEx0K6MZQ694LHk0DqrgfADkreIYz1q5c+UlTEQzesIuMryrggYQWjNL3RGO7p2tuFMeqjaOidgzyCz1yJMTJ6L6d66WEVCcHIO/dQkI75Chs2g97Hoc3jRz9Lge1ED5l4r0gckqRPB0gTw34t1B+h3IqxZkmrn2SULUa7ezZszdE5xfR9130Xsm5ilrnHrmkQOcKvrkncxqrIiY6wlewbw7BOUfDo/b84zzvj9C7J7eCS0NrUiRKCPjUE7ScMBdlF/B2HqBi0ERXBcuXL99YnQz9fX2ah3Up4UnsWGEmDRuUhoTn+Z5PfvbZZ2N/fuCZRJgnfhNVBu73EZoIKt7l0L2UBsYeDZg016nb5EUCWuXQewinUtTuyq2aTStF14a8SD+VDQVj6hDYxjuXf4Hjl83sSMCmTp8j4FtoMuRQ5dAZcii3kk/0s2bBhxIcBxjxUlib1hWInEDO/6qKV+y4geO5HAMntEE/pq+nZyo0ywsG1SmwL4Orf+0yqGCfmvR73LAn9lAeBjQTEhkA+1h49a08iRflcq4H5iuXFU9cz4lqihC/LXS/NZa6Bc+pz5gql5ub6VXD2tZWTSPeyS7XgeLhXrMnEhj6MSHSwaIhFGZH8oA/JzzFeexvJbRN2HW03moT6cEChx6w4QY2rurn85JWrxsiCy0FwjcIqos8w7GZNPulkawDEbFHlaBtjzODEDrVztuKXMmADPWA3RaljyJeNdKq98ilAez8iJdyGqfO31V4NoV/EvyaCqR54V2EshE5Lqcb+TrkstkTLD4WKB4PNNZQ8P05HAelMXNSPWChC8JsYvwthJo0jSoF6fIqjjqe08Aat+LIkd+AVjn09zxbZFqK3tjXAUbXUaWDjTUSyN4J45YZX2Igo4cEOVfFson2ALIxSjR0jog5YNgpfNHM90BxIjDyWIB8Z2NfB01HISJ20wPaw4w1FlavXq1v8aPGXhFw9JNRFTDItifU/RwwpfmKxYsDK180kU4x0lhAXvOSJUs+bezlIDL2N4xi4GpjK4MGCuzUA+SPxzn3m4iKgKyV2DCV08DeMWg0B+zHHOt2DpjS3Mz1BfFOM25C5ZH4LxldJBB0g7GVARkaXgv8VsKqZtIMPpN9RUnJgRzU5Wfp22vifcG3+2vQvmdsdQXsX2pm+oKX+GYjjQXkPWqsXshpRhcJ0RpbGShSHiSuheP37ZYHsGusVHOrU1lMxkO9od4eE+8LlSzQqfetpnPAooBN/2Um+gISp89MkF8K4G3RrMJYoOhbYGxlQEGhSOGogfoLwipExGtUZVVBYIVAluaAaUpuWA+YujlPF22Ra/iBLYEOsV6tV4w0FiitfmLsXiBMU0NiAVrfsp77Zd8MHPgbDoHtva6uLs1jiv1piAKy5tCG+4KJ9wVO/p6RDzvy+b5rzSwP9Okh/WKPERiCWzfk4K8bUSTiOljAyCdx5DZG4gE8W5Dov+NYUfsV/j50fUC4dmXIQDh0qQ6PVgJsOcLM8oA410Ggvo6Ojr81di+g2TKuQOiyJOKWxlpCJpM5zUjKAL3awTsamQfEbYhjtDGKa5tPsyn/wAuiURftlBO56h6aunEwCMxxvV1d+2Fr7Jce2vAu5LUtLeoGi/19gtbToCaR97BoD6BvUs+WkXqgbw6OuhC6wH5l4rRGaCFOvYnjYbyxnpcsCvDVhYOxo6+zszNwSNHVTtJEmSiwzlMAQmNPwIPW42Dds2hfEK/5WJo0Fth+5VNxFHSlkoTzFRh/N3wnq0OGWxXtdoO8enFwaI4jsyidYgNZTxhrMEjEJ4w+En65ESWRXZ7Q4K/COqDAPlhka87WedB8KawmngTIHREOJs5pMiRp+p/GGgxL1FiA9hxjK6G1tVVdhJGAV15+cPXq1f7dahVC20Wg4miCp0uTe3Xh4Hwu93rY1B7SR/t7xQbP5R1FGgpy8IlKe+MJhZ9Aa7u5jPm+pGLX2BMDOZ+hDXgQiXIJ5xoXHZg96anEEFcvOTi0SMUXS4w0FijSTzTWYEA3hkTSEtDI2qw6RoytDLA6jctCvzKqJ8oPFOO7kAhnYe9cZGiWiZ/N9ezguWaSL4h3TUfvKJIfoN0I4sjigYSdZyxlcDVMgEczEY41ER6oZFBOh2Yqegf2zYoziFC3DuZZrjSTPLDtMlxaNPmPP/54W2OPxksrVozP5fLPGr8vEOpbxJCr3jQSJyDvGRNRhv7iHh8vE5LMpKznHBz4zSTOaXwe+mXGGh9tbWvVQf+iyfCAON/ZlTj4v43ECfB94Le4CuMrWVpTtw7O9fZOM5M8oD7xVSOLBdLuNWN1g7bgJUF8+4qpBjf7Te9M6hD4tBDc0289Wh2MHbuaSR7gsHOMLBaQ9W/G6o5MJrNDPu9dcYdQ33Yc95I6OFV5hnp2cGCliDingX5KU+9MShd0dmqta/k8J4zwnV2JsuuNxAnI83VwNpO52kiSoC4djA255cuXBzYPycGzjTQWkPdNY00OfRcQVLafRnd39ySLLsG1i20AyPZ3cDb7AyNJgnp1cOhUHUhcFiL045v9jTUa8Gjlm29fsQQhb3DzJLUEhC+oiK7EISPOwapoEh+7JQJti5YfGXs0YNC62ouC1h9lsrlToClsjc/RM7uSe0kd3EmlzTO/Kqk8Q106mM/Yw2aOB9jnOg6sWTHxJ9FraSJMy6nGz7RbZUDYmN7e3BnQ5Gisez7u3J9c0JwA6Pb0aCFvNObgwKk6NoU59uJwaJ8y1viAT4vCtEFXYO8SFQGtCZpllyXQtNqL+4lmZ/BN/5qJKQFZozEHe9JtAGSaw4wsFnie4JmUQcjleh8yZq0Fnmq3y0D02IzPMgnonYqYIfA4pC+TcXrgIahLB+PEb5s5HrjaR0b7kbHGB0pK7TDO1/T39x1lUZGAPlUH0xTbz+KSoC4dDDx2DQCHzTCaWOB5zjbW+KCSpW0IS0BIJmy6zWCk7WDuxZ4r5oO6dHB7e/sBZo4H2OfUsYOv9jHW+ECJdkAtA/c6MpmMd+XaEKj7km9M4F5TEfBzSKovDLKG1cHobw+b6EDa3WOksYBPAhevBUJMxl8GJTRhFyMLBKSJFn5ls9nvmogS0DfaHOzb3h8AcUuNNBLQNiWa0gRv4MwMMyBwCqxAfCIH82JdYSJKQN+ocjA5NHD2I/e1aj/23iPyhbG6A+bAgXsZoUEII/UAkkQORu71JqIE7o22HBw4VaelpWU74mPPDc/39d1trO5Qb4vJ8QXxbwat06WofcTInMCzeToAtN4VXUn/l1AXDkan9tDSfmL6C81BZooHxDkN9CMveLFZFFAWWZtDwVta3G0sJcAbe3bmYEiniShBXabcL+wflQDD5mD0yKlvk0b/Tk33AG5F7idG+/ibRe54oEl1nLG6A+ZYe1jyAIuG/u2LB3MazxwAfL5vJFGJinxQUwcju6c/n3+FNPm5JhJyy2k/sQTp5nm+2HBJCGi1X1WpwzuBoQXAN+IcjDz8mdePKi/WhH1uxd7GcCjIVBcWpUYDfZ0VbclEJSr2akMBhVrdX6j+Jx3DpSh7vKB8CIiqKwcrcXGqdr05k3RKbU9ryTQVkUB3aHMrEshw7kGCXiv8xxG0h6Uzent6Fpn6MhA17A6GT/3yTxNO1coJbgWur3JFf1fXNuTes5AZe18xXobFHJKv04JZc3O7CtIcgGL9KW03u3QCfL4D4b292dhrpoYgsYOhEz4kaOuHqXKqiagYiN9QnUlyKgX84JUYsQFP9GKzMFRSe8XJb9upE9Dn62CK/KQT75wdTLz+NXgPNdrDuYzeUd0ByN4Wp07n+EdCRZuTY1/ymZQDwIjQye9pA32xdw6IiUgHc639mN8kzCLRjkxzQRzitUpkZ8LZBP1CILUd55EVvdgsCrzJl5i8mgCja+Zgjst4Pq3DUnMmtSWqyNIuQruRU3+CbO08n+pvBAZAjf1IU5kcGJc0YRMBfVV3MPd2RN4+YbvYukI/3sSpe+LUmbw0ryG/6ts1oSLeYrMw6C0xeaFAGc+Wq3hbfeRk582b55lrzf3UHJwWkD0Wp+6BQ3+BfXEXw6UCdHX4TVB0BoJi9Y1Cp59XbUWN8HW7lRjLli3zbINE+1hNiCRI1cGakIhT99ani/A6z1z1nDoUqNQfbO40kyqDfrCBwMg3E5rsCy+8sFlHR8dEnFzRTq/I8hQ9NFFOtGhXVOxgFeUqfknUK7Ctpjl1ANKJ/vmUkvrdwRZmWjpA4J9MTyja2toKY8TQa/ufxP/Whdd5c5cQJHIwfBsTvkKiaqd6/fRyOHKqavdL0H+V2sxmWvrQCAeKItfmQlNyDG/8SVwnetMHyxmA7lm0K2I7GFrlVBW/V6FPP9GqeU4V0Kt2+O2yhctUN6AJBEWD9ngMnessJxh5AfCoQe+8q+xQOYLuWbQrQh2MXP1XYh8S9DKC2sI1z6kCatW3/RCZ6Vj9fNPMqx2wQVNJQlcNEl/mGG5pv48bi7HxMVSOoHsW7QqPg5GlvnJtk6/B9+HMqYUfaXE6rampqWy4dVhgi8FfLprnBXEex+i/wCSkNiSNDSpUxxt7Ccj2nQQYAwUHc9yE3HEotuifDklnfFYMdGNC/lWCxotDf4PvB/jHZTs71c+f2n+ryqCPPcb5/pKdGrTvbH2MUjH4ByOLBDpON9YSFi5cuI1FOwFbbyTox5T6y+iwFL8CqvWvwVtolWgSv/N4sXbl5ZP3r8hRLT50d56KgYJDCYXVhYOhtqqReKDdZuGJtSQSOk8f67x581SspvH3lpoBe9Vefbg/lzveaXmnAf6tEDMNGRp3LnV3ch29o10lQIf+bOKZc+XnmMGARF2EK4vUwQiSw33n7ZlqDWwcaK9Ob29vd26vwj+OT8m3kKFxdd9tlILSJ1Wo8Y8RZT/YiKOY4le5P3SGZJAc7telg7FroL16Jc/n/a1cBBCxsSblwT8LOfofcCh4AQ4x1uoCXZtgVKnYDXLMUECnPSQD29VBcrhfVw7GHrVXb6WylGg0SvUZcrr+YPYuwWVfaE9ltmpA2Q6EQq2UY+yigzf2oqCH4v4MIysD94fdwdig9uqDnB4T5/d+gwHPGNVFcOopyJiPLOfmGTwa0Ek8qS8RKDKORLFWH95utwbDd94SRqqN/Cv4PDXbTFfXfUZWBvRUPJCRBJiIqfnnccy0Dz74wHkWoypY2D4ZGU8gK+kKjQKQ8RcTW1uQI2fmc7nH7LIMFEW+sw6xdyN4CgvNByNIDjp+ZyRVhzlV7dVLaZc7t1cRoW0w9of/No6ptbuRdZupqC3QPZY33HchMkbJiRPssgyaHkN82XaJXPtOJuN+JRuixQI6Cu1VXiZtJehcFGpeNPyXI6cqPWTIvsxU1R7o912akevre4OHfTHot3fEfRbD3y8+Qu0djO5Ce5UXNGl7dTt4z0RGqnOuhgLZgmcPk2FHrrd3jgwkAVQ58e1ioxjcHeMLPWQcq+5gZKm9+hJHjXo5z4xQBQsxxyDjEfir+nNq5GfQo/nYh6f9e4NUgGEFx3DEzvw1nPrOhSJ+kh6GUBUHw6//Kmls96dJ2qv6FxNF9z8g405kVLVXDfkaiFAd4JIkttYUGFpyDOf91Ch/YVEe8DA/gORpuywDfLNMjBOQt4qEupbTPTX4YeJig+/qrnoxkfMeIdH2UHGBfP0H6kFepElc1rY5lBQYXZbzuO7BWYH7b3V3d/+TX1FEG/JSExEJdOi7qsnrx3DuNM8Zdg2NqnN/BjK0EXlVhxORr56wP6Lv/DT+X1FzYLynaOWe2s1TjCQW4An9t6Jk4hBVdH6YpB9YNXoS+SRk/JaQZHd5J2CnesLuyGaze3KZ2hTemoNcpO+uB3pAQuzvC7SeJSfc0258Wo97aX9PT+TmMEMB73jsO0wJzXnVx4llL7pe5kWaFtSqGHHgu6rpPr5jsdx+hyI59G+hA4C25GDO1V69mbf/77h0+lZpzZX44B+Ye1X1cWKz92pKrYlcjtzc6gfN+ufhApd/ErcwTvuTRNI0m4c4Tg77u6gfbCHdTuQcrRFaRKiFU7Xl1O/RqX9RObevRxR43gmEBYUn9wEJIMeF/jk0yVKTta2tE0jg43kx1OatWifEYKDrHYKGDnfkMrU1xHUPaoh7k8i+030EvoV3c6i4aTCoc/9+9NVkFgh6BmZFaig08he3oxYkwBEkQGCzg7gfG6kzaDvuSyLfgIyqt1cF6SAspoS4iJf3c9xaf3JrGEgUzZcOGgvO4agzjTQUkI9V5z4851MuLhBvUUp1gR7tjXEHL+shXFZnduNIBomi6T73FVLLByQePu4N3CxMbVxyzfeQUTYZrdpA3yvoPVf/1jdTGggC6aXx0ieLSecFcWoj72vkhU4IcswU7gVORksb6FHnufbouJ4Xbv+gf1g0EADav9uSeO9YenpA3IfURFVZ0gqEms1rRg0qCzM4TuYy1T061jt0dXXpX0xJ96FMDXIqQXtJ3tSfze6OaY0KU1ogfTUgUJMK0lBIL06dS/F/LJeRe0k2kAAk7BgSWN2GVW/aCOjRuPCbBHVGBG6J3ECKIN3VlfjroguqA+RrMsFvCNqisf5mRox2qPlB4s8vuiMdIE/fVjVvLlRnhKlqYLig7QIpOiva40PAqR2E22neJFrN10AVgWMOIDgPuMOjmRFa+HVaR0fHliaugXoEOe80nBWrZg2dZkZoYffuaW5u1kCVkadmbT70AGdqJodWOhxHqP2eFg1UDvsLatnSFq41M+KKnp6eXbhsdB2OdGiCeX8+/2ecqgnmk/VXNYtqYLSAnNposzpjgw3+H/belpVa8J7TAAAAAElFTkSuQmCC",t.style.position="absolute",t.style.left="50%",t.style.top="50%",t.style.marginLeft="-60px",t.style.marginTop="-60px",t.style.animation="spin1 2s infinite ease-in-out",t.style.webkitAnimation="spin1 2s infinite ease-in-out",t.style.transformOrigin="50% 50%",t.style.webkitTransformOrigin="50% 50%",this._loadingDiv.appendChild(t),this._resizeLoadingUI(),window.addEventListener("resize",this._resizeLoadingUI),this._loadingDiv.style.backgroundColor=this._loadingDivBackgroundColor,document.body.appendChild(this._loadingDiv),this._loadingDiv.style.opacity="1"}},e.prototype.hideLoadingUI=function(){var e=this;if(this._loadingDiv){var t=function(){e._loadingDiv&&(document.body.removeChild(e._loadingDiv),window.removeEventListener("resize",e._resizeLoadingUI),e._loadingDiv=null)};this._loadingDiv.style.opacity="0",this._loadingDiv.addEventListener("transitionend",t)}},Object.defineProperty(e.prototype,"loadingUIText",{set:function(e){this._loadingText=e,this._loadingTextDiv&&(this._loadingTextDiv.innerHTML=this._loadingText)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"loadingUIBackgroundColor",{get:function(){return this._loadingDivBackgroundColor},set:function(e){this._loadingDivBackgroundColor=e,this._loadingDiv&&(this._loadingDiv.style.backgroundColor=this._loadingDivBackgroundColor)},enumerable:!0,configurable:!0}),e})();e.DefaultLoadingScreen=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){}return Object.defineProperty(t,"NO_LOGGING",{get:function(){return 0},enumerable:!0,configurable:!0}),Object.defineProperty(t,"MINIMAL_LOGGING",{get:function(){return 1},enumerable:!0,configurable:!0}),Object.defineProperty(t,"SUMMARY_LOGGING",{get:function(){return 2},enumerable:!0,configurable:!0}),Object.defineProperty(t,"DETAILED_LOGGING",{get:function(){return 3},enumerable:!0,configurable:!0}),Object.defineProperty(t,"ForceFullSceneLoadingForIncremental",{get:function(){return t._ForceFullSceneLoadingForIncremental},set:function(e){t._ForceFullSceneLoadingForIncremental=e},enumerable:!0,configurable:!0}),Object.defineProperty(t,"ShowLoadingScreen",{get:function(){return t._ShowLoadingScreen},set:function(e){t._ShowLoadingScreen=e},enumerable:!0,configurable:!0}),Object.defineProperty(t,"loggingLevel",{get:function(){return t._loggingLevel},set:function(e){t._loggingLevel=e},enumerable:!0,configurable:!0}),Object.defineProperty(t,"CleanBoneMatrixWeights",{get:function(){return t._CleanBoneMatrixWeights},set:function(e){t._CleanBoneMatrixWeights=e},enumerable:!0,configurable:!0}),t._getDefaultPlugin=function(){return t._registeredPlugins[".babylon"]},t._getPluginForExtension=function(e){var r=t._registeredPlugins[e];return r||t._getDefaultPlugin()},t._getPluginForDirectLoad=function(e){for(var r in t._registeredPlugins){var i=t._registeredPlugins[r].plugin;if(i.canDirectLoad&&i.canDirectLoad(e))return t._registeredPlugins[r]}return t._getDefaultPlugin()},t._getPluginForFilename=function(e){e.name&&(e=e.name);var r=e.lastIndexOf("."),i=e.indexOf("?");-1===i&&(i=e.length);var n=e.substring(r,i).toLowerCase();return t._getPluginForExtension(n)},t._getDirectLoad=function(e){return e.substr&&"data:"===e.substr(0,5)?e.substr(5):null},t._loadData=function(r,i,n,o,s,a){var u,l=t._getDirectLoad(i),h=l?t._getPluginForDirectLoad(i):t._getPluginForFilename(i),c=h.plugin,f=h.isBinary;t.OnPluginActivatedObservable.notifyObservers(h.plugin);var d=function(e){if(n.isDisposed)return void a("Scene has been disposed");n.database=u;try{o(c,e)}catch(e){a(null,e)}},p=function(t){e.Tools.LoadFile(r+i,d,s,u,f,(function(e){a(e.status+" "+e.statusText)}))};if(l)return void d(l);-1===r.indexOf("file:")?n.getEngine().enableOfflineSupport?u=new e.Database(r+i,p):p():e.Tools.ReadFile(i,d,s,f)},t.GetPluginForExtension=function(e){return t._getPluginForExtension(e).plugin},t.RegisterPlugin=function(e){if("string"==typeof e.extensions){var r=e.extensions;t._registeredPlugins[r.toLowerCase()]={plugin:e,isBinary:!1}}else{var i=e.extensions;Object.keys(i).forEach((function(r){t._registeredPlugins[r.toLowerCase()]={plugin:e,isBinary:i[r].isBinary}}))}},t.ImportMesh=function(r,i,n,o,s,a,u){if(n.substr&&"/"===n.substr(0,1))return void e.Tools.Error("Wrong sceneFilename parameter");var l={};o._addPendingData(l);var h=function(e,t){u&&u(o,"Unable to import meshes from "+i+n+(e?": "+e:"")),o._removePendingData(l)},c=function(e){a&&a(e)};t._loadData(i,n,o,(function(e,t){if(e.importMesh){var a=e,u=[],f=[],d=[];if(!a.importMesh(r,o,t,i,u,f,d,h))return;s&&(o.importedMeshesFiles.push(i+n),s(u,f,d),o._removePendingData(l))}else{e.importMeshAsync(r,o,t,i,(function(e,t,r){s&&(o.importedMeshesFiles.push(i+n),s(e,t,r),o._removePendingData(l))}),c,h)}}),c,h)},t.Load=function(r,i,n,o,s,a){t.Append(r,i,new e.Scene(n),o,s,a)},t.Append=function(r,i,n,o,s,a){if(i.substr&&"/"===i.substr(0,1))return void e.Tools.Error("Wrong sceneFilename parameter");t.ShowLoadingScreen&&n.getEngine().displayLoadingUI();var u={};n._addPendingData(u);var l=function(e,t){a&&a(n,"Unable to load from "+r+i+(e?": "+e:"")),n._removePendingData(u),n.getEngine().hideLoadingUI()},h=function(e){s&&s(e)};t._loadData(r,i,n,(function(e,i){if(e.load){if(!e.load(n,i,r,l))return;o&&o(n),n.loadingPluginName=e.name,n._removePendingData(u)}else{e.loadAsync(n,i,r,(function(){o&&o(n),n.loadingPluginName=e.name,n._removePendingData(u)}),h,l)}t.ShowLoadingScreen&&n.executeWhenReady((function(){n.getEngine().hideLoadingUI()}))}),h,l)},t._ForceFullSceneLoadingForIncremental=!1,t._ShowLoadingScreen=!0,t._CleanBoneMatrixWeights=!1,t._loggingLevel=t.NO_LOGGING,
- t.OnPluginActivatedObservable=new e.Observable,t._registeredPlugins={},t})();e.SceneLoader=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(t){var r=function(t,r,i,n){for(var o=0,s=r.materials.length;o<s;o++){var a=r.materials[o];if(a.id===t)return e.Material.Parse(a,i,n)}return null},i=function(e,t,r){for(var i in t)if(e.name===t[i])return r.push(e.id),!0;return!(!e.parentId||-1===r.indexOf(e.parentId))&&(r.push(e.id),!0)},n=function(e,t){return e+" of "+(t?t.file+" from "+t.name+" version: "+t.version+", exporter version: "+t.exporter_version:"unknown")};e.SceneLoader.RegisterPlugin({name:"babylon.js",extensions:".babylon",canDirectLoad:function(e){return-1!==e.indexOf("babylon")},importMesh:function(t,o,s,a,u,l,h){var c="importMesh has failed JSON parse";try{var f=JSON.parse(s);c="";var d=e.SceneLoader.loggingLevel===e.SceneLoader.DETAILED_LOGGING;if(t?Array.isArray(t)||(t=[t]):t=null,void 0!==f.meshes&&null!==f.meshes){var p,g,_=[],m=[],v=[];for(p=0,g=f.meshes.length;p<g;p++){var y=f.meshes[p];if(null===t||i(y,t,v)){if(null!==t&&delete t[t.indexOf(y.name)],void 0!==y.geometryId&&null!==y.geometryId&&void 0!==f.geometries&&null!==f.geometries){var A=!1;["boxes","spheres","cylinders","toruses","grounds","planes","torusKnots","vertexData"].forEach((function(t){!0!==A&&f.geometries[t]&&Array.isArray(f.geometries[t])&&f.geometries[t].forEach((function(r){if(r.id===y.geometryId){switch(t){case"boxes":e.Geometry.Primitives.Box.Parse(r,o);break;case"spheres":e.Geometry.Primitives.Sphere.Parse(r,o);break;case"cylinders":e.Geometry.Primitives.Cylinder.Parse(r,o);break;case"toruses":e.Geometry.Primitives.Torus.Parse(r,o);break;case"grounds":e.Geometry.Primitives.Ground.Parse(r,o);break;case"planes":e.Geometry.Primitives.Plane.Parse(r,o);break;case"torusKnots":e.Geometry.Primitives.TorusKnot.Parse(r,o);break;case"vertexData":e.Geometry.Parse(r,o,a)}A=!0}}))})),!1===A&&e.Tools.Warn("Geometry not found for mesh "+y.id)}if(y.materialId){var T=-1!==m.indexOf(y.materialId);if(!1===T&&void 0!==f.multiMaterials&&null!==f.multiMaterials)for(var E=0,b=f.multiMaterials.length;E<b;E++){var x=f.multiMaterials[E];if(x.id===y.materialId){for(var M=0,P=x.materials.length;M<P;M++){var R=x.materials[M];m.push(R);var C=r(R,f,o,a);c+="\n\tMaterial "+C.toString(d)}m.push(x.id);var O=e.Material.ParseMultiMaterial(x,o);T=!0,c+="\n\tMulti-Material "+O.toString(d);break}}if(!1===T){m.push(y.materialId);var C=r(y.materialId,f,o,a);C?c+="\n\tMaterial "+C.toString(d):e.Tools.Warn("Material not found for mesh "+y.id)}}if(y.skeletonId>-1&&void 0!==f.skeletons&&null!==f.skeletons){if(!1===_.indexOf(y.skeletonId)>-1)for(var S=0,I=f.skeletons.length;S<I;S++){var L=f.skeletons[S];if(L.id===y.skeletonId){var D=e.Skeleton.Parse(L,o);h.push(D),_.push(L.id),c+="\n\tSkeleton "+D.toString(d)}}}var B=e.Mesh.Parse(y,o,a);u.push(B),c+="\n\tMesh "+B.toString(d)}}var N;for(p=0,g=o.meshes.length;p<g;p++)N=o.meshes[p],N._waitingParentId&&(N.parent=o.getLastEntryByID(N._waitingParentId),N._waitingParentId=void 0);for(p=0,g=o.meshes.length;p<g;p++)N=o.meshes[p],N._waitingFreezeWorldMatrix?(N.freezeWorldMatrix(),N._waitingFreezeWorldMatrix=void 0):N.computeWorldMatrix(!0)}if(void 0!==f.particleSystems&&null!==f.particleSystems)for(p=0,g=f.particleSystems.length;p<g;p++){var F=f.particleSystems[p];-1!==v.indexOf(F.emitterId)&&l.push(e.ParticleSystem.Parse(F,o,a))}return!0}catch(t){throw e.Tools.Log(n("importMesh",f?f.producer:"Unknown")+c),c=null,t}finally{null!==c&&e.SceneLoader.loggingLevel!==e.SceneLoader.NO_LOGGING&&e.Tools.Log(n("importMesh",f?f.producer:"Unknown")+(e.SceneLoader.loggingLevel!==e.SceneLoader.MINIMAL_LOGGING?c:""))}},load:function(t,r,i){var o="importScene has failed JSON parse";try{var s=JSON.parse(r);o="";var a=e.SceneLoader.loggingLevel===e.SceneLoader.DETAILED_LOGGING;if(void 0!==s.useDelayedTextureLoading&&null!==s.useDelayedTextureLoading&&(t.useDelayedTextureLoading=s.useDelayedTextureLoading&&!e.SceneLoader.ForceFullSceneLoadingForIncremental),void 0!==s.autoClear&&null!==s.autoClear&&(t.autoClear=s.autoClear),void 0!==s.clearColor&&null!==s.clearColor&&(t.clearColor=e.Color4.FromArray(s.clearColor)),void 0!==s.ambientColor&&null!==s.ambientColor&&(t.ambientColor=e.Color3.FromArray(s.ambientColor)),void 0!==s.gravity&&null!==s.gravity&&(t.gravity=e.Vector3.FromArray(s.gravity)),s.fogMode&&0!==s.fogMode)switch(t.fogMode=s.fogMode,t.fogColor=e.Color3.FromArray(s.fogColor),t.fogStart=s.fogStart,t.fogEnd=s.fogEnd,t.fogDensity=s.fogDensity,o+="\tFog mode for scene: ",t.fogMode){case 1:o+="exp\n";break;case 2:o+="exp2\n";break;case 3:o+="linear\n"}if(s.physicsEnabled){var u;"cannon"===s.physicsEngine?u=new e.CannonJSPlugin:"oimo"===s.physicsEngine&&(u=new e.OimoJSPlugin),o="\tPhysics engine "+(s.physicsEngine?s.physicsEngine:"oimo")+" enabled\n";var l=s.physicsGravity?e.Vector3.FromArray(s.physicsGravity):null;t.enablePhysics(l,u)}void 0!==s.metadata&&null!==s.metadata&&(t.metadata=s.metadata),void 0!==s.collisionsEnabled&&null!==s.collisionsEnabled&&(t.collisionsEnabled=s.collisionsEnabled),t.workerCollisions=!!s.workerCollisions;var h,c;if(void 0!==s.lights&&null!==s.lights)for(h=0,c=s.lights.length;h<c;h++){var f=s.lights[h],d=e.Light.Parse(f,t);o+=0===h?"\n\tLights:":"",o+="\n\t\t"+d.toString(a)}if(void 0!==s.animations&&null!==s.animations)for(h=0,c=s.animations.length;h<c;h++){var p=s.animations[h],g=e.Animation.Parse(p);t.animations.push(g),o+=0===h?"\n\tAnimations:":"",o+="\n\t\t"+g.toString(a)}if(s.autoAnimate&&t.beginAnimation(t,s.autoAnimateFrom,s.autoAnimateTo,s.autoAnimateLoop,s.autoAnimateSpeed||1),void 0!==s.materials&&null!==s.materials)for(h=0,c=s.materials.length;h<c;h++){var _=s.materials[h],m=e.Material.Parse(_,t,i);o+=0===h?"\n\tMaterials:":"",o+="\n\t\t"+m.toString(a)}if(void 0!==s.multiMaterials&&null!==s.multiMaterials)for(h=0,c=s.multiMaterials.length;h<c;h++){var v=s.multiMaterials[h],y=e.Material.ParseMultiMaterial(v,t);o+=0===h?"\n\tMultiMaterials:":"",o+="\n\t\t"+y.toString(a)}if(void 0!==s.morphTargetManagers&&null!==s.morphTargetManagers)for(var A=0,T=s.morphTargetManagers;A<T.length;A++){var E=T[A];e.MorphTargetManager.Parse(E,t)}if(void 0!==s.skeletons&&null!==s.skeletons)for(h=0,c=s.skeletons.length;h<c;h++){var b=s.skeletons[h],x=e.Skeleton.Parse(b,t);o+=0===h?"\n\tSkeletons:":"",o+="\n\t\t"+x.toString(a)}var M=s.geometries;if(void 0!==M&&null!==M){var P=M.boxes;if(void 0!==P&&null!==P)for(h=0,c=P.length;h<c;h++){var R=P[h];e.Geometry.Primitives.Box.Parse(R,t)}var C=M.spheres;if(void 0!==C&&null!==C)for(h=0,c=C.length;h<c;h++){var O=C[h];e.Geometry.Primitives.Sphere.Parse(O,t)}var S=M.cylinders;if(void 0!==S&&null!==S)for(h=0,c=S.length;h<c;h++){var I=S[h];e.Geometry.Primitives.Cylinder.Parse(I,t)}var L=M.toruses;if(void 0!==L&&null!==L)for(h=0,c=L.length;h<c;h++){var D=L[h];e.Geometry.Primitives.Torus.Parse(D,t)}var B=M.grounds;if(void 0!==B&&null!==B)for(h=0,c=B.length;h<c;h++){var N=B[h];e.Geometry.Primitives.Ground.Parse(N,t)}var F=M.planes;if(void 0!==F&&null!==F)for(h=0,c=F.length;h<c;h++){var w=F[h];e.Geometry.Primitives.Plane.Parse(w,t)}var V=M.torusKnots;if(void 0!==V&&null!==V)for(h=0,c=V.length;h<c;h++){var U=V[h];e.Geometry.Primitives.TorusKnot.Parse(U,t)}var k=M.vertexData;if(void 0!==k&&null!==k)for(h=0,c=k.length;h<c;h++){var z=k[h];e.Geometry.Parse(z,t,i)}}if(void 0!==s.meshes&&null!==s.meshes)for(h=0,c=s.meshes.length;h<c;h++){var G=s.meshes[h],H=e.Mesh.Parse(G,t,i);o+=0===h?"\n\tMeshes:":"",o+="\n\t\t"+H.toString(a)}if(void 0!==s.cameras&&null!==s.cameras)for(h=0,c=s.cameras.length;h<c;h++){var Y=s.cameras[h],W=e.Camera.Parse(Y,t);o+=0===h?"\n\tCameras:":"",o+="\n\t\t"+W.toString(a)}for(void 0!==s.activeCameraID&&null!==s.activeCameraID&&t.setActiveCameraByID(s.activeCameraID),h=0,c=t.cameras.length;h<c;h++){var W=t.cameras[h];W._waitingParentId&&(W.parent=t.getLastEntryByID(W._waitingParentId),W._waitingParentId=void 0)}for(h=0,c=t.lights.length;h<c;h++){var d=t.lights[h];d._waitingParentId&&(d.parent=t.getLastEntryByID(d._waitingParentId),d._waitingParentId=void 0)}var X,j=[];if(e.AudioEngine&&void 0!==s.sounds&&null!==s.sounds)for(h=0,c=s.sounds.length;h<c;h++){var K=s.sounds[h];if(e.Engine.audioEngine.canUseWebAudio)K.url||(K.url=K.name),j[K.url]?e.Sound.Parse(K,t,i,j[K.url]):(X=e.Sound.Parse(K,t,i),j[K.url]=X);else{new e.Sound(K.name,null,t)}}for(j=[],h=0,c=t.meshes.length;h<c;h++){var H=t.meshes[h];H._waitingParentId&&(H.parent=t.getLastEntryByID(H._waitingParentId),H._waitingParentId=void 0),H._waitingActions&&(e.ActionManager.Parse(H._waitingActions,H,t),H._waitingActions=void 0)}for(h=0,c=t.meshes.length;h<c;h++){var Q=t.meshes[h];Q._waitingFreezeWorldMatrix?(Q.freezeWorldMatrix(),Q._waitingFreezeWorldMatrix=void 0):Q.computeWorldMatrix(!0)}if(void 0!==s.particleSystems&&null!==s.particleSystems)for(h=0,c=s.particleSystems.length;h<c;h++){var Z=s.particleSystems[h];e.ParticleSystem.Parse(Z,t,i)}if(void 0!==s.lensFlareSystems&&null!==s.lensFlareSystems)for(h=0,c=s.lensFlareSystems.length;h<c;h++){var q=s.lensFlareSystems[h];e.LensFlareSystem.Parse(q,t,i)}if(void 0!==s.shadowGenerators&&null!==s.shadowGenerators)for(h=0,c=s.shadowGenerators.length;h<c;h++){var J=s.shadowGenerators[h];e.ShadowGenerator.Parse(J,t)}for(h=0,c=t.lights.length;h<c;h++){var d=t.lights[h];if(d._excludedMeshesIds.length>0){for(var $=0;$<d._excludedMeshesIds.length;$++){var ee=t.getMeshByID(d._excludedMeshesIds[$]);ee&&d.excludedMeshes.push(ee)}d._excludedMeshesIds=[]}if(d._includedOnlyMeshesIds.length>0){for(var te=0;te<d._includedOnlyMeshesIds.length;te++){var re=t.getMeshByID(d._includedOnlyMeshesIds[te]);re&&d.includedOnlyMeshes.push(re)}d._includedOnlyMeshesIds=[]}}return void 0!==s.actions&&null!==s.actions&&e.ActionManager.Parse(s.actions,null,t),!0}catch(t){throw e.Tools.Log(n("importScene",s?s.producer:"Unknown")+o),o=null,t}finally{null!==o&&e.SceneLoader.loggingLevel!==e.SceneLoader.NO_LOGGING&&e.Tools.Log(n("importScene",s?s.producer:"Unknown")+(e.SceneLoader.loggingLevel!==e.SceneLoader.MINIMAL_LOGGING?o:""))}}})})(e.Internals||(e.Internals={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(e,t,r,i,n,o,s,a){this._engine=e,this._canvas=r,this._currentScene=t,this._sceneLoadedCallback=i,this._progressCallback=n,this._additionnalRenderLoopLogicCallback=o,this._textureLoadingCallback=s,this._startingProcessingFilesCallback=a}return t.prototype.monitorElementForDragNDrop=function(e){var t=this;e&&(this._elementToMonitor=e,this._elementToMonitor.addEventListener("dragenter",(function(e){t.drag(e)}),!1),this._elementToMonitor.addEventListener("dragover",(function(e){t.drag(e)}),!1),this._elementToMonitor.addEventListener("drop",(function(e){t.drop(e)}),!1))},t.prototype.renderFunction=function(){if(this._additionnalRenderLoopLogicCallback&&this._additionnalRenderLoopLogicCallback(),this._currentScene){if(this._textureLoadingCallback){var e=this._currentScene.getWaitingItemsCount();e>0&&this._textureLoadingCallback(e)}this._currentScene.render()}},t.prototype.drag=function(e){e.stopPropagation(),e.preventDefault()},t.prototype.drop=function(e){e.stopPropagation(),e.preventDefault(),this.loadFiles(e)},t.prototype._handleFolderDrop=function(e,t,r){var i=e.createReader(),n=e.fullPath.replace(/^\//,"").replace(/(.+?)\/?$/,"$1/");i.readEntries((function(e){for(var i=e.length,o=0,s=e;o<s.length;o++){var a=s[o];a.isFile?a.file((function(e){e.correctName=n+e.name,t.push(e),0===--i&&r()})):0===--i&&r()}}))},t.prototype._processFiles=function(e){for(var r=0;r<e.length;r++){var i=e[r].correctName.toLowerCase(),n=i.split(".").pop();"babylon"!==n&&"stl"!==n&&"obj"!==n&&"gltf"!==n&&"glb"!==n||-1!==i.indexOf(".binary.babylon")||-1!==i.indexOf(".incremental.babylon")?t.FilesToLoad[i]=e[r]:this._sceneFileToLoad=e[r]}this.reload()},t.prototype.loadFiles=function(e){var t=this;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 r=[],i=[],n=0;n<this._filesToLoad.length;n++){var o=this._filesToLoad[n],s=o.name.toLowerCase(),a=(o.type,void 0);if(o.correctName=s,e.dataTransfer&&e.dataTransfer.items){var u=e.dataTransfer.items[n];u.getAsEntry?a=u.getAsEntry():u.webkitGetAsEntry&&(a=u.webkitGetAsEntry())}a&&a.isDirectory?i.push(a):r.push(o)}if(0===i.length)this._processFiles(r);else for(var l=i.length,h=0,c=i;h<c.length;h++){var f=c[h];this._handleFolderDrop(f,r,(function(){0===--l&&t._processFiles(r)}))}}},t.prototype.reload=function(){var t=this,r=this;this._sceneFileToLoad?(this._currentScene&&(e.Tools.errorsCount>0&&(e.Tools.ClearLogCache(),e.Tools.Log("Babylon.js engine (v"+e.Engine.Version+") launched")),this._engine.stopRenderLoop(),this._currentScene.dispose()),e.SceneLoader.Load("file:",this._sceneFileToLoad,this._engine,(function(e){r._currentScene=e,r._currentScene.executeWhenReady((function(){r._sceneLoadedCallback&&r._sceneLoadedCallback(t._sceneFileToLoad,r._currentScene),r._engine.runRenderLoop((function(){r.renderFunction()}))}))}),(function(e){t._progressCallback&&t._progressCallback(e)}))):e.Tools.Error("Please provide a valid .babylon file.")},t.FilesToLoad=new Array,t})();e.FilesInput=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){this._mode=t.IgnoreBoundsSizeMode,this._relativeRadius=1,this._elevation=.3,this._positionY=0,this._defaultElevation=.3,this._elevationReturnTime=1500,this._elevationReturnWaitTime=1e3,this._zoomStopsAnimation=!1,this._framingTime=1500,this._isPointerDown=!1,this._lastFrameTime=null,this._lastInteractionTime=-1/0,this._animatables=new Array,this._betaIsAnimating=!1,this._lastFrameRadius=0}return Object.defineProperty(t.prototype,"name",{get:function(){return"Framing"},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"mode",{get:function(){return this._mode},set:function(e){this._mode=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"relativeRadius",{get:function(){return this._relativeRadius},set:function(e){this._relativeRadius=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"elevation",{get:function(){return this._elevation},set:function(e){this._elevation=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"positionY",{get:function(){return this._positionY},set:function(e){this._positionY=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"defaultElevation",{get:function(){return this._defaultElevation},set:function(e){this._defaultElevation=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"elevationReturnTime",{get:function(){return this._elevationReturnTime},set:function(e){this._elevationReturnTime=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"elevationReturnWaitTime",{get:function(){return this._elevationReturnWaitTime},set:function(e){this._elevationReturnWaitTime=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"zoomStopsAnimation",{get:function(){return this._zoomStopsAnimation},set:function(e){this._zoomStopsAnimation=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"framingTime",{get:function(){return this._framingTime},set:function(e){this._framingTime=e},enumerable:!0,configurable:!0}),t.prototype.attach=function(r){var i=this;this._attachedCamera=r;var n=this._attachedCamera.getScene();t.EasingFunction.setEasingMode(t.EasingMode),this._onPrePointerObservableObserver=n.onPrePointerObservable.add((function(t){if(t.type===e.PointerEventTypes.POINTERDOWN)return void(i._isPointerDown=!0);t.type===e.PointerEventTypes.POINTERUP&&(i._isPointerDown=!1)})),this._onMeshTargetChangedObserver=r.onMeshTargetChangedObservable.add((function(e){e&&i.zoomOnMesh(e)})),this._onAfterCheckInputsObserver=r.onAfterCheckInputsObservable.add((function(){i._applyUserInteraction(),i._maintainCameraAboveGround()}))},t.prototype.detach=function(e){this._attachedCamera.getScene().onPrePointerObservable.remove(this._onPrePointerObservableObserver),e.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver),e.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver)},t.prototype.zoomOnMesh=function(r,i,n,o,s){void 0===n&&(n=!1),void 0===s&&(s=!0),null==o&&(o=this._positionY),r.computeWorldMatrix(!0);var a,u=r.getBoundingInfo().boundingSphere.centerWorld;if(a=s?new e.Vector3(0,u.y,0):u.clone(),this._attachedCamera.setTarget(a),null==i){if(this._mode===t.FitFrustumSidesMode){var l=this._calculateLowerRadiusFromModelBoundingSphere(r);this._attachedCamera.lowerRadiusLimit=l-.1,i=l}else this._mode===t.IgnoreBoundsSizeMode&&(i=this._calculateLowerRadiusFromModelBoundingSphere(r))}n&&(this._attachedCamera.lowerRadiusLimit=i)},t.prototype._calculateLowerRadiusFromModelBoundingSphere=function(e){var r=e.getBoundingInfo().diagonalLength,i=this._getFrustumSlope(),n=.5*r,o=(e.getBoundingInfo().boundingSphere.radiusWorld,n*this._relativeRadius),s=o*Math.sqrt(1+1/(i.x*i.x)),a=o*Math.sqrt(1+1/(i.y*i.y)),u=Math.max(s,a),l=this._attachedCamera;return l.lowerRadiusLimit&&this._mode===t.IgnoreBoundsSizeMode&&(u=u<l.lowerRadiusLimit?l.lowerRadiusLimit:u),l.upperRadiusLimit&&(u=u>l.upperRadiusLimit?l.upperRadiusLimit:u),u},t.prototype._maintainCameraAboveGround=function(){var r=this,i=e.Tools.Now-this._lastInteractionTime,n=.5*Math.PI-this._defaultElevation,o=.5*Math.PI;!this._betaIsAnimating&&this._attachedCamera.beta>o&&i>=this._elevationReturnWaitTime&&(this._betaIsAnimating=!0,this.stopAllAnimations(),this._betaTransition||(this._betaTransition=e.Animation.CreateAnimation("beta",e.Animation.ANIMATIONTYPE_FLOAT,60,t.EasingFunction)),this._animatables.push(e.Animation.TransitionTo("beta",n,this._attachedCamera,this._attachedCamera.getScene(),60,this._betaTransition,this._elevationReturnTime,(function(){r._clearAnimationLocks(),r.stopAllAnimations()}))))},t.prototype._getFrustumSlope=function(){var t=this._attachedCamera,r=t.getScene().getEngine(),i=r.getAspectRatio(t),n=Math.tan(t.fov/2),o=n/i;return new e.Vector2(o,n)},t.prototype._clearAnimationLocks=function(){this._betaIsAnimating=!1},t.prototype._applyUserInteraction=function(){this._userIsMoving()&&(this._lastInteractionTime=e.Tools.Now,this.stopAllAnimations(),this._clearAnimationLocks())},t.prototype.stopAllAnimations=function(){for(this._attachedCamera.animations=[];this._animatables.length;)this._animatables[0].onAnimationEnd=null,this._animatables[0].stop(),this._animatables.shift()},t.prototype._userIsMoving=function(){return 0!==this._attachedCamera.inertialAlphaOffset||0!==this._attachedCamera.inertialBetaOffset||0!==this._attachedCamera.inertialRadiusOffset||0!==this._attachedCamera.inertialPanningX||0!==this._attachedCamera.inertialPanningY||this._isPointerDown},t.EasingFunction=new e.ExponentialEase,t.EasingMode=e.EasingFunction.EASINGMODE_EASEINOUT,t.IgnoreBoundsSizeMode=0,t.FitFrustumSidesMode=1,t})();e.FramingBehavior=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){this.transitionDuration=450,this.lowerRadiusTransitionRange=2,this.upperRadiusTransitionRange=-2,this._radiusIsAnimating=!1,this._radiusBounceTransition=null,this._animatables=new Array}return Object.defineProperty(t.prototype,"name",{get:function(){return"Bouncing"},enumerable:!0,configurable:!0}),t.prototype.attach=function(e){var t=this;this._attachedCamera=e,this._onAfterCheckInputsObserver=e.onAfterCheckInputsObservable.add((function(){t._isRadiusAtLimit(t._attachedCamera.lowerRadiusLimit)&&t._applyBoundRadiusAnimation(t.lowerRadiusTransitionRange),t._isRadiusAtLimit(t._attachedCamera.upperRadiusLimit)&&t._applyBoundRadiusAnimation(t.upperRadiusTransitionRange)}))},t.prototype.detach=function(e){e.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver)},t.prototype._isRadiusAtLimit=function(e){return this._attachedCamera.radius===e&&!this._radiusIsAnimating},t.prototype._applyBoundRadiusAnimation=function(r){var i=this;this._radiusBounceTransition||(t.EasingFunction.setEasingMode(t.EasingMode),this._radiusBounceTransition=e.Animation.CreateAnimation("radius",e.Animation.ANIMATIONTYPE_FLOAT,60,t.EasingFunction)),this._cachedWheelPrecision=this._attachedCamera.wheelPrecision,this._attachedCamera.wheelPrecision=1/0,this._attachedCamera.inertialRadiusOffset=0,this.stopAllAnimations(),this._radiusIsAnimating=!0,this._animatables.push(e.Animation.TransitionTo("radius",this._attachedCamera.radius+r,this._attachedCamera,this._attachedCamera.getScene(),60,this._radiusBounceTransition,this.transitionDuration,(function(){return i._clearAnimationLocks()})))},t.prototype._clearAnimationLocks=function(){this._radiusIsAnimating=!1,this._attachedCamera.wheelPrecision=this._cachedWheelPrecision},t.prototype.stopAllAnimations=function(){for(this._attachedCamera.animations=[];this._animatables.length;)this._animatables[0].onAnimationEnd=null,this._animatables[0].stop(),this._animatables.shift()},t.EasingFunction=new e.BackEase(.3),t.EasingMode=e.EasingFunction.EASINGMODE_EASEOUT,t})();e.BouncingBehavior=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){this._zoomStopsAnimation=!1,this._idleRotationSpeed=.05,this._idleRotationWaitTime=2e3,this._idleRotationSpinupTime=2e3,this._isPointerDown=!1,this._lastFrameTime=null,this._lastInteractionTime=-1/0,this._lastFrameRadius=0}return Object.defineProperty(t.prototype,"name",{get:function(){return"AutoRotation"},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"zoomStopsAnimation",{get:function(){return this._zoomStopsAnimation},set:function(e){this._zoomStopsAnimation=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"idleRotationSpeed",{get:function(){return this._idleRotationSpeed},set:function(e){this._idleRotationSpeed=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"idleRotationWaitTime",{get:function(){return this._idleRotationWaitTime},set:function(e){this._idleRotationWaitTime=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"idleRotationSpinupTime",{get:function(){return this._idleRotationSpinupTime},set:function(e){this._idleRotationSpinupTime=e},enumerable:!0,configurable:!0}),t.prototype.attach=function(t){var r=this;this._attachedCamera=t;var i=this._attachedCamera.getScene();this._onPrePointerObservableObserver=i.onPrePointerObservable.add((function(t){if(t.type===e.PointerEventTypes.POINTERDOWN)return void(r._isPointerDown=!0);t.type===e.PointerEventTypes.POINTERUP&&(r._isPointerDown=!1)})),this._onAfterCheckInputsObserver=t.onAfterCheckInputsObservable.add((function(){var t=e.Tools.Now,i=16;null!=r._lastFrameTime&&(i=t-r._lastFrameTime),r._lastFrameTime=t,r._applyUserInteraction();var n=t-r._lastInteractionTime-r._idleRotationWaitTime,o=Math.max(Math.min(n/r._idleRotationSpinupTime,1),0),s=r._idleRotationSpeed*o;r._attachedCamera.alpha-=s*(i/1e3)}))},t.prototype.detach=function(e){this._attachedCamera.getScene().onPrePointerObservable.remove(this._onPrePointerObservableObserver),e.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver)},t.prototype._userIsZooming=function(){return 0!==this._attachedCamera.inertialRadiusOffset},t.prototype._shouldAnimationStopForInteraction=function(){var e=!1;return this._lastFrameRadius===this._attachedCamera.radius&&0!==this._attachedCamera.inertialRadiusOffset&&(e=!0),this._lastFrameRadius=this._attachedCamera.radius,this._zoomStopsAnimation?e:this._userIsZooming()},t.prototype._applyUserInteraction=function(){this._userIsMoving()&&!this._shouldAnimationStopForInteraction()&&(this._lastInteractionTime=e.Tools.Now)},t.prototype._userIsMoving=function(){return 0!==this._attachedCamera.inertialAlphaOffset||0!==this._attachedCamera.inertialBetaOffset||0!==this._attachedCamera.inertialRadiusOffset||0!==this._attachedCamera.inertialPanningX||0!==this._attachedCamera.inertialPanningY||this._isPointerDown},t})();e.AutoRotationBehavior=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(t,r){void 0===r&&(r=0),this.name=t,this.animations=new Array,this.onInfluenceChanged=new e.Observable,this.influence=r}return Object.defineProperty(t.prototype,"influence",{get:function(){return this._influence},set:function(e){if(this._influence!==e){var t=this._influence;this._influence=e,this.onInfluenceChanged.hasObservers&&this.onInfluenceChanged.notifyObservers(0===t||0===e)}},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"hasNormals",{get:function(){return void 0!==this._normals},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"hasTangents",{get:function(){return void 0!==this._tangents},enumerable:!0,configurable:!0}),t.prototype.setPositions=function(e){this._positions=new Float32Array(e)},t.prototype.getPositions=function(){return this._positions},t.prototype.setNormals=function(e){this._normals=new Float32Array(e)},t.prototype.getNormals=function(){return this._normals},t.prototype.setTangents=function(e){this._tangents=new Float32Array(e)},t.prototype.getTangents=function(){return this._tangents},t.prototype.serialize=function(){var e={};return e.name=this.name,e.influence=this.influence,e.positions=Array.prototype.slice.call(this.getPositions()),this.hasNormals&&(e.normals=Array.prototype.slice.call(this.getNormals())),this.hasTangents&&(e.tangents=Array.prototype.slice.call(this.getTangents())),e},t.Parse=function(e){var r=new t(e.name,e.influence);return r.setPositions(e.positions),e.normals&&r.setNormals(e.normals),e.tangents&&r.setTangents(e.tangents),r},t.FromMesh=function(r,i,n){i||(i=r.name);var o=new t(i,n);return o.setPositions(r.getVerticesData(e.VertexBuffer.PositionKind)),r.isVerticesDataPresent(e.VertexBuffer.NormalKind)&&o.setNormals(r.getVerticesData(e.VertexBuffer.NormalKind)),r.isVerticesDataPresent(e.VertexBuffer.TangentKind)&&o.setTangents(r.getVerticesData(e.VertexBuffer.TangentKind)),o},t})();e.MorphTarget=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(t){this._targets=new Array,this._targetObservable=new Array,this._activeTargets=new e.SmartArray(16),this._supportsNormals=!1,this._supportsTangents=!1,this._vertexCount=0,this._uniqueId=0,this._tempInfluences=new Array,t||(t=e.Engine.LastCreatedScene),this._scene=t,this._scene.morphTargetManagers.push(this),this._uniqueId=t.getUniqueId()}return Object.defineProperty(t.prototype,"uniqueId",{get:function(){return this._uniqueId},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"vertexCount",{get:function(){return this._vertexCount},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"supportsNormals",{get:function(){return this._supportsNormals},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"supportsTangents",{get:function(){return this._supportsTangents},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"numTargets",{get:function(){return this._targets.length},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"numInfluencers",{get:function(){return this._activeTargets.length},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"influences",{get:function(){return this._influences},enumerable:!0,configurable:!0}),t.prototype.getActiveTarget=function(e){return this._activeTargets.data[e]},t.prototype.getTarget=function(e){return this._targets[e]},t.prototype.addTarget=function(t){var r=this;if(this._vertexCount&&this._vertexCount!==t.getPositions().length/3)return void e.Tools.Error("Incompatible target. Targets must all have the same vertices count.");this._targets.push(t),this._targetObservable.push(t.onInfluenceChanged.add((function(e){r._syncActiveTargets(e)}))),this._syncActiveTargets(!0)},t.prototype.removeTarget=function(e){var t=this._targets.indexOf(e);t>=0&&(this._targets.splice(t,1),e.onInfluenceChanged.remove(this._targetObservable.splice(t,1)[0]),this._vertexCount=0,this._syncActiveTargets(!0))},t.prototype.serialize=function(){var e={};e.id=this.uniqueId,e.targets=[];for(var t=0,r=this._targets;t<r.length;t++){var i=r[t];e.targets.push(i.serialize())}return e},t.prototype._onInfluenceChanged=function(e){this._syncActiveTargets(e)},t.prototype._syncActiveTargets=function(e){var t=0;this._activeTargets.reset(),this._supportsNormals=!0,this._supportsTangents=!0;for(var r=0,i=this._targets;r<i.length;r++){var n=i[r];n.influence>0&&(this._activeTargets.push(n),this._tempInfluences[t++]=n.influence,this._supportsNormals=this._supportsNormals&&n.hasNormals,this._supportsTangents=this._supportsTangents&&n.hasTangents,0===this._vertexCount&&(this._vertexCount=n.getPositions().length/3))}this._influences&&this._influences.length===t||(this._influences=new Float32Array(t));for(var o=0;o<t;o++)this._influences[o]=this._tempInfluences[o];if(e)for(var s=0,a=this._scene.meshes;s<a.length;s++){var u=a[s];u.morphTargetManager===this&&u._syncGeometryWithMorphTargetManager()}},t.Parse=function(r,i){var n=new t(i);n._uniqueId=r.id;for(var o=0,s=r.targets;o<s.length;o++){var a=s[o];n.addTarget(e.MorphTarget.Parse(a))}return n},t})();e.MorphTargetManager=t})(BABYLON||(BABYLON={})),BABYLON.Effect.ShadersStore={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}",passPixelShader:"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nvoid main(void) \n{\ngl_FragColor=texture2D(textureSampler,vUV);\n}",shadowMapVertexShader:"\nattribute vec3 position;\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\nuniform mat4 viewProjection;\nuniform vec2 biasAndScale;\nuniform vec2 depthValues;\nvarying float vDepthMetric;\n#ifdef ALPHATEST\nvarying vec2 vUV;\nuniform mat4 diffuseMatrix;\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#endif\nvoid main(void)\n{\n#include<instancesVertex>\n#include<bonesVertex>\nvec4 worldPos=finalWorld*vec4(position,1.0);\ngl_Position=viewProjection*worldPos;\nvDepthMetric=((gl_Position.z+depthValues.x)/(depthValues.y))+biasAndScale.x;\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}",shadowMapPixelShader:"#ifndef FLOAT\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#endif\nvarying float vDepthMetric;\n#ifdef ALPHATEST\nvarying vec2 vUV;\nuniform sampler2D diffuseSampler;\n#endif\nuniform vec2 biasAndScale;\nuniform vec2 depthValues;\nvoid main(void)\n{\n#ifdef ALPHATEST\nif (texture2D(diffuseSampler,vUV).a<0.4)\ndiscard;\n#endif\nfloat depth=vDepthMetric;\n#ifdef ESM\ndepth=clamp(exp(-min(87.,biasAndScale.y*depth)),0.,1.);\n#endif\n#ifdef FLOAT\ngl_FragColor=vec4(depth,1.0,1.0,1.0);\n#else\ngl_FragColor=pack(depth);\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}",
- pbrVertexShader:"precision highp float;\n#include<__decl__pbrVertex>\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#ifdef TANGENT\nattribute vec4 tangent;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2; \n#endif \n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\n#if defined(ALBEDO) && ALBEDODIRECTUV == 0\nvarying vec2 vAlbedoUV;\n#endif\n#if defined(AMBIENT) && AMBIENTDIRECTUV == 0\nvarying vec2 vAmbientUV;\n#endif\n#if defined(OPACITY) && OPACITYDIRECTUV == 0\nvarying vec2 vOpacityUV;\n#endif\n#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0\nvarying vec2 vEmissiveUV;\n#endif\n#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0\nvarying vec2 vLightmapUV;\n#endif\n#if defined(REFLECTIVITY) && REFLECTIVITYDIRECTUV == 0\nvarying vec2 vReflectivityUV;\n#endif\n#if defined(MICROSURFACEMAP) && MICROSURFACEMAPDIRECTUV == 0\nvarying vec2 vMicroSurfaceSamplerUV;\n#endif\n#if defined(BUMP) && BUMPDIRECTUV == 0\nvarying vec2 vBumpUV;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#if defined(USESPHERICALFROMREFLECTIONMAP) && !defined(USESPHERICALINFRAGMENT)\nvarying vec3 vEnvironmentIrradiance;\n#include<harmonicsFunctions>\n#endif\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<bumpVertexDeclaration>\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<morphTargetsVertexGlobalDeclaration>\n#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#include<logDepthDeclaration>\nvoid main(void) {\nvec3 positionUpdated=position;\n#ifdef NORMAL\nvec3 normalUpdated=normal;\n#endif\n#ifdef TANGENT\nvec4 tangentUpdated=tangent;\n#endif\n#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\nvPositionUVW=positionUpdated;\n#endif \n#include<instancesVertex>\n#include<bonesVertex>\ngl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);\nvec4 worldPos=finalWorld*vec4(positionUpdated,1.0);\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nvNormalW=normalize(vec3(finalWorld*vec4(normalUpdated,0.0)));\n#if defined(USESPHERICALFROMREFLECTIONMAP) && !defined(USESPHERICALINFRAGMENT)\nvec3 reflectionVector=vec3(reflectionMatrix*vec4(vNormalW,0)).xyz;\n#ifdef REFLECTIONMAP_OPPOSITEZ\nreflectionVector.z*=-1.0;\n#endif\nvEnvironmentIrradiance=environmentIrradianceJones(reflectionVector);\n#endif\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvDirectionW=normalize(vec3(finalWorld*vec4(positionUpdated,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 MAINUV1\nvMainUV1=uv;\n#endif \n#ifdef MAINUV2\nvMainUV2=uv2;\n#endif \n#if defined(ALBEDO) && ALBEDODIRECTUV == 0 \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#if defined(AMBIENT) && AMBIENTDIRECTUV == 0 \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#if defined(OPACITY) && OPACITYDIRECTUV == 0 \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#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0 \nif (vEmissiveInfos.x == 0.)\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0 \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) && REFLECTIVITYDIRECTUV == 0 \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#if defined(MICROSURFACEMAP) && MICROSURFACEMAPDIRECTUV == 0 \nif (vMicroSurfaceSamplerInfos.x == 0.)\n{\nvMicroSurfaceSamplerUV=vec2(microSurfaceSamplerMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvMicroSurfaceSamplerUV=vec2(microSurfaceSamplerMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(BUMP) && BUMPDIRECTUV == 0 \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<bumpVertex>\n\n#include<clipPlaneVertex>\n\n#include<fogVertex>\n\n#include<shadowsVertex>[0..maxSimultaneousLights]\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n\n#include<logDepthVertex>\n}",pbrPixelShader:"#if defined(BUMP) || !defined(NORMAL) || defined(FORCENORMALFORWARD)\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;\n#include<__decl__pbrFragment>\nuniform vec4 vEyePosition;\nuniform vec3 vAmbientColor;\nuniform vec4 vCameraInfos;\n\nvarying vec3 vPositionW;\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif \n#ifdef MAINUV2 \nvarying vec2 vMainUV2; \n#endif \n#ifdef NORMAL\nvarying vec3 vNormalW;\n#if defined(USESPHERICALFROMREFLECTIONMAP) && !defined(USESPHERICALINFRAGMENT)\nvarying vec3 vEnvironmentIrradiance;\n#endif\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n\n#ifdef ALBEDO\n#if ALBEDODIRECTUV == 1\n#define vAlbedoUV vMainUV1\n#elif ALBEDODIRECTUV == 2\n#define vAlbedoUV vMainUV2\n#else\nvarying vec2 vAlbedoUV;\n#endif\nuniform sampler2D albedoSampler;\n#endif\n#ifdef AMBIENT\n#if AMBIENTDIRECTUV == 1\n#define vAmbientUV vMainUV1\n#elif AMBIENTDIRECTUV == 2\n#define vAmbientUV vMainUV2\n#else\nvarying vec2 vAmbientUV;\n#endif\nuniform sampler2D ambientSampler;\n#endif\n#ifdef OPACITY\n#if OPACITYDIRECTUV == 1\n#define vOpacityUV vMainUV1\n#elif OPACITYDIRECTUV == 2\n#define vOpacityUV vMainUV2\n#else\nvarying vec2 vOpacityUV;\n#endif\nuniform sampler2D opacitySampler;\n#endif\n#ifdef EMISSIVE\n#if EMISSIVEDIRECTUV == 1\n#define vEmissiveUV vMainUV1\n#elif EMISSIVEDIRECTUV == 2\n#define vEmissiveUV vMainUV2\n#else\nvarying vec2 vEmissiveUV;\n#endif\nuniform sampler2D emissiveSampler;\n#endif\n#ifdef LIGHTMAP\n#if LIGHTMAPDIRECTUV == 1\n#define vLightmapUV vMainUV1\n#elif LIGHTMAPDIRECTUV == 2\n#define vLightmapUV vMainUV2\n#else\nvarying vec2 vLightmapUV;\n#endif\nuniform sampler2D lightmapSampler;\n#endif\n#ifdef REFLECTIVITY\n#if REFLECTIVITYDIRECTUV == 1\n#define vReflectivityUV vMainUV1\n#elif REFLECTIVITYDIRECTUV == 2\n#define vReflectivityUV vMainUV2\n#else\nvarying vec2 vReflectivityUV;\n#endif\nuniform sampler2D reflectivitySampler;\n#endif\n#ifdef MICROSURFACEMAP\n#if MICROSURFACEMAPDIRECTUV == 1\n#define vMicroSurfaceSamplerUV vMainUV1\n#elif MICROSURFACEMAPDIRECTUV == 2\n#define vMicroSurfaceSamplerUV vMainUV2\n#else\nvarying vec2 vMicroSurfaceSamplerUV;\n#endif\nuniform sampler2D microSurfaceSampler;\n#endif\n\n#ifdef REFRACTION\n#ifdef REFRACTIONMAP_3D\n#define sampleRefraction(s,c) textureCube(s,c)\nuniform samplerCube refractionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleRefractionLod(s,c,l) textureCubeLodEXT(s,c,l)\n#else\nuniform samplerCube refractionSamplerLow;\nuniform samplerCube refractionSamplerHigh;\n#endif\n#else\n#define sampleRefraction(s,c) texture2D(s,c)\nuniform sampler2D refractionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleRefractionLod(s,c,l) texture2DLodEXT(s,c,l)\n#else\nuniform samplerCube refractionSamplerLow;\nuniform samplerCube refractionSamplerHigh;\n#endif\n#endif\n#endif\n\n#ifdef REFLECTION\n#ifdef REFLECTIONMAP_3D\n#define sampleReflection(s,c) textureCube(s,c)\nuniform samplerCube reflectionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleReflectionLod(s,c,l) textureCubeLodEXT(s,c,l)\n#else\nuniform samplerCube reflectionSamplerLow;\nuniform samplerCube reflectionSamplerHigh;\n#endif\n#else\n#define sampleReflection(s,c) texture2D(s,c)\nuniform sampler2D reflectionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleReflectionLod(s,c,l) texture2DLodEXT(s,c,l)\n#else\nuniform samplerCube reflectionSamplerLow;\nuniform samplerCube reflectionSamplerHigh;\n#endif\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#else\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#endif\n#include<reflectionFunction>\n#endif\n#ifdef ENVIRONMENTBRDF\nuniform sampler2D environmentBrdfSampler;\n#endif\n\n#ifndef FROMLINEARSPACE\n#define FROMLINEARSPACE;\n#endif\n#include<imageProcessingDeclaration>\n#include<helperFunctions>\n#include<imageProcessingFunctions>\n\n#include<shadowsFragmentFunctions>\n#include<pbrFunctions>\n#include<harmonicsFunctions>\n#include<pbrLightFunctions>\n#include<bumpFragmentFunctions>\n#include<clipPlaneFragmentDeclaration>\n#include<logDepthDeclaration>\n\n#include<fogFragmentDeclaration>\nvoid main(void) {\n#include<clipPlaneFragment>\n\n\nvec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=normalize(cross(dFdx(vPositionW),dFdy(vPositionW)))*vEyePosition.w;\n#endif\n#include<bumpFragment>\n#if defined(FORCENORMALFORWARD) && defined(NORMAL)\nvec3 faceNormal=normalize(cross(dFdx(vPositionW),dFdy(vPositionW)))*vEyePosition.w;\n#if defined(TWOSIDEDLIGHTING)\nfaceNormal=gl_FrontFacing ? faceNormal : -faceNormal;\n#endif\nfloat comp=sign(dot(normalW,faceNormal));\nnormalW*=-comp;\n#endif\n#if defined(TWOSIDEDLIGHTING) && defined(NORMAL)\nnormalW=gl_FrontFacing ? normalW : -normalW;\n#endif\n\n\nvec3 surfaceAlbedo=vAlbedoColor.rgb;\n\nfloat alpha=vAlbedoColor.a;\n#ifdef ALBEDO\nvec4 albedoTexture=texture2D(albedoSampler,vAlbedoUV+uvOffset);\n#if defined(ALPHAFROMALBEDO) || defined(ALPHATEST)\nalpha*=albedoTexture.a;\n#endif\nsurfaceAlbedo*=toLinearSpace(albedoTexture.rgb);\nsurfaceAlbedo*=vAlbedoInfos.y;\n#endif\n\n#ifdef OPACITY\nvec4 opacityMap=texture2D(opacitySampler,vOpacityUV+uvOffset);\n#ifdef OPACITYRGB\nalpha=getLuminance(opacityMap.rgb);\n#else\nalpha*=opacityMap.a;\n#endif\nalpha*=vOpacityInfos.y;\n#endif\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n#if !defined(LINKREFRACTIONTOTRANSPARENCY) && !defined(ALPHAFRESNEL)\n#ifdef ALPHATEST\nif (alpha<=ALPHATESTVALUE)\ndiscard;\n#ifndef ALPHABLEND\n\nalpha=1.0;\n#endif\n#endif\n#endif\n#ifdef VERTEXCOLOR\nsurfaceAlbedo*=vColor.rgb;\n#endif\n\nvec3 ambientOcclusionColor=vec3(1.,1.,1.);\n#ifdef AMBIENT\nvec3 ambientOcclusionColorMap=texture2D(ambientSampler,vAmbientUV+uvOffset).rgb*vAmbientInfos.y;\n#ifdef AMBIENTINGRAYSCALE\nambientOcclusionColorMap=vec3(ambientOcclusionColorMap.r,ambientOcclusionColorMap.r,ambientOcclusionColorMap.r);\n#endif\nambientOcclusionColor=mix(ambientOcclusionColor,ambientOcclusionColorMap,vAmbientInfos.z);\n#endif\n\nfloat microSurface=vReflectivityColor.a;\nvec3 surfaceReflectivityColor=vReflectivityColor.rgb;\n#ifdef METALLICWORKFLOW\nvec2 metallicRoughness=surfaceReflectivityColor.rg;\n#ifdef REFLECTIVITY\nvec4 surfaceMetallicColorMap=texture2D(reflectivitySampler,vReflectivityUV+uvOffset);\n#ifdef AOSTOREINMETALMAPRED\nvec3 aoStoreInMetalMap=vec3(surfaceMetallicColorMap.r,surfaceMetallicColorMap.r,surfaceMetallicColorMap.r);\nambientOcclusionColor=mix(ambientOcclusionColor,aoStoreInMetalMap,vReflectivityInfos.z);\n#endif\n#ifdef METALLNESSSTOREINMETALMAPBLUE\nmetallicRoughness.r*=surfaceMetallicColorMap.b;\n#else\nmetallicRoughness.r*=surfaceMetallicColorMap.r;\n#endif\n#ifdef ROUGHNESSSTOREINMETALMAPALPHA\nmetallicRoughness.g*=surfaceMetallicColorMap.a;\n#else\n#ifdef ROUGHNESSSTOREINMETALMAPGREEN\nmetallicRoughness.g*=surfaceMetallicColorMap.g;\n#endif\n#endif\n#endif\n#ifdef MICROSURFACEMAP\nvec4 microSurfaceTexel=texture2D(microSurfaceSampler,vMicroSurfaceSamplerUV+uvOffset)*vMicroSurfaceSamplerInfos.y;\nmetallicRoughness.g*=microSurfaceTexel.r;\n#endif\n\nmicroSurface=1.0-metallicRoughness.g;\n\nvec3 baseColor=surfaceAlbedo;\n\n\nconst vec3 DefaultSpecularReflectanceDielectric=vec3(0.04,0.04,0.04);\n\nsurfaceAlbedo=mix(baseColor.rgb*(1.0-DefaultSpecularReflectanceDielectric.r),vec3(0.,0.,0.),metallicRoughness.r);\n\nsurfaceReflectivityColor=mix(DefaultSpecularReflectanceDielectric,baseColor,metallicRoughness.r);\n#else\n#ifdef REFLECTIVITY\nvec4 surfaceReflectivityColorMap=texture2D(reflectivitySampler,vReflectivityUV+uvOffset);\nsurfaceReflectivityColor*=toLinearSpace(surfaceReflectivityColorMap.rgb);\nsurfaceReflectivityColor*=vReflectivityInfos.y;\n#ifdef MICROSURFACEFROMREFLECTIVITYMAP\nmicroSurface*=surfaceReflectivityColorMap.a;\nmicroSurface*=vReflectivityInfos.z;\n#else\n#ifdef MICROSURFACEAUTOMATIC\nmicroSurface*=computeDefaultMicroSurface(microSurface,surfaceReflectivityColor);\n#endif\n#ifdef MICROSURFACEMAP\nvec4 microSurfaceTexel=texture2D(microSurfaceSampler,vMicroSurfaceSamplerUV+uvOffset)*vMicroSurfaceSamplerInfos.y;\nmicroSurface*=microSurfaceTexel.r;\n#endif\n#endif\n#endif\n#endif\n\nmicroSurface=clamp(microSurface,0.,1.);\n\nfloat roughness=1.-microSurface;\n\n#ifdef ALPHAFRESNEL\n#if defined(ALPHATEST) || defined(ALPHABLEND)\n\n\n\nfloat opacityPerceptual=alpha;\nfloat opacity0=opacityPerceptual*opacityPerceptual;\nfloat opacity90=fresnelGrazingReflectance(opacity0);\nvec3 normalForward=faceforward(normalW,-viewDirectionW,normalW);\n\nalpha=fresnelSchlickEnvironmentGGX(clamp(dot(viewDirectionW,normalForward),0.0,1.0),vec3(opacity0),vec3(opacity90),sqrt(microSurface)).x;\n#ifdef ALPHATEST\nif (alpha<=ALPHATESTVALUE)\ndiscard;\n#ifndef ALPHABLEND\n\nalpha=1.0;\n#endif\n#endif\n#endif\n#endif\n\n\nfloat NdotVUnclamped=dot(normalW,viewDirectionW);\nfloat NdotV=clamp(NdotVUnclamped,0.,1.)+0.00001;\nfloat alphaG=convertRoughnessToAverageSlope(roughness);\n\n#ifdef REFRACTION\nvec3 environmentRefraction=vec3(0.,0.,0.);\nvec3 refractionVector=refract(-viewDirectionW,normalW,vRefractionInfos.y);\n#ifdef REFRACTIONMAP_OPPOSITEZ\nrefractionVector.z*=-1.0;\n#endif\n\n#ifdef REFRACTIONMAP_3D\nrefractionVector.y=refractionVector.y*vRefractionInfos.w;\nvec3 refractionCoords=refractionVector;\nrefractionCoords=vec3(refractionMatrix*vec4(refractionCoords,0));\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#endif\n#ifdef LODINREFRACTIONALPHA\nfloat refractionLOD=getLodFromAlphaG(vRefractionMicrosurfaceInfos.x,alphaG,NdotVUnclamped);\n#else\nfloat refractionLOD=getLodFromAlphaG(vRefractionMicrosurfaceInfos.x,alphaG,1.0);\n#endif\n#ifdef LODBASEDMICROSFURACE\n\nrefractionLOD=refractionLOD*vRefractionMicrosurfaceInfos.y+vRefractionMicrosurfaceInfos.z;\n#ifdef LODINREFRACTIONALPHA\n\n\n\n\n\n\n\n\n\nfloat automaticRefractionLOD=UNPACK_LOD(sampleRefraction(refractionSampler,refractionCoords).a);\nfloat requestedRefractionLOD=max(automaticRefractionLOD,refractionLOD);\n#else\nfloat requestedRefractionLOD=refractionLOD;\n#endif\nenvironmentRefraction=sampleRefractionLod(refractionSampler,refractionCoords,requestedRefractionLOD).rgb;\n#else\nfloat lodRefractionNormalized=clamp(refractionLOD/log2(vRefractionMicrosurfaceInfos.x),0.,1.);\nfloat lodRefractionNormalizedDoubled=lodRefractionNormalized*2.0;\nvec3 environmentRefractionMid=sampleRefraction(refractionSampler,refractionCoords).rgb;\nif(lodRefractionNormalizedDoubled<1.0){\nenvironmentRefraction=mix(\nsampleRefraction(refractionSamplerHigh,refractionCoords).rgb,\nenvironmentRefractionMid,\nlodRefractionNormalizedDoubled\n);\n}else{\nenvironmentRefraction=mix(\nenvironmentRefractionMid,\nsampleRefraction(refractionSamplerLow,refractionCoords).rgb,\nlodRefractionNormalizedDoubled-1.0\n);\n}\n#endif\n#ifdef GAMMAREFRACTION\nenvironmentRefraction=toLinearSpace(environmentRefraction.rgb);\n#endif\n\nenvironmentRefraction*=vRefractionInfos.x;\n#endif\n\n#ifdef REFLECTION\nvec3 environmentRadiance=vec3(0.,0.,0.);\nvec3 environmentIrradiance=vec3(0.,0.,0.);\nvec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),normalW);\n#ifdef REFLECTIONMAP_OPPOSITEZ\nreflectionVector.z*=-1.0;\n#endif\n\n#ifdef REFLECTIONMAP_3D\nvec3 reflectionCoords=reflectionVector;\n#else\nvec2 reflectionCoords=reflectionVector.xy;\n#ifdef REFLECTIONMAP_PROJECTION\nreflectionCoords/=reflectionVector.z;\n#endif\nreflectionCoords.y=1.0-reflectionCoords.y;\n#endif\n#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)\nfloat reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG,NdotVUnclamped);\n#else\nfloat reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG,1.);\n#endif\n#ifdef LODBASEDMICROSFURACE\n\nreflectionLOD=reflectionLOD*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z;\n#ifdef LODINREFLECTIONALPHA\n\n\n\n\n\n\n\n\n\nfloat automaticReflectionLOD=UNPACK_LOD(sampleReflection(reflectionSampler,reflectionCoords).a);\nfloat requestedReflectionLOD=max(automaticReflectionLOD,reflectionLOD);\n#else\nfloat requestedReflectionLOD=reflectionLOD;\n#endif\nenvironmentRadiance=sampleReflectionLod(reflectionSampler,reflectionCoords,requestedReflectionLOD).rgb;\n#else\nfloat lodReflectionNormalized=clamp(reflectionLOD/log2(vReflectionMicrosurfaceInfos.x),0.,1.);\nfloat lodReflectionNormalizedDoubled=lodReflectionNormalized*2.0;\nvec3 environmentSpecularMid=sampleReflection(reflectionSampler,reflectionCoords).rgb;\nif(lodReflectionNormalizedDoubled<1.0){\nenvironmentRadiance=mix(\nsampleReflection(reflectionSamplerHigh,reflectionCoords).rgb,\nenvironmentSpecularMid,\nlodReflectionNormalizedDoubled\n);\n}else{\nenvironmentRadiance=mix(\nenvironmentSpecularMid,\nsampleReflection(reflectionSamplerLow,reflectionCoords).rgb,\nlodReflectionNormalizedDoubled-1.0\n);\n}\n#endif\n#ifdef GAMMAREFLECTION\nenvironmentRadiance=toLinearSpace(environmentRadiance.rgb);\n#endif\n\n#ifdef USESPHERICALFROMREFLECTIONMAP\n#if defined(NORMAL) && !defined(USESPHERICALINFRAGMENT)\nenvironmentIrradiance=vEnvironmentIrradiance;\n#else\nvec3 irradianceVector=vec3(reflectionMatrix*vec4(normalW,0)).xyz;\n#ifdef REFLECTIONMAP_OPPOSITEZ\nirradianceVector.z*=-1.0;\n#endif\nenvironmentIrradiance=environmentIrradianceJones(irradianceVector);\n#endif\n#endif\n\nenvironmentRadiance*=vReflectionInfos.x;\nenvironmentRadiance*=vReflectionColor.rgb;\nenvironmentIrradiance*=vReflectionColor.rgb;\n#endif\n\n\n\nfloat reflectance=max(max(surfaceReflectivityColor.r,surfaceReflectivityColor.g),surfaceReflectivityColor.b);\nfloat reflectance90=fresnelGrazingReflectance(reflectance);\nvec3 specularEnvironmentR0=surfaceReflectivityColor.rgb;\nvec3 specularEnvironmentR90=vec3(1.0,1.0,1.0)*reflectance90;\n\nvec3 diffuseBase=vec3(0.,0.,0.);\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif\n#ifdef LIGHTMAP\nvec3 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset).rgb*vLightmapInfos.y;\n#endif\nlightingInfo info;\nfloat shadow=1.; \nfloat NdotL=-1.;\n#include<lightFragment>[0..maxSimultaneousLights]\n\n#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)\n\nvec2 brdfSamplerUV=vec2(NdotV,roughness);\n\nvec4 environmentBrdf=texture2D(environmentBrdfSampler,brdfSamplerUV);\nvec3 specularEnvironmentReflectance=specularEnvironmentR0*environmentBrdf.x+environmentBrdf.y;\n#ifdef AMBIENTINGRAYSCALE\nfloat ambientMonochrome=ambientOcclusionColor.r;\n#else\nfloat ambientMonochrome=getLuminance(ambientOcclusionColor);\n#endif\nfloat seo=environmentRadianceOcclusion(ambientMonochrome,NdotVUnclamped);\nspecularEnvironmentReflectance*=seo;\n#ifdef BUMP\n#ifdef REFLECTIONMAP_3D\nfloat eho=environmentHorizonOcclusion(reflectionCoords,normalW);\nspecularEnvironmentReflectance*=eho;\n#endif\n#endif\n#else\n\nvec3 specularEnvironmentReflectance=fresnelSchlickEnvironmentGGX(NdotV,specularEnvironmentR0,specularEnvironmentR90,sqrt(microSurface));\n#endif\n\n#ifdef REFRACTION\nvec3 refractance=vec3(0.0,0.0,0.0);\nvec3 transmission=vec3(1.0,1.0,1.0);\n#ifdef LINKREFRACTIONTOTRANSPARENCY\n\ntransmission*=(1.0-alpha);\n\n\nvec3 mixedAlbedo=surfaceAlbedo;\nfloat maxChannel=max(max(mixedAlbedo.r,mixedAlbedo.g),mixedAlbedo.b);\nvec3 tint=clamp(maxChannel*mixedAlbedo,0.0,1.0);\n\nsurfaceAlbedo*=alpha;\n\nenvironmentIrradiance*=alpha;\n\nenvironmentRefraction*=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=transmission;\n#endif\n\n\n\n\nsurfaceAlbedo.rgb=(1.-reflectance)*surfaceAlbedo.rgb;\n\nvec3 finalDiffuse=diffuseBase;\nfinalDiffuse.rgb+=vAmbientColor;\nfinalDiffuse*=surfaceAlbedo.rgb;\nfinalDiffuse=max(finalDiffuse,0.0);\n\n#ifdef REFLECTION\nvec3 finalIrradiance=environmentIrradiance;\nfinalIrradiance*=surfaceAlbedo.rgb;\n#endif\n\n#ifdef SPECULARTERM\nvec3 finalSpecular=specularBase;\nfinalSpecular=max(finalSpecular,0.0);\n\nvec3 finalSpecularScaled=finalSpecular*vLightingIntensity.x*vLightingIntensity.w;\n#endif\n\n#ifdef REFLECTION\nvec3 finalRadiance=environmentRadiance;\nfinalRadiance*=specularEnvironmentReflectance;\n\nvec3 finalRadianceScaled=finalRadiance*vLightingIntensity.z;\n#endif\n\n#ifdef REFRACTION\nvec3 finalRefraction=environmentRefraction;\nfinalRefraction*=refractance;\n#endif\n\nvec3 finalEmissive=vEmissiveColor;\n#ifdef EMISSIVE\nvec3 emissiveColorTex=texture2D(emissiveSampler,vEmissiveUV+uvOffset).rgb;\nfinalEmissive*=toLinearSpace(emissiveColorTex.rgb);\nfinalEmissive*=vEmissiveInfos.y;\n#endif\n\n#ifdef ALPHABLEND\nfloat luminanceOverAlpha=0.0;\n#if defined(REFLECTION) && defined(RADIANCEOVERALPHA)\nluminanceOverAlpha+=getLuminance(finalRadianceScaled);\n#endif\n#if defined(SPECULARTERM) && defined(SPECULAROVERALPHA)\nluminanceOverAlpha+=getLuminance(finalSpecularScaled);\n#endif\n#if defined(RADIANCEOVERALPHA) || defined(SPECULAROVERALPHA)\nalpha=clamp(alpha+luminanceOverAlpha*luminanceOverAlpha,0.,1.);\n#endif\n#endif\n\n\n\nvec4 finalColor=vec4(finalDiffuse*ambientOcclusionColor*vLightingIntensity.x +\n#ifdef REFLECTION\nfinalIrradiance*ambientOcclusionColor*vLightingIntensity.z +\n#endif\n#ifdef SPECULARTERM\n\n\nfinalSpecularScaled +\n#endif\n#ifdef REFLECTION\n\n\nfinalRadianceScaled +\n#endif\n#ifdef REFRACTION\nfinalRefraction*vLightingIntensity.z +\n#endif\nfinalEmissive*vLightingIntensity.y,\nalpha);\n\n#ifdef LIGHTMAP\n#ifndef LIGHTMAPEXCLUDED\n#ifdef USELIGHTMAPASSHADOWMAP\nfinalColor.rgb*=lightmapColor;\n#else\nfinalColor.rgb+=lightmapColor;\n#endif\n#endif\n#endif\n\nfinalColor=max(finalColor,0.0);\n#include<logDepthFragment>\n#include<fogFragment>(color,finalColor)\n#ifdef IMAGEPROCESSINGPOSTPROCESS\n\n\nfinalColor.rgb=clamp(finalColor.rgb,0.,30.0);\n#else\n\nfinalColor=applyImageProcessing(finalColor);\n#endif\n#ifdef PREMULTIPLYALPHA\n\nfinalColor.rgb*=finalColor.a;\n#endif\ngl_FragColor=finalColor;\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n}",layerVertexShader:"\nattribute vec2 position;\n\nuniform vec2 scale;\nuniform vec2 offset;\nuniform mat4 textureMatrix;\n\nvarying vec2 vUV;\nconst vec2 madd=vec2(0.5,0.5);\nvoid main(void) { \nvec2 shiftedPosition=position*scale+offset;\nvUV=vec2(textureMatrix*vec4(shiftedPosition*madd+madd,1.0,0.0));\ngl_Position=vec4(shiftedPosition,0.0,1.0);\n}",layerPixelShader:"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n\nuniform vec4 color;\nvoid main(void) {\nvec4 baseColor=texture2D(textureSampler,vUV);\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\ngl_FragColor=baseColor*color;\n}",kernelBlurVertexShader:"\nattribute vec2 position;\n\nuniform vec2 delta;\n\nvarying vec2 sampleCenter;\n#include<kernelBlurVaryingDeclaration>[0..varyingCount]\nconst vec2 madd=vec2(0.5,0.5);\nvoid main(void) { \nsampleCenter=(position*madd+madd);\n#include<kernelBlurVertex>[0..varyingCount]\ngl_Position=vec4(position,0.0,1.0);\n}",kernelBlurPixelShader:"\nuniform sampler2D textureSampler;\nuniform vec2 delta;\n\nvarying vec2 sampleCenter;\n#include<kernelBlurVaryingDeclaration>[0..varyingCount]\n#ifdef PACKEDFLOAT\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}\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\nvoid main(void)\n{\n#ifdef PACKEDFLOAT \nfloat blend=0.;\n#else\nvec4 blend=vec4(0.);\n#endif\n#include<kernelBlurFragment>[0..varyingCount]\n#include<kernelBlurFragment2>[0..depCount]\n#ifdef PACKEDFLOAT\ngl_FragColor=pack(blend);\n#else\ngl_FragColor=blend;\n#endif\n}",fxaaVertexShader:"\nattribute vec2 position;\nuniform vec2 texelSize;\n\nvarying vec2 vUV;\nvarying vec2 sampleCoordS;\nvarying vec2 sampleCoordE;\nvarying vec2 sampleCoordN;\nvarying vec2 sampleCoordW;\nvarying vec2 sampleCoordNW;\nvarying vec2 sampleCoordSE;\nvarying vec2 sampleCoordNE;\nvarying vec2 sampleCoordSW;\nconst vec2 madd=vec2(0.5,0.5);\nvoid main(void) { \nvUV=(position*madd+madd);\nsampleCoordS=vUV+vec2( 0.0,1.0)*texelSize;\nsampleCoordE=vUV+vec2( 1.0,0.0)*texelSize;\nsampleCoordN=vUV+vec2( 0.0,-1.0)*texelSize;\nsampleCoordW=vUV+vec2(-1.0,0.0)*texelSize;\nsampleCoordNW=vUV+vec2(-1.0,-1.0)*texelSize;\nsampleCoordSE=vUV+vec2( 1.0,1.0)*texelSize;\nsampleCoordNE=vUV+vec2( 1.0,-1.0)*texelSize;\nsampleCoordSW=vUV+vec2(-1.0,1.0)*texelSize;\ngl_Position=vec4(position,0.0,1.0);\n}",fxaaPixelShader:"uniform sampler2D textureSampler;\nuniform vec2 texelSize;\nvarying vec2 vUV;\nvarying vec2 sampleCoordS;\nvarying vec2 sampleCoordE;\nvarying vec2 sampleCoordN;\nvarying vec2 sampleCoordW;\nvarying vec2 sampleCoordNW;\nvarying vec2 sampleCoordSE;\nvarying vec2 sampleCoordNE;\nvarying vec2 sampleCoordSW;\nconst float fxaaQualitySubpix=1.0;\nconst float fxaaQualityEdgeThreshold=0.166;\nconst float fxaaQualityEdgeThresholdMin=0.0833;\nconst vec3 kLumaCoefficients=vec3(0.2126,0.7152,0.0722);\n#define FxaaLuma(rgba) dot(rgba.rgb,kLumaCoefficients)\nvoid main(){\nvec2 posM;\nposM.x=vUV.x;\nposM.y=vUV.y;\nvec4 rgbyM=texture2D(textureSampler,vUV,0.0);\nfloat lumaM=FxaaLuma(rgbyM);\nfloat lumaS=FxaaLuma(texture2D(textureSampler,sampleCoordS,0.0));\nfloat lumaE=FxaaLuma(texture2D(textureSampler,sampleCoordE,0.0));\nfloat lumaN=FxaaLuma(texture2D(textureSampler,sampleCoordN,0.0));\nfloat lumaW=FxaaLuma(texture2D(textureSampler,sampleCoordW,0.0));\nfloat maxSM=max(lumaS,lumaM);\nfloat minSM=min(lumaS,lumaM);\nfloat maxESM=max(lumaE,maxSM);\nfloat minESM=min(lumaE,minSM);\nfloat maxWN=max(lumaN,lumaW);\nfloat minWN=min(lumaN,lumaW);\nfloat rangeMax=max(maxWN,maxESM);\nfloat rangeMin=min(minWN,minESM);\nfloat rangeMaxScaled=rangeMax*fxaaQualityEdgeThreshold;\nfloat range=rangeMax-rangeMin;\nfloat rangeMaxClamped=max(fxaaQualityEdgeThresholdMin,rangeMaxScaled);\nif(range<rangeMaxClamped) \n{\ngl_FragColor=rgbyM;\nreturn;\n}\nfloat lumaNW=FxaaLuma(texture2D(textureSampler,sampleCoordNW,0.0));\nfloat lumaSE=FxaaLuma(texture2D(textureSampler,sampleCoordSE,0.0));\nfloat lumaNE=FxaaLuma(texture2D(textureSampler,sampleCoordNE,0.0));\nfloat lumaSW=FxaaLuma(texture2D(textureSampler,sampleCoordSW,0.0));\nfloat lumaNS=lumaN+lumaS;\nfloat lumaWE=lumaW+lumaE;\nfloat subpixRcpRange=1.0/range;\nfloat subpixNSWE=lumaNS+lumaWE;\nfloat edgeHorz1=(-2.0*lumaM)+lumaNS;\nfloat edgeVert1=(-2.0*lumaM)+lumaWE;\nfloat lumaNESE=lumaNE+lumaSE;\nfloat lumaNWNE=lumaNW+lumaNE;\nfloat edgeHorz2=(-2.0*lumaE)+lumaNESE;\nfloat edgeVert2=(-2.0*lumaN)+lumaNWNE;\nfloat lumaNWSW=lumaNW+lumaSW;\nfloat lumaSWSE=lumaSW+lumaSE;\nfloat edgeHorz4=(abs(edgeHorz1)*2.0)+abs(edgeHorz2);\nfloat edgeVert4=(abs(edgeVert1)*2.0)+abs(edgeVert2);\nfloat edgeHorz3=(-2.0*lumaW)+lumaNWSW;\nfloat edgeVert3=(-2.0*lumaS)+lumaSWSE;\nfloat edgeHorz=abs(edgeHorz3)+edgeHorz4;\nfloat edgeVert=abs(edgeVert3)+edgeVert4;\nfloat subpixNWSWNESE=lumaNWSW+lumaNESE;\nfloat lengthSign=texelSize.x;\nbool horzSpan=edgeHorz>=edgeVert;\nfloat subpixA=subpixNSWE*2.0+subpixNWSWNESE;\nif (!horzSpan)\n{\nlumaN=lumaW;\n}\nif (!horzSpan) \n{\nlumaS=lumaE;\n}\nif (horzSpan) \n{\nlengthSign=texelSize.y;\n}\nfloat subpixB=(subpixA*(1.0/12.0))-lumaM;\nfloat gradientN=lumaN-lumaM;\nfloat gradientS=lumaS-lumaM;\nfloat lumaNN=lumaN+lumaM;\nfloat lumaSS=lumaS+lumaM;\nbool pairN=abs(gradientN)>=abs(gradientS);\nfloat gradient=max(abs(gradientN),abs(gradientS));\nif (pairN)\n{\nlengthSign=-lengthSign;\n}\nfloat subpixC=clamp(abs(subpixB)*subpixRcpRange,0.0,1.0);\nvec2 posB;\nposB.x=posM.x;\nposB.y=posM.y;\nvec2 offNP;\noffNP.x=(!horzSpan) ? 0.0 : texelSize.x;\noffNP.y=(horzSpan) ? 0.0 : texelSize.y;\nif (!horzSpan) \n{\nposB.x+=lengthSign*0.5;\n}\nif (horzSpan)\n{\nposB.y+=lengthSign*0.5;\n}\nvec2 posN;\nposN.x=posB.x-offNP.x*1.5;\nposN.y=posB.y-offNP.y*1.5;\nvec2 posP;\nposP.x=posB.x+offNP.x*1.5;\nposP.y=posB.y+offNP.y*1.5;\nfloat subpixD=((-2.0)*subpixC)+3.0;\nfloat lumaEndN=FxaaLuma(texture2D(textureSampler,posN,0.0));\nfloat subpixE=subpixC*subpixC;\nfloat lumaEndP=FxaaLuma(texture2D(textureSampler,posP,0.0));\nif (!pairN) \n{\nlumaNN=lumaSS;\n}\nfloat gradientScaled=gradient*1.0/4.0;\nfloat lumaMM=lumaM-lumaNN*0.5;\nfloat subpixF=subpixD*subpixE;\nbool lumaMLTZero=lumaMM<0.0;\nlumaEndN-=lumaNN*0.5;\nlumaEndP-=lumaNN*0.5;\nbool doneN=abs(lumaEndN)>=gradientScaled;\nbool doneP=abs(lumaEndP)>=gradientScaled;\nif (!doneN) \n{\nposN.x-=offNP.x*3.0;\n}\nif (!doneN) \n{\nposN.y-=offNP.y*3.0;\n}\nbool doneNP=(!doneN) || (!doneP);\nif (!doneP) \n{\nposP.x+=offNP.x*3.0;\n}\nif (!doneP)\n{\nposP.y+=offNP.y*3.0;\n}\nif (doneNP)\n{\nif (!doneN) lumaEndN=FxaaLuma(texture2D(textureSampler,posN.xy,0.0));\nif (!doneP) lumaEndP=FxaaLuma(texture2D(textureSampler,posP.xy,0.0));\nif (!doneN) lumaEndN=lumaEndN-lumaNN*0.5;\nif (!doneP) lumaEndP=lumaEndP-lumaNN*0.5;\ndoneN=abs(lumaEndN)>=gradientScaled;\ndoneP=abs(lumaEndP)>=gradientScaled;\nif (!doneN) posN.x-=offNP.x*12.0;\nif (!doneN) posN.y-=offNP.y*12.0;\ndoneNP=(!doneN) || (!doneP);\nif (!doneP) posP.x+=offNP.x*12.0;\nif (!doneP) posP.y+=offNP.y*12.0;\n}\nfloat dstN=posM.x-posN.x;\nfloat dstP=posP.x-posM.x;\nif (!horzSpan)\n{\ndstN=posM.y-posN.y;\n}\nif (!horzSpan) \n{\ndstP=posP.y-posM.y;\n}\nbool goodSpanN=(lumaEndN<0.0) != lumaMLTZero;\nfloat spanLength=(dstP+dstN);\nbool goodSpanP=(lumaEndP<0.0) != lumaMLTZero;\nfloat spanLengthRcp=1.0/spanLength;\nbool directionN=dstN<dstP;\nfloat dst=min(dstN,dstP);\nbool goodSpan=directionN ? goodSpanN : goodSpanP;\nfloat subpixG=subpixF*subpixF;\nfloat pixelOffset=(dst*(-spanLengthRcp))+0.5;\nfloat subpixH=subpixG*fxaaQualitySubpix;\nfloat pixelOffsetGood=goodSpan ? pixelOffset : 0.0;\nfloat pixelOffsetSubpix=max(pixelOffsetGood,subpixH);\nif (!horzSpan)\n{\nposM.x+=pixelOffsetSubpix*lengthSign;\n}\nif (horzSpan)\n{\nposM.y+=pixelOffsetSubpix*lengthSign;\n}\ngl_FragColor=texture2D(textureSampler,posM,0.0);\n}",
- highlightsPixelShader:"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nconst vec3 RGBLuminanceCoefficients=vec3(0.2126,0.7152,0.0722);\nvoid main(void) \n{\nvec4 tex=texture2D(textureSampler,vUV);\nvec3 c=tex.rgb;\nfloat luma=dot(c.rgb,RGBLuminanceCoefficients);\n\n\ngl_FragColor=vec4(pow(c,vec3(25.0-luma*15.0)),tex.a); \n}",imageProcessingPixelShader:"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n#include<imageProcessingDeclaration>\n#include<helperFunctions>\n#include<imageProcessingFunctions>\nvoid main(void)\n{\nvec4 result=texture2D(textureSampler,vUV);\n#ifdef IMAGEPROCESSING\n#ifndef FROMLINEARSPACE\n\nresult.rgb=toLinearSpace(result.rgb);\n#endif\nresult=applyImageProcessing(result);\n#else\n\n#ifdef FROMLINEARSPACE\nresult=applyImageProcessing(result);\n#endif\n#endif\ngl_FragColor=result;\n}",colorVertexShader:"\nattribute vec3 position;\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<bonesDeclaration>\n\nuniform mat4 viewProjection;\nuniform mat4 world;\n\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\nvoid main(void) {\nmat4 finalWorld=world;\n#include<bonesVertex>\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\n#ifdef VERTEXCOLOR\n\nvColor=color;\n#endif\n}",colorPixelShader:"#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#else\nuniform vec4 color;\n#endif\nvoid main(void) {\n#ifdef VERTEXCOLOR\ngl_FragColor=vColor;\n#else\ngl_FragColor=color;\n#endif\n}",defaultVertexShader:"#include<__decl__defaultVertex>\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#ifdef TANGENT\nattribute vec4 tangent;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2;\n#endif\n#if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0\nvarying vec2 vDiffuseUV;\n#endif\n#if defined(AMBIENT) && AMBIENTDIRECTUV == 0\nvarying vec2 vAmbientUV;\n#endif\n#if defined(OPACITY) && OPACITYDIRECTUV == 0\nvarying vec2 vOpacityUV;\n#endif\n#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0\nvarying vec2 vEmissiveUV;\n#endif\n#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0\nvarying vec2 vLightmapUV;\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM) && SPECULARDIRECTUV == 0\nvarying vec2 vSpecularUV;\n#endif\n#if defined(BUMP) && BUMPDIRECTUV == 0\nvarying vec2 vBumpUV;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<bumpVertexDeclaration>\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<morphTargetsVertexGlobalDeclaration>\n#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#include<logDepthDeclaration>\nvoid main(void) {\nvec3 positionUpdated=position;\n#ifdef NORMAL \nvec3 normalUpdated=normal;\n#endif\n#ifdef TANGENT\nvec4 tangentUpdated=tangent;\n#endif\n#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\nvPositionUVW=positionUpdated;\n#endif \n#include<instancesVertex>\n#include<bonesVertex>\ngl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);\nvec4 worldPos=finalWorld*vec4(positionUpdated,1.0);\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nvNormalW=normalize(vec3(finalWorld*vec4(normalUpdated,0.0)));\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvDirectionW=normalize(vec3(finalWorld*vec4(positionUpdated,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 MAINUV1\nvMainUV1=uv;\n#endif\n#ifdef MAINUV2\nvMainUV2=uv2;\n#endif\n#if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0\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#if defined(AMBIENT) && AMBIENTDIRECTUV == 0\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#if defined(OPACITY) && OPACITYDIRECTUV == 0\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#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0\nif (vEmissiveInfos.x == 0.)\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0\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) && SPECULARDIRECTUV == 0\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#if defined(BUMP) && BUMPDIRECTUV == 0\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<bumpVertex>\n#include<clipPlaneVertex>\n#include<fogVertex>\n#include<shadowsVertex>[0..maxSimultaneousLights]\n#ifdef VERTEXCOLOR\n\nvColor=color;\n#endif\n#include<pointCloudVertex>\n#include<logDepthVertex>\n}",defaultPixelShader:"#include<__decl__defaultFragment>\n#if defined(BUMP) || !defined(NORMAL)\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;\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2;\n#endif\n\n#include<helperFunctions>\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n\n#ifdef DIFFUSE\n#if DIFFUSEDIRECTUV == 1\n#define vDiffuseUV vMainUV1\n#elif DIFFUSEDIRECTUV == 2\n#define vDiffuseUV vMainUV2\n#else\nvarying vec2 vDiffuseUV;\n#endif\nuniform sampler2D diffuseSampler;\n#endif\n#ifdef AMBIENT\n#if AMBIENTDIRECTUV == 1\n#define vAmbientUV vMainUV1\n#elif AMBIENTDIRECTUV == 2\n#define vAmbientUV vMainUV2\n#else\nvarying vec2 vAmbientUV;\n#endif\nuniform sampler2D ambientSampler;\n#endif\n#ifdef OPACITY \n#if OPACITYDIRECTUV == 1\n#define vOpacityUV vMainUV1\n#elif OPACITYDIRECTUV == 2\n#define vOpacityUV vMainUV2\n#else\nvarying vec2 vOpacityUV;\n#endif\nuniform sampler2D opacitySampler;\n#endif\n#ifdef EMISSIVE\n#if EMISSIVEDIRECTUV == 1\n#define vEmissiveUV vMainUV1\n#elif EMISSIVEDIRECTUV == 2\n#define vEmissiveUV vMainUV2\n#else\nvarying vec2 vEmissiveUV;\n#endif\nuniform sampler2D emissiveSampler;\n#endif\n#ifdef LIGHTMAP\n#if LIGHTMAPDIRECTUV == 1\n#define vLightmapUV vMainUV1\n#elif LIGHTMAPDIRECTUV == 2\n#define vLightmapUV vMainUV2\n#else\nvarying vec2 vLightmapUV;\n#endif\nuniform sampler2D lightmapSampler;\n#endif\n#ifdef REFRACTION\n#ifdef REFRACTIONMAP_3D\nuniform samplerCube refractionCubeSampler;\n#else\nuniform sampler2D refraction2DSampler;\n#endif\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM)\n#if SPECULARDIRECTUV == 1\n#define vSpecularUV vMainUV1\n#elif SPECULARDIRECTUV == 2\n#define vSpecularUV vMainUV2\n#else\nvarying vec2 vSpecularUV;\n#endif\nuniform sampler2D specularSampler;\n#endif\n\n#include<fresnelFunction>\n\n#ifdef REFLECTION\n#ifdef REFLECTIONMAP_3D\nuniform samplerCube reflectionCubeSampler;\n#else\nuniform sampler2D reflection2DSampler;\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#else\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#endif\n#include<reflectionFunction>\n#endif\n#include<imageProcessingDeclaration>\n#include<imageProcessingFunctions>\n#include<bumpFragmentFunctions>\n#include<clipPlaneFragmentDeclaration>\n#include<logDepthDeclaration>\n#include<fogFragmentDeclaration>\nvoid main(void) {\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\nvec4 baseColor=vec4(1.,1.,1.,1.);\nvec3 diffuseColor=vDiffuseColor.rgb;\n\nfloat alpha=vDiffuseColor.a;\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=normalize(-cross(dFdx(vPositionW),dFdy(vPositionW)));\n#endif\n#include<bumpFragment>\n#ifdef TWOSIDEDLIGHTING\nnormalW=gl_FrontFacing ? normalW : -normalW;\n#endif\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<lightFragment>[0..maxSimultaneousLights]\n\nvec3 refractionColor=vec3(0.,0.,0.);\n#ifdef REFRACTION\nvec3 refractionVector=normalize(refract(-viewDirectionW,normalW,vRefractionInfos.y));\n#ifdef REFRACTIONMAP_3D\nrefractionVector.y=refractionVector.y*vRefractionInfos.w;\nif (dot(refractionVector,viewDirectionW)<1.0)\n{\nrefractionColor=textureCube(refractionCubeSampler,refractionVector).rgb*vRefractionInfos.x;\n}\n#else\nvec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*vRefractionInfos.z,1.0)));\nvec2 refractionCoords=vRefractionUVW.xy/vRefractionUVW.z;\nrefractionCoords.y=1.0-refractionCoords.y;\nrefractionColor=texture2D(refraction2DSampler,refractionCoords).rgb*vRefractionInfos.x;\n#endif\n#endif\n\nvec3 reflectionColor=vec3(0.,0.,0.);\n#ifdef REFLECTION\nvec3 vReflectionUVW=computeReflectionCoords(vec4(vPositionW,1.0),normalW);\n#ifdef REFLECTIONMAP_3D\n#ifdef ROUGHNESS\nfloat bias=vReflectionInfos.y;\n#ifdef SPECULARTERM\n#ifdef SPECULAR\n#ifdef GLOSSINESS\nbias*=(1.0-specularMapColor.a);\n#endif\n#endif\n#endif\nreflectionColor=textureCube(reflectionCubeSampler,vReflectionUVW,bias).rgb*vReflectionInfos.x;\n#else\nreflectionColor=textureCube(reflectionCubeSampler,vReflectionUVW).rgb*vReflectionInfos.x;\n#endif\n#else\nvec2 coords=vReflectionUVW.xy;\n#ifdef REFLECTIONMAP_PROJECTION\ncoords/=vReflectionUVW.z;\n#endif\ncoords.y=1.0-coords.y;\nreflectionColor=texture2D(reflection2DSampler,coords).rgb*vReflectionInfos.x;\n#endif\n#ifdef REFLECTIONFRESNEL\nfloat reflectionFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,reflectionRightColor.a,reflectionLeftColor.a);\n#ifdef REFLECTIONFRESNELFROMSPECULAR\n#ifdef SPECULARTERM\nreflectionColor*=specularColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;\n#else\nreflectionColor*=reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;\n#endif\n#else\nreflectionColor*=reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;\n#endif\n#endif\n#endif\n#ifdef REFRACTIONFRESNEL\nfloat refractionFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,refractionRightColor.a,refractionLeftColor.a);\nrefractionColor*=refractionLeftColor.rgb*(1.0-refractionFresnelTerm)+refractionFresnelTerm*refractionRightColor.rgb;\n#endif\n#ifdef OPACITY\nvec4 opacityMap=texture2D(opacitySampler,vOpacityUV+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#ifdef SPECULAROVERALPHA\nalpha=clamp(alpha+dot(finalSpecular,vec3(0.3,0.59,0.11)),0.,1.);\n#endif\n#else\nvec3 finalSpecular=vec3(0.0);\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<logDepthFragment>\n#include<fogFragment>\n\n\n#ifdef IMAGEPROCESSINGPOSTPROCESS\ncolor.rgb=toLinearSpace(color.rgb);\n#else\n#ifdef IMAGEPROCESSING\ncolor.rgb=toLinearSpace(color.rgb);\ncolor=applyImageProcessing(color);\n#endif\n#endif\ngl_FragColor=color;\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",instancesDeclaration:"#ifdef INSTANCES\nattribute vec4 world0;\nattribute vec4 world1;\nattribute vec4 world2;\nattribute vec4 world3;\n#else\nuniform mat4 world;\n#endif",bumpVertexDeclaration:"#if defined(BUMP) || defined(PARALLAX)\n#if defined(TANGENT) && defined(NORMAL) \nvarying mat3 vTBN;\n#endif\n#endif\n",clipPlaneVertexDeclaration:"#ifdef CLIPPLANE\nuniform vec4 vClipPlane;\nvarying float fClipDistance;\n#endif",fogVertexDeclaration:"#ifdef FOG\nvarying vec3 vFogDistance;\n#endif",morphTargetsVertexGlobalDeclaration:"#ifdef MORPHTARGETS\nuniform float morphTargetInfluences[NUM_MORPH_INFLUENCERS];\n#endif",morphTargetsVertexDeclaration:"#ifdef MORPHTARGETS\nattribute vec3 position{X};\n#ifdef MORPHTARGETS_NORMAL\nattribute vec3 normal{X};\n#endif\n#ifdef MORPHTARGETS_TANGENT\nattribute vec3 tangent{X};\n#endif\n#endif",logDepthDeclaration:"#ifdef LOGARITHMICDEPTH\nuniform float logarithmicDepthConstant;\nvarying float vFragmentDepth;\n#endif",morphTargetsVertex:"#ifdef MORPHTARGETS\npositionUpdated+=(position{X}-position)*morphTargetInfluences[{X}];\n#ifdef MORPHTARGETS_NORMAL\nnormalUpdated+=(normal{X}-normal)*morphTargetInfluences[{X}];\n#endif\n#ifdef MORPHTARGETS_TANGENT\ntangentUpdated.xyz+=(tangent{X}-tangent.xyz)*morphTargetInfluences[{X}];\n#endif\n#endif",instancesVertex:"#ifdef INSTANCES\nmat4 finalWorld=mat4(world0,world1,world2,world3);\n#else\nmat4 finalWorld=world;\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",bumpVertex:"#if defined(BUMP) || defined(PARALLAX)\n#if defined(TANGENT) && defined(NORMAL)\nvec3 normalW=normalize(vec3(finalWorld*vec4(normalUpdated,0.0)));\nvec3 tangentW=normalize(vec3(finalWorld*vec4(tangentUpdated.xyz,0.0)));\nvec3 bitangentW=cross(normalW,tangentW)*tangentUpdated.w;\nvTBN=mat3(tangentW,bitangentW,normalW);\n#endif\n#endif",clipPlaneVertex:"#ifdef CLIPPLANE\nfClipDistance=dot(worldPos,vClipPlane);\n#endif",fogVertex:"#ifdef FOG\nvFogDistance=(view*worldPos).xyz;\n#endif",shadowsVertex:"#ifdef SHADOWS\n#if defined(SHADOW{X}) && !defined(SHADOWCUBE{X})\nvPositionFromLight{X}=lightMatrix{X}*worldPos;\nvDepthMetric{X}=((vPositionFromLight{X}.z+light{X}.depthValues.x)/(light{X}.depthValues.y));\n#endif\n#endif",logDepthVertex:"#ifdef LOGARITHMICDEPTH\nvFragmentDepth=1.0+gl_Position.w;\ngl_Position.z=log2(max(0.000001,vFragmentDepth))*logarithmicDepthConstant;\n#endif",lightFragmentDeclaration:"#ifdef LIGHT{X}\nuniform vec4 vLightData{X};\nuniform vec4 vLightDiffuse{X};\n#ifdef SPECULARTERM\nuniform vec3 vLightSpecular{X};\n#else\nvec3 vLightSpecular{X}=vec3(0.);\n#endif\n#ifdef SHADOW{X}\n#if defined(SHADOWCUBE{X})\nuniform samplerCube shadowSampler{X};\n#else\nvarying vec4 vPositionFromLight{X};\nvarying float vDepthMetric{X};\nuniform sampler2D shadowSampler{X};\nuniform mat4 lightMatrix{X};\n#endif\nuniform vec4 shadowsInfo{X};\nuniform vec2 depthValues{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",lightUboDeclaration:"#ifdef LIGHT{X}\nuniform Light{X}\n{\nvec4 vLightData;\nvec4 vLightDiffuse;\nvec3 vLightSpecular;\n#ifdef SPOTLIGHT{X}\nvec4 vLightDirection;\n#endif\n#ifdef HEMILIGHT{X}\nvec3 vLightGround;\n#endif\nvec4 shadowsInfo;\nvec2 depthValues;\n} light{X};\n#ifdef SHADOW{X}\n#if defined(SHADOWCUBE{X})\nuniform samplerCube shadowSampler{X};\n#else\nvarying vec4 vPositionFromLight{X};\nvarying float vDepthMetric{X};\nuniform sampler2D shadowSampler{X};\nuniform mat4 lightMatrix{X};\n#endif\n#endif\n#endif",pbrVertexDeclaration:"uniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef ALBEDO\nuniform mat4 albedoMatrix;\nuniform vec2 vAlbedoInfos;\n#endif\n#ifdef AMBIENT\nuniform mat4 ambientMatrix;\nuniform vec3 vAmbientInfos;\n#endif\n#ifdef OPACITY\nuniform mat4 opacityMatrix;\nuniform vec2 vOpacityInfos;\n#endif\n#ifdef EMISSIVE\nuniform vec2 vEmissiveInfos;\nuniform mat4 emissiveMatrix;\n#endif\n#ifdef LIGHTMAP\nuniform vec2 vLightmapInfos;\nuniform mat4 lightmapMatrix;\n#endif\n#ifdef REFLECTIVITY \nuniform vec3 vReflectivityInfos;\nuniform mat4 reflectivityMatrix;\n#endif\n#ifdef MICROSURFACEMAP\nuniform vec2 vMicroSurfaceSamplerInfos;\nuniform mat4 microSurfaceSamplerMatrix;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;\nuniform mat4 bumpMatrix;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n\n#ifdef REFRACTION\nuniform vec4 vRefractionInfos;\nuniform mat4 refractionMatrix;\nuniform vec3 vRefractionMicrosurfaceInfos;\n#endif\n\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\nuniform mat4 reflectionMatrix;\nuniform vec3 vReflectionMicrosurfaceInfos;\n#endif\n",pbrFragmentDeclaration:"uniform vec3 vReflectionColor;\nuniform vec4 vAlbedoColor;\n\nuniform vec4 vLightingIntensity;\nuniform vec4 vReflectivityColor;\nuniform vec3 vEmissiveColor;\n\n#ifdef ALBEDO\nuniform vec2 vAlbedoInfos;\n#endif\n#ifdef AMBIENT\nuniform vec3 vAmbientInfos;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;\nuniform vec4 vNormalReoderParams;\n#endif\n#ifdef OPACITY \nuniform vec2 vOpacityInfos;\n#endif\n#ifdef EMISSIVE\nuniform vec2 vEmissiveInfos;\n#endif\n#ifdef LIGHTMAP\nuniform vec2 vLightmapInfos;\n#endif\n#ifdef REFLECTIVITY\nuniform vec3 vReflectivityInfos;\n#endif\n#ifdef MICROSURFACEMAP\nuniform vec2 vMicroSurfaceSamplerInfos;\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;\nuniform mat4 refractionMatrix;\nuniform vec3 vRefractionMicrosurfaceInfos;\n#endif\n\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\nuniform mat4 reflectionMatrix;\nuniform vec3 vReflectionMicrosurfaceInfos;\n#endif",pbrUboDeclaration:"layout(std140,column_major) uniform;\nuniform Material\n{\nuniform vec2 vAlbedoInfos;\nuniform vec3 vAmbientInfos;\nuniform vec2 vOpacityInfos;\nuniform vec2 vEmissiveInfos;\nuniform vec2 vLightmapInfos;\nuniform vec3 vReflectivityInfos;\nuniform vec2 vMicroSurfaceSamplerInfos;\nuniform vec4 vRefractionInfos;\nuniform vec2 vReflectionInfos;\nuniform vec3 vBumpInfos;\nuniform mat4 albedoMatrix;\nuniform mat4 ambientMatrix;\nuniform mat4 opacityMatrix;\nuniform mat4 emissiveMatrix;\nuniform mat4 lightmapMatrix;\nuniform mat4 reflectivityMatrix;\nuniform mat4 microSurfaceSamplerMatrix;\nuniform mat4 bumpMatrix;\nuniform vec4 vNormalReoderParams;\nuniform mat4 refractionMatrix;\nuniform mat4 reflectionMatrix;\nuniform vec3 vReflectionColor;\nuniform vec4 vAlbedoColor;\nuniform vec4 vLightingIntensity;\nuniform vec3 vRefractionMicrosurfaceInfos;\nuniform vec3 vReflectionMicrosurfaceInfos;\nuniform vec4 vReflectivityColor;\nuniform vec3 vEmissiveColor;\nuniform float pointSize;\n};\nuniform Scene {\nmat4 viewProjection;\nmat4 view;\n};",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",reflectionFunction:"vec3 computeReflectionCoords(vec4 worldPos,vec3 worldNormal)\n{\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_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;\n#ifdef REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED\nreturn vec3(1.0-s,t,0);\n#else\nreturn vec3(s,t,0);\n#endif\n#endif\n#ifdef REFLECTIONMAP_EQUIRECTANGULAR\nvec3 cameraToVertex=normalize(worldPos.xyz-vEyePosition.xyz);\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.xyz;\nvec3 coords=normalize(reflect(viewDir,worldNormal));\nreturn vec3(reflectionMatrix*vec4(coords,1));\n#endif\n#ifdef REFLECTIONMAP_CUBIC\nvec3 viewDir=worldPos.xyz-vEyePosition.xyz;\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 SHADOWFLOAT\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\nfloat computeShadowCube(vec3 lightPosition,samplerCube shadowSampler,float darkness,vec2 depthValues)\n{\nvec3 directionToLight=vPositionW-lightPosition;\nfloat depth=length(directionToLight);\ndepth=(depth+depthValues.x)/(depthValues.y);\ndepth=clamp(depth,0.,1.0);\ndirectionToLight=normalize(directionToLight);\ndirectionToLight.y=-directionToLight.y;\n#ifndef SHADOWFLOAT\nfloat shadow=unpack(textureCube(shadowSampler,directionToLight));\n#else\nfloat shadow=textureCube(shadowSampler,directionToLight).x;\n#endif\nif (depth>shadow)\n{\nreturn darkness;\n}\nreturn 1.0;\n}\nfloat computeShadowWithPCFCube(vec3 lightPosition,samplerCube shadowSampler,float mapSize,float darkness,vec2 depthValues)\n{\nvec3 directionToLight=vPositionW-lightPosition;\nfloat depth=length(directionToLight);\ndepth=(depth+depthValues.x)/(depthValues.y);\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\n#ifndef SHADOWFLOAT\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[0]*mapSize))<depth) visibility-=0.25;\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[1]*mapSize))<depth) visibility-=0.25;\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[2]*mapSize))<depth) visibility-=0.25;\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[3]*mapSize))<depth) visibility-=0.25;\n#else\nif (textureCube(shadowSampler,directionToLight+poissonDisk[0]*mapSize).x<depth) visibility-=0.25;\nif (textureCube(shadowSampler,directionToLight+poissonDisk[1]*mapSize).x<depth) visibility-=0.25;\nif (textureCube(shadowSampler,directionToLight+poissonDisk[2]*mapSize).x<depth) visibility-=0.25;\nif (textureCube(shadowSampler,directionToLight+poissonDisk[3]*mapSize).x<depth) visibility-=0.25;\n#endif\nreturn min(1.0,visibility+darkness);\n}\nfloat computeShadowWithESMCube(vec3 lightPosition,samplerCube shadowSampler,float darkness,float depthScale,vec2 depthValues)\n{\nvec3 directionToLight=vPositionW-lightPosition;\nfloat depth=length(directionToLight);\ndepth=(depth+depthValues.x)/(depthValues.y);\nfloat shadowPixelDepth=clamp(depth,0.,1.0);\ndirectionToLight=normalize(directionToLight);\ndirectionToLight.y=-directionToLight.y;\n#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(textureCube(shadowSampler,directionToLight));\n#else\nfloat shadowMapSample=textureCube(shadowSampler,directionToLight).x;\n#endif\nfloat esm=1.0-clamp(exp(min(87.,depthScale*shadowPixelDepth))*shadowMapSample,0.,1.-darkness); \nreturn esm;\n}\nfloat computeShadowWithCloseESMCube(vec3 lightPosition,samplerCube shadowSampler,float darkness,float depthScale,vec2 depthValues)\n{\nvec3 directionToLight=vPositionW-lightPosition;\nfloat depth=length(directionToLight);\ndepth=(depth+depthValues.x)/(depthValues.y);\nfloat shadowPixelDepth=clamp(depth,0.,1.0);\ndirectionToLight=normalize(directionToLight);\ndirectionToLight.y=-directionToLight.y;\n#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(textureCube(shadowSampler,directionToLight));\n#else\nfloat shadowMapSample=textureCube(shadowSampler,directionToLight).x;\n#endif\nfloat esm=clamp(exp(min(87.,-depthScale*(shadowPixelDepth-shadowMapSample))),darkness,1.);\nreturn esm;\n}\nfloat computeShadow(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\n#ifndef SHADOWFLOAT\nfloat shadow=unpack(texture2D(shadowSampler,uv));\n#else\nfloat shadow=texture2D(shadowSampler,uv).x;\n#endif\nif (shadowPixelDepth>shadow)\n{\nreturn computeFallOff(darkness,clipSpace.xy,frustumEdgeFalloff);\n}\nreturn 1.;\n}\nfloat computeShadowWithPCF(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float mapSize,float darkness,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\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\n#ifndef SHADOWFLOAT\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[0]*mapSize))<shadowPixelDepth) visibility-=0.25;\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[1]*mapSize))<shadowPixelDepth) visibility-=0.25;\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[2]*mapSize))<shadowPixelDepth) visibility-=0.25;\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[3]*mapSize))<shadowPixelDepth) visibility-=0.25;\n#else\nif (texture2D(shadowSampler,uv+poissonDisk[0]*mapSize).x<shadowPixelDepth) visibility-=0.25;\nif (texture2D(shadowSampler,uv+poissonDisk[1]*mapSize).x<shadowPixelDepth) visibility-=0.25;\nif (texture2D(shadowSampler,uv+poissonDisk[2]*mapSize).x<shadowPixelDepth) visibility-=0.25;\nif (texture2D(shadowSampler,uv+poissonDisk[3]*mapSize).x<shadowPixelDepth) visibility-=0.25;\n#endif\nreturn computeFallOff(min(1.0,visibility+darkness),clipSpace.xy,frustumEdgeFalloff);\n}\nfloat computeShadowWithESM(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float depthScale,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\n#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(texture2D(shadowSampler,uv));\n#else\nfloat shadowMapSample=texture2D(shadowSampler,uv).x;\n#endif\nfloat esm=1.0-clamp(exp(min(87.,depthScale*shadowPixelDepth))*shadowMapSample,0.,1.-darkness);\nreturn computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);\n}\nfloat computeShadowWithCloseESM(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float depthScale,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0); \n#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(texture2D(shadowSampler,uv));\n#else\nfloat shadowMapSample=texture2D(shadowSampler,uv).x;\n#endif\nfloat esm=clamp(exp(min(87.,-depthScale*(shadowPixelDepth-shadowMapSample))),darkness,1.);\nreturn computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);\n}\n#endif\n",
- pbrFunctions:"\n#define RECIPROCAL_PI2 0.15915494\n#define FRESNEL_MAXIMUM_ON_ROUGH 0.25\n\nconst float kRougnhessToAlphaScale=0.1;\nconst float kRougnhessToAlphaOffset=0.29248125;\nfloat convertRoughnessToAverageSlope(float roughness)\n{\n\nconst float kMinimumVariance=0.0005;\nfloat alphaG=square(roughness)+kMinimumVariance;\nreturn alphaG;\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/(PI*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 reflectance0,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); \nfloat specTerm=max(0.,visibility*distribution)*NdotL;\nvec3 fresnel=fresnelSchlickGGX(VdotH,reflectance0,reflectance90);\nreturn fresnel*specTerm;\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 fresnel =\n(1.0+(diffuseFresnel90-1.0)*diffuseFresnelNL) *\n(1.0+(diffuseFresnel90-1.0)*diffuseFresnelNV);\nreturn fresnel*NdotL/PI;\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{\nconst float kReflectivityNoAlphaWorkflow_SmoothnessMax=0.95;\nfloat reflectivityLuminance=getLuminance(reflectivityColor);\nfloat reflectivityLuma=sqrt(reflectivityLuminance);\nmicroSurface=reflectivityLuma*kReflectivityNoAlphaWorkflow_SmoothnessMax;\nreturn microSurface;\n}\n\n\nfloat fresnelGrazingReflectance(float reflectance0) {\nfloat reflectance90=clamp(reflectance0*25.0,0.0,1.0);\nreturn reflectance90;\n}\n\n\n#define UNPACK_LOD(x) (1.0-x)*255.0\nfloat getLodFromAlphaG(float cubeMapDimensionPixels,float alphaG,float NdotV) {\nfloat microsurfaceAverageSlope=alphaG;\n\n\n\n\n\n\nmicrosurfaceAverageSlope*=sqrt(abs(NdotV));\nfloat microsurfaceAverageSlopeTexels=microsurfaceAverageSlope*cubeMapDimensionPixels;\nfloat lod=log2(microsurfaceAverageSlopeTexels);\nreturn lod;\n}\nfloat environmentRadianceOcclusion(float ambientOcclusion,float NdotVUnclamped) {\n\n\nfloat temp=NdotVUnclamped+ambientOcclusion;\nreturn clamp(square(temp)-1.0+ambientOcclusion,0.0,1.0);\n}\nfloat environmentHorizonOcclusion(vec3 reflection,vec3 normal) {\n\n#ifdef REFLECTIONMAP_OPPOSITEZ\nreflection.z*=-1.0;\n#endif\nfloat temp=clamp( 1.0+1.1*dot(reflection,normal),0.0,1.0);\nreturn square(temp);\n}",imageProcessingDeclaration:"#ifdef EXPOSURE\nuniform float exposureLinear;\n#endif\n#ifdef CONTRAST\nuniform float contrast;\n#endif\n#ifdef VIGNETTE\nuniform vec2 vInverseScreenSize;\nuniform vec4 vignetteSettings1;\nuniform vec4 vignetteSettings2;\n#endif\n#ifdef COLORCURVES\nuniform vec4 vCameraColorCurveNegative;\nuniform vec4 vCameraColorCurveNeutral;\nuniform vec4 vCameraColorCurvePositive;\n#endif\n#ifdef COLORGRADING\nuniform sampler2D txColorTransform;\nuniform vec4 colorTransformSettings;\n#endif",imageProcessingFunctions:"#ifdef COLORGRADING\n\nvec3 sampleTexture3D(sampler2D colorTransform,vec3 color,vec2 sampler3dSetting)\n{\nfloat sliceSize=2.0*sampler3dSetting.x; \n#ifdef SAMPLER3DGREENDEPTH\nfloat sliceContinuous=(color.g-sampler3dSetting.x)*sampler3dSetting.y;\n#else\nfloat sliceContinuous=(color.b-sampler3dSetting.x)*sampler3dSetting.y;\n#endif\nfloat sliceInteger=floor(sliceContinuous);\n\n\nfloat sliceFraction=sliceContinuous-sliceInteger;\n#ifdef SAMPLER3DGREENDEPTH\nvec2 sliceUV=color.rb;\n#else\nvec2 sliceUV=color.rg;\n#endif\nsliceUV.x*=sliceSize;\nsliceUV.x+=sliceInteger*sliceSize;\nsliceUV=clamp(sliceUV,0.,1.);\nvec4 slice0Color=texture2D(colorTransform,sliceUV);\nsliceUV.x+=sliceSize;\nsliceUV=clamp(sliceUV,0.,1.);\nvec4 slice1Color=texture2D(colorTransform,sliceUV);\nvec3 result=mix(slice0Color.rgb,slice1Color.rgb,sliceFraction);\n#ifdef SAMPLER3DBGRMAP\ncolor.rgb=result.rgb;\n#else\ncolor.rgb=result.bgr;\n#endif\nreturn color;\n}\n#endif\nvec4 applyImageProcessing(vec4 result) {\n#ifdef EXPOSURE\nresult.rgb*=exposureLinear;\n#endif\n#ifdef VIGNETTE\n\nvec2 viewportXY=gl_FragCoord.xy*vInverseScreenSize;\nviewportXY=viewportXY*2.0-1.0;\nvec3 vignetteXY1=vec3(viewportXY*vignetteSettings1.xy+vignetteSettings1.zw,1.0);\nfloat vignetteTerm=dot(vignetteXY1,vignetteXY1);\nfloat vignette=pow(vignetteTerm,vignetteSettings2.w);\n\nvec3 vignetteColor=vignetteSettings2.rgb;\n#ifdef VIGNETTEBLENDMODEMULTIPLY\nvec3 vignetteColorMultiplier=mix(vignetteColor,vec3(1,1,1),vignette);\nresult.rgb*=vignetteColorMultiplier;\n#endif\n#ifdef VIGNETTEBLENDMODEOPAQUE\nresult.rgb=mix(vignetteColor,result.rgb,vignette);\n#endif\n#endif\n#ifdef TONEMAPPING\nconst float tonemappingCalibration=1.590579;\nresult.rgb=1.0-exp2(-tonemappingCalibration*result.rgb);\n#endif\n\nresult.rgb=toGammaSpace(result.rgb);\nresult.rgb=clamp(result.rgb,0.0,1.0);\n#ifdef CONTRAST\n\nvec3 resultHighContrast=applyEaseInOut(result.rgb);\nif (contrast<1.0) {\n\nresult.rgb=mix(vec3(0.5,0.5,0.5),result.rgb,contrast);\n} else {\n\nresult.rgb=mix(result.rgb,resultHighContrast,contrast-1.0);\n}\n#endif\n\n#ifdef COLORGRADING\nvec3 colorTransformInput=result.rgb*colorTransformSettings.xxx+colorTransformSettings.yyy;\nvec3 colorTransformOutput=sampleTexture3D(txColorTransform,colorTransformInput,colorTransformSettings.yz).rgb;\nresult.rgb=mix(result.rgb,colorTransformOutput,colorTransformSettings.www);\n#endif\n#ifdef COLORCURVES\n\nfloat luma=getLuminance(result.rgb);\nvec2 curveMix=clamp(vec2(luma*3.0-1.5,luma*-3.0+1.5),vec2(0.0),vec2(1.0));\nvec4 colorCurve=vCameraColorCurveNeutral+curveMix.x*vCameraColorCurvePositive-curveMix.y*vCameraColorCurveNegative;\nresult.rgb*=colorCurve.rgb;\nresult.rgb=mix(vec3(luma),result.rgb,colorCurve.a);\n#endif\nreturn result;\n}",harmonicsFunctions:"#ifdef USESPHERICALFROMREFLECTIONMAP\nuniform vec3 vSphericalX;\nuniform vec3 vSphericalY;\nuniform vec3 vSphericalZ;\nuniform vec3 vSphericalXX_ZZ;\nuniform vec3 vSphericalYY_ZZ;\nuniform vec3 vSphericalZZ;\nuniform vec3 vSphericalXY;\nuniform vec3 vSphericalYZ;\nuniform vec3 vSphericalZX;\nvec3 quaternionVectorRotation_ScaledSqrtTwo(vec4 Q,vec3 V){\nvec3 T=cross(Q.xyz,V);\nT+=Q.www*V;\nreturn cross(Q.xyz,T)+V;\n}\nvec3 environmentIrradianceJones(vec3 normal)\n{\n\n\n\n\n\n\n\n\n\nfloat Nx=normal.x;\nfloat Ny=normal.y;\nfloat Nz=normal.z;\nvec3 C1=vSphericalZZ.rgb;\nvec3 Cx=vSphericalX.rgb;\nvec3 Cy=vSphericalY.rgb;\nvec3 Cz=vSphericalZ.rgb;\nvec3 Cxx_zz=vSphericalXX_ZZ.rgb;\nvec3 Cyy_zz=vSphericalYY_ZZ.rgb;\nvec3 Cxy=vSphericalXY.rgb;\nvec3 Cyz=vSphericalYZ.rgb;\nvec3 Czx=vSphericalZX.rgb;\nvec3 a1=Cyy_zz*Ny+Cy;\nvec3 a2=Cyz*Nz+a1;\nvec3 b1=Czx*Nz+Cx;\nvec3 b2=Cxy*Ny+b1;\nvec3 b3=Cxx_zz*Nx+b2;\nvec3 t1=Cz*Nz+C1;\nvec3 t2=a2*Ny+t1;\nvec3 t3=b3*Nx+t2;\nreturn t3;\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.001));\n#else\nfloat lightDistanceFalloff=max(0.,1.0-length(lightOffset)/range);\n#endif\nreturn lightDistanceFalloff;\n}\nfloat computeDirectionalLightFalloff(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle,float exponent)\n{\nfloat falloff=0.0;\n#ifdef USEPHYSICALLIGHTFALLOFF\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>=cosHalfAngle)\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 reflectance0,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=clamp(dot(vNormal,lightDirection),0.00000000001,1.0);\nfloat VdotH=clamp(dot(viewDirectionW,H),0.0,1.0);\nfloat diffuseTerm=computeDiffuseTerm(NdotL,NdotV,VdotH,roughness);\nresult.diffuse=diffuseTerm*diffuseColor*attenuation;\n#ifdef SPECULARTERM\n\nfloat NdotH=clamp(dot(vNormal,H),0.000000000001,1.0);\nvec3 specTerm=computeSpecularTerm(NdotH,NdotL,NdotV,VdotH,roughness,reflectance0,reflectance90);\nresult.specular=specTerm*diffuseColor*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 reflectance0,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+directionToLightCenterW);\nNdotL=clamp(dot(vNormal,directionToLightCenterW),0.000000000001,1.0);\nfloat VdotH=clamp(dot(viewDirectionW,H),0.0,1.0);\nfloat diffuseTerm=computeDiffuseTerm(NdotL,NdotV,VdotH,roughness);\nresult.diffuse=diffuseTerm*diffuseColor*attenuation;\n#ifdef SPECULARTERM\n\nfloat NdotH=clamp(dot(vNormal,H),0.000000000001,1.0);\nvec3 specTerm=computeSpecularTerm(NdotH,NdotL,NdotV,VdotH,roughness,reflectance0,reflectance90);\nresult.specular=specTerm*diffuseColor*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 reflectance0,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=clamp(dot(vNormal,H),0.000000000001,1.0);\nNdotL=clamp(NdotL,0.000000000001,1.0);\nfloat VdotH=clamp(dot(viewDirectionW,H),0.0,1.0);\nvec3 specTerm=computeSpecularTerm(NdotH,NdotL,NdotV,VdotH,roughness,reflectance0,reflectance90);\nresult.specular=specTerm*diffuseColor;\n#endif\nreturn result;\n}",helperFunctions:"const float PI=3.1415926535897932384626433832795;\nconst float LinearEncodePowerApprox=2.2;\nconst float GammaEncodePowerApprox=1.0/LinearEncodePowerApprox;\nconst vec3 LuminanceEncodeApprox=vec3(0.2126,0.7152,0.0722);\nmat3 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}\nfloat computeFallOff(float value,vec2 clipSpace,float frustumEdgeFalloff)\n{\nfloat mask=smoothstep(1.0-frustumEdgeFalloff,1.0,clamp(dot(clipSpace,clipSpace),0.,1.));\nreturn mix(value,1.0,mask);\n}\nvec3 applyEaseInOut(vec3 x){\nreturn x*x*(3.0-2.0*x);\n}\nvec3 toLinearSpace(vec3 color)\n{\nreturn pow(color,vec3(LinearEncodePowerApprox));\n}\nvec3 toGammaSpace(vec3 color)\n{\nreturn pow(color,vec3(GammaEncodePowerApprox));\n}\nfloat square(float value)\n{\nreturn value*value;\n}\nfloat getLuminance(vec3 color)\n{\nreturn clamp(dot(color,LuminanceEncodeApprox),0.,1.);\n}",bumpFragmentFunctions:"#ifdef BUMP\n#if BUMPDIRECTUV == 1\n#define vBumpUV vMainUV1\n#elif BUMPDIRECTUV == 2\n#define vBumpUV vMainUV2\n#else\nvarying vec2 vBumpUV;\n#endif\nuniform sampler2D bumpSampler;\n#if defined(TANGENT) && defined(NORMAL) \nvarying mat3 vTBN;\n#endif\n\nmat3 cotangent_frame(vec3 normal,vec3 p,vec2 uv)\n{\n\nuv=gl_FrontFacing ? uv : -uv;\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#ifdef USERIGHTHANDEDSYSTEM\nbinormal=-binormal;\n#endif\n\nfloat invmax=inversesqrt(max(dot(tangent,tangent),dot(binormal,binormal)));\nreturn mat3(tangent*invmax,binormal*invmax,normal);\n}\nvec3 perturbNormal(mat3 cotangentFrame,vec2 uv)\n{\nvec3 map=texture2D(bumpSampler,uv).xyz;\nmap.x=vNormalReoderParams.x+vNormalReoderParams.y*map.x;\nmap.y=vNormalReoderParams.z+vNormalReoderParams.w*map.y;\nmap=map*255./127.-128./127.;\n#ifdef NORMALXYSCALE\nmap=normalize(map*vec3(vBumpInfos.y,vBumpInfos.y,1.0));\n#endif\nreturn normalize(cotangentFrame*map);\n}\n#ifdef PARALLAX\nconst float minSamples=4.;\nconst float maxSamples=15.;\nconst int iMaxSamples=15;\n\nvec2 parallaxOcclusion(vec3 vViewDirCoT,vec3 vNormalCoT,vec2 texCoord,float parallaxScale) {\nfloat parallaxLimit=length(vViewDirCoT.xy)/vViewDirCoT.z;\nparallaxLimit*=parallaxScale;\nvec2 vOffsetDir=normalize(vViewDirCoT.xy);\nvec2 vMaxOffset=vOffsetDir*parallaxLimit;\nfloat numSamples=maxSamples+(dot(vViewDirCoT,vNormalCoT)*(minSamples-maxSamples));\nfloat stepSize=1.0/numSamples;\n\nfloat currRayHeight=1.0;\nvec2 vCurrOffset=vec2(0,0);\nvec2 vLastOffset=vec2(0,0);\nfloat lastSampledHeight=1.0;\nfloat currSampledHeight=1.0;\nfor (int i=0; i<iMaxSamples; i++)\n{\ncurrSampledHeight=texture2D(bumpSampler,vBumpUV+vCurrOffset).w;\n\nif (currSampledHeight>currRayHeight)\n{\nfloat delta1=currSampledHeight-currRayHeight;\nfloat delta2=(currRayHeight+stepSize)-lastSampledHeight;\nfloat ratio=delta1/(delta1+delta2);\nvCurrOffset=(ratio)* vLastOffset+(1.0-ratio)*vCurrOffset;\n\nbreak;\n}\nelse\n{\ncurrRayHeight-=stepSize;\nvLastOffset=vCurrOffset;\nvCurrOffset+=stepSize*vMaxOffset;\nlastSampledHeight=currSampledHeight;\n}\n}\nreturn vCurrOffset;\n}\nvec2 parallaxOffset(vec3 viewDir,float heightScale)\n{\n\nfloat height=texture2D(bumpSampler,vBumpUV).w;\nvec2 texCoordOffset=heightScale*viewDir.xy*height;\nreturn -texCoordOffset;\n}\n#endif\n#endif",clipPlaneFragmentDeclaration:"#ifdef CLIPPLANE\nvarying float fClipDistance;\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 vec3 vFogDistance;\nfloat CalcFogFactor()\n{\nfloat fogCoeff=1.0;\nfloat fogStart=vFogInfos.y;\nfloat fogEnd=vFogInfos.z;\nfloat fogDensity=vFogInfos.w;\nfloat fogDistance=length(vFogDistance);\nif (FOGMODE_LINEAR == vFogInfos.x)\n{\nfogCoeff=(fogEnd-fogDistance)/(fogEnd-fogStart);\n}\nelse if (FOGMODE_EXP == vFogInfos.x)\n{\nfogCoeff=1.0/pow(E,fogDistance*fogDensity);\n}\nelse if (FOGMODE_EXP2 == vFogInfos.x)\n{\nfogCoeff=1.0/pow(E,fogDistance*fogDistance*fogDensity*fogDensity);\n}\nreturn clamp(fogCoeff,0.0,1.0);\n}\n#endif",clipPlaneFragment:"#ifdef CLIPPLANE\nif (fClipDistance>0.0)\n{\ndiscard;\n}\n#endif",bumpFragment:"vec2 uvOffset=vec2(0.0,0.0);\n#if defined(BUMP) || defined(PARALLAX)\n#ifdef NORMALXYSCALE\nfloat normalScale=1.0;\n#else \nfloat normalScale=vBumpInfos.y;\n#endif\n#if defined(TANGENT) && defined(NORMAL)\nmat3 TBN=vTBN;\n#else\nmat3 TBN=cotangent_frame(normalW*normalScale,vPositionW,vBumpUV);\n#endif\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(TBN,vBumpUV+uvOffset);\n#endif",lightFragment:"#ifdef LIGHT{X}\n#if defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X}) && defined(LIGHTMAPNOSPECULAR{X})\n\n#else\n#ifdef PBR\n#ifdef SPOTLIGHT{X}\ninfo=computeSpotLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDirection,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,light{X}.vLightDiffuse.a,roughness,NdotV,specularEnvironmentR0,specularEnvironmentR90,NdotL);\n#endif\n#ifdef HEMILIGHT{X}\ninfo=computeHemisphericLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,light{X}.vLightGround,roughness,NdotV,specularEnvironmentR0,specularEnvironmentR90,NdotL);\n#endif\n#if defined(POINTLIGHT{X}) || defined(DIRLIGHT{X})\ninfo=computeLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,light{X}.vLightDiffuse.a,roughness,NdotV,specularEnvironmentR0,specularEnvironmentR90,NdotL);\n#endif\n#else\n#ifdef SPOTLIGHT{X}\ninfo=computeSpotLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDirection,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,light{X}.vLightDiffuse.a,glossiness);\n#endif\n#ifdef HEMILIGHT{X}\ninfo=computeHemisphericLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,light{X}.vLightGround,glossiness);\n#endif\n#if defined(POINTLIGHT{X}) || defined(DIRLIGHT{X})\ninfo=computeLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,light{X}.vLightDiffuse.a,glossiness);\n#endif\n#endif\n#endif\n#ifdef SHADOW{X}\n#ifdef SHADOWCLOSEESM{X}\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowWithCloseESMCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues);\n#else\nshadow=computeShadowWithCloseESM(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w);\n#endif\n#else\n#ifdef SHADOWESM{X}\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowWithESMCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues);\n#else\nshadow=computeShadowWithESM(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w);\n#endif\n#else \n#ifdef SHADOWPCF{X}\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowWithPCFCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.depthValues);\n#else\nshadow=computeShadowWithPCF(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#else\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.depthValues);\n#else\nshadow=computeShadow(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#endif\n#endif\n#endif\n#else\nshadow=1.;\n#endif\n#ifdef CUSTOMUSERLIGHTING\ndiffuseBase+=computeCustomDiffuseLighting(info,diffuseBase,shadow);\n#ifdef SPECULARTERM\nspecularBase+=computeCustomSpecularLighting(info,specularBase,shadow);\n#endif\n#elif 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",logDepthFragment:"#ifdef LOGARITHMICDEPTH\ngl_FragDepthEXT=log2(vFragmentDepth)*logarithmicDepthConstant*0.5;\n#endif",fogFragment:"#ifdef FOG\nfloat fog=CalcFogFactor();\ncolor.rgb=fog*color.rgb+(1.0-fog)*vFogColor;\n#endif",kernelBlurFragment:"#ifdef PACKEDFLOAT\nblend+=unpack(texture2D(textureSampler,sampleCoord{X}))*KERNEL_WEIGHT{X};\n#else\nblend+=texture2D(textureSampler,sampleCoord{X})*KERNEL_WEIGHT{X};\n#endif",kernelBlurFragment2:"#ifdef PACKEDFLOAT\nblend+=unpack(texture2D(textureSampler,sampleCenter+delta*KERNEL_DEP_OFFSET{X}))*KERNEL_DEP_WEIGHT{X};\n#else\nblend+=texture2D(textureSampler,sampleCenter+delta*KERNEL_DEP_OFFSET{X})*KERNEL_DEP_WEIGHT{X};\n#endif",kernelBlurVaryingDeclaration:"varying vec2 sampleCoord{X};",kernelBlurVertex:"sampleCoord{X}=sampleCenter+delta*KERNEL_OFFSET{X};",pointCloudVertexDeclaration:"#ifdef POINTSIZE\nuniform float pointSize;\n#endif",pointCloudVertex:"#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif",lightsFragmentFunctions:"\nstruct lightingInfo\n{\nvec3 diffuse;\n#ifdef SPECULARTERM\nvec3 specular;\n#endif\n#ifdef NDOTL\nfloat ndl;\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));\n#ifdef NDOTL\nresult.ndl=ndl;\n#endif\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,lightVectorW));\n#ifdef NDOTL\nresult.ndl=ndl;\n#endif\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}\nresult.diffuse=vec3(0.);\n#ifdef SPECULARTERM\nresult.specular=vec3(0.);\n#endif\n#ifdef NDOTL\nresult.ndl=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;\n#ifdef NDOTL\nresult.ndl=ndl;\n#endif\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",defaultVertexDeclaration:"\nuniform mat4 viewProjection;\nuniform mat4 view;\n#ifdef DIFFUSE\nuniform mat4 diffuseMatrix;\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef AMBIENT\nuniform mat4 ambientMatrix;\nuniform vec2 vAmbientInfos;\n#endif\n#ifdef OPACITY\nuniform mat4 opacityMatrix;\nuniform vec2 vOpacityInfos;\n#endif\n#ifdef EMISSIVE\nuniform vec2 vEmissiveInfos;\nuniform mat4 emissiveMatrix;\n#endif\n#ifdef LIGHTMAP\nuniform vec2 vLightmapInfos;\nuniform mat4 lightmapMatrix;\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM)\nuniform vec2 vSpecularInfos;\nuniform mat4 specularMatrix;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;\nuniform mat4 bumpMatrix;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n",defaultFragmentDeclaration:"uniform vec4 vDiffuseColor;\n#ifdef SPECULARTERM\nuniform vec4 vSpecularColor;\n#endif\nuniform vec3 vEmissiveColor;\n\n#ifdef DIFFUSE\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef AMBIENT\nuniform vec2 vAmbientInfos;\n#endif\n#ifdef OPACITY \nuniform vec2 vOpacityInfos;\n#endif\n#ifdef EMISSIVE\nuniform vec2 vEmissiveInfos;\n#endif\n#ifdef LIGHTMAP\nuniform vec2 vLightmapInfos;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;\nuniform vec4 vNormalReoderParams;\n#endif\n#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(REFRACTION)\nuniform mat4 view;\n#endif\n#ifdef REFRACTION\nuniform vec4 vRefractionInfos;\n#ifndef REFRACTIONMAP_3D\nuniform mat4 refractionMatrix;\n#endif\n#ifdef REFRACTIONFRESNEL\nuniform vec4 refractionLeftColor;\nuniform vec4 refractionRightColor;\n#endif\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM)\nuniform vec2 vSpecularInfos;\n#endif\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_SKYBOX\n#else\n#if defined(REFLECTIONMAP_PLANAR) || defined(REFLECTIONMAP_CUBIC) || defined(REFLECTIONMAP_PROJECTION)\nuniform mat4 reflectionMatrix;\n#endif\n#endif\n#ifdef REFLECTIONFRESNEL\nuniform vec4 reflectionLeftColor;\nuniform vec4 reflectionRightColor;\n#endif\n#endif",defaultUboDeclaration:"layout(std140,column_major) uniform;\nuniform Material\n{\nvec4 diffuseLeftColor;\nvec4 diffuseRightColor;\nvec4 opacityParts;\nvec4 reflectionLeftColor;\nvec4 reflectionRightColor;\nvec4 refractionLeftColor;\nvec4 refractionRightColor;\nvec4 emissiveLeftColor; \nvec4 emissiveRightColor;\nvec2 vDiffuseInfos;\nvec2 vAmbientInfos;\nvec2 vOpacityInfos;\nvec2 vReflectionInfos;\nvec2 vEmissiveInfos;\nvec2 vLightmapInfos;\nvec2 vSpecularInfos;\nvec3 vBumpInfos;\nmat4 diffuseMatrix;\nmat4 ambientMatrix;\nmat4 opacityMatrix;\nmat4 reflectionMatrix;\nmat4 emissiveMatrix;\nmat4 lightmapMatrix;\nmat4 specularMatrix;\nmat4 bumpMatrix; \nvec4 vNormalReoderParams;\nmat4 refractionMatrix;\nvec4 vRefractionInfos;\nvec4 vSpecularColor;\nvec3 vEmissiveColor;\nvec4 vDiffuseColor;\nfloat pointSize; \n};\nuniform Scene {\nmat4 viewProjection;\nmat4 view;\n};"};var BABYLON;!(function(e){var t=(function(e){function t(){var t=e.call(this)||this;return t.TRANSPARENT=!1,t.FOG=!1,t.PREMULTIPLYALPHA=!1,t.rebuild(),t}return __extends(t,e),t})(e.MaterialDefines),r=(function(r){function i(t,i){var n=r.call(this,t,i)||this;return n.mainColor=e.Color3.Black(),n.lineColor=e.Color3.Teal(),n.gridRatio=1,n.majorUnitFrequency=10,n.minorUnitVisibility=.33,n.opacity=1,n.preMultiplyAlpha=!1,n._gridControl=new e.Vector4(n.gridRatio,n.majorUnitFrequency,n.minorUnitVisibility,n.opacity),n}return __extends(i,r),i.prototype.needAlphaBlending=function(){return this.opacity<1},i.prototype.isReadyForSubMesh=function(r,i,n){if(this.isFrozen&&this._wasPreviouslyReady&&i.effect)return!0;i._materialDefines||(i._materialDefines=new t);var o=i._materialDefines,s=this.getScene();if(!this.checkReadyOnEveryCall&&i.effect&&this._renderId===s.getRenderId())return!0;s.getEngine();if(o.TRANSPARENT!==this.opacity<1&&(o.TRANSPARENT=!o.TRANSPARENT,o.markAsUnprocessed()),o.PREMULTIPLYALPHA!=this.preMultiplyAlpha&&(o.PREMULTIPLYALPHA=!o.PREMULTIPLYALPHA,o.markAsUnprocessed()),e.MaterialHelper.PrepareDefinesForMisc(r,s,!1,!1,this.fogEnabled,o),o.isDirty){o.markAsProcessed(),s.resetCachedMaterial();var a=[e.VertexBuffer.PositionKind,e.VertexBuffer.NormalKind],u=o.toString();i.setEffect(s.getEngine().createEffect("grid",a,["projection","worldView","mainColor","lineColor","gridControl","vFogInfos","vFogColor","world","view"],[],u,null,this.onCompiled,this.onError),o)}return!!i.effect.isReady()&&(this._renderId=s.getRenderId(),this._wasPreviouslyReady=!0,!0)},i.prototype.bindForSubMesh=function(t,r,i){var n=this.getScene();if(i._materialDefines){var o=i.effect;this._activeEffect=o,this.bindOnlyWorldMatrix(t),this._activeEffect.setMatrix("worldView",t.multiply(n.getViewMatrix())),this._activeEffect.setMatrix("view",n.getViewMatrix()),this._activeEffect.setMatrix("projection",n.getProjectionMatrix()),this._mustRebind(n,o)&&(this._activeEffect.setColor3("mainColor",this.mainColor),this._activeEffect.setColor3("lineColor",this.lineColor),this._gridControl.x=this.gridRatio,this._gridControl.y=Math.round(this.majorUnitFrequency),this._gridControl.z=this.minorUnitVisibility,this._gridControl.w=this.opacity,this._activeEffect.setVector4("gridControl",this._gridControl)),e.MaterialHelper.BindFogParameters(n,r,this._activeEffect),this._afterBind(r,this._activeEffect)}},i.prototype.dispose=function(e){r.prototype.dispose.call(this,e)},i.prototype.clone=function(t){var r=this;return e.SerializationHelper.Clone((function(){return new i(t,r.getScene())}),this)},i.prototype.serialize=function(){var t=e.SerializationHelper.Serialize(this);return t.customType="BABYLON.GridMaterial",t},i.prototype.getClassName=function(){return"GridMaterial"},i.Parse=function(t,r,n){return e.SerializationHelper.Parse((function(){return new i(t.name,r)}),t,r,n)},__decorate([e.serializeAsColor3()],i.prototype,"mainColor",void 0),__decorate([e.serializeAsColor3()],i.prototype,"lineColor",void 0),__decorate([e.serialize()],i.prototype,"gridRatio",void 0),__decorate([e.serialize()],i.prototype,"majorUnitFrequency",void 0),__decorate([e.serialize()],i.prototype,"minorUnitVisibility",void 0),__decorate([e.serialize()],i.prototype,"opacity",void 0),__decorate([e.serialize()],i.prototype,"preMultiplyAlpha",void 0),i})(e.PushMaterial);e.GridMaterial=r})(BABYLON||(BABYLON={})),
- BABYLON.Effect.ShadersStore.gridVertexShader="precision highp float;\n\nattribute vec3 position;\nattribute vec3 normal;\n\nuniform mat4 projection;\nuniform mat4 world;\nuniform mat4 view;\nuniform mat4 worldView;\n\n#ifdef TRANSPARENT\nvarying vec4 vCameraSpacePosition;\n#endif\nvarying vec3 vPosition;\nvarying vec3 vNormal;\n#include<fogVertexDeclaration>\nvoid main(void) {\n#ifdef FOG\nvec4 worldPos=world*vec4(position,1.0);\n#endif\n#include<fogVertex>\nvec4 cameraSpacePosition=worldView*vec4(position,1.0);\ngl_Position=projection*cameraSpacePosition;\n#ifdef TRANSPARENT\nvCameraSpacePosition=cameraSpacePosition;\n#endif\nvPosition=position;\nvNormal=normal;\n}",BABYLON.Effect.ShadersStore.gridPixelShader="#extension GL_OES_standard_derivatives : enable\n#define SQRT2 1.41421356\n#define PI 3.14159\nprecision highp float;\nuniform vec3 mainColor;\nuniform vec3 lineColor;\nuniform vec4 gridControl;\n\n#ifdef TRANSPARENT\nvarying vec4 vCameraSpacePosition;\n#endif\nvarying vec3 vPosition;\nvarying vec3 vNormal;\n#include<fogFragmentDeclaration>\nfloat getVisibility(float position) {\n\nfloat majorGridFrequency=gridControl.y;\nif (floor(position+0.5) == floor(position/majorGridFrequency+0.5)*majorGridFrequency)\n{\nreturn 1.0;\n} \nreturn gridControl.z;\n}\nfloat getAnisotropicAttenuation(float differentialLength) {\nconst float maxNumberOfLines=10.0;\nreturn clamp(1.0/(differentialLength+1.0)-1.0/maxNumberOfLines,0.0,1.0);\n}\nfloat isPointOnLine(float position,float differentialLength) {\nfloat fractionPartOfPosition=position-floor(position+0.5); \nfractionPartOfPosition/=differentialLength; \nfractionPartOfPosition=clamp(fractionPartOfPosition,-1.,1.);\nfloat result=0.5+0.5*cos(fractionPartOfPosition*PI); \nreturn result; \n}\nfloat contributionOnAxis(float position) {\nfloat differentialLength=length(vec2(dFdx(position),dFdy(position)));\ndifferentialLength*=SQRT2; \n\nfloat result=isPointOnLine(position,differentialLength);\n\nfloat visibility=getVisibility(position);\nresult*=visibility;\n\nfloat anisotropicAttenuation=getAnisotropicAttenuation(differentialLength);\nresult*=anisotropicAttenuation;\nreturn result;\n}\nfloat normalImpactOnAxis(float x) {\nfloat normalImpact=clamp(1.0-3.0*abs(x*x*x),0.0,1.0);\nreturn normalImpact;\n}\nvoid main(void) {\n\nfloat gridRatio=gridControl.x;\nvec3 gridPos=vPosition/gridRatio;\n\nfloat x=contributionOnAxis(gridPos.x);\nfloat y=contributionOnAxis(gridPos.y);\nfloat z=contributionOnAxis(gridPos.z);\n\nvec3 normal=normalize(vNormal);\nx*=normalImpactOnAxis(normal.x);\ny*=normalImpactOnAxis(normal.y);\nz*=normalImpactOnAxis(normal.z);\n\nfloat grid=clamp(x+y+z,0.,1.);\n\nvec3 color=mix(mainColor,lineColor,grid);\n#ifdef FOG\n#include<fogFragment>\n#endif\n#ifdef TRANSPARENT\nfloat distanceToFragment=length(vCameraSpacePosition.xyz);\nfloat cameraPassThrough=clamp(distanceToFragment-0.25,0.0,1.0);\nfloat opacity=clamp(grid,0.08,cameraPassThrough*gridControl.w*grid);\ngl_FragColor=vec4(color.rgb,opacity);\n#ifdef PREMULTIPLYALPHA\ngl_FragColor.rgb*=opacity;\n#endif\n#else\n\ngl_FragColor=vec4(color.rgb,1.0);\n#endif\n}";var BABYLON;!(function(e){var t;!(function(e){e[e.AUTO=0]="AUTO",e[e.PASS_THROUGH=1]="PASS_THROUGH",e[e.FORCE_RIGHT_HANDED=2]="FORCE_RIGHT_HANDED"})(t=e.GLTFLoaderCoordinateSystemMode||(e.GLTFLoaderCoordinateSystemMode={}));var r=(function(){function e(){this.coordinateSystemMode=t.AUTO,this.name="gltf",this.extensions={".gltf":{isBinary:!1},".glb":{isBinary:!0}}}return e.prototype.importMeshAsync=function(t,r,i,n,o,s,a){var u=e._parse(i,a);if(u){var l=this._getLoader(u,a);l&&l.importMeshAsync(t,r,u,n,o,s,a)}},e.prototype.loadAsync=function(t,r,i,n,o,s){var a=e._parse(r,s);if(a){var u=this._getLoader(a,s);if(u)return u.loadAsync(t,a,i,n,o,s)}},e.prototype.canDirectLoad=function(e){return-1!==e.indexOf("scene")&&-1!==e.indexOf("node")},e._parse=function(t,r){if(t instanceof ArrayBuffer)return e._parseBinary(t,r);try{return{json:JSON.parse(t),bin:null}}catch(e){return r(e.message),null}},e.prototype._getLoader=function(t,r){var i={major:2,minor:0},n=t.json.asset||{},o=e._parseVersion(n.version);if(!o)return r("Invalid version: "+n.version),null;if(void 0!==n.minVersion){var s=e._parseVersion(n.minVersion);if(!s)return r("Invalid minimum version: "+n.minVersion),null;if(e._compareVersion(s,i)>0)return r("Incompatible minimum version: "+n.minVersion),null}var a={1:e.CreateGLTFLoaderV1,2:e.CreateGLTFLoaderV2},u=a[o.major];return u?u(this):(r("Unsupported version: "+n.version),null)},e._parseBinary=function(t,r){var n={Magic:1179937895},o=new i(t),s=o.readUint32();if(s!==n.Magic)return r("Unexpected magic: "+s),null;var a=o.readUint32();switch(a){case 1:return e._parseV1(o,r);case 2:return e._parseV2(o,r)}return r("Unsupported version: "+a),null},e._parseV1=function(t,r){var i={JSON:0},n=t.readUint32();if(n!=t.getLength())return r("Length in header does not match actual data length: "+n+" != "+t.getLength()),null;var o,s=t.readUint32(),a=t.readUint32();switch(a){case i.JSON:o=JSON.parse(e._decodeBufferToText(t.readUint8Array(s)));break;default:return r("Unexpected content format: "+a),null}var u=t.getLength()-t.getPosition();return{json:o,bin:t.readUint8Array(u)}},e._parseV2=function(t,r){var i={JSON:1313821514,BIN:5130562},n=t.readUint32();if(n!==t.getLength())return r("Length in header does not match actual data length: "+n+" != "+t.getLength()),null;var o=t.readUint32(),s=t.readUint32();if(s!==i.JSON)return r("First chunk format is not JSON"),null;for(var a=JSON.parse(e._decodeBufferToText(t.readUint8Array(o))),u=null;t.getPosition()<t.getLength();)switch(o=t.readUint32(),s=t.readUint32()){case i.JSON:return r("Unexpected JSON chunk"),null;case i.BIN:u=t.readUint8Array(o);break;default:t.skipBytes(o)}return{json:a,bin:u}},e._parseVersion=function(e){if(!e)return null;var t=e.split(".");if(2!=t.length)return null;var r=+t[0];if(isNaN(r))return null;var i=+t[1];return isNaN(i)?null:{major:r,minor:i}},e._compareVersion=function(e,t){return e.major>t.major?1:e.major<t.major?-1:e.minor>t.minor?1:e.minor<t.minor?-1:0},e._decodeBufferToText=function(e){for(var t="",r=e.byteLength,i=0;i<r;++i)t+=String.fromCharCode(e[i]);return t},e.HomogeneousCoordinates=!1,e.IncrementalLoading=!0,e})();e.GLTFFileLoader=r;var i=(function(){function e(e){this._arrayBuffer=e,this._dataView=new DataView(e),this._byteOffset=0}return e.prototype.getPosition=function(){return this._byteOffset},e.prototype.getLength=function(){return this._arrayBuffer.byteLength},e.prototype.readUint32=function(){var e=this._dataView.getUint32(this._byteOffset,!0);return this._byteOffset+=4,e},e.prototype.readUint8Array=function(e){var t=new Uint8Array(this._arrayBuffer,this._byteOffset,e);return this._byteOffset+=e,t},e.prototype.skipBytes=function(e){this._byteOffset+=e},e})();e.SceneLoader&&e.SceneLoader.RegisterPlugin(new r)})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(e){!(function(e){e[e.BYTE=5120]="BYTE",e[e.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",e[e.SHORT=5122]="SHORT",e[e.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",e[e.FLOAT=5126]="FLOAT"})(e.EComponentType||(e.EComponentType={}));!(function(e){e[e.FRAGMENT=35632]="FRAGMENT",e[e.VERTEX=35633]="VERTEX"})(e.EShaderType||(e.EShaderType={}));!(function(e){e[e.BYTE=5120]="BYTE",e[e.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",e[e.SHORT=5122]="SHORT",e[e.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",e[e.INT=5124]="INT",e[e.UNSIGNED_INT=5125]="UNSIGNED_INT",e[e.FLOAT=5126]="FLOAT",e[e.FLOAT_VEC2=35664]="FLOAT_VEC2",e[e.FLOAT_VEC3=35665]="FLOAT_VEC3",e[e.FLOAT_VEC4=35666]="FLOAT_VEC4",e[e.INT_VEC2=35667]="INT_VEC2",e[e.INT_VEC3=35668]="INT_VEC3",e[e.INT_VEC4=35669]="INT_VEC4",e[e.BOOL=35670]="BOOL",e[e.BOOL_VEC2=35671]="BOOL_VEC2",e[e.BOOL_VEC3=35672]="BOOL_VEC3",e[e.BOOL_VEC4=35673]="BOOL_VEC4",e[e.FLOAT_MAT2=35674]="FLOAT_MAT2",e[e.FLOAT_MAT3=35675]="FLOAT_MAT3",e[e.FLOAT_MAT4=35676]="FLOAT_MAT4",e[e.SAMPLER_2D=35678]="SAMPLER_2D"})(e.EParameterType||(e.EParameterType={}));!(function(e){e[e.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",e[e.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",e[e.REPEAT=10497]="REPEAT"})(e.ETextureWrapMode||(e.ETextureWrapMode={}));!(function(e){e[e.NEAREST=9728]="NEAREST",e[e.LINEAR=9728]="LINEAR",e[e.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",e[e.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",e[e.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",e[e.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR"})(e.ETextureFilterType||(e.ETextureFilterType={}));!(function(e){e[e.ALPHA=6406]="ALPHA",e[e.RGB=6407]="RGB",e[e.RGBA=6408]="RGBA",e[e.LUMINANCE=6409]="LUMINANCE",e[e.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA"})(e.ETextureFormat||(e.ETextureFormat={}));!(function(e){e[e.FRONT=1028]="FRONT",e[e.BACK=1029]="BACK",e[e.FRONT_AND_BACK=1032]="FRONT_AND_BACK"})(e.ECullingType||(e.ECullingType={}));!(function(e){e[e.ZERO=0]="ZERO",e[e.ONE=1]="ONE",e[e.SRC_COLOR=768]="SRC_COLOR",e[e.ONE_MINUS_SRC_COLOR=769]="ONE_MINUS_SRC_COLOR",e[e.DST_COLOR=774]="DST_COLOR",e[e.ONE_MINUS_DST_COLOR=775]="ONE_MINUS_DST_COLOR",e[e.SRC_ALPHA=770]="SRC_ALPHA",e[e.ONE_MINUS_SRC_ALPHA=771]="ONE_MINUS_SRC_ALPHA",e[e.DST_ALPHA=772]="DST_ALPHA",e[e.ONE_MINUS_DST_ALPHA=773]="ONE_MINUS_DST_ALPHA",e[e.CONSTANT_COLOR=32769]="CONSTANT_COLOR",e[e.ONE_MINUS_CONSTANT_COLOR=32770]="ONE_MINUS_CONSTANT_COLOR",e[e.CONSTANT_ALPHA=32771]="CONSTANT_ALPHA",e[e.ONE_MINUS_CONSTANT_ALPHA=32772]="ONE_MINUS_CONSTANT_ALPHA",e[e.SRC_ALPHA_SATURATE=776]="SRC_ALPHA_SATURATE"})(e.EBlendingFunction||(e.EBlendingFunction={}))})(e.GLTF1||(e.GLTF1={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(t){var r;!(function(e){e[e.IDENTIFIER=1]="IDENTIFIER",e[e.UNKNOWN=2]="UNKNOWN",e[e.END_OF_INPUT=3]="END_OF_INPUT"})(r||(r={}));var i=(function(){function e(e){this._pos=0,this.isLetterOrDigitPattern=/^[a-zA-Z0-9]+$/,this._toParse=e,this._maxPos=e.length}return e.prototype.getNextToken=function(){if(this.isEnd())return r.END_OF_INPUT;if(this.currentString=this.read(),this.currentToken=r.UNKNOWN,"_"===this.currentString||this.isLetterOrDigitPattern.test(this.currentString))for(this.currentToken=r.IDENTIFIER,this.currentIdentifier=this.currentString;!this.isEnd()&&(this.isLetterOrDigitPattern.test(this.currentString=this.peek())||"_"===this.currentString);)this.currentIdentifier+=this.currentString,this.forward();return this.currentToken},e.prototype.peek=function(){return this._toParse[this._pos]},e.prototype.read=function(){return this._toParse[this._pos++]},e.prototype.forward=function(){this._pos++},e.prototype.isEnd=function(){return this._pos>=this._maxPos},e})(),n=["MODEL","VIEW","PROJECTION","MODELVIEW","MODELVIEWPROJECTION","JOINTMATRIX"],o=["world","view","projection","worldView","worldViewProjection","mBones"],s=["translation","rotation","scale"],a=["position","rotationQuaternion","scaling"],u=function(e,t){for(var r in e){var i=e[r];t.buffers[r]=i,t.buffersCount++}},l=function(e,t){for(var r in e){var i=e[r];t.shaders[r]=i,t.shaderscount++}},h=function(e,t,r){for(var i in e){var n=e[i];r[t][i]=n}},c=function(e){if(e)for(var t=0;t<e.length/2;t++)e[2*t+1]=1-e[2*t+1]},f=function(e){if("NORMAL"===e.semantic)return"normal";if("POSITION"===e.semantic)return"position";if("JOINT"===e.semantic)return"matricesIndices";if("WEIGHT"===e.semantic)return"matricesWeights";if("COLOR"===e.semantic)return"color";if(-1!==e.semantic.indexOf("TEXCOORD_")){var t=Number(e.semantic.split("_")[1]);return"uv"+(0===t?"":t+1)}},d=function(r){for(var i in r.animations)for(var n=r.animations[i],o=null,u=0;u<n.channels.length;u++){var l=n.channels[u],h=n.samplers[l.sampler];if(h){var c=null,f=null;n.parameters?(c=n.parameters[h.input],f=n.parameters[h.output]):(c=h.input,f=h.output);var d=t.GLTFUtils.GetBufferFromAccessor(r,r.accessors[c]),p=t.GLTFUtils.GetBufferFromAccessor(r,r.accessors[f]),g=l.target.id,_=r.scene.getNodeByID(g);if(null===_&&(_=r.scene.getNodeByName(g)),null!==_){var m=_ instanceof e.Bone,v=l.target.path,y=s.indexOf(v);-1!==y&&(v=a[y]);var A=e.Animation.ANIMATIONTYPE_MATRIX;m||("rotationQuaternion"===v?(A=e.Animation.ANIMATIONTYPE_QUATERNION,_.rotationQuaternion=new e.Quaternion):A=e.Animation.ANIMATIONTYPE_VECTOR3);var T=null,E=[],b=0,x=!1;m&&o&&o.getKeys().length===d.length&&(T=o,x=!0),x||(T=new e.Animation(i,m?"_matrix":v,1,A,e.Animation.ANIMATIONLOOPMODE_CYCLE));for(var M=0;M<d.length;M++){var P=null;if("rotationQuaternion"===v?(P=e.Quaternion.FromArray([p[b],p[b+1],p[b+2],p[b+3]]),b+=4):(P=e.Vector3.FromArray([p[b],p[b+1],p[b+2]]),b+=3),m){var R=_,C=e.Vector3.Zero(),O=new e.Quaternion,S=e.Vector3.Zero(),I=R.getBaseMatrix();x&&(I=o.getKeys()[M].value),I.decompose(S,O,C),"position"===v?C=P:"rotationQuaternion"===v?O=P:S=P,P=e.Matrix.Compose(S,O,C)}x?o.getKeys()[M].value=P:E.push({frame:d[M],value:P})}x||(T.setKeys(E),_.animations.push(T)),o=T,r.scene.stopAnimation(_),r.scene.beginAnimation(_,0,d[d.length-1],!0,1)}else e.Tools.Warn("Creating animation named "+i+". But cannot find node named "+g+" to attach to")}}},p=function(t){var r=null;if(t.translation||t.rotation||t.scale){var i=e.Vector3.FromArray(t.scale||[1,1,1]),n=e.Quaternion.FromArray(t.rotation||[0,0,0,1]),o=e.Vector3.FromArray(t.translation||[0,0,0]);r=e.Matrix.Compose(i,n,o)}else r=e.Matrix.FromArray(t.matrix);return r},g=function(t,r,i,n){for(var o=0;o<n.bones.length;o++)if(n.bones[o].name===i)return n.bones[o];var s=t.nodes;for(var a in s){var u=s[a];if(u.jointName)for(var l=u.children,o=0;o<l.length;o++){var h=t.nodes[l[o]];if(h.jointName&&h.jointName===i){var c=p(u),f=new e.Bone(u.name,n,g(t,r,u.jointName,n),c);return f.id=a,f}}}return null},_=function(e,t){for(var r=0;r<e.length;r++)for(var i=e[r],n=0;n<i.node.children.length;n++){var o=i.node.children[n];if(o===t)return i.bone}return null},m=function(e,t){var r=e.nodes,i=r[t];if(i)return{node:i,id:t};for(var n in r)if(i=r[n],i.jointName===t)return{node:i,id:n};return null},v=function(e,t){for(var r=0;r<e.jointNames.length;r++)if(e.jointNames[r]===t)return!0;return!1},y=function(t,r,i,n){for(var o in t.nodes){var s=t.nodes[o],a=o;if(s.jointName&&!v(i,s.jointName)){var u=p(s),l=new e.Bone(s.name,r,null,u);l.id=a,n.push({bone:l,node:s,id:a})}}for(var h=0;h<n.length;h++)for(var c=n[h],f=c.node.children,d=0;d<f.length;d++){for(var g=null,_=0;_<n.length;_++)if(n[_].id===f[d]){g=n[_];break}g&&(g.bone._parent=c.bone,c.bone.children.push(g.bone))}},A=function(r,i,n,o,s){if(o||(o=new e.Skeleton(i.name,"",r.scene)),!i.babylonSkeleton)return o;var a=r.accessors[i.inverseBindMatrices],u=(t.GLTFUtils.GetBufferFromAccessor(r,a),e.Matrix.FromArray(i.bindShapeMatrix),[]),l=[];y(r,o,i,u),o.bones=[];for(var h=0;h<i.jointNames.length;h++){var c=m(r,i.jointNames[h]),f=c.node;if(f){var s=c.id,d=r.scene.getBoneByID(s);if(d)o.bones.push(d);else{for(var v=!1,A=null,T=0;T<h;T++){var E=m(r,i.jointNames[T]).node;if(E){var b=E.children;if(b){v=!1;for(var x=0;x<b.length;x++)if(b[x]===s){A=g(r,i,i.jointNames[T],o),v=!0;break}if(v)break}}else e.Tools.Warn("Joint named "+i.jointNames[T]+" does not exist when looking for parent")}var M=p(f);!A&&u.length>0&&(A=_(u,s))&&-1===l.indexOf(A)&&l.push(A);new e.Bone(f.jointName,o,A,M).id=s}}else e.Tools.Warn("Joint named "+i.jointNames[h]+" does not exist")}var P=o.bones;o.bones=[];for(var h=0;h<i.jointNames.length;h++){var c=m(r,i.jointNames[h]);if(c)for(var T=0;T<P.length;T++)if(P[T].id===c.id){o.bones.push(P[T]);break}}o.prepare();for(var h=0;h<l.length;h++)o.bones.push(l[h]);return o},T=function(r,i,n,o,s){if(s||(s=new e.Mesh(i.name,r.scene),s.id=o),!i.babylonNode)return s;var a=new e.MultiMaterial("multimat"+o,r.scene);s.material||(s.material=a);for(var u=new e.VertexData,l=new e.Geometry(o,r.scene,u,!1,s),h=[],f=[],d=[],p=[],g=0;g<n.length;g++){var _=n[g],m=r.meshes[_];if(m)for(var v=0;v<m.primitives.length;v++){var y=new e.VertexData,A=m.primitives[v];A.mode;var T=A.attributes,E=null,b=null;for(var x in T)if(E=r.accessors[T[x]],b=t.GLTFUtils.GetBufferFromAccessor(r,E),"NORMAL"===x)y.normals=new Float32Array(b.length),y.normals.set(b);else if("POSITION"===x){if(e.GLTFFileLoader.HomogeneousCoordinates){y.positions=new Float32Array(b.length-b.length/4);for(var M=0;M<b.length;M+=4)y.positions[M]=b[M],y.positions[M+1]=b[M+1],y.positions[M+2]=b[M+2]}else y.positions=new Float32Array(b.length),y.positions.set(b);f.push(y.positions.length)}else if(-1!==x.indexOf("TEXCOORD_")){var P=Number(x.split("_")[1]),R=e.VertexBuffer.UVKind+(0===P?"":P+1),C=new Float32Array(b.length);C.set(b),c(C),y.set(C,R)}else"JOINT"===x?(y.matricesIndices=new Float32Array(b.length),y.matricesIndices.set(b)):"WEIGHT"===x?(y.matricesWeights=new Float32Array(b.length),y.matricesWeights.set(b)):"COLOR"===x&&(y.colors=new Float32Array(b.length),y.colors.set(b));if(E=r.accessors[A.indices])b=t.GLTFUtils.GetBufferFromAccessor(r,E),y.indices=new Int32Array(b.length),y.indices.set(b),p.push(y.indices.length);else{for(var O=[],M=0;M<y.positions.length/3;M++)O.push(M);y.indices=new Int32Array(O),p.push(y.indices.length)}u.merge(y),y=void 0;var S=r.scene.getMaterialByID(A.material);a.subMaterials.push(null===S?t.GLTFUtils.GetDefaultMaterial(r.scene):S),h.push(0===h.length?0:h[h.length-1]+f[f.length-2]),d.push(0===d.length?0:d[d.length-1]+p[p.length-2])}}l.setAllVerticesData(u,!1),s.computeWorldMatrix(!0),s.subMeshes=[];for(var I=0,g=0;g<n.length;g++){var _=n[g],m=r.meshes[_];if(m)for(var v=0;v<m.primitives.length;v++){m.primitives[v].mode;new e.SubMesh(I,h[I],f[I],d[I],p[I],s,s,!0);I++}}return s},E=function(e,t,r,i){e.position&&(e.position=t),(e.rotationQuaternion||e.rotation)&&(e.rotationQuaternion=r),e.scaling&&(e.scaling=i)},b=function(t,r,i){if(r.matrix){var n=new e.Vector3(0,0,0),o=new e.Quaternion,s=new e.Vector3(0,0,0);e.Matrix.FromArray(r.matrix).decompose(s,o,n),E(t,n,o,s)}else E(t,e.Vector3.FromArray(r.translation),e.Quaternion.FromArray(r.rotation),e.Vector3.FromArray(r.scale));t.computeWorldMatrix(!0)},x=function(t,r,i,n){var o=null;if(t.importOnlyMeshes&&(r.skin||r.meshes)&&t.importMeshesNames.length>0&&-1===t.importMeshesNames.indexOf(r.name))return null;if(r.skin){if(r.meshes){var s=t.skins[r.skin],a=T(t,r,r.meshes,i,r.babylonNode);a.skeleton=t.scene.getLastSkeletonByID(r.skin),null===a.skeleton&&(a.skeleton=A(t,s,0,s.babylonSkeleton,r.skin),s.babylonSkeleton||(s.babylonSkeleton=a.skeleton)),o=a}}else if(r.meshes){var a=T(t,r,r.mesh?[r.mesh]:r.meshes,i,r.babylonNode);o=a}else if(!r.light||r.babylonNode||t.importOnlyMeshes){if(r.camera&&!r.babylonNode&&!t.importOnlyMeshes){var u=t.cameras[r.camera];if(u)if("orthographic"===u.type){var l=(u[u.type],new e.FreeCamera(r.camera,e.Vector3.Zero(),t.scene));l.name=r.name,l.mode=e.Camera.ORTHOGRAPHIC_CAMERA,l.attachControl(t.scene.getEngine().getRenderingCanvas()),o=l}else if("perspective"===u.type){var h=u[u.type],c=new e.FreeCamera(r.camera,e.Vector3.Zero(),t.scene);c.name=r.name,c.attachControl(t.scene.getEngine().getRenderingCanvas()),h.aspectRatio||(h.aspectRatio=t.scene.getEngine().getRenderWidth()/t.scene.getEngine().getRenderHeight()),h.znear&&h.zfar&&(c.maxZ=h.zfar,c.minZ=h.znear),o=c}}}else{var f=t.lights[r.light];if(f)if("ambient"===f.type){var d=f[f.type],p=new e.HemisphericLight(r.light,e.Vector3.Zero(),t.scene);p.name=r.name,d.color&&(p.diffuse=e.Color3.FromArray(d.color)),o=p}else if("directional"===f.type){var g=f[f.type],_=new e.DirectionalLight(r.light,e.Vector3.Zero(),t.scene);_.name=r.name,g.color&&(_.diffuse=e.Color3.FromArray(g.color)),o=_}else if("point"===f.type){var m=f[f.type],v=new e.PointLight(r.light,e.Vector3.Zero(),t.scene);v.name=r.name,m.color&&(v.diffuse=e.Color3.FromArray(m.color)),o=v}else if("spot"===f.type){var y=f[f.type],x=new e.SpotLight(r.light,e.Vector3.Zero(),e.Vector3.Zero(),0,0,t.scene);x.name=r.name,y.color&&(x.diffuse=e.Color3.FromArray(y.color)),y.fallOfAngle&&(x.angle=y.fallOfAngle),y.fallOffExponent&&(x.exponent=y.fallOffExponent),o=x}}if(!r.jointName){if(r.babylonNode)return r.babylonNode;if(null===o){var M=new e.Mesh(r.name,t.scene);r.babylonNode=M,o=M}}if(null!==o){if(r.matrix&&o instanceof e.Mesh)b(o,r);else{var P=r.translation||[0,0,0],R=r.rotation||[0,0,0,1],C=r.scale||[1,1,1];E(o,e.Vector3.FromArray(P),e.Quaternion.FromArray(R),e.Vector3.FromArray(C))}o.updateCache(!0),r.babylonNode=o}return o},M=function(e,t,r,i){var n=e.nodes[t],o=null;if(i=!(e.importOnlyMeshes&&!i)||(-1!==e.importMeshesNames.indexOf(n.name)||0===e.importMeshesNames.length),!n.jointName&&i&&null!==(o=x(e,n,t))&&(o.id=t,o.parent=r),n.children)for(var s=0;s<n.children.length;s++)M(e,n.children[s],o,i)},P=function(e){var t=e.currentScene;if(t)for(var r=0;r<t.nodes.length;r++)M(e,t.nodes[r],null);else for(var i in e.scenes){t=e.scenes[i];for(var r=0;r<t.nodes.length;r++)M(e,t.nodes[r],null)}d(e);for(var r=0;r<e.scene.skeletons.length;r++){var n=e.scene.skeletons[r];e.scene.beginAnimation(n,0,Number.MAX_VALUE,!0,1)}},R=function(e,r,i,n,o,s,a){var u=s.values||o.parameters;for(var l in i){var h=i[l],c=h.type;if(c===t.EParameterType.FLOAT_MAT2||c===t.EParameterType.FLOAT_MAT3||c===t.EParameterType.FLOAT_MAT4)if(!h.semantic||h.source||h.node){if(h.semantic&&(h.source||h.node)){var f=r.scene.getNodeByName(h.source||h.node);if(null===f&&(f=r.scene.getNodeByID(h.source||h.node)),null===f)continue;t.GLTFUtils.SetMatrix(r.scene,f,h,l,n.getEffect())}}else t.GLTFUtils.SetMatrix(r.scene,e,h,l,n.getEffect());else{var d=u[o.uniforms[l]];if(!d)continue;if(c===t.EParameterType.SAMPLER_2D){var p=r.textures[s.values?d:h.value].babylonTexture;if(null===p||void 0===p)continue;n.getEffect().setTexture(l,p)}else t.GLTFUtils.SetUniform(n.getEffect(),l,d,c)}}a(n)},C=function(e,r,i,n,o){var s=n.values||i.parameters,a=i.uniforms;for(var u in o){var l=o[u],h=l.type,c=s[a[u]];if(void 0===c&&(c=l.value),c){var f=function(e){return function(t){l.value&&(r.setTexture(e,t),delete o[e])}};h===t.EParameterType.SAMPLER_2D?t.GLTFLoaderExtension.LoadTextureAsync(e,n.values?c:l.value,f(u),(function(){return f(null)})):l.value&&t.GLTFUtils.SetUniform(r,u,n.values?c:l.value,h)&&delete o[u]}}},O=function(e,t,r){return function(i,n){t.dispose(!0),r("Cannot compile program named "+e.name+". Error: "+n+". Default material will be applied")}},S=function(e,t,r,i,n,o){return function(s){C(e,t,r,i,n),t.onBind=function(s){R(s,e,n,t,r,i,o)}}},I=function(e,t,r){for(var i in t.uniforms){var s=t.uniforms[i],a=t.parameters[s];if(e.currentIdentifier===i&&a.semantic&&!a.source&&!a.node){var u=n.indexOf(a.semantic);if(-1!==u)return delete r[i],o[u]}}return e.currentIdentifier},L=function(e){for(var r in e.materials)t.GLTFLoaderExtension.LoadMaterialAsync(e,r,(function(e){}),(function(){}))},D=(function(){function s(){}return s.CreateRuntime=function(e,t,r){var i={extensions:{},accessors:{},buffers:{},bufferViews:{},meshes:{},lights:{},cameras:{},nodes:{},images:{},textures:{},shaders:{},programs:{},samplers:{},techniques:{},materials:{},animations:{},skins:{},extensionsUsed:[],scenes:{},buffersCount:0,shaderscount:0,scene:t,rootUrl:r,loadedBufferCount:0,loadedBufferViews:{},loadedShaderCount:0,importOnlyMeshes:!1,dummyNodes:[]};return e.extensions&&h(e.extensions,"extensions",i),e.extensionsUsed&&h(e.extensionsUsed,"extensionsUsed",i),e.buffers&&u(e.buffers,i),e.bufferViews&&h(e.bufferViews,"bufferViews",i),e.accessors&&h(e.accessors,"accessors",i),e.meshes&&h(e.meshes,"meshes",i),e.lights&&h(e.lights,"lights",i),e.cameras&&h(e.cameras,"cameras",i),e.nodes&&h(e.nodes,"nodes",i),e.images&&h(e.images,"images",i),e.textures&&h(e.textures,"textures",i),e.shaders&&l(e.shaders,i),e.programs&&h(e.programs,"programs",i),e.samplers&&h(e.samplers,"samplers",i),e.techniques&&h(e.techniques,"techniques",i),e.materials&&h(e.materials,"materials",i),e.animations&&h(e.animations,"animations",i),e.skins&&h(e.skins,"skins",i),e.scenes&&(i.scenes=e.scenes),e.scene&&e.scenes&&(i.currentScene=e.scenes[e.scene]),i},s.LoadBufferAsync=function(r,i,n,o,s){var a=r.buffers[i];t.GLTFUtils.IsBase64(a.uri)?setTimeout((function(){return n(new Uint8Array(t.GLTFUtils.DecodeBase64(a.uri)))})):e.Tools.LoadFile(r.rootUrl+a.uri,(function(e){return n(new Uint8Array(e))}),s,null,!0,(function(e){o(e.status+" "+e.statusText)}))},s.LoadTextureBufferAsync=function(r,i,n,o){var s=r.textures[i];if(!s||!s.source)return void o(null);if(s.babylonTexture)return void n(null);var a=r.images[s.source];t.GLTFUtils.IsBase64(a.uri)?setTimeout((function(){return n(new Uint8Array(t.GLTFUtils.DecodeBase64(a.uri)))})):e.Tools.LoadFile(r.rootUrl+a.uri,(function(e){return n(new Uint8Array(e))}),null,null,!0,(function(e){o(e.status+" "+e.statusText)}))},s.CreateTextureAsync=function(r,i,n,o,s){var a=r.textures[i];if(a.babylonTexture)return void o(a.babylonTexture);var u=r.samplers[a.sampler],l=u.minFilter===t.ETextureFilterType.NEAREST_MIPMAP_NEAREST||u.minFilter===t.ETextureFilterType.NEAREST_MIPMAP_LINEAR||u.minFilter===t.ETextureFilterType.LINEAR_MIPMAP_NEAREST||u.minFilter===t.ETextureFilterType.LINEAR_MIPMAP_LINEAR,h=e.Texture.BILINEAR_SAMPLINGMODE,c=new Blob([n]),f=URL.createObjectURL(c),d=function(){return URL.revokeObjectURL(f)},p=new e.Texture(f,r.scene,!l,!0,h,d,d);p.wrapU=t.GLTFUtils.GetWrapMode(u.wrapS),p.wrapV=t.GLTFUtils.GetWrapMode(u.wrapT),p.name=i,a.babylonTexture=p,o(p)},s.LoadShaderStringAsync=function(r,i,n,o){var s=r.shaders[i];if(t.GLTFUtils.IsBase64(s.uri)){n(atob(s.uri.split(",")[1]))}else e.Tools.LoadFile(r.rootUrl+s.uri,n,null,null,!1,(function(e){o(e.status+" "+e.statusText)}))},s.LoadMaterialAsync=function(s,a,u,l){var h=s.materials[a],c=s.techniques[h.technique];if(!c){var d=new e.StandardMaterial(a,s.scene);return d.diffuseColor=new e.Color3(.5,.5,.5),d.sideOrientation=e.Material.CounterClockWiseSideOrientation,void u(d)}var p=s.programs[c.program],g=c.states,_=e.Effect.ShadersStore[p.vertexShader+"VertexShader"],m=e.Effect.ShadersStore[p.fragmentShader+"PixelShader"],v="",y="",A=new i(_),T=new i(m),E={},b=[],x=[],M=[];for(var P in c.uniforms){var R=c.uniforms[P],C=c.parameters[R];if(E[P]=C,!C.semantic||C.node||C.source)C.type===t.EParameterType.SAMPLER_2D?M.push(P):b.push(P);else{var L=n.indexOf(C.semantic);-1!==L?(b.push(o[L]),delete E[P]):b.push(P)}}for(var D in c.attributes){var B=c.attributes[D],N=c.parameters[B];N.semantic&&x.push(f(N))}for(;!A.isEnd()&&A.getNextToken();){var F=A.currentToken;if(F===r.IDENTIFIER){var w=!1;for(var D in c.attributes){var B=c.attributes[D],N=c.parameters[B];if(A.currentIdentifier===D&&N.semantic){v+=f(N),w=!0;break}}w||(v+=I(A,c,E))}else v+=A.currentString}for(;!T.isEnd()&&T.getNextToken();){var F=T.currentToken;F===r.IDENTIFIER?y+=I(T,c,E):y+=T.currentString}var V={vertex:p.vertexShader+a,fragment:p.fragmentShader+a},U={attributes:x,uniforms:b,samplers:M,needAlphaBlending:g&&g.enable&&-1!==g.enable.indexOf(3042)};e.Effect.ShadersStore[p.vertexShader+a+"VertexShader"]=v,e.Effect.ShadersStore[p.fragmentShader+a+"PixelShader"]=y;var k=new e.ShaderMaterial(a,s.scene,V,U);if(k.onError=O(p,k,l),k.onCompiled=S(s,k,c,h,E,u),k.sideOrientation=e.Material.CounterClockWiseSideOrientation,g&&g.functions){var z=g.functions;z.cullFace&&z.cullFace[0]!==t.ECullingType.BACK&&(k.backFaceCulling=!1);var G=z.blendFuncSeparate;G&&(G[0]===t.EBlendingFunction.SRC_ALPHA&&G[1]===t.EBlendingFunction.ONE_MINUS_SRC_ALPHA&&G[2]===t.EBlendingFunction.ONE&&G[3]===t.EBlendingFunction.ONE?k.alphaMode=e.Engine.ALPHA_COMBINE:G[0]===t.EBlendingFunction.ONE&&G[1]===t.EBlendingFunction.ONE&&G[2]===t.EBlendingFunction.ZERO&&G[3]===t.EBlendingFunction.ONE?k.alphaMode=e.Engine.ALPHA_ONEONE:G[0]===t.EBlendingFunction.SRC_ALPHA&&G[1]===t.EBlendingFunction.ONE&&G[2]===t.EBlendingFunction.ZERO&&G[3]===t.EBlendingFunction.ONE?k.alphaMode=e.Engine.ALPHA_ADD:G[0]===t.EBlendingFunction.ZERO&&G[1]===t.EBlendingFunction.ONE_MINUS_SRC_COLOR&&G[2]===t.EBlendingFunction.ONE&&G[3]===t.EBlendingFunction.ONE?k.alphaMode=e.Engine.ALPHA_SUBTRACT:G[0]===t.EBlendingFunction.DST_COLOR&&G[1]===t.EBlendingFunction.ZERO&&G[2]===t.EBlendingFunction.ONE&&G[3]===t.EBlendingFunction.ONE?k.alphaMode=e.Engine.ALPHA_MULTIPLY:G[0]===t.EBlendingFunction.SRC_ALPHA&&G[1]===t.EBlendingFunction.ONE_MINUS_SRC_COLOR&&G[2]===t.EBlendingFunction.ONE&&G[3]===t.EBlendingFunction.ONE&&(k.alphaMode=e.Engine.ALPHA_MAXIMIZED))}},s})();t.GLTFLoaderBase=D;var B=(function(){function r(){}return r.RegisterExtension=function(t){if(r.Extensions[t.name])return void e.Tools.Error('Tool with the same name "'+t.name+'" already exists');r.Extensions[t.name]=t},r.prototype.importMeshAsync=function(r,i,n,o,s,a,u){var l=this;i.useRightHandedSystem=!0;t.GLTFLoaderExtension.LoadRuntimeAsync(i,n,o,(function(t){t.importOnlyMeshes=!0,""===r?t.importMeshesNames=[]:"string"==typeof r?t.importMeshesNames=[r]:!r||r instanceof Array?(t.importMeshesNames=[],e.Tools.Warn("Argument meshesNames must be of type string or string[]")):t.importMeshesNames=[r],l._createNodes(t);var i=[],n=[];for(var o in t.nodes){var u=t.nodes[o];u.babylonNode instanceof e.AbstractMesh&&i.push(u.babylonNode)}for(var h in t.skins){var c=t.skins[h];c.babylonSkeleton instanceof e.Skeleton&&n.push(c.babylonSkeleton)}l._loadBuffersAsync(t,(function(){l._loadShadersAsync(t,(function(){L(t),P(t),!e.GLTFFileLoader.IncrementalLoading&&s&&s(i,null,n)}))}),a),e.GLTFFileLoader.IncrementalLoading&&s&&s(i,null,n)}),u);return!0},r.prototype.loadAsync=function(r,i,n,o,s,a){var u=this;r.useRightHandedSystem=!0,t.GLTFLoaderExtension.LoadRuntimeAsync(r,i,n,(function(r){t.GLTFLoaderExtension.LoadRuntimeExtensionsAsync(r,(function(){u._createNodes(r),u._loadBuffersAsync(r,(function(){u._loadShadersAsync(r,(function(){L(r),P(r),e.GLTFFileLoader.IncrementalLoading||o()}))})),e.GLTFFileLoader.IncrementalLoading&&o()}),a)}),a)},r.prototype._loadShadersAsync=function(r,i){var n=!1,o=function(n,o){t.GLTFLoaderExtension.LoadShaderStringAsync(r,n,(function(s){r.loadedShaderCount++,s&&(e.Effect.ShadersStore[n+(o.type===t.EShaderType.VERTEX?"VertexShader":"PixelShader")]=s),r.loadedShaderCount===r.shaderscount&&i()}),(function(){e.Tools.Error("Error when loading shader program named "+n+" located at "+o.uri)}))};for(var s in r.shaders){n=!0;var a=r.shaders[s];a?o.bind(this,s,a)():e.Tools.Error("No shader named: "+s)}n||i()},r.prototype._loadBuffersAsync=function(r,i,n){var o=!1,s=function(n,o){t.GLTFLoaderExtension.LoadBufferAsync(r,n,(function(t){r.loadedBufferCount++,t&&(t.byteLength!=r.buffers[n].byteLength&&e.Tools.Error("Buffer named "+n+" is length "+t.byteLength+". Expected: "+o.byteLength),r.loadedBufferViews[n]=t),r.loadedBufferCount===r.buffersCount&&i()}),(function(){e.Tools.Error("Error when loading buffer named "+n+" located at "+o.uri)}))};for(var a in r.buffers){o=!0;var u=r.buffers[a];u?s.bind(this,a,u)():e.Tools.Error("No buffer named: "+a)}o||i()},r.prototype._createNodes=function(e){var t=e.currentScene;if(t)for(var r=0;r<t.nodes.length;r++)M(e,t.nodes[r],null);else for(var i in e.scenes){t=e.scenes[i];for(var r=0;r<t.nodes.length;r++)M(e,t.nodes[r],null)}},r.Extensions={},r})();t.GLTFLoader=B,e.GLTFFileLoader.CreateGLTFLoaderV1=function(){return new B}})(e.GLTF1||(e.GLTF1={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(t){var r=(function(){function r(){}return r.SetMatrix=function(r,i,n,o,s){var a=null;switch("MODEL"===n.semantic?a=i.getWorldMatrix():"PROJECTION"===n.semantic?a=r.getProjectionMatrix():"VIEW"===n.semantic?a=r.getViewMatrix():"MODELVIEWINVERSETRANSPOSE"===n.semantic?a=e.Matrix.Transpose(i.getWorldMatrix().multiply(r.getViewMatrix()).invert()):"MODELVIEW"===n.semantic?a=i.getWorldMatrix().multiply(r.getViewMatrix()):"MODELVIEWPROJECTION"===n.semantic?a=i.getWorldMatrix().multiply(r.getTransformMatrix()):"MODELINVERSE"===n.semantic?a=i.getWorldMatrix().invert():"VIEWINVERSE"===n.semantic?a=r.getViewMatrix().invert():"PROJECTIONINVERSE"===n.semantic?a=r.getProjectionMatrix().invert():"MODELVIEWINVERSE"===n.semantic?a=i.getWorldMatrix().multiply(r.getViewMatrix()).invert():"MODELVIEWPROJECTIONINVERSE"===n.semantic?a=i.getWorldMatrix().multiply(r.getTransformMatrix()).invert():"MODELINVERSETRANSPOSE"===n.semantic&&(a=e.Matrix.Transpose(i.getWorldMatrix().invert())),n.type){case t.EParameterType.FLOAT_MAT2:
- s.setMatrix2x2(o,e.Matrix.GetAsMatrix2x2(a));break;case t.EParameterType.FLOAT_MAT3:s.setMatrix3x3(o,e.Matrix.GetAsMatrix3x3(a));break;case t.EParameterType.FLOAT_MAT4:s.setMatrix(o,a)}},r.SetUniform=function(r,i,n,o){switch(o){case t.EParameterType.FLOAT:return r.setFloat(i,n),!0;case t.EParameterType.FLOAT_VEC2:return r.setVector2(i,e.Vector2.FromArray(n)),!0;case t.EParameterType.FLOAT_VEC3:return r.setVector3(i,e.Vector3.FromArray(n)),!0;case t.EParameterType.FLOAT_VEC4:return r.setVector4(i,e.Vector4.FromArray(n)),!0;default:return!1}},r.IsBase64=function(e){return!(e.length<5)&&"data:"===e.substr(0,5)},r.DecodeBase64=function(e){for(var t=atob(e.split(",")[1]),r=t.length,i=new Uint8Array(new ArrayBuffer(r)),n=0;n<r;n++)i[n]=t.charCodeAt(n);return i.buffer},r.GetWrapMode=function(r){switch(r){case t.ETextureWrapMode.CLAMP_TO_EDGE:return e.Texture.CLAMP_ADDRESSMODE;case t.ETextureWrapMode.MIRRORED_REPEAT:return e.Texture.MIRROR_ADDRESSMODE;case t.ETextureWrapMode.REPEAT:default:return e.Texture.WRAP_ADDRESSMODE}},r.GetByteStrideFromType=function(e){switch(e.type){case"VEC2":return 2;case"VEC3":return 3;case"VEC4":case"MAT2":return 4;case"MAT3":return 9;case"MAT4":return 16;default:return 1}},r.GetTextureFilterMode=function(r){switch(r){case t.ETextureFilterType.LINEAR:case t.ETextureFilterType.LINEAR_MIPMAP_NEAREST:case t.ETextureFilterType.LINEAR_MIPMAP_LINEAR:return e.Texture.TRILINEAR_SAMPLINGMODE;case t.ETextureFilterType.NEAREST:case t.ETextureFilterType.NEAREST_MIPMAP_NEAREST:return e.Texture.NEAREST_SAMPLINGMODE;default:return e.Texture.BILINEAR_SAMPLINGMODE}},r.GetBufferFromBufferView=function(e,r,i,n,o){var i=r.byteOffset+i,s=e.loadedBufferViews[r.buffer];if(i+n>s.byteLength)throw new Error("Buffer access is out of range");var a=s.buffer;switch(i+=s.byteOffset,o){case t.EComponentType.BYTE:return new Int8Array(a,i,n);case t.EComponentType.UNSIGNED_BYTE:return new Uint8Array(a,i,n);case t.EComponentType.SHORT:return new Int16Array(a,i,n);case t.EComponentType.UNSIGNED_SHORT:return new Uint16Array(a,i,n);default:return new Float32Array(a,i,n)}},r.GetBufferFromAccessor=function(e,t){var i=e.bufferViews[t.bufferView],n=t.count*r.GetByteStrideFromType(t);return r.GetBufferFromBufferView(e,i,t.byteOffset,n,t.componentType)},r.DecodeBufferToText=function(e){for(var t="",r=e.byteLength,i=0;i<r;++i)t+=String.fromCharCode(e[i]);return t},r.GetDefaultMaterial=function(t){if(!r._DefaultMaterial){e.Effect.ShadersStore.GLTFDefaultMaterialVertexShader=["precision highp float;","","uniform mat4 worldView;","uniform mat4 projection;","","attribute vec3 position;","","void main(void)","{"," gl_Position = projection * worldView * vec4(position, 1.0);","}"].join("\n"),e.Effect.ShadersStore.GLTFDefaultMaterialPixelShader=["precision highp float;","","uniform vec4 u_emission;","","void main(void)","{"," gl_FragColor = u_emission;","}"].join("\n");var i={vertex:"GLTFDefaultMaterial",fragment:"GLTFDefaultMaterial"},n={attributes:["position"],uniforms:["worldView","projection","u_emission"],samplers:[],needAlphaBlending:!1};r._DefaultMaterial=new e.ShaderMaterial("GLTFDefaultMaterial",t,i,n),r._DefaultMaterial.setColor4("u_emission",new e.Color4(.5,.5,.5,1))}return r._DefaultMaterial},r._DefaultMaterial=null,r})();t.GLTFUtils=r})(e.GLTF1||(e.GLTF1={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(e){var t=(function(){function t(e){this._name=e}return Object.defineProperty(t.prototype,"name",{get:function(){return this._name},enumerable:!0,configurable:!0}),t.prototype.loadRuntimeAsync=function(e,t,r,i,n){return!1},t.prototype.loadRuntimeExtensionsAsync=function(e,t,r){return!1},t.prototype.loadBufferAsync=function(e,t,r,i,n){return!1},t.prototype.loadTextureBufferAsync=function(e,t,r,i){return!1},t.prototype.createTextureAsync=function(e,t,r,i,n){return!1},t.prototype.loadShaderStringAsync=function(e,t,r,i){return!1},t.prototype.loadMaterialAsync=function(e,t,r,i){return!1},t.LoadRuntimeAsync=function(r,i,n,o,s){t.ApplyExtensions((function(e){return e.loadRuntimeAsync(r,i,n,o,s)}),(function(){setTimeout((function(){o(e.GLTFLoaderBase.CreateRuntime(i.json,r,n))}))}))},t.LoadRuntimeExtensionsAsync=function(e,r,i){t.ApplyExtensions((function(t){return t.loadRuntimeExtensionsAsync(e,r,i)}),(function(){setTimeout((function(){r()}))}))},t.LoadBufferAsync=function(r,i,n,o,s){t.ApplyExtensions((function(e){return e.loadBufferAsync(r,i,n,o,s)}),(function(){e.GLTFLoaderBase.LoadBufferAsync(r,i,n,o,s)}))},t.LoadTextureAsync=function(e,r,i,n){t.LoadTextureBufferAsync(e,r,(function(o){return t.CreateTextureAsync(e,r,o,i,n)}),n)},t.LoadShaderStringAsync=function(r,i,n,o){t.ApplyExtensions((function(e){return e.loadShaderStringAsync(r,i,n,o)}),(function(){e.GLTFLoaderBase.LoadShaderStringAsync(r,i,n,o)}))},t.LoadMaterialAsync=function(r,i,n,o){t.ApplyExtensions((function(e){return e.loadMaterialAsync(r,i,n,o)}),(function(){e.GLTFLoaderBase.LoadMaterialAsync(r,i,n,o)}))},t.LoadTextureBufferAsync=function(r,i,n,o){t.ApplyExtensions((function(e){return e.loadTextureBufferAsync(r,i,n,o)}),(function(){e.GLTFLoaderBase.LoadTextureBufferAsync(r,i,n,o)}))},t.CreateTextureAsync=function(r,i,n,o,s){t.ApplyExtensions((function(e){return e.createTextureAsync(r,i,n,o,s)}),(function(){e.GLTFLoaderBase.CreateTextureAsync(r,i,n,o,s)}))},t.ApplyExtensions=function(t,r){for(var i in e.GLTFLoader.Extensions){if(t(e.GLTFLoader.Extensions[i]))return}r()},t})();e.GLTFLoaderExtension=t})(e.GLTF1||(e.GLTF1={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(e){var t;!(function(e){e[e.JSON=0]="JSON"})(t||(t={}));var r=(function(t){function r(){return t.call(this,"KHR_binary_glTF")||this}return __extends(r,t),r.prototype.loadRuntimeAsync=function(t,r,i,n,o){var s=r.json.extensionsUsed;return!(!s||-1===s.indexOf(this.name))&&(this._bin=r.bin,n(e.GLTFLoaderBase.CreateRuntime(r.json,t,i)),!0)},r.prototype.loadBufferAsync=function(e,t,r,i){return-1!==e.extensionsUsed.indexOf(this.name)&&("binary_glTF"===t&&(r(this._bin),!0))},r.prototype.loadTextureBufferAsync=function(t,r,i,n){var o=t.textures[r],s=t.images[o.source];if(!(s.extensions&&this.name in s.extensions))return!1;var a=s.extensions[this.name],u=t.bufferViews[a.bufferView];return i(e.GLTFUtils.GetBufferFromBufferView(t,u,0,u.byteLength,e.EComponentType.UNSIGNED_BYTE)),!0},r.prototype.loadShaderStringAsync=function(t,r,i,n){var o=t.shaders[r];if(!(o.extensions&&this.name in o.extensions))return!1;var s=o.extensions[this.name],a=t.bufferViews[s.bufferView],u=e.GLTFUtils.GetBufferFromBufferView(t,a,0,a.byteLength,e.EComponentType.UNSIGNED_BYTE);return setTimeout((function(){var t=e.GLTFUtils.DecodeBufferToText(u);i(t)})),!0},r})(e.GLTFLoaderExtension);e.GLTFBinaryExtension=r;!(function(){function e(e){this._arrayBuffer=e,this._dataView=new DataView(e),this._byteOffset=0}e.prototype.getUint32=function(){var e=this._dataView.getUint32(this._byteOffset,!0);return this._byteOffset+=4,e},e.prototype.getUint8Array=function(e){e||(e=this._arrayBuffer.byteLength-this._byteOffset);var t=new Uint8Array(this._arrayBuffer,this._byteOffset,e);return this._byteOffset+=e,t}})();e.GLTFLoader.RegisterExtension(new r)})(e.GLTF1||(e.GLTF1={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(t){var r=(function(r){function i(){return r.call(this,"KHR_materials_common")||this}return __extends(i,r),i.prototype.loadRuntimeExtensionsAsync=function(t,r,i){if(!t.extensions)return!1;var n=t.extensions[this.name];if(!n)return!1;var o=n.lights;if(o)for(var s in o){var a=o[s];switch(a.type){case"ambient":var u=new e.HemisphericLight(a.name,new e.Vector3(0,1,0),t.scene),l=a.ambient;u.diffuse=e.Color3.FromArray(l.color||[1,1,1]);break;case"point":var h=new e.PointLight(a.name,new e.Vector3(10,10,10),t.scene),c=a.point;h.diffuse=e.Color3.FromArray(c.color||[1,1,1]);break;case"directional":var f=new e.DirectionalLight(a.name,new e.Vector3(0,-1,0),t.scene),d=a.directional;f.diffuse=e.Color3.FromArray(d.color||[1,1,1]);break;case"spot":var p=a.spot,g=new e.SpotLight(a.name,new e.Vector3(0,10,0),new e.Vector3(0,-1,0),a.spot.fallOffAngle||Math.PI,a.spot.fallOffExponent||0,t.scene);g.diffuse=e.Color3.FromArray(p.color||[1,1,1]);break;default:e.Tools.Warn('GLTF Material Common extension: light type "'+a.type+"” not supported")}}return!1},i.prototype.loadMaterialAsync=function(t,r,i,n){var o=t.materials[r];if(!o||!o.extensions)return!1;var s=o.extensions[this.name];if(!s)return!1;var a=new e.StandardMaterial(r,t.scene);return a.sideOrientation=e.Material.CounterClockWiseSideOrientation,"CONSTANT"===s.technique&&(a.disableLighting=!0),a.backFaceCulling=void 0!==s.doubleSided&&!s.doubleSided,a.alpha=void 0===s.values.transparency?1:s.values.transparency,a.specularPower=void 0===s.values.shininess?0:s.values.shininess,"string"==typeof s.values.ambient?this._loadTexture(t,s.values.ambient,a,"ambientTexture",n):a.ambientColor=e.Color3.FromArray(s.values.ambient||[0,0,0]),"string"==typeof s.values.diffuse?this._loadTexture(t,s.values.diffuse,a,"diffuseTexture",n):a.diffuseColor=e.Color3.FromArray(s.values.diffuse||[0,0,0]),"string"==typeof s.values.emission?this._loadTexture(t,s.values.emission,a,"emissiveTexture",n):a.emissiveColor=e.Color3.FromArray(s.values.emission||[0,0,0]),"string"==typeof s.values.specular?this._loadTexture(t,s.values.specular,a,"specularTexture",n):a.specularColor=e.Color3.FromArray(s.values.specular||[0,0,0]),!0},i.prototype._loadTexture=function(e,r,i,n,o){t.GLTFLoaderBase.LoadTextureBufferAsync(e,r,(function(s){t.GLTFLoaderBase.CreateTextureAsync(e,r,s,(function(e){return i[n]=e}),o)}),o)},i})(t.GLTFLoaderExtension);t.GLTFMaterialsCommonExtension=r,t.GLTFLoader.RegisterExtension(new r)})(e.GLTF1||(e.GLTF1={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(e){!(function(e){e[e.BYTE=5120]="BYTE",e[e.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",e[e.SHORT=5122]="SHORT",e[e.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",e[e.UNSIGNED_INT=5125]="UNSIGNED_INT",e[e.FLOAT=5126]="FLOAT"})(e.EComponentType||(e.EComponentType={}));!(function(e){e[e.POINTS=0]="POINTS",e[e.LINES=1]="LINES",e[e.LINE_LOOP=2]="LINE_LOOP",e[e.LINE_STRIP=3]="LINE_STRIP",e[e.TRIANGLES=4]="TRIANGLES",e[e.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",e[e.TRIANGLE_FAN=6]="TRIANGLE_FAN"})(e.EMeshPrimitiveMode||(e.EMeshPrimitiveMode={}));!(function(e){e[e.NEAREST=9728]="NEAREST",e[e.LINEAR=9729]="LINEAR"})(e.ETextureMagFilter||(e.ETextureMagFilter={}));!(function(e){e[e.NEAREST=9728]="NEAREST",e[e.LINEAR=9729]="LINEAR",e[e.NEAREST_MIPMAP_NEAREST=9984]="NEAREST_MIPMAP_NEAREST",e[e.LINEAR_MIPMAP_NEAREST=9985]="LINEAR_MIPMAP_NEAREST",e[e.NEAREST_MIPMAP_LINEAR=9986]="NEAREST_MIPMAP_LINEAR",e[e.LINEAR_MIPMAP_LINEAR=9987]="LINEAR_MIPMAP_LINEAR"})(e.ETextureMinFilter||(e.ETextureMinFilter={}));!(function(e){e[e.CLAMP_TO_EDGE=33071]="CLAMP_TO_EDGE",e[e.MIRRORED_REPEAT=33648]="MIRRORED_REPEAT",e[e.REPEAT=10497]="REPEAT"})(e.ETextureWrapMode||(e.ETextureWrapMode={}))})(e.GLTF2||(e.GLTF2={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(t){var r=(function(){function r(t){this._renderReady=!1,this._disposed=!1,this._objectURLs=new Array,this._blockPendingTracking=!1,this._renderReadyObservable=new e.Observable,this._renderPendingCount=0,this._loaderPendingCount=0,this._parent=t}return r.RegisterExtension=function(i){if(r.Extensions[i.name])return void e.Tools.Error("Extension with the same name '"+i.name+"' already exists");r.Extensions[i.name]=i,t.GLTFLoaderExtension._Extensions.push(i)},Object.defineProperty(r.prototype,"gltf",{get:function(){return this._gltf},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"babylonScene",{get:function(){return this._babylonScene},enumerable:!0,configurable:!0}),r.prototype.executeWhenRenderReady=function(e){this._renderReady?e():this._renderReadyObservable.add(e)},r.prototype.dispose=function(){this._disposed||(this._disposed=!0,this._objectURLs.forEach((function(e){return URL.revokeObjectURL(e)})),this._objectURLs.length=0,this._gltf=void 0,this._babylonScene=void 0,this._rootUrl=void 0,this._defaultMaterial=void 0,this._successCallback=void 0,this._errorCallback=void 0,this._renderReady=!1,this._renderReadyObservable.clear(),this._renderPendingCount=0,this._loaderPendingCount=0)},r.prototype.importMeshAsync=function(e,t,r,i,n,o,s){var a=this;this._loadAsync(e,t,r,i,(function(){n(a._getMeshes(),null,a._getSkeletons())}),o,s)},r.prototype.loadAsync=function(e,t,r,i,n,o){this._loadAsync(null,e,t,r,i,n,o)},r.prototype._loadAsync=function(e,t,r,i,n,o,s){this._loadData(r),this._babylonScene=t,this._rootUrl=i,this._successCallback=n,this._progressCallback=o,this._errorCallback=s,this.addPendingData(this),this._loadScene(e),this._loadAnimations(),this.removePendingData(this)},r.prototype._onError=function(e){this._errorCallback(e),this.dispose()},r.prototype._onProgress=function(e){this._progressCallback(e)},r.prototype._onRenderReady=function(){switch(this._parent.coordinateSystemMode){case e.GLTFLoaderCoordinateSystemMode.AUTO:this._babylonScene.useRightHandedSystem||this._addRightHandToLeftHandRootTransform();break;case e.GLTFLoaderCoordinateSystemMode.PASS_THROUGH:break;case e.GLTFLoaderCoordinateSystemMode.FORCE_RIGHT_HANDED:this._babylonScene.useRightHandedSystem=!0;break;default:e.Tools.Error("Invalid coordinate system mode ("+this._parent.coordinateSystemMode+")")}this._showMeshes(),this._startAnimations(),this._successCallback(),this._renderReadyObservable.notifyObservers(this)},r.prototype._onLoaderComplete=function(){this._parent.onComplete&&this._parent.onComplete()},r.prototype._onLoaderFirstLODComplete=function(){this._parent.onFirstLODComplete&&this._parent.onFirstLODComplete()},r.prototype._loadData=function(t){this._gltf=t.json;var r,i=this._gltf.buffers;i.length>0&&void 0===i[0].uri&&(r=i[0]),t.bin&&(r?r.byteLength!=t.bin.byteLength&&e.Tools.Warn("Binary buffer length ("+r.byteLength+") from JSON does not match chunk length ("+t.bin.byteLength+")"):e.Tools.Warn("Unexpected BIN chunk"),r.loadedData=t.bin)},r.prototype._addRightHandToLeftHandRootTransform=function(){var t=new e.Mesh("root",this._babylonScene);t.scaling=new e.Vector3(1,1,-1),t.rotation.y=Math.PI;for(var r=this._gltf.nodes,i=0;i<r.length;i++){var n=r[i].babylonMesh;n&&!n.parent&&(n.parent=t)}},r.prototype._getMeshes=function(){var e=[],t=this._gltf.nodes;return t&&t.forEach((function(t){t.babylonMesh&&e.push(t.babylonMesh)})),e},r.prototype._getSkeletons=function(){var t=[],r=this._gltf.skins;return r&&r.forEach((function(r){r.babylonSkeleton instanceof e.Skeleton&&t.push(r.babylonSkeleton)})),t},r.prototype._getAnimationTargets=function(){var e=[],t=this._gltf.animations;return t&&t.forEach((function(t){e.push.apply(e,t.targets)})),e},r.prototype._showMeshes=function(){this._getMeshes().forEach((function(e){return e.isVisible=!0}))},r.prototype._startAnimations=function(){var e=this;this._getAnimationTargets().forEach((function(t){return e._babylonScene.beginAnimation(t,0,Number.MAX_VALUE,!0)}))},r.prototype._loadScene=function(e){var t=this,r=this._gltf.scenes[this._gltf.scene||0],i=r.nodes;this._traverseNodes(i,(function(e,t,r){return e.index=t,e.parent=r,!0}));var n=this._gltf.materials;if(n&&n.forEach((function(e,t){return e.index=t})),e){e instanceof Array||(e=[e]);var o=new Array;this._traverseNodes(i,(function(t){return-1===e.indexOf(t.name)||(o.push(t.index),!1)})),i=o}this._traverseNodes(i,(function(e){return t._loadSkin(e)})),this._traverseNodes(i,(function(e){return t._loadMesh(e)}))},r.prototype._loadSkin=function(t){var r=this;if(void 0!==t.skin){var i=this._gltf.skins[t.skin],n="skeleton"+t.skin;i.babylonSkeleton=new e.Skeleton(i.name||n,n,this._babylonScene),i.index=t.skin;for(var o=0;o<i.joints.length;o++)this._createBone(this._gltf.nodes[i.joints[o]],i);if(void 0===i.skeleton)throw new Error("Not implemented");if(void 0===i.inverseBindMatrices)throw new Error("Not implemented");var s=this._gltf.accessors[i.inverseBindMatrices];this._loadAccessorAsync(s,(function(e){r._traverseNode(i.skeleton,(function(t,n,o){return r._updateBone(t,o,i,e)}))}))}return!0},r.prototype._updateBone=function(t,r,i,n){var o=i.joints.indexOf(t.index);-1===o&&this._createBone(t,i);var s=t.babylonSkinToBones[i.index],a=-1===o?e.Matrix.Identity():e.Matrix.FromArray(n,16*o);return a.invertToRef(a),r&&(s.setParent(r.babylonSkinToBones[i.index],!1),a.multiplyToRef(s.getParent().getInvertedAbsoluteTransform(),a)),s.updateMatrix(a),!0},r.prototype._createBone=function(t,r){var i=new e.Bone(t.name||"bone"+t.index,r.babylonSkeleton);return t.babylonSkinToBones=t.babylonSkinToBones||{},t.babylonSkinToBones[r.index]=i,t.babylonAnimationTargets=t.babylonAnimationTargets||[],t.babylonAnimationTargets.push(i),i},r.prototype._loadMesh=function(t){var r=new e.Mesh(t.name||"mesh"+t.index,this._babylonScene);if(r.isVisible=!1,this._loadTransform(t,r),void 0!==t.mesh){var i=this._gltf.meshes[t.mesh];this._loadMeshData(t,i,r)}if(r.parent=t.parent?t.parent.babylonMesh:null,t.babylonMesh=r,t.babylonAnimationTargets=t.babylonAnimationTargets||[],t.babylonAnimationTargets.push(t.babylonMesh),void 0!==t.skin){var n=this._gltf.skins[t.skin];r.skeleton=n.babylonSkeleton}return t.camera,!0},r.prototype._loadMeshData=function(r,i,n){var o=this;n.name=i.name||n.name;var s=new e.MultiMaterial(n.name,this._babylonScene);n.material=s;var a=new e.Geometry(n.name,this._babylonScene,null,!1,n),u=new e.VertexData;u.positions=[],u.indices=[];for(var l=[],h=0,c=i.primitives.length,f=this,d=0;d<c;d++)!(function(d){var p=i.primitives[d];if(p.mode&&p.mode!==t.EMeshPrimitiveMode.TRIANGLES)throw new Error("Not implemented");f._createMorphTargets(r,i,p,n),f._loadVertexDataAsync(p,(function(t){o._loadMorphTargetsData(i,p,t,n),l.push({materialIndex:d,verticesStart:u.positions.length,verticesCount:t.positions.length,indicesStart:u.indices.length,indicesCount:t.indices.length,loadMaterial:function(){if(void 0===p.material)s.subMaterials[d]=o._getDefaultMaterial();else{var e=o._gltf.materials[p.material];o.loadMaterial(e,(function(t,r){r&&o._parent.onMaterialLoaded&&o._parent.onMaterialLoaded(t),o._parent.onBeforeMaterialReadyAsync?(o.addLoaderPendingData(e),o._parent.onBeforeMaterialReadyAsync(t,n,null!=s.subMaterials[d],(function(){s.subMaterials[d]=t,o.removeLoaderPendingData(e)}))):s.subMaterials[d]=t}))}}}),u.merge(t),++h===c&&(a.setAllVerticesData(u,!1),l.forEach((function(e){return e.loadMaterial()})),n.subMeshes=[],l.forEach((function(t){return new e.SubMesh(t.materialIndex,t.verticesStart,t.verticesCount,t.indicesStart,t.indicesCount,n)})))}))})(d)},r.prototype._loadVertexDataAsync=function(t,r){var i=this,n=t.attributes;if(!n)return void this._onError("Primitive has no attributes");var o,s=new e.VertexData,a=0,u=Object.keys(n).length,l=this;for(var h in n)!(function(h){o=l._gltf.accessors[n[h]],l._loadAccessorAsync(o,(function(n){switch(h){case"NORMAL":s.normals=n;break;case"POSITION":s.positions=n;break;case"TANGENT":s.tangents=n;break;case"TEXCOORD_0":s.uvs=n;break;case"TEXCOORD_1":s.uvs2=n;break;case"JOINTS_0":s.matricesIndices=new Float32Array(Array.prototype.slice.apply(n));break;case"WEIGHTS_0":s.matricesWeights=n;break;case"COLOR_0":s.colors=n;break;default:e.Tools.Warn("Ignoring unrecognized semantic '"+h+"'")}if(++a===u){var o=i._gltf.accessors[t.indices];o?i._loadAccessorAsync(o,(function(e){s.indices=e,r(s)})):(s.indices=new Uint32Array(s.positions.length/3),s.indices.forEach((function(e,t){return s.indices[t]=t})),r(s))}}))})(h)},r.prototype._createMorphTargets=function(t,r,i,n){var o=i.targets;if(o){n.morphTargetManager||(n.morphTargetManager=new e.MorphTargetManager);for(var s=0;s<o.length;s++){var a=t.weights?t.weights[s]:r.weights?r.weights[s]:0;n.morphTargetManager.addTarget(new e.MorphTarget("morphTarget"+s,a))}}},r.prototype._loadMorphTargetsData=function(r,i,n,o){var s=i.targets;if(s)for(var a,u,l=this,h=0;h<s.length;h++)!(function(){var r=o.morphTargetManager.getTarget(h);a=s[h];for(var i in a)!(function(i){u=l._gltf.accessors[a[i]],l._loadAccessorAsync(u,(function(o){u.name&&(r.name=u.name);var s=o;switch(i){case"NORMAL":t.GLTFUtils.ForEach(s,(function(e,t){return s[t]+=n.normals[t]})),r.setNormals(s);break;case"POSITION":t.GLTFUtils.ForEach(s,(function(e,t){return s[t]+=n.positions[t]})),r.setPositions(s);break;case"TANGENT":for(var a=0,l=0;a<s.length;a++,l++)s[a]+=n.tangents[l],(a+1)%3==0&&l++;r.setTangents(s);break;default:e.Tools.Warn("Ignoring unrecognized semantic '"+i+"'")}}))})(i)})()},r.prototype._loadTransform=function(t,r){var i=e.Vector3.Zero(),n=e.Quaternion.Identity(),o=e.Vector3.One();if(t.matrix){e.Matrix.FromArray(t.matrix).decompose(o,n,i)}else t.translation&&(i=e.Vector3.FromArray(t.translation)),t.rotation&&(n=e.Quaternion.FromArray(t.rotation)),t.scale&&(o=e.Vector3.FromArray(t.scale));r.position=i,r.rotationQuaternion=n,r.scaling=o},r.prototype._traverseNodes=function(e,t,r){void 0===r&&(r=null);for(var i=0;i<e.length;i++)this._traverseNode(e[i],t,r)},r.prototype._traverseNode=function(e,t,r){void 0===r&&(r=null);var i=this._gltf.nodes[e];if(t(i,e,r)&&i.children)for(var n=0;n<i.children.length;n++)this._traverseNode(i.children[n],t,i)},r.prototype._loadAnimations=function(){var e=this._gltf.animations;if(e&&0!==e.length)for(var t=0;t<e.length;t++)for(var r=e[t],i=0;i<r.channels.length;i++)this._loadAnimationChannel(r,t,i)},r.prototype._loadAnimationChannel=function(t,r,i){var n=t.channels[i],o=n.sampler,s=t.samplers[o],a=this._gltf.nodes[n.target.node];if(!a)return void e.Tools.Warn("Animation channel target node ("+n.target.node+") does not exist");var u={translation:"position",rotation:"rotationQuaternion",scale:"scaling",weights:"influence"}[n.target.path];if(!u)return void e.Tools.Warn("Animation channel target path '"+n.target.path+"' is not valid");var l,h,c={position:e.Animation.ANIMATIONTYPE_VECTOR3,rotationQuaternion:e.Animation.ANIMATIONTYPE_QUATERNION,scaling:e.Animation.ANIMATIONTYPE_VECTOR3,influence:e.Animation.ANIMATIONTYPE_FLOAT}[u],f=function(){if(l&&h){for(var i=0,n={position:function(){var t=e.Vector3.FromArray(h,i);return i+=3,t},rotationQuaternion:function(){var t=e.Quaternion.FromArray(h,i);return i+=4,t},scaling:function(){var t=e.Vector3.FromArray(h,i);return i+=3,t},influence:function(){for(var e=a.babylonMesh.morphTargetManager.numTargets,t=new Array(e),r=0;r<e;r++)t[r]=h[i++];return t}}[u],o={LINEAR:function(e){return{frame:l[e],value:n()}},CUBICSPLINE:function(e){return{frame:l[e],inTangent:n(),value:n(),outTangent:n()}}}[s.interpolation],f=new Array(l.length),d=0;d<l.length;d++)f[d]=o(d);if(t.targets=t.targets||[],"influence"===u)for(var p=a.babylonMesh.morphTargetManager,g=0;g<p.numTargets;g++){var _=p.getTarget(g),m=(t.name||"anim"+r)+"_"+g,v=new e.Animation(m,u,1,c);v.setKeys(f.map((function(e){return{frame:e.frame,inTangent:e.inTangent?e.inTangent[g]:void 0,value:e.value[g],outTangent:e.outTangent?e.outTangent[g]:void 0}}))),_.animations.push(v),t.targets.push(_)}else{var m=t.name||"anim"+r,v=new e.Animation(m,u,1,c);v.setKeys(f);for(var y=0;y<a.babylonAnimationTargets.length;y++){var A=a.babylonAnimationTargets[y];A.animations.push(v.clone()),t.targets.push(A)}}}};this._loadAccessorAsync(this._gltf.accessors[s.input],(function(e){l=e,f()})),this._loadAccessorAsync(this._gltf.accessors[s.output],(function(e){h=e,f()}))},r.prototype._loadBufferAsync=function(r,i){var n=this,o=this._gltf.buffers[r];if(this.addPendingData(o),o.loadedData)setTimeout((function(){i(o.loadedData),n.removePendingData(o)}));else if(t.GLTFUtils.IsBase64(o.uri)){var s=t.GLTFUtils.DecodeBase64(o.uri);o.loadedData=new Uint8Array(s),setTimeout((function(){i(o.loadedData),n.removePendingData(o)}))}else o.loadedObservable?o.loadedObservable.add((function(e){i(e.loadedData),n.removePendingData(e)})):(o.loadedObservable=new e.Observable,o.loadedObservable.add((function(e){i(e.loadedData),n.removePendingData(e)})),e.Tools.LoadFile(this._rootUrl+o.uri,(function(e){o.loadedData=new Uint8Array(e),o.loadedObservable.notifyObservers(o),o.loadedObservable=null}),(function(e){n._disposed||n._onProgress(e)}),this._babylonScene.database,!0,(function(e){n._disposed||(n._onError("Failed to load file '"+o.uri+"': "+e.status+" "+e.statusText),n.removePendingData(o))})))},r.prototype._loadBufferViewAsync=function(e,r,i,n,o){var s=this;r+=e.byteOffset||0,this._loadBufferAsync(e.buffer,(function(e){if(r+i>e.byteLength)return void s._onError("Buffer access is out of range");var a=e.buffer;r+=e.byteOffset;var u;switch(n){case t.EComponentType.BYTE:u=new Int8Array(a,r,i);break;case t.EComponentType.UNSIGNED_BYTE:u=new Uint8Array(a,r,i);break;case t.EComponentType.SHORT:u=new Int16Array(a,r,i);break;case t.EComponentType.UNSIGNED_SHORT:u=new Uint16Array(a,r,i);break;case t.EComponentType.UNSIGNED_INT:u=new Uint32Array(a,r,i);break;case t.EComponentType.FLOAT:u=new Float32Array(a,r,i);break;default:return void s._onError("Invalid component type ("+n+")")}o(u)}))},r.prototype._loadAccessorAsync=function(e,t){var r=this._gltf.bufferViews[e.bufferView],i=e.byteOffset||0,n=e.count*this._getByteStrideFromType(e);this._loadBufferViewAsync(r,i,n,e.componentType,t)},r.prototype._getByteStrideFromType=function(e){switch(e.type){case"SCALAR":return 1;case"VEC2":return 2;case"VEC3":return 3;case"VEC4":case"MAT2":return 4;case"MAT3":return 9;case"MAT4":return 16;default:return this._onError("Invalid accessor type ("+e.type+")"),0}},Object.defineProperty(r.prototype,"blockPendingTracking",{set:function(e){this._blockPendingTracking=e},enumerable:!0,configurable:!0}),r.prototype.addPendingData=function(e){this._renderReady||this._renderPendingCount++,this.addLoaderPendingData(e)},r.prototype.removePendingData=function(e){this._renderReady||0==--this._renderPendingCount&&(this._renderReady=!0,this._onRenderReady()),this.removeLoaderPendingData(e)},r.prototype.addLoaderNonBlockingPendingData=function(e){this._nonBlockingData||(this._nonBlockingData=new Array),this._nonBlockingData.push(e)},r.prototype.addLoaderPendingData=function(e){if(this._blockPendingTracking)return void this.addLoaderNonBlockingPendingData(e);this._loaderPendingCount++},r.prototype.removeLoaderPendingData=function(e){var t=this._nonBlockingData?this._nonBlockingData.indexOf(e):-1;-1!==t?this._nonBlockingData.splice(t,1):0==--this._loaderPendingCount&&this._onLoaderFirstLODComplete(),this._nonBlockingData&&0!==this._nonBlockingData.length||0!==this._loaderPendingCount||(this._onLoaderComplete(),this.dispose())},r.prototype._getDefaultMaterial=function(){if(!this._defaultMaterial){var t="__gltf_default",r=this._babylonScene.getMaterialByName(t);r||(r=new e.PBRMaterial(t,this._babylonScene),r.sideOrientation=e.Material.CounterClockWiseSideOrientation,r.metallic=1,r.roughness=1),this._defaultMaterial=r}return this._defaultMaterial},r.prototype._loadMaterialMetallicRoughnessProperties=function(t){var r=t.babylonMaterial;r.metallic=1,r.roughness=1;var i=t.pbrMetallicRoughness;i&&(r.albedoColor=i.baseColorFactor?e.Color3.FromArray(i.baseColorFactor):new e.Color3(1,1,1),r.metallic=void 0===i.metallicFactor?1:i.metallicFactor,r.roughness=void 0===i.roughnessFactor?1:i.roughnessFactor,i.baseColorTexture&&(r.albedoTexture=this.loadTexture(i.baseColorTexture)),i.metallicRoughnessTexture&&(r.metallicTexture=this.loadTexture(i.metallicRoughnessTexture),r.useMetallnessFromMetallicTextureBlue=!0,r.useRoughnessFromMetallicTextureGreen=!0,r.useRoughnessFromMetallicTextureAlpha=!1),this.loadMaterialAlphaProperties(t,i.baseColorFactor))},r.prototype.loadMaterial=function(e,r){if(e.babylonMaterial)return void r(e.babylonMaterial,!1);t.GLTFLoaderExtension.LoadMaterial(this,e,r)||(this.createPbrMaterial(e),this.loadMaterialBaseProperties(e),this._loadMaterialMetallicRoughnessProperties(e),r(e.babylonMaterial,!0))},r.prototype.createPbrMaterial=function(t){var r=new e.PBRMaterial(t.name||"mat"+t.index,this._babylonScene);r.sideOrientation=e.Material.CounterClockWiseSideOrientation,t.babylonMaterial=r},r.prototype.loadMaterialBaseProperties=function(t){var r=t.babylonMaterial;r.emissiveColor=t.emissiveFactor?e.Color3.FromArray(t.emissiveFactor):new e.Color3(0,0,0),t.doubleSided&&(r.backFaceCulling=!1,r.twoSidedLighting=!0),t.normalTexture&&(r.bumpTexture=this.loadTexture(t.normalTexture),r.invertNormalMapX=!0,r.invertNormalMapY=!0,void 0!==t.normalTexture.scale&&(r.bumpTexture.level=t.normalTexture.scale)),t.occlusionTexture&&(r.ambientTexture=this.loadTexture(t.occlusionTexture),r.useAmbientInGrayScale=!0,void 0!==t.occlusionTexture.strength&&(r.ambientTextureStrength=t.occlusionTexture.strength)),t.emissiveTexture&&(r.emissiveTexture=this.loadTexture(t.emissiveTexture))},r.prototype.loadMaterialAlphaProperties=function(t,r){var i=t.babylonMaterial,n=t.alphaMode||"OPAQUE";switch(n){case"OPAQUE":break;case"MASK":case"BLEND":r&&(i.alpha=r[3]),i.albedoTexture&&(i.albedoTexture.hasAlpha=!0,i.useAlphaFromAlbedoTexture="BLEND"===n);break;default:e.Tools.Warn("Invalid alpha mode '"+t.alphaMode+"'")}},r.prototype.loadTexture=function(r){var i=this,n=this._gltf.textures[r.index],o=r.texCoord||0;if(!n||void 0===n.source)return null;var s;if(n.babylonTextures){if(!(s=n.babylonTextures[o]))for(var a=0;a<n.babylonTextures.length;a++)if(s=n.babylonTextures[a]){s=s.clone(),s.coordinatesIndex=o;break}return s}var u=this._gltf.images[n.source],l=void 0===n.sampler?{}:this._gltf.samplers[n.sampler],h=l.minFilter===t.ETextureMinFilter.NEAREST||l.minFilter===t.ETextureMinFilter.LINEAR,c=t.GLTFUtils.GetTextureSamplingMode(l.magFilter,l.minFilter);this.addPendingData(n),s=new e.Texture(null,this._babylonScene,h,!1,c,function(){i._disposed||i.removePendingData(n)},function(){i._disposed||(i._onError("Failed to load texture '"+u.uri+"'"),i.removePendingData(n))});var f=function(e){var t=URL.createObjectURL(new Blob([e],{type:u.mimeType}));i._objectURLs.push(t),s.updateURL(t)};if(u.uri)t.GLTFUtils.IsBase64(u.uri)?f(new Uint8Array(t.GLTFUtils.DecodeBase64(u.uri))):e.Tools.LoadFile(this._rootUrl+u.uri,f,(function(e){i._disposed||i._onProgress(e)}),this._babylonScene.database,!0,(function(e){i._onError("Failed to load file '"+u.uri+"': "+e.status+" "+e.statusText)}));else{var d=this._gltf.bufferViews[u.bufferView];this._loadBufferViewAsync(d,0,d.byteLength,t.EComponentType.UNSIGNED_BYTE,f)}return s.coordinatesIndex=o,s.wrapU=t.GLTFUtils.GetTextureWrapMode(l.wrapS),s.wrapV=t.GLTFUtils.GetTextureWrapMode(l.wrapT),s.name=n.name||"texture"+r.index,n.babylonTextures=n.babylonTextures||[],n.babylonTextures[o]=s,this._parent.onTextureLoaded&&this._parent.onTextureLoaded(s),s},r.Extensions={},r})();t.GLTFLoader=r,e.GLTFFileLoader.CreateGLTFLoaderV2=function(e){return new r(e)}})(e.GLTF2||(e.GLTF2={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(t){var r=(function(){function r(){}return r.IsBase64=function(e){return!(e.length<5)&&"data:"===e.substr(0,5)},r.DecodeBase64=function(e){for(var t=atob(e.split(",")[1]),r=t.length,i=new Uint8Array(new ArrayBuffer(r)),n=0;n<r;n++)i[n]=t.charCodeAt(n);return i.buffer},r.ForEach=function(e,t){for(var r=0;r<e.length;r++)t(e[r],r)},r.GetTextureWrapMode=function(r){switch(r=void 0===r?t.ETextureWrapMode.REPEAT:r){case t.ETextureWrapMode.CLAMP_TO_EDGE:e.Texture.CLAMP_ADDRESSMODE;case t.ETextureWrapMode.MIRRORED_REPEAT:return e.Texture.MIRROR_ADDRESSMODE;case t.ETextureWrapMode.REPEAT:return e.Texture.WRAP_ADDRESSMODE;default:return e.Tools.Warn("Invalid texture wrap mode ("+r+")"),e.Texture.WRAP_ADDRESSMODE}},r.GetTextureSamplingMode=function(r,i){if(r=void 0===r?t.ETextureMagFilter.LINEAR:r,i=void 0===i?t.ETextureMinFilter.LINEAR_MIPMAP_NEAREST:i,r===t.ETextureMagFilter.LINEAR)switch(i){case t.ETextureMinFilter.NEAREST:return e.Texture.LINEAR_NEAREST;case t.ETextureMinFilter.LINEAR:return e.Texture.LINEAR_LINEAR;case t.ETextureMinFilter.NEAREST_MIPMAP_NEAREST:return e.Texture.LINEAR_NEAREST_MIPNEAREST;case t.ETextureMinFilter.LINEAR_MIPMAP_NEAREST:return e.Texture.LINEAR_LINEAR_MIPNEAREST;case t.ETextureMinFilter.NEAREST_MIPMAP_LINEAR:return e.Texture.LINEAR_NEAREST_MIPLINEAR;case t.ETextureMinFilter.LINEAR_MIPMAP_LINEAR:return e.Texture.LINEAR_LINEAR_MIPLINEAR;default:
- return e.Tools.Warn("Invalid texture minification filter ("+i+")"),e.Texture.LINEAR_LINEAR_MIPLINEAR}else switch(r!==t.ETextureMagFilter.NEAREST&&e.Tools.Warn("Invalid texture magnification filter ("+r+")"),i){case t.ETextureMinFilter.NEAREST:return e.Texture.NEAREST_NEAREST;case t.ETextureMinFilter.LINEAR:return e.Texture.NEAREST_LINEAR;case t.ETextureMinFilter.NEAREST_MIPMAP_NEAREST:return e.Texture.NEAREST_NEAREST_MIPNEAREST;case t.ETextureMinFilter.LINEAR_MIPMAP_NEAREST:return e.Texture.NEAREST_LINEAR_MIPNEAREST;case t.ETextureMinFilter.NEAREST_MIPMAP_LINEAR:return e.Texture.NEAREST_NEAREST_MIPLINEAR;case t.ETextureMinFilter.LINEAR_MIPMAP_LINEAR:return e.Texture.NEAREST_LINEAR_MIPLINEAR;default:return e.Tools.Warn("Invalid texture minification filter ("+i+")"),e.Texture.NEAREST_NEAREST_MIPNEAREST}},r.DecodeBufferToText=function(e){for(var t="",r=e.byteLength,i=0;i<r;++i)t+=String.fromCharCode(e[i]);return t},r})();t.GLTFUtils=r})(e.GLTF2||(e.GLTF2={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(e){var t=(function(){function e(){this.enabled=!0}return e.prototype.loadMaterial=function(e,t,r){return!1},e.LoadMaterial=function(e,t,r){return this._ApplyExtensions((function(i){return i.loadMaterial(e,t,r)}))},e._ApplyExtensions=function(t){var r=e._Extensions;if(r){for(var i=0;i<r.length;i++){var n=r[i];if(n.enabled&&t(n))return!0}return!1}},e._Extensions=[],e})();e.GLTFLoaderExtension=t})(e.GLTF2||(e.GLTF2={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(t){!(function(r){var i=(function(t){function r(){return null!==t&&t.apply(this,arguments)||this}return __extends(r,t),Object.defineProperty(r.prototype,"name",{get:function(){return"MSFT_lod"},enumerable:!0,configurable:!0}),r.prototype.loadMaterial=function(e,t,r){if(!t.extensions)return!1;var i=t.extensions[this.name];if(!i)return!1;t.extensions[this.name]=void 0;var n=[t.index].concat(i.ids);e.addLoaderPendingData(t);for(var o=0;o<n.length;o++)e.addLoaderNonBlockingPendingData(o);return this.loadMaterialLOD(e,t,n,n.length-1,r),!0},r.prototype.loadMaterialLOD=function(t,i,n,o,s){var a=this,u=t.gltf.materials[n[o]];o!==n.length-1&&(t.blockPendingTracking=!0),t.loadMaterial(u,(function(u,l){if(s(u,l),t.removeLoaderPendingData(o),o===n.length-1&&t.removeLoaderPendingData(i),0===o)return void(t.blockPendingTracking=!1);t.executeWhenRenderReady((function(){e.BaseTexture.WhenAllReady(u.getActiveTextures(),(function(){setTimeout((function(){a.loadMaterialLOD(t,i,n,o-1,s)}),r.MinimalLODDelay)}))}))}))},r.MinimalLODDelay=250,r})(t.GLTFLoaderExtension);r.MSFTLOD=i,t.GLTFLoader.RegisterExtension(new i)})(t.Extensions||(t.Extensions={}))})(e.GLTF2||(e.GLTF2={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(t){!(function(r){var i=(function(t){function r(){return null!==t&&t.apply(this,arguments)||this}return __extends(r,t),Object.defineProperty(r.prototype,"name",{get:function(){return"KHR_materials_pbrSpecularGlossiness"},enumerable:!0,configurable:!0}),r.prototype.loadMaterial=function(e,t,r){if(!t.extensions)return!1;var i=t.extensions[this.name];return!!i&&(e.createPbrMaterial(t),e.loadMaterialBaseProperties(t),this._loadSpecularGlossinessProperties(e,t,i),r(t.babylonMaterial,!0),!0)},r.prototype._loadSpecularGlossinessProperties=function(t,r,i){var n=r.babylonMaterial;n.albedoColor=i.diffuseFactor?e.Color3.FromArray(i.diffuseFactor):new e.Color3(1,1,1),n.reflectivityColor=i.specularFactor?e.Color3.FromArray(i.specularFactor):new e.Color3(1,1,1),n.microSurface=void 0===i.glossinessFactor?1:i.glossinessFactor,i.diffuseTexture&&(n.albedoTexture=t.loadTexture(i.diffuseTexture),t.loadMaterialAlphaProperties(r)),i.specularGlossinessTexture&&(n.reflectivityTexture=t.loadTexture(i.specularGlossinessTexture),n.reflectivityTexture.hasAlpha=!0,n.useMicroSurfaceFromReflectivityMapAlpha=!0),t.loadMaterialAlphaProperties(r,i.diffuseFactor)},r})(t.GLTFLoaderExtension);r.KHRMaterialsPbrSpecularGlossiness=i,t.GLTFLoader.RegisterExtension(new i)})(t.Extensions||(t.Extensions={}))})(e.GLTF2||(e.GLTF2={}))})(BABYLON||(BABYLON={})),("undefined"!=typeof window&&window.module||"undefined"!=typeof module)&&void 0!==module.exports&&(module.exports=BABYLON);
|