babylon.js 687 KB

1234567891011121314151617181920212223
  1. var __decorate=this&&this.__decorate||function(e,t,i,r){var n,s=arguments.length,o=s<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,r);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(o=(s<3?n(o):s>3?n(t,i,o):n(t,i))||o);return s>3&&o&&Object.defineProperty(t,i,o),o},__extends=this&&this.__extends||(function(){var e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i])};return function(t,i){function r(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(r.prototype=i.prototype,new r)}})(),BABYLON;!(function(e){e.ToGammaSpace=1/2.2,e.ToLinearSpace=2.2,e.Epsilon=.001;var t=(function(){function e(){}return e.WithinEpsilon=function(e,t,i){void 0===i&&(i=1.401298e-45);var r=e-t;return-i<=r&&r<=i},e.ToHex=function(e){var t=e.toString(16);return e<=15?("0"+t).toUpperCase():t.toUpperCase()},e.Sign=function(e){return e=+e,0===e||isNaN(e)?e:e>0?1:-1},e.Clamp=function(e,t,i){return void 0===t&&(t=0),void 0===i&&(i=1),Math.min(i,Math.max(t,e))},e})();e.MathTools=t;var i=(function(){function e(){}return e.Lerp=function(e,t,i){return e+(t-e)*i},e.Hermite=function(e,t,i,r,n){var s=n*n,o=n*s;return e*(2*o-3*s+1)+i*(-2*o+3*s)+t*(o-2*s+n)+r*(o-s)},e})();e.Scalar=i;var r=(function(){function i(e,t,i){void 0===e&&(e=0),void 0===t&&(t=0),void 0===i&&(i=0),this.r=e,this.g=t,this.b=i}return i.prototype.toString=function(){return"{R: "+this.r+" G:"+this.g+" B:"+this.b+"}"},i.prototype.getClassName=function(){return"Color3"},i.prototype.getHashCode=function(){var e=this.r||0;return e=397*e^(this.g||0),e=397*e^(this.b||0)},i.prototype.toArray=function(e,t){return void 0===t&&(t=0),e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,this},i.prototype.toColor4=function(e){return void 0===e&&(e=1),new n(this.r,this.g,this.b,e)},i.prototype.asArray=function(){var e=[];return this.toArray(e,0),e},i.prototype.toLuminance=function(){return.3*this.r+.59*this.g+.11*this.b},i.prototype.multiply=function(e){return new i(this.r*e.r,this.g*e.g,this.b*e.b)},i.prototype.multiplyToRef=function(e,t){return t.r=this.r*e.r,t.g=this.g*e.g,t.b=this.b*e.b,this},i.prototype.equals=function(e){return e&&this.r===e.r&&this.g===e.g&&this.b===e.b},i.prototype.equalsFloats=function(e,t,i){return this.r===e&&this.g===t&&this.b===i},i.prototype.scale=function(e){return new i(this.r*e,this.g*e,this.b*e)},i.prototype.scaleToRef=function(e,t){return t.r=this.r*e,t.g=this.g*e,t.b=this.b*e,this},i.prototype.add=function(e){return new i(this.r+e.r,this.g+e.g,this.b+e.b)},i.prototype.addToRef=function(e,t){return t.r=this.r+e.r,t.g=this.g+e.g,t.b=this.b+e.b,this},i.prototype.subtract=function(e){return new i(this.r-e.r,this.g-e.g,this.b-e.b)},i.prototype.subtractToRef=function(e,t){return t.r=this.r-e.r,t.g=this.g-e.g,t.b=this.b-e.b,this},i.prototype.clone=function(){return new i(this.r,this.g,this.b)},i.prototype.copyFrom=function(e){return this.r=e.r,this.g=e.g,this.b=e.b,this},i.prototype.copyFromFloats=function(e,t,i){return this.r=e,this.g=t,this.b=i,this},i.prototype.set=function(e,t,i){return this.copyFromFloats(e,t,i)},i.prototype.toHexString=function(){var e=255*this.r|0,i=255*this.g|0,r=255*this.b|0;return"#"+t.ToHex(e)+t.ToHex(i)+t.ToHex(r)},i.prototype.toLinearSpace=function(){var e=new i;return this.toLinearSpaceToRef(e),e},i.prototype.toLinearSpaceToRef=function(t){return t.r=Math.pow(this.r,e.ToLinearSpace),t.g=Math.pow(this.g,e.ToLinearSpace),t.b=Math.pow(this.b,e.ToLinearSpace),this},i.prototype.toGammaSpace=function(){var e=new i;return this.toGammaSpaceToRef(e),e},i.prototype.toGammaSpaceToRef=function(t){return t.r=Math.pow(this.r,e.ToGammaSpace),t.g=Math.pow(this.g,e.ToGammaSpace),t.b=Math.pow(this.b,e.ToGammaSpace),this},i.FromHexString=function(e){if("#"!==e.substring(0,1)||7!==e.length)return new i(0,0,0);var t=parseInt(e.substring(1,3),16),r=parseInt(e.substring(3,5),16),n=parseInt(e.substring(5,7),16);return i.FromInts(t,r,n)},i.FromArray=function(e,t){return void 0===t&&(t=0),new i(e[t],e[t+1],e[t+2])},i.FromInts=function(e,t,r){return new i(e/255,t/255,r/255)},i.Lerp=function(e,t,r){return new i(e.r+(t.r-e.r)*r,e.g+(t.g-e.g)*r,e.b+(t.b-e.b)*r)},i.Red=function(){return new i(1,0,0)},i.Green=function(){return new i(0,1,0)},i.Blue=function(){return new i(0,0,1)},i.Black=function(){return new i(0,0,0)},i.White=function(){return new i(1,1,1)},i.Purple=function(){return new i(.5,0,.5)},i.Magenta=function(){return new i(1,0,1)},i.Yellow=function(){return new i(1,1,0)},i.Gray=function(){return new i(.5,.5,.5)},i.Random=function(){return new i(Math.random(),Math.random(),Math.random())},i})();e.Color3=r;var n=(function(){function e(e,t,i,r){this.r=e,this.g=t,this.b=i,this.a=r}return e.prototype.addInPlace=function(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this.a+=e.a,this},e.prototype.asArray=function(){var e=[];return this.toArray(e,0),e},e.prototype.toArray=function(e,t){return void 0===t&&(t=0),e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e[t+3]=this.a,this},e.prototype.add=function(t){return new e(this.r+t.r,this.g+t.g,this.b+t.b,this.a+t.a)},e.prototype.subtract=function(t){return new e(this.r-t.r,this.g-t.g,this.b-t.b,this.a-t.a)},e.prototype.subtractToRef=function(e,t){return t.r=this.r-e.r,t.g=this.g-e.g,t.b=this.b-e.b,t.a=this.a-e.a,this},e.prototype.scale=function(t){return new e(this.r*t,this.g*t,this.b*t,this.a*t)},e.prototype.scaleToRef=function(e,t){return t.r=this.r*e,t.g=this.g*e,t.b=this.b*e,t.a=this.a*e,this},e.prototype.multiply=function(t){return new e(this.r*t.r,this.g*t.g,this.b*t.b,this.a*t.a)},e.prototype.multiplyToRef=function(e,t){return t.r=this.r*e.r,t.g=this.g*e.g,t.b=this.b*e.b,t.a=this.a*e.a,t},e.prototype.toString=function(){return"{R: "+this.r+" G:"+this.g+" B:"+this.b+" A:"+this.a+"}"},e.prototype.getClassName=function(){return"Color4"},e.prototype.getHashCode=function(){var e=this.r||0;return e=397*e^(this.g||0),e=397*e^(this.b||0),e=397*e^(this.a||0)},e.prototype.clone=function(){return new e(this.r,this.g,this.b,this.a)},e.prototype.copyFrom=function(e){return this.r=e.r,this.g=e.g,this.b=e.b,this.a=e.a,this},e.prototype.copyFromFloats=function(e,t,i,r){return this.r=e,this.g=t,this.b=i,this.a=r,this},e.prototype.set=function(e,t,i,r){return this.copyFromFloats(e,t,i,r)},e.prototype.toHexString=function(){var e=255*this.r|0,i=255*this.g|0,r=255*this.b|0,n=255*this.a|0;return"#"+t.ToHex(e)+t.ToHex(i)+t.ToHex(r)+t.ToHex(n)},e.FromHexString=function(t){if("#"!==t.substring(0,1)||9!==t.length)return new e(0,0,0,0);var i=parseInt(t.substring(1,3),16),r=parseInt(t.substring(3,5),16),n=parseInt(t.substring(5,7),16),s=parseInt(t.substring(7,9),16);return e.FromInts(i,r,n,s)},e.Lerp=function(t,i,r){var n=new e(0,0,0,0);return e.LerpToRef(t,i,r,n),n},e.LerpToRef=function(e,t,i,r){r.r=e.r+(t.r-e.r)*i,r.g=e.g+(t.g-e.g)*i,r.b=e.b+(t.b-e.b)*i,r.a=e.a+(t.a-e.a)*i},e.FromArray=function(t,i){return void 0===i&&(i=0),new e(t[i],t[i+1],t[i+2],t[i+3])},e.FromInts=function(t,i,r,n){return new e(t/255,i/255,r/255,n/255)},e.CheckColors4=function(e,t){if(e.length===3*t){for(var i=[],r=0;r<e.length;r+=3){var n=r/3*4;i[n]=e[r],i[n+1]=e[r+1],i[n+2]=e[r+2],i[n+3]=1}return i}return e},e})();e.Color4=n;var s=(function(){function i(e,t){this.x=e,this.y=t}return i.prototype.toString=function(){return"{X: "+this.x+" Y:"+this.y+"}"},i.prototype.getClassName=function(){return"Vector2"},i.prototype.getHashCode=function(){var e=this.x||0;return e=397*e^(this.y||0)},i.prototype.toArray=function(e,t){return void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,this},i.prototype.asArray=function(){var e=[];return this.toArray(e,0),e},i.prototype.copyFrom=function(e){return this.x=e.x,this.y=e.y,this},i.prototype.copyFromFloats=function(e,t){return this.x=e,this.y=t,this},i.prototype.set=function(e,t){return this.copyFromFloats(e,t)},i.prototype.add=function(e){return new i(this.x+e.x,this.y+e.y)},i.prototype.addToRef=function(e,t){return t.x=this.x+e.x,t.y=this.y+e.y,this},i.prototype.addInPlace=function(e){return this.x+=e.x,this.y+=e.y,this},i.prototype.addVector3=function(e){return new i(this.x+e.x,this.y+e.y)},i.prototype.subtract=function(e){return new i(this.x-e.x,this.y-e.y)},i.prototype.subtractToRef=function(e,t){return t.x=this.x-e.x,t.y=this.y-e.y,this},i.prototype.subtractInPlace=function(e){return this.x-=e.x,this.y-=e.y,this},i.prototype.multiplyInPlace=function(e){return this.x*=e.x,this.y*=e.y,this},i.prototype.multiply=function(e){return new i(this.x*e.x,this.y*e.y)},i.prototype.multiplyToRef=function(e,t){return t.x=this.x*e.x,t.y=this.y*e.y,this},i.prototype.multiplyByFloats=function(e,t){return new i(this.x*e,this.y*t)},i.prototype.divide=function(e){return new i(this.x/e.x,this.y/e.y)},i.prototype.divideToRef=function(e,t){return t.x=this.x/e.x,t.y=this.y/e.y,this},i.prototype.negate=function(){return new i(-this.x,-this.y)},i.prototype.scaleInPlace=function(e){return this.x*=e,this.y*=e,this},i.prototype.scale=function(e){return new i(this.x*e,this.y*e)},i.prototype.equals=function(e){return e&&this.x===e.x&&this.y===e.y},i.prototype.equalsWithEpsilon=function(i,r){return void 0===r&&(r=e.Epsilon),i&&t.WithinEpsilon(this.x,i.x,r)&&t.WithinEpsilon(this.y,i.y,r)},i.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y)},i.prototype.lengthSquared=function(){return this.x*this.x+this.y*this.y},i.prototype.normalize=function(){var e=this.length();if(0===e)return this;var t=1/e;return this.x*=t,this.y*=t,this},i.prototype.clone=function(){return new i(this.x,this.y)},i.Zero=function(){return new i(0,0)},i.FromArray=function(e,t){return void 0===t&&(t=0),new i(e[t],e[t+1])},i.FromArrayToRef=function(e,t,i){i.x=e[t],i.y=e[t+1]},i.CatmullRom=function(e,t,r,n,s){var o=s*s,a=s*o;return new i(.5*(2*t.x+(-e.x+r.x)*s+(2*e.x-5*t.x+4*r.x-n.x)*o+(-e.x+3*t.x-3*r.x+n.x)*a),.5*(2*t.y+(-e.y+r.y)*s+(2*e.y-5*t.y+4*r.y-n.y)*o+(-e.y+3*t.y-3*r.y+n.y)*a))},i.Clamp=function(e,t,r){var n=e.x;n=n>r.x?r.x:n,n=n<t.x?t.x:n;var s=e.y;return s=s>r.y?r.y:s,s=s<t.y?t.y:s,new i(n,s)},i.Hermite=function(e,t,r,n,s){var o=s*s,a=s*o,h=2*a-3*o+1,u=-2*a+3*o,c=a-2*o+s,l=a-o;return new i(e.x*h+r.x*u+t.x*c+n.x*l,e.y*h+r.y*u+t.y*c+n.y*l)},i.Lerp=function(e,t,r){return new i(e.x+(t.x-e.x)*r,e.y+(t.y-e.y)*r)},i.Dot=function(e,t){return e.x*t.x+e.y*t.y},i.Normalize=function(e){var t=e.clone();return t.normalize(),t},i.Minimize=function(e,t){return new i(e.x<t.x?e.x:t.x,e.y<t.y?e.y:t.y)},i.Maximize=function(e,t){return new i(e.x>t.x?e.x:t.x,e.y>t.y?e.y:t.y)},i.Transform=function(e,t){var r=i.Zero();return i.TransformToRef(e,t,r),r},i.TransformToRef=function(e,t,i){var r=e.x*t.m[0]+e.y*t.m[4]+t.m[12],n=e.x*t.m[1]+e.y*t.m[5]+t.m[13];i.x=r,i.y=n},i.PointInTriangle=function(e,t,i,r){var n=.5*(-i.y*r.x+t.y*(-i.x+r.x)+t.x*(i.y-r.y)+i.x*r.y),s=n<0?-1:1,o=(t.y*r.x-t.x*r.y+(r.y-t.y)*e.x+(t.x-r.x)*e.y)*s,a=(t.x*i.y-t.y*i.x+(t.y-i.y)*e.x+(i.x-t.x)*e.y)*s;return o>0&&a>0&&o+a<2*n*s},i.Distance=function(e,t){return Math.sqrt(i.DistanceSquared(e,t))},i.DistanceSquared=function(e,t){var i=e.x-t.x,r=e.y-t.y;return i*i+r*r},i.Center=function(e,t){var i=e.add(t);return i.scaleInPlace(.5),i},i.DistanceOfPointFromSegment=function(e,t,r){var n=i.DistanceSquared(t,r);if(0===n)return i.Distance(e,t);var s=r.subtract(t),o=Math.max(0,Math.min(1,i.Dot(e.subtract(t),s)/n)),a=t.add(s.multiplyByFloats(o,o));return i.Distance(e,a)},i})();e.Vector2=s;var o=(function(){function i(e,t,i){this.x=e,this.y=t,this.z=i}return i.prototype.toString=function(){return"{X: "+this.x+" Y:"+this.y+" Z:"+this.z+"}"},i.prototype.getClassName=function(){return"Vector3"},i.prototype.getHashCode=function(){var e=this.x||0;return e=397*e^(this.y||0),e=397*e^(this.z||0)},i.prototype.asArray=function(){var e=[];return this.toArray(e,0),e},i.prototype.toArray=function(e,t){return void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,this},i.prototype.toQuaternion=function(){var e=new u(0,0,0,1),t=Math.cos(.5*(this.x+this.z)),i=Math.sin(.5*(this.x+this.z)),r=Math.cos(.5*(this.z-this.x)),n=Math.sin(.5*(this.z-this.x)),s=Math.cos(.5*this.y),o=Math.sin(.5*this.y);return e.x=r*o,e.y=-n*o,e.z=i*s,e.w=t*s,e},i.prototype.addInPlace=function(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this},i.prototype.add=function(e){return new i(this.x+e.x,this.y+e.y,this.z+e.z)},i.prototype.addToRef=function(e,t){return t.x=this.x+e.x,t.y=this.y+e.y,t.z=this.z+e.z,this},i.prototype.subtractInPlace=function(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this},i.prototype.subtract=function(e){return new i(this.x-e.x,this.y-e.y,this.z-e.z)},i.prototype.subtractToRef=function(e,t){return t.x=this.x-e.x,t.y=this.y-e.y,t.z=this.z-e.z,this},i.prototype.subtractFromFloats=function(e,t,r){return new i(this.x-e,this.y-t,this.z-r)},i.prototype.subtractFromFloatsToRef=function(e,t,i,r){return r.x=this.x-e,r.y=this.y-t,r.z=this.z-i,this},i.prototype.negate=function(){return new i(-this.x,-this.y,-this.z)},i.prototype.scaleInPlace=function(e){return this.x*=e,this.y*=e,this.z*=e,this},i.prototype.scale=function(e){return new i(this.x*e,this.y*e,this.z*e)},i.prototype.scaleToRef=function(e,t){return t.x=this.x*e,t.y=this.y*e,t.z=this.z*e,this},i.prototype.equals=function(e){return e&&this.x===e.x&&this.y===e.y&&this.z===e.z},i.prototype.equalsWithEpsilon=function(i,r){return void 0===r&&(r=e.Epsilon),i&&t.WithinEpsilon(this.x,i.x,r)&&t.WithinEpsilon(this.y,i.y,r)&&t.WithinEpsilon(this.z,i.z,r)},i.prototype.equalsToFloats=function(e,t,i){return this.x===e&&this.y===t&&this.z===i},i.prototype.multiplyInPlace=function(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this},i.prototype.multiply=function(e){return new i(this.x*e.x,this.y*e.y,this.z*e.z)},i.prototype.multiplyToRef=function(e,t){return t.x=this.x*e.x,t.y=this.y*e.y,t.z=this.z*e.z,this},i.prototype.multiplyByFloats=function(e,t,r){return new i(this.x*e,this.y*t,this.z*r)},i.prototype.divide=function(e){return new i(this.x/e.x,this.y/e.y,this.z/e.z)},i.prototype.divideToRef=function(e,t){return t.x=this.x/e.x,t.y=this.y/e.y,t.z=this.z/e.z,this},i.prototype.MinimizeInPlace=function(e){return e.x<this.x&&(this.x=e.x),e.y<this.y&&(this.y=e.y),e.z<this.z&&(this.z=e.z),this},i.prototype.MaximizeInPlace=function(e){return e.x>this.x&&(this.x=e.x),e.y>this.y&&(this.y=e.y),e.z>this.z&&(this.z=e.z),this},i.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},i.prototype.lengthSquared=function(){return this.x*this.x+this.y*this.y+this.z*this.z},i.prototype.normalize=function(){var e=this.length();if(0===e||1===e)return this;var t=1/e;return this.x*=t,this.y*=t,this.z*=t,this},i.prototype.clone=function(){return new i(this.x,this.y,this.z)},i.prototype.copyFrom=function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this},i.prototype.copyFromFloats=function(e,t,i){return this.x=e,this.y=t,this.z=i,this},i.prototype.set=function(e,t,i){return this.copyFromFloats(e,t,i)},i.GetClipFactor=function(e,t,r,n){var s=i.Dot(e,r)-n;return s/(s-(i.Dot(t,r)-n))},i.FromArray=function(e,t){return t||(t=0),new i(e[t],e[t+1],e[t+2])},i.FromFloatArray=function(e,t){return i.FromArray(e,t)},i.FromArrayToRef=function(e,t,i){i.x=e[t],i.y=e[t+1],i.z=e[t+2]},i.FromFloatArrayToRef=function(e,t,r){return i.FromArrayToRef(e,t,r)},i.FromFloatsToRef=function(e,t,i,r){r.x=e,r.y=t,r.z=i},i.Zero=function(){return new i(0,0,0)},i.Up=function(){return new i(0,1,0)},i.Forward=function(){return new i(0,0,1)},i.Right=function(){return new i(1,0,0)},i.Left=function(){return new i(-1,0,0)},i.TransformCoordinates=function(e,t){var r=i.Zero();return i.TransformCoordinatesToRef(e,t,r),r},i.TransformCoordinatesToRef=function(e,t,i){var r=e.x*t.m[0]+e.y*t.m[4]+e.z*t.m[8]+t.m[12],n=e.x*t.m[1]+e.y*t.m[5]+e.z*t.m[9]+t.m[13],s=e.x*t.m[2]+e.y*t.m[6]+e.z*t.m[10]+t.m[14],o=e.x*t.m[3]+e.y*t.m[7]+e.z*t.m[11]+t.m[15];i.x=r/o,i.y=n/o,i.z=s/o},i.TransformCoordinatesFromFloatsToRef=function(e,t,i,r,n){var s=e*r.m[0]+t*r.m[4]+i*r.m[8]+r.m[12],o=e*r.m[1]+t*r.m[5]+i*r.m[9]+r.m[13],a=e*r.m[2]+t*r.m[6]+i*r.m[10]+r.m[14],h=e*r.m[3]+t*r.m[7]+i*r.m[11]+r.m[15];n.x=s/h,n.y=o/h,n.z=a/h},i.TransformNormal=function(e,t){var r=i.Zero();return i.TransformNormalToRef(e,t,r),r},i.TransformNormalToRef=function(e,t,i){var r=e.x*t.m[0]+e.y*t.m[4]+e.z*t.m[8],n=e.x*t.m[1]+e.y*t.m[5]+e.z*t.m[9],s=e.x*t.m[2]+e.y*t.m[6]+e.z*t.m[10];i.x=r,i.y=n,i.z=s},i.TransformNormalFromFloatsToRef=function(e,t,i,r,n){n.x=e*r.m[0]+t*r.m[4]+i*r.m[8],n.y=e*r.m[1]+t*r.m[5]+i*r.m[9],n.z=e*r.m[2]+t*r.m[6]+i*r.m[10]},i.CatmullRom=function(e,t,r,n,s){var o=s*s,a=s*o;return new i(.5*(2*t.x+(-e.x+r.x)*s+(2*e.x-5*t.x+4*r.x-n.x)*o+(-e.x+3*t.x-3*r.x+n.x)*a),.5*(2*t.y+(-e.y+r.y)*s+(2*e.y-5*t.y+4*r.y-n.y)*o+(-e.y+3*t.y-3*r.y+n.y)*a),.5*(2*t.z+(-e.z+r.z)*s+(2*e.z-5*t.z+4*r.z-n.z)*o+(-e.z+3*t.z-3*r.z+n.z)*a))},i.Clamp=function(e,t,r){var n=e.x;n=n>r.x?r.x:n,n=n<t.x?t.x:n;var s=e.y;s=s>r.y?r.y:s,s=s<t.y?t.y:s;var o=e.z;return o=o>r.z?r.z:o,o=o<t.z?t.z:o,new i(n,s,o)},i.Hermite=function(e,t,r,n,s){var o=s*s,a=s*o,h=2*a-3*o+1,u=-2*a+3*o,c=a-2*o+s,l=a-o;return new i(e.x*h+r.x*u+t.x*c+n.x*l,e.y*h+r.y*u+t.y*c+n.y*l,e.z*h+r.z*u+t.z*c+n.z*l)},i.Lerp=function(e,t,r){var n=new i(0,0,0);return i.LerpToRef(e,t,r,n),n},i.LerpToRef=function(e,t,i,r){r.x=e.x+(t.x-e.x)*i,r.y=e.y+(t.y-e.y)*i,r.z=e.z+(t.z-e.z)*i},i.Dot=function(e,t){return e.x*t.x+e.y*t.y+e.z*t.z},i.Cross=function(e,t){var r=i.Zero();return i.CrossToRef(e,t,r),r},i.CrossToRef=function(e,t,i){O.Vector3[0].x=e.y*t.z-e.z*t.y,O.Vector3[0].y=e.z*t.x-e.x*t.z,O.Vector3[0].z=e.x*t.y-e.y*t.x,i.copyFrom(O.Vector3[0])},i.Normalize=function(e){var t=i.Zero();return i.NormalizeToRef(e,t),t},i.NormalizeToRef=function(e,t){t.copyFrom(e),t.normalize()},i.Project=function(e,t,r,n){var s=n.width,o=n.height,a=n.x,h=n.y,u=i._viewportMatrixCache?i._viewportMatrixCache:i._viewportMatrixCache=new c;c.FromValuesToRef(s/2,0,0,0,0,-o/2,0,0,0,0,.5,0,a+s/2,o/2+h,.5,1,u);var l=i._matrixCache?i._matrixCache:i._matrixCache=new c;return t.multiplyToRef(r,l),l.multiplyToRef(u,l),i.TransformCoordinates(e,l)},i.UnprojectFromTransform=function(e,r,n,s,o){var a=i._matrixCache?i._matrixCache:i._matrixCache=new c;s.multiplyToRef(o,a),a.invert(),e.x=e.x/r*2-1,e.y=-(e.y/n*2-1);var h=i.TransformCoordinates(e,a),u=e.x*a.m[3]+e.y*a.m[7]+e.z*a.m[11]+a.m[15];return t.WithinEpsilon(u,1)&&(h=h.scale(1/u)),h},i.Unproject=function(e,r,n,s,o,a){var h=i._matrixCache?i._matrixCache:i._matrixCache=new c;s.multiplyToRef(o,h),h.multiplyToRef(a,h),h.invert();var u=new i(e.x/r*2-1,-(e.y/n*2-1),2*e.z-1),l=i.TransformCoordinates(u,h),f=u.x*h.m[3]+u.y*h.m[7]+u.z*h.m[11]+h.m[15];return t.WithinEpsilon(f,1)&&(l=l.scale(1/f)),l},i.Minimize=function(e,t){var i=e.clone();return i.MinimizeInPlace(t),i},i.Maximize=function(e,t){var i=e.clone();return i.MaximizeInPlace(t),i},i.Distance=function(e,t){return Math.sqrt(i.DistanceSquared(e,t))},i.DistanceSquared=function(e,t){var i=e.x-t.x,r=e.y-t.y,n=e.z-t.z;return i*i+r*r+n*n},i.Center=function(e,t){var i=e.add(t);return i.scaleInPlace(.5),i},i.RotationFromAxis=function(e,t,r){var n=i.Zero();return i.RotationFromAxisToRef(e,t,r,n),n},i.RotationFromAxisToRef=function(e,t,i,r){var n=O.Quaternion[0];u.RotationQuaternionFromAxisToRef(e,t,i,n),n.toEulerAnglesToRef(r)},i})();e.Vector3=o;var a=(function(){function i(e,t,i,r){this.x=e,this.y=t,this.z=i,this.w=r}return i.prototype.toString=function(){return"{X: "+this.x+" Y:"+this.y+" Z:"+this.z+" W:"+this.w+"}"},i.prototype.getClassName=function(){return"Vector4"},i.prototype.getHashCode=function(){var e=this.x||0;return e=397*e^(this.y||0),e=397*e^(this.z||0),e=397*e^(this.w||0)},i.prototype.asArray=function(){var e=[];return this.toArray(e,0),e},i.prototype.toArray=function(e,t){return void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,this},i.prototype.addInPlace=function(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this},i.prototype.add=function(e){return new i(this.x+e.x,this.y+e.y,this.z+e.z,this.w+e.w)},i.prototype.addToRef=function(e,t){return t.x=this.x+e.x,t.y=this.y+e.y,t.z=this.z+e.z,t.w=this.w+e.w,this},i.prototype.subtractInPlace=function(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this},i.prototype.subtract=function(e){return new i(this.x-e.x,this.y-e.y,this.z-e.z,this.w-e.w)},i.prototype.subtractToRef=function(e,t){return t.x=this.x-e.x,t.y=this.y-e.y,t.z=this.z-e.z,t.w=this.w-e.w,this},i.prototype.subtractFromFloats=function(e,t,r,n){return new i(this.x-e,this.y-t,this.z-r,this.w-n)},i.prototype.subtractFromFloatsToRef=function(e,t,i,r,n){return n.x=this.x-e,n.y=this.y-t,n.z=this.z-i,n.w=this.w-r,this},i.prototype.negate=function(){return new i(-this.x,-this.y,-this.z,-this.w)},i.prototype.scaleInPlace=function(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this},i.prototype.scale=function(e){return new i(this.x*e,this.y*e,this.z*e,this.w*e)},i.prototype.scaleToRef=function(e,t){return t.x=this.x*e,t.y=this.y*e,t.z=this.z*e,t.w=this.w*e,this},i.prototype.equals=function(e){return e&&this.x===e.x&&this.y===e.y&&this.z===e.z&&this.w===e.w},i.prototype.equalsWithEpsilon=function(i,r){return void 0===r&&(r=e.Epsilon),i&&t.WithinEpsilon(this.x,i.x,r)&&t.WithinEpsilon(this.y,i.y,r)&&t.WithinEpsilon(this.z,i.z,r)&&t.WithinEpsilon(this.w,i.w,r)},i.prototype.equalsToFloats=function(e,t,i,r){return this.x===e&&this.y===t&&this.z===i&&this.w===r},i.prototype.multiplyInPlace=function(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this},i.prototype.multiply=function(e){return new i(this.x*e.x,this.y*e.y,this.z*e.z,this.w*e.w)},i.prototype.multiplyToRef=function(e,t){return t.x=this.x*e.x,t.y=this.y*e.y,t.z=this.z*e.z,t.w=this.w*e.w,this},i.prototype.multiplyByFloats=function(e,t,r,n){return new i(this.x*e,this.y*t,this.z*r,this.w*n)},i.prototype.divide=function(e){return new i(this.x/e.x,this.y/e.y,this.z/e.z,this.w/e.w)},i.prototype.divideToRef=function(e,t){return t.x=this.x/e.x,t.y=this.y/e.y,t.z=this.z/e.z,t.w=this.w/e.w,this},i.prototype.MinimizeInPlace=function(e){return e.x<this.x&&(this.x=e.x),e.y<this.y&&(this.y=e.y),e.z<this.z&&(this.z=e.z),e.w<this.w&&(this.w=e.w),this},i.prototype.MaximizeInPlace=function(e){return e.x>this.x&&(this.x=e.x),e.y>this.y&&(this.y=e.y),e.z>this.z&&(this.z=e.z),e.w>this.w&&(this.w=e.w),this},i.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},i.prototype.lengthSquared=function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},i.prototype.normalize=function(){var e=this.length();if(0===e)return this;var t=1/e;return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this},i.prototype.toVector3=function(){return new o(this.x,this.y,this.z)},i.prototype.clone=function(){return new i(this.x,this.y,this.z,this.w)},i.prototype.copyFrom=function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w,this},i.prototype.copyFromFloats=function(e,t,i,r){return this.x=e,this.y=t,this.z=i,this.w=r,this},i.prototype.set=function(e,t,i,r){return this.copyFromFloats(e,t,i,r)},i.FromArray=function(e,t){return t||(t=0),new i(e[t],e[t+1],e[t+2],e[t+3])},i.FromArrayToRef=function(e,t,i){i.x=e[t],i.y=e[t+1],i.z=e[t+2],i.w=e[t+3]},i.FromFloatArrayToRef=function(e,t,r){i.FromArrayToRef(e,t,r)},i.FromFloatsToRef=function(e,t,i,r,n){n.x=e,n.y=t,n.z=i,n.w=r},i.Zero=function(){return new i(0,0,0,0)},i.Normalize=function(e){var t=i.Zero();return i.NormalizeToRef(e,t),t},i.NormalizeToRef=function(e,t){t.copyFrom(e),t.normalize()},i.Minimize=function(e,t){var i=e.clone();return i.MinimizeInPlace(t),i},i.Maximize=function(e,t){var i=e.clone();return i.MaximizeInPlace(t),i},i.Distance=function(e,t){return Math.sqrt(i.DistanceSquared(e,t))},i.DistanceSquared=function(e,t){var i=e.x-t.x,r=e.y-t.y,n=e.z-t.z,s=e.w-t.w;return i*i+r*r+n*n+s*s},i.Center=function(e,t){var i=e.add(t);return i.scaleInPlace(.5),i},i.TransformNormal=function(e,t){var r=i.Zero();return i.TransformNormalToRef(e,t,r),r},i.TransformNormalToRef=function(e,t,i){var r=e.x*t.m[0]+e.y*t.m[4]+e.z*t.m[8],n=e.x*t.m[1]+e.y*t.m[5]+e.z*t.m[9],s=e.x*t.m[2]+e.y*t.m[6]+e.z*t.m[10];i.x=r,i.y=n,i.z=s,i.w=e.w},i.TransformNormalFromFloatsToRef=function(e,t,i,r,n,s){s.x=e*n.m[0]+t*n.m[4]+i*n.m[8],s.y=e*n.m[1]+t*n.m[5]+i*n.m[9],s.z=e*n.m[2]+t*n.m[6]+i*n.m[10],s.w=r},i})();e.Vector4=a;var h=(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,i){return new e(this.width*t,this.height*i)},e.prototype.clone=function(){return new e(this.width,this.height)},e.prototype.equals=function(e){return!!e&&(this.width===e.width&&this.height===e.height)},Object.defineProperty(e.prototype,"surface",{get:function(){return this.width*this.height},enumerable:!0,configurable:!0}),e.Zero=function(){return new e(0,0)},e.prototype.add=function(t){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,i,r){return new e(t.width+(i.width-t.width)*r,t.height+(i.height-t.height)*r)},e})();e.Size=h;var u=(function(){function t(e,t,i,r){void 0===e&&(e=0),void 0===t&&(t=0),void 0===i&&(i=0),void 0===r&&(r=1),this.x=e,this.y=t,this.z=i,this.w=r}return 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,i,r){return this.x=e,this.y=t,this.z=i,this.w=r,this},t.prototype.set=function(e,t,i,r){return this.copyFromFloats(e,t,i,r)},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 i=new t(0,0,0,1);return this.multiplyToRef(e,i),i},t.prototype.multiplyToRef=function(e,t){var i=this.x*e.w+this.y*e.z-this.z*e.y+this.w*e.x,r=-this.x*e.z+this.y*e.w+this.z*e.x+this.w*e.y,n=this.x*e.y-this.y*e.x+this.z*e.w+this.w*e.z,s=-this.x*e.x-this.y*e.y-this.z*e.z+this.w*e.w;return t.copyFromFloats(i,r,n,s),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=o.Zero();return this.toEulerAnglesToRef(t,e),t},t.prototype.toEulerAnglesToRef=function(e,t){void 0===t&&(t="YZX");var i=this.z,r=this.x,n=this.y,s=this.w,o=s*s,a=i*i,h=r*r,u=n*n,c=n*i-r*s;return c<-.4999999?(e.y=2*Math.atan2(n,s),e.x=Math.PI/2,e.z=0):c>.4999999?(e.y=2*Math.atan2(n,s),e.x=-Math.PI/2,e.z=0):(e.z=Math.atan2(2*(r*n+i*s),-a-h+u+o),e.x=Math.asin(-2*(i*n-r*s)),e.y=Math.atan2(2*(i*r+n*s),a-h-u+o)),this},t.prototype.toRotationMatrix=function(e){var t=this.x*this.x,i=this.y*this.y,r=this.z*this.z,n=this.x*this.y,s=this.z*this.w,o=this.z*this.x,a=this.y*this.w,h=this.y*this.z,u=this.x*this.w;return e.m[0]=1-2*(i+r),e.m[1]=2*(n+s),e.m[2]=2*(o-a),e.m[3]=0,e.m[4]=2*(n-s),e.m[5]=1-2*(r+t),e.m[6]=2*(h+u),e.m[7]=0,e.m[8]=2*(o+a),e.m[9]=2*(h-u),e.m[10]=1-2*(i+t),e.m[11]=0,e.m[12]=0,e.m[13]=0,e.m[14]=0,e.m[15]=1,e._markAsUpdated(),this},t.prototype.fromRotationMatrix=function(e){return t.FromRotationMatrixToRef(e,this),this},t.FromRotationMatrix=function(e){var i=new t;return t.FromRotationMatrixToRef(e,i),i},t.FromRotationMatrixToRef=function(e,t){var i,r=e.m,n=r[0],s=r[4],o=r[8],a=r[1],h=r[5],u=r[9],c=r[2],l=r[6],f=r[10],d=n+h+f;d>0?(i=.5/Math.sqrt(d+1),t.w=.25/i,t.x=(l-u)*i,t.y=(o-c)*i,t.z=(a-s)*i):n>h&&n>f?(i=2*Math.sqrt(1+n-h-f),t.w=(l-u)/i,t.x=.25*i,t.y=(s+a)/i,t.z=(o+c)/i):h>f?(i=2*Math.sqrt(1+h-n-f),t.w=(o-c)/i,t.x=(s+a)/i,t.y=.25*i,t.z=(u+l)/i):(i=2*Math.sqrt(1+f-n-h),t.w=(a-s)/i,t.x=(o+c)/i,t.y=(u+l)/i,t.z=.25*i)},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,i){return t.RotationAxisToRef(e,i,new t)},t.RotationAxisToRef=function(e,t,i){var r=Math.sin(t/2);return e.normalize(),i.w=Math.cos(t/2),i.x=e.x*r,i.y=e.y*r,i.z=e.z*r,i},t.FromArray=function(e,i){return i||(i=0),new t(e[i],e[i+1],e[i+2],e[i+3])},t.RotationYawPitchRoll=function(e,i,r){var n=new t;return t.RotationYawPitchRollToRef(e,i,r,n),n},t.RotationYawPitchRollToRef=function(e,t,i,r){var n=.5*i,s=.5*t,o=.5*e,a=Math.sin(n),h=Math.cos(n),u=Math.sin(s),c=Math.cos(s),l=Math.sin(o),f=Math.cos(o);r.x=f*u*h+l*c*a,r.y=l*c*h-f*u*a,r.z=f*c*a-l*u*h,r.w=f*c*h+l*u*a},t.RotationAlphaBetaGamma=function(e,i,r){var n=new t;return t.RotationAlphaBetaGammaToRef(e,i,r,n),n},t.RotationAlphaBetaGammaToRef=function(e,t,i,r){var n=.5*(i+e),s=.5*(i-e),o=.5*t;r.x=Math.cos(s)*Math.sin(o),r.y=Math.sin(s)*Math.sin(o),r.z=Math.sin(n)*Math.cos(o),r.w=Math.cos(n)*Math.cos(o)},t.RotationQuaternionFromAxis=function(e,i,r,n){var s=new t(0,0,0,0);return t.RotationQuaternionFromAxisToRef(e,i,r,s),s},t.RotationQuaternionFromAxisToRef=function(t,i,r,n){var s=O.Matrix[0];e.Matrix.FromXYZAxesToRef(t.normalize(),i.normalize(),r.normalize(),s),e.Quaternion.FromRotationMatrixToRef(s,n)},t.Slerp=function(e,i,r){var n=t.Identity();return t.SlerpToRef(e,i,r,n),n},t.SlerpToRef=function(e,t,i,r){var n,s,o=i,a=e.x*t.x+e.y*t.y+e.z*t.z+e.w*t.w,h=!1;if(a<0&&(h=!0,a=-a),a>.999999)s=1-o,n=h?-o:o;else{var u=Math.acos(a),c=1/Math.sin(u);s=Math.sin((1-o)*u)*c,n=h?-Math.sin(o*u)*c:Math.sin(o*u)*c}r.x=s*e.x+n*t.x,r.y=s*e.y+n*t.y,r.z=s*e.z+n*t.z,r.w=s*e.w+n*t.w},t.Hermite=function(e,i,r,n,s){var o=s*s,a=s*o,h=2*a-3*o+1,u=-2*a+3*o,c=a-2*o+s,l=a-o;return new t(e.x*h+r.x*u+i.x*c+n.x*l,e.y*h+r.y*u+i.y*c+n.y*l,e.z*h+r.z*u+i.z*c+n.z*l,e.w*h+r.w*u+i.w*c+n.w*l)},t})();e.Quaternion=u;var c=(function(){function i(){this.m=new Float32Array(16),this._markAsUpdated()}return i.prototype._markAsUpdated=function(){this.updateFlag=i._updateFlagSeed++},i.prototype.isIdentity=function(){return 1===this.m[0]&&1===this.m[5]&&1===this.m[10]&&1===this.m[15]&&(0===this.m[1]&&0===this.m[2]&&0===this.m[3]&&0===this.m[4]&&0===this.m[6]&&0===this.m[7]&&0===this.m[8]&&0===this.m[9]&&0===this.m[11]&&0===this.m[12]&&0===this.m[13]&&0===this.m[14])},i.prototype.determinant=function(){var e=this.m[10]*this.m[15]-this.m[11]*this.m[14],t=this.m[9]*this.m[15]-this.m[11]*this.m[13],i=this.m[9]*this.m[14]-this.m[10]*this.m[13],r=this.m[8]*this.m[15]-this.m[11]*this.m[12],n=this.m[8]*this.m[14]-this.m[10]*this.m[12],s=this.m[8]*this.m[13]-this.m[9]*this.m[12]
  2. ;return this.m[0]*(this.m[5]*e-this.m[6]*t+this.m[7]*i)-this.m[1]*(this.m[4]*e-this.m[6]*r+this.m[7]*n)+this.m[2]*(this.m[4]*t-this.m[5]*r+this.m[7]*s)-this.m[3]*(this.m[4]*i-this.m[5]*n+this.m[6]*s)},i.prototype.toArray=function(){return this.m},i.prototype.asArray=function(){return this.toArray()},i.prototype.invert=function(){return this.invertToRef(this),this},i.prototype.reset=function(){for(var e=0;e<16;e++)this.m[e]=0;return this._markAsUpdated(),this},i.prototype.add=function(e){var t=new i;return this.addToRef(e,t),t},i.prototype.addToRef=function(e,t){for(var i=0;i<16;i++)t.m[i]=this.m[i]+e.m[i];return t._markAsUpdated(),this},i.prototype.addToSelf=function(e){for(var t=0;t<16;t++)this.m[t]+=e.m[t];return this._markAsUpdated(),this},i.prototype.invertToRef=function(e){var t=this.m[0],i=this.m[1],r=this.m[2],n=this.m[3],s=this.m[4],o=this.m[5],a=this.m[6],h=this.m[7],u=this.m[8],c=this.m[9],l=this.m[10],f=this.m[11],d=this.m[12],p=this.m[13],_=this.m[14],m=this.m[15],g=l*m-f*_,y=c*m-f*p,v=c*_-l*p,b=u*m-f*d,x=u*_-l*d,T=u*p-c*d,E=o*g-a*y+h*v,A=-(s*g-a*b+h*x),M=s*y-o*b+h*T,P=-(s*v-o*x+a*T),O=1/(t*E+i*A+r*M+n*P),R=a*m-h*_,C=o*m-h*p,S=o*_-a*p,I=s*m-h*d,D=s*_-a*d,L=s*p-o*d,F=a*f-h*l,B=o*f-h*c,w=o*l-a*c,N=s*f-h*u,V=s*l-a*u,U=s*c-o*u;return e.m[0]=E*O,e.m[4]=A*O,e.m[8]=M*O,e.m[12]=P*O,e.m[1]=-(i*g-r*y+n*v)*O,e.m[5]=(t*g-r*b+n*x)*O,e.m[9]=-(t*y-i*b+n*T)*O,e.m[13]=(t*v-i*x+r*T)*O,e.m[2]=(i*R-r*C+n*S)*O,e.m[6]=-(t*R-r*I+n*D)*O,e.m[10]=(t*C-i*I+n*L)*O,e.m[14]=-(t*S-i*D+r*L)*O,e.m[3]=-(i*F-r*B+n*w)*O,e.m[7]=(t*F-r*N+n*V)*O,e.m[11]=-(t*B-i*N+n*U)*O,e.m[15]=(t*w-i*V+r*U)*O,e._markAsUpdated(),this},i.prototype.setTranslationFromFloats=function(e,t,i){return this.m[12]=e,this.m[13]=t,this.m[14]=i,this._markAsUpdated(),this},i.prototype.setTranslation=function(e){return this.m[12]=e.x,this.m[13]=e.y,this.m[14]=e.z,this._markAsUpdated(),this},i.prototype.getTranslation=function(){return new o(this.m[12],this.m[13],this.m[14])},i.prototype.getTranslationToRef=function(e){return e.x=this.m[12],e.y=this.m[13],e.z=this.m[14],this},i.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},i.prototype.multiply=function(e){var t=new i;return this.multiplyToRef(e,t),t},i.prototype.copyFrom=function(e){for(var t=0;t<16;t++)this.m[t]=e.m[t];return this._markAsUpdated(),this},i.prototype.copyToArray=function(e,t){void 0===t&&(t=0);for(var i=0;i<16;i++)e[t+i]=this.m[i];return this},i.prototype.multiplyToRef=function(e,t){return this.multiplyToArray(e,t.m,0),t._markAsUpdated(),this},i.prototype.multiplyToArray=function(e,t,i){var r=this.m[0],n=this.m[1],s=this.m[2],o=this.m[3],a=this.m[4],h=this.m[5],u=this.m[6],c=this.m[7],l=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],y=this.m[15],v=e.m[0],b=e.m[1],x=e.m[2],T=e.m[3],E=e.m[4],A=e.m[5],M=e.m[6],P=e.m[7],O=e.m[8],R=e.m[9],C=e.m[10],S=e.m[11],I=e.m[12],D=e.m[13],L=e.m[14],F=e.m[15];return t[i]=r*v+n*E+s*O+o*I,t[i+1]=r*b+n*A+s*R+o*D,t[i+2]=r*x+n*M+s*C+o*L,t[i+3]=r*T+n*P+s*S+o*F,t[i+4]=a*v+h*E+u*O+c*I,t[i+5]=a*b+h*A+u*R+c*D,t[i+6]=a*x+h*M+u*C+c*L,t[i+7]=a*T+h*P+u*S+c*F,t[i+8]=l*v+f*E+d*O+p*I,t[i+9]=l*b+f*A+d*R+p*D,t[i+10]=l*x+f*M+d*C+p*L,t[i+11]=l*T+f*P+d*S+p*F,t[i+12]=_*v+m*E+g*O+y*I,t[i+13]=_*b+m*A+g*R+y*D,t[i+14]=_*x+m*M+g*C+y*L,t[i+15]=_*T+m*P+g*S+y*F,this},i.prototype.equals=function(e){return e&&this.m[0]===e.m[0]&&this.m[1]===e.m[1]&&this.m[2]===e.m[2]&&this.m[3]===e.m[3]&&this.m[4]===e.m[4]&&this.m[5]===e.m[5]&&this.m[6]===e.m[6]&&this.m[7]===e.m[7]&&this.m[8]===e.m[8]&&this.m[9]===e.m[9]&&this.m[10]===e.m[10]&&this.m[11]===e.m[11]&&this.m[12]===e.m[12]&&this.m[13]===e.m[13]&&this.m[14]===e.m[14]&&this.m[15]===e.m[15]},i.prototype.clone=function(){return i.FromValues(this.m[0],this.m[1],this.m[2],this.m[3],this.m[4],this.m[5],this.m[6],this.m[7],this.m[8],this.m[9],this.m[10],this.m[11],this.m[12],this.m[13],this.m[14],this.m[15])},i.prototype.getClassName=function(){return"Matrix"},i.prototype.getHashCode=function(){for(var e=this.m[0]||0,t=1;t<16;t++)e=397*e^(this.m[t]||0);return e},i.prototype.decompose=function(e,r,n){n.x=this.m[12],n.y=this.m[13],n.z=this.m[14];var s=t.Sign(this.m[0]*this.m[1]*this.m[2]*this.m[3])<0?-1:1,o=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=s*Math.sqrt(this.m[0]*this.m[0]+this.m[1]*this.m[1]+this.m[2]*this.m[2]),e.y=o*Math.sqrt(this.m[4]*this.m[4]+this.m[5]*this.m[5]+this.m[6]*this.m[6]),e.z=a*Math.sqrt(this.m[8]*this.m[8]+this.m[9]*this.m[9]+this.m[10]*this.m[10]),0===e.x||0===e.y||0===e.z?(r.x=0,r.y=0,r.z=0,r.w=1,!1):(i.FromValuesToRef(this.m[0]/e.x,this.m[1]/e.x,this.m[2]/e.x,0,this.m[4]/e.y,this.m[5]/e.y,this.m[6]/e.y,0,this.m[8]/e.z,this.m[9]/e.z,this.m[10]/e.z,0,0,0,0,1,O.Matrix[0]),u.FromRotationMatrixToRef(O.Matrix[0],r),!0)},i.prototype.getRotationMatrix=function(){var e=i.Identity();return this.getRotationMatrixToRef(e),e},i.prototype.getRotationMatrixToRef=function(e){var t=this.m,r=t[0]*t[1]*t[2]*t[3]<0?-1:1,n=t[4]*t[5]*t[6]*t[7]<0?-1:1,s=t[8]*t[9]*t[10]*t[11]<0?-1:1,o=r*Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]),a=n*Math.sqrt(t[4]*t[4]+t[5]*t[5]+t[6]*t[6]),h=s*Math.sqrt(t[8]*t[8]+t[9]*t[9]+t[10]*t[10]);return i.FromValuesToRef(t[0]/o,t[1]/o,t[2]/o,0,t[4]/a,t[5]/a,t[6]/a,0,t[8]/h,t[9]/h,t[10]/h,0,0,0,0,1,e),this},i.FromArray=function(e,t){var r=new i;return t||(t=0),i.FromArrayToRef(e,t,r),r},i.FromArrayToRef=function(e,t,i){for(var r=0;r<16;r++)i.m[r]=e[r+t];i._markAsUpdated()},i.FromFloat32ArrayToRefScaled=function(e,t,i,r){for(var n=0;n<16;n++)r.m[n]=e[n+t]*i;r._markAsUpdated()},i.FromValuesToRef=function(e,t,i,r,n,s,o,a,h,u,c,l,f,d,p,_,m){m.m[0]=e,m.m[1]=t,m.m[2]=i,m.m[3]=r,m.m[4]=n,m.m[5]=s,m.m[6]=o,m.m[7]=a,m.m[8]=h,m.m[9]=u,m.m[10]=c,m.m[11]=l,m.m[12]=f,m.m[13]=d,m.m[14]=p,m.m[15]=_,m._markAsUpdated()},i.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])},i.prototype.setRow=function(e,t){if(e<0||e>3)return this;var i=4*e;return this.m[i+0]=t.x,this.m[i+1]=t.y,this.m[i+2]=t.z,this.m[i+3]=t.w,this._markAsUpdated(),this},i.prototype.setRowFromFloats=function(e,t,i,r,n){if(e<0||e>3)return this;var s=4*e;return this.m[s+0]=t,this.m[s+1]=i,this.m[s+2]=r,this.m[s+3]=n,this._markAsUpdated(),this},i.FromValues=function(e,t,r,n,s,o,a,h,u,c,l,f,d,p,_,m){var g=new i;return g.m[0]=e,g.m[1]=t,g.m[2]=r,g.m[3]=n,g.m[4]=s,g.m[5]=o,g.m[6]=a,g.m[7]=h,g.m[8]=u,g.m[9]=c,g.m[10]=l,g.m[11]=f,g.m[12]=d,g.m[13]=p,g.m[14]=_,g.m[15]=m,g},i.Compose=function(e,t,r){var n=i.Identity();return i.ComposeToRef(e,t,r,n),n},i.ComposeToRef=function(e,t,r,n){i.FromValuesToRef(e.x,0,0,0,0,e.y,0,0,0,0,e.z,0,0,0,0,1,O.Matrix[1]),t.toRotationMatrix(O.Matrix[0]),O.Matrix[1].multiplyToRef(O.Matrix[0],n),n.setTranslation(r)},i.Identity=function(){return i.FromValues(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1)},i.IdentityToRef=function(e){i.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,e)},i.Zero=function(){return i.FromValues(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)},i.RotationX=function(e){var t=new i;return i.RotationXToRef(e,t),t},i.Invert=function(e){var t=new i;return e.invertToRef(t),t},i.RotationXToRef=function(e,t){var i=Math.sin(e),r=Math.cos(e);t.m[0]=1,t.m[15]=1,t.m[5]=r,t.m[10]=r,t.m[9]=-i,t.m[6]=i,t.m[1]=0,t.m[2]=0,t.m[3]=0,t.m[4]=0,t.m[7]=0,t.m[8]=0,t.m[11]=0,t.m[12]=0,t.m[13]=0,t.m[14]=0,t._markAsUpdated()},i.RotationY=function(e){var t=new i;return i.RotationYToRef(e,t),t},i.RotationYToRef=function(e,t){var i=Math.sin(e),r=Math.cos(e);t.m[5]=1,t.m[15]=1,t.m[0]=r,t.m[2]=-i,t.m[8]=i,t.m[10]=r,t.m[1]=0,t.m[3]=0,t.m[4]=0,t.m[6]=0,t.m[7]=0,t.m[9]=0,t.m[11]=0,t.m[12]=0,t.m[13]=0,t.m[14]=0,t._markAsUpdated()},i.RotationZ=function(e){var t=new i;return i.RotationZToRef(e,t),t},i.RotationZToRef=function(e,t){var i=Math.sin(e),r=Math.cos(e);t.m[10]=1,t.m[15]=1,t.m[0]=r,t.m[1]=i,t.m[4]=-i,t.m[5]=r,t.m[2]=0,t.m[3]=0,t.m[6]=0,t.m[7]=0,t.m[8]=0,t.m[9]=0,t.m[11]=0,t.m[12]=0,t.m[13]=0,t.m[14]=0,t._markAsUpdated()},i.RotationAxis=function(e,t){var r=i.Zero();return i.RotationAxisToRef(e,t,r),r},i.RotationAxisToRef=function(e,t,i){var r=Math.sin(-t),n=Math.cos(-t),s=1-n;e.normalize(),i.m[0]=e.x*e.x*s+n,i.m[1]=e.x*e.y*s-e.z*r,i.m[2]=e.x*e.z*s+e.y*r,i.m[3]=0,i.m[4]=e.y*e.x*s+e.z*r,i.m[5]=e.y*e.y*s+n,i.m[6]=e.y*e.z*s-e.x*r,i.m[7]=0,i.m[8]=e.z*e.x*s-e.y*r,i.m[9]=e.z*e.y*s+e.x*r,i.m[10]=e.z*e.z*s+n,i.m[11]=0,i.m[15]=1,i._markAsUpdated()},i.RotationYawPitchRoll=function(e,t,r){var n=new i;return i.RotationYawPitchRollToRef(e,t,r,n),n},i.RotationYawPitchRollToRef=function(e,t,i,r){u.RotationYawPitchRollToRef(e,t,i,this._tempQuaternion),this._tempQuaternion.toRotationMatrix(r)},i.Scaling=function(e,t,r){var n=i.Zero();return i.ScalingToRef(e,t,r,n),n},i.ScalingToRef=function(e,t,i,r){r.m[0]=e,r.m[1]=0,r.m[2]=0,r.m[3]=0,r.m[4]=0,r.m[5]=t,r.m[6]=0,r.m[7]=0,r.m[8]=0,r.m[9]=0,r.m[10]=i,r.m[11]=0,r.m[12]=0,r.m[13]=0,r.m[14]=0,r.m[15]=1,r._markAsUpdated()},i.Translation=function(e,t,r){var n=i.Identity();return i.TranslationToRef(e,t,r,n),n},i.TranslationToRef=function(e,t,r,n){i.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,e,t,r,1,n)},i.Lerp=function(e,t,r){for(var n=i.Zero(),s=0;s<16;s++)n.m[s]=e.m[s]*(1-r)+t.m[s]*r;return n._markAsUpdated(),n},i.DecomposeLerp=function(e,t,r){var n=new o(0,0,0),s=new u,a=new o(0,0,0);e.decompose(n,s,a);var h=new o(0,0,0),c=new u,l=new o(0,0,0);t.decompose(h,c,l);var f=o.Lerp(n,h,r),d=u.Slerp(s,c,r),p=o.Lerp(a,l,r);return i.Compose(f,d,p)},i.LookAtLH=function(e,t,r){var n=i.Zero();return i.LookAtLHToRef(e,t,r,n),n},i.LookAtLHToRef=function(e,t,r,n){t.subtractToRef(e,this._zAxis),this._zAxis.normalize(),o.CrossToRef(r,this._zAxis,this._xAxis),0===this._xAxis.lengthSquared()?this._xAxis.x=1:this._xAxis.normalize(),o.CrossToRef(this._zAxis,this._xAxis,this._yAxis),this._yAxis.normalize();var s=-o.Dot(this._xAxis,e),a=-o.Dot(this._yAxis,e),h=-o.Dot(this._zAxis,e);return i.FromValuesToRef(this._xAxis.x,this._yAxis.x,this._zAxis.x,0,this._xAxis.y,this._yAxis.y,this._zAxis.y,0,this._xAxis.z,this._yAxis.z,this._zAxis.z,0,s,a,h,1,n)},i.LookAtRH=function(e,t,r){var n=i.Zero();return i.LookAtRHToRef(e,t,r,n),n},i.LookAtRHToRef=function(e,t,r,n){e.subtractToRef(t,this._zAxis),this._zAxis.normalize(),o.CrossToRef(r,this._zAxis,this._xAxis),0===this._xAxis.lengthSquared()?this._xAxis.x=1:this._xAxis.normalize(),o.CrossToRef(this._zAxis,this._xAxis,this._yAxis),this._yAxis.normalize();var s=-o.Dot(this._xAxis,e),a=-o.Dot(this._yAxis,e),h=-o.Dot(this._zAxis,e);return i.FromValuesToRef(this._xAxis.x,this._yAxis.x,this._zAxis.x,0,this._xAxis.y,this._yAxis.y,this._zAxis.y,0,this._xAxis.z,this._yAxis.z,this._zAxis.z,0,s,a,h,1,n)},i.OrthoLH=function(e,t,r,n){var s=i.Zero();return i.OrthoLHToRef(e,t,r,n,s),s},i.OrthoLHToRef=function(t,i,r,n,s){var o=r,a=n,h=2/t,u=2/i,c=2/(a-o),l=-(a+o)/(a-o);e.Matrix.FromValuesToRef(h,0,0,0,0,u,0,0,0,0,c,0,0,0,l,1,s)},i.OrthoOffCenterLH=function(e,t,r,n,s,o){var a=i.Zero();return i.OrthoOffCenterLHToRef(e,t,r,n,s,o,a),a},i.OrthoOffCenterLHToRef=function(t,i,r,n,s,o,a){var h=s,u=o,c=2/(i-t),l=2/(n-r),f=2/(u-h),d=-(u+h)/(u-h),p=(t+i)/(t-i),_=(n+r)/(r-n);e.Matrix.FromValuesToRef(c,0,0,0,0,l,0,0,0,0,f,0,p,_,d,1,a)},i.OrthoOffCenterRH=function(e,t,r,n,s,o){var a=i.Zero();return i.OrthoOffCenterRHToRef(e,t,r,n,s,o,a),a},i.OrthoOffCenterRHToRef=function(e,t,r,n,s,o,a){i.OrthoOffCenterLHToRef(e,t,r,n,s,o,a),a.m[10]*=-1},i.PerspectiveLH=function(t,r,n,s){var o=i.Zero(),a=n,h=s,u=2*a/t,c=2*a/r,l=(h+a)/(h-a),f=-2*h*a/(h-a);return e.Matrix.FromValuesToRef(u,0,0,0,0,c,0,0,0,0,l,1,0,0,f,0,o),o},i.PerspectiveFovLH=function(e,t,r,n){var s=i.Zero();return i.PerspectiveFovLHToRef(e,t,r,n,s),s},i.PerspectiveFovLHToRef=function(t,i,r,n,s,o){void 0===o&&(o=!0);var a=r,h=n,u=1/Math.tan(.5*t),c=o?u/i:u,l=o?u:u*i,f=(h+a)/(h-a),d=-2*h*a/(h-a);e.Matrix.FromValuesToRef(c,0,0,0,0,l,0,0,0,0,f,1,0,0,d,0,s)},i.PerspectiveFovRH=function(e,t,r,n){var s=i.Zero();return i.PerspectiveFovRHToRef(e,t,r,n,s),s},i.PerspectiveFovRHToRef=function(t,i,r,n,s,o){void 0===o&&(o=!0);var a=r,h=n,u=1/Math.tan(.5*t),c=o?u/i:u,l=o?u:u*i,f=-(h+a)/(h-a),d=-2*h*a/(h-a);e.Matrix.FromValuesToRef(c,0,0,0,0,l,0,0,0,0,f,-1,0,0,d,0,s)},i.PerspectiveFovWebVRToRef=function(e,t,i,r,n){void 0===n&&(n=!1);var s=n?-1:1,o=Math.tan(e.upDegrees*Math.PI/180),a=Math.tan(e.downDegrees*Math.PI/180),h=Math.tan(e.leftDegrees*Math.PI/180),u=Math.tan(e.rightDegrees*Math.PI/180),c=2/(h+u),l=2/(o+a);r.m[0]=c,r.m[1]=r.m[2]=r.m[3]=r.m[4]=0,r.m[5]=l,r.m[6]=r.m[7]=0,r.m[8]=(h-u)*c*.5,r.m[9]=-(o-a)*l*.5,r.m[10]=-i/(t-i),r.m[11]=1*s,r.m[12]=r.m[13]=r.m[15]=0,r.m[14]=-2*i*t/(i-t),r._markAsUpdated()},i.GetFinalMatrix=function(e,t,r,n,s,o){var a=e.width,h=e.height,u=e.x,c=e.y,l=i.FromValues(a/2,0,0,0,0,-h/2,0,0,0,0,o-s,0,u+a/2,h/2+c,s,1);return t.multiply(r).multiply(n).multiply(l)},i.GetAsMatrix2x2=function(e){return new Float32Array([e.m[0],e.m[1],e.m[4],e.m[5]])},i.GetAsMatrix3x3=function(e){return new Float32Array([e.m[0],e.m[1],e.m[2],e.m[4],e.m[5],e.m[6],e.m[8],e.m[9],e.m[10]])},i.Transpose=function(e){var t=new i;return t.m[0]=e.m[0],t.m[1]=e.m[4],t.m[2]=e.m[8],t.m[3]=e.m[12],t.m[4]=e.m[1],t.m[5]=e.m[5],t.m[6]=e.m[9],t.m[7]=e.m[13],t.m[8]=e.m[2],t.m[9]=e.m[6],t.m[10]=e.m[10],t.m[11]=e.m[14],t.m[12]=e.m[3],t.m[13]=e.m[7],t.m[14]=e.m[11],t.m[15]=e.m[15],t},i.Reflection=function(e){var t=new i;return i.ReflectionToRef(e,t),t},i.ReflectionToRef=function(e,t){e.normalize();var i=e.normal.x,r=e.normal.y,n=e.normal.z,s=-2*i,o=-2*r,a=-2*n;t.m[0]=s*i+1,t.m[1]=o*i,t.m[2]=a*i,t.m[3]=0,t.m[4]=s*r,t.m[5]=o*r+1,t.m[6]=a*r,t.m[7]=0,t.m[8]=s*n,t.m[9]=o*n,t.m[10]=a*n+1,t.m[11]=0,t.m[12]=s*e.d,t.m[13]=o*e.d,t.m[14]=a*e.d,t.m[15]=1,t._markAsUpdated()},i.FromXYZAxesToRef=function(e,t,i,r){r.m[0]=e.x,r.m[1]=e.y,r.m[2]=e.z,r.m[3]=0,r.m[4]=t.x,r.m[5]=t.y,r.m[6]=t.z,r.m[7]=0,r.m[8]=i.x,r.m[9]=i.y,r.m[10]=i.z,r.m[11]=0,r.m[12]=0,r.m[13]=0,r.m[14]=0,r.m[15]=1,r._markAsUpdated()},i.FromQuaternionToRef=function(e,t){var i=e.x*e.x,r=e.y*e.y,n=e.z*e.z,s=e.x*e.y,o=e.z*e.w,a=e.z*e.x,h=e.y*e.w,u=e.y*e.z,c=e.x*e.w;t.m[0]=1-2*(r+n),t.m[1]=2*(s+o),t.m[2]=2*(a-h),t.m[3]=0,t.m[4]=2*(s-o),t.m[5]=1-2*(n+i),t.m[6]=2*(u+c),t.m[7]=0,t.m[8]=2*(a+h),t.m[9]=2*(u-c),t.m[10]=1-2*(r+i),t.m[11]=0,t.m[12]=0,t.m[13]=0,t.m[14]=0,t.m[15]=1,t._markAsUpdated()},i})();c._tempQuaternion=new u,c._xAxis=o.Zero(),c._yAxis=o.Zero(),c._zAxis=o.Zero(),c._updateFlagSeed=0,e.Matrix=c;var l=(function(){function e(e,t,i,r){this.normal=new o(e,t,i),this.d=r}return e.prototype.asArray=function(){return[this.normal.x,this.normal.y,this.normal.z,this.d]},e.prototype.clone=function(){return new e(this.normal.x,this.normal.y,this.normal.z,this.d)},e.prototype.getClassName=function(){return"Plane"},e.prototype.getHashCode=function(){var e=this.normal.getHashCode();return e=397*e^(this.d||0)},e.prototype.normalize=function(){var e=Math.sqrt(this.normal.x*this.normal.x+this.normal.y*this.normal.y+this.normal.z*this.normal.z),t=0;return 0!==e&&(t=1/e),this.normal.x*=t,this.normal.y*=t,this.normal.z*=t,this.d*=t,this},e.prototype.transform=function(t){var i=c.Transpose(t),r=this.normal.x,n=this.normal.y,s=this.normal.z,o=this.d;return new e(r*i.m[0]+n*i.m[1]+s*i.m[2]+o*i.m[3],r*i.m[4]+n*i.m[5]+s*i.m[6]+o*i.m[7],r*i.m[8]+n*i.m[9]+s*i.m[10]+o*i.m[11],r*i.m[12]+n*i.m[13]+s*i.m[14]+o*i.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,i){var r,n=t.x-e.x,s=t.y-e.y,o=t.z-e.z,a=i.x-e.x,h=i.y-e.y,u=i.z-e.z,c=s*u-o*h,l=o*a-n*u,f=n*h-s*a,d=Math.sqrt(c*c+l*l+f*f);return r=0!==d?1/d:0,this.normal.x=c*r,this.normal.y=l*r,this.normal.z=f*r,this.d=-(this.normal.x*e.x+this.normal.y*e.y+this.normal.z*e.z),this},e.prototype.isFrontFacingTo=function(e,t){return o.Dot(this.normal,e)<=t},e.prototype.signedDistanceTo=function(e){return o.Dot(e,this.normal)+this.d},e.FromArray=function(t){return new e(t[0],t[1],t[2],t[3])},e.FromPoints=function(t,i,r){var n=new e(0,0,0,0);return n.copyFromPoints(t,i,r),n},e.FromPositionAndNormal=function(t,i){var r=new e(0,0,0,0);return i.normalize(),r.normal=i,r.d=-(i.x*t.x+i.y*t.y+i.z*t.z),r},e.SignedDistanceToPlaneFromPositionAndNormal=function(e,t,i){var r=-(t.x*e.x+t.y*e.y+t.z*e.z);return o.Dot(i,t)+r},e})();e.Plane=l;var f=(function(){function e(e,t,i,r){this.x=e,this.y=t,this.width=i,this.height=r}return e.prototype.toGlobal=function(t,i){return new e(this.x*t,this.y*i,this.width*t,this.height*i)},e.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 i=[],r=0;r<6;r++)i.push(new l(0,0,0,0));return e.GetPlanesToRef(t,i),i},e.GetPlanesToRef=function(e,t){t[0].normal.x=e.m[3]+e.m[2],t[0].normal.y=e.m[7]+e.m[6],t[0].normal.z=e.m[11]+e.m[10],t[0].d=e.m[15]+e.m[14],t[0].normalize(),t[1].normal.x=e.m[3]-e.m[2],t[1].normal.y=e.m[7]-e.m[6],t[1].normal.z=e.m[11]-e.m[10],t[1].d=e.m[15]-e.m[14],t[1].normalize(),t[2].normal.x=e.m[3]+e.m[0],t[2].normal.y=e.m[7]+e.m[4],t[2].normal.z=e.m[11]+e.m[8],t[2].d=e.m[15]+e.m[12],t[2].normalize(),t[3].normal.x=e.m[3]-e.m[0],t[3].normal.y=e.m[7]-e.m[4],t[3].normal.z=e.m[11]-e.m[8],t[3].d=e.m[15]-e.m[12],t[3].normalize(),t[4].normal.x=e.m[3]-e.m[1],t[4].normal.y=e.m[7]-e.m[5],t[4].normal.z=e.m[11]-e.m[9],t[4].d=e.m[15]-e.m[13],t[4].normalize(),t[5].normal.x=e.m[3]+e.m[1],t[5].normal.y=e.m[7]+e.m[5],t[5].normal.z=e.m[11]+e.m[9],t[5].d=e.m[15]+e.m[13],t[5].normalize()},e})();e.Frustum=d;!(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 o(1,0,0),p.Y=new o(0,1,0),p.Z=new o(0,0,1),e.Axis=p;var _=(function(){function e(){}return e.interpolate=function(e,t,i,r,n){for(var s=1-3*r+3*t,o=3*r-6*t,a=3*t,h=e,u=0;u<5;u++){var c=h*h;h-=(s*(c*h)+o*c+a*h-e)*(1/(3*s*c+2*o*h+a)),h=Math.min(1,Math.max(0,h))}return 3*Math.pow(1-h,2)*h*i+3*(1-h)*Math.pow(h,2)*n+Math.pow(h,3)},e})();e.BezierCurve=_;var m;!(function(e){e[e.CW=0]="CW",e[e.CCW=1]="CCW"})(m=e.Orientation||(e.Orientation={}));var g=(function(){function e(e){var t=this;this.degrees=function(){return 180*t._radians/Math.PI},this.radians=function(){return t._radians},this._radians=e,this._radians<0&&(this._radians+=2*Math.PI)}return e.BetweenTwoPoints=function(t,i){var r=i.subtract(t);return new e(Math.atan2(r.y,r.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 y=(function(){function e(e,t,i){this.startPoint=e,this.midPoint=t,this.endPoint=i;var r=Math.pow(t.x,2)+Math.pow(t.y,2),n=(Math.pow(e.x,2)+Math.pow(e.y,2)-r)/2,o=(r-Math.pow(i.x,2)-Math.pow(i.y,2))/2,a=(e.x-t.x)*(t.y-i.y)-(t.x-i.x)*(e.y-t.y);this.centerPoint=new s((n*(t.y-i.y)-o*(e.y-t.y))/a,((e.x-t.x)*o-(t.x-i.x)*n)/a),this.radius=this.centerPoint.subtract(this.startPoint).length(),this.startAngle=g.BetweenTwoPoints(this.centerPoint,this.startPoint);var h=this.startAngle.degrees(),u=g.BetweenTwoPoints(this.centerPoint,this.midPoint).degrees(),c=g.BetweenTwoPoints(this.centerPoint,this.endPoint).degrees();u-h>180&&(u-=360),u-h<-180&&(u+=360),c-u>180&&(c-=360),c-u<-180&&(c+=360),this.orientation=u-h<0?m.CW:m.CCW,this.angle=g.FromDegrees(this.orientation===m.CW?h-c:c-h)}return e})();e.Arc2=y;var v=(function(){function e(e,t){this._points=new Array,this._length=0,this.closed=!1,this._points.push(new s(e,t))}return e.prototype.addLineTo=function(e,t){if(closed)return this;var i=new s(e,t),r=this._points[this._points.length-1];return this._points.push(i),this._length+=i.subtract(r).length(),this},e.prototype.addArcTo=function(e,t,i,r,n){if(void 0===n&&(n=36),closed)return this;var o=this._points[this._points.length-1],a=new s(e,t),h=new s(i,r),u=new y(o,a,h),c=u.angle.radians()/n;u.orientation===m.CW&&(c*=-1);for(var l=u.startAngle.radians()+c,f=0;f<n;f++){var d=Math.cos(l)*u.radius+u.centerPoint.x,p=Math.sin(l)*u.radius+u.centerPoint.y;this.addLineTo(d,p),l+=c}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 s.Zero();for(var t=e*this.length(),i=0,r=0;r<this._points.length;r++){var n=(r+1)%this._points.length,o=this._points[r],a=this._points[n],h=a.subtract(o),u=h.length()+i;if(t>=i&&t<=u){var c=h.normalize(),l=t-i;return new s(o.x+c.x*l,o.y+c.y*l)}i=u}return s.Zero()},e.StartingAt=function(t,i){return new e(t,i)},e})();e.Path2=v;var b=(function(){function i(e,t,i){this.path=e,this._curve=new Array,this._distances=new Array,this._tangents=new Array,this._normals=new Array,this._binormals=new Array;for(var r=0;r<e.length;r++)this._curve[r]=e[r].clone();this._raw=i||!1,this._compute(t)}return i.prototype.getCurve=function(){return this._curve},i.prototype.getTangents=function(){return this._tangents},i.prototype.getNormals=function(){return this._normals},i.prototype.getBinormals=function(){return this._binormals},i.prototype.getDistances=function(){return this._distances},i.prototype.update=function(e,t){for(var i=0;i<e.length;i++)this._curve[i].x=e[i].x,this._curve[i].y=e[i].y,this._curve[i].z=e[i].z;return this._compute(t),this},i.prototype._compute=function(e){var t=this._curve.length;this._tangents[0]=this._getFirstNonNullVector(0),this._raw||this._tangents[0].normalize(),this._tangents[t-1]=this._curve[t-1].subtract(this._curve[t-2]),this._raw||this._tangents[t-1].normalize();var i=this._tangents[0],r=this._normalVector(this._curve[0],i,e);this._normals[0]=r,this._raw||this._normals[0].normalize(),this._binormals[0]=o.Cross(i,this._normals[0]),this._raw||this._binormals[0].normalize(),this._distances[0]=0;for(var n,s,a,h,u=1;u<t;u++)n=this._getLastNonNullVector(u),u<t-1&&(s=this._getFirstNonNullVector(u),this._tangents[u]=n.add(s),this._tangents[u].normalize()),this._distances[u]=this._distances[u-1]+n.length(),a=this._tangents[u],h=this._binormals[u-1],this._normals[u]=o.Cross(h,a),this._raw||this._normals[u].normalize(),this._binormals[u]=o.Cross(a,this._normals[u]),this._raw||this._binormals[u].normalize()},i.prototype._getFirstNonNullVector=function(e){for(var t=1,i=this._curve[e+t].subtract(this._curve[e]);0===i.length()&&e+t+1<this._curve.length;)t++,i=this._curve[e+t].subtract(this._curve[e]);return i},i.prototype._getLastNonNullVector=function(e){for(var t=1,i=this._curve[e].subtract(this._curve[e-t]);0===i.length()&&e>t+1;)t++,i=this._curve[e].subtract(this._curve[e-t]);return i},i.prototype._normalVector=function(i,r,n){var s,a=r.length();if(0===a&&(a=1),void 0===n||null===n){var h;t.WithinEpsilon(Math.abs(r.y)/a,1,e.Epsilon)?t.WithinEpsilon(Math.abs(r.x)/a,1,e.Epsilon)?t.WithinEpsilon(Math.abs(r.z)/a,1,e.Epsilon)||(h=new o(0,0,1)):h=new o(1,0,0):h=new o(0,-1,0),s=o.Cross(r,h)}else s=o.Cross(r,n),o.CrossToRef(s,r,s);return s.normalize(),s},i})();e.Path3D=b;var x=(function(){function e(e){this._length=0,this._points=e,this._length=this._computeLength(e)}return e.CreateQuadraticBezier=function(t,i,r,n){n=n>2?n:3;for(var s=new Array,a=function(e,t,i,r){return(1-e)*(1-e)*t+2*e*(1-e)*i+e*e*r},h=0;h<=n;h++)s.push(new o(a(h/n,t.x,i.x,r.x),a(h/n,t.y,i.y,r.y),a(h/n,t.z,i.z,r.z)));return new e(s)},e.CreateCubicBezier=function(t,i,r,n,s){s=s>3?s:4;for(var a=new Array,h=function(e,t,i,r,n){return(1-e)*(1-e)*(1-e)*t+3*e*(1-e)*(1-e)*i+3*e*e*(1-e)*r+e*e*e*n},u=0;u<=s;u++)a.push(new o(h(u/s,t.x,i.x,r.x,n.x),h(u/s,t.y,i.y,r.y,n.y),h(u/s,t.z,i.z,r.z,n.z)));return new e(a)},e.CreateHermiteSpline=function(t,i,r,n,s){for(var a=new Array,h=1/s,u=0;u<=s;u++)a.push(o.Hermite(t,i,r,n,u*h));return new e(a)},e.CreateCatmullRomSpline=function(t,i){var r=new Array;r.push(t[0].clone()),Array.prototype.push.apply(r,t),r.push(t[t.length-1].clone());for(var n=new Array,s=1/i,a=0;a<r.length-3;a++)for(var h=0,u=0;u<i;u++)n.push(o.CatmullRom(r[a],r[a+1],r[a+2],r[a+3],h)),h+=s;return a--,n.push(o.CatmullRom(r[a],r[a+1],r[a+2],r[a+3],h)),new e(n)},e.prototype.getPoints=function(){return this._points},e.prototype.length=function(){return this._length},e.prototype.continue=function(t){for(var i=this._points[this._points.length-1],r=this._points.slice(),n=t.getPoints(),s=1;s<n.length;s++)r.push(n[s].subtract(n[0]).add(i));return new e(r)},e.prototype._computeLength=function(e){for(var t=0,i=1;i<e.length;i++)t+=e[i].subtract(e[i-1]).length();return t},e})();e.Curve3=x;var T=(function(){function e(){this.L00=o.Zero(),this.L1_1=o.Zero(),this.L10=o.Zero(),this.L11=o.Zero(),this.L2_2=o.Zero(),this.L2_1=o.Zero(),this.L20=o.Zero(),this.L21=o.Zero(),this.L22=o.Zero()}return e.prototype.addLight=function(e,t,i){var r=new o(t.r,t.g,t.b),n=r.scale(i);this.L00=this.L00.add(n.scale(.282095)),this.L1_1=this.L1_1.add(n.scale(.488603*e.y)),this.L10=this.L10.add(n.scale(.488603*e.z)),this.L11=this.L11.add(n.scale(.488603*e.x)),this.L2_2=this.L2_2.add(n.scale(1.092548*e.x*e.y)),this.L2_1=this.L2_1.add(n.scale(1.092548*e.y*e.z)),this.L21=this.L21.add(n.scale(1.092548*e.x*e.z)),this.L20=this.L20.add(n.scale(.315392*(3*e.z*e.z-1))),this.L22=this.L22.add(n.scale(.546274*(e.x*e.x-e.y*e.y)))},e.prototype.scale=function(e){this.L00=this.L00.scale(e),this.L1_1=this.L1_1.scale(e),this.L10=this.L10.scale(e),this.L11=this.L11.scale(e),this.L2_2=this.L2_2.scale(e),this.L2_1=this.L2_1.scale(e),this.L20=this.L20.scale(e),this.L21=this.L21.scale(e),this.L22=this.L22.scale(e)},e})();e.SphericalHarmonics=T;var E=(function(){function e(){this.x=o.Zero(),this.y=o.Zero(),this.z=o.Zero(),this.xx=o.Zero(),this.yy=o.Zero(),this.zz=o.Zero(),this.xy=o.Zero(),this.yz=o.Zero(),this.zx=o.Zero()}return e.prototype.addAmbient=function(e){var t=new o(e.r,e.g,e.b);this.xx=this.xx.add(t),this.yy=this.yy.add(t),this.zz=this.zz.add(t)},e.getSphericalPolynomialFromHarmonics=function(t){var i=new e;return i.x=t.L11.scale(1.02333),i.y=t.L1_1.scale(1.02333),i.z=t.L10.scale(1.02333),i.xx=t.L00.scale(.886277).subtract(t.L20.scale(.247708)).add(t.L22.scale(.429043)),i.yy=t.L00.scale(.886277).subtract(t.L20.scale(.247708)).subtract(t.L22.scale(.429043)),i.zz=t.L00.scale(.886277).add(t.L20.scale(.495417)),i.yz=t.L2_1.scale(.858086),i.zx=t.L21.scale(.858086),i.xy=t.L2_2.scale(.858086),i},e})();e.SphericalPolynomial=E;var A=(function(){function e(e,t){void 0===e&&(e=o.Zero()),void 0===t&&(t=o.Up()),this.position=e,this.normal=t}return e.prototype.clone=function(){return new e(this.position.clone(),this.normal.clone())},e})();e.PositionNormalVertex=A;var M=(function(){function e(e,t,i){void 0===e&&(e=o.Zero()),void 0===t&&(t=o.Up()),void 0===i&&(i=s.Zero()),this.position=e,this.normal=t,this.uv=i}return e.prototype.clone=function(){return new e(this.position.clone(),this.normal.clone(),this.uv.clone())},e})();e.PositionNormalTextureVertex=M;var P=(function(){function e(){}return e})();P.Color3=[r.Black(),r.Black(),r.Black()],P.Vector2=[s.Zero(),s.Zero(),s.Zero()],P.Vector3=[o.Zero(),o.Zero(),o.Zero(),o.Zero(),o.Zero(),o.Zero(),o.Zero(),o.Zero(),o.Zero()],P.Vector4=[a.Zero(),a.Zero(),a.Zero()],P.Quaternion=[u.Zero(),u.Zero()],P.Matrix=[c.Zero(),c.Zero(),c.Zero(),c.Zero(),c.Zero(),c.Zero(),c.Zero(),c.Zero()],e.Tmp=P;var O=(function(){function e(){}return e})();O.Vector3=[o.Zero()],O.Matrix=[c.Zero(),c.Zero()],O.Quaternion=[u.Zero()]})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){function t(e,t){return function(i,r){i.__serializableMembers||(i.__serializableMembers={}),i.__serializableMembers[r]||(i.__serializableMembers[r]={type:e,sourceName:t})}}function i(e){return function(t,i){if(e){var r="_"+i;Object.defineProperty(t,i,{get:function(){return this[r]},set:function(i){this[r]!==i&&(this[r]=i,t[e].apply(this))},enumerable:!0,configurable:!0})}}}function r(e){return i(e)}function n(e){return t(0,e)}function s(e){return t(1,e)}function o(e){return t(2,e)}function a(e){return t(3,e)}function h(e){return t(4,e)}function u(e){return t(5,e)}function c(e){return t(6,e)}function l(e){return t(7,e)}e.expandToProperty=r,e.serialize=n,e.serializeAsTexture=s,e.serializeAsColor3=o,e.serializeAsFresnelParameters=a,e.serializeAsVector2=h,e.serializeAsVector3=u,e.serializeAsMeshReference=c,e.serializeAsColorCurves=l;var f=(function(){function t(){}return t.Serialize=function(t,i){i||(i={}),i.tags=e.Tags.GetTags(t);for(var r in t.__serializableMembers){var n=t.__serializableMembers[r],s=n.sourceName||r,o=n.type,a=t[r];if(void 0!==a&&null!==a)switch(o){case 0:i[s]=a;break;case 1:i[s]=a.serialize();break;case 2:i[s]=a.asArray();break;case 3:i[s]=a.serialize();break;case 4:case 5:i[s]=a.asArray();break;case 6:i[s]=a.id;break;case 7:i[s]=a.serialize()}}return i},t.Parse=function(t,i,r,n){var s=t();e.Tags.AddTagsTo(s,i.tags);for(var o in s.__serializableMembers){var a=s.__serializableMembers[o],h=i[a.sourceName||o],u=a.type;if(void 0!==h&&null!==h)switch(u){case 0:s[o]=h;break;case 1:s[o]=e.Texture.Parse(h,r,n);break;case 2:s[o]=e.Color3.FromArray(h);break;case 3:s[o]=e.FresnelParameters.Parse(h);break;case 4:s[o]=e.Vector2.FromArray(h);break;case 5:s[o]=e.Vector3.FromArray(h);break;case 6:s[o]=r.getLastMeshByID(h);break;case 7:s[o]=e.ColorCurves.Parse(h)}}return s},t.Clone=function(t,i){var r=t();e.Tags.AddTagsTo(r,i.tags);for(var n in r.__serializableMembers){var s=r.__serializableMembers[n],o=i[n],a=s.type;if(void 0!==o&&null!==o)switch(a){case 0:case 6:r[n]=o;break;case 1:case 2:case 3:case 4:case 5:case 7:r[n]=o.clone()}}return r},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 i=(function(){function e(e,t){this.callback=e,this.mask=t}return e})();e.Observer=i;var r=(function(){function e(){this._observers=new Array,this._eventState=new t(0)}return e.prototype.add=function(e,t,r){if(void 0===t&&(t=-1),void 0===r&&(r=!1),!e)return null;var n=new i(e,t);return r?this._observers.unshift(n):this._observers.push(n),n},e.prototype.remove=function(e){var t=this._observers.indexOf(e);return-1!==t&&(this._observers.splice(t,1),!0)},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 i=this._eventState;i.mask=t,i.skipNextObservers=!1;for(var r=0,n=this._observers;r<n.length;r++){var s=n[r];if(s.mask&t&&s.callback(e,i),i.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,i=this._observers;t<i.length;t++){var r=i[t];if(r.mask&e&&r.mask===e)return!0}return!1},e})();e.Observable=r})(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))
  3. ;for(var t=0;t<e.length;t++)this.data[this.length++]=(e.data||e)[t]}},e.prototype.concatWithNoDuplicate=function(e){if(0!==e.length){this.length+e.length>this.data.length&&(this.data.length=2*(this.length+e.length));for(var t=0;t<e.length;t++){var i=(e.data||e)[t];this.pushNoDuplicate(i)}}},e.prototype.indexOf=function(e){var t=this.data.indexOf(e);return t>=this.length?-1:t},e.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(i){i.__bjsclassName__=e,i.__bjsmoduleName__=null!=t?t:null}}var i,r=function(t,i){return t?t instanceof e.Mesh?null:t instanceof e.SubMesh?t.clone(i):t.clone?t.clone():null:null},n=(function(){function t(){}return t.Instantiate=function(e){for(var t=e.split("."),i=window||this,r=0,n=t.length;r<n;r++)i=i[t[r]];return"function"!=typeof i?null:i},t.SetImmediate=function(e){window.setImmediate?window.setImmediate(e):setTimeout(e,1)},t.IsExponentOfTwo=function(e){var t=1;do{t*=2}while(t<e);return t===e},t.GetExponentOfTwo=function(e,t){var i=1;do{i*=2}while(i<e);return i>t&&(i=t),i},t.GetFilename=function(e){var t=e.lastIndexOf("/");return t<0?e:e.substring(t+1)},t.GetDOMTextContent=function(e){for(var t="",i=e.firstChild;i;)3===i.nodeType&&(t+=i.textContent),i=i.nextSibling;return t},t.ToDegrees=function(e){return 180*e/Math.PI},t.ToRadians=function(e){return e*Math.PI/180},t.EncodeArrayBufferTobase64=function(e){for(var t,i,r,n,s,o,a,h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",u="",c=0,l=new Uint8Array(e);c<l.length;)t=l[c++],i=c<l.length?l[c++]:Number.NaN,r=c<l.length?l[c++]:Number.NaN,n=t>>2,s=(3&t)<<4|i>>4,o=(15&i)<<2|r>>6,a=63&r,isNaN(i)?o=a=64:isNaN(r)&&(a=64),u+=h.charAt(n)+h.charAt(s)+h.charAt(o)+h.charAt(a);return"data:image/png;base64,"+u},t.ExtractMinAndMaxIndexed=function(t,i,r,n,s){void 0===s&&(s=null);for(var o=new e.Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),a=new e.Vector3(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),h=r;h<r+n;h++){var u=new e.Vector3(t[3*i[h]],t[3*i[h]+1],t[3*i[h]+2]);o=e.Vector3.Minimize(u,o),a=e.Vector3.Maximize(u,a)}return s&&(o.x-=o.x*s.x+s.y,o.y-=o.y*s.x+s.y,o.z-=o.z*s.x+s.y,a.x+=a.x*s.x+s.y,a.y+=a.y*s.x+s.y,a.z+=a.z*s.x+s.y),{minimum:o,maximum:a}},t.ExtractMinAndMax=function(t,i,r,n,s){void 0===n&&(n=null);var o=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);s||(s=3);for(var h=i;h<i+r;h++){var u=new e.Vector3(t[h*s],t[h*s+1],t[h*s+2]);o=e.Vector3.Minimize(u,o),a=e.Vector3.Maximize(u,a)}return n&&(o.x-=o.x*n.x+n.y,o.y-=o.y*n.x+n.y,o.z-=o.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:o,maximum:a}},t.Vector2ArrayFeeder=function(t){return function(i){var r=void 0!==t.BYTES_PER_ELEMENT;if(i>=(r?t.length/2:t.length))return null;if(r){var n=t;return new e.Vector2(n[2*i+0],n[2*i+1])}return t[i]}},t.ExtractMinAndMaxVector2=function(t,i){void 0===i&&(i=null);for(var r=new e.Vector2(Number.MAX_VALUE,Number.MAX_VALUE),n=new e.Vector2(-Number.MAX_VALUE,-Number.MAX_VALUE),s=0,o=t(s++);o;)r=e.Vector2.Minimize(o,r),n=e.Vector2.Maximize(o,n),o=t(s++);return i&&(r.x-=r.x*i.x+i.y,r.y-=r.y*i.x+i.y,n.x+=n.x*i.x+i.y,n.y+=n.y*i.x+i.y),{minimum:r,maximum:n}},t.MakeArray=function(e,t){if(!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,i){if(t.CorsBehavior)switch(typeof t.CorsBehavior){case"function":var r=t.CorsBehavior(e);r&&(i.crossOrigin=r);break;case"string":default:i.crossOrigin=t.CorsBehavior}},t.CleanUrl=function(e){return e=e.replace(/#/gm,"%23")},t.LoadImage=function(i,r,n,s){i instanceof ArrayBuffer&&(i=t.EncodeArrayBufferTobase64(i)),i=t.CleanUrl(i);var o=new Image;"data:"!==i.substr(0,5)&&t.SetCorsBehavior(i,o),o.onload=function(){r(o)},o.onerror=function(e){t.Error("Error while trying to load image: "+i),t.UseFallbackTexture?(o.src=t.fallbackTexture,r(o)):n()};var a=function(){o.src=i},h=function(){s.loadImageFromDB(i,o)};if("data:"!==i.substr(0,5)&&s&&s.enableTexturesOffline&&e.Database.IsUASupportingBlobStorage)s.openAsync(h,a);else if(-1===i.indexOf("file:"))a();else{var u=i.substring(5).toLowerCase();if(e.FilesInput.FilesToLoad[u])try{var c;try{c=URL.createObjectURL(e.FilesInput.FilesToLoad[u],{oneTimeOnly:!0})}catch(t){c=URL.createObjectURL(e.FilesInput.FilesToLoad[u])}o.src=c}catch(e){o.src=null}else t.Error("Image: "+u+" not found. Did you forget to provide it?"),o.src=t.fallbackTexture}return o},t.LoadFile=function(i,r,n,s,o,a){i=t.CleanUrl(i);var h=function(){var e=new XMLHttpRequest,s=t.BaseUrl+i;e.open("GET",s,!0),o&&(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)r(o?e.response:e.responseText);else{if(!a)throw new Error("Error status: "+e.status+" - Unable to load "+s);a(e)}},e.send(null)},u=function(){s.loadFileFromDB(i,r,n,h,o)};if(-1!==i.indexOf("file:")){var c=i.substring(5).toLowerCase();e.FilesInput.FilesToLoad[c]?t.ReadFile(e.FilesInput.FilesToLoad[c],r,n,o):t.Error("File: "+c+" not found. Did you forget to provide it?")}else s&&s.enableSceneOffline?s.openAsync(u,h):h()},t.LoadScript=function(e,t,i){var r=document.getElementsByTagName("head")[0],n=document.createElement("script");n.type="text/javascript",n.src=e;n.onload=function(){t&&t()},n.onerror=function(){i&&i()},r.appendChild(n)},t.ReadFileAsDataURL=function(e,t,i){var r=new FileReader;r.onload=function(e){t(e.target.result)},r.onprogress=i,r.readAsDataURL(e)},t.ReadFile=function(e,i,r,n){var s=new FileReader;s.onerror=function(r){t.Log("Error while reading file: "+e.name),i(JSON.stringify({autoClear:!0,clearColor:[1,0,0],ambientColor:[0,0,0],gravity:[0,-9.807,0],meshes:[],cameras:[],lights:[]}))},s.onload=function(e){i(e.target.result)},s.onprogress=r,n?s.readAsArrayBuffer(e):s.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,i){e.x<t.x&&(t.x=e.x),e.y<t.y&&(t.y=e.y),e.z<t.z&&(t.z=e.z),e.x>i.x&&(i.x=e.x),e.y>i.y&&(i.y=e.y),e.z>i.z&&(i.z=e.z)},t.DeepCopy=function(e,t,i,n){for(var s in e)if(("_"!==s[0]||n&&-1!==n.indexOf(s))&&(!i||-1===i.indexOf(s))){var o=e[s],a=typeof o;if("function"!==a)if("object"===a)if(o instanceof Array){if(t[s]=[],o.length>0)if("object"==typeof o[0])for(var h=0;h<o.length;h++){var u=r(o[h],t);-1===t[s].indexOf(u)&&t[s].push(u)}else t[s]=o.slice(0)}else t[s]=r(o,t);else t[s]=o}},t.IsEmpty=function(e){for(var t in e)return!1;return!0},t.RegisterTopRootEvents=function(e){for(var t=0;t<e.length;t++){var i=e[t];window.addEventListener(i.name,i.handler,!1);try{window.parent&&window.parent.addEventListener(i.name,i.handler,!1)}catch(e){}}},t.UnregisterTopRootEvents=function(e){for(var t=0;t<e.length;t++){var i=e[t];window.removeEventListener(i.name,i.handler);try{window.parent&&window.parent.removeEventListener(i.name,i.handler)}catch(e){}}},t.DumpFramebuffer=function(e,r,n,s,o){void 0===o&&(o="image/png");for(var a=4*e,h=r/2,u=n.readPixels(0,0,e,r),c=0;c<h;c++)for(var l=0;l<a;l++){var f=l+c*a,d=r-c-1,p=l+d*a,_=u[f];u[f]=u[p],u[p]=_}i||(i=document.createElement("canvas")),i.width=e,i.height=r;var m=i.getContext("2d"),g=m.createImageData(e,r);g.data.set(u),m.putImageData(g,0,0),t.EncodeScreenshotCanvasData(s,o)},t.EncodeScreenshotCanvasData=function(e,t){void 0===t&&(t="image/png");var r=i.toDataURL(t);if(e)e(r);else if("download"in document.createElement("a")){var n=window.document.createElement("a");n.href=r;var s=new Date,o=(s.getFullYear()+"-"+(s.getMonth()+1)).slice(-2)+"-"+s.getDate()+"_"+s.getHours()+"-"+("0"+s.getMinutes()).slice(-2);n.setAttribute("download","screenshot_"+o+".png"),window.document.body.appendChild(n),n.addEventListener("click",(function(){n.parentElement.removeChild(n)})),n.click()}else{var a=window.open(""),h=a.document.createElement("img");h.src=r,a.document.body.appendChild(h)}},t.CreateScreenshot=function(e,r,n,s,o){void 0===o&&(o="image/png");var a,h;if(n.precision)a=Math.round(e.getRenderWidth()*n.precision),h=Math.round(a/e.getAspectRatio(r));else if(n.width&&n.height)a=n.width,h=n.height;else if(n.width&&!n.height)a=n.width,h=Math.round(a/e.getAspectRatio(r));else if(n.height&&!n.width)h=n.height,a=Math.round(h*e.getAspectRatio(r));else{if(isNaN(n))return void t.Error("Invalid 'size' parameter !");h=n,a=n}i||(i=document.createElement("canvas")),i.width=a,i.height=h;var u=i.getContext("2d"),c=e.getRenderWidth()/e.getRenderHeight(),l=a,f=l/c;f>h&&(f=h,l=f*c);var d=Math.max(0,a-l)/2,p=Math.max(0,h-f)/2;u.drawImage(e.getRenderingCanvas(),d,p,l,f),t.EncodeScreenshotCanvasData(s,o)},t.CreateScreenshotUsingRenderTarget=function(i,r,n,s,o,a){void 0===o&&(o="image/png"),void 0===a&&(a=1);var h,u;if(n.precision)h=Math.round(i.getRenderWidth()*n.precision),u=Math.round(h/i.getAspectRatio(r)),n={width:h,height:u};else if(n.width&&n.height)h=n.width,u=n.height;else if(n.width&&!n.height)h=n.width,u=Math.round(h/i.getAspectRatio(r)),n={width:h,height:u};else if(n.height&&!n.width)u=n.height,h=Math.round(u*i.getAspectRatio(r)),n={width:h,height:u};else{if(isNaN(n))return void t.Error("Invalid 'size' parameter !");u=n,h=n}var c=r.getScene(),l=null;c.activeCamera!==r&&(l=c.activeCamera,c.activeCamera=r);var f=new e.RenderTargetTexture("screenShot",n,c,!1,!1,e.Engine.TEXTURETYPE_UNSIGNED_INT,!1,e.Texture.NEAREST_SAMPLINGMODE);f.renderList=c.meshes,f.samples=a,f.onAfterRenderObservable.add((function(){t.DumpFramebuffer(h,u,i,s,o)})),c.incrementRenderId(),c.resetCachedMaterial(),f.render(!0),f.dispose(),l&&(c.activeCamera=l),r.getProjectionMatrix(!0)},t.ValidateXHRData=function(t,i){void 0===i&&(i=7);try{if(1&i){if(t.responseText&&t.responseText.length>0)return!0;if(1===i)return!1}if(2&i){var r=e.Internals.TGATools.GetTGAHeader(t.response);if(r.width&&r.height&&r.width>0&&r.height>0)return!0;if(2===i)return!1}if(4&i){var n=new Uint8Array(t.response,0,3);return 68===n[0]&&68===n[1]&&83===n[2]}}catch(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},i=new Date;return"["+t(i.getHours())+":"+t(i.getMinutes())+":"+t(i.getSeconds())+"]: "+e},t._LogDisabled=function(e){},t._LogEnabled=function(e){var i=t._FormatMessage(e);console.log("BJS - "+i);var r="<div style='color:white'>"+i+"</div><br>";t._AddLogEntry(r)},t._WarnDisabled=function(e){},t._WarnEnabled=function(e){var i=t._FormatMessage(e);console.warn("BJS - "+i);var r="<div style='color:orange'>"+i+"</div><br>";t._AddLogEntry(r)},t._ErrorDisabled=function(e){},t._ErrorEnabled=function(e){t.errorsCount++;var i=t._FormatMessage(e);console.error("BJS - "+i);var r="<div style='color:red'>"+i+"</div><br>";t._AddLogEntry(r)},Object.defineProperty(t,"LogCache",{get:function(){return t._LogCache},enumerable:!0,configurable:!0}),t.ClearLogCache=function(){t._LogCache="",t.errorsCount=0},Object.defineProperty(t,"LogLevels",{set:function(e){(e&t.MessageLogLevel)===t.MessageLogLevel?t.Log=t._LogEnabled:t.Log=t._LogDisabled,(e&t.WarningLogLevel)===t.WarningLogLevel?t.Warn=t._WarnEnabled:t.Warn=t._WarnDisabled,(e&t.ErrorLogLevel)===t.ErrorLogLevel?t.Error=t._ErrorEnabled:t.Error=t._ErrorDisabled},enumerable:!0,configurable:!0}),Object.defineProperty(t,"PerformanceNoneLogLevel",{get:function(){return t._PerformanceNoneLogLevel},enumerable:!0,configurable:!0}),Object.defineProperty(t,"PerformanceUserMarkLogLevel",{get:function(){return t._PerformanceUserMarkLogLevel},enumerable:!0,configurable:!0}),Object.defineProperty(t,"PerformanceConsoleLogLevel",{get:function(){return t._PerformanceConsoleLogLevel},enumerable:!0,configurable:!0}),Object.defineProperty(t,"PerformanceLogLevel",{set:function(e){return(e&t.PerformanceUserMarkLogLevel)===t.PerformanceUserMarkLogLevel?(t.StartPerformanceCounter=t._StartUserMark,void(t.EndPerformanceCounter=t._EndUserMark)):(e&t.PerformanceConsoleLogLevel)===t.PerformanceConsoleLogLevel?(t.StartPerformanceCounter=t._StartPerformanceConsole,void(t.EndPerformanceCounter=t._EndPerformanceConsole)):(t.StartPerformanceCounter=t._StartPerformanceCounterDisabled,void(t.EndPerformanceCounter=t._EndPerformanceCounterDisabled))},enumerable:!0,configurable:!0}),t._StartPerformanceCounterDisabled=function(e,t){},t._EndPerformanceCounterDisabled=function(e,t){},t._StartUserMark=function(e,i){void 0===i&&(i=!0),i&&t._performance.mark&&t._performance.mark(e+"-Begin")},t._EndUserMark=function(e,i){void 0===i&&(i=!0),i&&t._performance.mark&&(t._performance.mark(e+"-End"),t._performance.measure(e,e+"-Begin",e+"-End"))},t._StartPerformanceConsole=function(e,i){void 0===i&&(i=!0),i&&(t._StartUserMark(e,i),console.time&&console.time(e))},t._EndPerformanceConsole=function(e,i){void 0===i&&(i=!0),i&&(t._EndUserMark(e,i),console.time&&console.timeEnd(e))},Object.defineProperty(t,"Now",{get:function(){return window.performance&&window.performance.now?window.performance.now():(new Date).getTime()},enumerable:!0,configurable:!0}),t.getClassName=function(e,t){void 0===t&&(t=!1);var i=null;if(!t&&e.getClassName)i=e.getClassName();else{if(e instanceof Object){i=(t?e:Object.getPrototypeOf(e)).constructor.__bjsclassName__}i||(i=typeof e)}return i},t.first=function(e,t){for(var i=0,r=e;i<r.length;i++){var n=r[i];if(t(n))return n}},t.getFullClassName=function(e,t){void 0===t&&(t=!1);var i=null,r=null;if(!t&&e.getClassName)i=e.getClassName();else{if(e instanceof Object){var n=t?e:Object.getPrototypeOf(e);i=n.constructor.__bjsclassName__,r=n.constructor.__bjsmoduleName__}i||(i=typeof e)}return i?(null!=r?r+".":"")+i:null},t.arrayOrStringFeeder=function(e){return function(i){if(i>=e.length)return null;var r=e.charCodeAt?e.charCodeAt(i):e[i];return r&&r.getHashCode&&(r=r.getHashCode()),"string"==typeof r?t.hashCodeFromStream(t.arrayOrStringFeeder(r)):r}},t.hashCodeFromStream=function(e){for(var t=0,i=0,r=e(i++);null!=r;)t=(t<<5)-t+r,t|=0,r=e(i++);return t},t})();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 s=(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,i){e.Enabled&&(this._current+=t,i&&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 i=n.Now;this._current=i-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})();s.Enabled=!0,e.PerfCounter=s,e.className=t;var o=(function(){function e(e,t,i,r){void 0===r&&(r=0),this.iterations=e,this._fn=t,this._successCallback=i,this.index=r-1,this._done=!1}return e.prototype.executeNext=function(){this._done||(this.index+1<this.iterations?(++this.index,this._fn(this)):this.breakLoop())},e.prototype.breakLoop=function(){this._done=!0,this._successCallback()},e.Run=function(t,i,r,n){void 0===n&&(n=0);var s=new e(t,i,r,n);return s.executeNext(),s},e.SyncAsyncForLoop=function(t,i,r,n,s,o){void 0===o&&(o=0),e.Run(Math.ceil(t/i),(function(e){s&&s()?e.breakLoop():setTimeout((function(){for(var n=0;n<i;++n){var o=e.index*i+n;if(o>=t)break;if(r(o),s&&s()){e.breakLoop();break}}e.executeNext()}),o)}),n)},e})();e.AsyncLoop=o})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(e){var t=(function(){function e(){this._isAlphaBlendDirty=!1,this._isBlendFunctionParametersDirty=!1,this._alphaBlend=!1,this._blendFunctionParameters=new Array(4),this.reset()}return Object.defineProperty(e.prototype,"isDirty",{get:function(){return this._isAlphaBlendDirty||this._isBlendFunctionParametersDirty},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"alphaBlend",{get:function(){return this._alphaBlend},set:function(e){this._alphaBlend!==e&&(this._alphaBlend=e,this._isAlphaBlendDirty=!0)},enumerable:!0,configurable:!0}),e.prototype.setAlphaBlendFunctionParameters=function(e,t,i,r){this._blendFunctionParameters[0]===e&&this._blendFunctionParameters[1]===t&&this._blendFunctionParameters[2]===i&&this._blendFunctionParameters[3]===r||(this._blendFunctionParameters[0]=e,this._blendFunctionParameters[1]=t,this._blendFunctionParameters[2]=i,this._blendFunctionParameters[3]=r,this._isBlendFunctionParametersDirty=!0)},e.prototype.reset=function(){this._alphaBlend=!1,this._blendFunctionParameters[0]=null,this._blendFunctionParameters[1]=null,this._blendFunctionParameters[2]=null,this._blendFunctionParameters[3]=null,this._isAlphaBlendDirty=!0,this._isBlendFunctionParametersDirty=!1},e.prototype.apply=function(e){this.isDirty&&(this._isAlphaBlendDirty&&(this._alphaBlend?e.enable(e.BLEND):e.disable(e.BLEND),this._isAlphaBlendDirty=!1),this._isBlendFunctionParametersDirty&&(e.blendFuncSeparate(this._blendFunctionParameters[0],this._blendFunctionParameters[1],this._blendFunctionParameters[2],this._blendFunctionParameters[3]),this._isBlendFunctionParametersDirty=!1))},e})();e._AlphaState=t})(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 i=(function(){function t(){this._isStencilTestDirty=!1,this._isStencilMaskDirty=!1,this._isStencilFuncDirty=!1,this._isStencilOpDirty=!1,this.reset()}return Object.defineProperty(t.prototype,"isDirty",{get:function(){return this._isStencilTestDirty||this._isStencilMaskDirty||this._isStencilFuncDirty||this._isStencilOpDirty},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stencilFunc",{get:function(){return this._stencilFunc},set:function(e){this._stencilFunc!==e&&(this._stencilFunc=e,this._isStencilFuncDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stencilFuncRef",{get:function(){return this._stencilFuncRef},set:function(e){this._stencilFuncRef!==e&&(this._stencilFuncRef=e,this._isStencilFuncDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stencilFuncMask",{get:function(){return this._stencilFuncMask},set:function(e){this._stencilFuncMask!==e&&(this._stencilFuncMask=e,this._isStencilFuncDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stencilOpStencilFail",{get:function(){return this._stencilOpStencilFail},set:function(e){this._stencilOpStencilFail!==e&&(this._stencilOpStencilFail=e,this._isStencilOpDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stencilOpDepthFail",{get:function(){return this._stencilOpDepthFail},set:function(e){this._stencilOpDepthFail!==e&&(this._stencilOpDepthFail=e,this._isStencilOpDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stencilOpStencilDepthPass",{get:function(){return this._stencilOpStencilDepthPass},set:function(e){this._stencilOpStencilDepthPass!==e&&(this._stencilOpStencilDepthPass=e,this._isStencilOpDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stencilMask",{get:function(){return this._stencilMask},set:function(e){this._stencilMask!==e&&(this._stencilMask=e,this._isStencilMaskDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stencilTest",{get:function(){return this._stencilTest},set:function(e){this._stencilTest!==e&&(this._stencilTest=e,this._isStencilTestDirty=!0)},enumerable:!0,configurable:!0}),t.prototype.reset=function(){this._stencilTest=!1,this._stencilMask=255,this._stencilFunc=e.Engine.ALWAYS,this._stencilFuncRef=1,this._stencilFuncMask=255,this._stencilOpStencilFail=e.Engine.KEEP,this._stencilOpDepthFail=e.Engine.KEEP,this._stencilOpStencilDepthPass=e.Engine.REPLACE,this._isStencilTestDirty=!0,this._isStencilMaskDirty=!0,this._isStencilFuncDirty=!0,this._isStencilOpDirty=!0},t.prototype.apply=function(e){this.isDirty&&(this._isStencilTestDirty&&(this.stencilTest?e.enable(e.STENCIL_TEST):e.disable(e.STENCIL_TEST),this._isStencilTestDirty=!1),this._isStencilMaskDirty&&(e.stencilMask(this.stencilMask),this._isStencilMaskDirty=!1),this._isStencilFuncDirty&&(e.stencilFunc(this.stencilFunc,this.stencilFuncRef,this.stencilFuncMask),this._isStencilFuncDirty=!1),this._isStencilOpDirty&&(e.stencilOp(this.stencilOpStencilFail,this.stencilOpDepthFail,this.stencilOpStencilDepthPass),this._isStencilOpDirty=!1))},t})();t._StencilState=i})(e.Internals||(e.Internals={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=function(e,t,i,r,n){var s=e.createShader("vertex"===i?e.VERTEX_SHADER:e.FRAGMENT_SHADER);if(e.shaderSource(s,n+(r?r+"\n":"")+t),e.compileShader(s),!e.getShaderParameter(s,e.COMPILE_STATUS))throw new Error(e.getShaderInfoLog(s));return s},i=function(t,i,r){var n=r.NEAREST,s=r.NEAREST;return t===e.Texture.BILINEAR_SAMPLINGMODE?(n=r.LINEAR,s=i?r.LINEAR_MIPMAP_NEAREST:r.LINEAR):t===e.Texture.TRILINEAR_SAMPLINGMODE?(n=r.LINEAR,s=i?r.LINEAR_MIPMAP_LINEAR:r.LINEAR):t===e.Texture.NEAREST_SAMPLINGMODE&&(n=r.NEAREST,s=i?r.NEAREST_MIPMAP_LINEAR:r.NEAREST),{min:s,mag:n}},r=function(t,r,n,s,o,a,h,u,c,l){void 0===l&&(l=e.Texture.TRILINEAR_SAMPLINGMODE);var f=n.getEngine();if(f){var d=e.Tools.GetExponentOfTwo(s,f.getCaps().maxTextureSize),p=e.Tools.GetExponentOfTwo(o,f.getCaps().maxTextureSize);f._bindTextureDirectly(r.TEXTURE_2D,t),r.pixelStorei(r.UNPACK_FLIP_Y_WEBGL,void 0===a?1:a?1:0),t._baseWidth=s,t._baseHeight=o,t._width=d,t._height=p,t.isReady=!0,c(d,p);var _=i(l,!h,r);r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,_.mag),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,_.min),h||u||r.generateMipmap(r.TEXTURE_2D),f._bindTextureDirectly(r.TEXTURE_2D,null),f.resetTextureCache(),n._removePendingData(t),t.onLoadedCallbacks.forEach((function(e){e()})),t.onLoadedCallbacks=[]}},n=function(t,i,r,n,s,o){void 0===o&&(o=null);var a,h=function(){r[i]=a,r._internalCount++,n._removePendingData(a),6===r._internalCount&&s(r)},u=function(){n._removePendingData(a),o&&o()};a=e.Tools.LoadImage(t,h,u,n.database),n._addPendingData(a)},s=function(e,t,i,r,s){
  4. void 0===s&&(s=null);var o=[];o._internalCount=0;for(var a=0;a<6;a++)n(r[a],a,o,t,i,s)},o=(function(){function e(){}return e})();e.InstancingAttributeInfo=o;var a=(function(){function e(){}return e})();e.EngineCapabilities=a;var h=(function(){function n(t,i,r,s){void 0===s&&(s=!1);var o=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._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(o._vrDisplayEnabled&&o._vrDisplayEnabled.isPresenting){o._oldSize=new e.Size(o.getRenderWidth(),o.getRenderHeight()),o._oldHardwareScaleFactor=o.getHardwareScalingLevel();var t=o._vrDisplayEnabled.getEyeParameters("left");o.setHardwareScalingLevel(1),o.setSize(2*t.renderWidth,t.renderHeight)}else o.setHardwareScalingLevel(o._oldHardwareScaleFactor),o.setSize(o._oldSize.width,o._oldSize.height),o._vrDisplayEnabled=void 0},this._renderingCanvas=t,n.Instances.push(this),r=r||{},null!=i&&(r.antialias=i),void 0===r.preserveDrawingBuffer&&(r.preserveDrawingBuffer=!1),void 0===r.audioEngine&&(r.audioEngine=!0),void 0===r.stencil&&(r.stencil=!0),!r.disableWebGL2Support)try{this._gl=t.getContext("webgl2",r)||t.getContext("experimental-webgl2",r),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",r)||t.getContext("experimental-webgl",r)}catch(e){throw new Error("WebGL not supported")}}if(!this._gl)throw new Error("WebGL not supported");this._onBlur=function(){o._windowIsBackground=!0},this._onFocus=function(){o._windowIsBackground=!1},window.addEventListener("blur",this._onBlur),window.addEventListener("focus",this._onFocus);var h=r.limitDeviceRatio||window.devicePixelRatio||1;this._hardwareScalingLevel=s?1/Math.min(h,window.devicePixelRatio||1):1,this.resize(),this._isStencilEnable=r.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 u=this._gl.getExtension("WEBGL_debug_renderer_info");if(null!=u&&(this._glRenderer=this._gl.getParameter(u.UNMASKED_RENDERER_WEBGL),this._glVendor=this._gl.getParameter(u.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._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 c=this._gl.getExtension("OES_vertex_array_object");null!=c?(this._caps.vertexArrayObject=!0,this._gl.createVertexArray=c.createVertexArrayOES.bind(c),this._gl.bindVertexArray=c.bindVertexArrayOES.bind(c),this._gl.deleteVertexArray=c.deleteVertexArrayOES.bind(c)):this._caps.vertexArrayObject=!1}if(this._webGLVersion>1)this._caps.instancedArrays=!0;else{var l=this._gl.getExtension("ANGLE_instanced_arrays");null!=l?(this._caps.instancedArrays=!0,this._gl.drawArraysInstanced=l.drawArraysInstancedANGLE.bind(l),this._gl.drawElementsInstanced=l.drawElementsInstancedANGLE.bind(l),this._gl.vertexAttribDivisor=l.vertexAttribDivisorANGLE.bind(l)):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?o.isFullscreen=document.fullscreen:void 0!==document.mozFullScreen?o.isFullscreen=document.mozFullScreen:void 0!==document.webkitIsFullScreen?o.isFullscreen=document.webkitIsFullScreen:void 0!==document.msIsFullScreen&&(o.isFullscreen=document.msIsFullScreen),o.isFullscreen&&o._pointerLockRequested&&(t.requestPointerLock=t.requestPointerLock||t.msRequestPointerLock||t.mozRequestPointerLock||t.webkitRequestPointerLock,t.requestPointerLock&&t.requestPointerLock())},document.addEventListener("fullscreenchange",this._onFullscreenChange,!1),document.addEventListener("mozfullscreenchange",this._onFullscreenChange,!1),document.addEventListener("webkitfullscreenchange",this._onFullscreenChange,!1),document.addEventListener("msfullscreenchange",this._onFullscreenChange,!1),this._onPointerLockChange=function(){o.isPointerLock=document.mozPointerLockElement===t||document.webkitPointerLockElement===t||document.msPointerLockElement===t||document.pointerLockElement===t},document.addEventListener("pointerlockchange",this._onPointerLockChange,!1),document.addEventListener("mspointerlockchange",this._onPointerLockChange,!1),document.addEventListener("mozpointerlockchange",this._onPointerLockChange,!1),document.addEventListener("webkitpointerlockchange",this._onPointerLockChange,!1),r.audioEngine&&e.AudioEngine&&!n.audioEngine&&(n.audioEngine=new e.AudioEngine),r.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 i=0;i<n.Instances.length;i++)for(var r=n.Instances[i],s=0;s<r.scenes.length;s++)r.scenes[s].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,"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,"Version",{get:function(){return"3.0-alpha"},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,"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 i=e.viewport;return this.getRenderWidth(t)*i.width/(this.getRenderHeight(t)*i.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 i=0;i<this._activeRenderLoops.length;i++){(0,this._activeRenderLoops[i])()}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,i,r){void 0===r&&(r=!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),i&&(this._gl.clearDepth(1),n|=this._gl.DEPTH_BUFFER_BIT),r&&(this._gl.clearStencil(0),n|=this._gl.STENCIL_BUFFER_BIT),this._gl.clear(n)},n.prototype.scissorClear=function(e,t,i,r,n){var s=this._gl,o=s.getParameter(s.SCISSOR_TEST),a=s.getParameter(s.SCISSOR_BOX);s.enable(s.SCISSOR_TEST),s.scissor(e,t,i,r),this.clear(n,!0,!0,!0),s.scissor(a[0],a[1],a[2],a[3]),!0===o?s.enable(s.SCISSOR_TEST):s.disable(s.SCISSOR_TEST)},n.prototype.setViewport=function(e,t,i){var r=t||(navigator.isCocoonJS?window.innerWidth:this.getRenderWidth()),n=i||(navigator.isCocoonJS?window.innerHeight:this.getRenderHeight()),s=e.x||0,o=e.y||0;this._cachedViewport=e,this._gl.viewport(s*r,o*n,r*e.width,n*e.height)},n.prototype.setDirectViewport=function(e,t,i,r){var n=this._cachedViewport;return this._cachedViewport=null,this._gl.viewport(e,t,i,r),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 i=0;i<this.scenes.length;i++)for(var r=this.scenes[i],n=0;n<r.cameras.length;n++){var s=r.cameras[n];s._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,i){if(!this.vrDisplaysPromise)return void i(null);this.vrDisplaysPromise.then((function(r){if(r.length>0)if(t){var n=r.some((function(e){return e.displayName===t&&(i(e),!0)}));n||(e.Tools.Warn("Display "+t+" was not found. Using "+r[0].displayName),i(r[0]))}else i(r[0]);else e.Tools.Error("No WebVR devices found!"),i(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,i,r){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,i||e._width,r||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,i){void 0===t&&(t=!1),this._currentRenderTarget=null;var r=this._gl;e._MSAAFramebuffer&&(r.bindFramebuffer(r.READ_FRAMEBUFFER,e._MSAAFramebuffer),r.bindFramebuffer(r.DRAW_FRAMEBUFFER,e._framebuffer),r.blitFramebuffer(0,0,e._width,e._height,0,0,e._width,e._height,r.COLOR_BUFFER_BIT,r.NEAREST)),e.generateMipMaps&&!t&&(this._bindTextureDirectly(r.TEXTURE_2D,e),r.generateMipmap(r.TEXTURE_2D),this._bindTextureDirectly(r.TEXTURE_2D,null)),i&&(e._MSAAFramebuffer&&this.bindUnboundFramebuffer(e._framebuffer),i()),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.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,i,r){this.bindUniformBuffer(e),void 0===i&&(i=0),void 0===r?t instanceof Float32Array?this._gl.bufferSubData(this._gl.UNIFORM_BUFFER,i,t):this._gl.bufferSubData(this._gl.UNIFORM_BUFFER,i,new Float32Array(t)):t instanceof Float32Array?this._gl.bufferSubData(this._gl.UNIFORM_BUFFER,0,t.subarray(i,i+r)):this._gl.bufferSubData(this._gl.UNIFORM_BUFFER,0,new Float32Array(t).subarray(i,i+r)),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,i,r){this.bindArrayBuffer(e),void 0===i&&(i=0),void 0===r?t instanceof Float32Array?this._gl.bufferSubData(this._gl.ARRAY_BUFFER,i,t):this._gl.bufferSubData(this._gl.ARRAY_BUFFER,i,new Float32Array(t)):t instanceof Float32Array?this._gl.bufferSubData(this._gl.ARRAY_BUFFER,0,t.subarray(i,i+r)):this._gl.bufferSubData(this._gl.ARRAY_BUFFER,0,new Float32Array(t).subarray(i,i+r)),this._resetVertexBufferBinding()},n.prototype._resetIndexBufferBinding=function(){this.bindIndexBuffer(null),this._cachedIndexBuffer=null},n.prototype.createIndexBuffer=function(e){var t=this._gl.createBuffer();this.bindIndexBuffer(t);var i,r=!1;if(e instanceof Uint16Array)i=e;else if(this._caps.uintIndices)if(e instanceof Uint32Array)i=e,r=!0;else{for(var n=0;n<e.length;n++)if(e[n]>65535){r=!0;break}i=r?new Uint32Array(e):new Uint16Array(e)}else i=new Uint16Array(e);return this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER,i,this._gl.STATIC_DRAW),this._resetIndexBufferBinding(),t.references=1,t.is32Bits=r,t},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,i){var r=this._gl.getUniformBlockIndex(e,t);this._gl.uniformBlockBinding(e,r,i)},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,i,r,n,s,o){var a=this._currentBufferPointers[t],h=!1;a?(a.buffer!==e&&(a.buffer=e,h=!0),a.size!==i&&(a.size=i,h=!0),a.type!==r&&(a.type=r,h=!0),a.normalized!==n&&(a.normalized=n,h=!0),a.stride!==s&&(a.stride=s,h=!0),a.offset!==o&&(a.offset=o,h=!0)):(h=!0,this._currentBufferPointers[t]={indx:t,size:i,type:r,normalized:n,stride:s,offset:o,buffer:e}),(h||this._vaoRecordInProgress)&&(this.bindArrayBuffer(e),this._gl.vertexAttribPointer(t,i,r,n,s,o))},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 i=t.getAttributesNames();this._vaoRecordInProgress||this._unBindVertexArrayObject(),this.unbindAllAttributes();for(var r=0;r<i.length;r++){var n=t.getAttributeLocation(r);if(n>=0){var s=e[i[r]];if(!s)continue;this._gl.enableVertexAttribArray(n),this._vaoRecordInProgress||(this._vertexAttribArraysEnabled[n]=!0);var o=s.getBuffer();this.vertexAttribPointer(o,n,s.getSize(),this._gl.FLOAT,!1,4*s.getStrideSize(),4*s.getOffset()),s.getIsInstanced()&&(this._gl.vertexAttribDivisor(n,1),this._vaoRecordInProgress||(this._currentInstanceLocations.push(n),this._currentInstanceBuffers.push(o)))}}},n.prototype.recordVertexArrayObject=function(e,t,i){var r=this._gl.createVertexArray();return this._vaoRecordInProgress=!0,this._gl.bindVertexArray(r),this._mustWipeVertexAttributes=!0,this._bindVertexBuffersAttributes(e,i),this.bindIndexBuffer(t),this._vaoRecordInProgress=!1,this._gl.bindVertexArray(null),r},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,i,r,n){if(this._cachedVertexBuffers!==e||this._cachedEffectForVertexBuffers!==n){this._cachedVertexBuffers=e,this._cachedEffectForVertexBuffers=n;var s=n.getAttributesCount();this._unBindVertexArrayObject(),this.unbindAllAttributes();for(var o=0,a=0;a<s;a++)if(a<i.length){var h=n.getAttributeLocation(a);h>=0&&(this._gl.enableVertexAttribArray(h),this._vertexAttribArraysEnabled[h]=!0,this.vertexAttribPointer(e,h,i[a],this._gl.FLOAT,!1,r,o)),o+=4*i[a]}}this._bindIndexBufferWithCache(t)},n.prototype._unBindVertexArrayObject=function(){this._cachedVertexArrayObject&&(this._cachedVertexArrayObject=null,this._gl.bindVertexArray(null))},n.prototype.bindBuffers=function(e,t,i){this._cachedVertexBuffers===e&&this._cachedEffectForVertexBuffers===i||(this._cachedVertexBuffers=e,this._cachedEffectForVertexBuffers=i,this._bindVertexBuffersAttributes(e,i)),this._bindIndexBufferWithCache(t)},n.prototype.unbindInstanceAttributes=function(){for(var e,t=0,i=this._currentInstanceLocations.length;t<i;t++){var r=this._currentInstanceBuffers[t];e!=r&&r.references&&(e=r,this.bindArrayBuffer(r));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,i){if(this.bindArrayBuffer(e),t&&this._gl.bufferSubData(this._gl.ARRAY_BUFFER,0,t),void 0!==i[0].index){for(var r=0,n=0;n<i.length;n++){var s=i[n];r+=4*s.attributeSize}for(var n=0;n<i.length;n++){var s=i[n];this._vertexAttribArraysEnabled[s.index]||(this._gl.enableVertexAttribArray(s.index),this._vertexAttribArraysEnabled[s.index]=!0),this.vertexAttribPointer(e,s.index,s.attributeSize,s.attribyteType||this._gl.FLOAT,s.normalized||!1,r,s.offset),this._gl.vertexAttribDivisor(s.index,1),this._currentInstanceLocations.push(s.index),this._currentInstanceBuffers.push(e)}}else for(var o=0;o<4;o++){var a=i[o]
  5. ;this._vertexAttribArraysEnabled[a]||(this._gl.enableVertexAttribArray(a),this._vertexAttribArraysEnabled[a]=!0),this.vertexAttribPointer(e,a,4,this._gl.FLOAT,!1,64,16*o),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,i,r){this.applyStates(),this._drawCalls.addCount(1,!1);var n=this._uintIndicesCurrentlySet?this._gl.UNSIGNED_INT:this._gl.UNSIGNED_SHORT,s=this._uintIndicesCurrentlySet?4:2;if(r)return void this._gl.drawElementsInstanced(e?this._gl.TRIANGLES:this._gl.LINES,i,n,t*s,r);this._gl.drawElements(e?this._gl.TRIANGLES:this._gl.LINES,i,n,t*s)},n.prototype.drawPointClouds=function(e,t,i){if(this.applyStates(),this._drawCalls.addCount(1,!1),i)return void this._gl.drawArraysInstanced(this._gl.POINTS,e,t,i);this._gl.drawArrays(this._gl.POINTS,e,t)},n.prototype.drawUnIndexed=function(e,t,i,r){if(this.applyStates(),this._drawCalls.addCount(1,!1),r)return void this._gl.drawArraysInstanced(e?this._gl.TRIANGLES:this._gl.LINES,t,i,r);this._gl.drawArrays(e?this._gl.TRIANGLES:this._gl.LINES,t,i)},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,i,r,n,s,o,a,h,u){var c=t.vertexElement||t.vertex||t,l=t.fragmentElement||t.fragment||t,f=c+"+"+l+"@"+(s||i.defines);if(this._compiledEffects[f])return this._compiledEffects[f];var d=new e.Effect(t,i,r,n,this,s,o,a,h,u);return d._key=f,this._compiledEffects[f]=d,d},n.prototype.createEffectForParticles=function(e,t,i,r,n,s,o){return void 0===t&&(t=[]),void 0===i&&(i=[]),void 0===r&&(r=""),this.createEffect({vertex:"particles",fragmentElement:e},["position","color","options"],["view","projection"].concat(t),["diffuseSampler"].concat(i),r,n,s,o)},n.prototype.createShaderProgram=function(e,i,r,n){n=n||this._gl;var s=this._webGLVersion>1?"#version 300 es\n":"",o=t(n,e,"vertex",r,s),a=t(n,i,"fragment",r,s),h=n.createProgram();if(n.attachShader(h,o),n.attachShader(h,a),n.linkProgram(h),!n.getProgramParameter(h,n.LINK_STATUS)){var u=n.getProgramInfoLog(h);if(u)throw new Error(u)}return n.deleteShader(o),n.deleteShader(a),h},n.prototype.getUniforms=function(e,t){for(var i=[],r=0;r<t.length;r++)i.push(this._gl.getUniformLocation(e,t[r]));return i},n.prototype.getAttributes=function(e,t){for(var i=[],r=0;r<t.length;r++)try{i.push(this._gl.getAttribLocation(e,t[r]))}catch(e){i.push(-1)}return i},n.prototype.enableEffect=function(e){this.setProgram(e.getProgram()),this._currentEffect=e,e.onBind&&e.onBind(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,i){e&&this._gl.uniform2f(e,t,i)},n.prototype.setFloat3=function(e,t,i,r){e&&this._gl.uniform3f(e,t,i,r)},n.prototype.setBool=function(e,t){e&&this._gl.uniform1i(e,t)},n.prototype.setFloat4=function(e,t,i,r,n){e&&this._gl.uniform4f(e,t,i,r,n)},n.prototype.setColor3=function(e,t){e&&this._gl.uniform3f(e,t.r,t.g,t.b)},n.prototype.setColor4=function(e,t,i){e&&this._gl.uniform4f(e,t.r,t.g,t.b,i)},n.prototype.setState=function(e,t,i,r){void 0===t&&(t=0),void 0===r&&(r=!1);var n=r?this._gl.FRONT:this._gl.BACK,s=r?this._gl.BACK:this._gl.FRONT,o=this.cullBackFaces?n:s;(this._depthCullingState.cull!==e||i||this._depthCullingState.cullFace!==o)&&(e?(this._depthCullingState.cullFace=o,this._depthCullingState.cull=!0):this._depthCullingState.cull=!1),this._depthCullingState.zOffset=t},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.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}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(){this.preventCacheWipeBetweenFrames||(this.resetTextureCache(),this._currentEffect=null,this._stencilState.reset(),this._depthCullingState.reset(),this.setDepthFunctionToLessOrEqual(),this._alphaState.reset(),this._cachedVertexBuffers=null,this._cachedIndexBuffer=null,this._cachedEffectForVertexBuffers=null,this._unBindVertexArrayObject(),this.bindIndexBuffer(null),this.bindArrayBuffer(null))},n.prototype.setTextureFormatToUse=function(e){for(var t=0,i=this.texturesSupported.length;t<i;t++)for(var r=0,n=e.length;r<n;r++)if(this._texturesSupported[t]===e[r].toLowerCase())return this._textureFormatInUse=this._texturesSupported[t];return this._textureFormatInUse=null},n.prototype.createTexture=function(t,i,n,s,o,a,h,u,c,l){var f=this;void 0===o&&(o=e.Texture.TRILINEAR_SAMPLINGMODE),void 0===a&&(a=null),void 0===h&&(h=null),void 0===u&&(u=null);var d=c||this._gl.createTexture(),p=String(t),_="data:"===p.substr(0,5),m=_&&-1!==p.indexOf("base64"),g=p.lastIndexOf("."),y=g>0?p.substring(g).toLowerCase():"",v=this.getCaps().s3tc&&".dds"===y;v&&e.Tools.Warn("DDS files deprecated since 3.0, use KTX files");var b=".tga"===y,x=!1;!this._textureFormatInUse||m||c||(p=p.substring(0,g)+this._textureFormatInUse,x=!0),s._addPendingData(d),d.url=p,d.noMipmap=i,d.references=1,d.samplingMode=o,d.onLoadedCallbacks=[],a&&d.onLoadedCallbacks.push(a),c||this._loadedTexturesCache.push(d);var T,E=function(){s._removePendingData(d),x?f.createTexture(t,i,n,s,o,null,h,u,d):h&&h()};if(x||b||v)x?T=function(t){var a=new e.Internals.KhronosTextureContainer(t,1);r(d,f._gl,s,a.pixelWidth,a.pixelHeight,n,!1,!0,(function(){a.uploadLevels(f._gl,!i)}),o)}:b?T=function(t){var a=new Uint8Array(t),h=e.Internals.TGATools.GetTGAHeader(a);r(d,f._gl,s,h.width,h.height,n,i,!1,(function(){e.Internals.TGATools.UploadContent(f._gl,a)}),o)}:v&&(T=function(t){var a=e.Internals.DDSTools.GetDDSInfo(t),h=(a.isRGB||a.isLuminance||a.mipmapCount>1)&&!i&&a.width>>a.mipmapCount-1==1;r(d,f._gl,s,a.width,a.height,n,!h,a.isFourCC,(function(){e.Internals.DDSTools.UploadDDSLevels(f._gl,f.getCaps().s3tc,t,a,h,1)}),o)}),u?T(u):e.Tools.LoadFile(p,(function(e){T(e)}),null,s.database,!0,E);else{var A=function(t){r(d,f._gl,s,t.width,t.height,n,i,!1,(function(i,r){var n=t.width===i&&t.height===r;n||(f._prepareWorkingCanvas(),f._workingCanvas.width=i,f._workingCanvas.height=r,o===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,i,r),o===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 s=l?f._getInternalFormat(l):".jpg"===y?f._gl.RGB:f._gl.RGBA;f._gl.texImage2D(f._gl.TEXTURE_2D,0,s,s,f._gl.UNSIGNED_BYTE,n?t:f._workingCanvas)}),o)};!_||m?e.Tools.LoadImage(p,A,E,s.database):u instanceof Array||"string"==typeof u?e.Tools.LoadImage(u,A,E,s.database):A(u)}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,i,r,n){void 0===n&&(n=null);var s=this._getInternalFormat(i);this._bindTextureDirectly(this._gl.TEXTURE_2D,e),this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL,void 0===r?1:r?1:0),e._width%4!=0&&this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT,1),n?this._gl.compressedTexImage2D(this._gl.TEXTURE_2D,0,this.getCaps().s3tc[n],e._width,e._height,0,t):this._gl.texImage2D(this._gl.TEXTURE_2D,0,s,e._width,e._height,0,s,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,r,n,s,o,a,h){void 0===h&&(h=null);var u=this._gl.createTexture();u._baseWidth=t,u._baseHeight=r,u._width=t,u._height=r,u.references=1,this.updateRawTexture(u,e,n,o,h),this._bindTextureDirectly(this._gl.TEXTURE_2D,u);var c=i(a,s,this._gl);return this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MAG_FILTER,c.mag),this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MIN_FILTER,c.min),s&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(this._gl.TEXTURE_2D,null),u.samplingMode=a,this._loadedTexturesCache.push(u),u},n.prototype.createDynamicTexture=function(t,i,r,n){var s=this._gl.createTexture();return s._baseWidth=t,s._baseHeight=i,r&&(t=e.Tools.GetExponentOfTwo(t,this._caps.maxTextureSize),i=e.Tools.GetExponentOfTwo(i,this._caps.maxTextureSize)),this.resetTextureCache(),s._width=t,s._height=i,s.isReady=!1,s.generateMipMaps=r,s.references=1,s.samplingMode=n,this.updateTextureSamplingMode(n,s),this._loadedTexturesCache.push(s),s},n.prototype.updateTextureSamplingMode=function(e,t){var r=i(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,r.mag),this._gl.texParameteri(this._gl.TEXTURE_CUBE_MAP,this._gl.TEXTURE_MIN_FILTER,r.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,r.mag),this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MIN_FILTER,r.min),this._bindTextureDirectly(this._gl.TEXTURE_2D,null)),t.samplingMode=e},n.prototype.updateDynamicTexture=function(e,t,i,r,n){void 0===r&&(r=!1),this._bindTextureDirectly(this._gl.TEXTURE_2D,e),this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL,i?1:0),r&&this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,1);var s=n?this._getInternalFormat(n):this._gl.RGBA;this._gl.texImage2D(this._gl.TEXTURE_2D,0,s,s,this._gl.UNSIGNED_BYTE,t),e.generateMipMaps&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(this._gl.TEXTURE_2D,null),r&&this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),this.resetTextureCache(),e.isReady=!0},n.prototype.updateVideoTexture=function(e,t,i){if(!e._isDisabled){this._bindTextureDirectly(this._gl.TEXTURE_2D,e),this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL,i?0:1);try{void 0===this._videoTextureSupported&&(this._gl.texImage2D(this._gl.TEXTURE_2D,0,this._gl.RGBA,this._gl.RGBA,this._gl.UNSIGNED_BYTE,t),0!==this._gl.getError()?this._videoTextureSupported=!1:this._videoTextureSupported=!0),this._videoTextureSupported?this._gl.texImage2D(this._gl.TEXTURE_2D,0,this._gl.RGBA,this._gl.RGBA,this._gl.UNSIGNED_BYTE,t):(e._workingCanvas||(e._workingCanvas=document.createElement("canvas"),e._workingContext=e._workingCanvas.getContext("2d"),e._workingCanvas.width=e._width,e._workingCanvas.height=e._height),e._workingContext.drawImage(t,0,0,t.videoWidth,t.videoHeight,0,0,e._width,e._height),this._gl.texImage2D(this._gl.TEXTURE_2D,0,this._gl.RGBA,this._gl.RGBA,this._gl.UNSIGNED_BYTE,e._workingCanvas)),e.generateMipMaps&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(this._gl.TEXTURE_2D,null),this.resetTextureCache(),e.isReady=!0}catch(t){e._isDisabled=!0}}},n.prototype.createRenderTargetTexture=function(t,r){var s=!1,o=!0,a=!1,h=n.TEXTURETYPE_UNSIGNED_INT,u=e.Texture.TRILINEAR_SAMPLINGMODE;void 0!==r&&(s=void 0===r.generateMipMaps?r:r.generateMipMaps,o=void 0===r.generateDepthBuffer||r.generateDepthBuffer,a=o&&r.generateStencilBuffer,h=void 0===r.type?h:r.type,void 0!==r.samplingMode&&(u=r.samplingMode),h!==n.TEXTURETYPE_FLOAT||this._caps.textureFloatLinearFiltering?h!==n.TEXTURETYPE_HALF_FLOAT||this._caps.textureHalfFloatLinearFiltering||(u=e.Texture.NEAREST_SAMPLINGMODE):u=e.Texture.NEAREST_SAMPLINGMODE);var c=this._gl,l=c.createTexture();this._bindTextureDirectly(c.TEXTURE_2D,l);var f=t.width||t,d=t.height||t,p=i(u,s,c);h!==n.TEXTURETYPE_FLOAT||this._caps.textureFloat||(h=n.TEXTURETYPE_UNSIGNED_INT,e.Tools.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type")),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MAG_FILTER,p.mag),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_MIN_FILTER,p.min),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE),c.texParameteri(c.TEXTURE_2D,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE),c.texImage2D(c.TEXTURE_2D,0,this._getRGBABufferInternalSizedFormat(h),f,d,0,c.RGBA,this._getWebGLTextureType(h),null);var _=c.createFramebuffer();return this.bindUnboundFramebuffer(_),c.framebufferTexture2D(c.FRAMEBUFFER,c.COLOR_ATTACHMENT0,c.TEXTURE_2D,l,0),l._depthStencilBuffer=this._setupFramebufferDepthAttachments(a,o,f,d),s&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(c.TEXTURE_2D,null),c.bindRenderbuffer(c.RENDERBUFFER,null),this.bindUnboundFramebuffer(null),l._framebuffer=_,l._baseWidth=f,l._baseHeight=d,l._width=f,l._height=d,l.isReady=!0,l.samples=1,l.generateMipMaps=s,l.references=1,l.samplingMode=u,l.type=h,l._generateDepthBuffer=o,l._generateStencilBuffer=a,this.resetTextureCache(),this._loadedTexturesCache.push(l),l},n.prototype._setupFramebufferDepthAttachments=function(e,t,i,r,n){void 0===n&&(n=1);var s=null,o=this._gl;return e?(s=o.createRenderbuffer(),o.bindRenderbuffer(o.RENDERBUFFER,s),n>1?o.renderbufferStorageMultisample(o.RENDERBUFFER,n,o.DEPTH_STENCIL,i,r):o.renderbufferStorage(o.RENDERBUFFER,o.DEPTH_STENCIL,i,r),o.framebufferRenderbuffer(o.FRAMEBUFFER,o.DEPTH_STENCIL_ATTACHMENT,o.RENDERBUFFER,s)):t&&(s=o.createRenderbuffer(),o.bindRenderbuffer(o.RENDERBUFFER,s),n>1?o.renderbufferStorageMultisample(o.RENDERBUFFER,n,o.DEPTH_COMPONENT16,i,r):o.renderbufferStorage(o.RENDERBUFFER,o.DEPTH_COMPONENT16,i,r),o.framebufferRenderbuffer(o.FRAMEBUFFER,o.DEPTH_ATTACHMENT,o.RENDERBUFFER,s)),s},n.prototype.updateRenderTargetTextureSampleCount=function(e,t){if(this.webGLVersion<2)return 1;if(e.samples===t)return t;var i=this._gl;if(t=Math.min(t,i.getParameter(i.MAX_SAMPLES)),e._depthStencilBuffer&&i.deleteRenderbuffer(e._depthStencilBuffer),e._MSAAFramebuffer&&i.deleteFramebuffer(e._MSAAFramebuffer),e._MSAARenderBuffer&&i.deleteRenderbuffer(e._MSAARenderBuffer),t>1){e._MSAAFramebuffer=i.createFramebuffer(),this.bindUnboundFramebuffer(e._MSAAFramebuffer);var r=i.createRenderbuffer();i.bindRenderbuffer(i.RENDERBUFFER,r),i.renderbufferStorageMultisample(i.RENDERBUFFER,t,i.RGBA8,e._width,e._height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,r),e._MSAARenderBuffer=r}else this.bindUnboundFramebuffer(e._framebuffer);return e.samples=t,e._depthStencilBuffer=this._setupFramebufferDepthAttachments(e._generateStencilBuffer,e._generateDepthBuffer,e._width,e._height,t),i.bindRenderbuffer(i.RENDERBUFFER,null),this.bindUnboundFramebuffer(null),t},n.prototype.createRenderTargetCubeTexture=function(t,r){var n=this._gl,s=n.createTexture(),o=!0,a=!0,h=!1,u=e.Texture.TRILINEAR_SAMPLINGMODE;void 0!==r&&(o=void 0===r.generateMipMaps?r:r.generateMipMaps,a=void 0===r.generateDepthBuffer||r.generateDepthBuffer,h=a&&r.generateStencilBuffer,void 0!==r.samplingMode&&(u=r.samplingMode)),s.isCube=!0,s.references=1,s.generateMipMaps=o,s.references=1,s.samples=1,s.samplingMode=u;var c=i(u,o,n);this._bindTextureDirectly(n.TEXTURE_CUBE_MAP,s);for(var l=0;l<6;l++)n.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+l,0,n.RGBA,t,t,0,n.RGBA,n.UNSIGNED_BYTE,null);n.texParameteri(n.TEXTURE_CUBE_MAP,n.TEXTURE_MAG_FILTER,c.mag),n.texParameteri(n.TEXTURE_CUBE_MAP,n.TEXTURE_MIN_FILTER,c.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),s._depthStencilBuffer=this._setupFramebufferDepthAttachments(h,a,t,t),s.generateMipMaps&&(this._bindTextureDirectly(n.TEXTURE_CUBE_MAP,s),n.generateMipmap(n.TEXTURE_CUBE_MAP)),this._bindTextureDirectly(n.TEXTURE_CUBE_MAP,null),n.bindRenderbuffer(n.RENDERBUFFER,null),this.bindUnboundFramebuffer(null),s._framebuffer=f,s._width=t,s._height=t,s.isReady=!0,this.resetTextureCache(),this._loadedTexturesCache.push(s),s},n.prototype.createCubeTexture=function(t,i,r,n,o,a,h){var u=this;void 0===o&&(o=null),void 0===a&&(a=null);var c=this._gl,l=c.createTexture();l.isCube=!0,l.url=t,l.references=1,l.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 i=new e.Internals.KhronosTextureContainer(t,6),r=i.numberOfMipmapLevels>1&&!n;u._bindTextureDirectly(c.TEXTURE_CUBE_MAP,l),c.pixelStorei(c.UNPACK_FLIP_Y_WEBGL,1),i.uploadLevels(u._gl,!n),c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MAG_FILTER,c.LINEAR),c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MIN_FILTER,r?c.LINEAR_MIPMAP_LINEAR:c.LINEAR),c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE),c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE),u._bindTextureDirectly(c.TEXTURE_CUBE_MAP,null),u.resetTextureCache(),l._width=i.pixelWidth,l._height=i.pixelHeight,l.isReady=!0}),null,null,!0,a):_?e.Tools.LoadFile(t,(function(t){var i=e.Internals.DDSTools.GetDDSInfo(t),r=(i.isRGB||i.isLuminance||i.mipmapCount>1)&&!n;u._bindTextureDirectly(c.TEXTURE_CUBE_MAP,l),c.pixelStorei(c.UNPACK_FLIP_Y_WEBGL,1),e.Internals.DDSTools.UploadDDSLevels(u._gl,u.getCaps().s3tc,t,i,r,6),n||i.isFourCC||1!==i.mipmapCount||c.generateMipmap(c.TEXTURE_CUBE_MAP),c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MAG_FILTER,c.LINEAR),c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MIN_FILTER,r?c.LINEAR_MIPMAP_LINEAR:c.LINEAR),c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE),c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE),u._bindTextureDirectly(c.TEXTURE_CUBE_MAP,null),u.resetTextureCache(),l._width=i.width,l._height=i.height,l.isReady=!0}),null,null,!0,a):s(0,i,(function(t){var i=e.Tools.GetExponentOfTwo(t[0].width,u._caps.maxCubemapTextureSize),r=i;u._prepareWorkingCanvas(),u._workingCanvas.width=i,u._workingCanvas.height=r;var s=[c.TEXTURE_CUBE_MAP_POSITIVE_X,c.TEXTURE_CUBE_MAP_POSITIVE_Y,c.TEXTURE_CUBE_MAP_POSITIVE_Z,c.TEXTURE_CUBE_MAP_NEGATIVE_X,c.TEXTURE_CUBE_MAP_NEGATIVE_Y,c.TEXTURE_CUBE_MAP_NEGATIVE_Z];u._bindTextureDirectly(c.TEXTURE_CUBE_MAP,l),c.pixelStorei(c.UNPACK_FLIP_Y_WEBGL,0);for(var a=h?u._getInternalFormat(h):u._gl.RGBA,f=0;f<s.length;f++)u._workingContext.drawImage(t[f],0,0,t[f].width,t[f].height,0,0,i,r),c.texImage2D(s[f],0,a,a,c.UNSIGNED_BYTE,u._workingCanvas);n||c.generateMipmap(c.TEXTURE_CUBE_MAP),c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MAG_FILTER,c.LINEAR),c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MIN_FILTER,n?c.LINEAR:c.LINEAR_MIPMAP_LINEAR),c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE),c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE),u._bindTextureDirectly(c.TEXTURE_CUBE_MAP,null),u.resetTextureCache(),l._width=i,l._height=r,l.isReady=!0,l.onLoadedCallbacks.forEach((function(e){e()})),o&&o()}),r,a),this._loadedTexturesCache.push(l),l},n.prototype.updateTextureSize=function(e,t,i){e._width=t,e._height=i,e._size=t*i,e._baseWidth=t,e._baseHeight=i},n.prototype.createRawCubeTexture=function(t,i,r,s,o,a,h,u,c,l){var f=this;void 0===c&&(c=null),void 0===l&&(l=null);var d=this._gl,p=d.createTexture();i._addPendingData(p),p.isCube=!0,p.references=1,p.url=t;var _=d.UNSIGNED_BYTE;o===n.TEXTURETYPE_FLOAT&&(_=d.FLOAT);var m=this._getInternalFormat(s),g=!1;m===d.RGB&&(m=d.RGBA,g=!0);var y=this._getRGBABufferInternalSizedFormat(o),v=r,b=v,x=e.Tools.IsExponentOfTwo(v)&&e.Tools.IsExponentOfTwo(b);p._width=v,p._height=b;var T=function(){i._removePendingData(p),l&&l()},E=function(t){var r=h(t),s=[d.TEXTURE_CUBE_MAP_POSITIVE_X,d.TEXTURE_CUBE_MAP_POSITIVE_Y,d.TEXTURE_CUBE_MAP_POSITIVE_Z,d.TEXTURE_CUBE_MAP_NEGATIVE_X,d.TEXTURE_CUBE_MAP_NEGATIVE_Y,d.TEXTURE_CUBE_MAP_NEGATIVE_Z];if(v=p._width,b=p._height,x=e.Tools.IsExponentOfTwo(v)&&e.Tools.IsExponentOfTwo(b),f._bindTextureDirectly(d.TEXTURE_CUBE_MAP,p),d.pixelStorei(d.UNPACK_FLIP_Y_WEBGL,0),u){var l=[];l.push(r[0]),l.push(r[3]),l.push(r[1]),l.push(r[4]),l.push(r[2]),l.push(r[5]);for(var T=u(l),E=[0,2,4,1,3,5],A=0;A<T.length;A++){var M=v>>A;for(var P in E){var O=T[A][E[P]];g&&(O=f._convertRGBtoRGBATextureData(O,M,M,o)),d.texImage2D(s[P],A,y,M,M,0,m,_,O)}}}else{for(var R=0;R<s.length;R++){var C=r[R];g&&(C=f._convertRGBtoRGBATextureData(C,v,b,o)),d.texImage2D(s[R],0,y,v,b,0,m,_,C)}!a&&x?d.generateMipmap(d.TEXTURE_CUBE_MAP):a=!0}(_!==d.FLOAT||f._caps.textureFloatLinearFiltering)&&(_!==n.HALF_FLOAT_OES||f._caps.textureHalfFloatLinearFiltering)?(d.texParameteri(d.TEXTURE_CUBE_MAP,d.TEXTURE_MAG_FILTER,d.LINEAR),d.texParameteri(d.TEXTURE_CUBE_MAP,d.TEXTURE_MIN_FILTER,a?d.LINEAR:d.LINEAR_MIPMAP_LINEAR)):(d.texParameteri(d.TEXTURE_CUBE_MAP,d.TEXTURE_MAG_FILTER,d.NEAREST),d.texParameteri(d.TEXTURE_CUBE_MAP,d.TEXTURE_MIN_FILTER,d.NEAREST)),d.texParameteri(d.TEXTURE_CUBE_MAP,d.TEXTURE_WRAP_S,d.CLAMP_TO_EDGE),d.texParameteri(d.TEXTURE_CUBE_MAP,d.TEXTURE_WRAP_T,d.CLAMP_TO_EDGE),f._bindTextureDirectly(d.TEXTURE_CUBE_MAP,null),p.isReady=!0,f.resetTextureCache(),i._removePendingData(p),c&&c()};return e.Tools.LoadFile(t,(function(e){E(e)}),T,i.database,!0),p},n.prototype._convertRGBtoRGBATextureData=function(e,t,i,r){var s;s=r===n.TEXTURETYPE_FLOAT?new Float32Array(t*i*4):new Uint32Array(t*i*4);for(var o=0;o<t;o++)for(var a=0;a<i;a++){var h=3*(a*t+o),u=4*(a*t+o);s[u+0]=e[h+0],s[u+1]=e[h+1],s[u+2]=e[h+2],s[u+3]=1}return s},n.prototype._releaseTexture=function(e){var t=this._gl;e._framebuffer&&t.deleteFramebuffer(e._framebuffer),e._depthStencilBuffer&&t.deleteRenderbuffer(e._depthStencilBuffer),e._MSAAFramebuffer&&t.deleteFramebuffer(e._MSAAFramebuffer),e._MSAARenderBuffer&&t.deleteRenderbuffer(e._MSAARenderBuffer),t.deleteTexture(e),this.unbindAllTextures();var i=this._loadedTexturesCache.indexOf(e);-1!==i&&this._loadedTexturesCache.splice(i,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(),i=0;i<t.length;i++){var r=e.getUniform(t[i]);this._gl.uniform1i(r,i)}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,i){e<0||(this._gl.uniform1i(t,e),this._setTexture(e,i))},n.prototype._setTexture=function(t,i){if(!i||!i.isReady())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 r=!1;if(i.video)this.activateTexture(this._gl["TEXTURE"+t]),r=!0,i.update();else if(i.delayLoadState===n.DELAYLOADSTATE_NOTLOADED)return void i.delayLoad();var s=i.getInternalTexture();if(this._activeTexturesCache[t]!==s)if(r||this.activateTexture(this._gl["TEXTURE"+t]),s.isCube){if(this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,s),s._cachedCoordinatesMode!==i.coordinatesMode){s._cachedCoordinatesMode=i.coordinatesMode;var o=i.coordinatesMode!==e.Texture.CUBIC_MODE&&i.coordinatesMode!==e.Texture.SKYBOX_MODE?this._gl.REPEAT:this._gl.CLAMP_TO_EDGE;this._gl.texParameteri(this._gl.TEXTURE_CUBE_MAP,this._gl.TEXTURE_WRAP_S,o),this._gl.texParameteri(this._gl.TEXTURE_CUBE_MAP,this._gl.TEXTURE_WRAP_T,o)}this._setAnisotropicLevel(this._gl.TEXTURE_CUBE_MAP,i)}else{if(this._bindTextureDirectly(this._gl.TEXTURE_2D,s),s._cachedWrapU!==i.wrapU)switch(s._cachedWrapU=i.wrapU,i.wrapU){case e.Texture.WRAP_ADDRESSMODE:this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_WRAP_S,this._gl.REPEAT);break;case e.Texture.CLAMP_ADDRESSMODE:this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_WRAP_S,this._gl.CLAMP_TO_EDGE);break;case e.Texture.MIRROR_ADDRESSMODE:this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_WRAP_S,this._gl.MIRRORED_REPEAT)}if(s._cachedWrapV!==i.wrapV)switch(s._cachedWrapV=i.wrapV,i.wrapV){case e.Texture.WRAP_ADDRESSMODE:this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_WRAP_T,this._gl.REPEAT);break;case e.Texture.CLAMP_ADDRESSMODE:this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_WRAP_T,this._gl.CLAMP_TO_EDGE);break;case e.Texture.MIRROR_ADDRESSMODE:this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_WRAP_T,this._gl.MIRRORED_REPEAT)}this._setAnisotropicLevel(this._gl.TEXTURE_2D,i)}},n.prototype.setTextureArray=function(e,t,i){if(!(e<0)){this._textureUnits&&this._textureUnits.length===i.length||(this._textureUnits=new Int32Array(i.length));for(var r=0;r<i.length;r++)this._textureUnits[r]=e+r;this._gl.uniform1iv(t,this._textureUnits);for(var n=0;n<i.length;n++)this._setTexture(e+n,i[n])}},n.prototype._setAnisotropicLevel=function(t,i){var r=this._caps.textureAnisotropicFilterExtension,n=i.anisotropicFilteringLevel;i.getInternalTexture().samplingMode===e.Texture.NEAREST_SAMPLINGMODE&&(n=1),r&&i._cachedAnisotropicFilteringLevel!==n&&(this._gl.texParameterf(t,r.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(n,this._caps.maxAnisotropy)),i._cachedAnisotropicFilteringLevel=n)},n.prototype.readPixels=function(e,t,i,r){var n=new Uint8Array(r*i*4);return this._gl.readPixels(e,t,i,r,this._gl.RGBA,this._gl.UNSIGNED_BYTE,n),n},n.prototype.addExternalData=function(t,i){return this._externalData||(this._externalData=new e.StringDictionary),this._externalData.add(t,i)},n.prototype.getExternalData=function(t){return this._externalData||(this._externalData=new e.StringDictionary),this._externalData.get(t)},n.prototype.getOrAddExternalDataWithFactory=function(t,i){return this._externalData||(this._externalData=new e.StringDictionary),this._externalData.getOrAddWithFactory(t,i)},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(),i=t.indexOf(e);i>-1&&t.splice(i,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.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),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)},
  6. 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.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 i=0,r=0;r<t-1;r++)i+=this.previousFramesDuration[r+1]-this.previousFramesDuration[r];this.fps=1e3/(i/(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 i=!0,r=t.createTexture();t.bindTexture(t.TEXTURE_2D,r),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,r,0);var s=t.checkFramebufferStatus(t.FRAMEBUFFER);if(i=i&&s===t.FRAMEBUFFER_COMPLETE,i=i&&t.getError()===t.NO_ERROR,i&&(t.clear(t.COLOR_BUFFER_BIT),i=i&&t.getError()===t.NO_ERROR),i){t.bindFramebuffer(t.FRAMEBUFFER,null);var o=t.RGBA,a=t.UNSIGNED_BYTE,h=new Uint8Array(4);t.readPixels(0,0,1,1,o,a,h),i=i&&t.getError()===t.NO_ERROR}for(t.deleteTexture(r),t.deleteFramebuffer(n),t.bindFramebuffer(t.FRAMEBUFFER,null);!i&&t.getError()!==t.NO_ERROR;);return i},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})();h.Instances=new Array,h._ALPHA_DISABLE=0,h._ALPHA_ADD=1,h._ALPHA_COMBINE=2,h._ALPHA_SUBTRACT=3,h._ALPHA_MULTIPLY=4,h._ALPHA_MAXIMIZED=5,h._ALPHA_ONEONE=6,h._ALPHA_PREMULTIPLIED=7,h._ALPHA_PREMULTIPLIED_PORTERDUFF=8,h._DELAYLOADSTATE_NONE=0,h._DELAYLOADSTATE_LOADED=1,h._DELAYLOADSTATE_LOADING=2,h._DELAYLOADSTATE_NOTLOADED=4,h._TEXTUREFORMAT_ALPHA=0,h._TEXTUREFORMAT_LUMINANCE=1,h._TEXTUREFORMAT_LUMINANCE_ALPHA=2,h._TEXTUREFORMAT_RGB=4,h._TEXTUREFORMAT_RGBA=5,h._TEXTURETYPE_UNSIGNED_INT=0,h._TEXTURETYPE_FLOAT=1,h._TEXTURETYPE_HALF_FLOAT=2,h._NEVER=512,h._ALWAYS=519,h._LESS=513,h._EQUAL=514,h._LEQUAL=515,h._GREATER=516,h._GEQUAL=518,h._NOTEQUAL=517,h.HALF_FLOAT_OES=36193,h.RGBA16F=34842,h.RGBA32F=34836,h._KEEP=7680,h._REPLACE=7681,h._INCR=7682,h._DECR=7683,h._INVERT=5386,h._INCR_WRAP=34055,h._DECR_WRAP=34056,h.CollisionsEpsilon=.001,h.CodeRepository="src/",h.ShadersRepository="src/Shaders/",e.Engine=h})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(t,i){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=i||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,i){if(void 0===t&&(t=!1),this._children)for(var r=0;r<this._children.length;r++){var n=this._children[r];i&&!i(n)||e.push(n),t||n._getDescendants(e,!1,i)}},t.prototype.getDescendants=function(e,t){var i=[];return this._getDescendants(i,e,t),i},t.prototype.getChildMeshes=function(t,i){var r=[];return this._getDescendants(r,t,(function(t){return(!i||i(t))&&t instanceof e.AbstractMesh})),r},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 i=this.animations[t];if(i.name===e)return i}return null},t.prototype.createAnimationRange=function(t,i,r){if(!this._ranges[t]){this._ranges[t]=new e.AnimationRange(t,i,r);for(var n=0,s=this.animations.length;n<s;n++)this.animations[n]&&this.animations[n].createRange(t,i,r)}},t.prototype.deleteAnimationRange=function(e,t){void 0===t&&(t=!0);for(var i=0,r=this.animations.length;i<r;i++)this.animations[i]&&this.animations[i].deleteRange(e,t);this._ranges[e]=void 0},t.prototype.getAnimationRange=function(e){return this._ranges[e]},t.prototype.beginAnimation=function(e,t,i,r){var n=this.getAnimationRange(e);if(!n)return null;this._scene.beginAnimation(this,n.from,n.to,t,i,r)},t.prototype.serializeAnimationRanges=function(){var e=[];for(var t in this._ranges){var i={};i.name=t,i.from=this._ranges[t].from,i.to=this._ranges[t].to,e.push(i)}return e},t.prototype.dispose=function(){this.parent=null,this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear()},t.ParseAnimationRanges=function(e,t,i){if(t.ranges)for(var r=0;r<t.ranges.length;r++){var n=t.ranges[r];e.createAnimationRange(n.name,n.from,n.to)}},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,i){this.minimum=t,this.maximum=i,this._tempRadiusVector=e.Vector3.Zero();var r=e.Vector3.Distance(t,i);this.center=e.Vector3.Lerp(t,i,.5),this.radius=.5*r,this.centerWorld=e.Vector3.Zero(),this._update(e.Matrix.Identity())}return t.prototype._update=function(t){e.Vector3.TransformCoordinatesToRef(this.center,t,this.centerWorld),e.Vector3.TransformNormalFromFloatsToRef(1,1,1,t,this._tempRadiusVector),this.radiusWorld=Math.max(Math.abs(this._tempRadiusVector.x),Math.abs(this._tempRadiusVector.y),Math.abs(this._tempRadiusVector.z))*this.radius},t.prototype.isInFrustum=function(e){for(var t=0;t<6;t++)if(e[t].dotCoordinate(this.centerWorld)<=-this.radiusWorld)return!1;return!0},t.prototype.intersectsPoint=function(t){var i=this.centerWorld.x-t.x,r=this.centerWorld.y-t.y,n=this.centerWorld.z-t.z,s=Math.sqrt(i*i+r*r+n*n);return!(Math.abs(this.radiusWorld-s)<e.Epsilon)},t.Intersects=function(e,t){var i=e.centerWorld.x-t.centerWorld.x,r=e.centerWorld.y-t.centerWorld.y,n=e.centerWorld.z-t.centerWorld.z,s=Math.sqrt(i*i+r*r+n*n);return!(e.radiusWorld+t.radiusWorld<s)},t})();e.BoundingSphere=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(t,i){this.minimum=t,this.maximum=i,this.vectors=new Array,this.vectorsWorld=new Array,this.vectors.push(this.minimum.clone()),this.vectors.push(this.maximum.clone()),this.vectors.push(this.minimum.clone()),this.vectors[2].x=this.maximum.x,this.vectors.push(this.minimum.clone()),this.vectors[3].y=this.maximum.y,this.vectors.push(this.minimum.clone()),this.vectors[4].z=this.maximum.z,this.vectors.push(this.maximum.clone()),this.vectors[5].z=this.minimum.z,this.vectors.push(this.maximum.clone()),this.vectors[6].x=this.minimum.x,this.vectors.push(this.maximum.clone()),this.vectors[7].y=this.minimum.y,this.center=this.maximum.add(this.minimum).scale(.5),this.extendSize=this.maximum.subtract(this.minimum).scale(.5),this.directions=[e.Vector3.Zero(),e.Vector3.Zero(),e.Vector3.Zero()];for(var r=0;r<this.vectors.length;r++)this.vectorsWorld[r]=e.Vector3.Zero();this.minimumWorld=e.Vector3.Zero(),this.maximumWorld=e.Vector3.Zero(),this.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 i=0;i<this.vectors.length;i++){var r=this.vectorsWorld[i];e.Vector3.TransformCoordinatesToRef(this.vectors[i],t,r),r.x<this.minimumWorld.x&&(this.minimumWorld.x=r.x),r.y<this.minimumWorld.y&&(this.minimumWorld.y=r.y),r.z<this.minimumWorld.z&&(this.minimumWorld.z=r.z),r.x>this.maximumWorld.x&&(this.maximumWorld.x=r.x),r.y>this.maximumWorld.y&&(this.maximumWorld.y=r.y),r.z>this.maximumWorld.z&&(this.maximumWorld.z=r.z)}this.maximumWorld.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 i=-e.Epsilon;return!(this.maximumWorld.x-t.x<i||i>t.x-this.minimumWorld.x)&&(!(this.maximumWorld.y-t.y<i||i>t.y-this.minimumWorld.y)&&!(this.maximumWorld.z-t.z<i||i>t.z-this.minimumWorld.z))},t.prototype.intersectsSphere=function(e){return t.IntersectsSphere(this.minimumWorld,this.maximumWorld,e.centerWorld,e.radiusWorld)},t.prototype.intersectsMinMax=function(e,t){return!(this.maximumWorld.x<e.x||this.minimumWorld.x>t.x)&&(!(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,i,r,n){var s=e.Vector3.Clamp(r,t,i);return e.Vector3.DistanceSquared(r,s)<=n*n},t.IsCompletelyInFrustum=function(e,t){for(var i=0;i<6;i++)for(var r=0;r<8;r++)if(t[i].dotCoordinate(e[r])<0)return!1;return!0},t.IsInFrustum=function(e,t){for(var i=0;i<6;i++){for(var r=8,n=0;n<8&&t[i].dotCoordinate(e[n])<0;n++)--r;if(0===r)return!1}return!0},t})();e.BoundingBox=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=function(t,i){var r=e.Vector3.Dot(i.centerWorld,t),n=Math.abs(e.Vector3.Dot(i.directions[0],t))*i.extendSize.x,s=Math.abs(e.Vector3.Dot(i.directions[1],t))*i.extendSize.y,o=Math.abs(e.Vector3.Dot(i.directions[2],t))*i.extendSize.z,a=n+s+o;return{min:r-a,max:r+a}},i=function(e,t,i,r){return!(e>r||i>t)},r=function(e,r,n){var s=t(e,r),o=t(e,n);return i(s.min,s.max,o.min,o.max)},n=(function(){function t(t,i){this.minimum=t,this.maximum=i,this._isLocked=!1,this.boundingBox=new e.BoundingBox(t,i),this.boundingSphere=new e.BoundingSphere(t,i)}return Object.defineProperty(t.prototype,"isLocked",{get:function(){return this._isLocked},set:function(e){this._isLocked=e},enumerable:!0,configurable:!0}),t.prototype.update=function(e){this._isLocked||(this.boundingBox._update(e),this.boundingSphere._update(e))},t.prototype.isInFrustum=function(e){return!!this.boundingSphere.isInFrustum(e)&&this.boundingBox.isInFrustum(e)},t.prototype.isCompletelyInFrustum=function(e){return this.boundingBox.isCompletelyInFrustum(e)},t.prototype._checkCollision=function(e){return e._canDoCollision(this.boundingSphere.centerWorld,this.boundingSphere.radiusWorld,this.boundingBox.minimumWorld,this.boundingBox.maximumWorld)},t.prototype.intersectsPoint=function(e){return!!this.boundingSphere.centerWorld&&(!!this.boundingSphere.intersectsPoint(e)&&!!this.boundingBox.intersectsPoint(e))},t.prototype.intersects=function(t,i){if(!this.boundingSphere.centerWorld||!t.boundingSphere.centerWorld)return!1;if(!e.BoundingSphere.Intersects(this.boundingSphere,t.boundingSphere))return!1;if(!e.BoundingBox.Intersects(this.boundingBox,t.boundingBox))return!1;if(!i)return!0;var n=this.boundingBox,s=t.boundingBox;return!!r(n.directions[0],n,s)&&(!!r(n.directions[1],n,s)&&(!!r(n.directions[2],n,s)&&(!!r(s.directions[0],n,s)&&(!!r(s.directions[1],n,s)&&(!!r(s.directions[2],n,s)&&(!!r(e.Vector3.Cross(n.directions[0],s.directions[0]),n,s)&&(!!r(e.Vector3.Cross(n.directions[0],s.directions[1]),n,s)&&(!!r(e.Vector3.Cross(n.directions[0],s.directions[2]),n,s)&&(!!r(e.Vector3.Cross(n.directions[1],s.directions[0]),n,s)&&(!!r(e.Vector3.Cross(n.directions[1],s.directions[1]),n,s)&&(!!r(e.Vector3.Cross(n.directions[1],s.directions[2]),n,s)&&(!!r(e.Vector3.Cross(n.directions[2],s.directions[0]),n,s)&&(!!r(e.Vector3.Cross(n.directions[2],s.directions[1]),n,s)&&!!r(e.Vector3.Cross(n.directions[2],s.directions[2]),n,s))))))))))))))},t})();e.BoundingInfo=n})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(r,n){var s=t.call(this,r,n)||this;return s._facetNb=0,s._partitioningSubdivisions=10,s._partitioningBBoxRatio=1.01,s._facetDataEnabled=!1,s._facetParameters={},s._bbSize=e.Vector3.Zero(),s._subDiv={max:1,X:1,Y:1,Z:1},s.onCollideObservable=new e.Observable,s.onCollisionPositionChangeObservable=new e.Observable,s.onAfterWorldMatrixUpdateObservable=new e.Observable,s.definedFacingForward=!0,s.position=new e.Vector3(0,0,0),s._rotation=new e.Vector3(0,0,0),s._scaling=new e.Vector3(1,1,1),s.billboardMode=i.BILLBOARDMODE_NONE,s.visibility=1,s.alphaIndex=Number.MAX_VALUE,s.infiniteDistance=!1,s.isVisible=!0,s.isPickable=!0,s.showBoundingBox=!1,s.showSubMeshesBoundingBox=!1,s.isBlocker=!1,s.renderingGroupId=0,s._receiveShadows=!1,s.renderOutline=!1,s.outlineColor=e.Color3.Red(),s.outlineWidth=.02,s.renderOverlay=!1,s.overlayColor=e.Color3.Red(),s.overlayAlpha=.5,s._hasVertexAlpha=!1,s._useVertexColors=!0,s._computeBonesUsingShaders=!0,s._numBoneInfluencers=4,s._applyFog=!0,s.scalingDeterminant=1,s.useOctreeForRenderingSelection=!0,s.useOctreeForPicking=!0,s.useOctreeForCollisions=!0,s.layerMask=268435455,s.alwaysSelectAsActiveMesh=!1,s._checkCollisions=!1,s._collisionMask=-1,s._collisionGroup=-1,s.ellipsoid=new e.Vector3(.5,1,.5),s.ellipsoidOffset=new e.Vector3(0,0,0),s._oldPositionForCollisions=new e.Vector3(0,0,0),s._diffPositionForCollisions=new e.Vector3(0,0,0),s._newPositionForCollisions=new e.Vector3(0,0,0),s.edgesWidth=1,s.edgesColor=new e.Color4(1,0,0,1),s._localWorld=e.Matrix.Zero(),s._worldMatrix=e.Matrix.Zero(),s._absolutePosition=e.Vector3.Zero(),s._collisionsTransformMatrix=e.Matrix.Zero(),s._collisionsScalingMatrix=e.Matrix.Zero(),s._isDirty=!1,s._pivotMatrix=e.Matrix.Identity(),s._isDisposed=!1,s._renderId=0,s._intersectionsInProgress=new Array,s._isWorldMatrixFrozen=!1,s._unIndexed=!1,s._lightSources=new Array,s._onCollisionPositionChange=function(t,i,r){void 0===r&&(r=null),s.getScene().workerCollisions&&i.multiplyInPlace(s._collider.radius),i.subtractToRef(s._oldPositionForCollisions,s._diffPositionForCollisions),s._diffPositionForCollisions.length()>e.Engine.CollisionsEpsilon&&s.position.addInPlace(s._diffPositionForCollisions),r&&s.onCollideObservable.notifyObservers(r),s.onCollisionPositionChangeObservable.notifyObservers(s.position)},s.getScene().addMesh(s),s._resyncLightSources(),s}return __extends(i,t),Object.defineProperty(i,"BILLBOARDMODE_NONE",{get:function(){return i._BILLBOARDMODE_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(i,"BILLBOARDMODE_X",{get:function(){return i._BILLBOARDMODE_X},enumerable:!0,configurable:!0}),Object.defineProperty(i,"BILLBOARDMODE_Y",{get:function(){return i._BILLBOARDMODE_Y},enumerable:!0,configurable:!0}),Object.defineProperty(i,"BILLBOARDMODE_Z",{get:function(){return i._BILLBOARDMODE_Z},enumerable:!0,configurable:!0}),Object.defineProperty(i,"BILLBOARDMODE_ALL",{get:function(){return i._BILLBOARDMODE_ALL},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"facetNb",{get:function(){return this._facetNb},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"partitioningSubdivisions",{get:function(){return this._partitioningSubdivisions},set:function(e){this._partitioningSubdivisions=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"partitioningBBoxRatio",{get:function(){return this._partitioningBBoxRatio},set:function(e){this._partitioningBBoxRatio=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"isFacetDataEnabled",{get:function(){return this._facetDataEnabled},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"onCollide",{set:function(e){this._onCollideObserver&&this.onCollideObservable.remove(this._onCollideObserver),this._onCollideObserver=this.onCollideObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"onCollisionPositionChange",{set:function(e){this._onCollisionPositionChangeObserver&&this.onCollisionPositionChangeObservable.remove(this._onCollisionPositionChangeObserver),this._onCollisionPositionChangeObserver=this.onCollisionPositionChangeObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"material",{get:function(){return this._material},set:function(e){if(this._material!==e&&(this._material=e,this.subMeshes))for(var t=0,i=this.subMeshes;t<i.length;t++){var r=i[t];r.setEffect(null)}},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"receiveShadows",{get:function(){return this._receiveShadows},set:function(e){this._receiveShadows!==e&&(this._receiveShadows=e,this._markSubMeshesAsLightDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"hasVertexAlpha",{get:function(){return this._hasVertexAlpha},set:function(e){this._hasVertexAlpha!==e&&(this._hasVertexAlpha=e,this._markSubMeshesAsAttributesDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"useVertexColors",{get:function(){return this._useVertexColors},set:function(e){this._useVertexColors!==e&&(this._useVertexColors=e,this._markSubMeshesAsAttributesDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"computeBonesUsingShaders",{get:function(){return this._computeBonesUsingShaders},set:function(e){this._computeBonesUsingShaders!==e&&(this._computeBonesUsingShaders=e,this._markSubMeshesAsAttributesDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"numBoneInfluencers",{get:function(){return this._numBoneInfluencers},set:function(e){this._numBoneInfluencers!==e&&(this._numBoneInfluencers=e,this._markSubMeshesAsAttributesDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"applyFog",{get:function(){return this._applyFog},set:function(e){this._applyFog!==e&&(this._applyFog=e,this._markSubMeshesAsMiscDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"collisionMask",{get:function(){return this._collisionMask},set:function(e){this._collisionMask=isNaN(e)?-1:e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"collisionGroup",{get:function(){return this._collisionGroup},set:function(e){this._collisionGroup=isNaN(e)?-1:e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"skeleton",{get:function(){return this._skeleton},set:function(e){this._skeleton&&this._skeleton.needInitialSkinMatrix&&this._skeleton._unregisterMeshWithPoseMatrix(this),e&&e.needInitialSkinMatrix&&e._registerMeshWithPoseMatrix(this),this._skeleton=e,this._skeleton||(this._bonesTransformMatrices=null),this._markSubMeshesAsAttributesDirty()},enumerable:!0,configurable:!0}),i.prototype.getClassName=function(){return"AbstractMesh"},i.prototype.toString=function(t){var i="Name: "+this.name+", isInstance: "+(this instanceof e.InstancedMesh?"YES":"NO");return i+=", # of submeshes: "+(this.subMeshes?this.subMeshes.length:0),this._skeleton&&(i+=", skeleton: "+this._skeleton.name),t&&(i+=", billboard mode: "+["NONE","X","Y",null,"Z",null,null,"ALL"][this.billboardMode],i+=", freeze wrld mat: "+(this._isWorldMatrixFrozen||this._waitingFreezeWorldMatrix?"YES":"NO")),i},i.prototype._resyncLightSources=function(){this._lightSources.length=0;for(var e=0,t=this.getScene().lights;e<t.length;e++){var i=t[e];i.isEnabled()&&(i.canAffectMesh(this)&&this._lightSources.push(i))}this._markSubMeshesAsLightDirty()},i.prototype._resyncLighSource=function(e){var t=e.isEnabled()&&e.canAffectMesh(this),i=this._lightSources.indexOf(e);if(-1===i){if(!t)return;this._lightSources.push(e)}else{if(t)return;this._lightSources.splice(i,1)}this._markSubMeshesAsLightDirty()},i.prototype._removeLightSource=function(e){var t=this._lightSources.indexOf(e);-1!==t&&this._lightSources.splice(t,1)},i.prototype._markSubMeshesAsDirty=function(e){if(this.subMeshes)for(var t=0,i=this.subMeshes;t<i.length;t++){var r=i[t];r._materialDefines&&e(r._materialDefines)}},i.prototype._markSubMeshesAsLightDirty=function(){this._markSubMeshesAsDirty((function(e){return e.markAsLightDirty()}))},i.prototype._markSubMeshesAsAttributesDirty=function(){this._markSubMeshesAsDirty((function(e){return e.markAsAttributesDirty()}))},i.prototype._markSubMeshesAsMiscDirty=function(){if(this.subMeshes)for(var t=0,i=this.subMeshes;t<i.length;t++){var r=i[t],n=r.getMaterial();n&&n.markAsDirty(e.Material.MiscDirtyFlag)}},Object.defineProperty(i.prototype,"rotation",{get:function(){return this._rotation},set:function(e){this._rotation=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"scaling",{get:function(){return this._scaling},set:function(e){this._scaling=e,this.physicsImpostor&&this.physicsImpostor.forceUpdate()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"rotationQuaternion",{get:function(){return this._rotationQuaternion},set:function(e){this._rotationQuaternion=e,e&&this.rotation.length()&&this.rotation.copyFromFloats(0,0,0)},enumerable:!0,configurable:!0}),i.prototype.updatePoseMatrix=function(e){return this._poseMatrix.copyFrom(e),this},i.prototype.getPoseMatrix=function(){return this._poseMatrix},i.prototype.disableEdgesRendering=function(){return void 0!==this._edgesRenderer&&(this._edgesRenderer.dispose(),this._edgesRenderer=void 0),this},i.prototype.enableEdgesRendering=function(t,i){return void 0===t&&(t=.95),void 0===i&&(i=!1),this.disableEdgesRendering(),this._edgesRenderer=new e.EdgesRenderer(this,t,i),this},Object.defineProperty(i.prototype,"isBlocked",{get:function(){return!1},enumerable:!0,configurable:!0}),i.prototype.getLOD=function(e){return this},i.prototype.getTotalVertices=function(){return 0},i.prototype.getIndices=function(){return null},i.prototype.getVerticesData=function(e){return null},i.prototype.setVerticesData=function(e,t,i,r){return null},i.prototype.updateVerticesData=function(e,t,i,r){return null},i.prototype.setIndices=function(e,t){return null},i.prototype.isVerticesDataPresent=function(e){return!1},i.prototype.getBoundingInfo=function(){return this._masterMesh?this._masterMesh.getBoundingInfo():(this._boundingInfo||this._updateBoundingInfo(),this._boundingInfo)},i.prototype.setBoundingInfo=function(e){return this._boundingInfo=e,this},Object.defineProperty(i.prototype,"useBones",{get:function(){return this.skeleton&&this.getScene().skeletonsEnabled&&this.isVerticesDataPresent(e.VertexBuffer.MatricesIndicesKind)&&this.isVerticesDataPresent(e.VertexBuffer.MatricesWeightsKind)},enumerable:!0,configurable:!0}),i.prototype._preActivate=function(){},i.prototype._preActivateForIntermediateRendering=function(e){},i.prototype._activate=function(e){this._renderId=e},i.prototype.getWorldMatrix=function(){return this._masterMesh?this._masterMesh.getWorldMatrix():(this._currentRenderId===this.getScene().getRenderId()&&this.isSynchronized()||this.computeWorldMatrix(),this._worldMatrix)},Object.defineProperty(i.prototype,"worldMatrixFromCache",{get:function(){return this._worldMatrix},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"absolutePosition",{get:function(){return this._absolutePosition},enumerable:!0,configurable:!0}),i.prototype.freezeWorldMatrix=function(){return this._isWorldMatrixFrozen=!1,this.computeWorldMatrix(!0),this._isWorldMatrixFrozen=!0,this},i.prototype.unfreezeWorldMatrix=function(){return this._isWorldMatrixFrozen=!1,this.computeWorldMatrix(!0),this},Object.defineProperty(i.prototype,"isWorldMatrixFrozen",{get:function(){return this._isWorldMatrixFrozen},enumerable:!0,configurable:!0}),i.prototype.rotate=function(t,r,n){t.normalize(),this.rotationQuaternion||(this.rotationQuaternion=e.Quaternion.RotationYawPitchRoll(this.rotation.y,this.rotation.x,this.rotation.z),this.rotation=e.Vector3.Zero());var s;if(n&&n!==e.Space.LOCAL){if(this.parent){var o=this.parent.getWorldMatrix().clone();o.invert(),t=e.Vector3.TransformNormal(t,o)}s=e.Quaternion.RotationAxisToRef(t,r,i._rotationAxisCache),s.multiplyToRef(this.rotationQuaternion,this.rotationQuaternion)}else s=e.Quaternion.RotationAxisToRef(t,r,i._rotationAxisCache),this.rotationQuaternion.multiplyToRef(s,this.rotationQuaternion);return this},i.prototype.translate=function(t,i,r){var n=t.scale(i);if(r&&r!==e.Space.LOCAL)this.setAbsolutePosition(this.getAbsolutePosition().add(n));else{var s=this.getPositionExpressedInLocalSpace().add(n);this.setPositionWithLocalVector(s)}return this},i.prototype.addRotation=function(t,i,r){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 s=e.Tmp.Quaternion[0];return e.Quaternion.RotationYawPitchRollToRef(i,t,r,s),n.multiplyInPlace(s),this.rotationQuaternion||n.toEulerAnglesToRef(this.rotation),this},i.prototype.getAbsolutePosition=function(){return this.computeWorldMatrix(),this._absolutePosition},i.prototype.setAbsolutePosition=function(t){if(t){var i,r,n;if(void 0===t.x){if(arguments.length<3)return;i=arguments[0],r=arguments[1],n=arguments[2]}else i=t.x,r=t.y,n=t.z;if(this.parent){var s=this.parent.getWorldMatrix().clone();s.invert();var o=new e.Vector3(i,r,n);this.position=e.Vector3.TransformCoordinates(o,s)}else this.position.x=i,this.position.y=r,this.position.z=n;return this}},i.prototype.movePOV=function(e,t,i){return this.position.addInPlace(this.calcMovePOV(e,t,i)),this},i.prototype.calcMovePOV=function(t,i,r){var n=new e.Matrix;(this.rotationQuaternion?this.rotationQuaternion:e.Quaternion.RotationYawPitchRoll(this.rotation.y,this.rotation.x,this.rotation.z)).toRotationMatrix(n);var s=e.Vector3.Zero(),o=this.definedFacingForward?-1:1;return e.Vector3.TransformCoordinatesFromFloatsToRef(t*o,i,r*o,n,s),s},i.prototype.rotatePOV=function(e,t,i){return this.rotation.addInPlace(this.calcRotatePOV(e,t,i)),this},i.prototype.calcRotatePOV=function(t,i,r){var n=this.definedFacingForward?1:-1;return new e.Vector3(t*n,i,r*n)},i.prototype.setPivotMatrix=function(e){return this._pivotMatrix=e,this._cache.pivotMatrixUpdated=!0,this},i.prototype.getPivotMatrix=function(){return this._pivotMatrix},i.prototype._isSynchronized=function(){return!this._isDirty&&(this.billboardMode===this._cache.billboardMode&&this.billboardMode===i.BILLBOARDMODE_NONE&&(!this._cache.pivotMatrixUpdated&&(!this.infiniteDistance&&(!!this._cache.position.equals(this.position)&&(!(this.rotationQuaternion&&!this._cache.rotationQuaternion.equals(this.rotationQuaternion))&&(!!this._cache.rotation.equals(this.rotation)&&!!this._cache.scaling.equals(this.scaling)))))))},i.prototype._initCache=function(){t.prototype._initCache.call(this),this._cache.localMatrixUpdated=!1,this._cache.position=e.Vector3.Zero(),this._cache.scaling=e.Vector3.Zero(),this._cache.rotation=e.Vector3.Zero(),this._cache.rotationQuaternion=new e.Quaternion(0,0,0,0),this._cache.billboardMode=-1},i.prototype.markAsDirty=function(e){return"rotation"===e&&(this.rotationQuaternion=null),this._currentRenderId=Number.MAX_VALUE,this._isDirty=!0,this},i.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},i.prototype._updateSubMeshesBoundingInfo=function(e){if(this.subMeshes){for(var t=0;t<this.subMeshes.length;t++){var i=this.subMeshes[t]
  7. ;i.IsGlobal||i.updateBoundingInfo(e)}return this}},i.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 r=this.getScene().activeCamera;if(r){var n=r.getWorldMatrix(),s=new e.Vector3(n.m[12],n.m[13],n.m[14]);e.Matrix.TranslationToRef(this.position.x+s.x,this.position.y+s.y,this.position.z+s.z,e.Tmp.Matrix[2])}}else e.Matrix.TranslationToRef(this.position.x,this.position.y,this.position.z,e.Tmp.Matrix[2]);if(this._pivotMatrix.multiplyToRef(e.Tmp.Matrix[1],e.Tmp.Matrix[4]),e.Tmp.Matrix[4].multiplyToRef(e.Tmp.Matrix[0],e.Tmp.Matrix[5]),this.billboardMode!==i.BILLBOARDMODE_NONE&&this.getScene().activeCamera){if((this.billboardMode&i.BILLBOARDMODE_ALL)!==i.BILLBOARDMODE_ALL){var o=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],o)):e.Vector3.TransformCoordinatesToRef(this.position,this.parent.getWorldMatrix(),o):o.copyFrom(this.position),o.subtractInPlace(this.getScene().activeCamera.globalPosition);var a=e.Tmp.Vector3[4].copyFromFloats(0,0,0);(this.billboardMode&i.BILLBOARDMODE_X)===i.BILLBOARDMODE_X&&(a.x=Math.atan2(-o.y,o.z)),(this.billboardMode&i.BILLBOARDMODE_Y)===i.BILLBOARDMODE_Y&&(a.y=Math.atan2(o.x,o.z)),(this.billboardMode&i.BILLBOARDMODE_Z)===i.BILLBOARDMODE_Z&&(a.z=Math.atan2(o.y,o.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._markSyncedWithParent(),this.billboardMode!==i.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._worldMatrix.copyFrom(this._localWorld),this._updateBoundingInfo(),this._absolutePosition.copyFromFloats(this._worldMatrix.m[12],this._worldMatrix.m[13],this._worldMatrix.m[14]),this.onAfterWorldMatrixUpdateObservable.notifyObservers(this),this._poseMatrix||(this._poseMatrix=e.Matrix.Invert(this._worldMatrix)),this._worldMatrix},i.prototype.registerAfterWorldMatrixUpdate=function(e){return this.onAfterWorldMatrixUpdateObservable.add(e),this},i.prototype.unregisterAfterWorldMatrixUpdate=function(e){return this.onAfterWorldMatrixUpdateObservable.removeCallback(e),this},i.prototype.setPositionWithLocalVector=function(t){return this.computeWorldMatrix(),this.position=e.Vector3.TransformNormal(t,this._localWorld),this},i.prototype.getPositionExpressedInLocalSpace=function(){this.computeWorldMatrix();var t=this._localWorld.clone();return t.invert(),e.Vector3.TransformNormal(this.position,t)},i.prototype.locallyTranslate=function(t){return this.computeWorldMatrix(!0),this.position=e.Vector3.TransformCoordinates(t,this._localWorld),this},i.prototype.lookAt=function(t,r,n,s,o){void 0===r&&(r=0),void 0===n&&(n=0),void 0===s&&(s=0),void 0===o&&(o=e.Space.LOCAL);var a=i._lookAtVectorCache,h=o===e.Space.LOCAL?this.position:this.getAbsolutePosition();t.subtractToRef(h,a);var u=-Math.atan2(a.z,a.x)-Math.PI/2,c=Math.sqrt(a.x*a.x+a.z*a.z),l=Math.atan2(a.y,c);return this.rotationQuaternion=this.rotationQuaternion||new e.Quaternion,e.Quaternion.RotationYawPitchRollToRef(u+r,l+n,s,this.rotationQuaternion),this},i.prototype.attachToBone=function(e,t){return this._meshToBoneReferal=t,this.parent=e,e.getWorldMatrix().determinant()<0&&(this.scalingDeterminant*=-1),this},i.prototype.detachFromBone=function(){return this.parent.getWorldMatrix().determinant()<0&&(this.scalingDeterminant*=-1),this._meshToBoneReferal=null,this.parent=null,this},i.prototype.isInFrustum=function(e){return this._boundingInfo.isInFrustum(e)},i.prototype.isCompletelyInFrustum=function(e){return this._boundingInfo.isCompletelyInFrustum(e)},i.prototype.intersectsMesh=function(e,t){return!(!this._boundingInfo||!e._boundingInfo)&&this._boundingInfo.intersects(e._boundingInfo,t)},i.prototype.intersectsPoint=function(e){return!!this._boundingInfo&&this._boundingInfo.intersectsPoint(e)},i.prototype.getPhysicsImpostor=function(){return this.physicsImpostor},i.prototype.getPositionInCameraSpace=function(t){return t||(t=this.getScene().activeCamera),e.Vector3.TransformCoordinates(this.absolutePosition,t.getViewMatrix())},i.prototype.getDistanceToCamera=function(e){return e||(e=this.getScene().activeCamera),this.absolutePosition.subtract(e.position).length()},i.prototype.applyImpulse=function(e,t){if(this.physicsImpostor)return this.physicsImpostor.applyImpulse(e,t),this},i.prototype.setPhysicsLinkWith=function(t,i,r,n){if(this.physicsImpostor&&t.physicsImpostor)return this.physicsImpostor.createJoint(t.physicsImpostor,e.PhysicsJoint.HingeJoint,{mainPivot:i,connectedPivot:r,nativeParams:n}),this},Object.defineProperty(i.prototype,"checkCollisions",{get:function(){return this._checkCollisions},set:function(e){this._checkCollisions=e,this.getScene().workerCollisions&&this.getScene().collisionCoordinator.onMeshUpdated(this)},enumerable:!0,configurable:!0}),i.prototype.moveWithCollisions=function(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},i.prototype.createOrUpdateSubmeshesOctree=function(t,i){void 0===t&&(t=64),void 0===i&&(i=2),this._submeshesOctree||(this._submeshesOctree=new e.Octree(e.Octree.CreationFuncForSubMeshes,t,i)),this.computeWorldMatrix(!0);var r=this.getBoundingInfo().boundingBox;return this._submeshesOctree.update(r.minimumWorld,r.maximumWorld,this.subMeshes),this._submeshesOctree},i.prototype._collideForSubMesh=function(t,i,r){if(this._generatePointsArray(),!t._lastColliderWorldVertices||!t._lastColliderTransformMatrix.equals(i)){t._lastColliderTransformMatrix=i.clone(),t._lastColliderWorldVertices=[],t._trianglePlanes=[];for(var n=t.verticesStart,s=t.verticesStart+t.verticesCount,o=n;o<s;o++)t._lastColliderWorldVertices.push(e.Vector3.TransformCoordinates(this._positions[o],i))}return r._collide(t._trianglePlanes,t._lastColliderWorldVertices,this.getIndices(),t.indexStart,t.indexStart+t.indexCount,t.verticesStart,!!t.getMaterial()),r.collisionFound&&(r.collidedMesh=this),this},i.prototype._processCollisionsForSubMeshes=function(e,t){var i,r;if(this._submeshesOctree&&this.useOctreeForCollisions){var n=e.velocityWorldLength+Math.max(e.radius.x,e.radius.y,e.radius.z),s=this._submeshesOctree.intersects(e.basePointWorld,n);r=s.length,i=s.data}else i=this.subMeshes,r=i.length;for(var o=0;o<r;o++){var a=i[o];r>1&&!a._checkCollision(e)||this._collideForSubMesh(a,t,e)}return this},i.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},i.prototype._generatePointsArray=function(){return!1},i.prototype.intersects=function(t,i){var r=new e.PickingInfo;if(!(this.subMeshes&&this._boundingInfo&&t.intersectsSphere(this._boundingInfo.boundingSphere)&&t.intersectsBox(this._boundingInfo.boundingBox)))return r;if(!this._generatePointsArray())return r;var n,s,o=null;if(this._submeshesOctree&&this.useOctreeForPicking){var a=e.Ray.Transform(t,this.getWorldMatrix()),h=this._submeshesOctree.intersectsRay(a);s=h.length,n=h.data}else n=this.subMeshes,s=n.length;for(var u=0;u<s;u++){var c=n[u];if(!(s>1)||c.canIntersects(t)){var l=c.intersects(t,this._positions,this.getIndices(),i);if(l&&(i||!o||l.distance<o.distance)&&(o=l,o.subMeshId=u,i))break}}if(o){var f=this.getWorldMatrix(),d=e.Vector3.TransformCoordinates(t.origin,f),p=t.direction.clone();p=p.scale(o.distance);var _=e.Vector3.TransformNormal(p,f),m=d.add(_);return r.hit=!0,r.distance=e.Vector3.Distance(d,m),r.pickedPoint=m,r.pickedMesh=this,r.bu=o.bu,r.bv=o.bv,r.faceId=o.faceId,r.subMeshId=o.subMeshId,r}return r},i.prototype.clone=function(e,t,i){return null},i.prototype.releaseSubMeshes=function(){if(this.subMeshes)for(;this.subMeshes.length;)this.subMeshes[0].dispose();else this.subMeshes=new Array;return this},i.prototype.dispose=function(e){var i,r=this;for(this.actionManager&&(this.actionManager.dispose(),this.actionManager=null),this.skeleton=null,this.getScene().stopAnimation(this),this.physicsImpostor&&this.physicsImpostor.dispose(),i=0;i<this._intersectionsInProgress.length;i++){var n=this._intersectionsInProgress[i],s=n._intersectionsInProgress.indexOf(this);n._intersectionsInProgress.splice(s,1)}this._intersectionsInProgress=[],this.getScene().lights.forEach((function(e){var t=e.includedOnlyMeshes.indexOf(r);-1!==t&&e.includedOnlyMeshes.splice(t,1),-1!==(t=e.excludedMeshes.indexOf(r))&&e.excludedMeshes.splice(t,1);var i=e.getShadowGenerator();i&&-1!==(t=i.getShadowMap().renderList.indexOf(r))&&i.getShadowMap().renderList.splice(t,1)})),this._edgesRenderer&&(this._edgesRenderer.dispose(),this._edgesRenderer=null),"InstancedMesh"!==this.getClassName()&&this.releaseSubMeshes();var o=this.getScene().selectionOctree;if(o){var i=o.dynamicContent.indexOf(this);-1!==i&&o.dynamicContent.splice(i,1)}if(this.getScene().getEngine().wipeCaches(),this.getScene().removeMesh(this),e){var a=this.getChildMeshes(!0);for(i=0;i<a.length;i++){var h=a[i];h.parent=null,h.computeWorldMatrix(!0)}}else{for(i=0;i<this.getScene().particleSystems.length;i++)this.getScene().particleSystems[i].emitter===this&&(this.getScene().particleSystems[i].dispose(),i--);var u=this.getDescendants(!0);for(i=0;i<u.length;i++)u[i].dispose()}this._facetDataEnabled&&this.disableFacetData(),this.onAfterWorldMatrixUpdateObservable.clear(),this.onCollideObservable.clear(),this.onCollisionPositionChangeObservable.clear(),this._isDisposed=!0,t.prototype.dispose.call(this)},i.prototype.getDirection=function(t){var i=e.Vector3.Zero();return this.getDirectionToRef(t,i),i},i.prototype.getDirectionToRef=function(t,i){return e.Vector3.TransformNormalToRef(t,this.getWorldMatrix(),i),this},i.prototype.setPivotPoint=function(t,i){void 0===i&&(i=e.Space.LOCAL),0==this.getScene().getRenderId()&&this.computeWorldMatrix(!0);var r=this.getWorldMatrix();if(i==e.Space.WORLD){var n=e.Tmp.Matrix[0];r.invertToRef(n),t=e.Vector3.TransformCoordinates(t,n)}return e.Vector3.TransformCoordinatesToRef(t,r,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},i.prototype.getPivotPoint=function(){var t=e.Vector3.Zero();return this.getPivotPointToRef(t),t},i.prototype.getPivotPointToRef=function(e){return e.x=-this._pivotMatrix.m[12],e.y=-this._pivotMatrix.m[13],e.z=-this._pivotMatrix.m[14],this},i.prototype.getAbsolutePivotPoint=function(){var t=e.Vector3.Zero();return this.getAbsolutePivotPointToRef(t),t},i.prototype.setParent=function(t){var i=this,r=t;if(null==t){var n=e.Tmp.Quaternion[0],s=e.Tmp.Vector3[0],o=e.Tmp.Vector3[1];i.getWorldMatrix().decompose(o,n,s),i.rotationQuaternion?i.rotationQuaternion.copyFrom(n):n.toEulerAnglesToRef(i.rotation),i.position.x=s.x,i.position.y=s.y,i.position.z=s.z}else{var n=e.Tmp.Quaternion[0],s=e.Tmp.Vector3[0],o=e.Tmp.Vector3[1],a=e.Tmp.Matrix[0],h=e.Tmp.Matrix[1];r.getWorldMatrix().decompose(o,n,s),n.toRotationMatrix(a),h.setTranslation(s),h.multiplyToRef(a,a);var u=e.Matrix.Invert(a),c=i.getWorldMatrix().multiply(u);c.decompose(o,n,s),i.rotationQuaternion?i.rotationQuaternion.copyFrom(n):n.toEulerAnglesToRef(i.rotation),u=e.Matrix.Invert(r.getWorldMatrix());var c=i.getWorldMatrix().multiply(u);c.decompose(o,n,s),i.position.x=s.x,i.position.y=s.y,i.position.z=s.z}return i.parent=r,this},i.prototype.addChild=function(e){return e.setParent(this),this},i.prototype.removeChild=function(e){return e.setParent(null),this},i.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},i.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},i.prototype.updateFacetData=function(){this._facetDataEnabled||this._initFacetData();var t=this.getVerticesData(e.VertexBuffer.PositionKind),i=this.getIndices(),r=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 s=this._bbSize.x>this._bbSize.y?this._bbSize.x:this._bbSize.y;return s=s>this._bbSize.z?s:this._bbSize.z,this._subDiv.max=this._partitioningSubdivisions,this._subDiv.X=Math.floor(this._subDiv.max*this._bbSize.x/s),this._subDiv.Y=Math.floor(this._subDiv.max*this._bbSize.y/s),this._subDiv.Z=Math.floor(this._subDiv.max*this._bbSize.z/s),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,i,r,this._facetParameters),this},i.prototype.getFacetLocalNormals=function(){return this._facetNormals||this.updateFacetData(),this._facetNormals},i.prototype.getFacetLocalPositions=function(){return this._facetPositions||this.updateFacetData(),this._facetPositions},i.prototype.getFacetLocalPartitioning=function(){return this._facetPartitioning||this.updateFacetData(),this._facetPartitioning},i.prototype.getFacetPosition=function(t){var i=e.Vector3.Zero();return this.getFacetPositionToRef(t,i),i},i.prototype.getFacetPositionToRef=function(t,i){var r=this.getFacetLocalPositions()[t],n=this.getWorldMatrix();return e.Vector3.TransformCoordinatesToRef(r,n,i),this},i.prototype.getFacetNormal=function(t){var i=e.Vector3.Zero();return this.getFacetNormalToRef(t,i),i},i.prototype.getFacetNormalToRef=function(t,i){var r=this.getFacetLocalNormals()[t];return e.Vector3.TransformNormalToRef(r,this.getWorldMatrix(),i),this},i.prototype.getFacetsAtLocalCoordinates=function(e,t,i){var r=this.getBoundingInfo(),n=Math.floor((e-r.minimum.x*this._partitioningBBoxRatio)*this._subDiv.X*this._partitioningBBoxRatio/this._bbSize.x),s=Math.floor((t-r.minimum.y*this._partitioningBBoxRatio)*this._subDiv.Y*this._partitioningBBoxRatio/this._bbSize.y),o=Math.floor((i-r.minimum.z*this._partitioningBBoxRatio)*this._subDiv.Z*this._partitioningBBoxRatio/this._bbSize.z);return n<0||n>this._subDiv.max||s<0||s>this._subDiv.max||o<0||o>this._subDiv.max?null:this._facetPartitioning[n+this._subDiv.max*s+this._subDiv.max*this._subDiv.max*o]},i.prototype.getClosestFacetAtCoordinates=function(t,i,r,n,s,o){void 0===s&&(s=!1),void 0===o&&(o=!0);var a=this.getWorldMatrix(),h=e.Tmp.Matrix[5];a.invertToRef(h);var u=e.Tmp.Vector3[8],c=null;return e.Vector3.TransformCoordinatesFromFloatsToRef(t,i,r,h,u),c=this.getClosestFacetAtLocalCoordinates(u.x,u.y,u.z,n,s,o),n&&e.Vector3.TransformCoordinatesFromFloatsToRef(n.x,n.y,n.z,a,n),c},i.prototype.getClosestFacetAtLocalCoordinates=function(e,t,i,r,n,s){void 0===n&&(n=!1),void 0===s&&(s=!0);var o=null,a=0,h=0,u=0,c=0,l=0,f=0,d=0,p=0,_=this.getFacetLocalPositions(),m=this.getFacetLocalNormals(),g=this.getFacetsAtLocalCoordinates(e,t,i);if(!g)return null;for(var y,v,b,x=Number.MAX_VALUE,T=x,E=0;E<g.length;E++)y=g[E],v=m[y],b=_[y],c=(e-b.x)*v.x+(t-b.y)*v.y+(i-b.z)*v.z,(!n||n&&s&&c>=0||n&&!s&&c<=0)&&(c=v.x*b.x+v.y*b.y+v.z*b.z,l=-(v.x*e+v.y*t+v.z*i-c)/(v.x*v.x+v.y*v.y+v.z*v.z),f=e+v.x*l,d=t+v.y*l,p=i+v.z*l,a=f-e,h=d-t,u=p-i,(T=a*a+h*h+u*u)<x&&(x=T,o=y,r&&(r.x=f,r.y=d,r.z=p)));return o},i.prototype.getFacetDataParameters=function(){return this._facetParameters},i.prototype.disableFacetData=function(){return this._facetDataEnabled&&(this._facetDataEnabled=!1,this._facetPositions=null,this._facetNormals=null,this._facetPartitioning=null,this._facetParameters=null),this},i.prototype.createNormals=function(t){var i,r=this.getVerticesData(e.VertexBuffer.PositionKind),n=this.getIndices();i=this.isVerticesDataPresent(e.VertexBuffer.NormalKind)?this.getVerticesData(e.VertexBuffer.NormalKind):[],e.VertexData.ComputeNormals(r,n,i,{useRightHandedSystem:this.getScene().useRightHandedSystem}),this.setVerticesData(e.VertexBuffer.NormalKind,i,t)},i})(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 i(i,r){var n=t.call(this,i,r)||this;return n.diffuse=new e.Color3(1,1,1),n.specular=new e.Color3(1,1,1),n.intensity=1,n.range=Number.MAX_VALUE,n._excludeWithLayerMask=0,n._includeOnlyWithLayerMask=0,n._lightmapMode=0,n.radius=1e-5,n._excludedMeshesIds=new Array,n._includedOnlyMeshesIds=new Array,n.getScene().addLight(n),n._uniformBuffer=new e.UniformBuffer(n.getScene().getEngine()),n._buildUniformLayout(),n.includedOnlyMeshes=new Array,n.excludedMeshes=new Array,n._resyncMeshes(),n}return __extends(i,t),Object.defineProperty(i,"LIGHTMAP_DEFAULT",{get:function(){return i._LIGHTMAP_DEFAULT},enumerable:!0,configurable:!0}),Object.defineProperty(i,"LIGHTMAP_SPECULAR",{get:function(){return i._LIGHTMAP_SPECULAR},enumerable:!0,configurable:!0}),Object.defineProperty(i,"LIGHTMAP_SHADOWSONLY",{get:function(){return i._LIGHTMAP_SHADOWSONLY},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"includedOnlyMeshes",{get:function(){return this._includedOnlyMeshes},set:function(e){this._includedOnlyMeshes=e,this._hookArrayForIncludedOnly(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"excludedMeshes",{get:function(){return this._excludedMeshes},set:function(e){this._excludedMeshes=e,this._hookArrayForExcluded(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"excludeWithLayerMask",{get:function(){return this._excludeWithLayerMask},set:function(e){this._excludeWithLayerMask=e,this._resyncMeshes()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"includeOnlyWithLayerMask",{get:function(){return this._includeOnlyWithLayerMask},set:function(e){this._includeOnlyWithLayerMask=e,this._resyncMeshes()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"lightmapMode",{get:function(){return this._lightmapMode},set:function(e){this._lightmapMode!==e&&(this._lightmapMode=e,this._markMeshesAsLightDirty())},enumerable:!0,configurable:!0}),i.prototype._buildUniformLayout=function(){},i.prototype.getClassName=function(){return"Light"},i.prototype.toString=function(e){var t="Name: "+this.name;if(t+=", type: "+["Point","Directional","Spot","Hemispheric"][this.getTypeID()],this.animations)for(var i=0;i<this.animations.length;i++)t+=", animation[0]: "+this.animations[i].toString(e);return t},i.prototype.setEnabled=function(e){t.prototype.setEnabled.call(this,e),this._resyncMeshes()},i.prototype.getShadowGenerator=function(){return this._shadowGenerator},i.prototype.getAbsolutePosition=function(){return e.Vector3.Zero()},i.prototype.transferToEffect=function(e,t){},i.prototype._getWorldMatrix=function(){return e.Matrix.Identity()},i.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)))},i.prototype.getWorldMatrix=function(){this._currentRenderId=this.getScene().getRenderId();var t=this._getWorldMatrix();return this.parent&&this.parent.getWorldMatrix?(this._parentedWorldMatrix||(this._parentedWorldMatrix=e.Matrix.Identity()),t.multiplyToRef(this.parent.getWorldMatrix(),this._parentedWorldMatrix),this._markSyncedWithParent(),this._parentedWorldMatrix):t},i.prototype.dispose=function(){this._shadowGenerator&&(this._shadowGenerator.dispose(),this._shadowGenerator=null),this.getScene().stopAnimation(this);for(var e=0,i=this.getScene().meshes;e<i.length;e++){i[e]._removeLightSource(this)}this._uniformBuffer.dispose(),this.getScene().removeLight(this),t.prototype.dispose.call(this)},i.prototype.getTypeID=function(){return 0},i.prototype.clone=function(t){return e.SerializationHelper.Clone(i.GetConstructorFromName(this.getTypeID(),t,this.getScene()),this)},i.prototype.serialize=function(){var t=e.SerializationHelper.Serialize(this);return t.type=this.getTypeID(),this.parent&&(t.parentId=this.parent.id),this.excludedMeshes.length>0&&(t.excludedMeshesIds=[],this.excludedMeshes.forEach((function(e){t.excludedMeshesIds.push(e.id)}))),this.includedOnlyMeshes.length>0&&(t.includedOnlyMeshesIds=[],this.includedOnlyMeshes.forEach((function(e){t.includedOnlyMeshesIds.push(e.id)}))),e.Animation.AppendSerializedAnimations(this,t),t.ranges=this.serializeAnimationRanges(),t},i.GetConstructorFromName=function(t,i,r){switch(t){case 0:return function(){return new e.PointLight(i,e.Vector3.Zero(),r)};case 1:return function(){return new e.DirectionalLight(i,e.Vector3.Zero(),r)};case 2:return function(){return new e.SpotLight(i,e.Vector3.Zero(),e.Vector3.Zero(),0,0,r)};case 3:return function(){return new e.HemisphericLight(i,e.Vector3.Zero(),r)}}},i.Parse=function(t,r){var n=e.SerializationHelper.Parse(i.GetConstructorFromName(t.type,t.name,r),t,r);if(t.excludedMeshesIds&&(n._excludedMeshesIds=t.excludedMeshesIds),t.includedOnlyMeshesIds&&(n._includedOnlyMeshesIds=t.includedOnlyMeshesIds),t.parentId&&(n._waitingParentId=t.parentId),t.animations){for(var s=0;s<t.animations.length;s++){var o=t.animations[s];n.animations.push(e.Animation.Parse(o))}e.Node.ParseAnimationRanges(n,t,r)}return t.autoAnimate&&r.beginAnimation(n,t.autoAnimateFrom,t.autoAnimateTo,t.autoAnimateLoop,t.autoAnimateSpeed||1),n},i.prototype._hookArrayForExcluded=function(e){var t=this,i=e.push;e.push=function(){for(var r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];for(var s=i.apply(e,r),o=0,a=r;o<a.length;o++){a[o]._resyncLighSource(t)}return s};var r=e.splice;e.splice=function(i,n){for(var s=r.apply(e,[i,n]),o=0,a=s;o<a.length;o++){a[o]._resyncLighSource(t)}return s};for(var n=0,s=e;n<s.length;n++){s[n]._resyncLighSource(this)}},i.prototype._hookArrayForIncludedOnly=function(e){var t=this,i=e.push;e.push=function(){for(var r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];var s=i.apply(e,r);return t._resyncMeshes(),s};var r=e.splice;e.splice=function(i,n){var s=r.apply(e,[i,n]);return t._resyncMeshes(),s},this._resyncMeshes()},i.prototype._resyncMeshes=function(){for(var e=0,t=this.getScene().meshes;e<t.length;e++){t[e]._resyncLighSource(this)}},i.prototype._markMeshesAsLightDirty=function(){for(var e=0,t=this.getScene().meshes;e<t.length;e++){var i=t[e];-1!==i._lightSources.indexOf(this)&&i._markSubMeshesAsLightDirty()}},i})(e.Node);t._LIGHTMAP_DEFAULT=0,t._LIGHTMAP_SPECULAR=1,t._LIGHTMAP_SHADOWSONLY=2,__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("excludeWithLayerMask")],t.prototype,"_excludeWithLayerMask",void 0),__decorate([e.serialize("includeOnlyWithLayerMask")],t.prototype,"_includeOnlyWithLayerMask",void 0),__decorate([e.serialize("lightmapMode")],t.prototype,"_lightmapMode",void 0),__decorate([e.serialize()],t.prototype,"radius",void 0),e.Light=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(r,n,s){var o=t.call(this,r,s)||this;return o.upVector=e.Vector3.Up(),o.orthoLeft=null,o.orthoRight=null,o.orthoBottom=null,o.orthoTop=null,o.fov=.8,o.minZ=1,o.maxZ=1e4,o.inertia=.9,o.mode=i.PERSPECTIVE_CAMERA,o.isIntermediate=!1,o.viewport=new e.Viewport(0,0,1,1),o.layerMask=268435455,o.fovMode=i.FOVMODE_VERTICAL_FIXED,o.cameraRigMode=i.RIG_MODE_NONE,o._rigCameras=new Array,o._webvrViewMatrix=e.Matrix.Identity(),o._computedViewMatrix=e.Matrix.Identity(),o._projectionMatrix=new e.Matrix,o._doNotComputeProjectionMatrix=!1,o._postProcesses=new Array,o._transformMatrix=e.Matrix.Zero(),o._activeMeshes=new e.SmartArray(256),o._globalPosition=e.Vector3.Zero(),o._refreshFrustumPlanes=!0,o.getScene().addCamera(o),o.getScene().activeCamera||(o.getScene().activeCamera=o),o.position=n,o}return __extends(i,t),Object.defineProperty(i,"PERSPECTIVE_CAMERA",{get:function(){return i._PERSPECTIVE_CAMERA},enumerable:!0,configurable:!0}),Object.defineProperty(i,"ORTHOGRAPHIC_CAMERA",{get:function(){return i._ORTHOGRAPHIC_CAMERA},enumerable:!0,configurable:!0}),Object.defineProperty(i,"FOVMODE_VERTICAL_FIXED",{get:function(){return i._FOVMODE_VERTICAL_FIXED},enumerable:!0,configurable:!0}),Object.defineProperty(i,"FOVMODE_HORIZONTAL_FIXED",{get:function(){return i._FOVMODE_HORIZONTAL_FIXED},enumerable:!0,configurable:!0}),Object.defineProperty(i,"RIG_MODE_NONE",{get:function(){return i._RIG_MODE_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(i,"RIG_MODE_STEREOSCOPIC_ANAGLYPH",{get:function(){return i._RIG_MODE_STEREOSCOPIC_ANAGLYPH},enumerable:!0,configurable:!0}),Object.defineProperty(i,"RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL",{get:function(){return i._RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL},enumerable:!0,configurable:!0}),Object.defineProperty(i,"RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED",{get:function(){return i._RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED},enumerable:!0,configurable:!0}),Object.defineProperty(i,"RIG_MODE_STEREOSCOPIC_OVERUNDER",{get:function(){return i._RIG_MODE_STEREOSCOPIC_OVERUNDER},enumerable:!0,configurable:!0}),Object.defineProperty(i,"RIG_MODE_VR",{get:function(){return i._RIG_MODE_VR},enumerable:!0,configurable:!0}),Object.defineProperty(i,"RIG_MODE_WEBVR",{get:function(){return i._RIG_MODE_WEBVR},enumerable:!0,configurable:!0}),i.prototype.getClassName=function(){return"Camera"},i.prototype.toString=function(e){var t="Name: "+this.name;if(t+=", type: "+this.getClassName(),this.animations)for(var i=0;i<this.animations.length;i++)t+=", animation[0]: "+this.animations[i].toString(e);return t},Object.defineProperty(i.prototype,"globalPosition",{get:function(){return this._globalPosition},enumerable:!0,configurable:!0}),i.prototype.getActiveMeshes=function(){return this._activeMeshes},i.prototype.isActiveMesh=function(e){return-1!==this._activeMeshes.indexOf(e)},i.prototype._initCache=function(){t.prototype._initCache.call(this),this._cache.position=new e.Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.upVector=new e.Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.mode=void 0,this._cache.minZ=void 0,this._cache.maxZ=void 0,this._cache.fov=void 0,this._cache.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},i.prototype._updateCache=function(e){e||t.prototype._updateCache.call(this);var i=this.getEngine();this._cache.position.copyFrom(this.position),this._cache.upVector.copyFrom(this.upVector),this._cache.mode=this.mode,this._cache.minZ=this.minZ,this._cache.maxZ=this.maxZ,this._cache.fov=this.fov,this._cache.fovMode=this.fovMode,this._cache.aspectRatio=i.getAspectRatio(this),this._cache.orthoLeft=this.orthoLeft,this._cache.orthoRight=this.orthoRight,this._cache.orthoBottom=this.orthoBottom,this._cache.orthoTop=this.orthoTop,this._cache.renderWidth=i.getRenderWidth(),this._cache.renderHeight=i.getRenderHeight()},i.prototype._updateFromScene=function(){this.updateCache(),this.update()},i.prototype._isSynchronized=function(){return this._isSynchronizedViewMatrix()&&this._isSynchronizedProjectionMatrix()},i.prototype._isSynchronizedViewMatrix=function(){return!!t.prototype._isSynchronized.call(this)&&(this._cache.position.equals(this.position)&&this._cache.upVector.equals(this.upVector)&&this.isSynchronizedWithParent())},i.prototype._isSynchronizedProjectionMatrix=function(){var e=this._cache.mode===this.mode&&this._cache.minZ===this.minZ&&this._cache.maxZ===this.maxZ;if(!e)return!1;var t=this.getEngine();return e=this.mode===i.PERSPECTIVE_CAMERA?this._cache.fov===this.fov&&this._cache.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()},i.prototype.attachControl=function(e,t){},
  8. i.prototype.detachControl=function(e){},i.prototype.update=function(){this.cameraRigMode!==i.RIG_MODE_NONE&&this._updateRigCameras(),this._checkInputs()},i.prototype._checkInputs=function(){},Object.defineProperty(i.prototype,"rigCameras",{get:function(){return this._rigCameras},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"rigPostProcess",{get:function(){return this._rigPostProcess},enumerable:!0,configurable:!0}),i.prototype._cascadePostProcessesToRigCams=function(){this._postProcesses.length>0&&this._postProcesses[0].markTextureDirty();for(var t=0,i=this._rigCameras.length;t<i;t++){var r=this._rigCameras[t],n=r._rigPostProcess;if(n){n instanceof e.PassPostProcess&&(r.isIntermediate=0===this._postProcesses.length),r._postProcesses=this._postProcesses.slice(0).concat(n),n.markTextureDirty()}else r._postProcesses=this._postProcesses.slice(0)}},i.prototype.attachPostProcess=function(t,i){return void 0===i&&(i=null),!t.isReusable()&&this._postProcesses.indexOf(t)>-1?(e.Tools.Error("You're trying to reuse a post process not defined as reusable."),0):(null==i||i<0?this._postProcesses.push(t):this._postProcesses.splice(i,0,t),this._cascadePostProcessesToRigCams(),this._postProcesses.indexOf(t))},i.prototype.detachPostProcess=function(e,t){void 0===t&&(t=null);var i,r,n=[];if(t)for(t=t instanceof Array?t:[t],i=t.length-1;i>=0;i--)this._postProcesses[t[i]]===e?(r=t[i],this._postProcesses.splice(r,1)):n.push(i);else{var s=this._postProcesses.indexOf(e);-1!==s&&this._postProcesses.splice(s,1)}return this._cascadePostProcessesToRigCams(),n},i.prototype.getWorldMatrix=function(){return this._worldMatrix||(this._worldMatrix=e.Matrix.Identity()),this.getViewMatrix().invertToRef(this._worldMatrix),this._worldMatrix},i.prototype._getViewMatrix=function(){return e.Matrix.Identity()},i.prototype.getViewMatrix=function(t){return this._computedViewMatrix=this._computeViewMatrix(t),!t&&this._isSynchronizedViewMatrix()?this._computedViewMatrix:(this._refreshFrustumPlanes=!0,this.parent&&this.parent.getWorldMatrix?(this._worldMatrix||(this._worldMatrix=e.Matrix.Identity()),this._computedViewMatrix.invertToRef(this._worldMatrix),this._worldMatrix.multiplyToRef(this.parent.getWorldMatrix(),this._computedViewMatrix),this._globalPosition.copyFromFloats(this._computedViewMatrix.m[12],this._computedViewMatrix.m[13],this._computedViewMatrix.m[14]),this._computedViewMatrix.invert(),this._markSyncedWithParent()):this._globalPosition.copyFrom(this.position),this._cameraRigParams&&this._cameraRigParams.vrPreViewMatrix&&this._computedViewMatrix.multiplyToRef(this._cameraRigParams.vrPreViewMatrix,this._computedViewMatrix),this._currentRenderId=this.getScene().getRenderId(),this._computedViewMatrix)},i.prototype._computeViewMatrix=function(e){return!e&&this._isSynchronizedViewMatrix()?this._computedViewMatrix:(this._computedViewMatrix=this._getViewMatrix(),this._currentRenderId=this.getScene().getRenderId(),this._computedViewMatrix)},i.prototype.freezeProjectionMatrix=function(e){this._doNotComputeProjectionMatrix=!0,void 0!==e&&(this._projectionMatrix=e)},i.prototype.unfreezeProjectionMatrix=function(){this._doNotComputeProjectionMatrix=!1},i.prototype.getProjectionMatrix=function(t){if(this._doNotComputeProjectionMatrix||!t&&this._isSynchronizedProjectionMatrix())return this._projectionMatrix;this._refreshFrustumPlanes=!0;var r=this.getEngine(),n=this.getScene();if(this.mode===i.PERSPECTIVE_CAMERA)return this.minZ<=0&&(this.minZ=.1),n.useRightHandedSystem?e.Matrix.PerspectiveFovRHToRef(this.fov,r.getAspectRatio(this),this.minZ,this.maxZ,this._projectionMatrix,this.fovMode===i.FOVMODE_VERTICAL_FIXED):e.Matrix.PerspectiveFovLHToRef(this.fov,r.getAspectRatio(this),this.minZ,this.maxZ,this._projectionMatrix,this.fovMode===i.FOVMODE_VERTICAL_FIXED),this._projectionMatrix;var s=r.getRenderWidth()/2,o=r.getRenderHeight()/2;return n.useRightHandedSystem?e.Matrix.OrthoOffCenterRHToRef(this.orthoLeft||-s,this.orthoRight||s,this.orthoBottom||-o,this.orthoTop||o,this.minZ,this.maxZ,this._projectionMatrix):e.Matrix.OrthoOffCenterLHToRef(this.orthoLeft||-s,this.orthoRight||s,this.orthoBottom||-o,this.orthoTop||o,this.minZ,this.maxZ,this._projectionMatrix),this._projectionMatrix},i.prototype.getTranformationMatrix=function(){return this._computedViewMatrix.multiplyToRef(this._projectionMatrix,this._transformMatrix),this._transformMatrix},i.prototype.updateFrustumPlanes=function(){this._refreshFrustumPlanes&&(this.getTranformationMatrix(),this._frustumPlanes?e.Frustum.GetPlanesToRef(this._transformMatrix,this._frustumPlanes):this._frustumPlanes=e.Frustum.GetPlanes(this._transformMatrix),this._refreshFrustumPlanes=!1)},i.prototype.isInFrustum=function(e){return this.updateFrustumPlanes(),e.isInFrustum(this._frustumPlanes)},i.prototype.isCompletelyInFrustum=function(e){return this.updateFrustumPlanes(),e.isCompletelyInFrustum(this._frustumPlanes)},i.prototype.getForwardRay=function(t,i,r){void 0===t&&(t=100),i||(i=this.getWorldMatrix()),r||(r=this.position);var n=new e.Vector3(0,0,1),s=e.Vector3.TransformNormal(n,i),o=e.Vector3.Normalize(s);return new e.Ray(r,o,t)},i.prototype.dispose=function(){for(this.getScene().stopAnimation(this),this.getScene().removeCamera(this);this._rigCameras.length>0;)this._rigCameras.pop().dispose();for(var e=this._postProcesses.length;--e>=0;)this._postProcesses[e].dispose(this);t.prototype.dispose.call(this)},Object.defineProperty(i.prototype,"leftCamera",{get:function(){if(!(this._rigCameras.length<1))return this._rigCameras[0]},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"rightCamera",{get:function(){if(!(this._rigCameras.length<2))return this._rigCameras[1]},enumerable:!0,configurable:!0}),i.prototype.getLeftTarget=function(){if(!(this._rigCameras.length<1))return this._rigCameras[0].getTarget()},i.prototype.getRightTarget=function(){if(!(this._rigCameras.length<2))return this._rigCameras[1].getTarget()},i.prototype.setCameraRigMode=function(t,r){for(;this._rigCameras.length>0;)this._rigCameras.pop().dispose();switch(this.cameraRigMode=t,this._cameraRigParams={},this._cameraRigParams.interaxialDistance=r.interaxialDistance||.0637,this._cameraRigParams.stereoHalfAngle=e.Tools.ToRadians(this._cameraRigParams.interaxialDistance/.0637),this.cameraRigMode!==i.RIG_MODE_NONE&&(this._rigCameras.push(this.createRigCamera(this.name+"_L",0)),this._rigCameras.push(this.createRigCamera(this.name+"_R",1))),this.cameraRigMode){case i.RIG_MODE_STEREOSCOPIC_ANAGLYPH:this._rigCameras[0]._rigPostProcess=new e.PassPostProcess(this.name+"_passthru",1,this._rigCameras[0]),this._rigCameras[1]._rigPostProcess=new e.AnaglyphPostProcess(this.name+"_anaglyph",1,this._rigCameras);break;case i.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case i.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:case i.RIG_MODE_STEREOSCOPIC_OVERUNDER:var n=this.cameraRigMode===i.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL||this.cameraRigMode===i.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED;this._rigCameras[0]._rigPostProcess=new e.PassPostProcess(this.name+"_passthru",1,this._rigCameras[0]),this._rigCameras[1]._rigPostProcess=new e.StereoscopicInterlacePostProcess(this.name+"_stereoInterlace",this._rigCameras,n);break;case i.RIG_MODE_VR:var s=r.vrCameraMetrics||e.VRCameraMetrics.GetDefault();this._rigCameras[0]._cameraRigParams.vrMetrics=s,this._rigCameras[0].viewport=new e.Viewport(0,0,.5,1),this._rigCameras[0]._cameraRigParams.vrWorkMatrix=new e.Matrix,this._rigCameras[0]._cameraRigParams.vrHMatrix=s.leftHMatrix,this._rigCameras[0]._cameraRigParams.vrPreViewMatrix=s.leftPreViewMatrix,this._rigCameras[0].getProjectionMatrix=this._rigCameras[0]._getVRProjectionMatrix,this._rigCameras[1]._cameraRigParams.vrMetrics=s,this._rigCameras[1].viewport=new e.Viewport(.5,0,.5,1),this._rigCameras[1]._cameraRigParams.vrWorkMatrix=new e.Matrix,this._rigCameras[1]._cameraRigParams.vrHMatrix=s.rightHMatrix,this._rigCameras[1]._cameraRigParams.vrPreViewMatrix=s.rightPreViewMatrix,this._rigCameras[1].getProjectionMatrix=this._rigCameras[1]._getVRProjectionMatrix,s.compensateDistortion&&(this._rigCameras[0]._rigPostProcess=new e.VRDistortionCorrectionPostProcess("VR_Distort_Compensation_Left",this._rigCameras[0],!1,s),this._rigCameras[1]._rigPostProcess=new e.VRDistortionCorrectionPostProcess("VR_Distort_Compensation_Right",this._rigCameras[1],!0,s));break;case i.RIG_MODE_WEBVR:if(r.vrDisplay){var o=r.vrDisplay.getEyeParameters("left"),a=r.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",r.specs),this._rigCameras[0].setCameraRigParameter("eyeParameters",o),this._rigCameras[0].setCameraRigParameter("frameData",r.frameData),this._rigCameras[0].setCameraRigParameter("parentCamera",r.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",r.specs),this._rigCameras[1].setCameraRigParameter("frameData",r.frameData),this._rigCameras[1].setCameraRigParameter("parentCamera",r.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()},i.prototype._getVRProjectionMatrix=function(){return e.Matrix.PerspectiveFovLHToRef(this._cameraRigParams.vrMetrics.aspectRatioFov,this._cameraRigParams.vrMetrics.aspectRatio,this.minZ,this.maxZ,this._cameraRigParams.vrWorkMatrix),this._cameraRigParams.vrWorkMatrix.multiplyToRef(this._cameraRigParams.vrHMatrix,this._projectionMatrix),this._projectionMatrix},i.prototype._updateCameraRotationMatrix=function(){},i.prototype._updateWebVRCameraRotationMatrix=function(){},i.prototype._getWebVRProjectionMatrix=function(){return e.Matrix.Identity()},i.prototype._getWebVRViewMatrix=function(){return e.Matrix.Identity()},i.prototype.setCameraRigParameter=function(t,i){this._cameraRigParams||(this._cameraRigParams={}),this._cameraRigParams[t]=i,"interaxialDistance"===t&&(this._cameraRigParams.stereoHalfAngle=e.Tools.ToRadians(i/.0637))},i.prototype.createRigCamera=function(e,t){return null},i.prototype._updateRigCameras=function(){for(var e=0;e<this._rigCameras.length;e++)this._rigCameras[e].minZ=this.minZ,this._rigCameras[e].maxZ=this.maxZ,this._rigCameras[e].fov=this.fov;this.cameraRigMode===i.RIG_MODE_STEREOSCOPIC_ANAGLYPH&&(this._rigCameras[0].viewport=this._rigCameras[1].viewport=this.viewport)},i.prototype._setupInputs=function(){},i.prototype.serialize=function(){var t=e.SerializationHelper.Serialize(this);return t.type=this.getClassName(),this.parent&&(t.parentId=this.parent.id),this.inputs&&this.inputs.serialize(t),e.Animation.AppendSerializedAnimations(this,t),t.ranges=this.serializeAnimationRanges(),t},i.prototype.clone=function(t){return e.SerializationHelper.Clone(i.GetConstructorFromName(this.getClassName(),t,this.getScene(),this.interaxialDistance,this.isStereoscopicSideBySide),this)},i.prototype.getDirection=function(t){var i=e.Vector3.Zero();return this.getDirectionToRef(t,i),i},i.prototype.getDirectionToRef=function(t,i){e.Vector3.TransformNormalToRef(t,this.getWorldMatrix(),i)},i.GetConstructorFromName=function(t,i,r,n,s){switch(void 0===n&&(n=0),void 0===s&&(s=!0),t){case"ArcRotateCamera":return function(){return new e.ArcRotateCamera(i,0,0,1,e.Vector3.Zero(),r)};case"DeviceOrientationCamera":return function(){return new e.DeviceOrientationCamera(i,e.Vector3.Zero(),r)};case"FollowCamera":return function(){return new e.FollowCamera(i,e.Vector3.Zero(),r)};case"ArcFollowCamera":return function(){return new e.ArcFollowCamera(i,0,0,1,null,r)};case"GamepadCamera":return function(){return new e.GamepadCamera(i,e.Vector3.Zero(),r)};case"TouchCamera":return function(){return new e.TouchCamera(i,e.Vector3.Zero(),r)};case"VirtualJoysticksCamera":return function(){return new e.VirtualJoysticksCamera(i,e.Vector3.Zero(),r)};case"WebVRFreeCamera":case"WebVRGamepadCamera":return function(){return new e.WebVRFreeCamera(i,e.Vector3.Zero(),r)};case"VRDeviceOrientationFreeCamera":return function(){return new e.VRDeviceOrientationFreeCamera(i,e.Vector3.Zero(),r)};case"VRDeviceOrientationGamepadCamera":return function(){return new e.VRDeviceOrientationGamepadCamera(i,e.Vector3.Zero(),r)};case"AnaglyphArcRotateCamera":return function(){return new e.AnaglyphArcRotateCamera(i,0,0,1,e.Vector3.Zero(),n,r)};case"AnaglyphFreeCamera":return function(){return new e.AnaglyphFreeCamera(i,e.Vector3.Zero(),n,r)};case"AnaglyphGamepadCamera":return function(){return new e.AnaglyphGamepadCamera(i,e.Vector3.Zero(),n,r)};case"AnaglyphUniversalCamera":return function(){return new e.AnaglyphUniversalCamera(i,e.Vector3.Zero(),n,r)};case"StereoscopicArcRotateCamera":return function(){return new e.StereoscopicArcRotateCamera(i,0,0,1,e.Vector3.Zero(),n,s,r)};case"StereoscopicFreeCamera":return function(){return new e.StereoscopicFreeCamera(i,e.Vector3.Zero(),n,s,r)};case"StereoscopicGamepadCamera":return function(){return new e.StereoscopicGamepadCamera(i,e.Vector3.Zero(),n,s,r)};case"StereoscopicUniversalCamera":return function(){return new e.StereoscopicUniversalCamera(i,e.Vector3.Zero(),n,s,r)};case"FreeCamera":default:return function(){return new e.UniversalCamera(i,e.Vector3.Zero(),r)}}},i.Parse=function(t,r){var n=t.type,s=i.GetConstructorFromName(n,t.name,r,t.interaxial_distance,t.isStereoscopicSideBySide),o=e.SerializationHelper.Parse(s,t,r);if(t.parentId&&(o._waitingParentId=t.parentId),o.inputs&&(o.inputs.parse(t),o._setupInputs()),t.target&&o.setTarget&&o.setTarget(e.Vector3.FromArray(t.target)),t.cameraRigMode){var a=t.interaxial_distance?{interaxialDistance:t.interaxial_distance}:{};o.setCameraRigMode(t.cameraRigMode,a)}if(t.animations){for(var h=0;h<t.animations.length;h++){var u=t.animations[h];o.animations.push(e.Animation.Parse(u))}e.Node.ParseAnimationRanges(o,t,r)}return t.autoAnimate&&r.beginAnimation(o,t.autoAnimateFrom,t.autoAnimateTo,t.autoAnimateLoop,t.autoAnimateSpeed||1),o},i})(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 i=t.MIN_RENDERINGGROUPS;i<t.MAX_RENDERINGGROUPS;i++)this._autoClearDepthStencil[i]={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(i,r,n,s){var o=this._scene.onRenderingGroupObservable.hasObservers()?this._scene.onRenderingGroupObservable:null,a=null;if(o&&(this._renderinGroupInfo||(this._renderinGroupInfo=new e.RenderingGroupInfo),a=this._renderinGroupInfo,a.scene=this._scene,a.camera=this._scene.activeCamera),s)for(var h=0;h<this._scene.spriteManagers.length;h++){var u=this._scene.spriteManagers[h];this.dispatchSprites(u)}for(var h=t.MIN_RENDERINGGROUPS;h<t.MAX_RENDERINGGROUPS;h++){this._depthStencilBufferAlreadyCleaned=h===t.MIN_RENDERINGGROUPS;var c=this._renderingGroups[h];if(c||o){this._currentIndex=h;var l=0;if(o&&(l=Math.pow(2,h),a.renderStage=e.RenderingGroupInfo.STAGE_PRECLEAR,a.renderingGroupId=h,o.notifyObservers(a,l)),t.AUTOCLEAR){var f=this._autoClearDepthStencil[h];f&&f.autoClear&&this._clearDepthStencilBuffer(f.depth,f.stencil)}o&&(a.renderStage=e.RenderingGroupInfo.STAGE_PREOPAQUE,o.notifyObservers(a,l),a.renderStage=e.RenderingGroupInfo.STAGE_PRETRANSPARENT,o.notifyObservers(a,l)),c&&c.render(i,s,n,r),o&&(a.renderStage=e.RenderingGroupInfo.STAGE_POSTTRANSPARENT,o.notifyObservers(a,l))}}},t.prototype.reset=function(){for(var e=t.MIN_RENDERINGGROUPS;e<t.MAX_RENDERINGGROUPS;e++){var i=this._renderingGroups[e];i&&i.prepare()}},t.prototype.dispose=function(){for(var e=t.MIN_RENDERINGGROUPS;e<t.MAX_RENDERINGGROUPS;e++){var i=this._renderingGroups[e];i&&i.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(),i=t.renderingGroupId||0;this._prepareRenderingGroup(i),this._renderingGroups[i].dispatch(e)},t.prototype.setRenderingOrder=function(e,t,i,r){if(void 0===t&&(t=null),void 0===i&&(i=null),void 0===r&&(r=null),this._customOpaqueSortCompareFn[e]=t,this._customAlphaTestSortCompareFn[e]=i,this._customTransparentSortCompareFn[e]=r,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,i,r){void 0===i&&(i=!0),void 0===r&&(r=!0),this._autoClearDepthStencil[e]={autoClear:t,depth:i,stencil:r}},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,i,r,n,s){void 0===r&&(r=null),void 0===n&&(n=null),void 0===s&&(s=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._scene=i,this.opaqueSortCompareFn=r,this.alphaTestSortCompareFn=n,this.transparentSortCompareFn=s}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,i,r,n){if(t)return void t(this._opaqueSubMeshes,this._alphaTestSubMeshes,this._transparentSubMeshes);var s=this._scene.getEngine();0!==this._opaqueSubMeshes.length&&this._renderOpaque(this._opaqueSubMeshes),0!==this._alphaTestSubMeshes.length&&(s.setAlphaTesting(!0),this._renderAlphaTest(this._alphaTestSubMeshes),s.setAlphaTesting(!1));var o=s.getStencilBuffer();s.setStencilBuffer(!1),i&&this._renderSprites(),r&&this._renderParticles(n),this.onBeforeTransparentRendering&&this.onBeforeTransparentRendering(),0!==this._transparentSubMeshes.length&&(this._renderTransparent(this._transparentSubMeshes),s.setAlphaMode(e.Engine.ALPHA_DISABLE)),s.setStencilBuffer(o)},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,i,r){for(var n,s=0;s<e.length;s++)n=e.data[s],n._alphaIndex=n.getMesh().alphaIndex,n._distanceToCamera=n.getBoundingInfo().boundingSphere.centerWorld.subtract(i).length();var o=e.data.slice(0,e.length);for(o.sort(t),s=0;s<o.length;s++)n=o[s],n.render(r)},t.renderUnsorted=function(e){for(var t=0;t<e.length;t++){e.data[t].render(!1)}},t.defaultTransparentSortCompare=function(e,i){return e._alphaIndex>i._alphaIndex?1:e._alphaIndex<i._alphaIndex?-1:t.backToFrontSortCompare(e,i)},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()},t.prototype.dispose=function(){this._opaqueSubMeshes.dispose(),this._transparentSubMeshes.dispose(),this._alphaTestSubMeshes.dispose(),this._particleSystems.dispose(),this._spriteManagers.dispose()},t.prototype.dispatch=function(e){var t=e.getMaterial(),i=e.getMesh();t.needAlphaBlending()||i.visibility<1||i.hasVertexAlpha?this._transparentSubMeshes.push(e):t.needAlphaTesting()?this._alphaTestSubMeshes.push(e):this._opaqueSubMeshes.push(e)},t.prototype.dispatchSprites=function(e){this._spriteManagers.push(e)},t.prototype.dispatchParticles=function(e){this._particleSystems.push(e)},t.prototype._renderParticles=function(e){if(0!==this._particleSystems.length){var t=this._scene.activeCamera;this._scene._particlesDuration.beginMonitoring();for(var i=0;i<this._scene._activeParticleSystems.length;i++){var r=this._scene._activeParticleSystems.data[i];0!=(t.layerMask&r.layerMask)&&(r.emitter.position&&e&&-1===e.indexOf(r.emitter)||this._scene._activeParticles.addCount(r.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 i=this._spriteManagers.data[t];0!=(e.layerMask&i.layerMask)&&i.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})(),i=(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})();i._POINTERDOWN=1,i._POINTERUP=2,i._POINTERMOVE=4,i._POINTERWHEEL=8,i._POINTERPICK=16,i._POINTERTAP=32,i._POINTERDOUBLETAP=64,e.PointerEventTypes=i;var r=(function(){function e(e,t){this.type=e,this.event=t}return e})();e.PointerInfoBase=r;var n=(function(t){function i(i,r,n,s){var o=t.call(this,i,r)||this;return o.skipOnPointerObservable=!1,o.localPosition=new e.Vector2(n,s),o}return __extends(i,t),i})(r);e.PointerInfoPre=n;var s=(function(e){function t(t,i,r){var n=e.call(this,t,i)||this;return n.pickInfo=r,n}return __extends(t,e),t})(r);e.PointerInfo=s;var o=(function(){function e(){}return e})();o.STAGE_PRECLEAR=1,o.STAGE_PREOPAQUE=2,o.STAGE_PRETRANSPARENT=3,o.STAGE_POSTTRANSPARENT=4,e.RenderingGroupInfo=o;var a=(function(){function r(t){this.autoClear=!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.useRightHandedSystem=!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._fogEnabled=!0,this._fogMode=r.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._edgesRenderers=new e.SmartArray(16),this._uniqueIdCounter=0,this.offscreenRenderTarget=null,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(r,"FOGMODE_NONE",{get:function(){return r._FOGMODE_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(r,"FOGMODE_EXP",{get:function(){return r._FOGMODE_EXP},enumerable:!0,configurable:!0}),Object.defineProperty(r,"FOGMODE_EXP2",{get:function(){return r._FOGMODE_EXP2},enumerable:!0,configurable:!0}),Object.defineProperty(r,"FOGMODE_LINEAR",{get:function(){return r._FOGMODE_LINEAR},enumerable:!0,configurable:!0}),Object.defineProperty(r.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(r.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"beforeRender",{set:function(e){this._onBeforeRenderObserver&&this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),this._onBeforeRenderObserver=this.onBeforeRenderObservable.add(e)},enumerable:!0,configurable:!0}),
  9. Object.defineProperty(r.prototype,"afterRender",{set:function(e){this._onAfterRenderObserver&&this.onAfterRenderObservable.remove(this._onAfterRenderObserver),this._onAfterRenderObserver=this.onAfterRenderObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"beforeCameraRender",{set:function(e){this._onBeforeCameraRenderObserver&&this.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver),this._onBeforeCameraRenderObserver=this.onBeforeCameraRenderObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"afterCameraRender",{set:function(e){this._onAfterCameraRenderObserver&&this.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver),this._onAfterCameraRenderObserver=this.onAfterCameraRenderObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"unTranslatedPointer",{get:function(){return new e.Vector2(this._unTranslatedPointerX,this._unTranslatedPointerY)},enumerable:!0,configurable:!0}),Object.defineProperty(r.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(r.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(r.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(r.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(r.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(r.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(r.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(r.prototype,"postProcessRenderPipelineManager",{get:function(){return this._postProcessRenderPipelineManager||(this._postProcessRenderPipelineManager=new e.PostProcessRenderPipelineManager),this._postProcessRenderPipelineManager},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"frustumPlanes",{get:function(){return this._frustumPlanes},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"debugLayer",{get:function(){return this._debugLayer||(this._debugLayer=new e.DebugLayer(this)),this._debugLayer},enumerable:!0,configurable:!0}),Object.defineProperty(r.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(r.prototype,"selectionOctree",{get:function(){return this._selectionOctree},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"meshUnderPointer",{get:function(){return this._pointerOverMesh},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"pointerX",{get:function(){return this._pointerX},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"pointerY",{get:function(){return this._pointerY},enumerable:!0,configurable:!0}),r.prototype.getCachedMaterial=function(){return this._cachedMaterial},r.prototype.getCachedEffect=function(){return this._cachedEffect},r.prototype.getCachedVisibility=function(){return this._cachedVisibility},r.prototype.isCachedMaterialValid=function(e,t,i){return void 0===i&&(i=0),this._cachedEffect!==t||this._cachedMaterial!==e||this._cachedVisibility!==i},r.prototype.getBoundingBoxRenderer=function(){return this._boundingBoxRenderer||(this._boundingBoxRenderer=new e.BoundingBoxRenderer(this)),this._boundingBoxRenderer},r.prototype.getOutlineRenderer=function(){return this._outlineRenderer},r.prototype.getEngine=function(){return this._engine},r.prototype.getTotalVertices=function(){return this._totalVertices.current},Object.defineProperty(r.prototype,"totalVerticesPerfCounter",{get:function(){return this._totalVertices},enumerable:!0,configurable:!0}),r.prototype.getActiveIndices=function(){return this._activeIndices.current},Object.defineProperty(r.prototype,"totalActiveIndicesPerfCounter",{get:function(){return this._activeIndices},enumerable:!0,configurable:!0}),r.prototype.getActiveParticles=function(){return this._activeParticles.current},Object.defineProperty(r.prototype,"activeParticlesPerfCounter",{get:function(){return this._activeParticles},enumerable:!0,configurable:!0}),r.prototype.getActiveBones=function(){return this._activeBones.current},Object.defineProperty(r.prototype,"activeBonesPerfCounter",{get:function(){return this._activeBones},enumerable:!0,configurable:!0}),r.prototype.getLastFrameDuration=function(){return this._lastFrameDuration.current},Object.defineProperty(r.prototype,"lastFramePerfCounter",{get:function(){return this._lastFrameDuration},enumerable:!0,configurable:!0}),r.prototype.getEvaluateActiveMeshesDuration=function(){return this._evaluateActiveMeshesDuration.current},Object.defineProperty(r.prototype,"evaluateActiveMeshesDurationPerfCounter",{get:function(){return this._evaluateActiveMeshesDuration},enumerable:!0,configurable:!0}),r.prototype.getActiveMeshes=function(){return this._activeMeshes},r.prototype.getRenderTargetsDuration=function(){return this._renderTargetsDuration.current},r.prototype.getRenderDuration=function(){return this._renderDuration.current},Object.defineProperty(r.prototype,"renderDurationPerfCounter",{get:function(){return this._renderDuration},enumerable:!0,configurable:!0}),r.prototype.getParticlesDuration=function(){return this._particlesDuration.current},Object.defineProperty(r.prototype,"particlesDurationPerfCounter",{get:function(){return this._particlesDuration},enumerable:!0,configurable:!0}),r.prototype.getSpritesDuration=function(){return this._spritesDuration.current},Object.defineProperty(r.prototype,"spriteDuractionPerfCounter",{get:function(){return this._spritesDuration},enumerable:!0,configurable:!0}),r.prototype.getAnimationRatio=function(){return this._animationRatio},r.prototype.getRenderId=function(){return this._renderId},r.prototype.incrementRenderId=function(){this._renderId++},r.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())},r.prototype._createUbo=function(){this._sceneUbo=new e.UniformBuffer(this._engine,null,!0),this._sceneUbo.addUniform("viewProjection",16),this._sceneUbo.addUniform("view",16)},r.prototype.attachControl=function(o,a,h){var u=this;void 0===o&&(o=!0),void 0===a&&(a=!0),void 0===h&&(h=!0),this._initActionManager=function(e,t){if(!u._meshPickProceed){var i=u.pick(u._unTranslatedPointerX,u._unTranslatedPointerY,u.pointerDownPredicate,!1,u.cameraToUseForPointers);u._currentPickResult=i,i&&(e=i.hit&&i.pickedMesh?i.pickedMesh.actionManager:null),u._meshPickProceed=!0}return e},this._delayedSimpleClick=function(e,t,i){((new Date).getTime()-u._previousStartingPointerTime>r.DoubleClickDelay&&!u._doubleClickOccured||e!==u._previousButtonPressed)&&(u._doubleClickOccured=!1,t.singleClick=!0,t.ignore=!1,i(t,u._currentPickResult))},this._initClickEvent=function(n,s,o,a){var h=new t;u._currentPickResult=null;var c,l=n.hasSpecificMask(i.POINTERPICK)||s.hasSpecificMask(i.POINTERPICK)||n.hasSpecificMask(i.POINTERTAP)||s.hasSpecificMask(i.POINTERTAP)||n.hasSpecificMask(i.POINTERDOUBLETAP)||s.hasSpecificMask(i.POINTERDOUBLETAP);if(!l&&e.ActionManager&&e.ActionManager.HasPickTriggers&&(c=u._initActionManager(c,h))&&(l=c.hasPickTriggers),l){var f=o.button;if(h.hasSwiped=Math.abs(u._startingPointerPosition.x-u._pointerX)>r.DragMovementThreshold||Math.abs(u._startingPointerPosition.y-u._pointerY)>r.DragMovementThreshold,!h.hasSwiped){var d=!r.ExclusiveDoubleClickMode;d||(d=!n.hasSpecificMask(i.POINTERDOUBLETAP)&&!s.hasSpecificMask(i.POINTERDOUBLETAP))&&!e.ActionManager.HasSpecificTrigger(e.ActionManager.OnDoublePickTrigger)&&(c=u._initActionManager(c,h))&&(d=!c.hasSpecificTrigger(e.ActionManager.OnDoublePickTrigger)),d?((new Date).getTime()-u._previousStartingPointerTime>r.DoubleClickDelay||f!==u._previousButtonPressed)&&(h.singleClick=!0,a(h,u._currentPickResult)):(u._previousDelayedSimpleClickTimeout=u._delayedSimpleClickTimeout,u._delayedSimpleClickTimeout=window.setTimeout(u._delayedSimpleClick.bind(u,f,h,a),r.DoubleClickDelay));var p=n.hasSpecificMask(i.POINTERDOUBLETAP)||s.hasSpecificMask(i.POINTERDOUBLETAP);!p&&e.ActionManager.HasSpecificTrigger(e.ActionManager.OnDoublePickTrigger)&&(c=u._initActionManager(c,h))&&(p=c.hasSpecificTrigger(e.ActionManager.OnDoublePickTrigger)),p&&(f===u._previousButtonPressed&&(new Date).getTime()-u._previousStartingPointerTime<r.DoubleClickDelay&&!u._doubleClickOccured?!h.hasSwiped&&Math.abs(u._previousStartingPointerPosition.x-u._startingPointerPosition.x)<r.DragMovementThreshold&&Math.abs(u._previousStartingPointerPosition.y-u._startingPointerPosition.y)<r.DragMovementThreshold?(u._previousStartingPointerTime=0,u._doubleClickOccured=!0,h.doubleClick=!0,h.ignore=!1,r.ExclusiveDoubleClickMode&&u._previousDelayedSimpleClickTimeout&&u._previousDelayedSimpleClickTimeout.clearTimeout&&u._previousDelayedSimpleClickTimeout.clearTimeout(),u._previousDelayedSimpleClickTimeout=u._delayedSimpleClickTimeout,a(h,u._currentPickResult)):(u._doubleClickOccured=!1,u._previousStartingPointerTime=u._startingPointerTime,u._previousStartingPointerPosition.x=u._startingPointerPosition.x,u._previousStartingPointerPosition.y=u._startingPointerPosition.y,u._previousButtonPressed=f,u._previousHasSwiped=h.hasSwiped,r.ExclusiveDoubleClickMode?(u._previousDelayedSimpleClickTimeout&&u._previousDelayedSimpleClickTimeout.clearTimeout&&u._previousDelayedSimpleClickTimeout.clearTimeout(),u._previousDelayedSimpleClickTimeout=u._delayedSimpleClickTimeout,a(h,u._previousPickResult)):a(h,u._currentPickResult)):(u._doubleClickOccured=!1,u._previousStartingPointerTime=u._startingPointerTime,u._previousStartingPointerPosition.x=u._startingPointerPosition.x,u._previousStartingPointerPosition.y=u._startingPointerPosition.y,u._previousButtonPressed=f,u._previousHasSwiped=h.hasSwiped))}}h.ignore=!0,a(h,u._currentPickResult)};var c=function(e){return e.isPickable&&e.actionManager&&e.actionManager.hasPointerTriggers};this._onPointerMove=function(e){if(u._updatePointerPosition(e),u.onPrePointerObservable.hasObservers()){var t="mousewheel"===e.type||"DOMMouseScroll"===e.type?i.POINTERWHEEL:i.POINTERMOVE,r=new n(t,e,u._unTranslatedPointerX,u._unTranslatedPointerY);if(u.onPrePointerObservable.notifyObservers(r,t),r.skipOnPointerObservable)return}if(u.cameraToUseForPointers||u.activeCamera){var o=u._engine.getRenderingCanvas();u.pointerMovePredicate||(u.pointerMovePredicate=function(e){return e.isPickable&&e.isVisible&&e.isReady()&&e.isEnabled()&&(u.constantlyUpdateMeshUnderPointer||null!==e.actionManager&&void 0!==e.actionManager)});var a=u.pick(u._unTranslatedPointerX,u._unTranslatedPointerY,u.pointerMovePredicate,!1,u.cameraToUseForPointers);if(a&&a.hit&&a.pickedMesh?(u.setPointerOverSprite(null),u.setPointerOverMesh(a.pickedMesh),u._pointerOverMesh.actionManager&&u._pointerOverMesh.actionManager.hasPointerTriggers?u._pointerOverMesh.actionManager.hoverCursor?o.style.cursor=u._pointerOverMesh.actionManager.hoverCursor:o.style.cursor=u.hoverCursor:o.style.cursor=""):(u.setPointerOverMesh(null),a=u.pickSprite(u._unTranslatedPointerX,u._unTranslatedPointerY,c,!1,u.cameraToUseForPointers),a&&a.hit&&a.pickedSprite?(u.setPointerOverSprite(a.pickedSprite),u._pointerOverSprite.actionManager&&u._pointerOverSprite.actionManager.hoverCursor?o.style.cursor=u._pointerOverSprite.actionManager.hoverCursor:o.style.cursor=u.hoverCursor):(u.setPointerOverSprite(null),o.style.cursor="")),u.onPointerMove&&u.onPointerMove(e,a),u.onPointerObservable.hasObservers()){var t="mousewheel"===e.type||"DOMMouseScroll"===e.type?i.POINTERWHEEL:i.POINTERMOVE,r=new s(t,e,a);u.onPointerObservable.notifyObservers(r,t)}}},this._onPointerDown=function(t){if(u._isButtonPressed=!0,u._pickedDownMesh=null,u._meshPickProceed=!1,u._updatePointerPosition(t),u.onPrePointerObservable.hasObservers()){var o=i.POINTERDOWN,a=new n(o,t,u._unTranslatedPointerX,u._unTranslatedPointerY);if(u.onPrePointerObservable.notifyObservers(a,o),a.skipOnPointerObservable)return}if(u.cameraToUseForPointers||u.activeCamera){u._startingPointerPosition.x=u._pointerX,u._startingPointerPosition.y=u._pointerY,u._startingPointerTime=(new Date).getTime(),u.pointerDownPredicate||(u.pointerDownPredicate=function(e){return e.isPickable&&e.isVisible&&e.isReady()&&e.isEnabled()}),u._pickedDownMesh=null;var h=u.pick(u._unTranslatedPointerX,u._unTranslatedPointerY,u.pointerDownPredicate,!1,u.cameraToUseForPointers);if(h&&h.hit&&h.pickedMesh){u._pickedDownMesh=h.pickedMesh;var l=h.pickedMesh.actionManager;if(l){if(l.hasPickTriggers)switch(l.processTrigger(e.ActionManager.OnPickDownTrigger,e.ActionEvent.CreateNew(h.pickedMesh,t)),t.button){case 0:l.processTrigger(e.ActionManager.OnLeftPickTrigger,e.ActionEvent.CreateNew(h.pickedMesh,t));break;case 1:l.processTrigger(e.ActionManager.OnCenterPickTrigger,e.ActionEvent.CreateNew(h.pickedMesh,t));break;case 2:l.processTrigger(e.ActionManager.OnRightPickTrigger,e.ActionEvent.CreateNew(h.pickedMesh,t))}l.hasSpecificTrigger(e.ActionManager.OnLongPressTrigger)&&window.setTimeout(function(){var i=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==i._pickedDownMesh}),!1,this.cameraToUseForPointers);n&&n.hit&&n.pickedMesh&&this._isButtonPressed&&(new Date).getTime()-this._startingPointerTime>r.LongPressDelay&&Math.abs(this._startingPointerPosition.x-this._pointerX)<r.DragMovementThreshold&&Math.abs(this._startingPointerPosition.y-this._pointerY)<r.DragMovementThreshold&&(this._startingPointerTime=0,l.processTrigger(e.ActionManager.OnLongPressTrigger,e.ActionEvent.CreateNew(n.pickedMesh,t)))}.bind(u),r.LongPressDelay)}}if(u.onPointerDown&&u.onPointerDown(t,h),u.onPointerObservable.hasObservers()){var o=i.POINTERDOWN,a=new s(o,t,h);u.onPointerObservable.notifyObservers(a,o)}if(u._pickedDownSprite=null,u.spriteManagers.length>0&&(h=u.pickSprite(u._unTranslatedPointerX,u._unTranslatedPointerY,c,!1,u.cameraToUseForPointers))&&h.hit&&h.pickedSprite&&h.pickedSprite.actionManager){switch(u._pickedDownSprite=h.pickedSprite,t.button){case 0:h.pickedSprite.actionManager.processTrigger(e.ActionManager.OnLeftPickTrigger,e.ActionEvent.CreateNewFromSprite(h.pickedSprite,u,t));break;case 1:h.pickedSprite.actionManager.processTrigger(e.ActionManager.OnCenterPickTrigger,e.ActionEvent.CreateNewFromSprite(h.pickedSprite,u,t));break;case 2:h.pickedSprite.actionManager.processTrigger(e.ActionManager.OnRightPickTrigger,e.ActionEvent.CreateNewFromSprite(h.pickedSprite,u,t))}h.pickedSprite.actionManager&&h.pickedSprite.actionManager.processTrigger(e.ActionManager.OnPickDownTrigger,e.ActionEvent.CreateNewFromSprite(h.pickedSprite,u,t))}}},this._onPointerUp=function(t){u._isButtonPressed=!1,u._pickedUpMesh=null,u._meshPickProceed=!1,u._updatePointerPosition(t),u._initClickEvent(u.onPrePointerObservable,u.onPointerObservable,t,function(o,a){if(this.onPrePointerObservable.hasObservers())if(o.ignore){var h=i.POINTERUP,u=new n(h,t,this._unTranslatedPointerX,this._unTranslatedPointerY);if(this.onPrePointerObservable.notifyObservers(u,h),u.skipOnPointerObservable)return}else if(!o.hasSwiped){if(o.singleClick&&this.onPrePointerObservable.hasSpecificMask(i.POINTERTAP)){var h=i.POINTERTAP,u=new n(h,t,this._unTranslatedPointerX,this._unTranslatedPointerY);if(this.onPrePointerObservable.notifyObservers(u,h),u.skipOnPointerObservable)return}if(o.doubleClick&&this.onPrePointerObservable.hasSpecificMask(i.POINTERDOUBLETAP)){var h=i.POINTERDOUBLETAP,u=new n(h,t,this._unTranslatedPointerX,this._unTranslatedPointerY);if(this.onPrePointerObservable.notifyObservers(u,h),u.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,o),a||(a=this._currentPickResult),a&&a&&a.pickedMesh){if(this._pickedUpMesh=a.pickedMesh,this._pickedDownMesh===this._pickedUpMesh&&(this.onPointerPick&&this.onPointerPick(t,a),o.singleClick&&!o.ignore&&this.onPointerObservable.hasObservers())){var h=i.POINTERPICK,u=new s(h,t,a);this.onPointerObservable.notifyObservers(u,h)}a.pickedMesh.actionManager&&(o.ignore&&a.pickedMesh.actionManager.processTrigger(e.ActionManager.OnPickUpTrigger,e.ActionEvent.CreateNew(a.pickedMesh,t)),o.hasSwiped||o.ignore||!o.singleClick||a.pickedMesh.actionManager.processTrigger(e.ActionManager.OnPickTrigger,e.ActionEvent.CreateNew(a.pickedMesh,t)),o.doubleClick&&!o.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(o.ignore){var h=i.POINTERUP,u=new s(h,t,a);this.onPointerObservable.notifyObservers(u,h)}else if(!o.hasSwiped){if(o.singleClick&&this.onPointerObservable.hasSpecificMask(i.POINTERTAP)){var h=i.POINTERTAP,u=new s(h,t,a);this.onPointerObservable.notifyObservers(u,h)}if(o.doubleClick&&this.onPointerObservable.hasSpecificMask(i.POINTERDOUBLETAP)){var h=i.POINTERDOUBLETAP,u=new s(h,t,a);this.onPointerObservable.notifyObservers(u,h)}}this.spriteManagers.length>0&&(a=this.pickSprite(this._unTranslatedPointerX,this._unTranslatedPointerY,c,!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)<r.DragMovementThreshold&&Math.abs(this._startingPointerPosition.y-this._pointerY)<r.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(u))},this._onKeyDown=function(t){u.actionManager&&u.actionManager.processTrigger(e.ActionManager.OnKeyDownTrigger,e.ActionEvent.CreateNewFromScene(u,t))},this._onKeyUp=function(t){u.actionManager&&u.actionManager.processTrigger(e.ActionManager.OnKeyUpTrigger,e.ActionEvent.CreateNewFromScene(u,t))};var l=e.Tools.GetPointerPrefix(),f=this._engine.getRenderingCanvas();h&&(f.addEventListener(l+"move",this._onPointerMove,!1),f.addEventListener("mousewheel",this._onPointerMove,!1),f.addEventListener("DOMMouseScroll",this._onPointerMove,!1)),a&&f.addEventListener(l+"down",this._onPointerDown,!1),o&&f.addEventListener(l+"up",this._onPointerUp,!1),f.tabIndex=1,f.addEventListener("keydown",this._onKeyDown,!1),f.addEventListener("keyup",this._onKeyUp,!1)},r.prototype.detachControl=function(){var t=e.Tools.GetPointerPrefix(),i=this._engine.getRenderingCanvas();i.removeEventListener(t+"move",this._onPointerMove),i.removeEventListener(t+"down",this._onPointerDown),i.removeEventListener(t+"up",this._onPointerUp),i.removeEventListener("mousewheel",this._onPointerMove),i.removeEventListener("DOMMouseScroll",this._onPointerMove),i.removeEventListener("keydown",this._onKeyDown),i.removeEventListener("keyup",this._onKeyUp)},r.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 i=this.meshes[t];if(i.isEnabled()&&(i.subMeshes&&0!==i.subMeshes.length)){if(!i.isReady())return!1;var r=i.material;if(r&&!r.isReady(i))return!1}}return!0},r.prototype.resetCachedMaterial=function(){this._cachedMaterial=null,this._cachedEffect=null,this._cachedVisibility=null},r.prototype.registerBeforeRender=function(e){this.onBeforeRenderObservable.add(e)},r.prototype.unregisterBeforeRender=function(e){this.onBeforeRenderObservable.removeCallback(e)},r.prototype.registerAfterRender=function(e){this.onAfterRenderObservable.add(e)},r.prototype.unregisterAfterRender=function(e){this.onAfterRenderObservable.removeCallback(e)},r.prototype._addPendingData=function(e){this._pendingData.push(e)},r.prototype._removePendingData=function(e){var t=this._pendingData.indexOf(e);-1!==t&&this._pendingData.splice(t,1)},r.prototype.getWaitingItemsCount=function(){return this._pendingData.length},r.prototype.executeWhenReady=function(e){var t=this;this.onReadyObservable.add(e),-1===this._executeWhenReadyTimeoutId&&(this._executeWhenReadyTimeoutId=setTimeout((function(){t._checkIsReady()}),150))},r.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)},r.prototype.beginAnimation=function(t,i,r,n,s,o,a){if(void 0===s&&(s=1),this.stopAnimation(t),a||(a=new e.Animatable(this,t,i,r,n,s,o)),t.animations&&a.appendAnimations(t,t.animations),t.getAnimatables)for(var h=t.getAnimatables(),u=0;u<h.length;u++)this.beginAnimation(h[u],i,r,n,s,o,a);return a.reset(),a},r.prototype.beginDirectAnimation=function(t,i,r,n,s,o,a){return void 0===o&&(o=1),new e.Animatable(this,t,r,n,s,o,a,i)},r.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(r.prototype,"Animatables",{get:function(){return this._activeAnimatables},enumerable:!0,configurable:!0}),r.prototype.stopAnimation=function(e,t){var i=this.getAnimatableByTarget(e);i&&i.stop(t)},r.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 i=(t-this._animationTimeLast)*this.animationTimeScale;this._animationTime+=i,this._animationTimeLast=t;for(var r=0;r<this._activeAnimatables.length;r++)this._activeAnimatables[r]._animate(this._animationTime)}},r.prototype.getViewMatrix=function(){return this._viewMatrix},r.prototype.getProjectionMatrix=function(){return this._projectionMatrix},r.prototype.getTransformMatrix=function(){return this._transformMatrix},r.prototype.setTransformMatrix=function(t,i){this._viewUpdateFlag===t.updateFlag&&this._projectionUpdateFlag===i.updateFlag||(this._viewUpdateFlag=t.updateFlag,this._projectionUpdateFlag=i.updateFlag,this._viewMatrix=t,this._projectionMatrix=i,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()))},r.prototype.getSceneUniformBuffer=function(){return this._sceneUbo},r.prototype.getUniqueId=function(){var e=this._uniqueIdCounter;return this._uniqueIdCounter++,e},r.prototype.addMesh=function(e){e.uniqueId=this.getUniqueId();this.meshes.push(e);this.collisionCoordinator&&this.collisionCoordinator.onMeshAdded(e),this.onNewMeshAddedObservable.notifyObservers(e)},r.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},r.prototype.removeSkeleton=function(e){var t=this.skeletons.indexOf(e);return-1!==t&&this.skeletons.splice(t,1),t},r.prototype.removeMorphTargetManager=function(e){var t=this.morphTargetManagers.indexOf(e);return-1!==t&&this.morphTargetManagers.splice(t,1),t},r.prototype.removeLight=function(e){var t=this.lights.indexOf(e);return-1!==t&&this.lights.splice(t,1),this.onLightRemovedObservable.notifyObservers(e),t},r.prototype.removeCamera=function(e){var t=this.cameras.indexOf(e);-1!==t&&this.cameras.splice(t,1);var i=this.activeCameras.indexOf(e);return-1!==i&&this.activeCameras.splice(i,1),this.activeCamera===e&&(this.cameras.length>0?this.activeCamera=this.cameras[0]:this.activeCamera=null),this.onCameraRemovedObservable.notifyObservers(e),t},r.prototype.addLight=function(e){e.uniqueId=this.getUniqueId();this.lights.push(e);this.onNewLightAddedObservable.notifyObservers(e)},r.prototype.addCamera=function(e){e.uniqueId=this.getUniqueId();this.cameras.push(e);this.onNewCameraAddedObservable.notifyObservers(e)},r.prototype.switchActiveCamera=function(e,t){void 0===t&&(t=!0);var i=this._engine.getRenderingCanvas();this.activeCamera.detachControl(i),this.activeCamera=e,t&&e.attachControl(i)},r.prototype.setActiveCameraByID=function(e){var t=this.getCameraByID(e);return t?(this.activeCamera=t,t):null},r.prototype.setActiveCameraByName=function(e){var t=this.getCameraByName(e);return t?(this.activeCamera=t,t):null},r.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},r.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},r.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},r.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},r.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},r.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},r.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},r.prototype.getBoneByID=function(e){for(var t=0;t<this.skeletons.length;t++)for(var i=this.skeletons[t],r=0;r<i.bones.length;r++)if(i.bones[r].id===e)return i.bones[r];return null},r.prototype.getBoneByName=function(e){for(var t=0;t<this.skeletons.length;t++)for(var i=this.skeletons[t],r=0;r<i.bones.length;r++)if(i.bones[r].name===e)return i.bones[r];return null},r.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},r.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},r.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},r.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},r.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},r.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)},r.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)},r.prototype.getGeometries=function(){return this._geometries},r.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},r.prototype.getMeshesByID=function(e){return this.meshes.filter((function(t){return t.id===e}))},r.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},r.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},r.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},r.prototype.getNodeByID=function(e){var t=this.getMeshByID(e);if(t)return t;var i=this.getLightByID(e);if(i)return i;var r=this.getCameraByID(e);return r||this.getBoneByID(e)},r.prototype.getNodeByName=function(e){var t=this.getMeshByName(e);if(t)return t;var i=this.getLightByName(e);if(i)return i;var r=this.getCameraByName(e);return r||this.getBoneByName(e)},r.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},r.prototype.getSoundByName=function(t){var i;if(e.AudioEngine){for(i=0;i<this.mainSoundTrack.soundCollection.length;i++)if(this.mainSoundTrack.soundCollection[i].name===t)return this.mainSoundTrack.soundCollection[i];for(var r=0;r<this.soundTracks.length;r++)for(i=0;i<this.soundTracks[r].soundCollection.length;i++)if(this.soundTracks[r].soundCollection[i].name===t)return this.soundTracks[r].soundCollection[i]}return null},r.prototype.getLastSkeletonByID=function(e){
  10. for(var t=this.skeletons.length-1;t>=0;t--)if(this.skeletons[t].id===e)return this.skeletons[t];return null},r.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},r.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},r.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},r.prototype.isActiveMesh=function(e){return-1!==this._activeMeshes.indexOf(e)},r.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(r.prototype,"uid",{get:function(){return this._uid||(this._uid=e.Tools.RandomId()),this._uid},enumerable:!0,configurable:!0}),r.prototype.addExternalData=function(t,i){return this._externalData||(this._externalData=new e.StringDictionary),this._externalData.add(t,i)},r.prototype.getExternalData=function(e){return this._externalData?this._externalData.get(e):null},r.prototype.getOrAddExternalDataWithFactory=function(t,i){return this._externalData||(this._externalData=new e.StringDictionary),this._externalData.getOrAddWithFactory(t,i)},r.prototype.removeExternalData=function(e){return this._externalData.remove(e)},r.prototype._evaluateSubMesh=function(e,t){if(t.alwaysSelectAsActiveMesh||1===t.subMeshes.length||e.isInFrustum(this._frustumPlanes)){var i=e.getMaterial();t.showSubMeshesBoundingBox&&this.getBoundingBoxRenderer().renderList.push(e.getBoundingInfo().boundingBox),i&&(i.getRenderTargetTextures&&-1===this._processedMaterials.indexOf(i)&&(this._processedMaterials.push(i),this._renderTargets.concatWithNoDuplicate(i.getRenderTargetTextures())),this._activeIndices.addCount(e.indexCount,!1),this._renderingManager.dispatch(e))}},r.prototype._isInIntermediateRendering=function(){return this._intermediateRendering},r.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(),this._edgesRenderers.reset();var t,i;if(this._selectionOctree){var r=this._selectionOctree.select(this._frustumPlanes);t=r.data,i=r.length}else i=this.meshes.length,t=this.meshes;for(var n=0;n<i;n++){var s=t[n];if(!s.isBlocked&&(this._totalVertices.addCount(s.getTotalVertices(),!1),s.isReady()&&s.isEnabled())){s.computeWorldMatrix(),s.actionManager&&s.actionManager.hasSpecificTriggers([e.ActionManager.OnIntersectionEnterTrigger,e.ActionManager.OnIntersectionExitTrigger])&&this._meshesForIntersections.pushNoDuplicate(s);var o=s.getLOD(this.activeCamera);o&&(s._preActivate(),(s.alwaysSelectAsActiveMesh||s.isVisible&&s.visibility>0&&0!=(s.layerMask&this.activeCamera.layerMask)&&s.isInFrustum(this._frustumPlanes))&&(this._activeMeshes.push(s),this.activeCamera._activeMeshes.push(s),s._activate(this._renderId),this._activeMesh(s,o)))}}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 h=this.particleSystems[a];h.isStarted()&&((!h.emitter.position||h.emitter&&h.emitter.isEnabled())&&(this._activeParticleSystems.push(h),h.animate(),this._renderingManager.dispatchParticles(h)))}e.Tools.EndPerformanceCounter("Particles",this.particleSystems.length>0)}this._particlesDuration.endMonitoring(!1)},r.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),e._edgesRenderer&&this._edgesRenderers.push(e._edgesRenderer),t&&t.subMeshes){var i,r;if(t._submeshesOctree&&t.useOctreeForRenderingSelection){var n=t._submeshesOctree.select(this._frustumPlanes);i=n.length,r=n.data}else r=t.subMeshes,i=r.length;for(var s=0;s<i;s++){var o=r[s];this._evaluateSubMesh(o,t)}}},r.prototype.updateTransformMatrix=function(e){this.setTransformMatrix(this.activeCamera.getViewMatrix(),this.activeCamera.getProjectionMatrix(e))},r.prototype._renderForCamera=function(t){var i=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),i.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 r=0;r<this._softwareSkinnedMeshes.length;r++){var n=this._softwareSkinnedMeshes.data[r];n.applySkeleton(n.skeleton)}this._renderTargetsDuration.beginMonitoring();var s=!1;e.Tools.Now;if(this.renderTargetsEnabled&&this._renderTargets.length>0){this._intermediateRendering=!0,e.Tools.StartPerformanceCounter("Render targets",this._renderTargets.length>0);for(var o=0;o<this._renderTargets.length;o++){var a=this._renderTargets.data[o];if(a._shouldRender()){this._renderId++;var h=a.activeCamera&&a.activeCamera!==this.activeCamera;a.render(h,this.dumpNextRenderTargets)}}e.Tools.EndPerformanceCounter("Render targets",this._renderTargets.length>0),this._intermediateRendering=!1,this._renderId++,s=!0}var u=this._engine.getStencilBuffer(),c=!1;if(this.renderTargetsEnabled&&this.highlightLayers&&this.highlightLayers.length>0){this._intermediateRendering=!0;for(var l=0;l<this.highlightLayers.length;l++){var f=this.highlightLayers[l];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)){c=!0;var a=f._mainTexture;a._shouldRender()&&(this._renderId++,a.render(!1,!1),s=!0)}}this._intermediateRendering=!1,this._renderId++}s&&(this.offscreenRenderTarget?i.bindFramebuffer(this.offscreenRenderTarget._texture):i.restoreDefaultFramebuffer()),this._renderTargetsDuration.endMonitoring(!1),this.postProcessManager._prepareFrame(),this._renderDuration.beginMonitoring();var d,p;if(this.layers.length){for(i.setDepthBuffer(!1),d=0;d<this.layers.length;d++)p=this.layers[d],p.isBackground&&p.render();i.setDepthBuffer(!0)}e.Tools.StartPerformanceCounter("Main render"),c&&this._engine.setStencilBuffer(!0),this._renderingManager.render(null,null,!0,!0),c&&this._engine.setStencilBuffer(u),e.Tools.EndPerformanceCounter("Main render"),this._boundingBoxRenderer&&this._boundingBoxRenderer.render();for(var _=0;_<this._edgesRenderers.length;_++)this._edgesRenderers.data[_].render();if(this.lensFlaresEnabled){e.Tools.StartPerformanceCounter("Lens flares",this.lensFlareSystems.length>0);for(var m=0;m<this.lensFlareSystems.length;m++){var g=this.lensFlareSystems[m];0!=(t.layerMask&g.layerMask)&&g.render()}e.Tools.EndPerformanceCounter("Lens flares",this.lensFlareSystems.length>0)}if(this.layers.length){for(i.setDepthBuffer(!1),d=0;d<this.layers.length;d++)p=this.layers[d],p.isBackground||p.render();i.setDepthBuffer(!0)}if(c){i.setDepthBuffer(!1);for(var l=0;l<this.highlightLayers.length;l++)this.highlightLayers[l].shouldRender()&&this.highlightLayers[l].render();i.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)},r.prototype._processSubCameras=function(t){if(t.cameraRigMode===e.Camera.RIG_MODE_NONE)return void this._renderForCamera(t);for(var i=0;i<t._rigCameras.length;i++)this._renderForCamera(t._rigCameras[i]);this.activeCamera=t,this.setTransformMatrix(this.activeCamera.getViewMatrix(),this.activeCamera.getProjectionMatrix()),this.activeCamera._updateFromScene()},r.prototype._checkIntersections=function(){for(var t=0;t<this._meshesForIntersections.length;t++)for(var i=this._meshesForIntersections.data[t],r=0;r<i.actionManager.actions.length;r++){var n=i.actionManager.actions[r];if(n.trigger===e.ActionManager.OnIntersectionEnterTrigger||n.trigger===e.ActionManager.OnIntersectionExitTrigger){var s=n.getTriggerParameter(),o=s instanceof e.AbstractMesh?s:s.mesh,a=o.intersectsMesh(i,s.usePreciseIntersection),h=i._intersectionsInProgress.indexOf(o);a&&-1===h?n.trigger===e.ActionManager.OnIntersectionEnterTrigger?(n._executeCurrent(e.ActionEvent.CreateNew(i,null,o)),i._intersectionsInProgress.push(o)):n.trigger===e.ActionManager.OnIntersectionExitTrigger&&i._intersectionsInProgress.push(o):!a&&h>-1&&(n.trigger===e.ActionManager.OnIntersectionExitTrigger&&n._executeCurrent(e.ActionEvent.CreateNew(i,null,o)),i.actionManager.hasSpecificTrigger(e.ActionManager.OnIntersectionExitTrigger)&&n.trigger!==e.ActionManager.OnIntersectionExitTrigger||i._intersectionsInProgress.splice(h,1))}}},r.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(r.MinDeltaTime,Math.min(this._engine.getDeltaTime(),r.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 i=(e.Tools.Now,this.getEngine()),n=this.activeCamera;if(this.renderTargetsEnabled){e.Tools.StartPerformanceCounter("Custom render targets",this.customRenderTargets.length>0);for(var s=0;s<this.customRenderTargets.length;s++){var o=this.customRenderTargets[s];if(o._shouldRender()){if(this._renderId++,this.activeCamera=o.activeCamera||this.activeCamera,!this.activeCamera)throw new Error("Active camera not set");i.setViewport(this.activeCamera.viewport),this.updateTransformMatrix(),o.render(n!==this.activeCamera,this.dumpNextRenderTargets)}}e.Tools.EndPerformanceCounter("Custom render targets",this.customRenderTargets.length>0),this._renderId++}if(this.offscreenRenderTarget?i.bindFramebuffer(this.offscreenRenderTarget._texture):this.customRenderTargets.length>0&&i.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 h=this._proceduralTextures[a];h._shouldRender()&&h.render()}e.Tools.EndPerformanceCounter("Procedural textures",this._proceduralTextures.length>0)}if(this._engine.clear(this.clearColor,this.autoClear||this.forceWireframe||this.forcePointsCloud,!0,!0),this.shadowsEnabled)for(var u=0;u<this.lights.length;u++){var c=this.lights[u],l=c.getShadowGenerator();c.isEnabled()&&l&&-1!==l.getShadowMap().getScene().textures.indexOf(l.getShadowMap())&&this._renderTargets.push(l.getShadowMap())}if(this._depthRenderer&&this._renderTargets.push(this._depthRenderer.getDepthMap()),this._postProcessRenderPipelineManager&&this._postProcessRenderPipelineManager.update(),this.activeCameras.length>0)for(var f=0;f<this.activeCameras.length;f++)f>0&&this._engine.clear(null,!1,!0,!0),this._processSubCameras(this.activeCameras[f]);else{if(!this.activeCamera)throw new Error("No camera defined");this._processSubCameras(this.activeCamera)}this._checkIntersections(),e.AudioEngine&&this._updateAudioParameters(),this.afterRender&&this.afterRender(),this.onAfterRenderObservable.notifyObservers(this);for(var d=0;d<this._toBeDisposed.length;d++)this._toBeDisposed.data[d].dispose(),this._toBeDisposed[d]=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)}},r.prototype._updateAudioParameters=function(){if(this.audioEnabled&&(0!==this.mainSoundTrack.soundCollection.length||1!==this.soundTracks.length)){var t,i=e.Engine.audioEngine;if((t=this.activeCameras.length>0?this.activeCameras[0]:this.activeCamera)&&i.canUseWebAudio){i.audioContext.listener.setPosition(t.position.x,t.position.y,t.position.z);var r=e.Matrix.Invert(t.getViewMatrix()),n=e.Vector3.TransformNormal(new e.Vector3(0,0,-1),r);n.normalize(),i.audioContext.listener.setOrientation(n.x,n.y,n.z,0,1,0);var s;for(s=0;s<this.mainSoundTrack.soundCollection.length;s++){var o=this.mainSoundTrack.soundCollection[s];o.useCustomAttenuation&&o.updateDistanceFromListener()}for(s=0;s<this.soundTracks.length;s++)for(var a=0;a<this.soundTracks[s].soundCollection.length;a++)o=this.soundTracks[s].soundCollection[a],o.useCustomAttenuation&&o.updateDistanceFromListener()}}},Object.defineProperty(r.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}),r.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()},r.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(r.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}),r.prototype._switchAudioModeForHeadphones=function(){this.mainSoundTrack.switchPanningModelToHRTF();for(var e=0;e<this.soundTracks.length;e++)this.soundTracks[e].switchPanningModelToHRTF()},r.prototype._switchAudioModeForNormalSpeakers=function(){this.mainSoundTrack.switchPanningModelToEqualPower();for(var e=0;e<this.soundTracks.length;e++)this.soundTracks[e].switchPanningModelToEqualPower()},r.prototype.enableDepthRenderer=function(){return this._depthRenderer?this._depthRenderer:(this._depthRenderer=new e.DepthRenderer(this),this._depthRenderer)},r.prototype.disableDepthRenderer=function(){this._depthRenderer&&(this._depthRenderer.dispose(),this._depthRenderer=null)},r.prototype.freezeMaterials=function(){for(var e=0;e<this.materials.length;e++)this.materials[e].freeze()},r.prototype.unfreezeMaterials=function(){for(var e=0;e<this.materials.length;e++)this.materials[e].unfreeze()},r.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._edgesRenderers.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,i=this._engine.getRenderingCanvas();for(t=0;t<this.cameras.length;t++)this.cameras[t].detachControl(i);for(;this.lights.length;)this.lights[0].dispose();for(;this.meshes.length;)this.meshes[0].dispose(!0);for(;this.cameras.length;)this.cameras[0].dispose();for(;this.materials.length;)this.materials[0].dispose();for(;this.particleSystems.length;)this.particleSystems[0].dispose();for(;this.spriteManagers.length;)this.spriteManagers[0].dispose();for(;this.layers.length;)this.layers[0].dispose();for(;this.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(r.prototype,"isDisposed",{get:function(){return!this._engine},enumerable:!0,configurable:!0}),r.prototype.disposeSounds=function(){this.mainSoundTrack.dispose();for(var e=0;e<this.soundTracks.length;e++)this.soundTracks[e].dispose()},r.prototype.getWorldExtends=function(){for(var t=new e.Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),i=new e.Vector3(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),r=0;r<this.meshes.length;r++){var n=this.meshes[r];n.computeWorldMatrix(!0);var s=n.getBoundingInfo().boundingBox.minimumWorld,o=n.getBoundingInfo().boundingBox.maximumWorld;e.Tools.CheckExtends(s,t,i),e.Tools.CheckExtends(o,t,i)}return{min:t,max:i}},r.prototype.createOrUpdateSelectionOctree=function(t,i){void 0===t&&(t=64),void 0===i&&(i=2),this._selectionOctree||(this._selectionOctree=new e.Octree(e.Octree.CreationFuncForMeshes,t,i));var r=this.getWorldExtends();return this._selectionOctree.update(r.min,r.max,this.meshes),this._selectionOctree},r.prototype.createPickingRay=function(t,i,r,n,s){void 0===s&&(s=!1);var o=this._engine;if(!n){if(!this.activeCamera)throw new Error("Active camera not set");n=this.activeCamera}var a=n.viewport,h=a.toGlobal(o.getRenderWidth(),o.getRenderHeight());return t=t/this._engine.getHardwareScalingLevel()-h.x,i=i/this._engine.getHardwareScalingLevel()-(this._engine.getRenderHeight()-h.y-h.height),e.Ray.CreateNew(t,i,h.width,h.height,r||e.Matrix.Identity(),s?e.Matrix.Identity():n.getViewMatrix(),n.getProjectionMatrix())},r.prototype.createPickingRayInCameraSpace=function(t,i,r){if(!e.PickingInfo)return null;var n=this._engine;if(!r){if(!this.activeCamera)throw new Error("Active camera not set");r=this.activeCamera}var s=r.viewport,o=s.toGlobal(n.getRenderWidth(),n.getRenderHeight()),a=e.Matrix.Identity();return t=t/this._engine.getHardwareScalingLevel()-o.x,i=i/this._engine.getHardwareScalingLevel()-(this._engine.getRenderHeight()-o.y-o.height),e.Ray.CreateNew(t,i,o.width,o.height,a,a,r.getProjectionMatrix())},r.prototype._internalPick=function(t,i,r){if(!e.PickingInfo)return null;for(var n=null,s=0;s<this.meshes.length;s++){var o=this.meshes[s];if(i){if(!i(o))continue}else if(!o.isEnabled()||!o.isVisible||!o.isPickable)continue;var a=o.getWorldMatrix(),h=t(a),u=o.intersects(h,r);if(u&&u.hit&&((r||null==n||!(u.distance>=n.distance))&&(n=u,r)))break}return n||new e.PickingInfo},r.prototype._internalMultiPick=function(t,i){if(!e.PickingInfo)return null;for(var r=new Array,n=0;n<this.meshes.length;n++){var s=this.meshes[n];if(i){if(!i(s))continue}else if(!s.isEnabled()||!s.isVisible||!s.isPickable)continue;var o=s.getWorldMatrix(),a=t(o),h=s.intersects(a,!1);h&&h.hit&&r.push(h)}return r},r.prototype._internalPickSprites=function(t,i,r,n){if(!e.PickingInfo)return null;var s=null;if(n=n||this.activeCamera,this.spriteManagers.length>0)for(var o=0;o<this.spriteManagers.length;o++){var a=this.spriteManagers[o];if(a.isPickable){var h=a.intersects(t,n,i,r);if(h&&h.hit&&(r||null==s||!(h.distance>=s.distance))&&(s=h,r))break}}return s||new e.PickingInfo},r.prototype.pick=function(e,t,i,r,n){var s=this;return this._internalPick((function(i){return s.createPickingRay(e,t,i,n)}),i,r)},r.prototype.pickSprite=function(e,t,i,r,n){return this._internalPickSprites(this.createPickingRayInCameraSpace(e,t,n),i,r,n)},r.prototype.pickWithRay=function(t,i,r){var n=this;return this._internalPick((function(i){return n._pickWithRayInverseMatrix||(n._pickWithRayInverseMatrix=e.Matrix.Identity()),i.invertToRef(n._pickWithRayInverseMatrix),e.Ray.Transform(t,n._pickWithRayInverseMatrix)}),i,r)},r.prototype.multiPick=function(e,t,i,r){var n=this;return this._internalMultiPick((function(i){return n.createPickingRay(e,t,i,r)}),i)},r.prototype.multiPickWithRay=function(t,i){var r=this;return this._internalMultiPick((function(i){return r._pickWithRayInverseMatrix||(r._pickWithRayInverseMatrix=e.Matrix.Identity()),i.invertToRef(r._pickWithRayInverseMatrix),e.Ray.Transform(t,r._pickWithRayInverseMatrix)}),i)},r.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)))},r.prototype.getPointerOverMesh=function(){return this._pointerOverMesh},r.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)))},r.prototype.getPointerOverSprite=function(){return this._pointerOverSprite},r.prototype.getPhysicsEngine=function(){return this._physicsEngine},r.prototype.enablePhysics=function(t,i){if(this._physicsEngine)return!0;try{return this._physicsEngine=new e.PhysicsEngine(t,i),!0}catch(t){return e.Tools.Error(t.message),!1}},r.prototype.disablePhysicsEngine=function(){this._physicsEngine&&(this._physicsEngine.dispose(),this._physicsEngine=void 0)},r.prototype.isPhysicsEnabled=function(){return void 0!==this._physicsEngine},r.prototype.deleteCompoundImpostor=function(e){var t=e.parts[0].mesh;t.physicsImpostor.dispose(),t.physicsImpostor=null},r.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 i,r=this.getWorldExtends(),n=r.max.subtract(r.min),s=r.min.add(n.scale(.5)),o=1.5*n.length();if(t){var a=new e.ArcRotateCamera("default camera",4.712,1.571,o,s,this);a.lowerRadiusLimit=.01*o,a.wheelPrecision=100/o,i=a}else{var h=new e.FreeCamera("default camera",new e.Vector3(s.x,s.y,this.useRightHandedSystem?-o:o),this);h.setTarget(s),i=h}i.minZ=.01*o,i.maxZ=100*o,i.speed=.2*o,this.activeCamera=i}},r.prototype._getByTags=function(t,i,r){if(void 0===i)return t;var n=[];r=r||function(e){};for(var s in t){var o=t[s];e.Tags.MatchesQuery(o,i)&&(n.push(o),r(o))}return n},r.prototype.getMeshesByTags=function(e,t){return this._getByTags(this.meshes,e,t)},r.prototype.getCamerasByTags=function(e,t){return this._getByTags(this.cameras,e,t)},r.prototype.getLightsByTags=function(e,t){return this._getByTags(this.lights,e,t)},r.prototype.getMaterialByTags=function(e,t){return this._getByTags(this.materials,e,t).concat(this._getByTags(this.multiMaterials,e,t))},r.prototype.setRenderingOrder=function(e,t,i,r){void 0===t&&(t=null),void 0===i&&(i=null),void 0===r&&(r=null),this._renderingManager.setRenderingOrder(e,t,i,r)},r.prototype.setRenderingAutoClearDepthStencil=function(e,t,i,r){void 0===i&&(i=!0),void 0===r&&(r=!0),this._renderingManager.setRenderingAutoClearDepthStencil(e,t,i,r)},r.prototype.markAllMaterialsAsDirty=function(e,t){for(var i=0,r=this.materials;i<r.length;i++){var n=r[i];t&&!t(n)||n.markAsDirty(e)}},r})();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,i,r,n,s,o){t instanceof e.Mesh?this._engine=t.getScene().getEngine():this._engine=t,this._updatable=r,this._data=i,this._strideSize=n,s||this.create(),this._instanced=o}return t.prototype.createVertexBuffer=function(t,i,r,n){return new e.VertexBuffer(this._engine,this,t,this._updatable,!0,n||this._strideSize,this._instanced,i,r)},t.prototype.isUpdatable=function(){return this._updatable},t.prototype.getData=function(){return this._data},t.prototype.getBuffer=function(){return this._buffer},t.prototype.getStrideSize=function(){return this._strideSize},t.prototype.getIsInstanced=function(){return this._instanced},t.prototype.create=function(e){!e&&this._buffer||(e=e||this._data,this._buffer?this._updatable&&(this._engine.updateDynamicVertexBuffer(this._buffer,e),this._data=e):this._updatable?(this._buffer=this._engine.createDynamicVertexBuffer(e),this._data=e):this._buffer=this._engine.createVertexBuffer(e))},t.prototype.update=function(e){this.create(e)},t.prototype.updateDirectly=function(e,t,i){this._buffer&&this._updatable&&(this._engine.updateDynamicVertexBuffer(this._buffer,e,t,i?i*this.getStrideSize():void 0),this._data=null)},t.prototype.dispose=function(){this._buffer&&this._engine._releaseBuffer(this._buffer)&&(this._buffer=null)},t})();e.Buffer=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(i,r,n,s,o,a,h,u,c){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}r instanceof e.Buffer?(a||(a=r.getStrideSize()),this._buffer=r,this._ownsBuffer=!1):(this._buffer=new e.Buffer(i,r,s,a,o,h),this._ownsBuffer=!0),this._stride=a,this._offset=u||0,this._size=c||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(i){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=i||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),
  11. this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!0,configurable:!0}),t.prototype.getScene=function(){return this._scene},t.prototype.getTextureMatrix=function(){return null},t.prototype.getReflectionTextureMatrix=function(){return null},t.prototype.getInternalTexture=function(){return this._texture},t.prototype.isReady=function(){return this.delayLoadState===e.Engine.DELAYLOADSTATE_NOTLOADED?(this.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 i=this._scene.getEngine().getLoadedTexturesCache(),r=0;r<i.length;r++){var n=i[r];if(n.url===e&&n.noMipmap===t)return void i.splice(r,1)}},t.prototype._getFromCache=function(e,t,i){for(var r=this._scene.getEngine().getLoadedTexturesCache(),n=0;n<r.length;n++){var s=r[n];if(s.url===e&&s.noMipmap===t&&(!i||i===s.samplingMode))return s.references++,s}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 i(r,n,s,o,a,h,u,c,l,f){void 0===s&&(s=!1),void 0===o&&(o=!0),void 0===a&&(a=i.TRILINEAR_SAMPLINGMODE),void 0===h&&(h=null),void 0===u&&(u=null),void 0===c&&(c=null),void 0===l&&(l=!1);var d=t.call(this,n)||this;if(d.uOffset=0,d.vOffset=0,d.uScale=1,d.vScale=1,d.uAng=0,d.vAng=0,d.wAng=0,d.name=r,d.url=r,d._noMipmap=s,d._invertY=o,d._samplingMode=a,d._buffer=c,d._deleteBuffer=l,d._format=f,n=d.getScene(),!r)return d;d._texture=d._getFromCache(r,s,a);var p=function(){d._onLoadObservarble&&d._onLoadObservarble.hasObservers()&&d.onLoadObservable.notifyObservers(!0),h&&h()};return 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=u):(d._texture=n.getEngine().createTexture(r,s,o,n,d._samplingMode,p,u,d._buffer,null,d._format),l&&delete d._buffer),d}return __extends(i,t),Object.defineProperty(i.prototype,"noMipmap",{get:function(){return this._noMipmap},enumerable:!0,configurable:!0}),i.prototype.delayLoad=function(){this.delayLoadState===e.Engine.DELAYLOADSTATE_NOTLOADED&&(this.delayLoadState=e.Engine.DELAYLOADSTATE_LOADED,this._texture=this._getFromCache(this.url,this._noMipmap,this._samplingMode),this._texture||(this._texture=this.getScene().getEngine().createTexture(this.url,this._noMipmap,this._invertY,this.getScene(),this._samplingMode,this._delayedOnLoad,this._delayedOnError,this._buffer,null,this._format),this._deleteBuffer&&delete this._buffer))},i.prototype.updateSamplingMode=function(e){this._texture&&(this._samplingMode=e,this.getScene().getEngine().updateTextureSamplingMode(e,this._texture))},i.prototype._prepareRowForTextureGeneration=function(t,i,r,n){t*=this.uScale,i*=this.vScale,t-=.5*this.uScale,i-=.5*this.vScale,r-=.5,e.Vector3.TransformCoordinatesFromFloatsToRef(t,i,r,this._rowGenerationMatrix,n),n.x+=.5*this.uScale+this.uOffset,n.y+=.5*this.vScale+this.vOffset,n.z+=.5},i.prototype.getTextureMatrix=function(){return this.uOffset===this._cachedUOffset&&this.vOffset===this._cachedVOffset&&this.uScale===this._cachedUScale&&this.vScale===this._cachedVScale&&this.uAng===this._cachedUAng&&this.vAng===this._cachedVAng&&this.wAng===this._cachedWAng?this._cachedTextureMatrix:(this._cachedUOffset=this.uOffset,this._cachedVOffset=this.vOffset,this._cachedUScale=this.uScale,this._cachedVScale=this.vScale,this._cachedUAng=this.uAng,this._cachedVAng=this.vAng,this._cachedWAng=this.wAng,this._cachedTextureMatrix||(this._cachedTextureMatrix=e.Matrix.Zero(),this._rowGenerationMatrix=new e.Matrix,this._t0=e.Vector3.Zero(),this._t1=e.Vector3.Zero(),this._t2=e.Vector3.Zero()),e.Matrix.RotationYawPitchRollToRef(this.vAng,this.uAng,this.wAng,this._rowGenerationMatrix),this._prepareRowForTextureGeneration(0,0,0,this._t0),this._prepareRowForTextureGeneration(1,0,0,this._t1),this._prepareRowForTextureGeneration(0,1,0,this._t2),this._t1.subtractInPlace(this._t0),this._t2.subtractInPlace(this._t0),e.Matrix.IdentityToRef(this._cachedTextureMatrix),this._cachedTextureMatrix.m[0]=this._t1.x,this._cachedTextureMatrix.m[1]=this._t1.y,this._cachedTextureMatrix.m[2]=this._t1.z,this._cachedTextureMatrix.m[4]=this._t2.x,this._cachedTextureMatrix.m[5]=this._t2.y,this._cachedTextureMatrix.m[6]=this._t2.z,this._cachedTextureMatrix.m[8]=this._t0.x,this._cachedTextureMatrix.m[9]=this._t0.y,this._cachedTextureMatrix.m[10]=this._t0.z,this._cachedTextureMatrix)},i.prototype.getReflectionTextureMatrix=function(){if(this.uOffset===this._cachedUOffset&&this.vOffset===this._cachedVOffset&&this.uScale===this._cachedUScale&&this.vScale===this._cachedVScale&&this.coordinatesMode===this._cachedCoordinatesMode)return this._cachedTextureMatrix;switch(this._cachedTextureMatrix||(this._cachedTextureMatrix=e.Matrix.Zero(),this._projectionModeMatrix=e.Matrix.Zero()),this._cachedCoordinatesMode=this.coordinatesMode,this.coordinatesMode){case i.PLANAR_MODE:e.Matrix.IdentityToRef(this._cachedTextureMatrix),this._cachedTextureMatrix[0]=this.uScale,this._cachedTextureMatrix[5]=this.vScale,this._cachedTextureMatrix[12]=this.uOffset,this._cachedTextureMatrix[13]=this.vOffset;break;case i.PROJECTION_MODE:e.Matrix.IdentityToRef(this._projectionModeMatrix),this._projectionModeMatrix.m[0]=.5,this._projectionModeMatrix.m[5]=-.5,this._projectionModeMatrix.m[10]=0,this._projectionModeMatrix.m[12]=.5,this._projectionModeMatrix.m[13]=.5,this._projectionModeMatrix.m[14]=1,this._projectionModeMatrix.m[15]=1,this.getScene().getProjectionMatrix().multiplyToRef(this._projectionModeMatrix,this._cachedTextureMatrix);break;default:e.Matrix.IdentityToRef(this._cachedTextureMatrix)}return this._cachedTextureMatrix},i.prototype.clone=function(){var t=this;return e.SerializationHelper.Clone((function(){return new i(t._texture.url,t.getScene(),t._noMipmap,t._invertY,t._samplingMode)}),this)},Object.defineProperty(i.prototype,"onLoadObservable",{get:function(){return this._onLoadObservarble||(this._onLoadObservarble=new e.Observable),this._onLoadObservarble},enumerable:!0,configurable:!0}),i.CreateFromBase64String=function(t,r,n,s,o,a,h,u,c){return void 0===a&&(a=i.TRILINEAR_SAMPLINGMODE),void 0===h&&(h=null),void 0===u&&(u=null),void 0===c&&(c=e.Engine.TEXTUREFORMAT_RGBA),new i("data:"+r,n,s,o,a,h,u,t,!1,c)},i.Parse=function(t,r,n){if(t.customType){var s=e.Tools.Instantiate(t.customType),o=s.Parse(t,r,n);return t.samplingMode&&o.updateSamplingMode&&o._samplingMode&&o._samplingMode!==t.samplingMode&&o.updateSamplingMode(t.samplingMode),o}if(t.isCube)return e.CubeTexture.Parse(t,r,n);if(!t.name&&!t.isRenderTarget)return null;var a=e.SerializationHelper.Parse((function(){if(t.mirrorPlane){var s=new e.MirrorTexture(t.name,t.renderTargetSize,r);return s._waitingRenderList=t.renderList,s.mirrorPlane=e.Plane.FromArray(t.mirrorPlane),s}if(t.isRenderTarget){var o=new e.RenderTargetTexture(t.name,t.renderTargetSize,r);return o._waitingRenderList=t.renderList,o}return t.base64String?i.CreateFromBase64String(t.base64String,t.name,r):new i(n+t.name,r)}),t,r);if(t.samplingMode){var h=t.samplingMode;a._samplingMode!==h&&a.updateSamplingMode(h)}if(t.animations)for(var u=0;u<t.animations.length;u++){var c=t.animations[u];a.animations.push(e.Animation.Parse(c))}return a},i.LoadFromDataString=function(t,r,n,s,o,a,h,u,c,l){return void 0===s&&(s=!1),void 0===o&&(o=!1),void 0===a&&(a=!0),void 0===h&&(h=i.TRILINEAR_SAMPLINGMODE),void 0===u&&(u=null),void 0===c&&(c=null),void 0===l&&(l=e.Engine.TEXTUREFORMAT_RGBA),"data:"!==t.substr(0,5)&&(t="data:"+t),new i(t,n,o,a,h,u,c,r,s,l)},i})(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),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 i=(function(i){function r(n,s,o,a,h,u){void 0===o&&(o=null),void 0===u&&(u=!0);var c=i.call(this,n,s)||this;if(c.onBeforeRenderObservable=new e.Observable,c.onAfterRenderObservable=new e.Observable,c.onBeforeDrawObservable=new e.Observable,c.delayLoadState=e.Engine.DELAYLOADSTATE_NONE,c.instances=new Array,c._LODLevels=new Array,c._visibleInstances={},c._renderIdForInstances=new Array,c._batchCache=new t,c._instancesBufferSize=2048,c._sideOrientation=r._DEFAULTSIDE,c._areNormalsFrozen=!1,c._source=null,a){c._source=a,a._geometry&&a._geometry.applyToMesh(c),e.Tools.DeepCopy(a,c,["name","material","skeleton","instances","parent","uniqueId"],["_poseMatrix"]),c.parent=a.parent,c.setPivotMatrix(a.getPivotMatrix()),c.id=n+"."+a.id,c.material=a.material;var l;if(!h)for(l=0;l<s.meshes.length;l++){var f=s.meshes[l];if(f.parent===a){f.clone(n+"."+f.name,c,h)}}var d=c.getScene().getPhysicsEngine();if(u&&d){var p=d.getImpostorForPhysicsObject(a);p&&(c.physicsImpostor=p.clone(c))}for(l=0;l<s.particleSystems.length;l++){var _=s.particleSystems[l];_.emitter===a&&_.clone(_.name,c)}c.computeWorldMatrix(!0)}return null!==o&&(c.parent=o),c}return __extends(r,i),Object.defineProperty(r,"FRONTSIDE",{get:function(){return r._FRONTSIDE},enumerable:!0,configurable:!0}),Object.defineProperty(r,"BACKSIDE",{get:function(){return r._BACKSIDE},enumerable:!0,configurable:!0}),Object.defineProperty(r,"DOUBLESIDE",{get:function(){return r._DOUBLESIDE},enumerable:!0,configurable:!0}),Object.defineProperty(r,"DEFAULTSIDE",{get:function(){return r._DEFAULTSIDE},enumerable:!0,configurable:!0}),Object.defineProperty(r,"NO_CAP",{get:function(){return r._NO_CAP},enumerable:!0,configurable:!0}),Object.defineProperty(r,"CAP_START",{get:function(){return r._CAP_START},enumerable:!0,configurable:!0}),Object.defineProperty(r,"CAP_END",{get:function(){return r._CAP_END},enumerable:!0,configurable:!0}),Object.defineProperty(r,"CAP_ALL",{get:function(){return r._CAP_ALL},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"onBeforeDraw",{set:function(e){this._onBeforeDrawObserver&&this.onBeforeDrawObservable.remove(this._onBeforeDrawObserver),this._onBeforeDrawObserver=this.onBeforeDrawObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"morphTargetManager",{get:function(){return this._morphTargetManager},set:function(e){this._morphTargetManager!==e&&(this._morphTargetManager=e,this._syncGeometryWithMorphTargetManager())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"source",{get:function(){return this._source},enumerable:!0,configurable:!0}),r.prototype.getClassName=function(){return"Mesh"},r.prototype.toString=function(t){var r=i.prototype.toString.call(this,t);if(r+=", n vertices: "+this.getTotalVertices(),r+=", parent: "+(this._waitingParentId?this._waitingParentId:this.parent?this.parent.name:"NONE"),this.animations)for(var n=0;n<this.animations.length;n++)r+=", animation[0]: "+this.animations[n].toString(t);return t&&(r+=", flat shading: "+(this._geometry?this.getVerticesData(e.VertexBuffer.PositionKind).length/3===this.getIndices().length?"YES":"NO":"UNKNOWN")),r},Object.defineProperty(r.prototype,"hasLODLevels",{get:function(){return this._LODLevels.length>0},enumerable:!0,configurable:!0}),r.prototype._sortLODLevels=function(){this._LODLevels.sort((function(e,t){return e.distance<t.distance?1:e.distance>t.distance?-1:0}))},r.prototype.addLODLevel=function(t,i){if(i&&i._masterMesh)return e.Tools.Warn("You cannot use a mesh as LOD level twice"),this;var r=new e.Internals.MeshLODLevel(t,i);return this._LODLevels.push(r),i&&(i._masterMesh=this),this._sortLODLevels(),this},r.prototype.getLODLevelAtDistance=function(e){for(var t=0;t<this._LODLevels.length;t++){var i=this._LODLevels[t];if(i.distance===e)return i.mesh}return null},r.prototype.removeLODLevel=function(e){for(var t=0;t<this._LODLevels.length;t++)this._LODLevels[t].mesh===e&&(this._LODLevels.splice(t,1),e&&(e._masterMesh=null));return this._sortLODLevels(),this},r.prototype.getLOD=function(e,t){if(!this._LODLevels||0===this._LODLevels.length)return this;var i=(t||this.getBoundingInfo().boundingSphere).centerWorld.subtract(e.globalPosition).length();if(this._LODLevels[this._LODLevels.length-1].distance>i)return this.onLODLevelSelection&&this.onLODLevelSelection(i,this,this._LODLevels[this._LODLevels.length-1].mesh),this;for(var r=0;r<this._LODLevels.length;r++){var n=this._LODLevels[r];if(n.distance<i)return n.mesh&&(n.mesh._preActivate(),n.mesh._updateSubMeshesBoundingInfo(this.worldMatrixFromCache)),this.onLODLevelSelection&&this.onLODLevelSelection(i,this,n.mesh),n.mesh}return this.onLODLevelSelection&&this.onLODLevelSelection(i,this,this),this},Object.defineProperty(r.prototype,"geometry",{get:function(){return this._geometry},enumerable:!0,configurable:!0}),r.prototype.getTotalVertices=function(){return this._geometry?this._geometry.getTotalVertices():0},r.prototype.getVerticesData=function(e,t,i){return this._geometry?this._geometry.getVerticesData(e,t,i):null},r.prototype.getVertexBuffer=function(e){if(this._geometry)return this._geometry.getVertexBuffer(e)},r.prototype.isVerticesDataPresent=function(e){return this._geometry?this._geometry.isVerticesDataPresent(e):!!this._delayInfo&&-1!==this._delayInfo.indexOf(e)},r.prototype.getVerticesDataKinds=function(){if(!this._geometry){var e=[];return this._delayInfo&&this._delayInfo.forEach((function(t,i,r){e.push(t)})),e}return this._geometry.getVerticesDataKinds()},r.prototype.getTotalIndices=function(){return this._geometry?this._geometry.getTotalIndices():0},r.prototype.getIndices=function(e){return this._geometry?this._geometry.getIndices(e):[]},Object.defineProperty(r.prototype,"isBlocked",{get:function(){return null!==this._masterMesh&&void 0!==this._masterMesh},enumerable:!0,configurable:!0}),r.prototype.isReady=function(){return this.delayLoadState!==e.Engine.DELAYLOADSTATE_LOADING&&i.prototype.isReady.call(this)},r.prototype.isDisposed=function(){return this._isDisposed},Object.defineProperty(r.prototype,"sideOrientation",{get:function(){return this._sideOrientation},set:function(e){this._sideOrientation=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"areNormalsFrozen",{get:function(){return this._areNormalsFrozen},enumerable:!0,configurable:!0}),r.prototype.freezeNormals=function(){return this._areNormalsFrozen=!0,this},r.prototype.unfreezeNormals=function(){return this._areNormalsFrozen=!1,this},Object.defineProperty(r.prototype,"overridenInstanceCount",{set:function(e){this._overridenInstanceCount=e},enumerable:!0,configurable:!0}),r.prototype._preActivate=function(){var e=this.getScene().getRenderId();return this._preActivateId===e?this:(this._preActivateId=e,this._visibleInstances=null,this)},r.prototype._preActivateForIntermediateRendering=function(e){return this._visibleInstances&&(this._visibleInstances.intermediateDefaultRenderId=e),this},r.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},r.prototype.refreshBoundingInfo=function(){if(!this._boundingInfo.isLocked){var t=this.getVerticesData(e.VertexBuffer.PositionKind);if(t){var i=e.Tools.ExtractMinAndMax(t,0,this.getTotalVertices());this._boundingInfo=new e.BoundingInfo(i.minimum,i.maximum)}if(this.subMeshes)for(var r=0;r<this.subMeshes.length;r++)this.subMeshes[r].refreshBoundingInfo();return this._updateBoundingInfo(),this}},r.prototype._createGlobalSubMesh=function(){var t=this.getTotalVertices();return t&&this.getIndices()?(this.releaseSubMeshes(),new e.SubMesh(0,0,t,0,this.getTotalIndices(),this)):null},r.prototype.subdivide=function(t){if(!(t<1)){for(var i=this.getTotalIndices(),r=i/t|0,n=0;r%3!=0;)r++;this.releaseSubMeshes();for(var s=0;s<t&&!(n>=i);s++)e.SubMesh.CreateFromIndices(0,n,Math.min(r,i-n),this),n+=r;this.synchronizeInstances()}},r.prototype.setVerticesData=function(t,i,r,n){if(this._geometry)this._geometry.setVerticesData(t,i,r,n);else{var s=new e.VertexData;s.set(i,t);var o=this.getScene();new e.Geometry(e.Geometry.RandomId(),o,s,r,this)}return this},r.prototype.markVerticesDataAsUpdatable=function(e,t){void 0===t&&(t=!0),this.getVertexBuffer(e).isUpdatable()!==t&&this.setVerticesData(e,this.getVerticesData(e),t)},r.prototype.setVerticesBuffer=function(t){if(!this._geometry){var i=this.getScene();new e.Geometry(e.Geometry.RandomId(),i).applyToMesh(this)}return this._geometry.setVerticesBuffer(t),this},r.prototype.updateVerticesData=function(e,t,i,r){if(this._geometry)return r?(this.makeGeometryUnique(),this.updateVerticesData(e,t,i,!1)):this._geometry.updateVerticesData(e,t,i),this},r.prototype.updateMeshPositions=function(t,i){void 0===i&&(i=!0);var r=this.getVerticesData(e.VertexBuffer.PositionKind);if(t(r),this.updateVerticesData(e.VertexBuffer.PositionKind,r,!1,!1),i){var n=this.getIndices(),s=this.getVerticesData(e.VertexBuffer.NormalKind);e.VertexData.ComputeNormals(r,n,s),this.updateVerticesData(e.VertexBuffer.NormalKind,s,!1,!1)}return this},r.prototype.makeGeometryUnique=function(){if(this._geometry){var t=this._geometry,i=this._geometry.copy(e.Geometry.RandomId());return t.releaseForMesh(this,!0),i.applyToMesh(this),this}},r.prototype.setIndices=function(t,i){if(this._geometry)this._geometry.setIndices(t,i);else{var r=new e.VertexData;r.indices=t;var n=this.getScene();new e.Geometry(e.Geometry.RandomId(),n,r,!1,this)}return this},r.prototype.toLeftHanded=function(){if(this._geometry)return this._geometry.toLeftHanded(),this},r.prototype._bind=function(t,i,r){var n,s=this.getScene().getEngine();if(this._unIndexed)n=null;else switch(r){case e.Material.PointFillMode:n=null;break;case e.Material.WireFrameFillMode:n=t.getLinesIndexBuffer(this.getIndices(),s);break;default:case e.Material.TriangleFillMode:n=this._unIndexed?null:this._geometry.getIndexBuffer()}return this._geometry._bind(i,n),this},r.prototype._draw=function(t,i,r){if(!this._geometry||!this._geometry.getVertexBuffers()||!this._geometry.getIndexBuffer())return this;this.onBeforeDrawObservable.notifyObservers(this);var n=this.getScene().getEngine();switch(i){case e.Material.PointFillMode:n.drawPointClouds(t.verticesStart,t.verticesCount,r);break;case e.Material.WireFrameFillMode:this._unIndexed?n.drawUnIndexed(!1,t.verticesStart,t.verticesCount,r):n.draw(!1,0,r>0?t.linesIndexCount/2:t.linesIndexCount,r);break;default:this._unIndexed?n.drawUnIndexed(!0,t.verticesStart,t.verticesCount,r):n.draw(!0,t.indexStart,t.indexCount,r)}return this},r.prototype.registerBeforeRender=function(e){return this.onBeforeRenderObservable.add(e),this},r.prototype.unregisterBeforeRender=function(e){return this.onBeforeRenderObservable.removeCallback(e),this},r.prototype.registerAfterRender=function(e){return this.onAfterRenderObservable.add(e),this},r.prototype.unregisterAfterRender=function(e){return this.onAfterRenderObservable.removeCallback(e),this},r.prototype._getInstancesRenderList=function(e){var t=this.getScene();if(this._batchCache.mustReturn=!1,this._batchCache.renderSelf[e]=this.isEnabled()&&this.isVisible,this._batchCache.visibleInstances[e]=null,this._visibleInstances){var i=t.getRenderId(),r=t._isInIntermediateRendering()?this._visibleInstances.intermediateDefaultRenderId:this._visibleInstances.defaultRenderId;this._batchCache.visibleInstances[e]=this._visibleInstances[i];var n=this._renderId;if(!this._batchCache.visibleInstances[e]&&r&&(this._batchCache.visibleInstances[e]=this._visibleInstances[r],i=Math.max(r,i),n=Math.max(this._visibleInstances.selfDefaultRenderId,i)),this._batchCache.visibleInstances[e]&&this._batchCache.visibleInstances[e].length){if(this._renderIdForInstances[e]===i)return this._batchCache.mustReturn=!0,this._batchCache;i!==n&&(this._batchCache.renderSelf[e]=!1)}this._renderIdForInstances[e]=i}return this._batchCache},r.prototype._renderWithInstances=function(t,i,r,n,s){for(var o=r.visibleInstances[t._id],a=o.length+1,h=16*a*4,u=this._instancesBufferSize,c=this._instancesBuffer;this._instancesBufferSize<h;)this._instancesBufferSize*=2;this._instancesData&&u==this._instancesBufferSize||(this._instancesData=new Float32Array(this._instancesBufferSize/4));var l=0,f=0,d=this.getWorldMatrix();if(r.renderSelf[t._id]&&(d.copyToArray(this._instancesData,l),l+=16,f++),o)for(var p=0;p<o.length;p++){var _=o[p];_.getWorldMatrix().copyToArray(this._instancesData,l),l+=16,f++}return c&&u==this._instancesBufferSize?c.updateDirectly(this._instancesData,0,f):(c&&c.dispose(),c=new e.Buffer(s,this._instancesData,!0,16,!1,!0),this._instancesBuffer=c,this.setVerticesBuffer(c.createVertexBuffer("world0",0,4)),this.setVerticesBuffer(c.createVertexBuffer("world1",4,4)),this.setVerticesBuffer(c.createVertexBuffer("world2",8,4)),this.setVerticesBuffer(c.createVertexBuffer("world3",12,4))),this.geometry._bind(n),this._draw(t,i,f),s.unbindInstanceAttributes(),this},r.prototype._processRendering=function(e,t,i,r,n,s,o){var a=this.getScene(),h=a.getEngine();if(n)this._renderWithInstances(e,i,r,t,h);else if(r.renderSelf[e._id]&&(s&&s(!1,this.getWorldMatrix(),o),this._draw(e,i,this._overridenInstanceCount)),r.visibleInstances[e._id])for(var u=0;u<r.visibleInstances[e._id].length;u++){var c=r.visibleInstances[e._id][u],l=c.getWorldMatrix();s&&s(!0,l,o),this._draw(e,i)}return this},r.prototype.render=function(t,i){var r=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 s=r.getEngine(),o=null!==s.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,o))return this}else if(!a.isReady(this,o))return this;var h=s.getDepthWrite();this.renderOutline&&(s.setDepthWrite(!1),r.getOutlineRenderer().render(t,n),s.setDepthWrite(h));var u;u=a.storeEffectOnSubMeshes?t.effect:a.getEffect(),a._preBind(u);var c=r.forcePointsCloud?e.Material.PointFillMode:r.forceWireframe?e.Material.WireFrameFillMode:a.fillMode;this._bind(t,u,c);var l=this.getWorldMatrix();if(a.storeEffectOnSubMeshes?a.bindForSubMesh(l,this,t):a.bind(l,this),i&&s.setAlphaMode(a.alphaMode),this._processRendering(t,u,c,n,o,this._onBeforeDraw,a),a.unbind(),this.renderOutline&&h&&(s.setDepthWrite(!0),s.setColorWrite(!1),r.getOutlineRenderer().render(t,n),s.setColorWrite(!0)),this.renderOverlay){var f=s.getAlphaMode();s.setAlphaMode(e.Engine.ALPHA_COMBINE),r.getOutlineRenderer().render(t,n,!0),s.setAlphaMode(f)}return this.onAfterRenderObservable.notifyObservers(this),this},r.prototype._onBeforeDraw=function(e,t,i){return e&&i.bindOnlyWorldMatrix(t),this},r.prototype.getEmittedParticleSystems=function(){for(var e=new Array,t=0;t<this.getScene().particleSystems.length;t++){var i=this.getScene().particleSystems[t];i.emitter===this&&e.push(i)}return e},r.prototype.getHierarchyEmittedParticleSystems=function(){var e=new Array,t=this.getDescendants();t.push(this);for(var i=0;i<this.getScene().particleSystems.length;i++){var r=this.getScene().particleSystems[i];-1!==t.indexOf(r.emitter)&&e.push(r)}return e},r.prototype._checkDelayState=function(){var t=this.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},r.prototype._queueLoad=function(t,i){var r=this;i._addPendingData(t);var n=-1!==this.delayLoadingFile.indexOf(".babylonbinarymeshdata");return e.Tools.LoadFile(this.delayLoadingFile,(function(t){t instanceof ArrayBuffer?r._delayLoadingFunction(t,r):r._delayLoadingFunction(JSON.parse(t),r),r.instances.forEach((function(e){e._syncSubMeshes()})),r.delayLoadState=e.Engine.DELAYLOADSTATE_LOADED,i._removePendingData(r)}),(function(){}),i.database,n),this},r.prototype.isInFrustum=function(t){return this.delayLoadState!==e.Engine.DELAYLOADSTATE_LOADING&&(!!i.prototype.isInFrustum.call(this,t)&&(this._checkDelayState(),!0))},r.prototype.setMaterialByID=function(e){var t,i=this.getScene().materials;for(t=i.length-1;t>-1;t--)if(i[t].id===e)return this.material=i[t],this;var r=this.getScene().multiMaterials;for(t=r.length-1;t>-1;t--)if(r[t].id===e)return this.material=r[t],this;return this},r.prototype.getAnimatables=function(){var e=[];return this.material&&e.push(this.material),this.skeleton&&e.push(this.skeleton),e},r.prototype.bakeTransformIntoVertices=function(t){if(!this.isVerticesDataPresent(e.VertexBuffer.PositionKind))return this;var i=this.subMeshes.splice(0);this._resetPointsArrayCache();var r,n=this.getVerticesData(e.VertexBuffer.PositionKind),s=[];for(r=0;r<n.length;r+=3)e.Vector3.TransformCoordinates(e.Vector3.FromArray(n,r),t).toArray(s,r);if(this.setVerticesData(e.VertexBuffer.PositionKind,s,this.getVertexBuffer(e.VertexBuffer.PositionKind).isUpdatable()),!this.isVerticesDataPresent(e.VertexBuffer.NormalKind))return this;for(n=this.getVerticesData(e.VertexBuffer.NormalKind),s=[],r=0;r<n.length;r+=3)e.Vector3.TransformNormal(e.Vector3.FromArray(n,r),t).normalize().toArray(s,r);return this.setVerticesData(e.VertexBuffer.NormalKind,s,this.getVertexBuffer(e.VertexBuffer.NormalKind).isUpdatable()),t.m[0]*t.m[5]*t.m[10]<0&&this.flipFaces(),this.releaseSubMeshes(),this.subMeshes=i,this},r.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},r.prototype._resetPointsArrayCache=function(){return this._positions=null,this},r.prototype._generatePointsArray=function(){if(this._positions)return!0;this._positions=[];var t=this.getVerticesData(e.VertexBuffer.PositionKind);if(!t)return!1;for(var i=0;i<t.length;i+=3)this._positions.push(e.Vector3.FromArray(t,i));return!0},r.prototype.clone=function(e,t,i,n){return void 0===n&&(n=!0),new r(e,this.getScene(),t,this,i,n)},r.prototype.dispose=function(e){var t=this;this.morphTargetManager=void 0,this._geometry&&this._geometry.releaseForMesh(this,!0);var r=this.getScene().meshes;for(r.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,s=0;s<n.length;s++){var o=n[s];o&&(o.removeMesh(this),o.removeExcludedMesh(this))}i.prototype.dispose.call(this,e)},r.prototype.applyDisplacementMap=function(t,i,r,n,s,o){var a=this,h=this.getScene(),u=function(e){var t=document.createElement("canvas"),h=t.getContext("2d"),u=e.width,c=e.height;t.width=u,t.height=c,h.drawImage(e,0,0);var l=h.getImageData(0,0,u,c).data;a.applyDisplacementMapFromBuffer(l,u,c,i,r,s,o),n&&n(a)};return e.Tools.LoadImage(t,u,(function(){}),h.database),this},r.prototype.applyDisplacementMapFromBuffer=function(t,i,r,n,s,o,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 h=this.getVerticesData(e.VertexBuffer.PositionKind),u=this.getVerticesData(e.VertexBuffer.NormalKind),c=this.getVerticesData(e.VertexBuffer.UVKind),l=e.Vector3.Zero(),f=e.Vector3.Zero(),d=e.Vector2.Zero();o=o||e.Vector2.Zero(),a=a||new e.Vector2(1,1);for(var p=0;p<h.length;p+=3){e.Vector3.FromArrayToRef(h,p,l),e.Vector3.FromArrayToRef(u,p,f),e.Vector2.FromArrayToRef(c,p/3*2,d);var _=Math.abs(d.x*a.x+o.x)*i%i|0,m=Math.abs(d.y*a.y+o.y)*r%r|0,g=4*(_+m*i),y=t[g]/255,v=t[g+1]/255,b=t[g+2]/255,x=.3*y+.59*v+.11*b;f.normalize(),f.scaleInPlace(n+(s-n)*x),l=l.add(f),l.toArray(h,p)}return e.VertexData.ComputeNormals(h,this.getIndices(),u),this.updateVerticesData(e.VertexBuffer.PositionKind,h),this.updateVerticesData(e.VertexBuffer.NormalKind,u),this},r.prototype.convertToFlatShadedMesh=function(){var t,i,r=this.getVerticesDataKinds(),n=[],s=[],o=[],a=!1;for(t=0;t<r.length;t++){i=r[t];var h=this.getVertexBuffer(i);i!==e.VertexBuffer.NormalKind?(n[i]=h,s[i]=n[i].getData(),o[i]=[]):(a=h.isUpdatable(),r.splice(t,1),t--)}var u,c=this.subMeshes.slice(0),l=this.getIndices(),f=this.getTotalIndices();for(u=0;u<f;u++){var d=l[u];for(t=0;t<r.length;t++){i=r[t];for(var p=n[i].getStrideSize(),_=0;_<p;_++)o[i].push(s[i][d*p+_])}}var m=[],g=o[e.VertexBuffer.PositionKind];for(u=0;u<f;u+=3){l[u]=u,l[u+1]=u+1,l[u+2]=u+2;for(var y=e.Vector3.FromArray(g,3*u),v=e.Vector3.FromArray(g,3*(u+1)),b=e.Vector3.FromArray(g,3*(u+2)),x=y.subtract(v),T=b.subtract(v),E=e.Vector3.Normalize(e.Vector3.Cross(x,T)),A=0;A<3;A++)m.push(E.x),m.push(E.y),m.push(E.z)}for(this.setIndices(l),this.setVerticesData(e.VertexBuffer.NormalKind,m,a),t=0;t<r.length;t++)i=r[t],this.setVerticesData(i,o[i],n[i].isUpdatable());this.releaseSubMeshes();for(var M=0;M<c.length;M++){var P=c[M]
  12. ;new e.SubMesh(P.materialIndex,P.indexStart,P.indexCount,P.indexStart,P.indexCount,this)}return this.synchronizeInstances(),this},r.prototype.convertToUnIndexedMesh=function(){var t,i,r=this.getVerticesDataKinds(),n=[],s=[],o=[];for(t=0;t<r.length;t++){i=r[t];var a=this.getVertexBuffer(i);n[i]=a,s[i]=n[i].getData(),o[i]=[]}var h,u=this.subMeshes.slice(0),c=this.getIndices(),l=this.getTotalIndices();for(h=0;h<l;h++){var f=c[h];for(t=0;t<r.length;t++){i=r[t];for(var d=n[i].getStrideSize(),p=0;p<d;p++)o[i].push(s[i][f*d+p])}}for(h=0;h<l;h+=3)c[h]=h,c[h+1]=h+1,c[h+2]=h+2;for(this.setIndices(c),t=0;t<r.length;t++)i=r[t],this.setVerticesData(i,o[i],n[i].isUpdatable());this.releaseSubMeshes();for(var _=0;_<u.length;_++){var m=u[_];new e.SubMesh(m.materialIndex,m.indexStart,m.indexCount,m.indexStart,m.indexCount,this)}return this._unIndexed=!0,this.synchronizeInstances(),this},r.prototype.flipFaces=function(t){void 0===t&&(t=!1);var i,r=e.VertexData.ExtractFromMesh(this);if(t&&this.isVerticesDataPresent(e.VertexBuffer.NormalKind))for(i=0;i<r.normals.length;i++)r.normals[i]*=-1;var n;for(i=0;i<r.indices.length;i+=3)n=r.indices[i+1],r.indices[i+1]=r.indices[i+2],r.indices[i+2]=n;return r.applyToMesh(this),this},r.prototype.createInstance=function(t){return new e.InstancedMesh(t,this)},r.prototype.synchronizeInstances=function(){for(var e=0;e<this.instances.length;e++){this.instances[e]._syncSubMeshes()}return this},r.prototype.simplify=function(t,i,r,n){return void 0===i&&(i=!0),void 0===r&&(r=e.SimplificationType.QUADRATIC),this.getScene().simplificationQueue.addTask({settings:t,parallelProcessing:i,mesh:this,simplificationType:r,successCallback:n}),this},r.prototype.optimizeIndices=function(t){for(var i=this,r=this.getIndices(),n=this.getVerticesData(e.VertexBuffer.PositionKind),s=[],o=0;o<n.length;o+=3)s.push(e.Vector3.FromArray(n,o));var a=[];return e.AsyncLoop.SyncAsyncForLoop(s.length,40,(function(e){for(var t=s.length-1-e,i=s[t],r=0;r<t;++r){var n=s[r];if(i.equals(n)){a[t]=r;break}}}),(function(){for(var e=0;e<r.length;++e)r[e]=a[r[e]]||r[e];var n=i.subMeshes.slice(0);i.setIndices(r),i.subMeshes=n,t&&t(i)})),this},r.prototype.serialize=function(t){t.name=this.name,t.id=this.id,t.type=this.getClassName(),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 i=this._geometry;if(i){var r=i.id;t.geometryId=r,t.subMeshes=[];for(var n=0;n<this.subMeshes.length;n++){var s=this.subMeshes[n];t.subMeshes.push({materialIndex:s.materialIndex,verticesStart:s.verticesStart,verticesCount:s.verticesCount,indexStart:s.indexStart,indexCount:s.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 o=this.getPhysicsImpostor();t.physicsMass=o.getParam("mass"),t.physicsFriction=o.getParam("friction"),t.physicsRestitution=o.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 h=this.instances[a],u={name:h.name,position:h.position.asArray(),scaling:h.scaling.asArray()};h.rotationQuaternion?u.rotationQuaternion=h.rotationQuaternion.asArray():h.rotation&&(u.rotation=h.rotation.asArray()),t.instances.push(u),e.Animation.AppendSerializedAnimations(h,u),u.ranges=h.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))},r.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 i=this.morphTargetManager.getActiveTarget(t);this.geometry.setVerticesData(e.VertexBuffer.PositionKind+t,i.getPositions(),!1,3),i.hasNormals&&this.geometry.setVerticesData(e.VertexBuffer.NormalKind+t,i.getNormals(),!1,3),i.hasTangents&&this.geometry.setVerticesData(e.VertexBuffer.TangentKind+t,i.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++},r.Parse=function(t,i,n){var s;if(s=t.type&&"GroundMesh"===t.type?e.GroundMesh.Parse(t,i):new r(t.name,i),s.id=t.id,e.Tags.AddTagsTo(s,t.tags),s.position=e.Vector3.FromArray(t.position),void 0!==t.metadata&&(s.metadata=t.metadata),t.rotationQuaternion?s.rotationQuaternion=e.Quaternion.FromArray(t.rotationQuaternion):t.rotation&&(s.rotation=e.Vector3.FromArray(t.rotation)),s.scaling=e.Vector3.FromArray(t.scaling),t.localMatrix?s.setPivotMatrix(e.Matrix.FromArray(t.localMatrix)):t.pivotMatrix&&s.setPivotMatrix(e.Matrix.FromArray(t.pivotMatrix)),s.setEnabled(t.isEnabled),s.isVisible=t.isVisible,s.infiniteDistance=t.infiniteDistance,s.showBoundingBox=t.showBoundingBox,s.showSubMeshesBoundingBox=t.showSubMeshesBoundingBox,void 0!==t.applyFog&&(s.applyFog=t.applyFog),void 0!==t.pickable&&(s.isPickable=t.pickable),void 0!==t.alphaIndex&&(s.alphaIndex=t.alphaIndex),s.receiveShadows=t.receiveShadows,s.billboardMode=t.billboardMode,void 0!==t.visibility&&(s.visibility=t.visibility),s.checkCollisions=t.checkCollisions,void 0!==t.isBlocker&&(s.isBlocker=t.isBlocker),s._shouldGenerateFlatShading=t.useFlatShading,t.freezeWorldMatrix&&(s._waitingFreezeWorldMatrix=t.freezeWorldMatrix),t.parentId&&(s._waitingParentId=t.parentId),void 0!==t.actions&&(s._waitingActions=t.actions),void 0!==t.overlayAlpha&&(s.overlayAlpha=t.overlayAlpha),void 0!==t.overlayColor&&(s.overlayColor=e.Color3.FromArray(t.overlayColor)),void 0!==t.renderOverlay&&(s.renderOverlay=t.renderOverlay),s.hasVertexAlpha=t.hasVertexAlpha,t.delayLoadingFile?(s.delayLoadState=e.Engine.DELAYLOADSTATE_NOTLOADED,s.delayLoadingFile=n+t.delayLoadingFile,s._boundingInfo=new e.BoundingInfo(e.Vector3.FromArray(t.boundingBoxMinimum),e.Vector3.FromArray(t.boundingBoxMaximum)),t._binaryInfo&&(s._binaryInfo=t._binaryInfo),s._delayInfo=[],t.hasUVs&&s._delayInfo.push(e.VertexBuffer.UVKind),t.hasUVs2&&s._delayInfo.push(e.VertexBuffer.UV2Kind),t.hasUVs3&&s._delayInfo.push(e.VertexBuffer.UV3Kind),t.hasUVs4&&s._delayInfo.push(e.VertexBuffer.UV4Kind),t.hasUVs5&&s._delayInfo.push(e.VertexBuffer.UV5Kind),t.hasUVs6&&s._delayInfo.push(e.VertexBuffer.UV6Kind),t.hasColors&&s._delayInfo.push(e.VertexBuffer.ColorKind),t.hasMatricesIndices&&s._delayInfo.push(e.VertexBuffer.MatricesIndicesKind),t.hasMatricesWeights&&s._delayInfo.push(e.VertexBuffer.MatricesWeightsKind),s._delayLoadingFunction=e.Geometry.ImportGeometry,e.SceneLoader.ForceFullSceneLoadingForIncremental&&s._checkDelayState()):e.Geometry.ImportGeometry(t,s),t.materialId?s.setMaterialByID(t.materialId):s.material=null,t.morphTargetManagerId>-1&&(s.morphTargetManager=i.getMorphTargetManagerById(t.morphTargetManagerId)),t.skeletonId>-1&&(s.skeleton=i.getLastSkeletonByID(t.skeletonId),t.numBoneInfluencers&&(s.numBoneInfluencers=t.numBoneInfluencers)),t.animations){for(var o=0;o<t.animations.length;o++){var a=t.animations[o];s.animations.push(e.Animation.Parse(a))}e.Node.ParseAnimationRanges(s,t,i)}if(t.autoAnimate&&i.beginAnimation(s,t.autoAnimateFrom,t.autoAnimateTo,t.autoAnimateLoop,t.autoAnimateSpeed||1),t.layerMask&&!isNaN(t.layerMask)?s.layerMask=Math.abs(parseInt(t.layerMask)):s.layerMask=268435455,t.physicsImpostor&&(s.physicsImpostor=new e.PhysicsImpostor(s,t.physicsImpostor,{mass:t.physicsMass,friction:t.physicsFriction,restitution:t.physicsRestitution},i)),t.instances)for(var h=0;h<t.instances.length;h++){var u=t.instances[h],c=s.createInstance(u.name);if(e.Tags.AddTagsTo(c,u.tags),c.position=e.Vector3.FromArray(u.position),u.parentId&&(c._waitingParentId=u.parentId),u.rotationQuaternion?c.rotationQuaternion=e.Quaternion.FromArray(u.rotationQuaternion):u.rotation&&(c.rotation=e.Vector3.FromArray(u.rotation)),c.scaling=e.Vector3.FromArray(u.scaling),c.checkCollisions=s.checkCollisions,t.animations){for(o=0;o<t.animations.length;o++)a=t.animations[o],c.animations.push(e.Animation.Parse(a));e.Node.ParseAnimationRanges(c,t,i)}}return s},r.CreateRibbon=function(t,i,r,n,s,o,a,h,u){return e.MeshBuilder.CreateRibbon(t,{pathArray:i,closeArray:r,closePath:n,offset:s,updatable:a,sideOrientation:h,instance:u},o)},r.CreateDisc=function(t,i,r,n,s,o){var a={radius:i,tessellation:r,sideOrientation:o,updatable:s};return e.MeshBuilder.CreateDisc(t,a,n)},r.CreateBox=function(t,i,r,n,s){var o={size:i,sideOrientation:s,updatable:n};return e.MeshBuilder.CreateBox(t,o,r)},r.CreateSphere=function(t,i,r,n,s,o){var a={segments:i,diameterX:r,diameterY:r,diameterZ:r,sideOrientation:o,updatable:s};return e.MeshBuilder.CreateSphere(t,a,n)},r.CreateCylinder=function(t,i,n,s,o,a,h,u,c){void 0!==h&&h instanceof e.Scene||(void 0!==h&&(c=u||r.DEFAULTSIDE,u=h),h=a,a=1);var l={height:i,diameterTop:n,diameterBottom:s,tessellation:o,subdivisions:a,sideOrientation:c,updatable:u};return e.MeshBuilder.CreateCylinder(t,l,h)},r.CreateTorus=function(t,i,r,n,s,o,a){var h={diameter:i,thickness:r,tessellation:n,sideOrientation:a,updatable:o};return e.MeshBuilder.CreateTorus(t,h,s)},r.CreateTorusKnot=function(t,i,r,n,s,o,a,h,u,c){var l={radius:i,tube:r,radialSegments:n,tubularSegments:s,p:o,q:a,sideOrientation:c,updatable:u};return e.MeshBuilder.CreateTorusKnot(t,l,h)},r.CreateLines=function(t,i,r,n,s){var o={points:i,updatable:n,instance:s};return e.MeshBuilder.CreateLines(t,o,r)},r.CreateDashedLines=function(t,i,r,n,s,o,a,h){var u={points:i,dashSize:r,gapSize:n,dashNb:s,updatable:a,instance:h};return e.MeshBuilder.CreateDashedLines(t,u,o)},r.ExtrudeShape=function(t,i,n,s,o,a,h,u,c,l){var f={shape:i,path:n,scale:s,rotation:o,cap:0===a?0:a||r.NO_CAP,sideOrientation:c,instance:l,updatable:u};return e.MeshBuilder.ExtrudeShape(t,f,h)},r.ExtrudeShapeCustom=function(t,i,n,s,o,a,h,u,c,l,f,d){var p={shape:i,path:n,scaleFunction:s,rotationFunction:o,ribbonCloseArray:a,ribbonClosePath:h,cap:0===u?0:u||r.NO_CAP,sideOrientation:f,instance:d,updatable:l};return e.MeshBuilder.ExtrudeShapeCustom(t,p,c)},r.CreateLathe=function(t,i,r,n,s,o,a){var h={shape:i,radius:r,tessellation:n,sideOrientation:a,updatable:o};return e.MeshBuilder.CreateLathe(t,h,s)},r.CreatePlane=function(t,i,r,n,s){var o={size:i,width:i,height:i,sideOrientation:s,updatable:n};return e.MeshBuilder.CreatePlane(t,o,r)},r.CreateGround=function(t,i,r,n,s,o){var a={width:i,height:r,subdivisions:n,updatable:o};return e.MeshBuilder.CreateGround(t,a,s)},r.CreateTiledGround=function(t,i,r,n,s,o,a,h,u){var c={xmin:i,zmin:r,xmax:n,zmax:s,subdivisions:o,precision:a,updatable:u};return e.MeshBuilder.CreateTiledGround(t,c,h)},r.CreateGroundFromHeightMap=function(t,i,r,n,s,o,a,h,u,c){var l={width:r,height:n,subdivisions:s,minHeight:o,maxHeight:a,updatable:u,onReady:c};return e.MeshBuilder.CreateGroundFromHeightMap(t,i,l,h)},r.CreateTube=function(t,i,r,n,s,o,a,h,u,c){var l={path:i,radius:r,tessellation:n,radiusFunction:s,arc:1,cap:o,updatable:h,sideOrientation:u,instance:c};return e.MeshBuilder.CreateTube(t,l,a)},r.CreatePolyhedron=function(t,i,r){return e.MeshBuilder.CreatePolyhedron(t,i,r)},r.CreateIcoSphere=function(t,i,r){return e.MeshBuilder.CreateIcoSphere(t,i,r)},r.CreateDecal=function(t,i,r,n,s,o){var a={position:r,normal:n,size:s,angle:o};return e.MeshBuilder.CreateDecal(t,i,a)},r.prototype.setPositionsForCPUSkinning=function(){var t;return this._sourcePositions||(t=this.getVerticesData(e.VertexBuffer.PositionKind),this._sourcePositions=new Float32Array(t),this.getVertexBuffer(e.VertexBuffer.PositionKind).isUpdatable()||this.setVerticesData(e.VertexBuffer.PositionKind,t,!0)),this._sourcePositions},r.prototype.setNormalsForCPUSkinning=function(){var t;return this._sourceNormals||(t=this.getVerticesData(e.VertexBuffer.NormalKind),this._sourceNormals=new Float32Array(t),this.getVertexBuffer(e.VertexBuffer.NormalKind).isUpdatable()||this.setVerticesData(e.VertexBuffer.NormalKind,t,!0)),this._sourceNormals},r.prototype.applySkeleton=function(t){if(!this.geometry)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 i=this.subMeshes.slice();this.setPositionsForCPUSkinning(),this.subMeshes=i}this._sourceNormals||this.setNormalsForCPUSkinning();var r=this.getVerticesData(e.VertexBuffer.PositionKind);r instanceof Float32Array||(r=new Float32Array(r));var n=this.getVerticesData(e.VertexBuffer.NormalKind);n instanceof Float32Array||(n=new Float32Array(n));for(var s,o=this.getVerticesData(e.VertexBuffer.MatricesIndicesKind),a=this.getVerticesData(e.VertexBuffer.MatricesWeightsKind),h=this.numBoneInfluencers>4,u=h?this.getVerticesData(e.VertexBuffer.MatricesIndicesExtraKind):null,c=h?this.getVerticesData(e.VertexBuffer.MatricesWeightsExtraKind):null,l=t.getTransformMatrices(this),f=e.Vector3.Zero(),d=new e.Matrix,p=new e.Matrix,_=0,m=0;m<r.length;m+=3,_+=4){var g;for(s=0;s<4&&(g=a[_+s])>0;s++)e.Matrix.FromFloat32ArrayToRefScaled(l,16*o[_+s],g,p),d.addToSelf(p);if(h)for(s=0;s<4&&(g=c[_+s])>0;s++)e.Matrix.FromFloat32ArrayToRefScaled(l,16*u[_+s],g,p),d.addToSelf(p);e.Vector3.TransformCoordinatesFromFloatsToRef(this._sourcePositions[m],this._sourcePositions[m+1],this._sourcePositions[m+2],d,f),f.toArray(r,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,r),this.updateVerticesData(e.VertexBuffer.NormalKind,n),this},r.MinMax=function(e){var t=null,i=null;return e.forEach((function(e,r,n){var s=e.getBoundingInfo().boundingBox;t?(t.MinimizeInPlace(s.minimumWorld),i.MaximizeInPlace(s.maximumWorld)):(t=s.minimumWorld,i=s.maximumWorld)})),{min:t,max:i}},r.Center=function(t){var i=t instanceof Array?e.Mesh.MinMax(t):t;return e.Vector3.Center(i.min,i.max)},r.MergeMeshes=function(t,i,n,s,o){void 0===i&&(i=!0);var a;if(!n){var h=0;for(a=0;a<t.length;a++)if(t[a]&&(h+=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 u,c,l,f=new Array;for(a=0;a<t.length;a++)t[a]&&(t[a].computeWorldMatrix(!0),c=e.VertexData.ExtractFromMesh(t[a],!0),c.transform(t[a].getWorldMatrix()),u?u.merge(c):(u=c,l=t[a]),o&&f.push(t[a].getTotalIndices()));if(s||(s=new r(l.name+"_merged",l.getScene())),u.applyToMesh(s),s.material=l.material,s.checkCollisions=l.checkCollisions,i)for(a=0;a<t.length;a++)t[a]&&t[a].dispose();if(o){s.releaseSubMeshes(),a=0;for(var d=0;a<f.length;)e.SubMesh.CreateFromIndices(0,d,f[a],s),d+=f[a],a++}return s},r})(e.AbstractMesh);i._FRONTSIDE=0,i._BACKSIDE=1,i._DOUBLESIDE=2,i._DEFAULTSIDE=0,i._NO_CAP=0,i._CAP_START=1,i._CAP_END=2,i._CAP_ALL=3,e.Mesh=i})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(e,t,i,r,n,s,o,a){void 0===a&&(a=!0),this.materialIndex=e,this.verticesStart=t,this.verticesCount=i,this.indexStart=r,this.indexCount=n,this._renderId=0,this._mesh=s,this._renderingMesh=o||s,s.subMeshes.push(this),this._trianglePlanes=[],this._id=s.subMeshes.length-1,a&&(this.refreshBoundingInfo(),s.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,i=t.getSubMaterial(this.materialIndex);return this._currentMaterial!==i&&(this._currentMaterial=i,this._materialDefines&&this._materialDefines.markAllAsDirty()),i}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 i,r=this._renderingMesh.getIndices();return i=0===this.indexStart&&this.indexCount===r.length?{minimum:this._renderingMesh.getBoundingInfo().minimum.clone(),maximum:this._renderingMesh.getBoundingInfo().maximum.clone()}:e.Tools.ExtractMinAndMaxIndexed(t,r,this.indexStart,this.indexCount,this._renderingMesh.geometry.boundingBias),this._boundingInfo=new e.BoundingInfo(i.minimum,i.maximum),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 i=[],r=this.indexStart;r<this.indexStart+this.indexCount;r+=3)i.push(e[r],e[r+1],e[r+1],e[r+2],e[r+2],e[r]);this._linesIndexBuffer=t.createIndexBuffer(i),this.linesIndexCount=i.length}return this._linesIndexBuffer},t.prototype.canIntersects=function(e){return e.intersectsBox(this.getBoundingInfo().boundingBox)},t.prototype.intersects=function(t,i,r,n){var s=null;if(this._mesh instanceof e.LinesMesh)for(var o=this._mesh,a=this.indexStart;a<this.indexStart+this.indexCount;a+=2){var h=i[r[a]],u=i[r[a+1]],c=t.intersectionSegment(h,u,o.intersectionThreshold);if(!(c<0)&&((n||!s||c<s.distance)&&(s=new e.IntersectionInfo(null,null,c),n)))break}else for(var a=this.indexStart;a<this.indexStart+this.indexCount;a+=3){var h=i[r[a]],u=i[r[a+1]],l=i[r[a+2]],f=t.intersectsTriangle(h,u,l);if(f){if(f.distance<0)continue;if((n||!s||f.distance<s.distance)&&(s=f,s.faceId=a/3,n))break}}return s},t.prototype.clone=function(i,r){var n=new t(this.materialIndex,this.verticesStart,this.verticesCount,this.indexStart,this.indexCount,i,r,!1);return this.IsGlobal||(n._boundingInfo=new e.BoundingInfo(this.getBoundingInfo().minimum,this.getBoundingInfo().maximum)),n},t.prototype.dispose=function(){this._linesIndexBuffer&&(this._mesh.getScene().getEngine()._releaseBuffer(this._linesIndexBuffer),this._linesIndexBuffer=null);var e=this._mesh.subMeshes.indexOf(this);this._mesh.subMeshes.splice(e,1)},t.CreateFromIndices=function(e,i,r,n,s){var o=Number.MAX_VALUE,a=-Number.MAX_VALUE;s=s||n;for(var h=s.getIndices(),u=i;u<i+r;u++){var c=h[u];c<o&&(o=c),c>a&&(a=c)}return new t(e,o,a-o+1,i,r,n,s)},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(),i=0;i<t.meshes.length;i++){var r=t.meshes[i];r.material===this._mesh.material&&r.computeBonesUsingShaders&&r.numBoneInfluencers>0&&(r.computeBonesUsingShaders=!1)}}else{var n=this._defines[this._currentRank];if(n)for(var i=0;i<n.length;i++)e=e.replace("#define "+n[i],"");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,i,r,n,s,o,a,h,u){var c=this;if(this.uniqueId=0,this._uniformBuffersNames={},this._isReady=!1,this._compilationError="",this._valueCache={},this.name=e,t.attributes){var l=t;if(this._engine=i,this._attributesNames=l.attributes,this._uniformsNames=l.uniformsNames.concat(l.samplers),this._samplers=l.samplers,this.defines=l.defines,this.onError=l.onError,this.onCompiled=l.onCompiled,this._fallbacks=l.fallbacks,this._indexParameters=l.indexParameters,l.uniformBuffersNames)for(var f=0;f<l.uniformBuffersNames.length;f++)this._uniformBuffersNames[l.uniformBuffersNames[f]]=f}else this._engine=n,this.defines=s,this._uniformsNames=i.concat(r),this._samplers=r,this._attributesNames=t,this.onError=h,this.onCompiled=a,this._indexParameters=u,this._fallbacks=o;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){c._processIncludes(e,(function(e){c._processShaderConversion(e,!1,(function(e){c._loadFragmentShader(p,(function(t){c._processIncludes(t,(function(t){c._processShaderConversion(t,!0,(function(t){c._prepareEffect(e,t,c._attributesNames,c.defines,c._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._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 i;i="."===e[0]||"/"===e[0]||e.indexOf("http")>-1?e:BABYLON.Engine.ShadersRepository+e,BABYLON.Tools.LoadFile(i+".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 i;i="."===e[0]||"/"===e[0]||e.indexOf("http")>-1?e:BABYLON.Engine.ShadersRepository+e,BABYLON.Tools.LoadFile(i+".fragment.fx",t)},Effect.prototype._dumpShadersSource=function(e,t,i){var r=this._engine.webGLVersion>1?"#version 300 es\n":"",n=r+(i?i+"\n":"");e=n+e,t=n+t;var s=2,o=/\n/gm,a="\n1\t"+e.replace(o,(function(){return"\n"+s+++"\t"}));s=2;var h="\n1\t"+t.replace(o,(function(){return"\n"+s+++"\t"}));this.name.vertexElement?(BABYLON.Tools.Error("Vertex shader: "+this.name.vertexElement+a),BABYLON.Tools.Error("Fragment shader: "+this.name.fragmentElement+h)):this.name.vertex?(BABYLON.Tools.Error("Vertex shader: "+this.name.vertex+a),BABYLON.Tools.Error("Fragment shader: "+this.name.fragment+h)):(BABYLON.Tools.Error("Vertex shader: "+this.name+a),BABYLON.Tools.Error("Fragment shader: "+this.name+h))},Effect.prototype._processShaderConversion=function(e,t,i){var r=this._processPrecision(e);if(1==this._engine.webGLVersion)return void i(r);if(-1!==r.indexOf("#version 3"))return void i(r);var n=/#extension.+(GL_OES_standard_derivatives|GL_EXT_shader_texture_lod|GL_EXT_frag_depth).+enable/g,s=r.replace(n,"");s=s.replace(/varying(?![\n\r])\s/g,t?"in ":"out "),s=s.replace(/attribute[ \t]/g,"in "),s=s.replace(/[ \t]attribute/g," in"),t&&(s=s.replace(/texture2DLodEXT\(/g,"textureLod("),s=s.replace(/textureCubeLodEXT\(/g,"textureLod("),s=s.replace(/texture2D\(/g,"texture("),s=s.replace(/textureCube\(/g,"texture("),s=s.replace(/gl_FragDepthEXT/g,"gl_FragDepth"),s=s.replace(/gl_FragColor/g,"glFragColor"),s=s.replace(/void\s+?main\(/g,"out vec4 glFragColor;\nvoid main(")),i(s)},Effect.prototype._processIncludes=function(e,t){for(var i=this,r=/#include<(.+)>(\((.*)\))*(\[(.*)\])*/g,n=r.exec(e),s=new String(e);null!=n;){var o=n[1];if(-1!==o.indexOf("__decl__")&&(o=o.replace(/__decl__/,""),1!=this._engine.webGLVersion&&(o=o.replace(/Vertex/,"Ubo"),o=o.replace(/Fragment/,"Ubo")),o+="Declaration"),!Effect.IncludesShadersStore[o]){var a=BABYLON.Engine.ShadersRepository+"ShadersInclude/"+o+".fx";return void BABYLON.Tools.LoadFile(a,(function(e){Effect.IncludesShadersStore[o]=e,i._processIncludes(s,t)}))}var h=Effect.IncludesShadersStore[o];if(n[2])for(var u=n[3].split(","),c=0;c<u.length;c+=2){var l=new RegExp(u[c],"g"),f=u[c+1];h=h.replace(l,f)}if(n[4]){var d=n[5];if(-1!==d.indexOf("..")){var p=d.split(".."),_=parseInt(p[0]),m=parseInt(p[1]),g=h.slice(0);h="",isNaN(m)&&(m=this._indexParameters[p[1]]);for(var y=_;y<m;y++)1===this._engine.webGLVersion&&(g=g.replace(/light\{X\}.(\w*)/g,(function(e,t){return t+"{X}"}))),h+=g.replace(/\{X\}/g,y)+"\n"}else 1===this._engine.webGLVersion&&(h=h.replace(/light\{X\}.(\w*)/g,(function(e,t){return t+"{X}"}))),h=h.replace(/\{X\}/g,d)}s=s.replace(n[0],h),n=r.exec(e)}t(s)},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,i,r,n){try{var s=this._engine;if(this._program=s.createShaderProgram(e,t,r),s.webGLVersion>1)for(var o in this._uniformBuffersNames)this.bindUniformBlock(o,this._uniformBuffersNames[o]);this._uniforms=s.getUniforms(this._program,this._uniformsNames),this._attributes=s.getAttributes(this._program,i);var a;for(a=0;a<this._samplers.length;a++){null==this.getUniform(this._samplers[a])&&(this._samplers.splice(a,1),a--)}s.bindSamplers(this),this._compilationError="",this._isReady=!0,this.onCompiled&&this.onCompiled(this)}catch(s){this._compilationError=s.message,BABYLON.Tools.Error("Unable to compile effect:"),BABYLON.Tools.Error("Uniforms: "+this._uniformsNames.map((function(e){return" "+e}))),BABYLON.Tools.Error("Attributes: "+i.map((function(e){return" "+e}))),this._dumpShadersSource(e,t,r),BABYLON.Tools.Error("Error: "+this._compilationError),n&&n.isMoreFallbacks?(BABYLON.Tools.Error("Trying next fallback."),r=n.reduce(r),this._prepareEffect(e,t,i,r,n)):this.onError&&this.onError(this,this._compilationError)}},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 i=this._samplers.indexOf(e),r=1;r<t.length;r++)this._samplers.splice(i+r,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 i=this._valueCache[e],r=t.updateFlag;return(void 0===i||i!==r)&&(this._valueCache[e]=r,!0)},Effect.prototype._cacheFloat2=function(e,t,i){var r=this._valueCache[e];if(!r)return r=[t,i],this._valueCache[e]=r,!0;var n=!1;return r[0]!==t&&(r[0]=t,n=!0),r[1]!==i&&(r[1]=i,n=!0),n},Effect.prototype._cacheFloat3=function(e,t,i,r){var n=this._valueCache[e];if(!n)return n=[t,i,r],this._valueCache[e]=n,!0;var s=!1;return n[0]!==t&&(n[0]=t,s=!0),n[1]!==i&&(n[1]=i,s=!0),n[2]!==r&&(n[2]=r,s=!0),s},Effect.prototype._cacheFloat4=function(e,t,i,r,n){var s=this._valueCache[e];if(!s)return s=[t,i,r,n],this._valueCache[e]=s,!0;var o=!1;return s[0]!==t&&(s[0]=t,o=!0),s[1]!==i&&(s[1]=i,o=!0),s[2]!==r&&(s[2]=r,o=!0),s[3]!==n&&(s[3]=n,o=!0),o},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){
  13. 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 i=this._valueCache[e];return void 0!==i&&i===t?this:(this._valueCache[e]=t,this._engine.setFloat(this.getUniform(e),t),this)},Effect.prototype.setBool=function(e,t){var i=this._valueCache[e];return void 0!==i&&i===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,i){return this._cacheFloat2(e,t,i)&&this._engine.setFloat2(this.getUniform(e),t,i),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,i,r){return this._cacheFloat3(e,t,i,r)&&this._engine.setFloat3(this.getUniform(e),t,i,r),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,i,r,n){return this._cacheFloat4(e,t,i,r,n)&&this._engine.setFloat4(this.getUniform(e),t,i,r,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,i){return this._cacheFloat4(e,t.r,t.g,t.b,i)&&this._engine.setColor4(this.getUniform(e),t,i),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:[]},i=t,r=e.split("\n"),n=0;n<r.length;n++){var s=r[n].trim(),o=s.indexOf("#ifdef ");if(-1===o){var o=s.indexOf("#ifndef ");if(-1===o){var o=s.indexOf("#if ");if(-1===o)o=s.indexOf("#endif"),-1===o?i.children.push(s):i=i.parent;else{var a=s.substr(o+4).trim(),h=a.indexOf(" ");u={condition:a.substr(h+1),define:a.substr(0,h),ndef:!1,children:[],parent:i},i.children.push(u),i=u}}else{var a=s.substr(o+8);u={condition:null,define:a,ndef:!0,children:[],parent:i},i.children.push(u),i=u}}else{var a=s.substr(o+7),u={condition:null,ndef:!1,define:a,children:[],parent:i};i.children.push(u),i=u}}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,i,r,n,s,o){o._areMiscDirty&&(o.LOGARITHMICDEPTH=r,o.POINTSIZE=n||i.forcePointsCloud,o.FOG=i.fogEnabled&&t.applyFog&&i.fogMode!==e.Scene.FOGMODE_NONE&&s)},t.PrepareDefinesForFrameBoundValues=function(e,t,i,r){var n=!1;i.CLIPPLANE!==(void 0!==e.clipPlane&&null!==e.clipPlane)&&(i.CLIPPLANE=!i.CLIPPLANE,n=!0),i.ALPHATEST!==t.getAlphaTesting()&&(i.ALPHATEST=!i.ALPHATEST,n=!0),i.INSTANCES!==r&&(i.INSTANCES=r,n=!0),n&&i.markAsUnprocessed()},t.PrepareDefinesForAttributes=function(t,i,r,n,s){if(void 0===s&&(s=!1),(i._areAttributesDirty||i._needNormals!==i._normals||i._needUVs!==i._uvs)&&(i._normals=i._needNormals,i._uvs=i._needUVs,i.NORMAL=i._needNormals&&t.isVerticesDataPresent(e.VertexBuffer.NormalKind),i._needNormals&&t.isVerticesDataPresent(e.VertexBuffer.TangentKind)&&(i.TANGENT=!0),i._needUVs?(i.UV1=t.isVerticesDataPresent(e.VertexBuffer.UVKind),i.UV2=t.isVerticesDataPresent(e.VertexBuffer.UV2Kind)):(i.UV1=!1,i.UV2=!1),r&&(i.VERTEXCOLOR=t.useVertexColors&&t.isVerticesDataPresent(e.VertexBuffer.ColorKind),i.VERTEXALPHA=t.hasVertexAlpha),n&&(t.useBones&&t.computeBonesUsingShaders?(i.NUM_BONE_INFLUENCERS=t.numBoneInfluencers,i.BonesPerMesh=t.skeleton.bones.length+1):(i.NUM_BONE_INFLUENCERS=0,i.BonesPerMesh=0)),s))if(t.morphTargetManager){var o=t.morphTargetManager;i.MORPHTARGETS_TANGENT=o.supportsTangents&&i.TANGENT,i.MORPHTARGETS_NORMAL=o.supportsNormals&&i.NORMAL,i.MORPHTARGETS=o.numInfluencers>0,i.NUM_MORPH_INFLUENCERS=o.numInfluencers}else i.MORPHTARGETS_TANGENT=!1,i.MORPHTARGETS_NORMAL=!1,i.MORPHTARGETS=!1,i.NUM_MORPH_INFLUENCERS=0},t.PrepareDefinesForLights=function(t,i,r,n,s,o){if(void 0===s&&(s=4),void 0===o&&(o=!1),!r._areLightsDirty)return r._needNormals;var a=0,h=!1,u=!1,c=!1,l=!1,f=!1;if(t.lightsEnabled&&!o)for(var d=0,p=i._lightSources;d<p.length;d++){var _=p[d];h=!0,void 0===r["LIGHT"+a]&&(u=!0),r["LIGHT"+a]=!0,r["SPOTLIGHT"+a]=!1,r["HEMILIGHT"+a]=!1,r["POINTLIGHT"+a]=!1,r["DIRLIGHT"+a]=!1;var m;if(m=2===_.getTypeID()?"SPOTLIGHT"+a:3===_.getTypeID()?"HEMILIGHT"+a:0===_.getTypeID()?"POINTLIGHT"+a:"DIRLIGHT"+a,r[m]=!0,n&&!_.specular.equalsFloats(0,0,0)&&(f=!0),r["SHADOW"+a]=!1,t.shadowsEnabled){var g=_.getShadowGenerator();i&&i.receiveShadows&&g&&(r["SHADOW"+a]=!0,l=!0,r["SHADOWPCF"+a]=!1,r["SHADOWESM"+a]=!1,g.usePoissonSampling?r["SHADOWPCF"+a]=!0:(g.useExponentialShadowMap||g.useBlurExponentialShadowMap)&&(r["SHADOWESM"+a]=!0))}if(_.lightmapMode!=e.Light.LIGHTMAP_DEFAULT?(c=!0,r["LIGHTMAPEXCLUDED"+a]=!0,r["LIGHTMAPNOSPECULAR"+a]=_.lightmapMode==e.Light.LIGHTMAP_SHADOWSONLY):(r["LIGHTMAPEXCLUDED"+a]=!1,r["LIGHTMAPNOSPECULAR"+a]=!1),++a===s)break}r.SPECULARTERM=f,r.SHADOWS=l;for(var y=a;y<s;y++)void 0!==r["LIGHT"+y]&&(r["LIGHT"+y]=!1);var v=t.getEngine().getCaps();return void 0===r.SHADOWFULLFLOAT&&(u=!0),r.SHADOWFULLFLOAT=l&&v.textureFloat&&v.textureFloatLinearFiltering&&v.textureFloatRender,r.LIGHTMAPEXCLUDED=c,u&&r.rebuild(),h},t.PrepareUniformsAndSamplersList=function(e,t,i,r){void 0===r&&(r=4);var n,s,t,i;if(e.uniformsNames){var o=e;n=o.uniformsNames,s=o.uniformBuffersNames,t=o.samplers,i=o.defines,r=o.maxSimultaneousLights}else n=e;for(var a=0;a<r&&i["LIGHT"+a];a++)n.push("vLightData"+a,"vLightDiffuse"+a,"vLightSpecular"+a,"vLightDirection"+a,"vLightGround"+a,"lightMatrix"+a,"shadowsInfo"+a),s&&s.push("Light"+a),t.push("shadowSampler"+a);i.NUM_MORPH_INFLUENCERS&&n.push("morphTargetInfluences")},t.HandleFallbacksForShadows=function(e,t,i){if(void 0===i&&(i=4),e.SHADOWS)for(var r=0;r<i&&e["LIGHT"+r];r++)r>0&&t.addFallback(r,"LIGHT"+r),e["SHADOW"+r]&&t.addFallback(0,"SHADOW"+r),e["SHADOWPCF"+r]&&t.addFallback(0,"SHADOWPCF"+r),e["SHADOWESM"+r]&&t.addFallback(0,"SHADOWESM"+r)},t.PrepareAttributesForMorphTargets=function(t,i,r){var n=r.NUM_MORPH_INFLUENCERS;if(n>0)for(var s=e.Engine.LastCreatedEngine.getCaps().maxVertexAttribs,o=i.morphTargetManager,a=o.supportsNormals&&r.NORMAL,h=o.supportsTangents&&r.TANGENT,u=0;u<n;u++)t.push(e.VertexBuffer.PositionKind+u),a&&t.push(e.VertexBuffer.NormalKind+u),h&&t.push(e.VertexBuffer.TangentKind+u),t.length>s&&e.Tools.Error("Cannot add more vertex attributes for mesh "+i.name)},t.PrepareAttributesForBones=function(t,i,r,n){r.NUM_BONE_INFLUENCERS>0&&(n.addCPUSkinningFallback(0,i),t.push(e.VertexBuffer.MatricesIndicesKind),t.push(e.VertexBuffer.MatricesWeightsKind),r.NUM_BONE_INFLUENCERS>4&&(t.push(e.VertexBuffer.MatricesIndicesExtraKind),t.push(e.VertexBuffer.MatricesWeightsExtraKind)))},t.PrepareAttributesForInstances=function(e,t){t.INSTANCES&&(e.push("world0"),e.push("world1"),e.push("world2"),e.push("world3"))},t.BindLightShadow=function(e,t,i,r,n,s){var o=e.getShadowGenerator();return i.receiveShadows&&o&&(e.needCube()?s||(s=!0,n.setFloat2("depthValues",t.activeCamera.minZ,t.activeCamera.maxZ)):n.setMatrix("lightMatrix"+r,o.getTransformMatrix()),n.setTexture("shadowSampler"+r,o.getShadowMapForRendering()),e._uniformBuffer.updateFloat3("shadowsInfo",o.getDarkness(),o.blurScale/o.getShadowMap().getSize().width,o.depthScale,r)),s},t.BindLightProperties=function(e,t,i){e.transferToEffect(t,i+"")},t.BindLights=function(i,r,n,s,o){void 0===o&&(o=4);for(var a=0,h=!1,u=0,c=r._lightSources;u<c.length;u++){var l=c[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+""),s.SPECULARTERM&&(l.specular.scaleToRef(l.intensity,e.Tmp.Color3[1]),l._uniformBuffer.updateColor3("vLightSpecular",e.Tmp.Color3[1],a+"")),i.shadowsEnabled&&(h=this.BindLightShadow(l,i,r,a+"",n,h)),l._uniformBuffer.update(),++a===o)break}},t.BindFogParameters=function(t,i,r){t.fogEnabled&&i.applyFog&&t.fogMode!==e.Scene.FOGMODE_NONE&&(r.setFloat4("vFogInfos",t.fogMode,t.fogStart,t.fogEnd,t.fogDensity),r.setColor3("vFogColor",t.fogColor))},t.BindBonesParameters=function(e,t){if(e&&e.useBones&&e.computeBonesUsingShaders){var i=e.skeleton.getTransformMatrices(e);i&&t.setMatrices("mBones",i)}},t.BindMorphTargetParameters=function(e,t){e&&e.morphTargetManager&&t.setFloatArray("morphTargetInfluences",e.morphTargetManager.influences)},t.BindLogDepth=function(e,t,i){e.LOGARITHMICDEPTH&&t.setFloat("logarithmicDepthConstant",2/(Math.log(i.activeCamera.maxZ+1)/Math.LN2))},t.BindClipPlane=function(e,t){if(t.clipPlane){var i=t.clipPlane;e.setFloat4("vClipPlane",i.normal.x,i.normal.y,i.normal.z,i.d)}},t})();e.MaterialHelper=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function 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 i=t[e];"_"!==i[0]&&this._keys.push(i)}},e.prototype.isEqual=function(e){if(this._keys.length!==e._keys.length)return!1;for(var t=0;t<this._keys.length;t++){var i=this._keys[t];if(this[i]!==e[i])return!1}return!0},e.prototype.cloneTo=function(e){this._keys.length!==e._keys.length&&(e._keys=this._keys.slice(0));for(var t=0;t<this._keys.length;t++){var i=this._keys[t];e[i]=this[i]}},e.prototype.reset=function(){for(var e=0;e<this._keys.length;e++){var t=this._keys[e];"number"==typeof this[t]?this[t]=0:this[t]=!1}},e.prototype.toString=function(){for(var e="",t=0;t<this._keys.length;t++){var i=this._keys[t],r=this[i];"number"==typeof r?e+="#define "+i+" "+this[i]+"\n":r&&(e+="#define "+i+"\n")}return e},e})();e.MaterialDefines=t;var i=(function(){function t(i,r,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=i,this.id=i,this._scene=r||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,i){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 i=this._scene.getEngine(),r=this.sideOrientation===t.ClockWiseSideOrientation;i.enableEffect(e||this._effect),i.setState(this.backFaceCulling,this.zOffset,!1,r)},t.prototype.bind=function(e,t){},t.prototype.bindForSubMesh=function(e,t,i){},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 i=this._scene.meshes[t];i.material===this&&e.push(i)}return e},t.prototype.dispose=function(e,t){this.getScene().stopAnimation(this);var i=this._scene.materials.indexOf(this);for(i>=0&&this._scene.materials.splice(i,1),i=0;i<this._scene.meshes.length;i++){var r=this._scene.meshes[i];if(r.material===this&&(r.material=null,r.geometry)){var n=r.geometry;if(this.storeEffectOnSubMeshes)for(var s=0,o=r.subMeshes;s<o.length;s++){var a=o[s];n._releaseVertexArrayObject(a._materialEffect)}else n._releaseVertexArrayObject(this._effect)}}if(this._uniformBuffer.dispose(),e&&this._effect){if(this.storeEffectOnSubMeshes)for(var h=0,u=r.subMeshes;h<u.length;h++){var a=u[h];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,i){var r=new e.MultiMaterial(t.name,i);r.id=t.id,e.Tags.AddTagsTo(r,t.tags);for(var n=0;n<t.materials.length;n++){var s=t.materials[n];s?r.subMaterials.push(i.getMaterialByID(s)):r.subMaterials.push(null)}return r},t.Parse=function(t,i,r){return t.customType?e.Tools.Instantiate(t.customType).Parse(t,i,r):e.StandardMaterial.Parse(t,i,r)},t})();i._TriangleFillMode=0,i._WireFrameFillMode=1,i._PointFillMode=2,i._ClockWiseSideOrientation=0,i._CounterClockWiseSideOrientation=1,i._TextureDirtyFlag=1,i._LightDirtyFlag=2,i._FresnelDirtyFlag=4,i._AttributesDirtyFlag=8,i._MiscDirtyFlag=16,__decorate([e.serialize()],i.prototype,"id",void 0),__decorate([e.serialize()],i.prototype,"name",void 0),__decorate([e.serialize()],i.prototype,"checkReadyOnEveryCall",void 0),__decorate([e.serialize()],i.prototype,"checkReadyOnlyOnce",void 0),__decorate([e.serialize()],i.prototype,"state",void 0),__decorate([e.serialize()],i.prototype,"alpha",void 0),__decorate([e.serialize("backFaceCulling")],i.prototype,"_backFaceCulling",void 0),__decorate([e.serialize()],i.prototype,"sideOrientation",void 0),__decorate([e.serialize()],i.prototype,"alphaMode",void 0),__decorate([e.serialize()],i.prototype,"disableDepthWrite",void 0),__decorate([e.serialize("fogEnabled")],i.prototype,"_fogEnabled",void 0),__decorate([e.serialize()],i.prototype,"pointSize",void 0),__decorate([e.serialize()],i.prototype,"zOffset",void 0),__decorate([e.serialize()],i.prototype,"wireframe",null),__decorate([e.serialize()],i.prototype,"pointsCloud",null),__decorate([e.serialize()],i.prototype,"fillMode",null),e.Material=i})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(e,t,i){this._engine=e,this._noUBO=1===e.webGLVersion,this._dynamic=i,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 i=this._uniformLocationPointer;this._uniformLocationPointer+=t-this._uniformLocationPointer%t;for(var r=this._uniformLocationPointer-i,n=0;n<r;n++)this._data.push(0)}},t.prototype.addUniform=function(e,t){if(!this._noUBO&&void 0===this._uniformLocations[e]){var i;if(t instanceof Array)i=t,t=i.length;else{t=t,i=[];for(var r=0;r<t;r++)i.push(0)}this._fillAlignment(t),this._uniformSizes[e]=t,this._uniformLocations[e]=this._uniformLocationPointer,this._uniformLocationPointer+=t;for(var r=0;r<t;r++)this._data.push(i[r]);this._needSync=!0}},t.prototype.addMatrix=function(e,t){this.addUniform(e,Array.prototype.slice.call(t.toArray()))},t.prototype.addFloat2=function(e,t,i){var r=[t,i];this.addUniform(e,r)},t.prototype.addFloat3=function(e,t,i,r){var n=[t,i,r];this.addUniform(e,n)},t.prototype.addColor3=function(e,t){var i=[];t.toArray(i),this.addUniform(e,i)},t.prototype.addColor4=function(e,t,i){var r=[];t.toArray(r),r.push(i),this.addUniform(e,r)},t.prototype.addVector3=function(e,t){var i=[];t.toArray(i),this.addUniform(e,i)},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,i,r){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,r),n=this._uniformLocations[t]}if(this._buffer||this.create(),this._dynamic)for(var s=0;s<r;s++)this._bufferData[n+s]=i[s];else{for(var o=!1,s=0;s<r;s++)this._bufferData[n+s]!==i[s]&&(o=!0,this._bufferData[n+s]=i[s]);this._needSync=this._needSync||o}},t.prototype._updateMatrix3x3ForUniform=function(e,i){for(var r=0;r<3;r++)t._tempBuffer[4*r]=i[3*r],t._tempBuffer[4*r+1]=i[3*r+1],t._tempBuffer[4*r+2]=i[3*r+2],t._tempBuffer[4*r+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,i){for(var r=0;r<2;r++)t._tempBuffer[4*r]=i[2*r],t._tempBuffer[4*r+1]=i[2*r+1],t._tempBuffer[4*r+2]=0,t._tempBuffer[4*r+3]=0;this.updateUniform(e,t._tempBuffer,8)},t.prototype._updateFloatForEffect=function(e,t){this._currentEffect.setFloat(e,t)},t.prototype._updateFloatForUniform=function(e,i){t._tempBuffer[0]=i,this.updateUniform(e,t._tempBuffer,1)},t.prototype._updateFloat2ForEffect=function(e,t,i){this._currentEffect.setFloat2(e,t,i)},t.prototype._updateFloat2ForUniform=function(e,i,r){t._tempBuffer[0]=i,t._tempBuffer[1]=r,this.updateUniform(e,t._tempBuffer,2)},t.prototype._updateFloat3ForEffect=function(e,t,i,r,n){void 0===n&&(n=""),this._currentEffect.setFloat3(e+n,t,i,r)},t.prototype._updateFloat3ForUniform=function(e,i,r,n,s){void 0===s&&(s=""),t._tempBuffer[0]=i,t._tempBuffer[1]=r,t._tempBuffer[2]=n,this.updateUniform(e,t._tempBuffer,3)},t.prototype._updateFloat4ForEffect=function(e,t,i,r,n,s){void 0===s&&(s=""),this._currentEffect.setFloat4(e+s,t,i,r,n)},t.prototype._updateFloat4ForUniform=function(e,i,r,n,s,o){void 0===o&&(o=""),t._tempBuffer[0]=i,t._tempBuffer[1]=r,t._tempBuffer[2]=n,t._tempBuffer[3]=s,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,i){i.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,i){i.toArray(t._tempBuffer),this.updateUniform(e,t._tempBuffer,4)},t.prototype._updateColor3ForEffect=function(e,t,i){void 0===i&&(i=""),this._currentEffect.setColor3(e+i,t)},t.prototype._updateColor3ForUniform=function(e,i,r){void 0===r&&(r=""),i.toArray(t._tempBuffer),this.updateUniform(e,t._tempBuffer,3)},t.prototype._updateColor4ForEffect=function(e,t,i,r){void 0===r&&(r=""),this._currentEffect.setColor4(e+r,t,i)},t.prototype._updateColor4ForUniform=function(e,i,r,n){void 0===n&&(n=""),i.toArray(t._tempBuffer),t._tempBuffer[3]=r,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 i(e,i){var r=t.call(this,e,i)||this;return r.storeEffectOnSubMeshes=!0,r}return __extends(i,t),i.prototype.getEffect=function(){return this._activeEffect},i.prototype.isReady=function(e,t){return!!e&&(!e.subMeshes||0===e.subMeshes.length||this.isReadyForSubMesh(e,e.subMeshes[0],t))},i.prototype.bindOnlyWorldMatrix=function(e){this._activeEffect.setMatrix("world",e)},i.prototype.bind=function(e,t){t&&this.bindForSubMesh(e,t,t.subMeshes[0])},i.prototype._afterBind=function(e,i){t.prototype._afterBind.call(this,e),this.getScene()._cachedEffect=i},i.prototype._mustRebind=function(e,t,i){return void 0===i&&(i=0),e.isCachedMaterialValid(this,t,i)},i.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()},i.prototype._markAllSubMeshesAsDirty=function(e){for(var t=0,i=this.getScene().meshes;t<i.length;t++){var r=i[t];if(r.subMeshes)for(var n=0,s=r.subMeshes;n<s.length;n++){var o=s[n];if(o.getMaterial()===this){if(!o._materialDefines)return;e(o._materialDefines)}}}},i.prototype._markAllSubMeshesAsTexturesDirty=function(){this._markAllSubMeshesAsDirty((function(e){return e.markAsTexturesDirty()}))},i.prototype._markAllSubMeshesAsFresnelDirty=function(){this._markAllSubMeshesAsDirty((function(e){return e.markAsFresnelDirty()}))},i.prototype._markAllSubMeshesAsLightsDirty=function(){this._markAllSubMeshesAsDirty((function(e){return e.markAsLightDirty()}))},i.prototype._markAllSubMeshesAsAttributesDirty=function(){this._markAllSubMeshesAsDirty((function(e){return e.markAsAttributesDirty()}))},i.prototype._markAllSubMeshesAsMiscDirty=function(){this._markAllSubMeshesAsDirty((function(e){return e.markAsMiscDirty()}))},i})(e.Material);e.PushMaterial=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){}return t.prototype.set=function(t,i){switch(i){case e.VertexBuffer.PositionKind:this.positions=t;break;case e.VertexBuffer.NormalKind:this.normals=t;break;case e.VertexBuffer.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,i){
  14. return this._update(e),this},t.prototype.updateGeometry=function(e,t,i){return this._update(e),this},t.prototype._applyTo=function(t,i){return this.positions&&t.setVerticesData(e.VertexBuffer.PositionKind,this.positions,i),this.normals&&t.setVerticesData(e.VertexBuffer.NormalKind,this.normals,i),this.tangents&&t.setVerticesData(e.VertexBuffer.TangentKind,this.tangents,i),this.uvs&&t.setVerticesData(e.VertexBuffer.UVKind,this.uvs,i),this.uvs2&&t.setVerticesData(e.VertexBuffer.UV2Kind,this.uvs2,i),this.uvs3&&t.setVerticesData(e.VertexBuffer.UV3Kind,this.uvs3,i),this.uvs4&&t.setVerticesData(e.VertexBuffer.UV4Kind,this.uvs4,i),this.uvs5&&t.setVerticesData(e.VertexBuffer.UV5Kind,this.uvs5,i),this.uvs6&&t.setVerticesData(e.VertexBuffer.UV6Kind,this.uvs6,i),this.colors&&t.setVerticesData(e.VertexBuffer.ColorKind,this.colors,i),this.matricesIndices&&t.setVerticesData(e.VertexBuffer.MatricesIndicesKind,this.matricesIndices,i),this.matricesWeights&&t.setVerticesData(e.VertexBuffer.MatricesWeightsKind,this.matricesWeights,i),this.matricesIndicesExtra&&t.setVerticesData(e.VertexBuffer.MatricesIndicesExtraKind,this.matricesIndicesExtra,i),this.matricesWeightsExtra&&t.setVerticesData(e.VertexBuffer.MatricesWeightsExtraKind,this.matricesWeightsExtra,i),this.indices&&t.setIndices(this.indices),this},t.prototype._update=function(t,i,r){return this.positions&&t.updateVerticesData(e.VertexBuffer.PositionKind,this.positions,i,r),this.normals&&t.updateVerticesData(e.VertexBuffer.NormalKind,this.normals,i,r),this.tangents&&t.updateVerticesData(e.VertexBuffer.TangentKind,this.tangents,i,r),this.uvs&&t.updateVerticesData(e.VertexBuffer.UVKind,this.uvs,i,r),this.uvs2&&t.updateVerticesData(e.VertexBuffer.UV2Kind,this.uvs2,i,r),this.uvs3&&t.updateVerticesData(e.VertexBuffer.UV3Kind,this.uvs3,i,r),this.uvs4&&t.updateVerticesData(e.VertexBuffer.UV4Kind,this.uvs4,i,r),this.uvs5&&t.updateVerticesData(e.VertexBuffer.UV5Kind,this.uvs5,i,r),this.uvs6&&t.updateVerticesData(e.VertexBuffer.UV6Kind,this.uvs6,i,r),this.colors&&t.updateVerticesData(e.VertexBuffer.ColorKind,this.colors,i,r),this.matricesIndices&&t.updateVerticesData(e.VertexBuffer.MatricesIndicesKind,this.matricesIndices,i,r),this.matricesWeights&&t.updateVerticesData(e.VertexBuffer.MatricesWeightsKind,this.matricesWeights,i,r),this.matricesIndicesExtra&&t.updateVerticesData(e.VertexBuffer.MatricesIndicesExtraKind,this.matricesIndicesExtra,i,r),this.matricesWeightsExtra&&t.updateVerticesData(e.VertexBuffer.MatricesWeightsExtraKind,this.matricesWeightsExtra,i,r),this.indices&&t.setIndices(this.indices),this},t.prototype.transform=function(t){var i,r=e.Vector3.Zero();if(this.positions){var n=e.Vector3.Zero();for(i=0;i<this.positions.length;i+=3)e.Vector3.FromArrayToRef(this.positions,i,n),e.Vector3.TransformCoordinatesToRef(n,t,r),this.positions[i]=r.x,this.positions[i+1]=r.y,this.positions[i+2]=r.z}if(this.normals){var s=e.Vector3.Zero();for(i=0;i<this.normals.length;i+=3)e.Vector3.FromArrayToRef(this.normals,i,s),e.Vector3.TransformNormalToRef(s,t,r),this.normals[i]=r.x,this.normals[i+1]=r.y,this.normals[i+2]=r.z}if(this.tangents){var o=e.Vector4.Zero(),a=e.Vector4.Zero();for(i=0;i<this.tangents.length;i+=4)e.Vector4.FromArrayToRef(this.tangents,i,o),e.Vector4.TransformNormalToRef(o,t,a),this.tangents[i]=a.x,this.tangents[i+1]=a.y,this.tangents[i+2]=a.z,this.tangents[i+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,i=0;i<e.indices.length;i++)this.indices.push(e.indices[i]+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 i=t.length+e.length,r=e instanceof Float32Array,n=t instanceof Float32Array;if(r){var s=new Float32Array(i);return s.set(e),s.set(t,e.length),s}if(n){for(var o=e.slice(0),a=0,i=t.length;a<i;a++)o.push(t[a]);return o}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,i,r){return t._ExtractFrom(e,i,r)},t.ExtractFromGeometry=function(e,i,r){return t._ExtractFrom(e,i,r)},t._ExtractFrom=function(i,r,n){var s=new t;return i.isVerticesDataPresent(e.VertexBuffer.PositionKind)&&(s.positions=i.getVerticesData(e.VertexBuffer.PositionKind,r,n)),i.isVerticesDataPresent(e.VertexBuffer.NormalKind)&&(s.normals=i.getVerticesData(e.VertexBuffer.NormalKind,r,n)),i.isVerticesDataPresent(e.VertexBuffer.TangentKind)&&(s.tangents=i.getVerticesData(e.VertexBuffer.TangentKind,r,n)),i.isVerticesDataPresent(e.VertexBuffer.UVKind)&&(s.uvs=i.getVerticesData(e.VertexBuffer.UVKind,r,n)),i.isVerticesDataPresent(e.VertexBuffer.UV2Kind)&&(s.uvs2=i.getVerticesData(e.VertexBuffer.UV2Kind,r,n)),i.isVerticesDataPresent(e.VertexBuffer.UV3Kind)&&(s.uvs3=i.getVerticesData(e.VertexBuffer.UV3Kind,r,n)),i.isVerticesDataPresent(e.VertexBuffer.UV4Kind)&&(s.uvs4=i.getVerticesData(e.VertexBuffer.UV4Kind,r,n)),i.isVerticesDataPresent(e.VertexBuffer.UV5Kind)&&(s.uvs5=i.getVerticesData(e.VertexBuffer.UV5Kind,r,n)),i.isVerticesDataPresent(e.VertexBuffer.UV6Kind)&&(s.uvs6=i.getVerticesData(e.VertexBuffer.UV6Kind,r,n)),i.isVerticesDataPresent(e.VertexBuffer.ColorKind)&&(s.colors=i.getVerticesData(e.VertexBuffer.ColorKind,r,n)),i.isVerticesDataPresent(e.VertexBuffer.MatricesIndicesKind)&&(s.matricesIndices=i.getVerticesData(e.VertexBuffer.MatricesIndicesKind,r,n)),i.isVerticesDataPresent(e.VertexBuffer.MatricesWeightsKind)&&(s.matricesWeights=i.getVerticesData(e.VertexBuffer.MatricesWeightsKind,r,n)),i.isVerticesDataPresent(e.VertexBuffer.MatricesIndicesExtraKind)&&(s.matricesIndicesExtra=i.getVerticesData(e.VertexBuffer.MatricesIndicesExtraKind,r,n)),i.isVerticesDataPresent(e.VertexBuffer.MatricesWeightsExtraKind)&&(s.matricesWeightsExtra=i.getVerticesData(e.VertexBuffer.MatricesWeightsExtraKind,r,n)),s.indices=i.getIndices(r),s},t.CreateRibbon=function(i){var r=i.pathArray,n=i.closeArray||!1,s=i.closePath||!1,o=i.invertUV||!1,a=Math.floor(r[0].length/2),h=i.offset||a;h=h>a?a:Math.floor(h);var u,c,l,f,d=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,p=i.uvs,_=i.colors,m=[],g=[],y=[],v=[],b=[],x=[],T=[],E=[],A=[],M=[];if(r.length<2){var P=[],O=[];for(l=0;l<r[0].length-h;l++)P.push(r[0][l]),O.push(r[0][l+h]);r=[P,O]}var R,C,S=0,I=s?1:0;u=r[0].length;var D,L;for(c=0;c<r.length;c++){for(T[c]=0,b[c]=[0],R=r[c],C=R.length,u=u<C?u:C,f=0;f<C;)m.push(R[f].x,R[f].y,R[f].z),f>0&&(D=R[f].subtract(R[f-1]).length(),L=D+T[c],b[c].push(L),T[c]=L),f++;s&&(f--,m.push(R[0].x,R[0].y,R[0].z),D=R[f].subtract(R[0]).length(),L=D+T[c],b[c].push(L),T[c]=L),A[c]=C+I,M[c]=S,S+=C+I}var F,B,w,N;for(l=0;l<u+I;l++){for(E[l]=0,x[l]=[0],c=0;c<r.length-1;c++)F=r[c],B=r[c+1],l===u?(w=F[0],N=B[0]):(w=F[l],N=B[l]),D=N.subtract(w).length(),L=D+E[l],x[l].push(L),E[l]=L;n&&(F=r[c],B=r[0],l===u&&(N=B[0]),D=N.subtract(w).length(),L=D+E[l],E[l]=L)}var V,U;if(p)for(c=0;c<p.length;c++)v.push(p[c].x,p[c].y);else for(c=0;c<r.length;c++)for(l=0;l<u+I;l++)V=0!=T[c]?b[c][l]/T[c]:0,U=0!=E[l]?x[l][c]/E[l]:0,o?v.push(U,V):v.push(V,U);c=0;for(var k=0,z=A[c]-1,G=A[c+1]-1,W=z<G?z:G,K=M[1]-M[0],X=n?A.length:A.length-1;k<=W&&c<X;)g.push(k,k+K,k+1),g.push(k+K+1,k+1,k+K),(k+=1)===W&&(c++,c===A.length-1?(K=M[0]-M[c],z=A[c]-1,G=A[0]-1):(K=M[c+1]-M[c],z=A[c]-1,G=A[c+1]-1),k=M[c],W=z<G?z+k:G+k);if(t.ComputeNormals(m,g,y),s){var Y=0,H=0;for(c=0;c<r.length;c++)Y=3*M[c],H=c+1<r.length?3*(M[c+1]-1):y.length-3,y[Y]=.5*(y[Y]+y[H]),y[Y+1]=.5*(y[Y+1]+y[H+1]),y[Y+2]=.5*(y[Y+2]+y[H+2]),y[H]=y[Y],y[H+1]=y[Y+1],y[H+2]=y[Y+2]}if(t._ComputeSides(d,m,g,y,v),_)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(y),$=new Float32Array(v);return Q.indices=g,Q.positions=q,Q.normals=J,Q.uvs=$,_&&Q.set(j,e.VertexBuffer.ColorKind),s&&(Q._idx=M),Q},t.CreateBox=function(i){for(var r=[new e.Vector3(0,0,1),new e.Vector3(0,0,-1),new e.Vector3(1,0,0),new e.Vector3(-1,0,0),new e.Vector3(0,1,0),new e.Vector3(0,-1,0)],n=[],s=[],o=[],a=[],h=i.width||i.size||1,u=i.height||i.size||1,c=i.depth||i.size||1,l=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,f=i.faceUV||new Array(6),d=i.faceColors,p=[],_=0;_<6;_++)void 0===f[_]&&(f[_]=new e.Vector4(0,0,1,1)),d&&void 0===d[_]&&(d[_]=new e.Color4(1,1,1,1));for(var m=new e.Vector3(h/2,u/2,c/2),g=0;g<r.length;g++){var y=r[g],v=new e.Vector3(y.y,y.z,y.x),b=e.Vector3.Cross(y,v),x=s.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 T=y.subtract(v).subtract(b).multiply(m);s.push(T.x,T.y,T.z),o.push(y.x,y.y,y.z),a.push(f[g].z,f[g].w),d&&p.push(d[g].r,d[g].g,d[g].b,d[g].a),T=y.subtract(v).add(b).multiply(m),s.push(T.x,T.y,T.z),o.push(y.x,y.y,y.z),a.push(f[g].x,f[g].w),d&&p.push(d[g].r,d[g].g,d[g].b,d[g].a),T=y.add(v).add(b).multiply(m),s.push(T.x,T.y,T.z),o.push(y.x,y.y,y.z),a.push(f[g].x,f[g].y),d&&p.push(d[g].r,d[g].g,d[g].b,d[g].a),T=y.add(v).subtract(b).multiply(m),s.push(T.x,T.y,T.z),o.push(y.x,y.y,y.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(l,s,n,o,a);var E=new t;if(E.indices=n,E.positions=s,E.normals=o,E.uvs=a,d){var A=l===e.Mesh.DOUBLESIDE?p.concat(p):p;E.colors=A}return E},t.CreateSphere=function(i){for(var r=i.segments||32,n=i.diameterX||i.diameter||1,s=i.diameterY||i.diameter||1,o=i.diameterZ||i.diameter||1,a=i.arc<=0||i.arc>1?1:i.arc||1,h=i.slice<=0?1:i.slice||1,u=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,c=new e.Vector3(n/2,s/2,o/2),l=2+r,f=2*l,d=[],p=[],_=[],m=[],g=0;g<=l;g++){for(var y=g/l,v=y*Math.PI*h,b=0;b<=f;b++){var x=b/f,T=x*Math.PI*2*a,E=e.Matrix.RotationZ(-v),A=e.Matrix.RotationY(T),M=e.Vector3.TransformCoordinates(e.Vector3.Up(),E),P=e.Vector3.TransformCoordinates(M,A),O=P.multiply(c),R=P.divide(c).normalize();p.push(O.x,O.y,O.z),_.push(R.x,R.y,R.z),m.push(x,y)}if(g>0)for(var C=p.length/3,S=C-2*(f+1);S+f+2<C;S++)d.push(S),d.push(S+1),d.push(S+f+1),d.push(S+f+1),d.push(S+1),d.push(S+f+2)}t._ComputeSides(u,p,d,_,m);var I=new t;return I.indices=d,I.positions=p,I.normals=_,I.uvs=m,I},t.CreateCylinder=function(i){var r,n=i.height||2,s=0===i.diameterTop?0:i.diameterTop||i.diameter||1,o=0===i.diameterBottom?0:i.diameterBottom||i.diameter||1,a=i.tessellation||24,h=i.subdivisions||1,u=i.hasRings,c=i.enclose,l=i.arc<=0||i.arc>1?1:i.arc||1,f=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,d=i.faceUV||new Array(3),p=i.faceColors,_=1!==l&&c?2:0,m=u?h:1,g=2+(1+_)*m;for(r=0;r<g;r++)p&&void 0===p[r]&&(p[r]=new e.Color4(1,1,1,1));for(r=0;r<g;r++)d&&void 0===d[r]&&(d[r]=new e.Vector4(0,0,1,1));var y,v,b,x,T,E,A=[],M=[],P=[],O=[],R=[],C=2*Math.PI*l/a,S=(o-s)/2/n,I=e.Vector3.Zero(),D=e.Vector3.Zero(),L=e.Vector3.Zero(),F=e.Vector3.Zero(),B=e.Vector3.Zero(),w=e.Axis.Y,N=1,V=1,U=0,k=0;for(x=0;x<=h;x++)for(v=x/h,b=(v*(s-o)+o)/2,N=u&&0!==x&&x!==h?2:1,E=0;E<N;E++){for(u&&(V+=E),c&&(V+=2*E),T=0;T<=a;T++)y=T*C,I.x=Math.cos(-y)*b,I.y=-n/2+v*n,I.z=Math.sin(-y)*b,0===s&&x===h?(D.x=P[P.length-3*(a+1)],D.y=P[P.length-3*(a+1)+1],D.z=P[P.length-3*(a+1)+2]):(D.x=I.x,D.z=I.z,D.y=Math.sqrt(D.x*D.x+D.z*D.z)*S,D.normalize()),0===T&&(L.copyFrom(I),F.copyFrom(D)),M.push(I.x,I.y,I.z),P.push(D.x,D.y,D.z),k=u?U!==V?d[V].y:d[V].w:d[V].y+(d[V].w-d[V].y)*v,O.push(d[V].x+(d[V].z-d[V].x)*T/a,k),p&&R.push(p[V].r,p[V].g,p[V].b,p[V].a);1!==l&&c&&(M.push(I.x,I.y,I.z),M.push(0,I.y,0),M.push(0,I.y,0),M.push(L.x,L.y,L.z),e.Vector3.CrossToRef(w,D,B),B.normalize(),P.push(B.x,B.y,B.z,B.x,B.y,B.z),e.Vector3.CrossToRef(F,w,B),B.normalize(),P.push(B.x,B.y,B.z,B.x,B.y,B.z),k=u?U!==V?d[V+1].y:d[V+1].w:d[V+1].y+(d[V+1].w-d[V+1].y)*v,O.push(d[V+1].x,k),O.push(d[V+1].z,k),k=u?U!==V?d[V+2].y:d[V+2].w:d[V+2].y+(d[V+2].w-d[V+2].y)*v,O.push(d[V+2].x,k),O.push(d[V+2].z,k),p&&(R.push(p[V+1].r,p[V+1].g,p[V+1].b,p[V+1].a),R.push(p[V+1].r,p[V+1].g,p[V+1].b,p[V+1].a),R.push(p[V+2].r,p[V+2].g,p[V+2].b,p[V+2].a),R.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!==l&&c?a+4:a;for(x=0,V=0;V<h;V++){for(T=0;T<a;T++){var G=x*(z+1)+T,W=(x+1)*(z+1)+T,K=x*(z+1)+(T+1),X=(x+1)*(z+1)+(T+1);A.push(G,W,K),A.push(X,K,W)}1!==l&&c&&(A.push(G+2,W+2,K+2),A.push(X+2,K+2,W+2),A.push(G+4,W+4,K+4),A.push(X+4,K+4,W+4)),x=u?x+2:x+1}var Y=function(t){var i=t?s/2:o/2;if(0!==i){var r,h,u,c,f=t?d[g-1]:d[0];p&&(c=t?p[g-1]:p[0]);var _=M.length/3,m=t?n/2:-n/2,y=new e.Vector3(0,m,0);M.push(y.x,y.y,y.z),P.push(0,t?1:-1,0),O.push(f.x+.5*(f.z-f.x),f.y+.5*(f.w-f.y)),p&&R.push(c.r,c.g,c.b,c.a);var v=new e.Vector2(.5,.5);for(u=0;u<=a;u++){r=2*Math.PI*u*l/a;var b=Math.cos(-r),x=Math.sin(-r);h=new e.Vector3(b*i,m,x*i);var T=new e.Vector2(b*v.x+.5,x*v.y+.5);M.push(h.x,h.y,h.z),P.push(0,t?1:-1,0),O.push(f.x+(f.z-f.x)*T.x,f.y+(f.w-f.y)*T.y),p&&R.push(c.r,c.g,c.b,c.a)}for(u=0;u<a;u++)t?(A.push(_),A.push(_+(u+2)),A.push(_+(u+1))):(A.push(_),A.push(_+(u+1)),A.push(_+(u+2)))}};Y(!1),Y(!0),t._ComputeSides(f,M,A,P,O);var H=new t;return H.indices=A,H.positions=M,H.normals=P,H.uvs=O,p&&(H.colors=R),H},t.CreateTorus=function(i){for(var r=[],n=[],s=[],o=[],a=i.diameter||1,h=i.thickness||.5,u=i.tessellation||16,c=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,l=u+1,f=0;f<=u;f++)for(var d=f/u,p=f*Math.PI*2/u-Math.PI/2,_=e.Matrix.Translation(a/2,0,0).multiply(e.Matrix.RotationY(p)),m=0;m<=u;m++){var g=1-m/u,y=m*Math.PI*2/u+Math.PI,v=Math.cos(y),b=Math.sin(y),x=new e.Vector3(v,b,0),T=x.scale(h/2),E=new e.Vector2(d,g);T=e.Vector3.TransformCoordinates(T,_),x=e.Vector3.TransformNormal(x,_),n.push(T.x,T.y,T.z),s.push(x.x,x.y,x.z),o.push(E.x,E.y);var A=(f+1)%l,M=(m+1)%l;r.push(f*l+m),r.push(f*l+M),r.push(A*l+m),r.push(f*l+M),r.push(A*l+M),r.push(A*l+m)}t._ComputeSides(c,n,r,s,o);var P=new t;return P.indices=r,P.positions=n,P.normals=s,P.uvs=o,P},t.CreateLineSystem=function(e){for(var i=[],r=[],n=e.lines,s=0,o=0;o<n.length;o++)for(var a=n[o],h=0;h<a.length;h++)r.push(a[h].x,a[h].y,a[h].z),h>0&&(i.push(s-1),i.push(s)),s++;var u=new t;return u.indices=i,u.positions=r,u},t.CreateDashedLines=function(i){var r=i.dashSize||3,n=i.gapSize||1,s=i.dashNb||200,o=i.points,a=new Array,h=new Array,u=e.Vector3.Zero(),c=0,l=0,f=0,d=0,p=0,_=0,m=0;for(m=0;m<o.length-1;m++)o[m+1].subtractToRef(o[m],u),c+=u.length();for(f=c/s,d=r*f/(r+n),m=0;m<o.length-1;m++){o[m+1].subtractToRef(o[m],u),l=Math.floor(u.length()/f),u.normalize();for(var g=0;g<l;g++)p=f*g,a.push(o[m].x+p*u.x,o[m].y+p*u.y,o[m].z+p*u.z),a.push(o[m].x+(p+d)*u.x,o[m].y+(p+d)*u.y,o[m].z+(p+d)*u.z),h.push(_,_+1),_+=2}var y=new t;return y.positions=a,y.indices=h,y},t.CreateGround=function(i){var r,n,s=[],o=[],a=[],h=[],u=i.width||1,c=i.height||1,l=i.subdivisionsX||i.subdivisions||1,f=i.subdivisionsY||i.subdivisions||1;for(r=0;r<=f;r++)for(n=0;n<=l;n++){var d=new e.Vector3(n*u/l-u/2,0,(f-r)*c/f-c/2),p=new e.Vector3(0,1,0);o.push(d.x,d.y,d.z),a.push(p.x,p.y,p.z),h.push(n/l,1-r/f)}for(r=0;r<f;r++)for(n=0;n<l;n++)s.push(n+1+(r+1)*(l+1)),s.push(n+1+r*(l+1)),s.push(n+r*(l+1)),s.push(n+(r+1)*(l+1)),s.push(n+1+(r+1)*(l+1)),s.push(n+r*(l+1));var _=new t;return _.indices=s,_.positions=o,_.normals=a,_.uvs=h,_},t.CreateTiledGround=function(i){var r,n,s,o,a=i.xmin||-1,h=i.zmin||-1,u=i.xmax||1,c=i.zmax||1,l=i.subdivisions||{w:1,h:1},f=i.precision||{w:1,h:1},d=[],p=[],_=[],m=[];l.h=l.h<1?1:l.h,l.w=l.w<1?1:l.w,f.w=f.w<1?1:f.w,f.h=f.h<1?1:f.h;var g={w:(u-a)/l.w,h:(c-h)/l.h};for(s=0;s<l.h;s++)for(o=0;o<l.w;o++)!(function(t,i,s,o){var a=p.length/3,h=f.w+1;for(r=0;r<f.h;r++)for(n=0;n<f.w;n++){var u=[a+n+r*h,a+(n+1)+r*h,a+(n+1)+(r+1)*h,a+n+(r+1)*h];d.push(u[1]),d.push(u[2]),d.push(u[3]),d.push(u[0]),d.push(u[1]),d.push(u[3])}var c=e.Vector3.Zero(),l=new e.Vector3(0,1,0);for(r=0;r<=f.h;r++)for(c.z=r*(o-i)/f.h+i,n=0;n<=f.w;n++)c.x=n*(s-t)/f.w+t,c.y=0,p.push(c.x,c.y,c.z),_.push(l.x,l.y,l.z),m.push(n/f.w,r/f.h)})(a+o*g.w,h+s*g.h,a+(o+1)*g.w,h+(s+1)*g.h);var y=new t;return y.indices=d,y.positions=p,y.normals=_,y.uvs=m,y},t.CreateGroundFromHeightMap=function(i){var r,n,s=[],o=[],a=[],h=[],u=i.colorFilter||new e.Color3(.3,.59,.11);for(r=0;r<=i.subdivisions;r++)for(n=0;n<=i.subdivisions;n++){var c=new e.Vector3(n*i.width/i.subdivisions-i.width/2,0,(i.subdivisions-r)*i.height/i.subdivisions-i.height/2),l=(c.x+i.width/2)/i.width*(i.bufferWidth-1)|0,f=(1-(c.z+i.height/2)/i.height)*(i.bufferHeight-1)|0,d=4*(l+f*i.bufferWidth),p=i.buffer[d]/255,_=i.buffer[d+1]/255,m=i.buffer[d+2]/255,g=p*u.r+_*u.g+m*u.b;c.y=i.minHeight+(i.maxHeight-i.minHeight)*g,o.push(c.x,c.y,c.z),a.push(0,0,0),h.push(n/i.subdivisions,1-r/i.subdivisions)}for(r=0;r<i.subdivisions;r++)for(n=0;n<i.subdivisions;n++)s.push(n+1+(r+1)*(i.subdivisions+1)),s.push(n+1+r*(i.subdivisions+1)),s.push(n+r*(i.subdivisions+1)),s.push(n+(r+1)*(i.subdivisions+1)),s.push(n+1+(r+1)*(i.subdivisions+1)),s.push(n+r*(i.subdivisions+1));t.ComputeNormals(o,s,a);var y=new t;return y.indices=s,y.positions=o,y.normals=a,y.uvs=h,y},t.CreatePlane=function(i){var r=[],n=[],s=[],o=[],a=i.width||i.size||1,h=i.height||i.size||1,u=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,c=a/2,l=h/2;n.push(-c,-l,0),s.push(0,0,-1),o.push(0,0),n.push(c,-l,0),s.push(0,0,-1),o.push(1,0),n.push(c,l,0),s.push(0,0,-1),o.push(1,1),n.push(-c,l,0),s.push(0,0,-1),o.push(0,1),r.push(0),r.push(1),r.push(2),r.push(0),r.push(2),r.push(3),t._ComputeSides(u,n,r,s,o);var f=new t;return f.indices=r,f.positions=n,f.normals=s,f.uvs=o,f},t.CreateDisc=function(i){var r=[],n=[],s=[],o=[],a=i.radius||.5,h=i.tessellation||64,u=i.arc<=0||i.arc>1?1:i.arc||1,c=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE;r.push(0,0,0),o.push(.5,.5);for(var l=2*Math.PI*u,f=l/h,d=0;d<l;d+=f){var p=Math.cos(d),_=Math.sin(d),m=(p+1)/2,g=(1-_)/2;r.push(a*p,a*_,0),o.push(m,g)}1===u&&(r.push(r[3],r[4],r[5]),o.push(o[2],o[3]));for(var y=r.length/3,v=1;v<y-1;v++)n.push(v+1,0,v);t.ComputeNormals(r,n,s),t._ComputeSides(c,r,n,s,o);var b=new t;return b.indices=n,b.positions=r,b.normals=s,b.uvs=o,b},t.CreateIcoSphere=function(i){var r,n=i.sideOrientation||e.Mesh.DEFAULTSIDE,s=i.radius||1,o=void 0===i.flat||i.flat,a=i.subdivisions||4,h=i.radiusX||s,u=i.radiusY||s,c=i.radiusZ||s,l=(1+Math.sqrt(5))/2,f=[-1,l,-0,1,l,0,-1,-l,0,1,-l,0,0,-1,-l,0,1,-l,0,-1,l,0,1,l,l,0,1,l,0,-1,-l,0,1,-l,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=[],y=[],v=[],b=[],x=0,T=new Array(3),E=new Array(3);for(r=0;r<3;r++)T[r]=e.Vector3.Zero(),E[r]=e.Vector2.Zero();for(var A=0;A<20;A++){for(r=0;r<3;r++){var M=d[3*A+r];T[r].copyFromFloats(f[3*p[M]],f[3*p[M]+1],f[3*p[M]+2]),T[r].normalize().scaleInPlace(s),E[r].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,i,r,n){var s=e.Vector3.Lerp(T[0],T[2],i/a),l=e.Vector3.Lerp(T[1],T[2],i/a),f=a===i?T[2]:e.Vector3.Lerp(s,l,t/(a-i));f.normalize();var d;if(o){var p=e.Vector3.Lerp(T[0],T[2],n/a),_=e.Vector3.Lerp(T[1],T[2],n/a);d=e.Vector3.Lerp(p,_,r/(a-n))}else d=new e.Vector3(f.x,f.y,f.z);d.x/=h,d.y/=u,d.z/=c,d.normalize();var m=e.Vector2.Lerp(E[0],E[2],i/a),A=e.Vector2.Lerp(E[1],E[2],i/a),M=a===i?E[2]:e.Vector2.Lerp(m,A,t/(a-i));y.push(f.x*h,f.y*u,f.z*c),v.push(d.x,d.y,d.z),b.push(M.x,M.y),g.push(x),x++},O=0;O<a;O++)for(var R=0;R+O<a;R++)P(R,O,R+1/3,O+1/3),P(R+1,O,R+1/3,O+1/3),P(R,O+1,R+1/3,O+1/3),R+O+1<a&&(P(R+1,O,R+2/3,O+2/3),P(R+1,O+1,R+2/3,O+2/3),P(R,O+1,R+2/3,O+2/3))}t._ComputeSides(n,y,g,v,b);var C=new t;return C.indices=g,C.positions=y,C.normals=v,C.uvs=b,C},t.CreatePolyhedron=function(i){var r=[];r[0]={vertex:[[0,0,1.732051],[1.632993,0,-.5773503],[-.8164966,1.414214,-.5773503],[-.8164966,-1.414214,-.5773503]],face:[[0,1,2],[0,2,3],[0,3,1],[1,3,2]]},r[1]={vertex:[[0,0,1.414214],[1.414214,0,0],[0,1.414214,0],[-1.414214,0,0],[0,-1.414214,0],[0,0,-1.414214]],face:[[0,1,2],[0,2,3],[0,3,4],[0,4,1],[1,4,5],[1,5,2],[2,5,3],[3,5,4]]},r[2]={vertex:[[0,0,1.070466],[.7136442,0,.7978784],[-.3568221,.618034,.7978784],[-.3568221,-.618034,.7978784],[.7978784,.618034,.3568221],[.7978784,-.618034,.3568221],[-.9341724,.381966,.3568221],[.1362939,1,.3568221],[.1362939,-1,.3568221],[-.9341724,-.381966,.3568221],[.9341724,.381966,-.3568221],[.9341724,-.381966,-.3568221],[-.7978784,.618034,-.3568221],[-.1362939,1,-.3568221],[-.1362939,-1,-.3568221],[-.7978784,-.618034,-.3568221],[.3568221,.618034,-.7978784],[.3568221,-.618034,-.7978784],[-.7136442,0,-.7978784],[0,0,-1.070466]],face:[[0,1,4,7,2],[0,2,6,9,3],[0,3,8,5,1],[1,5,11,10,4],[2,7,13,12,6],[3,9,15,14,8],[4,10,16,13,7],[5,8,14,17,11],[6,12,18,15,9],[10,11,17,19,16],[12,13,16,19,18],[14,15,18,19,17]]},r[3]={vertex:[[0,0,1.175571],[1.051462,0,.5257311],[.3249197,1,.5257311],[-.8506508,.618034,.5257311],[-.8506508,-.618034,.5257311],[.3249197,-1,.5257311],[.8506508,.618034,-.5257311],[.8506508,-.618034,-.5257311],[-.3249197,1,-.5257311],[-1.051462,0,-.5257311],[-.3249197,-1,-.5257311],[0,0,-1.175571]],face:[[0,1,2],[0,2,3],[0,3,4],[0,4,5],[0,5,1],[1,5,7],[1,7,6],[1,6,2],[2,6,8],[2,8,3],[3,8,9],[3,9,4],[4,9,10],[4,10,5],[5,10,7],[6,7,11],[6,11,8],[7,10,11],[8,11,9],[9,11,10]]},r[4]={vertex:[[0,0,1.070722],[.7148135,0,.7971752],[-.104682,.7071068,.7971752],[-.6841528,.2071068,.7971752],[-.104682,-.7071068,.7971752],[.6101315,.7071068,.5236279],[1.04156,.2071068,.1367736],[.6101315,-.7071068,.5236279],[-.3574067,1,.1367736],[-.7888348,-.5,.5236279],[-.9368776,.5,.1367736],[-.3574067,-1,.1367736],[.3574067,1,-.1367736],[.9368776,-.5,-.1367736],[.7888348,.5,-.5236279],[.3574067,-1,-.1367736],[-.6101315,.7071068,-.5236279],[-1.04156,-.2071068,-.1367736],[-.6101315,-.7071068,-.5236279],[.104682,.7071068,-.7971752],[.6841528,-.2071068,-.7971752],[.104682,-.7071068,-.7971752],[-.7148135,0,-.7971752],[0,0,-1.070722]],face:[[0,2,3],[1,6,5],[4,9,11],[7,15,13],[8,16,10],[12,14,19],[17,22,18],[20,21,23],[0,1,5,2],[0,3,9,4],[0,4,7,1],[1,7,13,6],[2,5,12,8],[2,8,10,3],[3,10,17,9],[4,11,15,7],[5,6,14,12],[6,13,20,14],[8,12,19,16],[9,17,18,11],[10,16,22,17],[11,18,21,15],[13,15,21,20],[14,20,23,19],[16,19,23,22],[18,22,23,21]]},r[5]={vertex:[[0,0,1.322876],[1.309307,0,.1889822],[-.9819805,.8660254,.1889822],[.1636634,-1.299038,.1889822],[.3273268,.8660254,-.9449112],[-.8183171,-.4330127,-.9449112]],face:[[0,3,1],[2,4,5],[0,1,4,2],[0,2,5,3],[1,3,5,4]]},r[6]={vertex:[[0,0,1.159953],[1.013464,0,.5642542],[-.3501431,.9510565,.5642542],[-.7715208,-.6571639,.5642542],[.6633206,.9510565,-.03144481],[.8682979,-.6571639,-.3996071],[-1.121664,.2938926,-.03144481],[-.2348831,-1.063314,-.3996071],[.5181548,.2938926,-.9953061],[-.5850262,-.112257,-.9953061]],face:[[0,1,4,2],[0,2,6,3],[1,5,8,4],[3,6,9,7],[5,7,9,8],[0,3,7,5,1],[2,4,8,9,6]]},r[7]={vertex:[[0,0,1.118034],[.8944272,0,.6708204],[-.2236068,.8660254,.6708204],[-.7826238,-.4330127,.6708204],[.6708204,.8660254,.2236068],[1.006231,-.4330127,-.2236068],[-1.006231,.4330127,.2236068],[-.6708204,-.8660254,-.2236068],[.7826238,.4330127,-.6708204],[.2236068,-.8660254,-.6708204],[-.8944272,0,-.6708204],[0,0,-1.118034]],face:[[0,1,4,2],[0,2,6,3],[1,5,8,4],[3,6,10,7],[5,9,11,8],[7,10,11,9],[0,3,7,9,5,1],[2,4,8,11,10,6]]},r[8]={vertex:[[-.729665,.670121,.319155],[-.655235,-.29213,-.754096],[-.093922,-.607123,.537818],[.702196,.595691,.485187],[.776626,-.36656,-.588064]],face:[[1,4,2],[0,1,2],[3,0,2],[4,3,2],[4,1,0,3]]},r[9]={vertex:[[-.868849,-.100041,.61257],[-.329458,.976099,.28078],[-.26629,-.013796,-.477654],[-.13392,-1.034115,.229829],[.738834,.707117,-.307018],[.859683,-.535264,-.338508]],face:[[3,0,2],[5,3,2],[4,5,2],[1,4,2],[0,1,2],[0,3,5,4,1]]},r[10]={vertex:[[-.610389,.243975,.531213],[-.187812,-.48795,-.664016],[-.187812,.9759,-.664016],[.187812,-.9759,.664016],[.798201,.243975,.132803]],face:[[1,3,0],[3,4,0],[3,1,4],[0,2,1],[0,4,2],[2,4,1]]},r[11]={vertex:[[-1.028778,.392027,-.048786],[-.640503,-.646161,.621837],[-.125162,-.395663,-.540059],[.004683,.888447,-.651988],[.125161,.395663,.540059],[.632925,-.791376,.433102],[1.031672,.157063,-.354165]],face:[[3,2,0],[2,1,0],[2,5,1],[0,4,3],[0,1,4],[4,1,5],[2,3,6],[3,4,6],[5,2,6],[4,5,6]]},r[12]={vertex:[[-.669867,.334933,-.529576],[-.669867,.334933,.529577],[-.4043,1.212901,0],[-.334933,-.669867,-.529576],[-.334933,-.669867,.529577],[.334933,.669867,-.529576],[.334933,.669867,.529577],[.4043,-1.212901,0],[.669867,-.334933,-.529576],[.669867,-.334933,.529577]],face:[[8,9,7],[6,5,2],[3,8,7],[5,0,2],[4,3,7],[0,1,2],[9,4,7],[1,6,2],[9,8,5,6],[8,3,0,5],[3,4,1,0],[4,9,6,1]]},r[13]={vertex:[[-.931836,.219976,-.264632],[-.636706,.318353,.692816],[-.613483,-.735083,-.264632],[-.326545,.979634,0],[-.318353,-.636706,.692816],[-.159176,.477529,-.856368],[.159176,-.477529,-.856368],[.318353,.636706,.692816],[.326545,-.979634,0],[.613482,.735082,-.264632],[.636706,-.318353,.692816],[.931835,-.219977,-.264632]],face:[[11,10,8],[7,9,3],[6,11,8],[9,5,3],[2,6,8],[5,0,3],[4,2,8],[0,1,3],[10,4,8],[1,7,3],[10,11,9,7],[11,6,5,9],[6,2,0,5],[2,4,1,0],[4,10,7,1]]},r[14]={vertex:[[-.93465,.300459,-.271185],[-.838689,-.260219,-.516017],[-.711319,.717591,.128359],[-.710334,-.156922,.080946],[-.599799,.556003,-.725148],[-.503838,-.004675,-.969981],[-.487004,.26021,.48049],[-.460089,-.750282,-.512622],[-.376468,.973135,-.325605],[-.331735,-.646985,.084342],[-.254001,.831847,.530001],[-.125239,-.494738,-.966586],[.029622,.027949,.730817],[.056536,-.982543,-.262295],[.08085,1.087391,.076037],[.125583,-.532729,.485984],[.262625,.599586,.780328],[.391387,-.726999,-.716259],[.513854,-.868287,.139347],[.597475,.85513,.326364],[.641224,.109523,.783723],[.737185,-.451155,.538891],[.848705,-.612742,-.314616],[.976075,.365067,.32976],[1.072036,-.19561,.084927]],face:[[15,18,21],[12,20,16],[6,10,2],[3,0,1],[9,7,13],[2,8,4,0],[0,4,5,1],[1,5,11,7],[7,11,17,13],[13,17,22,18],[18,22,24,21],[21,24,23,20],[20,23,19,16],[16,19,14,10],[10,14,8,2],[15,9,13,18],[12,15,21,20],[6,12,16,10],[3,6,2,0],[9,3,1,7],[9,15,12,6,3],[22,17,11,5,4,8,14,19,23,24]]};var n,s,o,a,h,u,c=i.type<0||i.type>=r.length?0:i.type||0,l=i.size,f=i.sizeX||l||1,d=i.sizeY||l||1,p=i.sizeZ||l||1,_=i.custom||r[c],m=_.face.length,g=i.faceUV||new Array(m),y=i.faceColors,v=void 0===i.flat||i.flat,b=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,x=[],T=[],E=[],A=[],M=[],P=0,O=0,R=[],C=0,S=0;if(v)for(S=0;S<m;S++)y&&void 0===y[S]&&(y[S]=new e.Color4(1,1,1,1)),g&&void 0===g[S]&&(g[S]=new e.Vector4(0,0,1,1));if(v)for(S=0;S<m;S++){var I=_.face[S].length;for(o=2*Math.PI/I,a=.5*Math.tan(o/2),h=.5,C=0;C<I;C++)x.push(_.vertex[_.face[S][C]][0]*f,_.vertex[_.face[S][C]][1]*d,_.vertex[_.face[S][C]][2]*p),R.push(P),P++,n=g[S].x+(g[S].z-g[S].x)*(.5+a),s=g[S].y+(g[S].w-g[S].y)*(h-.5),A.push(n,s),u=a*Math.cos(o)-h*Math.sin(o),h=a*Math.sin(o)+h*Math.cos(o),a=u,y&&M.push(y[S].r,y[S].g,y[S].b,y[S].a);for(C=0;C<I-2;C++)T.push(R[0+O],R[C+2+O],R[C+1+O]);O+=I}else{for(C=0;C<_.vertex.length;C++)x.push(_.vertex[C][0]*f,_.vertex[C][1]*d,_.vertex[C][2]*p),A.push(0,0);for(S=0;S<m;S++)for(C=0;C<_.face[S].length-2;C++)T.push(_.face[S][0],_.face[S][C+2],_.face[S][C+1])}t.ComputeNormals(x,T,E),t._ComputeSides(b,x,T,E,A);var D=new t;return D.positions=x,D.indices=T,D.normals=E,D.uvs=A,y&&v&&(D.colors=M),D},t.CreateTorusKnot=function(i){var r,n,s=[],o=[],a=[],h=[],u=i.radius||2,c=i.tube||.5,l=i.radialSegments||32,f=i.tubularSegments||32,d=i.p||2,p=i.q||3,_=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,m=function(t){var i=Math.cos(t),r=Math.sin(t),n=p/d*t,s=Math.cos(n),o=u*(2+s)*.5*i,a=u*(2+s)*r*.5,h=u*Math.sin(n)*.5;return new e.Vector3(o,a,h)};for(r=0;r<=l;r++){var g=r%l,y=g/l*2*d*Math.PI,v=m(y),b=m(y+.01),x=b.subtract(v),T=b.add(v),E=e.Vector3.Cross(x,T);for(T=e.Vector3.Cross(E,x),E.normalize(),T.normalize(),n=0;n<f;n++){var A=n%f,M=A/f*2*Math.PI,P=-c*Math.cos(M),O=c*Math.sin(M);o.push(v.x+P*T.x+O*E.x),o.push(v.y+P*T.y+O*E.y),o.push(v.z+P*T.z+O*E.z),h.push(r/l),h.push(n/f)}}for(r=0;r<l;r++)for(n=0;n<f;n++){var R=(n+1)%f,C=r*f+n,S=(r+1)*f+n,I=(r+1)*f+R,D=r*f+R;s.push(D),s.push(S),s.push(C),s.push(D),s.push(I),s.push(S)}t.ComputeNormals(o,s,a),t._ComputeSides(_,o,s,a,h);var L=new t;return L.indices=s,L.positions=o,L.normals=a,L.uvs=h,L},t.ComputeNormals=function(e,t,i,r){var n=0,s=0,o=0,a=0,h=0,u=0,c=0,l=0,f=0,d=0,p=0,_=0,m=0,g=0,y=0,v=0,b=0,x=0,T=0,E=0,A=!1,M=!1,P=!1,O=1;if(r&&(A=!!r.facetNormals,M=!!r.facetPositions,P=!!r.facetPartitioning,O=!0===r.useRightHandedSystem?-1:1),P){var R=0,C=0,S=0,I=0,D=0,L=0,F=0,B=0,w=0,N=0,V=0,U=0,k=0,z=0,G=0,W=0,K=r.bbSize.x>r.bbSize.y?r.bbSize.x:r.bbSize.y;K=K>r.bbSize.z?K:r.bbSize.z;var X=r.subDiv.X*r.ratio/r.bbSize.x,Y=r.subDiv.Y*r.ratio/r.bbSize.y,H=r.subDiv.Z*r.ratio/r.bbSize.z,j=r.subDiv.max*r.subDiv.max;r.facetPartitioning.length=0}for(n=0;n<e.length;n++)i[n]=0;var Z=t.length/3;for(n=0;n<Z;n++)_=3*t[3*n],m=_+1,g=_+2,y=3*t[3*n+1],v=y+1,b=y+2,x=3*t[3*n+2],T=x+1,E=x+2,s=e[_]-e[y],o=e[m]-e[v],a=e[g]-e[b],h=e[x]-e[y],u=e[T]-e[v],c=e[E]-e[b],l=O*(o*c-a*u),f=O*(a*h-s*c),d=O*(s*u-o*h),p=Math.sqrt(l*l+f*f+d*d),p=0===p?1:p,l/=p,f/=p,d/=p,A&&(r.facetNormals[n].x=l,r.facetNormals[n].y=f,r.facetNormals[n].z=d),M&&(r.facetPositions[n].x=(e[_]+e[y]+e[x])/3,r.facetPositions[n].y=(e[m]+e[v]+e[T])/3,r.facetPositions[n].z=(e[g]+e[b]+e[E])/3),P&&(R=Math.floor((r.facetPositions[n].x-r.bInfo.minimum.x*r.ratio)*X),C=Math.floor((r.facetPositions[n].y-r.bInfo.minimum.y*r.ratio)*Y),S=Math.floor((r.facetPositions[n].z-r.bInfo.minimum.z*r.ratio)*H),I=Math.floor((e[_]-r.bInfo.minimum.x*r.ratio)*X),D=Math.floor((e[m]-r.bInfo.minimum.y*r.ratio)*Y),L=Math.floor((e[g]-r.bInfo.minimum.z*r.ratio)*H),F=Math.floor((e[y]-r.bInfo.minimum.x*r.ratio)*X),B=Math.floor((e[v]-r.bInfo.minimum.y*r.ratio)*Y),w=Math.floor((e[b]-r.bInfo.minimum.z*r.ratio)*H),N=Math.floor((e[x]-r.bInfo.minimum.x*r.ratio)*X),V=Math.floor((e[T]-r.bInfo.minimum.y*r.ratio)*Y),U=Math.floor((e[E]-r.bInfo.minimum.z*r.ratio)*H),z=I+r.subDiv.max*D+j*L,G=F+r.subDiv.max*B+j*w,W=N+r.subDiv.max*V+j*U,k=R+r.subDiv.max*C+j*S,r.facetPartitioning[k]=r.facetPartitioning[k]?r.facetPartitioning[k]:new Array,r.facetPartitioning[z]=r.facetPartitioning[z]?r.facetPartitioning[z]:new Array,r.facetPartitioning[G]=r.facetPartitioning[G]?r.facetPartitioning[G]:new Array,r.facetPartitioning[W]=r.facetPartitioning[W]?r.facetPartitioning[W]:new Array,r.facetPartitioning[z].push(n),G!=z&&r.facetPartitioning[G].push(n),W!=G&&W!=z&&r.facetPartitioning[W].push(n),
  15. k!=z&&k!=G&&k!=W&&r.facetPartitioning[k].push(n)),i[_]+=l,i[m]+=f,i[g]+=d,i[y]+=l,i[v]+=f,i[b]+=d,i[x]+=l,i[T]+=f,i[E]+=d;for(n=0;n<i.length/3;n++)l=i[3*n],f=i[3*n+1],d=i[3*n+2],p=Math.sqrt(l*l+f*f+d*d),p=0===p?1:p,l/=p,f/=p,d/=p,i[3*n]=l,i[3*n+1]=f,i[3*n+2]=d},t._ComputeSides=function(t,i,r,n,s){var o,a,h=r.length,u=n.length;switch(t=t||e.Mesh.DEFAULTSIDE){case e.Mesh.FRONTSIDE:break;case e.Mesh.BACKSIDE:var c;for(o=0;o<h;o+=3)c=r[o],r[o]=r[o+2],r[o+2]=c;for(a=0;a<u;a++)n[a]=-n[a];break;case e.Mesh.DOUBLESIDE:for(var l=i.length,f=l/3,d=0;d<l;d++)i[l+d]=i[d];for(o=0;o<h;o+=3)r[o+h]=r[o+2]+f,r[o+1+h]=r[o+1]+f,r[o+2+h]=r[o]+f;for(a=0;a<u;a++)n[u+a]=-n[a];for(var p=s.length,_=0;_<p;_++)s[_+p]=s[_]}},t.ImportVertexData=function(i,r){var n=new t,s=i.positions;s&&n.set(s,e.VertexBuffer.PositionKind);var o=i.normals;o&&n.set(o,e.VertexBuffer.NormalKind);var a=i.tangents;a&&n.set(a,e.VertexBuffer.TangentKind);var h=i.uvs;h&&n.set(h,e.VertexBuffer.UVKind);var u=i.uv2s;u&&n.set(u,e.VertexBuffer.UV2Kind);var c=i.uv3s;c&&n.set(c,e.VertexBuffer.UV3Kind);var l=i.uv4s;l&&n.set(l,e.VertexBuffer.UV4Kind);var f=i.uv5s;f&&n.set(f,e.VertexBuffer.UV5Kind);var d=i.uv6s;d&&n.set(d,e.VertexBuffer.UV6Kind);var p=i.colors;p&&n.set(e.Color4.CheckColors4(p,s.length/3),e.VertexBuffer.ColorKind);var _=i.matricesIndices;_&&n.set(_,e.VertexBuffer.MatricesIndicesKind);var m=i.matricesWeights;m&&n.set(m,e.VertexBuffer.MatricesWeightsKind);var g=i.indices;g&&(n.indices=g),r.setAllVerticesData(n,i.updatable)},t})();e.VertexData=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(t,i,r,n,s){this.delayLoadState=e.Engine.DELAYLOADSTATE_NONE,this._totalVertices=0,this._isDisposed=!1,this.id=t,this._engine=i.getEngine(),this._meshes=[],this._scene=i,this._vertexBuffers={},this._indices=[],r?this.setAllVerticesData(r,n):(this._totalVertices=0,this._indices=[]),this._engine.getCaps().vertexArrayObject&&(this._vertexArrayObjects={}),s&&("LinesMesh"===s.getClassName()&&(this.boundingBias=new e.Vector2(0,s.intersectionThreshold),this.updateExtend()),this.applyToMesh(s),s.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,i,r,n){var s=new e.VertexBuffer(this._engine,i,t,r,0===this._meshes.length,n);this.setVerticesBuffer(s)},t.prototype.removeVerticesData=function(e){this._vertexBuffers[e]&&(this._vertexBuffers[e].dispose(),delete this._vertexBuffers[e])},t.prototype.setVerticesBuffer=function(t){var i=t.getKind();if(this._vertexBuffers[i]&&this._vertexBuffers[i].dispose(),this._vertexBuffers[i]=t,i===e.VertexBuffer.PositionKind){var r=t.getData(),n=t.getStrideSize();this._totalVertices=r.length/n,this.updateExtend(r,n);for(var s=this._meshes,o=s.length,a=0;a<o;a++){var h=s[a];h._resetPointsArrayCache(),h._boundingInfo=new e.BoundingInfo(this._extend.minimum,this._extend.maximum),h._createGlobalSubMesh(),h.computeWorldMatrix(!0)}}this.notifyUpdate(i),this._vertexArrayObjects&&(this._disposeVertexArrayObjects(),this._vertexArrayObjects={})},t.prototype.updateVerticesDataDirectly=function(e,t,i){var r=this.getVertexBuffer(e);r&&(r.updateDirectly(t,i),this.notifyUpdate(e))},t.prototype.updateVerticesData=function(t,i,r){var n=this.getVertexBuffer(t);if(n){if(n.update(i),t===e.VertexBuffer.PositionKind){var s=n.getStrideSize();this._totalVertices=i.length/s,this.updateBoundingInfo(r,i)}this.notifyUpdate(t)}},t.prototype.updateBoundingInfo=function(t,i){t&&this.updateExtend(i);for(var r=this._meshes,n=r.length,s=0;s<n;s++){var o=r[s];if(o._resetPointsArrayCache(),t){o._boundingInfo=new e.BoundingInfo(this._extend.minimum,this._extend.maximum);for(var a=0;a<o.subMeshes.length;a++){o.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,i){var r=this.getVertexBuffer(e);if(!r)return null;var n=r.getData();if(i||t&&1!==this._meshes.length){for(var s=n.length,o=[],a=0;a<s;a++)o.push(n[a]);return o}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 i=this._meshes,r=i.length,n=0;n<r;n++)i[n]._createGlobalSubMesh();this.notifyUpdate()},t.prototype.getTotalIndices=function(){return this.isReady()?this._indices.length:0},t.prototype.getIndices=function(e){if(!this.isReady())return null;var t=this._indices;if(e&&1!==this._meshes.length){for(var i=t.length,r=[],n=0;n<i;n++)r.push(t[n]);return r}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 i=this._meshes,r=i.indexOf(e);-1!==r&&(i.splice(r,1),e._geometry=null,0===i.length&&t&&this.dispose())},t.prototype.applyToMesh=function(e){if(e._geometry!==this){var t=e._geometry;t&&t.releaseForMesh(e);var i=this._meshes;e._geometry=this,this._scene.pushGeometry(this),i.push(e),this.isReady()?this._applyToMesh(e):e._boundingInfo=this._boundingInfo}},t.prototype.updateExtend=function(t,i){void 0===t&&(t=null),t||(t=this._vertexBuffers[e.VertexBuffer.PositionKind].getData()),this._extend=e.Tools.ExtractMinAndMax(t,0,this._totalVertices,this.boundingBias,i)},t.prototype._applyToMesh=function(t){var i=this._meshes.length;for(var r in this._vertexBuffers){1===i&&this._vertexBuffers[r].create();var n=this._vertexBuffers[r].getBuffer();n&&(n.references=i),r===e.VertexBuffer.PositionKind&&(t._resetPointsArrayCache(),this._extend||this.updateExtend(this._vertexBuffers[r].getData()),t._boundingInfo=new e.BoundingInfo(this._extend.minimum,this._extend.maximum),t._createGlobalSubMesh(),t._updateBoundingInfo())}1===i&&this._indices&&this._indices.length>0&&(this._indexBuffer=this._engine.createIndexBuffer(this._indices)),this._indexBuffer&&(this._indexBuffer.references=i)},t.prototype.notifyUpdate=function(e){this.onGeometryUpdated&&this.onGeometryUpdated(this,e);for(var t=0,i=this._meshes;t<i.length;t++){i[t]._markSubMeshesAsAttributesDirty()}},t.prototype.load=function(t,i){if(this.delayLoadState!==e.Engine.DELAYLOADSTATE_LOADING){if(this.isReady())return void(i&&i());this.delayLoadState=e.Engine.DELAYLOADSTATE_LOADING,this._queueLoad(t,i)}},t.prototype._queueLoad=function(t,i){var r=this;t._addPendingData(this),e.Tools.LoadFile(this.delayLoadingFile,(function(n){r._delayLoadingFunction(JSON.parse(n),r),r.delayLoadState=e.Engine.DELAYLOADSTATE_LOADED,r._delayInfo=[],t._removePendingData(r);for(var s=r._meshes,o=s.length,a=0;a<o;a++)r._applyToMesh(s[a]);i&&i()}),(function(){}),t.database)},t.prototype.toLeftHanded=function(){var t=this.getIndices(!1);if(null!=t&&t.length>0){for(var i=0;i<t.length;i+=3){var r=t[i+0];t[i+0]=t[i+2],t[i+2]=r}this.setIndices(t)}var n=this.getVerticesData(e.VertexBuffer.PositionKind,!1);if(null!=n&&n.length>0){for(var i=0;i<n.length;i+=3)n[i+2]=-n[i+2];this.setVerticesData(e.VertexBuffer.PositionKind,n,!1)}var s=this.getVerticesData(e.VertexBuffer.NormalKind,!1);if(null!=s&&s.length>0){for(var i=0;i<s.length;i+=3)s[i+2]=-s[i+2];this.setVerticesData(e.VertexBuffer.NormalKind,s,!1)}},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,i=this._meshes,r=i.length;for(t=0;t<r;t++)this.releaseForMesh(i[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(i){var r=new e.VertexData;r.indices=[];for(var n=this.getIndices(),s=0;s<n.length;s++)r.indices.push(n[s]);var o,a=!1,h=!1;for(o in this._vertexBuffers){var u=this.getVerticesData(o);u instanceof Float32Array?r.set(new Float32Array(u),o):r.set(u.slice(0),o),h||(a=this.getVertexBuffer(o).isUpdatable(),h=!a)}var c=new t(i,this._scene,r,a,null);c.delayLoadState=this.delayLoadState,c.delayLoadingFile=this.delayLoadingFile,c._delayLoadingFunction=this._delayLoadingFunction;for(o in this._delayInfo)c._delayInfo=c._delayInfo||[],c._delayInfo.push(o);return c._boundingInfo=new e.BoundingInfo(this._extend.minimum,this._extend.maximum),c},t.prototype.serialize=function(){var t={};return t.id=this.id,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 i=e._geometry;return i?i.copy(t):null},t.RandomId=function(){return e.Tools.RandomId()},t.ImportGeometry=function(t,i){var r=i.getScene(),n=t.geometryId;if(n){var s=r.getGeometryByID(n);s&&s.applyToMesh(i)}else if(t instanceof ArrayBuffer){var o=i._binaryInfo;if(o.positionsAttrDesc&&o.positionsAttrDesc.count>0){var a=new Float32Array(t,o.positionsAttrDesc.offset,o.positionsAttrDesc.count);i.setVerticesData(e.VertexBuffer.PositionKind,a,!1)}if(o.normalsAttrDesc&&o.normalsAttrDesc.count>0){var h=new Float32Array(t,o.normalsAttrDesc.offset,o.normalsAttrDesc.count);i.setVerticesData(e.VertexBuffer.NormalKind,h,!1)}if(o.uvsAttrDesc&&o.uvsAttrDesc.count>0){var u=new Float32Array(t,o.uvsAttrDesc.offset,o.uvsAttrDesc.count);i.setVerticesData(e.VertexBuffer.UVKind,u,!1)}if(o.uvs2AttrDesc&&o.uvs2AttrDesc.count>0){var c=new Float32Array(t,o.uvs2AttrDesc.offset,o.uvs2AttrDesc.count);i.setVerticesData(e.VertexBuffer.UV2Kind,c,!1)}if(o.uvs3AttrDesc&&o.uvs3AttrDesc.count>0){var l=new Float32Array(t,o.uvs3AttrDesc.offset,o.uvs3AttrDesc.count);i.setVerticesData(e.VertexBuffer.UV3Kind,l,!1)}if(o.uvs4AttrDesc&&o.uvs4AttrDesc.count>0){var f=new Float32Array(t,o.uvs4AttrDesc.offset,o.uvs4AttrDesc.count);i.setVerticesData(e.VertexBuffer.UV4Kind,f,!1)}if(o.uvs5AttrDesc&&o.uvs5AttrDesc.count>0){var d=new Float32Array(t,o.uvs5AttrDesc.offset,o.uvs5AttrDesc.count);i.setVerticesData(e.VertexBuffer.UV5Kind,d,!1)}if(o.uvs6AttrDesc&&o.uvs6AttrDesc.count>0){var p=new Float32Array(t,o.uvs6AttrDesc.offset,o.uvs6AttrDesc.count);i.setVerticesData(e.VertexBuffer.UV6Kind,p,!1)}if(o.colorsAttrDesc&&o.colorsAttrDesc.count>0){var _=new Float32Array(t,o.colorsAttrDesc.offset,o.colorsAttrDesc.count);i.setVerticesData(e.VertexBuffer.ColorKind,_,!1,o.colorsAttrDesc.stride)}if(o.matricesIndicesAttrDesc&&o.matricesIndicesAttrDesc.count>0){var m=new Int32Array(t,o.matricesIndicesAttrDesc.offset,o.matricesIndicesAttrDesc.count);i.setVerticesData(e.VertexBuffer.MatricesIndicesKind,m,!1)}if(o.matricesWeightsAttrDesc&&o.matricesWeightsAttrDesc.count>0){var g=new Float32Array(t,o.matricesWeightsAttrDesc.offset,o.matricesWeightsAttrDesc.count);i.setVerticesData(e.VertexBuffer.MatricesWeightsKind,g,!1)}if(o.indicesAttrDesc&&o.indicesAttrDesc.count>0){var y=new Int32Array(t,o.indicesAttrDesc.offset,o.indicesAttrDesc.count);i.setIndices(y)}if(o.subMeshesAttrDesc&&o.subMeshesAttrDesc.count>0){var v=new Int32Array(t,o.subMeshesAttrDesc.offset,5*o.subMeshesAttrDesc.count);i.subMeshes=[];for(var b=0;b<o.subMeshesAttrDesc.count;b++){var x=v[5*b+0],T=v[5*b+1],E=v[5*b+2],A=v[5*b+3],M=v[5*b+4];new e.SubMesh(x,T,E,A,M,i)}}}else if(t.positions&&t.normals&&t.indices){if(i.setVerticesData(e.VertexBuffer.PositionKind,t.positions,t.positions._updatable),i.setVerticesData(e.VertexBuffer.NormalKind,t.normals,t.normals._updatable),t.uvs&&i.setVerticesData(e.VertexBuffer.UVKind,t.uvs,t.uvs._updatable),t.uvs2&&i.setVerticesData(e.VertexBuffer.UV2Kind,t.uvs2,t.uvs2._updatable),t.uvs3&&i.setVerticesData(e.VertexBuffer.UV3Kind,t.uvs3,t.uvs3._updatable),t.uvs4&&i.setVerticesData(e.VertexBuffer.UV4Kind,t.uvs4,t.uvs4._updatable),t.uvs5&&i.setVerticesData(e.VertexBuffer.UV5Kind,t.uvs5,t.uvs5._updatable),t.uvs6&&i.setVerticesData(e.VertexBuffer.UV6Kind,t.uvs6,t.uvs6._updatable),t.colors&&i.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,i.setVerticesData(e.VertexBuffer.MatricesIndicesKind,t.matricesIndices,t.matricesIndices._updatable);else{for(var P=[],b=0;b<t.matricesIndices.length;b++){var O=t.matricesIndices[b];P.push(255&O),P.push((65280&O)>>8),P.push((16711680&O)>>16),P.push(O>>24)}i.setVerticesData(e.VertexBuffer.MatricesIndicesKind,P,t.matricesIndices._updatable)}if(t.matricesIndicesExtra)if(t.matricesIndicesExtra._isExpanded)delete t.matricesIndices._isExpanded,i.setVerticesData(e.VertexBuffer.MatricesIndicesExtraKind,t.matricesIndicesExtra,t.matricesIndicesExtra._updatable);else{for(var P=[],b=0;b<t.matricesIndicesExtra.length;b++){var O=t.matricesIndicesExtra[b];P.push(255&O),P.push((65280&O)>>8),P.push((16711680&O)>>16),P.push(O>>24)}i.setVerticesData(e.VertexBuffer.MatricesIndicesExtraKind,P,t.matricesIndicesExtra._updatable)}t.matricesWeights&&i.setVerticesData(e.VertexBuffer.MatricesWeightsKind,t.matricesWeights,t.matricesWeights._updatable),t.matricesWeightsExtra&&i.setVerticesData(e.VertexBuffer.MatricesWeightsExtraKind,t.matricesWeightsExtra,t.matricesWeights._updatable),i.setIndices(t.indices)}if(t.subMeshes){i.subMeshes=[];for(var R=0;R<t.subMeshes.length;R++){var C=t.subMeshes[R];new e.SubMesh(C.materialIndex,C.verticesStart,C.verticesCount,C.indexStart,C.indexCount,i)}}i._shouldGenerateFlatShading&&(i.convertToFlatShadedMesh(),delete i._shouldGenerateFlatShading),i.computeWorldMatrix(!0),r._selectionOctree&&r._selectionOctree.addMesh(i)},t.Parse=function(i,r,n){if(r.getGeometryByID(i.id))return null;var s=new t(i.id,r);return e.Tags.AddTagsTo(s,i.tags),i.delayLoadingFile?(s.delayLoadState=e.Engine.DELAYLOADSTATE_NOTLOADED,s.delayLoadingFile=n+i.delayLoadingFile,s._boundingInfo=new e.BoundingInfo(e.Vector3.FromArray(i.boundingBoxMinimum),e.Vector3.FromArray(i.boundingBoxMaximum)),s._delayInfo=[],i.hasUVs&&s._delayInfo.push(e.VertexBuffer.UVKind),i.hasUVs2&&s._delayInfo.push(e.VertexBuffer.UV2Kind),i.hasUVs3&&s._delayInfo.push(e.VertexBuffer.UV3Kind),i.hasUVs4&&s._delayInfo.push(e.VertexBuffer.UV4Kind),i.hasUVs5&&s._delayInfo.push(e.VertexBuffer.UV5Kind),i.hasUVs6&&s._delayInfo.push(e.VertexBuffer.UV6Kind),i.hasColors&&s._delayInfo.push(e.VertexBuffer.ColorKind),i.hasMatricesIndices&&s._delayInfo.push(e.VertexBuffer.MatricesIndicesKind),i.hasMatricesWeights&&s._delayInfo.push(e.VertexBuffer.MatricesWeightsKind),s._delayLoadingFunction=e.VertexData.ImportVertexData):e.VertexData.ImportVertexData(i,s),r.pushGeometry(s,!0),s},t})();e.Geometry=t,(function(t){!(function(i){var r=(function(e){function t(t,i,r,n){var s=e.call(this,t,i,null,!1,n)||this;return s._canBeRegenerated=r,s._beingRegenerated=!0,s.regenerate(),s._beingRegenerated=!1,s}return __extends(t,e),t.prototype.canBeRegenerated=function(){return this._canBeRegenerated},t.prototype.regenerate=function(){this._canBeRegenerated&&(this._beingRegenerated=!0,this.setAllVerticesData(this._regenerateVertexData(),!1),this._beingRegenerated=!1)},t.prototype.asNewGeometry=function(t){return e.prototype.copy.call(this,t)},t.prototype.setAllVerticesData=function(t,i){this._beingRegenerated&&e.prototype.setAllVerticesData.call(this,t,!1)},t.prototype.setVerticesData=function(t,i,r){this._beingRegenerated&&e.prototype.setVerticesData.call(this,t,i,!1)},t.prototype._regenerateVertexData=function(){throw new Error("Abstract method")},t.prototype.copy=function(e){throw new Error("Must be overriden in sub-classes.")},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return t.canBeRegenerated=this.canBeRegenerated(),t},t})(t);i._Primitive=r;var n=(function(t){function i(i,r,n,s,o,a,h,u,c){void 0===c&&(c=e.Mesh.DEFAULTSIDE);var l=t.call(this,i,r,h,u)||this;return l.pathArray=n,l.closeArray=s,l.closePath=o,l.offset=a,l.side=c,l}return __extends(i,t),i.prototype._regenerateVertexData=function(){return e.VertexData.CreateRibbon({pathArray:this.pathArray,closeArray:this.closeArray,closePath:this.closePath,offset:this.offset,sideOrientation:this.side})},i.prototype.copy=function(e){return new i(e,this.getScene(),this.pathArray,this.closeArray,this.closePath,this.offset,this.canBeRegenerated(),null,this.side)},i})(r);i.Ribbon=n;var s=(function(i){function r(t,r,n,s,o,a){void 0===a&&(a=e.Mesh.DEFAULTSIDE);var h=i.call(this,t,r,s,o)||this;return h.size=n,h.side=a,h}return __extends(r,i),r.prototype._regenerateVertexData=function(){return e.VertexData.CreateBox({size:this.size,sideOrientation:this.side})},r.prototype.copy=function(e){return new r(e,this.getScene(),this.size,this.canBeRegenerated(),null,this.side)},r.prototype.serialize=function(){var e=i.prototype.serialize.call(this);return e.size=this.size,e},r.Parse=function(i,r){if(r.getGeometryByID(i.id))return null;var n=new t.Primitives.Box(i.id,r,i.size,i.canBeRegenerated,null);return e.Tags.AddTagsTo(n,i.tags),r.pushGeometry(n,!0),n},r})(r);i.Box=s;var o=(function(i){function r(t,r,n,s,o,a,h){void 0===h&&(h=e.Mesh.DEFAULTSIDE);var u=i.call(this,t,r,o,a)||this;return u.segments=n,u.diameter=s,u.side=h,u}return __extends(r,i),r.prototype._regenerateVertexData=function(){return e.VertexData.CreateSphere({segments:this.segments,diameter:this.diameter,sideOrientation:this.side})},r.prototype.copy=function(e){return new r(e,this.getScene(),this.segments,this.diameter,this.canBeRegenerated(),null,this.side)},r.prototype.serialize=function(){var e=i.prototype.serialize.call(this);return e.segments=this.segments,e.diameter=this.diameter,e},r.Parse=function(i,r){if(r.getGeometryByID(i.id))return null;var n=new t.Primitives.Sphere(i.id,r,i.segments,i.diameter,i.canBeRegenerated,null);return e.Tags.AddTagsTo(n,i.tags),r.pushGeometry(n,!0),n},r})(r);i.Sphere=o;var a=(function(t){function i(i,r,n,s,o,a,h){void 0===h&&(h=e.Mesh.DEFAULTSIDE);var u=t.call(this,i,r,o,a)||this;return u.radius=n,u.tessellation=s,u.side=h,u}return __extends(i,t),i.prototype._regenerateVertexData=function(){return e.VertexData.CreateDisc({radius:this.radius,tessellation:this.tessellation,sideOrientation:this.side})},i.prototype.copy=function(e){return new i(e,this.getScene(),this.radius,this.tessellation,this.canBeRegenerated(),null,this.side)},i})(r);i.Disc=a;var h=(function(i){function r(t,r,n,s,o,a,h,u,c,l){void 0===h&&(h=1),void 0===l&&(l=e.Mesh.DEFAULTSIDE);var f=i.call(this,t,r,u,c)||this;return f.height=n,f.diameterTop=s,f.diameterBottom=o,f.tessellation=a,f.subdivisions=h,f.side=l,f}return __extends(r,i),r.prototype._regenerateVertexData=function(){return e.VertexData.CreateCylinder({height:this.height,diameterTop:this.diameterTop,diameterBottom:this.diameterBottom,tessellation:this.tessellation,subdivisions:this.subdivisions,sideOrientation:this.side})},r.prototype.copy=function(e){return new r(e,this.getScene(),this.height,this.diameterTop,this.diameterBottom,this.tessellation,this.subdivisions,this.canBeRegenerated(),null,this.side)},r.prototype.serialize=function(){var e=i.prototype.serialize.call(this);return e.height=this.height,e.diameterTop=this.diameterTop,e.diameterBottom=this.diameterBottom,e.tessellation=this.tessellation,e},r.Parse=function(i,r){if(r.getGeometryByID(i.id))return null;var n=new t.Primitives.Cylinder(i.id,r,i.height,i.diameterTop,i.diameterBottom,i.tessellation,i.subdivisions,i.canBeRegenerated,null);return e.Tags.AddTagsTo(n,i.tags),r.pushGeometry(n,!0),n},r})(r);i.Cylinder=h;var u=(function(i){function r(t,r,n,s,o,a,h,u){void 0===u&&(u=e.Mesh.DEFAULTSIDE);var c=i.call(this,t,r,a,h)||this;return c.diameter=n,c.thickness=s,c.tessellation=o,c.side=u,c}return __extends(r,i),r.prototype._regenerateVertexData=function(){return e.VertexData.CreateTorus({diameter:this.diameter,thickness:this.thickness,tessellation:this.tessellation,sideOrientation:this.side})},r.prototype.copy=function(e){return new r(e,this.getScene(),this.diameter,this.thickness,this.tessellation,this.canBeRegenerated(),null,this.side)},r.prototype.serialize=function(){var e=i.prototype.serialize.call(this);return e.diameter=this.diameter,e.thickness=this.thickness,e.tessellation=this.tessellation,e},r.Parse=function(i,r){if(r.getGeometryByID(i.id))return null;var n=new t.Primitives.Torus(i.id,r,i.diameter,i.thickness,i.tessellation,i.canBeRegenerated,null);return e.Tags.AddTagsTo(n,i.tags),r.pushGeometry(n,!0),n},r})(r);i.Torus=u;var c=(function(i){function r(e,t,r,n,s,o,a){var h=i.call(this,e,t,o,a)||this;return h.width=r,h.height=n,h.subdivisions=s,h}return __extends(r,i),r.prototype._regenerateVertexData=function(){return e.VertexData.CreateGround({width:this.width,height:this.height,subdivisions:this.subdivisions})},r.prototype.copy=function(e){return new r(e,this.getScene(),this.width,this.height,this.subdivisions,this.canBeRegenerated(),null)},r.prototype.serialize=function(){var e=i.prototype.serialize.call(this);return e.width=this.width,e.height=this.height,e.subdivisions=this.subdivisions,e},r.Parse=function(i,r){if(r.getGeometryByID(i.id))return null;var n=new t.Primitives.Ground(i.id,r,i.width,i.height,i.subdivisions,i.canBeRegenerated,null);return e.Tags.AddTagsTo(n,i.tags),r.pushGeometry(n,!0),n},r})(r);i.Ground=c;var l=(function(t){function i(e,i,r,n,s,o,a,h,u,c){var l=t.call(this,e,i,u,c)||this;return l.xmin=r,l.zmin=n,l.xmax=s,l.zmax=o,l.subdivisions=a,l.precision=h,l}return __extends(i,t),i.prototype._regenerateVertexData=function(){return e.VertexData.CreateTiledGround({xmin:this.xmin,zmin:this.zmin,xmax:this.xmax,zmax:this.zmax,subdivisions:this.subdivisions,precision:this.precision})},i.prototype.copy=function(e){return new i(e,this.getScene(),this.xmin,this.zmin,this.xmax,this.zmax,this.subdivisions,this.precision,this.canBeRegenerated(),null)},i})(r);i.TiledGround=l;var f=(function(i){function r(t,r,n,s,o,a){void 0===a&&(a=e.Mesh.DEFAULTSIDE);var h=i.call(this,t,r,s,o)||this;return h.size=n,h.side=a,h}return __extends(r,i),r.prototype._regenerateVertexData=function(){return e.VertexData.CreatePlane({size:this.size,sideOrientation:this.side})},r.prototype.copy=function(e){return new r(e,this.getScene(),this.size,this.canBeRegenerated(),null,this.side)},r.prototype.serialize=function(){var e=i.prototype.serialize.call(this);return e.size=this.size,e},r.Parse=function(i,r){if(r.getGeometryByID(i.id))return null;var n=new t.Primitives.Plane(i.id,r,i.size,i.canBeRegenerated,null);return e.Tags.AddTagsTo(n,i.tags),r.pushGeometry(n,!0),n},r})(r);i.Plane=f;var d=(function(i){function r(t,r,n,s,o,a,h,u,c,l,f){void 0===f&&(f=e.Mesh.DEFAULTSIDE);var d=i.call(this,t,r,c,l)||this;return d.radius=n,d.tube=s,d.radialSegments=o,d.tubularSegments=a,d.p=h,d.q=u,d.side=f,d}return __extends(r,i),r.prototype._regenerateVertexData=function(){return e.VertexData.CreateTorusKnot({radius:this.radius,tube:this.tube,radialSegments:this.radialSegments,tubularSegments:this.tubularSegments,p:this.p,q:this.q,sideOrientation:this.side})},r.prototype.copy=function(e){return new r(e,this.getScene(),this.radius,this.tube,this.radialSegments,this.tubularSegments,this.p,this.q,this.canBeRegenerated(),null,this.side)},r.prototype.serialize=function(){var e=i.prototype.serialize.call(this);return e.radius=this.radius,e.tube=this.tube,e.radialSegments=this.radialSegments,e.tubularSegments=this.tubularSegments,e.p=this.p,e.q=this.q,e},r.Parse=function(i,r){if(r.getGeometryByID(i.id))return null;var n=new t.Primitives.TorusKnot(i.id,r,i.radius,i.tube,i.radialSegments,i.tubularSegments,i.p,i.q,i.canBeRegenerated,null);return e.Tags.AddTagsTo(n,i.tags),r.pushGeometry(n,!0),n},r})(r);i.TorusKnot=d})(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 i=[];i.push(0),i.push(1),i.push(2),i.push(0),i.push(2),i.push(3),this._indexBuffer=this._scene.getEngine().createIndexBuffer(i)}},t.prototype._prepareFrame=function(e){var t=this._scene.activeCamera._postProcesses;return!(0===t.length||!this._scene.postProcessesEnabled)&&(t[0].activate(this._scene.activeCamera,e),!0)},t.prototype.directRender=function(e,t){for(var i=this._scene.getEngine(),r=0;r<e.length;r++){r<e.length-1?e[r+1].activate(this._scene.activeCamera,t):t?i.bindFramebuffer(t):i.restoreDefaultFramebuffer();var n=e[r],s=n.apply();s&&(n.onBeforeRenderObservable.notifyObservers(s),this._prepareBuffers(),i.bindBuffers(this._vertexBuffers,this._indexBuffer,s),i.draw(!0,0,6),n.onAfterRenderObservable.notifyObservers(s))}i.setDepthBuffer(!0),i.setDepthWrite(!0)},t.prototype._finalizeFrame=function(e,t,i,r){if(r=r||this._scene.activeCamera._postProcesses,0!==r.length&&this._scene.postProcessesEnabled){for(var n=this._scene.getEngine(),s=0,o=r.length;s<o&&(s<o-1?r[s+1].activate(this._scene.activeCamera,t):t?n.bindFramebuffer(t,i):n.restoreDefaultFramebuffer(),!e);s++){var a=r[s],h=a.apply();h&&(a.onBeforeRenderObservable.notifyObservers(h),this._prepareBuffers(),n.bindBuffers(this._vertexBuffers,this._indexBuffer,h),n.draw(!0,0,6),a.onAfterRenderObservable.notifyObservers(h))}n.setDepthBuffer(!0),n.setDepthWrite(!0)}},t.prototype.dispose=function(){var t=this._vertexBuffers[e.VertexBuffer.PositionKind];t&&(t.dispose(),this._vertexBuffers[e.VertexBuffer.PositionKind]=null),this._indexBuffer&&(this._scene.getEngine()._releaseBuffer(this._indexBuffer),this._indexBuffer=null)},t})();e.PostProcessManager=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,s){var o=t.call(this,i,r)||this;return o._textures={},o._textureArrays={},o._floats={},o._floatsArrays={},o._colors3={},o._colors4={},o._vectors2={},o._vectors3={},o._vectors4={},o._matrices={},o._matrices3x3={},o._matrices2x2={},o._vectors3Arrays={},o._cachedWorldViewMatrix=new e.Matrix,o._shaderPath=n,s.needAlphaBlending=s.needAlphaBlending||!1,s.needAlphaTesting=s.needAlphaTesting||!1,s.attributes=s.attributes||["position","normal","uv"],s.uniforms=s.uniforms||["worldViewProjection"],s.uniformBuffers=s.uniformBuffers||[],s.samplers=s.samplers||[],s.defines=s.defines||[],o._options=s,o}return __extends(i,t),i.prototype.getClassName=function(){return"ShaderMaterial"},i.prototype.needAlphaBlending=function(){return this._options.needAlphaBlending},i.prototype.needAlphaTesting=function(){return this._options.needAlphaTesting},i.prototype._checkUniform=function(e){-1===this._options.uniforms.indexOf(e)&&this._options.uniforms.push(e)},i.prototype.setTexture=function(e,t){return-1===this._options.samplers.indexOf(e)&&this._options.samplers.push(e),this._textures[e]=t,this},i.prototype.setTextureArray=function(e,t){return-1===this._options.samplers.indexOf(e)&&this._options.samplers.push(e),this._checkUniform(e),this._textureArrays[e]=t,this},
  16. i.prototype.setFloat=function(e,t){return this._checkUniform(e),this._floats[e]=t,this},i.prototype.setFloats=function(e,t){return this._checkUniform(e),this._floatsArrays[e]=t,this},i.prototype.setColor3=function(e,t){return this._checkUniform(e),this._colors3[e]=t,this},i.prototype.setColor4=function(e,t){return this._checkUniform(e),this._colors4[e]=t,this},i.prototype.setVector2=function(e,t){return this._checkUniform(e),this._vectors2[e]=t,this},i.prototype.setVector3=function(e,t){return this._checkUniform(e),this._vectors3[e]=t,this},i.prototype.setVector4=function(e,t){return this._checkUniform(e),this._vectors4[e]=t,this},i.prototype.setMatrix=function(e,t){return this._checkUniform(e),this._matrices[e]=t,this},i.prototype.setMatrix3x3=function(e,t){return this._checkUniform(e),this._matrices3x3[e]=t,this},i.prototype.setMatrix2x2=function(e,t){return this._checkUniform(e),this._matrices2x2[e]=t,this},i.prototype.setArray3=function(e,t){return this._checkUniform(e),this._vectors3Arrays[e]=t,this},i.prototype._checkCache=function(e,t,i){return!t||(this._effect&&this._effect.defines.indexOf("#define INSTANCES"),!1)},i.prototype.isReady=function(t,i){var r=this.getScene(),n=r.getEngine();if(!this.checkReadyOnEveryCall&&this._renderId===r.getRenderId()&&this._checkCache(r,t,i))return!0;var s=[],o=[],a=new e.EffectFallbacks;i&&s.push("#define INSTANCES");for(var h=0;h<this._options.defines.length;h++)s.push(this._options.defines[h]);for(var h=0;h<this._options.attributes.length;h++)o.push(this._options.attributes[h]);t&&t.isVerticesDataPresent(e.VertexBuffer.ColorKind)&&(o.push(e.VertexBuffer.ColorKind),s.push("#define VERTEXCOLOR")),t&&t.useBones&&t.computeBonesUsingShaders?(o.push(e.VertexBuffer.MatricesIndicesKind),o.push(e.VertexBuffer.MatricesWeightsKind),t.numBoneInfluencers>4&&(o.push(e.VertexBuffer.MatricesIndicesExtraKind),o.push(e.VertexBuffer.MatricesWeightsExtraKind)),s.push("#define NUM_BONE_INFLUENCERS "+t.numBoneInfluencers),s.push("#define BonesPerMesh "+(t.skeleton.bones.length+1)),a.addCPUSkinningFallback(0,t)):s.push("#define NUM_BONE_INFLUENCERS 0");for(var u in this._textures)if(!this._textures[u].isReady())return!1;n.getAlphaTesting()&&s.push("#define ALPHATEST");var c=this._effect,l=s.join("\n");return this._effect=n.createEffect(this._shaderPath,{attributes:o,uniformsNames:this._options.uniforms,uniformBuffersNames:this._options.uniformBuffers,samplers:this._options.samplers,defines:l,fallbacks:a,onCompiled:this.onCompiled,onError:this.onError},n),!!this._effect.isReady()&&(c!==this._effect&&r.resetCachedMaterial(),this._renderId=r.getRenderId(),!0)},i.prototype.bindOnlyWorldMatrix=function(e){var t=this.getScene();-1!==this._options.uniforms.indexOf("world")&&this._effect.setMatrix("world",e),-1!==this._options.uniforms.indexOf("worldView")&&(e.multiplyToRef(t.getViewMatrix(),this._cachedWorldViewMatrix),this._effect.setMatrix("worldView",this._cachedWorldViewMatrix)),-1!==this._options.uniforms.indexOf("worldViewProjection")&&this._effect.setMatrix("worldViewProjection",e.multiply(t.getTransformMatrix()))},i.prototype.bind=function(t,i){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(i,this._effect);var r;for(r in this._textures)this._effect.setTexture(r,this._textures[r]);for(r in this._textureArrays)this._effect.setTextureArray(r,this._textureArrays[r]);for(r in this._floats)this._effect.setFloat(r,this._floats[r]);for(r in this._floatsArrays)this._effect.setArray(r,this._floatsArrays[r]);for(r in this._colors3)this._effect.setColor3(r,this._colors3[r]);for(r in this._colors4){var n=this._colors4[r];this._effect.setFloat4(r,n.r,n.g,n.b,n.a)}for(r in this._vectors2)this._effect.setVector2(r,this._vectors2[r]);for(r in this._vectors3)this._effect.setVector3(r,this._vectors3[r]);for(r in this._vectors4)this._effect.setVector4(r,this._vectors4[r]);for(r in this._matrices)this._effect.setMatrix(r,this._matrices[r]);for(r in this._matrices3x3)this._effect.setMatrix3x3(r,this._matrices3x3[r]);for(r in this._matrices2x2)this._effect.setMatrix2x2(r,this._matrices2x2[r]);for(r in this._vectors3Arrays)this._effect.setArray3(r,this._vectors3Arrays[r])}this._afterBind(i)},i.prototype.clone=function(e){return new i(e,this.getScene(),this._shaderPath,this._options)},i.prototype.dispose=function(e,i){if(i){var r;for(r in this._textures)this._textures[r].dispose();for(r in this._textureArrays)for(var n=this._textureArrays[r],s=0;s<n.length;s++)n[s].dispose()}this._textures={},t.prototype.dispose.call(this,e,i)},i.prototype.serialize=function(){var t=e.SerializationHelper.Serialize(this);t.customType="BABYLON.ShaderMaterial",t.options=this._options,t.shaderPath=this._shaderPath;var i;t.textures={};for(i in this._textures)t.textures[i]=this._textures[i].serialize();t.textureArrays={};for(i in this._textureArrays){t.textureArrays[i]=[];for(var r=this._textureArrays[i],n=0;n<r.length;n++)t.textureArrays[i].push(r[n].serialize())}t.floats={};for(i in this._floats)t.floats[i]=this._floats[i];t.floatArrays={};for(i in this._floatsArrays)t.floatArrays[i]=this._floatsArrays[i];t.colors3={};for(i in this._colors3)t.colors3[i]=this._colors3[i].asArray();t.colors4={};for(i in this._colors4)t.colors4[i]=this._colors4[i].asArray();t.vectors2={};for(i in this._vectors2)t.vectors2[i]=this._vectors2[i].asArray();t.vectors3={};for(i in this._vectors3)t.vectors3[i]=this._vectors3[i].asArray();t.vectors4={};for(i in this._vectors4)t.vectors4[i]=this._vectors4[i].asArray();t.matrices={};for(i in this._matrices)t.matrices[i]=this._matrices[i].asArray();t.matrices3x3={};for(i in this._matrices3x3)t.matrices3x3[i]=this._matrices3x3[i];t.matrices2x2={};for(i in this._matrices2x2)t.matrices2x2[i]=this._matrices2x2[i];t.vectors3Arrays={};for(i in this._vectors3Arrays)t.vectors3Arrays[i]=this._vectors3Arrays[i];return t},i.Parse=function(t,r,n){var s,o=e.SerializationHelper.Parse((function(){return new i(t.name,r,t.shaderPath,t.options)}),t,r,n);for(s in t.textures)o.setTexture(s,e.Texture.Parse(t.textures[s],r,n));for(s in t.textureArrays){for(var a=t.textureArrays[s],h=new Array,u=0;u<a.length;u++)h.push(e.Texture.Parse(a[u],r,n));o.setTextureArray(s,h)}for(s in t.floats)o.setFloat(s,t.floats[s]);for(s in t.floatsArrays)o.setFloats(s,t.floatsArrays[s]);for(s in t.colors3)o.setColor3(s,e.Color3.FromArray(t.colors3[s]));for(s in t.colors4)o.setColor4(s,e.Color4.FromArray(t.colors4[s]));for(s in t.vectors2)o.setVector2(s,e.Vector2.FromArray(t.vectors2[s]));for(s in t.vectors3)o.setVector3(s,e.Vector3.FromArray(t.vectors3[s]));for(s in t.vectors4)o.setVector4(s,e.Vector4.FromArray(t.vectors4[s]));for(s in t.matrices)o.setMatrix(s,e.Matrix.FromArray(t.matrices[s]));for(s in t.matrices3x3)o.setMatrix3x3(s,t.matrices3x3[s]);for(s in t.matrices2x2)o.setMatrix2x2(s,t.matrices2x2[s]);for(s in t.vectors3Arrays)o.setArray3(s,t.vectors3Arrays[s]);return o},i})(e.Material);e.ShaderMaterial=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(){}return t.updateSideOrientation=function(t,i){return t==e.Mesh.DOUBLESIDE?e.Mesh.DOUBLESIDE:void 0===t||null===t?e.Mesh.FRONTSIDE:t},t.CreateBox=function(i,r,n){var s=new e.Mesh(i,n);return r.sideOrientation=t.updateSideOrientation(r.sideOrientation,n),s.sideOrientation=r.sideOrientation,e.VertexData.CreateBox(r).applyToMesh(s,r.updatable),s},t.CreateSphere=function(i,r,n){var s=new e.Mesh(i,n);return r.sideOrientation=t.updateSideOrientation(r.sideOrientation,n),s.sideOrientation=r.sideOrientation,e.VertexData.CreateSphere(r).applyToMesh(s,r.updatable),s},t.CreateDisc=function(i,r,n){var s=new e.Mesh(i,n);return r.sideOrientation=t.updateSideOrientation(r.sideOrientation,n),s.sideOrientation=r.sideOrientation,e.VertexData.CreateDisc(r).applyToMesh(s,r.updatable),s},t.CreateIcoSphere=function(i,r,n){var s=new e.Mesh(i,n);return r.sideOrientation=t.updateSideOrientation(r.sideOrientation,n),s.sideOrientation=r.sideOrientation,e.VertexData.CreateIcoSphere(r).applyToMesh(s,r.updatable),s},t.CreateRibbon=function(i,r,n){var s=r.pathArray,o=r.closeArray,a=r.closePath,h=(r.offset,t.updateSideOrientation(r.sideOrientation,n)),u=r.instance,c=r.updatable;if(u){e.Vector3.FromFloatsToRef(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,e.Tmp.Vector3[0]),e.Vector3.FromFloatsToRef(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE,e.Tmp.Vector3[1]);var l=u.getVerticesData(e.VertexBuffer.PositionKind);if(function(t){for(var i=s[0].length,r=0,n=u.sideOrientation===e.Mesh.DOUBLESIDE?2:1,o=1;o<=n;o++)for(var a=0;a<s.length;a++){var h=s[a],c=h.length;i=i<c?i:c;for(var l=0;l<i;)t[r]=h[l].x,t[r+1]=h[l].y,t[r+2]=h[l].z,h[l].x<e.Tmp.Vector3[0].x&&(e.Tmp.Vector3[0].x=h[l].x),h[l].x>e.Tmp.Vector3[1].x&&(e.Tmp.Vector3[1].x=h[l].x),h[l].y<e.Tmp.Vector3[0].y&&(e.Tmp.Vector3[0].y=h[l].y),h[l].y>e.Tmp.Vector3[1].y&&(e.Tmp.Vector3[1].y=h[l].y),h[l].z<e.Tmp.Vector3[0].z&&(e.Tmp.Vector3[0].z=h[l].z),h[l].z>e.Tmp.Vector3[1].z&&(e.Tmp.Vector3[1].z=h[l].z),l++,r+=3;u._closePath&&(t[r]=h[0].x,t[r+1]=h[0].y,t[r+2]=h[0].z,r+=3)}}(l),u._boundingInfo=new e.BoundingInfo(e.Tmp.Vector3[0],e.Tmp.Vector3[1]),u._boundingInfo.update(u._worldMatrix),u.updateVerticesData(e.VertexBuffer.PositionKind,l,!1,!1),r.colors){for(var f=u.getVerticesData(e.VertexBuffer.ColorKind),d=0;d<r.colors.length;d++)f[4*d]=r.colors[d].r,f[4*d+1]=r.colors[d].g,f[4*d+2]=r.colors[d].b,f[4*d+3]=r.colors[d].a;u.updateVerticesData(e.VertexBuffer.ColorKind,f,!1,!1)}if(r.uvs){for(var p=u.getVerticesData(e.VertexBuffer.UVKind),_=0;_<r.uvs.length;_++)p[2*_]=r.uvs[_].x,p[2*_+1]=r.uvs[_].y;u.updateVerticesData(e.VertexBuffer.UVKind,p,!1,!1)}if(!u.areNormalsFrozen||u.isFacetDataEnabled){var m=u.getIndices(),g=u.getVerticesData(e.VertexBuffer.NormalKind),y=u.isFacetDataEnabled?u.getFacetDataParameters():null;if(e.VertexData.ComputeNormals(l,m,g,y),u._closePath)for(var v=0,b=0,x=0;x<s.length;x++)v=3*u._idx[x],b=x+1<s.length?3*(u._idx[x+1]-1):g.length-3,g[v]=.5*(g[v]+g[b]),g[v+1]=.5*(g[v+1]+g[b+1]),g[v+2]=.5*(g[v+2]+g[b+2]),g[b]=g[v],g[b+1]=g[v+1],g[b+2]=g[v+2];u.areNormalsFrozen||u.updateVerticesData(e.VertexBuffer.NormalKind,g,!1,!1)}return u}var T=new e.Mesh(i,n);T.sideOrientation=h;var E=e.VertexData.CreateRibbon(r);return a&&(T._idx=E._idx),T._closePath=a,T._closeArray=o,E.applyToMesh(T,c),T},t.CreateCylinder=function(i,r,n){var s=new e.Mesh(i,n);return r.sideOrientation=t.updateSideOrientation(r.sideOrientation,n),s.sideOrientation=r.sideOrientation,e.VertexData.CreateCylinder(r).applyToMesh(s,r.updatable),s},t.CreateTorus=function(i,r,n){var s=new e.Mesh(i,n);return r.sideOrientation=t.updateSideOrientation(r.sideOrientation,n),s.sideOrientation=r.sideOrientation,e.VertexData.CreateTorus(r).applyToMesh(s,r.updatable),s},t.CreateTorusKnot=function(i,r,n){var s=new e.Mesh(i,n);return r.sideOrientation=t.updateSideOrientation(r.sideOrientation,n),s.sideOrientation=r.sideOrientation,e.VertexData.CreateTorusKnot(r).applyToMesh(s,r.updatable),s},t.CreateLineSystem=function(t,i,r){var n=i.instance,s=i.lines;if(n){var o=function(e){for(var t=0,i=0;i<s.length;i++)for(var r=s[i],n=0;n<r.length;n++)e[t]=r[n].x,e[t+1]=r[n].y,e[t+2]=r[n].z,t+=3};return n.updateMeshPositions(o,!1),n}var a=new e.LinesMesh(t,r);return e.VertexData.CreateLineSystem(i).applyToMesh(a,i.updatable),a},t.CreateLines=function(e,i,r){return t.CreateLineSystem(e,{lines:[i.points],updatable:i.updatable,instance:i.instance},r)},t.CreateDashedLines=function(t,i,r){var n=i.points,s=i.instance,o=i.gapSize,a=(i.dashNb,i.dashSize);if(s){var h=function(t){var i=e.Vector3.Zero(),r=t.length/6,o=0,a=0,h=0,u=0,c=0,l=0,f=0,d=0;for(f=0;f<n.length-1;f++)n[f+1].subtractToRef(n[f],i),o+=i.length();for(h=o/r,u=s.dashSize*h/(s.dashSize+s.gapSize),f=0;f<n.length-1;f++)for(n[f+1].subtractToRef(n[f],i),a=Math.floor(i.length()/h),i.normalize(),d=0;d<a&&l<t.length;)c=h*d,t[l]=n[f].x+c*i.x,t[l+1]=n[f].y+c*i.y,t[l+2]=n[f].z+c*i.z,t[l+3]=n[f].x+(c+u)*i.x,t[l+4]=n[f].y+(c+u)*i.y,t[l+5]=n[f].z+(c+u)*i.z,l+=6,d++;for(;l<t.length;)t[l]=n[f].x,t[l+1]=n[f].y,t[l+2]=n[f].z,l+=3};return s.updateMeshPositions(h,!1),s}var u=new e.LinesMesh(t,r);return e.VertexData.CreateDashedLines(i).applyToMesh(u,i.updatable),u.dashSize=a,u.gapSize=o,u},t.ExtrudeShape=function(i,r,n){var s=r.path,o=r.shape,a=r.scale||1,h=r.rotation||0,u=0===r.cap?0:r.cap||e.Mesh.NO_CAP,c=r.updatable,l=t.updateSideOrientation(r.sideOrientation,n),f=r.instance,d=r.invertUV||!1;return t._ExtrudeShapeGeneric(i,o,s,a,h,null,null,!1,!1,u,!1,n,c,l,f,d)},t.ExtrudeShapeCustom=function(i,r,n){var s=r.path,o=r.shape,a=r.scaleFunction||function(){return 1},h=r.rotationFunction||function(){return 0},u=r.ribbonCloseArray||!1,c=r.ribbonClosePath||!1,l=0===r.cap?0:r.cap||e.Mesh.NO_CAP,f=r.updatable,d=t.updateSideOrientation(r.sideOrientation,n),p=r.instance,_=r.invertUV||!1;return t._ExtrudeShapeGeneric(i,o,s,null,null,a,h,u,c,l,!0,n,f,d,p,_)},t.CreateLathe=function(i,r,n){var s,o=r.arc?r.arc<=0||r.arc>1?1:r.arc:1,a=void 0===r.closed||r.closed,h=r.shape,u=r.radius||1,c=r.tessellation||64,l=r.updatable,f=t.updateSideOrientation(r.sideOrientation,n),d=r.cap||e.Mesh.NO_CAP,p=2*Math.PI,_=new Array,m=r.invertUV||!1,g=0,y=0,v=p/c*o,b=new Array;for(g=0;g<=c;g++){var b=[];for(d!=e.Mesh.CAP_START&&d!=e.Mesh.CAP_ALL||(b.push(new e.Vector3(0,h[0].y,0)),b.push(new e.Vector3(Math.cos(g*v)*h[0].x*u,h[0].y,Math.sin(g*v)*h[0].x*u))),y=0;y<h.length;y++)s=new e.Vector3(Math.cos(g*v)*h[y].x*u,h[y].y,Math.sin(g*v)*h[y].x*u),b.push(s);d!=e.Mesh.CAP_END&&d!=e.Mesh.CAP_ALL||(b.push(new e.Vector3(Math.cos(g*v)*h[h.length-1].x*u,h[h.length-1].y,Math.sin(g*v)*h[h.length-1].x*u)),b.push(new e.Vector3(0,h[h.length-1].y,0))),_.push(b)}return t.CreateRibbon(i,{pathArray:_,closeArray:a,sideOrientation:f,updatable:l,invertUV:m},n)},t.CreatePlane=function(i,r,n){var s=new e.Mesh(i,n);if(r.sideOrientation=t.updateSideOrientation(r.sideOrientation,n),s.sideOrientation=r.sideOrientation,e.VertexData.CreatePlane(r).applyToMesh(s,r.updatable),r.sourcePlane){s.translate(r.sourcePlane.normal,r.sourcePlane.d);var o=Math.acos(e.Vector3.Dot(r.sourcePlane.normal,e.Axis.Z)),a=e.Vector3.Cross(e.Axis.Z,r.sourcePlane.normal);s.rotate(a,o)}return s},t.CreateGround=function(t,i,r){var n=new e.GroundMesh(t,r);return n._setReady(!1),n._subdivisionsX=i.subdivisionsX||i.subdivisions||1,n._subdivisionsY=i.subdivisionsY||i.subdivisions||1,n._width=i.width||1,n._height=i.height||1,n._maxX=n._width/2,n._maxZ=n._height/2,n._minX=-n._maxX,n._minZ=-n._maxZ,e.VertexData.CreateGround(i).applyToMesh(n,i.updatable),n._setReady(!0),n},t.CreateTiledGround=function(t,i,r){var n=new e.Mesh(t,r);return e.VertexData.CreateTiledGround(i).applyToMesh(n,i.updatable),n},t.CreateGroundFromHeightMap=function(t,i,r,n){var s=r.width||10,o=r.height||10,a=r.subdivisions||1,h=r.minHeight||0,u=r.maxHeight||10,c=r.colorFilter||new e.Color3(.3,.59,.11),l=r.updatable,f=r.onReady,d=new e.GroundMesh(t,n);d._subdivisionsX=a,d._subdivisionsY=a,d._width=s,d._height=o,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 i=document.createElement("canvas"),r=i.getContext("2d"),n=t.width,p=t.height;i.width=n,i.height=p,r.drawImage(t,0,0);var _=r.getImageData(0,0,n,p).data;e.VertexData.CreateGroundFromHeightMap({width:s,height:o,subdivisions:a,minHeight:h,maxHeight:u,colorFilter:c,buffer:_,bufferWidth:n,bufferHeight:p}).applyToMesh(d,l),d._setReady(!0),f&&f(d)};return e.Tools.LoadImage(i,p,(function(){}),n.database),d},t.CreateTube=function(i,r,n){var s=r.path,o=r.radius||1,a=r.tessellation||64,h=r.radiusFunction,u=r.cap||e.Mesh.NO_CAP,c=r.invertUV||!1,l=r.updatable,f=t.updateSideOrientation(r.sideOrientation,n),d=r.instance;r.arc=r.arc<=0||r.arc>1?1:r.arc||1;var p,_,m=function(t,i,r,n,s,o,a,h){for(var u,c,l,f,d=i.getTangents(),p=i.getNormals(),_=i.getDistances(),m=2*Math.PI,g=m/s*h,y=function(){return n},v=o||y,b=e.Tmp.Matrix[0],x=a===e.Mesh._NO_CAP||a===e.Mesh.CAP_END?0:2,T=0;T<t.length;T++){c=v(T,_[T]),u=Array(),l=p[T];for(var E=0;E<s;E++)e.Matrix.RotationAxisToRef(d[T],g*E,b),f=u[E]?u[E]:e.Vector3.Zero(),e.Vector3.TransformCoordinatesToRef(l,b,f),f.scaleInPlace(c).addInPlace(t[T]),u[E]=f;r[x]=u,x++}var A=function(e,i){for(var r=Array(),n=0;n<e;n++)r.push(t[i]);return r};switch(a){case e.Mesh.NO_CAP:break;case e.Mesh.CAP_START:r[0]=A(s,0),r[1]=r[2].slice(0);break;case e.Mesh.CAP_END:r[x]=r[x-1].slice(0),r[x+1]=A(s,t.length-1);break;case e.Mesh.CAP_ALL:r[0]=A(s,0),r[1]=r[2].slice(0),r[x]=r[x-1].slice(0),r[x+1]=A(s,t.length-1)}return r};if(d){var g=r.arc||d.arc;return p=d.path3D.update(s),_=m(s,p,d.pathArray,o,d.tessellation,h,d.cap,g),d=t.CreateRibbon(null,{pathArray:_,instance:d}),d.path3D=p,d.pathArray=_,d.arc=g,d}p=new e.Path3D(s);var y=new Array;u=u<0||u>3?0:u,_=m(s,p,y,o,a,h,u,r.arc);var v=t.CreateRibbon(i,{pathArray:_,closePath:!0,closeArray:!1,updatable:l,sideOrientation:f,invertUV:c},n);return v.pathArray=_,v.path3D=p,v.tessellation=a,v.cap=u,v.arc=r.arc,v},t.CreatePolyhedron=function(i,r,n){var s=new e.Mesh(i,n);return r.sideOrientation=t.updateSideOrientation(r.sideOrientation,n),s.sideOrientation=r.sideOrientation,e.VertexData.CreatePolyhedron(r).applyToMesh(s,r.updatable),s},t.CreateDecal=function(t,i,r){var n=i.getIndices(),s=i.getVerticesData(e.VertexBuffer.PositionKind),o=i.getVerticesData(e.VertexBuffer.NormalKind),a=r.position||e.Vector3.Zero(),h=r.normal||e.Vector3.Up(),u=r.size||new e.Vector3(1,1,1),c=r.angle||0;if(!h){var l=new e.Vector3(0,0,1),f=i.getScene().activeCamera,d=e.Vector3.TransformCoordinates(l,f.getWorldMatrix());h=f.globalPosition.subtract(d)}var p=-Math.atan2(h.z,h.x)-Math.PI/2,_=Math.sqrt(h.x*h.x+h.z*h.z),m=Math.atan2(h.y,_),g=e.Matrix.RotationYawPitchRoll(p,m,c).multiply(e.Matrix.Translation(a.x,a.y,a.z)),y=e.Matrix.Invert(g),v=i.getWorldMatrix(),b=v.multiply(y),x=new e.VertexData;x.indices=[],x.positions=[],x.normals=[],x.uvs=[];for(var T=0,E=function(t){var i=n[t],r=new e.PositionNormalVertex;return r.position=new e.Vector3(s[3*i],s[3*i+1],s[3*i+2]),r.position=e.Vector3.TransformCoordinates(r.position,b),r.normal=new e.Vector3(o[3*i],o[3*i+1],o[3*i+2]),r.normal=e.Vector3.TransformNormal(r.normal,b),r},A=function(t,i){if(0===t.length)return t;for(var r=.5*Math.abs(e.Vector3.Dot(u,i)),n=function(t,n){var s=e.Vector3.GetClipFactor(t.position,n.position,i,r);return new e.PositionNormalVertex(e.Vector3.Lerp(t.position,n.position,s),e.Vector3.Lerp(t.normal,n.normal,s))},s=new Array,o=0;o<t.length;o+=3){var a,h,c,l,f,d,p,_=e.Vector3.Dot(t[o].position,i)-r,m=e.Vector3.Dot(t[o+1].position,i)-r,g=e.Vector3.Dot(t[o+2].position,i)-r;switch(a=_>0,h=m>0,c=g>0,(a?1:0)+(h?1:0)+(c?1:0)){case 0:s.push(t[o]),s.push(t[o+1]),s.push(t[o+2]);break;case 1:if(a&&(l=t[o+1],f=t[o+2],d=n(t[o],l),p=n(t[o],f)),h){l=t[o],f=t[o+2],d=n(t[o+1],l),p=n(t[o+1],f),s.push(d),s.push(f.clone()),s.push(l.clone()),s.push(f.clone()),s.push(d.clone()),s.push(p);break}c&&(l=t[o],f=t[o+1],d=n(t[o+2],l),p=n(t[o+2],f)),s.push(l.clone()),s.push(f.clone()),s.push(d),s.push(p),s.push(d.clone()),s.push(f.clone());break;case 2:a||(l=t[o].clone(),f=n(l,t[o+1]),d=n(l,t[o+2]),s.push(l),s.push(f),s.push(d)),h||(l=t[o+1].clone(),f=n(l,t[o+2]),d=n(l,t[o]),s.push(l),s.push(f),s.push(d)),c||(l=t[o+2].clone(),f=n(l,t[o]),d=n(l,t[o+1]),s.push(l),s.push(f),s.push(d))}}return s},M=0;M<n.length;M+=3){var P=new Array;if(P.push(E(M)),P.push(E(M+1)),P.push(E(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 O=0;O<P.length;O++){var R=P[O];x.indices.push(T),R.position.toArray(x.positions,3*T),R.normal.toArray(x.normals,3*T),x.uvs.push(.5+R.position.x/u.x),x.uvs.push(.5+R.position.y/u.y),T++}}var C=new e.Mesh(t,i.getScene());return x.applyToMesh(C),C.position=a.clone(),C.rotation=new e.Vector3(m,p,c),C},t._ExtrudeShapeGeneric=function(i,r,n,s,o,a,h,u,c,l,f,d,p,_,m,g){var y,v,b=function(t,i,r,n,s,o,a,h,u,c){for(var l=r.getTangents(),f=r.getNormals(),d=r.getBinormals(),p=r.getDistances(),_=0,m=function(){return s},g=function(){return o},y=c?h:g,v=c?a:m,b=u===e.Mesh.NO_CAP||u===e.Mesh.CAP_END?0:2,x=e.Tmp.Matrix[0],T=0;T<i.length;T++){for(var E=new Array,A=y(T,p[T]),M=v(T,p[T]),P=0;P<t.length;P++){e.Matrix.RotationAxisToRef(l[T],_,x);var O=l[T].scale(t[P].z).add(f[T].scale(t[P].x)).add(d[T].scale(t[P].y)),R=E[P]?E[P]:e.Vector3.Zero();e.Vector3.TransformCoordinatesToRef(O,x,R),R.scaleInPlace(M).addInPlace(i[T]),E[P]=R}n[b]=E,_+=A,b++}var C=function(t){var i,r=Array(),n=e.Vector3.Zero();for(i=0;i<t.length;i++)n.addInPlace(t[i]);for(n.scaleInPlace(1/t.length),i=0;i<t.length;i++)r.push(n);return r};switch(u){case e.Mesh.NO_CAP:break;case e.Mesh.CAP_START:n[0]=C(n[2]),n[1]=n[2];break;case e.Mesh.CAP_END:n[b]=n[b-1],n[b+1]=C(n[b-1]);break;case e.Mesh.CAP_ALL:n[0]=C(n[2]),n[1]=n[2],n[b]=n[b-1],n[b+1]=C(n[b-1])}return n};if(m)return y=m.path3D.update(n),v=b(r,n,m.path3D,m.pathArray,s,o,a,h,m.cap,f),m=e.Mesh.CreateRibbon(null,v,null,null,null,d,null,null,m);y=new e.Path3D(n);var x=new Array;l=l<0||l>3?0:l,v=b(r,n,y,x,s,o,a,h,l,f);var T=t.CreateRibbon(i,{pathArray:v,closeArray:u,closePath:c,updatable:p,sideOrientation:_,invertUV:g},d);return T.pathArray=v,T.path3D=y,T.cap=l,T},t})();e.MeshBuilder=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(e,t,i){this.name=e,this.from=t,this.to=i}return e.prototype.clone=function(){return new e(this.name,this.from,this.to)},e})();e.AnimationRange=t;var i=(function(){function e(e,t,i){this.frame=e,this.action=t,this.onlyOnce=i,this.isDone=!1}return e})();e.AnimationEvent=i;var r=(function(){function t(e){this.path=e,this._onchange=new Array,this.value=0,this.animations=new Array}return t.prototype.getPoint=function(){var t=this.path.getPointAtLengthPosition(this.value);return new e.Vector3(t.x,0,t.y)},t.prototype.moveAhead=function(e){return void 0===e&&(e=.002),this.move(e),this},t.prototype.moveBack=function(e){return void 0===e&&(e=.002),this.move(-e),this},t.prototype.move=function(e){if(Math.abs(e)>1)throw"step size should be less than 1.";return this.value+=e,this.ensureLimits(),this.raiseOnChange(),this},t.prototype.ensureLimits=function(){for(;this.value>1;)this.value-=1;for(;this.value<0;)this.value+=1;return this},t.prototype.markAsDirty=function(e){return this.ensureLimits(),this.raiseOnChange(),this},t.prototype.raiseOnChange=function(){var e=this;return this._onchange.forEach((function(t){return t(e)})),this},t.prototype.onchange=function(e){return this._onchange.push(e),this},t})();e.PathCursor=r;var n=(function(){function i(e,t,r,n,s,o){this.name=e,this.targetProperty=t,this.framePerSecond=r,this.dataType=n,this.loopMode=s,this.enableBlending=o,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===s?i.ANIMATIONLOOPMODE_CYCLE:s}return i._PrepareAnimation=function(t,r,n,s,o,a,h,u){var c=void 0;if(!isNaN(parseFloat(o))&&isFinite(o)?c=i.ANIMATIONTYPE_FLOAT:o instanceof e.Quaternion?c=i.ANIMATIONTYPE_QUATERNION:o instanceof e.Vector3?c=i.ANIMATIONTYPE_VECTOR3:o instanceof e.Vector2?c=i.ANIMATIONTYPE_VECTOR2:o instanceof e.Color3?c=i.ANIMATIONTYPE_COLOR3:o instanceof e.Size&&(c=i.ANIMATIONTYPE_SIZE),void 0==c)return null;var l=new i(t,r,n,c,h),f=[{frame:0,value:o},{frame:s,value:a}];return l.setKeys(f),void 0!==u&&l.setEasingFunction(u),l},i.CreateAndStartAnimation=function(e,t,r,n,s,o,a,h,u,c){var l=i._PrepareAnimation(e,r,n,s,o,a,h,u);return t.getScene().beginDirectAnimation(t,[l],0,s,1===l.loopMode,1,c)},i.CreateMergeAndStartAnimation=function(e,t,r,n,s,o,a,h,u,c){var l=i._PrepareAnimation(e,r,n,s,o,a,h,u);return t.animations.push(l),t.getScene().beginAnimation(t,0,s,1===l.loopMode,1,c)},i.prototype.toString=function(e){var t="Name: "+this.name+", property: "+this.targetProperty;if(t+=", datatype: "+["Float","Vector3","Quaternion","Matrix","Color3","Vector2"][this.dataType],t+=", nKeys: "+(this._keys?this._keys.length:"none"),t+=", nRanges: "+(this._ranges?Object.keys(this._ranges).length:"none"),e){t+=", Ranges: {";var i=!0;for(var r in this._ranges)i&&(t+=", ",i=!1),t+=r;t+="}"}return t},i.prototype.addEvent=function(e){this._events.push(e)},i.prototype.removeEvents=function(e){for(var t=0;t<this._events.length;t++)this._events[t].frame===e&&(this._events.splice(t,1),t--)},i.prototype.createRange=function(e,i,r){this._ranges[e]||(this._ranges[e]=new t(e,i,r))},i.prototype.deleteRange=function(e,t){if(void 0===t&&(t=!0),this._ranges[e]){if(t)for(var i=this._ranges[e].from,r=this._ranges[e].to,n=this._keys.length-1;n>=0;n--)this._keys[n].frame>=i&&this._keys[n].frame<=r&&this._keys.splice(n,1);this._ranges[e]=void 0}},i.prototype.getRange=function(e){return this._ranges[e]},i.prototype.reset=function(){this._offsetsCache={},this._highLimitsCache={},this.currentFrame=0,this._blendingFactor=0,this._originalBlendValue=null},i.prototype.isStopped=function(){return this._stopped},i.prototype.getKeys=function(){return this._keys},i.prototype.getHighestFrame=function(){for(var e=0,t=0,i=this._keys.length;t<i;t++)e<this._keys[t].frame&&(e=this._keys[t].frame);return e},i.prototype.getEasingFunction=function(){return this._easingFunction},i.prototype.setEasingFunction=function(e){this._easingFunction=e},i.prototype.floatInterpolateFunction=function(t,i,r){return e.Scalar.Lerp(t,i,r)},i.prototype.floatInterpolateFunctionWithTangents=function(t,i,r,n,s){return e.Scalar.Hermite(t,i,r,n,s)},i.prototype.quaternionInterpolateFunction=function(t,i,r){return e.Quaternion.Slerp(t,i,r)},i.prototype.quaternionInterpolateFunctionWithTangents=function(t,i,r,n,s){return e.Quaternion.Hermite(t,i,r,n,s).normalize()},i.prototype.vector3InterpolateFunction=function(t,i,r){return e.Vector3.Lerp(t,i,r)},i.prototype.vector3InterpolateFunctionWithTangents=function(t,i,r,n,s){return e.Vector3.Hermite(t,i,r,n,s)},i.prototype.vector2InterpolateFunction=function(t,i,r){return e.Vector2.Lerp(t,i,r)},i.prototype.vector2InterpolateFunctionWithTangents=function(t,i,r,n,s){return e.Vector2.Hermite(t,i,r,n,s)},i.prototype.sizeInterpolateFunction=function(t,i,r){return e.Size.Lerp(t,i,r)},i.prototype.color3InterpolateFunction=function(t,i,r){return e.Color3.Lerp(t,i,r)},i.prototype.matrixInterpolateFunction=function(t,i,r){return e.Matrix.Lerp(t,i,r)},i.prototype.clone=function(){var e=new i(this.name,this.targetPropertyPath.join("."),this.framePerSecond,this.dataType,this.loopMode);if(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},i.prototype.setKeys=function(e){this._keys=e.slice(0),this._offsetsCache={},this._highLimitsCache={}},i.prototype._getKeyValue=function(e){return"function"==typeof e?e():e},i.prototype._interpolate=function(e,t,r,n,s){if(r===i.ANIMATIONLOOPMODE_CONSTANT&&t>0)return s.clone?s.clone():s;this.currentFrame=e;var o=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[o].frame>=e)for(;o-1>=0&&this._keys[o].frame>=e;)o--;for(var a=o;a<this._keys.length;a++){var h=this._keys[a+1];if(h.frame>=e){var u=this._keys[a],c=this._getKeyValue(u.value),l=this._getKeyValue(h.value),f=void 0!==u.outTangent&&void 0!==h.inTangent,d=h.frame-u.frame,p=(e-u.frame)/d;switch(null!=this._easingFunction&&(p=this._easingFunction.ease(p)),this.dataType){case i.ANIMATIONTYPE_FLOAT:var _=f?this.floatInterpolateFunctionWithTangents(c,u.outTangent*d,l,h.inTangent*d,p):this.floatInterpolateFunction(c,l,p);switch(r){case i.ANIMATIONLOOPMODE_CYCLE:case i.ANIMATIONLOOPMODE_CONSTANT:return _;case i.ANIMATIONLOOPMODE_RELATIVE:return n*t+_}break;case i.ANIMATIONTYPE_QUATERNION:var m=f?this.quaternionInterpolateFunctionWithTangents(c,u.outTangent.scale(d),l,h.inTangent.scale(d),p):this.quaternionInterpolateFunction(c,l,p);switch(r){case i.ANIMATIONLOOPMODE_CYCLE:case i.ANIMATIONLOOPMODE_CONSTANT:return m;case i.ANIMATIONLOOPMODE_RELATIVE:return m.add(n.scale(t))}return m;case i.ANIMATIONTYPE_VECTOR3:var g=f?this.vector3InterpolateFunctionWithTangents(c,u.outTangent.scale(d),l,h.inTangent.scale(d),p):this.vector3InterpolateFunction(c,l,p);switch(r){case i.ANIMATIONLOOPMODE_CYCLE:case i.ANIMATIONLOOPMODE_CONSTANT:return g;case i.ANIMATIONLOOPMODE_RELATIVE:return g.add(n.scale(t))}case i.ANIMATIONTYPE_VECTOR2:var y=f?this.vector2InterpolateFunctionWithTangents(c,u.outTangent.scale(d),l,h.inTangent.scale(d),p):this.vector2InterpolateFunction(c,l,p);switch(r){case i.ANIMATIONLOOPMODE_CYCLE:case i.ANIMATIONLOOPMODE_CONSTANT:return y;case i.ANIMATIONLOOPMODE_RELATIVE:return y.add(n.scale(t))}case i.ANIMATIONTYPE_SIZE:switch(r){case i.ANIMATIONLOOPMODE_CYCLE:case i.ANIMATIONLOOPMODE_CONSTANT:return this.sizeInterpolateFunction(c,l,p);case i.ANIMATIONLOOPMODE_RELATIVE:return this.sizeInterpolateFunction(c,l,p).add(n.scale(t))}case i.ANIMATIONTYPE_COLOR3:switch(r){case i.ANIMATIONLOOPMODE_CYCLE:case i.ANIMATIONLOOPMODE_CONSTANT:return this.color3InterpolateFunction(c,l,p);case i.ANIMATIONLOOPMODE_RELATIVE:return this.color3InterpolateFunction(c,l,p).add(n.scale(t))}case i.ANIMATIONTYPE_MATRIX:switch(r){case i.ANIMATIONLOOPMODE_CYCLE:case i.ANIMATIONLOOPMODE_CONSTANT:if(this.allowMatricesInterpolation)return this.matrixInterpolateFunction(c,l,p);case i.ANIMATIONLOOPMODE_RELATIVE:return c}}break}}return this._getKeyValue(this._keys[this._keys.length-1].value)},i.prototype.setValue=function(t,i){void 0===i&&(i=!1);var r,n;if(this.targetPropertyPath.length>1){for(var s=this._target[this.targetPropertyPath[0]],o=1;o<this.targetPropertyPath.length-1;o++)s=s[this.targetPropertyPath[o]];r=this.targetPropertyPath[this.targetPropertyPath.length-1],n=s}else r=this.targetPropertyPath[0],n=this._target;this.enableBlending&&this._blendingFactor<=1?(this._originalBlendValue||(n[r].clone?this._originalBlendValue=n[r].clone():this._originalBlendValue=n[r]),this._originalBlendValue.prototype?this._originalBlendValue.prototype.Lerp?n[r]=this._originalBlendValue.construtor.prototype.Lerp(t,this._originalBlendValue,this._blendingFactor):n[r]=t:this._originalBlendValue.m?n[r]=e.Matrix.Lerp(this._originalBlendValue,t,this._blendingFactor):n[r]=this._originalBlendValue*(1-this._blendingFactor)+this._blendingFactor*t,this._blendingFactor+=this.blendingSpeed):n[r]=t,this._target.markAsDirty&&this._target.markAsDirty(this.targetProperty)},i.prototype.goToFrame=function(e){e<this._keys[0].frame?e=this._keys[0].frame:e>this._keys[this._keys.length-1].frame&&(e=this._keys[this._keys.length-1].frame);var t=this._interpolate(e,0,this.loopMode);this.setValue(t)},i.prototype.animate=function(t,r,n,s,o,a){if(void 0===a&&(a=!1),!this.targetPropertyPath||this.targetPropertyPath.length<1)return this._stopped=!0,!1;var h=!0;if(0!==this._keys[0].frame){var u={frame:0,value:this._keys[0].value};this._keys.splice(0,0,u)}(r<this._keys[0].frame||r>this._keys[this._keys.length-1].frame)&&(r=this._keys[0].frame),(n<this._keys[0].frame||n>this._keys[this._keys.length-1].frame)&&(n=this._keys[this._keys.length-1].frame),r===n&&r++;var c,l=n-r,f=t*(this.framePerSecond*o)/1e3,d=0;if(f>l&&!s)h=!1,d=this._getKeyValue(this._keys[this._keys.length-1].value);else if(this.loopMode!==i.ANIMATIONLOOPMODE_CYCLE){var p=n.toString()+r.toString();if(!this._offsetsCache[p]){
  17. var _=this._interpolate(r,0,i.ANIMATIONLOOPMODE_CYCLE),m=this._interpolate(n,0,i.ANIMATIONLOOPMODE_CYCLE);switch(this.dataType){case i.ANIMATIONTYPE_FLOAT:this._offsetsCache[p]=m-_;break;case i.ANIMATIONTYPE_QUATERNION:this._offsetsCache[p]=m.subtract(_);break;case i.ANIMATIONTYPE_VECTOR3:this._offsetsCache[p]=m.subtract(_);case i.ANIMATIONTYPE_VECTOR2:this._offsetsCache[p]=m.subtract(_);case i.ANIMATIONTYPE_SIZE:this._offsetsCache[p]=m.subtract(_);case i.ANIMATIONTYPE_COLOR3:this._offsetsCache[p]=m.subtract(_)}this._highLimitsCache[p]=m}d=this._highLimitsCache[p],c=this._offsetsCache[p]}if(void 0===c)switch(this.dataType){case i.ANIMATIONTYPE_FLOAT:c=0;break;case i.ANIMATIONTYPE_QUATERNION:c=new e.Quaternion(0,0,0,0);break;case i.ANIMATIONTYPE_VECTOR3:c=e.Vector3.Zero();break;case i.ANIMATIONTYPE_VECTOR2:c=e.Vector2.Zero();break;case i.ANIMATIONTYPE_SIZE:c=e.Size.Zero();break;case i.ANIMATIONTYPE_COLOR3:c=e.Color3.Black()}var g=f/l>>0,y=h?r+f%l:n,v=this._interpolate(y,g,this.loopMode,c,d);this.setValue(v);for(var b=0;b<this._events.length;b++)if(y>=this._events[b].frame){var x=this._events[b];x.isDone||(x.onlyOnce&&(this._events.splice(b,1),b--),x.isDone=!0,x.action())}else this._events[b].isDone&&!this._events[b].onlyOnce&&(this._events[b].isDone=!1);return h||(this._stopped=!0),h},i.prototype.serialize=function(){var e={};e.name=this.name,e.property=this.targetProperty,e.framePerSecond=this.framePerSecond,e.dataType=this.dataType,e.loopBehavior=this.loopMode,e.enableBlending=this.enableBlending,e.blendingSpeed=this.blendingSpeed;var t=this.dataType;e.keys=[];for(var r=this.getKeys(),n=0;n<r.length;n++){var s=r[n],o={};switch(o.frame=s.frame,t){case i.ANIMATIONTYPE_FLOAT:o.values=[s.value];break;case i.ANIMATIONTYPE_QUATERNION:case i.ANIMATIONTYPE_MATRIX:case i.ANIMATIONTYPE_VECTOR3:case i.ANIMATIONTYPE_COLOR3:o.values=s.value.asArray()}e.keys.push(o)}e.ranges=[];for(var a in this._ranges){var h={};h.name=a,h.from=this._ranges[a].from,h.to=this._ranges[a].to,e.ranges.push(h)}return e},Object.defineProperty(i,"ANIMATIONTYPE_FLOAT",{get:function(){return i._ANIMATIONTYPE_FLOAT},enumerable:!0,configurable:!0}),Object.defineProperty(i,"ANIMATIONTYPE_VECTOR3",{get:function(){return i._ANIMATIONTYPE_VECTOR3},enumerable:!0,configurable:!0}),Object.defineProperty(i,"ANIMATIONTYPE_VECTOR2",{get:function(){return i._ANIMATIONTYPE_VECTOR2},enumerable:!0,configurable:!0}),Object.defineProperty(i,"ANIMATIONTYPE_SIZE",{get:function(){return i._ANIMATIONTYPE_SIZE},enumerable:!0,configurable:!0}),Object.defineProperty(i,"ANIMATIONTYPE_QUATERNION",{get:function(){return i._ANIMATIONTYPE_QUATERNION},enumerable:!0,configurable:!0}),Object.defineProperty(i,"ANIMATIONTYPE_MATRIX",{get:function(){return i._ANIMATIONTYPE_MATRIX},enumerable:!0,configurable:!0}),Object.defineProperty(i,"ANIMATIONTYPE_COLOR3",{get:function(){return i._ANIMATIONTYPE_COLOR3},enumerable:!0,configurable:!0}),Object.defineProperty(i,"ANIMATIONLOOPMODE_RELATIVE",{get:function(){return i._ANIMATIONLOOPMODE_RELATIVE},enumerable:!0,configurable:!0}),Object.defineProperty(i,"ANIMATIONLOOPMODE_CYCLE",{get:function(){return i._ANIMATIONLOOPMODE_CYCLE},enumerable:!0,configurable:!0}),Object.defineProperty(i,"ANIMATIONLOOPMODE_CONSTANT",{get:function(){return i._ANIMATIONLOOPMODE_CONSTANT},enumerable:!0,configurable:!0}),i.Parse=function(t){var r,n,s=new i(t.name,t.property,t.framePerSecond,t.dataType,t.loopBehavior),o=t.dataType,a=[];for(t.enableBlending&&(s.enableBlending=t.enableBlending),t.blendingSpeed&&(s.blendingSpeed=t.blendingSpeed),n=0;n<t.keys.length;n++){var h=t.keys[n];switch(o){case i.ANIMATIONTYPE_FLOAT:r=h.values[0];break;case i.ANIMATIONTYPE_QUATERNION:r=e.Quaternion.FromArray(h.values);break;case i.ANIMATIONTYPE_MATRIX:r=e.Matrix.FromArray(h.values);break;case i.ANIMATIONTYPE_COLOR3:r=e.Color3.FromArray(h.values);break;case i.ANIMATIONTYPE_VECTOR3:default:r=e.Vector3.FromArray(h.values)}a.push({frame:h.frame,value:r})}if(s.setKeys(a),t.ranges)for(n=0;n<t.ranges.length;n++)r=t.ranges[n],s.createRange(r.name,r.from,r.to);return s},i.AppendSerializedAnimations=function(e,t){if(e.animations){t.animations=[];for(var i=0;i<e.animations.length;i++){var r=e.animations[i];t.animations.push(r.serialize())}}},i})();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,i,r,n,s,o,a){void 0===i&&(i=0),void 0===r&&(r=100),void 0===n&&(n=!1),void 0===s&&(s=1),this.target=t,this.fromFrame=i,this.toFrame=r,this.loopAnimation=n,this.speedRatio=s,this.onAnimationEnd=o,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 i=0;i<t.length;i++){var r=t[i];r._target=e,this._animations.push(r)}},e.prototype.getAnimationByTargetProperty=function(e){for(var t=this._animations,i=0;i<t.length;i++)if(t[i].targetProperty===e)return t[i];return null},e.prototype.reset=function(){for(var e=this._animations,t=0;t<e.length;t++)e[t].reset();this._localDelayOffset=null,this._pausedDelay=null},e.prototype.enableBlending=function(e){for(var t=this._animations,i=0;i<t.length;i++)t[i].enableBlending=!0,t[i].blendingSpeed=e},e.prototype.disableBlending=function(){for(var e=this._animations,t=0;t<e.length;t++)e[t].enableBlending=!1},e.prototype.goToFrame=function(e){var t=this._animations;if(t[0]){var i=t[0].framePerSecond,r=t[0].currentFrame,n=e-r,s=1e3*n/i;this._localDelayOffset-=s}for(var o=0;o<t.length;o++)t[o].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 i=this._animations,r=i.length-1;r>=0;r--)"string"==typeof e&&i[r].name!=e||(i[r].reset(),i.splice(r,1));0==i.length&&(this._scene._activeAnimatables.splice(t,1),this.onAnimationEnd&&this.onAnimationEnd())}}else{var r=this._scene._activeAnimatables.indexOf(this);if(r>-1){this._scene._activeAnimatables.splice(r,1);for(var i=this._animations,r=0;r<i.length;r++)i[r].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,i=!1,r=this._animations;for(t=0;t<r.length;t++){var n=r[t],s=n.animate(e-this._localDelayOffset,this.fromFrame,this.toFrame,this.loopAnimation,this.speedRatio);i=i||s}return this.animationStarted=i,i||(t=this._scene._activeAnimatables.indexOf(this),this._scene._activeAnimatables.splice(t,1)),!i&&this.onAnimationEnd&&(this.onAnimationEnd(),this.onAnimationEnd=null),i},e})();e.Animatable=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(){this._easingMode=e.EASINGMODE_EASEIN}return Object.defineProperty(e,"EASINGMODE_EASEIN",{get:function(){return e._EASINGMODE_EASEIN},enumerable:!0,configurable:!0}),Object.defineProperty(e,"EASINGMODE_EASEOUT",{get:function(){return e._EASINGMODE_EASEOUT},enumerable:!0,configurable:!0}),Object.defineProperty(e,"EASINGMODE_EASEINOUT",{get:function(){return e._EASINGMODE_EASEINOUT},enumerable:!0,configurable:!0}),e.prototype.setEasingMode=function(e){var t=Math.min(Math.max(e,0),2);this._easingMode=t},e.prototype.getEasingMode=function(){return this._easingMode},e.prototype.easeInCore=function(e){throw new Error("You must implement this method")},e.prototype.ease=function(t){switch(this._easingMode){case e.EASINGMODE_EASEIN:return this.easeInCore(t);case e.EASINGMODE_EASEOUT:return 1-this.easeInCore(1-t)}return t>=.5?.5*(1-this.easeInCore(2*(1-t)))+.5:.5*this.easeInCore(2*t)},e})();t._EASINGMODE_EASEIN=0,t._EASINGMODE_EASEOUT=1,t._EASINGMODE_EASEINOUT=2,e.EasingFunction=t;var i=(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=i;var r=(function(e){function t(t){void 0===t&&(t=1);var i=e.call(this)||this;return i.amplitude=t,i}return __extends(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.amplitude);return Math.pow(e,3)-e*t*Math.sin(3.141592653589793*e)},t})(t);e.BackEase=r;var n=(function(e){function t(t,i){void 0===t&&(t=3),void 0===i&&(i=2);var r=e.call(this)||this;return r.bounces=t,r.bounciness=i,r}return __extends(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.bounces),i=this.bounciness;i<=1&&(i=1.001);var r=Math.pow(i,t),n=1-i,s=(1-r)/n+.5*r,o=e*s,a=Math.log(-o*(1-i)+1)/Math.log(i),h=Math.floor(a),u=h+1,c=(1-Math.pow(i,h))/(n*s),l=(1-Math.pow(i,u))/(n*s),f=.5*(c+l),d=e-f,p=f-c;return-Math.pow(1/i,t-h)/(p*p)*(d-p)*(d+p)},t})(t);e.BounceEase=n;var s=(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=s;var o=(function(e){function t(t,i){void 0===t&&(t=3),void 0===i&&(i=3);var r=e.call(this)||this;return r.oscillations=t,r.springiness=i,r}return __extends(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.oscillations),i=Math.max(0,this.springiness);return(0==i?e:(Math.exp(i*e)-1)/(Math.exp(i)-1))*Math.sin((6.283185307179586*t+1.5707963267948966)*e)},t})(t);e.ElasticEase=o;var a=(function(e){function t(t){void 0===t&&(t=2);var i=e.call(this)||this;return i.exponent=t,i}return __extends(t,e),t.prototype.easeInCore=function(e){return this.exponent<=0?e:(Math.exp(this.exponent*e)-1)/(Math.exp(this.exponent)-1)},t})(t);e.ExponentialEase=a;var h=(function(e){function t(t){void 0===t&&(t=2);var i=e.call(this)||this;return i.power=t,i}return __extends(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.power);return Math.pow(e,t)},t})(t);e.PowerEase=h;var u=(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=u;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},t})(t);e.QuarticEase=c;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*e},t})(t);e.QuinticEase=l;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 i(e,i,r,n){void 0===e&&(e=0),void 0===i&&(i=0),void 0===r&&(r=1),void 0===n&&(n=1);var s=t.call(this)||this;return s.x1=e,s.y1=i,s.x2=r,s.y2=n,s}return __extends(i,t),i.prototype.easeInCore=function(t){return e.BezierCurve.interpolate(t,this.x1,this.y1,this.x2,this.y2)},i})(t);e.BezierCurveEase=d})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){e.CameraInputTypes={};var t=(function(){function t(e){this.attached={},this.camera=e,this.checkInputs=function(){}}return t.prototype.add=function(t){var i=t.getSimpleName();if(this.attached[i])return void e.Tools.Warn("camera input of type "+i+" already exists on camera");this.attached[i]=t,t.camera=this.camera,t.checkInputs&&(this.checkInputs=this._addCheckInputs(t.checkInputs.bind(t))),this.attachedElement&&t.attachControl(this.attachedElement)},t.prototype.remove=function(e){for(var t in this.attached){var i=this.attached[t];i===e&&(i.detachControl(this.attachedElement),delete this.attached[t],this.rebuildInputCheck())}},t.prototype.removeByType=function(e){for(var t in this.attached){var i=this.attached[t];i.getTypeName()===e&&(i.detachControl(this.attachedElement),delete this.attached[t],this.rebuildInputCheck())}},t.prototype._addCheckInputs=function(e){var t=this.checkInputs;return function(){t(),e()}},t.prototype.attachInput=function(e){e.attachControl(this.attachedElement,this.noPreventDefault)},t.prototype.attachElement=function(t,i){if(!this.attachedElement){i=!e.Camera.ForceAttachControlToAlwaysPreventDefault&&i,this.attachedElement=t,this.noPreventDefault=i;for(var r in this.attached){this.attached[r];this.attached[r].attachControl(t,i)}}},t.prototype.detachElement=function(e){if(this.attachedElement===e){for(var t in this.attached){this.attached[t];this.attached[t].detachControl(e)}this.attachedElement=null}},t.prototype.rebuildInputCheck=function(){this.checkInputs=function(){};for(var e in this.attached){var t=this.attached[e];t.checkInputs&&(this.checkInputs=this._addCheckInputs(t.checkInputs.bind(t)))}},t.prototype.clear=function(){this.attachedElement&&this.detachElement(this.attachedElement),this.attached={},this.attachedElement=null,this.checkInputs=function(){}},t.prototype.serialize=function(t){var i={};for(var r in this.attached){var n=this.attached[r],s=e.SerializationHelper.Serialize(n);i[n.getTypeName()]=s}t.inputsmgr=i},t.prototype.parse=function(t){var i=t.inputsmgr;if(i){this.clear();for(var r in i){var n=e.CameraInputTypes[r];if(n){var s=i[r],o=e.SerializationHelper.Parse((function(){return new n}),s,null);this.add(o)}}}else for(var r in this.attached){var n=e.CameraInputTypes[this.attached[r].getTypeName()];if(n){var o=e.SerializationHelper.Parse((function(){return new n}),t,null);this.remove(this.attached[r]),this.add(o)}}},t})();e.CameraInputsManager=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n){var s=t.call(this,i,r,n)||this;return s.cameraDirection=new e.Vector3(0,0,0),s.cameraRotation=new e.Vector2(0,0),s.rotation=new e.Vector3(0,0,0),s.speed=2,s.noRotationConstraint=!1,s.lockedTarget=null,s._currentTarget=e.Vector3.Zero(),s._viewMatrix=e.Matrix.Zero(),s._camMatrix=e.Matrix.Zero(),s._cameraTransformMatrix=e.Matrix.Zero(),s._cameraRotationMatrix=e.Matrix.Zero(),s._referencePoint=new e.Vector3(0,0,1),s._defaultUpVector=new e.Vector3(0,1,0),s._transformedReferencePoint=e.Vector3.Zero(),s._lookAtTemp=e.Matrix.Zero(),s._tempMatrix=e.Matrix.Zero(),s}return __extends(i,t),i.prototype.getFrontPosition=function(e){var t=this.getTarget().subtract(this.position);return t.normalize(),t.scaleInPlace(e),this.globalPosition.add(t)},i.prototype._getLockedTargetPosition=function(){return this.lockedTarget?(this.lockedTarget.absolutePosition&&this.lockedTarget.computeWorldMatrix(),this.lockedTarget.absolutePosition||this.lockedTarget):null},i.prototype._initCache=function(){t.prototype._initCache.call(this),this._cache.lockedTarget=new e.Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.rotation=new e.Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.rotationQuaternion=new e.Quaternion(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE)},i.prototype._updateCache=function(e){e||t.prototype._updateCache.call(this);var i=this._getLockedTargetPosition();i?this._cache.lockedTarget?this._cache.lockedTarget.copyFrom(i):this._cache.lockedTarget=i.clone():this._cache.lockedTarget=null,this._cache.rotation.copyFrom(this.rotation),this.rotationQuaternion&&this._cache.rotationQuaternion.copyFrom(this.rotationQuaternion)},i.prototype._isSynchronizedViewMatrix=function(){if(!t.prototype._isSynchronizedViewMatrix.call(this))return!1;var e=this._getLockedTargetPosition();return(this._cache.lockedTarget?this._cache.lockedTarget.equals(e):!e)&&(this.rotationQuaternion?this.rotationQuaternion.equals(this._cache.rotationQuaternion):this._cache.rotation.equals(this.rotation))},i.prototype._computeLocalCameraSpeed=function(){var e=this.getEngine();return this.speed*Math.sqrt(e.getDeltaTime()/(100*e.getFps()))},i.prototype.setTarget=function(t){this.upVector.normalize(),e.Matrix.LookAtLHToRef(this.position,t,this._defaultUpVector,this._camMatrix),this._camMatrix.invert(),this.rotation.x=Math.atan(this._camMatrix.m[6]/this._camMatrix.m[10]);var i=t.subtract(this.position);i.x>=0?this.rotation.y=-Math.atan(i.z/i.x)+Math.PI/2:this.rotation.y=-Math.atan(i.z/i.x)-Math.PI/2,this.rotation.z=0,isNaN(this.rotation.x)&&(this.rotation.x=0),isNaN(this.rotation.y)&&(this.rotation.y=0),isNaN(this.rotation.z)&&(this.rotation.z=0),this.rotationQuaternion&&e.Quaternion.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,this.rotationQuaternion)},i.prototype.getTarget=function(){return this._currentTarget},i.prototype._decideIfNeedsToMove=function(){return Math.abs(this.cameraDirection.x)>0||Math.abs(this.cameraDirection.y)>0||Math.abs(this.cameraDirection.z)>0},i.prototype._updatePosition=function(){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)},i.prototype._checkInputs=function(){var i=this._decideIfNeedsToMove(),r=Math.abs(this.cameraRotation.x)>0||Math.abs(this.cameraRotation.y)>0;if(i&&this._updatePosition(),r){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)}}i&&(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)),r&&(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)},i.prototype._updateCameraRotationMatrix=function(){this.rotationQuaternion?(this.rotationQuaternion.toRotationMatrix(this._cameraRotationMatrix),e.Vector3.TransformNormalToRef(this._defaultUpVector,this._cameraRotationMatrix,this.upVector)):e.Matrix.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,this._cameraRotationMatrix)},i.prototype._getViewMatrix=function(){return this.lockedTarget?this._currentTarget.copyFrom(this._getLockedTargetPosition()):(this._updateCameraRotationMatrix(),e.Vector3.TransformCoordinatesToRef(this._referencePoint,this._cameraRotationMatrix,this._transformedReferencePoint),this.position.addToRef(this._transformedReferencePoint,this._currentTarget)),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},i.prototype.createRigCamera=function(t,r){if(this.cameraRigMode!==e.Camera.RIG_MODE_NONE){var n=new i(t,this.position.clone(),this.getScene());return this.cameraRigMode!==e.Camera.RIG_MODE_VR&&this.cameraRigMode!==e.Camera.RIG_MODE_WEBVR||(this.rotationQuaternion||(this.rotationQuaternion=new e.Quaternion),n._cameraRigParams={},n.rotationQuaternion=new e.Quaternion),n}return null},i.prototype._updateRigCameras=function(){var i=this._rigCameras[0],r=this._rigCameras[1];switch(this.cameraRigMode){case e.Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:case e.Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER:var n=this.cameraRigMode===e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED?1:-1,s=this.cameraRigMode===e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED?-1:1;this._getRigCamPosition(this._cameraRigParams.stereoHalfAngle*n,i.position),this._getRigCamPosition(this._cameraRigParams.stereoHalfAngle*s,r.position),i.setTarget(this.getTarget()),r.setTarget(this.getTarget());break;case e.Camera.RIG_MODE_VR:i.rotationQuaternion?(i.rotationQuaternion.copyFrom(this.rotationQuaternion),r.rotationQuaternion.copyFrom(this.rotationQuaternion)):(i.rotation.copyFrom(this.rotation),r.rotation.copyFrom(this.rotation)),i.position.copyFrom(this.position),r.position.copyFrom(this.position)}t.prototype._updateRigCameras.call(this)},i.prototype._getRigCamPosition=function(t,i){this._rigCamTransformMatrix||(this._rigCamTransformMatrix=new e.Matrix);var r=this.getTarget();e.Matrix.Translation(-r.x,-r.y,-r.z).multiplyToRef(e.Matrix.RotationY(t),this._rigCamTransformMatrix),this._rigCamTransformMatrix=this._rigCamTransformMatrix.multiply(e.Matrix.Translation(r.x,r.y,r.z)),e.Vector3.TransformCoordinatesToRef(this.position,this._rigCamTransformMatrix,i)},i.prototype.getClassName=function(){return"TargetCamera"},i})(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,i){var r=this;t.tabIndex=1,this._onKeyDown=function(e){if(-1!==r.keysUp.indexOf(e.keyCode)||-1!==r.keysDown.indexOf(e.keyCode)||-1!==r.keysLeft.indexOf(e.keyCode)||-1!==r.keysRight.indexOf(e.keyCode)){-1===r._keys.indexOf(e.keyCode)&&r._keys.push(e.keyCode),e.preventDefault&&(i||e.preventDefault())}},this._onKeyUp=function(e){if(-1!==r.keysUp.indexOf(e.keyCode)||-1!==r.keysDown.indexOf(e.keyCode)||-1!==r.keysLeft.indexOf(e.keyCode)||-1!==r.keysRight.indexOf(e.keyCode)){var t=r._keys.indexOf(e.keyCode);t>=0&&r._keys.splice(t,1),e.preventDefault&&(i||e.preventDefault())}},this._onLostFocus=function(){r._keys=[]},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 i=this._keys[t];-1!==this.keysLeft.indexOf(i)?e.inertialAlphaOffset-=.01:-1!==this.keysUp.indexOf(i)?e.inertialBetaOffset-=.01:-1!==this.keysRight.indexOf(i)?e.inertialAlphaOffset+=.01:-1!==this.keysDown.indexOf(i)&&(e.inertialBetaOffset+=.01)}},t.prototype.getTypeName=function(){return"ArcRotateCameraKeyboardMoveInput"},t.prototype.getSimpleName=function(){return"keyboard"},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,i){var r=this;this._wheel=function(t,n){if(t.type===e.PointerEventTypes.POINTERWHEEL){var s=t.event,o=0;s.wheelDelta?o=s.wheelDelta/(40*r.wheelPrecision):s.detail&&(o=-s.detail/r.wheelPrecision),o&&(r.camera.inertialRadiusOffset+=o),s.preventDefault&&(i||s.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,i){var r,n,s,o=this,a=this.camera.getEngine(),h=0;this._pointerInput=function(a,u){var c=a.event;if(a.type===e.PointerEventTypes.POINTERMOVE||-1!==o.buttons.indexOf(c.button))if(a.type===e.PointerEventTypes.POINTERDOWN){try{c.srcElement.setPointerCapture(c.pointerId)}catch(e){}o._isPanClick=c.button===o.camera._panningMouseButton,r={x:c.clientX,y:c.clientY,pointerId:c.pointerId,type:c.pointerType},void 0===n?n=r:void 0===s&&(s=r),i||(c.preventDefault(),t.focus())}else if(a.type===e.PointerEventTypes.POINTERUP){try{c.srcElement.releasePointerCapture(c.pointerId)}catch(e){}r=null,h=0,n=s=void 0,i||c.preventDefault()}else if(a.type===e.PointerEventTypes.POINTERMOVE)if(i||c.preventDefault(),n&&void 0===s){if(0!==o.panningSensibility&&(c.ctrlKey&&o.camera._useCtrlForPanning||!o.camera._useCtrlForPanning&&o._isPanClick))o.camera.inertialPanningX+=-(c.clientX-r.x)/o.panningSensibility,o.camera.inertialPanningY+=(c.clientY-r.y)/o.panningSensibility;else{var l=c.clientX-r.x,f=c.clientY-r.y;o.camera.inertialAlphaOffset-=l/o.angularSensibilityX,o.camera.inertialBetaOffset-=f/o.angularSensibilityY}r.x=c.clientX,r.y=c.clientY}else if(n&&s){var d=n.pointerId===c.pointerId?n:s;d.x=c.clientX,d.y=c.clientY;var p=o.pinchInwards?1:-1,_=n.x-s.x,m=n.y-s.y,g=_*_+m*m;if(0===h)return void(h=g);g!==h&&(o.camera.inertialRadiusOffset+=(g-h)/(o.pinchPrecision*((o.angularSensibilityX+o.angularSensibilityY)/2)*p),h=g)}},this._observer=this.camera.getScene().onPointerObservable.add(this._pointerInput,e.PointerEventTypes.POINTERDOWN|e.PointerEventTypes.POINTERUP|e.PointerEventTypes.POINTERMOVE),this._onContextMenu=function(e){e.preventDefault()},this.camera._useCtrlForPanning||t.addEventListener("contextmenu",this._onContextMenu,!1),this._onLostFocus=function(){n=s=void 0,h=0,r=null},this._onMouseMove=function(e){if(a.isPointerLock){var t=e.movementX||e.mozMovementX||e.webkitMovementX||e.msMovementX||0,r=e.movementY||e.mozMovementY||e.webkitMovementY||e.msMovementY||0;o.camera.inertialAlphaOffset-=t/o.angularSensibilityX,o.camera.inertialBetaOffset-=r/o.angularSensibilityY,i||e.preventDefault()}},this._onGestureStart=function(e){void 0!==window.MSGesture&&(o._MSGestureHandler||(o._MSGestureHandler=new MSGesture,o._MSGestureHandler.target=t),o._MSGestureHandler.addPointer(e.pointerId))},this._onGesture=function(e){o.camera.radius*=e.scale,e.preventDefault&&(i||(e.stopPropagation(),e.preventDefault()))},t.addEventListener("mousemove",this._onMouseMove,!1),t.addEventListener("MSPointerDown",this._onGestureStart,!1),t.addEventListener("MSGestureChange",this._onGesture,!1),e.Tools.RegisterTopRootEvents([{name:"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 i(i,r,n,s,o,a){var h=t.call(this,i,e.Vector3.Zero(),a)||this;return h.inertialAlphaOffset=0,h.inertialBetaOffset=0,h.inertialRadiusOffset=0,h.lowerAlphaLimit=null,h.upperAlphaLimit=null,h.lowerBetaLimit=.01,h.upperBetaLimit=Math.PI,h.lowerRadiusLimit=null,h.upperRadiusLimit=null,h.inertialPanningX=0,h.inertialPanningY=0,h.zoomOnFactor=1,h.targetScreenOffset=e.Vector2.Zero(),h.allowUpsideDown=!0,h._viewMatrix=new e.Matrix,h.panningAxis=new e.Vector3(1,1,0),h.checkCollisions=!1,h.collisionRadius=new e.Vector3(.5,.5,.5),h._previousPosition=e.Vector3.Zero(),h._collisionVelocity=e.Vector3.Zero(),h._newPosition=e.Vector3.Zero(),h._onCollisionPositionChange=function(t,i,r){void 0===r&&(r=null),h.getScene().workerCollisions&&h.checkCollisions&&i.multiplyInPlace(h._collider.radius),r?(h.setPosition(i),h.onCollide&&h.onCollide(r)):h._previousPosition.copyFrom(h.position);var n=Math.cos(h.alpha),s=Math.sin(h.alpha),o=Math.cos(h.beta),a=Math.sin(h.beta);0===a&&(a=1e-4);var u=h._getTargetPosition();u.addToRef(new e.Vector3(h.radius*n*a,h.radius*o,h.radius*s*a),h._newPosition),h.position.copyFrom(h._newPosition);var c=h.upVector;h.allowUpsideDown&&h.beta<0&&(c=c.clone(),c=c.negate()),e.Matrix.LookAtLHToRef(h.position,u,c,h._viewMatrix),h._viewMatrix.m[12]+=h.targetScreenOffset.x,h._viewMatrix.m[13]+=h.targetScreenOffset.y,h._collisionTriggered=!1},h._target=e.Vector3.Zero(),o&&h.setTarget(o),h.alpha=r,h.beta=n,h.radius=s,h.getViewMatrix(),h.inputs=new e.ArcRotateCameraInputsManager(h),h.inputs.addKeyboard().addMouseWheel().addPointers(),h}return __extends(i,t),Object.defineProperty(i.prototype,"target",{get:function(){return this._target},set:function(e){this.setTarget(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"angularSensibilityX",{get:function(){var e=this.inputs.attached.pointers;if(e)return e.angularSensibilityX},set:function(e){var t=this.inputs.attached.pointers;t&&(t.angularSensibilityX=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"angularSensibilityY",{get:function(){var e=this.inputs.attached.pointers;if(e)return e.angularSensibilityY},set:function(e){var t=this.inputs.attached.pointers;t&&(t.angularSensibilityY=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"pinchPrecision",{get:function(){var e=this.inputs.attached.pointers;if(e)return e.pinchPrecision},set:function(e){var t=this.inputs.attached.pointers;t&&(t.pinchPrecision=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"panningSensibility",{get:function(){var e=this.inputs.attached.pointers;if(e)return e.panningSensibility},set:function(e){var t=this.inputs.attached.pointers;t&&(t.panningSensibility=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"keysUp",{get:function(){var e=this.inputs.attached.keyboard;if(e)return e.keysUp},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysUp=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"keysDown",{get:function(){var e=this.inputs.attached.keyboard;if(e)return e.keysDown},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysDown=e)},enumerable:!0,configurable:!0}),
  18. Object.defineProperty(i.prototype,"keysLeft",{get:function(){var e=this.inputs.attached.keyboard;if(e)return e.keysLeft},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysLeft=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"keysRight",{get:function(){var e=this.inputs.attached.keyboard;if(e)return e.keysRight},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysRight=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"wheelPrecision",{get:function(){var e=this.inputs.attached.mousewheel;if(e)return e.wheelPrecision},set:function(e){var t=this.inputs.attached.mousewheel;t&&(t.wheelPrecision=e)},enumerable:!0,configurable:!0}),i.prototype._initCache=function(){t.prototype._initCache.call(this),this._cache._target=new e.Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.alpha=void 0,this._cache.beta=void 0,this._cache.radius=void 0,this._cache.targetScreenOffset=e.Vector2.Zero()},i.prototype._updateCache=function(e){e||t.prototype._updateCache.call(this),this._cache._target.copyFrom(this._getTargetPosition()),this._cache.alpha=this.alpha,this._cache.beta=this.beta,this._cache.radius=this.radius,this._cache.targetScreenOffset.copyFrom(this.targetScreenOffset)},i.prototype._getTargetPosition=function(){if(this._targetHost&&this._targetHost.getAbsolutePosition){var e=this._targetHost.getAbsolutePosition();this._targetBoundingCenter?e.addToRef(this._targetBoundingCenter,this._target):this._target.copyFrom(e)}return this._target},i.prototype._isSynchronizedViewMatrix=function(){return!!t.prototype._isSynchronizedViewMatrix.call(this)&&(this._cache._target.equals(this._target)&&this._cache.alpha===this.alpha&&this._cache.beta===this.beta&&this._cache.radius===this.radius&&this._cache.targetScreenOffset.equals(this.targetScreenOffset))},i.prototype.attachControl=function(e,t,i,r){var n=this;void 0===i&&(i=!0),void 0===r&&(r=2),this._useCtrlForPanning=i,this._panningMouseButton=r,this.inputs.attachElement(e,t),this._reset=function(){n.inertialAlphaOffset=0,n.inertialBetaOffset=0,n.inertialRadiusOffset=0}},i.prototype.detachControl=function(e){this.inputs.detachElement(e),this._reset&&this._reset()},i.prototype._checkInputs=function(){this._collisionTriggered||(this.inputs.checkInputs(),0===this.inertialAlphaOffset&&0===this.inertialBetaOffset&&0===this.inertialRadiusOffset||(this.getScene().useRightHandedSystem?this.alpha-=this.beta<=0?-this.inertialAlphaOffset:this.inertialAlphaOffset:this.alpha+=this.beta<=0?-this.inertialAlphaOffset:this.inertialAlphaOffset,this.beta+=this.inertialBetaOffset,this.radius-=this.inertialRadiusOffset,this.inertialAlphaOffset*=this.inertia,this.inertialBetaOffset*=this.inertia,this.inertialRadiusOffset*=this.inertia,Math.abs(this.inertialAlphaOffset)<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.inertia,this.inertialPanningY*=this.inertia,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))},i.prototype._checkLimits=function(){null===this.lowerBetaLimit||void 0===this.lowerBetaLimit?this.allowUpsideDown&&this.beta>Math.PI&&(this.beta=this.beta-2*Math.PI):this.beta<this.lowerBetaLimit&&(this.beta=this.lowerBetaLimit),null===this.upperBetaLimit||void 0===this.upperBetaLimit?this.allowUpsideDown&&this.beta<-Math.PI&&(this.beta=this.beta+2*Math.PI):this.beta>this.upperBetaLimit&&(this.beta=this.upperBetaLimit),this.lowerAlphaLimit&&this.alpha<this.lowerAlphaLimit&&(this.alpha=this.lowerAlphaLimit),this.upperAlphaLimit&&this.alpha>this.upperAlphaLimit&&(this.alpha=this.upperAlphaLimit),this.lowerRadiusLimit&&this.radius<this.lowerRadiusLimit&&(this.radius=this.lowerRadiusLimit),this.upperRadiusLimit&&this.radius>this.upperRadiusLimit&&(this.radius=this.upperRadiusLimit)},i.prototype.rebuildAnglesAndRadius=function(){var e=this.position.subtract(this._getTargetPosition());this.radius=e.length(),this.alpha=Math.acos(e.x/Math.sqrt(Math.pow(e.x,2)+Math.pow(e.z,2))),e.z<0&&(this.alpha=2*Math.PI-this.alpha),this.beta=Math.acos(e.y/this.radius),this._checkLimits()},i.prototype.setPosition=function(e){this.position.equals(e)||(this.position.copyFrom(e),this.rebuildAnglesAndRadius())},i.prototype.setTarget=function(e,t,i){if(void 0===t&&(t=!1),void 0===i&&(i=!1),e.getBoundingInfo)this._targetBoundingCenter=t?e.getBoundingInfo().boundingBox.centerWorld.clone():null,this._targetHost=e,this._target=this._getTargetPosition();else{var r=e,n=this._getTargetPosition();if(n&&!i&&n.equals(r))return;this._target=r,this._targetBoundingCenter=null}this.rebuildAnglesAndRadius()},i.prototype._getViewMatrix=function(){var t=Math.cos(this.alpha),i=Math.sin(this.alpha),r=Math.cos(this.beta),n=Math.sin(this.beta);0===n&&(n=1e-4);var s=this._getTargetPosition();if(s.addToRef(new e.Vector3(this.radius*t*n,this.radius*r,this.radius*i*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 o=this.upVector;this.allowUpsideDown&&n<0&&(o=o.clone(),o=o.negate()),this.getScene().useRightHandedSystem?e.Matrix.LookAtRHToRef(this.position,s,o,this._viewMatrix):e.Matrix.LookAtLHToRef(this.position,s,o,this._viewMatrix),this._viewMatrix.m[12]+=this.targetScreenOffset.x,this._viewMatrix.m[13]+=this.targetScreenOffset.y}return this._currentTarget=s,this._viewMatrix},i.prototype.zoomOn=function(t,i){void 0===i&&(i=!1),t=t||this.getScene().meshes;var r=e.Mesh.MinMax(t),n=e.Vector3.Distance(r.min,r.max);this.radius=n*this.zoomOnFactor,this.focusOn({min:r.min,max:r.max,distance:n},i)},i.prototype.focusOn=function(t,i){void 0===i&&(i=!1);var r,n;void 0===t.min?(r=t||this.getScene().meshes,r=e.Mesh.MinMax(r),n=e.Vector3.Distance(r.min,r.max)):(r=t,n=t.distance),this._target=e.Mesh.Center(r),i||(this.maxZ=2*n)},i.prototype.createRigCamera=function(t,r){var n;switch(this.cameraRigMode){case e.Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case e.Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER:case e.Camera.RIG_MODE_VR:n=this._cameraRigParams.stereoHalfAngle*(0===r?1:-1);break;case e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:n=this._cameraRigParams.stereoHalfAngle*(0===r?-1:1)}var s=new i(t,this.alpha+n,this.beta,this.radius,this._target,this.getScene());return s._cameraRigParams={},s},i.prototype._updateRigCameras=function(){var i=this._rigCameras[0],r=this._rigCameras[1];switch(i.beta=r.beta=this.beta,i.radius=r.radius=this.radius,this.cameraRigMode){case e.Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case e.Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER:case e.Camera.RIG_MODE_VR:i.alpha=this.alpha-this._cameraRigParams.stereoHalfAngle,r.alpha=this.alpha+this._cameraRigParams.stereoHalfAngle;break;case e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:i.alpha=this.alpha+this._cameraRigParams.stereoHalfAngle,r.alpha=this.alpha-this._cameraRigParams.stereoHalfAngle}t.prototype._updateRigCameras.call(this)},i.prototype.dispose=function(){this.inputs.clear(),t.prototype.dispose.call(this)},i.prototype.getClassName=function(){return"ArcRotateCamera"},i})(e.TargetCamera);__decorate([e.serialize()],t.prototype,"alpha",void 0),__decorate([e.serialize()],t.prototype,"beta",void 0),__decorate([e.serialize()],t.prototype,"radius",void 0),__decorate([e.serializeAsVector3("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,"zoomOnFactor",void 0),__decorate([e.serialize()],t.prototype,"allowUpsideDown",void 0),e.ArcRotateCamera=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(e){return t.call(this,e)||this}return __extends(i,t),i.prototype.addMouseWheel=function(){return this.add(new e.ArcRotateCameraMouseWheelInput),this},i.prototype.addPointers=function(){return this.add(new e.ArcRotateCameraPointersInput),this},i.prototype.addKeyboard=function(){return this.add(new e.ArcRotateCameraKeyboardMoveInput),this},i.prototype.addGamepad=function(){return this.add(new e.ArcRotateCameraGamepadInput),this},i.prototype.addVRDeviceOrientation=function(){return this.add(new e.ArcRotateCameraVRDeviceOrientationInput),this},i})(e.CameraInputsManager);e.ArcRotateCameraInputsManager=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,s,o,a,h,u){void 0===a&&(a=null),void 0===h&&(h=null),void 0===u&&(u=e.Engine.TEXTUREFORMAT_RGBA);var c=t.call(this,r)||this;if(c.coordinatesMode=e.Texture.CUBIC_MODE,c.name=i,c.url=i,c._noMipmap=s,c.hasAlpha=!1,c._format=u,!i&&!o)return c;if(c._texture=c._getFromCache(i,s),!o){n||(n=["_px.jpg","_py.jpg","_pz.jpg","_nx.jpg","_ny.jpg","_nz.jpg"]),o=[];for(var l=0;l<n.length;l++)o.push(i+n[l]);c._extensions=n}return c._files=o,c._texture?a&&(c._texture.isReady?e.Tools.SetImmediate((function(){return a()})):c._texture.onLoadedCallbacks.push(a)):r.useDelayedTextureLoading?c.delayLoadState=e.Engine.DELAYLOADSTATE_NOTLOADED:c._texture=r.getEngine().createCubeTexture(i,r,o,s,a,h,c._format),c.isCube=!0,c._textureMatrix=e.Matrix.Identity(),c}return __extends(i,t),i.CreateFromImages=function(e,t,r){return new i("",t,null,r,e)},i.prototype.delayLoad=function(){this.delayLoadState===e.Engine.DELAYLOADSTATE_NOTLOADED&&(this.delayLoadState=e.Engine.DELAYLOADSTATE_LOADED,this._texture=this._getFromCache(this.url,this._noMipmap),this._texture||(this._texture=this.getScene().getEngine().createCubeTexture(this.url,this.getScene(),this._files,this._noMipmap,void 0,void 0,this._format)))},i.prototype.getReflectionTextureMatrix=function(){return this._textureMatrix},i.Parse=function(t,i,r){var n=e.SerializationHelper.Parse((function(){return new e.CubeTexture(r+t.name,i,t.extensions)}),t,i);if(t.animations)for(var s=0;s<t.animations.length;s++){var o=t.animations[s];n.animations.push(e.Animation.Parse(o))}return n},i.prototype.clone=function(){var t=this;return e.SerializationHelper.Clone((function(){return new i(t.url,t.getScene(),t._extensions,t._noMipmap,t._files)}),this)},i})(e.BaseTexture);e.CubeTexture=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,s,o,a,h,u,c,l){void 0===o&&(o=!0),void 0===a&&(a=e.Engine.TEXTURETYPE_UNSIGNED_INT),void 0===h&&(h=!1),void 0===u&&(u=e.Texture.TRILINEAR_SAMPLINGMODE),void 0===c&&(c=!0),void 0===l&&(l=!1);var f=t.call(this,null,n,!s)||this;return f.isCube=h,f.renderList=new Array,f.renderParticles=!0,f.renderSprites=!1,f.coordinatesMode=e.Texture.PROJECTION_MODE,f.onAfterUnbindObservable=new e.Observable,f.onBeforeRenderObservable=new e.Observable,f.onAfterRenderObservable=new e.Observable,f.onClearObservable=new e.Observable,f._currentRefreshId=-1,f._refreshRate=1,f._samples=1,f.name=i,f.isRenderTarget=!0,f._size=r,f._generateMipMaps=s,f._doNotChangeAspectRatio=o,f._renderTargetOptions={generateMipMaps:s,type:a,samplingMode:u,generateDepthBuffer:c,generateStencilBuffer:l},u===e.Texture.NEAREST_SAMPLINGMODE&&(f.wrapU=e.Texture.CLAMP_ADDRESSMODE,f.wrapV=e.Texture.CLAMP_ADDRESSMODE),h?(f._texture=n.getEngine().createRenderTargetCubeTexture(r,f._renderTargetOptions),f.coordinatesMode=e.Texture.INVCUBIC_MODE,f._textureMatrix=e.Matrix.Identity()):f._texture=n.getEngine().createRenderTargetTexture(r,f._renderTargetOptions),f._renderingManager=new e.RenderingManager(n),f}return __extends(i,t),Object.defineProperty(i,"REFRESHRATE_RENDER_ONCE",{get:function(){return i._REFRESHRATE_RENDER_ONCE},enumerable:!0,configurable:!0}),Object.defineProperty(i,"REFRESHRATE_RENDER_ONEVERYFRAME",{get:function(){return i._REFRESHRATE_RENDER_ONEVERYFRAME},enumerable:!0,configurable:!0}),Object.defineProperty(i,"REFRESHRATE_RENDER_ONEVERYTWOFRAMES",{get:function(){return i._REFRESHRATE_RENDER_ONEVERYTWOFRAMES},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"onAfterUnbind",{set:function(e){this._onAfterUnbindObserver&&this.onAfterUnbindObservable.remove(this._onAfterUnbindObserver),this._onAfterUnbindObserver=this.onAfterUnbindObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"onBeforeRender",{set:function(e){this._onBeforeRenderObserver&&this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),this._onBeforeRenderObserver=this.onBeforeRenderObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"onAfterRender",{set:function(e){this._onAfterRenderObserver&&this.onAfterRenderObservable.remove(this._onAfterRenderObserver),this._onAfterRenderObserver=this.onAfterRenderObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"onClear",{set:function(e){this._onClearObserver&&this.onClearObservable.remove(this._onClearObserver),this._onClearObserver=this.onClearObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"renderTargetOptions",{get:function(){return this._renderTargetOptions},enumerable:!0,configurable:!0}),Object.defineProperty(i.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}),i.prototype.resetRefreshCounter=function(){this._currentRefreshId=-1},Object.defineProperty(i.prototype,"refreshRate",{get:function(){return this._refreshRate},set:function(e){this._refreshRate=e,this.resetRefreshCounter()},enumerable:!0,configurable:!0}),i.prototype._shouldRender=function(){return-1===this._currentRefreshId?(this._currentRefreshId=1,!0):this.refreshRate===this._currentRefreshId?(this._currentRefreshId=1,!0):(this._currentRefreshId++,!1)},i.prototype.isReady=function(){return!!this.getScene().renderTargetsEnabled&&t.prototype.isReady.call(this)},i.prototype.getRenderSize=function(){return this._size},Object.defineProperty(i.prototype,"canRescale",{get:function(){return!0},enumerable:!0,configurable:!0}),i.prototype.scale=function(e){var t=this._size*e;this.resize(t)},i.prototype.getReflectionTextureMatrix=function(){return this.isCube?this._textureMatrix:t.prototype.getReflectionTextureMatrix.call(this)},i.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)},i.prototype.render=function(e,t){var i=this.getScene(),r=i.getEngine();if(void 0!==this.useCameraPostProcesses&&(e=this.useCameraPostProcesses),this._waitingRenderList){this.renderList=[];for(var n=0;n<this._waitingRenderList.length;n++){var s=this._waitingRenderList[n];this.renderList.push(i.getMeshByID(s))}delete this._waitingRenderList}if(this.renderListPredicate){this.renderList.splice(0);for(var o=this.getScene().meshes,n=0;n<o.length;n++){var a=o[n];this.renderListPredicate(a)&&this.renderList.push(a)}}if(!this.renderList||0!==this.renderList.length){this.activeCamera?(r.setViewport(this.activeCamera.viewport),this.activeCamera!==i.activeCamera&&i.setTransformMatrix(this.activeCamera.getViewMatrix(),this.activeCamera.getProjectionMatrix(!0))):r.setViewport(i.activeCamera.viewport),this._renderingManager.reset();for(var h=this.renderList?this.renderList:i.getActiveMeshes().data,u=this.renderList?this.renderList.length:i.getActiveMeshes().length,c=i.getRenderId(),l=0;l<u;l++){var a=h[l];if(a){if(!a.isReady()){this.resetRefreshCounter();continue}if(a._preActivateForIntermediateRendering(c),a.isEnabled()&&a.isVisible&&a.subMeshes&&0!=(a.layerMask&i.activeCamera.layerMask)){a._activate(c);for(var f=0;f<a.subMeshes.length;f++){var d=a.subMeshes[f];i._activeIndices.addCount(d.indexCount,!1),this._renderingManager.dispatch(d)}}}}for(var p=0;p<i.particleSystems.length;p++){var _=i.particleSystems[p];_.isStarted()&&_.emitter&&_.emitter.position&&_.emitter.isEnabled()&&(h.indexOf(_.emitter)>=0&&this._renderingManager.dispatchParticles(_))}if(this.isCube)for(var m=0;m<6;m++)this.renderToTarget(m,h,u,e,t),i.incrementRenderId(),i.resetCachedMaterial();else this.renderToTarget(0,h,u,e,t);this.onAfterUnbindObservable.notifyObservers(this),this.activeCamera&&this.activeCamera!==i.activeCamera&&i.setTransformMatrix(i.activeCamera.getViewMatrix(),i.activeCamera.getProjectionMatrix(!0)),r.setViewport(i.activeCamera.viewport),i.resetCachedMaterial()}},i.prototype.renderToTarget=function(t,i,r,n,s){var o=this,a=this.getScene(),h=a.getEngine();n&&a.postProcessManager._prepareFrame(this._texture)||(this.isCube?h.bindFramebuffer(this._texture,t):h.bindFramebuffer(this._texture)),this.onBeforeRenderObservable.notifyObservers(t),this.onClearObservable.hasObservers()?this.onClearObservable.notifyObservers(h):h.clear(a.clearColor,!0,!0,!0),this._doNotChangeAspectRatio||a.updateTransformMatrix(!0),this._renderingManager.render(this.customRenderFunction,i,this.renderParticles,this.renderSprites),n&&a.postProcessManager._finalizeFrame(!1,this._texture,t),this._doNotChangeAspectRatio||a.updateTransformMatrix(!0),s&&e.Tools.DumpFramebuffer(this._size,this._size,h),this.isCube&&5!==t?this.onAfterRenderObservable.notifyObservers(t):(this.isCube&&5===t&&h.generateMipMapsForCubemap(this._texture),h.unBindFramebuffer(this._texture,this.isCube,(function(){o.onAfterRenderObservable.notifyObservers(t)})))},i.prototype.setRenderingOrder=function(e,t,i,r){void 0===t&&(t=null),void 0===i&&(i=null),void 0===r&&(r=null),this._renderingManager.setRenderingOrder(e,t,i,r)},i.prototype.setRenderingAutoClearDepthStencil=function(e,t){this._renderingManager.setRenderingAutoClearDepthStencil(e,t)},i.prototype.clone=function(){var e=this.getSize(),t=new i(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},i.prototype.serialize=function(){if(!this.name)return null;var e=t.prototype.serialize.call(this);e.renderTargetSize=this.getRenderSize(),e.renderList=[];for(var i=0;i<this.renderList.length;i++)e.renderList.push(this.renderList[i].id);return e},i})(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 i(i,r,n,s,o,a,h){void 0===o&&(o=e.Engine.TEXTURETYPE_UNSIGNED_INT),void 0===a&&(a=e.Texture.BILINEAR_SAMPLINGMODE),void 0===h&&(h=!0);var u=t.call(this,i,r,n,s,!0,o,!1,a,h)||this;return u.mirrorPlane=new e.Plane(0,1,0,1),u._transformMatrix=e.Matrix.Zero(),u._mirrorMatrix=e.Matrix.Zero(),u.onBeforeRenderObservable.add((function(){e.Matrix.ReflectionToRef(u.mirrorPlane,u._mirrorMatrix),u._savedViewMatrix=n.getViewMatrix(),u._mirrorMatrix.multiplyToRef(u._savedViewMatrix,u._transformMatrix),n.setTransformMatrix(u._transformMatrix,n.getProjectionMatrix()),n.clipPlane=u.mirrorPlane,n.getEngine().cullBackFaces=!1,n._mirroredCameraPosition=e.Vector3.TransformCoordinates(n.activeCamera.position,u._mirrorMatrix)})),u.onAfterRenderObservable.add((function(){n.setTransformMatrix(u._savedViewMatrix,n.getProjectionMatrix()),n.getEngine().cullBackFaces=!0,n._mirroredCameraPosition=null,delete n.clipPlane})),u}return __extends(i,t),i.prototype.clone=function(){var e=this.getSize(),t=new i(this.name,e.width,this.getScene(),this._renderTargetOptions.generateMipMaps,this._renderTargetOptions.type,this._renderTargetOptions.samplingMode,this._renderTargetOptions.generateDepthBuffer);return t.hasAlpha=this.hasAlpha,t.level=this.level,t.mirrorPlane=this.mirrorPlane.clone(),t.renderList=this.renderList.slice(0),t},i.prototype.serialize=function(){if(!this.name)return null;var e=t.prototype.serialize.call(this);return e.mirrorPlane=this.mirrorPlane.asArray(),e},i})(e.RenderTargetTexture);e.MirrorTexture=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,s){var o=t.call(this,i,r,n,s,!0)||this;return o.refractionPlane=new e.Plane(0,1,0,1),o.depth=2,o.onBeforeRenderObservable.add((function(){n.clipPlane=o.refractionPlane})),o.onAfterRenderObservable.add((function(){delete n.clipPlane})),o}return __extends(i,t),i.prototype.clone=function(){var e=this.getSize(),t=new i(this.name,e.width,this.getScene(),this._generateMipMaps);return t.hasAlpha=this.hasAlpha,t.level=this.level,t.refractionPlane=this.refractionPlane.clone(),t.renderList=this.renderList.slice(0),t.depth=this.depth,t},i.prototype.serialize=function(){if(!this.name)return null;var e=t.prototype.serialize.call(this);return e.mirrorPlane=this.refractionPlane.asArray(),e.depth=this.depth,e},i})(e.RenderTargetTexture);e.RefractionTexture=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,s,o,a){void 0===o&&(o=e.Texture.TRILINEAR_SAMPLINGMODE),void 0===a&&(a=e.Engine.TEXTUREFORMAT_RGBA);var h=t.call(this,null,n,!s,void 0,o,void 0,void 0,void 0,void 0,a)||this;h.name=i;var u=h.getScene().getEngine();h.wrapU=e.Texture.CLAMP_ADDRESSMODE,h.wrapV=e.Texture.CLAMP_ADDRESSMODE,h._generateMipMaps=s,r.getContext?(h._canvas=r,h._texture=u.createDynamicTexture(r.width,r.height,s,o)):(h._canvas=document.createElement("canvas"),r.width?h._texture=u.createDynamicTexture(r.width,r.height,s,o):h._texture=u.createDynamicTexture(r,r,s,o));var c=h.getSize();return h._canvas.width=c.width,h._canvas.height=c.height,h._context=h._canvas.getContext("2d"),h}return __extends(i,t),Object.defineProperty(i.prototype,"canRescale",{get:function(){return!0},enumerable:!0,configurable:!0}),i.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)},i.prototype.scale=function(e){var t=this.getSize();t.width*=e,t.height*=e,this._recreate(t)},i.prototype.scaleTo=function(e,t){var i=this.getSize();i.width=e,i.height=t,this._recreate(i)},i.prototype.getContext=function(){return this._context},i.prototype.clear=function(){var e=this.getSize();this._context.fillRect(0,0,e.width,e.height)},i.prototype.update=function(e){this.getScene().getEngine().updateDynamicTexture(this._texture,this._canvas,void 0===e||e,void 0,this._format)},i.prototype.drawText=function(e,t,i,r,n,s,o,a){void 0===a&&(a=!0);var h=this.getSize();if(s&&(this._context.fillStyle=s,this._context.fillRect(0,0,h.width,h.height)),this._context.font=r,null===t||void 0===t){var u=this._context.measureText(e);t=(h.width-u.width)/2}if(null===i||void 0===i){var c=parseInt(r.replace(/\D/g,""));i=h.height/2+c/3.65}this._context.fillStyle=n,this._context.fillText(e,t,i),a&&this.update(o)},i.prototype.clone=function(){var e=this.getSize(),t=new i(this.name,e,this.getScene(),this._generateMipMaps);return t.hasAlpha=this.hasAlpha,t.level=this.level,t.wrapU=this.wrapU,t.wrapV=this.wrapV,t},i})(e.Texture);e.DynamicTexture=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,s,o,a){void 0===s&&(s=!1),void 0===o&&(o=!1),void 0===a&&(a=e.Texture.TRILINEAR_SAMPLINGMODE);var h=t.call(this,null,n,!s,o)||this;h._autoLaunch=!0;var u;return h.name=i,r instanceof HTMLVideoElement?h.video=r:(u=r,h.video=document.createElement("video"),h.video.autoplay=!1,h.video.loop=!0),h._generateMipMaps=s,h._samplingMode=a,e.Tools.IsExponentOfTwo(h.video.videoWidth)&&e.Tools.IsExponentOfTwo(h.video.videoHeight)?(h.wrapU=e.Texture.WRAP_ADDRESSMODE,h.wrapV=e.Texture.WRAP_ADDRESSMODE):(h.wrapU=e.Texture.CLAMP_ADDRESSMODE,h.wrapV=e.Texture.CLAMP_ADDRESSMODE,h._generateMipMaps=!1),u?(h.video.addEventListener("canplay",(function(){h._createTexture()})),u.forEach((function(e){var t=document.createElement("source");t.src=e,h.video.appendChild(t)}))):h._createTexture(),h._lastUpdate=e.Tools.Now,h}return __extends(i,t),i.prototype.__setTextureReady=function(){this._texture.isReady=!0},i.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)},i.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)},i.prototype.dispose=function(){t.prototype.dispose.call(this),this.video.removeEventListener("playing",this._setTextureReady)},i.CreateFromWebCam=function(t,i,r){var n,s=document.createElement("video");r&&r.deviceId&&(n={exact:r.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:r&&r.minWidth||256,max:r&&r.maxWidth||640},height:{min:r&&r.minHeight||256,max:r&&r.maxHeight||480}}},(function(r){void 0!==s.mozSrcObject?s.mozSrcObject=r:s.src=window.URL&&window.URL.createObjectURL(r)||r,s.play(),i&&i(new e.VideoTexture("video",s,t,!0,!0))}),(function(t){e.Tools.Error(t.name)}))},i})(e.Texture);e.VideoTexture=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,s,o,a,h,u){void 0===a&&(a=!0),void 0===h&&(h=!1),void 0===u&&(u=e.Texture.TRILINEAR_SAMPLINGMODE);var c=t.call(this,null,o,!a,h)||this;return c.format=s,c._texture=o.getEngine().createRawTexture(i,r,n,s,a,h,u),c.wrapU=e.Texture.CLAMP_ADDRESSMODE,c.wrapV=e.Texture.CLAMP_ADDRESSMODE,c}return __extends(i,t),i.prototype.update=function(e){this.getScene().getEngine().updateRawTexture(this._texture,e,this.format,this._invertY)},i.CreateLuminanceTexture=function(t,r,n,s,o,a,h){return void 0===o&&(o=!0),void 0===a&&(a=!1),void 0===h&&(h=e.Texture.TRILINEAR_SAMPLINGMODE),new i(t,r,n,e.Engine.TEXTUREFORMAT_LUMINANCE,s,o,a,h)},i.CreateLuminanceAlphaTexture=function(t,r,n,s,o,a,h){return void 0===o&&(o=!0),void 0===a&&(a=!1),void 0===h&&(h=e.Texture.TRILINEAR_SAMPLINGMODE),new i(t,r,n,e.Engine.TEXTUREFORMAT_LUMINANCE_ALPHA,s,o,a,h)},i.CreateAlphaTexture=function(t,r,n,s,o,a,h){return void 0===o&&(o=!0),void 0===a&&(a=!1),void 0===h&&(h=e.Texture.TRILINEAR_SAMPLINGMODE),new i(t,r,n,e.Engine.TEXTUREFORMAT_ALPHA,s,o,a,h)},i.CreateRGBTexture=function(t,r,n,s,o,a,h){return void 0===o&&(o=!0),void 0===a&&(a=!1),void 0===h&&(h=e.Texture.TRILINEAR_SAMPLINGMODE),new i(t,r,n,e.Engine.TEXTUREFORMAT_RGB,s,o,a,h)},i.CreateRGBATexture=function(t,r,n,s,o,a,h){return void 0===o&&(o=!0),void 0===a&&(a=!1),void 0===h&&(h=e.Texture.TRILINEAR_SAMPLINGMODE),new i(t,r,n,e.Engine.TEXTUREFORMAT_RGBA,s,o,a,h)},i})(e.Texture);e.RawTexture=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(t){var i=(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(i,r){if(r.length<19)return void e.Tools.Error("Unable to load TGA file - Not enough data to contain header");var n=18,s=t.GetTGAHeader(r);if(s.id_length+n>r.length)return void e.Tools.Error("Unable to load TGA file - Not enough data");n+=s.id_length;var o=!1,a=!1,h=!1;switch(s.image_type){case t._TYPE_RLE_INDEXED:o=!0;case t._TYPE_INDEXED:a=!0;break;case t._TYPE_RLE_RGB:o=!0;case t._TYPE_RGB:!0;break;case t._TYPE_RLE_GREY:o=!0;case t._TYPE_GREY:h=!0}var u,c,l=(s.flags,s.pixel_size>>3),f=s.width*s.height*l;if(a&&(c=r.subarray(n,n+=s.colormap_length*(s.colormap_size>>3))),o){u=new Uint8Array(f);for(var d,p,_,m=0,g=new Uint8Array(l);n<f&&m<f;)if(d=r[n++],p=1+(127&d),128&d){for(_=0;_<l;++_)g[_]=r[n++];for(_=0;_<p;++_)u.set(g,m+_*l);m+=l*p}else{for(p*=l,_=0;_<p;++_)u[m+_]=r[n++];m+=p}}else u=r.subarray(n,n+=a?s.width*s.height:f);var y,v,b,x,T,E;switch((s.flags&t._ORIGIN_MASK)>>t._ORIGIN_SHIFT){default:case t._ORIGIN_UL:y=0,b=1,E=s.width,v=0,x=1,T=s.height;break;case t._ORIGIN_BL:y=0,b=1,E=s.width,v=s.height-1,x=-1,T=-1;break;case t._ORIGIN_UR:y=s.width-1,b=-1,E=-1,v=0,x=1,T=s.height;break;case t._ORIGIN_BR:y=s.width-1,b=-1,E=-1,v=s.height-1,x=-1,T=-1}var A="_getImageData"+(h?"Grey":"")+s.pixel_size+"bits",M=t[A](s,c,u,v,x,T,y,b,E);i.texImage2D(i.TEXTURE_2D,0,i.RGBA,s.width,s.height,0,i.RGBA,i.UNSIGNED_BYTE,M)},t._getImageData8bits=function(e,t,i,r,n,s,o,a,h){var u,c,l,f=i,d=t,p=e.width,_=e.height,m=0,g=new Uint8Array(p*_*4);for(l=r;l!==s;l+=n)for(c=o;c!==h;c+=a,m++)u=f[m],g[4*(c+p*l)+3]=255,g[4*(c+p*l)+2]=d[3*u+0],g[4*(c+p*l)+1]=d[3*u+1],g[4*(c+p*l)+0]=d[3*u+2];return g},t._getImageData16bits=function(e,t,i,r,n,s,o,a,h){var u,c,l,f=i,d=e.width,p=e.height,_=0,m=new Uint8Array(d*p*4);for(l=r;l!==s;l+=n)for(c=o;c!==h;c+=a,_+=2)u=f[_+0]+(f[_+1]<<8),m[4*(c+d*l)+0]=(31744&u)>>7,m[4*(c+d*l)+1]=(992&u)>>2,m[4*(c+d*l)+2]=(31&u)>>3,m[4*(c+d*l)+3]=32768&u?0:255;return m},t._getImageData24bits=function(e,t,i,r,n,s,o,a,h){var u,c,l=i,f=e.width,d=e.height,p=0,_=new Uint8Array(f*d*4);for(c=r;c!==s;c+=n)for(u=o;u!==h;u+=a,p+=3)_[4*(u+f*c)+3]=255,_[4*(u+f*c)+2]=l[p+0],_[4*(u+f*c)+1]=l[p+1],_[4*(u+f*c)+0]=l[p+2];return _},t._getImageData32bits=function(e,t,i,r,n,s,o,a,h){var u,c,l=i,f=e.width,d=e.height,p=0,_=new Uint8Array(f*d*4);for(c=r;c!==s;c+=n)for(u=o;u!==h;u+=a,p+=4)_[4*(u+f*c)+2]=l[p+0],_[4*(u+f*c)+1]=l[p+1],_[4*(u+f*c)+0]=l[p+2],_[4*(u+f*c)+3]=l[p+3];return _},t._getImageDataGrey8bits=function(e,t,i,r,n,s,o,a,h){var u,c,l,f=i,d=e.width,p=e.height,_=0,m=new Uint8Array(d*p*4);for(l=r;l!==s;l+=n)for(c=o;c!==h;c+=a,_++)u=f[_],
  19. m[4*(c+d*l)+0]=u,m[4*(c+d*l)+1]=u,m[4*(c+d*l)+2]=u,m[4*(c+d*l)+3]=255;return m},t._getImageDataGrey16bits=function(e,t,i,r,n,s,o,a,h){var u,c,l=i,f=e.width,d=e.height,p=0,_=new Uint8Array(f*d*4);for(c=r;c!==s;c+=n)for(u=o;u!==h;u+=a,p+=2)_[4*(u+f*c)+0]=l[p+0],_[4*(u+f*c)+1]=l[p+0],_[4*(u+f*c)+2]=l[p+0],_[4*(u+f*c)+3]=l[p+1];return _},t})();i._TYPE_NO_DATA=0,i._TYPE_INDEXED=1,i._TYPE_RGB=2,i._TYPE_GREY=3,i._TYPE_RLE_INDEXED=9,i._TYPE_RLE_RGB=10,i._TYPE_RLE_GREY=11,i._ORIGIN_MASK=48,i._ORIGIN_SHIFT=4,i._ORIGIN_BL=0,i._ORIGIN_BR=1,i._ORIGIN_UL=2,i._ORIGIN_UR=3,t.TGATools=i})(e.Internals||(e.Internals={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(t){function i(e){return e.charCodeAt(0)+(e.charCodeAt(1)<<8)+(e.charCodeAt(2)<<16)+(e.charCodeAt(3)<<24)}function r(e){return String.fromCharCode(255&e,e>>8&255,e>>16&255,e>>24&255)}var n=i("DXT1"),s=i("DXT3"),o=i("DXT5"),a=(function(){function t(){}return t.GetDDSInfo=function(e){var t=new Int32Array(e,0,31),i=1;return 131072&t[2]&&(i=Math.max(1,t[7])),{width:t[4],height:t[3],mipmapCount:i,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,i,r,n){for(var s=new Uint8Array(r),o=new Uint8Array(n),a=0,h=t-1;h>=0;h--)for(var u=0;u<e;u++){var c=i+4*(u+h*e);s[a+2]=o[c],s[a+1]=o[c+1],s[a]=o[c+2],s[a+3]=o[c+3],a+=4}return s},t.GetRGBArrayBuffer=function(e,t,i,r,n){for(var s=new Uint8Array(r),o=new Uint8Array(n),a=0,h=t-1;h>=0;h--)for(var u=0;u<e;u++){var c=i+3*(u+h*e);s[a+2]=o[c],s[a+1]=o[c+1],s[a]=o[c+2],a+=3}return s},t.GetLuminanceArrayBuffer=function(e,t,i,r,n){for(var s=new Uint8Array(r),o=new Uint8Array(n),a=0,h=t-1;h>=0;h--)for(var u=0;u<e;u++){var c=i+(u+h*e);s[a]=o[c],a++}return s},t.UploadDDSLevels=function(i,a,h,u,c,l){var f,d,p,_,m,g,y,v,b,x,T=new Int32Array(h,0,31);if(542327876!=T[0])return void e.Tools.Error("Invalid magic number in DDS header");if(!u.isFourCC&&!u.isRGB&&!u.isLuminance)return void e.Tools.Error("Unsupported format, must contain a FourCC, RGB or LUMINANCE code");if(u.isFourCC)switch(f=T[21]){case n:d=8,p=a.COMPRESSED_RGBA_S3TC_DXT1_EXT;break;case s:d=16,p=a.COMPRESSED_RGBA_S3TC_DXT3_EXT;break;case o:d=16,p=a.COMPRESSED_RGBA_S3TC_DXT5_EXT;break;default:return void console.error("Unsupported FourCC code:",r(f))}b=1,131072&T[2]&&!1!==c&&(b=Math.max(1,T[7]));for(var E=T[22],A=0;A<l;A++){var M=1===l?i.TEXTURE_2D:i.TEXTURE_CUBE_MAP_POSITIVE_X+A;for(_=T[4],m=T[3],y=T[1]+4,x=0;x<b;++x){if(u.isRGB)24===E?(g=_*m*3,v=t.GetRGBArrayBuffer(_,m,y,g,h),i.texImage2D(M,x,i.RGB,_,m,0,i.RGB,i.UNSIGNED_BYTE,v)):(g=_*m*4,v=t.GetRGBAArrayBuffer(_,m,y,g,h),i.texImage2D(M,x,i.RGBA,_,m,0,i.RGBA,i.UNSIGNED_BYTE,v));else if(u.isLuminance){var P=i.getParameter(i.UNPACK_ALIGNMENT),O=_,R=Math.floor((_+P-1)/P)*P;g=R*(m-1)+O,v=t.GetLuminanceArrayBuffer(_,m,y,g,h),i.texImage2D(M,x,i.LUMINANCE,_,m,0,i.LUMINANCE,i.UNSIGNED_BYTE,v)}else g=Math.max(4,_)/4*Math.max(4,m)/4*d,v=new Uint8Array(h,y,g),i.compressedTexImage2D(M,x,p,_,m,0,v);y+=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 i=(function(){function t(i,r,n,s){this.arrayBuffer=i;var o=new Uint8Array(this.arrayBuffer,0,12);if(171!==o[0]||75!==o[1]||84!==o[2]||88!==o[3]||32!==o[4]||49!==o[5]||49!==o[6]||187!==o[7]||13!==o[8]||10!==o[9]||26!==o[10]||10!==o[11])return void e.Tools.Error("texture missing KTX identifier");var a=new Int32Array(this.arrayBuffer,12,13),h=16909060===a[0];return this.glType=h?this.switchEndainness(a[1]):a[1],this.glTypeSize=h?this.switchEndainness(a[2]):a[2],this.glFormat=h?this.switchEndainness(a[3]):a[3],this.glInternalFormat=h?this.switchEndainness(a[4]):a[4],this.glBaseInternalFormat=h?this.switchEndainness(a[5]):a[5],this.pixelWidth=h?this.switchEndainness(a[6]):a[6],this.pixelHeight=h?this.switchEndainness(a[7]):a[7],this.pixelDepth=h?this.switchEndainness(a[8]):a[8],this.numberOfArrayElements=h?this.switchEndainness(a[9]):a[9],this.numberOfFaces=h?this.switchEndainness(a[10]):a[10],this.numberOfMipmapLevels=h?this.switchEndainness(a[11]):a[11],this.bytesOfKeyValueData=h?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!==r?void e.Tools.Error("number of faces expected"+r+", 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,i){switch(this.loadType){case t.COMPRESSED_2D:this._upload2DCompressedLevels(e,i);break;case t.TEX_2D:case t.COMPRESSED_3D:case t.TEX_3D:}},t.prototype._upload2DCompressedLevels=function(e,i){for(var r=t.HEADER_LEN+this.bytesOfKeyValueData,n=this.pixelWidth,s=this.pixelHeight,o=i?this.numberOfMipmapLevels:1,a=0;a<o;a++){for(var h=new Int32Array(this.arrayBuffer,r,1)[0],u=0;u<this.numberOfFaces;u++){var c=1===this.numberOfFaces?e.TEXTURE_2D:e.TEXTURE_CUBE_MAP_POSITIVE_X+u,l=new Uint8Array(this.arrayBuffer,r+4,h);e.compressedTexImage2D(c,a,this.glInternalFormat,n,s,0,l),r+=h+4,r+=3-(h+3)%4}n=Math.max(1,.5*n),s=Math.max(1,.5*s)}},t})();i.HEADER_LEN=64,i.COMPRESSED_2D=0,i.COMPRESSED_3D=1,i.TEX_2D=2,i.TEX_3D=3,t.KhronosTextureContainer=i})(e.Internals||(e.Internals={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r){var n=t.call(this,i,r)||this;return n.generateOctree=!1,n._worldInverse=new e.Matrix,n}return __extends(i,t),i.prototype.getClassName=function(){return"GroundMesh"},Object.defineProperty(i.prototype,"subdivisions",{get:function(){return Math.min(this._subdivisionsX,this._subdivisionsY)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"subdivisionsX",{get:function(){return this._subdivisionsX},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"subdivisionsY",{get:function(){return this._subdivisionsY},enumerable:!0,configurable:!0}),i.prototype.optimize=function(e,t){void 0===t&&(t=32),this._subdivisionsX=e,this._subdivisionsY=e,this.subdivide(e),this.createOrUpdateSubmeshesOctree(t)},i.prototype.getHeightAtCoordinates=function(t,i){var r=this.getWorldMatrix(),n=e.Tmp.Matrix[5];r.invertToRef(n);var s=e.Tmp.Vector3[8];if(e.Vector3.TransformCoordinatesFromFloatsToRef(t,0,i,n,s),t=s.x,i=s.z,t<this._minX||t>this._maxX||i<this._minZ||i>this._maxZ)return this.position.y;this._heightQuads&&0!=this._heightQuads.length||(this._initHeightQuads(),this._computeHeightQuads());var o=this._getFacetAt(t,i),a=-(o.x*t+o.z*i+o.w)/o.y;return e.Vector3.TransformCoordinatesFromFloatsToRef(0,a,0,r,s),s.y},i.prototype.getNormalAtCoordinates=function(t,i){var r=new e.Vector3(0,1,0);return this.getNormalAtCoordinatesToRef(t,i,r),r},i.prototype.getNormalAtCoordinatesToRef=function(t,i,r){var n=this.getWorldMatrix(),s=e.Tmp.Matrix[5];n.invertToRef(s);var o=e.Tmp.Vector3[8];if(e.Vector3.TransformCoordinatesFromFloatsToRef(t,0,i,s,o),t=o.x,i=o.z,t<this._minX||t>this._maxX||i<this._minZ||i>this._maxZ)return this;this._heightQuads&&0!=this._heightQuads.length||(this._initHeightQuads(),this._computeHeightQuads());var a=this._getFacetAt(t,i);return e.Vector3.TransformNormalFromFloatsToRef(a.x,a.y,a.z,n,r),this},i.prototype.updateCoordinateHeights=function(){return this._heightQuads&&0!=this._heightQuads.length||this._initHeightQuads(),this._computeHeightQuads(),this},i.prototype._getFacetAt=function(e,t){var i=(this._subdivisionsX,this._subdivisionsY,Math.floor((e+this._maxX)*this._subdivisionsX/this._width)),r=Math.floor(-(t+this._maxZ)*this._subdivisionsY/this._height+this._subdivisionsY),n=this._heightQuads[r*this._subdivisionsX+i];return t<n.slope.x*e+n.slope.y?n.facet1:n.facet2},i.prototype._initHeightQuads=function(){var t=this._subdivisionsX,i=this._subdivisionsY;this._heightQuads=new Array;for(var r=0;r<i;r++)for(var n=0;n<t;n++){var s={slope:e.Vector2.Zero(),facet1:new e.Vector4(0,0,0,0),facet2:new e.Vector4(0,0,0,0)};this._heightQuads[r*t+n]=s}return this},i.prototype._computeHeightQuads=function(){for(var t=this.getVerticesData(e.VertexBuffer.PositionKind),i=e.Tmp.Vector3[3],r=e.Tmp.Vector3[2],n=e.Tmp.Vector3[1],s=e.Tmp.Vector3[0],o=e.Tmp.Vector3[4],a=e.Tmp.Vector3[5],h=e.Tmp.Vector3[6],u=e.Tmp.Vector3[7],c=e.Tmp.Vector3[8],l=0,f=0,d=0,p=0,_=0,m=0,g=0,y=this._subdivisionsX,v=this._subdivisionsY,b=0;b<v;b++)for(var x=0;x<y;x++){l=3*x,f=b*(y+1)*3,d=(b+1)*(y+1)*3,i.x=t[f+l],i.y=t[f+l+1],i.z=t[f+l+2],r.x=t[f+l+3],r.y=t[f+l+4],r.z=t[f+l+5],n.x=t[d+l],n.y=t[d+l+1],n.z=t[d+l+2],s.x=t[d+l+3],s.y=t[d+l+4],s.z=t[d+l+5],p=(s.z-i.z)/(s.x-i.x),_=i.z-p*i.x,r.subtractToRef(i,o),n.subtractToRef(i,a),s.subtractToRef(i,h),e.Vector3.CrossToRef(h,a,u),e.Vector3.CrossToRef(o,h,c),u.normalize(),c.normalize(),m=-(u.x*i.x+u.y*i.y+u.z*i.z),g=-(c.x*r.x+c.y*r.y+c.z*r.z);var T=this._heightQuads[b*y+x];T.slope.copyFromFloats(p,_),T.facet1.copyFromFloats(u.x,u.y,u.z,m),T.facet2.copyFromFloats(c.x,c.y,c.z,g)}return this},i.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},i.Parse=function(e,t){var r=new i(e.name,t);return r._subdivisionsX=e.subdivisionsX||1,r._subdivisionsY=e.subdivisionsY||1,r._minX=e.minX,r._maxX=e.maxX,r._minZ=e.minZ,r._maxZ=e.maxZ,r._width=e.width,r._height=e.height,r},i})(e.Mesh);e.GroundMesh=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(e,i){var r=t.call(this,e,i.getScene())||this;return i.instances.push(r),r._sourceMesh=i,r.position.copyFrom(i.position),r.rotation.copyFrom(i.rotation),r.scaling.copyFrom(i.scaling),i.rotationQuaternion&&(r.rotationQuaternion=i.rotationQuaternion.clone()),r.infiniteDistance=i.infiniteDistance,r.setPivotMatrix(i.getPivotMatrix()),r.refreshBoundingInfo(),r._syncSubMeshes(),r}return __extends(i,t),i.prototype.getClassName=function(){return"InstancedMesh"},Object.defineProperty(i.prototype,"receiveShadows",{get:function(){return this._sourceMesh.receiveShadows},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"material",{get:function(){return this._sourceMesh.material},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"visibility",{get:function(){return this._sourceMesh.visibility},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"skeleton",{get:function(){return this._sourceMesh.skeleton},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"renderingGroupId",{get:function(){return this._sourceMesh.renderingGroupId},enumerable:!0,configurable:!0}),i.prototype.getTotalVertices=function(){return this._sourceMesh.getTotalVertices()},Object.defineProperty(i.prototype,"sourceMesh",{get:function(){return this._sourceMesh},enumerable:!0,configurable:!0}),i.prototype.getVerticesData=function(e,t){return this._sourceMesh.getVerticesData(e,t)},i.prototype.setVerticesData=function(e,t,i,r){return this.sourceMesh&&this.sourceMesh.setVerticesData(e,t,i,r),this.sourceMesh},i.prototype.updateVerticesData=function(e,t,i,r){return this.sourceMesh&&this.sourceMesh.updateVerticesData(e,t,i,r),this.sourceMesh},i.prototype.setIndices=function(e,t){return this.sourceMesh&&this.sourceMesh.setIndices(e,t),this.sourceMesh},i.prototype.isVerticesDataPresent=function(e){return this._sourceMesh.isVerticesDataPresent(e)},i.prototype.getIndices=function(){return this._sourceMesh.getIndices()},Object.defineProperty(i.prototype,"_positions",{get:function(){return this._sourceMesh._positions},enumerable:!0,configurable:!0}),i.prototype.refreshBoundingInfo=function(){var t=this._sourceMesh.getBoundingInfo();return this._boundingInfo=new e.BoundingInfo(t.minimum.clone(),t.maximum.clone()),this._updateBoundingInfo(),this},i.prototype._preActivate=function(){return this._currentLOD&&this._currentLOD._preActivate(),this},i.prototype._activate=function(e){return this._currentLOD&&this._currentLOD._registerInstanceForRenderId(this,e),this},i.prototype.getLOD=function(e){return this._currentLOD=this.sourceMesh.getLOD(this.getScene().activeCamera,this.getBoundingInfo().boundingSphere),this._currentLOD===this.sourceMesh?this:this._currentLOD},i.prototype._syncSubMeshes=function(){if(this.releaseSubMeshes(),this._sourceMesh.subMeshes)for(var e=0;e<this._sourceMesh.subMeshes.length;e++)this._sourceMesh.subMeshes[e].clone(this,this._sourceMesh);return this},i.prototype._generatePointsArray=function(){return this._sourceMesh._generatePointsArray()},i.prototype.clone=function(t,i,r){var n=this._sourceMesh.createInstance(t);if(e.Tools.DeepCopy(this,n,["name","subMeshes","uniqueId"],[]),this.refreshBoundingInfo(),i&&(n.parent=i),!r)for(var s=0;s<this.getScene().meshes.length;s++){var o=this.getScene().meshes[s];o.parent===this&&o.clone(o.name,n)}return n.computeWorldMatrix(!0),n},i.prototype.dispose=function(e){var i=this._sourceMesh.instances.indexOf(this);this._sourceMesh.instances.splice(i,1),t.prototype.dispose.call(this,e)},i})(e.AbstractMesh);e.InstancedMesh=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(i,r,n,s,o,a){void 0===n&&(n=null);var h=t.call(this,i,r,n,s,o)||this;h.useVertexColor=a,h.color=new e.Color3(1,1,1),h.alpha=1,s&&(h.color=s.color.clone(),h.alpha=s.alpha,h.useVertexColor=s.useVertexColor),h._intersectionThreshold=.1;var u={attributes:[e.VertexBuffer.PositionKind],uniforms:["world","viewProjection"],needAlphaBlending:!1};return a||(u.uniforms.push("color"),u.needAlphaBlending=!0),h._colorShader=new e.ShaderMaterial("colorShader",r,"color",u),h}return __extends(i,t),Object.defineProperty(i.prototype,"intersectionThreshold",{get:function(){return this._intersectionThreshold},set:function(t){this._intersectionThreshold!==t&&(this._intersectionThreshold=t,this.geometry&&(this.geometry.boundingBias=new e.Vector2(0,t)))},enumerable:!0,configurable:!0}),i.prototype.getClassName=function(){return"LinesMesh"},Object.defineProperty(i.prototype,"material",{get:function(){return this._colorShader},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"checkCollisions",{get:function(){return!1},enumerable:!0,configurable:!0}),i.prototype.createInstance=function(t){return e.Tools.Log("LinesMeshes do not support createInstance."),null},i.prototype._bind=function(e,t,i){return this._geometry._bind(this._colorShader.getEffect()),this.useVertexColor||this._colorShader.setColor4("color",this.color.toColor4(this.alpha)),this},i.prototype._draw=function(e,t,i){return this._geometry&&this._geometry.getVertexBuffers()&&this._geometry.getIndexBuffer()?(this.getScene().getEngine().draw(!1,e.indexStart,e.indexCount),this):this},i.prototype.dispose=function(e){this._colorShader.dispose(),t.prototype.dispose.call(this,e)},i.prototype.clone=function(e,t,r){return new i(e,this.getScene(),t,this,r)},i})(e.Mesh);e.LinesMesh=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(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.SHADOWFULLFLOAT=!1,t.CAMERACOLORGRADING=!1,t.CAMERACOLORCURVES=!1,t.MORPHTARGETS=!1,t.MORPHTARGETS_NORMAL=!1,t.MORPHTARGETS_TANGENT=!1,t.NUM_MORPH_INFLUENCERS=0,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"],i=0,r=t;i<r.length;i++){var n=r[i];this[n]=n===e}},t})(e.MaterialDefines);e.StandardMaterialDefines=t;var i=(function(i){function r(t,n){var s=i.call(this,t,n)||this;return s.ambientColor=new e.Color3(0,0,0),s.diffuseColor=new e.Color3(1,1,1),s.specularColor=new e.Color3(1,1,1),s.emissiveColor=new e.Color3(0,0,0),s.specularPower=64,s._useAlphaFromDiffuseTexture=!1,s._useEmissiveAsIllumination=!1,s._linkEmissiveWithDiffuse=!1,s._useSpecularOverAlpha=!1,s._useReflectionOverAlpha=!1,s._disableLighting=!1,s._useParallax=!1,s._useParallaxOcclusion=!1,s.parallaxScaleBias=.05,s._roughness=0,s.indexOfRefraction=.98,s.invertRefractionY=!0,s._useLightmapAsShadowmap=!1,s._useReflectionFresnelFromSpecular=!1,s._useGlossinessFromSpecularMapAlpha=!1,s._maxSimultaneousLights=4,s._invertNormalMapX=!1,s._invertNormalMapY=!1,s._twoSidedLighting=!1,s._cameraColorCurves=null,s._renderTargets=new e.SmartArray(16),s._worldViewProjectionMatrix=e.Matrix.Zero(),s._globalAmbientColor=new e.Color3(0,0,0),s.getRenderTargetTextures=function(){return s._renderTargets.reset(),r.ReflectionTextureEnabled&&s._reflectionTexture&&s._reflectionTexture.isRenderTarget&&s._renderTargets.push(s._reflectionTexture),r.RefractionTextureEnabled&&s._refractionTexture&&s._refractionTexture.isRenderTarget&&s._renderTargets.push(s._refractionTexture),s._renderTargets},s}return __extends(r,i),r.prototype.getClassName=function(){return"StandardMaterial"},Object.defineProperty(r.prototype,"useLogarithmicDepth",{get:function(){return this._useLogarithmicDepth},set:function(e){this._useLogarithmicDepth=e&&this.getScene().getEngine().getCaps().fragmentDepthSupported,this._markAllSubMeshesAsMiscDirty()},enumerable:!0,configurable:!0}),r.prototype.needAlphaBlending=function(){return this.alpha<1||null!=this._opacityTexture||this._shouldUseAlphaFromDiffuseTexture()||this._opacityFresnelParameters&&this._opacityFresnelParameters.isEnabled},r.prototype.needAlphaTesting=function(){return null!=this._diffuseTexture&&this._diffuseTexture.hasAlpha},r.prototype._shouldUseAlphaFromDiffuseTexture=function(){return null!=this._diffuseTexture&&this._diffuseTexture.hasAlpha&&this._useAlphaFromDiffuseTexture},r.prototype.getAlphaTestTexture=function(){return this._diffuseTexture},r.prototype.isReadyForSubMesh=function(i,n,s){if(this.isFrozen&&this._wasPreviouslyReady&&n.effect)return!0;n._materialDefines||(n._materialDefines=new t);var o=this.getScene(),a=n._materialDefines;if(!this.checkReadyOnEveryCall&&n.effect&&a._renderId===o.getRenderId())return!0;var h=o.getEngine();if(a._needNormals=e.MaterialHelper.PrepareDefinesForLights(o,i,a,!0,this._maxSimultaneousLights,this._disableLighting),a._areTexturesDirty){if(a._needUVs=!1,o.texturesEnabled){if(this._diffuseTexture&&r.DiffuseTextureEnabled){if(!this._diffuseTexture.isReady())return!1;a._needUVs=!0,a.DIFFUSE=!0}else a.DIFFUSE=!1;if(this._ambientTexture&&r.AmbientTextureEnabled){if(!this._ambientTexture.isReady())return!1;a._needUVs=!0,a.AMBIENT=!0}else a.AMBIENT=!1;if(this._opacityTexture&&r.OpacityTextureEnabled){if(!this._opacityTexture.isReady())return!1;a._needUVs=!0,a.OPACITY=!0,a.OPACITYRGB=this._opacityTexture.getAlphaFromRGB}else a.OPACITY=!1;if(this._reflectionTexture&&r.ReflectionTextureEnabled){if(!this._reflectionTexture.isReady())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&&r.EmissiveTextureEnabled){if(!this._emissiveTexture.isReady())return!1;a._needUVs=!0,a.EMISSIVE=!0}else a.EMISSIVE=!1;if(this._lightmapTexture&&r.LightmapTextureEnabled){if(!this._lightmapTexture.isReady())return!1;a._needUVs=!0,a.LIGHTMAP=!0,a.USELIGHTMAPASSHADOWMAP=this._useLightmapAsShadowmap}else a.LIGHTMAP=!1;if(this._specularTexture&&r.SpecularTextureEnabled){if(!this._specularTexture.isReady())return!1;a._needUVs=!0,a.SPECULAR=!0,a.GLOSSINESS=this._useGlossinessFromSpecularMapAlpha}else a.SPECULAR=!1;if(o.getEngine().getCaps().standardDerivatives&&this._bumpTexture&&r.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&&r.RefractionTextureEnabled){if(!this._refractionTexture.isReady())return!1;a._needUVs=!0,a.REFRACTION=!0,a.REFRACTIONMAP_3D=this._refractionTexture.isCube}else a.REFRACTION=!1;if(this._cameraColorGradingTexture&&r.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&&(r.FresnelEnabled?(this._diffuseFresnelParameters&&this._diffuseFresnelParameters.isEnabled||this._opacityFresnelParameters&&this._opacityFresnelParameters.isEnabled||this._emissiveFresnelParameters&&this._emissiveFresnelParameters.isEnabled||this._refractionFresnelParameters&&this._refractionFresnelParameters.isEnabled||this._reflectionFresnelParameters&&this._reflectionFresnelParameters.isEnabled)&&(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(i,o,this._useLogarithmicDepth,this.pointsCloud,this.fogEnabled,a),e.MaterialHelper.PrepareDefinesForAttributes(i,a,!0,!0,!0),e.MaterialHelper.PrepareDefinesForFrameBoundValues(o,h,a,s),o._mirroredCameraPosition&&a.BUMP&&(a.INVERTNORMALMAPX=!this.invertNormalMapX,a.INVERTNORMALMAPY=!this.invertNormalMapY,a.markAsUnprocessed()),a.isDirty){a.markAsProcessed(),o.resetCachedMaterial();var u=new e.EffectFallbacks;a.REFLECTION&&u.addFallback(0,"REFLECTION"),a.SPECULAR&&u.addFallback(0,"SPECULAR"),a.BUMP&&u.addFallback(0,"BUMP"),a.PARALLAX&&u.addFallback(1,"PARALLAX"),a.PARALLAXOCCLUSION&&u.addFallback(0,"PARALLAXOCCLUSION"),a.SPECULAROVERALPHA&&u.addFallback(0,"SPECULAROVERALPHA"),a.FOG&&u.addFallback(1,"FOG"),a.POINTSIZE&&u.addFallback(0,"POINTSIZE"),a.LOGARITHMICDEPTH&&u.addFallback(0,"LOGARITHMICDEPTH"),e.MaterialHelper.HandleFallbacksForShadows(a,u,this._maxSimultaneousLights),a.SPECULARTERM&&u.addFallback(0,"SPECULARTERM"),a.DIFFUSEFRESNEL&&u.addFallback(1,"DIFFUSEFRESNEL"),a.OPACITYFRESNEL&&u.addFallback(2,"OPACITYFRESNEL"),a.REFLECTIONFRESNEL&&u.addFallback(3,"REFLECTIONFRESNEL"),a.EMISSIVEFRESNEL&&u.addFallback(4,"EMISSIVEFRESNEL"),a.FRESNEL&&u.addFallback(4,"FRESNEL");var c=[e.VertexBuffer.PositionKind];a.NORMAL&&c.push(e.VertexBuffer.NormalKind),a.UV1&&c.push(e.VertexBuffer.UVKind),a.UV2&&c.push(e.VertexBuffer.UV2Kind),a.VERTEXCOLOR&&c.push(e.VertexBuffer.ColorKind),e.MaterialHelper.PrepareAttributesForBones(c,i,a,u),e.MaterialHelper.PrepareAttributesForInstances(c,a),e.MaterialHelper.PrepareAttributesForMorphTargets(c,i,a);var l="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","depthValues","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&&(l=this.customShaderNameResolve(l,f,p,d,a));var _=a.toString();n.setEffect(o.getEngine().createEffect(l,{attributes:c,uniformsNames:f,uniformBuffersNames:p,samplers:d,defines:_,fallbacks:u,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:this._maxSimultaneousLights,maxSimultaneousMorphTargets:a.NUM_MORPH_INFLUENCERS}},h),a),this.buildUniformLayout()}return!!n.effect.isReady()&&(a._renderId=o.getRenderId(),this._wasPreviouslyReady=!0,!0)},r.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()},r.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)),i.prototype.unbind.call(this)},r.prototype.bindForSubMesh=function(t,i,n){var s=this.getScene(),o=n._materialDefines;if(o){var a=n.effect;if(this._activeEffect=a,this.bindOnlyWorldMatrix(t),e.MaterialHelper.BindBonesParameters(i,a),this._mustRebind(s,a,i.visibility)){if(this._uniformBuffer.bindToEffect(a,"Material"),this.bindViewProjection(a),!this._uniformBuffer.useUbo||!this.isFrozen||!this._uniformBuffer.isSync){if(r.FresnelEnabled&&o.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))),s.texturesEnabled&&(this._diffuseTexture&&r.DiffuseTextureEnabled&&(this._uniformBuffer.updateFloat2("vDiffuseInfos",this._diffuseTexture.coordinatesIndex,this._diffuseTexture.level),this._uniformBuffer.updateMatrix("diffuseMatrix",this._diffuseTexture.getTextureMatrix())),
  20. this._ambientTexture&&r.AmbientTextureEnabled&&(this._uniformBuffer.updateFloat2("vAmbientInfos",this._ambientTexture.coordinatesIndex,this._ambientTexture.level),this._uniformBuffer.updateMatrix("ambientMatrix",this._ambientTexture.getTextureMatrix())),this._opacityTexture&&r.OpacityTextureEnabled&&(this._uniformBuffer.updateFloat2("vOpacityInfos",this._opacityTexture.coordinatesIndex,this._opacityTexture.level),this._uniformBuffer.updateMatrix("opacityMatrix",this._opacityTexture.getTextureMatrix())),this._reflectionTexture&&r.ReflectionTextureEnabled&&(this._uniformBuffer.updateFloat2("vReflectionInfos",this._reflectionTexture.level,this.roughness),this._uniformBuffer.updateMatrix("reflectionMatrix",this._reflectionTexture.getReflectionTextureMatrix())),this._emissiveTexture&&r.EmissiveTextureEnabled&&(this._uniformBuffer.updateFloat2("vEmissiveInfos",this._emissiveTexture.coordinatesIndex,this._emissiveTexture.level),this._uniformBuffer.updateMatrix("emissiveMatrix",this._emissiveTexture.getTextureMatrix())),this._lightmapTexture&&r.LightmapTextureEnabled&&(this._uniformBuffer.updateFloat2("vLightmapInfos",this._lightmapTexture.coordinatesIndex,this._lightmapTexture.level),this._uniformBuffer.updateMatrix("lightmapMatrix",this._lightmapTexture.getTextureMatrix())),this._specularTexture&&r.SpecularTextureEnabled&&(this._uniformBuffer.updateFloat2("vSpecularInfos",this._specularTexture.coordinatesIndex,this._specularTexture.level),this._uniformBuffer.updateMatrix("specularMatrix",this._specularTexture.getTextureMatrix())),this._bumpTexture&&s.getEngine().getCaps().standardDerivatives&&r.BumpTextureEnabled&&(this._uniformBuffer.updateFloat3("vBumpInfos",this._bumpTexture.coordinatesIndex,1/this._bumpTexture.level,this.parallaxScaleBias),this._uniformBuffer.updateMatrix("bumpMatrix",this._bumpTexture.getTextureMatrix())),this._refractionTexture&&r.RefractionTextureEnabled)){var h=1;this._refractionTexture.isCube||(this._uniformBuffer.updateMatrix("refractionMatrix",this._refractionTexture.getReflectionTextureMatrix()),this._refractionTexture.depth&&(h=this._refractionTexture.depth)),this._uniformBuffer.updateFloat4("vRefractionInfos",this._refractionTexture.level,this.indexOfRefraction,h,this.invertRefractionY?-1:1)}this.pointsCloud&&this._uniformBuffer.updateFloat("pointSize",this.pointSize),o.SPECULARTERM&&this._uniformBuffer.updateColor4("vSpecularColor",this.specularColor,this.specularPower),this._uniformBuffer.updateColor3("vEmissiveColor",this.emissiveColor),this._uniformBuffer.updateColor4("vDiffuseColor",this.diffuseColor,this.alpha*i.visibility)}if(s.texturesEnabled){if(this._diffuseTexture&&r.DiffuseTextureEnabled&&a.setTexture("diffuseSampler",this._diffuseTexture),this._ambientTexture&&r.AmbientTextureEnabled&&a.setTexture("ambientSampler",this._ambientTexture),this._opacityTexture&&r.OpacityTextureEnabled&&a.setTexture("opacitySampler",this._opacityTexture),this._reflectionTexture&&r.ReflectionTextureEnabled&&(this._reflectionTexture.isCube?a.setTexture("reflectionCubeSampler",this._reflectionTexture):a.setTexture("reflection2DSampler",this._reflectionTexture)),this._emissiveTexture&&r.EmissiveTextureEnabled&&a.setTexture("emissiveSampler",this._emissiveTexture),this._lightmapTexture&&r.LightmapTextureEnabled&&a.setTexture("lightmapSampler",this._lightmapTexture),this._specularTexture&&r.SpecularTextureEnabled&&a.setTexture("specularSampler",this._specularTexture),this._bumpTexture&&s.getEngine().getCaps().standardDerivatives&&r.BumpTextureEnabled&&a.setTexture("bumpSampler",this._bumpTexture),this._refractionTexture&&r.RefractionTextureEnabled){var h=1;this._refractionTexture.isCube?a.setTexture("refractionCubeSampler",this._refractionTexture):a.setTexture("refraction2DSampler",this._refractionTexture)}this._cameraColorGradingTexture&&r.ColorGradingTextureEnabled&&e.ColorGradingTexture.Bind(this._cameraColorGradingTexture,a)}e.MaterialHelper.BindClipPlane(a,s),s.ambientColor.multiplyToRef(this.ambientColor,this._globalAmbientColor),a.setVector3("vEyePosition",s._mirroredCameraPosition?s._mirroredCameraPosition:s.activeCamera.position),a.setColor3("vAmbientColor",this._globalAmbientColor)}!this._mustRebind(s,a)&&this.isFrozen||(s.lightsEnabled&&!this._disableLighting&&e.MaterialHelper.BindLights(s,i,a,o,this._maxSimultaneousLights),(s.fogEnabled&&i.applyFog&&s.fogMode!==e.Scene.FOGMODE_NONE||this._reflectionTexture||this._refractionTexture)&&this.bindView(a),e.MaterialHelper.BindFogParameters(s,i,a),o.NUM_MORPH_INFLUENCERS&&e.MaterialHelper.BindMorphTargetParameters(i,a),e.MaterialHelper.BindLogDepth(o,a,s),this._cameraColorCurves&&e.ColorCurves.Bind(this._cameraColorCurves,a)),this._uniformBuffer.update(),this._afterBind(i,this._activeEffect)}},r.prototype.getAnimatables=function(){var e=[];return this._diffuseTexture&&this._diffuseTexture.animations&&this._diffuseTexture.animations.length>0&&e.push(this._diffuseTexture),this._ambientTexture&&this._ambientTexture.animations&&this._ambientTexture.animations.length>0&&e.push(this._ambientTexture),this._opacityTexture&&this._opacityTexture.animations&&this._opacityTexture.animations.length>0&&e.push(this._opacityTexture),this._reflectionTexture&&this._reflectionTexture.animations&&this._reflectionTexture.animations.length>0&&e.push(this._reflectionTexture),this._emissiveTexture&&this._emissiveTexture.animations&&this._emissiveTexture.animations.length>0&&e.push(this._emissiveTexture),this._specularTexture&&this._specularTexture.animations&&this._specularTexture.animations.length>0&&e.push(this._specularTexture),this._bumpTexture&&this._bumpTexture.animations&&this._bumpTexture.animations.length>0&&e.push(this._bumpTexture),this._lightmapTexture&&this._lightmapTexture.animations&&this._lightmapTexture.animations.length>0&&e.push(this._lightmapTexture),this._refractionTexture&&this._refractionTexture.animations&&this._refractionTexture.animations.length>0&&e.push(this._refractionTexture),this._cameraColorGradingTexture&&this._cameraColorGradingTexture.animations&&this._cameraColorGradingTexture.animations.length>0&&e.push(this._cameraColorGradingTexture),e},r.prototype.dispose=function(e,t){t&&(this._diffuseTexture&&this._diffuseTexture.dispose(),this._ambientTexture&&this._ambientTexture.dispose(),this._opacityTexture&&this._opacityTexture.dispose(),this._reflectionTexture&&this._reflectionTexture.dispose(),this._emissiveTexture&&this._emissiveTexture.dispose(),this._specularTexture&&this._specularTexture.dispose(),this._bumpTexture&&this._bumpTexture.dispose(),this._lightmapTexture&&this._lightmapTexture.dispose(),this._refractionTexture&&this._refractionTexture.dispose(),this._cameraColorGradingTexture&&this._cameraColorGradingTexture.dispose()),i.prototype.dispose.call(this,e,t)},r.prototype.clone=function(t){var i=this,n=e.SerializationHelper.Clone((function(){return new r(t,i.getScene())}),this);return n.name=t,n.id=t,n},r.prototype.serialize=function(){return e.SerializationHelper.Serialize(this)},r.Parse=function(t,i,n){return e.SerializationHelper.Parse((function(){return new r(t.name,i)}),t,i,n)},Object.defineProperty(r,"DiffuseTextureEnabled",{get:function(){return r._DiffuseTextureEnabled},set:function(t){r._DiffuseTextureEnabled!==t&&(r._DiffuseTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(r,"AmbientTextureEnabled",{get:function(){return r._AmbientTextureEnabled},set:function(t){r._AmbientTextureEnabled!==t&&(r._AmbientTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(r,"OpacityTextureEnabled",{get:function(){return r._OpacityTextureEnabled},set:function(t){r._OpacityTextureEnabled!==t&&(r._OpacityTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(r,"ReflectionTextureEnabled",{get:function(){return r._ReflectionTextureEnabled},set:function(t){r._ReflectionTextureEnabled!==t&&(r._ReflectionTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(r,"EmissiveTextureEnabled",{get:function(){return r._EmissiveTextureEnabled},set:function(t){r._EmissiveTextureEnabled!==t&&(r._EmissiveTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(r,"SpecularTextureEnabled",{get:function(){return r._SpecularTextureEnabled},set:function(t){r._SpecularTextureEnabled!==t&&(r._SpecularTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(r,"BumpTextureEnabled",{get:function(){return r._BumpTextureEnabled},set:function(t){r._BumpTextureEnabled!==t&&(r._BumpTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(r,"LightmapTextureEnabled",{get:function(){return r._LightmapTextureEnabled},set:function(t){r._LightmapTextureEnabled!==t&&(r._LightmapTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(r,"RefractionTextureEnabled",{get:function(){return r._RefractionTextureEnabled},set:function(t){r._RefractionTextureEnabled!==t&&(r._RefractionTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(r,"ColorGradingTextureEnabled",{get:function(){return r._ColorGradingTextureEnabled},set:function(t){r._ColorGradingTextureEnabled!==t&&(r._ColorGradingTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(r,"FresnelEnabled",{get:function(){return r._FresnelEnabled},set:function(t){r._FresnelEnabled!==t&&(r._FresnelEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.FresnelDirtyFlag))},enumerable:!0,configurable:!0}),r})(e.PushMaterial);i._DiffuseTextureEnabled=!0,i._AmbientTextureEnabled=!0,i._OpacityTextureEnabled=!0,i._ReflectionTextureEnabled=!0,i._EmissiveTextureEnabled=!0,i._SpecularTextureEnabled=!0,i._BumpTextureEnabled=!0,i._LightmapTextureEnabled=!0,i._RefractionTextureEnabled=!0,i._ColorGradingTextureEnabled=!0,i._FresnelEnabled=!0,__decorate([e.serializeAsTexture("diffuseTexture")],i.prototype,"_diffuseTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"diffuseTexture",void 0),__decorate([e.serializeAsTexture("ambientTexture")],i.prototype,"_ambientTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"ambientTexture",void 0),__decorate([e.serializeAsTexture("opacityTexture")],i.prototype,"_opacityTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"opacityTexture",void 0),__decorate([e.serializeAsTexture("reflectionTexture")],i.prototype,"_reflectionTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"reflectionTexture",void 0),__decorate([e.serializeAsTexture("emissiveTexture")],i.prototype,"_emissiveTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"emissiveTexture",void 0),__decorate([e.serializeAsTexture("specularTexture")],i.prototype,"_specularTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"specularTexture",void 0),__decorate([e.serializeAsTexture("bumpTexture")],i.prototype,"_bumpTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"bumpTexture",void 0),__decorate([e.serializeAsTexture("lightmapTexture")],i.prototype,"_lightmapTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"lightmapTexture",void 0),__decorate([e.serializeAsTexture("refractionTexture")],i.prototype,"_refractionTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"refractionTexture",void 0),__decorate([e.serializeAsColor3("ambient")],i.prototype,"ambientColor",void 0),__decorate([e.serializeAsColor3("diffuse")],i.prototype,"diffuseColor",void 0),__decorate([e.serializeAsColor3("specular")],i.prototype,"specularColor",void 0),__decorate([e.serializeAsColor3("emissive")],i.prototype,"emissiveColor",void 0),__decorate([e.serialize()],i.prototype,"specularPower",void 0),__decorate([e.serialize("useAlphaFromDiffuseTexture")],i.prototype,"_useAlphaFromDiffuseTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useAlphaFromDiffuseTexture",void 0),__decorate([e.serialize("useEmissiveAsIllumination")],i.prototype,"_useEmissiveAsIllumination",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useEmissiveAsIllumination",void 0),__decorate([e.serialize("linkEmissiveWithDiffuse")],i.prototype,"_linkEmissiveWithDiffuse",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"linkEmissiveWithDiffuse",void 0),__decorate([e.serialize("useSpecularOverAlpha")],i.prototype,"_useSpecularOverAlpha",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useSpecularOverAlpha",void 0),__decorate([e.serialize("useReflectionOverAlpha")],i.prototype,"_useReflectionOverAlpha",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useReflectionOverAlpha",void 0),__decorate([e.serialize("disableLighting")],i.prototype,"_disableLighting",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsLightsDirty")],i.prototype,"disableLighting",void 0),__decorate([e.serialize("useParallax")],i.prototype,"_useParallax",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useParallax",void 0),__decorate([e.serialize("useParallaxOcclusion")],i.prototype,"_useParallaxOcclusion",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useParallaxOcclusion",void 0),__decorate([e.serialize()],i.prototype,"parallaxScaleBias",void 0),__decorate([e.serialize("roughness")],i.prototype,"_roughness",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"roughness",void 0),__decorate([e.serialize()],i.prototype,"indexOfRefraction",void 0),__decorate([e.serialize()],i.prototype,"invertRefractionY",void 0),__decorate([e.serialize("useLightmapAsShadowmap")],i.prototype,"_useLightmapAsShadowmap",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useLightmapAsShadowmap",void 0),__decorate([e.serializeAsFresnelParameters("diffuseFresnelParameters")],i.prototype,"_diffuseFresnelParameters",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsFresnelDirty")],i.prototype,"diffuseFresnelParameters",void 0),__decorate([e.serializeAsFresnelParameters("opacityFresnelParameters")],i.prototype,"_opacityFresnelParameters",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsFresnelDirty")],i.prototype,"opacityFresnelParameters",void 0),__decorate([e.serializeAsFresnelParameters("reflectionFresnelParameters")],i.prototype,"_reflectionFresnelParameters",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsFresnelDirty")],i.prototype,"reflectionFresnelParameters",void 0),__decorate([e.serializeAsFresnelParameters("refractionFresnelParameters")],i.prototype,"_refractionFresnelParameters",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsFresnelDirty")],i.prototype,"refractionFresnelParameters",void 0),__decorate([e.serializeAsFresnelParameters("emissiveFresnelParameters")],i.prototype,"_emissiveFresnelParameters",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsFresnelDirty")],i.prototype,"emissiveFresnelParameters",void 0),__decorate([e.serialize("useReflectionFresnelFromSpecular")],i.prototype,"_useReflectionFresnelFromSpecular",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsFresnelDirty")],i.prototype,"useReflectionFresnelFromSpecular",void 0),__decorate([e.serialize("useGlossinessFromSpecularMapAlpha")],i.prototype,"_useGlossinessFromSpecularMapAlpha",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useGlossinessFromSpecularMapAlpha",void 0),__decorate([e.serialize("maxSimultaneousLights")],i.prototype,"_maxSimultaneousLights",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsLightsDirty")],i.prototype,"maxSimultaneousLights",void 0),__decorate([e.serialize("invertNormalMapX")],i.prototype,"_invertNormalMapX",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"invertNormalMapX",void 0),__decorate([e.serialize("invertNormalMapY")],i.prototype,"_invertNormalMapY",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"invertNormalMapY",void 0),__decorate([e.serialize("twoSidedLighting")],i.prototype,"_twoSidedLighting",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"twoSidedLighting",void 0),__decorate([e.serializeAsTexture("cameraColorGradingTexture")],i.prototype,"_cameraColorGradingTexture",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"cameraColorGradingTexture",void 0),__decorate([e.serializeAsColorCurves("cameraColorCurves")],i.prototype,"_cameraColorCurves",void 0),__decorate([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"cameraColorCurves",void 0),__decorate([e.serialize()],i.prototype,"useLogarithmicDepth",null),e.StandardMaterial=i})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(){this._count=0,this._data={}}return e.prototype.copyFrom=function(e){var t=this;this.clear(),e.forEach((function(e,i){return t.add(e,i)}))},e.prototype.get=function(e){var t=this._data[e];if(void 0!==t)return t},e.prototype.getOrAddWithFactory=function(e,t){var i=this.get(e);return void 0!==i?i:(i=t(e),i&&this.add(e,i),i)},e.prototype.getOrAdd=function(e,t){var i=this.get(e);return void 0!==i?i:(this.add(e,t),t)},e.prototype.contains=function(e){return void 0!==this._data[e]},e.prototype.add=function(e,t){return void 0===this._data[e]&&(this._data[e]=t,++this._count,!0)},e.prototype.set=function(e,t){return void 0!==this._data[e]&&(this._data[e]=t,!0)},e.prototype.getAndRemove=function(e){var t=this.get(e);return void 0!==t?(delete this._data[e],--this._count,t):null},e.prototype.remove=function(e){return!!this.contains(e)&&(delete this._data[e],--this._count,!0)},e.prototype.clear=function(){this._data={},this._count=0},Object.defineProperty(e.prototype,"count",{get:function(){return this._count},enumerable:!0,configurable:!0}),e.prototype.forEach=function(e){for(var t in this._data){e(t,this._data[t])}},e.prototype.first=function(e){for(var t in this._data){var i=this._data[t],r=e(t,i);if(r)return r}return null},e})();e.StringDictionary=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(){}return e})();e.DynamicFloatArrayElementInfo=t;var i=(function(){function e(e,i){this.compareValueOffset=null,this.sortingAscending=!0,this._stride=e,this.buffer=new Float32Array(e*i),this._lastUsed=0,this._firstFree=0,this._allEntries=new Array(i),this._freeEntries=new Array(i);for(var r=0;r<i;r++){var n=new t;n.offset=r*e,this._allEntries[r]=n,this._freeEntries[i-r-1]=n}}return e.prototype.allocElement=function(){0===this._freeEntries.length&&this._growBuffer();var e=this._freeEntries.pop();return this._lastUsed=Math.max(e.offset,this._lastUsed),e.offset===this._firstFree&&(this._freeEntries.length>0?this._firstFree=this._freeEntries[this._freeEntries.length-1].offset:this._firstFree+=this._stride),e},e.prototype.freeElement=function(e){this._firstFree=Math.min(e.offset,this._firstFree),this._freeEntries.push(e)},e.prototype.pack=function(){if(0===this._freeEntries.length)return this.buffer;if(this._lastUsed<this._firstFree){return this.buffer.subarray(0,this._lastUsed+this._stride)}var e=this._stride,i=new t;i.offset=this.totalElementCount*e,this._freeEntries.push(i);for(var r=this._freeEntries.sort((function(e,t){return e.offset-t.offset})),n=this._allEntries.sort((function(e,t){return e.offset-t.offset})),s=r[0].offset,o=1,a=(this.usedElementCount+1)*e,h=r[0].offset,u=1;u<r.length&&!(s>=a);u++){var c=r[u],l=c.offset,f=l-h;if(f!==e){for(var d=f/e-1,p=l-e,_=Math.min(o,d),m=0;m<_;m++){var g=s/e,y=p/e,v=n[y];this._moveElement(v,s);var b=n[g];b.offset=p,n[g]=v,n[y]=b,p-=e,s+=e}o<=d?(s=p+e,o=1+_):o=(l-s)/e+1,h=l}else++o,h=l}var x=this.buffer.subarray(0,s);return this._lastUsed=s-e,this._firstFree=s,r.pop(),this._freeEntries=r.sort((function(e,t){return t.offset-e.offset})),this._allEntries=n,x},e.prototype._moveElement=function(e,t){for(var i=0;i<this._stride;i++)this.buffer[t+i]=this.buffer[e.offset+i];e.offset=t},e.prototype._growBuffer=function(){var e=Math.floor(1.5*this.totalElementCount),i=new Float32Array(e*this._stride);i.set(this.buffer);for(var r=this.totalElementCount,n=e-this.totalElementCount,s=0;s<n;s++){var o=new t;o.offset=(r+s)*this.stride,this._allEntries.push(o),this._freeEntries[n-s-1]=o}this._firstFree=r*this.stride,this.buffer=i},Object.defineProperty(e.prototype,"totalElementCount",{get:function(){return this._allEntries.length},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"freeElementCount",{get:function(){return this._freeEntries.length},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"usedElementCount",{get:function(){return this._allEntries.length-this._freeEntries.length},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"stride",{get:function(){return this._stride},enumerable:!0,configurable:!0}),e.prototype.sort=function(){var e=this;if(!this.compareValueOffset)throw new Error("The DynamicFloatArray.sort() method needs a valid 'compareValueOffset' property");var t=this.usedElementCount;if(!this._sortTable||this._sortTable.length<t){var i=Math.min(this.totalElementCount,2*t);this._sortTable=new Array(i)}this._sortedTable&&this._sortedTable.length===t||(this._sortedTable=new Array(t)),this.pack();for(var n=0,s=this.stride,o=0;o<t;o++,n+=s){var a=this._sortTable[o];a||(a=new r,this._sortTable[o]=a),a.compareData=this.buffer[n+this.compareValueOffset],a.offset=n,a.swapedOffset=null,this._sortedTable[o]=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 o=0;o<t;o++){var h=this._sortedTable[o],u=this._sortTable[o],c=h.offset;if(h.swapedOffset){for(var l=h;l.swapedOffset;)l=this._sortTable[l.swapedOffset/s];c=l.offset}u.swapedOffset=c,c!==u.offset&&(function(t,i){for(var r=0;r<s;r++){var n=e.buffer[i+r];e.buffer[i+r]=e.buffer[t+r],e.buffer[t+r]=n}})(c,u.offset),this._allEntries[h.offset/s].offset=u.offset}return this._allEntries.sort((function(e,t){return e.offset-t.offset})),!0},e})();e.DynamicFloatArray=i;var r=(function(){function e(){this.compareData=this.offset=this.swapedOffset=null}return e})()})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function e(e){this._actionManager=e}return e.prototype.isValid=function(){return!0},e.prototype._getProperty=function(e){return this._actionManager._getProperty(e)},e.prototype._getEffectiveTarget=function(e,t){return this._actionManager._getEffectiveTarget(e,t)},e.prototype.serialize=function(){},e.prototype._serialize=function(e){return{type:2,children:[],name:e.name,properties:e.properties}},e})();e.Condition=t;var i=(function(t){function i(e,r,n,s,o){void 0===o&&(o=i.IsEqual);var a=t.call(this,e)||this;return a.propertyPath=n,a.value=s,a.operator=o,a._target=r,a._effectiveTarget=a._getEffectiveTarget(r,a.propertyPath),a._property=a._getProperty(a.propertyPath),a}return __extends(i,t),Object.defineProperty(i,"IsEqual",{get:function(){return i._IsEqual},enumerable:!0,configurable:!0}),Object.defineProperty(i,"IsDifferent",{get:function(){return i._IsDifferent},enumerable:!0,configurable:!0}),Object.defineProperty(i,"IsGreater",{get:function(){return i._IsGreater},enumerable:!0,configurable:!0}),Object.defineProperty(i,"IsLesser",{get:function(){return i._IsLesser},enumerable:!0,configurable:!0}),i.prototype.isValid=function(){switch(this.operator){case i.IsGreater:return this._effectiveTarget[this._property]>this.value;case i.IsLesser:return this._effectiveTarget[this._property]<this.value;case i.IsEqual:case i.IsDifferent:var e;return e=this.value.equals?this.value.equals(this._effectiveTarget[this._property]):this.value===this._effectiveTarget[this._property],this.operator===i.IsEqual?e:!e}return!1},i.prototype.serialize=function(){return this._serialize({name:"ValueCondition",properties:[e.Action._GetTargetProperty(this._target),{name:"propertyPath",value:this.propertyPath},{name:"value",value:e.Action._SerializeValueAsString(this.value)},{name:"operator",value:i.GetOperatorName(this.operator)}]})},i.GetOperatorName=function(e){switch(e){case i._IsEqual:return"IsEqual";case i._IsDifferent:return"IsDifferent";case i._IsGreater:return"IsGreater";case i._IsLesser:return"IsLesser";default:return""}},i})(t);i._IsEqual=0,i._IsDifferent=1,i._IsGreater=2,i._IsLesser=3,e.ValueCondition=i;var r=(function(e){function t(t,i){var r=e.call(this,t)||this;return r.predicate=i,r}return __extends(t,e),t.prototype.isValid=function(){return this.predicate()},t})(t);e.PredicateCondition=r;var n=(function(t){function i(e,i,r){var n=t.call(this,e)||this;return n.value=r,n._target=i,n}return __extends(i,t),i.prototype.isValid=function(){return this._target.state===this.value},i.prototype.serialize=function(){return this._serialize({name:"StateCondition",properties:[e.Action._GetTargetProperty(this._target),{name:"value",value:this.value}]})},i})(t);e.StateCondition=n})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function 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,i=this._actionManager.getScene().getRenderId();if(t._evaluationId===i){if(!t._currentResult)return}else{if(t._evaluationId=i,!t.isValid())return void(t._currentResult=!1);t._currentResult=!0}}this._nextActiveAction.execute(e),this.skipToNextActiveAction()},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 i={type:1,children:[],name:e.name,properties:e.properties||[]};if(this._child&&this._child.serialize(i),this._condition){var r=this._condition.serialize();return r.children.push(i),t&&t.children.push(r),r}return t&&t.children.push(i),i},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,i,r,n,s){this.source=e,this.pointerX=t,this.pointerY=i,this.meshUnderPointer=r,this.sourceEvent=n,this.additionalData=s}return e.CreateNew=function(t,i,r){var n=t.getScene();return new e(t,n.pointerX,n.pointerY,n.meshUnderPointer,i,r)},e.CreateNewFromSprite=function(t,i,r,n){return new e(t,i.pointerX,i.pointerY,i.meshUnderPointer,r,n)},e.CreateNewFromScene=function(t,i){return new e(null,t.pointerX,t.pointerY,t.meshUnderPointer,i)},e.CreateNewFromPrimitive=function(t,i,r,n){return new e(t,i.x,i.y,null,r,n)},e})();e.ActionEvent=t;var i=(function(){function t(e){this.actions=new Array,this.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),i=0;i<this.actions.length;i++){var r=this.actions[i];t.Triggers[r.trigger]--,0===t.Triggers[r.trigger]&&delete t.Triggers[r.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 i=this.actions[t];if(e.indexOf(i.trigger)>-1)return!0}return!1},t.prototype.hasSpecificTrigger=function(e){for(var t=0;t<this.actions.length;t++){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 i=this.actions[e];if(i.trigger>=t._OnPickTrigger&&i.trigger<=t._OnPointerOutTrigger)return!0}return!1},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"hasPickTriggers",{get:function(){for(var e=0;e<this.actions.length;e++){var i=this.actions[e]
  21. ;if(i.trigger>=t._OnPickTrigger&&i.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 i=parseInt(e);if(i>=t._OnPickTrigger&&i<=t._OnPickUpTrigger)return!0}return!1},enumerable:!0,configurable:!0}),t.HasSpecificTrigger=function(e){for(var i in t.Triggers)if(t.Triggers.hasOwnProperty(i)){var r=parseInt(i);if(r===e)return!0}return!1},t.prototype.registerAction=function(i){return i.trigger===t.OnEveryFrameTrigger&&this.getScene().actionManager!==this?(e.Tools.Warn("OnEveryFrameTrigger can only be used with scene.actionManager"),null):(this.actions.push(i),t.Triggers[i.trigger]?t.Triggers[i.trigger]++:t.Triggers[i.trigger]=1,i._actionManager=this,i._prepare(),i)},t.prototype.processTrigger=function(e,i){for(var r=0;r<this.actions.length;r++){var n=this.actions[r];if(n.trigger===e){if(e===t.OnKeyUpTrigger||e===t.OnKeyDownTrigger){var s=n.getTriggerParameter();if(s&&s!==i.sourceEvent.keyCode){var o=i.sourceEvent.charCode?i.sourceEvent.charCode:i.sourceEvent.keyCode;if(String.fromCharCode(o).toLowerCase()!==s.toLowerCase())continue}}n._executeCurrent(i)}}},t.prototype._getEffectiveTarget=function(e,t){for(var i=t.split("."),r=0;r<i.length-1;r++)e=e[i[r]];return e},t.prototype._getProperty=function(e){var t=e.split(".");return t[t.length-1]},t.prototype.serialize=function(i){for(var r={children:[],name:i,type:3,properties:[]},n=0;n<this.actions.length;n++){var s={type:0,children:[],name:t.GetTriggerName(this.actions[n].trigger),properties:[]},o=this.actions[n].triggerOptions;if(o&&"number"!=typeof o)if(o.parameter instanceof e.Node)s.properties.push(e.Action._GetTargetProperty(o.parameter));else{var a={};e.Tools.DeepCopy(o.parameter,a,["mesh"]),o.parameter.mesh&&(a._meshId=o.parameter.mesh.id),s.properties.push({name:"parameter",targetType:null,value:a})}this.actions[n].serialize(s),r.children.push(s)}return r},t.Parse=function(i,r,n){var s=new e.ActionManager(n);null===r?n.actionManager=s:r.actionManager=s;for(var o=function(t,i){var r=Object.create(e[t].prototype);return r.constructor.apply(r,i),r},a=function(t,i,r,n){if(null===n){var s=parseFloat(i);return"true"===i||"false"===i?"true"===i:isNaN(s)?i:s}for(var o=n.split("."),a=i.split(","),h=0;h<o.length;h++)r=r[o[h]];if("boolean"==typeof r)return"true"===a[0];if("string"==typeof r)return a[0];for(var u=new Array,h=0;h<a.length;h++)u.push(parseFloat(a[h]));return r instanceof e.Vector3?e.Vector3.FromArray(u):r instanceof e.Vector4?e.Vector4.FromArray(u):r instanceof e.Color3?e.Color3.FromArray(u):r instanceof e.Color4?e.Color4.FromArray(u):parseFloat(a[0])},h=function(i,r,u,c,l){if(void 0===l&&(l=null),!i.detached){var f=new Array,d=null,p=null,_=i.combine&&i.combine.length>0;if(2===i.type?f.push(s):f.push(r),_){for(var m=new Array,g=0;g<i.combine.length;g++)h(i.combine[g],t.NothingTrigger,u,c,m);f.push(m)}else for(var y=0;y<i.properties.length;y++){var v=i.properties[y].value,b=i.properties[y].name,x=i.properties[y].targetType;"target"===b?v=d=null!==x&&"SceneProperties"===x?n:n.getNodeByName(v):"parent"===b?v=n.getNodeByName(v):"sound"===b?v=n.getSoundByName(v):"propertyPath"!==b?v=2===i.type&&"operator"===b?e.ValueCondition[v]:a(0,v,d,"value"===b?p:null):p=v,f.push(v)}if(null===l?f.push(u):f.push(null),"InterpolateValueAction"===i.name){var T=f[f.length-2];f[f.length-1]=T,f[f.length-2]=u}var E=o(i.name,f);if(E instanceof e.Condition&&null!==u){var A=new e.DoNothingAction(r,u);c?c.then(A):s.registerAction(A),c=A}null===l?E instanceof e.Condition?(u=E,E=c):(u=null,c?c.then(E):s.registerAction(E)):l.push(E);for(var y=0;y<i.children.length;y++)h(i.children[y],r,u,E,null)}},u=0;u<i.children.length;u++){var c,l=i.children[u];if(l.properties.length>0){var f=l.properties[0].value,d=null===l.properties[0].targetType?f:n.getMeshByName(f);d._meshId&&(d.mesh=n.getMeshByID(d._meshId)),c={trigger:e.ActionManager[l.name],parameter:d}}else c=e.ActionManager[l.name];for(var p=0;p<l.children.length;p++)l.detached||h(l.children[p],c,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})();i._NothingTrigger=0,i._OnPickTrigger=1,i._OnLeftPickTrigger=2,i._OnRightPickTrigger=3,i._OnCenterPickTrigger=4,i._OnPickDownTrigger=5,i._OnDoublePickTrigger=6,i._OnPickUpTrigger=7,i._OnLongPressTrigger=8,i._OnPointerOverTrigger=9,i._OnPointerOutTrigger=10,i._OnEveryFrameTrigger=11,i._OnIntersectionEnterTrigger=12,i._OnIntersectionExitTrigger=13,i._OnKeyDownTrigger=14,i._OnKeyUpTrigger=15,i._OnPickOutTrigger=16,i.Triggers={},e.ActionManager=i})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(e,i,r,n,s,o,a,h){void 0===s&&(s=1e3);var u=t.call(this,e,o)||this;return u.propertyPath=r,u.value=n,u.duration=s,u.stopOtherAnimations=a,u.onInterpolationDone=h,u._target=u._effectiveTarget=i,u}return __extends(i,t),i.prototype._prepare=function(){this._effectiveTarget=this._getEffectiveTarget(this._effectiveTarget,this.propertyPath),this._property=this._getProperty(this.propertyPath)},i.prototype.execute=function(){var t,i=this._actionManager.getScene(),r=[{frame:0,value:this._effectiveTarget[this._property]},{frame:100,value:this.value}];if("number"==typeof this.value)t=e.Animation.ANIMATIONTYPE_FLOAT;else if(this.value instanceof e.Color3)t=e.Animation.ANIMATIONTYPE_COLOR3;else if(this.value instanceof e.Vector3)t=e.Animation.ANIMATIONTYPE_VECTOR3;else if(this.value instanceof e.Matrix)t=e.Animation.ANIMATIONTYPE_MATRIX;else{if(!(this.value instanceof e.Quaternion))return void e.Tools.Warn("InterpolateValueAction: Unsupported type ("+typeof this.value+")");t=e.Animation.ANIMATIONTYPE_QUATERNION}var n=new e.Animation("InterpolateValueAction",this._property,1e3/this.duration*100,t,e.Animation.ANIMATIONLOOPMODE_CONSTANT);n.setKeys(r),this.stopOtherAnimations&&i.stopAnimation(this._effectiveTarget),i.beginDirectAnimation(this._effectiveTarget,[n],0,100,!1,1,this.onInterpolationDone)},i.prototype.serialize=function(i){return t.prototype._serialize.call(this,{name:"InterpolateValueAction",properties:[e.Action._GetTargetProperty(this._target),{name:"propertyPath",value:this.propertyPath},{name:"value",value:e.Action._SerializeValueAsString(this.value)},{name:"duration",value:e.Action._SerializeValueAsString(this.duration)},{name:"stopOtherAnimations",value:e.Action._SerializeValueAsString(this.stopOtherAnimations)||!1}]},i)},i})(e.Action);e.InterpolateValueAction=t})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(t){function i(e,i,r,n){var s=t.call(this,e,n)||this;return s.propertyPath=r,s._target=s._effectiveTarget=i,s}return __extends(i,t),i.prototype._prepare=function(){this._effectiveTarget=this._getEffectiveTarget(this._effectiveTarget,this.propertyPath),this._property=this._getProperty(this.propertyPath)},i.prototype.execute=function(){this._effectiveTarget[this._property]=!this._effectiveTarget[this._property]},i.prototype.serialize=function(i){return t.prototype._serialize.call(this,{name:"SwitchBooleanAction",properties:[e.Action._GetTargetProperty(this._target),{name:"propertyPath",value:this.propertyPath}]},i)},i})(e.Action);e.SwitchBooleanAction=t;var i=(function(t){function i(e,i,r,n){var s=t.call(this,e,n)||this;return s.value=r,s._target=i,s}return __extends(i,t),i.prototype.execute=function(){this._target.state=this.value},i.prototype.serialize=function(i){return t.prototype._serialize.call(this,{name:"SetStateAction",properties:[e.Action._GetTargetProperty(this._target),{name:"value",value:this.value}]},i)},i})(e.Action);e.SetStateAction=i;var r=(function(t){function i(e,i,r,n,s){var o=t.call(this,e,s)||this;return o.propertyPath=r,o.value=n,o._target=o._effectiveTarget=i,o}return __extends(i,t),i.prototype._prepare=function(){this._effectiveTarget=this._getEffectiveTarget(this._effectiveTarget,this.propertyPath),this._property=this._getProperty(this.propertyPath)},i.prototype.execute=function(){this._effectiveTarget[this._property]=this.value,this._target.markAsDirty&&this._target.markAsDirty(this._property)},i.prototype.serialize=function(i){return t.prototype._serialize.call(this,{name:"SetValueAction",properties:[e.Action._GetTargetProperty(this._target),{name:"propertyPath",value:this.propertyPath},{name:"value",value:e.Action._SerializeValueAsString(this.value)}]},i)},i})(e.Action);e.SetValueAction=r;var n=(function(t){function i(e,i,r,n,s){var o=t.call(this,e,s)||this;return o.propertyPath=r,o.value=n,o._target=o._effectiveTarget=i,o}return __extends(i,t),i.prototype._prepare=function(){this._effectiveTarget=this._getEffectiveTarget(this._effectiveTarget,this.propertyPath),this._property=this._getProperty(this.propertyPath),"number"!=typeof this._effectiveTarget[this._property]&&e.Tools.Warn("Warning: IncrementValueAction can only be used with number values")},i.prototype.execute=function(){this._effectiveTarget[this._property]+=this.value,this._target.markAsDirty&&this._target.markAsDirty(this._property)},i.prototype.serialize=function(i){return t.prototype._serialize.call(this,{name:"IncrementValueAction",properties:[e.Action._GetTargetProperty(this._target),{name:"propertyPath",value:this.propertyPath},{name:"value",value:e.Action._SerializeValueAsString(this.value)}]},i)},i})(e.Action);e.IncrementValueAction=n;var s=(function(t){function i(e,i,r,n,s,o){var a=t.call(this,e,o)||this;return a.from=r,a.to=n,a.loop=s,a._target=i,a}return __extends(i,t),i.prototype._prepare=function(){},i.prototype.execute=function(){this._actionManager.getScene().beginAnimation(this._target,this.from,this.to,this.loop)},i.prototype.serialize=function(i){return t.prototype._serialize.call(this,{name:"PlayAnimationAction",properties:[e.Action._GetTargetProperty(this._target),{name:"from",value:String(this.from)},{name:"to",value:String(this.to)},{name:"loop",value:e.Action._SerializeValueAsString(this.loop)||!1}]},i)},i})(e.Action);e.PlayAnimationAction=s;var o=(function(t){function i(e,i,r){var n=t.call(this,e,r)||this;return n._target=i,n}return __extends(i,t),i.prototype._prepare=function(){},i.prototype.execute=function(){this._actionManager.getScene().stopAnimation(this._target)},i.prototype.serialize=function(i){return t.prototype._serialize.call(this,{name:"StopAnimationAction",properties:[e.Action._GetTargetProperty(this._target)]},i)},i})(e.Action);e.StopAnimationAction=o;var a=(function(t){function i(i,r){return void 0===i&&(i=e.ActionManager.NothingTrigger),t.call(this,i,r)||this}return __extends(i,t),i.prototype.execute=function(){},i.prototype.serialize=function(e){return t.prototype._serialize.call(this,{name:"DoNothingAction",properties:[]},e)},i})(e.Action);e.DoNothingAction=a;var h=(function(e){function t(t,i,r){var n=e.call(this,t,r)||this;return n.children=i,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 i=e.prototype._serialize.call(this,{name:"CombineAction",properties:[],combine:[]},t),r=0;r<this.children.length;r++)i.combine.push(this.children[r].serialize(null));return i},t})(e.Action);e.CombineAction=h;var u=(function(e){function t(t,i,r){var n=e.call(this,t,r)||this;return n.func=i,n}return __extends(t,e),t.prototype.execute=function(e){this.func(e)},t})(e.Action);e.ExecuteCodeAction=u;var c=(function(t){function i(e,i,r,n){var s=t.call(this,e,n)||this;return s._target=i,s._parent=r,s}return __extends(i,t),i.prototype._prepare=function(){},i.prototype.execute=function(){if(this._target.parent!==this._parent){var t=this._parent.getWorldMatrix().clone();t.invert(),this._target.position=e.Vector3.TransformCoordinates(this._target.position,t),this._target.parent=this._parent}},i.prototype.serialize=function(i){return t.prototype._serialize.call(this,{name:"SetParentAction",properties:[e.Action._GetTargetProperty(this._target),e.Action._GetTargetProperty(this._parent)]},i)},i})(e.Action);e.SetParentAction=c;var l=(function(e){function t(t,i,r){var n=e.call(this,t,r)||this;return n._sound=i,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=l;var f=(function(e){function t(t,i,r){var n=e.call(this,t,r)||this;return n._sound=i,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 i=(function(){function t(t,i,r,n,s){void 0===n&&(n=!0),void 0===s&&(s=1),this.skeleton=t,this.mesh=i,this.autoUpdateBonesMatrices=n,this.renderingGroupId=s,this.color=e.Color3.White(),this._debugLines=[],this._isEnabled=!1,this._scene=r,this.update(),this._renderFunction=this.update.bind(this)}return Object.defineProperty(t.prototype,"isEnabled",{get:function(){return this._isEnabled},set:function(e){this._isEnabled!==e&&(this._isEnabled=e,e?this._scene.registerBeforeRender(this._renderFunction):this._scene.unregisterBeforeRender(this._renderFunction))},enumerable:!0,configurable:!0}),t.prototype._getBonePosition=function(t,i,r,n,s,o){void 0===n&&(n=0),void 0===s&&(s=0),void 0===o&&(o=0);var a=e.Tmp.Matrix[0],h=i.getParent();if(a.copyFrom(i.getLocalMatrix()),0!==n||0!==s||0!==o){var u=e.Tmp.Matrix[1];e.Matrix.IdentityToRef(u),u.m[12]=n,u.m[13]=s,u.m[14]=o,u.multiplyToRef(a,a)}h&&a.multiplyToRef(h.getAbsoluteTransform(),a),a.multiplyToRef(r,a),t.x=a.m[12],t.y=a.m[13],t.z=a.m[14]},t.prototype._getLinesForBonesWithLength=function(t,i){for(var r=t.length,n=this.mesh.position,s=0;s<r;s++){var o=t[s],a=this._debugLines[s];a||(a=[e.Vector3.Zero(),e.Vector3.Zero()],this._debugLines[s]=a),this._getBonePosition(a[0],o,i),this._getBonePosition(a[1],o,i,0,o.length,0),a[0].subtractInPlace(n),a[1].subtractInPlace(n)}},t.prototype._getLinesForBonesNoLength=function(t,i){for(var r=t.length,n=0,s=this.mesh.position,o=r-1;o>=0;o--){var a=t[o],h=a.getParent();if(h){var u=this._debugLines[n];u||(u=[e.Vector3.Zero(),e.Vector3.Zero()],this._debugLines[n]=u),a.getAbsolutePositionToRef(this.mesh,u[0]),h.getAbsolutePositionToRef(this.mesh,u[1]),u[0].subtractInPlace(s),u[1].subtractInPlace(s),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=i})(e.Debug||(e.Debug={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(t){var i=(function(){function t(t,i){void 0===i&&(i=1),this._xline=[e.Vector3.Zero(),e.Vector3.Zero()],this._yline=[e.Vector3.Zero(),e.Vector3.Zero()],this._zline=[e.Vector3.Zero(),e.Vector3.Zero()],this.scaleLines=1,this.scaleLines=i,this._xmesh=e.Mesh.CreateLines("xline",this._xline,t,!0),this._ymesh=e.Mesh.CreateLines("yline",this._yline,t,!0),this._zmesh=e.Mesh.CreateLines("zline",this._zline,t,!0),this._xmesh.renderingGroupId=2,this._ymesh.renderingGroupId=2,this._zmesh.renderingGroupId=2,this._xmesh.material.checkReadyOnlyOnce=!0,this._xmesh.color=new e.Color3(1,0,0),this._ymesh.material.checkReadyOnlyOnce=!0,this._ymesh.color=new e.Color3(0,1,0),this._zmesh.material.checkReadyOnlyOnce=!0,this._zmesh.color=new e.Color3(0,0,1),this.scene=t}return t.prototype.update=function(t,i,r,n){var s=this.scaleLines;this._xmesh.position.copyFrom(t),this._ymesh.position.copyFrom(t),this._zmesh.position.copyFrom(t);var o=this._xline[1];o.x=i.x*s,o.y=i.y*s,o.z=i.z*s,e.Mesh.CreateLines(null,this._xline,null,null,this._xmesh),o=this._yline[1],o.x=r.x*s,o.y=r.y*s,o.z=r.z*s,e.Mesh.CreateLines(null,this._yline,null,null,this._ymesh),o=this._zline[1],o.x=n.x*s,o.y=n.y*s,o.z=n.z*s,e.Mesh.CreateLines(null,this._zline,null,null,this._zmesh)},t.prototype.dispose=function(){this._xmesh&&(this._xmesh.dispose(),this._ymesh.dispose(),this._zmesh.dispose(),this._xmesh=null,this._ymesh=null,this._zmesh=null,this._xline=null,this._yline=null,this._zline=null,this.scene=null)},t})();t.AxesViewer=i})(e.Debug||(e.Debug={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){!(function(t){var i=(function(t){function i(i,r,n,s){void 0===s&&(s=1);var o=t.call(this,i,s)||this;return o.pos=e.Vector3.Zero(),o.xaxis=e.Vector3.Zero(),o.yaxis=e.Vector3.Zero(),o.zaxis=e.Vector3.Zero(),o.mesh=n,o.bone=r,o}return __extends(i,t),i.prototype.update=function(){var i=this.bone;i.getAbsolutePositionToRef(this.mesh,this.pos),i.getDirectionToRef(e.Axis.X,this.mesh,this.xaxis),i.getDirectionToRef(e.Axis.Y,this.mesh,this.yaxis),i.getDirectionToRef(e.Axis.Z,this.mesh,this.zaxis),t.prototype.update.call(this,this.pos,this.xaxis,this.yaxis,this.zaxis)},i.prototype.dispose=function(){this.pos&&(this.pos=null,this.xaxis=null,this.yaxis=null,this.zaxis=null,this.mesh=null,this.bone=null,t.prototype.dispose.call(this))},i})(t.AxesViewer);t.BoneAxesViewer=i})(e.Debug||(e.Debug={}))})(BABYLON||(BABYLON={}));var BABYLON;!(function(e){var t=(function(){function t(e){this.ray=e}return t.CreateAndShow=function(e,i,r){var n=new t(e);return n.show(i,r),n},t.prototype.show=function(t,i){if(!this._renderFunction){var r=this.ray;this._renderFunction=this._render.bind(this),this._scene=t,this._renderPoints=[r.origin,r.origin.add(r.direction.scale(r.length))],this._renderLine=e.Mesh.CreateLines("ray",this._renderPoints,t,!0),this._scene.registerBeforeRender(this._renderFunction)}i&&this._renderLine.color.copyFrom(i)},t.prototype.hide=function(){this._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,i=this._renderPoints[1],r=Math.min(t.length,1e6);i.copyFrom(t.direction),i.scaleInPlace(r),i.addInPlace(t.origin),e.Mesh.CreateLines("ray",this._renderPoints,this._scene,!0,this._renderLine)},t.prototype.attachToMesh=function(t,i,r,n){this._attachedToMesh=t;var s=this.ray;s.direction||(s.direction=e.Vector3.Zero()),s.origin||(s.origin=e.Vector3.Zero()),n&&(s.length=n),r||(r=e.Vector3.Zero()),i||(i=new e.Vector3(0,0,-1)),this._meshSpaceDirection?(this._meshSpaceDirection.copyFrom(i),this._meshSpaceOrigin.copyFrom(r)):(this._meshSpaceDirection=i.clone(),this._meshSpaceOrigin=r.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,i=e.initialTab||0,r=e.parentElement||null;this._inspector||(this._inspector=new INSPECTOR.Inspector(this._scene,t,i,r,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(i){void 0===i&&(i={}),"undefined"==typeof INSPECTOR?e.Tools.LoadScript(t.InspectorURL,this._createInspector.bind(this,i)):this._createInspector(i)},t})();t.InspectorURL=window.location.href.split("/")[0]+"//www.babylonjs.com/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(),i=e.VertexData.CreateBox(1);this._vertexBuffers[e.VertexBuffer.PositionKind]=new e.VertexBuffer(t,i.positions,e.VertexBuffer.PositionKind,!1),this._indexBuffer=t.createIndexBuffer([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,7,1,6,2,5,3,4])}},t.prototype.reset=function(){this.renderList.reset()},t.prototype.render=function(){if(0!==this.renderList.length&&(this._prepareRessources(),this._colorShader.isReady())){var t=this._scene.getEngine();t.setDepthWrite(!1),this._colorShader._preBind();for(var i=0;i<this.renderList.length;i++){var r=this.renderList.data[i],n=r.minimum,s=r.maximum,o=s.subtract(n),a=n.add(o.scale(.5)),h=e.Matrix.Scaling(o.x,o.y,o.z).multiply(e.Matrix.Translation(a.x,a.y,a.z)).multiply(r.getWorldMatrix());t.bindBuffers(this._vertexBuffers,this._indexBuffer,this._colorShader.getEffect()),this.showBackLines&&(t.setDepthFunctionToGreaterOrEqual(),this._scene.resetCachedMaterial(),this._colorShader.setColor4("color",this.backColor.toColor4()),this._colorShader.bind(h),t.draw(!1,0,24)),t.setDepthFunctionToLess(),this._scene.resetCachedMaterial(),this._colorShader.setColor4("color",this.frontColor.toColor4()),this._colorShader.bind(h),t.draw(!1,0,24)}this._colorShader.unbind(),t.setDepthFunctionToLessOrEqual(),t.setDepthWrite(!0)}},t.prototype.dispose=function(){if(this._colorShader){this.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(t){function i(e,i){var r=t.call(this,e,i,!0)||this;return r.subMaterials=new Array,i.multiMaterials.push(r),r}return __extends(i,t),i.prototype.getSubMaterial=function(e){return e<0||e>=this.subMaterials.length?this.getScene().defaultMaterial:this.subMaterials[e]},i.prototype.getClassName=function(){return"MultiMaterial"},i.prototype.isReady=function(e){for(var t=0;t<this.subMaterials.length;t++){if(this.subMaterials[t]&&!this.subMaterials[t].isReady(e))return!1}return!0},i.prototype.clone=function(e,t){for(var r=new i(e,this.getScene()),n=0;n<this.subMaterials.length;n++){var s=null;s=t?this.subMaterials[n].clone(e+"-"+this.subMaterials[n].name):this.subMaterials[n],r.subMaterials.push(s)}return r},i.prototype.serialize=function(){var t={};t.name=this.name,t.id=this.id,t.tags=e.Tags.GetTags(this),t.materials=[];for(var i=0;i<this.subMaterials.length;i++){var r=this.subMaterials[i];r?t.materials.push(r.id):t.materials.push(null)}return t},i})(e.Material);e.MultiMaterial=t})(BABYLON||(BABYLON={})),BABYLON.Effect.ShadersStore={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<shadowsVertexDeclaration>[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}",
  22. 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",pointCloudVertexDeclaration:"#ifdef POINTSIZE\nuniform float pointSize;\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",shadowsVertexDeclaration:"#ifdef SHADOWS\n#if defined(SPOTLIGHT{X}) || defined(DIRLIGHT{X})\nuniform mat4 lightMatrix{X};\nvarying vec4 vPositionFromLight{X};\n#endif\n#endif\n",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(SPOTLIGHT{X}) || defined(DIRLIGHT{X})\nvPositionFromLight{X}=lightMatrix{X}*worldPos;\n#endif\n#endif",pointCloudVertex:"#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif",logDepthVertex:"#ifdef LOGARITHMICDEPTH\nvFragmentDepth=1.0+gl_Position.w;\ngl_Position.z=log2(max(0.000001,vFragmentDepth))*logarithmicDepthConstant;\n#endif",helperFunctions:"mat3 transposeMat3(mat3 inMatrix) {\nvec3 i0=inMatrix[0];\nvec3 i1=inMatrix[1];\nvec3 i2=inMatrix[2];\nmat3 outMatrix=mat3(\nvec3(i0.x,i1.x,i2.x),\nvec3(i0.y,i1.y,i2.y),\nvec3(i0.z,i1.z,i2.z)\n);\nreturn outMatrix;\n}",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(SPOTLIGHT{X}) || defined(DIRLIGHT{X})\nvarying vec4 vPositionFromLight{X};\nuniform sampler2D shadowSampler{X};\n#else\nuniform samplerCube shadowSampler{X};\n#endif\nuniform vec3 shadowsInfo{X};\n#endif\n#ifdef SPOTLIGHT{X}\nuniform vec4 vLightDirection{X};\n#endif\n#ifdef HEMILIGHT{X}\nuniform vec3 vLightGround{X};\n#endif\n#endif",lightsFragmentFunctions:"\nstruct lightingInfo\n{\nvec3 diffuse;\n#ifdef SPECULARTERM\nvec3 specular;\n#endif\n#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",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;\n} light{X};\n#ifdef SHADOW{X}\n#if defined(SPOTLIGHT{X}) || defined(DIRLIGHT{X})\nvarying vec4 vPositionFromLight{X};\nuniform sampler2D shadowSampler{X};\n#else\nuniform samplerCube shadowSampler{X};\n#endif\n#endif\n#endif",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};",shadowsFragmentFunctions:"#ifdef SHADOWS\n#ifndef SHADOWFULLFLOAT\nfloat unpack(vec4 color)\n{\nconst vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);\nreturn dot(color,bit_shift);\n}\n#endif\nuniform vec2 depthValues;\nfloat computeShadowCube(vec3 lightPosition,samplerCube shadowSampler,float darkness)\n{\nvec3 directionToLight=vPositionW-lightPosition;\nfloat depth=length(directionToLight);\ndepth=(depth-depthValues.x)/(depthValues.y-depthValues.x);\ndepth=clamp(depth,0.,1.0);\ndirectionToLight=normalize(directionToLight);\ndirectionToLight.y=-directionToLight.y;\n#ifndef SHADOWFULLFLOAT\nfloat shadow=unpack(textureCube(shadowSampler,directionToLight));\n#else\nfloat shadow=textureCube(shadowSampler,directionToLight).x;\n#endif\nif (depth>shadow)\n{\n#ifdef OVERLOADEDSHADOWVALUES\nreturn mix(1.0,darkness,vOverloadedShadowIntensity.x);\n#else\nreturn darkness;\n#endif\n}\nreturn 1.0;\n}\nfloat computeShadowWithPCFCube(vec3 lightPosition,samplerCube shadowSampler,float mapSize,float darkness)\n{\nvec3 directionToLight=vPositionW-lightPosition;\nfloat depth=length(directionToLight);\ndepth=(depth-depthValues.x)/(depthValues.y-depthValues.x);\ndepth=clamp(depth,0.,1.0);\ndirectionToLight=normalize(directionToLight);\ndirectionToLight.y=-directionToLight.y;\nfloat visibility=1.;\nvec3 poissonDisk[4];\npoissonDisk[0]=vec3(-1.0,1.0,-1.0);\npoissonDisk[1]=vec3(1.0,-1.0,-1.0);\npoissonDisk[2]=vec3(-1.0,-1.0,-1.0);\npoissonDisk[3]=vec3(1.0,-1.0,1.0);\n\n#ifndef SHADOWFULLFLOAT\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\n#ifdef OVERLOADEDSHADOWVALUES\nreturn min(1.0,mix(1.0,visibility+darkness,vOverloadedShadowIntensity.x));\n#else\nreturn min(1.0,visibility+darkness);\n#endif\n}\nfloat computeShadowWithESMCube(vec3 lightPosition,samplerCube shadowSampler,float darkness,float depthScale)\n{\nvec3 directionToLight=vPositionW-lightPosition;\nfloat depth=length(directionToLight);\ndepth=(depth-depthValues.x)/(depthValues.y-depthValues.x);\nfloat shadowPixelDepth=clamp(depth,0.,1.0);\ndirectionToLight=normalize(directionToLight);\ndirectionToLight.y=-directionToLight.y;\n#ifndef SHADOWFULLFLOAT\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.); \n#ifdef OVERLOADEDSHADOWVALUES\nreturn mix(1.0,esm,vOverloadedShadowIntensity.x);\n#else\nreturn esm;\n#endif\n}\nfloat computeShadow(vec4 vPositionFromLight,sampler2D shadowSampler,float darkness)\n{\nvec3 depth=vPositionFromLight.xyz/vPositionFromLight.w;\ndepth=0.5*depth+vec3(0.5);\nvec2 uv=depth.xy;\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\n#ifndef SHADOWFULLFLOAT\nfloat shadow=unpack(texture2D(shadowSampler,uv));\n#else\nfloat shadow=texture2D(shadowSampler,uv).x;\n#endif\nif (depth.z>shadow)\n{\n#ifdef OVERLOADEDSHADOWVALUES\nreturn mix(1.0,darkness,vOverloadedShadowIntensity.x);\n#else\nreturn darkness;\n#endif\n}\nreturn 1.;\n}\nfloat computeShadowWithPCF(vec4 vPositionFromLight,sampler2D shadowSampler,float mapSize,float darkness)\n{\nvec3 depth=vPositionFromLight.xyz/vPositionFromLight.w;\ndepth=0.5*depth+vec3(0.5);\nvec2 uv=depth.xy;\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nfloat visibility=1.;\nvec2 poissonDisk[4];\npoissonDisk[0]=vec2(-0.94201624,-0.39906216);\npoissonDisk[1]=vec2(0.94558609,-0.76890725);\npoissonDisk[2]=vec2(-0.094184101,-0.92938870);\npoissonDisk[3]=vec2(0.34495938,0.29387760);\n\n#ifndef SHADOWFULLFLOAT\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[0]*mapSize))<depth.z) visibility-=0.25;\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[1]*mapSize))<depth.z) visibility-=0.25;\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[2]*mapSize))<depth.z) visibility-=0.25;\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[3]*mapSize))<depth.z) visibility-=0.25;\n#else\nif (texture2D(shadowSampler,uv+poissonDisk[0]*mapSize).x<depth.z) visibility-=0.25;\nif (texture2D(shadowSampler,uv+poissonDisk[1]*mapSize).x<depth.z) visibility-=0.25;\nif (texture2D(shadowSampler,uv+poissonDisk[2]*mapSize).x<depth.z) visibility-=0.25;\nif (texture2D(shadowSampler,uv+poissonDisk[3]*mapSize).x<depth.z) visibility-=0.25;\n#endif\n#ifdef OVERLOADEDSHADOWVALUES\nreturn mix(1.0,min(1.0,visibility+darkness),vOverloadedShadowIntensity.x);\n#else\nreturn min(1.0,visibility+darkness);\n#endif\n}\nfloat computeShadowWithESM(vec4 vPositionFromLight,sampler2D shadowSampler,float darkness,float depthScale)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 depth=0.5*clipSpace+vec3(0.5);\nvec2 uv=depth.xy;\nfloat shadowPixelDepth=depth.z;\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\n#ifndef SHADOWFULLFLOAT\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\n#ifdef OVERLOADEDSHADOWVALUES\nreturn mix(1.0,esm,vOverloadedShadowIntensity.x);\n#else\nreturn esm;\n#endif\n}\n#endif",fresnelFunction:"#ifdef FRESNEL\nfloat computeFresnelTerm(vec3 viewDirection,vec3 worldNormal,float bias,float power)\n{\nfloat fresnelTerm=pow(bias+abs(dot(viewDirection,worldNormal)),power);\nreturn clamp(fresnelTerm,0.,1.);\n}\n#endif",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;",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}",colorCurvesDefinition:"uniform vec4 vCameraColorCurveNeutral;\nuniform vec4 vCameraColorCurvePositive;\nuniform vec4 vCameraColorCurveNegative;",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}",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\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",
  23. bumpFragment:"vec2 uvOffset=vec2(0.0,0.0);\n#if defined(BUMP) || defined(PARALLAX)\n#if defined(TANGENT) && defined(NORMAL)\nmat3 TBN=vTBN;\n#else\nmat3 TBN=cotangent_frame(normalW*vBumpInfos.y,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 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#ifdef SHADOW{X}\n#ifdef SHADOWESM{X}\n#if defined(POINTLIGHT{X})\nshadow=computeShadowWithESMCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z);\n#else\nshadow=computeShadowWithESM(vPositionFromLight{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z);\n#endif\n#else \n#ifdef SHADOWPCF{X}\n#if defined(POINTLIGHT{X})\nshadow=computeShadowWithPCFCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.x);\n#else\nshadow=computeShadowWithPCF(vPositionFromLight{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.x);\n#endif\n#else\n#if defined(POINTLIGHT{X})\nshadow=computeShadowCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x);\n#else\nshadow=computeShadow(vPositionFromLight{X},shadowSampler{X},light{X}.shadowsInfo.x);\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"},("undefined"!=typeof window&&window.module||"undefined"!=typeof module)&&void 0!==module.exports&&(module.exports=BABYLON);