1234567891011121314151617181920212223242526272829 |
- 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 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})();e.MathTools=t;var r=(function(){function e(){}return e.Lerp=function(e,t,r){return e+(t-e)*r},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})();e.Scalar=r;var i=(function(){function r(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 r.prototype.toString=function(){return"{R: "+this.r+" G:"+this.g+" B:"+this.b+"}"},r.prototype.getClassName=function(){return"Color3"},r.prototype.getHashCode=function(){var e=this.r||0;return e=397*e^(this.g||0),e=397*e^(this.b||0)},r.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},r.prototype.toColor4=function(e){return void 0===e&&(e=1),new n(this.r,this.g,this.b,e)},r.prototype.asArray=function(){var e=[];return this.toArray(e,0),e},r.prototype.toLuminance=function(){return.3*this.r+.59*this.g+.11*this.b},r.prototype.multiply=function(e){return new r(this.r*e.r,this.g*e.g,this.b*e.b)},r.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},r.prototype.equals=function(e){return e&&this.r===e.r&&this.g===e.g&&this.b===e.b},r.prototype.equalsFloats=function(e,t,r){return this.r===e&&this.g===t&&this.b===r},r.prototype.scale=function(e){return new r(this.r*e,this.g*e,this.b*e)},r.prototype.scaleToRef=function(e,t){return t.r=this.r*e,t.g=this.g*e,t.b=this.b*e,this},r.prototype.add=function(e){return new r(this.r+e.r,this.g+e.g,this.b+e.b)},r.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},r.prototype.subtract=function(e){return new r(this.r-e.r,this.g-e.g,this.b-e.b)},r.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},r.prototype.clone=function(){return new r(this.r,this.g,this.b)},r.prototype.copyFrom=function(e){return this.r=e.r,this.g=e.g,this.b=e.b,this},r.prototype.copyFromFloats=function(e,t,r){return this.r=e,this.g=t,this.b=r,this},r.prototype.set=function(e,t,r){return this.copyFromFloats(e,t,r)},r.prototype.toHexString=function(){var e=255*this.r|0,r=255*this.g|0,i=255*this.b|0;return"#"+t.ToHex(e)+t.ToHex(r)+t.ToHex(i)},r.prototype.toLinearSpace=function(){var e=new r;return this.toLinearSpaceToRef(e),e},r.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},r.prototype.toGammaSpace=function(){var e=new r;return this.toGammaSpaceToRef(e),e},r.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},r.FromHexString=function(e){if("#"!==e.substring(0,1)||7!==e.length)return new r(0,0,0);var t=parseInt(e.substring(1,3),16),i=parseInt(e.substring(3,5),16),n=parseInt(e.substring(5,7),16);return r.FromInts(t,i,n)},r.FromArray=function(e,t){return void 0===t&&(t=0),new r(e[t],e[t+1],e[t+2])},r.FromInts=function(e,t,i){return new r(e/255,t/255,i/255)},r.Lerp=function(e,t,i){return new r(e.r+(t.r-e.r)*i,e.g+(t.g-e.g)*i,e.b+(t.b-e.b)*i)},r.Red=function(){return new r(1,0,0)},r.Green=function(){return new r(0,1,0)},r.Blue=function(){return new r(0,0,1)},r.Black=function(){return new r(0,0,0)},r.White=function(){return new r(1,1,1)},r.Purple=function(){return new r(.5,0,.5)},r.Magenta=function(){return new r(1,0,1)},r.Yellow=function(){return new r(1,1,0)},r.Gray=function(){return new r(.5,.5,.5)},r.Random=function(){return new r(Math.random(),Math.random(),Math.random())},r})();e.Color3=i;var n=(function(){function e(e,t,r,i){this.r=e,this.g=t,this.b=r,this.a=i}return e.prototype.addInPlace=function(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this.a+=e.a,this},e.prototype.asArray=function(){var e=[];return this.toArray(e,0),e},e.prototype.toArray=function(e,t){return void 0===t&&(t=0),e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e[t+3]=this.a,this},e.prototype.add=function(t){return new e(this.r+t.r,this.g+t.g,this.b+t.b,this.a+t.a)},e.prototype.subtract=function(t){return new e(this.r-t.r,this.g-t.g,this.b-t.b,this.a-t.a)},e.prototype.subtractToRef=function(e,t){return t.r=this.r-e.r,t.g=this.g-e.g,t.b=this.b-e.b,t.a=this.a-e.a,this},e.prototype.scale=function(t){return new e(this.r*t,this.g*t,this.b*t,this.a*t)},e.prototype.scaleToRef=function(e,t){return t.r=this.r*e,t.g=this.g*e,t.b=this.b*e,t.a=this.a*e,this},e.prototype.multiply=function(t){return new e(this.r*t.r,this.g*t.g,this.b*t.b,this.a*t.a)},e.prototype.multiplyToRef=function(e,t){return t.r=this.r*e.r,t.g=this.g*e.g,t.b=this.b*e.b,t.a=this.a*e.a,t},e.prototype.toString=function(){return"{R: "+this.r+" G:"+this.g+" B:"+this.b+" A:"+this.a+"}"},e.prototype.getClassName=function(){return"Color4"},e.prototype.getHashCode=function(){var e=this.r||0;return e=397*e^(this.g||0),e=397*e^(this.b||0),e=397*e^(this.a||0)},e.prototype.clone=function(){return new e(this.r,this.g,this.b,this.a)},e.prototype.copyFrom=function(e){return this.r=e.r,this.g=e.g,this.b=e.b,this.a=e.a,this},e.prototype.copyFromFloats=function(e,t,r,i){return this.r=e,this.g=t,this.b=r,this.a=i,this},e.prototype.set=function(e,t,r,i){return this.copyFromFloats(e,t,r,i)},e.prototype.toHexString=function(){var e=255*this.r|0,r=255*this.g|0,i=255*this.b|0,n=255*this.a|0;return"#"+t.ToHex(e)+t.ToHex(r)+t.ToHex(i)+t.ToHex(n)},e.FromHexString=function(t){if("#"!==t.substring(0,1)||9!==t.length)return new e(0,0,0,0);var r=parseInt(t.substring(1,3),16),i=parseInt(t.substring(3,5),16),n=parseInt(t.substring(5,7),16),o=parseInt(t.substring(7,9),16);return e.FromInts(r,i,n,o)},e.Lerp=function(t,r,i){var n=new e(0,0,0,0);return e.LerpToRef(t,r,i,n),n},e.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},e.FromArray=function(t,r){return void 0===r&&(r=0),new e(t[r],t[r+1],t[r+2],t[r+3])},e.FromInts=function(t,r,i,n){return new e(t/255,r/255,i/255,n/255)},e.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},e})();e.Color4=n;var o=(function(){function r(e,t){this.x=e,this.y=t}return r.prototype.toString=function(){return"{X: "+this.x+" Y:"+this.y+"}"},r.prototype.getClassName=function(){return"Vector2"},r.prototype.getHashCode=function(){var e=this.x||0;return e=397*e^(this.y||0)},r.prototype.toArray=function(e,t){return void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,this},r.prototype.asArray=function(){var e=[];return this.toArray(e,0),e},r.prototype.copyFrom=function(e){return this.x=e.x,this.y=e.y,this},r.prototype.copyFromFloats=function(e,t){return this.x=e,this.y=t,this},r.prototype.set=function(e,t){return this.copyFromFloats(e,t)},r.prototype.add=function(e){return new r(this.x+e.x,this.y+e.y)},r.prototype.addToRef=function(e,t){return t.x=this.x+e.x,t.y=this.y+e.y,this},r.prototype.addInPlace=function(e){return this.x+=e.x,this.y+=e.y,this},r.prototype.addVector3=function(e){return new r(this.x+e.x,this.y+e.y)},r.prototype.subtract=function(e){return new r(this.x-e.x,this.y-e.y)},r.prototype.subtractToRef=function(e,t){return t.x=this.x-e.x,t.y=this.y-e.y,this},r.prototype.subtractInPlace=function(e){return this.x-=e.x,this.y-=e.y,this},r.prototype.multiplyInPlace=function(e){return this.x*=e.x,this.y*=e.y,this},r.prototype.multiply=function(e){return new r(this.x*e.x,this.y*e.y)},r.prototype.multiplyToRef=function(e,t){return t.x=this.x*e.x,t.y=this.y*e.y,this},r.prototype.multiplyByFloats=function(e,t){return new r(this.x*e,this.y*t)},r.prototype.divide=function(e){return new r(this.x/e.x,this.y/e.y)},r.prototype.divideToRef=function(e,t){return t.x=this.x/e.x,t.y=this.y/e.y,this},r.prototype.negate=function(){return new r(-this.x,-this.y)},r.prototype.scaleInPlace=function(e){return this.x*=e,this.y*=e,this},r.prototype.scale=function(e){return new r(this.x*e,this.y*e)},r.prototype.equals=function(e){return e&&this.x===e.x&&this.y===e.y},r.prototype.equalsWithEpsilon=function(r,i){return void 0===i&&(i=e.Epsilon),r&&t.WithinEpsilon(this.x,r.x,i)&&t.WithinEpsilon(this.y,r.y,i)},r.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y)},r.prototype.lengthSquared=function(){return this.x*this.x+this.y*this.y},r.prototype.normalize=function(){var e=this.length();if(0===e)return this;var t=1/e;return this.x*=t,this.y*=t,this},r.prototype.clone=function(){return new r(this.x,this.y)},r.Zero=function(){return new r(0,0)},r.One=function(){return new r(1,1)},r.FromArray=function(e,t){return void 0===t&&(t=0),new r(e[t],e[t+1])},r.FromArrayToRef=function(e,t,r){r.x=e[t],r.y=e[t+1]},r.CatmullRom=function(e,t,i,n,o){var s=o*o,a=o*s;return new r(.5*(2*t.x+(-e.x+i.x)*o+(2*e.x-5*t.x+4*i.x-n.x)*s+(-e.x+3*t.x-3*i.x+n.x)*a),.5*(2*t.y+(-e.y+i.y)*o+(2*e.y-5*t.y+4*i.y-n.y)*s+(-e.y+3*t.y-3*i.y+n.y)*a))},r.Clamp=function(e,t,i){var n=e.x;n=n>i.x?i.x:n,n=n<t.x?t.x:n;var o=e.y;return o=o>i.y?i.y:o,o=o<t.y?t.y:o,new r(n,o)},r.Hermite=function(e,t,i,n,o){var s=o*o,a=o*s,u=2*a-3*s+1,h=-2*a+3*s,l=a-2*s+o,c=a-s;return new r(e.x*u+i.x*h+t.x*l+n.x*c,e.y*u+i.y*h+t.y*l+n.y*c)},r.Lerp=function(e,t,i){return new r(e.x+(t.x-e.x)*i,e.y+(t.y-e.y)*i)},r.Dot=function(e,t){return e.x*t.x+e.y*t.y},r.Normalize=function(e){var t=e.clone();return t.normalize(),t},r.Minimize=function(e,t){return new r(e.x<t.x?e.x:t.x,e.y<t.y?e.y:t.y)},r.Maximize=function(e,t){return new r(e.x>t.x?e.x:t.x,e.y>t.y?e.y:t.y)},r.Transform=function(e,t){var i=r.Zero();return r.TransformToRef(e,t,i),i},r.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},r.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},r.Distance=function(e,t){return Math.sqrt(r.DistanceSquared(e,t))},r.DistanceSquared=function(e,t){var r=e.x-t.x,i=e.y-t.y;return r*r+i*i},r.Center=function(e,t){var r=e.add(t);return r.scaleInPlace(.5),r},r.DistanceOfPointFromSegment=function(e,t,i){var n=r.DistanceSquared(t,i);if(0===n)return r.Distance(e,t);var o=i.subtract(t),s=Math.max(0,Math.min(1,r.Dot(e.subtract(t),o)/n)),a=t.add(o.multiplyByFloats(s,s));return r.Distance(e,a)},r})();e.Vector2=o;var s=(function(){function r(e,t,r){this.x=e,this.y=t,this.z=r}return r.prototype.toString=function(){return"{X: "+this.x+" Y:"+this.y+" Z:"+this.z+"}"},r.prototype.getClassName=function(){return"Vector3"},r.prototype.getHashCode=function(){var e=this.x||0;return e=397*e^(this.y||0),e=397*e^(this.z||0)},r.prototype.asArray=function(){var e=[];return this.toArray(e,0),e},r.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},r.prototype.toQuaternion=function(){var e=new h(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},r.prototype.addInPlace=function(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this},r.prototype.add=function(e){return new r(this.x+e.x,this.y+e.y,this.z+e.z)},r.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},r.prototype.subtractInPlace=function(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this},r.prototype.subtract=function(e){return new r(this.x-e.x,this.y-e.y,this.z-e.z)},r.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},r.prototype.subtractFromFloats=function(e,t,i){return new r(this.x-e,this.y-t,this.z-i)},r.prototype.subtractFromFloatsToRef=function(e,t,r,i){return i.x=this.x-e,i.y=this.y-t,i.z=this.z-r,this},r.prototype.negate=function(){return new r(-this.x,-this.y,-this.z)},r.prototype.scaleInPlace=function(e){return this.x*=e,this.y*=e,this.z*=e,this},r.prototype.scale=function(e){return new r(this.x*e,this.y*e,this.z*e)},r.prototype.scaleToRef=function(e,t){return t.x=this.x*e,t.y=this.y*e,t.z=this.z*e,this},r.prototype.equals=function(e){return e&&this.x===e.x&&this.y===e.y&&this.z===e.z},r.prototype.equalsWithEpsilon=function(r,i){return void 0===i&&(i=e.Epsilon),r&&t.WithinEpsilon(this.x,r.x,i)&&t.WithinEpsilon(this.y,r.y,i)&&t.WithinEpsilon(this.z,r.z,i)},r.prototype.equalsToFloats=function(e,t,r){return this.x===e&&this.y===t&&this.z===r},r.prototype.multiplyInPlace=function(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this},r.prototype.multiply=function(e){return new r(this.x*e.x,this.y*e.y,this.z*e.z)},r.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},r.prototype.multiplyByFloats=function(e,t,i){return new r(this.x*e,this.y*t,this.z*i)},r.prototype.divide=function(e){return new r(this.x/e.x,this.y/e.y,this.z/e.z)},r.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},r.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},r.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},r.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},r.prototype.lengthSquared=function(){return this.x*this.x+this.y*this.y+this.z*this.z},r.prototype.normalize=function(){var 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},r.prototype.clone=function(){return new r(this.x,this.y,this.z)},r.prototype.copyFrom=function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this},r.prototype.copyFromFloats=function(e,t,r){return this.x=e,this.y=t,this.z=r,this},r.prototype.set=function(e,t,r){return this.copyFromFloats(e,t,r)},r.GetClipFactor=function(e,t,i,n){var o=r.Dot(e,i)-n;return o/(o-(r.Dot(t,i)-n))},r.FromArray=function(e,t){return t||(t=0),new r(e[t],e[t+1],e[t+2])},r.FromFloatArray=function(e,t){return r.FromArray(e,t)},r.FromArrayToRef=function(e,t,r){r.x=e[t],r.y=e[t+1],r.z=e[t+2]},r.FromFloatArrayToRef=function(e,t,i){return r.FromArrayToRef(e,t,i)},r.FromFloatsToRef=function(e,t,r,i){i.x=e,i.y=t,i.z=r},r.Zero=function(){return new r(0,0,0)},r.One=function(){return new r(1,1,1)},r.Up=function(){return new r(0,1,0)},r.Forward=function(){return new r(0,0,1)},r.Right=function(){return new r(1,0,0)},r.Left=function(){return new r(-1,0,0)},r.TransformCoordinates=function(e,t){var i=r.Zero();return r.TransformCoordinatesToRef(e,t,i),i},r.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},r.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},r.TransformNormal=function(e,t){var i=r.Zero();return r.TransformNormalToRef(e,t,i),i},r.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.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]},r.CatmullRom=function(e,t,i,n,o){var s=o*o,a=o*s;return new r(.5*(2*t.x+(-e.x+i.x)*o+(2*e.x-5*t.x+4*i.x-n.x)*s+(-e.x+3*t.x-3*i.x+n.x)*a),.5*(2*t.y+(-e.y+i.y)*o+(2*e.y-5*t.y+4*i.y-n.y)*s+(-e.y+3*t.y-3*i.y+n.y)*a),.5*(2*t.z+(-e.z+i.z)*o+(2*e.z-5*t.z+4*i.z-n.z)*s+(-e.z+3*t.z-3*i.z+n.z)*a))},r.Clamp=function(e,t,i){var n=e.x;n=n>i.x?i.x:n,n=n<t.x?t.x:n;var o=e.y;o=o>i.y?i.y:o,o=o<t.y?t.y:o;var s=e.z;return s=s>i.z?i.z:s,s=s<t.z?t.z:s,new r(n,o,s)},r.Hermite=function(e,t,i,n,o){var s=o*o,a=o*s,u=2*a-3*s+1,h=-2*a+3*s,l=a-2*s+o,c=a-s;return new r(e.x*u+i.x*h+t.x*l+n.x*c,e.y*u+i.y*h+t.y*l+n.y*c,e.z*u+i.z*h+t.z*l+n.z*c)},r.Lerp=function(e,t,i){var n=new r(0,0,0);return r.LerpToRef(e,t,i,n),n},r.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},r.Dot=function(e,t){return e.x*t.x+e.y*t.y+e.z*t.z},r.Cross=function(e,t){var i=r.Zero();return r.CrossToRef(e,t,i),i},r.CrossToRef=function(e,t,r){R.Vector3[0].x=e.y*t.z-e.z*t.y,R.Vector3[0].y=e.z*t.x-e.x*t.z,R.Vector3[0].z=e.x*t.y-e.y*t.x,r.copyFrom(R.Vector3[0])},r.Normalize=function(e){var t=r.Zero();return r.NormalizeToRef(e,t),t},r.NormalizeToRef=function(e,t){t.copyFrom(e),t.normalize()},r.Project=function(e,t,i,n){var o=n.width,s=n.height,a=n.x,u=n.y,h=r._viewportMatrixCache?r._viewportMatrixCache:r._viewportMatrixCache=new l;l.FromValuesToRef(o/2,0,0,0,0,-s/2,0,0,0,0,.5,0,a+o/2,s/2+u,.5,1,h);var c=r._matrixCache?r._matrixCache:r._matrixCache=new l;return t.multiplyToRef(i,c),c.multiplyToRef(h,c),r.TransformCoordinates(e,c)},r.UnprojectFromTransform=function(e,i,n,o,s){var a=r._matrixCache?r._matrixCache:r._matrixCache=new l;o.multiplyToRef(s,a),a.invert(),e.x=e.x/i*2-1,e.y=-(e.y/n*2-1);var u=r.TransformCoordinates(e,a),h=e.x*a.m[3]+e.y*a.m[7]+e.z*a.m[11]+a.m[15];return t.WithinEpsilon(h,1)&&(u=u.scale(1/h)),u},r.Unproject=function(e,i,n,o,s,a){var u=r._matrixCache?r._matrixCache:r._matrixCache=new l;o.multiplyToRef(s,u),u.multiplyToRef(a,u),u.invert();var h=new r(e.x/i*2-1,-(e.y/n*2-1),2*e.z-1),c=r.TransformCoordinates(h,u),f=h.x*u.m[3]+h.y*u.m[7]+h.z*u.m[11]+u.m[15];return t.WithinEpsilon(f,1)&&(c=c.scale(1/f)),c},r.Minimize=function(e,t){var r=e.clone();return r.MinimizeInPlace(t),r},r.Maximize=function(e,t){var r=e.clone();return r.MaximizeInPlace(t),r},r.Distance=function(e,t){return Math.sqrt(r.DistanceSquared(e,t))},r.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},r.Center=function(e,t){var r=e.add(t);return r.scaleInPlace(.5),r},r.RotationFromAxis=function(e,t,i){var n=r.Zero();return r.RotationFromAxisToRef(e,t,i,n),n},r.RotationFromAxisToRef=function(e,t,r,i){var n=R.Quaternion[0];h.RotationQuaternionFromAxisToRef(e,t,r,n),n.toEulerAnglesToRef(i)},r})();e.Vector3=s;var a=(function(){function r(e,t,r,i){this.x=e,this.y=t,this.z=r,this.w=i}return r.prototype.toString=function(){return"{X: "+this.x+" Y:"+this.y+" Z:"+this.z+" W:"+this.w+"}"},r.prototype.getClassName=function(){return"Vector4"},r.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)},r.prototype.asArray=function(){var e=[];return this.toArray(e,0),e},r.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},r.prototype.addInPlace=function(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this},r.prototype.add=function(e){return new r(this.x+e.x,this.y+e.y,this.z+e.z,this.w+e.w)},r.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},r.prototype.subtractInPlace=function(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this},r.prototype.subtract=function(e){return new r(this.x-e.x,this.y-e.y,this.z-e.z,this.w-e.w)},r.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},r.prototype.subtractFromFloats=function(e,t,i,n){return new r(this.x-e,this.y-t,this.z-i,this.w-n)},r.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},r.prototype.negate=function(){return new r(-this.x,-this.y,-this.z,-this.w)},r.prototype.scaleInPlace=function(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this},r.prototype.scale=function(e){return new r(this.x*e,this.y*e,this.z*e,this.w*e)},r.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},r.prototype.equals=function(e){return e&&this.x===e.x&&this.y===e.y&&this.z===e.z&&this.w===e.w},r.prototype.equalsWithEpsilon=function(r,i){return void 0===i&&(i=e.Epsilon),r&&t.WithinEpsilon(this.x,r.x,i)&&t.WithinEpsilon(this.y,r.y,i)&&t.WithinEpsilon(this.z,r.z,i)&&t.WithinEpsilon(this.w,r.w,i)},r.prototype.equalsToFloats=function(e,t,r,i){return this.x===e&&this.y===t&&this.z===r&&this.w===i},r.prototype.multiplyInPlace=function(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this},r.prototype.multiply=function(e){return new r(this.x*e.x,this.y*e.y,this.z*e.z,this.w*e.w)},r.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},r.prototype.multiplyByFloats=function(e,t,i,n){return new r(this.x*e,this.y*t,this.z*i,this.w*n)},r.prototype.divide=function(e){return new r(this.x/e.x,this.y/e.y,this.z/e.z,this.w/e.w)},r.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},r.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},r.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},r.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},r.prototype.lengthSquared=function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},r.prototype.normalize=function(){var 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},r.prototype.toVector3=function(){return new s(this.x,this.y,this.z)},r.prototype.clone=function(){return new r(this.x,this.y,this.z,this.w)},r.prototype.copyFrom=function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w,this},r.prototype.copyFromFloats=function(e,t,r,i){return this.x=e,this.y=t,this.z=r,this.w=i,this},r.prototype.set=function(e,t,r,i){return this.copyFromFloats(e,t,r,i)},r.FromArray=function(e,t){return t||(t=0),new r(e[t],e[t+1],e[t+2],e[t+3])},r.FromArrayToRef=function(e,t,r){r.x=e[t],r.y=e[t+1],r.z=e[t+2],r.w=e[t+3]},r.FromFloatArrayToRef=function(e,t,i){r.FromArrayToRef(e,t,i)},r.FromFloatsToRef=function(e,t,r,i,n){n.x=e,n.y=t,n.z=r,n.w=i},r.Zero=function(){return new r(0,0,0,0)},r.One=function(){return new r(1,1,1,1)},r.Normalize=function(e){var t=r.Zero();return r.NormalizeToRef(e,t),t},r.NormalizeToRef=function(e,t){t.copyFrom(e),t.normalize()},r.Minimize=function(e,t){var r=e.clone();return r.MinimizeInPlace(t),r},r.Maximize=function(e,t){var r=e.clone();return r.MaximizeInPlace(t),r},r.Distance=function(e,t){return Math.sqrt(r.DistanceSquared(e,t))},r.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},r.Center=function(e,t){var r=e.add(t);return r.scaleInPlace(.5),r},r.TransformNormal=function(e,t){var i=r.Zero();return r.TransformNormalToRef(e,t,i),i},r.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},r.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},r})();e.Vector4=a;var u=(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=u;var h=(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=s.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,h=n*n,l=n*r-i*o;return l<-.4999999?(e.y=2*Math.atan2(n,o),e.x=Math.PI/2,e.z=0):l>.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+h+s),e.x=Math.asin(-2*(r*n-i*o)),e.y=Math.atan2(2*(r*i+n*o),a-u-h+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,h=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+h),e.m[7]=0,e.m[8]=2*(s+a),e.m[9]=2*(u-h),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],h=i[9],l=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-h)*r,t.y=(s-l)*r,t.z=(a-o)*r):n>u&&n>f?(r=2*Math.sqrt(1+n-u-f),t.w=(c-h)/r,t.x=.25*r,t.y=(o+a)/r,t.z=(s+l)/r):u>f?(r=2*Math.sqrt(1+u-n-f),t.w=(s-l)/r,t.x=(o+a)/r,t.y=.25*r,t.z=(h+c)/r):(r=2*Math.sqrt(1+f-n-u),t.w=(a-o)/r,t.x=(s+l)/r,t.y=(h+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),h=Math.sin(o),l=Math.cos(o),c=Math.sin(s),f=Math.cos(s);i.x=f*h*u+c*l*a,i.y=c*l*u-f*h*a,i.z=f*l*a-c*h*u,i.w=f*l*u+c*h*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=R.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 h=Math.acos(a),l=1/Math.sin(h);o=Math.sin((1-s)*h)*l,n=u?-Math.sin(s*h)*l:Math.sin(s*h)*l}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,h=-2*a+3*s,l=a-2*s+o,c=a-s;return new t(e.x*u+i.x*h+r.x*l+n.x*c,e.y*u+i.y*h+r.y*l+n.y*c,e.z*u+i.z*h+r.z*l+n.z*c,e.w*u+i.w*h+r.w*l+n.w*c)},t})();e.Quaternion=h;var l=(function(){function r(){this.m=new Float32Array(16),this._markAsUpdated()}return r.prototype._markAsUpdated=function(){this.updateFlag=r._updateFlagSeed++},r.prototype.isIdentity=function(){return 1===this.m[0]&&1===this.m[5]&&1===this.m[10]&&1===this.m[15]&&(0===this.m[1]&&0===this.m[2]&&0===this.m[3]&&0===this.m[4]&&0===this.m[6]&&0===this.m[7]&&0===this.m[8]&&0===this.m[9]&&0===this.m[11]&&0===this.m[12]&&0===this.m[13]&&0===this.m[14])},r.prototype.determinant=function(){var 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)},r.prototype.toArray=function(){return this.m},r.prototype.asArray=function(){return this.toArray()},r.prototype.invert=function(){return this.invertToRef(this),this},r.prototype.reset=function(){for(var e=0;e<16;e++)this.m[e]=0;return this._markAsUpdated(),this},r.prototype.add=function(e){var t=new r;return this.addToRef(e,t),t},r.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},r.prototype.addToSelf=function(e){for(var t=0;t<16;t++)this.m[t]+=e.m[t];return this._markAsUpdated(),this},r.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],h=this.m[8],l=this.m[9],c=this.m[10],f=this.m[11],d=this.m[12],p=this.m[13],_=this.m[14],m=this.m[15],g=c*m-f*_,v=l*m-f*p,y=l*_-c*p,T=h*m-f*d,x=h*_-c*d,E=h*p-l*d,b=s*g-a*v+u*y,A=-(o*g-a*T+u*x),M=o*v-s*T+u*E,P=-(o*y-s*x+a*E),R=1/(t*b+r*A+i*M+n*P),S=a*m-u*_,O=s*m-u*p,C=s*_-a*p,I=o*m-u*d,L=o*_-a*d,D=o*p-s*d,B=a*f-u*c,F=s*f-u*l,N=s*c-a*l,w=o*f-u*h,V=o*c-a*h,U=o*l-s*h;return e.m[0]=b*R,e.m[4]=A*R,e.m[8]=M*R,e.m[12]=P*R,e.m[1]=-(r*g-i*v+n*y)*R,e.m[5]=(t*g-i*T+n*x)*R,e.m[9]=-(t*v-r*T+n*E)*R,e.m[13]=(t*y-r*x+i*E)*R,e.m[2]=(r*S-i*O+n*C)*R,e.m[6]=-(t*S-i*I+n*L)*R,e.m[10]=(t*O-r*I+n*D)*R,e.m[14]=-(t*C-r*L+i*D)*R,e.m[3]=-(r*B-i*F+n*N)*R,e.m[7]=(t*B-i*w+n*V)*R,e.m[11]=-(t*F-r*w+n*U)*R,e.m[15]=(t*N-r*V+i*U)*R,e._markAsUpdated(),this},r.prototype.setTranslationFromFloats=function(e,t,r){return this.m[12]=e,this.m[13]=t,this.m[14]=r,this._markAsUpdated(),this},r.prototype.setTranslation=function(e){return this.m[12]=e.x,this.m[13]=e.y,this.m[14]=e.z,this._markAsUpdated(),this},r.prototype.getTranslation=function(){return new s(this.m[12],this.m[13],this.m[14])},r.prototype.getTranslationToRef=function(e){return e.x=this.m[12],e.y=this.m[13],e.z=this.m[14],this},r.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},r.prototype.multiply=function(e){var t=new r;return this.multiplyToRef(e,t),t},r.prototype.copyFrom=function(e){for(var t=0;t<16;t++)this.m[t]=e.m[t];return this._markAsUpdated(),this},r.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},r.prototype.multiplyToRef=function(e,t){return this.multiplyToArray(e,t.m,0),t._markAsUpdated(),this},r.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],h=this.m[6],l=this.m[7],c=this.m[8],f=this.m[9],d=this.m[10],p=this.m[11],_=this.m[12],m=this.m[13],g=this.m[14],v=this.m[15],y=e.m[0],T=e.m[1],x=e.m[2],E=e.m[3],b=e.m[4],A=e.m[5],M=e.m[6],P=e.m[7],R=e.m[8],S=e.m[9],O=e.m[10],C=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*T+n*A+o*S+s*L,t[r+2]=i*x+n*M+o*O+s*D,t[r+3]=i*E+n*P+o*C+s*B,t[r+4]=a*y+u*b+h*R+l*I,t[r+5]=a*T+u*A+h*S+l*L,t[r+6]=a*x+u*M+h*O+l*D,t[r+7]=a*E+u*P+h*C+l*B,t[r+8]=c*y+f*b+d*R+p*I,t[r+9]=c*T+f*A+d*S+p*L,t[r+10]=c*x+f*M+d*O+p*D,t[r+11]=c*E+f*P+d*C+p*B,t[r+12]=_*y+m*b+g*R+v*I,t[r+13]=_*T+m*A+g*S+v*L,t[r+14]=_*x+m*M+g*O+v*D,t[r+15]=_*E+m*P+g*C+v*B,this},r.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]},r.prototype.clone=function(){return r.FromValues(this.m[0],this.m[1],this.m[2],this.m[3],this.m[4],this.m[5],this.m[6],this.m[7],this.m[8],this.m[9],this.m[10],this.m[11],this.m[12],this.m[13],this.m[14],this.m[15])},r.prototype.getClassName=function(){return"Matrix"},r.prototype.getHashCode=function(){for(var e=this.m[0]||0,t=1;t<16;t++)e=397*e^(this.m[t]||0);return e},r.prototype.decompose=function(e,i,n){n.x=this.m[12],n.y=this.m[13],n.z=this.m[14];var o=t.Sign(this.m[0]*this.m[1]*this.m[2]*this.m[3])<0?-1:1,s=t.Sign(this.m[4]*this.m[5]*this.m[6]*this.m[7])<0?-1:1,a=t.Sign(this.m[8]*this.m[9]*this.m[10]*this.m[11])<0?-1:1;return e.x=o*Math.sqrt(this.m[0]*this.m[0]+this.m[1]*this.m[1]+this.m[2]*this.m[2]),e.y=s*Math.sqrt(this.m[4]*this.m[4]+this.m[5]*this.m[5]+this.m[6]*this.m[6]),e.z=a*Math.sqrt(this.m[8]*this.m[8]+this.m[9]*this.m[9]+this.m[10]*this.m[10]),0===e.x||0===e.y||0===e.z?(i.x=0,i.y=0,i.z=0,i.w=1,!1):(r.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,R.Matrix[0]),h.FromRotationMatrixToRef(R.Matrix[0],i),!0)},r.prototype.getRotationMatrix=function(){var e=r.Identity();return this.getRotationMatrixToRef(e),e},r.prototype.getRotationMatrixToRef=function(e){var t=this.m,i=t[0]*t[1]*t[2]*t[3]<0?-1:1,n=t[4]*t[5]*t[6]*t[7]<0?-1:1,o=t[8]*t[9]*t[10]*t[11]<0?-1:1,s=i*Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]),a=n*Math.sqrt(t[4]*t[4]+t[5]*t[5]+t[6]*t[6]),u=o*Math.sqrt(t[8]*t[8]+t[9]*t[9]+t[10]*t[10]);return r.FromValuesToRef(t[0]/s,t[1]/s,t[2]/s,0,t[4]/a,t[5]/a,t[6]/a,0,t[8]/u,t[9]/u,t[10]/u,0,0,0,0,1,e),this},r.FromArray=function(e,t){var i=new r;return t||(t=0),r.FromArrayToRef(e,t,i),i},r.FromArrayToRef=function(e,t,r){for(var i=0;i<16;i++)r.m[i]=e[i+t];r._markAsUpdated()},r.FromFloat32ArrayToRefScaled=function(e,t,r,i){for(var n=0;n<16;n++)i.m[n]=e[n+t]*r;i._markAsUpdated()},r.FromValuesToRef=function(e,t,r,i,n,o,s,a,u,h,l,c,f,d,p,_,m){m.m[0]=e,m.m[1]=t,m.m[2]=r,m.m[3]=i,m.m[4]=n,m.m[5]=o,m.m[6]=s,m.m[7]=a,m.m[8]=u,m.m[9]=h,m.m[10]=l,m.m[11]=c,m.m[12]=f,m.m[13]=d,m.m[14]=p,m.m[15]=_,m._markAsUpdated()},r.prototype.getRow=function(e){if(e<0||e>3)return null;var t=4*e;return new a(this.m[t+0],this.m[t+1],this.m[t+2],this.m[t+3])},r.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},r.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},r.FromValues=function(e,t,i,n,o,s,a,u,h,l,c,f,d,p,_,m){var g=new r;return g.m[0]=e,g.m[1]=t,g.m[2]=i,g.m[3]=n,g.m[4]=o,g.m[5]=s,g.m[6]=a,g.m[7]=u,g.m[8]=h,g.m[9]=l,g.m[10]=c,g.m[11]=f,g.m[12]=d,g.m[13]=p,g.m[14]=_,g.m[15]=m,g},r.Compose=function(e,t,i){var n=r.Identity();return r.ComposeToRef(e,t,i,n),n},r.ComposeToRef=function(e,t,i,n){r.FromValuesToRef(e.x,0,0,0,0,e.y,0,0,0,0,e.z,0,0,0,0,1,R.Matrix[1]),t.toRotationMatrix(R.Matrix[0]),R.Matrix[1].multiplyToRef(R.Matrix[0],n),n.setTranslation(i)},r.Identity=function(){return r.FromValues(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1)},r.IdentityToRef=function(e){r.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,e)},r.Zero=function(){return r.FromValues(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)},r.RotationX=function(e){var t=new r;return r.RotationXToRef(e,t),t},r.Invert=function(e){var t=new r;return e.invertToRef(t),t},r.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()},r.RotationY=function(e){var t=new r;return r.RotationYToRef(e,t),t},r.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()},r.RotationZ=function(e){var t=new r;return r.RotationZToRef(e,t),t},r.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()},r.RotationAxis=function(e,t){var i=r.Zero();return r.RotationAxisToRef(e,t,i),i},r.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()},r.RotationYawPitchRoll=function(e,t,i){var n=new r;return r.RotationYawPitchRollToRef(e,t,i,n),n},r.RotationYawPitchRollToRef=function(e,t,r,i){h.RotationYawPitchRollToRef(e,t,r,this._tempQuaternion),this._tempQuaternion.toRotationMatrix(i)},r.Scaling=function(e,t,i){var n=r.Zero();return r.ScalingToRef(e,t,i,n),n},r.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()},r.Translation=function(e,t,i){var n=r.Identity();return r.TranslationToRef(e,t,i,n),n},r.TranslationToRef=function(e,t,i,n){r.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,e,t,i,1,n)},r.Lerp=function(e,t,i){for(var n=r.Zero(),o=0;o<16;o++)n.m[o]=e.m[o]*(1-i)+t.m[o]*i;return n._markAsUpdated(),n},r.DecomposeLerp=function(e,t,i){var n=new s(0,0,0),o=new h,a=new s(0,0,0);e.decompose(n,o,a);var u=new s(0,0,0),l=new h,c=new s(0,0,0);t.decompose(u,l,c);var f=s.Lerp(n,u,i),d=h.Slerp(o,l,i),p=s.Lerp(a,c,i);return r.Compose(f,d,p)},r.LookAtLH=function(e,t,i){var n=r.Zero();return r.LookAtLHToRef(e,t,i,n),n},r.LookAtLHToRef=function(e,t,i,n){t.subtractToRef(e,this._zAxis),this._zAxis.normalize(),s.CrossToRef(i,this._zAxis,this._xAxis),0===this._xAxis.lengthSquared()?this._xAxis.x=1:this._xAxis.normalize(),s.CrossToRef(this._zAxis,this._xAxis,this._yAxis),this._yAxis.normalize();var o=-s.Dot(this._xAxis,e),a=-s.Dot(this._yAxis,e),u=-s.Dot(this._zAxis,e);return r.FromValuesToRef(this._xAxis.x,this._yAxis.x,this._zAxis.x,0,this._xAxis.y,this._yAxis.y,this._zAxis.y,0,this._xAxis.z,this._yAxis.z,this._zAxis.z,0,o,a,u,1,n)},r.LookAtRH=function(e,t,i){var n=r.Zero();return r.LookAtRHToRef(e,t,i,n),n},r.LookAtRHToRef=function(e,t,i,n){e.subtractToRef(t,this._zAxis),this._zAxis.normalize(),s.CrossToRef(i,this._zAxis,this._xAxis),0===this._xAxis.lengthSquared()?this._xAxis.x=1:this._xAxis.normalize(),s.CrossToRef(this._zAxis,this._xAxis,this._yAxis),this._yAxis.normalize();var o=-s.Dot(this._xAxis,e),a=-s.Dot(this._yAxis,e),u=-s.Dot(this._zAxis,e);return r.FromValuesToRef(this._xAxis.x,this._yAxis.x,this._zAxis.x,0,this._xAxis.y,this._yAxis.y,this._zAxis.y,0,this._xAxis.z,this._yAxis.z,this._zAxis.z,0,o,a,u,1,n)},r.OrthoLH=function(e,t,i,n){var o=r.Zero();return r.OrthoLHToRef(e,t,i,n,o),o},r.OrthoLHToRef=function(t,r,i,n,o){var s=i,a=n,u=2/t,h=2/r,l=2/(a-s),c=-(a+s)/(a-s);e.Matrix.FromValuesToRef(u,0,0,0,0,h,0,0,0,0,l,0,0,0,c,1,o)},r.OrthoOffCenterLH=function(e,t,i,n,o,s){var a=r.Zero();return r.OrthoOffCenterLHToRef(e,t,i,n,o,s,a),a},r.OrthoOffCenterLHToRef=function(t,r,i,n,o,s,a){var u=o,h=s,l=2/(r-t),c=2/(n-i),f=2/(h-u),d=-(h+u)/(h-u),p=(t+r)/(t-r),_=(n+i)/(i-n);e.Matrix.FromValuesToRef(l,0,0,0,0,c,0,0,0,0,f,0,p,_,d,1,a)},r.OrthoOffCenterRH=function(e,t,i,n,o,s){var a=r.Zero();return r.OrthoOffCenterRHToRef(e,t,i,n,o,s,a),a},r.OrthoOffCenterRHToRef=function(e,t,i,n,o,s,a){r.OrthoOffCenterLHToRef(e,t,i,n,o,s,a),a.m[10]*=-1},r.PerspectiveLH=function(t,i,n,o){var s=r.Zero(),a=n,u=o,h=2*a/t,l=2*a/i,c=(u+a)/(u-a),f=-2*u*a/(u-a);return e.Matrix.FromValuesToRef(h,0,0,0,0,l,0,0,0,0,c,1,0,0,f,0,s),s},r.PerspectiveFovLH=function(e,t,i,n){var o=r.Zero();return r.PerspectiveFovLHToRef(e,t,i,n,o),o},r.PerspectiveFovLHToRef=function(t,r,i,n,o,s){void 0===s&&(s=!0);var a=i,u=n,h=1/Math.tan(.5*t),l=s?h/r:h,c=s?h:h*r,f=(u+a)/(u-a),d=-2*u*a/(u-a);e.Matrix.FromValuesToRef(l,0,0,0,0,c,0,0,0,0,f,1,0,0,d,0,o)},r.PerspectiveFovRH=function(e,t,i,n){var o=r.Zero();return r.PerspectiveFovRHToRef(e,t,i,n,o),o},r.PerspectiveFovRHToRef=function(t,r,i,n,o,s){void 0===s&&(s=!0);var a=i,u=n,h=1/Math.tan(.5*t),l=s?h/r:h,c=s?h:h*r,f=-(u+a)/(u-a),d=-2*u*a/(u-a);e.Matrix.FromValuesToRef(l,0,0,0,0,c,0,0,0,0,f,-1,0,0,d,0,o)},r.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),h=Math.tan(e.rightDegrees*Math.PI/180),l=2/(u+h),c=2/(s+a);i.m[0]=l,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-h)*l*.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()},r.GetFinalMatrix=function(e,t,i,n,o,s){var a=e.width,u=e.height,h=e.x,l=e.y,c=r.FromValues(a/2,0,0,0,0,-u/2,0,0,0,0,s-o,0,h+a/2,u/2+l,o,1);return t.multiply(i).multiply(n).multiply(c)},r.GetAsMatrix2x2=function(e){return new Float32Array([e.m[0],e.m[1],e.m[4],e.m[5]])},r.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]])},r.Transpose=function(e){var t=new r;return t.m[0]=e.m[0],t.m[1]=e.m[4],t.m[2]=e.m[8],t.m[3]=e.m[12],t.m[4]=e.m[1],t.m[5]=e.m[5],t.m[6]=e.m[9],t.m[7]=e.m[13],t.m[8]=e.m[2],t.m[9]=e.m[6],t.m[10]=e.m[10],t.m[11]=e.m[14],t.m[12]=e.m[3],t.m[13]=e.m[7],t.m[14]=e.m[11],t.m[15]=e.m[15],t},r.Reflection=function(e){var t=new r;return r.ReflectionToRef(e,t),t},r.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()},r.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()},r.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,h=e.y*e.z,l=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*(h+l),t.m[7]=0,t.m[8]=2*(a+u),t.m[9]=2*(h-l),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()},r})();l._tempQuaternion=new h,l._xAxis=s.Zero(),l._yAxis=s.Zero(),l._zAxis=s.Zero(),l._updateFlagSeed=0,e.Matrix=l;var c=(function(){function e(e,t,r,i){this.normal=new s(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=l.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,h=r.z-e.z,l=o*h-s*u,c=s*a-n*h,f=n*u-o*a,d=Math.sqrt(l*l+c*c+f*f);return i=0!==d?1/d:0,this.normal.x=l*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 s.Dot(this.normal,e)<=t},e.prototype.signedDistanceTo=function(e){return s.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 s.Dot(r,t)+i},e})();e.Plane=c;var f=(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){return new e(this.x*t,this.y*r,this.width*t,this.height*r)},e.prototype.clone=function(){return new e(this.x,this.y,this.width,this.height)},e})();e.Viewport=f;var d=(function(){function e(){}return e.GetPlanes=function(t){for(var r=[],i=0;i<6;i++)r.push(new c(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=d;!(function(e){e[e.LOCAL=0]="LOCAL",e[e.WORLD=1]="WORLD",e[e.BONE=2]="BONE"})(e.Space||(e.Space={}));var p=(function(){function e(){}return e})();p.X=new s(1,0,0),p.Y=new s(0,1,0),p.Z=new s(0,0,1),e.Axis=p;var _=(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,h=0;h<5;h++){var l=u*u;u-=(o*(l*u)+s*l+a*u-e)*(1/(3*o*l+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=_;var m;!(function(e){e[e.CW=0]="CW",e[e.CCW=1]="CCW"})(m=e.Orientation||(e.Orientation={}));var g=(function(){function e(e){var t=this;this.degrees=function(){return 180*t._radians/Math.PI},this.radians=function(){return t._radians},this._radians=e,this._radians<0&&(this._radians+=2*Math.PI)}return e.BetweenTwoPoints=function(t,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 v=(function(){function e(e,t,r){this.startPoint=e,this.midPoint=t,this.endPoint=r;var i=Math.pow(t.x,2)+Math.pow(t.y,2),n=(Math.pow(e.x,2)+Math.pow(e.y,2)-i)/2,s=(i-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 o((n*(t.y-r.y)-s*(e.y-t.y))/a,((e.x-t.x)*s-(t.x-r.x)*n)/a),this.radius=this.centerPoint.subtract(this.startPoint).length(),this.startAngle=g.BetweenTwoPoints(this.centerPoint,this.startPoint);var u=this.startAngle.degrees(),h=g.BetweenTwoPoints(this.centerPoint,this.midPoint).degrees(),l=g.BetweenTwoPoints(this.centerPoint,this.endPoint).degrees();h-u>180&&(h-=360),h-u<-180&&(h+=360),l-h>180&&(l-=360),l-h<-180&&(l+=360),this.orientation=h-u<0?m.CW:m.CCW,this.angle=g.FromDegrees(this.orientation===m.CW?u-l:l-u)}return e})();e.Arc2=v;var y=(function(){function e(e,t){this._points=new Array,this._length=0,this.closed=!1,this._points.push(new o(e,t))}return e.prototype.addLineTo=function(e,t){if(closed)return this;var r=new o(e,t),i=this._points[this._points.length-1];return this._points.push(r),this._length+=r.subtract(i).length(),this},e.prototype.addArcTo=function(e,t,r,i,n){if(void 0===n&&(n=36),closed)return this;var s=this._points[this._points.length-1],a=new o(e,t),u=new o(r,i),h=new v(s,a,u),l=h.angle.radians()/n;h.orientation===m.CW&&(l*=-1);for(var c=h.startAngle.radians()+l,f=0;f<n;f++){var d=Math.cos(c)*h.radius+h.centerPoint.x,p=Math.sin(c)*h.radius+h.centerPoint.y;this.addLineTo(d,p),c+=l}return this},e.prototype.close=function(){return this.closed=!0,this},e.prototype.length=function(){var e=this._length;if(!this.closed){var t=this._points[this._points.length-1];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 o.Zero();for(var t=e*this.length(),r=0,i=0;i<this._points.length;i++){var n=(i+1)%this._points.length,s=this._points[i],a=this._points[n],u=a.subtract(s),h=u.length()+r;if(t>=r&&t<=h){var l=u.normalize(),c=t-r;return new o(s.x+l.x*c,s.y+l.y*c)}r=h}return o.Zero()},e.StartingAt=function(t,r){return new e(t,r)},e})();e.Path2=y;var T=(function(){function r(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 r.prototype.getCurve=function(){return this._curve},r.prototype.getTangents=function(){return this._tangents},r.prototype.getNormals=function(){return this._normals},r.prototype.getBinormals=function(){return this._binormals},r.prototype.getDistances=function(){return this._distances},r.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},r.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]=s.Cross(r,this._normals[0]),this._raw||this._binormals[0].normalize(),this._distances[0]=0;for(var n,o,a,u,h=1;h<t;h++)n=this._getLastNonNullVector(h),h<t-1&&(o=this._getFirstNonNullVector(h),this._tangents[h]=n.add(o),this._tangents[h].normalize()),this._distances[h]=this._distances[h-1]+n.length(),a=this._tangents[h],u=this._binormals[h-1],this._normals[h]=s.Cross(u,a),this._raw||this._normals[h].normalize(),this._binormals[h]=s.Cross(a,this._normals[h]),this._raw||this._binormals[h].normalize()},r.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},r.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},r.prototype._normalVector=function(r,i,n){var o,a=i.length();if(0===a&&(a=1),void 0===n||null===n){var u;t.WithinEpsilon(Math.abs(i.y)/a,1,e.Epsilon)?t.WithinEpsilon(Math.abs(i.x)/a,1,e.Epsilon)?t.WithinEpsilon(Math.abs(i.z)/a,1,e.Epsilon)||(u=new s(0,0,1)):u=new s(1,0,0):u=new s(0,-1,0),o=s.Cross(i,u)}else o=s.Cross(i,n),s.CrossToRef(o,i,o);return o.normalize(),o},r})();e.Path3D=T;var x=(function(){function e(e){this._length=0,this._points=e,this._length=this._computeLength(e)}return e.CreateQuadraticBezier=function(t,r,i,n){n=n>2?n:3;for(var o=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<=n;u++)o.push(new s(a(u/n,t.x,r.x,i.x),a(u/n,t.y,r.y,i.y),a(u/n,t.z,r.z,i.z)));return new e(o)},e.CreateCubicBezier=function(t,r,i,n,o){o=o>3?o: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},h=0;h<=o;h++)a.push(new s(u(h/o,t.x,r.x,i.x,n.x),u(h/o,t.y,r.y,i.y,n.y),u(h/o,t.z,r.z,i.z,n.z)));return new e(a)},e.CreateHermiteSpline=function(t,r,i,n,o){for(var a=new Array,u=1/o,h=0;h<=o;h++)a.push(s.Hermite(t,r,i,n,h*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 n=new Array,o=1/r,a=0;a<i.length-3;a++)for(var u=0,h=0;h<r;h++)n.push(s.CatmullRom(i[a],i[a+1],i[a+2],i[a+3],u)),u+=o;return a--,n.push(s.CatmullRom(i[a],i[a+1],i[a+2],i[a+3],u)),new e(n)},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=x;var E=(function(){function e(){this.L00=s.Zero(),this.L1_1=s.Zero(),this.L10=s.Zero(),this.L11=s.Zero(),this.L2_2=s.Zero(),this.L2_1=s.Zero(),this.L20=s.Zero(),this.L21=s.Zero(),this.L22=s.Zero()}return e.prototype.addLight=function(e,t,r){var i=new s(t.r,t.g,t.b),n=i.scale(r);this.L00=this.L00.add(n.scale(.282095)),this.L1_1=this.L1_1.add(n.scale(.488603*e.y)),this.L10=this.L10.add(n.scale(.488603*e.z)),this.L11=this.L11.add(n.scale(.488603*e.x)),this.L2_2=this.L2_2.add(n.scale(1.092548*e.x*e.y)),this.L2_1=this.L2_1.add(n.scale(1.092548*e.y*e.z)),this.L21=this.L21.add(n.scale(1.092548*e.x*e.z)),this.L20=this.L20.add(n.scale(.315392*(3*e.z*e.z-1))),this.L22=this.L22.add(n.scale(.546274*(e.x*e.x-e.y*e.y)))},e.prototype.scale=function(e){this.L00=this.L00.scale(e),this.L1_1=this.L1_1.scale(e),this.L10=this.L10.scale(e),this.L11=this.L11.scale(e),this.L2_2=this.L2_2.scale(e),this.L2_1=this.L2_1.scale(e),this.L20=this.L20.scale(e),this.L21=this.L21.scale(e),this.L22=this.L22.scale(e)},e})();e.SphericalHarmonics=E;var b=(function(){function e(){this.x=s.Zero(),this.y=s.Zero(),this.z=s.Zero(),this.xx=s.Zero(),this.yy=s.Zero(),this.zz=s.Zero(),this.xy=s.Zero(),this.yz=s.Zero(),this.zx=s.Zero()}return e.prototype.addAmbient=function(e){var t=new s(e.r,e.g,e.b);this.xx=this.xx.add(t),this.yy=this.yy.add(t),this.zz=this.zz.add(t)},e.getSphericalPolynomialFromHarmonics=function(t){var r=new e;return r.x=t.L11.scale(1.02333),r.y=t.L1_1.scale(1.02333),r.z=t.L10.scale(1.02333),r.xx=t.L00.scale(.886277).subtract(t.L20.scale(.247708)).add(t.L22.scale(.429043)),r.yy=t.L00.scale(.886277).subtract(t.L20.scale(.247708)).subtract(t.L22.scale(.429043)),r.zz=t.L00.scale(.886277).add(t.L20.scale(.495417)),r.yz=t.L2_1.scale(.858086),r.zx=t.L21.scale(.858086),r.xy=t.L2_2.scale(.858086),r},e})();e.SphericalPolynomial=b;var A=(function(){function e(e,t){void 0===e&&(e=s.Zero()),void 0===t&&(t=s.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 M=(function(){function e(e,t,r){void 0===e&&(e=s.Zero()),void 0===t&&(t=s.Up()),void 0===r&&(r=o.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=M;var P=(function(){function e(){}return e})();P.Color3=[i.Black(),i.Black(),i.Black()],P.Vector2=[o.Zero(),o.Zero(),o.Zero()],P.Vector3=[s.Zero(),s.Zero(),s.Zero(),s.Zero(),s.Zero(),s.Zero(),s.Zero(),s.Zero(),s.Zero()],P.Vector4=[a.Zero(),a.Zero(),a.Zero()],P.Quaternion=[h.Zero(),h.Zero()],P.Matrix=[l.Zero(),l.Zero(),l.Zero(),l.Zero(),l.Zero(),l.Zero(),l.Zero(),l.Zero()],e.Tmp=P;var R=(function(){function e(){}return e})();R.Vector3=[s.Zero()],R.Matrix=[l.Zero(),l.Zero()],R.Quaternion=[h.Zero()]})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){function t(e,t){return function(r,i){r.__serializableMembers||(r.__serializableMembers={}),r.__serializableMembers[i]||(r.__serializableMembers[i]={type:e,sourceName:t})}}function r(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 i(e,t){return r(e,t)}function n(e){return t(0,e)}function o(e){return t(1,e)}function s(e){return t(2,e)}function a(e){return t(3,e)}function u(e){return t(4,e)}function h(e){return t(5,e)}function l(e){return t(6,e)}function c(e){return t(7,e)}e.expandToProperty=i,e.serialize=n,e.serializeAsTexture=o,e.serializeAsColor3=s,e.serializeAsFresnelParameters=a,e.serializeAsVector2=u,e.serializeAsVector3=h,e.serializeAsMeshReference=l,e.serializeAsColorCurves=c;var f=(function(){function t(){}return t.Serialize=function(t,r){r||(r={}),e.Tags&&(r.tags=e.Tags.GetTags(t));for(var i in t.__serializableMembers){var n=t.__serializableMembers[i],o=n.sourceName||i,s=n.type,a=t[i];if(void 0!==a&&null!==a)switch(s){case 0:r[o]=a;break;case 1:r[o]=a.serialize();break;case 2:r[o]=a.asArray();break;case 3:r[o]=a.serialize();break;case 4:case 5:r[o]=a.asArray();break;case 6:r[o]=a.id;break;case 7:r[o]=a.serialize()}}return r},t.Parse=function(t,r,i,n){var o=t();e.Tags&&e.Tags.AddTagsTo(o,r.tags);for(var s in o.__serializableMembers){var a=o.__serializableMembers[s],u=r[a.sourceName||s],h=a.type;if(void 0!==u&&null!==u)switch(h){case 0:o[s]=u;break;case 1:o[s]=e.Texture.Parse(u,i,n);break;case 2:o[s]=e.Color3.FromArray(u);break;case 3:o[s]=e.FresnelParameters.Parse(u);break;case 4:o[s]=e.Vector2.FromArray(u);break;case 5:o[s]=e.Vector3.FromArray(u);break;case 6:o[s]=i.getLastMeshByID(u);break;case 7:o[s]=e.ColorCurves.Parse(u)}}return o},t.Clone=function(t,r){var i=t();e.Tags&&e.Tags.AddTagsTo(i,r.tags);for(var n in i.__serializableMembers){var o=i.__serializableMembers[n],s=r[n],a=o.type;if(void 0!==s&&null!==s)switch(a){case 0:case 6:i[n]=s;break;case 1:case 2:case 3:case 4:case 5:case 7:i[n]=s.clone()}}return i},t})();e.SerializationHelper=f})(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.length=0},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})();t._GlobalId=0,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+/=",h="",l=0,c=new Uint8Array(e);l<c.length;)t=c[l++],r=l<c.length?c[l++]:Number.NaN,i=l<c.length?c[l++]: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),h+=u.charAt(n)+u.charAt(o)+u.charAt(s)+u.charAt(a);return"data:image/png;base64,"+h},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 h=new e.Vector3(t[3*r[u]],t[3*r[u]+1],t[3*r[u]+2]);s=e.Vector3.Minimize(h,s),a=e.Vector3.Maximize(h,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 h=new e.Vector3(t[u*o],t[u*o+1],t[u*o+2]);s=e.Vector3.Minimize(h,s),a=e.Vector3.Maximize(h,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 h=r.substring(5).toLowerCase();if(e.FilesInput.FilesToLoad[h])try{var l;try{l=URL.createObjectURL(e.FilesInput.FilesToLoad[h],{oneTimeOnly:!0})}catch(t){l=URL.createObjectURL(e.FilesInput.FilesToLoad[h])}s.src=l}catch(e){s.src=null}else t.Error("Image: "+h+" 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)},h=function(){o.loadFileFromDB(r,i,n,u,s)};if(-1!==r.indexOf("file:")){var l=r.substring(5).toLowerCase();e.FilesInput.FilesToLoad[l]?t.ReadFile(e.FilesInput.FilesToLoad[l],i,n,s):t.Error("File: "+l+" not found. Did you forget to provide it?")}else o&&o.enableSceneOffline?o.openAsync(h,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 h=i(s[u],t);-1===t[o].indexOf(h)&&t[o].push(h)}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,h=n.readPixels(0,0,e,i),l=0;l<u;l++)for(var c=0;c<a;c++){var f=c+l*a,d=i-l-1,p=c+d*a,_=h[f];h[f]=h[p],h[p]=_}r||(r=document.createElement("canvas")),r.width=e,r.height=i;var m=r.getContext("2d"),g=m.createImageData(e,i);g.data.set(h),m.putImageData(g,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 h=r.getContext("2d"),l=e.getRenderWidth()/e.getRenderHeight(),c=a,f=c/l;f>u&&(f=u,c=f*l);var d=Math.max(0,a-c)/2,p=Math.max(0,u-f)/2;h.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,h;if(n.precision)u=Math.round(r.getRenderWidth()*n.precision),h=Math.round(u/r.getAspectRatio(i)),n={width:u,height:h};else if(n.width&&n.height)u=n.width,h=n.height;else if(n.width&&!n.height)u=n.width,h=Math.round(u/r.getAspectRatio(i)),n={width:u,height:h};else if(n.height&&!n.width)h=n.height,u=Math.round(h*r.getAspectRatio(i)),n={width:u,height:h};else{if(isNaN(n))return void t.Error("Invalid 'size' parameter !");h=n,u=n}var l=i.getScene(),c=null;l.activeCamera!==i&&(c=l.activeCamera,l.activeCamera=i);var f=new e.RenderTargetTexture("screenShot",n,l,!1,!1,e.Engine.TEXTURETYPE_UNSIGNED_INT,!1,e.Texture.NEAREST_SAMPLINGMODE);f.renderList=l.meshes,f.samples=a,f.onAfterRenderObservable.add((function(){t.DumpFramebuffer(u,h,r,o,s)})),l.incrementRenderId(),l.resetCachedMaterial(),f.render(!0),f.dispose(),c&&(l.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})();n.BaseUrl="",n.CorsBehavior="anonymous",n.UseFallbackTexture=!0,n.fallbackTexture="data:image/jpg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD/4QBmRXhpZgAATU0AKgAAAAgABAEaAAUAAAABAAAAPgEbAAUAAAABAAAARgEoAAMAAAABAAIAAAExAAIAAAAQAAAATgAAAAAAAABgAAAAAQAAAGAAAAABcGFpbnQubmV0IDQuMC41AP/bAEMABAIDAwMCBAMDAwQEBAQFCQYFBQUFCwgIBgkNCw0NDQsMDA4QFBEODxMPDAwSGBITFRYXFxcOERkbGRYaFBYXFv/bAEMBBAQEBQUFCgYGChYPDA8WFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFv/AABEIAQABAAMBIgACEQEDEQH/xAAfAAABBQEBAQEBAQAAAAAAAAAAAQIDBAUGBwgJCgv/xAC1EAACAQMDAgQDBQUEBAAAAX0BAgMABBEFEiExQQYTUWEHInEUMoGRoQgjQrHBFVLR8CQzYnKCCQoWFxgZGiUmJygpKjQ1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4eLj5OXm5+jp6vHy8/T19vf4+fr/xAAfAQADAQEBAQEBAQEBAAAAAAAAAQIDBAUGBwgJCgv/xAC1EQACAQIEBAMEBwUEBAABAncAAQIDEQQFITEGEkFRB2FxEyIygQgUQpGhscEJIzNS8BVictEKFiQ04SXxFxgZGiYnKCkqNTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqCg4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2dri4+Tl5ufo6ery8/T19vf4+fr/2gAMAwEAAhEDEQA/APH6KKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FCiiigD6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++gooooA+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gUKKKKAPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76CiiigD5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BQooooA+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/voKKKKAPl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FCiiigD6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++gooooA+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gUKKKKAPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76CiiigD5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BQooooA+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/voKKKKAPl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FCiiigD6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++gooooA+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gUKKKKAPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76P//Z",n._NoneLogLevel=0,n._MessageLogLevel=1,n._WarningLogLevel=2,n._ErrorLogLevel=4,n._LogCache="",n.errorsCount=0,n.Log=n._LogEnabled,n.Warn=n._WarnEnabled,n.Error=n._ErrorEnabled,n._PerformanceNoneLogLevel=0,n._PerformanceUserMarkLogLevel=1,n._PerformanceConsoleLogLevel=2,n._performance=window.performance,n.StartPerformanceCounter=n._StartPerformanceCounterDisabled,n.EndPerformanceCounter=n._EndPerformanceCounterDisabled,e.Tools=n;var o=(function(){function e(){this._startMonitoringTime=0,this._min=0,this._max=0,this._average=0,this._lastSecAverage=0,this._current=0,this._totalValueCount=0,this._totalAccumulated=0,this._lastSecAccumulated=0,this._lastSecTime=0,this._lastSecValueCount=0}return Object.defineProperty(e.prototype,"min",{get:function(){return this._min},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"max",{get:function(){return this._max},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"average",{get:function(){return this._average},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"lastSecAverage",{get:function(){return this._lastSecAverage},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"current",{get:function(){return this._current},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"total",{get:function(){return this._totalAccumulated},enumerable:!0,configurable:!0}),e.prototype.fetchNewFrame=function(){this._totalValueCount++,this._current=0,this._lastSecValueCount++},e.prototype.addCount=function(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})();o.Enabled=!0,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;return t===e.Texture.BILINEAR_SAMPLINGMODE?(n=i.LINEAR,o=r?i.LINEAR_MIPMAP_NEAREST:i.LINEAR):t===e.Texture.TRILINEAR_SAMPLINGMODE?(n=i.LINEAR,o=r?i.LINEAR_MIPMAP_LINEAR:i.LINEAR):t===e.Texture.NEAREST_SAMPLINGMODE&&(n=i.NEAREST,o=r?i.NEAREST_MIPMAP_LINEAR:i.NEAREST),{min:o,mag:n}},i=function(t,i,n,o,s,a,u,h,l,c){void 0===c&&(c=e.Texture.TRILINEAR_SAMPLINGMODE);var f=n.getEngine();if(f){var d=e.Tools.GetExponentOfTwo(o,f.getCaps().maxTextureSize),p=e.Tools.GetExponentOfTwo(s,f.getCaps().maxTextureSize);f._bindTextureDirectly(i.TEXTURE_2D,t),i.pixelStorei(i.UNPACK_FLIP_Y_WEBGL,void 0===a?1:a?1:0),t._baseWidth=o,t._baseHeight=s,t._width=d,t._height=p,t.isReady=!0,l(d,p);var _=r(c,!u,i);i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MAG_FILTER,_.mag),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_MIN_FILTER,_.min),u||h||i.generateMipmap(i.TEXTURE_2D),f._bindTextureDirectly(i.TEXTURE_2D,null),f.resetTextureCache(),n._removePendingData(t),t.onLoadedCallbacks.forEach((function(e){e()})),t.onLoadedCallbacks=[]}},n=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)},h=function(){n._removePendingData(a),s&&s()};a=e.Tools.LoadImage(t,u,h,n.database),n._addPendingData(a)},o=function(e,t,r,i,o){void 0===o&&(o=null);var s=[];s._internalCount=0;for(var a=0;a<6;a++)n(i[a],a,s,t,r,o)},s=(function(){function e(){}return e})();e.InstancingAttributeInfo=s;var a=(function(){function e(){}return e})();e.EngineCapabilities=a;var u=(function(){function n(t,r,i,o){void 0===o&&(o=!1);var s=this;if(this.isFullscreen=!1,this.isPointerLock=!1,this.cullBackFaces=!0,this.renderEvenInBackground=!0,this.preventCacheWipeBetweenFrames=!1,this.enableOfflineSupport=e.Database,this.scenes=new Array,this.onResizeObservable=new e.Observable,this.onCanvasBlurObservable=new e.Observable,this._windowIsBackground=!1,this._webGLVersion=1,this._badOS=!1,this._drawCalls=new e.PerfCounter,this._renderingQueueLaunched=!1,this._activeRenderLoops=[],this.fpsRange=60,this.previousFramesDuration=[],this.fps=60,this.deltaTime=0,this._depthCullingState=new e.Internals._DepthCullingState,this._stencilState=new e.Internals._StencilState,this._alphaState=new e.Internals._AlphaState,this._alphaMode=n.ALPHA_DISABLE,this._loadedTexturesCache=new Array,this._maxTextureChannels=16,this._activeTexturesCache=new Array(this._maxTextureChannels),this._compiledEffects={},this._vertexAttribArraysEnabled=[],this._uintIndicesCurrentlySet=!1,this._currentBoundBuffer=new Array,this._currentBufferPointers=[],this._currentInstanceLocations=new Array,this._currentInstanceBuffers=new Array,this._vaoRecordInProgress=!1,this._mustWipeVertexAttributes=!1,this._texturesSupported=new Array,this._onVRFullScreenTriggered=function(){if(s._vrDisplayEnabled&&s._vrDisplayEnabled.isPresenting){s._oldSize=new e.Size(s.getRenderWidth(),s.getRenderHeight()),s._oldHardwareScaleFactor=s.getHardwareScalingLevel();var t=s._vrDisplayEnabled.getEyeParameters("left");s.setHardwareScalingLevel(1),s.setSize(2*t.renderWidth,t.renderHeight)}else s.setHardwareScalingLevel(s._oldHardwareScaleFactor),s.setSize(s._oldSize.width,s._oldSize.height),s._vrDisplayEnabled=void 0},this._renderingCanvas=t,n.Instances.push(this),i=i||{},null!=r&&(i.antialias=r),void 0===i.preserveDrawingBuffer&&(i.preserveDrawingBuffer=!1),void 0===i.audioEngine&&(i.audioEngine=!0),void 0===i.stencil&&(i.stencil=!0),!i.disableWebGL2Support)try{this._gl=t.getContext("webgl2",i)||t.getContext("experimental-webgl2",i),this._gl&&(this._webGLVersion=2)}catch(e){}if(!this._gl){if(!t)throw new Error("The provided canvas is null or undefined.");try{this._gl=t.getContext("webgl",i)||t.getContext("experimental-webgl",i)}catch(e){throw new Error("WebGL not supported")}}if(!this._gl)throw new Error("WebGL not supported");this._onBlur=function(){s._windowIsBackground=!0},this._onFocus=function(){s._windowIsBackground=!1},this._onCanvasBlur=function(){s.onCanvasBlurObservable.notifyObservers(s)},window.addEventListener("blur",this._onBlur),window.addEventListener("focus",this._onFocus),t.addEventListener("pointerout",this._onCanvasBlur);var u=i.limitDeviceRatio||window.devicePixelRatio||1;this._hardwareScalingLevel=o?1/Math.min(u,window.devicePixelRatio||1):1,this.resize(),this._isStencilEnable=i.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 h=this._gl.getExtension("WEBGL_debug_renderer_info");if(null!=h&&(this._glRenderer=this._gl.getParameter(h.UNMASKED_RENDERER_WEBGL),this._glVendor=this._gl.getParameter(h.UNMASKED_VENDOR_WEBGL)),this._glVendor||(this._glVendor="Unknown vendor"),this._glRenderer||(this._glRenderer="Unknown renderer"),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&&(n.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 l=this._gl.getExtension("OES_vertex_array_object");null!=l?(this._caps.vertexArrayObject=!0,this._gl.createVertexArray=l.createVertexArrayOES.bind(l),this._gl.bindVertexArray=l.bindVertexArrayOES.bind(l),this._gl.deleteVertexArray=l.deleteVertexArrayOES.bind(l)):this._caps.vertexArrayObject=!1}if(this._webGLVersion>1)this._caps.instancedArrays=!0;else{var c=this._gl.getExtension("ANGLE_instanced_arrays");null!=c?(this._caps.instancedArrays=!0,this._gl.drawArraysInstanced=c.drawArraysInstancedANGLE.bind(c),this._gl.drawElementsInstanced=c.drawElementsInstancedANGLE.bind(c),this._gl.vertexAttribDivisor=c.vertexAttribDivisorANGLE.bind(c)):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 f=this._gl.getShaderPrecisionFormat(this._gl.FRAGMENT_SHADER,this._gl.HIGH_FLOAT);this._caps.highPrecisionShaderSupported=0!==f.precision}this.setDepthBuffer(!0),this.setDepthFunctionToLessOrEqual(),this.setDepthWrite(!0),this._onFullscreenChange=function(){void 0!==document.fullscreen?s.isFullscreen=document.fullscreen:void 0!==document.mozFullScreen?s.isFullscreen=document.mozFullScreen:void 0!==document.webkitIsFullScreen?s.isFullscreen=document.webkitIsFullScreen:void 0!==document.msIsFullScreen&&(s.isFullscreen=document.msIsFullScreen),s.isFullscreen&&s._pointerLockRequested&&(t.requestPointerLock=t.requestPointerLock||t.msRequestPointerLock||t.mozRequestPointerLock||t.webkitRequestPointerLock,t.requestPointerLock&&t.requestPointerLock())},document.addEventListener("fullscreenchange",this._onFullscreenChange,!1),document.addEventListener("mozfullscreenchange",this._onFullscreenChange,!1),document.addEventListener("webkitfullscreenchange",this._onFullscreenChange,!1),document.addEventListener("msfullscreenchange",this._onFullscreenChange,!1),this._onPointerLockChange=function(){s.isPointerLock=document.mozPointerLockElement===t||document.webkitPointerLockElement===t||document.msPointerLockElement===t||document.pointerLockElement===t},document.addEventListener("pointerlockchange",this._onPointerLockChange,!1),document.addEventListener("mspointerlockchange",this._onPointerLockChange,!1),document.addEventListener("mozpointerlockchange",this._onPointerLockChange,!1),document.addEventListener("webkitpointerlockchange",this._onPointerLockChange,!1),i.audioEngine&&e.AudioEngine&&!n.audioEngine&&(n.audioEngine=new e.AudioEngine),i.autoEnableWebVR&&this.initWebVR();var d=/AppleWebKit.*10.[\d] Mobile/;this._badOS=d.test(navigator.userAgent),e.Tools.Log("Babylon.js engine (v"+n.Version+") launched")}return Object.defineProperty(n,"LastCreatedEngine",{get:function(){return 0===n.Instances.length?null:n.Instances[n.Instances.length-1]},enumerable:!0,configurable:!0}),Object.defineProperty(n,"LastCreatedScene",{get:function(){var e=n.LastCreatedEngine;return e?0===e.scenes.length?null:e.scenes[e.scenes.length-1]:null},enumerable:!0,configurable:!0}),n.MarkAllMaterialsAsDirty=function(e,t){for(var r=0;r<n.Instances.length;r++)for(var i=n.Instances[r],o=0;o<i.scenes.length;o++)i.scenes[o].markAllMaterialsAsDirty(e,t)},Object.defineProperty(n,"NEVER",{get:function(){return n._NEVER},enumerable:!0,configurable:!0}),Object.defineProperty(n,"ALWAYS",{get:function(){return n._ALWAYS},enumerable:!0,configurable:!0}),Object.defineProperty(n,"LESS",{get:function(){return n._LESS},enumerable:!0,configurable:!0}),Object.defineProperty(n,"EQUAL",{get:function(){return n._EQUAL},enumerable:!0,configurable:!0}),Object.defineProperty(n,"LEQUAL",{get:function(){return n._LEQUAL},enumerable:!0,configurable:!0}),Object.defineProperty(n,"GREATER",{get:function(){return n._GREATER},enumerable:!0,configurable:!0}),Object.defineProperty(n,"GEQUAL",{get:function(){return n._GEQUAL},enumerable:!0,configurable:!0}),Object.defineProperty(n,"NOTEQUAL",{get:function(){return n._NOTEQUAL},enumerable:!0,configurable:!0}),Object.defineProperty(n,"KEEP",{get:function(){return n._KEEP},enumerable:!0,configurable:!0}),Object.defineProperty(n,"REPLACE",{get:function(){return n._REPLACE},enumerable:!0,configurable:!0}),Object.defineProperty(n,"INCR",{get:function(){return n._INCR},enumerable:!0,configurable:!0}),Object.defineProperty(n,"DECR",{get:function(){return n._DECR},enumerable:!0,configurable:!0}),Object.defineProperty(n,"INVERT",{get:function(){return n._INVERT},enumerable:!0,configurable:!0}),Object.defineProperty(n,"INCR_WRAP",{get:function(){return n._INCR_WRAP},enumerable:!0,configurable:!0}),Object.defineProperty(n,"DECR_WRAP",{get:function(){return n._DECR_WRAP},enumerable:!0,configurable:!0}),Object.defineProperty(n,"ALPHA_DISABLE",{get:function(){return n._ALPHA_DISABLE},enumerable:!0,configurable:!0}),Object.defineProperty(n,"ALPHA_ONEONE",{get:function(){return n._ALPHA_ONEONE},enumerable:!0,configurable:!0}),Object.defineProperty(n,"ALPHA_ADD",{get:function(){return n._ALPHA_ADD},enumerable:!0,configurable:!0}),Object.defineProperty(n,"ALPHA_COMBINE",{get:function(){return n._ALPHA_COMBINE},enumerable:!0,configurable:!0}),Object.defineProperty(n,"ALPHA_SUBTRACT",{get:function(){return n._ALPHA_SUBTRACT},enumerable:!0,configurable:!0}),Object.defineProperty(n,"ALPHA_MULTIPLY",{get:function(){return n._ALPHA_MULTIPLY},enumerable:!0,configurable:!0}),Object.defineProperty(n,"ALPHA_MAXIMIZED",{get:function(){return n._ALPHA_MAXIMIZED},enumerable:!0,configurable:!0}),Object.defineProperty(n,"ALPHA_PREMULTIPLIED",{get:function(){return n._ALPHA_PREMULTIPLIED},enumerable:!0,configurable:!0}),Object.defineProperty(n,"ALPHA_PREMULTIPLIED_PORTERDUFF",{get:function(){return n._ALPHA_PREMULTIPLIED_PORTERDUFF},enumerable:!0,configurable:!0}),Object.defineProperty(n,"ALPHA_INTERPOLATE",{get:function(){return n._ALPHA_INTERPOLATE},enumerable:!0,configurable:!0}),Object.defineProperty(n,"ALPHA_SCREENMODE",{get:function(){return n._ALPHA_SCREENMODE},enumerable:!0,configurable:!0}),Object.defineProperty(n,"DELAYLOADSTATE_NONE",{get:function(){return n._DELAYLOADSTATE_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(n,"DELAYLOADSTATE_LOADED",{get:function(){return n._DELAYLOADSTATE_LOADED},enumerable:!0,configurable:!0}),Object.defineProperty(n,"DELAYLOADSTATE_LOADING",{get:function(){return n._DELAYLOADSTATE_LOADING},enumerable:!0,configurable:!0}),Object.defineProperty(n,"DELAYLOADSTATE_NOTLOADED",{get:function(){return n._DELAYLOADSTATE_NOTLOADED},enumerable:!0,configurable:!0}),Object.defineProperty(n,"TEXTUREFORMAT_ALPHA",{get:function(){return n._TEXTUREFORMAT_ALPHA},enumerable:!0,configurable:!0}),Object.defineProperty(n,"TEXTUREFORMAT_LUMINANCE",{get:function(){return n._TEXTUREFORMAT_LUMINANCE},enumerable:!0,configurable:!0}),Object.defineProperty(n,"TEXTUREFORMAT_LUMINANCE_ALPHA",{get:function(){return n._TEXTUREFORMAT_LUMINANCE_ALPHA},enumerable:!0,configurable:!0}),Object.defineProperty(n,"TEXTUREFORMAT_RGB",{get:function(){return n._TEXTUREFORMAT_RGB},enumerable:!0,configurable:!0}),Object.defineProperty(n,"TEXTUREFORMAT_RGBA",{get:function(){return n._TEXTUREFORMAT_RGBA},enumerable:!0,configurable:!0}),Object.defineProperty(n,"TEXTURETYPE_UNSIGNED_INT",{get:function(){return n._TEXTURETYPE_UNSIGNED_INT},enumerable:!0,configurable:!0}),Object.defineProperty(n,"TEXTURETYPE_FLOAT",{get:function(){return n._TEXTURETYPE_FLOAT},enumerable:!0,configurable:!0}),Object.defineProperty(n,"TEXTURETYPE_HALF_FLOAT",{get:function(){return n._TEXTURETYPE_HALF_FLOAT},enumerable:!0,configurable:!0}),Object.defineProperty(n,"SCALEMODE_FLOOR",{get:function(){return n._SCALEMODE_FLOOR},enumerable:!0,configurable:!0}),Object.defineProperty(n,"SCALEMODE_NEAREST",{get:function(){return n._SCALEMODE_NEAREST},enumerable:!0,configurable:!0}),Object.defineProperty(n,"SCALEMODE_CEILING",{get:function(){return n._SCALEMODE_CEILING},enumerable:!0,configurable:!0}),Object.defineProperty(n,"Version",{get:function(){return"3.0-beta"},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"texturesSupported",{get:function(){return this._texturesSupported},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"textureFormatInUse",{get:function(){return this._textureFormatInUse},enumerable:!0,configurable:!0}),Object.defineProperty(n.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(n.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(n.prototype,"webGLVersion",{get:function(){return this._webGLVersion},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"isStencilEnable",{get:function(){return this._isStencilEnable},enumerable:!0,configurable:!0}),n.prototype._prepareWorkingCanvas=function(){this._workingCanvas||(this._workingCanvas=document.createElement("canvas"),this._workingContext=this._workingCanvas.getContext("2d"))},n.prototype.resetTextureCache=function(){for(var e=0;e<this._maxTextureChannels;e++)this._activeTexturesCache[e]=null},n.prototype.getGlInfo=function(){return{vendor:this._glVendor,renderer:this._glRenderer,version:this._glVersion}},n.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)},n.prototype.getRenderWidth=function(e){return void 0===e&&(e=!1),!e&&this._currentRenderTarget?this._currentRenderTarget._width:this._renderingCanvas.width},n.prototype.getRenderHeight=function(e){return void 0===e&&(e=!1),!e&&this._currentRenderTarget?this._currentRenderTarget._height:this._renderingCanvas.height},n.prototype.getRenderingCanvas=function(){return this._renderingCanvas},n.prototype.getRenderingCanvasClientRect=function(){return this._renderingCanvas.getBoundingClientRect()},n.prototype.setHardwareScalingLevel=function(e){this._hardwareScalingLevel=e,this.resize()},n.prototype.getHardwareScalingLevel=function(){return this._hardwareScalingLevel},n.prototype.getLoadedTexturesCache=function(){return this._loadedTexturesCache},n.prototype.getCaps=function(){return this._caps},Object.defineProperty(n.prototype,"drawCalls",{get:function(){return this._drawCalls.current},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"drawCallsPerfCounter",{get:function(){return this._drawCalls},enumerable:!0,configurable:!0}),n.prototype.getDepthFunction=function(){return this._depthCullingState.depthFunc},n.prototype.setDepthFunction=function(e){this._depthCullingState.depthFunc=e},n.prototype.setDepthFunctionToGreater=function(){this._depthCullingState.depthFunc=this._gl.GREATER},n.prototype.setDepthFunctionToGreaterOrEqual=function(){this._depthCullingState.depthFunc=this._gl.GEQUAL},n.prototype.setDepthFunctionToLess=function(){this._depthCullingState.depthFunc=this._gl.LESS},n.prototype.setDepthFunctionToLessOrEqual=function(){this._depthCullingState.depthFunc=this._gl.LEQUAL},n.prototype.getStencilBuffer=function(){return this._stencilState.stencilTest},n.prototype.setStencilBuffer=function(e){this._stencilState.stencilTest=e},n.prototype.getStencilMask=function(){return this._stencilState.stencilMask},n.prototype.setStencilMask=function(e){this._stencilState.stencilMask=e},n.prototype.getStencilFunction=function(){return this._stencilState.stencilFunc},n.prototype.getStencilFunctionReference=function(){return this._stencilState.stencilFuncRef},n.prototype.getStencilFunctionMask=function(){return this._stencilState.stencilFuncMask},n.prototype.setStencilFunction=function(e){this._stencilState.stencilFunc=e},n.prototype.setStencilFunctionReference=function(e){this._stencilState.stencilFuncRef=e},n.prototype.setStencilFunctionMask=function(e){this._stencilState.stencilFuncMask=e},n.prototype.getStencilOperationFail=function(){return this._stencilState.stencilOpStencilFail},n.prototype.getStencilOperationDepthFail=function(){return this._stencilState.stencilOpDepthFail},n.prototype.getStencilOperationPass=function(){return this._stencilState.stencilOpStencilDepthPass},n.prototype.setStencilOperationFail=function(e){this._stencilState.stencilOpStencilFail=e},n.prototype.setStencilOperationDepthFail=function(e){this._stencilState.stencilOpDepthFail=e},n.prototype.setStencilOperationPass=function(e){this._stencilState.stencilOpStencilDepthPass=e},n.prototype.setDitheringState=function(e){e?this._gl.enable(this._gl.DITHER):this._gl.disable(this._gl.DITHER)},n.prototype.stopRenderLoop=function(e){if(!e)return void(this._activeRenderLoops=[]);var t=this._activeRenderLoops.indexOf(e);t>=0&&this._activeRenderLoops.splice(t,1)},n.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},n.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)))},n.prototype.switchFullscreen=function(t){this.isFullscreen?e.Tools.ExitFullscreen():(this._pointerLockRequested=t,e.Tools.RequestFullscreen(this._renderingCanvas))},n.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)},n.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)},n.prototype.setViewport=function(e,t,r){var i=t||(navigator.isCocoonJS?window.innerWidth:this.getRenderWidth()),n=r||(navigator.isCocoonJS?window.innerHeight: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)},n.prototype.setDirectViewport=function(e,t,r,i){var n=this._cachedViewport;return this._cachedViewport=null,this._gl.viewport(e,t,r,i),n},n.prototype.beginFrame=function(){this._measureFps()},n.prototype.endFrame=function(){this._badOS&&this.flushFramebuffer(),this._vrDisplayEnabled&&this._vrDisplayEnabled.isPresenting&&this._vrDisplayEnabled.submitFrame()},n.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)}},n.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)}},n.prototype.isVRDevicePresent=function(e){this.getVRDevice(null,(function(t){e(null!==t)}))},n.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)}))},n.prototype.initWebVR=function(){this.vrDisplaysPromise||this._getVRDisplays()},n.prototype.enableVR=function(e){this._vrDisplayEnabled=e,this._vrDisplayEnabled.requestPresent([{source:this.getRenderingCanvas()}]).then(this._onVRFullScreenTriggered)},n.prototype.disableVR=function(){this._vrDisplayEnabled&&this._vrDisplayEnabled.exitPresent().then(this._onVRFullScreenTriggered)},n.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))},n.prototype.bindFramebuffer=function(e,t,r,i){this._currentRenderTarget=e,this.bindUnboundFramebuffer(e._MSAAFramebuffer?e._MSAAFramebuffer:e._framebuffer);var n=this._gl;e.isCube&&n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+t,e,0),n.viewport(0,0,r||e._width,i||e._height),this.wipeCaches()},n.prototype.bindUnboundFramebuffer=function(e){this._currentFramebuffer!==e&&(this._gl.bindFramebuffer(this._gl.FRAMEBUFFER,e),this._currentFramebuffer=e)},n.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&&(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)},n.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)}},n.prototype.flushFramebuffer=function(){this._gl.flush()},n.prototype.restoreDefaultFramebuffer=function(){this._currentRenderTarget=null,this.bindUnboundFramebuffer(null),this._cachedViewport&&this.setViewport(this._cachedViewport),this.wipeCaches()},n.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},n.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},n.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)},n.prototype._resetVertexBufferBinding=function(){this.bindArrayBuffer(null),this._cachedVertexBuffers=null},n.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},n.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},n.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()},n.prototype._resetIndexBufferBinding=function(){this.bindIndexBuffer(null),this._cachedIndexBuffer=null},n.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},n.prototype.bindArrayBuffer=function(e){this._vaoRecordInProgress||this._unBindVertexArrayObject(),this.bindBuffer(e,this._gl.ARRAY_BUFFER)},n.prototype.bindUniformBuffer=function(e){this._gl.bindBuffer(this._gl.UNIFORM_BUFFER,e)},n.prototype.bindUniformBufferBase=function(e,t){this._gl.bindBufferBase(this._gl.UNIFORM_BUFFER,t,e)},n.prototype.bindUniformBlock=function(e,t,r){var i=this._gl.getUniformBlockIndex(e,t);this._gl.uniformBlockBinding(e,i,r)},n.prototype.bindIndexBuffer=function(e){this._vaoRecordInProgress||this._unBindVertexArrayObject(),this.bindBuffer(e,this._gl.ELEMENT_ARRAY_BUFFER)},n.prototype.bindBuffer=function(e,t){(this._vaoRecordInProgress||this._currentBoundBuffer[t]!==e)&&(this._gl.bindBuffer(t,e),this._currentBoundBuffer[t]=e)},n.prototype.updateArrayBuffer=function(e){this._gl.bufferSubData(this._gl.ARRAY_BUFFER,0,e)},n.prototype.vertexAttribPointer=function(e,t,r,i,n,o,s){var a=this._currentBufferPointers[t],u=!1;a?(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,this._currentBufferPointers[t]={indx:t,size:r,type:i,normalized:n,stride:o,offset:s,buffer:e}),(u||this._vaoRecordInProgress)&&(this.bindArrayBuffer(e),this._gl.vertexAttribPointer(t,r,i,n,o,s))},n.prototype._bindIndexBufferWithCache=function(e){null!=e&&this._cachedIndexBuffer!==e&&(this._cachedIndexBuffer=e,this.bindIndexBuffer(e),this._uintIndicesCurrentlySet=e.is32Bits)},n.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,1),this._vaoRecordInProgress||(this._currentInstanceLocations.push(n),this._currentInstanceBuffers.push(s)))}}},n.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},n.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)},n.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)},n.prototype._unBindVertexArrayObject=function(){this._cachedVertexArrayObject&&(this._cachedVertexArrayObject=null,this._gl.bindVertexArray(null))},n.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)},n.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},n.prototype.releaseVertexArrayObject=function(e){this._gl.deleteVertexArray(e)},n.prototype._releaseBuffer=function(e){return 0===--e.references&&(this._gl.deleteBuffer(e),!0)},n.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},n.prototype.deleteInstancesBuffer=function(e){this._gl.deleteBuffer(e)},n.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)}},n.prototype.applyStates=function(){this._depthCullingState.apply(this._gl),this._stencilState.apply(this._gl),this._alphaState.apply(this._gl)},n.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)},n.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)},n.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)},n.prototype._releaseEffect=function(e){this._compiledEffects[e._key]&&(delete this._compiledEffects[e._key],e.getProgram()&&this._gl.deleteProgram(e.getProgram()))},n.prototype.createEffect=function(t,r,i,n,o,s,a,u,h){var l=t.vertexElement||t.vertex||t,c=t.fragmentElement||t.fragment||t,f=l+"+"+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,h);return p._key=f,this._compiledEffects[f]=p,p},n.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)},n.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)){var h=n.getProgramInfoLog(u);if(h)throw new Error(h)}return n.deleteShader(s),n.deleteShader(a),u},n.prototype.getUniforms=function(e,t){for(var r=[],i=0;i<t.length;i++)r.push(this._gl.getUniformLocation(e,t[i]));return r},n.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},n.prototype.enableEffect=function(e){this.setProgram(e.getProgram()),this._currentEffect=e,e.onBind&&e.onBind(e),e.onBindObservable.notifyObservers(e)},n.prototype.setIntArray=function(e,t){e&&this._gl.uniform1iv(e,t)},n.prototype.setIntArray2=function(e,t){e&&t.length%2==0&&this._gl.uniform2iv(e,t)},n.prototype.setIntArray3=function(e,t){e&&t.length%3==0&&this._gl.uniform3iv(e,t)},n.prototype.setIntArray4=function(e,t){e&&t.length%4==0&&this._gl.uniform4iv(e,t)},n.prototype.setFloatArray=function(e,t){e&&this._gl.uniform1fv(e,t)},n.prototype.setFloatArray2=function(e,t){e&&t.length%2==0&&this._gl.uniform2fv(e,t)},n.prototype.setFloatArray3=function(e,t){e&&t.length%3==0&&this._gl.uniform3fv(e,t)},n.prototype.setFloatArray4=function(e,t){e&&t.length%4==0&&this._gl.uniform4fv(e,t)},n.prototype.setArray=function(e,t){e&&this._gl.uniform1fv(e,t)},n.prototype.setArray2=function(e,t){e&&t.length%2==0&&this._gl.uniform2fv(e,t)},n.prototype.setArray3=function(e,t){e&&t.length%3==0&&this._gl.uniform3fv(e,t)},n.prototype.setArray4=function(e,t){e&&t.length%4==0&&this._gl.uniform4fv(e,t)},n.prototype.setMatrices=function(e,t){e&&this._gl.uniformMatrix4fv(e,!1,t)},n.prototype.setMatrix=function(e,t){e&&this._gl.uniformMatrix4fv(e,!1,t.toArray())},n.prototype.setMatrix3x3=function(e,t){e&&this._gl.uniformMatrix3fv(e,!1,t)},n.prototype.setMatrix2x2=function(e,t){e&&this._gl.uniformMatrix2fv(e,!1,t)},n.prototype.setFloat=function(e,t){e&&this._gl.uniform1f(e,t)},n.prototype.setFloat2=function(e,t,r){e&&this._gl.uniform2f(e,t,r)},n.prototype.setFloat3=function(e,t,r,i){e&&this._gl.uniform3f(e,t,r,i)},n.prototype.setBool=function(e,t){e&&this._gl.uniform1i(e,t)},n.prototype.setFloat4=function(e,t,r,i,n){e&&this._gl.uniform4f(e,t,r,i,n)},n.prototype.setColor3=function(e,t){e&&this._gl.uniform3f(e,t.r,t.g,t.b)},n.prototype.setColor4=function(e,t,r){e&&this._gl.uniform4f(e,t.r,t.g,t.b,r)},n.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)},n.prototype.setZOffset=function(e){this._depthCullingState.zOffset=e},n.prototype.getZOffset=function(){return this._depthCullingState.zOffset},n.prototype.setDepthBuffer=function(e){this._depthCullingState.depthTest=e},n.prototype.getDepthWrite=function(){return this._depthCullingState.depthMask},n.prototype.setDepthWrite=function(e){this._depthCullingState.depthMask=e},n.prototype.setColorWrite=function(e){this._gl.colorMask(e,e,e,e)},n.prototype.setAlphaConstants=function(e,t,r,i){this._alphaState.setAlphaBlendConstants(e,t,r,i)},n.prototype.setAlphaMode=function(e,t){if(void 0===t&&(t=!1),this._alphaMode!==e){switch(e){case n.ALPHA_DISABLE:this._alphaState.alphaBlend=!1;break;case n.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 n.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 n.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 n.ALPHA_ONEONE:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE,this._gl.ONE,this._gl.ZERO,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case n.ALPHA_ADD:this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA,this._gl.ONE,this._gl.ZERO,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case n.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 n.ALPHA_MULTIPLY:this._alphaState.setAlphaBlendFunctionParameters(this._gl.DST_COLOR,this._gl.ZERO,this._gl.ONE,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case n.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 n.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 n.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===n.ALPHA_DISABLE),this._alphaMode=e}},n.prototype.getAlphaMode=function(){return this._alphaMode},n.prototype.setAlphaTesting=function(e){this._alphaTest=e},n.prototype.getAlphaTesting=function(){return!!this._alphaTest},n.prototype.wipeCaches=function(e){this.preventCacheWipeBetweenFrames||(this.resetTextureCache(),this._currentEffect=null,e&&(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))},n.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},n.prototype.createTexture=function(t,r,n,o,s,a,u,h,l,c){var f=this;void 0===s&&(s=e.Texture.TRILINEAR_SAMPLINGMODE),void 0===a&&(a=null),void 0===u&&(u=null),void 0===h&&(h=null);var d=l||this._gl.createTexture(),p=String(t),_="data:"===p.substr(0,5),m=_&&-1!==p.indexOf("base64"),g=p.lastIndexOf("."),v=g>0?p.substring(g).toLowerCase():"",y=this.getCaps().s3tc&&".dds"===v;y&&e.Tools.Warn("DDS files deprecated since 3.0, use KTX files");var T=".tga"===v,x=!1;!this._textureFormatInUse||m||l||(p=p.substring(0,g)+this._textureFormatInUse,x=!0),o._addPendingData(d),d.url=p,d.noMipmap=r,d.references=1,d.samplingMode=s,d.onLoadedCallbacks=[],a&&d.onLoadedCallbacks.push(a),l||this._loadedTexturesCache.push(d);var E,b=function(){o._removePendingData(d),x?f.createTexture(t,r,n,o,s,null,u,h,d):u&&u()};if(x||T||y)x?E=function(t){var a=new e.Internals.KhronosTextureContainer(t,1);i(d,f._gl,o,a.pixelWidth,a.pixelHeight,n,!1,!0,(function(){a.uploadLevels(f._gl,!r)}),s)}:T?E=function(t){var a=new Uint8Array(t),u=e.Internals.TGATools.GetTGAHeader(a);i(d,f._gl,o,u.width,u.height,n,r,!1,(function(){e.Internals.TGATools.UploadContent(f._gl,a)}),s)}:y&&(E=function(t){var a=e.Internals.DDSTools.GetDDSInfo(t),u=(a.isRGB||a.isLuminance||a.mipmapCount>1)&&!r&&a.width>>a.mipmapCount-1==1;i(d,f._gl,o,a.width,a.height,n,!u,a.isFourCC,(function(){e.Internals.DDSTools.UploadDDSLevels(f._gl,f.getCaps().s3tc,t,a,u,1)}),s)}),h?E(h):e.Tools.LoadFile(p,(function(e){E(e)}),null,o.database,!0,b);else{var A=function(t){i(d,f._gl,o,t.width,t.height,n,r,!1,(function(r,i){var n=t.width===r&&t.height===i;n||(f._prepareWorkingCanvas(),f._workingCanvas.width=r,f._workingCanvas.height=i,s===e.Texture.NEAREST_SAMPLINGMODE&&(f._workingContext.imageSmoothingEnabled=!1,f._workingContext.mozImageSmoothingEnabled=!1,f._workingContext.oImageSmoothingEnabled=!1,f._workingContext.webkitImageSmoothingEnabled=!1,f._workingContext.msImageSmoothingEnabled=!1),f._workingContext.drawImage(t,0,0,t.width,t.height,0,0,r,i),s===e.Texture.NEAREST_SAMPLINGMODE&&(f._workingContext.imageSmoothingEnabled=!0,f._workingContext.mozImageSmoothingEnabled=!0,f._workingContext.oImageSmoothingEnabled=!0,f._workingContext.webkitImageSmoothingEnabled=!0,f._workingContext.msImageSmoothingEnabled=!0));var o=c?f._getInternalFormat(c):".jpg"===v?f._gl.RGB:f._gl.RGBA;f._gl.texImage2D(f._gl.TEXTURE_2D,0,o,o,f._gl.UNSIGNED_BYTE,n?t:f._workingCanvas)}),s)};!_||m?e.Tools.LoadImage(p,A,b,o.database):h instanceof Array||"string"==typeof h?e.Tools.LoadImage(h,A,b,o.database):A(h)}return d},n.prototype._getInternalFormat=function(e){var t=this._gl.RGBA;switch(e){case n.TEXTUREFORMAT_ALPHA:t=this._gl.ALPHA;break;case n.TEXTUREFORMAT_LUMINANCE:t=this._gl.LUMINANCE;break;case n.TEXTUREFORMAT_LUMINANCE_ALPHA:t=this._gl.LUMINANCE_ALPHA;break;case n.TEXTUREFORMAT_RGB:t=this._gl.RGB;break;case n.TEXTUREFORMAT_RGBA:t=this._gl.RGBA}return t},n.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},n.prototype.createRawTexture=function(e,t,i,n,o,s,a,u){void 0===u&&(u=null);var h=this._gl.createTexture();h._baseWidth=t,h._baseHeight=i,h._width=t,h._height=i,h.references=1,this.updateRawTexture(h,e,n,s,u),this._bindTextureDirectly(this._gl.TEXTURE_2D,h);var l=r(a,o,this._gl);return this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MAG_FILTER,l.mag),this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MIN_FILTER,l.min),o&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(this._gl.TEXTURE_2D,null),h.samplingMode=a,this._loadedTexturesCache.push(h),h},n.prototype.createDynamicTexture=function(t,r,i,n){var o=this._gl.createTexture();return o._baseWidth=t,o._baseHeight=r,i&&(t=e.Tools.GetExponentOfTwo(t,this._caps.maxTextureSize),r=e.Tools.GetExponentOfTwo(r,this._caps.maxTextureSize)),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},n.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},n.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},n.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}}},n.prototype.createRenderTargetTexture=function(t,i){var o=!1,s=!0,a=!1,u=n.TEXTURETYPE_UNSIGNED_INT,h=e.Texture.TRILINEAR_SAMPLINGMODE;void 0!==i&&(o=void 0===i.generateMipMaps?i:i.generateMipMaps,s=void 0===i.generateDepthBuffer||i.generateDepthBuffer,a=s&&i.generateStencilBuffer,u=void 0===i.type?u:i.type,void 0!==i.samplingMode&&(h=i.samplingMode),u!==n.TEXTURETYPE_FLOAT||this._caps.textureFloatLinearFiltering?u!==n.TEXTURETYPE_HALF_FLOAT||this._caps.textureHalfFloatLinearFiltering||(h=e.Texture.NEAREST_SAMPLINGMODE):h=e.Texture.NEAREST_SAMPLINGMODE);var l=this._gl,c=l.createTexture();this._bindTextureDirectly(l.TEXTURE_2D,c);var f=t.width||t,d=t.height||t,p=r(h,o,l);u!==n.TEXTURETYPE_FLOAT||this._caps.textureFloat||(u=n.TEXTURETYPE_UNSIGNED_INT,e.Tools.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type")),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MAG_FILTER,p.mag),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MIN_FILTER,p.min),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_S,l.CLAMP_TO_EDGE),l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_T,l.CLAMP_TO_EDGE),l.texImage2D(l.TEXTURE_2D,0,this._getRGBABufferInternalSizedFormat(u),f,d,0,l.RGBA,this._getWebGLTextureType(u),null);var _=l.createFramebuffer();return this.bindUnboundFramebuffer(_),l.framebufferTexture2D(l.FRAMEBUFFER,l.COLOR_ATTACHMENT0,l.TEXTURE_2D,c,0),c._depthStencilBuffer=this._setupFramebufferDepthAttachments(a,s,f,d),o&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(l.TEXTURE_2D,null),l.bindRenderbuffer(l.RENDERBUFFER,null),this.bindUnboundFramebuffer(null),c._framebuffer=_,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=h,c.type=u,c._generateDepthBuffer=s,c._generateStencilBuffer=a,this.resetTextureCache(),this._loadedTexturesCache.push(c),c},n.prototype.createMultipleRenderTarget=function(t,i){var o=!1,s=!0,a=!1,u=!1,h=1,l=n.TEXTURETYPE_UNSIGNED_INT,c=e.Texture.TRILINEAR_SAMPLINGMODE,f=[],d=[];void 0!==i&&(o=i.generateMipMaps,s=void 0===i.generateDepthBuffer||i.generateDepthBuffer,a=i.generateStencilBuffer,u=i.generateDepthTexture,h=i.textureCount||1,i.types&&(f=i.types),i.samplingModes&&(d=i.samplingModes));var p=this._gl,_=p.createFramebuffer();this.bindUnboundFramebuffer(_);for(var m=t.width||t,g=t.height||t,v=[],y=[],T=this._setupFramebufferDepthAttachments(a,s,m,g),x=0;x<h;x++){var E=d[x]||c,b=f[x]||l;b!==n.TEXTURETYPE_FLOAT||this._caps.textureFloatLinearFiltering?b!==n.TEXTURETYPE_HALF_FLOAT||this._caps.textureHalfFloatLinearFiltering||(E=e.Texture.NEAREST_SAMPLINGMODE):E=e.Texture.NEAREST_SAMPLINGMODE;var A=r(E,o,p);b!==n.TEXTURETYPE_FLOAT||this._caps.textureFloat||(b=n.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"+x];v.push(M),y.push(P),p.activeTexture(p["TEXTURE"+x]),p.bindTexture(p.TEXTURE_2D,M),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MAG_FILTER,A.mag),p.texParameteri(p.TEXTURE_2D,p.TEXTURE_MIN_FILTER,A.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,g,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=_,M._depthStencilBuffer=T,M._baseWidth=m,M._baseHeight=g,M._width=m,M._height=g,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,g,0,p.DEPTH_COMPONENT,p.UNSIGNED_SHORT,null),p.framebufferTexture2D(p.FRAMEBUFFER,p.DEPTH_ATTACHMENT,p.TEXTURE_2D,R,0),R._framebuffer=_,R._baseWidth=m,R._baseHeight=g,R._width=m,R._height=g,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},n.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.DEPTH_STENCIL,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},n.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},n.prototype.createRenderTargetCubeTexture=function(t,i){var n=this._gl,o=n.createTexture(),s=!0,a=!0,u=!1,h=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&&(h=i.samplingMode)),o.isCube=!0,o.references=1,o.generateMipMaps=s,o.references=1,o.samples=1,o.samplingMode=h;var l=r(h,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,l.mag),n.texParameteri(n.TEXTURE_CUBE_MAP,n.TEXTURE_MIN_FILTER,l.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},n.prototype.createCubeTexture=function(t,r,i,n,s,a,u){var h=this;void 0===s&&(s=null),void 0===a&&(a=null);var l=this._gl,c=l.createTexture();c.isCube=!0,c.url=t,c.references=1,c.onLoadedCallbacks=[];var f=!1,d=t.lastIndexOf("."),p=t.substring(d).toLowerCase();this._textureFormatInUse&&(p=this._textureFormatInUse,t=t.substring(0,d)+this._textureFormatInUse,f=!0);var _=this.getCaps().s3tc&&".dds"===p;return _&&e.Tools.Warn("DDS files deprecated since 3.0, use KTX files"),f?e.Tools.LoadFile(t,(function(t){var r=new e.Internals.KhronosTextureContainer(t,6),i=r.numberOfMipmapLevels>1&&!n;h._bindTextureDirectly(l.TEXTURE_CUBE_MAP,c),l.pixelStorei(l.UNPACK_FLIP_Y_WEBGL,1),r.uploadLevels(h._gl,!n),l.texParameteri(l.TEXTURE_CUBE_MAP,l.TEXTURE_MAG_FILTER,l.LINEAR),l.texParameteri(l.TEXTURE_CUBE_MAP,l.TEXTURE_MIN_FILTER,i?l.LINEAR_MIPMAP_LINEAR:l.LINEAR),l.texParameteri(l.TEXTURE_CUBE_MAP,l.TEXTURE_WRAP_S,l.CLAMP_TO_EDGE),l.texParameteri(l.TEXTURE_CUBE_MAP,l.TEXTURE_WRAP_T,l.CLAMP_TO_EDGE),h._bindTextureDirectly(l.TEXTURE_CUBE_MAP,null),h.resetTextureCache(),c._width=r.pixelWidth,c._height=r.pixelHeight,c.isReady=!0}),null,null,!0,a):_?e.Tools.LoadFile(t,(function(t){var r=e.Internals.DDSTools.GetDDSInfo(t),i=(r.isRGB||r.isLuminance||r.mipmapCount>1)&&!n;h._bindTextureDirectly(l.TEXTURE_CUBE_MAP,c),l.pixelStorei(l.UNPACK_FLIP_Y_WEBGL,1),e.Internals.DDSTools.UploadDDSLevels(h._gl,h.getCaps().s3tc,t,r,i,6),n||r.isFourCC||1!==r.mipmapCount||l.generateMipmap(l.TEXTURE_CUBE_MAP),l.texParameteri(l.TEXTURE_CUBE_MAP,l.TEXTURE_MAG_FILTER,l.LINEAR),l.texParameteri(l.TEXTURE_CUBE_MAP,l.TEXTURE_MIN_FILTER,i?l.LINEAR_MIPMAP_LINEAR:l.LINEAR),l.texParameteri(l.TEXTURE_CUBE_MAP,l.TEXTURE_WRAP_S,l.CLAMP_TO_EDGE),l.texParameteri(l.TEXTURE_CUBE_MAP,l.TEXTURE_WRAP_T,l.CLAMP_TO_EDGE),h._bindTextureDirectly(l.TEXTURE_CUBE_MAP,null),h.resetTextureCache(),c._width=r.width,c._height=r.height,c.isReady=!0}),null,null,!0,a):o(0,r,(function(t){var r=e.Tools.GetExponentOfTwo(t[0].width,h._caps.maxCubemapTextureSize),i=r;h._prepareWorkingCanvas(),h._workingCanvas.width=r,h._workingCanvas.height=i;var o=[l.TEXTURE_CUBE_MAP_POSITIVE_X,l.TEXTURE_CUBE_MAP_POSITIVE_Y,l.TEXTURE_CUBE_MAP_POSITIVE_Z,l.TEXTURE_CUBE_MAP_NEGATIVE_X,l.TEXTURE_CUBE_MAP_NEGATIVE_Y,l.TEXTURE_CUBE_MAP_NEGATIVE_Z];h._bindTextureDirectly(l.TEXTURE_CUBE_MAP,c),l.pixelStorei(l.UNPACK_FLIP_Y_WEBGL,0);for(var a=u?h._getInternalFormat(u):h._gl.RGBA,f=0;f<o.length;f++)h._workingContext.drawImage(t[f],0,0,t[f].width,t[f].height,0,0,r,i),l.texImage2D(o[f],0,a,a,l.UNSIGNED_BYTE,h._workingCanvas);n||l.generateMipmap(l.TEXTURE_CUBE_MAP),l.texParameteri(l.TEXTURE_CUBE_MAP,l.TEXTURE_MAG_FILTER,l.LINEAR),l.texParameteri(l.TEXTURE_CUBE_MAP,l.TEXTURE_MIN_FILTER,n?l.LINEAR:l.LINEAR_MIPMAP_LINEAR),l.texParameteri(l.TEXTURE_CUBE_MAP,l.TEXTURE_WRAP_S,l.CLAMP_TO_EDGE),l.texParameteri(l.TEXTURE_CUBE_MAP,l.TEXTURE_WRAP_T,l.CLAMP_TO_EDGE),h._bindTextureDirectly(l.TEXTURE_CUBE_MAP,null),h.resetTextureCache(),c._width=r,c._height=i,c.isReady=!0,c.onLoadedCallbacks.forEach((function(e){e()})),s&&s()}),i,a),this._loadedTexturesCache.push(c),c},n.prototype.updateTextureSize=function(e,t,r){e._width=t,e._height=r,e._size=t*r,e._baseWidth=t,e._baseHeight=r},n.prototype.updateRawCubeTexture=function(t,r,i,n,o,s,a){void 0===s&&(s=null),void 0===a&&(a=0);var u=this._gl,h=this._getWebGLTextureType(n),l=this._getInternalFormat(i),c=this._getRGBABufferInternalSizedFormat(n),f=!1;l===u.RGB&&(l=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=[u.TEXTURE_CUBE_MAP_POSITIVE_X,u.TEXTURE_CUBE_MAP_POSITIVE_Y,u.TEXTURE_CUBE_MAP_POSITIVE_Z,u.TEXTURE_CUBE_MAP_NEGATIVE_X,u.TEXTURE_CUBE_MAP_NEGATIVE_Y,u.TEXTURE_CUBE_MAP_NEGATIVE_Z],p=0;p<d.length;p++){var _=r[p];s?u.compressedTexImage2D(d[p],a,this.getCaps().s3tc[s],t._width,t._height,0,_):(f&&(_=this._convertRGBtoRGBATextureData(_,t._width,t._height,n)),u.texImage2D(d[p],a,c,t._width,t._height,0,l,h,_))}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},n.prototype.createRawCubeTexture=function(t,i,o,s,a,u,h,l){void 0===l&&(l=null);var c=this._gl,f=c.createTexture();f.isCube=!0,f.references=1;var d=this._getWebGLTextureType(s),p=this._getInternalFormat(o);this._getRGBABufferInternalSizedFormat(s);p===c.RGB&&(p=c.RGBA);var _=i,m=_;if(f._width=_,f._height=m,e.Tools.IsExponentOfTwo(f._width)&&e.Tools.IsExponentOfTwo(f._height)||(a=!1),f.generateMipMaps=a,t&&this.updateRawCubeTexture(f,t,o,s,u,l),this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,f),t&&a&&this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP),d!==c.FLOAT||this._caps.textureFloatLinearFiltering)if(d!==n.HALF_FLOAT_OES||this._caps.textureHalfFloatLinearFiltering){var g=r(h,a,c);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MAG_FILTER,g.mag),c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MIN_FILTER,g.min)}else c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MAG_FILTER,c.NEAREST),c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MIN_FILTER,c.NEAREST);else c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MAG_FILTER,c.NEAREST),c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MIN_FILTER,c.NEAREST);return 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),this._bindTextureDirectly(c.TEXTURE_CUBE_MAP,null),this._loadedTexturesCache.push(f),f},
- n.prototype.createRawCubeTextureFromUrl=function(t,r,i,n,o,s,a,u,h,l,c,f){var d=this;void 0===h&&(h=null),void 0===l&&(l=null),void 0===c&&(c=e.Texture.TRILINEAR_SAMPLINGMODE),void 0===f&&(f=!1);var p=this._gl,_=this.createRawCubeTexture(null,i,n,o,!s,f,c);r._addPendingData(_),_.url=t;var m=function(){r._removePendingData(_),l&&l()},g=function(e){var t=a(e),i=[p.TEXTURE_CUBE_MAP_POSITIVE_X,p.TEXTURE_CUBE_MAP_POSITIVE_Y,p.TEXTURE_CUBE_MAP_POSITIVE_Z,p.TEXTURE_CUBE_MAP_NEGATIVE_X,p.TEXTURE_CUBE_MAP_NEGATIVE_Y,p.TEXTURE_CUBE_MAP_NEGATIVE_Z],l=_._width;_._height;if(u){var c=d._getWebGLTextureType(o),m=d._getInternalFormat(n),g=d._getRGBABufferInternalSizedFormat(o),v=!1;m===p.RGB&&(m=p.RGBA,v=!0),d._bindTextureDirectly(p.TEXTURE_CUBE_MAP,_),p.pixelStorei(p.UNPACK_FLIP_Y_WEBGL,0);var y=[];y.push(t[0]),y.push(t[3]),y.push(t[1]),y.push(t[4]),y.push(t[2]),y.push(t[5]);for(var T=u(y),x=[0,2,4,1,3,5],E=0;E<T.length;E++){var b=l>>E;for(var A in x){var M=T[E][x[A]];v&&(M=d._convertRGBtoRGBATextureData(M,b,b,o)),p.texImage2D(i[A],E,g,b,b,0,m,c,M)}}d._bindTextureDirectly(p.TEXTURE_CUBE_MAP,null)}else _.generateMipMaps=!s,d.updateRawCubeTexture(_,t,n,o,f);_.isReady=!0,d.resetTextureCache(),r._removePendingData(_),h&&h()};return e.Tools.LoadFile(t,(function(e){g(e)}),m,r.database,!0),_},n.prototype._convertRGBtoRGBATextureData=function(e,t,r,i){var o;o=i===n.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),h=4*(a*t+s);o[h+0]=e[u+0],o[h+1]=e[u+1],o[h+2]=e[u+2],o[h+3]=1}return o},n.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)},n.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)},n.prototype.setProgram=function(e){this._currentProgram!==e&&(this._gl.useProgram(e),this._currentProgram=e)},n.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},n.prototype.activateTexture=function(e){this._activeTexture!==e&&(this._gl.activeTexture(e),this._activeTexture=e)},n.prototype._bindTextureDirectly=function(e,t){this._activeTexturesCache[this._activeTexture]!==t&&(this._gl.bindTexture(e,t),this._activeTexturesCache[this._activeTexture]=t)},n.prototype._bindTexture=function(e,t){e<0||(this.activateTexture(this._gl.TEXTURE0+e),this._bindTextureDirectly(this._gl.TEXTURE_2D,t))},n.prototype.setTextureFromPostProcess=function(e,t){this._bindTexture(e,t._textures.data[t._currentRenderTextureInd])},n.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)},n.prototype.setTexture=function(e,t,r){e<0||(this._gl.uniform1i(t,e),this._setTexture(e,r))},n.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 i=!1;if(r.video)this.activateTexture(this._gl["TEXTURE"+t]),i=!0,r.update();else if(r.delayLoadState===n.DELAYLOADSTATE_NOTLOADED)return void r.delayLoad();var o=r.isReady()?r.getInternalTexture():r.isCube?this.emptyCubeTexture:this.emptyTexture;if(this._activeTexturesCache[t]!==o)if(i||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)}},n.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])}},n.prototype._setAnisotropicLevel=function(t,r){var i=this._caps.textureAnisotropicFilterExtension,n=r.anisotropicFilteringLevel;r.getInternalTexture().samplingMode===e.Texture.NEAREST_SAMPLINGMODE&&(n=1),i&&r._cachedAnisotropicFilteringLevel!==n&&(this._gl.texParameterf(t,i.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(n,this._caps.maxAnisotropy)),r._cachedAnisotropicFilteringLevel=n)},n.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},n.prototype.addExternalData=function(t,r){return this._externalData||(this._externalData=new e.StringDictionary),this._externalData.add(t,r)},n.prototype.getExternalData=function(t){return this._externalData||(this._externalData=new e.StringDictionary),this._externalData.get(t)},n.prototype.getOrAddExternalDataWithFactory=function(t,r){return this._externalData||(this._externalData=new e.StringDictionary),this._externalData.getOrAddWithFactory(t,r)},n.prototype.removeExternalData=function(t){return this._externalData||(this._externalData=new e.StringDictionary),this._externalData.remove(t)},n.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)}},n.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]=null}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]=null)},n.prototype.releaseEffects=function(){for(var e in this._compiledEffects)this._gl.deleteProgram(this._compiledEffects[e]._program);this._compiledEffects={}},n.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.scenes.length;)this.scenes[0].dispose();n.audioEngine&&n.audioEngine.dispose(),this.releaseEffects(),this.unbindAllAttributes(),this._gl=null,this.disableVR(),window.removeEventListener("blur",this._onBlur),window.removeEventListener("focus",this._onFocus),this._renderingCanvas.removeEventListener("blur",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 e=n.Instances.indexOf(this);e>=0&&n.Instances.splice(e,1)},n.prototype.displayLoadingUI=function(){var e=this.loadingScreen;e&&e.displayLoadingUI()},n.prototype.hideLoadingUI=function(){var e=this.loadingScreen;e&&e.hideLoadingUI()},Object.defineProperty(n.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(n.prototype,"loadingUIText",{set:function(e){this.loadingScreen.loadingUIText=e},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"loadingUIBackgroundColor",{set:function(e){this.loadingScreen.loadingUIBackgroundColor=e},enumerable:!0,configurable:!0}),n.prototype.attachContextLostEvent=function(e){this._renderingCanvas.addEventListener("webglcontextlost",e,!1)},n.prototype.attachContextRestoredEvent=function(e){this._renderingCanvas.addEventListener("webglcontextrestored",e,!1)},n.prototype.getVertexShaderSource=function(e){var t=this._gl.getAttachedShaders(e);return this._gl.getShaderSource(t[0])},n.prototype.getFragmentShaderSource=function(e){var t=this._gl.getAttachedShaders(e);return this._gl.getShaderSource(t[1])},n.prototype.getError=function(){return this._gl.getError()},n.prototype.getFps=function(){return this.fps},n.prototype.getDeltaTime=function(){return this.deltaTime},n.prototype._measureFps=function(){this.previousFramesDuration.push(e.Tools.Now);var t=this.previousFramesDuration.length;if(t>=2&&(this.deltaTime=this.previousFramesDuration[t-1]-this.previousFramesDuration[t-2]),t>=this.fpsRange){t>this.fpsRange&&(this.previousFramesDuration.splice(0,1),t=this.previousFramesDuration.length);for(var r=0,i=0;i<t-1;i++)r+=this.previousFramesDuration[i+1]-this.previousFramesDuration[i];this.fps=1e3/(r/(t-1))}},n.prototype._canRenderToFloatFramebuffer=function(){return this._webGLVersion>1?this._caps.colorBufferFloat:this._canRenderToFramebuffer(e.Engine.TEXTURETYPE_FLOAT)},n.prototype._canRenderToHalfFloatFramebuffer=function(){return this._webGLVersion>1?this._caps.colorBufferFloat:this._canRenderToFramebuffer(e.Engine.TEXTURETYPE_HALF_FLOAT)},n.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},n.prototype._getWebGLTextureType=function(e){return e===n.TEXTURETYPE_FLOAT?this._gl.FLOAT:e===n.TEXTURETYPE_HALF_FLOAT?n.HALF_FLOAT_OES:this._gl.UNSIGNED_BYTE},n.prototype._getRGBABufferInternalSizedFormat=function(e){return 1===this._webGLVersion?this._gl.RGBA:e===n.TEXTURETYPE_FLOAT?n.RGBA32F:e===n.TEXTURETYPE_HALF_FLOAT?n.RGBA16F:this._gl.RGBA},n.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}},n})();u.Instances=new Array,u._ALPHA_DISABLE=0,u._ALPHA_ADD=1,u._ALPHA_COMBINE=2,u._ALPHA_SUBTRACT=3,u._ALPHA_MULTIPLY=4,u._ALPHA_MAXIMIZED=5,u._ALPHA_ONEONE=6,u._ALPHA_PREMULTIPLIED=7,u._ALPHA_PREMULTIPLIED_PORTERDUFF=8,u._ALPHA_INTERPOLATE=9,u._ALPHA_SCREENMODE=10,u._DELAYLOADSTATE_NONE=0,u._DELAYLOADSTATE_LOADED=1,u._DELAYLOADSTATE_LOADING=2,u._DELAYLOADSTATE_NOTLOADED=4,u._TEXTUREFORMAT_ALPHA=0,u._TEXTUREFORMAT_LUMINANCE=1,u._TEXTUREFORMAT_LUMINANCE_ALPHA=2,u._TEXTUREFORMAT_RGB=4,u._TEXTUREFORMAT_RGBA=5,u._TEXTURETYPE_UNSIGNED_INT=0,u._TEXTURETYPE_FLOAT=1,u._TEXTURETYPE_HALF_FLOAT=2,u._NEVER=512,u._ALWAYS=519,u._LESS=513,u._EQUAL=514,u._LEQUAL=515,u._GREATER=516,u._GEQUAL=518,u._NOTEQUAL=517,u.HALF_FLOAT_OES=36193,u.RGBA16F=34842,u.RGBA32F=34836,u._KEEP=7680,u._REPLACE=7681,u._INCR=7682,u._DECR=7683,u._INVERT=5386,u._INCR_WRAP=34055,u._DECR_WRAP=34056,u._SCALEMODE_FLOOR=1,u._SCALEMODE_NEAREST=2,u._SCALEMODE_CEILING=3,u.CollisionsEpsilon=.001,u.CodeRepository="src/",u.ShadersRepository="src/Shaders/",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.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.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()},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)}},t})();__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),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)},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.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.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.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,"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.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.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 h=-Math.atan2(a.z,a.x)-Math.PI/2,l=Math.sqrt(a.x*a.x+a.z*a.z),c=Math.atan2(a.y,l);return this.rotationQuaternion=this.rotationQuaternion||new e.Quaternion,e.Quaternion.RotationYawPitchRollToRef(h+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 h=0;h<o;h++){var l=n[h];if(!(o>1)||l.canIntersects(t)){var c=l.intersects(t,this._positions,this.getIndices(),r);if(c&&(r||!s||c.distance<s.distance)&&(s=c,s.subMeshId=h,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 _=e.Vector3.TransformNormal(p,f),m=d.add(_);return i.hit=!0,i.distance=e.Vector3.Distance(d,m),i.pickedPoint=m,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 h=this.getDescendants(!0);for(r=0;r<h.length;r++)h[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 h=e.Matrix.Invert(a),l=r.getWorldMatrix().multiply(h);l.decompose(s,n,o),r.rotationQuaternion?r.rotationQuaternion.copyFrom(n):n.toEulerAnglesToRef(r.rotation),h=e.Matrix.Invert(i.getWorldMatrix());var l=r.getWorldMatrix().multiply(h);l.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 h=e.Tmp.Vector3[8],l=null;return e.Vector3.TransformCoordinatesFromFloatsToRef(t,r,i,u,h),l=this.getClosestFacetAtLocalCoordinates(h.x,h.y,h.z,n,o,s),n&&e.Vector3.TransformCoordinatesFromFloatsToRef(n.x,n.y,n.z,a,n),l},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,h=0,l=0,c=0,f=0,d=0,p=0,_=this.getFacetLocalPositions(),m=this.getFacetLocalNormals(),g=this.getFacetsAtLocalCoordinates(e,t,r);if(!g)return null;for(var v,y,T,x=Number.MAX_VALUE,E=x,b=0;b<g.length;b++)v=g[b],y=m[v],T=_[v],l=(e-T.x)*y.x+(t-T.y)*y.y+(r-T.z)*y.z,(!n||n&&o&&l>=0||n&&!o&&l<=0)&&(l=y.x*T.x+y.y*T.y+y.z*T.z,c=-(y.x*e+y.y*t+y.z*r-l)/(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,h=p-r,(E=a*a+u*u+h*h)<x&&(x=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})(e.Node);t._BILLBOARDMODE_NONE=0,t._BILLBOARDMODE_X=1,t._BILLBOARDMODE_Y=2,t._BILLBOARDMODE_Z=4,t._BILLBOARDMODE_ALL=7,t._rotationAxisCache=new e.Quaternion,t._lookAtVectorCache=new e.Vector3(0,0,0),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})(e.Node);t._LIGHTMAP_DEFAULT=0,t._LIGHTMAP_SPECULAR=1,t._LIGHTMAP_SHADOWSONLY=2,t._INTENSITYMODE_AUTOMATIC=0,t._INTENSITYMODE_LUMINOUSPOWER=1,t._INTENSITYMODE_LUMINOUSINTENSITY=2,t._INTENSITYMODE_ILLUMINANCE=3,t._INTENSITYMODE_LUMINANCE=4,t._LIGHTTYPEID_POINTLIGHT=0,t._LIGHTTYPEID_DIRECTIONALLIGHT=1,t._LIGHTTYPEID_SPOTLIGHT=2,t._LIGHTTYPEID_HEMISPHERICLIGHT=3,__decorate([e.serializeAsColor3()],t.prototype,"diffuse",void 0),__decorate([e.serializeAsColor3()],t.prototype,"specular",void 0),__decorate([e.serialize()],t.prototype,"intensity",void 0),__decorate([e.serialize()],t.prototype,"range",void 0),__decorate([e.serialize()],t.prototype,"intensityMode",null),__decorate([e.serialize()],t.prototype,"radius",null),__decorate([e.serialize()],t.prototype,"_renderPriority",void 0),__decorate([e.expandToProperty("_reorderLightsInScene")],t.prototype,"renderPriority",void 0),__decorate([e.serialize()],t.prototype,"shadowEnabled",void 0),__decorate([e.serialize("excludeWithLayerMask")],t.prototype,"_excludeWithLayerMask",void 0),__decorate([e.serialize("includeOnlyWithLayerMask")],t.prototype,"_includeOnlyWithLayerMask",void 0),__decorate([e.serialize("lightmapMode")],t.prototype,"_lightmapMode",void 0),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._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(){},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 this._computedViewMatrix=this._computeViewMatrix(t),!t&&this._isSynchronizedViewMatrix()?this._computedViewMatrix:(this._refreshFrustumPlanes=!0,this.parent&&this.parent.getWorldMatrix?(this._worldMatrix||(this._worldMatrix=e.Matrix.Identity()),this._computedViewMatrix.invertToRef(this._worldMatrix),this._worldMatrix.multiplyToRef(this.parent.getWorldMatrix(),this._computedViewMatrix),this._globalPosition.copyFromFloats(this._computedViewMatrix.m[12],this._computedViewMatrix.m[13],this._computedViewMatrix.m[14]),this._computedViewMatrix.invert(),this._markSyncedWithParent()):this._globalPosition.copyFrom(this.position),this._cameraRigParams&&this._cameraRigParams.vrPreViewMatrix&&this._computedViewMatrix.multiplyToRef(this._cameraRigParams.vrPreViewMatrix,this._computedViewMatrix),this._currentRenderId=this.getScene().getRenderId(),this._computedViewMatrix)},r.prototype._computeViewMatrix=function(e){return!e&&this._isSynchronizedViewMatrix()?this._computedViewMatrix:(this._computedViewMatrix=this._getViewMatrix(),this._currentRenderId=this.getScene().getRenderId(),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)return 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),this._projectionMatrix;var o=i.getRenderWidth()/2,s=i.getRenderHeight()/2;return n.useRightHandedSystem?e.Matrix.OrthoOffCenterRHToRef(this.orthoLeft||-o,this.orthoRight||o,this.orthoBottom||-s,this.orthoTop||s,this.minZ,this.maxZ,this._projectionMatrix):e.Matrix.OrthoOffCenterLHToRef(this.orthoLeft||-o,this.orthoRight||o,this.orthoBottom||-s,this.orthoTop||s,this.minZ,this.maxZ,this._projectionMatrix),this._projectionMatrix},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.getScene().stopAnimation(this),this.getScene().removeCamera(this);this._rigCameras.length>0;)this._rigCameras.pop().dispose();for(var e=this._postProcesses.length;--e>=0;)this._postProcesses[e].dispose(this);t.prototype.dispose.call(this)},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 h=t.animations[u];s.animations.push(e.Animation.Parse(h))}e.Node.ParseAnimationRanges(s,t,i)}return t.autoAnimate&&i.beginAnimation(s,t.autoAnimateFrom,t.autoAnimateTo,t.autoAnimateLoop,t.autoAnimateSpeed||1),s},r})(e.Node);t._PERSPECTIVE_CAMERA=0,t._ORTHOGRAPHIC_CAMERA=1,t._FOVMODE_VERTICAL_FIXED=0,t._FOVMODE_HORIZONTAL_FIXED=1,t._RIG_MODE_NONE=0,t._RIG_MODE_STEREOSCOPIC_ANAGLYPH=10,t._RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL=11,t._RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED=12,t._RIG_MODE_STEREOSCOPIC_OVERUNDER=13,t._RIG_MODE_VR=20,t._RIG_MODE_WEBVR=21,t.ForceAttachControlToAlwaysPreventDefault=!1,__decorate([e.serializeAsVector3()],t.prototype,"position",void 0),__decorate([e.serializeAsVector3()],t.prototype,"upVector",void 0),__decorate([e.serialize()],t.prototype,"orthoLeft",void 0),__decorate([e.serialize()],t.prototype,"orthoRight",void 0),__decorate([e.serialize()],t.prototype,"orthoBottom",void 0),__decorate([e.serialize()],t.prototype,"orthoTop",void 0),__decorate([e.serialize()],t.prototype,"fov",void 0),__decorate([e.serialize()],t.prototype,"minZ",void 0),__decorate([e.serialize()],t.prototype,"maxZ",void 0),__decorate([e.serialize()],t.prototype,"inertia",void 0),__decorate([e.serialize()],t.prototype,"mode",void 0),__decorate([e.serialize()],t.prototype,"layerMask",void 0),__decorate([e.serialize()],t.prototype,"fovMode",void 0),__decorate([e.serialize()],t.prototype,"cameraRigMode",void 0),__decorate([e.serialize()],t.prototype,"interaxialDistance",void 0),__decorate([e.serialize()],t.prototype,"isStereoscopicSideBySide",void 0),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 h=this._scene.spriteManagers[u];this.dispatchSprites(h)}for(var u=t.MIN_RENDERINGGROUPS;u<t.MAX_RENDERINGGROUPS;u++){this._depthStencilBufferAlreadyCleaned=u===t.MIN_RENDERINGGROUPS;var l=this._renderingGroups[u];if(l||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)),l&&l.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})();t.MAX_RENDERINGGROUPS=4,t.MIN_RENDERINGGROUPS=0,t.AUTOCLEAR=!0,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(s);for(var a=0;a<this._edgesRenderers.length;a++)this._edgesRenderers.data[a].render()},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];0!=(t.layerMask&i.layerMask)&&(i.emitter.position&&e&&-1===e.indexOf(i.emitter)||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})();r._POINTERDOWN=1,r._POINTERUP=2,r._POINTERMOVE=4,r._POINTERWHEEL=8,r._POINTERPICK=16,r._POINTERTAP=32,r._POINTERDOUBLETAP=64,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})();s.STAGE_PRECLEAR=1,s.STAGE_PREOPAQUE=2,s.STAGE_PRETRANSPARENT=3,s.STAGE_POSTTRANSPARENT=4,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.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.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._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()}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,"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}),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.isCachedMaterialValid=function(e,t,r){return void 0===r&&(r=0),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,this.cameraToUseForPointers&&(this._pointerX=this._pointerX-this.cameraToUseForPointers.viewport.x*this._engine.getRenderWidth(),this._pointerY=this._pointerY-this.cameraToUseForPointers.viewport.y*this._engine.getRenderHeight())},i.prototype._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 h=this;void 0===s&&(s=!0),void 0===a&&(a=!0),void 0===u&&(u=!0),this._initActionManager=function(e,t){if(!h._meshPickProceed){var r=h.pick(h._unTranslatedPointerX,h._unTranslatedPointerY,h.pointerDownPredicate,!1,h.cameraToUseForPointers);h._currentPickResult=r,r&&(e=r.hit&&r.pickedMesh?r.pickedMesh.actionManager:null),h._meshPickProceed=!0}return e},this._delayedSimpleClick=function(e,t,r){((new Date).getTime()-h._previousStartingPointerTime>i.DoubleClickDelay&&!h._doubleClickOccured||e!==h._previousButtonPressed)&&(h._doubleClickOccured=!1,t.singleClick=!0,t.ignore=!1,r(t,h._currentPickResult))},this._initClickEvent=function(n,o,s,a){var u=new t;h._currentPickResult=null;var l,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&&(l=h._initActionManager(l,u))&&(c=l.hasPickTriggers),c){var f=s.button;if(u.hasSwiped=Math.abs(h._startingPointerPosition.x-h._pointerX)>i.DragMovementThreshold||Math.abs(h._startingPointerPosition.y-h._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)&&(l=h._initActionManager(l,u))&&(d=!l.hasSpecificTrigger(e.ActionManager.OnDoublePickTrigger)),d?((new Date).getTime()-h._previousStartingPointerTime>i.DoubleClickDelay||f!==h._previousButtonPressed)&&(u.singleClick=!0,a(u,h._currentPickResult)):(h._previousDelayedSimpleClickTimeout=h._delayedSimpleClickTimeout,h._delayedSimpleClickTimeout=window.setTimeout(h._delayedSimpleClick.bind(h,f,u,a),i.DoubleClickDelay));var p=n.hasSpecificMask(r.POINTERDOUBLETAP)||o.hasSpecificMask(r.POINTERDOUBLETAP);!p&&e.ActionManager.HasSpecificTrigger(e.ActionManager.OnDoublePickTrigger)&&(l=h._initActionManager(l,u))&&(p=l.hasSpecificTrigger(e.ActionManager.OnDoublePickTrigger)),p&&(f===h._previousButtonPressed&&(new Date).getTime()-h._previousStartingPointerTime<i.DoubleClickDelay&&!h._doubleClickOccured?!u.hasSwiped&&Math.abs(h._previousStartingPointerPosition.x-h._startingPointerPosition.x)<i.DragMovementThreshold&&Math.abs(h._previousStartingPointerPosition.y-h._startingPointerPosition.y)<i.DragMovementThreshold?(h._previousStartingPointerTime=0,h._doubleClickOccured=!0,u.doubleClick=!0,u.ignore=!1,i.ExclusiveDoubleClickMode&&h._previousDelayedSimpleClickTimeout&&h._previousDelayedSimpleClickTimeout.clearTimeout&&h._previousDelayedSimpleClickTimeout.clearTimeout(),h._previousDelayedSimpleClickTimeout=h._delayedSimpleClickTimeout,a(u,h._currentPickResult)):(h._doubleClickOccured=!1,h._previousStartingPointerTime=h._startingPointerTime,h._previousStartingPointerPosition.x=h._startingPointerPosition.x,h._previousStartingPointerPosition.y=h._startingPointerPosition.y,h._previousButtonPressed=f,h._previousHasSwiped=u.hasSwiped,i.ExclusiveDoubleClickMode?(h._previousDelayedSimpleClickTimeout&&h._previousDelayedSimpleClickTimeout.clearTimeout&&h._previousDelayedSimpleClickTimeout.clearTimeout(),h._previousDelayedSimpleClickTimeout=h._delayedSimpleClickTimeout,a(u,h._previousPickResult)):a(u,h._currentPickResult)):(h._doubleClickOccured=!1,h._previousStartingPointerTime=h._startingPointerTime,h._previousStartingPointerPosition.x=h._startingPointerPosition.x,h._previousStartingPointerPosition.y=h._startingPointerPosition.y,h._previousButtonPressed=f,h._previousHasSwiped=u.hasSwiped))}}u.ignore=!0,a(u,h._currentPickResult)};var l=function(e){return e.isPickable&&e.actionManager&&e.actionManager.hasPointerTriggers};this._onPointerMove=function(e){if(h._updatePointerPosition(e),h.onPrePointerObservable.hasObservers()){var t="mousewheel"===e.type||"DOMMouseScroll"===e.type?r.POINTERWHEEL:r.POINTERMOVE,i=new n(t,e,h._unTranslatedPointerX,h._unTranslatedPointerY);if(h.onPrePointerObservable.notifyObservers(i,t),i.skipOnPointerObservable)return}if(h.cameraToUseForPointers||h.activeCamera){var s=h._engine.getRenderingCanvas();h.pointerMovePredicate||(h.pointerMovePredicate=function(e){return e.isPickable&&e.isVisible&&e.isReady()&&e.isEnabled()&&(h.constantlyUpdateMeshUnderPointer||null!==e.actionManager&&void 0!==e.actionManager)});var a=h.pick(h._unTranslatedPointerX,h._unTranslatedPointerY,h.pointerMovePredicate,!1,h.cameraToUseForPointers);if(a&&a.hit&&a.pickedMesh?(h.setPointerOverSprite(null),h.setPointerOverMesh(a.pickedMesh),h._pointerOverMesh.actionManager&&h._pointerOverMesh.actionManager.hasPointerTriggers?h._pointerOverMesh.actionManager.hoverCursor?s.style.cursor=h._pointerOverMesh.actionManager.hoverCursor:s.style.cursor=h.hoverCursor:s.style.cursor=""):(h.setPointerOverMesh(null),a=h.pickSprite(h._unTranslatedPointerX,h._unTranslatedPointerY,l,!1,h.cameraToUseForPointers),a&&a.hit&&a.pickedSprite?(h.setPointerOverSprite(a.pickedSprite),h._pointerOverSprite.actionManager&&h._pointerOverSprite.actionManager.hoverCursor?s.style.cursor=h._pointerOverSprite.actionManager.hoverCursor:s.style.cursor=h.hoverCursor):(h.setPointerOverSprite(null),s.style.cursor="")),h.onPointerMove&&h.onPointerMove(e,a),h.onPointerObservable.hasObservers()){var t="mousewheel"===e.type||"DOMMouseScroll"===e.type?r.POINTERWHEEL:r.POINTERMOVE,i=new o(t,e,a);h.onPointerObservable.notifyObservers(i,t)}}},this._onPointerDown=function(t){if(h._isButtonPressed=!0,h._pickedDownMesh=null,h._meshPickProceed=!1,h._updatePointerPosition(t),h.onPrePointerObservable.hasObservers()){var s=r.POINTERDOWN,a=new n(s,t,h._unTranslatedPointerX,h._unTranslatedPointerY);if(h.onPrePointerObservable.notifyObservers(a,s),a.skipOnPointerObservable)return}if(h.cameraToUseForPointers||h.activeCamera){h._startingPointerPosition.x=h._pointerX,h._startingPointerPosition.y=h._pointerY,h._startingPointerTime=(new Date).getTime(),h.pointerDownPredicate||(h.pointerDownPredicate=function(e){return e.isPickable&&e.isVisible&&e.isReady()&&e.isEnabled()}),h._pickedDownMesh=null;var u=h.pick(h._unTranslatedPointerX,h._unTranslatedPointerY,h.pointerDownPredicate,!1,h.cameraToUseForPointers);if(u&&u.hit&&u.pickedMesh){h._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(h),i.LongPressDelay)}}if(h.onPointerDown&&h.onPointerDown(t,u),h.onPointerObservable.hasObservers()){var s=r.POINTERDOWN,a=new o(s,t,u);h.onPointerObservable.notifyObservers(a,s)}if(h._pickedDownSprite=null,h.spriteManagers.length>0&&(u=h.pickSprite(h._unTranslatedPointerX,h._unTranslatedPointerY,l,!1,h.cameraToUseForPointers))&&u.hit&&u.pickedSprite&&u.pickedSprite.actionManager){switch(h._pickedDownSprite=u.pickedSprite,t.button){case 0:u.pickedSprite.actionManager.processTrigger(e.ActionManager.OnLeftPickTrigger,e.ActionEvent.CreateNewFromSprite(u.pickedSprite,h,t));break;case 1:u.pickedSprite.actionManager.processTrigger(e.ActionManager.OnCenterPickTrigger,e.ActionEvent.CreateNewFromSprite(u.pickedSprite,h,t));break;case 2:u.pickedSprite.actionManager.processTrigger(e.ActionManager.OnRightPickTrigger,e.ActionEvent.CreateNewFromSprite(u.pickedSprite,h,t))}u.pickedSprite.actionManager&&u.pickedSprite.actionManager.processTrigger(e.ActionManager.OnPickDownTrigger,e.ActionEvent.CreateNewFromSprite(u.pickedSprite,h,t))}}},this._onPointerUp=function(t){h._isButtonPressed=!1,h._pickedUpMesh=null,h._meshPickProceed=!1,h._updatePointerPosition(t),h._initClickEvent(h.onPrePointerObservable,h.onPointerObservable,t,function(s,a){if(this.onPrePointerObservable.hasObservers())if(s.ignore){var u=r.POINTERUP,h=new n(u,t,this._unTranslatedPointerX,this._unTranslatedPointerY);if(this.onPrePointerObservable.notifyObservers(h,u),h.skipOnPointerObservable)return}else if(!s.hasSwiped){if(s.singleClick&&this.onPrePointerObservable.hasSpecificMask(r.POINTERTAP)){var u=r.POINTERTAP,h=new n(u,t,this._unTranslatedPointerX,this._unTranslatedPointerY);if(this.onPrePointerObservable.notifyObservers(h,u),h.skipOnPointerObservable)return}if(s.doubleClick&&this.onPrePointerObservable.hasSpecificMask(r.POINTERDOUBLETAP)){var u=r.POINTERDOUBLETAP,h=new n(u,t,this._unTranslatedPointerX,this._unTranslatedPointerY);if(this.onPrePointerObservable.notifyObservers(h,u),h.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,h=new o(u,t,a);this.onPointerObservable.notifyObservers(h,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,h=new o(u,t,a);this.onPointerObservable.notifyObservers(h,u)}else if(!s.hasSwiped){if(s.singleClick&&this.onPointerObservable.hasSpecificMask(r.POINTERTAP)){var u=r.POINTERTAP,h=new o(u,t,a);this.onPointerObservable.notifyObservers(h,u)}if(s.doubleClick&&this.onPointerObservable.hasSpecificMask(r.POINTERDOUBLETAP)){var u=r.POINTERDOUBLETAP,h=new o(u,t,a);this.onPointerObservable.notifyObservers(h,u)}}this.spriteManagers.length>0&&(a=this.pickSprite(this._unTranslatedPointerX,this._unTranslatedPointerY,l,!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(h))},this._onKeyDown=function(t){h.actionManager&&h.actionManager.processTrigger(e.ActionManager.OnKeyDownTrigger,e.ActionEvent.CreateNewFromScene(h,t))},this._onKeyUp=function(t){h.actionManager&&h.actionManager.processTrigger(e.ActionManager.OnKeyUpTrigger,e.ActionEvent.CreateNewFromScene(h,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(),h=0;h<u.length;h++)this.beginAnimation(u[h],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),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];u.isStarted()&&((!u.emitter.position||u.emitter&&u.emitter.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 h=this._engine.getStencilBuffer(),l=!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)){l=!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"),l&&this._engine.setStencilBuffer(!0),this._renderingManager.render(null,null,!0,!0),l&&this._engine.setStencilBuffer(h),e.Tools.EndPerformanceCounter("Main render"),this._boundingBoxRenderer&&this._boundingBoxRenderer.render(),this.lensFlaresEnabled){e.Tools.StartPerformanceCounter("Lens flares",this.lensFlareSystems.length>0);for(var _=0;_<this.lensFlareSystems.length;_++){var m=this.lensFlareSystems[_];0!=(t.layerMask&m.layerMask)&&m.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(l){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){this._lastFrameDuration.beginMonitoring(),this._particlesDuration.fetchNewFrame(),this._spritesDuration.fetchNewFrame(),this._activeParticles.fetchNewFrame(),this._renderDuration.fetchNewFrame(),this._renderTargetsDuration.fetchNewFrame(),this._evaluateActiveMeshesDuration.fetchNewFrame(),this._totalVertices.fetchNewFrame(),this._activeIndices.fetchNewFrame(),this._activeBones.fetchNewFrame(),this.getEngine().drawCallsPerfCounter.fetchNewFrame(),this._meshesForIntersections.reset(),this.resetCachedMaterial(),e.Tools.StartPerformanceCounter("Scene rendering"),this.actionManager&&this.actionManager.processTrigger(e.ActionManager.OnEveryFrameTrigger,null),this.simplificationQueue&&!this.simplificationQueue.running&&this.simplificationQueue.executeNext();var t=Math.max(i.MinDeltaTime,Math.min(this._engine.getDeltaTime(),i.MaxDeltaTime));this._animationRatio=.06*t,this._animate(),this._physicsEngine&&(e.Tools.StartPerformanceCounter("Physics"),this._physicsEngine._step(t/1e3),e.Tools.EndPerformanceCounter("Physics")),this.onBeforeRenderObservable.notifyObservers(this),this._renderTargetsDuration.beginMonitoring();var r=(e.Tools.Now,this.getEngine()),n=this.activeCamera;if(this.renderTargetsEnabled){e.Tools.StartPerformanceCounter("Custom render targets",this.customRenderTargets.length>0);for(var o=0;o<this.customRenderTargets.length;o++){var s=this.customRenderTargets[o];if(s._shouldRender()){if(this._renderId++,this.activeCamera=s.activeCamera||this.activeCamera,!this.activeCamera)throw new Error("Active camera not set");r.setViewport(this.activeCamera.viewport),this.updateTransformMatrix(),s.render(n!==this.activeCamera,this.dumpNextRenderTargets)}}e.Tools.EndPerformanceCounter("Custom render targets",this.customRenderTargets.length>0),this._renderId++}if(this.customRenderTargets.length>0&&r.restoreDefaultFramebuffer(),this._renderTargetsDuration.endMonitoring(),this.activeCamera=n,this.proceduralTexturesEnabled){e.Tools.StartPerformanceCounter("Procedural textures",this._proceduralTextures.length>0);for(var a=0;a<this._proceduralTextures.length;a++){var u=this._proceduralTextures[a];u._shouldRender()&&u.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 h=0;h<this.lights.length;h++){var l=this.lights[h],c=l.getShadowGenerator();if(l.isEnabled()&&l.shadowEnabled&&c){var f=c.getShadowMap();-1!==f.getScene().textures.indexOf(f)&&this._renderTargets.push(f)}}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 d=0;d<this.activeCameras.length;d++)d>0&&this._engine.clear(null,!1,!0,!0),this._processSubCameras(this.activeCameras[d]);else{if(!this.activeCamera)throw new Error("No camera defined");this._processSubCameras(this.activeCamera)}this._checkIntersections(),e.AudioEngine&&this._updateAudioParameters(),this.afterRender&&this.afterRender(),this.onAfterRenderObservable.notifyObservers(this);for(var p=0;p<this._toBeDisposed.length;p++)this._toBeDisposed.data[p].dispose(),this._toBeDisposed[p]=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);var i=e.Matrix.Invert(t.getViewMatrix()),n=e.Vector3.TransformNormal(new e.Vector3(0,0,-1),i);n.normalize(),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._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._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();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.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},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),h=s.intersects(u,i);if(h&&h.hit&&((i||null==n||!(h.distance>=n.distance))&&(n=h,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){if(void 0===t&&(t=!1),0===this.lights.length&&new e.HemisphericLight("default light",e.Vector3.Up(),this),!this.activeCamera){var r,i=this.getWorldExtends(),n=i.max.subtract(i.min),o=i.min.add(n.scale(.5)),s=1.5*n.length();if(t){var a=new e.ArcRotateCamera("default camera",4.712,1.571,s,o,this);a.lowerRadiusLimit=.01*s,a.wheelPrecision=100/s,r=a}else{var u=new e.FreeCamera("default camera",new e.Vector3(o.x,o.y,this.useRightHandedSystem?-s:s),this);u.setTarget(o),r=u}r.minZ=.01*s,r.maxZ=100*s,r.speed=.2*s,this.activeCamera=r}},i.prototype.createDefaultSkybox=function(t,r){if(void 0===r&&(r=!1),t&&(this.environmentTexture=t),!this.environmentTexture)return void e.Tools.Warn("Can not create default skybox without environment texture.");if(!this.environmentTexture)return void e.Tools.Warn("Can not create default skybox without environment texture.");var i=e.Mesh.CreateBox("hdrSkyBox",1e3,this);if(r){var n=new e.PBRMaterial("skyBox",this);n.backFaceCulling=!1,n.reflectionTexture=t.clone(),n.reflectionTexture.coordinatesMode=e.Texture.SKYBOX_MODE,n.microSurface=1,n.disableLighting=!0,i.infiniteDistance=!0,i.material=n}else{var o=new e.StandardMaterial("skyBox",this);o.backFaceCulling=!1,o.reflectionTexture=t.clone(),o.reflectionTexture.coordinatesMode=e.Texture.SKYBOX_MODE,o.diffuseColor=new e.Color3(0,0,0),o.specularColor=new e.Color3(0,0,0),o.disableLighting=!0,i.infiniteDistance=!0,i.material=o}return i},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})();a._FOGMODE_NONE=0,a._FOGMODE_EXP=1,a._FOGMODE_EXP2=2,a._FOGMODE_LINEAR=3,a.MinDeltaTime=1,a.MaxDeltaTime=1e3,a.DragMovementThreshold=10,a.LongPressDelay=500,a.DoubleClickDelay=300,a.ExclusiveDoubleClickMode=!1,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}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},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,h,l){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=h||0,this._size=l||a,this._kind=n}return t.prototype.getKind=function(){return this._kind},t.prototype.isUpdatable=function(){return this._buffer.isUpdatable()},t.prototype.getData=function(){return this._buffer.getData()},t.prototype.getBuffer=function(){return this._buffer.getBuffer()},t.prototype.getStrideSize=function(){return this._stride},t.prototype.getOffset=function(){return this._offset},t.prototype.getSize=function(){return this._size},t.prototype.getIsInstanced=function(){return this._buffer.getIsInstanced()},t.prototype.create=function(e){return this._buffer.create(e)},t.prototype.update=function(e){return this._buffer.update(e)},t.prototype.updateDirectly=function(e,t){return this._buffer.updateDirectly(e,t)},t.prototype.dispose=function(){this._ownsBuffer&&this._buffer.dispose()},Object.defineProperty(t,"PositionKind",{get:function(){return t._PositionKind},enumerable:!0,configurable:!0}),Object.defineProperty(t,"NormalKind",{get:function(){return t._NormalKind},enumerable:!0,configurable:!0}),Object.defineProperty(t,"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})();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",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.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},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.noMipmap===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.noMipmap===t&&(!r||r===o.samplingMode))return o.references++,o}return null},t.prototype.delayLoad=function(){},t.prototype.clone=function(){return null},t.prototype.releaseInternalTexture=function(){this._texture&&(this._scene.getEngine().releaseInternalTexture(this._texture),delete this._texture)},t.prototype.dispose=function(){this.getScene().stopAnimation(this),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})();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,"isRenderTarget",void 0),e.BaseTexture=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(i,n,o,s,a,u,h,l,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===h&&(h=null),void 0===l&&(l=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=l,d._deleteBuffer=c,d._format=f,n=d.getScene();var p=function(){d._onLoadObservarble&&d._onLoadObservarble.hasObservers()&&d.onLoadObservable.notifyObservers(!0),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=h):(d._texture=n.getEngine().createTexture(i,o,s,n,d._samplingMode,p,h,d._buffer,null,d._format),c&&delete d._buffer),d):(d._delayedOnLoad=p,d._delayedOnError=h,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}),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(){return this.uOffset===this._cachedUOffset&&this.vOffset===this._cachedVOffset&&this.uScale===this._cachedUScale&&this.vScale===this._cachedVScale&&this.uAng===this._cachedUAng&&this.vAng===this._cachedVAng&&this.wAng===this._cachedWAng?this._cachedTextureMatrix:(this._cachedUOffset=this.uOffset,this._cachedVOffset=this.vOffset,this._cachedUScale=this.uScale,this._cachedVScale=this.vScale,this._cachedUAng=this.uAng,this._cachedVAng=this.vAng,this._cachedWAng=this.wAng,this._cachedTextureMatrix||(this._cachedTextureMatrix=e.Matrix.Zero(),this._rowGenerationMatrix=new e.Matrix,this._t0=e.Vector3.Zero(),this._t1=e.Vector3.Zero(),this._t2=e.Vector3.Zero()),e.Matrix.RotationYawPitchRollToRef(this.vAng,this.uAng,this.wAng,this._rowGenerationMatrix),this._prepareRowForTextureGeneration(0,0,0,this._t0),this._prepareRowForTextureGeneration(1,0,0,this._t1),this._prepareRowForTextureGeneration(0,1,0,this._t2),this._t1.subtractInPlace(this._t0),this._t2.subtractInPlace(this._t0),e.Matrix.IdentityToRef(this._cachedTextureMatrix),this._cachedTextureMatrix.m[0]=this._t1.x,this._cachedTextureMatrix.m[1]=this._t1.y,this._cachedTextureMatrix.m[2]=this._t1.z,this._cachedTextureMatrix.m[4]=this._t2.x,this._cachedTextureMatrix.m[5]=this._t2.y,this._cachedTextureMatrix.m[6]=this._t2.z,this._cachedTextureMatrix.m[8]=this._t0.x,this._cachedTextureMatrix.m[9]=this._t0.y,this._cachedTextureMatrix.m[10]=this._t0.z,this._cachedTextureMatrix)},r.prototype.getReflectionTextureMatrix=function(){if(this.uOffset===this._cachedUOffset&&this.vOffset===this._cachedVOffset&&this.uScale===this._cachedUScale&&this.vScale===this._cachedVScale&&this.coordinatesMode===this._cachedCoordinatesMode)return this._cachedTextureMatrix;switch(this._cachedTextureMatrix||(this._cachedTextureMatrix=e.Matrix.Zero(),this._projectionModeMatrix=e.Matrix.Zero()),this._cachedCoordinatesMode=this.coordinatesMode,this.coordinatesMode){case 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,this.getScene().getProjectionMatrix().multiplyToRef(this._projectionModeMatrix,this._cachedTextureMatrix);break;default:e.Matrix.IdentityToRef(this._cachedTextureMatrix)}return 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._onLoadObservarble||(this._onLoadObservarble=new e.Observable),this._onLoadObservarble},enumerable:!0,configurable:!0}),r.CreateFromBase64String=function(t,i,n,o,s,a,u,h,l){return void 0===a&&(a=r.TRILINEAR_SAMPLINGMODE),void 0===u&&(u=null),void 0===h&&(h=null),void 0===l&&(l=e.Engine.TEXTUREFORMAT_RGBA),new r("data:"+i,n,o,s,a,u,h,t,!1,l)},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 h=0;h<t.animations.length;h++){var l=t.animations[h];a.animations.push(e.Animation.Parse(l))}return a},r.LoadFromDataString=function(t,i,n,o,s,a,u,h,l,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===h&&(h=null),void 0===l&&(l=null),void 0===c&&(c=e.Engine.TEXTUREFORMAT_RGBA),"data:"!==t.substr(0,5)&&(t="data:"+t),new r(t,n,s,a,u,h,l,i,o,c)},r})(e.BaseTexture);t.NEAREST_SAMPLINGMODE=1,t.BILINEAR_SAMPLINGMODE=2,t.TRILINEAR_SAMPLINGMODE=3,t.EXPLICIT_MODE=0,t.SPHERICAL_MODE=1,t.PLANAR_MODE=2,t.CUBIC_MODE=3,t.PROJECTION_MODE=4,t.SKYBOX_MODE=5,t.INVCUBIC_MODE=6,t.EQUIRECTANGULAR_MODE=7,t.FIXED_EQUIRECTANGULAR_MODE=8,t.FIXED_EQUIRECTANGULAR_MIRRORED_MODE=9,t.CLAMP_ADDRESSMODE=0,t.WRAP_ADDRESSMODE=1,t.MIRROR_ADDRESSMODE=2,__decorate([e.serialize()],t.prototype,"url",void 0),__decorate([e.serialize()],t.prototype,"uOffset",void 0),__decorate([e.serialize()],t.prototype,"vOffset",void 0),__decorate([e.serialize()],t.prototype,"uScale",void 0),__decorate([e.serialize()],t.prototype,"vScale",void 0),__decorate([e.serialize()],t.prototype,"uAng",void 0),__decorate([e.serialize()],t.prototype,"vAng",void 0),__decorate([e.serialize()],t.prototype,"wAng",void 0),__decorate([e.serialize()],t.prototype,"isBlocking",null),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,h){void 0===s&&(s=null),void 0===h&&(h=!0);var l=r.call(this,n,o)||this;if(l.onBeforeRenderObservable=new e.Observable,l.onAfterRenderObservable=new e.Observable,l.onBeforeDrawObservable=new e.Observable,l.delayLoadState=e.Engine.DELAYLOADSTATE_NONE,l.instances=new Array,l._LODLevels=new Array,l._visibleInstances={},l._renderIdForInstances=new Array,l._batchCache=new t,l._instancesBufferSize=2048,l._sideOrientation=i._DEFAULTSIDE,l._areNormalsFrozen=!1,l._source=null,a){l._source=a,a._geometry&&a._geometry.applyToMesh(l),e.Tools.DeepCopy(a,l,["name","material","skeleton","instances","parent","uniqueId"],["_poseMatrix"]),l.parent=a.parent,l.setPivotMatrix(a.getPivotMatrix()),l.id=n+"."+a.id,l.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,l,u)}}var d=l.getScene().getPhysicsEngine();if(h&&d){var p=d.getImpostorForPhysicsObject(a);p&&(l.physicsImpostor=p.clone(l))}for(c=0;c<o.particleSystems.length;c++){var _=o.particleSystems[c];_.emitter===a&&_.clone(_.name,l)}l.computeWorldMatrix(!0)}return null!==s&&(l.parent=s),l}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)},i.prototype.isDisposed=function(){return this._isDisposed},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(){var t=this.getTotalVertices();return t&&this.getIndices()?(this.releaseSubMeshes(),new e.SubMesh(0,0,t,0,this.getTotalIndices(),this)):null},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,h=this._instancesBufferSize,l=this._instancesBuffer;this._instancesBufferSize<u;)this._instancesBufferSize*=2;this._instancesData&&h==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 _=s[p];_.getWorldMatrix().copyToArray(this._instancesData,c),c+=16,f++}return l&&h==this._instancesBufferSize?l.updateDirectly(this._instancesData,0,f):(l&&l.dispose(),l=new e.Buffer(o,this._instancesData,!0,16,!1,!0),this._instancesBuffer=l,this.setVerticesBuffer(l.createVertexBuffer("world0",0,4)),this.setVerticesBuffer(l.createVertexBuffer("world1",4,4)),this.setVerticesBuffer(l.createVertexBuffer("world2",8,4)),this.setVerticesBuffer(l.createVertexBuffer("world3",12,4))),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 h=0;h<i.visibleInstances[e._id].length;h++){var l=i.visibleInstances[e._id][h],c=l.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 h;h=a.storeEffectOnSubMeshes?t.effect:a.getEffect(),a._preBind(h);var l=i.forcePointsCloud?e.Material.PointFillMode:i.forceWireframe?e.Material.WireFrameFillMode:a.fillMode;this._bind(t,h,l);var c=this.getWorldMatrix();if(a.storeEffectOnSubMeshes?a.bindForSubMesh(c,this,t):a.bind(c,this),this._processRendering(t,h,l,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];-1!==t.indexOf(i.emitter)&&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(),h=function(e){var t=document.createElement("canvas"),u=t.getContext("2d"),h=e.width,l=e.height;t.width=h,t.height=l,u.drawImage(e,0,0);var c=u.getImageData(0,0,h,l).data;a.applyDisplacementMapFromBuffer(c,h,l,r,i,o,s),n&&n(a)};return e.Tools.LoadImage(t,h,(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),h=this.getVerticesData(e.VertexBuffer.NormalKind),l=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(h,p,f),e.Vector2.FromArrayToRef(l,p/3*2,d);var _=Math.abs(d.x*a.x+s.x)*r%r|0,m=Math.abs(d.y*a.y+s.y)*i%i|0,g=4*(_+m*r),v=t[g]/255,y=t[g+1]/255,T=t[g+2]/255,x=.3*v+.59*y+.11*T;f.normalize(),f.scaleInPlace(n+(o-n)*x),c=c.add(f),c.toArray(u,p)}return e.VertexData.ComputeNormals(u,this.getIndices(),h),this.updateVerticesData(e.VertexBuffer.PositionKind,u),this.updateVerticesData(e.VertexBuffer.NormalKind,h),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 h,l=this.subMeshes.slice(0),c=this.getIndices(),f=this.getTotalIndices();for(h=0;h<f;h++){var d=c[h];for(t=0;t<i.length;t++){r=i[t];for(var p=n[r].getStrideSize(),_=0;_<p;_++)s[r].push(o[r][d*p+_])}}var m=[],g=s[e.VertexBuffer.PositionKind];for(h=0;h<f;h+=3){c[h]=h,c[h+1]=h+1,c[h+2]=h+2;for(var v=e.Vector3.FromArray(g,3*h),y=e.Vector3.FromArray(g,3*(h+1)),T=e.Vector3.FromArray(g,3*(h+2)),x=v.subtract(y),E=T.subtract(y),b=e.Vector3.Normalize(e.Vector3.Cross(x,E)),A=0;A<3;A++)m.push(b.x),m.push(b.y),m.push(b.z)}for(this.setIndices(c),this.setVerticesData(e.VertexBuffer.NormalKind,m,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<l.length;M++){var P=l[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,h=this.subMeshes.slice(0),l=this.getIndices(),c=this.getTotalIndices();for(u=0;u<c;u++){var f=l[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)l[u]=u,l[u+1]=u+1,l[u+2]=u+2;for(this.setIndices(l),t=0;t<i.length;t++)r=i[t],this.setVerticesData(r,s[r],n[r].isUpdatable());this.releaseSubMeshes();for(var _=0;_<h.length;_++){var m=h[_];new e.SubMesh(m.materialIndex,m.indexStart,m.indexCount,m.indexStart,m.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],h={name:u.name,position:u.position.asArray(),scaling:u.scaling.asArray()};u.rotationQuaternion?h.rotationQuaternion=u.rotationQuaternion.asArray():u.rotation&&(h.rotation=u.rotation.asArray()),t.instances.push(h),e.Animation.AppendSerializedAnimations(u,h),h.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 h=t.instances[u],l=o.createInstance(h.name);if(e.Tags&&e.Tags.AddTagsTo(l,h.tags),l.position=e.Vector3.FromArray(h.position),h.parentId&&(l._waitingParentId=h.parentId),h.rotationQuaternion?l.rotationQuaternion=e.Quaternion.FromArray(h.rotationQuaternion):h.rotation&&(l.rotation=e.Vector3.FromArray(h.rotation)),l.scaling=e.Vector3.FromArray(h.scaling),l.checkCollisions=o.checkCollisions,t.animations){for(s=0;s<t.animations.length;s++)a=t.animations[s],l.animations.push(e.Animation.Parse(a));e.Node.ParseAnimationRanges(l,t,r)}}return o},i.CreateRibbon=function(t,r,i,n,o,s,a,u,h){return e.MeshBuilder.CreateRibbon(t,{pathArray:r,closeArray:i,closePath:n,offset:o,updatable:a,sideOrientation:u,instance:h},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,h,l){void 0!==u&&u instanceof e.Scene||(void 0!==u&&(l=h||i.DEFAULTSIDE,h=u),u=a,a=1);var c={height:r,diameterTop:n,diameterBottom:o,tessellation:s,subdivisions:a,sideOrientation:l,updatable:h};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,h,l){var c={radius:r,tube:i,radialSegments:n,tubularSegments:o,p:s,q:a,sideOrientation:l,updatable:h};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 h={points:r,dashSize:i,gapSize:n,dashNb:o,updatable:a,instance:u};return e.MeshBuilder.CreateDashedLines(t,h,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,h,l,c){var f={shape:r,path:n,scale:o,rotation:s,cap:0===a?0:a||i.NO_CAP,sideOrientation:l,instance:c,updatable:h};return e.MeshBuilder.ExtrudeShape(t,f,u)},i.ExtrudeShapeCustom=function(t,r,n,o,s,a,u,h,l,c,f,d){var p={shape:r,path:n,scaleFunction:o,rotationFunction:s,ribbonCloseArray:a,ribbonClosePath:u,cap:0===h?0:h||i.NO_CAP,sideOrientation:f,instance:d,updatable:c};return e.MeshBuilder.ExtrudeShapeCustom(t,p,l)},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,h){var l={xmin:r,zmin:i,xmax:n,zmax:o,subdivisions:s,precision:a,updatable:h};return e.MeshBuilder.CreateTiledGround(t,l,u)},i.CreateGroundFromHeightMap=function(t,r,i,n,o,s,a,u,h,l){var c={width:i,height:n,subdivisions:o,minHeight:s,maxHeight:a,updatable:h,onReady:l};return e.MeshBuilder.CreateGroundFromHeightMap(t,r,c,u)},i.CreateTube=function(t,r,i,n,o,s,a,u,h,l){var c={path:r,radius:i,tessellation:n,radiusFunction:o,arc:1,cap:s,updatable:u,sideOrientation:h,instance:l};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,h=u?this.getVerticesData(e.VertexBuffer.MatricesIndicesExtraKind):null,l=u?this.getVerticesData(e.VertexBuffer.MatricesWeightsExtraKind):null,c=t.getTransformMatrices(this),f=e.Vector3.Zero(),d=new e.Matrix,p=new e.Matrix,_=0,m=0;m<i.length;m+=3,_+=4){var g;for(o=0;o<4&&(g=a[_+o])>0;o++)e.Matrix.FromFloat32ArrayToRefScaled(c,16*s[_+o],g,p),d.addToSelf(p);if(u)for(o=0;o<4&&(g=l[_+o])>0;o++)e.Matrix.FromFloat32ArrayToRefScaled(c,16*h[_+o],g,p),d.addToSelf(p);e.Vector3.TransformCoordinatesFromFloatsToRef(this._sourcePositions[m],this._sourcePositions[m+1],this._sourcePositions[m+2],d,f),f.toArray(i,m),e.Vector3.TransformNormalFromFloatsToRef(this._sourceNormals[m],this._sourceNormals[m+1],this._sourceNormals[m+2],d,f),f.toArray(n,m),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 h,l,c,f=new Array;for(a=0;a<t.length;a++)t[a]&&(t[a].computeWorldMatrix(!0),l=e.VertexData.ExtractFromMesh(t[a],!0),l.transform(t[a].getWorldMatrix()),h?h.merge(l):(h=l,c=t[a]),s&&f.push(t[a].getTotalIndices()));if(o||(o=new i(c.name+"_merged",c.getScene())),h.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})(e.AbstractMesh);r._FRONTSIDE=0,r._BACKSIDE=1,r._DOUBLESIDE=2,r._DEFAULTSIDE=0,r._NO_CAP=0,r._CAP_START=1,r._CAP_END=2,r._CAP_ALL=3,e.Mesh=r})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(e,t,r,i,n,o,s,a){void 0===a&&(a=!0),this.materialIndex=e,this.verticesStart=t,this.verticesCount=r,this.indexStart=i,this.indexCount=n,this._renderId=0,this._mesh=o,this._renderingMesh=s||o,o.subMeshes.push(this),this._trianglePlanes=[],this._id=o.subMeshes.length-1,a&&(this.refreshBoundingInfo(),o.computeWorldMatrix(!0))}return Object.defineProperty(t.prototype,"effect",{get:function(){return this._materialEffect},enumerable:!0,configurable:!0}),t.prototype.setEffect=function(e,t){this._materialEffect!==e&&(this._materialDefines=t,this._materialEffect=e)},Object.defineProperty(t.prototype,"IsGlobal",{get:function(){return 0===this.verticesStart&&this.verticesCount==this._mesh.getTotalVertices()},enumerable:!0,configurable:!0}),t.prototype.getBoundingInfo=function(){return this.IsGlobal?this._mesh.getBoundingInfo():this._boundingInfo},t.prototype.setBoundingInfo=function(e){return this._boundingInfo=e,this},t.prototype.getMesh=function(){return this._mesh},t.prototype.getRenderingMesh=function(){return this._renderingMesh},t.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&&this._materialDefines.markAllAsDirty()),r}return e||this._mesh.getScene().defaultMaterial},t.prototype.refreshBoundingInfo=function(){if(this._lastColliderWorldVertices=null,!this.IsGlobal){var t=this._renderingMesh.getVerticesData(e.VertexBuffer.PositionKind);if(!t)return void(this._boundingInfo=this._mesh._boundingInfo);var 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}},t.prototype._checkCollision=function(e){return this.getBoundingInfo()._checkCollision(e)},t.prototype.updateBoundingInfo=function(e){return this.getBoundingInfo()||this.refreshBoundingInfo(),this.getBoundingInfo().update(e),this},t.prototype.isInFrustum=function(e){return this.getBoundingInfo().isInFrustum(e)},t.prototype.isCompletelyInFrustum=function(e){return this.getBoundingInfo().isCompletelyInFrustum(e)},t.prototype.render=function(e){return this._renderingMesh.render(this,e),this},t.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},t.prototype.canIntersects=function(e){return e.intersectsBox(this.getBoundingInfo().boundingBox)},t.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]],h=r[i[a+1]],l=t.intersectionSegment(u,h,s.intersectionThreshold);if(!(l<0)&&((n||!o||l<o.distance)&&(o=new e.IntersectionInfo(null,null,l),n)))break}else for(var a=this.indexStart;a<this.indexStart+this.indexCount;a+=3){var u=r[i[a]],h=r[i[a+1]],c=r[i[a+2]],f=t.intersectsTriangle(u,h,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},t.prototype.clone=function(r,i){var n=new t(this.materialIndex,this.verticesStart,this.verticesCount,this.indexStart,this.indexCount,r,i,!1);return this.IsGlobal||(n._boundingInfo=new e.BoundingInfo(this.getBoundingInfo().minimum,this.getBoundingInfo().maximum)),n},t.prototype.dispose=function(){this._linesIndexBuffer&&(this._mesh.getScene().getEngine()._releaseBuffer(this._linesIndexBuffer),this._linesIndexBuffer=null);var e=this._mesh.subMeshes.indexOf(this);this._mesh.subMeshes.splice(e,1)},t.CreateFromIndices=function(e,r,i,n,o){var s=Number.MAX_VALUE,a=-Number.MAX_VALUE;o=o||n;for(var u=o.getIndices(),h=r;h<r+i;h++){var l=u[h];l<s&&(s=l),l>a&&(a=l)}return new t(e,s,a-s+1,r,i,n,o)},t})();e.SubMesh=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(BABYLON){var EffectFallbacks=(function(){function e(){this._defines={},this._currentRank=32,this._maxRank=-1}return e.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)},e.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(e.prototype,"isMoreFallbacks",{get:function(){return this._currentRank<=this._maxRank},enumerable:!0,configurable:!0}),e.prototype.reduce=function(e){if(this._mesh&&this._mesh.computeBonesUsingShaders&&this._mesh.numBoneInfluencers>0){this._mesh.computeBonesUsingShaders=!1,e=e.replace("#define NUM_BONE_INFLUENCERS "+this._mesh.numBoneInfluencers,"#define NUM_BONE_INFLUENCERS 0"),BABYLON.Tools.Log("Falling back to CPU skinning for "+this._mesh.name);for(var t=this._mesh.getScene(),r=0;r<t.meshes.length;r++){var i=t.meshes[r];i.material===this._mesh.material&&i.computeBonesUsingShaders&&i.numBoneInfluencers>0&&(i.computeBonesUsingShaders=!1)}}else{var n=this._defines[this._currentRank];if(n)for(var r=0;r<n.length;r++)e=e.replace("#define "+n[r],"");this._currentRank++}return e},e})();BABYLON.EffectFallbacks=EffectFallbacks;var EffectCreationOptions=(function(){function e(){}return e})();BABYLON.EffectCreationOptions=EffectCreationOptions;var Effect=(function(){function Effect(e,t,r,i,n,o,s,a,u,h){var l=this;if(this.uniqueId=0,this.onCompileObservable=new BABYLON.Observable,this.onErrorObservable=new BABYLON.Observable,this.onBindObservable=new BABYLON.Observable,this._uniformBuffersNames={},this._isReady=!1,this._compilationError="",this._valueCache={},this.name=e,t.attributes){var c=t;if(this._engine=r,this._attributesNames=c.attributes,this._uniformsNames=c.uniformsNames.concat(c.samplers),this._samplers=c.samplers,this.defines=c.defines,this.onError=c.onError,this.onCompiled=c.onCompiled,this._fallbacks=c.fallbacks,this._indexParameters=c.indexParameters,c.uniformBuffersNames)for(var f=0;f<c.uniformBuffersNames.length;f++)this._uniformBuffersNames[c.uniformBuffersNames[f]]=f}else this._engine=n,this.defines=o,this._uniformsNames=r.concat(i),this._samplers=i,this._attributesNames=t,this.onError=u,this.onCompiled=a,this._indexParameters=h,this._fallbacks=s;this.uniqueId=Effect._uniqueIdSeed++;var d,p;e.vertexElement?(d=document.getElementById(e.vertexElement))||(d=e.vertexElement):d=e.vertex||e,e.fragmentElement?(p=document.getElementById(e.fragmentElement))||(p=e.fragmentElement):p=e.fragment||e,this._loadVertexShader(d,(function(e){l._processIncludes(e,(function(e){l._processShaderConversion(e,!1,(function(e){l._loadFragmentShader(p,(function(t){l._processIncludes(t,(function(t){l._processShaderConversion(t,!0,(function(t){l._prepareEffect(e,t,l._attributesNames,l.defines,l._fallbacks)}))}))}))}))}))}))}return Object.defineProperty(Effect.prototype,"key",{get:function(){return this._key},enumerable:!0,configurable:!0}),Effect.prototype.isReady=function(){return this._isReady},Effect.prototype.getProgram=function(){return this._program},Effect.prototype.getAttributesNames=function(){return this._attributesNames},Effect.prototype.getAttributeLocation=function(e){return this._attributes[e]},Effect.prototype.getAttributeLocationByName=function(e){var t=this._attributesNames.indexOf(e);return this._attributes[t]},Effect.prototype.getAttributesCount=function(){return this._attributes.length},Effect.prototype.getUniformIndex=function(e){return this._uniformsNames.indexOf(e)},Effect.prototype.getUniform=function(e){return this._uniforms[this._uniformsNames.indexOf(e)]},Effect.prototype.getSamplers=function(){return this._samplers},Effect.prototype.getCompilationError=function(){return this._compilationError},Effect.prototype.getVertexShaderSource=function(){return this._evaluateDefinesOnString(this._engine.getVertexShaderSource(this._program))},Effect.prototype.getFragmentShaderSource=function(){return this._evaluateDefinesOnString(this._engine.getFragmentShaderSource(this._program))},Effect.prototype.executeWhenCompiled=function(e){var t=this;if(this.isReady())return void e(this);var r=this.onCompileObservable.add((function(i){t.onCompileObservable.remove(r),e(i)}))},Effect.prototype._loadVertexShader=function(e,t){if(e instanceof HTMLElement){return void t(BABYLON.Tools.GetDOMTextContent(e))}if("base64:"===e.substr(0,7)){return void t(window.atob(e.substr(7)))}if(Effect.ShadersStore[e+"VertexShader"])return void t(Effect.ShadersStore[e+"VertexShader"]);var r;r="."===e[0]||"/"===e[0]||e.indexOf("http")>-1?e:BABYLON.Engine.ShadersRepository+e,BABYLON.Tools.LoadFile(r+".vertex.fx",t)},Effect.prototype._loadFragmentShader=function(e,t){if(e instanceof HTMLElement){return void t(BABYLON.Tools.GetDOMTextContent(e))}if("base64:"===e.substr(0,7)){return void t(window.atob(e.substr(7)))}if(Effect.ShadersStore[e+"PixelShader"])return void t(Effect.ShadersStore[e+"PixelShader"]);if(Effect.ShadersStore[e+"FragmentShader"])return void t(Effect.ShadersStore[e+"FragmentShader"]);var r;r="."===e[0]||"/"===e[0]||e.indexOf("http")>-1?e:BABYLON.Engine.ShadersRepository+e,BABYLON.Tools.LoadFile(r+".fragment.fx",t)},Effect.prototype._dumpShadersSource=function(e,t,r){var i=this._engine.webGLVersion>1?"#version 300 es\n":"",n=i+(r?r+"\n":"");e=n+e,t=n+t;var o=2,s="\n1\t"+e.replace(/\n/gm,(function(){return"\n"+o+++"\t"}));o=2;var a="\n1\t"+t.replace(/\n/gm,(function(){return"\n"+o+++"\t"}));this.name.vertexElement?(BABYLON.Tools.Error("Vertex shader: "+this.name.vertexElement+s),BABYLON.Tools.Error("Fragment shader: "+this.name.fragmentElement+a)):this.name.vertex?(BABYLON.Tools.Error("Vertex shader: "+this.name.vertex+s),BABYLON.Tools.Error("Fragment shader: "+this.name.fragment+a)):(BABYLON.Tools.Error("Vertex shader: "+this.name+s),BABYLON.Tools.Error("Fragment shader: "+this.name+a))},Effect.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)},Effect.prototype._processIncludes=function(e,t){for(var r=this,i=/#include<(.+)>(\((.*)\))*(\[(.*)\])*/g,n=i.exec(e),o=new String(e);null!=n;){var s=n[1];if(-1!==s.indexOf("__decl__")&&(s=s.replace(/__decl__/,""),1!=this._engine.webGLVersion&&(s=s.replace(/Vertex/,"Ubo"),s=s.replace(/Fragment/,"Ubo")),s+="Declaration"),!Effect.IncludesShadersStore[s]){var a=BABYLON.Engine.ShadersRepository+"ShadersInclude/"+s+".fx";return void BABYLON.Tools.LoadFile(a,(function(e){Effect.IncludesShadersStore[s]=e,r._processIncludes(o,t)}))}var u=Effect.IncludesShadersStore[s];if(n[2])for(var h=n[3].split(","),l=0;l<h.length;l+=2){var c=new RegExp(h[l],"g"),f=h[l+1];u=u.replace(c,f)}if(n[4]){var d=n[5];if(-1!==d.indexOf("..")){var p=d.split(".."),_=parseInt(p[0]),m=parseInt(p[1]),g=u.slice(0);u="",isNaN(m)&&(m=this._indexParameters[p[1]]);for(var v=_;v<m;v++)1===this._engine.webGLVersion&&(g=g.replace(/light\{X\}.(\w*)/g,(function(e,t){return t+"{X}"}))),u+=g.replace(/\{X\}/g,v)+"\n"}else 1===this._engine.webGLVersion&&(u=u.replace(/light\{X\}.(\w*)/g,(function(e,t){return t+"{X}"}))),u=u.replace(/\{X\}/g,d)}o=o.replace(n[0],u),n=i.exec(e)}t(o)},Effect.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},Effect.prototype._prepareEffect=function(e,t,r,i,n){try{var o=this._engine;if(this._program=o.createShaderProgram(e,t,i),o.webGLVersion>1)for(var s in this._uniformBuffersNames)this.bindUniformBlock(s,this._uniformBuffersNames[s]);this._uniforms=o.getUniforms(this._program,this._uniformsNames),this._attributes=o.getAttributes(this._program,r);var a;for(a=0;a<this._samplers.length;a++){null==this.getUniform(this._samplers[a])&&(this._samplers.splice(a,1),a--)}o.bindSamplers(this),this._compilationError="",this._isReady=!0,this.onCompiled&&this.onCompiled(this),this.onCompileObservable.notifyObservers(this)}catch(o){this._compilationError=o.message,BABYLON.Tools.Error("Unable to compile effect:"),BABYLON.Tools.Error("Uniforms: "+this._uniformsNames.map((function(e){return" "+e}))),BABYLON.Tools.Error("Attributes: "+r.map((function(e){return" "+e}))),this._dumpShadersSource(e,t,i),BABYLON.Tools.Error("Error: "+this._compilationError),n&&n.isMoreFallbacks?(BABYLON.Tools.Error("Trying next fallback."),i=n.reduce(i),this._prepareEffect(e,t,r,i,n)):(this.onError&&this.onError(this,this._compilationError),this.onErrorObservable.notifyObservers(this))}},Object.defineProperty(Effect.prototype,"isSupported",{get:function(){return""===this._compilationError},enumerable:!0,configurable:!0}),Effect.prototype._bindTexture=function(e,t){this._engine._bindTexture(this._samplers.indexOf(e),t)},Effect.prototype.setTexture=function(e,t){this._engine.setTexture(this._samplers.indexOf(e),this.getUniform(e),t)},Effect.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)},Effect.prototype.setTextureFromPostProcess=function(e,t){this._engine.setTextureFromPostProcess(this._samplers.indexOf(e),t)},Effect.prototype._cacheMatrix=function(e,t){var r=this._valueCache[e],i=t.updateFlag;return(void 0===r||r!==i)&&(this._valueCache[e]=i,!0)},Effect.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},Effect.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},Effect.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},Effect.prototype.bindUniformBuffer=function(e,t){Effect._baseCache[this._uniformBuffersNames[t]]!==e&&(Effect._baseCache[this._uniformBuffersNames[t]]=e,this._engine.bindUniformBufferBase(e,this._uniformBuffersNames[t]))},Effect.prototype.bindUniformBlock=function(e,t){this._engine.bindUniformBlock(this._program,e,t)},Effect.prototype.setIntArray=function(e,t){return this._valueCache[e]=null,this._engine.setIntArray(this.getUniform(e),t),this},Effect.prototype.setIntArray2=function(e,t){return this._valueCache[e]=null,this._engine.setIntArray2(this.getUniform(e),t),this},Effect.prototype.setIntArray3=function(e,t){return this._valueCache[e]=null,this._engine.setIntArray3(this.getUniform(e),t),this},Effect.prototype.setIntArray4=function(e,t){return this._valueCache[e]=null,this._engine.setIntArray4(this.getUniform(e),t),this},Effect.prototype.setFloatArray=function(e,t){return this._valueCache[e]=null,this._engine.setFloatArray(this.getUniform(e),t),this},Effect.prototype.setFloatArray2=function(e,t){return this._valueCache[e]=null,this._engine.setFloatArray2(this.getUniform(e),t),this},Effect.prototype.setFloatArray3=function(e,t){return this._valueCache[e]=null,this._engine.setFloatArray3(this.getUniform(e),t),this},Effect.prototype.setFloatArray4=function(e,t){return this._valueCache[e]=null,this._engine.setFloatArray4(this.getUniform(e),t),this},Effect.prototype.setArray=function(e,t){return this._valueCache[e]=null,this._engine.setArray(this.getUniform(e),t),this},Effect.prototype.setArray2=function(e,t){return this._valueCache[e]=null,this._engine.setArray2(this.getUniform(e),t),this},Effect.prototype.setArray3=function(e,t){return this._valueCache[e]=null,this._engine.setArray3(this.getUniform(e),t),this},Effect.prototype.setArray4=function(e,t){return this._valueCache[e]=null,this._engine.setArray4(this.getUniform(e),t),this},Effect.prototype.setMatrices=function(e,t){if(t)return this._valueCache[e]=null,this._engine.setMatrices(this.getUniform(e),t),this},Effect.prototype.setMatrix=function(e,t){return this._cacheMatrix(e,t)&&this._engine.setMatrix(this.getUniform(e),t),this},Effect.prototype.setMatrix3x3=function(e,t){return this._valueCache[e]=null,this._engine.setMatrix3x3(this.getUniform(e),t),this},Effect.prototype.setMatrix2x2=function(e,t){return this._valueCache[e]=null,this._engine.setMatrix2x2(this.getUniform(e),t),this},Effect.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)},Effect.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)},Effect.prototype.setVector2=function(e,t){return this._cacheFloat2(e,t.x,t.y)&&this._engine.setFloat2(this.getUniform(e),t.x,t.y),this},Effect.prototype.setFloat2=function(e,t,r){return this._cacheFloat2(e,t,r)&&this._engine.setFloat2(this.getUniform(e),t,r),this},Effect.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},Effect.prototype.setFloat3=function(e,t,r,i){return this._cacheFloat3(e,t,r,i)&&this._engine.setFloat3(this.getUniform(e),t,r,i),this},Effect.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},Effect.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},Effect.prototype.setColor3=function(e,t){return this._cacheFloat3(e,t.r,t.g,t.b)&&this._engine.setColor3(this.getUniform(e),t),this},Effect.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},Effect.prototype._recombineShader=function(node){if(node.define)if(node.condition){var defineIndex=this.defines.indexOf("#define "+node.define);if(-1===defineIndex)return null;var nextComma=this.defines.indexOf("\n",defineIndex),defineValue=this.defines.substr(defineIndex+7,nextComma-defineIndex-7).replace(node.define,"").trim(),condition=defineValue+node.condition;if(!eval(condition))return null}else if(node.ndef){if(-1!==this.defines.indexOf("#define "+node.define))return null}else if(-1===this.defines.indexOf("#define "+node.define))return null;for(var result="",index=0;index<node.children.length;index++){var line=node.children[index];if(line.children){var combined=this._recombineShader(line);null!==combined&&(result+=combined+"\r\n")}else line.length>0&&(result+=line+"\r\n")}return result},Effect.prototype._evaluateDefinesOnString=function(e){for(var t={children:[]},r=t,i=e.split("\n"),n=0;n<i.length;n++){var o=i[n].trim(),s=o.indexOf("#ifdef ");if(-1===s){var s=o.indexOf("#ifndef ");if(-1===s){var s=o.indexOf("#if ");if(-1===s)s=o.indexOf("#endif"),-1===s?r.children.push(o):r=r.parent;else{var a=o.substr(s+4).trim(),u=a.indexOf(" ");h={condition:a.substr(u+1),define:a.substr(0,u),ndef:!1,children:[],parent:r},r.children.push(h),r=h}}else{var a=o.substr(s+8);h={condition:null,define:a,ndef:!0,children:[],parent:r},r.children.push(h),r=h}}else{var a=o.substr(s+7),h={condition:null,ndef:!1,define:a,children:[],parent:r};r.children.push(h),r=h}}return this._recombineShader(t)},Effect})();Effect._uniqueIdSeed=0,Effect._baseCache={},Effect.ShadersStore={},Effect.IncludesShadersStore={},BABYLON.Effect=Effect})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){}return 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,h=!1,l=!1,c=!1,f=!1;if(t.lightsEnabled&&!s)for(var d=0,p=r._lightSources;d<p.length;d++){var _=p[d];u=!0,void 0===i["LIGHT"+a]&&(h=!0),i["LIGHT"+a]=!0,i["SPOTLIGHT"+a]=!1,i["HEMILIGHT"+a]=!1,i["POINTLIGHT"+a]=!1,i["DIRLIGHT"+a]=!1;var m;if(m=_.getTypeID()===e.Light.LIGHTTYPEID_SPOTLIGHT?"SPOTLIGHT"+a:_.getTypeID()===e.Light.LIGHTTYPEID_HEMISPHERICLIGHT?"HEMILIGHT"+a:_.getTypeID()===e.Light.LIGHTTYPEID_POINTLIGHT?"POINTLIGHT"+a:"DIRLIGHT"+a,i[m]=!0,n&&!_.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&&_.shadowEnabled){var g=_.getShadowGenerator();g&&(c=!0,g.prepareDefines(i,a))}if(_.lightmapMode!=e.Light.LIGHTMAP_DEFAULT?(l=!0,i["LIGHTMAPEXCLUDED"+a]=!0,i["LIGHTMAPNOSPECULAR"+a]=_.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);var y=t.getEngine().getCaps();return void 0===i.SHADOWFLOAT&&(h=!0),i.SHADOWFLOAT=c&&(y.textureFloatRender&&y.textureFloatLinearFiltering||y.textureHalfFloatRender&&y.textureHalfFloatLinearFiltering),i.LIGHTMAPEXCLUDED=l,h&&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,h=0;h<n;h++)t.push(e.VertexBuffer.PositionKind+h),a&&t.push(e.VertexBuffer.NormalKind+h),u&&t.push(e.VertexBuffer.TangentKind+h),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){void 0===s&&(s=4);for(var a=0,u=0,h=i._lightSources;u<h.length;u++){var l=h[u];if(l._uniformBuffer.bindToEffect(n,"Light"+a),t.BindLightProperties(l,n,a),l.diffuse.scaleToRef(l.intensity,e.Tmp.Color3[0]),l._uniformBuffer.updateColor4("vLightDiffuse",e.Tmp.Color3[0],l.range,a+""),o.SPECULARTERM&&(l.specular.scaleToRef(l.intensity,e.Tmp.Color3[1]),l._uniformBuffer.updateColor3("vLightSpecular",e.Tmp.Color3[1],a+"")),r.shadowsEnabled&&this.BindLightShadow(l,r,i,a+"",n),l._uniformBuffer.update(),++a===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._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},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._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,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.markAsDirty=function(e){},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.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.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.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,h=i.subMeshes;u<h.length;u++){var a=h[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})();r._TriangleFillMode=0,r._WireFrameFillMode=1,r._PointFillMode=2,r._ClockWiseSideOrientation=0,r._CounterClockWiseSideOrientation=1,r._TextureDirtyFlag=1,r._LightDirtyFlag=2,r._FresnelDirtyFlag=4,r._AttributesDirtyFlag=8,r._MiscDirtyFlag=16,__decorate([e.serialize()],r.prototype,"id",void 0),__decorate([e.serialize()],r.prototype,"name",void 0),__decorate([e.serialize()],r.prototype,"checkReadyOnEveryCall",void 0),__decorate([e.serialize()],r.prototype,"checkReadyOnlyOnce",void 0),__decorate([e.serialize()],r.prototype,"state",void 0),__decorate([e.serialize()],r.prototype,"alpha",void 0),__decorate([e.serialize("backFaceCulling")],r.prototype,"_backFaceCulling",void 0),__decorate([e.serialize()],r.prototype,"sideOrientation",void 0),__decorate([e.serialize()],r.prototype,"alphaMode",void 0),__decorate([e.serialize()],r.prototype,"disableDepthWrite",void 0),__decorate([e.serialize("fogEnabled")],r.prototype,"_fogEnabled",void 0),__decorate([e.serialize()],r.prototype,"pointSize",void 0),__decorate([e.serialize()],r.prototype,"zOffset",void 0),__decorate([e.serialize()],r.prototype,"wireframe",null),__decorate([e.serialize()],r.prototype,"pointsCloud",null),__decorate([e.serialize()],r.prototype,"fillMode",null),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})();t._MAX_UNIFORM_SIZE=256,t._tempBuffer=new Float32Array(t._MAX_UNIFORM_SIZE),e.UniformBuffer=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.storeEffectOnSubMeshes=!0,i}return __extends(r,t),r.prototype.getEffect=function(){return this._activeEffect},r.prototype.isReady=function(e,t){return!!e&&(!e.subMeshes||0===e.subMeshes.length||this.isReadyForSubMesh(e,e.subMeshes[0],t))},r.prototype.bindOnlyWorldMatrix=function(e){this._activeEffect.setMatrix("world",e)},r.prototype.bind=function(e,t){t&&this.bindForSubMesh(e,t,t.subMeshes[0])},r.prototype._afterBind=function(e,r){t.prototype._afterBind.call(this,e),this.getScene()._cachedEffect=r},r.prototype._mustRebind=function(e,t,r){return void 0===r&&(r=0),e.isCachedMaterialValid(this,t,r)},r.prototype.markAsDirty=function(t){t&e.Material.TextureDirtyFlag&&this._markAllSubMeshesAsTexturesDirty(),t&e.Material.LightDirtyFlag&&this._markAllSubMeshesAsLightsDirty(),t&e.Material.FresnelDirtyFlag&&this._markAllSubMeshesAsFresnelDirty(),t&e.Material.AttributesDirtyFlag&&this._markAllSubMeshesAsAttributesDirty(),t&e.Material.MiscDirtyFlag&&this._markAllSubMeshesAsMiscDirty(),this.getScene().resetCachedMaterial()},r.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];if(s.getMaterial()===this){if(!s._materialDefines)return;e(s._materialDefines)}}}},r.prototype._markAllSubMeshesAsTexturesDirty=function(){this._markAllSubMeshesAsDirty((function(e){return e.markAsTexturesDirty()}))},r.prototype._markAllSubMeshesAsFresnelDirty=function(){this._markAllSubMeshesAsDirty((function(e){return e.markAsFresnelDirty()}))},r.prototype._markAllSubMeshesAsLightsDirty=function(){this._markAllSubMeshesAsDirty((function(e){return e.markAsLightDirty()}))},r.prototype._markAllSubMeshesAsAttributesDirty=function(){this._markAllSubMeshesAsDirty((function(e){return e.markAsAttributesDirty()}))},r.prototype._markAllSubMeshesAsMiscDirty=function(){this._markAllSubMeshesAsDirty((function(e){return e.markAsMiscDirty()}))},r})(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 h,l,c,f,d=0===r.sideOrientation?0:r.sideOrientation||e.Mesh.DEFAULTSIDE,p=r.uvs,_=r.colors,m=[],g=[],v=[],y=[],T=[],x=[],E=[],b=[],A=[],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 S,O,C=0,I=o?1:0;h=i[0].length;var L,D;for(l=0;l<i.length;l++){for(E[l]=0,T[l]=[0],S=i[l],O=S.length,h=h<O?h:O,f=0;f<O;)m.push(S[f].x,S[f].y,S[f].z),f>0&&(L=S[f].subtract(S[f-1]).length(),D=L+E[l],T[l].push(D),E[l]=D),f++;o&&(f--,m.push(S[0].x,S[0].y,S[0].z),L=S[f].subtract(S[0]).length(),D=L+E[l],T[l].push(D),E[l]=D),A[l]=O+I,M[l]=C,C+=O+I}var B,F,N,w;for(c=0;c<h+I;c++){for(b[c]=0,x[c]=[0],l=0;l<i.length-1;l++)B=i[l],F=i[l+1],c===h?(N=B[0],w=F[0]):(N=B[c],w=F[c]),L=w.subtract(N).length(),D=L+b[c],x[c].push(D),b[c]=D;n&&(B=i[l],F=i[0],c===h&&(w=F[0]),L=w.subtract(N).length(),D=L+b[c],b[c]=D)}var V,U;if(p)for(l=0;l<p.length;l++)y.push(p[l].x,p[l].y);else for(l=0;l<i.length;l++)for(c=0;c<h+I;c++)V=0!=E[l]?T[l][c]/E[l]:0,U=0!=b[c]?x[c][l]/b[c]:0,s?y.push(U,V):y.push(V,U);l=0;for(var k=0,z=A[l]-1,G=A[l+1]-1,W=z<G?z:G,X=M[1]-M[0],Y=n?A.length:A.length-1;k<=W&&l<Y;)g.push(k,k+X,k+1),g.push(k+X+1,k+1,k+X),(k+=1)===W&&(l++,l===A.length-1?(X=M[0]-M[l],z=A[l]-1,G=A[0]-1):(X=M[l+1]-M[l],z=A[l]-1,G=A[l+1]-1),k=M[l],W=z<G?z+k:G+k);if(t.ComputeNormals(m,g,v),o){var H=0,K=0;for(l=0;l<i.length;l++)H=3*M[l],K=l+1<i.length?3*(M[l+1]-1):v.length-3,v[H]=.5*(v[H]+v[K]),v[H+1]=.5*(v[H+1]+v[K+1]),v[H+2]=.5*(v[H+2]+v[K+2]),v[K]=v[H],v[K+1]=v[H+1],v[K+2]=v[H+2]}if(t._ComputeSides(d,m,g,v,y,r.frontUVs,r.backUVs),_)for(var j=new Float32Array(4*_.length),Z=0;Z<_.length;Z++)j[4*Z]=_[Z].r,j[4*Z+1]=_[Z].g,j[4*Z+2]=_[Z].b,j[4*Z+3]=_[Z].a;var Q=new t,q=new Float32Array(m),J=new Float32Array(v),$=new Float32Array(y);return Q.indices=g,Q.positions=q,Q.normals=J,Q.uvs=$,_&&Q.set(j,e.VertexBuffer.ColorKind),o&&(Q._idx=M),Q},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,h=r.height||r.size||1,l=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=[],_=0;_<6;_++)void 0===f[_]&&(f[_]=new e.Vector4(0,0,1,1)),d&&void 0===d[_]&&(d[_]=new e.Color4(1,1,1,1));for(var m=new e.Vector3(u/2,h/2,l/2),g=0;g<i.length;g++){var v=i[g],y=new e.Vector3(v.y,v.z,v.x),T=e.Vector3.Cross(v,y),x=o.length/3;n.push(x),n.push(x+1),n.push(x+2),n.push(x),n.push(x+2),n.push(x+3);var E=v.subtract(y).subtract(T).multiply(m);o.push(E.x,E.y,E.z),s.push(v.x,v.y,v.z),a.push(f[g].z,f[g].w),d&&p.push(d[g].r,d[g].g,d[g].b,d[g].a),E=v.subtract(y).add(T).multiply(m),o.push(E.x,E.y,E.z),s.push(v.x,v.y,v.z),a.push(f[g].x,f[g].w),d&&p.push(d[g].r,d[g].g,d[g].b,d[g].a),E=v.add(y).add(T).multiply(m),o.push(E.x,E.y,E.z),s.push(v.x,v.y,v.z),a.push(f[g].x,f[g].y),d&&p.push(d[g].r,d[g].g,d[g].b,d[g].a),E=v.add(y).subtract(T).multiply(m),o.push(E.x,E.y,E.z),s.push(v.x,v.y,v.z),a.push(f[g].z,f[g].y),d&&p.push(d[g].r,d[g].g,d[g].b,d[g].a)}t._ComputeSides(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 A=c===e.Mesh.DOUBLESIDE?p.concat(p):p;b.colors=A}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,h=0===r.sideOrientation?0:r.sideOrientation||e.Mesh.DEFAULTSIDE,l=new e.Vector3(n/2,o/2,s/2),c=2+i,f=2*c,d=[],p=[],_=[],m=[],g=0;g<=c;g++){for(var v=g/c,y=v*Math.PI*u,T=0;T<=f;T++){var x=T/f,E=x*Math.PI*2*a,b=e.Matrix.RotationZ(-y),A=e.Matrix.RotationY(E),M=e.Vector3.TransformCoordinates(e.Vector3.Up(),b),P=e.Vector3.TransformCoordinates(M,A),R=P.multiply(l),S=P.divide(l).normalize();p.push(R.x,R.y,R.z),_.push(S.x,S.y,S.z),m.push(x,v)}if(g>0)for(var O=p.length/3,C=O-2*(f+1);C+f+2<O;C++)d.push(C),d.push(C+1),d.push(C+f+1),d.push(C+f+1),d.push(C+1),d.push(C+f+2)}t._ComputeSides(h,p,d,_,m,r.frontUVs,r.backUVs);var I=new t;return I.indices=d,I.positions=p,I.normals=_,I.uvs=m,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,h=r.hasRings,l=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,_=1!==c&&l?2:0,m=h?u:1,g=2+(1+_)*m;for(i=0;i<g;i++)p&&void 0===p[i]&&(p[i]=new e.Color4(1,1,1,1));for(i=0;i<g;i++)d&&void 0===d[i]&&(d[i]=new e.Vector4(0,0,1,1));var v,y,T,x,E,b,A=[],M=[],P=[],R=[],S=[],O=2*Math.PI*c/a,C=(s-o)/2/n,I=e.Vector3.Zero(),L=e.Vector3.Zero(),D=e.Vector3.Zero(),B=e.Vector3.Zero(),F=e.Vector3.Zero(),N=e.Axis.Y,w=1,V=1,U=0,k=0;for(x=0;x<=u;x++)for(y=x/u,T=(y*(o-s)+s)/2,w=h&&0!==x&&x!==u?2:1,b=0;b<w;b++){for(h&&(V+=b),l&&(V+=2*b),E=0;E<=a;E++)v=E*O,I.x=Math.cos(-v)*T,I.y=-n/2+y*n,I.z=Math.sin(-v)*T,0===o&&x===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)*C,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=h?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&&S.push(p[V].r,p[V].g,p[V].b,p[V].a);1!==c&&l&&(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(N,L,F),F.normalize(),P.push(F.x,F.y,F.z,F.x,F.y,F.z),e.Vector3.CrossToRef(B,N,F),F.normalize(),P.push(F.x,F.y,F.z,F.x,F.y,F.z),k=h?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=h?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&&(S.push(p[V+1].r,p[V+1].g,p[V+1].b,p[V+1].a),S.push(p[V+1].r,p[V+1].g,p[V+1].b,p[V+1].a),S.push(p[V+2].r,p[V+2].g,p[V+2].b,p[V+2].a),S.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&&l?a+4:a;for(x=0,V=0;V<u;V++){for(E=0;E<a;E++){var G=x*(z+1)+E,W=(x+1)*(z+1)+E,X=x*(z+1)+(E+1),Y=(x+1)*(z+1)+(E+1);A.push(G,W,X),A.push(Y,X,W)}1!==c&&l&&(A.push(G+2,W+2,X+2),A.push(Y+2,X+2,W+2),A.push(G+4,W+4,X+4),A.push(Y+4,X+4,W+4)),x=h?x+2:x+1}var H=function(t){var r=t?o/2:s/2;if(0!==r){var i,u,h,l,f=t?d[g-1]:d[0];p&&(l=t?p[g-1]:p[0]);var _=M.length/3,m=t?n/2:-n/2,v=new e.Vector3(0,m,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&&S.push(l.r,l.g,l.b,l.a);var y=new e.Vector2(.5,.5);for(h=0;h<=a;h++){i=2*Math.PI*h*c/a;var T=Math.cos(-i),x=Math.sin(-i);u=new e.Vector3(T*r,m,x*r);var E=new e.Vector2(T*y.x+.5,x*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&&S.push(l.r,l.g,l.b,l.a)}for(h=0;h<a;h++)t?(A.push(_),A.push(_+(h+2)),A.push(_+(h+1))):(A.push(_),A.push(_+(h+1)),A.push(_+(h+2)))}};H(!1),H(!0),t._ComputeSides(f,M,A,P,R,r.frontUVs,r.backUVs);var K=new t;return K.indices=A,K.positions=M,K.normals=P,K.uvs=R,p&&(K.colors=S),K},t.CreateTorus=function(r){for(var i=[],n=[],o=[],s=[],a=r.diameter||1,u=r.thickness||.5,h=r.tessellation||16,l=0===r.sideOrientation?0:r.sideOrientation||e.Mesh.DEFAULTSIDE,c=h+1,f=0;f<=h;f++)for(var d=f/h,p=f*Math.PI*2/h-Math.PI/2,_=e.Matrix.Translation(a/2,0,0).multiply(e.Matrix.RotationY(p)),m=0;m<=h;m++){
- var g=1-m/h,v=m*Math.PI*2/h+Math.PI,y=Math.cos(v),T=Math.sin(v),x=new e.Vector3(y,T,0),E=x.scale(u/2),b=new e.Vector2(d,g);E=e.Vector3.TransformCoordinates(E,_),x=e.Vector3.TransformNormal(x,_),n.push(E.x,E.y,E.z),o.push(x.x,x.y,x.z),s.push(b.x,b.y);var A=(f+1)%c,M=(m+1)%c;i.push(f*c+m),i.push(f*c+M),i.push(A*c+m),i.push(f*c+M),i.push(A*c+M),i.push(A*c+m)}t._ComputeSides(l,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 h=new t;return h.indices=r,h.positions=i,h},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,h=e.Vector3.Zero(),l=0,c=0,f=0,d=0,p=0,_=0,m=0;for(m=0;m<s.length-1;m++)s[m+1].subtractToRef(s[m],h),l+=h.length();for(f=l/o,d=i*f/(i+n),m=0;m<s.length-1;m++){s[m+1].subtractToRef(s[m],h),c=Math.floor(h.length()/f),h.normalize();for(var g=0;g<c;g++)p=f*g,a.push(s[m].x+p*h.x,s[m].y+p*h.y,s[m].z+p*h.z),a.push(s[m].x+(p+d)*h.x,s[m].y+(p+d)*h.y,s[m].z+(p+d)*h.z),u.push(_,_+1),_+=2}var v=new t;return v.positions=a,v.indices=u,v},t.CreateGround=function(r){var i,n,o=[],s=[],a=[],u=[],h=r.width||1,l=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*h/c-h/2,0,(f-i)*l/f-l/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 _=new t;return _.indices=o,_.positions=s,_.normals=a,_.uvs=u,_},t.CreateTiledGround=function(r){var i,n,o,s,a=r.xmin||-1,u=r.zmin||-1,h=r.xmax||1,l=r.zmax||1,c=r.subdivisions||{w:1,h:1},f=r.precision||{w:1,h:1},d=[],p=[],_=[],m=[];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 g={w:(h-a)/c.w,h:(l-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 h=[a+n+i*u,a+(n+1)+i*u,a+(n+1)+(i+1)*u,a+n+(i+1)*u];d.push(h[1]),d.push(h[2]),d.push(h[3]),d.push(h[0]),d.push(h[1]),d.push(h[3])}var l=e.Vector3.Zero(),c=new e.Vector3(0,1,0);for(i=0;i<=f.h;i++)for(l.z=i*(s-r)/f.h+r,n=0;n<=f.w;n++)l.x=n*(o-t)/f.w+t,l.y=0,p.push(l.x,l.y,l.z),_.push(c.x,c.y,c.z),m.push(n/f.w,i/f.h)})(a+s*g.w,u+o*g.h,a+(s+1)*g.w,u+(o+1)*g.h);var v=new t;return v.indices=d,v.positions=p,v.normals=_,v.uvs=m,v},t.CreateGroundFromHeightMap=function(r){var i,n,o=[],s=[],a=[],u=[],h=r.colorFilter||new e.Color3(.3,.59,.11);for(i=0;i<=r.subdivisions;i++)for(n=0;n<=r.subdivisions;n++){var l=new e.Vector3(n*r.width/r.subdivisions-r.width/2,0,(r.subdivisions-i)*r.height/r.subdivisions-r.height/2),c=(l.x+r.width/2)/r.width*(r.bufferWidth-1)|0,f=(1-(l.z+r.height/2)/r.height)*(r.bufferHeight-1)|0,d=4*(c+f*r.bufferWidth),p=r.buffer[d]/255,_=r.buffer[d+1]/255,m=r.buffer[d+2]/255,g=p*h.r+_*h.g+m*h.b;l.y=r.minHeight+(r.maxHeight-r.minHeight)*g,s.push(l.x,l.y,l.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,h=0===r.sideOrientation?0:r.sideOrientation||e.Mesh.DEFAULTSIDE,l=a/2,c=u/2;n.push(-l,-c,0),o.push(0,0,-1),s.push(0,0),n.push(l,-c,0),o.push(0,0,-1),s.push(1,0),n.push(l,c,0),o.push(0,0,-1),s.push(1,1),n.push(-l,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(h,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,h=r.arc<=0||r.arc>1?1:r.arc||1,l=0===r.sideOrientation?0:r.sideOrientation||e.Mesh.DEFAULTSIDE;i.push(0,0,0),s.push(.5,.5);for(var c=2*Math.PI*h,f=c/u,d=0;d<c;d+=f){var p=Math.cos(d),_=Math.sin(d),m=(p+1)/2,g=(1-_)/2;i.push(a*p,a*_,0),s.push(m,g)}1===h&&(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(l,i,n,o,s,r.frontUVs,r.backUVs);var T=new t;return T.indices=n,T.positions=i,T.normals=o,T.uvs=s,T},t.CreatePolygon=function(r,i,n,o,s,a){for(var u=n||new Array(3),h=o,l=[],c=0;c<3;c++)void 0===u[c]&&(u[c]=new e.Vector4(0,0,1,1)),h&&void 0===h[c]&&(h[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),_=r.getIndices(),m=0,g=0,v=0;v<d.length;v+=3)0==Math.abs(d[v+1])&&(g=1),1==d[v+1]&&(g=0),-1==d[v+1]&&(g=2),m=v/3,p[2*m]=(1-p[2*m])*u[g].x+p[2*m]*u[g].z,p[2*m+1]=(1-p[2*m+1])*u[g].y+p[2*m+1]*u[g].w,h&&l.push(h[g].r,h[g].g,h[g].b,h[g].a);t._ComputeSides(i,f,_,d,p,s,a);var y=new t;if(y.indices=_,y.positions=f,y.normals=d,y.uvs=p,h){var T=i===e.Mesh.DOUBLESIDE?l.concat(l):l;y.colors=T}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,h=r.radiusY||o,l=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],_=[5,1,3,1,6,4,0,0,5,3,4,2,2,2,4,0,2,0,1,1,6,0,6,2,0,4,3,3,4,4,3,1,4,2,4,4,0,2,1,1,2,2,3,3,1,3,2,4],m=[0,0,0,0,1,0,0,1,1,0,0,0,1,1,0,0,1,1,1,0],g=[],v=[],y=[],T=[],x=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 A=0;A<20;A++){for(i=0;i<3;i++){var M=d[3*A+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(_[2*M]*(138/1024)+60/1024+m[A]*(-40/1024),_[2*M+1]*(239/1024)+26/1024+m[A]*(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),_=e.Vector3.Lerp(E[1],E[2],n/a);d=e.Vector3.Lerp(p,_,i/(a-n))}else d=new e.Vector3(f.x,f.y,f.z);d.x/=u,d.y/=h,d.z/=l,d.normalize();var m=e.Vector2.Lerp(b[0],b[2],r/a),A=e.Vector2.Lerp(b[1],b[2],r/a),M=a===r?b[2]:e.Vector2.Lerp(m,A,t/(a-r));v.push(f.x*u,f.y*h,f.z*l),y.push(d.x,d.y,d.z),T.push(M.x,M.y),g.push(x),x++},R=0;R<a;R++)for(var S=0;S+R<a;S++)P(S,R,S+1/3,R+1/3),P(S+1,R,S+1/3,R+1/3),P(S,R+1,S+1/3,R+1/3),S+R+1<a&&(P(S+1,R,S+2/3,R+2/3),P(S+1,R+1,S+2/3,R+2/3),P(S,R+1,S+2/3,R+2/3))}t._ComputeSides(n,v,g,y,T,r.frontUVs,r.backUVs);var O=new t;return O.indices=g,O.positions=v,O.normals=y,O.uvs=T,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,h,l=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,_=r.custom||i[l],m=_.face.length,g=r.faceUV||new Array(m),v=r.faceColors,y=void 0===r.flat||r.flat,T=0===r.sideOrientation?0:r.sideOrientation||e.Mesh.DEFAULTSIDE,x=[],E=[],b=[],A=[],M=[],P=0,R=0,S=[],O=0,C=0;if(y)for(C=0;C<m;C++)v&&void 0===v[C]&&(v[C]=new e.Color4(1,1,1,1)),g&&void 0===g[C]&&(g[C]=new e.Vector4(0,0,1,1));if(y)for(C=0;C<m;C++){var I=_.face[C].length;for(s=2*Math.PI/I,a=.5*Math.tan(s/2),u=.5,O=0;O<I;O++)x.push(_.vertex[_.face[C][O]][0]*f,_.vertex[_.face[C][O]][1]*d,_.vertex[_.face[C][O]][2]*p),S.push(P),P++,n=g[C].x+(g[C].z-g[C].x)*(.5+a),o=g[C].y+(g[C].w-g[C].y)*(u-.5),A.push(n,o),h=a*Math.cos(s)-u*Math.sin(s),u=a*Math.sin(s)+u*Math.cos(s),a=h,v&&M.push(v[C].r,v[C].g,v[C].b,v[C].a);for(O=0;O<I-2;O++)E.push(S[0+R],S[O+2+R],S[O+1+R]);R+=I}else{for(O=0;O<_.vertex.length;O++)x.push(_.vertex[O][0]*f,_.vertex[O][1]*d,_.vertex[O][2]*p),A.push(0,0);for(C=0;C<m;C++)for(O=0;O<_.face[C].length-2;O++)E.push(_.face[C][0],_.face[C][O+2],_.face[C][O+1])}t.ComputeNormals(x,E,b),t._ComputeSides(T,x,E,b,A,r.frontUVs,r.backUVs);var L=new t;return L.positions=x,L.indices=E,L.normals=b,L.uvs=A,v&&y&&(L.colors=M),L},t.CreateTorusKnot=function(r){var i,n,o=[],s=[],a=[],u=[],h=r.radius||2,l=r.tube||.5,c=r.radialSegments||32,f=r.tubularSegments||32,d=r.p||2,p=r.q||3,_=0===r.sideOrientation?0:r.sideOrientation||e.Mesh.DEFAULTSIDE,m=function(t){var r=Math.cos(t),i=Math.sin(t),n=p/d*t,o=Math.cos(n),s=h*(2+o)*.5*r,a=h*(2+o)*i*.5,u=h*Math.sin(n)*.5;return new e.Vector3(s,a,u)};for(i=0;i<=c;i++){var g=i%c,v=g/c*2*d*Math.PI,y=m(v),T=m(v+.01),x=T.subtract(y),E=T.add(y),b=e.Vector3.Cross(x,E);for(E=e.Vector3.Cross(b,x),b.normalize(),E.normalize(),n=0;n<f;n++){var A=n%f,M=A/f*2*Math.PI,P=-l*Math.cos(M),R=l*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 S=(n+1)%f,O=i*f+n,C=(i+1)*f+n,I=(i+1)*f+S,L=i*f+S;o.push(L),o.push(C),o.push(O),o.push(L),o.push(I),o.push(C)}t.ComputeNormals(s,o,a),t._ComputeSides(_,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,h=0,l=0,c=0,f=0,d=0,p=0,_=0,m=0,g=0,v=0,y=0,T=0,x=0,E=0,b=0,A=!1,M=!1,P=!1,R=1;if(i&&(A=!!i.facetNormals,M=!!i.facetPositions,P=!!i.facetPartitioning,R=!0===i.useRightHandedSystem?-1:1),P){var S=0,O=0,C=0,I=0,L=0,D=0,B=0,F=0,N=0,w=0,V=0,U=0,k=0,z=0,G=0,W=0,X=i.bbSize.x>i.bbSize.y?i.bbSize.x:i.bbSize.y;X=X>i.bbSize.z?X:i.bbSize.z;var Y=i.subDiv.X*i.ratio/i.bbSize.x,H=i.subDiv.Y*i.ratio/i.bbSize.y,K=i.subDiv.Z*i.ratio/i.bbSize.z,j=i.subDiv.max*i.subDiv.max;i.facetPartitioning.length=0}for(n=0;n<e.length;n++)r[n]=0;var Z=t.length/3;for(n=0;n<Z;n++)_=3*t[3*n],m=_+1,g=_+2,v=3*t[3*n+1],y=v+1,T=v+2,x=3*t[3*n+2],E=x+1,b=x+2,o=e[_]-e[v],s=e[m]-e[y],a=e[g]-e[T],u=e[x]-e[v],h=e[E]-e[y],l=e[b]-e[T],c=R*(s*l-a*h),f=R*(a*u-o*l),d=R*(o*h-s*u),p=Math.sqrt(c*c+f*f+d*d),p=0===p?1:p,c/=p,f/=p,d/=p,A&&(i.facetNormals[n].x=c,i.facetNormals[n].y=f,i.facetNormals[n].z=d),M&&(i.facetPositions[n].x=(e[_]+e[v]+e[x])/3,i.facetPositions[n].y=(e[m]+e[y]+e[E])/3,i.facetPositions[n].z=(e[g]+e[T]+e[b])/3),P&&(S=Math.floor((i.facetPositions[n].x-i.bInfo.minimum.x*i.ratio)*Y),O=Math.floor((i.facetPositions[n].y-i.bInfo.minimum.y*i.ratio)*H),C=Math.floor((i.facetPositions[n].z-i.bInfo.minimum.z*i.ratio)*K),I=Math.floor((e[_]-i.bInfo.minimum.x*i.ratio)*Y),L=Math.floor((e[m]-i.bInfo.minimum.y*i.ratio)*H),D=Math.floor((e[g]-i.bInfo.minimum.z*i.ratio)*K),B=Math.floor((e[v]-i.bInfo.minimum.x*i.ratio)*Y),F=Math.floor((e[y]-i.bInfo.minimum.y*i.ratio)*H),N=Math.floor((e[T]-i.bInfo.minimum.z*i.ratio)*K),w=Math.floor((e[x]-i.bInfo.minimum.x*i.ratio)*Y),V=Math.floor((e[E]-i.bInfo.minimum.y*i.ratio)*H),U=Math.floor((e[b]-i.bInfo.minimum.z*i.ratio)*K),z=I+i.subDiv.max*L+j*D,G=B+i.subDiv.max*F+j*N,W=w+i.subDiv.max*V+j*U,k=S+i.subDiv.max*O+j*C,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[W]=i.facetPartitioning[W]?i.facetPartitioning[W]:new Array,i.facetPartitioning[z].push(n),G!=z&&i.facetPartitioning[G].push(n),W!=G&&W!=z&&i.facetPartitioning[W].push(n),k!=z&&k!=G&&k!=W&&i.facetPartitioning[k].push(n)),r[_]+=c,r[m]+=f,r[g]+=d,r[v]+=c,r[y]+=f,r[T]+=d,r[x]+=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,h,l=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<l;u+=3)f=i[u],i[u]=i[u+2],i[u+2]=f;for(h=0;h<c;h++)n[h]=-n[h];break;case e.Mesh.DOUBLESIDE:for(var d=r.length,p=d/3,_=0;_<d;_++)r[d+_]=r[_];for(u=0;u<l;u+=3)i[u+l]=i[u+2]+p,i[u+1+l]=i[u+1]+p,i[u+2+l]=i[u]+p;for(h=0;h<c;h++)n[c+h]=-n[h];var m=o.length,g=0;for(g=0;g<m;g++)o[g+m]=o[g];var s=s||new e.Vector4(0,0,1,1),a=a||new e.Vector4(0,0,1,1);for(g=0,u=0;u<m/2;u++)o[g]=s.x+(s.z-s.x)*o[g],o[g+1]=s.y+(s.w-s.y)*o[g+1],o[g+m]=a.x+(a.z-a.x)*o[g+m],o[g+m+1]=a.y+(a.w-a.y)*o[g+m+1],g+=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 h=r.uv2s;h&&n.set(h,e.VertexBuffer.UV2Kind);var l=r.uv3s;l&&n.set(l,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 _=r.matricesIndices;_&&n.set(_,e.VertexBuffer.MatricesIndicesKind);var m=r.matricesWeights;m&&n.set(m,e.VertexBuffer.MatricesWeightsKind);var g=r.indices;g&&(n.indices=g),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=[],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(),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();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(),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 h=this.getVerticesData(s);h instanceof Float32Array?i.set(new Float32Array(h),s):i.set(h.slice(0),s),u||(a=this.getVertexBuffer(s).isUpdatable(),u=!a)}var l=new t(r,this._scene,i,a,null);l.delayLoadState=this.delayLoadState,l.delayLoadingFile=this.delayLoadingFile,l._delayLoadingFunction=this._delayLoadingFunction;for(s in this._delayInfo)l._delayInfo=l._delayInfo||[],l._delayInfo.push(s);return l._boundingInfo=new e.BoundingInfo(this._extend.minimum,this._extend.maximum),l},t.prototype.serialize=function(){var t={};return t.id=this.id,e.Tags&&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(t,r){var i=r.getScene(),n=t.geometryId;if(n){var o=i.getGeometryByID(n);o&&o.applyToMesh(r)}else if(t instanceof ArrayBuffer){var s=r._binaryInfo;if(s.positionsAttrDesc&&s.positionsAttrDesc.count>0){var a=new Float32Array(t,s.positionsAttrDesc.offset,s.positionsAttrDesc.count);r.setVerticesData(e.VertexBuffer.PositionKind,a,!1)}if(s.normalsAttrDesc&&s.normalsAttrDesc.count>0){var u=new Float32Array(t,s.normalsAttrDesc.offset,s.normalsAttrDesc.count);r.setVerticesData(e.VertexBuffer.NormalKind,u,!1)}if(s.uvsAttrDesc&&s.uvsAttrDesc.count>0){var h=new Float32Array(t,s.uvsAttrDesc.offset,s.uvsAttrDesc.count);r.setVerticesData(e.VertexBuffer.UVKind,h,!1)}if(s.uvs2AttrDesc&&s.uvs2AttrDesc.count>0){var l=new Float32Array(t,s.uvs2AttrDesc.offset,s.uvs2AttrDesc.count);r.setVerticesData(e.VertexBuffer.UV2Kind,l,!1)}if(s.uvs3AttrDesc&&s.uvs3AttrDesc.count>0){var c=new Float32Array(t,s.uvs3AttrDesc.offset,s.uvs3AttrDesc.count);r.setVerticesData(e.VertexBuffer.UV3Kind,c,!1)}if(s.uvs4AttrDesc&&s.uvs4AttrDesc.count>0){var f=new Float32Array(t,s.uvs4AttrDesc.offset,s.uvs4AttrDesc.count);r.setVerticesData(e.VertexBuffer.UV4Kind,f,!1)}if(s.uvs5AttrDesc&&s.uvs5AttrDesc.count>0){var d=new Float32Array(t,s.uvs5AttrDesc.offset,s.uvs5AttrDesc.count);r.setVerticesData(e.VertexBuffer.UV5Kind,d,!1)}if(s.uvs6AttrDesc&&s.uvs6AttrDesc.count>0){var p=new Float32Array(t,s.uvs6AttrDesc.offset,s.uvs6AttrDesc.count);r.setVerticesData(e.VertexBuffer.UV6Kind,p,!1)}if(s.colorsAttrDesc&&s.colorsAttrDesc.count>0){var _=new Float32Array(t,s.colorsAttrDesc.offset,s.colorsAttrDesc.count);r.setVerticesData(e.VertexBuffer.ColorKind,_,!1,s.colorsAttrDesc.stride)}if(s.matricesIndicesAttrDesc&&s.matricesIndicesAttrDesc.count>0){var m=new Int32Array(t,s.matricesIndicesAttrDesc.offset,s.matricesIndicesAttrDesc.count);r.setVerticesData(e.VertexBuffer.MatricesIndicesKind,m,!1)}if(s.matricesWeightsAttrDesc&&s.matricesWeightsAttrDesc.count>0){var g=new Float32Array(t,s.matricesWeightsAttrDesc.offset,s.matricesWeightsAttrDesc.count);r.setVerticesData(e.VertexBuffer.MatricesWeightsKind,g,!1)}if(s.indicesAttrDesc&&s.indicesAttrDesc.count>0){var v=new Int32Array(t,s.indicesAttrDesc.offset,s.indicesAttrDesc.count);r.setIndices(v)}if(s.subMeshesAttrDesc&&s.subMeshesAttrDesc.count>0){var y=new Int32Array(t,s.subMeshesAttrDesc.offset,5*s.subMeshesAttrDesc.count);r.subMeshes=[];for(var T=0;T<s.subMeshesAttrDesc.count;T++){var x=y[5*T+0],E=y[5*T+1],b=y[5*T+2],A=y[5*T+3],M=y[5*T+4];new e.SubMesh(x,E,b,A,M,r)}}}else if(t.positions&&t.normals&&t.indices){if(r.setVerticesData(e.VertexBuffer.PositionKind,t.positions,t.positions._updatable),r.setVerticesData(e.VertexBuffer.NormalKind,t.normals,t.normals._updatable),t.uvs&&r.setVerticesData(e.VertexBuffer.UVKind,t.uvs,t.uvs._updatable),t.uvs2&&r.setVerticesData(e.VertexBuffer.UV2Kind,t.uvs2,t.uvs2._updatable),t.uvs3&&r.setVerticesData(e.VertexBuffer.UV3Kind,t.uvs3,t.uvs3._updatable),t.uvs4&&r.setVerticesData(e.VertexBuffer.UV4Kind,t.uvs4,t.uvs4._updatable),t.uvs5&&r.setVerticesData(e.VertexBuffer.UV5Kind,t.uvs5,t.uvs5._updatable),t.uvs6&&r.setVerticesData(e.VertexBuffer.UV6Kind,t.uvs6,t.uvs6._updatable),t.colors&&r.setVerticesData(e.VertexBuffer.ColorKind,e.Color4.CheckColors4(t.colors,t.positions.length/3),t.colors._updatable),t.matricesIndices)if(t.matricesIndices._isExpanded)delete t.matricesIndices._isExpanded,r.setVerticesData(e.VertexBuffer.MatricesIndicesKind,t.matricesIndices,t.matricesIndices._updatable);else{for(var P=[],T=0;T<t.matricesIndices.length;T++){var R=t.matricesIndices[T];P.push(255&R),P.push((65280&R)>>8),P.push((16711680&R)>>16),P.push(R>>24)}r.setVerticesData(e.VertexBuffer.MatricesIndicesKind,P,t.matricesIndices._updatable)}if(t.matricesIndicesExtra)if(t.matricesIndicesExtra._isExpanded)delete t.matricesIndices._isExpanded,r.setVerticesData(e.VertexBuffer.MatricesIndicesExtraKind,t.matricesIndicesExtra,t.matricesIndicesExtra._updatable);else{for(var P=[],T=0;T<t.matricesIndicesExtra.length;T++){var R=t.matricesIndicesExtra[T];P.push(255&R),P.push((65280&R)>>8),P.push((16711680&R)>>16),P.push(R>>24)}r.setVerticesData(e.VertexBuffer.MatricesIndicesExtraKind,P,t.matricesIndicesExtra._updatable)}t.matricesWeights&&r.setVerticesData(e.VertexBuffer.MatricesWeightsKind,t.matricesWeights,t.matricesWeights._updatable),t.matricesWeightsExtra&&r.setVerticesData(e.VertexBuffer.MatricesWeightsExtraKind,t.matricesWeightsExtra,t.matricesWeights._updatable),r.setIndices(t.indices)}if(t.subMeshes){r.subMeshes=[];for(var S=0;S<t.subMeshes.length;S++){var O=t.subMeshes[S];new e.SubMesh(O.materialIndex,O.verticesStart,O.verticesCount,O.indexStart,O.indexCount,r)}}r._shouldGenerateFlatShading&&(r.convertToFlatShadedMesh(),delete r._shouldGenerateFlatShading),r.computeWorldMatrix(!0),i._selectionOctree&&i._selectionOctree.addMesh(r)},t.Parse=function(r,i,n){if(i.getGeometryByID(r.id))return null;var o=new t(r.id,i);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,h,l){void 0===l&&(l=e.Mesh.DEFAULTSIDE);var c=t.call(this,r,i,u,h)||this;return c.pathArray=n,c.closeArray=o,c.closePath=s,c.offset=a,c.side=l,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 h=r.call(this,t,i,s,a)||this;return h.segments=n,h.diameter=o,h.side=u,h}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 h=t.call(this,r,i,s,a)||this;return h.radius=n,h.tessellation=o,h.side=u,h}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,h,l,c){void 0===u&&(u=1),void 0===c&&(c=e.Mesh.DEFAULTSIDE);var f=r.call(this,t,i,h,l)||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 h=(function(r){function i(t,i,n,o,s,a,u,h){void 0===h&&(h=e.Mesh.DEFAULTSIDE);var l=r.call(this,t,i,a,u)||this;return l.diameter=n,l.thickness=o,l.tessellation=s,l.side=h,l}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=h;var l=(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=l;var c=(function(t){function r(e,r,i,n,o,s,a,u,h,l){var c=t.call(this,e,r,h,l)||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,h,l,c,f){void 0===f&&(f=e.Mesh.DEFAULTSIDE);var d=r.call(this,t,i,l,c)||this;return d.radius=n,d.tube=o,d.radialSegments=s,d.tubularSegments=a,d.p=u,d.q=h,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],h=u.apply();h&&(u.onBeforeRenderObservable.notifyObservers(h),this._prepareBuffers(),o.bindBuffers(this._vertexBuffers,this._indexBuffer,h),o.draw(!0,0,6),u.onAfterRenderObservable.notifyObservers(h))}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 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,h){var l=void 0;if(!isNaN(parseFloat(s))&&isFinite(s)?l=r.ANIMATIONTYPE_FLOAT:s instanceof e.Quaternion?l=r.ANIMATIONTYPE_QUATERNION:s instanceof e.Vector3?l=r.ANIMATIONTYPE_VECTOR3:s instanceof e.Vector2?l=r.ANIMATIONTYPE_VECTOR2:s instanceof e.Color3?l=r.ANIMATIONTYPE_COLOR3:s instanceof e.Size&&(l=r.ANIMATIONTYPE_SIZE),void 0==l)return null;var c=new r(t,i,n,l,u),f=[{frame:0,value:s},{frame:o,value:a}];return c.setKeys(f),void 0!==h&&c.setEasingFunction(h),c},r.CreateAndStartAnimation=function(e,t,i,n,o,s,a,u,h,l){var c=r._PrepareAnimation(e,i,n,o,s,a,u,h);return t.getScene().beginDirectAnimation(t,[c],0,o,1===c.loopMode,1,l)},r.CreateMergeAndStartAnimation=function(e,t,i,n,o,s,a,u,h,l){var c=r._PrepareAnimation(e,i,n,o,s,a,u,h);return t.animations.push(c),t.getScene().beginAnimation(t,0,o,1===c.loopMode,1,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 h=this._keys[a],l=this._getKeyValue(h.value),c=this._getKeyValue(u.value),f=void 0!==h.outTangent&&void 0!==u.inTangent,d=u.frame-h.frame,p=(e-h.frame)/d;switch(null!=this._easingFunction&&(p=this._easingFunction.ease(p)),this.dataType){case r.ANIMATIONTYPE_FLOAT:var _=f?this.floatInterpolateFunctionWithTangents(l,h.outTangent*d,c,u.inTangent*d,p):this.floatInterpolateFunction(l,c,p);switch(i){case r.ANIMATIONLOOPMODE_CYCLE:case r.ANIMATIONLOOPMODE_CONSTANT:return _;case r.ANIMATIONLOOPMODE_RELATIVE:return n*t+_}break;case r.ANIMATIONTYPE_QUATERNION:var m=f?this.quaternionInterpolateFunctionWithTangents(l,h.outTangent.scale(d),c,u.inTangent.scale(d),p):this.quaternionInterpolateFunction(l,c,p);switch(i){case r.ANIMATIONLOOPMODE_CYCLE:case r.ANIMATIONLOOPMODE_CONSTANT:return m;case r.ANIMATIONLOOPMODE_RELATIVE:return m.add(n.scale(t))}return m;case r.ANIMATIONTYPE_VECTOR3:var g=f?this.vector3InterpolateFunctionWithTangents(l,h.outTangent.scale(d),c,u.inTangent.scale(d),p):this.vector3InterpolateFunction(l,c,p);switch(i){case r.ANIMATIONLOOPMODE_CYCLE:case r.ANIMATIONLOOPMODE_CONSTANT:return g;case r.ANIMATIONLOOPMODE_RELATIVE:return g.add(n.scale(t))}case r.ANIMATIONTYPE_VECTOR2:var v=f?this.vector2InterpolateFunctionWithTangents(l,h.outTangent.scale(d),c,u.inTangent.scale(d),p):this.vector2InterpolateFunction(l,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(l,c,p);case r.ANIMATIONLOOPMODE_RELATIVE:return this.sizeInterpolateFunction(l,c,p).add(n.scale(t))}case r.ANIMATIONTYPE_COLOR3:switch(i){case r.ANIMATIONLOOPMODE_CYCLE:case r.ANIMATIONLOOPMODE_CONSTANT:return this.color3InterpolateFunction(l,c,p);case r.ANIMATIONLOOPMODE_RELATIVE:return this.color3InterpolateFunction(l,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(l,c,p);case r.ANIMATIONLOOPMODE_RELATIVE:return l}}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 h={frame:0,value:this._keys[0].value};this._keys.splice(0,0,h)}(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 l,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 _=this._interpolate(i,0,r.ANIMATIONLOOPMODE_CYCLE),m=this._interpolate(n,0,r.ANIMATIONLOOPMODE_CYCLE);switch(this.dataType){case r.ANIMATIONTYPE_FLOAT:this._offsetsCache[p]=m-_;break;case r.ANIMATIONTYPE_QUATERNION:this._offsetsCache[p]=m.subtract(_);break;case r.ANIMATIONTYPE_VECTOR3:this._offsetsCache[p]=m.subtract(_);case r.ANIMATIONTYPE_VECTOR2:this._offsetsCache[p]=m.subtract(_);case r.ANIMATIONTYPE_SIZE:this._offsetsCache[p]=m.subtract(_);case r.ANIMATIONTYPE_COLOR3:this._offsetsCache[p]=m.subtract(_)}this._highLimitsCache[p]=m}d=this._highLimitsCache[p],l=this._offsetsCache[p]}if(void 0===l)switch(this.dataType){case r.ANIMATIONTYPE_FLOAT:l=0;break;case r.ANIMATIONTYPE_QUATERNION:l=new e.Quaternion(0,0,0,0);break;case r.ANIMATIONTYPE_VECTOR3:l=e.Vector3.Zero();break;case r.ANIMATIONTYPE_VECTOR2:l=e.Vector2.Zero();break;case r.ANIMATIONTYPE_SIZE:l=e.Size.Zero();break;case r.ANIMATIONTYPE_COLOR3:l=e.Color3.Black()}var g=f/c>>0,v=u?i+f%c:n,y=this._interpolate(v,g,this.loopMode,l,d);this.setValue(y);for(var T=0;T<this._events.length;T++)if(v>=this._events[T].frame){var x=this._events[T];x.isDone||(x.onlyOnce&&(this._events.splice(T,1),T--),x.isDone=!0,x.action())}else this._events[T].isDone&&!this._events[T].onlyOnce&&(this._events[T].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})();n._ANIMATIONTYPE_FLOAT=0,n._ANIMATIONTYPE_VECTOR3=1,n._ANIMATIONTYPE_QUATERNION=2,n._ANIMATIONTYPE_MATRIX=3,
- n._ANIMATIONTYPE_COLOR3=4,n._ANIMATIONTYPE_VECTOR2=5,n._ANIMATIONTYPE_SIZE=6,n._ANIMATIONLOOPMODE_RELATIVE=0,n._ANIMATIONLOOPMODE_CYCLE=1,n._ANIMATIONLOOPMODE_CONSTANT=2,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})();t._EASINGMODE_EASEIN=0,t._EASINGMODE_EASEOUT=1,t._EASINGMODE_EASEINOUT=2,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),h=u+1,l=(1-Math.pow(r,u))/(n*o),c=(1-Math.pow(r,h))/(n*o),f=.5*(l+c),d=e-f,p=f-l;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 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},t})(t);e.QuadraticEase=h;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*e*e},t})(t);e.QuarticEase=l;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),delete this.attached[t],this.rebuildInputCheck())}},t.prototype.removeByType=function(e){for(var t in this.attached){var r=this.attached[t];r.getTypeName()===e&&(r.detachControl(this.attachedElement),delete this.attached[t],this.rebuildInputCheck())}},t.prototype._addCheckInputs=function(e){var t=this.checkInputs;return function(){t(),e()}},t.prototype.attachInput=function(e){e.attachControl(this.attachedElement,this.noPreventDefault)},t.prototype.attachElement=function(t,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){if(this.attachedElement===e){for(var t in this.attached){this.attached[t];this.attached[t].detachControl(e)}this.attachedElement=null}},t.prototype.rebuildInputCheck=function(){this.checkInputs=function(){};for(var e in this.attached){var t=this.attached[e];t.checkInputs&&(this.checkInputs=this._addCheckInputs(t.checkInputs.bind(t)))}},t.prototype.clear=function(){this.attachedElement&&this.detachElement(this.attachedElement),this.attached={},this.attachedElement=null,this.checkInputs=function(){}},t.prototype.serialize=function(t){var r={};for(var i in this.attached){var n=this.attached[i],o=e.SerializationHelper.Serialize(n);r[n.getTypeName()]=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].getTypeName()];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"},r})(e.Camera);__decorate([e.serializeAsVector3()],t.prototype,"rotation",void 0),__decorate([e.serialize()],t.prototype,"speed",void 0),__decorate([e.serializeAsMeshReference("lockedTargetId")],t.prototype,"lockedTarget",void 0),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.getTypeName=function(){return"ArcRotateCameraKeyboardMoveInput"},t.prototype.getSimpleName=function(){return"keyboard"},t})();__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),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.getTypeName=function(){return"ArcRotateCameraMouseWheelInput"},t.prototype.getSimpleName=function(){return"mousewheel"},t})();__decorate([e.serialize()],t.prototype,"wheelPrecision",void 0),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,h){var l=a.event;if(a.type===e.PointerEventTypes.POINTERMOVE||-1!==s.buttons.indexOf(l.button))if(a.type===e.PointerEventTypes.POINTERDOWN){try{l.srcElement.setPointerCapture(l.pointerId)}catch(e){}s._isPanClick=l.button===s.camera._panningMouseButton,i={x:l.clientX,y:l.clientY,pointerId:l.pointerId,type:l.pointerType},void 0===n?n=i:void 0===o&&(o=i),r||(l.preventDefault(),t.focus())}else if(a.type===e.PointerEventTypes.POINTERUP){try{l.srcElement.releasePointerCapture(l.pointerId)}catch(e){}i=null,u=0,n=o=void 0,r||l.preventDefault()}else if(a.type===e.PointerEventTypes.POINTERMOVE)if(r||l.preventDefault(),n&&void 0===o){if(0!==s.panningSensibility&&(l.ctrlKey&&s.camera._useCtrlForPanning||!s.camera._useCtrlForPanning&&s._isPanClick))s.camera.inertialPanningX+=-(l.clientX-i.x)/s.panningSensibility,s.camera.inertialPanningY+=(l.clientY-i.y)/s.panningSensibility;else{var c=l.clientX-i.x,f=l.clientY-i.y;s.camera.inertialAlphaOffset-=c/s.angularSensibilityX,s.camera.inertialBetaOffset-=f/s.angularSensibilityY}i.x=l.clientX,i.y=l.clientY}else if(n&&o){var d=n.pointerId===l.pointerId?n:o;d.x=l.clientX,d.y=l.clientY;var p=s.pinchInwards?1:-1,_=n.x-o.x,m=n.y-o.y,g=_*_+m*m;if(0===u)return void(u=g);g!==u&&(s.camera.inertialRadiusOffset+=(g-u)/(s.pinchPrecision*((s.angularSensibilityX+s.angularSensibilityY)/2)*p),u=g)}},this._observer=this.camera.getScene().onPointerObservable.add(this._pointerInput,e.PointerEventTypes.POINTERDOWN|e.PointerEventTypes.POINTERUP|e.PointerEventTypes.POINTERMOVE),this._onContextMenu=function(e){e.preventDefault()},this.camera._useCtrlForPanning||t.addEventListener("contextmenu",this._onContextMenu,!1),this._onLostFocus=function(){n=o=void 0,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){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),e.Tools.UnregisterTopRootEvents([{name:"blur",handler:this._onLostFocus}])},t.prototype.getTypeName=function(){return"ArcRotateCameraPointersInput"},t.prototype.getSimpleName=function(){return"pointers"},t})());__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),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.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 h=u._getTargetPosition();h.addToRef(new e.Vector3(u.radius*n*a,u.radius*s,u.radius*o*a),u._newPosition),u.position.copyFrom(u._newPosition);var l=u.upVector;u.allowUpsideDown&&u.beta<0&&(l=l.clone(),l=l.negate()),e.Matrix.LookAtLHToRef(u.position,h,l,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}),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)}return 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)<this.speed*e.Epsilon&&(this.inertialAlphaOffset=0),Math.abs(this.inertialBetaOffset)<this.speed*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(),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();else{var i=e,n=this._getTargetPosition();if(n&&!r&&n.equals(i))return;this._target=i,this._targetBoundingCenter=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"},r})(e.TargetCamera);__decorate([e.serialize()],t.prototype,"alpha",void 0),__decorate([e.serialize()],t.prototype,"beta",void 0),__decorate([e.serialize()],t.prototype,"radius",void 0),__decorate([e.serializeAsVector3("target")],t.prototype,"_target",void 0),__decorate([e.serialize()],t.prototype,"inertialAlphaOffset",void 0),__decorate([e.serialize()],t.prototype,"inertialBetaOffset",void 0),__decorate([e.serialize()],t.prototype,"inertialRadiusOffset",void 0),__decorate([e.serialize()],t.prototype,"lowerAlphaLimit",void 0),__decorate([e.serialize()],t.prototype,"upperAlphaLimit",void 0),__decorate([e.serialize()],t.prototype,"lowerBetaLimit",void 0),__decorate([e.serialize()],t.prototype,"upperBetaLimit",void 0),__decorate([e.serialize()],t.prototype,"lowerRadiusLimit",void 0),__decorate([e.serialize()],t.prototype,"upperRadiusLimit",void 0),__decorate([e.serialize()],t.prototype,"inertialPanningX",void 0),__decorate([e.serialize()],t.prototype,"inertialPanningY",void 0),__decorate([e.serialize()],t.prototype,"panningInertia",void 0),__decorate([e.serialize()],t.prototype,"zoomOnFactor",void 0),__decorate([e.serialize()],t.prototype,"allowUpsideDown",void 0),e.ArcRotateCamera=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function 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,h){void 0===a&&(a=null),void 0===u&&(u=null),void 0===h&&(h=e.Engine.TEXTUREFORMAT_RGBA);var l=t.call(this,i)||this;if(l.coordinatesMode=e.Texture.CUBIC_MODE,l.name=r,l.url=r,l._noMipmap=o,l.hasAlpha=!1,l._format=h,!r&&!s)return l;if(l._texture=l._getFromCache(r,o),!s){n||(n=["_px.jpg","_py.jpg","_pz.jpg","_nx.jpg","_ny.jpg","_nz.jpg"]),s=[];for(var c=0;c<n.length;c++)s.push(r+n[c]);l._extensions=n}return l._files=s,l._texture?a&&(l._texture.isReady?e.Tools.SetImmediate((function(){return a()})):l._texture.onLoadedCallbacks.push(a)):i.useDelayedTextureLoading?l.delayLoadState=e.Engine.DELAYLOADSTATE_NOTLOADED:l._texture=i.getEngine().createCubeTexture(r,i,s,o,a,u,l._format),l.isCube=!0,l._textureMatrix=e.Matrix.Identity(),l}return __extends(r,t),r.CreateFromImages=function(e,t,i){return new r("",t,null,i,e)},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._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.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,h,l,c,f){void 0===s&&(s=!0),void 0===a&&(a=e.Engine.TEXTURETYPE_UNSIGNED_INT),void 0===u&&(u=!1),void 0===h&&(h=e.Texture.TRILINEAR_SAMPLINGMODE),void 0===l&&(l=!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.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:h,generateDepthBuffer:l,generateStencilBuffer:c},h===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){var u;this.activeCamera?(u=this.activeCamera,i.setViewport(this.activeCamera.viewport),this.activeCamera!==r.activeCamera&&r.setTransformMatrix(this.activeCamera.getViewMatrix(),this.activeCamera.getProjectionMatrix(!0))):(u=r.activeCamera,i.setViewport(r.activeCamera.viewport)),this._renderingManager.reset();for(var h=this.renderList?this.renderList:r.getActiveMeshes().data,l=this.renderList?this.renderList.length:r.getActiveMeshes().length,c=r.getRenderId(),f=0;f<l;f++){var a=h[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 _=a.subMeshes[p];r._activeIndices.addCount(_.indexCount,!1),this._renderingManager.dispatch(_)}}}}for(var m=0;m<r.particleSystems.length;m++){var g=r.particleSystems[m];g.isStarted()&&g.emitter&&g.emitter.position&&g.emitter.isEnabled()&&(h.indexOf(g.emitter)>=0&&this._renderingManager.dispatchParticles(g))}if(this.isCube)for(var v=0;v<6;v++)this.renderToTarget(v,h,l,e,t),r.incrementRenderId(),r.resetCachedMaterial();else this.renderToTarget(0,h,l,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)||(this.isCube?u.bindFramebuffer(this._texture,t):u.bindFramebuffer(this._texture)),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);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})(e.Texture);t._REFRESHRATE_RENDER_ONCE=0,t._REFRESHRATE_RENDER_ONEVERYFRAME=1,t._REFRESHRATE_RENDER_ONEVERYTWOFRAMES=2,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,h=!!s.generateDepthTexture&&s.generateDepthTexture,l=void 0===s.doNotChangeAspectRatio||s.doNotChangeAspectRatio;if(a=t.call(this,r,i,o,u,l)||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,_=void 0!==s.generateStencilBuffer&&s.generateStencilBuffer;return a._count=n,a._size=i,a._multiRenderTargetOptions={samplingModes:f,generateMipMaps:u,generateDepthBuffer:p,generateStencilBuffer:_,generateDepthTexture:h,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 h=t.call(this,r,i,n,o,!0,s,!1,a,u)||this;return h.mirrorPlane=new e.Plane(0,1,0,1),h._transformMatrix=e.Matrix.Zero(),h._mirrorMatrix=e.Matrix.Zero(),h._blurKernelX=0,h._blurKernelY=0,h._blurRatio=1,h.onBeforeRenderObservable.add((function(){e.Matrix.ReflectionToRef(h.mirrorPlane,h._mirrorMatrix),h._savedViewMatrix=n.getViewMatrix(),h._mirrorMatrix.multiplyToRef(h._savedViewMatrix,h._transformMatrix),n.setTransformMatrix(h._transformMatrix,n.getProjectionMatrix()),n.clipPlane=h.mirrorPlane,n.getEngine().cullBackFaces=!1,n._mirroredCameraPosition=e.Vector3.TransformCoordinates(n.activeCamera.position,h._mirrorMatrix)})),h.onAfterRenderObservable.add((function(){n.setTransformMatrix(h._savedViewMatrix,n.getProjectionMatrix()),n.getEngine().cullBackFaces=!0,n._mirroredCameraPosition=null,delete n.clipPlane})),h}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 h=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=h.createDynamicTexture(i.width,i.height,o,s)):(u._canvas=document.createElement("canvas"),i.width?u._texture=h.createDynamicTexture(i.width,i.height,o,s):u._texture=h.createDynamicTexture(i,i,o,s));var l=u.getSize();return u._canvas.width=l.width,u._canvas.height=l.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 h=this._context.measureText(e);t=(u.width-h.width)/2}if(null===r||void 0===r){var l=parseInt(i.replace(/\D/g,""));r=u.height/2+l/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 h;return u.name=r,i instanceof HTMLVideoElement?u.video=i:(h=i,u.video=document.createElement("video"),u.video.autoplay=!1,u.video.loop=!0),u._generateMipMaps=o,u._samplingMode=a,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),h?(u.video.addEventListener("canplay",(function(){u._createTexture()})),h.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,h){void 0===a&&(a=!0),void 0===u&&(u=!1),void 0===h&&(h=e.Texture.TRILINEAR_SAMPLINGMODE);var l=t.call(this,null,s,!a,u)||this;return l.format=o,l._texture=s.getEngine().createRawTexture(r,i,n,o,a,u,h),l.wrapU=e.Texture.CLAMP_ADDRESSMODE,l.wrapV=e.Texture.CLAMP_ADDRESSMODE,l}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 h,l,c=(o.flags,o.pixel_size>>3),f=o.width*o.height*c;if(a&&(l=i.subarray(n,n+=o.colormap_length*(o.colormap_size>>3))),s){h=new Uint8Array(f);for(var d,p,_,m=0,g=new Uint8Array(c);n<f&&m<f;)if(d=i[n++],p=1+(127&d),128&d){for(_=0;_<c;++_)g[_]=i[n++];for(_=0;_<p;++_)h.set(g,m+_*c);m+=c*p}else{for(p*=c,_=0;_<p;++_)h[m+_]=i[n++];m+=p}}else h=i.subarray(n,n+=a?o.width*o.height:f);var v,y,T,x,E,b;switch((o.flags&t._ORIGIN_MASK)>>t._ORIGIN_SHIFT){default:case t._ORIGIN_UL:v=0,T=1,b=o.width,y=0,x=1,E=o.height;break;case t._ORIGIN_BL:v=0,T=1,b=o.width,y=o.height-1,x=-1,E=-1;break;case t._ORIGIN_UR:v=o.width-1,T=-1,b=-1,y=0,x=1,E=o.height;break;case t._ORIGIN_BR:v=o.width-1,T=-1,b=-1,
- y=o.height-1,x=-1,E=-1}var A="_getImageData"+(u?"Grey":"")+o.pixel_size+"bits",M=t[A](o,l,h,y,x,E,v,T,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 h,l,c,f=r,d=t,p=e.width,_=e.height,m=0,g=new Uint8Array(p*_*4);for(c=i;c!==o;c+=n)for(l=s;l!==u;l+=a,m++)h=f[m],g[4*(l+p*c)+3]=255,g[4*(l+p*c)+2]=d[3*h+0],g[4*(l+p*c)+1]=d[3*h+1],g[4*(l+p*c)+0]=d[3*h+2];return g},t._getImageData16bits=function(e,t,r,i,n,o,s,a,u){var h,l,c,f=r,d=e.width,p=e.height,_=0,m=new Uint8Array(d*p*4);for(c=i;c!==o;c+=n)for(l=s;l!==u;l+=a,_+=2)h=f[_+0]+(f[_+1]<<8),m[4*(l+d*c)+0]=(31744&h)>>7,m[4*(l+d*c)+1]=(992&h)>>2,m[4*(l+d*c)+2]=(31&h)>>3,m[4*(l+d*c)+3]=32768&h?0:255;return m},t._getImageData24bits=function(e,t,r,i,n,o,s,a,u){var h,l,c=r,f=e.width,d=e.height,p=0,_=new Uint8Array(f*d*4);for(l=i;l!==o;l+=n)for(h=s;h!==u;h+=a,p+=3)_[4*(h+f*l)+3]=255,_[4*(h+f*l)+2]=c[p+0],_[4*(h+f*l)+1]=c[p+1],_[4*(h+f*l)+0]=c[p+2];return _},t._getImageData32bits=function(e,t,r,i,n,o,s,a,u){var h,l,c=r,f=e.width,d=e.height,p=0,_=new Uint8Array(f*d*4);for(l=i;l!==o;l+=n)for(h=s;h!==u;h+=a,p+=4)_[4*(h+f*l)+2]=c[p+0],_[4*(h+f*l)+1]=c[p+1],_[4*(h+f*l)+0]=c[p+2],_[4*(h+f*l)+3]=c[p+3];return _},t._getImageDataGrey8bits=function(e,t,r,i,n,o,s,a,u){var h,l,c,f=r,d=e.width,p=e.height,_=0,m=new Uint8Array(d*p*4);for(c=i;c!==o;c+=n)for(l=s;l!==u;l+=a,_++)h=f[_],m[4*(l+d*c)+0]=h,m[4*(l+d*c)+1]=h,m[4*(l+d*c)+2]=h,m[4*(l+d*c)+3]=255;return m},t._getImageDataGrey16bits=function(e,t,r,i,n,o,s,a,u){var h,l,c=r,f=e.width,d=e.height,p=0,_=new Uint8Array(f*d*4);for(l=i;l!==o;l+=n)for(h=s;h!==u;h+=a,p+=2)_[4*(h+f*l)+0]=c[p+0],_[4*(h+f*l)+1]=c[p+0],_[4*(h+f*l)+2]=c[p+0],_[4*(h+f*l)+3]=c[p+1];return _},t})();r._TYPE_NO_DATA=0,r._TYPE_INDEXED=1,r._TYPE_RGB=2,r._TYPE_GREY=3,r._TYPE_RLE_INDEXED=9,r._TYPE_RLE_RGB=10,r._TYPE_RLE_GREY=11,r._ORIGIN_MASK=48,r._ORIGIN_SHIFT=4,r._ORIGIN_BL=0,r._ORIGIN_BR=1,r._ORIGIN_UL=2,r._ORIGIN_UR=3,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=(function(){function t(){}return t.GetDDSInfo=function(e){var t=new Int32Array(e,0,31),r=1;return 131072&t[2]&&(r=Math.max(1,t[7])),{width:t[4],height:t[3],mipmapCount:r,isFourCC:4==(4&t[20]),isRGB:64==(64&t[20]),isLuminance:131072==(131072&t[20]),isCube:512==(512&t[28])}},t.GetRGBAArrayBuffer=function(e,t,r,i,n){for(var o=new Uint8Array(i),s=new Uint8Array(n),a=0,u=t-1;u>=0;u--)for(var h=0;h<e;h++){var l=r+4*(h+u*e);o[a+2]=s[l],o[a+1]=s[l+1],o[a]=s[l+2],o[a+3]=s[l+3],a+=4}return o},t.GetRGBArrayBuffer=function(e,t,r,i,n){for(var o=new Uint8Array(i),s=new Uint8Array(n),a=0,u=t-1;u>=0;u--)for(var h=0;h<e;h++){var l=r+3*(h+u*e);o[a+2]=s[l],o[a+1]=s[l+1],o[a]=s[l+2],a+=3}return o},t.GetLuminanceArrayBuffer=function(e,t,r,i,n){for(var o=new Uint8Array(i),s=new Uint8Array(n),a=0,u=t-1;u>=0;u--)for(var h=0;h<e;h++){var l=r+(h+u*e);o[a]=s[l],a++}return o},t.UploadDDSLevels=function(r,a,u,h,l,c){var f,d,p,_,m,g,v,y,T,x,E=new Int32Array(u,0,31);if(542327876!=E[0])return void e.Tools.Error("Invalid magic number in DDS header");if(!h.isFourCC&&!h.isRGB&&!h.isLuminance)return void e.Tools.Error("Unsupported format, must contain a FourCC, RGB or LUMINANCE code");if(h.isFourCC)switch(f=E[21]){case n:d=8,p=a.COMPRESSED_RGBA_S3TC_DXT1_EXT;break;case o:d=16,p=a.COMPRESSED_RGBA_S3TC_DXT3_EXT;break;case s:d=16,p=a.COMPRESSED_RGBA_S3TC_DXT5_EXT;break;default:return void console.error("Unsupported FourCC code:",i(f))}T=1,131072&E[2]&&!1!==l&&(T=Math.max(1,E[7]));for(var b=E[22],A=0;A<c;A++){var M=1===c?r.TEXTURE_2D:r.TEXTURE_CUBE_MAP_POSITIVE_X+A;for(_=E[4],m=E[3],v=E[1]+4,x=0;x<T;++x){if(h.isRGB)24===b?(g=_*m*3,y=t.GetRGBArrayBuffer(_,m,v,g,u),r.texImage2D(M,x,r.RGB,_,m,0,r.RGB,r.UNSIGNED_BYTE,y)):(g=_*m*4,y=t.GetRGBAArrayBuffer(_,m,v,g,u),r.texImage2D(M,x,r.RGBA,_,m,0,r.RGBA,r.UNSIGNED_BYTE,y));else if(h.isLuminance){var P=r.getParameter(r.UNPACK_ALIGNMENT),R=_,S=Math.floor((_+P-1)/P)*P;g=S*(m-1)+R,y=t.GetLuminanceArrayBuffer(_,m,v,g,u),r.texImage2D(M,x,r.LUMINANCE,_,m,0,r.LUMINANCE,r.UNSIGNED_BYTE,y)}else g=Math.max(4,_)/4*Math.max(4,m)/4*d,y=new Uint8Array(u,v,g),r.compressedTexImage2D(M,x,p,_,m,0,y);v+=g,_*=.5,m*=.5,_=Math.max(1,_),m=Math.max(1,m)}}},t})();t.DDSTools=a})(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],h=0;h<this.numberOfFaces;h++){var l=1===this.numberOfFaces?e.TEXTURE_2D:e.TEXTURE_CUBE_MAP_POSITIVE_X+h,c=new Uint8Array(this.arrayBuffer,i+4,u);e.compressedTexImage2D(l,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})();r.HEADER_LEN=64,r.COMPRESSED_2D=0,r.COMPRESSED_3D=1,r.TEX_2D=2,r.TEX_3D=3,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,h,l,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=h||!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(l)}return Object.defineProperty(t.prototype,"onActivate",{set:function(e){this._onActivateObserver&&this.onActivateObservable.remove(this._onActivateObserver),this._onActivateObserver=this.onActivateObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onSizeChanged",{set:function(e){this._onSizeChangedObserver&&this.onSizeChangedObservable.remove(this._onSizeChangedObserver),this._onSizeChangedObserver=this.onSizeChangedObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onApply",{set:function(e){this._onApplyObserver&&this.onApplyObservable.remove(this._onApplyObserver),this._onApplyObserver=this.onApplyObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onBeforeRender",{set:function(e){this._onBeforeRenderObserver&&this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),this._onBeforeRenderObserver=this.onBeforeRenderObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onAfterRender",{set:function(e){this._onAfterRenderObserver&&this.onAfterRenderObservable.remove(this._onAfterRenderObserver),this._onAfterRenderObserver=this.onAfterRenderObservable.add(e)},enumerable:!0,configurable:!0}),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=t.getEngine().getCaps().maxTextureSize,a=(r?r._width:this._engine.getRenderingCanvas().width)*this._options|0,u=(r?r._height:this._engine.getRenderingCanvas().height)*this._options|0,h=this._options.width||a,l=this._options.height||u;if((this.renderTargetSamplingMode===e.Texture.TRILINEAR_SAMPLINGMODE||this.alwaysForcePOT)&&(this._options.width||(h=e.Tools.GetExponentOfTwo(h,s,this.scaleMode)),this._options.height||(l=e.Tools.GetExponentOfTwo(l,s,this.scaleMode))),this.width!==h||this.height!==l){if(this._textures.length>0){for(var c=0;c<this._textures.length;c++)this._engine._releaseTexture(this._textures.data[c]);this._textures.reset()}this.width=h,this.height=l;var f={width:this.width,height:this.height},d={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(f,d)),this._reusable&&this._textures.push(this._engine.createRenderTargetTexture(f,d)),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 p;this._shareOutputWithPostProcess?p=this._shareOutputWithPostProcess.outputTexture:this._forcedOutputTexture?(p=this._forcedOutputTexture,this.width=this._forcedOutputTexture._width,this.height=this._forcedOutputTexture._height):p=this.outputTexture,this.enablePixelPerfectMode?(this._scaleRatio.copyFromFloats(a/h,u/l),this._engine.bindFramebuffer(p,0,a,u)):(this._scaleRatio.copyFromFloats(1,1),this._engine.bindFramebuffer(p)),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.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){this._light.needCube()&&(e===t.FILTER_BLUREXPONENTIALSHADOWMAP?this.useExponentialShadowMap=!0:e===t.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP&&(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 h=u.getAlphaTestTexture();h&&(this._effect.setTexture("diffuseSampler",h),this._effect.setMatrix("diffuseMatrix",h.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.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.updateFloat3("shadowsInfo",this.getDarkness(),this.blurScale/this.getShadowMap().getSize().width,this.depthScale,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})();t._FILTER_NONE=0,t._FILTER_EXPONENTIALSHADOWMAP=1,t._FILTER_POISSONSAMPLING=2,t._FILTER_BLUREXPONENTIALSHADOWMAP=3,t._FILTER_CLOSEEXPONENTIALSHADOWMAP=4,t._FILTER_BLURCLOSEEXPONENTIALSHADOWMAP=5,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},r})(e.Light);__decorate([e.serializeAsVector3()],t.prototype,"position",void 0),__decorate([e.serializeAsVector3()],t.prototype,"direction",null),__decorate([e.serialize()],t.prototype,"shadowMinZ",null),__decorate([e.serialize()],t.prototype,"shadowMaxZ",null),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)},r})(e.ShadowLight);__decorate([e.serialize()],t.prototype,"shadowAngle",null),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 h=u.boundingBox,l=0;l<h.vectorsWorld.length;l++)e.Vector3.TransformCoordinatesToRef(h.vectorsWorld[l],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},r})(e.ShadowLight);__decorate([e.serialize()],t.prototype,"shadowFrustumSize",null),__decorate([e.serialize()],t.prototype,"shadowOrthoScale",null),__decorate([e.serialize()],t.prototype,"autoUpdateExtends",void 0),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},r})(e.ShadowLight);__decorate([e.serialize()],t.prototype,"angle",null),__decorate([e.serialize()],t.prototype,"shadowAngleScale",null),__decorate([e.serialize()],t.prototype,"exponent",void 0),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 i.subMaterials=new Array,r.multiMaterials.push(i),i}return __extends(r,t),r.prototype.getSubMaterial=function(e){return e<0||e>=this.subMaterials.length?this.getScene().defaultMaterial:this.subMaterials[e]},r.prototype.getClassName=function(){return"MultiMaterial"},r.prototype.isReady=function(e){for(var t=0;t<this.subMaterials.length;t++){if(this.subMaterials[t]&&!this.subMaterials[t].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})(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.ALBEDO=!1,t.AMBIENT=!1,t.AMBIENTINGRAYSCALE=!1,t.OPACITY=!1,t.OPACITYRGB=!1,t.REFLECTION=!1,t.EMISSIVE=!1,t.REFLECTIVITY=!1,t.BUMP=!1,t.PARALLAX=!1,t.PARALLAXOCCLUSION=!1,t.SPECULAROVERALPHA=!1,t.CLIPPLANE=!1,t.ALPHATEST=!1,t.ALPHAFROMALBEDO=!1,t.POINTSIZE=!1,t.FOG=!1,t.SPECULARTERM=!1,t.OPACITYFRESNEL=!1,t.EMISSIVEFRESNEL=!1,t.FRESNEL=!1,t.NORMAL=!1,t.TANGENT=!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.MICROSURFACEFROMREFLECTIVITYMAP=!1,t.MICROSURFACEAUTOMATIC=!1,t.EMISSIVEASILLUMINATION=!1,t.LIGHTMAP=!1,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.CAMERATONEMAP=!1,t.CAMERACONTRAST=!1,t.CAMERACOLORGRADING=!1,t.CAMERACOLORCURVES=!1,t.USESPHERICALFROMREFLECTIONMAP=!1,t.REFRACTION=!1,t.REFRACTIONMAP_3D=!1,t.LINKREFRACTIONTOTRANSPARENCY=!1,t.REFRACTIONMAPINLINEARSPACE=!1,t.LODBASEDMICROSFURACE=!1,t.USEPHYSICALLIGHTFALLOFF=!1,t.RADIANCEOVERALPHA=!1,t.USEPMREMREFLECTION=!1,t.USEPMREMREFRACTION=!1,t.INVERTNORMALMAPX=!1,t.INVERTNORMALMAPY=!1,t.TWOSIDEDLIGHTING=!1,t.SHADOWFLOAT=!1,t.NORMALXYSCALE=!0,t.USERIGHTHANDEDSYSTEM=!1,t.METALLICWORKFLOW=!1,t.METALLICMAP=!1,t.ROUGHNESSSTOREINMETALMAPALPHA=!1,t.ROUGHNESSSTOREINMETALMAPGREEN=!1,t.METALLNESSSTOREINMETALMAPBLUE=!1,t.AOSTOREINMETALMAPRED=!1,t.MICROSURFACEMAP=!1,t.MORPHTARGETS=!1,t.MORPHTARGETS_NORMAL=!1,t.MORPHTARGETS_TANGENT=!1,t.NUM_MORPH_INFLUENCERS=0,t.ALPHATESTVALUE=.4,t.LDROUTPUT=!0,t.rebuild(),t}return __extends(t,e),t.prototype.reset=function(){e.prototype.reset.call(this),this.ALPHATESTVALUE=.4,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._cameraExposure=1,n._cameraContrast=1,n._cameraColorGradingTexture=null,n._cameraColorCurves=null,n._cameraInfos=new e.Vector4(1,1,0,0),n._microsurfaceTextureLods=new e.Vector2(0,0),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(0,0,0),n._emissiveColor=new e.Color3(0,0,0),n._microSurface=.9,n._indexOfRefraction=.66,n._invertRefractionY=!1,n._linkRefractionWithTransparency=!1,n._useLightmapAsShadowmap=!1,n._useEmissiveAsIllumination=!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._useScalarInLinearSpace=!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._ldrOutput=!0,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.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}return __extends(i,r),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()||this._opacityFresnelParameters&&this._opacityFresnelParameters.isEnabled)},i.prototype.needAlphaTesting=function(){return!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.convertColorToLinearSpaceToRef=function(t,r){e.PBRMaterial.convertColorToLinearSpaceToRef(t,r,this._useScalarInLinearSpace)},i.convertColorToLinearSpaceToRef=function(e,t,r){r?(t.r=e.r,t.g=e.g,t.b=e.b):e.toLinearSpaceToRef(t)},i.BindLights=function(t,r,i,n,o,s,a){for(var u=0,h=0,l=r._lightSources;h<l.length;h++){var c=l[h],f=c._uniformBuffer.useUbo,d=c.getScaledIntensity();if(c._uniformBuffer.bindToEffect(i,"Light"+u),e.MaterialHelper.BindLightProperties(c,i,u),this.convertColorToLinearSpaceToRef(c.diffuse,e.PBRMaterial._scaledAlbedo,o),e.PBRMaterial._scaledAlbedo.scaleToRef(d,e.PBRMaterial._scaledAlbedo),c._uniformBuffer.updateColor4(f?"vLightDiffuse":"vLightDiffuse"+u,e.PBRMaterial._scaledAlbedo,a?c.radius:c.range),n.SPECULARTERM&&(this.convertColorToLinearSpaceToRef(c.specular,e.PBRMaterial._scaledReflectivity,o),e.PBRMaterial._scaledReflectivity.scaleToRef(d,e.PBRMaterial._scaledReflectivity),c._uniformBuffer.updateColor3(f?"vLightSpecular":"vLightSpecular"+u,e.PBRMaterial._scaledReflectivity)),t.shadowsEnabled&&e.MaterialHelper.BindLightShadow(c,t,r,u+"",i),c._uniformBuffer.update(),++u===s)break}},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&&(s._needUVs=!1,o.texturesEnabled)){if(o.getEngine().getCaps().textureLOD&&(s.LODBASEDMICROSFURACE=!0),s.LDROUTPUT=this._ldrOutput,this._albedoTexture&&e.StandardMaterial.DiffuseTextureEnabled){if(!this._albedoTexture.isReadyOrNotBlocking())return!1;s._needUVs=!0,s.ALBEDO=!0}if(this._ambientTexture&&e.StandardMaterial.AmbientTextureEnabled){if(!this._ambientTexture.isReadyOrNotBlocking())return!1;s._needUVs=!0,s.AMBIENT=!0,s.AMBIENTINGRAYSCALE=this._useAmbientInGrayScale}if(this._opacityTexture&&e.StandardMaterial.OpacityTextureEnabled){if(!this._opacityTexture.isReadyOrNotBlocking())return!1;s._needUVs=!0,s.OPACITY=!0,this._opacityTexture.getAlphaFromRGB&&(s.OPACITYRGB=!0)}var u=this._reflectionTexture||o.environmentTexture;if(u&&e.StandardMaterial.ReflectionTextureEnabled){if(!u.isReadyOrNotBlocking())return!1;switch(s.REFLECTION=!0,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 instanceof e.HDRCubeTexture&&u&&(s.USESPHERICALFROMREFLECTIONMAP=!0,u.isPMREM&&(s.USEPMREMREFLECTION=!0))}if(this._lightmapTexture&&e.StandardMaterial.LightmapTextureEnabled){if(!this._lightmapTexture.isReadyOrNotBlocking())return!1;s._needUVs=!0,s.LIGHTMAP=!0,s.USELIGHTMAPASSHADOWMAP=this._useLightmapAsShadowmap}if(this._emissiveTexture&&e.StandardMaterial.EmissiveTextureEnabled){if(!this._emissiveTexture.isReadyOrNotBlocking())return!1;s._needUVs=!0,s.EMISSIVE=!0}if(e.StandardMaterial.SpecularTextureEnabled){if(this._metallicTexture){if(!this._metallicTexture.isReadyOrNotBlocking())return!1;s._needUVs=!0,s.METALLICWORKFLOW=!0,s.METALLICMAP=!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;s._needUVs=!0,s.REFLECTIVITY=!0,s.MICROSURFACEFROMREFLECTIVITYMAP=this._useMicroSurfaceFromReflectivityMapAlpha,s.MICROSURFACEAUTOMATIC=this._useAutoMicroSurfaceFromReflectivityMap}if(this._microSurfaceTexture){if(!this._microSurfaceTexture.isReadyOrNotBlocking())return!1;s._needUVs=!0,s.MICROSURFACEMAP=!0}}if(o.getEngine().getCaps().standardDerivatives&&this._bumpTexture&&e.StandardMaterial.BumpTextureEnabled&&!this._disableBumpMap){if(!this._bumpTexture.isReady())return!1;s._needUVs=!0,s.BUMP=!0,this._useParallax&&this._albedoTexture&&e.StandardMaterial.DiffuseTextureEnabled&&(s.PARALLAX=!0,this._useParallaxOcclusion&&(s.PARALLAXOCCLUSION=!0)),this._invertNormalMapX&&(s.INVERTNORMALMAPX=!0),this._invertNormalMapY&&(s.INVERTNORMALMAPY=!0),o._mirroredCameraPosition&&(s.INVERTNORMALMAPX=!s.INVERTNORMALMAPX,s.INVERTNORMALMAPY=!s.INVERTNORMALMAPY),s.USERIGHTHANDEDSYSTEM=o.useRightHandedSystem}if(this._refractionTexture&&e.StandardMaterial.RefractionTextureEnabled){if(!this._refractionTexture.isReadyOrNotBlocking())return!1;s._needUVs=!0,s.REFRACTION=!0,s.REFRACTIONMAP_3D=this._refractionTexture.isCube,this._linkRefractionWithTransparency&&(s.LINKREFRACTIONTOTRANSPARENCY=!0),this._refractionTexture instanceof e.HDRCubeTexture&&(s.REFRACTIONMAPINLINEARSPACE=!0,this._refractionTexture.isPMREM&&(s.USEPMREMREFRACTION=!0))}if(this._cameraColorGradingTexture&&e.StandardMaterial.ColorGradingTextureEnabled){if(!this._cameraColorGradingTexture.isReady())return!1;s.CAMERACOLORGRADING=!0}!this.backFaceCulling&&this._twoSidedLighting&&(s.TWOSIDEDLIGHTING=!0),this._shouldUseAlphaFromAlbedoTexture()&&(s.ALPHAFROMALBEDO=!0),this._useEmissiveAsIllumination&&(s.EMISSIVEASILLUMINATION=!0),1!=this._cameraContrast&&(s.CAMERACONTRAST=!0),1!=this._cameraExposure&&(s.CAMERATONEMAP=!0),this._cameraColorCurves&&(s.CAMERACOLORCURVES=!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),s.ALPHATESTVALUE=this._alphaCutOff}if(s._areFresnelDirty&&e.StandardMaterial.FresnelEnabled&&(this._opacityFresnelParameters&&this._opacityFresnelParameters.isEnabled||this._emissiveFresnelParameters&&this._emissiveFresnelParameters.isEnabled)&&(this._opacityFresnelParameters&&this._opacityFresnelParameters.isEnabled&&(s.OPACITYFRESNEL=!0),this._emissiveFresnelParameters&&this._emissiveFresnelParameters.isEnabled&&(s.EMISSIVEFRESNEL=!0),s.FRESNEL=!0),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.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.OPACITYFRESNEL&&h.addFallback(1,"OPACITYFRESNEL"),s.EMISSIVEFRESNEL&&h.addFallback(2,"EMISSIVEFRESNEL"),s.FRESNEL&&h.addFallback(3,"FRESNEL"),s.NUM_BONE_INFLUENCERS>0&&h.addCPUSkinningFallback(0,r);var l=[e.VertexBuffer.PositionKind];s.NORMAL&&l.push(e.VertexBuffer.NormalKind),s.TANGENT&&l.push(e.VertexBuffer.TangentKind),s.UV1&&l.push(e.VertexBuffer.UVKind),s.UV2&&l.push(e.VertexBuffer.UV2Kind),s.VERTEXCOLOR&&l.push(e.VertexBuffer.ColorKind),e.MaterialHelper.PrepareAttributesForBones(l,r,s,h),e.MaterialHelper.PrepareAttributesForInstances(l,s),e.MaterialHelper.PrepareAttributesForMorphTargets(l,r,s);var c=["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","opacityParts","emissiveLeftColor","emissiveRightColor","vLightingIntensity","logarithmicDepthConstant","vSphericalX","vSphericalY","vSphericalZ","vSphericalXX","vSphericalYY","vSphericalZZ","vSphericalXY","vSphericalYZ","vSphericalZX","vMicrosurfaceTextureLods","vCameraInfos"],f=["albedoSampler","ambientSampler","opacitySampler","reflectionCubeSampler","reflection2DSampler","emissiveSampler","reflectivitySampler","microSurfaceSampler","bumpSampler","lightmapSampler","refractionCubeSampler","refraction2DSampler"],d=["Material","Scene"];s.CAMERACOLORCURVES&&e.ColorCurves.PrepareUniforms(c),s.CAMERACOLORGRADING&&e.ColorGradingTexture.PrepareUniformsAndSamplers(c,f),e.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:c,uniformBuffersNames:d,samplers:f,defines:s,maxSimultaneousLights:this._maxSimultaneousLights});var p=function(e){this.onCompiled&&this.onCompiled(e),this.bindSceneUniformBuffer(e,o.getSceneUniformBuffer())}.bind(this),_=s.toString();i.setEffect(o.getEngine().createEffect("pbr",{attributes:l,uniformsNames:c,uniformBuffersNames:d,samplers:f,defines:_,fallbacks:h,onCompiled:p,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("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("vMicrosurfaceTextureLods",2),this._uniformBuffer.addUniform("vReflectivityColor",4),this._uniformBuffer.addUniform("vEmissiveColor",3),this._uniformBuffer.addUniform("opacityParts",4),this._uniformBuffer.addUniform("emissiveLeftColor",4),this._uniformBuffer.addUniform("emissiveRightColor",4),this._uniformBuffer.addUniform("pointSize",1),this._uniformBuffer.create()},i.prototype.unbind=function(){this._reflectionTexture&&this._reflectionTexture.isRenderTarget&&this._uniformBuffer.setTexture("reflection2DSampler",null),this._refractionTexture&&this._refractionTexture.isRenderTarget&&this._uniformBuffer.setTexture("refraction2DSampler",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;if(this._activeEffect=s,this.bindOnlyWorldMatrix(t),e.MaterialHelper.BindBonesParameters(r,this._activeEffect),this._mustRebind(n,s,r.visibility)){if(this._uniformBuffer.bindToEffect(s,"Material"),this.bindViewProjection(s),!this._uniformBuffer.useUbo||!this.isFrozen||!this._uniformBuffer.isSync){if(e.StandardMaterial.FresnelEnabled&&(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._emissiveFresnelParameters&&this._emissiveFresnelParameters.isEnabled&&(this._uniformBuffer.updateColor4("emissiveLeftColor",this._emissiveFresnelParameters.leftColor,this._emissiveFresnelParameters.power),this._uniformBuffer.updateColor4("emissiveRightColor",this._emissiveFresnelParameters.rightColor,this._emissiveFresnelParameters.bias))),n.texturesEnabled){this._albedoTexture&&e.StandardMaterial.DiffuseTextureEnabled&&(this._uniformBuffer.updateFloat2("vAlbedoInfos",this._albedoTexture.coordinatesIndex,this._albedoTexture.level),this._uniformBuffer.updateMatrix("albedoMatrix",this._albedoTexture.getTextureMatrix())),this._ambientTexture&&e.StandardMaterial.AmbientTextureEnabled&&(this._uniformBuffer.updateFloat3("vAmbientInfos",this._ambientTexture.coordinatesIndex,this._ambientTexture.level,this._ambientTextureStrength),this._uniformBuffer.updateMatrix("ambientMatrix",this._ambientTexture.getTextureMatrix())),this._opacityTexture&&e.StandardMaterial.OpacityTextureEnabled&&(this._uniformBuffer.updateFloat2("vOpacityInfos",this._opacityTexture.coordinatesIndex,this._opacityTexture.level),this._uniformBuffer.updateMatrix("opacityMatrix",this._opacityTexture.getTextureMatrix()));var a=this._reflectionTexture||n.environmentTexture;if(a&&e.StandardMaterial.ReflectionTextureEnabled&&(this._microsurfaceTextureLods.x=Math.round(Math.log(a.getSize().width)*Math.LOG2E),
- this._uniformBuffer.updateMatrix("reflectionMatrix",a.getReflectionTextureMatrix()),this._uniformBuffer.updateFloat2("vReflectionInfos",a.level,0),o.USESPHERICALFROMREFLECTIONMAP&&(this._activeEffect.setFloat3("vSphericalX",a.sphericalPolynomial.x.x,a.sphericalPolynomial.x.y,a.sphericalPolynomial.x.z),this._activeEffect.setFloat3("vSphericalY",a.sphericalPolynomial.y.x,a.sphericalPolynomial.y.y,a.sphericalPolynomial.y.z),this._activeEffect.setFloat3("vSphericalZ",a.sphericalPolynomial.z.x,a.sphericalPolynomial.z.y,a.sphericalPolynomial.z.z),this._activeEffect.setFloat3("vSphericalXX",a.sphericalPolynomial.xx.x,a.sphericalPolynomial.xx.y,a.sphericalPolynomial.xx.z),this._activeEffect.setFloat3("vSphericalYY",a.sphericalPolynomial.yy.x,a.sphericalPolynomial.yy.y,a.sphericalPolynomial.yy.z),this._activeEffect.setFloat3("vSphericalZZ",a.sphericalPolynomial.zz.x,a.sphericalPolynomial.zz.y,a.sphericalPolynomial.zz.z),this._activeEffect.setFloat3("vSphericalXY",a.sphericalPolynomial.xy.x,a.sphericalPolynomial.xy.y,a.sphericalPolynomial.xy.z),this._activeEffect.setFloat3("vSphericalYZ",a.sphericalPolynomial.yz.x,a.sphericalPolynomial.yz.y,a.sphericalPolynomial.yz.z),this._activeEffect.setFloat3("vSphericalZX",a.sphericalPolynomial.zx.x,a.sphericalPolynomial.zx.y,a.sphericalPolynomial.zx.z))),this._emissiveTexture&&e.StandardMaterial.EmissiveTextureEnabled&&(this._uniformBuffer.updateFloat2("vEmissiveInfos",this._emissiveTexture.coordinatesIndex,this._emissiveTexture.level),this._uniformBuffer.updateMatrix("emissiveMatrix",this._emissiveTexture.getTextureMatrix())),this._lightmapTexture&&e.StandardMaterial.LightmapTextureEnabled&&(this._uniformBuffer.updateFloat2("vLightmapInfos",this._lightmapTexture.coordinatesIndex,this._lightmapTexture.level),this._uniformBuffer.updateMatrix("lightmapMatrix",this._lightmapTexture.getTextureMatrix())),e.StandardMaterial.SpecularTextureEnabled&&(this._metallicTexture?(this._uniformBuffer.updateFloat3("vReflectivityInfos",this._metallicTexture.coordinatesIndex,this._metallicTexture.level,this._ambientTextureStrength),this._uniformBuffer.updateMatrix("reflectivityMatrix",this._metallicTexture.getTextureMatrix())):this._reflectivityTexture&&(this._uniformBuffer.updateFloat3("vReflectivityInfos",this._reflectivityTexture.coordinatesIndex,this._reflectivityTexture.level,1),this._uniformBuffer.updateMatrix("reflectivityMatrix",this._reflectivityTexture.getTextureMatrix())),this._microSurfaceTexture&&(this._uniformBuffer.updateFloat2("vMicroSurfaceSamplerInfos",this._microSurfaceTexture.coordinatesIndex,this._microSurfaceTexture.level),this._uniformBuffer.updateMatrix("microSurfaceSamplerMatrix",this._microSurfaceTexture.getTextureMatrix()))),this._bumpTexture&&n.getEngine().getCaps().standardDerivatives&&e.StandardMaterial.BumpTextureEnabled&&!this._disableBumpMap&&(this._uniformBuffer.updateFloat3("vBumpInfos",this._bumpTexture.coordinatesIndex,this._bumpTexture.level,this._parallaxScaleBias),this._uniformBuffer.updateMatrix("bumpMatrix",this._bumpTexture.getTextureMatrix())),this._refractionTexture&&e.StandardMaterial.RefractionTextureEnabled){this._microsurfaceTextureLods.y=Math.round(Math.log(this._refractionTexture.getSize().width)*Math.LOG2E);var u=1;this._refractionTexture.isCube||(this._uniformBuffer.updateMatrix("refractionMatrix",this._refractionTexture.getReflectionTextureMatrix()),this._refractionTexture.depth&&(u=this._refractionTexture.depth)),this._uniformBuffer.updateFloat4("vRefractionInfos",this._refractionTexture.level,this._indexOfRefraction,u,this._invertRefractionY?-1:1)}(a||this._refractionTexture)&&this._uniformBuffer.updateFloat2("vMicrosurfaceTextureLods",this._microsurfaceTextureLods.x,this._microsurfaceTextureLods.y)}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.convertColorToLinearSpaceToRef(this._reflectivityColor,e.PBRMaterial._scaledReflectivity),this._uniformBuffer.updateColor4("vReflectivityColor",e.PBRMaterial._scaledReflectivity,this._microSurface)),this.convertColorToLinearSpaceToRef(this._emissiveColor,e.PBRMaterial._scaledEmissive),this._uniformBuffer.updateColor3("vEmissiveColor",e.PBRMaterial._scaledEmissive),this.convertColorToLinearSpaceToRef(this._reflectionColor,e.PBRMaterial._scaledReflection),this._uniformBuffer.updateColor3("vReflectionColor",e.PBRMaterial._scaledReflection),this.convertColorToLinearSpaceToRef(this._albedoColor,e.PBRMaterial._scaledAlbedo),this._uniformBuffer.updateColor4("vAlbedoColor",e.PBRMaterial._scaledAlbedo,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),a&&e.StandardMaterial.ReflectionTextureEnabled&&(a.isCube?this._uniformBuffer.setTexture("reflectionCubeSampler",a):this._uniformBuffer.setTexture("reflection2DSampler",a)),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),this._refractionTexture&&e.StandardMaterial.RefractionTextureEnabled&&(this._refractionTexture.isCube?this._uniformBuffer.setTexture("refractionCubeSampler",this._refractionTexture):this._uniformBuffer.setTexture("refraction2DSampler",this._refractionTexture)),this._cameraColorGradingTexture&&e.StandardMaterial.ColorGradingTextureEnabled&&e.ColorGradingTexture.Bind(this._cameraColorGradingTexture,this._activeEffect)),e.MaterialHelper.BindClipPlane(this._activeEffect,n),n.ambientColor.multiplyToRef(this._ambientColor,this._globalAmbientColor),s.setVector3("vEyePosition",n._mirroredCameraPosition?n._mirroredCameraPosition:n.activeCamera.position),s.setColor3("vAmbientColor",this._globalAmbientColor)}!this._mustRebind(n,s)&&this.isFrozen||(n.lightsEnabled&&!this._disableLighting&&e.PBRMaterial.BindLights(n,r,this._activeEffect,o,this._useScalarInLinearSpace,this._maxSimultaneousLights,this._usePhysicalLightFalloff),(n.fogEnabled&&r.applyFog&&n.fogMode!==e.Scene.FOGMODE_NONE||a)&&this.bindView(s),e.MaterialHelper.BindFogParameters(n,r,this._activeEffect),o.NUM_MORPH_INFLUENCERS&&e.MaterialHelper.BindMorphTargetParameters(r,this._activeEffect),this._cameraInfos.x=this._cameraExposure,this._cameraInfos.y=this._cameraContrast,s.setVector4("vCameraInfos",this._cameraInfos),this._cameraColorCurves&&e.ColorCurves.Bind(this._cameraColorCurves,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),this._cameraColorGradingTexture&&this._cameraColorGradingTexture.animations&&this._cameraColorGradingTexture.animations.length>0&&e.push(this._cameraColorGradingTexture),e},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._emissiveTexture&&this._emissiveTexture.dispose(),this._metallicTexture&&this._metallicTexture.dispose(),this._reflectivityTexture&&this._reflectivityTexture.dispose(),this._bumpTexture&&this._bumpTexture.dispose(),this._lightmapTexture&&this._lightmapTexture.dispose(),this._refractionTexture&&this._refractionTexture.dispose(),this._cameraColorGradingTexture&&this._cameraColorGradingTexture.dispose()),this._renderTargets.dispose(),r.prototype.dispose.call(this,e,t)},i})(e.PushMaterial);r._scaledAlbedo=new e.Color3,r._scaledReflectivity=new e.Color3,r._scaledEmissive=new e.Color3,r._scaledReflection=new e.Color3,__decorate([e.serialize()],r.prototype,"useLogarithmicDepth",null),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._useEmissiveAsIllumination=!0,n._useAmbientInGrayScale=!0,n._useScalarInLinearSpace=!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})(e.PBRBaseMaterial);__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),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.cameraExposure=1,n.cameraContrast=1,n.cameraColorGradingTexture=null,n.cameraColorCurves=null,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(0,0,0),n.emissiveColor=new e.Color3(0,0,0),n.microSurface=.9,n.indexOfRefraction=.66,n.invertRefractionY=!1,n.linkRefractionWithTransparency=!1,n.useLightmapAsShadowmap=!1,n.useEmissiveAsIllumination=!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.useScalarInLinearSpace=!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}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}),r.prototype.getClassName=function(){return"PBRMaterial"},r.prototype.clone=function(t){var i=this;return e.SerializationHelper.Clone((function(){return new r(t,i.getScene())}),this)},r.prototype.serialize=function(){var t=e.SerializationHelper.Serialize(this);return t.customType="BABYLON.PBRMaterial",t},r.Parse=function(t,i,n){return e.SerializationHelper.Parse((function(){return new r(t.name,i)}),t,i,n)},r})(e.PBRBaseMaterial);t._PBRMATERIAL_OPAQUE=0,t._PBRMATERIAL_ALPHATEST=1,t._PBRMATERIAL_ALPHABLEND=2,t._PBRMATERIAL_ALPHATESTANDBLEND=3,__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"directIntensity",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"emissiveIntensity",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"environmentIntensity",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"specularIntensity",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"disableBumpMap",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"cameraExposure",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"cameraContrast",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"cameraColorGradingTexture",void 0),__decorate([e.serializeAsColorCurves(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"cameraColorCurves",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"albedoTexture",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"ambientTexture",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"ambientTextureStrength",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"opacityTexture",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionTexture",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"emissiveTexture",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectivityTexture",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"metallicTexture",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"metallic",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"roughness",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"microSurfaceTexture",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"bumpTexture",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty",null)],t.prototype,"lightmapTexture",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"refractionTexture",void 0),__decorate([e.serializeAsColor3("ambient"),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"ambientColor",void 0),__decorate([e.serializeAsColor3("albedo"),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"albedoColor",void 0),__decorate([e.serializeAsColor3("reflectivity"),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectivityColor",void 0),__decorate([e.serializeAsColor3("reflection"),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionColor",void 0),__decorate([e.serializeAsColor3("emissive"),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"emissiveColor",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"microSurface",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"indexOfRefraction",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"invertRefractionY",void 0),__decorate([e.serializeAsFresnelParameters(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"opacityFresnelParameters",void 0),__decorate([e.serializeAsFresnelParameters(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"emissiveFresnelParameters",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"linkRefractionWithTransparency",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useLightmapAsShadowmap",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useEmissiveAsIllumination",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAlphaFromAlbedoTexture",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useSpecularOverAlpha",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useMicroSurfaceFromReflectivityMapAlpha",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRoughnessFromMetallicTextureAlpha",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRoughnessFromMetallicTextureGreen",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useMetallnessFromMetallicTextureBlue",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAmbientOcclusionFromMetallicTextureRed",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAmbientInGrayScale",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAutoMicroSurfaceFromReflectivityMap",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useScalarInLinearSpace",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"usePhysicalLightFalloff",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRadianceOverAlpha",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useParallax",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useParallaxOcclusion",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"parallaxScaleBias",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsLightsDirty")],t.prototype,"disableLighting",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsLightsDirty")],t.prototype,"maxSimultaneousLights",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"invertNormalMapX",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"invertNormalMapY",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"twoSidedLighting",void 0),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._useRoughnessFromMetallicTextureGreen=!0,i._useMetallnessFromMetallicTextureBlue=!0,i}return __extends(r,t),r.prototype.getClassName=function(){return"PBRMetallicRoughnessMaterial"},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)},r})(e.Internals.PBRBaseSimpleMaterial);__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_albedoColor")],t.prototype,"baseColor",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_albedoTexture")],t.prototype,"baseTexture",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"metallic",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],t.prototype,"roughness",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_metallicTexture")],t.prototype,"metallicRoughnessTexture",void 0),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.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)},r})(e.Internals.PBRBaseSimpleMaterial);__decorate([e.serializeAsColor3(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_albedoColor")],t.prototype,"diffuseColor",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_albedoTexture")],t.prototype,"diffuseTexture",void 0),__decorate([e.serializeAsColor3(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_reflectivityColor")],t.prototype,"specularColor",void 0),__decorate([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_microSurface")],t.prototype,"glossiness",void 0),__decorate([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_reflectivityTexture")],t.prototype,"specularGlossinessTexture",void 0),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._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.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)):o.push("#define NUM_BONE_INFLUENCERS 0");for(var h in this._textures)if(!this._textures[h].isReady())return!1;n.getAlphaTesting()&&o.push("#define ALPHATEST");var l=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()&&(l!==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._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.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.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,h=0;h<a.length;h++)u.push(e.Texture.Parse(a[h],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.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)),h=i.instance,l=i.updatable;if(h){e.Vector3.FromFloatsToRef(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,e.Tmp.Vector3[0]),e.Vector3.FromFloatsToRef(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE,e.Tmp.Vector3[1]);var c=h.getVerticesData(e.VertexBuffer.PositionKind);if(function(t){for(var r=o[0].length,i=0,n=h.sideOrientation===e.Mesh.DOUBLESIDE?2:1,s=1;s<=n;s++)for(var a=0;a<o.length;a++){var u=o[a],l=u.length;r=r<l?r:l;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;h._closePath&&(t[i]=u[0].x,t[i+1]=u[0].y,t[i+2]=u[0].z,i+=3)}}(c),h._boundingInfo=new e.BoundingInfo(e.Tmp.Vector3[0],e.Tmp.Vector3[1]),h._boundingInfo.update(h._worldMatrix),h.updateVerticesData(e.VertexBuffer.PositionKind,c,!1,!1),i.colors){for(var f=h.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;h.updateVerticesData(e.VertexBuffer.ColorKind,f,!1,!1)}if(i.uvs){for(var p=h.getVerticesData(e.VertexBuffer.UVKind),_=0;_<i.uvs.length;_++)p[2*_]=i.uvs[_].x,p[2*_+1]=i.uvs[_].y;h.updateVerticesData(e.VertexBuffer.UVKind,p,!1,!1)}if(!h.areNormalsFrozen||h.isFacetDataEnabled){var m=h.getIndices(),g=h.getVerticesData(e.VertexBuffer.NormalKind),v=h.isFacetDataEnabled?h.getFacetDataParameters():null;if(e.VertexData.ComputeNormals(c,m,g,v),h._closePath)for(var y=0,T=0,x=0;x<o.length;x++)y=3*h._idx[x],T=x+1<o.length?3*(h._idx[x+1]-1):g.length-3,g[y]=.5*(g[y]+g[T]),g[y+1]=.5*(g[y+1]+g[T+1]),g[y+2]=.5*(g[y+2]+g[T+2]),g[T]=g[y],g[T+1]=g[y+1],g[T+2]=g[y+2];h.areNormalsFrozen||h.updateVerticesData(e.VertexBuffer.NormalKind,g,!1,!1)}return h}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,l),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,h=0,l=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,h=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;)l=u*d,t[c]=n[f].x+l*r.x,t[c+1]=n[f].y+l*r.y,t[c+2]=n[f].z+l*r.z,t[c+3]=n[f].x+(l+h)*r.x,t[c+4]=n[f].y+(l+h)*r.y,t[c+5]=n[f].z+(l+h)*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 h=new e.LinesMesh(t,i);return e.VertexData.CreateDashedLines(r).applyToMesh(h,r.updatable),h.dashSize=a,h.gapSize=s,h},t.ExtrudeShape=function(r,i,n){var o=i.path,s=i.shape,a=i.scale||1,u=i.rotation||0,h=0===i.cap?0:i.cap||e.Mesh.NO_CAP,l=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,h,!1,n,l,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},h=i.ribbonCloseArray||!1,l=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,_=i.invertUV||!1;return t._ExtrudeShapeGeneric(r,s,o,null,null,a,u,h,l,c,!0,n,f,d,p,_,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,h=i.radius||1,l=i.tessellation||64,c=i.updatable,f=t.updateSideOrientation(i.sideOrientation,n),d=i.cap||e.Mesh.NO_CAP,p=2*Math.PI,_=new Array,m=i.invertUV||!1,g=0,v=0,y=p/l*s,T=new Array;for(g=0;g<=l;g++){var T=[];for(d!=e.Mesh.CAP_START&&d!=e.Mesh.CAP_ALL||(T.push(new e.Vector3(0,u[0].y,0)),T.push(new e.Vector3(Math.cos(g*y)*u[0].x*h,u[0].y,Math.sin(g*y)*u[0].x*h))),v=0;v<u.length;v++)o=new e.Vector3(Math.cos(g*y)*u[v].x*h,u[v].y,Math.sin(g*y)*u[v].x*h),T.push(o);d!=e.Mesh.CAP_END&&d!=e.Mesh.CAP_ALL||(T.push(new e.Vector3(Math.cos(g*y)*u[u.length-1].x*h,u[u.length-1].y,Math.sin(g*y)*u[u.length-1].x*h)),T.push(new e.Vector3(0,u[u.length-1].y,0))),_.push(T)}return t.CreateRibbon(r,{pathArray:_,closeArray:a,sideOrientation:f,updatable:c,invertUV:m,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,h=i.maxHeight||10,l=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 _=i.getImageData(0,0,n,p).data;e.VertexData.CreateGroundFromHeightMap({width:o,height:s,subdivisions:a,minHeight:u,maxHeight:h,colorFilter:l,buffer:_,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=[],h=[],l=0;l<o.length;l++)u[l]=new e.Vector2(o[l].x,o[l].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++){h=[];for(var d=0;d<s[f].length;d++)h.push(new e.Vector2(s[f][d].x,s[f][d].z));c.addHole(h)}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,h=i.cap||e.Mesh.NO_CAP,l=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,_,m=function(t,r,i,n,o,s,a,u){for(var h,l,c,f,d=r.getTangents(),p=r.getNormals(),_=r.getDistances(),m=2*Math.PI,g=m/o*u,v=function(){return n},y=s||v,T=e.Tmp.Matrix[0],x=a===e.Mesh._NO_CAP||a===e.Mesh.CAP_END?0:2,E=0;E<t.length;E++){l=y(E,_[E]),h=Array(),c=p[E];for(var b=0;b<o;b++)e.Matrix.RotationAxisToRef(d[E],g*b,T),f=h[b]?h[b]:e.Vector3.Zero(),e.Vector3.TransformCoordinatesToRef(c,T,f),f.scaleInPlace(l).addInPlace(t[E]),h[b]=f;i[x]=h,x++}var A=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]=A(o,0),i[1]=i[2].slice(0);break;case e.Mesh.CAP_END:i[x]=i[x-1].slice(0),i[x+1]=A(o,t.length-1);break;case e.Mesh.CAP_ALL:i[0]=A(o,0),i[1]=i[2].slice(0),i[x]=i[x-1].slice(0),i[x+1]=A(o,t.length-1)}return i};if(d){var g=i.arc||d.arc;return p=d.path3D.update(o),_=m(o,p,d.pathArray,s,d.tessellation,u,d.cap,g),d=t.CreateRibbon(null,{pathArray:_,instance:d}),d.path3D=p,d.pathArray=_,d.arc=g,d}p=new e.Path3D(o);var v=new Array;h=h<0||h>3?0:h,_=m(o,p,v,s,a,u,h,i.arc);var y=t.CreateRibbon(r,{pathArray:_,closePath:!0,closeArray:!1,updatable:c,sideOrientation:f,invertUV:l,frontUVs:i.frontUVs,backUVs:i.backUVs},n);return y.pathArray=_,y.path3D=p,y.tessellation=a,y.cap=h,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(),h=i.size||e.Vector3.One(),l=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,_=Math.sqrt(u.x*u.x+u.z*u.z),m=Math.atan2(u.y,_),g=e.Matrix.RotationYawPitchRoll(p,m,l).multiply(e.Matrix.Translation(a.x,a.y,a.z)),v=e.Matrix.Invert(g),y=r.getWorldMatrix(),T=y.multiply(v),x=new e.VertexData;x.indices=[],x.positions=[],x.normals=[],x.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,T),i.normal=new e.Vector3(s[3*r],s[3*r+1],s[3*r+2]),i.normal=e.Vector3.TransformNormal(i.normal,T),i},A=function(t,r){if(0===t.length)return t;for(var i=.5*Math.abs(e.Vector3.Dot(h,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,l,c,f,d,p,_=e.Vector3.Dot(t[s].position,r)-i,m=e.Vector3.Dot(t[s+1].position,r)-i,g=e.Vector3.Dot(t[s+2].position,r)-i;switch(a=_>0,u=m>0,l=g>0,(a?1:0)+(u?1:0)+(l?1:0)){case 0:o.push(t[s]),o.push(t[s+1]),o.push(t[s+2]);break;case 1:if(a&&(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}l&&(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)),l||(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=A(P,new e.Vector3(1,0,0)),P=A(P,new e.Vector3(-1,0,0)),P=A(P,new e.Vector3(0,1,0)),P=A(P,new e.Vector3(0,-1,0)),P=A(P,new e.Vector3(0,0,1)),P=A(P,new e.Vector3(0,0,-1)),0!==P.length)for(var R=0;R<P.length;R++){var S=P[R];x.indices.push(E),S.position.toArray(x.positions,3*E),S.normal.toArray(x.normals,3*E),x.uvs.push(.5+S.position.x/h.x),x.uvs.push(.5+S.position.y/h.y),E++}}var O=new e.Mesh(t,r.getScene());return x.applyToMesh(O),O.position=a.clone(),O.rotation=new e.Vector3(m,p,l),O},t._ExtrudeShapeGeneric=function(r,i,n,o,s,a,u,h,l,c,f,d,p,_,m,g,v,y){var T,x,E=function(t,r,i,n,o,s,a,u,h,l){for(var c=i.getTangents(),f=i.getNormals(),d=i.getBinormals(),p=i.getDistances(),_=0,m=function(){return o},g=function(){return s},v=l?u:g,y=l?a:m,T=h===e.Mesh.NO_CAP||h===e.Mesh.CAP_END?0:2,x=e.Tmp.Matrix[0],E=0;E<r.length;E++){for(var b=new Array,A=v(E,p[E]),M=y(E,p[E]),P=0;P<t.length;P++){e.Matrix.RotationAxisToRef(c[E],_,x);var R=c[E].scale(t[P].z).add(f[E].scale(t[P].x)).add(d[E].scale(t[P].y)),S=b[P]?b[P]:e.Vector3.Zero();e.Vector3.TransformCoordinatesToRef(R,x,S),S.scaleInPlace(M).addInPlace(r[E]),b[P]=S}n[T]=b,_+=A,T++}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(h){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[T]=n[T-1],n[T+1]=O(n[T-1]);break;case e.Mesh.CAP_ALL:n[0]=O(n[2]),n[1]=n[2],n[T]=n[T-1],n[T+1]=O(n[T-1])}return n};if(m)return T=m.path3D.update(n),x=E(i,n,m.path3D,m.pathArray,o,s,a,u,m.cap,f),m=e.Mesh.CreateRibbon(null,x,null,null,null,d,null,null,m);T=new e.Path3D(n);var b=new Array;c=c<0||c>3?0:c,x=E(i,n,T,b,o,s,a,u,c,f);var A=t.CreateRibbon(r,{pathArray:x,closeArray:h,closePath:l,updatable:p,sideOrientation:_,invertUV:g,frontUVs:v,backUVs:y},d);return A.pathArray=x,A.path3D=T,A.cap=c,A},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 h=[];h.push(0),h.push(1),h.push(2),h.push(0),h.push(2),h.push(3),this._indexBuffer=s.createIndexBuffer(h),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,h,l){void 0===a&&(a=e.Texture.BILINEAR_SAMPLINGMODE),void 0===l&&(l=e.Engine.TEXTURETYPE_UNSIGNED_INT);var c=t.call(this,r,"kernelBlur",["delta","direction"],null,o,s,a,u,h,null,l,"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=[],h=[],l=[],o=0;o<=t;o+=2){var c=Math.min(o+1,Math.floor(t));if(o===c)l.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?(l.push({o:r[o],w:i[o]}),l.push({o:r[o+1],w:i[o+1]})):(l.push({o:p,w:d}),l.push({o:-p,w:d}))}}for(var o=0;o<l.length;o++)h[o]=l[o].o,u[o]=l[o].w;r=h,i=u;for(var _=this.getEngine().getCaps().maxVaryingVectors,m=Math.max(_,0)-1,g=Math.min(r.length,m),v="",o=0;o<g;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=m;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:g,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 h=t.call(this,r,"fxaa",["texelSize"],null,i,n,o||e.Texture.BILINEAR_SAMPLINGMODE,s,a,null,u,"fxaa")||this;return h.onApplyObservable.add((function(e){var t=h.texelSize;e.setFloat2("texelSize",t.x,t.y)})),h}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(i,n,o,s,a,u,h){void 0===h&&(h=e.Engine.TEXTURETYPE_UNSIGNED_INT);var l=t.call(this,i,"imageProcessing",["contrast","vignetteSettings1","vignetteSettings2","cameraExposureLinear","vCameraColorCurveNegative","vCameraColorCurveNeutral","vCameraColorCurvePositive","colorTransformSettings"],["txColorTransform"],n,o,s,a,u,null,h,"postprocess",null,!0)||this;return l.colorGradingWeight=1,l.colorCurves=new e.ColorCurves,l._colorCurvesEnabled=!0,l.cameraFov=.5,l.vignetteStretch=0,l.vignetteCentreX=0,l.vignetteCentreY=0,l.vignetteWeight=1.5,l.vignetteColor=new e.Color4(0,0,0,0),l._vignetteBlendMode=r.VIGNETTEMODE_MULTIPLY,l._vignetteEnabled=!0,l.cameraContrast=1,l.cameraExposure=1.68,l._cameraToneMappingEnabled=!0,l._fromLinearSpace=!1,l._updateParameters(),l.onApply=function(t){var r=l.aspectRatio;if(l._colorCurvesEnabled&&e.ColorCurves.Bind(l.colorCurves,t),l._vignetteEnabled){var i=Math.tan(.5*l.cameraFov),n=i*r,o=Math.sqrt(n*i);n=e.Tools.Mix(n,o,l.vignetteStretch),i=e.Tools.Mix(i,o,l.vignetteStretch),t.setFloat4("vignetteSettings1",n,i,-n*l.vignetteCentreX,-i*l.vignetteCentreY);var s=-2*l.vignetteWeight;t.setFloat4("vignetteSettings2",l.vignetteColor.r,l.vignetteColor.g,l.vignetteColor.b,s)}if(t.setFloat("contrast",l.cameraContrast),t.setFloat("cameraExposureLinear",Math.pow(2,-l.cameraExposure)*Math.PI),l._colorGradingTexture){t.setTexture("txColorTransform",l.colorGradingTexture);var a=l.colorGradingTexture.getSize().height;t.setFloat4("colorTransformSettings",(a-1)/a,.5/a,a,l.colorGradingWeight)}},l}return __extends(r,t),Object.defineProperty(r.prototype,"colorGradingTexture",{get:function(){return this._colorGradingTexture},set:function(e){this._colorGradingTexture!==e&&(this._colorGradingTexture=e,this._updateParameters())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"vignetteBlendMode",{get:function(){return this._vignetteBlendMode},set:function(e){this._vignetteBlendMode!==e&&(this._vignetteBlendMode=e,this._updateParameters())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"colorCurvesEnabled",{get:function(){return this._colorCurvesEnabled},set:function(e){this._colorCurvesEnabled!==e&&(this._colorCurvesEnabled=e,this._updateParameters())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"vignetteEnabled",{get:function(){return this._vignetteEnabled},set:function(e){this._vignetteEnabled!==e&&(this._vignetteEnabled=e,this._updateParameters())},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}),Object.defineProperty(r.prototype,"cameraToneMappingEnabled",{get:function(){return this._cameraToneMappingEnabled},set:function(e){this._cameraToneMappingEnabled!==e&&(this._cameraToneMappingEnabled=e,this._updateParameters())},enumerable:!0,configurable:!0}),r.prototype._updateParameters=function(){var e="",t=["textureSampler"];this.colorGradingTexture&&(e="#define COLORGRADING\r\n",t.push("txColorTransform")),this._vignetteEnabled&&(e+="#define VIGNETTE\r\n",this.vignetteBlendMode===r._VIGNETTEMODE_MULTIPLY?e+="#define VIGNETTEBLENDMODEMULTIPLY\r\n":e+="#define VIGNETTEBLENDMODEOPAQUE\r\n"),this.cameraToneMappingEnabled&&(e+="#define TONEMAPPING\r\n"),this._colorCurvesEnabled&&this.colorCurves&&(e+="#define COLORCURVES\r\n"),this._fromLinearSpace&&(e+="#define FROMLINEARSPACE\r\n"),this.updateEffect(e,null,t)},Object.defineProperty(r,"VIGNETTEMODE_MULTIPLY",{get:function(){return r._VIGNETTEMODE_MULTIPLY},enumerable:!0,configurable:!0}),Object.defineProperty(r,"VIGNETTEMODE_OPAQUE",{get:function(){return r._VIGNETTEMODE_OPAQUE},enumerable:!0,configurable:!0}),r})(e.PostProcess);t._VIGNETTEMODE_MULTIPLY=0,t._VIGNETTEMODE_OPAQUE=1,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"),h=0,l=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 _=a.split(" ");if(0!==h){if(0!=h){var m=Math.max(parseInt(_[0]),0),g=Math.max(parseInt(_[1]),0),v=Math.max(parseInt(_[2]),0);d=Math.max(m,d),d=Math.max(g,d),d=Math.max(v,d);var y=4*(l+f*h+c*h*h);s[y+0]=m,s[y+1]=g,s[y+2]=v,s[y+3]=0,f++,f%h==0&&(c++,f=0,c%h==0&&(l++,c=0))}}else h=_.length,o=new Uint8Array(h*h*h*4),s=new Float32Array(h*h*h*4)}for(var p=0;p<s.length;p++){var T=s[p];o[p]=T/d*255}t.getScene().getEngine().updateTextureSize(i,h*h,h),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.Bind=function(e,t){t.setTexture("cameraColorGrading2DSampler",e);var r=e.level,i=e.getSize().height,n=i-1,o=1/i;t.setFloat4("vCameraColorGradingInfos",r,i,n,o);var s=o/i,a=o,u=n*s,h=n/i,l=.5*s,c=.5*a;t.setFloat4("vCameraColorGradingScaleOffset",u,h,l,c)},r.PrepareUniformsAndSamplers=function(e,t){e.push("vCameraColorGradingInfos","vCameraColorGradingScaleOffset"),t.push("cameraColorGrading2DSampler")},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})(e.BaseTexture);t._noneEmptyLineRegex=/\S+/,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.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),h=o-u,l=a*(1-s),c=a*(1-s*h),f=a*(1-s*(1-h));switch(u){case 0:n.r=a,n.g=f,n.b=l;break;case 1:n.r=c,n.g=a,n.b=l;break;case 2:n.r=l,n.g=a,n.b=f;break;case 3:n.r=l,n.g=c,n.b=a;break;case 4:n.r=f,n.g=l,n.b=a;break;default:n.r=a,n.g=l,n.b=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)},t})();__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),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 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 h=s[u],l=h.name;this._renderEffectsForIsolatedPass[l]=this._renderEffectsForIsolatedPass[l]||new e.PostProcessRenderEffect(this._engine,t.PASS_EFFECT_NAME,function(){return new e.DisplayPassPostProcess(t.PASS_EFFECT_NAME,1,null,null,o._engine,!0)}),this._renderEffectsForIsolatedPass[l].emptyPasses(),this._renderEffectsForIsolatedPass[l].addPass(a),this._renderEffectsForIsolatedPass[l]._attachCameras(h)}}},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})();t.PASS_EFFECT_NAME="passEffect",t.PASS_SAMPLER_NAME="passSampler",__decorate([e.serialize()],t.prototype,"_name",void 0),e.PostProcessRenderPipeline=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function r(r,i,n,o){var s=t.call(this,n.getEngine(),r)||this;s.PassPostProcessId="PassPostProcessEffect",s.HighLightsPostProcessId="HighLightsPostProcessEffect",s.BlurXPostProcessId="BlurXPostProcessEffect",s.BlurYPostProcessId="BlurYPostProcessEffect",s.CopyBackPostProcessId="CopyBackPostProcessEffect",s.ImageProcessingPostProcessId="ImageProcessingPostProcessEffect",s.FxaaPostProcessId="FxaaPostProcessEffect",s.FinalMergePostProcessId="FinalMergePostProcessEffect",s.animations=[],s._bloomEnabled=!1,s._fxaaEnabled=!1,s._imageProcessingEnabled=!0,s._bloomScale=.6,s.bloomKernel=64,s._bloomWeight=.15,s._cameras=o||[],s._scene=n;var a=s._scene.getEngine().getCaps();return s._hdr=i&&(a.textureHalfFloatRender||a.textureFloatRender),s._hdr?a.textureHalfFloatRender?s._defaultPipelineTextureType=e.Engine.TEXTURETYPE_HALF_FLOAT:a.textureFloatRender&&(s._defaultPipelineTextureType=e.Engine.TEXTURETYPE_FLOAT):s._defaultPipelineTextureType=e.Engine.TEXTURETYPE_UNSIGNED_INT,n.postProcessRenderPipelineManager.addPipeline(s),s._buildPipeline(),s}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._buildPipeline=function(){var t=this,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.pass=null),this.highlights&&(this.highlights.dispose(t),this.highlights=null),this.blurX&&(this.blurX.dispose(t),this.blurX=null),this.blurY&&(this.blurY.dispose(t),this.blurY=null),this.copyBack&&(this.copyBack.dispose(t),this.copyBack=null),this.imageProcessing&&(this.imageProcessing.dispose(t),this.imageProcessing=null),this.fxaa&&(this.fxaa.dispose(t),this.fxaa=null),this.finalMerge&&(this.finalMerge.dispose(t),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)},r})(e.PostProcessRenderPipeline);__decorate([e.serialize()],t.prototype,"bloomKernel",void 0),__decorate([e.serialize()],t.prototype,"_bloomWeight",void 0),__decorate([e.serialize()],t.prototype,"_hdr",void 0),__decorate([e.serialize()],t.prototype,"bloomWeight",null),__decorate([e.serialize()],t.prototype,"bloomScale",null),__decorate([e.serialize()],t.prototype,"bloomEnabled",null),__decorate([e.serialize()],t.prototype,"fxaaEnabled",null),__decorate([e.serialize()],t.prototype,"imageProcessingEnabled",null),e.DefaultRenderingPipeline=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],h=e.Tmp.Vector3[7],l=e.Tmp.Vector3[8],c=0,f=0,d=0,p=0,_=0,m=0,g=0,v=this._subdivisionsX,y=this._subdivisionsY,T=0;T<y;T++)for(var x=0;x<v;x++){c=3*x,f=T*(v+1)*3,d=(T+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),_=r.z-p*r.x,i.subtractToRef(r,s),n.subtractToRef(r,a),o.subtractToRef(r,u),e.Vector3.CrossToRef(u,a,h),e.Vector3.CrossToRef(s,u,l),h.normalize(),l.normalize(),m=-(h.x*r.x+h.y*r.y+h.z*r.z),g=-(l.x*i.x+l.y*i.y+l.z*i.z);var E=this._heightQuads[T*v+x];E.slope.copyFromFloats(p,_),E.facet1.copyFromFloats(h.x,h.y,h.z,m),E.facet2.copyFromFloats(l.x,l.y,l.z,g)}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 h={attributes:[e.VertexBuffer.PositionKind],uniforms:["world","viewProjection"],needAlphaBlending:!1};return a||(h.uniforms.push("color"),h.needAlphaBlending=!0),u._colorShader=new e.ShaderMaterial("colorShader",i,"color",h),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.DIFFUSE=!1,t.AMBIENT=!1,t.OPACITY=!1,t.OPACITYRGB=!1,t.REFLECTION=!1,t.EMISSIVE=!1,t.SPECULAR=!1,t.BUMP=!1,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.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.INVERTNORMALMAPX=!1,t.INVERTNORMALMAPY=!1,t.TWOSIDEDLIGHTING=!1,t.SHADOWFLOAT=!1,t.CAMERACOLORGRADING=!1,t.CAMERACOLORCURVES=!1,t.MORPHTARGETS=!1,t.MORPHTARGETS_NORMAL=!1,t.MORPHTARGETS_TANGENT=!1,t.NUM_MORPH_INFLUENCERS=0,t.USERIGHTHANDEDSYSTEM=!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._cameraColorCurves=null,o._renderTargets=new e.SmartArray(16),o._worldViewProjectionMatrix=e.Matrix.Zero(),o._globalAmbientColor=new e.Color3(0,0,0),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),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,s.texturesEnabled){if(this._diffuseTexture&&i.DiffuseTextureEnabled){if(!this._diffuseTexture.isReadyOrNotBlocking())return!1;a._needUVs=!0,a.DIFFUSE=!0}else a.DIFFUSE=!1;if(this._ambientTexture&&i.AmbientTextureEnabled){if(!this._ambientTexture.isReadyOrNotBlocking())return!1;a._needUVs=!0,a.AMBIENT=!0}else a.AMBIENT=!1;if(this._opacityTexture&&i.OpacityTextureEnabled){if(!this._opacityTexture.isReadyOrNotBlocking())return!1;a._needUVs=!0,a.OPACITY=!0,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;a._needUVs=!0,a.EMISSIVE=!0}else a.EMISSIVE=!1;if(this._lightmapTexture&&i.LightmapTextureEnabled){if(!this._lightmapTexture.isReadyOrNotBlocking())return!1;a._needUVs=!0,a.LIGHTMAP=!0,a.USELIGHTMAPASSHADOWMAP=this._useLightmapAsShadowmap}else a.LIGHTMAP=!1;if(this._specularTexture&&i.SpecularTextureEnabled){if(!this._specularTexture.isReadyOrNotBlocking())return!1;a._needUVs=!0,a.SPECULAR=!0,a.GLOSSINESS=this._useGlossinessFromSpecularMapAlpha}else a.SPECULAR=!1;if(s.getEngine().getCaps().standardDerivatives&&this._bumpTexture&&i.BumpTextureEnabled){if(!this._bumpTexture.isReady())return!1;a._needUVs=!0,a.BUMP=!0,a.INVERTNORMALMAPX=this.invertNormalMapX,a.INVERTNORMALMAPY=this.invertNormalMapY,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;if(this._cameraColorGradingTexture&&i.ColorGradingTextureEnabled){if(!this._cameraColorGradingTexture.isReady())return!1;a.CAMERACOLORGRADING=!0}else a.CAMERACOLORGRADING=!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.CAMERACOLORGRADING=!1;a.CAMERACOLORCURVES=void 0!==this._cameraColorCurves&&null!==this._cameraColorCurves,a.ALPHAFROMDIFFUSE=this._shouldUseAlphaFromDiffuseTexture(),a.EMISSIVEASILLUMINATION=this._useEmissiveAsIllumination,a.LINKEMISSIVEWITHDIFFUSE=this._linkEmissiveWithDiffuse,a.SPECULAROVERALPHA=this._useSpecularOverAlpha}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),s._mirroredCameraPosition&&a.BUMP&&(a.INVERTNORMALMAPX=!this.invertNormalMapX,a.INVERTNORMALMAPY=!this.invertNormalMapY,a.markAsUnprocessed()),a.isDirty){a.markAsProcessed(),s.resetCachedMaterial();var h=new e.EffectFallbacks;a.REFLECTION&&h.addFallback(0,"REFLECTION"),a.SPECULAR&&h.addFallback(0,"SPECULAR"),a.BUMP&&h.addFallback(0,"BUMP"),a.PARALLAX&&h.addFallback(1,"PARALLAX"),a.PARALLAXOCCLUSION&&h.addFallback(0,"PARALLAXOCCLUSION"),a.SPECULAROVERALPHA&&h.addFallback(0,"SPECULAROVERALPHA"),a.FOG&&h.addFallback(1,"FOG"),a.POINTSIZE&&h.addFallback(0,"POINTSIZE"),a.LOGARITHMICDEPTH&&h.addFallback(0,"LOGARITHMICDEPTH"),e.MaterialHelper.HandleFallbacksForShadows(a,h,this._maxSimultaneousLights),a.SPECULARTERM&&h.addFallback(0,"SPECULARTERM"),a.DIFFUSEFRESNEL&&h.addFallback(1,"DIFFUSEFRESNEL"),a.OPACITYFRESNEL&&h.addFallback(2,"OPACITYFRESNEL"),a.REFLECTIONFRESNEL&&h.addFallback(3,"REFLECTIONFRESNEL"),a.EMISSIVEFRESNEL&&h.addFallback(4,"EMISSIVEFRESNEL"),a.FRESNEL&&h.addFallback(4,"FRESNEL");var l=[e.VertexBuffer.PositionKind];a.NORMAL&&l.push(e.VertexBuffer.NormalKind),a.UV1&&l.push(e.VertexBuffer.UVKind),a.UV2&&l.push(e.VertexBuffer.UV2Kind),a.VERTEXCOLOR&&l.push(e.VertexBuffer.ColorKind),e.MaterialHelper.PrepareAttributesForBones(l,r,a,h),e.MaterialHelper.PrepareAttributesForInstances(l,a),e.MaterialHelper.PrepareAttributesForMorphTargets(l,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"],d=["diffuseSampler","ambientSampler","opacitySampler","reflectionCubeSampler","reflection2DSampler","emissiveSampler","specularSampler","bumpSampler","lightmapSampler","refractionCubeSampler","refraction2DSampler"],p=["Material","Scene"];a.CAMERACOLORCURVES&&e.ColorCurves.PrepareUniforms(f),a.CAMERACOLORGRADING&&e.ColorGradingTexture.PrepareUniformsAndSamplers(f,d),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 _=a.toString();n.setEffect(s.getEngine().createEffect(c,{attributes:l,uniformsNames:f,uniformBuffersNames:p,samplers:d,defines:_,fallbacks:h,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("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;if(this._activeEffect=a,this.bindOnlyWorldMatrix(t),e.MaterialHelper.BindBonesParameters(r,a),this._mustRebind(o,a,r.visibility)){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),this._uniformBuffer.updateMatrix("diffuseMatrix",this._diffuseTexture.getTextureMatrix())),this._ambientTexture&&i.AmbientTextureEnabled&&(this._uniformBuffer.updateFloat2("vAmbientInfos",this._ambientTexture.coordinatesIndex,this._ambientTexture.level),this._uniformBuffer.updateMatrix("ambientMatrix",this._ambientTexture.getTextureMatrix())),this._opacityTexture&&i.OpacityTextureEnabled&&(this._uniformBuffer.updateFloat2("vOpacityInfos",this._opacityTexture.coordinatesIndex,this._opacityTexture.level),this._uniformBuffer.updateMatrix("opacityMatrix",this._opacityTexture.getTextureMatrix())),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),this._uniformBuffer.updateMatrix("emissiveMatrix",this._emissiveTexture.getTextureMatrix())),this._lightmapTexture&&i.LightmapTextureEnabled&&(this._uniformBuffer.updateFloat2("vLightmapInfos",this._lightmapTexture.coordinatesIndex,this._lightmapTexture.level),this._uniformBuffer.updateMatrix("lightmapMatrix",this._lightmapTexture.getTextureMatrix())),this._specularTexture&&i.SpecularTextureEnabled&&(this._uniformBuffer.updateFloat2("vSpecularInfos",this._specularTexture.coordinatesIndex,this._specularTexture.level),this._uniformBuffer.updateMatrix("specularMatrix",this._specularTexture.getTextureMatrix())),this._bumpTexture&&o.getEngine().getCaps().standardDerivatives&&i.BumpTextureEnabled&&(this._uniformBuffer.updateFloat3("vBumpInfos",this._bumpTexture.coordinatesIndex,1/this._bumpTexture.level,this.parallaxScaleBias),this._uniformBuffer.updateMatrix("bumpMatrix",this._bumpTexture.getTextureMatrix())),this._refractionTexture&&i.RefractionTextureEnabled)){var u=1;this._refractionTexture.isCube||(this._uniformBuffer.updateMatrix("refractionMatrix",this._refractionTexture.getReflectionTextureMatrix()),this._refractionTexture.depth&&(u=this._refractionTexture.depth)),this._uniformBuffer.updateFloat4("vRefractionInfos",this._refractionTexture.level,this.indexOfRefraction,u,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){if(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 u=1;this._refractionTexture.isCube?a.setTexture("refractionCubeSampler",this._refractionTexture):a.setTexture("refraction2DSampler",this._refractionTexture)}this._cameraColorGradingTexture&&i.ColorGradingTextureEnabled&&e.ColorGradingTexture.Bind(this._cameraColorGradingTexture,a)}e.MaterialHelper.BindClipPlane(a,o),o.ambientColor.multiplyToRef(this.ambientColor,this._globalAmbientColor),a.setVector3("vEyePosition",o._mirroredCameraPosition?o._mirroredCameraPosition:o.activeCamera.position),a.setColor3("vAmbientColor",this._globalAmbientColor)}!this._mustRebind(o,a)&&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._cameraColorCurves&&e.ColorCurves.Bind(this._cameraColorCurves,a)),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),this._cameraColorGradingTexture&&this._cameraColorGradingTexture.animations&&this._cameraColorGradingTexture.animations.length>0&&e.push(this._cameraColorGradingTexture),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._cameraColorGradingTexture&&this._cameraColorGradingTexture.dispose()),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})(e.PushMaterial);r._DiffuseTextureEnabled=!0,r._AmbientTextureEnabled=!0,r._OpacityTextureEnabled=!0,r._ReflectionTextureEnabled=!0,r._EmissiveTextureEnabled=!0,r._SpecularTextureEnabled=!0,r._BumpTextureEnabled=!0,r._LightmapTextureEnabled=!0,r._RefractionTextureEnabled=!0,r._ColorGradingTextureEnabled=!0,r._FresnelEnabled=!0,__decorate([e.serializeAsTexture("diffuseTexture")],r.prototype,"_diffuseTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"diffuseTexture",void 0),__decorate([e.serializeAsTexture("ambientTexture")],r.prototype,"_ambientTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"ambientTexture",void 0),__decorate([e.serializeAsTexture("opacityTexture")],r.prototype,"_opacityTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"opacityTexture",void 0),__decorate([e.serializeAsTexture("reflectionTexture")],r.prototype,"_reflectionTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"reflectionTexture",void 0),__decorate([e.serializeAsTexture("emissiveTexture")],r.prototype,"_emissiveTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"emissiveTexture",void 0),__decorate([e.serializeAsTexture("specularTexture")],r.prototype,"_specularTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"specularTexture",void 0),__decorate([e.serializeAsTexture("bumpTexture")],r.prototype,"_bumpTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"bumpTexture",void 0),__decorate([e.serializeAsTexture("lightmapTexture")],r.prototype,"_lightmapTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"lightmapTexture",void 0),__decorate([e.serializeAsTexture("refractionTexture")],r.prototype,"_refractionTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"refractionTexture",void 0),__decorate([e.serializeAsColor3("ambient")],r.prototype,"ambientColor",void 0),__decorate([e.serializeAsColor3("diffuse")],r.prototype,"diffuseColor",void 0),__decorate([e.serializeAsColor3("specular")],r.prototype,"specularColor",void 0),__decorate([e.serializeAsColor3("emissive")],r.prototype,"emissiveColor",void 0),__decorate([e.serialize()],r.prototype,"specularPower",void 0),__decorate([e.serialize("useAlphaFromDiffuseTexture")],r.prototype,"_useAlphaFromDiffuseTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"useAlphaFromDiffuseTexture",void 0),__decorate([e.serialize("useEmissiveAsIllumination")],r.prototype,"_useEmissiveAsIllumination",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"useEmissiveAsIllumination",void 0),__decorate([e.serialize("linkEmissiveWithDiffuse")],r.prototype,"_linkEmissiveWithDiffuse",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"linkEmissiveWithDiffuse",void 0),__decorate([e.serialize("useSpecularOverAlpha")],r.prototype,"_useSpecularOverAlpha",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"useSpecularOverAlpha",void 0),__decorate([e.serialize("useReflectionOverAlpha")],r.prototype,"_useReflectionOverAlpha",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"useReflectionOverAlpha",void 0),__decorate([e.serialize("disableLighting")],r.prototype,"_disableLighting",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsLightsDirty")],r.prototype,"disableLighting",void 0),__decorate([e.serialize("useParallax")],r.prototype,"_useParallax",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"useParallax",void 0),__decorate([e.serialize("useParallaxOcclusion")],r.prototype,"_useParallaxOcclusion",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"useParallaxOcclusion",void 0),__decorate([e.serialize()],r.prototype,"parallaxScaleBias",void 0),__decorate([e.serialize("roughness")],r.prototype,"_roughness",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"roughness",void 0),__decorate([e.serialize()],r.prototype,"indexOfRefraction",void 0),__decorate([e.serialize()],r.prototype,"invertRefractionY",void 0),__decorate([e.serialize("useLightmapAsShadowmap")],r.prototype,"_useLightmapAsShadowmap",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"useLightmapAsShadowmap",void 0),__decorate([e.serializeAsFresnelParameters("diffuseFresnelParameters")],r.prototype,"_diffuseFresnelParameters",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsFresnelDirty")],r.prototype,"diffuseFresnelParameters",void 0),__decorate([e.serializeAsFresnelParameters("opacityFresnelParameters")],r.prototype,"_opacityFresnelParameters",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsFresnelDirty")],r.prototype,"opacityFresnelParameters",void 0),__decorate([e.serializeAsFresnelParameters("reflectionFresnelParameters")],r.prototype,"_reflectionFresnelParameters",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsFresnelDirty")],r.prototype,"reflectionFresnelParameters",void 0),__decorate([e.serializeAsFresnelParameters("refractionFresnelParameters")],r.prototype,"_refractionFresnelParameters",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsFresnelDirty")],r.prototype,"refractionFresnelParameters",void 0),__decorate([e.serializeAsFresnelParameters("emissiveFresnelParameters")],r.prototype,"_emissiveFresnelParameters",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsFresnelDirty")],r.prototype,"emissiveFresnelParameters",void 0),__decorate([e.serialize("useReflectionFresnelFromSpecular")],r.prototype,"_useReflectionFresnelFromSpecular",void 0),
- __decorate([e.expandToProperty("_markAllSubMeshesAsFresnelDirty")],r.prototype,"useReflectionFresnelFromSpecular",void 0),__decorate([e.serialize("useGlossinessFromSpecularMapAlpha")],r.prototype,"_useGlossinessFromSpecularMapAlpha",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"useGlossinessFromSpecularMapAlpha",void 0),__decorate([e.serialize("maxSimultaneousLights")],r.prototype,"_maxSimultaneousLights",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsLightsDirty")],r.prototype,"maxSimultaneousLights",void 0),__decorate([e.serialize("invertNormalMapX")],r.prototype,"_invertNormalMapX",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"invertNormalMapX",void 0),__decorate([e.serialize("invertNormalMapY")],r.prototype,"_invertNormalMapY",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"invertNormalMapY",void 0),__decorate([e.serialize("twoSidedLighting")],r.prototype,"_twoSidedLighting",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"twoSidedLighting",void 0),__decorate([e.serializeAsTexture("cameraColorGradingTexture")],r.prototype,"_cameraColorGradingTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"cameraColorGradingTexture",void 0),__decorate([e.serializeAsColorCurves("cameraColorCurves")],r.prototype,"_cameraColorCurves",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"cameraColorCurves",void 0),__decorate([e.serialize()],r.prototype,"useLogarithmicDepth",null),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,h=1;h<i.length&&!(o>=a);h++){var l=i[h],c=l.offset,f=c-u;if(f!==e){for(var d=f/e-1,p=c-e,_=Math.min(s,d),m=0;m<_;m++){var g=o/e,v=p/e,y=n[v];this._moveElement(y,o);var T=n[g];T.offset=p,n[g]=y,n[v]=T,p-=e,o+=e}s<=d?(o=p+e,s=1+_):s=(c-o)/e+1,u=c}else++s,u=c}var x=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,x},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],h=this._sortTable[s],l=u.offset;if(u.swapedOffset){for(var c=u;c.swapedOffset;)c=this._sortTable[c.swapedOffset/o];l=c.offset}h.swapedOffset=l,l!==h.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}})(l,h.offset),this._allEntries[u.offset/o].offset=h.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})(t);r._IsEqual=0,r._IsDifferent=1,r._IsGreater=2,r._IsLesser=3,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 e(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 e.prototype._prepare=function(){},e.prototype.getTriggerParameter=function(){return this._triggerParameter},e.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()},e.prototype.execute=function(e){},e.prototype.skipToNextActiveAction=function(){this._nextActiveAction._child?(this._nextActiveAction._child._actionManager||(this._nextActiveAction._child._actionManager=this._actionManager),this._nextActiveAction=this._nextActiveAction._child):this._nextActiveAction=this},e.prototype.then=function(e){return this._child=e,e._actionManager=this._actionManager,e._prepare(),e},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){},e.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},e})();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}},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 h=new Array,u=0;u<a.length;u++)h.push(parseFloat(a[u]));return i instanceof e.Vector3?e.Vector3.FromArray(h):i instanceof e.Vector4?e.Vector4.FromArray(h):i instanceof e.Color3?e.Color3.FromArray(h):i instanceof e.Color4?e.Color4.FromArray(h):parseFloat(a[0])},u=function(r,i,h,l,c){if(void 0===c&&(c=null),!r.detached){var f=new Array,d=null,p=null,_=r.combine&&r.combine.length>0;if(2===r.type?f.push(o):f.push(i),_){for(var m=new Array,g=0;g<r.combine.length;g++)u(r.combine[g],t.NothingTrigger,h,l,m);f.push(m)}else for(var v=0;v<r.properties.length;v++){var y=r.properties[v].value,T=r.properties[v].name,x=r.properties[v].targetType;"target"===T?y=d=null!==x&&"SceneProperties"===x?n:n.getNodeByName(y):"parent"===T?y=n.getNodeByName(y):"sound"===T?y=n.getSoundByName(y):"propertyPath"!==T?y=2===r.type&&"operator"===T?e.ValueCondition[y]:a(0,y,d,"value"===T?p:null):p=y,f.push(y)}if(null===c?f.push(h):f.push(null),"InterpolateValueAction"===r.name){var E=f[f.length-2];f[f.length-1]=E,f[f.length-2]=h}var b=s(r.name,f);if(b instanceof e.Condition&&null!==h){var A=new e.DoNothingAction(i,h);l?l.then(A):o.registerAction(A),l=A}null===c?b instanceof e.Condition?(h=b,b=l):(h=null,l?l.then(b):o.registerAction(b)):c.push(b);for(var v=0;v<r.children.length;v++)u(r.children[v],i,h,b,null)}},h=0;h<r.children.length;h++){var l,c=r.children[h];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)),l={trigger:e.ActionManager[c.name],parameter:d}}else l=e.ActionManager[c.name];for(var p=0;p<c.children.length;p++)c.detached||u(c.children[p],l,null,null)}},t.GetTriggerName=function(e){switch(e){case 0:return"NothingTrigger";case 1:return"OnPickTrigger";case 2:return"OnLeftPickTrigger";case 3:return"OnRightPickTrigger";case 4:return"OnCenterPickTrigger";case 5:return"OnPickDownTrigger";case 6:return"OnPickUpTrigger";case 7:return"OnLongPressTrigger";case 8:return"OnPointerOverTrigger";case 9:return"OnPointerOutTrigger";case 10:return"OnEveryFrameTrigger";case 11:return"OnIntersectionEnterTrigger";case 12:return"OnIntersectionExitTrigger";case 13:return"OnKeyDownTrigger";case 14:return"OnKeyUpTrigger";case 15:return"OnPickOutTrigger";default:return""}},t})();r._NothingTrigger=0,r._OnPickTrigger=1,r._OnLeftPickTrigger=2,r._OnRightPickTrigger=3,r._OnCenterPickTrigger=4,r._OnPickDownTrigger=5,r._OnDoublePickTrigger=6,r._OnPickUpTrigger=7,r._OnLongPressTrigger=8,r._OnPointerOverTrigger=9,r._OnPointerOutTrigger=10,r._OnEveryFrameTrigger=11,r._OnIntersectionEnterTrigger=12,r._OnIntersectionExitTrigger=13,r._OnKeyDownTrigger=14,r._OnKeyUpTrigger=15,r._OnPickOutTrigger=16,r.Triggers={},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 h=t.call(this,e,s)||this;return h.propertyPath=i,h.value=n,h.duration=o,h.stopOtherAnimations=a,h.onInterpolationDone=u,h._target=h._effectiveTarget=r,h}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 h=(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=h;var l=(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=l;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 h=e.Tmp.Matrix[1];e.Matrix.IdentityToRef(h),h.m[12]=n,h.m[13]=o,h.m[14]=s,h.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 h=this._debugLines[n];h||(h=[e.Vector3.Zero(),e.Vector3.Zero()],this._debugLines[n]=h),a.getAbsolutePositionToRef(this.mesh,h[0]),u.getAbsolutePositionToRef(this.mesh,h[1]),h[0].subtractInPlace(o),h[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})();t.InspectorURL=window.location.href.split("/")[0]+"//preview.babylonjs.com/inspector/babylon.inspector.bundle.js",e.DebugLayer=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(t){this.frontColor=new e.Color3(1,1,1),this.backColor=new e.Color3(.1,.1,.1),this.showBackLines=!0,this.renderList=new e.SmartArray(32),this._vertexBuffers={},this._scene=t}return t.prototype._prepareRessources=function(){if(!this._colorShader){this._colorShader=new e.ShaderMaterial("colorShader",this._scene,"color",{attributes:[e.VertexBuffer.PositionKind],uniforms:["world","viewProjection","color"]});var t=this._scene.getEngine(),r=e.VertexData.CreateBox(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})();e.TextureTools=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 VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\n#ifdef ALBEDO\nvarying vec2 vAlbedoUV;\n#endif\n#ifdef AMBIENT\nvarying vec2 vAmbientUV;\n#endif\n#ifdef OPACITY\nvarying vec2 vOpacityUV;\n#endif\n#ifdef EMISSIVE\nvarying vec2 vEmissiveUV;\n#endif\n#ifdef LIGHTMAP\nvarying vec2 vLightmapUV;\n#endif\n#if defined(REFLECTIVITY) || defined(METALLICWORKFLOW) \nvarying vec2 vReflectivityUV;\n#endif\n#ifdef MICROSURFACEMAP\nvarying vec2 vMicroSurfaceSamplerUV;\n#endif\n#ifdef BUMP\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 ALBEDO\nif (vAlbedoInfos.x == 0.)\n{\nvAlbedoUV=vec2(albedoMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvAlbedoUV=vec2(albedoMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#ifdef AMBIENT\nif (vAmbientInfos.x == 0.)\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#ifdef OPACITY\nif (vOpacityInfos.x == 0.)\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#ifdef EMISSIVE\nif (vEmissiveInfos.x == 0.)\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#ifdef LIGHTMAP\nif (vLightmapInfos.x == 0.)\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(REFLECTIVITY) || defined(METALLICWORKFLOW) \nif (vReflectivityInfos.x == 0.)\n{\nvReflectivityUV=vec2(reflectivityMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvReflectivityUV=vec2(reflectivityMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#ifdef MICROSURFACEMAP\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#ifdef BUMP\nif (vBumpInfos.x == 0.)\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n\n#include<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)\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 vec3 vEyePosition;\nuniform vec3 vAmbientColor;\nuniform vec4 vCameraInfos;\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n\n#ifdef ALBEDO\nvarying vec2 vAlbedoUV;\nuniform sampler2D albedoSampler;\n#endif\n#ifdef AMBIENT\nvarying vec2 vAmbientUV;\nuniform sampler2D ambientSampler;\n#endif\n#ifdef OPACITY \nvarying vec2 vOpacityUV;\nuniform sampler2D opacitySampler;\n#endif\n#ifdef EMISSIVE\nvarying vec2 vEmissiveUV;\nuniform sampler2D emissiveSampler;\n#endif\n#ifdef LIGHTMAP\nvarying vec2 vLightmapUV;\nuniform sampler2D lightmapSampler;\n#endif\n#if defined(REFLECTIVITY) || defined(METALLICWORKFLOW) \nvarying vec2 vReflectivityUV;\nuniform sampler2D reflectivitySampler;\n#endif\n#ifdef MICROSURFACEMAP\nvarying vec2 vMicroSurfaceSamplerUV;\nuniform sampler2D microSurfaceSampler;\n#endif\n\n#include<fresnelFunction>\n\n#ifdef REFRACTION\n#ifdef REFRACTIONMAP_3D\nuniform samplerCube refractionCubeSampler;\n#else\nuniform sampler2D refraction2DSampler;\n#endif\n#endif\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#ifdef CAMERACOLORGRADING\n#include<colorGradingDefinition>\n#endif\n#ifdef CAMERACOLORCURVES\n#include<colorCurvesDefinition>\n#endif\n\n#include<shadowsFragmentFunctions>\n#include<pbrFunctions>\n#ifdef CAMERACOLORGRADING\n#include<colorGrading>\n#endif\n#ifdef CAMERACOLORCURVES\n#include<colorCurves>\n#endif\n#include<harmonicsFunctions>\n#include<pbrLightFunctions>\n#include<helperFunctions>\n#include<bumpFragmentFunctions>\n#include<clipPlaneFragmentDeclaration>\n#include<logDepthDeclaration>\n\n#include<fogFragmentDeclaration>\nvoid main(void) {\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=normalize(cross(dFdx(vPositionW),dFdy(vPositionW)));\n#endif\n#include<bumpFragment>\n#if defined(TWOSIDEDLIGHTING) && defined(NORMAL) \nnormalW=gl_FrontFacing ? normalW : -normalW;\n#endif\n\nvec3 surfaceAlbedo=vAlbedoColor.rgb;\n\nfloat alpha=vAlbedoColor.a;\n#ifdef ALBEDO\nvec4 albedoTexture=texture2D(albedoSampler,vAlbedoUV+uvOffset);\n#ifdef ALPHAFROMALBEDO\nalpha*=albedoTexture.a;\n#endif\nsurfaceAlbedo*=toLinearSpace(albedoTexture.rgb);\nsurfaceAlbedo*=vAlbedoInfos.y;\n#endif\n#ifndef LINKREFRACTIONTOTRANSPARENCY\n#if defined(ALPHATEST) && defined(ALPHATESTVALUE)\nif (alpha<ALPHATESTVALUE)\ndiscard;\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 METALLICMAP\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\nfloat NdotV=max(0.00000000001,dot(normalW,viewDirectionW));\n\nmicroSurface=clamp(microSurface,0.,1.)*0.98;\n\nfloat roughness=clamp(1.-microSurface,0.000001,1.0);\n#ifdef LIGHTMAP\nvec3 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset).rgb*vLightmapInfos.y;\n#endif\nfloat NdotL=-1.;\n\nfloat reflectance=max(max(surfaceReflectivityColor.r,surfaceReflectivityColor.g),surfaceReflectivityColor.b);\n\n\nfloat reflectance90=clamp(reflectance*25.0,0.0,1.0);\nvec3 specularEnvironmentR0=surfaceReflectivityColor.rgb;\nvec3 specularEnvironmentR90=vec3(1.0,1.0,1.0)*reflectance90;\n\nvec3 diffuseBase=vec3(0.,0.,0.);\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif\nlightingInfo info;\nfloat shadow=1.; \n#include<lightFragment>[0..maxSimultaneousLights]\nvec3 lightDiffuseContribution=diffuseBase;\n#ifdef SPECULARTERM\nvec3 lightSpecularContribution=specularBase*vLightingIntensity.w;\n#endif\n#ifdef OPACITY\nvec4 opacityMap=texture2D(opacitySampler,vOpacityUV+uvOffset);\n#ifdef OPACITYRGB\nopacityMap.rgb=opacityMap.rgb*vec3(0.3,0.59,0.11);\nalpha*=(opacityMap.x+opacityMap.y+opacityMap.z)* vOpacityInfos.y;\n#else\nalpha*=opacityMap.a*vOpacityInfos.y;\n#endif\n#endif\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n#ifdef OPACITYFRESNEL\nfloat opacityFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,opacityParts.z,opacityParts.w);\nalpha+=opacityParts.x*(1.0-opacityFresnelTerm)+opacityFresnelTerm*opacityParts.y;\n#endif\n\nvec3 surfaceRefractionColor=vec3(0.,0.,0.);\n\n#ifdef LODBASEDMICROSFURACE\nfloat alphaG=convertRoughnessToAverageSlope(roughness);\n#endif\n#ifdef REFRACTION\nvec3 refractionVector=refract(-viewDirectionW,normalW,vRefractionInfos.y);\n#ifdef LODBASEDMICROSFURACE\n#ifdef USEPMREMREFRACTION\nfloat lodRefraction=getMipMapIndexFromAverageSlopeWithPMREM(vMicrosurfaceTextureLods.y,alphaG);\n#else\nfloat lodRefraction=getMipMapIndexFromAverageSlope(vMicrosurfaceTextureLods.y,alphaG);\n#endif\n#else\nfloat biasRefraction=(vMicrosurfaceTextureLods.y+2.)*(1.0-microSurface);\n#endif\n#ifdef REFRACTIONMAP_3D\nrefractionVector.y=refractionVector.y*vRefractionInfos.w;\nif (dot(refractionVector,viewDirectionW)<1.0)\n{\n#ifdef LODBASEDMICROSFURACE\n#ifdef USEPMREMREFRACTION\n\nif ((vMicrosurfaceTextureLods.y-lodRefraction)>4.0)\n{\n\nfloat scaleRefraction=1.-exp2(lodRefraction)/exp2(vMicrosurfaceTextureLods.y); \nfloat maxRefraction=max(max(abs(refractionVector.x),abs(refractionVector.y)),abs(refractionVector.z));\nif (abs(refractionVector.x) != maxRefraction) refractionVector.x*=scaleRefraction;\nif (abs(refractionVector.y) != maxRefraction) refractionVector.y*=scaleRefraction;\nif (abs(refractionVector.z) != maxRefraction) refractionVector.z*=scaleRefraction;\n}\n#endif\nsurfaceRefractionColor=textureCubeLodEXT(refractionCubeSampler,refractionVector,lodRefraction).rgb*vRefractionInfos.x;\n#else\nsurfaceRefractionColor=textureCube(refractionCubeSampler,refractionVector,biasRefraction).rgb*vRefractionInfos.x;\n#endif\n}\n#ifndef REFRACTIONMAPINLINEARSPACE\nsurfaceRefractionColor=toLinearSpace(surfaceRefractionColor.rgb);\n#endif\n#else\nvec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*vRefractionInfos.z,1.0)));\nvec2 refractionCoords=vRefractionUVW.xy/vRefractionUVW.z;\nrefractionCoords.y=1.0-refractionCoords.y;\n#ifdef LODBASEDMICROSFURACE\nsurfaceRefractionColor=texture2DLodEXT(refraction2DSampler,refractionCoords,lodRefraction).rgb*vRefractionInfos.x;\n#else\nsurfaceRefractionColor=texture2D(refraction2DSampler,refractionCoords,biasRefraction).rgb*vRefractionInfos.x;\n#endif \nsurfaceRefractionColor=toLinearSpace(surfaceRefractionColor.rgb);\n#endif\n#endif\n\nvec3 environmentRadiance=vReflectionColor.rgb;\nvec3 environmentIrradiance=vReflectionColor.rgb;\n#ifdef REFLECTION\nvec3 vReflectionUVW=computeReflectionCoords(vec4(vPositionW,1.0),normalW);\n#ifdef LODBASEDMICROSFURACE\n#ifdef USEPMREMREFLECTION\nfloat lodReflection=getMipMapIndexFromAverageSlopeWithPMREM(vMicrosurfaceTextureLods.x,alphaG);\n#else\nfloat lodReflection=getMipMapIndexFromAverageSlope(vMicrosurfaceTextureLods.x,alphaG);\n#endif\n#else\nfloat biasReflection=(vMicrosurfaceTextureLods.x+2.)*(1.0-microSurface);\n#endif\n#ifdef REFLECTIONMAP_3D\n#ifdef LODBASEDMICROSFURACE\n#ifdef USEPMREMREFLECTION\n\nif ((vMicrosurfaceTextureLods.y-lodReflection)>4.0)\n{\n\nfloat scaleReflection=1.-exp2(lodReflection)/exp2(vMicrosurfaceTextureLods.x); \nfloat maxReflection=max(max(abs(vReflectionUVW.x),abs(vReflectionUVW.y)),abs(vReflectionUVW.z));\nif (abs(vReflectionUVW.x) != maxReflection) vReflectionUVW.x*=scaleReflection;\nif (abs(vReflectionUVW.y) != maxReflection) vReflectionUVW.y*=scaleReflection;\nif (abs(vReflectionUVW.z) != maxReflection) vReflectionUVW.z*=scaleReflection;\n}\n#endif\nenvironmentRadiance=textureCubeLodEXT(reflectionCubeSampler,vReflectionUVW,lodReflection).rgb*vReflectionInfos.x;\n#else\nenvironmentRadiance=textureCube(reflectionCubeSampler,vReflectionUVW,biasReflection).rgb*vReflectionInfos.x;\n#endif\n#ifdef USESPHERICALFROMREFLECTIONMAP\n#ifndef REFLECTIONMAP_SKYBOX\nvec3 normalEnvironmentSpace=(reflectionMatrix*vec4(normalW,1)).xyz;\nenvironmentIrradiance=EnvironmentIrradiance(normalEnvironmentSpace);\n#endif\n#else\nenvironmentRadiance=toLinearSpace(environmentRadiance.rgb);\nenvironmentIrradiance=textureCube(reflectionCubeSampler,normalW,20.).rgb*vReflectionInfos.x;\nenvironmentIrradiance=toLinearSpace(environmentIrradiance.rgb);\nenvironmentIrradiance*=0.2; \n#endif\n#else\nvec2 coords=vReflectionUVW.xy;\n#ifdef REFLECTIONMAP_PROJECTION\ncoords/=vReflectionUVW.z;\n#endif\ncoords.y=1.0-coords.y;\n#ifdef LODBASEDMICROSFURACE\nenvironmentRadiance=texture2DLodEXT(reflection2DSampler,coords,lodReflection).rgb*vReflectionInfos.x;\n#else\nenvironmentRadiance=texture2D(reflection2DSampler,coords,biasReflection).rgb*vReflectionInfos.x;\n#endif\nenvironmentRadiance=toLinearSpace(environmentRadiance.rgb);\nenvironmentIrradiance=texture2D(reflection2DSampler,coords,20.).rgb*vReflectionInfos.x;\nenvironmentIrradiance=toLinearSpace(environmentIrradiance.rgb);\n#endif\n#endif\nenvironmentRadiance*=vLightingIntensity.z;\nenvironmentIrradiance*=vLightingIntensity.z;\n\nvec3 specularEnvironmentReflectance=FresnelSchlickEnvironmentGGX(clamp(NdotV,0.,1.),specularEnvironmentR0,specularEnvironmentR90,sqrt(microSurface));\n\nvec3 refractance=vec3(0.0,0.0,0.0);\n#ifdef REFRACTION\nvec3 transmission=vec3(1.0,1.0,1.0);\n#ifdef LINKREFRACTIONTOTRANSPARENCY\n\ntransmission*=(1.0-alpha);\n\n\nvec3 mixedAlbedo=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\nsurfaceRefractionColor*=tint;\n\nalpha=1.0;\n#endif\n\nvec3 bounceSpecularEnvironmentReflectance=(2.0*specularEnvironmentReflectance)/(1.0+specularEnvironmentReflectance);\nspecularEnvironmentReflectance=mix(bounceSpecularEnvironmentReflectance,specularEnvironmentReflectance,alpha);\n\ntransmission*=1.0-specularEnvironmentReflectance;\n\nrefractance=surfaceRefractionColor*transmission;\n#endif\n\nsurfaceAlbedo.rgb=(1.-reflectance)*surfaceAlbedo.rgb;\nrefractance*=vLightingIntensity.z;\nenvironmentRadiance*=specularEnvironmentReflectance;\n\nvec3 surfaceEmissiveColor=vEmissiveColor;\n#ifdef EMISSIVE\nvec3 emissiveColorTex=texture2D(emissiveSampler,vEmissiveUV+uvOffset).rgb;\nsurfaceEmissiveColor=toLinearSpace(emissiveColorTex.rgb)*surfaceEmissiveColor*vEmissiveInfos.y;\n#endif\n#ifdef EMISSIVEFRESNEL\nfloat emissiveFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,emissiveRightColor.a,emissiveLeftColor.a);\nsurfaceEmissiveColor*=emissiveLeftColor.rgb*(1.0-emissiveFresnelTerm)+emissiveFresnelTerm*emissiveRightColor.rgb;\n#endif\n\nvec3 finalDiffuse=lightDiffuseContribution;\n#ifndef EMISSIVEASILLUMINATION\nfinalDiffuse+=surfaceEmissiveColor;\n#endif\nfinalDiffuse.rgb+=vAmbientColor;\nfinalDiffuse*=surfaceAlbedo.rgb;\nfinalDiffuse=max(finalDiffuse,0.0);\nfinalDiffuse=(finalDiffuse*vLightingIntensity.x+surfaceAlbedo.rgb*environmentIrradiance)*ambientOcclusionColor;\nfloat luminanceOverAlpha=0.0;\n#ifdef RADIANCEOVERALPHA\nluminanceOverAlpha+=getLuminance(environmentRadiance);\n#endif\n#ifdef SPECULARTERM\nvec3 finalSpecular=lightSpecularContribution*surfaceReflectivityColor;\n#ifdef SPECULAROVERALPHA\nluminanceOverAlpha+=getLuminance(finalSpecular);\n#endif\n#else\nvec3 finalSpecular=vec3(0.0);\n#endif\nfinalSpecular*=vLightingIntensity.x;\n#if defined(RADIANCEOVERALPHA) || defined(SPECULAROVERALPHA)\nalpha=clamp(alpha+luminanceOverAlpha*alpha,0.,1.);\n#endif\n\n\nvec4 finalColor=vec4(finalDiffuse+finalSpecular+environmentRadiance+refractance,alpha);\n#ifdef EMISSIVEASILLUMINATION\nfinalColor.rgb+=(surfaceEmissiveColor*vLightingIntensity.y);\n#endif\n#ifdef LIGHTMAP\n#ifndef LIGHTMAPEXCLUDED\n#ifdef USELIGHTMAPASSHADOWMAP\nfinalColor.rgb*=lightmapColor;\n#else\nfinalColor.rgb+=lightmapColor;\n#endif\n#endif\n#endif\nfinalColor=max(finalColor,0.0);\n#ifdef CAMERATONEMAP\nfinalColor.rgb=toneMaps(finalColor.rgb);\n#endif\nfinalColor.rgb=toGammaSpace(finalColor.rgb);\n#include<logDepthFragment>\n#include<fogFragment>(color,finalColor)\n#ifdef CAMERACONTRAST\nfinalColor=contrasts(finalColor);\n#endif\n#ifdef LDROUTPUT\nfinalColor.rgb=clamp(finalColor.rgb,0.,1.);\n#ifdef CAMERACOLORGRADING\nfinalColor=colorGrades(finalColor);\n#endif\n#ifdef CAMERACOLORCURVES\nfinalColor.rgb=applyColorCurves(finalColor.rgb);\n#endif\n#endif\ngl_FragColor=finalColor;\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;\nconst float GammaEncodePowerApprox=1.0/2.2;\nconst float LinearEncodePowerApprox=2.2;\nconst vec3 RGBLuminanceCoefficients=vec3(0.2126,0.7152,0.0722);\nuniform float contrast;\nuniform vec4 vignetteSettings1;\nuniform vec4 vignetteSettings2;\nuniform float cameraExposureLinear;\nuniform vec4 vCameraColorCurveNegative;\nuniform vec4 vCameraColorCurveNeutral;\nuniform vec4 vCameraColorCurvePositive;\nuniform sampler2D txColorTransform;\nuniform vec4 colorTransformSettings;\nvec3 applyEaseInOut(vec3 x){\nreturn x*x*(3.0-2.0*x);\n}\n\nvec3 sampleTexture3D(sampler2D colorTransform,vec3 color)\n{\nfloat sliceSize=2.0*colorTransformSettings.y; \nfloat sliceContinuous=(color.y-colorTransformSettings.y)*colorTransformSettings.z;\nfloat sliceInteger=floor(sliceContinuous);\n\n\nfloat sliceFraction=sliceContinuous-sliceInteger;\nvec2 sliceUV=color.xz;\nsliceUV.x*=sliceSize;\nsliceUV.x+=sliceInteger*sliceSize;\nvec4 slice0Color=texture2D(colorTransform,sliceUV);\nsliceUV.x+=sliceSize;\nvec4 slice1Color=texture2D(colorTransform,sliceUV);\nvec3 result=mix(slice0Color.rgb,slice1Color.rgb,sliceFraction);\ncolor.rgb=result.bgr;\nreturn color;\n}\nvec4 applyImageProcessing(vec4 result,vec2 viewportXY){\n#ifndef FROMLINEARSPACE\n\nresult.rgb=pow(result.rgb,vec3(LinearEncodePowerApprox));\n#endif\nresult.rgb*=cameraExposureLinear;\n#ifdef VIGNETTE\n\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 \nfloat tonemappingCalibration=1.590579;\nresult.rgb=1.0-exp2(-tonemappingCalibration*result.rgb);\n#endif\n\nresult.rgb=pow(result.rgb,vec3(GammaEncodePowerApprox));\nresult.rgb=clamp(result.rgb,0.0,1.0);\n\nvec3 resultHighContrast=applyEaseInOut(result.rgb);\nif (contrast<1.0) {\nresult.rgb=mix(vec3(0.5,0.5,0.5),result.rgb,contrast);\n} else {\nresult.rgb=mix(result.rgb,resultHighContrast,contrast-1.0);\n}\n\n#ifdef COLORGRADING\nvec3 colorTransformInput=result.rgb*colorTransformSettings.xxx+colorTransformSettings.yyy;\nvec3 colorTransformOutput=sampleTexture3D(txColorTransform,colorTransformInput).rgb;\nresult.rgb=mix(result.rgb,colorTransformOutput,colorTransformSettings.www);\n#endif\n#ifdef COLORCURVES\n\nfloat luma=dot(result.rgb,RGBLuminanceCoefficients);\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}\nvoid main(void) \n{\nvec4 result=texture2D(textureSampler,vUV);\nvec2 viewportXY=vUV*2.0-1.0;\nresult=applyImageProcessing(result,viewportXY);\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 DIFFUSE\nvarying vec2 vDiffuseUV;\n#endif\n#ifdef AMBIENT\nvarying vec2 vAmbientUV;\n#endif\n#ifdef OPACITY\nvarying vec2 vOpacityUV;\n#endif\n#ifdef EMISSIVE\nvarying vec2 vEmissiveUV;\n#endif\n#ifdef LIGHTMAP\nvarying vec2 vLightmapUV;\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM)\nvarying vec2 vSpecularUV;\n#endif\n#ifdef BUMP\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 DIFFUSE\nif (vDiffuseInfos.x == 0.)\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#ifdef AMBIENT\nif (vAmbientInfos.x == 0.)\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#ifdef OPACITY\nif (vOpacityInfos.x == 0.)\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#ifdef EMISSIVE\nif (vEmissiveInfos.x == 0.)\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#ifdef LIGHTMAP\nif (vLightmapInfos.x == 0.)\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM)\nif (vSpecularInfos.x == 0.)\n{\nvSpecularUV=vec2(specularMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvSpecularUV=vec2(specularMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#ifdef BUMP\nif (vBumpInfos.x == 0.)\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#include<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#ifdef BUMP\n#extension GL_OES_standard_derivatives : enable\n#endif\n#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\n\n#define RECIPROCAL_PI2 0.15915494\nuniform vec3 vEyePosition;\nuniform vec3 vAmbientColor;\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n\n#include<helperFunctions>\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n\n#ifdef DIFFUSE\nvarying vec2 vDiffuseUV;\nuniform sampler2D diffuseSampler;\n#endif\n#ifdef AMBIENT\nvarying vec2 vAmbientUV;\nuniform sampler2D ambientSampler;\n#endif\n#ifdef OPACITY \nvarying vec2 vOpacityUV;\nuniform sampler2D opacitySampler;\n#endif\n#ifdef EMISSIVE\nvarying vec2 vEmissiveUV;\nuniform sampler2D emissiveSampler;\n#endif\n#ifdef LIGHTMAP\nvarying vec2 vLightmapUV;\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)\nvarying vec2 vSpecularUV;\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#ifdef CAMERACOLORGRADING\n#include<colorGradingDefinition> \n#include<colorGrading>\n#endif\n#ifdef CAMERACOLORCURVES\n#include<colorCurvesDefinition>\n#include<colorCurves>\n#endif\n#include<bumpFragmentFunctions>\n#include<clipPlaneFragmentDeclaration>\n#include<logDepthDeclaration>\n#include<fogFragmentDeclaration>\nvoid main(void) {\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\nvec4 baseColor=vec4(1.,1.,1.,1.);\nvec3 diffuseColor=vDiffuseColor.rgb;\n\nfloat alpha=vDiffuseColor.a;\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(1.0,1.0,1.0);\n#endif\n#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#ifdef CAMERACOLORGRADING\ncolor=colorGrades(color);\n#endif\n#ifdef CAMERACOLORCURVES\ncolor.rgb=applyColorCurves(color.rgb);\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 vec3 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\nvec3 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#if defined(REFLECTIVITY) || defined(METALLICWORKFLOW) \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",pbrFragmentDeclaration:"uniform vec3 vReflectionColor;\nuniform vec4 vAlbedoColor;\n\nuniform vec4 vLightingIntensity;\n#if defined(REFLECTION) || defined(REFRACTION)\nuniform vec2 vMicrosurfaceTextureLods;\n#endif\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;\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#if defined(REFLECTIVITY) || defined(METALLICWORKFLOW) \nuniform vec3 vReflectivityInfos;\n#endif\n#ifdef MICROSURFACEMAP\nuniform vec2 vMicroSurfaceSamplerInfos;\n#endif\n#ifdef OPACITYFRESNEL\nuniform vec4 opacityParts;\n#endif\n#ifdef EMISSIVEFRESNEL\nuniform vec4 emissiveLeftColor;\nuniform vec4 emissiveRightColor;\n#endif\n\n#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(REFRACTION)\nuniform mat4 view;\n#endif\n\n#ifdef REFRACTION\nuniform vec4 vRefractionInfos;\n#ifdef REFRACTIONMAP_3D\n#else\nuniform mat4 refractionMatrix;\n#endif\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#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 mat4 refractionMatrix;\nuniform mat4 reflectionMatrix;\nuniform vec3 vReflectionColor;\nuniform vec4 vAlbedoColor;\nuniform vec4 vLightingIntensity;\nuniform vec2 vMicrosurfaceTextureLods;\nuniform vec4 vReflectivityColor;\nuniform vec3 vEmissiveColor;\nuniform vec4 opacityParts;\nuniform vec4 emissiveLeftColor;\nuniform vec4 emissiveRightColor;\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);\nvec3 r=reflect(cameraToVertex,worldNormal);\nfloat t=clamp(r.y*-0.5+0.5,0.,1.0);\nfloat s=atan(r.z,r.x)*RECIPROCAL_PI2+0.5;\nreturn vec3(s,t,0);\n#endif\n#ifdef REFLECTIONMAP_SPHERICAL\nvec3 viewDir=normalize(vec3(view*worldPos));\nvec3 viewNormal=normalize(vec3(view*vec4(worldNormal,0.0)));\nvec3 r=reflect(viewDir,viewNormal);\nr.z=r.z-1.0;\nfloat m=2.0*length(r);\nreturn vec3(r.x/m+0.5,1.0-r.y/m-0.5,0);\n#endif\n#ifdef REFLECTIONMAP_PLANAR\nvec3 viewDir=worldPos.xyz-vEyePosition;\nvec3 coords=normalize(reflect(viewDir,worldNormal));\nreturn vec3(reflectionMatrix*vec4(coords,1));\n#endif\n#ifdef REFLECTIONMAP_CUBIC\nvec3 viewDir=worldPos.xyz-vEyePosition;\nvec3 coords=reflect(viewDir,worldNormal);\n#ifdef INVERTCUBICMAP\ncoords.y=1.0-coords.y;\n#endif\nreturn vec3(reflectionMatrix*vec4(coords,0));\n#endif\n#ifdef REFLECTIONMAP_PROJECTION\nreturn vec3(reflectionMatrix*(view*worldPos));\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nreturn vPositionUVW;\n#endif\n#ifdef REFLECTIONMAP_EXPLICIT\nreturn vec3(0,0,0);\n#endif\n}",colorGradingDefinition:"uniform sampler2D cameraColorGrading2DSampler;\nuniform vec4 vCameraColorGradingInfos;\nuniform vec4 vCameraColorGradingScaleOffset;",colorCurvesDefinition:"uniform vec4 vCameraColorCurveNeutral;\nuniform vec4 vCameraColorCurvePositive;\nuniform vec4 vCameraColorCurveNegative;",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-darkness,0.,1.); \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,0.,1.);\nreturn esm;\n}\nfloat computeShadow(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nclipSpace=0.5*clipSpace+vec3(0.5);\nvec2 uv=clipSpace.xy;\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 darkness;\n}\nreturn 1.;\n}\nfloat computeShadowWithPCF(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float mapSize,float darkness)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nclipSpace=0.5*clipSpace+vec3(0.5);\nvec2 uv=clipSpace.xy;\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 min(1.0,visibility+darkness);\n}\nfloat computeShadowWithESM(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float depthScale)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nclipSpace=0.5*clipSpace+vec3(0.5);\nvec2 uv=clipSpace.xy;\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-darkness,0.,1.);\n\n\n\n\n\nreturn esm;\n}\nfloat computeShadowWithCloseESM(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float depthScale)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nclipSpace=0.5*clipSpace+vec3(0.5);\nvec2 uv=clipSpace.xy;\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,0.,1.);\n\n\n\n\n\nreturn esm;\n}\n#endif",pbrFunctions:"\n#define RECIPROCAL_PI2 0.15915494\n#define FRESNEL_MAXIMUM_ON_ROUGH 0.25\n\nconst float kPi=3.1415926535897932384626433832795;\nconst float kRougnhessToAlphaScale=0.1;\nconst float kRougnhessToAlphaOffset=0.29248125;\nfloat Square(float value)\n{\nreturn value*value;\n}\nfloat getLuminance(vec3 color)\n{\nreturn clamp(dot(color,vec3(0.2126,0.7152,0.0722)),0.,1.);\n}\nfloat convertRoughnessToAverageSlope(float roughness)\n{\n\nconst float kMinimumVariance=0.0005;\nfloat alphaG=Square(roughness)+kMinimumVariance;\nreturn alphaG;\n}\n\nfloat getMipMapIndexFromAverageSlope(float maxMipLevel,float alpha)\n{\n\n\n\n\n\n\n\nfloat mip=kRougnhessToAlphaOffset+maxMipLevel+(maxMipLevel*kRougnhessToAlphaScale*log2(alpha));\nreturn clamp(mip,0.,maxMipLevel);\n}\nfloat getMipMapIndexFromAverageSlopeWithPMREM(float maxMipLevel,float alphaG)\n{\nfloat specularPower=clamp(2./alphaG-2.,0.000001,2048.);\n\nreturn clamp(- 0.5*log2(specularPower)+5.5,0.,maxMipLevel);\n}\n\nfloat smithVisibilityG1_TrowbridgeReitzGGX(float dot,float alphaG)\n{\nfloat tanSquared=(1.0-dot*dot)/(dot*dot);\nreturn 2.0/(1.0+sqrt(1.0+alphaG*alphaG*tanSquared));\n}\nfloat smithVisibilityG_TrowbridgeReitzGGX_Walter(float NdotL,float NdotV,float alphaG)\n{\nreturn smithVisibilityG1_TrowbridgeReitzGGX(NdotL,alphaG)*smithVisibilityG1_TrowbridgeReitzGGX(NdotV,alphaG);\n}\n\n\nfloat normalDistributionFunction_TrowbridgeReitzGGX(float NdotH,float alphaG)\n{\n\n\n\nfloat a2=Square(alphaG);\nfloat d=NdotH*NdotH*(a2-1.0)+1.0;\nreturn a2/(kPi*d*d);\n}\nvec3 fresnelSchlickGGX(float VdotH,vec3 reflectance0,vec3 reflectance90)\n{\nreturn reflectance0+(reflectance90-reflectance0)*pow(clamp(1.0-VdotH,0.,1.),5.0);\n}\nvec3 FresnelSchlickEnvironmentGGX(float VdotN,vec3 reflectance0,vec3 reflectance90,float smoothness)\n{\n\nfloat weight=mix(FRESNEL_MAXIMUM_ON_ROUGH,1.0,smoothness);\nreturn reflectance0+weight*(reflectance90-reflectance0)*pow(clamp(1.0-VdotN,0.,1.),5.0);\n}\n\nvec3 computeSpecularTerm(float NdotH,float NdotL,float NdotV,float VdotH,float roughness,vec3 specularColor,vec3 reflectance90)\n{\nfloat alphaG=convertRoughnessToAverageSlope(roughness);\nfloat distribution=normalDistributionFunction_TrowbridgeReitzGGX(NdotH,alphaG);\nfloat visibility=smithVisibilityG_TrowbridgeReitzGGX_Walter(NdotL,NdotV,alphaG);\nvisibility/=(4.0*NdotL*NdotV); \nvec3 fresnel=fresnelSchlickGGX(VdotH,specularColor,reflectance90);\nfloat specTerm=max(0.,visibility*distribution)*NdotL;\nreturn fresnel*specTerm*kPi; \n}\nfloat computeDiffuseTerm(float NdotL,float NdotV,float VdotH,float roughness)\n{\n\n\nfloat diffuseFresnelNV=pow(clamp(1.0-NdotL,0.000001,1.),5.0);\nfloat diffuseFresnelNL=pow(clamp(1.0-NdotV,0.000001,1.),5.0);\nfloat diffuseFresnel90=0.5+2.0*VdotH*VdotH*roughness;\nfloat diffuseFresnelTerm =\n(1.0+(diffuseFresnel90-1.0)*diffuseFresnelNL) *\n(1.0+(diffuseFresnel90-1.0)*diffuseFresnelNV);\nreturn diffuseFresnelTerm*NdotL;\n\n\n}\nfloat adjustRoughnessFromLightProperties(float roughness,float lightRadius,float lightDistance)\n{\n#ifdef USEPHYSICALLIGHTFALLOFF\n\nfloat lightRoughness=lightRadius/lightDistance;\n\nfloat totalRoughness=clamp(lightRoughness+roughness,0.,1.);\nreturn totalRoughness;\n#else\nreturn roughness;\n#endif\n}\nfloat computeDefaultMicroSurface(float microSurface,vec3 reflectivityColor)\n{\nfloat kReflectivityNoAlphaWorkflow_SmoothnessMax=0.95;\nfloat reflectivityLuminance=getLuminance(reflectivityColor);\nfloat reflectivityLuma=sqrt(reflectivityLuminance);\nmicroSurface=reflectivityLuma*kReflectivityNoAlphaWorkflow_SmoothnessMax;\nreturn microSurface;\n}\nvec3 toLinearSpace(vec3 color)\n{\nreturn vec3(pow(color.r,2.2),pow(color.g,2.2),pow(color.b,2.2));\n}\nvec3 toGammaSpace(vec3 color)\n{\nreturn vec3(pow(color.r,1.0/2.2),pow(color.g,1.0/2.2),pow(color.b,1.0/2.2));\n}\n#ifdef CAMERATONEMAP\nvec3 toneMaps(vec3 color)\n{\ncolor=max(color,0.0);\n\ncolor.rgb=color.rgb*vCameraInfos.x;\nfloat tuning=1.5; \n\n\nvec3 tonemapped=1.0-exp2(-color.rgb*tuning); \ncolor.rgb=mix(color.rgb,tonemapped,1.0);\nreturn color;\n}\n#endif\n#ifdef CAMERACONTRAST\nvec4 contrasts(vec4 color)\n{\ncolor=clamp(color,0.0,1.0);\nvec3 resultHighContrast=color.rgb*color.rgb*(3.0-2.0*color.rgb);\nfloat contrast=vCameraInfos.y;\nif (contrast<1.0)\n{\n\ncolor.rgb=mix(vec3(0.5,0.5,0.5),color.rgb,contrast);\n}\nelse\n{\n\ncolor.rgb=mix(color.rgb,resultHighContrast,contrast-1.0);\n}\nreturn color;\n}\n#endif",colorGrading:"vec4 colorGrades(vec4 color) \n{ \n\nfloat sliceContinuous=color.z*vCameraColorGradingInfos.z;\nfloat sliceInteger=floor(sliceContinuous);\n\n\nfloat sliceFraction=sliceContinuous-sliceInteger; \n\nvec2 sliceUV=color.xy*vCameraColorGradingScaleOffset.xy+vCameraColorGradingScaleOffset.zw;\n\n\nsliceUV.x+=sliceInteger*vCameraColorGradingInfos.w;\nvec4 slice0Color=texture2D(cameraColorGrading2DSampler,sliceUV);\nsliceUV.x+=vCameraColorGradingInfos.w;\nvec4 slice1Color=texture2D(cameraColorGrading2DSampler,sliceUV);\nvec3 result=mix(slice0Color.rgb,slice1Color.rgb,sliceFraction);\ncolor.rgb=mix(color.rgb,result,vCameraColorGradingInfos.x);\nreturn color;\n}",colorCurves:"const vec3 HDTVRec709_RGBLuminanceCoefficients=vec3(0.2126,0.7152,0.0722);\nvec3 applyColorCurves(vec3 original) {\nvec3 result=original;\n\n\n\nfloat luma=dot(result.rgb,HDTVRec709_RGBLuminanceCoefficients);\nvec2 curveMix=clamp(vec2(luma*3.0-1.5,luma*-3.0+1.5),vec2(0.0,0.0),vec2(1.0,1.0));\nvec4 colorCurve=vCameraColorCurveNeutral+curveMix.x*vCameraColorCurvePositive-curveMix.y*vCameraColorCurveNegative;\nresult.rgb*=colorCurve.rgb;\nresult.rgb=mix(vec3(luma,luma,luma),result.rgb,colorCurve.a);\nreturn result;\n}",harmonicsFunctions:"#ifdef USESPHERICALFROMREFLECTIONMAP\nuniform vec3 vSphericalX;\nuniform vec3 vSphericalY;\nuniform vec3 vSphericalZ;\nuniform vec3 vSphericalXX;\nuniform vec3 vSphericalYY;\nuniform vec3 vSphericalZZ;\nuniform vec3 vSphericalXY;\nuniform vec3 vSphericalYZ;\nuniform vec3 vSphericalZX;\nvec3 EnvironmentIrradiance(vec3 normal)\n{\n\n\n\nvec3 result =\nvSphericalX*normal.x +\nvSphericalY*normal.y +\nvSphericalZ*normal.z +\nvSphericalXX*normal.x*normal.x +\nvSphericalYY*normal.y*normal.y +\nvSphericalZZ*normal.z*normal.z +\nvSphericalYZ*normal.y*normal.z +\nvSphericalZX*normal.z*normal.x +\nvSphericalXY*normal.x*normal.y;\nreturn result.rgb;\n}\n#endif",pbrLightFunctions:"\nstruct lightingInfo\n{\nvec3 diffuse;\n#ifdef SPECULARTERM\nvec3 specular;\n#endif\n};\nfloat computeDistanceLightFalloff(vec3 lightOffset,float lightDistanceSquared,float range)\n{ \n#ifdef USEPHYSICALLIGHTFALLOFF\nfloat lightDistanceFalloff=1.0/((lightDistanceSquared+0.0001));\n#else\nfloat lightDistanceFalloff=max(0.,1.0-length(lightOffset)/range);\n#endif\nreturn lightDistanceFalloff;\n}\nfloat computeDirectionalLightFalloff(vec3 lightDirection,vec3 directionToLightCenterW,float lightAngle,float exponent)\n{\nfloat falloff=0.0;\n#ifdef USEPHYSICALLIGHTFALLOFF\nfloat cosHalfAngle=cos(lightAngle*0.5);\nconst float kMinusLog2ConeAngleIntensityRatio=6.64385618977; \n\n\n\n\n\nfloat concentrationKappa=kMinusLog2ConeAngleIntensityRatio/(1.0-cosHalfAngle);\n\n\nvec4 lightDirectionSpreadSG=vec4(-lightDirection*concentrationKappa,-concentrationKappa);\nfalloff=exp2(dot(vec4(directionToLightCenterW,1.0),lightDirectionSpreadSG));\n#else\nfloat cosAngle=max(0.000000000000001,dot(-lightDirection,directionToLightCenterW));\nif (cosAngle>=lightAngle)\n{\nfalloff=max(0.,pow(cosAngle,exponent));\n}\n#endif\nreturn falloff;\n}\nlightingInfo computeLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec3 diffuseColor,vec3 specularColor,float rangeRadius,float roughness,float NdotV,vec3 reflectance90,out float NdotL) {\nlightingInfo result;\nvec3 lightDirection;\nfloat attenuation=1.0;\nfloat lightDistance;\n\nif (lightData.w == 0.)\n{\nvec3 lightOffset=lightData.xyz-vPositionW;\nfloat lightDistanceSquared=dot(lightOffset,lightOffset);\nattenuation=computeDistanceLightFalloff(lightOffset,lightDistanceSquared,rangeRadius);\nlightDistance=sqrt(lightDistanceSquared);\nlightDirection=normalize(lightOffset);\n}\n\nelse\n{\nlightDistance=length(-lightData.xyz);\nlightDirection=normalize(-lightData.xyz);\n}\n\nroughness=adjustRoughnessFromLightProperties(roughness,rangeRadius,lightDistance);\n\nvec3 H=normalize(viewDirectionW+lightDirection);\nNdotL=max(0.00000000001,dot(vNormal,lightDirection));\nfloat VdotH=clamp(0.00000000001,1.0,dot(viewDirectionW,H));\nfloat diffuseTerm=computeDiffuseTerm(NdotL,NdotV,VdotH,roughness);\nresult.diffuse=diffuseTerm*diffuseColor*attenuation;\n#ifdef SPECULARTERM\n\nfloat NdotH=max(0.00000000001,dot(vNormal,H));\nvec3 specTerm=computeSpecularTerm(NdotH,NdotL,NdotV,VdotH,roughness,specularColor,reflectance90);\nresult.specular=specTerm*attenuation;\n#endif\nreturn result;\n}\nlightingInfo computeSpotLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec4 lightDirection,vec3 diffuseColor,vec3 specularColor,float rangeRadius,float roughness,float NdotV,vec3 reflectance90,out float NdotL) {\nlightingInfo result;\nvec3 lightOffset=lightData.xyz-vPositionW;\nvec3 directionToLightCenterW=normalize(lightOffset);\n\nfloat lightDistanceSquared=dot(lightOffset,lightOffset);\nfloat attenuation=computeDistanceLightFalloff(lightOffset,lightDistanceSquared,rangeRadius);\n\nfloat directionalAttenuation=computeDirectionalLightFalloff(lightDirection.xyz,directionToLightCenterW,lightDirection.w,lightData.w);\nattenuation*=directionalAttenuation;\n\nfloat lightDistance=sqrt(lightDistanceSquared);\nroughness=adjustRoughnessFromLightProperties(roughness,rangeRadius,lightDistance);\n\nvec3 H=normalize(viewDirectionW+directionToLightCenterW);\nNdotL=max(0.00000000001,dot(vNormal,directionToLightCenterW));\nfloat VdotH=clamp(dot(viewDirectionW,H),0.00000000001,1.0);\nfloat diffuseTerm=computeDiffuseTerm(NdotL,NdotV,VdotH,roughness);\nresult.diffuse=diffuseTerm*diffuseColor*attenuation;\n#ifdef SPECULARTERM\n\nfloat NdotH=max(0.00000000001,dot(vNormal,H));\nvec3 specTerm=computeSpecularTerm(NdotH,NdotL,NdotV,VdotH,roughness,specularColor,reflectance90);\nresult.specular=specTerm*attenuation;\n#endif\nreturn result;\n}\nlightingInfo computeHemisphericLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec3 diffuseColor,vec3 specularColor,vec3 groundColor,float roughness,float NdotV,vec3 reflectance90,out float NdotL) {\nlightingInfo result;\n\n\n\nNdotL=dot(vNormal,lightData.xyz)*0.5+0.5;\nresult.diffuse=mix(groundColor,diffuseColor,NdotL);\n#ifdef SPECULARTERM\n\nvec3 lightVectorW=normalize(lightData.xyz);\nvec3 H=normalize(viewDirectionW+lightVectorW);\nfloat NdotH=max(0.00000000001,dot(vNormal,H));\nNdotL=max(0.00000000001,NdotL);\nfloat VdotH=clamp(0.00000000001,1.0,dot(viewDirectionW,H));\nvec3 specTerm=computeSpecularTerm(NdotH,NdotL,NdotV,VdotH,roughness,specularColor,reflectance90);\nresult.specular=specTerm;\n#endif\nreturn result;\n}",helperFunctions:"mat3 transposeMat3(mat3 inMatrix) {\nvec3 i0=inMatrix[0];\nvec3 i1=inMatrix[1];\nvec3 i2=inMatrix[2];\nmat3 outMatrix=mat3(\nvec3(i0.x,i1.x,i2.x),\nvec3(i0.y,i1.y,i2.y),\nvec3(i0.z,i1.z,i2.z)\n);\nreturn outMatrix;\n}",bumpFragmentFunctions:"#ifdef BUMP\nvarying vec2 vBumpUV;\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;\n#ifdef INVERTNORMALMAPX\nmap.x=1.0-map.x;\n#endif\n#ifdef INVERTNORMALMAPY\nmap.y=1.0-map.y;\n#endif\nmap=map*255./127.-128./127.;\nreturn normalize(cotangentFrame*map);\n}\n#ifdef PARALLAX\nconst float minSamples=4.;\nconst float maxSamples=15.;\nconst int iMaxSamples=15;\n\nvec2 parallaxOcclusion(vec3 vViewDirCoT,vec3 vNormalCoT,vec2 texCoord,float parallaxScale) {\nfloat parallaxLimit=length(vViewDirCoT.xy)/vViewDirCoT.z;\nparallaxLimit*=parallaxScale;\nvec2 vOffsetDir=normalize(vViewDirCoT.xy);\nvec2 vMaxOffset=vOffsetDir*parallaxLimit;\nfloat numSamples=maxSamples+(dot(vViewDirCoT,vNormalCoT)*(minSamples-maxSamples));\nfloat stepSize=1.0/numSamples;\n\nfloat currRayHeight=1.0;\nvec2 vCurrOffset=vec2(0,0);\nvec2 vLastOffset=vec2(0,0);\nfloat lastSampledHeight=1.0;\nfloat currSampledHeight=1.0;\nfor (int i=0; i<iMaxSamples; i++)\n{\ncurrSampledHeight=texture2D(bumpSampler,vBumpUV+vCurrOffset).w;\n\nif (currSampledHeight>currRayHeight)\n{\nfloat delta1=currSampledHeight-currRayHeight;\nfloat delta2=(currRayHeight+stepSize)-lastSampledHeight;\nfloat ratio=delta1/(delta1+delta2);\nvCurrOffset=(ratio)* vLastOffset+(1.0-ratio)*vCurrOffset;\n\nbreak;\n}\nelse\n{\ncurrRayHeight-=stepSize;\nvLastOffset=vCurrOffset;\nvCurrOffset+=stepSize*vMaxOffset;\nlastSampledHeight=currSampledHeight;\n}\n}\nreturn vCurrOffset;\n}\nvec2 parallaxOffset(vec3 viewDir,float heightScale)\n{\n\nfloat height=texture2D(bumpSampler,vBumpUV).w;\nvec2 texCoordOffset=heightScale*viewDir.xy*height;\nreturn -texCoordOffset;\n}\n#endif\n#endif",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\nnormalW=normalize(normalW*vec3(vBumpInfos.y,vBumpInfos.y,1.0));\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,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,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,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);\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);\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);\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);\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;\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; \nmat4 refractionMatrix;\nvec4 vRefractionInfos;\nvec4 vSpecularColor;\nvec3 vEmissiveColor;\nvec4 vDiffuseColor;\nfloat pointSize; \n};\nuniform Scene {\nmat4 viewProjection;\nmat4 view;\n};"},("undefined"!=typeof window&&window.module||"undefined"!=typeof module)&&void 0!==module.exports&&(module.exports=BABYLON);
|