babylon.js 2.1 MB

12345678910111213141516
  1. !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define("babylonjs",[],t):"object"==typeof exports?exports.babylonjs=t():e.BABYLON=t()}(window,function(){return function(e){var t={};function i(r){if(t[r])return t[r].exports;var n=t[r]={i:r,l:!1,exports:{}};return e[r].call(n.exports,n,n.exports,i),n.l=!0,n.exports}return i.m=e,i.c=t,i.d=function(e,t,r){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(i.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)i.d(r,n,function(t){return e[t]}.bind(null,n));return r},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="",i(i.s=119)}([function(e,t,i){"use strict";i.d(t,"u",function(){return s}),i.d(t,"v",function(){return a}),i.d(t,"h",function(){return c}),i.d(t,"e",function(){return l}),i.d(t,"f",function(){return u}),i.d(t,"w",function(){return h}),i.d(t,"x",function(){return d}),i.d(t,"y",function(){return f}),i.d(t,"r",function(){return p}),i.d(t,"q",function(){return _}),i.d(t,"j",function(){return g}),i.d(t,"n",function(){return m}),i.d(t,"z",function(){return v}),i.d(t,"i",function(){return y}),i.d(t,"s",function(){return r}),i.d(t,"c",function(){return T}),i.d(t,"d",function(){return E}),i.d(t,"k",function(){return b}),i.d(t,"a",function(){return x}),i.d(t,"b",function(){return A}),i.d(t,"l",function(){return P}),i.d(t,"m",function(){return R}),i.d(t,"g",function(){return S}),i.d(t,"p",function(){return C}),i.d(t,"o",function(){return M}),i.d(t,"t",function(){return O});var r,n=i(34),o=i(12),s=1/2.2,a=2.2,c=.001,l=function(){function e(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 e.prototype.toString=function(){return"{R: "+this.r+" G:"+this.g+" B:"+this.b+"}"},e.prototype.getClassName=function(){return"Color3"},e.prototype.getHashCode=function(){var e=this.r||0;return e=397*(e=397*e^(this.g||0))^(this.b||0)},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,this},e.prototype.toColor4=function(e){return void 0===e&&(e=1),new u(this.r,this.g,this.b,e)},e.prototype.asArray=function(){var e=new Array;return this.toArray(e,0),e},e.prototype.toLuminance=function(){return.3*this.r+.59*this.g+.11*this.b},e.prototype.multiply=function(t){return new e(this.r*t.r,this.g*t.g,this.b*t.b)},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,this},e.prototype.equals=function(e){return e&&this.r===e.r&&this.g===e.g&&this.b===e.b},e.prototype.equalsFloats=function(e,t,i){return this.r===e&&this.g===t&&this.b===i},e.prototype.scale=function(t){return new e(this.r*t,this.g*t,this.b*t)},e.prototype.scaleToRef=function(e,t){return t.r=this.r*e,t.g=this.g*e,t.b=this.b*e,this},e.prototype.scaleAndAddToRef=function(e,t){return t.r+=this.r*e,t.g+=this.g*e,t.b+=this.b*e,this},e.prototype.clampToRef=function(e,t,i){return void 0===e&&(e=0),void 0===t&&(t=1),i.r=o.a.Clamp(this.r,e,t),i.g=o.a.Clamp(this.g,e,t),i.b=o.a.Clamp(this.b,e,t),this},e.prototype.add=function(t){return new e(this.r+t.r,this.g+t.g,this.b+t.b)},e.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},e.prototype.subtract=function(t){return new e(this.r-t.r,this.g-t.g,this.b-t.b)},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,this},e.prototype.clone=function(){return new e(this.r,this.g,this.b)},e.prototype.copyFrom=function(e){return this.r=e.r,this.g=e.g,this.b=e.b,this},e.prototype.copyFromFloats=function(e,t,i){return this.r=e,this.g=t,this.b=i,this},e.prototype.set=function(e,t,i){return this.copyFromFloats(e,t,i)},e.prototype.toHexString=function(){var e=255*this.r|0,t=255*this.g|0,i=255*this.b|0;return"#"+o.a.ToHex(e)+o.a.ToHex(t)+o.a.ToHex(i)},e.prototype.toLinearSpace=function(){var t=new e;return this.toLinearSpaceToRef(t),t},e.prototype.toLinearSpaceToRef=function(e){return e.r=Math.pow(this.r,a),e.g=Math.pow(this.g,a),e.b=Math.pow(this.b,a),this},e.prototype.toGammaSpace=function(){var t=new e;return this.toGammaSpaceToRef(t),t},e.prototype.toGammaSpaceToRef=function(e){return e.r=Math.pow(this.r,s),e.g=Math.pow(this.g,s),e.b=Math.pow(this.b,s),this},e.FromHexString=function(t){if("#"!==t.substring(0,1)||7!==t.length)return new e(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);return e.FromInts(i,r,n)},e.FromArray=function(t,i){return void 0===i&&(i=0),new e(t[i],t[i+1],t[i+2])},e.FromInts=function(t,i,r){return new e(t/255,i/255,r/255)},e.Lerp=function(t,i,r){var n=new e(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},e.Red=function(){return new e(1,0,0)},e.Green=function(){return new e(0,1,0)},e.Blue=function(){return new e(0,0,1)},e.Black=function(){return new e(0,0,0)},Object.defineProperty(e,"BlackReadOnly",{get:function(){return e._BlackReadOnly},enumerable:!0,configurable:!0}),e.White=function(){return new e(1,1,1)},e.Purple=function(){return new e(.5,0,.5)},e.Magenta=function(){return new e(1,0,1)},e.Yellow=function(){return new e(1,1,0)},e.Gray=function(){return new e(.5,.5,.5)},e.Teal=function(){return new e(0,1,1)},e.Random=function(){return new e(Math.random(),Math.random(),Math.random())},e._BlackReadOnly=e.Black(),e}(),u=function(){function e(e,t,i,r){void 0===e&&(e=0),void 0===t&&(t=0),void 0===i&&(i=0),void 0===r&&(r=1),this.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=new Array;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.equals=function(e){return e&&this.r===e.r&&this.g===e.g&&this.b===e.b&&this.a===e.a},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.scaleAndAddToRef=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.clampToRef=function(e,t,i){return void 0===e&&(e=0),void 0===t&&(t=1),i.r=o.a.Clamp(this.r,e,t),i.g=o.a.Clamp(this.g,e,t),i.b=o.a.Clamp(this.b,e,t),i.a=o.a.Clamp(this.a,e,t),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=397*(e=397*e^(this.g||0))^(this.b||0))^(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,t=255*this.g|0,i=255*this.b|0,r=255*this.a|0;return"#"+o.a.ToHex(e)+o.a.ToHex(t)+o.a.ToHex(i)+o.a.ToHex(r)},e.prototype.toLinearSpace=function(){var t=new e;return this.toLinearSpaceToRef(t),t},e.prototype.toLinearSpaceToRef=function(e){return e.r=Math.pow(this.r,a),e.g=Math.pow(this.g,a),e.b=Math.pow(this.b,a),e.a=this.a,this},e.prototype.toGammaSpace=function(){var t=new e;return this.toGammaSpaceToRef(t),t},e.prototype.toGammaSpaceToRef=function(e){return e.r=Math.pow(this.r,s),e.g=Math.pow(this.g,s),e.b=Math.pow(this.b,s),e.a=this.a,this},e.FromHexString=function(t){if("#"!==t.substring(0,1)||9!==t.length)return new e(0,0,0,0);var i=parseInt(t.substring(1,3),16),r=parseInt(t.substring(3,5),16),n=parseInt(t.substring(5,7),16),o=parseInt(t.substring(7,9),16);return e.FromInts(i,r,n,o)},e.Lerp=function(t,i,r){var n=new e(0,0,0,0);return e.LerpToRef(t,i,r,n),n},e.LerpToRef=function(e,t,i,r){r.r=e.r+(t.r-e.r)*i,r.g=e.g+(t.g-e.g)*i,r.b=e.b+(t.b-e.b)*i,r.a=e.a+(t.a-e.a)*i},e.FromColor3=function(t,i){return void 0===i&&(i=1),new e(t.r,t.g,t.b,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}(),h=function(){function e(e,t){void 0===e&&(e=0),void 0===t&&(t=0),this.x=e,this.y=t}return e.prototype.toString=function(){return"{X: "+this.x+" Y:"+this.y+"}"},e.prototype.getClassName=function(){return"Vector2"},e.prototype.getHashCode=function(){var e=this.x||0;return e=397*e^(this.y||0)},e.prototype.toArray=function(e,t){return void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,this},e.prototype.asArray=function(){var e=new Array;return this.toArray(e,0),e},e.prototype.copyFrom=function(e){return this.x=e.x,this.y=e.y,this},e.prototype.copyFromFloats=function(e,t){return this.x=e,this.y=t,this},e.prototype.set=function(e,t){return this.copyFromFloats(e,t)},e.prototype.add=function(t){return new e(this.x+t.x,this.y+t.y)},e.prototype.addToRef=function(e,t){return t.x=this.x+e.x,t.y=this.y+e.y,this},e.prototype.addInPlace=function(e){return this.x+=e.x,this.y+=e.y,this},e.prototype.addVector3=function(t){return new e(this.x+t.x,this.y+t.y)},e.prototype.subtract=function(t){return new e(this.x-t.x,this.y-t.y)},e.prototype.subtractToRef=function(e,t){return t.x=this.x-e.x,t.y=this.y-e.y,this},e.prototype.subtractInPlace=function(e){return this.x-=e.x,this.y-=e.y,this},e.prototype.multiplyInPlace=function(e){return this.x*=e.x,this.y*=e.y,this},e.prototype.multiply=function(t){return new e(this.x*t.x,this.y*t.y)},e.prototype.multiplyToRef=function(e,t){return t.x=this.x*e.x,t.y=this.y*e.y,this},e.prototype.multiplyByFloats=function(t,i){return new e(this.x*t,this.y*i)},e.prototype.divide=function(t){return new e(this.x/t.x,this.y/t.y)},e.prototype.divideToRef=function(e,t){return t.x=this.x/e.x,t.y=this.y/e.y,this},e.prototype.divideInPlace=function(e){return this.divideToRef(e,this)},e.prototype.negate=function(){return new e(-this.x,-this.y)},e.prototype.scaleInPlace=function(e){return this.x*=e,this.y*=e,this},e.prototype.scale=function(t){var i=new e(0,0);return this.scaleToRef(t,i),i},e.prototype.scaleToRef=function(e,t){return t.x=this.x*e,t.y=this.y*e,this},e.prototype.scaleAndAddToRef=function(e,t){return t.x+=this.x*e,t.y+=this.y*e,this},e.prototype.equals=function(e){return e&&this.x===e.x&&this.y===e.y},e.prototype.equalsWithEpsilon=function(e,t){return void 0===t&&(t=c),e&&o.a.WithinEpsilon(this.x,e.x,t)&&o.a.WithinEpsilon(this.y,e.y,t)},e.prototype.floor=function(){return new e(Math.floor(this.x),Math.floor(this.y))},e.prototype.fract=function(){return new e(this.x-Math.floor(this.x),this.y-Math.floor(this.y))},e.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y)},e.prototype.lengthSquared=function(){return this.x*this.x+this.y*this.y},e.prototype.normalize=function(){var e=this.length();if(0===e)return this;var t=1/e;return this.x*=t,this.y*=t,this},e.prototype.clone=function(){return new e(this.x,this.y)},e.Zero=function(){return new e(0,0)},e.One=function(){return new e(1,1)},e.FromArray=function(t,i){return void 0===i&&(i=0),new e(t[i],t[i+1])},e.FromArrayToRef=function(e,t,i){i.x=e[t],i.y=e[t+1]},e.CatmullRom=function(t,i,r,n,o){var s=o*o,a=o*s;return new e(.5*(2*i.x+(-t.x+r.x)*o+(2*t.x-5*i.x+4*r.x-n.x)*s+(-t.x+3*i.x-3*r.x+n.x)*a),.5*(2*i.y+(-t.y+r.y)*o+(2*t.y-5*i.y+4*r.y-n.y)*s+(-t.y+3*i.y-3*r.y+n.y)*a))},e.Clamp=function(t,i,r){var n=t.x;n=(n=n>r.x?r.x:n)<i.x?i.x:n;var o=t.y;return new e(n,o=(o=o>r.y?r.y:o)<i.y?i.y:o)},e.Hermite=function(t,i,r,n,o){var s=o*o,a=o*s,c=2*a-3*s+1,l=-2*a+3*s,u=a-2*s+o,h=a-s;return new e(t.x*c+r.x*l+i.x*u+n.x*h,t.y*c+r.y*l+i.y*u+n.y*h)},e.Lerp=function(t,i,r){return new e(t.x+(i.x-t.x)*r,t.y+(i.y-t.y)*r)},e.Dot=function(e,t){return e.x*t.x+e.y*t.y},e.Normalize=function(e){var t=e.clone();return t.normalize(),t},e.Minimize=function(t,i){return new e(t.x<i.x?t.x:i.x,t.y<i.y?t.y:i.y)},e.Maximize=function(t,i){return new e(t.x>i.x?t.x:i.x,t.y>i.y?t.y:i.y)},e.Transform=function(t,i){var r=e.Zero();return e.TransformToRef(t,i,r),r},e.TransformToRef=function(e,t,i){var r=t.m,n=e.x*r[0]+e.y*r[4]+r[12],o=e.x*r[1]+e.y*r[5]+r[13];i.x=n,i.y=o},e.PointInTriangle=function(e,t,i,r){var n=.5*(-i.y*r.x+t.y*(-i.x+r.x)+t.x*(i.y-r.y)+i.x*r.y),o=n<0?-1:1,s=(t.y*r.x-t.x*r.y+(r.y-t.y)*e.x+(t.x-r.x)*e.y)*o,a=(t.x*i.y-t.y*i.x+(t.y-i.y)*e.x+(i.x-t.x)*e.y)*o;return s>0&&a>0&&s+a<2*n*o},e.Distance=function(t,i){return Math.sqrt(e.DistanceSquared(t,i))},e.DistanceSquared=function(e,t){var i=e.x-t.x,r=e.y-t.y;return i*i+r*r},e.Center=function(e,t){var i=e.add(t);return i.scaleInPlace(.5),i},e.DistanceOfPointFromSegment=function(t,i,r){var n=e.DistanceSquared(i,r);if(0===n)return e.Distance(t,i);var o=r.subtract(i),s=Math.max(0,Math.min(1,e.Dot(t.subtract(i),o)/n)),a=i.add(o.multiplyByFloats(s,s));return e.Distance(t,a)},e}(),d=function(){function e(e,t,i){void 0===e&&(e=0),void 0===t&&(t=0),void 0===i&&(i=0),this.x=e,this.y=t,this.z=i}return e.prototype.toString=function(){return"{X: "+this.x+" Y:"+this.y+" Z:"+this.z+"}"},e.prototype.getClassName=function(){return"Vector3"},e.prototype.getHashCode=function(){var e=this.x||0;return e=397*(e=397*e^(this.y||0))^(this.z||0)},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.x,e[t+1]=this.y,e[t+2]=this.z,this},e.prototype.toQuaternion=function(){return _.RotationYawPitchRoll(this.y,this.x,this.z)},e.prototype.addInPlace=function(e){return this.addInPlaceFromFloats(e.x,e.y,e.z)},e.prototype.addInPlaceFromFloats=function(e,t,i){return this.x+=e,this.y+=t,this.z+=i,this},e.prototype.add=function(t){return new e(this.x+t.x,this.y+t.y,this.z+t.z)},e.prototype.addToRef=function(e,t){return t.copyFromFloats(this.x+e.x,this.y+e.y,this.z+e.z)},e.prototype.subtractInPlace=function(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this},e.prototype.subtract=function(t){return new e(this.x-t.x,this.y-t.y,this.z-t.z)},e.prototype.subtractToRef=function(e,t){return this.subtractFromFloatsToRef(e.x,e.y,e.z,t)},e.prototype.subtractFromFloats=function(t,i,r){return new e(this.x-t,this.y-i,this.z-r)},e.prototype.subtractFromFloatsToRef=function(e,t,i,r){return r.copyFromFloats(this.x-e,this.y-t,this.z-i)},e.prototype.negate=function(){return new e(-this.x,-this.y,-this.z)},e.prototype.scaleInPlace=function(e){return this.x*=e,this.y*=e,this.z*=e,this},e.prototype.scale=function(t){return new e(this.x*t,this.y*t,this.z*t)},e.prototype.scaleToRef=function(e,t){return t.copyFromFloats(this.x*e,this.y*e,this.z*e)},e.prototype.scaleAndAddToRef=function(e,t){return t.addInPlaceFromFloats(this.x*e,this.y*e,this.z*e)},e.prototype.equals=function(e){return e&&this.x===e.x&&this.y===e.y&&this.z===e.z},e.prototype.equalsWithEpsilon=function(e,t){return void 0===t&&(t=c),e&&o.a.WithinEpsilon(this.x,e.x,t)&&o.a.WithinEpsilon(this.y,e.y,t)&&o.a.WithinEpsilon(this.z,e.z,t)},e.prototype.equalsToFloats=function(e,t,i){return this.x===e&&this.y===t&&this.z===i},e.prototype.multiplyInPlace=function(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this},e.prototype.multiply=function(e){return this.multiplyByFloats(e.x,e.y,e.z)},e.prototype.multiplyToRef=function(e,t){return t.copyFromFloats(this.x*e.x,this.y*e.y,this.z*e.z)},e.prototype.multiplyByFloats=function(t,i,r){return new e(this.x*t,this.y*i,this.z*r)},e.prototype.divide=function(t){return new e(this.x/t.x,this.y/t.y,this.z/t.z)},e.prototype.divideToRef=function(e,t){return t.copyFromFloats(this.x/e.x,this.y/e.y,this.z/e.z)},e.prototype.divideInPlace=function(e){return this.divideToRef(e,this)},e.prototype.minimizeInPlace=function(e){return this.minimizeInPlaceFromFloats(e.x,e.y,e.z)},e.prototype.maximizeInPlace=function(e){return this.maximizeInPlaceFromFloats(e.x,e.y,e.z)},e.prototype.minimizeInPlaceFromFloats=function(e,t,i){return e<this.x&&(this.x=e),t<this.y&&(this.y=t),i<this.z&&(this.z=i),this},e.prototype.maximizeInPlaceFromFloats=function(e,t,i){return e>this.x&&(this.x=e),t>this.y&&(this.y=t),i>this.z&&(this.z=i),this},e.prototype.isNonUniformWithinEpsilon=function(e){var t=Math.abs(this.x),i=Math.abs(this.y);if(!o.a.WithinEpsilon(t,i,e))return!0;var r=Math.abs(this.z);return!o.a.WithinEpsilon(t,r,e)||!o.a.WithinEpsilon(i,r,e)},Object.defineProperty(e.prototype,"isNonUniform",{get:function(){var e=Math.abs(this.x),t=Math.abs(this.y);if(e!==t)return!0;var i=Math.abs(this.z);return e!==i||t!==i},enumerable:!0,configurable:!0}),e.prototype.floor=function(){return new e(Math.floor(this.x),Math.floor(this.y),Math.floor(this.z))},e.prototype.fract=function(){return new e(this.x-Math.floor(this.x),this.y-Math.floor(this.y),this.z-Math.floor(this.z))},e.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},e.prototype.lengthSquared=function(){return this.x*this.x+this.y*this.y+this.z*this.z},e.prototype.normalize=function(){return this.normalizeFromLength(this.length())},e.prototype.reorderInPlace=function(e){var t=this;return"xyz"===(e=e.toLowerCase())?this:(I.Vector3[0].copyFrom(this),["x","y","z"].forEach(function(i,r){t[i]=I.Vector3[0][e[r]]}),this)},e.prototype.rotateByQuaternionToRef=function(t,i){return t.toRotationMatrix(I.Matrix[0]),e.TransformCoordinatesToRef(this,I.Matrix[0],i),i},e.prototype.rotateByQuaternionAroundPointToRef=function(e,t,i){return this.subtractToRef(t,I.Vector3[0]),I.Vector3[0].rotateByQuaternionToRef(e,I.Vector3[0]),t.addToRef(I.Vector3[0],i),i},e.prototype.normalizeFromLength=function(e){return 0===e||1===e?this:this.scaleInPlace(1/e)},e.prototype.normalizeToNew=function(){var t=new e(0,0,0);return this.normalizeToRef(t),t},e.prototype.normalizeToRef=function(e){var t=this.length();return 0===t||1===t?e.copyFromFloats(this.x,this.y,this.z):this.scaleToRef(1/t,e)},e.prototype.clone=function(){return new e(this.x,this.y,this.z)},e.prototype.copyFrom=function(e){return this.copyFromFloats(e.x,e.y,e.z)},e.prototype.copyFromFloats=function(e,t,i){return this.x=e,this.y=t,this.z=i,this},e.prototype.set=function(e,t,i){return this.copyFromFloats(e,t,i)},e.prototype.setAll=function(e){return this.x=this.y=this.z=e,this},e.GetClipFactor=function(t,i,r,n){var o=e.Dot(t,r)-n;return o/(o-(e.Dot(i,r)-n))},e.GetAngleBetweenVectors=function(t,i,r){var n=t.normalizeToRef(I.Vector3[1]),o=i.normalizeToRef(I.Vector3[2]),s=e.Dot(n,o),a=I.Vector3[3];return e.CrossToRef(n,o,a),e.Dot(a,r)>0?Math.acos(s):-Math.acos(s)},e.FromArray=function(t,i){return void 0===i&&(i=0),new e(t[i],t[i+1],t[i+2])},e.FromFloatArray=function(t,i){return e.FromArray(t,i)},e.FromArrayToRef=function(e,t,i){i.x=e[t],i.y=e[t+1],i.z=e[t+2]},e.FromFloatArrayToRef=function(t,i,r){return e.FromArrayToRef(t,i,r)},e.FromFloatsToRef=function(e,t,i,r){r.copyFromFloats(e,t,i)},e.Zero=function(){return new e(0,0,0)},e.One=function(){return new e(1,1,1)},e.Up=function(){return new e(0,1,0)},Object.defineProperty(e,"UpReadOnly",{get:function(){return e._UpReadOnly},enumerable:!0,configurable:!0}),e.Down=function(){return new e(0,-1,0)},e.Forward=function(){return new e(0,0,1)},e.Backward=function(){return new e(0,0,-1)},e.Right=function(){return new e(1,0,0)},e.Left=function(){return new e(-1,0,0)},e.TransformCoordinates=function(t,i){var r=e.Zero();return e.TransformCoordinatesToRef(t,i,r),r},e.TransformCoordinatesToRef=function(t,i,r){e.TransformCoordinatesFromFloatsToRef(t.x,t.y,t.z,i,r)},e.TransformCoordinatesFromFloatsToRef=function(e,t,i,r,n){var o=r.m,s=e*o[0]+t*o[4]+i*o[8]+o[12],a=e*o[1]+t*o[5]+i*o[9]+o[13],c=e*o[2]+t*o[6]+i*o[10]+o[14],l=1/(e*o[3]+t*o[7]+i*o[11]+o[15]);n.x=s*l,n.y=a*l,n.z=c*l},e.TransformNormal=function(t,i){var r=e.Zero();return e.TransformNormalToRef(t,i,r),r},e.TransformNormalToRef=function(e,t,i){this.TransformNormalFromFloatsToRef(e.x,e.y,e.z,t,i)},e.TransformNormalFromFloatsToRef=function(e,t,i,r,n){var o=r.m;n.x=e*o[0]+t*o[4]+i*o[8],n.y=e*o[1]+t*o[5]+i*o[9],n.z=e*o[2]+t*o[6]+i*o[10]},e.CatmullRom=function(t,i,r,n,o){var s=o*o,a=o*s;return new e(.5*(2*i.x+(-t.x+r.x)*o+(2*t.x-5*i.x+4*r.x-n.x)*s+(-t.x+3*i.x-3*r.x+n.x)*a),.5*(2*i.y+(-t.y+r.y)*o+(2*t.y-5*i.y+4*r.y-n.y)*s+(-t.y+3*i.y-3*r.y+n.y)*a),.5*(2*i.z+(-t.z+r.z)*o+(2*t.z-5*i.z+4*r.z-n.z)*s+(-t.z+3*i.z-3*r.z+n.z)*a))},e.Clamp=function(t,i,r){var n=new e;return e.ClampToRef(t,i,r,n),n},e.ClampToRef=function(e,t,i,r){var n=e.x;n=(n=n>i.x?i.x:n)<t.x?t.x:n;var o=e.y;o=(o=o>i.y?i.y:o)<t.y?t.y:o;var s=e.z;s=(s=s>i.z?i.z:s)<t.z?t.z:s,r.copyFromFloats(n,o,s)},e.Hermite=function(t,i,r,n,o){var s=o*o,a=o*s,c=2*a-3*s+1,l=-2*a+3*s,u=a-2*s+o,h=a-s;return new e(t.x*c+r.x*l+i.x*u+n.x*h,t.y*c+r.y*l+i.y*u+n.y*h,t.z*c+r.z*l+i.z*u+n.z*h)},e.Lerp=function(t,i,r){var n=new e(0,0,0);return e.LerpToRef(t,i,r,n),n},e.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},e.Dot=function(e,t){return e.x*t.x+e.y*t.y+e.z*t.z},e.Cross=function(t,i){var r=e.Zero();return e.CrossToRef(t,i,r),r},e.CrossToRef=function(e,t,i){var r=e.y*t.z-e.z*t.y,n=e.z*t.x-e.x*t.z,o=e.x*t.y-e.y*t.x;i.copyFromFloats(r,n,o)},e.Normalize=function(t){var i=e.Zero();return e.NormalizeToRef(t,i),i},e.NormalizeToRef=function(e,t){e.normalizeToRef(t)},e.Project=function(t,i,r,n){var o=n.width,s=n.height,a=n.x,c=n.y,l=I.Matrix[1];g.FromValuesToRef(o/2,0,0,0,0,-s/2,0,0,0,0,.5,0,a+o/2,s/2+c,.5,1,l);var u=I.Matrix[0];return i.multiplyToRef(r,u),u.multiplyToRef(l,u),e.TransformCoordinates(t,u)},e._UnprojectFromInvertedMatrixToRef=function(t,i,r){e.TransformCoordinatesToRef(t,i,r);var n=i.m,s=t.x*n[3]+t.y*n[7]+t.z*n[11]+n[15];o.a.WithinEpsilon(s,1)&&r.scaleInPlace(1/s)},e.UnprojectFromTransform=function(t,i,r,n,o){var s=I.Matrix[0];n.multiplyToRef(o,s),s.invert(),t.x=t.x/i*2-1,t.y=-(t.y/r*2-1);var a=new e;return e._UnprojectFromInvertedMatrixToRef(t,s,a),a},e.Unproject=function(t,i,r,n,o,s){var a=e.Zero();return e.UnprojectToRef(t,i,r,n,o,s,a),a},e.UnprojectToRef=function(t,i,r,n,o,s,a){e.UnprojectFloatsToRef(t.x,t.y,t.z,i,r,n,o,s,a)},e.UnprojectFloatsToRef=function(t,i,r,n,o,s,a,c,l){var u=I.Matrix[0];s.multiplyToRef(a,u),u.multiplyToRef(c,u),u.invert();var h=I.Vector3[0];h.x=t/n*2-1,h.y=-(i/o*2-1),h.z=2*r-1,e._UnprojectFromInvertedMatrixToRef(h,u,l)},e.Minimize=function(e,t){var i=e.clone();return i.minimizeInPlace(t),i},e.Maximize=function(e,t){var i=e.clone();return i.maximizeInPlace(t),i},e.Distance=function(t,i){return Math.sqrt(e.DistanceSquared(t,i))},e.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},e.Center=function(e,t){var i=e.add(t);return i.scaleInPlace(.5),i},e.RotationFromAxis=function(t,i,r){var n=e.Zero();return e.RotationFromAxisToRef(t,i,r,n),n},e.RotationFromAxisToRef=function(e,t,i,r){var n=I.Quaternion[0];_.RotationQuaternionFromAxisToRef(e,t,i,n),n.toEulerAnglesToRef(r)},e._UpReadOnly=e.Up(),e}(),f=function(){function e(e,t,i,r){this.x=e,this.y=t,this.z=i,this.w=r}return e.prototype.toString=function(){return"{X: "+this.x+" Y:"+this.y+" Z:"+this.z+" W:"+this.w+"}"},e.prototype.getClassName=function(){return"Vector4"},e.prototype.getHashCode=function(){var e=this.x||0;return e=397*(e=397*(e=397*e^(this.y||0))^(this.z||0))^(this.w||0)},e.prototype.asArray=function(){var e=new Array;return this.toArray(e,0),e},e.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},e.prototype.addInPlace=function(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this},e.prototype.add=function(t){return new e(this.x+t.x,this.y+t.y,this.z+t.z,this.w+t.w)},e.prototype.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},e.prototype.subtractInPlace=function(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this},e.prototype.subtract=function(t){return new e(this.x-t.x,this.y-t.y,this.z-t.z,this.w-t.w)},e.prototype.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},e.prototype.subtractFromFloats=function(t,i,r,n){return new e(this.x-t,this.y-i,this.z-r,this.w-n)},e.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},e.prototype.negate=function(){return new e(-this.x,-this.y,-this.z,-this.w)},e.prototype.scaleInPlace=function(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this},e.prototype.scale=function(t){return new e(this.x*t,this.y*t,this.z*t,this.w*t)},e.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},e.prototype.scaleAndAddToRef=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},e.prototype.equals=function(e){return e&&this.x===e.x&&this.y===e.y&&this.z===e.z&&this.w===e.w},e.prototype.equalsWithEpsilon=function(e,t){return void 0===t&&(t=c),e&&o.a.WithinEpsilon(this.x,e.x,t)&&o.a.WithinEpsilon(this.y,e.y,t)&&o.a.WithinEpsilon(this.z,e.z,t)&&o.a.WithinEpsilon(this.w,e.w,t)},e.prototype.equalsToFloats=function(e,t,i,r){return this.x===e&&this.y===t&&this.z===i&&this.w===r},e.prototype.multiplyInPlace=function(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this},e.prototype.multiply=function(t){return new e(this.x*t.x,this.y*t.y,this.z*t.z,this.w*t.w)},e.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},e.prototype.multiplyByFloats=function(t,i,r,n){return new e(this.x*t,this.y*i,this.z*r,this.w*n)},e.prototype.divide=function(t){return new e(this.x/t.x,this.y/t.y,this.z/t.z,this.w/t.w)},e.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},e.prototype.divideInPlace=function(e){return this.divideToRef(e,this)},e.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},e.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},e.prototype.floor=function(){return new e(Math.floor(this.x),Math.floor(this.y),Math.floor(this.z),Math.floor(this.w))},e.prototype.fract=function(){return new e(this.x-Math.floor(this.x),this.y-Math.floor(this.y),this.z-Math.floor(this.z),this.w-Math.floor(this.w))},e.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},e.prototype.lengthSquared=function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},e.prototype.normalize=function(){var e=this.length();return 0===e?this:this.scaleInPlace(1/e)},e.prototype.toVector3=function(){return new d(this.x,this.y,this.z)},e.prototype.clone=function(){return new e(this.x,this.y,this.z,this.w)},e.prototype.copyFrom=function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w,this},e.prototype.copyFromFloats=function(e,t,i,r){return this.x=e,this.y=t,this.z=i,this.w=r,this},e.prototype.set=function(e,t,i,r){return this.copyFromFloats(e,t,i,r)},e.prototype.setAll=function(e){return this.x=this.y=this.z=this.w=e,this},e.FromArray=function(t,i){return i||(i=0),new e(t[i],t[i+1],t[i+2],t[i+3])},e.FromArrayToRef=function(e,t,i){i.x=e[t],i.y=e[t+1],i.z=e[t+2],i.w=e[t+3]},e.FromFloatArrayToRef=function(t,i,r){e.FromArrayToRef(t,i,r)},e.FromFloatsToRef=function(e,t,i,r,n){n.x=e,n.y=t,n.z=i,n.w=r},e.Zero=function(){return new e(0,0,0,0)},e.One=function(){return new e(1,1,1,1)},e.Normalize=function(t){var i=e.Zero();return e.NormalizeToRef(t,i),i},e.NormalizeToRef=function(e,t){t.copyFrom(e),t.normalize()},e.Minimize=function(e,t){var i=e.clone();return i.minimizeInPlace(t),i},e.Maximize=function(e,t){var i=e.clone();return i.maximizeInPlace(t),i},e.Distance=function(t,i){return Math.sqrt(e.DistanceSquared(t,i))},e.DistanceSquared=function(e,t){var i=e.x-t.x,r=e.y-t.y,n=e.z-t.z,o=e.w-t.w;return i*i+r*r+n*n+o*o},e.Center=function(e,t){var i=e.add(t);return i.scaleInPlace(.5),i},e.TransformNormal=function(t,i){var r=e.Zero();return e.TransformNormalToRef(t,i,r),r},e.TransformNormalToRef=function(e,t,i){var r=t.m,n=e.x*r[0]+e.y*r[4]+e.z*r[8],o=e.x*r[1]+e.y*r[5]+e.z*r[9],s=e.x*r[2]+e.y*r[6]+e.z*r[10];i.x=n,i.y=o,i.z=s,i.w=e.w},e.TransformNormalFromFloatsToRef=function(e,t,i,r,n,o){var s=n.m;o.x=e*s[0]+t*s[4]+i*s[8],o.y=e*s[1]+t*s[5]+i*s[9],o.z=e*s[2]+t*s[6]+i*s[10],o.w=r},e.FromVector3=function(t,i){return void 0===i&&(i=0),new e(t.x,t.y,t.z,i)},e}(),p=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}(),_=function(){function e(e,t,i,r){void 0===e&&(e=0),void 0===t&&(t=0),void 0===i&&(i=0),void 0===r&&(r=1),this.x=e,this.y=t,this.z=i,this.w=r}return e.prototype.toString=function(){return"{X: "+this.x+" Y:"+this.y+" Z:"+this.z+" W:"+this.w+"}"},e.prototype.getClassName=function(){return"Quaternion"},e.prototype.getHashCode=function(){var e=this.x||0;return e=397*(e=397*(e=397*e^(this.y||0))^(this.z||0))^(this.w||0)},e.prototype.asArray=function(){return[this.x,this.y,this.z,this.w]},e.prototype.equals=function(e){return e&&this.x===e.x&&this.y===e.y&&this.z===e.z&&this.w===e.w},e.prototype.clone=function(){return new e(this.x,this.y,this.z,this.w)},e.prototype.copyFrom=function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w,this},e.prototype.copyFromFloats=function(e,t,i,r){return this.x=e,this.y=t,this.z=i,this.w=r,this},e.prototype.set=function(e,t,i,r){return this.copyFromFloats(e,t,i,r)},e.prototype.add=function(t){return new e(this.x+t.x,this.y+t.y,this.z+t.z,this.w+t.w)},e.prototype.addInPlace=function(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this},e.prototype.subtract=function(t){return new e(this.x-t.x,this.y-t.y,this.z-t.z,this.w-t.w)},e.prototype.scale=function(t){return new e(this.x*t,this.y*t,this.z*t,this.w*t)},e.prototype.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},e.prototype.scaleInPlace=function(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this},e.prototype.scaleAndAddToRef=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},e.prototype.multiply=function(t){var i=new e(0,0,0,1);return this.multiplyToRef(t,i),i},e.prototype.multiplyToRef=function(e,t){var i=this.x*e.w+this.y*e.z-this.z*e.y+this.w*e.x,r=-this.x*e.z+this.y*e.w+this.z*e.x+this.w*e.y,n=this.x*e.y-this.y*e.x+this.z*e.w+this.w*e.z,o=-this.x*e.x-this.y*e.y-this.z*e.z+this.w*e.w;return t.copyFromFloats(i,r,n,o),this},e.prototype.multiplyInPlace=function(e){return this.multiplyToRef(e,this),this},e.prototype.conjugateToRef=function(e){return e.copyFromFloats(-this.x,-this.y,-this.z,this.w),this},e.prototype.conjugateInPlace=function(){return this.x*=-1,this.y*=-1,this.z*=-1,this},e.prototype.conjugate=function(){return new e(-this.x,-this.y,-this.z,this.w)},e.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},e.prototype.normalize=function(){var e=1/this.length();return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this},e.prototype.toEulerAngles=function(e){void 0===e&&(e="YZX");var t=d.Zero();return this.toEulerAnglesToRef(t),t},e.prototype.toEulerAnglesToRef=function(e){var t=this.z,i=this.x,r=this.y,n=this.w,o=n*n,s=t*t,a=i*i,c=r*r,l=r*t-i*n;return l<-.4999999?(e.y=2*Math.atan2(r,n),e.x=Math.PI/2,e.z=0):l>.4999999?(e.y=2*Math.atan2(r,n),e.x=-Math.PI/2,e.z=0):(e.z=Math.atan2(2*(i*r+t*n),-s-a+c+o),e.x=Math.asin(-2*(t*r-i*n)),e.y=Math.atan2(2*(t*i+r*n),s-a-c+o)),this},e.prototype.toRotationMatrix=function(e){return g.FromQuaternionToRef(this,e),this},e.prototype.fromRotationMatrix=function(t){return e.FromRotationMatrixToRef(t,this),this},e.FromRotationMatrix=function(t){var i=new e;return e.FromRotationMatrixToRef(t,i),i},e.FromRotationMatrixToRef=function(e,t){var i,r=e.m,n=r[0],o=r[4],s=r[8],a=r[1],c=r[5],l=r[9],u=r[2],h=r[6],d=r[10],f=n+c+d;f>0?(i=.5/Math.sqrt(f+1),t.w=.25/i,t.x=(h-l)*i,t.y=(s-u)*i,t.z=(a-o)*i):n>c&&n>d?(i=2*Math.sqrt(1+n-c-d),t.w=(h-l)/i,t.x=.25*i,t.y=(o+a)/i,t.z=(s+u)/i):c>d?(i=2*Math.sqrt(1+c-n-d),t.w=(s-u)/i,t.x=(o+a)/i,t.y=.25*i,t.z=(l+h)/i):(i=2*Math.sqrt(1+d-n-c),t.w=(a-o)/i,t.x=(s+u)/i,t.y=(l+h)/i,t.z=.25*i)},e.Dot=function(e,t){return e.x*t.x+e.y*t.y+e.z*t.z+e.w*t.w},e.AreClose=function(t,i){return e.Dot(t,i)>=0},e.Zero=function(){return new e(0,0,0,0)},e.Inverse=function(t){return new e(-t.x,-t.y,-t.z,t.w)},e.InverseToRef=function(e,t){return t.set(-e.x,-e.y,-e.z,e.w),t},e.Identity=function(){return new e(0,0,0,1)},e.IsIdentity=function(e){return e&&0===e.x&&0===e.y&&0===e.z&&1===e.w},e.RotationAxis=function(t,i){return e.RotationAxisToRef(t,i,new e)},e.RotationAxisToRef=function(e,t,i){var r=Math.sin(t/2);return e.normalize(),i.w=Math.cos(t/2),i.x=e.x*r,i.y=e.y*r,i.z=e.z*r,i},e.FromArray=function(t,i){return i||(i=0),new e(t[i],t[i+1],t[i+2],t[i+3])},e.FromEulerAngles=function(t,i,r){var n=new e;return e.RotationYawPitchRollToRef(i,t,r,n),n},e.FromEulerAnglesToRef=function(t,i,r,n){return e.RotationYawPitchRollToRef(i,t,r,n),n},e.FromEulerVector=function(t){var i=new e;return e.RotationYawPitchRollToRef(t.y,t.x,t.z,i),i},e.FromEulerVectorToRef=function(t,i){return e.RotationYawPitchRollToRef(t.y,t.x,t.z,i),i},e.RotationYawPitchRoll=function(t,i,r){var n=new e;return e.RotationYawPitchRollToRef(t,i,r,n),n},e.RotationYawPitchRollToRef=function(e,t,i,r){var n=.5*i,o=.5*t,s=.5*e,a=Math.sin(n),c=Math.cos(n),l=Math.sin(o),u=Math.cos(o),h=Math.sin(s),d=Math.cos(s);r.x=d*l*c+h*u*a,r.y=h*u*c-d*l*a,r.z=d*u*a-h*l*c,r.w=d*u*c+h*l*a},e.RotationAlphaBetaGamma=function(t,i,r){var n=new e;return e.RotationAlphaBetaGammaToRef(t,i,r,n),n},e.RotationAlphaBetaGammaToRef=function(e,t,i,r){var n=.5*(i+e),o=.5*(i-e),s=.5*t;r.x=Math.cos(o)*Math.sin(s),r.y=Math.sin(o)*Math.sin(s),r.z=Math.sin(n)*Math.cos(s),r.w=Math.cos(n)*Math.cos(s)},e.RotationQuaternionFromAxis=function(t,i,r){var n=new e(0,0,0,0);return e.RotationQuaternionFromAxisToRef(t,i,r,n),n},e.RotationQuaternionFromAxisToRef=function(t,i,r,n){var o=I.Matrix[0];g.FromXYZAxesToRef(t.normalize(),i.normalize(),r.normalize(),o),e.FromRotationMatrixToRef(o,n)},e.Slerp=function(t,i,r){var n=e.Identity();return e.SlerpToRef(t,i,r,n),n},e.SlerpToRef=function(e,t,i,r){var n,o,s=e.x*t.x+e.y*t.y+e.z*t.z+e.w*t.w,a=!1;if(s<0&&(a=!0,s=-s),s>.999999)o=1-i,n=a?-i:i;else{var c=Math.acos(s),l=1/Math.sin(c);o=Math.sin((1-i)*c)*l,n=a?-Math.sin(i*c)*l:Math.sin(i*c)*l}r.x=o*e.x+n*t.x,r.y=o*e.y+n*t.y,r.z=o*e.z+n*t.z,r.w=o*e.w+n*t.w},e.Hermite=function(t,i,r,n,o){var s=o*o,a=o*s,c=2*a-3*s+1,l=-2*a+3*s,u=a-2*s+o,h=a-s;return new e(t.x*c+r.x*l+i.x*u+n.x*h,t.y*c+r.y*l+i.y*u+n.y*h,t.z*c+r.z*l+i.z*u+n.z*h,t.w*c+r.w*l+i.w*u+n.w*h)},e}(),g=function(){function e(){this._isIdentity=!1,this._isIdentityDirty=!0,this._isIdentity3x2=!0,this._isIdentity3x2Dirty=!0,this._m=new Float32Array(16),this._updateIdentityStatus(!1)}return Object.defineProperty(e.prototype,"m",{get:function(){return this._m},enumerable:!0,configurable:!0}),e.prototype._markAsUpdated=function(){this.updateFlag=e._updateFlagSeed++,this._isIdentity=!1,this._isIdentity3x2=!1,this._isIdentityDirty=!0,this._isIdentity3x2Dirty=!0},e.prototype._updateIdentityStatus=function(t,i,r,n){void 0===i&&(i=!1),void 0===r&&(r=!1),void 0===n&&(n=!0),this.updateFlag=e._updateFlagSeed++,this._isIdentity=t,this._isIdentity3x2=t||r,this._isIdentityDirty=!this._isIdentity&&i,this._isIdentity3x2Dirty=!this._isIdentity3x2&&n},e.prototype.isIdentity=function(){if(this._isIdentityDirty){this._isIdentityDirty=!1;var e=this._m;this._isIdentity=1===e[0]&&0===e[1]&&0===e[2]&&0===e[3]&&0===e[4]&&1===e[5]&&0===e[6]&&0===e[7]&&0===e[8]&&0===e[9]&&1===e[10]&&0===e[11]&&0===e[12]&&0===e[13]&&0===e[14]&&1===e[15]}return this._isIdentity},e.prototype.isIdentityAs3x2=function(){return this._isIdentity3x2Dirty&&(this._isIdentity3x2Dirty=!1,1!==this._m[0]||1!==this._m[5]||1!==this._m[15]?this._isIdentity3x2=!1:0!==this._m[1]||0!==this._m[2]||0!==this._m[3]||0!==this._m[4]||0!==this._m[6]||0!==this._m[7]||0!==this._m[8]||0!==this._m[9]||0!==this._m[10]||0!==this._m[11]||0!==this._m[12]||0!==this._m[13]||0!==this._m[14]?this._isIdentity3x2=!1:this._isIdentity3x2=!0),this._isIdentity3x2},e.prototype.determinant=function(){if(!0===this._isIdentity)return 1;var e=this._m,t=e[0],i=e[1],r=e[2],n=e[3],o=e[4],s=e[5],a=e[6],c=e[7],l=e[8],u=e[9],h=e[10],d=e[11],f=e[12],p=e[13],_=e[14],g=e[15],m=h*g-_*d,v=u*g-p*d,y=u*_-p*h,b=l*g-f*d,T=l*_-h*f,E=l*p-f*u;return t*+(s*m-a*v+c*y)+i*-(o*m-a*b+c*T)+r*+(o*v-s*b+c*E)+n*-(o*y-s*T+a*E)},e.prototype.toArray=function(){return this._m},e.prototype.asArray=function(){return this._m},e.prototype.invert=function(){return this.invertToRef(this),this},e.prototype.reset=function(){return e.FromValuesToRef(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,this),this._updateIdentityStatus(!1),this},e.prototype.add=function(t){var i=new e;return this.addToRef(t,i),i},e.prototype.addToRef=function(e,t){for(var i=this._m,r=t._m,n=e.m,o=0;o<16;o++)r[o]=i[o]+n[o];return t._markAsUpdated(),this},e.prototype.addToSelf=function(e){for(var t=this._m,i=e.m,r=0;r<16;r++)t[r]+=i[r];return this._markAsUpdated(),this},e.prototype.invertToRef=function(t){if(!0===this._isIdentity)return e.IdentityToRef(t),this;var i=this._m,r=i[0],n=i[1],o=i[2],s=i[3],a=i[4],c=i[5],l=i[6],u=i[7],h=i[8],d=i[9],f=i[10],p=i[11],_=i[12],g=i[13],m=i[14],v=i[15],y=f*v-m*p,b=d*v-g*p,T=d*m-g*f,E=h*v-_*p,x=h*m-f*_,A=h*g-_*d,P=+(c*y-l*b+u*T),R=-(a*y-l*E+u*x),S=+(a*b-c*E+u*A),C=-(a*T-c*x+l*A),M=r*P+n*R+o*S+s*C;if(0===M)return t.copyFrom(this),this;var O=1/M,I=l*v-m*u,D=c*v-g*u,w=c*m-g*l,L=a*v-_*u,F=a*m-_*l,N=a*g-_*c,B=l*p-f*u,U=c*p-d*u,V=c*f-d*l,G=a*p-h*u,k=a*f-h*l,z=a*d-h*c,j=-(n*y-o*b+s*T),W=+(r*y-o*E+s*x),H=-(r*b-n*E+s*A),X=+(r*T-n*x+o*A),Y=+(n*I-o*D+s*w),K=-(r*I-o*L+s*F),Q=+(r*D-n*L+s*N),q=-(r*w-n*F+o*N),Z=-(n*B-o*U+s*V),J=+(r*B-o*G+s*k),$=-(r*U-n*G+s*z),ee=+(r*V-n*k+o*z);return e.FromValuesToRef(P*O,j*O,Y*O,Z*O,R*O,W*O,K*O,J*O,S*O,H*O,Q*O,$*O,C*O,X*O,q*O,ee*O,t),this},e.prototype.addAtIndex=function(e,t){return this._m[e]+=t,this._markAsUpdated(),this},e.prototype.multiplyAtIndex=function(e,t){return this._m[e]*=t,this._markAsUpdated(),this},e.prototype.setTranslationFromFloats=function(e,t,i){return this._m[12]=e,this._m[13]=t,this._m[14]=i,this._markAsUpdated(),this},e.prototype.setTranslation=function(e){return this.setTranslationFromFloats(e.x,e.y,e.z)},e.prototype.getTranslation=function(){return new d(this._m[12],this._m[13],this._m[14])},e.prototype.getTranslationToRef=function(e){return e.x=this._m[12],e.y=this._m[13],e.z=this._m[14],this},e.prototype.removeRotationAndScaling=function(){var t=this.m;return e.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,t[12],t[13],t[14],t[15],this),this._updateIdentityStatus(0===t[12]&&0===t[13]&&0===t[14]&&1===t[15]),this},e.prototype.multiply=function(t){var i=new e;return this.multiplyToRef(t,i),i},e.prototype.copyFrom=function(e){e.copyToArray(this._m);var t=e;return this._updateIdentityStatus(t._isIdentity,t._isIdentityDirty,t._isIdentity3x2,t._isIdentity3x2Dirty),this},e.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},e.prototype.multiplyToRef=function(e,t){return this._isIdentity?(t.copyFrom(e),this):e._isIdentity?(t.copyFrom(this),this):(this.multiplyToArray(e,t._m,0),t._markAsUpdated(),this)},e.prototype.multiplyToArray=function(e,t,i){var r=this._m,n=e.m,o=r[0],s=r[1],a=r[2],c=r[3],l=r[4],u=r[5],h=r[6],d=r[7],f=r[8],p=r[9],_=r[10],g=r[11],m=r[12],v=r[13],y=r[14],b=r[15],T=n[0],E=n[1],x=n[2],A=n[3],P=n[4],R=n[5],S=n[6],C=n[7],M=n[8],O=n[9],I=n[10],D=n[11],w=n[12],L=n[13],F=n[14],N=n[15];return t[i]=o*T+s*P+a*M+c*w,t[i+1]=o*E+s*R+a*O+c*L,t[i+2]=o*x+s*S+a*I+c*F,t[i+3]=o*A+s*C+a*D+c*N,t[i+4]=l*T+u*P+h*M+d*w,t[i+5]=l*E+u*R+h*O+d*L,t[i+6]=l*x+u*S+h*I+d*F,t[i+7]=l*A+u*C+h*D+d*N,t[i+8]=f*T+p*P+_*M+g*w,t[i+9]=f*E+p*R+_*O+g*L,t[i+10]=f*x+p*S+_*I+g*F,t[i+11]=f*A+p*C+_*D+g*N,t[i+12]=m*T+v*P+y*M+b*w,t[i+13]=m*E+v*R+y*O+b*L,t[i+14]=m*x+v*S+y*I+b*F,t[i+15]=m*A+v*C+y*D+b*N,this},e.prototype.equals=function(e){var t=e;if(!t)return!1;if((this._isIdentity||t._isIdentity)&&!this._isIdentityDirty&&!t._isIdentityDirty)return this._isIdentity&&t._isIdentity;var i=this.m,r=t.m;return i[0]===r[0]&&i[1]===r[1]&&i[2]===r[2]&&i[3]===r[3]&&i[4]===r[4]&&i[5]===r[5]&&i[6]===r[6]&&i[7]===r[7]&&i[8]===r[8]&&i[9]===r[9]&&i[10]===r[10]&&i[11]===r[11]&&i[12]===r[12]&&i[13]===r[13]&&i[14]===r[14]&&i[15]===r[15]},e.prototype.clone=function(){var t=new e;return t.copyFrom(this),t},e.prototype.getClassName=function(){return"Matrix"},e.prototype.getHashCode=function(){for(var e=this._m[0]||0,t=1;t<16;t++)e=397*e^(this._m[t]||0);return e},e.prototype.decompose=function(t,i,r){if(this._isIdentity)return r&&r.setAll(0),t&&t.setAll(1),i&&i.copyFromFloats(0,0,0,1),!0;var n=this._m;if(r&&r.copyFromFloats(n[12],n[13],n[14]),(t=t||I.Vector3[0]).x=Math.sqrt(n[0]*n[0]+n[1]*n[1]+n[2]*n[2]),t.y=Math.sqrt(n[4]*n[4]+n[5]*n[5]+n[6]*n[6]),t.z=Math.sqrt(n[8]*n[8]+n[9]*n[9]+n[10]*n[10]),this.determinant()<=0&&(t.y*=-1),0===t.x||0===t.y||0===t.z)return i&&i.copyFromFloats(0,0,0,1),!1;if(i){var o=1/t.x,s=1/t.y,a=1/t.z;e.FromValuesToRef(n[0]*o,n[1]*o,n[2]*o,0,n[4]*s,n[5]*s,n[6]*s,0,n[8]*a,n[9]*a,n[10]*a,0,0,0,0,1,I.Matrix[0]),_.FromRotationMatrixToRef(I.Matrix[0],i)}return!0},e.prototype.getRow=function(e){if(e<0||e>3)return null;var t=4*e;return new f(this._m[t+0],this._m[t+1],this._m[t+2],this._m[t+3])},e.prototype.setRow=function(e,t){return this.setRowFromFloats(e,t.x,t.y,t.z,t.w)},e.prototype.transpose=function(){return e.Transpose(this)},e.prototype.transposeToRef=function(t){return e.TransposeToRef(this,t),this},e.prototype.setRowFromFloats=function(e,t,i,r,n){if(e<0||e>3)return this;var o=4*e;return this._m[o+0]=t,this._m[o+1]=i,this._m[o+2]=r,this._m[o+3]=n,this._markAsUpdated(),this},e.prototype.scale=function(t){var i=new e;return this.scaleToRef(t,i),i},e.prototype.scaleToRef=function(e,t){for(var i=0;i<16;i++)t._m[i]=this._m[i]*e;return t._markAsUpdated(),this},e.prototype.scaleAndAddToRef=function(e,t){for(var i=0;i<16;i++)t._m[i]+=this._m[i]*e;return t._markAsUpdated(),this},e.prototype.toNormalMatrix=function(t){var i=I.Matrix[0];this.invertToRef(i),i.transposeToRef(t);var r=t._m;e.FromValuesToRef(r[0],r[1],r[2],0,r[4],r[5],r[6],0,r[8],r[9],r[10],0,0,0,0,1,t)},e.prototype.getRotationMatrix=function(){var t=new e;return this.getRotationMatrixToRef(t),t},e.prototype.getRotationMatrixToRef=function(t){var i=I.Vector3[0];if(!this.decompose(i))return e.IdentityToRef(t),this;var r=this._m,n=1/i.x,o=1/i.y,s=1/i.z;return e.FromValuesToRef(r[0]*n,r[1]*n,r[2]*n,0,r[4]*o,r[5]*o,r[6]*o,0,r[8]*s,r[9]*s,r[10]*s,0,0,0,0,1,t),this},e.prototype.toggleModelMatrixHandInPlace=function(){var e=this._m;e[2]*=-1,e[6]*=-1,e[8]*=-1,e[9]*=-1,e[14]*=-1,this._markAsUpdated()},e.prototype.toggleProjectionMatrixHandInPlace=function(){var e=this._m;e[8]*=-1,e[9]*=-1,e[10]*=-1,e[11]*=-1,this._markAsUpdated()},e.FromArray=function(t,i){void 0===i&&(i=0);var r=new e;return e.FromArrayToRef(t,i,r),r},e.FromArrayToRef=function(e,t,i){for(var r=0;r<16;r++)i._m[r]=e[r+t];i._markAsUpdated()},e.FromFloat32ArrayToRefScaled=function(e,t,i,r){for(var n=0;n<16;n++)r._m[n]=e[n+t]*i;r._markAsUpdated()},Object.defineProperty(e,"IdentityReadOnly",{get:function(){return e._identityReadOnly},enumerable:!0,configurable:!0}),e.FromValuesToRef=function(e,t,i,r,n,o,s,a,c,l,u,h,d,f,p,_,g){var m=g._m;m[0]=e,m[1]=t,m[2]=i,m[3]=r,m[4]=n,m[5]=o,m[6]=s,m[7]=a,m[8]=c,m[9]=l,m[10]=u,m[11]=h,m[12]=d,m[13]=f,m[14]=p,m[15]=_,g._markAsUpdated()},e.FromValues=function(t,i,r,n,o,s,a,c,l,u,h,d,f,p,_,g){var m=new e,v=m._m;return v[0]=t,v[1]=i,v[2]=r,v[3]=n,v[4]=o,v[5]=s,v[6]=a,v[7]=c,v[8]=l,v[9]=u,v[10]=h,v[11]=d,v[12]=f,v[13]=p,v[14]=_,v[15]=g,m._markAsUpdated(),m},e.Compose=function(t,i,r){var n=new e;return e.ComposeToRef(t,i,r,n),n},e.ComposeToRef=function(t,i,r,n){e.ScalingToRef(t.x,t.y,t.z,I.Matrix[1]),i.toRotationMatrix(I.Matrix[0]),I.Matrix[1].multiplyToRef(I.Matrix[0],n),n.setTranslation(r)},e.Identity=function(){var t=e.FromValues(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return t._updateIdentityStatus(!0),t},e.IdentityToRef=function(t){e.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,t),t._updateIdentityStatus(!0)},e.Zero=function(){var t=e.FromValues(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);return t._updateIdentityStatus(!1),t},e.RotationX=function(t){var i=new e;return e.RotationXToRef(t,i),i},e.Invert=function(t){var i=new e;return t.invertToRef(i),i},e.RotationXToRef=function(t,i){var r=Math.sin(t),n=Math.cos(t);e.FromValuesToRef(1,0,0,0,0,n,r,0,0,-r,n,0,0,0,0,1,i),i._updateIdentityStatus(1===n&&0===r)},e.RotationY=function(t){var i=new e;return e.RotationYToRef(t,i),i},e.RotationYToRef=function(t,i){var r=Math.sin(t),n=Math.cos(t);e.FromValuesToRef(n,0,-r,0,0,1,0,0,r,0,n,0,0,0,0,1,i),i._updateIdentityStatus(1===n&&0===r)},e.RotationZ=function(t){var i=new e;return e.RotationZToRef(t,i),i},e.RotationZToRef=function(t,i){var r=Math.sin(t),n=Math.cos(t);e.FromValuesToRef(n,r,0,0,-r,n,0,0,0,0,1,0,0,0,0,1,i),i._updateIdentityStatus(1===n&&0===r)},e.RotationAxis=function(t,i){var r=new e;return e.RotationAxisToRef(t,i,r),r},e.RotationAxisToRef=function(e,t,i){var r=Math.sin(-t),n=Math.cos(-t),o=1-n;e.normalize();var s=i._m;s[0]=e.x*e.x*o+n,s[1]=e.x*e.y*o-e.z*r,s[2]=e.x*e.z*o+e.y*r,s[3]=0,s[4]=e.y*e.x*o+e.z*r,s[5]=e.y*e.y*o+n,s[6]=e.y*e.z*o-e.x*r,s[7]=0,s[8]=e.z*e.x*o-e.y*r,s[9]=e.z*e.y*o+e.x*r,s[10]=e.z*e.z*o+n,s[11]=0,s[12]=0,s[13]=0,s[14]=0,s[15]=1,i._markAsUpdated()},e.RotationYawPitchRoll=function(t,i,r){var n=new e;return e.RotationYawPitchRollToRef(t,i,r,n),n},e.RotationYawPitchRollToRef=function(e,t,i,r){_.RotationYawPitchRollToRef(e,t,i,I.Quaternion[0]),I.Quaternion[0].toRotationMatrix(r)},e.Scaling=function(t,i,r){var n=new e;return e.ScalingToRef(t,i,r,n),n},e.ScalingToRef=function(t,i,r,n){e.FromValuesToRef(t,0,0,0,0,i,0,0,0,0,r,0,0,0,0,1,n),n._updateIdentityStatus(1===t&&1===i&&1===r)},e.Translation=function(t,i,r){var n=new e;return e.TranslationToRef(t,i,r,n),n},e.TranslationToRef=function(t,i,r,n){e.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,t,i,r,1,n),n._updateIdentityStatus(0===t&&0===i&&0===r)},e.Lerp=function(t,i,r){var n=new e;return e.LerpToRef(t,i,r,n),n},e.LerpToRef=function(e,t,i,r){for(var n=r._m,o=e.m,s=t.m,a=0;a<16;a++)n[a]=o[a]*(1-i)+s[a]*i;r._markAsUpdated()},e.DecomposeLerp=function(t,i,r){var n=new e;return e.DecomposeLerpToRef(t,i,r,n),n},e.DecomposeLerpToRef=function(t,i,r,n){var o=I.Vector3[0],s=I.Quaternion[0],a=I.Vector3[1];t.decompose(o,s,a);var c=I.Vector3[2],l=I.Quaternion[1],u=I.Vector3[3];i.decompose(c,l,u);var h=I.Vector3[4];d.LerpToRef(o,c,r,h);var f=I.Quaternion[2];_.SlerpToRef(s,l,r,f);var p=I.Vector3[5];d.LerpToRef(a,u,r,p),e.ComposeToRef(h,f,p,n)},e.LookAtLH=function(t,i,r){var n=new e;return e.LookAtLHToRef(t,i,r,n),n},e.LookAtLHToRef=function(t,i,r,n){var o=I.Vector3[0],s=I.Vector3[1],a=I.Vector3[2];i.subtractToRef(t,a),a.normalize(),d.CrossToRef(r,a,o);var c=o.lengthSquared();0===c?o.x=1:o.normalizeFromLength(Math.sqrt(c)),d.CrossToRef(a,o,s),s.normalize();var l=-d.Dot(o,t),u=-d.Dot(s,t),h=-d.Dot(a,t);e.FromValuesToRef(o.x,s.x,a.x,0,o.y,s.y,a.y,0,o.z,s.z,a.z,0,l,u,h,1,n)},e.LookAtRH=function(t,i,r){var n=new e;return e.LookAtRHToRef(t,i,r,n),n},e.LookAtRHToRef=function(t,i,r,n){var o=I.Vector3[0],s=I.Vector3[1],a=I.Vector3[2];t.subtractToRef(i,a),a.normalize(),d.CrossToRef(r,a,o);var c=o.lengthSquared();0===c?o.x=1:o.normalizeFromLength(Math.sqrt(c)),d.CrossToRef(a,o,s),s.normalize();var l=-d.Dot(o,t),u=-d.Dot(s,t),h=-d.Dot(a,t);e.FromValuesToRef(o.x,s.x,a.x,0,o.y,s.y,a.y,0,o.z,s.z,a.z,0,l,u,h,1,n)},e.OrthoLH=function(t,i,r,n){var o=new e;return e.OrthoLHToRef(t,i,r,n,o),o},e.OrthoLHToRef=function(t,i,r,n,o){var s=2/t,a=2/i,c=2/(n-r),l=-(n+r)/(n-r);e.FromValuesToRef(s,0,0,0,0,a,0,0,0,0,c,0,0,0,l,1,o),o._updateIdentityStatus(1===s&&1===a&&1===c&&0===l)},e.OrthoOffCenterLH=function(t,i,r,n,o,s){var a=new e;return e.OrthoOffCenterLHToRef(t,i,r,n,o,s,a),a},e.OrthoOffCenterLHToRef=function(t,i,r,n,o,s,a){var c=2/(i-t),l=2/(n-r),u=2/(s-o),h=-(s+o)/(s-o),d=(t+i)/(t-i),f=(n+r)/(r-n);e.FromValuesToRef(c,0,0,0,0,l,0,0,0,0,u,0,d,f,h,1,a),a._markAsUpdated()},e.OrthoOffCenterRH=function(t,i,r,n,o,s){var a=new e;return e.OrthoOffCenterRHToRef(t,i,r,n,o,s,a),a},e.OrthoOffCenterRHToRef=function(t,i,r,n,o,s,a){e.OrthoOffCenterLHToRef(t,i,r,n,o,s,a),a._m[10]*=-1},e.PerspectiveLH=function(t,i,r,n){var o=new e,s=2*r/t,a=2*r/i,c=(n+r)/(n-r),l=-2*n*r/(n-r);return e.FromValuesToRef(s,0,0,0,0,a,0,0,0,0,c,1,0,0,l,0,o),o._updateIdentityStatus(!1),o},e.PerspectiveFovLH=function(t,i,r,n){var o=new e;return e.PerspectiveFovLHToRef(t,i,r,n,o),o},e.PerspectiveFovLHToRef=function(t,i,r,n,o,s){void 0===s&&(s=!0);var a=r,c=n,l=1/Math.tan(.5*t),u=s?l/i:l,h=s?l:l*i,d=(c+a)/(c-a),f=-2*c*a/(c-a);e.FromValuesToRef(u,0,0,0,0,h,0,0,0,0,d,1,0,0,f,0,o),o._updateIdentityStatus(!1)},e.PerspectiveFovRH=function(t,i,r,n){var o=new e;return e.PerspectiveFovRHToRef(t,i,r,n,o),o},e.PerspectiveFovRHToRef=function(t,i,r,n,o,s){void 0===s&&(s=!0);var a=r,c=n,l=1/Math.tan(.5*t),u=s?l/i:l,h=s?l:l*i,d=-(c+a)/(c-a),f=-2*c*a/(c-a);e.FromValuesToRef(u,0,0,0,0,h,0,0,0,0,d,-1,0,0,f,0,o),o._updateIdentityStatus(!1)},e.PerspectiveFovWebVRToRef=function(e,t,i,r,n){void 0===n&&(n=!1);var o=n?-1:1,s=Math.tan(e.upDegrees*Math.PI/180),a=Math.tan(e.downDegrees*Math.PI/180),c=Math.tan(e.leftDegrees*Math.PI/180),l=Math.tan(e.rightDegrees*Math.PI/180),u=2/(c+l),h=2/(s+a),d=r._m;d[0]=u,d[1]=d[2]=d[3]=d[4]=0,d[5]=h,d[6]=d[7]=0,d[8]=(c-l)*u*.5,d[9]=-(s-a)*h*.5,d[10]=-i/(t-i),d[11]=1*o,d[12]=d[13]=d[15]=0,d[14]=-2*i*t/(i-t),r._markAsUpdated()},e.GetFinalMatrix=function(t,i,r,n,o,s){var a=t.width,c=t.height,l=t.x,u=t.y,h=e.FromValues(a/2,0,0,0,0,-c/2,0,0,0,0,s-o,0,l+a/2,c/2+u,o,1),d=I.Matrix[0];return i.multiplyToRef(r,d),d.multiplyToRef(n,d),d.multiply(h)},e.GetAsMatrix2x2=function(e){var t=e.m;return new Float32Array([t[0],t[1],t[4],t[5]])},e.GetAsMatrix3x3=function(e){var t=e.m;return new Float32Array([t[0],t[1],t[2],t[4],t[5],t[6],t[8],t[9],t[10]])},e.Transpose=function(t){var i=new e;return e.TransposeToRef(t,i),i},e.TransposeToRef=function(e,t){var i=t._m,r=e.m;i[0]=r[0],i[1]=r[4],i[2]=r[8],i[3]=r[12],i[4]=r[1],i[5]=r[5],i[6]=r[9],i[7]=r[13],i[8]=r[2],i[9]=r[6],i[10]=r[10],i[11]=r[14],i[12]=r[3],i[13]=r[7],i[14]=r[11],i[15]=r[15],t._updateIdentityStatus(e._isIdentity,e._isIdentityDirty)},e.Reflection=function(t){var i=new e;return e.ReflectionToRef(t,i),i},e.ReflectionToRef=function(t,i){t.normalize();var r=t.normal.x,n=t.normal.y,o=t.normal.z,s=-2*r,a=-2*n,c=-2*o;e.FromValuesToRef(s*r+1,a*r,c*r,0,s*n,a*n+1,c*n,0,s*o,a*o,c*o+1,0,s*t.d,a*t.d,c*t.d,1,i)},e.FromXYZAxesToRef=function(t,i,r,n){e.FromValuesToRef(t.x,t.y,t.z,0,i.x,i.y,i.z,0,r.x,r.y,r.z,0,0,0,0,1,n)},e.FromQuaternionToRef=function(e,t){var i=e.x*e.x,r=e.y*e.y,n=e.z*e.z,o=e.x*e.y,s=e.z*e.w,a=e.z*e.x,c=e.y*e.w,l=e.y*e.z,u=e.x*e.w;t._m[0]=1-2*(r+n),t._m[1]=2*(o+s),t._m[2]=2*(a-c),t._m[3]=0,t._m[4]=2*(o-s),t._m[5]=1-2*(n+i),t._m[6]=2*(l+u),t._m[7]=0,t._m[8]=2*(a+c),t._m[9]=2*(l-u),t._m[10]=1-2*(r+i),t._m[11]=0,t._m[12]=0,t._m[13]=0,t._m[14]=0,t._m[15]=1,t._markAsUpdated()},e._updateFlagSeed=0,e._identityReadOnly=e.Identity(),e}(),m=function(){function e(e,t,i,r){this.normal=new d(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=I.Matrix[0];g.TransposeToRef(t,i);var r=i.m,n=this.normal.x,o=this.normal.y,s=this.normal.z,a=this.d;return new e(n*r[0]+o*r[1]+s*r[2]+a*r[3],n*r[4]+o*r[5]+s*r[6]+a*r[7],n*r[8]+o*r[9]+s*r[10]+a*r[11],n*r[12]+o*r[13]+s*r[14]+a*r[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,o=t.y-e.y,s=t.z-e.z,a=i.x-e.x,c=i.y-e.y,l=i.z-e.z,u=o*l-s*c,h=s*a-n*l,d=n*c-o*a,f=Math.sqrt(u*u+h*h+d*d);return r=0!==f?1/f:0,this.normal.x=u*r,this.normal.y=h*r,this.normal.z=d*r,this.d=-(this.normal.x*e.x+this.normal.y*e.y+this.normal.z*e.z),this},e.prototype.isFrontFacingTo=function(e,t){return d.Dot(this.normal,e)<=t},e.prototype.signedDistanceTo=function(e){return d.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 d.Dot(i,t)+r},e}(),v=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.toGlobalToRef=function(e,t,i){return i.x=this.x*e,i.y=this.y*t,i.width=this.width*e,i.height=this.height*t,this},e.prototype.clone=function(){return new e(this.x,this.y,this.width,this.height)},e}(),y=function(){function e(){}return e.GetPlanes=function(t){for(var i=[],r=0;r<6;r++)i.push(new m(0,0,0,0));return e.GetPlanesToRef(t,i),i},e.GetNearPlaneToRef=function(e,t){var i=e.m;t.normal.x=i[3]+i[2],t.normal.y=i[7]+i[6],t.normal.z=i[11]+i[10],t.d=i[15]+i[14],t.normalize()},e.GetFarPlaneToRef=function(e,t){var i=e.m;t.normal.x=i[3]-i[2],t.normal.y=i[7]-i[6],t.normal.z=i[11]-i[10],t.d=i[15]-i[14],t.normalize()},e.GetLeftPlaneToRef=function(e,t){var i=e.m;t.normal.x=i[3]+i[0],t.normal.y=i[7]+i[4],t.normal.z=i[11]+i[8],t.d=i[15]+i[12],t.normalize()},e.GetRightPlaneToRef=function(e,t){var i=e.m;t.normal.x=i[3]-i[0],t.normal.y=i[7]-i[4],t.normal.z=i[11]-i[8],t.d=i[15]-i[12],t.normalize()},e.GetTopPlaneToRef=function(e,t){var i=e.m;t.normal.x=i[3]-i[1],t.normal.y=i[7]-i[5],t.normal.z=i[11]-i[9],t.d=i[15]-i[13],t.normalize()},e.GetBottomPlaneToRef=function(e,t){var i=e.m;t.normal.x=i[3]+i[1],t.normal.y=i[7]+i[5],t.normal.z=i[11]+i[9],t.d=i[15]+i[13],t.normalize()},e.GetPlanesToRef=function(t,i){e.GetNearPlaneToRef(t,i[0]),e.GetFarPlaneToRef(t,i[1]),e.GetLeftPlaneToRef(t,i[2]),e.GetRightPlaneToRef(t,i[3]),e.GetTopPlaneToRef(t,i[4]),e.GetBottomPlaneToRef(t,i[5])},e}();!function(e){e[e.LOCAL=0]="LOCAL",e[e.WORLD=1]="WORLD",e[e.BONE=2]="BONE"}(r||(r={}));var b,T=function(){function e(){}return e.X=new d(1,0,0),e.Y=new d(0,1,0),e.Z=new d(0,0,1),e}(),E=function(){function e(){}return e.Interpolate=function(e,t,i,r,n){for(var o=1-3*r+3*t,s=3*r-6*t,a=3*t,c=e,l=0;l<5;l++){var u=c*c;c-=(o*(u*c)+s*u+a*c-e)*(1/(3*o*u+2*s*c+a)),c=Math.min(1,Math.max(0,c))}return 3*Math.pow(1-c,2)*c*i+3*(1-c)*Math.pow(c,2)*n+Math.pow(c,3)},e}();!function(e){e[e.CW=0]="CW",e[e.CCW=1]="CCW"}(b||(b={}));var x=function(){function e(e){this._radians=e,this._radians<0&&(this._radians+=2*Math.PI)}return e.prototype.degrees=function(){return 180*this._radians/Math.PI},e.prototype.radians=function(){return this._radians},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}(),A=function(){return function(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,s=(e.x-t.x)*(t.y-i.y)-(t.x-i.x)*(e.y-t.y);this.centerPoint=new h((n*(t.y-i.y)-o*(e.y-t.y))/s,((e.x-t.x)*o-(t.x-i.x)*n)/s),this.radius=this.centerPoint.subtract(this.startPoint).length(),this.startAngle=x.BetweenTwoPoints(this.centerPoint,this.startPoint);var a=this.startAngle.degrees(),c=x.BetweenTwoPoints(this.centerPoint,this.midPoint).degrees(),l=x.BetweenTwoPoints(this.centerPoint,this.endPoint).degrees();c-a>180&&(c-=360),c-a<-180&&(c+=360),l-c>180&&(l-=360),l-c<-180&&(l+=360),this.orientation=c-a<0?b.CW:b.CCW,this.angle=x.FromDegrees(this.orientation===b.CW?a-l:l-a)}}(),P=function(){function e(e,t){this._points=new Array,this._length=0,this.closed=!1,this._points.push(new h(e,t))}return e.prototype.addLineTo=function(e,t){if(this.closed)return this;var i=new h(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),this.closed)return this;var o=this._points[this._points.length-1],s=new h(e,t),a=new h(i,r),c=new A(o,s,a),l=c.angle.radians()/n;c.orientation===b.CW&&(l*=-1);for(var u=c.startAngle.radians()+l,d=0;d<n;d++){var f=Math.cos(u)*c.radius+c.centerPoint.x,p=Math.sin(u)*c.radius+c.centerPoint.y;this.addLineTo(f,p),u+=l}return this},e.prototype.close=function(){return this.closed=!0,this},e.prototype.length=function(){var e=this._length;if(!this.closed){var t=this._points[this._points.length-1];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 h.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],s=this._points[n].subtract(o),a=s.length()+i;if(t>=i&&t<=a){var c=s.normalize(),l=t-i;return new h(o.x+c.x*l,o.y+c.y*l)}i=a}return h.Zero()},e.StartingAt=function(t,i){return new e(t,i)},e}(),R=function(){function e(e,t,i){void 0===t&&(t=null),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 e.prototype.getCurve=function(){return this._curve},e.prototype.getTangents=function(){return this._tangents},e.prototype.getNormals=function(){return this._normals},e.prototype.getBinormals=function(){return this._binormals},e.prototype.getDistances=function(){return this._distances},e.prototype.update=function(e,t){void 0===t&&(t=null);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},e.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,r,n,o,s=this._tangents[0],a=this._normalVector(s,e);this._normals[0]=a,this._raw||this._normals[0].normalize(),this._binormals[0]=d.Cross(s,this._normals[0]),this._raw||this._binormals[0].normalize(),this._distances[0]=0;for(var c=1;c<t;c++)i=this._getLastNonNullVector(c),c<t-1&&(r=this._getFirstNonNullVector(c),this._tangents[c]=i.add(r),this._tangents[c].normalize()),this._distances[c]=this._distances[c-1]+i.length(),n=this._tangents[c],o=this._binormals[c-1],this._normals[c]=d.Cross(o,n),this._raw||this._normals[c].normalize(),this._binormals[c]=d.Cross(n,this._normals[c]),this._raw||this._binormals[c].normalize()},e.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},e.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},e.prototype._normalVector=function(e,t){var i,r,n=e.length();(0===n&&(n=1),null==t)?(r=o.a.WithinEpsilon(Math.abs(e.y)/n,1,c)?o.a.WithinEpsilon(Math.abs(e.x)/n,1,c)?o.a.WithinEpsilon(Math.abs(e.z)/n,1,c)?d.Zero():new d(0,0,1):new d(1,0,0):new d(0,-1,0),i=d.Cross(e,r)):(i=d.Cross(e,t),d.CrossToRef(i,e,i));return i.normalize(),i},e}(),S=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 o=new Array,s=function(e,t,i,r){return(1-e)*(1-e)*t+2*e*(1-e)*i+e*e*r},a=0;a<=n;a++)o.push(new d(s(a/n,t.x,i.x,r.x),s(a/n,t.y,i.y,r.y),s(a/n,t.z,i.z,r.z)));return new e(o)},e.CreateCubicBezier=function(t,i,r,n,o){o=o>3?o:4;for(var s=new Array,a=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},c=0;c<=o;c++)s.push(new d(a(c/o,t.x,i.x,r.x,n.x),a(c/o,t.y,i.y,r.y,n.y),a(c/o,t.z,i.z,r.z,n.z)));return new e(s)},e.CreateHermiteSpline=function(t,i,r,n,o){for(var s=new Array,a=1/o,c=0;c<=o;c++)s.push(d.Hermite(t,i,r,n,c*a));return new e(s)},e.CreateCatmullRomSpline=function(t,i,r){var n=new Array,o=1/i,s=0;if(r){for(var a=t.length,c=0;c<a;c++){s=0;for(var l=0;l<i;l++)n.push(d.CatmullRom(t[c%a],t[(c+1)%a],t[(c+2)%a],t[(c+3)%a],s)),s+=o}n.push(n[0])}else{var u=new Array;u.push(t[0].clone()),Array.prototype.push.apply(u,t),u.push(t[t.length-1].clone());for(c=0;c<u.length-3;c++){s=0;for(l=0;l<i;l++)n.push(d.CatmullRom(u[c],u[c+1],u[c+2],u[c+3],s)),s+=o}c--,n.push(d.CatmullRom(u[c],u[c+1],u[c+2],u[c+3],s))}return 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(),o=1;o<n.length;o++)r.push(n[o].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}(),C=function(){function e(e,t){void 0===e&&(e=d.Zero()),void 0===t&&(t=d.Up()),this.position=e,this.normal=t}return e.prototype.clone=function(){return new e(this.position.clone(),this.normal.clone())},e}(),M=function(){function e(e,t,i){void 0===e&&(e=d.Zero()),void 0===t&&(t=d.Up()),void 0===i&&(i=h.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}(),O=function(){function e(){}return e.Color3=n.a.BuildArray(3,l.Black),e.Color4=n.a.BuildArray(3,function(){return new u(0,0,0,0)}),e.Vector2=n.a.BuildArray(3,h.Zero),e.Vector3=n.a.BuildArray(13,d.Zero),e.Vector4=n.a.BuildArray(3,f.Zero),e.Quaternion=n.a.BuildArray(2,_.Zero),e.Matrix=n.a.BuildArray(8,g.Identity),e}(),I=function(){function e(){}return e.Vector3=n.a.BuildArray(6,d.Zero),e.Matrix=n.a.BuildArray(2,g.Identity),e.Quaternion=n.a.BuildArray(3,_.Zero),e}()},function(e,t,i){"use strict";i.d(t,"d",function(){return n}),i.d(t,"a",function(){return o}),i.d(t,"c",function(){return s}),i.d(t,"b",function(){return a}),i.d(t,"e",function(){return c});
  2. /*! *****************************************************************************
  3. Copyright (c) Microsoft Corporation. All rights reserved.
  4. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  5. this file except in compliance with the License. You may obtain a copy of the
  6. License at http://www.apache.org/licenses/LICENSE-2.0
  7. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  8. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  9. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  10. MERCHANTABLITY OR NON-INFRINGEMENT.
  11. See the Apache Version 2.0 License for specific language governing permissions
  12. and limitations under the License.
  13. ***************************************************************************** */
  14. var r=function(e,t){return(r=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])})(e,t)};function n(e,t){function i(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}var o=function(){return(o=Object.assign||function(e){for(var t,i=1,r=arguments.length;i<r;i++)for(var n in t=arguments[i])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}).apply(this,arguments)};function s(e,t,i,r){var n,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,i,r);else for(var a=e.length-1;a>=0;a--)(n=e[a])&&(s=(o<3?n(s):o>3?n(t,i,s):n(t,i))||s);return o>3&&s&&Object.defineProperty(t,i,s),s}function a(e,t,i,r){return new(i||(i=Promise))(function(n,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){e.done?n(e.value):new i(function(t){t(e.value)}).then(s,a)}c((r=r.apply(e,t||[])).next())})}function c(e,t){var i,r,n,o,s={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return o={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function a(o){return function(a){return function(o){if(i)throw new TypeError("Generator is already executing.");for(;s;)try{if(i=1,r&&(n=2&o[0]?r.return:o[0]?r.throw||((n=r.return)&&n.call(r),0):r.next)&&!(n=n.call(r,o[1])).done)return n;switch(r=0,n&&(o=[2&o[0],n.value]),o[0]){case 0:case 1:n=o;break;case 4:return s.label++,{value:o[1],done:!1};case 5:s.label++,r=o[1],o=[0];continue;case 7:o=s.ops.pop(),s.trys.pop();continue;default:if(!(n=(n=s.trys).length>0&&n[n.length-1])&&(6===o[0]||2===o[0])){s=0;continue}if(3===o[0]&&(!n||o[1]>n[0]&&o[1]<n[3])){s.label=o[1];break}if(6===o[0]&&s.label<n[1]){s.label=n[1],n=o;break}if(n&&s.label<n[2]){s.label=n[2],s.ops.push(o);break}n[2]&&s.ops.pop(),s.trys.pop();continue}o=t.call(e,s)}catch(e){o=[6,e],r=0}finally{i=n=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,a])}}}},function(e,t,i){"use strict";i.d(t,"b",function(){return u}),i.d(t,"c",function(){return h}),i.d(t,"l",function(){return d}),i.d(t,"e",function(){return f}),i.d(t,"h",function(){return p}),i.d(t,"m",function(){return _}),i.d(t,"n",function(){return g}),i.d(t,"j",function(){return m}),i.d(t,"g",function(){return v}),i.d(t,"f",function(){return y}),i.d(t,"i",function(){return b}),i.d(t,"k",function(){return T}),i.d(t,"d",function(){return E}),i.d(t,"a",function(){return x});var r=i(26),n=i(0),o={},s={},a=function(e,t,i){var n=e();r.a&&r.a.AddTagsTo(n,t.tags);var o=c(n);for(var s in o){var a=o[s],l=t[s],u=a.type;if(null!=l)switch(u){case 0:case 6:case 11:n[s]=l;break;case 1:n[s]=i||l.isRenderTarget?l:l.clone();break;case 2:case 3:case 4:case 5:case 7:case 10:n[s]=i?l:l.clone()}}return n};function c(e){var t=e.getClassName();if(s[t])return s[t];s[t]={};for(var i=s[t],r=e,n=t;n;){var a=o[n];for(var c in a)i[c]=a[c];var l=void 0,u=!1;do{if(!(l=Object.getPrototypeOf(r)).getClassName){u=!0;break}if(l.getClassName()!==n)break;r=l}while(l);if(u)break;n=l.getClassName(),r=l}return i}function l(e,t){return function(i,r){var n=function(e){var t=e.getClassName();return o[t]||(o[t]={}),o[t]}(i);n[r]||(n[r]={type:e,sourceName:t})}}function u(e,t){return void 0===t&&(t=null),function(e,t){return void 0===t&&(t=null),function(i,r){var n=t||"_"+r;Object.defineProperty(i,r,{get:function(){return this[n]},set:function(t){this[n]!==t&&(this[n]=t,i[e].apply(this))},enumerable:!0,configurable:!0})}}(e,t)}function h(e){return l(0,e)}function d(e){return l(1,e)}function f(e){return l(2,e)}function p(e){return l(3,e)}function _(e){return l(4,e)}function g(e){return l(5,e)}function m(e){return l(6,e)}function v(e){return l(7,e)}function y(e){return l(8,e)}function b(e){return l(9,e)}function T(e){return l(10,e)}function E(e){return l(11,e)}var x=function(){function e(){}return e.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())}}},e.Serialize=function(e,t){t||(t={}),r.a&&(t.tags=r.a.GetTags(e));var i=c(e);for(var n in i){var o=i[n],s=o.sourceName||n,a=o.type,l=e[n];if(null!=l)switch(a){case 0:t[s]=l;break;case 1:t[s]=l.serialize();break;case 2:t[s]=l.asArray();break;case 3:t[s]=l.serialize();break;case 4:case 5:t[s]=l.asArray();break;case 6:t[s]=l.id;break;case 7:t[s]=l.serialize();break;case 8:t[s]=l.asArray();break;case 9:t[s]=l.serialize();break;case 10:t[s]=l.asArray();break;case 11:t[s]=l.id}}return t},e.Parse=function(t,i,o,s){void 0===s&&(s=null);var a=t();s||(s=""),r.a&&r.a.AddTagsTo(a,i.tags);var l=c(a);for(var u in l){var h=l[u],d=i[h.sourceName||u],f=h.type;if(null!=d){var p=a;switch(f){case 0:p[u]=d;break;case 1:o&&(p[u]=e._TextureParser(d,o,s));break;case 2:p[u]=n.e.FromArray(d);break;case 3:p[u]=e._FresnelParametersParser(d);break;case 4:p[u]=n.w.FromArray(d);break;case 5:p[u]=n.x.FromArray(d);break;case 6:o&&(p[u]=o.getLastMeshByID(d));break;case 7:p[u]=e._ColorCurvesParser(d);break;case 8:p[u]=n.f.FromArray(d);break;case 9:p[u]=e._ImageProcessingConfigurationParser(d);break;case 10:p[u]=n.q.FromArray(d);break;case 11:o&&(p[u]=o.getCameraByID(d))}}}return a},e.Clone=function(e,t){return a(e,t,!1)},e.Instanciate=function(e,t){return a(e,t,!0)},e._ImageProcessingConfigurationParser=function(e){throw"ImageProcessingConfiguration needs to be imported before being deserialized."},e._FresnelParametersParser=function(e){throw"FresnelParameters needs to be imported before being deserialized."},e._ColorCurvesParser=function(e){throw"ColorCurves needs to be imported before being deserialized."},e._TextureParser=function(e,t,i){throw"Texture needs to be imported before being deserialized."},e}()},function(e,t,i){"use strict";i.d(t,"a",function(){return r});var r=function(){function e(){}return e.ALPHA_DISABLE=0,e.ALPHA_ADD=1,e.ALPHA_COMBINE=2,e.ALPHA_SUBTRACT=3,e.ALPHA_MULTIPLY=4,e.ALPHA_MAXIMIZED=5,e.ALPHA_ONEONE=6,e.ALPHA_PREMULTIPLIED=7,e.ALPHA_PREMULTIPLIED_PORTERDUFF=8,e.ALPHA_INTERPOLATE=9,e.ALPHA_SCREENMODE=10,e.DELAYLOADSTATE_NONE=0,e.DELAYLOADSTATE_LOADED=1,e.DELAYLOADSTATE_LOADING=2,e.DELAYLOADSTATE_NOTLOADED=4,e.NEVER=512,e.ALWAYS=519,e.LESS=513,e.EQUAL=514,e.LEQUAL=515,e.GREATER=516,e.GEQUAL=518,e.NOTEQUAL=517,e.KEEP=7680,e.REPLACE=7681,e.INCR=7682,e.DECR=7683,e.INVERT=5386,e.INCR_WRAP=34055,e.DECR_WRAP=34056,e.TEXTURE_CLAMP_ADDRESSMODE=0,e.TEXTURE_WRAP_ADDRESSMODE=1,e.TEXTURE_MIRROR_ADDRESSMODE=2,e.TEXTUREFORMAT_ALPHA=0,e.TEXTUREFORMAT_LUMINANCE=1,e.TEXTUREFORMAT_LUMINANCE_ALPHA=2,e.TEXTUREFORMAT_RGB=4,e.TEXTUREFORMAT_RGBA=5,e.TEXTUREFORMAT_RED=6,e.TEXTUREFORMAT_R=6,e.TEXTUREFORMAT_RG=7,e.TEXTUREFORMAT_RED_INTEGER=8,e.TEXTUREFORMAT_R_INTEGER=8,e.TEXTUREFORMAT_RG_INTEGER=9,e.TEXTUREFORMAT_RGB_INTEGER=10,e.TEXTUREFORMAT_RGBA_INTEGER=11,e.TEXTURETYPE_UNSIGNED_BYTE=0,e.TEXTURETYPE_UNSIGNED_INT=0,e.TEXTURETYPE_FLOAT=1,e.TEXTURETYPE_HALF_FLOAT=2,e.TEXTURETYPE_BYTE=3,e.TEXTURETYPE_SHORT=4,e.TEXTURETYPE_UNSIGNED_SHORT=5,e.TEXTURETYPE_INT=6,e.TEXTURETYPE_UNSIGNED_INTEGER=7,e.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4=8,e.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1=9,e.TEXTURETYPE_UNSIGNED_SHORT_5_6_5=10,e.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV=11,e.TEXTURETYPE_UNSIGNED_INT_24_8=12,e.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV=13,e.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV=14,e.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV=15,e.TEXTURE_NEAREST_SAMPLINGMODE=1,e.TEXTURE_BILINEAR_SAMPLINGMODE=2,e.TEXTURE_TRILINEAR_SAMPLINGMODE=3,e.TEXTURE_NEAREST_NEAREST_MIPLINEAR=1,e.TEXTURE_LINEAR_LINEAR_MIPNEAREST=2,e.TEXTURE_LINEAR_LINEAR_MIPLINEAR=3,e.TEXTURE_NEAREST_NEAREST_MIPNEAREST=4,e.TEXTURE_NEAREST_LINEAR_MIPNEAREST=5,e.TEXTURE_NEAREST_LINEAR_MIPLINEAR=6,e.TEXTURE_NEAREST_LINEAR=7,e.TEXTURE_NEAREST_NEAREST=8,e.TEXTURE_LINEAR_NEAREST_MIPNEAREST=9,e.TEXTURE_LINEAR_NEAREST_MIPLINEAR=10,e.TEXTURE_LINEAR_LINEAR=11,e.TEXTURE_LINEAR_NEAREST=12,e.TEXTURE_EXPLICIT_MODE=0,e.TEXTURE_SPHERICAL_MODE=1,e.TEXTURE_PLANAR_MODE=2,e.TEXTURE_CUBIC_MODE=3,e.TEXTURE_PROJECTION_MODE=4,e.TEXTURE_SKYBOX_MODE=5,e.TEXTURE_INVCUBIC_MODE=6,e.TEXTURE_EQUIRECTANGULAR_MODE=7,e.TEXTURE_FIXED_EQUIRECTANGULAR_MODE=8,e.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE=9,e.SCALEMODE_FLOOR=1,e.SCALEMODE_NEAREST=2,e.SCALEMODE_CEILING=3,e.MATERIAL_TextureDirtyFlag=1,e.MATERIAL_LightDirtyFlag=2,e.MATERIAL_FresnelDirtyFlag=4,e.MATERIAL_AttributesDirtyFlag=8,e.MATERIAL_MiscDirtyFlag=16,e.MATERIAL_AllDirtyFlag=31,e.MATERIAL_TriangleFillMode=0,e.MATERIAL_WireFrameFillMode=1,e.MATERIAL_PointFillMode=2,e.MATERIAL_PointListDrawMode=3,e.MATERIAL_LineListDrawMode=4,e.MATERIAL_LineLoopDrawMode=5,e.MATERIAL_LineStripDrawMode=6,e.MATERIAL_TriangleStripDrawMode=7,e.MATERIAL_TriangleFanDrawMode=8,e.MATERIAL_ClockWiseSideOrientation=0,e.MATERIAL_CounterClockWiseSideOrientation=1,e.ACTION_NothingTrigger=0,e.ACTION_OnPickTrigger=1,e.ACTION_OnLeftPickTrigger=2,e.ACTION_OnRightPickTrigger=3,e.ACTION_OnCenterPickTrigger=4,e.ACTION_OnPickDownTrigger=5,e.ACTION_OnDoublePickTrigger=6,e.ACTION_OnPickUpTrigger=7,e.ACTION_OnPickOutTrigger=16,e.ACTION_OnLongPressTrigger=8,e.ACTION_OnPointerOverTrigger=9,e.ACTION_OnPointerOutTrigger=10,e.ACTION_OnEveryFrameTrigger=11,e.ACTION_OnIntersectionEnterTrigger=12,e.ACTION_OnIntersectionExitTrigger=13,e.ACTION_OnKeyDownTrigger=14,e.ACTION_OnKeyUpTrigger=15,e.PARTICLES_BILLBOARDMODE_Y=2,e.PARTICLES_BILLBOARDMODE_ALL=7,e.PARTICLES_BILLBOARDMODE_STRETCHED=8,e.PARTICLES_BaseAssetsUrl="https://assets.babylonjs.com/particles",e.MESHES_CULLINGSTRATEGY_STANDARD=0,e.MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY=1,e.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION=2,e.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY=3,e.SCENELOADER_NO_LOGGING=0,e.SCENELOADER_MINIMAL_LOGGING=1,e.SCENELOADER_SUMMARY_LOGGING=2,e.SCENELOADER_DETAILED_LOGGING=3,e}()},function(e,t,i){"use strict";i.d(t,"a",function(){return r}),i.d(t,"b",function(){return n});var r=function(){function e(e,t,i,r,n,o,s){void 0===r&&(r=0),void 0===n&&(n=!1),void 0===o&&(o=!1),void 0===s&&(s=!1),e.getScene?this._engine=e.getScene().getEngine():this._engine=e,this._updatable=i,this._instanced=o,this._data=t,this.byteStride=s?r:r*Float32Array.BYTES_PER_ELEMENT,n||this.create()}return e.prototype.createVertexBuffer=function(e,t,i,r,o,s){void 0===s&&(s=!1);var a=s?t:t*Float32Array.BYTES_PER_ELEMENT,c=r?s?r:r*Float32Array.BYTES_PER_ELEMENT:this.byteStride;return new n(this._engine,this,e,this._updatable,!0,c,void 0===o?this._instanced:o,a,i,void 0,void 0,!0)},e.prototype.isUpdatable=function(){return this._updatable},e.prototype.getData=function(){return this._data},e.prototype.getBuffer=function(){return this._buffer},e.prototype.getStrideSize=function(){return this.byteStride/Float32Array.BYTES_PER_ELEMENT},e.prototype.create=function(e){void 0===e&&(e=null),!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))},e.prototype._rebuild=function(){this._buffer=null,this.create(this._data)},e.prototype.update=function(e){this.create(e)},e.prototype.updateDirectly=function(e,t,i,r){void 0===r&&(r=!1),this._buffer&&this._updatable&&(this._engine.updateDynamicVertexBuffer(this._buffer,e,r?t:t*Float32Array.BYTES_PER_ELEMENT,i?i*this.byteStride:void 0),this._data=null)},e.prototype.dispose=function(){this._buffer&&this._engine._releaseBuffer(this._buffer)&&(this._buffer=null)},e}(),n=function(){function e(t,i,n,o,s,a,c,l,u,h,d,f){if(void 0===d&&(d=!1),void 0===f&&(f=!1),i instanceof r?(this._buffer=i,this._ownsBuffer=!1):(this._buffer=new r(t,i,o,a,s,c,f),this._ownsBuffer=!0),this._kind=n,null==h){var p=this.getData();this.type=e.FLOAT,p instanceof Int8Array?this.type=e.BYTE:p instanceof Uint8Array?this.type=e.UNSIGNED_BYTE:p instanceof Int16Array?this.type=e.SHORT:p instanceof Uint16Array?this.type=e.UNSIGNED_SHORT:p instanceof Int32Array?this.type=e.INT:p instanceof Uint32Array&&(this.type=e.UNSIGNED_INT)}else this.type=h;var _=e.GetTypeByteLength(this.type);f?(this._size=u||(a?a/_:e.DeduceStride(n)),this.byteStride=a||this._buffer.byteStride||this._size*_,this.byteOffset=l||0):(this._size=u||a||e.DeduceStride(n),this.byteStride=a?a*_:this._buffer.byteStride||this._size*_,this.byteOffset=(l||0)*_),this.normalized=d,this._instanced=void 0!==c&&c,this._instanceDivisor=c?1:0}return Object.defineProperty(e.prototype,"instanceDivisor",{get:function(){return this._instanceDivisor},set:function(e){this._instanceDivisor=e,this._instanced=0!=e},enumerable:!0,configurable:!0}),e.prototype._rebuild=function(){this._buffer&&this._buffer._rebuild()},e.prototype.getKind=function(){return this._kind},e.prototype.isUpdatable=function(){return this._buffer.isUpdatable()},e.prototype.getData=function(){return this._buffer.getData()},e.prototype.getBuffer=function(){return this._buffer.getBuffer()},e.prototype.getStrideSize=function(){return this.byteStride/e.GetTypeByteLength(this.type)},e.prototype.getOffset=function(){return this.byteOffset/e.GetTypeByteLength(this.type)},e.prototype.getSize=function(){return this._size},e.prototype.getIsInstanced=function(){return this._instanced},e.prototype.getInstanceDivisor=function(){return this._instanceDivisor},e.prototype.create=function(e){this._buffer.create(e)},e.prototype.update=function(e){this._buffer.update(e)},e.prototype.updateDirectly=function(e,t,i){void 0===i&&(i=!1),this._buffer.updateDirectly(e,t,void 0,i)},e.prototype.dispose=function(){this._ownsBuffer&&this._buffer.dispose()},e.prototype.forEach=function(t,i){e.ForEach(this._buffer.getData(),this.byteOffset,this.byteStride,this._size,this.type,t,this.normalized,i)},e.DeduceStride=function(t){switch(t){case e.UVKind:case e.UV2Kind:case e.UV3Kind:case e.UV4Kind:case e.UV5Kind:case e.UV6Kind:return 2;case e.NormalKind:case e.PositionKind:return 3;case e.ColorKind:case e.MatricesIndicesKind:case e.MatricesIndicesExtraKind:case e.MatricesWeightsKind:case e.MatricesWeightsExtraKind:case e.TangentKind:return 4;default:throw new Error("Invalid kind '"+t+"'")}},e.GetTypeByteLength=function(t){switch(t){case e.BYTE:case e.UNSIGNED_BYTE:return 1;case e.SHORT:case e.UNSIGNED_SHORT:return 2;case e.INT:case e.FLOAT:return 4;default:throw new Error("Invalid type '"+t+"'")}},e.ForEach=function(t,i,r,n,o,s,a,c){if(t instanceof Array)for(var l=i/4,u=r/4,h=0;h<s;h+=n){for(var d=0;d<n;d++)c(t[l+d],h+d);l+=u}else{var f=t instanceof ArrayBuffer?new DataView(t):new DataView(t.buffer,t.byteOffset,t.byteLength),p=e.GetTypeByteLength(o);for(h=0;h<s;h+=n){var _=i;for(d=0;d<n;d++){c(e._GetFloatValue(f,o,_,a),h+d),_+=p}i+=r}}},e._GetFloatValue=function(t,i,r,n){switch(i){case e.BYTE:var o=t.getInt8(r);return n&&(o=Math.max(o/127,-1)),o;case e.UNSIGNED_BYTE:o=t.getUint8(r);return n&&(o/=255),o;case e.SHORT:o=t.getInt16(r,!0);return n&&(o=Math.max(o/16383,-1)),o;case e.UNSIGNED_SHORT:o=t.getUint16(r,!0);return n&&(o/=65535),o;case e.FLOAT:return t.getFloat32(r,!0);default:throw new Error("Invalid component type "+i)}},e.BYTE=5120,e.UNSIGNED_BYTE=5121,e.SHORT=5122,e.UNSIGNED_SHORT=5123,e.INT=5124,e.UNSIGNED_INT=5125,e.FLOAT=5126,e.PositionKind="position",e.NormalKind="normal",e.TangentKind="tangent",e.UVKind="uv",e.UV2Kind="uv2",e.UV3Kind="uv3",e.UV4Kind="uv4",e.UV5Kind="uv5",e.UV6Kind="uv6",e.ColorKind="color",e.MatricesIndicesKind="matricesIndices",e.MatricesWeightsKind="matricesWeights",e.MatricesIndicesExtraKind="matricesIndicesExtra",e.MatricesWeightsExtraKind="matricesWeightsExtra",e}()},function(e,t,i){"use strict";i.d(t,"c",function(){return a}),i.d(t,"b",function(){return c}),i.d(t,"a",function(){return l});var r=i(7),n=i(3),o=i(38),s=i(8),a=function(){function e(){this._defines={},this._currentRank=32,this._maxRank=-1}return e.prototype.unBindMesh=function(){this._mesh=null},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._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,t){if(this._mesh&&this._mesh.computeBonesUsingShaders&&this._mesh.numBoneInfluencers>0&&this._mesh.material){this._mesh.computeBonesUsingShaders=!1,e=e.replace("#define NUM_BONE_INFLUENCERS "+this._mesh.numBoneInfluencers,"#define NUM_BONE_INFLUENCERS 0"),t._bonesComputationForcedToCPU=!0;for(var i=this._mesh.getScene(),r=0;r<i.meshes.length;r++){var n=i.meshes[r];if(n.material&&(n.computeBonesUsingShaders&&0!==n.numBoneInfluencers))if(n.material.getEffect()===t)n.computeBonesUsingShaders=!1;else if(n.subMeshes)for(var o=0,s=n.subMeshes;o<s.length;o++){if(s[o].effect===t){n.computeBonesUsingShaders=!1;break}}}}else{var a=this._defines[this._currentRank];if(a)for(r=0;r<a.length;r++)e=e.replace("#define "+a[r],"");this._currentRank++}return e},e}(),c=function(){return function(){}}(),l=function(){function e(t,i,n,o,s,a,c,l,u,h){void 0===o&&(o=null),void 0===a&&(a=null),void 0===c&&(c=null),void 0===l&&(l=null),void 0===u&&(u=null);var d,f,p=this;if(this.uniqueId=0,this.onCompileObservable=new r.c,this.onErrorObservable=new r.c,this._bonesComputationForcedToCPU=!1,this._uniformBuffersNames={},this._isReady=!1,this._compilationError="",this.name=t,i.attributes){var _=i;if(this._engine=n,this._attributesNames=_.attributes,this._uniformsNames=_.uniformsNames.concat(_.samplers),this._samplers=_.samplers.slice(),this.defines=_.defines,this.onError=_.onError,this.onCompiled=_.onCompiled,this._fallbacks=_.fallbacks,this._indexParameters=_.indexParameters,this._transformFeedbackVaryings=_.transformFeedbackVaryings,_.uniformBuffersNames)for(var g=0;g<_.uniformBuffersNames.length;g++)this._uniformBuffersNames[_.uniformBuffersNames[g]]=g}else this._engine=s,this.defines=a,this._uniformsNames=n.concat(o),this._samplers=o?o.slice():[],this._attributesNames=i,this.onError=u,this.onCompiled=l,this._indexParameters=h,this._fallbacks=c;this.uniqueId=e._uniqueIdSeed++,t.vertexElement?(d=document.getElementById(t.vertexElement))||(d=t.vertexElement):d=t.vertex||t,t.fragmentElement?(f=document.getElementById(t.fragmentElement))||(f=t.fragmentElement):f=t.fragment||t,this._loadVertexShader(d,function(e){p._processIncludes(e,function(e){p._processShaderConversion(e,!1,function(e){p._loadFragmentShader(f,function(i){p._processIncludes(i,function(i){p._processShaderConversion(i,!0,function(i){if(t){var r=t.vertexElement||t.vertex||t,n=t.fragmentElement||t.fragment||t;p._vertexSourceCode="#define SHADER_NAME vertex:"+r+"\n"+e,p._fragmentSourceCode="#define SHADER_NAME fragment:"+n+"\n"+i}else p._vertexSourceCode=e,p._fragmentSourceCode=i;p._prepareEffect()})})})})})})}return Object.defineProperty(e.prototype,"onBindObservable",{get:function(){return this._onBindObservable||(this._onBindObservable=new r.c),this._onBindObservable},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"key",{get:function(){return this._key},enumerable:!0,configurable:!0}),e.prototype.isReady=function(){return!this._isReady&&this._program&&this._program.isParallelCompiled?this._engine._isProgramCompiled(this._program):this._isReady},e.prototype.getEngine=function(){return this._engine},e.prototype.getProgram=function(){return this._program},e.prototype.getAttributesNames=function(){return this._attributesNames},e.prototype.getAttributeLocation=function(e){return this._attributes[e]},e.prototype.getAttributeLocationByName=function(e){var t=this._attributesNames.indexOf(e);return this._attributes[t]},e.prototype.getAttributesCount=function(){return this._attributes.length},e.prototype.getUniformIndex=function(e){return this._uniformsNames.indexOf(e)},e.prototype.getUniform=function(e){return this._uniforms[this._uniformsNames.indexOf(e)]},e.prototype.getSamplers=function(){return this._samplers},e.prototype.getCompilationError=function(){return this._compilationError},e.prototype.executeWhenCompiled=function(e){var t=this;this.isReady()?e(this):(this.onCompileObservable.add(function(t){e(t)}),this._program&&!this._program.isParallelCompiled||setTimeout(function(){t._checkIsReady()},16))},e.prototype._checkIsReady=function(){var e=this;this.isReady()||setTimeout(function(){e._checkIsReady()},16)},e.prototype._loadVertexShader=function(t,i){var r;if(o.a.IsWindowObjectExist()&&t instanceof HTMLElement)return void i(o.a.GetDOMTextContent(t));"base64:"!==t.substr(0,7)?e.ShadersStore[t+"VertexShader"]?i(e.ShadersStore[t+"VertexShader"]):(r="."===t[0]||"/"===t[0]||t.indexOf("http")>-1?t:e.ShadersRepository+t,this._engine._loadFile(r+".vertex.fx",i)):i(window.atob(t.substr(7)))},e.prototype._loadFragmentShader=function(t,i){var r;if(o.a.IsWindowObjectExist()&&t instanceof HTMLElement)return void i(o.a.GetDOMTextContent(t));"base64:"!==t.substr(0,7)?e.ShadersStore[t+"PixelShader"]?i(e.ShadersStore[t+"PixelShader"]):e.ShadersStore[t+"FragmentShader"]?i(e.ShadersStore[t+"FragmentShader"]):(r="."===t[0]||"/"===t[0]||t.indexOf("http")>-1?t:e.ShadersRepository+t,this._engine._loadFile(r+".fragment.fx",i)):i(window.atob(t.substr(7)))},e.prototype._dumpShadersSource=function(e,t,i){var r=(this._engine.webGLVersion>1?"#version 300 es\n#define WEBGL2 \n":"")+(i?i+"\n":"");t=r+t;var n=2,o=/\n/gm,a="\n1\t"+(e=r+e).replace(o,function(){return"\n"+n+++"\t"});n=2;var c="\n1\t"+t.replace(o,function(){return"\n"+n+++"\t"});this.name.vertexElement?(s.a.Error("Vertex shader: "+this.name.vertexElement+a),s.a.Error("Fragment shader: "+this.name.fragmentElement+c)):this.name.vertex?(s.a.Error("Vertex shader: "+this.name.vertex+a),s.a.Error("Fragment shader: "+this.name.fragment+c)):(s.a.Error("Vertex shader: "+this.name+a),s.a.Error("Fragment shader: "+this.name+c))},e.prototype._processShaderConversion=function(e,t,i){var r=this._processPrecision(e);if(1!=this._engine.webGLVersion)if(-1===r.indexOf("#version 3")){var n=-1!==r.search(/#extension.+GL_EXT_draw_buffers.+require/),o=r.replace(/#extension.+(GL_OES_standard_derivatives|GL_EXT_shader_texture_lod|GL_EXT_frag_depth|GL_EXT_draw_buffers).+(enable|require)/g,"");o=(o=(o=(o=o.replace(/varying(?![\n\r])\s/g,t?"in ":"out ")).replace(/attribute[ \t]/g,"in ")).replace(/[ \t]attribute/g," in")).replace(/texture2D\s*\(/g,"texture("),t&&(o=(o=(o=(o=(o=(o=(o=o.replace(/texture2DLodEXT\s*\(/g,"textureLod(")).replace(/textureCubeLodEXT\s*\(/g,"textureLod(")).replace(/textureCube\s*\(/g,"texture(")).replace(/gl_FragDepthEXT/g,"gl_FragDepth")).replace(/gl_FragColor/g,"glFragColor")).replace(/gl_FragData/g,"glFragData")).replace(/void\s+?main\s*\(/g,(n?"":"out vec4 glFragColor;\n")+"void main(")),i(o)}else i(r.replace("#version 300 es",""));else i(r)},e.prototype._processIncludes=function(t,i){for(var r=this,n=/#include<(.+)>(\((.*)\))*(\[(.*)\])*/g,o=n.exec(t),s=new String(t);null!=o;){var a=o[1];if(-1!==a.indexOf("__decl__")&&(a=a.replace(/__decl__/,""),this._engine.supportsUniformBuffers&&(a=(a=a.replace(/Vertex/,"Ubo")).replace(/Fragment/,"Ubo")),a+="Declaration"),!e.IncludesShadersStore[a]){var c=e.ShadersRepository+"ShadersInclude/"+a+".fx";return void this._engine._loadFile(c,function(t){e.IncludesShadersStore[a]=t,r._processIncludes(s,i)})}var l=e.IncludesShadersStore[a];if(o[2])for(var u=o[3].split(","),h=0;h<u.length;h+=2){var d=new RegExp(u[h],"g"),f=u[h+1];l=l.replace(d,f)}if(o[4]){var p=o[5];if(-1!==p.indexOf("..")){var _=p.split(".."),g=parseInt(_[0]),m=parseInt(_[1]),v=l.slice(0);l="",isNaN(m)&&(m=this._indexParameters[_[1]]);for(var y=g;y<m;y++)this._engine.supportsUniformBuffers||(v=v.replace(/light\{X\}.(\w*)/g,function(e,t){return t+"{X}"})),l+=v.replace(/\{X\}/g,y.toString())+"\n"}else this._engine.supportsUniformBuffers||(l=l.replace(/light\{X\}.(\w*)/g,function(e,t){return t+"{X}"})),l=l.replace(/\{X\}/g,p)}s=s.replace(o[0],l),o=n.exec(t)}i(s)},e.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},e.prototype._rebuildProgram=function(e,t,i,r){var o=this;this._isReady=!1,this._vertexSourceCodeOverride=e,this._fragmentSourceCodeOverride=t,this.onError=function(e,t){r&&r(t)},this.onCompiled=function(){for(var e=o.getEngine().scenes,t=0;t<e.length;t++)e[t].markAllMaterialsAsDirty(n.a.MATERIAL_TextureDirtyFlag);i&&i(o._program)},this._fallbacks=null,this._prepareEffect()},e.prototype.getSpecificUniformLocations=function(e){return this._engine.getUniforms(this._program,e)},e.prototype._prepareEffect=function(){var e=this,t=this._attributesNames,i=this.defines,r=this._fallbacks;this._valueCache={};var n=this._program;try{var o=this._engine;this._vertexSourceCodeOverride&&this._fragmentSourceCodeOverride?this._program=o.createRawShaderProgram(this._vertexSourceCodeOverride,this._fragmentSourceCodeOverride,void 0,this._transformFeedbackVaryings):this._program=o.createShaderProgram(this._vertexSourceCode,this._fragmentSourceCode,i,void 0,this._transformFeedbackVaryings),this._program.__SPECTOR_rebuildProgram=this._rebuildProgram.bind(this),o._executeWhenProgramIsCompiled(this._program,function(){if(o.supportsUniformBuffers)for(var i in e._uniformBuffersNames)e.bindUniformBlock(i,e._uniformBuffersNames[i]);var r;for(e._uniforms=o.getUniforms(e._program,e._uniformsNames),e._attributes=o.getAttributes(e._program,t),r=0;r<e._samplers.length;r++){null==e.getUniform(e._samplers[r])&&(e._samplers.splice(r,1),r--)}o.bindSamplers(e),e._compilationError="",e._isReady=!0,e.onCompiled&&e.onCompiled(e),e.onCompileObservable.notifyObservers(e),e.onCompileObservable.clear(),e._fallbacks&&e._fallbacks.unBindMesh(),n&&e.getEngine()._deleteProgram(n)}),this._program.isParallelCompiled&&this._checkIsReady()}catch(e){this._compilationError=e.message,s.a.Error("Unable to compile effect:"),s.a.Error("Uniforms: "+this._uniformsNames.map(function(e){return" "+e})),s.a.Error("Attributes: "+t.map(function(e){return" "+e})),s.a.Error("Error: "+this._compilationError),n&&(this._program=n,this._isReady=!0,this.onError&&this.onError(this,this._compilationError),this.onErrorObservable.notifyObservers(this)),r&&r.isMoreFallbacks?(s.a.Error("Trying next fallback."),this.defines=r.reduce(this.defines,this),this._prepareEffect()):(this.onError&&this.onError(this,this._compilationError),this.onErrorObservable.notifyObservers(this),this.onErrorObservable.clear(),this._fallbacks&&this._fallbacks.unBindMesh())}},Object.defineProperty(e.prototype,"isSupported",{get:function(){return""===this._compilationError},enumerable:!0,configurable:!0}),e.prototype._bindTexture=function(e,t){this._engine._bindTexture(this._samplers.indexOf(e),t)},e.prototype.setTexture=function(e,t){this._engine.setTexture(this._samplers.indexOf(e),this.getUniform(e),t)},e.prototype.setDepthStencilTexture=function(e,t){this._engine.setDepthStencilTexture(this._samplers.indexOf(e),this.getUniform(e),t)},e.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)},e.prototype.setTextureFromPostProcess=function(e,t){this._engine.setTextureFromPostProcess(this._samplers.indexOf(e),t)},e.prototype.setTextureFromPostProcessOutput=function(e,t){this._engine.setTextureFromPostProcessOutput(this._samplers.indexOf(e),t)},e.prototype._cacheMatrix=function(e,t){var i=this._valueCache[e],r=t.updateFlag;return(void 0===i||i!==r)&&(this._valueCache[e]=r,!0)},e.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},e.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 o=!1;return n[0]!==t&&(n[0]=t,o=!0),n[1]!==i&&(n[1]=i,o=!0),n[2]!==r&&(n[2]=r,o=!0),o},e.prototype._cacheFloat4=function(e,t,i,r,n){var o=this._valueCache[e];if(!o)return o=[t,i,r,n],this._valueCache[e]=o,!0;var s=!1;return o[0]!==t&&(o[0]=t,s=!0),o[1]!==i&&(o[1]=i,s=!0),o[2]!==r&&(o[2]=r,s=!0),o[3]!==n&&(o[3]=n,s=!0),s},e.prototype.bindUniformBuffer=function(t,i){var r=this._uniformBuffersNames[i];void 0!==r&&e._baseCache[r]!==t&&(e._baseCache[r]=t,this._engine.bindUniformBufferBase(t,r))},e.prototype.bindUniformBlock=function(e,t){this._engine.bindUniformBlock(this._program,e,t)},e.prototype.setInt=function(e,t){var i=this._valueCache[e];return void 0!==i&&i===t?this:(this._valueCache[e]=t,this._engine.setInt(this.getUniform(e),t),this)},e.prototype.setIntArray=function(e,t){return this._valueCache[e]=null,this._engine.setIntArray(this.getUniform(e),t),this},e.prototype.setIntArray2=function(e,t){return this._valueCache[e]=null,this._engine.setIntArray2(this.getUniform(e),t),this},e.prototype.setIntArray3=function(e,t){return this._valueCache[e]=null,this._engine.setIntArray3(this.getUniform(e),t),this},e.prototype.setIntArray4=function(e,t){return this._valueCache[e]=null,this._engine.setIntArray4(this.getUniform(e),t),this},e.prototype.setFloatArray=function(e,t){return this._valueCache[e]=null,this._engine.setFloatArray(this.getUniform(e),t),this},e.prototype.setFloatArray2=function(e,t){return this._valueCache[e]=null,this._engine.setFloatArray2(this.getUniform(e),t),this},e.prototype.setFloatArray3=function(e,t){return this._valueCache[e]=null,this._engine.setFloatArray3(this.getUniform(e),t),this},e.prototype.setFloatArray4=function(e,t){return this._valueCache[e]=null,this._engine.setFloatArray4(this.getUniform(e),t),this},e.prototype.setArray=function(e,t){return this._valueCache[e]=null,this._engine.setArray(this.getUniform(e),t),this},e.prototype.setArray2=function(e,t){return this._valueCache[e]=null,this._engine.setArray2(this.getUniform(e),t),this},e.prototype.setArray3=function(e,t){return this._valueCache[e]=null,this._engine.setArray3(this.getUniform(e),t),this},e.prototype.setArray4=function(e,t){return this._valueCache[e]=null,this._engine.setArray4(this.getUniform(e),t),this},e.prototype.setMatrices=function(e,t){return t?(this._valueCache[e]=null,this._engine.setMatrices(this.getUniform(e),t),this):this},e.prototype.setMatrix=function(e,t){return this._cacheMatrix(e,t)&&this._engine.setMatrix(this.getUniform(e),t),this},e.prototype.setMatrix3x3=function(e,t){return this._valueCache[e]=null,this._engine.setMatrix3x3(this.getUniform(e),t),this},e.prototype.setMatrix2x2=function(e,t){return this._valueCache[e]=null,this._engine.setMatrix2x2(this.getUniform(e),t),this},e.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)},e.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)},e.prototype.setVector2=function(e,t){return this._cacheFloat2(e,t.x,t.y)&&this._engine.setFloat2(this.getUniform(e),t.x,t.y),this},e.prototype.setFloat2=function(e,t,i){return this._cacheFloat2(e,t,i)&&this._engine.setFloat2(this.getUniform(e),t,i),this},e.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},e.prototype.setFloat3=function(e,t,i,r){return this._cacheFloat3(e,t,i,r)&&this._engine.setFloat3(this.getUniform(e),t,i,r),this},e.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},e.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},e.prototype.setColor3=function(e,t){return this._cacheFloat3(e,t.r,t.g,t.b)&&this._engine.setColor3(this.getUniform(e),t),this},e.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},e.prototype.setDirectColor4=function(e,t){return this._cacheFloat4(e,t.r,t.g,t.b,t.a)&&this._engine.setDirectColor4(this.getUniform(e),t),this},e.RegisterShader=function(t,i,r){i&&(e.ShadersStore[t+"PixelShader"]=i),r&&(e.ShadersStore[t+"VertexShader"]=r)},e.ResetCache=function(){e._baseCache={}},e.ShadersRepository="src/Shaders/",e._uniqueIdSeed=0,e._baseCache={},e.ShadersStore={},e.IncludesShadersStore={},e}()},function(e,t,i){"use strict";i.d(t,"a",function(){return h});var r=i(1),n=i(2),o=i(7),s=i(9),a=i(0),c=i(44),l=i(3),u=i(20),h=function(e){function t(i,r,n,a,c,u,h,d,f,p){void 0===n&&(n=!1),void 0===a&&(a=!0),void 0===c&&(c=t.TRILINEAR_SAMPLINGMODE),void 0===u&&(u=null),void 0===h&&(h=null),void 0===d&&(d=null),void 0===f&&(f=!1);var _=e.call(this,r)||this;if(_.uOffset=0,_.vOffset=0,_.uScale=1,_.vScale=1,_.uAng=0,_.vAng=0,_.wAng=0,_.uRotationCenter=.5,_.vRotationCenter=.5,_.wRotationCenter=.5,_._initialSamplingMode=t.BILINEAR_SAMPLINGMODE,_.onLoadObservable=new o.c,_._isBlocking=!0,_.name=i||"",_.url=i,_._noMipmap=n,_._invertY=a,_._initialSamplingMode=c,_._buffer=d,_._deleteBuffer=f,p&&(_._format=p),!(r=_.getScene()))return _;r.getEngine().onBeforeTextureInitObservable.notifyObservers(_);var g=function(){_._texture&&_._texture._invertVScale&&(_.vScale=-1),_.onLoadObservable.hasObservers()&&_.onLoadObservable.notifyObservers(_),u&&u(),!_.isBlocking&&r&&r.resetCachedMaterial()};return _.url?(_._texture=_._getFromCache(_.url,n,c),_._texture?_._texture.isReady?s.h.SetImmediate(function(){return g()}):_._texture.onLoadedObservable.add(g):r.useDelayedTextureLoading?(_.delayLoadState=l.a.DELAYLOADSTATE_NOTLOADED,_._delayedOnLoad=g,_._delayedOnError=h):(_._texture=r.getEngine().createTexture(_.url,n,a,r,c,g,h,_._buffer,void 0,_._format),f&&delete _._buffer),_):(_._delayedOnLoad=g,_._delayedOnError=h,_)}return r.d(t,e),Object.defineProperty(t.prototype,"noMipmap",{get:function(){return this._noMipmap},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isBlocking",{get:function(){return this._isBlocking},set:function(e){this._isBlocking=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"samplingMode",{get:function(){return this._texture?this._texture.samplingMode:this._initialSamplingMode},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"invertY",{get:function(){return this._invertY},enumerable:!0,configurable:!0}),t.prototype.updateURL=function(e,t,i){void 0===t&&(t=null),this.url&&(this.releaseInternalTexture(),this.getScene().markAllMaterialsAsDirty(l.a.MATERIAL_TextureDirtyFlag)),this.url=e,this._buffer=t,this.delayLoadState=l.a.DELAYLOADSTATE_NOTLOADED,i&&(this._delayedOnLoad=i),this.delayLoad()},t.prototype.delayLoad=function(){if(this.delayLoadState===l.a.DELAYLOADSTATE_NOTLOADED){var e=this.getScene();e&&(this.delayLoadState=l.a.DELAYLOADSTATE_LOADED,this._texture=this._getFromCache(this.url,this._noMipmap,this.samplingMode),this._texture?this._delayedOnLoad&&(this._texture.isReady?s.h.SetImmediate(this._delayedOnLoad):this._texture.onLoadedObservable.add(this._delayedOnLoad)):(this._texture=e.getEngine().createTexture(this.url,this._noMipmap,this._invertY,e,this.samplingMode,this._delayedOnLoad,this._delayedOnError,this._buffer,null,this._format),this._deleteBuffer&&delete this._buffer),this._delayedOnLoad=null,this._delayedOnError=null)}},t.prototype._prepareRowForTextureGeneration=function(e,t,i,r){e*=this.uScale,t*=this.vScale,e-=this.uRotationCenter*this.uScale,t-=this.vRotationCenter*this.vScale,i-=this.wRotationCenter,a.x.TransformCoordinatesFromFloatsToRef(e,t,i,this._rowGenerationMatrix,r),r.x+=this.uRotationCenter*this.uScale+this.uOffset,r.y+=this.vRotationCenter*this.vScale+this.vOffset,r.z+=this.wRotationCenter},t.prototype.getTextureMatrix=function(){var e=this;if(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)return 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=a.j.Zero(),this._rowGenerationMatrix=new a.j,this._t0=a.x.Zero(),this._t1=a.x.Zero(),this._t2=a.x.Zero()),a.j.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),a.j.FromValuesToRef(this._t1.x,this._t1.y,this._t1.z,0,this._t2.x,this._t2.y,this._t2.z,0,this._t0.x,this._t0.y,this._t0.z,0,0,0,0,1,this._cachedTextureMatrix);var t=this.getScene();return t?(t.markAllMaterialsAsDirty(l.a.MATERIAL_TextureDirtyFlag,function(t){return t.hasTexture(e)}),this._cachedTextureMatrix):this._cachedTextureMatrix},t.prototype.getReflectionTextureMatrix=function(){var e=this,i=this.getScene();if(!i)return this._cachedTextureMatrix;if(this.uOffset===this._cachedUOffset&&this.vOffset===this._cachedVOffset&&this.uScale===this._cachedUScale&&this.vScale===this._cachedVScale&&this.coordinatesMode===this._cachedCoordinatesMode){if(this.coordinatesMode!==t.PROJECTION_MODE)return this._cachedTextureMatrix;if(this._cachedProjectionMatrixId===i.getProjectionMatrix().updateFlag)return this._cachedTextureMatrix}switch(this._cachedTextureMatrix||(this._cachedTextureMatrix=a.j.Zero()),this._projectionModeMatrix||(this._projectionModeMatrix=a.j.Zero()),this._cachedUOffset=this.uOffset,this._cachedVOffset=this.vOffset,this._cachedUScale=this.uScale,this._cachedVScale=this.vScale,this._cachedCoordinatesMode=this.coordinatesMode,this.coordinatesMode){case t.PLANAR_MODE:a.j.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 t.PROJECTION_MODE:a.j.FromValuesToRef(.5,0,0,0,0,-.5,0,0,0,0,0,0,.5,.5,1,1,this._projectionModeMatrix);var r=i.getProjectionMatrix();this._cachedProjectionMatrixId=r.updateFlag,r.multiplyToRef(this._projectionModeMatrix,this._cachedTextureMatrix);break;default:a.j.IdentityToRef(this._cachedTextureMatrix)}return i.markAllMaterialsAsDirty(l.a.MATERIAL_TextureDirtyFlag,function(t){return-1!==t.getActiveTextures().indexOf(e)}),this._cachedTextureMatrix},t.prototype.clone=function(){var e=this;return n.a.Clone(function(){return new t(e._texture?e._texture.url:null,e.getScene(),e._noMipmap,e._invertY,e.samplingMode)},this)},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return"string"==typeof this._buffer&&"data:"===this._buffer.substr(0,5)&&(t.base64String=this._buffer,t.name=t.name.replace("data:","")),t.invertY=this._invertY,t.samplingMode=this.samplingMode,t},t.prototype.getClassName=function(){return"Texture"},t.prototype.dispose=function(){e.prototype.dispose.call(this),this.onLoadObservable.clear(),this._delayedOnLoad=null,this._delayedOnError=null},t.Parse=function(e,i,r){if(e.customType){var o=s.h.Instantiate(e.customType).Parse(e,i,r);return e.samplingMode&&o.updateSamplingMode&&o._samplingMode&&o._samplingMode!==e.samplingMode&&o.updateSamplingMode(e.samplingMode),o}if(e.isCube&&!e.isRenderTarget)return t._CubeTextureParser(e,i,r);if(!e.name&&!e.isRenderTarget)return null;var c=n.a.Parse(function(){var n,o=!0;if(e.noMipmap&&(o=!1),e.mirrorPlane){var s=t._CreateMirror(e.name,e.renderTargetSize,i,o);return s._waitingRenderList=e.renderList,s.mirrorPlane=a.n.FromArray(e.mirrorPlane),s}if(e.isRenderTarget){var c=null;if(e.isCube){if(i.reflectionProbes)for(var l=0;l<i.reflectionProbes.length;l++){var u=i.reflectionProbes[l];if(u.name===e.name)return u.cubeTexture}}else(c=t._CreateRenderTargetTexture(e.name,e.renderTargetSize,i,o))._waitingRenderList=e.renderList;return c}if(e.base64String)n=t.CreateFromBase64String(e.base64String,e.name,i,!o);else{var h=r+e.name;t.UseSerializedUrlIfAny&&e.url&&(h=e.url),n=new t(h,i,!o,e.invertY)}return n},e,i);if(e.samplingMode){var l=e.samplingMode;c&&c.samplingMode!==l&&c.updateSamplingMode(l)}if(c&&e.animations)for(var h=0;h<e.animations.length;h++){var d=e.animations[h],f=u.a.GetClass("BABYLON.Animation");f&&c.animations.push(f.Parse(d))}return c},t.CreateFromBase64String=function(e,i,r,n,o,s,a,c,u){return void 0===s&&(s=t.TRILINEAR_SAMPLINGMODE),void 0===a&&(a=null),void 0===c&&(c=null),void 0===u&&(u=l.a.TEXTUREFORMAT_RGBA),new t("data:"+i,r,n,o,s,a,c,e,!1,u)},t.LoadFromDataString=function(e,i,r,n,o,s,a,c,u,h){return void 0===n&&(n=!1),void 0===o&&(o=!1),void 0===s&&(s=!0),void 0===a&&(a=t.TRILINEAR_SAMPLINGMODE),void 0===c&&(c=null),void 0===u&&(u=null),void 0===h&&(h=l.a.TEXTUREFORMAT_RGBA),"data:"!==e.substr(0,5)&&(e="data:"+e),new t(e,r,o,s,a,c,u,i,n,h)},t._CubeTextureParser=function(e,t,i){throw"CubeTexture needs to be imported before being deserialized."},t._CreateMirror=function(e,t,i,r){throw"MirrorTexture needs to be imported before being deserialized."},t._CreateRenderTargetTexture=function(e,t,i,r){throw"RenderTargetTexture needs to be imported before being deserialized."},t.NEAREST_SAMPLINGMODE=l.a.TEXTURE_NEAREST_SAMPLINGMODE,t.NEAREST_NEAREST_MIPLINEAR=l.a.TEXTURE_NEAREST_NEAREST_MIPLINEAR,t.BILINEAR_SAMPLINGMODE=l.a.TEXTURE_BILINEAR_SAMPLINGMODE,t.LINEAR_LINEAR_MIPNEAREST=l.a.TEXTURE_LINEAR_LINEAR_MIPNEAREST,t.TRILINEAR_SAMPLINGMODE=l.a.TEXTURE_TRILINEAR_SAMPLINGMODE,t.LINEAR_LINEAR_MIPLINEAR=l.a.TEXTURE_LINEAR_LINEAR_MIPLINEAR,t.NEAREST_NEAREST_MIPNEAREST=l.a.TEXTURE_NEAREST_NEAREST_MIPNEAREST,t.NEAREST_LINEAR_MIPNEAREST=l.a.TEXTURE_NEAREST_LINEAR_MIPNEAREST,t.NEAREST_LINEAR_MIPLINEAR=l.a.TEXTURE_NEAREST_LINEAR_MIPLINEAR,t.NEAREST_LINEAR=l.a.TEXTURE_NEAREST_LINEAR,t.NEAREST_NEAREST=l.a.TEXTURE_NEAREST_NEAREST,t.LINEAR_NEAREST_MIPNEAREST=l.a.TEXTURE_LINEAR_NEAREST_MIPNEAREST,t.LINEAR_NEAREST_MIPLINEAR=l.a.TEXTURE_LINEAR_NEAREST_MIPLINEAR,t.LINEAR_LINEAR=l.a.TEXTURE_LINEAR_LINEAR,t.LINEAR_NEAREST=l.a.TEXTURE_LINEAR_NEAREST,t.EXPLICIT_MODE=l.a.TEXTURE_EXPLICIT_MODE,t.SPHERICAL_MODE=l.a.TEXTURE_SPHERICAL_MODE,t.PLANAR_MODE=l.a.TEXTURE_PLANAR_MODE,t.CUBIC_MODE=l.a.TEXTURE_CUBIC_MODE,t.PROJECTION_MODE=l.a.TEXTURE_PROJECTION_MODE,t.SKYBOX_MODE=l.a.TEXTURE_SKYBOX_MODE,t.INVCUBIC_MODE=l.a.TEXTURE_INVCUBIC_MODE,t.EQUIRECTANGULAR_MODE=l.a.TEXTURE_EQUIRECTANGULAR_MODE,t.FIXED_EQUIRECTANGULAR_MODE=l.a.TEXTURE_FIXED_EQUIRECTANGULAR_MODE,t.FIXED_EQUIRECTANGULAR_MIRRORED_MODE=l.a.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE,t.CLAMP_ADDRESSMODE=l.a.TEXTURE_CLAMP_ADDRESSMODE,t.WRAP_ADDRESSMODE=l.a.TEXTURE_WRAP_ADDRESSMODE,t.MIRROR_ADDRESSMODE=l.a.TEXTURE_MIRROR_ADDRESSMODE,t.UseSerializedUrlIfAny=!1,r.c([Object(n.c)()],t.prototype,"url",void 0),r.c([Object(n.c)()],t.prototype,"uOffset",void 0),r.c([Object(n.c)()],t.prototype,"vOffset",void 0),r.c([Object(n.c)()],t.prototype,"uScale",void 0),r.c([Object(n.c)()],t.prototype,"vScale",void 0),r.c([Object(n.c)()],t.prototype,"uAng",void 0),r.c([Object(n.c)()],t.prototype,"vAng",void 0),r.c([Object(n.c)()],t.prototype,"wAng",void 0),r.c([Object(n.c)()],t.prototype,"uRotationCenter",void 0),r.c([Object(n.c)()],t.prototype,"vRotationCenter",void 0),r.c([Object(n.c)()],t.prototype,"wRotationCenter",void 0),r.c([Object(n.c)()],t.prototype,"isBlocking",null),t}(c.a);n.a._TextureParser=h.Parse},function(e,t,i){"use strict";i.d(t,"a",function(){return r}),i.d(t,"d",function(){return n}),i.d(t,"b",function(){return o}),i.d(t,"c",function(){return s});var r=function(){function e(e,t,i,r){void 0===t&&(t=!1),this.initalize(e,t,i,r)}return e.prototype.initalize=function(e,t,i,r){return void 0===t&&(t=!1),this.mask=e,this.skipNextObservers=t,this.target=i,this.currentTarget=r,this},e}(),n=function(){return function(e,t,i){void 0===i&&(i=null),this.callback=e,this.mask=t,this.scope=i,this._willBeUnregistered=!1,this.unregisterOnNextCall=!1}}(),o=function(){function e(){}return e.prototype.dispose=function(){if(this._observers&&this._observables)for(var e=0;e<this._observers.length;e++)this._observables[e].remove(this._observers[e]);this._observers=null,this._observables=null},e.Watch=function(t,i,r,n){void 0===r&&(r=-1),void 0===n&&(n=null);var o=new e;o._observers=new Array,o._observables=t;for(var s=0,a=t;s<a.length;s++){var c=a[s].add(i,r,!1,n);c&&o._observers.push(c)}return o},e}(),s=function(){function e(e){this._observers=new Array,this._eventState=new r(0),e&&(this._onObserverAdded=e)}return e.prototype.add=function(e,t,i,r,o){if(void 0===t&&(t=-1),void 0===i&&(i=!1),void 0===r&&(r=null),void 0===o&&(o=!1),!e)return null;var s=new n(e,t,r);return s.unregisterOnNextCall=o,i?this._observers.unshift(s):this._observers.push(s),this._onObserverAdded&&this._onObserverAdded(s),s},e.prototype.addOnce=function(e){return this.add(e,void 0,void 0,void 0,!0)},e.prototype.remove=function(e){return!!e&&(-1!==this._observers.indexOf(e)&&(this._deferUnregister(e),!0))},e.prototype.removeCallback=function(e,t){for(var i=0;i<this._observers.length;i++)if(this._observers[i].callback===e&&(!t||t===this._observers[i].scope))return this._deferUnregister(this._observers[i]),!0;return!1},e.prototype._deferUnregister=function(e){var t=this;e.unregisterOnNextCall=!1,e._willBeUnregistered=!0,setTimeout(function(){t._remove(e)},0)},e.prototype._remove=function(e){if(!e)return!1;var t=this._observers.indexOf(e);return-1!==t&&(this._observers.splice(t,1),!0)},e.prototype.notifyObservers=function(e,t,i,r){if(void 0===t&&(t=-1),!this._observers.length)return!0;var n=this._eventState;n.mask=t,n.target=i,n.currentTarget=r,n.skipNextObservers=!1,n.lastReturnValue=e;for(var o=0,s=this._observers;o<s.length;o++){var a=s[o];if(!a._willBeUnregistered&&(a.mask&t&&(a.scope?n.lastReturnValue=a.callback.apply(a.scope,[e,n]):n.lastReturnValue=a.callback(e,n),a.unregisterOnNextCall&&this._deferUnregister(a)),n.skipNextObservers))return!1}return!0},e.prototype.notifyObserversWithPromise=function(e,t,i,r){var n=this;void 0===t&&(t=-1);var o=Promise.resolve(e);if(!this._observers.length)return o;var s=this._eventState;return s.mask=t,s.target=i,s.currentTarget=r,s.skipNextObservers=!1,this._observers.forEach(function(i){s.skipNextObservers||i._willBeUnregistered||i.mask&t&&(o=i.scope?o.then(function(t){return s.lastReturnValue=t,i.callback.apply(i.scope,[e,s])}):o.then(function(t){return s.lastReturnValue=t,i.callback(e,s)}),i.unregisterOnNextCall&&n._deferUnregister(i))}),o.then(function(){return e})},e.prototype.notifyObserver=function(e,t,i){void 0===i&&(i=-1);var r=this._eventState;r.mask=i,r.skipNextObservers=!1,e.callback(t,r)},e.prototype.hasObservers=function(){return this._observers.length>0},e.prototype.clear=function(){this._observers=new Array,this._onObserverAdded=null},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}()},function(e,t,i){"use strict";i.d(t,"a",function(){return r});var r=function(){function e(){}return e._AddLogEntry=function(t){e._LogCache=t+e._LogCache,e.OnNewCacheEntry&&e.OnNewCacheEntry(t)},e._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},e._LogDisabled=function(e){},e._LogEnabled=function(t){var i=e._FormatMessage(t);console.log("BJS - "+i);var r="<div style='color:white'>"+i+"</div><br>";e._AddLogEntry(r)},e._WarnDisabled=function(e){},e._WarnEnabled=function(t){var i=e._FormatMessage(t);console.warn("BJS - "+i);var r="<div style='color:orange'>"+i+"</div><br>";e._AddLogEntry(r)},e._ErrorDisabled=function(e){},e._ErrorEnabled=function(t){e.errorsCount++;var i=e._FormatMessage(t);console.error("BJS - "+i);var r="<div style='color:red'>"+i+"</div><br>";e._AddLogEntry(r)},Object.defineProperty(e,"LogCache",{get:function(){return e._LogCache},enumerable:!0,configurable:!0}),e.ClearLogCache=function(){e._LogCache="",e.errorsCount=0},Object.defineProperty(e,"LogLevels",{set:function(t){(t&e.MessageLogLevel)===e.MessageLogLevel?e.Log=e._LogEnabled:e.Log=e._LogDisabled,(t&e.WarningLogLevel)===e.WarningLogLevel?e.Warn=e._WarnEnabled:e.Warn=e._WarnDisabled,(t&e.ErrorLogLevel)===e.ErrorLogLevel?e.Error=e._ErrorEnabled:e.Error=e._ErrorDisabled},enumerable:!0,configurable:!0}),e.NoneLogLevel=0,e.MessageLogLevel=1,e.WarningLogLevel=2,e.ErrorLogLevel=4,e.AllLogLevel=7,e._LogCache="",e.errorsCount=0,e.Log=e._LogEnabled,e.Warn=e._WarnEnabled,e.Error=e._ErrorEnabled,e}()},function(e,t,i){"use strict";i.d(t,"c",function(){return _}),i.d(t,"b",function(){return g}),i.d(t,"d",function(){return m}),i.d(t,"e",function(){return v}),i.d(t,"g",function(){return y}),i.d(t,"h",function(){return b}),i.d(t,"f",function(){return T}),i.d(t,"i",function(){return E}),i.d(t,"a",function(){return x});var r,n=i(1),o=i(0),s=i(12),a=i(7),c=i(57),l=i(3),u=i(38),h=i(8),d=i(20),f=i(32),p=i(43),_=function(){function e(){}return e.prototype.getColorToRef=function(e){this.color2?o.f.LerpToRef(this.color1,this.color2,Math.random(),e):e.copyFrom(this.color1)},e}(),g=function(){return function(){}}(),m=function(){function e(){}return e.prototype.getFactor=function(){return void 0===this.factor2?this.factor1:s.a.Lerp(this.factor1,this.factor2,Math.random())},e}(),v=function(e){function t(i,r){var n=e.call(this,i)||this;return n.request=r,n.name="LoadFileError",t._setPrototypeOf(n,t.prototype),n}return n.d(t,e),t._setPrototypeOf=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},t}(Error),y=function(){function e(){}return e.ExponentialBackoff=function(e,t){return void 0===e&&(e=3),void 0===t&&(t=500),function(i,r,n){return 0!==r.status||n>=e||-1!==i.indexOf("file:")?-1:Math.pow(2,n)*t}},e}(),b=function(){function e(){}return e.FetchToRef=function(e,t,i,r,n,o){var s=4*((Math.abs(e)*i%i|0)+(Math.abs(t)*r%r|0)*i);o.r=n[s]/255,o.g=n[s+1]/255,o.b=n[s+2]/255,o.a=n[s+3]/255},e.Mix=function(e,t,i){return e*(1-i)+t*i},e.Instantiate=function(t){if(e.RegisteredExternalClasses&&e.RegisteredExternalClasses[t])return e.RegisteredExternalClasses[t];var i=d.a.GetClass(t);if(i)return i;h.a.Warn(t+" not found, you may have missed an import.");for(var r=t.split("."),n=window||this,o=0,s=r.length;o<s;o++)n=n[r[o]];return"function"!=typeof n?null:n},e.Slice=function(e,t,i){return e.slice?e.slice(t,i):Array.prototype.slice.call(e,t,i)},e.SetImmediate=function(e){u.a.IsWindowObjectExist()&&window.setImmediate?window.setImmediate(e):setTimeout(e,1)},e.IsExponentOfTwo=function(e){var t=1;do{t*=2}while(t<e);return t===e},e.FloatRound=function(t){return Math.fround?Math.fround(t):e._tmpFloatArray[0]=t},e.CeilingPOT=function(e){return e--,e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,++e},e.FloorPOT=function(e){return e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,(e|=e>>16)-(e>>1)},e.NearestPOT=function(t){var i=e.CeilingPOT(t),r=e.FloorPOT(t);return i-t>t-r?r:i},e.GetExponentOfTwo=function(t,i,r){var n;switch(void 0===r&&(r=l.a.SCALEMODE_NEAREST),r){case l.a.SCALEMODE_FLOOR:n=e.FloorPOT(t);break;case l.a.SCALEMODE_NEAREST:n=e.NearestPOT(t);break;case l.a.SCALEMODE_CEILING:default:n=e.CeilingPOT(t)}return Math.min(n,i)},e.GetFilename=function(e){var t=e.lastIndexOf("/");return t<0?e:e.substring(t+1)},e.GetFolderPath=function(e,t){void 0===t&&(t=!1);var i=e.lastIndexOf("/");return i<0?t?e:"":e.substring(0,i+1)},e.ToDegrees=function(e){return 180*e/Math.PI},e.ToRadians=function(e){return e*Math.PI/180},e.EncodeArrayBufferTobase64=function(e){for(var t,i,r,n,o,s,a,c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",l="",u=0,h=new Uint8Array(e);u<h.length;)n=(t=h[u++])>>2,o=(3&t)<<4|(i=u<h.length?h[u++]:Number.NaN)>>4,s=(15&i)<<2|(r=u<h.length?h[u++]:Number.NaN)>>6,a=63&r,isNaN(i)?s=a=64:isNaN(r)&&(a=64),l+=c.charAt(n)+c.charAt(o)+c.charAt(s)+c.charAt(a);return"data:image/png;base64,"+l},e.ExtractMinAndMaxIndexed=function(e,t,i,r,n){void 0===n&&(n=null);for(var s=new o.x(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),a=new o.x(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),c=i;c<i+r;c++){var l=3*t[c],u=e[l],h=e[l+1],d=e[l+2];s.minimizeInPlaceFromFloats(u,h,d),a.maximizeInPlaceFromFloats(u,h,d)}return n&&(s.x-=s.x*n.x+n.y,s.y-=s.y*n.x+n.y,s.z-=s.z*n.x+n.y,a.x+=a.x*n.x+n.y,a.y+=a.y*n.x+n.y,a.z+=a.z*n.x+n.y),{minimum:s,maximum:a}},e.ExtractMinAndMax=function(e,t,i,r,n){void 0===r&&(r=null);var s=new o.x(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),a=new o.x(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);n||(n=3);for(var c=t,l=t*n;c<t+i;c++,l+=n){var u=e[l],h=e[l+1],d=e[l+2];s.minimizeInPlaceFromFloats(u,h,d),a.maximizeInPlaceFromFloats(u,h,d)}return r&&(s.x-=s.x*r.x+r.y,s.y-=s.y*r.x+r.y,s.z-=s.z*r.x+r.y,a.x+=a.x*r.x+r.y,a.y+=a.y*r.x+r.y,a.z+=a.z*r.x+r.y),{minimum:s,maximum:a}},e.MakeArray=function(e,t){return!0===t||void 0!==e&&null!=e?Array.isArray(e)?e:[e]:null},e.GetPointerPrefix=function(){var e="pointer";return!u.a.IsWindowObjectExist()||window.PointerEvent||navigator.pointerEnabled||(e="mouse"),e},e.QueueNewFrame=function(e,t){return u.a.IsWindowObjectExist()?(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)):setTimeout(e,16)},e.RequestFullscreen=function(e){var t=e.requestFullscreen||e.msRequestFullscreen||e.webkitRequestFullscreen||e.mozRequestFullScreen;t&&t.call(e)},e.ExitFullscreen=function(){document.exitFullscreen?document.exitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitCancelFullScreen?document.webkitCancelFullScreen():document.msCancelFullScreen&&document.msCancelFullScreen()},e.SetCorsBehavior=function(t,i){if((!t||0!==t.indexOf("data:"))&&e.CorsBehavior)if("string"==typeof e.CorsBehavior||e.CorsBehavior instanceof String)i.crossOrigin=e.CorsBehavior;else{var r=e.CorsBehavior(t);r&&(i.crossOrigin=r)}},e.CleanUrl=function(e){return e=e.replace(/#/gm,"%23")},e.LoadImage=function(t,i,r,n){var o,s=!1;t instanceof ArrayBuffer?(o=URL.createObjectURL(new Blob([t])),s=!0):t instanceof Blob?(o=URL.createObjectURL(t),s=!0):(o=e.CleanUrl(t),o=e.PreprocessUrl(t));var a=new Image;e.SetCorsBehavior(o,a);var l=function(){s&&a.src&&URL.revokeObjectURL(a.src),a.removeEventListener("load",l),a.removeEventListener("error",u),i(a)},u=function(e){s&&a.src&&URL.revokeObjectURL(a.src),a.removeEventListener("load",l),a.removeEventListener("error",u),h.a.Error("Error while trying to load image: "+t),r&&r("Error while trying to load image: "+t,e)};a.addEventListener("load",l),a.addEventListener("error",u);var d=function(){a.src=o};if("data:"!==o.substr(0,5)&&n&&n.enableTexturesOffline)n.open(function(){n&&n.loadImage(o,a)},d);else{if(-1!==o.indexOf("file:")){var f=decodeURIComponent(o.substring(5).toLowerCase());if(c.a.FilesToLoad[f]){try{var p;try{p=URL.createObjectURL(c.a.FilesToLoad[f])}catch(e){p=URL.createObjectURL(c.a.FilesToLoad[f])}a.src=p,s=!0}catch(e){a.src=""}return a}}d()}return a},e.LoadFile=function(t,i,r,n,o,s){if(t=e.CleanUrl(t),-1!==(t=e.PreprocessUrl(t)).indexOf("file:")){var l=decodeURIComponent(t.substring(5).toLowerCase());if(c.a.FilesToLoad[l])return e.ReadFile(c.a.FilesToLoad[l],i,r,o)}var h=e.BaseUrl+t,d=!1,f={onCompleteObservable:new a.c,abort:function(){return d=!0}},p=function(){var t=new XMLHttpRequest,n=null;f.abort=function(){d=!0,t.readyState!==(XMLHttpRequest.DONE||4)&&t.abort(),null!==n&&(clearTimeout(n),n=null)};var a=function(c){t.open("GET",h,!0),o&&(t.responseType="arraybuffer"),r&&t.addEventListener("progress",r);var l=function(){t.removeEventListener("loadend",l),f.onCompleteObservable.notifyObservers(f),f.onCompleteObservable.clear()};t.addEventListener("loadend",l);var p=function(){if(!d&&t.readyState===(XMLHttpRequest.DONE||4)){if(t.removeEventListener("readystatechange",p),t.status>=200&&t.status<300||0===t.status&&(!u.a.IsWindowObjectExist()||e.IsFileURL()))return void i(o?t.response:t.responseText,t.responseURL);var r=e.DefaultRetryStrategy;if(r){var f=r(h,t,c);if(-1!==f)return t.removeEventListener("loadend",l),t=new XMLHttpRequest,void(n=setTimeout(function(){return a(c+1)},f))}var _=new v("Error status: "+t.status+" "+t.statusText+" - Unable to load "+h,t);if(!s)throw _;s(t,_)}};t.addEventListener("readystatechange",p),e.UseCustomRequestHeaders&&e.InjectCustomRequestHeaders(t),t.send()};a(0)};if(n&&n.enableSceneOffline){var _=function(e){e&&e.status>400?s&&s(e):d||p()};n.open(function(){d||n&&n.loadFile(t,function(e){d||i(e),f.onCompleteObservable.notifyObservers(f)},r?function(e){d||r(e)}:void 0,_,o)},_)}else p();return f},e.LoadScript=function(e,t,i){if(u.a.IsWindowObjectExist()){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(t){i&&i("Unable to load script '"+e+"'",t)},r.appendChild(n)}},e.ReadFileAsDataURL=function(e,t,i){var r=new FileReader,n={onCompleteObservable:new a.c,abort:function(){return r.abort()}};return r.onloadend=function(e){n.onCompleteObservable.notifyObservers(n)},r.onload=function(e){t(e.target.result)},r.onprogress=i,r.readAsDataURL(e),n},e.ReadFile=function(e,t,i,r){var n=new FileReader,o={onCompleteObservable:new a.c,abort:function(){return n.abort()}};return n.onloadend=function(e){return o.onCompleteObservable.notifyObservers(o)},n.onerror=function(i){h.a.Log("Error while reading file: "+e.name),t(JSON.stringify({autoClear:!0,clearColor:[1,0,0],ambientColor:[0,0,0],gravity:[0,-9.807,0],meshes:[],cameras:[],lights:[]}))},n.onload=function(e){t(e.target.result)},i&&(n.onprogress=i),r?n.readAsArrayBuffer(e):n.readAsText(e),o},e.FileAsURL=function(e){var t=new Blob([e]);return(window.URL||window.webkitURL).createObjectURL(t)},e.Format=function(e,t){return void 0===t&&(t=2),e.toFixed(t)},e.CheckExtends=function(e,t,i){t.minimizeInPlace(e),i.maximizeInPlace(e)},e.DeepCopy=function(e,t,i,r){f.a.DeepCopy(e,t,i,r)},e.IsEmpty=function(e){for(var t in e)if(e.hasOwnProperty(t))return!1;return!0},e.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){}}},e.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){}}},e.DumpFramebuffer=function(t,i,n,o,s,a){void 0===s&&(s="image/png");for(var c=4*t,l=i/2,u=n.readPixels(0,0,t,i),h=0;h<l;h++)for(var d=0;d<c;d++){var f=d+h*c,p=d+(i-h-1)*c,_=u[f];u[f]=u[p],u[p]=_}r||(r=document.createElement("canvas")),r.width=t,r.height=i;var g=r.getContext("2d");if(g){var m=g.createImageData(t,i);m.data.set(u),g.putImageData(m,0,0),e.EncodeScreenshotCanvasData(o,s,a)}},e.ToBlob=function(e,t,i){void 0===i&&(i="image/png"),e.toBlob||(e.toBlob=function(e,t,i){var r=this;setTimeout(function(){for(var n=atob(r.toDataURL(t,i).split(",")[1]),o=n.length,s=new Uint8Array(o),a=0;a<o;a++)s[a]=n.charCodeAt(a);e(new Blob([s]))})}),e.toBlob(function(e){t(e)},i)},e.EncodeScreenshotCanvasData=function(t,i,n){(void 0===i&&(i="image/png"),t)?t(r.toDataURL(i)):this.ToBlob(r,function(t){if("download"in document.createElement("a")){if(!n){var i=new Date,r=(i.getFullYear()+"-"+(i.getMonth()+1)).slice(2)+"-"+i.getDate()+"_"+i.getHours()+"-"+("0"+i.getMinutes()).slice(-2);n="screenshot_"+r+".png"}e.Download(t,n)}else{var o=URL.createObjectURL(t),s=window.open("");if(!s)return;var a=s.document.createElement("img");a.onload=function(){URL.revokeObjectURL(o)},a.src=o,s.document.body.appendChild(a)}},i)},e.Download=function(e,t){if(navigator&&navigator.msSaveBlob)navigator.msSaveBlob(e,t);else{var i=window.URL.createObjectURL(e),r=document.createElement("a");document.body.appendChild(r),r.style.display="none",r.href=i,r.download=t,r.addEventListener("click",function(){r.parentElement&&r.parentElement.removeChild(r)}),r.click(),window.URL.revokeObjectURL(i)}},e.CreateScreenshot=function(e,t,i,r,n){throw void 0===n&&(n="image/png"),"Import ScreenshotTools before creating screenshot."},e.CreateScreenshotUsingRenderTarget=function(e,t,i,r,n,o,s,a){throw void 0===n&&(n="image/png"),void 0===o&&(o=1),void 0===s&&(s=!1),"Import ScreenshotTools before creating screenshot."},e.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)})},e.IsBase64=function(e){return!(e.length<5)&&"data:"===e.substr(0,5)},e.DecodeBase64=function(e){for(var t=atob(e.split(",")[1]),i=t.length,r=new Uint8Array(new ArrayBuffer(i)),n=0;n<i;n++)r[n]=t.charCodeAt(n);return r.buffer},Object.defineProperty(e,"errorsCount",{get:function(){return h.a.errorsCount},enumerable:!0,configurable:!0}),e.Log=function(e){h.a.Log(e)},e.Warn=function(e){h.a.Warn(e)},e.Error=function(e){h.a.Error(e)},Object.defineProperty(e,"LogCache",{get:function(){return h.a.LogCache},enumerable:!0,configurable:!0}),e.ClearLogCache=function(){h.a.ClearLogCache()},Object.defineProperty(e,"LogLevels",{set:function(e){h.a.LogLevels=e},enumerable:!0,configurable:!0}),e.IsFileURL=function(){return"file:"===location.protocol},Object.defineProperty(e,"PerformanceLogLevel",{set:function(t){return(t&e.PerformanceUserMarkLogLevel)===e.PerformanceUserMarkLogLevel?(e.StartPerformanceCounter=e._StartUserMark,void(e.EndPerformanceCounter=e._EndUserMark)):(t&e.PerformanceConsoleLogLevel)===e.PerformanceConsoleLogLevel?(e.StartPerformanceCounter=e._StartPerformanceConsole,void(e.EndPerformanceCounter=e._EndPerformanceConsole)):(e.StartPerformanceCounter=e._StartPerformanceCounterDisabled,void(e.EndPerformanceCounter=e._EndPerformanceCounterDisabled))},enumerable:!0,configurable:!0}),e._StartPerformanceCounterDisabled=function(e,t){},e._EndPerformanceCounterDisabled=function(e,t){},e._StartUserMark=function(t,i){if(void 0===i&&(i=!0),!e._performance){if(!u.a.IsWindowObjectExist())return;e._performance=window.performance}i&&e._performance.mark&&e._performance.mark(t+"-Begin")},e._EndUserMark=function(t,i){void 0===i&&(i=!0),i&&e._performance.mark&&(e._performance.mark(t+"-End"),e._performance.measure(t,t+"-Begin",t+"-End"))},e._StartPerformanceConsole=function(t,i){void 0===i&&(i=!0),i&&(e._StartUserMark(t,i),console.time&&console.time(t))},e._EndPerformanceConsole=function(t,i){void 0===i&&(i=!0),i&&(e._EndUserMark(t,i),console.time&&console.timeEnd(t))},e.InjectCustomRequestHeaders=function(t){for(var i in e.CustomRequestHeaders){var r=e.CustomRequestHeaders[i];r&&t.setRequestHeader(i,r)}},Object.defineProperty(e,"Now",{get:function(){return p.a.Now},enumerable:!0,configurable:!0}),e.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},e.First=function(e,t){for(var i=0,r=e;i<r.length;i++){var n=r[i];if(t(n))return n}return null},e.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},e.DelayAsync=function(e){return new Promise(function(t){setTimeout(function(){t()},e)})},e.GetCurrentGradient=function(e,t,i){for(var r=0;r<t.length-1;r++){var n=t[r],o=t[r+1];if(e>=n.gradient&&e<=o.gradient)return void i(n,o,(e-n.gradient)/(o.gradient-n.gradient))}var s=t.length-1;i(t[s],t[s],1)},e.BaseUrl="",e.UseCustomRequestHeaders=!1,e.CustomRequestHeaders={},e.DefaultRetryStrategy=y.ExponentialBackoff(),e.CorsBehavior="anonymous",e.UseFallbackTexture=!0,e.RegisteredExternalClasses={},e.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",e._tmpFloatArray=new Float32Array(1),e.GetDOMTextContent=u.a.GetDOMTextContent,e.PreprocessUrl=function(e){return e},e.NoneLogLevel=h.a.NoneLogLevel,e.MessageLogLevel=h.a.MessageLogLevel,e.WarningLogLevel=h.a.WarningLogLevel,e.ErrorLogLevel=h.a.ErrorLogLevel,e.AllLogLevel=h.a.AllLogLevel,e.IsWindowObjectExist=u.a.IsWindowObjectExist,e.PerformanceNoneLogLevel=0,e.PerformanceUserMarkLogLevel=1,e.PerformanceConsoleLogLevel=2,e.StartPerformanceCounter=e._StartPerformanceCounterDisabled,e.EndPerformanceCounter=e._EndPerformanceCounterDisabled,e}(),T=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}),Object.defineProperty(e.prototype,"count",{get:function(){return this._totalValueCount},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=p.a.Now)},e.prototype.endMonitoring=function(t){if(void 0===t&&(t=!0),e.Enabled){t&&this.fetchNewFrame();var i=p.a.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=p.a.Now;e-this._lastSecTime>1e3&&(this._lastSecAverage=this._lastSecAccumulated/this._lastSecValueCount,this._lastSecTime=e,this._lastSecAccumulated=0,this._lastSecValueCount=0)},e.Enabled=!0,e}();function E(e,t){return function(i){i.__bjsclassName__=e,i.__bjsmoduleName__=null!=t?t:null}}var x=function(){function e(e,t,i,r){void 0===r&&(r=0),this.iterations=e,this.index=r-1,this._done=!1,this._fn=t,this._successCallback=i}return e.prototype.executeNext=function(){this._done||(this.index+1<this.iterations?(++this.index,this._fn(this)):this.breakLoop())},e.prototype.breakLoop=function(){this._done=!0,this._successCallback()},e.Run=function(t,i,r,n){void 0===n&&(n=0);var o=new e(t,i,r,n);return o.executeNext(),o},e.SyncAsyncForLoop=function(t,i,r,n,o,s){return void 0===s&&(s=0),e.Run(Math.ceil(t/i),function(e){o&&o()?e.breakLoop():setTimeout(function(){for(var n=0;n<i;++n){var s=e.index*i+n;if(s>=t)break;if(r(s),o&&o()){e.breakLoop();break}}e.executeNext()},s)},n)},e}()},function(e,t,i){"use strict";i.d(t,"b",function(){return x}),i.d(t,"c",function(){return A}),i.d(t,"d",function(){return R}),i.d(t,"a",function(){return S});var r=i(1),n=i(7),o=i(9),s=i(32),a=i(26),c=i(0),l=i(24),u=i(4),h=i(13),d=i(55),f=i(23),p=i(45),_=i(41),g=i(18),m=i(52),v=i(29),y=i(3),b=i(2),T=i(8),E=i(20),x=function(){return function(e,t){this.distance=e,this.mesh=t}}(),A=function(){return function(){}}(),P=function(){return function(){this.visibleInstances={},this.renderIdForInstances=new Array,this.batchCache=new R,this.instancesBufferSize=2048}}(),R=function(){return function(){this.mustReturn=!1,this.visibleInstances=new Array,this.renderSelf=new Array}}(),S=function(e){function t(i,r,n,o,c,l){void 0===r&&(r=null),void 0===n&&(n=null),void 0===o&&(o=null),void 0===l&&(l=!0);var u=e.call(this,i,r)||this;if(u.delayLoadState=y.a.DELAYLOADSTATE_NONE,u.instances=new Array,u._LODLevels=new Array,u._instanceDataStorage=new P,u._originalBuilderSideOrientation=t.DEFAULTSIDE,u.overrideMaterialSideOrientation=null,u._areNormalsFrozen=!1,u._source=null,u._isMesh=!0,r=u.getScene(),o){if(o._geometry&&o._geometry.applyToMesh(u),s.a.DeepCopy(o,u,["name","material","skeleton","instances","parent","uniqueId","source","metadata","hasLODLevels","geometry","isBlocked","areNormalsFrozen","onBeforeDrawObservable","onBeforeRenderObservable","onAfterRenderObservable","onBeforeDraw","onAfterWorldMatrixUpdateObservable","onCollideObservable","onCollisionPositionChangeObservable","onRebuildObservable","onDisposeObservable"],["_poseMatrix"]),u._source=o,r.useClonedMeshhMap&&(o.meshMap||(o.meshMap={}),o.meshMap[u.uniqueId]=u),u._originalBuilderSideOrientation=o._originalBuilderSideOrientation,u._creationDataStorage=o._creationDataStorage,u._source._ranges){var h=u._source._ranges;for(var i in h)h.hasOwnProperty(i)&&h[i]&&u.createAnimationRange(i,h[i].from,h[i].to)}var d;if(o.metadata&&o.metadata.clone?u.metadata=o.metadata.clone():u.metadata=o.metadata,a.a&&a.a.HasTags(o)&&a.a.AddTagsTo(u,a.a.GetTags(o,!0)),u.parent=o.parent,u.setPivotMatrix(o.getPivotMatrix()),u.id=i+"."+o.id,u.material=o.material,!c)for(var f=o.getDescendants(!0),p=0;p<f.length;p++){var _=f[p];_.clone&&_.clone(i+"."+_.name,u)}var g=u.getScene().getPhysicsEngine();if(l&&g){var m=g.getImpostorForPhysicsObject(o);m&&(u.physicsImpostor=m.clone(u))}for(d=0;d<r.particleSystems.length;d++){var v=r.particleSystems[d];v.emitter===o&&v.clone(v.name,u)}u.refreshBoundingInfo(),u.computeWorldMatrix(!0)}return null!==n&&(u.parent=n),u}return r.d(t,e),t._GetDefaultSideOrientation=function(e){return e==t.DOUBLESIDE?t.DOUBLESIDE:null==e?t.FRONTSIDE:e},Object.defineProperty(t.prototype,"onBeforeRenderObservable",{get:function(){return this._onBeforeRenderObservable||(this._onBeforeRenderObservable=new n.c),this._onBeforeRenderObservable},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onBeforeBindObservable",{get:function(){return this._onBeforeBindObservable||(this._onBeforeBindObservable=new n.c),this._onBeforeBindObservable},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onAfterRenderObservable",{get:function(){return this._onAfterRenderObservable||(this._onAfterRenderObservable=new n.c),this._onAfterRenderObservable},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onBeforeDrawObservable",{get:function(){return this._onBeforeDrawObservable||(this._onBeforeDrawObservable=new n.c),this._onBeforeDrawObservable},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onBeforeDraw",{set:function(e){this._onBeforeDrawObserver&&this.onBeforeDrawObservable.remove(this._onBeforeDrawObserver),this._onBeforeDrawObserver=this.onBeforeDrawObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"morphTargetManager",{get:function(){return this._morphTargetManager},set:function(e){this._morphTargetManager!==e&&(this._morphTargetManager=e,this._syncGeometryWithMorphTargetManager())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"source",{get:function(){return this._source},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isUnIndexed",{get:function(){return this._unIndexed},set:function(e){this._unIndexed!==e&&(this._unIndexed=e,this._markSubMeshesAsAttributesDirty())},enumerable:!0,configurable:!0}),t.prototype.getClassName=function(){return"Mesh"},t.prototype.toString=function(t){var i=e.prototype.toString.call(this,t);if(i+=", n vertices: "+this.getTotalVertices(),i+=", parent: "+(this._waitingParentId?this._waitingParentId:this.parent?this.parent.name:"NONE"),this.animations)for(var r=0;r<this.animations.length;r++)i+=", animation[0]: "+this.animations[r].toString(t);if(t)if(this._geometry){var n=this.getIndices(),o=this.getVerticesData(u.b.PositionKind);o&&n&&(i+=", flat shading: "+(o.length/3===n.length?"YES":"NO"))}else i+=", flat shading: UNKNOWN";return i},t.prototype._unBindEffect=function(){e.prototype._unBindEffect.call(this);for(var t=0,i=this.instances;t<i.length;t++){i[t]._unBindEffect()}},Object.defineProperty(t.prototype,"hasLODLevels",{get:function(){return this._LODLevels.length>0},enumerable:!0,configurable:!0}),t.prototype.getLODLevels=function(){return this._LODLevels},t.prototype._sortLODLevels=function(){this._LODLevels.sort(function(e,t){return e.distance<t.distance?1:e.distance>t.distance?-1:0})},t.prototype.addLODLevel=function(e,t){if(t&&t._masterMesh)return T.a.Warn("You cannot use a mesh as LOD level twice"),this;var i=new x(e,t);return this._LODLevels.push(i),t&&(t._masterMesh=this),this._sortLODLevels(),this},t.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},t.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},t.prototype.getLOD=function(e,t){if(!this._LODLevels||0===this._LODLevels.length)return this;var i;t?i=t:i=this.getBoundingInfo().boundingSphere;var r=i.centerWorld.subtract(e.globalPosition).length();if(this._LODLevels[this._LODLevels.length-1].distance>r)return this.onLODLevelSelection&&this.onLODLevelSelection(r,this,this._LODLevels[this._LODLevels.length-1].mesh),this;for(var n=0;n<this._LODLevels.length;n++){var o=this._LODLevels[n];if(o.distance<r)return o.mesh&&(o.mesh._preActivate(),o.mesh._updateSubMeshesBoundingInfo(this.worldMatrixFromCache)),this.onLODLevelSelection&&this.onLODLevelSelection(r,this,o.mesh),o.mesh}return this.onLODLevelSelection&&this.onLODLevelSelection(r,this,this),this},Object.defineProperty(t.prototype,"geometry",{get:function(){return this._geometry},enumerable:!0,configurable:!0}),t.prototype.getTotalVertices=function(){return null===this._geometry||void 0===this._geometry?0:this._geometry.getTotalVertices()},t.prototype.getVerticesData=function(e,t,i){return this._geometry?this._geometry.getVerticesData(e,t,i):null},t.prototype.getVertexBuffer=function(e){return this._geometry?this._geometry.getVertexBuffer(e):null},t.prototype.isVerticesDataPresent=function(e){return this._geometry?this._geometry.isVerticesDataPresent(e):!!this._delayInfo&&-1!==this._delayInfo.indexOf(e)},t.prototype.isVertexBufferUpdatable=function(e){return this._geometry?this._geometry.isVertexBufferUpdatable(e):!!this._delayInfo&&-1!==this._delayInfo.indexOf(e)},t.prototype.getVerticesDataKinds=function(){if(!this._geometry){var e=new Array;return this._delayInfo&&this._delayInfo.forEach(function(t){e.push(t)}),e}return this._geometry.getVerticesDataKinds()},t.prototype.getTotalIndices=function(){return this._geometry?this._geometry.getTotalIndices():0},t.prototype.getIndices=function(e,t){return this._geometry?this._geometry.getIndices(e,t):[]},Object.defineProperty(t.prototype,"isBlocked",{get:function(){return null!==this._masterMesh&&void 0!==this._masterMesh},enumerable:!0,configurable:!0}),t.prototype.isReady=function(t,i){if(void 0===t&&(t=!1),void 0===i&&(i=!1),this.delayLoadState===y.a.DELAYLOADSTATE_LOADING)return!1;if(!e.prototype.isReady.call(this,t))return!1;if(!this.subMeshes||0===this.subMeshes.length)return!0;if(!t)return!0;var r=this.getEngine(),n=this.getScene(),o=i||r.getCaps().instancedArrays&&this.instances.length>0;this.computeWorldMatrix();var s=this.material||n.defaultMaterial;if(s)if(s._storeEffectOnSubMeshes)for(var a=0,c=this.subMeshes;a<c.length;a++){var l=(_=c[a]).getMaterial();if(l)if(l._storeEffectOnSubMeshes){if(!l.isReadyForSubMesh(this,_,o))return!1}else if(!l.isReady(this,o))return!1}else if(!s.isReady(this,o))return!1;for(var u=0,h=this._lightSources;u<h.length;u++){var d=h[u].getShadowGenerator();if(d)for(var f=0,p=this.subMeshes;f<p.length;f++){var _=p[f];if(!d.isReady(_,o))return!1}}for(var g=0,m=this._LODLevels;g<m.length;g++){var v=m[g];if(v.mesh&&!v.mesh.isReady(o))return!1}return!0},Object.defineProperty(t.prototype,"areNormalsFrozen",{get:function(){return this._areNormalsFrozen},enumerable:!0,configurable:!0}),t.prototype.freezeNormals=function(){return this._areNormalsFrozen=!0,this},t.prototype.unfreezeNormals=function(){return this._areNormalsFrozen=!1,this},Object.defineProperty(t.prototype,"overridenInstanceCount",{set:function(e){this._instanceDataStorage.overridenInstanceCount=e},enumerable:!0,configurable:!0}),t.prototype._preActivate=function(){var e=this.getScene().getRenderId();return this._preActivateId===e?this:(this._preActivateId=e,this._instanceDataStorage.visibleInstances=null,this)},t.prototype._preActivateForIntermediateRendering=function(e){return this._instanceDataStorage.visibleInstances&&(this._instanceDataStorage.visibleInstances.intermediateDefaultRenderId=e),this},t.prototype._registerInstanceForRenderId=function(e,t){return this._instanceDataStorage.visibleInstances||(this._instanceDataStorage.visibleInstances={defaultRenderId:t,selfDefaultRenderId:this._renderId}),this._instanceDataStorage.visibleInstances[t]||(this._instanceDataStorage.visibleInstances[t]=new Array),this._instanceDataStorage.visibleInstances[t].push(e),this},t.prototype.refreshBoundingInfo=function(e){if(void 0===e&&(e=!1),this._boundingInfo&&this._boundingInfo.isLocked)return this;var t=this.geometry?this.geometry.boundingBias:null;return this._refreshBoundingInfo(this._getPositionData(e),t),this},t.prototype._createGlobalSubMesh=function(e){var t=this.getTotalVertices();if(!t||!this.getIndices())return null;if(this.subMeshes&&this.subMeshes.length>0){var i=this.getIndices();if(!i)return null;var r=i.length,n=!1;if(e)n=!0;else for(var o=0,s=this.subMeshes;o<s.length;o++){var a=s[o];if(a.indexStart+a.indexCount>=r){n=!0;break}if(a.verticesStart+a.verticesCount>=t){n=!0;break}}if(!n)return this.subMeshes[0]}return this.releaseSubMeshes(),new p.b(0,0,t,0,this.getTotalIndices(),this)},t.prototype.subdivide=function(e){if(!(e<1)){for(var t=this.getTotalIndices(),i=t/e|0,r=0;i%3!=0;)i++;this.releaseSubMeshes();for(var n=0;n<e&&!(r>=t);n++)p.b.CreateFromIndices(0,r,Math.min(i,t-r),this),r+=i;this.synchronizeInstances()}},t.prototype.setVerticesData=function(e,t,i,r){if(void 0===i&&(i=!1),this._geometry)this._geometry.setVerticesData(e,t,i,r);else{var n=new h.a;n.set(t,e);var o=this.getScene();new d.a(d.a.RandomId(),o,n,i,this)}return this},t.prototype.markVerticesDataAsUpdatable=function(e,t){void 0===t&&(t=!0);var i=this.getVertexBuffer(e);i&&i.isUpdatable()!==t&&this.setVerticesData(e,this.getVerticesData(e),t)},t.prototype.setVerticesBuffer=function(e){return this._geometry||(this._geometry=d.a.CreateGeometryForMesh(this)),this._geometry.setVerticesBuffer(e),this},t.prototype.updateVerticesData=function(e,t,i,r){return this._geometry?(r?(this.makeGeometryUnique(),this.updateVerticesData(e,t,i,!1)):this._geometry.updateVerticesData(e,t,i),this):this},t.prototype.updateMeshPositions=function(e,t){void 0===t&&(t=!0);var i=this.getVerticesData(u.b.PositionKind);if(!i)return this;if(e(i),this.updateVerticesData(u.b.PositionKind,i,!1,!1),t){var r=this.getIndices(),n=this.getVerticesData(u.b.NormalKind);if(!n)return this;h.a.ComputeNormals(i,r,n),this.updateVerticesData(u.b.NormalKind,n,!1,!1)}return this},t.prototype.makeGeometryUnique=function(){if(!this._geometry)return this;var e=this._geometry,t=this._geometry.copy(d.a.RandomId());return e.releaseForMesh(this,!0),t.applyToMesh(this),this},t.prototype.setIndices=function(e,t,i){if(void 0===t&&(t=null),void 0===i&&(i=!1),this._geometry)this._geometry.setIndices(e,t,i);else{var r=new h.a;r.indices=e;var n=this.getScene();new d.a(d.a.RandomId(),n,r,i,this)}return this},t.prototype.updateIndices=function(e,t){return this._geometry?(this._geometry.updateIndices(e,t),this):this},t.prototype.toLeftHanded=function(){return this._geometry?(this._geometry.toLeftHanded(),this):this},t.prototype._bind=function(e,t,i){if(!this._geometry)return this;var r,n=this.getScene().getEngine();if(this._unIndexed)r=null;else switch(i){case g.a.PointFillMode:r=null;break;case g.a.WireFrameFillMode:r=e._getLinesIndexBuffer(this.getIndices(),n);break;default:case g.a.TriangleFillMode:r=this._unIndexed?null:this._geometry.getIndexBuffer()}return this._geometry._bind(t,r),this},t.prototype._draw=function(e,t,i,r){if(void 0===r&&(r=!1),!this._geometry||!this._geometry.getVertexBuffers()||!this._unIndexed&&!this._geometry.getIndexBuffer())return this;this._onBeforeDrawObservable&&this._onBeforeDrawObservable.notifyObservers(this);var n=this.getScene(),o=n.getEngine();if(this._unIndexed||t==g.a.PointFillMode?o.drawArraysType(t,e.verticesStart,e.verticesCount,i):t==g.a.WireFrameFillMode?o.drawElementsType(t,0,e._linesIndexCount,i):o.drawElementsType(t,e.indexStart,e.indexCount,i),n._isAlternateRenderingEnabled&&!r){var s=e.effect||this._effectiveMaterial.getEffect();if(!s||!n.activeCamera)return this;n._switchToAlternateCameraConfiguration(!0),this._effectiveMaterial.bindView(s),this._effectiveMaterial.bindViewProjection(s),o.setViewport(n.activeCamera._alternateCamera.viewport),this._draw(e,t,i,!0),o.setViewport(n.activeCamera.viewport),n._switchToAlternateCameraConfiguration(!1),this._effectiveMaterial.bindView(s),this._effectiveMaterial.bindViewProjection(s)}return this},t.prototype.registerBeforeRender=function(e){return this.onBeforeRenderObservable.add(e),this},t.prototype.unregisterBeforeRender=function(e){return this.onBeforeRenderObservable.removeCallback(e),this},t.prototype.registerAfterRender=function(e){return this.onAfterRenderObservable.add(e),this},t.prototype.unregisterAfterRender=function(e){return this.onAfterRenderObservable.removeCallback(e),this},t.prototype._getInstancesRenderList=function(e){var t=this.getScene(),i=this._instanceDataStorage.batchCache;if(i.mustReturn=!1,i.renderSelf[e]=this.isEnabled()&&this.isVisible,i.visibleInstances[e]=null,this._instanceDataStorage.visibleInstances){var r=this._instanceDataStorage.visibleInstances,n=t.getRenderId(),o=t._isInIntermediateRendering()?r.intermediateDefaultRenderId:r.defaultRenderId;i.visibleInstances[e]=r[n];var s=this._renderId;!i.visibleInstances[e]&&o&&(i.visibleInstances[e]=r[o],n=Math.max(o,n),s=Math.max(r.selfDefaultRenderId,n));var a=i.visibleInstances[e];if(a&&a.length){if(this._instanceDataStorage.renderIdForInstances[e]===n)return i.mustReturn=!0,i;n!==s&&(i.renderSelf[e]=!1)}this._instanceDataStorage.renderIdForInstances[e]=n}return i},t.prototype._renderWithInstances=function(e,t,i,r,n){var o=i.visibleInstances[e._id];if(!o)return this;for(var s=16*(o.length+1)*4,a=this._instanceDataStorage,c=a.instancesBufferSize,l=a.instancesBuffer;a.instancesBufferSize<s;)a.instancesBufferSize*=2;a.instancesData&&c==a.instancesBufferSize||(a.instancesData=new Float32Array(a.instancesBufferSize/4));var h=0,d=0,f=this.getWorldMatrix();if(i.renderSelf[e._id]&&(f.copyToArray(a.instancesData,h),h+=16,d++),o)for(var p=0;p<o.length;p++){o[p].getWorldMatrix().copyToArray(a.instancesData,h),h+=16,d++}return l&&c==a.instancesBufferSize?l.updateDirectly(a.instancesData,0,d):(l&&l.dispose(),l=new u.a(n,a.instancesData,!0,16,!1,!0),a.instancesBuffer=l,this.setVerticesBuffer(l.createVertexBuffer("world0",0,4)),this.setVerticesBuffer(l.createVertexBuffer("world1",4,4)),this.setVerticesBuffer(l.createVertexBuffer("world2",8,4)),this.setVerticesBuffer(l.createVertexBuffer("world3",12,4))),this._bind(e,r,t),this._draw(e,t,d),n.unbindInstanceAttributes(),this},t.prototype._processRendering=function(e,t,i,r,n,o,s){var a=this.getScene().getEngine();if(n)this._renderWithInstances(e,i,r,t,a);else{r.renderSelf[e._id]&&(o&&o(!1,this.getWorldMatrix(),s),this._draw(e,i,this._instanceDataStorage.overridenInstanceCount));var c=r.visibleInstances[e._id];if(c)for(var l=0;l<c.length;l++){var u=c[l].getWorldMatrix();o&&o(!0,u,s),this._draw(e,i)}}return this},t.prototype.render=function(e,t){if(this._checkOcclusionQuery())return this;var i=this.getScene(),r=this._getInstancesRenderList(e._id);if(r.mustReturn)return this;if(!this._geometry||!this._geometry.getVertexBuffers()||!this._unIndexed&&!this._geometry.getIndexBuffer())return this;this._onBeforeRenderObservable&&this._onBeforeRenderObservable.notifyObservers(this);var n,o=i.getEngine(),s=o.getCaps().instancedArrays&&null!==r.visibleInstances[e._id]&&void 0!==r.visibleInstances[e._id],a=e.getMaterial();if(!a)return this;if(this._effectiveMaterial=a,this._effectiveMaterial._storeEffectOnSubMeshes){if(!this._effectiveMaterial.isReadyForSubMesh(this,e,s))return this}else if(!this._effectiveMaterial.isReady(this,s))return this;t&&o.setAlphaMode(this._effectiveMaterial.alphaMode);for(var c=0,l=i._beforeRenderingMeshStage;c<l.length;c++){l[c].action(this,e,r)}if(!(n=this._effectiveMaterial._storeEffectOnSubMeshes?e.effect:this._effectiveMaterial.getEffect()))return this;var u=this.skeleton&&this.skeleton.overrideMesh||this,h=this.overrideMaterialSideOrientation;null==h&&(h=this._effectiveMaterial.sideOrientation,u._getWorldMatrixDeterminant()<0&&(h=h===g.a.ClockWiseSideOrientation?g.a.CounterClockWiseSideOrientation:g.a.ClockWiseSideOrientation));var d=this._effectiveMaterial._preBind(n,h);this._effectiveMaterial.forceDepthWrite&&o.setDepthWrite(!0);var f=i.forcePointsCloud?g.a.PointFillMode:i.forceWireframe?g.a.WireFrameFillMode:this._effectiveMaterial.fillMode;this._onBeforeBindObservable&&this._onBeforeBindObservable.notifyObservers(this),s||this._bind(e,n,f);var p=u.getWorldMatrix();this._effectiveMaterial._storeEffectOnSubMeshes?this._effectiveMaterial.bindForSubMesh(p,this,e):this._effectiveMaterial.bind(p,this),!this._effectiveMaterial.backFaceCulling&&this._effectiveMaterial.separateCullingPass&&(o.setState(!0,this._effectiveMaterial.zOffset,!1,!d),this._processRendering(e,n,f,r,s,this._onBeforeDraw,this._effectiveMaterial),o.setState(!0,this._effectiveMaterial.zOffset,!1,d)),this._processRendering(e,n,f,r,s,this._onBeforeDraw,this._effectiveMaterial),this._effectiveMaterial.unbind();for(var _=0,m=i._afterRenderingMeshStage;_<m.length;_++){m[_].action(this,e,r)}return this._onAfterRenderObservable&&this._onAfterRenderObservable.notifyObservers(this),this},t.prototype._onBeforeDraw=function(e,t,i){e&&i&&i.bindOnlyWorldMatrix(t)},t.prototype.cleanMatrixWeights=function(){this.isVerticesDataPresent(u.b.MatricesWeightsKind)&&(this.isVerticesDataPresent(u.b.MatricesWeightsExtraKind)?this.normalizeSkinWeightsAndExtra():this.normalizeSkinFourWeights())},t.prototype.normalizeSkinFourWeights=function(){for(var e=this.getVerticesData(u.b.MatricesWeightsKind),t=e.length,i=0;i<t;i+=4){var r=e[i]+e[i+1]+e[i+2]+e[i+3];if(0===r)e[i]=1;else{var n=1/r;e[i]*=n,e[i+1]*=n,e[i+2]*=n,e[i+3]*=n}}this.setVerticesData(u.b.MatricesWeightsKind,e)},t.prototype.normalizeSkinWeightsAndExtra=function(){for(var e=this.getVerticesData(u.b.MatricesWeightsExtraKind),t=this.getVerticesData(u.b.MatricesWeightsKind),i=t.length,r=0;r<i;r+=4){var n=t[r]+t[r+1]+t[r+2]+t[r+3];if(0===(n+=e[r]+e[r+1]+e[r+2]+e[r+3]))t[r]=1;else{var o=1/n;t[r]*=o,t[r+1]*=o,t[r+2]*=o,t[r+3]*=o,e[r]*=o,e[r+1]*=o,e[r+2]*=o,e[r+3]*=o}}this.setVerticesData(u.b.MatricesWeightsKind,t),this.setVerticesData(u.b.MatricesWeightsKind,e)},t.prototype.validateSkinning=function(){var e=this.getVerticesData(u.b.MatricesWeightsExtraKind),t=this.getVerticesData(u.b.MatricesWeightsKind);if(null===t||null==this.skeleton)return{skinned:!1,valid:!0,report:"not skinned"};for(var i=t.length,r=0,n=0,o=0,s=0,a=null===e?4:8,c=new Array,l=0;l<=a;l++)c[l]=0;for(l=0;l<i;l+=4){for(var h=t[l],d=h,f=0===d?0:1,p=1;p<a;p++){var _=p<4?t[l+p]:e[l+p-4];_>h&&r++,0!==_&&f++,d+=_,h=_}if(c[f]++,f>o&&(o=f),0===d)n++;else{var g=1/d,m=0;for(p=0;p<a;p++)m+=p<4?Math.abs(t[l+p]-t[l+p]*g):Math.abs(e[l+p-4]-e[l+p-4]*g);m>.001&&s++}}var v=this.skeleton.bones.length,y=this.getVerticesData(u.b.MatricesIndicesKind),b=this.getVerticesData(u.b.MatricesIndicesExtraKind),T=0;for(l=0;l<i;l++)for(p=0;p<a;p++){var E=p<4?y[p]:b[p-4];(E>=v||E<0)&&T++}return{skinned:!0,valid:0===n&&0===s&&0===T,report:"Number of Weights = "+i/4+"\nMaximum influences = "+o+"\nMissing Weights = "+n+"\nNot Sorted = "+r+"\nNot Normalized = "+s+"\nWeightCounts = ["+c+"]\nNumber of bones = "+v+"\nBad Bone Indices = "+T}},t.prototype._checkDelayState=function(){var e=this.getScene();return this._geometry?this._geometry.load(e):this.delayLoadState===y.a.DELAYLOADSTATE_NOTLOADED&&(this.delayLoadState=y.a.DELAYLOADSTATE_LOADING,this._queueLoad(e)),this},t.prototype._queueLoad=function(e){var t=this;e._addPendingData(this);var i=-1!==this.delayLoadingFile.indexOf(".babylonbinarymeshdata");return o.h.LoadFile(this.delayLoadingFile,function(i){i instanceof ArrayBuffer?t._delayLoadingFunction(i,t):t._delayLoadingFunction(JSON.parse(i),t),t.instances.forEach(function(e){e._syncSubMeshes()}),t.delayLoadState=y.a.DELAYLOADSTATE_LOADED,e._removePendingData(t)},function(){},e.offlineProvider,i),this},t.prototype.isInFrustum=function(t){return this.delayLoadState!==y.a.DELAYLOADSTATE_LOADING&&(!!e.prototype.isInFrustum.call(this,t)&&(this._checkDelayState(),!0))},t.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},t.prototype.getAnimatables=function(){var e=new Array;return this.material&&e.push(this.material),this.skeleton&&e.push(this.skeleton),e},t.prototype.bakeTransformIntoVertices=function(e){if(!this.isVerticesDataPresent(u.b.PositionKind))return this;var t=this.subMeshes.splice(0);this._resetPointsArrayCache();var i,r=this.getVerticesData(u.b.PositionKind),n=new Array;for(i=0;i<r.length;i+=3)c.x.TransformCoordinates(c.x.FromArray(r,i),e).toArray(n,i);if(this.setVerticesData(u.b.PositionKind,n,this.getVertexBuffer(u.b.PositionKind).isUpdatable()),this.isVerticesDataPresent(u.b.NormalKind)){for(r=this.getVerticesData(u.b.NormalKind),n=[],i=0;i<r.length;i+=3)c.x.TransformNormal(c.x.FromArray(r,i),e).normalize().toArray(n,i);this.setVerticesData(u.b.NormalKind,n,this.getVertexBuffer(u.b.NormalKind).isUpdatable())}return e.m[0]*e.m[5]*e.m[10]<0&&this.flipFaces(),this.releaseSubMeshes(),this.subMeshes=t,this},t.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=c.q.Identity()),this._worldMatrix=c.j.Identity(),this},Object.defineProperty(t.prototype,"_positions",{get:function(){return this._geometry?this._geometry._positions:null},enumerable:!0,configurable:!0}),t.prototype._resetPointsArrayCache=function(){return this._geometry&&this._geometry._resetPointsArrayCache(),this},t.prototype._generatePointsArray=function(){return!!this._geometry&&this._geometry._generatePointsArray()},t.prototype.clone=function(e,i,r,n){return void 0===e&&(e=""),void 0===n&&(n=!0),new t(e,this.getScene(),i,this,r,n)},t.prototype.dispose=function(t,i){if(void 0===i&&(i=!1),this.morphTargetManager=null,this._geometry&&this._geometry.releaseForMesh(this,!0),this._onBeforeDrawObservable&&this._onBeforeDrawObservable.clear(),this._onBeforeBindObservable&&this._onBeforeBindObservable.clear(),this._onBeforeRenderObservable&&this._onBeforeRenderObservable.clear(),this._onAfterRenderObservable&&this._onAfterRenderObservable.clear(),this._scene.useClonedMeshhMap){if(this.meshMap)for(var r in this.meshMap){(s=this.meshMap[r])&&(s._source=null,this.meshMap[r]=void 0)}this._source&&this._source.meshMap&&(this._source.meshMap[this.uniqueId]=void 0)}else for(var n=0,o=this.getScene().meshes;n<o.length;n++){var s;(s=o[n])._source&&s._source===this&&(s._source=null)}for(this._source=null,this._instanceDataStorage.instancesBuffer&&(this._instanceDataStorage.instancesBuffer.dispose(),this._instanceDataStorage.instancesBuffer=null);this.instances.length;)this.instances[0].dispose();e.prototype.dispose.call(this,t,i)},t.prototype.applyDisplacementMap=function(e,t,i,r,n,s,a){var c=this;void 0===a&&(a=!1);var l=this.getScene();return o.h.LoadImage(e,function(e){var o=document.createElement("canvas"),l=o.getContext("2d"),u=e.width,h=e.height;o.width=u,o.height=h,l.drawImage(e,0,0);var d=l.getImageData(0,0,u,h).data;c.applyDisplacementMapFromBuffer(d,u,h,t,i,n,s,a),r&&r(c)},function(){},l.offlineProvider),this},t.prototype.applyDisplacementMapFromBuffer=function(e,t,i,r,n,o,s,a){if(void 0===a&&(a=!1),!this.isVerticesDataPresent(u.b.PositionKind)||!this.isVerticesDataPresent(u.b.NormalKind)||!this.isVerticesDataPresent(u.b.UVKind))return T.a.Warn("Cannot call applyDisplacementMap: Given mesh is not complete. Position, Normal or UV are missing"),this;var l=this.getVerticesData(u.b.PositionKind,!0,!0),d=this.getVerticesData(u.b.NormalKind),f=this.getVerticesData(u.b.UVKind),p=c.x.Zero(),_=c.x.Zero(),g=c.w.Zero();o=o||c.w.Zero(),s=s||new c.w(1,1);for(var m=0;m<l.length;m+=3){c.x.FromArrayToRef(l,m,p),c.x.FromArrayToRef(d,m,_),c.w.FromArrayToRef(f,m/3*2,g);var v=4*((Math.abs(g.x*s.x+o.x)*t%t|0)+(Math.abs(g.y*s.y+o.y)*i%i|0)*t),y=.3*(e[v]/255)+.59*(e[v+1]/255)+.11*(e[v+2]/255);_.normalize(),_.scaleInPlace(r+(n-r)*y),(p=p.add(_)).toArray(l,m)}return h.a.ComputeNormals(l,this.getIndices(),d),a?(this.setVerticesData(u.b.PositionKind,l),this.setVerticesData(u.b.NormalKind,d)):(this.updateVerticesData(u.b.PositionKind,l),this.updateVerticesData(u.b.NormalKind,d)),this},t.prototype.convertToFlatShadedMesh=function(){var e,t,i=this.getVerticesDataKinds(),r={},n={},o={},s=!1;for(e=0;e<i.length;e++){t=i[e];var a=this.getVertexBuffer(t);t!==u.b.NormalKind?(r[t]=a,n[t]=r[t].getData(),o[t]=[]):(s=a.isUpdatable(),i.splice(e,1),e--)}var l,h=this.subMeshes.slice(0),d=this.getIndices(),f=this.getTotalIndices();for(l=0;l<f;l++){var _=d[l];for(e=0;e<i.length;e++)for(var g=r[t=i[e]].getStrideSize(),m=0;m<g;m++)o[t].push(n[t][_*g+m])}var v=[],y=o[u.b.PositionKind];for(l=0;l<f;l+=3){d[l]=l,d[l+1]=l+1,d[l+2]=l+2;for(var b=c.x.FromArray(y,3*l),T=c.x.FromArray(y,3*(l+1)),E=c.x.FromArray(y,3*(l+2)),x=b.subtract(T),A=E.subtract(T),P=c.x.Normalize(c.x.Cross(x,A)),R=0;R<3;R++)v.push(P.x),v.push(P.y),v.push(P.z)}for(this.setIndices(d),this.setVerticesData(u.b.NormalKind,v,s),e=0;e<i.length;e++)t=i[e],this.setVerticesData(t,o[t],r[t].isUpdatable());this.releaseSubMeshes();for(var S=0;S<h.length;S++){var C=h[S];p.b.AddToMesh(C.materialIndex,C.indexStart,C.indexCount,C.indexStart,C.indexCount,this)}return this.synchronizeInstances(),this},t.prototype.convertToUnIndexedMesh=function(){var e,t,i=this.getVerticesDataKinds(),r={},n={},o={};for(e=0;e<i.length;e++){t=i[e];var s=this.getVertexBuffer(t);r[t]=s,n[t]=r[t].getData(),o[t]=[]}var a,c=this.subMeshes.slice(0),l=this.getIndices(),u=this.getTotalIndices();for(a=0;a<u;a++){var h=l[a];for(e=0;e<i.length;e++)for(var d=r[t=i[e]].getStrideSize(),f=0;f<d;f++)o[t].push(n[t][h*d+f])}for(a=0;a<u;a+=3)l[a]=a,l[a+1]=a+1,l[a+2]=a+2;for(this.setIndices(l),e=0;e<i.length;e++)t=i[e],this.setVerticesData(t,o[t],r[t].isUpdatable());this.releaseSubMeshes();for(var _=0;_<c.length;_++){var g=c[_];p.b.AddToMesh(g.materialIndex,g.indexStart,g.indexCount,g.indexStart,g.indexCount,this)}return this._unIndexed=!0,this.synchronizeInstances(),this},t.prototype.flipFaces=function(e){void 0===e&&(e=!1);var t,i,r=h.a.ExtractFromMesh(this);if(e&&this.isVerticesDataPresent(u.b.NormalKind)&&r.normals)for(t=0;t<r.normals.length;t++)r.normals[t]*=-1;if(r.indices)for(t=0;t<r.indices.length;t+=3)i=r.indices[t+1],r.indices[t+1]=r.indices[t+2],r.indices[t+2]=i;return r.applyToMesh(this),this},t.prototype.createInstance=function(e){return t._instancedMeshFactory(e,this)},t.prototype.synchronizeInstances=function(){for(var e=0;e<this.instances.length;e++){this.instances[e]._syncSubMeshes()}return this},t.prototype.optimizeIndices=function(e){var t=this,i=this.getIndices(),r=this.getVerticesData(u.b.PositionKind);if(!r||!i)return this;for(var n=new Array,s=0;s<r.length;s+=3)n.push(c.x.FromArray(r,s));var a=new Array;return o.a.SyncAsyncForLoop(n.length,40,function(e){for(var t=n.length-1-e,i=n[t],r=0;r<t;++r){var o=n[r];if(i.equals(o)){a[t]=r;break}}},function(){for(var r=0;r<i.length;++r)i[r]=a[i[r]]||i[r];var n=t.subMeshes.slice(0);t.setIndices(i),t.subMeshes=n,e&&e(t)}),this},t.prototype.serialize=function(e){e.name=this.name,e.id=this.id,e.type=this.getClassName(),a.a&&a.a.HasTags(this)&&(e.tags=a.a.GetTags(this)),e.position=this.position.asArray(),this.rotationQuaternion?e.rotationQuaternion=this.rotationQuaternion.asArray():this.rotation&&(e.rotation=this.rotation.asArray()),e.scaling=this.scaling.asArray(),this._postMultiplyPivotMatrix?e.pivotMatrix=this.getPivotMatrix().asArray():e.localMatrix=this.getPivotMatrix().asArray(),e.isEnabled=this.isEnabled(!1),e.isVisible=this.isVisible,e.infiniteDistance=this.infiniteDistance,e.pickable=this.isPickable,e.receiveShadows=this.receiveShadows,e.billboardMode=this.billboardMode,e.visibility=this.visibility,e.checkCollisions=this.checkCollisions,e.isBlocker=this.isBlocker,this.parent&&(e.parentId=this.parent.id),e.isUnIndexed=this.isUnIndexed;var t=this._geometry;if(t){var i=t.id;e.geometryId=i,e.subMeshes=[];for(var r=0;r<this.subMeshes.length;r++){var n=this.subMeshes[r];e.subMeshes.push({materialIndex:n.materialIndex,verticesStart:n.verticesStart,verticesCount:n.verticesCount,indexStart:n.indexStart,indexCount:n.indexCount})}}this.material?e.materialId=this.material.id:this.material=null,this.morphTargetManager&&(e.morphTargetManagerId=this.morphTargetManager.uniqueId),this.skeleton&&(e.skeletonId=this.skeleton.id);var o=this.getPhysicsImpostor();o&&(e.physicsMass=o.getParam("mass"),e.physicsFriction=o.getParam("friction"),e.physicsRestitution=o.getParam("mass"),e.physicsImpostor=o.type),this.metadata&&(e.metadata=this.metadata),e.instances=[];for(var s=0;s<this.instances.length;s++){var c=this.instances[s];if(!c.doNotSerialize){var l={name:c.name,id:c.id,position:c.position.asArray(),scaling:c.scaling.asArray()};c.parent&&(l.parentId=c.parent.id),c.rotationQuaternion?l.rotationQuaternion=c.rotationQuaternion.asArray():c.rotation&&(l.rotation=c.rotation.asArray()),e.instances.push(l),b.a.AppendSerializedAnimations(c,l),l.ranges=c.serializeAnimationRanges()}}b.a.AppendSerializedAnimations(this,e),e.ranges=this.serializeAnimationRanges(),e.layerMask=this.layerMask,e.alphaIndex=this.alphaIndex,e.hasVertexAlpha=this.hasVertexAlpha,e.overlayAlpha=this.overlayAlpha,e.overlayColor=this.overlayColor.asArray(),e.renderOverlay=this.renderOverlay,e.applyFog=this.applyFog,this.actionManager&&(e.actions=this.actionManager.serialize(this.name))},t.prototype._syncGeometryWithMorphTargetManager=function(){if(this.geometry){this._markSubMeshesAsAttributesDirty();var e=this._morphTargetManager;if(e&&e.vertexCount){if(e.vertexCount!==this.getTotalVertices())return T.a.Error("Mesh is incompatible with morph targets. Targets and mesh must all have the same vertices count."),void(this.morphTargetManager=null);for(var t=0;t<e.numInfluencers;t++){var i=e.getActiveTarget(t),r=i.getPositions();if(!r)return void T.a.Error("Invalid morph target. Target must have positions.");this.geometry.setVerticesData(u.b.PositionKind+t,r,!1,3);var n=i.getNormals();n&&this.geometry.setVerticesData(u.b.NormalKind+t,n,!1,3);var o=i.getTangents();o&&this.geometry.setVerticesData(u.b.TangentKind+t,o,!1,3)}}else for(t=0;this.geometry.isVerticesDataPresent(u.b.PositionKind+t);)this.geometry.removeVerticesData(u.b.PositionKind+t),this.geometry.isVerticesDataPresent(u.b.NormalKind+t)&&this.geometry.removeVerticesData(u.b.NormalKind+t),this.geometry.isVerticesDataPresent(u.b.TangentKind+t)&&this.geometry.removeVerticesData(u.b.TangentKind+t),t++}},t.Parse=function(e,i,r){var n;if((n=e.type&&"GroundMesh"===e.type?t._GroundMeshParser(e,i):new t(e.name,i)).id=e.id,a.a&&a.a.AddTagsTo(n,e.tags),n.position=c.x.FromArray(e.position),void 0!==e.metadata&&(n.metadata=e.metadata),e.rotationQuaternion?n.rotationQuaternion=c.q.FromArray(e.rotationQuaternion):e.rotation&&(n.rotation=c.x.FromArray(e.rotation)),n.scaling=c.x.FromArray(e.scaling),e.localMatrix?n.setPreTransformMatrix(c.j.FromArray(e.localMatrix)):e.pivotMatrix&&n.setPivotMatrix(c.j.FromArray(e.pivotMatrix)),n.setEnabled(e.isEnabled),n.isVisible=e.isVisible,n.infiniteDistance=e.infiniteDistance,n.showBoundingBox=e.showBoundingBox,n.showSubMeshesBoundingBox=e.showSubMeshesBoundingBox,void 0!==e.applyFog&&(n.applyFog=e.applyFog),void 0!==e.pickable&&(n.isPickable=e.pickable),void 0!==e.alphaIndex&&(n.alphaIndex=e.alphaIndex),n.receiveShadows=e.receiveShadows,n.billboardMode=e.billboardMode,void 0!==e.visibility&&(n.visibility=e.visibility),n.checkCollisions=e.checkCollisions,void 0!==e.isBlocker&&(n.isBlocker=e.isBlocker),n._shouldGenerateFlatShading=e.useFlatShading,e.freezeWorldMatrix&&(n._waitingFreezeWorldMatrix=e.freezeWorldMatrix),e.parentId&&(n._waitingParentId=e.parentId),void 0!==e.actions&&(n._waitingActions=e.actions),void 0!==e.overlayAlpha&&(n.overlayAlpha=e.overlayAlpha),void 0!==e.overlayColor&&(n.overlayColor=c.e.FromArray(e.overlayColor)),void 0!==e.renderOverlay&&(n.renderOverlay=e.renderOverlay),n.isUnIndexed=!!e.isUnIndexed,n.hasVertexAlpha=e.hasVertexAlpha,e.delayLoadingFile?(n.delayLoadState=y.a.DELAYLOADSTATE_NOTLOADED,n.delayLoadingFile=r+e.delayLoadingFile,n._boundingInfo=new _.a(c.x.FromArray(e.boundingBoxMinimum),c.x.FromArray(e.boundingBoxMaximum)),e._binaryInfo&&(n._binaryInfo=e._binaryInfo),n._delayInfo=[],e.hasUVs&&n._delayInfo.push(u.b.UVKind),e.hasUVs2&&n._delayInfo.push(u.b.UV2Kind),e.hasUVs3&&n._delayInfo.push(u.b.UV3Kind),e.hasUVs4&&n._delayInfo.push(u.b.UV4Kind),e.hasUVs5&&n._delayInfo.push(u.b.UV5Kind),e.hasUVs6&&n._delayInfo.push(u.b.UV6Kind),e.hasColors&&n._delayInfo.push(u.b.ColorKind),e.hasMatricesIndices&&n._delayInfo.push(u.b.MatricesIndicesKind),e.hasMatricesWeights&&n._delayInfo.push(u.b.MatricesWeightsKind),n._delayLoadingFunction=d.a._ImportGeometry,m.a.ForceFullSceneLoadingForIncremental&&n._checkDelayState()):d.a._ImportGeometry(e,n),e.materialId?n.setMaterialByID(e.materialId):n.material=null,e.morphTargetManagerId>-1&&(n.morphTargetManager=i.getMorphTargetManagerById(e.morphTargetManagerId)),e.skeletonId>-1&&(n.skeleton=i.getLastSkeletonByID(e.skeletonId),e.numBoneInfluencers&&(n.numBoneInfluencers=e.numBoneInfluencers)),e.animations){for(var o=0;o<e.animations.length;o++){var s=e.animations[o];(g=E.a.GetClass("BABYLON.Animation"))&&n.animations.push(g.Parse(s))}l.a.ParseAnimationRanges(n,e,i)}if(e.autoAnimate&&i.beginAnimation(n,e.autoAnimateFrom,e.autoAnimateTo,e.autoAnimateLoop,e.autoAnimateSpeed||1),e.layerMask&&!isNaN(e.layerMask)?n.layerMask=Math.abs(parseInt(e.layerMask)):n.layerMask=268435455,e.physicsImpostor&&(n.physicsImpostor=new v.a(n,e.physicsImpostor,{mass:e.physicsMass,friction:e.physicsFriction,restitution:e.physicsRestitution},i)),e.instances)for(var h=0;h<e.instances.length;h++){var f=e.instances[h],p=n.createInstance(f.name);if(f.id&&(p.id=f.id),a.a&&(f.tags?a.a.AddTagsTo(p,f.tags):a.a.AddTagsTo(p,e.tags)),p.position=c.x.FromArray(f.position),f.parentId&&(p._waitingParentId=f.parentId),f.rotationQuaternion?p.rotationQuaternion=c.q.FromArray(f.rotationQuaternion):f.rotation&&(p.rotation=c.x.FromArray(f.rotation)),p.scaling=c.x.FromArray(f.scaling),null!=f.checkCollisions&&null!=f.checkCollisions&&(p.checkCollisions=f.checkCollisions),null!=f.pickable&&null!=f.pickable&&(p.isPickable=f.pickable),null!=f.showBoundingBox&&null!=f.showBoundingBox&&(p.showBoundingBox=f.showBoundingBox),null!=f.showSubMeshesBoundingBox&&null!=f.showSubMeshesBoundingBox&&(p.showSubMeshesBoundingBox=f.showSubMeshesBoundingBox),null!=f.alphaIndex&&null!=f.showSubMeshesBoundingBox&&(p.alphaIndex=f.alphaIndex),f.physicsImpostor&&(p.physicsImpostor=new v.a(p,f.physicsImpostor,{mass:f.physicsMass,friction:f.physicsFriction,restitution:f.physicsRestitution},i)),f.animations){for(o=0;o<f.animations.length;o++){var g;s=f.animations[o],(g=E.a.GetClass("BABYLON.Animation"))&&p.animations.push(g.Parse(s))}l.a.ParseAnimationRanges(p,f,i),f.autoAnimate&&i.beginAnimation(p,f.autoAnimateFrom,f.autoAnimateTo,f.autoAnimateLoop,f.autoAnimateSpeed||1)}}return n},t.CreateRibbon=function(e,t,i,r,n,o,s,a,c){throw"Import MeshBuilder before creating meshes."},t.CreateDisc=function(e,t,i,r,n,o){throw void 0===r&&(r=null),"Import MeshBuilder before creating meshes."},t.CreateBox=function(e,t,i,r,n){throw void 0===i&&(i=null),"Import MeshBuilder before creating meshes."},t.CreateSphere=function(e,t,i,r,n,o){throw"Import MeshBuilder before creating meshes."},t.CreateCylinder=function(e,t,i,r,n,o,s,a,c){throw"Import MeshBuilder before creating meshes."},t.CreateTorus=function(e,t,i,r,n,o,s){throw"Import MeshBuilder before creating meshes."},t.CreateTorusKnot=function(e,t,i,r,n,o,s,a,c,l){throw"Import MeshBuilder before creating meshes."},t.CreateLines=function(e,t,i,r,n){throw void 0===i&&(i=null),void 0===r&&(r=!1),void 0===n&&(n=null),"Import MeshBuilder before creating meshes."},t.CreateDashedLines=function(e,t,i,r,n,o,s,a){throw void 0===o&&(o=null),"Import MeshBuilder before creating meshes."},t.CreatePolygon=function(e,t,i,r,n,o,s){throw void 0===s&&(s=earcut),"Import MeshBuilder before creating meshes."},t.ExtrudePolygon=function(e,t,i,r,n,o,s,a){throw void 0===a&&(a=earcut),"Import MeshBuilder before creating meshes."},t.ExtrudeShape=function(e,t,i,r,n,o,s,a,c,l){throw void 0===s&&(s=null),"Import MeshBuilder before creating meshes."},t.ExtrudeShapeCustom=function(e,t,i,r,n,o,s,a,c,l,u,h){throw"Import MeshBuilder before creating meshes."},t.CreateLathe=function(e,t,i,r,n,o,s){throw"Import MeshBuilder before creating meshes."},t.CreatePlane=function(e,t,i,r,n){throw"Import MeshBuilder before creating meshes."},t.CreateGround=function(e,t,i,r,n,o){throw"Import MeshBuilder before creating meshes."},t.CreateTiledGround=function(e,t,i,r,n,o,s,a,c){throw"Import MeshBuilder before creating meshes."},t.CreateGroundFromHeightMap=function(e,t,i,r,n,o,s,a,c,l,u){throw"Import MeshBuilder before creating meshes."},t.CreateTube=function(e,t,i,r,n,o,s,a,c,l){throw"Import MeshBuilder before creating meshes."},t.CreatePolyhedron=function(e,t,i){throw"Import MeshBuilder before creating meshes."},t.CreateIcoSphere=function(e,t,i){throw"Import MeshBuilder before creating meshes."},t.CreateDecal=function(e,t,i,r,n,o){throw"Import MeshBuilder before creating meshes."},t.prototype.setPositionsForCPUSkinning=function(){if(!this._sourcePositions){var e=this.getVerticesData(u.b.PositionKind);if(!e)return this._sourcePositions;this._sourcePositions=new Float32Array(e),this.isVertexBufferUpdatable(u.b.PositionKind)||this.setVerticesData(u.b.PositionKind,e,!0)}return this._sourcePositions},t.prototype.setNormalsForCPUSkinning=function(){if(!this._sourceNormals){var e=this.getVerticesData(u.b.NormalKind);if(!e)return this._sourceNormals;this._sourceNormals=new Float32Array(e),this.isVertexBufferUpdatable(u.b.NormalKind)||this.setVerticesData(u.b.NormalKind,e,!0)}return this._sourceNormals},t.prototype.applySkeleton=function(e){if(!this.geometry)return this;if(this.geometry._softwareSkinningFrameId==this.getScene().getFrameId())return this;if(this.geometry._softwareSkinningFrameId=this.getScene().getFrameId(),!this.isVerticesDataPresent(u.b.PositionKind))return this;if(!this.isVerticesDataPresent(u.b.NormalKind))return this;if(!this.isVerticesDataPresent(u.b.MatricesIndicesKind))return this;if(!this.isVerticesDataPresent(u.b.MatricesWeightsKind))return this;if(!this._sourcePositions){var t=this.subMeshes.slice();this.setPositionsForCPUSkinning(),this.subMeshes=t}this._sourceNormals||this.setNormalsForCPUSkinning();var i=this.getVerticesData(u.b.PositionKind);if(!i)return this;i instanceof Float32Array||(i=new Float32Array(i));var r=this.getVerticesData(u.b.NormalKind);if(!r)return this;r instanceof Float32Array||(r=new Float32Array(r));var n=this.getVerticesData(u.b.MatricesIndicesKind),o=this.getVerticesData(u.b.MatricesWeightsKind);if(!o||!n)return this;for(var s,a=this.numBoneInfluencers>4,l=a?this.getVerticesData(u.b.MatricesIndicesExtraKind):null,h=a?this.getVerticesData(u.b.MatricesWeightsExtraKind):null,d=e.getTransformMatrices(this),f=c.x.Zero(),p=new c.j,_=new c.j,g=0,m=0;m<i.length;m+=3,g+=4){var v;for(s=0;s<4;s++)(v=o[g+s])>0&&(c.j.FromFloat32ArrayToRefScaled(d,Math.floor(16*n[g+s]),v,_),p.addToSelf(_));if(a)for(s=0;s<4;s++)(v=h[g+s])>0&&(c.j.FromFloat32ArrayToRefScaled(d,Math.floor(16*l[g+s]),v,_),p.addToSelf(_));c.x.TransformCoordinatesFromFloatsToRef(this._sourcePositions[m],this._sourcePositions[m+1],this._sourcePositions[m+2],p,f),f.toArray(i,m),c.x.TransformNormalFromFloatsToRef(this._sourceNormals[m],this._sourceNormals[m+1],this._sourceNormals[m+2],p,f),f.toArray(r,m),p.reset()}return this.updateVerticesData(u.b.PositionKind,i),this.updateVerticesData(u.b.NormalKind,r),this},t.MinMax=function(e){var t=null,i=null;return e.forEach(function(e){var r=e.getBoundingInfo().boundingBox;t&&i?(t.minimizeInPlace(r.minimumWorld),i.maximizeInPlace(r.maximumWorld)):(t=r.minimumWorld,i=r.maximumWorld)}),t&&i?{min:t,max:i}:{min:c.x.Zero(),max:c.x.Zero()}},t.Center=function(e){var i=e instanceof Array?t.MinMax(e):e;return c.x.Center(i.min,i.max)},t.MergeMeshes=function(e,i,r,n,o){var s;if(void 0===i&&(i=!0),!r){var a=0;for(s=0;s<e.length;s++)if(e[s]&&(a+=e[s].getTotalVertices())>65536)return T.a.Warn("Cannot merge meshes because resulting mesh will have more than 65536 vertices. Please use allow32BitsIndices = true to use 32 bits indices"),null}var c,l=null,u=new Array,d=null;for(s=0;s<e.length;s++)if(e[s]){var f=e[s].computeWorldMatrix(!0);(c=h.a.ExtractFromMesh(e[s],!0,!0)).transform(f),l?l.merge(c,r):(l=c,d=e[s]),o&&u.push(e[s].getTotalIndices())}if(d=d,n||(n=new t(d.name+"_merged",d.getScene())),l.applyToMesh(n),n.material=d.material,n.checkCollisions=d.checkCollisions,i)for(s=0;s<e.length;s++)e[s]&&e[s].dispose();if(o){n.releaseSubMeshes(),s=0;for(var _=0;s<u.length;)p.b.CreateFromIndices(0,_,u[s],n),_+=u[s],s++}return n},t.prototype.addInstance=function(e){e._indexInSourceMeshInstanceArray=this.instances.length,this.instances.push(e)},t.prototype.removeInstance=function(e){var t=e._indexInSourceMeshInstanceArray;if(-1!=t){if(t!==this.instances.length-1){var i=this.instances[this.instances.length-1];this.instances[t]=i,i._indexInSourceMeshInstanceArray=t}e._indexInSourceMeshInstanceArray=-1,this.instances.pop()}},t.FRONTSIDE=h.a.FRONTSIDE,t.BACKSIDE=h.a.BACKSIDE,t.DOUBLESIDE=h.a.DOUBLESIDE,t.DEFAULTSIDE=h.a.DEFAULTSIDE,t.NO_CAP=0,t.CAP_START=1,t.CAP_END=2,t.CAP_ALL=3,t._instancedMeshFactory=function(e,t){throw"Import InstancedMesh before creating instances."},t._GroundMeshParser=function(e,t){throw"Import GroundMesh before trying to parse it."},t}(f.a)},function(e,t,i){"use strict";i.d(t,"d",function(){return E}),i.d(t,"a",function(){return x}),i.d(t,"c",function(){return A}),i.d(t,"b",function(){return P});var r=i(1),n=i(7),o=i(100),s=i(58),a=i(101),c=i(9),l=i(0),u=i(12),h=i(5),d=i(18),f=i(88),p=i(25),_=i(85),g=i(3),m=i(38),v=i(8),y=i(22),b=i(83),T=function(){return function(){}}(),E=function(){return function(){}}(),x=function(){return function(){}}(),A=function(){return function(){}}(),P=function(){function e(t,i,r,s){void 0===s&&(s=!1);var u=this;this.forcePOTTextures=!1,this.isFullscreen=!1,this.isPointerLock=!1,this.cullBackFaces=!0,this.renderEvenInBackground=!0,this.preventCacheWipeBetweenFrames=!1,this.enableOfflineSupport=!1,this.disableManifestCheck=!1,this.scenes=new Array,this.onNewSceneAddedObservable=new n.c,this.postProcesses=new Array,this.validateShaderPrograms=!1,this.onResizeObservable=new n.c,this.onCanvasBlurObservable=new n.c,this.onCanvasFocusObservable=new n.c,this.onCanvasPointerOutObservable=new n.c,this.onBeforeTextureInitObservable=new n.c,this._vrDisplay=void 0,this._vrSupported=!1,this._vrExclusivePointerMode=!1,this.disableUniformBuffers=!1,this._uniformBuffers=new Array,this.onBeginFrameObservable=new n.c,this.customAnimationFrameRequester=null,this.onEndFrameObservable=new n.c,this.onBeforeShaderCompilationObservable=new n.c,this.onAfterShaderCompilationObservable=new n.c,this._windowIsBackground=!1,this._webGLVersion=1,this._badOS=!1,this._badDesktopOS=!1,this.disableTextureBindingOptimization=!1,this.onVRDisplayChangedObservable=new n.c,this.onVRRequestPresentComplete=new n.c,this.onVRRequestPresentStart=new n.c,this._colorWrite=!0,this._drawCalls=new c.f,this._textureCollisions=new c.f,this._renderingQueueLaunched=!1,this._activeRenderLoops=new Array,this._deterministicLockstep=!1,this._lockstepMaxSteps=4,this.onContextLostObservable=new n.c,this.onContextRestoredObservable=new n.c,this._contextWasLost=!1,this._doNotHandleContextLost=!1,this._performanceMonitor=new o.a,this._fps=60,this._deltaTime=0,this.disablePerformanceMonitorInBackground=!1,this._depthCullingState=new _.b,this._stencilState=new _.c,this._alphaState=new _.a,this._alphaMode=e.ALPHA_DISABLE,this._internalTexturesCache=new Array,this._activeChannel=0,this._currentTextureChannel=-1,this._boundTexturesCache={},this._compiledEffects={},this._vertexAttribArraysEnabled=[],this._uintIndicesCurrentlySet=!1,this._currentBoundBuffer=new Array,this._currentFramebuffer=null,this._currentBufferPointers=new Array,this._currentInstanceLocations=new Array,this._currentInstanceBuffers=new Array,this._firstBoundInternalTextureTracker=new f.a,this._lastBoundInternalTextureTracker=new f.a,this._vaoRecordInProgress=!1,this._mustWipeVertexAttributes=!1,this._nextFreeTextureSlots=new Array,this._maxSimultaneousTextures=0,this._activeRequests=new Array,this._texturesSupported=new Array,this.premultipliedAlpha=!0,this._viewportCached=new l.y(0,0,0,0),this._onVRFullScreenTriggered=function(){if(u._vrDisplay&&u._vrDisplay.isPresenting){u._oldSize=new l.r(u.getRenderWidth(),u.getRenderHeight()),u._oldHardwareScaleFactor=u.getHardwareScalingLevel();var e=u._vrDisplay.getEyeParameters("left");u.setHardwareScalingLevel(1),u.setSize(2*e.renderWidth,e.renderHeight)}else u.setHardwareScalingLevel(u._oldHardwareScaleFactor),u.setSize(u._oldSize.width,u._oldSize.height)},this._unpackFlipYCached=null,this.enableUnpackFlipYCached=!0,this._boundUniforms={},a.a.Apply();var h=null;if(e.Instances.push(this),t){if(r=r||{},t.getContext){if(h=t,this._renderingCanvas=h,null!=i&&(r.antialias=i),void 0===r.deterministicLockstep&&(r.deterministicLockstep=!1),void 0===r.lockstepMaxSteps&&(r.lockstepMaxSteps=4),void 0===r.preserveDrawingBuffer&&(r.preserveDrawingBuffer=!1),void 0===r.audioEngine&&(r.audioEngine=!0),void 0===r.stencil&&(r.stencil=!0),!1===r.premultipliedAlpha&&(this.premultipliedAlpha=!1),this._deterministicLockstep=r.deterministicLockstep,this._lockstepMaxSteps=r.lockstepMaxSteps,this._doNotHandleContextLost=!!r.doNotHandleContextLost,navigator&&navigator.userAgent)for(var d=navigator.userAgent,p=0,g=e.ExceptionList;p<g.length;p++){var y=g[p],b=y.key,E=y.targets;if(d.indexOf(b)>-1){if(y.capture&&y.captureConstraint){var x=y.capture,A=y.captureConstraint,P=new RegExp(x).exec(d);if(P&&P.length>0)if(parseInt(P[P.length-1])>=A)continue}for(var R=0,S=E;R<S.length;R++){switch(S[R]){case"uniformBuffer":this.disableUniformBuffers=!0;break;case"textureBindingOptimization":this.disableTextureBindingOptimization=!0}}}}if(!r.disableWebGL2Support)try{this._gl=h.getContext("webgl2",r)||h.getContext("experimental-webgl2",r),this._gl&&(this._webGLVersion=2,this._gl.deleteQuery||(this._webGLVersion=1))}catch(e){}if(!this._gl){if(!h)throw new Error("The provided canvas is null or undefined.");try{this._gl=h.getContext("webgl",r)||h.getContext("experimental-webgl",r)}catch(e){throw new Error("WebGL not supported")}}if(!this._gl)throw new Error("WebGL not supported");this._onCanvasFocus=function(){u.onCanvasFocusObservable.notifyObservers(u)},this._onCanvasBlur=function(){u.onCanvasBlurObservable.notifyObservers(u)},h.addEventListener("focus",this._onCanvasFocus),h.addEventListener("blur",this._onCanvasBlur),this._onBlur=function(){u.disablePerformanceMonitorInBackground&&u._performanceMonitor.disable(),u._windowIsBackground=!0},this._onFocus=function(){u.disablePerformanceMonitorInBackground&&u._performanceMonitor.enable(),u._windowIsBackground=!1},this._onCanvasPointerOut=function(e){u.onCanvasPointerOutObservable.notifyObservers(e)},m.a.IsWindowObjectExist()&&(window.addEventListener("blur",this._onBlur),window.addEventListener("focus",this._onFocus)),h.addEventListener("pointerout",this._onCanvasPointerOut),this._doNotHandleContextLost||(this._onContextLost=function(e){e.preventDefault(),u._contextWasLost=!0,v.a.Warn("WebGL context lost."),u.onContextLostObservable.notifyObservers(u)},this._onContextRestored=function(){setTimeout(function(){u._initGLContext(),u._rebuildEffects(),u._rebuildInternalTextures(),u._rebuildBuffers(),u.wipeCaches(!0),v.a.Warn("WebGL context successfully restored."),u.onContextRestoredObservable.notifyObservers(u),u._contextWasLost=!1},0)},h.addEventListener("webglcontextlost",this._onContextLost,!1),h.addEventListener("webglcontextrestored",this._onContextRestored,!1)),r.doNotHandleTouchAction||this._disableTouchAction()}else{this._gl=t,this._renderingCanvas=this._gl.canvas,this._gl.renderbufferStorageMultisample&&(this._webGLVersion=2);var C=this._gl.getContextAttributes();C&&(r.stencil=C.stencil)}var M=m.a.IsWindowObjectExist()&&window.devicePixelRatio||1,O=r.limitDeviceRatio||M;this._hardwareScalingLevel=s?1/Math.min(O,M):1,this.resize(),this._isStencilEnable=!!r.stencil,this._initGLContext(),h&&(this._onFullscreenChange=function(){void 0!==document.fullscreen?u.isFullscreen=document.fullscreen:void 0!==document.mozFullScreen?u.isFullscreen=document.mozFullScreen:void 0!==document.webkitIsFullScreen?u.isFullscreen=document.webkitIsFullScreen:void 0!==document.msIsFullScreen&&(u.isFullscreen=document.msIsFullScreen),u.isFullscreen&&u._pointerLockRequested&&h&&(h.requestPointerLock=h.requestPointerLock||h.msRequestPointerLock||h.mozRequestPointerLock||h.webkitRequestPointerLock,h.requestPointerLock&&h.requestPointerLock())},document.addEventListener("fullscreenchange",this._onFullscreenChange,!1),document.addEventListener("mozfullscreenchange",this._onFullscreenChange,!1),document.addEventListener("webkitfullscreenchange",this._onFullscreenChange,!1),document.addEventListener("msfullscreenchange",this._onFullscreenChange,!1),this._onPointerLockChange=function(){u.isPointerLock=document.mozPointerLockElement===h||document.webkitPointerLockElement===h||document.msPointerLockElement===h||document.pointerLockElement===h},document.addEventListener("pointerlockchange",this._onPointerLockChange,!1),document.addEventListener("mspointerlockchange",this._onPointerLockChange,!1),document.addEventListener("mozpointerlockchange",this._onPointerLockChange,!1),document.addEventListener("webkitpointerlockchange",this._onPointerLockChange,!1),this._onVRDisplayPointerRestricted=function(){h&&h.requestPointerLock()},this._onVRDisplayPointerUnrestricted=function(){document.exitPointerLock()},m.a.IsWindowObjectExist()&&(window.addEventListener("vrdisplaypointerrestricted",this._onVRDisplayPointerRestricted,!1),window.addEventListener("vrdisplaypointerunrestricted",this._onVRDisplayPointerUnrestricted,!1))),!e.audioEngine&&r.audioEngine&&e.AudioEngineFactory&&(e.audioEngine=e.AudioEngineFactory(this.getRenderingCanvas()));for(var I=0;I<this._caps.maxVertexAttribs;I++)this._currentBufferPointers[I]=new T;this._linkTrackers(this._firstBoundInternalTextureTracker,this._lastBoundInternalTextureTracker),r.autoEnableWebVR&&this.initWebVR(),this._badOS=/iPad/i.test(navigator.userAgent)||/iPhone/i.test(navigator.userAgent),this._badDesktopOS=/^((?!chrome|android).)*safari/i.test(navigator.userAgent),console.log("Babylon.js v"+e.Version+" - "+this.description),this.enableOfflineSupport=void 0!==e.OfflineProviderFactory}}return Object.defineProperty(e,"Instances",{get:function(){return y.a.Instances},enumerable:!0,configurable:!0}),Object.defineProperty(e,"LastCreatedEngine",{get:function(){return y.a.LastCreatedEngine},enumerable:!0,configurable:!0}),Object.defineProperty(e,"LastCreatedScene",{get:function(){return y.a.LastCreatedScene},enumerable:!0,configurable:!0}),e.MarkAllMaterialsAsDirty=function(t,i){for(var r=0;r<e.Instances.length;r++)for(var n=e.Instances[r],o=0;o<n.scenes.length;o++)n.scenes[o].markAllMaterialsAsDirty(t,i)},Object.defineProperty(e,"Version",{get:function(){return"4.0.0-alpha.19"},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"description",{get:function(){var e="WebGL"+this.webGLVersion;return this._caps.parallelShaderCompile&&(e+=" - Parallel shader compilation"),e},enumerable:!0,configurable:!0}),Object.defineProperty(e,"ShadersRepository",{get:function(){return h.a.ShadersRepository},set:function(e){h.a.ShadersRepository=e},enumerable:!0,configurable:!0}),e.DefaultLoadingScreenFactory=function(e){throw"Import LoadingScreen or set DefaultLoadingScreenFactory on engine before using the loading screen"},Object.defineProperty(e.prototype,"isInVRExclusivePointerMode",{get:function(){return this._vrExclusivePointerMode},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"supportsUniformBuffers",{get:function(){return this.webGLVersion>1&&!this.disableUniformBuffers},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"needPOTTextures",{get:function(){return this._webGLVersion<2||this.forcePOTTextures},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"doNotHandleContextLost",{get:function(){return this._doNotHandleContextLost},set:function(e){this._doNotHandleContextLost=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"performanceMonitor",{get:function(){return this._performanceMonitor},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"texturesSupported",{get:function(){return this._texturesSupported},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"textureFormatInUse",{get:function(){return this._textureFormatInUse},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"currentViewport",{get:function(){return this._cachedViewport},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"emptyTexture",{get:function(){return this._emptyTexture||(this._emptyTexture=this.createRawTexture(new Uint8Array(4),1,1,e.TEXTUREFORMAT_RGBA,!1,!1,e.TEXTURE_NEAREST_SAMPLINGMODE)),this._emptyTexture},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"emptyTexture3D",{get:function(){return this._emptyTexture3D||(this._emptyTexture3D=this.createRawTexture3D(new Uint8Array(4),1,1,1,e.TEXTUREFORMAT_RGBA,!1,!1,e.TEXTURE_NEAREST_SAMPLINGMODE)),this._emptyTexture3D},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"emptyCubeTexture",{get:function(){if(!this._emptyCubeTexture){var t=new Uint8Array(4),i=[t,t,t,t,t,t];this._emptyCubeTexture=this.createRawCubeTexture(i,1,e.TEXTUREFORMAT_RGBA,e.TEXTURETYPE_UNSIGNED_INT,!1,!1,e.TEXTURE_NEAREST_SAMPLINGMODE)}return this._emptyCubeTexture},enumerable:!0,configurable:!0}),e.prototype._disableTouchAction=function(){this._renderingCanvas&&(this._renderingCanvas.setAttribute("touch-action","none"),this._renderingCanvas.style.touchAction="none",this._renderingCanvas.style.msTouchAction="none")},e.prototype._rebuildInternalTextures=function(){for(var e=0,t=this._internalTexturesCache.slice();e<t.length;e++){t[e]._rebuild()}},e.prototype._rebuildEffects=function(){for(var e in this._compiledEffects){this._compiledEffects[e]._prepareEffect()}h.a.ResetCache()},e.prototype.areAllEffectsReady=function(){for(var e in this._compiledEffects){if(!this._compiledEffects[e].isReady())return!1}return!0},e.prototype._rebuildBuffers=function(){for(var e=0,t=this.scenes;e<t.length;e++){var i=t[e];i.resetCachedMaterial(),i._rebuildGeometries(),i._rebuildTextures()}for(var r=0,n=this._uniformBuffers;r<n.length;r++){n[r]._rebuild()}},e.prototype._initGLContext=function(){this._caps=new A,this._caps.maxTexturesImageUnits=this._gl.getParameter(this._gl.MAX_TEXTURE_IMAGE_UNITS),this._caps.maxCombinedTexturesImageUnits=this._gl.getParameter(this._gl.MAX_COMBINED_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 e=this._gl.getExtension("WEBGL_debug_renderer_info");if(null!=e&&(this._glRenderer=this._gl.getParameter(e.UNMASKED_RENDERER_WEBGL),this._glVendor=this._gl.getParameter(e.UNMASKED_VENDOR_WEBGL)),this._glVendor||(this._glVendor="Unknown vendor"),this._glRenderer||(this._glRenderer="Unknown renderer"),this._gl.HALF_FLOAT_OES=36193,34842!==this._gl.RGBA16F&&(this._gl.RGBA16F=34842),34836!==this._gl.RGBA32F&&(this._gl.RGBA32F=34836),35056!==this._gl.DEPTH24_STENCIL8&&(this._gl.DEPTH24_STENCIL8=35056),this._caps.standardDerivatives=this._webGLVersion>1||null!==this._gl.getExtension("OES_standard_derivatives"),this._caps.astc=this._gl.getExtension("WEBGL_compressed_texture_astc")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_astc"),this._caps.s3tc=this._gl.getExtension("WEBGL_compressed_texture_s3tc")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc"),this._caps.pvrtc=this._gl.getExtension("WEBGL_compressed_texture_pvrtc")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),this._caps.etc1=this._gl.getExtension("WEBGL_compressed_texture_etc1")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_etc1"),this._caps.etc2=this._gl.getExtension("WEBGL_compressed_texture_etc")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_etc")||this._gl.getExtension("WEBGL_compressed_texture_es3_0"),this._caps.textureAnisotropicFilterExtension=this._gl.getExtension("EXT_texture_filter_anisotropic")||this._gl.getExtension("WEBKIT_EXT_texture_filter_anisotropic")||this._gl.getExtension("MOZ_EXT_texture_filter_anisotropic"),this._caps.maxAnisotropy=this._caps.textureAnisotropicFilterExtension?this._gl.getParameter(this._caps.textureAnisotropicFilterExtension.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0,this._caps.uintIndices=this._webGLVersion>1||null!==this._gl.getExtension("OES_element_index_uint"),this._caps.fragmentDepthSupported=this._webGLVersion>1||null!==this._gl.getExtension("EXT_frag_depth"),this._caps.highPrecisionShaderSupported=!1,this._caps.timerQuery=this._gl.getExtension("EXT_disjoint_timer_query_webgl2")||this._gl.getExtension("EXT_disjoint_timer_query"),this._caps.timerQuery&&(1===this._webGLVersion&&(this._gl.getQuery=this._caps.timerQuery.getQueryEXT.bind(this._caps.timerQuery)),this._caps.canUseTimestampForTimerQuery=this._gl.getQuery(this._caps.timerQuery.TIMESTAMP_EXT,this._caps.timerQuery.QUERY_COUNTER_BITS_EXT)>0),this._caps.colorBufferFloat=this._webGLVersion>1&&this._gl.getExtension("EXT_color_buffer_float"),this._caps.textureFloat=!!(this._webGLVersion>1||this._gl.getExtension("OES_texture_float")),this._caps.textureFloatLinearFiltering=!(!this._caps.textureFloat||!this._gl.getExtension("OES_texture_float_linear")),this._caps.textureFloatRender=!(!this._caps.textureFloat||!this._canRenderToFloatFramebuffer()),this._caps.textureHalfFloat=!!(this._webGLVersion>1||this._gl.getExtension("OES_texture_half_float")),this._caps.textureHalfFloatLinearFiltering=!!(this._webGLVersion>1||this._caps.textureHalfFloat&&this._gl.getExtension("OES_texture_half_float_linear")),this._webGLVersion>1&&(this._gl.HALF_FLOAT_OES=5131),this._caps.textureHalfFloatRender=this._caps.textureHalfFloat&&this._canRenderToHalfFloatFramebuffer(),this._caps.textureLOD=!!(this._webGLVersion>1||this._gl.getExtension("EXT_shader_texture_lod")),this._webGLVersion>1)this._caps.drawBuffersExtension=!0;else{var t=this._gl.getExtension("WEBGL_draw_buffers");if(null!==t){this._caps.drawBuffersExtension=!0,this._gl.drawBuffers=t.drawBuffersWEBGL.bind(t),this._gl.DRAW_FRAMEBUFFER=this._gl.FRAMEBUFFER;for(var i=0;i<16;i++)this._gl["COLOR_ATTACHMENT"+i+"_WEBGL"]=t["COLOR_ATTACHMENT"+i+"_WEBGL"]}else this._caps.drawBuffersExtension=!1}if(this._caps.parallelShaderCompile=this._gl.getExtension("KHR_parallel_shader_compile"),this._caps.parallelShaderCompile){var r=this._gl.getParameter(this._caps.parallelShaderCompile.MAX_SHADER_COMPILER_THREADS_KHR);this._caps.parallelShaderCompile.maxShaderCompilerThreadsKHR(r)}if(this._webGLVersion>1)this._caps.depthTextureExtension=!0;else{var n=this._gl.getExtension("WEBGL_depth_texture");null!=n&&(this._caps.depthTextureExtension=!0,this._gl.UNSIGNED_INT_24_8=n.UNSIGNED_INT_24_8_WEBGL)}if(this._webGLVersion>1)this._caps.vertexArrayObject=!0;else{var o=this._gl.getExtension("OES_vertex_array_object");null!=o?(this._caps.vertexArrayObject=!0,this._gl.createVertexArray=o.createVertexArrayOES.bind(o),this._gl.bindVertexArray=o.bindVertexArrayOES.bind(o),this._gl.deleteVertexArray=o.deleteVertexArrayOES.bind(o)):this._caps.vertexArrayObject=!1}if(this._webGLVersion>1)this._caps.instancedArrays=!0;else{var s=this._gl.getExtension("ANGLE_instanced_arrays");null!=s?(this._caps.instancedArrays=!0,this._gl.drawArraysInstanced=s.drawArraysInstancedANGLE.bind(s),this._gl.drawElementsInstanced=s.drawElementsInstancedANGLE.bind(s),this._gl.vertexAttribDivisor=s.vertexAttribDivisorANGLE.bind(s)):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 a=this._gl.getShaderPrecisionFormat(this._gl.VERTEX_SHADER,this._gl.HIGH_FLOAT),c=this._gl.getShaderPrecisionFormat(this._gl.FRAGMENT_SHADER,this._gl.HIGH_FLOAT);a&&c&&(this._caps.highPrecisionShaderSupported=0!==a.precision&&0!==c.precision)}this.setDepthBuffer(!0),this.setDepthFunctionToLessOrEqual(),this.setDepthWrite(!0),this._maxSimultaneousTextures=this._caps.maxCombinedTexturesImageUnits;for(var l=0;l<this._maxSimultaneousTextures;l++)this._nextFreeTextureSlots.push(l)},Object.defineProperty(e.prototype,"webGLVersion",{get:function(){return this._webGLVersion},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isStencilEnable",{get:function(){return this._isStencilEnable},enumerable:!0,configurable:!0}),e.prototype._prepareWorkingCanvas=function(){if(!this._workingCanvas){this._workingCanvas=document.createElement("canvas");var e=this._workingCanvas.getContext("2d");e&&(this._workingContext=e)}},e.prototype.resetTextureCache=function(){for(var e in this._boundTexturesCache)if(this._boundTexturesCache.hasOwnProperty(e)){var t=this._boundTexturesCache[e];t&&this._removeDesignatedSlot(t),this._boundTexturesCache[e]=null}if(!this.disableTextureBindingOptimization){this._nextFreeTextureSlots=[];for(var i=0;i<this._maxSimultaneousTextures;i++)this._nextFreeTextureSlots.push(i)}this._currentTextureChannel=-1},e.prototype.isDeterministicLockStep=function(){return this._deterministicLockstep},e.prototype.getLockstepMaxSteps=function(){return this._lockstepMaxSteps},e.prototype.getGlInfo=function(){return{vendor:this._glVendor,renderer:this._glRenderer,version:this._glVersion}},e.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)},e.prototype.getScreenAspectRatio=function(){return this.getRenderWidth(!0)/this.getRenderHeight(!0)},e.prototype.getRenderWidth=function(e){return void 0===e&&(e=!1),!e&&this._currentRenderTarget?this._currentRenderTarget.width:this._gl.drawingBufferWidth},e.prototype.getRenderHeight=function(e){return void 0===e&&(e=!1),!e&&this._currentRenderTarget?this._currentRenderTarget.height:this._gl.drawingBufferHeight},e.prototype.getRenderingCanvas=function(){return this._renderingCanvas},e.prototype.getRenderingCanvasClientRect=function(){return this._renderingCanvas?this._renderingCanvas.getBoundingClientRect():null},e.prototype.setHardwareScalingLevel=function(e){this._hardwareScalingLevel=e,this.resize()},e.prototype.getHardwareScalingLevel=function(){return this._hardwareScalingLevel},e.prototype.getLoadedTexturesCache=function(){return this._internalTexturesCache},e.prototype.getCaps=function(){return this._caps},e.prototype.getDepthFunction=function(){return this._depthCullingState.depthFunc},e.prototype.setDepthFunction=function(e){this._depthCullingState.depthFunc=e},e.prototype.setDepthFunctionToGreater=function(){this._depthCullingState.depthFunc=this._gl.GREATER},e.prototype.setDepthFunctionToGreaterOrEqual=function(){this._depthCullingState.depthFunc=this._gl.GEQUAL},e.prototype.setDepthFunctionToLess=function(){this._depthCullingState.depthFunc=this._gl.LESS},e.prototype.setDepthFunctionToLessOrEqual=function(){this._depthCullingState.depthFunc=this._gl.LEQUAL},e.prototype.getStencilBuffer=function(){return this._stencilState.stencilTest},e.prototype.setStencilBuffer=function(e){this._stencilState.stencilTest=e},e.prototype.getStencilMask=function(){return this._stencilState.stencilMask},e.prototype.setStencilMask=function(e){this._stencilState.stencilMask=e},e.prototype.getStencilFunction=function(){return this._stencilState.stencilFunc},e.prototype.getStencilFunctionReference=function(){return this._stencilState.stencilFuncRef},e.prototype.getStencilFunctionMask=function(){return this._stencilState.stencilFuncMask},e.prototype.setStencilFunction=function(e){this._stencilState.stencilFunc=e},e.prototype.setStencilFunctionReference=function(e){this._stencilState.stencilFuncRef=e},e.prototype.setStencilFunctionMask=function(e){this._stencilState.stencilFuncMask=e},e.prototype.getStencilOperationFail=function(){return this._stencilState.stencilOpStencilFail},e.prototype.getStencilOperationDepthFail=function(){return this._stencilState.stencilOpDepthFail},e.prototype.getStencilOperationPass=function(){return this._stencilState.stencilOpStencilDepthPass},e.prototype.setStencilOperationFail=function(e){this._stencilState.stencilOpStencilFail=e},e.prototype.setStencilOperationDepthFail=function(e){this._stencilState.stencilOpDepthFail=e},e.prototype.setStencilOperationPass=function(e){this._stencilState.stencilOpStencilDepthPass=e},e.prototype.setDitheringState=function(e){e?this._gl.enable(this._gl.DITHER):this._gl.disable(this._gl.DITHER)},e.prototype.setRasterizerState=function(e){e?this._gl.disable(this._gl.RASTERIZER_DISCARD):this._gl.enable(this._gl.RASTERIZER_DISCARD)},e.prototype.stopRenderLoop=function(e){if(e){var t=this._activeRenderLoops.indexOf(e);t>=0&&this._activeRenderLoops.splice(t,1)}else this._activeRenderLoops=[]},e.prototype._renderLoop=function(){if(!this._contextWasLost){var e=!0;if(!this.renderEvenInBackground&&this._windowIsBackground&&(e=!1),e){this.beginFrame();for(var t=0;t<this._activeRenderLoops.length;t++){(0,this._activeRenderLoops[t])()}this.endFrame()}}this._activeRenderLoops.length>0?this.customAnimationFrameRequester?(this.customAnimationFrameRequester.requestID=c.h.QueueNewFrame(this.customAnimationFrameRequester.renderFunction||this._bindedRenderFunction,this.customAnimationFrameRequester),this._frameHandler=this.customAnimationFrameRequester.requestID):this._vrDisplay&&this._vrDisplay.isPresenting?this._frameHandler=c.h.QueueNewFrame(this._bindedRenderFunction,this._vrDisplay):this._frameHandler=c.h.QueueNewFrame(this._bindedRenderFunction):this._renderingQueueLaunched=!1},e.prototype.runRenderLoop=function(e){-1===this._activeRenderLoops.indexOf(e)&&(this._activeRenderLoops.push(e),this._renderingQueueLaunched||(this._renderingQueueLaunched=!0,this._bindedRenderFunction=this._renderLoop.bind(this),this._frameHandler=c.h.QueueNewFrame(this._bindedRenderFunction)))},e.prototype.switchFullscreen=function(e){this.isFullscreen?c.h.ExitFullscreen():(this._pointerLockRequested=e,this._renderingCanvas&&c.h.RequestFullscreen(this._renderingCanvas))},e.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)},e.prototype.scissorClear=function(e,t,i,r,n){this.enableScissor(e,t,i,r),this.clear(n,!0,!0,!0),this.disableScissor()},e.prototype.enableScissor=function(e,t,i,r){var n=this._gl;n.enable(n.SCISSOR_TEST),n.scissor(e,t,i,r)},e.prototype.disableScissor=function(){var e=this._gl;e.disable(e.SCISSOR_TEST)},e.prototype._viewport=function(e,t,i,r){e===this._viewportCached.x&&t===this._viewportCached.y&&i===this._viewportCached.z&&r===this._viewportCached.w||(this._viewportCached.x=e,this._viewportCached.y=t,this._viewportCached.z=i,this._viewportCached.w=r,this._gl.viewport(e,t,i,r))},e.prototype.setViewport=function(e,t,i){var r=t||this.getRenderWidth(),n=i||this.getRenderHeight(),o=e.x||0,s=e.y||0;this._cachedViewport=e,this._viewport(o*r,s*n,r*e.width,n*e.height)},e.prototype.setDirectViewport=function(e,t,i,r){var n=this._cachedViewport;return this._cachedViewport=null,this._viewport(e,t,i,r),n},e.prototype.beginFrame=function(){this.onBeginFrameObservable.notifyObservers(this),this._measureFps()},e.prototype.endFrame=function(){this._badOS&&this.flushFramebuffer(),this._vrDisplay&&this._vrDisplay.isPresenting&&this._vrDisplay.submitFrame(),this.onEndFrameObservable.notifyObservers(this)},e.prototype.resize=function(){if(!this._vrDisplay||!this._vrDisplay.isPresenting){var e=this._renderingCanvas?this._renderingCanvas.clientWidth:window.innerWidth,t=this._renderingCanvas?this._renderingCanvas.clientHeight:window.innerHeight;this.setSize(e/this._hardwareScalingLevel,t/this._hardwareScalingLevel)}},e.prototype.setSize=function(e,t){if(this._renderingCanvas&&(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++){r.cameras[n]._currentRenderId=0}this.onResizeObservable.hasObservers&&this.onResizeObservable.notifyObservers(this)}},e.prototype.isVRDevicePresent=function(){return!!this._vrDisplay},e.prototype.getVRDevice=function(){return this._vrDisplay},e.prototype.initWebVR=function(){return this.initWebVRAsync(),this.onVRDisplayChangedObservable},e.prototype.initWebVRAsync=function(){var e=this,t=function(){var t={vrDisplay:e._vrDisplay,vrSupported:e._vrSupported};e.onVRDisplayChangedObservable.notifyObservers(t),e._webVRInitPromise=new Promise(function(e){e(t)})};return this._onVrDisplayConnect||(this._onVrDisplayConnect=function(i){e._vrDisplay=i.display,t()},this._onVrDisplayDisconnect=function(){e._vrDisplay.cancelAnimationFrame(e._frameHandler),e._vrDisplay=void 0,e._frameHandler=c.h.QueueNewFrame(e._bindedRenderFunction),t()},this._onVrDisplayPresentChange=function(){e._vrExclusivePointerMode=e._vrDisplay&&e._vrDisplay.isPresenting},window.addEventListener("vrdisplayconnect",this._onVrDisplayConnect),window.addEventListener("vrdisplaydisconnect",this._onVrDisplayDisconnect),window.addEventListener("vrdisplaypresentchange",this._onVrDisplayPresentChange)),this._webVRInitPromise=this._webVRInitPromise||this._getVRDisplaysAsync(),this._webVRInitPromise.then(t),this._webVRInitPromise},e.prototype.enableVR=function(){var e=this;if(this._vrDisplay&&!this._vrDisplay.isPresenting){this.onVRRequestPresentStart.notifyObservers(this),this._vrDisplay.requestPresent([{source:this.getRenderingCanvas()}]).then(function(){e.onVRRequestPresentComplete.notifyObservers(!0),e._onVRFullScreenTriggered()}).catch(function(){e.onVRRequestPresentComplete.notifyObservers(!1)})}},e.prototype.disableVR=function(){this._vrDisplay&&this._vrDisplay.isPresenting&&this._vrDisplay.exitPresent().then(this._onVRFullScreenTriggered).catch(this._onVRFullScreenTriggered)},e.prototype._getVRDisplaysAsync=function(){var e=this;return new Promise(function(t){navigator.getVRDisplays?navigator.getVRDisplays().then(function(i){e._vrSupported=!0,e._vrDisplay=i[0],t({vrDisplay:e._vrDisplay,vrSupported:e._vrSupported})}):(e._vrDisplay=void 0,e._vrSupported=!1,t({vrDisplay:e._vrDisplay,vrSupported:e._vrSupported}))})},e.prototype.bindFramebuffer=function(e,t,i,r,n,o,s){void 0===s&&(s=0),this._currentRenderTarget&&this.unBindFramebuffer(this._currentRenderTarget),this._currentRenderTarget=e,this.bindUnboundFramebuffer(e._MSAAFramebuffer?e._MSAAFramebuffer:e._framebuffer);var a=this._gl;e.isCube&&(void 0===t&&(t=0),a.framebufferTexture2D(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_CUBE_MAP_POSITIVE_X+t,e._webGLTexture,s),o&&(o._generateStencilBuffer?a.framebufferTexture2D(a.FRAMEBUFFER,a.DEPTH_STENCIL_ATTACHMENT,a.TEXTURE_CUBE_MAP_POSITIVE_X+t,o._webGLTexture,s):a.framebufferTexture2D(a.FRAMEBUFFER,a.DEPTH_ATTACHMENT,a.TEXTURE_CUBE_MAP_POSITIVE_X+t,o._webGLTexture,s))),this._cachedViewport&&!n?this.setViewport(this._cachedViewport,i,r):(i||(i=e.width,s&&(i/=Math.pow(2,s))),r||(r=e.height,s&&(r/=Math.pow(2,s))),this._viewport(0,0,i,r)),this.wipeCaches()},e.prototype.bindUnboundFramebuffer=function(e){this._currentFramebuffer!==e&&(this._gl.bindFramebuffer(this._gl.FRAMEBUFFER,e),this._currentFramebuffer=e)},e.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||e.isCube||(this._bindTextureDirectly(r.TEXTURE_2D,e,!0),r.generateMipmap(r.TEXTURE_2D),this._bindTextureDirectly(r.TEXTURE_2D,null)),i&&(e._MSAAFramebuffer&&this.bindUnboundFramebuffer(e._framebuffer),i()),this.bindUnboundFramebuffer(null)},e.prototype.unBindMultiColorAttachmentFramebuffer=function(e,t,i){void 0===t&&(t=!1),this._currentRenderTarget=null;var r=this._gl;if(e[0]._MSAAFramebuffer){r.bindFramebuffer(r.READ_FRAMEBUFFER,e[0]._MSAAFramebuffer),r.bindFramebuffer(r.DRAW_FRAMEBUFFER,e[0]._framebuffer);var n=e[0]._attachments;n||(n=new Array(e.length),e[0]._attachments=n);for(var o=0;o<e.length;o++){for(var s=e[o],a=0;a<n.length;a++)n[a]=r.NONE;n[o]=r[this.webGLVersion>1?"COLOR_ATTACHMENT"+o:"COLOR_ATTACHMENT"+o+"_WEBGL"],r.readBuffer(n[o]),r.drawBuffers(n),r.blitFramebuffer(0,0,s.width,s.height,0,0,s.width,s.height,r.COLOR_BUFFER_BIT,r.NEAREST)}for(o=0;o<n.length;o++)n[o]=r[this.webGLVersion>1?"COLOR_ATTACHMENT"+o:"COLOR_ATTACHMENT"+o+"_WEBGL"];r.drawBuffers(n)}for(o=0;o<e.length;o++){!(s=e[o]).generateMipMaps||t||s.isCube||(this._bindTextureDirectly(r.TEXTURE_2D,s),r.generateMipmap(r.TEXTURE_2D),this._bindTextureDirectly(r.TEXTURE_2D,null))}i&&(e[0]._MSAAFramebuffer&&this.bindUnboundFramebuffer(e[0]._framebuffer),i()),this.bindUnboundFramebuffer(null)},e.prototype.generateMipMapsForCubemap=function(e){if(e.generateMipMaps){var t=this._gl;this._bindTextureDirectly(t.TEXTURE_CUBE_MAP,e,!0),t.generateMipmap(t.TEXTURE_CUBE_MAP),this._bindTextureDirectly(t.TEXTURE_CUBE_MAP,null)}},e.prototype.flushFramebuffer=function(){this._gl.flush()},e.prototype.restoreDefaultFramebuffer=function(){this._currentRenderTarget?this.unBindFramebuffer(this._currentRenderTarget):this.bindUnboundFramebuffer(null),this._cachedViewport&&this.setViewport(this._cachedViewport),this.wipeCaches()},e.prototype.createUniformBuffer=function(e){var t=this._gl.createBuffer();if(!t)throw new Error("Unable to create uniform buffer");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},e.prototype.createDynamicUniformBuffer=function(e){var t=this._gl.createBuffer();if(!t)throw new Error("Unable to create dynamic uniform buffer");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},e.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)},e.prototype._resetVertexBufferBinding=function(){this.bindArrayBuffer(null),this._cachedVertexBuffers=null},e.prototype.createVertexBuffer=function(e){var t=this._gl.createBuffer();if(!t)throw new Error("Unable to create vertex buffer");return this.bindArrayBuffer(t),e instanceof Array?this._gl.bufferData(this._gl.ARRAY_BUFFER,new Float32Array(e),this._gl.STATIC_DRAW):this._gl.bufferData(this._gl.ARRAY_BUFFER,e,this._gl.STATIC_DRAW),this._resetVertexBufferBinding(),t.references=1,t},e.prototype.createDynamicVertexBuffer=function(e){var t=this._gl.createBuffer();if(!t)throw new Error("Unable to create dynamic vertex buffer");return this.bindArrayBuffer(t),e instanceof Array?this._gl.bufferData(this._gl.ARRAY_BUFFER,new Float32Array(e),this._gl.DYNAMIC_DRAW):this._gl.bufferData(this._gl.ARRAY_BUFFER,e,this._gl.DYNAMIC_DRAW),this._resetVertexBufferBinding(),t.references=1,t},e.prototype.updateDynamicIndexBuffer=function(e,t,i){var r;void 0===i&&(i=0),this._currentBoundBuffer[this._gl.ELEMENT_ARRAY_BUFFER]=null,this.bindIndexBuffer(e),r=t instanceof Uint16Array||t instanceof Uint32Array?t:e.is32Bits?new Uint32Array(t):new Uint16Array(t),this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER,r,this._gl.DYNAMIC_DRAW),this._resetIndexBufferBinding()},e.prototype.updateDynamicVertexBuffer=function(e,t,i,r){this.bindArrayBuffer(e),void 0===i&&(i=0),void 0===r?t instanceof Array?this._gl.bufferSubData(this._gl.ARRAY_BUFFER,i,new Float32Array(t)):this._gl.bufferSubData(this._gl.ARRAY_BUFFER,i,t):t instanceof Array?this._gl.bufferSubData(this._gl.ARRAY_BUFFER,0,new Float32Array(t).subarray(i,i+r)):(t=t instanceof ArrayBuffer?new Uint8Array(t,i,r):new Uint8Array(t.buffer,t.byteOffset+i,r),this._gl.bufferSubData(this._gl.ARRAY_BUFFER,0,t)),this._resetVertexBufferBinding()},e.prototype._resetIndexBufferBinding=function(){this.bindIndexBuffer(null),this._cachedIndexBuffer=null},e.prototype.createIndexBuffer=function(e,t){var i,r=this._gl.createBuffer();if(!r)throw new Error("Unable to create index buffer");this.bindIndexBuffer(r);var n=!1;if(e instanceof Uint16Array)i=e;else if(this._caps.uintIndices)if(e instanceof Uint32Array)i=e,n=!0;else{for(var o=0;o<e.length;o++)if(e[o]>65535){n=!0;break}i=n?new Uint32Array(e):new Uint16Array(e)}else i=new Uint16Array(e);return this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER,i,t?this._gl.DYNAMIC_DRAW:this._gl.STATIC_DRAW),this._resetIndexBufferBinding(),r.references=1,r.is32Bits=n,r},e.prototype.bindArrayBuffer=function(e){this._vaoRecordInProgress||this._unbindVertexArrayObject(),this.bindBuffer(e,this._gl.ARRAY_BUFFER)},e.prototype.bindUniformBuffer=function(e){this._gl.bindBuffer(this._gl.UNIFORM_BUFFER,e)},e.prototype.bindUniformBufferBase=function(e,t){this._gl.bindBufferBase(this._gl.UNIFORM_BUFFER,t,e)},e.prototype.bindUniformBlock=function(e,t,i){var r=this._gl.getUniformBlockIndex(e,t);this._gl.uniformBlockBinding(e,r,i)},e.prototype.bindIndexBuffer=function(e){this._vaoRecordInProgress||this._unbindVertexArrayObject(),this.bindBuffer(e,this._gl.ELEMENT_ARRAY_BUFFER)},e.prototype.bindBuffer=function(e,t){(this._vaoRecordInProgress||this._currentBoundBuffer[t]!==e)&&(this._gl.bindBuffer(t,e),this._currentBoundBuffer[t]=e)},e.prototype.updateArrayBuffer=function(e){this._gl.bufferSubData(this._gl.ARRAY_BUFFER,0,e)},e.prototype._vertexAttribPointer=function(e,t,i,r,n,o,s){var a=this._currentBufferPointers[t],c=!1;a.active?(a.buffer!==e&&(a.buffer=e,c=!0),a.size!==i&&(a.size=i,c=!0),a.type!==r&&(a.type=r,c=!0),a.normalized!==n&&(a.normalized=n,c=!0),a.stride!==o&&(a.stride=o,c=!0),a.offset!==s&&(a.offset=s,c=!0)):(c=!0,a.active=!0,a.index=t,a.size=i,a.type=r,a.normalized=n,a.stride=o,a.offset=s,a.buffer=e),(c||this._vaoRecordInProgress)&&(this.bindArrayBuffer(e),this._gl.vertexAttribPointer(t,i,r,n,o,s))},e.prototype._bindIndexBufferWithCache=function(e){null!=e&&this._cachedIndexBuffer!==e&&(this._cachedIndexBuffer=e,this.bindIndexBuffer(e),this._uintIndicesCurrentlySet=e.is32Bits)},e.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 o=e[i[r]];if(!o)continue;this._gl.enableVertexAttribArray(n),this._vaoRecordInProgress||(this._vertexAttribArraysEnabled[n]=!0);var s=o.getBuffer();s&&(this._vertexAttribPointer(s,n,o.getSize(),o.type,o.normalized,o.byteStride,o.byteOffset),o.getIsInstanced()&&(this._gl.vertexAttribDivisor(n,o.getInstanceDivisor()),this._vaoRecordInProgress||(this._currentInstanceLocations.push(n),this._currentInstanceBuffers.push(s))))}}},e.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},e.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)},e.prototype.bindBuffersDirectly=function(e,t,i,r,n){if(this._cachedVertexBuffers!==e||this._cachedEffectForVertexBuffers!==n){this._cachedVertexBuffers=e,this._cachedEffectForVertexBuffers=n;var o=n.getAttributesCount();this._unbindVertexArrayObject(),this.unbindAllAttributes();for(var s=0,a=0;a<o;a++)if(a<i.length){var c=n.getAttributeLocation(a);c>=0&&(this._gl.enableVertexAttribArray(c),this._vertexAttribArraysEnabled[c]=!0,this._vertexAttribPointer(e,c,i[a],this._gl.FLOAT,!1,r,s)),s+=4*i[a]}}this._bindIndexBufferWithCache(t)},e.prototype._unbindVertexArrayObject=function(){this._cachedVertexArrayObject&&(this._cachedVertexArrayObject=null,this._gl.bindVertexArray(null))},e.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)},e.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},e.prototype.releaseVertexArrayObject=function(e){this._gl.deleteVertexArray(e)},e.prototype._releaseBuffer=function(e){return e.references--,0===e.references&&(this._gl.deleteBuffer(e),!0)},e.prototype.createInstancesBuffer=function(e){var t=this._gl.createBuffer();if(!t)throw new Error("Unable to create instance buffer");return t.capacity=e,this.bindArrayBuffer(t),this._gl.bufferData(this._gl.ARRAY_BUFFER,e,this._gl.DYNAMIC_DRAW),t},e.prototype.deleteInstancesBuffer=function(e){this._gl.deleteBuffer(e)},e.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++){r+=4*(o=i[n]).attributeSize}for(n=0;n<i.length;n++){var o=i[n];this._vertexAttribArraysEnabled[o.index]||(this._gl.enableVertexAttribArray(o.index),this._vertexAttribArraysEnabled[o.index]=!0),this._vertexAttribPointer(e,o.index,o.attributeSize,o.attribyteType||this._gl.FLOAT,o.normalized||!1,r,o.offset),this._gl.vertexAttribDivisor(o.index,1),this._currentInstanceLocations.push(o.index),this._currentInstanceBuffers.push(e)}}else for(var s=0;s<4;s++){var a=i[s];this._vertexAttribArraysEnabled[a]||(this._gl.enableVertexAttribArray(a),this._vertexAttribArraysEnabled[a]=!0),this._vertexAttribPointer(e,a,4,this._gl.FLOAT,!1,64,16*s),this._gl.vertexAttribDivisor(a,1),this._currentInstanceLocations.push(a),this._currentInstanceBuffers.push(e)}},e.prototype.applyStates=function(){this._depthCullingState.apply(this._gl),this._stencilState.apply(this._gl),this._alphaState.apply(this._gl)},e.prototype.draw=function(e,t,i,r){this.drawElementsType(e?d.a.TriangleFillMode:d.a.WireFrameFillMode,t,i,r)},e.prototype.drawPointClouds=function(e,t,i){this.drawArraysType(d.a.PointFillMode,e,t,i)},e.prototype.drawUnIndexed=function(e,t,i,r){this.drawArraysType(e?d.a.TriangleFillMode:d.a.WireFrameFillMode,t,i,r)},e.prototype.drawElementsType=function(e,t,i,r){this.applyStates(),this._drawCalls.addCount(1,!1);var n=this._drawMode(e),o=this._uintIndicesCurrentlySet?this._gl.UNSIGNED_INT:this._gl.UNSIGNED_SHORT,s=this._uintIndicesCurrentlySet?4:2;r?this._gl.drawElementsInstanced(n,i,o,t*s,r):this._gl.drawElements(n,i,o,t*s)},e.prototype.drawArraysType=function(e,t,i,r){this.applyStates(),this._drawCalls.addCount(1,!1);var n=this._drawMode(e);r?this._gl.drawArraysInstanced(n,t,i,r):this._gl.drawArrays(n,t,i)},e.prototype._drawMode=function(e){switch(e){case d.a.TriangleFillMode:return this._gl.TRIANGLES;case d.a.PointFillMode:return this._gl.POINTS;case d.a.WireFrameFillMode:return this._gl.LINES;case d.a.PointListDrawMode:return this._gl.POINTS;case d.a.LineListDrawMode:return this._gl.LINES;case d.a.LineLoopDrawMode:return this._gl.LINE_LOOP;case d.a.LineStripDrawMode:return this._gl.LINE_STRIP;case d.a.TriangleStripDrawMode:return this._gl.TRIANGLE_STRIP;case d.a.TriangleFanDrawMode:return this._gl.TRIANGLE_FAN;default:return this._gl.TRIANGLES}},e.prototype._releaseEffect=function(e){this._compiledEffects[e._key]&&(delete this._compiledEffects[e._key],this._deleteProgram(e.getProgram()))},e.prototype._deleteProgram=function(e){e&&(e.__SPECTOR_rebuildProgram=null,e.transformFeedback&&(this.deleteTransformFeedback(e.transformFeedback),e.transformFeedback=null),this._gl.deleteProgram(e))},e.prototype.createEffect=function(e,t,i,r,n,o,s,a,c){var l=(e.vertexElement||e.vertex||e)+"+"+(e.fragmentElement||e.fragment||e)+"@"+(n||t.defines);if(this._compiledEffects[l]){var u=this._compiledEffects[l];return s&&u.isReady()&&s(u),u}var d=new h.a(e,t,i,r,this,n,o,s,a,c);return d._key=l,this._compiledEffects[l]=d,d},e.prototype._compileShader=function(e,t,i,r){return this._compileRawShader(r+(i?i+"\n":"")+e,t)},e.prototype._compileRawShader=function(e,t){var i=this._gl,r=i.createShader("vertex"===t?i.VERTEX_SHADER:i.FRAGMENT_SHADER);if(!r)throw new Error("Something went wrong while compile the shader.");if(i.shaderSource(r,e),i.compileShader(r),!i.getShaderParameter(r,i.COMPILE_STATUS)){var n=i.getShaderInfoLog(r);if(n)throw new Error(n)}return r},e.prototype.createRawShaderProgram=function(e,t,i,r){void 0===r&&(r=null),i=i||this._gl;var n=this._compileRawShader(e,"vertex"),o=this._compileRawShader(t,"fragment");return this._createShaderProgram(n,o,i,r)},e.prototype.createShaderProgram=function(e,t,i,r,n){void 0===n&&(n=null),r=r||this._gl,this.onBeforeShaderCompilationObservable.notifyObservers(this);var o=this._webGLVersion>1?"#version 300 es\n#define WEBGL2 \n":"",s=this._compileShader(e,"vertex",i,o),a=this._compileShader(t,"fragment",i,o),c=this._createShaderProgram(s,a,r,n);return this.onAfterShaderCompilationObservable.notifyObservers(this),c},e.prototype._createShaderProgram=function(e,t,i,r){void 0===r&&(r=null);var n=i.createProgram();if(!n)throw new Error("Unable to create program");if(i.attachShader(n,e),i.attachShader(n,t),this.webGLVersion>1&&r){var o=this.createTransformFeedback();this.bindTransformFeedback(o),this.setTranformFeedbackVaryings(n,r),n.transformFeedback=o}return i.linkProgram(n),this.webGLVersion>1&&r&&this.bindTransformFeedback(null),n.context=i,n.vertexShader=e,n.fragmentShader=t,this._caps.parallelShaderCompile?n.isParallelCompiled=!0:this._finalizeProgram(n),n},e.prototype._finalizeProgram=function(e){var t,i=e.context,r=e.vertexShader,n=e.fragmentShader;if(!i.getProgramParameter(e,i.LINK_STATUS)&&(t=i.getProgramInfoLog(e)))throw new Error(t);if(this.validateShaderPrograms&&(i.validateProgram(e),!i.getProgramParameter(e,i.VALIDATE_STATUS)&&(t=i.getProgramInfoLog(e))))throw new Error(t);i.deleteShader(r),i.deleteShader(n),e.context=void 0,e.vertexShader=void 0,e.fragmentShader=void 0,e.onCompiled&&(e.onCompiled(),e.onCompiled=void 0)},e.prototype._isProgramCompiled=function(e){return!e.isParallelCompiled||!!this._gl.getProgramParameter(e,this._caps.parallelShaderCompile.COMPLETION_STATUS_KHR)&&(this._finalizeProgram(e),!0)},e.prototype._executeWhenProgramIsCompiled=function(e,t){e.isParallelCompiled?e.onCompiled=t:t()},e.prototype.getUniforms=function(e,t){for(var i=new Array,r=0;r<t.length;r++)i.push(this._gl.getUniformLocation(e,t[r]));return i},e.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},e.prototype.enableEffect=function(e){e&&e!==this._currentEffect&&(this.bindSamplers(e),this._currentEffect=e,e.onBind&&e.onBind(e),e._onBindObservable&&e._onBindObservable.notifyObservers(e))},e.prototype.setIntArray=function(e,t){e&&this._gl.uniform1iv(e,t)},e.prototype.setIntArray2=function(e,t){e&&t.length%2==0&&this._gl.uniform2iv(e,t)},e.prototype.setIntArray3=function(e,t){e&&t.length%3==0&&this._gl.uniform3iv(e,t)},e.prototype.setIntArray4=function(e,t){e&&t.length%4==0&&this._gl.uniform4iv(e,t)},e.prototype.setFloatArray=function(e,t){e&&this._gl.uniform1fv(e,t)},e.prototype.setFloatArray2=function(e,t){e&&t.length%2==0&&this._gl.uniform2fv(e,t)},e.prototype.setFloatArray3=function(e,t){e&&t.length%3==0&&this._gl.uniform3fv(e,t)},e.prototype.setFloatArray4=function(e,t){e&&t.length%4==0&&this._gl.uniform4fv(e,t)},e.prototype.setArray=function(e,t){e&&this._gl.uniform1fv(e,t)},e.prototype.setArray2=function(e,t){e&&t.length%2==0&&this._gl.uniform2fv(e,t)},e.prototype.setArray3=function(e,t){e&&t.length%3==0&&this._gl.uniform3fv(e,t)},e.prototype.setArray4=function(e,t){e&&t.length%4==0&&this._gl.uniform4fv(e,t)},e.prototype.setMatrices=function(e,t){e&&this._gl.uniformMatrix4fv(e,!1,t)},e.prototype.setMatrix=function(e,t){e&&this._gl.uniformMatrix4fv(e,!1,t.toArray())},e.prototype.setMatrix3x3=function(e,t){e&&this._gl.uniformMatrix3fv(e,!1,t)},e.prototype.setMatrix2x2=function(e,t){e&&this._gl.uniformMatrix2fv(e,!1,t)},e.prototype.setInt=function(e,t){e&&this._gl.uniform1i(e,t)},e.prototype.setFloat=function(e,t){e&&this._gl.uniform1f(e,t)},e.prototype.setFloat2=function(e,t,i){e&&this._gl.uniform2f(e,t,i)},e.prototype.setFloat3=function(e,t,i,r){e&&this._gl.uniform3f(e,t,i,r)},e.prototype.setBool=function(e,t){e&&this._gl.uniform1i(e,t)},e.prototype.setFloat4=function(e,t,i,r,n){e&&this._gl.uniform4f(e,t,i,r,n)},e.prototype.setColor3=function(e,t){e&&this._gl.uniform3f(e,t.r,t.g,t.b)},e.prototype.setColor4=function(e,t,i){e&&this._gl.uniform4f(e,t.r,t.g,t.b,i)},e.prototype.setDirectColor4=function(e,t){e&&this._gl.uniform4f(e,t.r,t.g,t.b,t.a)},e.prototype.setState=function(e,t,i,r){void 0===t&&(t=0),void 0===r&&(r=!1),(this._depthCullingState.cull!==e||i)&&(this._depthCullingState.cull=e);var n=this.cullBackFaces?this._gl.BACK:this._gl.FRONT;(this._depthCullingState.cullFace!==n||i)&&(this._depthCullingState.cullFace=n),this.setZOffset(t);var o=r?this._gl.CW:this._gl.CCW;(this._depthCullingState.frontFace!==o||i)&&(this._depthCullingState.frontFace=o)},e.prototype.setZOffset=function(e){this._depthCullingState.zOffset=e},e.prototype.getZOffset=function(){return this._depthCullingState.zOffset},e.prototype.setDepthBuffer=function(e){this._depthCullingState.depthTest=e},e.prototype.getDepthWrite=function(){return this._depthCullingState.depthMask},e.prototype.setDepthWrite=function(e){this._depthCullingState.depthMask=e},e.prototype.setColorWrite=function(e){this._gl.colorMask(e,e,e,e),this._colorWrite=e},e.prototype.getColorWrite=function(){return this._colorWrite},e.prototype.setAlphaConstants=function(e,t,i,r){this._alphaState.setAlphaBlendConstants(e,t,i,r)},e.prototype.setAlphaMode=function(t,i){if(void 0===i&&(i=!1),this._alphaMode!==t){switch(t){case e.ALPHA_DISABLE:this._alphaState.alphaBlend=!1;break;case e.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 e.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 e.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 e.ALPHA_ONEONE:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE,this._gl.ONE,this._gl.ZERO,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case e.ALPHA_ADD:this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA,this._gl.ONE,this._gl.ZERO,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case e.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 e.ALPHA_MULTIPLY:this._alphaState.setAlphaBlendFunctionParameters(this._gl.DST_COLOR,this._gl.ZERO,this._gl.ONE,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case e.ALPHA_MAXIMIZED:this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA,this._gl.ONE_MINUS_SRC_COLOR,this._gl.ONE,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case e.ALPHA_INTERPOLATE:this._alphaState.setAlphaBlendFunctionParameters(this._gl.CONSTANT_COLOR,this._gl.ONE_MINUS_CONSTANT_COLOR,this._gl.CONSTANT_ALPHA,this._gl.ONE_MINUS_CONSTANT_ALPHA),this._alphaState.alphaBlend=!0;break;case e.ALPHA_SCREENMODE:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE,this._gl.ONE_MINUS_SRC_COLOR,this._gl.ONE,this._gl.ONE_MINUS_SRC_ALPHA),this._alphaState.alphaBlend=!0}i||this.setDepthWrite(t===e.ALPHA_DISABLE),this._alphaMode=t}},e.prototype.getAlphaMode=function(){return this._alphaMode},e.prototype.clearInternalTexturesCache=function(){this._internalTexturesCache=[]},e.prototype.wipeCaches=function(e){this.preventCacheWipeBetweenFrames&&!e||(this._currentEffect=null,this._viewportCached.x=0,this._viewportCached.y=0,this._viewportCached.z=0,this._viewportCached.w=0,e&&(this.resetTextureCache(),this._currentProgram=null,this._stencilState.reset(),this._depthCullingState.reset(),this.setDepthFunctionToLessOrEqual(),this._alphaState.reset(),this._unpackFlipYCached=null),this._resetVertexBufferBinding(),this._cachedIndexBuffer=null,this._cachedEffectForVertexBuffers=null,this._unbindVertexArrayObject(),this.bindIndexBuffer(null))},e.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,null},e.prototype._getSamplingParameters=function(t,i){var r=this._gl,n=r.NEAREST,o=r.NEAREST;switch(t){case e.TEXTURE_BILINEAR_SAMPLINGMODE:n=r.LINEAR,o=i?r.LINEAR_MIPMAP_NEAREST:r.LINEAR;break;case e.TEXTURE_TRILINEAR_SAMPLINGMODE:n=r.LINEAR,o=i?r.LINEAR_MIPMAP_LINEAR:r.LINEAR;break;case e.TEXTURE_NEAREST_SAMPLINGMODE:n=r.NEAREST,o=i?r.NEAREST_MIPMAP_LINEAR:r.NEAREST;break;case e.TEXTURE_NEAREST_NEAREST_MIPNEAREST:n=r.NEAREST,o=i?r.NEAREST_MIPMAP_NEAREST:r.NEAREST;break;case e.TEXTURE_NEAREST_LINEAR_MIPNEAREST:n=r.NEAREST,o=i?r.LINEAR_MIPMAP_NEAREST:r.LINEAR;break;case e.TEXTURE_NEAREST_LINEAR_MIPLINEAR:n=r.NEAREST,o=i?r.LINEAR_MIPMAP_LINEAR:r.LINEAR;break;case e.TEXTURE_NEAREST_LINEAR:n=r.NEAREST,o=r.LINEAR;break;case e.TEXTURE_NEAREST_NEAREST:n=r.NEAREST,o=r.NEAREST;break;case e.TEXTURE_LINEAR_NEAREST_MIPNEAREST:n=r.LINEAR,o=i?r.NEAREST_MIPMAP_NEAREST:r.NEAREST;break;case e.TEXTURE_LINEAR_NEAREST_MIPLINEAR:n=r.LINEAR,o=i?r.NEAREST_MIPMAP_LINEAR:r.NEAREST;break;case e.TEXTURE_LINEAR_LINEAR:n=r.LINEAR,o=r.LINEAR;break;case e.TEXTURE_LINEAR_NEAREST:n=r.LINEAR,o=r.NEAREST}return{min:o,mag:n}},e.prototype._partialLoadImg=function(e,t,i,r,n,o){var s;void 0===o&&(o=null);s=c.h.LoadImage(e,function(){i[t]=s,i._internalCount++,r&&r._removePendingData(s),6===i._internalCount&&n(i)},function(e,t){r&&r._removePendingData(s),o&&o(e,t)},r?r.offlineProvider:null),r&&r._addPendingData(s)},e.prototype._cascadeLoadImgs=function(e,t,i,r){void 0===r&&(r=null);var n=[];n._internalCount=0;for(var o=0;o<6;o++)this._partialLoadImg(i[o],o,n,e,t,r)},e.prototype._createTexture=function(){var e=this._gl.createTexture();if(!e)throw new Error("Unable to create texture");return e},e.prototype.createTexture=function(t,i,r,n,o,s,a,l,u,h,d,f){var _=this;void 0===o&&(o=e.TEXTURE_TRILINEAR_SAMPLINGMODE),void 0===s&&(s=null),void 0===a&&(a=null),void 0===l&&(l=null),void 0===u&&(u=null),void 0===h&&(h=null),void 0===d&&(d=null),void 0===f&&(f=[]);for(var g=String(t),m="data:"===g.substr(0,5),v="blob:"===g.substr(0,5),y=m&&-1!==g.indexOf(";base64,"),b=u||new p.a(this,p.a.DATASOURCE_URL),T=g.lastIndexOf("."),E=d||(T>-1?g.substring(T).toLowerCase():""),x=null,A=0,P=e._TextureLoaders;A<P.length;A++){var R=P[A];if(-1===f.indexOf(R)&&R.canLoad(E,this._textureFormatInUse,u,y,!!l)){x=R;break}}x&&(g=x.transformUrl(g,this._textureFormatInUse)),n&&n._addPendingData(b),b.url=g,b.generateMipMaps=!i,b.samplingMode=o,b.invertY=r,this._doNotHandleContextLost||(b._buffer=l);var S=null;s&&!u&&(S=b.onLoadedObservable.add(s)),u||this._internalTexturesCache.push(b);var C=function(e,r){n&&n._removePendingData(b);var s=!1;x&&(x.getFallbackTextureUrl(g,_._textureFormatInUse)&&(s=!0,f.push(x),c.h.Warn(x.constructor.name+" failed when trying to load "+b.url+", falling back to the next supported loader"),_.createTexture(t,i,b.invertY,n,o,null,null,l,b,void 0,void 0,f)));s||(S&&b.onLoadedObservable.remove(S),c.h.UseFallbackTexture&&_.createTexture(c.h.fallbackTexture,i,b.invertY,n,o,null,null,l,b)),a&&a(e||"Unknown error",r)};if(x){var M=function(e){x.loadData(e,b,function(e,t,i,r,s,a){a?C("TextureLoader failed to load data"):_._prepareWebGLTexture(b,n,e,t,b.invertY,!i,r,function(){return s(),!1},o)})};l?M(l):this._loadFile(g,M,void 0,n?n.offlineProvider:void 0,!0,function(e,t){C("Unable to load "+(e&&e.responseURL,t))})}else{var O=function(t){v&&!_._doNotHandleContextLost&&(b._buffer=t),_._prepareWebGLTexture(b,n,t.width,t.height,b.invertY,i,!1,function(i,r,o){var s=_._gl,a=t.width===i&&t.height===r,c=h?_._getInternalFormat(h):".jpg"===E?s.RGB:s.RGBA;if(a)return s.texImage2D(s.TEXTURE_2D,0,c,c,s.UNSIGNED_BYTE,t),!1;var l=_._caps.maxTextureSize;if(t.width>l||t.height>l||null===e._RescalePostProcessFactory)return _._prepareWorkingCanvas(),!(!_._workingCanvas||!_._workingContext)&&(_._workingCanvas.width=i,_._workingCanvas.height=r,_._workingContext.drawImage(t,0,0,t.width,t.height,0,0,i,r),s.texImage2D(s.TEXTURE_2D,0,c,c,s.UNSIGNED_BYTE,_._workingCanvas),b.width=i,b.height=r,!1);var u=new p.a(_,p.a.DATASOURCE_TEMP);return _._bindTextureDirectly(s.TEXTURE_2D,u,!0),s.texImage2D(s.TEXTURE_2D,0,c,c,s.UNSIGNED_BYTE,t),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),_._rescaleTexture(u,b,n,c,function(){_._releaseTexture(u),_._bindTextureDirectly(s.TEXTURE_2D,b,!0),o()}),!0},o)};!m||y?l instanceof HTMLImageElement?O(l):c.h.LoadImage(g,O,C,n?n.offlineProvider:null):"string"==typeof l||l instanceof ArrayBuffer||l instanceof Blob?c.h.LoadImage(l,O,C,n?n.offlineProvider:null):O(l)}return b},e.prototype._rescaleTexture=function(t,i,r,n,o){var s=this,a=this.createRenderTargetTexture({width:i.width,height:i.height},{generateMipMaps:!1,type:e.TEXTURETYPE_UNSIGNED_INT,samplingMode:e.TEXTURE_BILINEAR_SAMPLINGMODE,generateDepthBuffer:!1,generateStencilBuffer:!1});!this._rescalePostProcess&&e._RescalePostProcessFactory&&(this._rescalePostProcess=e._RescalePostProcessFactory(this)),this._rescalePostProcess.getEffect().executeWhenCompiled(function(){s._rescalePostProcess.onApply=function(e){e._bindTexture("textureSampler",t)};var e=r;e||(e=s.scenes[s.scenes.length-1]),e.postProcessManager.directRender([s._rescalePostProcess],a,!0),s._bindTextureDirectly(s._gl.TEXTURE_2D,i,!0),s._gl.copyTexImage2D(s._gl.TEXTURE_2D,0,n,0,0,i.width,i.height,0),s.unBindFramebuffer(a),s._releaseTexture(a),o&&o()})},e.prototype.updateRawTexture=function(t,i,r,n,o,s){if(void 0===o&&(o=null),void 0===s&&(s=e.TEXTURETYPE_UNSIGNED_INT),t){var a=this._getRGBABufferInternalSizedFormat(s,r),c=this._getInternalFormat(r),l=this._getWebGLTextureType(s);this._bindTextureDirectly(this._gl.TEXTURE_2D,t,!0),this._unpackFlipY(void 0===n||!!n),this._doNotHandleContextLost||(t._bufferView=i,t.format=r,t.type=s,t.invertY=n,t._compression=o),t.width%4!=0&&this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT,1),o&&i?this._gl.compressedTexImage2D(this._gl.TEXTURE_2D,0,this.getCaps().s3tc[o],t.width,t.height,0,i):this._gl.texImage2D(this._gl.TEXTURE_2D,0,a,t.width,t.height,0,c,l,i),t.generateMipMaps&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(this._gl.TEXTURE_2D,null),t.isReady=!0}},e.prototype.createRawTexture=function(t,i,r,n,o,s,a,c,l){void 0===c&&(c=null),void 0===l&&(l=e.TEXTURETYPE_UNSIGNED_INT);var u=new p.a(this,p.a.DATASOURCE_RAW);u.baseWidth=i,u.baseHeight=r,u.width=i,u.height=r,u.format=n,u.generateMipMaps=o,u.samplingMode=a,u.invertY=s,u._compression=c,u.type=l,this._doNotHandleContextLost||(u._bufferView=t),this.updateRawTexture(u,t,n,s,c,l),this._bindTextureDirectly(this._gl.TEXTURE_2D,u,!0);var h=this._getSamplingParameters(a,o);return this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MAG_FILTER,h.mag),this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MIN_FILTER,h.min),o&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(this._gl.TEXTURE_2D,null),this._internalTexturesCache.push(u),u},e.prototype._unpackFlipY=function(e){this._unpackFlipYCached!==e&&(this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL,e?1:0),this.enableUnpackFlipYCached&&(this._unpackFlipYCached=e))},e.prototype._getUnpackAlignement=function(){return this._gl.getParameter(this._gl.UNPACK_ALIGNMENT)},e.prototype.createDynamicTexture=function(e,t,i,r){var n=new p.a(this,p.a.DATASOURCE_DYNAMIC);return n.baseWidth=e,n.baseHeight=t,i&&(e=this.needPOTTextures?c.h.GetExponentOfTwo(e,this._caps.maxTextureSize):e,t=this.needPOTTextures?c.h.GetExponentOfTwo(t,this._caps.maxTextureSize):t),n.width=e,n.height=t,n.isReady=!1,n.generateMipMaps=i,n.samplingMode=r,this.updateTextureSamplingMode(r,n),this._internalTexturesCache.push(n),n},e.prototype.updateTextureSamplingMode=function(e,t){var i=this._getSamplingParameters(e,t.generateMipMaps);t.isCube?(this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP,this._gl.TEXTURE_MAG_FILTER,i.mag,t),this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP,this._gl.TEXTURE_MIN_FILTER,i.min),this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null)):t.is3D?(this._setTextureParameterInteger(this._gl.TEXTURE_3D,this._gl.TEXTURE_MAG_FILTER,i.mag,t),this._setTextureParameterInteger(this._gl.TEXTURE_3D,this._gl.TEXTURE_MIN_FILTER,i.min),this._bindTextureDirectly(this._gl.TEXTURE_3D,null)):(this._setTextureParameterInteger(this._gl.TEXTURE_2D,this._gl.TEXTURE_MAG_FILTER,i.mag,t),this._setTextureParameterInteger(this._gl.TEXTURE_2D,this._gl.TEXTURE_MIN_FILTER,i.min),this._bindTextureDirectly(this._gl.TEXTURE_2D,null)),t.samplingMode=e},e.prototype.updateDynamicTexture=function(e,t,i,r,n,o){if(void 0===r&&(r=!1),void 0===o&&(o=!1),e){this._bindTextureDirectly(this._gl.TEXTURE_2D,e,!0,o),this._unpackFlipY(i),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),e.isReady=!0}},e.prototype.updateVideoTexture=function(e,t,i){if(e&&!e._isDisabled){var r=this._bindTextureDirectly(this._gl.TEXTURE_2D,e,!0);this._unpackFlipY(!i);try{if(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);else{if(!e._workingCanvas){e._workingCanvas=document.createElement("canvas");var n=e._workingCanvas.getContext("2d");if(!n)throw new Error("Unable to get 2d context");e._workingContext=n,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),r||this._bindTextureDirectly(this._gl.TEXTURE_2D,null),e.isReady=!0}catch(t){e._isDisabled=!0}}},e.prototype.updateTextureComparisonFunction=function(t,i){if(1!==this.webGLVersion){var r=this._gl;t.isCube?(this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,t,!0),0===i?(r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_COMPARE_FUNC,e.LEQUAL),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_COMPARE_MODE,r.NONE)):(r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_COMPARE_FUNC,i),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_COMPARE_MODE,r.COMPARE_REF_TO_TEXTURE)),this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null)):(this._bindTextureDirectly(this._gl.TEXTURE_2D,t,!0),0===i?(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_COMPARE_FUNC,e.LEQUAL),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_COMPARE_MODE,r.NONE)):(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_COMPARE_FUNC,i),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_COMPARE_MODE,r.COMPARE_REF_TO_TEXTURE)),this._bindTextureDirectly(this._gl.TEXTURE_2D,null)),t._comparisonFunction=i}else v.a.Error("WebGL 1 does not support texture comparison.")},e.prototype._setupDepthStencilTexture=function(t,i,r,n,o){var s=i.width||i,a=i.height||i;t.baseWidth=s,t.baseHeight=a,t.width=s,t.height=a,t.isReady=!0,t.samples=1,t.generateMipMaps=!1,t._generateDepthBuffer=!0,t._generateStencilBuffer=r,t.samplingMode=n?e.TEXTURE_BILINEAR_SAMPLINGMODE:e.TEXTURE_NEAREST_SAMPLINGMODE,t.type=e.TEXTURETYPE_UNSIGNED_INT,t._comparisonFunction=o;var c=this._gl,l=t.isCube?c.TEXTURE_CUBE_MAP:c.TEXTURE_2D,u=this._getSamplingParameters(t.samplingMode,!1);c.texParameteri(l,c.TEXTURE_MAG_FILTER,u.mag),c.texParameteri(l,c.TEXTURE_MIN_FILTER,u.min),c.texParameteri(l,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE),c.texParameteri(l,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE),0===o?(c.texParameteri(l,c.TEXTURE_COMPARE_FUNC,e.LEQUAL),c.texParameteri(l,c.TEXTURE_COMPARE_MODE,c.NONE)):(c.texParameteri(l,c.TEXTURE_COMPARE_FUNC,o),c.texParameteri(l,c.TEXTURE_COMPARE_MODE,c.COMPARE_REF_TO_TEXTURE))},e.prototype.createDepthStencilTexture=function(e,t){if(t.isCube){var i=e.width||e;return this._createDepthStencilCubeTexture(i,t)}return this._createDepthStencilTexture(e,t)},e.prototype._createDepthStencilTexture=function(e,t){var i=new p.a(this,p.a.DATASOURCE_DEPTHTEXTURE);if(!this._caps.depthTextureExtension)return v.a.Error("Depth texture is not supported by your browser or hardware."),i;var n=r.a({bilinearFiltering:!1,comparisonFunction:0,generateStencil:!1},t),o=this._gl;return this._bindTextureDirectly(o.TEXTURE_2D,i,!0),this._setupDepthStencilTexture(i,e,n.generateStencil,n.bilinearFiltering,n.comparisonFunction),this.webGLVersion>1?n.generateStencil?o.texImage2D(o.TEXTURE_2D,0,o.DEPTH24_STENCIL8,i.width,i.height,0,o.DEPTH_STENCIL,o.UNSIGNED_INT_24_8,null):o.texImage2D(o.TEXTURE_2D,0,o.DEPTH_COMPONENT24,i.width,i.height,0,o.DEPTH_COMPONENT,o.UNSIGNED_INT,null):n.generateStencil?o.texImage2D(o.TEXTURE_2D,0,o.DEPTH_STENCIL,i.width,i.height,0,o.DEPTH_STENCIL,o.UNSIGNED_INT_24_8,null):o.texImage2D(o.TEXTURE_2D,0,o.DEPTH_COMPONENT,i.width,i.height,0,o.DEPTH_COMPONENT,o.UNSIGNED_INT,null),this._bindTextureDirectly(o.TEXTURE_2D,null),i},e.prototype._createDepthStencilCubeTexture=function(e,t){var i=new p.a(this,p.a.DATASOURCE_UNKNOWN);if(i.isCube=!0,1===this.webGLVersion)return v.a.Error("Depth cube texture is not supported by WebGL 1."),i;var n=r.a({bilinearFiltering:!1,comparisonFunction:0,generateStencil:!1},t),o=this._gl;this._bindTextureDirectly(o.TEXTURE_CUBE_MAP,i,!0),this._setupDepthStencilTexture(i,e,n.generateStencil,n.bilinearFiltering,n.comparisonFunction);for(var s=0;s<6;s++)n.generateStencil?o.texImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+s,0,o.DEPTH24_STENCIL8,e,e,0,o.DEPTH_STENCIL,o.UNSIGNED_INT_24_8,null):o.texImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+s,0,o.DEPTH_COMPONENT24,e,e,0,o.DEPTH_COMPONENT,o.UNSIGNED_INT,null);return this._bindTextureDirectly(o.TEXTURE_CUBE_MAP,null),i},e.prototype.setFrameBufferDepthStencilTexture=function(e){var t=e.getInternalTexture();if(t&&t._framebuffer&&e.depthStencilTexture){var i=this._gl,r=e.depthStencilTexture;this.bindUnboundFramebuffer(t._framebuffer),r.isCube?r._generateStencilBuffer?i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.TEXTURE_CUBE_MAP_POSITIVE_X,r._webGLTexture,0):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_CUBE_MAP_POSITIVE_X,r._webGLTexture,0):r._generateStencilBuffer?i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.TEXTURE_2D,r._webGLTexture,0):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,r._webGLTexture,0),this.bindUnboundFramebuffer(null)}},e.prototype.createRenderTargetTexture=function(t,i){var r=new b.a;void 0!==i&&"object"==typeof i?(r.generateMipMaps=i.generateMipMaps,r.generateDepthBuffer=void 0===i.generateDepthBuffer||i.generateDepthBuffer,r.generateStencilBuffer=r.generateDepthBuffer&&i.generateStencilBuffer,r.type=void 0===i.type?e.TEXTURETYPE_UNSIGNED_INT:i.type,r.samplingMode=void 0===i.samplingMode?e.TEXTURE_TRILINEAR_SAMPLINGMODE:i.samplingMode,r.format=void 0===i.format?e.TEXTUREFORMAT_RGBA:i.format):(r.generateMipMaps=i,r.generateDepthBuffer=!0,r.generateStencilBuffer=!1,r.type=e.TEXTURETYPE_UNSIGNED_INT,r.samplingMode=e.TEXTURE_TRILINEAR_SAMPLINGMODE,r.format=e.TEXTUREFORMAT_RGBA),(r.type!==e.TEXTURETYPE_FLOAT||this._caps.textureFloatLinearFiltering)&&(r.type!==e.TEXTURETYPE_HALF_FLOAT||this._caps.textureHalfFloatLinearFiltering)||(r.samplingMode=e.TEXTURE_NEAREST_SAMPLINGMODE);var n=this._gl,o=new p.a(this,p.a.DATASOURCE_RENDERTARGET);this._bindTextureDirectly(n.TEXTURE_2D,o,!0);var s=t.width||t,a=t.height||t,c=this._getSamplingParameters(r.samplingMode,!!r.generateMipMaps);r.type!==e.TEXTURETYPE_FLOAT||this._caps.textureFloat||(r.type=e.TEXTURETYPE_UNSIGNED_INT,v.a.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type")),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,c.mag),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,c.min),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE),n.texImage2D(n.TEXTURE_2D,0,this._getRGBABufferInternalSizedFormat(r.type,r.format),s,a,0,this._getInternalFormat(r.format),this._getWebGLTextureType(r.type),null);var l=this._currentFramebuffer,u=n.createFramebuffer();return this.bindUnboundFramebuffer(u),n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,o._webGLTexture,0),o._depthStencilBuffer=this._setupFramebufferDepthAttachments(!!r.generateStencilBuffer,r.generateDepthBuffer,s,a),r.generateMipMaps&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(n.TEXTURE_2D,null),n.bindRenderbuffer(n.RENDERBUFFER,null),this.bindUnboundFramebuffer(l),o._framebuffer=u,o.baseWidth=s,o.baseHeight=a,o.width=s,o.height=a,o.isReady=!0,o.samples=1,o.generateMipMaps=!!r.generateMipMaps,o.samplingMode=r.samplingMode,o.type=r.type,o.format=r.format,o._generateDepthBuffer=r.generateDepthBuffer,o._generateStencilBuffer=!!r.generateStencilBuffer,this._internalTexturesCache.push(o),o},e.prototype.createMultipleRenderTarget=function(t,i){var r=!1,n=!0,o=!1,s=!1,a=1,c=e.TEXTURETYPE_UNSIGNED_INT,l=e.TEXTURE_TRILINEAR_SAMPLINGMODE,u=new Array,h=new Array;void 0!==i&&(r=void 0!==i.generateMipMaps&&i.generateMipMaps,n=void 0===i.generateDepthBuffer||i.generateDepthBuffer,o=void 0!==i.generateStencilBuffer&&i.generateStencilBuffer,s=void 0!==i.generateDepthTexture&&i.generateDepthTexture,a=i.textureCount||1,i.types&&(u=i.types),i.samplingModes&&(h=i.samplingModes));var d=this._gl,f=d.createFramebuffer();this.bindUnboundFramebuffer(f);for(var _=t.width||t,g=t.height||t,m=[],y=[],b=this._setupFramebufferDepthAttachments(o,n,_,g),T=0;T<a;T++){var E=h[T]||l,x=u[T]||c;(x!==e.TEXTURETYPE_FLOAT||this._caps.textureFloatLinearFiltering)&&(x!==e.TEXTURETYPE_HALF_FLOAT||this._caps.textureHalfFloatLinearFiltering)||(E=e.TEXTURE_NEAREST_SAMPLINGMODE);var A=this._getSamplingParameters(E,r);x!==e.TEXTURETYPE_FLOAT||this._caps.textureFloat||(x=e.TEXTURETYPE_UNSIGNED_INT,v.a.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type"));var P=new p.a(this,p.a.DATASOURCE_MULTIRENDERTARGET),R=d[this.webGLVersion>1?"COLOR_ATTACHMENT"+T:"COLOR_ATTACHMENT"+T+"_WEBGL"];m.push(P),y.push(R),d.activeTexture(d["TEXTURE"+T]),d.bindTexture(d.TEXTURE_2D,P._webGLTexture),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MAG_FILTER,A.mag),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MIN_FILTER,A.min),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_S,d.CLAMP_TO_EDGE),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_T,d.CLAMP_TO_EDGE),d.texImage2D(d.TEXTURE_2D,0,this._getRGBABufferInternalSizedFormat(x),_,g,0,d.RGBA,this._getWebGLTextureType(x),null),d.framebufferTexture2D(d.DRAW_FRAMEBUFFER,R,d.TEXTURE_2D,P._webGLTexture,0),r&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(d.TEXTURE_2D,null),P._framebuffer=f,P._depthStencilBuffer=b,P.baseWidth=_,P.baseHeight=g,P.width=_,P.height=g,P.isReady=!0,P.samples=1,P.generateMipMaps=r,P.samplingMode=E,P.type=x,P._generateDepthBuffer=n,P._generateStencilBuffer=o,P._attachments=y,this._internalTexturesCache.push(P)}if(s&&this._caps.depthTextureExtension){var S=new p.a(this,p.a.DATASOURCE_MULTIRENDERTARGET);d.activeTexture(d.TEXTURE0),d.bindTexture(d.TEXTURE_2D,S._webGLTexture),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MAG_FILTER,d.NEAREST),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MIN_FILTER,d.NEAREST),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_S,d.CLAMP_TO_EDGE),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_T,d.CLAMP_TO_EDGE),d.texImage2D(d.TEXTURE_2D,0,this.webGLVersion<2?d.DEPTH_COMPONENT:d.DEPTH_COMPONENT16,_,g,0,d.DEPTH_COMPONENT,d.UNSIGNED_SHORT,null),d.framebufferTexture2D(d.FRAMEBUFFER,d.DEPTH_ATTACHMENT,d.TEXTURE_2D,S._webGLTexture,0),S._framebuffer=f,S.baseWidth=_,S.baseHeight=g,S.width=_,S.height=g,S.isReady=!0,S.samples=1,S.generateMipMaps=r,S.samplingMode=d.NEAREST,S._generateDepthBuffer=n,S._generateStencilBuffer=o,m.push(S),this._internalTexturesCache.push(S)}return d.drawBuffers(y),d.bindRenderbuffer(d.RENDERBUFFER,null),this.bindUnboundFramebuffer(null),this.resetTextureCache(),m},e.prototype._setupFramebufferDepthAttachments=function(e,t,i,r,n){void 0===n&&(n=1);var o=null,s=this._gl;return e?(o=s.createRenderbuffer(),s.bindRenderbuffer(s.RENDERBUFFER,o),n>1?s.renderbufferStorageMultisample(s.RENDERBUFFER,n,s.DEPTH24_STENCIL8,i,r):s.renderbufferStorage(s.RENDERBUFFER,s.DEPTH_STENCIL,i,r),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.DEPTH_STENCIL_ATTACHMENT,s.RENDERBUFFER,o)):t&&(o=s.createRenderbuffer(),s.bindRenderbuffer(s.RENDERBUFFER,o),n>1?s.renderbufferStorageMultisample(s.RENDERBUFFER,n,s.DEPTH_COMPONENT16,i,r):s.renderbufferStorage(s.RENDERBUFFER,s.DEPTH_COMPONENT16,i,r),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.DEPTH_ATTACHMENT,s.RENDERBUFFER,o)),o},e.prototype.updateRenderTargetTextureSampleCount=function(e,t){if(this.webGLVersion<2||!e)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._depthStencilBuffer=null),e._MSAAFramebuffer&&(i.deleteFramebuffer(e._MSAAFramebuffer),e._MSAAFramebuffer=null),e._MSAARenderBuffer&&(i.deleteRenderbuffer(e._MSAARenderBuffer),e._MSAARenderBuffer=null),t>1){var r=i.createFramebuffer();if(!r)throw new Error("Unable to create multi sampled framebuffer");e._MSAAFramebuffer=r,this.bindUnboundFramebuffer(e._MSAAFramebuffer);var n=i.createRenderbuffer();if(!n)throw new Error("Unable to create multi sampled framebuffer");i.bindRenderbuffer(i.RENDERBUFFER,n),i.renderbufferStorageMultisample(i.RENDERBUFFER,t,this._getRGBAMultiSampleBufferFormat(e.type),e.width,e.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,n),e._MSAARenderBuffer=n}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},e.prototype.updateMultipleRenderTargetTextureSampleCount=function(e,t){if(this.webGLVersion<2||!e||0==e.length)return 1;if(e[0].samples===t)return t;var i=this._gl;t=Math.min(t,i.getParameter(i.MAX_SAMPLES)),e[0]._depthStencilBuffer&&(i.deleteRenderbuffer(e[0]._depthStencilBuffer),e[0]._depthStencilBuffer=null),e[0]._MSAAFramebuffer&&(i.deleteFramebuffer(e[0]._MSAAFramebuffer),e[0]._MSAAFramebuffer=null);for(var r=0;r<e.length;r++)e[r]._MSAARenderBuffer&&(i.deleteRenderbuffer(e[r]._MSAARenderBuffer),e[r]._MSAARenderBuffer=null);if(t>1){var n=i.createFramebuffer();if(!n)throw new Error("Unable to create multi sampled framebuffer");this.bindUnboundFramebuffer(n);var o=this._setupFramebufferDepthAttachments(e[0]._generateStencilBuffer,e[0]._generateDepthBuffer,e[0].width,e[0].height,t),s=[];for(r=0;r<e.length;r++){var a=e[r],c=i[this.webGLVersion>1?"COLOR_ATTACHMENT"+r:"COLOR_ATTACHMENT"+r+"_WEBGL"],l=i.createRenderbuffer();if(!l)throw new Error("Unable to create multi sampled framebuffer");i.bindRenderbuffer(i.RENDERBUFFER,l),i.renderbufferStorageMultisample(i.RENDERBUFFER,t,this._getRGBAMultiSampleBufferFormat(a.type),a.width,a.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,c,i.RENDERBUFFER,l),a._MSAAFramebuffer=n,a._MSAARenderBuffer=l,a.samples=t,a._depthStencilBuffer=o,i.bindRenderbuffer(i.RENDERBUFFER,null),s.push(c)}i.drawBuffers(s)}else this.bindUnboundFramebuffer(e[0]._framebuffer);return this.bindUnboundFramebuffer(null),t},e.prototype._uploadCompressedDataToTextureDirectly=function(e,t,i,r,n,o,s){void 0===o&&(o=0),void 0===s&&(s=0);var a=this._gl,c=a.TEXTURE_2D;e.isCube&&(c=a.TEXTURE_CUBE_MAP_POSITIVE_X+o),this._gl.compressedTexImage2D(c,s,t,i,r,0,n)},e.prototype._uploadDataToTextureDirectly=function(e,t,i,r){void 0===i&&(i=0),void 0===r&&(r=0);var n=this._gl,o=this._getWebGLTextureType(e.type),s=this._getInternalFormat(e.format),a=this._getRGBABufferInternalSizedFormat(e.type,s);this._unpackFlipY(e.invertY);var c=n.TEXTURE_2D;e.isCube&&(c=n.TEXTURE_CUBE_MAP_POSITIVE_X+i);var l=Math.round(u.a.Log2(e.width)),h=Math.round(u.a.Log2(e.height)),d=Math.pow(2,Math.max(l-r,0)),f=Math.pow(2,Math.max(h-r,0));n.texImage2D(c,r,a,d,f,0,s,o,t)},e.prototype._uploadArrayBufferViewToTexture=function(e,t,i,r){void 0===i&&(i=0),void 0===r&&(r=0);var n=this._gl,o=e.isCube?n.TEXTURE_CUBE_MAP:n.TEXTURE_2D;this._bindTextureDirectly(o,e,!0),this._uploadDataToTextureDirectly(e,t,i,r),this._bindTextureDirectly(o,null,!0)},e.prototype._uploadImageToTexture=function(e,t,i,r){void 0===i&&(i=0),void 0===r&&(r=0);var n=this._gl,o=this._getWebGLTextureType(e.type),s=this._getInternalFormat(e.format),a=this._getRGBABufferInternalSizedFormat(e.type,s),c=e.isCube?n.TEXTURE_CUBE_MAP:n.TEXTURE_2D;this._bindTextureDirectly(c,e,!0),this._unpackFlipY(e.invertY);var l=n.TEXTURE_2D;e.isCube&&(l=n.TEXTURE_CUBE_MAP_POSITIVE_X+i),n.texImage2D(l,r,a,s,o,t),this._bindTextureDirectly(c,null,!0)},e.prototype.createRenderTargetCubeTexture=function(t,i){var n=r.a({generateMipMaps:!0,generateDepthBuffer:!0,generateStencilBuffer:!1,type:e.TEXTURETYPE_UNSIGNED_INT,samplingMode:e.TEXTURE_TRILINEAR_SAMPLINGMODE,format:e.TEXTUREFORMAT_RGBA},i);n.generateStencilBuffer=n.generateDepthBuffer&&n.generateStencilBuffer,(n.type!==e.TEXTURETYPE_FLOAT||this._caps.textureFloatLinearFiltering)&&(n.type!==e.TEXTURETYPE_HALF_FLOAT||this._caps.textureHalfFloatLinearFiltering)||(n.samplingMode=e.TEXTURE_NEAREST_SAMPLINGMODE);var o=this._gl,s=new p.a(this,p.a.DATASOURCE_RENDERTARGET);this._bindTextureDirectly(o.TEXTURE_CUBE_MAP,s,!0);var a=this._getSamplingParameters(n.samplingMode,n.generateMipMaps);n.type!==e.TEXTURETYPE_FLOAT||this._caps.textureFloat||(n.type=e.TEXTURETYPE_UNSIGNED_INT,v.a.Warn("Float textures are not supported. Cube render target forced to TEXTURETYPE_UNESIGNED_BYTE type")),o.texParameteri(o.TEXTURE_CUBE_MAP,o.TEXTURE_MAG_FILTER,a.mag),o.texParameteri(o.TEXTURE_CUBE_MAP,o.TEXTURE_MIN_FILTER,a.min),o.texParameteri(o.TEXTURE_CUBE_MAP,o.TEXTURE_WRAP_S,o.CLAMP_TO_EDGE),o.texParameteri(o.TEXTURE_CUBE_MAP,o.TEXTURE_WRAP_T,o.CLAMP_TO_EDGE);for(var c=0;c<6;c++)o.texImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+c,0,this._getRGBABufferInternalSizedFormat(n.type,n.format),t,t,0,this._getInternalFormat(n.format),this._getWebGLTextureType(n.type),null);var l=o.createFramebuffer();return this.bindUnboundFramebuffer(l),s._depthStencilBuffer=this._setupFramebufferDepthAttachments(n.generateStencilBuffer,n.generateDepthBuffer,t,t),n.generateMipMaps&&o.generateMipmap(o.TEXTURE_CUBE_MAP),this._bindTextureDirectly(o.TEXTURE_CUBE_MAP,null),o.bindRenderbuffer(o.RENDERBUFFER,null),this.bindUnboundFramebuffer(null),s._framebuffer=l,s.width=t,s.height=t,s.isReady=!0,s.isCube=!0,s.samples=1,s.generateMipMaps=n.generateMipMaps,s.samplingMode=n.samplingMode,s.type=n.type,s.format=n.format,s._generateDepthBuffer=n.generateDepthBuffer,s._generateStencilBuffer=n.generateStencilBuffer,this._internalTexturesCache.push(s),s},e.prototype.createCubeTexture=function(t,i,r,n,o,s,a,l,u,h,d,f,_){var g=this;void 0===o&&(o=null),void 0===s&&(s=null),void 0===l&&(l=null),void 0===u&&(u=!1),void 0===h&&(h=0),void 0===d&&(d=0),void 0===f&&(f=null),void 0===_&&(_=[]);var m=this._gl,y=f||new p.a(this,p.a.DATASOURCE_CUBE);y.isCube=!0,y.url=t,y.generateMipMaps=!n,y._lodGenerationScale=h,y._lodGenerationOffset=d,this._doNotHandleContextLost||(y._extension=l,y._files=r);for(var b=t.lastIndexOf("."),T=l||(b>-1?t.substring(b).toLowerCase():""),E=null,x=0,A=e._TextureLoaders;x<A.length;x++){var P=A[x];if(-1===_.indexOf(P)&&P.canLoad(T,this._textureFormatInUse,f,!1,!1)){E=P;break}}if(E){t=E.transformUrl(t,this._textureFormatInUse);var R=function(e){g._bindTextureDirectly(m.TEXTURE_CUBE_MAP,y,!0),E.loadCubeData(e,y,u,o,s)};r&&6===r.length?E.supportCascades?this._cascadeLoadFiles(i,R,r,s):s&&s("Textures type does not support cascades."):this._loadFile(t,R,void 0,void 0,!0,function(e,t){if(E){var c=E.getFallbackTextureUrl(y.url,g._textureFormatInUse);if(v.a.Warn(E.constructor.name+" failed when trying to load "+y.url+", falling back to the next supported loader"),c)return _.push(E),void g.createCubeTexture(c,i,r,n,o,s,a,T,u,h,d,y,_)}s&&e&&s(e.status+" "+e.statusText,t)})}else{if(!r)throw new Error("Cannot load cubemap because files were not defined");this._cascadeLoadImgs(i,function(e){var t=g.needPOTTextures?c.h.GetExponentOfTwo(e[0].width,g._caps.maxCubemapTextureSize):e[0].width,i=t;if(g._prepareWorkingCanvas(),g._workingCanvas&&g._workingContext){g._workingCanvas.width=t,g._workingCanvas.height=i;var r=[m.TEXTURE_CUBE_MAP_POSITIVE_X,m.TEXTURE_CUBE_MAP_POSITIVE_Y,m.TEXTURE_CUBE_MAP_POSITIVE_Z,m.TEXTURE_CUBE_MAP_NEGATIVE_X,m.TEXTURE_CUBE_MAP_NEGATIVE_Y,m.TEXTURE_CUBE_MAP_NEGATIVE_Z];g._bindTextureDirectly(m.TEXTURE_CUBE_MAP,y,!0),g._unpackFlipY(!1);for(var s=a?g._getInternalFormat(a):g._gl.RGBA,l=0;l<r.length;l++)g._workingContext.drawImage(e[l],0,0,e[l].width,e[l].height,0,0,t,i),m.texImage2D(r[l],0,s,s,m.UNSIGNED_BYTE,g._workingCanvas);n||m.generateMipmap(m.TEXTURE_CUBE_MAP),g._setCubeMapTextureParams(!n),y.width=t,y.height=i,y.isReady=!0,a&&(y.format=a),y.onLoadedObservable.notifyObservers(y),y.onLoadedObservable.clear(),o&&o()}},r,s)}return this._internalTexturesCache.push(y),y},e.prototype._setCubeMapTextureParams=function(e){var t=this._gl;t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MIN_FILTER,e?t.LINEAR_MIPMAP_LINEAR:t.LINEAR),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),this._bindTextureDirectly(t.TEXTURE_CUBE_MAP,null)},e.prototype.updateRawCubeTexture=function(e,t,i,r,n,o,s){void 0===o&&(o=null),void 0===s&&(s=0),e._bufferViewArray=t,e.format=i,e.type=r,e.invertY=n,e._compression=o;var a=this._gl,l=this._getWebGLTextureType(r),u=this._getInternalFormat(i),h=this._getRGBABufferInternalSizedFormat(r),d=!1;u===a.RGB&&(u=a.RGBA,d=!0),this._bindTextureDirectly(a.TEXTURE_CUBE_MAP,e,!0),this._unpackFlipY(void 0===n||!!n),e.width%4!=0&&a.pixelStorei(a.UNPACK_ALIGNMENT,1);for(var f=0;f<6;f++){var p=t[f];o?a.compressedTexImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+f,s,this.getCaps().s3tc[o],e.width,e.height,0,p):(d&&(p=this._convertRGBtoRGBATextureData(p,e.width,e.height,r)),a.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+f,s,h,e.width,e.height,0,u,l,p))}(!this.needPOTTextures||c.h.IsExponentOfTwo(e.width)&&c.h.IsExponentOfTwo(e.height))&&e.generateMipMaps&&0===s&&this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP),this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null),e.isReady=!0},e.prototype.createRawCubeTexture=function(t,i,r,n,o,s,a,l){void 0===l&&(l=null);var u=this._gl,h=new p.a(this,p.a.DATASOURCE_CUBERAW);h.isCube=!0,h.format=r,h.type=n,this._doNotHandleContextLost||(h._bufferViewArray=t);var d=this._getWebGLTextureType(n),f=this._getInternalFormat(r);f===u.RGB&&(f=u.RGBA),d!==u.FLOAT||this._caps.textureFloatLinearFiltering?d!==this._gl.HALF_FLOAT_OES||this._caps.textureHalfFloatLinearFiltering?d!==u.FLOAT||this._caps.textureFloatRender?d!==u.HALF_FLOAT||this._caps.colorBufferFloat||(o=!1,v.a.Warn("Render to half float textures is not supported. Mipmap generation forced to false.")):(o=!1,v.a.Warn("Render to float textures is not supported. Mipmap generation forced to false.")):(o=!1,a=e.TEXTURE_NEAREST_SAMPLINGMODE,v.a.Warn("Half float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively.")):(o=!1,a=e.TEXTURE_NEAREST_SAMPLINGMODE,v.a.Warn("Float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively."));var _=i,g=_;h.width=_,h.height=g,!this.needPOTTextures||c.h.IsExponentOfTwo(h.width)&&c.h.IsExponentOfTwo(h.height)||(o=!1),t&&this.updateRawCubeTexture(h,t,r,n,s,l),this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,h,!0),t&&o&&this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP);var m=this._getSamplingParameters(a,o);return u.texParameteri(u.TEXTURE_CUBE_MAP,u.TEXTURE_MAG_FILTER,m.mag),u.texParameteri(u.TEXTURE_CUBE_MAP,u.TEXTURE_MIN_FILTER,m.min),u.texParameteri(u.TEXTURE_CUBE_MAP,u.TEXTURE_WRAP_S,u.CLAMP_TO_EDGE),u.texParameteri(u.TEXTURE_CUBE_MAP,u.TEXTURE_WRAP_T,u.CLAMP_TO_EDGE),this._bindTextureDirectly(u.TEXTURE_CUBE_MAP,null),h.generateMipMaps=o,h},e.prototype.createRawCubeTextureFromUrl=function(t,i,r,n,o,s,a,c,l,u,h,d){var f=this;void 0===l&&(l=null),void 0===u&&(u=null),void 0===h&&(h=e.TEXTURE_TRILINEAR_SAMPLINGMODE),void 0===d&&(d=!1);var p=this._gl,_=this.createRawCubeTexture(null,r,n,o,!s,d,h);i._addPendingData(_),_.url=t,this._internalTexturesCache.push(_);return this._loadFile(t,function(e){!function(e){var t=_.width,r=a(e);if(r){if(c){var s=f._getWebGLTextureType(o),u=f._getInternalFormat(n),h=f._getRGBABufferInternalSizedFormat(o),g=!1;u===p.RGB&&(u=p.RGBA,g=!0),f._bindTextureDirectly(p.TEXTURE_CUBE_MAP,_,!0),f._unpackFlipY(!1);for(var m=c(r),v=0;v<m.length;v++)for(var y=t>>v,b=0;b<6;b++){var T=m[v][b];g&&(T=f._convertRGBtoRGBATextureData(T,y,y,o)),p.texImage2D(b,v,h,y,y,0,u,s,T)}f._bindTextureDirectly(p.TEXTURE_CUBE_MAP,null)}else f.updateRawCubeTexture(_,r,n,o,d);_.isReady=!0,i._removePendingData(_),l&&l()}}(e)},void 0,i.offlineProvider,!0,function(e,t){i._removePendingData(_),u&&e&&u(e.status+" "+e.statusText,t)}),_},e.prototype.updateRawTexture3D=function(t,i,r,n,o,s){void 0===o&&(o=null),void 0===s&&(s=e.TEXTURETYPE_UNSIGNED_INT);var a=this._getWebGLTextureType(s),c=this._getInternalFormat(r),l=this._getRGBABufferInternalSizedFormat(s,r);this._bindTextureDirectly(this._gl.TEXTURE_3D,t,!0),this._unpackFlipY(void 0===n||!!n),this._doNotHandleContextLost||(t._bufferView=i,t.format=r,t.invertY=n,t._compression=o),t.width%4!=0&&this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT,1),o&&i?this._gl.compressedTexImage3D(this._gl.TEXTURE_3D,0,this.getCaps().s3tc[o],t.width,t.height,t.depth,0,i):this._gl.texImage3D(this._gl.TEXTURE_3D,0,l,t.width,t.height,t.depth,0,c,a,i),t.generateMipMaps&&this._gl.generateMipmap(this._gl.TEXTURE_3D),this._bindTextureDirectly(this._gl.TEXTURE_3D,null),t.isReady=!0},e.prototype.createRawTexture3D=function(t,i,r,n,o,s,a,c,l,u){void 0===l&&(l=null),void 0===u&&(u=e.TEXTURETYPE_UNSIGNED_INT);var h=new p.a(this,p.a.DATASOURCE_RAW3D);h.baseWidth=i,h.baseHeight=r,h.baseDepth=n,h.width=i,h.height=r,h.depth=n,h.format=o,h.type=u,h.generateMipMaps=s,h.samplingMode=c,h.is3D=!0,this._doNotHandleContextLost||(h._bufferView=t),this.updateRawTexture3D(h,t,o,a,l,u),this._bindTextureDirectly(this._gl.TEXTURE_3D,h,!0);var d=this._getSamplingParameters(c,s);return this._gl.texParameteri(this._gl.TEXTURE_3D,this._gl.TEXTURE_MAG_FILTER,d.mag),this._gl.texParameteri(this._gl.TEXTURE_3D,this._gl.TEXTURE_MIN_FILTER,d.min),s&&this._gl.generateMipmap(this._gl.TEXTURE_3D),this._bindTextureDirectly(this._gl.TEXTURE_3D,null),this._internalTexturesCache.push(h),h},e.prototype._prepareWebGLTextureContinuation=function(e,t,i,r,n){var o=this._gl;if(o){var s=this._getSamplingParameters(n,!i);o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,s.mag),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,s.min),i||r||o.generateMipmap(o.TEXTURE_2D),this._bindTextureDirectly(o.TEXTURE_2D,null),t&&t._removePendingData(e),e.onLoadedObservable.notifyObservers(e),e.onLoadedObservable.clear()}},e.prototype._prepareWebGLTexture=function(t,i,r,n,o,s,a,l,u){var h=this;void 0===u&&(u=e.TEXTURE_TRILINEAR_SAMPLINGMODE);var d=this.getCaps().maxTextureSize,f=Math.min(d,this.needPOTTextures?c.h.GetExponentOfTwo(r,d):r),p=Math.min(d,this.needPOTTextures?c.h.GetExponentOfTwo(n,d):n),_=this._gl;_&&(t._webGLTexture?(this._bindTextureDirectly(_.TEXTURE_2D,t,!0),this._unpackFlipY(void 0===o||!!o),t.baseWidth=r,t.baseHeight=n,t.width=f,t.height=p,t.isReady=!0,l(f,p,function(){h._prepareWebGLTextureContinuation(t,i,s,a,u)})||this._prepareWebGLTextureContinuation(t,i,s,a,u)):i&&i._removePendingData(t))},e.prototype._convertRGBtoRGBATextureData=function(t,i,r,n){var o;o=n===e.TEXTURETYPE_FLOAT?new Float32Array(i*r*4):new Uint32Array(i*r*4);for(var s=0;s<i;s++)for(var a=0;a<r;a++){var c=3*(a*i+s),l=4*(a*i+s);o[l+0]=t[c+0],o[l+1]=t[c+1],o[l+2]=t[c+2],o[l+3]=1}return o},e.prototype._releaseFramebufferObjects=function(e){var t=this._gl;e._framebuffer&&(t.deleteFramebuffer(e._framebuffer),e._framebuffer=null),e._depthStencilBuffer&&(t.deleteRenderbuffer(e._depthStencilBuffer),e._depthStencilBuffer=null),e._MSAAFramebuffer&&(t.deleteFramebuffer(e._MSAAFramebuffer),e._MSAAFramebuffer=null),e._MSAARenderBuffer&&(t.deleteRenderbuffer(e._MSAARenderBuffer),e._MSAARenderBuffer=null)},e.prototype._releaseTexture=function(e){var t=this._gl;this._releaseFramebufferObjects(e),t.deleteTexture(e._webGLTexture),this.unbindAllTextures();var i=this._internalTexturesCache.indexOf(e);-1!==i&&this._internalTexturesCache.splice(i,1),e._lodTextureHigh&&e._lodTextureHigh.dispose(),e._lodTextureMid&&e._lodTextureMid.dispose(),e._lodTextureLow&&e._lodTextureLow.dispose(),this.scenes.forEach(function(t){t.postProcesses.forEach(function(t){t._outputTexture==e&&(t._outputTexture=null)}),t.cameras.forEach(function(t){t._postProcesses.forEach(function(t){t&&t._outputTexture==e&&(t._outputTexture=null)})})})},e.prototype.setProgram=function(e){this._currentProgram!==e&&(this._gl.useProgram(e),this._currentProgram=e)},e.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]);r&&(this._boundUniforms[i]=r)}this._currentEffect=null},e.prototype._moveBoundTextureOnTop=function(e){this.disableTextureBindingOptimization||this._lastBoundInternalTextureTracker.previous===e||(this._linkTrackers(e.previous,e.next),this._linkTrackers(this._lastBoundInternalTextureTracker.previous,e),this._linkTrackers(e,this._lastBoundInternalTextureTracker))},e.prototype._getCorrectTextureChannel=function(e,t){if(!t)return-1;if(t._initialSlot=e,this.disableTextureBindingOptimization)e!==t._designatedSlot&&this._textureCollisions.addCount(1,!1);else if(e!==t._designatedSlot)return t._designatedSlot>-1?t._designatedSlot:this._nextFreeTextureSlots.length?this._nextFreeTextureSlots[0]:(this._textureCollisions.addCount(1,!1),this._removeDesignatedSlot(this._firstBoundInternalTextureTracker.next));return e},e.prototype._linkTrackers=function(e,t){e.next=t,t.previous=e},e.prototype._removeDesignatedSlot=function(e){var t=e._designatedSlot;return-1===t?-1:(e._designatedSlot=-1,this.disableTextureBindingOptimization?-1:(this._linkTrackers(e.previous,e.next),this._boundTexturesCache[t]=null,this._nextFreeTextureSlots.push(t),t))},e.prototype._activateCurrentTexture=function(){this._currentTextureChannel!==this._activeChannel&&(this._gl.activeTexture(this._gl.TEXTURE0+this._activeChannel),this._currentTextureChannel=this._activeChannel)},e.prototype._bindTextureDirectly=function(e,t,i,r){void 0===i&&(i=!1),void 0===r&&(r=!1);var n=!1;i&&t&&t._designatedSlot>-1&&(this._activeChannel=t._designatedSlot);var o=this._boundTexturesCache[this._activeChannel],s=t&&t._initialSlot>-1;if(o!==t||r){if(o&&this._removeDesignatedSlot(o),this._activateCurrentTexture(),this._gl.bindTexture(e,t?t._webGLTexture:null),this._boundTexturesCache[this._activeChannel]=t,t){if(!this.disableTextureBindingOptimization){var a=this._nextFreeTextureSlots.indexOf(this._activeChannel);a>-1&&this._nextFreeTextureSlots.splice(a,1),this._linkTrackers(this._lastBoundInternalTextureTracker.previous,t),this._linkTrackers(t,this._lastBoundInternalTextureTracker)}t._designatedSlot=this._activeChannel}}else i&&(n=!0,this._activateCurrentTexture());return s&&!i&&this._bindSamplerUniformToChannel(t._initialSlot,this._activeChannel),n},e.prototype._bindTexture=function(e,t){e<0||(t&&(e=this._getCorrectTextureChannel(e,t)),this._activeChannel=e,this._bindTextureDirectly(this._gl.TEXTURE_2D,t))},e.prototype.setTextureFromPostProcess=function(e,t){this._bindTexture(e,t?t._textures.data[t._currentRenderTextureInd]:null)},e.prototype.setTextureFromPostProcessOutput=function(e,t){this._bindTexture(e,t?t._outputTexture:null)},e.prototype.unbindAllTextures=function(){for(var e=0;e<this._maxSimultaneousTextures;e++)this._activeChannel=e,this._bindTextureDirectly(this._gl.TEXTURE_2D,null),this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null),this.webGLVersion>1&&this._bindTextureDirectly(this._gl.TEXTURE_3D,null)},e.prototype.setTexture=function(e,t,i){e<0||(t&&(this._boundUniforms[e]=t),this._setTexture(e,i))},e.prototype.setDepthStencilTexture=function(e,t,i){e<0||(t&&(this._boundUniforms[e]=t),i&&i.depthStencilTexture?this._setTexture(e,i,!1,!0):this._setTexture(e,null))},e.prototype._bindSamplerUniformToChannel=function(e,t){var i=this._boundUniforms[e];i._currentState!==t&&(this._gl.uniform1i(i,t),i._currentState=t)},e.prototype._getTextureWrapMode=function(t){switch(t){case e.TEXTURE_WRAP_ADDRESSMODE:return this._gl.REPEAT;case e.TEXTURE_CLAMP_ADDRESSMODE:return this._gl.CLAMP_TO_EDGE;case e.TEXTURE_MIRROR_ADDRESSMODE:return this._gl.MIRRORED_REPEAT}return this._gl.REPEAT},e.prototype._setTexture=function(t,i,r,n){if(void 0===r&&(r=!1),void 0===n&&(n=!1),!i)return null!=this._boundTexturesCache[t]&&(this._activeChannel=t,this._bindTextureDirectly(this._gl.TEXTURE_2D,null),this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null),this.webGLVersion>1&&this._bindTextureDirectly(this._gl.TEXTURE_3D,null)),!1;if(i.video)this._activeChannel=t,i.update();else if(i.delayLoadState===e.DELAYLOADSTATE_NOTLOADED)return i.delayLoad(),!1;var o;o=n?i.depthStencilTexture:i.isReady()?i.getInternalTexture():i.isCube?this.emptyCubeTexture:i.is3D?this.emptyTexture3D:this.emptyTexture,r||(t=this._getCorrectTextureChannel(t,o));var s=!0;if(this._boundTexturesCache[t]===o&&(this._moveBoundTextureOnTop(o),r||this._bindSamplerUniformToChannel(o._initialSlot,t),s=!1),this._activeChannel=t,o&&o.is3D)s&&this._bindTextureDirectly(this._gl.TEXTURE_3D,o,r),o&&o._cachedWrapU!==i.wrapU&&(o._cachedWrapU=i.wrapU,this._setTextureParameterInteger(this._gl.TEXTURE_3D,this._gl.TEXTURE_WRAP_S,this._getTextureWrapMode(i.wrapU),o)),o&&o._cachedWrapV!==i.wrapV&&(o._cachedWrapV=i.wrapV,this._setTextureParameterInteger(this._gl.TEXTURE_3D,this._gl.TEXTURE_WRAP_T,this._getTextureWrapMode(i.wrapV),o)),o&&o._cachedWrapR!==i.wrapR&&(o._cachedWrapR=i.wrapR,this._setTextureParameterInteger(this._gl.TEXTURE_3D,this._gl.TEXTURE_WRAP_R,this._getTextureWrapMode(i.wrapR),o)),this._setAnisotropicLevel(this._gl.TEXTURE_3D,i);else if(o&&o.isCube){if(s&&this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,o,r),o._cachedCoordinatesMode!==i.coordinatesMode){o._cachedCoordinatesMode=i.coordinatesMode;var a=i.coordinatesMode!==e.TEXTURE_CUBIC_MODE&&i.coordinatesMode!==e.TEXTURE_SKYBOX_MODE?this._gl.REPEAT:this._gl.CLAMP_TO_EDGE;this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP,this._gl.TEXTURE_WRAP_S,a,o),this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP,this._gl.TEXTURE_WRAP_T,a)}this._setAnisotropicLevel(this._gl.TEXTURE_CUBE_MAP,i)}else s&&this._bindTextureDirectly(this._gl.TEXTURE_2D,o,r),o&&o._cachedWrapU!==i.wrapU&&(o._cachedWrapU=i.wrapU,this._setTextureParameterInteger(this._gl.TEXTURE_2D,this._gl.TEXTURE_WRAP_S,this._getTextureWrapMode(i.wrapU),o)),o&&o._cachedWrapV!==i.wrapV&&(o._cachedWrapV=i.wrapV,this._setTextureParameterInteger(this._gl.TEXTURE_2D,this._gl.TEXTURE_WRAP_T,this._getTextureWrapMode(i.wrapV),o)),this._setAnisotropicLevel(this._gl.TEXTURE_2D,i);return!0},e.prototype.setTextureArray=function(e,t,i){if(!(e<0)&&t){this._textureUnits&&this._textureUnits.length===i.length||(this._textureUnits=new Int32Array(i.length));for(var r=0;r<i.length;r++)this._textureUnits[r]=this._getCorrectTextureChannel(e+r,i[r].getInternalTexture());this._gl.uniform1iv(t,this._textureUnits);for(var n=0;n<i.length;n++)this._setTexture(this._textureUnits[n],i[n],!0)}},e.prototype._setAnisotropicLevel=function(t,i){var r=i.getInternalTexture();if(r){var n=this._caps.textureAnisotropicFilterExtension,o=i.anisotropicFilteringLevel;r.samplingMode!==e.TEXTURE_LINEAR_LINEAR_MIPNEAREST&&r.samplingMode!==e.TEXTURE_LINEAR_LINEAR_MIPLINEAR&&r.samplingMode!==e.TEXTURE_LINEAR_LINEAR&&(o=1),n&&r._cachedAnisotropicFilteringLevel!==o&&(this._setTextureParameterFloat(t,n.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(o,this._caps.maxAnisotropy),r),r._cachedAnisotropicFilteringLevel=o)}},e.prototype._setTextureParameterFloat=function(e,t,i,r){this._bindTextureDirectly(e,r,!0,!0),this._gl.texParameterf(e,t,i)},e.prototype._setTextureParameterInteger=function(e,t,i,r){r&&this._bindTextureDirectly(e,r,!0,!0),this._gl.texParameteri(e,t,i)},e.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},e.prototype.addExternalData=function(e,t){return this._externalData||(this._externalData=new s.a),this._externalData.add(e,t)},e.prototype.getExternalData=function(e){return this._externalData||(this._externalData=new s.a),this._externalData.get(e)},e.prototype.getOrAddExternalDataWithFactory=function(e,t){return this._externalData||(this._externalData=new s.a),this._externalData.getOrAddWithFactory(e,t)},e.prototype.removeExternalData=function(e){return this._externalData||(this._externalData=new s.a),this._externalData.remove(e)},e.prototype.unbindAllAttributes=function(){if(this._mustWipeVertexAttributes){this._mustWipeVertexAttributes=!1;for(var e=0;e<this._caps.maxVertexAttribs;e++)this._gl.disableVertexAttribArray(e),this._vertexAttribArraysEnabled[e]=!1,this._currentBufferPointers[e].active=!1}else{e=0;for(var t=this._vertexAttribArraysEnabled.length;e<t;e++)e>=this._caps.maxVertexAttribs||!this._vertexAttribArraysEnabled[e]||(this._gl.disableVertexAttribArray(e),this._vertexAttribArraysEnabled[e]=!1,this._currentBufferPointers[e].active=!1)}},e.prototype.releaseEffects=function(){for(var e in this._compiledEffects)this._deleteProgram(this._compiledEffects[e]._program);this._compiledEffects={}},e.prototype.dispose=function(){for(this.hideLoadingUI(),this.stopRenderLoop(),this.onNewSceneAddedObservable.clear();this.postProcesses.length;)this.postProcesses[0].dispose();for(this._emptyTexture&&(this._releaseTexture(this._emptyTexture),this._emptyTexture=null),this._emptyCubeTexture&&(this._releaseTexture(this._emptyCubeTexture),this._emptyCubeTexture=null),this._rescalePostProcess&&this._rescalePostProcess.dispose();this.scenes.length;)this.scenes[0].dispose();1===e.Instances.length&&e.audioEngine&&e.audioEngine.dispose(),this.releaseEffects(),this.unbindAllAttributes(),this._boundUniforms=[],this._dummyFramebuffer&&this._gl.deleteFramebuffer(this._dummyFramebuffer),this.disableVR(),m.a.IsWindowObjectExist()&&(window.removeEventListener("blur",this._onBlur),window.removeEventListener("focus",this._onFocus),window.removeEventListener("vrdisplaypointerrestricted",this._onVRDisplayPointerRestricted),window.removeEventListener("vrdisplaypointerunrestricted",this._onVRDisplayPointerUnrestricted),this._renderingCanvas&&(this._renderingCanvas.removeEventListener("focus",this._onCanvasFocus),this._renderingCanvas.removeEventListener("blur",this._onCanvasBlur),this._renderingCanvas.removeEventListener("pointerout",this._onCanvasPointerOut),this._doNotHandleContextLost||(this._renderingCanvas.removeEventListener("webglcontextlost",this._onContextLost),this._renderingCanvas.removeEventListener("webglcontextrestored",this._onContextRestored))),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),this._onVrDisplayConnect&&(window.removeEventListener("vrdisplayconnect",this._onVrDisplayConnect),this._onVrDisplayDisconnect&&window.removeEventListener("vrdisplaydisconnect",this._onVrDisplayDisconnect),this._onVrDisplayPresentChange&&window.removeEventListener("vrdisplaypresentchange",this._onVrDisplayPresentChange),this._onVrDisplayConnect=null,this._onVrDisplayDisconnect=null));var t=e.Instances.indexOf(this);t>=0&&e.Instances.splice(t,1),this._workingCanvas=null,this._workingContext=null,this._currentBufferPointers=[],this._renderingCanvas=null,this._currentProgram=null,this._bindedRenderFunction=null,this.onResizeObservable.clear(),this.onCanvasBlurObservable.clear(),this.onCanvasFocusObservable.clear(),this.onCanvasPointerOutObservable.clear(),this.onBeginFrameObservable.clear(),this.onEndFrameObservable.clear(),h.a.ResetCache();for(var i=0,r=this._activeRequests;i<r.length;i++){r[i].abort()}},e.prototype.displayLoadingUI=function(){if(m.a.IsWindowObjectExist()){var e=this.loadingScreen;e&&e.displayLoadingUI()}},e.prototype.hideLoadingUI=function(){if(m.a.IsWindowObjectExist()){var e=this.loadingScreen;e&&e.hideLoadingUI()}},Object.defineProperty(e.prototype,"loadingScreen",{get:function(){return!this._loadingScreen&&this._renderingCanvas&&(this._loadingScreen=e.DefaultLoadingScreenFactory(this._renderingCanvas)),this._loadingScreen},set:function(e){this._loadingScreen=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"loadingUIText",{set:function(e){this.loadingScreen.loadingUIText=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"loadingUIBackgroundColor",{set:function(e){this.loadingScreen.loadingUIBackgroundColor=e},enumerable:!0,configurable:!0}),e.prototype.attachContextLostEvent=function(e){this._renderingCanvas&&this._renderingCanvas.addEventListener("webglcontextlost",e,!1)},e.prototype.attachContextRestoredEvent=function(e){this._renderingCanvas&&this._renderingCanvas.addEventListener("webglcontextrestored",e,!1)},e.prototype.getVertexShaderSource=function(e){var t=this._gl.getAttachedShaders(e);return t?this._gl.getShaderSource(t[0]):null},e.prototype.getFragmentShaderSource=function(e){var t=this._gl.getAttachedShaders(e);return t?this._gl.getShaderSource(t[1]):null},e.prototype.getError=function(){return this._gl.getError()},e.prototype.getFps=function(){return this._fps},e.prototype.getDeltaTime=function(){return this._deltaTime},e.prototype._measureFps=function(){this._performanceMonitor.sampleFrame(),this._fps=this._performanceMonitor.averageFPS,this._deltaTime=this._performanceMonitor.instantaneousFrameTime||0},e.prototype._readTexturePixels=function(e,t,i,r,n,o){void 0===r&&(r=-1),void 0===n&&(n=0),void 0===o&&(o=null);var s=this._gl;if(!this._dummyFramebuffer){var a=s.createFramebuffer();if(!a)throw new Error("Unable to create dummy framebuffer");this._dummyFramebuffer=a}s.bindFramebuffer(s.FRAMEBUFFER,this._dummyFramebuffer),r>-1?s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+r,e._webGLTexture,n):s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,e._webGLTexture,n);var c=void 0!==e.type?this._getWebGLTextureType(e.type):s.UNSIGNED_BYTE;switch(c){case s.UNSIGNED_BYTE:o||(o=new Uint8Array(4*t*i)),c=s.UNSIGNED_BYTE;break;default:o||(o=new Float32Array(4*t*i)),c=s.FLOAT}return s.readPixels(0,0,t,i,s.RGBA,c,o),s.bindFramebuffer(s.FRAMEBUFFER,this._currentFramebuffer),o},e.prototype._canRenderToFloatFramebuffer=function(){return this._webGLVersion>1?this._caps.colorBufferFloat:this._canRenderToFramebuffer(e.TEXTURETYPE_FLOAT)},e.prototype._canRenderToHalfFloatFramebuffer=function(){return this._webGLVersion>1?this._caps.colorBufferFloat:this._canRenderToFramebuffer(e.TEXTURETYPE_HALF_FLOAT)},e.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 o=t.checkFramebufferStatus(t.FRAMEBUFFER);if((i=(i=i&&o===t.FRAMEBUFFER_COMPLETE)&&t.getError()===t.NO_ERROR)&&(t.clear(t.COLOR_BUFFER_BIT),i=i&&t.getError()===t.NO_ERROR),i){t.bindFramebuffer(t.FRAMEBUFFER,null);var s=t.RGBA,a=t.UNSIGNED_BYTE,c=new Uint8Array(4);t.readPixels(0,0,1,1,s,a,c),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},e.prototype._getWebGLTextureType=function(t){if(1===this._webGLVersion){switch(t){case e.TEXTURETYPE_FLOAT:return this._gl.FLOAT;case e.TEXTURETYPE_HALF_FLOAT:return this._gl.HALF_FLOAT_OES;case e.TEXTURETYPE_UNSIGNED_BYTE:return this._gl.UNSIGNED_BYTE}return this._gl.UNSIGNED_BYTE}switch(t){case e.TEXTURETYPE_BYTE:return this._gl.BYTE;case e.TEXTURETYPE_UNSIGNED_BYTE:return this._gl.UNSIGNED_BYTE;case e.TEXTURETYPE_SHORT:return this._gl.SHORT;case e.TEXTURETYPE_UNSIGNED_SHORT:return this._gl.UNSIGNED_SHORT;case e.TEXTURETYPE_INT:return this._gl.INT;case e.TEXTURETYPE_UNSIGNED_INTEGER:return this._gl.UNSIGNED_INT;case e.TEXTURETYPE_FLOAT:return this._gl.FLOAT;case e.TEXTURETYPE_HALF_FLOAT:return this._gl.HALF_FLOAT;case e.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:return this._gl.UNSIGNED_SHORT_4_4_4_4;case e.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:return this._gl.UNSIGNED_SHORT_5_5_5_1;case e.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:return this._gl.UNSIGNED_SHORT_5_6_5;case e.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:return this._gl.UNSIGNED_INT_2_10_10_10_REV;case e.TEXTURETYPE_UNSIGNED_INT_24_8:return this._gl.UNSIGNED_INT_24_8;case e.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:return this._gl.UNSIGNED_INT_10F_11F_11F_REV;case e.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:return this._gl.UNSIGNED_INT_5_9_9_9_REV;case e.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV:return this._gl.FLOAT_32_UNSIGNED_INT_24_8_REV}return this._gl.UNSIGNED_BYTE},e.prototype._getInternalFormat=function(t){var i=this._gl.RGBA;switch(t){case e.TEXTUREFORMAT_ALPHA:i=this._gl.ALPHA;break;case e.TEXTUREFORMAT_LUMINANCE:i=this._gl.LUMINANCE;break;case e.TEXTUREFORMAT_LUMINANCE_ALPHA:i=this._gl.LUMINANCE_ALPHA;break;case e.TEXTUREFORMAT_RED:i=this._gl.RED;break;case e.TEXTUREFORMAT_RG:i=this._gl.RG;break;case e.TEXTUREFORMAT_RGB:i=this._gl.RGB;break;case e.TEXTUREFORMAT_RGBA:i=this._gl.RGBA}if(this._webGLVersion>1)switch(t){case e.TEXTUREFORMAT_RED_INTEGER:i=this._gl.RED_INTEGER;break;case e.TEXTUREFORMAT_RG_INTEGER:i=this._gl.RG_INTEGER;break;case e.TEXTUREFORMAT_RGB_INTEGER:i=this._gl.RGB_INTEGER;break;case e.TEXTUREFORMAT_RGBA_INTEGER:i=this._gl.RGBA_INTEGER}return i},e.prototype._getRGBABufferInternalSizedFormat=function(t,i){if(1===this._webGLVersion){if(void 0!==i)switch(i){case e.TEXTUREFORMAT_ALPHA:return this._gl.ALPHA;case e.TEXTUREFORMAT_LUMINANCE:return this._gl.LUMINANCE;case e.TEXTUREFORMAT_LUMINANCE_ALPHA:return this._gl.LUMINANCE_ALPHA}return this._gl.RGBA}switch(t){case e.TEXTURETYPE_BYTE:switch(i){case e.TEXTUREFORMAT_RED:return this._gl.R8_SNORM;case e.TEXTUREFORMAT_RG:return this._gl.RG8_SNORM;case e.TEXTUREFORMAT_RGB:return this._gl.RGB8_SNORM;case e.TEXTUREFORMAT_RED_INTEGER:return this._gl.R8I;case e.TEXTUREFORMAT_RG_INTEGER:return this._gl.RG8I;case e.TEXTUREFORMAT_RGB_INTEGER:return this._gl.RGB8I;case e.TEXTUREFORMAT_RGBA_INTEGER:return this._gl.RGBA8I;default:return this._gl.RGBA8_SNORM}case e.TEXTURETYPE_UNSIGNED_BYTE:switch(i){case e.TEXTUREFORMAT_RED:return this._gl.R8;case e.TEXTUREFORMAT_RG:return this._gl.RG8;case e.TEXTUREFORMAT_RGB:return this._gl.RGB8;case e.TEXTUREFORMAT_RGBA:return this._gl.RGBA8;case e.TEXTUREFORMAT_RED_INTEGER:return this._gl.R8UI;case e.TEXTUREFORMAT_RG_INTEGER:return this._gl.RG8UI;case e.TEXTUREFORMAT_RGB_INTEGER:return this._gl.RGB8UI;case e.TEXTUREFORMAT_RGBA_INTEGER:return this._gl.RGBA8UI;default:return this._gl.RGBA8}case e.TEXTURETYPE_SHORT:switch(i){case e.TEXTUREFORMAT_RED_INTEGER:return this._gl.R16I;case e.TEXTUREFORMAT_RG_INTEGER:return this._gl.RG16I;case e.TEXTUREFORMAT_RGB_INTEGER:return this._gl.RGB16I;case e.TEXTUREFORMAT_RGBA_INTEGER:default:return this._gl.RGBA16I}case e.TEXTURETYPE_UNSIGNED_SHORT:switch(i){case e.TEXTUREFORMAT_RED_INTEGER:return this._gl.R16UI;case e.TEXTUREFORMAT_RG_INTEGER:return this._gl.RG16UI;case e.TEXTUREFORMAT_RGB_INTEGER:return this._gl.RGB16UI;case e.TEXTUREFORMAT_RGBA_INTEGER:default:return this._gl.RGBA16UI}case e.TEXTURETYPE_INT:switch(i){case e.TEXTUREFORMAT_RED_INTEGER:return this._gl.R32I;case e.TEXTUREFORMAT_RG_INTEGER:return this._gl.RG32I;case e.TEXTUREFORMAT_RGB_INTEGER:return this._gl.RGB32I;case e.TEXTUREFORMAT_RGBA_INTEGER:default:return this._gl.RGBA32I}case e.TEXTURETYPE_UNSIGNED_INTEGER:switch(i){case e.TEXTUREFORMAT_RED_INTEGER:return this._gl.R32UI;case e.TEXTUREFORMAT_RG_INTEGER:return this._gl.RG32UI;case e.TEXTUREFORMAT_RGB_INTEGER:return this._gl.RGB32UI;case e.TEXTUREFORMAT_RGBA_INTEGER:default:return this._gl.RGBA32UI}case e.TEXTURETYPE_FLOAT:switch(i){case e.TEXTUREFORMAT_RED:return this._gl.R32F;case e.TEXTUREFORMAT_RG:return this._gl.RG32F;case e.TEXTUREFORMAT_RGB:return this._gl.RGB32F;case e.TEXTUREFORMAT_RGBA:default:return this._gl.RGBA32F}case e.TEXTURETYPE_HALF_FLOAT:switch(i){case e.TEXTUREFORMAT_RED:return this._gl.R16F;case e.TEXTUREFORMAT_RG:return this._gl.RG16F;case e.TEXTUREFORMAT_RGB:return this._gl.RGB16F;case e.TEXTUREFORMAT_RGBA:default:return this._gl.RGBA16F}case e.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:return this._gl.RGB565;case e.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:return this._gl.R11F_G11F_B10F;case e.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:return this._gl.RGB9_E5;case e.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:return this._gl.RGBA4;case e.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:return this._gl.RGB5_A1;case e.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:switch(i){case e.TEXTUREFORMAT_RGBA:return this._gl.RGB10_A2;case e.TEXTUREFORMAT_RGBA_INTEGER:return this._gl.RGB10_A2UI;default:return this._gl.RGB10_A2}}return this._gl.RGBA8},e.prototype._getRGBAMultiSampleBufferFormat=function(t){return t===e.TEXTURETYPE_FLOAT?this._gl.RGBA32F:t===e.TEXTURETYPE_HALF_FLOAT?this._gl.RGBA16F:this._gl.RGBA8},e.prototype._loadFile=function(e,t,i,r,n,o){var s=this,a=c.h.LoadFile(e,t,i,r,n,o);return this._activeRequests.push(a),a.onCompleteObservable.add(function(e){s._activeRequests.splice(s._activeRequests.indexOf(e),1)}),a},e.prototype._loadFileAsync=function(e,t,i){var r=this;return new Promise(function(n,o){r._loadFile(e,function(e){n(e)},void 0,t,i,function(e,t){o(t)})})},e.prototype._partialLoadFile=function(e,t,i,r,n){void 0===n&&(n=null);this._loadFile(e,function(e){i[t]=e,i._internalCount++,6===i._internalCount&&r(i)},void 0,void 0,!0,function(e,t){n&&e&&n(e.status+" "+e.statusText,t)})},e.prototype._cascadeLoadFiles=function(e,t,i,r){void 0===r&&(r=null);var n=[];n._internalCount=0;for(var o=0;o<6;o++)this._partialLoadFile(i[o],o,n,t,r)},e.isSupported=function(){try{var e=document.createElement("canvas");return null!=(e.getContext("webgl")||e.getContext("experimental-webgl"))&&!!window.WebGLRenderingContext}catch(e){return!1}},e.ExceptionList=[{key:"Chrome/63.0",capture:"63\\.0\\.3239\\.(\\d+)",captureConstraint:108,targets:["uniformBuffer"]},{key:"Firefox/58",capture:null,captureConstraint:null,targets:["uniformBuffer"]},{key:"Firefox/59",capture:null,captureConstraint:null,targets:["uniformBuffer"]},{key:"Macintosh",capture:null,captureConstraint:null,targets:["textureBindingOptimization"]},{key:"iPhone",capture:null,captureConstraint:null,targets:["textureBindingOptimization"]},{key:"iPad",capture:null,captureConstraint:null,targets:["textureBindingOptimization"]}],e._TextureLoaders=[],e.ALPHA_DISABLE=g.a.ALPHA_DISABLE,e.ALPHA_ADD=g.a.ALPHA_ADD,e.ALPHA_COMBINE=g.a.ALPHA_COMBINE,e.ALPHA_SUBTRACT=g.a.ALPHA_SUBTRACT,e.ALPHA_MULTIPLY=g.a.ALPHA_MULTIPLY,e.ALPHA_MAXIMIZED=g.a.ALPHA_MAXIMIZED,e.ALPHA_ONEONE=g.a.ALPHA_ONEONE,e.ALPHA_PREMULTIPLIED=g.a.ALPHA_PREMULTIPLIED,e.ALPHA_PREMULTIPLIED_PORTERDUFF=g.a.ALPHA_PREMULTIPLIED_PORTERDUFF,e.ALPHA_INTERPOLATE=g.a.ALPHA_INTERPOLATE,e.ALPHA_SCREENMODE=g.a.ALPHA_SCREENMODE,e.DELAYLOADSTATE_NONE=g.a.DELAYLOADSTATE_NONE,e.DELAYLOADSTATE_LOADED=g.a.DELAYLOADSTATE_LOADED,e.DELAYLOADSTATE_LOADING=g.a.DELAYLOADSTATE_LOADING,e.DELAYLOADSTATE_NOTLOADED=g.a.DELAYLOADSTATE_NOTLOADED,e.NEVER=g.a.NEVER,e.ALWAYS=g.a.ALWAYS,e.LESS=g.a.LESS,e.EQUAL=g.a.EQUAL,e.LEQUAL=g.a.LEQUAL,e.GREATER=g.a.GREATER,e.GEQUAL=g.a.GEQUAL,e.NOTEQUAL=g.a.NOTEQUAL,e.KEEP=g.a.KEEP,e.REPLACE=g.a.REPLACE,e.INCR=g.a.INCR,e.DECR=g.a.DECR,e.INVERT=g.a.INVERT,e.INCR_WRAP=g.a.INCR_WRAP,e.DECR_WRAP=g.a.DECR_WRAP,e.TEXTURE_CLAMP_ADDRESSMODE=g.a.TEXTURE_CLAMP_ADDRESSMODE,e.TEXTURE_WRAP_ADDRESSMODE=g.a.TEXTURE_WRAP_ADDRESSMODE,e.TEXTURE_MIRROR_ADDRESSMODE=g.a.TEXTURE_MIRROR_ADDRESSMODE,e.TEXTUREFORMAT_ALPHA=g.a.TEXTUREFORMAT_ALPHA,e.TEXTUREFORMAT_LUMINANCE=g.a.TEXTUREFORMAT_LUMINANCE,e.TEXTUREFORMAT_LUMINANCE_ALPHA=g.a.TEXTUREFORMAT_LUMINANCE_ALPHA,e.TEXTUREFORMAT_RGB=g.a.TEXTUREFORMAT_RGB,e.TEXTUREFORMAT_RGBA=g.a.TEXTUREFORMAT_RGBA,e.TEXTUREFORMAT_RED=g.a.TEXTUREFORMAT_RED,e.TEXTUREFORMAT_R=g.a.TEXTUREFORMAT_R,e.TEXTUREFORMAT_RG=g.a.TEXTUREFORMAT_RG,e.TEXTUREFORMAT_RED_INTEGER=g.a.TEXTUREFORMAT_RED_INTEGER,e.TEXTUREFORMAT_R_INTEGER=g.a.TEXTUREFORMAT_R_INTEGER,e.TEXTUREFORMAT_RG_INTEGER=g.a.TEXTUREFORMAT_RG_INTEGER,e.TEXTUREFORMAT_RGB_INTEGER=g.a.TEXTUREFORMAT_RGB_INTEGER,e.TEXTUREFORMAT_RGBA_INTEGER=g.a.TEXTUREFORMAT_RGBA_INTEGER,e.TEXTURETYPE_UNSIGNED_BYTE=g.a.TEXTURETYPE_UNSIGNED_BYTE,e.TEXTURETYPE_UNSIGNED_INT=g.a.TEXTURETYPE_UNSIGNED_INT,e.TEXTURETYPE_FLOAT=g.a.TEXTURETYPE_FLOAT,e.TEXTURETYPE_HALF_FLOAT=g.a.TEXTURETYPE_HALF_FLOAT,e.TEXTURETYPE_BYTE=g.a.TEXTURETYPE_BYTE,e.TEXTURETYPE_SHORT=g.a.TEXTURETYPE_SHORT,e.TEXTURETYPE_UNSIGNED_SHORT=g.a.TEXTURETYPE_UNSIGNED_SHORT,e.TEXTURETYPE_INT=g.a.TEXTURETYPE_INT,e.TEXTURETYPE_UNSIGNED_INTEGER=g.a.TEXTURETYPE_UNSIGNED_INTEGER,e.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4=g.a.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4,e.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1=g.a.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1,e.TEXTURETYPE_UNSIGNED_SHORT_5_6_5=g.a.TEXTURETYPE_UNSIGNED_SHORT_5_6_5,e.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV=g.a.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV,e.TEXTURETYPE_UNSIGNED_INT_24_8=g.a.TEXTURETYPE_UNSIGNED_INT_24_8,e.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV=g.a.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV,e.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV=g.a.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV,e.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV=g.a.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV,e.TEXTURE_NEAREST_SAMPLINGMODE=g.a.TEXTURE_NEAREST_SAMPLINGMODE,e.TEXTURE_BILINEAR_SAMPLINGMODE=g.a.TEXTURE_BILINEAR_SAMPLINGMODE,e.TEXTURE_TRILINEAR_SAMPLINGMODE=g.a.TEXTURE_TRILINEAR_SAMPLINGMODE,e.TEXTURE_NEAREST_NEAREST_MIPLINEAR=g.a.TEXTURE_NEAREST_NEAREST_MIPLINEAR,e.TEXTURE_LINEAR_LINEAR_MIPNEAREST=g.a.TEXTURE_LINEAR_LINEAR_MIPNEAREST,e.TEXTURE_LINEAR_LINEAR_MIPLINEAR=g.a.TEXTURE_LINEAR_LINEAR_MIPLINEAR,e.TEXTURE_NEAREST_NEAREST_MIPNEAREST=g.a.TEXTURE_NEAREST_NEAREST_MIPNEAREST,e.TEXTURE_NEAREST_LINEAR_MIPNEAREST=g.a.TEXTURE_NEAREST_LINEAR_MIPNEAREST,e.TEXTURE_NEAREST_LINEAR_MIPLINEAR=g.a.TEXTURE_NEAREST_LINEAR_MIPLINEAR,e.TEXTURE_NEAREST_LINEAR=g.a.TEXTURE_NEAREST_LINEAR,e.TEXTURE_NEAREST_NEAREST=g.a.TEXTURE_NEAREST_NEAREST,e.TEXTURE_LINEAR_NEAREST_MIPNEAREST=g.a.TEXTURE_LINEAR_NEAREST_MIPNEAREST,e.TEXTURE_LINEAR_NEAREST_MIPLINEAR=g.a.TEXTURE_LINEAR_NEAREST_MIPLINEAR,e.TEXTURE_LINEAR_LINEAR=g.a.TEXTURE_LINEAR_LINEAR,e.TEXTURE_LINEAR_NEAREST=g.a.TEXTURE_LINEAR_NEAREST,e.TEXTURE_EXPLICIT_MODE=g.a.TEXTURE_EXPLICIT_MODE,e.TEXTURE_SPHERICAL_MODE=g.a.TEXTURE_SPHERICAL_MODE,e.TEXTURE_PLANAR_MODE=g.a.TEXTURE_PLANAR_MODE,e.TEXTURE_CUBIC_MODE=g.a.TEXTURE_CUBIC_MODE,e.TEXTURE_PROJECTION_MODE=g.a.TEXTURE_PROJECTION_MODE,e.TEXTURE_SKYBOX_MODE=g.a.TEXTURE_SKYBOX_MODE,e.TEXTURE_INVCUBIC_MODE=g.a.TEXTURE_INVCUBIC_MODE,e.TEXTURE_EQUIRECTANGULAR_MODE=g.a.TEXTURE_EQUIRECTANGULAR_MODE,e.TEXTURE_FIXED_EQUIRECTANGULAR_MODE=g.a.TEXTURE_FIXED_EQUIRECTANGULAR_MODE,e.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE=g.a.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE,e.SCALEMODE_FLOOR=g.a.SCALEMODE_FLOOR,e.SCALEMODE_NEAREST=g.a.SCALEMODE_NEAREST,e.SCALEMODE_CEILING=g.a.SCALEMODE_CEILING,e.CollisionsEpsilon=.001,e._RescalePostProcessFactory=null,e}()},function(e,t,i){"use strict";i.d(t,"a",function(){return r});var r=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 0===(e=+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.Log2=function(e){return Math.log(e)*Math.LOG2E},e.Repeat=function(e,t){return e-Math.floor(e/t)*t},e.Normalize=function(e,t,i){return(e-t)/(i-t)},e.Denormalize=function(e,t,i){return e*(i-t)+t},e.DeltaAngle=function(t,i){var r=e.Repeat(i-t,360);return r>180&&(r-=360),r},e.PingPong=function(t,i){var r=e.Repeat(t,2*i);return i-Math.abs(r-i)},e.SmoothStep=function(t,i,r){var n=e.Clamp(r);return i*(n=-2*n*n*n+3*n*n)+t*(1-n)},e.MoveTowards=function(t,i,r){return Math.abs(i-t)<=r?i:t+e.Sign(i-t)*r},e.MoveTowardsAngle=function(t,i,r){var n=e.DeltaAngle(t,i),o=0;return-r<n&&n<r?o=i:(i=t+n,o=e.MoveTowards(t,i,r)),o},e.Lerp=function(e,t,i){return e+(t-e)*i},e.LerpAngle=function(t,i,r){var n=e.Repeat(i-t,360);return n>180&&(n-=360),t+n*e.Clamp(r)},e.InverseLerp=function(t,i,r){return t!=i?e.Clamp((r-t)/(i-t)):0},e.Hermite=function(e,t,i,r,n){var o=n*n,s=n*o;return e*(2*s-3*o+1)+i*(-2*s+3*o)+t*(s-2*o+n)+r*(s-o)},e.RandomRange=function(e,t){return e===t?e:Math.random()*(t-e)+e},e.RangeToPercent=function(e,t,i){return(e-t)/(i-t)},e.PercentToRange=function(e,t,i){return(i-t)*e+t},e.NormalizeRadians=function(t){return t-=e.TwoPi*Math.floor((t+Math.PI)/e.TwoPi)},e.TwoPi=2*Math.PI,e}()},function(e,t,i){"use strict";i.d(t,"a",function(){return o});var r=i(0),n=i(4),o=function(){function e(){}return e.prototype.set=function(e,t){switch(t){case n.b.PositionKind:this.positions=e;break;case n.b.NormalKind:this.normals=e;break;case n.b.TangentKind:this.tangents=e;break;case n.b.UVKind:this.uvs=e;break;case n.b.UV2Kind:this.uvs2=e;break;case n.b.UV3Kind:this.uvs3=e;break;case n.b.UV4Kind:this.uvs4=e;break;case n.b.UV5Kind:this.uvs5=e;break;case n.b.UV6Kind:this.uvs6=e;break;case n.b.ColorKind:this.colors=e;break;case n.b.MatricesIndicesKind:this.matricesIndices=e;break;case n.b.MatricesWeightsKind:this.matricesWeights=e;break;case n.b.MatricesIndicesExtraKind:this.matricesIndicesExtra=e;break;case n.b.MatricesWeightsExtraKind:this.matricesWeightsExtra=e}},e.prototype.applyToMesh=function(e,t){return this._applyTo(e,t),this},e.prototype.applyToGeometry=function(e,t){return this._applyTo(e,t),this},e.prototype.updateMesh=function(e){return this._update(e),this},e.prototype.updateGeometry=function(e){return this._update(e),this},e.prototype._applyTo=function(e,t){return void 0===t&&(t=!1),this.positions&&e.setVerticesData(n.b.PositionKind,this.positions,t),this.normals&&e.setVerticesData(n.b.NormalKind,this.normals,t),this.tangents&&e.setVerticesData(n.b.TangentKind,this.tangents,t),this.uvs&&e.setVerticesData(n.b.UVKind,this.uvs,t),this.uvs2&&e.setVerticesData(n.b.UV2Kind,this.uvs2,t),this.uvs3&&e.setVerticesData(n.b.UV3Kind,this.uvs3,t),this.uvs4&&e.setVerticesData(n.b.UV4Kind,this.uvs4,t),this.uvs5&&e.setVerticesData(n.b.UV5Kind,this.uvs5,t),this.uvs6&&e.setVerticesData(n.b.UV6Kind,this.uvs6,t),this.colors&&e.setVerticesData(n.b.ColorKind,this.colors,t),this.matricesIndices&&e.setVerticesData(n.b.MatricesIndicesKind,this.matricesIndices,t),this.matricesWeights&&e.setVerticesData(n.b.MatricesWeightsKind,this.matricesWeights,t),this.matricesIndicesExtra&&e.setVerticesData(n.b.MatricesIndicesExtraKind,this.matricesIndicesExtra,t),this.matricesWeightsExtra&&e.setVerticesData(n.b.MatricesWeightsExtraKind,this.matricesWeightsExtra,t),this.indices?e.setIndices(this.indices,null,t):e.setIndices([],null),this},e.prototype._update=function(e,t,i){return this.positions&&e.updateVerticesData(n.b.PositionKind,this.positions,t,i),this.normals&&e.updateVerticesData(n.b.NormalKind,this.normals,t,i),this.tangents&&e.updateVerticesData(n.b.TangentKind,this.tangents,t,i),this.uvs&&e.updateVerticesData(n.b.UVKind,this.uvs,t,i),this.uvs2&&e.updateVerticesData(n.b.UV2Kind,this.uvs2,t,i),this.uvs3&&e.updateVerticesData(n.b.UV3Kind,this.uvs3,t,i),this.uvs4&&e.updateVerticesData(n.b.UV4Kind,this.uvs4,t,i),this.uvs5&&e.updateVerticesData(n.b.UV5Kind,this.uvs5,t,i),this.uvs6&&e.updateVerticesData(n.b.UV6Kind,this.uvs6,t,i),this.colors&&e.updateVerticesData(n.b.ColorKind,this.colors,t,i),this.matricesIndices&&e.updateVerticesData(n.b.MatricesIndicesKind,this.matricesIndices,t,i),this.matricesWeights&&e.updateVerticesData(n.b.MatricesWeightsKind,this.matricesWeights,t,i),this.matricesIndicesExtra&&e.updateVerticesData(n.b.MatricesIndicesExtraKind,this.matricesIndicesExtra,t,i),this.matricesWeightsExtra&&e.updateVerticesData(n.b.MatricesWeightsExtraKind,this.matricesWeightsExtra,t,i),this.indices&&e.setIndices(this.indices,null),this},e.prototype.transform=function(e){var t,i=e.m[0]*e.m[5]*e.m[10]<0,n=r.x.Zero();if(this.positions){var o=r.x.Zero();for(t=0;t<this.positions.length;t+=3)r.x.FromArrayToRef(this.positions,t,o),r.x.TransformCoordinatesToRef(o,e,n),this.positions[t]=n.x,this.positions[t+1]=n.y,this.positions[t+2]=n.z}if(this.normals){var s=r.x.Zero();for(t=0;t<this.normals.length;t+=3)r.x.FromArrayToRef(this.normals,t,s),r.x.TransformNormalToRef(s,e,n),this.normals[t]=n.x,this.normals[t+1]=n.y,this.normals[t+2]=n.z}if(this.tangents){var a=r.y.Zero(),c=r.y.Zero();for(t=0;t<this.tangents.length;t+=4)r.y.FromArrayToRef(this.tangents,t,a),r.y.TransformNormalToRef(a,e,c),this.tangents[t]=c.x,this.tangents[t+1]=c.y,this.tangents[t+2]=c.z,this.tangents[t+3]=c.w}if(i&&this.indices)for(t=0;t<this.indices.length;t+=3){var l=this.indices[t+1];this.indices[t+1]=this.indices[t+2],this.indices[t+2]=l}return this},e.prototype.merge=function(e,t){if(void 0===t&&(t=!1),this._validate(),e._validate(),!this.normals!=!e.normals||!this.tangents!=!e.tangents||!this.uvs!=!e.uvs||!this.uvs2!=!e.uvs2||!this.uvs3!=!e.uvs3||!this.uvs4!=!e.uvs4||!this.uvs5!=!e.uvs5||!this.uvs6!=!e.uvs6||!this.colors!=!e.colors||!this.matricesIndices!=!e.matricesIndices||!this.matricesWeights!=!e.matricesWeights||!this.matricesIndicesExtra!=!e.matricesIndicesExtra||!this.matricesWeightsExtra!=!e.matricesWeightsExtra)throw new Error("Cannot merge vertex data that do not have the same set of attributes");if(e.indices){this.indices||(this.indices=[]);var i=this.positions?this.positions.length/3:0;if(void 0!==this.indices.BYTES_PER_ELEMENT){var r=this.indices.length+e.indices.length,n=t||this.indices instanceof Uint32Array?new Uint32Array(r):new Uint16Array(r);n.set(this.indices);for(var o=this.indices.length,s=0;s<e.indices.length;s++)n[o+s]=e.indices[s]+i;this.indices=n}else for(s=0;s<e.indices.length;s++)this.indices.push(e.indices[s]+i)}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},e.prototype._mergeElement=function(e,t){if(!e)return t;if(!t)return e;var i=t.length+e.length,r=e instanceof Float32Array,n=t instanceof Float32Array;if(r){var o=new Float32Array(i);return o.set(e),o.set(t,e.length),o}if(n){var s=e.slice(0),a=0;for(i=t.length;a<i;a++)s.push(t[a]);return s}return e.concat(t)},e.prototype._validate=function(){if(!this.positions)throw new Error("Positions are required");var e=function(e,t){var i=n.b.DeduceStride(e);if(t.length%i!=0)throw new Error("The "+e+"s array count must be a multiple of "+i);return t.length/i},t=e(n.b.PositionKind,this.positions),i=function(i,r){var n=e(i,r);if(n!==t)throw new Error("The "+i+"s element count ("+n+") does not match the positions count ("+t+")")};this.normals&&i(n.b.NormalKind,this.normals),this.tangents&&i(n.b.TangentKind,this.tangents),this.uvs&&i(n.b.UVKind,this.uvs),this.uvs2&&i(n.b.UV2Kind,this.uvs2),this.uvs3&&i(n.b.UV3Kind,this.uvs3),this.uvs4&&i(n.b.UV4Kind,this.uvs4),this.uvs5&&i(n.b.UV5Kind,this.uvs5),this.uvs6&&i(n.b.UV6Kind,this.uvs6),this.colors&&i(n.b.ColorKind,this.colors),this.matricesIndices&&i(n.b.MatricesIndicesKind,this.matricesIndices),this.matricesWeights&&i(n.b.MatricesWeightsKind,this.matricesWeights),this.matricesIndicesExtra&&i(n.b.MatricesIndicesExtraKind,this.matricesIndicesExtra),this.matricesWeightsExtra&&i(n.b.MatricesWeightsExtraKind,this.matricesWeightsExtra)},e.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},e.ExtractFromMesh=function(t,i,r){return e._ExtractFrom(t,i,r)},e.ExtractFromGeometry=function(t,i,r){return e._ExtractFrom(t,i,r)},e._ExtractFrom=function(t,i,r){var o=new e;return t.isVerticesDataPresent(n.b.PositionKind)&&(o.positions=t.getVerticesData(n.b.PositionKind,i,r)),t.isVerticesDataPresent(n.b.NormalKind)&&(o.normals=t.getVerticesData(n.b.NormalKind,i,r)),t.isVerticesDataPresent(n.b.TangentKind)&&(o.tangents=t.getVerticesData(n.b.TangentKind,i,r)),t.isVerticesDataPresent(n.b.UVKind)&&(o.uvs=t.getVerticesData(n.b.UVKind,i,r)),t.isVerticesDataPresent(n.b.UV2Kind)&&(o.uvs2=t.getVerticesData(n.b.UV2Kind,i,r)),t.isVerticesDataPresent(n.b.UV3Kind)&&(o.uvs3=t.getVerticesData(n.b.UV3Kind,i,r)),t.isVerticesDataPresent(n.b.UV4Kind)&&(o.uvs4=t.getVerticesData(n.b.UV4Kind,i,r)),t.isVerticesDataPresent(n.b.UV5Kind)&&(o.uvs5=t.getVerticesData(n.b.UV5Kind,i,r)),t.isVerticesDataPresent(n.b.UV6Kind)&&(o.uvs6=t.getVerticesData(n.b.UV6Kind,i,r)),t.isVerticesDataPresent(n.b.ColorKind)&&(o.colors=t.getVerticesData(n.b.ColorKind,i,r)),t.isVerticesDataPresent(n.b.MatricesIndicesKind)&&(o.matricesIndices=t.getVerticesData(n.b.MatricesIndicesKind,i,r)),t.isVerticesDataPresent(n.b.MatricesWeightsKind)&&(o.matricesWeights=t.getVerticesData(n.b.MatricesWeightsKind,i,r)),t.isVerticesDataPresent(n.b.MatricesIndicesExtraKind)&&(o.matricesIndicesExtra=t.getVerticesData(n.b.MatricesIndicesExtraKind,i,r)),t.isVerticesDataPresent(n.b.MatricesWeightsExtraKind)&&(o.matricesWeightsExtra=t.getVerticesData(n.b.MatricesWeightsExtraKind,i,r)),o.indices=t.getIndices(i,r),o},e.CreateRibbon=function(e){throw"Import Meshes/Builders/ribbonBuilder before trying to create ribbons."},e.CreateBox=function(e){throw"Import Meshes/Builders/boxBuilder before trying to create boxes."},e.CreateSphere=function(e){throw"Import Meshes/Builders/sphereBuilder before trying to create spheres."},e.CreateCylinder=function(e){throw"Import Meshes/Builders/cylinderBuilder before trying to create cylinders."},e.CreateTorus=function(e){throw"Import Meshes/Builders/torusBuilder before trying to create torus."},e.CreateLineSystem=function(e){throw"Import Meshes/Builders/linesBuilder before trying to create lines."},e.CreateDashedLines=function(e){throw"Import Meshes/Builders/linesBuilder before trying to create dashed lines."},e.CreateGround=function(e){throw"Import Meshes/Builders/groundBuilder before trying to create grounds."},e.CreateTiledGround=function(e){throw"Import Meshes/Builders/groundBuilder before trying to create grounds."},e.CreateGroundFromHeightMap=function(e){throw"Import Meshes/Builders/groundBuilder before trying to create grounds."},e.CreatePlane=function(e){throw"Import Meshes/Builders/planeBuilder before trying to create planes."},e.CreateDisc=function(e){throw"Import Meshes/Builders/discBuilder before trying to create discs."},e.CreatePolygon=function(e,t,i,r,n,o){throw"Import Meshes/Builders/polygonBuilder before trying to create polygons."},e.CreateIcoSphere=function(e){throw"Import Meshes/Builders/icoSphereBuilder before trying to create icoSpheres."},e.CreatePolyhedron=function(e){throw"Import Meshes/Builders/polyhedronBuilder before trying to create polyhedrons."},e.CreateTorusKnot=function(e){throw"Import Meshes/Builders/torusKnotBuilder before trying to create torusKnots."},e.ComputeNormals=function(e,t,i,n){var o=0,s=0,a=0,c=0,l=0,u=0,h=0,d=0,f=0,p=0,_=0,g=0,m=0,v=0,y=0,b=0,T=0,E=0,x=0,A=0,P=!1,R=!1,S=!1,C=!1,M=1,O=0,I=null;if(n&&(P=!!n.facetNormals,R=!!n.facetPositions,S=!!n.facetPartitioning,M=!0===n.useRightHandedSystem?-1:1,O=n.ratio||0,C=!!n.depthSort,I=n.distanceTo,C)){void 0===I&&(I=r.x.Zero());var D=n.depthSortedFacets}var w=0,L=0,F=0,N=0;if(S&&n&&n.bbSize){var B=0,U=0,V=0,G=0,k=0,z=0,j=0,W=0,H=0,X=0,Y=0,K=0,Q=0,q=0,Z=0,J=0,$=n.bbSize.x>n.bbSize.y?n.bbSize.x:n.bbSize.y;$=$>n.bbSize.z?$:n.bbSize.z,w=n.subDiv.X*O/n.bbSize.x,L=n.subDiv.Y*O/n.bbSize.y,F=n.subDiv.Z*O/n.bbSize.z,N=n.subDiv.max*n.subDiv.max,n.facetPartitioning.length=0}for(o=0;o<e.length;o++)i[o]=0;var ee=t.length/3|0;for(o=0;o<ee;o++){if(m=(g=3*t[3*o])+1,v=g+2,b=(y=3*t[3*o+1])+1,T=y+2,x=(E=3*t[3*o+2])+1,A=E+2,s=e[g]-e[y],a=e[m]-e[b],c=e[v]-e[T],l=e[E]-e[y],u=e[x]-e[b],d=M*(a*(h=e[A]-e[T])-c*u),f=M*(c*l-s*h),p=M*(s*u-a*l),d/=_=0===(_=Math.sqrt(d*d+f*f+p*p))?1:_,f/=_,p/=_,P&&n&&(n.facetNormals[o].x=d,n.facetNormals[o].y=f,n.facetNormals[o].z=p),R&&n&&(n.facetPositions[o].x=(e[g]+e[y]+e[E])/3,n.facetPositions[o].y=(e[m]+e[b]+e[x])/3,n.facetPositions[o].z=(e[v]+e[T]+e[A])/3),S&&n&&(B=Math.floor((n.facetPositions[o].x-n.bInfo.minimum.x*O)*w),U=Math.floor((n.facetPositions[o].y-n.bInfo.minimum.y*O)*L),V=Math.floor((n.facetPositions[o].z-n.bInfo.minimum.z*O)*F),G=Math.floor((e[g]-n.bInfo.minimum.x*O)*w),k=Math.floor((e[m]-n.bInfo.minimum.y*O)*L),z=Math.floor((e[v]-n.bInfo.minimum.z*O)*F),j=Math.floor((e[y]-n.bInfo.minimum.x*O)*w),W=Math.floor((e[b]-n.bInfo.minimum.y*O)*L),H=Math.floor((e[T]-n.bInfo.minimum.z*O)*F),X=Math.floor((e[E]-n.bInfo.minimum.x*O)*w),Y=Math.floor((e[x]-n.bInfo.minimum.y*O)*L),K=Math.floor((e[A]-n.bInfo.minimum.z*O)*F),q=G+n.subDiv.max*k+N*z,Z=j+n.subDiv.max*W+N*H,J=X+n.subDiv.max*Y+N*K,Q=B+n.subDiv.max*U+N*V,n.facetPartitioning[Q]=n.facetPartitioning[Q]?n.facetPartitioning[Q]:new Array,n.facetPartitioning[q]=n.facetPartitioning[q]?n.facetPartitioning[q]:new Array,n.facetPartitioning[Z]=n.facetPartitioning[Z]?n.facetPartitioning[Z]:new Array,n.facetPartitioning[J]=n.facetPartitioning[J]?n.facetPartitioning[J]:new Array,n.facetPartitioning[q].push(o),Z!=q&&n.facetPartitioning[Z].push(o),J!=Z&&J!=q&&n.facetPartitioning[J].push(o),Q!=q&&Q!=Z&&Q!=J&&n.facetPartitioning[Q].push(o)),C&&n&&n.facetPositions){var te=D[o];te.ind=3*o,te.sqDistance=r.x.DistanceSquared(n.facetPositions[o],I)}i[g]+=d,i[m]+=f,i[v]+=p,i[y]+=d,i[b]+=f,i[T]+=p,i[E]+=d,i[x]+=f,i[A]+=p}for(o=0;o<i.length/3;o++)d=i[3*o],f=i[3*o+1],p=i[3*o+2],d/=_=0===(_=Math.sqrt(d*d+f*f+p*p))?1:_,f/=_,p/=_,i[3*o]=d,i[3*o+1]=f,i[3*o+2]=p},e._ComputeSides=function(t,i,n,o,s,a,c){var l,u,h=n.length,d=o.length;switch(t=t||e.DEFAULTSIDE){case e.FRONTSIDE:break;case e.BACKSIDE:var f;for(l=0;l<h;l+=3)f=n[l],n[l]=n[l+2],n[l+2]=f;for(u=0;u<d;u++)o[u]=-o[u];break;case e.DOUBLESIDE:for(var p=i.length,_=p/3,g=0;g<p;g++)i[p+g]=i[g];for(l=0;l<h;l+=3)n[l+h]=n[l+2]+_,n[l+1+h]=n[l+1]+_,n[l+2+h]=n[l]+_;for(u=0;u<d;u++)o[d+u]=-o[u];var m=s.length,v=0;for(v=0;v<m;v++)s[v+m]=s[v];for(a=a||new r.y(0,0,1,1),c=c||new r.y(0,0,1,1),v=0,l=0;l<m/2;l++)s[v]=a.x+(a.z-a.x)*s[v],s[v+1]=a.y+(a.w-a.y)*s[v+1],s[v+m]=c.x+(c.z-c.x)*s[v+m],s[v+m+1]=c.y+(c.w-c.y)*s[v+m+1],v+=2}},e.ImportVertexData=function(t,i){var o=new e,s=t.positions;s&&o.set(s,n.b.PositionKind);var a=t.normals;a&&o.set(a,n.b.NormalKind);var c=t.tangents;c&&o.set(c,n.b.TangentKind);var l=t.uvs;l&&o.set(l,n.b.UVKind);var u=t.uv2s;u&&o.set(u,n.b.UV2Kind);var h=t.uv3s;h&&o.set(h,n.b.UV3Kind);var d=t.uv4s;d&&o.set(d,n.b.UV4Kind);var f=t.uv5s;f&&o.set(f,n.b.UV5Kind);var p=t.uv6s;p&&o.set(p,n.b.UV6Kind);var _=t.colors;_&&o.set(r.f.CheckColors4(_,s.length/3),n.b.ColorKind);var g=t.matricesIndices;g&&o.set(g,n.b.MatricesIndicesKind);var m=t.matricesWeights;m&&o.set(m,n.b.MatricesWeightsKind);var v=t.indices;v&&(o.indices=v),i.setAllVerticesData(o,t.updatable)},e.FRONTSIDE=0,e.BACKSIDE=1,e.DOUBLESIDE=2,e.DEFAULTSIDE=0,e}()},function(e,t,i){"use strict";i.d(t,"a",function(){return n}),i.d(t,"b",function(){return o});var r=i(1),n=function(){function e(){}return e.NAME_EFFECTLAYER="EffectLayer",e.NAME_LAYER="Layer",e.NAME_LENSFLARESYSTEM="LensFlareSystem",e.NAME_BOUNDINGBOXRENDERER="BoundingBoxRenderer",e.NAME_PARTICLESYSTEM="ParticleSystem",e.NAME_GAMEPAD="Gamepad",e.NAME_SIMPLIFICATIONQUEUE="SimplificationQueue",e.NAME_GEOMETRYBUFFERRENDERER="GeometryBufferRenderer",e.NAME_DEPTHRENDERER="DepthRenderer",e.NAME_POSTPROCESSRENDERPIPELINEMANAGER="PostProcessRenderPipelineManager",e.NAME_SPRITE="Sprite",e.NAME_OUTLINERENDERER="Outline",e.NAME_PROCEDURALTEXTURE="ProceduralTexture",e.NAME_SHADOWGENERATOR="ShadowGenerator",e.NAME_OCTREE="Octree",e.NAME_PHYSICSENGINE="PhysicsEngine",e.NAME_AUDIO="Audio",e.STEP_ISREADYFORMESH_EFFECTLAYER=0,e.STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER=0,e.STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER=0,e.STEP_ACTIVEMESH_BOUNDINGBOXRENDERER=0,e.STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER=1,e.STEP_BEFORECAMERADRAW_EFFECTLAYER=0,e.STEP_BEFORECAMERADRAW_LAYER=1,e.STEP_BEFORERENDERTARGETDRAW_LAYER=0,e.STEP_BEFORERENDERINGMESH_OUTLINE=0,e.STEP_AFTERRENDERINGMESH_OUTLINE=0,e.STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW=0,e.STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER=1,e.STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE=0,e.STEP_BEFORECAMERAUPDATE_GAMEPAD=1,e.STEP_BEFORECLEAR_PROCEDURALTEXTURE=0,e.STEP_AFTERRENDERTARGETDRAW_LAYER=0,e.STEP_AFTERCAMERADRAW_EFFECTLAYER=0,e.STEP_AFTERCAMERADRAW_LENSFLARESYSTEM=1,e.STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW=2,e.STEP_AFTERCAMERADRAW_LAYER=3,e.STEP_AFTERRENDER_AUDIO=0,e.STEP_GATHERRENDERTARGETS_SHADOWGENERATOR=0,e.STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER=1,e.STEP_GATHERRENDERTARGETS_DEPTHRENDERER=2,e.STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER=3,e.STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER=0,e.STEP_POINTERMOVE_SPRITE=0,e.STEP_POINTERDOWN_SPRITE=0,e.STEP_POINTERUP_SPRITE=0,e}(),o=function(e){function t(t){return e.apply(this,t)||this}return r.d(t,e),t.Create=function(){return Object.create(t.prototype)},t.prototype.registerStep=function(e,t,i){var r=0;for(Number.MAX_VALUE;r<this.length;r++){if(e<this[r].index)break}this.splice(r,0,{index:e,component:t,action:i.bind(t)})},t.prototype.clear=function(){this.length=0},t}(Array)},function(e,t,i){"use strict";i.d(t,"a",function(){return o}),i.d(t,"c",function(){return s}),i.d(t,"d",function(){return a}),i.d(t,"b",function(){return c});var r=i(1),n=i(0),o=function(){function e(){}return e.POINTERDOWN=1,e.POINTERUP=2,e.POINTERMOVE=4,e.POINTERWHEEL=8,e.POINTERPICK=16,e.POINTERTAP=32,e.POINTERDOUBLETAP=64,e}(),s=function(){return function(e,t){this.type=e,this.event=t}}(),a=function(e){function t(t,i,r,o){var s=e.call(this,t,i)||this;return s.ray=null,s.skipOnPointerObservable=!1,s.localPosition=new n.w(r,o),s}return r.d(t,e),t}(s),c=function(e){function t(t,i,r){var n=e.call(this,t,i)||this;return n.pickInfo=r,n}return r.d(t,e),t}(s)},function(e,t,i){"use strict";i.d(t,"a",function(){return l});var r=i(8),n=i(17),o=i(0),s=i(22),a=i(4),c=i(39),l=function(){function e(){}return e.BindEyePosition=function(e,t){t._forcedViewPosition?e.setVector3("vEyePosition",t._forcedViewPosition):e.setVector3("vEyePosition",t._mirroredCameraPosition?t._mirroredCameraPosition:t.activeCamera.globalPosition)},e.PrepareDefinesForMergedUV=function(e,t,i){t._needUVs=!0,t[i]=!0,e.getTextureMatrix().isIdentityAs3x2()?(t[i+"DIRECTUV"]=e.coordinatesIndex+1,0===e.coordinatesIndex?t.MAINUV1=!0:t.MAINUV2=!0):t[i+"DIRECTUV"]=0},e.BindTextureMatrix=function(e,t,i){var r=e.getTextureMatrix();r.isIdentityAs3x2()||t.updateMatrix(i+"Matrix",r)},e.PrepareDefinesForMisc=function(e,t,i,r,o,s,a){a._areMiscDirty&&(a.LOGARITHMICDEPTH=i,a.POINTSIZE=r,a.FOG=t.fogEnabled&&e.applyFog&&t.fogMode!==n.a.FOGMODE_NONE&&o,a.NONUNIFORMSCALING=e.nonUniformScaling,a.ALPHATEST=s)},e.PrepareDefinesForFrameBoundValues=function(e,t,i,r,n){void 0===n&&(n=null);var o,s,a,c,l=!1;o=null==n?void 0!==e.clipPlane&&null!==e.clipPlane:n,s=null==n?void 0!==e.clipPlane2&&null!==e.clipPlane2:n,a=null==n?void 0!==e.clipPlane3&&null!==e.clipPlane3:n,c=null==n?void 0!==e.clipPlane4&&null!==e.clipPlane4:n,i.CLIPPLANE!==o&&(i.CLIPPLANE=o,l=!0),i.CLIPPLANE2!==s&&(i.CLIPPLANE2=s,l=!0),i.CLIPPLANE3!==a&&(i.CLIPPLANE3=a,l=!0),i.CLIPPLANE4!==c&&(i.CLIPPLANE4=c,l=!0),i.DEPTHPREPASS!==!t.getColorWrite()&&(i.DEPTHPREPASS=!i.DEPTHPREPASS,l=!0),i.INSTANCES!==r&&(i.INSTANCES=r,l=!0),l&&i.markAsUnprocessed()},e.PrepareDefinesForAttributes=function(e,t,i,r,n,o){if(void 0===n&&(n=!1),void 0===o&&(o=!0),!t._areAttributesDirty&&t._needNormals===t._normals&&t._needUVs===t._uvs)return!1;if(t._normals=t._needNormals,t._uvs=t._needUVs,t.NORMAL=t._needNormals&&e.isVerticesDataPresent(a.b.NormalKind),t._needNormals&&e.isVerticesDataPresent(a.b.TangentKind)&&(t.TANGENT=!0),t._needUVs?(t.UV1=e.isVerticesDataPresent(a.b.UVKind),t.UV2=e.isVerticesDataPresent(a.b.UV2Kind)):(t.UV1=!1,t.UV2=!1),i){var s=e.useVertexColors&&e.isVerticesDataPresent(a.b.ColorKind);t.VERTEXCOLOR=s,t.VERTEXALPHA=e.hasVertexAlpha&&s&&o}if(r)if(e.useBones&&e.computeBonesUsingShaders&&e.skeleton){t.NUM_BONE_INFLUENCERS=e.numBoneInfluencers;var c=void 0!==t.BONETEXTURE;e.skeleton.isUsingTextureForMatrices&&c?t.BONETEXTURE=!0:(t.BonesPerMesh=e.skeleton.bones.length+1,t.BONETEXTURE=!c&&void 0)}else t.NUM_BONE_INFLUENCERS=0,t.BonesPerMesh=0;if(n){var l=e.morphTargetManager;l?(t.MORPHTARGETS_TANGENT=l.supportsTangents&&t.TANGENT,t.MORPHTARGETS_NORMAL=l.supportsNormals&&t.NORMAL,t.MORPHTARGETS=l.numInfluencers>0,t.NUM_MORPH_INFLUENCERS=l.numInfluencers):(t.MORPHTARGETS_TANGENT=!1,t.MORPHTARGETS_NORMAL=!1,t.MORPHTARGETS=!1,t.NUM_MORPH_INFLUENCERS=0)}return!0},e.PrepareDefinesForLights=function(e,t,i,r,n,o){if(void 0===n&&(n=4),void 0===o&&(o=!1),!i._areLightsDirty)return i._needNormals;var s=0,a=!1,l=!1,u=!1,h=!1,d=!1;if(e.lightsEnabled&&!o)for(var f=0,p=t._lightSources;f<p.length;f++){var _=p[f];switch(a=!0,void 0===i["LIGHT"+s]&&(l=!0),i["LIGHT"+s]=!0,i["SPOTLIGHT"+s]=!1,i["HEMILIGHT"+s]=!1,i["POINTLIGHT"+s]=!1,i["DIRLIGHT"+s]=!1,_.prepareLightSpecificDefines(i,s),i["LIGHT_FALLOFF_PHYSICAL"+s]=!1,i["LIGHT_FALLOFF_GLTF"+s]=!1,i["LIGHT_FALLOFF_STANDARD"+s]=!1,_.falloffType){case c.a.FALLOFF_GLTF:i["LIGHT_FALLOFF_GLTF"+s]=!0;break;case c.a.FALLOFF_PHYSICAL:i["LIGHT_FALLOFF_PHYSICAL"+s]=!0;break;case c.a.FALLOFF_STANDARD:i["LIGHT_FALLOFF_STANDARD"+s]=!0}if(r&&!_.specular.equalsFloats(0,0,0)&&(d=!0),i["SHADOW"+s]=!1,i["SHADOWPCF"+s]=!1,i["SHADOWPCSS"+s]=!1,i["SHADOWPOISSON"+s]=!1,i["SHADOWESM"+s]=!1,i["SHADOWCUBE"+s]=!1,i["SHADOWLOWQUALITY"+s]=!1,i["SHADOWMEDIUMQUALITY"+s]=!1,t&&t.receiveShadows&&e.shadowsEnabled&&_.shadowEnabled){var g=_.getShadowGenerator();if(g){var m=g.getShadowMap();m&&m.renderList&&m.renderList.length>0&&(h=!0,g.prepareDefines(i,s))}}if(_.lightmapMode!=c.a.LIGHTMAP_DEFAULT?(u=!0,i["LIGHTMAPEXCLUDED"+s]=!0,i["LIGHTMAPNOSPECULAR"+s]=_.lightmapMode==c.a.LIGHTMAP_SHADOWSONLY):(i["LIGHTMAPEXCLUDED"+s]=!1,i["LIGHTMAPNOSPECULAR"+s]=!1),++s===n)break}i.SPECULARTERM=d,i.SHADOWS=h;for(var v=s;v<n;v++)void 0!==i["LIGHT"+v]&&(i["LIGHT"+v]=!1,i["HEMILIGHT"+s]=!1,i["POINTLIGHT"+s]=!1,i["DIRLIGHT"+s]=!1,i["SPOTLIGHT"+s]=!1,i["SHADOW"+s]=!1);var y=e.getEngine().getCaps();return void 0===i.SHADOWFLOAT&&(l=!0),i.SHADOWFLOAT=h&&(y.textureFloatRender&&y.textureFloatLinearFiltering||y.textureHalfFloatRender&&y.textureHalfFloatLinearFiltering),i.LIGHTMAPEXCLUDED=u,l&&i.rebuild(),a},e.PrepareUniformsAndSamplersList=function(e,t,i,r){var n;void 0===r&&(r=4);var o=null;if(e.uniformsNames){var s=e;n=s.uniformsNames,o=s.uniformBuffersNames,t=s.samplers,i=s.defines,r=s.maxSimultaneousLights}else n=e,t||(t=[]);for(var a=0;a<r&&i["LIGHT"+a];a++)n.push("vLightData"+a,"vLightDiffuse"+a,"vLightSpecular"+a,"vLightDirection"+a,"vLightFalloff"+a,"vLightGround"+a,"lightMatrix"+a,"shadowsInfo"+a,"depthValues"+a),o&&o.push("Light"+a),t.push("shadowSampler"+a),t.push("depthSampler"+a),i["PROJECTEDLIGHTTEXTURE"+a]&&(t.push("projectionLightSampler"+a),n.push("textureProjectionMatrix"+a));i.NUM_MORPH_INFLUENCERS&&n.push("morphTargetInfluences")},e.HandleFallbacksForShadows=function(e,t,i,r){void 0===i&&(i=4),void 0===r&&(r=0);for(var n=0,o=0;o<i&&e["LIGHT"+o];o++)o>0&&(n=r+o,t.addFallback(n,"LIGHT"+o)),e.SHADOWS||(e["SHADOW"+o]&&t.addFallback(r,"SHADOW"+o),e["SHADOWPCF"+o]&&t.addFallback(r,"SHADOWPCF"+o),e["SHADOWPCSS"+o]&&t.addFallback(r,"SHADOWPCSS"+o),e["SHADOWPOISSON"+o]&&t.addFallback(r,"SHADOWPOISSON"+o),e["SHADOWESM"+o]&&t.addFallback(r,"SHADOWESM"+o));return n++},e.PrepareAttributesForMorphTargets=function(e,t,i){var n=i.NUM_MORPH_INFLUENCERS;if(n>0&&s.a.LastCreatedEngine)for(var o=s.a.LastCreatedEngine.getCaps().maxVertexAttribs,c=t.morphTargetManager,l=c&&c.supportsNormals&&i.NORMAL,u=c&&c.supportsTangents&&i.TANGENT,h=0;h<n;h++)e.push(a.b.PositionKind+h),l&&e.push(a.b.NormalKind+h),u&&e.push(a.b.TangentKind+h),e.length>o&&r.a.Error("Cannot add more vertex attributes for mesh "+t.name)},e.PrepareAttributesForBones=function(e,t,i,r){i.NUM_BONE_INFLUENCERS>0&&(r.addCPUSkinningFallback(0,t),e.push(a.b.MatricesIndicesKind),e.push(a.b.MatricesWeightsKind),i.NUM_BONE_INFLUENCERS>4&&(e.push(a.b.MatricesIndicesExtraKind),e.push(a.b.MatricesWeightsExtraKind)))},e.PrepareAttributesForInstances=function(e,t){t.INSTANCES&&(e.push("world0"),e.push("world1"),e.push("world2"),e.push("world3"))},e.BindLightShadow=function(e,t,i,r){if(e.shadowEnabled&&t.receiveShadows){var n=e.getShadowGenerator();n&&n.bindShadowLight(i,r)}},e.BindLightProperties=function(e,t,i){e.transferToEffect(t,i+"")},e.BindLights=function(t,i,r,n,s,a){void 0===s&&(s=4),void 0===a&&(a=!1);for(var c=Math.min(i._lightSources.length,s),l=0;l<c;l++){var u=i._lightSources[l],h=l.toString(),d=u.getScaledIntensity();u._uniformBuffer.bindToEffect(r,"Light"+l),e.BindLightProperties(u,r,l),u.diffuse.scaleToRef(d,o.t.Color3[0]),u._uniformBuffer.updateColor4("vLightDiffuse",o.t.Color3[0],a?u.radius:u.range,h),n.SPECULARTERM&&(u.specular.scaleToRef(d,o.t.Color3[1]),u._uniformBuffer.updateColor3("vLightSpecular",o.t.Color3[1],h)),t.shadowsEnabled&&this.BindLightShadow(u,i,h,r),u._uniformBuffer.update()}},e.BindFogParameters=function(e,t,i,r){void 0===r&&(r=!1),e.fogEnabled&&t.applyFog&&e.fogMode!==n.a.FOGMODE_NONE&&(i.setFloat4("vFogInfos",e.fogMode,e.fogStart,e.fogEnd,e.fogDensity),r?(e.fogColor.toLinearSpaceToRef(this._tempFogColor),i.setColor3("vFogColor",this._tempFogColor)):i.setColor3("vFogColor",e.fogColor))},e.BindBonesParameters=function(e,t){if(t&&e&&(e.computeBonesUsingShaders&&t._bonesComputationForcedToCPU&&(e.computeBonesUsingShaders=!1),e.useBones&&e.computeBonesUsingShaders&&e.skeleton)){var i=e.skeleton;if(i.isUsingTextureForMatrices&&t.getUniformIndex("boneTextureWidth")>-1){var r=i.getTransformMatrixTexture();t.setTexture("boneSampler",r),t.setFloat("boneTextureWidth",4*(i.bones.length+1))}else{var n=i.getTransformMatrices(e);n&&t.setMatrices("mBones",n)}}},e.BindMorphTargetParameters=function(e,t){var i=e.morphTargetManager;e&&i&&t.setFloatArray("morphTargetInfluences",i.influences)},e.BindLogDepth=function(e,t,i){e.LOGARITHMICDEPTH&&t.setFloat("logarithmicDepthConstant",2/(Math.log(i.activeCamera.maxZ+1)/Math.LN2))},e.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)}if(t.clipPlane2){i=t.clipPlane2;e.setFloat4("vClipPlane2",i.normal.x,i.normal.y,i.normal.z,i.d)}if(t.clipPlane3){i=t.clipPlane3;e.setFloat4("vClipPlane3",i.normal.x,i.normal.y,i.normal.z,i.d)}if(t.clipPlane4){i=t.clipPlane4;e.setFloat4("vClipPlane4",i.normal.x,i.normal.y,i.normal.z,i.d)}},e._tempFogColor=o.e.Black(),e}()},function(e,t,i){"use strict";i.d(t,"a",function(){return I});var r=i(1),n=i(9),o=i(43),s=i(7),a=i(28),c=i(58),l=i(26),u=i(0),h=i(23),d=i(19),f=i(30),p=i(31),_=i(66),g=i(39),m=i(51),v=i(15),y=i(47),b=i(37),T=i(75),E=i(82),x=i(14),A=i(27),P=i(3),R=i(38),S=i(8),C=i(22),M=i(72),O=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(e){function t(i,r){var o=e.call(this)||this;return o._isScene=!0,o.autoClear=!0,o.autoClearDepthAndStencil=!0,o.clearColor=new u.f(.2,.2,.3,1),o.ambientColor=new u.e(0,0,0),o._forceWireframe=!1,o._forcePointsCloud=!1,o.animationsEnabled=!0,o._animationPropertiesOverride=null,o.useConstantAnimationDeltaTime=!1,o.constantlyUpdateMeshUnderPointer=!1,o.hoverCursor="pointer",o.defaultCursor="",o.preventDefaultOnPointerDown=!0,o.preventDefaultOnPointerUp=!0,o.metadata=null,o.reservedDataStore=null,o.disableOfflineSupportExceptionRules=new Array,o.onDisposeObservable=new s.c,o._onDisposeObserver=null,o.onBeforeRenderObservable=new s.c,o._onBeforeRenderObserver=null,o.onAfterRenderObservable=new s.c,o._onAfterRenderObserver=null,o.onBeforeAnimationsObservable=new s.c,o.onAfterAnimationsObservable=new s.c,o.onBeforeDrawPhaseObservable=new s.c,o.onAfterDrawPhaseObservable=new s.c,o.onReadyObservable=new s.c,o.onBeforeCameraRenderObservable=new s.c,o._onBeforeCameraRenderObserver=null,o.onAfterCameraRenderObservable=new s.c,o._onAfterCameraRenderObserver=null,o.onBeforeActiveMeshesEvaluationObservable=new s.c,o.onAfterActiveMeshesEvaluationObservable=new s.c,o.onBeforeParticlesRenderingObservable=new s.c,o.onAfterParticlesRenderingObservable=new s.c,o.onDataLoadedObservable=new s.c,o.onNewCameraAddedObservable=new s.c,o.onCameraRemovedObservable=new s.c,o.onNewLightAddedObservable=new s.c,o.onLightRemovedObservable=new s.c,o.onNewGeometryAddedObservable=new s.c,o.onGeometryRemovedObservable=new s.c,o.onNewTransformNodeAddedObservable=new s.c,o.onTransformNodeRemovedObservable=new s.c,o.onNewMeshAddedObservable=new s.c,o.onMeshRemovedObservable=new s.c,o.onNewMaterialAddedObservable=new s.c,o.onMaterialRemovedObservable=new s.c,o.onNewTextureAddedObservable=new s.c,o.onTextureRemovedObservable=new s.c,o.onBeforeRenderTargetsRenderObservable=new s.c,o.onAfterRenderTargetsRenderObservable=new s.c,o.onBeforeStepObservable=new s.c,o.onAfterStepObservable=new s.c,o.onActiveCameraChanged=new s.c,o.onBeforeRenderingGroupObservable=new s.c,o.onAfterRenderingGroupObservable=new s.c,o.onMeshImportedObservable=new s.c,o._registeredForLateAnimationBindings=new a.b(256),o.onPrePointerObservable=new s.c,o.onPointerObservable=new s.c,o._meshPickProceed=!1,o._currentPickResult=null,o._previousPickResult=null,o._totalPointersPressed=0,o._doubleClickOccured=!1,o.cameraToUseForPointers=null,o._pointerX=0,o._pointerY=0,o._startingPointerPosition=new u.w(0,0),o._previousStartingPointerPosition=new u.w(0,0),o._startingPointerTime=0,o._previousStartingPointerTime=0,o._pointerCaptures={},o._timeAccumulator=0,o._currentStepId=0,o._currentInternalStep=0,o.onPreKeyboardObservable=new s.c,o.onKeyboardObservable=new s.c,o._useRightHandedSystem=!1,o._fogEnabled=!0,o._fogMode=t.FOGMODE_NONE,o.fogColor=new u.e(.2,.2,.3),o.fogDensity=.1,o.fogStart=0,o.fogEnd=1e3,o._shadowsEnabled=!0,o._lightsEnabled=!0,o.activeCameras=new Array,o._texturesEnabled=!0,o.particlesEnabled=!0,o.spritesEnabled=!0,o._skeletonsEnabled=!0,o.lensFlaresEnabled=!0,o.collisionsEnabled=!0,o.gravity=new u.x(0,-9.807,0),o.postProcessesEnabled=!0,o.postProcesses=new Array,o.renderTargetsEnabled=!0,o.dumpNextRenderTargets=!1,o.customRenderTargets=new Array,o.importedMeshesFiles=new Array,o.probesEnabled=!0,o._meshesForIntersections=new a.b(256),o.proceduralTexturesEnabled=!0,o._totalVertices=new n.f,o._activeIndices=new n.f,o._activeParticles=new n.f,o._activeBones=new n.f,o._animationTime=0,o.animationTimeScale=1,o._renderId=0,o._frameId=0,o._executeWhenReadyTimeoutId=-1,o._intermediateRendering=!1,o._viewUpdateFlag=-1,o._projectionUpdateFlag=-1,o._alternateViewUpdateFlag=-1,o._alternateProjectionUpdateFlag=-1,o._toBeDisposed=new Array(256),o._activeRequests=new Array,o._pendingData=new Array,o._isDisposed=!1,o.dispatchAllSubMeshesOfActiveMeshes=!1,o._activeMeshes=new a.a(256),o._processedMaterials=new a.a(256),o._renderTargets=new a.b(256),o._activeParticleSystems=new a.a(256),o._activeSkeletons=new a.b(32),o._softwareSkinnedMeshes=new a.b(32),o._activeAnimatables=new Array,o._transformMatrix=u.j.Zero(),o._useAlternateCameraConfiguration=!1,o._alternateRendering=!1,o._wheelEventName="",o.requireLightSorting=!1,o._components=[],o._serializableComponents=[],o._transientComponents=[],o._beforeCameraUpdateStage=x.b.Create(),o._beforeClearStage=x.b.Create(),o._gatherRenderTargetsStage=x.b.Create(),o._gatherActiveCameraRenderTargetsStage=x.b.Create(),o._isReadyForMeshStage=x.b.Create(),o._beforeEvaluateActiveMeshStage=x.b.Create(),o._evaluateSubMeshStage=x.b.Create(),o._activeMeshStage=x.b.Create(),o._cameraDrawRenderTargetStage=x.b.Create(),o._beforeCameraDrawStage=x.b.Create(),o._beforeRenderTargetDrawStage=x.b.Create(),o._beforeRenderingGroupDrawStage=x.b.Create(),o._beforeRenderingMeshStage=x.b.Create(),o._afterRenderingMeshStage=x.b.Create(),o._afterRenderingGroupDrawStage=x.b.Create(),o._afterCameraDrawStage=x.b.Create(),o._afterRenderTargetDrawStage=x.b.Create(),o._afterRenderStage=x.b.Create(),o._pointerMoveStage=x.b.Create(),o._pointerDownStage=x.b.Create(),o._pointerUpStage=x.b.Create(),o.geometriesByUniqueId=null,o._defaultMeshCandidates={data:[],length:0},o._defaultSubMeshCandidates={data:[],length:0},o._preventFreeActiveMeshesAndRenderingGroups=!1,o._activeMeshesFrozen=!1,o._allowPostProcessClearColor=!0,o.getDeterministicFrameTime=function(){return 1e3/60},o._tempPickingRay=A.a?A.a.Zero():null,o._blockMaterialDirtyMechanism=!1,o._engine=i||C.a.LastCreatedEngine,o._engine.scenes.push(o),o._uid=null,o._renderingManager=new E.b(o),T.a&&(o.postProcessManager=new T.a(o)),R.a.IsWindowObjectExist()&&o.attachControl(),o._createUbo(),p.a&&(o._imageProcessingConfiguration=new p.a),o.setDefaultCandidateProviders(),r&&!0===r.useGeometryUniqueIdsMap&&(o.geometriesByUniqueId={}),o.useMaterialMeshMap=r&&r.useGeometryUniqueIdsMap||!1,o.useClonedMeshhMap=r&&r.useClonedMeshhMap||!1,o._engine.onNewSceneAddedObservable.notifyObservers(o),o}return r.d(t,e),t.DefaultMaterialFactory=function(e){throw"Import StandardMaterial or set DefaultMaterialFactory static property on scene before relying on default material creation."},t.CollisionCoordinatorFactory=function(){throw"Import DefaultCollisionCoordinator or set CollisionCoordinatorFactory static property on scene to enable collisions."},Object.defineProperty(t.prototype,"environmentTexture",{get:function(){return this._environmentTexture},set:function(e){this._environmentTexture!==e&&(this._environmentTexture=e,this.markAllMaterialsAsDirty(P.a.MATERIAL_TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"imageProcessingConfiguration",{get:function(){return this._imageProcessingConfiguration},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"forceWireframe",{get:function(){return this._forceWireframe},set:function(e){this._forceWireframe!==e&&(this._forceWireframe=e,this.markAllMaterialsAsDirty(P.a.MATERIAL_MiscDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"forcePointsCloud",{get:function(){return this._forcePointsCloud},set:function(e){this._forcePointsCloud!==e&&(this._forcePointsCloud=e,this.markAllMaterialsAsDirty(P.a.MATERIAL_MiscDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"animationPropertiesOverride",{get:function(){return this._animationPropertiesOverride},set:function(e){this._animationPropertiesOverride=e},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,"beforeRender",{set:function(e){this._onBeforeRenderObserver&&this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),e&&(this._onBeforeRenderObserver=this.onBeforeRenderObservable.add(e))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"afterRender",{set:function(e){this._onAfterRenderObserver&&this.onAfterRenderObservable.remove(this._onAfterRenderObserver),e&&(this._onAfterRenderObserver=this.onAfterRenderObservable.add(e))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"beforeCameraRender",{set:function(e){this._onBeforeCameraRenderObserver&&this.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver),this._onBeforeCameraRenderObserver=this.onBeforeCameraRenderObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"afterCameraRender",{set:function(e){this._onAfterCameraRenderObserver&&this.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver),this._onAfterCameraRenderObserver=this.onAfterCameraRenderObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"unTranslatedPointer",{get:function(){return new u.w(this._unTranslatedPointerX,this._unTranslatedPointerY)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useRightHandedSystem",{get:function(){return this._useRightHandedSystem},set:function(e){this._useRightHandedSystem!==e&&(this._useRightHandedSystem=e,this.markAllMaterialsAsDirty(P.a.MATERIAL_MiscDirtyFlag))},enumerable:!0,configurable:!0}),t.prototype.setStepId=function(e){this._currentStepId=e},t.prototype.getStepId=function(){return this._currentStepId},t.prototype.getInternalStep=function(){return this._currentInternalStep},Object.defineProperty(t.prototype,"fogEnabled",{get:function(){return this._fogEnabled},set:function(e){this._fogEnabled!==e&&(this._fogEnabled=e,this.markAllMaterialsAsDirty(P.a.MATERIAL_MiscDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"fogMode",{get:function(){return this._fogMode},set:function(e){this._fogMode!==e&&(this._fogMode=e,this.markAllMaterialsAsDirty(P.a.MATERIAL_MiscDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"shadowsEnabled",{get:function(){return this._shadowsEnabled},set:function(e){this._shadowsEnabled!==e&&(this._shadowsEnabled=e,this.markAllMaterialsAsDirty(P.a.MATERIAL_LightDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"lightsEnabled",{get:function(){return this._lightsEnabled},set:function(e){this._lightsEnabled!==e&&(this._lightsEnabled=e,this.markAllMaterialsAsDirty(P.a.MATERIAL_LightDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"activeCamera",{get:function(){return this._activeCamera},set:function(e){e!==this._activeCamera&&(this._activeCamera=e,this.onActiveCameraChanged.notifyObservers(this))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"defaultMaterial",{get:function(){return this._defaultMaterial||(this._defaultMaterial=t.DefaultMaterialFactory(this)),this._defaultMaterial},set:function(e){this._defaultMaterial=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"texturesEnabled",{get:function(){return this._texturesEnabled},set:function(e){this._texturesEnabled!==e&&(this._texturesEnabled=e,this.markAllMaterialsAsDirty(P.a.MATERIAL_TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"skeletonsEnabled",{get:function(){return this._skeletonsEnabled},set:function(e){this._skeletonsEnabled!==e&&(this._skeletonsEnabled=e,this.markAllMaterialsAsDirty(P.a.MATERIAL_AttributesDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"collisionCoordinator",{get:function(){return this._collisionCoordinator||(this._collisionCoordinator=t.CollisionCoordinatorFactory(),this._collisionCoordinator.init(this)),this._collisionCoordinator},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"_isAlternateRenderingEnabled",{get:function(){return this._alternateRendering},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"frustumPlanes",{get:function(){return this._frustumPlanes},enumerable:!0,configurable:!0}),t.prototype._registerTransientComponents=function(){if(this._transientComponents.length>0){for(var e=0,t=this._transientComponents;e<t.length;e++){t[e].register()}this._transientComponents=[]}},t.prototype._addComponent=function(e){this._components.push(e),this._transientComponents.push(e);var t=e;t.addFromContainer&&this._serializableComponents.push(t)},t.prototype._getComponent=function(e){for(var t=0,i=this._components;t<i.length;t++){var r=i[t];if(r.name===e)return r}return null},t.prototype._getDefaultMeshCandidates=function(){return this._defaultMeshCandidates.data=this.meshes,this._defaultMeshCandidates.length=this.meshes.length,this._defaultMeshCandidates},t.prototype._getDefaultSubMeshCandidates=function(e){return this._defaultSubMeshCandidates.data=e.subMeshes,this._defaultSubMeshCandidates.length=e.subMeshes.length,this._defaultSubMeshCandidates},t.prototype.setDefaultCandidateProviders=function(){this.getActiveMeshCandidates=this._getDefaultMeshCandidates.bind(this),this.getActiveSubMeshCandidates=this._getDefaultSubMeshCandidates.bind(this),this.getIntersectingSubMeshCandidates=this._getDefaultSubMeshCandidates.bind(this),this.getCollidingSubMeshCandidates=this._getDefaultSubMeshCandidates.bind(this)},Object.defineProperty(t.prototype,"meshUnderPointer",{get:function(){return this._pointerOverMesh},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"pointerX",{get:function(){return this._pointerX},set:function(e){this._pointerX=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"pointerY",{get:function(){return this._pointerY},set:function(e){this._pointerY=e},enumerable:!0,configurable:!0}),t.prototype.getCachedMaterial=function(){return this._cachedMaterial},t.prototype.getCachedEffect=function(){return this._cachedEffect},t.prototype.getCachedVisibility=function(){return this._cachedVisibility},t.prototype.isCachedMaterialInvalid=function(e,t,i){return void 0===i&&(i=1),this._cachedEffect!==t||this._cachedMaterial!==e||this._cachedVisibility!==i},t.prototype.getEngine=function(){return this._engine},t.prototype.getTotalVertices=function(){return this._totalVertices.current},Object.defineProperty(t.prototype,"totalVerticesPerfCounter",{get:function(){return this._totalVertices},enumerable:!0,configurable:!0}),t.prototype.getActiveIndices=function(){return this._activeIndices.current},Object.defineProperty(t.prototype,"totalActiveIndicesPerfCounter",{get:function(){return this._activeIndices},enumerable:!0,configurable:!0}),t.prototype.getActiveParticles=function(){return this._activeParticles.current},Object.defineProperty(t.prototype,"activeParticlesPerfCounter",{get:function(){return this._activeParticles},enumerable:!0,configurable:!0}),t.prototype.getActiveBones=function(){return this._activeBones.current},Object.defineProperty(t.prototype,"activeBonesPerfCounter",{get:function(){return this._activeBones},enumerable:!0,configurable:!0}),t.prototype.getActiveMeshes=function(){return this._activeMeshes},t.prototype.getAnimationRatio=function(){return void 0!==this._animationRatio?this._animationRatio:1},t.prototype.getRenderId=function(){return this._renderId},t.prototype.getFrameId=function(){return this._frameId},t.prototype.incrementRenderId=function(){this._renderId++},t.prototype._updatePointerPosition=function(e){var t=this._engine.getRenderingCanvasClientRect();t&&(this._pointerX=e.clientX-t.left,this._pointerY=e.clientY-t.top,this._unTranslatedPointerX=this._pointerX,this._unTranslatedPointerY=this._pointerY)},t.prototype._createUbo=function(){this._sceneUbo=new _.a(this._engine,void 0,!0),this._sceneUbo.addUniform("viewProjection",16),this._sceneUbo.addUniform("view",16)},t.prototype._createAlternateUbo=function(){this._alternateSceneUbo=new _.a(this._engine,void 0,!0),this._alternateSceneUbo.addUniform("viewProjection",16),this._alternateSceneUbo.addUniform("view",16)},t.prototype._setRayOnPointerInfo=function(e){e.pickInfo&&(e.pickInfo.ray||(e.pickInfo.ray=this.createPickingRay(e.event.offsetX,e.event.offsetY,u.j.Identity(),this.activeCamera)))},t.prototype.simulatePointerMove=function(e,t){var i=new PointerEvent("pointermove",t);return this._checkPrePointerObservable(e,i,v.a.POINTERMOVE)?this:this._processPointerMove(e,i)},t.prototype._processPointerMove=function(e,t){var i=this._engine.getRenderingCanvas();if(!i)return this;i.style.cursor=this.defaultCursor;var r=!!(e&&e.hit&&e.pickedMesh);r?(this.setPointerOverMesh(e.pickedMesh),this._pointerOverMesh&&this._pointerOverMesh.actionManager&&this._pointerOverMesh.actionManager.hasPointerTriggers&&(this._pointerOverMesh.actionManager.hoverCursor?i.style.cursor=this._pointerOverMesh.actionManager.hoverCursor:i.style.cursor=this.hoverCursor)):this.setPointerOverMesh(null);for(var n=0,o=this._pointerMoveStage;n<o.length;n++){e=o[n].action(this._unTranslatedPointerX,this._unTranslatedPointerY,e,r,i)}if(e){var s=t.type===this._wheelEventName?v.a.POINTERWHEEL:v.a.POINTERMOVE;if(this.onPointerMove&&this.onPointerMove(t,e,s),this.onPointerObservable.hasObservers()){var a=new v.b(s,t,e);this._setRayOnPointerInfo(a),this.onPointerObservable.notifyObservers(a,s)}}return this},t.prototype._checkPrePointerObservable=function(e,t,i){var r=new v.d(i,t,this._unTranslatedPointerX,this._unTranslatedPointerY);return e&&(r.ray=e.ray),this.onPrePointerObservable.notifyObservers(r,i),!!r.skipOnPointerObservable},t.prototype.simulatePointerDown=function(e,t){var i=new PointerEvent("pointerdown",t);return this._checkPrePointerObservable(e,i,v.a.POINTERDOWN)?this:this._processPointerDown(e,i)},t.prototype._processPointerDown=function(e,i){var r=this;if(e&&e.hit&&e.pickedMesh){this._pickedDownMesh=e.pickedMesh;var n=e.pickedMesh.actionManager;if(n){if(n.hasPickTriggers)switch(n.processTrigger(P.a.ACTION_OnPickDownTrigger,b.a.CreateNew(e.pickedMesh,i)),i.button){case 0:n.processTrigger(P.a.ACTION_OnLeftPickTrigger,b.a.CreateNew(e.pickedMesh,i));break;case 1:n.processTrigger(P.a.ACTION_OnCenterPickTrigger,b.a.CreateNew(e.pickedMesh,i));break;case 2:n.processTrigger(P.a.ACTION_OnRightPickTrigger,b.a.CreateNew(e.pickedMesh,i))}n.hasSpecificTrigger(P.a.ACTION_OnLongPressTrigger)&&window.setTimeout(function(){var e=r.pick(r._unTranslatedPointerX,r._unTranslatedPointerY,function(e){return e.isPickable&&e.isVisible&&e.isReady()&&e.actionManager&&e.actionManager.hasSpecificTrigger(P.a.ACTION_OnLongPressTrigger)&&e==r._pickedDownMesh},!1,r.cameraToUseForPointers);e&&e.hit&&e.pickedMesh&&n&&0!==r._totalPointersPressed&&Date.now()-r._startingPointerTime>t.LongPressDelay&&!r._isPointerSwiping()&&(r._startingPointerTime=0,n.processTrigger(P.a.ACTION_OnLongPressTrigger,b.a.CreateNew(e.pickedMesh,i)))},t.LongPressDelay)}}else for(var o=0,s=this._pointerDownStage;o<s.length;o++){e=s[o].action(this._unTranslatedPointerX,this._unTranslatedPointerY,e,i)}if(e){var a=v.a.POINTERDOWN;if(this.onPointerDown&&this.onPointerDown(i,e,a),this.onPointerObservable.hasObservers()){var c=new v.b(a,i,e);this._setRayOnPointerInfo(c),this.onPointerObservable.notifyObservers(c,a)}}return this},t.prototype.simulatePointerUp=function(e,t,i){var r=new PointerEvent("pointerup",t),n=new O;return i?n.doubleClick=!0:n.singleClick=!0,this._checkPrePointerObservable(e,r,v.a.POINTERUP)?this:this._processPointerUp(e,r,n)},t.prototype._processPointerUp=function(e,t,i){if(e&&e&&e.pickedMesh){if(this._pickedUpMesh=e.pickedMesh,this._pickedDownMesh===this._pickedUpMesh&&(this.onPointerPick&&this.onPointerPick(t,e),i.singleClick&&!i.ignore&&this.onPointerObservable.hasObservers())){var r=v.a.POINTERPICK,n=new v.b(r,t,e);this._setRayOnPointerInfo(n),this.onPointerObservable.notifyObservers(n,r)}e.pickedMesh.actionManager&&!i.ignore&&(e.pickedMesh.actionManager.processTrigger(P.a.ACTION_OnPickUpTrigger,b.a.CreateNew(e.pickedMesh,t)),!i.hasSwiped&&i.singleClick&&e.pickedMesh.actionManager.processTrigger(P.a.ACTION_OnPickTrigger,b.a.CreateNew(e.pickedMesh,t)),i.doubleClick&&e.pickedMesh.actionManager.hasSpecificTrigger(P.a.ACTION_OnDoublePickTrigger)&&e.pickedMesh.actionManager.processTrigger(P.a.ACTION_OnDoublePickTrigger,b.a.CreateNew(e.pickedMesh,t)))}else if(!i.ignore)for(var o=0,s=this._pointerUpStage;o<s.length;o++){e=s[o].action(this._unTranslatedPointerX,this._unTranslatedPointerY,e,t)}this._pickedDownMesh&&this._pickedDownMesh.actionManager&&this._pickedDownMesh.actionManager.hasSpecificTrigger(P.a.ACTION_OnPickOutTrigger)&&this._pickedDownMesh!==this._pickedUpMesh&&this._pickedDownMesh.actionManager.processTrigger(P.a.ACTION_OnPickOutTrigger,b.a.CreateNew(this._pickedDownMesh,t));var a=0;if(this.onPointerObservable.hasObservers()){if(!i.ignore&&!i.hasSwiped&&(i.singleClick&&this.onPointerObservable.hasSpecificMask(v.a.POINTERTAP)?a=v.a.POINTERTAP:i.doubleClick&&this.onPointerObservable.hasSpecificMask(v.a.POINTERDOUBLETAP)&&(a=v.a.POINTERDOUBLETAP),a)){n=new v.b(a,t,e);this._setRayOnPointerInfo(n),this.onPointerObservable.notifyObservers(n,a)}if(!i.ignore){a=v.a.POINTERUP;n=new v.b(a,t,e);this._setRayOnPointerInfo(n),this.onPointerObservable.notifyObservers(n,a)}}return this.onPointerUp&&!i.ignore&&this.onPointerUp(t,e,a),this},t.prototype.isPointerCaptured=function(e){return void 0===e&&(e=0),this._pointerCaptures[e]},t.prototype._isPointerSwiping=function(){return Math.abs(this._startingPointerPosition.x-this._pointerX)>t.DragMovementThreshold||Math.abs(this._startingPointerPosition.y-this._pointerY)>t.DragMovementThreshold},t.prototype.attachControl=function(e,i,r){var o=this;void 0===e&&(e=!0),void 0===i&&(i=!0),void 0===r&&(r=!0),this._initActionManager=function(e,t){if(!o._meshPickProceed){var i=o.pick(o._unTranslatedPointerX,o._unTranslatedPointerY,o.pointerDownPredicate,!1,o.cameraToUseForPointers);o._currentPickResult=i,i&&(e=i.hit&&i.pickedMesh?i.pickedMesh.actionManager:null),o._meshPickProceed=!0}return e},this._delayedSimpleClick=function(e,i,r){(Date.now()-o._previousStartingPointerTime>t.DoubleClickDelay&&!o._doubleClickOccured||e!==o._previousButtonPressed)&&(o._doubleClickOccured=!1,i.singleClick=!0,i.ignore=!1,r(i,o._currentPickResult))},this._initClickEvent=function(e,i,r,n){var s=new O;o._currentPickResult=null;var a=null,c=e.hasSpecificMask(v.a.POINTERPICK)||i.hasSpecificMask(v.a.POINTERPICK)||e.hasSpecificMask(v.a.POINTERTAP)||i.hasSpecificMask(v.a.POINTERTAP)||e.hasSpecificMask(v.a.POINTERDOUBLETAP)||i.hasSpecificMask(v.a.POINTERDOUBLETAP);!c&&M.a&&(a=o._initActionManager(a,s))&&(c=a.hasPickTriggers);var l=!1;if(c){var u=r.button;if(s.hasSwiped=o._isPointerSwiping(),!s.hasSwiped){var h=!t.ExclusiveDoubleClickMode;h||(h=!e.hasSpecificMask(v.a.POINTERDOUBLETAP)&&!i.hasSpecificMask(v.a.POINTERDOUBLETAP))&&!M.a.HasSpecificTrigger(P.a.ACTION_OnDoublePickTrigger)&&(a=o._initActionManager(a,s))&&(h=!a.hasSpecificTrigger(P.a.ACTION_OnDoublePickTrigger)),h?(Date.now()-o._previousStartingPointerTime>t.DoubleClickDelay||u!==o._previousButtonPressed)&&(s.singleClick=!0,n(s,o._currentPickResult),l=!0):(o._previousDelayedSimpleClickTimeout=o._delayedSimpleClickTimeout,o._delayedSimpleClickTimeout=window.setTimeout(o._delayedSimpleClick.bind(o,u,s,n),t.DoubleClickDelay));var d=e.hasSpecificMask(v.a.POINTERDOUBLETAP)||i.hasSpecificMask(v.a.POINTERDOUBLETAP);!d&&M.a.HasSpecificTrigger(P.a.ACTION_OnDoublePickTrigger)&&(a=o._initActionManager(a,s))&&(d=a.hasSpecificTrigger(P.a.ACTION_OnDoublePickTrigger)),d&&(u===o._previousButtonPressed&&Date.now()-o._previousStartingPointerTime<t.DoubleClickDelay&&!o._doubleClickOccured?(s.hasSwiped||o._isPointerSwiping()?(o._doubleClickOccured=!1,o._previousStartingPointerTime=o._startingPointerTime,o._previousStartingPointerPosition.x=o._startingPointerPosition.x,o._previousStartingPointerPosition.y=o._startingPointerPosition.y,o._previousButtonPressed=u,t.ExclusiveDoubleClickMode?(o._previousDelayedSimpleClickTimeout&&clearTimeout(o._previousDelayedSimpleClickTimeout),o._previousDelayedSimpleClickTimeout=o._delayedSimpleClickTimeout,n(s,o._previousPickResult)):n(s,o._currentPickResult)):(o._previousStartingPointerTime=0,o._doubleClickOccured=!0,s.doubleClick=!0,s.ignore=!1,t.ExclusiveDoubleClickMode&&o._previousDelayedSimpleClickTimeout&&clearTimeout(o._previousDelayedSimpleClickTimeout),o._previousDelayedSimpleClickTimeout=o._delayedSimpleClickTimeout,n(s,o._currentPickResult)),l=!0):(o._doubleClickOccured=!1,o._previousStartingPointerTime=o._startingPointerTime,o._previousStartingPointerPosition.x=o._startingPointerPosition.x,o._previousStartingPointerPosition.y=o._startingPointerPosition.y,o._previousButtonPressed=u))}}l||n(s,o._currentPickResult)},this._onPointerMove=function(e){if(o._updatePointerPosition(e),!o._checkPrePointerObservable(null,e,e.type===o._wheelEventName?v.a.POINTERWHEEL:v.a.POINTERMOVE)&&(o.cameraToUseForPointers||o.activeCamera)){o.pointerMovePredicate||(o.pointerMovePredicate=function(e){return e.isPickable&&e.isVisible&&e.isReady()&&e.isEnabled()&&(e.enablePointerMoveEvents||o.constantlyUpdateMeshUnderPointer||null!==e.actionManager&&void 0!==e.actionManager)});var t=o.pick(o._unTranslatedPointerX,o._unTranslatedPointerY,o.pointerMovePredicate,!1,o.cameraToUseForPointers);o._processPointerMove(t,e)}},this._onPointerDown=function(e){if(o._totalPointersPressed++,o._pickedDownMesh=null,o._meshPickProceed=!1,o._updatePointerPosition(e),o.preventDefaultOnPointerDown&&c&&(e.preventDefault(),c.focus()),o._startingPointerPosition.x=o._pointerX,o._startingPointerPosition.y=o._pointerY,o._startingPointerTime=Date.now(),!o._checkPrePointerObservable(null,e,v.a.POINTERDOWN)&&(o.cameraToUseForPointers||o.activeCamera)){o._pointerCaptures[e.pointerId]=!0,o.pointerDownPredicate||(o.pointerDownPredicate=function(e){return e.isPickable&&e.isVisible&&e.isReady()&&e.isEnabled()}),o._pickedDownMesh=null;var t=o.pick(o._unTranslatedPointerX,o._unTranslatedPointerY,o.pointerDownPredicate,!1,o.cameraToUseForPointers);o._processPointerDown(t,e)}},this._onPointerUp=function(e){0!==o._totalPointersPressed&&(o._totalPointersPressed--,o._pickedUpMesh=null,o._meshPickProceed=!1,o._updatePointerPosition(e),o.preventDefaultOnPointerUp&&c&&(e.preventDefault(),c.focus()),o._initClickEvent(o.onPrePointerObservable,o.onPointerObservable,e,function(t,i){if(o._pointerCaptures[e.pointerId]=!1,o.onPrePointerObservable.hasObservers()&&!t.ignore){if(!t.hasSwiped){if(t.singleClick&&o.onPrePointerObservable.hasSpecificMask(v.a.POINTERTAP)&&o._checkPrePointerObservable(null,e,v.a.POINTERTAP))return;if(t.doubleClick&&o.onPrePointerObservable.hasSpecificMask(v.a.POINTERDOUBLETAP)&&o._checkPrePointerObservable(null,e,v.a.POINTERDOUBLETAP))return}if(o._checkPrePointerObservable(null,e,v.a.POINTERUP))return}(o.cameraToUseForPointers||o.activeCamera)&&(o.pointerUpPredicate||(o.pointerUpPredicate=function(e){return e.isPickable&&e.isVisible&&e.isReady()&&e.isEnabled()}),!o._meshPickProceed&&(M.a&&M.a.HasTriggers||o.onPointerObservable.hasObservers())&&o._initActionManager(null,t),i||(i=o._currentPickResult),o._processPointerUp(i,e,t),o._previousPickResult=o._currentPickResult)}))},this._onKeyDown=function(e){var t=y.a.KEYDOWN;if(o.onPreKeyboardObservable.hasObservers()){var i=new y.c(t,e);if(o.onPreKeyboardObservable.notifyObservers(i,t),i.skipOnPointerObservable)return}if(o.onKeyboardObservable.hasObservers()){i=new y.b(t,e);o.onKeyboardObservable.notifyObservers(i,t)}o.actionManager&&o.actionManager.processTrigger(P.a.ACTION_OnKeyDownTrigger,b.a.CreateNewFromScene(o,e))},this._onKeyUp=function(e){var t=y.a.KEYUP;if(o.onPreKeyboardObservable.hasObservers()){var i=new y.c(t,e);if(o.onPreKeyboardObservable.notifyObservers(i,t),i.skipOnPointerObservable)return}if(o.onKeyboardObservable.hasObservers()){i=new y.b(t,e);o.onKeyboardObservable.notifyObservers(i,t)}o.actionManager&&o.actionManager.processTrigger(P.a.ACTION_OnKeyUpTrigger,b.a.CreateNewFromScene(o,e))};var s=this.getEngine();this._onCanvasFocusObserver=s.onCanvasFocusObservable.add(function(){c&&(c.addEventListener("keydown",o._onKeyDown,!1),c.addEventListener("keyup",o._onKeyUp,!1))}),this._onCanvasBlurObserver=s.onCanvasBlurObservable.add(function(){c&&(c.removeEventListener("keydown",o._onKeyDown),c.removeEventListener("keyup",o._onKeyUp))});var a=n.h.GetPointerPrefix(),c=this._engine.getRenderingCanvas();c&&(r&&(c.addEventListener(a+"move",this._onPointerMove,!1),this._wheelEventName="onwheel"in document.createElement("div")?"wheel":void 0!==document.onmousewheel?"mousewheel":"DOMMouseScroll",c.addEventListener(this._wheelEventName,this._onPointerMove,!1)),i&&c.addEventListener(a+"down",this._onPointerDown,!1),e&&window.addEventListener(a+"up",this._onPointerUp,!1),c.tabIndex=1)},t.prototype.detachControl=function(){var e=this.getEngine(),t=n.h.GetPointerPrefix(),i=e.getRenderingCanvas();i&&(i.removeEventListener(t+"move",this._onPointerMove),i.removeEventListener(t+"down",this._onPointerDown),window.removeEventListener(t+"up",this._onPointerUp),this._onCanvasBlurObserver&&e.onCanvasBlurObservable.remove(this._onCanvasBlurObserver),this._onCanvasFocusObserver&&e.onCanvasFocusObservable.remove(this._onCanvasFocusObserver),i.removeEventListener(this._wheelEventName,this._onPointerMove),i.removeEventListener("keydown",this._onKeyDown),i.removeEventListener("keyup",this._onKeyUp),this.onKeyboardObservable.clear(),this.onPreKeyboardObservable.clear(),this.onPointerObservable.clear(),this.onPrePointerObservable.clear())},t.prototype.isReady=function(){if(this._isDisposed)return!1;var e,t=this.getEngine();if(!t.areAllEffectsReady())return!1;if(this._pendingData.length>0)return!1;for(e=0;e<this.meshes.length;e++){var i=this.meshes[e];if(i.isEnabled()&&(i.subMeshes&&0!==i.subMeshes.length)){if(!i.isReady(!0))return!1;for(var r="InstancedMesh"===i.getClassName()||"InstancedLinesMesh"===i.getClassName()||t.getCaps().instancedArrays&&i.instances.length>0,n=0,o=this._isReadyForMeshStage;n<o.length;n++){if(!o[n].action(i,r))return!1}}}for(e=0;e<this.geometries.length;e++){if(this.geometries[e].delayLoadState===P.a.DELAYLOADSTATE_LOADING)return!1}if(this.activeCameras&&this.activeCameras.length>0)for(var s=0,a=this.activeCameras;s<a.length;s++){if(!a[s].isReady(!0))return!1}else if(this.activeCamera&&!this.activeCamera.isReady(!0))return!1;for(var c=0,l=this.particleSystems;c<l.length;c++){if(!l[c].isReady())return!1}return!0},t.prototype.resetCachedMaterial=function(){this._cachedMaterial=null,this._cachedEffect=null,this._cachedVisibility=null},t.prototype.registerBeforeRender=function(e){this.onBeforeRenderObservable.add(e)},t.prototype.unregisterBeforeRender=function(e){this.onBeforeRenderObservable.removeCallback(e)},t.prototype.registerAfterRender=function(e){this.onAfterRenderObservable.add(e)},t.prototype.unregisterAfterRender=function(e){this.onAfterRenderObservable.removeCallback(e)},t.prototype._executeOnceBeforeRender=function(e){var t=this,i=function(){e(),setTimeout(function(){t.unregisterBeforeRender(i)})};this.registerBeforeRender(i)},t.prototype.executeOnceBeforeRender=function(e,t){var i=this;void 0!==t?setTimeout(function(){i._executeOnceBeforeRender(e)},t):this._executeOnceBeforeRender(e)},t.prototype._addPendingData=function(e){this._pendingData.push(e)},t.prototype._removePendingData=function(e){var t=this.isLoading,i=this._pendingData.indexOf(e);-1!==i&&this._pendingData.splice(i,1),t&&!this.isLoading&&this.onDataLoadedObservable.notifyObservers(this)},t.prototype.getWaitingItemsCount=function(){return this._pendingData.length},Object.defineProperty(t.prototype,"isLoading",{get:function(){return this._pendingData.length>0},enumerable:!0,configurable:!0}),t.prototype.executeWhenReady=function(e){var t=this;this.onReadyObservable.add(e),-1===this._executeWhenReadyTimeoutId&&(this._executeWhenReadyTimeoutId=setTimeout(function(){t._checkIsReady()},150))},t.prototype.whenReadyAsync=function(){var e=this;return new Promise(function(t){e.executeWhenReady(function(){t()})})},t.prototype._checkIsReady=function(){var e=this;if(this._registerTransientComponents(),this.isReady())return this.onReadyObservable.notifyObservers(this),this.onReadyObservable.clear(),void(this._executeWhenReadyTimeoutId=-1);this._executeWhenReadyTimeoutId=setTimeout(function(){e._checkIsReady()},150)},Object.defineProperty(t.prototype,"animatables",{get:function(){return this._activeAnimatables},enumerable:!0,configurable:!0}),t.prototype.resetLastAnimationTimeFrame=function(){this._animationTimeLast=o.a.Now},t.prototype._switchToAlternateCameraConfiguration=function(e){this._useAlternateCameraConfiguration=e},t.prototype.getViewMatrix=function(){return this._useAlternateCameraConfiguration?this._alternateViewMatrix:this._viewMatrix},t.prototype.getProjectionMatrix=function(){return this._useAlternateCameraConfiguration?this._alternateProjectionMatrix:this._projectionMatrix},t.prototype.getTransformMatrix=function(){return this._useAlternateCameraConfiguration?this._alternateTransformMatrix:this._transformMatrix},t.prototype.setTransformMatrix=function(e,t){if(this._viewUpdateFlag!==e.updateFlag||this._projectionUpdateFlag!==t.updateFlag){if(this._viewUpdateFlag=e.updateFlag,this._projectionUpdateFlag=t.updateFlag,this._viewMatrix=e,this._projectionMatrix=t,this._viewMatrix.multiplyToRef(this._projectionMatrix,this._transformMatrix),this._frustumPlanes?u.i.GetPlanesToRef(this._transformMatrix,this._frustumPlanes):this._frustumPlanes=u.i.GetPlanes(this._transformMatrix),this.activeCamera&&this.activeCamera._alternateCamera){var i=this.activeCamera._alternateCamera;i.getViewMatrix().multiplyToRef(i.getProjectionMatrix(),u.t.Matrix[0]),u.i.GetRightPlaneToRef(u.t.Matrix[0],this._frustumPlanes[3])}this._sceneUbo.useUbo&&(this._sceneUbo.updateMatrix("viewProjection",this._transformMatrix),this._sceneUbo.updateMatrix("view",this._viewMatrix),this._sceneUbo.update())}},t.prototype._setAlternateTransformMatrix=function(e,t){this._alternateViewUpdateFlag===e.updateFlag&&this._alternateProjectionUpdateFlag===t.updateFlag||(this._alternateViewUpdateFlag=e.updateFlag,this._alternateProjectionUpdateFlag=t.updateFlag,this._alternateViewMatrix=e,this._alternateProjectionMatrix=t,this._alternateTransformMatrix||(this._alternateTransformMatrix=u.j.Zero()),this._alternateViewMatrix.multiplyToRef(this._alternateProjectionMatrix,this._alternateTransformMatrix),this._alternateSceneUbo||this._createAlternateUbo(),this._alternateSceneUbo.useUbo&&(this._alternateSceneUbo.updateMatrix("viewProjection",this._alternateTransformMatrix),this._alternateSceneUbo.updateMatrix("view",this._alternateViewMatrix),this._alternateSceneUbo.update()))},t.prototype.getSceneUniformBuffer=function(){return this._useAlternateCameraConfiguration?this._alternateSceneUbo:this._sceneUbo},t.prototype.getUniqueId=function(){var e=t._uniqueIdCounter;return t._uniqueIdCounter++,e},t.prototype.addMesh=function(e,t){var i=this;void 0===t&&(t=!1),this.meshes.push(e),e._resyncLightSources(),this.onNewMeshAddedObservable.notifyObservers(e),t&&e.getChildMeshes().forEach(function(e){i.addMesh(e)})},t.prototype.removeMesh=function(e,t){var i=this;void 0===t&&(t=!1);var r=this.meshes.indexOf(e);return-1!==r&&(this.meshes[r]=this.meshes[this.meshes.length-1],this.meshes.pop()),this.onMeshRemovedObservable.notifyObservers(e),t&&e.getChildMeshes().forEach(function(e){i.removeMesh(e)}),r},t.prototype.addTransformNode=function(e){e._indexInSceneTransformNodesArray=this.transformNodes.length,this.transformNodes.push(e),this.onNewTransformNodeAddedObservable.notifyObservers(e)},t.prototype.removeTransformNode=function(e){var t=e._indexInSceneTransformNodesArray;if(-1!==t){if(t!==this.transformNodes.length-1){var i=this.transformNodes[this.transformNodes.length-1];this.transformNodes[t]=i,i._indexInSceneTransformNodesArray=t}e._indexInSceneTransformNodesArray=-1,this.transformNodes.pop()}return this.onTransformNodeRemovedObservable.notifyObservers(e),t},t.prototype.removeSkeleton=function(e){var t=this.skeletons.indexOf(e);return-1!==t&&this.skeletons.splice(t,1),t},t.prototype.removeMorphTargetManager=function(e){var t=this.morphTargetManagers.indexOf(e);return-1!==t&&this.morphTargetManagers.splice(t,1),t},t.prototype.removeLight=function(e){var t=this.lights.indexOf(e);if(-1!==t){for(var i=0,r=this.meshes;i<r.length;i++){r[i]._removeLightSource(e)}this.lights.splice(t,1),this.sortLightsByPriority()}return this.onLightRemovedObservable.notifyObservers(e),t},t.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},t.prototype.removeParticleSystem=function(e){var t=this.particleSystems.indexOf(e);return-1!==t&&this.particleSystems.splice(t,1),t},t.prototype.removeAnimation=function(e){var t=this.animations.indexOf(e);return-1!==t&&this.animations.splice(t,1),t},t.prototype.removeAnimationGroup=function(e){var t=this.animationGroups.indexOf(e);return-1!==t&&this.animationGroups.splice(t,1),t},t.prototype.removeMultiMaterial=function(e){var t=this.multiMaterials.indexOf(e);return-1!==t&&this.multiMaterials.splice(t,1),t},t.prototype.removeMaterial=function(e){var t=e._indexInSceneMaterialArray;if(-1!==t&&t<this.materials.length){if(t!==this.materials.length-1){var i=this.materials[this.materials.length-1];this.materials[t]=i,i._indexInSceneMaterialArray=t}e._indexInSceneMaterialArray=-1,this.materials.pop()}return this.onMaterialRemovedObservable.notifyObservers(e),t},t.prototype.removeActionManager=function(e){var t=this.actionManagers.indexOf(e);return-1!==t&&this.actionManagers.splice(t,1),t},t.prototype.removeTexture=function(e){var t=this.textures.indexOf(e);return-1!==t&&this.textures.splice(t,1),this.onTextureRemovedObservable.notifyObservers(e),t},t.prototype.addLight=function(e){this.lights.push(e),this.sortLightsByPriority();for(var t=0,i=this.meshes;t<i.length;t++){var r=i[t];-1===r._lightSources.indexOf(e)&&(r._lightSources.push(e),r._resyncLightSources())}this.onNewLightAddedObservable.notifyObservers(e)},t.prototype.sortLightsByPriority=function(){this.requireLightSorting&&this.lights.sort(g.a.CompareLightsPriority)},t.prototype.addCamera=function(e){this.cameras.push(e),this.onNewCameraAddedObservable.notifyObservers(e)},t.prototype.addSkeleton=function(e){this.skeletons.push(e)},t.prototype.addParticleSystem=function(e){this.particleSystems.push(e)},t.prototype.addAnimation=function(e){this.animations.push(e)},t.prototype.addAnimationGroup=function(e){this.animationGroups.push(e)},t.prototype.addMultiMaterial=function(e){this.multiMaterials.push(e)},t.prototype.addMaterial=function(e){e._indexInSceneMaterialArray=this.materials.length,this.materials.push(e),this.onNewMaterialAddedObservable.notifyObservers(e)},t.prototype.addMorphTargetManager=function(e){this.morphTargetManagers.push(e)},t.prototype.addGeometry=function(e){this.geometriesByUniqueId&&(this.geometriesByUniqueId[e.uniqueId]=this.geometries.length),this.geometries.push(e)},t.prototype.addActionManager=function(e){this.actionManagers.push(e)},t.prototype.addTexture=function(e){this.textures.push(e),this.onNewTextureAddedObservable.notifyObservers(e)},t.prototype.switchActiveCamera=function(e,t){void 0===t&&(t=!0);var i=this._engine.getRenderingCanvas();i&&(this.activeCamera&&this.activeCamera.detachControl(i),this.activeCamera=e,t&&e.attachControl(i))},t.prototype.setActiveCameraByID=function(e){var t=this.getCameraByID(e);return t?(this.activeCamera=t,t):null},t.prototype.setActiveCameraByName=function(e){var t=this.getCameraByName(e);return t?(this.activeCamera=t,t):null},t.prototype.getAnimationGroupByName=function(e){for(var t=0;t<this.animationGroups.length;t++)if(this.animationGroups[t].name===e)return this.animationGroups[t];return null},t.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},t.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},t.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},t.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},t.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},t.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},t.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},t.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},t.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},t.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},t.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},t.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},t.prototype._getGeometryByUniqueID=function(e){if(this.geometriesByUniqueId){var t=this.geometriesByUniqueId[e];if(void 0!==t)return this.geometries[t]}else for(var i=0;i<this.geometries.length;i++)if(this.geometries[i].uniqueId===e)return this.geometries[i];return null},t.prototype.pushGeometry=function(e,t){return!(!t&&this._getGeometryByUniqueID(e.uniqueId))&&(this.addGeometry(e),this.onNewGeometryAddedObservable.notifyObservers(e),!0)},t.prototype.removeGeometry=function(e){var t;if(this.geometriesByUniqueId){if(void 0===(t=this.geometriesByUniqueId[e.uniqueId]))return!1}else if((t=this.geometries.indexOf(e))<0)return!1;if(t!==this.geometries.length-1){var i=this.geometries[this.geometries.length-1];this.geometries[t]=i,this.geometriesByUniqueId&&(this.geometriesByUniqueId[i.uniqueId]=t,this.geometriesByUniqueId[e.uniqueId]=void 0)}return this.geometries.pop(),this.onGeometryRemovedObservable.notifyObservers(e),!0},t.prototype.getGeometries=function(){return this.geometries},t.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},t.prototype.getMeshesByID=function(e){return this.meshes.filter(function(t){return t.id===e})},t.prototype.getTransformNodeByID=function(e){for(var t=0;t<this.transformNodes.length;t++)if(this.transformNodes[t].id===e)return this.transformNodes[t];return null},t.prototype.getTransformNodesByID=function(e){return this.transformNodes.filter(function(t){return t.id===e})},t.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},t.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},t.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.transformNodes.length-1;t>=0;t--)if(this.transformNodes[t].id===e)return this.transformNodes[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},t.prototype.getNodeByID=function(e){var t=this.getMeshByID(e);if(t)return t;var i=this.getTransformNodeByID(e);if(i)return i;var r=this.getLightByID(e);if(r)return r;var n=this.getCameraByID(e);if(n)return n;var o=this.getBoneByID(e);return o||null},t.prototype.getNodeByName=function(e){var t=this.getMeshByName(e);if(t)return t;var i=this.getTransformNodeByName(e);if(i)return i;var r=this.getLightByName(e);if(r)return r;var n=this.getCameraByName(e);if(n)return n;var o=this.getBoneByName(e);return o||null},t.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},t.prototype.getTransformNodeByName=function(e){for(var t=0;t<this.transformNodes.length;t++)if(this.transformNodes[t].name===e)return this.transformNodes[t];return null},t.prototype.getLastSkeletonByID=function(e){for(var t=this.skeletons.length-1;t>=0;t--)if(this.skeletons[t].id===e)return this.skeletons[t];return null},t.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},t.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},t.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},t.prototype.getMorphTargetById=function(e){for(var t=0;t<this.morphTargetManagers.length;++t)for(var i=this.morphTargetManagers[t],r=0;r<i.numTargets;++r){var n=i.getTarget(r);if(n.id===e)return n}return null},t.prototype.isActiveMesh=function(e){return-1!==this._activeMeshes.indexOf(e)},Object.defineProperty(t.prototype,"uid",{get:function(){return this._uid||(this._uid=n.h.RandomId()),this._uid},enumerable:!0,configurable:!0}),t.prototype.addExternalData=function(e,t){return this._externalData||(this._externalData=new c.a),this._externalData.add(e,t)},t.prototype.getExternalData=function(e){return this._externalData?this._externalData.get(e):null},t.prototype.getOrAddExternalDataWithFactory=function(e,t){return this._externalData||(this._externalData=new c.a),this._externalData.getOrAddWithFactory(e,t)},t.prototype.removeExternalData=function(e){return this._externalData.remove(e)},t.prototype._evaluateSubMesh=function(e,t){if(this.dispatchAllSubMeshesOfActiveMeshes||t.alwaysSelectAsActiveMesh||1===t.subMeshes.length||e.isInFrustum(this._frustumPlanes)){for(var i=0,r=this._evaluateSubMeshStage;i<r.length;i++){r[i].action(t,e)}var n=e.getMaterial();null!=n&&(n.hasRenderTargetTextures&&void 0!==n.getRenderTargetTextures&&-1===this._processedMaterials.indexOf(n)&&(this._processedMaterials.push(n),this._renderTargets.concatWithNoDuplicate(n.getRenderTargetTextures())),this._activeIndices.addCount(e.indexCount,!1),this._renderingManager.dispatch(e,t,n))}},t.prototype.freeProcessedMaterials=function(){this._processedMaterials.dispose()},Object.defineProperty(t.prototype,"blockfreeActiveMeshesAndRenderingGroups",{get:function(){return this._preventFreeActiveMeshesAndRenderingGroups},set:function(e){this._preventFreeActiveMeshesAndRenderingGroups!==e&&(e&&(this.freeActiveMeshes(),this.freeRenderingGroups()),this._preventFreeActiveMeshesAndRenderingGroups=e)},enumerable:!0,configurable:!0}),t.prototype.freeActiveMeshes=function(){if(!this.blockfreeActiveMeshesAndRenderingGroups&&(this._activeMeshes.dispose(),this.activeCamera&&this.activeCamera._activeMeshes&&this.activeCamera._activeMeshes.dispose(),this.activeCameras))for(var e=0;e<this.activeCameras.length;e++){var t=this.activeCameras[e];t&&t._activeMeshes&&t._activeMeshes.dispose()}},t.prototype.freeRenderingGroups=function(){if(!this.blockfreeActiveMeshesAndRenderingGroups&&(this._renderingManager&&this._renderingManager.freeRenderingGroups(),this.textures))for(var e=0;e<this.textures.length;e++){var t=this.textures[e];t&&t.renderList&&t.freeRenderingGroups()}},t.prototype._isInIntermediateRendering=function(){return this._intermediateRendering},t.prototype.freezeActiveMeshes=function(){return this.activeCamera?(this._frustumPlanes||this.setTransformMatrix(this.activeCamera.getViewMatrix(),this.activeCamera.getProjectionMatrix()),this._evaluateActiveMeshes(),this._activeMeshesFrozen=!0,this):this},t.prototype.unfreezeActiveMeshes=function(){return this._activeMeshesFrozen=!1,this},t.prototype._evaluateActiveMeshes=function(){if((!this._activeMeshesFrozen||!this._activeMeshes.length)&&this.activeCamera){this.onBeforeActiveMeshesEvaluationObservable.notifyObservers(this),this.activeCamera._activeMeshes.reset(),this._activeMeshes.reset(),this._renderingManager.reset(),this._processedMaterials.reset(),this._activeParticleSystems.reset(),this._activeSkeletons.reset(),this._softwareSkinnedMeshes.reset();for(var e=0,t=this._beforeEvaluateActiveMeshStage;e<t.length;e++){t[e].action()}for(var i=this.getActiveMeshCandidates(),r=i.length,n=0;n<r;n++){var o=i.data[n];if(!o.isBlocked&&(this._totalVertices.addCount(o.getTotalVertices(),!1),o.isReady()&&o.isEnabled())){o.computeWorldMatrix(),o.actionManager&&o.actionManager.hasSpecificTriggers2(P.a.ACTION_OnIntersectionEnterTrigger,P.a.ACTION_OnIntersectionExitTrigger)&&this._meshesForIntersections.pushNoDuplicate(o);var s=o.getLOD(this.activeCamera);null!=s&&(o._preActivate(),o.isVisible&&o.visibility>0&&0!=(o.layerMask&this.activeCamera.layerMask)&&(o.alwaysSelectAsActiveMesh||o.isInFrustum(this._frustumPlanes))&&(this._activeMeshes.push(o),this.activeCamera._activeMeshes.push(o),o._activate(this._renderId),s!==o&&s._activate(this._renderId),this._activeMesh(o,s)))}}if(this.onAfterActiveMeshesEvaluationObservable.notifyObservers(this),this.particlesEnabled){this.onBeforeParticlesRenderingObservable.notifyObservers(this);for(var a=0;a<this.particleSystems.length;a++){var c=this.particleSystems[a];if(c.isStarted()&&c.emitter){var l=c.emitter;l.position&&!l.isEnabled()||(this._activeParticleSystems.push(c),c.animate(),this._renderingManager.dispatchParticles(c))}}this.onAfterParticlesRenderingObservable.notifyObservers(this)}}},t.prototype._activeMesh=function(e,t){this._skeletonsEnabled&&null!==t.skeleton&&void 0!==t.skeleton&&(this._activeSkeletons.pushNoDuplicate(t.skeleton)&&t.skeleton.prepare(),t.computeBonesUsingShaders||this._softwareSkinnedMeshes.pushNoDuplicate(t));for(var i=0,r=this._activeMeshStage;i<r.length;i++){r[i].action(e,t)}if(null!=t&&void 0!==t.subMeshes&&null!==t.subMeshes&&t.subMeshes.length>0)for(var n=this.getActiveSubMeshCandidates(t),o=n.length,s=0;s<o;s++){var a=n.data[s];this._evaluateSubMesh(a,t)}},t.prototype.updateTransformMatrix=function(e){this.activeCamera&&this.setTransformMatrix(this.activeCamera.getViewMatrix(),this.activeCamera.getProjectionMatrix(e))},t.prototype.updateAlternateTransformMatrix=function(e){this._setAlternateTransformMatrix(e.getViewMatrix(),e.getProjectionMatrix())},t.prototype._renderForCamera=function(e,t){if(!e||!e._skipRendering){var i=this._engine;if(this.activeCamera=e,!this.activeCamera)throw new Error("Active camera not set");i.setViewport(this.activeCamera.viewport),this.resetCachedMaterial(),this._renderId++,this.updateTransformMatrix(),e._alternateCamera&&(this.updateAlternateTransformMatrix(e._alternateCamera),this._alternateRendering=!0),this.onBeforeCameraRenderObservable.notifyObservers(this.activeCamera),this._evaluateActiveMeshes();for(var r=0;r<this._softwareSkinnedMeshes.length;r++){var o=this._softwareSkinnedMeshes.data[r];o.applySkeleton(o.skeleton)}this.onBeforeRenderTargetsRenderObservable.notifyObservers(this),e.customRenderTargets&&e.customRenderTargets.length>0&&this._renderTargets.concatWithNoDuplicate(e.customRenderTargets),t&&t.customRenderTargets&&t.customRenderTargets.length>0&&this._renderTargets.concatWithNoDuplicate(t.customRenderTargets);for(var s=0,a=this._gatherActiveCameraRenderTargetsStage;s<a.length;s++){a[s].action(this._renderTargets)}if(this.renderTargetsEnabled){if(this._intermediateRendering=!0,this._renderTargets.length>0){n.h.StartPerformanceCounter("Render targets",this._renderTargets.length>0);for(var c=0;c<this._renderTargets.length;c++){var l=this._renderTargets.data[c];if(l._shouldRender()){this._renderId++;var u=l.activeCamera&&l.activeCamera!==this.activeCamera;l.render(u,this.dumpNextRenderTargets)}}n.h.EndPerformanceCounter("Render targets",this._renderTargets.length>0),this._renderId++}for(var h=0,d=this._cameraDrawRenderTargetStage;h<d.length;h++){d[h].action(this.activeCamera)}if(this._intermediateRendering=!1,this.activeCamera.outputRenderTarget){var f=this.activeCamera.outputRenderTarget.getInternalTexture();f?i.bindFramebuffer(f):S.a.Error("Camera contains invalid customDefaultRenderTarget")}else i.restoreDefaultFramebuffer()}this.onAfterRenderTargetsRenderObservable.notifyObservers(this),this.postProcessManager&&this.postProcessManager._prepareFrame();for(var p=0,_=this._beforeCameraDrawStage;p<_.length;p++){_[p].action(this.activeCamera)}this.onBeforeDrawPhaseObservable.notifyObservers(this),this._renderingManager.render(null,null,!0,!0),this.onAfterDrawPhaseObservable.notifyObservers(this);for(var g=0,m=this._afterCameraDrawStage;g<m.length;g++){m[g].action(this.activeCamera)}this.postProcessManager&&this.postProcessManager._finalizeFrame(e.isIntermediate),this._renderTargets.reset(),this._alternateRendering=!1,this.onAfterCameraRenderObservable.notifyObservers(this.activeCamera)}},t.prototype._processSubCameras=function(e){if(e.cameraRigMode!==d.a.RIG_MODE_NONE){for(var t=0;t<e._rigCameras.length;t++)this._renderForCamera(e._rigCameras[t],e);this.activeCamera=e,this.setTransformMatrix(this.activeCamera.getViewMatrix(),this.activeCamera.getProjectionMatrix())}else this._renderForCamera(e)},t.prototype._checkIntersections=function(){for(var e=0;e<this._meshesForIntersections.length;e++){var t=this._meshesForIntersections.data[e];if(t.actionManager)for(var i=0;i<t.actionManager.actions.length;i++){var r=t.actionManager.actions[i];if(r.trigger===P.a.ACTION_OnIntersectionEnterTrigger||r.trigger===P.a.ACTION_OnIntersectionExitTrigger){var n=r.getTriggerParameter(),o=n instanceof h.a?n:n.mesh,s=o.intersectsMesh(t,n.usePreciseIntersection),a=t._intersectionsInProgress.indexOf(o);s&&-1===a?r.trigger===P.a.ACTION_OnIntersectionEnterTrigger?(r._executeCurrent(b.a.CreateNew(t,void 0,o)),t._intersectionsInProgress.push(o)):r.trigger===P.a.ACTION_OnIntersectionExitTrigger&&t._intersectionsInProgress.push(o):!s&&a>-1&&(r.trigger===P.a.ACTION_OnIntersectionExitTrigger&&r._executeCurrent(b.a.CreateNew(t,void 0,o)),t.actionManager.hasSpecificTrigger(P.a.ACTION_OnIntersectionExitTrigger,function(e){var t=e instanceof h.a?e:e.mesh;return o===t})&&r.trigger!==P.a.ACTION_OnIntersectionExitTrigger||t._intersectionsInProgress.splice(a,1))}}}},t.prototype._advancePhysicsEngineStep=function(e){},t.prototype.render=function(e){if(void 0===e&&(e=!0),!this.isDisposed){if(this._frameId++,this._registerTransientComponents(),this._activeParticles.fetchNewFrame(),this._totalVertices.fetchNewFrame(),this._activeIndices.fetchNewFrame(),this._activeBones.fetchNewFrame(),this._meshesForIntersections.reset(),this.resetCachedMaterial(),this.onBeforeAnimationsObservable.notifyObservers(this),this.actionManager&&this.actionManager.processTrigger(P.a.ACTION_OnEveryFrameTrigger),this._engine.isDeterministicLockStep()){var i=Math.max(t.MinDeltaTime,Math.min(this._engine.getDeltaTime(),t.MaxDeltaTime))+this._timeAccumulator,r=this.getDeterministicFrameTime(),o=0,s=this._engine.getLockstepMaxSteps(),a=Math.floor(i/60);a=Math.min(a,s);do{this.onBeforeStepObservable.notifyObservers(this),this._animationRatio=.06*r,this._animate(),this.onAfterAnimationsObservable.notifyObservers(this),this._advancePhysicsEngineStep(r),this.onAfterStepObservable.notifyObservers(this),this._currentStepId++,o++,i-=r}while(i>0&&o<a);this._timeAccumulator=i<0?0:i}else{i=this.useConstantAnimationDeltaTime?16:Math.max(t.MinDeltaTime,Math.min(this._engine.getDeltaTime(),t.MaxDeltaTime));this._animationRatio=.06*i,this._animate(),this.onAfterAnimationsObservable.notifyObservers(this),this._advancePhysicsEngineStep(i)}for(var c=0,l=this._beforeCameraUpdateStage;c<l.length;c++){l[c].action()}if(e)if(this.activeCameras.length>0)for(var u=0;u<this.activeCameras.length;u++){var h=this.activeCameras[u];if(h.update(),h.cameraRigMode!==d.a.RIG_MODE_NONE)for(var f=0;f<h._rigCameras.length;f++)h._rigCameras[f].update()}else if(this.activeCamera&&(this.activeCamera.update(),this.activeCamera.cameraRigMode!==d.a.RIG_MODE_NONE))for(f=0;f<this.activeCamera._rigCameras.length;f++)this.activeCamera._rigCameras[f].update();this.onBeforeRenderObservable.notifyObservers(this),this.onBeforeRenderTargetsRenderObservable.notifyObservers(this);var p=this.getEngine(),_=this.activeCamera;if(this.renderTargetsEnabled){n.h.StartPerformanceCounter("Custom render targets",this.customRenderTargets.length>0),this._intermediateRendering=!0;for(var g=0;g<this.customRenderTargets.length;g++){var m=this.customRenderTargets[g];if(m._shouldRender()){if(this._renderId++,this.activeCamera=m.activeCamera||this.activeCamera,!this.activeCamera)throw new Error("Active camera not set");p.setViewport(this.activeCamera.viewport),this.updateTransformMatrix(),m.render(_!==this.activeCamera,this.dumpNextRenderTargets)}}n.h.EndPerformanceCounter("Custom render targets",this.customRenderTargets.length>0),this._intermediateRendering=!1,this._renderId++}this.customRenderTargets.length>0&&p.restoreDefaultFramebuffer(),this.onAfterRenderTargetsRenderObservable.notifyObservers(this),this.activeCamera=_;for(var v=0,y=this._beforeClearStage;v<y.length;v++){y[v].action()}(this.autoClearDepthAndStencil||this.autoClear)&&this._engine.clear(this.clearColor,this.autoClear||this.forceWireframe||this.forcePointsCloud,this.autoClearDepthAndStencil,this.autoClearDepthAndStencil);for(var b=0,T=this._gatherRenderTargetsStage;b<T.length;b++){T[b].action(this._renderTargets)}if(this.activeCameras.length>0)for(u=0;u<this.activeCameras.length;u++)u>0&&this._engine.clear(null,!1,!0,!0),this._processSubCameras(this.activeCameras[u]);else{if(!this.activeCamera)throw new Error("No camera defined");this._processSubCameras(this.activeCamera)}this._checkIntersections();for(var E=0,x=this._afterRenderStage;E<x.length;E++){x[E].action()}if(this.afterRender&&this.afterRender(),this.onAfterRenderObservable.notifyObservers(this),this._toBeDisposed.length){for(f=0;f<this._toBeDisposed.length;f++){var A=this._toBeDisposed[f];A&&A.dispose()}this._toBeDisposed=[]}this.dumpNextRenderTargets&&(this.dumpNextRenderTargets=!1),this._activeBones.addCount(0,!0),this._activeIndices.addCount(0,!0),this._activeParticles.addCount(0,!0)}},t.prototype.freezeMaterials=function(){for(var e=0;e<this.materials.length;e++)this.materials[e].freeze()},t.prototype.unfreezeMaterials=function(){for(var e=0;e<this.materials.length;e++)this.materials[e].unfreeze()},t.prototype.dispose=function(){this.beforeRender=null,this.afterRender=null,this.skeletons=[],this.morphTargetManagers=[],this._transientComponents=[],this._isReadyForMeshStage.clear(),this._beforeEvaluateActiveMeshStage.clear(),this._evaluateSubMeshStage.clear(),this._activeMeshStage.clear(),this._cameraDrawRenderTargetStage.clear(),this._beforeCameraDrawStage.clear(),this._beforeRenderTargetDrawStage.clear(),this._beforeRenderingGroupDrawStage.clear(),this._beforeRenderingMeshStage.clear(),this._afterRenderingMeshStage.clear(),this._afterRenderingGroupDrawStage.clear(),this._afterCameraDrawStage.clear(),this._afterRenderTargetDrawStage.clear(),this._afterRenderStage.clear(),this._beforeCameraUpdateStage.clear(),this._beforeClearStage.clear(),this._gatherRenderTargetsStage.clear(),this._gatherActiveCameraRenderTargetsStage.clear(),this._pointerMoveStage.clear(),this._pointerDownStage.clear(),this._pointerUpStage.clear();for(var e=0,t=this._components;e<t.length;e++){t[e].dispose()}this.importedMeshesFiles=new Array,this.stopAllAnimations(),this.resetCachedMaterial(),this.activeCamera&&(this.activeCamera._activeMeshes.dispose(),this.activeCamera=null),this._activeMeshes.dispose(),this._renderingManager.dispose(),this._processedMaterials.dispose(),this._activeParticleSystems.dispose(),this._activeSkeletons.dispose(),this._softwareSkinnedMeshes.dispose(),this._renderTargets.dispose(),this._registeredForLateAnimationBindings.dispose(),this._meshesForIntersections.dispose(),this._toBeDisposed=[];for(var i=0,r=this._activeRequests;i<r.length;i++){r[i].abort()}this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this.onBeforeRenderObservable.clear(),this.onAfterRenderObservable.clear(),this.onBeforeRenderTargetsRenderObservable.clear(),this.onAfterRenderTargetsRenderObservable.clear(),this.onAfterStepObservable.clear(),this.onBeforeStepObservable.clear(),this.onBeforeActiveMeshesEvaluationObservable.clear(),this.onAfterActiveMeshesEvaluationObservable.clear(),this.onBeforeParticlesRenderingObservable.clear(),this.onAfterParticlesRenderingObservable.clear(),this.onBeforeDrawPhaseObservable.clear(),this.onAfterDrawPhaseObservable.clear(),this.onBeforeAnimationsObservable.clear(),this.onAfterAnimationsObservable.clear(),this.onDataLoadedObservable.clear(),this.onBeforeRenderingGroupObservable.clear(),this.onAfterRenderingGroupObservable.clear(),this.onMeshImportedObservable.clear(),this.onBeforeCameraRenderObservable.clear(),this.onAfterCameraRenderObservable.clear(),this.onReadyObservable.clear(),this.onNewCameraAddedObservable.clear(),this.onCameraRemovedObservable.clear(),this.onNewLightAddedObservable.clear(),this.onLightRemovedObservable.clear(),this.onNewGeometryAddedObservable.clear(),this.onGeometryRemovedObservable.clear(),this.onNewTransformNodeAddedObservable.clear(),this.onTransformNodeRemovedObservable.clear(),this.onNewMeshAddedObservable.clear(),this.onMeshRemovedObservable.clear(),this.onNewMaterialAddedObservable.clear(),this.onMaterialRemovedObservable.clear(),this.onNewTextureAddedObservable.clear(),this.onTextureRemovedObservable.clear(),this.onPrePointerObservable.clear(),this.onPointerObservable.clear(),this.onPreKeyboardObservable.clear(),this.onKeyboardObservable.clear(),this.onActiveCameraChanged.clear(),this.detachControl();var n,o=this._engine.getRenderingCanvas();if(o)for(n=0;n<this.cameras.length;n++)this.cameras[n].detachControl(o);for(;this.animationGroups.length;)this.animationGroups[0].dispose();for(;this.lights.length;)this.lights[0].dispose();for(;this.meshes.length;)this.meshes[0].dispose(!0);for(;this.transformNodes.length;)this.removeTransformNode(this.transformNodes[0]);for(;this.cameras.length;)this.cameras[0].dispose();for(this.defaultMaterial&&this.defaultMaterial.dispose();this.multiMaterials.length;)this.multiMaterials[0].dispose();for(;this.materials.length;)this.materials[0].dispose();for(;this.particleSystems.length;)this.particleSystems[0].dispose();for(;this.postProcesses.length;)this.postProcesses[0].dispose();for(;this.textures.length;)this.textures[0].dispose();this._sceneUbo.dispose(),this._alternateSceneUbo&&this._alternateSceneUbo.dispose(),this.postProcessManager.dispose(),(n=this._engine.scenes.indexOf(this))>-1&&this._engine.scenes.splice(n,1),this._engine.wipeCaches(!0),this._isDisposed=!0},Object.defineProperty(t.prototype,"isDisposed",{get:function(){return this._isDisposed},enumerable:!0,configurable:!0}),t.prototype.clearCachedVertexData=function(){for(var e=0;e<this.meshes.length;e++){var t=this.meshes[e].geometry;if(t)for(var i in t._indices=[],t._vertexBuffers)t._vertexBuffers.hasOwnProperty(i)&&(t._vertexBuffers[i]._buffer._data=null)}},t.prototype.cleanCachedTextureBuffer=function(){for(var e=0,t=this.textures;e<t.length;e++){var i=t[e];i._buffer&&(i._buffer=null)}},t.prototype.getWorldExtends=function(e){var t=new u.x(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),i=new u.x(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);return e=e||function(){return!0},this.meshes.filter(e).forEach(function(e){if(e.computeWorldMatrix(!0),e.subMeshes&&0!==e.subMeshes.length&&!e.infiniteDistance){var r=e.getBoundingInfo(),o=r.boundingBox.minimumWorld,s=r.boundingBox.maximumWorld;n.h.CheckExtends(o,t,i),n.h.CheckExtends(s,t,i)}}),{min:t,max:i}},t.prototype.createPickingRay=function(e,t,i,r,n){void 0===n&&(n=!1);var o=A.a.Zero();return this.createPickingRayToRef(e,t,i,o,r,n),o},t.prototype.createPickingRayToRef=function(e,t,i,r,n,o){void 0===o&&(o=!1);var s=this._engine;if(!n){if(!this.activeCamera)throw new Error("Active camera not set");n=this.activeCamera}var a=n.viewport.toGlobal(s.getRenderWidth(),s.getRenderHeight());return e=e/this._engine.getHardwareScalingLevel()-a.x,t=t/this._engine.getHardwareScalingLevel()-(this._engine.getRenderHeight()-a.y-a.height),r.update(e,t,a.width,a.height,i||u.j.IdentityReadOnly,o?u.j.IdentityReadOnly:n.getViewMatrix(),n.getProjectionMatrix()),this},t.prototype.createPickingRayInCameraSpace=function(e,t,i){var r=A.a.Zero();return this.createPickingRayInCameraSpaceToRef(e,t,r,i),r},t.prototype.createPickingRayInCameraSpaceToRef=function(e,t,i,r){if(!m.a)return this;var n=this._engine;if(!r){if(!this.activeCamera)throw new Error("Active camera not set");r=this.activeCamera}var o=r.viewport.toGlobal(n.getRenderWidth(),n.getRenderHeight()),s=u.j.Identity();return e=e/this._engine.getHardwareScalingLevel()-o.x,t=t/this._engine.getHardwareScalingLevel()-(this._engine.getRenderHeight()-o.y-o.height),i.update(e,t,o.width,o.height,s,s,r.getProjectionMatrix()),this},t.prototype._internalPick=function(e,t,i){if(!m.a)return null;for(var r=null,n=0;n<this.meshes.length;n++){var o=this.meshes[n];if(t){if(!t(o))continue}else if(!o.isEnabled()||!o.isVisible||!o.isPickable)continue;var s=e(o.getWorldMatrix()),a=o.intersects(s,i);if(a&&a.hit&&((i||null==r||!(a.distance>=r.distance))&&(r=a,i)))break}return r||new m.a},t.prototype._internalMultiPick=function(e,t){if(!m.a)return null;for(var i=new Array,r=0;r<this.meshes.length;r++){var n=this.meshes[r];if(t){if(!t(n))continue}else if(!n.isEnabled()||!n.isVisible||!n.isPickable)continue;var o=e(n.getWorldMatrix()),s=n.intersects(o,!1);s&&s.hit&&i.push(s)}return i},t.prototype.pick=function(e,t,i,r,n){var o=this;if(!m.a)return null;var s=this._internalPick(function(i){return o.createPickingRayToRef(e,t,i,o._tempPickingRay,n||null),o._tempPickingRay},i,r);return s&&(s.ray=this.createPickingRay(e,t,u.j.Identity(),n||null)),s},t.prototype.pickWithRay=function(e,t,i){var r=this,n=this._internalPick(function(t){return r._pickWithRayInverseMatrix||(r._pickWithRayInverseMatrix=u.j.Identity()),t.invertToRef(r._pickWithRayInverseMatrix),r._cachedRayForTransform||(r._cachedRayForTransform=A.a.Zero()),A.a.TransformToRef(e,r._pickWithRayInverseMatrix,r._cachedRayForTransform),r._cachedRayForTransform},t,i);return n&&(n.ray=e),n},t.prototype.multiPick=function(e,t,i,r){var n=this;return this._internalMultiPick(function(i){return n.createPickingRay(e,t,i,r||null)},i)},t.prototype.multiPickWithRay=function(e,t){var i=this;return this._internalMultiPick(function(t){return i._pickWithRayInverseMatrix||(i._pickWithRayInverseMatrix=u.j.Identity()),t.invertToRef(i._pickWithRayInverseMatrix),i._cachedRayForTransform||(i._cachedRayForTransform=A.a.Zero()),A.a.TransformToRef(e,i._pickWithRayInverseMatrix,i._cachedRayForTransform),i._cachedRayForTransform},t)},t.prototype.setPointerOverMesh=function(e){this._pointerOverMesh!==e&&(this._pointerOverMesh&&this._pointerOverMesh.actionManager&&this._pointerOverMesh.actionManager.processTrigger(P.a.ACTION_OnPointerOutTrigger,b.a.CreateNew(this._pointerOverMesh)),this._pointerOverMesh=e,this._pointerOverMesh&&this._pointerOverMesh.actionManager&&this._pointerOverMesh.actionManager.processTrigger(P.a.ACTION_OnPointerOverTrigger,b.a.CreateNew(this._pointerOverMesh)))},t.prototype.getPointerOverMesh=function(){return this._pointerOverMesh},t.prototype._rebuildGeometries=function(){for(var e=0,t=this.geometries;e<t.length;e++){t[e]._rebuild()}for(var i=0,r=this.meshes;i<r.length;i++){r[i]._rebuild()}this.postProcessManager&&this.postProcessManager._rebuild();for(var n=0,o=this._components;n<o.length;n++){o[n].rebuild()}for(var s=0,a=this.particleSystems;s<a.length;s++){a[s].rebuild()}},t.prototype._rebuildTextures=function(){for(var e=0,t=this.textures;e<t.length;e++){t[e]._rebuild()}this.markAllMaterialsAsDirty(P.a.MATERIAL_TextureDirtyFlag)},t.prototype._getByTags=function(e,t,i){if(void 0===t)return e;var r=[];for(var n in i=i||function(e){},e){var o=e[n];l.a&&l.a.MatchesQuery(o,t)&&(r.push(o),i(o))}return r},t.prototype.getMeshesByTags=function(e,t){return this._getByTags(this.meshes,e,t)},t.prototype.getCamerasByTags=function(e,t){return this._getByTags(this.cameras,e,t)},t.prototype.getLightsByTags=function(e,t){return this._getByTags(this.lights,e,t)},t.prototype.getMaterialByTags=function(e,t){return this._getByTags(this.materials,e,t).concat(this._getByTags(this.multiMaterials,e,t))},t.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)},t.prototype.setRenderingAutoClearDepthStencil=function(e,t,i,r){void 0===i&&(i=!0),void 0===r&&(r=!0),this._renderingManager.setRenderingAutoClearDepthStencil(e,t,i,r)},t.prototype.getAutoClearDepthStencilSetup=function(e){return this._renderingManager.getAutoClearDepthStencilSetup(e)},Object.defineProperty(t.prototype,"blockMaterialDirtyMechanism",{get:function(){return this._blockMaterialDirtyMechanism},set:function(e){this._blockMaterialDirtyMechanism!==e&&(this._blockMaterialDirtyMechanism=e,e||this.markAllMaterialsAsDirty(P.a.MATERIAL_AllDirtyFlag))},enumerable:!0,configurable:!0}),t.prototype.markAllMaterialsAsDirty=function(e,t){if(!this._blockMaterialDirtyMechanism)for(var i=0,r=this.materials;i<r.length;i++){var n=r[i];t&&!t(n)||n.markAsDirty(e)}},t.prototype._loadFile=function(e,t,i,r,o,s){var a=this,c=n.h.LoadFile(e,t,i,r?this.offlineProvider:void 0,o,s);return this._activeRequests.push(c),c.onCompleteObservable.add(function(e){a._activeRequests.splice(a._activeRequests.indexOf(e),1)}),c},t.prototype._loadFileAsync=function(e,t,i){var r=this;return new Promise(function(n,o){r._loadFile(e,function(e){n(e)},void 0,t,i,function(e,t){o(t)})})},t._uniqueIdCounter=0,t.FOGMODE_NONE=0,t.FOGMODE_EXP=1,t.FOGMODE_EXP2=2,t.FOGMODE_LINEAR=3,t.MinDeltaTime=1,t.MaxDeltaTime=1e3,t.DragMovementThreshold=10,t.LongPressDelay=500,t.DoubleClickDelay=300,t.ExclusiveDoubleClickMode=!1,t}(f.a)},function(e,t,i){"use strict";i.d(t,"a",function(){return f});var r=i(1),n=i(2),o=i(9),s=i(7),a=i(0),c=i(22),l=i(45),u=i(66),h=i(3),d=i(8),f=function(){function e(t,i,r){this.metadata=null,this.reservedDataStore=null,this.checkReadyOnEveryCall=!1,this.checkReadyOnlyOnce=!1,this.state="",this._alpha=1,this._backFaceCulling=!0,this.doNotSerialize=!1,this._storeEffectOnSubMeshes=!1,this.onDisposeObservable=new s.c,this._alphaMode=h.a.ALPHA_COMBINE,this._needDepthPrePass=!1,this.disableDepthWrite=!1,this.forceDepthWrite=!1,this.separateCullingPass=!1,this._fogEnabled=!0,this.pointSize=1,this.zOffset=0,this._wasPreviouslyReady=!1,this._fillMode=e.TriangleFillMode,this._indexInSceneMaterialArray=-1,this.name=t,this.id=t||o.h.RandomId(),this._scene=i||c.a.LastCreatedScene,this.uniqueId=this._scene.getUniqueId(),this._scene.useRightHandedSystem?this.sideOrientation=e.ClockWiseSideOrientation:this.sideOrientation=e.CounterClockWiseSideOrientation,this._uniformBuffer=new u.a(this._scene.getEngine()),this._useUBO=this.getScene().getEngine().supportsUniformBuffers,r||this._scene.addMaterial(this),this._scene.useMaterialMeshMap&&(this.meshMap={})}return Object.defineProperty(e.prototype,"alpha",{get:function(){return this._alpha},set:function(t){this._alpha!==t&&(this._alpha=t,this.markAsDirty(e.MiscDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"backFaceCulling",{get:function(){return this._backFaceCulling},set:function(t){this._backFaceCulling!==t&&(this._backFaceCulling=t,this.markAsDirty(e.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"hasRenderTargetTextures",{get:function(){return!1},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onBindObservable",{get:function(){return this._onBindObservable||(this._onBindObservable=new s.c),this._onBindObservable},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onBind",{set:function(e){this._onBindObserver&&this.onBindObservable.remove(this._onBindObserver),this._onBindObserver=this.onBindObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onUnBindObservable",{get:function(){return this._onUnBindObservable||(this._onUnBindObservable=new s.c),this._onUnBindObservable},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"alphaMode",{get:function(){return this._alphaMode},set:function(t){this._alphaMode!==t&&(this._alphaMode=t,this.markAsDirty(e.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"needDepthPrePass",{get:function(){return this._needDepthPrePass},set:function(e){this._needDepthPrePass!==e&&(this._needDepthPrePass=e,this._needDepthPrePass&&(this.checkReadyOnEveryCall=!0))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"fogEnabled",{get:function(){return this._fogEnabled},set:function(t){this._fogEnabled!==t&&(this._fogEnabled=t,this.markAsDirty(e.MiscDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"wireframe",{get:function(){switch(this._fillMode){case e.WireFrameFillMode:case e.LineListDrawMode:case e.LineLoopDrawMode:case e.LineStripDrawMode:return!0}return this._scene.forceWireframe},set:function(t){this.fillMode=t?e.WireFrameFillMode:e.TriangleFillMode},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"pointsCloud",{get:function(){switch(this._fillMode){case e.PointFillMode:case e.PointListDrawMode:return!0}return this._scene.forcePointsCloud},set:function(t){this.fillMode=t?e.PointFillMode:e.TriangleFillMode},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"fillMode",{get:function(){return this._fillMode},set:function(t){this._fillMode!==t&&(this._fillMode=t,this.markAsDirty(e.MiscDirtyFlag))},enumerable:!0,configurable:!0}),e.prototype.toString=function(e){return"Name: "+this.name},e.prototype.getClassName=function(){return"Material"},Object.defineProperty(e.prototype,"isFrozen",{get:function(){return this.checkReadyOnlyOnce},enumerable:!0,configurable:!0}),e.prototype.freeze=function(){this.checkReadyOnlyOnce=!0},e.prototype.unfreeze=function(){this.checkReadyOnlyOnce=!1},e.prototype.isReady=function(e,t){return!0},e.prototype.isReadyForSubMesh=function(e,t,i){return!1},e.prototype.getEffect=function(){return this._effect},e.prototype.getScene=function(){return this._scene},e.prototype.needAlphaBlending=function(){return this.alpha<1},e.prototype.needAlphaBlendingForMesh=function(e){return this.needAlphaBlending()||e.visibility<1||e.hasVertexAlpha},e.prototype.needAlphaTesting=function(){return!1},e.prototype.getAlphaTestTexture=function(){return null},e.prototype.markDirty=function(){this._wasPreviouslyReady=!1},e.prototype._preBind=function(t,i){void 0===i&&(i=null);var r=this._scene.getEngine(),n=(null==i?this.sideOrientation:i)===e.ClockWiseSideOrientation;return r.enableEffect(t||this._effect),r.setState(this.backFaceCulling,this.zOffset,!1,n),n},e.prototype.bind=function(e,t){},e.prototype.bindForSubMesh=function(e,t,i){},e.prototype.bindOnlyWorldMatrix=function(e){},e.prototype.bindSceneUniformBuffer=function(e,t){t.bindToEffect(e,"Scene")},e.prototype.bindView=function(e){this._useUBO?this.bindSceneUniformBuffer(e,this.getScene().getSceneUniformBuffer()):e.setMatrix("view",this.getScene().getViewMatrix())},e.prototype.bindViewProjection=function(e){this._useUBO?this.bindSceneUniformBuffer(e,this.getScene().getSceneUniformBuffer()):e.setMatrix("viewProjection",this.getScene().getTransformMatrix())},e.prototype._shouldTurnAlphaTestOn=function(e){return!this.needAlphaBlendingForMesh(e)&&this.needAlphaTesting()},e.prototype._afterBind=function(e){if(this._scene._cachedMaterial=this,this._scene._cachedVisibility=e?e.visibility:1,this._onBindObservable&&e&&this._onBindObservable.notifyObservers(e),this.disableDepthWrite){var t=this._scene.getEngine();this._cachedDepthWriteState=t.getDepthWrite(),t.setDepthWrite(!1)}},e.prototype.unbind=function(){(this._onUnBindObservable&&this._onUnBindObservable.notifyObservers(this),this.disableDepthWrite)&&this._scene.getEngine().setDepthWrite(this._cachedDepthWriteState)},e.prototype.getActiveTextures=function(){return[]},e.prototype.hasTexture=function(e){return!1},e.prototype.clone=function(e){return null},e.prototype.getBindedMeshes=function(){var e=this;if(this.meshMap){var t=new Array;for(var i in this.meshMap){var r=this.meshMap[i];r&&t.push(r)}return t}return this._scene.meshes.filter(function(t){return t.material===e})},e.prototype.forceCompilation=function(e,t,i){var n=this,o=r.a({clipPlane:!1},i),s=new l.a,c=this.getScene(),u=function(){if(n._scene&&n._scene.getEngine()){s._materialDefines&&(s._materialDefines._renderId=-1);var i=c.clipPlane;o.clipPlane&&(c.clipPlane=new a.n(0,0,0,1)),n._storeEffectOnSubMeshes?n.isReadyForSubMesh(e,s)?t&&t(n):setTimeout(u,16):n.isReady()?t&&t(n):setTimeout(u,16),o.clipPlane&&(c.clipPlane=i)}};u()},e.prototype.forceCompilationAsync=function(e,t){var i=this;return new Promise(function(r){i.forceCompilation(e,function(){r()},t)})},e.prototype.markAsDirty=function(t){this.getScene().blockMaterialDirtyMechanism||(e._DirtyCallbackArray.length=0,t&e.TextureDirtyFlag&&e._DirtyCallbackArray.push(e._TextureDirtyCallBack),t&e.LightDirtyFlag&&e._DirtyCallbackArray.push(e._LightsDirtyCallBack),t&e.FresnelDirtyFlag&&e._DirtyCallbackArray.push(e._FresnelDirtyCallBack),t&e.AttributesDirtyFlag&&e._DirtyCallbackArray.push(e._AttributeDirtyCallBack),t&e.MiscDirtyFlag&&e._DirtyCallbackArray.push(e._MiscDirtyCallBack),e._DirtyCallbackArray.length&&this._markAllSubMeshesAsDirty(e._RunDirtyCallBacks),this.getScene().resetCachedMaterial())},e.prototype._markAllSubMeshesAsDirty=function(e){if(!this.getScene().blockMaterialDirtyMechanism)for(var t=0,i=this.getScene().meshes;t<i.length;t++){var r=i[t];if(r.subMeshes)for(var n=0,o=r.subMeshes;n<o.length;n++){var s=o[n];s.getMaterial()===this&&(s._materialDefines&&e(s._materialDefines))}}},e.prototype._markAllSubMeshesAsImageProcessingDirty=function(){this._markAllSubMeshesAsDirty(e._ImageProcessingDirtyCallBack)},e.prototype._markAllSubMeshesAsTexturesDirty=function(){this._markAllSubMeshesAsDirty(e._TextureDirtyCallBack)},e.prototype._markAllSubMeshesAsFresnelDirty=function(){this._markAllSubMeshesAsDirty(e._FresnelDirtyCallBack)},e.prototype._markAllSubMeshesAsFresnelAndMiscDirty=function(){this._markAllSubMeshesAsDirty(e._FresnelAndMiscDirtyCallBack)},e.prototype._markAllSubMeshesAsLightsDirty=function(){this._markAllSubMeshesAsDirty(e._LightsDirtyCallBack)},e.prototype._markAllSubMeshesAsAttributesDirty=function(){this._markAllSubMeshesAsDirty(e._AttributeDirtyCallBack)},e.prototype._markAllSubMeshesAsMiscDirty=function(){this._markAllSubMeshesAsDirty(e._MiscDirtyCallBack)},e.prototype._markAllSubMeshesAsTexturesAndMiscDirty=function(){this._markAllSubMeshesAsDirty(e._TextureAndMiscDirtyCallBack)},e.prototype.dispose=function(e,t,i){var r=this.getScene();if(r.stopAnimation(this),r.freeProcessedMaterials(),r.removeMaterial(this),!0!==i)if(this.meshMap)for(var n in this.meshMap){(a=this.meshMap[n])&&(a.material=null,this.releaseVertexArrayObject(a,e))}else for(var o=0,s=r.meshes;o<s.length;o++){var a;(a=s[o]).material===this&&(a.material=null,this.releaseVertexArrayObject(a,e))}this._uniformBuffer.dispose(),e&&this._effect&&(this._storeEffectOnSubMeshes||r.getEngine()._releaseEffect(this._effect),this._effect=null),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this._onBindObservable&&this._onBindObservable.clear(),this._onUnBindObservable&&this._onUnBindObservable.clear()},e.prototype.releaseVertexArrayObject=function(e,t){if(e.geometry){var i=e.geometry,r=this.getScene();if(this._storeEffectOnSubMeshes)for(var n=0,o=e.subMeshes;n<o.length;n++){var s=o[n];i._releaseVertexArrayObject(s._materialEffect),t&&s._materialEffect&&r.getEngine()._releaseEffect(s._materialEffect)}else i._releaseVertexArrayObject(this._effect)}},e.prototype.serialize=function(){return n.a.Serialize(this)},e.Parse=function(e,t,i){if(e.customType){if("BABYLON.PBRMaterial"===e.customType&&e.overloadedAlbedo&&(e.customType="BABYLON.LegacyPBRMaterial",!BABYLON.LegacyPBRMaterial))return void d.a.Error("Your scene is trying to load a legacy version of the PBRMaterial, please, include it from the materials library.")}else e.customType="BABYLON.StandardMaterial";return o.h.Instantiate(e.customType).Parse(e,t,i)},e.TriangleFillMode=h.a.MATERIAL_TriangleFillMode,e.WireFrameFillMode=h.a.MATERIAL_WireFrameFillMode,e.PointFillMode=h.a.MATERIAL_PointFillMode,e.PointListDrawMode=h.a.MATERIAL_PointListDrawMode,e.LineListDrawMode=h.a.MATERIAL_LineListDrawMode,e.LineLoopDrawMode=h.a.MATERIAL_LineLoopDrawMode,e.LineStripDrawMode=h.a.MATERIAL_LineStripDrawMode,e.TriangleStripDrawMode=h.a.MATERIAL_TriangleStripDrawMode,e.TriangleFanDrawMode=h.a.MATERIAL_TriangleFanDrawMode,e.ClockWiseSideOrientation=h.a.MATERIAL_ClockWiseSideOrientation,e.CounterClockWiseSideOrientation=h.a.MATERIAL_CounterClockWiseSideOrientation,e.TextureDirtyFlag=h.a.MATERIAL_TextureDirtyFlag,e.LightDirtyFlag=h.a.MATERIAL_LightDirtyFlag,e.FresnelDirtyFlag=h.a.MATERIAL_FresnelDirtyFlag,e.AttributesDirtyFlag=h.a.MATERIAL_AttributesDirtyFlag,e.MiscDirtyFlag=h.a.MATERIAL_MiscDirtyFlag,e.AllDirtyFlag=h.a.MATERIAL_AllDirtyFlag,e._ImageProcessingDirtyCallBack=function(e){return e.markAsImageProcessingDirty()},e._TextureDirtyCallBack=function(e){return e.markAsTexturesDirty()},e._FresnelDirtyCallBack=function(e){return e.markAsFresnelDirty()},e._MiscDirtyCallBack=function(e){return e.markAsMiscDirty()},e._LightsDirtyCallBack=function(e){return e.markAsLightDirty()},e._AttributeDirtyCallBack=function(e){return e.markAsAttributesDirty()},e._FresnelAndMiscDirtyCallBack=function(t){e._FresnelDirtyCallBack(t),e._MiscDirtyCallBack(t)},e._TextureAndMiscDirtyCallBack=function(t){e._TextureDirtyCallBack(t),e._MiscDirtyCallBack(t)},e._DirtyCallbackArray=[],e._RunDirtyCallBacks=function(t){for(var i=0,r=e._DirtyCallbackArray;i<r.length;i++){(0,r[i])(t)}},r.c([Object(n.c)()],e.prototype,"id",void 0),r.c([Object(n.c)()],e.prototype,"uniqueId",void 0),r.c([Object(n.c)()],e.prototype,"name",void 0),r.c([Object(n.c)()],e.prototype,"checkReadyOnEveryCall",void 0),r.c([Object(n.c)()],e.prototype,"checkReadyOnlyOnce",void 0),r.c([Object(n.c)()],e.prototype,"state",void 0),r.c([Object(n.c)("alpha")],e.prototype,"_alpha",void 0),r.c([Object(n.c)("backFaceCulling")],e.prototype,"_backFaceCulling",void 0),r.c([Object(n.c)()],e.prototype,"sideOrientation",void 0),r.c([Object(n.c)("alphaMode")],e.prototype,"_alphaMode",void 0),r.c([Object(n.c)()],e.prototype,"_needDepthPrePass",void 0),r.c([Object(n.c)()],e.prototype,"disableDepthWrite",void 0),r.c([Object(n.c)()],e.prototype,"forceDepthWrite",void 0),r.c([Object(n.c)()],e.prototype,"separateCullingPass",void 0),r.c([Object(n.c)("fogEnabled")],e.prototype,"_fogEnabled",void 0),r.c([Object(n.c)()],e.prototype,"pointSize",void 0),r.c([Object(n.c)()],e.prototype,"zOffset",void 0),r.c([Object(n.c)()],e.prototype,"wireframe",null),r.c([Object(n.c)()],e.prototype,"pointsCloud",null),r.c([Object(n.c)()],e.prototype,"fillMode",null),e}()},function(e,t,i){"use strict";i.d(t,"a",function(){return f});var r=i(1),n=i(2),o=i(28),s=i(9),a=i(7),c=i(0),l=i(24),u=i(27),h=i(8),d=i(20),f=function(e){function t(i,r,n,s){void 0===s&&(s=!0);var l=e.call(this,i,n)||this;return l.upVector=c.x.Up(),l.orthoLeft=null,l.orthoRight=null,l.orthoBottom=null,l.orthoTop=null,l.fov=.8,l.minZ=1,l.maxZ=1e4,l.inertia=.9,l.mode=t.PERSPECTIVE_CAMERA,l.isIntermediate=!1,l.viewport=new c.z(0,0,1,1),l.layerMask=268435455,l.fovMode=t.FOVMODE_VERTICAL_FIXED,l.cameraRigMode=t.RIG_MODE_NONE,l.customRenderTargets=new Array,l.outputRenderTarget=null,l.onViewMatrixChangedObservable=new a.c,l.onProjectionMatrixChangedObservable=new a.c,l.onAfterCheckInputsObservable=new a.c,l.onRestoreStateObservable=new a.c,l._rigCameras=new Array,l._webvrViewMatrix=c.j.Identity(),l._skipRendering=!1,l._projectionMatrix=new c.j,l._postProcesses=new Array,l._activeMeshes=new o.a(256),l._globalPosition=c.x.Zero(),l._computedViewMatrix=c.j.Identity(),l._doNotComputeProjectionMatrix=!1,l._transformMatrix=c.j.Zero(),l._refreshFrustumPlanes=!0,l._isCamera=!0,l.getScene().addCamera(l),s&&!l.getScene().activeCamera&&(l.getScene().activeCamera=l),l.position=r,l}return r.d(t,e),t.prototype.storeState=function(){return this._stateStored=!0,this._storedFov=this.fov,this},t.prototype._restoreStateValues=function(){return!!this._stateStored&&(this.fov=this._storedFov,!0)},t.prototype.restoreState=function(){return!!this._restoreStateValues()&&(this.onRestoreStateObservable.notifyObservers(this),!0)},t.prototype.getClassName=function(){return"Camera"},t.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(t.prototype,"globalPosition",{get:function(){return this._globalPosition},enumerable:!0,configurable:!0}),t.prototype.getActiveMeshes=function(){return this._activeMeshes},t.prototype.isActiveMesh=function(e){return-1!==this._activeMeshes.indexOf(e)},t.prototype.isReady=function(t){if(void 0===t&&(t=!1),t)for(var i=0,r=this._postProcesses;i<r.length;i++){var n=r[i];if(n&&!n.isReady())return!1}return e.prototype.isReady.call(this,t)},t.prototype._initCache=function(){e.prototype._initCache.call(this),this._cache.position=new c.x(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.upVector=new c.x(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},t.prototype._updateCache=function(t){t||e.prototype._updateCache.call(this),this._cache.position.copyFrom(this.position),this._cache.upVector.copyFrom(this.upVector)},t.prototype._isSynchronized=function(){return this._isSynchronizedViewMatrix()&&this._isSynchronizedProjectionMatrix()},t.prototype._isSynchronizedViewMatrix=function(){return!!e.prototype._isSynchronized.call(this)&&(this._cache.position.equals(this.position)&&this._cache.upVector.equals(this.upVector)&&this.isSynchronizedWithParent())},t.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 i=this.getEngine();return e=this.mode===t.PERSPECTIVE_CAMERA?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()},t.prototype.attachControl=function(e,t){},t.prototype.detachControl=function(e){},t.prototype.update=function(){this._checkInputs(),this.cameraRigMode!==t.RIG_MODE_NONE&&this._updateRigCameras()},t.prototype._checkInputs=function(){this.onAfterCheckInputsObservable.notifyObservers(this)},Object.defineProperty(t.prototype,"rigCameras",{get:function(){return this._rigCameras},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"rigPostProcess",{get:function(){return this._rigPostProcess},enumerable:!0,configurable:!0}),t.prototype._getFirstPostProcess=function(){for(var e=0;e<this._postProcesses.length;e++)if(null!==this._postProcesses[e])return this._postProcesses[e];return null},t.prototype._cascadePostProcessesToRigCams=function(){var e=this._getFirstPostProcess();e&&e.markTextureDirty();for(var t=0,i=this._rigCameras.length;t<i;t++){var r=this._rigCameras[t],n=r._rigPostProcess;if(n)"pass"===n.getEffectName()&&(r.isIntermediate=0===this._postProcesses.length),r._postProcesses=this._postProcesses.slice(0).concat(n),n.markTextureDirty();else r._postProcesses=this._postProcesses.slice(0)}},t.prototype.attachPostProcess=function(e,t){return void 0===t&&(t=null),!e.isReusable()&&this._postProcesses.indexOf(e)>-1?(h.a.Error("You're trying to reuse a post process not defined as reusable."),0):(null==t||t<0?this._postProcesses.push(e):null===this._postProcesses[t]?this._postProcesses[t]=e:this._postProcesses.splice(t,0,e),this._cascadePostProcessesToRigCams(),this._postProcesses.indexOf(e))},t.prototype.detachPostProcess=function(e){var t=this._postProcesses.indexOf(e);-1!==t&&(this._postProcesses[t]=null),this._cascadePostProcessesToRigCams()},t.prototype.getWorldMatrix=function(){return this._isSynchronizedViewMatrix()?this._worldMatrix:(this.getViewMatrix(),this._worldMatrix)},t.prototype._getViewMatrix=function(){return c.j.Identity()},t.prototype.getViewMatrix=function(e){return!e&&this._isSynchronizedViewMatrix()?this._computedViewMatrix:(this.updateCache(),this._computedViewMatrix=this._getViewMatrix(),this._currentRenderId=this.getScene().getRenderId(),this._childRenderId=this._currentRenderId,this._refreshFrustumPlanes=!0,this._cameraRigParams&&this._cameraRigParams.vrPreViewMatrix&&this._computedViewMatrix.multiplyToRef(this._cameraRigParams.vrPreViewMatrix,this._computedViewMatrix),this.onViewMatrixChangedObservable.notifyObservers(this),this._computedViewMatrix.invertToRef(this._worldMatrix),this._computedViewMatrix)},t.prototype.freezeProjectionMatrix=function(e){this._doNotComputeProjectionMatrix=!0,void 0!==e&&(this._projectionMatrix=e)},t.prototype.unfreezeProjectionMatrix=function(){this._doNotComputeProjectionMatrix=!1},t.prototype.getProjectionMatrix=function(e){if(this._doNotComputeProjectionMatrix||!e&&this._isSynchronizedProjectionMatrix())return this._projectionMatrix;this._cache.mode=this.mode,this._cache.minZ=this.minZ,this._cache.maxZ=this.maxZ,this._refreshFrustumPlanes=!0;var i=this.getEngine(),r=this.getScene();if(this.mode===t.PERSPECTIVE_CAMERA)this._cache.fov=this.fov,this._cache.fovMode=this.fovMode,this._cache.aspectRatio=i.getAspectRatio(this),this.minZ<=0&&(this.minZ=.1),r.useRightHandedSystem?c.j.PerspectiveFovRHToRef(this.fov,i.getAspectRatio(this),this.minZ,this.maxZ,this._projectionMatrix,this.fovMode===t.FOVMODE_VERTICAL_FIXED):c.j.PerspectiveFovLHToRef(this.fov,i.getAspectRatio(this),this.minZ,this.maxZ,this._projectionMatrix,this.fovMode===t.FOVMODE_VERTICAL_FIXED);else{var n=i.getRenderWidth()/2,o=i.getRenderHeight()/2;r.useRightHandedSystem?c.j.OrthoOffCenterRHToRef(this.orthoLeft||-n,this.orthoRight||n,this.orthoBottom||-o,this.orthoTop||o,this.minZ,this.maxZ,this._projectionMatrix):c.j.OrthoOffCenterLHToRef(this.orthoLeft||-n,this.orthoRight||n,this.orthoBottom||-o,this.orthoTop||o,this.minZ,this.maxZ,this._projectionMatrix),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()}return this.onProjectionMatrixChangedObservable.notifyObservers(this),this._projectionMatrix},t.prototype.getTransformationMatrix=function(){return this._computedViewMatrix.multiplyToRef(this._projectionMatrix,this._transformMatrix),this._transformMatrix},t.prototype._updateFrustumPlanes=function(){this._refreshFrustumPlanes&&(this.getTransformationMatrix(),this._frustumPlanes?c.i.GetPlanesToRef(this._transformMatrix,this._frustumPlanes):this._frustumPlanes=c.i.GetPlanes(this._transformMatrix),this._refreshFrustumPlanes=!1)},t.prototype.isInFrustum=function(e){return this._updateFrustumPlanes(),e.isInFrustum(this._frustumPlanes)},t.prototype.isCompletelyInFrustum=function(e){return this._updateFrustumPlanes(),e.isCompletelyInFrustum(this._frustumPlanes)},t.prototype.getForwardRay=function(e,t,i){void 0===e&&(e=100),t||(t=this.getWorldMatrix()),i||(i=this.position);var r=this._scene.useRightHandedSystem?new c.x(0,0,-1):new c.x(0,0,1),n=c.x.TransformNormal(r,t),o=c.x.Normalize(n);return new u.a(i,o,e)},t.prototype.dispose=function(i,r){for(void 0===r&&(r=!1),this.onViewMatrixChangedObservable.clear(),this.onProjectionMatrixChangedObservable.clear(),this.onAfterCheckInputsObservable.clear(),this.onRestoreStateObservable.clear(),this.inputs&&this.inputs.clear(),this.getScene().stopAnimation(this),this.getScene().removeCamera(this);this._rigCameras.length>0;){var n=this._rigCameras.pop();n&&n.dispose()}if(this._rigPostProcess)this._rigPostProcess.dispose(this),this._rigPostProcess=null,this._postProcesses=[];else if(this.cameraRigMode!==t.RIG_MODE_NONE)this._rigPostProcess=null,this._postProcesses=[];else for(var o=this._postProcesses.length;--o>=0;){var s=this._postProcesses[o];s&&s.dispose(this)}for(o=this.customRenderTargets.length;--o>=0;)this.customRenderTargets[o].dispose();this.customRenderTargets=[],this._activeMeshes.dispose(),e.prototype.dispose.call(this,i,r)},Object.defineProperty(t.prototype,"leftCamera",{get:function(){return this._rigCameras.length<1?null:this._rigCameras[0]},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"rightCamera",{get:function(){return this._rigCameras.length<2?null:this._rigCameras[1]},enumerable:!0,configurable:!0}),t.prototype.getLeftTarget=function(){return this._rigCameras.length<1?null:this._rigCameras[0].getTarget()},t.prototype.getRightTarget=function(){return this._rigCameras.length<2?null:this._rigCameras[1].getTarget()},t.prototype.setCameraRigMode=function(e,i){if(this.cameraRigMode!==e){for(;this._rigCameras.length>0;){var r=this._rigCameras.pop();r&&r.dispose()}if(this.cameraRigMode=e,this._cameraRigParams={},this._cameraRigParams.interaxialDistance=i.interaxialDistance||.0637,this._cameraRigParams.stereoHalfAngle=s.h.ToRadians(this._cameraRigParams.interaxialDistance/.0637),this.cameraRigMode!==t.RIG_MODE_NONE){var n=this.createRigCamera(this.name+"_L",0),o=this.createRigCamera(this.name+"_R",1);n&&o&&(this._rigCameras.push(n),this._rigCameras.push(o))}switch(this.cameraRigMode){case t.RIG_MODE_STEREOSCOPIC_ANAGLYPH:t._setStereoscopicAnaglyphRigMode(this);break;case t.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case t.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:case t.RIG_MODE_STEREOSCOPIC_OVERUNDER:t._setStereoscopicRigMode(this);break;case t.RIG_MODE_VR:t._setVRRigMode(this,i);break;case t.RIG_MODE_WEBVR:t._setWebVRRigMode(this,i)}this._cascadePostProcessesToRigCams(),this.update()}},t._setStereoscopicRigMode=function(e){throw"Import Cameras/RigModes/stereoscopicRigMode before using stereoscopic rig mode"},t._setStereoscopicAnaglyphRigMode=function(e){throw"Import Cameras/RigModes/stereoscopicAnaglyphRigMode before using stereoscopic anaglyph rig mode"},t._setVRRigMode=function(e,t){throw"Import Cameras/RigModes/vrRigMode before using VR rig mode"},t._setWebVRRigMode=function(e,t){throw"Import Cameras/RigModes/WebVRRigMode before using Web VR rig mode"},t.prototype._getVRProjectionMatrix=function(){return c.j.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},t.prototype._updateCameraRotationMatrix=function(){},t.prototype._updateWebVRCameraRotationMatrix=function(){},t.prototype._getWebVRProjectionMatrix=function(){return c.j.Identity()},t.prototype._getWebVRViewMatrix=function(){return c.j.Identity()},t.prototype.setCameraRigParameter=function(e,t){this._cameraRigParams||(this._cameraRigParams={}),this._cameraRigParams[e]=t,"interaxialDistance"===e&&(this._cameraRigParams.stereoHalfAngle=s.h.ToRadians(t/.0637))},t.prototype.createRigCamera=function(e,t){return null},t.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._rigCameras[e].upVector.copyFrom(this.upVector);this.cameraRigMode===t.RIG_MODE_STEREOSCOPIC_ANAGLYPH&&(this._rigCameras[0].viewport=this._rigCameras[1].viewport=this.viewport)},t.prototype._setupInputs=function(){},t.prototype.serialize=function(){var e=n.a.Serialize(this);return e.type=this.getClassName(),this.parent&&(e.parentId=this.parent.id),this.inputs&&this.inputs.serialize(e),n.a.AppendSerializedAnimations(this,e),e.ranges=this.serializeAnimationRanges(),e},t.prototype.clone=function(e){return n.a.Clone(t.GetConstructorFromName(this.getClassName(),e,this.getScene(),this.interaxialDistance,this.isStereoscopicSideBySide),this)},t.prototype.getDirection=function(e){var t=c.x.Zero();return this.getDirectionToRef(e,t),t},t.prototype.getDirectionToRef=function(e,t){c.x.TransformNormalToRef(e,this.getWorldMatrix(),t)},t.GetConstructorFromName=function(e,i,r,n,o){void 0===n&&(n=0),void 0===o&&(o=!0);var s=l.a.Construct(e,i,r,{interaxial_distance:n,isStereoscopicSideBySide:o});return s||function(){return t._createDefaultParsedCamera(i,r)}},t.prototype.computeWorldMatrix=function(){return this.getWorldMatrix()},t.Parse=function(e,i){var r=e.type,o=t.GetConstructorFromName(r,e.name,i,e.interaxial_distance,e.isStereoscopicSideBySide),s=n.a.Parse(o,e,i);if(e.parentId&&(s._waitingParentId=e.parentId),s.inputs&&(s.inputs.parse(e),s._setupInputs()),s.setPosition&&(s.position.copyFromFloats(0,0,0),s.setPosition(c.x.FromArray(e.position))),e.target&&s.setTarget&&s.setTarget(c.x.FromArray(e.target)),e.cameraRigMode){var a=e.interaxial_distance?{interaxialDistance:e.interaxial_distance}:{};s.setCameraRigMode(e.cameraRigMode,a)}if(e.animations){for(var u=0;u<e.animations.length;u++){var h=e.animations[u],f=d.a.GetClass("BABYLON.Animation");f&&s.animations.push(f.Parse(h))}l.a.ParseAnimationRanges(s,e,i)}return e.autoAnimate&&i.beginAnimation(s,e.autoAnimateFrom,e.autoAnimateTo,e.autoAnimateLoop,e.autoAnimateSpeed||1),s},t._createDefaultParsedCamera=function(e,t){throw"UniversalCamera needs to be imported before deserialization can create a default camera."},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.RIG_MODE_CUSTOM=22,t.ForceAttachControlToAlwaysPreventDefault=!1,t.UseAlternateWebVRRendering=!1,r.c([Object(n.n)()],t.prototype,"position",void 0),r.c([Object(n.n)()],t.prototype,"upVector",void 0),r.c([Object(n.c)()],t.prototype,"orthoLeft",void 0),r.c([Object(n.c)()],t.prototype,"orthoRight",void 0),r.c([Object(n.c)()],t.prototype,"orthoBottom",void 0),r.c([Object(n.c)()],t.prototype,"orthoTop",void 0),r.c([Object(n.c)()],t.prototype,"fov",void 0),r.c([Object(n.c)()],t.prototype,"minZ",void 0),r.c([Object(n.c)()],t.prototype,"maxZ",void 0),r.c([Object(n.c)()],t.prototype,"inertia",void 0),r.c([Object(n.c)()],t.prototype,"mode",void 0),r.c([Object(n.c)()],t.prototype,"layerMask",void 0),r.c([Object(n.c)()],t.prototype,"fovMode",void 0),r.c([Object(n.c)()],t.prototype,"cameraRigMode",void 0),r.c([Object(n.c)()],t.prototype,"interaxialDistance",void 0),r.c([Object(n.c)()],t.prototype,"isStereoscopicSideBySide",void 0),t}(l.a)},function(e,t,i){"use strict";i.d(t,"a",function(){return r});var r=function(){function e(){}return e.GetClass=function(e){return this.RegisteredTypes&&this.RegisteredTypes[e]?this.RegisteredTypes[e]:null},e.RegisteredTypes={},e}()},function(e,t,i){"use strict";i.d(t,"a",function(){return o});var r=i(11),n=i(3),o=function(){function e(){}return Object.defineProperty(e,"DiffuseTextureEnabled",{get:function(){return this._DiffuseTextureEnabled},set:function(e){this._DiffuseTextureEnabled!==e&&(this._DiffuseTextureEnabled=e,r.b.MarkAllMaterialsAsDirty(n.a.MATERIAL_TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(e,"AmbientTextureEnabled",{get:function(){return this._AmbientTextureEnabled},set:function(e){this._AmbientTextureEnabled!==e&&(this._AmbientTextureEnabled=e,r.b.MarkAllMaterialsAsDirty(n.a.MATERIAL_TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(e,"OpacityTextureEnabled",{get:function(){return this._OpacityTextureEnabled},set:function(e){this._OpacityTextureEnabled!==e&&(this._OpacityTextureEnabled=e,r.b.MarkAllMaterialsAsDirty(n.a.MATERIAL_TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(e,"ReflectionTextureEnabled",{get:function(){return this._ReflectionTextureEnabled},set:function(e){this._ReflectionTextureEnabled!==e&&(this._ReflectionTextureEnabled=e,r.b.MarkAllMaterialsAsDirty(n.a.MATERIAL_TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(e,"EmissiveTextureEnabled",{get:function(){return this._EmissiveTextureEnabled},set:function(e){this._EmissiveTextureEnabled!==e&&(this._EmissiveTextureEnabled=e,r.b.MarkAllMaterialsAsDirty(n.a.MATERIAL_TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(e,"SpecularTextureEnabled",{get:function(){return this._SpecularTextureEnabled},set:function(e){this._SpecularTextureEnabled!==e&&(this._SpecularTextureEnabled=e,r.b.MarkAllMaterialsAsDirty(n.a.MATERIAL_TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(e,"BumpTextureEnabled",{get:function(){return this._BumpTextureEnabled},set:function(e){this._BumpTextureEnabled!==e&&(this._BumpTextureEnabled=e,r.b.MarkAllMaterialsAsDirty(n.a.MATERIAL_TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(e,"LightmapTextureEnabled",{get:function(){return this._LightmapTextureEnabled},set:function(e){this._LightmapTextureEnabled!==e&&(this._LightmapTextureEnabled=e,r.b.MarkAllMaterialsAsDirty(n.a.MATERIAL_TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(e,"RefractionTextureEnabled",{get:function(){return this._RefractionTextureEnabled},set:function(e){this._RefractionTextureEnabled!==e&&(this._RefractionTextureEnabled=e,r.b.MarkAllMaterialsAsDirty(n.a.MATERIAL_TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(e,"ColorGradingTextureEnabled",{get:function(){return this._ColorGradingTextureEnabled},set:function(e){this._ColorGradingTextureEnabled!==e&&(this._ColorGradingTextureEnabled=e,r.b.MarkAllMaterialsAsDirty(n.a.MATERIAL_TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(e,"FresnelEnabled",{get:function(){return this._FresnelEnabled},set:function(e){this._FresnelEnabled!==e&&(this._FresnelEnabled=e,r.b.MarkAllMaterialsAsDirty(n.a.MATERIAL_FresnelDirtyFlag))},enumerable:!0,configurable:!0}),e._DiffuseTextureEnabled=!0,e._AmbientTextureEnabled=!0,e._OpacityTextureEnabled=!0,e._ReflectionTextureEnabled=!0,e._EmissiveTextureEnabled=!0,e._SpecularTextureEnabled=!0,e._BumpTextureEnabled=!0,e._LightmapTextureEnabled=!0,e._RefractionTextureEnabled=!0,e._ColorGradingTextureEnabled=!0,e._FresnelEnabled=!0,e}()},function(e,t,i){"use strict";i.d(t,"a",function(){return r});var r=function(){function e(){}return Object.defineProperty(e,"LastCreatedEngine",{get:function(){return 0===this.Instances.length?null:this.Instances[this.Instances.length-1]},enumerable:!0,configurable:!0}),Object.defineProperty(e,"LastCreatedScene",{get:function(){var e=this.LastCreatedEngine;return e?0===e.scenes.length?null:e.scenes[e.scenes.length-1]:null},enumerable:!0,configurable:!0}),e.Instances=new Array,e}()},function(e,t,i){"use strict";i.d(t,"a",function(){return _});var r=i(1),n=i(9),o=i(7),s=i(0),a=i(11),c=i(4),l=i(13),u=i(46),h=i(51),d=i(41),f=i(3),p=function(){return function(){this.facetNb=0,this.partitioningSubdivisions=10,this.partitioningBBoxRatio=1.01,this.facetDataEnabled=!1,this.facetParameters={},this.bbSize=s.x.Zero(),this.subDiv={max:1,X:1,Y:1,Z:1},this.facetDepthSort=!1,this.facetDepthSortEnabled=!1}}(),_=function(e){function t(i,r){void 0===r&&(r=null);var n=e.call(this,i,r,!1)||this;return n._facetData=new p,n.cullingStrategy=t.CULLINGSTRATEGY_STANDARD,n.onCollideObservable=new o.c,n.onCollisionPositionChangeObservable=new o.c,n.onMaterialChangedObservable=new o.c,n.definedFacingForward=!0,n._visibility=1,n.alphaIndex=Number.MAX_VALUE,n.isVisible=!0,n.isPickable=!0,n.showSubMeshesBoundingBox=!1,n.isBlocker=!1,n.enablePointerMoveEvents=!1,n.renderingGroupId=0,n._receiveShadows=!1,n.outlineColor=s.e.Red(),n.outlineWidth=.02,n.overlayColor=s.e.Red(),n.overlayAlpha=.5,n._hasVertexAlpha=!1,n._useVertexColors=!0,n._computeBonesUsingShaders=!0,n._numBoneInfluencers=4,n._applyFog=!0,n.useOctreeForRenderingSelection=!0,n.useOctreeForPicking=!0,n.useOctreeForCollisions=!0,n._layerMask=268435455,n.alwaysSelectAsActiveMesh=!1,n.actionManager=null,n._checkCollisions=!1,n._collisionMask=-1,n._collisionGroup=-1,n.ellipsoid=new s.x(.5,1,.5),n.ellipsoidOffset=new s.x(0,0,0),n._oldPositionForCollisions=new s.x(0,0,0),n._diffPositionForCollisions=new s.x(0,0,0),n.edgesWidth=1,n.edgesColor=new s.f(1,0,0,1),n._renderId=0,n._intersectionsInProgress=new Array,n._unIndexed=!1,n._lightSources=new Array,n.onRebuildObservable=new o.c,n._onCollisionPositionChange=function(e,t,i){void 0===i&&(i=null),t.subtractToRef(n._oldPositionForCollisions,n._diffPositionForCollisions),n._diffPositionForCollisions.length()>a.b.CollisionsEpsilon&&n.position.addInPlace(n._diffPositionForCollisions),i&&n.onCollideObservable.notifyObservers(i),n.onCollisionPositionChangeObservable.notifyObservers(n.position)},n.getScene().addMesh(n),n._resyncLightSources(),n}return r.d(t,e),Object.defineProperty(t,"BILLBOARDMODE_NONE",{get:function(){return u.a.BILLBOARDMODE_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(t,"BILLBOARDMODE_X",{get:function(){return u.a.BILLBOARDMODE_X},enumerable:!0,configurable:!0}),Object.defineProperty(t,"BILLBOARDMODE_Y",{get:function(){return u.a.BILLBOARDMODE_Y},enumerable:!0,configurable:!0}),Object.defineProperty(t,"BILLBOARDMODE_Z",{get:function(){return u.a.BILLBOARDMODE_Z},enumerable:!0,configurable:!0}),Object.defineProperty(t,"BILLBOARDMODE_ALL",{get:function(){return u.a.BILLBOARDMODE_ALL},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"facetNb",{get:function(){return this._facetData.facetNb},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"partitioningSubdivisions",{get:function(){return this._facetData.partitioningSubdivisions},set:function(e){this._facetData.partitioningSubdivisions=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"partitioningBBoxRatio",{get:function(){return this._facetData.partitioningBBoxRatio},set:function(e){this._facetData.partitioningBBoxRatio=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"mustDepthSortFacets",{get:function(){return this._facetData.facetDepthSort},set:function(e){this._facetData.facetDepthSort=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"facetDepthSortFrom",{get:function(){return this._facetData.facetDepthSortFrom},set:function(e){this._facetData.facetDepthSortFrom=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isFacetDataEnabled",{get:function(){return this._facetData.facetDataEnabled},enumerable:!0,configurable:!0}),t.prototype._updateNonUniformScalingState=function(t){return!!e.prototype._updateNonUniformScalingState.call(this,t)&&(this._markSubMeshesAsMiscDirty(),!0)},Object.defineProperty(t.prototype,"onCollide",{set:function(e){this._onCollideObserver&&this.onCollideObservable.remove(this._onCollideObserver),this._onCollideObserver=this.onCollideObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onCollisionPositionChange",{set:function(e){this._onCollisionPositionChangeObserver&&this.onCollisionPositionChangeObservable.remove(this._onCollisionPositionChangeObserver),this._onCollisionPositionChangeObserver=this.onCollisionPositionChangeObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"visibility",{get:function(){return this._visibility},set:function(e){this._visibility!==e&&(this._visibility=e,this._markSubMeshesAsMiscDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"material",{get:function(){return this._material},set:function(e){this._material!==e&&(this._material&&this._material.meshMap&&(this._material.meshMap[this.uniqueId]=void 0),this._material=e,e&&e.meshMap&&(e.meshMap[this.uniqueId]=this),this.onMaterialChangedObservable.hasObservers&&this.onMaterialChangedObservable.notifyObservers(this),this.subMeshes&&this._unBindEffect())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"receiveShadows",{get:function(){return this._receiveShadows},set:function(e){this._receiveShadows!==e&&(this._receiveShadows=e,this._markSubMeshesAsLightDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"hasVertexAlpha",{get:function(){return this._hasVertexAlpha},set:function(e){this._hasVertexAlpha!==e&&(this._hasVertexAlpha=e,this._markSubMeshesAsAttributesDirty(),this._markSubMeshesAsMiscDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useVertexColors",{get:function(){return this._useVertexColors},set:function(e){this._useVertexColors!==e&&(this._useVertexColors=e,this._markSubMeshesAsAttributesDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"computeBonesUsingShaders",{get:function(){return this._computeBonesUsingShaders},set:function(e){this._computeBonesUsingShaders!==e&&(this._computeBonesUsingShaders=e,this._markSubMeshesAsAttributesDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"numBoneInfluencers",{get:function(){return this._numBoneInfluencers},set:function(e){this._numBoneInfluencers!==e&&(this._numBoneInfluencers=e,this._markSubMeshesAsAttributesDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"applyFog",{get:function(){return this._applyFog},set:function(e){this._applyFog!==e&&(this._applyFog=e,this._markSubMeshesAsMiscDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"layerMask",{get:function(){return this._layerMask},set:function(e){e!==this._layerMask&&(this._layerMask=e,this._resyncLightSources())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"collisionMask",{get:function(){return this._collisionMask},set:function(e){this._collisionMask=isNaN(e)?-1:e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"collisionGroup",{get:function(){return this._collisionGroup},set:function(e){this._collisionGroup=isNaN(e)?-1:e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"_positions",{get:function(){return null},enumerable:!0,configurable:!0}),Object.defineProperty(t.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}),t.prototype.getClassName=function(){return"AbstractMesh"},t.prototype.toString=function(e){var t="Name: "+this.name+", isInstance: "+("InstancedMesh"!==this.getClassName()?"YES":"NO");return t+=", # of submeshes: "+(this.subMeshes?this.subMeshes.length:0),this._skeleton&&(t+=", skeleton: "+this._skeleton.name),e&&(t+=", billboard mode: "+["NONE","X","Y",null,"Z",null,null,"ALL"][this.billboardMode],t+=", freeze wrld mat: "+(this._isWorldMatrixFrozen||this._waitingFreezeWorldMatrix?"YES":"NO")),t},t.prototype._rebuild=function(){if(this.onRebuildObservable.notifyObservers(this),this._occlusionQuery&&(this._occlusionQuery=null),this.subMeshes)for(var e=0,t=this.subMeshes;e<t.length;e++){t[e]._rebuild()}},t.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()},t.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()},t.prototype._unBindEffect=function(){for(var e=0,t=this.subMeshes;e<t.length;e++){t[e].setEffect(null)}},t.prototype._removeLightSource=function(e){var t=this._lightSources.indexOf(e);-1!==t&&(this._lightSources.splice(t,1),this._markSubMeshesAsLightDirty())},t.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)}},t.prototype._markSubMeshesAsLightDirty=function(){this._markSubMeshesAsDirty(function(e){return e.markAsLightDirty()})},t.prototype._markSubMeshesAsAttributesDirty=function(){this._markSubMeshesAsDirty(function(e){return e.markAsAttributesDirty()})},t.prototype._markSubMeshesAsMiscDirty=function(){if(this.subMeshes)for(var e=0,t=this.subMeshes;e<t.length;e++){var i=t[e].getMaterial();i&&i.markAsDirty(f.a.MATERIAL_MiscDirtyFlag)}},Object.defineProperty(t.prototype,"scaling",{get:function(){return this._scaling},set:function(e){this._scaling=e,this.physicsImpostor&&this.physicsImpostor.forceUpdate()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isBlocked",{get:function(){return!1},enumerable:!0,configurable:!0}),t.prototype.getLOD=function(e){return this},t.prototype.getTotalVertices=function(){return 0},t.prototype.getTotalIndices=function(){return 0},t.prototype.getIndices=function(){return null},t.prototype.getVerticesData=function(e){return null},t.prototype.setVerticesData=function(e,t,i,r){return this},t.prototype.updateVerticesData=function(e,t,i,r){return this},t.prototype.setIndices=function(e,t){return this},t.prototype.isVerticesDataPresent=function(e){return!1},t.prototype.getBoundingInfo=function(){return this._masterMesh?this._masterMesh.getBoundingInfo():(this._boundingInfo||this._updateBoundingInfo(),this._boundingInfo)},t.prototype.normalizeToUnitCube=function(e){void 0===e&&(e=!0);var t=this.getHierarchyBoundingVectors(e),i=t.max.subtract(t.min),r=Math.max(i.x,i.y,i.z);if(0===r)return this;var n=1/r;return this.scaling.scaleInPlace(n),this},t.prototype.setBoundingInfo=function(e){return this._boundingInfo=e,this},Object.defineProperty(t.prototype,"useBones",{get:function(){return this.skeleton&&this.getScene().skeletonsEnabled&&this.isVerticesDataPresent(c.b.MatricesIndicesKind)&&this.isVerticesDataPresent(c.b.MatricesWeightsKind)},enumerable:!0,configurable:!0}),t.prototype._preActivate=function(){},t.prototype._preActivateForIntermediateRendering=function(e){},t.prototype._activate=function(e){this._renderId=e},t.prototype.getWorldMatrix=function(){return this._masterMesh?this._masterMesh.getWorldMatrix():e.prototype.getWorldMatrix.call(this)},t.prototype._getWorldMatrixDeterminant=function(){return this._masterMesh?this._masterMesh._getWorldMatrixDeterminant():e.prototype._getWorldMatrixDeterminant.call(this)},t.prototype.movePOV=function(e,t,i){return this.position.addInPlace(this.calcMovePOV(e,t,i)),this},t.prototype.calcMovePOV=function(e,t,i){var r=new s.j;(this.rotationQuaternion?this.rotationQuaternion:s.q.RotationYawPitchRoll(this.rotation.y,this.rotation.x,this.rotation.z)).toRotationMatrix(r);var n=s.x.Zero(),o=this.definedFacingForward?-1:1;return s.x.TransformCoordinatesFromFloatsToRef(e*o,t,i*o,r,n),n},t.prototype.rotatePOV=function(e,t,i){return this.rotation.addInPlace(this.calcRotatePOV(e,t,i)),this},t.prototype.calcRotatePOV=function(e,t,i){var r=this.definedFacingForward?1:-1;return new s.x(e*r,t,i*r)},t.prototype.getHierarchyBoundingVectors=function(e,t){var i,r;void 0===e&&(e=!0),void 0===t&&(t=null),this.getScene().incrementRenderId(),this.computeWorldMatrix(!0);var o=this.getBoundingInfo();if(this.subMeshes?(i=o.boundingBox.minimumWorld,r=o.boundingBox.maximumWorld):(i=new s.x(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),r=new s.x(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE)),e)for(var a=0,c=this.getDescendants(!1);a<c.length;a++){var l=c[a];if(l.computeWorldMatrix(!0),(!t||t(l))&&l.getBoundingInfo&&0!==l.getTotalVertices()){var u=l.getBoundingInfo().boundingBox,h=u.minimumWorld,d=u.maximumWorld;n.h.CheckExtends(h,i,r),n.h.CheckExtends(d,i,r)}}return{min:i,max:r}},t.prototype.refreshBoundingInfo=function(e){return void 0===e&&(e=!1),this._boundingInfo&&this._boundingInfo.isLocked?this:(this._refreshBoundingInfo(this._getPositionData(e),null),this)},t.prototype._refreshBoundingInfo=function(e,t){if(e){var i=n.h.ExtractMinAndMax(e,0,this.getTotalVertices(),t);this._boundingInfo?this._boundingInfo.reConstruct(i.minimum,i.maximum):this._boundingInfo=new d.a(i.minimum,i.maximum)}if(this.subMeshes)for(var r=0;r<this.subMeshes.length;r++)this.subMeshes[r].refreshBoundingInfo();this._updateBoundingInfo()},t.prototype._getPositionData=function(e){var t=this.getVerticesData(c.b.PositionKind);if(t&&e&&this.skeleton){t=n.h.Slice(t);var i=this.getVerticesData(c.b.MatricesIndicesKind),r=this.getVerticesData(c.b.MatricesWeightsKind);if(r&&i)for(var o=this.numBoneInfluencers>4,a=o?this.getVerticesData(c.b.MatricesIndicesExtraKind):null,l=o?this.getVerticesData(c.b.MatricesWeightsExtraKind):null,u=this.skeleton.getTransformMatrices(this),h=s.t.Vector3[0],d=s.t.Matrix[0],f=s.t.Matrix[1],p=0,_=0;_<t.length;_+=3,p+=4){var g,m;for(d.reset(),g=0;g<4;g++)(m=r[p+g])>0&&(s.j.FromFloat32ArrayToRefScaled(u,Math.floor(16*i[p+g]),m,f),d.addToSelf(f));if(o)for(g=0;g<4;g++)(m=l[p+g])>0&&(s.j.FromFloat32ArrayToRefScaled(u,Math.floor(16*a[p+g]),m,f),d.addToSelf(f));s.x.TransformCoordinatesFromFloatsToRef(t[_],t[_+1],t[_+2],d,h),h.toArray(t,_)}}return t},t.prototype._updateBoundingInfo=function(){var e=this.skeleton&&this.skeleton.overrideMesh||this;return this._boundingInfo?this._boundingInfo.update(e.worldMatrixFromCache):this._boundingInfo=new d.a(this.absolutePosition,this.absolutePosition,e.worldMatrixFromCache),this._updateSubMeshesBoundingInfo(e.worldMatrixFromCache),this},t.prototype._updateSubMeshesBoundingInfo=function(e){if(!this.subMeshes)return this;for(var t=this.subMeshes.length,i=0;i<t;i++){var r=this.subMeshes[i];(t>1||!r.IsGlobal)&&r.updateBoundingInfo(e)}return this},t.prototype._afterComputeWorldMatrix=function(){this._updateBoundingInfo()},t.prototype.isInFrustum=function(e){return null!==this._boundingInfo&&this._boundingInfo.isInFrustum(e,this.cullingStrategy)},t.prototype.isCompletelyInFrustum=function(e){return null!==this._boundingInfo&&this._boundingInfo.isCompletelyInFrustum(e)},t.prototype.intersectsMesh=function(e,t,i){if(void 0===t&&(t=!1),!this._boundingInfo||!e._boundingInfo)return!1;if(this._boundingInfo.intersects(e._boundingInfo,t))return!0;if(i)for(var r=0,n=this.getChildMeshes();r<n.length;r++){if(n[r].intersectsMesh(e,t,!0))return!0}return!1},t.prototype.intersectsPoint=function(e){return!!this._boundingInfo&&this._boundingInfo.intersectsPoint(e)},Object.defineProperty(t.prototype,"checkCollisions",{get:function(){return this._checkCollisions},set:function(e){this._checkCollisions=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"collider",{get:function(){return this._collider},enumerable:!0,configurable:!0}),t.prototype.moveWithCollisions=function(e){this.getAbsolutePosition().addToRef(this.ellipsoidOffset,this._oldPositionForCollisions);var t=this.getScene().collisionCoordinator;return this._collider||(this._collider=t.createCollider()),this._collider._radius=this.ellipsoid,t.getNewPosition(this._oldPositionForCollisions,e,this._collider,3,this,this._onCollisionPositionChange,this.uniqueId),this},t.prototype._collideForSubMesh=function(e,t,i){if(this._generatePointsArray(),!this._positions)return this;if(!e._lastColliderWorldVertices||!e._lastColliderTransformMatrix.equals(t)){e._lastColliderTransformMatrix=t.clone(),e._lastColliderWorldVertices=[],e._trianglePlanes=[];for(var r=e.verticesStart,n=e.verticesStart+e.verticesCount,o=r;o<n;o++)e._lastColliderWorldVertices.push(s.x.TransformCoordinates(this._positions[o],t))}return i._collide(e._trianglePlanes,e._lastColliderWorldVertices,this.getIndices(),e.indexStart,e.indexStart+e.indexCount,e.verticesStart,!!e.getMaterial()),i.collisionFound&&(i.collidedMesh=this),this},t.prototype._processCollisionsForSubMeshes=function(e,t){for(var i=this._scene.getCollidingSubMeshCandidates(this,e),r=i.length,n=0;n<r;n++){var o=i.data[n];r>1&&!o._checkCollision(e)||this._collideForSubMesh(o,t,e)}return this},t.prototype._checkCollision=function(e){if(!this._boundingInfo||!this._boundingInfo._checkCollision(e))return this;var t=s.t.Matrix[0],i=s.t.Matrix[1];return s.j.ScalingToRef(1/e._radius.x,1/e._radius.y,1/e._radius.z,t),this.worldMatrixFromCache.multiplyToRef(t,i),this._processCollisionsForSubMeshes(e,i),this},t.prototype._generatePointsArray=function(){return!1},t.prototype.intersects=function(e,t){var i=new h.a,r="InstancedLinesMesh"===this.getClassName()||"LinesMesh"===this.getClassName()?this.intersectionThreshold:0,n=this._boundingInfo;if(!(this.subMeshes&&n&&e.intersectsSphere(n.boundingSphere,r)&&e.intersectsBox(n.boundingBox,r)))return i;if(!this._generatePointsArray())return i;for(var o=null,a=this._scene.getIntersectingSubMeshCandidates(this,e),c=a.length,l=0;l<c;l++){var u=a.data[l];if(!(c>1)||u.canIntersects(e)){var d=u.intersects(e,this._positions,this.getIndices(),t);if(d&&(t||!o||d.distance<o.distance)&&((o=d).subMeshId=l,t))break}}if(o){var f=this.getWorldMatrix(),p=s.t.Vector3[0],_=s.t.Vector3[1];s.x.TransformCoordinatesToRef(e.origin,f,p),e.direction.scaleToRef(o.distance,_);var g=s.x.TransformNormal(_,f).addInPlace(p);return i.hit=!0,i.distance=s.x.Distance(p,g),i.pickedPoint=g,i.pickedMesh=this,i.bu=o.bu||0,i.bv=o.bv||0,i.faceId=o.faceId,i.subMeshId=o.subMeshId,i}return i},t.prototype.clone=function(e,t,i){return null},t.prototype.releaseSubMeshes=function(){if(this.subMeshes)for(;this.subMeshes.length;)this.subMeshes[0].dispose();else this.subMeshes=new Array;return this},t.prototype.dispose=function(t,i){var r,n=this;for(void 0===i&&(i=!1),this.getScene().freeActiveMeshes(),this.getScene().freeRenderingGroups(),void 0!==this.actionManager&&null!==this.actionManager&&(this.actionManager.dispose(),this.actionManager=null),this._skeleton=null,r=0;r<this._intersectionsInProgress.length;r++){var o=this._intersectionsInProgress[r],s=o._intersectionsInProgress.indexOf(this);o._intersectionsInProgress.splice(s,1)}this._intersectionsInProgress=[],this.getScene().lights.forEach(function(e){var t=e.includedOnlyMeshes.indexOf(n);-1!==t&&e.includedOnlyMeshes.splice(t,1),-1!==(t=e.excludedMeshes.indexOf(n))&&e.excludedMeshes.splice(t,1);var i=e.getShadowGenerator();if(i){var r=i.getShadowMap();r&&r.renderList&&-1!==(t=r.renderList.indexOf(n))&&r.renderList.splice(t,1)}}),"InstancedMesh"===this.getClassName()&&"InstancedLinesMesh"===this.getClassName()||this.releaseSubMeshes();var a=this.getScene().getEngine();if(this._occlusionQuery&&(this.isOcclusionQueryInProgress=!1,a.deleteQuery(this._occlusionQuery),this._occlusionQuery=null),a.wipeCaches(),this.getScene().removeMesh(this),i&&this.material&&this.material.dispose(!1,!0),!t)for(r=0;r<this.getScene().particleSystems.length;r++)this.getScene().particleSystems[r].emitter===this&&(this.getScene().particleSystems[r].dispose(),r--);this._facetData.facetDataEnabled&&this.disableFacetData(),this.onAfterWorldMatrixUpdateObservable.clear(),this.onCollideObservable.clear(),this.onCollisionPositionChangeObservable.clear(),this.onRebuildObservable.clear(),e.prototype.dispose.call(this,t,i)},t.prototype.addChild=function(e){return e.setParent(this),this},t.prototype.removeChild=function(e){return e.setParent(null),this},t.prototype._initFacetData=function(){var e=this._facetData;e.facetNormals||(e.facetNormals=new Array),e.facetPositions||(e.facetPositions=new Array),e.facetPartitioning||(e.facetPartitioning=new Array),e.facetNb=this.getIndices().length/3|0,e.partitioningSubdivisions=e.partitioningSubdivisions?e.partitioningSubdivisions:10,e.partitioningBBoxRatio=e.partitioningBBoxRatio?e.partitioningBBoxRatio:1.01;for(var t=0;t<e.facetNb;t++)e.facetNormals[t]=s.x.Zero(),e.facetPositions[t]=s.x.Zero();return e.facetDataEnabled=!0,this},t.prototype.updateFacetData=function(){var e=this._facetData;e.facetDataEnabled||this._initFacetData();var t=this.getVerticesData(c.b.PositionKind),i=this.getIndices(),r=this.getVerticesData(c.b.NormalKind),n=this.getBoundingInfo();if(e.facetDepthSort&&!e.facetDepthSortEnabled){if(e.facetDepthSortEnabled=!0,i instanceof Uint16Array)e.depthSortedIndices=new Uint16Array(i);else if(i instanceof Uint32Array)e.depthSortedIndices=new Uint32Array(i);else{for(var o=!1,a=0;a<i.length;a++)if(i[a]>65535){o=!0;break}e.depthSortedIndices=o?new Uint32Array(i):new Uint16Array(i)}if(e.facetDepthSortFunction=function(e,t){return t.sqDistance-e.sqDistance},!e.facetDepthSortFrom){var u=this.getScene().activeCamera;e.facetDepthSortFrom=u?u.position:s.x.Zero()}e.depthSortedFacets=[];for(var h=0;h<e.facetNb;h++){var d={ind:3*h,sqDistance:0};e.depthSortedFacets.push(d)}e.invertedMatrix=s.j.Identity(),e.facetDepthSortOrigin=s.x.Zero()}e.bbSize.x=n.maximum.x-n.minimum.x>s.h?n.maximum.x-n.minimum.x:s.h,e.bbSize.y=n.maximum.y-n.minimum.y>s.h?n.maximum.y-n.minimum.y:s.h,e.bbSize.z=n.maximum.z-n.minimum.z>s.h?n.maximum.z-n.minimum.z:s.h;var f=e.bbSize.x>e.bbSize.y?e.bbSize.x:e.bbSize.y;if(f=f>e.bbSize.z?f:e.bbSize.z,e.subDiv.max=e.partitioningSubdivisions,e.subDiv.X=Math.floor(e.subDiv.max*e.bbSize.x/f),e.subDiv.Y=Math.floor(e.subDiv.max*e.bbSize.y/f),e.subDiv.Z=Math.floor(e.subDiv.max*e.bbSize.z/f),e.subDiv.X=e.subDiv.X<1?1:e.subDiv.X,e.subDiv.Y=e.subDiv.Y<1?1:e.subDiv.Y,e.subDiv.Z=e.subDiv.Z<1?1:e.subDiv.Z,e.facetParameters.facetNormals=this.getFacetLocalNormals(),e.facetParameters.facetPositions=this.getFacetLocalPositions(),e.facetParameters.facetPartitioning=this.getFacetLocalPartitioning(),e.facetParameters.bInfo=n,e.facetParameters.bbSize=e.bbSize,e.facetParameters.subDiv=e.subDiv,e.facetParameters.ratio=this.partitioningBBoxRatio,e.facetParameters.depthSort=e.facetDepthSort,e.facetDepthSort&&e.facetDepthSortEnabled&&(this.computeWorldMatrix(!0),this._worldMatrix.invertToRef(e.invertedMatrix),s.x.TransformCoordinatesToRef(e.facetDepthSortFrom,e.invertedMatrix,e.facetDepthSortOrigin),e.facetParameters.distanceTo=e.facetDepthSortOrigin),e.facetParameters.depthSortedFacets=e.depthSortedFacets,l.a.ComputeNormals(t,i,r,e.facetParameters),e.facetDepthSort&&e.facetDepthSortEnabled){e.depthSortedFacets.sort(e.facetDepthSortFunction);var p=e.depthSortedIndices.length/3|0;for(h=0;h<p;h++){var _=e.depthSortedFacets[h].ind;e.depthSortedIndices[3*h]=i[_],e.depthSortedIndices[3*h+1]=i[_+1],e.depthSortedIndices[3*h+2]=i[_+2]}this.updateIndices(e.depthSortedIndices)}return this},t.prototype.getFacetLocalNormals=function(){return this._facetData.facetNormals||this.updateFacetData(),this._facetData.facetNormals},t.prototype.getFacetLocalPositions=function(){return this._facetData.facetPositions||this.updateFacetData(),this._facetData.facetPositions},t.prototype.getFacetLocalPartitioning=function(){return this._facetData.facetPartitioning||this.updateFacetData(),this._facetData.facetPartitioning},t.prototype.getFacetPosition=function(e){var t=s.x.Zero();return this.getFacetPositionToRef(e,t),t},t.prototype.getFacetPositionToRef=function(e,t){var i=this.getFacetLocalPositions()[e],r=this.getWorldMatrix();return s.x.TransformCoordinatesToRef(i,r,t),this},t.prototype.getFacetNormal=function(e){var t=s.x.Zero();return this.getFacetNormalToRef(e,t),t},t.prototype.getFacetNormalToRef=function(e,t){var i=this.getFacetLocalNormals()[e];return s.x.TransformNormalToRef(i,this.getWorldMatrix(),t),this},t.prototype.getFacetsAtLocalCoordinates=function(e,t,i){var r=this.getBoundingInfo(),n=this._facetData,o=Math.floor((e-r.minimum.x*n.partitioningBBoxRatio)*n.subDiv.X*n.partitioningBBoxRatio/n.bbSize.x),s=Math.floor((t-r.minimum.y*n.partitioningBBoxRatio)*n.subDiv.Y*n.partitioningBBoxRatio/n.bbSize.y),a=Math.floor((i-r.minimum.z*n.partitioningBBoxRatio)*n.subDiv.Z*n.partitioningBBoxRatio/n.bbSize.z);return o<0||o>n.subDiv.max||s<0||s>n.subDiv.max||a<0||a>n.subDiv.max?null:n.facetPartitioning[o+n.subDiv.max*s+n.subDiv.max*n.subDiv.max*a]},t.prototype.getClosestFacetAtCoordinates=function(e,t,i,r,n,o){void 0===n&&(n=!1),void 0===o&&(o=!0);var a=this.getWorldMatrix(),c=s.t.Matrix[5];a.invertToRef(c);var l=s.t.Vector3[8];s.x.TransformCoordinatesFromFloatsToRef(e,t,i,c,l);var u=this.getClosestFacetAtLocalCoordinates(l.x,l.y,l.z,r,n,o);return r&&s.x.TransformCoordinatesFromFloatsToRef(r.x,r.y,r.z,a,r),u},t.prototype.getClosestFacetAtLocalCoordinates=function(e,t,i,r,n,o){void 0===n&&(n=!1),void 0===o&&(o=!0);var s=null,a=0,c=0,l=0,u=0,h=0,d=0,f=0,p=0,_=this.getFacetLocalPositions(),g=this.getFacetLocalNormals(),m=this.getFacetsAtLocalCoordinates(e,t,i);if(!m)return null;for(var v,y,b,T=Number.MAX_VALUE,E=T,x=0;x<m.length;x++)y=g[v=m[x]],u=(e-(b=_[v]).x)*y.x+(t-b.y)*y.y+(i-b.z)*y.z,(!n||n&&o&&u>=0||n&&!o&&u<=0)&&(u=y.x*b.x+y.y*b.y+y.z*b.z,h=-(y.x*e+y.y*t+y.z*i-u)/(y.x*y.x+y.y*y.y+y.z*y.z),(E=(a=(d=e+y.x*h)-e)*a+(c=(f=t+y.y*h)-t)*c+(l=(p=i+y.z*h)-i)*l)<T&&(T=E,s=v,r&&(r.x=d,r.y=f,r.z=p)));return s},t.prototype.getFacetDataParameters=function(){return this._facetData.facetParameters},t.prototype.disableFacetData=function(){return this._facetData.facetDataEnabled&&(this._facetData.facetDataEnabled=!1,this._facetData.facetPositions=new Array,this._facetData.facetNormals=new Array,this._facetData.facetPartitioning=new Array,this._facetData.facetParameters=null,this._facetData.depthSortedIndices=new Uint32Array(0)),this},t.prototype.updateIndices=function(e){return this},t.prototype.createNormals=function(e){var t,i=this.getVerticesData(c.b.PositionKind),r=this.getIndices();return t=this.isVerticesDataPresent(c.b.NormalKind)?this.getVerticesData(c.b.NormalKind):[],l.a.ComputeNormals(i,r,t,{useRightHandedSystem:this.getScene().useRightHandedSystem}),this.setVerticesData(c.b.NormalKind,t,e),this},t.prototype.alignWithNormal=function(e,t){t||(t=s.c.Y);var i=s.t.Vector3[0],r=s.t.Vector3[1];return s.x.CrossToRef(t,e,r),s.x.CrossToRef(e,r,i),this.rotationQuaternion?s.q.RotationQuaternionFromAxisToRef(i,e,r,this.rotationQuaternion):s.x.RotationFromAxisToRef(i,e,r,this.rotation),this},t.prototype._checkOcclusionQuery=function(){return!1},t.OCCLUSION_TYPE_NONE=0,t.OCCLUSION_TYPE_OPTIMISTIC=1,t.OCCLUSION_TYPE_STRICT=2,t.OCCLUSION_ALGORITHM_TYPE_ACCURATE=0,t.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE=1,t.CULLINGSTRATEGY_STANDARD=f.a.MESHES_CULLINGSTRATEGY_STANDARD,t.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY=f.a.MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY,t.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION=f.a.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION,t.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY=f.a.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY,t}(u.a)},function(e,t,i){"use strict";i.d(t,"a",function(){return c});var r=i(1),n=i(0),o=i(2),s=i(7),a=i(22),c=function(){function e(e,t,i){void 0===t&&(t=null),void 0===i&&(i=!0),this.state="",this.metadata=null,this.reservedDataStore=null,this.doNotSerialize=!1,this._isDisposed=!1,this.animations=new Array,this._ranges={},this._isEnabled=!0,this._isParentEnabled=!0,this._isReady=!0,this._currentRenderId=-1,this._parentRenderId=-1,this._childRenderId=-1,this._worldMatrix=n.j.Identity(),this._worldMatrixDeterminant=0,this._sceneRootNodesIndex=-1,this._animationPropertiesOverride=null,this._isNode=!0,this.onDisposeObservable=new s.c,this._behaviors=new Array,this.name=e,this.id=e,this._scene=t||a.a.LastCreatedScene,this.uniqueId=this._scene.getUniqueId(),this._initCache(),i&&this.addToSceneRootNodes()}return e.AddNodeConstructor=function(e,t){this._NodeConstructors[e]=t},e.Construct=function(e,t,i,r){var n=this._NodeConstructors[e];return n?n(t,i,r):null},e.prototype.isDisposed=function(){return this._isDisposed},Object.defineProperty(e.prototype,"parent",{get:function(){return this._parentNode},set:function(e){if(this._parentNode!==e){var t=this._parentNode;if(this._parentNode&&void 0!==this._parentNode._children&&null!==this._parentNode._children){var i=this._parentNode._children.indexOf(this);-1!==i&&this._parentNode._children.splice(i,1),e||this._isDisposed||this.addToSceneRootNodes()}this._parentNode=e,this._parentNode&&(void 0!==this._parentNode._children&&null!==this._parentNode._children||(this._parentNode._children=new Array),this._parentNode._children.push(this),t||this.removeFromSceneRootNodes()),this._syncParentEnabledState()}},enumerable:!0,configurable:!0}),e.prototype.addToSceneRootNodes=function(){-1===this._sceneRootNodesIndex&&(this._sceneRootNodesIndex=this._scene.rootNodes.length,this._scene.rootNodes.push(this))},e.prototype.removeFromSceneRootNodes=function(){if(-1!==this._sceneRootNodesIndex){var e=this._scene.rootNodes,t=e.length-1;e[this._sceneRootNodesIndex]=e[t],e[this._sceneRootNodesIndex]._sceneRootNodesIndex=this._sceneRootNodesIndex,this._scene.rootNodes.pop(),this._sceneRootNodesIndex=-1}},Object.defineProperty(e.prototype,"animationPropertiesOverride",{get:function(){return this._animationPropertiesOverride?this._animationPropertiesOverride:this._scene.animationPropertiesOverride},set:function(e){this._animationPropertiesOverride=e},enumerable:!0,configurable:!0}),e.prototype.getClassName=function(){return"Node"},Object.defineProperty(e.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!0,configurable:!0}),e.prototype.getScene=function(){return this._scene},e.prototype.getEngine=function(){return this._scene.getEngine()},e.prototype.addBehavior=function(e,t){var i=this;return void 0===t&&(t=!1),-1!==this._behaviors.indexOf(e)?this:(e.init(),this._scene.isLoading&&!t?this._scene.onDataLoadedObservable.addOnce(function(){e.attach(i)}):e.attach(this),this._behaviors.push(e),this)},e.prototype.removeBehavior=function(e){var t=this._behaviors.indexOf(e);return-1===t?this:(this._behaviors[t].detach(),this._behaviors.splice(t,1),this)},Object.defineProperty(e.prototype,"behaviors",{get:function(){return this._behaviors},enumerable:!0,configurable:!0}),e.prototype.getBehaviorByName=function(e){for(var t=0,i=this._behaviors;t<i.length;t++){var r=i[t];if(r.name===e)return r}return null},e.prototype.getWorldMatrix=function(){return this._currentRenderId!==this._scene.getRenderId()&&this.computeWorldMatrix(),this._worldMatrix},e.prototype._getWorldMatrixDeterminant=function(){return this._worldMatrixDeterminant},Object.defineProperty(e.prototype,"worldMatrixFromCache",{get:function(){return this._worldMatrix},enumerable:!0,configurable:!0}),e.prototype._initCache=function(){this._cache={},this._cache.parent=void 0},e.prototype.updateCache=function(e){!e&&this.isSynchronized()||(this._cache.parent=this.parent,this._updateCache())},e.prototype._updateCache=function(e){},e.prototype._isSynchronized=function(){return!0},e.prototype._markSyncedWithParent=function(){this._parentNode&&(this._parentRenderId=this._parentNode._childRenderId)},e.prototype.isSynchronizedWithParent=function(){return!this._parentNode||this._parentRenderId===this._parentNode._childRenderId&&this._parentNode.isSynchronized()},e.prototype.isSynchronized=function(){return this._cache.parent!=this._parentNode?(this._cache.parent=this._parentNode,!1):!(this._parentNode&&!this.isSynchronizedWithParent())&&this._isSynchronized()},e.prototype.isReady=function(e){return void 0===e&&(e=!1),this._isReady},e.prototype.isEnabled=function(e){return void 0===e&&(e=!0),!1===e?this._isEnabled:!!this._isEnabled&&this._isParentEnabled},e.prototype._syncParentEnabledState=function(){this._isParentEnabled=!this._parentNode||this._parentNode.isEnabled(),this._children&&this._children.forEach(function(e){e._syncParentEnabledState()})},e.prototype.setEnabled=function(e){this._isEnabled=e,this._syncParentEnabledState()},e.prototype.isDescendantOf=function(e){return!!this.parent&&(this.parent===e||this.parent.isDescendantOf(e))},e.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)}},e.prototype.getDescendants=function(e,t){var i=new Array;return this._getDescendants(i,e,t),i},e.prototype.getChildMeshes=function(e,t){var i=[];return this._getDescendants(i,e,function(e){return(!t||t(e))&&void 0!==e.cullingStrategy}),i},e.prototype.getChildren=function(e,t){return void 0===t&&(t=!0),this.getDescendants(t,e)},e.prototype._setReady=function(e){e!==this._isReady&&(e?(this.onReady&&this.onReady(this),this._isReady=!0):this._isReady=!1)},e.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},e.prototype.createAnimationRange=function(t,i,r){if(!this._ranges[t]){this._ranges[t]=e._AnimationRangeFactory(t,i,r);for(var n=0,o=this.animations.length;n<o;n++)this.animations[n]&&this.animations[n].createRange(t,i,r)}},e.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]=null},e.prototype.getAnimationRange=function(e){return this._ranges[e]},e.prototype.beginAnimation=function(e,t,i,r){var n=this.getAnimationRange(e);return n?this._scene.beginAnimation(this,n.from,n.to,t,i,r):null},e.prototype.serializeAnimationRanges=function(){var e=[];for(var t in this._ranges){var i=this._ranges[t];if(i){var r={};r.name=t,r.from=i.from,r.to=i.to,e.push(r)}}return e},e.prototype.computeWorldMatrix=function(e){return this._worldMatrix||(this._worldMatrix=n.j.Identity()),this._worldMatrix},e.prototype.dispose=function(e,t){if(void 0===t&&(t=!1),this._isDisposed=!0,!e)for(var i=0,r=this.getDescendants(!0);i<r.length;i++){r[i].dispose(e,t)}this.parent?this.parent=null:this.removeFromSceneRootNodes(),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear();for(var n=0,o=this._behaviors;n<o.length;n++){o[n].detach()}this._behaviors=[]},e.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)}},e._AnimationRangeFactory=function(e,t,i){throw"AnimationRange needs to be imported from animation before being created."},e._NodeConstructors={},r.c([Object(o.c)()],e.prototype,"name",void 0),r.c([Object(o.c)()],e.prototype,"id",void 0),r.c([Object(o.c)()],e.prototype,"uniqueId",void 0),r.c([Object(o.c)()],e.prototype,"state",void 0),r.c([Object(o.c)()],e.prototype,"metadata",void 0),e}()},function(e,t,i){"use strict";i.d(t,"a",function(){return s});var r=i(7),n=i(83),o=i(3),s=function(){function e(t,i,n){void 0===n&&(n=!1),this.onLoadedObservable=new r.c,this.previous=null,this.next=null,this._invertVScale=!1,this._initialSlot=-1,this._designatedSlot=-1,this._dataSource=e.DATASOURCE_UNKNOWN,this._comparisonFunction=0,this._sphericalPolynomial=null,this._lodGenerationScale=0,this._lodGenerationOffset=0,this._isRGBD=!1,this._references=1,this._engine=t,this._dataSource=i,n||(this._webGLTexture=t._createTexture())}return e.prototype.getEngine=function(){return this._engine},Object.defineProperty(e.prototype,"dataSource",{get:function(){return this._dataSource},enumerable:!0,configurable:!0}),e.prototype.incrementReferences=function(){this._references++},e.prototype.updateSize=function(e,t,i){void 0===i&&(i=1),this.width=e,this.height=t,this.depth=i,this.baseWidth=e,this.baseHeight=t,this.baseDepth=i,this._size=e*t*i},e.prototype._rebuild=function(){var t,i=this;switch(this.isReady=!1,this._cachedCoordinatesMode=null,this._cachedWrapU=null,this._cachedWrapV=null,this._cachedAnisotropicFilteringLevel=null,this._dataSource){case e.DATASOURCE_TEMP:return;case e.DATASOURCE_URL:return void(t=this._engine.createTexture(this.url,!this.generateMipMaps,this.invertY,null,this.samplingMode,function(){t._swapAndDie(i),i.isReady=!0},null,this._buffer,void 0,this.format));case e.DATASOURCE_RAW:return(t=this._engine.createRawTexture(this._bufferView,this.baseWidth,this.baseHeight,this.format,this.generateMipMaps,this.invertY,this.samplingMode,this._compression))._swapAndDie(this),void(this.isReady=!0);case e.DATASOURCE_RAW3D:return(t=this._engine.createRawTexture3D(this._bufferView,this.baseWidth,this.baseHeight,this.baseDepth,this.format,this.generateMipMaps,this.invertY,this.samplingMode,this._compression))._swapAndDie(this),void(this.isReady=!0);case e.DATASOURCE_DYNAMIC:return(t=this._engine.createDynamicTexture(this.baseWidth,this.baseHeight,this.generateMipMaps,this.samplingMode))._swapAndDie(this),void this._engine.updateDynamicTexture(this,this._engine.getRenderingCanvas(),this.invertY,void 0,void 0,!0);case e.DATASOURCE_RENDERTARGET:var r=new n.a;if(r.generateDepthBuffer=this._generateDepthBuffer,r.generateMipMaps=this.generateMipMaps,r.generateStencilBuffer=this._generateStencilBuffer,r.samplingMode=this.samplingMode,r.type=this.type,this.isCube)t=this._engine.createRenderTargetCubeTexture(this.width,r);else{var s={width:this.width,height:this.height};t=this._engine.createRenderTargetTexture(s,r)}return t._swapAndDie(this),void(this.isReady=!0);case e.DATASOURCE_DEPTHTEXTURE:var a={bilinearFiltering:this.samplingMode!==o.a.TEXTURE_BILINEAR_SAMPLINGMODE,comparisonFunction:this._comparisonFunction,generateStencil:this._generateStencilBuffer,isCube:this.isCube};return(t=this._engine.createDepthStencilTexture({width:this.width,height:this.height},a))._swapAndDie(this),void(this.isReady=!0);case e.DATASOURCE_CUBE:return void(t=this._engine.createCubeTexture(this.url,null,this._files,!this.generateMipMaps,function(){t._swapAndDie(i),i.isReady=!0},null,this.format,this._extension));case e.DATASOURCE_CUBERAW:return(t=this._engine.createRawCubeTexture(this._bufferViewArray,this.width,this.format,this.type,this.generateMipMaps,this.invertY,this.samplingMode,this._compression))._swapAndDie(this),void(this.isReady=!0);case e.DATASOURCE_CUBERAW_RGBD:return t=this._engine.createRawCubeTexture(null,this.width,this.format,this.type,this.generateMipMaps,this.invertY,this.samplingMode,this._compression),void e._UpdateRGBDAsync(t,this._bufferViewArrayArray,this._sphericalPolynomial,this._lodGenerationScale,this._lodGenerationOffset).then(function(){t._swapAndDie(i),i.isReady=!0});case e.DATASOURCE_CUBEPREFILTERED:return void((t=this._engine.createPrefilteredCubeTexture(this.url,null,this._lodGenerationScale,this._lodGenerationOffset,function(e){e&&e._swapAndDie(i),i.isReady=!0},null,this.format,this._extension))._sphericalPolynomial=this._sphericalPolynomial)}},e.prototype._swapAndDie=function(e){e._webGLTexture=this._webGLTexture,this._framebuffer&&(e._framebuffer=this._framebuffer),this._depthStencilBuffer&&(e._depthStencilBuffer=this._depthStencilBuffer),this._lodTextureHigh&&(e._lodTextureHigh&&e._lodTextureHigh.dispose(),e._lodTextureHigh=this._lodTextureHigh),this._lodTextureMid&&(e._lodTextureMid&&e._lodTextureMid.dispose(),e._lodTextureMid=this._lodTextureMid),this._lodTextureLow&&(e._lodTextureLow&&e._lodTextureLow.dispose(),e._lodTextureLow=this._lodTextureLow);var t=this._engine.getLoadedTexturesCache(),i=t.indexOf(this);-1!==i&&t.splice(i,1)},e.prototype.dispose=function(){this._webGLTexture&&(this._references--,0===this._references&&(this._engine._releaseTexture(this),this._webGLTexture=null,this.previous=null,this.next=null))},e._UpdateRGBDAsync=function(e,t,i,r,n){throw"environmentTextureTools needs to be imported before rebuilding RGBD textures."},e.DATASOURCE_UNKNOWN=0,e.DATASOURCE_URL=1,e.DATASOURCE_TEMP=2,e.DATASOURCE_RAW=3,e.DATASOURCE_DYNAMIC=4,e.DATASOURCE_RENDERTARGET=5,e.DATASOURCE_MULTIRENDERTARGET=6,e.DATASOURCE_CUBE=7,e.DATASOURCE_CUBERAW=8,e.DATASOURCE_CUBEPREFILTERED=9,e.DATASOURCE_RAW3D=10,e.DATASOURCE_DEPTHTEXTURE=11,e.DATASOURCE_CUBERAW_RGBD=12,e}()},function(e,t,i){"use strict";i.d(t,"a",function(){return o});var r=i(9),n=i(99),o=function(){function e(){}return e.EnableFor=function(t){t._tags=t._tags||{},t.hasTags=function(){return e.HasTags(t)},t.addTags=function(i){return e.AddTagsTo(t,i)},t.removeTags=function(i){return e.RemoveTagsFrom(t,i)},t.matchesTagsQuery=function(i){return e.MatchesQuery(t,i)}},e.DisableFor=function(e){delete e._tags,delete e.hasTags,delete e.addTags,delete e.removeTags,delete e.matchesTagsQuery},e.HasTags=function(e){return!!e._tags&&!r.h.IsEmpty(e._tags)},e.GetTags=function(e,t){if(void 0===t&&(t=!0),!e._tags)return null;if(t){var i=[];for(var r in e._tags)e._tags.hasOwnProperty(r)&&!0===e._tags[r]&&i.push(r);return i.join(" ")}return e._tags},e.AddTagsTo=function(t,i){i&&("string"==typeof i&&i.split(" ").forEach(function(i,r,n){e._AddTagTo(t,i)}))},e._AddTagTo=function(t,i){""!==(i=i.trim())&&"true"!==i&&"false"!==i&&(i.match(/[\s]/)||i.match(/^([!]|([|]|[&]){2})/)||(e.EnableFor(t),t._tags[i]=!0))},e.RemoveTagsFrom=function(t,i){if(e.HasTags(t)){var r=i.split(" ");for(var n in r)e._RemoveTagFrom(t,r[n])}},e._RemoveTagFrom=function(e,t){delete e._tags[t]},e.MatchesQuery=function(t,i){return void 0===i||(""===i?e.HasTags(t):n.a.Eval(i,function(i){return e.HasTags(t)&&t._tags[i]}))},e}()},function(e,t,i){"use strict";i.d(t,"a",function(){return s});var r=i(34),n=i(0),o=i(81),s=function(){function e(e,t,i){void 0===i&&(i=Number.MAX_VALUE),this.origin=e,this.direction=t,this.length=i}return e.prototype.intersectsBoxMinMax=function(t,i,r){void 0===r&&(r=0);var n,o,s,a,c=e.TmpVector3[0].copyFromFloats(t.x-r,t.y-r,t.z-r),l=e.TmpVector3[1].copyFromFloats(i.x+r,i.y+r,i.z+r),u=0,h=Number.MAX_VALUE;if(Math.abs(this.direction.x)<1e-7){if(this.origin.x<c.x||this.origin.x>l.x)return!1}else if(n=1/this.direction.x,o=(c.x-this.origin.x)*n,(s=(l.x-this.origin.x)*n)===-1/0&&(s=1/0),o>s&&(a=o,o=s,s=a),(u=Math.max(o,u))>(h=Math.min(s,h)))return!1;if(Math.abs(this.direction.y)<1e-7){if(this.origin.y<c.y||this.origin.y>l.y)return!1}else if(n=1/this.direction.y,o=(c.y-this.origin.y)*n,(s=(l.y-this.origin.y)*n)===-1/0&&(s=1/0),o>s&&(a=o,o=s,s=a),(u=Math.max(o,u))>(h=Math.min(s,h)))return!1;if(Math.abs(this.direction.z)<1e-7){if(this.origin.z<c.z||this.origin.z>l.z)return!1}else if(n=1/this.direction.z,o=(c.z-this.origin.z)*n,(s=(l.z-this.origin.z)*n)===-1/0&&(s=1/0),o>s&&(a=o,o=s,s=a),(u=Math.max(o,u))>(h=Math.min(s,h)))return!1;return!0},e.prototype.intersectsBox=function(e,t){return void 0===t&&(t=0),this.intersectsBoxMinMax(e.minimum,e.maximum,t)},e.prototype.intersectsSphere=function(e,t){void 0===t&&(t=0);var i=e.center.x-this.origin.x,r=e.center.y-this.origin.y,n=e.center.z-this.origin.z,o=i*i+r*r+n*n,s=e.radius+t,a=s*s;if(o<=a)return!0;var c=i*this.direction.x+r*this.direction.y+n*this.direction.z;return!(c<0)&&o-c*c<=a},e.prototype.intersectsTriangle=function(t,i,r){var s=e.TmpVector3[0],a=e.TmpVector3[1],c=e.TmpVector3[2],l=e.TmpVector3[3],u=e.TmpVector3[4];i.subtractToRef(t,s),r.subtractToRef(t,a),n.x.CrossToRef(this.direction,a,c);var h=n.x.Dot(s,c);if(0===h)return null;var d=1/h;this.origin.subtractToRef(t,l);var f=n.x.Dot(l,c)*d;if(f<0||f>1)return null;n.x.CrossToRef(l,s,u);var p=n.x.Dot(this.direction,u)*d;if(p<0||f+p>1)return null;var _=n.x.Dot(a,u)*d;return _>this.length?null:new o.a(f,p,_)},e.prototype.intersectsPlane=function(e){var t,i=n.x.Dot(e.normal,this.direction);if(Math.abs(i)<9.99999997475243e-7)return null;var r=n.x.Dot(e.normal,this.origin);return(t=(-e.d-r)/i)<0?t<-9.99999997475243e-7?null:0:t},e.prototype.intersectsMesh=function(t,i){var r=n.t.Matrix[0];return t.getWorldMatrix().invertToRef(r),this._tmpRay?e.TransformToRef(this,r,this._tmpRay):this._tmpRay=e.Transform(this,r),t.intersects(this._tmpRay,i)},e.prototype.intersectsMeshes=function(e,t,i){i?i.length=0:i=[];for(var r=0;r<e.length;r++){var n=this.intersectsMesh(e[r],t);n.hit&&i.push(n)}return i.sort(this._comparePickingInfo),i},e.prototype._comparePickingInfo=function(e,t){return e.distance<t.distance?-1:e.distance>t.distance?1:0},e.prototype.intersectionSegment=function(t,i,r){var o=this.origin,s=n.t.Vector3[0],a=n.t.Vector3[1],c=n.t.Vector3[2],l=n.t.Vector3[3];i.subtractToRef(t,s),this.direction.scaleToRef(e.rayl,c),o.addToRef(c,a),t.subtractToRef(o,l);var u,h,d,f,p=n.x.Dot(s,s),_=n.x.Dot(s,c),g=n.x.Dot(c,c),m=n.x.Dot(s,l),v=n.x.Dot(c,l),y=p*g-_*_,b=y,T=y;y<e.smallnum?(h=0,b=1,f=v,T=g):(f=p*v-_*m,(h=_*v-g*m)<0?(h=0,f=v,T=g):h>b&&(h=b,f=v+_,T=g)),f<0?(f=0,-m<0?h=0:-m>p?h=b:(h=-m,b=p)):f>T&&(f=T,-m+_<0?h=0:-m+_>p?h=b:(h=-m+_,b=p)),u=Math.abs(h)<e.smallnum?0:h/b,d=Math.abs(f)<e.smallnum?0:f/T;var E=n.t.Vector3[4];c.scaleToRef(d,E);var x=n.t.Vector3[5];s.scaleToRef(u,x),x.addInPlace(l);var A=n.t.Vector3[6];return x.subtractToRef(E,A),d>0&&d<=this.length&&A.lengthSquared()<r*r?x.length():-1},e.prototype.update=function(e,t,i,r,n,o,s){return this.unprojectRayToRef(e,t,i,r,n,o,s),this},e.Zero=function(){return new e(n.x.Zero(),n.x.Zero())},e.CreateNew=function(t,i,r,n,o,s,a){return e.Zero().update(t,i,r,n,o,s,a)},e.CreateNewFromTo=function(t,i,r){void 0===r&&(r=n.j.IdentityReadOnly);var o=i.subtract(t),s=Math.sqrt(o.x*o.x+o.y*o.y+o.z*o.z);return o.normalize(),e.Transform(new e(t,o,s),r)},e.Transform=function(t,i){var r=new e(new n.x(0,0,0),new n.x(0,0,0));return e.TransformToRef(t,i,r),r},e.TransformToRef=function(e,t,i){n.x.TransformCoordinatesToRef(e.origin,t,i.origin),n.x.TransformNormalToRef(e.direction,t,i.direction),i.length=e.length;var r=i.direction,o=r.length();if(0!==o&&1!==o){var s=1/o;r.x*=s,r.y*=s,r.z*=s,i.length*=o}},e.prototype.unprojectRayToRef=function(e,t,i,r,o,s,a){var c=n.t.Matrix[0];o.multiplyToRef(s,c),c.multiplyToRef(a,c),c.invert();var l=n.t.Vector3[0];l.x=e/i*2-1,l.y=-(t/r*2-1),l.z=-1;var u=n.t.Vector3[1].copyFromFloats(l.x,l.y,1),h=n.t.Vector3[2],d=n.t.Vector3[3];n.x._UnprojectFromInvertedMatrixToRef(l,c,h),n.x._UnprojectFromInvertedMatrixToRef(u,c,d),this.origin.copyFrom(h),d.subtractToRef(h,this.direction),this.direction.normalize()},e.TmpVector3=r.a.BuildArray(6,n.x.Zero),e.smallnum=1e-8,e.rayl=1e9,e}()},function(e,t,i){"use strict";i.d(t,"a",function(){return n}),i.d(t,"b",function(){return o});var r=i(1),n=function(){function e(t){this.length=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.prototype.forEach=function(e){for(var t=0;t<this.length;t++)e(this.data[t])},e.prototype.sort=function(e){this.data.sort(e)},e.prototype.reset=function(){this.length=0},e.prototype.dispose=function(){this.reset(),this.data&&(this.data.length=0,this.data=[])},e.prototype.concat=function(e){if(0!==e.length){this.length+e.length>this.data.length&&(this.data.length=2*(this.length+e.length));for(var t=0;t<e.length;t++)this.data[this.length++]=(e.data||e)[t]}},e.prototype.indexOf=function(e){var t=this.data.indexOf(e);return t>=this.length?-1:t},e.prototype.contains=function(e){return-1!==this.indexOf(e)},e._GlobalId=0,e}(),o=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._duplicateId=0,t}return r.d(t,e),t.prototype.push=function(t){e.prototype.push.call(this,t),t.__smartArrayFlags||(t.__smartArrayFlags={}),t.__smartArrayFlags[this._id]=this._duplicateId},t.prototype.pushNoDuplicate=function(e){return(!e.__smartArrayFlags||e.__smartArrayFlags[this._id]!==this._duplicateId)&&(this.push(e),!0)},t.prototype.reset=function(){e.prototype.reset.call(this),this._duplicateId++},t.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)}}},t}(n)},function(e,t,i){"use strict";i.d(t,"a",function(){return c});var r=i(8),n=i(34),o=i(0),s=i(23),a=i(36),c=function(){function e(e,t,i,n){void 0===i&&(i={mass:0});var s=this;this.object=e,this.type=t,this._options=i,this._scene=n,this._bodyUpdateRequired=!1,this._onBeforePhysicsStepCallbacks=new Array,this._onAfterPhysicsStepCallbacks=new Array,this._onPhysicsCollideCallbacks=[],this._deltaPosition=o.x.Zero(),this._isDisposed=!1,this._tmpQuat=new o.q,this._tmpQuat2=new o.q,this.beforeStep=function(){s._physicsEngine&&(s.object.translate(s._deltaPosition,-1),s._deltaRotationConjugated&&s.object.rotationQuaternion&&s.object.rotationQuaternion.multiplyToRef(s._deltaRotationConjugated,s.object.rotationQuaternion),s.object.computeWorldMatrix(!1),s.object.parent&&s.object.rotationQuaternion?(s.getParentsRotation(),s._tmpQuat.multiplyToRef(s.object.rotationQuaternion,s._tmpQuat)):s._tmpQuat.copyFrom(s.object.rotationQuaternion||new o.q),s._options.disableBidirectionalTransformation||s.object.rotationQuaternion&&s._physicsEngine.getPhysicsPlugin().setPhysicsBodyTransformation(s,s.object.getAbsolutePosition(),s._tmpQuat),s._onBeforePhysicsStepCallbacks.forEach(function(e){e(s)}))},this.afterStep=function(){s._physicsEngine&&(s._onAfterPhysicsStepCallbacks.forEach(function(e){e(s)}),s._physicsEngine.getPhysicsPlugin().setTransformationFromPhysicsBody(s),s.object.parent&&s.object.rotationQuaternion&&(s.getParentsRotation(),s._tmpQuat.conjugateInPlace(),s._tmpQuat.multiplyToRef(s.object.rotationQuaternion,s.object.rotationQuaternion)),s.object.setAbsolutePosition(s.object.position),s._deltaRotation&&s.object.rotationQuaternion&&s.object.rotationQuaternion.multiplyToRef(s._deltaRotation,s.object.rotationQuaternion),s.object.translate(s._deltaPosition,1))},this.onCollideEvent=null,this.onCollide=function(e){if((s._onPhysicsCollideCallbacks.length||s.onCollideEvent)&&s._physicsEngine){var t=s._physicsEngine.getImpostorWithPhysicsBody(e.body);t&&(s.onCollideEvent&&s.onCollideEvent(s,t),s._onPhysicsCollideCallbacks.filter(function(e){return-1!==e.otherImpostors.indexOf(t)}).forEach(function(e){e.callback(s,t)}))}},this.object?(!this._scene&&e.getScene&&(this._scene=e.getScene()),this._scene&&(this._physicsEngine=this._scene.getPhysicsEngine(),this._physicsEngine?(this.object.rotationQuaternion||(this.object.rotation?this.object.rotationQuaternion=o.q.RotationYawPitchRoll(this.object.rotation.y,this.object.rotation.x,this.object.rotation.z):this.object.rotationQuaternion=new o.q),this._options.mass=void 0===i.mass?0:i.mass,this._options.friction=void 0===i.friction?.2:i.friction,this._options.restitution=void 0===i.restitution?.2:i.restitution,this._joints=[],!this.object.parent||this._options.ignoreParent?this._init():this.object.parent.physicsImpostor&&r.a.Warn("You must affect impostors to children before affecting impostor to parent.")):r.a.Error("Physics not enabled. Please use scene.enablePhysics(...) before creating impostors."))):r.a.Error("No object was provided. A physics object is obligatory")}return Object.defineProperty(e.prototype,"isDisposed",{get:function(){return this._isDisposed},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"mass",{get:function(){return this._physicsEngine?this._physicsEngine.getPhysicsPlugin().getBodyMass(this):0},set:function(e){this.setMass(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"friction",{get:function(){return this._physicsEngine?this._physicsEngine.getPhysicsPlugin().getBodyFriction(this):0},set:function(e){this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().setBodyFriction(this,e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"restitution",{get:function(){return this._physicsEngine?this._physicsEngine.getPhysicsPlugin().getBodyRestitution(this):0},set:function(e){this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().setBodyRestitution(this,e)},enumerable:!0,configurable:!0}),e.prototype._init=function(){this._physicsEngine&&(this._physicsEngine.removeImpostor(this),this.physicsBody=null,this._parent=this._parent||this._getPhysicsParent(),this._isDisposed||this.parent&&!this._options.ignoreParent||this._physicsEngine.addImpostor(this))},e.prototype._getPhysicsParent=function(){return this.object.parent instanceof s.a?this.object.parent.physicsImpostor:null},e.prototype.isBodyInitRequired=function(){return this._bodyUpdateRequired||!this._physicsBody&&!this._parent},e.prototype.setScalingUpdated=function(){this.forceUpdate()},e.prototype.forceUpdate=function(){this._init(),this.parent&&!this._options.ignoreParent&&this.parent.forceUpdate()},Object.defineProperty(e.prototype,"physicsBody",{get:function(){return this._parent&&!this._options.ignoreParent?this._parent.physicsBody:this._physicsBody},set:function(e){this._physicsBody&&this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().removePhysicsBody(this),this._physicsBody=e,this.resetUpdateFlags()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"parent",{get:function(){return!this._options.ignoreParent&&this._parent?this._parent:null},set:function(e){this._parent=e},enumerable:!0,configurable:!0}),e.prototype.resetUpdateFlags=function(){this._bodyUpdateRequired=!1},e.prototype.getObjectExtendSize=function(){if(this.object.getBoundingInfo){var t=this.object.rotationQuaternion;this.object.rotationQuaternion=e.IDENTITY_QUATERNION,this.object.computeWorldMatrix&&this.object.computeWorldMatrix(!0);var i=this.object.getBoundingInfo().boundingBox.extendSizeWorld.scale(2);return this.object.rotationQuaternion=t,this.object.computeWorldMatrix&&this.object.computeWorldMatrix(!0),i}return e.DEFAULT_OBJECT_SIZE},e.prototype.getObjectCenter=function(){return this.object.getBoundingInfo?this.object.getBoundingInfo().boundingBox.centerWorld:this.object.position},e.prototype.getParam=function(e){return this._options[e]},e.prototype.setParam=function(e,t){this._options[e]=t,this._bodyUpdateRequired=!0},e.prototype.setMass=function(e){this.getParam("mass")!==e&&this.setParam("mass",e),this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().setBodyMass(this,e)},e.prototype.getLinearVelocity=function(){return this._physicsEngine?this._physicsEngine.getPhysicsPlugin().getLinearVelocity(this):o.x.Zero()},e.prototype.setLinearVelocity=function(e){this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().setLinearVelocity(this,e)},e.prototype.getAngularVelocity=function(){return this._physicsEngine?this._physicsEngine.getPhysicsPlugin().getAngularVelocity(this):o.x.Zero()},e.prototype.setAngularVelocity=function(e){this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().setAngularVelocity(this,e)},e.prototype.executeNativeFunction=function(e){this._physicsEngine&&e(this._physicsEngine.getPhysicsPlugin().world,this.physicsBody)},e.prototype.registerBeforePhysicsStep=function(e){this._onBeforePhysicsStepCallbacks.push(e)},e.prototype.unregisterBeforePhysicsStep=function(e){var t=this._onBeforePhysicsStepCallbacks.indexOf(e);t>-1?this._onBeforePhysicsStepCallbacks.splice(t,1):r.a.Warn("Function to remove was not found")},e.prototype.registerAfterPhysicsStep=function(e){this._onAfterPhysicsStepCallbacks.push(e)},e.prototype.unregisterAfterPhysicsStep=function(e){var t=this._onAfterPhysicsStepCallbacks.indexOf(e);t>-1?this._onAfterPhysicsStepCallbacks.splice(t,1):r.a.Warn("Function to remove was not found")},e.prototype.registerOnPhysicsCollide=function(e,t){var i=e instanceof Array?e:[e];this._onPhysicsCollideCallbacks.push({callback:t,otherImpostors:i})},e.prototype.unregisterOnPhysicsCollide=function(e,t){var i=e instanceof Array?e:[e],n=-1;this._onPhysicsCollideCallbacks.some(function(e,r){if(e.callback===t&&e.otherImpostors.length===i.length){var o=e.otherImpostors.every(function(e){return i.indexOf(e)>-1});return o&&(n=r),o}return!1})?this._onPhysicsCollideCallbacks.splice(n,1):r.a.Warn("Function to remove was not found")},e.prototype.getParentsRotation=function(){var e=this.object.parent;for(this._tmpQuat.copyFromFloats(0,0,0,1);e;)e.rotationQuaternion?this._tmpQuat2.copyFrom(e.rotationQuaternion):o.q.RotationYawPitchRollToRef(e.rotation.y,e.rotation.x,e.rotation.z,this._tmpQuat2),this._tmpQuat.multiplyToRef(this._tmpQuat2,this._tmpQuat),e=e.parent;return this._tmpQuat},e.prototype.applyForce=function(e,t){return this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().applyForce(this,e,t),this},e.prototype.applyImpulse=function(e,t){return this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().applyImpulse(this,e,t),this},e.prototype.createJoint=function(e,t,i){var r=new a.e(t,i);return this.addJoint(e,r),this},e.prototype.addJoint=function(e,t){return this._joints.push({otherImpostor:e,joint:t}),this._physicsEngine&&this._physicsEngine.addJoint(this,e,t),this},e.prototype.sleep=function(){return this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().sleepBody(this),this},e.prototype.wakeUp=function(){return this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().wakeUpBody(this),this},e.prototype.clone=function(t){return t?new e(t,this.type,this._options,this._scene):null},e.prototype.dispose=function(){var e=this;this._physicsEngine&&(this._joints.forEach(function(t){e._physicsEngine&&e._physicsEngine.removeJoint(e,t.otherImpostor,t.joint)}),this._physicsEngine.removeImpostor(this),this.parent&&this.parent.forceUpdate(),this._isDisposed=!0)},e.prototype.setDeltaPosition=function(e){this._deltaPosition.copyFrom(e)},e.prototype.setDeltaRotation=function(e){this._deltaRotation||(this._deltaRotation=new o.q),this._deltaRotation.copyFrom(e),this._deltaRotationConjugated=this._deltaRotation.conjugate()},e.prototype.getBoxSizeToRef=function(e){return this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().getBoxSizeToRef(this,e),this},e.prototype.getRadius=function(){return this._physicsEngine?this._physicsEngine.getPhysicsPlugin().getRadius(this):0},e.prototype.syncBoneWithImpostor=function(t,i,r,n,s){var a=e._tmpVecs[0],c=this.object;if(c.rotationQuaternion)if(s){var l=e._tmpQuat;c.rotationQuaternion.multiplyToRef(s,l),t.setRotationQuaternion(l,o.s.WORLD,i)}else t.setRotationQuaternion(c.rotationQuaternion,o.s.WORLD,i);a.x=0,a.y=0,a.z=0,r&&(a.x=r.x,a.y=r.y,a.z=r.z,t.getDirectionToRef(a,i,a),null==n&&(n=r.length()),a.x*=n,a.y*=n,a.z*=n),t.getParent()?(a.addInPlace(c.getAbsolutePosition()),t.setAbsolutePosition(a,i)):(i.setAbsolutePosition(c.getAbsolutePosition()),i.position.x-=a.x,i.position.y-=a.y,i.position.z-=a.z)},e.prototype.syncImpostorWithBone=function(t,i,r,n,s,a){var c=this.object;if(c.rotationQuaternion)if(s){var l=e._tmpQuat;t.getRotationQuaternionToRef(o.s.WORLD,i,l),l.multiplyToRef(s,c.rotationQuaternion)}else t.getRotationQuaternionToRef(o.s.WORLD,i,c.rotationQuaternion);var u=e._tmpVecs[0],h=e._tmpVecs[1];a||((a=e._tmpVecs[2]).x=0,a.y=1,a.z=0),t.getDirectionToRef(a,i,h),t.getAbsolutePositionToRef(i,u),null==n&&r&&(n=r.length()),null!=n&&(u.x+=h.x*n,u.y+=h.y*n,u.z+=h.z*n),c.setAbsolutePosition(u)},e.DEFAULT_OBJECT_SIZE=new o.x(1,1,1),e.IDENTITY_QUATERNION=o.q.Identity(),e._tmpVecs=n.a.BuildArray(3,o.x.Zero),e._tmpQuat=o.q.Identity(),e.NoImpostor=0,e.SphereImpostor=1,e.BoxImpostor=2,e.PlaneImpostor=3,e.MeshImpostor=4,e.CylinderImpostor=7,e.ParticleImpostor=8,e.HeightmapImpostor=9,e}()},function(e,t,i){"use strict";i.d(t,"a",function(){return r});var r=function(){function e(){this.rootNodes=new Array,this.cameras=new Array,this.lights=new Array,this.meshes=new Array,this.skeletons=new Array,this.particleSystems=new Array,this.animations=[],this.animationGroups=new Array,this.multiMaterials=new Array,this.materials=new Array,this.morphTargetManagers=new Array,this.geometries=new Array,this.transformNodes=new Array,this.actionManagers=new Array,this.textures=new Array}return e.AddParser=function(e,t){this._BabylonFileParsers[e]=t},e.GetParser=function(e){return this._BabylonFileParsers[e]?this._BabylonFileParsers[e]:null},e.AddIndividualParser=function(e,t){this._IndividualBabylonFileParsers[e]=t},e.GetIndividualParser=function(e){return this._IndividualBabylonFileParsers[e]?this._IndividualBabylonFileParsers[e]:null},e.Parse=function(e,t,i,r){for(var n in this._BabylonFileParsers)this._BabylonFileParsers.hasOwnProperty(n)&&this._BabylonFileParsers[n](e,t,i,r)},e._BabylonFileParsers={},e._IndividualBabylonFileParsers={},e}()},function(e,t,i){"use strict";i.d(t,"b",function(){return u}),i.d(t,"a",function(){return h});var r=i(1),n=i(2),o=i(7),s=i(9),a=i(0),c=i(60),l=i(84),u=function(e){function t(){var t=e.call(this)||this;return t.IMAGEPROCESSING=!1,t.VIGNETTE=!1,t.VIGNETTEBLENDMODEMULTIPLY=!1,t.VIGNETTEBLENDMODEOPAQUE=!1,t.TONEMAPPING=!1,t.TONEMAPPING_ACES=!1,t.CONTRAST=!1,t.COLORCURVES=!1,t.COLORGRADING=!1,t.COLORGRADING3D=!1,t.SAMPLER3DGREENDEPTH=!1,t.SAMPLER3DBGRMAP=!1,t.IMAGEPROCESSINGPOSTPROCESS=!1,t.EXPOSURE=!1,t.rebuild(),t}return r.d(t,e),t}(c.a),h=function(){function e(){this.colorCurves=new l.a,this._colorCurvesEnabled=!1,this._colorGradingEnabled=!1,this._colorGradingWithGreenDepth=!0,this._colorGradingBGR=!0,this._exposure=1,this._toneMappingEnabled=!1,this._toneMappingType=e.TONEMAPPING_STANDARD,this._contrast=1,this.vignetteStretch=0,this.vignetteCentreX=0,this.vignetteCentreY=0,this.vignetteWeight=1.5,this.vignetteColor=new a.f(0,0,0,0),this.vignetteCameraFov=.5,this._vignetteBlendMode=e.VIGNETTEMODE_MULTIPLY,this._vignetteEnabled=!1,this._applyByPostProcess=!1,this._isEnabled=!0,this.onUpdateParameters=new o.c}return Object.defineProperty(e.prototype,"colorCurvesEnabled",{get:function(){return this._colorCurvesEnabled},set:function(e){this._colorCurvesEnabled!==e&&(this._colorCurvesEnabled=e,this._updateParameters())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"colorGradingTexture",{get:function(){return this._colorGradingTexture},set:function(e){this._colorGradingTexture!==e&&(this._colorGradingTexture=e,this._updateParameters())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"colorGradingEnabled",{get:function(){return this._colorGradingEnabled},set:function(e){this._colorGradingEnabled!==e&&(this._colorGradingEnabled=e,this._updateParameters())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"colorGradingWithGreenDepth",{get:function(){return this._colorGradingWithGreenDepth},set:function(e){this._colorGradingWithGreenDepth!==e&&(this._colorGradingWithGreenDepth=e,this._updateParameters())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"colorGradingBGR",{get:function(){return this._colorGradingBGR},set:function(e){this._colorGradingBGR!==e&&(this._colorGradingBGR=e,this._updateParameters())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"exposure",{get:function(){return this._exposure},set:function(e){this._exposure!==e&&(this._exposure=e,this._updateParameters())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"toneMappingEnabled",{get:function(){return this._toneMappingEnabled},set:function(e){this._toneMappingEnabled!==e&&(this._toneMappingEnabled=e,this._updateParameters())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"toneMappingType",{get:function(){return this._toneMappingType},set:function(e){this._toneMappingType!==e&&(this._toneMappingType=e,this._updateParameters())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"contrast",{get:function(){return this._contrast},set:function(e){this._contrast!==e&&(this._contrast=e,this._updateParameters())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"vignetteBlendMode",{get:function(){return this._vignetteBlendMode},set:function(e){this._vignetteBlendMode!==e&&(this._vignetteBlendMode=e,this._updateParameters())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"vignetteEnabled",{get:function(){return this._vignetteEnabled},set:function(e){this._vignetteEnabled!==e&&(this._vignetteEnabled=e,this._updateParameters())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"applyByPostProcess",{get:function(){return this._applyByPostProcess},set:function(e){this._applyByPostProcess!==e&&(this._applyByPostProcess=e,this._updateParameters())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isEnabled",{get:function(){return this._isEnabled},set:function(e){this._isEnabled!==e&&(this._isEnabled=e,this._updateParameters())},enumerable:!0,configurable:!0}),e.prototype._updateParameters=function(){this.onUpdateParameters.notifyObservers(this)},e.prototype.getClassName=function(){return"ImageProcessingConfiguration"},e.PrepareUniforms=function(e,t){t.EXPOSURE&&e.push("exposureLinear"),t.CONTRAST&&e.push("contrast"),t.COLORGRADING&&e.push("colorTransformSettings"),t.VIGNETTE&&(e.push("vInverseScreenSize"),e.push("vignetteSettings1"),e.push("vignetteSettings2")),t.COLORCURVES&&l.a.PrepareUniforms(e)},e.PrepareSamplers=function(e,t){t.COLORGRADING&&e.push("txColorTransform")},e.prototype.prepareDefines=function(t,i){if(void 0===i&&(i=!1),i!==this.applyByPostProcess||!this._isEnabled)return t.VIGNETTE=!1,t.TONEMAPPING=!1,t.TONEMAPPING_ACES=!1,t.CONTRAST=!1,t.EXPOSURE=!1,t.COLORCURVES=!1,t.COLORGRADING=!1,t.COLORGRADING3D=!1,t.IMAGEPROCESSING=!1,void(t.IMAGEPROCESSINGPOSTPROCESS=this.applyByPostProcess&&this._isEnabled);switch(t.VIGNETTE=this.vignetteEnabled,t.VIGNETTEBLENDMODEMULTIPLY=this.vignetteBlendMode===e._VIGNETTEMODE_MULTIPLY,t.VIGNETTEBLENDMODEOPAQUE=!t.VIGNETTEBLENDMODEMULTIPLY,t.TONEMAPPING=this.toneMappingEnabled,this._toneMappingType){case e.TONEMAPPING_ACES:t.TONEMAPPING_ACES=!0;break;default:t.TONEMAPPING_ACES=!1}t.CONTRAST=1!==this.contrast,t.EXPOSURE=1!==this.exposure,t.COLORCURVES=this.colorCurvesEnabled&&!!this.colorCurves,t.COLORGRADING=this.colorGradingEnabled&&!!this.colorGradingTexture,t.COLORGRADING?t.COLORGRADING3D=this.colorGradingTexture.is3D:t.COLORGRADING3D=!1,t.SAMPLER3DGREENDEPTH=this.colorGradingWithGreenDepth,t.SAMPLER3DBGRMAP=this.colorGradingBGR,t.IMAGEPROCESSINGPOSTPROCESS=this.applyByPostProcess,t.IMAGEPROCESSING=t.VIGNETTE||t.TONEMAPPING||t.CONTRAST||t.EXPOSURE||t.COLORCURVES||t.COLORGRADING},e.prototype.isReady=function(){return!this.colorGradingEnabled||!this.colorGradingTexture||this.colorGradingTexture.isReady()},e.prototype.bind=function(e,t){if(void 0===t&&(t=1),this._colorCurvesEnabled&&this.colorCurves&&l.a.Bind(this.colorCurves,e),this._vignetteEnabled){var i=1/e.getEngine().getRenderWidth(),r=1/e.getEngine().getRenderHeight();e.setFloat2("vInverseScreenSize",i,r);var n=Math.tan(.5*this.vignetteCameraFov),o=n*t,a=Math.sqrt(o*n);o=s.h.Mix(o,a,this.vignetteStretch),n=s.h.Mix(n,a,this.vignetteStretch),e.setFloat4("vignetteSettings1",o,n,-o*this.vignetteCentreX,-n*this.vignetteCentreY);var c=-2*this.vignetteWeight;e.setFloat4("vignetteSettings2",this.vignetteColor.r,this.vignetteColor.g,this.vignetteColor.b,c)}if(e.setFloat("exposureLinear",this.exposure),e.setFloat("contrast",this.contrast),this.colorGradingTexture){e.setTexture("txColorTransform",this.colorGradingTexture);var u=this.colorGradingTexture.getSize().height;e.setFloat4("colorTransformSettings",(u-1)/u,.5/u,u,this.colorGradingTexture.level)}},e.prototype.clone=function(){return n.a.Clone(function(){return new e},this)},e.prototype.serialize=function(){return n.a.Serialize(this)},e.Parse=function(t){return n.a.Parse(function(){return new e},t,null,null)},Object.defineProperty(e,"VIGNETTEMODE_MULTIPLY",{get:function(){return this._VIGNETTEMODE_MULTIPLY},enumerable:!0,configurable:!0}),Object.defineProperty(e,"VIGNETTEMODE_OPAQUE",{get:function(){return this._VIGNETTEMODE_OPAQUE},enumerable:!0,configurable:!0}),e.TONEMAPPING_STANDARD=0,e.TONEMAPPING_ACES=1,e._VIGNETTEMODE_MULTIPLY=0,e._VIGNETTEMODE_OPAQUE=1,r.c([Object(n.g)()],e.prototype,"colorCurves",void 0),r.c([Object(n.c)()],e.prototype,"_colorCurvesEnabled",void 0),r.c([Object(n.l)("colorGradingTexture")],e.prototype,"_colorGradingTexture",void 0),r.c([Object(n.c)()],e.prototype,"_colorGradingEnabled",void 0),r.c([Object(n.c)()],e.prototype,"_colorGradingWithGreenDepth",void 0),r.c([Object(n.c)()],e.prototype,"_colorGradingBGR",void 0),r.c([Object(n.c)()],e.prototype,"_exposure",void 0),r.c([Object(n.c)()],e.prototype,"_toneMappingEnabled",void 0),r.c([Object(n.c)()],e.prototype,"_toneMappingType",void 0),r.c([Object(n.c)()],e.prototype,"_contrast",void 0),r.c([Object(n.c)()],e.prototype,"vignetteStretch",void 0),r.c([Object(n.c)()],e.prototype,"vignetteCentreX",void 0),r.c([Object(n.c)()],e.prototype,"vignetteCentreY",void 0),r.c([Object(n.c)()],e.prototype,"vignetteWeight",void 0),r.c([Object(n.f)()],e.prototype,"vignetteColor",void 0),r.c([Object(n.c)()],e.prototype,"vignetteCameraFov",void 0),r.c([Object(n.c)()],e.prototype,"_vignetteBlendMode",void 0),r.c([Object(n.c)()],e.prototype,"_vignetteEnabled",void 0),r.c([Object(n.c)()],e.prototype,"_applyByPostProcess",void 0),r.c([Object(n.c)()],e.prototype,"_isEnabled",void 0),e}();n.a._ImageProcessingConfigurationParser=h.Parse},function(e,t,i){"use strict";i.d(t,"a",function(){return n});var r=function(e,t){return e?e.getClassName&&"Mesh"===e.getClassName()?null:e.getClassName&&"SubMesh"===e.getClassName()?e.clone(t):e.clone?e.clone():null:null},n=function(){function e(){}return e.DeepCopy=function(e,t,i,n){for(var o in e)if(("_"!==o[0]||n&&-1!==n.indexOf(o))&&(!i||-1===i.indexOf(o))){var s=e[o],a=typeof s;if("function"!==a)try{if("object"===a)if(s instanceof Array){if(t[o]=[],s.length>0)if("object"==typeof s[0])for(var c=0;c<s.length;c++){var l=r(s[c],t);-1===t[o].indexOf(l)&&t[o].push(l)}else t[o]=s.slice(0)}else t[o]=r(s,t);else t[o]=s}catch(e){}}},e}()},function(e,t,i){"use strict";var r=i(1),n=i(2),o=i(28),s=i(17),a=i(0),c=i(4),l=i(31),u=i(5),h=i(60),d=i(69),f=i(16),p=i(6),_=i(20),g=i(21),m="uniform vec4 vDiffuseColor;\n#ifdef SPECULARTERM\nuniform vec4 vSpecularColor;\n#endif\nuniform vec3 vEmissiveColor;\n\n#ifdef DIFFUSE\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef AMBIENT\nuniform vec2 vAmbientInfos;\n#endif\n#ifdef OPACITY\nuniform vec2 vOpacityInfos;\n#endif\n#ifdef EMISSIVE\nuniform vec2 vEmissiveInfos;\n#endif\n#ifdef LIGHTMAP\nuniform vec2 vLightmapInfos;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;\nuniform vec2 vTangentSpaceParams;\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#if defined(USE_LOCAL_REFLECTIONMAP_CUBIC) && defined(REFLECTIONMAP_CUBIC)\nuniform vec3 vReflectionPosition;\nuniform vec3 vReflectionSize;\n#endif\n#endif\n#ifdef REFLECTIONFRESNEL\nuniform vec4 reflectionLeftColor;\nuniform vec4 reflectionRightColor;\n#endif\n#endif";u.a.IncludesShadersStore.defaultFragmentDeclaration=m;var v="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;\nvec3 vReflectionPosition;\nvec3 vReflectionSize;\nvec2 vEmissiveInfos;\nvec2 vLightmapInfos;\nvec2 vSpecularInfos;\nvec3 vBumpInfos;\nmat4 diffuseMatrix;\nmat4 ambientMatrix;\nmat4 opacityMatrix;\nmat4 reflectionMatrix;\nmat4 emissiveMatrix;\nmat4 lightmapMatrix;\nmat4 specularMatrix;\nmat4 bumpMatrix;\nvec4 vTangentSpaceParams;\nmat4 refractionMatrix;\nvec4 vRefractionInfos;\nvec4 vSpecularColor;\nvec3 vEmissiveColor;\nvec4 vDiffuseColor;\nfloat pointSize;\n};\nuniform Scene {\nmat4 viewProjection;\nmat4 view;\n};";u.a.IncludesShadersStore.defaultUboDeclaration=v;i(53),i(76),i(77),i(111),i(104);var y="#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";u.a.IncludesShadersStore.fresnelFunction=y;i(105),i(78),i(79),i(112),i(91),i(80),i(92),i(86),i(113),i(114),i(106),i(107),i(93);var b="#include<__decl__defaultFragment>\n#if defined(BUMP) || !defined(NORMAL)\n#extension GL_OES_standard_derivatives : enable\n#endif\n#define CUSTOM_FRAGMENT_BEGIN\n#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\n\n#define RECIPROCAL_PI2 0.15915494\nuniform vec3 vEyePosition;\nuniform vec3 vAmbientColor;\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2;\n#endif\n\n#include<helperFunctions>\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n\n#ifdef DIFFUSE\n#if DIFFUSEDIRECTUV == 1\n#define vDiffuseUV vMainUV1\n#elif DIFFUSEDIRECTUV == 2\n#define vDiffuseUV vMainUV2\n#else\nvarying vec2 vDiffuseUV;\n#endif\nuniform sampler2D diffuseSampler;\n#endif\n#ifdef AMBIENT\n#if AMBIENTDIRECTUV == 1\n#define vAmbientUV vMainUV1\n#elif AMBIENTDIRECTUV == 2\n#define vAmbientUV vMainUV2\n#else\nvarying vec2 vAmbientUV;\n#endif\nuniform sampler2D ambientSampler;\n#endif\n#ifdef OPACITY\n#if OPACITYDIRECTUV == 1\n#define vOpacityUV vMainUV1\n#elif OPACITYDIRECTUV == 2\n#define vOpacityUV vMainUV2\n#else\nvarying vec2 vOpacityUV;\n#endif\nuniform sampler2D opacitySampler;\n#endif\n#ifdef EMISSIVE\n#if EMISSIVEDIRECTUV == 1\n#define vEmissiveUV vMainUV1\n#elif EMISSIVEDIRECTUV == 2\n#define vEmissiveUV vMainUV2\n#else\nvarying vec2 vEmissiveUV;\n#endif\nuniform sampler2D emissiveSampler;\n#endif\n#ifdef LIGHTMAP\n#if LIGHTMAPDIRECTUV == 1\n#define vLightmapUV vMainUV1\n#elif LIGHTMAPDIRECTUV == 2\n#define vLightmapUV vMainUV2\n#else\nvarying vec2 vLightmapUV;\n#endif\nuniform sampler2D lightmapSampler;\n#endif\n#ifdef REFRACTION\n#ifdef REFRACTIONMAP_3D\nuniform samplerCube refractionCubeSampler;\n#else\nuniform sampler2D refraction2DSampler;\n#endif\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM)\n#if SPECULARDIRECTUV == 1\n#define vSpecularUV vMainUV1\n#elif SPECULARDIRECTUV == 2\n#define vSpecularUV vMainUV2\n#else\nvarying vec2 vSpecularUV;\n#endif\nuniform sampler2D specularSampler;\n#endif\n#ifdef ALPHATEST\nuniform float alphaCutOff;\n#endif\n\n#include<fresnelFunction>\n\n#ifdef REFLECTION\n#ifdef REFLECTIONMAP_3D\nuniform samplerCube reflectionCubeSampler;\n#else\nuniform sampler2D reflection2DSampler;\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#else\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#endif\n#include<reflectionFunction>\n#endif\n#include<imageProcessingDeclaration>\n#include<imageProcessingFunctions>\n#include<bumpFragmentFunctions>\n#include<clipPlaneFragmentDeclaration>\n#include<logDepthDeclaration>\n#include<fogFragmentDeclaration>\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\nvec4 baseColor=vec4(1.,1.,1.,1.);\nvec3 diffuseColor=vDiffuseColor.rgb;\n\nfloat alpha=vDiffuseColor.a;\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=normalize(-cross(dFdx(vPositionW),dFdy(vPositionW)));\n#endif\n#include<bumpFragment>\n#ifdef TWOSIDEDLIGHTING\nnormalW=gl_FrontFacing ? normalW : -normalW;\n#endif\n#ifdef DIFFUSE\nbaseColor=texture2D(diffuseSampler,vDiffuseUV+uvOffset);\n#ifdef ALPHATEST\nif (baseColor.a<alphaCutOff)\ndiscard;\n#endif\n#ifdef ALPHAFROMDIFFUSE\nalpha*=baseColor.a;\n#endif\n#define CUSTOM_FRAGMENT_UPDATE_ALPHA\nbaseColor.rgb*=vDiffuseInfos.y;\n#endif\n#include<depthPrePass>\n#ifdef VERTEXCOLOR\nbaseColor.rgb*=vColor.rgb;\n#endif\n#define CUSTOM_FRAGMENT_UPDATE_DIFFUSE\n\nvec3 baseAmbientColor=vec3(1.,1.,1.);\n#ifdef AMBIENT\nbaseAmbientColor=texture2D(ambientSampler,vAmbientUV+uvOffset).rgb*vAmbientInfos.y;\n#endif\n#define CUSTOM_FRAGMENT_BEFORE_LIGHTS\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) {\nrefractionColor=textureCube(refractionCubeSampler,refractionVector).rgb;\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;\n#endif\n#ifdef IS_REFRACTION_LINEAR\nrefractionColor=toGammaSpace(refractionColor);\n#endif\nrefractionColor*=vRefractionInfos.x;\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;\n#else\nreflectionColor=textureCube(reflectionCubeSampler,vReflectionUVW).rgb;\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;\n#endif\n#ifdef IS_REFLECTION_LINEAR\nreflectionColor=toGammaSpace(reflectionColor);\n#endif\nreflectionColor*=vReflectionInfos.x;\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#define CUSTOM_FRAGMENT_BEFORE_FOG\ncolor.rgb=max(color.rgb,0.);\n#include<logDepthFragment>\n#include<fogFragment>\n\n\n#ifdef IMAGEPROCESSINGPOSTPROCESS\ncolor.rgb=toLinearSpace(color.rgb);\n#else\n#ifdef IMAGEPROCESSING\ncolor.rgb=toLinearSpace(color.rgb);\ncolor=applyImageProcessing(color);\n#endif\n#endif\n#ifdef PREMULTIPLYALPHA\n\ncolor.rgb*=color.a;\n#endif\n#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR\ngl_FragColor=color;\n}\n";u.a.ShadersStore.defaultPixelShader=b;var T="\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 REFLECTION\nuniform mat4 reflectionMatrix;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n";u.a.IncludesShadersStore.defaultVertexDeclaration=T;i(62),i(63),i(115),i(94),i(95),i(96),i(97),i(98),i(64),i(65),i(116),i(87),i(108),i(109);u.a.IncludesShadersStore.pointCloudVertex="#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif";i(110);var E="#include<__decl__defaultVertex>\n\n#define CUSTOM_VERTEX_BEGIN\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<helperFunctions>\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2;\n#endif\n#if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0\nvarying vec2 vDiffuseUV;\n#endif\n#if defined(AMBIENT) && AMBIENTDIRECTUV == 0\nvarying vec2 vAmbientUV;\n#endif\n#if defined(OPACITY) && OPACITYDIRECTUV == 0\nvarying vec2 vOpacityUV;\n#endif\n#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0\nvarying vec2 vEmissiveUV;\n#endif\n#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0\nvarying vec2 vLightmapUV;\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM) && SPECULARDIRECTUV == 0\nvarying vec2 vSpecularUV;\n#endif\n#if defined(BUMP) && BUMPDIRECTUV == 0\nvarying vec2 vBumpUV;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<bumpVertexDeclaration>\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<morphTargetsVertexGlobalDeclaration>\n#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#include<logDepthDeclaration>\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\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\n#ifdef REFLECTIONMAP_SKYBOX_TRANSFORMED\nvPositionUVW=(reflectionMatrix*vec4(position,1.0)).xyz;\n#else\nvPositionUVW=position;\n#endif\n#endif\n#define CUSTOM_VERTEX_UPDATE_POSITION\n#define CUSTOM_VERTEX_UPDATE_NORMAL\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\nmat3 normalWorld=mat3(finalWorld);\n#ifdef NONUNIFORMSCALING\nnormalWorld=transposeMat3(inverseMat3(normalWorld));\n#endif\nvNormalW=normalize(normalWorld*normalUpdated);\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvDirectionW=normalize(vec3(finalWorld*vec4(positionUpdated,0.0)));\n#endif\n\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef MAINUV1\nvMainUV1=uv;\n#endif\n#ifdef MAINUV2\nvMainUV2=uv2;\n#endif\n#if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0\nif (vDiffuseInfos.x == 0.)\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(AMBIENT) && AMBIENTDIRECTUV == 0\nif (vAmbientInfos.x == 0.)\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(OPACITY) && OPACITYDIRECTUV == 0\nif (vOpacityInfos.x == 0.)\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0\nif (vEmissiveInfos.x == 0.)\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0\nif (vLightmapInfos.x == 0.)\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM) && SPECULARDIRECTUV == 0\nif (vSpecularInfos.x == 0.)\n{\nvSpecularUV=vec2(specularMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvSpecularUV=vec2(specularMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(BUMP) && BUMPDIRECTUV == 0\nif (vBumpInfos.x == 0.)\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#include<bumpVertex>\n#include<clipPlaneVertex>\n#include<fogVertex>\n#include<shadowsVertex>[0..maxSimultaneousLights]\n#ifdef VERTEXCOLOR\n\nvColor=color;\n#endif\n#include<pointCloudVertex>\n#include<logDepthVertex>\n#define CUSTOM_VERTEX_MAIN_END\n}\n";u.a.ShadersStore.defaultVertexShader=E;var x=i(3);i.d(t,"b",function(){return A}),i.d(t,"a",function(){return P});var A=function(e){function t(){var t=e.call(this)||this;return t.MAINUV1=!1,t.MAINUV2=!1,t.DIFFUSE=!1,t.DIFFUSEDIRECTUV=0,t.AMBIENT=!1,t.AMBIENTDIRECTUV=0,t.OPACITY=!1,t.OPACITYDIRECTUV=0,t.OPACITYRGB=!1,t.REFLECTION=!1,t.EMISSIVE=!1,t.EMISSIVEDIRECTUV=0,t.SPECULAR=!1,t.SPECULARDIRECTUV=0,t.BUMP=!1,t.BUMPDIRECTUV=0,t.PARALLAX=!1,t.PARALLAXOCCLUSION=!1,t.SPECULAROVERALPHA=!1,t.CLIPPLANE=!1,t.CLIPPLANE2=!1,t.CLIPPLANE3=!1,t.CLIPPLANE4=!1,t.ALPHATEST=!1,t.DEPTHPREPASS=!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.BONETEXTURE=!1,t.INSTANCES=!1,t.GLOSSINESS=!1,t.ROUGHNESS=!1,t.EMISSIVEASILLUMINATION=!1,t.LINKEMISSIVEWITHDIFFUSE=!1,t.REFLECTIONFRESNELFROMSPECULAR=!1,t.LIGHTMAP=!1,t.LIGHTMAPDIRECTUV=0,t.OBJECTSPACE_NORMALMAP=!1,t.USELIGHTMAPASSHADOWMAP=!1,t.REFLECTIONMAP_3D=!1,t.REFLECTIONMAP_SPHERICAL=!1,t.REFLECTIONMAP_PLANAR=!1,t.REFLECTIONMAP_CUBIC=!1,t.USE_LOCAL_REFLECTIONMAP_CUBIC=!1,t.REFLECTIONMAP_PROJECTION=!1,t.REFLECTIONMAP_SKYBOX=!1,t.REFLECTIONMAP_SKYBOX_TRANSFORMED=!1,t.REFLECTIONMAP_EXPLICIT=!1,t.REFLECTIONMAP_EQUIRECTANGULAR=!1,t.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,t.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,t.INVERTCUBICMAP=!1,t.LOGARITHMICDEPTH=!1,t.REFRACTION=!1,t.REFRACTIONMAP_3D=!1,t.REFLECTIONOVERALPHA=!1,t.TWOSIDEDLIGHTING=!1,t.SHADOWFLOAT=!1,t.MORPHTARGETS=!1,t.MORPHTARGETS_NORMAL=!1,t.MORPHTARGETS_TANGENT=!1,t.NUM_MORPH_INFLUENCERS=0,t.NONUNIFORMSCALING=!1,t.PREMULTIPLYALPHA=!1,t.IMAGEPROCESSING=!1,t.VIGNETTE=!1,t.VIGNETTEBLENDMODEMULTIPLY=!1,t.VIGNETTEBLENDMODEOPAQUE=!1,t.TONEMAPPING=!1,t.TONEMAPPING_ACES=!1,t.CONTRAST=!1,t.COLORCURVES=!1,t.COLORGRADING=!1,t.COLORGRADING3D=!1,t.SAMPLER3DGREENDEPTH=!1,t.SAMPLER3DBGRMAP=!1,t.IMAGEPROCESSINGPOSTPROCESS=!1,t.IS_REFLECTION_LINEAR=!1,t.IS_REFRACTION_LINEAR=!1,t.EXPOSURE=!1,t.rebuild(),t}return r.d(t,e),t.prototype.setReflectionMode=function(e){for(var t=0,i=["REFLECTIONMAP_CUBIC","REFLECTIONMAP_EXPLICIT","REFLECTIONMAP_PLANAR","REFLECTIONMAP_PROJECTION","REFLECTIONMAP_PROJECTION","REFLECTIONMAP_SKYBOX","REFLECTIONMAP_SPHERICAL","REFLECTIONMAP_EQUIRECTANGULAR","REFLECTIONMAP_EQUIRECTANGULAR_FIXED","REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED"];t<i.length;t++){var r=i[t];this[r]=r===e}},t}(h.a),P=function(e){function t(i,r){var n=e.call(this,i,r)||this;return n.ambientColor=new a.e(0,0,0),n.diffuseColor=new a.e(1,1,1),n.specularColor=new a.e(1,1,1),n.emissiveColor=new a.e(0,0,0),n.specularPower=64,n._useAlphaFromDiffuseTexture=!1,n._useEmissiveAsIllumination=!1,n._linkEmissiveWithDiffuse=!1,n._useSpecularOverAlpha=!1,n._useReflectionOverAlpha=!1,n._disableLighting=!1,n._useObjectSpaceNormalMap=!1,n._useParallax=!1,n._useParallaxOcclusion=!1,n.parallaxScaleBias=.05,n._roughness=0,n.indexOfRefraction=.98,n.invertRefractionY=!0,n.alphaCutOff=.4,n._useLightmapAsShadowmap=!1,n._useReflectionFresnelFromSpecular=!1,n._useGlossinessFromSpecularMapAlpha=!1,n._maxSimultaneousLights=4,n._invertNormalMapX=!1,n._invertNormalMapY=!1,n._twoSidedLighting=!1,n._renderTargets=new o.a(16),n._worldViewProjectionMatrix=a.j.Zero(),n._globalAmbientColor=new a.e(0,0,0),n._attachImageProcessingConfiguration(null),n.getRenderTargetTextures=function(){return n._renderTargets.reset(),t.ReflectionTextureEnabled&&n._reflectionTexture&&n._reflectionTexture.isRenderTarget&&n._renderTargets.push(n._reflectionTexture),t.RefractionTextureEnabled&&n._refractionTexture&&n._refractionTexture.isRenderTarget&&n._renderTargets.push(n._refractionTexture),n._renderTargets},n}return r.d(t,e),Object.defineProperty(t.prototype,"imageProcessingConfiguration",{get:function(){return this._imageProcessingConfiguration},set:function(e){this._attachImageProcessingConfiguration(e),this._markAllSubMeshesAsTexturesDirty()},enumerable:!0,configurable:!0}),t.prototype._attachImageProcessingConfiguration=function(e){var t=this;e!==this._imageProcessingConfiguration&&(this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),this._imageProcessingConfiguration=e||this.getScene().imageProcessingConfiguration,this._imageProcessingConfiguration&&(this._imageProcessingObserver=this._imageProcessingConfiguration.onUpdateParameters.add(function(){t._markAllSubMeshesAsImageProcessingDirty()})))},Object.defineProperty(t.prototype,"cameraColorCurvesEnabled",{get:function(){return this.imageProcessingConfiguration.colorCurvesEnabled},set:function(e){this.imageProcessingConfiguration.colorCurvesEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"cameraColorGradingEnabled",{get:function(){return this.imageProcessingConfiguration.colorGradingEnabled},set:function(e){this.imageProcessingConfiguration.colorGradingEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"cameraToneMappingEnabled",{get:function(){return this._imageProcessingConfiguration.toneMappingEnabled},set:function(e){this._imageProcessingConfiguration.toneMappingEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"cameraExposure",{get:function(){return this._imageProcessingConfiguration.exposure},set:function(e){this._imageProcessingConfiguration.exposure=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"cameraContrast",{get:function(){return this._imageProcessingConfiguration.contrast},set:function(e){this._imageProcessingConfiguration.contrast=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"cameraColorGradingTexture",{get:function(){return this._imageProcessingConfiguration.colorGradingTexture},set:function(e){this._imageProcessingConfiguration.colorGradingTexture=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"cameraColorCurves",{get:function(){return this._imageProcessingConfiguration.colorCurves},set:function(e){this._imageProcessingConfiguration.colorCurves=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"hasRenderTargetTextures",{get:function(){return!!(t.ReflectionTextureEnabled&&this._reflectionTexture&&this._reflectionTexture.isRenderTarget)||!!(t.RefractionTextureEnabled&&this._refractionTexture&&this._refractionTexture.isRenderTarget)},enumerable:!0,configurable:!0}),t.prototype.getClassName=function(){return"StandardMaterial"},Object.defineProperty(t.prototype,"useLogarithmicDepth",{get:function(){return this._useLogarithmicDepth},set:function(e){this._useLogarithmicDepth=e&&this.getScene().getEngine().getCaps().fragmentDepthSupported,this._markAllSubMeshesAsMiscDirty()},enumerable:!0,configurable:!0}),t.prototype.needAlphaBlending=function(){return this.alpha<1||null!=this._opacityTexture||this._shouldUseAlphaFromDiffuseTexture()||this._opacityFresnelParameters&&this._opacityFresnelParameters.isEnabled},t.prototype.needAlphaTesting=function(){return null!=this._diffuseTexture&&this._diffuseTexture.hasAlpha},t.prototype._shouldUseAlphaFromDiffuseTexture=function(){return null!=this._diffuseTexture&&this._diffuseTexture.hasAlpha&&this._useAlphaFromDiffuseTexture},t.prototype.getAlphaTestTexture=function(){return this._diffuseTexture},t.prototype.isReadyForSubMesh=function(e,i,r){if(void 0===r&&(r=!1),i.effect&&this.isFrozen&&this._wasPreviouslyReady)return!0;i._materialDefines||(i._materialDefines=new A);var n=this.getScene(),o=i._materialDefines;if(!this.checkReadyOnEveryCall&&i.effect&&o._renderId===n.getRenderId())return!0;var s=n.getEngine();if(o._needNormals=f.a.PrepareDefinesForLights(n,e,o,!0,this._maxSimultaneousLights,this._disableLighting),o._areTexturesDirty){if(o._needUVs=!1,o.MAINUV1=!1,o.MAINUV2=!1,n.texturesEnabled){if(this._diffuseTexture&&t.DiffuseTextureEnabled){if(!this._diffuseTexture.isReadyOrNotBlocking())return!1;f.a.PrepareDefinesForMergedUV(this._diffuseTexture,o,"DIFFUSE")}else o.DIFFUSE=!1;if(this._ambientTexture&&t.AmbientTextureEnabled){if(!this._ambientTexture.isReadyOrNotBlocking())return!1;f.a.PrepareDefinesForMergedUV(this._ambientTexture,o,"AMBIENT")}else o.AMBIENT=!1;if(this._opacityTexture&&t.OpacityTextureEnabled){if(!this._opacityTexture.isReadyOrNotBlocking())return!1;f.a.PrepareDefinesForMergedUV(this._opacityTexture,o,"OPACITY"),o.OPACITYRGB=this._opacityTexture.getAlphaFromRGB}else o.OPACITY=!1;if(this._reflectionTexture&&t.ReflectionTextureEnabled){if(!this._reflectionTexture.isReadyOrNotBlocking())return!1;switch(o._needNormals=!0,o.REFLECTION=!0,o.ROUGHNESS=this._roughness>0,o.REFLECTIONOVERALPHA=this._useReflectionOverAlpha,o.INVERTCUBICMAP=this._reflectionTexture.coordinatesMode===p.a.INVCUBIC_MODE,o.REFLECTIONMAP_3D=this._reflectionTexture.isCube,this._reflectionTexture.coordinatesMode){case p.a.EXPLICIT_MODE:o.setReflectionMode("REFLECTIONMAP_EXPLICIT");break;case p.a.PLANAR_MODE:o.setReflectionMode("REFLECTIONMAP_PLANAR");break;case p.a.PROJECTION_MODE:o.setReflectionMode("REFLECTIONMAP_PROJECTION");break;case p.a.SKYBOX_MODE:o.setReflectionMode("REFLECTIONMAP_SKYBOX"),o.REFLECTIONMAP_SKYBOX_TRANSFORMED=!this._reflectionTexture.getReflectionTextureMatrix().isIdentity();break;case p.a.SPHERICAL_MODE:o.setReflectionMode("REFLECTIONMAP_SPHERICAL");break;case p.a.EQUIRECTANGULAR_MODE:o.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR");break;case p.a.FIXED_EQUIRECTANGULAR_MODE:o.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR_FIXED");break;case p.a.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:o.setReflectionMode("REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED");break;case p.a.CUBIC_MODE:case p.a.INVCUBIC_MODE:default:o.setReflectionMode("REFLECTIONMAP_CUBIC")}o.USE_LOCAL_REFLECTIONMAP_CUBIC=!!this._reflectionTexture.boundingBoxSize}else o.REFLECTION=!1;if(this._emissiveTexture&&t.EmissiveTextureEnabled){if(!this._emissiveTexture.isReadyOrNotBlocking())return!1;f.a.PrepareDefinesForMergedUV(this._emissiveTexture,o,"EMISSIVE")}else o.EMISSIVE=!1;if(this._lightmapTexture&&t.LightmapTextureEnabled){if(!this._lightmapTexture.isReadyOrNotBlocking())return!1;f.a.PrepareDefinesForMergedUV(this._lightmapTexture,o,"LIGHTMAP"),o.USELIGHTMAPASSHADOWMAP=this._useLightmapAsShadowmap}else o.LIGHTMAP=!1;if(this._specularTexture&&t.SpecularTextureEnabled){if(!this._specularTexture.isReadyOrNotBlocking())return!1;f.a.PrepareDefinesForMergedUV(this._specularTexture,o,"SPECULAR"),o.GLOSSINESS=this._useGlossinessFromSpecularMapAlpha}else o.SPECULAR=!1;if(n.getEngine().getCaps().standardDerivatives&&this._bumpTexture&&t.BumpTextureEnabled){if(!this._bumpTexture.isReady())return!1;f.a.PrepareDefinesForMergedUV(this._bumpTexture,o,"BUMP"),o.PARALLAX=this._useParallax,o.PARALLAXOCCLUSION=this._useParallaxOcclusion,o.OBJECTSPACE_NORMALMAP=this._useObjectSpaceNormalMap}else o.BUMP=!1;if(this._refractionTexture&&t.RefractionTextureEnabled){if(!this._refractionTexture.isReadyOrNotBlocking())return!1;o._needUVs=!0,o.REFRACTION=!0,o.REFRACTIONMAP_3D=this._refractionTexture.isCube}else o.REFRACTION=!1;o.TWOSIDEDLIGHTING=!this._backFaceCulling&&this._twoSidedLighting}else o.DIFFUSE=!1,o.AMBIENT=!1,o.OPACITY=!1,o.REFLECTION=!1,o.EMISSIVE=!1,o.LIGHTMAP=!1,o.BUMP=!1,o.REFRACTION=!1;o.ALPHAFROMDIFFUSE=this._shouldUseAlphaFromDiffuseTexture(),o.EMISSIVEASILLUMINATION=this._useEmissiveAsIllumination,o.LINKEMISSIVEWITHDIFFUSE=this._linkEmissiveWithDiffuse,o.SPECULAROVERALPHA=this._useSpecularOverAlpha,o.PREMULTIPLYALPHA=this.alphaMode===x.a.ALPHA_PREMULTIPLIED||this.alphaMode===x.a.ALPHA_PREMULTIPLIED_PORTERDUFF}if(o._areImageProcessingDirty&&this._imageProcessingConfiguration){if(!this._imageProcessingConfiguration.isReady())return!1;this._imageProcessingConfiguration.prepareDefines(o),o.IS_REFLECTION_LINEAR=null!=this.reflectionTexture&&!this.reflectionTexture.gammaSpace,o.IS_REFRACTION_LINEAR=null!=this.refractionTexture&&!this.refractionTexture.gammaSpace}if(o._areFresnelDirty&&(t.FresnelEnabled?(this._diffuseFresnelParameters||this._opacityFresnelParameters||this._emissiveFresnelParameters||this._refractionFresnelParameters||this._reflectionFresnelParameters)&&(o.DIFFUSEFRESNEL=this._diffuseFresnelParameters&&this._diffuseFresnelParameters.isEnabled,o.OPACITYFRESNEL=this._opacityFresnelParameters&&this._opacityFresnelParameters.isEnabled,o.REFLECTIONFRESNEL=this._reflectionFresnelParameters&&this._reflectionFresnelParameters.isEnabled,o.REFLECTIONFRESNELFROMSPECULAR=this._useReflectionFresnelFromSpecular,o.REFRACTIONFRESNEL=this._refractionFresnelParameters&&this._refractionFresnelParameters.isEnabled,o.EMISSIVEFRESNEL=this._emissiveFresnelParameters&&this._emissiveFresnelParameters.isEnabled,o._needNormals=!0,o.FRESNEL=!0):o.FRESNEL=!1),f.a.PrepareDefinesForMisc(e,n,this._useLogarithmicDepth,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e),o),f.a.PrepareDefinesForAttributes(e,o,!0,!0,!0),f.a.PrepareDefinesForFrameBoundValues(n,s,o,r),o.isDirty){o.markAsProcessed();var a=new u.c;o.REFLECTION&&a.addFallback(0,"REFLECTION"),o.SPECULAR&&a.addFallback(0,"SPECULAR"),o.BUMP&&a.addFallback(0,"BUMP"),o.PARALLAX&&a.addFallback(1,"PARALLAX"),o.PARALLAXOCCLUSION&&a.addFallback(0,"PARALLAXOCCLUSION"),o.SPECULAROVERALPHA&&a.addFallback(0,"SPECULAROVERALPHA"),o.FOG&&a.addFallback(1,"FOG"),o.POINTSIZE&&a.addFallback(0,"POINTSIZE"),o.LOGARITHMICDEPTH&&a.addFallback(0,"LOGARITHMICDEPTH"),f.a.HandleFallbacksForShadows(o,a,this._maxSimultaneousLights),o.SPECULARTERM&&a.addFallback(0,"SPECULARTERM"),o.DIFFUSEFRESNEL&&a.addFallback(1,"DIFFUSEFRESNEL"),o.OPACITYFRESNEL&&a.addFallback(2,"OPACITYFRESNEL"),o.REFLECTIONFRESNEL&&a.addFallback(3,"REFLECTIONFRESNEL"),o.EMISSIVEFRESNEL&&a.addFallback(4,"EMISSIVEFRESNEL"),o.FRESNEL&&a.addFallback(4,"FRESNEL");var h=[c.b.PositionKind];o.NORMAL&&h.push(c.b.NormalKind),o.UV1&&h.push(c.b.UVKind),o.UV2&&h.push(c.b.UV2Kind),o.VERTEXCOLOR&&h.push(c.b.ColorKind),f.a.PrepareAttributesForBones(h,e,o,a),f.a.PrepareAttributesForInstances(h,o),f.a.PrepareAttributesForMorphTargets(h,e,o);var d="default",_=["world","view","viewProjection","vEyePosition","vLightsType","vAmbientColor","vDiffuseColor","vSpecularColor","vEmissiveColor","vFogInfos","vFogColor","pointSize","vDiffuseInfos","vAmbientInfos","vOpacityInfos","vReflectionInfos","vEmissiveInfos","vSpecularInfos","vBumpInfos","vLightmapInfos","vRefractionInfos","mBones","vClipPlane","vClipPlane2","vClipPlane3","vClipPlane4","diffuseMatrix","ambientMatrix","opacityMatrix","reflectionMatrix","emissiveMatrix","specularMatrix","bumpMatrix","normalMatrix","lightmapMatrix","refractionMatrix","diffuseLeftColor","diffuseRightColor","opacityParts","reflectionLeftColor","reflectionRightColor","emissiveLeftColor","emissiveRightColor","refractionLeftColor","refractionRightColor","vReflectionPosition","vReflectionSize","logarithmicDepthConstant","vTangentSpaceParams","alphaCutOff","boneTextureWidth"],g=["diffuseSampler","ambientSampler","opacitySampler","reflectionCubeSampler","reflection2DSampler","emissiveSampler","specularSampler","bumpSampler","lightmapSampler","refractionCubeSampler","refraction2DSampler","boneSampler"],m=["Material","Scene"];l.a&&(l.a.PrepareUniforms(_,o),l.a.PrepareSamplers(g,o)),f.a.PrepareUniformsAndSamplersList({uniformsNames:_,uniformBuffersNames:m,samplers:g,defines:o,maxSimultaneousLights:this._maxSimultaneousLights}),this.customShaderNameResolve&&(d=this.customShaderNameResolve(d,_,m,g,o));var v=o.toString(),y=i.effect,b=n.getEngine().createEffect(d,{attributes:h,uniformsNames:_,uniformBuffersNames:m,samplers:g,defines:v,fallbacks:a,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:this._maxSimultaneousLights,maxSimultaneousMorphTargets:o.NUM_MORPH_INFLUENCERS}},s);b&&(this.allowShaderHotSwapping&&y&&!b.isReady()?(b=y,o.markAsUnprocessed()):(n.resetCachedMaterial(),i.setEffect(b,o),this.buildUniformLayout()))}return!(!i.effect||!i.effect.isReady())&&(o._renderId=n.getRenderId(),this._wasPreviouslyReady=!0,!0)},t.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("vReflectionPosition",3),this._uniformBuffer.addUniform("vReflectionSize",3),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("vTangentSpaceParams",2),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()},t.prototype.unbind=function(){if(this._activeEffect){var t=!1;this._reflectionTexture&&this._reflectionTexture.isRenderTarget&&(this._activeEffect.setTexture("reflection2DSampler",null),t=!0),this._refractionTexture&&this._refractionTexture.isRenderTarget&&(this._activeEffect.setTexture("refraction2DSampler",null),t=!0),t&&this._markAllSubMeshesAsTexturesDirty()}e.prototype.unbind.call(this)},t.prototype.bindForSubMesh=function(e,i,r){var n=this.getScene(),o=r._materialDefines;if(o){var c=r.effect;if(c){this._activeEffect=c,this.bindOnlyWorldMatrix(e),o.OBJECTSPACE_NORMALMAP&&(e.toNormalMatrix(this._normalMatrix),this.bindOnlyNormalMatrix(this._normalMatrix));var l=this._mustRebind(n,c,i.visibility);if(f.a.BindBonesParameters(i,c),l){if(this._uniformBuffer.bindToEffect(c,"Material"),this.bindViewProjection(c),!this._uniformBuffer.useUbo||!this.isFrozen||!this._uniformBuffer.isSync){if(t.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 a.e(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))),n.texturesEnabled){if(this._diffuseTexture&&t.DiffuseTextureEnabled&&(this._uniformBuffer.updateFloat2("vDiffuseInfos",this._diffuseTexture.coordinatesIndex,this._diffuseTexture.level),f.a.BindTextureMatrix(this._diffuseTexture,this._uniformBuffer,"diffuse"),this._diffuseTexture.hasAlpha&&c.setFloat("alphaCutOff",this.alphaCutOff)),this._ambientTexture&&t.AmbientTextureEnabled&&(this._uniformBuffer.updateFloat2("vAmbientInfos",this._ambientTexture.coordinatesIndex,this._ambientTexture.level),f.a.BindTextureMatrix(this._ambientTexture,this._uniformBuffer,"ambient")),this._opacityTexture&&t.OpacityTextureEnabled&&(this._uniformBuffer.updateFloat2("vOpacityInfos",this._opacityTexture.coordinatesIndex,this._opacityTexture.level),f.a.BindTextureMatrix(this._opacityTexture,this._uniformBuffer,"opacity")),this._reflectionTexture&&t.ReflectionTextureEnabled&&(this._uniformBuffer.updateFloat2("vReflectionInfos",this._reflectionTexture.level,this.roughness),this._uniformBuffer.updateMatrix("reflectionMatrix",this._reflectionTexture.getReflectionTextureMatrix()),this._reflectionTexture.boundingBoxSize)){var u=this._reflectionTexture;this._uniformBuffer.updateVector3("vReflectionPosition",u.boundingBoxPosition),this._uniformBuffer.updateVector3("vReflectionSize",u.boundingBoxSize)}if(this._emissiveTexture&&t.EmissiveTextureEnabled&&(this._uniformBuffer.updateFloat2("vEmissiveInfos",this._emissiveTexture.coordinatesIndex,this._emissiveTexture.level),f.a.BindTextureMatrix(this._emissiveTexture,this._uniformBuffer,"emissive")),this._lightmapTexture&&t.LightmapTextureEnabled&&(this._uniformBuffer.updateFloat2("vLightmapInfos",this._lightmapTexture.coordinatesIndex,this._lightmapTexture.level),f.a.BindTextureMatrix(this._lightmapTexture,this._uniformBuffer,"lightmap")),this._specularTexture&&t.SpecularTextureEnabled&&(this._uniformBuffer.updateFloat2("vSpecularInfos",this._specularTexture.coordinatesIndex,this._specularTexture.level),f.a.BindTextureMatrix(this._specularTexture,this._uniformBuffer,"specular")),this._bumpTexture&&n.getEngine().getCaps().standardDerivatives&&t.BumpTextureEnabled&&(this._uniformBuffer.updateFloat3("vBumpInfos",this._bumpTexture.coordinatesIndex,1/this._bumpTexture.level,this.parallaxScaleBias),f.a.BindTextureMatrix(this._bumpTexture,this._uniformBuffer,"bump"),n._mirroredCameraPosition?this._uniformBuffer.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?1:-1,this._invertNormalMapY?1:-1):this._uniformBuffer.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?-1:1,this._invertNormalMapY?-1:1)),this._refractionTexture&&t.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",t.EmissiveTextureEnabled?this.emissiveColor:a.e.BlackReadOnly),this._uniformBuffer.updateColor4("vDiffuseColor",this.diffuseColor,this.alpha*i.visibility)}if(n.texturesEnabled&&(this._diffuseTexture&&t.DiffuseTextureEnabled&&c.setTexture("diffuseSampler",this._diffuseTexture),this._ambientTexture&&t.AmbientTextureEnabled&&c.setTexture("ambientSampler",this._ambientTexture),this._opacityTexture&&t.OpacityTextureEnabled&&c.setTexture("opacitySampler",this._opacityTexture),this._reflectionTexture&&t.ReflectionTextureEnabled&&(this._reflectionTexture.isCube?c.setTexture("reflectionCubeSampler",this._reflectionTexture):c.setTexture("reflection2DSampler",this._reflectionTexture)),this._emissiveTexture&&t.EmissiveTextureEnabled&&c.setTexture("emissiveSampler",this._emissiveTexture),this._lightmapTexture&&t.LightmapTextureEnabled&&c.setTexture("lightmapSampler",this._lightmapTexture),this._specularTexture&&t.SpecularTextureEnabled&&c.setTexture("specularSampler",this._specularTexture),this._bumpTexture&&n.getEngine().getCaps().standardDerivatives&&t.BumpTextureEnabled&&c.setTexture("bumpSampler",this._bumpTexture),this._refractionTexture&&t.RefractionTextureEnabled)){h=1;this._refractionTexture.isCube?c.setTexture("refractionCubeSampler",this._refractionTexture):c.setTexture("refraction2DSampler",this._refractionTexture)}f.a.BindClipPlane(c,n),n.ambientColor.multiplyToRef(this.ambientColor,this._globalAmbientColor),f.a.BindEyePosition(c,n),c.setColor3("vAmbientColor",this._globalAmbientColor)}!l&&this.isFrozen||(n.lightsEnabled&&!this._disableLighting&&f.a.BindLights(n,i,c,o,this._maxSimultaneousLights),(n.fogEnabled&&i.applyFog&&n.fogMode!==s.a.FOGMODE_NONE||this._reflectionTexture||this._refractionTexture)&&this.bindView(c),f.a.BindFogParameters(n,i,c),o.NUM_MORPH_INFLUENCERS&&f.a.BindMorphTargetParameters(i,c),f.a.BindLogDepth(o,c,n),this._imageProcessingConfiguration&&!this._imageProcessingConfiguration.applyByPostProcess&&this._imageProcessingConfiguration.bind(this._activeEffect)),this._uniformBuffer.update(),this._afterBind(i,this._activeEffect)}}},t.prototype.getAnimatables=function(){var e=[];return this._diffuseTexture&&this._diffuseTexture.animations&&this._diffuseTexture.animations.length>0&&e.push(this._diffuseTexture),this._ambientTexture&&this._ambientTexture.animations&&this._ambientTexture.animations.length>0&&e.push(this._ambientTexture),this._opacityTexture&&this._opacityTexture.animations&&this._opacityTexture.animations.length>0&&e.push(this._opacityTexture),this._reflectionTexture&&this._reflectionTexture.animations&&this._reflectionTexture.animations.length>0&&e.push(this._reflectionTexture),this._emissiveTexture&&this._emissiveTexture.animations&&this._emissiveTexture.animations.length>0&&e.push(this._emissiveTexture),this._specularTexture&&this._specularTexture.animations&&this._specularTexture.animations.length>0&&e.push(this._specularTexture),this._bumpTexture&&this._bumpTexture.animations&&this._bumpTexture.animations.length>0&&e.push(this._bumpTexture),this._lightmapTexture&&this._lightmapTexture.animations&&this._lightmapTexture.animations.length>0&&e.push(this._lightmapTexture),this._refractionTexture&&this._refractionTexture.animations&&this._refractionTexture.animations.length>0&&e.push(this._refractionTexture),e},t.prototype.getActiveTextures=function(){var t=e.prototype.getActiveTextures.call(this);return this._diffuseTexture&&t.push(this._diffuseTexture),this._ambientTexture&&t.push(this._ambientTexture),this._opacityTexture&&t.push(this._opacityTexture),this._reflectionTexture&&t.push(this._reflectionTexture),this._emissiveTexture&&t.push(this._emissiveTexture),this._specularTexture&&t.push(this._specularTexture),this._bumpTexture&&t.push(this._bumpTexture),this._lightmapTexture&&t.push(this._lightmapTexture),this._refractionTexture&&t.push(this._refractionTexture),t},t.prototype.hasTexture=function(t){return!!e.prototype.hasTexture.call(this,t)||(this._diffuseTexture===t||(this._ambientTexture===t||(this._opacityTexture===t||(this._reflectionTexture===t||(this._emissiveTexture===t||(this._specularTexture===t||(this._bumpTexture===t||(this._lightmapTexture===t||this._refractionTexture===t))))))))},t.prototype.dispose=function(t,i){i&&(this._diffuseTexture&&this._diffuseTexture.dispose(),this._ambientTexture&&this._ambientTexture.dispose(),this._opacityTexture&&this._opacityTexture.dispose(),this._reflectionTexture&&this._reflectionTexture.dispose(),this._emissiveTexture&&this._emissiveTexture.dispose(),this._specularTexture&&this._specularTexture.dispose(),this._bumpTexture&&this._bumpTexture.dispose(),this._lightmapTexture&&this._lightmapTexture.dispose(),this._refractionTexture&&this._refractionTexture.dispose()),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),e.prototype.dispose.call(this,t,i)},t.prototype.clone=function(e){var i=this,r=n.a.Clone(function(){return new t(e,i.getScene())},this);return r.name=e,r.id=e,r},t.prototype.serialize=function(){return n.a.Serialize(this)},t.Parse=function(e,i,r){return n.a.Parse(function(){return new t(e.name,i)},e,i,r)},Object.defineProperty(t,"DiffuseTextureEnabled",{get:function(){return g.a.DiffuseTextureEnabled},set:function(e){g.a.DiffuseTextureEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(t,"AmbientTextureEnabled",{get:function(){return g.a.AmbientTextureEnabled},set:function(e){g.a.AmbientTextureEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(t,"OpacityTextureEnabled",{get:function(){return g.a.OpacityTextureEnabled},set:function(e){g.a.OpacityTextureEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(t,"ReflectionTextureEnabled",{get:function(){return g.a.ReflectionTextureEnabled},set:function(e){g.a.ReflectionTextureEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(t,"EmissiveTextureEnabled",{get:function(){return g.a.EmissiveTextureEnabled},set:function(e){g.a.EmissiveTextureEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(t,"SpecularTextureEnabled",{get:function(){return g.a.SpecularTextureEnabled},set:function(e){g.a.SpecularTextureEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(t,"BumpTextureEnabled",{get:function(){return g.a.BumpTextureEnabled},set:function(e){g.a.BumpTextureEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(t,"LightmapTextureEnabled",{get:function(){return g.a.LightmapTextureEnabled},set:function(e){g.a.LightmapTextureEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(t,"RefractionTextureEnabled",{get:function(){return g.a.RefractionTextureEnabled},set:function(e){g.a.RefractionTextureEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(t,"ColorGradingTextureEnabled",{get:function(){return g.a.ColorGradingTextureEnabled},set:function(e){g.a.ColorGradingTextureEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(t,"FresnelEnabled",{get:function(){return g.a.FresnelEnabled},set:function(e){g.a.FresnelEnabled=e},enumerable:!0,configurable:!0}),r.c([Object(n.l)("diffuseTexture")],t.prototype,"_diffuseTexture",void 0),r.c([Object(n.b)("_markAllSubMeshesAsTexturesAndMiscDirty")],t.prototype,"diffuseTexture",void 0),r.c([Object(n.l)("ambientTexture")],t.prototype,"_ambientTexture",void 0),r.c([Object(n.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"ambientTexture",void 0),r.c([Object(n.l)("opacityTexture")],t.prototype,"_opacityTexture",void 0),r.c([Object(n.b)("_markAllSubMeshesAsTexturesAndMiscDirty")],t.prototype,"opacityTexture",void 0),r.c([Object(n.l)("reflectionTexture")],t.prototype,"_reflectionTexture",void 0),r.c([Object(n.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionTexture",void 0),r.c([Object(n.l)("emissiveTexture")],t.prototype,"_emissiveTexture",void 0),r.c([Object(n.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"emissiveTexture",void 0),r.c([Object(n.l)("specularTexture")],t.prototype,"_specularTexture",void 0),r.c([Object(n.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"specularTexture",void 0),r.c([Object(n.l)("bumpTexture")],t.prototype,"_bumpTexture",void 0),r.c([Object(n.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"bumpTexture",void 0),r.c([Object(n.l)("lightmapTexture")],t.prototype,"_lightmapTexture",void 0),r.c([Object(n.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"lightmapTexture",void 0),r.c([Object(n.l)("refractionTexture")],t.prototype,"_refractionTexture",void 0),r.c([Object(n.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"refractionTexture",void 0),r.c([Object(n.e)("ambient")],t.prototype,"ambientColor",void 0),r.c([Object(n.e)("diffuse")],t.prototype,"diffuseColor",void 0),r.c([Object(n.e)("specular")],t.prototype,"specularColor",void 0),r.c([Object(n.e)("emissive")],t.prototype,"emissiveColor",void 0),r.c([Object(n.c)()],t.prototype,"specularPower",void 0),r.c([Object(n.c)("useAlphaFromDiffuseTexture")],t.prototype,"_useAlphaFromDiffuseTexture",void 0),r.c([Object(n.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAlphaFromDiffuseTexture",void 0),r.c([Object(n.c)("useEmissiveAsIllumination")],t.prototype,"_useEmissiveAsIllumination",void 0),r.c([Object(n.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useEmissiveAsIllumination",void 0),r.c([Object(n.c)("linkEmissiveWithDiffuse")],t.prototype,"_linkEmissiveWithDiffuse",void 0),r.c([Object(n.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"linkEmissiveWithDiffuse",void 0),r.c([Object(n.c)("useSpecularOverAlpha")],t.prototype,"_useSpecularOverAlpha",void 0),r.c([Object(n.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useSpecularOverAlpha",void 0),r.c([Object(n.c)("useReflectionOverAlpha")],t.prototype,"_useReflectionOverAlpha",void 0),r.c([Object(n.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useReflectionOverAlpha",void 0),r.c([Object(n.c)("disableLighting")],t.prototype,"_disableLighting",void 0),r.c([Object(n.b)("_markAllSubMeshesAsLightsDirty")],t.prototype,"disableLighting",void 0),r.c([Object(n.c)("useObjectSpaceNormalMap")],t.prototype,"_useObjectSpaceNormalMap",void 0),r.c([Object(n.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useObjectSpaceNormalMap",void 0),r.c([Object(n.c)("useParallax")],t.prototype,"_useParallax",void 0),r.c([Object(n.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useParallax",void 0),r.c([Object(n.c)("useParallaxOcclusion")],t.prototype,"_useParallaxOcclusion",void 0),r.c([Object(n.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useParallaxOcclusion",void 0),r.c([Object(n.c)()],t.prototype,"parallaxScaleBias",void 0),r.c([Object(n.c)("roughness")],t.prototype,"_roughness",void 0),r.c([Object(n.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"roughness",void 0),r.c([Object(n.c)()],t.prototype,"indexOfRefraction",void 0),r.c([Object(n.c)()],t.prototype,"invertRefractionY",void 0),r.c([Object(n.c)()],t.prototype,"alphaCutOff",void 0),r.c([Object(n.c)("useLightmapAsShadowmap")],t.prototype,"_useLightmapAsShadowmap",void 0),r.c([Object(n.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useLightmapAsShadowmap",void 0),r.c([Object(n.h)("diffuseFresnelParameters")],t.prototype,"_diffuseFresnelParameters",void 0),r.c([Object(n.b)("_markAllSubMeshesAsFresnelDirty")],t.prototype,"diffuseFresnelParameters",void 0),r.c([Object(n.h)("opacityFresnelParameters")],t.prototype,"_opacityFresnelParameters",void 0),r.c([Object(n.b)("_markAllSubMeshesAsFresnelAndMiscDirty")],t.prototype,"opacityFresnelParameters",void 0),r.c([Object(n.h)("reflectionFresnelParameters")],t.prototype,"_reflectionFresnelParameters",void 0),r.c([Object(n.b)("_markAllSubMeshesAsFresnelDirty")],t.prototype,"reflectionFresnelParameters",void 0),r.c([Object(n.h)("refractionFresnelParameters")],t.prototype,"_refractionFresnelParameters",void 0),r.c([Object(n.b)("_markAllSubMeshesAsFresnelDirty")],t.prototype,"refractionFresnelParameters",void 0),r.c([Object(n.h)("emissiveFresnelParameters")],t.prototype,"_emissiveFresnelParameters",void 0),r.c([Object(n.b)("_markAllSubMeshesAsFresnelDirty")],t.prototype,"emissiveFresnelParameters",void 0),r.c([Object(n.c)("useReflectionFresnelFromSpecular")],t.prototype,"_useReflectionFresnelFromSpecular",void 0),r.c([Object(n.b)("_markAllSubMeshesAsFresnelDirty")],t.prototype,"useReflectionFresnelFromSpecular",void 0),r.c([Object(n.c)("useGlossinessFromSpecularMapAlpha")],t.prototype,"_useGlossinessFromSpecularMapAlpha",void 0),r.c([Object(n.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useGlossinessFromSpecularMapAlpha",void 0),r.c([Object(n.c)("maxSimultaneousLights")],t.prototype,"_maxSimultaneousLights",void 0),r.c([Object(n.b)("_markAllSubMeshesAsLightsDirty")],t.prototype,"maxSimultaneousLights",void 0),r.c([Object(n.c)("invertNormalMapX")],t.prototype,"_invertNormalMapX",void 0),r.c([Object(n.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"invertNormalMapX",void 0),r.c([Object(n.c)("invertNormalMapY")],t.prototype,"_invertNormalMapY",void 0),r.c([Object(n.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"invertNormalMapY",void 0),r.c([Object(n.c)("twoSidedLighting")],t.prototype,"_twoSidedLighting",void 0),r.c([Object(n.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"twoSidedLighting",void 0),r.c([Object(n.c)()],t.prototype,"useLogarithmicDepth",null),t}(d.a);_.a.RegisteredTypes["BABYLON.StandardMaterial"]=P,s.a.DefaultMaterialFactory=function(e){return new P("default material",e)}},function(e,t,i){"use strict";i.d(t,"a",function(){return r});var r=function(){function e(){}return e.BuildArray=function(e,t){for(var i=[],r=0;r<e;++r)i.push(t());return i},e}()},function(e,t,i){"use strict";i.d(t,"a",function(){return c});var r=i(0),n=i(10),o=i(13),s=i(68),a=i(4);o.a.CreateLineSystem=function(e){for(var t=[],i=[],r=e.lines,n=e.colors,s=[],a=0,c=0;c<r.length;c++)for(var l=r[c],u=0;u<l.length;u++){if(i.push(l[u].x,l[u].y,l[u].z),n){var h=n[c];s.push(h[u].r,h[u].g,h[u].b,h[u].a)}u>0&&(t.push(a-1),t.push(a)),a++}var d=new o.a;return d.indices=t,d.positions=i,n&&(d.colors=s),d},o.a.CreateDashedLines=function(e){var t,i,n=e.dashSize||3,s=e.gapSize||1,a=e.dashNb||200,c=e.points,l=new Array,u=new Array,h=r.x.Zero(),d=0,f=0,p=0,_=0,g=0;for(g=0;g<c.length-1;g++)c[g+1].subtractToRef(c[g],h),d+=h.length();for(i=n*(t=d/a)/(n+s),g=0;g<c.length-1;g++){c[g+1].subtractToRef(c[g],h),f=Math.floor(h.length()/t),h.normalize();for(var m=0;m<f;m++)p=t*m,l.push(c[g].x+p*h.x,c[g].y+p*h.y,c[g].z+p*h.z),l.push(c[g].x+(p+i)*h.x,c[g].y+(p+i)*h.y,c[g].z+(p+i)*h.z),u.push(_,_+1),_+=2}var v=new o.a;return v.positions=l,v.indices=u,v},n.a.CreateLines=function(e,t,i,r,n){void 0===i&&(i=null),void 0===r&&(r=!1),void 0===n&&(n=null);var o={points:t,updatable:r,instance:n};return c.CreateLines(e,o,i)},n.a.CreateDashedLines=function(e,t,i,r,n,o,s,a){void 0===o&&(o=null);var l={points:t,dashSize:i,gapSize:r,dashNb:n,updatable:s,instance:a};return c.CreateDashedLines(e,l,o)};var c=function(){function e(){}return e.CreateLineSystem=function(e,t,i){var r=t.instance,n=t.lines,c=t.colors;if(r){var l,u,h=r.getVerticesData(a.b.PositionKind);c&&(l=r.getVerticesData(a.b.ColorKind));for(var d=0,f=0,p=0;p<n.length;p++)for(var _=n[p],g=0;g<_.length;g++)h[d]=_[g].x,h[d+1]=_[g].y,h[d+2]=_[g].z,c&&l&&(u=c[p],l[f]=u[g].r,l[f+1]=u[g].g,l[f+2]=u[g].b,l[f+3]=u[g].a,f+=4),d+=3;return r.updateVerticesData(a.b.PositionKind,h,!1,!1),c&&l&&r.updateVerticesData(a.b.ColorKind,l,!1,!1),r}var m=!!c,v=new s.b(e,i,null,void 0,void 0,m,t.useVertexAlpha);return o.a.CreateLineSystem(t).applyToMesh(v,t.updatable),v},e.CreateLines=function(t,i,r){void 0===r&&(r=null);var n=i.colors?[i.colors]:null;return e.CreateLineSystem(t,{lines:[i.points],updatable:i.updatable,instance:i.instance,colors:n,useVertexAlpha:i.useVertexAlpha},r)},e.CreateDashedLines=function(e,t,i){void 0===i&&(i=null);var a=t.points,c=t.instance,l=t.gapSize||1,u=t.dashSize||3;if(c){return c.updateMeshPositions(function(e){var t,i,n=r.x.Zero(),o=e.length/6,s=0,l=0,u=0,h=0,d=0,f=0;for(d=0;d<a.length-1;d++)a[d+1].subtractToRef(a[d],n),s+=n.length();t=s/o;var p=c._creationDataStorage.dashSize;for(i=p*t/(p+c._creationDataStorage.gapSize),d=0;d<a.length-1;d++)for(a[d+1].subtractToRef(a[d],n),l=Math.floor(n.length()/t),n.normalize(),f=0;f<l&&h<e.length;)u=t*f,e[h]=a[d].x+u*n.x,e[h+1]=a[d].y+u*n.y,e[h+2]=a[d].z+u*n.z,e[h+3]=a[d].x+(u+i)*n.x,e[h+4]=a[d].y+(u+i)*n.y,e[h+5]=a[d].z+(u+i)*n.z,h+=6,f++;for(;h<e.length;)e[h]=a[d].x,e[h+1]=a[d].y,e[h+2]=a[d].z,h+=3},!1),c}var h=new s.b(e,i);return o.a.CreateDashedLines(t).applyToMesh(h,t.updatable),h._creationDataStorage=new n.c,h._creationDataStorage.dashSize=u,h._creationDataStorage.gapSize=l,h},e}()},function(e,t,i){"use strict";i.d(t,"e",function(){return n}),i.d(t,"a",function(){return o}),i.d(t,"d",function(){return s}),i.d(t,"c",function(){return a}),i.d(t,"b",function(){return c});var r=i(1),n=function(){function e(e,t){this.type=e,this.jointData=t,t.nativeParams=t.nativeParams||{}}return Object.defineProperty(e.prototype,"physicsJoint",{get:function(){return this._physicsJoint},set:function(e){this._physicsJoint,this._physicsJoint=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"physicsPlugin",{set:function(e){this._physicsPlugin=e},enumerable:!0,configurable:!0}),e.prototype.executeNativeFunction=function(e){e(this._physicsPlugin.world,this._physicsJoint)},e.DistanceJoint=0,e.HingeJoint=1,e.BallAndSocketJoint=2,e.WheelJoint=3,e.SliderJoint=4,e.PrismaticJoint=5,e.UniversalJoint=6,e.Hinge2Joint=e.WheelJoint,e.PointToPointJoint=8,e.SpringJoint=9,e.LockJoint=10,e}(),o=function(e){function t(t){return e.call(this,n.DistanceJoint,t)||this}return r.d(t,e),t.prototype.updateDistance=function(e,t){this._physicsPlugin.updateDistanceJoint(this,e,t)},t}(n),s=function(e){function t(t,i){return e.call(this,t,i)||this}return r.d(t,e),t.prototype.setMotor=function(e,t){this._physicsPlugin.setMotor(this,e||0,t)},t.prototype.setLimit=function(e,t){this._physicsPlugin.setLimit(this,e,t)},t}(n),a=function(e){function t(t){return e.call(this,n.HingeJoint,t)||this}return r.d(t,e),t.prototype.setMotor=function(e,t){this._physicsPlugin.setMotor(this,e||0,t)},t.prototype.setLimit=function(e,t){this._physicsPlugin.setLimit(this,e,t)},t}(s),c=function(e){function t(t){return e.call(this,n.Hinge2Joint,t)||this}return r.d(t,e),t.prototype.setMotor=function(e,t,i){void 0===i&&(i=0),this._physicsPlugin.setMotor(this,e||0,t,i)},t.prototype.setLimit=function(e,t,i){void 0===i&&(i=0),this._physicsPlugin.setLimit(this,e,t,i)},t}(s)},function(e,t,i){"use strict";i.d(t,"a",function(){return r});var r=function(){function e(e,t,i,r,n,o){this.source=e,this.pointerX=t,this.pointerY=i,this.meshUnderPointer=r,this.sourceEvent=n,this.additionalData=o}return e.CreateNew=function(t,i,r){var n=t.getScene();return new e(t,n.pointerX,n.pointerY,n.meshUnderPointer,i,r)},e.CreateNewFromSprite=function(t,i,r,n){return new e(t,i.pointerX,i.pointerY,i.meshUnderPointer,r,n)},e.CreateNewFromScene=function(t,i){return new e(null,t.pointerX,t.pointerY,t.meshUnderPointer,i)},e.CreateNewFromPrimitive=function(t,i,r,n){return new e(t,i.x,i.y,null,r,n)},e}()},function(e,t,i){"use strict";i.d(t,"a",function(){return r});var r=function(){function e(){}return e.IsWindowObjectExist=function(){return"undefined"!=typeof window},e.GetDOMTextContent=function(e){for(var t="",i=e.firstChild;i;)3===i.nodeType&&(t+=i.textContent),i=i.nextSibling;return t},e}()},function(e,t,i){"use strict";i.d(t,"a",function(){return l});var r=i(1),n=i(2),o=i(0),s=i(24),a=i(66),c=i(20),l=function(e){function t(i,r){var n=e.call(this,i,r)||this;return n.diffuse=new o.e(1,1,1),n.specular=new o.e(1,1,1),n.falloffType=t.FALLOFF_DEFAULT,n.intensity=1,n._range=Number.MAX_VALUE,n._inverseSquaredRange=0,n._photometricScale=1,n._intensityMode=t.INTENSITYMODE_AUTOMATIC,n._radius=1e-5,n.renderPriority=0,n._shadowEnabled=!0,n._excludeWithLayerMask=0,n._includeOnlyWithLayerMask=0,n._lightmapMode=0,n._excludedMeshesIds=new Array,n._includedOnlyMeshesIds=new Array,n._isLight=!0,n.getScene().addLight(n),n._uniformBuffer=new a.a(n.getScene().getEngine()),n._buildUniformLayout(),n.includedOnlyMeshes=new Array,n.excludedMeshes=new Array,n._resyncMeshes(),n}return r.d(t,e),Object.defineProperty(t.prototype,"range",{get:function(){return this._range},set:function(e){this._range=e,this._inverseSquaredRange=1/(this.range*this.range)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"intensityMode",{get:function(){return this._intensityMode},set:function(e){this._intensityMode=e,this._computePhotometricScale()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"radius",{get:function(){return this._radius},set:function(e){this._radius=e,this._computePhotometricScale()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"shadowEnabled",{get:function(){return this._shadowEnabled},set:function(e){this._shadowEnabled!==e&&(this._shadowEnabled=e,this._markMeshesAsLightDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"includedOnlyMeshes",{get:function(){return this._includedOnlyMeshes},set:function(e){this._includedOnlyMeshes=e,this._hookArrayForIncludedOnly(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"excludedMeshes",{get:function(){return this._excludedMeshes},set:function(e){this._excludedMeshes=e,this._hookArrayForExcluded(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"excludeWithLayerMask",{get:function(){return this._excludeWithLayerMask},set:function(e){this._excludeWithLayerMask=e,this._resyncMeshes()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"includeOnlyWithLayerMask",{get:function(){return this._includeOnlyWithLayerMask},set:function(e){this._includeOnlyWithLayerMask=e,this._resyncMeshes()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"lightmapMode",{get:function(){return this._lightmapMode},set:function(e){this._lightmapMode!==e&&(this._lightmapMode=e,this._markMeshesAsLightDirty())},enumerable:!0,configurable:!0}),t.prototype.getClassName=function(){return"Light"},t.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},t.prototype._syncParentEnabledState=function(){e.prototype._syncParentEnabledState.call(this),this._resyncMeshes()},t.prototype.setEnabled=function(t){e.prototype.setEnabled.call(this,t),this._resyncMeshes()},t.prototype.getShadowGenerator=function(){return this._shadowGenerator},t.prototype.getAbsolutePosition=function(){return o.x.Zero()},t.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)))},t.CompareLightsPriority=function(e,t){return e.shadowEnabled!==t.shadowEnabled?(t.shadowEnabled?1:0)-(e.shadowEnabled?1:0):t.renderPriority-e.renderPriority},t.prototype.dispose=function(t,i){void 0===i&&(i=!1),this._shadowGenerator&&(this._shadowGenerator.dispose(),this._shadowGenerator=null),this.getScene().stopAnimation(this);for(var r=0,n=this.getScene().meshes;r<n.length;r++){n[r]._removeLightSource(this)}this._uniformBuffer.dispose(),this.getScene().removeLight(this),e.prototype.dispose.call(this,t,i)},t.prototype.getTypeID=function(){return 0},t.prototype.getScaledIntensity=function(){return this._photometricScale*this.intensity},t.prototype.clone=function(e){var i=t.GetConstructorFromName(this.getTypeID(),e,this.getScene());return i?n.a.Clone(i,this):null},t.prototype.serialize=function(){var e=n.a.Serialize(this);return e.type=this.getTypeID(),this.parent&&(e.parentId=this.parent.id),this.excludedMeshes.length>0&&(e.excludedMeshesIds=[],this.excludedMeshes.forEach(function(t){e.excludedMeshesIds.push(t.id)})),this.includedOnlyMeshes.length>0&&(e.includedOnlyMeshesIds=[],this.includedOnlyMeshes.forEach(function(t){e.includedOnlyMeshesIds.push(t.id)})),n.a.AppendSerializedAnimations(this,e),e.ranges=this.serializeAnimationRanges(),e},t.GetConstructorFromName=function(e,t,i){var r=s.a.Construct("Light_Type_"+e,t,i);return r||null},t.Parse=function(e,i){var r=t.GetConstructorFromName(e.type,e.name,i);if(!r)return null;var o=n.a.Parse(r,e,i);if(e.excludedMeshesIds&&(o._excludedMeshesIds=e.excludedMeshesIds),e.includedOnlyMeshesIds&&(o._includedOnlyMeshesIds=e.includedOnlyMeshesIds),e.parentId&&(o._waitingParentId=e.parentId),e.animations){for(var a=0;a<e.animations.length;a++){var l=e.animations[a],u=c.a.GetClass("BABYLON.Animation");u&&o.animations.push(u.Parse(l))}s.a.ParseAnimationRanges(o,e,i)}return e.autoAnimate&&i.beginAnimation(o,e.autoAnimateFrom,e.autoAnimateTo,e.autoAnimateLoop,e.autoAnimateSpeed||1),o},t.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 o=i.apply(e,r),s=0,a=r;s<a.length;s++){a[s]._resyncLighSource(t)}return o};var r=e.splice;e.splice=function(i,n){for(var o=r.apply(e,[i,n]),s=0,a=o;s<a.length;s++){a[s]._resyncLighSource(t)}return o};for(var n=0,o=e;n<o.length;n++){o[n]._resyncLighSource(this)}},t.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 o=i.apply(e,r);return t._resyncMeshes(),o};var r=e.splice;e.splice=function(i,n){var o=r.apply(e,[i,n]);return t._resyncMeshes(),o},this._resyncMeshes()},t.prototype._resyncMeshes=function(){for(var e=0,t=this.getScene().meshes;e<t.length;e++){t[e]._resyncLighSource(this)}},t.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()}},t.prototype._computePhotometricScale=function(){this._photometricScale=this._getPhotometricScale(),this.getScene().resetCachedMaterial()},t.prototype._getPhotometricScale=function(){var e=0,i=this.getTypeID(),r=this.intensityMode;switch(r===t.INTENSITYMODE_AUTOMATIC&&(r=i===t.LIGHTTYPEID_DIRECTIONALLIGHT?t.INTENSITYMODE_ILLUMINANCE:t.INTENSITYMODE_LUMINOUSINTENSITY),i){case t.LIGHTTYPEID_POINTLIGHT:case t.LIGHTTYPEID_SPOTLIGHT:switch(r){case t.INTENSITYMODE_LUMINOUSPOWER:e=1/(4*Math.PI);break;case t.INTENSITYMODE_LUMINOUSINTENSITY:e=1;break;case t.INTENSITYMODE_LUMINANCE:e=this.radius*this.radius}break;case t.LIGHTTYPEID_DIRECTIONALLIGHT:switch(r){case t.INTENSITYMODE_ILLUMINANCE:e=1;break;case t.INTENSITYMODE_LUMINANCE:var n=this.radius;n=Math.max(n,.001),e=2*Math.PI*(1-Math.cos(n))}break;case t.LIGHTTYPEID_HEMISPHERICLIGHT:e=1}return e},t.prototype._reorderLightsInScene=function(){var e=this.getScene();0!=this._renderPriority&&(e.requireLightSorting=!0),this.getScene().sortLightsByPriority()},t.FALLOFF_DEFAULT=0,t.FALLOFF_PHYSICAL=1,t.FALLOFF_GLTF=2,t.FALLOFF_STANDARD=3,t.LIGHTMAP_DEFAULT=0,t.LIGHTMAP_SPECULAR=1,t.LIGHTMAP_SHADOWSONLY=2,t.INTENSITYMODE_AUTOMATIC=0,t.INTENSITYMODE_LUMINOUSPOWER=1,t.INTENSITYMODE_LUMINOUSINTENSITY=2,t.INTENSITYMODE_ILLUMINANCE=3,t.INTENSITYMODE_LUMINANCE=4,t.LIGHTTYPEID_POINTLIGHT=0,t.LIGHTTYPEID_DIRECTIONALLIGHT=1,t.LIGHTTYPEID_SPOTLIGHT=2,t.LIGHTTYPEID_HEMISPHERICLIGHT=3,r.c([Object(n.e)()],t.prototype,"diffuse",void 0),r.c([Object(n.e)()],t.prototype,"specular",void 0),r.c([Object(n.c)()],t.prototype,"falloffType",void 0),r.c([Object(n.c)()],t.prototype,"intensity",void 0),r.c([Object(n.c)()],t.prototype,"range",null),r.c([Object(n.c)()],t.prototype,"intensityMode",null),r.c([Object(n.c)()],t.prototype,"radius",null),r.c([Object(n.c)()],t.prototype,"_renderPriority",void 0),r.c([Object(n.b)("_reorderLightsInScene")],t.prototype,"renderPriority",void 0),r.c([Object(n.c)("shadowEnabled")],t.prototype,"_shadowEnabled",void 0),r.c([Object(n.c)("excludeWithLayerMask")],t.prototype,"_excludeWithLayerMask",void 0),r.c([Object(n.c)("includeOnlyWithLayerMask")],t.prototype,"_includeOnlyWithLayerMask",void 0),r.c([Object(n.c)("lightmapMode")],t.prototype,"_lightmapMode",void 0),t}(s.a)},function(e,t,i){"use strict";i.d(t,"a",function(){return a});var r=i(17),n=i(7),o=i(15),s=i(22),a=function(){function e(e,t){void 0===t&&(t=!0);var i=this;this.originalScene=e,this._pointerCaptures={},this._lastPointerEvents={},this.pickUtilitySceneFirst=!0,this.shouldRender=!0,this.onlyCheckPointerDownEvents=!0,this.processAllEvents=!1,this.onPointerOutObservable=new n.c,this.utilityLayerScene=new r.a(e.getEngine()),this.utilityLayerScene.useRightHandedSystem=e.useRightHandedSystem,this.utilityLayerScene._allowPostProcessClearColor=!1,e.getEngine().scenes.pop(),this.utilityLayerScene.detachControl(),t&&(this._originalPointerObserver=e.onPrePointerObservable.add(function(t,r){if(i.utilityLayerScene.activeCamera&&(i.processAllEvents||t.type===o.a.POINTERMOVE||t.type===o.a.POINTERUP||t.type===o.a.POINTERDOWN)){i.utilityLayerScene.pointerX=e.pointerX,i.utilityLayerScene.pointerY=e.pointerY;var n=t.event;if(e.isPointerCaptured(n.pointerId))i._pointerCaptures[n.pointerId]=!1;else{var s=t.ray?i.utilityLayerScene.pickWithRay(t.ray):i.utilityLayerScene.pick(e.pointerX,e.pointerY);if(!t.ray&&s&&(t.ray=s.ray),i.utilityLayerScene.onPrePointerObservable.notifyObservers(t),i.onlyCheckPointerDownEvents&&t.type!=o.a.POINTERDOWN)return t.skipOnPointerObservable||i.utilityLayerScene.onPointerObservable.notifyObservers(new o.b(t.type,t.event,s)),void(t.type===o.a.POINTERUP&&i._pointerCaptures[n.pointerId]&&(i._pointerCaptures[n.pointerId]=!1));if(i.utilityLayerScene.autoClearDepthAndStencil||i.pickUtilitySceneFirst)s&&s.hit&&(t.skipOnPointerObservable||i.utilityLayerScene.onPointerObservable.notifyObservers(new o.b(t.type,t.event,s)),t.skipOnPointerObservable=!0);else{var a=t.ray?e.pickWithRay(t.ray):e.pick(e.pointerX,e.pointerY),c=t.event;a&&s&&(0===s.distance&&a.pickedMesh?i.mainSceneTrackerPredicate&&i.mainSceneTrackerPredicate(a.pickedMesh)?(i._notifyObservers(t,a,c),t.skipOnPointerObservable=!0):t.type===o.a.POINTERDOWN?i._pointerCaptures[c.pointerId]=!0:i._lastPointerEvents[c.pointerId]&&(i.onPointerOutObservable.notifyObservers(c.pointerId),delete i._lastPointerEvents[c.pointerId]):!i._pointerCaptures[c.pointerId]&&(s.distance<a.distance||0===a.distance)?(i._notifyObservers(t,s,c),t.skipOnPointerObservable||(t.skipOnPointerObservable=s.distance>0)):!i._pointerCaptures[c.pointerId]&&s.distance>a.distance&&(i.mainSceneTrackerPredicate&&i.mainSceneTrackerPredicate(a.pickedMesh)?(i._notifyObservers(t,a,c),t.skipOnPointerObservable=!0):i._lastPointerEvents[c.pointerId]&&(i.onPointerOutObservable.notifyObservers(c.pointerId),delete i._lastPointerEvents[c.pointerId])),t.type===o.a.POINTERUP&&i._pointerCaptures[c.pointerId]&&(i._pointerCaptures[c.pointerId]=!1))}}}})),this.utilityLayerScene.autoClear=!1,this._afterRenderObserver=this.originalScene.onAfterRenderObservable.add(function(){i.shouldRender&&i.render()}),this._sceneDisposeObserver=this.originalScene.onDisposeObservable.add(function(){i.dispose()}),this._updateCamera()}return Object.defineProperty(e,"DefaultUtilityLayer",{get:function(){return null==e._DefaultUtilityLayer&&(e._DefaultUtilityLayer=new e(s.a.LastCreatedScene),e._DefaultUtilityLayer.originalScene.onDisposeObservable.addOnce(function(){e._DefaultUtilityLayer=null})),e._DefaultUtilityLayer},enumerable:!0,configurable:!0}),Object.defineProperty(e,"DefaultKeepDepthUtilityLayer",{get:function(){return null==e._DefaultKeepDepthUtilityLayer&&(e._DefaultKeepDepthUtilityLayer=new e(s.a.LastCreatedScene),e._DefaultKeepDepthUtilityLayer.utilityLayerScene.autoClearDepthAndStencil=!1,e._DefaultKeepDepthUtilityLayer.originalScene.onDisposeObservable.addOnce(function(){e._DefaultKeepDepthUtilityLayer=null})),e._DefaultKeepDepthUtilityLayer},enumerable:!0,configurable:!0}),e.prototype._notifyObservers=function(e,t,i){e.skipOnPointerObservable||(this.utilityLayerScene.onPointerObservable.notifyObservers(new o.b(e.type,e.event,t)),this._lastPointerEvents[i.pointerId]=!0)},e.prototype.render=function(){if(this._updateCamera(),this.utilityLayerScene.activeCamera){var e=this.utilityLayerScene.activeCamera.getScene(),t=this.utilityLayerScene.activeCamera;t._scene=this.utilityLayerScene,t.leftCamera&&(t.leftCamera._scene=this.utilityLayerScene),t.rightCamera&&(t.rightCamera._scene=this.utilityLayerScene),this.utilityLayerScene.render(!1),t._scene=e,t.leftCamera&&(t.leftCamera._scene=e),t.rightCamera&&(t.rightCamera._scene=e)}},e.prototype.dispose=function(){this.onPointerOutObservable.clear(),this._afterRenderObserver&&this.originalScene.onAfterRenderObservable.remove(this._afterRenderObserver),this._sceneDisposeObserver&&this.originalScene.onDisposeObservable.remove(this._sceneDisposeObserver),this._originalPointerObserver&&this.originalScene.onPrePointerObservable.remove(this._originalPointerObserver),this.utilityLayerScene.dispose()},e.prototype._updateCamera=function(){this.originalScene.activeCameras.length>1?this.utilityLayerScene.activeCamera=this.originalScene.activeCameras[this.originalScene.activeCameras.length-1]:this.utilityLayerScene.activeCamera=this.originalScene.activeCamera},e._DefaultUtilityLayer=null,e._DefaultKeepDepthUtilityLayer=null,e}()},function(e,t,i){"use strict";i.d(t,"a",function(){return d});var r=i(34),n=i(0),o=i(3),s=i(71),a=i(74),c={min:0,max:0},l={min:0,max:0},u=function(e,t,i){var r=n.x.Dot(t.centerWorld,e),o=Math.abs(n.x.Dot(t.directions[0],e))*t.extendSize.x+Math.abs(n.x.Dot(t.directions[1],e))*t.extendSize.y+Math.abs(n.x.Dot(t.directions[2],e))*t.extendSize.z;i.min=r-o,i.max=r+o},h=function(e,t,i){return u(e,t,c),u(e,i,l),!(c.min>l.max||l.min>c.max)},d=function(){function e(e,t,i){this._isLocked=!1,this.boundingBox=new s.a(e,t,i),this.boundingSphere=new a.a(e,t,i)}return e.prototype.reConstruct=function(e,t,i){this.boundingBox.reConstruct(e,t,i),this.boundingSphere.reConstruct(e,t,i)},Object.defineProperty(e.prototype,"minimum",{get:function(){return this.boundingBox.minimum},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"maximum",{get:function(){return this.boundingBox.maximum},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isLocked",{get:function(){return this._isLocked},set:function(e){this._isLocked=e},enumerable:!0,configurable:!0}),e.prototype.update=function(e){this._isLocked||(this.boundingBox._update(e),this.boundingSphere._update(e))},e.prototype.centerOn=function(t,i){var r=e.TmpVector3[0].copyFrom(t).subtractInPlace(i),n=e.TmpVector3[1].copyFrom(t).addInPlace(i);return this.boundingBox.reConstruct(r,n,this.boundingBox.getWorldMatrix()),this.boundingSphere.reConstruct(r,n,this.boundingBox.getWorldMatrix()),this},e.prototype.scale=function(e){return this.boundingBox.scale(e),this.boundingSphere.scale(e),this},e.prototype.isInFrustum=function(e,t){return void 0===t&&(t=o.a.MESHES_CULLINGSTRATEGY_STANDARD),!(t!==o.a.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION&&t!==o.a.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY||!this.boundingSphere.isCenterInFrustum(e))||!!this.boundingSphere.isInFrustum(e)&&(!(t!==o.a.MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY&&t!==o.a.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY)||this.boundingBox.isInFrustum(e))},Object.defineProperty(e.prototype,"diagonalLength",{get:function(){var t=this.boundingBox;return t.maximumWorld.subtractToRef(t.minimumWorld,e.TmpVector3[0]).length()},enumerable:!0,configurable:!0}),e.prototype.isCompletelyInFrustum=function(e){return this.boundingBox.isCompletelyInFrustum(e)},e.prototype._checkCollision=function(e){return e._canDoCollision(this.boundingSphere.centerWorld,this.boundingSphere.radiusWorld,this.boundingBox.minimumWorld,this.boundingBox.maximumWorld)},e.prototype.intersectsPoint=function(e){return!!this.boundingSphere.centerWorld&&(!!this.boundingSphere.intersectsPoint(e)&&!!this.boundingBox.intersectsPoint(e))},e.prototype.intersects=function(e,t){if(!a.a.Intersects(this.boundingSphere,e.boundingSphere))return!1;if(!s.a.Intersects(this.boundingBox,e.boundingBox))return!1;if(!t)return!0;var i=this.boundingBox,r=e.boundingBox;return!!h(i.directions[0],i,r)&&(!!h(i.directions[1],i,r)&&(!!h(i.directions[2],i,r)&&(!!h(r.directions[0],i,r)&&(!!h(r.directions[1],i,r)&&(!!h(r.directions[2],i,r)&&(!!h(n.x.Cross(i.directions[0],r.directions[0]),i,r)&&(!!h(n.x.Cross(i.directions[0],r.directions[1]),i,r)&&(!!h(n.x.Cross(i.directions[0],r.directions[2]),i,r)&&(!!h(n.x.Cross(i.directions[1],r.directions[0]),i,r)&&(!!h(n.x.Cross(i.directions[1],r.directions[1]),i,r)&&(!!h(n.x.Cross(i.directions[1],r.directions[2]),i,r)&&(!!h(n.x.Cross(i.directions[2],r.directions[0]),i,r)&&(!!h(n.x.Cross(i.directions[2],r.directions[1]),i,r)&&!!h(n.x.Cross(i.directions[2],r.directions[2]),i,r))))))))))))))},e.TmpVector3=r.a.BuildArray(2,n.x.Zero),e}()},function(e,t,i){"use strict";i.d(t,"a",function(){return n});var r=i(0),n=function(){function e(){}return e._RemoveAndStorePivotPoint=function(t){t&&0===e._PivotCached&&(t.getPivotPointToRef(e._OldPivotPoint),e._OldPivotPoint.equalsToFloats(0,0,0)||(t.setPivotMatrix(r.j.IdentityReadOnly),e._OldPivotPoint.subtractToRef(t.getPivotPoint(),e._PivotTranslation),e._PivotTmpVector.copyFromFloats(1,1,1),e._PivotTmpVector.subtractInPlace(t.scaling),e._PivotTmpVector.multiplyInPlace(e._PivotTranslation),t.position.addInPlace(e._PivotTmpVector))),e._PivotCached++},e._RestorePivotPoint=function(t){t&&!e._OldPivotPoint.equalsToFloats(0,0,0)&&1===e._PivotCached&&(t.setPivotPoint(e._OldPivotPoint),e._PivotTmpVector.copyFromFloats(1,1,1),e._PivotTmpVector.subtractInPlace(t.scaling),e._PivotTmpVector.multiplyInPlace(e._PivotTranslation),t.position.subtractInPlace(e._PivotTmpVector)),this._PivotCached--},e._PivotCached=0,e._OldPivotPoint=new r.x,e._PivotTranslation=new r.x,e._PivotTmpVector=new r.x,e}()},function(e,t,i){"use strict";i.d(t,"a",function(){return n});var r=i(38),n=function(){function e(){}return Object.defineProperty(e,"Now",{get:function(){return r.a.IsWindowObjectExist()&&window.performance&&window.performance.now?window.performance.now():Date.now()},enumerable:!0,configurable:!0}),e}()},function(e,t,i){"use strict";i.d(t,"a",function(){return h});var r=i(1),n=i(2),o=i(7),s=i(9),a=i(67),c=i(0),l=i(22),u=i(3),h=function(){function e(t){this.metadata=null,this.reservedDataStore=null,this._hasAlpha=!1,this.getAlphaFromRGB=!1,this.level=1,this.coordinatesIndex=0,this._coordinatesMode=u.a.TEXTURE_EXPLICIT_MODE,this.wrapU=u.a.TEXTURE_WRAP_ADDRESSMODE,this.wrapV=u.a.TEXTURE_WRAP_ADDRESSMODE,this.wrapR=u.a.TEXTURE_WRAP_ADDRESSMODE,this.anisotropicFilteringLevel=e.DEFAULT_ANISOTROPIC_FILTERING_LEVEL,this.gammaSpace=!0,this.invertZ=!1,this.lodLevelInAlpha=!1,this.isRenderTarget=!1,this.animations=new Array,this.onDisposeObservable=new o.c,this.delayLoadState=u.a.DELAYLOADSTATE_NONE,this._cachedSize=c.r.Zero(),this._scene=t||l.a.LastCreatedScene,this._scene&&(this.uniqueId=this._scene.getUniqueId(),this._scene.addTexture(this)),this._uid=null}return Object.defineProperty(e.prototype,"hasAlpha",{get:function(){return this._hasAlpha},set:function(e){this._hasAlpha!==e&&(this._hasAlpha=e,this._scene&&this._scene.markAllMaterialsAsDirty(u.a.MATERIAL_TextureDirtyFlag|u.a.MATERIAL_MiscDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"coordinatesMode",{get:function(){return this._coordinatesMode},set:function(e){this._coordinatesMode!==e&&(this._coordinatesMode=e,this._scene&&this._scene.markAllMaterialsAsDirty(u.a.MATERIAL_TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isCube",{get:function(){return!!this._texture&&this._texture.isCube},set:function(e){this._texture&&(this._texture.isCube=e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"is3D",{get:function(){return!!this._texture&&this._texture.is3D},set:function(e){this._texture&&(this._texture.is3D=e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isRGBD",{get:function(){return null!=this._texture&&this._texture._isRGBD},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"noMipmap",{get:function(){return!1},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"lodGenerationOffset",{get:function(){return this._texture?this._texture._lodGenerationOffset:0},set:function(e){this._texture&&(this._texture._lodGenerationOffset=e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"lodGenerationScale",{get:function(){return this._texture?this._texture._lodGenerationScale:0},set:function(e){this._texture&&(this._texture._lodGenerationScale=e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"uid",{get:function(){return this._uid||(this._uid=s.h.RandomId()),this._uid},enumerable:!0,configurable:!0}),e.prototype.toString=function(){return this.name},e.prototype.getClassName=function(){return"BaseTexture"},Object.defineProperty(e.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isBlocking",{get:function(){return!0},enumerable:!0,configurable:!0}),e.prototype.getScene=function(){return this._scene},e.prototype.getTextureMatrix=function(){return c.j.IdentityReadOnly},e.prototype.getReflectionTextureMatrix=function(){return c.j.IdentityReadOnly},e.prototype.getInternalTexture=function(){return this._texture},e.prototype.isReadyOrNotBlocking=function(){return!this.isBlocking||this.isReady()},e.prototype.isReady=function(){return this.delayLoadState===u.a.DELAYLOADSTATE_NOTLOADED?(this.delayLoad(),!1):!!this._texture&&this._texture.isReady},e.prototype.getSize=function(){if(this._texture){if(this._texture.width)return this._cachedSize.width=this._texture.width,this._cachedSize.height=this._texture.height,this._cachedSize;if(this._texture._size)return this._cachedSize.width=this._texture._size,this._cachedSize.height=this._texture._size,this._cachedSize}return this._cachedSize},e.prototype.getBaseSize=function(){return this.isReady()&&this._texture?this._texture._size?new c.r(this._texture._size,this._texture._size):new c.r(this._texture.baseWidth,this._texture.baseHeight):c.r.Zero()},e.prototype.updateSamplingMode=function(e){if(this._texture){var t=this.getScene();t&&t.getEngine().updateTextureSamplingMode(e,this._texture)}},e.prototype.scale=function(e){},Object.defineProperty(e.prototype,"canRescale",{get:function(){return!1},enumerable:!0,configurable:!0}),e.prototype._getFromCache=function(e,t,i){if(!this._scene)return null;for(var r=this._scene.getEngine().getLoadedTexturesCache(),n=0;n<r.length;n++){var o=r[n];if(o.url===e&&o.generateMipMaps===!t&&(!i||i===o.samplingMode))return o.incrementReferences(),o}return null},e.prototype._rebuild=function(){},e.prototype.delayLoad=function(){},e.prototype.clone=function(){return null},Object.defineProperty(e.prototype,"textureType",{get:function(){return this._texture&&void 0!==this._texture.type?this._texture.type:u.a.TEXTURETYPE_UNSIGNED_INT},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"textureFormat",{get:function(){return this._texture&&void 0!==this._texture.format?this._texture.format:u.a.TEXTUREFORMAT_RGBA},enumerable:!0,configurable:!0}),e.prototype.readPixels=function(e,t,i){if(void 0===e&&(e=0),void 0===t&&(t=0),void 0===i&&(i=null),!this._texture)return null;var r=this.getSize(),n=r.width,o=r.height,s=this.getScene();if(!s)return null;var a=s.getEngine();return 0!=t&&(n/=Math.pow(2,t),o/=Math.pow(2,t),n=Math.round(n),o=Math.round(o)),this._texture.isCube?a._readTexturePixels(this._texture,n,o,e,t,i):a._readTexturePixels(this._texture,n,o,-1,t,i)},e.prototype.releaseInternalTexture=function(){this._texture&&(this._texture.dispose(),this._texture=null)},Object.defineProperty(e.prototype,"sphericalPolynomial",{get:function(){return this._texture&&a.a&&this.isReady()?(this._texture._sphericalPolynomial||(this._texture._sphericalPolynomial=a.a.ConvertCubeMapTextureToSphericalPolynomial(this)),this._texture._sphericalPolynomial):null},set:function(e){this._texture&&(this._texture._sphericalPolynomial=e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"_lodTextureHigh",{get:function(){return this._texture?this._texture._lodTextureHigh:null},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"_lodTextureMid",{get:function(){return this._texture?this._texture._lodTextureMid:null},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"_lodTextureLow",{get:function(){return this._texture?this._texture._lodTextureLow:null},enumerable:!0,configurable:!0}),e.prototype.dispose=function(){if(this._scene){this._scene.stopAnimation(this),this._scene._removePendingData(this);var e=this._scene.textures.indexOf(this);e>=0&&this._scene.textures.splice(e,1),this._scene.onTextureRemovedObservable.notifyObservers(this),void 0!==this._texture&&(this.releaseInternalTexture(),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear())}},e.prototype.serialize=function(){if(!this.name)return null;var e=n.a.Serialize(this);return n.a.AppendSerializedAnimations(this,e),e},e.WhenAllReady=function(e,t){var i=e.length;if(0!==i)for(var r,n,o=function(){if((r=e[s]).isReady())0==--i&&t();else{n=r.onLoadObservable;var o=function(){n.removeCallback(o),0==--i&&t()};n.add(o)}},s=0;s<e.length;s++)o();else t()},e.DEFAULT_ANISOTROPIC_FILTERING_LEVEL=4,r.c([Object(n.c)()],e.prototype,"uniqueId",void 0),r.c([Object(n.c)()],e.prototype,"name",void 0),r.c([Object(n.c)()],e.prototype,"metadata",void 0),r.c([Object(n.c)("hasAlpha")],e.prototype,"_hasAlpha",void 0),r.c([Object(n.c)()],e.prototype,"getAlphaFromRGB",void 0),r.c([Object(n.c)()],e.prototype,"level",void 0),r.c([Object(n.c)()],e.prototype,"coordinatesIndex",void 0),r.c([Object(n.c)("coordinatesMode")],e.prototype,"_coordinatesMode",void 0),r.c([Object(n.c)()],e.prototype,"wrapU",void 0),r.c([Object(n.c)()],e.prototype,"wrapV",void 0),r.c([Object(n.c)()],e.prototype,"wrapR",void 0),r.c([Object(n.c)()],e.prototype,"anisotropicFilteringLevel",void 0),r.c([Object(n.c)()],e.prototype,"isCube",null),r.c([Object(n.c)()],e.prototype,"is3D",null),r.c([Object(n.c)()],e.prototype,"gammaSpace",void 0),r.c([Object(n.c)()],e.prototype,"invertZ",void 0),r.c([Object(n.c)()],e.prototype,"lodLevelInAlpha",void 0),r.c([Object(n.c)()],e.prototype,"lodGenerationOffset",null),r.c([Object(n.c)()],e.prototype,"lodGenerationScale",null),r.c([Object(n.c)()],e.prototype,"isRenderTarget",void 0),e}()},function(e,t,i){"use strict";i.d(t,"a",function(){return l}),i.d(t,"b",function(){return u});var r=i(1),n=i(9),o=i(4),s=i(81),a=i(41),c=i(3),l=function(){function e(){}return Object.defineProperty(e.prototype,"effect",{get:function(){return this._materialEffect},enumerable:!0,configurable:!0}),e.prototype.setEffect=function(e,t){void 0===t&&(t=null),this._materialEffect!==e?(this._materialDefines=t,this._materialEffect=e):e||(this._materialDefines=null)},e}(),u=function(e){function t(t,i,r,n,o,s,a,c){void 0===c&&(c=!0);var l=e.call(this)||this;return l.materialIndex=t,l.verticesStart=i,l.verticesCount=r,l.indexStart=n,l.indexCount=o,l._renderId=0,l._mesh=s,l._renderingMesh=a||s,s.subMeshes.push(l),l._trianglePlanes=[],l._id=s.subMeshes.length-1,c&&(l.refreshBoundingInfo(),s.computeWorldMatrix(!0)),l}return r.d(t,e),t.AddToMesh=function(e,i,r,n,o,s,a,c){return void 0===c&&(c=!0),new t(e,i,r,n,o,s,a,c)},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(null==e)return this._mesh.getScene().defaultMaterial;if(e.getSubMaterial){var t=e.getSubMaterial(this.materialIndex);return this._currentMaterial!==t&&(this._currentMaterial=t,this._materialDefines=null),t}return e},t.prototype.refreshBoundingInfo=function(){if(this._lastColliderWorldVertices=null,this.IsGlobal||!this._renderingMesh||!this._renderingMesh.geometry)return this;var e=this._renderingMesh.getVerticesData(o.b.PositionKind);if(!e)return this._boundingInfo=this._mesh.getBoundingInfo(),this;var t,i=this._renderingMesh.getIndices();if(0===this.indexStart&&this.indexCount===i.length){var r=this._renderingMesh.getBoundingInfo();t={minimum:r.minimum.clone(),maximum:r.maximum.clone()}}else t=n.h.ExtractMinAndMaxIndexed(e,i,this.indexStart,this.indexCount,this._renderingMesh.geometry.boundingBias);return this._boundingInfo?this._boundingInfo.reConstruct(t.minimum,t.maximum):this._boundingInfo=new a.a(t.minimum,t.maximum),this},t.prototype._checkCollision=function(e){return this.getBoundingInfo()._checkCollision(e)},t.prototype.updateBoundingInfo=function(e){var t=this.getBoundingInfo();return t||(this.refreshBoundingInfo(),t=this.getBoundingInfo()),t.update(e),this},t.prototype.isInFrustum=function(e){var t=this.getBoundingInfo();return!!t&&t.isInFrustum(e,this._mesh.cullingStrategy)},t.prototype.isCompletelyInFrustum=function(e){var t=this.getBoundingInfo();return!!t&&t.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){var t=this.getBoundingInfo();return!!t&&e.intersectsBox(t.boundingBox)},t.prototype.intersects=function(e,t,i,r){var n=this.getMaterial();if(!n)return null;switch(n.fillMode){case c.a.MATERIAL_PointListDrawMode:case c.a.MATERIAL_LineListDrawMode:case c.a.MATERIAL_LineLoopDrawMode:case c.a.MATERIAL_LineStripDrawMode:case c.a.MATERIAL_TriangleFanDrawMode:case c.a.MATERIAL_TriangleStripDrawMode:return null}return"InstancedLinesMesh"===this._mesh.getClassName()||"LinesMesh"===this._mesh.getClassName()?this._intersectLines(e,t,i,this._mesh.intersectionThreshold,r):this._intersectTriangles(e,t,i,r)},t.prototype._intersectLines=function(e,t,i,r,n){for(var o=null,a=this.indexStart;a<this.indexStart+this.indexCount;a+=2){var c=t[i[a]],l=t[i[a+1]],u=e.intersectionSegment(c,l,r);if(!(u<0)&&((n||!o||u<o.distance)&&((o=new s.a(null,null,u)).faceId=a/2,n)))break}return o},t.prototype._intersectTriangles=function(e,t,i,r){for(var n=null,o=this.indexStart;o<this.indexStart+this.indexCount;o+=3){var s=t[i[o]],a=t[i[o+1]],c=t[i[o+2]],l=e.intersectsTriangle(s,a,c);if(l){if(l.distance<0)continue;if((r||!n||l.distance<n.distance)&&((n=l).faceId=o/3,r))break}}return n},t.prototype._rebuild=function(){this._linesIndexBuffer&&(this._linesIndexBuffer=null)},t.prototype.clone=function(e,i){var r=new t(this.materialIndex,this.verticesStart,this.verticesCount,this.indexStart,this.indexCount,e,i,!1);if(!this.IsGlobal){var n=this.getBoundingInfo();if(!n)return r;r._boundingInfo=new a.a(n.minimum,n.maximum)}return r},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.prototype.getClassName=function(){return"SubMesh"},t.CreateFromIndices=function(e,i,r,n,o){for(var s=Number.MAX_VALUE,a=-Number.MAX_VALUE,c=(o||n).getIndices(),l=i;l<i+r;l++){var u=c[l];u<s&&(s=u),u>a&&(a=u)}return new t(e,s,a-s+1,i,r,n,o)},t}(l)},function(e,t,i){"use strict";i.d(t,"a",function(){return c});var r=i(1),n=i(2),o=i(26),s=i(7),a=i(0),c=function(e){function t(i,r,n){void 0===r&&(r=null),void 0===n&&(n=!0);var o=e.call(this,i,r)||this;return o._forward=new a.x(0,0,1),o._forwardInverted=new a.x(0,0,-1),o._up=new a.x(0,1,0),o._right=new a.x(1,0,0),o._rightInverted=new a.x(-1,0,0),o._position=a.x.Zero(),o._rotation=a.x.Zero(),o._scaling=a.x.One(),o._isDirty=!1,o.billboardMode=t.BILLBOARDMODE_NONE,o.scalingDeterminant=1,o.infiniteDistance=!1,o.ignoreNonUniformScaling=!1,o._localMatrix=a.j.Zero(),o._absolutePosition=a.x.Zero(),o._pivotMatrix=a.j.Identity(),o._postMultiplyPivotMatrix=!1,o._isWorldMatrixFrozen=!1,o._indexInSceneTransformNodesArray=-1,o.onAfterWorldMatrixUpdateObservable=new s.c,o._nonUniformScaling=!1,n&&o.getScene().addTransformNode(o),o}return r.d(t,e),t.prototype.getClassName=function(){return"TransformNode"},Object.defineProperty(t.prototype,"position",{get:function(){return this._position},set:function(e){this._position=e,this._isDirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"rotation",{get:function(){return this._rotation},set:function(e){this._rotation=e,this._isDirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"scaling",{get:function(){return this._scaling},set:function(e){this._scaling=e,this._isDirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"rotationQuaternion",{get:function(){return this._rotationQuaternion},set:function(e){this._rotationQuaternion=e,e&&this.rotation.setAll(0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"forward",{get:function(){return a.x.Normalize(a.x.TransformNormal(this.getScene().useRightHandedSystem?this._forwardInverted:this._forward,this.getWorldMatrix()))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"up",{get:function(){return a.x.Normalize(a.x.TransformNormal(this._up,this.getWorldMatrix()))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"right",{get:function(){return a.x.Normalize(a.x.TransformNormal(this.getScene().useRightHandedSystem?this._rightInverted:this._right,this.getWorldMatrix()))},enumerable:!0,configurable:!0}),t.prototype.updatePoseMatrix=function(e){return this._poseMatrix.copyFrom(e),this},t.prototype.getPoseMatrix=function(){return this._poseMatrix},t.prototype._isSynchronized=function(){return!this._isDirty&&(this.billboardMode===this._cache.billboardMode&&this.billboardMode===t.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)))))))},t.prototype._initCache=function(){e.prototype._initCache.call(this),this._cache.localMatrixUpdated=!1,this._cache.position=a.x.Zero(),this._cache.scaling=a.x.Zero(),this._cache.rotation=a.x.Zero(),this._cache.rotationQuaternion=new a.q(0,0,0,0),this._cache.billboardMode=-1,this._cache.infiniteDistance=!1},t.prototype.markAsDirty=function(e){return"rotation"===e&&(this.rotationQuaternion=null),this._currentRenderId=Number.MAX_VALUE,this._isDirty=!0,this},Object.defineProperty(t.prototype,"absolutePosition",{get:function(){return this._absolutePosition},enumerable:!0,configurable:!0}),t.prototype.setPreTransformMatrix=function(e){return this.setPivotMatrix(e,!1)},t.prototype.setPivotMatrix=function(e,t){return void 0===t&&(t=!0),this._pivotMatrix.copyFrom(e),this._cache.pivotMatrixUpdated=!0,this._postMultiplyPivotMatrix=t,this._postMultiplyPivotMatrix&&(this._pivotMatrixInverse?this._pivotMatrix.invertToRef(this._pivotMatrixInverse):this._pivotMatrixInverse=a.j.Invert(this._pivotMatrix)),this},t.prototype.getPivotMatrix=function(){return this._pivotMatrix},t.prototype.freezeWorldMatrix=function(){return this._isWorldMatrixFrozen=!1,this.computeWorldMatrix(!0),this._isWorldMatrixFrozen=!0,this},t.prototype.unfreezeWorldMatrix=function(){return this._isWorldMatrixFrozen=!1,this.computeWorldMatrix(!0),this},Object.defineProperty(t.prototype,"isWorldMatrixFrozen",{get:function(){return this._isWorldMatrixFrozen},enumerable:!0,configurable:!0}),t.prototype.getAbsolutePosition=function(){return this.computeWorldMatrix(),this._absolutePosition},t.prototype.setAbsolutePosition=function(e){if(!e)return this;var t,i,r;if(void 0===e.x){if(arguments.length<3)return this;t=arguments[0],i=arguments[1],r=arguments[2]}else t=e.x,i=e.y,r=e.z;if(this.parent){var n=a.t.Matrix[0];this.parent.getWorldMatrix().invertToRef(n),a.x.TransformCoordinatesFromFloatsToRef(t,i,r,n,this.position)}else this.position.x=t,this.position.y=i,this.position.z=r;return this},t.prototype.setPositionWithLocalVector=function(e){return this.computeWorldMatrix(),this.position=a.x.TransformNormal(e,this._localMatrix),this},t.prototype.getPositionExpressedInLocalSpace=function(){this.computeWorldMatrix();var e=a.t.Matrix[0];return this._localMatrix.invertToRef(e),a.x.TransformNormal(this.position,e)},t.prototype.locallyTranslate=function(e){return this.computeWorldMatrix(!0),this.position=a.x.TransformCoordinates(e,this._localMatrix),this},t.prototype.lookAt=function(e,i,r,n,o){void 0===i&&(i=0),void 0===r&&(r=0),void 0===n&&(n=0),void 0===o&&(o=a.s.LOCAL);var s=t._lookAtVectorCache,c=o===a.s.LOCAL?this.position:this.getAbsolutePosition();if(e.subtractToRef(c,s),this.setDirection(s,i,r,n),o===a.s.WORLD&&this.parent)if(this.rotationQuaternion){var l=a.t.Matrix[0];this.rotationQuaternion.toRotationMatrix(l);var u=a.t.Matrix[1];this.parent.getWorldMatrix().getRotationMatrixToRef(u),u.invert(),l.multiplyToRef(u,l),this.rotationQuaternion.fromRotationMatrix(l)}else{var h=a.t.Quaternion[0];a.q.FromEulerVectorToRef(this.rotation,h);l=a.t.Matrix[0];h.toRotationMatrix(l);u=a.t.Matrix[1];this.parent.getWorldMatrix().getRotationMatrixToRef(u),u.invert(),l.multiplyToRef(u,l),h.fromRotationMatrix(l),h.toEulerAnglesToRef(this.rotation)}return this},t.prototype.getDirection=function(e){var t=a.x.Zero();return this.getDirectionToRef(e,t),t},t.prototype.getDirectionToRef=function(e,t){return a.x.TransformNormalToRef(e,this.getWorldMatrix(),t),this},t.prototype.setDirection=function(e,t,i,r){void 0===t&&(t=0),void 0===i&&(i=0),void 0===r&&(r=0);var n=-Math.atan2(e.z,e.x)+Math.PI/2,o=Math.sqrt(e.x*e.x+e.z*e.z),s=-Math.atan2(e.y,o);return this.rotationQuaternion?a.q.RotationYawPitchRollToRef(n+t,s+i,r,this.rotationQuaternion):(this.rotation.x=s+i,this.rotation.y=n+t,this.rotation.z=r),this},t.prototype.setPivotPoint=function(e,t){void 0===t&&(t=a.s.LOCAL),0==this.getScene().getRenderId()&&this.computeWorldMatrix(!0);var i=this.getWorldMatrix();if(t==a.s.WORLD){var r=a.t.Matrix[0];i.invertToRef(r),e=a.x.TransformCoordinates(e,r)}return this.setPivotMatrix(a.j.Translation(-e.x,-e.y,-e.z),!0)},t.prototype.getPivotPoint=function(){var e=a.x.Zero();return this.getPivotPointToRef(e),e},t.prototype.getPivotPointToRef=function(e){return e.x=-this._pivotMatrix.m[12],e.y=-this._pivotMatrix.m[13],e.z=-this._pivotMatrix.m[14],this},t.prototype.getAbsolutePivotPoint=function(){var e=a.x.Zero();return this.getAbsolutePivotPointToRef(e),e},t.prototype.getAbsolutePivotPointToRef=function(e){return e.x=this._pivotMatrix.m[12],e.y=this._pivotMatrix.m[13],e.z=this._pivotMatrix.m[14],this.getPivotPointToRef(e),a.x.TransformCoordinatesToRef(e,this.getWorldMatrix(),e),this},t.prototype.setParent=function(e){if(!e&&!this.parent)return this;var t=a.t.Quaternion[0],i=a.t.Vector3[0],r=a.t.Vector3[1];if(e){var n=a.t.Matrix[0],o=a.t.Matrix[1];this.computeWorldMatrix(!0),e.computeWorldMatrix(!0),e.getWorldMatrix().invertToRef(o),this.getWorldMatrix().multiplyToRef(o,n),n.decompose(r,t,i)}else this.parent&&this.parent.computeWorldMatrix&&this.parent.computeWorldMatrix(!0),this.computeWorldMatrix(!0),this.getWorldMatrix().decompose(r,t,i);return this.rotationQuaternion?this.rotationQuaternion.copyFrom(t):t.toEulerAnglesToRef(this.rotation),this.scaling.copyFrom(r),this.position.copyFrom(i),this.parent=e,this},Object.defineProperty(t.prototype,"nonUniformScaling",{get:function(){return this._nonUniformScaling},enumerable:!0,configurable:!0}),t.prototype._updateNonUniformScalingState=function(e){return this._nonUniformScaling!==e&&(this._nonUniformScaling=e,!0)},t.prototype.attachToBone=function(e,t){return this._transformToBoneReferal=t,this.parent=e,e.getWorldMatrix().determinant()<0&&(this.scalingDeterminant*=-1),this},t.prototype.detachFromBone=function(){return this.parent?(this.parent.getWorldMatrix().determinant()<0&&(this.scalingDeterminant*=-1),this._transformToBoneReferal=null,this.parent=null,this):this},t.prototype.rotate=function(e,i,r){var n;if(e.normalize(),this.rotationQuaternion||(this.rotationQuaternion=this.rotation.toQuaternion(),this.rotation.setAll(0)),r&&r!==a.s.LOCAL){if(this.parent){var o=a.t.Matrix[0];this.parent.getWorldMatrix().invertToRef(o),e=a.x.TransformNormal(e,o)}(n=a.q.RotationAxisToRef(e,i,t._rotationAxisCache)).multiplyToRef(this.rotationQuaternion,this.rotationQuaternion)}else n=a.q.RotationAxisToRef(e,i,t._rotationAxisCache),this.rotationQuaternion.multiplyToRef(n,this.rotationQuaternion);return this},t.prototype.rotateAround=function(e,t,i){t.normalize(),this.rotationQuaternion||(this.rotationQuaternion=a.q.RotationYawPitchRoll(this.rotation.y,this.rotation.x,this.rotation.z),this.rotation.setAll(0));var r=a.t.Vector3[0],n=a.t.Vector3[1],o=a.t.Vector3[2],s=a.t.Quaternion[0],c=a.t.Matrix[0],l=a.t.Matrix[1],u=a.t.Matrix[2],h=a.t.Matrix[3];return e.subtractToRef(this.position,r),a.j.TranslationToRef(r.x,r.y,r.z,c),a.j.TranslationToRef(-r.x,-r.y,-r.z,l),a.j.RotationAxisToRef(t,i,u),l.multiplyToRef(u,h),h.multiplyToRef(c,h),h.decompose(n,s,o),this.position.addInPlace(o),s.multiplyToRef(this.rotationQuaternion,this.rotationQuaternion),this},t.prototype.translate=function(e,t,i){var r=e.scale(t);if(i&&i!==a.s.LOCAL)this.setAbsolutePosition(this.getAbsolutePosition().add(r));else{var n=this.getPositionExpressedInLocalSpace().add(r);this.setPositionWithLocalVector(n)}return this},t.prototype.addRotation=function(e,t,i){var r;this.rotationQuaternion?r=this.rotationQuaternion:(r=a.t.Quaternion[1],a.q.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,r));var n=a.t.Quaternion[0];return a.q.RotationYawPitchRollToRef(t,e,i,n),r.multiplyInPlace(n),this.rotationQuaternion||r.toEulerAnglesToRef(this.rotation),this},t.prototype.computeWorldMatrix=function(e){if(this._isWorldMatrixFrozen)return this._worldMatrix;if(!e&&this.isSynchronized())return this._currentRenderId=this.getScene().getRenderId(),this._worldMatrix;(this._updateCache(),this._cache.position.copyFrom(this.position),this._cache.scaling.copyFrom(this.scaling),this._cache.pivotMatrixUpdated=!1,this._cache.billboardMode=this.billboardMode,this._cache.infiniteDistance=this.infiniteDistance,this._currentRenderId=this.getScene().getRenderId(),this._childRenderId=this.getScene().getRenderId(),this._isDirty=!1,a.j.ScalingToRef(this.scaling.x*this.scalingDeterminant,this.scaling.y*this.scalingDeterminant,this.scaling.z*this.scalingDeterminant,a.t.Matrix[1]),this.rotationQuaternion)&&(this.rotation.length()&&(this.rotationQuaternion.multiplyInPlace(a.q.RotationYawPitchRoll(this.rotation.y,this.rotation.x,this.rotation.z)),this.rotation.copyFromFloats(0,0,0)));this.rotationQuaternion?(this.rotationQuaternion.toRotationMatrix(a.t.Matrix[0]),this._cache.rotationQuaternion.copyFrom(this.rotationQuaternion)):(a.j.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,a.t.Matrix[0]),this._cache.rotation.copyFrom(this.rotation));var i=this.getScene().activeCamera;if(this.infiniteDistance&&!this.parent&&i){var r=i.getWorldMatrix(),n=new a.x(r.m[12],r.m[13],r.m[14]);a.j.TranslationToRef(this.position.x+n.x,this.position.y+n.y,this.position.z+n.z,a.t.Matrix[2])}else a.j.TranslationToRef(this.position.x,this.position.y,this.position.z,a.t.Matrix[2]);if(this._pivotMatrix.multiplyToRef(a.t.Matrix[1],a.t.Matrix[4]),a.t.Matrix[4].multiplyToRef(a.t.Matrix[0],a.t.Matrix[5]),this.billboardMode!==t.BILLBOARDMODE_NONE&&i){if((this.billboardMode&t.BILLBOARDMODE_ALL)!==t.BILLBOARDMODE_ALL){var o=a.t.Vector3[3];this.parent&&this.parent.getWorldMatrix?this._transformToBoneReferal?(this.parent.getWorldMatrix().multiplyToRef(this._transformToBoneReferal.getWorldMatrix(),a.t.Matrix[6]),a.x.TransformCoordinatesToRef(this.position,a.t.Matrix[6],o)):a.x.TransformCoordinatesToRef(this.position,this.parent.getWorldMatrix(),o):o.copyFrom(this.position),o.subtractInPlace(i.globalPosition);var s=a.t.Vector3[4].copyFromFloats(0,0,0);(this.billboardMode&t.BILLBOARDMODE_X)===t.BILLBOARDMODE_X&&(s.x=Math.atan2(-o.y,o.z)),(this.billboardMode&t.BILLBOARDMODE_Y)===t.BILLBOARDMODE_Y&&(s.y=Math.atan2(o.x,o.z)),(this.billboardMode&t.BILLBOARDMODE_Z)===t.BILLBOARDMODE_Z&&(s.z=Math.atan2(o.y,o.x)),a.j.RotationYawPitchRollToRef(s.y,s.x,s.z,a.t.Matrix[0])}else a.t.Matrix[1].copyFrom(i.getViewMatrix()),a.t.Matrix[1].setTranslationFromFloats(0,0,0),a.t.Matrix[1].invertToRef(a.t.Matrix[0]);a.t.Matrix[1].copyFrom(a.t.Matrix[5]),a.t.Matrix[1].multiplyToRef(a.t.Matrix[0],a.t.Matrix[5])}return this._postMultiplyPivotMatrix&&a.t.Matrix[5].multiplyToRef(this._pivotMatrixInverse,a.t.Matrix[5]),a.t.Matrix[5].multiplyToRef(a.t.Matrix[2],this._localMatrix),this.parent&&this.parent.getWorldMatrix?(this.billboardMode!==t.BILLBOARDMODE_NONE?(this._transformToBoneReferal?(this.parent.getWorldMatrix().multiplyToRef(this._transformToBoneReferal.getWorldMatrix(),a.t.Matrix[6]),a.t.Matrix[5].copyFrom(a.t.Matrix[6])):a.t.Matrix[5].copyFrom(this.parent.getWorldMatrix()),this._localMatrix.getTranslationToRef(a.t.Vector3[5]),a.x.TransformCoordinatesToRef(a.t.Vector3[5],a.t.Matrix[5],a.t.Vector3[5]),this._worldMatrix.copyFrom(this._localMatrix),this._worldMatrix.setTranslation(a.t.Vector3[5])):this._transformToBoneReferal?(this._localMatrix.multiplyToRef(this.parent.getWorldMatrix(),a.t.Matrix[6]),a.t.Matrix[6].multiplyToRef(this._transformToBoneReferal.getWorldMatrix(),this._worldMatrix)):this._localMatrix.multiplyToRef(this.parent.getWorldMatrix(),this._worldMatrix),this._markSyncedWithParent()):this._worldMatrix.copyFrom(this._localMatrix),this.ignoreNonUniformScaling?this._updateNonUniformScalingState(!1):this.scaling.isNonUniform?this._updateNonUniformScalingState(!0):this.parent&&this.parent._nonUniformScaling?this._updateNonUniformScalingState(this.parent._nonUniformScaling):this._updateNonUniformScalingState(!1),this._afterComputeWorldMatrix(),this._absolutePosition.copyFromFloats(this._worldMatrix.m[12],this._worldMatrix.m[13],this._worldMatrix.m[14]),this.onAfterWorldMatrixUpdateObservable.notifyObservers(this),this._poseMatrix||(this._poseMatrix=a.j.Invert(this._worldMatrix)),this._worldMatrixDeterminant=this._worldMatrix.determinant(),this._worldMatrix},t.prototype._afterComputeWorldMatrix=function(){},t.prototype.registerAfterWorldMatrixUpdate=function(e){return this.onAfterWorldMatrixUpdateObservable.add(e),this},t.prototype.unregisterAfterWorldMatrixUpdate=function(e){return this.onAfterWorldMatrixUpdateObservable.removeCallback(e),this},t.prototype.getPositionInCameraSpace=function(e){return void 0===e&&(e=null),e||(e=this.getScene().activeCamera),a.x.TransformCoordinates(this.absolutePosition,e.getViewMatrix())},t.prototype.getDistanceToCamera=function(e){return void 0===e&&(e=null),e||(e=this.getScene().activeCamera),this.absolutePosition.subtract(e.position).length()},t.prototype.clone=function(e,i,r){var o=this,s=n.a.Clone(function(){return new t(e,o.getScene())},this);if(s.name=e,s.id=e,i&&(s.parent=i),!r)for(var a=this.getDescendants(!0),c=0;c<a.length;c++){var l=a[c];l.clone&&l.clone(e+"."+l.name,s)}return s},t.prototype.serialize=function(e){var t=n.a.Serialize(this,e);return t.type=this.getClassName(),this.parent&&(t.parentId=this.parent.id),o.a&&o.a.HasTags(this)&&(t.tags=o.a.GetTags(this)),t.localMatrix=this.getPivotMatrix().asArray(),t.isEnabled=this.isEnabled(),this.parent&&(t.parentId=this.parent.id),t},t.Parse=function(e,i,r){var s=n.a.Parse(function(){return new t(e.name,i)},e,i,r);return o.a&&o.a.AddTagsTo(s,e.tags),e.localMatrix?s.setPreTransformMatrix(a.j.FromArray(e.localMatrix)):e.pivotMatrix&&s.setPivotMatrix(a.j.FromArray(e.pivotMatrix)),s.setEnabled(e.isEnabled),e.parentId&&(s._waitingParentId=e.parentId),s},t.prototype.getChildTransformNodes=function(e,i){var r=[];return this._getDescendants(r,e,function(e){return(!i||i(e))&&e instanceof t}),r},t.prototype.dispose=function(t,i){if(void 0===i&&(i=!1),this.getScene().stopAnimation(this),this.getScene().removeTransformNode(this),this.onAfterWorldMatrixUpdateObservable.clear(),t)for(var r=0,n=this.getChildTransformNodes(!0);r<n.length;r++){var o=n[r];o.parent=null,o.computeWorldMatrix(!0)}e.prototype.dispose.call(this,t,i)},t.BILLBOARDMODE_NONE=0,t.BILLBOARDMODE_X=1,t.BILLBOARDMODE_Y=2,t.BILLBOARDMODE_Z=4,t.BILLBOARDMODE_ALL=7,t._lookAtVectorCache=new a.x(0,0,0),t._rotationAxisCache=new a.q,r.c([Object(n.n)("position")],t.prototype,"_position",void 0),r.c([Object(n.n)("rotation")],t.prototype,"_rotation",void 0),r.c([Object(n.k)("rotationQuaternion")],t.prototype,"_rotationQuaternion",void 0),r.c([Object(n.n)("scaling")],t.prototype,"_scaling",void 0),r.c([Object(n.c)()],t.prototype,"billboardMode",void 0),r.c([Object(n.c)()],t.prototype,"scalingDeterminant",void 0),r.c([Object(n.c)()],t.prototype,"infiniteDistance",void 0),r.c([Object(n.c)()],t.prototype,"ignoreNonUniformScaling",void 0),t}(i(24).a)},function(e,t,i){"use strict";i.d(t,"a",function(){return n}),i.d(t,"b",function(){return o}),i.d(t,"c",function(){return s});var r=i(1),n=function(){function e(){}return e.KEYDOWN=1,e.KEYUP=2,e}(),o=function(){return function(e,t){this.type=e,this.event=t}}(),s=function(e){function t(t,i){var r=e.call(this,t,i)||this;return r.type=t,r.event=i,r.skipOnPointerObservable=!1,r}return r.d(t,e),t}(o)},function(e,t,i){"use strict";i.d(t,"a",function(){return s});var r=i(0),n=i(10),o=i(40),s=function(){function e(e){void 0===e&&(e=o.a.DefaultUtilityLayer);var t=this;this.gizmoLayer=e,this.scaleRatio=1,this._tmpMatrix=new r.j,this._customMeshSet=!1,this.updateGizmoRotationToMatchAttachedMesh=!0,this.updateGizmoPositionToMatchAttachedMesh=!0,this._updateScale=!0,this._interactionsEnabled=!0,this._tempVector=new r.x,this._rootMesh=new n.a("gizmoRootNode",e.utilityLayerScene),this._beforeRenderObserver=this.gizmoLayer.utilityLayerScene.onBeforeRenderObservable.add(function(){t._update()}),this.attachedMesh=null}return Object.defineProperty(e.prototype,"attachedMesh",{get:function(){return this._attachedMesh},set:function(e){this._attachedMesh=e,this._rootMesh.setEnabled(!!e),this._attachedMeshChanged(e)},enumerable:!0,configurable:!0}),e.prototype.setCustomMesh=function(e){if(e.getScene()!=this.gizmoLayer.utilityLayerScene)throw"When setting a custom mesh on a gizmo, the custom meshes scene must be the same as the gizmos (eg. gizmo.gizmoLayer.utilityLayerScene)";this._rootMesh.getChildMeshes().forEach(function(e){e.dispose()}),e.parent=this._rootMesh,this._customMeshSet=!0},e.prototype._attachedMeshChanged=function(e){},e.prototype._update=function(){if(this.attachedMesh&&(this.updateGizmoRotationToMatchAttachedMesh?(this._rootMesh.rotationQuaternion||(this._rootMesh.rotationQuaternion=r.q.RotationYawPitchRoll(this._rootMesh.rotation.y,this._rootMesh.rotation.x,this._rootMesh.rotation.z)),this._tempVector.copyFrom(this.attachedMesh.scaling),this.attachedMesh.scaling.x<0&&(this.attachedMesh.scaling.x*=-1),this.attachedMesh.scaling.y<0&&(this.attachedMesh.scaling.y*=-1),this.attachedMesh.scaling.z<0&&(this.attachedMesh.scaling.z*=-1),this.attachedMesh.computeWorldMatrix().getRotationMatrixToRef(this._tmpMatrix),this.attachedMesh.scaling.copyFrom(this._tempVector),this.attachedMesh.computeWorldMatrix(),r.q.FromRotationMatrixToRef(this._tmpMatrix,this._rootMesh.rotationQuaternion)):this._rootMesh.rotationQuaternion&&this._rootMesh.rotationQuaternion.set(0,0,0,1),this.updateGizmoPositionToMatchAttachedMesh&&this._rootMesh.position.copyFrom(this.attachedMesh.absolutePosition),this._updateScale&&this.gizmoLayer.utilityLayerScene.activeCamera&&this.attachedMesh)){var e=this.gizmoLayer.utilityLayerScene.activeCamera.globalPosition;this.gizmoLayer.utilityLayerScene.activeCamera.devicePosition&&(e=this.gizmoLayer.utilityLayerScene.activeCamera.devicePosition),this._rootMesh.position.subtractToRef(e,this._tempVector);var t=this._tempVector.length()*this.scaleRatio;this._rootMesh.scaling.set(t,t,t)}},e.prototype.dispose=function(){this._rootMesh.dispose(),this._beforeRenderObserver&&this.gizmoLayer.utilityLayerScene.onBeforeRenderObservable.remove(this._beforeRenderObserver)},e}()},function(e,t,i){"use strict";i.d(t,"a",function(){return s});var r=i(0),n=i(10),o=i(13);o.a.CreateBox=function(e){for(var t=[new r.x(0,0,1),new r.x(0,0,-1),new r.x(1,0,0),new r.x(-1,0,0),new r.x(0,1,0),new r.x(0,-1,0)],i=[],n=[],s=[],a=[],c=e.width||e.size||1,l=e.height||e.size||1,u=e.depth||e.size||1,h=0===e.sideOrientation?0:e.sideOrientation||o.a.DEFAULTSIDE,d=e.faceUV||new Array(6),f=e.faceColors,p=[],_=0;_<6;_++)void 0===d[_]&&(d[_]=new r.y(0,0,1,1)),f&&void 0===f[_]&&(f[_]=new r.f(1,1,1,1));for(var g=new r.x(c/2,l/2,u/2),m=0;m<t.length;m++){var v=t[m],y=new r.x(v.y,v.z,v.x),b=r.x.Cross(v,y),T=n.length/3;i.push(T),i.push(T+1),i.push(T+2),i.push(T),i.push(T+2),i.push(T+3);var E=v.subtract(y).subtract(b).multiply(g);n.push(E.x,E.y,E.z),s.push(v.x,v.y,v.z),a.push(d[m].z,d[m].w),f&&p.push(f[m].r,f[m].g,f[m].b,f[m].a),E=v.subtract(y).add(b).multiply(g),n.push(E.x,E.y,E.z),s.push(v.x,v.y,v.z),a.push(d[m].x,d[m].w),f&&p.push(f[m].r,f[m].g,f[m].b,f[m].a),E=v.add(y).add(b).multiply(g),n.push(E.x,E.y,E.z),s.push(v.x,v.y,v.z),a.push(d[m].x,d[m].y),f&&p.push(f[m].r,f[m].g,f[m].b,f[m].a),E=v.add(y).subtract(b).multiply(g),n.push(E.x,E.y,E.z),s.push(v.x,v.y,v.z),a.push(d[m].z,d[m].y),f&&p.push(f[m].r,f[m].g,f[m].b,f[m].a)}o.a._ComputeSides(h,n,i,s,a,e.frontUVs,e.backUVs);var x=new o.a;if(x.indices=i,x.positions=n,x.normals=s,x.uvs=a,f){var A=h===o.a.DOUBLESIDE?p.concat(p):p;x.colors=A}return x},n.a.CreateBox=function(e,t,i,r,n){void 0===i&&(i=null);var o={size:t,sideOrientation:n,updatable:r};return s.CreateBox(e,o,i)};var s=function(){function e(){}return e.CreateBox=function(e,t,i){void 0===i&&(i=null);var r=new n.a(e,i);return t.sideOrientation=n.a._GetDefaultSideOrientation(t.sideOrientation),r._originalBuilderSideOrientation=t.sideOrientation,o.a.CreateBox(t).applyToMesh(r,t.updatable),r},e}()},function(e,t,i){"use strict";i.d(t,"a",function(){return u});var r=i(10),n=i(17),o=i(7),s=i(0),a=i(15),c=i(27),l=i(42),u=(i(73),function(){function e(e){this.maxDragAngle=0,this._useAlternatePickedPointAboveMaxDragAngle=!1,this.currentDraggingPointerID=-1,this.dragging=!1,this.dragDeltaRatio=.2,this.updateDragPlane=!0,this._debugMode=!1,this._moving=!1,this.onDragObservable=new o.c,this.onDragStartObservable=new o.c,this.onDragEndObservable=new o.c,this.moveAttached=!0,this.enabled=!0,this.detachCameraControls=!0,this.useObjectOrienationForDragging=!0,this.validateDrag=function(e){return!0},this._tmpVector=new s.x(0,0,0),this._alternatePickedPoint=new s.x(0,0,0),this._worldDragAxis=new s.x(0,0,0),this._targetPosition=new s.x(0,0,0),this._attachedElement=null,this._startDragRay=new c.a(new s.x,new s.x),this._lastPointerRay={},this._dragDelta=new s.x,this._pointA=new s.x(0,0,0),this._pointB=new s.x(0,0,0),this._pointC=new s.x(0,0,0),this._lineA=new s.x(0,0,0),this._lineB=new s.x(0,0,0),this._localAxis=new s.x(0,0,0),this._lookAt=new s.x(0,0,0),this._options=e||{};var t=0;if(this._options.dragAxis&&t++,this._options.dragPlaneNormal&&t++,t>1)throw"Multiple drag modes specified in dragBehavior options. Only one expected"}return Object.defineProperty(e.prototype,"name",{get:function(){return"PointerDrag"},enumerable:!0,configurable:!0}),e.prototype.init=function(){},e.prototype.attach=function(t){var i=this;this._scene=t.getScene(),this._attachedNode=t,e._planeScene||(this._debugMode?e._planeScene=this._scene:(e._planeScene=new n.a(this._scene.getEngine()),e._planeScene.detachControl(),this._scene.getEngine().scenes.pop(),this._scene.onDisposeObservable.addOnce(function(){e._planeScene.dispose(),e._planeScene=null}))),this._dragPlane=r.a.CreatePlane("pointerDragPlane",this._debugMode?1:1e4,e._planeScene,!1,r.a.DOUBLESIDE),this.lastDragPosition=new s.x(0,0,0);this._pointerObserver=this._scene.onPointerObservable.add(function(t,r){var n;if(i.enabled)if(t.type==a.a.POINTERDOWN)!i.dragging&&t.pickInfo&&t.pickInfo.hit&&t.pickInfo.pickedMesh&&t.pickInfo.pickedPoint&&t.pickInfo.ray&&(n=t.pickInfo.pickedMesh,i._attachedNode==n||n.isDescendantOf(i._attachedNode))&&i._startDrag(t.event.pointerId,t.pickInfo.ray,t.pickInfo.pickedPoint);else if(t.type==a.a.POINTERUP)i.currentDraggingPointerID==t.event.pointerId&&i.releaseDrag();else if(t.type==a.a.POINTERMOVE){var o=t.event.pointerId;i.currentDraggingPointerID===e._AnyMouseID&&o!==e._AnyMouseID&&"mouse"==t.event.pointerType&&(i._lastPointerRay[i.currentDraggingPointerID]&&(i._lastPointerRay[o]=i._lastPointerRay[i.currentDraggingPointerID],delete i._lastPointerRay[i.currentDraggingPointerID]),i.currentDraggingPointerID=o),i._lastPointerRay[o]||(i._lastPointerRay[o]=new c.a(new s.x,new s.x)),t.pickInfo&&t.pickInfo.ray&&(i._lastPointerRay[o].origin.copyFrom(t.pickInfo.ray.origin),i._lastPointerRay[o].direction.copyFrom(t.pickInfo.ray.direction),i.currentDraggingPointerID==o&&i.dragging&&i._moveDrag(t.pickInfo.ray))}}),this._beforeRenderObserver=this._scene.onBeforeRenderObservable.add(function(){i._moving&&i.moveAttached&&(l.a._RemoveAndStorePivotPoint(i._attachedNode),i._targetPosition.subtractToRef(i._attachedNode.absolutePosition,i._tmpVector),i._tmpVector.scaleInPlace(i.dragDeltaRatio),i._attachedNode.getAbsolutePosition().addToRef(i._tmpVector,i._tmpVector),i.validateDrag(i._tmpVector)&&i._attachedNode.setAbsolutePosition(i._tmpVector),l.a._RestorePivotPoint(i._attachedNode))})},e.prototype.releaseDrag=function(){this.dragging=!1,this.onDragEndObservable.notifyObservers({dragPlanePoint:this.lastDragPosition,pointerId:this.currentDraggingPointerID}),this.currentDraggingPointerID=-1,this._moving=!1,this.detachCameraControls&&this._attachedElement&&this._scene.activeCamera&&!this._scene.activeCamera.leftCamera&&this._scene.activeCamera.attachControl(this._attachedElement,!0)},e.prototype.startDrag=function(t,i,r){void 0===t&&(t=e._AnyMouseID),this._startDrag(t,i,r);var n=this._lastPointerRay[t];t===e._AnyMouseID&&(n=this._lastPointerRay[Object.keys(this._lastPointerRay)[0]]),n&&this._moveDrag(n)},e.prototype._startDrag=function(e,t,i){if(this._scene.activeCamera&&!this.dragging&&this._attachedNode){l.a._RemoveAndStorePivotPoint(this._attachedNode),t?(this._startDragRay.direction.copyFrom(t.direction),this._startDragRay.origin.copyFrom(t.origin)):(this._startDragRay.origin.copyFrom(this._scene.activeCamera.position),this._attachedNode.getWorldMatrix().getTranslationToRef(this._tmpVector),this._tmpVector.subtractToRef(this._scene.activeCamera.position,this._startDragRay.direction)),this._updateDragPlanePosition(this._startDragRay,i||this._tmpVector);var r=this._pickWithRayOnDragPlane(this._startDragRay);r&&(this.dragging=!0,this.currentDraggingPointerID=e,this.lastDragPosition.copyFrom(r),this.onDragStartObservable.notifyObservers({dragPlanePoint:r,pointerId:this.currentDraggingPointerID}),this._targetPosition.copyFrom(this._attachedNode.absolutePosition),this.detachCameraControls&&this._scene.activeCamera&&!this._scene.activeCamera.leftCamera&&(this._scene.activeCamera.inputs.attachedElement?(this._attachedElement=this._scene.activeCamera.inputs.attachedElement,this._scene.activeCamera.detachControl(this._scene.activeCamera.inputs.attachedElement)):this._attachedElement=null)),l.a._RestorePivotPoint(this._attachedNode)}},e.prototype._moveDrag=function(e){this._moving=!0;var t=this._pickWithRayOnDragPlane(e);if(t){this.updateDragPlane&&this._updateDragPlanePosition(e,t);var i=0;this._options.dragAxis?(s.x.TransformCoordinatesToRef(this._options.dragAxis,this._attachedNode.getWorldMatrix().getRotationMatrix(),this._worldDragAxis),t.subtractToRef(this.lastDragPosition,this._tmpVector),i=s.x.Dot(this._tmpVector,this._worldDragAxis),this._worldDragAxis.scaleToRef(i,this._dragDelta)):(i=this._dragDelta.length(),t.subtractToRef(this.lastDragPosition,this._dragDelta)),this._targetPosition.addInPlace(this._dragDelta),this.onDragObservable.notifyObservers({dragDistance:i,delta:this._dragDelta,dragPlanePoint:t,dragPlaneNormal:this._dragPlane.forward,pointerId:this.currentDraggingPointerID}),this.lastDragPosition.copyFrom(t)}},e.prototype._pickWithRayOnDragPlane=function(t){var i=this;if(!t)return null;var r=Math.acos(s.x.Dot(this._dragPlane.forward,t.direction));if(r>Math.PI/2&&(r=Math.PI-r),this.maxDragAngle>0&&r>this.maxDragAngle){if(this._useAlternatePickedPointAboveMaxDragAngle){this._tmpVector.copyFrom(t.direction),this._attachedNode.absolutePosition.subtractToRef(t.origin,this._alternatePickedPoint),this._alternatePickedPoint.normalize(),this._alternatePickedPoint.scaleInPlace(-2*s.x.Dot(this._alternatePickedPoint,this._tmpVector)),this._tmpVector.addInPlace(this._alternatePickedPoint);var n=s.x.Dot(this._dragPlane.forward,this._tmpVector);return this._dragPlane.forward.scaleToRef(-n,this._alternatePickedPoint),this._alternatePickedPoint.addInPlace(this._tmpVector),this._alternatePickedPoint.addInPlace(this._attachedNode.absolutePosition),this._alternatePickedPoint}return null}var o=e._planeScene.pickWithRay(t,function(e){return e==i._dragPlane});return o&&o.hit&&o.pickedMesh&&o.pickedPoint?o.pickedPoint:null},e.prototype._updateDragPlanePosition=function(e,t){this._pointA.copyFrom(t),this._options.dragAxis?(this.useObjectOrienationForDragging?s.x.TransformCoordinatesToRef(this._options.dragAxis,this._attachedNode.getWorldMatrix().getRotationMatrix(),this._localAxis):this._localAxis.copyFrom(this._options.dragAxis),this._pointA.addToRef(this._localAxis,this._pointB),e.origin.subtractToRef(this._pointA,this._pointC),this._pointA.addToRef(this._pointC.normalize(),this._pointC),this._pointB.subtractToRef(this._pointA,this._lineA),this._pointC.subtractToRef(this._pointA,this._lineB),s.x.CrossToRef(this._lineA,this._lineB,this._lookAt),s.x.CrossToRef(this._lineA,this._lookAt,this._lookAt),this._lookAt.normalize(),this._dragPlane.position.copyFrom(this._pointA),this._pointA.addToRef(this._lookAt,this._lookAt),this._dragPlane.lookAt(this._lookAt)):this._options.dragPlaneNormal?(this.useObjectOrienationForDragging?s.x.TransformCoordinatesToRef(this._options.dragPlaneNormal,this._attachedNode.getWorldMatrix().getRotationMatrix(),this._localAxis):this._localAxis.copyFrom(this._options.dragPlaneNormal),this._dragPlane.position.copyFrom(this._pointA),this._pointA.addToRef(this._localAxis,this._lookAt),this._dragPlane.lookAt(this._lookAt)):(this._dragPlane.position.copyFrom(this._pointA),this._dragPlane.lookAt(e.origin)),this._dragPlane.computeWorldMatrix(!0)},e.prototype.detach=function(){this._pointerObserver&&this._scene.onPointerObservable.remove(this._pointerObserver),this._beforeRenderObserver&&this._scene.onBeforeRenderObservable.remove(this._beforeRenderObserver)},e._AnyMouseID=-2,e}())},function(e,t,i){"use strict";i.d(t,"a",function(){return o});var r=i(0),n=i(4),o=function(){function e(){this.hit=!1,this.distance=0,this.pickedPoint=null,this.pickedMesh=null,this.bu=0,this.bv=0,this.faceId=-1,this.subMeshId=0,this.pickedSprite=null,this.originMesh=null,this.ray=null}return e.prototype.getNormal=function(e,t){if(void 0===e&&(e=!1),void 0===t&&(t=!0),!this.pickedMesh||!this.pickedMesh.isVerticesDataPresent(n.b.NormalKind))return null;var i,o=this.pickedMesh.getIndices();if(!o)return null;if(t){var s=this.pickedMesh.getVerticesData(n.b.NormalKind),a=r.x.FromArray(s,3*o[3*this.faceId]),c=r.x.FromArray(s,3*o[3*this.faceId+1]),l=r.x.FromArray(s,3*o[3*this.faceId+2]);a=a.scale(this.bu),c=c.scale(this.bv),l=l.scale(1-this.bu-this.bv),i=new r.x(a.x+c.x+l.x,a.y+c.y+l.y,a.z+c.z+l.z)}else{var u=this.pickedMesh.getVerticesData(n.b.PositionKind),h=r.x.FromArray(u,3*o[3*this.faceId]),d=r.x.FromArray(u,3*o[3*this.faceId+1]),f=r.x.FromArray(u,3*o[3*this.faceId+2]),p=h.subtract(d),_=f.subtract(d);i=r.x.Cross(p,_)}if(e){var g=this.pickedMesh.getWorldMatrix();this.pickedMesh.nonUniformScaling&&(r.t.Matrix[0].copyFrom(g),(g=r.t.Matrix[0]).setTranslationFromFloats(0,0,0),g.invert(),g.transposeToRef(r.t.Matrix[1]),g=r.t.Matrix[1]),i=r.x.TransformNormal(i,g)}return i.normalize(),i},e.prototype.getTextureCoordinates=function(){if(!this.pickedMesh||!this.pickedMesh.isVerticesDataPresent(n.b.UVKind))return null;var e=this.pickedMesh.getIndices();if(!e)return null;var t=this.pickedMesh.getVerticesData(n.b.UVKind);if(!t)return null;var i=r.w.FromArray(t,2*e[3*this.faceId]),o=r.w.FromArray(t,2*e[3*this.faceId+1]),s=r.w.FromArray(t,2*e[3*this.faceId+2]);return i=i.scale(1-this.bu-this.bv),o=o.scale(this.bu),s=s.scale(this.bv),new r.w(i.x+o.x+s.x,i.y+o.y+s.y)},e}()},function(e,t,i){"use strict";i.d(t,"a",function(){return n});var r=i(3),n=function(){function e(){}return Object.defineProperty(e,"ForceFullSceneLoadingForIncremental",{get:function(){return e._ForceFullSceneLoadingForIncremental},set:function(t){e._ForceFullSceneLoadingForIncremental=t},enumerable:!0,configurable:!0}),Object.defineProperty(e,"ShowLoadingScreen",{get:function(){return e._ShowLoadingScreen},set:function(t){e._ShowLoadingScreen=t},enumerable:!0,configurable:!0}),Object.defineProperty(e,"loggingLevel",{get:function(){return e._loggingLevel},set:function(t){e._loggingLevel=t},enumerable:!0,configurable:!0}),Object.defineProperty(e,"CleanBoneMatrixWeights",{get:function(){return e._CleanBoneMatrixWeights},set:function(t){e._CleanBoneMatrixWeights=t},enumerable:!0,configurable:!0}),e._ForceFullSceneLoadingForIncremental=!1,e._ShowLoadingScreen=!0,e._CleanBoneMatrixWeights=!1,e._loggingLevel=r.a.SCENELOADER_NO_LOGGING,e}()},function(e,t,i){"use strict";var r="helperFunctions",n="const float PI=3.1415926535897932384626433832795;\nconst float LinearEncodePowerApprox=2.2;\nconst float GammaEncodePowerApprox=1.0/LinearEncodePowerApprox;\nconst vec3 LuminanceEncodeApprox=vec3(0.2126,0.7152,0.0722);\nmat3 transposeMat3(mat3 inMatrix) {\nvec3 i0=inMatrix[0];\nvec3 i1=inMatrix[1];\nvec3 i2=inMatrix[2];\nmat3 outMatrix=mat3(\nvec3(i0.x,i1.x,i2.x),\nvec3(i0.y,i1.y,i2.y),\nvec3(i0.z,i1.z,i2.z)\n);\nreturn outMatrix;\n}\n\nmat3 inverseMat3(mat3 inMatrix) {\nfloat a00=inMatrix[0][0],a01=inMatrix[0][1],a02=inMatrix[0][2];\nfloat a10=inMatrix[1][0],a11=inMatrix[1][1],a12=inMatrix[1][2];\nfloat a20=inMatrix[2][0],a21=inMatrix[2][1],a22=inMatrix[2][2];\nfloat b01=a22*a11-a12*a21;\nfloat b11=-a22*a10+a12*a20;\nfloat b21=a21*a10-a11*a20;\nfloat det=a00*b01+a01*b11+a02*b21;\nreturn mat3(b01,(-a22*a01+a02*a21),(a12*a01-a02*a11),\nb11,(a22*a00-a02*a20),(-a12*a00+a02*a10),\nb21,(-a21*a00+a01*a20),(a11*a00-a01*a10))/det;\n}\nfloat computeFallOff(float value,vec2 clipSpace,float frustumEdgeFalloff)\n{\nfloat mask=smoothstep(1.0-frustumEdgeFalloff,1.0,clamp(dot(clipSpace,clipSpace),0.,1.));\nreturn mix(value,1.0,mask);\n}\nvec3 applyEaseInOut(vec3 x){\nreturn x*x*(3.0-2.0*x);\n}\nvec3 toLinearSpace(vec3 color)\n{\nreturn pow(color,vec3(LinearEncodePowerApprox));\n}\nvec3 toGammaSpace(vec3 color)\n{\nreturn pow(color,vec3(GammaEncodePowerApprox));\n}\nfloat square(float value)\n{\nreturn value*value;\n}\nfloat getLuminance(vec3 color)\n{\nreturn clamp(dot(color,LuminanceEncodeApprox),0.,1.);\n}\n\nfloat getRand(vec2 seed) {\nreturn fract(sin(dot(seed.xy ,vec2(12.9898,78.233)))*43758.5453);\n}\nfloat dither(vec2 seed,float varianceAmount) {\nfloat rand=getRand(seed);\nfloat dither=mix(-varianceAmount/255.0,varianceAmount/255.0,rand);\nreturn dither;\n}\n\nconst float rgbdMaxRange=255.0;\nvec4 toRGBD(vec3 color) {\nfloat maxRGB=max(0.0000001,max(color.r,max(color.g,color.b)));\nfloat D=max(rgbdMaxRange/maxRGB,1.);\nD=clamp(floor(D)/255.0,0.,1.);\n\nvec3 rgb=color.rgb*D;\n\nrgb=toGammaSpace(rgb);\nreturn vec4(rgb,D);\n}\nvec3 fromRGBD(vec4 rgbd) {\n\nrgbd.rgb=toLinearSpace(rgbd.rgb);\n\nreturn rgbd.rgb/rgbd.a;\n}";i(5).a.IncludesShadersStore[r]=n},function(e,t,i){"use strict";i.d(t,"a",function(){return s});var r=i(0),n=i(10),o=i(13);o.a.CreateSphere=function(e){for(var t=e.segments||32,i=e.diameterX||e.diameter||1,n=e.diameterY||e.diameter||1,s=e.diameterZ||e.diameter||1,a=e.arc&&(e.arc<=0||e.arc>1)?1:e.arc||1,c=e.slice&&e.slice<=0?1:e.slice||1,l=0===e.sideOrientation?0:e.sideOrientation||o.a.DEFAULTSIDE,u=new r.x(i/2,n/2,s/2),h=2+t,d=2*h,f=[],p=[],_=[],g=[],m=0;m<=h;m++){for(var v=m/h,y=v*Math.PI*c,b=0;b<=d;b++){var T=b/d,E=T*Math.PI*2*a,x=r.j.RotationZ(-y),A=r.j.RotationY(E),P=r.x.TransformCoordinates(r.x.Up(),x),R=r.x.TransformCoordinates(P,A),S=R.multiply(u),C=R.divide(u).normalize();p.push(S.x,S.y,S.z),_.push(C.x,C.y,C.z),g.push(T,v)}if(m>0)for(var M=p.length/3,O=M-2*(d+1);O+d+2<M;O++)f.push(O),f.push(O+1),f.push(O+d+1),f.push(O+d+1),f.push(O+1),f.push(O+d+2)}o.a._ComputeSides(l,p,f,_,g,e.frontUVs,e.backUVs);var I=new o.a;return I.indices=f,I.positions=p,I.normals=_,I.uvs=g,I},n.a.CreateSphere=function(e,t,i,r,n,o){var a={segments:t,diameterX:i,diameterY:i,diameterZ:i,sideOrientation:o,updatable:n};return s.CreateSphere(e,a,r)};var s=function(){function e(){}return e.CreateSphere=function(e,t,i){var r=new n.a(e,i);return t.sideOrientation=n.a._GetDefaultSideOrientation(t.sideOrientation),r._originalBuilderSideOrientation=t.sideOrientation,o.a.CreateSphere(t).applyToMesh(r,t.updatable),r},e}()},function(e,t,i){"use strict";i.d(t,"a",function(){return d});var r=i(0),n=i(13),o=i(4),s=i(45),a=i(52),c=i(41),l=i(3),u=i(9),h=i(26),d=function(){function e(e,t,i,r,n){void 0===r&&(r=!1),void 0===n&&(n=null),this.delayLoadState=l.a.DELAYLOADSTATE_NONE,this._totalVertices=0,this._isDisposed=!1,this._indexBufferIsUpdatable=!1,this.id=e,this.uniqueId=t.getUniqueId(),this._engine=t.getEngine(),this._meshes=[],this._scene=t,this._vertexBuffers={},this._indices=[],this._updatable=r,i?this.setAllVerticesData(i,r):(this._totalVertices=0,this._indices=[]),this._engine.getCaps().vertexArrayObject&&(this._vertexArrayObjects={}),n&&(this.applyToMesh(n),n.computeWorldMatrix(!0))}return Object.defineProperty(e.prototype,"boundingBias",{get:function(){return this._boundingBias},set:function(e){this._boundingBias?this._boundingBias.copyFrom(e):this._boundingBias=e.clone(),this._updateBoundingInfo(!0,null)},enumerable:!0,configurable:!0}),e.CreateGeometryForMesh=function(t){var i=new e(e.RandomId(),t.getScene());return i.applyToMesh(t),i},Object.defineProperty(e.prototype,"extend",{get:function(){return this._extend},enumerable:!0,configurable:!0}),e.prototype.getScene=function(){return this._scene},e.prototype.getEngine=function(){return this._engine},e.prototype.isReady=function(){return this.delayLoadState===l.a.DELAYLOADSTATE_LOADED||this.delayLoadState===l.a.DELAYLOADSTATE_NONE},Object.defineProperty(e.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}),e.prototype._rebuild=function(){for(var e in this._vertexArrayObjects&&(this._vertexArrayObjects={}),0!==this._meshes.length&&this._indices&&(this._indexBuffer=this._engine.createIndexBuffer(this._indices)),this._vertexBuffers){this._vertexBuffers[e]._rebuild()}},e.prototype.setAllVerticesData=function(e,t){e.applyToGeometry(this,t),this.notifyUpdate()},e.prototype.setVerticesData=function(e,t,i,r){void 0===i&&(i=!1);var n=new o.b(this._engine,t,e,i,0===this._meshes.length,r);this.setVerticesBuffer(n)},e.prototype.removeVerticesData=function(e){this._vertexBuffers[e]&&(this._vertexBuffers[e].dispose(),delete this._vertexBuffers[e])},e.prototype.setVerticesBuffer=function(e,t){void 0===t&&(t=null);var i=e.getKind();if(this._vertexBuffers[i]&&this._vertexBuffers[i].dispose(),this._vertexBuffers[i]=e,i===o.b.PositionKind){var r=e.getData();null!=t?this._totalVertices=t:null!=r&&(this._totalVertices=r.length/(e.byteStride/4)),this._updateExtend(r),this._resetPointsArrayCache();for(var n=this._meshes,s=n.length,a=0;a<s;a++){var l=n[a];l._boundingInfo=new c.a(this._extend.minimum,this._extend.maximum),l._createGlobalSubMesh(!1),l.computeWorldMatrix(!0)}}this.notifyUpdate(i),this._vertexArrayObjects&&(this._disposeVertexArrayObjects(),this._vertexArrayObjects={})},e.prototype.updateVerticesDataDirectly=function(e,t,i,r){void 0===r&&(r=!1);var n=this.getVertexBuffer(e);n&&(n.updateDirectly(t,i,r),this.notifyUpdate(e))},e.prototype.updateVerticesData=function(e,t,i){void 0===i&&(i=!1);var r=this.getVertexBuffer(e);r&&(r.update(t),e===o.b.PositionKind&&this._updateBoundingInfo(i,t),this.notifyUpdate(e))},e.prototype._updateBoundingInfo=function(e,t){if(e&&this._updateExtend(t),this._resetPointsArrayCache(),e)for(var i=0,r=this._meshes;i<r.length;i++){var n=r[i];n._boundingInfo?n._boundingInfo.reConstruct(this._extend.minimum,this._extend.maximum):n._boundingInfo=new c.a(this._extend.minimum,this._extend.maximum);for(var o=0,s=n.subMeshes;o<s.length;o++){s[o].refreshBoundingInfo()}}},e.prototype._bind=function(e,t){if(e){void 0===t&&(t=this._indexBuffer);var i=this.getVertexBuffers();i&&(t==this._indexBuffer&&this._vertexArrayObjects?(this._vertexArrayObjects[e.key]||(this._vertexArrayObjects[e.key]=this._engine.recordVertexArrayObject(i,t,e)),this._engine.bindVertexArrayObject(this._vertexArrayObjects[e.key],t)):this._engine.bindBuffers(i,t,e))}},e.prototype.getTotalVertices=function(){return this.isReady()?this._totalVertices:0},e.prototype.getVerticesData=function(e,t,i){var r=this.getVertexBuffer(e);if(!r)return null;var n=r.getData();if(!n)return null;var s=r.getSize()*o.b.GetTypeByteLength(r.type),a=this._totalVertices*r.getSize();if(r.type!==o.b.FLOAT||r.byteStride!==s){var c=[];return r.forEach(a,function(e){return c.push(e)}),c}if(!(n instanceof Array||n instanceof Float32Array)||0!==r.byteOffset||n.length!==a){if(n instanceof Array){var l=r.byteOffset/4;return u.h.Slice(n,l,l+a)}if(n instanceof ArrayBuffer)return new Float32Array(n,r.byteOffset,a);l=n.byteOffset+r.byteOffset;if(i||t&&1!==this._meshes.length){var h=new Float32Array(a),d=new Float32Array(n.buffer,l,a);return h.set(d),h}return new Float32Array(n.buffer,l,a)}return i||t&&1!==this._meshes.length?u.h.Slice(n):n},e.prototype.isVertexBufferUpdatable=function(e){var t=this._vertexBuffers[e];return!!t&&t.isUpdatable()},e.prototype.getVertexBuffer=function(e){return this.isReady()?this._vertexBuffers[e]:null},e.prototype.getVertexBuffers=function(){return this.isReady()?this._vertexBuffers:null},e.prototype.isVerticesDataPresent=function(e){return this._vertexBuffers?void 0!==this._vertexBuffers[e]:!!this._delayInfo&&-1!==this._delayInfo.indexOf(e)},e.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},e.prototype.updateIndices=function(e,t){if(this._indexBuffer)if(this._indexBufferIsUpdatable){var i=e.length!==this._indices.length;if(this._indices=e,this._engine.updateDynamicIndexBuffer(this._indexBuffer,e,t),i)for(var r=0,n=this._meshes;r<n.length;r++){n[r]._createGlobalSubMesh(!0)}}else this.setIndices(e,null,!0)},e.prototype.setIndices=function(e,t,i){void 0===t&&(t=null),void 0===i&&(i=!1),this._indexBuffer&&this._engine._releaseBuffer(this._indexBuffer),this._disposeVertexArrayObjects(),this._indices=e,this._indexBufferIsUpdatable=i,0!==this._meshes.length&&this._indices&&(this._indexBuffer=this._engine.createIndexBuffer(this._indices,i)),null!=t&&(this._totalVertices=t);for(var r=0,n=this._meshes;r<n.length;r++){n[r]._createGlobalSubMesh(!0)}this.notifyUpdate()},e.prototype.getTotalIndices=function(){return this.isReady()?this._indices.length:0},e.prototype.getIndices=function(e,t){if(!this.isReady())return null;var i=this._indices;if(t||e&&1!==this._meshes.length){for(var r=i.length,n=[],o=0;o<r;o++)n.push(i[o]);return n}return i},e.prototype.getIndexBuffer=function(){return this.isReady()?this._indexBuffer:null},e.prototype._releaseVertexArrayObject=function(e){void 0===e&&(e=null),e&&this._vertexArrayObjects&&this._vertexArrayObjects[e.key]&&(this._engine.releaseVertexArrayObject(this._vertexArrayObjects[e.key]),delete this._vertexArrayObjects[e.key])},e.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())},e.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}},e.prototype._updateExtend=function(e){void 0===e&&(e=null),e||(e=this.getVerticesData(o.b.PositionKind)),this._extend=u.h.ExtractMinAndMax(e,0,this._totalVertices,this.boundingBias,3)},e.prototype._applyToMesh=function(e){var t=this._meshes.length;for(var i in this._vertexBuffers){1===t&&this._vertexBuffers[i].create();var r=this._vertexBuffers[i].getBuffer();r&&(r.references=t),i===o.b.PositionKind&&(this._extend||this._updateExtend(),e._boundingInfo=new c.a(this._extend.minimum,this._extend.maximum),e._createGlobalSubMesh(!1),e._updateBoundingInfo())}1===t&&this._indices&&this._indices.length>0&&(this._indexBuffer=this._engine.createIndexBuffer(this._indices)),this._indexBuffer&&(this._indexBuffer.references=t),e._syncGeometryWithMorphTargetManager(),e.synchronizeInstances()},e.prototype.notifyUpdate=function(e){this.onGeometryUpdated&&this.onGeometryUpdated(this,e);for(var t=0,i=this._meshes;t<i.length;t++){i[t]._markSubMeshesAsAttributesDirty()}},e.prototype.load=function(e,t){this.delayLoadState!==l.a.DELAYLOADSTATE_LOADING&&(this.isReady()?t&&t():(this.delayLoadState=l.a.DELAYLOADSTATE_LOADING,this._queueLoad(e,t)))},e.prototype._queueLoad=function(e,t){var i=this;this.delayLoadingFile&&(e._addPendingData(this),e._loadFile(this.delayLoadingFile,function(r){if(i._delayLoadingFunction){i._delayLoadingFunction(JSON.parse(r),i),i.delayLoadState=l.a.DELAYLOADSTATE_LOADED,i._delayInfo=[],e._removePendingData(i);for(var n=i._meshes,o=n.length,s=0;s<o;s++)i._applyToMesh(n[s]);t&&t()}},void 0,!0))},e.prototype.toLeftHanded=function(){var e=this.getIndices(!1);if(null!=e&&e.length>0){for(var t=0;t<e.length;t+=3){var i=e[t+0];e[t+0]=e[t+2],e[t+2]=i}this.setIndices(e)}var r=this.getVerticesData(o.b.PositionKind,!1);if(null!=r&&r.length>0){for(t=0;t<r.length;t+=3)r[t+2]=-r[t+2];this.setVerticesData(o.b.PositionKind,r,!1)}var n=this.getVerticesData(o.b.NormalKind,!1);if(null!=n&&n.length>0){for(t=0;t<n.length;t+=3)n[t+2]=-n[t+2];this.setVerticesData(o.b.NormalKind,n,!1)}},e.prototype._resetPointsArrayCache=function(){this._positions=null},e.prototype._generatePointsArray=function(){if(this._positions)return!0;var e=this.getVerticesData(o.b.PositionKind);if(!e||0===e.length)return!1;this._positions=[];for(var t=0;t<e.length;t+=3)this._positions.push(r.x.FromArray(e,t));return!0},e.prototype.isDisposed=function(){return this._isDisposed},e.prototype._disposeVertexArrayObjects=function(){if(this._vertexArrayObjects){for(var e in this._vertexArrayObjects)this._engine.releaseVertexArrayObject(this._vertexArrayObjects[e]);this._vertexArrayObjects={}}},e.prototype.dispose=function(){var e,t=this._meshes,i=t.length;for(e=0;e<i;e++)this.releaseForMesh(t[e]);for(var r in this._meshes=[],this._disposeVertexArrayObjects(),this._vertexBuffers)this._vertexBuffers[r].dispose();this._vertexBuffers={},this._totalVertices=0,this._indexBuffer&&this._engine._releaseBuffer(this._indexBuffer),this._indexBuffer=null,this._indices=[],this.delayLoadState=l.a.DELAYLOADSTATE_NONE,this.delayLoadingFile=null,this._delayLoadingFunction=null,this._delayInfo=[],this._boundingInfo=null,this._scene.removeGeometry(this),this._isDisposed=!0},e.prototype.copy=function(t){var i=new n.a;i.indices=[];var r=this.getIndices();if(r)for(var o=0;o<r.length;o++)i.indices.push(r[o]);var s,a=!1,l=!1;for(s in this._vertexBuffers){var u=this.getVerticesData(s);if(u&&(u instanceof Float32Array?i.set(new Float32Array(u),s):i.set(u.slice(0),s),!l)){var h=this.getVertexBuffer(s);h&&(l=!(a=h.isUpdatable()))}}var d=new e(t,this._scene,i,a);for(s in d.delayLoadState=this.delayLoadState,d.delayLoadingFile=this.delayLoadingFile,d._delayLoadingFunction=this._delayLoadingFunction,this._delayInfo)d._delayInfo=d._delayInfo||[],d._delayInfo.push(s);return d._boundingInfo=new c.a(this._extend.minimum,this._extend.maximum),d},e.prototype.serialize=function(){var e={};return e.id=this.id,e.updatable=this._updatable,h.a&&h.a.HasTags(this)&&(e.tags=h.a.GetTags(this)),e},e.prototype.toNumberArray=function(e){return Array.isArray(e)?e:Array.prototype.slice.call(e)},e.prototype.serializeVerticeData=function(){var e=this.serialize();return this.isVerticesDataPresent(o.b.PositionKind)&&(e.positions=this.toNumberArray(this.getVerticesData(o.b.PositionKind)),this.isVertexBufferUpdatable(o.b.PositionKind)&&(e.positions._updatable=!0)),this.isVerticesDataPresent(o.b.NormalKind)&&(e.normals=this.toNumberArray(this.getVerticesData(o.b.NormalKind)),this.isVertexBufferUpdatable(o.b.NormalKind)&&(e.normals._updatable=!0)),this.isVerticesDataPresent(o.b.TangentKind)&&(e.tangets=this.toNumberArray(this.getVerticesData(o.b.TangentKind)),this.isVertexBufferUpdatable(o.b.TangentKind)&&(e.tangets._updatable=!0)),this.isVerticesDataPresent(o.b.UVKind)&&(e.uvs=this.toNumberArray(this.getVerticesData(o.b.UVKind)),this.isVertexBufferUpdatable(o.b.UVKind)&&(e.uvs._updatable=!0)),this.isVerticesDataPresent(o.b.UV2Kind)&&(e.uv2s=this.toNumberArray(this.getVerticesData(o.b.UV2Kind)),this.isVertexBufferUpdatable(o.b.UV2Kind)&&(e.uv2s._updatable=!0)),this.isVerticesDataPresent(o.b.UV3Kind)&&(e.uv3s=this.toNumberArray(this.getVerticesData(o.b.UV3Kind)),this.isVertexBufferUpdatable(o.b.UV3Kind)&&(e.uv3s._updatable=!0)),this.isVerticesDataPresent(o.b.UV4Kind)&&(e.uv4s=this.toNumberArray(this.getVerticesData(o.b.UV4Kind)),this.isVertexBufferUpdatable(o.b.UV4Kind)&&(e.uv4s._updatable=!0)),this.isVerticesDataPresent(o.b.UV5Kind)&&(e.uv5s=this.toNumberArray(this.getVerticesData(o.b.UV5Kind)),this.isVertexBufferUpdatable(o.b.UV5Kind)&&(e.uv5s._updatable=!0)),this.isVerticesDataPresent(o.b.UV6Kind)&&(e.uv6s=this.toNumberArray(this.getVerticesData(o.b.UV6Kind)),this.isVertexBufferUpdatable(o.b.UV6Kind)&&(e.uv6s._updatable=!0)),this.isVerticesDataPresent(o.b.ColorKind)&&(e.colors=this.toNumberArray(this.getVerticesData(o.b.ColorKind)),this.isVertexBufferUpdatable(o.b.ColorKind)&&(e.colors._updatable=!0)),this.isVerticesDataPresent(o.b.MatricesIndicesKind)&&(e.matricesIndices=this.toNumberArray(this.getVerticesData(o.b.MatricesIndicesKind)),e.matricesIndices._isExpanded=!0,this.isVertexBufferUpdatable(o.b.MatricesIndicesKind)&&(e.matricesIndices._updatable=!0)),this.isVerticesDataPresent(o.b.MatricesWeightsKind)&&(e.matricesWeights=this.toNumberArray(this.getVerticesData(o.b.MatricesWeightsKind)),this.isVertexBufferUpdatable(o.b.MatricesWeightsKind)&&(e.matricesWeights._updatable=!0)),e.indices=this.toNumberArray(this.getIndices()),e},e.ExtractFromMesh=function(e,t){var i=e._geometry;return i?i.copy(t):null},e.RandomId=function(){return u.h.RandomId()},e._ImportGeometry=function(t,i){var n=i.getScene(),a=t.geometryId;if(a){var c=n.getGeometryByID(a);c&&c.applyToMesh(i)}else if(t instanceof ArrayBuffer){var l=i._binaryInfo;if(l.positionsAttrDesc&&l.positionsAttrDesc.count>0){var u=new Float32Array(t,l.positionsAttrDesc.offset,l.positionsAttrDesc.count);i.setVerticesData(o.b.PositionKind,u,!1)}if(l.normalsAttrDesc&&l.normalsAttrDesc.count>0){var h=new Float32Array(t,l.normalsAttrDesc.offset,l.normalsAttrDesc.count);i.setVerticesData(o.b.NormalKind,h,!1)}if(l.tangetsAttrDesc&&l.tangetsAttrDesc.count>0){var d=new Float32Array(t,l.tangetsAttrDesc.offset,l.tangetsAttrDesc.count);i.setVerticesData(o.b.TangentKind,d,!1)}if(l.uvsAttrDesc&&l.uvsAttrDesc.count>0){var f=new Float32Array(t,l.uvsAttrDesc.offset,l.uvsAttrDesc.count);i.setVerticesData(o.b.UVKind,f,!1)}if(l.uvs2AttrDesc&&l.uvs2AttrDesc.count>0){var p=new Float32Array(t,l.uvs2AttrDesc.offset,l.uvs2AttrDesc.count);i.setVerticesData(o.b.UV2Kind,p,!1)}if(l.uvs3AttrDesc&&l.uvs3AttrDesc.count>0){var _=new Float32Array(t,l.uvs3AttrDesc.offset,l.uvs3AttrDesc.count);i.setVerticesData(o.b.UV3Kind,_,!1)}if(l.uvs4AttrDesc&&l.uvs4AttrDesc.count>0){var g=new Float32Array(t,l.uvs4AttrDesc.offset,l.uvs4AttrDesc.count);i.setVerticesData(o.b.UV4Kind,g,!1)}if(l.uvs5AttrDesc&&l.uvs5AttrDesc.count>0){var m=new Float32Array(t,l.uvs5AttrDesc.offset,l.uvs5AttrDesc.count);i.setVerticesData(o.b.UV5Kind,m,!1)}if(l.uvs6AttrDesc&&l.uvs6AttrDesc.count>0){var v=new Float32Array(t,l.uvs6AttrDesc.offset,l.uvs6AttrDesc.count);i.setVerticesData(o.b.UV6Kind,v,!1)}if(l.colorsAttrDesc&&l.colorsAttrDesc.count>0){var y=new Float32Array(t,l.colorsAttrDesc.offset,l.colorsAttrDesc.count);i.setVerticesData(o.b.ColorKind,y,!1,l.colorsAttrDesc.stride)}if(l.matricesIndicesAttrDesc&&l.matricesIndicesAttrDesc.count>0){for(var b=new Int32Array(t,l.matricesIndicesAttrDesc.offset,l.matricesIndicesAttrDesc.count),T=[],E=0;E<b.length;E++){var x=b[E];T.push(255&x),T.push((65280&x)>>8),T.push((16711680&x)>>16),T.push(x>>24)}i.setVerticesData(o.b.MatricesIndicesKind,T,!1)}if(l.matricesWeightsAttrDesc&&l.matricesWeightsAttrDesc.count>0){var A=new Float32Array(t,l.matricesWeightsAttrDesc.offset,l.matricesWeightsAttrDesc.count);i.setVerticesData(o.b.MatricesWeightsKind,A,!1)}if(l.indicesAttrDesc&&l.indicesAttrDesc.count>0){var P=new Int32Array(t,l.indicesAttrDesc.offset,l.indicesAttrDesc.count);i.setIndices(P,null)}if(l.subMeshesAttrDesc&&l.subMeshesAttrDesc.count>0){var R=new Int32Array(t,l.subMeshesAttrDesc.offset,5*l.subMeshesAttrDesc.count);i.subMeshes=[];for(E=0;E<l.subMeshesAttrDesc.count;E++){var S=R[5*E+0],C=R[5*E+1],M=R[5*E+2],O=R[5*E+3],I=R[5*E+4];s.b.AddToMesh(S,C,M,O,I,i)}}}else if(t.positions&&t.normals&&t.indices){if(i.setVerticesData(o.b.PositionKind,t.positions,t.positions._updatable),i.setVerticesData(o.b.NormalKind,t.normals,t.normals._updatable),t.tangents&&i.setVerticesData(o.b.TangentKind,t.tangents,t.tangents._updatable),t.uvs&&i.setVerticesData(o.b.UVKind,t.uvs,t.uvs._updatable),t.uvs2&&i.setVerticesData(o.b.UV2Kind,t.uvs2,t.uvs2._updatable),t.uvs3&&i.setVerticesData(o.b.UV3Kind,t.uvs3,t.uvs3._updatable),t.uvs4&&i.setVerticesData(o.b.UV4Kind,t.uvs4,t.uvs4._updatable),t.uvs5&&i.setVerticesData(o.b.UV5Kind,t.uvs5,t.uvs5._updatable),t.uvs6&&i.setVerticesData(o.b.UV6Kind,t.uvs6,t.uvs6._updatable),t.colors&&i.setVerticesData(o.b.ColorKind,r.f.CheckColors4(t.colors,t.positions.length/3),t.colors._updatable),t.matricesIndices)if(t.matricesIndices._isExpanded)delete t.matricesIndices._isExpanded,i.setVerticesData(o.b.MatricesIndicesKind,t.matricesIndices,t.matricesIndices._updatable);else{for(T=[],E=0;E<t.matricesIndices.length;E++){var D=t.matricesIndices[E];T.push(255&D),T.push((65280&D)>>8),T.push((16711680&D)>>16),T.push(D>>24)}i.setVerticesData(o.b.MatricesIndicesKind,T,t.matricesIndices._updatable)}if(t.matricesIndicesExtra)if(t.matricesIndicesExtra._isExpanded)delete t.matricesIndices._isExpanded,i.setVerticesData(o.b.MatricesIndicesExtraKind,t.matricesIndicesExtra,t.matricesIndicesExtra._updatable);else{for(T=[],E=0;E<t.matricesIndicesExtra.length;E++){D=t.matricesIndicesExtra[E];T.push(255&D),T.push((65280&D)>>8),T.push((16711680&D)>>16),T.push(D>>24)}i.setVerticesData(o.b.MatricesIndicesExtraKind,T,t.matricesIndicesExtra._updatable)}t.matricesWeights&&(e._CleanMatricesWeights(t,i),i.setVerticesData(o.b.MatricesWeightsKind,t.matricesWeights,t.matricesWeights._updatable)),t.matricesWeightsExtra&&i.setVerticesData(o.b.MatricesWeightsExtraKind,t.matricesWeightsExtra,t.matricesWeights._updatable),i.setIndices(t.indices,null)}if(t.subMeshes){i.subMeshes=[];for(var w=0;w<t.subMeshes.length;w++){var L=t.subMeshes[w];s.b.AddToMesh(L.materialIndex,L.verticesStart,L.verticesCount,L.indexStart,L.indexCount,i)}}i._shouldGenerateFlatShading&&(i.convertToFlatShadedMesh(),delete i._shouldGenerateFlatShading),i.computeWorldMatrix(!0),n.onMeshImportedObservable.notifyObservers(i)},e._CleanMatricesWeights=function(e,t){if(a.a.CleanBoneMatrixWeights){var i=0;if(e.skeletonId>-1){var r=t.getScene().getLastSkeletonByID(e.skeletonId);if(r){i=r.bones.length;for(var n=t.getVerticesData(o.b.MatricesIndicesKind),s=t.getVerticesData(o.b.MatricesIndicesExtraKind),c=e.matricesWeights,l=e.matricesWeightsExtra,u=e.numBoneInfluencer,h=c.length,d=0;d<h;d+=4){for(var f=0,p=-1,_=0;_<4;_++){f+=g=c[d+_],g<.001&&p<0&&(p=_)}if(l)for(_=0;_<4;_++){var g;f+=g=l[d+_],g<.001&&p<0&&(p=_+4)}if((p<0||p>u-1)&&(p=u-1),f>.001){var m=1/f;for(_=0;_<4;_++)c[d+_]*=m;if(l)for(_=0;_<4;_++)l[d+_]*=m}else p>=4?(l[d+p-4]=1-f,s[d+p-4]=i):(c[d+p]=1-f,n[d+p]=i)}t.setVerticesData(o.b.MatricesIndicesKind,n),e.matricesWeightsExtra&&t.setVerticesData(o.b.MatricesIndicesExtraKind,s)}}}},e.Parse=function(t,i,s){if(i.getGeometryByID(t.id))return null;var a=new e(t.id,i,void 0,t.updatable);return h.a&&h.a.AddTagsTo(a,t.tags),t.delayLoadingFile?(a.delayLoadState=l.a.DELAYLOADSTATE_NOTLOADED,a.delayLoadingFile=s+t.delayLoadingFile,a._boundingInfo=new c.a(r.x.FromArray(t.boundingBoxMinimum),r.x.FromArray(t.boundingBoxMaximum)),a._delayInfo=[],t.hasUVs&&a._delayInfo.push(o.b.UVKind),t.hasUVs2&&a._delayInfo.push(o.b.UV2Kind),t.hasUVs3&&a._delayInfo.push(o.b.UV3Kind),t.hasUVs4&&a._delayInfo.push(o.b.UV4Kind),t.hasUVs5&&a._delayInfo.push(o.b.UV5Kind),t.hasUVs6&&a._delayInfo.push(o.b.UV6Kind),t.hasColors&&a._delayInfo.push(o.b.ColorKind),t.hasMatricesIndices&&a._delayInfo.push(o.b.MatricesIndicesKind),t.hasMatricesWeights&&a._delayInfo.push(o.b.MatricesWeightsKind),a._delayLoadingFunction=n.a.ImportVertexData):n.a.ImportVertexData(t,a),i.pushGeometry(a,!0),a},e}()},function(e,t,i){"use strict";i.d(t,"a",function(){return f});var r=i(1),n=i(7),o=i(0),s=i(46),a=i(61),c=i(35),l=i(50),u=i(48),h=i(40),d=i(33),f=function(e){function t(i,r,s){void 0===r&&(r=o.e.Gray()),void 0===s&&(s=h.a.DefaultUtilityLayer);var a=e.call(this,s)||this;a._pointerObserver=null,a.snapDistance=0,a.onSnapObservable=new n.c;var c=new d.a("",s.utilityLayerScene);c.disableLighting=!0,c.emissiveColor=r;var u=new d.a("",s.utilityLayerScene);u.disableLighting=!0,u.emissiveColor=r.add(new o.e(.3,.3,.3));var f=t._CreateArrow(s.utilityLayerScene,c);f.lookAt(a._rootMesh.position.add(i)),f.scaling.scaleInPlace(1/3),f.parent=a._rootMesh;var p=0,_=new o.x,g={snapDistance:0};a.dragBehavior=new l.a({dragAxis:i}),a.dragBehavior.moveAttached=!1,a._rootMesh.addBehavior(a.dragBehavior);var m=new o.x,v=new o.j;return a.dragBehavior.onDragObservable.add(function(e){if(a.attachedMesh)if(a.attachedMesh.parent?(a.attachedMesh.parent.computeWorldMatrix().invertToRef(v),v.setTranslationFromFloats(0,0,0),o.x.TransformCoordinatesToRef(e.delta,v,m)):m.copyFrom(e.delta),0==a.snapDistance)a.attachedMesh.position.addInPlace(m);else if(p+=e.dragDistance,Math.abs(p)>a.snapDistance){var t=Math.floor(Math.abs(p)/a.snapDistance);p%=a.snapDistance,m.normalizeToRef(_),_.scaleInPlace(a.snapDistance*t),a.attachedMesh.position.addInPlace(_),g.snapDistance=a.snapDistance*t,a.onSnapObservable.notifyObservers(g)}}),a._pointerObserver=s.utilityLayerScene.onPointerObservable.add(function(e){if(!a._customMeshSet){var t=e.pickInfo&&-1!=a._rootMesh.getChildMeshes().indexOf(e.pickInfo.pickedMesh)?u:c;a._rootMesh.getChildMeshes().forEach(function(e){e.material=t,e.color&&(e.color=t.emissiveColor)})}}),a}return r.d(t,e),t._CreateArrow=function(e,t){var i=new s.a("arrow",e),r=a.a.CreateCylinder("cylinder",{diameterTop:0,height:1.5,diameterBottom:.75,tessellation:96},e),n=c.a.CreateLines("line",{points:[new o.x(0,0,0),new o.x(0,1.1,0)]},e);return n.color=t.emissiveColor,r.parent=i,n.parent=i,r.scaling.scaleInPlace(.05),r.material=t,r.rotation.x=Math.PI/2,r.position.z+=.3,n.scaling.scaleInPlace(.26),n.rotation.x=Math.PI/2,n.material=t,i},t._CreateArrowInstance=function(e,t){for(var i=new s.a("arrow",e),r=0,n=t.getChildMeshes();r<n.length;r++){var o=n[r];o.createInstance(o.name).parent=i}return i},t.prototype._attachedMeshChanged=function(e){this.dragBehavior&&(this.dragBehavior.enabled=!!e)},t.prototype.dispose=function(){this.onSnapObservable.clear(),this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver),this.dragBehavior.detach(),e.prototype.dispose.call(this)},t}(u.a)},function(e,t,i){"use strict";i.d(t,"a",function(){return r});var r=function(){function e(){}return e.FilesToLoad={},e}()},function(e,t,i){"use strict";i.d(t,"a",function(){return r});var r=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))&&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=e(t,this._data[t]);if(i)return i}return null},e}()},function(e,t,i){"use strict";i.d(t,"b",function(){return n}),i.d(t,"a",function(){return o});var r=i(0),n=function(){function e(){this.x=r.x.Zero(),this.y=r.x.Zero(),this.z=r.x.Zero(),this.xx=r.x.Zero(),this.yy=r.x.Zero(),this.zz=r.x.Zero(),this.xy=r.x.Zero(),this.yz=r.x.Zero(),this.zx=r.x.Zero()}return e.prototype.addAmbient=function(e){var t=new r.x(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.prototype.scale=function(e){this.x=this.x.scale(e),this.y=this.y.scale(e),this.z=this.z.scale(e),this.xx=this.xx.scale(e),this.yy=this.yy.scale(e),this.zz=this.zz.scale(e),this.yz=this.yz.scale(e),this.zx=this.zx.scale(e),this.xy=this.xy.scale(e)},e.FromHarmonics=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.lL22.scale(.429043)),i.yy=t.l00.scale(.886277).subtract(t.l20.scale(.247708)).subtract(t.lL22.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.scale(1/Math.PI),i},e.FromArray=function(t){var i=new e;return r.x.FromArrayToRef(t[0],0,i.x),r.x.FromArrayToRef(t[1],0,i.y),r.x.FromArrayToRef(t[2],0,i.z),r.x.FromArrayToRef(t[3],0,i.xx),r.x.FromArrayToRef(t[4],0,i.yy),r.x.FromArrayToRef(t[5],0,i.zz),r.x.FromArrayToRef(t[6],0,i.yz),r.x.FromArrayToRef(t[7],0,i.zx),r.x.FromArrayToRef(t[8],0,i.xy),i},e}(),o=function(){function e(){this.l00=r.x.Zero(),this.l1_1=r.x.Zero(),this.l10=r.x.Zero(),this.l11=r.x.Zero(),this.l2_2=r.x.Zero(),this.l2_1=r.x.Zero(),this.l20=r.x.Zero(),this.l21=r.x.Zero(),this.lL22=r.x.Zero()}return e.prototype.addLight=function(e,t,i){var n=new r.x(t.r,t.g,t.b).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.lL22=this.lL22.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.lL22=this.lL22.scale(e)},e.prototype.convertIncidentRadianceToIrradiance=function(){this.l00=this.l00.scale(3.141593),this.l1_1=this.l1_1.scale(2.094395),this.l10=this.l10.scale(2.094395),this.l11=this.l11.scale(2.094395),this.l2_2=this.l2_2.scale(.785398),this.l2_1=this.l2_1.scale(.785398),this.l20=this.l20.scale(.785398),this.l21=this.l21.scale(.785398),this.lL22=this.lL22.scale(.785398)},e.prototype.convertIrradianceToLambertianRadiance=function(){this.scale(1/Math.PI)},e.FromPolynomial=function(t){var i=new e;return i.l00=t.xx.scale(.376127).add(t.yy.scale(.376127)).add(t.zz.scale(.376126)),i.l1_1=t.y.scale(.977204),i.l10=t.z.scale(.977204),i.l11=t.x.scale(.977204),i.l2_2=t.xy.scale(1.16538),i.l2_1=t.yz.scale(1.16538),i.l20=t.zz.scale(1.34567).subtract(t.xx.scale(.672834)).subtract(t.yy.scale(.672834)),i.l21=t.zx.scale(1.16538),i.lL22=t.xx.scale(1.16538).subtract(t.yy.scale(1.16538)),i.scale(Math.PI),i},e.FromArray=function(t){var i=new e;return r.x.FromArrayToRef(t[0],0,i.l00),r.x.FromArrayToRef(t[1],0,i.l1_1),r.x.FromArrayToRef(t[2],0,i.l10),r.x.FromArrayToRef(t[3],0,i.l11),r.x.FromArrayToRef(t[4],0,i.l2_2),r.x.FromArrayToRef(t[5],0,i.l2_1),r.x.FromArrayToRef(t[6],0,i.l20),r.x.FromArrayToRef(t[7],0,i.l21),r.x.FromArrayToRef(t[8],0,i.lL22),i},e}()},function(e,t,i){"use strict";i.d(t,"a",function(){return r});var r=function(){function e(){this._isDirty=!0,this._areLightsDirty=!0,this._areAttributesDirty=!0,this._areTexturesDirty=!0,this._areFresnelDirty=!0,this._areMiscDirty=!0,this._areImageProcessingDirty=!0,this._normals=!1,this._uvs=!1,this._needNormals=!1,this._needUVs=!1}return Object.defineProperty(e.prototype,"isDirty",{get:function(){return this._isDirty},enumerable:!0,configurable:!0}),e.prototype.markAsProcessed=function(){this._isDirty=!1,this._areAttributesDirty=!1,this._areTexturesDirty=!1,this._areFresnelDirty=!1,this._areLightsDirty=!1,this._areMiscDirty=!1,this._areImageProcessingDirty=!1},e.prototype.markAsUnprocessed=function(){this._isDirty=!0},e.prototype.markAllAsDirty=function(){this._areTexturesDirty=!0,this._areAttributesDirty=!0,this._areLightsDirty=!0,this._areFresnelDirty=!0,this._areMiscDirty=!0,this._areImageProcessingDirty=!0,this._isDirty=!0},e.prototype.markAsImageProcessingDirty=function(){this._areImageProcessingDirty=!0,this._isDirty=!0},e.prototype.markAsLightDirty=function(){this._areLightsDirty=!0,this._isDirty=!0},e.prototype.markAsAttributesDirty=function(){this._areAttributesDirty=!0,this._isDirty=!0},e.prototype.markAsTexturesDirty=function(){this._areTexturesDirty=!0,this._isDirty=!0},e.prototype.markAsFresnelDirty=function(){this._areFresnelDirty=!0,this._isDirty=!0},e.prototype.markAsMiscDirty=function(){this._areMiscDirty=!0,this._isDirty=!0},e.prototype.rebuild=function(){this._keys&&delete this._keys,this._keys=[];for(var e=0,t=Object.keys(this);e<t.length;e++){var 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];switch(typeof this[t]){case"number":this[t]=0;break;case"string":this[t]="";break;default: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];switch(typeof r){case"number":case"string":e+="#define "+i+" "+r+"\n";break;default:r&&(e+="#define "+i+"\n")}}return e},e}()},function(e,t,i){"use strict";i.d(t,"a",function(){return a});var r=i(0),n=i(10),o=i(13),s=i(17);o.a.CreateCylinder=function(e){var t,i=e.height||2,n=0===e.diameterTop?0:e.diameterTop||e.diameter||1,s=0===e.diameterBottom?0:e.diameterBottom||e.diameter||1,a=e.tessellation||24,c=e.subdivisions||1,l=!!e.hasRings,u=!!e.enclose,h=e.arc&&(e.arc<=0||e.arc>1)?1:e.arc||1,d=0===e.sideOrientation?0:e.sideOrientation||o.a.DEFAULTSIDE,f=e.faceUV||new Array(3),p=e.faceColors,_=2+(1+(1!==h&&u?2:0))*(l?c:1);for(t=0;t<_;t++)p&&void 0===p[t]&&(p[t]=new r.f(1,1,1,1));for(t=0;t<_;t++)f&&void 0===f[t]&&(f[t]=new r.y(0,0,1,1));var g,m,v,y,b,T,E=new Array,x=new Array,A=new Array,P=new Array,R=new Array,S=2*Math.PI*h/a,C=(s-n)/2/i,M=r.x.Zero(),O=r.x.Zero(),I=r.x.Zero(),D=r.x.Zero(),w=r.x.Zero(),L=r.c.Y,F=1,N=1,B=0,U=0;for(y=0;y<=c;y++)for(v=((m=y/c)*(n-s)+s)/2,F=l&&0!==y&&y!==c?2:1,T=0;T<F;T++){for(l&&(N+=T),u&&(N+=2*T),b=0;b<=a;b++)g=b*S,M.x=Math.cos(-g)*v,M.y=-i/2+m*i,M.z=Math.sin(-g)*v,0===n&&y===c?(O.x=A[A.length-3*(a+1)],O.y=A[A.length-3*(a+1)+1],O.z=A[A.length-3*(a+1)+2]):(O.x=M.x,O.z=M.z,O.y=Math.sqrt(O.x*O.x+O.z*O.z)*C,O.normalize()),0===b&&(I.copyFrom(M),D.copyFrom(O)),x.push(M.x,M.y,M.z),A.push(O.x,O.y,O.z),U=l?B!==N?f[N].y:f[N].w:f[N].y+(f[N].w-f[N].y)*m,P.push(f[N].x+(f[N].z-f[N].x)*b/a,U),p&&R.push(p[N].r,p[N].g,p[N].b,p[N].a);1!==h&&u&&(x.push(M.x,M.y,M.z),x.push(0,M.y,0),x.push(0,M.y,0),x.push(I.x,I.y,I.z),r.x.CrossToRef(L,O,w),w.normalize(),A.push(w.x,w.y,w.z,w.x,w.y,w.z),r.x.CrossToRef(D,L,w),w.normalize(),A.push(w.x,w.y,w.z,w.x,w.y,w.z),U=l?B!==N?f[N+1].y:f[N+1].w:f[N+1].y+(f[N+1].w-f[N+1].y)*m,P.push(f[N+1].x,U),P.push(f[N+1].z,U),U=l?B!==N?f[N+2].y:f[N+2].w:f[N+2].y+(f[N+2].w-f[N+2].y)*m,P.push(f[N+2].x,U),P.push(f[N+2].z,U),p&&(R.push(p[N+1].r,p[N+1].g,p[N+1].b,p[N+1].a),R.push(p[N+1].r,p[N+1].g,p[N+1].b,p[N+1].a),R.push(p[N+2].r,p[N+2].g,p[N+2].b,p[N+2].a),R.push(p[N+2].r,p[N+2].g,p[N+2].b,p[N+2].a))),B!==N&&(B=N)}var V=1!==h&&u?a+4:a;for(y=0,N=0;N<c;N++){var G=0,k=0,z=0,j=0;for(b=0;b<a;b++)G=y*(V+1)+b,k=(y+1)*(V+1)+b,z=y*(V+1)+(b+1),j=(y+1)*(V+1)+(b+1),E.push(G,k,z),E.push(j,z,k);1!==h&&u&&(E.push(G+2,k+2,z+2),E.push(j+2,z+2,k+2),E.push(G+4,k+4,z+4),E.push(j+4,z+4,k+4)),y=l?y+2:y+1}var W=function(e){var t=e?n/2:s/2;if(0!==t){var o,c,l,u=e?f[_-1]:f[0],d=null;p&&(d=e?p[_-1]:p[0]);var g=x.length/3,m=e?i/2:-i/2,v=new r.x(0,m,0);x.push(v.x,v.y,v.z),A.push(0,e?1:-1,0),P.push(u.x+.5*(u.z-u.x),u.y+.5*(u.w-u.y)),d&&R.push(d.r,d.g,d.b,d.a);var y=new r.w(.5,.5);for(l=0;l<=a;l++){o=2*Math.PI*l*h/a;var b=Math.cos(-o),T=Math.sin(-o);c=new r.x(b*t,m,T*t);var S=new r.w(b*y.x+.5,T*y.y+.5);x.push(c.x,c.y,c.z),A.push(0,e?1:-1,0),P.push(u.x+(u.z-u.x)*S.x,u.y+(u.w-u.y)*S.y),d&&R.push(d.r,d.g,d.b,d.a)}for(l=0;l<a;l++)e?(E.push(g),E.push(g+(l+2)),E.push(g+(l+1))):(E.push(g),E.push(g+(l+1)),E.push(g+(l+2)))}};W(!1),W(!0),o.a._ComputeSides(d,x,E,A,P,e.frontUVs,e.backUVs);var H=new o.a;return H.indices=E,H.positions=x,H.normals=A,H.uvs=P,p&&(H.colors=R),H},n.a.CreateCylinder=function(e,t,i,r,o,c,l,u,h){void 0!==l&&l instanceof s.a||(void 0!==l&&(h=u||n.a.DEFAULTSIDE,u=l),l=c,c=1);var d={height:t,diameterTop:i,diameterBottom:r,tessellation:o,subdivisions:c,sideOrientation:h,updatable:u};return a.CreateCylinder(e,d,l)};var a=function(){function e(){}return e.CreateCylinder=function(e,t,i){var r=new n.a(e,i);return t.sideOrientation=n.a._GetDefaultSideOrientation(t.sideOrientation),r._originalBuilderSideOrientation=t.sideOrientation,o.a.CreateCylinder(t).applyToMesh(r,t.updatable),r},e}()},function(e,t,i){"use strict";var r="bonesDeclaration",n="#if NUM_BONE_INFLUENCERS>0\n#ifdef BONETEXTURE\nuniform sampler2D boneSampler;\nuniform float boneTextureWidth;\n#else\nuniform mat4 mBones[BonesPerMesh];\n#endif\nattribute vec4 matricesIndices;\nattribute vec4 matricesWeights;\n#if NUM_BONE_INFLUENCERS>4\nattribute vec4 matricesIndicesExtra;\nattribute vec4 matricesWeightsExtra;\n#endif\n#ifdef BONETEXTURE\nmat4 readMatrixFromRawSampler(sampler2D smp,float index)\n{\nfloat offset=index*4.0;\nfloat dx=1.0/boneTextureWidth;\nvec4 m0=texture2D(smp,vec2(dx*(offset+0.5),0.));\nvec4 m1=texture2D(smp,vec2(dx*(offset+1.5),0.));\nvec4 m2=texture2D(smp,vec2(dx*(offset+2.5),0.));\nvec4 m3=texture2D(smp,vec2(dx*(offset+3.5),0.));\nreturn mat4(m0,m1,m2,m3);\n}\n#endif\n#endif";i(5).a.IncludesShadersStore[r]=n},function(e,t,i){"use strict";var r="instancesDeclaration",n="#ifdef INSTANCES\nattribute vec4 world0;\nattribute vec4 world1;\nattribute vec4 world2;\nattribute vec4 world3;\n#else\nuniform mat4 world;\n#endif";i(5).a.IncludesShadersStore[r]=n},function(e,t,i){"use strict";var r="instancesVertex",n="#ifdef INSTANCES\nmat4 finalWorld=mat4(world0,world1,world2,world3);\n#else\nmat4 finalWorld=world;\n#endif";i(5).a.IncludesShadersStore[r]=n},function(e,t,i){"use strict";var r="#if NUM_BONE_INFLUENCERS>0\nmat4 influence;\n#ifdef BONETEXTURE\ninfluence=readMatrixFromRawSampler(boneSampler,matricesIndices[0])*matricesWeights[0];\n#if NUM_BONE_INFLUENCERS>1\ninfluence+=readMatrixFromRawSampler(boneSampler,matricesIndices[1])*matricesWeights[1];\n#endif\n#if NUM_BONE_INFLUENCERS>2\ninfluence+=readMatrixFromRawSampler(boneSampler,matricesIndices[2])*matricesWeights[2];\n#endif\n#if NUM_BONE_INFLUENCERS>3\ninfluence+=readMatrixFromRawSampler(boneSampler,matricesIndices[3])*matricesWeights[3];\n#endif\n#if NUM_BONE_INFLUENCERS>4\ninfluence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[0])*matricesWeightsExtra[0];\n#endif\n#if NUM_BONE_INFLUENCERS>5\ninfluence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[1])*matricesWeightsExtra[1];\n#endif\n#if NUM_BONE_INFLUENCERS>6\ninfluence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[2])*matricesWeightsExtra[2];\n#endif\n#if NUM_BONE_INFLUENCERS>7\ninfluence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[3])*matricesWeightsExtra[3];\n#endif\n#else\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\n#endif\nfinalWorld=finalWorld*influence;\n#endif";i(5).a.IncludesShadersStore.bonesVertex=r},function(e,t,i){"use strict";i.d(t,"a",function(){return n});var r=i(8),n=function(){function e(e,t,i){this._engine=e,this._noUBO=!e.supportsUniformBuffers,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._engine._uniformBuffers.push(this),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(e.prototype,"useUbo",{get:function(){return!this._noUBO},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isSync",{get:function(){return!this._needSync},enumerable:!0,configurable:!0}),e.prototype.isDynamic=function(){return void 0!==this._dynamic},e.prototype.getData=function(){return this._bufferData},e.prototype.getBuffer=function(){return this._buffer},e.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)}},e.prototype.addUniform=function(e,t){if(!this._noUBO&&void 0===this._uniformLocations[e]){var i;if(t instanceof Array)t=(i=t).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(r=0;r<t;r++)this._data.push(i[r]);this._needSync=!0}},e.prototype.addMatrix=function(e,t){this.addUniform(e,Array.prototype.slice.call(t.toArray()))},e.prototype.addFloat2=function(e,t,i){var r=[t,i];this.addUniform(e,r)},e.prototype.addFloat3=function(e,t,i,r){var n=[t,i,r];this.addUniform(e,n)},e.prototype.addColor3=function(e,t){var i=new Array;t.toArray(i),this.addUniform(e,i)},e.prototype.addColor4=function(e,t,i){var r=new Array;t.toArray(r),r.push(i),this.addUniform(e,r)},e.prototype.addVector3=function(e,t){var i=new Array;t.toArray(i),this.addUniform(e,i)},e.prototype.addMatrix3x3=function(e){this.addUniform(e,12)},e.prototype.addMatrix2x2=function(e){this.addUniform(e,8)},e.prototype.create=function(){this._noUBO||this._buffer||(this._fillAlignment(4),this._bufferData=new Float32Array(this._data),this._rebuild(),this._needSync=!0)},e.prototype._rebuild=function(){this._noUBO||(this._dynamic?this._buffer=this._engine.createDynamicUniformBuffer(this._bufferData):this._buffer=this._engine.createUniformBuffer(this._bufferData))},e.prototype.update=function(){this._buffer?(this._dynamic||this._needSync)&&(this._engine.updateUniformBuffer(this._buffer,this._bufferData),this._needSync=!1):this.create()},e.prototype.updateUniform=function(e,t,i){var n=this._uniformLocations[e];if(void 0===n){if(this._buffer)return void r.a.Error("Cannot add an uniform after UBO has been created.");this.addUniform(e,i),n=this._uniformLocations[e]}if(this._buffer||this.create(),this._dynamic)for(s=0;s<i;s++)this._bufferData[n+s]=t[s];else{for(var o=!1,s=0;s<i;s++)this._bufferData[n+s]!==t[s]&&(o=!0,this._bufferData[n+s]=t[s]);this._needSync=this._needSync||o}},e.prototype._updateMatrix3x3ForUniform=function(t,i){for(var r=0;r<3;r++)e._tempBuffer[4*r]=i[3*r],e._tempBuffer[4*r+1]=i[3*r+1],e._tempBuffer[4*r+2]=i[3*r+2],e._tempBuffer[4*r+3]=0;this.updateUniform(t,e._tempBuffer,12)},e.prototype._updateMatrix3x3ForEffect=function(e,t){this._currentEffect.setMatrix3x3(e,t)},e.prototype._updateMatrix2x2ForEffect=function(e,t){this._currentEffect.setMatrix2x2(e,t)},e.prototype._updateMatrix2x2ForUniform=function(t,i){for(var r=0;r<2;r++)e._tempBuffer[4*r]=i[2*r],e._tempBuffer[4*r+1]=i[2*r+1],e._tempBuffer[4*r+2]=0,e._tempBuffer[4*r+3]=0;this.updateUniform(t,e._tempBuffer,8)},e.prototype._updateFloatForEffect=function(e,t){this._currentEffect.setFloat(e,t)},e.prototype._updateFloatForUniform=function(t,i){e._tempBuffer[0]=i,this.updateUniform(t,e._tempBuffer,1)},e.prototype._updateFloat2ForEffect=function(e,t,i,r){void 0===r&&(r=""),this._currentEffect.setFloat2(e+r,t,i)},e.prototype._updateFloat2ForUniform=function(t,i,r){e._tempBuffer[0]=i,e._tempBuffer[1]=r,this.updateUniform(t,e._tempBuffer,2)},e.prototype._updateFloat3ForEffect=function(e,t,i,r,n){void 0===n&&(n=""),this._currentEffect.setFloat3(e+n,t,i,r)},e.prototype._updateFloat3ForUniform=function(t,i,r,n){e._tempBuffer[0]=i,e._tempBuffer[1]=r,e._tempBuffer[2]=n,this.updateUniform(t,e._tempBuffer,3)},e.prototype._updateFloat4ForEffect=function(e,t,i,r,n,o){void 0===o&&(o=""),this._currentEffect.setFloat4(e+o,t,i,r,n)},e.prototype._updateFloat4ForUniform=function(t,i,r,n,o){e._tempBuffer[0]=i,e._tempBuffer[1]=r,e._tempBuffer[2]=n,e._tempBuffer[3]=o,this.updateUniform(t,e._tempBuffer,4)},e.prototype._updateMatrixForEffect=function(e,t){this._currentEffect.setMatrix(e,t)},e.prototype._updateMatrixForUniform=function(e,t){this.updateUniform(e,t.toArray(),16)},e.prototype._updateVector3ForEffect=function(e,t){this._currentEffect.setVector3(e,t)},e.prototype._updateVector3ForUniform=function(t,i){i.toArray(e._tempBuffer),this.updateUniform(t,e._tempBuffer,3)},e.prototype._updateVector4ForEffect=function(e,t){this._currentEffect.setVector4(e,t)},e.prototype._updateVector4ForUniform=function(t,i){i.toArray(e._tempBuffer),this.updateUniform(t,e._tempBuffer,4)},e.prototype._updateColor3ForEffect=function(e,t,i){void 0===i&&(i=""),this._currentEffect.setColor3(e+i,t)},e.prototype._updateColor3ForUniform=function(t,i){i.toArray(e._tempBuffer),this.updateUniform(t,e._tempBuffer,3)},e.prototype._updateColor4ForEffect=function(e,t,i,r){void 0===r&&(r=""),this._currentEffect.setColor4(e+r,t,i)},e.prototype._updateColor4ForUniform=function(t,i,r){i.toArray(e._tempBuffer),e._tempBuffer[3]=r,this.updateUniform(t,e._tempBuffer,4)},e.prototype.setTexture=function(e,t){this._currentEffect.setTexture(e,t)},e.prototype.updateUniformDirectly=function(e,t){this.updateUniform(e,t,t.length),this.update()},e.prototype.bindToEffect=function(e,t){this._currentEffect=e,!this._noUBO&&this._buffer&&e.bindUniformBuffer(this._buffer,t)},e.prototype.dispose=function(){if(!this._noUBO){var e=this._engine._uniformBuffers,t=e.indexOf(this);-1!==t&&(e[t]=e[e.length-1],e.pop()),this._buffer&&this._engine._releaseBuffer(this._buffer)&&(this._buffer=null)}},e._MAX_UNIFORM_SIZE=256,e._tempBuffer=new Float32Array(e._MAX_UNIFORM_SIZE),e}()},function(e,t,i){"use strict";i.d(t,"a",function(){return c});var r=i(0),n=i(12),o=i(59),s=i(3),a=function(){return function(e,t,i,r){this.name=e,this.worldAxisForNormal=t,this.worldAxisForFileX=i,this.worldAxisForFileY=r}}(),c=function(){function e(){}return e.ConvertCubeMapTextureToSphericalPolynomial=function(e){if(!e.isCube)return null;var t,i,r=e.getSize().width,n=e.readPixels(0),o=e.readPixels(1);e.isRenderTarget?(t=e.readPixels(3),i=e.readPixels(2)):(t=e.readPixels(2),i=e.readPixels(3));var a=e.readPixels(4),c=e.readPixels(5),l=e.gammaSpace,u=s.a.TEXTUREFORMAT_RGBA,h=s.a.TEXTURETYPE_UNSIGNED_INT;e.textureType&&e.textureType!==s.a.TEXTURETYPE_UNSIGNED_INT&&(h=s.a.TEXTURETYPE_FLOAT);var d={size:r,right:n,left:o,up:t,down:i,front:a,back:c,format:u,type:h,gammaSpace:l};return this.ConvertCubeMapToSphericalPolynomial(d)},e.ConvertCubeMapToSphericalPolynomial=function(e){for(var t=new o.a,i=0,a=2/e.size,c=a,l=.5*a-1,u=0;u<6;u++)for(var h=this.FileFaces[u],d=e[h.name],f=l,p=e.format===s.a.TEXTUREFORMAT_RGBA?4:3,_=0;_<e.size;_++){for(var g=l,m=0;m<e.size;m++){var v=h.worldAxisForFileX.scale(g).add(h.worldAxisForFileY.scale(f)).add(h.worldAxisForNormal);v.normalize();var y=Math.pow(1+g*g+f*f,-1.5),b=d[_*e.size*p+m*p+0],T=d[_*e.size*p+m*p+1],E=d[_*e.size*p+m*p+2];e.type===s.a.TEXTURETYPE_UNSIGNED_INT&&(b/=255,T/=255,E/=255),e.gammaSpace&&(b=Math.pow(n.a.Clamp(b),r.v),T=Math.pow(n.a.Clamp(T),r.v),E=Math.pow(n.a.Clamp(E),r.v));var x=new r.e(b,T,E);t.addLight(v,x,y),i+=y,g+=a}f+=c}var A=6*(4*Math.PI)/6/i;return t.scale(A),t.convertIncidentRadianceToIrradiance(),t.convertIrradianceToLambertianRadiance(),o.b.FromHarmonics(t)},e.FileFaces=[new a("right",new r.x(1,0,0),new r.x(0,0,-1),new r.x(0,-1,0)),new a("left",new r.x(-1,0,0),new r.x(0,0,1),new r.x(0,-1,0)),new a("up",new r.x(0,1,0),new r.x(1,0,0),new r.x(0,0,1)),new a("down",new r.x(0,-1,0),new r.x(1,0,0),new r.x(0,0,-1)),new a("front",new r.x(0,0,1),new r.x(1,0,0),new r.x(0,-1,0)),new a("back",new r.x(0,0,-1),new r.x(-1,0,0),new r.x(0,-1,0))],e}()},function(e,t,i){"use strict";i.d(t,"b",function(){return u}),i.d(t,"a",function(){return h});var r=i(1),n=i(0),o=i(4),s=i(10),a=i(103),c=i(18),l=i(70),u=(i(117),i(118),function(e){function t(t,i,r,s,a,c,u){void 0===i&&(i=null),void 0===r&&(r=null);var h=e.call(this,t,i,r,s,a)||this;h.useVertexColor=c,h.useVertexAlpha=u,h.color=new n.e(1,1,1),h.alpha=1,s&&(h.color=s.color.clone(),h.alpha=s.alpha,h.useVertexColor=s.useVertexColor,h.useVertexAlpha=s.useVertexAlpha),h.intersectionThreshold=.1;var d={attributes:[o.b.PositionKind,"world0","world1","world2","world3"],uniforms:["world","viewProjection"],needAlphaBlending:!0,defines:[]};return!1===u&&(d.needAlphaBlending=!1),c?(d.defines.push("#define VERTEXCOLOR"),d.attributes.push(o.b.ColorKind)):d.uniforms.push("color"),h._colorShader=new l.a("colorShader",h.getScene(),"color",d),h}return r.d(t,e),t.prototype.getClassName=function(){return"LinesMesh"},Object.defineProperty(t.prototype,"material",{get:function(){return this._colorShader},set:function(e){},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"checkCollisions",{get:function(){return!1},enumerable:!0,configurable:!0}),t.prototype._bind=function(e,t,i){return this._geometry?(this._geometry._bind(this._colorShader.getEffect()),this.useVertexColor||this._colorShader.setColor4("color",this.color.toColor4(this.alpha)),this):this},t.prototype._draw=function(e,t,i){return this._geometry&&this._geometry.getVertexBuffers()&&(this._unIndexed||this._geometry.getIndexBuffer())?(this.getScene().getEngine().drawElementsType(c.a.LineListDrawMode,e.indexStart,e.indexCount,i),this):this},t.prototype.dispose=function(t){this._colorShader.dispose(!1,!1,!0),e.prototype.dispose.call(this,t)},t.prototype.clone=function(e,i,r){return new t(e,this.getScene(),i,this,r)},t.prototype.createInstance=function(e){return new h(e,this)},t}(s.a)),h=function(e){function t(t,i){var r=e.call(this,t,i)||this;return r.intersectionThreshold=i.intersectionThreshold,r}return r.d(t,e),t.prototype.getClassName=function(){return"InstancedLinesMesh"},t}(a.a)},function(e,t,i){"use strict";i.d(t,"a",function(){return o});var r=i(1),n=i(0),o=function(e){function t(t,i){var r=e.call(this,t,i)||this;return r._normalMatrix=new n.j,r.allowShaderHotSwapping=!0,r._storeEffectOnSubMeshes=!0,r}return r.d(t,e),t.prototype.getEffect=function(){return this._activeEffect},t.prototype.isReady=function(e,t){return!!e&&(!e.subMeshes||0===e.subMeshes.length||this.isReadyForSubMesh(e,e.subMeshes[0],t))},t.prototype.bindOnlyWorldMatrix=function(e){this._activeEffect.setMatrix("world",e)},t.prototype.bindOnlyNormalMatrix=function(e){this._activeEffect.setMatrix("normalMatrix",e)},t.prototype.bind=function(e,t){t&&this.bindForSubMesh(e,t,t.subMeshes[0])},t.prototype._afterBind=function(t,i){void 0===i&&(i=null),e.prototype._afterBind.call(this,t),this.getScene()._cachedEffect=i},t.prototype._mustRebind=function(e,t,i){return void 0===i&&(i=1),e.isCachedMaterialInvalid(this,t,i)},t}(i(18).a)},function(e,t,i){"use strict";i.d(t,"a",function(){return d});var r=i(1),n=i(2),o=i(0),s=i(4),a=i(6),c=i(16),l=i(5),u=i(18),h=i(20),d=function(e){function t(t,i,n,s){void 0===s&&(s={});var a=e.call(this,t,i)||this;return a._textures={},a._textureArrays={},a._floats={},a._ints={},a._floatsArrays={},a._colors3={},a._colors3Arrays={},a._colors4={},a._vectors2={},a._vectors3={},a._vectors4={},a._matrices={},a._matrices3x3={},a._matrices2x2={},a._vectors2Arrays={},a._vectors3Arrays={},a._cachedWorldViewMatrix=new o.j,a._shaderPath=n,a._options=r.a({needAlphaBlending:!1,needAlphaTesting:!1,attributes:["position","normal","uv"],uniforms:["worldViewProjection"],uniformBuffers:[],samplers:[],defines:[]},s),a}return r.d(t,e),t.prototype.getClassName=function(){return"ShaderMaterial"},t.prototype.needAlphaBlending=function(){return this.alpha<1||this._options.needAlphaBlending},t.prototype.needAlphaTesting=function(){return this._options.needAlphaTesting},t.prototype._checkUniform=function(e){-1===this._options.uniforms.indexOf(e)&&this._options.uniforms.push(e)},t.prototype.setTexture=function(e,t){return-1===this._options.samplers.indexOf(e)&&this._options.samplers.push(e),this._textures[e]=t,this},t.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},t.prototype.setFloat=function(e,t){return this._checkUniform(e),this._floats[e]=t,this},t.prototype.setInt=function(e,t){return this._checkUniform(e),this._ints[e]=t,this},t.prototype.setFloats=function(e,t){return this._checkUniform(e),this._floatsArrays[e]=t,this},t.prototype.setColor3=function(e,t){return this._checkUniform(e),this._colors3[e]=t,this},t.prototype.setColor3Array=function(e,t){return this._checkUniform(e),this._colors3Arrays[e]=t.reduce(function(e,t){return t.toArray(e,e.length),e},[]),this},t.prototype.setColor4=function(e,t){return this._checkUniform(e),this._colors4[e]=t,this},t.prototype.setVector2=function(e,t){return this._checkUniform(e),this._vectors2[e]=t,this},t.prototype.setVector3=function(e,t){return this._checkUniform(e),this._vectors3[e]=t,this},t.prototype.setVector4=function(e,t){return this._checkUniform(e),this._vectors4[e]=t,this},t.prototype.setMatrix=function(e,t){return this._checkUniform(e),this._matrices[e]=t,this},t.prototype.setMatrix3x3=function(e,t){return this._checkUniform(e),this._matrices3x3[e]=t,this},t.prototype.setMatrix2x2=function(e,t){return this._checkUniform(e),this._matrices2x2[e]=t,this},t.prototype.setArray2=function(e,t){return this._checkUniform(e),this._vectors2Arrays[e]=t,this},t.prototype.setArray3=function(e,t){return this._checkUniform(e),this._vectors3Arrays[e]=t,this},t.prototype._checkCache=function(e,t){return!e||(this._effect&&this._effect.defines.indexOf("#define INSTANCES"),!1)},t.prototype.isReady=function(e,t){var i=this.getScene(),r=i.getEngine();if(!this.checkReadyOnEveryCall&&this._renderId===i.getRenderId()&&this._checkCache(e,t))return!0;for(var n=[],o=[],a=new l.c,u=0;u<this._options.defines.length;u++)n.push(this._options.defines[u]);for(u=0;u<this._options.attributes.length;u++)o.push(this._options.attributes[u]);if(e&&e.isVerticesDataPresent(s.b.ColorKind)&&(o.push(s.b.ColorKind),n.push("#define VERTEXCOLOR")),t&&(n.push("#define INSTANCES"),c.a.PrepareAttributesForInstances(o,n)),e&&e.useBones&&e.computeBonesUsingShaders&&e.skeleton){o.push(s.b.MatricesIndicesKind),o.push(s.b.MatricesWeightsKind),e.numBoneInfluencers>4&&(o.push(s.b.MatricesIndicesExtraKind),o.push(s.b.MatricesWeightsExtraKind));var h=e.skeleton;n.push("#define NUM_BONE_INFLUENCERS "+e.numBoneInfluencers),a.addCPUSkinningFallback(0,e),h.isUsingTextureForMatrices?(n.push("#define BONETEXTURE"),-1===this._options.uniforms.indexOf("boneTextureWidth")&&this._options.uniforms.push("boneTextureWidth"),-1===this._options.samplers.indexOf("boneSampler")&&this._options.samplers.push("boneSampler")):(n.push("#define BonesPerMesh "+(h.bones.length+1)),-1===this._options.uniforms.indexOf("mBones")&&this._options.uniforms.push("mBones"))}else n.push("#define NUM_BONE_INFLUENCERS 0");for(var d in this._textures)if(!this._textures[d].isReady())return!1;e&&this._shouldTurnAlphaTestOn(e)&&n.push("#define ALPHATEST");var f=this._effect,p=n.join("\n");return this._effect=r.createEffect(this._shaderPath,{attributes:o,uniformsNames:this._options.uniforms,uniformBuffersNames:this._options.uniformBuffers,samplers:this._options.samplers,defines:p,fallbacks:a,onCompiled:this.onCompiled,onError:this.onError},r),!!this._effect.isReady()&&(f!==this._effect&&i.resetCachedMaterial(),this._renderId=i.getRenderId(),!0)},t.prototype.bindOnlyWorldMatrix=function(e){var t=this.getScene();this._effect&&(-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())))},t.prototype.bind=function(e,t){if(this.bindOnlyWorldMatrix(e),this._effect&&this.getScene().getCachedMaterial()!==this){var i;for(i in-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()),c.a.BindBonesParameters(t,this._effect),this._textures)this._effect.setTexture(i,this._textures[i]);for(i in this._textureArrays)this._effect.setTextureArray(i,this._textureArrays[i]);for(i in this._ints)this._effect.setInt(i,this._ints[i]);for(i in this._floats)this._effect.setFloat(i,this._floats[i]);for(i in this._floatsArrays)this._effect.setArray(i,this._floatsArrays[i]);for(i in this._colors3)this._effect.setColor3(i,this._colors3[i]);for(i in this._colors3Arrays)this._effect.setArray3(i,this._colors3Arrays[i]);for(i in this._colors4){var r=this._colors4[i];this._effect.setFloat4(i,r.r,r.g,r.b,r.a)}for(i in this._vectors2)this._effect.setVector2(i,this._vectors2[i]);for(i in this._vectors3)this._effect.setVector3(i,this._vectors3[i]);for(i in this._vectors4)this._effect.setVector4(i,this._vectors4[i]);for(i in this._matrices)this._effect.setMatrix(i,this._matrices[i]);for(i in this._matrices3x3)this._effect.setMatrix3x3(i,this._matrices3x3[i]);for(i in this._matrices2x2)this._effect.setMatrix2x2(i,this._matrices2x2[i]);for(i in this._vectors2Arrays)this._effect.setArray2(i,this._vectors2Arrays[i]);for(i in this._vectors3Arrays)this._effect.setArray3(i,this._vectors3Arrays[i])}this._afterBind(t)},t.prototype.getActiveTextures=function(){var t=e.prototype.getActiveTextures.call(this);for(var i in this._textures)t.push(this._textures[i]);for(var i in this._textureArrays)for(var r=this._textureArrays[i],n=0;n<r.length;n++)t.push(r[n]);return t},t.prototype.hasTexture=function(t){if(e.prototype.hasTexture.call(this,t))return!0;for(var i in this._textures)if(this._textures[i]===t)return!0;for(var i in this._textureArrays)for(var r=this._textureArrays[i],n=0;n<r.length;n++)if(r[n]===t)return!0;return!1},t.prototype.clone=function(e){return new t(e,this.getScene(),this._shaderPath,this._options)},t.prototype.dispose=function(t,i,r){if(i){var n;for(n in this._textures)this._textures[n].dispose();for(n in this._textureArrays)for(var o=this._textureArrays[n],s=0;s<o.length;s++)o[s].dispose()}this._textures={},e.prototype.dispose.call(this,t,i,r)},t.prototype.serialize=function(){var e,t=n.a.Serialize(this);for(e in t.customType="ShaderMaterial",t.options=this._options,t.shaderPath=this._shaderPath,t.textures={},this._textures)t.textures[e]=this._textures[e].serialize();for(e in t.textureArrays={},this._textureArrays){t.textureArrays[e]=[];for(var i=this._textureArrays[e],r=0;r<i.length;r++)t.textureArrays[e].push(i[r].serialize())}for(e in t.floats={},this._floats)t.floats[e]=this._floats[e];for(e in t.FloatArrays={},this._floatsArrays)t.FloatArrays[e]=this._floatsArrays[e];for(e in t.colors3={},this._colors3)t.colors3[e]=this._colors3[e].asArray();for(e in t.colors3Arrays={},this._colors3Arrays)t.colors3Arrays[e]=this._colors3Arrays[e];for(e in t.colors4={},this._colors4)t.colors4[e]=this._colors4[e].asArray();for(e in t.vectors2={},this._vectors2)t.vectors2[e]=this._vectors2[e].asArray();for(e in t.vectors3={},this._vectors3)t.vectors3[e]=this._vectors3[e].asArray();for(e in t.vectors4={},this._vectors4)t.vectors4[e]=this._vectors4[e].asArray();for(e in t.matrices={},this._matrices)t.matrices[e]=this._matrices[e].asArray();for(e in t.matrices3x3={},this._matrices3x3)t.matrices3x3[e]=this._matrices3x3[e];for(e in t.matrices2x2={},this._matrices2x2)t.matrices2x2[e]=this._matrices2x2[e];for(e in t.vectors2Arrays={},this._vectors2Arrays)t.vectors2Arrays[e]=this._vectors2Arrays[e];for(e in t.vectors3Arrays={},this._vectors3Arrays)t.vectors3Arrays[e]=this._vectors3Arrays[e];return t},t.Parse=function(e,i,r){var s,c=n.a.Parse(function(){return new t(e.name,i,e.shaderPath,e.options)},e,i,r);for(s in e.textures)c.setTexture(s,a.a.Parse(e.textures[s],i,r));for(s in e.textureArrays){for(var l=e.textureArrays[s],u=new Array,h=0;h<l.length;h++)u.push(a.a.Parse(l[h],i,r));c.setTextureArray(s,u)}for(s in e.floats)c.setFloat(s,e.floats[s]);for(s in e.floatsArrays)c.setFloats(s,e.floatsArrays[s]);for(s in e.colors3)c.setColor3(s,o.e.FromArray(e.colors3[s]));for(s in e.colors3Arrays){var d=e.colors3Arrays[s].reduce(function(e,t,i){return i%3==0?e.push([t]):e[e.length-1].push(t),e},[]).map(function(e){return o.e.FromArray(e)});c.setColor3Array(s,d)}for(s in e.colors4)c.setColor4(s,o.f.FromArray(e.colors4[s]));for(s in e.vectors2)c.setVector2(s,o.w.FromArray(e.vectors2[s]));for(s in e.vectors3)c.setVector3(s,o.x.FromArray(e.vectors3[s]));for(s in e.vectors4)c.setVector4(s,o.y.FromArray(e.vectors4[s]));for(s in e.matrices)c.setMatrix(s,o.j.FromArray(e.matrices[s]));for(s in e.matrices3x3)c.setMatrix3x3(s,e.matrices3x3[s]);for(s in e.matrices2x2)c.setMatrix2x2(s,e.matrices2x2[s]);for(s in e.vectors2Arrays)c.setArray2(s,e.vectors2Arrays[s]);for(s in e.vectors3Arrays)c.setArray3(s,e.vectors3Arrays[s]);return c},t}(u.a);h.a.RegisteredTypes["BABYLON.ShaderMaterial"]=d},function(e,t,i){"use strict";i.d(t,"a",function(){return o});var r=i(34),n=i(0),o=function(){function e(e,t,i){this.vectors=r.a.BuildArray(8,n.x.Zero),this.center=n.x.Zero(),this.centerWorld=n.x.Zero(),this.extendSize=n.x.Zero(),this.extendSizeWorld=n.x.Zero(),this.directions=r.a.BuildArray(3,n.x.Zero),this.vectorsWorld=r.a.BuildArray(8,n.x.Zero),this.minimumWorld=n.x.Zero(),this.maximumWorld=n.x.Zero(),this.minimum=n.x.Zero(),this.maximum=n.x.Zero(),this.reConstruct(e,t,i)}return e.prototype.reConstruct=function(e,t,i){var r=e.x,o=e.y,s=e.z,a=t.x,c=t.y,l=t.z,u=this.vectors;this.minimum.copyFromFloats(r,o,s),this.maximum.copyFromFloats(a,c,l),u[0].copyFromFloats(r,o,s),u[1].copyFromFloats(a,c,l),u[2].copyFromFloats(a,o,s),u[3].copyFromFloats(r,c,s),u[4].copyFromFloats(r,o,l),u[5].copyFromFloats(a,c,s),u[6].copyFromFloats(r,c,l),u[7].copyFromFloats(a,o,l),t.addToRef(e,this.center).scaleInPlace(.5),t.subtractToRef(e,this.extendSize).scaleInPlace(.5),this._update(i||n.j.IdentityReadOnly)},e.prototype.scale=function(t){var i=e.TmpVector3,r=this.maximum.subtractToRef(this.minimum,i[0]),n=r.length();r.normalizeFromLength(n);var o=n*t,s=r.scaleInPlace(.5*o),a=this.center.subtractToRef(s,i[1]),c=this.center.addToRef(s,i[2]);return this.reConstruct(a,c,this._worldMatrix),this},e.prototype.getWorldMatrix=function(){return this._worldMatrix},e.prototype._update=function(e){var t=this.minimumWorld,i=this.maximumWorld,r=this.directions,o=this.vectorsWorld,s=this.vectors;if(e.isIdentity()){t.copyFrom(this.minimum),i.copyFrom(this.maximum);for(a=0;a<8;++a)o[a].copyFrom(s[a]);this.extendSizeWorld.copyFrom(this.extendSize),this.centerWorld.copyFrom(this.center)}else{t.setAll(Number.MAX_VALUE),i.setAll(-Number.MAX_VALUE);for(var a=0;a<8;++a){var c=o[a];n.x.TransformCoordinatesToRef(s[a],e,c),t.minimizeInPlace(c),i.maximizeInPlace(c)}i.subtractToRef(t,this.extendSizeWorld).scaleInPlace(.5),i.addToRef(t,this.centerWorld).scaleInPlace(.5)}n.x.FromArrayToRef(e.m,0,r[0]),n.x.FromArrayToRef(e.m,4,r[1]),n.x.FromArrayToRef(e.m,8,r[2]),this._worldMatrix=e},e.prototype.isInFrustum=function(t){return e.IsInFrustum(this.vectorsWorld,t)},e.prototype.isCompletelyInFrustum=function(t){return e.IsCompletelyInFrustum(this.vectorsWorld,t)},e.prototype.intersectsPoint=function(e){var t=this.minimumWorld,i=this.maximumWorld,r=t.x,o=t.y,s=t.z,a=i.x,c=i.y,l=i.z,u=e.x,h=e.y,d=e.z,f=-n.h;return!(a-u<f||f>u-r)&&(!(c-h<f||f>h-o)&&!(l-d<f||f>d-s))},e.prototype.intersectsSphere=function(t){return e.IntersectsSphere(this.minimumWorld,this.maximumWorld,t.centerWorld,t.radiusWorld)},e.prototype.intersectsMinMax=function(e,t){var i=this.minimumWorld,r=this.maximumWorld,n=i.x,o=i.y,s=i.z,a=r.x,c=r.y,l=r.z,u=e.x,h=e.y,d=e.z,f=t.x,p=t.y,_=t.z;return!(a<u||n>f)&&(!(c<h||o>p)&&!(l<d||s>_))},e.Intersects=function(e,t){return e.intersectsMinMax(t.minimumWorld,t.maximumWorld)},e.IntersectsSphere=function(t,i,r,o){var s=e.TmpVector3[0];return n.x.ClampToRef(r,t,i,s),n.x.DistanceSquared(r,s)<=o*o},e.IsCompletelyInFrustum=function(e,t){for(var i=0;i<6;++i)for(var r=t[i],n=0;n<8;++n)if(r.dotCoordinate(e[n])<0)return!1;return!0},e.IsInFrustum=function(e,t){for(var i=0;i<6;++i){for(var r=!0,n=t[i],o=0;o<8;++o)if(n.dotCoordinate(e[o])>=0){r=!1;break}if(r)return!1}return!0},e.TmpVector3=r.a.BuildArray(3,n.x.Zero),e}()},function(e,t,i){"use strict";i.d(t,"a",function(){return n});var r=i(3),n=function(){function e(){this.hoverCursor="",this.actions=new Array}return Object.defineProperty(e,"HasTriggers",{get:function(){for(var t in e.Triggers)if(e.Triggers.hasOwnProperty(t))return!0;return!1},enumerable:!0,configurable:!0}),Object.defineProperty(e,"HasPickTriggers",{get:function(){for(var t in e.Triggers)if(e.Triggers.hasOwnProperty(t)){var i=parseInt(t);if(i>=r.a.ACTION_OnPickTrigger&&i<=r.a.ACTION_OnPickUpTrigger)return!0}return!1},enumerable:!0,configurable:!0}),e.HasSpecificTrigger=function(t){for(var i in e.Triggers){if(e.Triggers.hasOwnProperty(i))if(parseInt(i)===t)return!0}return!1},e.Triggers={},e}()},function(e,t,i){"use strict";i.d(t,"a",function(){return o});var r=i(10),n=i(13);n.a.CreatePlane=function(e){var t=[],i=[],r=[],o=[],s=e.width||e.size||1,a=e.height||e.size||1,c=0===e.sideOrientation?0:e.sideOrientation||n.a.DEFAULTSIDE,l=s/2,u=a/2;i.push(-l,-u,0),r.push(0,0,-1),o.push(0,0),i.push(l,-u,0),r.push(0,0,-1),o.push(1,0),i.push(l,u,0),r.push(0,0,-1),o.push(1,1),i.push(-l,u,0),r.push(0,0,-1),o.push(0,1),t.push(0),t.push(1),t.push(2),t.push(0),t.push(2),t.push(3),n.a._ComputeSides(c,i,t,r,o,e.frontUVs,e.backUVs);var h=new n.a;return h.indices=t,h.positions=i,h.normals=r,h.uvs=o,h},r.a.CreatePlane=function(e,t,i,r,n){var s={size:t,width:t,height:t,sideOrientation:n,updatable:r};return o.CreatePlane(e,s,i)};var o=function(){function e(){}return e.CreatePlane=function(e,t,i){var o=new r.a(e,i);return t.sideOrientation=r.a._GetDefaultSideOrientation(t.sideOrientation),o._originalBuilderSideOrientation=t.sideOrientation,n.a.CreatePlane(t).applyToMesh(o,t.updatable),t.sourcePlane&&(o.translate(t.sourcePlane.normal,-t.sourcePlane.d),o.setDirection(t.sourcePlane.normal.scale(-1))),o},e}()},function(e,t,i){"use strict";i.d(t,"a",function(){return o});var r=i(34),n=i(0),o=function(){function e(e,t,i){this.center=n.x.Zero(),this.centerWorld=n.x.Zero(),this.minimum=n.x.Zero(),this.maximum=n.x.Zero(),this.reConstruct(e,t,i)}return e.prototype.reConstruct=function(e,t,i){this.minimum.copyFrom(e),this.maximum.copyFrom(t);var r=n.x.Distance(e,t);t.addToRef(e,this.center).scaleInPlace(.5),this.radius=.5*r,this._update(i||n.j.IdentityReadOnly)},e.prototype.scale=function(t){var i=this.radius*t,r=e.TmpVector3,n=r[0].setAll(i),o=this.center.subtractToRef(n,r[1]),s=this.center.addToRef(n,r[2]);return this.reConstruct(o,s,this._worldMatrix),this},e.prototype.getWorldMatrix=function(){return this._worldMatrix},e.prototype._update=function(t){if(t.isIdentity())this.centerWorld.copyFrom(this.center),this.radiusWorld=this.radius;else{n.x.TransformCoordinatesToRef(this.center,t,this.centerWorld);var i=e.TmpVector3[0];n.x.TransformNormalFromFloatsToRef(1,1,1,t,i),this.radiusWorld=Math.max(Math.abs(i.x),Math.abs(i.y),Math.abs(i.z))*this.radius}},e.prototype.isInFrustum=function(e){for(var t=this.centerWorld,i=this.radiusWorld,r=0;r<6;r++)if(e[r].dotCoordinate(t)<=-i)return!1;return!0},e.prototype.isCenterInFrustum=function(e){for(var t=this.centerWorld,i=0;i<6;i++)if(e[i].dotCoordinate(t)<0)return!1;return!0},e.prototype.intersectsPoint=function(e){var t=n.x.DistanceSquared(this.centerWorld,e);return!(this.radiusWorld*this.radiusWorld<t)},e.Intersects=function(e,t){var i=n.x.DistanceSquared(e.centerWorld,t.centerWorld),r=e.radiusWorld+t.radiusWorld;return!(r*r<i)},e.TmpVector3=r.a.BuildArray(3,n.x.Zero),e}()},function(e,t,i){"use strict";i.d(t,"a",function(){return s});var r=i(18),n=i(4),o=i(3),s=function(){function e(e){this._vertexBuffers={},this._scene=e}return e.prototype._prepareBuffers=function(){if(!this._vertexBuffers[n.b.PositionKind]){var e=[];e.push(1,1),e.push(-1,1),e.push(-1,-1),e.push(1,-1),this._vertexBuffers[n.b.PositionKind]=new n.b(this._scene.getEngine(),e,n.b.PositionKind,!1,!1,2),this._buildIndexBuffer()}},e.prototype._buildIndexBuffer=function(){var e=[];e.push(0),e.push(1),e.push(2),e.push(0),e.push(2),e.push(3),this._indexBuffer=this._scene.getEngine().createIndexBuffer(e)},e.prototype._rebuild=function(){var e=this._vertexBuffers[n.b.PositionKind];e&&(e._rebuild(),this._buildIndexBuffer())},e.prototype._prepareFrame=function(e,t){void 0===e&&(e=null),void 0===t&&(t=null);var i=this._scene.activeCamera;return!!i&&(!(!(t=t||i._postProcesses.filter(function(e){return null!=e}))||0===t.length||!this._scene.postProcessesEnabled)&&(t[0].activate(i,e,null!=t),!0))},e.prototype.directRender=function(e,t,i,n,o){void 0===t&&(t=null),void 0===i&&(i=!1),void 0===n&&(n=0),void 0===o&&(o=0);for(var s=this._scene.getEngine(),a=0;a<e.length;a++){a<e.length-1?e[a+1].activate(this._scene.activeCamera,t):t?s.bindFramebuffer(t,n,void 0,void 0,i,void 0,o):s.restoreDefaultFramebuffer();var c=e[a],l=c.apply();l&&(c.onBeforeRenderObservable.notifyObservers(l),this._prepareBuffers(),s.bindBuffers(this._vertexBuffers,this._indexBuffer,l),s.drawElementsType(r.a.TriangleFillMode,0,6),c.onAfterRenderObservable.notifyObservers(l))}s.setDepthBuffer(!0),s.setDepthWrite(!0)},e.prototype._finalizeFrame=function(e,t,i,n,s){void 0===s&&(s=!1);var a=this._scene.activeCamera;if(a&&0!==(n=n||a._postProcesses.filter(function(e){return null!=e})).length&&this._scene.postProcessesEnabled){for(var c=this._scene.getEngine(),l=0,u=n.length;l<u;l++){var h=n[l];if(l<u-1?h._outputTexture=n[l+1].activate(a,t):t?(c.bindFramebuffer(t,i,void 0,void 0,s),h._outputTexture=t):(c.restoreDefaultFramebuffer(),h._outputTexture=null),e)break;var d=h.apply();d&&(h.onBeforeRenderObservable.notifyObservers(d),this._prepareBuffers(),c.bindBuffers(this._vertexBuffers,this._indexBuffer,d),c.drawElementsType(r.a.TriangleFillMode,0,6),h.onAfterRenderObservable.notifyObservers(d))}c.setDepthBuffer(!0),c.setDepthWrite(!0),c.setAlphaMode(o.a.ALPHA_DISABLE)}},e.prototype.dispose=function(){var e=this._vertexBuffers[n.b.PositionKind];e&&(e.dispose(),this._vertexBuffers[n.b.PositionKind]=null),this._indexBuffer&&(this._scene.getEngine()._releaseBuffer(this._indexBuffer),this._indexBuffer=null)},e}()},function(e,t,i){"use strict";var r="lightFragmentDeclaration",n="#ifdef LIGHT{X}\nuniform vec4 vLightData{X};\nuniform vec4 vLightDiffuse{X};\n#ifdef SPECULARTERM\nuniform vec3 vLightSpecular{X};\n#else\nvec3 vLightSpecular{X}=vec3(0.);\n#endif\n#ifdef SHADOW{X}\n#if defined(SHADOWCUBE{X})\nuniform samplerCube shadowSampler{X};\n#else\nvarying vec4 vPositionFromLight{X};\nvarying float vDepthMetric{X};\n#if defined(SHADOWPCSS{X})\nuniform highp sampler2DShadow shadowSampler{X};\nuniform highp sampler2D depthSampler{X};\n#elif defined(SHADOWPCF{X})\nuniform highp sampler2DShadow shadowSampler{X};\n#else\nuniform sampler2D shadowSampler{X};\n#endif\nuniform mat4 lightMatrix{X};\n#endif\nuniform vec4 shadowsInfo{X};\nuniform vec2 depthValues{X};\n#endif\n#ifdef SPOTLIGHT{X}\nuniform vec4 vLightDirection{X};\nuniform vec4 vLightFalloff{X};\n#elif defined(POINTLIGHT{X})\nuniform vec4 vLightFalloff{X};\n#elif defined(HEMILIGHT{X})\nuniform vec3 vLightGround{X};\n#endif\n#ifdef PROJECTEDLIGHTTEXTURE{X}\nuniform mat4 textureProjectionMatrix{X};\nuniform sampler2D projectionLightSampler{X};\n#endif\n#endif";i(5).a.IncludesShadersStore[r]=n},function(e,t,i){"use strict";var r="lightUboDeclaration",n="#ifdef LIGHT{X}\nuniform Light{X}\n{\nvec4 vLightData;\nvec4 vLightDiffuse;\nvec3 vLightSpecular;\n#ifdef SPOTLIGHT{X}\nvec4 vLightDirection;\nvec4 vLightFalloff;\n#elif defined(POINTLIGHT{X})\nvec4 vLightFalloff;\n#elif defined(HEMILIGHT{X})\nvec3 vLightGround;\n#endif\nvec4 shadowsInfo;\nvec2 depthValues;\n} light{X};\n#ifdef PROJECTEDLIGHTTEXTURE{X}\nuniform mat4 textureProjectionMatrix{X};\nuniform sampler2D projectionLightSampler{X};\n#endif\n#ifdef SHADOW{X}\n#if defined(SHADOWCUBE{X})\nuniform samplerCube shadowSampler{X};\n#else\nvarying vec4 vPositionFromLight{X};\nvarying float vDepthMetric{X};\n#if defined(SHADOWPCSS{X})\nuniform highp sampler2DShadow shadowSampler{X};\nuniform highp sampler2D depthSampler{X};\n#elif defined(SHADOWPCF{X})\nuniform highp sampler2DShadow shadowSampler{X};\n#else\nuniform sampler2D shadowSampler{X};\n#endif\nuniform mat4 lightMatrix{X};\n#endif\n#endif\n#endif";i(5).a.IncludesShadersStore[r]=n},function(e,t,i){"use strict";var r="imageProcessingDeclaration",n="#ifdef EXPOSURE\nuniform float exposureLinear;\n#endif\n#ifdef CONTRAST\nuniform float contrast;\n#endif\n#ifdef VIGNETTE\nuniform vec2 vInverseScreenSize;\nuniform vec4 vignetteSettings1;\nuniform vec4 vignetteSettings2;\n#endif\n#ifdef COLORCURVES\nuniform vec4 vCameraColorCurveNegative;\nuniform vec4 vCameraColorCurveNeutral;\nuniform vec4 vCameraColorCurvePositive;\n#endif\n#ifdef COLORGRADING\n#ifdef COLORGRADING3D\nuniform highp sampler3D txColorTransform;\n#else\nuniform sampler2D txColorTransform;\n#endif\nuniform vec4 colorTransformSettings;\n#endif";i(5).a.IncludesShadersStore[r]=n},function(e,t,i){"use strict";var r="imageProcessingFunctions",n="#if defined(COLORGRADING) && !defined(COLORGRADING3D)\n\nvec3 sampleTexture3D(sampler2D colorTransform,vec3 color,vec2 sampler3dSetting)\n{\nfloat sliceSize=2.0*sampler3dSetting.x;\n#ifdef SAMPLER3DGREENDEPTH\nfloat sliceContinuous=(color.g-sampler3dSetting.x)*sampler3dSetting.y;\n#else\nfloat sliceContinuous=(color.b-sampler3dSetting.x)*sampler3dSetting.y;\n#endif\nfloat sliceInteger=floor(sliceContinuous);\n\n\nfloat sliceFraction=sliceContinuous-sliceInteger;\n#ifdef SAMPLER3DGREENDEPTH\nvec2 sliceUV=color.rb;\n#else\nvec2 sliceUV=color.rg;\n#endif\nsliceUV.x*=sliceSize;\nsliceUV.x+=sliceInteger*sliceSize;\nsliceUV=clamp(sliceUV,0.,1.);\nvec4 slice0Color=texture2D(colorTransform,sliceUV);\nsliceUV.x+=sliceSize;\nsliceUV=clamp(sliceUV,0.,1.);\nvec4 slice1Color=texture2D(colorTransform,sliceUV);\nvec3 result=mix(slice0Color.rgb,slice1Color.rgb,sliceFraction);\n#ifdef SAMPLER3DBGRMAP\ncolor.rgb=result.rgb;\n#else\ncolor.rgb=result.bgr;\n#endif\nreturn color;\n}\n#endif\n#ifdef TONEMAPPING_ACES\n\n\n\n\n\nconst mat3 ACESInputMat=mat3(\nvec3(0.59719,0.07600,0.02840),\nvec3(0.35458,0.90834,0.13383),\nvec3(0.04823,0.01566,0.83777)\n);\n\nconst mat3 ACESOutputMat=mat3(\nvec3( 1.60475,-0.10208,-0.00327),\nvec3(-0.53108,1.10813,-0.07276),\nvec3(-0.07367,-0.00605,1.07602)\n);\nvec3 RRTAndODTFit(vec3 v)\n{\nvec3 a=v*(v+0.0245786)-0.000090537;\nvec3 b=v*(0.983729*v+0.4329510)+0.238081;\nreturn a/b;\n}\nvec3 ACESFitted(vec3 color)\n{\ncolor=ACESInputMat*color;\n\ncolor=RRTAndODTFit(color);\ncolor=ACESOutputMat*color;\n\ncolor=clamp(color,0.0,1.0);\nreturn color;\n}\n#endif\nvec4 applyImageProcessing(vec4 result) {\n#ifdef EXPOSURE\nresult.rgb*=exposureLinear;\n#endif\n#ifdef VIGNETTE\n\nvec2 viewportXY=gl_FragCoord.xy*vInverseScreenSize;\nviewportXY=viewportXY*2.0-1.0;\nvec3 vignetteXY1=vec3(viewportXY*vignetteSettings1.xy+vignetteSettings1.zw,1.0);\nfloat vignetteTerm=dot(vignetteXY1,vignetteXY1);\nfloat vignette=pow(vignetteTerm,vignetteSettings2.w);\n\nvec3 vignetteColor=vignetteSettings2.rgb;\n#ifdef VIGNETTEBLENDMODEMULTIPLY\nvec3 vignetteColorMultiplier=mix(vignetteColor,vec3(1,1,1),vignette);\nresult.rgb*=vignetteColorMultiplier;\n#endif\n#ifdef VIGNETTEBLENDMODEOPAQUE\nresult.rgb=mix(vignetteColor,result.rgb,vignette);\n#endif\n#endif\n#ifdef TONEMAPPING\n#ifdef TONEMAPPING_ACES\nresult.rgb=ACESFitted(result.rgb);\n#else\nconst float tonemappingCalibration=1.590579;\nresult.rgb=1.0-exp2(-tonemappingCalibration*result.rgb);\n#endif\n#endif\n\nresult.rgb=toGammaSpace(result.rgb);\nresult.rgb=clamp(result.rgb,0.0,1.0);\n#ifdef CONTRAST\n\nvec3 resultHighContrast=applyEaseInOut(result.rgb);\nif (contrast<1.0) {\n\nresult.rgb=mix(vec3(0.5,0.5,0.5),result.rgb,contrast);\n} else {\n\nresult.rgb=mix(result.rgb,resultHighContrast,contrast-1.0);\n}\n#endif\n\n#ifdef COLORGRADING\nvec3 colorTransformInput=result.rgb*colorTransformSettings.xxx+colorTransformSettings.yyy;\n#ifdef COLORGRADING3D\nvec3 colorTransformOutput=texture(txColorTransform,colorTransformInput).rgb;\n#else\nvec3 colorTransformOutput=sampleTexture3D(txColorTransform,colorTransformInput,colorTransformSettings.yz).rgb;\n#endif\nresult.rgb=mix(result.rgb,colorTransformOutput,colorTransformSettings.www);\n#endif\n#ifdef COLORCURVES\n\nfloat luma=getLuminance(result.rgb);\nvec2 curveMix=clamp(vec2(luma*3.0-1.5,luma*-3.0+1.5),vec2(0.0),vec2(1.0));\nvec4 colorCurve=vCameraColorCurveNeutral+curveMix.x*vCameraColorCurvePositive-curveMix.y*vCameraColorCurveNegative;\nresult.rgb*=colorCurve.rgb;\nresult.rgb=mix(vec3(luma),result.rgb,colorCurve.a);\n#endif\nreturn result;\n}";i(5).a.IncludesShadersStore[r]=n},function(e,t,i){"use strict";var r="logDepthDeclaration",n="#ifdef LOGARITHMICDEPTH\nuniform float logarithmicDepthConstant;\nvarying float vFragmentDepth;\n#endif";i(5).a.IncludesShadersStore[r]=n},function(e,t,i){"use strict";i.d(t,"a",function(){return r});var r=function(){return function(e,t,i){this.bu=e,this.bv=t,this.distance=i,this.faceId=0,this.subMeshId=0}}()},function(e,t,i){"use strict";i.d(t,"a",function(){return n}),i.d(t,"b",function(){return o});var r=i(102),n=function(){return function(){}}(),o=function(){function e(t){this._useSceneAutoClearSetup=!1,this._renderingGroups=new Array,this._autoClearDepthStencil={},this._customOpaqueSortCompareFn={},this._customAlphaTestSortCompareFn={},this._customTransparentSortCompareFn={},this._renderingGroupInfo=new n,this._scene=t;for(var i=e.MIN_RENDERINGGROUPS;i<e.MAX_RENDERINGGROUPS;i++)this._autoClearDepthStencil[i]={autoClear:!0,depth:!0,stencil:!0}}return e.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)},e.prototype.render=function(t,i,r,n){var o=this._renderingGroupInfo;if(o.scene=this._scene,o.camera=this._scene.activeCamera,this._scene.spriteManagers&&n)for(var s=0;s<this._scene.spriteManagers.length;s++){var a=this._scene.spriteManagers[s];this.dispatchSprites(a)}for(s=e.MIN_RENDERINGGROUPS;s<e.MAX_RENDERINGGROUPS;s++){this._depthStencilBufferAlreadyCleaned=s===e.MIN_RENDERINGGROUPS;var c=this._renderingGroups[s];if(c){var l=Math.pow(2,s);if(o.renderingGroupId=s,this._scene.onBeforeRenderingGroupObservable.notifyObservers(o,l),e.AUTOCLEAR){var u=this._useSceneAutoClearSetup?this._scene.getAutoClearDepthStencilSetup(s):this._autoClearDepthStencil[s];u&&u.autoClear&&this._clearDepthStencilBuffer(u.depth,u.stencil)}for(var h=0,d=this._scene._beforeRenderingGroupDrawStage;h<d.length;h++){d[h].action(s)}c.render(t,n,r,i);for(var f=0,p=this._scene._afterRenderingGroupDrawStage;f<p.length;f++){p[f].action(s)}this._scene.onAfterRenderingGroupObservable.notifyObservers(o,l)}}},e.prototype.reset=function(){for(var t=e.MIN_RENDERINGGROUPS;t<e.MAX_RENDERINGGROUPS;t++){var i=this._renderingGroups[t];i&&i.prepare()}},e.prototype.dispose=function(){this.freeRenderingGroups(),this._renderingGroups.length=0,this._renderingGroupInfo=null},e.prototype.freeRenderingGroups=function(){for(var t=e.MIN_RENDERINGGROUPS;t<e.MAX_RENDERINGGROUPS;t++){var i=this._renderingGroups[t];i&&i.dispose()}},e.prototype._prepareRenderingGroup=function(e){void 0===this._renderingGroups[e]&&(this._renderingGroups[e]=new r.a(e,this._scene,this._customOpaqueSortCompareFn[e],this._customAlphaTestSortCompareFn[e],this._customTransparentSortCompareFn[e]))},e.prototype.dispatchSprites=function(e){var t=e.renderingGroupId||0;this._prepareRenderingGroup(t),this._renderingGroups[t].dispatchSprites(e)},e.prototype.dispatchParticles=function(e){var t=e.renderingGroupId||0;this._prepareRenderingGroup(t),this._renderingGroups[t].dispatchParticles(e)},e.prototype.dispatch=function(e,t,i){void 0===t&&(t=e.getMesh());var r=t.renderingGroupId||0;this._prepareRenderingGroup(r),this._renderingGroups[r].dispatch(e,t,i)},e.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]}},e.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}},e.prototype.getAutoClearDepthStencilSetup=function(e){return this._autoClearDepthStencil[e]},e.MAX_RENDERINGGROUPS=4,e.MIN_RENDERINGGROUPS=0,e.AUTOCLEAR=!0,e}()},function(e,t,i){"use strict";i.d(t,"a",function(){return r});var r=function(){return function(){}}()},function(e,t,i){"use strict";i.d(t,"a",function(){return s});var r=i(1),n=i(2),o=i(0),s=function(){function e(){this._dirty=!0,this._tempColor=new o.f(0,0,0,0),this._globalCurve=new o.f(0,0,0,0),this._highlightsCurve=new o.f(0,0,0,0),this._midtonesCurve=new o.f(0,0,0,0),this._shadowsCurve=new o.f(0,0,0,0),this._positiveCurve=new o.f(0,0,0,0),this._negativeCurve=new o.f(0,0,0,0),this._globalHue=30,this._globalDensity=0,this._globalSaturation=0,this._globalExposure=0,this._highlightsHue=30,this._highlightsDensity=0,this._highlightsSaturation=0,this._highlightsExposure=0,this._midtonesHue=30,this._midtonesDensity=0,this._midtonesSaturation=0,this._midtonesExposure=0,this._shadowsHue=30,this._shadowsDensity=0,this._shadowsSaturation=0,this._shadowsExposure=0}return Object.defineProperty(e.prototype,"globalHue",{get:function(){return this._globalHue},set:function(e){this._globalHue=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"globalDensity",{get:function(){return this._globalDensity},set:function(e){this._globalDensity=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"globalSaturation",{get:function(){return this._globalSaturation},set:function(e){this._globalSaturation=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"globalExposure",{get:function(){return this._globalExposure},set:function(e){this._globalExposure=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"highlightsHue",{get:function(){return this._highlightsHue},set:function(e){this._highlightsHue=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"highlightsDensity",{get:function(){return this._highlightsDensity},set:function(e){this._highlightsDensity=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"highlightsSaturation",{get:function(){return this._highlightsSaturation},set:function(e){this._highlightsSaturation=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"highlightsExposure",{get:function(){return this._highlightsExposure},set:function(e){this._highlightsExposure=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"midtonesHue",{get:function(){return this._midtonesHue},set:function(e){this._midtonesHue=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"midtonesDensity",{get:function(){return this._midtonesDensity},set:function(e){this._midtonesDensity=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"midtonesSaturation",{get:function(){return this._midtonesSaturation},set:function(e){this._midtonesSaturation=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"midtonesExposure",{get:function(){return this._midtonesExposure},set:function(e){this._midtonesExposure=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"shadowsHue",{get:function(){return this._shadowsHue},set:function(e){this._shadowsHue=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"shadowsDensity",{get:function(){return this._shadowsDensity},set:function(e){this._shadowsDensity=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"shadowsSaturation",{get:function(){return this._shadowsSaturation},set:function(e){this._shadowsSaturation=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"shadowsExposure",{get:function(){return this._shadowsExposure},set:function(e){this._shadowsExposure=e,this._dirty=!0},enumerable:!0,configurable:!0}),e.prototype.getClassName=function(){return"ColorCurves"},e.Bind=function(e,t,i,r,n){void 0===i&&(i="vCameraColorCurvePositive"),void 0===r&&(r="vCameraColorCurveNeutral"),void 0===n&&(n="vCameraColorCurveNegative"),e._dirty&&(e._dirty=!1,e.getColorGradingDataToRef(e._globalHue,e._globalDensity,e._globalSaturation,e._globalExposure,e._globalCurve),e.getColorGradingDataToRef(e._highlightsHue,e._highlightsDensity,e._highlightsSaturation,e._highlightsExposure,e._tempColor),e._tempColor.multiplyToRef(e._globalCurve,e._highlightsCurve),e.getColorGradingDataToRef(e._midtonesHue,e._midtonesDensity,e._midtonesSaturation,e._midtonesExposure,e._tempColor),e._tempColor.multiplyToRef(e._globalCurve,e._midtonesCurve),e.getColorGradingDataToRef(e._shadowsHue,e._shadowsDensity,e._shadowsSaturation,e._shadowsExposure,e._tempColor),e._tempColor.multiplyToRef(e._globalCurve,e._shadowsCurve),e._highlightsCurve.subtractToRef(e._midtonesCurve,e._positiveCurve),e._midtonesCurve.subtractToRef(e._shadowsCurve,e._negativeCurve)),t&&(t.setFloat4(i,e._positiveCurve.r,e._positiveCurve.g,e._positiveCurve.b,e._positiveCurve.a),t.setFloat4(r,e._midtonesCurve.r,e._midtonesCurve.g,e._midtonesCurve.b,e._midtonesCurve.a),t.setFloat4(n,e._negativeCurve.r,e._negativeCurve.g,e._negativeCurve.b,e._negativeCurve.a))},e.PrepareUniforms=function(e){e.push("vCameraColorCurveNeutral","vCameraColorCurvePositive","vCameraColorCurveNegative")},e.prototype.getColorGradingDataToRef=function(t,i,r,n,o){null!=t&&(t=e.clamp(t,0,360),i=e.clamp(i,-100,100),r=e.clamp(r,-100,100),n=e.clamp(n,-100,100),i=e.applyColorGradingSliderNonlinear(i),i*=.5,n=e.applyColorGradingSliderNonlinear(n),i<0&&(i*=-1,t=(t+180)%360),e.fromHSBToRef(t,i,50+.25*n,o),o.scaleToRef(2,o),o.a=1+.01*r)},e.applyColorGradingSliderNonlinear=function(e){e/=100;var t=Math.abs(e);return t=Math.pow(t,2),e<0&&(t*=-1),t*=100},e.fromHSBToRef=function(t,i,r,n){var o=e.clamp(t,0,360),s=e.clamp(i/100,0,1),a=e.clamp(r/100,0,1);if(0===s)n.r=a,n.g=a,n.b=a;else{o/=60;var c=Math.floor(o),l=o-c,u=a*(1-s),h=a*(1-s*l),d=a*(1-s*(1-l));switch(c){case 0:n.r=a,n.g=d,n.b=u;break;case 1:n.r=h,n.g=a,n.b=u;break;case 2:n.r=u,n.g=a,n.b=d;break;case 3:n.r=u,n.g=h,n.b=a;break;case 4:n.r=d,n.g=u,n.b=a;break;default:n.r=a,n.g=u,n.b=h}}n.a=1},e.clamp=function(e,t,i){return Math.min(Math.max(e,t),i)},e.prototype.clone=function(){return n.a.Clone(function(){return new e},this)},e.prototype.serialize=function(){return n.a.Serialize(this)},e.Parse=function(t){return n.a.Parse(function(){return new e},t,null,null)},r.c([Object(n.c)()],e.prototype,"_globalHue",void 0),r.c([Object(n.c)()],e.prototype,"_globalDensity",void 0),r.c([Object(n.c)()],e.prototype,"_globalSaturation",void 0),r.c([Object(n.c)()],e.prototype,"_globalExposure",void 0),r.c([Object(n.c)()],e.prototype,"_highlightsHue",void 0),r.c([Object(n.c)()],e.prototype,"_highlightsDensity",void 0),r.c([Object(n.c)()],e.prototype,"_highlightsSaturation",void 0),r.c([Object(n.c)()],e.prototype,"_highlightsExposure",void 0),r.c([Object(n.c)()],e.prototype,"_midtonesHue",void 0),r.c([Object(n.c)()],e.prototype,"_midtonesDensity",void 0),r.c([Object(n.c)()],e.prototype,"_midtonesSaturation",void 0),r.c([Object(n.c)()],e.prototype,"_midtonesExposure",void 0),e}();n.a._ColorCurvesParser=s.Parse},function(e,t,i){"use strict";var r=function(){function e(){this._isAlphaBlendDirty=!1,this._isBlendFunctionParametersDirty=!1,this._isBlendEquationParametersDirty=!1,this._isBlendConstantsDirty=!1,this._alphaBlend=!1,this._blendFunctionParameters=new Array(4),this._blendEquationParameters=new Array(2),this._blendConstants=new Array(4),this.reset()}return Object.defineProperty(e.prototype,"isDirty",{get:function(){return this._isAlphaBlendDirty||this._isBlendFunctionParametersDirty},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"alphaBlend",{get:function(){return this._alphaBlend},set:function(e){this._alphaBlend!==e&&(this._alphaBlend=e,this._isAlphaBlendDirty=!0)},enumerable:!0,configurable:!0}),e.prototype.setAlphaBlendConstants=function(e,t,i,r){this._blendConstants[0]===e&&this._blendConstants[1]===t&&this._blendConstants[2]===i&&this._blendConstants[3]===r||(this._blendConstants[0]=e,this._blendConstants[1]=t,this._blendConstants[2]=i,this._blendConstants[3]=r,this._isBlendConstantsDirty=!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.setAlphaEquationParameters=function(e,t){this._blendEquationParameters[0]===e&&this._blendEquationParameters[1]===t||(this._blendEquationParameters[0]=e,this._blendEquationParameters[1]=t,this._isBlendEquationParametersDirty=!0)},e.prototype.reset=function(){this._alphaBlend=!1,this._blendFunctionParameters[0]=null,this._blendFunctionParameters[1]=null,this._blendFunctionParameters[2]=null,this._blendFunctionParameters[3]=null,this._blendEquationParameters[0]=null,this._blendEquationParameters[1]=null,this._blendConstants[0]=null,this._blendConstants[1]=null,this._blendConstants[2]=null,this._blendConstants[3]=null,this._isAlphaBlendDirty=!0,this._isBlendFunctionParametersDirty=!1,this._isBlendEquationParametersDirty=!1,this._isBlendConstantsDirty=!1},e.prototype.apply=function(e){this.isDirty&&(this._isAlphaBlendDirty&&(this._alphaBlend?e.enable(e.BLEND):e.disable(e.BLEND),this._isAlphaBlendDirty=!1),this._isBlendFunctionParametersDirty&&(e.blendFuncSeparate(this._blendFunctionParameters[0],this._blendFunctionParameters[1],this._blendFunctionParameters[2],this._blendFunctionParameters[3]),this._isBlendFunctionParametersDirty=!1),this._isBlendEquationParametersDirty&&(e.blendEquationSeparate(this._blendEquationParameters[0],this._blendEquationParameters[1]),this._isBlendEquationParametersDirty=!1),this._isBlendConstantsDirty&&(e.blendColor(this._blendConstants[0],this._blendConstants[1],this._blendConstants[2],this._blendConstants[3]),this._isBlendConstantsDirty=!1))},e}(),n=function(){function e(){this._isDepthTestDirty=!1,this._isDepthMaskDirty=!1,this._isDepthFuncDirty=!1,this._isCullFaceDirty=!1,this._isCullDirty=!1,this._isZOffsetDirty=!1,this._isFrontFaceDirty=!1,this.reset()}return Object.defineProperty(e.prototype,"isDirty",{get:function(){return this._isDepthFuncDirty||this._isDepthTestDirty||this._isDepthMaskDirty||this._isCullFaceDirty||this._isCullDirty||this._isZOffsetDirty||this._isFrontFaceDirty},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}),Object.defineProperty(e.prototype,"frontFace",{get:function(){return this._frontFace},set:function(e){this._frontFace!==e&&(this._frontFace=e,this._isFrontFaceDirty=!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._frontFace=null,this._isDepthTestDirty=!0,this._isDepthMaskDirty=!0,this._isDepthFuncDirty=!1,this._isCullFaceDirty=!1,this._isCullDirty=!1,this._isZOffsetDirty=!1,this._isFrontFaceDirty=!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),this._isFrontFaceDirty&&(e.frontFace(this.frontFace),this._isFrontFaceDirty=!1))},e}(),o=i(3),s=function(){function e(){this._isStencilTestDirty=!1,this._isStencilMaskDirty=!1,this._isStencilFuncDirty=!1,this._isStencilOpDirty=!1,this.reset()}return Object.defineProperty(e.prototype,"isDirty",{get:function(){return this._isStencilTestDirty||this._isStencilMaskDirty||this._isStencilFuncDirty||this._isStencilOpDirty},enumerable:!0,configurable:!0}),Object.defineProperty(e.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(e.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(e.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(e.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(e.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(e.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(e.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(e.prototype,"stencilTest",{get:function(){return this._stencilTest},set:function(e){this._stencilTest!==e&&(this._stencilTest=e,this._isStencilTestDirty=!0)},enumerable:!0,configurable:!0}),e.prototype.reset=function(){this._stencilTest=!1,this._stencilMask=255,this._stencilFunc=e.ALWAYS,this._stencilFuncRef=1,this._stencilFuncMask=255,this._stencilOpStencilFail=e.KEEP,this._stencilOpDepthFail=e.KEEP,this._stencilOpStencilDepthPass=e.REPLACE,this._isStencilTestDirty=!0,this._isStencilMaskDirty=!0,this._isStencilFuncDirty=!0,this._isStencilOpDirty=!0},e.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))},e.ALWAYS=o.a.ALWAYS,e.KEEP=o.a.KEEP,e.REPLACE=o.a.REPLACE,e}();i.d(t,"a",function(){return r}),i.d(t,"b",function(){return n}),i.d(t,"c",function(){return s})},function(e,t,i){"use strict";var r="clipPlaneFragment",n="#ifdef CLIPPLANE\nif (fClipDistance>0.0)\n{\ndiscard;\n}\n#endif\n#ifdef CLIPPLANE2\nif (fClipDistance2>0.0)\n{\ndiscard;\n}\n#endif\n#ifdef CLIPPLANE3\nif (fClipDistance3>0.0)\n{\ndiscard;\n}\n#endif\n#ifdef CLIPPLANE4\nif (fClipDistance4>0.0)\n{\ndiscard;\n}\n#endif";i(5).a.IncludesShadersStore[r]=n},function(e,t,i){"use strict";var r="clipPlaneVertex",n="#ifdef CLIPPLANE\nfClipDistance=dot(worldPos,vClipPlane);\n#endif\n#ifdef CLIPPLANE2\nfClipDistance2=dot(worldPos,vClipPlane2);\n#endif\n#ifdef CLIPPLANE3\nfClipDistance3=dot(worldPos,vClipPlane3);\n#endif\n#ifdef CLIPPLANE4\nfClipDistance4=dot(worldPos,vClipPlane4);\n#endif";i(5).a.IncludesShadersStore[r]=n},function(e,t,i){"use strict";i.d(t,"a",function(){return r});var r=function(){return function(){this.previous=null,this.next=null}}()},function(e,t,i){"use strict";i.r(t);var r=i(30),n=i(7),o=i(0),s=i(20),a=function(){function e(e,t){this.triggerOptions=e,this.onBeforeExecuteObservable=new n.c,e.parameter?(this.trigger=e.trigger,this._triggerParameter=e.parameter):e.trigger?this.trigger=e.trigger: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.onBeforeExecuteObservable.notifyObservers(this),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._SerializeValueAsString=function(e){return"number"==typeof e?e.toString():"boolean"==typeof e?e?"true":"false":e instanceof o.w?e.x+", "+e.y:e instanceof o.x?e.x+", "+e.y+", "+e.z:e instanceof o.e?e.r+", "+e.g+", "+e.b:e instanceof o.f?e.r+", "+e.g+", "+e.b+", "+e.a:e},e._GetTargetProperty=function(e){return{name:"target",targetType:e._isMesh?"MeshProperties":e._isLight?"LightProperties":e._isCamera?"CameraProperties":"SceneProperties",value:e._isScene?"Scene":e.name}},e}();s.a.RegisteredTypes["BABYLON.Action"]=a;var c=i(37),l=i(1),u=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}(),h=function(e){function t(i,r,n,o,s){void 0===s&&(s=t.IsEqual);var a=e.call(this,i)||this;return a.propertyPath=n,a.value=o,a.operator=s,a._target=r,a._effectiveTarget=a._getEffectiveTarget(r,a.propertyPath),a._property=a._getProperty(a.propertyPath),a}return l.d(t,e),Object.defineProperty(t,"IsEqual",{get:function(){return t._IsEqual},enumerable:!0,configurable:!0}),Object.defineProperty(t,"IsDifferent",{get:function(){return t._IsDifferent},enumerable:!0,configurable:!0}),Object.defineProperty(t,"IsGreater",{get:function(){return t._IsGreater},enumerable:!0,configurable:!0}),Object.defineProperty(t,"IsLesser",{get:function(){return t._IsLesser},enumerable:!0,configurable:!0}),t.prototype.isValid=function(){switch(this.operator){case t.IsGreater:return this._effectiveTarget[this._property]>this.value;case t.IsLesser:return this._effectiveTarget[this._property]<this.value;case t.IsEqual:case t.IsDifferent:var e;return e=this.value.equals?this.value.equals(this._effectiveTarget[this._property]):this.value===this._effectiveTarget[this._property],this.operator===t.IsEqual?e:!e}return!1},t.prototype.serialize=function(){return this._serialize({name:"ValueCondition",properties:[a._GetTargetProperty(this._target),{name:"propertyPath",value:this.propertyPath},{name:"value",value:a._SerializeValueAsString(this.value)},{name:"operator",value:t.GetOperatorName(this.operator)}]})},t.GetOperatorName=function(e){switch(e){case t._IsEqual:return"IsEqual";case t._IsDifferent:return"IsDifferent";case t._IsGreater:return"IsGreater";case t._IsLesser:return"IsLesser";default:return""}},t._IsEqual=0,t._IsDifferent=1,t._IsGreater=2,t._IsLesser=3,t}(u),d=function(e){function t(t,i){var r=e.call(this,t)||this;return r.predicate=i,r}return l.d(t,e),t.prototype.isValid=function(){return this.predicate()},t}(u),f=function(e){function t(t,i,r){var n=e.call(this,t)||this;return n.value=r,n._target=i,n}return l.d(t,e),t.prototype.isValid=function(){return this._target.state===this.value},t.prototype.serialize=function(){return this._serialize({name:"StateCondition",properties:[a._GetTargetProperty(this._target),{name:"value",value:this.value}]})},t}(u);s.a.RegisteredTypes["BABYLON.ValueCondition"]=h,s.a.RegisteredTypes["BABYLON.PredicateCondition"]=d,s.a.RegisteredTypes["BABYLON.StateCondition"]=f;var p=i(8),_=i(3),g=function(e){function t(t,i,r,n){var o=e.call(this,t,n)||this;return o.propertyPath=r,o._target=o._effectiveTarget=i,o}return l.d(t,e),t.prototype._prepare=function(){this._effectiveTarget=this._getEffectiveTarget(this._effectiveTarget,this.propertyPath),this._property=this._getProperty(this.propertyPath)},t.prototype.execute=function(){this._effectiveTarget[this._property]=!this._effectiveTarget[this._property]},t.prototype.serialize=function(t){return e.prototype._serialize.call(this,{name:"SwitchBooleanAction",properties:[a._GetTargetProperty(this._target),{name:"propertyPath",value:this.propertyPath}]},t)},t}(a),m=function(e){function t(t,i,r,n){var o=e.call(this,t,n)||this;return o.value=r,o._target=i,o}return l.d(t,e),t.prototype.execute=function(){this._target.state=this.value},t.prototype.serialize=function(t){return e.prototype._serialize.call(this,{name:"SetStateAction",properties:[a._GetTargetProperty(this._target),{name:"value",value:this.value}]},t)},t}(a),v=function(e){function t(t,i,r,n,o){var s=e.call(this,t,o)||this;return s.propertyPath=r,s.value=n,s._target=s._effectiveTarget=i,s}return l.d(t,e),t.prototype._prepare=function(){this._effectiveTarget=this._getEffectiveTarget(this._effectiveTarget,this.propertyPath),this._property=this._getProperty(this.propertyPath)},t.prototype.execute=function(){this._effectiveTarget[this._property]=this.value,this._target.markAsDirty&&this._target.markAsDirty(this._property)},t.prototype.serialize=function(t){return e.prototype._serialize.call(this,{name:"SetValueAction",properties:[a._GetTargetProperty(this._target),{name:"propertyPath",value:this.propertyPath},{name:"value",value:a._SerializeValueAsString(this.value)}]},t)},t}(a),y=function(e){function t(t,i,r,n,o){var s=e.call(this,t,o)||this;return s.propertyPath=r,s.value=n,s._target=s._effectiveTarget=i,s}return l.d(t,e),t.prototype._prepare=function(){this._effectiveTarget=this._getEffectiveTarget(this._effectiveTarget,this.propertyPath),this._property=this._getProperty(this.propertyPath),"number"!=typeof this._effectiveTarget[this._property]&&p.a.Warn("Warning: IncrementValueAction can only be used with number values")},t.prototype.execute=function(){this._effectiveTarget[this._property]+=this.value,this._target.markAsDirty&&this._target.markAsDirty(this._property)},t.prototype.serialize=function(t){return e.prototype._serialize.call(this,{name:"IncrementValueAction",properties:[a._GetTargetProperty(this._target),{name:"propertyPath",value:this.propertyPath},{name:"value",value:a._SerializeValueAsString(this.value)}]},t)},t}(a),b=function(e){function t(t,i,r,n,o,s){var a=e.call(this,t,s)||this;return a.from=r,a.to=n,a.loop=o,a._target=i,a}return l.d(t,e),t.prototype._prepare=function(){},t.prototype.execute=function(){this._actionManager.getScene().beginAnimation(this._target,this.from,this.to,this.loop)},t.prototype.serialize=function(t){return e.prototype._serialize.call(this,{name:"PlayAnimationAction",properties:[a._GetTargetProperty(this._target),{name:"from",value:String(this.from)},{name:"to",value:String(this.to)},{name:"loop",value:a._SerializeValueAsString(this.loop)||!1}]},t)},t}(a),T=function(e){function t(t,i,r){var n=e.call(this,t,r)||this;return n._target=i,n}return l.d(t,e),t.prototype._prepare=function(){},t.prototype.execute=function(){this._actionManager.getScene().stopAnimation(this._target)},t.prototype.serialize=function(t){return e.prototype._serialize.call(this,{name:"StopAnimationAction",properties:[a._GetTargetProperty(this._target)]},t)},t}(a),E=function(e){function t(t,i){return void 0===t&&(t=_.a.ACTION_NothingTrigger),e.call(this,t,i)||this}return l.d(t,e),t.prototype.execute=function(){},t.prototype.serialize=function(t){return e.prototype._serialize.call(this,{name:"DoNothingAction",properties:[]},t)},t}(a),x=function(e){function t(t,i,r){var n=e.call(this,t,r)||this;return n.children=i,n}return l.d(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}(a),A=function(e){function t(t,i,r){var n=e.call(this,t,r)||this;return n.func=i,n}return l.d(t,e),t.prototype.execute=function(e){this.func(e)},t}(a),P=function(e){function t(t,i,r,n){var o=e.call(this,t,n)||this;return o._target=i,o._parent=r,o}return l.d(t,e),t.prototype._prepare=function(){},t.prototype.execute=function(){if(this._target.parent!==this._parent){var e=this._parent.getWorldMatrix().clone();e.invert(),this._target.position=o.x.TransformCoordinates(this._target.position,e),this._target.parent=this._parent}},t.prototype.serialize=function(t){return e.prototype._serialize.call(this,{name:"SetParentAction",properties:[a._GetTargetProperty(this._target),a._GetTargetProperty(this._parent)]},t)},t}(a);s.a.RegisteredTypes["BABYLON.SetParentAction"]=P,s.a.RegisteredTypes["BABYLON.ExecuteCodeAction"]=A,s.a.RegisteredTypes["BABYLON.DoNothingAction"]=E,s.a.RegisteredTypes["BABYLON.StopAnimationAction"]=T,s.a.RegisteredTypes["BABYLON.PlayAnimationAction"]=b,s.a.RegisteredTypes["BABYLON.IncrementValueAction"]=y,s.a.RegisteredTypes["BABYLON.SetValueAction"]=v,s.a.RegisteredTypes["BABYLON.SetStateAction"]=m,s.a.RegisteredTypes["BABYLON.SetParentAction"]=P;var R=i(22),S=i(32),C=function(e){function t(t){var i=e.call(this)||this;return i._scene=t||R.a.LastCreatedScene,t.actionManagers.push(i),i}return l.d(t,e),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.hasSpecificTriggers2=function(e,t){for(var i=0;i<this.actions.length;i++){var r=this.actions[i];if(e==r.trigger||t==r.trigger)return!0}return!1},t.prototype.hasSpecificTrigger=function(e,t){for(var i=0;i<this.actions.length;i++){var r=this.actions[i];if(r.trigger===e){if(!t)return!0;if(t(r.getTriggerParameter()))return!0}}return!1},Object.defineProperty(t.prototype,"hasPointerTriggers",{get:function(){for(var e=0;e<this.actions.length;e++){var i=this.actions[e];if(i.trigger>=t.OnPickTrigger&&i.trigger<=t.OnPointerOutTrigger)return!0}return!1},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"hasPickTriggers",{get:function(){for(var e=0;e<this.actions.length;e++){var i=this.actions[e];if(i.trigger>=t.OnPickTrigger&&i.trigger<=t.OnPickUpTrigger)return!0}return!1},enumerable:!0,configurable:!0}),t.prototype.registerAction=function(e){return e.trigger===t.OnEveryFrameTrigger&&this.getScene().actionManager!==this?(p.a.Warn("OnEveryFrameTrigger can only be used with scene.actionManager"),null):(this.actions.push(e),t.Triggers[e.trigger]?t.Triggers[e.trigger]++:t.Triggers[e.trigger]=1,e._actionManager=this,e._prepare(),e)},t.prototype.unregisterAction=function(e){var i=this.actions.indexOf(e);return-1!==i&&(this.actions.splice(i,1),t.Triggers[e.trigger]-=1,0===t.Triggers[e.trigger]&&delete t.Triggers[e.trigger],delete e._actionManager,!0)},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(i&&(e===t.OnKeyUpTrigger||e===t.OnKeyDownTrigger)){var o=n.getTriggerParameter();if(o&&o!==i.sourceEvent.keyCode){if(!o.toLowerCase)continue;var s=o.toLowerCase();if(s!==i.sourceEvent.key){var a=i.sourceEvent.charCode?i.sourceEvent.charCode:i.sourceEvent.keyCode;if(String.fromCharCode(a).toLowerCase()!==s)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(e){for(var i={children:new Array,name:e,type:3,properties:new Array},r=0;r<this.actions.length;r++){var n={type:0,children:new Array,name:t.GetTriggerName(this.actions[r].trigger),properties:new Array},o=this.actions[r].triggerOptions;if(o&&"number"!=typeof o)if(o.parameter instanceof Node)n.properties.push(a._GetTargetProperty(o.parameter));else{var s={};S.a.DeepCopy(o.parameter,s,["mesh"]),o.parameter&&o.parameter.mesh&&(s._meshId=o.parameter.mesh.id),n.properties.push({name:"parameter",targetType:null,value:s})}this.actions[r].serialize(n),i.children.push(n)}return i},t.Parse=function(e,i,r){var n=new t(r);null===i?r.actionManager=n:i.actionManager=n;for(var a=function(e,t,i,r){if(null===r){var n=parseFloat(t);return"true"===t||"false"===t?"true"===t:isNaN(n)?t:n}for(var s=r.split("."),a=t.split(","),c=0;c<s.length;c++)i=i[s[c]];if("boolean"==typeof i)return"true"===a[0];if("string"==typeof i)return a[0];var l=new Array;for(c=0;c<a.length;c++)l.push(parseFloat(a[c]));return i instanceof o.x?o.x.FromArray(l):i instanceof o.y?o.y.FromArray(l):i instanceof o.e?o.e.FromArray(l):i instanceof o.f?o.f.FromArray(l):parseFloat(a[0])},c=function(e,i,o,l,d){if(void 0===d&&(d=null),!e.detached){var f=new Array,p=null,_=null,g=e.combine&&e.combine.length>0;if(2===e.type?f.push(n):f.push(i),g){for(var m=new Array,v=0;v<e.combine.length;v++)c(e.combine[v],t.NothingTrigger,o,l,m);f.push(m)}else for(var y=0;y<e.properties.length;y++){var b=e.properties[y].value,T=e.properties[y].name,x=e.properties[y].targetType;"target"===T?b=p=null!==x&&"SceneProperties"===x?r:r.getNodeByName(b):"parent"===T?b=r.getNodeByName(b):"sound"===T?r.getSoundByName&&(b=r.getSoundByName(b)):"propertyPath"!==T?b=2===e.type&&"operator"===T?h[b]:a(0,b,p,"value"===T?_:null):_=b,f.push(b)}if(null===d?f.push(o):f.push(null),"InterpolateValueAction"===e.name){var A=f[f.length-2];f[f.length-1]=A,f[f.length-2]=o}var P=function(e,t){var i=s.a.GetClass("BABYLON."+e);if(i){var r=Object.create(i.prototype);return r.constructor.apply(r,t),r}}(e.name,f);if(P instanceof u&&null!==o){var R=new E(i,o);l?l.then(R):n.registerAction(R),l=R}null===d?P instanceof u?(o=P,P=l):(o=null,l?l.then(P):n.registerAction(P)):d.push(P);for(y=0;y<e.children.length;y++)c(e.children[y],i,o,P,null)}},l=0;l<e.children.length;l++){var d,f=e.children[l];if(f.properties.length>0){var p=f.properties[0].value,_=null===f.properties[0].targetType?p:r.getMeshByName(p);_._meshId&&(_.mesh=r.getMeshByID(_._meshId)),d={trigger:t[f.name],parameter:_}}else d=t[f.name];for(var g=0;g<f.children.length;g++)f.detached||c(f.children[g],d,null,null)}},t.GetTriggerName=function(e){switch(e){case 0:return"NothingTrigger";case 1:return"OnPickTrigger";case 2:return"OnLeftPickTrigger";case 3:return"OnRightPickTrigger";case 4:return"OnCenterPickTrigger";case 5:return"OnPickDownTrigger";case 6:return"OnPickUpTrigger";case 7:return"OnLongPressTrigger";case 8:return"OnPointerOverTrigger";case 9:return"OnPointerOutTrigger";case 10:return"OnEveryFrameTrigger";case 11:return"OnIntersectionEnterTrigger";case 12:return"OnIntersectionExitTrigger";case 13:return"OnKeyDownTrigger";case 14:return"OnKeyUpTrigger";case 15:return"OnPickOutTrigger";default:return""}},t.NothingTrigger=_.a.ACTION_NothingTrigger,t.OnPickTrigger=_.a.ACTION_OnPickTrigger,t.OnLeftPickTrigger=_.a.ACTION_OnLeftPickTrigger,t.OnRightPickTrigger=_.a.ACTION_OnRightPickTrigger,t.OnCenterPickTrigger=_.a.ACTION_OnCenterPickTrigger,t.OnPickDownTrigger=_.a.ACTION_OnPickDownTrigger,t.OnDoublePickTrigger=_.a.ACTION_OnDoublePickTrigger,t.OnPickUpTrigger=_.a.ACTION_OnPickUpTrigger,t.OnPickOutTrigger=_.a.ACTION_OnPickOutTrigger,t.OnLongPressTrigger=_.a.ACTION_OnLongPressTrigger,t.OnPointerOverTrigger=_.a.ACTION_OnPointerOverTrigger,t.OnPointerOutTrigger=_.a.ACTION_OnPointerOutTrigger,t.OnEveryFrameTrigger=_.a.ACTION_OnEveryFrameTrigger,t.OnIntersectionEnterTrigger=_.a.ACTION_OnIntersectionEnterTrigger,t.OnIntersectionExitTrigger=_.a.ACTION_OnIntersectionExitTrigger,t.OnKeyDownTrigger=_.a.ACTION_OnKeyDownTrigger,t.OnKeyUpTrigger=15,t}(i(72).a),M=function(e){function t(t,i,r){var n=e.call(this,t,r)||this;return n._sound=i,n}return l.d(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}(a),O=function(e){function t(t,i,r){var n=e.call(this,t,r)||this;return n._sound=i,n}return l.d(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}(a);s.a.RegisteredTypes["BABYLON.PlaySoundAction"]=O,s.a.RegisteredTypes["BABYLON.StopSoundAction"]=O;var I,D=i(12),w=i(2);!function(e){e[e.STEP=1]="STEP"}(I||(I={}));var L=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}(),F=i(24),N=function(){function e(t,i,r,n,o,s){this.name=t,this.targetProperty=i,this.framePerSecond=r,this.dataType=n,this.loopMode=o,this.enableBlending=s,this._runtimeAnimations=new Array,this._events=new Array,this.blendingSpeed=.01,this._ranges={},this.targetPropertyPath=i.split("."),this.dataType=n,this.loopMode=void 0===o?e.ANIMATIONLOOPMODE_CYCLE:o}return e._PrepareAnimation=function(t,i,r,n,s,a,c,l){var u=void 0;if(!isNaN(parseFloat(s))&&isFinite(s)?u=e.ANIMATIONTYPE_FLOAT:s instanceof o.q?u=e.ANIMATIONTYPE_QUATERNION:s instanceof o.x?u=e.ANIMATIONTYPE_VECTOR3:s instanceof o.w?u=e.ANIMATIONTYPE_VECTOR2:s instanceof o.e?u=e.ANIMATIONTYPE_COLOR3:s instanceof o.r&&(u=e.ANIMATIONTYPE_SIZE),null==u)return null;var h=new e(t,i,r,u,c),d=[{frame:0,value:s},{frame:n,value:a}];return h.setKeys(d),void 0!==l&&h.setEasingFunction(l),h},e.CreateAnimation=function(t,i,r,n){var o=new e(t+"Animation",t,r,i,e.ANIMATIONLOOPMODE_CONSTANT);return o.setEasingFunction(n),o},e.CreateAndStartAnimation=function(t,i,r,n,o,s,a,c,l,u){var h=e._PrepareAnimation(t,r,n,o,s,a,c,l);return h?i.getScene().beginDirectAnimation(i,[h],0,o,1===h.loopMode,1,u):null},e.CreateAndStartHierarchyAnimation=function(t,i,r,n,o,s,a,c,l,u,h){var d=e._PrepareAnimation(t,n,o,s,a,c,l,u);return d?i.getScene().beginDirectHierarchyAnimation(i,r,[d],0,s,1===d.loopMode,1,h):null},e.CreateMergeAndStartAnimation=function(t,i,r,n,o,s,a,c,l,u){var h=e._PrepareAnimation(t,r,n,o,s,a,c,l);return h?(i.animations.push(h),i.getScene().beginAnimation(i,0,o,1===h.loopMode,1,u)):null},e.TransitionTo=function(e,t,i,r,n,o,s,a){if(void 0===a&&(a=null),s<=0)return i[e]=t,a&&a(),null;var c=n*(s/1e3);o.setKeys([{frame:0,value:i[e].clone?i[e].clone():i[e]},{frame:c,value:t}]),i.animations||(i.animations=[]),i.animations.push(o);var l=r.beginAnimation(i,0,c,!1);return l.onAnimationEnd=a,l},Object.defineProperty(e.prototype,"runtimeAnimations",{get:function(){return this._runtimeAnimations},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"hasRunningRuntimeAnimations",{get:function(){for(var e=0,t=this._runtimeAnimations;e<t.length;e++){if(!t[e].isStopped)return!0}return!1},enumerable:!0,configurable:!0}),e.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},e.prototype.addEvent=function(e){this._events.push(e)},e.prototype.removeEvents=function(e){for(var t=0;t<this._events.length;t++)this._events[t].frame===e&&(this._events.splice(t,1),t--)},e.prototype.getEvents=function(){return this._events},e.prototype.createRange=function(e,t,i){this._ranges[e]||(this._ranges[e]=new L(e,t,i))},e.prototype.deleteRange=function(e,t){void 0===t&&(t=!0);var i=this._ranges[e];if(i){if(t)for(var r=i.from,n=i.to,o=this._keys.length-1;o>=0;o--)this._keys[o].frame>=r&&this._keys[o].frame<=n&&this._keys.splice(o,1);this._ranges[e]=null}},e.prototype.getRange=function(e){return this._ranges[e]},e.prototype.getKeys=function(){return this._keys},e.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},e.prototype.getEasingFunction=function(){return this._easingFunction},e.prototype.setEasingFunction=function(e){this._easingFunction=e},e.prototype.floatInterpolateFunction=function(e,t,i){return D.a.Lerp(e,t,i)},e.prototype.floatInterpolateFunctionWithTangents=function(e,t,i,r,n){return D.a.Hermite(e,t,i,r,n)},e.prototype.quaternionInterpolateFunction=function(e,t,i){return o.q.Slerp(e,t,i)},e.prototype.quaternionInterpolateFunctionWithTangents=function(e,t,i,r,n){return o.q.Hermite(e,t,i,r,n).normalize()},e.prototype.vector3InterpolateFunction=function(e,t,i){return o.x.Lerp(e,t,i)},e.prototype.vector3InterpolateFunctionWithTangents=function(e,t,i,r,n){return o.x.Hermite(e,t,i,r,n)},e.prototype.vector2InterpolateFunction=function(e,t,i){return o.w.Lerp(e,t,i)},e.prototype.vector2InterpolateFunctionWithTangents=function(e,t,i,r,n){return o.w.Hermite(e,t,i,r,n)},e.prototype.sizeInterpolateFunction=function(e,t,i){return o.r.Lerp(e,t,i)},e.prototype.color3InterpolateFunction=function(e,t,i){return o.e.Lerp(e,t,i)},e.prototype._getKeyValue=function(e){return"function"==typeof e?e():e},e.prototype._interpolate=function(t,i,r,n,o,s){if(n===e.ANIMATIONLOOPMODE_CONSTANT&&i>0)return s.clone?s.clone():s;var a=this.getKeys(),c=Math.max(0,Math.min(a.length-1,Math.floor(a.length*(t-a[0].frame)/(a[a.length-1].frame-a[0].frame))-1));if(a[c].frame>=t)for(;c-1>=0&&a[c].frame>=t;)c--;for(var l=c;l<a.length;l++){var u=a[l+1];if(u.frame>=t){var h=a[l],d=this._getKeyValue(h.value);if(h.interpolation===I.STEP)return d;var f=this._getKeyValue(u.value),p=void 0!==h.outTangent&&void 0!==u.inTangent,_=u.frame-h.frame,g=(t-h.frame)/_,m=this.getEasingFunction();switch(null!=m&&(g=m.ease(g)),this.dataType){case e.ANIMATIONTYPE_FLOAT:var v=p?this.floatInterpolateFunctionWithTangents(d,h.outTangent*_,f,u.inTangent*_,g):this.floatInterpolateFunction(d,f,g);switch(n){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:return v;case e.ANIMATIONLOOPMODE_RELATIVE:return o*i+v}break;case e.ANIMATIONTYPE_QUATERNION:var y=p?this.quaternionInterpolateFunctionWithTangents(d,h.outTangent.scale(_),f,u.inTangent.scale(_),g):this.quaternionInterpolateFunction(d,f,g);switch(n){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:return y;case e.ANIMATIONLOOPMODE_RELATIVE:return y.addInPlace(o.scale(i))}return y;case e.ANIMATIONTYPE_VECTOR3:var b=p?this.vector3InterpolateFunctionWithTangents(d,h.outTangent.scale(_),f,u.inTangent.scale(_),g):this.vector3InterpolateFunction(d,f,g);switch(n){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:return b;case e.ANIMATIONLOOPMODE_RELATIVE:return b.add(o.scale(i))}case e.ANIMATIONTYPE_VECTOR2:var T=p?this.vector2InterpolateFunctionWithTangents(d,h.outTangent.scale(_),f,u.inTangent.scale(_),g):this.vector2InterpolateFunction(d,f,g);switch(n){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:return T;case e.ANIMATIONLOOPMODE_RELATIVE:return T.add(o.scale(i))}case e.ANIMATIONTYPE_SIZE:switch(n){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:return this.sizeInterpolateFunction(d,f,g);case e.ANIMATIONLOOPMODE_RELATIVE:return this.sizeInterpolateFunction(d,f,g).add(o.scale(i))}case e.ANIMATIONTYPE_COLOR3:switch(n){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:return this.color3InterpolateFunction(d,f,g);case e.ANIMATIONLOOPMODE_RELATIVE:return this.color3InterpolateFunction(d,f,g).add(o.scale(i))}case e.ANIMATIONTYPE_MATRIX:switch(n){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:if(e.AllowMatricesInterpolation)return this.matrixInterpolateFunction(d,f,g,r);case e.ANIMATIONLOOPMODE_RELATIVE:return d}}break}}return this._getKeyValue(a[a.length-1].value)},e.prototype.matrixInterpolateFunction=function(t,i,r,n){return e.AllowMatrixDecomposeForInterpolation?n?(o.j.DecomposeLerpToRef(t,i,r,n),n):o.j.DecomposeLerp(t,i,r):n?(o.j.LerpToRef(t,i,r,n),n):o.j.Lerp(t,i,r)},e.prototype.clone=function(){var t=new e(this.name,this.targetPropertyPath.join("."),this.framePerSecond,this.dataType,this.loopMode);if(t.enableBlending=this.enableBlending,t.blendingSpeed=this.blendingSpeed,this._keys&&t.setKeys(this._keys),this._ranges)for(var i in t._ranges={},this._ranges){var r=this._ranges[i];r&&(t._ranges[i]=r.clone())}return t},e.prototype.setKeys=function(e){this._keys=e.slice(0)},e.prototype.serialize=function(){var t={};t.name=this.name,t.property=this.targetProperty,t.framePerSecond=this.framePerSecond,t.dataType=this.dataType,t.loopBehavior=this.loopMode,t.enableBlending=this.enableBlending,t.blendingSpeed=this.blendingSpeed;var i=this.dataType;t.keys=[];for(var r=this.getKeys(),n=0;n<r.length;n++){var o=r[n],s={};switch(s.frame=o.frame,i){case e.ANIMATIONTYPE_FLOAT:s.values=[o.value];break;case e.ANIMATIONTYPE_QUATERNION:case e.ANIMATIONTYPE_MATRIX:case e.ANIMATIONTYPE_VECTOR3:case e.ANIMATIONTYPE_COLOR3:s.values=o.value.asArray()}t.keys.push(s)}for(var a in t.ranges=[],this._ranges){var c=this._ranges[a];if(c){var l={};l.name=a,l.from=c.from,l.to=c.to,t.ranges.push(l)}}return t},Object.defineProperty(e,"ANIMATIONTYPE_FLOAT",{get:function(){return e._ANIMATIONTYPE_FLOAT},enumerable:!0,configurable:!0}),Object.defineProperty(e,"ANIMATIONTYPE_VECTOR3",{get:function(){return e._ANIMATIONTYPE_VECTOR3},enumerable:!0,configurable:!0}),Object.defineProperty(e,"ANIMATIONTYPE_VECTOR2",{get:function(){return e._ANIMATIONTYPE_VECTOR2},enumerable:!0,configurable:!0}),Object.defineProperty(e,"ANIMATIONTYPE_SIZE",{get:function(){return e._ANIMATIONTYPE_SIZE},enumerable:!0,configurable:!0}),Object.defineProperty(e,"ANIMATIONTYPE_QUATERNION",{get:function(){return e._ANIMATIONTYPE_QUATERNION},enumerable:!0,configurable:!0}),Object.defineProperty(e,"ANIMATIONTYPE_MATRIX",{get:function(){return e._ANIMATIONTYPE_MATRIX},enumerable:!0,configurable:!0}),Object.defineProperty(e,"ANIMATIONTYPE_COLOR3",{get:function(){return e._ANIMATIONTYPE_COLOR3},enumerable:!0,configurable:!0}),Object.defineProperty(e,"ANIMATIONLOOPMODE_RELATIVE",{get:function(){return e._ANIMATIONLOOPMODE_RELATIVE},enumerable:!0,configurable:!0}),Object.defineProperty(e,"ANIMATIONLOOPMODE_CYCLE",{get:function(){return e._ANIMATIONLOOPMODE_CYCLE},enumerable:!0,configurable:!0}),Object.defineProperty(e,"ANIMATIONLOOPMODE_CONSTANT",{get:function(){return e._ANIMATIONLOOPMODE_CONSTANT},enumerable:!0,configurable:!0}),e._UniversalLerp=function(e,t,i){var r=e.constructor;return r.Lerp?r.Lerp(e,t,i):r.Slerp?r.Slerp(e,t,i):e.toFixed?e*(1-i)+i*t:t},e.Parse=function(t){var i,r,n=new e(t.name,t.property,t.framePerSecond,t.dataType,t.loopBehavior),s=t.dataType,a=[];for(t.enableBlending&&(n.enableBlending=t.enableBlending),t.blendingSpeed&&(n.blendingSpeed=t.blendingSpeed),r=0;r<t.keys.length;r++){var c,l,u=t.keys[r];switch(s){case e.ANIMATIONTYPE_FLOAT:i=u.values[0],u.values.length>=1&&(c=u.values[1]),u.values.length>=2&&(l=u.values[2]);break;case e.ANIMATIONTYPE_QUATERNION:if(i=o.q.FromArray(u.values),u.values.length>=8){var h=o.q.FromArray(u.values.slice(4,8));h.equals(o.q.Zero())||(c=h)}if(u.values.length>=12){var d=o.q.FromArray(u.values.slice(8,12));d.equals(o.q.Zero())||(l=d)}break;case e.ANIMATIONTYPE_MATRIX:i=o.j.FromArray(u.values);break;case e.ANIMATIONTYPE_COLOR3:i=o.e.FromArray(u.values);break;case e.ANIMATIONTYPE_VECTOR3:default:i=o.x.FromArray(u.values)}var f={};f.frame=u.frame,f.value=i,null!=c&&(f.inTangent=c),null!=l&&(f.outTangent=l),a.push(f)}if(n.setKeys(a),t.ranges)for(r=0;r<t.ranges.length;r++)i=t.ranges[r],n.createRange(i.name,i.from,i.to);return n},e.AppendSerializedAnimations=function(e,t){w.a.AppendSerializedAnimations(e,t)},e.AllowMatricesInterpolation=!1,e.AllowMatrixDecomposeForInterpolation=!0,e._ANIMATIONTYPE_FLOAT=0,e._ANIMATIONTYPE_VECTOR3=1,e._ANIMATIONTYPE_QUATERNION=2,e._ANIMATIONTYPE_MATRIX=3,e._ANIMATIONTYPE_COLOR3=4,e._ANIMATIONTYPE_VECTOR2=5,e._ANIMATIONTYPE_SIZE=6,e._ANIMATIONLOOPMODE_RELATIVE=0,e._ANIMATIONLOOPMODE_CYCLE=1,e._ANIMATIONLOOPMODE_CONSTANT=2,e}();s.a.RegisteredTypes["BABYLON.Animation"]=N,F.a._AnimationRangeFactory=function(e,t,i){return new L(e,t,i)};var B=function(e){function t(t,i,r,o,s,a,c,l){void 0===s&&(s=1e3);var u=e.call(this,t,a)||this;return u.duration=1e3,u.onInterpolationDoneObservable=new n.c,u.propertyPath=r,u.value=o,u.duration=s,u.stopOtherAnimations=c,u.onInterpolationDone=l,u._target=u._effectiveTarget=i,u}return l.d(t,e),t.prototype._prepare=function(){this._effectiveTarget=this._getEffectiveTarget(this._effectiveTarget,this.propertyPath),this._property=this._getProperty(this.propertyPath)},t.prototype.execute=function(){var e,t=this,i=this._actionManager.getScene(),r=[{frame:0,value:this._effectiveTarget[this._property]},{frame:100,value:this.value}];if("number"==typeof this.value)e=N.ANIMATIONTYPE_FLOAT;else if(this.value instanceof o.e)e=N.ANIMATIONTYPE_COLOR3;else if(this.value instanceof o.x)e=N.ANIMATIONTYPE_VECTOR3;else if(this.value instanceof o.j)e=N.ANIMATIONTYPE_MATRIX;else{if(!(this.value instanceof o.q))return void p.a.Warn("InterpolateValueAction: Unsupported type ("+typeof this.value+")");e=N.ANIMATIONTYPE_QUATERNION}var n=new N("InterpolateValueAction",this._property,1e3/this.duration*100,e,N.ANIMATIONLOOPMODE_CONSTANT);n.setKeys(r),this.stopOtherAnimations&&i.stopAnimation(this._effectiveTarget);i.beginDirectAnimation(this._effectiveTarget,[n],0,100,!1,1,function(){t.onInterpolationDoneObservable.notifyObservers(t),t.onInterpolationDone&&t.onInterpolationDone()})},t.prototype.serialize=function(t){return e.prototype._serialize.call(this,{name:"InterpolateValueAction",properties:[a._GetTargetProperty(this._target),{name:"propertyPath",value:this.propertyPath},{name:"value",value:a._SerializeValueAsString(this.value)},{name:"duration",value:a._SerializeValueAsString(this.duration)},{name:"stopOtherAnimations",value:a._SerializeValueAsString(this.stopOtherAnimations)||!1}]},t)},t}(a);s.a.RegisteredTypes["BABYLON.InterpolateValueAction"]=a;var U=Object.freeze(new o.q(0,0,0,0)),V=Object.freeze(o.x.Zero()),G=Object.freeze(o.w.Zero()),k=Object.freeze(o.r.Zero()),z=Object.freeze(o.e.Black()),j=function(){function e(e,t,i,r){var n=this;this._events=new Array,this._currentFrame=0,this._originalValue=new Array,this._offsetsCache={},this._highLimitsCache={},this._stopped=!1,this._blendingFactor=0,this._targetPath="",this._weight=1,this._ratioOffset=0,this._previousDelay=0,this._previousRatio=0,this._animation=t,this._target=e,this._scene=i,this._host=r,t._runtimeAnimations.push(this);var o=t.getEvents();o&&o.length>0&&o.forEach(function(e){n._events.push(e._clone())})}return Object.defineProperty(e.prototype,"currentFrame",{get:function(){return this._currentFrame},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"weight",{get:function(){return this._weight},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"currentValue",{get:function(){return this._currentValue},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"targetPath",{get:function(){return this._targetPath},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"target",{get:function(){return this._activeTarget},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"animation",{get:function(){return this._animation},enumerable:!0,configurable:!0}),e.prototype.reset=function(e){if(void 0===e&&(e=!1),e)if(this._target instanceof Array)for(var t=0,i=0,r=this._target;i<r.length;i++){var n=r[i];void 0!==this._originalValue[t]&&this._setValue(n,this._originalValue[t],-1),t++}else void 0!==this._originalValue[0]&&this._setValue(this._target,this._originalValue[0],-1);this._offsetsCache={},this._highLimitsCache={},this._currentFrame=0,this._blendingFactor=0,this._originalValue=new Array;for(t=0;t<this._events.length;t++)this._events[t].isDone=!1},e.prototype.isStopped=function(){return this._stopped},e.prototype.dispose=function(){var e=this._animation.runtimeAnimations.indexOf(this);e>-1&&this._animation.runtimeAnimations.splice(e,1)},e.prototype._interpolate=function(e,t,i,r,n){return this._currentFrame=e,this._animation.dataType!==N.ANIMATIONTYPE_MATRIX||this._workValue||(this._workValue=o.j.Zero()),this._animation._interpolate(e,t,this._workValue,i,r,n)},e.prototype.setValue=function(e,t){if(void 0===t&&(t=1),this._target instanceof Array)for(var i=0,r=0,n=this._target;r<n.length;r++){var o=n[r];this._setValue(o,e,t,i),i++}else this._setValue(this._target,e,t)},e.prototype._setValue=function(e,t,i,r){var n,s;void 0===r&&(r=0);var a=this._animation.targetPropertyPath;if(a.length>1){for(var c=e[a[0]],l=1;l<a.length-1;l++)c=c[a[l]];n=a[a.length-1],s=c}else n=a[0],s=e;if(this._targetPath=n,this._activeTarget=s,this._weight=i,void 0===this._originalValue[r]){var u=void 0;(u=s.getRestPose&&"_matrix"===n?s.getRestPose():s[n])&&u.clone?this._originalValue[r]=u.clone():this._originalValue[r]=u}if((e&&e.animationPropertiesOverride?e.animationPropertiesOverride.enableBlending:this._animation.enableBlending)&&this._blendingFactor<=1){if(!this._originalBlendValue)(u=s[n]).clone?this._originalBlendValue=u.clone():this._originalBlendValue=u;this._originalBlendValue.m?N.AllowMatrixDecomposeForInterpolation?this._currentValue?o.j.DecomposeLerpToRef(this._originalBlendValue,t,this._blendingFactor,this._currentValue):this._currentValue=o.j.DecomposeLerp(this._originalBlendValue,t,this._blendingFactor):this._currentValue?o.j.LerpToRef(this._originalBlendValue,t,this._blendingFactor,this._currentValue):this._currentValue=o.j.Lerp(this._originalBlendValue,t,this._blendingFactor):this._currentValue=N._UniversalLerp(this._originalBlendValue,t,this._blendingFactor);var h=e&&e.animationPropertiesOverride?e.animationPropertiesOverride.blendingSpeed:this._animation.blendingSpeed;this._blendingFactor+=h}else this._currentValue=t;-1!==i?this._scene._registerTargetForLateAnimationBinding(this,this._originalValue[r]):s[n]=this._currentValue,e.markAsDirty&&e.markAsDirty(this._animation.targetProperty)},e.prototype._getCorrectLoopMode=function(){return this._target&&this._target.animationPropertiesOverride?this._target.animationPropertiesOverride.loopMode:this._animation.loopMode},e.prototype.goToFrame=function(e){var t=this._animation.getKeys();e<t[0].frame?e=t[0].frame:e>t[t.length-1].frame&&(e=t[t.length-1].frame);var i=this._interpolate(e,0,this._getCorrectLoopMode());this.setValue(i,-1)},e.prototype._prepareForSpeedRatioChange=function(e){var t=this._previousDelay*(this._animation.framePerSecond*e)/1e3;this._ratioOffset=this._previousRatio-t},e.prototype.animate=function(e,t,i,r,n,o,s){void 0===o&&(o=-1);var a=this._animation.targetPropertyPath;if(!a||a.length<1)return this._stopped=!0,!1;var c=!0,l=this._animation.getKeys();if(0!==l[0].frame){var u={frame:0,value:l[0].value};l.splice(0,0,u)}else if(1===l.length){u={frame:.001,value:l[0].value};l.push(u)}(t<l[0].frame||t>l[l.length-1].frame)&&(t=l[0].frame),(i<l[0].frame||i>l[l.length-1].frame)&&(i=l[l.length-1].frame),t===i&&(t>l[0].frame?t--:i<l[l.length-1].frame&&i++);var h,d=i-t,f=e*(this._animation.framePerSecond*n)/1e3+this._ratioOffset,p=0;if(this._previousDelay=e,this._previousRatio=f,(i>t&&f>=d||t>i&&f<=d)&&!r)c=!1,p=this._animation._getKeyValue(l[l.length-1].value);else if(this._getCorrectLoopMode()!==N.ANIMATIONLOOPMODE_CYCLE){var _=i.toString()+t.toString();if(!this._offsetsCache[_]){var g=this._interpolate(t,0,N.ANIMATIONLOOPMODE_CYCLE),m=this._interpolate(i,0,N.ANIMATIONLOOPMODE_CYCLE);switch(this._animation.dataType){case N.ANIMATIONTYPE_FLOAT:this._offsetsCache[_]=m-g;break;case N.ANIMATIONTYPE_QUATERNION:this._offsetsCache[_]=m.subtract(g);break;case N.ANIMATIONTYPE_VECTOR3:this._offsetsCache[_]=m.subtract(g);case N.ANIMATIONTYPE_VECTOR2:this._offsetsCache[_]=m.subtract(g);case N.ANIMATIONTYPE_SIZE:this._offsetsCache[_]=m.subtract(g);case N.ANIMATIONTYPE_COLOR3:this._offsetsCache[_]=m.subtract(g)}this._highLimitsCache[_]=m}p=this._highLimitsCache[_],h=this._offsetsCache[_]}if(void 0===h)switch(this._animation.dataType){case N.ANIMATIONTYPE_FLOAT:h=0;break;case N.ANIMATIONTYPE_QUATERNION:h=U;break;case N.ANIMATIONTYPE_VECTOR3:h=V;break;case N.ANIMATIONTYPE_VECTOR2:h=G;break;case N.ANIMATIONTYPE_SIZE:h=k;break;case N.ANIMATIONTYPE_COLOR3:h=z}var v=f/d>>0,y=c?t+f%d:i;if(this._host&&this._host.syncRoot){var b=this._host.syncRoot;y=t+(i-t)*((b.masterFrame-b.fromFrame)/(b.toFrame-b.fromFrame))}var T=this._events;if(d>0&&this.currentFrame>y||d<0&&this.currentFrame<y){s&&s();for(var E=0;E<T.length;E++)T[E].onlyOnce||(T[E].isDone=!1)}var x=this._interpolate(y,v,this._getCorrectLoopMode(),h,p);this.setValue(x,o);for(E=0;E<T.length;E++)if(d>0&&y>=T[E].frame&&T[E].frame>=t||d<0&&y<=T[E].frame&&T[E].frame<=t){var A=T[E];A.isDone||(A.onlyOnce&&(T.splice(E,1),E--),A.isDone=!0,A.action(y))}return c||(this._stopped=!0),c},e}(),W=i(17),H=i(43),X=i(34),Y=function(e){function t(t,i,r,n,s,a,c){void 0===r&&(r=null),void 0===n&&(n=null),void 0===s&&(s=null),void 0===a&&(a=null),void 0===c&&(c=null);var l=e.call(this,t,i.getScene(),!1)||this;return l.name=t,l.children=new Array,l.animations=new Array,l._index=null,l._absoluteTransform=new o.j,l._invertedAbsoluteTransform=new o.j,l._scalingDeterminant=1,l._worldTransform=new o.j,l._needToDecompose=!0,l._needToCompose=!1,l._linkedTransformNode=null,l._skeleton=i,l._localMatrix=n?n.clone():o.j.Identity(),l._restPose=s||l._localMatrix.clone(),l._baseMatrix=a||l._localMatrix.clone(),l._index=c,i.bones.push(l),l.setParent(r,!1),(a||n)&&l._updateDifferenceMatrix(),l}return l.d(t,e),Object.defineProperty(t.prototype,"_matrix",{get:function(){return this._compose(),this._localMatrix},set:function(e){this._localMatrix.copyFrom(e),this._needToDecompose=!0},enumerable:!0,configurable:!0}),t.prototype.getSkeleton=function(){return this._skeleton},t.prototype.getParent=function(){return this._parent},t.prototype.setParent=function(e,t){if(void 0===t&&(t=!0),this._parent!==e){if(this._parent){var i=this._parent.children.indexOf(this);-1!==i&&this._parent.children.splice(i,1)}this._parent=e,this._parent&&this._parent.children.push(this),t&&this._updateDifferenceMatrix(),this.markAsDirty()}},t.prototype.getLocalMatrix=function(){return this._compose(),this._localMatrix},t.prototype.getBaseMatrix=function(){return this._baseMatrix},t.prototype.getRestPose=function(){return this._restPose},t.prototype.getWorldMatrix=function(){return this._worldTransform},t.prototype.returnToRest=function(){this.updateMatrix(this._restPose.clone())},t.prototype.getInvertedAbsoluteTransform=function(){return this._invertedAbsoluteTransform},t.prototype.getAbsoluteTransform=function(){return this._absoluteTransform},t.prototype.linkTransformNode=function(e){this._linkedTransformNode&&this._skeleton._numBonesWithLinkedTransformNode--,this._linkedTransformNode=e,this._linkedTransformNode&&this._skeleton._numBonesWithLinkedTransformNode++},Object.defineProperty(t.prototype,"position",{get:function(){return this._decompose(),this._localPosition},set:function(e){this._decompose(),this._localPosition.copyFrom(e),this._markAsDirtyAndCompose()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"rotation",{get:function(){return this.getRotation()},set:function(e){this.setRotation(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"rotationQuaternion",{get:function(){return this._decompose(),this._localRotation},set:function(e){this.setRotationQuaternion(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"scaling",{get:function(){return this.getScale()},set:function(e){this.setScale(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"animationPropertiesOverride",{get:function(){return this._skeleton.animationPropertiesOverride},enumerable:!0,configurable:!0}),t.prototype._decompose=function(){this._needToDecompose&&(this._needToDecompose=!1,this._localScaling||(this._localScaling=o.x.Zero(),this._localRotation=o.q.Zero(),this._localPosition=o.x.Zero()),this._localMatrix.decompose(this._localScaling,this._localRotation,this._localPosition))},t.prototype._compose=function(){this._needToCompose&&(this._needToCompose=!1,o.j.ComposeToRef(this._localScaling,this._localRotation,this._localPosition,this._localMatrix))},t.prototype.updateMatrix=function(e,t,i){void 0===t&&(t=!0),void 0===i&&(i=!0),this._baseMatrix.copyFrom(e),t&&this._updateDifferenceMatrix(),i?(this._localMatrix.copyFrom(e),this._markAsDirtyAndDecompose()):this.markAsDirty()},t.prototype._updateDifferenceMatrix=function(e,t){if(void 0===t&&(t=!0),e||(e=this._baseMatrix),this._parent?e.multiplyToRef(this._parent._absoluteTransform,this._absoluteTransform):this._absoluteTransform.copyFrom(e),this._absoluteTransform.invertToRef(this._invertedAbsoluteTransform),t)for(var i=0;i<this.children.length;i++)this.children[i]._updateDifferenceMatrix();this._scalingDeterminant=this._absoluteTransform.determinant()<0?-1:1},t.prototype.markAsDirty=function(){this._currentRenderId++,this._childRenderId++,this._skeleton._markAsDirty()},t.prototype._markAsDirtyAndCompose=function(){this.markAsDirty(),this._needToCompose=!0},t.prototype._markAsDirtyAndDecompose=function(){this.markAsDirty(),this._needToDecompose=!0},t.prototype.translate=function(e,i,r){void 0===i&&(i=o.s.LOCAL);var n=this.getLocalMatrix();if(i==o.s.LOCAL)n.addAtIndex(12,e.x),n.addAtIndex(13,e.y),n.addAtIndex(14,e.z);else{var s=null;r&&(s=r.getWorldMatrix()),this._skeleton.computeAbsoluteTransforms();var a=t._tmpMats[0],c=t._tmpVecs[0];this._parent&&(r&&s?(a.copyFrom(this._parent.getAbsoluteTransform()),a.multiplyToRef(s,a)):a.copyFrom(this._parent.getAbsoluteTransform())),a.setTranslationFromFloats(0,0,0),a.invert(),o.x.TransformCoordinatesToRef(e,a,c),n.addAtIndex(12,c.x),n.addAtIndex(13,c.y),n.addAtIndex(14,c.z)}this._markAsDirtyAndDecompose()},t.prototype.setPosition=function(e,i,r){void 0===i&&(i=o.s.LOCAL);var n=this.getLocalMatrix();if(i==o.s.LOCAL)n.setTranslationFromFloats(e.x,e.y,e.z);else{var s=null;r&&(s=r.getWorldMatrix()),this._skeleton.computeAbsoluteTransforms();var a=t._tmpMats[0],c=t._tmpVecs[0];this._parent&&(r&&s?(a.copyFrom(this._parent.getAbsoluteTransform()),a.multiplyToRef(s,a)):a.copyFrom(this._parent.getAbsoluteTransform())),a.invert(),o.x.TransformCoordinatesToRef(e,a,c),n.setTranslationFromFloats(c.x,c.y,c.z)}this._markAsDirtyAndDecompose()},t.prototype.setAbsolutePosition=function(e,t){this.setPosition(e,o.s.WORLD,t)},t.prototype.scale=function(e,i,r,n){void 0===n&&(n=!1);var s=this.getLocalMatrix(),a=t._tmpMats[0];o.j.ScalingToRef(e,i,r,a),a.multiplyToRef(s,s),a.invert();for(var c=0,l=this.children;c<l.length;c++){var u=(f=l[c]).getLocalMatrix();u.multiplyToRef(a,u),u.multiplyAtIndex(12,e),u.multiplyAtIndex(13,i),u.multiplyAtIndex(14,r),f._markAsDirtyAndDecompose()}if(this._markAsDirtyAndDecompose(),n)for(var h=0,d=this.children;h<d.length;h++){var f;(f=d[h]).scale(e,i,r,n)}},t.prototype.setScale=function(e){this._decompose(),this._localScaling.copyFrom(e),this._markAsDirtyAndCompose()},t.prototype.getScale=function(){return this._decompose(),this._localScaling},t.prototype.getScaleToRef=function(e){this._decompose(),e.copyFrom(this._localScaling)},t.prototype.setYawPitchRoll=function(e,i,r,n,s){if(void 0===n&&(n=o.s.LOCAL),n===o.s.LOCAL){var a=t._tmpQuat;return o.q.RotationYawPitchRollToRef(e,i,r,a),void this.setRotationQuaternion(a,n,s)}var c=t._tmpMats[0];if(this._getNegativeRotationToRef(c,s)){var l=t._tmpMats[1];o.j.RotationYawPitchRollToRef(e,i,r,l),c.multiplyToRef(l,l),this._rotateWithMatrix(l,n,s)}},t.prototype.rotate=function(e,i,r,n){void 0===r&&(r=o.s.LOCAL);var s=t._tmpMats[0];s.setTranslationFromFloats(0,0,0),o.j.RotationAxisToRef(e,i,s),this._rotateWithMatrix(s,r,n)},t.prototype.setAxisAngle=function(e,i,r,n){if(void 0===r&&(r=o.s.LOCAL),r===o.s.LOCAL){var s=t._tmpQuat;return o.q.RotationAxisToRef(e,i,s),void this.setRotationQuaternion(s,r,n)}var a=t._tmpMats[0];if(this._getNegativeRotationToRef(a,n)){var c=t._tmpMats[1];o.j.RotationAxisToRef(e,i,c),a.multiplyToRef(c,c),this._rotateWithMatrix(c,r,n)}},t.prototype.setRotation=function(e,t,i){void 0===t&&(t=o.s.LOCAL),this.setYawPitchRoll(e.y,e.x,e.z,t,i)},t.prototype.setRotationQuaternion=function(e,i,r){if(void 0===i&&(i=o.s.LOCAL),i===o.s.LOCAL)return this._decompose(),this._localRotation.copyFrom(e),void this._markAsDirtyAndCompose();var n=t._tmpMats[0];if(this._getNegativeRotationToRef(n,r)){var s=t._tmpMats[1];o.j.FromQuaternionToRef(e,s),n.multiplyToRef(s,s),this._rotateWithMatrix(s,i,r)}},t.prototype.setRotationMatrix=function(e,i,r){if(void 0===i&&(i=o.s.LOCAL),i===o.s.LOCAL){var n=t._tmpQuat;return o.q.FromRotationMatrixToRef(e,n),void this.setRotationQuaternion(n,i,r)}var s=t._tmpMats[0];if(this._getNegativeRotationToRef(s,r)){var a=t._tmpMats[1];a.copyFrom(e),s.multiplyToRef(e,a),this._rotateWithMatrix(a,i,r)}},t.prototype._rotateWithMatrix=function(e,i,r){void 0===i&&(i=o.s.LOCAL);var n=this.getLocalMatrix(),s=n.m[12],a=n.m[13],c=n.m[14],l=this.getParent(),u=t._tmpMats[3],h=t._tmpMats[4];l&&i==o.s.WORLD?(r?(u.copyFrom(r.getWorldMatrix()),l.getAbsoluteTransform().multiplyToRef(u,u)):u.copyFrom(l.getAbsoluteTransform()),h.copyFrom(u),h.invert(),n.multiplyToRef(u,n),n.multiplyToRef(e,n),n.multiplyToRef(h,n)):i==o.s.WORLD&&r?(u.copyFrom(r.getWorldMatrix()),h.copyFrom(u),h.invert(),n.multiplyToRef(u,n),n.multiplyToRef(e,n),n.multiplyToRef(h,n)):n.multiplyToRef(e,n),n.setTranslationFromFloats(s,a,c),this.computeAbsoluteTransforms(),this._markAsDirtyAndDecompose()},t.prototype._getNegativeRotationToRef=function(e,i){var r=t._tmpMats[2];return e.copyFrom(this.getAbsoluteTransform()),i&&(e.multiplyToRef(i.getWorldMatrix(),e),o.j.ScalingToRef(i.scaling.x,i.scaling.y,i.scaling.z,r)),e.invert(),!isNaN(e.m[0])&&(r.multiplyAtIndex(0,this._scalingDeterminant),e.multiplyToRef(r,e),!0)},t.prototype.getPosition=function(e,t){void 0===e&&(e=o.s.LOCAL),void 0===t&&(t=null);var i=o.x.Zero();return this.getPositionToRef(e,t,i),i},t.prototype.getPositionToRef=function(e,i,r){if(void 0===e&&(e=o.s.LOCAL),e==o.s.LOCAL){var n=this.getLocalMatrix();r.x=n.m[12],r.y=n.m[13],r.z=n.m[14]}else{var s=null;i&&(s=i.getWorldMatrix()),this._skeleton.computeAbsoluteTransforms();var a=t._tmpMats[0];i&&s?(a.copyFrom(this.getAbsoluteTransform()),a.multiplyToRef(s,a)):a=this.getAbsoluteTransform(),r.x=a.m[12],r.y=a.m[13],r.z=a.m[14]}},t.prototype.getAbsolutePosition=function(e){void 0===e&&(e=null);var t=o.x.Zero();return this.getPositionToRef(o.s.WORLD,e,t),t},t.prototype.getAbsolutePositionToRef=function(e,t){this.getPositionToRef(o.s.WORLD,e,t)},t.prototype.computeAbsoluteTransforms=function(){if(this._compose(),this._parent)this._localMatrix.multiplyToRef(this._parent._absoluteTransform,this._absoluteTransform);else{this._absoluteTransform.copyFrom(this._localMatrix);var e=this._skeleton.getPoseMatrix();e&&this._absoluteTransform.multiplyToRef(e,this._absoluteTransform)}for(var t=this.children,i=t.length,r=0;r<i;r++)t[r].computeAbsoluteTransforms()},t.prototype.getDirection=function(e,t){void 0===t&&(t=null);var i=o.x.Zero();return this.getDirectionToRef(e,t,i),i},t.prototype.getDirectionToRef=function(e,i,r){void 0===i&&(i=null);var n=null;i&&(n=i.getWorldMatrix()),this._skeleton.computeAbsoluteTransforms();var s=t._tmpMats[0];s.copyFrom(this.getAbsoluteTransform()),i&&n&&s.multiplyToRef(n,s),o.x.TransformNormalToRef(e,s,r),r.normalize()},t.prototype.getRotation=function(e,t){void 0===e&&(e=o.s.LOCAL),void 0===t&&(t=null);var i=o.x.Zero();return this.getRotationToRef(e,t,i),i},t.prototype.getRotationToRef=function(e,i,r){void 0===e&&(e=o.s.LOCAL),void 0===i&&(i=null);var n=t._tmpQuat;this.getRotationQuaternionToRef(e,i,n),n.toEulerAnglesToRef(r)},t.prototype.getRotationQuaternion=function(e,t){void 0===e&&(e=o.s.LOCAL),void 0===t&&(t=null);var i=o.q.Identity();return this.getRotationQuaternionToRef(e,t,i),i},t.prototype.getRotationQuaternionToRef=function(e,i,r){if(void 0===e&&(e=o.s.LOCAL),void 0===i&&(i=null),e==o.s.LOCAL)this._decompose(),r.copyFrom(this._localRotation);else{var n=t._tmpMats[0],s=this.getAbsoluteTransform();i?s.multiplyToRef(i.getWorldMatrix(),n):n.copyFrom(s),n.multiplyAtIndex(0,this._scalingDeterminant),n.multiplyAtIndex(1,this._scalingDeterminant),n.multiplyAtIndex(2,this._scalingDeterminant),n.decompose(void 0,r,void 0)}},t.prototype.getRotationMatrix=function(e,t){void 0===e&&(e=o.s.LOCAL);var i=o.j.Identity();return this.getRotationMatrixToRef(e,t,i),i},t.prototype.getRotationMatrixToRef=function(e,i,r){if(void 0===e&&(e=o.s.LOCAL),e==o.s.LOCAL)this.getLocalMatrix().getRotationMatrixToRef(r);else{var n=t._tmpMats[0],s=this.getAbsoluteTransform();i?s.multiplyToRef(i.getWorldMatrix(),n):n.copyFrom(s),n.multiplyAtIndex(0,this._scalingDeterminant),n.multiplyAtIndex(1,this._scalingDeterminant),n.multiplyAtIndex(2,this._scalingDeterminant),n.getRotationMatrixToRef(r)}},t.prototype.getAbsolutePositionFromLocal=function(e,t){void 0===t&&(t=null);var i=o.x.Zero();return this.getAbsolutePositionFromLocalToRef(e,t,i),i},t.prototype.getAbsolutePositionFromLocalToRef=function(e,i,r){void 0===i&&(i=null);var n=null;i&&(n=i.getWorldMatrix()),this._skeleton.computeAbsoluteTransforms();var s=t._tmpMats[0];i&&n?(s.copyFrom(this.getAbsoluteTransform()),s.multiplyToRef(n,s)):s=this.getAbsoluteTransform(),o.x.TransformCoordinatesToRef(e,s,r)},t.prototype.getLocalPositionFromAbsolute=function(e,t){void 0===t&&(t=null);var i=o.x.Zero();return this.getLocalPositionFromAbsoluteToRef(e,t,i),i},t.prototype.getLocalPositionFromAbsoluteToRef=function(e,i,r){void 0===i&&(i=null);var n=null;i&&(n=i.getWorldMatrix()),this._skeleton.computeAbsoluteTransforms();var s=t._tmpMats[0];s.copyFrom(this.getAbsoluteTransform()),i&&n&&s.multiplyToRef(n,s),s.invert(),o.x.TransformCoordinatesToRef(e,s,r)},t._tmpVecs=X.a.BuildArray(2,o.x.Zero),t._tmpQuat=o.q.Identity(),t._tmpMats=X.a.BuildArray(5,o.j.Identity),t}(F.a),K=function(){function e(e,t,i,r,o,s,a,c,l){void 0===i&&(i=0),void 0===r&&(r=100),void 0===o&&(o=!1),void 0===s&&(s=1),this.target=t,this.fromFrame=i,this.toFrame=r,this.loopAnimation=o,this.onAnimationEnd=a,this.onAnimationLoop=l,this._localDelayOffset=null,this._pausedDelay=null,this._runtimeAnimations=new Array,this._paused=!1,this._speedRatio=1,this._weight=-1,this.disposeOnEnd=!0,this.animationStarted=!1,this.onAnimationEndObservable=new n.c,this.onAnimationLoopObservable=new n.c,this._scene=e,c&&this.appendAnimations(t,c),this._speedRatio=s,e._activeAnimatables.push(this)}return Object.defineProperty(e.prototype,"syncRoot",{get:function(){return this._syncRoot},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"masterFrame",{get:function(){return 0===this._runtimeAnimations.length?0:this._runtimeAnimations[0].currentFrame},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"weight",{get:function(){return this._weight},set:function(e){this._weight=-1!==e?Math.min(Math.max(e,0),1):-1},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"speedRatio",{get:function(){return this._speedRatio},set:function(e){for(var t=0;t<this._runtimeAnimations.length;t++){this._runtimeAnimations[t]._prepareForSpeedRatioChange(e)}this._speedRatio=e},enumerable:!0,configurable:!0}),e.prototype.syncWith=function(e){if(this._syncRoot=e,e){var t=this._scene._activeAnimatables.indexOf(this);t>-1&&(this._scene._activeAnimatables.splice(t,1),this._scene._activeAnimatables.push(this))}return this},e.prototype.getAnimations=function(){return this._runtimeAnimations},e.prototype.appendAnimations=function(e,t){for(var i=0;i<t.length;i++){var r=t[i];this._runtimeAnimations.push(new j(e,r,this._scene,this))}},e.prototype.getAnimationByTargetProperty=function(e){for(var t=this._runtimeAnimations,i=0;i<t.length;i++)if(t[i].animation.targetProperty===e)return t[i].animation;return null},e.prototype.getRuntimeAnimationByTargetProperty=function(e){for(var t=this._runtimeAnimations,i=0;i<t.length;i++)if(t[i].animation.targetProperty===e)return t[i];return null},e.prototype.reset=function(){for(var e=this._runtimeAnimations,t=0;t<e.length;t++)e[t].reset(!0);this._localDelayOffset=null,this._pausedDelay=null},e.prototype.enableBlending=function(e){for(var t=this._runtimeAnimations,i=0;i<t.length;i++)t[i].animation.enableBlending=!0,t[i].animation.blendingSpeed=e},e.prototype.disableBlending=function(){for(var e=this._runtimeAnimations,t=0;t<e.length;t++)e[t].animation.enableBlending=!1},e.prototype.goToFrame=function(e){var t=this._runtimeAnimations;if(t[0]){var i=t[0].animation.framePerSecond,r=1e3*(e-t[0].currentFrame)/(i*this.speedRatio);null===this._localDelayOffset&&(this._localDelayOffset=0),this._localDelayOffset-=r}for(var n=0;n<t.length;n++)t[n].goToFrame(e)},e.prototype.pause=function(){this._paused||(this._paused=!0)},e.prototype.restart=function(){this._paused=!1},e.prototype._raiseOnAnimationEnd=function(){this.onAnimationEnd&&this.onAnimationEnd(),this.onAnimationEndObservable.notifyObservers(this)},e.prototype.stop=function(e,t){if(e||t){var i=this._scene._activeAnimatables.indexOf(this);if(i>-1){for(var r=(o=this._runtimeAnimations).length-1;r>=0;r--){var n=o[r];e&&n.animation.name!=e||(t&&!t(n.target)||(n.dispose(),o.splice(r,1)))}0==o.length&&(this._scene._activeAnimatables.splice(i,1),this._raiseOnAnimationEnd())}}else{if((r=this._scene._activeAnimatables.indexOf(this))>-1){this._scene._activeAnimatables.splice(r,1);var o=this._runtimeAnimations;for(r=0;r<o.length;r++)o[r].dispose();this._raiseOnAnimationEnd()}}},e.prototype.waitAsync=function(){var e=this;return new Promise(function(t,i){e.onAnimationEndObservable.add(function(){t(e)},void 0,void 0,e,!0)})},e.prototype._animate=function(e){var t=this;if(this._paused)return this.animationStarted=!1,null===this._pausedDelay&&(this._pausedDelay=e),!0;if(null===this._localDelayOffset?(this._localDelayOffset=e,this._pausedDelay=null):null!==this._pausedDelay&&(this._localDelayOffset+=e-this._pausedDelay,this._pausedDelay=null),0===this._weight)return!0;var i,r=!1,n=this._runtimeAnimations;for(i=0;i<n.length;i++){var o=n[i].animate(e-this._localDelayOffset,this.fromFrame,this.toFrame,this.loopAnimation,this._speedRatio,this._weight,function(){t.onAnimationLoopObservable.notifyObservers(t),t.onAnimationLoop&&t.onAnimationLoop()});r=r||o}if(this.animationStarted=r,!r){if(this.disposeOnEnd)for(i=this._scene._activeAnimatables.indexOf(this),this._scene._activeAnimatables.splice(i,1),i=0;i<n.length;i++)n[i].dispose();this._raiseOnAnimationEnd(),this.disposeOnEnd&&(this.onAnimationEnd=null,this.onAnimationLoop=null,this.onAnimationLoopObservable.clear(),this.onAnimationEndObservable.clear())}return r},e}();W.a.prototype._animate=function(){if(this.animationsEnabled&&0!==this._activeAnimatables.length){var e=H.a.Now;if(!this._animationTimeLast){if(this._pendingData.length>0)return;this._animationTimeLast=e}var t=this.useConstantAnimationDeltaTime?16:(e-this._animationTimeLast)*this.animationTimeScale;this._animationTime+=t,this._animationTimeLast=e;for(var i=0;i<this._activeAnimatables.length;i++)this._activeAnimatables[i]._animate(this._animationTime);this._processLateAnimationBindings()}},W.a.prototype.beginWeightedAnimation=function(e,t,i,r,n,o,s,a,c,l){void 0===r&&(r=1),void 0===o&&(o=1);var u=this.beginAnimation(e,t,i,n,o,s,a,!1,c,l);return u.weight=r,u},W.a.prototype.beginAnimation=function(e,t,i,r,n,o,s,a,c,l){void 0===n&&(n=1),void 0===a&&(a=!0),t>i&&n>0&&(n*=-1),a&&this.stopAnimation(e,void 0,c),s||(s=new K(this,e,t,i,r,n,o,void 0,l));var u=!c||c(e);if(e.animations&&u&&s.appendAnimations(e,e.animations),e.getAnimatables)for(var h=e.getAnimatables(),d=0;d<h.length;d++)this.beginAnimation(h[d],t,i,r,n,o,s,a,c,l);return s.reset(),s},W.a.prototype.beginHierarchyAnimation=function(e,t,i,r,n,o,s,a,c,l,u){void 0===o&&(o=1),void 0===c&&(c=!0);var h=e.getDescendants(t),d=[];d.push(this.beginAnimation(e,i,r,n,o,s,a,c,l));for(var f=0,p=h;f<p.length;f++){var _=p[f];d.push(this.beginAnimation(_,i,r,n,o,s,a,c,l))}return d},W.a.prototype.beginDirectAnimation=function(e,t,i,r,n,o,s,a){return void 0===o&&(o=1),new K(this,e,i,r,n,o,s,t,a)},W.a.prototype.beginDirectHierarchyAnimation=function(e,t,i,r,n,o,s,a,c){var l=e.getDescendants(t),u=[];u.push(this.beginDirectAnimation(e,i,r,n,o,s,a,c));for(var h=0,d=l;h<d.length;h++){var f=d[h];u.push(this.beginDirectAnimation(f,i,r,n,o,s,a,c))}return u},W.a.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},W.a.prototype.getAllAnimatablesByTarget=function(e){for(var t=[],i=0;i<this._activeAnimatables.length;i++)this._activeAnimatables[i].target===e&&t.push(this._activeAnimatables[i]);return t},W.a.prototype.stopAnimation=function(e,t,i){for(var r=0,n=this.getAllAnimatablesByTarget(e);r<n.length;r++){n[r].stop(t,i)}},W.a.prototype.stopAllAnimations=function(){if(this._activeAnimatables){for(var e=0;e<this._activeAnimatables.length;e++)this._activeAnimatables[e].stop();this._activeAnimatables=[]}for(var t=0,i=this.animationGroups;t<i.length;t++){i[t].stop()}},W.a.prototype._registerTargetForLateAnimationBinding=function(e,t){var i=e.target;this._registeredForLateAnimationBindings.pushNoDuplicate(i),i._lateAnimationHolders||(i._lateAnimationHolders={}),i._lateAnimationHolders[e.targetPath]||(i._lateAnimationHolders[e.targetPath]={totalWeight:0,animations:[],originalValue:t}),i._lateAnimationHolders[e.targetPath].animations.push(e),i._lateAnimationHolders[e.targetPath].totalWeight+=e.weight},W.a.prototype._processLateAnimationBindingsForMatrices=function(e){var t=1,i=o.t.Vector3[0],r=o.t.Vector3[1],n=o.t.Quaternion[0],s=0,a=e.animations[0],c=e.originalValue,l=1;if(e.totalWeight<1)c.decompose(r,n,i),l=1-e.totalWeight;else if(s=1,t=e.totalWeight,a.currentValue.decompose(r,n,i),1==(l=a.weight/t))return a.currentValue;r.scaleInPlace(l),i.scaleInPlace(l),n.scaleInPlace(l);for(var u=s;u<e.animations.length;u++){var h=e.animations[u],d=(l=h.weight/t,o.t.Vector3[2]),f=o.t.Vector3[3],p=o.t.Quaternion[1];h.currentValue.decompose(f,p,d),f.scaleAndAddToRef(l,r),p.scaleAndAddToRef(l,n),d.scaleAndAddToRef(l,i)}return o.j.ComposeToRef(r,n,i,a._workValue),a._workValue},W.a.prototype._processLateAnimationBindingsForQuaternions=function(e,t){var i=e.animations[0],r=e.originalValue;if(1===e.animations.length)return o.q.SlerpToRef(r,i.currentValue,Math.min(1,e.totalWeight),t),t;var n,s,a=1;if(e.totalWeight<1){var c=1-e.totalWeight;s=[],(n=[]).push(r),s.push(c)}else{if(2===e.animations.length)return o.q.SlerpToRef(e.animations[0].currentValue,e.animations[1].currentValue,e.animations[1].weight/e.totalWeight,t),t;n=[],s=[],a=e.totalWeight}for(var l=0;l<e.animations.length;l++){var u=e.animations[l];n.push(u.currentValue),s.push(u.weight/a)}for(var h=0,d=null,f=0;f<n.length;)d?(h+=s[f],o.q.SlerpToRef(d,n[f],s[f]/h,d),f++):(o.q.SlerpToRef(n[f],n[f+1],s[f+1]/(s[f]+s[f+1]),t),d=t,h=s[f]+s[f+1],f+=2);return d},W.a.prototype._processLateAnimationBindings=function(){if(this._registeredForLateAnimationBindings.length){for(var e=0;e<this._registeredForLateAnimationBindings.length;e++){var t=this._registeredForLateAnimationBindings.data[e];for(var i in t._lateAnimationHolders){var r=t._lateAnimationHolders[i],n=r.animations[0],s=r.originalValue,a=N.AllowMatrixDecomposeForInterpolation&&s.m,c=t[i];if(a)c=this._processLateAnimationBindingsForMatrices(r);else if(void 0!==s.w)c=this._processLateAnimationBindingsForQuaternions(r,c||o.q.Identity());else{var l=0,u=1;if(r.totalWeight<1)c=s.scale?s.scale(1-r.totalWeight):s*(1-r.totalWeight);else{u=r.totalWeight;var h=n.weight/u;c=1!==h?n.currentValue.scale?n.currentValue.scale(h):n.currentValue*h:n.currentValue,l=1}for(var d=l;d<r.animations.length;d++){var f=r.animations[d],p=f.weight/u;f.currentValue.scaleAndAddToRef?f.currentValue.scaleAndAddToRef(p,c):c+=f.currentValue*p}}t[i]=c}t._lateAnimationHolders={}}this._registeredForLateAnimationBindings.reset()}},Y.prototype.copyAnimationRange=function(e,t,i,r,n){void 0===r&&(r=!1),void 0===n&&(n=null),0===this.animations.length&&(this.animations.push(new N(this.name,"_matrix",e.animations[0].framePerSecond,N.ANIMATIONTYPE_MATRIX,0)),this.animations[0].setKeys([]));var o=e.animations[0].getRange(t);if(!o)return!1;for(var s,a,c,l=o.from,u=o.to,h=e.animations[0].getKeys(),d=e.length,f=e.getParent(),p=this.getParent(),_=r&&f&&d&&this.length&&d!==this.length,g=_&&p&&f?p.length/f.length:1,m=r&&!p&&n&&(1!==n.x||1!==n.y||1!==n.z),v=this.animations[0].getKeys(),y=0,b=h.length;y<b;y++)(s=h[y]).frame>=l&&s.frame<=u&&(r?(c=s.value.clone(),_?(a=c.getTranslation(),c.setTranslation(a.scaleInPlace(g))):m&&n?(a=c.getTranslation(),c.setTranslation(a.multiplyInPlace(n))):c=s.value):c=s.value,v.push({frame:s.frame+i,value:c}));return this.animations[0].createRange(t,l+i,u+i),!0};var Q=function(){return function(){}}(),q=function(){function e(e,t){void 0===t&&(t=null),this.name=e,this._targetedAnimations=new Array,this._animatables=new Array,this._from=Number.MAX_VALUE,this._to=-Number.MAX_VALUE,this._speedRatio=1,this.onAnimationEndObservable=new n.c,this.onAnimationLoopObservable=new n.c,this.onAnimationGroupEndObservable=new n.c,this.onAnimationGroupPauseObservable=new n.c,this.onAnimationGroupPlayObservable=new n.c,this._scene=t||R.a.LastCreatedScene,this.uniqueId=this._scene.getUniqueId(),this._scene.animationGroups.push(this)}return Object.defineProperty(e.prototype,"from",{get:function(){return this._from},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"to",{get:function(){return this._to},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isStarted",{get:function(){return this._isStarted},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isPlaying",{get:function(){return this._isStarted&&!this._isPaused},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"speedRatio",{get:function(){return this._speedRatio},set:function(e){if(this._speedRatio!==e){this._speedRatio=e;for(var t=0;t<this._animatables.length;t++){this._animatables[t].speedRatio=this._speedRatio}}},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"targetedAnimations",{get:function(){return this._targetedAnimations},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"animatables",{get:function(){return this._animatables},enumerable:!0,configurable:!0}),e.prototype.addTargetedAnimation=function(e,t){var i={animation:e,target:t},r=e.getKeys();return this._from>r[0].frame&&(this._from=r[0].frame),this._to<r[r.length-1].frame&&(this._to=r[r.length-1].frame),this._targetedAnimations.push(i),i},e.prototype.normalize=function(e,t){void 0===e&&(e=null),void 0===t&&(t=null),null==e&&(e=this._from),null==t&&(t=this._to);for(var i=0;i<this._targetedAnimations.length;i++){var r=this._targetedAnimations[i].animation.getKeys(),n=r[0],o=r[r.length-1];if(n.frame>e){var s={frame:e,value:n.value,inTangent:n.inTangent,outTangent:n.outTangent,interpolation:n.interpolation};r.splice(0,0,s)}if(o.frame<t){s={frame:t,value:o.value,inTangent:o.outTangent,outTangent:o.outTangent,interpolation:o.interpolation};r.push(s)}}return this._from=e,this._to=t,this},e.prototype.start=function(e,t,i,r){var n=this;if(void 0===e&&(e=!1),void 0===t&&(t=1),this._isStarted||0===this._targetedAnimations.length)return this;for(var o=function(o){var a=s._scene.beginDirectAnimation(o.target,[o.animation],void 0!==i?i:s._from,void 0!==r?r:s._to,e,t);a.onAnimationEnd=function(){n.onAnimationEndObservable.notifyObservers(o),n._checkAnimationGroupEnded(a)},a.onAnimationLoop=function(){n.onAnimationLoopObservable.notifyObservers(o)},s._animatables.push(a)},s=this,a=0,c=this._targetedAnimations;a<c.length;a++){o(c[a])}return this._speedRatio=t,void 0!==i&&void 0!==r&&i>r&&this._speedRatio>0&&(this._speedRatio=-t),this._isStarted=!0,this._isPaused=!1,this.onAnimationGroupPlayObservable.notifyObservers(this),this},e.prototype.pause=function(){if(!this._isStarted)return this;this._isPaused=!0;for(var e=0;e<this._animatables.length;e++){this._animatables[e].pause()}return this.onAnimationGroupPauseObservable.notifyObservers(this),this},e.prototype.play=function(e){if(this.isStarted&&this._animatables.length===this._targetedAnimations.length){if(void 0!==e)for(var t=0;t<this._animatables.length;t++){this._animatables[t].loopAnimation=e}this.restart()}else this.stop(),this.start(e,this._speedRatio);return this._isPaused=!1,this},e.prototype.reset=function(){if(!this._isStarted)return this;for(var e=0;e<this._animatables.length;e++){this._animatables[e].reset()}return this},e.prototype.restart=function(){if(!this._isStarted)return this;for(var e=0;e<this._animatables.length;e++){this._animatables[e].restart()}return this.onAnimationGroupPlayObservable.notifyObservers(this),this},e.prototype.stop=function(){if(!this._isStarted)return this;for(var e=this._animatables.slice(),t=0;t<e.length;t++)e[t].stop();return this._isStarted=!1,this},e.prototype.setWeightForAllAnimatables=function(e){for(var t=0;t<this._animatables.length;t++){this._animatables[t].weight=e}return this},e.prototype.syncAllAnimationsWith=function(e){for(var t=0;t<this._animatables.length;t++){this._animatables[t].syncWith(e)}return this},e.prototype.goToFrame=function(e){if(!this._isStarted)return this;for(var t=0;t<this._animatables.length;t++){this._animatables[t].goToFrame(e)}return this},e.prototype.dispose=function(){this._targetedAnimations=[],this._animatables=[];var e=this._scene.animationGroups.indexOf(this);e>-1&&this._scene.animationGroups.splice(e,1),this.onAnimationEndObservable.clear(),this.onAnimationGroupEndObservable.clear(),this.onAnimationGroupPauseObservable.clear(),this.onAnimationGroupPlayObservable.clear(),this.onAnimationLoopObservable.clear()},e.prototype._checkAnimationGroupEnded=function(e){var t=this._animatables.indexOf(e);t>-1&&this._animatables.splice(t,1),0===this._animatables.length&&(this._isStarted=!1,this.onAnimationGroupEndObservable.notifyObservers(this))},e.Parse=function(t,i){for(var r=new e(t.name,i),n=0;n<t.targetedAnimations.length;n++){var o=t.targetedAnimations[n],s=N.Parse(o.animation),a=o.targetId;if("influence"===o.animation.property){var c=i.getMorphTargetById(a);c&&r.addTargetedAnimation(s,c)}else{var l=i.getNodeByID(a);null!=l&&r.addTargetedAnimation(s,l)}}return null!==t.from&&null!==t.from&&r.normalize(t.from,t.to),r},e.prototype.getClassName=function(){return"AnimationGroup"},e.prototype.toString=function(e){var t="Name: "+this.name;return t+=", type: "+this.getClassName(),e&&(t+=", from: "+this._from,t+=", to: "+this._to,t+=", isStarted: "+this._isStarted,t+=", speedRatio: "+this._speedRatio,t+=", targetedAnimations length: "+this._targetedAnimations.length,t+=", animatables length: "+this._animatables),t},e}(),Z=function(){return function(){this.enableBlending=!1,this.blendingSpeed=.01,this.loopMode=N.ANIMATIONLOOPMODE_CYCLE}}(),J=function(){function e(){this._easingMode=e.EASINGMODE_EASEIN}return e.prototype.setEasingMode=function(e){var t=Math.min(Math.max(e,0),2);this._easingMode=t},e.prototype.getEasingMode=function(){return this._easingMode},e.prototype.easeInCore=function(e){throw new Error("You must implement this method")},e.prototype.ease=function(t){switch(this._easingMode){case e.EASINGMODE_EASEIN:return this.easeInCore(t);case e.EASINGMODE_EASEOUT:return 1-this.easeInCore(1-t)}return t>=.5?.5*(1-this.easeInCore(2*(1-t)))+.5:.5*this.easeInCore(2*t)},e.EASINGMODE_EASEIN=0,e.EASINGMODE_EASEOUT=1,e.EASINGMODE_EASEINOUT=2,e}(),$=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return l.d(t,e),t.prototype.easeInCore=function(e){return e=Math.max(0,Math.min(1,e)),1-Math.sqrt(1-e*e)},t}(J),ee=function(e){function t(t){void 0===t&&(t=1);var i=e.call(this)||this;return i.amplitude=t,i}return l.d(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}(J),te=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 l.d(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.bounces),i=this.bounciness;i<=1&&(i=1.001);var r=Math.pow(i,t),n=1-i,o=(1-r)/n+.5*r,s=e*o,a=Math.log(-s*(1-i)+1)/Math.log(i),c=Math.floor(a),l=c+1,u=(1-Math.pow(i,c))/(n*o),h=.5*(u+(1-Math.pow(i,l))/(n*o)),d=e-h,f=h-u;return-Math.pow(1/i,t-c)/(f*f)*(d-f)*(d+f)},t}(J),ie=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return l.d(t,e),t.prototype.easeInCore=function(e){return e*e*e},t}(J),re=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 l.d(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}(J),ne=function(e){function t(t){void 0===t&&(t=2);var i=e.call(this)||this;return i.exponent=t,i}return l.d(t,e),t.prototype.easeInCore=function(e){return this.exponent<=0?e:(Math.exp(this.exponent*e)-1)/(Math.exp(this.exponent)-1)},t}(J),oe=function(e){function t(t){void 0===t&&(t=2);var i=e.call(this)||this;return i.power=t,i}return l.d(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.power);return Math.pow(e,t)},t}(J),se=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return l.d(t,e),t.prototype.easeInCore=function(e){return e*e},t}(J),ae=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return l.d(t,e),t.prototype.easeInCore=function(e){return e*e*e*e},t}(J),ce=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return l.d(t,e),t.prototype.easeInCore=function(e){return e*e*e*e*e},t}(J),le=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return l.d(t,e),t.prototype.easeInCore=function(e){return 1-Math.sin(1.5707963267948966*(1-e))},t}(J),ue=function(e){function t(t,i,r,n){void 0===t&&(t=0),void 0===i&&(i=0),void 0===r&&(r=1),void 0===n&&(n=1);var o=e.call(this)||this;return o.x1=t,o.y1=i,o.x2=r,o.y2=n,o}return l.d(t,e),t.prototype.easeInCore=function(e){return o.d.Interpolate(e,this.x1,this.y1,this.x2,this.y2)},t}(J),he=function(){function e(e,t,i){this.frame=e,this.action=t,this.onlyOnce=i,this.isDone=!1}return e.prototype._clone=function(){return new e(this.frame,this.action,this.onlyOnce)},e}(),de=i(10),fe=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return l.d(t,e),t}(r.a),pe=function(e){function t(t){var i=e.call(this)||this;return i.scene=t,i.sounds=[],i.effectLayers=[],i.layers=[],i.lensFlareSystems=[],i.proceduralTextures=[],i.reflectionProbes=[],i}return l.d(t,e),t.prototype.addAllToScene=function(){var e=this;this.cameras.forEach(function(t){e.scene.addCamera(t)}),this.lights.forEach(function(t){e.scene.addLight(t)}),this.meshes.forEach(function(t){e.scene.addMesh(t)}),this.skeletons.forEach(function(t){e.scene.addSkeleton(t)}),this.animations.forEach(function(t){e.scene.addAnimation(t)}),this.animationGroups.forEach(function(t){e.scene.addAnimationGroup(t)}),this.multiMaterials.forEach(function(t){e.scene.addMultiMaterial(t)}),this.materials.forEach(function(t){e.scene.addMaterial(t)}),this.morphTargetManagers.forEach(function(t){e.scene.addMorphTargetManager(t)}),this.geometries.forEach(function(t){e.scene.addGeometry(t)}),this.transformNodes.forEach(function(t){e.scene.addTransformNode(t)}),this.actionManagers.forEach(function(t){e.scene.addActionManager(t)}),this.textures.forEach(function(t){e.scene.addTexture(t)}),this.reflectionProbes.forEach(function(t){e.scene.addReflectionProbe(t)});for(var t=0,i=this.scene._serializableComponents;t<i.length;t++){i[t].addFromContainer(this)}},t.prototype.removeAllFromScene=function(){var e=this;this.cameras.forEach(function(t){e.scene.removeCamera(t)}),this.lights.forEach(function(t){e.scene.removeLight(t)}),this.meshes.forEach(function(t){e.scene.removeMesh(t)}),this.skeletons.forEach(function(t){e.scene.removeSkeleton(t)}),this.animations.forEach(function(t){e.scene.removeAnimation(t)}),this.animationGroups.forEach(function(t){e.scene.removeAnimationGroup(t)}),this.multiMaterials.forEach(function(t){e.scene.removeMultiMaterial(t)}),this.materials.forEach(function(t){e.scene.removeMaterial(t)}),this.morphTargetManagers.forEach(function(t){e.scene.removeMorphTargetManager(t)}),this.geometries.forEach(function(t){e.scene.removeGeometry(t)}),this.transformNodes.forEach(function(t){e.scene.removeTransformNode(t)}),this.actionManagers.forEach(function(t){e.scene.removeActionManager(t)}),this.textures.forEach(function(t){e.scene.removeTexture(t)}),this.reflectionProbes.forEach(function(t){e.scene.removeReflectionProbe(t)});for(var t=0,i=this.scene._serializableComponents;t<i.length;t++){i[t].removeFromContainer(this)}},t.prototype.dispose=function(){this.cameras.forEach(function(e){e.dispose()}),this.lights.forEach(function(e){e.dispose()}),this.meshes.forEach(function(e){e.dispose()}),this.skeletons.forEach(function(e){e.dispose()}),this.animationGroups.forEach(function(e){e.dispose()}),this.multiMaterials.forEach(function(e){e.dispose()}),this.materials.forEach(function(e){e.dispose()}),this.geometries.forEach(function(e){e.dispose()}),this.transformNodes.forEach(function(e){e.dispose()}),this.actionManagers.forEach(function(e){e.dispose()}),this.textures.forEach(function(e){e.dispose()}),this.reflectionProbes.forEach(function(e){e.dispose()});for(var e=0,t=this.scene._serializableComponents;e<t.length;e++){t[e].dispose()}},t.prototype._moveAssets=function(e,t,i){if(e)for(var r=0,n=e;r<n.length;r++){var o=n[r],s=!0;if(i)for(var a=0,c=i;a<c.length;a++){if(o===c[a]){s=!1;break}}s&&t.push(o)}},t.prototype.moveAllFromScene=function(e){for(var t in void 0===e&&(e=new fe),this)this.hasOwnProperty(t)&&(this[t]=this[t]||[],this._moveAssets(this.scene[t],this[t],e[t]));this.removeAllFromScene()},t.prototype.createRootMesh=function(){var e=new de.a("assetContainerRootMesh",this.scene);return this.meshes.forEach(function(t){t.parent||e.addChild(t)}),this.meshes.unshift(e),e},t}(r.a),_e=i(11),ge=function(){function e(e){this.SMOOTHING=.75,this.FFT_SIZE=512,this.BARGRAPHAMPLITUDE=256,this.DEBUGCANVASPOS={x:20,y:20},this.DEBUGCANVASSIZE={width:320,height:200},this._scene=e,this._audioEngine=_e.b.audioEngine,this._audioEngine.canUseWebAudio&&this._audioEngine.audioContext&&(this._webAudioAnalyser=this._audioEngine.audioContext.createAnalyser(),this._webAudioAnalyser.minDecibels=-140,this._webAudioAnalyser.maxDecibels=0,this._byteFreqs=new Uint8Array(this._webAudioAnalyser.frequencyBinCount),this._byteTime=new Uint8Array(this._webAudioAnalyser.frequencyBinCount),this._floatFreqs=new Float32Array(this._webAudioAnalyser.frequencyBinCount))}return e.prototype.getFrequencyBinCount=function(){return this._audioEngine.canUseWebAudio?this._webAudioAnalyser.frequencyBinCount:0},e.prototype.getByteFrequencyData=function(){return this._audioEngine.canUseWebAudio&&(this._webAudioAnalyser.smoothingTimeConstant=this.SMOOTHING,this._webAudioAnalyser.fftSize=this.FFT_SIZE,this._webAudioAnalyser.getByteFrequencyData(this._byteFreqs)),this._byteFreqs},e.prototype.getByteTimeDomainData=function(){return this._audioEngine.canUseWebAudio&&(this._webAudioAnalyser.smoothingTimeConstant=this.SMOOTHING,this._webAudioAnalyser.fftSize=this.FFT_SIZE,this._webAudioAnalyser.getByteTimeDomainData(this._byteTime)),this._byteTime},e.prototype.getFloatFrequencyData=function(){return this._audioEngine.canUseWebAudio&&(this._webAudioAnalyser.smoothingTimeConstant=this.SMOOTHING,this._webAudioAnalyser.fftSize=this.FFT_SIZE,this._webAudioAnalyser.getFloatFrequencyData(this._floatFreqs)),this._floatFreqs},e.prototype.drawDebugCanvas=function(){var e=this;if(this._audioEngine.canUseWebAudio&&(this._debugCanvas||(this._debugCanvas=document.createElement("canvas"),this._debugCanvas.width=this.DEBUGCANVASSIZE.width,this._debugCanvas.height=this.DEBUGCANVASSIZE.height,this._debugCanvas.style.position="absolute",this._debugCanvas.style.top=this.DEBUGCANVASPOS.y+"px",this._debugCanvas.style.left=this.DEBUGCANVASPOS.x+"px",this._debugCanvasContext=this._debugCanvas.getContext("2d"),document.body.appendChild(this._debugCanvas),this._registerFunc=function(){e.drawDebugCanvas()},this._scene.registerBeforeRender(this._registerFunc)),this._registerFunc&&this._debugCanvasContext)){var t=this.getByteFrequencyData();this._debugCanvasContext.fillStyle="rgb(0, 0, 0)",this._debugCanvasContext.fillRect(0,0,this.DEBUGCANVASSIZE.width,this.DEBUGCANVASSIZE.height);for(var i=0;i<this.getFrequencyBinCount();i++){var r=t[i]/this.BARGRAPHAMPLITUDE,n=this.DEBUGCANVASSIZE.height*r,o=this.DEBUGCANVASSIZE.height-n-1,s=this.DEBUGCANVASSIZE.width/this.getFrequencyBinCount(),a=i/this.getFrequencyBinCount()*360;this._debugCanvasContext.fillStyle="hsl("+a+", 100%, 50%)",this._debugCanvasContext.fillRect(i*s,o,s,n)}}},e.prototype.stopDebugCanvas=function(){this._debugCanvas&&(this._registerFunc&&(this._scene.unregisterBeforeRender(this._registerFunc),this._registerFunc=null),document.body.removeChild(this._debugCanvas),this._debugCanvas=null,this._debugCanvasContext=null)},e.prototype.connectAudioNodes=function(e,t){this._audioEngine.canUseWebAudio&&(e.connect(this._webAudioAnalyser),this._webAudioAnalyser.connect(t))},e.prototype.dispose=function(){this._audioEngine.canUseWebAudio&&this._webAudioAnalyser.disconnect()},e}();_e.b.AudioEngineFactory=function(e){return new me(e)};var me=function(){function e(e){void 0===e&&(e=null);var t=this;this._audioContext=null,this._audioContextInitialized=!1,this._muteButton=null,this.canUseWebAudio=!1,this.WarnedWebAudioUnsupported=!1,this.isMP3supported=!1,this.isOGGsupported=!1,this.unlocked=!0,this.useCustomUnlockedButton=!1,this.onAudioUnlockedObservable=new n.c,this.onAudioLockedObservable=new n.c,this._tryToRun=!1,this._onResize=function(){t._moveButtonToTopLeft()},void 0===window.AudioContext&&void 0===window.webkitAudioContext||(window.AudioContext=window.AudioContext||window.webkitAudioContext,this.canUseWebAudio=!0);var i=document.createElement("audio");this._hostElement=e;try{i&&i.canPlayType&&i.canPlayType('audio/mpeg; codecs="mp3"').replace(/^no$/,"")&&(this.isMP3supported=!0)}catch(e){}try{i&&i.canPlayType&&i.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,"")&&(this.isOGGsupported=!0)}catch(e){}}return Object.defineProperty(e.prototype,"audioContext",{get:function(){return this._audioContextInitialized?this.unlocked||this._muteButton||this._displayMuteButton():this._initializeAudioContext(),this._audioContext},enumerable:!0,configurable:!0}),e.prototype.lock=function(){this._triggerSuspendedState()},e.prototype.unlock=function(){this._triggerRunningState()},e.prototype._resumeAudioContext=function(){var e;return this._audioContext.resume&&(e=this._audioContext.resume()),e||Promise.resolve()},e.prototype._initializeAudioContext=function(){try{this.canUseWebAudio&&(this._audioContext=new AudioContext,this.masterGain=this._audioContext.createGain(),this.masterGain.gain.value=1,this.masterGain.connect(this._audioContext.destination),this._audioContextInitialized=!0,"running"===this._audioContext.state&&this._triggerRunningState())}catch(e){this.canUseWebAudio=!1,p.a.Error("Web Audio: "+e.message)}},e.prototype._triggerRunningState=function(){var e=this;this._tryToRun||(this._tryToRun=!0,this._resumeAudioContext().then(function(){e._tryToRun=!1,e._muteButton&&e._hideMuteButton()}).catch(function(){e._tryToRun=!1,e.unlocked=!1}),this.unlocked=!0,this.onAudioUnlockedObservable.notifyObservers(this))},e.prototype._triggerSuspendedState=function(){this.unlocked=!1,this.onAudioLockedObservable.notifyObservers(this),this._displayMuteButton()},e.prototype._displayMuteButton=function(){var e=this;if(!this.useCustomUnlockedButton&&!this._muteButton){this._muteButton=document.createElement("BUTTON"),this._muteButton.className="babylonUnmuteIcon",this._muteButton.id="babylonUnmuteIconBtn",this._muteButton.title="Unmute";var t=document.createElement("style");t.appendChild(document.createTextNode(".babylonUnmuteIcon { position: absolute; left: 20px; top: 20px; height: 40px; width: 60px; background-color: rgba(51,51,51,0.7); background-image: url(data:image/svg+xml;charset=UTF-8,%3Csvg%20version%3D%221.1%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2239%22%20height%3D%2232%22%20viewBox%3D%220%200%2039%2032%22%3E%3Cpath%20fill%3D%22white%22%20d%3D%22M9.625%2018.938l-0.031%200.016h-4.953q-0.016%200-0.031-0.016v-12.453q0-0.016%200.031-0.016h4.953q0.031%200%200.031%200.016v12.453zM12.125%207.688l8.719-8.703v27.453l-8.719-8.719-0.016-0.047v-9.938zM23.359%207.875l1.406-1.406%204.219%204.203%204.203-4.203%201.422%201.406-4.219%204.219%204.219%204.203-1.484%201.359-4.141-4.156-4.219%204.219-1.406-1.422%204.219-4.203z%22%3E%3C%2Fpath%3E%3C%2Fsvg%3E); background-size: 80%; background-repeat:no-repeat; background-position: center; background-position-y: 4px; border: none; outline: none; transition: transform 0.125s ease-out; cursor: pointer; z-index: 9999; } .babylonUnmuteIcon:hover { transform: scale(1.05) } .babylonUnmuteIcon:active { background-color: rgba(51,51,51,1) }")),document.getElementsByTagName("head")[0].appendChild(t),document.body.appendChild(this._muteButton),this._moveButtonToTopLeft(),this._muteButton.addEventListener("touchend",function(){e._triggerRunningState()},!0),this._muteButton.addEventListener("click",function(){e._triggerRunningState()},!0),window.addEventListener("resize",this._onResize)}},e.prototype._moveButtonToTopLeft=function(){this._hostElement&&this._muteButton&&(this._muteButton.style.top=this._hostElement.offsetTop+20+"px",this._muteButton.style.left=this._hostElement.offsetLeft+20+"px")},e.prototype._hideMuteButton=function(){this._muteButton&&(document.body.removeChild(this._muteButton),this._muteButton=null)},e.prototype.dispose=function(){this.canUseWebAudio&&this._audioContextInitialized&&(this._connectedAnalyser&&this._audioContext&&(this._connectedAnalyser.stopDebugCanvas(),this._connectedAnalyser.dispose(),this.masterGain.disconnect(),this.masterGain.connect(this._audioContext.destination),this._connectedAnalyser=null),this.masterGain.gain.value=1),this.WarnedWebAudioUnsupported=!1,this._hideMuteButton(),window.removeEventListener("resize",this._onResize),this.onAudioUnlockedObservable.clear(),this.onAudioLockedObservable.clear()},e.prototype.getGlobalVolume=function(){return this.canUseWebAudio&&this._audioContextInitialized?this.masterGain.gain.value:-1},e.prototype.setGlobalVolume=function(e){this.canUseWebAudio&&this._audioContextInitialized&&(this.masterGain.gain.value=e)},e.prototype.connectToAnalyser=function(e){this._connectedAnalyser&&this._connectedAnalyser.stopDebugCanvas(),this.canUseWebAudio&&this._audioContextInitialized&&this._audioContext&&(this._connectedAnalyser=e,this.masterGain.disconnect(),this._connectedAnalyser.connectAudioNodes(this.masterGain,this._audioContext.destination))},e}(),ve=i(9),ye=function(){function e(t,i,r,s,a){void 0===s&&(s=null);var c=this;if(this.autoplay=!1,this.loop=!1,this.useCustomAttenuation=!1,this.isPlaying=!1,this.isPaused=!1,this.spatialSound=!1,this.refDistance=1,this.rolloffFactor=1,this.maxDistance=100,this.distanceModel="linear",this.onEndedObservable=new n.c,this._panningModel="equalpower",this._playbackRate=1,this._streaming=!1,this._startTime=0,this._startOffset=0,this._position=o.x.Zero(),this._positionInEmitterSpace=!1,this._localDirection=new o.x(1,0,0),this._volume=1,this._isReadyToPlay=!1,this._isDirectional=!1,this._coneInnerAngle=360,this._coneOuterAngle=360,this._coneOuterGain=0,this._isOutputConnected=!1,this._urlType="Unknown",this.name=t,this._scene=r,e._SceneComponentInitialization(r),this._readyToPlayCallback=s,this._customAttenuationFunction=function(e,t,i,r,n){return t<i?e*(1-t/i):0},a&&(this.autoplay=a.autoplay||!1,this.loop=a.loop||!1,void 0!==a.volume&&(this._volume=a.volume),this.spatialSound=a.spatialSound||!1,this.maxDistance=a.maxDistance||100,this.useCustomAttenuation=a.useCustomAttenuation||!1,this.rolloffFactor=a.rolloffFactor||1,this.refDistance=a.refDistance||1,this.distanceModel=a.distanceModel||"linear",this._playbackRate=a.playbackRate||1,this._streaming=a.streaming||!1),_e.b.audioEngine.canUseWebAudio&&_e.b.audioEngine.audioContext){this._soundGain=_e.b.audioEngine.audioContext.createGain(),this._soundGain.gain.value=this._volume,this._inputAudioNode=this._soundGain,this._outputAudioNode=this._soundGain,this.spatialSound&&this._createSpatialParameters(),this._scene.mainSoundTrack.AddSound(this);var l=!0;if(i)try{"string"==typeof i?this._urlType="String":i instanceof ArrayBuffer?this._urlType="ArrayBuffer":i instanceof MediaStream?this._urlType="MediaStream":Array.isArray(i)&&(this._urlType="Array");var u=[],h=!1;switch(this._urlType){case"MediaStream":this._streaming=!0,this._isReadyToPlay=!0,this._streamingSource=_e.b.audioEngine.audioContext.createMediaElementSource(i),this.autoplay&&this.play(),this._readyToPlayCallback&&this._readyToPlayCallback();break;case"ArrayBuffer":i.byteLength>0&&(h=!0,this._soundLoaded(i));break;case"String":u.push(i);case"Array":0===u.length&&(u=i);for(var d=0;d<u.length;d++){var f=u[d];if(-1!==f.indexOf(".mp3",f.length-4)&&_e.b.audioEngine.isMP3supported&&(h=!0),-1!==f.indexOf(".ogg",f.length-4)&&_e.b.audioEngine.isOGGsupported&&(h=!0),-1!==f.indexOf(".wav",f.length-4)&&(h=!0),-1!==f.indexOf("blob:")&&(h=!0),h){this._streaming?(this._htmlAudioElement=new Audio(f),this._htmlAudioElement.controls=!1,this._htmlAudioElement.loop=this.loop,ve.h.SetCorsBehavior(f,this._htmlAudioElement),this._htmlAudioElement.preload="auto",this._htmlAudioElement.addEventListener("canplaythrough",function(){c._isReadyToPlay=!0,c.autoplay&&c.play(),c._readyToPlayCallback&&c._readyToPlayCallback()}),document.body.appendChild(this._htmlAudioElement),this._htmlAudioElement.load()):this._scene._loadFile(f,function(e){c._soundLoaded(e)},void 0,!0,!0,function(e){e&&p.a.Error("XHR "+e.status+" error on: "+f+"."),p.a.Error("Sound creation aborted."),c._scene.mainSoundTrack.RemoveSound(c)});break}}break;default:l=!1}l?h||(this._isReadyToPlay=!0,this._readyToPlayCallback&&window.setTimeout(function(){c._readyToPlayCallback&&c._readyToPlayCallback()},1e3)):p.a.Error("Parameter must be a URL to the sound, an Array of URLs (.mp3 & .ogg) or an ArrayBuffer of the sound.")}catch(e){p.a.Error("Unexpected error. Sound creation aborted."),this._scene.mainSoundTrack.RemoveSound(this)}}else this._scene.mainSoundTrack.AddSound(this),_e.b.audioEngine.WarnedWebAudioUnsupported||(p.a.Error("Web Audio is not supported by your browser."),_e.b.audioEngine.WarnedWebAudioUnsupported=!0),this._readyToPlayCallback&&window.setTimeout(function(){c._readyToPlayCallback&&c._readyToPlayCallback()},1e3)}return e.prototype.dispose=function(){_e.b.audioEngine.canUseWebAudio&&(this.isPlaying&&this.stop(),this._isReadyToPlay=!1,-1===this.soundTrackId?this._scene.mainSoundTrack.RemoveSound(this):this._scene.soundTracks&&this._scene.soundTracks[this.soundTrackId].RemoveSound(this),this._soundGain&&(this._soundGain.disconnect(),this._soundGain=null),this._soundPanner&&(this._soundPanner.disconnect(),this._soundPanner=null),this._soundSource&&(this._soundSource.disconnect(),this._soundSource=null),this._audioBuffer=null,this._htmlAudioElement&&(this._htmlAudioElement.pause(),this._htmlAudioElement.src="",document.body.removeChild(this._htmlAudioElement)),this._streamingSource&&this._streamingSource.disconnect(),this._connectedTransformNode&&this._registerFunc&&(this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc),this._connectedTransformNode=null))},e.prototype.isReady=function(){return this._isReadyToPlay},e.prototype._soundLoaded=function(e){var t=this;_e.b.audioEngine.audioContext&&_e.b.audioEngine.audioContext.decodeAudioData(e,function(e){t._audioBuffer=e,t._isReadyToPlay=!0,t.autoplay&&t.play(),t._readyToPlayCallback&&t._readyToPlayCallback()},function(e){p.a.Error("Error while decoding audio data for: "+t.name+" / Error: "+e)})},e.prototype.setAudioBuffer=function(e){_e.b.audioEngine.canUseWebAudio&&(this._audioBuffer=e,this._isReadyToPlay=!0)},e.prototype.updateOptions=function(e){e&&(this.loop=e.loop||this.loop,this.maxDistance=e.maxDistance||this.maxDistance,this.useCustomAttenuation=e.useCustomAttenuation||this.useCustomAttenuation,this.rolloffFactor=e.rolloffFactor||this.rolloffFactor,this.refDistance=e.refDistance||this.refDistance,this.distanceModel=e.distanceModel||this.distanceModel,this._playbackRate=e.playbackRate||this._playbackRate,this._updateSpatialParameters(),this.isPlaying&&(this._streaming&&this._htmlAudioElement?this._htmlAudioElement.playbackRate=this._playbackRate:this._soundSource&&(this._soundSource.playbackRate.value=this._playbackRate)))},e.prototype._createSpatialParameters=function(){_e.b.audioEngine.canUseWebAudio&&_e.b.audioEngine.audioContext&&(this._scene.headphone&&(this._panningModel="HRTF"),this._soundPanner=_e.b.audioEngine.audioContext.createPanner(),this._updateSpatialParameters(),this._soundPanner.connect(this._outputAudioNode),this._inputAudioNode=this._soundPanner)},e.prototype._updateSpatialParameters=function(){this.spatialSound&&this._soundPanner&&(this.useCustomAttenuation?(this._soundPanner.distanceModel="linear",this._soundPanner.maxDistance=Number.MAX_VALUE,this._soundPanner.refDistance=1,this._soundPanner.rolloffFactor=1,this._soundPanner.panningModel=this._panningModel):(this._soundPanner.distanceModel=this.distanceModel,this._soundPanner.maxDistance=this.maxDistance,this._soundPanner.refDistance=this.refDistance,this._soundPanner.rolloffFactor=this.rolloffFactor,this._soundPanner.panningModel=this._panningModel))},e.prototype.switchPanningModelToHRTF=function(){this._panningModel="HRTF",this._switchPanningModel()},e.prototype.switchPanningModelToEqualPower=function(){this._panningModel="equalpower",this._switchPanningModel()},e.prototype._switchPanningModel=function(){_e.b.audioEngine.canUseWebAudio&&this.spatialSound&&this._soundPanner&&(this._soundPanner.panningModel=this._panningModel)},e.prototype.connectToSoundTrackAudioNode=function(e){_e.b.audioEngine.canUseWebAudio&&(this._isOutputConnected&&this._outputAudioNode.disconnect(),this._outputAudioNode.connect(e),this._isOutputConnected=!0)},e.prototype.setDirectionalCone=function(e,t,i){t<e?p.a.Error("setDirectionalCone(): outer angle of the cone must be superior or equal to the inner angle."):(this._coneInnerAngle=e,this._coneOuterAngle=t,this._coneOuterGain=i,this._isDirectional=!0,this.isPlaying&&this.loop&&(this.stop(),this.play()))},Object.defineProperty(e.prototype,"directionalConeInnerAngle",{get:function(){return this._coneInnerAngle},set:function(e){if(e!=this._coneInnerAngle){if(this._coneOuterAngle<e)return void p.a.Error("directionalConeInnerAngle: outer angle of the cone must be superior or equal to the inner angle.");this._coneInnerAngle=e,_e.b.audioEngine.canUseWebAudio&&this.spatialSound&&this._soundPanner&&(this._soundPanner.coneInnerAngle=this._coneInnerAngle)}},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"directionalConeOuterAngle",{get:function(){return this._coneOuterAngle},set:function(e){if(e!=this._coneOuterAngle){if(e<this._coneInnerAngle)return void p.a.Error("directionalConeOuterAngle: outer angle of the cone must be superior or equal to the inner angle.");this._coneOuterAngle=e,_e.b.audioEngine.canUseWebAudio&&this.spatialSound&&this._soundPanner&&(this._soundPanner.coneOuterAngle=this._coneOuterAngle)}},enumerable:!0,configurable:!0}),e.prototype.setPosition=function(e){this._position=e,_e.b.audioEngine.canUseWebAudio&&this.spatialSound&&this._soundPanner&&!isNaN(this._position.x)&&!isNaN(this._position.y)&&!isNaN(this._position.z)&&this._soundPanner.setPosition(this._position.x,this._position.y,this._position.z)},e.prototype.setLocalDirectionToMesh=function(e){this._localDirection=e,_e.b.audioEngine.canUseWebAudio&&this._connectedTransformNode&&this.isPlaying&&this._updateDirection()},e.prototype._updateDirection=function(){if(this._connectedTransformNode&&this._soundPanner){var e=this._connectedTransformNode.getWorldMatrix(),t=o.x.TransformNormal(this._localDirection,e);t.normalize(),this._soundPanner.setOrientation(t.x,t.y,t.z)}},e.prototype.updateDistanceFromListener=function(){if(_e.b.audioEngine.canUseWebAudio&&this._connectedTransformNode&&this.useCustomAttenuation&&this._soundGain&&this._scene.activeCamera){var e=this._connectedTransformNode.getDistanceToCamera(this._scene.activeCamera);this._soundGain.gain.value=this._customAttenuationFunction(this._volume,e,this.maxDistance,this.refDistance,this.rolloffFactor)}},e.prototype.setAttenuationFunction=function(e){this._customAttenuationFunction=e},e.prototype.play=function(e,t){var i=this;if(this._isReadyToPlay&&this._scene.audioEnabled&&_e.b.audioEngine.audioContext)try{this._startOffset<0&&(e=-this._startOffset,this._startOffset=0);var r=e?_e.b.audioEngine.audioContext.currentTime+e:_e.b.audioEngine.audioContext.currentTime;if(this._soundSource&&this._streamingSource||this.spatialSound&&this._soundPanner&&(isNaN(this._position.x)||isNaN(this._position.y)||isNaN(this._position.z)||this._soundPanner.setPosition(this._position.x,this._position.y,this._position.z),this._isDirectional&&(this._soundPanner.coneInnerAngle=this._coneInnerAngle,this._soundPanner.coneOuterAngle=this._coneOuterAngle,this._soundPanner.coneOuterGain=this._coneOuterGain,this._connectedTransformNode?this._updateDirection():this._soundPanner.setOrientation(this._localDirection.x,this._localDirection.y,this._localDirection.z))),this._streaming){if(this._streamingSource||(this._streamingSource=_e.b.audioEngine.audioContext.createMediaElementSource(this._htmlAudioElement),this._htmlAudioElement.onended=function(){i._onended()},this._htmlAudioElement.playbackRate=this._playbackRate),this._streamingSource.disconnect(),this._streamingSource.connect(this._inputAudioNode),this._htmlAudioElement)(n=function(){if(_e.b.audioEngine.unlocked){var e=i._htmlAudioElement.play();void 0!==e&&e.catch(function(e){_e.b.audioEngine.lock(),(i.loop||i.autoplay)&&_e.b.audioEngine.onAudioUnlockedObservable.addOnce(function(){n()})})}else(i.loop||i.autoplay)&&_e.b.audioEngine.onAudioUnlockedObservable.addOnce(function(){n()})})()}else{var n=function(){_e.b.audioEngine.audioContext&&(i._soundSource=_e.b.audioEngine.audioContext.createBufferSource(),i._soundSource.buffer=i._audioBuffer,i._soundSource.connect(i._inputAudioNode),i._soundSource.loop=i.loop,i._soundSource.playbackRate.value=i._playbackRate,i._soundSource.onended=function(){i._onended()},r=e?_e.b.audioEngine.audioContext.currentTime+e:_e.b.audioEngine.audioContext.currentTime,i._soundSource.start(r,i.isPaused?i._startOffset%i._soundSource.buffer.duration:t||0))};"suspended"===_e.b.audioEngine.audioContext.state?setTimeout(function(){"suspended"===_e.b.audioEngine.audioContext.state?(_e.b.audioEngine.lock(),(i.loop||i.autoplay)&&_e.b.audioEngine.onAudioUnlockedObservable.addOnce(function(){n()})):n()},500):n()}this._startTime=r,this.isPlaying=!0,this.isPaused=!1}catch(e){p.a.Error("Error while trying to play audio: "+this.name+", "+e.message)}},e.prototype._onended=function(){this.isPlaying=!1,this.onended&&this.onended(),this.onEndedObservable.notifyObservers(this)},e.prototype.stop=function(e){if(this.isPlaying){if(this._streaming)this._htmlAudioElement?(this._htmlAudioElement.pause(),this._htmlAudioElement.currentTime>0&&(this._htmlAudioElement.currentTime=0)):this._streamingSource.disconnect();else if(_e.b.audioEngine.audioContext&&this._soundSource){var t=e?_e.b.audioEngine.audioContext.currentTime+e:_e.b.audioEngine.audioContext.currentTime;this._soundSource.stop(t),this._soundSource.onended=function(){},this.isPaused||(this._startOffset=0)}this.isPlaying=!1}},e.prototype.pause=function(){this.isPlaying&&(this.isPaused=!0,this._streaming?this._htmlAudioElement?this._htmlAudioElement.pause():this._streamingSource.disconnect():_e.b.audioEngine.audioContext&&(this.stop(0),this._startOffset+=_e.b.audioEngine.audioContext.currentTime-this._startTime))},e.prototype.setVolume=function(e,t){_e.b.audioEngine.canUseWebAudio&&this._soundGain&&(t&&_e.b.audioEngine.audioContext?(this._soundGain.gain.cancelScheduledValues(_e.b.audioEngine.audioContext.currentTime),this._soundGain.gain.setValueAtTime(this._soundGain.gain.value,_e.b.audioEngine.audioContext.currentTime),this._soundGain.gain.linearRampToValueAtTime(e,_e.b.audioEngine.audioContext.currentTime+t)):this._soundGain.gain.value=e),this._volume=e},e.prototype.setPlaybackRate=function(e){this._playbackRate=e,this.isPlaying&&(this._streaming&&this._htmlAudioElement?this._htmlAudioElement.playbackRate=this._playbackRate:this._soundSource&&(this._soundSource.playbackRate.value=this._playbackRate))},e.prototype.getVolume=function(){return this._volume},e.prototype.attachToMesh=function(e){var t=this;this._connectedTransformNode&&this._registerFunc&&(this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc),this._registerFunc=null),this._connectedTransformNode=e,this.spatialSound||(this.spatialSound=!0,this._createSpatialParameters(),this.isPlaying&&this.loop&&(this.stop(),this.play())),this._onRegisterAfterWorldMatrixUpdate(this._connectedTransformNode),this._registerFunc=function(e){return t._onRegisterAfterWorldMatrixUpdate(e)},this._connectedTransformNode.registerAfterWorldMatrixUpdate(this._registerFunc)},e.prototype.detachFromMesh=function(){this._connectedTransformNode&&this._registerFunc&&(this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc),this._registerFunc=null,this._connectedTransformNode=null)},e.prototype._onRegisterAfterWorldMatrixUpdate=function(e){if(e.getBoundingInfo){var t=e;if(this._positionInEmitterSpace)t.worldMatrixFromCache.invertToRef(o.t.Matrix[0]),this.setPosition(o.t.Matrix[0].getTranslation());else{var i=t.getBoundingInfo();this.setPosition(i.boundingSphere.centerWorld)}_e.b.audioEngine.canUseWebAudio&&this._isDirectional&&this.isPlaying&&this._updateDirection()}},e.prototype.clone=function(){var t=this;if(this._streaming)return null;var i=function(){t._isReadyToPlay?(n._audioBuffer=t.getAudioBuffer(),n._isReadyToPlay=!0,n.autoplay&&n.play()):window.setTimeout(i,300)},r={autoplay:this.autoplay,loop:this.loop,volume:this._volume,spatialSound:this.spatialSound,maxDistance:this.maxDistance,useCustomAttenuation:this.useCustomAttenuation,rolloffFactor:this.rolloffFactor,refDistance:this.refDistance,distanceModel:this.distanceModel},n=new e(this.name+"_cloned",new ArrayBuffer(0),this._scene,null,r);return this.useCustomAttenuation&&n.setAttenuationFunction(this._customAttenuationFunction),n.setPosition(this._position),n.setPlaybackRate(this._playbackRate),i(),n},e.prototype.getAudioBuffer=function(){return this._audioBuffer},e.prototype.serialize=function(){var e={name:this.name,url:this.name,autoplay:this.autoplay,loop:this.loop,volume:this._volume,spatialSound:this.spatialSound,maxDistance:this.maxDistance,rolloffFactor:this.rolloffFactor,refDistance:this.refDistance,distanceModel:this.distanceModel,playbackRate:this._playbackRate,panningModel:this._panningModel,soundTrackId:this.soundTrackId};return this.spatialSound&&(this._connectedTransformNode&&(e.connectedMeshId=this._connectedTransformNode.id),e.position=this._position.asArray(),e.refDistance=this.refDistance,e.distanceModel=this.distanceModel,e.isDirectional=this._isDirectional,e.localDirectionToMesh=this._localDirection.asArray(),e.coneInnerAngle=this._coneInnerAngle,e.coneOuterAngle=this._coneOuterAngle,e.coneOuterGain=this._coneOuterGain),e},e.Parse=function(t,i,r,n){var s,a=t.name;s=t.url?r+t.url:r+a;var c,l={autoplay:t.autoplay,loop:t.loop,volume:t.volume,spatialSound:t.spatialSound,maxDistance:t.maxDistance,rolloffFactor:t.rolloffFactor,refDistance:t.refDistance,distanceModel:t.distanceModel,playbackRate:t.playbackRate};if(n){var u=function(){n._isReadyToPlay?(c._audioBuffer=n.getAudioBuffer(),c._isReadyToPlay=!0,c.autoplay&&c.play()):window.setTimeout(u,300)};c=new e(a,new ArrayBuffer(0),i,null,l),u()}else c=new e(a,s,i,function(){i._removePendingData(c)},l),i._addPendingData(c);if(t.position){var h=o.x.FromArray(t.position);c.setPosition(h)}if(t.isDirectional&&(c.setDirectionalCone(t.coneInnerAngle||360,t.coneOuterAngle||360,t.coneOuterGain||0),t.localDirectionToMesh)){var d=o.x.FromArray(t.localDirectionToMesh);c.setLocalDirectionToMesh(d)}if(t.connectedMeshId){var f=i.getMeshByID(t.connectedMeshId);f&&c.attachToMesh(f)}return c},e._SceneComponentInitialization=function(e){throw"Import AudioSceneComponent before creating sound."},e}(),be=function(){function e(e,t){void 0===t&&(t={}),this.id=-1,this._isMainTrack=!1,this._isInitialized=!1,this._scene=e,this.soundCollection=new Array,this._options=t,!this._isMainTrack&&this._scene.soundTracks&&(this._scene.soundTracks.push(this),this.id=this._scene.soundTracks.length-1)}return e.prototype._initializeSoundTrackAudioGraph=function(){_e.b.audioEngine.canUseWebAudio&&_e.b.audioEngine.audioContext&&(this._outputAudioNode=_e.b.audioEngine.audioContext.createGain(),this._outputAudioNode.connect(_e.b.audioEngine.masterGain),this._options&&(this._options.volume&&(this._outputAudioNode.gain.value=this._options.volume),this._options.mainTrack&&(this._isMainTrack=this._options.mainTrack)),this._isInitialized=!0)},e.prototype.dispose=function(){if(_e.b.audioEngine&&_e.b.audioEngine.canUseWebAudio){for(this._connectedAnalyser&&this._connectedAnalyser.stopDebugCanvas();this.soundCollection.length;)this.soundCollection[0].dispose();this._outputAudioNode&&this._outputAudioNode.disconnect(),this._outputAudioNode=null}},e.prototype.AddSound=function(e){this._isInitialized||this._initializeSoundTrackAudioGraph(),_e.b.audioEngine.canUseWebAudio&&this._outputAudioNode&&e.connectToSoundTrackAudioNode(this._outputAudioNode),e.soundTrackId&&(-1===e.soundTrackId?this._scene.mainSoundTrack.RemoveSound(e):this._scene.soundTracks&&this._scene.soundTracks[e.soundTrackId].RemoveSound(e)),this.soundCollection.push(e),e.soundTrackId=this.id},e.prototype.RemoveSound=function(e){var t=this.soundCollection.indexOf(e);-1!==t&&this.soundCollection.splice(t,1)},e.prototype.setVolume=function(e){_e.b.audioEngine.canUseWebAudio&&this._outputAudioNode&&(this._outputAudioNode.gain.value=e)},e.prototype.switchPanningModelToHRTF=function(){if(_e.b.audioEngine.canUseWebAudio)for(var e=0;e<this.soundCollection.length;e++)this.soundCollection[e].switchPanningModelToHRTF()},e.prototype.switchPanningModelToEqualPower=function(){if(_e.b.audioEngine.canUseWebAudio)for(var e=0;e<this.soundCollection.length;e++)this.soundCollection[e].switchPanningModelToEqualPower()},e.prototype.connectToAnalyser=function(e){this._connectedAnalyser&&this._connectedAnalyser.stopDebugCanvas(),this._connectedAnalyser=e,_e.b.audioEngine.canUseWebAudio&&this._outputAudioNode&&(this._outputAudioNode.disconnect(),this._connectedAnalyser.connectAudioNodes(this._outputAudioNode,_e.b.audioEngine.masterGain))},e}(),Te=i(14);r.a.AddParser(Te.a.NAME_AUDIO,function(e,t,i,r){var n,o=[];if(i.sounds=i.sounds||[],void 0!==e.sounds&&null!==e.sounds)for(var s=0,a=e.sounds.length;s<a;s++){var c=e.sounds[s];_e.b.audioEngine.canUseWebAudio?(c.url||(c.url=c.name),o[c.url]?i.sounds.push(ye.Parse(c,t,r,o[c.url])):(n=ye.Parse(c,t,r),o[c.url]=n,i.sounds.push(n))):i.sounds.push(new ye(c.name,null,t))}o=[]}),Object.defineProperty(W.a.prototype,"mainSoundTrack",{get:function(){var e=this._getComponent(Te.a.NAME_AUDIO);return e||(e=new Ee(this),this._addComponent(e)),this._mainSoundTrack||(this._mainSoundTrack=new be(this,{mainTrack:!0})),this._mainSoundTrack},enumerable:!0,configurable:!0}),W.a.prototype.getSoundByName=function(e){var t;for(t=0;t<this.mainSoundTrack.soundCollection.length;t++)if(this.mainSoundTrack.soundCollection[t].name===e)return this.mainSoundTrack.soundCollection[t];if(this.soundTracks)for(var i=0;i<this.soundTracks.length;i++)for(t=0;t<this.soundTracks[i].soundCollection.length;t++)if(this.soundTracks[i].soundCollection[t].name===e)return this.soundTracks[i].soundCollection[t];return null},Object.defineProperty(W.a.prototype,"audioEnabled",{get:function(){var e=this._getComponent(Te.a.NAME_AUDIO);return e||(e=new Ee(this),this._addComponent(e)),e.audioEnabled},set:function(e){var t=this._getComponent(Te.a.NAME_AUDIO);t||(t=new Ee(this),this._addComponent(t)),e?t.enableAudio():t.disableAudio()},enumerable:!0,configurable:!0}),Object.defineProperty(W.a.prototype,"headphone",{get:function(){var e=this._getComponent(Te.a.NAME_AUDIO);return e||(e=new Ee(this),this._addComponent(e)),e.headphone},set:function(e){var t=this._getComponent(Te.a.NAME_AUDIO);t||(t=new Ee(this),this._addComponent(t)),e?t.switchAudioModeForHeadphones():t.switchAudioModeForNormalSpeakers()},enumerable:!0,configurable:!0});var Ee=function(){function e(e){this.name=Te.a.NAME_AUDIO,this._audioEnabled=!0,this._headphone=!1,this.scene=e,e.soundTracks=new Array,e.sounds=new Array}return Object.defineProperty(e.prototype,"audioEnabled",{get:function(){return this._audioEnabled},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"headphone",{get:function(){return this._headphone},enumerable:!0,configurable:!0}),e.prototype.register=function(){this.scene._afterRenderStage.registerStep(Te.a.STEP_AFTERRENDER_AUDIO,this,this._afterRender)},e.prototype.rebuild=function(){},e.prototype.serialize=function(e){if(e.sounds=[],this.scene.soundTracks)for(var t=0;t<this.scene.soundTracks.length;t++)for(var i=this.scene.soundTracks[t],r=0;r<i.soundCollection.length;r++)e.sounds.push(i.soundCollection[r].serialize())},e.prototype.addFromContainer=function(e){var t=this;e.sounds&&e.sounds.forEach(function(e){e.play(),e.autoplay=!0,t.scene.mainSoundTrack.AddSound(e)})},e.prototype.removeFromContainer=function(e){var t=this;e.sounds&&e.sounds.forEach(function(e){e.stop(),e.autoplay=!1,t.scene.mainSoundTrack.RemoveSound(e)})},e.prototype.dispose=function(){var e=this.scene;if(e._mainSoundTrack&&e.mainSoundTrack.dispose(),e.soundTracks)for(var t=0;t<e.soundTracks.length;t++)e.soundTracks[t].dispose()},e.prototype.disableAudio=function(){var e,t=this.scene;for(this._audioEnabled=!1,e=0;e<t.mainSoundTrack.soundCollection.length;e++)t.mainSoundTrack.soundCollection[e].pause();if(t.soundTracks)for(e=0;e<t.soundTracks.length;e++)for(var i=0;i<t.soundTracks[e].soundCollection.length;i++)t.soundTracks[e].soundCollection[i].pause()},e.prototype.enableAudio=function(){var e,t=this.scene;for(this._audioEnabled=!0,e=0;e<t.mainSoundTrack.soundCollection.length;e++)t.mainSoundTrack.soundCollection[e].isPaused&&t.mainSoundTrack.soundCollection[e].play();if(t.soundTracks)for(e=0;e<t.soundTracks.length;e++)for(var i=0;i<t.soundTracks[e].soundCollection.length;i++)t.soundTracks[e].soundCollection[i].isPaused&&t.soundTracks[e].soundCollection[i].play()},e.prototype.switchAudioModeForHeadphones=function(){var e=this.scene;if(this._headphone=!0,e.mainSoundTrack.switchPanningModelToHRTF(),e.soundTracks)for(var t=0;t<e.soundTracks.length;t++)e.soundTracks[t].switchPanningModelToHRTF()},e.prototype.switchAudioModeForNormalSpeakers=function(){var e=this.scene;if(this._headphone=!1,e.mainSoundTrack.switchPanningModelToEqualPower(),e.soundTracks)for(var t=0;t<e.soundTracks.length;t++)e.soundTracks[t].switchPanningModelToEqualPower()},e.prototype._afterRender=function(){var e=this.scene;if(this._audioEnabled&&e._mainSoundTrack&&e.soundTracks&&(0!==e._mainSoundTrack.soundCollection.length||1!==e.soundTracks.length)){var t,i=_e.b.audioEngine;if((t=e.activeCameras.length>0?e.activeCameras[0]:e.activeCamera)&&i.audioContext){i.audioContext.listener.setPosition(t.position.x,t.position.y,t.position.z),t.rigCameras&&t.rigCameras.length>0&&(t=t.rigCameras[0]);var r,n=o.j.Invert(t.getViewMatrix()),s=o.x.TransformNormal(new o.x(0,0,-1),n);for(s.normalize(),isNaN(s.x)||isNaN(s.y)||isNaN(s.z)||i.audioContext.listener.setOrientation(s.x,s.y,s.z,0,1,0),r=0;r<e.mainSoundTrack.soundCollection.length;r++){var a=e.mainSoundTrack.soundCollection[r];a.useCustomAttenuation&&a.updateDistanceFromListener()}if(e.soundTracks)for(r=0;r<e.soundTracks.length;r++)for(var c=0;c<e.soundTracks[r].soundCollection.length;c++)(a=e.soundTracks[r].soundCollection[c]).useCustomAttenuation&&a.updateDistanceFromListener()}}},e}();ye._SceneComponentInitialization=function(e){var t=e._getComponent(Te.a.NAME_AUDIO);t||(t=new Ee(e),e._addComponent(t))};var xe=function(){function e(e,t,i){var r=this;if(this.loop=!1,this._coneInnerAngle=360,this._coneOuterAngle=360,this._volume=1,this.isPlaying=!1,this.isPaused=!1,this._sounds=[],this._weights=[],t.length!==i.length)throw new Error("Sounds length does not equal weights length");this.loop=e,this._weights=i;for(var n=0,o=0,s=i;o<s.length;o++){n+=s[o]}for(var a=n>0?1/n:0,c=0;c<this._weights.length;c++)this._weights[c]*=a;this._sounds=t;for(var l=0,u=this._sounds;l<u.length;l++){u[l].onEndedObservable.add(function(){r._onended()})}}return Object.defineProperty(e.prototype,"directionalConeInnerAngle",{get:function(){return this._coneInnerAngle},set:function(e){if(e!==this._coneInnerAngle){if(this._coneOuterAngle<e)return void p.a.Error("directionalConeInnerAngle: outer angle of the cone must be superior or equal to the inner angle.");this._coneInnerAngle=e;for(var t=0,i=this._sounds;t<i.length;t++){i[t].directionalConeInnerAngle=e}}},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"directionalConeOuterAngle",{get:function(){return this._coneOuterAngle},set:function(e){if(e!==this._coneOuterAngle){if(e<this._coneInnerAngle)return void p.a.Error("directionalConeOuterAngle: outer angle of the cone must be superior or equal to the inner angle.");this._coneOuterAngle=e;for(var t=0,i=this._sounds;t<i.length;t++){i[t].directionalConeOuterAngle=e}}},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"volume",{get:function(){return this._volume},set:function(e){if(e!==this._volume)for(var t=0,i=this._sounds;t<i.length;t++){i[t].setVolume(e)}},enumerable:!0,configurable:!0}),e.prototype._onended=function(){void 0!==this._currentIndex&&(this._sounds[this._currentIndex].autoplay=!1),this.loop&&this.isPlaying?this.play():this.isPlaying=!1},e.prototype.pause=function(){this.isPaused=!0,void 0!==this._currentIndex&&this._sounds[this._currentIndex].pause()},e.prototype.stop=function(){this.isPlaying=!1,void 0!==this._currentIndex&&this._sounds[this._currentIndex].stop()},e.prototype.play=function(e){if(!this.isPaused){this.stop();for(var t=Math.random(),i=0,r=0;r<this._weights.length;r++)if(t<=(i+=this._weights[r])){this._currentIndex=r;break}}var n=this._sounds[this._currentIndex];n.isReady()?n.play(0,this.isPaused?void 0:e):n.autoplay=!0,this.isPlaying=!0,this.isPaused=!1},e}(),Ae=i(15),Pe=function(){function e(){this._zoomStopsAnimation=!1,this._idleRotationSpeed=.05,this._idleRotationWaitTime=2e3,this._idleRotationSpinupTime=2e3,this._isPointerDown=!1,this._lastFrameTime=null,this._lastInteractionTime=-1/0,this._cameraRotationSpeed=0,this._lastFrameRadius=0}return Object.defineProperty(e.prototype,"name",{get:function(){return"AutoRotation"},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"zoomStopsAnimation",{get:function(){return this._zoomStopsAnimation},set:function(e){this._zoomStopsAnimation=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"idleRotationSpeed",{get:function(){return this._idleRotationSpeed},set:function(e){this._idleRotationSpeed=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"idleRotationWaitTime",{get:function(){return this._idleRotationWaitTime},set:function(e){this._idleRotationWaitTime=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"idleRotationSpinupTime",{get:function(){return this._idleRotationSpinupTime},set:function(e){this._idleRotationSpinupTime=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rotationInProgress",{get:function(){return Math.abs(this._cameraRotationSpeed)>0},enumerable:!0,configurable:!0}),e.prototype.init=function(){},e.prototype.attach=function(e){var t=this;this._attachedCamera=e;var i=this._attachedCamera.getScene();this._onPrePointerObservableObserver=i.onPrePointerObservable.add(function(e){e.type!==Ae.a.POINTERDOWN?e.type===Ae.a.POINTERUP&&(t._isPointerDown=!1):t._isPointerDown=!0}),this._onAfterCheckInputsObserver=e.onAfterCheckInputsObservable.add(function(){var e=H.a.Now,i=0;null!=t._lastFrameTime&&(i=e-t._lastFrameTime),t._lastFrameTime=e,t._applyUserInteraction();var r=e-t._lastInteractionTime-t._idleRotationWaitTime,n=Math.max(Math.min(r/t._idleRotationSpinupTime,1),0);t._cameraRotationSpeed=t._idleRotationSpeed*n,t._attachedCamera&&(t._attachedCamera.alpha-=t._cameraRotationSpeed*(i/1e3))})},e.prototype.detach=function(){if(this._attachedCamera){var e=this._attachedCamera.getScene();this._onPrePointerObservableObserver&&e.onPrePointerObservable.remove(this._onPrePointerObservableObserver),this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver),this._attachedCamera=null}},e.prototype._userIsZooming=function(){return!!this._attachedCamera&&0!==this._attachedCamera.inertialRadiusOffset},e.prototype._shouldAnimationStopForInteraction=function(){if(!this._attachedCamera)return!1;var e=!1;return this._lastFrameRadius===this._attachedCamera.radius&&0!==this._attachedCamera.inertialRadiusOffset&&(e=!0),this._lastFrameRadius=this._attachedCamera.radius,this._zoomStopsAnimation?e:this._userIsZooming()},e.prototype._applyUserInteraction=function(){this._userIsMoving()&&!this._shouldAnimationStopForInteraction()&&(this._lastInteractionTime=H.a.Now)},e.prototype._userIsMoving=function(){return!!this._attachedCamera&&(0!==this._attachedCamera.inertialAlphaOffset||0!==this._attachedCamera.inertialBetaOffset||0!==this._attachedCamera.inertialRadiusOffset||0!==this._attachedCamera.inertialPanningX||0!==this._attachedCamera.inertialPanningY||this._isPointerDown)},e}(),Re=function(){function e(){this.transitionDuration=450,this.lowerRadiusTransitionRange=2,this.upperRadiusTransitionRange=-2,this._autoTransitionRange=!1,this._radiusIsAnimating=!1,this._radiusBounceTransition=null,this._animatables=new Array}return Object.defineProperty(e.prototype,"name",{get:function(){return"Bouncing"},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"autoTransitionRange",{get:function(){return this._autoTransitionRange},set:function(e){var t=this;if(this._autoTransitionRange!==e){this._autoTransitionRange=e;var i=this._attachedCamera;i&&(e?this._onMeshTargetChangedObserver=i.onMeshTargetChangedObservable.add(function(e){if(e){e.computeWorldMatrix(!0);var i=e.getBoundingInfo().diagonalLength;t.lowerRadiusTransitionRange=.05*i,t.upperRadiusTransitionRange=.05*i}}):this._onMeshTargetChangedObserver&&i.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver))}},enumerable:!0,configurable:!0}),e.prototype.init=function(){},e.prototype.attach=function(e){var t=this;this._attachedCamera=e,this._onAfterCheckInputsObserver=e.onAfterCheckInputsObservable.add(function(){t._attachedCamera&&(t._isRadiusAtLimit(t._attachedCamera.lowerRadiusLimit)&&t._applyBoundRadiusAnimation(t.lowerRadiusTransitionRange),t._isRadiusAtLimit(t._attachedCamera.upperRadiusLimit)&&t._applyBoundRadiusAnimation(t.upperRadiusTransitionRange))})},e.prototype.detach=function(){this._attachedCamera&&(this._onAfterCheckInputsObserver&&this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver),this._onMeshTargetChangedObserver&&this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver),this._attachedCamera=null)},e.prototype._isRadiusAtLimit=function(e){return!!this._attachedCamera&&(this._attachedCamera.radius===e&&!this._radiusIsAnimating)},e.prototype._applyBoundRadiusAnimation=function(t){var i=this;if(this._attachedCamera){this._radiusBounceTransition||(e.EasingFunction.setEasingMode(e.EasingMode),this._radiusBounceTransition=N.CreateAnimation("radius",N.ANIMATIONTYPE_FLOAT,60,e.EasingFunction)),this._cachedWheelPrecision=this._attachedCamera.wheelPrecision,this._attachedCamera.wheelPrecision=1/0,this._attachedCamera.inertialRadiusOffset=0,this.stopAllAnimations(),this._radiusIsAnimating=!0;var r=N.TransitionTo("radius",this._attachedCamera.radius+t,this._attachedCamera,this._attachedCamera.getScene(),60,this._radiusBounceTransition,this.transitionDuration,function(){return i._clearAnimationLocks()});r&&this._animatables.push(r)}},e.prototype._clearAnimationLocks=function(){this._radiusIsAnimating=!1,this._attachedCamera&&(this._attachedCamera.wheelPrecision=this._cachedWheelPrecision)},e.prototype.stopAllAnimations=function(){for(this._attachedCamera&&(this._attachedCamera.animations=[]);this._animatables.length;)this._animatables[0].onAnimationEnd=null,this._animatables[0].stop(),this._animatables.shift()},e.EasingFunction=new ee(.3),e.EasingMode=J.EASINGMODE_EASEOUT,e}(),Se=function(){function e(){this._mode=e.FitFrustumSidesMode,this._radiusScale=1,this._positionScale=.5,this._defaultElevation=.3,this._elevationReturnTime=1500,this._elevationReturnWaitTime=1e3,this._zoomStopsAnimation=!1,this._framingTime=1500,this.autoCorrectCameraLimitsAndSensibility=!0,this._isPointerDown=!1,this._lastInteractionTime=-1/0,this._animatables=new Array,this._betaIsAnimating=!1}return Object.defineProperty(e.prototype,"name",{get:function(){return"Framing"},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"mode",{get:function(){return this._mode},set:function(e){this._mode=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"radiusScale",{get:function(){return this._radiusScale},set:function(e){this._radiusScale=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"positionScale",{get:function(){return this._positionScale},set:function(e){this._positionScale=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"defaultElevation",{get:function(){return this._defaultElevation},set:function(e){this._defaultElevation=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"elevationReturnTime",{get:function(){return this._elevationReturnTime},set:function(e){this._elevationReturnTime=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"elevationReturnWaitTime",{get:function(){return this._elevationReturnWaitTime},set:function(e){this._elevationReturnWaitTime=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"zoomStopsAnimation",{get:function(){return this._zoomStopsAnimation},set:function(e){this._zoomStopsAnimation=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"framingTime",{get:function(){return this._framingTime},set:function(e){this._framingTime=e},enumerable:!0,configurable:!0}),e.prototype.init=function(){},e.prototype.attach=function(t){var i=this;this._attachedCamera=t;var r=this._attachedCamera.getScene();e.EasingFunction.setEasingMode(e.EasingMode),this._onPrePointerObservableObserver=r.onPrePointerObservable.add(function(e){e.type!==Ae.a.POINTERDOWN?e.type===Ae.a.POINTERUP&&(i._isPointerDown=!1):i._isPointerDown=!0}),this._onMeshTargetChangedObserver=t.onMeshTargetChangedObservable.add(function(e){e&&i.zoomOnMesh(e)}),this._onAfterCheckInputsObserver=t.onAfterCheckInputsObservable.add(function(){i._applyUserInteraction(),i._maintainCameraAboveGround()})},e.prototype.detach=function(){if(this._attachedCamera){var e=this._attachedCamera.getScene();this._onPrePointerObservableObserver&&e.onPrePointerObservable.remove(this._onPrePointerObservableObserver),this._onAfterCheckInputsObserver&&this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver),this._onMeshTargetChangedObserver&&this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver),this._attachedCamera=null}},e.prototype.zoomOnMesh=function(e,t,i){void 0===t&&(t=!1),void 0===i&&(i=null),e.computeWorldMatrix(!0);var r=e.getBoundingInfo().boundingBox;this.zoomOnBoundingInfo(r.minimumWorld,r.maximumWorld,t,i)},e.prototype.zoomOnMeshHierarchy=function(e,t,i){void 0===t&&(t=!1),void 0===i&&(i=null),e.computeWorldMatrix(!0);var r=e.getHierarchyBoundingVectors(!0);this.zoomOnBoundingInfo(r.min,r.max,t,i)},e.prototype.zoomOnMeshesHierarchy=function(e,t,i){void 0===t&&(t=!1),void 0===i&&(i=null);for(var r=new o.x(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),n=new o.x(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),s=0;s<e.length;s++){var a=e[s].getHierarchyBoundingVectors(!0);ve.h.CheckExtends(a.min,r,n),ve.h.CheckExtends(a.max,r,n)}this.zoomOnBoundingInfo(r,n,t,i)},e.prototype.zoomOnBoundingInfo=function(t,i,r,n){var s,a=this;if(void 0===r&&(r=!1),void 0===n&&(n=null),this._attachedCamera){var c=t.y,l=c+(i.y-c)*this._positionScale,u=i.subtract(t).scale(.5);if(r)s=new o.x(0,l,0);else{var h=t.add(u);s=new o.x(h.x,l,h.z)}this._vectorTransition||(this._vectorTransition=N.CreateAnimation("target",N.ANIMATIONTYPE_VECTOR3,60,e.EasingFunction)),this._betaIsAnimating=!0;var d=N.TransitionTo("target",s,this._attachedCamera,this._attachedCamera.getScene(),60,this._vectorTransition,this._framingTime);d&&this._animatables.push(d);var f=0;if(this._mode===e.FitFrustumSidesMode){var p=this._calculateLowerRadiusFromModelBoundingSphere(t,i);this.autoCorrectCameraLimitsAndSensibility&&(this._attachedCamera.lowerRadiusLimit=u.length()+this._attachedCamera.minZ),f=p}else this._mode===e.IgnoreBoundsSizeMode&&(f=this._calculateLowerRadiusFromModelBoundingSphere(t,i),this.autoCorrectCameraLimitsAndSensibility&&null===this._attachedCamera.lowerRadiusLimit&&(this._attachedCamera.lowerRadiusLimit=this._attachedCamera.minZ));if(this.autoCorrectCameraLimitsAndSensibility){var _=i.subtract(t).length();this._attachedCamera.panningSensibility=5e3/_,this._attachedCamera.wheelPrecision=100/f}this._radiusTransition||(this._radiusTransition=N.CreateAnimation("radius",N.ANIMATIONTYPE_FLOAT,60,e.EasingFunction)),(d=N.TransitionTo("radius",f,this._attachedCamera,this._attachedCamera.getScene(),60,this._radiusTransition,this._framingTime,function(){a.stopAllAnimations(),n&&n(),a._attachedCamera&&a._attachedCamera.useInputToRestoreState&&a._attachedCamera.storeState()}))&&this._animatables.push(d)}},e.prototype._calculateLowerRadiusFromModelBoundingSphere=function(t,i){var r=i.subtract(t).length(),n=this._getFrustumSlope(),o=.5*r*this._radiusScale,s=o*Math.sqrt(1+1/(n.x*n.x)),a=o*Math.sqrt(1+1/(n.y*n.y)),c=Math.max(s,a),l=this._attachedCamera;return l?(l.lowerRadiusLimit&&this._mode===e.IgnoreBoundsSizeMode&&(c=c<l.lowerRadiusLimit?l.lowerRadiusLimit:c),l.upperRadiusLimit&&(c=c>l.upperRadiusLimit?l.upperRadiusLimit:c),c):0},e.prototype._maintainCameraAboveGround=function(){var t=this;if(!(this._elevationReturnTime<0)){var i=H.a.Now-this._lastInteractionTime,r=.5*Math.PI-this._defaultElevation,n=.5*Math.PI;if(this._attachedCamera&&!this._betaIsAnimating&&this._attachedCamera.beta>n&&i>=this._elevationReturnWaitTime){this._betaIsAnimating=!0,this.stopAllAnimations(),this._betaTransition||(this._betaTransition=N.CreateAnimation("beta",N.ANIMATIONTYPE_FLOAT,60,e.EasingFunction));var o=N.TransitionTo("beta",r,this._attachedCamera,this._attachedCamera.getScene(),60,this._betaTransition,this._elevationReturnTime,function(){t._clearAnimationLocks(),t.stopAllAnimations()});o&&this._animatables.push(o)}}},e.prototype._getFrustumSlope=function(){var e=this._attachedCamera;if(!e)return o.w.Zero();var t=e.getScene().getEngine().getAspectRatio(e),i=Math.tan(e.fov/2),r=i*t;return new o.w(r,i)},e.prototype._clearAnimationLocks=function(){this._betaIsAnimating=!1},e.prototype._applyUserInteraction=function(){this.isUserIsMoving&&(this._lastInteractionTime=H.a.Now,this.stopAllAnimations(),this._clearAnimationLocks())},e.prototype.stopAllAnimations=function(){for(this._attachedCamera&&(this._attachedCamera.animations=[]);this._animatables.length;)this._animatables[0]&&(this._animatables[0].onAnimationEnd=null,this._animatables[0].stop()),this._animatables.shift()},Object.defineProperty(e.prototype,"isUserIsMoving",{get:function(){return!!this._attachedCamera&&(0!==this._attachedCamera.inertialAlphaOffset||0!==this._attachedCamera.inertialBetaOffset||0!==this._attachedCamera.inertialRadiusOffset||0!==this._attachedCamera.inertialPanningX||0!==this._attachedCamera.inertialPanningY||this._isPointerDown)},enumerable:!0,configurable:!0}),e.EasingFunction=new ne,e.EasingMode=J.EASINGMODE_EASEINOUT,e.IgnoreBoundsSizeMode=0,e.FitFrustumSidesMode=1,e}(),Ce=function(){return function(e,t,i,r){void 0===t&&(t=new o.x),void 0===i&&(i=0),void 0===r&&(r=!1),this.direction=e,this.rotatedDirection=t,this.diff=i,this.ignore=r}}(),Me=function(){function e(e){this.ui=e,this.name="AttachToBoxBehavior",this.distanceAwayFromFace=.15,this.distanceAwayFromBottomOfFace=.15,this._faceVectors=[new Ce(o.x.Up()),new Ce(o.x.Down()),new Ce(o.x.Left()),new Ce(o.x.Right()),new Ce(o.x.Forward()),new Ce(o.x.Forward().scaleInPlace(-1))],this._tmpMatrix=new o.j,this._tmpVector=new o.x,this._zeroVector=o.x.Zero(),this._lookAtTmpMatrix=new o.j}return e.prototype.init=function(){},e.prototype._closestFace=function(e){var t=this;return this._faceVectors.forEach(function(i){t._target.rotationQuaternion||(t._target.rotationQuaternion=o.q.RotationYawPitchRoll(t._target.rotation.y,t._target.rotation.x,t._target.rotation.z)),t._target.rotationQuaternion.toRotationMatrix(t._tmpMatrix),o.x.TransformCoordinatesToRef(i.direction,t._tmpMatrix,i.rotatedDirection),i.diff=o.x.GetAngleBetweenVectors(i.rotatedDirection,e,o.x.Cross(i.rotatedDirection,e))}),this._faceVectors.reduce(function(e,t){return e.ignore?t:t.ignore?e:e.diff<t.diff?e:t},this._faceVectors[0])},e.prototype._lookAtToRef=function(e,t,i){void 0===t&&(t=new o.x(0,1,0)),o.j.LookAtLHToRef(this._zeroVector,e,t,this._lookAtTmpMatrix),this._lookAtTmpMatrix.invert(),o.q.FromRotationMatrixToRef(this._lookAtTmpMatrix,i)},e.prototype.attach=function(e){var t=this;this._target=e,this._scene=this._target.getScene(),this._onRenderObserver=this._scene.onBeforeRenderObservable.add(function(){if(t._scene.activeCamera){var i=t._scene.activeCamera.position;t._scene.activeCamera.devicePosition&&(i=t._scene.activeCamera.devicePosition);var r=t._closestFace(i.subtract(e.position));t._scene.activeCamera.leftCamera?t._scene.activeCamera.leftCamera.computeWorldMatrix().getRotationMatrixToRef(t._tmpMatrix):t._scene.activeCamera.computeWorldMatrix().getRotationMatrixToRef(t._tmpMatrix),o.x.TransformCoordinatesToRef(o.x.Up(),t._tmpMatrix,t._tmpVector),t._faceVectors.forEach(function(e){r.direction.x&&e.direction.x&&(e.ignore=!0),r.direction.y&&e.direction.y&&(e.ignore=!0),r.direction.z&&e.direction.z&&(e.ignore=!0)});var n=t._closestFace(t._tmpVector);t._faceVectors.forEach(function(e){e.ignore=!1}),t.ui.position.copyFrom(e.position),r.direction.x&&(r.rotatedDirection.scaleToRef(e.scaling.x/2+t.distanceAwayFromFace,t._tmpVector),t.ui.position.addInPlace(t._tmpVector)),r.direction.y&&(r.rotatedDirection.scaleToRef(e.scaling.y/2+t.distanceAwayFromFace,t._tmpVector),t.ui.position.addInPlace(t._tmpVector)),r.direction.z&&(r.rotatedDirection.scaleToRef(e.scaling.z/2+t.distanceAwayFromFace,t._tmpVector),t.ui.position.addInPlace(t._tmpVector)),t.ui.rotationQuaternion||(t.ui.rotationQuaternion=o.q.RotationYawPitchRoll(t.ui.rotation.y,t.ui.rotation.x,t.ui.rotation.z)),r.rotatedDirection.scaleToRef(-1,t._tmpVector),t._lookAtToRef(t._tmpVector,n.rotatedDirection,t.ui.rotationQuaternion),n.direction.x&&t.ui.up.scaleToRef(t.distanceAwayFromBottomOfFace-e.scaling.x/2,t._tmpVector),n.direction.y&&t.ui.up.scaleToRef(t.distanceAwayFromBottomOfFace-e.scaling.y/2,t._tmpVector),n.direction.z&&t.ui.up.scaleToRef(t.distanceAwayFromBottomOfFace-e.scaling.z/2,t._tmpVector),t.ui.position.addInPlace(t._tmpVector)}})},e.prototype.detach=function(){this._scene.onBeforeRenderObservable.remove(this._onRenderObserver)},e}(),Oe=function(){function e(){var e=this;this.delay=0,this.fadeInTime=300,this._millisecondsPerFrame=1e3/60,this._hovered=!1,this._hoverValue=0,this._ownerNode=null,this._update=function(){if(e._ownerNode){if(e._hoverValue+=e._hovered?e._millisecondsPerFrame:-e._millisecondsPerFrame,e._setAllVisibility(e._ownerNode,(e._hoverValue-e.delay)/e.fadeInTime),e._ownerNode.visibility>1)return e._setAllVisibility(e._ownerNode,1),void(e._hoverValue=e.fadeInTime+e.delay);if(e._ownerNode.visibility<0&&(e._setAllVisibility(e._ownerNode,0),e._hoverValue<0))return void(e._hoverValue=0);setTimeout(e._update,e._millisecondsPerFrame)}}}return Object.defineProperty(e.prototype,"name",{get:function(){return"FadeInOut"},enumerable:!0,configurable:!0}),e.prototype.init=function(){},e.prototype.attach=function(e){this._ownerNode=e,this._setAllVisibility(this._ownerNode,0)},e.prototype.detach=function(){this._ownerNode=null},e.prototype.fadeIn=function(e){this._hovered=e,this._update()},e.prototype._setAllVisibility=function(e,t){var i=this;e.visibility=t,e.getChildMeshes().forEach(function(e){i._setAllVisibility(e,t)})},e}(),Ie=i(50),De=function(){function e(){this._startDistance=0,this._initialScale=new o.x(0,0,0),this._targetScale=new o.x(0,0,0),this._sceneRenderObserver=null,this._dragBehaviorA=new Ie.a({}),this._dragBehaviorA.moveAttached=!1,this._dragBehaviorB=new Ie.a({}),this._dragBehaviorB.moveAttached=!1}return Object.defineProperty(e.prototype,"name",{get:function(){return"MultiPointerScale"},enumerable:!0,configurable:!0}),e.prototype.init=function(){},e.prototype._getCurrentDistance=function(){return this._dragBehaviorA.lastDragPosition.subtract(this._dragBehaviorB.lastDragPosition).length()},e.prototype.attach=function(e){var t=this;this._ownerNode=e,this._dragBehaviorA.onDragStartObservable.add(function(i){t._dragBehaviorA.dragging&&t._dragBehaviorB.dragging&&(t._dragBehaviorA.currentDraggingPointerID==t._dragBehaviorB.currentDraggingPointerID?t._dragBehaviorA.releaseDrag():(t._initialScale.copyFrom(e.scaling),t._startDistance=t._getCurrentDistance()))}),this._dragBehaviorB.onDragStartObservable.add(function(i){t._dragBehaviorA.dragging&&t._dragBehaviorB.dragging&&(t._dragBehaviorA.currentDraggingPointerID==t._dragBehaviorB.currentDraggingPointerID?t._dragBehaviorB.releaseDrag():(t._initialScale.copyFrom(e.scaling),t._startDistance=t._getCurrentDistance()))}),[this._dragBehaviorA,this._dragBehaviorB].forEach(function(e){e.onDragObservable.add(function(){if(t._dragBehaviorA.dragging&&t._dragBehaviorB.dragging){var e=t._getCurrentDistance()/t._startDistance;t._initialScale.scaleToRef(e,t._targetScale)}})}),e.addBehavior(this._dragBehaviorA),e.addBehavior(this._dragBehaviorB),this._sceneRenderObserver=e.getScene().onBeforeRenderObservable.add(function(){if(t._dragBehaviorA.dragging&&t._dragBehaviorB.dragging){var i=t._targetScale.subtract(e.scaling).scaleInPlace(.1);i.length()>.01&&e.scaling.addInPlace(i)}})},e.prototype.detach=function(){var e=this;this._ownerNode.getScene().onBeforeRenderObservable.remove(this._sceneRenderObserver),[this._dragBehaviorA,this._dragBehaviorB].forEach(function(t){t.onDragStartObservable.clear(),t.onDragObservable.clear(),e._ownerNode.removeBehavior(t)})},e}(),we=i(23),Le=i(19),Fe=i(42),Ne=function(){function e(){this._sceneRenderObserver=null,this._targetPosition=new o.x(0,0,0),this._moving=!1,this._startingOrientation=new o.q,this.zDragFactor=3,this.rotateDraggedObject=!0,this.dragging=!1,this.dragDeltaRatio=.2,this.currentDraggingPointerID=-1,this.detachCameraControls=!0,this.onDragStartObservable=new n.c,this.onDragEndObservable=new n.c}return Object.defineProperty(e.prototype,"name",{get:function(){return"SixDofDrag"},enumerable:!0,configurable:!0}),e.prototype.init=function(){},e.prototype.attach=function(t){var i=this;this._ownerNode=t,this._scene=this._ownerNode.getScene(),e._virtualScene||(e._virtualScene=new W.a(this._scene.getEngine()),e._virtualScene.detachControl(),this._scene.getEngine().scenes.pop());var r=null,n=new o.x(0,0,0);this._virtualOriginMesh=new we.a("",e._virtualScene),this._virtualOriginMesh.rotationQuaternion=new o.q,this._virtualDragMesh=new we.a("",e._virtualScene),this._virtualDragMesh.rotationQuaternion=new o.q;var s=null;this._pointerObserver=this._scene.onPointerObservable.add(function(e,t){if(e.type==Ae.a.POINTERDOWN){if(!i.dragging&&e.pickInfo&&e.pickInfo.hit&&e.pickInfo.pickedMesh&&e.pickInfo.ray&&(h=e.pickInfo.pickedMesh,i._ownerNode==h||h.isDescendantOf(i._ownerNode))){i._scene.activeCamera&&i._scene.activeCamera.cameraRigMode==Le.a.RIG_MODE_NONE&&e.pickInfo.ray.origin.copyFrom(i._scene.activeCamera.globalPosition),r=i._ownerNode,Fe.a._RemoveAndStorePivotPoint(r),n.copyFrom(e.pickInfo.ray.origin),i._virtualOriginMesh.position.copyFrom(e.pickInfo.ray.origin),i._virtualOriginMesh.lookAt(e.pickInfo.ray.origin.add(e.pickInfo.ray.direction)),i._virtualOriginMesh.removeChild(i._virtualDragMesh),r.computeWorldMatrix(),i._virtualDragMesh.position.copyFrom(r.absolutePosition),r.rotationQuaternion||(r.rotationQuaternion=o.q.RotationYawPitchRoll(r.rotation.y,r.rotation.x,r.rotation.z));var a=r.parent;r.setParent(null),i._virtualDragMesh.rotationQuaternion.copyFrom(r.rotationQuaternion),r.setParent(a),i._virtualOriginMesh.addChild(i._virtualDragMesh),i._targetPosition.copyFrom(i._virtualDragMesh.absolutePosition),i.dragging=!0,i.currentDraggingPointerID=e.event.pointerId,i.detachCameraControls&&i._scene.activeCamera&&!i._scene.activeCamera.leftCamera&&(i._scene.activeCamera.inputs.attachedElement?(s=i._scene.activeCamera.inputs.attachedElement,i._scene.activeCamera.detachControl(i._scene.activeCamera.inputs.attachedElement)):s=null),Fe.a._RestorePivotPoint(r),i.onDragStartObservable.notifyObservers({})}}else if(e.type==Ae.a.POINTERUP)i.currentDraggingPointerID==e.event.pointerId&&(i.dragging=!1,i._moving=!1,i.currentDraggingPointerID=-1,r=null,i._virtualOriginMesh.removeChild(i._virtualDragMesh),i.detachCameraControls&&s&&i._scene.activeCamera&&!i._scene.activeCamera.leftCamera&&i._scene.activeCamera.attachControl(s,!0),i.onDragEndObservable.notifyObservers({}));else if(e.type==Ae.a.POINTERMOVE&&i.currentDraggingPointerID==e.event.pointerId&&i.dragging&&e.pickInfo&&e.pickInfo.ray&&r){var c=i.zDragFactor;i._scene.activeCamera&&i._scene.activeCamera.cameraRigMode==Le.a.RIG_MODE_NONE&&(e.pickInfo.ray.origin.copyFrom(i._scene.activeCamera.globalPosition),c=0);var l=e.pickInfo.ray.origin.subtract(n);n.copyFrom(e.pickInfo.ray.origin);var u=-o.x.Dot(l,e.pickInfo.ray.direction);i._virtualOriginMesh.addChild(i._virtualDragMesh),i._virtualDragMesh.position.z-=i._virtualDragMesh.position.z<1?u*i.zDragFactor:u*c*i._virtualDragMesh.position.z,i._virtualDragMesh.position.z<0&&(i._virtualDragMesh.position.z=0),i._virtualOriginMesh.position.copyFrom(e.pickInfo.ray.origin),i._virtualOriginMesh.lookAt(e.pickInfo.ray.origin.add(e.pickInfo.ray.direction)),i._virtualOriginMesh.removeChild(i._virtualDragMesh),i._targetPosition.copyFrom(i._virtualDragMesh.absolutePosition),r.parent&&o.x.TransformCoordinatesToRef(i._targetPosition,o.j.Invert(r.parent.getWorldMatrix()),i._targetPosition),i._moving||i._startingOrientation.copyFrom(i._virtualDragMesh.rotationQuaternion),i._moving=!0}var h});var a=new o.q;this._sceneRenderObserver=t.getScene().onBeforeRenderObservable.add(function(){if(i.dragging&&i._moving&&r){if(Fe.a._RemoveAndStorePivotPoint(r),r.position.addInPlace(i._targetPosition.subtract(r.position).scale(i.dragDeltaRatio)),i.rotateDraggedObject){a.copyFrom(i._startingOrientation),a.x=-a.x,a.y=-a.y,a.z=-a.z,i._virtualDragMesh.rotationQuaternion.multiplyToRef(a,a),o.q.RotationYawPitchRollToRef(a.toEulerAngles("xyz").y,0,0,a),a.multiplyToRef(i._startingOrientation,a);var e=r.parent;(!e||e.scaling&&!e.scaling.isNonUniformWithinEpsilon(.001))&&(r.setParent(null),o.q.SlerpToRef(r.rotationQuaternion,a,i.dragDeltaRatio,r.rotationQuaternion),r.setParent(e))}Fe.a._RestorePivotPoint(r)}})},e.prototype.detach=function(){this._scene&&this._scene.onPointerObservable.remove(this._pointerObserver),this._ownerNode&&this._ownerNode.getScene().onBeforeRenderObservable.remove(this._sceneRenderObserver),this._virtualOriginMesh&&this._virtualOriginMesh.dispose(),this._virtualDragMesh&&this._virtualDragMesh.dispose(),this.onDragEndObservable.clear(),this.onDragStartObservable.clear()},e}(),Be=function(){function e(e,t,i){if(this.targetPosition=o.x.Zero(),this.poleTargetPosition=o.x.Zero(),this.poleTargetLocalOffset=o.x.Zero(),this.poleAngle=0,this.slerpAmount=1,this._bone1Quat=o.q.Identity(),this._bone1Mat=o.j.Identity(),this._bone2Ang=Math.PI,this._maxAngle=Math.PI,this._rightHandedSystem=!1,this._bendAxis=o.x.Right(),this._slerping=!1,this._adjustRoll=0,this._bone2=t,this._bone1=t.getParent(),this._bone1){this.mesh=e;var r=t.getPosition();if(t.getAbsoluteTransform().determinant()>0&&(this._rightHandedSystem=!0,this._bendAxis.x=0,this._bendAxis.y=0,this._bendAxis.z=-1,r.x>r.y&&r.x>r.z&&(this._adjustRoll=.5*Math.PI,this._bendAxis.z=1)),this._bone1.length){var n=this._bone1.getScale(),s=this._bone2.getScale();this._bone1Length=this._bone1.length*n.y*this.mesh.scaling.y,this._bone2Length=this._bone2.length*s.y*this.mesh.scaling.y}else if(this._bone1.children[0]){e.computeWorldMatrix(!0);var a=this._bone2.children[0].getAbsolutePosition(e),c=this._bone2.getAbsolutePosition(e),l=this._bone1.getAbsolutePosition(e);this._bone1Length=o.x.Distance(a,c),this._bone2Length=o.x.Distance(c,l)}this._bone1.getRotationMatrixToRef(o.s.WORLD,e,this._bone1Mat),this.maxAngle=Math.PI,i&&(i.targetMesh&&(this.targetMesh=i.targetMesh,this.targetMesh.computeWorldMatrix(!0)),i.poleTargetMesh?(this.poleTargetMesh=i.poleTargetMesh,this.poleTargetMesh.computeWorldMatrix(!0)):i.poleTargetBone?this.poleTargetBone=i.poleTargetBone:this._bone1.getParent()&&(this.poleTargetBone=this._bone1.getParent()),i.poleTargetLocalOffset&&this.poleTargetLocalOffset.copyFrom(i.poleTargetLocalOffset),i.poleAngle&&(this.poleAngle=i.poleAngle),i.bendAxis&&this._bendAxis.copyFrom(i.bendAxis),i.maxAngle&&(this.maxAngle=i.maxAngle),i.slerpAmount&&(this.slerpAmount=i.slerpAmount))}}return Object.defineProperty(e.prototype,"maxAngle",{get:function(){return this._maxAngle},set:function(e){this._setMaxAngle(e)},enumerable:!0,configurable:!0}),e.prototype._setMaxAngle=function(e){e<0&&(e=0),(e>Math.PI||null==e)&&(e=Math.PI),this._maxAngle=e;var t=this._bone1Length,i=this._bone2Length;this._maxReach=Math.sqrt(t*t+i*i-2*t*i*Math.cos(e))},e.prototype.update=function(){var t=this._bone1;if(t){var i=this.targetPosition,r=this.poleTargetPosition,n=e._tmpMats[0],s=e._tmpMats[1];this.targetMesh&&i.copyFrom(this.targetMesh.getAbsolutePosition()),this.poleTargetBone?this.poleTargetBone.getAbsolutePositionFromLocalToRef(this.poleTargetLocalOffset,this.mesh,r):this.poleTargetMesh&&o.x.TransformCoordinatesToRef(this.poleTargetLocalOffset,this.poleTargetMesh.getWorldMatrix(),r);var a=e._tmpVecs[0],c=e._tmpVecs[1],l=e._tmpVecs[2],u=e._tmpVecs[3],h=e._tmpVecs[4],d=e._tmpQuat;t.getAbsolutePositionToRef(this.mesh,a),r.subtractToRef(a,h),0==h.x&&0==h.y&&0==h.z?h.y=1:h.normalize(),i.subtractToRef(a,u),u.normalize(),o.x.CrossToRef(u,h,c),c.normalize(),o.x.CrossToRef(u,c,l),l.normalize(),o.j.FromXYZAxesToRef(l,u,c,n);var f=this._bone1Length,p=this._bone2Length,_=o.x.Distance(a,i);this._maxReach>0&&(_=Math.min(this._maxReach,_));var g=(p*p+_*_-f*f)/(2*p*_),m=(_*_+f*f-p*p)/(2*_*f);g>1&&(g=1),m>1&&(m=1),g<-1&&(g=-1),m<-1&&(m=-1);var v=Math.acos(g),y=Math.acos(m),b=-v-y;if(this._rightHandedSystem)o.j.RotationYawPitchRollToRef(0,0,this._adjustRoll,s),s.multiplyToRef(n,n),o.j.RotationAxisToRef(this._bendAxis,y,s),s.multiplyToRef(n,n);else{var T=e._tmpVecs[5];T.copyFrom(this._bendAxis),T.x*=-1,o.j.RotationAxisToRef(T,-y,s),s.multiplyToRef(n,n)}this.poleAngle&&(o.j.RotationAxisToRef(u,this.poleAngle,s),n.multiplyToRef(s,n)),this._bone1&&(this.slerpAmount<1?(this._slerping||o.q.FromRotationMatrixToRef(this._bone1Mat,this._bone1Quat),o.q.FromRotationMatrixToRef(n,d),o.q.SlerpToRef(this._bone1Quat,d,this.slerpAmount,this._bone1Quat),b=this._bone2Ang*(1-this.slerpAmount)+b*this.slerpAmount,this._bone1.setRotationQuaternion(this._bone1Quat,o.s.WORLD,this.mesh),this._slerping=!0):(this._bone1.setRotationMatrix(n,o.s.WORLD,this.mesh),this._bone1Mat.copyFrom(n),this._slerping=!1)),this._bone2.setAxisAngle(this._bendAxis,b,o.s.LOCAL),this._bone2Ang=b}},e._tmpVecs=[o.x.Zero(),o.x.Zero(),o.x.Zero(),o.x.Zero(),o.x.Zero(),o.x.Zero()],e._tmpQuat=o.q.Identity(),e._tmpMats=[o.j.Identity(),o.j.Identity()],e}(),Ue=function(){function e(e,t,i,r){if(this.upAxis=o.x.Up(),this.upAxisSpace=o.s.LOCAL,this.adjustYaw=0,this.adjustPitch=0,this.adjustRoll=0,this.slerpAmount=1,this._boneQuat=o.q.Identity(),this._slerping=!1,this._firstFrameSkipped=!1,this._fowardAxis=o.x.Forward(),this.mesh=e,this.bone=t,this.target=i,r&&(r.adjustYaw&&(this.adjustYaw=r.adjustYaw),r.adjustPitch&&(this.adjustPitch=r.adjustPitch),r.adjustRoll&&(this.adjustRoll=r.adjustRoll),null!=r.maxYaw?this.maxYaw=r.maxYaw:this.maxYaw=Math.PI,null!=r.minYaw?this.minYaw=r.minYaw:this.minYaw=-Math.PI,null!=r.maxPitch?this.maxPitch=r.maxPitch:this.maxPitch=Math.PI,null!=r.minPitch?this.minPitch=r.minPitch:this.minPitch=-Math.PI,null!=r.slerpAmount&&(this.slerpAmount=r.slerpAmount),null!=r.upAxis&&(this.upAxis=r.upAxis),null!=r.upAxisSpace&&(this.upAxisSpace=r.upAxisSpace),null!=r.yawAxis||null!=r.pitchAxis)){var n=o.c.Y,s=o.c.X;null!=r.yawAxis&&(n=r.yawAxis.clone()).normalize(),null!=r.pitchAxis&&(s=r.pitchAxis.clone()).normalize();var a=o.x.Cross(s,n);this._transformYawPitch=o.j.Identity(),o.j.FromXYZAxesToRef(s,n,a,this._transformYawPitch),this._transformYawPitchInv=this._transformYawPitch.clone(),this._transformYawPitch.invert()}t.getParent()||this.upAxisSpace!=o.s.BONE||(this.upAxisSpace=o.s.LOCAL)}return Object.defineProperty(e.prototype,"minYaw",{get:function(){return this._minYaw},set:function(e){this._minYaw=e,this._minYawSin=Math.sin(e),this._minYawCos=Math.cos(e),null!=this._maxYaw&&(this._midYawConstraint=.5*this._getAngleDiff(this._minYaw,this._maxYaw)+this._minYaw,this._yawRange=this._maxYaw-this._minYaw)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"maxYaw",{get:function(){return this._maxYaw},set:function(e){this._maxYaw=e,this._maxYawSin=Math.sin(e),this._maxYawCos=Math.cos(e),null!=this._minYaw&&(this._midYawConstraint=.5*this._getAngleDiff(this._minYaw,this._maxYaw)+this._minYaw,this._yawRange=this._maxYaw-this._minYaw)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"minPitch",{get:function(){return this._minPitch},set:function(e){this._minPitch=e,this._minPitchTan=Math.tan(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"maxPitch",{get:function(){return this._maxPitch},set:function(e){this._maxPitch=e,this._maxPitchTan=Math.tan(e)},enumerable:!0,configurable:!0}),e.prototype.update=function(){if(this.slerpAmount<1&&!this._firstFrameSkipped)this._firstFrameSkipped=!0;else{var t=this.bone,i=e._tmpVecs[0];t.getAbsolutePositionToRef(this.mesh,i);var r=this.target,n=e._tmpMats[0],s=e._tmpMats[1],a=this.mesh,c=t.getParent(),l=e._tmpVecs[1];l.copyFrom(this.upAxis),this.upAxisSpace==o.s.BONE&&c?(this._transformYawPitch&&o.x.TransformCoordinatesToRef(l,this._transformYawPitchInv,l),c.getDirectionToRef(l,this.mesh,l)):this.upAxisSpace==o.s.LOCAL&&(a.getDirectionToRef(l,l),1==a.scaling.x&&1==a.scaling.y&&1==a.scaling.z||l.normalize());var u=!1,h=!1;if(this._maxYaw==Math.PI&&this._minYaw==-Math.PI||(u=!0),this._maxPitch==Math.PI&&this._minPitch==-Math.PI||(h=!0),u||h){var d=e._tmpMats[2],f=e._tmpMats[3];if(this.upAxisSpace==o.s.BONE&&1==l.y&&c)c.getRotationMatrixToRef(o.s.WORLD,this.mesh,d);else if(this.upAxisSpace!=o.s.LOCAL||1!=l.y||c){(_=e._tmpVecs[2]).copyFrom(this._fowardAxis),this._transformYawPitch&&o.x.TransformCoordinatesToRef(_,this._transformYawPitchInv,_),c?c.getDirectionToRef(_,this.mesh,_):a.getDirectionToRef(_,_);var p=o.x.Cross(l,_);p.normalize();var _=o.x.Cross(p,l);o.j.FromXYZAxesToRef(p,l,_,d)}else d.copyFrom(a.getWorldMatrix());d.invertToRef(f);var g=null;if(h){var m=e._tmpVecs[3];r.subtractToRef(i,m),o.x.TransformCoordinatesToRef(m,f,m),g=Math.sqrt(m.x*m.x+m.z*m.z);var v=Math.atan2(m.y,g),y=v;v>this._maxPitch?(m.y=this._maxPitchTan*g,y=this._maxPitch):v<this._minPitch&&(m.y=this._minPitchTan*g,y=this._minPitch),v!=y&&(o.x.TransformCoordinatesToRef(m,d,m),m.addInPlace(i),r=m)}if(u){m=e._tmpVecs[4];r.subtractToRef(i,m),o.x.TransformCoordinatesToRef(m,f,m);var b=Math.atan2(m.x,m.z),T=b;if((b>this._maxYaw||b<this._minYaw)&&(null==g&&(g=Math.sqrt(m.x*m.x+m.z*m.z)),this._yawRange>Math.PI?this._isAngleBetween(b,this._maxYaw,this._midYawConstraint)?(m.z=this._maxYawCos*g,m.x=this._maxYawSin*g,T=this._maxYaw):this._isAngleBetween(b,this._midYawConstraint,this._minYaw)&&(m.z=this._minYawCos*g,m.x=this._minYawSin*g,T=this._minYaw):b>this._maxYaw?(m.z=this._maxYawCos*g,m.x=this._maxYawSin*g,T=this._maxYaw):b<this._minYaw&&(m.z=this._minYawCos*g,m.x=this._minYawSin*g,T=this._minYaw)),this._slerping&&this._yawRange>Math.PI){var E=e._tmpVecs[8];E.copyFrom(o.c.Z),this._transformYawPitch&&o.x.TransformCoordinatesToRef(E,this._transformYawPitchInv,E);var x=e._tmpMats[4];this._boneQuat.toRotationMatrix(x),this.mesh.getWorldMatrix().multiplyToRef(x,x),o.x.TransformCoordinatesToRef(E,x,E),o.x.TransformCoordinatesToRef(E,f,E);var A=Math.atan2(E.x,E.z);if(this._getAngleBetween(A,b)>this._getAngleBetween(A,this._midYawConstraint)){null==g&&(g=Math.sqrt(m.x*m.x+m.z*m.z));var P=this._getAngleBetween(A,this._maxYaw);this._getAngleBetween(A,this._minYaw)<P?(T=A+.75*Math.PI,m.z=Math.cos(T)*g,m.x=Math.sin(T)*g):(T=A-.75*Math.PI,m.z=Math.cos(T)*g,m.x=Math.sin(T)*g)}}b!=T&&(o.x.TransformCoordinatesToRef(m,d,m),m.addInPlace(i),r=m)}}var R=e._tmpVecs[5],S=e._tmpVecs[6],C=e._tmpVecs[7],M=e._tmpQuat;r.subtractToRef(i,R),R.normalize(),o.x.CrossToRef(l,R,S),S.normalize(),o.x.CrossToRef(R,S,C),C.normalize(),o.j.FromXYZAxesToRef(S,C,R,n),0===S.x&&0===S.y&&0===S.z||0===C.x&&0===C.y&&0===C.z||0===R.x&&0===R.y&&0===R.z||((this.adjustYaw||this.adjustPitch||this.adjustRoll)&&(o.j.RotationYawPitchRollToRef(this.adjustYaw,this.adjustPitch,this.adjustRoll,s),s.multiplyToRef(n,n)),this.slerpAmount<1?(this._slerping||this.bone.getRotationQuaternionToRef(o.s.WORLD,this.mesh,this._boneQuat),this._transformYawPitch&&this._transformYawPitch.multiplyToRef(n,n),o.q.FromRotationMatrixToRef(n,M),o.q.SlerpToRef(this._boneQuat,M,this.slerpAmount,this._boneQuat),this.bone.setRotationQuaternion(this._boneQuat,o.s.WORLD,this.mesh),this._slerping=!0):(this._transformYawPitch&&this._transformYawPitch.multiplyToRef(n,n),this.bone.setRotationMatrix(n,o.s.WORLD,this.mesh),this._slerping=!1))}},e.prototype._getAngleDiff=function(e,t){var i=t-e;return(i%=2*Math.PI)>Math.PI?i-=2*Math.PI:i<-Math.PI&&(i+=2*Math.PI),i},e.prototype._getAngleBetween=function(e,t){var i=0;return(i=(e=(e%=2*Math.PI)<0?e+2*Math.PI:e)<(t=(t%=2*Math.PI)<0?t+2*Math.PI:t)?t-e:e-t)>Math.PI&&(i=2*Math.PI-i),i},e.prototype._isAngleBetween=function(e,t,i){if(e=(e%=2*Math.PI)<0?e+2*Math.PI:e,(t=(t%=2*Math.PI)<0?t+2*Math.PI:t)<(i=(i%=2*Math.PI)<0?i+2*Math.PI:i)){if(e>t&&e<i)return!0}else if(e>i&&e<t)return!0;return!1},e._tmpVecs=X.a.BuildArray(10,o.x.Zero),e._tmpQuat=o.q.Identity(),e._tmpMats=X.a.BuildArray(5,o.j.Identity),e}(),Ve=i(6),Ge=function(e){function t(t,i,r,n,o,s,a,c,l){void 0===s&&(s=!0),void 0===a&&(a=!1),void 0===c&&(c=_.a.TEXTURE_TRILINEAR_SAMPLINGMODE),void 0===l&&(l=_.a.TEXTURETYPE_UNSIGNED_INT);var u=e.call(this,null,o,!s,a)||this;return u.format=n,u._engine=o.getEngine(),u._texture=o.getEngine().createRawTexture(t,i,r,n,s,a,c,null,l),u.wrapU=Ve.a.CLAMP_ADDRESSMODE,u.wrapV=Ve.a.CLAMP_ADDRESSMODE,u}return l.d(t,e),t.prototype.update=function(e){this._engine.updateRawTexture(this._texture,e,this._texture.format,this._texture.invertY,void 0,this._texture.type)},t.CreateLuminanceTexture=function(e,i,r,n,o,s,a){return void 0===o&&(o=!0),void 0===s&&(s=!1),void 0===a&&(a=_.a.TEXTURE_TRILINEAR_SAMPLINGMODE),new t(e,i,r,_.a.TEXTUREFORMAT_LUMINANCE,n,o,s,a)},t.CreateLuminanceAlphaTexture=function(e,i,r,n,o,s,a){return void 0===o&&(o=!0),void 0===s&&(s=!1),void 0===a&&(a=_.a.TEXTURE_TRILINEAR_SAMPLINGMODE),new t(e,i,r,_.a.TEXTUREFORMAT_LUMINANCE_ALPHA,n,o,s,a)},t.CreateAlphaTexture=function(e,i,r,n,o,s,a){return void 0===o&&(o=!0),void 0===s&&(s=!1),void 0===a&&(a=_.a.TEXTURE_TRILINEAR_SAMPLINGMODE),new t(e,i,r,_.a.TEXTUREFORMAT_ALPHA,n,o,s,a)},t.CreateRGBTexture=function(e,i,r,n,o,s,a,c){return void 0===o&&(o=!0),void 0===s&&(s=!1),void 0===a&&(a=_.a.TEXTURE_TRILINEAR_SAMPLINGMODE),void 0===c&&(c=_.a.TEXTURETYPE_UNSIGNED_INT),new t(e,i,r,_.a.TEXTUREFORMAT_RGB,n,o,s,a,c)},t.CreateRGBATexture=function(e,i,r,n,o,s,a,c){return void 0===o&&(o=!0),void 0===s&&(s=!1),void 0===a&&(a=_.a.TEXTURE_TRILINEAR_SAMPLINGMODE),void 0===c&&(c=_.a.TEXTURETYPE_UNSIGNED_INT),new t(e,i,r,_.a.TEXTUREFORMAT_RGBA,n,o,s,a,c)},t.CreateRTexture=function(e,i,r,n,o,s,a,c){return void 0===o&&(o=!0),void 0===s&&(s=!1),void 0===a&&(a=Ve.a.TRILINEAR_SAMPLINGMODE),void 0===c&&(c=_.a.TEXTURETYPE_FLOAT),new t(e,i,r,_.a.TEXTUREFORMAT_R,n,o,s,a,c)},t}(Ve.a),ke=function(){function e(e,t,i){this.name=e,this.id=t,this.bones=new Array,this.needInitialSkinMatrix=!1,this.overrideMesh=null,this._isDirty=!0,this._meshesWithPoseMatrix=new Array,this._identity=o.j.Identity(),this._ranges={},this._lastAbsoluteTransformsUpdateId=-1,this._canUseTextureForBones=!1,this._numBonesWithLinkedTransformNode=0,this.doNotSerialize=!1,this.useTextureToStoreBoneMatrices=!0,this._animationPropertiesOverride=null,this.onBeforeComputeObservable=new n.c,this.bones=[],this._scene=i||R.a.LastCreatedScene,this._scene.skeletons.push(this),this._isDirty=!0;var r=this._scene.getEngine().getCaps();this._canUseTextureForBones=r.textureFloat&&r.maxVertexTextureImageUnits>0}return Object.defineProperty(e.prototype,"animationPropertiesOverride",{get:function(){return this._animationPropertiesOverride?this._animationPropertiesOverride:this._scene.animationPropertiesOverride},set:function(e){this._animationPropertiesOverride=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isUsingTextureForMatrices",{get:function(){return this.useTextureToStoreBoneMatrices&&this._canUseTextureForBones&&!this.needInitialSkinMatrix},enumerable:!0,configurable:!0}),e.prototype.getTransformMatrices=function(e){return this.needInitialSkinMatrix&&e._bonesTransformMatrices?e._bonesTransformMatrices:(this._transformMatrices||this.prepare(),this._transformMatrices)},e.prototype.getTransformMatrixTexture=function(){return this._transformMatrixTexture},e.prototype.getScene=function(){return this._scene},e.prototype.toString=function(e){var t="Name: "+this.name+", nBones: "+this.bones.length;if(t+=", nAnimationRanges: "+(this._ranges?Object.keys(this._ranges).length:"none"),e){t+=", Ranges: {";var i=!0;for(var r in this._ranges)i&&(t+=", ",i=!1),t+=r;t+="}"}return t},e.prototype.getBoneIndexByName=function(e){for(var t=0,i=this.bones.length;t<i;t++)if(this.bones[t].name===e)return t;return-1},e.prototype.createAnimationRange=function(e,t,i){if(!this._ranges[e]){this._ranges[e]=new L(e,t,i);for(var r=0,n=this.bones.length;r<n;r++)this.bones[r].animations[0]&&this.bones[r].animations[0].createRange(e,t,i)}},e.prototype.deleteAnimationRange=function(e,t){void 0===t&&(t=!0);for(var i=0,r=this.bones.length;i<r;i++)this.bones[i].animations[0]&&this.bones[i].animations[0].deleteRange(e,t);this._ranges[e]=null},e.prototype.getAnimationRange=function(e){return this._ranges[e]},e.prototype.getAnimationRanges=function(){var e,t=[],i=0;for(e in this._ranges)t[i]=this._ranges[e],i++;return t},e.prototype.copyAnimationRange=function(e,t,i){if(void 0===i&&(i=!1),this._ranges[t]||!e.getAnimationRange(t))return!1;var r,n,o=!0,s=this._getHighestAnimationFrame()+1,a={},c=e.bones;for(n=0,r=c.length;n<r;n++)a[c[n].name]=c[n];this.bones.length!==c.length&&(p.a.Warn("copyAnimationRange: this rig has "+this.bones.length+" bones, while source as "+c.length),o=!1);var l=i&&this.dimensionsAtRest&&e.dimensionsAtRest?this.dimensionsAtRest.divide(e.dimensionsAtRest):null;for(n=0,r=this.bones.length;n<r;n++){var u=this.bones[n].name,h=a[u];h?o=o&&this.bones[n].copyAnimationRange(h,t,s,i,l):(p.a.Warn("copyAnimationRange: not same rig, missing source bone "+u),o=!1)}var d=e.getAnimationRange(t);return d&&(this._ranges[t]=new L(t,d.from+s,d.to+s)),o},e.prototype.returnToRest=function(){for(var e=0;e<this.bones.length;e++)this.bones[e].returnToRest()},e.prototype._getHighestAnimationFrame=function(){for(var e=0,t=0,i=this.bones.length;t<i;t++)if(this.bones[t].animations[0]){var r=this.bones[t].animations[0].getHighestFrame();e<r&&(e=r)}return e},e.prototype.beginAnimation=function(e,t,i,r){var n=this.getAnimationRange(e);return n?this._scene.beginAnimation(this,n.from,n.to,t,i,r):null},e.prototype._markAsDirty=function(){this._isDirty=!0},e.prototype._registerMeshWithPoseMatrix=function(e){this._meshesWithPoseMatrix.push(e)},e.prototype._unregisterMeshWithPoseMatrix=function(e){var t=this._meshesWithPoseMatrix.indexOf(e);t>-1&&this._meshesWithPoseMatrix.splice(t,1)},e.prototype._computeTransformMatrices=function(e,t){this.onBeforeComputeObservable.notifyObservers(this);for(var i=0;i<this.bones.length;i++){var r=this.bones[i],n=r.getParent();if(n?r.getLocalMatrix().multiplyToRef(n.getWorldMatrix(),r.getWorldMatrix()):t?r.getLocalMatrix().multiplyToRef(t,r.getWorldMatrix()):r.getWorldMatrix().copyFrom(r.getLocalMatrix()),-1!==r._index){var o=null===r._index?i:r._index;r.getInvertedAbsoluteTransform().multiplyToArray(r.getWorldMatrix(),e,16*o)}}this._identity.copyToArray(e,16*this.bones.length)},e.prototype.prepare=function(){if(this._numBonesWithLinkedTransformNode>0)for(var e=0,t=this.bones;e<t.length;e++){var i=t[e];i._linkedTransformNode&&(i._linkedTransformNode.computeWorldMatrix(),i._matrix=i._linkedTransformNode._localMatrix,i.markAsDirty())}if(this._isDirty){if(this.needInitialSkinMatrix)for(var r=0;r<this._meshesWithPoseMatrix.length;r++){var n=this._meshesWithPoseMatrix[r],s=n.getPoseMatrix();if(n._bonesTransformMatrices&&n._bonesTransformMatrices.length===16*(this.bones.length+1)||(n._bonesTransformMatrices=new Float32Array(16*(this.bones.length+1))),this._synchronizedWithMesh!==n){this._synchronizedWithMesh=n;for(var a=0;a<this.bones.length;a++){var c=this.bones[a];if(!c.getParent())c.getBaseMatrix().multiplyToRef(s,o.t.Matrix[1]),c._updateDifferenceMatrix(o.t.Matrix[1])}}this._computeTransformMatrices(n._bonesTransformMatrices,s)}else this._transformMatrices&&this._transformMatrices.length===16*(this.bones.length+1)||(this._transformMatrices=new Float32Array(16*(this.bones.length+1)),this.isUsingTextureForMatrices&&(this._transformMatrixTexture&&this._transformMatrixTexture.dispose(),this._transformMatrixTexture=Ge.CreateRGBATexture(this._transformMatrices,4*(this.bones.length+1),1,this._scene,!1,!1,_.a.TEXTURE_NEAREST_SAMPLINGMODE,_.a.TEXTURETYPE_FLOAT))),this._computeTransformMatrices(this._transformMatrices,null),this.isUsingTextureForMatrices&&this._transformMatrixTexture&&this._transformMatrixTexture.update(this._transformMatrices);this._isDirty=!1,this._scene._activeBones.addCount(this.bones.length,!1)}},e.prototype.getAnimatables=function(){if(!this._animatables||this._animatables.length!==this.bones.length){this._animatables=[];for(var e=0;e<this.bones.length;e++)this._animatables.push(this.bones[e])}return this._animatables},e.prototype.clone=function(t,i){var r=new e(t,i||t,this._scene);r.needInitialSkinMatrix=this.needInitialSkinMatrix;for(var n=0;n<this.bones.length;n++){var o=this.bones[n],s=null,a=o.getParent();if(a){var c=this.bones.indexOf(a);s=r.bones[c]}var l=new Y(o.name,r,s,o.getBaseMatrix().clone(),o.getRestPose().clone());S.a.DeepCopy(o.animations,l.animations)}if(this._ranges)for(var u in r._ranges={},this._ranges){var h=this._ranges[u];h&&(r._ranges[u]=h.clone())}return this._isDirty=!0,r},e.prototype.enableBlending=function(e){void 0===e&&(e=.01),this.bones.forEach(function(t){t.animations.forEach(function(t){t.enableBlending=!0,t.blendingSpeed=e})})},e.prototype.dispose=function(){this._meshesWithPoseMatrix=[],this.getScene().stopAnimation(this),this.getScene().removeSkeleton(this),this._transformMatrixTexture&&(this._transformMatrixTexture.dispose(),this._transformMatrixTexture=null)},e.prototype.serialize=function(){var e={};e.name=this.name,e.id=this.id,this.dimensionsAtRest&&(e.dimensionsAtRest=this.dimensionsAtRest.asArray()),e.bones=[],e.needInitialSkinMatrix=this.needInitialSkinMatrix;for(var t=0;t<this.bones.length;t++){var i=this.bones[t],r=i.getParent(),n={parentBoneIndex:r?this.bones.indexOf(r):-1,name:i.name,matrix:i.getBaseMatrix().toArray(),rest:i.getRestPose().toArray()};for(var o in e.bones.push(n),i.length&&(n.length=i.length),i.metadata&&(n.metadata=i.metadata),i.animations&&i.animations.length>0&&(n.animation=i.animations[0].serialize()),e.ranges=[],this._ranges){var s=this._ranges[o];if(s){var a={};a.name=o,a.from=s.from,a.to=s.to,e.ranges.push(a)}}}return e},e.Parse=function(t,i){var r,n=new e(t.name,t.id,i);for(t.dimensionsAtRest&&(n.dimensionsAtRest=o.x.FromArray(t.dimensionsAtRest)),n.needInitialSkinMatrix=t.needInitialSkinMatrix,r=0;r<t.bones.length;r++){var s=t.bones[r],a=null;s.parentBoneIndex>-1&&(a=n.bones[s.parentBoneIndex]);var c=s.rest?o.j.FromArray(s.rest):null,l=new Y(s.name,n,a,o.j.FromArray(s.matrix),c);void 0!==s.id&&null!==s.id&&(l.id=s.id),s.length&&(l.length=s.length),s.metadata&&(l.metadata=s.metadata),s.animation&&l.animations.push(N.Parse(s.animation))}if(t.ranges)for(r=0;r<t.ranges.length;r++){var u=t.ranges[r];n.createAnimationRange(u.name,u.from,u.to)}return n},e.prototype.computeAbsoluteTransforms=function(e){void 0===e&&(e=!1);var t=this._scene.getRenderId();(this._lastAbsoluteTransformsUpdateId!=t||e)&&(this.bones[0].computeAbsoluteTransforms(),this._lastAbsoluteTransformsUpdateId=t)},e.prototype.getPoseMatrix=function(){var e=null;return this._meshesWithPoseMatrix.length>0&&(e=this._meshesWithPoseMatrix[0].getPoseMatrix()),e},e.prototype.sortBones=function(){for(var e=new Array,t=new Array(this.bones.length),i=0;i<this.bones.length;i++)this._sortBones(i,e,t);this.bones=e},e.prototype._sortBones=function(e,t,i){if(!i[e]){i[e]=!0;var r=this.bones[e];void 0===r._index&&(r._index=e);var n=r.getParent();n&&this._sortBones(this.bones.indexOf(n),t,i),t.push(r)}},e}(),ze={},je=function(){function e(e){this.attached={},this.camera=e,this.checkInputs=function(){}}return e.prototype.add=function(e){var t=e.getSimpleName();this.attached[t]?p.a.Warn("camera input of type "+t+" already exists on camera"):(this.attached[t]=e,e.camera=this.camera,e.checkInputs&&(this.checkInputs=this._addCheckInputs(e.checkInputs.bind(e))),this.attachedElement&&e.attachControl(this.attachedElement))},e.prototype.remove=function(e){for(var t in this.attached){var i=this.attached[t];i===e&&(i.detachControl(this.attachedElement),i.camera=null,delete this.attached[t],this.rebuildInputCheck())}},e.prototype.removeByType=function(e){for(var t in this.attached){var i=this.attached[t];i.getClassName()===e&&(i.detachControl(this.attachedElement),i.camera=null,delete this.attached[t],this.rebuildInputCheck())}},e.prototype._addCheckInputs=function(e){var t=this.checkInputs;return function(){t(),e()}},e.prototype.attachInput=function(e){this.attachedElement&&e.attachControl(this.attachedElement,this.noPreventDefault)},e.prototype.attachElement=function(e,t){if(void 0===t&&(t=!1),!this.attachedElement)for(var i in t=!Le.a.ForceAttachControlToAlwaysPreventDefault&&t,this.attachedElement=e,this.noPreventDefault=t,this.attached)this.attached[i].attachControl(e,t)},e.prototype.detachElement=function(e,t){if(void 0===t&&(t=!1),this.attachedElement===e){for(var i in this.attached)this.attached[i].detachControl(e),t&&(this.attached[i].camera=null);this.attachedElement=null}},e.prototype.rebuildInputCheck=function(){for(var e in this.checkInputs=function(){},this.attached){var t=this.attached[e];t.checkInputs&&(this.checkInputs=this._addCheckInputs(t.checkInputs.bind(t)))}},e.prototype.clear=function(){this.attachedElement&&this.detachElement(this.attachedElement,!0),this.attached={},this.attachedElement=null,this.checkInputs=function(){}},e.prototype.serialize=function(e){var t={};for(var i in this.attached){var r=this.attached[i],n=w.a.Serialize(r);t[r.getClassName()]=n}e.inputsmgr=t},e.prototype.parse=function(e){var t=e.inputsmgr;if(t)for(var i in this.clear(),t){if(o=ze[i]){var r=t[i],n=w.a.Parse(function(){return new o},r,null);this.add(n)}}else for(var i in this.attached){var o;if(o=ze[this.attached[i].getClassName()]){n=w.a.Parse(function(){return new o},e,null);this.remove(this.attached[i]),this.add(n)}}},e}(),We=function(){return function(e,t){this.x=e,this.y=t}}(),He=function(){function e(t,i,r,n,o,s,a){void 0===n&&(n=0),void 0===o&&(o=1),void 0===s&&(s=2),void 0===a&&(a=3),this.id=t,this.index=i,this.browserGamepad=r,this._leftStick={x:0,y:0},this._rightStick={x:0,y:0},this._isConnected=!0,this._invertLeftStickY=!1,this.type=e.GAMEPAD,this._leftStickAxisX=n,this._leftStickAxisY=o,this._rightStickAxisX=s,this._rightStickAxisY=a,this.browserGamepad.axes.length>=2&&(this._leftStick={x:this.browserGamepad.axes[this._leftStickAxisX],y:this.browserGamepad.axes[this._leftStickAxisY]}),this.browserGamepad.axes.length>=4&&(this._rightStick={x:this.browserGamepad.axes[this._rightStickAxisX],y:this.browserGamepad.axes[this._rightStickAxisY]})}return Object.defineProperty(e.prototype,"isConnected",{get:function(){return this._isConnected},enumerable:!0,configurable:!0}),e.prototype.onleftstickchanged=function(e){this._onleftstickchanged=e},e.prototype.onrightstickchanged=function(e){this._onrightstickchanged=e},Object.defineProperty(e.prototype,"leftStick",{get:function(){return this._leftStick},set:function(e){!this._onleftstickchanged||this._leftStick.x===e.x&&this._leftStick.y===e.y||this._onleftstickchanged(e),this._leftStick=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rightStick",{get:function(){return this._rightStick},set:function(e){!this._onrightstickchanged||this._rightStick.x===e.x&&this._rightStick.y===e.y||this._onrightstickchanged(e),this._rightStick=e},enumerable:!0,configurable:!0}),e.prototype.update=function(){this._leftStick&&(this.leftStick={x:this.browserGamepad.axes[this._leftStickAxisX],y:this.browserGamepad.axes[this._leftStickAxisY]},this._invertLeftStickY&&(this.leftStick.y*=-1)),this._rightStick&&(this.rightStick={x:this.browserGamepad.axes[this._rightStickAxisX],y:this.browserGamepad.axes[this._rightStickAxisY]})},e.prototype.dispose=function(){},e.GAMEPAD=0,e.GENERIC=1,e.XBOX=2,e.POSE_ENABLED=3,e}(),Xe=function(e){function t(t,i,r){var o=e.call(this,t,i,r)||this;return o.onButtonDownObservable=new n.c,o.onButtonUpObservable=new n.c,o.type=He.GENERIC,o._buttons=new Array(r.buttons.length),o}return l.d(t,e),t.prototype.onbuttondown=function(e){this._onbuttondown=e},t.prototype.onbuttonup=function(e){this._onbuttonup=e},t.prototype._setButtonValue=function(e,t,i){return e!==t&&(1===e&&(this._onbuttondown&&this._onbuttondown(i),this.onButtonDownObservable.notifyObservers(i)),0===e&&(this._onbuttonup&&this._onbuttonup(i),this.onButtonUpObservable.notifyObservers(i))),e},t.prototype.update=function(){e.prototype.update.call(this);for(var t=0;t<this._buttons.length;t++)this._buttons[t]=this._setButtonValue(this.browserGamepad.buttons[t].value,this._buttons[t],t)},t.prototype.dispose=function(){e.prototype.dispose.call(this),this.onButtonDownObservable.clear(),this.onButtonUpObservable.clear()},t}(He),Ye=function(){function e(){this.gamepadRotationSensibility=80,this.gamepadMoveSensibility=40}return e.prototype.attachControl=function(e,t){var i=this,r=this.camera.getScene().gamepadManager;this._onGamepadConnectedObserver=r.onGamepadConnectedObservable.add(function(e){e.type!==He.POSE_ENABLED&&(i.gamepad&&e.type!==He.XBOX||(i.gamepad=e))}),this._onGamepadDisconnectedObserver=r.onGamepadDisconnectedObservable.add(function(e){i.gamepad===e&&(i.gamepad=null)}),this.gamepad=r.getGamepadByType(He.XBOX)},e.prototype.detachControl=function(e){this.camera.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver),this.camera.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver),this.gamepad=null},e.prototype.checkInputs=function(){if(this.gamepad){var e=this.camera,t=this.gamepad.rightStick;if(t){if(0!=t.x){var i=t.x/this.gamepadRotationSensibility;0!=i&&Math.abs(i)>.005&&(e.inertialAlphaOffset+=i)}if(0!=t.y){var r=t.y/this.gamepadRotationSensibility;0!=r&&Math.abs(r)>.005&&(e.inertialBetaOffset+=r)}}var n=this.gamepad.leftStick;if(n&&0!=n.y){var o=n.y/this.gamepadMoveSensibility;0!=o&&Math.abs(o)>.005&&(this.camera.inertialRadiusOffset-=o)}}},e.prototype.getClassName=function(){return"ArcRotateCameraGamepadInput"},e.prototype.getSimpleName=function(){return"gamepad"},l.c([Object(w.c)()],e.prototype,"gamepadRotationSensibility",void 0),l.c([Object(w.c)()],e.prototype,"gamepadMoveSensibility",void 0),e}();ze.ArcRotateCameraGamepadInput=Ye;var Ke=i(47),Qe=function(){function e(){this.keysUp=[38],this.keysDown=[40],this.keysLeft=[37],this.keysRight=[39],this.keysReset=[220],this.panningSensibility=50,this.zoomingSensibility=25,this.useAltToZoom=!0,this.angularSpeed=.01,this._keys=new Array}return e.prototype.attachControl=function(e,t){var i=this;this._onCanvasBlurObserver||(this._scene=this.camera.getScene(),this._engine=this._scene.getEngine(),this._onCanvasBlurObserver=this._engine.onCanvasBlurObservable.add(function(){i._keys=[]}),this._onKeyboardObserver=this._scene.onKeyboardObservable.add(function(e){var r,n=e.event;n.metaKey||(e.type===Ke.a.KEYDOWN?(i._ctrlPressed=n.ctrlKey,i._altPressed=n.altKey,(-1!==i.keysUp.indexOf(n.keyCode)||-1!==i.keysDown.indexOf(n.keyCode)||-1!==i.keysLeft.indexOf(n.keyCode)||-1!==i.keysRight.indexOf(n.keyCode)||-1!==i.keysReset.indexOf(n.keyCode))&&(-1===(r=i._keys.indexOf(n.keyCode))&&i._keys.push(n.keyCode),n.preventDefault&&(t||n.preventDefault()))):-1===i.keysUp.indexOf(n.keyCode)&&-1===i.keysDown.indexOf(n.keyCode)&&-1===i.keysLeft.indexOf(n.keyCode)&&-1===i.keysRight.indexOf(n.keyCode)&&-1===i.keysReset.indexOf(n.keyCode)||((r=i._keys.indexOf(n.keyCode))>=0&&i._keys.splice(r,1),n.preventDefault&&(t||n.preventDefault())))}))},e.prototype.detachControl=function(e){this._scene&&(this._onKeyboardObserver&&this._scene.onKeyboardObservable.remove(this._onKeyboardObserver),this._onCanvasBlurObserver&&this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver),this._onKeyboardObserver=null,this._onCanvasBlurObserver=null),this._keys=[]},e.prototype.checkInputs=function(){if(this._onKeyboardObserver)for(var e=this.camera,t=0;t<this._keys.length;t++){var i=this._keys[t];-1!==this.keysLeft.indexOf(i)?this._ctrlPressed&&this.camera._useCtrlForPanning?e.inertialPanningX-=1/this.panningSensibility:e.inertialAlphaOffset-=this.angularSpeed:-1!==this.keysUp.indexOf(i)?this._ctrlPressed&&this.camera._useCtrlForPanning?e.inertialPanningY+=1/this.panningSensibility:this._altPressed&&this.useAltToZoom?e.inertialRadiusOffset+=1/this.zoomingSensibility:e.inertialBetaOffset-=this.angularSpeed:-1!==this.keysRight.indexOf(i)?this._ctrlPressed&&this.camera._useCtrlForPanning?e.inertialPanningX+=1/this.panningSensibility:e.inertialAlphaOffset+=this.angularSpeed:-1!==this.keysDown.indexOf(i)?this._ctrlPressed&&this.camera._useCtrlForPanning?e.inertialPanningY-=1/this.panningSensibility:this._altPressed&&this.useAltToZoom?e.inertialRadiusOffset-=1/this.zoomingSensibility:e.inertialBetaOffset+=this.angularSpeed:-1!==this.keysReset.indexOf(i)&&e.useInputToRestoreState&&e.restoreState()}},e.prototype.getClassName=function(){return"ArcRotateCameraKeyboardMoveInput"},e.prototype.getSimpleName=function(){return"keyboard"},l.c([Object(w.c)()],e.prototype,"keysUp",void 0),l.c([Object(w.c)()],e.prototype,"keysDown",void 0),l.c([Object(w.c)()],e.prototype,"keysLeft",void 0),l.c([Object(w.c)()],e.prototype,"keysRight",void 0),l.c([Object(w.c)()],e.prototype,"keysReset",void 0),l.c([Object(w.c)()],e.prototype,"panningSensibility",void 0),l.c([Object(w.c)()],e.prototype,"zoomingSensibility",void 0),l.c([Object(w.c)()],e.prototype,"useAltToZoom",void 0),l.c([Object(w.c)()],e.prototype,"angularSpeed",void 0),e}();ze.ArcRotateCameraKeyboardMoveInput=Qe;var qe=function(){function e(){this.wheelPrecision=3,this.wheelDeltaPercentage=0}return e.prototype.attachControl=function(e,t){var i=this;this._wheel=function(e,r){if(e.type===Ae.a.POINTERWHEEL){var n=e.event,o=0,s=n;if(s.wheelDelta)if(i.wheelDeltaPercentage){var a=.01*s.wheelDelta*i.wheelDeltaPercentage*i.camera.radius;o=s.wheelDelta>0?a/(1+i.wheelDeltaPercentage):a*(1+i.wheelDeltaPercentage)}else o=s.wheelDelta/(40*i.wheelPrecision);else o=-(n.deltaY||n.detail)/i.wheelPrecision;o&&(i.camera.inertialRadiusOffset+=o),n.preventDefault&&(t||n.preventDefault())}},this._observer=this.camera.getScene().onPointerObservable.add(this._wheel,Ae.a.POINTERWHEEL)},e.prototype.detachControl=function(e){this._observer&&e&&(this.camera.getScene().onPointerObservable.remove(this._observer),this._observer=null,this._wheel=null)},e.prototype.getClassName=function(){return"ArcRotateCameraMouseWheelInput"},e.prototype.getSimpleName=function(){return"mousewheel"},l.c([Object(w.c)()],e.prototype,"wheelPrecision",void 0),l.c([Object(w.c)()],e.prototype,"wheelDeltaPercentage",void 0),e}();ze.ArcRotateCameraMouseWheelInput=qe;var Ze=function(){function e(){this.buttons=[0,1,2],this.angularSensibilityX=1e3,this.angularSensibilityY=1e3,this.pinchPrecision=12,this.pinchDeltaPercentage=0,this.panningSensibility=1e3,this.multiTouchPanning=!0,this.multiTouchPanAndZoom=!0,this.pinchInwards=!0,this._isPanClick=!1}return e.prototype.attachControl=function(e,t){var i,r=this,n=this.camera.getEngine(),o=null,s=null,a=0,c=0,l=0,u={x:0,y:0,isPaning:!1,isPinching:!1};this._pointerInput=function(h,d){var f=h.event,p="touch"===h.event.pointerType;if(!n.isInVRExclusivePointerMode&&(h.type===Ae.a.POINTERMOVE||-1!==r.buttons.indexOf(f.button))){var _=f.srcElement||f.target;if(h.type===Ae.a.POINTERDOWN&&_){try{_.setPointerCapture(f.pointerId)}catch(e){}r._isPanClick=f.button===r.camera._panningMouseButton,i={x:f.clientX,y:f.clientY,pointerId:f.pointerId,type:f.pointerType},null===o?o=i:null===s&&(s=i),t||(f.preventDefault(),e.focus())}else if(h.type===Ae.a.POINTERDOUBLETAP)r.camera.useInputToRestoreState&&r.camera.restoreState();else if(h.type===Ae.a.POINTERUP&&_){try{_.releasePointerCapture(f.pointerId)}catch(e){}i=null,a=0,u.isPaning=!1,u.isPinching=!1,l=0,c=0,p||(s=null),n._badOS?o=s=null:s&&o&&o.pointerId==f.pointerId?(o=s,s=null,i={x:o.x,y:o.y,pointerId:o.pointerId,type:f.pointerType}):o&&s&&s.pointerId==f.pointerId?(s=null,i={x:o.x,y:o.y,pointerId:o.pointerId,type:f.pointerType}):o=s=null,t||f.preventDefault()}else if(h.type===Ae.a.POINTERMOVE)if(t||f.preventDefault(),o&&null===s&&i){if(0!==r.panningSensibility&&(f.ctrlKey&&r.camera._useCtrlForPanning||r._isPanClick))r.camera.inertialPanningX+=-(f.clientX-i.x)/r.panningSensibility,r.camera.inertialPanningY+=(f.clientY-i.y)/r.panningSensibility;else{var g=f.clientX-i.x,m=f.clientY-i.y;r.camera.inertialAlphaOffset-=g/r.angularSensibilityX,r.camera.inertialBetaOffset-=m/r.angularSensibilityY}i.x=f.clientX,i.y=f.clientY}else if(o&&s){var v=o.pointerId===f.pointerId?o:s;v.x=f.clientX,v.y=f.clientY;var y=r.pinchInwards?1:-1,b=o.x-s.x,T=o.y-s.y,E=b*b+T*T,x=Math.sqrt(E);if(0===a)return c=x,a=E,u.x=(o.x+s.x)/2,void(u.y=(o.y+s.y)/2);if(r.multiTouchPanAndZoom){if(r.pinchDeltaPercentage?r.camera.inertialRadiusOffset+=.001*(E-a)*r.camera.radius*r.pinchDeltaPercentage:r.camera.inertialRadiusOffset+=(E-a)/(r.pinchPrecision*((r.angularSensibilityX+r.angularSensibilityY)/2)*y),0!==r.panningSensibility){var A=(o.x+s.x)/2,P=(o.y+s.y)/2,R=A-u.x,S=P-u.y;u.x=A,u.y=P,r.camera.inertialPanningX+=-R/r.panningSensibility,r.camera.inertialPanningY+=S/r.panningSensibility}}else{if(l++,u.isPinching||l<20&&Math.abs(x-c)>r.camera.pinchToPanMaxDistance)r.pinchDeltaPercentage?r.camera.inertialRadiusOffset+=.001*(E-a)*r.camera.radius*r.pinchDeltaPercentage:r.camera.inertialRadiusOffset+=(E-a)/(r.pinchPrecision*((r.angularSensibilityX+r.angularSensibilityY)/2)*y),u.isPaning=!1,u.isPinching=!0;else if(i&&i.pointerId===v.pointerId&&0!==r.panningSensibility&&r.multiTouchPanning){if(!u.isPaning)return u.isPaning=!0,u.isPinching=!1,u.x=v.x,void(u.y=v.y);r.camera.inertialPanningX+=-(v.x-u.x)/r.panningSensibility,r.camera.inertialPanningY+=(v.y-u.y)/r.panningSensibility}i&&i.pointerId===f.pointerId&&(u.x=v.x,u.y=v.y)}a=E}}},this._observer=this.camera.getScene().onPointerObservable.add(this._pointerInput,Ae.a.POINTERDOWN|Ae.a.POINTERUP|Ae.a.POINTERMOVE|Ae.a.POINTERDOUBLETAP),this._onContextMenu=function(e){e.preventDefault()},this.camera._useCtrlForPanning||e.addEventListener("contextmenu",this._onContextMenu,!1),this._onLostFocus=function(){o=s=null,a=0,u.isPaning=!1,u.isPinching=!1,l=0,i=null,c=0},this._onMouseMove=function(e){if(n.isPointerLock){var i=e.movementX||e.mozMovementX||e.webkitMovementX||e.msMovementX||0,o=e.movementY||e.mozMovementY||e.webkitMovementY||e.msMovementY||0;r.camera.inertialAlphaOffset-=i/r.angularSensibilityX,r.camera.inertialBetaOffset-=o/r.angularSensibilityY,t||e.preventDefault()}},this._onGestureStart=function(t){void 0!==window.MSGesture&&(r._MSGestureHandler||(r._MSGestureHandler=new MSGesture,r._MSGestureHandler.target=e),r._MSGestureHandler.addPointer(t.pointerId))},this._onGesture=function(e){r.camera.radius*=e.scale,e.preventDefault&&(t||(e.stopPropagation(),e.preventDefault()))},e.addEventListener("mousemove",this._onMouseMove,!1),e.addEventListener("MSPointerDown",this._onGestureStart,!1),e.addEventListener("MSGestureChange",this._onGesture,!1),ve.h.RegisterTopRootEvents([{name:"blur",handler:this._onLostFocus}])},e.prototype.detachControl=function(e){this._onLostFocus&&ve.h.UnregisterTopRootEvents([{name:"blur",handler:this._onLostFocus}]),e&&this._observer&&(this.camera.getScene().onPointerObservable.remove(this._observer),this._observer=null,this._onContextMenu&&e.removeEventListener("contextmenu",this._onContextMenu),this._onMouseMove&&e.removeEventListener("mousemove",this._onMouseMove),this._onGestureStart&&e.removeEventListener("MSPointerDown",this._onGestureStart),this._onGesture&&e.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.prototype.getClassName=function(){return"ArcRotateCameraPointersInput"},e.prototype.getSimpleName=function(){return"pointers"},l.c([Object(w.c)()],e.prototype,"buttons",void 0),l.c([Object(w.c)()],e.prototype,"angularSensibilityX",void 0),l.c([Object(w.c)()],e.prototype,"angularSensibilityY",void 0),l.c([Object(w.c)()],e.prototype,"pinchPrecision",void 0),l.c([Object(w.c)()],e.prototype,"pinchDeltaPercentage",void 0),l.c([Object(w.c)()],e.prototype,"panningSensibility",void 0),l.c([Object(w.c)()],e.prototype,"multiTouchPanning",void 0),l.c([Object(w.c)()],e.prototype,"multiTouchPanAndZoom",void 0),e}();ze.ArcRotateCameraPointersInput=Ze;var Je=function(e){function t(t){return e.call(this,t)||this}return l.d(t,e),t.prototype.addMouseWheel=function(){return this.add(new qe),this},t.prototype.addPointers=function(){return this.add(new Ze),this},t.prototype.addKeyboard=function(){return this.add(new Qe),this},t}(je);Je.prototype.addVRDeviceOrientation=function(){return this.add(new $e),this};var $e=function(){function e(){this.alphaCorrection=1,this.gammaCorrection=1,this._alpha=0,this._gamma=0,this._dirty=!1,this._deviceOrientationHandler=this._onOrientationEvent.bind(this)}return e.prototype.attachControl=function(e,t){this.camera.attachControl(e,t),window.addEventListener("deviceorientation",this._deviceOrientationHandler)},e.prototype._onOrientationEvent=function(e){null!==e.alpha&&(this._alpha=(0|+e.alpha)*this.alphaCorrection),null!==e.gamma&&(this._gamma=(0|+e.gamma)*this.gammaCorrection),this._dirty=!0},e.prototype.checkInputs=function(){this._dirty&&(this._dirty=!1,this._gamma<0&&(this._gamma=180+this._gamma),this.camera.alpha=-this._alpha/180*Math.PI%Math.PI*2,this.camera.beta=this._gamma/180*Math.PI)},e.prototype.detachControl=function(e){window.removeEventListener("deviceorientation",this._deviceOrientationHandler)},e.prototype.getClassName=function(){return"ArcRotateCameraVRDeviceOrientationInput"},e.prototype.getSimpleName=function(){return"VRDeviceOrientation"},e}();ze.ArcRotateCameraVRDeviceOrientationInput=$e;var et=function(){function e(){this.keysForward=[87],this.keysBackward=[83],this.keysUp=[69],this.keysDown=[81],this.keysRight=[68],this.keysLeft=[65],this._keys=new Array}return e.prototype.attachControl=function(e,t){var i=this;this._onCanvasBlurObserver||(this._scene=this.camera.getScene(),this._engine=this._scene.getEngine(),this._onCanvasBlurObserver=this._engine.onCanvasBlurObservable.add(function(){i._keys=[]}),this._onKeyboardObserver=this._scene.onKeyboardObservable.add(function(e){var r,n=e.event;e.type===Ke.a.KEYDOWN?-1===i.keysForward.indexOf(n.keyCode)&&-1===i.keysBackward.indexOf(n.keyCode)&&-1===i.keysUp.indexOf(n.keyCode)&&-1===i.keysDown.indexOf(n.keyCode)&&-1===i.keysLeft.indexOf(n.keyCode)&&-1===i.keysRight.indexOf(n.keyCode)||(-1===(r=i._keys.indexOf(n.keyCode))&&i._keys.push(n.keyCode),t||n.preventDefault()):-1===i.keysForward.indexOf(n.keyCode)&&-1===i.keysBackward.indexOf(n.keyCode)&&-1===i.keysUp.indexOf(n.keyCode)&&-1===i.keysDown.indexOf(n.keyCode)&&-1===i.keysLeft.indexOf(n.keyCode)&&-1===i.keysRight.indexOf(n.keyCode)||((r=i._keys.indexOf(n.keyCode))>=0&&i._keys.splice(r,1),t||n.preventDefault())}))},e.prototype.detachControl=function(e){this._scene&&(this._onKeyboardObserver&&this._scene.onKeyboardObservable.remove(this._onKeyboardObserver),this._onCanvasBlurObserver&&this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver),this._onKeyboardObserver=null,this._onCanvasBlurObserver=null),this._keys=[]},e.prototype.getClassName=function(){return"FlyCameraKeyboardInput"},e.prototype._onLostFocus=function(e){this._keys=[]},e.prototype.getSimpleName=function(){return"keyboard"},e.prototype.checkInputs=function(){if(this._onKeyboardObserver)for(var e=this.camera,t=0;t<this._keys.length;t++){var i=this._keys[t],r=e._computeLocalCameraSpeed();-1!==this.keysForward.indexOf(i)?e._localDirection.copyFromFloats(0,0,r):-1!==this.keysBackward.indexOf(i)?e._localDirection.copyFromFloats(0,0,-r):-1!==this.keysUp.indexOf(i)?e._localDirection.copyFromFloats(0,r,0):-1!==this.keysDown.indexOf(i)?e._localDirection.copyFromFloats(0,-r,0):-1!==this.keysRight.indexOf(i)?e._localDirection.copyFromFloats(r,0,0):-1!==this.keysLeft.indexOf(i)&&e._localDirection.copyFromFloats(-r,0,0),e.getScene().useRightHandedSystem&&(e._localDirection.z*=-1),e.getViewMatrix().invertToRef(e._cameraTransformMatrix),o.x.TransformNormalToRef(e._localDirection,e._cameraTransformMatrix,e._transformedDirection),e.cameraDirection.addInPlace(e._transformedDirection)}},l.c([Object(w.c)()],e.prototype,"keysForward",void 0),l.c([Object(w.c)()],e.prototype,"keysBackward",void 0),l.c([Object(w.c)()],e.prototype,"keysUp",void 0),l.c([Object(w.c)()],e.prototype,"keysDown",void 0),l.c([Object(w.c)()],e.prototype,"keysRight",void 0),l.c([Object(w.c)()],e.prototype,"keysLeft",void 0),e}();ze.FlyCameraKeyboardInput=et;var tt=function(){function e(e){void 0===e&&(e=!0),this.buttons=[0,1,2],this.buttonsYaw=[-1,0,1],this.buttonsPitch=[-1,0,1],this.buttonsRoll=[2],this.activeButton=-1,this.angularSensibility=1e3,this.previousPosition=null}return e.prototype.attachControl=function(e,t){var i=this;this.element=e,this.noPreventDefault=t,this._observer=this.camera.getScene().onPointerObservable.add(function(e,t){i._pointerInput(e,t)},Ae.a.POINTERDOWN|Ae.a.POINTERUP|Ae.a.POINTERMOVE),this._rollObserver=this.camera.getScene().onBeforeRenderObservable.add(function(){i.camera.rollCorrect&&i.camera.restoreRoll(i.camera.rollCorrect)}),this._mousemoveCallback=function(e){i._onMouseMove(e)},e.addEventListener("mousemove",this._mousemoveCallback,!1)},e.prototype.detachControl=function(e){this._observer&&e&&(this.camera.getScene().onPointerObservable.remove(this._observer),this.camera.getScene().onBeforeRenderObservable.remove(this._rollObserver),this._mousemoveCallback&&e.removeEventListener("mousemove",this._mousemoveCallback),this._observer=null,this._rollObserver=null,this.previousPosition=null,this.noPreventDefault=void 0)},e.prototype.getClassName=function(){return"FlyCameraMouseInput"},e.prototype.getSimpleName=function(){return"mouse"},e.prototype._pointerInput=function(e,t){var i=e.event,r=this.camera.getEngine();if(!r.isInVRExclusivePointerMode&&(this.touchEnabled||"touch"!==i.pointerType)&&(e.type===Ae.a.POINTERMOVE||-1!==this.buttons.indexOf(i.button))){var n=i.srcElement||i.target;if(e.type===Ae.a.POINTERDOWN&&n){try{n.setPointerCapture(i.pointerId)}catch(i){}this.previousPosition={x:i.clientX,y:i.clientY},this.activeButton=i.button,this.noPreventDefault||(i.preventDefault(),this.element.focus())}else if(e.type===Ae.a.POINTERUP&&n){try{n.releasePointerCapture(i.pointerId)}catch(i){}this.activeButton=-1,this.previousPosition=null,this.noPreventDefault||i.preventDefault()}else if(e.type===Ae.a.POINTERMOVE){if(!this.previousPosition||r.isPointerLock)return;var o=i.clientX-this.previousPosition.x,s=i.clientY-this.previousPosition.y;this.rotateCamera(o,s),this.previousPosition={x:i.clientX,y:i.clientY},this.noPreventDefault||i.preventDefault()}}},e.prototype._onMouseMove=function(e){var t=this.camera.getEngine();if(t.isPointerLock&&!t.isInVRExclusivePointerMode){var i=e.movementX||e.mozMovementX||e.webkitMovementX||e.msMovementX||0,r=e.movementY||e.mozMovementY||e.webkitMovementY||e.msMovementY||0;this.rotateCamera(i,r),this.previousPosition=null,this.noPreventDefault||e.preventDefault()}},e.prototype.rotateCamera=function(e,t){var i=this,r=this.camera;this.camera.getScene().useRightHandedSystem&&(e*=-1),r.parent&&r.parent._getWorldMatrixDeterminant()<0&&(e*=-1);var n,s=e/this.angularSensibility,a=t/this.angularSensibility,c=o.q.RotationYawPitchRoll(r.rotation.y,r.rotation.x,r.rotation.z);if(this.buttonsPitch.some(function(e){return e===i.activeButton})&&(n=o.q.RotationAxis(o.c.X,a),c.multiplyInPlace(n)),this.buttonsYaw.some(function(e){return e===i.activeButton})){n=o.q.RotationAxis(o.c.Y,s),c.multiplyInPlace(n);var l=r.bankedTurnLimit+r._trackRoll;if(r.bankedTurn&&-l<r.rotation.z&&r.rotation.z<l){var u=r.bankedTurnMultiplier*-s;n=o.q.RotationAxis(o.c.Z,u),c.multiplyInPlace(n)}}this.buttonsRoll.some(function(e){return e===i.activeButton})&&(n=o.q.RotationAxis(o.c.Z,-s),r._trackRoll-=s,c.multiplyInPlace(n)),c.toEulerAnglesToRef(r.rotation)},l.c([Object(w.c)()],e.prototype,"buttons",void 0),l.c([Object(w.c)()],e.prototype,"angularSensibility",void 0),e}();ze.FlyCameraMouseInput=tt;var it=function(){function e(){this.keysUp=[38],this.keysDown=[40],this.keysLeft=[37],this.keysRight=[39],this._keys=new Array}return e.prototype.attachControl=function(e,t){var i=this;this._onCanvasBlurObserver||(this._scene=this.camera.getScene(),this._engine=this._scene.getEngine(),this._onCanvasBlurObserver=this._engine.onCanvasBlurObservable.add(function(){i._keys=[]}),this._onKeyboardObserver=this._scene.onKeyboardObservable.add(function(e){var r,n=e.event;n.metaKey||(e.type===Ke.a.KEYDOWN?-1===i.keysUp.indexOf(n.keyCode)&&-1===i.keysDown.indexOf(n.keyCode)&&-1===i.keysLeft.indexOf(n.keyCode)&&-1===i.keysRight.indexOf(n.keyCode)||(-1===(r=i._keys.indexOf(n.keyCode))&&i._keys.push(n.keyCode),t||n.preventDefault()):-1===i.keysUp.indexOf(n.keyCode)&&-1===i.keysDown.indexOf(n.keyCode)&&-1===i.keysLeft.indexOf(n.keyCode)&&-1===i.keysRight.indexOf(n.keyCode)||((r=i._keys.indexOf(n.keyCode))>=0&&i._keys.splice(r,1),t||n.preventDefault()))}))},e.prototype.detachControl=function(e){this._scene&&(this._onKeyboardObserver&&this._scene.onKeyboardObservable.remove(this._onKeyboardObserver),this._onCanvasBlurObserver&&this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver),this._onKeyboardObserver=null,this._onCanvasBlurObserver=null),this._keys=[]},e.prototype.checkInputs=function(){if(this._onKeyboardObserver)for(var e=this.camera,t=0;t<this._keys.length;t++){var i=this._keys[t],r=e._computeLocalCameraSpeed();-1!==this.keysLeft.indexOf(i)?e._localDirection.copyFromFloats(-r,0,0):-1!==this.keysUp.indexOf(i)?e._localDirection.copyFromFloats(0,0,r):-1!==this.keysRight.indexOf(i)?e._localDirection.copyFromFloats(r,0,0):-1!==this.keysDown.indexOf(i)&&e._localDirection.copyFromFloats(0,0,-r),e.getScene().useRightHandedSystem&&(e._localDirection.z*=-1),e.getViewMatrix().invertToRef(e._cameraTransformMatrix),o.x.TransformNormalToRef(e._localDirection,e._cameraTransformMatrix,e._transformedDirection),e.cameraDirection.addInPlace(e._transformedDirection)}},e.prototype.getClassName=function(){return"FreeCameraKeyboardMoveInput"},e.prototype._onLostFocus=function(){this._keys=[]},e.prototype.getSimpleName=function(){return"keyboard"},l.c([Object(w.c)()],e.prototype,"keysUp",void 0),l.c([Object(w.c)()],e.prototype,"keysDown",void 0),l.c([Object(w.c)()],e.prototype,"keysLeft",void 0),l.c([Object(w.c)()],e.prototype,"keysRight",void 0),e}();ze.FreeCameraKeyboardMoveInput=it;var rt=function(){function e(e){void 0===e&&(e=!0),this.touchEnabled=e,this.buttons=[0,1,2],this.angularSensibility=2e3,this.previousPosition=null}return e.prototype.attachControl=function(e,t){var i=this,r=this.camera.getEngine();this._pointerInput||(this._pointerInput=function(n){var o=n.event;if(!r.isInVRExclusivePointerMode&&(i.touchEnabled||"touch"!==o.pointerType)&&(n.type===Ae.a.POINTERMOVE||-1!==i.buttons.indexOf(o.button))){var s=o.srcElement||o.target;if(n.type===Ae.a.POINTERDOWN&&s){try{s.setPointerCapture(o.pointerId)}catch(e){}i.previousPosition={x:o.clientX,y:o.clientY},t||(o.preventDefault(),e.focus())}else if(n.type===Ae.a.POINTERUP&&s){try{s.releasePointerCapture(o.pointerId)}catch(e){}i.previousPosition=null,t||o.preventDefault()}else if(n.type===Ae.a.POINTERMOVE){if(!i.previousPosition||r.isPointerLock)return;var a=o.clientX-i.previousPosition.x;i.camera.getScene().useRightHandedSystem&&(a*=-1),i.camera.parent&&i.camera.parent._getWorldMatrixDeterminant()<0&&(a*=-1),i.camera.cameraRotation.y+=a/i.angularSensibility;var c=o.clientY-i.previousPosition.y;i.camera.cameraRotation.x+=c/i.angularSensibility,i.previousPosition={x:o.clientX,y:o.clientY},t||o.preventDefault()}}}),this._onMouseMove=function(e){if(r.isPointerLock&&!r.isInVRExclusivePointerMode){var n=e.movementX||e.mozMovementX||e.webkitMovementX||e.msMovementX||0;i.camera.getScene().useRightHandedSystem&&(n*=-1),i.camera.parent&&i.camera.parent._getWorldMatrixDeterminant()<0&&(n*=-1),i.camera.cameraRotation.y+=n/i.angularSensibility;var o=e.movementY||e.mozMovementY||e.webkitMovementY||e.msMovementY||0;i.camera.cameraRotation.x+=o/i.angularSensibility,i.previousPosition=null,t||e.preventDefault()}},this._observer=this.camera.getScene().onPointerObservable.add(this._pointerInput,Ae.a.POINTERDOWN|Ae.a.POINTERUP|Ae.a.POINTERMOVE),e.addEventListener("mousemove",this._onMouseMove,!1)},e.prototype.detachControl=function(e){this._observer&&e&&(this.camera.getScene().onPointerObservable.remove(this._observer),this._onMouseMove&&e.removeEventListener("mousemove",this._onMouseMove),this._observer=null,this._onMouseMove=null,this.previousPosition=null)},e.prototype.getClassName=function(){return"FreeCameraMouseInput"},e.prototype.getSimpleName=function(){return"mouse"},l.c([Object(w.c)()],e.prototype,"buttons",void 0),l.c([Object(w.c)()],e.prototype,"angularSensibility",void 0),e}();ze.FreeCameraMouseInput=rt;var nt=function(){function e(){this.touchAngularSensibility=2e5,this.touchMoveSensibility=250,this._offsetX=null,this._offsetY=null,this._pointerPressed=new Array}return e.prototype.attachControl=function(e,t){var i=this,r=null;void 0===this._pointerInput&&(this._onLostFocus=function(){i._offsetX=null,i._offsetY=null},this._pointerInput=function(e){var n=e.event;if("mouse"!==n.pointerType)if(e.type===Ae.a.POINTERDOWN){if(t||n.preventDefault(),i._pointerPressed.push(n.pointerId),1!==i._pointerPressed.length)return;r={x:n.clientX,y:n.clientY}}else if(e.type===Ae.a.POINTERUP){if(t||n.preventDefault(),-1===(o=i._pointerPressed.indexOf(n.pointerId)))return;if(i._pointerPressed.splice(o,1),0!=o)return;r=null,i._offsetX=null,i._offsetY=null}else if(e.type===Ae.a.POINTERMOVE){if(t||n.preventDefault(),!r)return;var o;if(0!=(o=i._pointerPressed.indexOf(n.pointerId)))return;i._offsetX=n.clientX-r.x,i._offsetY=-(n.clientY-r.y)}}),this._observer=this.camera.getScene().onPointerObservable.add(this._pointerInput,Ae.a.POINTERDOWN|Ae.a.POINTERUP|Ae.a.POINTERMOVE),this._onLostFocus&&e.addEventListener("blur",this._onLostFocus)},e.prototype.detachControl=function(e){this._pointerInput&&e&&(this._observer&&(this.camera.getScene().onPointerObservable.remove(this._observer),this._observer=null),this._onLostFocus&&(e.removeEventListener("blur",this._onLostFocus),this._onLostFocus=null),this._pointerPressed=[],this._offsetX=null,this._offsetY=null)},e.prototype.checkInputs=function(){if(this._offsetX&&this._offsetY){var e=this.camera;if(e.cameraRotation.y+=this._offsetX/this.touchAngularSensibility,this._pointerPressed.length>1)e.cameraRotation.x+=-this._offsetY/this.touchAngularSensibility;else{var t=e._computeLocalCameraSpeed(),i=new o.x(0,0,t*this._offsetY/this.touchMoveSensibility);o.j.RotationYawPitchRollToRef(e.rotation.y,e.rotation.x,0,e._cameraRotationMatrix),e.cameraDirection.addInPlace(o.x.TransformCoordinates(i,e._cameraRotationMatrix))}}},e.prototype.getClassName=function(){return"FreeCameraTouchInput"},e.prototype.getSimpleName=function(){return"touch"},l.c([Object(w.c)()],e.prototype,"touchAngularSensibility",void 0),l.c([Object(w.c)()],e.prototype,"touchMoveSensibility",void 0),e}();ze.FreeCameraTouchInput=nt;var ot=function(e){function t(t){return e.call(this,t)||this}return l.d(t,e),t.prototype.addKeyboard=function(){return this.add(new it),this},t.prototype.addMouse=function(e){return void 0===e&&(e=!0),this.add(new rt(e)),this},t.prototype.addTouch=function(){return this.add(new nt),this},t}(je);ot.prototype.addDeviceOrientation=function(){return this.add(new st),this};var st=function(){function e(){var e=this;this._screenOrientationAngle=0,this._screenQuaternion=new o.q,this._alpha=0,this._beta=0,this._gamma=0,this._orientationChanged=function(){e._screenOrientationAngle=void 0!==window.orientation?+window.orientation:window.screen.orientation&&window.screen.orientation.angle?window.screen.orientation.angle:0,e._screenOrientationAngle=-ve.h.ToRadians(e._screenOrientationAngle/2),e._screenQuaternion.copyFromFloats(0,Math.sin(e._screenOrientationAngle),0,Math.cos(e._screenOrientationAngle))},this._deviceOrientation=function(t){e._alpha=null!==t.alpha?t.alpha:0,e._beta=null!==t.beta?t.beta:0,e._gamma=null!==t.gamma?t.gamma:0},this._constantTranform=new o.q(-Math.sqrt(.5),0,0,Math.sqrt(.5)),this._orientationChanged()}return Object.defineProperty(e.prototype,"camera",{get:function(){return this._camera},set:function(e){this._camera=e,null==this._camera||this._camera.rotationQuaternion||(this._camera.rotationQuaternion=new o.q)},enumerable:!0,configurable:!0}),e.prototype.attachControl=function(e,t){window.addEventListener("orientationchange",this._orientationChanged),window.addEventListener("deviceorientation",this._deviceOrientation),this._orientationChanged()},e.prototype.detachControl=function(e){window.removeEventListener("orientationchange",this._orientationChanged),window.removeEventListener("deviceorientation",this._deviceOrientation)},e.prototype.checkInputs=function(){this._alpha&&(o.q.RotationYawPitchRollToRef(ve.h.ToRadians(this._alpha),ve.h.ToRadians(this._beta),-ve.h.ToRadians(this._gamma),this.camera.rotationQuaternion),this._camera.rotationQuaternion.multiplyInPlace(this._screenQuaternion),this._camera.rotationQuaternion.multiplyInPlace(this._constantTranform),this._camera.rotationQuaternion.z*=-1,this._camera.rotationQuaternion.w*=-1)},e.prototype.getClassName=function(){return"FreeCameraDeviceOrientationInput"},e.prototype.getSimpleName=function(){return"deviceOrientation"},e}();ze.FreeCameraDeviceOrientationInput=st;var at=function(){function e(){this.gamepadAngularSensibility=200,this.gamepadMoveSensibility=40,this._cameraTransform=o.j.Identity(),this._deltaTransform=o.x.Zero(),this._vector3=o.x.Zero(),this._vector2=o.w.Zero()}return e.prototype.attachControl=function(e,t){var i=this,r=this.camera.getScene().gamepadManager;this._onGamepadConnectedObserver=r.onGamepadConnectedObservable.add(function(e){e.type!==He.POSE_ENABLED&&(i.gamepad&&e.type!==He.XBOX||(i.gamepad=e))}),this._onGamepadDisconnectedObserver=r.onGamepadDisconnectedObservable.add(function(e){i.gamepad===e&&(i.gamepad=null)}),this.gamepad=r.getGamepadByType(He.XBOX)},e.prototype.detachControl=function(e){this.camera.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver),this.camera.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver),this.gamepad=null},e.prototype.checkInputs=function(){if(this.gamepad&&this.gamepad.leftStick){var e=this.camera,t=this.gamepad.leftStick,i=t.x/this.gamepadMoveSensibility,r=t.y/this.gamepadMoveSensibility;t.x=Math.abs(i)>.005?0+i:0,t.y=Math.abs(r)>.005?0+r:0;var n=this.gamepad.rightStick;if(n){var s=n.x/this.gamepadAngularSensibility,a=n.y/this.gamepadAngularSensibility;n.x=Math.abs(s)>.001?0+s:0,n.y=Math.abs(a)>.001?0+a:0}else n={x:0,y:0};e.rotationQuaternion?e.rotationQuaternion.toRotationMatrix(this._cameraTransform):o.j.RotationYawPitchRollToRef(e.rotation.y,e.rotation.x,0,this._cameraTransform);var c=50*e._computeLocalCameraSpeed();this._vector3.copyFromFloats(t.x*c,0,-t.y*c),o.x.TransformCoordinatesToRef(this._vector3,this._cameraTransform,this._deltaTransform),e.cameraDirection.addInPlace(this._deltaTransform),this._vector2.copyFromFloats(n.y,n.x),e.cameraRotation.addInPlace(this._vector2)}},e.prototype.getClassName=function(){return"FreeCameraGamepadInput"},e.prototype.getSimpleName=function(){return"gamepad"},l.c([Object(w.c)()],e.prototype,"gamepadAngularSensibility",void 0),l.c([Object(w.c)()],e.prototype,"gamepadMoveSensibility",void 0),e}();ze.FreeCameraGamepadInput=at;var ct,lt=i(58);!function(e){e[e.X=0]="X",e[e.Y=1]="Y",e[e.Z=2]="Z"}(ct||(ct={}));var ut=function(){function e(t){var i=this;if(this._leftJoystick=!!t,e._globalJoystickIndex++,this._axisTargetedByLeftAndRight=ct.X,this._axisTargetedByUpAndDown=ct.Y,this.reverseLeftRight=!1,this.reverseUpDown=!1,this._touches=new lt.a,this.deltaPosition=o.x.Zero(),this._joystickSensibility=25,this._inversedSensibility=1/(this._joystickSensibility/1e3),this._onResize=function(t){e.vjCanvasWidth=window.innerWidth,e.vjCanvasHeight=window.innerHeight,e.Canvas&&(e.Canvas.width=e.vjCanvasWidth,e.Canvas.height=e.vjCanvasHeight),e.halfWidth=e.vjCanvasWidth/2},!e.Canvas){window.addEventListener("resize",this._onResize,!1),e.Canvas=document.createElement("canvas"),e.vjCanvasWidth=window.innerWidth,e.vjCanvasHeight=window.innerHeight,e.Canvas.width=window.innerWidth,e.Canvas.height=window.innerHeight,e.Canvas.style.width="100%",e.Canvas.style.height="100%",e.Canvas.style.position="absolute",e.Canvas.style.backgroundColor="transparent",e.Canvas.style.top="0px",e.Canvas.style.left="0px",e.Canvas.style.zIndex="5",e.Canvas.style.msTouchAction="none",e.Canvas.setAttribute("touch-action","none");var r=e.Canvas.getContext("2d");if(!r)throw new Error("Unable to create canvas for virtual joystick");e.vjCanvasContext=r,e.vjCanvasContext.strokeStyle="#ffffff",e.vjCanvasContext.lineWidth=2,document.body.appendChild(e.Canvas)}e.halfWidth=e.Canvas.width/2,this.pressed=!1,this._joystickColor="cyan",this._joystickPointerID=-1,this._joystickPointerPos=new o.w(0,0),this._joystickPreviousPointerPos=new o.w(0,0),this._joystickPointerStartPos=new o.w(0,0),this._deltaJoystickVector=new o.w(0,0),this._onPointerDownHandlerRef=function(e){i._onPointerDown(e)},this._onPointerMoveHandlerRef=function(e){i._onPointerMove(e)},this._onPointerUpHandlerRef=function(e){i._onPointerUp(e)},e.Canvas.addEventListener("pointerdown",this._onPointerDownHandlerRef,!1),e.Canvas.addEventListener("pointermove",this._onPointerMoveHandlerRef,!1),e.Canvas.addEventListener("pointerup",this._onPointerUpHandlerRef,!1),e.Canvas.addEventListener("pointerout",this._onPointerUpHandlerRef,!1),e.Canvas.addEventListener("contextmenu",function(e){e.preventDefault()},!1),requestAnimationFrame(function(){i._drawVirtualJoystick()})}return e.prototype.setJoystickSensibility=function(e){this._joystickSensibility=e,this._inversedSensibility=1/(this._joystickSensibility/1e3)},e.prototype._onPointerDown=function(t){t.preventDefault(),(!0===this._leftJoystick?t.clientX<e.halfWidth:t.clientX>e.halfWidth)&&this._joystickPointerID<0?(this._joystickPointerID=t.pointerId,this._joystickPointerStartPos.x=t.clientX,this._joystickPointerStartPos.y=t.clientY,this._joystickPointerPos=this._joystickPointerStartPos.clone(),this._joystickPreviousPointerPos=this._joystickPointerStartPos.clone(),this._deltaJoystickVector.x=0,this._deltaJoystickVector.y=0,this.pressed=!0,this._touches.add(t.pointerId.toString(),t)):e._globalJoystickIndex<2&&this._action&&(this._action(),this._touches.add(t.pointerId.toString(),{x:t.clientX,y:t.clientY,prevX:t.clientX,prevY:t.clientY}))},e.prototype._onPointerMove=function(e){if(this._joystickPointerID==e.pointerId){this._joystickPointerPos.x=e.clientX,this._joystickPointerPos.y=e.clientY,this._deltaJoystickVector=this._joystickPointerPos.clone(),this._deltaJoystickVector=this._deltaJoystickVector.subtract(this._joystickPointerStartPos);var t=(this.reverseLeftRight?-1:1)*this._deltaJoystickVector.x/this._inversedSensibility;switch(this._axisTargetedByLeftAndRight){case ct.X:this.deltaPosition.x=Math.min(1,Math.max(-1,t));break;case ct.Y:this.deltaPosition.y=Math.min(1,Math.max(-1,t));break;case ct.Z:this.deltaPosition.z=Math.min(1,Math.max(-1,t))}var i=(this.reverseUpDown?1:-1)*this._deltaJoystickVector.y/this._inversedSensibility;switch(this._axisTargetedByUpAndDown){case ct.X:this.deltaPosition.x=Math.min(1,Math.max(-1,i));break;case ct.Y:this.deltaPosition.y=Math.min(1,Math.max(-1,i));break;case ct.Z:this.deltaPosition.z=Math.min(1,Math.max(-1,i))}}else{var r=this._touches.get(e.pointerId.toString());r&&(r.x=e.clientX,r.y=e.clientY)}},e.prototype._onPointerUp=function(t){if(this._joystickPointerID==t.pointerId)e.vjCanvasContext.clearRect(this._joystickPointerStartPos.x-64,this._joystickPointerStartPos.y-64,128,128),e.vjCanvasContext.clearRect(this._joystickPreviousPointerPos.x-42,this._joystickPreviousPointerPos.y-42,84,84),this._joystickPointerID=-1,this.pressed=!1;else{var i=this._touches.get(t.pointerId.toString());i&&e.vjCanvasContext.clearRect(i.prevX-44,i.prevY-44,88,88)}this._deltaJoystickVector.x=0,this._deltaJoystickVector.y=0,this._touches.remove(t.pointerId.toString())},e.prototype.setJoystickColor=function(e){this._joystickColor=e},e.prototype.setActionOnTouch=function(e){this._action=e},e.prototype.setAxisForLeftRight=function(e){switch(e){case ct.X:case ct.Y:case ct.Z:this._axisTargetedByLeftAndRight=e;break;default:this._axisTargetedByLeftAndRight=ct.X}},e.prototype.setAxisForUpDown=function(e){switch(e){case ct.X:case ct.Y:case ct.Z:this._axisTargetedByUpAndDown=e;break;default:this._axisTargetedByUpAndDown=ct.Y}},e.prototype._drawVirtualJoystick=function(){var t=this;this.pressed&&this._touches.forEach(function(i,r){r.pointerId===t._joystickPointerID?(e.vjCanvasContext.clearRect(t._joystickPointerStartPos.x-64,t._joystickPointerStartPos.y-64,128,128),e.vjCanvasContext.clearRect(t._joystickPreviousPointerPos.x-42,t._joystickPreviousPointerPos.y-42,84,84),e.vjCanvasContext.beginPath(),e.vjCanvasContext.lineWidth=6,e.vjCanvasContext.strokeStyle=t._joystickColor,e.vjCanvasContext.arc(t._joystickPointerStartPos.x,t._joystickPointerStartPos.y,40,0,2*Math.PI,!0),e.vjCanvasContext.stroke(),e.vjCanvasContext.closePath(),e.vjCanvasContext.beginPath(),e.vjCanvasContext.strokeStyle=t._joystickColor,e.vjCanvasContext.lineWidth=2,e.vjCanvasContext.arc(t._joystickPointerStartPos.x,t._joystickPointerStartPos.y,60,0,2*Math.PI,!0),e.vjCanvasContext.stroke(),e.vjCanvasContext.closePath(),e.vjCanvasContext.beginPath(),e.vjCanvasContext.strokeStyle=t._joystickColor,e.vjCanvasContext.arc(t._joystickPointerPos.x,t._joystickPointerPos.y,40,0,2*Math.PI,!0),e.vjCanvasContext.stroke(),e.vjCanvasContext.closePath(),t._joystickPreviousPointerPos=t._joystickPointerPos.clone()):(e.vjCanvasContext.clearRect(r.prevX-44,r.prevY-44,88,88),e.vjCanvasContext.beginPath(),e.vjCanvasContext.fillStyle="white",e.vjCanvasContext.beginPath(),e.vjCanvasContext.strokeStyle="red",e.vjCanvasContext.lineWidth=6,e.vjCanvasContext.arc(r.x,r.y,40,0,2*Math.PI,!0),e.vjCanvasContext.stroke(),e.vjCanvasContext.closePath(),r.prevX=r.x,r.prevY=r.y)}),requestAnimationFrame(function(){t._drawVirtualJoystick()})},e.prototype.releaseCanvas=function(){e.Canvas&&(e.Canvas.removeEventListener("pointerdown",this._onPointerDownHandlerRef),e.Canvas.removeEventListener("pointermove",this._onPointerMoveHandlerRef),e.Canvas.removeEventListener("pointerup",this._onPointerUpHandlerRef),e.Canvas.removeEventListener("pointerout",this._onPointerUpHandlerRef),window.removeEventListener("resize",this._onResize),document.body.removeChild(e.Canvas),e.Canvas=null)},e._globalJoystickIndex=0,e}();ot.prototype.addVirtualJoystick=function(){return this.add(new ht),this};var ht=function(){function e(){}return e.prototype.getLeftJoystick=function(){return this._leftjoystick},e.prototype.getRightJoystick=function(){return this._rightjoystick},e.prototype.checkInputs=function(){if(this._leftjoystick){var e=this.camera,t=50*e._computeLocalCameraSpeed(),i=o.j.RotationYawPitchRoll(e.rotation.y,e.rotation.x,0),r=o.x.TransformCoordinates(new o.x(this._leftjoystick.deltaPosition.x*t,this._leftjoystick.deltaPosition.y*t,this._leftjoystick.deltaPosition.z*t),i);e.cameraDirection=e.cameraDirection.add(r),e.cameraRotation=e.cameraRotation.addVector3(this._rightjoystick.deltaPosition),this._leftjoystick.pressed||(this._leftjoystick.deltaPosition=this._leftjoystick.deltaPosition.scale(.9)),this._rightjoystick.pressed||(this._rightjoystick.deltaPosition=this._rightjoystick.deltaPosition.scale(.9))}},e.prototype.attachControl=function(e,t){this._leftjoystick=new ut(!0),this._leftjoystick.setAxisForUpDown(ct.Z),this._leftjoystick.setAxisForLeftRight(ct.X),this._leftjoystick.setJoystickSensibility(.15),this._rightjoystick=new ut(!1),this._rightjoystick.setAxisForUpDown(ct.X),this._rightjoystick.setAxisForLeftRight(ct.Y),this._rightjoystick.reverseUpDown=!0,this._rightjoystick.setJoystickSensibility(.05),this._rightjoystick.setJoystickColor("yellow")},e.prototype.detachControl=function(e){this._leftjoystick.releaseCanvas(),this._rightjoystick.releaseCanvas()},e.prototype.getClassName=function(){return"FreeCameraVirtualJoystickInput"},e.prototype.getSimpleName=function(){return"virtualJoystick"},e}();ze.FreeCameraVirtualJoystickInput=ht;var dt=function(e){function t(t,i,r,n){void 0===n&&(n=!0);var s=e.call(this,t,i,r,n)||this;return s.cameraDirection=new o.x(0,0,0),s.cameraRotation=new o.w(0,0),s.updateUpVectorFromRotation=!1,s._tmpQuaternion=new o.q,s.rotation=new o.x(0,0,0),s.speed=2,s.noRotationConstraint=!1,s.lockedTarget=null,s._currentTarget=o.x.Zero(),s._initialFocalDistance=1,s._viewMatrix=o.j.Zero(),s._camMatrix=o.j.Zero(),s._cameraTransformMatrix=o.j.Zero(),s._cameraRotationMatrix=o.j.Zero(),s._referencePoint=new o.x(0,0,1),s._transformedReferencePoint=o.x.Zero(),s._globalCurrentTarget=o.x.Zero(),s._globalCurrentUpVector=o.x.Zero(),s._defaultUp=o.x.Up(),s._cachedRotationZ=0,s._cachedQuaternionRotationZ=0,s}return l.d(t,e),t.prototype.getFrontPosition=function(e){this.getWorldMatrix();var t=this.getTarget().subtract(this.position);return t.normalize(),t.scaleInPlace(e),this.globalPosition.add(t)},t.prototype._getLockedTargetPosition=function(){return this.lockedTarget?(this.lockedTarget.absolutePosition&&this.lockedTarget.computeWorldMatrix(),this.lockedTarget.absolutePosition||this.lockedTarget):null},t.prototype.storeState=function(){return this._storedPosition=this.position.clone(),this._storedRotation=this.rotation.clone(),this.rotationQuaternion&&(this._storedRotationQuaternion=this.rotationQuaternion.clone()),e.prototype.storeState.call(this)},t.prototype._restoreStateValues=function(){return!!e.prototype._restoreStateValues.call(this)&&(this.position=this._storedPosition.clone(),this.rotation=this._storedRotation.clone(),this.rotationQuaternion&&(this.rotationQuaternion=this._storedRotationQuaternion.clone()),this.cameraDirection.copyFromFloats(0,0,0),this.cameraRotation.copyFromFloats(0,0),!0)},t.prototype._initCache=function(){e.prototype._initCache.call(this),this._cache.lockedTarget=new o.x(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.rotation=new o.x(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.rotationQuaternion=new o.q(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE)},t.prototype._updateCache=function(t){t||e.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)},t.prototype._isSynchronizedViewMatrix=function(){if(!e.prototype._isSynchronizedViewMatrix.call(this))return!1;var t=this._getLockedTargetPosition();return(this._cache.lockedTarget?this._cache.lockedTarget.equals(t):!t)&&(this.rotationQuaternion?this.rotationQuaternion.equals(this._cache.rotationQuaternion):this._cache.rotation.equals(this.rotation))},t.prototype._computeLocalCameraSpeed=function(){var e=this.getEngine();return this.speed*Math.sqrt(e.getDeltaTime()/(100*e.getFps()))},t.prototype.setTarget=function(e){this.upVector.normalize(),this._initialFocalDistance=e.subtract(this.position).length(),this.position.z===e.z&&(this.position.z+=o.h),o.j.LookAtLHToRef(this.position,e,this._defaultUp,this._camMatrix),this._camMatrix.invert(),this.rotation.x=Math.atan(this._camMatrix.m[6]/this._camMatrix.m[10]);var t=e.subtract(this.position);t.x>=0?this.rotation.y=-Math.atan(t.z/t.x)+Math.PI/2:this.rotation.y=-Math.atan(t.z/t.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&&o.q.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,this.rotationQuaternion)},t.prototype.getTarget=function(){return this._currentTarget},t.prototype._decideIfNeedsToMove=function(){return Math.abs(this.cameraDirection.x)>0||Math.abs(this.cameraDirection.y)>0||Math.abs(this.cameraDirection.z)>0},t.prototype._updatePosition=function(){if(this.parent)return this.parent.getWorldMatrix().invertToRef(o.t.Matrix[0]),o.x.TransformNormalToRef(this.cameraDirection,o.t.Matrix[0],o.t.Vector3[0]),void this.position.addInPlace(o.t.Vector3[0]);this.position.addInPlace(this.cameraDirection)},t.prototype._checkInputs=function(){var t=this._decideIfNeedsToMove(),i=Math.abs(this.cameraRotation.x)>0||Math.abs(this.cameraRotation.y)>0;if(t&&this._updatePosition(),i){if(this.rotation.x+=this.cameraRotation.x,this.rotation.y+=this.cameraRotation.y,this.rotationQuaternion)this.rotation.lengthSquared()&&o.q.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,this.rotationQuaternion);if(!this.noRotationConstraint){var r=Math.PI/2*.95;this.rotation.x>r&&(this.rotation.x=r),this.rotation.x<-r&&(this.rotation.x=-r)}}t&&(Math.abs(this.cameraDirection.x)<this.speed*o.h&&(this.cameraDirection.x=0),Math.abs(this.cameraDirection.y)<this.speed*o.h&&(this.cameraDirection.y=0),Math.abs(this.cameraDirection.z)<this.speed*o.h&&(this.cameraDirection.z=0),this.cameraDirection.scaleInPlace(this.inertia)),i&&(Math.abs(this.cameraRotation.x)<this.speed*o.h&&(this.cameraRotation.x=0),Math.abs(this.cameraRotation.y)<this.speed*o.h&&(this.cameraRotation.y=0),this.cameraRotation.scaleInPlace(this.inertia)),e.prototype._checkInputs.call(this)},t.prototype._updateCameraRotationMatrix=function(){this.rotationQuaternion?this.rotationQuaternion.toRotationMatrix(this._cameraRotationMatrix):o.j.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,this._cameraRotationMatrix)},t.prototype._rotateUpVectorWithCameraRotationMatrix=function(){return o.x.TransformNormalToRef(this._defaultUp,this._cameraRotationMatrix,this.upVector),this},t.prototype._getViewMatrix=function(){return this.lockedTarget&&this.setTarget(this._getLockedTargetPosition()),this._updateCameraRotationMatrix(),this.rotationQuaternion&&this._cachedQuaternionRotationZ!=this.rotationQuaternion.z?(this._rotateUpVectorWithCameraRotationMatrix(),this._cachedQuaternionRotationZ=this.rotationQuaternion.z):this._cachedRotationZ!=this.rotation.z&&(this._rotateUpVectorWithCameraRotationMatrix(),this._cachedRotationZ=this.rotation.z),o.x.TransformCoordinatesToRef(this._referencePoint,this._cameraRotationMatrix,this._transformedReferencePoint),this.position.addToRef(this._transformedReferencePoint,this._currentTarget),this.updateUpVectorFromRotation&&(this.rotationQuaternion?o.c.Y.rotateByQuaternionToRef(this.rotationQuaternion,this.upVector):(o.q.FromEulerVectorToRef(this.rotation,this._tmpQuaternion),o.c.Y.rotateByQuaternionToRef(this._tmpQuaternion,this.upVector))),this._computeViewMatrix(this.position,this._currentTarget,this.upVector),this._viewMatrix},t.prototype._computeViewMatrix=function(e,t,i){if(this.parent){var r=this.parent.getWorldMatrix();o.x.TransformCoordinatesToRef(e,r,this._globalPosition),o.x.TransformCoordinatesToRef(t,r,this._globalCurrentTarget),o.x.TransformNormalToRef(i,r,this._globalCurrentUpVector),this._markSyncedWithParent()}else this._globalPosition.copyFrom(e),this._globalCurrentTarget.copyFrom(t),this._globalCurrentUpVector.copyFrom(i);this.getScene().useRightHandedSystem?o.j.LookAtRHToRef(this._globalPosition,this._globalCurrentTarget,this._globalCurrentUpVector,this._viewMatrix):o.j.LookAtLHToRef(this._globalPosition,this._globalCurrentTarget,this._globalCurrentUpVector,this._viewMatrix)},t.prototype.createRigCamera=function(e,i){if(this.cameraRigMode!==Le.a.RIG_MODE_NONE){var r=new t(e,this.position.clone(),this.getScene());return this.cameraRigMode!==Le.a.RIG_MODE_VR&&this.cameraRigMode!==Le.a.RIG_MODE_WEBVR||(this.rotationQuaternion||(this.rotationQuaternion=new o.q),r._cameraRigParams={},r.rotationQuaternion=new o.q),r}return null},t.prototype._updateRigCameras=function(){var t=this._rigCameras[0],i=this._rigCameras[1];switch(this.computeWorldMatrix(),this.cameraRigMode){case Le.a.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case Le.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case Le.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:case Le.a.RIG_MODE_STEREOSCOPIC_OVERUNDER:var r=this.cameraRigMode===Le.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED?1:-1,n=this.cameraRigMode===Le.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED?-1:1;this._getRigCamPositionAndTarget(this._cameraRigParams.stereoHalfAngle*r,t),this._getRigCamPositionAndTarget(this._cameraRigParams.stereoHalfAngle*n,i);break;case Le.a.RIG_MODE_VR:t.rotationQuaternion?(t.rotationQuaternion.copyFrom(this.rotationQuaternion),i.rotationQuaternion.copyFrom(this.rotationQuaternion)):(t.rotation.copyFrom(this.rotation),i.rotation.copyFrom(this.rotation)),t.position.copyFrom(this.position),i.position.copyFrom(this.position)}e.prototype._updateRigCameras.call(this)},t.prototype._getRigCamPositionAndTarget=function(e,i){this.getTarget().subtractToRef(this.position,t._TargetFocalPoint),t._TargetFocalPoint.normalize().scaleInPlace(this._initialFocalDistance);var r=t._TargetFocalPoint.addInPlace(this.position);o.j.TranslationToRef(-r.x,-r.y,-r.z,t._TargetTransformMatrix),t._TargetTransformMatrix.multiplyToRef(o.j.RotationY(e),t._RigCamTransformMatrix),o.j.TranslationToRef(r.x,r.y,r.z,t._TargetTransformMatrix),t._RigCamTransformMatrix.multiplyToRef(t._TargetTransformMatrix,t._RigCamTransformMatrix),o.x.TransformCoordinatesToRef(this.position,t._RigCamTransformMatrix,i.position),i.setTarget(r)},t.prototype.getClassName=function(){return"TargetCamera"},t._RigCamTransformMatrix=new o.j,t._TargetTransformMatrix=new o.j,t._TargetFocalPoint=new o.x,l.c([Object(w.n)()],t.prototype,"rotation",void 0),l.c([Object(w.c)()],t.prototype,"speed",void 0),l.c([Object(w.j)("lockedTargetId")],t.prototype,"lockedTarget",void 0),t}(Le.a),ft=function(e){function t(t,i,r,n){void 0===n&&(n=!0);var s=e.call(this,t,i,r,n)||this;return s.ellipsoid=new o.x(.5,1,.5),s.ellipsoidOffset=new o.x(0,0,0),s.checkCollisions=!1,s.applyGravity=!1,s._needMoveForGravity=!1,s._oldPosition=o.x.Zero(),s._diffPosition=o.x.Zero(),s._newPosition=o.x.Zero(),s._collisionMask=-1,s._onCollisionPositionChange=function(e,t,i){void 0===i&&(i=null);var r;r=t,s._newPosition.copyFrom(r),s._newPosition.subtractToRef(s._oldPosition,s._diffPosition),s._diffPosition.length()>_e.b.CollisionsEpsilon&&(s.position.addInPlace(s._diffPosition),s.onCollide&&i&&s.onCollide(i))},s.inputs=new ot(s),s.inputs.addKeyboard().addMouse(),s}return l.d(t,e),Object.defineProperty(t.prototype,"angularSensibility",{get:function(){var e=this.inputs.attached.mouse;return e?e.angularSensibility:0},set:function(e){var t=this.inputs.attached.mouse;t&&(t.angularSensibility=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"keysUp",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysUp:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysUp=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"keysDown",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysDown:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysDown=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"keysLeft",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysLeft:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysLeft=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"keysRight",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysRight:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysRight=e)},enumerable:!0,configurable:!0}),t.prototype.attachControl=function(e,t){this.inputs.attachElement(e,t)},t.prototype.detachControl=function(e){this.inputs.detachElement(e),this.cameraDirection=new o.x(0,0,0),this.cameraRotation=new o.w(0,0)},Object.defineProperty(t.prototype,"collisionMask",{get:function(){return this._collisionMask},set:function(e){this._collisionMask=isNaN(e)?-1:e},enumerable:!0,configurable:!0}),t.prototype._collideWithWorld=function(e){(this.parent?o.x.TransformCoordinates(this.position,this.parent.getWorldMatrix()):this.position).subtractFromFloatsToRef(0,this.ellipsoid.y,0,this._oldPosition),this._oldPosition.addInPlace(this.ellipsoidOffset);var t=this.getScene().collisionCoordinator;this._collider||(this._collider=t.createCollider()),this._collider._radius=this.ellipsoid,this._collider.collisionMask=this._collisionMask;var i=e;this.applyGravity&&(i=e.add(this.getScene().gravity)),t.getNewPosition(this._oldPosition,i,this._collider,3,null,this._onCollisionPositionChange,this.uniqueId)},t.prototype._checkInputs=function(){this._localDirection||(this._localDirection=o.x.Zero(),this._transformedDirection=o.x.Zero()),this.inputs.checkInputs(),e.prototype._checkInputs.call(this)},t.prototype._decideIfNeedsToMove=function(){return this._needMoveForGravity||Math.abs(this.cameraDirection.x)>0||Math.abs(this.cameraDirection.y)>0||Math.abs(this.cameraDirection.z)>0},t.prototype._updatePosition=function(){this.checkCollisions&&this.getScene().collisionsEnabled?this._collideWithWorld(this.cameraDirection):e.prototype._updatePosition.call(this)},t.prototype.dispose=function(){this.inputs.clear(),e.prototype.dispose.call(this)},t.prototype.getClassName=function(){return"FreeCamera"},l.c([Object(w.n)()],t.prototype,"ellipsoid",void 0),l.c([Object(w.n)()],t.prototype,"ellipsoidOffset",void 0),l.c([Object(w.c)()],t.prototype,"checkCollisions",void 0),l.c([Object(w.c)()],t.prototype,"applyGravity",void 0),t}(dt);F.a.AddNodeConstructor("TouchCamera",function(e,t){return function(){return new pt(e,o.x.Zero(),t)}});var pt=function(e){function t(t,i,r){var n=e.call(this,t,i,r)||this;return n.inputs.addTouch(),n._setupInputs(),n}return l.d(t,e),Object.defineProperty(t.prototype,"touchAngularSensibility",{get:function(){var e=this.inputs.attached.touch;return e?e.touchAngularSensibility:0},set:function(e){var t=this.inputs.attached.touch;t&&(t.touchAngularSensibility=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"touchMoveSensibility",{get:function(){var e=this.inputs.attached.touch;return e?e.touchMoveSensibility:0},set:function(e){var t=this.inputs.attached.touch;t&&(t.touchMoveSensibility=e)},enumerable:!0,configurable:!0}),t.prototype.getClassName=function(){return"TouchCamera"},t.prototype._setupInputs=function(){var e=this.inputs.attached.mouse;e&&(e.touchEnabled=!1)},t}(ft);F.a.AddNodeConstructor("ArcRotateCamera",function(e,t){return function(){return new _t(e,0,0,1,o.x.Zero(),t)}});var _t=function(e){function t(t,i,r,s,a,c,l){void 0===l&&(l=!0);var u=e.call(this,t,o.x.Zero(),c,l)||this;return u.inertialAlphaOffset=0,u.inertialBetaOffset=0,u.inertialRadiusOffset=0,u.lowerAlphaLimit=null,u.upperAlphaLimit=null,u.lowerBetaLimit=.01,u.upperBetaLimit=Math.PI-.01,u.lowerRadiusLimit=null,u.upperRadiusLimit=null,u.inertialPanningX=0,u.inertialPanningY=0,u.pinchToPanMaxDistance=20,u.panningDistanceLimit=null,u.panningOriginTarget=o.x.Zero(),u.panningInertia=.9,u.zoomOnFactor=1,u.targetScreenOffset=o.w.Zero(),u.allowUpsideDown=!0,u.useInputToRestoreState=!0,u._viewMatrix=new o.j,u.panningAxis=new o.x(1,1,0),u.onMeshTargetChangedObservable=new n.c,u.checkCollisions=!1,u.collisionRadius=new o.x(.5,.5,.5),u._previousPosition=o.x.Zero(),u._collisionVelocity=o.x.Zero(),u._newPosition=o.x.Zero(),u._computationVector=o.x.Zero(),u._onCollisionPositionChange=function(e,t,i){void 0===i&&(i=null),i?(u.setPosition(t),u.onCollide&&u.onCollide(i)):u._previousPosition.copyFrom(u.position);var r=Math.cos(u.alpha),n=Math.sin(u.alpha),o=Math.cos(u.beta),s=Math.sin(u.beta);0===s&&(s=1e-4);var a=u._getTargetPosition();u._computationVector.copyFromFloats(u.radius*r*s,u.radius*o,u.radius*n*s),a.addToRef(u._computationVector,u._newPosition),u.position.copyFrom(u._newPosition);var c=u.upVector;u.allowUpsideDown&&u.beta<0&&(c=(c=c.clone()).negate()),u._computeViewMatrix(u.position,a,c),u._viewMatrix.addAtIndex(12,u.targetScreenOffset.x),u._viewMatrix.addAtIndex(13,u.targetScreenOffset.y),u._collisionTriggered=!1},u._target=o.x.Zero(),a&&u.setTarget(a),u.alpha=i,u.beta=r,u.radius=s,u.getViewMatrix(),u.inputs=new Je(u),u.inputs.addKeyboard().addMouseWheel().addPointers(),u}return l.d(t,e),Object.defineProperty(t.prototype,"target",{get:function(){return this._target},set:function(e){this.setTarget(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"angularSensibilityX",{get:function(){var e=this.inputs.attached.pointers;return e?e.angularSensibilityX:0},set:function(e){var t=this.inputs.attached.pointers;t&&(t.angularSensibilityX=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"angularSensibilityY",{get:function(){var e=this.inputs.attached.pointers;return e?e.angularSensibilityY:0},set:function(e){var t=this.inputs.attached.pointers;t&&(t.angularSensibilityY=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"pinchPrecision",{get:function(){var e=this.inputs.attached.pointers;return e?e.pinchPrecision:0},set:function(e){var t=this.inputs.attached.pointers;t&&(t.pinchPrecision=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"pinchDeltaPercentage",{get:function(){var e=this.inputs.attached.pointers;return e?e.pinchDeltaPercentage:0},set:function(e){var t=this.inputs.attached.pointers;t&&(t.pinchDeltaPercentage=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"panningSensibility",{get:function(){var e=this.inputs.attached.pointers;return e?e.panningSensibility:0},set:function(e){var t=this.inputs.attached.pointers;t&&(t.panningSensibility=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"keysUp",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysUp:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysUp=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"keysDown",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysDown:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysDown=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"keysLeft",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysLeft:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysLeft=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"keysRight",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysRight:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysRight=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"wheelPrecision",{get:function(){var e=this.inputs.attached.mousewheel;return e?e.wheelPrecision:0},set:function(e){var t=this.inputs.attached.mousewheel;t&&(t.wheelPrecision=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"wheelDeltaPercentage",{get:function(){var e=this.inputs.attached.mousewheel;return e?e.wheelDeltaPercentage:0},set:function(e){var t=this.inputs.attached.mousewheel;t&&(t.wheelDeltaPercentage=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"bouncingBehavior",{get:function(){return this._bouncingBehavior},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useBouncingBehavior",{get:function(){return null!=this._bouncingBehavior},set:function(e){e!==this.useBouncingBehavior&&(e?(this._bouncingBehavior=new Re,this.addBehavior(this._bouncingBehavior)):this._bouncingBehavior&&(this.removeBehavior(this._bouncingBehavior),this._bouncingBehavior=null))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"framingBehavior",{get:function(){return this._framingBehavior},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useFramingBehavior",{get:function(){return null!=this._framingBehavior},set:function(e){e!==this.useFramingBehavior&&(e?(this._framingBehavior=new Se,this.addBehavior(this._framingBehavior)):this._framingBehavior&&(this.removeBehavior(this._framingBehavior),this._framingBehavior=null))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"autoRotationBehavior",{get:function(){return this._autoRotationBehavior},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useAutoRotationBehavior",{get:function(){return null!=this._autoRotationBehavior},set:function(e){e!==this.useAutoRotationBehavior&&(e?(this._autoRotationBehavior=new Pe,this.addBehavior(this._autoRotationBehavior)):this._autoRotationBehavior&&(this.removeBehavior(this._autoRotationBehavior),this._autoRotationBehavior=null))},enumerable:!0,configurable:!0}),t.prototype._initCache=function(){e.prototype._initCache.call(this),this._cache._target=new o.x(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=o.w.Zero()},t.prototype._updateCache=function(t){t||e.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)},t.prototype._getTargetPosition=function(){if(this._targetHost&&this._targetHost.getAbsolutePosition){var e=this._targetHost.absolutePosition;this._targetBoundingCenter?e.addToRef(this._targetBoundingCenter,this._target):this._target.copyFrom(e)}var t=this._getLockedTargetPosition();return t||this._target},t.prototype.storeState=function(){return this._storedAlpha=this.alpha,this._storedBeta=this.beta,this._storedRadius=this.radius,this._storedTarget=this._getTargetPosition().clone(),e.prototype.storeState.call(this)},t.prototype._restoreStateValues=function(){return!!e.prototype._restoreStateValues.call(this)&&(this.alpha=this._storedAlpha,this.beta=this._storedBeta,this.radius=this._storedRadius,this.setTarget(this._storedTarget.clone()),this.inertialAlphaOffset=0,this.inertialBetaOffset=0,this.inertialRadiusOffset=0,this.inertialPanningX=0,this.inertialPanningY=0,!0)},t.prototype._isSynchronizedViewMatrix=function(){return!!e.prototype._isSynchronizedViewMatrix.call(this)&&(this._cache._target.equals(this._getTargetPosition())&&this._cache.alpha===this.alpha&&this._cache.beta===this.beta&&this._cache.radius===this.radius&&this._cache.targetScreenOffset.equals(this.targetScreenOffset))},t.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,n.inertialPanningX=0,n.inertialPanningY=0}},t.prototype.detachControl=function(e){this.inputs.detachElement(e),this._reset&&this._reset()},t.prototype._checkInputs=function(){if(!this._collisionTriggered){if(this.inputs.checkInputs(),0!==this.inertialAlphaOffset||0!==this.inertialBetaOffset||0!==this.inertialRadiusOffset){var t=this.inertialAlphaOffset;this.beta<=0&&(t*=-1),this.getScene().useRightHandedSystem&&(t*=-1),this.parent&&this.parent._getWorldMatrixDeterminant()<0&&(t*=-1),this.alpha+=t,this.beta+=this.inertialBetaOffset,this.radius-=this.inertialRadiusOffset,this.inertialAlphaOffset*=this.inertia,this.inertialBetaOffset*=this.inertia,this.inertialRadiusOffset*=this.inertia,Math.abs(this.inertialAlphaOffset)<o.h&&(this.inertialAlphaOffset=0),Math.abs(this.inertialBetaOffset)<o.h&&(this.inertialBetaOffset=0),Math.abs(this.inertialRadiusOffset)<this.speed*o.h&&(this.inertialRadiusOffset=0)}if(0!==this.inertialPanningX||0!==this.inertialPanningY){if(this._localDirection||(this._localDirection=o.x.Zero(),this._transformedDirection=o.x.Zero()),this._localDirection.copyFromFloats(this.inertialPanningX,this.inertialPanningY,this.inertialPanningY),this._localDirection.multiplyInPlace(this.panningAxis),this._viewMatrix.invertToRef(this._cameraTransformMatrix),o.x.TransformNormalToRef(this._localDirection,this._cameraTransformMatrix,this._transformedDirection),this.panningAxis.y||(this._transformedDirection.y=0),!this._targetHost)if(this.panningDistanceLimit)this._transformedDirection.addInPlace(this._target),o.x.DistanceSquared(this._transformedDirection,this.panningOriginTarget)<=this.panningDistanceLimit*this.panningDistanceLimit&&this._target.copyFrom(this._transformedDirection);else this._target.addInPlace(this._transformedDirection);this.inertialPanningX*=this.panningInertia,this.inertialPanningY*=this.panningInertia,Math.abs(this.inertialPanningX)<this.speed*o.h&&(this.inertialPanningX=0),Math.abs(this.inertialPanningY)<this.speed*o.h&&(this.inertialPanningY=0)}this._checkLimits(),e.prototype._checkInputs.call(this)}},t.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),null!==this.lowerAlphaLimit&&this.alpha<this.lowerAlphaLimit&&(this.alpha=this.lowerAlphaLimit),null!==this.upperAlphaLimit&&this.alpha>this.upperAlphaLimit&&(this.alpha=this.upperAlphaLimit),null!==this.lowerRadiusLimit&&this.radius<this.lowerRadiusLimit&&(this.radius=this.lowerRadiusLimit,this.inertialRadiusOffset=0),null!==this.upperRadiusLimit&&this.radius>this.upperRadiusLimit&&(this.radius=this.upperRadiusLimit,this.inertialRadiusOffset=0)},t.prototype.rebuildAnglesAndRadius=function(){this.position.subtractToRef(this._getTargetPosition(),this._computationVector),this.radius=this._computationVector.length(),0===this.radius&&(this.radius=1e-4),this.alpha=Math.acos(this._computationVector.x/Math.sqrt(Math.pow(this._computationVector.x,2)+Math.pow(this._computationVector.z,2))),this._computationVector.z<0&&(this.alpha=2*Math.PI-this.alpha),this.beta=Math.acos(this._computationVector.y/this.radius),this._checkLimits()},t.prototype.setPosition=function(e){this.position.equals(e)||(this.position.copyFrom(e),this.rebuildAnglesAndRadius())},t.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(),this.onMeshTargetChangedObservable.notifyObservers(this._targetHost);else{var r=e,n=this._getTargetPosition();if(n&&!i&&n.equals(r))return;this._targetHost=null,this._target=r,this._targetBoundingCenter=null,this.onMeshTargetChangedObservable.notifyObservers(null)}this.rebuildAnglesAndRadius()},t.prototype._getViewMatrix=function(){var e=Math.cos(this.alpha),t=Math.sin(this.alpha),i=Math.cos(this.beta),r=Math.sin(this.beta);0===r&&(r=1e-4);var n=this._getTargetPosition();if(this._computationVector.copyFromFloats(this.radius*e*r,this.radius*i,this.radius*t*r),0!==this.upVector.x||1!==this.upVector.y||0!==this.upVector.z){this._tempAxisVector||(this._tempAxisVector=new o.x,this._tempAxisRotationMatrix=new o.j),o.x.CrossToRef(o.x.Up(),this.upVector,this._tempAxisVector),this._tempAxisVector.normalize();var s=Math.acos(o.x.Dot(o.x.UpReadOnly,this.upVector));o.j.RotationAxisToRef(this._tempAxisVector,s,this._tempAxisRotationMatrix),this._tempAxisVector.copyFrom(this._computationVector),o.x.TransformCoordinatesToRef(this._tempAxisVector,this._tempAxisRotationMatrix,this._computationVector)}if(n.addToRef(this._computationVector,this._newPosition),this.getScene().collisionsEnabled&&this.checkCollisions){var a=this.getScene().collisionCoordinator;this._collider||(this._collider=a.createCollider()),this._collider._radius=this.collisionRadius,this._newPosition.subtractToRef(this.position,this._collisionVelocity),this._collisionTriggered=!0,a.getNewPosition(this.position,this._collisionVelocity,this._collider,3,null,this._onCollisionPositionChange,this.uniqueId)}else{this.position.copyFrom(this._newPosition);var c=this.upVector;this.allowUpsideDown&&r<0&&(c=(c=c.clone()).negate()),this._computeViewMatrix(this.position,n,c),this._viewMatrix.addAtIndex(12,this.targetScreenOffset.x),this._viewMatrix.addAtIndex(13,this.targetScreenOffset.y)}return this._currentTarget=n,this._viewMatrix},t.prototype.zoomOn=function(e,t){void 0===t&&(t=!1),e=e||this.getScene().meshes;var i=de.a.MinMax(e),r=o.x.Distance(i.min,i.max);this.radius=r*this.zoomOnFactor,this.focusOn({min:i.min,max:i.max,distance:r},t)},t.prototype.focusOn=function(e,t){var i,r;if(void 0===t&&(t=!1),void 0===e.min){var n=e||this.getScene().meshes;i=de.a.MinMax(n),r=o.x.Distance(i.min,i.max)}else{i=e,r=e.distance}this._target=de.a.Center(i),t||(this.maxZ=2*r)},t.prototype.createRigCamera=function(e,i){var r=0;switch(this.cameraRigMode){case Le.a.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case Le.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case Le.a.RIG_MODE_STEREOSCOPIC_OVERUNDER:case Le.a.RIG_MODE_VR:r=this._cameraRigParams.stereoHalfAngle*(0===i?1:-1);break;case Le.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:r=this._cameraRigParams.stereoHalfAngle*(0===i?-1:1)}var n=new t(e,this.alpha+r,this.beta,this.radius,this._target,this.getScene());return n._cameraRigParams={},n},t.prototype._updateRigCameras=function(){var t=this._rigCameras[0],i=this._rigCameras[1];switch(t.beta=i.beta=this.beta,this.cameraRigMode){case Le.a.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case Le.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case Le.a.RIG_MODE_STEREOSCOPIC_OVERUNDER:case Le.a.RIG_MODE_VR:t.alpha=this.alpha-this._cameraRigParams.stereoHalfAngle,i.alpha=this.alpha+this._cameraRigParams.stereoHalfAngle;break;case Le.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:t.alpha=this.alpha+this._cameraRigParams.stereoHalfAngle,i.alpha=this.alpha-this._cameraRigParams.stereoHalfAngle}e.prototype._updateRigCameras.call(this)},t.prototype.dispose=function(){this.inputs.clear(),e.prototype.dispose.call(this)},t.prototype.getClassName=function(){return"ArcRotateCamera"},l.c([Object(w.c)()],t.prototype,"alpha",void 0),l.c([Object(w.c)()],t.prototype,"beta",void 0),l.c([Object(w.c)()],t.prototype,"radius",void 0),l.c([Object(w.n)("target")],t.prototype,"_target",void 0),l.c([Object(w.c)()],t.prototype,"inertialAlphaOffset",void 0),l.c([Object(w.c)()],t.prototype,"inertialBetaOffset",void 0),l.c([Object(w.c)()],t.prototype,"inertialRadiusOffset",void 0),l.c([Object(w.c)()],t.prototype,"lowerAlphaLimit",void 0),l.c([Object(w.c)()],t.prototype,"upperAlphaLimit",void 0),l.c([Object(w.c)()],t.prototype,"lowerBetaLimit",void 0),l.c([Object(w.c)()],t.prototype,"upperBetaLimit",void 0),l.c([Object(w.c)()],t.prototype,"lowerRadiusLimit",void 0),l.c([Object(w.c)()],t.prototype,"upperRadiusLimit",void 0),l.c([Object(w.c)()],t.prototype,"inertialPanningX",void 0),l.c([Object(w.c)()],t.prototype,"inertialPanningY",void 0),l.c([Object(w.c)()],t.prototype,"pinchToPanMaxDistance",void 0),l.c([Object(w.c)()],t.prototype,"panningDistanceLimit",void 0),l.c([Object(w.n)()],t.prototype,"panningOriginTarget",void 0),l.c([Object(w.c)()],t.prototype,"panningInertia",void 0),l.c([Object(w.c)()],t.prototype,"zoomOnFactor",void 0),l.c([Object(w.c)()],t.prototype,"targetScreenOffset",void 0),l.c([Object(w.c)()],t.prototype,"allowUpsideDown",void 0),l.c([Object(w.c)()],t.prototype,"useInputToRestoreState",void 0),t}(dt);F.a.AddNodeConstructor("DeviceOrientationCamera",function(e,t){return function(){return new gt(e,o.x.Zero(),t)}});var gt=function(e){function t(t,i,r){var n=e.call(this,t,i,r)||this;return n._quaternionCache=new o.q,n.inputs.addDeviceOrientation(),n}return l.d(t,e),t.prototype.getClassName=function(){return"DeviceOrientationCamera"},t.prototype._checkInputs=function(){e.prototype._checkInputs.call(this),this._quaternionCache.copyFrom(this.rotationQuaternion),this._initialQuaternion&&this._initialQuaternion.multiplyToRef(this.rotationQuaternion,this.rotationQuaternion)},t.prototype.resetToCurrentRotation=function(e){var t=this;void 0===e&&(e=o.c.Y),this.rotationQuaternion&&(this._initialQuaternion||(this._initialQuaternion=new o.q),this._initialQuaternion.copyFrom(this._quaternionCache||this.rotationQuaternion),["x","y","z"].forEach(function(i){e[i]?t._initialQuaternion[i]*=-1:t._initialQuaternion[i]=0}),this._initialQuaternion.normalize(),this._initialQuaternion.multiplyToRef(this.rotationQuaternion,this.rotationQuaternion))},t}(ft),mt=function(e){function t(t){return e.call(this,t)||this}return l.d(t,e),t.prototype.addKeyboard=function(){return this.add(new et),this},t.prototype.addMouse=function(e){return void 0===e&&(e=!0),this.add(new tt(e)),this},t}(je),vt=function(e){function t(t,i,r,n){void 0===n&&(n=!0);var s=e.call(this,t,i,r,n)||this;return s.ellipsoid=new o.x(1,1,1),s.ellipsoidOffset=new o.x(0,0,0),s.checkCollisions=!1,s.applyGravity=!1,s.cameraDirection=o.x.Zero(),s._trackRoll=0,s.rollCorrect=100,s.bankedTurn=!1,s.bankedTurnLimit=Math.PI/2,s.bankedTurnMultiplier=1,s._needMoveForGravity=!1,s._oldPosition=o.x.Zero(),s._diffPosition=o.x.Zero(),s._newPosition=o.x.Zero(),s._collisionMask=-1,s._onCollisionPositionChange=function(e,t,i){void 0===i&&(i=null);var r;r=t,s._newPosition.copyFrom(r),s._newPosition.subtractToRef(s._oldPosition,s._diffPosition),s._diffPosition.length()>_e.b.CollisionsEpsilon&&(s.position.addInPlace(s._diffPosition),s.onCollide&&i&&s.onCollide(i))},s.inputs=new mt(s),s.inputs.addKeyboard().addMouse(),s}return l.d(t,e),Object.defineProperty(t.prototype,"angularSensibility",{get:function(){var e=this.inputs.attached.mouse;return e?e.angularSensibility:0},set:function(e){var t=this.inputs.attached.mouse;t&&(t.angularSensibility=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"keysForward",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysForward:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysForward=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"keysBackward",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysBackward:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysBackward=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"keysUp",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysUp:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysUp=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"keysDown",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysDown:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysDown=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"keysLeft",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysLeft:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysLeft=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"keysRight",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysRight:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysRight=e)},enumerable:!0,configurable:!0}),t.prototype.attachControl=function(e,t){this.inputs.attachElement(e,t)},t.prototype.detachControl=function(e){this.inputs.detachElement(e),this.cameraDirection=new o.x(0,0,0)},Object.defineProperty(t.prototype,"collisionMask",{get:function(){return this._collisionMask},set:function(e){this._collisionMask=isNaN(e)?-1:e},enumerable:!0,configurable:!0}),t.prototype._collideWithWorld=function(e){(this.parent?o.x.TransformCoordinates(this.position,this.parent.getWorldMatrix()):this.position).subtractFromFloatsToRef(0,this.ellipsoid.y,0,this._oldPosition),this._oldPosition.addInPlace(this.ellipsoidOffset);var t=this.getScene().collisionCoordinator;this._collider||(this._collider=t.createCollider()),this._collider._radius=this.ellipsoid,this._collider.collisionMask=this._collisionMask;var i=e;this.applyGravity&&(i=e.add(this.getScene().gravity)),t.getNewPosition(this._oldPosition,i,this._collider,3,null,this._onCollisionPositionChange,this.uniqueId)},t.prototype._checkInputs=function(){this._localDirection||(this._localDirection=o.x.Zero(),this._transformedDirection=o.x.Zero()),this.inputs.checkInputs(),e.prototype._checkInputs.call(this)},t.prototype._decideIfNeedsToMove=function(){return this._needMoveForGravity||Math.abs(this.cameraDirection.x)>0||Math.abs(this.cameraDirection.y)>0||Math.abs(this.cameraDirection.z)>0},t.prototype._updatePosition=function(){this.checkCollisions&&this.getScene().collisionsEnabled?this._collideWithWorld(this.cameraDirection):e.prototype._updatePosition.call(this)},t.prototype.restoreRoll=function(e){var t=this._trackRoll,i=t-this.rotation.z;Math.abs(i)>=.001&&(this.rotation.z+=i/e,Math.abs(t-this.rotation.z)<=.001&&(this.rotation.z=t))},t.prototype.dispose=function(){this.inputs.clear(),e.prototype.dispose.call(this)},t.prototype.getClassName=function(){return"FlyCamera"},l.c([Object(w.n)()],t.prototype,"ellipsoid",void 0),l.c([Object(w.n)()],t.prototype,"ellipsoidOffset",void 0),l.c([Object(w.c)()],t.prototype,"checkCollisions",void 0),l.c([Object(w.c)()],t.prototype,"applyGravity",void 0),t}(dt),yt=function(){function e(){this.keysHeightOffsetIncr=[38],this.keysHeightOffsetDecr=[40],this.keysHeightOffsetModifierAlt=!1,this.keysHeightOffsetModifierCtrl=!1,this.keysHeightOffsetModifierShift=!1,this.keysRotationOffsetIncr=[37],this.keysRotationOffsetDecr=[39],this.keysRotationOffsetModifierAlt=!1,this.keysRotationOffsetModifierCtrl=!1,this.keysRotationOffsetModifierShift=!1,this.keysRadiusIncr=[40],this.keysRadiusDecr=[38],this.keysRadiusModifierAlt=!0,this.keysRadiusModifierCtrl=!1,this.keysRadiusModifierShift=!1,this.heightSensibility=1,this.rotationSensibility=1,this.radiusSensibility=1,this._keys=new Array}return e.prototype.attachControl=function(e,t){var i=this;this._onCanvasBlurObserver||(this._scene=this.camera.getScene(),this._engine=this._scene.getEngine(),this._onCanvasBlurObserver=this._engine.onCanvasBlurObservable.add(function(){i._keys=[]}),this._onKeyboardObserver=this._scene.onKeyboardObservable.add(function(e){var r,n=e.event;n.metaKey||(e.type===Ke.a.KEYDOWN?(i._ctrlPressed=n.ctrlKey,i._altPressed=n.altKey,i._shiftPressed=n.shiftKey,(-1!==i.keysHeightOffsetIncr.indexOf(n.keyCode)||-1!==i.keysHeightOffsetDecr.indexOf(n.keyCode)||-1!==i.keysRotationOffsetIncr.indexOf(n.keyCode)||-1!==i.keysRotationOffsetDecr.indexOf(n.keyCode)||-1!==i.keysRadiusIncr.indexOf(n.keyCode)||-1!==i.keysRadiusDecr.indexOf(n.keyCode))&&(-1===(r=i._keys.indexOf(n.keyCode))&&i._keys.push(n.keyCode),n.preventDefault&&(t||n.preventDefault()))):-1===i.keysHeightOffsetIncr.indexOf(n.keyCode)&&-1===i.keysHeightOffsetDecr.indexOf(n.keyCode)&&-1===i.keysRotationOffsetIncr.indexOf(n.keyCode)&&-1===i.keysRotationOffsetDecr.indexOf(n.keyCode)&&-1===i.keysRadiusIncr.indexOf(n.keyCode)&&-1===i.keysRadiusDecr.indexOf(n.keyCode)||((r=i._keys.indexOf(n.keyCode))>=0&&i._keys.splice(r,1),n.preventDefault&&(t||n.preventDefault())))}))},e.prototype.detachControl=function(e){this._scene&&(this._onKeyboardObserver&&this._scene.onKeyboardObservable.remove(this._onKeyboardObserver),this._onCanvasBlurObserver&&this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver),this._onKeyboardObserver=null,this._onCanvasBlurObserver=null),this._keys=[]},e.prototype.checkInputs=function(){var e=this;this._onKeyboardObserver&&this._keys.forEach(function(t){-1!==e.keysHeightOffsetIncr.indexOf(t)&&e._modifierHeightOffset()?e.camera.heightOffset+=e.heightSensibility:-1!==e.keysHeightOffsetDecr.indexOf(t)&&e._modifierHeightOffset()?e.camera.heightOffset-=e.heightSensibility:-1!==e.keysRotationOffsetIncr.indexOf(t)&&e._modifierRotationOffset()?(e.camera.rotationOffset+=e.rotationSensibility,e.camera.rotationOffset%=360):-1!==e.keysRotationOffsetDecr.indexOf(t)&&e._modifierRotationOffset()?(e.camera.rotationOffset-=e.rotationSensibility,e.camera.rotationOffset%=360):-1!==e.keysRadiusIncr.indexOf(t)&&e._modifierRadius()?e.camera.radius+=e.radiusSensibility:-1!==e.keysRadiusDecr.indexOf(t)&&e._modifierRadius()&&(e.camera.radius-=e.radiusSensibility)})},e.prototype.getClassName=function(){return"FollowCameraKeyboardMoveInput"},e.prototype.getSimpleName=function(){return"keyboard"},e.prototype._modifierHeightOffset=function(){return this.keysHeightOffsetModifierAlt===this._altPressed&&this.keysHeightOffsetModifierCtrl===this._ctrlPressed&&this.keysHeightOffsetModifierShift===this._shiftPressed},e.prototype._modifierRotationOffset=function(){return this.keysRotationOffsetModifierAlt===this._altPressed&&this.keysRotationOffsetModifierCtrl===this._ctrlPressed&&this.keysRotationOffsetModifierShift===this._shiftPressed},e.prototype._modifierRadius=function(){return this.keysRadiusModifierAlt===this._altPressed&&this.keysRadiusModifierCtrl===this._ctrlPressed&&this.keysRadiusModifierShift===this._shiftPressed},l.c([Object(w.c)()],e.prototype,"keysHeightOffsetIncr",void 0),l.c([Object(w.c)()],e.prototype,"keysHeightOffsetDecr",void 0),l.c([Object(w.c)()],e.prototype,"keysHeightOffsetModifierAlt",void 0),l.c([Object(w.c)()],e.prototype,"keysHeightOffsetModifierCtrl",void 0),l.c([Object(w.c)()],e.prototype,"keysHeightOffsetModifierShift",void 0),l.c([Object(w.c)()],e.prototype,"keysRotationOffsetIncr",void 0),l.c([Object(w.c)()],e.prototype,"keysRotationOffsetDecr",void 0),l.c([Object(w.c)()],e.prototype,"keysRotationOffsetModifierAlt",void 0),l.c([Object(w.c)()],e.prototype,"keysRotationOffsetModifierCtrl",void 0),l.c([Object(w.c)()],e.prototype,"keysRotationOffsetModifierShift",void 0),l.c([Object(w.c)()],e.prototype,"keysRadiusIncr",void 0),l.c([Object(w.c)()],e.prototype,"keysRadiusDecr",void 0),l.c([Object(w.c)()],e.prototype,"keysRadiusModifierAlt",void 0),l.c([Object(w.c)()],e.prototype,"keysRadiusModifierCtrl",void 0),l.c([Object(w.c)()],e.prototype,"keysRadiusModifierShift",void 0),l.c([Object(w.c)()],e.prototype,"heightSensibility",void 0),l.c([Object(w.c)()],e.prototype,"rotationSensibility",void 0),l.c([Object(w.c)()],e.prototype,"radiusSensibility",void 0),e}();ze.FollowCameraKeyboardMoveInput=yt;var bt=function(){function e(){this.axisControlRadius=!0,this.axisControlHeight=!1,this.axisControlRotation=!1,this.wheelPrecision=3,this.wheelDeltaPercentage=0}return e.prototype.attachControl=function(e,t){var i=this;this._wheel=function(e,r){if(e.type===Ae.a.POINTERWHEEL){var n=e.event,o=0,s=Math.max(-1,Math.min(1,n.deltaY||n.wheelDelta||-n.detail));i.wheelDeltaPercentage?(console.assert(i.axisControlRadius+i.axisControlHeight+i.axisControlRotation<=1,"wheelDeltaPercentage only usable when mouse wheel controlls ONE axis. Currently enabled: axisControlRadius: "+i.axisControlRadius+", axisControlHeightOffset: "+i.axisControlHeight+", axisControlRotationOffset: "+i.axisControlRotation),i.axisControlRadius?o=.01*s*i.wheelDeltaPercentage*i.camera.radius:i.axisControlHeight?o=.01*s*i.wheelDeltaPercentage*i.camera.heightOffset:i.axisControlRotation&&(o=.01*s*i.wheelDeltaPercentage*i.camera.rotationOffset)):o=s*i.wheelPrecision,o&&(i.axisControlRadius?i.camera.radius+=o:i.axisControlHeight?i.camera.heightOffset-=o:i.axisControlRotation&&(i.camera.rotationOffset-=o)),n.preventDefault&&(t||n.preventDefault())}},this._observer=this.camera.getScene().onPointerObservable.add(this._wheel,Ae.a.POINTERWHEEL)},e.prototype.detachControl=function(e){this._observer&&e&&(this.camera.getScene().onPointerObservable.remove(this._observer),this._observer=null,this._wheel=null)},e.prototype.getClassName=function(){return"ArcRotateCameraMouseWheelInput"},e.prototype.getSimpleName=function(){return"mousewheel"},l.c([Object(w.c)()],e.prototype,"axisControlRadius",void 0),l.c([Object(w.c)()],e.prototype,"axisControlHeight",void 0),l.c([Object(w.c)()],e.prototype,"axisControlRotation",void 0),l.c([Object(w.c)()],e.prototype,"wheelPrecision",void 0),l.c([Object(w.c)()],e.prototype,"wheelDeltaPercentage",void 0),e}();ze.FollowCameraMouseWheelInput=bt;var Tt=function(e){function t(t){return e.call(this,t)||this}return l.d(t,e),t.prototype.addKeyboard=function(){return this.add(new yt),this},t.prototype.addMouseWheel=function(){return this.add(new bt),this},t.prototype.addPointers=function(){return console.warn("Pointer support not yet implemented for FollowCamera."),this},t.prototype.addVRDeviceOrientation=function(){return console.warn("DeviceOrientation support not yet implemented for FollowCamera."),this},t}(je);F.a.AddNodeConstructor("FollowCamera",function(e,t){return function(){return new Et(e,o.x.Zero(),t)}}),F.a.AddNodeConstructor("ArcFollowCamera",function(e,t){return function(){return new xt(e,0,0,1,null,t)}});var Et=function(e){function t(t,i,r,n){void 0===n&&(n=null);var o=e.call(this,t,i,r)||this;return o.radius=12,o.lowerRadiusLimit=null,o.upperRadiusLimit=null,o.rotationOffset=0,o.lowerRotationOffsetLimit=null,o.upperRotationOffsetLimit=null,o.heightOffset=4,o.lowerHeightOffsetLimit=null,o.upperHeightOffsetLimit=null,o.cameraAcceleration=.05,o.maxCameraSpeed=20,o.lockedTarget=n,o.inputs=new Tt(o),o.inputs.addKeyboard().addMouseWheel(),o}return l.d(t,e),t.prototype._follow=function(e){if(e){var t;if(e.rotationQuaternion){var i=new o.j;e.rotationQuaternion.toRotationMatrix(i),t=Math.atan2(i.m[8],i.m[10])}else t=e.rotation.y;var r=ve.h.ToRadians(this.rotationOffset)+t,n=e.getAbsolutePosition(),s=n.x+Math.sin(r)*this.radius,a=n.z+Math.cos(r)*this.radius,c=s-this.position.x,l=n.y+this.heightOffset-this.position.y,u=a-this.position.z,h=c*this.cameraAcceleration*2,d=l*this.cameraAcceleration,f=u*this.cameraAcceleration*2;(h>this.maxCameraSpeed||h<-this.maxCameraSpeed)&&(h=h<1?-this.maxCameraSpeed:this.maxCameraSpeed),(d>this.maxCameraSpeed||d<-this.maxCameraSpeed)&&(d=d<1?-this.maxCameraSpeed:this.maxCameraSpeed),(f>this.maxCameraSpeed||f<-this.maxCameraSpeed)&&(f=f<1?-this.maxCameraSpeed:this.maxCameraSpeed),this.position=new o.x(this.position.x+h,this.position.y+d,this.position.z+f),this.setTarget(n)}},t.prototype.attachControl=function(e,t){this.inputs.attachElement(e,t),this._reset=function(){}},t.prototype.detachControl=function(e){this.inputs.detachElement(e),this._reset&&this._reset()},t.prototype._checkInputs=function(){this.inputs.checkInputs(),this._checkLimits(),e.prototype._checkInputs.call(this),this.lockedTarget&&this._follow(this.lockedTarget)},t.prototype._checkLimits=function(){null!==this.lowerRadiusLimit&&this.radius<this.lowerRadiusLimit&&(this.radius=this.lowerRadiusLimit),null!==this.upperRadiusLimit&&this.radius>this.upperRadiusLimit&&(this.radius=this.upperRadiusLimit),null!==this.lowerHeightOffsetLimit&&this.heightOffset<this.lowerHeightOffsetLimit&&(this.heightOffset=this.lowerHeightOffsetLimit),null!==this.upperHeightOffsetLimit&&this.heightOffset>this.upperHeightOffsetLimit&&(this.heightOffset=this.upperHeightOffsetLimit),null!==this.lowerRotationOffsetLimit&&this.rotationOffset<this.lowerRotationOffsetLimit&&(this.rotationOffset=this.lowerRotationOffsetLimit),null!==this.upperRotationOffsetLimit&&this.rotationOffset>this.upperRotationOffsetLimit&&(this.rotationOffset=this.upperRotationOffsetLimit)},t.prototype.getClassName=function(){return"FollowCamera"},l.c([Object(w.c)()],t.prototype,"radius",void 0),l.c([Object(w.c)()],t.prototype,"lowerRadiusLimit",void 0),l.c([Object(w.c)()],t.prototype,"upperRadiusLimit",void 0),l.c([Object(w.c)()],t.prototype,"rotationOffset",void 0),l.c([Object(w.c)()],t.prototype,"lowerRotationOffsetLimit",void 0),l.c([Object(w.c)()],t.prototype,"upperRotationOffsetLimit",void 0),l.c([Object(w.c)()],t.prototype,"heightOffset",void 0),l.c([Object(w.c)()],t.prototype,"lowerHeightOffsetLimit",void 0),l.c([Object(w.c)()],t.prototype,"upperHeightOffsetLimit",void 0),l.c([Object(w.c)()],t.prototype,"cameraAcceleration",void 0),l.c([Object(w.c)()],t.prototype,"maxCameraSpeed",void 0),l.c([Object(w.j)("lockedTargetId")],t.prototype,"lockedTarget",void 0),t}(dt),xt=function(e){function t(t,i,r,n,s,a){var c=e.call(this,t,o.x.Zero(),a)||this;return c.alpha=i,c.beta=r,c.radius=n,c.target=s,c._cartesianCoordinates=o.x.Zero(),c._follow(),c}return l.d(t,e),t.prototype._follow=function(){if(this.target){this._cartesianCoordinates.x=this.radius*Math.cos(this.alpha)*Math.cos(this.beta),this._cartesianCoordinates.y=this.radius*Math.sin(this.beta),this._cartesianCoordinates.z=this.radius*Math.sin(this.alpha)*Math.cos(this.beta);var e=this.target.getAbsolutePosition();this.position=e.add(this._cartesianCoordinates),this.setTarget(e)}},t.prototype._checkInputs=function(){e.prototype._checkInputs.call(this),this._follow()},t.prototype.getClassName=function(){return"ArcFollowCamera"},t}(dt);F.a.AddNodeConstructor("FreeCamera",function(e,t){return function(){return new At(e,o.x.Zero(),t)}});var At=function(e){function t(t,i,r){var n=e.call(this,t,i,r)||this;return n.inputs.addGamepad(),n}return l.d(t,e),Object.defineProperty(t.prototype,"gamepadAngularSensibility",{get:function(){var e=this.inputs.attached.gamepad;return e?e.gamepadAngularSensibility:0},set:function(e){var t=this.inputs.attached.gamepad;t&&(t.gamepadAngularSensibility=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"gamepadMoveSensibility",{get:function(){var e=this.inputs.attached.gamepad;return e?e.gamepadMoveSensibility:0},set:function(e){var t=this.inputs.attached.gamepad;t&&(t.gamepadMoveSensibility=e)},enumerable:!0,configurable:!0}),t.prototype.getClassName=function(){return"UniversalCamera"},t}(pt);Le.a._createDefaultParsedCamera=function(e,t){return new At(e,o.x.Zero(),t)},F.a.AddNodeConstructor("GamepadCamera",function(e,t){return function(){return new Pt(e,o.x.Zero(),t)}});var Pt=function(e){function t(t,i,r){return e.call(this,t,i,r)||this}return l.d(t,e),t.prototype.getClassName=function(){return"GamepadCamera"},t}(At),Rt=i(28),St=i(5),Ct="\nattribute vec2 position;\nuniform vec2 scale;\n\nvarying vec2 vUV;\nconst vec2 madd=vec2(0.5,0.5);\nvoid main(void) {\nvUV=(position*madd+madd)*scale;\ngl_Position=vec4(position,0.0,1.0);\n}";St.a.ShadersStore.postprocessVertexShader=Ct;var Mt=function(){function e(e,t,i,r,s,a,c,l,u,h,d,f,p,g){void 0===c&&(c=_.a.TEXTURE_NEAREST_SAMPLINGMODE),void 0===h&&(h=null),void 0===d&&(d=_.a.TEXTURETYPE_UNSIGNED_INT),void 0===f&&(f="postprocess"),void 0===g&&(g=!1),this.name=e,this.width=-1,this.height=-1,this._outputTexture=null,this.autoClear=!0,this.alphaMode=_.a.ALPHA_DISABLE,this.animations=new Array,this.enablePixelPerfectMode=!1,this.forceFullscreenViewport=!0,this.scaleMode=_.a.SCALEMODE_FLOOR,this.alwaysForcePOT=!1,this._samples=1,this.adaptScaleToCurrentViewport=!1,this._reusable=!1,this._textures=new Rt.a(2),this._currentRenderTextureInd=0,this._scaleRatio=new o.w(1,1),this._texelSize=o.w.Zero(),this.onActivateObservable=new n.c,this.onSizeChangedObservable=new n.c,this.onApplyObservable=new n.c,this.onBeforeRenderObservable=new n.c,this.onAfterRenderObservable=new n.c,null!=a?(this._camera=a,this._scene=a.getScene(),a.attachPostProcess(this),this._engine=this._scene.getEngine(),this._scene.postProcesses.push(this)):l&&(this._engine=l,this._engine.postProcesses.push(this)),this._options=s,this.renderTargetSamplingMode=c||_.a.TEXTURE_NEAREST_SAMPLINGMODE,this._reusable=u||!1,this._textureType=d,this._samplers=r||[],this._samplers.push("textureSampler"),this._fragmentUrl=t,this._vertexUrl=f,this._parameters=i||[],this._parameters.push("scale"),this._indexParameters=p,g||this.updateEffect(h)}return Object.defineProperty(e.prototype,"samples",{get:function(){return this._samples},set:function(e){var t=this;this._samples=e,this._textures.forEach(function(e){e.samples!==t._samples&&t._engine.updateRenderTargetTextureSampleCount(e,t._samples)})},enumerable:!0,configurable:!0}),e.prototype.getEffectName=function(){return this._fragmentUrl},Object.defineProperty(e.prototype,"onActivate",{set:function(e){this._onActivateObserver&&this.onActivateObservable.remove(this._onActivateObserver),e&&(this._onActivateObserver=this.onActivateObservable.add(e))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onSizeChanged",{set:function(e){this._onSizeChangedObserver&&this.onSizeChangedObservable.remove(this._onSizeChangedObserver),this._onSizeChangedObserver=this.onSizeChangedObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onApply",{set:function(e){this._onApplyObserver&&this.onApplyObservable.remove(this._onApplyObserver),this._onApplyObserver=this.onApplyObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onBeforeRender",{set:function(e){this._onBeforeRenderObserver&&this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),this._onBeforeRenderObserver=this.onBeforeRenderObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onAfterRender",{set:function(e){this._onAfterRenderObserver&&this.onAfterRenderObservable.remove(this._onAfterRenderObserver),this._onAfterRenderObserver=this.onAfterRenderObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"inputTexture",{get:function(){return this._textures.data[this._currentRenderTextureInd]},set:function(e){this._forcedOutputTexture=e},enumerable:!0,configurable:!0}),e.prototype.getCamera=function(){return this._camera},Object.defineProperty(e.prototype,"texelSize",{get:function(){return this._shareOutputWithPostProcess?this._shareOutputWithPostProcess.texelSize:(this._forcedOutputTexture&&this._texelSize.copyFromFloats(1/this._forcedOutputTexture.width,1/this._forcedOutputTexture.height),this._texelSize)},enumerable:!0,configurable:!0}),e.prototype.getEngine=function(){return this._engine},e.prototype.getEffect=function(){return this._effect},e.prototype.shareOutputWith=function(e){return this._disposeTextures(),this._shareOutputWithPostProcess=e,this},e.prototype.useOwnOutput=function(){0==this._textures.length&&(this._textures=new Rt.a(2)),this._shareOutputWithPostProcess=null},e.prototype.updateEffect=function(e,t,i,r,n,o){void 0===e&&(e=null),void 0===t&&(t=null),void 0===i&&(i=null),this._effect=this._engine.createEffect({vertex:this._vertexUrl,fragment:this._fragmentUrl},["position"],t||this._parameters,i||this._samplers,null!==e?e:"",void 0,n,o,r||this._indexParameters)},e.prototype.isReusable=function(){return this._reusable},e.prototype.markTextureDirty=function(){this.width=-1},e.prototype.activate=function(e,t,i){var r=this;void 0===t&&(t=null);var n=(e=e||this._camera).getScene(),o=n.getEngine(),s=o.getCaps().maxTextureSize,a=(t?t.width:this._engine.getRenderWidth(!0))*this._options|0,c=(t?t.height:this._engine.getRenderHeight(!0))*this._options|0,l=e.parent;!l||l.leftCamera!=e&&l.rightCamera!=e||(a/=2);var u,h=this._options.width||a,d=this._options.height||c;if(!this._shareOutputWithPostProcess&&!this._forcedOutputTexture){if(this.adaptScaleToCurrentViewport){var f=o.currentViewport;f&&(h*=f.width,d*=f.height)}if((this.renderTargetSamplingMode===_.a.TEXTURE_TRILINEAR_SAMPLINGMODE||this.alwaysForcePOT)&&(this._options.width||(h=o.needPOTTextures?ve.h.GetExponentOfTwo(h,s,this.scaleMode):h),this._options.height||(d=o.needPOTTextures?ve.h.GetExponentOfTwo(d,s,this.scaleMode):d)),this.width!==h||this.height!==d){if(this._textures.length>0){for(var p=0;p<this._textures.length;p++)this._engine._releaseTexture(this._textures.data[p]);this._textures.reset()}this.width=h,this.height=d;var g={width:this.width,height:this.height},m={generateMipMaps:!1,generateDepthBuffer:i||0===e._postProcesses.indexOf(this),generateStencilBuffer:(i||0===e._postProcesses.indexOf(this))&&this._engine.isStencilEnable,samplingMode:this.renderTargetSamplingMode,type:this._textureType};this._textures.push(this._engine.createRenderTargetTexture(g,m)),this._reusable&&this._textures.push(this._engine.createRenderTargetTexture(g,m)),this._texelSize.copyFromFloats(1/this.width,1/this.height),this.onSizeChangedObservable.notifyObservers(this)}this._textures.forEach(function(e){e.samples!==r.samples&&r._engine.updateRenderTargetTextureSampleCount(e,r.samples)})}return this._shareOutputWithPostProcess?u=this._shareOutputWithPostProcess.inputTexture:this._forcedOutputTexture?(u=this._forcedOutputTexture,this.width=this._forcedOutputTexture.width,this.height=this._forcedOutputTexture.height):u=this.inputTexture,this.enablePixelPerfectMode?(this._scaleRatio.copyFromFloats(a/h,c/d),this._engine.bindFramebuffer(u,0,a,c,this.forceFullscreenViewport)):(this._scaleRatio.copyFromFloats(1,1),this._engine.bindFramebuffer(u,0,void 0,void 0,this.forceFullscreenViewport)),this.onActivateObservable.notifyObservers(e),this.autoClear&&this.alphaMode===_.a.ALPHA_DISABLE&&this._engine.clear(this.clearColor?this.clearColor:n.clearColor,n._allowPostProcessClearColor,!0,!0),this._reusable&&(this._currentRenderTextureInd=(this._currentRenderTextureInd+1)%2),u},Object.defineProperty(e.prototype,"isSupported",{get:function(){return this._effect.isSupported},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"aspectRatio",{get:function(){return this._shareOutputWithPostProcess?this._shareOutputWithPostProcess.aspectRatio:this._forcedOutputTexture?this._forcedOutputTexture.width/this._forcedOutputTexture.height:this.width/this.height},enumerable:!0,configurable:!0}),e.prototype.isReady=function(){return this._effect&&this._effect.isReady()},e.prototype.apply=function(){return this._effect&&this._effect.isReady()?(this._engine.enableEffect(this._effect),this._engine.setState(!1),this._engine.setDepthBuffer(!1),this._engine.setDepthWrite(!1),this._engine.setAlphaMode(this.alphaMode),this.alphaConstants&&this.getEngine().setAlphaConstants(this.alphaConstants.r,this.alphaConstants.g,this.alphaConstants.b,this.alphaConstants.a),e=this._shareOutputWithPostProcess?this._shareOutputWithPostProcess.inputTexture:this._forcedOutputTexture?this._forcedOutputTexture:this.inputTexture,this._effect._bindTexture("textureSampler",e),this._effect.setVector2("scale",this._scaleRatio),this.onApplyObservable.notifyObservers(this._effect),this._effect):null;var e},e.prototype._disposeTextures=function(){if(!this._shareOutputWithPostProcess&&!this._forcedOutputTexture){if(this._textures.length>0)for(var e=0;e<this._textures.length;e++)this._engine._releaseTexture(this._textures.data[e]);this._textures.dispose()}},e.prototype.dispose=function(e){if(e=e||this._camera,this._disposeTextures(),this._scene){var t=this._scene.postProcesses.indexOf(this);-1!==t&&this._scene.postProcesses.splice(t,1)}else{var i=this._engine.postProcesses.indexOf(this);-1!==i&&this._engine.postProcesses.splice(i,1)}if(e){if(e.detachPostProcess(this),0===e._postProcesses.indexOf(this)&&e._postProcesses.length>0){var r=this._camera._getFirstPostProcess();r&&r.markTextureDirty()}this.onActivateObservable.clear(),this.onAfterRenderObservable.clear(),this.onApplyObservable.clear(),this.onBeforeRenderObservable.clear(),this.onSizeChangedObservable.clear()}},e}(),Ot="\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nvoid main(void)\n{\ngl_FragColor=texture2D(textureSampler,vUV);\n}";St.a.ShadersStore.passPixelShader=Ot;var It="\nvarying vec2 vUV;\nuniform samplerCube textureSampler;\nvoid main(void)\n{\nvec2 uv=vUV*2.0-1.0;\n#ifdef POSITIVEX\ngl_FragColor=textureCube(textureSampler,vec3(1.001,uv.y,uv.x));\n#endif\n#ifdef NEGATIVEX\ngl_FragColor=textureCube(textureSampler,vec3(-1.001,uv.y,uv.x));\n#endif\n#ifdef POSITIVEY\ngl_FragColor=textureCube(textureSampler,vec3(uv.y,1.001,uv.x));\n#endif\n#ifdef NEGATIVEY\ngl_FragColor=textureCube(textureSampler,vec3(uv.y,-1.001,uv.x));\n#endif\n#ifdef POSITIVEZ\ngl_FragColor=textureCube(textureSampler,vec3(uv,1.001));\n#endif\n#ifdef NEGATIVEZ\ngl_FragColor=textureCube(textureSampler,vec3(uv,-1.001));\n#endif\n}";St.a.ShadersStore.passCubePixelShader=It;var Dt=function(e){function t(t,i,r,n,o,s,a,c){return void 0===r&&(r=null),void 0===a&&(a=_.a.TEXTURETYPE_UNSIGNED_INT),void 0===c&&(c=!1),e.call(this,t,"pass",null,null,i,r,n,o,s,void 0,a,void 0,null,c)||this}return l.d(t,e),t}(Mt),wt=function(e){function t(t,i,r,n,o,s,a,c){void 0===r&&(r=null),void 0===a&&(a=_.a.TEXTURETYPE_UNSIGNED_INT),void 0===c&&(c=!1);var l=e.call(this,t,"passCube",null,null,i,r,n,o,s,"#define POSITIVEX",a,void 0,null,c)||this;return l._face=0,l}return l.d(t,e),Object.defineProperty(t.prototype,"face",{get:function(){return this._face},set:function(e){if(!(e<0||e>5))switch(this._face=e,this._face){case 0:this.updateEffect("#define POSITIVEX");break;case 1:this.updateEffect("#define NEGATIVEX");break;case 2:this.updateEffect("#define POSITIVEY");break;case 3:this.updateEffect("#define NEGATIVEY");break;case 4:this.updateEffect("#define POSITIVEZ");break;case 5:this.updateEffect("#define NEGATIVEZ")}},enumerable:!0,configurable:!0}),t}(Mt);_e.b._RescalePostProcessFactory=function(e){return new Dt("rescale",1,null,_e.b.TEXTURE_BILINEAR_SAMPLINGMODE,e,!1,_e.b.TEXTURETYPE_UNSIGNED_INT)};var Lt="\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform sampler2D leftSampler;\nvoid main(void)\n{\nvec4 leftFrag=texture2D(leftSampler,vUV);\nleftFrag=vec4(1.0,leftFrag.g,leftFrag.b,1.0);\nvec4 rightFrag=texture2D(textureSampler,vUV);\nrightFrag=vec4(rightFrag.r,1.0,1.0,1.0);\ngl_FragColor=vec4(rightFrag.rgb*leftFrag.rgb,1.0);\n}";St.a.ShadersStore.anaglyphPixelShader=Lt;var Ft=function(e){function t(t,i,r,n,o,s){var a=e.call(this,t,"anaglyph",null,["leftSampler"],i,r[1],n,o,s)||this;return a._passedProcess=r[0]._rigPostProcess,a.onApplyObservable.add(function(e){e.setTextureFromPostProcess("leftSampler",a._passedProcess)}),a}return l.d(t,e),t}(Mt);Le.a._setStereoscopicAnaglyphRigMode=function(e){e._rigCameras[0]._rigPostProcess=new Dt(e.name+"_passthru",1,e._rigCameras[0]),e._rigCameras[1]._rigPostProcess=new Ft(e.name+"_anaglyph",1,e._rigCameras)},F.a.AddNodeConstructor("AnaglyphArcRotateCamera",function(e,t,i){return function(){return new Nt(e,0,0,1,o.x.Zero(),i.interaxial_distance,t)}});var Nt=function(e){function t(t,i,r,n,o,s,a){var c=e.call(this,t,i,r,n,o,a)||this;return c.interaxialDistance=s,c.setCameraRigMode(Le.a.RIG_MODE_STEREOSCOPIC_ANAGLYPH,{interaxialDistance:s}),c}return l.d(t,e),t.prototype.getClassName=function(){return"AnaglyphArcRotateCamera"},t}(_t);F.a.AddNodeConstructor("AnaglyphFreeCamera",function(e,t,i){return function(){return new Bt(e,o.x.Zero(),i.interaxial_distance,t)}});var Bt=function(e){function t(t,i,r,n){var o=e.call(this,t,i,n)||this;return o.interaxialDistance=r,o.setCameraRigMode(Le.a.RIG_MODE_STEREOSCOPIC_ANAGLYPH,{interaxialDistance:r}),o}return l.d(t,e),t.prototype.getClassName=function(){return"AnaglyphFreeCamera"},t}(ft);F.a.AddNodeConstructor("AnaglyphGamepadCamera",function(e,t,i){return function(){return new Ut(e,o.x.Zero(),i.interaxial_distance,t)}});var Ut=function(e){function t(t,i,r,n){var o=e.call(this,t,i,n)||this;return o.interaxialDistance=r,o.setCameraRigMode(Le.a.RIG_MODE_STEREOSCOPIC_ANAGLYPH,{interaxialDistance:r}),o}return l.d(t,e),t.prototype.getClassName=function(){return"AnaglyphGamepadCamera"},t}(Pt);F.a.AddNodeConstructor("AnaglyphUniversalCamera",function(e,t,i){return function(){return new Vt(e,o.x.Zero(),i.interaxial_distance,t)}});var Vt=function(e){function t(t,i,r,n){var o=e.call(this,t,i,n)||this;return o.interaxialDistance=r,o.setCameraRigMode(Le.a.RIG_MODE_STEREOSCOPIC_ANAGLYPH,{interaxialDistance:r}),o}return l.d(t,e),t.prototype.getClassName=function(){return"AnaglyphUniversalCamera"},t}(At),Gt="const vec3 TWO=vec3(2.0,2.0,2.0);\nvarying vec2 vUV;\nuniform sampler2D camASampler;\nuniform sampler2D textureSampler;\nuniform vec2 stepSize;\nvoid main(void)\n{\nbool useCamB;\nvec2 texCoord1;\nvec2 texCoord2;\nvec3 frag1;\nvec3 frag2;\n#ifdef IS_STEREOSCOPIC_HORIZ\nuseCamB=vUV.x>0.5;\ntexCoord1=vec2(useCamB ? (vUV.x-0.5)*2.0 : vUV.x*2.0,vUV.y);\ntexCoord2=vec2(texCoord1.x+stepSize.x,vUV.y);\n#else\nuseCamB=vUV.y>0.5;\ntexCoord1=vec2(vUV.x,useCamB ? (vUV.y-0.5)*2.0 : vUV.y*2.0);\ntexCoord2=vec2(vUV.x,texCoord1.y+stepSize.y);\n#endif\n\nif (useCamB){\nfrag1=texture2D(textureSampler,texCoord1).rgb;\nfrag2=texture2D(textureSampler,texCoord2).rgb;\n}else{\nfrag1=texture2D(camASampler ,texCoord1).rgb;\nfrag2=texture2D(camASampler ,texCoord2).rgb;\n}\ngl_FragColor=vec4((frag1+frag2)/TWO,1.0);\n}";St.a.ShadersStore.stereoscopicInterlacePixelShader=Gt;var kt=function(e){function t(t,i,r,n,s,a){var c=e.call(this,t,"stereoscopicInterlace",["stepSize"],["camASampler"],1,i[1],n,s,a,r?"#define IS_STEREOSCOPIC_HORIZ 1":void 0)||this;return c._passedProcess=i[0]._rigPostProcess,c._stepSize=new o.w(1/c.width,1/c.height),c.onSizeChangedObservable.add(function(){c._stepSize=new o.w(1/c.width,1/c.height)}),c.onApplyObservable.add(function(e){e.setTextureFromPostProcess("camASampler",c._passedProcess),e.setFloat2("stepSize",c._stepSize.x,c._stepSize.y)}),c}return l.d(t,e),t}(Mt);Le.a._setStereoscopicRigMode=function(e){var t=e.cameraRigMode===Le.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL||e.cameraRigMode===Le.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED;e._rigCameras[0]._rigPostProcess=new Dt(e.name+"_passthru",1,e._rigCameras[0]),e._rigCameras[1]._rigPostProcess=new kt(e.name+"_stereoInterlace",e._rigCameras,t)},F.a.AddNodeConstructor("StereoscopicArcRotateCamera",function(e,t,i){return function(){return new zt(e,0,0,1,o.x.Zero(),i.interaxial_distance,i.isStereoscopicSideBySide,t)}});var zt=function(e){function t(t,i,r,n,o,s,a,c){var l=e.call(this,t,i,r,n,o,c)||this;return l.interaxialDistance=s,l.isStereoscopicSideBySide=a,l.setCameraRigMode(a?Le.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:Le.a.RIG_MODE_STEREOSCOPIC_OVERUNDER,{interaxialDistance:s}),l}return l.d(t,e),t.prototype.getClassName=function(){return"StereoscopicArcRotateCamera"},t}(_t);F.a.AddNodeConstructor("StereoscopicFreeCamera",function(e,t,i){return function(){return new jt(e,o.x.Zero(),i.interaxial_distance,i.isStereoscopicSideBySide,t)}});var jt=function(e){function t(t,i,r,n,o){var s=e.call(this,t,i,o)||this;return s.interaxialDistance=r,s.isStereoscopicSideBySide=n,s.setCameraRigMode(n?Le.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:Le.a.RIG_MODE_STEREOSCOPIC_OVERUNDER,{interaxialDistance:r}),s}return l.d(t,e),t.prototype.getClassName=function(){return"StereoscopicFreeCamera"},t}(ft);F.a.AddNodeConstructor("StereoscopicGamepadCamera",function(e,t,i){return function(){return new Wt(e,o.x.Zero(),i.interaxial_distance,i.isStereoscopicSideBySide,t)}});var Wt=function(e){function t(t,i,r,n,o){var s=e.call(this,t,i,o)||this;return s.interaxialDistance=r,s.isStereoscopicSideBySide=n,s.setCameraRigMode(n?Le.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:Le.a.RIG_MODE_STEREOSCOPIC_OVERUNDER,{interaxialDistance:r}),s}return l.d(t,e),t.prototype.getClassName=function(){return"StereoscopicGamepadCamera"},t}(Pt);F.a.AddNodeConstructor("StereoscopicFreeCamera",function(e,t,i){return function(){return new Ht(e,o.x.Zero(),i.interaxial_distance,i.isStereoscopicSideBySide,t)}});var Ht=function(e){function t(t,i,r,n,o){var s=e.call(this,t,i,o)||this;return s.interaxialDistance=r,s.isStereoscopicSideBySide=n,s.setCameraRigMode(n?Le.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:Le.a.RIG_MODE_STEREOSCOPIC_OVERUNDER,{interaxialDistance:r}),s}return l.d(t,e),t.prototype.getClassName=function(){return"StereoscopicUniversalCamera"},t}(At);F.a.AddNodeConstructor("VirtualJoysticksCamera",function(e,t){return function(){return new Xt(e,o.x.Zero(),t)}});var Xt=function(e){function t(t,i,r){var n=e.call(this,t,i,r)||this;return n.inputs.addVirtualJoystick(),n}return l.d(t,e),t.prototype.getClassName=function(){return"VirtualJoysticksCamera"},t}(ft),Yt=function(){function e(){this.compensateDistortion=!0}return Object.defineProperty(e.prototype,"aspectRatio",{get:function(){return this.hResolution/(2*this.vResolution)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"aspectRatioFov",{get:function(){return 2*Math.atan(this.postProcessScaleFactor*this.vScreenSize/(2*this.eyeToScreenDistance))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"leftHMatrix",{get:function(){var e=4*(this.hScreenSize/4-this.lensSeparationDistance/2)/this.hScreenSize;return o.j.Translation(e,0,0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rightHMatrix",{get:function(){var e=4*(this.hScreenSize/4-this.lensSeparationDistance/2)/this.hScreenSize;return o.j.Translation(-e,0,0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"leftPreViewMatrix",{get:function(){return o.j.Translation(.5*this.interpupillaryDistance,0,0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rightPreViewMatrix",{get:function(){return o.j.Translation(-.5*this.interpupillaryDistance,0,0)},enumerable:!0,configurable:!0}),e.GetDefault=function(){var t=new e;return t.hResolution=1280,t.vResolution=800,t.hScreenSize=.149759993,t.vScreenSize=.0935999975,t.vScreenCenter=.0467999987,t.eyeToScreenDistance=.0410000011,t.lensSeparationDistance=.063500002,t.interpupillaryDistance=.064000003,t.distortionK=[1,.219999999,.239999995,0],t.chromaAbCorrection=[.995999992,-.00400000019,1.01400006,0],t.postProcessScaleFactor=1.714605507808412,t.lensCenterOffset=.151976421,t},e}(),Kt="\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform vec2 LensCenter;\nuniform vec2 Scale;\nuniform vec2 ScaleIn;\nuniform vec4 HmdWarpParam;\nvec2 HmdWarp(vec2 in01) {\nvec2 theta=(in01-LensCenter)*ScaleIn;\nfloat rSq=theta.x*theta.x+theta.y*theta.y;\nvec2 rvector=theta*(HmdWarpParam.x+HmdWarpParam.y*rSq+HmdWarpParam.z*rSq*rSq+HmdWarpParam.w*rSq*rSq*rSq);\nreturn LensCenter+Scale*rvector;\n}\nvoid main(void)\n{\nvec2 tc=HmdWarp(vUV);\nif (tc.x <0.0 || tc.x>1.0 || tc.y<0.0 || tc.y>1.0)\ngl_FragColor=vec4(0.0,0.0,0.0,0.0);\nelse{\ngl_FragColor=texture2D(textureSampler,tc);\n}\n}";St.a.ShadersStore.vrDistortionCorrectionPixelShader=Kt;var Qt=function(e){function t(t,i,r,n){var s=e.call(this,t,"vrDistortionCorrection",["LensCenter","Scale","ScaleIn","HmdWarpParam"],null,n.postProcessScaleFactor,i,Ve.a.BILINEAR_SAMPLINGMODE)||this;return s._isRightEye=r,s._distortionFactors=n.distortionK,s._postProcessScaleFactor=n.postProcessScaleFactor,s._lensCenterOffset=n.lensCenterOffset,s.adaptScaleToCurrentViewport=!0,s.onSizeChangedObservable.add(function(){s._scaleIn=new o.w(2,2/s.aspectRatio),s._scaleFactor=new o.w(1/s._postProcessScaleFactor*.5,1/s._postProcessScaleFactor*.5*s.aspectRatio),s._lensCenter=new o.w(s._isRightEye?.5-.5*s._lensCenterOffset:.5+.5*s._lensCenterOffset,.5)}),s.onApplyObservable.add(function(e){e.setFloat2("LensCenter",s._lensCenter.x,s._lensCenter.y),e.setFloat2("Scale",s._scaleFactor.x,s._scaleFactor.y),e.setFloat2("ScaleIn",s._scaleIn.x,s._scaleIn.y),e.setFloat4("HmdWarpParam",s._distortionFactors[0],s._distortionFactors[1],s._distortionFactors[2],s._distortionFactors[3])}),s}return l.d(t,e),t}(Mt);Le.a._setVRRigMode=function(e,t){var i=t.vrCameraMetrics||Yt.GetDefault();e._rigCameras[0]._cameraRigParams.vrMetrics=i,e._rigCameras[0].viewport=new o.z(0,0,.5,1),e._rigCameras[0]._cameraRigParams.vrWorkMatrix=new o.j,e._rigCameras[0]._cameraRigParams.vrHMatrix=i.leftHMatrix,e._rigCameras[0]._cameraRigParams.vrPreViewMatrix=i.leftPreViewMatrix,e._rigCameras[0].getProjectionMatrix=e._rigCameras[0]._getVRProjectionMatrix,e._rigCameras[1]._cameraRigParams.vrMetrics=i,e._rigCameras[1].viewport=new o.z(.5,0,.5,1),e._rigCameras[1]._cameraRigParams.vrWorkMatrix=new o.j,e._rigCameras[1]._cameraRigParams.vrHMatrix=i.rightHMatrix,e._rigCameras[1]._cameraRigParams.vrPreViewMatrix=i.rightPreViewMatrix,e._rigCameras[1].getProjectionMatrix=e._rigCameras[1]._getVRProjectionMatrix,i.compensateDistortion&&(e._rigCameras[0]._rigPostProcess=new Qt("VR_Distort_Compensation_Left",e._rigCameras[0],!1,i),e._rigCameras[1]._rigPostProcess=new Qt("VR_Distort_Compensation_Right",e._rigCameras[1],!0,i))},F.a.AddNodeConstructor("VRDeviceOrientationFreeCamera",function(e,t){return function(){return new qt(e,0,0,1,o.x.Zero(),t)}});var qt=function(e){function t(t,i,r,n,o,s,a,c){void 0===a&&(a=!0),void 0===c&&(c=Yt.GetDefault());var l=e.call(this,t,i,r,n,o,s)||this;return c.compensateDistortion=a,l.setCameraRigMode(Le.a.RIG_MODE_VR,{vrCameraMetrics:c}),l.inputs.addVRDeviceOrientation(),l}return l.d(t,e),t.prototype.getClassName=function(){return"VRDeviceOrientationArcRotateCamera"},t}(_t);F.a.AddNodeConstructor("VRDeviceOrientationFreeCamera",function(e,t){return function(){return new Zt(e,o.x.Zero(),t)}});var Zt=function(e){function t(t,i,r,n,o){void 0===n&&(n=!0),void 0===o&&(o=Yt.GetDefault());var s=e.call(this,t,i,r)||this;return o.compensateDistortion=n,s.setCameraRigMode(Le.a.RIG_MODE_VR,{vrCameraMetrics:o}),s}return l.d(t,e),t.prototype.getClassName=function(){return"VRDeviceOrientationFreeCamera"},t}(gt);F.a.AddNodeConstructor("VRDeviceOrientationGamepadCamera",function(e,t){return function(){return new $t(e,o.x.Zero(),t)}});var Jt,$t=function(e){function t(t,i,r,n,o){void 0===n&&(n=!0),void 0===o&&(o=Yt.GetDefault());var s=e.call(this,t,i,r,n,o)||this;return s.inputs.addGamepad(),s}return l.d(t,e),t.prototype.getClassName=function(){return"VRDeviceOrientationGamepadCamera"},t}(Zt),ei=i(27);!function(e){e[e.VIVE=0]="VIVE",e[e.OCULUS=1]="OCULUS",e[e.WINDOWS=2]="WINDOWS",e[e.GEAR_VR=3]="GEAR_VR",e[e.DAYDREAM=4]="DAYDREAM",e[e.GENERIC=5]="GENERIC"}(Jt||(Jt={}));var ti=function(){function e(){}return e.InitiateController=function(e){for(var t=0,i=this._ControllerFactories;t<i.length;t++){var r=i[t];if(r.canCreate(e))return r.create(e)}if(this._DefaultControllerFactory)return this._DefaultControllerFactory(e);throw"The type of gamepad you are trying to load needs to be imported first or is not supported."},e._ControllerFactories=[],e._DefaultControllerFactory=null,e}(),ii=function(e){function t(t){var i=e.call(this,t.id,t.index,t)||this;return i._deviceRoomPosition=o.x.Zero(),i._deviceRoomRotationQuaternion=new o.q,i.devicePosition=o.x.Zero(),i.deviceRotationQuaternion=new o.q,i.deviceScaleFactor=1,i._trackPosition=!0,i._maxRotationDistFromHeadset=Math.PI/5,i._draggedRoomRotation=0,i._leftHandSystemQuaternion=new o.q,i._deviceToWorld=o.j.Identity(),i._pointingPoseNode=null,i._workingMatrix=o.j.Identity(),i._meshAttachedObservable=new n.c,i.type=He.POSE_ENABLED,i.controllerType=Jt.GENERIC,i.position=o.x.Zero(),i.rotationQuaternion=new o.q,i._calculatedPosition=o.x.Zero(),i._calculatedRotation=new o.q,o.q.RotationYawPitchRollToRef(Math.PI,0,0,i._leftHandSystemQuaternion),i}return l.d(t,e),t.prototype._disableTrackPosition=function(e){this._trackPosition&&(this._calculatedPosition.copyFrom(e),this._trackPosition=!1)},t.prototype.update=function(){e.prototype.update.call(this),this._updatePoseAndMesh()},t.prototype._updatePoseAndMesh=function(){var e=this.browserGamepad.pose;if((this.updateFromDevice(e),!this._trackPosition&&R.a.LastCreatedScene&&R.a.LastCreatedScene.activeCamera&&R.a.LastCreatedScene.activeCamera.devicePosition)&&((t=R.a.LastCreatedScene.activeCamera)._computeDevicePosition(),this._deviceToWorld.setTranslation(t.devicePosition),t.deviceRotationQuaternion)){var t;(t=t)._deviceRoomRotationQuaternion.toEulerAnglesToRef(o.t.Vector3[0]);var i=Math.atan2(Math.sin(o.t.Vector3[0].y-this._draggedRoomRotation),Math.cos(o.t.Vector3[0].y-this._draggedRoomRotation));if(Math.abs(i)>this._maxRotationDistFromHeadset){var r=i-(i<0?-this._maxRotationDistFromHeadset:this._maxRotationDistFromHeadset);this._draggedRoomRotation+=r;var n=Math.sin(-r),s=Math.cos(-r);this._calculatedPosition.x=this._calculatedPosition.x*s-this._calculatedPosition.z*n,this._calculatedPosition.z=this._calculatedPosition.x*n+this._calculatedPosition.z*s}}o.x.TransformCoordinatesToRef(this._calculatedPosition,this._deviceToWorld,this.devicePosition),this._deviceToWorld.getRotationMatrixToRef(this._workingMatrix),o.q.FromRotationMatrixToRef(this._workingMatrix,this.deviceRotationQuaternion),this.deviceRotationQuaternion.multiplyInPlace(this._calculatedRotation),this._mesh&&(this._mesh.position.copyFrom(this.devicePosition),this._mesh.rotationQuaternion&&this._mesh.rotationQuaternion.copyFrom(this.deviceRotationQuaternion))},t.prototype.updateFromDevice=function(e){if(e){this.rawPose=e,e.position&&(this._deviceRoomPosition.copyFromFloats(e.position[0],e.position[1],-e.position[2]),this._mesh&&this._mesh.getScene().useRightHandedSystem&&(this._deviceRoomPosition.z*=-1),this._trackPosition&&this._deviceRoomPosition.scaleToRef(this.deviceScaleFactor,this._calculatedPosition),this._calculatedPosition.addInPlace(this.position));var t=this.rawPose;e.orientation&&t.orientation&&(this._deviceRoomRotationQuaternion.copyFromFloats(t.orientation[0],t.orientation[1],-t.orientation[2],-t.orientation[3]),this._mesh&&(this._mesh.getScene().useRightHandedSystem?(this._deviceRoomRotationQuaternion.z*=-1,this._deviceRoomRotationQuaternion.w*=-1):this._deviceRoomRotationQuaternion.multiplyToRef(this._leftHandSystemQuaternion,this._deviceRoomRotationQuaternion)),this._deviceRoomRotationQuaternion.multiplyToRef(this.rotationQuaternion,this._calculatedRotation))}},t.prototype.attachToMesh=function(e){if(this._mesh&&(this._mesh.parent=null),this._mesh=e,this._poseControlledCamera&&(this._mesh.parent=this._poseControlledCamera),this._mesh.rotationQuaternion||(this._mesh.rotationQuaternion=new o.q),this._updatePoseAndMesh(),this._pointingPoseNode){for(var t=[],i=this._pointingPoseNode;i.parent;)t.push(i.parent),i=i.parent;t.reverse().forEach(function(e){e.computeWorldMatrix(!0)})}this._meshAttachedObservable.notifyObservers(e)},t.prototype.attachToPoseControlledCamera=function(e){this._poseControlledCamera=e,this._mesh&&(this._mesh.parent=this._poseControlledCamera)},t.prototype.dispose=function(){this._mesh&&this._mesh.dispose(),this._mesh=null,e.prototype.dispose.call(this)},Object.defineProperty(t.prototype,"mesh",{get:function(){return this._mesh},enumerable:!0,configurable:!0}),t.prototype.getForwardRay=function(e){if(void 0===e&&(e=100),!this.mesh)return new ei.a(o.x.Zero(),new o.x(0,0,1),e);var t=this._pointingPoseNode?this._pointingPoseNode.getWorldMatrix():this.mesh.getWorldMatrix(),i=t.getTranslation(),r=new o.x(0,0,-1),n=o.x.TransformNormal(r,t),s=o.x.Normalize(n);return new ei.a(i,s,e)},t.POINTING_POSE="POINTING_POSE",t}(He),ri=i(39);F.a.AddNodeConstructor("Light_Type_3",function(e,t){return function(){return new ni(e,o.x.Zero(),t)}});var ni=function(e){function t(t,i,r){var n=e.call(this,t,r)||this;return n.groundColor=new o.e(0,0,0),n.direction=i||o.x.Up(),n}return l.d(t,e),t.prototype._buildUniformLayout=function(){this._uniformBuffer.addUniform("vLightData",4),this._uniformBuffer.addUniform("vLightDiffuse",4),this._uniformBuffer.addUniform("vLightSpecular",3),this._uniformBuffer.addUniform("vLightGround",3),this._uniformBuffer.addUniform("shadowsInfo",3),this._uniformBuffer.addUniform("depthValues",2),this._uniformBuffer.create()},t.prototype.getClassName=function(){return"HemisphericLight"},t.prototype.setDirectionToTarget=function(e){return this.direction=o.x.Normalize(e.subtract(o.x.Zero())),this.direction},t.prototype.getShadowGenerator=function(){return null},t.prototype.transferToEffect=function(e,t){var i=o.x.Normalize(this.direction);return this._uniformBuffer.updateFloat4("vLightData",i.x,i.y,i.z,0,t),this._uniformBuffer.updateColor3("vLightGround",this.groundColor.scale(this.intensity),t),this},t.prototype.computeWorldMatrix=function(){return this._worldMatrix||(this._worldMatrix=o.j.Identity()),this._worldMatrix},t.prototype.getTypeID=function(){return ri.a.LIGHTTYPEID_HEMISPHERICLIGHT},t.prototype.prepareLightSpecificDefines=function(e,t){e["HEMILIGHT"+t]=!0},l.c([Object(w.e)()],t.prototype,"groundColor",void 0),l.c([Object(w.n)()],t.prototype,"direction",void 0),t}(ri.a);Le.a._setWebVRRigMode=function(e,t){if(t.vrDisplay){var i=t.vrDisplay.getEyeParameters("left"),r=t.vrDisplay.getEyeParameters("right");e._rigCameras[0].viewport=new o.z(0,0,.5,1),e._rigCameras[0].setCameraRigParameter("left",!0),e._rigCameras[0].setCameraRigParameter("specs",t.specs),e._rigCameras[0].setCameraRigParameter("eyeParameters",i),e._rigCameras[0].setCameraRigParameter("frameData",t.frameData),e._rigCameras[0].setCameraRigParameter("parentCamera",t.parentCamera),e._rigCameras[0]._cameraRigParams.vrWorkMatrix=new o.j,e._rigCameras[0].getProjectionMatrix=e._getWebVRProjectionMatrix,e._rigCameras[0].parent=e,e._rigCameras[0]._getViewMatrix=e._getWebVRViewMatrix,e._rigCameras[1].viewport=new o.z(.5,0,.5,1),e._rigCameras[1].setCameraRigParameter("eyeParameters",r),e._rigCameras[1].setCameraRigParameter("specs",t.specs),e._rigCameras[1].setCameraRigParameter("frameData",t.frameData),e._rigCameras[1].setCameraRigParameter("parentCamera",t.parentCamera),e._rigCameras[1]._cameraRigParams.vrWorkMatrix=new o.j,e._rigCameras[1].getProjectionMatrix=e._getWebVRProjectionMatrix,e._rigCameras[1].parent=e,e._rigCameras[1]._getViewMatrix=e._getWebVRViewMatrix,Le.a.UseAlternateWebVRRendering&&(e._rigCameras[1]._skipRendering=!0,e._rigCameras[0]._alternateCamera=e._rigCameras[1])}},F.a.AddNodeConstructor("WebVRFreeCamera",function(e,t){return function(){return new ai(e,o.x.Zero(),t)}}),F.a.AddNodeConstructor("WebVRGamepadCamera",function(e,t){return function(){return new ai(e,o.x.Zero(),t)}});var oi,si,ai=function(e){function t(t,i,r,s){void 0===s&&(s={});var a=e.call(this,t,i,r)||this;a.webVROptions=s,a._vrDevice=null,a.rawPose=null,a._specsVersion="1.1",a._attached=!1,a._descendants=[],a._deviceRoomPosition=o.x.Zero(),a._deviceRoomRotationQuaternion=o.q.Identity(),a._standingMatrix=null,a.devicePosition=o.x.Zero(),a.deviceRotationQuaternion=o.q.Identity(),a.deviceScaleFactor=1,a._deviceToWorld=o.j.Identity(),a._worldToDevice=o.j.Identity(),a.controllers=[],a.onControllersAttachedObservable=new n.c,a.onControllerMeshLoadedObservable=new n.c,a.onPoseUpdatedFromDeviceObservable=new n.c,a._poseSet=!1,a.rigParenting=!0,a._defaultHeight=void 0,a._htmlElementAttached=null,a._detachIfAttached=function(){var e=a.getEngine().getVRDevice();e&&!e.isPresenting&&a._htmlElementAttached&&a.detachControl(a._htmlElementAttached)},a._workingVector=o.x.Zero(),a._oneVector=o.x.One(),a._workingMatrix=o.j.Identity(),a._tmpMatrix=new o.j,a._cache.position=o.x.Zero(),s.defaultHeight&&(a._defaultHeight=s.defaultHeight,a.position.y=a._defaultHeight),a.minZ=.1,5===arguments.length&&(a.webVROptions=arguments[4]),null==a.webVROptions.trackPosition&&(a.webVROptions.trackPosition=!0),null==a.webVROptions.controllerMeshes&&(a.webVROptions.controllerMeshes=!0),null==a.webVROptions.defaultLightingOnControllers&&(a.webVROptions.defaultLightingOnControllers=!0),a.rotationQuaternion=new o.q,a.webVROptions&&a.webVROptions.positionScale&&(a.deviceScaleFactor=a.webVROptions.positionScale);var c=a.getEngine();return a._onVREnabled=function(e){e&&a.initControllers()},c.onVRRequestPresentComplete.add(a._onVREnabled),c.initWebVR().add(function(e){e.vrDisplay&&a._vrDevice!==e.vrDisplay&&(a._vrDevice=e.vrDisplay,a.setCameraRigMode(Le.a.RIG_MODE_WEBVR,{parentCamera:a,vrDisplay:a._vrDevice,frameData:a._frameData,specs:a._specsVersion}),a._attached&&a.getEngine().enableVR())}),"undefined"!=typeof VRFrameData&&(a._frameData=new VRFrameData),r.onBeforeCameraRenderObservable.add(function(e){e.parent===a&&a.rigParenting&&(a._descendants=a.getDescendants(!0,function(e){var t=a.controllers.some(function(t){return t._mesh===e}),i=-1!==a._rigCameras.indexOf(e);return!t&&!i}),a._descendants.forEach(function(t){t.parent=e}))}),r.onAfterCameraRenderObservable.add(function(e){e.parent===a&&a.rigParenting&&a._descendants.forEach(function(e){e.parent=a})}),a}return l.d(t,e),t.prototype.deviceDistanceToRoomGround=function(){return this._standingMatrix?(this._standingMatrix.getTranslationToRef(this._workingVector),this._deviceRoomPosition.y+this._workingVector.y):this._defaultHeight||0},t.prototype.useStandingMatrix=function(e){var t=this;void 0===e&&(e=function(e){}),this.getEngine().initWebVRAsync().then(function(i){i.vrDisplay&&i.vrDisplay.stageParameters&&i.vrDisplay.stageParameters.sittingToStandingTransform&&t.webVROptions.trackPosition?(t._standingMatrix=new o.j,o.j.FromFloat32ArrayToRefScaled(i.vrDisplay.stageParameters.sittingToStandingTransform,0,1,t._standingMatrix),t.getScene().useRightHandedSystem||t._standingMatrix&&t._standingMatrix.toggleModelMatrixHandInPlace(),e(!0)):e(!1)})},t.prototype.useStandingMatrixAsync=function(){var e=this;return new Promise(function(t){e.useStandingMatrix(function(e){t(e)})})},t.prototype.dispose=function(){this._detachIfAttached(),this.getEngine().onVRRequestPresentComplete.removeCallback(this._onVREnabled),this._updateCacheWhenTrackingDisabledObserver&&this._scene.onBeforeRenderObservable.remove(this._updateCacheWhenTrackingDisabledObserver),e.prototype.dispose.call(this)},t.prototype.getControllerByName=function(e){for(var t=0,i=this.controllers;t<i.length;t++){var r=i[t];if(r.hand===e)return r}return null},Object.defineProperty(t.prototype,"leftController",{get:function(){return this._leftController||(this._leftController=this.getControllerByName("left")),this._leftController},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"rightController",{get:function(){return this._rightController||(this._rightController=this.getControllerByName("right")),this._rightController},enumerable:!0,configurable:!0}),t.prototype.getForwardRay=function(t){return void 0===t&&(t=100),this.leftCamera?e.prototype.getForwardRay.call(this,t,this.leftCamera.getWorldMatrix(),this.leftCamera.globalPosition):e.prototype.getForwardRay.call(this,t)},t.prototype._checkInputs=function(){this._vrDevice&&this._vrDevice.isPresenting&&(this._vrDevice.getFrameData(this._frameData),this.updateFromDevice(this._frameData.pose)),e.prototype._checkInputs.call(this)},t.prototype.updateFromDevice=function(e){e&&e.orientation&&(this.rawPose=e,this._deviceRoomRotationQuaternion.copyFromFloats(e.orientation[0],e.orientation[1],-e.orientation[2],-e.orientation[3]),this.getScene().useRightHandedSystem&&(this._deviceRoomRotationQuaternion.z*=-1,this._deviceRoomRotationQuaternion.w*=-1),this.webVROptions.trackPosition&&this.rawPose.position&&(this._deviceRoomPosition.copyFromFloats(this.rawPose.position[0],this.rawPose.position[1],-this.rawPose.position[2]),this.getScene().useRightHandedSystem&&(this._deviceRoomPosition.z*=-1)),this._poseSet=!0)},t.prototype.attachControl=function(t,i){e.prototype.attachControl.call(this,t,i),this._attached=!0,this._htmlElementAttached=t,i=!Le.a.ForceAttachControlToAlwaysPreventDefault&&i,this._vrDevice&&this.getEngine().enableVR(),window.addEventListener("vrdisplaypresentchange",this._detachIfAttached)},t.prototype.detachControl=function(t){this.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver),this.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver),e.prototype.detachControl.call(this,t),this._attached=!1,this.getEngine().disableVR(),window.removeEventListener("vrdisplaypresentchange",this._detachIfAttached)},t.prototype.getClassName=function(){return"WebVRFreeCamera"},t.prototype.resetToCurrentRotation=function(){this._vrDevice.resetPose()},t.prototype._updateRigCameras=function(){var e=this._rigCameras[0],t=this._rigCameras[1];e.rotationQuaternion.copyFrom(this._deviceRoomRotationQuaternion),t.rotationQuaternion.copyFrom(this._deviceRoomRotationQuaternion),e.position.copyFrom(this._deviceRoomPosition),t.position.copyFrom(this._deviceRoomPosition)},t.prototype._correctPositionIfNotTrackPosition=function(e,t){void 0===t&&(t=!1),this.rawPose&&this.rawPose.position&&!this.webVROptions.trackPosition&&(o.j.TranslationToRef(this.rawPose.position[0],this.rawPose.position[1],-this.rawPose.position[2],this._tmpMatrix),t||this._tmpMatrix.invert(),this._tmpMatrix.multiplyToRef(e,e))},t.prototype._updateCache=function(t){var i=this;this.rotationQuaternion.equals(this._cache.rotationQuaternion)&&this.position.equals(this._cache.position)||(this.updateCacheCalled||(this.updateCacheCalled=!0,this.update()),this.rotationQuaternion.toRotationMatrix(this._workingMatrix),o.x.TransformCoordinatesToRef(this._deviceRoomPosition,this._workingMatrix,this._workingVector),this.devicePosition.subtractToRef(this._workingVector,this._workingVector),o.j.ComposeToRef(this._oneVector,this.rotationQuaternion,this._workingVector,this._deviceToWorld),this._deviceToWorld.getTranslationToRef(this._workingVector),this._workingVector.addInPlace(this.position),this._workingVector.subtractInPlace(this._cache.position),this._deviceToWorld.setTranslation(this._workingVector),this._deviceToWorld.invertToRef(this._worldToDevice),this.controllers.forEach(function(e){e._deviceToWorld.copyFrom(i._deviceToWorld),i._correctPositionIfNotTrackPosition(e._deviceToWorld),e.update()})),t||e.prototype._updateCache.call(this),this.updateCacheCalled=!1},t.prototype._computeDevicePosition=function(){o.x.TransformCoordinatesToRef(this._deviceRoomPosition,this._deviceToWorld,this.devicePosition)},t.prototype.update=function(){this._computeDevicePosition(),o.j.FromQuaternionToRef(this._deviceRoomRotationQuaternion,this._workingMatrix),this._workingMatrix.multiplyToRef(this._deviceToWorld,this._workingMatrix),o.q.FromRotationMatrixToRef(this._workingMatrix,this.deviceRotationQuaternion),this._poseSet&&this.onPoseUpdatedFromDeviceObservable.notifyObservers(null),e.prototype.update.call(this)},t.prototype._getViewMatrix=function(){return o.j.Identity()},t.prototype._getWebVRViewMatrix=function(){var e=this._cameraRigParams.parentCamera;e._updateCache();var t=this._cameraRigParams.left?this._cameraRigParams.frameData.leftViewMatrix:this._cameraRigParams.frameData.rightViewMatrix;return o.j.FromArrayToRef(t,0,this._webvrViewMatrix),this.getScene().useRightHandedSystem||this._webvrViewMatrix.toggleModelMatrixHandInPlace(),this._webvrViewMatrix.getRotationMatrixToRef(this._cameraRotationMatrix),o.x.TransformCoordinatesToRef(this._referencePoint,this._cameraRotationMatrix,this._transformedReferencePoint),this.position.addToRef(this._transformedReferencePoint,this._currentTarget),1!==e.deviceScaleFactor&&(this._webvrViewMatrix.invert(),e.deviceScaleFactor&&(this._webvrViewMatrix.multiplyAtIndex(12,e.deviceScaleFactor),this._webvrViewMatrix.multiplyAtIndex(13,e.deviceScaleFactor),this._webvrViewMatrix.multiplyAtIndex(14,e.deviceScaleFactor)),this._webvrViewMatrix.invert()),e._correctPositionIfNotTrackPosition(this._webvrViewMatrix,!0),e._worldToDevice.multiplyToRef(this._webvrViewMatrix,this._webvrViewMatrix),this._workingMatrix=this._workingMatrix||o.j.Identity(),this._webvrViewMatrix.invertToRef(this._workingMatrix),this._workingMatrix.multiplyToRef(e.getWorldMatrix(),this._workingMatrix),this._workingMatrix.getTranslationToRef(this._globalPosition),this._markSyncedWithParent(),this._webvrViewMatrix},t.prototype._getWebVRProjectionMatrix=function(){var e=this.parent;e._vrDevice.depthNear=e.minZ,e._vrDevice.depthFar=e.maxZ;var t=this._cameraRigParams.left?this._cameraRigParams.frameData.leftProjectionMatrix:this._cameraRigParams.frameData.rightProjectionMatrix;return o.j.FromArrayToRef(t,0,this._projectionMatrix),this.getScene().useRightHandedSystem||this._projectionMatrix.toggleProjectionMatrixHandInPlace(),this._projectionMatrix},t.prototype.initControllers=function(){var e=this;this.controllers=[];var t=this.getScene().gamepadManager;this._onGamepadDisconnectedObserver=t.onGamepadDisconnectedObservable.add(function(t){if(t.type===He.POSE_ENABLED){var i=t;i.defaultModel&&i.defaultModel.setEnabled(!1),"right"===i.hand&&(e._rightController=null),"left"===i.hand&&(e._leftController=null);var r=e.controllers.indexOf(i);-1!==r&&e.controllers.splice(r,1)}}),this._onGamepadConnectedObserver=t.onGamepadConnectedObservable.add(function(t){if(t.type===He.POSE_ENABLED){var i=t;if(e.webVROptions.trackPosition||(i._disableTrackPosition(new o.x("left"==i.hand?-.15:.15,-.5,.25)),e._updateCacheWhenTrackingDisabledObserver||(e._updateCacheWhenTrackingDisabledObserver=e._scene.onBeforeRenderObservable.add(function(){e._updateCache()}))),i.deviceScaleFactor=e.deviceScaleFactor,i._deviceToWorld.copyFrom(e._deviceToWorld),e._correctPositionIfNotTrackPosition(i._deviceToWorld),e.webVROptions.controllerMeshes&&(i.defaultModel?i.defaultModel.setEnabled(!0):i.initControllerMesh(e.getScene(),function(t){if(t.scaling.scaleInPlace(e.deviceScaleFactor),e.onControllerMeshLoadedObservable.notifyObservers(i),e.webVROptions.defaultLightingOnControllers){e._lightOnControllers||(e._lightOnControllers=new ni("vrControllersLight",new o.x(0,1,0),e.getScene()));var r=function(e,t){var i=e.getChildren();i&&0!==i.length&&i.forEach(function(e){t.includedOnlyMeshes.push(e),r(e,t)})};e._lightOnControllers.includedOnlyMeshes.push(t),r(t,e._lightOnControllers)}})),i.attachToPoseControlledCamera(e),-1===e.controllers.indexOf(i)){e.controllers.push(i);for(var r=!1,n=0;n<e.controllers.length;n++)e.controllers[n].controllerType===Jt.VIVE&&(r?e.controllers[n].hand="right":(r=!0,e.controllers[n].hand="left"));e.controllers.length>=2&&e.onControllersAttachedObservable.notifyObservers(e.controllers)}}})},t}(ft),ci=function(e){function t(t){var i=e.call(this,t)||this;return i.onTriggerStateChangedObservable=new n.c,i.onMainButtonStateChangedObservable=new n.c,i.onSecondaryButtonStateChangedObservable=new n.c,i.onPadStateChangedObservable=new n.c,i.onPadValuesChangedObservable=new n.c,i.pad={x:0,y:0},i._changes={pressChanged:!1,touchChanged:!1,valueChanged:!1,changed:!1},i._buttons=new Array(t.buttons.length),i.hand=t.hand,i}return l.d(t,e),t.prototype.onButtonStateChange=function(e){this._onButtonStateChange=e},Object.defineProperty(t.prototype,"defaultModel",{get:function(){return this._defaultModel},enumerable:!0,configurable:!0}),t.prototype.update=function(){e.prototype.update.call(this);for(var t=0;t<this._buttons.length;t++)this._setButtonValue(this.browserGamepad.buttons[t],this._buttons[t],t);this.leftStick.x===this.pad.x&&this.leftStick.y===this.pad.y||(this.pad.x=this.leftStick.x,this.pad.y=this.leftStick.y,this.onPadValuesChangedObservable.notifyObservers(this.pad))},t.prototype._setButtonValue=function(e,t,i){e||(e={pressed:!1,touched:!1,value:0}),t?(this._checkChanges(e,t),this._changes.changed&&(this._onButtonStateChange&&this._onButtonStateChange(this.index,i,e),this._handleButtonChange(i,e,this._changes)),this._buttons[i].pressed=e.pressed,this._buttons[i].touched=e.touched,this._buttons[i].value=e.value<1e-8?0:e.value):this._buttons[i]={pressed:e.pressed,touched:e.touched,value:e.value}},t.prototype._checkChanges=function(e,t){return this._changes.pressChanged=e.pressed!==t.pressed,this._changes.touchChanged=e.touched!==t.touched,this._changes.valueChanged=e.value!==t.value,this._changes.changed=this._changes.pressChanged||this._changes.touchChanged||this._changes.valueChanged,this._changes},t.prototype.dispose=function(){e.prototype.dispose.call(this),this.onTriggerStateChangedObservable.clear(),this.onMainButtonStateChangedObservable.clear(),this.onSecondaryButtonStateChangedObservable.clear(),this.onPadStateChangedObservable.clear(),this.onPadValuesChangedObservable.clear()},t}(ii);!function(e){e[e.A=0]="A",e[e.B=1]="B",e[e.X=2]="X",e[e.Y=3]="Y",e[e.Start=4]="Start",e[e.Back=5]="Back",e[e.LB=6]="LB",e[e.RB=7]="RB",e[e.LeftStick=8]="LeftStick",e[e.RightStick=9]="RightStick"}(oi||(oi={})),function(e){e[e.Up=0]="Up",e[e.Down=1]="Down",e[e.Left=2]="Left",e[e.Right=3]="Right"}(si||(si={}));var li=function(e){function t(t,i,r,o){void 0===o&&(o=!1);var s=e.call(this,t,i,r,0,1,2,3)||this;return s._leftTrigger=0,s._rightTrigger=0,s.onButtonDownObservable=new n.c,s.onButtonUpObservable=new n.c,s.onPadDownObservable=new n.c,s.onPadUpObservable=new n.c,s._buttonA=0,s._buttonB=0,s._buttonX=0,s._buttonY=0,s._buttonBack=0,s._buttonStart=0,s._buttonLB=0,s._buttonRB=0,s._buttonLeftStick=0,s._buttonRightStick=0,s._dPadUp=0,s._dPadDown=0,s._dPadLeft=0,s._dPadRight=0,s._isXboxOnePad=!1,s.type=He.XBOX,s._isXboxOnePad=o,s}return l.d(t,e),t.prototype.onlefttriggerchanged=function(e){this._onlefttriggerchanged=e},t.prototype.onrighttriggerchanged=function(e){this._onrighttriggerchanged=e},Object.defineProperty(t.prototype,"leftTrigger",{get:function(){return this._leftTrigger},set:function(e){this._onlefttriggerchanged&&this._leftTrigger!==e&&this._onlefttriggerchanged(e),this._leftTrigger=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"rightTrigger",{get:function(){return this._rightTrigger},set:function(e){this._onrighttriggerchanged&&this._rightTrigger!==e&&this._onrighttriggerchanged(e),this._rightTrigger=e},enumerable:!0,configurable:!0}),t.prototype.onbuttondown=function(e){this._onbuttondown=e},t.prototype.onbuttonup=function(e){this._onbuttonup=e},t.prototype.ondpaddown=function(e){this._ondpaddown=e},t.prototype.ondpadup=function(e){this._ondpadup=e},t.prototype._setButtonValue=function(e,t,i){return e!==t&&(1===e&&(this._onbuttondown&&this._onbuttondown(i),this.onButtonDownObservable.notifyObservers(i)),0===e&&(this._onbuttonup&&this._onbuttonup(i),this.onButtonUpObservable.notifyObservers(i))),e},t.prototype._setDPadValue=function(e,t,i){return e!==t&&(1===e&&(this._ondpaddown&&this._ondpaddown(i),this.onPadDownObservable.notifyObservers(i)),0===e&&(this._ondpadup&&this._ondpadup(i),this.onPadUpObservable.notifyObservers(i))),e},Object.defineProperty(t.prototype,"buttonA",{get:function(){return this._buttonA},set:function(e){this._buttonA=this._setButtonValue(e,this._buttonA,oi.A)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"buttonB",{get:function(){return this._buttonB},set:function(e){this._buttonB=this._setButtonValue(e,this._buttonB,oi.B)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"buttonX",{get:function(){return this._buttonX},set:function(e){this._buttonX=this._setButtonValue(e,this._buttonX,oi.X)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"buttonY",{get:function(){return this._buttonY},set:function(e){this._buttonY=this._setButtonValue(e,this._buttonY,oi.Y)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"buttonStart",{get:function(){return this._buttonStart},set:function(e){this._buttonStart=this._setButtonValue(e,this._buttonStart,oi.Start)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"buttonBack",{get:function(){return this._buttonBack},set:function(e){this._buttonBack=this._setButtonValue(e,this._buttonBack,oi.Back)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"buttonLB",{get:function(){return this._buttonLB},set:function(e){this._buttonLB=this._setButtonValue(e,this._buttonLB,oi.LB)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"buttonRB",{get:function(){return this._buttonRB},set:function(e){this._buttonRB=this._setButtonValue(e,this._buttonRB,oi.RB)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"buttonLeftStick",{get:function(){return this._buttonLeftStick},set:function(e){this._buttonLeftStick=this._setButtonValue(e,this._buttonLeftStick,oi.LeftStick)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"buttonRightStick",{get:function(){return this._buttonRightStick},set:function(e){this._buttonRightStick=this._setButtonValue(e,this._buttonRightStick,oi.RightStick)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"dPadUp",{get:function(){return this._dPadUp},set:function(e){this._dPadUp=this._setDPadValue(e,this._dPadUp,si.Up)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"dPadDown",{get:function(){return this._dPadDown},set:function(e){this._dPadDown=this._setDPadValue(e,this._dPadDown,si.Down)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"dPadLeft",{get:function(){return this._dPadLeft},set:function(e){this._dPadLeft=this._setDPadValue(e,this._dPadLeft,si.Left)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"dPadRight",{get:function(){return this._dPadRight},set:function(e){this._dPadRight=this._setDPadValue(e,this._dPadRight,si.Right)},enumerable:!0,configurable:!0}),t.prototype.update=function(){e.prototype.update.call(this),this._isXboxOnePad?(this.buttonA=this.browserGamepad.buttons[0].value,this.buttonB=this.browserGamepad.buttons[1].value,this.buttonX=this.browserGamepad.buttons[2].value,this.buttonY=this.browserGamepad.buttons[3].value,this.buttonLB=this.browserGamepad.buttons[4].value,this.buttonRB=this.browserGamepad.buttons[5].value,this.leftTrigger=this.browserGamepad.axes[2],this.rightTrigger=this.browserGamepad.axes[5],this.buttonBack=this.browserGamepad.buttons[9].value,this.buttonStart=this.browserGamepad.buttons[8].value,this.buttonLeftStick=this.browserGamepad.buttons[6].value,this.buttonRightStick=this.browserGamepad.buttons[7].value,this.dPadUp=this.browserGamepad.buttons[11].value,this.dPadDown=this.browserGamepad.buttons[12].value,this.dPadLeft=this.browserGamepad.buttons[13].value,this.dPadRight=this.browserGamepad.buttons[14].value):(this.buttonA=this.browserGamepad.buttons[0].value,this.buttonB=this.browserGamepad.buttons[1].value,this.buttonX=this.browserGamepad.buttons[2].value,this.buttonY=this.browserGamepad.buttons[3].value,this.buttonLB=this.browserGamepad.buttons[4].value,this.buttonRB=this.browserGamepad.buttons[5].value,this.leftTrigger=this.browserGamepad.buttons[6].value,this.rightTrigger=this.browserGamepad.buttons[7].value,this.buttonBack=this.browserGamepad.buttons[8].value,this.buttonStart=this.browserGamepad.buttons[9].value,this.buttonLeftStick=this.browserGamepad.buttons[10].value,this.buttonRightStick=this.browserGamepad.buttons[11].value,this.dPadUp=this.browserGamepad.buttons[12].value,this.dPadDown=this.browserGamepad.buttons[13].value,this.dPadLeft=this.browserGamepad.buttons[14].value,this.dPadRight=this.browserGamepad.buttons[15].value)},t.prototype.dispose=function(){e.prototype.dispose.call(this),this.onButtonDownObservable.clear(),this.onButtonUpObservable.clear(),this.onPadDownObservable.clear(),this.onPadUpObservable.clear()},t}(He),ui=i(31),hi=i(33),di=function(e){function t(t,i,r,n,o,s){void 0===r&&(r=null),void 0===o&&(o=_.a.TEXTURE_TRILINEAR_SAMPLINGMODE),void 0===s&&(s=_.a.TEXTUREFORMAT_RGBA);var a=e.call(this,null,r,!n,void 0,o,void 0,void 0,void 0,void 0,s)||this;a.name=t,a._engine=a.getScene().getEngine(),a.wrapU=Ve.a.CLAMP_ADDRESSMODE,a.wrapV=Ve.a.CLAMP_ADDRESSMODE,a._generateMipMaps=n,i.getContext?(a._canvas=i,a._texture=a._engine.createDynamicTexture(i.width,i.height,n,o)):(a._canvas=document.createElement("canvas"),i.width||0===i.width?a._texture=a._engine.createDynamicTexture(i.width,i.height,n,o):a._texture=a._engine.createDynamicTexture(i,i,n,o));var c=a.getSize();return a._canvas.width=c.width,a._canvas.height=c.height,a._context=a._canvas.getContext("2d"),a}return l.d(t,e),t.prototype.getClassName=function(){return"DynamicTexture"},Object.defineProperty(t.prototype,"canRescale",{get:function(){return!0},enumerable:!0,configurable:!0}),t.prototype._recreate=function(e){this._canvas.width=e.width,this._canvas.height=e.height,this.releaseInternalTexture(),this._texture=this._engine.createDynamicTexture(e.width,e.height,this._generateMipMaps,this.samplingMode)},t.prototype.scale=function(e){var t=this.getSize();t.width*=e,t.height*=e,this._recreate(t)},t.prototype.scaleTo=function(e,t){var i=this.getSize();i.width=e,i.height=t,this._recreate(i)},t.prototype.getContext=function(){return this._context},t.prototype.clear=function(){var e=this.getSize();this._context.fillRect(0,0,e.width,e.height)},t.prototype.update=function(e,t){void 0===t&&(t=!1),this._engine.updateDynamicTexture(this._texture,this._canvas,void 0===e||e,t,this._format||void 0)},t.prototype.drawText=function(e,t,i,r,n,o,s,a){void 0===a&&(a=!0);var c=this.getSize();if(o&&(this._context.fillStyle=o,this._context.fillRect(0,0,c.width,c.height)),this._context.font=r,null==t){var l=this._context.measureText(e);t=(c.width-l.width)/2}if(null==i){var u=parseInt(r.replace(/\D/g,""));i=c.height/2+u/3.65}this._context.fillStyle=n,this._context.fillText(e,t,i),a&&this.update(s)},t.prototype.clone=function(){var e=this.getScene();if(!e)return this;var i=this.getSize(),r=new t(this.name,i,e,this._generateMipMaps);return r.hasAlpha=this.hasAlpha,r.level=this.level,r.wrapU=this.wrapU,r.wrapV=this.wrapV,r},t.prototype.serialize=function(){var t=this.getScene();t&&!t.isReady()&&p.a.Warn("The scene must be ready before serializing the dynamic texture");var i=e.prototype.serialize.call(this);return i.base64String=this._canvas.toDataURL(),i.invertY=this._invertY,i.samplingMode=this.samplingMode,i},t.prototype._rebuild=function(){this.update()},t}(Ve.a),fi=(i(78),i(53),i(79),"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n#include<imageProcessingDeclaration>\n#include<helperFunctions>\n#include<imageProcessingFunctions>\nvoid main(void)\n{\nvec4 result=texture2D(textureSampler,vUV);\n#ifdef IMAGEPROCESSING\n#ifndef FROMLINEARSPACE\n\nresult.rgb=toLinearSpace(result.rgb);\n#endif\nresult=applyImageProcessing(result);\n#else\n\n#ifdef FROMLINEARSPACE\nresult=applyImageProcessing(result);\n#endif\n#endif\ngl_FragColor=result;\n}");St.a.ShadersStore.imageProcessingPixelShader=fi;var pi=function(e){function t(t,i,r,n,o,s,a,c){void 0===r&&(r=null),void 0===a&&(a=_.a.TEXTURETYPE_UNSIGNED_INT);var l=e.call(this,t,"imageProcessing",[],[],i,r,n,o,s,null,a,"postprocess",null,!0)||this;return l._fromLinearSpace=!0,l._defines={IMAGEPROCESSING:!1,VIGNETTE:!1,VIGNETTEBLENDMODEMULTIPLY:!1,VIGNETTEBLENDMODEOPAQUE:!1,TONEMAPPING:!1,TONEMAPPING_ACES:!1,CONTRAST:!1,COLORCURVES:!1,COLORGRADING:!1,COLORGRADING3D:!1,FROMLINEARSPACE:!1,SAMPLER3DGREENDEPTH:!1,SAMPLER3DBGRMAP:!1,IMAGEPROCESSINGPOSTPROCESS:!1,EXPOSURE:!1},c?(c.applyByPostProcess=!0,l._attachImageProcessingConfiguration(c,!0),l.fromLinearSpace=!1):(l._attachImageProcessingConfiguration(null,!0),l.imageProcessingConfiguration.applyByPostProcess=!0),l.onApply=function(e){l.imageProcessingConfiguration.bind(e,l.aspectRatio)},l}return l.d(t,e),Object.defineProperty(t.prototype,"imageProcessingConfiguration",{get:function(){return this._imageProcessingConfiguration},set:function(e){this._attachImageProcessingConfiguration(e)},enumerable:!0,configurable:!0}),t.prototype._attachImageProcessingConfiguration=function(e,t){var i=this;if(void 0===t&&(t=!1),e!==this._imageProcessingConfiguration){if(this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),e)this._imageProcessingConfiguration=e;else{var r=null,n=this.getEngine(),o=this.getCamera();if(o)r=o.getScene();else if(n&&n.scenes){var s=n.scenes;r=s[s.length-1]}else r=R.a.LastCreatedScene;this._imageProcessingConfiguration=r.imageProcessingConfiguration}this._imageProcessingConfiguration&&(this._imageProcessingObserver=this._imageProcessingConfiguration.onUpdateParameters.add(function(){i._updateParameters()})),t||this._updateParameters()}},Object.defineProperty(t.prototype,"colorCurves",{get:function(){return this.imageProcessingConfiguration.colorCurves},set:function(e){this.imageProcessingConfiguration.colorCurves=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"colorCurvesEnabled",{get:function(){return this.imageProcessingConfiguration.colorCurvesEnabled},set:function(e){this.imageProcessingConfiguration.colorCurvesEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"colorGradingTexture",{get:function(){return this.imageProcessingConfiguration.colorGradingTexture},set:function(e){this.imageProcessingConfiguration.colorGradingTexture=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"colorGradingEnabled",{get:function(){return this.imageProcessingConfiguration.colorGradingEnabled},set:function(e){this.imageProcessingConfiguration.colorGradingEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"exposure",{get:function(){return this.imageProcessingConfiguration.exposure},set:function(e){this.imageProcessingConfiguration.exposure=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"toneMappingEnabled",{get:function(){return this._imageProcessingConfiguration.toneMappingEnabled},set:function(e){this._imageProcessingConfiguration.toneMappingEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"contrast",{get:function(){return this.imageProcessingConfiguration.contrast},set:function(e){this.imageProcessingConfiguration.contrast=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"vignetteStretch",{get:function(){return this.imageProcessingConfiguration.vignetteStretch},set:function(e){this.imageProcessingConfiguration.vignetteStretch=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"vignetteCentreX",{get:function(){return this.imageProcessingConfiguration.vignetteCentreX},set:function(e){this.imageProcessingConfiguration.vignetteCentreX=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"vignetteCentreY",{get:function(){return this.imageProcessingConfiguration.vignetteCentreY},set:function(e){this.imageProcessingConfiguration.vignetteCentreY=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"vignetteWeight",{get:function(){return this.imageProcessingConfiguration.vignetteWeight},set:function(e){this.imageProcessingConfiguration.vignetteWeight=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"vignetteColor",{get:function(){return this.imageProcessingConfiguration.vignetteColor},set:function(e){this.imageProcessingConfiguration.vignetteColor=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"vignetteCameraFov",{get:function(){return this.imageProcessingConfiguration.vignetteCameraFov},set:function(e){this.imageProcessingConfiguration.vignetteCameraFov=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"vignetteBlendMode",{get:function(){return this.imageProcessingConfiguration.vignetteBlendMode},set:function(e){this.imageProcessingConfiguration.vignetteBlendMode=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"vignetteEnabled",{get:function(){return this.imageProcessingConfiguration.vignetteEnabled},set:function(e){this.imageProcessingConfiguration.vignetteEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"fromLinearSpace",{get:function(){return this._fromLinearSpace},set:function(e){this._fromLinearSpace!==e&&(this._fromLinearSpace=e,this._updateParameters())},enumerable:!0,configurable:!0}),t.prototype.getClassName=function(){return"ImageProcessingPostProcess"},t.prototype._updateParameters=function(){this._defines.FROMLINEARSPACE=this._fromLinearSpace,this.imageProcessingConfiguration.prepareDefines(this._defines,!0);var e="";for(var t in this._defines)this._defines[t]&&(e+="#define "+t+";\r\n");var i=["textureSampler"],r=["scale"];ui.a&&(ui.a.PrepareSamplers(i,this._defines),ui.a.PrepareUniforms(r,this._defines)),this.updateEffect(e,r,i)},t.prototype.dispose=function(t){e.prototype.dispose.call(this,t),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),this._imageProcessingConfiguration&&(this.imageProcessingConfiguration.applyByPostProcess=!1)},l.c([Object(w.c)()],t.prototype,"_fromLinearSpace",void 0),t}(Mt),_i=i(13),gi=i(4);de.a._GroundMeshParser=function(e,t){return mi.Parse(e,t)};var mi=function(e){function t(t,i){var r=e.call(this,t,i)||this;return r.generateOctree=!1,r}return l.d(t,e),t.prototype.getClassName=function(){return"GroundMesh"},Object.defineProperty(t.prototype,"subdivisions",{get:function(){return Math.min(this._subdivisionsX,this._subdivisionsY)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"subdivisionsX",{get:function(){return this._subdivisionsX},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"subdivisionsY",{get:function(){return this._subdivisionsY},enumerable:!0,configurable:!0}),t.prototype.optimize=function(e,t){void 0===t&&(t=32),this._subdivisionsX=e,this._subdivisionsY=e,this.subdivide(e);this.createOrUpdateSubmeshesOctree&&this.createOrUpdateSubmeshesOctree(t)},t.prototype.getHeightAtCoordinates=function(e,t){var i=this.getWorldMatrix(),r=o.t.Matrix[5];i.invertToRef(r);var n=o.t.Vector3[8];if(o.x.TransformCoordinatesFromFloatsToRef(e,0,t,r,n),e=n.x,t=n.z,e<this._minX||e>this._maxX||t<this._minZ||t>this._maxZ)return this.position.y;this._heightQuads&&0!=this._heightQuads.length||(this._initHeightQuads(),this._computeHeightQuads());var s=this._getFacetAt(e,t),a=-(s.x*e+s.z*t+s.w)/s.y;return o.x.TransformCoordinatesFromFloatsToRef(0,a,0,i,n),n.y},t.prototype.getNormalAtCoordinates=function(e,t){var i=new o.x(0,1,0);return this.getNormalAtCoordinatesToRef(e,t,i),i},t.prototype.getNormalAtCoordinatesToRef=function(e,t,i){var r=this.getWorldMatrix(),n=o.t.Matrix[5];r.invertToRef(n);var s=o.t.Vector3[8];if(o.x.TransformCoordinatesFromFloatsToRef(e,0,t,n,s),e=s.x,t=s.z,e<this._minX||e>this._maxX||t<this._minZ||t>this._maxZ)return this;this._heightQuads&&0!=this._heightQuads.length||(this._initHeightQuads(),this._computeHeightQuads());var a=this._getFacetAt(e,t);return o.x.TransformNormalFromFloatsToRef(a.x,a.y,a.z,r,i),this},t.prototype.updateCoordinateHeights=function(){return this._heightQuads&&0!=this._heightQuads.length||this._initHeightQuads(),this._computeHeightQuads(),this},t.prototype._getFacetAt=function(e,t){var i=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},t.prototype._initHeightQuads=function(){var e=this._subdivisionsX,t=this._subdivisionsY;this._heightQuads=new Array;for(var i=0;i<t;i++)for(var r=0;r<e;r++){var n={slope:o.w.Zero(),facet1:new o.y(0,0,0,0),facet2:new o.y(0,0,0,0)};this._heightQuads[i*e+r]=n}return this},t.prototype._computeHeightQuads=function(){var e=this.getVerticesData(gi.b.PositionKind);if(!e)return this;for(var t=o.t.Vector3[3],i=o.t.Vector3[2],r=o.t.Vector3[1],n=o.t.Vector3[0],s=o.t.Vector3[4],a=o.t.Vector3[5],c=o.t.Vector3[6],l=o.t.Vector3[7],u=o.t.Vector3[8],h=0,d=0,f=0,p=0,_=0,g=0,m=0,v=this._subdivisionsX,y=this._subdivisionsY,b=0;b<y;b++)for(var T=0;T<v;T++){h=3*T,d=b*(v+1)*3,f=(b+1)*(v+1)*3,t.x=e[d+h],t.y=e[d+h+1],t.z=e[d+h+2],i.x=e[d+h+3],i.y=e[d+h+4],i.z=e[d+h+5],r.x=e[f+h],r.y=e[f+h+1],r.z=e[f+h+2],n.x=e[f+h+3],n.y=e[f+h+4],n.z=e[f+h+5],p=(n.z-t.z)/(n.x-t.x),_=t.z-p*t.x,i.subtractToRef(t,s),r.subtractToRef(t,a),n.subtractToRef(t,c),o.x.CrossToRef(c,a,l),o.x.CrossToRef(s,c,u),l.normalize(),u.normalize(),g=-(l.x*t.x+l.y*t.y+l.z*t.z),m=-(u.x*i.x+u.y*i.y+u.z*i.z);var E=this._heightQuads[b*v+T];E.slope.copyFromFloats(p,_),E.facet1.copyFromFloats(l.x,l.y,l.z,g),E.facet2.copyFromFloats(u.x,u.y,u.z,m)}return this},t.prototype.serialize=function(t){e.prototype.serialize.call(this,t),t.subdivisionsX=this._subdivisionsX,t.subdivisionsY=this._subdivisionsY,t.minX=this._minX,t.maxX=this._maxX,t.minZ=this._minZ,t.maxZ=this._maxZ,t.width=this._width,t.height=this._height},t.Parse=function(e,i){var r=new t(e.name,i);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},t}(de.a);_i.a.CreateGround=function(e){var t,i,r=[],n=[],s=[],a=[],c=e.width||1,l=e.height||1,u=e.subdivisionsX||e.subdivisions||1,h=e.subdivisionsY||e.subdivisions||1;for(t=0;t<=h;t++)for(i=0;i<=u;i++){var d=new o.x(i*c/u-c/2,0,(h-t)*l/h-l/2),f=new o.x(0,1,0);n.push(d.x,d.y,d.z),s.push(f.x,f.y,f.z),a.push(i/u,1-t/h)}for(t=0;t<h;t++)for(i=0;i<u;i++)r.push(i+1+(t+1)*(u+1)),r.push(i+1+t*(u+1)),r.push(i+t*(u+1)),r.push(i+(t+1)*(u+1)),r.push(i+1+(t+1)*(u+1)),r.push(i+t*(u+1));var p=new _i.a;return p.indices=r,p.positions=n,p.normals=s,p.uvs=a,p},_i.a.CreateTiledGround=function(e){var t,i,r,n,s=void 0!==e.xmin&&null!==e.xmin?e.xmin:-1,a=void 0!==e.zmin&&null!==e.zmin?e.zmin:-1,c=void 0!==e.xmax&&null!==e.xmax?e.xmax:1,l=void 0!==e.zmax&&null!==e.zmax?e.zmax:1,u=e.subdivisions||{w:1,h:1},h=e.precision||{w:1,h:1},d=new Array,f=new Array,p=new Array,_=new Array;u.h=u.h<1?1:u.h,u.w=u.w<1?1:u.w,h.w=h.w<1?1:h.w,h.h=h.h<1?1:h.h;var g=(c-s)/u.w,m=(l-a)/u.h;function v(e,r,n,s){var a=f.length/3,c=h.w+1;for(t=0;t<h.h;t++)for(i=0;i<h.w;i++){var l=[a+i+t*c,a+(i+1)+t*c,a+(i+1)+(t+1)*c,a+i+(t+1)*c];d.push(l[1]),d.push(l[2]),d.push(l[3]),d.push(l[0]),d.push(l[1]),d.push(l[3])}var u=o.x.Zero(),g=new o.x(0,1,0);for(t=0;t<=h.h;t++)for(u.z=t*(s-r)/h.h+r,i=0;i<=h.w;i++)u.x=i*(n-e)/h.w+e,u.y=0,f.push(u.x,u.y,u.z),p.push(g.x,g.y,g.z),_.push(i/h.w,t/h.h)}for(r=0;r<u.h;r++)for(n=0;n<u.w;n++)v(s+n*g,a+r*m,s+(n+1)*g,a+(r+1)*m);var y=new _i.a;return y.indices=d,y.positions=f,y.normals=p,y.uvs=_,y},_i.a.CreateGroundFromHeightMap=function(e){var t,i,r=[],n=[],s=[],a=[],c=e.colorFilter||new o.e(.3,.59,.11),l=e.alphaFilter||0;for(t=0;t<=e.subdivisions;t++)for(i=0;i<=e.subdivisions;i++){var u=new o.x(i*e.width/e.subdivisions-e.width/2,0,(e.subdivisions-t)*e.height/e.subdivisions-e.height/2),h=4*(((u.x+e.width/2)/e.width*(e.bufferWidth-1)|0)+((1-(u.z+e.height/2)/e.height)*(e.bufferHeight-1)|0)*e.bufferWidth),d=e.buffer[h]/255,f=e.buffer[h+1]/255,p=e.buffer[h+2]/255,_=e.buffer[h+3]/255,g=d*c.r+f*c.g+p*c.b;u.y=_>=l?e.minHeight+(e.maxHeight-e.minHeight)*g:e.minHeight-o.h,n.push(u.x,u.y,u.z),s.push(0,0,0),a.push(i/e.subdivisions,1-t/e.subdivisions)}for(t=0;t<e.subdivisions;t++)for(i=0;i<e.subdivisions;i++){var m=i+1+(t+1)*(e.subdivisions+1),v=i+1+t*(e.subdivisions+1),y=i+t*(e.subdivisions+1),b=i+(t+1)*(e.subdivisions+1),T=n[3*m+1]>=e.minHeight,E=n[3*v+1]>=e.minHeight,x=n[3*y+1]>=e.minHeight;T&&E&&x&&(r.push(m),r.push(v),r.push(y)),n[3*b+1]>=e.minHeight&&T&&x&&(r.push(b),r.push(m),r.push(y))}_i.a.ComputeNormals(n,r,s);var A=new _i.a;return A.indices=r,A.positions=n,A.normals=s,A.uvs=a,A},de.a.CreateGround=function(e,t,i,r,n,o){var s={width:t,height:i,subdivisions:r,updatable:o};return vi.CreateGround(e,s,n)},de.a.CreateTiledGround=function(e,t,i,r,n,o,s,a,c){var l={xmin:t,zmin:i,xmax:r,zmax:n,subdivisions:o,precision:s,updatable:c};return vi.CreateTiledGround(e,l,a)},de.a.CreateGroundFromHeightMap=function(e,t,i,r,n,o,s,a,c,l,u){var h={width:i,height:r,subdivisions:n,minHeight:o,maxHeight:s,updatable:c,onReady:l,alphaFilter:u};return vi.CreateGroundFromHeightMap(e,t,h,a)};var vi=function(){function e(){}return e.CreateGround=function(e,t,i){var r=new mi(e,i);return r._setReady(!1),r._subdivisionsX=t.subdivisionsX||t.subdivisions||1,r._subdivisionsY=t.subdivisionsY||t.subdivisions||1,r._width=t.width||1,r._height=t.height||1,r._maxX=r._width/2,r._maxZ=r._height/2,r._minX=-r._maxX,r._minZ=-r._maxZ,_i.a.CreateGround(t).applyToMesh(r,t.updatable),r._setReady(!0),r},e.CreateTiledGround=function(e,t,i){var r=new de.a(e,i);return _i.a.CreateTiledGround(t).applyToMesh(r,t.updatable),r},e.CreateGroundFromHeightMap=function(e,t,i,r){var n=i.width||10,s=i.height||10,a=i.subdivisions||1,c=i.minHeight||0,l=i.maxHeight||1,u=i.colorFilter||new o.e(.3,.59,.11),h=i.alphaFilter||0,d=i.updatable,f=i.onReady,p=new mi(e,r);p._subdivisionsX=a,p._subdivisionsY=a,p._width=n,p._height=s,p._maxX=p._width/2,p._maxZ=p._height/2,p._minX=-p._maxX,p._minZ=-p._maxZ,p._setReady(!1);return ve.h.LoadImage(t,function(e){var t=document.createElement("canvas"),i=t.getContext("2d");if(!i)throw new Error("Unable to get 2d context for CreateGroundFromHeightMap");if(!r.isDisposed){var o=e.width,_=e.height;t.width=o,t.height=_,i.drawImage(e,0,0);var g=i.getImageData(0,0,o,_).data;_i.a.CreateGroundFromHeightMap({width:n,height:s,subdivisions:a,minHeight:c,maxHeight:l,colorFilter:u,buffer:g,bufferWidth:o,bufferHeight:_,alphaFilter:h}).applyToMesh(p,d),f&&f(p),p._setReady(!0)}},function(){},r.offlineProvider),p},e}();_i.a.CreateTorus=function(e){for(var t=[],i=[],r=[],n=[],s=e.diameter||1,a=e.thickness||.5,c=e.tessellation||16,l=0===e.sideOrientation?0:e.sideOrientation||_i.a.DEFAULTSIDE,u=c+1,h=0;h<=c;h++)for(var d=h/c,f=h*Math.PI*2/c-Math.PI/2,p=o.j.Translation(s/2,0,0).multiply(o.j.RotationY(f)),_=0;_<=c;_++){var g=1-_/c,m=_*Math.PI*2/c+Math.PI,v=Math.cos(m),y=Math.sin(m),b=new o.x(v,y,0),T=b.scale(a/2),E=new o.w(d,g);T=o.x.TransformCoordinates(T,p),b=o.x.TransformNormal(b,p),i.push(T.x,T.y,T.z),r.push(b.x,b.y,b.z),n.push(E.x,E.y);var x=(h+1)%u,A=(_+1)%u;t.push(h*u+_),t.push(h*u+A),t.push(x*u+_),t.push(h*u+A),t.push(x*u+A),t.push(x*u+_)}_i.a._ComputeSides(l,i,t,r,n,e.frontUVs,e.backUVs);var P=new _i.a;return P.indices=t,P.positions=i,P.normals=r,P.uvs=n,P},de.a.CreateTorus=function(e,t,i,r,n,o,s){var a={diameter:t,thickness:i,tessellation:r,sideOrientation:s,updatable:o};return yi.CreateTorus(e,a,n)};var yi=function(){function e(){}return e.CreateTorus=function(e,t,i){var r=new de.a(e,i);return t.sideOrientation=de.a._GetDefaultSideOrientation(t.sideOrientation),r._originalBuilderSideOrientation=t.sideOrientation,_i.a.CreateTorus(t).applyToMesh(r,t.updatable),r},e}(),bi=i(61),Ti=function(){function e(t,i){if(void 0===i&&(i=null),this.scene=t,this._pointerDownOnMeshAsked=!1,this._isActionableMesh=!1,this._teleportationRequestInitiated=!1,this._teleportationBackRequestInitiated=!1,this._rotationRightAsked=!1,this._rotationLeftAsked=!1,this._dpadPressed=!0,this._activePointer=!1,this._id=e._idCounter++,i)this._gazeTracker=i.clone("gazeTracker");else{this._gazeTracker=de.a.CreateTorus("gazeTracker",.0035,.0025,20,t,!1),this._gazeTracker.bakeCurrentTransformIntoVertices(),this._gazeTracker.isPickable=!1,this._gazeTracker.isVisible=!1;var r=new hi.a("targetMat",t);r.specularColor=o.e.Black(),r.emissiveColor=new o.e(.7,.7,.7),r.backFaceCulling=!1,this._gazeTracker.material=r}}return e.prototype._getForwardRay=function(e){return new ei.a(o.x.Zero(),new o.x(0,0,e))},e.prototype._selectionPointerDown=function(){this._pointerDownOnMeshAsked=!0,this._currentHit&&this.scene.simulatePointerDown(this._currentHit,{pointerId:this._id})},e.prototype._selectionPointerUp=function(){this._currentHit&&this.scene.simulatePointerUp(this._currentHit,{pointerId:this._id}),this._pointerDownOnMeshAsked=!1},e.prototype._activatePointer=function(){this._activePointer=!0},e.prototype._deactivatePointer=function(){this._activePointer=!1},e.prototype._updatePointerDistance=function(e){void 0===e&&(e=100)},e.prototype.dispose=function(){this._interactionsEnabled=!1,this._teleportationEnabled=!1,this._gazeTracker&&this._gazeTracker.dispose()},e._idCounter=0,e}(),Ei=function(e){function t(t,i,r){var n=e.call(this,i,r)||this;n.webVRController=t,n._laserPointer=de.a.CreateCylinder("laserPointer",1,.004,2e-4,20,1,i,!1);var s=new hi.a("laserPointerMat",i);if(s.emissiveColor=new o.e(.7,.7,.7),s.alpha=.6,n._laserPointer.material=s,n._laserPointer.rotation.x=Math.PI/2,n._laserPointer.position.z=-.5,n._laserPointer.isVisible=!1,n._laserPointer.isPickable=!1,!t.mesh){var a=new de.a("preloadControllerMesh",i),c=new de.a(ii.POINTING_POSE,i);c.rotation.x=-.7,a.addChild(c),t.attachToMesh(a)}return n._setLaserPointerParent(t.mesh),n._meshAttachedObserver=t._meshAttachedObservable.add(function(e){n._setLaserPointerParent(e)}),n}return l.d(t,e),t.prototype._getForwardRay=function(e){return this.webVRController.getForwardRay(e)},t.prototype._activatePointer=function(){e.prototype._activatePointer.call(this),this._laserPointer.isVisible=!0},t.prototype._deactivatePointer=function(){e.prototype._deactivatePointer.call(this),this._laserPointer.isVisible=!1},t.prototype._setLaserPointerColor=function(e){this._laserPointer.material.emissiveColor=e},t.prototype._setLaserPointerParent=function(e){var t=function(e){e.isPickable=!1,e.getChildMeshes().forEach(function(e){t(e)})};t(e);var i=e.getChildren(void 0,!1),r=e;this.webVRController._pointingPoseNode=null;for(var n=0;n<i.length;n++)if(i[n].name&&i[n].name.indexOf(ii.POINTING_POSE)>=0){r=i[n],this.webVRController._pointingPoseNode=r;break}this._laserPointer.parent=r},t.prototype._updatePointerDistance=function(e){void 0===e&&(e=100),this._laserPointer.scaling.y=e,this._laserPointer.position.z=-e/2},t.prototype.dispose=function(){e.prototype.dispose.call(this),this._laserPointer.dispose(),this._meshAttachedObserver&&this.webVRController._meshAttachedObservable.remove(this._meshAttachedObserver)},t}(Ti),xi=function(e){function t(t,i){var r=e.call(this,i)||this;return r.getCamera=t,r}return l.d(t,e),t.prototype._getForwardRay=function(e){var t=this.getCamera();return t?t.getForwardRay(e):new ei.a(o.x.Zero(),o.x.Forward())},t}(Ti),Ai=function(){function e(e,t){void 0===t&&(t={});var i=this;if(this.webVROptions=t,this._webVRsupported=!1,this._webVRready=!1,this._webVRrequesting=!1,this._webVRpresenting=!1,this._fullscreenVRpresenting=!1,this.onEnteringVRObservable=new n.c,this.onExitingVRObservable=new n.c,this.onControllerMeshLoadedObservable=new n.c,this._useCustomVRButton=!1,this._teleportationRequested=!1,this._teleportActive=!1,this._floorMeshesCollection=[],this._rotationAllowed=!0,this._teleportBackwardsVector=new o.x(0,-1,-1),this._isDefaultTeleportationTarget=!0,this._teleportationFillColor="#444444",this._teleportationBorderColor="#FFFFFF",this._rotationAngle=0,this._haloCenter=new o.x(0,0,0),this._padSensibilityUp=.65,this._padSensibilityDown=.35,this._leftController=null,this._rightController=null,this.onNewMeshSelected=new n.c,this.onNewMeshPicked=new n.c,this.onBeforeCameraTeleport=new n.c,this.onAfterCameraTeleport=new n.c,this.onSelectedMeshUnselected=new n.c,this.teleportationEnabled=!0,this._teleportationInitialized=!1,this._interactionsEnabled=!1,this._interactionsRequested=!1,this._displayGaze=!0,this._displayLaserPointer=!0,this.updateGazeTrackerScale=!0,this.updateGazeTrackerColor=!0,this._onResize=function(){i.moveButtonToBottomRight(),i._fullscreenVRpresenting&&i._webVRready&&i.exitVR()},this._onFullscreenChange=function(){void 0!==document.fullscreen?i._fullscreenVRpresenting=document.fullscreen:void 0!==document.mozFullScreen?i._fullscreenVRpresenting=document.mozFullScreen:void 0!==document.webkitIsFullScreen?i._fullscreenVRpresenting=document.webkitIsFullScreen:void 0!==document.msIsFullScreen?i._fullscreenVRpresenting=document.msIsFullScreen:void 0!==document.msFullscreenElement&&(i._fullscreenVRpresenting=document.msFullscreenElement),!i._fullscreenVRpresenting&&i._canvas&&(i.exitVR(),i._useCustomVRButton||(i._btnVR.style.top=i._canvas.offsetTop+i._canvas.offsetHeight-70+"px",i._btnVR.style.left=i._canvas.offsetLeft+i._canvas.offsetWidth-100+"px"))},this._cachedAngularSensibility={angularSensibilityX:null,angularSensibilityY:null,angularSensibility:null},this.beforeRender=function(){i._leftController&&i._leftController._activePointer&&i._castRayAndSelectObject(i._leftController),i._rightController&&i._rightController._activePointer&&i._castRayAndSelectObject(i._rightController),i._noControllerIsActive?i._castRayAndSelectObject(i._cameraGazer):i._cameraGazer._gazeTracker.isVisible=!1},this._onNewGamepadConnected=function(e){if(e.type!==He.POSE_ENABLED)e.leftStick&&e.onleftstickchanged(function(e){i._teleportationInitialized&&i.teleportationEnabled&&(!i._leftController&&!i._rightController||i._leftController&&!i._leftController._activePointer&&i._rightController&&!i._rightController._activePointer)&&(i._checkTeleportWithRay(e,i._cameraGazer),i._checkTeleportBackwards(e,i._cameraGazer))}),e.rightStick&&e.onrightstickchanged(function(e){i._teleportationInitialized&&i._checkRotate(e,i._cameraGazer)}),e.type===He.XBOX&&(e.onbuttondown(function(e){i._interactionsEnabled&&e===oi.A&&i._cameraGazer._selectionPointerDown()}),e.onbuttonup(function(e){i._interactionsEnabled&&e===oi.A&&i._cameraGazer._selectionPointerUp()}));else{var t=e,r=new Ei(t,i._scene,i._cameraGazer._gazeTracker);"right"===t.hand||i._leftController&&i._leftController.webVRController!=t?i._rightController=r:i._leftController=r,i._tryEnableInteractionOnController(r)}},this._tryEnableInteractionOnController=function(e){i._interactionsRequested&&!e._interactionsEnabled&&i._enableInteractionOnController(e),i._teleportationRequested&&!e._teleportationEnabled&&i._enableTeleportationOnController(e)},this._onNewGamepadDisconnected=function(e){e instanceof ci&&("left"===e.hand&&null!=i._leftController&&(i._leftController.dispose(),i._leftController=null),"right"===e.hand&&null!=i._rightController&&(i._rightController.dispose(),i._rightController=null))},this._workingVector=o.x.Zero(),this._workingQuaternion=o.q.Identity(),this._workingMatrix=o.j.Identity(),this._scene=e,this._canvas=e.getEngine().getRenderingCanvas(),void 0===t.createFallbackVRDeviceOrientationFreeCamera&&(t.createFallbackVRDeviceOrientationFreeCamera=!0),void 0===t.createDeviceOrientationCamera&&(t.createDeviceOrientationCamera=!0),void 0===t.laserToggle&&(t.laserToggle=!0),void 0===t.defaultHeight&&(t.defaultHeight=1.7),t.useCustomVRButton&&(this._useCustomVRButton=!0,t.customVRButton&&(this._btnVR=t.customVRButton)),t.rayLength&&(this._rayLength=t.rayLength),this._defaultHeight=t.defaultHeight,t.positionScale&&(this._rayLength*=t.positionScale,this._defaultHeight*=t.positionScale),this._hasEnteredVR=!1,this._scene.activeCamera?this._position=this._scene.activeCamera.position.clone():this._position=new o.x(0,this._defaultHeight,0),t.createDeviceOrientationCamera||!this._scene.activeCamera){if(this._deviceOrientationCamera=new gt("deviceOrientationVRHelper",this._position.clone(),e),this._scene.activeCamera&&(this._deviceOrientationCamera.minZ=this._scene.activeCamera.minZ,this._deviceOrientationCamera.maxZ=this._scene.activeCamera.maxZ,this._scene.activeCamera instanceof dt&&this._scene.activeCamera.rotation)){var r=this._scene.activeCamera;r.rotationQuaternion?this._deviceOrientationCamera.rotationQuaternion.copyFrom(r.rotationQuaternion):this._deviceOrientationCamera.rotationQuaternion.copyFrom(o.q.RotationYawPitchRoll(r.rotation.y,r.rotation.x,r.rotation.z)),this._deviceOrientationCamera.rotation=r.rotation.clone()}this._scene.activeCamera=this._deviceOrientationCamera,this._canvas&&this._scene.activeCamera.attachControl(this._canvas)}else this._existingCamera=this._scene.activeCamera;if(t.createFallbackVRDeviceOrientationFreeCamera&&(this._vrDeviceOrientationCamera=new Zt("VRDeviceOrientationVRHelper",this._position,this._scene),this._vrDeviceOrientationCamera.angularSensibility=Number.MAX_VALUE),this._webVRCamera=new ai("WebVRHelper",this._position,this._scene,t),this._webVRCamera.useStandingMatrix(),this._cameraGazer=new xi(function(){return i.currentVRCamera},e),!this._useCustomVRButton){this._btnVR=document.createElement("BUTTON"),this._btnVR.className="babylonVRicon",this._btnVR.id="babylonVRiconbtn",this._btnVR.title="Click to switch to VR";".babylonVRicon.vrdisplaypresenting { display: none; }";var s=document.createElement("style");s.appendChild(document.createTextNode(".babylonVRicon { position: absolute; right: 20px; height: 50px; width: 80px; background-color: rgba(51,51,51,0.7); background-image: url(data:image/svg+xml;charset=UTF-8,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%222048%22%20height%3D%221152%22%20viewBox%3D%220%200%202048%201152%22%20version%3D%221.1%22%3E%3Cpath%20transform%3D%22rotate%28180%201024%2C576.0000000000001%29%22%20d%3D%22m1109%2C896q17%2C0%2030%2C-12t13%2C-30t-12.5%2C-30.5t-30.5%2C-12.5l-170%2C0q-18%2C0%20-30.5%2C12.5t-12.5%2C30.5t13%2C30t30%2C12l170%2C0zm-85%2C256q59%2C0%20132.5%2C-1.5t154.5%2C-5.5t164.5%2C-11.5t163%2C-20t150%2C-30t124.5%2C-41.5q23%2C-11%2042%2C-24t38%2C-30q27%2C-25%2041%2C-61.5t14%2C-72.5l0%2C-257q0%2C-123%20-47%2C-232t-128%2C-190t-190%2C-128t-232%2C-47l-81%2C0q-37%2C0%20-68.5%2C14t-60.5%2C34.5t-55.5%2C45t-53%2C45t-53%2C34.5t-55.5%2C14t-55.5%2C-14t-53%2C-34.5t-53%2C-45t-55.5%2C-45t-60.5%2C-34.5t-68.5%2C-14l-81%2C0q-123%2C0%20-232%2C47t-190%2C128t-128%2C190t-47%2C232l0%2C257q0%2C68%2038%2C115t97%2C73q54%2C24%20124.5%2C41.5t150%2C30t163%2C20t164.5%2C11.5t154.5%2C5.5t132.5%2C1.5zm939%2C-298q0%2C39%20-24.5%2C67t-58.5%2C42q-54%2C23%20-122%2C39.5t-143.5%2C28t-155.5%2C19t-157%2C11t-148.5%2C5t-129.5%2C1.5q-59%2C0%20-130%2C-1.5t-148%2C-5t-157%2C-11t-155.5%2C-19t-143.5%2C-28t-122%2C-39.5q-34%2C-14%20-58.5%2C-42t-24.5%2C-67l0%2C-257q0%2C-106%2040.5%2C-199t110%2C-162.5t162.5%2C-109.5t199%2C-40l81%2C0q27%2C0%2052%2C14t50%2C34.5t51%2C44.5t55.5%2C44.5t63.5%2C34.5t74%2C14t74%2C-14t63.5%2C-34.5t55.5%2C-44.5t51%2C-44.5t50%2C-34.5t52%2C-14l14%2C0q37%2C0%2070%2C0.5t64.5%2C4.5t63.5%2C12t68%2C23q71%2C30%20128.5%2C78.5t98.5%2C110t63.5%2C133.5t22.5%2C149l0%2C257z%22%20fill%3D%22white%22%20/%3E%3C/svg%3E%0A); background-size: 80%; background-repeat:no-repeat; background-position: center; border: none; outline: none; transition: transform 0.125s ease-out } .babylonVRicon:hover { transform: scale(1.05) } .babylonVRicon:active {background-color: rgba(51,51,51,1) } .babylonVRicon:focus {background-color: rgba(51,51,51,1) }.babylonVRicon.vrdisplaypresenting { display: none; }")),document.getElementsByTagName("head")[0].appendChild(s),this.moveButtonToBottomRight()}this._btnVR&&this._btnVR.addEventListener("click",function(){i.isInVRMode?i.exitVR():i.enterVR()}),window.addEventListener("resize",this._onResize),document.addEventListener("fullscreenchange",this._onFullscreenChange,!1),document.addEventListener("mozfullscreenchange",this._onFullscreenChange,!1),document.addEventListener("webkitfullscreenchange",this._onFullscreenChange,!1),document.addEventListener("msfullscreenchange",this._onFullscreenChange,!1),document.onmsfullscreenchange=this._onFullscreenChange,t.createFallbackVRDeviceOrientationFreeCamera?this.displayVRButton():this._scene.getEngine().onVRDisplayChangedObservable.add(function(e){e.vrDisplay&&i.displayVRButton()}),this._onKeyDown=function(e){27===e.keyCode&&i.isInVRMode&&i.exitVR()},document.addEventListener("keydown",this._onKeyDown),this._scene.onPrePointerObservable.add(function(){i.isInVRMode&&(i.exitVR(),i._fullscreenVRpresenting&&i._scene.getEngine().switchFullscreen(!0))},Ae.a.POINTERDOUBLETAP,!1),this._onVRDisplayChanged=function(e){return i.onVRDisplayChanged(e)},this._onVrDisplayPresentChange=function(){return i.onVrDisplayPresentChange()},this._onVRRequestPresentStart=function(){i._webVRrequesting=!0,i.updateButtonVisibility()},this._onVRRequestPresentComplete=function(){i._webVRrequesting=!1,i.updateButtonVisibility()},e.getEngine().onVRDisplayChangedObservable.add(this._onVRDisplayChanged),e.getEngine().onVRRequestPresentStart.add(this._onVRRequestPresentStart),e.getEngine().onVRRequestPresentComplete.add(this._onVRRequestPresentComplete),window.addEventListener("vrdisplaypresentchange",this._onVrDisplayPresentChange),e.onDisposeObservable.add(function(){i.dispose()}),this._webVRCamera.onControllerMeshLoadedObservable.add(function(e){return i._onDefaultMeshLoaded(e)}),this._scene.gamepadManager.onGamepadConnectedObservable.add(this._onNewGamepadConnected),this._scene.gamepadManager.onGamepadDisconnectedObservable.add(this._onNewGamepadDisconnected),this.updateButtonVisibility(),this._circleEase=new $,this._circleEase.setEasingMode(J.EASINGMODE_EASEINOUT),this.webVROptions.floorMeshes&&this.enableTeleportation({floorMeshes:this.webVROptions.floorMeshes})}return Object.defineProperty(e.prototype,"onEnteringVR",{get:function(){return this.onEnteringVRObservable},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onExitingVR",{get:function(){return this.onExitingVRObservable},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onControllerMeshLoaded",{get:function(){return this.onControllerMeshLoadedObservable},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"teleportationTarget",{get:function(){return this._teleportationTarget},set:function(e){e&&(e.name="teleportationTarget",this._isDefaultTeleportationTarget=!1,this._teleportationTarget=e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"gazeTrackerMesh",{get:function(){return this._cameraGazer._gazeTracker},set:function(e){e&&(this._cameraGazer._gazeTracker&&this._cameraGazer._gazeTracker.dispose(),this._leftController&&this._leftController._gazeTracker&&this._leftController._gazeTracker.dispose(),this._rightController&&this._rightController._gazeTracker&&this._rightController._gazeTracker.dispose(),this._cameraGazer._gazeTracker=e,this._cameraGazer._gazeTracker.bakeCurrentTransformIntoVertices(),this._cameraGazer._gazeTracker.isPickable=!1,this._cameraGazer._gazeTracker.isVisible=!1,this._cameraGazer._gazeTracker.name="gazeTracker",this._leftController&&(this._leftController._gazeTracker=this._cameraGazer._gazeTracker.clone("gazeTracker")),this._rightController&&(this._rightController._gazeTracker=this._cameraGazer._gazeTracker.clone("gazeTracker")))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"leftControllerGazeTrackerMesh",{get:function(){return this._leftController?this._leftController._gazeTracker:null},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rightControllerGazeTrackerMesh",{get:function(){return this._rightController?this._rightController._gazeTracker:null},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"displayGaze",{get:function(){return this._displayGaze},set:function(e){this._displayGaze=e,e||(this._cameraGazer._gazeTracker.isVisible=!1,this._leftController&&(this._leftController._gazeTracker.isVisible=!1),this._rightController&&(this._rightController._gazeTracker.isVisible=!1))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"displayLaserPointer",{get:function(){return this._displayLaserPointer},set:function(e){this._displayLaserPointer=e,e?(this._rightController&&this._rightController._activatePointer(),this._leftController&&this._leftController._activatePointer()):(this._rightController&&(this._rightController._deactivatePointer(),this._rightController._gazeTracker.isVisible=!1),this._leftController&&(this._leftController._deactivatePointer(),this._leftController._gazeTracker.isVisible=!1))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"deviceOrientationCamera",{get:function(){return this._deviceOrientationCamera},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"currentVRCamera",{get:function(){return this._webVRready?this._webVRCamera:this._scene.activeCamera},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"webVRCamera",{get:function(){return this._webVRCamera},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"vrDeviceOrientationCamera",{get:function(){return this._vrDeviceOrientationCamera},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"_teleportationRequestInitiated",{get:function(){return this._cameraGazer._teleportationRequestInitiated||null!==this._leftController&&this._leftController._teleportationRequestInitiated||null!==this._rightController&&this._rightController._teleportationRequestInitiated},enumerable:!0,configurable:!0}),e.prototype._onDefaultMeshLoaded=function(e){this._leftController&&this._leftController.webVRController==e&&e.mesh&&this._leftController._setLaserPointerParent(e.mesh),this._rightController&&this._rightController.webVRController==e&&e.mesh&&this._rightController._setLaserPointerParent(e.mesh);try{this.onControllerMeshLoadedObservable.notifyObservers(e)}catch(e){p.a.Warn("Error in your custom logic onControllerMeshLoaded: "+e)}},Object.defineProperty(e.prototype,"isInVRMode",{get:function(){return this._webVRpresenting||this._fullscreenVRpresenting},enumerable:!0,configurable:!0}),e.prototype.onVrDisplayPresentChange=function(){var e=this._scene.getEngine().getVRDevice();if(e){var t=this._webVRpresenting;this._webVRpresenting=e.isPresenting,t&&!this._webVRpresenting&&this.exitVR()}else p.a.Warn("Detected VRDisplayPresentChange on an unknown VRDisplay. Did you can enterVR on the vrExperienceHelper?");this.updateButtonVisibility()},e.prototype.onVRDisplayChanged=function(e){this._webVRsupported=e.vrSupported,this._webVRready=!!e.vrDisplay,this._webVRpresenting=e.vrDisplay&&e.vrDisplay.isPresenting,this.updateButtonVisibility()},e.prototype.moveButtonToBottomRight=function(){this._canvas&&!this._useCustomVRButton&&(this._btnVR.style.top=this._canvas.offsetTop+this._canvas.offsetHeight-70+"px",this._btnVR.style.left=this._canvas.offsetLeft+this._canvas.offsetWidth-100+"px")},e.prototype.displayVRButton=function(){this._useCustomVRButton||this._btnVRDisplayed||(document.body.appendChild(this._btnVR),this._btnVRDisplayed=!0)},e.prototype.updateButtonVisibility=function(){this._btnVR&&!this._useCustomVRButton&&(this._btnVR.className="babylonVRicon",this.isInVRMode?this._btnVR.className+=" vrdisplaypresenting":(this._webVRready&&(this._btnVR.className+=" vrdisplayready"),this._webVRsupported&&(this._btnVR.className+=" vrdisplaysupported"),this._webVRrequesting&&(this._btnVR.className+=" vrdisplayrequesting")))},e.prototype.enterVR=function(){if(this.onEnteringVRObservable)try{this.onEnteringVRObservable.notifyObservers(this)}catch(e){p.a.Warn("Error in your custom logic onEnteringVR: "+e)}if(this._scene.activeCamera){if(this._position=this._scene.activeCamera.position.clone(),this.vrDeviceOrientationCamera&&(this.vrDeviceOrientationCamera.rotation=o.q.FromRotationMatrix(this._scene.activeCamera.getWorldMatrix().getRotationMatrix()).toEulerAngles(),this.vrDeviceOrientationCamera.angularSensibility=2e3),this.webVRCamera){var e=this.webVRCamera.deviceRotationQuaternion.toEulerAngles().y,t=o.q.FromRotationMatrix(this._scene.activeCamera.getWorldMatrix().getRotationMatrix()).toEulerAngles().y-e,i=this.webVRCamera.rotationQuaternion.toEulerAngles().y;this.webVRCamera.rotationQuaternion=o.q.FromEulerAngles(0,i+t,0)}this._existingCamera=this._scene.activeCamera,this._existingCamera.angularSensibilityX&&(this._cachedAngularSensibility.angularSensibilityX=this._existingCamera.angularSensibilityX,this._existingCamera.angularSensibilityX=Number.MAX_VALUE),this._existingCamera.angularSensibilityY&&(this._cachedAngularSensibility.angularSensibilityY=this._existingCamera.angularSensibilityY,this._existingCamera.angularSensibilityY=Number.MAX_VALUE),this._existingCamera.angularSensibility&&(this._cachedAngularSensibility.angularSensibility=this._existingCamera.angularSensibility,this._existingCamera.angularSensibility=Number.MAX_VALUE)}this._webVRrequesting||(this._webVRready?this._webVRpresenting||(this._webVRCamera.position=this._position,this._scene.activeCamera=this._webVRCamera):this._vrDeviceOrientationCamera&&(this._vrDeviceOrientationCamera.position=this._position,this._scene.activeCamera&&(this._vrDeviceOrientationCamera.minZ=this._scene.activeCamera.minZ),this._scene.activeCamera=this._vrDeviceOrientationCamera,this._scene.getEngine().switchFullscreen(!0),this.updateButtonVisibility()),this._scene.activeCamera&&this._canvas&&this._scene.activeCamera.attachControl(this._canvas),this._interactionsEnabled&&this._scene.registerBeforeRender(this.beforeRender),this._displayLaserPointer&&[this._leftController,this._rightController].forEach(function(e){e&&e._activatePointer()}),this._hasEnteredVR=!0)},e.prototype.exitVR=function(){if(this._hasEnteredVR){if(this.onExitingVRObservable)try{this.onExitingVRObservable.notifyObservers(this)}catch(e){p.a.Warn("Error in your custom logic onExitingVR: "+e)}this._webVRpresenting&&this._scene.getEngine().disableVR(),this._scene.activeCamera&&(this._position=this._scene.activeCamera.position.clone()),this.vrDeviceOrientationCamera&&(this.vrDeviceOrientationCamera.angularSensibility=Number.MAX_VALUE),this._deviceOrientationCamera?(this._deviceOrientationCamera.position=this._position,this._scene.activeCamera=this._deviceOrientationCamera,this._canvas&&this._scene.activeCamera.attachControl(this._canvas),this._cachedAngularSensibility.angularSensibilityX&&(this._deviceOrientationCamera.angularSensibilityX=this._cachedAngularSensibility.angularSensibilityX,this._cachedAngularSensibility.angularSensibilityX=null),this._cachedAngularSensibility.angularSensibilityY&&(this._deviceOrientationCamera.angularSensibilityY=this._cachedAngularSensibility.angularSensibilityY,this._cachedAngularSensibility.angularSensibilityY=null),this._cachedAngularSensibility.angularSensibility&&(this._deviceOrientationCamera.angularSensibility=this._cachedAngularSensibility.angularSensibility,this._cachedAngularSensibility.angularSensibility=null)):this._existingCamera&&(this._existingCamera.position=this._position,this._scene.activeCamera=this._existingCamera,this._cachedAngularSensibility.angularSensibilityX&&(this._existingCamera.angularSensibilityX=this._cachedAngularSensibility.angularSensibilityX,this._cachedAngularSensibility.angularSensibilityX=null),this._cachedAngularSensibility.angularSensibilityY&&(this._existingCamera.angularSensibilityY=this._cachedAngularSensibility.angularSensibilityY,this._cachedAngularSensibility.angularSensibilityY=null),this._cachedAngularSensibility.angularSensibility&&(this._existingCamera.angularSensibility=this._cachedAngularSensibility.angularSensibility,this._cachedAngularSensibility.angularSensibility=null)),this.updateButtonVisibility(),this._interactionsEnabled&&(this._scene.unregisterBeforeRender(this.beforeRender),this._cameraGazer._gazeTracker.isVisible=!1,this._leftController&&(this._leftController._gazeTracker.isVisible=!1),this._rightController&&(this._rightController._gazeTracker.isVisible=!1)),this._scene.getEngine().resize(),[this._leftController,this._rightController].forEach(function(e){e&&e._deactivatePointer()}),this._hasEnteredVR=!1}},Object.defineProperty(e.prototype,"position",{get:function(){return this._position},set:function(e){this._position=e,this._scene.activeCamera&&(this._scene.activeCamera.position=e)},enumerable:!0,configurable:!0}),e.prototype.enableInteractions=function(){var e=this;this._interactionsEnabled||(this._interactionsRequested=!0,this._leftController&&this._enableInteractionOnController(this._leftController),this._rightController&&this._enableInteractionOnController(this._rightController),this.raySelectionPredicate=function(t){return t.isVisible&&(t.isPickable||t.name===e._floorMeshName)},this.meshSelectionPredicate=function(){return!0},this._raySelectionPredicate=function(t){return!!(e._isTeleportationFloor(t)||-1===t.name.indexOf("gazeTracker")&&-1===t.name.indexOf("teleportationTarget")&&-1===t.name.indexOf("torusTeleportation"))&&e.raySelectionPredicate(t)},this._interactionsEnabled=!0)},Object.defineProperty(e.prototype,"_noControllerIsActive",{get:function(){return!(this._leftController&&this._leftController._activePointer||this._rightController&&this._rightController._activePointer)},enumerable:!0,configurable:!0}),e.prototype._isTeleportationFloor=function(e){for(var t=0;t<this._floorMeshesCollection.length;t++)if(this._floorMeshesCollection[t].id===e.id)return!0;return!(!this._floorMeshName||e.name!==this._floorMeshName)},e.prototype.addFloorMesh=function(e){this._floorMeshesCollection&&(this._floorMeshesCollection.indexOf(e)>-1||this._floorMeshesCollection.push(e))},e.prototype.removeFloorMesh=function(e){if(this._floorMeshesCollection){var t=this._floorMeshesCollection.indexOf(e);-1!==t&&this._floorMeshesCollection.splice(t,1)}},e.prototype.enableTeleportation=function(e){if(void 0===e&&(e={}),!this._teleportationInitialized){this._teleportationRequested=!0,this.enableInteractions(),e.floorMeshName&&(this._floorMeshName=e.floorMeshName),e.floorMeshes&&(this._floorMeshesCollection=e.floorMeshes),null!=this._leftController&&this._enableTeleportationOnController(this._leftController),null!=this._rightController&&this._enableTeleportationOnController(this._rightController);var t=new ui.a;t.vignetteColor=new o.f(0,0,0,0),t.vignetteEnabled=!0,this._postProcessMove=new pi("postProcessMove",1,this._webVRCamera,void 0,void 0,void 0,void 0,t),this._webVRCamera.detachPostProcess(this._postProcessMove),this._teleportationInitialized=!0,this._isDefaultTeleportationTarget&&(this._createTeleportationCircles(),this._teleportationTarget.scaling.scaleInPlace(this._webVRCamera.deviceScaleFactor))}},e.prototype._enableInteractionOnController=function(e){var t=this;e.webVRController.mesh&&(e._interactionsEnabled=!0,this.isInVRMode&&this._displayLaserPointer&&e._activatePointer(),this.webVROptions.laserToggle&&e.webVRController.onMainButtonStateChangedObservable.add(function(i){t._displayLaserPointer&&1===i.value&&(e._activePointer?e._deactivatePointer():e._activatePointer(),t.displayGaze&&(e._gazeTracker.isVisible=e._activePointer))}),e.webVRController.onTriggerStateChangedObservable.add(function(i){var r=e;t._noControllerIsActive&&(r=t._cameraGazer),r._pointerDownOnMeshAsked?i.value<t._padSensibilityDown&&r._selectionPointerUp():i.value>t._padSensibilityUp&&r._selectionPointerDown()}))},e.prototype._checkTeleportWithRay=function(e,t){this._teleportationRequestInitiated&&!t._teleportationRequestInitiated||(t._teleportationRequestInitiated?Math.sqrt(e.y*e.y+e.x*e.x)<this._padSensibilityDown&&(this._teleportActive&&this.teleportCamera(this._haloCenter),t._teleportationRequestInitiated=!1):e.y<-this._padSensibilityUp&&t._dpadPressed&&(t._activatePointer(),t._teleportationRequestInitiated=!0))},e.prototype._checkRotate=function(e,t){t._teleportationRequestInitiated||(t._rotationLeftAsked?e.x>-this._padSensibilityDown&&(t._rotationLeftAsked=!1):e.x<-this._padSensibilityUp&&t._dpadPressed&&(t._rotationLeftAsked=!0,this._rotationAllowed&&this._rotateCamera(!1)),t._rotationRightAsked?e.x<this._padSensibilityDown&&(t._rotationRightAsked=!1):e.x>this._padSensibilityUp&&t._dpadPressed&&(t._rotationRightAsked=!0,this._rotationAllowed&&this._rotateCamera(!0)))},e.prototype._checkTeleportBackwards=function(e,t){if(!t._teleportationRequestInitiated)if(e.y>this._padSensibilityUp&&t._dpadPressed){if(!t._teleportationBackRequestInitiated){if(!this.currentVRCamera)return;var i=o.q.FromRotationMatrix(this.currentVRCamera.getWorldMatrix().getRotationMatrix()),r=this.currentVRCamera.position;this.currentVRCamera.devicePosition&&this.currentVRCamera.deviceRotationQuaternion&&(i=this.currentVRCamera.deviceRotationQuaternion,r=this.currentVRCamera.devicePosition),i.toEulerAnglesToRef(this._workingVector),this._workingVector.z=0,this._workingVector.x=0,o.q.RotationYawPitchRollToRef(this._workingVector.y,this._workingVector.x,this._workingVector.z,this._workingQuaternion),this._workingQuaternion.toRotationMatrix(this._workingMatrix),o.x.TransformCoordinatesToRef(this._teleportBackwardsVector,this._workingMatrix,this._workingVector);var n=new ei.a(r,this._workingVector),s=this._scene.pickWithRay(n,this._raySelectionPredicate);s&&s.pickedPoint&&s.pickedMesh&&this._isTeleportationFloor(s.pickedMesh)&&s.distance<5&&this.teleportCamera(s.pickedPoint),t._teleportationBackRequestInitiated=!0}}else t._teleportationBackRequestInitiated=!1},e.prototype._enableTeleportationOnController=function(e){var t=this;e.webVRController.mesh&&(e._interactionsEnabled||this._enableInteractionOnController(e),e._interactionsEnabled=!0,e._teleportationEnabled=!0,e.webVRController.controllerType===Jt.VIVE&&(e._dpadPressed=!1,e.webVRController.onPadStateChangedObservable.add(function(t){e._dpadPressed=t.pressed,e._dpadPressed||(e._rotationLeftAsked=!1,e._rotationRightAsked=!1,e._teleportationBackRequestInitiated=!1)})),e.webVRController.onPadValuesChangedObservable.add(function(i){t.teleportationEnabled&&(t._checkTeleportBackwards(i,e),t._checkTeleportWithRay(i,e)),t._checkRotate(i,e)}))},e.prototype._createTeleportationCircles=function(){this._teleportationTarget=de.a.CreateGround("teleportationTarget",2,2,2,this._scene),this._teleportationTarget.isPickable=!1;var e=new di("DynamicTexture",512,this._scene,!0);e.hasAlpha=!0;var t=e.getContext();t.beginPath(),t.arc(256,256,200,0,2*Math.PI,!1),t.fillStyle=this._teleportationFillColor,t.fill(),t.lineWidth=10,t.strokeStyle=this._teleportationBorderColor,t.stroke(),t.closePath(),e.update();var i=new hi.a("TextPlaneMaterial",this._scene);i.diffuseTexture=e,this._teleportationTarget.material=i;var r=de.a.CreateTorus("torusTeleportation",.75,.1,25,this._scene,!1);r.isPickable=!1,r.parent=this._teleportationTarget;var n=new N("animationInnerCircle","position.y",30,N.ANIMATIONTYPE_FLOAT,N.ANIMATIONLOOPMODE_CYCLE),o=[];o.push({frame:0,value:0}),o.push({frame:30,value:.4}),o.push({frame:60,value:0}),n.setKeys(o);var s=new le;s.setEasingMode(J.EASINGMODE_EASEINOUT),n.setEasingFunction(s),r.animations=[],r.animations.push(n),this._scene.beginAnimation(r,0,60,!0),this._hideTeleportationTarget()},e.prototype._displayTeleportationTarget=function(){this._teleportActive=!0,this._teleportationInitialized&&(this._teleportationTarget.isVisible=!0,this._isDefaultTeleportationTarget&&(this._teleportationTarget.getChildren()[0].isVisible=!0))},e.prototype._hideTeleportationTarget=function(){this._teleportActive=!1,this._teleportationInitialized&&(this._teleportationTarget.isVisible=!1,this._isDefaultTeleportationTarget&&(this._teleportationTarget.getChildren()[0].isVisible=!1))},e.prototype._rotateCamera=function(e){var t=this;if(this.currentVRCamera instanceof ft){e?this._rotationAngle++:this._rotationAngle--,this.currentVRCamera.animations=[];var i=o.q.FromRotationMatrix(o.j.RotationY(Math.PI/4*this._rotationAngle)),r=new N("animationRotation","rotationQuaternion",90,N.ANIMATIONTYPE_QUATERNION,N.ANIMATIONLOOPMODE_CONSTANT),n=[];n.push({frame:0,value:this.currentVRCamera.rotationQuaternion}),n.push({frame:6,value:i}),r.setKeys(n),r.setEasingFunction(this._circleEase),this.currentVRCamera.animations.push(r),this._postProcessMove.animations=[];var s=new N("animationPP","vignetteWeight",90,N.ANIMATIONTYPE_FLOAT,N.ANIMATIONLOOPMODE_CONSTANT),a=[];a.push({frame:0,value:0}),a.push({frame:3,value:4}),a.push({frame:6,value:0}),s.setKeys(a),s.setEasingFunction(this._circleEase),this._postProcessMove.animations.push(s);var c=new N("animationPP2","vignetteStretch",90,N.ANIMATIONTYPE_FLOAT,N.ANIMATIONLOOPMODE_CONSTANT),l=[];l.push({frame:0,value:0}),l.push({frame:3,value:10}),l.push({frame:6,value:0}),c.setKeys(l),c.setEasingFunction(this._circleEase),this._postProcessMove.animations.push(c),this._postProcessMove.imageProcessingConfiguration.vignetteWeight=0,this._postProcessMove.imageProcessingConfiguration.vignetteStretch=0,this._postProcessMove.samples=4,this._webVRCamera.attachPostProcess(this._postProcessMove),this._scene.beginAnimation(this._postProcessMove,0,6,!1,1,function(){t._webVRCamera.detachPostProcess(t._postProcessMove)}),this._scene.beginAnimation(this.currentVRCamera,0,6,!1,1)}},e.prototype._moveTeleportationSelectorTo=function(e,t,i){if(e.pickedPoint){t._teleportationRequestInitiated&&(this._displayTeleportationTarget(),this._haloCenter.copyFrom(e.pickedPoint),this._teleportationTarget.position.copyFrom(e.pickedPoint));var r=this._convertNormalToDirectionOfRay(e.getNormal(!0,!1),i);if(r){var n=o.x.Cross(o.c.Y,r),s=o.x.Cross(r,n);o.x.RotationFromAxisToRef(s,r,n,this._teleportationTarget.rotation)}this._teleportationTarget.position.y+=.1}},e.prototype.teleportCamera=function(e){var t=this;if(this.currentVRCamera instanceof ft){this.webVRCamera.leftCamera?(this._workingVector.copyFrom(this.webVRCamera.leftCamera.globalPosition),this._workingVector.subtractInPlace(this.webVRCamera.position),e.subtractToRef(this._workingVector,this._workingVector)):this._workingVector.copyFrom(e),this.isInVRMode?this._workingVector.y+=this.webVRCamera.deviceDistanceToRoomGround()*this._webVRCamera.deviceScaleFactor:this._workingVector.y+=this._defaultHeight,this.onBeforeCameraTeleport.notifyObservers(this._workingVector),this.currentVRCamera.animations=[];var i=new N("animationCameraTeleportation","position",90,N.ANIMATIONTYPE_VECTOR3,N.ANIMATIONLOOPMODE_CONSTANT),r=[{frame:0,value:this.currentVRCamera.position},{frame:11,value:this._workingVector}];i.setKeys(r),i.setEasingFunction(this._circleEase),this.currentVRCamera.animations.push(i),this._postProcessMove.animations=[];var n=new N("animationPP","vignetteWeight",90,N.ANIMATIONTYPE_FLOAT,N.ANIMATIONLOOPMODE_CONSTANT),o=[];o.push({frame:0,value:0}),o.push({frame:5,value:8}),o.push({frame:11,value:0}),n.setKeys(o),this._postProcessMove.animations.push(n);var s=new N("animationPP2","vignetteStretch",90,N.ANIMATIONTYPE_FLOAT,N.ANIMATIONLOOPMODE_CONSTANT),a=[];a.push({frame:0,value:0}),a.push({frame:5,value:10}),a.push({frame:11,value:0}),s.setKeys(a),this._postProcessMove.animations.push(s),this._postProcessMove.imageProcessingConfiguration.vignetteWeight=0,this._postProcessMove.imageProcessingConfiguration.vignetteStretch=0,this._webVRCamera.attachPostProcess(this._postProcessMove),this._scene.beginAnimation(this._postProcessMove,0,11,!1,1,function(){t._webVRCamera.detachPostProcess(t._postProcessMove)}),this._scene.beginAnimation(this.currentVRCamera,0,11,!1,1,function(){t.onAfterCameraTeleport.notifyObservers(t._workingVector)}),this._hideTeleportationTarget()}},e.prototype._convertNormalToDirectionOfRay=function(e,t){e&&(Math.acos(o.x.Dot(e,t.direction))<Math.PI/2&&e.scaleInPlace(-1));return e},e.prototype._castRayAndSelectObject=function(e){if(this.currentVRCamera instanceof ft){var t=e._getForwardRay(this._rayLength),i=this._scene.pickWithRay(t,this._raySelectionPredicate);if(i&&(e._laserPointer&&(i.originMesh=e._laserPointer.parent),this._scene.simulatePointerMove(i,{pointerId:e._id})),e._currentHit=i,i&&i.pickedPoint){if(this._displayGaze){var r=1;e._gazeTracker.isVisible=!0,e._isActionableMesh&&(r=3),this.updateGazeTrackerScale&&(e._gazeTracker.scaling.x=i.distance*r,e._gazeTracker.scaling.y=i.distance*r,e._gazeTracker.scaling.z=i.distance*r);var n=this._convertNormalToDirectionOfRay(i.getNormal(),t);if(n){var s=o.x.Cross(o.c.Y,n),a=o.x.Cross(n,s);o.x.RotationFromAxisToRef(a,n,s,e._gazeTracker.rotation)}e._gazeTracker.position.copyFrom(i.pickedPoint),e._gazeTracker.position.x<0?e._gazeTracker.position.x+=.002:e._gazeTracker.position.x-=.002,e._gazeTracker.position.y<0?e._gazeTracker.position.y+=.002:e._gazeTracker.position.y-=.002,e._gazeTracker.position.z<0?e._gazeTracker.position.z+=.002:e._gazeTracker.position.z-=.002}e._updatePointerDistance(i.distance)}else e._updatePointerDistance(),e._gazeTracker.isVisible=!1;if(i&&i.pickedMesh){if(this._teleportationInitialized&&this._isTeleportationFloor(i.pickedMesh)&&i.pickedPoint)return e._currentMeshSelected&&!this._isTeleportationFloor(e._currentMeshSelected)&&this._notifySelectedMeshUnselected(e._currentMeshSelected),e._currentMeshSelected=null,void(e._teleportationRequestInitiated&&this._moveTeleportationSelectorTo(i,e,t));if(i.pickedMesh!==e._currentMeshSelected)if(this.meshSelectionPredicate(i.pickedMesh)){this.onNewMeshPicked.notifyObservers(i),e._currentMeshSelected=i.pickedMesh,i.pickedMesh.isPickable&&i.pickedMesh.actionManager?(this.changeGazeColor(new o.e(0,0,1)),this.changeLaserColor(new o.e(.2,.2,1)),e._isActionableMesh=!0):(this.changeGazeColor(new o.e(.7,.7,.7)),this.changeLaserColor(new o.e(.7,.7,.7)),e._isActionableMesh=!1);try{this.onNewMeshSelected.notifyObservers(i.pickedMesh)}catch(e){p.a.Warn("Error in your custom logic onNewMeshSelected: "+e)}}else this._notifySelectedMeshUnselected(e._currentMeshSelected),e._currentMeshSelected=null,this.changeGazeColor(new o.e(.7,.7,.7)),this.changeLaserColor(new o.e(.7,.7,.7))}else this._notifySelectedMeshUnselected(e._currentMeshSelected),e._currentMeshSelected=null,this.changeGazeColor(new o.e(.7,.7,.7)),this.changeLaserColor(new o.e(.7,.7,.7))}},e.prototype._notifySelectedMeshUnselected=function(e){e&&this.onSelectedMeshUnselected.notifyObservers(e)},e.prototype.changeLaserColor=function(e){this._leftController&&this._leftController._setLaserPointerColor(e),this._rightController&&this._rightController._setLaserPointerColor(e)},e.prototype.changeGazeColor=function(e){this.updateGazeTrackerColor&&this._cameraGazer._gazeTracker.material&&(this._cameraGazer._gazeTracker.material.emissiveColor=e,this._leftController&&(this._leftController._gazeTracker.material.emissiveColor=e),this._rightController&&(this._rightController._gazeTracker.material.emissiveColor=e))},e.prototype.dispose=function(){this.isInVRMode&&this.exitVR(),this._postProcessMove&&this._postProcessMove.dispose(),this._webVRCamera&&this._webVRCamera.dispose(),this._vrDeviceOrientationCamera&&this._vrDeviceOrientationCamera.dispose(),!this._useCustomVRButton&&this._btnVR.parentNode&&document.body.removeChild(this._btnVR),this._deviceOrientationCamera&&this._scene.activeCamera!=this._deviceOrientationCamera&&this._deviceOrientationCamera.dispose(),this._cameraGazer&&this._cameraGazer.dispose(),this._leftController&&this._leftController.dispose(),this._rightController&&this._rightController.dispose(),this._teleportationTarget&&this._teleportationTarget.dispose(),this._floorMeshesCollection=[],document.removeEventListener("keydown",this._onKeyDown),window.removeEventListener("vrdisplaypresentchange",this._onVrDisplayPresentChange),window.removeEventListener("resize",this._onResize),document.removeEventListener("fullscreenchange",this._onFullscreenChange),document.removeEventListener("mozfullscreenchange",this._onFullscreenChange),document.removeEventListener("webkitfullscreenchange",this._onFullscreenChange),document.removeEventListener("msfullscreenchange",this._onFullscreenChange),document.onmsfullscreenchange=null,this._scene.getEngine().onVRDisplayChangedObservable.removeCallback(this._onVRDisplayChanged),this._scene.getEngine().onVRRequestPresentStart.removeCallback(this._onVRRequestPresentStart),this._scene.getEngine().onVRRequestPresentComplete.removeCallback(this._onVRRequestPresentComplete),window.removeEventListener("vrdisplaypresentchange",this._onVrDisplayPresentChange),this._scene.gamepadManager.onGamepadConnectedObservable.removeCallback(this._onNewGamepadConnected),this._scene.gamepadManager.onGamepadDisconnectedObservable.removeCallback(this._onNewGamepadDisconnected),this._scene.unregisterBeforeRender(this.beforeRender)},e.prototype.getClassName=function(){return"VRExperienceHelper"},e}(),Pi=function(e){function t(t,i){var r=e.call(this,t,o.x.Zero(),i)||this;return r.minZ=0,r.rotationQuaternion=new o.q,r.cameraRigMode=Le.a.RIG_MODE_CUSTOM,r.updateUpVectorFromRotation=!0,r._updateNumberOfRigCameras(1),r}return l.d(t,e),t.prototype._updateNumberOfRigCameras=function(e){for(void 0===e&&(e=1);this.rigCameras.length<e;){var t=new dt("view: "+this.rigCameras.length,o.x.Zero(),this.getScene());t.minZ=0,t.parent=this,t.rotationQuaternion=new o.q,t.updateUpVectorFromRotation=!0,this.rigCameras.push(t)}for(;this.rigCameras.length>e;){var i=this.rigCameras.pop();i&&i.dispose()}},t.prototype._updateForDualEyeDebugging=function(e){void 0===e&&(e=.01),this._updateNumberOfRigCameras(2),this.rigCameras[0].viewport=new o.z(0,0,.5,1),this.rigCameras[0].position.x=-e/2,this.rigCameras[0].outputRenderTarget=null,this.rigCameras[1].viewport=new o.z(.5,0,.5,1),this.rigCameras[1].position.x=e/2,this.rigCameras[1].outputRenderTarget=null},t.prototype.updateFromXRSessionManager=function(e){var i=this;if(!e._currentXRFrame||!e._currentXRFrame.getDevicePose)return!1;var r=e._currentXRFrame.getDevicePose(e._frameOfReference);return!(!r||!r.poseModelMatrix)&&(o.j.FromFloat32ArrayToRefScaled(r.poseModelMatrix,0,1,t._TmpMatrix),this._scene.useRightHandedSystem||t._TmpMatrix.toggleModelMatrixHandInPlace(),t._TmpMatrix.getTranslationToRef(this.position),t._TmpMatrix.getRotationMatrixToRef(t._TmpMatrix),o.q.FromRotationMatrixToRef(t._TmpMatrix,this.rotationQuaternion),this.computeWorldMatrix(),this._updateNumberOfRigCameras(e._currentXRFrame.views.length),e._currentXRFrame.views.forEach(function(t,n){o.j.FromFloat32ArrayToRefScaled(r.getViewMatrix(t),0,1,i.rigCameras[n]._computedViewMatrix),o.j.FromFloat32ArrayToRefScaled(t.projectionMatrix,0,1,i.rigCameras[n]._projectionMatrix),i._scene.useRightHandedSystem||(i.rigCameras[n]._computedViewMatrix.toggleModelMatrixHandInPlace(),i.rigCameras[n]._projectionMatrix.toggleProjectionMatrixHandInPlace());var s=e._xrSession.baseLayer.getViewport(t),a=e._xrSession.baseLayer.framebufferWidth,c=e._xrSession.baseLayer.framebufferHeight;i.rigCameras[n].viewport.width=s.width/a,i.rigCameras[n].viewport.height=s.height/c,i.rigCameras[n].viewport.x=s.x/a,i.rigCameras[n].viewport.y=s.y/c,i.rigCameras[n].outputRenderTarget=e._sessionRenderTargetTexture}),!0)},t._TmpMatrix=new o.j,t}(ft),Ri=i(25),Si=i(75),Ci=i(82),Mi=function(e){function t(t,i,r,s,a,c,l,u,h,d,f,p,g){void 0===a&&(a=!0),void 0===c&&(c=_.a.TEXTURETYPE_UNSIGNED_INT),void 0===l&&(l=!1),void 0===u&&(u=Ve.a.TRILINEAR_SAMPLINGMODE),void 0===h&&(h=!0),void 0===d&&(d=!1),void 0===f&&(f=!1),void 0===p&&(p=_.a.TEXTUREFORMAT_RGBA),void 0===g&&(g=!1);var m=e.call(this,null,r,!s)||this;return m.isCube=l,m.renderParticles=!0,m.renderSprites=!1,m.coordinatesMode=Ve.a.PROJECTION_MODE,m.ignoreCameraViewport=!1,m.onBeforeBindObservable=new n.c,m.onAfterUnbindObservable=new n.c,m.onBeforeRenderObservable=new n.c,m.onAfterRenderObservable=new n.c,m.onClearObservable=new n.c,m._currentRefreshId=-1,m._refreshRate=1,m._samples=1,m.boundingBoxPosition=o.x.Zero(),(r=m.getScene())?(m.renderList=new Array,m._engine=r.getEngine(),m.name=t,m.isRenderTarget=!0,m._initialSizeParameter=i,m._processSizeParameter(i),m._resizeObserver=m.getScene().getEngine().onResizeObservable.add(function(){}),m._generateMipMaps=!!s,m._doNotChangeAspectRatio=a,m._renderingManager=new Ci.b(r),m._renderingManager._useSceneAutoClearSetup=!0,f?m:(m._renderTargetOptions={generateMipMaps:s,type:c,format:p,samplingMode:u,generateDepthBuffer:h,generateStencilBuffer:d},u===Ve.a.NEAREST_SAMPLINGMODE&&(m.wrapU=Ve.a.CLAMP_ADDRESSMODE,m.wrapV=Ve.a.CLAMP_ADDRESSMODE),g||(l?(m._texture=r.getEngine().createRenderTargetCubeTexture(m.getRenderSize(),m._renderTargetOptions),m.coordinatesMode=Ve.a.INVCUBIC_MODE,m._textureMatrix=o.j.Identity()):m._texture=r.getEngine().createRenderTargetTexture(m._size,m._renderTargetOptions)),m)):m}return l.d(t,e),Object.defineProperty(t.prototype,"renderList",{get:function(){return this._renderList},set:function(e){this._renderList=e,this._renderList&&this._hookArray(this._renderList)},enumerable:!0,configurable:!0}),t.prototype._hookArray=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 o=0===e.length,s=i.apply(e,r);return o&&t.getScene().meshes.forEach(function(e){e._markSubMeshesAsLightDirty()}),s};var r=e.splice;e.splice=function(i,n){var o=r.apply(e,[i,n]);return 0===e.length&&t.getScene().meshes.forEach(function(e){e._markSubMeshesAsLightDirty()}),o}},Object.defineProperty(t.prototype,"onAfterUnbind",{set:function(e){this._onAfterUnbindObserver&&this.onAfterUnbindObservable.remove(this._onAfterUnbindObserver),this._onAfterUnbindObserver=this.onAfterUnbindObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onBeforeRender",{set:function(e){this._onBeforeRenderObserver&&this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),this._onBeforeRenderObserver=this.onBeforeRenderObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onAfterRender",{set:function(e){this._onAfterRenderObserver&&this.onAfterRenderObservable.remove(this._onAfterRenderObserver),this._onAfterRenderObserver=this.onAfterRenderObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onClear",{set:function(e){this._onClearObserver&&this.onClearObservable.remove(this._onClearObserver),this._onClearObserver=this.onClearObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"renderTargetOptions",{get:function(){return this._renderTargetOptions},enumerable:!0,configurable:!0}),t.prototype._onRatioRescale=function(){this._sizeRatio&&this.resize(this._initialSizeParameter)},Object.defineProperty(t.prototype,"boundingBoxSize",{get:function(){return this._boundingBoxSize},set:function(e){if(!this._boundingBoxSize||!this._boundingBoxSize.equals(e)){this._boundingBoxSize=e;var t=this.getScene();t&&t.markAllMaterialsAsDirty(_.a.MATERIAL_TextureDirtyFlag)}},enumerable:!0,configurable:!0}),t.prototype.createDepthStencilTexture=function(e,t,i){if(void 0===e&&(e=0),void 0===t&&(t=!0),void 0===i&&(i=!1),this.getScene()){var r=this.getScene().getEngine();this.depthStencilTexture=r.createDepthStencilTexture(this._size,{bilinearFiltering:t,comparisonFunction:e,generateStencil:i,isCube:this.isCube}),r.setFrameBufferDepthStencilTexture(this)}},t.prototype._processSizeParameter=function(e){e.ratio?(this._sizeRatio=e.ratio,this._size={width:this._bestReflectionRenderTargetDimension(this._engine.getRenderWidth(),this._sizeRatio),height:this._bestReflectionRenderTargetDimension(this._engine.getRenderHeight(),this._sizeRatio)}):this._size=e},Object.defineProperty(t.prototype,"samples",{get:function(){return this._samples},set:function(e){if(this._samples!==e){var t=this.getScene();t&&(this._samples=t.getEngine().updateRenderTargetTextureSampleCount(this._texture,e))}},enumerable:!0,configurable:!0}),t.prototype.resetRefreshCounter=function(){this._currentRefreshId=-1},Object.defineProperty(t.prototype,"refreshRate",{get:function(){return this._refreshRate},set:function(e){this._refreshRate=e,this.resetRefreshCounter()},enumerable:!0,configurable:!0}),t.prototype.addPostProcess=function(e){if(!this._postProcessManager){var t=this.getScene();if(!t)return;this._postProcessManager=new Si.a(t),this._postProcesses=new Array}this._postProcesses.push(e),this._postProcesses[0].autoClear=!1},t.prototype.clearPostProcesses=function(e){if(void 0===e&&(e=!1),this._postProcesses){if(e)for(var t=0,i=this._postProcesses;t<i.length;t++){i[t].dispose()}this._postProcesses=[]}},t.prototype.removePostProcess=function(e){if(this._postProcesses){var t=this._postProcesses.indexOf(e);-1!==t&&(this._postProcesses.splice(t,1),this._postProcesses.length>0&&(this._postProcesses[0].autoClear=!1))}},t.prototype._shouldRender=function(){return-1===this._currentRefreshId?(this._currentRefreshId=1,!0):this.refreshRate===this._currentRefreshId?(this._currentRefreshId=1,!0):(this._currentRefreshId++,!1)},t.prototype.getRenderSize=function(){return this.getRenderWidth()},t.prototype.getRenderWidth=function(){return this._size.width?this._size.width:this._size},t.prototype.getRenderHeight=function(){return this._size.width?this._size.height:this._size},Object.defineProperty(t.prototype,"canRescale",{get:function(){return!0},enumerable:!0,configurable:!0}),t.prototype.scale=function(e){var t=this.getRenderSize()*e;this.resize(t)},t.prototype.getReflectionTextureMatrix=function(){return this.isCube?this._textureMatrix:e.prototype.getReflectionTextureMatrix.call(this)},t.prototype.resize=function(e){this.releaseInternalTexture();var t=this.getScene();t&&(this._processSizeParameter(e),this.isCube?this._texture=t.getEngine().createRenderTargetCubeTexture(this.getRenderSize(),this._renderTargetOptions):this._texture=t.getEngine().createRenderTargetTexture(this._size,this._renderTargetOptions))},t.prototype.render=function(e,t){if(void 0===e&&(e=!1),void 0===t&&(t=!1),a=this.getScene()){var i,r=a.getEngine();if(void 0!==this.useCameraPostProcesses&&(e=this.useCameraPostProcesses),this._waitingRenderList){this.renderList=[];for(var n=0;n<this._waitingRenderList.length;n++){var o=this._waitingRenderList[n],s=a.getMeshByID(o);s&&this.renderList.push(s)}delete this._waitingRenderList}if(this.renderListPredicate){var a;if(this.renderList?this.renderList.length=0:this.renderList=[],!(a=this.getScene()))return;var c=a.meshes;for(n=0;n<c.length;n++){var l=c[n];this.renderListPredicate(l)&&this.renderList.push(l)}}this.onBeforeBindObservable.notifyObservers(this),this.activeCamera?(i=this.activeCamera,r.setViewport(this.activeCamera.viewport,this.getRenderWidth(),this.getRenderHeight()),this.activeCamera!==a.activeCamera&&a.setTransformMatrix(this.activeCamera.getViewMatrix(),this.activeCamera.getProjectionMatrix(!0))):(i=a.activeCamera)&&r.setViewport(i.viewport,this.getRenderWidth(),this.getRenderHeight()),this._renderingManager.reset();for(var u=this.renderList?this.renderList:a.getActiveMeshes().data,h=this.renderList?this.renderList.length:a.getActiveMeshes().length,d=a.getRenderId(),f=0;f<h;f++){if(l=u[f]){if(!l.isReady(0===this.refreshRate)){this.resetRefreshCounter();continue}l._preActivateForIntermediateRendering(d);var p=void 0;if(p=!(this.renderList||!i)&&0==(l.layerMask&i.layerMask),l.isEnabled()&&l.isVisible&&l.subMeshes&&!p){l._activate(d);for(var _=0;_<l.subMeshes.length;_++){var g=l.subMeshes[_];a._activeIndices.addCount(g.indexCount,!1),this._renderingManager.dispatch(g,l)}}}}for(var m=0;m<a.particleSystems.length;m++){var v=a.particleSystems[m],y=v.emitter;v.isStarted()&&y&&y.position&&y.isEnabled()&&(u.indexOf(y)>=0&&this._renderingManager.dispatchParticles(v))}if(this.isCube)for(var b=0;b<6;b++)this.renderToTarget(b,u,e,t),a.incrementRenderId(),a.resetCachedMaterial();else this.renderToTarget(0,u,e,t);this.onAfterUnbindObservable.notifyObservers(this),a.activeCamera&&(this.activeCamera&&this.activeCamera!==a.activeCamera&&a.setTransformMatrix(a.activeCamera.getViewMatrix(),a.activeCamera.getProjectionMatrix(!0)),r.setViewport(a.activeCamera.viewport)),a.resetCachedMaterial()}},t.prototype._bestReflectionRenderTargetDimension=function(e,t){var i=e*t,r=ve.h.NearestPOT(i+16384/(128+i));return Math.min(ve.h.FloorPOT(e),r)},t.prototype.unbindFrameBuffer=function(e,t){var i=this;this._texture&&e.unBindFramebuffer(this._texture,this.isCube,function(){i.onAfterRenderObservable.notifyObservers(t)})},t.prototype.renderToTarget=function(e,t,i,r){var n=this.getScene();if(n){var o=n.getEngine();if(this._texture){this._postProcessManager?this._postProcessManager._prepareFrame(this._texture,this._postProcesses):i&&n.postProcessManager._prepareFrame(this._texture)||this._texture&&o.bindFramebuffer(this._texture,this.isCube?e:void 0,void 0,void 0,this.ignoreCameraViewport,this.depthStencilTexture?this.depthStencilTexture:void 0),this.onBeforeRenderObservable.notifyObservers(e),this.onClearObservable.hasObservers()?this.onClearObservable.notifyObservers(o):o.clear(this.clearColor||n.clearColor,!0,!0,!0),this._doNotChangeAspectRatio||n.updateTransformMatrix(!0);for(var s=0,a=n._beforeRenderTargetDrawStage;s<a.length;s++){a[s].action(this)}this._renderingManager.render(this.customRenderFunction,t,this.renderParticles,this.renderSprites);for(var c=0,l=n._afterRenderTargetDrawStage;c<l.length;c++){l[c].action(this)}this._postProcessManager?this._postProcessManager._finalizeFrame(!1,this._texture,e,this._postProcesses,this.ignoreCameraViewport):i&&n.postProcessManager._finalizeFrame(!1,this._texture,e),this._doNotChangeAspectRatio||n.updateTransformMatrix(!0),r&&ve.h.DumpFramebuffer(this.getRenderWidth(),this.getRenderHeight(),o),this.isCube&&5!==e?this.onAfterRenderObservable.notifyObservers(e):(this.isCube&&5===e&&o.generateMipMapsForCubemap(this._texture),this.unbindFrameBuffer(o,e))}}},t.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)},t.prototype.setRenderingAutoClearDepthStencil=function(e,t){this._renderingManager.setRenderingAutoClearDepthStencil(e,t),this._renderingManager._useSceneAutoClearSetup=!1},t.prototype.clone=function(){var e=this.getSize(),i=new t(this.name,e,this.getScene(),this._renderTargetOptions.generateMipMaps,this._doNotChangeAspectRatio,this._renderTargetOptions.type,this.isCube,this._renderTargetOptions.samplingMode,this._renderTargetOptions.generateDepthBuffer,this._renderTargetOptions.generateStencilBuffer);return i.hasAlpha=this.hasAlpha,i.level=this.level,i.coordinatesMode=this.coordinatesMode,this.renderList&&(i.renderList=this.renderList.slice(0)),i},t.prototype.serialize=function(){if(!this.name)return null;var t=e.prototype.serialize.call(this);if(t.renderTargetSize=this.getRenderSize(),t.renderList=[],this.renderList)for(var i=0;i<this.renderList.length;i++)t.renderList.push(this.renderList[i].id);return t},t.prototype.disposeFramebufferObjects=function(){var e=this.getInternalTexture(),t=this.getScene();e&&t&&t.getEngine()._releaseFramebufferObjects(e)},t.prototype.dispose=function(){this._postProcessManager&&(this._postProcessManager.dispose(),this._postProcessManager=null),this.clearPostProcesses(!0),this._resizeObserver&&(this.getScene().getEngine().onResizeObservable.remove(this._resizeObserver),this._resizeObserver=null),this.renderList=null;var t=this.getScene();if(t){var i=t.customRenderTargets.indexOf(this);i>=0&&t.customRenderTargets.splice(i,1);for(var r=0,n=t.cameras;r<n.length;r++){var o=n[r];(i=o.customRenderTargets.indexOf(this))>=0&&o.customRenderTargets.splice(i,1)}e.prototype.dispose.call(this)}},t.prototype._rebuild=function(){this.refreshRate===t.REFRESHRATE_RENDER_ONCE&&(this.refreshRate=t.REFRESHRATE_RENDER_ONCE),this._postProcessManager&&this._postProcessManager._rebuild()},t.prototype.freeRenderingGroups=function(){this._renderingManager&&this._renderingManager.freeRenderingGroups()},t.REFRESHRATE_RENDER_ONCE=0,t.REFRESHRATE_RENDER_ONEVERYFRAME=1,t.REFRESHRATE_RENDER_ONEVERYTWOFRAMES=2,t}(Ve.a);Ve.a._CreateRenderTargetTexture=function(e,t,i,r){return new Mi(e,t,i,r)};var Oi,Ii=function(){function e(e){this.scene=e,this.onXRFrameObservable=new n.c,this.onXRSessionEnded=new n.c,this._sessionRenderTargetTexture=null,this._tmpMatrix=new o.j}return e.prototype.initializeAsync=function(){var e=this;return p.a.Warn("The WebXR APIs are still under development and are subject to change in the future."),this._xrNavigator=navigator,this._xrNavigator.xr?this._xrNavigator.xr.requestDevice().then(function(t){return e._xrDevice=t,e.scene.getEngine()._gl.setCompatibleXRDevice(e._xrDevice)}):Promise.reject("webXR not supported by this browser")},e.prototype.enterXRAsync=function(t,i){var r=this;return this._xrDevice.requestSession(t).then(function(e){return r._xrSession=e,r._xrSession.addEventListener("end",function(){r._sessionRenderTargetTexture=null,r.scene.getEngine().restoreDefaultFramebuffer(),r.scene.getEngine().customAnimationFrameRequester=null,r.onXRSessionEnded.notifyObservers(null),r.scene.getEngine()._renderLoop()},{once:!0}),r._xrSession.baseLayer=new XRWebGLLayer(r._xrSession,r.scene.getEngine()._gl),r._xrSession.requestFrameOfReference(i)}).then(function(t){r._frameOfReference=t,r.scene.getEngine().customAnimationFrameRequester={requestAnimationFrame:r._xrSession.requestAnimationFrame.bind(r._xrSession),renderFunction:function(e,t){r._currentXRFrame=t,r.onXRFrameObservable.notifyObservers(null),r.scene.getEngine()._renderLoop()}},r._sessionRenderTargetTexture=e._CreateRenderTargetTextureFromSession(r._xrSession,r.scene),window.cancelAnimationFrame(r.scene.getEngine()._frameHandler),r.scene.getEngine()._renderLoop()})},e.prototype.exitXRAsync=function(){return this._xrSession.end()},e.prototype.environmentPointHitTestAsync=function(e){var t=this;return new Promise(function(i){var r=new Float32Array([e.origin.x,e.origin.y,e.origin.z]),n=new Float32Array([e.direction.x,e.direction.y,e.direction.z]);t.scene.useRightHandedSystem||(r[2]*=-1,n[2]*=-1),t._xrSession.requestHitTest(r,n,t._frameOfReference).then(function(e){if(e.length>0){o.j.FromFloat32ArrayToRefScaled(e[0].hitMatrix,0,1,t._tmpMatrix);var r=t._tmpMatrix.getTranslation();t.scene.useRightHandedSystem||(r.z*=-1),i(r)}else i(null)}).catch(function(){i(null)})})},e.prototype.supportsSessionAsync=function(e){return this._xrDevice.supportsSession(e).then(function(){return!0}).catch(function(){return!1})},e._CreateRenderTargetTextureFromSession=function(e,t){var i=new Ri.a(t.getEngine(),Ri.a.DATASOURCE_UNKNOWN,!0);i.width=e.baseLayer.framebufferWidth,i.height=e.baseLayer.framebufferHeight,i._framebuffer=e.baseLayer.framebuffer;var r=new Mi("XR renderTargetTexture",{width:i.width,height:i.height},t,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,!0);return r._texture=i,r},e.prototype.dispose=function(){this.onXRFrameObservable.clear(),this.onXRSessionEnded.clear()},e}();!function(e){e[e.ENTERING_XR=0]="ENTERING_XR",e[e.EXITING_XR=1]="EXITING_XR",e[e.IN_XR=2]="IN_XR",e[e.NOT_IN_XR=3]="NOT_IN_XR"}(Oi||(Oi={}));var Di,wi=function(){function e(e){this.scene=e,this.state=Oi.NOT_IN_XR,this.onStateChangedObservable=new n.c,this._nonVRCamera=null,this._originalSceneAutoClear=!0,this._supported=!1,this.camera=new Pi("",e),this._sessionManager=new Ii(e),this.container=new we.a("",e),this.camera.parent=this.container}return e.prototype._setState=function(e){this.state=e,this.onStateChangedObservable.notifyObservers(this.state)},e.CreateAsync=function(t){var i=new e(t);return i._sessionManager.initializeAsync().then(function(){return i._supported=!0,i}).catch(function(){return i})},e.prototype.exitXRAsync=function(){return this._setState(Oi.EXITING_XR),this._sessionManager.exitXRAsync()},e.prototype.enterXRAsync=function(e,t){var i=this;if(!this._supported)throw"XR session not supported by this browser";return this._setState(Oi.ENTERING_XR),this._sessionManager.enterXRAsync(e,t).then(function(){i._originalSceneAutoClear=i.scene.autoClear,i._nonVRCamera=i.scene.activeCamera,i.scene.autoClear=!1,i.scene.activeCamera=i.camera,i._sessionManager.onXRFrameObservable.add(function(){i.camera.updateFromXRSessionManager(i._sessionManager)}),i._sessionManager.onXRSessionEnded.addOnce(function(){i.camera.rigCameras.forEach(function(e){e.outputRenderTarget=null}),i.scene.autoClear=i._originalSceneAutoClear,i.scene.activeCamera=i._nonVRCamera,i._sessionManager.onXRFrameObservable.clear(),i._setState(Oi.NOT_IN_XR)}),i._setState(Oi.IN_XR)})},e.prototype.environmentPointHitTestAsync=function(e){return this._sessionManager.environmentPointHitTestAsync(e)},e.prototype.setPositionOfCameraUsingContainer=function(t){this.camera.globalPosition.subtractToRef(t,e._TmpVector),this.container.position.subtractInPlace(e._TmpVector)},e.prototype.rotateCameraByQuaternionUsingContainer=function(e){this.container.rotationQuaternion||(this.container.rotationQuaternion=o.q.FromEulerVector(this.container.rotation)),this.container.rotationQuaternion.multiplyInPlace(e),this.container.position.rotateByQuaternionAroundPointToRef(e,this.camera.globalPosition,this.container.position)},e.prototype.supportsSessionAsync=function(e){return this._supported?this._sessionManager.supportsSessionAsync(e):Promise.resolve(!1)},e.prototype.dispose=function(){this.camera.dispose(),this.container.dispose(),this.onStateChangedObservable.clear(),this._sessionManager.dispose()},e._TmpVector=new o.x,e}(),Li=function(){function e(e,t){this.element=e,this.initializationOptions=t}return e.prototype.update=function(e){},e}(),Fi=function(){return function(){}}(),Ni=function(){function e(e,t){var i=this;if(this.scene=e,this._buttons=[],this._activeButton=null,this.activeButtonChangedObservable=new n.c,this._overlay=document.createElement("div"),this._overlay.style.cssText="z-index:11;position: absolute; right: 20px;bottom: 50px;",t.customButtons)this._buttons=t.customButtons;else{var r=document.createElement("button");r.style.cssText="color: #868686; border-color: #868686; border-style: solid; margin-left: 10px; height: 50px; width: 80px; background-color: rgba(51,51,51,0.7); background-repeat:no-repeat; background-position: center; outline: none;",r.innerText="HMD",this._buttons.push(new Li(r,{immersive:!0,outputContext:t.outputCanvasContext})),this._buttons[this._buttons.length-1].update=function(e){this.element.style.display=null===e||e===this?"":"none",this.element.innerText=e===this?"EXIT":"HMD"};var o=document.createElement("button");o.style.cssText=r.style.cssText,o.innerText="Window",this._buttons.push(new Li(o,{immersive:!1,environmentIntegration:!0,outputContext:t.outputCanvasContext})),this._buttons[this._buttons.length-1].update=function(e){this.element.style.display=null===e||e===this?"":"none",this.element.innerText=e===this?"EXIT":"Window"},this._updateButtons(null)}var s=e.getEngine().getRenderingCanvas();s&&s.parentNode&&(s.parentNode.appendChild(this._overlay),e.onDisposeObservable.addOnce(function(){i.dispose()}))}return e.CreateAsync=function(t,i,r){var n=this,o=new e(t,r),s=o._buttons.map(function(e){return i.supportsSessionAsync(e.initializationOptions)});return i.onStateChangedObservable.add(function(e){e==Oi.NOT_IN_XR&&o._updateButtons(null)}),Promise.all(s).then(function(e){return e.forEach(function(e,t){e&&(o._overlay.appendChild(o._buttons[t].element),o._buttons[t].element.onclick=function(){return l.b(n,void 0,void 0,function(){return l.e(this,function(e){switch(e.label){case 0:return i.state!=Oi.IN_XR?[3,2]:(o._updateButtons(null),[4,i.exitXRAsync()]);case 1:return e.sent(),[2];case 2:return i.state!=Oi.NOT_IN_XR?[3,4]:(o._updateButtons(o._buttons[t]),[4,i.enterXRAsync(o._buttons[t].initializationOptions,"eye-level")]);case 3:e.sent(),e.label=4;case 4:return[2]}})})})}),o})},e.prototype._updateButtons=function(e){var t=this;this._activeButton=e,this._buttons.forEach(function(e){e.update(t._activeButton)}),this.activeButtonChangedObservable.notifyObservers(this._activeButton)},e.prototype.dispose=function(){var e=this.scene.getEngine().getRenderingCanvas();e&&e.parentNode&&e.parentNode.contains(this._overlay)&&e.parentNode.removeChild(this._overlay),this.activeButtonChangedObservable.clear()},e}(),Bi=function(){function e(e){this.pointer=new we.a("controllerPointer",e)}return e.prototype.dispose=function(){this.grip&&this.grip.dispose(),this.pointer.dispose()},e}(),Ui=function(){function e(e){var t=this;this.helper=e,this.controllers=[],this._tmpMatrix=new o.j,this._frameObserver=e._sessionManager.onXRFrameObservable.add(function(){if(e._sessionManager._currentXRFrame&&e._sessionManager._currentXRFrame.getDevicePose){var i=e._sessionManager._currentXRFrame;e._sessionManager._xrSession.getInputSources().forEach(function(r,n){var s=i.getInputPose(r,e._sessionManager._frameOfReference);if(s){t.controllers.length<=n&&t.controllers.push(new Bi(e.container.getScene()));var a=t.controllers[n];s.gripMatrix&&(a.grip||(a.grip=new we.a("controllerGrip",e.container.getScene())),o.j.FromFloat32ArrayToRefScaled(s.gripMatrix,0,1,t._tmpMatrix),a.grip.getScene().useRightHandedSystem||t._tmpMatrix.toggleModelMatrixHandInPlace(),a.grip.rotationQuaternion||(a.grip.rotationQuaternion=new o.q),t._tmpMatrix.decompose(a.grip.scaling,a.grip.rotationQuaternion,a.grip.position)),o.j.FromFloat32ArrayToRefScaled(s.targetRay.transformMatrix,0,1,t._tmpMatrix),a.pointer.getScene().useRightHandedSystem||t._tmpMatrix.toggleModelMatrixHandInPlace(),a.pointer.rotationQuaternion||(a.pointer.rotationQuaternion=new o.q),t._tmpMatrix.decompose(a.pointer.scaling,a.pointer.rotationQuaternion,a.pointer.position)}})}})}return e.prototype.dispose=function(){this.controllers.forEach(function(e){e.dispose()}),this.helper._sessionManager.onXRFrameObservable.remove(this._frameObserver)},e}(),Vi=function(){function e(e,t){var i=this;this._canvas=null,this.canvasContext=null,t||((t=document.createElement("canvas")).style.cssText="position:absolute; bottom:0px;right:0px;z-index:10;width:100%;height:100%;background-color: #000000;"),this._setManagedOutputCanvas(t),e.onStateChangedObservable.add(function(t){t==Oi.ENTERING_XR?i._addCanvas():e.state==Oi.NOT_IN_XR&&i._removeCanvas()})}return e.prototype.dispose=function(){this._removeCanvas(),this._setManagedOutputCanvas(null)},e.prototype._setManagedOutputCanvas=function(e){this._removeCanvas(),e?(this._canvas=e,this.canvasContext=this._canvas.getContext("xrpresent")):(this._canvas=null,this.canvasContext=null)},e.prototype._addCanvas=function(){this._canvas&&document.body.appendChild(this._canvas)},e.prototype._removeCanvas=function(){this._canvas&&document.body.contains(this._canvas)&&document.body.removeChild(this._canvas)},e}(),Gi=(Di={root:0,found:!1},function(e,t,i,r){Di.root=0,Di.found=!1;var n=t*t-4*e*i;if(n<0)return Di;var o=Math.sqrt(n),s=(-t-o)/(2*e),a=(-t+o)/(2*e);if(s>a){var c=a;a=s,s=c}return s>0&&s<r?(Di.root=s,Di.found=!0,Di):a>0&&a<r?(Di.root=a,Di.found=!0,Di):Di}),ki=function(){function e(){this._collisionPoint=o.x.Zero(),this._planeIntersectionPoint=o.x.Zero(),this._tempVector=o.x.Zero(),this._tempVector2=o.x.Zero(),this._tempVector3=o.x.Zero(),this._tempVector4=o.x.Zero(),this._edge=o.x.Zero(),this._baseToVertex=o.x.Zero(),this._destinationPoint=o.x.Zero(),this._slidePlaneNormal=o.x.Zero(),this._displacementVector=o.x.Zero(),this._radius=o.x.One(),this._retry=0,this._basePointWorld=o.x.Zero(),this._velocityWorld=o.x.Zero(),this._normalizedVelocity=o.x.Zero(),this._collisionMask=-1}return Object.defineProperty(e.prototype,"collisionMask",{get:function(){return this._collisionMask},set:function(e){this._collisionMask=isNaN(e)?-1:e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"slidePlaneNormal",{get:function(){return this._slidePlaneNormal},enumerable:!0,configurable:!0}),e.prototype._initialize=function(e,t,i){this._velocity=t,o.x.NormalizeToRef(t,this._normalizedVelocity),this._basePoint=e,e.multiplyToRef(this._radius,this._basePointWorld),t.multiplyToRef(this._radius,this._velocityWorld),this._velocityWorldLength=this._velocityWorld.length(),this._epsilon=i,this.collisionFound=!1},e.prototype._checkPointInTriangle=function(e,t,i,r,n){t.subtractToRef(e,this._tempVector),i.subtractToRef(e,this._tempVector2),o.x.CrossToRef(this._tempVector,this._tempVector2,this._tempVector4);var s=o.x.Dot(this._tempVector4,n);return!(s<0)&&(r.subtractToRef(e,this._tempVector3),o.x.CrossToRef(this._tempVector2,this._tempVector3,this._tempVector4),!((s=o.x.Dot(this._tempVector4,n))<0)&&(o.x.CrossToRef(this._tempVector3,this._tempVector,this._tempVector4),(s=o.x.Dot(this._tempVector4,n))>=0))},e.prototype._canDoCollision=function(e,t,i,r){var n=o.x.Distance(this._basePointWorld,e),s=Math.max(this._radius.x,this._radius.y,this._radius.z);return!(n>this._velocityWorldLength+s+t)&&!!function(e,t,i,r){return!(e.x>i.x+r||i.x-r>t.x||e.y>i.y+r||i.y-r>t.y||e.z>i.z+r||i.z-r>t.z)}(i,r,this._basePointWorld,this._velocityWorldLength+s)},e.prototype._testTriangle=function(e,t,i,r,n,s){var a,c=!1;t||(t=[]),t[e]||(t[e]=new o.n(0,0,0,0),t[e].copyFromPoints(i,r,n));var l=t[e];if(s||l.isFrontFacingTo(this._normalizedVelocity,0)){var u=l.signedDistanceTo(this._basePoint),h=o.x.Dot(l.normal,this._velocity);if(0==h){if(Math.abs(u)>=1)return;c=!0,a=0}else{var d=(1-u)/h;if((a=(-1-u)/h)>d){var f=d;d=a,a=f}if(a>1||d<0)return;a<0&&(a=0),a>1&&(a=1)}this._collisionPoint.copyFromFloats(0,0,0);var p=!1,_=1;if(c||(this._basePoint.subtractToRef(l.normal,this._planeIntersectionPoint),this._velocity.scaleToRef(a,this._tempVector),this._planeIntersectionPoint.addInPlace(this._tempVector),this._checkPointInTriangle(this._planeIntersectionPoint,i,r,n,l.normal)&&(p=!0,_=a,this._collisionPoint.copyFrom(this._planeIntersectionPoint))),!p){var g=this._velocity.lengthSquared(),m=g;this._basePoint.subtractToRef(i,this._tempVector);var v=2*o.x.Dot(this._velocity,this._tempVector),y=this._tempVector.lengthSquared()-1,b=Gi(m,v,y,_);b.found&&(_=b.root,p=!0,this._collisionPoint.copyFrom(i)),this._basePoint.subtractToRef(r,this._tempVector),v=2*o.x.Dot(this._velocity,this._tempVector),y=this._tempVector.lengthSquared()-1,(b=Gi(m,v,y,_)).found&&(_=b.root,p=!0,this._collisionPoint.copyFrom(r)),this._basePoint.subtractToRef(n,this._tempVector),v=2*o.x.Dot(this._velocity,this._tempVector),y=this._tempVector.lengthSquared()-1,(b=Gi(m,v,y,_)).found&&(_=b.root,p=!0,this._collisionPoint.copyFrom(n)),r.subtractToRef(i,this._edge),i.subtractToRef(this._basePoint,this._baseToVertex);var T=this._edge.lengthSquared(),E=o.x.Dot(this._edge,this._velocity),x=o.x.Dot(this._edge,this._baseToVertex);if(m=T*-g+E*E,v=T*(2*o.x.Dot(this._velocity,this._baseToVertex))-2*E*x,y=T*(1-this._baseToVertex.lengthSquared())+x*x,(b=Gi(m,v,y,_)).found){var A=(E*b.root-x)/T;A>=0&&A<=1&&(_=b.root,p=!0,this._edge.scaleInPlace(A),i.addToRef(this._edge,this._collisionPoint))}n.subtractToRef(r,this._edge),r.subtractToRef(this._basePoint,this._baseToVertex),T=this._edge.lengthSquared(),E=o.x.Dot(this._edge,this._velocity),x=o.x.Dot(this._edge,this._baseToVertex),m=T*-g+E*E,v=T*(2*o.x.Dot(this._velocity,this._baseToVertex))-2*E*x,y=T*(1-this._baseToVertex.lengthSquared())+x*x,(b=Gi(m,v,y,_)).found&&(A=(E*b.root-x)/T)>=0&&A<=1&&(_=b.root,p=!0,this._edge.scaleInPlace(A),r.addToRef(this._edge,this._collisionPoint)),i.subtractToRef(n,this._edge),n.subtractToRef(this._basePoint,this._baseToVertex),T=this._edge.lengthSquared(),E=o.x.Dot(this._edge,this._velocity),x=o.x.Dot(this._edge,this._baseToVertex),m=T*-g+E*E,v=T*(2*o.x.Dot(this._velocity,this._baseToVertex))-2*E*x,y=T*(1-this._baseToVertex.lengthSquared())+x*x,(b=Gi(m,v,y,_)).found&&(A=(E*b.root-x)/T)>=0&&A<=1&&(_=b.root,p=!0,this._edge.scaleInPlace(A),n.addToRef(this._edge,this._collisionPoint))}if(p){var P=_*this._velocity.length();(!this.collisionFound||P<this._nearestDistance)&&(this.intersectionPoint?this.intersectionPoint.copyFrom(this._collisionPoint):this.intersectionPoint=this._collisionPoint.clone(),this._nearestDistance=P,this.collisionFound=!0)}}},e.prototype._collide=function(e,t,i,r,n,o,s){for(var a=r;a<n;a+=3){var c=t[i[a]-o],l=t[i[a+1]-o],u=t[i[a+2]-o];this._testTriangle(a,e,u,l,c,s)}},e.prototype._getResponse=function(e,t){e.addToRef(t,this._destinationPoint),t.scaleInPlace(this._nearestDistance/t.length()),this._basePoint.addToRef(t,e),e.subtractToRef(this.intersectionPoint,this._slidePlaneNormal),this._slidePlaneNormal.normalize(),this._slidePlaneNormal.scaleToRef(this._epsilon,this._displacementVector),e.addInPlace(this._displacementVector),this.intersectionPoint.addInPlace(this._displacementVector),this._slidePlaneNormal.scaleInPlace(o.n.SignedDistanceToPlaneFromPositionAndNormal(this.intersectionPoint,this._slidePlaneNormal,this._destinationPoint)),this._destinationPoint.subtractInPlace(this._slidePlaneNormal),this._destinationPoint.subtractToRef(this.intersectionPoint,t)},e}(),zi=function(){function e(){this._scaledPosition=o.x.Zero(),this._scaledVelocity=o.x.Zero(),this._finalPosition=o.x.Zero()}return e.prototype.getNewPosition=function(e,t,i,r,n,o,s){e.divideToRef(i._radius,this._scaledPosition),t.divideToRef(i._radius,this._scaledVelocity),i.collidedMesh=null,i._retry=0,i._initialVelocity=this._scaledVelocity,i._initialPosition=this._scaledPosition,this._collideWithWorld(this._scaledPosition,this._scaledVelocity,i,r,this._finalPosition,n),this._finalPosition.multiplyInPlace(i._radius),o(s,this._finalPosition,i.collidedMesh)},e.prototype.createCollider=function(){return new ki},e.prototype.init=function(e){this._scene=e},e.prototype._collideWithWorld=function(e,t,i,r,n,o){void 0===o&&(o=null);var s=10*_e.b.CollisionsEpsilon;if(i._retry>=r)n.copyFrom(e);else{var a=o?o.collisionMask:i.collisionMask;i._initialize(e,t,s);for(var c=0;c<this._scene.meshes.length;c++){var l=this._scene.meshes[c];l.isEnabled()&&l.checkCollisions&&l.subMeshes&&l!==o&&0!=(a&l.collisionGroup)&&l._checkCollision(i)}i.collisionFound?(0===t.x&&0===t.y&&0===t.z||i._getResponse(e,t),t.length()<=s?n.copyFrom(e):(i._retry++,this._collideWithWorld(e,t,i,r,n,o))):e.addToRef(t,n)}},e}();W.a.CollisionCoordinatorFactory=function(){return new zi};var ji=i(51),Wi=i(81),Hi=i(71),Xi=i(41),Yi=i(74),Ki=function(){function e(e,t,i,r,n,o){this.entries=new Array,this._boundingVectors=new Array,this._capacity=i,this._depth=r,this._maxDepth=n,this._creationFunc=o,this._minPoint=e,this._maxPoint=t,this._boundingVectors.push(e.clone()),this._boundingVectors.push(t.clone()),this._boundingVectors.push(e.clone()),this._boundingVectors[2].x=t.x,this._boundingVectors.push(e.clone()),this._boundingVectors[3].y=t.y,this._boundingVectors.push(e.clone()),this._boundingVectors[4].z=t.z,this._boundingVectors.push(t.clone()),this._boundingVectors[5].z=e.z,this._boundingVectors.push(t.clone()),this._boundingVectors[6].x=e.x,this._boundingVectors.push(t.clone()),this._boundingVectors[7].y=e.y}return Object.defineProperty(e.prototype,"capacity",{get:function(){return this._capacity},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"minPoint",{get:function(){return this._minPoint},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"maxPoint",{get:function(){return this._maxPoint},enumerable:!0,configurable:!0}),e.prototype.addEntry=function(e){if(this.blocks)for(var t=0;t<this.blocks.length;t++){this.blocks[t].addEntry(e)}else this._creationFunc(e,this),this.entries.length>this.capacity&&this._depth<this._maxDepth&&this.createInnerBlocks()},e.prototype.removeEntry=function(e){if(this.blocks)for(var t=0;t<this.blocks.length;t++){this.blocks[t].removeEntry(e)}else{var i=this.entries.indexOf(e);i>-1&&this.entries.splice(i,1)}},e.prototype.addEntries=function(e){for(var t=0;t<e.length;t++){var i=e[t];this.addEntry(i)}},e.prototype.select=function(e,t,i){if(Hi.a.IsInFrustum(this._boundingVectors,e)){if(this.blocks){for(var r=0;r<this.blocks.length;r++){this.blocks[r].select(e,t,i)}return}i?t.concat(this.entries):t.concatWithNoDuplicate(this.entries)}},e.prototype.intersects=function(e,t,i,r){if(Hi.a.IntersectsSphere(this._minPoint,this._maxPoint,e,t)){if(this.blocks){for(var n=0;n<this.blocks.length;n++){this.blocks[n].intersects(e,t,i,r)}return}r?i.concat(this.entries):i.concatWithNoDuplicate(this.entries)}},e.prototype.intersectsRay=function(e,t){if(e.intersectsBoxMinMax(this._minPoint,this._maxPoint)){if(this.blocks){for(var i=0;i<this.blocks.length;i++){this.blocks[i].intersectsRay(e,t)}return}t.concatWithNoDuplicate(this.entries)}},e.prototype.createInnerBlocks=function(){e._CreateBlocks(this._minPoint,this._maxPoint,this.entries,this._capacity,this._depth,this._maxDepth,this,this._creationFunc)},e._CreateBlocks=function(t,i,r,n,s,a,c,l){c.blocks=new Array;for(var u=new o.x((i.x-t.x)/2,(i.y-t.y)/2,(i.z-t.z)/2),h=0;h<2;h++)for(var d=0;d<2;d++)for(var f=0;f<2;f++){var p=new e(t.add(u.multiplyByFloats(h,d,f)),t.add(u.multiplyByFloats(h+1,d+1,f+1)),n,s+1,a,l);p.addEntries(r),c.blocks.push(p)}},e}(),Qi=function(){function e(e,t,i){void 0===i&&(i=2),this.maxDepth=i,this.dynamicContent=new Array,this._maxBlockCapacity=t||64,this._selectionContent=new Rt.b(1024),this._creationFunc=e}return e.prototype.update=function(e,t,i){Ki._CreateBlocks(e,t,i,this._maxBlockCapacity,0,this.maxDepth,this,this._creationFunc)},e.prototype.addMesh=function(e){for(var t=0;t<this.blocks.length;t++){this.blocks[t].addEntry(e)}},e.prototype.removeMesh=function(e){for(var t=0;t<this.blocks.length;t++){this.blocks[t].removeEntry(e)}},e.prototype.select=function(e,t){this._selectionContent.reset();for(var i=0;i<this.blocks.length;i++){this.blocks[i].select(e,this._selectionContent,t)}return t?this._selectionContent.concat(this.dynamicContent):this._selectionContent.concatWithNoDuplicate(this.dynamicContent),this._selectionContent},e.prototype.intersects=function(e,t,i){this._selectionContent.reset();for(var r=0;r<this.blocks.length;r++){this.blocks[r].intersects(e,t,this._selectionContent,i)}return i?this._selectionContent.concat(this.dynamicContent):this._selectionContent.concatWithNoDuplicate(this.dynamicContent),this._selectionContent},e.prototype.intersectsRay=function(e){this._selectionContent.reset();for(var t=0;t<this.blocks.length;t++){this.blocks[t].intersectsRay(e,this._selectionContent)}return this._selectionContent.concatWithNoDuplicate(this.dynamicContent),this._selectionContent},e.CreationFuncForMeshes=function(e,t){var i=e.getBoundingInfo();!e.isBlocked&&i.boundingBox.intersectsMinMax(t.minPoint,t.maxPoint)&&t.entries.push(e)},e.CreationFuncForSubMeshes=function(e,t){e.getBoundingInfo().boundingBox.intersectsMinMax(t.minPoint,t.maxPoint)&&t.entries.push(e)},e}();W.a.prototype.createOrUpdateSelectionOctree=function(e,t){void 0===e&&(e=64),void 0===t&&(t=2);var i=this._getComponent(Te.a.NAME_OCTREE);i||(i=new qi(this),this._addComponent(i)),this._selectionOctree||(this._selectionOctree=new Qi(Qi.CreationFuncForMeshes,e,t));var r=this.getWorldExtends();return this._selectionOctree.update(r.min,r.max,this.meshes),this._selectionOctree},Object.defineProperty(W.a.prototype,"selectionOctree",{get:function(){return this._selectionOctree},enumerable:!0,configurable:!0}),we.a.prototype.createOrUpdateSubmeshesOctree=function(e,t){void 0===e&&(e=64),void 0===t&&(t=2);var i=this.getScene(),r=i._getComponent(Te.a.NAME_OCTREE);r||(r=new qi(i),i._addComponent(r)),this._submeshesOctree||(this._submeshesOctree=new Qi(Qi.CreationFuncForSubMeshes,e,t)),this.computeWorldMatrix(!0);var n=this.getBoundingInfo().boundingBox;return this._submeshesOctree.update(n.minimumWorld,n.maximumWorld,this.subMeshes),this._submeshesOctree};var qi=function(){function e(e){this.name=Te.a.NAME_OCTREE,this.checksIsEnabled=!0,this._tempRay=new ei.a(o.x.Zero(),new o.x(1,1,1)),this.scene=e,this.scene.getActiveMeshCandidates=this.getActiveMeshCandidates.bind(this),this.scene.getActiveSubMeshCandidates=this.getActiveSubMeshCandidates.bind(this),this.scene.getCollidingSubMeshCandidates=this.getCollidingSubMeshCandidates.bind(this),this.scene.getIntersectingSubMeshCandidates=this.getIntersectingSubMeshCandidates.bind(this)}return e.prototype.register=function(){var e=this;this.scene.onMeshRemovedObservable.add(function(t){var i=e.scene.selectionOctree;if(null!=i){var r=i.dynamicContent.indexOf(t);-1!==r&&i.dynamicContent.splice(r,1)}}),this.scene.onMeshImportedObservable.add(function(t){var i=e.scene.selectionOctree;null!=i&&i.addMesh(t)})},e.prototype.getActiveMeshCandidates=function(){return this.scene._selectionOctree?this.scene._selectionOctree.select(this.scene.frustumPlanes):this.scene._getDefaultMeshCandidates()},e.prototype.getActiveSubMeshCandidates=function(e){return e._submeshesOctree&&e.useOctreeForRenderingSelection?e._submeshesOctree.select(this.scene.frustumPlanes):this.scene._getDefaultSubMeshCandidates(e)},e.prototype.getIntersectingSubMeshCandidates=function(e,t){return e._submeshesOctree&&e.useOctreeForPicking?(ei.a.TransformToRef(t,e.getWorldMatrix(),this._tempRay),e._submeshesOctree.intersectsRay(this._tempRay)):this.scene._getDefaultSubMeshCandidates(e)},e.prototype.getCollidingSubMeshCandidates=function(e,t){if(e._submeshesOctree&&e.useOctreeForCollisions){var i=t._velocityWorldLength+Math.max(t._radius.x,t._radius.y,t._radius.z);return e._submeshesOctree.intersects(t._basePointWorld,i)}return this.scene._getDefaultSubMeshCandidates(e)},e.prototype.rebuild=function(){},e.prototype.dispose=function(){},e}(),Zi=i(90),Ji=i(83),$i=function(){return function(){this.renderWidth=512,this.renderHeight=256,this.textureSize=512,this.deterministicLockstep=!1,this.lockstepMaxSteps=4}}(),er=function(e){function t(t){void 0===t&&(t=new $i);var i=e.call(this,null)||this;return void 0===t.deterministicLockstep&&(t.deterministicLockstep=!1),void 0===t.lockstepMaxSteps&&(t.lockstepMaxSteps=4),i._options=t,i._caps=new _e.c,i._caps.maxTexturesImageUnits=16,i._caps.maxVertexTextureImageUnits=16,i._caps.maxTextureSize=512,i._caps.maxCubemapTextureSize=512,i._caps.maxRenderTextureSize=512,i._caps.maxVertexAttribs=16,i._caps.maxVaryingVectors=16,i._caps.maxFragmentUniformVectors=16,i._caps.maxVertexUniformVectors=16,i._caps.standardDerivatives=!1,i._caps.astc=null,i._caps.s3tc=null,i._caps.pvrtc=null,i._caps.etc1=null,i._caps.etc2=null,i._caps.textureAnisotropicFilterExtension=null,i._caps.maxAnisotropy=0,i._caps.uintIndices=!1,i._caps.fragmentDepthSupported=!1,i._caps.highPrecisionShaderSupported=!0,i._caps.colorBufferFloat=!1,i._caps.textureFloat=!1,i._caps.textureFloatLinearFiltering=!1,i._caps.textureFloatRender=!1,i._caps.textureHalfFloat=!1,i._caps.textureHalfFloatLinearFiltering=!1,i._caps.textureHalfFloatRender=!1,i._caps.textureLOD=!1,i._caps.drawBuffersExtension=!1,i._caps.depthTextureExtension=!1,i._caps.vertexArrayObject=!1,i._caps.instancedArrays=!1,p.a.Log("Babylon.js v"+_e.b.Version+" - Null engine"),"undefined"==typeof URL&&(URL={createObjectURL:function(){},revokeObjectURL:function(){}}),"undefined"==typeof Blob&&(Blob=function(){}),i}return l.d(t,e),t.prototype.isDeterministicLockStep=function(){return this._options.deterministicLockstep},t.prototype.getLockstepMaxSteps=function(){return this._options.lockstepMaxSteps},t.prototype.getHardwareScalingLevel=function(){return 1},t.prototype.createVertexBuffer=function(e){return{capacity:0,references:1,is32Bits:!1}},t.prototype.createIndexBuffer=function(e){return{capacity:0,references:1,is32Bits:!1}},t.prototype.clear=function(e,t,i,r){void 0===r&&(r=!1)},t.prototype.getRenderWidth=function(e){return void 0===e&&(e=!1),!e&&this._currentRenderTarget?this._currentRenderTarget.width:this._options.renderWidth},t.prototype.getRenderHeight=function(e){return void 0===e&&(e=!1),!e&&this._currentRenderTarget?this._currentRenderTarget.height:this._options.renderHeight},t.prototype.setViewport=function(e,t,i){this._cachedViewport=e},t.prototype.createShaderProgram=function(e,t,i,r){return{transformFeedback:null,__SPECTOR_rebuildProgram:null,isParallelCompiled:!1}},t.prototype.getUniforms=function(e,t){return[]},t.prototype.getAttributes=function(e,t){return[]},t.prototype.bindSamplers=function(e){this._currentEffect=null},t.prototype.enableEffect=function(e){this._currentEffect=e,e.onBind&&e.onBind(e),e._onBindObservable&&e._onBindObservable.notifyObservers(e)},t.prototype.setState=function(e,t,i,r){void 0===t&&(t=0),void 0===r&&(r=!1)},t.prototype.setIntArray=function(e,t){},t.prototype.setIntArray2=function(e,t){},t.prototype.setIntArray3=function(e,t){},t.prototype.setIntArray4=function(e,t){},t.prototype.setFloatArray=function(e,t){},t.prototype.setFloatArray2=function(e,t){},t.prototype.setFloatArray3=function(e,t){},t.prototype.setFloatArray4=function(e,t){},t.prototype.setArray=function(e,t){},t.prototype.setArray2=function(e,t){},t.prototype.setArray3=function(e,t){},t.prototype.setArray4=function(e,t){},t.prototype.setMatrices=function(e,t){},t.prototype.setMatrix=function(e,t){},t.prototype.setMatrix3x3=function(e,t){},t.prototype.setMatrix2x2=function(e,t){},t.prototype.setFloat=function(e,t){},t.prototype.setFloat2=function(e,t,i){},t.prototype.setFloat3=function(e,t,i,r){},t.prototype.setBool=function(e,t){},t.prototype.setFloat4=function(e,t,i,r,n){},t.prototype.setColor3=function(e,t){},t.prototype.setColor4=function(e,t,i){},t.prototype.setAlphaMode=function(e,t){void 0===t&&(t=!1),this._alphaMode!==e&&(this._alphaState.alphaBlend=e!==_.a.ALPHA_DISABLE,t||this.setDepthWrite(e===_.a.ALPHA_DISABLE),this._alphaMode=e)},t.prototype.bindBuffers=function(e,t,i){},t.prototype.wipeCaches=function(e){this.preventCacheWipeBetweenFrames||(this.resetTextureCache(),this._currentEffect=null,e&&(this._currentProgram=null,this._stencilState.reset(),this._depthCullingState.reset(),this._alphaState.reset()),this._cachedVertexBuffers=null,this._cachedIndexBuffer=null,this._cachedEffectForVertexBuffers=null)},t.prototype.draw=function(e,t,i,r){},t.prototype.drawElementsType=function(e,t,i,r){},t.prototype.drawArraysType=function(e,t,i,r){},t.prototype._createTexture=function(){return{}},t.prototype._releaseTexture=function(e){},t.prototype.createTexture=function(e,t,i,r,n,o,s,a,c,l){void 0===n&&(n=_.a.TEXTURE_TRILINEAR_SAMPLINGMODE),void 0===o&&(o=null),void 0===s&&(s=null),void 0===a&&(a=null);var u=new Ri.a(this,Ri.a.DATASOURCE_URL),h=String(e);return u.url=h,u.generateMipMaps=!t,u.samplingMode=n,u.invertY=i,u.baseWidth=this._options.textureSize,u.baseHeight=this._options.textureSize,u.width=this._options.textureSize,u.height=this._options.textureSize,l&&(u.format=l),u.isReady=!0,o&&o(),this._internalTexturesCache.push(u),u},t.prototype.createRenderTargetTexture=function(e,t){var i=new Ji.a;void 0!==t&&"object"==typeof t?(i.generateMipMaps=t.generateMipMaps,i.generateDepthBuffer=void 0===t.generateDepthBuffer||t.generateDepthBuffer,i.generateStencilBuffer=i.generateDepthBuffer&&t.generateStencilBuffer,i.type=void 0===t.type?_.a.TEXTURETYPE_UNSIGNED_INT:t.type,i.samplingMode=void 0===t.samplingMode?_.a.TEXTURE_TRILINEAR_SAMPLINGMODE:t.samplingMode):(i.generateMipMaps=t,i.generateDepthBuffer=!0,i.generateStencilBuffer=!1,i.type=_.a.TEXTURETYPE_UNSIGNED_INT,i.samplingMode=_.a.TEXTURE_TRILINEAR_SAMPLINGMODE);var r=new Ri.a(this,Ri.a.DATASOURCE_RENDERTARGET),n=e.width||e,o=e.height||e;return r._depthStencilBuffer={},r._framebuffer={},r.baseWidth=n,r.baseHeight=o,r.width=n,r.height=o,r.isReady=!0,r.samples=1,r.generateMipMaps=!!i.generateMipMaps,r.samplingMode=i.samplingMode,r.type=i.type,r._generateDepthBuffer=i.generateDepthBuffer,r._generateStencilBuffer=!!i.generateStencilBuffer,this._internalTexturesCache.push(r),r},t.prototype.updateTextureSamplingMode=function(e,t){t.samplingMode=e},t.prototype.bindFramebuffer=function(e,t,i,r,n){this._currentRenderTarget&&this.unBindFramebuffer(this._currentRenderTarget),this._currentRenderTarget=e,this._currentFramebuffer=e._MSAAFramebuffer?e._MSAAFramebuffer:e._framebuffer,this._cachedViewport&&!n&&this.setViewport(this._cachedViewport,i,r)},t.prototype.unBindFramebuffer=function(e,t,i){void 0===t&&(t=!1),this._currentRenderTarget=null,i&&(e._MSAAFramebuffer&&(this._currentFramebuffer=e._framebuffer),i()),this._currentFramebuffer=null},t.prototype.createDynamicVertexBuffer=function(e){return{capacity:1,references:1,is32Bits:!1}},t.prototype.updateDynamicTexture=function(e,t,i,r,n){void 0===r&&(r=!1)},t.prototype.areAllEffectsReady=function(){return!0},t.prototype.getError=function(){return 0},t.prototype._getUnpackAlignement=function(){return 1},t.prototype._unpackFlipY=function(e){},t.prototype.updateDynamicIndexBuffer=function(e,t,i){void 0===i&&(i=0)},t.prototype.updateDynamicVertexBuffer=function(e,t,i,r){},t.prototype._bindTextureDirectly=function(e,t){return this._boundTexturesCache[this._activeChannel]!==t&&(this._boundTexturesCache[this._activeChannel]=t,!0)},t.prototype._bindTexture=function(e,t){e<0||this._bindTextureDirectly(0,t)},t.prototype._releaseBuffer=function(e){return e.references--,0===e.references},t.prototype.releaseEffects=function(){},t.prototype.displayLoadingUI=function(){},t.prototype.hideLoadingUI=function(){},t.prototype._uploadCompressedDataToTextureDirectly=function(e,t,i,r,n,o,s){void 0===o&&(o=0),void 0===s&&(s=0)},t.prototype._uploadDataToTextureDirectly=function(e,t,i,r){void 0===i&&(i=0),void 0===r&&(r=0)},t.prototype._uploadArrayBufferViewToTexture=function(e,t,i,r){void 0===i&&(i=0),void 0===r&&(r=0)},t.prototype._uploadImageToTexture=function(e,t,i,r){void 0===i&&(i=0),void 0===r&&(r=0)},t}(_e.b),tr=function(){return function(){this._timeElapsedQueryEnded=!1}}(),ir=function(){return function(){this.occlusionInternalRetryCounter=0,this.isOcclusionQueryInProgress=!1,this.isOccluded=!1,this.occlusionRetryCount=-1,this.occlusionType=we.a.OCCLUSION_TYPE_NONE,this.occlusionQueryAlgorithmType=we.a.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE}}();_e.b.prototype.createQuery=function(){return this._gl.createQuery()},_e.b.prototype.deleteQuery=function(e){return this._gl.deleteQuery(e),this},_e.b.prototype.isQueryResultAvailable=function(e){return this._gl.getQueryParameter(e,this._gl.QUERY_RESULT_AVAILABLE)},_e.b.prototype.getQueryResult=function(e){return this._gl.getQueryParameter(e,this._gl.QUERY_RESULT)},_e.b.prototype.beginOcclusionQuery=function(e,t){var i=this._getGlAlgorithmType(e);return this._gl.beginQuery(i,t),this},_e.b.prototype.endOcclusionQuery=function(e){var t=this._getGlAlgorithmType(e);return this._gl.endQuery(t),this},_e.b.prototype._createTimeQuery=function(){var e=this.getCaps().timerQuery;return e.createQueryEXT?e.createQueryEXT():this.createQuery()},_e.b.prototype._deleteTimeQuery=function(e){var t=this.getCaps().timerQuery;t.deleteQueryEXT?t.deleteQueryEXT(e):this.deleteQuery(e)},_e.b.prototype._getTimeQueryResult=function(e){var t=this.getCaps().timerQuery;return t.getQueryObjectEXT?t.getQueryObjectEXT(e,t.QUERY_RESULT_EXT):this.getQueryResult(e)},_e.b.prototype._getTimeQueryAvailability=function(e){var t=this.getCaps().timerQuery;return t.getQueryObjectEXT?t.getQueryObjectEXT(e,t.QUERY_RESULT_AVAILABLE_EXT):this.isQueryResultAvailable(e)},_e.b.prototype.startTimeQuery=function(){var e=this.getCaps(),t=e.timerQuery;if(!t)return null;var i=new tr;if(this._gl.getParameter(t.GPU_DISJOINT_EXT),e.canUseTimestampForTimerQuery)i._startTimeQuery=this._createTimeQuery(),t.queryCounterEXT(i._startTimeQuery,t.TIMESTAMP_EXT);else{if(this._currentNonTimestampToken)return this._currentNonTimestampToken;i._timeElapsedQuery=this._createTimeQuery(),t.beginQueryEXT?t.beginQueryEXT(t.TIME_ELAPSED_EXT,i._timeElapsedQuery):this._gl.beginQuery(t.TIME_ELAPSED_EXT,i._timeElapsedQuery),this._currentNonTimestampToken=i}return i},_e.b.prototype.endTimeQuery=function(e){var t=this.getCaps(),i=t.timerQuery;if(!i||!e)return-1;if(t.canUseTimestampForTimerQuery){if(!e._startTimeQuery)return-1;e._endTimeQuery||(e._endTimeQuery=this._createTimeQuery(),i.queryCounterEXT(e._endTimeQuery,i.TIMESTAMP_EXT))}else if(!e._timeElapsedQueryEnded){if(!e._timeElapsedQuery)return-1;i.endQueryEXT?i.endQueryEXT(i.TIME_ELAPSED_EXT):this._gl.endQuery(i.TIME_ELAPSED_EXT),e._timeElapsedQueryEnded=!0}var r=this._gl.getParameter(i.GPU_DISJOINT_EXT),n=!1;if(e._endTimeQuery?n=this._getTimeQueryAvailability(e._endTimeQuery):e._timeElapsedQuery&&(n=this._getTimeQueryAvailability(e._timeElapsedQuery)),n&&!r){var o=0;if(t.canUseTimestampForTimerQuery){if(!e._startTimeQuery||!e._endTimeQuery)return-1;var s=this._getTimeQueryResult(e._startTimeQuery);o=this._getTimeQueryResult(e._endTimeQuery)-s,this._deleteTimeQuery(e._startTimeQuery),this._deleteTimeQuery(e._endTimeQuery),e._startTimeQuery=null,e._endTimeQuery=null}else{if(!e._timeElapsedQuery)return-1;o=this._getTimeQueryResult(e._timeElapsedQuery),this._deleteTimeQuery(e._timeElapsedQuery),e._timeElapsedQuery=null,e._timeElapsedQueryEnded=!1,this._currentNonTimestampToken=null}return o}return-1},_e.b.prototype._getGlAlgorithmType=function(e){return e===we.a.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE?this._gl.ANY_SAMPLES_PASSED_CONSERVATIVE:this._gl.ANY_SAMPLES_PASSED},Object.defineProperty(we.a.prototype,"isOcclusionQueryInProgress",{get:function(){return this._occlusionDataStorage.isOcclusionQueryInProgress},enumerable:!1,configurable:!0}),Object.defineProperty(we.a.prototype,"_occlusionDataStorage",{get:function(){return this.__occlusionDataStorage||(this.__occlusionDataStorage=new ir),this.__occlusionDataStorage},enumerable:!1,configurable:!0}),Object.defineProperty(we.a.prototype,"isOccluded",{get:function(){return this._occlusionDataStorage.isOccluded},set:function(e){this._occlusionDataStorage.isOccluded=e},enumerable:!0,configurable:!0}),Object.defineProperty(we.a.prototype,"occlusionQueryAlgorithmType",{get:function(){return this._occlusionDataStorage.occlusionQueryAlgorithmType},set:function(e){this._occlusionDataStorage.occlusionQueryAlgorithmType=e},enumerable:!0,configurable:!0}),Object.defineProperty(we.a.prototype,"occlusionType",{get:function(){return this._occlusionDataStorage.occlusionType},set:function(e){this._occlusionDataStorage.occlusionType=e},enumerable:!0,configurable:!0}),Object.defineProperty(we.a.prototype,"occlusionRetryCount",{get:function(){return this._occlusionDataStorage.occlusionRetryCount},set:function(e){this._occlusionDataStorage.occlusionRetryCount=e},enumerable:!0,configurable:!0}),we.a.prototype._checkOcclusionQuery=function(){var e=this._occlusionDataStorage;if(e.occlusionType===we.a.OCCLUSION_TYPE_NONE)return e.isOccluded=!1,!1;var t=this.getEngine();if(t.webGLVersion<2)return e.isOccluded=!1,!1;if(!t.isQueryResultAvailable)return e.isOccluded=!1,!1;if(this.isOcclusionQueryInProgress&&this._occlusionQuery)if(t.isQueryResultAvailable(this._occlusionQuery)){var i=t.getQueryResult(this._occlusionQuery);e.isOcclusionQueryInProgress=!1,e.occlusionInternalRetryCounter=0,e.isOccluded=1!==i}else{if(e.occlusionInternalRetryCounter++,!(-1!==e.occlusionRetryCount&&e.occlusionInternalRetryCounter>e.occlusionRetryCount))return!1;e.isOcclusionQueryInProgress=!1,e.occlusionInternalRetryCounter=0,e.isOccluded=e.occlusionType!==we.a.OCCLUSION_TYPE_OPTIMISTIC&&e.isOccluded}var r=this.getScene();if(r.getBoundingBoxRenderer){var n=r.getBoundingBoxRenderer();this._occlusionQuery||(this._occlusionQuery=t.createQuery()),t.beginOcclusionQuery(e.occlusionQueryAlgorithmType,this._occlusionQuery),n.renderOcclusionBoundingBox(this),t.endOcclusionQuery(e.occlusionQueryAlgorithmType),this._occlusionDataStorage.isOcclusionQueryInProgress=!0}return e.isOccluded};_e.b.prototype.createTransformFeedback=function(){return this._gl.createTransformFeedback()},_e.b.prototype.deleteTransformFeedback=function(e){this._gl.deleteTransformFeedback(e)},_e.b.prototype.bindTransformFeedback=function(e){this._gl.bindTransformFeedback(this._gl.TRANSFORM_FEEDBACK,e)},_e.b.prototype.beginTransformFeedback=function(e){void 0===e&&(e=!0),this._gl.beginTransformFeedback(e?this._gl.POINTS:this._gl.TRIANGLES)},_e.b.prototype.endTransformFeedback=function(){this._gl.endTransformFeedback()},_e.b.prototype.setTranformFeedbackVaryings=function(e,t){this._gl.transformFeedbackVaryings(e,t,this._gl.INTERLEAVED_ATTRIBS)},_e.b.prototype.bindTransformFeedbackBuffer=function(e){this._gl.bindBufferBase(this._gl.TRANSFORM_FEEDBACK_BUFFER,0,e)};var rr=function(){function e(){}return e.COPY=1,e.CUT=2,e.PASTE=3,e}(),nr=function(){function e(e,t){this.type=e,this.event=t}return e.GetTypeFromCharacter=function(e){switch(e){case 67:return rr.COPY;case 86:return rr.PASTE;case 88:return rr.CUT;default:return-1}},e}(),or=i(57),sr=i(52),ar=function(){function e(e,t,i){this.lengthComputable=e,this.loaded=t,this.total=i}return e.FromProgressEvent=function(t){return new e(t.lengthComputable,t.loaded,t.total)},e}(),cr=function(){function e(){}return Object.defineProperty(e,"ForceFullSceneLoadingForIncremental",{get:function(){return sr.a.ForceFullSceneLoadingForIncremental},set:function(e){sr.a.ForceFullSceneLoadingForIncremental=e},enumerable:!0,configurable:!0}),Object.defineProperty(e,"ShowLoadingScreen",{get:function(){return sr.a.ShowLoadingScreen},set:function(e){sr.a.ShowLoadingScreen=e},enumerable:!0,configurable:!0}),Object.defineProperty(e,"loggingLevel",{get:function(){return sr.a.loggingLevel},set:function(e){sr.a.loggingLevel=e},enumerable:!0,configurable:!0}),Object.defineProperty(e,"CleanBoneMatrixWeights",{get:function(){return sr.a.CleanBoneMatrixWeights},set:function(e){sr.a.CleanBoneMatrixWeights=e},enumerable:!0,configurable:!0}),e._getDefaultPlugin=function(){return e._registeredPlugins[".babylon"]},e._getPluginForExtension=function(t){var i=e._registeredPlugins[t];return i||(p.a.Warn("Unable to find a plugin to load "+t+" files. Trying to use .babylon default plugin. To load from a specific filetype (eg. gltf) see: http://doc.babylonjs.com/how_to/load_from_any_file_type"),e._getDefaultPlugin())},e._getPluginForDirectLoad=function(t){for(var i in e._registeredPlugins){var r=e._registeredPlugins[i].plugin;if(r.canDirectLoad&&r.canDirectLoad(t))return e._registeredPlugins[i]}return e._getDefaultPlugin()},e._getPluginForFilename=function(t){var i=t.indexOf("?");-1!==i&&(t=t.substring(0,i));var r=t.lastIndexOf("."),n=t.substring(r,t.length).toLowerCase();return e._getPluginForExtension(n)},e._getDirectLoad=function(e){return"data:"===e.substr(0,5)?e.substr(5):null},e._loadData=function(t,i,r,n,o,s,a){var c,l=e._getDirectLoad(t.name),u=a?e._getPluginForExtension(a):l?e._getPluginForDirectLoad(t.name):e._getPluginForFilename(t.name);if(!(c=u.plugin.createPlugin?u.plugin.createPlugin():u.plugin))throw"The loader plugin corresponding to the file type you are trying to load has not been found. If using es6, please import the plugin you wish to use before.";var h,d=u.isBinary;e.OnPluginActivatedObservable.notifyObservers(c);var f=function(e,t){i.isDisposed?o("Scene has been disposed"):(i.offlineProvider=h,r(c,e,t))},p=null,_=!1,g=c.onDisposeObservable;g&&g.add(function(){_=!0,p&&(p.abort(),p=null),s()});var m=function(){_||(p=ve.h.LoadFile(t.url,f,n?function(e){n(ar.FromProgressEvent(e))}:void 0,h,d,function(e,t){o("Failed to load scene."+(t?" "+t.message:""),t)}))};if(l)return f(l),c;var v=t.file||or.a.FilesToLoad[t.name.toLowerCase()];if(-1===t.rootUrl.indexOf("file:")||-1!==t.rootUrl.indexOf("file:")&&!v){var y=i.getEngine(),b=y.enableOfflineSupport;if(b){for(var T=!1,E=0,x=i.disableOfflineSupportExceptionRules;E<x.length;E++){if(x[E].test(t.url)){T=!0;break}}b=!T}b&&_e.b.OfflineProviderFactory?h=_e.b.OfflineProviderFactory(t.url,m,y.disableManifestCheck):m()}else v?p=ve.h.ReadFile(v,f,n,d):o("Unable to find file named "+t.name);return c},e._getFileInfo=function(e,t){var i,r,n=null;if(t)if(t.lastModified){var o=t;i=e+o.name,r=o.name,n=o}else{var s=t;if("/"===s.substr(0,1))return ve.h.Error("Wrong sceneFilename parameter"),null;i=e+s,r=s}else i=e,r=ve.h.GetFilename(e),e=ve.h.GetFolderPath(e);return{url:i,rootUrl:e,name:r,file:n}},e.GetPluginForExtension=function(t){return e._getPluginForExtension(t).plugin},e.IsPluginForExtensionAvailable=function(t){return!!e._registeredPlugins[t]},e.RegisterPlugin=function(t){if("string"==typeof t.extensions){var i=t.extensions;e._registeredPlugins[i.toLowerCase()]={plugin:t,isBinary:!1}}else{var r=t.extensions;Object.keys(r).forEach(function(i){e._registeredPlugins[i.toLowerCase()]={plugin:t,isBinary:r[i].isBinary}})}},e.ImportMesh=function(t,i,r,n,o,s,a,c){if(void 0===r&&(r=""),void 0===n&&(n=R.a.LastCreatedScene),void 0===o&&(o=null),void 0===s&&(s=null),void 0===a&&(a=null),void 0===c&&(c=null),!n)return p.a.Error("No scene available to import mesh to"),null;var l=e._getFileInfo(i,r);if(!l)return null;var u={};n._addPendingData(u);var h=function(){n._removePendingData(u)},d=function(e,t){var i="Unable to import meshes from "+l.url+": "+e;a?a(n,i,t):p.a.Error(i),h()},f=s?function(e){try{s(e)}catch(e){d("Error in onProgress callback",e)}}:void 0,_=function(e,t,i,r){if(n.importedMeshesFiles.push(l.url),o)try{o(e,t,i,r)}catch(e){d("Error in onSuccess callback",e)}n._removePendingData(u)};return e._loadData(l,n,function(e,i,r){if(e.rewriteRootURL&&(l.rootUrl=e.rewriteRootURL(l.rootUrl,r)),e.importMesh){var o=e,s=new Array,a=new Array,c=new Array;if(!o.importMesh(t,n,i,l.rootUrl,s,a,c,d))return;n.loadingPluginName=e.name,_(s,a,c,[])}else{e.importMeshAsync(t,n,i,l.rootUrl,f,l.name).then(function(t){n.loadingPluginName=e.name,_(t.meshes,t.particleSystems,t.skeletons,t.animationGroups)}).catch(function(e){d(e.message,e)})}},f,d,h,c)},e.ImportMeshAsync=function(t,i,r,n,o,s){return void 0===r&&(r=""),void 0===n&&(n=R.a.LastCreatedScene),void 0===o&&(o=null),void 0===s&&(s=null),new Promise(function(a,c){e.ImportMesh(t,i,r,n,function(e,t,i,r){a({meshes:e,particleSystems:t,skeletons:i,animationGroups:r})},o,function(e,t,i){c(i||new Error(t))},s)})},e.Load=function(t,i,r,n,o,s,a){return void 0===i&&(i=""),void 0===r&&(r=R.a.LastCreatedEngine),void 0===n&&(n=null),void 0===o&&(o=null),void 0===s&&(s=null),void 0===a&&(a=null),r?e.Append(t,i,new W.a(r),n,o,s,a):(ve.h.Error("No engine available"),null)},e.LoadAsync=function(t,i,r,n,o){return void 0===i&&(i=""),void 0===r&&(r=R.a.LastCreatedEngine),void 0===n&&(n=null),void 0===o&&(o=null),new Promise(function(s,a){e.Load(t,i,r,function(e){s(e)},n,function(e,t,i){a(i||new Error(t))},o)})},e.Append=function(t,i,r,n,o,s,a){if(void 0===i&&(i=""),void 0===r&&(r=R.a.LastCreatedScene),void 0===n&&(n=null),void 0===o&&(o=null),void 0===s&&(s=null),void 0===a&&(a=null),!r)return p.a.Error("No scene available to append to"),null;var c=e._getFileInfo(t,i);if(!c)return null;e.ShowLoadingScreen&&r.getEngine().displayLoadingUI();var l={};r._addPendingData(l);var u=function(){r._removePendingData(l),r.getEngine().hideLoadingUI()},h=function(e,t){var i="Unable to load from "+c.url+(e?": "+e:"");s?s(r,i,t):p.a.Error(i),u()},d=o?function(e){try{o(e)}catch(e){h("Error in onProgress callback",e)}}:void 0,f=function(){if(n)try{n(r)}catch(e){h("Error in onSuccess callback",e)}r._removePendingData(l)};return e._loadData(c,r,function(t,i){if(t.load){if(!t.load(r,i,c.rootUrl,h))return;r.loadingPluginName=t.name,f()}else{t.loadAsync(r,i,c.rootUrl,d,c.name).then(function(){r.loadingPluginName=t.name,f()}).catch(function(e){h(e.message,e)})}e.ShowLoadingScreen&&r.executeWhenReady(function(){r.getEngine().hideLoadingUI()})},d,h,u,a)},e.AppendAsync=function(t,i,r,n,o){return void 0===i&&(i=""),void 0===r&&(r=R.a.LastCreatedScene),void 0===n&&(n=null),void 0===o&&(o=null),new Promise(function(s,a){e.Append(t,i,r,function(e){s(e)},n,function(e,t,i){a(i||new Error(t))},o)})},e.LoadAssetContainer=function(t,i,r,n,o,s,a){if(void 0===i&&(i=""),void 0===r&&(r=R.a.LastCreatedScene),void 0===n&&(n=null),void 0===o&&(o=null),void 0===s&&(s=null),void 0===a&&(a=null),!r)return p.a.Error("No scene available to load asset container to"),null;var c=e._getFileInfo(t,i);if(!c)return null;var l={};r._addPendingData(l);var u=function(){r._removePendingData(l)},h=function(e,t){var i="Unable to load assets from "+c.url+(e?": "+e:"");s?s(r,i,t):p.a.Error(i),u()},d=o?function(e){try{o(e)}catch(e){h("Error in onProgress callback",e)}}:void 0,f=function(e){if(n)try{n(e)}catch(e){h("Error in onSuccess callback",e)}r._removePendingData(l)};return e._loadData(c,r,function(t,i){if(t.loadAssetContainer){var n=t.loadAssetContainer(r,i,c.rootUrl,h);if(!n)return;r.loadingPluginName=t.name,f(n)}else if(t.loadAssetContainerAsync){t.loadAssetContainerAsync(r,i,c.rootUrl,d,c.name).then(function(e){r.loadingPluginName=t.name,f(e)}).catch(function(e){h(e.message,e)})}else h("LoadAssetContainer is not supported by this plugin. Plugin did not provide a loadAssetContainer or loadAssetContainerAsync method.");e.ShowLoadingScreen&&r.executeWhenReady(function(){r.getEngine().hideLoadingUI()})},d,h,u,a)},e.LoadAssetContainerAsync=function(t,i,r,n,o){return void 0===i&&(i=""),void 0===r&&(r=R.a.LastCreatedScene),void 0===n&&(n=null),void 0===o&&(o=null),new Promise(function(s,a){e.LoadAssetContainer(t,i,r,function(e){s(e)},n,function(e,t,i){a(i||new Error(t))},o)})},e.NO_LOGGING=_.a.SCENELOADER_NO_LOGGING,e.MINIMAL_LOGGING=_.a.SCENELOADER_MINIMAL_LOGGING,e.SUMMARY_LOGGING=_.a.SCENELOADER_SUMMARY_LOGGING,e.DETAILED_LOGGING=_.a.SCENELOADER_DETAILED_LOGGING,e.OnPluginActivatedObservable=new n.c,e._registeredPlugins={},e}(),lr=function(e){function t(t){var i=e.call(this,t)||this;return i.controllerType=Jt.DAYDREAM,i}return l.d(t,e),t.prototype.initControllerMesh=function(e,i){var r=this;cr.ImportMesh("",t.MODEL_BASE_URL,t.MODEL_FILENAME,e,function(e){r._defaultModel=e[1],r.attachToMesh(r._defaultModel),i&&i(r._defaultModel)})},t.prototype._handleButtonChange=function(e,t,i){if(0===e){var r=this.onTriggerStateChangedObservable;r&&r.notifyObservers(t)}else p.a.Warn("Unrecognized Daydream button index: "+e)},t.MODEL_BASE_URL="https://controllers.babylonjs.com/generic/",t.MODEL_FILENAME="generic.babylon",t.GAMEPAD_ID_PREFIX="Daydream",t}(ci);ti._ControllerFactories.push({canCreate:function(e){return 0===e.id.indexOf(lr.GAMEPAD_ID_PREFIX)},create:function(e){return new lr(e)}});var ur=function(e){function t(t){var i=e.call(this,t)||this;return i._buttonIndexToObservableNameMap=["onTrackpadChangedObservable","onTriggerStateChangedObservable"],i.controllerType=Jt.GEAR_VR,i._calculatedPosition=new o.x("left"==i.hand?-.15:.15,-.5,.25),i._disableTrackPosition(i._calculatedPosition),i}return l.d(t,e),t.prototype.initControllerMesh=function(e,i){var r=this;cr.ImportMesh("",t.MODEL_BASE_URL,t.MODEL_FILENAME,e,function(t){var n=new de.a("",e);t[1].parent=n,t[1].position.z=-.15,r._defaultModel=n,r.attachToMesh(r._defaultModel),i&&i(r._defaultModel)})},t.prototype._handleButtonChange=function(e,t,i){if(e<this._buttonIndexToObservableNameMap.length){var r=this[this._buttonIndexToObservableNameMap[e]];r&&r.notifyObservers(t)}},t.MODEL_BASE_URL="https://controllers.babylonjs.com/generic/",t.MODEL_FILENAME="generic.babylon",t.GAMEPAD_ID_PREFIX="Gear VR",t}(ci);ti._ControllerFactories.push({canCreate:function(e){return 0===e.id.indexOf(ur.GAMEPAD_ID_PREFIX)||-1!==e.id.indexOf("Oculus Go")},create:function(e){return new ur(e)}});var hr=function(e){function t(t){return e.call(this,t)||this}return l.d(t,e),t.prototype.initControllerMesh=function(e,i){var r=this;cr.ImportMesh("",t.MODEL_BASE_URL,t.MODEL_FILENAME,e,function(e){r._defaultModel=e[1],r.attachToMesh(r._defaultModel),i&&i(r._defaultModel)})},t.prototype._handleButtonChange=function(e,t,i){console.log("Button id: "+e+"state: "),console.dir(t)},t.MODEL_BASE_URL="https://controllers.babylonjs.com/generic/",t.MODEL_FILENAME="generic.babylon",t}(ci);ti._DefaultControllerFactory=function(e){return new hr(e)};var dr=function(e){function t(t){var i=e.call(this,t)||this;return i.onSecondaryTriggerStateChangedObservable=new n.c,i.onThumbRestChangedObservable=new n.c,i.controllerType=Jt.OCULUS,i}return l.d(t,e),t.prototype.initControllerMesh=function(e,i){var r,n=this;r="left"===this.hand?t.MODEL_LEFT_FILENAME:t.MODEL_RIGHT_FILENAME,cr.ImportMesh("",t.MODEL_BASE_URL,r,e,function(e){n._defaultModel=e[1],n.attachToMesh(n._defaultModel),i&&i(n._defaultModel)})},Object.defineProperty(t.prototype,"onAButtonStateChangedObservable",{get:function(){if("right"===this.hand)return this.onMainButtonStateChangedObservable;throw new Error("No A button on left hand")},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onBButtonStateChangedObservable",{get:function(){if("right"===this.hand)return this.onSecondaryButtonStateChangedObservable;throw new Error("No B button on left hand")},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onXButtonStateChangedObservable",{get:function(){if("left"===this.hand)return this.onMainButtonStateChangedObservable;throw new Error("No X button on right hand")},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onYButtonStateChangedObservable",{get:function(){if("left"===this.hand)return this.onSecondaryButtonStateChangedObservable;throw new Error("No Y button on right hand")},enumerable:!0,configurable:!0}),t.prototype._handleButtonChange=function(e,t,i){var r=t,n="right"===this.hand?-1:1;switch(e){case 0:return void this.onPadStateChangedObservable.notifyObservers(r);case 1:return this._defaultModel&&(this._defaultModel.getChildren()[3].rotation.x=.2*-r.value,this._defaultModel.getChildren()[3].position.y=.005*-r.value,this._defaultModel.getChildren()[3].position.z=.005*-r.value),void this.onTriggerStateChangedObservable.notifyObservers(r);case 2:return this._defaultModel&&(this._defaultModel.getChildren()[4].position.x=n*r.value*.0035),void this.onSecondaryTriggerStateChangedObservable.notifyObservers(r);case 3:return this._defaultModel&&(r.pressed?this._defaultModel.getChildren()[1].position.y=-.001:this._defaultModel.getChildren()[1].position.y=0),void this.onMainButtonStateChangedObservable.notifyObservers(r);case 4:return this._defaultModel&&(r.pressed?this._defaultModel.getChildren()[2].position.y=-.001:this._defaultModel.getChildren()[2].position.y=0),void this.onSecondaryButtonStateChangedObservable.notifyObservers(r);case 5:return void this.onThumbRestChangedObservable.notifyObservers(r)}},t.MODEL_BASE_URL="https://controllers.babylonjs.com/oculus/",t.MODEL_LEFT_FILENAME="left.babylon",t.MODEL_RIGHT_FILENAME="right.babylon",t}(ci);ti._ControllerFactories.push({canCreate:function(e){return-1!==e.id.indexOf("Oculus Touch")},create:function(e){return new dr(e)}});var fr=function(e){function t(t){var i=e.call(this,t)||this;return i.controllerType=Jt.VIVE,i._invertLeftStickY=!0,i}return l.d(t,e),t.prototype.initControllerMesh=function(e,i){var r=this;cr.ImportMesh("",t.MODEL_BASE_URL,t.MODEL_FILENAME,e,function(e){r._defaultModel=e[1],r.attachToMesh(r._defaultModel),i&&i(r._defaultModel)})},Object.defineProperty(t.prototype,"onLeftButtonStateChangedObservable",{get:function(){return this.onMainButtonStateChangedObservable},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onRightButtonStateChangedObservable",{get:function(){return this.onMainButtonStateChangedObservable},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onMenuButtonStateChangedObservable",{get:function(){return this.onSecondaryButtonStateChangedObservable},enumerable:!0,configurable:!0}),t.prototype._handleButtonChange=function(e,t,i){var r=t;switch(e){case 0:return void this.onPadStateChangedObservable.notifyObservers(r);case 1:return this._defaultModel&&(this._defaultModel.getChildren()[6].rotation.x=.15*-r.value),void this.onTriggerStateChangedObservable.notifyObservers(r);case 2:return void this.onMainButtonStateChangedObservable.notifyObservers(r);case 3:return this._defaultModel&&(r.pressed?this._defaultModel.getChildren()[2].position.y=-.001:this._defaultModel.getChildren()[2].position.y=0),void this.onSecondaryButtonStateChangedObservable.notifyObservers(r)}},t.MODEL_BASE_URL="https://controllers.babylonjs.com/vive/",t.MODEL_FILENAME="wand.babylon",t}(ci);ti._ControllerFactories.push({canCreate:function(e){return-1!==e.id.toLowerCase().indexOf("openvr")},create:function(e){return new fr(e)}});var pr=function(){return function(){this.buttonMeshes={},this.axisMeshes={}}}(),_r=function(e){function t(t){var i=e.call(this,t)||this;return i._mapping={buttons:["thumbstick","trigger","grip","menu","trackpad"],buttonMeshNames:{trigger:"SELECT",menu:"MENU",grip:"GRASP",thumbstick:"THUMBSTICK_PRESS",trackpad:"TOUCHPAD_PRESS"},buttonObservableNames:{trigger:"onTriggerStateChangedObservable",menu:"onSecondaryButtonStateChangedObservable",grip:"onMainButtonStateChangedObservable",thumbstick:"onPadStateChangedObservable",trackpad:"onTrackpadChangedObservable"},axisMeshNames:["THUMBSTICK_X","THUMBSTICK_Y","TOUCHPAD_TOUCH_X","TOUCHPAD_TOUCH_Y"],pointingPoseMeshName:ii.POINTING_POSE},i.onTrackpadChangedObservable=new n.c,i.onTrackpadValuesChangedObservable=new n.c,i.trackpad={x:0,y:0},i.controllerType=Jt.WINDOWS,i._loadedMeshInfo=null,i}return l.d(t,e),Object.defineProperty(t.prototype,"onTriggerButtonStateChangedObservable",{get:function(){return this.onTriggerStateChangedObservable},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onMenuButtonStateChangedObservable",{get:function(){return this.onSecondaryButtonStateChangedObservable},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onGripButtonStateChangedObservable",{get:function(){return this.onMainButtonStateChangedObservable},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onThumbstickButtonStateChangedObservable",{get:function(){return this.onPadStateChangedObservable},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onTouchpadButtonStateChangedObservable",{get:function(){return this.onTrackpadChangedObservable},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onTouchpadValuesChangedObservable",{get:function(){return this.onTrackpadValuesChangedObservable},enumerable:!0,configurable:!0}),t.prototype._updateTrackpad=function(){!this.browserGamepad.axes||this.browserGamepad.axes[2]==this.trackpad.x&&this.browserGamepad.axes[3]==this.trackpad.y||(this.trackpad.x=this.browserGamepad.axes[2],this.trackpad.y=this.browserGamepad.axes[3],this.onTrackpadValuesChangedObservable.notifyObservers(this.trackpad))},t.prototype.update=function(){if(e.prototype.update.call(this),this.browserGamepad.axes&&(this._updateTrackpad(),this._loadedMeshInfo))for(var t=0;t<this._mapping.axisMeshNames.length;t++)this._lerpAxisTransform(t,this.browserGamepad.axes[t])},t.prototype._handleButtonChange=function(e,t,i){var r=this._mapping.buttons[e];if(r){this._updateTrackpad();var n=this[this._mapping.buttonObservableNames[r]];n&&n.notifyObservers(t),this._lerpButtonTransform(r,t.value)}},t.prototype._lerpButtonTransform=function(e,t){if(this._loadedMeshInfo){var i=this._loadedMeshInfo.buttonMeshes[e];i.unpressed.rotationQuaternion&&i.pressed.rotationQuaternion&&i.value.rotationQuaternion&&(o.q.SlerpToRef(i.unpressed.rotationQuaternion,i.pressed.rotationQuaternion,t,i.value.rotationQuaternion),o.x.LerpToRef(i.unpressed.position,i.pressed.position,t,i.value.position))}},t.prototype._lerpAxisTransform=function(e,t){if(this._loadedMeshInfo){var i=this._loadedMeshInfo.axisMeshes[e];if(i&&i.min.rotationQuaternion&&i.max.rotationQuaternion&&i.value.rotationQuaternion){var r=.5*t+.5;o.q.SlerpToRef(i.min.rotationQuaternion,i.max.rotationQuaternion,r,i.value.rotationQuaternion),o.x.LerpToRef(i.min.position,i.max.position,r,i.value.position)}}},t.prototype.initControllerMesh=function(e,i,r){var n,o,s=this;if(void 0===r&&(r=!1),cr.IsPluginForExtensionAvailable(".glb")){var a="default";if(this.id&&!r){var c=this.id.match(t.GAMEPAD_ID_PATTERN);a=c&&c[0]||a}o="left"===this.hand?t.MODEL_LEFT_FILENAME:t.MODEL_RIGHT_FILENAME,n=t.MODEL_BASE_URL+a+"/"}else p.a.Warn("You need to reference GLTF loader to load Windows Motion Controllers model. Falling back to generic models"),n=hr.MODEL_BASE_URL,o=hr.MODEL_FILENAME;cr.ImportMesh("",n,o,e,function(t){s._loadedMeshInfo=s.processModel(e,t),s._loadedMeshInfo&&(s._defaultModel=s._loadedMeshInfo.rootNode,s.attachToMesh(s._defaultModel),i&&i(s._defaultModel))},null,function(e,t){p.a.Log(t),p.a.Warn("Failed to retrieve controller model from the remote server: "+n+o),r||s.initControllerMesh(e,i,!0)})},t.prototype.processModel=function(e,t){for(var i=null,r=new de.a(this.id+" "+this.hand,e),n=null,o=0;o<t.length;o++){var s=t[o];if(!s.parent){s.isPickable=!1,n=s;break}}return n?(n.setParent(r),i=this.createMeshInfo(r)):p.a.Warn("Could not find root node in model file."),i},t.prototype.createMeshInfo=function(e){var t,i=new pr;for(i.rootNode=e,i.buttonMeshes={},i.axisMeshes={},t=0;t<this._mapping.buttons.length;t++){var r=this._mapping.buttonMeshNames[this._mapping.buttons[t]];if(r){var n=l(e,r);if(n){var o={index:t,value:u(n,"VALUE"),pressed:u(n,"PRESSED"),unpressed:u(n,"UNPRESSED")};o.value&&o.pressed&&o.unpressed?i.buttonMeshes[this._mapping.buttons[t]]=o:p.a.Warn("Missing button submesh under mesh with name: "+r+"(VALUE: "+!!o.value+", PRESSED: "+!!o.pressed+", UNPRESSED:"+!!o.unpressed+")")}else p.a.Warn("Missing button mesh with name: "+r)}else p.a.Log("Skipping unknown button at index: "+t+" with mapped name: "+this._mapping.buttons[t])}for(t=0;t<this._mapping.axisMeshNames.length;t++){var s=this._mapping.axisMeshNames[t];if(s){var a=l(e,s);if(a){var c={index:t,value:u(a,"VALUE"),min:u(a,"MIN"),max:u(a,"MAX")};c.value&&c.min&&c.max?i.axisMeshes[t]=c:p.a.Warn("Missing axis submesh under mesh with name: "+s+"(VALUE: "+!!c.value+", MIN: "+!!c.min+", MAX:"+!!c.max+")")}else p.a.Warn("Missing axis mesh with name: "+s)}else p.a.Log("Skipping unknown axis at index: "+t)}return i.pointingPoseNode=l(e,this._mapping.pointingPoseMeshName),i.pointingPoseNode?this._pointingPoseNode=i.pointingPoseNode:p.a.Warn("Missing pointing pose mesh with name: "+this._mapping.pointingPoseMeshName),i;function l(e,t){return e.getChildren(function(e){return e.name===t},!1)[0]}function u(e,t){return e.getChildren(function(e){return e.name==t},!0)[0]}},t.prototype.getForwardRay=function(t){if(void 0===t&&(t=100),!this._loadedMeshInfo||!this._loadedMeshInfo.pointingPoseNode)return e.prototype.getForwardRay.call(this,t);var i=this._loadedMeshInfo.pointingPoseNode.getWorldMatrix(),r=i.getTranslation(),n=new o.x(0,0,-1),s=o.x.TransformNormal(n,i),a=o.x.Normalize(s);return new ei.a(r,a,t)},t.prototype.dispose=function(){e.prototype.dispose.call(this),this.onTrackpadChangedObservable.clear()},t.MODEL_BASE_URL="https://controllers.babylonjs.com/microsoft/",t.MODEL_LEFT_FILENAME="left.glb",t.MODEL_RIGHT_FILENAME="right.glb",t.GAMEPAD_ID_PREFIX="Spatial Controller (Spatial Interaction Source) ",t.GAMEPAD_ID_PATTERN=/([0-9a-zA-Z]+-[0-9a-zA-Z]+)$/,t}(ci);ti._ControllerFactories.push({canCreate:function(e){return 0===e.id.indexOf(_r.GAMEPAD_ID_PREFIX)},create:function(e){return new _r(e)}});var gr=i(38),mr=function(){function e(e){var t=this;this._scene=e,this._babylonGamepads=[],this._oneGamepadConnected=!1,this._isMonitoring=!1,this.onGamepadDisconnectedObservable=new n.c,gr.a.IsWindowObjectExist()?(this._gamepadEventSupported="GamepadEvent"in window,this._gamepadSupport=navigator.getGamepads||navigator.webkitGetGamepads||navigator.msGetGamepads||navigator.webkitGamepads):this._gamepadEventSupported=!1,this.onGamepadConnectedObservable=new n.c(function(e){for(var i in t._babylonGamepads){var r=t._babylonGamepads[i];r&&r._isConnected&&t.onGamepadConnectedObservable.notifyObserver(e,r)}}),this._onGamepadConnectedEvent=function(e){var i,r=e.gamepad;r.index in t._babylonGamepads&&t._babylonGamepads[r.index].isConnected||(t._babylonGamepads[r.index]?((i=t._babylonGamepads[r.index]).browserGamepad=r,i._isConnected=!0):i=t._addNewGamepad(r),t.onGamepadConnectedObservable.notifyObservers(i),t._startMonitoringGamepads())},this._onGamepadDisconnectedEvent=function(e){var i=e.gamepad;for(var r in t._babylonGamepads)if(t._babylonGamepads[r].index===i.index){var n=t._babylonGamepads[r];n._isConnected=!1,t.onGamepadDisconnectedObservable.notifyObservers(n);break}},this._gamepadSupport&&(this._updateGamepadObjects(),this._babylonGamepads.length&&this._startMonitoringGamepads(),this._gamepadEventSupported?(window.addEventListener("gamepadconnected",this._onGamepadConnectedEvent,!1),window.addEventListener("gamepaddisconnected",this._onGamepadDisconnectedEvent,!1)):this._startMonitoringGamepads())}return Object.defineProperty(e.prototype,"gamepads",{get:function(){return this._babylonGamepads},enumerable:!0,configurable:!0}),e.prototype.getGamepadByType=function(e){void 0===e&&(e=He.XBOX);for(var t=0,i=this._babylonGamepads;t<i.length;t++){var r=i[t];if(r&&r.type===e)return r}return null},e.prototype.dispose=function(){this._gamepadEventSupported&&(this._onGamepadConnectedEvent&&window.removeEventListener("gamepadconnected",this._onGamepadConnectedEvent),this._onGamepadDisconnectedEvent&&window.removeEventListener("gamepaddisconnected",this._onGamepadDisconnectedEvent),this._onGamepadConnectedEvent=null,this._onGamepadDisconnectedEvent=null),this._babylonGamepads.forEach(function(e){e.dispose()}),this.onGamepadConnectedObservable.clear(),this.onGamepadDisconnectedObservable.clear(),this._oneGamepadConnected=!1,this._stopMonitoringGamepads(),this._babylonGamepads=[]},e.prototype._addNewGamepad=function(e){var t;this._oneGamepadConnected||(this._oneGamepadConnected=!0);var i=-1!==e.id.search("Xbox One");return t=i||-1!==e.id.search("Xbox 360")||-1!==e.id.search("xinput")?new li(e.id,e.index,e,i):e.pose?ti.InitiateController(e):new Xe(e.id,e.index,e),this._babylonGamepads[t.index]=t,t},e.prototype._startMonitoringGamepads=function(){this._isMonitoring||(this._isMonitoring=!0,this._scene||this._checkGamepadsStatus())},e.prototype._stopMonitoringGamepads=function(){this._isMonitoring=!1},e.prototype._checkGamepadsStatus=function(){var e=this;for(var t in this._updateGamepadObjects(),this._babylonGamepads){var i=this._babylonGamepads[t];i&&i.isConnected&&i.update()}this._isMonitoring&&!this._scene&&ve.h.QueueNewFrame(function(){e._checkGamepadsStatus()})},e.prototype._updateGamepadObjects=function(){for(var e=navigator.getGamepads?navigator.getGamepads():navigator.webkitGetGamepads?navigator.webkitGetGamepads():[],t=0;t<e.length;t++){var i=e[t];if(i)if(this._babylonGamepads[i.index])this._babylonGamepads[t].browserGamepad=i,this._babylonGamepads[t].isConnected||(this._babylonGamepads[t]._isConnected=!0,this.onGamepadConnectedObservable.notifyObservers(this._babylonGamepads[t]));else{var r=this._addNewGamepad(i);this.onGamepadConnectedObservable.notifyObservers(r)}}},e}();Object.defineProperty(W.a.prototype,"gamepadManager",{get:function(){if(!this._gamepadManager){this._gamepadManager=new mr(this);var e=this._getComponent(Te.a.NAME_GAMEPAD);e||(e=new vr(this),this._addComponent(e))}return this._gamepadManager},enumerable:!0,configurable:!0}),ot.prototype.addGamepad=function(){return this.add(new at),this},Je.prototype.addGamepad=function(){return this.add(new Ye),this};var vr=function(){function e(e){this.name=Te.a.NAME_GAMEPAD,this.scene=e}return e.prototype.register=function(){this.scene._beforeCameraUpdateStage.registerStep(Te.a.STEP_BEFORECAMERAUPDATE_GAMEPAD,this,this._beforeCameraUpdate)},e.prototype.rebuild=function(){},e.prototype.dispose=function(){var e=this.scene._gamepadManager;e&&(e.dispose(),this.scene._gamepadManager=null)},e.prototype._beforeCameraUpdate=function(){var e=this.scene._gamepadManager;e&&e._isMonitoring&&e._checkGamepadsStatus()},e}(),yr=i(56),br=i(49),Tr=i(35),Er=i(48),xr=i(40),Ar=function(e){function t(t,i,r){void 0===i&&(i=o.e.Gray()),void 0===r&&(r=xr.a.DefaultUtilityLayer);var s=e.call(this,r)||this;s._pointerObserver=null,s.snapDistance=0,s.onSnapObservable=new n.c,s.uniformScaling=!1,s._coloredMaterial=new hi.a("",r.utilityLayerScene),s._coloredMaterial.disableLighting=!0,s._coloredMaterial.emissiveColor=i;var a=new hi.a("",r.utilityLayerScene);a.disableLighting=!0,a.emissiveColor=i.add(new o.e(.3,.3,.3));var c=new we.a("",r.utilityLayerScene),l=br.a.CreateBox("yPosMesh",{size:.4},r.utilityLayerScene),u=Tr.a.CreateLines("yPosMesh",{points:[new o.x(0,0,0),new o.x(0,1.1,0)]},r.utilityLayerScene);u.color=s._coloredMaterial.emissiveColor,c.addChild(l),c.addChild(u),l.scaling.scaleInPlace(.1),l.material=s._coloredMaterial,l.rotation.x=Math.PI/2,l.position.z+=.3,u.scaling.scaleInPlace(.26),u.rotation.x=Math.PI/2,u.material=s._coloredMaterial,c.lookAt(s._rootMesh.position.add(t)),s._rootMesh.addChild(c),c.scaling.scaleInPlace(1/3),s.dragBehavior=new Ie.a({dragAxis:t}),s.dragBehavior.moveAttached=!1,s._rootMesh.addBehavior(s.dragBehavior);var h=0,d=new o.x,f={snapDistance:0};return s.dragBehavior.onDragObservable.add(function(e){if(s.attachedMesh){var i=!1,r=0;s.uniformScaling?(s.attachedMesh.scaling.normalizeToRef(d),d.y<0&&d.scaleInPlace(-1)):d.copyFrom(t),0==s.snapDistance?d.scaleToRef(e.dragDistance,d):(h+=e.dragDistance,Math.abs(h)>s.snapDistance?(r=Math.floor(Math.abs(h)/s.snapDistance),h<0&&(r*=-1),h%=s.snapDistance,d.scaleToRef(s.snapDistance*r,d),i=!0):d.scaleInPlace(0)),s.attachedMesh.scaling.addInPlace(d),i&&(f.snapDistance=s.snapDistance*r,s.onSnapObservable.notifyObservers(f))}}),s._pointerObserver=r.utilityLayerScene.onPointerObservable.add(function(e){if(!s._customMeshSet){var t=e.pickInfo&&-1!=s._rootMesh.getChildMeshes().indexOf(e.pickInfo.pickedMesh)?a:s._coloredMaterial;s._rootMesh.getChildMeshes().forEach(function(e){e.material=t,e.color&&(e.color=t.emissiveColor)})}}),s}return l.d(t,e),t.prototype._attachedMeshChanged=function(e){this.dragBehavior&&(this.dragBehavior.enabled=!!e)},t.prototype.dispose=function(){this.onSnapObservable.clear(),this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver),this.dragBehavior.detach(),e.prototype.dispose.call(this)},t.prototype.setCustomMesh=function(t,i){var r=this;void 0===i&&(i=!1),e.prototype.setCustomMesh.call(this,t),i&&(this._rootMesh.getChildMeshes().forEach(function(e){e.material=r._coloredMaterial,e.color&&(e.color=r._coloredMaterial.emissiveColor)}),this._customMeshSet=!1)},t}(Er.a),Pr=i(54),Rr=function(e){function t(t,i){void 0===t&&(t=o.e.Gray()),void 0===i&&(i=xr.a.DefaultKeepDepthUtilityLayer);var r=e.call(this,i)||this;r._boundingDimensions=new o.x(1,1,1),r._renderObserver=null,r._pointerObserver=null,r._scaleDragSpeed=.2,r._tmpQuaternion=new o.q,r._tmpVector=new o.x(0,0,0),r._tmpRotationMatrix=new o.j,r.ignoreChildren=!1,r.includeChildPredicate=null,r.rotationSphereSize=.1,r.scaleBoxSize=.1,r.fixedDragMeshScreenSize=!1,r.fixedDragMeshScreenSizeDistanceFactor=10,r.onDragStartObservable=new n.c,r.onScaleBoxDragObservable=new n.c,r.onScaleBoxDragEndObservable=new n.c,r.onRotationSphereDragObservable=new n.c,r.onRotationSphereDragEndObservable=new n.c,r.scalePivot=null,r._existingMeshScale=new o.x,r._dragMesh=null,r.pointerDragBehavior=new Ie.a,r._updateScale=!1,r._anchorMesh=new we.a("anchor",i.utilityLayerScene);var s=new hi.a("",i.utilityLayerScene);s.disableLighting=!0,s.emissiveColor=t;var a=new hi.a("",i.utilityLayerScene);a.disableLighting=!0,a.emissiveColor=t.clone().add(new o.e(.3,.3,.3)),r._lineBoundingBox=new we.a("",i.utilityLayerScene),r._lineBoundingBox.rotationQuaternion=new o.q;var c=[];c.push(Tr.a.CreateLines("lines",{points:[new o.x(0,0,0),new o.x(r._boundingDimensions.x,0,0)]},i.utilityLayerScene)),c.push(Tr.a.CreateLines("lines",{points:[new o.x(0,0,0),new o.x(0,r._boundingDimensions.y,0)]},i.utilityLayerScene)),c.push(Tr.a.CreateLines("lines",{points:[new o.x(0,0,0),new o.x(0,0,r._boundingDimensions.z)]},i.utilityLayerScene)),c.push(Tr.a.CreateLines("lines",{points:[new o.x(r._boundingDimensions.x,0,0),new o.x(r._boundingDimensions.x,r._boundingDimensions.y,0)]},i.utilityLayerScene)),c.push(Tr.a.CreateLines("lines",{points:[new o.x(r._boundingDimensions.x,0,0),new o.x(r._boundingDimensions.x,0,r._boundingDimensions.z)]},i.utilityLayerScene)),c.push(Tr.a.CreateLines("lines",{points:[new o.x(0,r._boundingDimensions.y,0),new o.x(r._boundingDimensions.x,r._boundingDimensions.y,0)]},i.utilityLayerScene)),c.push(Tr.a.CreateLines("lines",{points:[new o.x(0,r._boundingDimensions.y,0),new o.x(0,r._boundingDimensions.y,r._boundingDimensions.z)]},i.utilityLayerScene)),c.push(Tr.a.CreateLines("lines",{points:[new o.x(0,0,r._boundingDimensions.z),new o.x(r._boundingDimensions.x,0,r._boundingDimensions.z)]},i.utilityLayerScene)),c.push(Tr.a.CreateLines("lines",{points:[new o.x(0,0,r._boundingDimensions.z),new o.x(0,r._boundingDimensions.y,r._boundingDimensions.z)]},i.utilityLayerScene)),c.push(Tr.a.CreateLines("lines",{points:[new o.x(r._boundingDimensions.x,r._boundingDimensions.y,r._boundingDimensions.z),new o.x(0,r._boundingDimensions.y,r._boundingDimensions.z)]},i.utilityLayerScene)),c.push(Tr.a.CreateLines("lines",{points:[new o.x(r._boundingDimensions.x,r._boundingDimensions.y,r._boundingDimensions.z),new o.x(r._boundingDimensions.x,0,r._boundingDimensions.z)]},i.utilityLayerScene)),c.push(Tr.a.CreateLines("lines",{points:[new o.x(r._boundingDimensions.x,r._boundingDimensions.y,r._boundingDimensions.z),new o.x(r._boundingDimensions.x,r._boundingDimensions.y,0)]},i.utilityLayerScene)),c.forEach(function(e){e.color=t,e.position.addInPlace(new o.x(-r._boundingDimensions.x/2,-r._boundingDimensions.y/2,-r._boundingDimensions.z/2)),e.isPickable=!1,r._lineBoundingBox.addChild(e)}),r._rootMesh.addChild(r._lineBoundingBox),r._rotateSpheresParent=new we.a("",i.utilityLayerScene),r._rotateSpheresParent.rotationQuaternion=new o.q;for(var l=function(e){var t=Pr.a.CreateSphere("",{diameter:1},i.utilityLayerScene);t.rotationQuaternion=new o.q,t.material=s,(_=new Ie.a({})).moveAttached=!1,_.updateDragPlane=!1,t.addBehavior(_);var n=new o.x(1,0,0),a=0;_.onDragStartObservable.add(function(){n.copyFrom(t.forward),a=0}),_.onDragObservable.add(function(t){if(r.onRotationSphereDragObservable.notifyObservers({}),r.attachedMesh){var i=r.attachedMesh.parent;if(i&&i.scaling&&i.scaling.isNonUniformWithinEpsilon(.001))return void p.a.Warn("BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling");Fe.a._RemoveAndStorePivotPoint(r.attachedMesh);var s=n,c=t.dragPlaneNormal.scale(o.x.Dot(t.dragPlaneNormal,s)),l=s.subtract(c).normalizeToNew(),u=o.x.Dot(l,t.delta)<0?Math.abs(t.delta.length()):-Math.abs(t.delta.length());u=u/r._boundingDimensions.length()*r._anchorMesh.scaling.length(),r.attachedMesh.rotationQuaternion||(r.attachedMesh.rotationQuaternion=o.q.RotationYawPitchRoll(r.attachedMesh.rotation.y,r.attachedMesh.rotation.x,r.attachedMesh.rotation.z)),r._anchorMesh.rotationQuaternion||(r._anchorMesh.rotationQuaternion=o.q.RotationYawPitchRoll(r._anchorMesh.rotation.y,r._anchorMesh.rotation.x,r._anchorMesh.rotation.z)),a+=u,Math.abs(a)<=2*Math.PI&&(e>=8?o.q.RotationYawPitchRollToRef(0,0,u,r._tmpQuaternion):e>=4?o.q.RotationYawPitchRollToRef(u,0,0,r._tmpQuaternion):o.q.RotationYawPitchRollToRef(0,u,0,r._tmpQuaternion),r._anchorMesh.addChild(r.attachedMesh),r._anchorMesh.rotationQuaternion.multiplyToRef(r._tmpQuaternion,r._anchorMesh.rotationQuaternion),r._anchorMesh.removeChild(r.attachedMesh),r.attachedMesh.setParent(i)),r.updateBoundingBox(),Fe.a._RestorePivotPoint(r.attachedMesh)}r._updateDummy()}),_.onDragStartObservable.add(function(){r.onDragStartObservable.notifyObservers({}),r._selectNode(t)}),_.onDragEndObservable.add(function(){r.onRotationSphereDragEndObservable.notifyObservers({}),r._selectNode(null),r._updateDummy()}),u._rotateSpheresParent.addChild(t)},u=this,h=0;h<12;h++)l(h);r._rootMesh.addChild(r._rotateSpheresParent),r._scaleBoxesParent=new we.a("",i.utilityLayerScene),r._scaleBoxesParent.rotationQuaternion=new o.q;for(var d=0;d<2;d++)for(var f=0;f<2;f++)for(var _,g=function(){var e=br.a.CreateBox("",{size:1},i.utilityLayerScene);e.material=s;var t=new o.x(0==d?-1:1,0==f?-1:1,0==v?-1:1);(_=new Ie.a({dragAxis:t})).moveAttached=!1,e.addBehavior(_),_.onDragObservable.add(function(t){if(r.onScaleBoxDragObservable.notifyObservers({}),r.attachedMesh){var i=r.attachedMesh.parent;if(i&&i.scaling&&i.scaling.isNonUniformWithinEpsilon(.001))return void p.a.Warn("BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling");Fe.a._RemoveAndStorePivotPoint(r.attachedMesh);var n=t.dragDistance/r._boundingDimensions.length()*r._anchorMesh.scaling.length(),s=new o.x(n,n,n);s.scaleInPlace(r._scaleDragSpeed),r.updateBoundingBox(),r.scalePivot?(r.attachedMesh.getWorldMatrix().getRotationMatrixToRef(r._tmpRotationMatrix),r._boundingDimensions.scaleToRef(.5,r._tmpVector),o.x.TransformCoordinatesToRef(r._tmpVector,r._tmpRotationMatrix,r._tmpVector),r._anchorMesh.position.subtractInPlace(r._tmpVector),r._boundingDimensions.multiplyToRef(r.scalePivot,r._tmpVector),o.x.TransformCoordinatesToRef(r._tmpVector,r._tmpRotationMatrix,r._tmpVector),r._anchorMesh.position.addInPlace(r._tmpVector)):(e.absolutePosition.subtractToRef(r._anchorMesh.position,r._tmpVector),r._anchorMesh.position.subtractInPlace(r._tmpVector)),r._anchorMesh.addChild(r.attachedMesh),r._anchorMesh.scaling.addInPlace(s),(r._anchorMesh.scaling.x<0||r._anchorMesh.scaling.y<0||r._anchorMesh.scaling.z<0)&&r._anchorMesh.scaling.subtractInPlace(s),r._anchorMesh.removeChild(r.attachedMesh),r.attachedMesh.setParent(i),Fe.a._RestorePivotPoint(r.attachedMesh)}r._updateDummy()}),_.onDragStartObservable.add(function(){r.onDragStartObservable.notifyObservers({}),r._selectNode(e)}),_.onDragEndObservable.add(function(){r.onScaleBoxDragEndObservable.notifyObservers({}),r._selectNode(null),r._updateDummy()}),m._scaleBoxesParent.addChild(e)},m=this,v=0;v<2;v++)g();r._rootMesh.addChild(r._scaleBoxesParent);var y=new Array;return r._pointerObserver=i.utilityLayerScene.onPointerObservable.add(function(e){y[e.event.pointerId]?e.pickInfo&&e.pickInfo.pickedMesh!=y[e.event.pointerId]&&(y[e.event.pointerId].material=s,delete y[e.event.pointerId]):r._rotateSpheresParent.getChildMeshes().concat(r._scaleBoxesParent.getChildMeshes()).forEach(function(t){e.pickInfo&&e.pickInfo.pickedMesh==t&&(y[e.event.pointerId]=t,t.material=a)})}),r._renderObserver=r.gizmoLayer.originalScene.onBeforeRenderObservable.add(function(){r.attachedMesh&&!r._existingMeshScale.equals(r.attachedMesh.scaling)?r.updateBoundingBox():r.fixedDragMeshScreenSize&&(r._updateRotationSpheres(),r._updateScaleBoxes()),r._dragMesh&&r.attachedMesh&&r.pointerDragBehavior.dragging&&(r._lineBoundingBox.position.rotateByQuaternionToRef(r._rootMesh.rotationQuaternion,r._tmpVector),r.attachedMesh.setAbsolutePosition(r._dragMesh.position.add(r._tmpVector.scale(-1))))}),r.updateBoundingBox(),r}return l.d(t,e),t.prototype._attachedMeshChanged=function(e){var t=this;if(e){Fe.a._RemoveAndStorePivotPoint(e);var i=e.parent;this._anchorMesh.addChild(e),this._anchorMesh.removeChild(e),e.setParent(i),Fe.a._RestorePivotPoint(e),this.updateBoundingBox(),e.getChildMeshes(!1).forEach(function(e){e.markAsDirty("scaling")}),this.gizmoLayer.utilityLayerScene.onAfterRenderObservable.addOnce(function(){t._updateDummy()})}},t.prototype._selectNode=function(e){this._rotateSpheresParent.getChildMeshes().concat(this._scaleBoxesParent.getChildMeshes()).forEach(function(t){t.isVisible=!e||t==e})},t.prototype.updateBoundingBox=function(){if(this.attachedMesh){Fe.a._RemoveAndStorePivotPoint(this.attachedMesh);var e=this.attachedMesh.parent;this.attachedMesh.setParent(null),this._update(),this.attachedMesh.rotationQuaternion||(this.attachedMesh.rotationQuaternion=o.q.RotationYawPitchRoll(this.attachedMesh.rotation.y,this.attachedMesh.rotation.x,this.attachedMesh.rotation.z)),this._anchorMesh.rotationQuaternion||(this._anchorMesh.rotationQuaternion=o.q.RotationYawPitchRoll(this._anchorMesh.rotation.y,this._anchorMesh.rotation.x,this._anchorMesh.rotation.z)),this._anchorMesh.rotationQuaternion.copyFrom(this.attachedMesh.rotationQuaternion),this._tmpQuaternion.copyFrom(this.attachedMesh.rotationQuaternion),this._tmpVector.copyFrom(this.attachedMesh.position),this.attachedMesh.rotationQuaternion.set(0,0,0,1),this.attachedMesh.position.set(0,0,0);var t=this.attachedMesh.getHierarchyBoundingVectors(!this.ignoreChildren,this.includeChildPredicate);t.max.subtractToRef(t.min,this._boundingDimensions),this._lineBoundingBox.scaling.copyFrom(this._boundingDimensions),this._lineBoundingBox.position.set((t.max.x+t.min.x)/2,(t.max.y+t.min.y)/2,(t.max.z+t.min.z)/2),this._rotateSpheresParent.position.copyFrom(this._lineBoundingBox.position),this._scaleBoxesParent.position.copyFrom(this._lineBoundingBox.position),this._lineBoundingBox.computeWorldMatrix(),this._anchorMesh.position.copyFrom(this._lineBoundingBox.absolutePosition),this.attachedMesh.rotationQuaternion.copyFrom(this._tmpQuaternion),this.attachedMesh.position.copyFrom(this._tmpVector),this.attachedMesh.setParent(e)}this._updateRotationSpheres(),this._updateScaleBoxes(),this.attachedMesh&&(this._existingMeshScale.copyFrom(this.attachedMesh.scaling),Fe.a._RestorePivotPoint(this.attachedMesh))},t.prototype._updateRotationSpheres=function(){for(var e=this._rotateSpheresParent.getChildMeshes(),t=0;t<3;t++)for(var i=0;i<2;i++)for(var r=0;r<2;r++){var n=4*t+2*i+r;if(0==t&&(e[n].position.set(this._boundingDimensions.x/2,this._boundingDimensions.y*i,this._boundingDimensions.z*r),e[n].position.addInPlace(new o.x(-this._boundingDimensions.x/2,-this._boundingDimensions.y/2,-this._boundingDimensions.z/2)),e[n].lookAt(o.x.Cross(e[n].position.normalizeToNew(),o.x.Right()).normalizeToNew().add(e[n].position))),1==t&&(e[n].position.set(this._boundingDimensions.x*i,this._boundingDimensions.y/2,this._boundingDimensions.z*r),e[n].position.addInPlace(new o.x(-this._boundingDimensions.x/2,-this._boundingDimensions.y/2,-this._boundingDimensions.z/2)),e[n].lookAt(o.x.Cross(e[n].position.normalizeToNew(),o.x.Up()).normalizeToNew().add(e[n].position))),2==t&&(e[n].position.set(this._boundingDimensions.x*i,this._boundingDimensions.y*r,this._boundingDimensions.z/2),e[n].position.addInPlace(new o.x(-this._boundingDimensions.x/2,-this._boundingDimensions.y/2,-this._boundingDimensions.z/2)),e[n].lookAt(o.x.Cross(e[n].position.normalizeToNew(),o.x.Forward()).normalizeToNew().add(e[n].position))),this.fixedDragMeshScreenSize&&this.gizmoLayer.utilityLayerScene.activeCamera){e[n].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position,this._tmpVector);var s=this.rotationSphereSize*this._tmpVector.length()/this.fixedDragMeshScreenSizeDistanceFactor;e[n].scaling.set(s,s,s)}else e[n].scaling.set(this.rotationSphereSize,this.rotationSphereSize,this.rotationSphereSize)}},t.prototype._updateScaleBoxes=function(){for(var e=this._scaleBoxesParent.getChildMeshes(),t=0;t<2;t++)for(var i=0;i<2;i++)for(var r=0;r<2;r++){var n=4*t+2*i+r;if(e[n])if(e[n].position.set(this._boundingDimensions.x*t,this._boundingDimensions.y*i,this._boundingDimensions.z*r),e[n].position.addInPlace(new o.x(-this._boundingDimensions.x/2,-this._boundingDimensions.y/2,-this._boundingDimensions.z/2)),this.fixedDragMeshScreenSize&&this.gizmoLayer.utilityLayerScene.activeCamera){e[n].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position,this._tmpVector);var s=this.scaleBoxSize*this._tmpVector.length()/this.fixedDragMeshScreenSizeDistanceFactor;e[n].scaling.set(s,s,s)}else e[n].scaling.set(this.scaleBoxSize,this.scaleBoxSize,this.scaleBoxSize)}},t.prototype.setEnabledRotationAxis=function(e){this._rotateSpheresParent.getChildMeshes().forEach(function(t,i){i<4?t.setEnabled(-1!=e.indexOf("x")):i<8?t.setEnabled(-1!=e.indexOf("y")):t.setEnabled(-1!=e.indexOf("z"))})},t.prototype.setEnabledScaling=function(e){this._scaleBoxesParent.getChildMeshes().forEach(function(t,i){t.setEnabled(e)})},t.prototype._updateDummy=function(){this._dragMesh&&(this._dragMesh.position.copyFrom(this._lineBoundingBox.getAbsolutePosition()),this._dragMesh.scaling.copyFrom(this._lineBoundingBox.scaling),this._dragMesh.rotationQuaternion.copyFrom(this._rootMesh.rotationQuaternion))},t.prototype.enableDragBehavior=function(){this._dragMesh=de.a.CreateBox("dummy",1,this.gizmoLayer.utilityLayerScene),this._dragMesh.visibility=0,this._dragMesh.rotationQuaternion=new o.q,this.pointerDragBehavior.useObjectOrienationForDragging=!1,this._dragMesh.addBehavior(this.pointerDragBehavior)},t.prototype.dispose=function(){this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver),this.gizmoLayer.originalScene.onBeforeRenderObservable.remove(this._renderObserver),this._lineBoundingBox.dispose(),this._rotateSpheresParent.dispose(),this._scaleBoxesParent.dispose(),this._dragMesh&&this._dragMesh.dispose(),e.prototype.dispose.call(this)},t.MakeNotPickableAndWrapInBoundingBox=function(e){var t=function(e){e.isPickable=!1,e.getChildMeshes().forEach(function(e){t(e)})};t(e),e.rotationQuaternion||(e.rotationQuaternion=o.q.RotationYawPitchRoll(e.rotation.y,e.rotation.x,e.rotation.z));var i=e.position.clone(),r=e.rotationQuaternion.clone();e.rotationQuaternion.set(0,0,0,1),e.position.set(0,0,0);var n=br.a.CreateBox("box",{size:1},e.getScene()),s=e.getHierarchyBoundingVectors();return s.max.subtractToRef(s.min,n.scaling),0===n.scaling.y&&(n.scaling.y=o.h),0===n.scaling.x&&(n.scaling.x=o.h),0===n.scaling.z&&(n.scaling.z=o.h),n.position.set((s.max.x+s.min.x)/2,(s.max.y+s.min.y)/2,(s.max.z+s.min.z)/2),e.addChild(n),e.rotationQuaternion.copyFrom(r),e.position.copyFrom(i),e.removeChild(n),n.addChild(e),n.visibility=0,n},t.prototype.setCustomMesh=function(e){p.a.Error("Custom meshes are not supported on this gizmo")},t}(Er.a),Sr=function(e){function t(t,i,r,s){void 0===i&&(i=o.e.Gray()),void 0===r&&(r=xr.a.DefaultUtilityLayer),void 0===s&&(s=32);var a=e.call(this,r)||this;a._pointerObserver=null,a.snapDistance=0,a.onSnapObservable=new n.c;var c=new hi.a("",r.utilityLayerScene);c.disableLighting=!0,c.emissiveColor=i;var l=new hi.a("",r.utilityLayerScene);l.disableLighting=!0,l.emissiveColor=i.add(new o.e(.3,.3,.3));for(var u=new we.a("",r.utilityLayerScene),h=new Array,d=0;d<s;d++){var f=2*Math.PI*(d/(s-1));h.push(new o.x(.8*Math.sin(f),0,.8*Math.cos(f)))}var p=de.a.CreateLines("",h,r.utilityLayerScene);p.color=c.emissiveColor,p.scaling.scaleInPlace(.26),p.material=c,p.rotation.x=Math.PI/2,u.addChild(p),u.lookAt(a._rootMesh.position.add(t)),a._rootMesh.addChild(u),u.scaling.scaleInPlace(1/3),a.dragBehavior=new Ie.a({dragPlaneNormal:t}),a.dragBehavior.moveAttached=!1,a.dragBehavior.maxDragAngle=9*Math.PI/20,a.dragBehavior._useAlternatePickedPointAboveMaxDragAngle=!0,a._rootMesh.addBehavior(a.dragBehavior);var _=new o.x;a.dragBehavior.onDragStartObservable.add(function(e){a.attachedMesh&&_.copyFrom(e.dragPlanePoint)});var g=new o.j,m=new o.x,v=new o.x,y={snapDistance:0},b=0,T=new o.j,E=new o.x,x=new o.q;return a.dragBehavior.onDragObservable.add(function(e){if(a.attachedMesh){a.attachedMesh.rotationQuaternion||(a.attachedMesh.rotationQuaternion=o.q.RotationYawPitchRoll(a.attachedMesh.rotation.y,a.attachedMesh.rotation.x,a.attachedMesh.rotation.z));var i=e.dragPlanePoint.subtract(a.attachedMesh.absolutePosition).normalize(),n=_.subtract(a.attachedMesh.absolutePosition).normalize(),s=o.x.Cross(i,n),c=o.x.Dot(i,n),l=Math.atan2(s.length(),c);if(m.copyFrom(t),v.copyFrom(t),a.updateGizmoRotationToMatchAttachedMesh&&(a.attachedMesh.rotationQuaternion.toRotationMatrix(g),v=o.x.TransformCoordinates(m,g)),r.utilityLayerScene.activeCamera){var u=r.utilityLayerScene.activeCamera.position.subtract(a.attachedMesh.position);o.x.Dot(u,v)>0&&(m.scaleInPlace(-1),v.scaleInPlace(-1))}o.x.Dot(v,s)>0&&(l=-l);var h=!1;if(0!=a.snapDistance)if(b+=l,Math.abs(b)>a.snapDistance){var d=Math.floor(Math.abs(b)/a.snapDistance);b<0&&(d*=-1),b%=a.snapDistance,l=a.snapDistance*d,h=!0}else l=0;T.reset(),a.attachedMesh.parent&&(a.attachedMesh.parent.computeWorldMatrix().invertToRef(T),T.getRotationMatrixToRef(T),o.x.TransformCoordinatesToRef(m,T,m));var f=Math.sin(l/2);x.set(m.x*f,m.y*f,m.z*f,Math.cos(l/2)),T.determinant()>0&&(x.toEulerAnglesToRef(E),o.q.RotationYawPitchRollToRef(E.y,-E.x,-E.z,x)),a.updateGizmoRotationToMatchAttachedMesh?a.attachedMesh.rotationQuaternion.multiplyToRef(x,a.attachedMesh.rotationQuaternion):x.multiplyToRef(a.attachedMesh.rotationQuaternion,a.attachedMesh.rotationQuaternion),_.copyFrom(e.dragPlanePoint),h&&(y.snapDistance=l,a.onSnapObservable.notifyObservers(y))}}),a._pointerObserver=r.utilityLayerScene.onPointerObservable.add(function(e){if(!a._customMeshSet){var t=e.pickInfo&&-1!=a._rootMesh.getChildMeshes().indexOf(e.pickInfo.pickedMesh)?l:c;a._rootMesh.getChildMeshes().forEach(function(e){e.material=t,e.color&&(e.color=t.emissiveColor)})}}),a}return l.d(t,e),t.prototype._attachedMeshChanged=function(e){this.dragBehavior&&(this.dragBehavior.enabled=!!e)},t.prototype.dispose=function(){this.onSnapObservable.clear(),this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver),this.dragBehavior.detach(),e.prototype.dispose.call(this)},t}(Er.a),Cr=function(e){function t(t,i){void 0===t&&(t=xr.a.DefaultUtilityLayer),void 0===i&&(i=32);var r=e.call(this,t)||this;return r.onDragStartObservable=new n.c,r.onDragEndObservable=new n.c,r.xGizmo=new Sr(new o.x(1,0,0),o.e.Red().scale(.5),t,i),r.yGizmo=new Sr(new o.x(0,1,0),o.e.Green().scale(.5),t,i),r.zGizmo=new Sr(new o.x(0,0,1),o.e.Blue().scale(.5),t,i),[r.xGizmo,r.yGizmo,r.zGizmo].forEach(function(e){e.dragBehavior.onDragStartObservable.add(function(){r.onDragStartObservable.notifyObservers({})}),e.dragBehavior.onDragEndObservable.add(function(){r.onDragEndObservable.notifyObservers({})})}),r.attachedMesh=null,r}return l.d(t,e),Object.defineProperty(t.prototype,"attachedMesh",{set:function(e){this.xGizmo&&(this.xGizmo.attachedMesh=e,this.yGizmo.attachedMesh=e,this.zGizmo.attachedMesh=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"updateGizmoRotationToMatchAttachedMesh",{get:function(){return this.xGizmo.updateGizmoRotationToMatchAttachedMesh},set:function(e){this.xGizmo&&(this.xGizmo.updateGizmoRotationToMatchAttachedMesh=e,this.yGizmo.updateGizmoRotationToMatchAttachedMesh=e,this.zGizmo.updateGizmoRotationToMatchAttachedMesh=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"snapDistance",{get:function(){return this.xGizmo.snapDistance},set:function(e){this.xGizmo&&(this.xGizmo.snapDistance=e,this.yGizmo.snapDistance=e,this.zGizmo.snapDistance=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"scaleRatio",{get:function(){return this.xGizmo.scaleRatio},set:function(e){this.xGizmo&&(this.xGizmo.scaleRatio=e,this.yGizmo.scaleRatio=e,this.zGizmo.scaleRatio=e)},enumerable:!0,configurable:!0}),t.prototype.dispose=function(){this.xGizmo.dispose(),this.yGizmo.dispose(),this.zGizmo.dispose(),this.onDragStartObservable.clear(),this.onDragEndObservable.clear()},t.prototype.setCustomMesh=function(e){p.a.Error("Custom meshes are not supported on this gizmo, please set the custom meshes on the gizmos contained within this one (gizmo.xGizmo, gizmo.yGizmo, gizmo.zGizmo)")},t}(Er.a),Mr=function(e){function t(t){void 0===t&&(t=xr.a.DefaultUtilityLayer);var i=e.call(this,t)||this;return i.onDragStartObservable=new n.c,i.onDragEndObservable=new n.c,i.xGizmo=new yr.a(new o.x(1,0,0),o.e.Red().scale(.5),t),i.yGizmo=new yr.a(new o.x(0,1,0),o.e.Green().scale(.5),t),i.zGizmo=new yr.a(new o.x(0,0,1),o.e.Blue().scale(.5),t),[i.xGizmo,i.yGizmo,i.zGizmo].forEach(function(e){e.dragBehavior.onDragStartObservable.add(function(){i.onDragStartObservable.notifyObservers({})}),e.dragBehavior.onDragEndObservable.add(function(){i.onDragEndObservable.notifyObservers({})})}),i.attachedMesh=null,i}return l.d(t,e),Object.defineProperty(t.prototype,"attachedMesh",{set:function(e){this.xGizmo&&(this.xGizmo.attachedMesh=e,this.yGizmo.attachedMesh=e,this.zGizmo.attachedMesh=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"updateGizmoRotationToMatchAttachedMesh",{get:function(){return this.xGizmo.updateGizmoRotationToMatchAttachedMesh},set:function(e){this.xGizmo&&(this.xGizmo.updateGizmoRotationToMatchAttachedMesh=e,this.yGizmo.updateGizmoRotationToMatchAttachedMesh=e,this.zGizmo.updateGizmoRotationToMatchAttachedMesh=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"snapDistance",{get:function(){return this.xGizmo.snapDistance},set:function(e){this.xGizmo&&(this.xGizmo.snapDistance=e,this.yGizmo.snapDistance=e,this.zGizmo.snapDistance=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"scaleRatio",{get:function(){return this.xGizmo.scaleRatio},set:function(e){this.xGizmo&&(this.xGizmo.scaleRatio=e,this.yGizmo.scaleRatio=e,this.zGizmo.scaleRatio=e)},enumerable:!0,configurable:!0}),t.prototype.dispose=function(){this.xGizmo.dispose(),this.yGizmo.dispose(),this.zGizmo.dispose(),this.onDragStartObservable.clear(),this.onDragEndObservable.clear()},t.prototype.setCustomMesh=function(e){p.a.Error("Custom meshes are not supported on this gizmo, please set the custom meshes on the gizmos contained within this one (gizmo.xGizmo, gizmo.yGizmo, gizmo.zGizmo)")},t}(Er.a);_i.a.CreatePolyhedron=function(e){var t=[];t[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]]},t[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]]},t[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]]},t[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]]},t[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]]},t[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]]},t[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]]},t[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]]},t[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]]},t[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]]},t[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]]},t[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]]},t[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]]},t[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]]},t[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 i,r,n,s,a,c,l=e.type&&(e.type<0||e.type>=t.length)?0:e.type||0,u=e.size,h=e.sizeX||u||1,d=e.sizeY||u||1,f=e.sizeZ||u||1,p=e.custom||t[l],_=p.face.length,g=e.faceUV||new Array(_),m=e.faceColors,v=void 0===e.flat||e.flat,y=0===e.sideOrientation?0:e.sideOrientation||_i.a.DEFAULTSIDE,b=new Array,T=new Array,E=new Array,x=new Array,A=new Array,P=0,R=0,S=new Array,C=0,M=0;if(v)for(M=0;M<_;M++)m&&void 0===m[M]&&(m[M]=new o.f(1,1,1,1)),g&&void 0===g[M]&&(g[M]=new o.y(0,0,1,1));if(v)for(M=0;M<_;M++){var O=p.face[M].length;for(n=2*Math.PI/O,s=.5*Math.tan(n/2),a=.5,C=0;C<O;C++)b.push(p.vertex[p.face[M][C]][0]*h,p.vertex[p.face[M][C]][1]*d,p.vertex[p.face[M][C]][2]*f),S.push(P),P++,i=g[M].x+(g[M].z-g[M].x)*(.5+s),r=g[M].y+(g[M].w-g[M].y)*(a-.5),x.push(i,r),c=s*Math.cos(n)-a*Math.sin(n),a=s*Math.sin(n)+a*Math.cos(n),s=c,m&&A.push(m[M].r,m[M].g,m[M].b,m[M].a);for(C=0;C<O-2;C++)T.push(S[0+R],S[C+2+R],S[C+1+R]);R+=O}else{for(C=0;C<p.vertex.length;C++)b.push(p.vertex[C][0]*h,p.vertex[C][1]*d,p.vertex[C][2]*f),x.push(0,0);for(M=0;M<_;M++)for(C=0;C<p.face[M].length-2;C++)T.push(p.face[M][0],p.face[M][C+2],p.face[M][C+1])}_i.a.ComputeNormals(b,T,E),_i.a._ComputeSides(y,b,T,E,x,e.frontUVs,e.backUVs);var I=new _i.a;return I.positions=b,I.indices=T,I.normals=E,I.uvs=x,m&&v&&(I.colors=A),I},de.a.CreatePolyhedron=function(e,t,i){return Or.CreatePolyhedron(e,t,i)};var Or=function(){function e(){}return e.CreatePolyhedron=function(e,t,i){var r=new de.a(e,i);return t.sideOrientation=de.a._GetDefaultSideOrientation(t.sideOrientation),r._originalBuilderSideOrientation=t.sideOrientation,_i.a.CreatePolyhedron(t).applyToMesh(r,t.updatable),r},e}(),Ir=function(e){function t(t){void 0===t&&(t=xr.a.DefaultUtilityLayer);var i=e.call(this,t)||this;i.onDragStartObservable=new n.c,i.onDragEndObservable=new n.c,i.xGizmo=new Ar(new o.x(1,0,0),o.e.Red().scale(.5),t),i.yGizmo=new Ar(new o.x(0,1,0),o.e.Green().scale(.5),t),i.zGizmo=new Ar(new o.x(0,0,1),o.e.Blue().scale(.5),t),i.uniformScaleGizmo=new Ar(new o.x(0,1,0),o.e.Yellow().scale(.5),t),i.uniformScaleGizmo.updateGizmoRotationToMatchAttachedMesh=!1,i.uniformScaleGizmo.uniformScaling=!0;var r=Or.CreatePolyhedron("",{type:1},i.uniformScaleGizmo.gizmoLayer.utilityLayerScene);r.scaling.scaleInPlace(.02),r.visibility=0;var s=Or.CreatePolyhedron("",{type:1},i.uniformScaleGizmo.gizmoLayer.utilityLayerScene);return s.scaling.scaleInPlace(.007),r.addChild(s),i.uniformScaleGizmo.setCustomMesh(r,!0),[i.xGizmo,i.yGizmo,i.zGizmo,i.uniformScaleGizmo].forEach(function(e){e.dragBehavior.onDragStartObservable.add(function(){i.onDragStartObservable.notifyObservers({})}),e.dragBehavior.onDragEndObservable.add(function(){i.onDragEndObservable.notifyObservers({})})}),i.attachedMesh=null,i}return l.d(t,e),Object.defineProperty(t.prototype,"attachedMesh",{set:function(e){this.xGizmo&&(this.xGizmo.attachedMesh=e,this.yGizmo.attachedMesh=e,this.zGizmo.attachedMesh=e,this.uniformScaleGizmo.attachedMesh=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"updateGizmoRotationToMatchAttachedMesh",{get:function(){return this.xGizmo.updateGizmoRotationToMatchAttachedMesh},set:function(e){e||p.a.Warn("Setting updateGizmoRotationToMatchAttachedMesh = false on scaling gizmo is not supported."),this.xGizmo&&(this.xGizmo.updateGizmoRotationToMatchAttachedMesh=e,this.yGizmo.updateGizmoRotationToMatchAttachedMesh=e,this.zGizmo.updateGizmoRotationToMatchAttachedMesh=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"snapDistance",{get:function(){return this.xGizmo.snapDistance},set:function(e){this.xGizmo&&(this.xGizmo.snapDistance=e,this.yGizmo.snapDistance=e,this.zGizmo.snapDistance=e,this.uniformScaleGizmo.snapDistance=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"scaleRatio",{get:function(){return this.xGizmo.scaleRatio},set:function(e){this.xGizmo&&(this.xGizmo.scaleRatio=e,this.yGizmo.scaleRatio=e,this.zGizmo.scaleRatio=e,this.uniformScaleGizmo.scaleRatio=e)},enumerable:!0,configurable:!0}),t.prototype.dispose=function(){this.xGizmo.dispose(),this.yGizmo.dispose(),this.zGizmo.dispose(),this.uniformScaleGizmo.dispose(),this.onDragStartObservable.clear(),this.onDragEndObservable.clear()},t}(Er.a),Dr=function(){function e(e){var t=this;this.scene=e,this.clearGizmoOnEmptyPointerEvent=!1,this.onAttachedToMeshObservable=new n.c,this._gizmosEnabled={positionGizmo:!1,rotationGizmo:!1,scaleGizmo:!1,boundingBoxGizmo:!1},this._pointerObserver=null,this._attachedMesh=null,this._boundingBoxColor=o.e.FromHexString("#0984e3"),this.boundingBoxDragBehavior=new Ne,this.attachableMeshes=null,this.usePointerToAttachGizmos=!0,this._defaultKeepDepthUtilityLayer=new xr.a(e),this._defaultKeepDepthUtilityLayer.utilityLayerScene.autoClearDepthAndStencil=!1,this._defaultUtilityLayer=new xr.a(e),this.gizmos={positionGizmo:null,rotationGizmo:null,scaleGizmo:null,boundingBoxGizmo:null},this._pointerObserver=e.onPointerObservable.add(function(e){if(t.usePointerToAttachGizmos&&e.type==Ae.a.POINTERDOWN)if(e.pickInfo&&e.pickInfo.pickedMesh){var i=e.pickInfo.pickedMesh;if(null==t.attachableMeshes)for(;i&&null!=i.parent;)i=i.parent;else{var r=!1;t.attachableMeshes.forEach(function(e){i&&(i==e||i.isDescendantOf(e))&&(i=e,r=!0)}),r||(i=null)}i instanceof we.a?t._attachedMesh!=i&&t.attachToMesh(i):t.clearGizmoOnEmptyPointerEvent&&t.attachToMesh(null)}else t.clearGizmoOnEmptyPointerEvent&&t.attachToMesh(null)})}return e.prototype.attachToMesh=function(e){for(var t in this._attachedMesh&&this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior),this._attachedMesh=e,this.gizmos){var i=this.gizmos[t];i&&this._gizmosEnabled[t]&&(i.attachedMesh=e)}this.boundingBoxGizmoEnabled&&this._attachedMesh&&this._attachedMesh.addBehavior(this.boundingBoxDragBehavior),this.onAttachedToMeshObservable.notifyObservers(e)},Object.defineProperty(e.prototype,"positionGizmoEnabled",{get:function(){return this._gizmosEnabled.positionGizmo},set:function(e){e?(this.gizmos.positionGizmo||(this.gizmos.positionGizmo=new Mr(this._defaultUtilityLayer)),this.gizmos.positionGizmo.attachedMesh=this._attachedMesh):this.gizmos.positionGizmo&&(this.gizmos.positionGizmo.attachedMesh=null),this._gizmosEnabled.positionGizmo=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rotationGizmoEnabled",{get:function(){return this._gizmosEnabled.rotationGizmo},set:function(e){e?(this.gizmos.rotationGizmo||(this.gizmos.rotationGizmo=new Cr(this._defaultUtilityLayer)),this.gizmos.rotationGizmo.attachedMesh=this._attachedMesh):this.gizmos.rotationGizmo&&(this.gizmos.rotationGizmo.attachedMesh=null),this._gizmosEnabled.rotationGizmo=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"scaleGizmoEnabled",{get:function(){return this._gizmosEnabled.scaleGizmo},set:function(e){e?(this.gizmos.scaleGizmo=this.gizmos.scaleGizmo||new Ir(this._defaultUtilityLayer),this.gizmos.scaleGizmo.attachedMesh=this._attachedMesh):this.gizmos.scaleGizmo&&(this.gizmos.scaleGizmo.attachedMesh=null),this._gizmosEnabled.scaleGizmo=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"boundingBoxGizmoEnabled",{get:function(){return this._gizmosEnabled.boundingBoxGizmo},set:function(e){e?(this.gizmos.boundingBoxGizmo=this.gizmos.boundingBoxGizmo||new Rr(this._boundingBoxColor,this._defaultKeepDepthUtilityLayer),this.gizmos.boundingBoxGizmo.attachedMesh=this._attachedMesh,this._attachedMesh&&(this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior),this._attachedMesh.addBehavior(this.boundingBoxDragBehavior))):this.gizmos.boundingBoxGizmo&&(this.gizmos.boundingBoxGizmo.attachedMesh=null),this._gizmosEnabled.boundingBoxGizmo=e},enumerable:!0,configurable:!0}),e.prototype.dispose=function(){for(var e in this.scene.onPointerObservable.remove(this._pointerObserver),this.gizmos){var t=this.gizmos[e];t&&t.dispose()}this._defaultKeepDepthUtilityLayer.dispose(),this._defaultUtilityLayer.dispose(),this.boundingBoxDragBehavior.detach(),this.onAttachedToMeshObservable.clear()},e}(),wr=i(44);St.a.IncludesShadersStore.kernelBlurVaryingDeclaration="varying vec2 sampleCoord{X};";var Lr="#ifdef DOF\nfactor=sampleCoC(sampleCoord{X});\ncomputedWeight=KERNEL_WEIGHT{X}*factor;\nsumOfWeights+=computedWeight;\n#else\ncomputedWeight=KERNEL_WEIGHT{X};\n#endif\n#ifdef PACKEDFLOAT\nblend+=unpack(texture2D(textureSampler,sampleCoord{X}))*computedWeight;\n#else\nblend+=texture2D(textureSampler,sampleCoord{X})*computedWeight;\n#endif";St.a.IncludesShadersStore.kernelBlurFragment=Lr;var Fr="#ifdef DOF\nfactor=sampleCoC(sampleCenter+delta*KERNEL_DEP_OFFSET{X});\ncomputedWeight=KERNEL_DEP_WEIGHT{X}*factor;\nsumOfWeights+=computedWeight;\n#else\ncomputedWeight=KERNEL_DEP_WEIGHT{X};\n#endif\n#ifdef PACKEDFLOAT\nblend+=unpack(texture2D(textureSampler,sampleCenter+delta*KERNEL_DEP_OFFSET{X}))*computedWeight;\n#else\nblend+=texture2D(textureSampler,sampleCenter+delta*KERNEL_DEP_OFFSET{X})*computedWeight;\n#endif";St.a.IncludesShadersStore.kernelBlurFragment2=Fr;var Nr="\nuniform sampler2D textureSampler;\nuniform vec2 delta;\n\nvarying vec2 sampleCenter;\n#ifdef DOF\nuniform sampler2D circleOfConfusionSampler;\nuniform vec2 cameraMinMaxZ;\nfloat sampleDistance(const in vec2 offset) {\nfloat depth=texture2D(circleOfConfusionSampler,offset).g;\nreturn cameraMinMaxZ.x+(cameraMinMaxZ.y-cameraMinMaxZ.x)*depth;\n}\nfloat sampleCoC(const in vec2 offset) {\nfloat coc=texture2D(circleOfConfusionSampler,offset).r;\nreturn coc;\n}\n#endif\n#include<kernelBlurVaryingDeclaration>[0..varyingCount]\n#ifdef PACKEDFLOAT\nvec4 pack(float depth)\n{\nconst vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);\nconst vec4 bit_mask=vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);\nvec4 res=fract(depth*bit_shift);\nres-=res.xxyz*bit_mask;\nreturn res;\n}\nfloat unpack(vec4 color)\n{\nconst vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);\nreturn dot(color,bit_shift);\n}\n#endif\nvoid main(void)\n{\nfloat computedWeight=0.0;\n#ifdef PACKEDFLOAT\nfloat blend=0.;\n#else\nvec4 blend=vec4(0.);\n#endif\n#ifdef DOF\nfloat sumOfWeights=CENTER_WEIGHT;\nfloat factor=0.0;\n\n#ifdef PACKEDFLOAT\nblend+=unpack(texture2D(textureSampler,sampleCenter))*CENTER_WEIGHT;\n#else\nblend+=texture2D(textureSampler,sampleCenter)*CENTER_WEIGHT;\n#endif\n#endif\n#include<kernelBlurFragment>[0..varyingCount]\n#include<kernelBlurFragment2>[0..depCount]\n#ifdef PACKEDFLOAT\ngl_FragColor=pack(blend);\n#else\ngl_FragColor=blend;\n#endif\n#ifdef DOF\ngl_FragColor/=sumOfWeights;\n#endif\n}";St.a.ShadersStore.kernelBlurPixelShader=Nr;St.a.IncludesShadersStore.kernelBlurVertex="sampleCoord{X}=sampleCenter+delta*KERNEL_OFFSET{X};";var Br="\nattribute vec2 position;\n\nuniform vec2 delta;\n\nvarying vec2 sampleCenter;\n#include<kernelBlurVaryingDeclaration>[0..varyingCount]\nconst vec2 madd=vec2(0.5,0.5);\nvoid main(void) {\nsampleCenter=(position*madd+madd);\n#include<kernelBlurVertex>[0..varyingCount]\ngl_Position=vec4(position,0.0,1.0);\n}";St.a.ShadersStore.kernelBlurVertexShader=Br;var Ur=function(e){function t(t,i,r,n,o,s,a,c,l,u,h){void 0===s&&(s=Ve.a.BILINEAR_SAMPLINGMODE),void 0===l&&(l=_.a.TEXTURETYPE_UNSIGNED_INT),void 0===u&&(u=""),void 0===h&&(h=!1);var d=e.call(this,t,"kernelBlur",["delta","direction","cameraMinMaxZ"],["circleOfConfusionSampler"],n,o,s,a,c,null,l,"kernelBlur",{varyingCount:0,depCount:0},!0)||this;return d.direction=i,d.blockCompilation=h,d._packedFloat=!1,d._staticDefines="",d._staticDefines=u,d.onApplyObservable.add(function(e){d._outputTexture?e.setFloat2("delta",1/d._outputTexture.width*d.direction.x,1/d._outputTexture.height*d.direction.y):e.setFloat2("delta",1/d.width*d.direction.x,1/d.height*d.direction.y)}),d.kernel=r,d}return l.d(t,e),Object.defineProperty(t.prototype,"kernel",{get:function(){return this._idealKernel},set:function(e){this._idealKernel!==e&&(e=Math.max(e,1),this._idealKernel=e,this._kernel=this._nearestBestKernel(e),this.blockCompilation||this._updateParameters())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"packedFloat",{get:function(){return this._packedFloat},set:function(e){this._packedFloat!==e&&(this._packedFloat=e,this.blockCompilation||this._updateParameters())},enumerable:!0,configurable:!0}),t.prototype.updateEffect=function(e,t,i,r,n,o){void 0===e&&(e=null),void 0===t&&(t=null),void 0===i&&(i=null),this._updateParameters(n,o)},t.prototype._updateParameters=function(t,i){for(var r=this._kernel,n=(r-1)/2,o=[],s=[],a=0,c=0;c<r;c++){var l=c/(r-1),u=this._gaussianWeight(2*l-1);o[c]=c-n,s[c]=u,a+=u}for(c=0;c<s.length;c++)s[c]/=a;var h=[],d=[],f=[];for(c=0;c<=n;c+=2){var p=Math.min(c+1,Math.floor(n));if(c===p)f.push({o:o[c],w:s[c]});else{var _=p===n,g=s[c]+s[p]*(_?.5:1),m=o[c]+1/(1+s[c]/s[p]);0===m?(f.push({o:o[c],w:s[c]}),f.push({o:o[c+1],w:s[c+1]})):(f.push({o:m,w:g}),f.push({o:-m,w:g}))}}for(c=0;c<f.length;c++)d[c]=f[c].o,h[c]=f[c].w;o=d,s=h;var v=this.getEngine().getCaps().maxVaryingVectors,y=Math.max(v,0)-1,b=Math.min(o.length,y),T="";T+=this._staticDefines,-1!=this._staticDefines.indexOf("DOF")&&(T+="#define CENTER_WEIGHT "+this._glslFloat(s[b-1])+"\r\n",b--);for(c=0;c<b;c++)T+="#define KERNEL_OFFSET"+c+" "+this._glslFloat(o[c])+"\r\n",T+="#define KERNEL_WEIGHT"+c+" "+this._glslFloat(s[c])+"\r\n";var E=0;for(c=y;c<o.length;c++)T+="#define KERNEL_DEP_OFFSET"+E+" "+this._glslFloat(o[c])+"\r\n",T+="#define KERNEL_DEP_WEIGHT"+E+" "+this._glslFloat(s[c])+"\r\n",E++;this.packedFloat&&(T+="#define PACKEDFLOAT 1"),this.blockCompilation=!1,e.prototype.updateEffect.call(this,T,null,null,{varyingCount:b,depCount:E},t,i)},t.prototype._nearestBestKernel=function(e){for(var t=Math.round(e),i=0,r=[t,t-1,t+1,t-2,t+2];i<r.length;i++){var n=r[i];if(n%2!=0&&Math.floor(n/2)%2==0&&n>0)return Math.max(n,3)}return Math.max(t,3)},t.prototype._gaussianWeight=function(e){var t=-e*e/(1/3*2*(1/3));return 1/(Math.sqrt(2*Math.PI)*(1/3))*Math.exp(t)},t.prototype._glslFloat=function(e,t){return void 0===t&&(t=8),e.toFixed(t).replace(/0+$/,"")},t}(Mt),Vr=function(e){function t(t,i,r,n,s,a,c){void 0===s&&(s=_.a.TEXTURETYPE_UNSIGNED_INT),void 0===a&&(a=Ve.a.BILINEAR_SAMPLINGMODE),void 0===c&&(c=!0);var l=e.call(this,t,i,r,n,!0,s,!1,a,c)||this;return l.scene=r,l.mirrorPlane=new o.n(0,1,0,1),l._transformMatrix=o.j.Zero(),l._mirrorMatrix=o.j.Zero(),l._adaptiveBlurKernel=0,l._blurKernelX=0,l._blurKernelY=0,l._blurRatio=1,l.ignoreCameraViewport=!0,l._updateGammaSpace(),l._imageProcessingConfigChangeObserver=r.imageProcessingConfiguration.onUpdateParameters.add(function(){l._updateGammaSpace}),l.onBeforeRenderObservable.add(function(){o.j.ReflectionToRef(l.mirrorPlane,l._mirrorMatrix),l._savedViewMatrix=r.getViewMatrix(),l._mirrorMatrix.multiplyToRef(l._savedViewMatrix,l._transformMatrix),r.setTransformMatrix(l._transformMatrix,r.getProjectionMatrix()),r.clipPlane=l.mirrorPlane,r.getEngine().cullBackFaces=!1,r._mirroredCameraPosition=o.x.TransformCoordinates(r.activeCamera.globalPosition,l._mirrorMatrix)}),l.onAfterRenderObservable.add(function(){r.setTransformMatrix(l._savedViewMatrix,r.getProjectionMatrix()),r.getEngine().cullBackFaces=!0,r._mirroredCameraPosition=null,delete r.clipPlane}),l}return l.d(t,e),Object.defineProperty(t.prototype,"blurRatio",{get:function(){return this._blurRatio},set:function(e){this._blurRatio!==e&&(this._blurRatio=e,this._preparePostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"adaptiveBlurKernel",{set:function(e){this._adaptiveBlurKernel=e,this._autoComputeBlurKernel()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"blurKernel",{set:function(e){this.blurKernelX=e,this.blurKernelY=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"blurKernelX",{get:function(){return this._blurKernelX},set:function(e){this._blurKernelX!==e&&(this._blurKernelX=e,this._preparePostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"blurKernelY",{get:function(){return this._blurKernelY},set:function(e){this._blurKernelY!==e&&(this._blurKernelY=e,this._preparePostProcesses())},enumerable:!0,configurable:!0}),t.prototype._autoComputeBlurKernel=function(){var e=this.getScene().getEngine(),t=this.getRenderWidth()/e.getRenderWidth(),i=this.getRenderHeight()/e.getRenderHeight();this.blurKernelX=this._adaptiveBlurKernel*t,this.blurKernelY=this._adaptiveBlurKernel*i},t.prototype._onRatioRescale=function(){this._sizeRatio&&(this.resize(this._initialSizeParameter),this._adaptiveBlurKernel||this._preparePostProcesses()),this._adaptiveBlurKernel&&this._autoComputeBlurKernel()},t.prototype._updateGammaSpace=function(){this.gammaSpace=!this.scene.imageProcessingConfiguration.isEnabled||!this.scene.imageProcessingConfiguration.applyByPostProcess},t.prototype._preparePostProcesses=function(){if(this.clearPostProcesses(!0),this._blurKernelX&&this._blurKernelY){var e=this.getScene().getEngine(),t=e.getCaps().textureFloatRender?_.a.TEXTURETYPE_FLOAT:_.a.TEXTURETYPE_HALF_FLOAT;this._blurX=new Ur("horizontal blur",new o.w(1,0),this._blurKernelX,this._blurRatio,null,Ve.a.BILINEAR_SAMPLINGMODE,e,!1,t),this._blurX.autoClear=!1,1===this._blurRatio&&this.samples<2&&this._texture?this._blurX.inputTexture=this._texture:this._blurX.alwaysForcePOT=!0,this._blurY=new Ur("vertical blur",new o.w(0,1),this._blurKernelY,this._blurRatio,null,Ve.a.BILINEAR_SAMPLINGMODE,e,!1,t),this._blurY.autoClear=!1,this._blurY.alwaysForcePOT=1!==this._blurRatio,this.addPostProcess(this._blurX),this.addPostProcess(this._blurY)}else this._blurY&&(this.removePostProcess(this._blurY),this._blurY.dispose(),this._blurY=null),this._blurX&&(this.removePostProcess(this._blurX),this._blurX.dispose(),this._blurX=null)},t.prototype.clone=function(){var e=this.getScene();if(!e)return this;var i=this.getSize(),r=new t(this.name,i.width,e,this._renderTargetOptions.generateMipMaps,this._renderTargetOptions.type,this._renderTargetOptions.samplingMode,this._renderTargetOptions.generateDepthBuffer);return r.hasAlpha=this.hasAlpha,r.level=this.level,r.mirrorPlane=this.mirrorPlane.clone(),this.renderList&&(r.renderList=this.renderList.slice(0)),r},t.prototype.serialize=function(){if(!this.name)return null;var t=e.prototype.serialize.call(this);return t.mirrorPlane=this.mirrorPlane.asArray(),t},t.prototype.dispose=function(){e.prototype.dispose.call(this),this.scene.imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingConfigChangeObserver)},t}(Mi);Ve.a._CreateMirror=function(e,t,i,r){return new Vr(e,t,i,r)};var Gr=function(e){function t(t,i,r,n,s,a,c,l,u,h,d,f,p){void 0===r&&(r=null),void 0===n&&(n=!1),void 0===s&&(s=null),void 0===a&&(a=null),void 0===c&&(c=null),void 0===l&&(l=_.a.TEXTUREFORMAT_RGBA),void 0===u&&(u=!1),void 0===h&&(h=null),void 0===d&&(d=!1),void 0===f&&(f=.8),void 0===p&&(p=0);var g=e.call(this,i)||this;if(g.boundingBoxPosition=o.x.Zero(),g._rotationY=0,g._prefiltered=!1,g.name=t,g.url=t,g._noMipmap=n,g.hasAlpha=!1,g._format=l,g.isCube=!0,g._textureMatrix=o.j.Identity(),g._createPolynomials=d,g.coordinatesMode=Ve.a.CUBIC_MODE,!t&&!s)return g;var m=t.lastIndexOf("."),v=h||(m>-1?t.substring(m).toLowerCase():""),y=".dds"===v,b=".env"===v;if(b?(g.gammaSpace=!1,g._prefiltered=!1):(g._prefiltered=u,u&&(g.gammaSpace=!1)),g._texture=g._getFromCache(t,n),!s&&(b||y||r||(r=["_px.jpg","_py.jpg","_pz.jpg","_nx.jpg","_ny.jpg","_nz.jpg"]),s=[],r))for(var T=0;T<r.length;T++)s.push(t+r[T]);return g._files=s,g._texture?a&&(g._texture.isReady?ve.h.SetImmediate(function(){return a()}):g._texture.onLoadedObservable.add(a)):i.useDelayedTextureLoading?g.delayLoadState=_.a.DELAYLOADSTATE_NOTLOADED:g._texture=u?i.getEngine().createPrefilteredCubeTexture(t,i,f,p,a,c,l,h,g._createPolynomials):i.getEngine().createCubeTexture(t,i,s,n,a,c,g._format,h,!1,f,p),g}return l.d(t,e),Object.defineProperty(t.prototype,"boundingBoxSize",{get:function(){return this._boundingBoxSize},set:function(e){if(!this._boundingBoxSize||!this._boundingBoxSize.equals(e)){this._boundingBoxSize=e;var t=this.getScene();t&&t.markAllMaterialsAsDirty(_.a.MATERIAL_TextureDirtyFlag)}},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"rotationY",{get:function(){return this._rotationY},set:function(e){this._rotationY=e,this.setReflectionTextureMatrix(o.j.RotationY(this._rotationY))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"noMipmap",{get:function(){return this._noMipmap},enumerable:!0,configurable:!0}),t.CreateFromImages=function(e,i,r){var n="";return e.forEach(function(e){return n+=e}),new t(n,i,null,r,e)},t.CreateFromPrefilteredData=function(e,i,r,n){return void 0===r&&(r=null),void 0===n&&(n=!0),new t(e,i,null,!1,null,null,null,void 0,!0,r,n)},t.prototype.getClassName=function(){return"CubeTexture"},t.prototype.updateURL=function(e,t,i){this.url&&(this.releaseInternalTexture(),this.getScene().markAllMaterialsAsDirty(_.a.MATERIAL_TextureDirtyFlag)),this.url=e,this.delayLoadState=_.a.DELAYLOADSTATE_NOTLOADED,this._prefiltered=!1,i&&(this._delayedOnLoad=i),this.delayLoad(t)},t.prototype.delayLoad=function(e){if(this.delayLoadState===_.a.DELAYLOADSTATE_NOTLOADED){var t=this.getScene();t&&(this.delayLoadState=_.a.DELAYLOADSTATE_LOADED,this._texture=this._getFromCache(this.url,this._noMipmap),this._texture||(this._prefiltered?this._texture=t.getEngine().createPrefilteredCubeTexture(this.url,t,this.lodGenerationScale,this.lodGenerationOffset,this._delayedOnLoad,void 0,this._format,void 0,this._createPolynomials):this._texture=t.getEngine().createCubeTexture(this.url,t,this._files,this._noMipmap,this._delayedOnLoad,void 0,this._format,e)))}},t.prototype.getReflectionTextureMatrix=function(){return this._textureMatrix},t.prototype.setReflectionTextureMatrix=function(e){var t=this;e.updateFlag!==this._textureMatrix.updateFlag&&(e.isIdentity()!==this._textureMatrix.isIdentity()&&this.getScene().markAllMaterialsAsDirty(_.a.MATERIAL_TextureDirtyFlag,function(e){return-1!==e.getActiveTextures().indexOf(t)}),this._textureMatrix=e)},t.Parse=function(e,i,r){var n=w.a.Parse(function(){var n=!1;return e.prefiltered&&(n=e.prefiltered),new t(r+e.name,i,e.extensions,!1,null,null,null,void 0,n)},e,i);if(e.boundingBoxPosition&&(n.boundingBoxPosition=o.x.FromArray(e.boundingBoxPosition)),e.boundingBoxSize&&(n.boundingBoxSize=o.x.FromArray(e.boundingBoxSize)),e.animations)for(var a=0;a<e.animations.length;a++){var c=e.animations[a],l=s.a.GetClass("BABYLON.Animation");l&&n.animations.push(l.Parse(c))}return n},t.prototype.clone=function(){var e=this,i=this.getScene(),r=0,n=w.a.Clone(function(){if(!i)return e;var n=new t(e.url,i,e._extensions,e._noMipmap,e._files);return r=n.uniqueId,n},this);return n.uniqueId=r,n},l.c([Object(w.c)("rotationY")],t.prototype,"rotationY",null),t}(wr.a);Ve.a._CubeTextureParser=Gr.Parse;var kr=i(16),zr=i(60),jr=i(69),Wr=i(21),Hr=" uniform vec4 vPrimaryColor;\n#ifdef USEHIGHLIGHTANDSHADOWCOLORS\nuniform vec4 vPrimaryColorShadow;\n#endif\nuniform float shadowLevel;\nuniform float alpha;\n#ifdef DIFFUSE\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\nuniform mat4 reflectionMatrix;\nuniform vec3 vReflectionMicrosurfaceInfos;\n#endif\n#if defined(REFLECTIONFRESNEL) || defined(OPACITYFRESNEL)\nuniform vec3 vBackgroundCenter;\n#endif\n#ifdef REFLECTIONFRESNEL\nuniform vec4 vReflectionControl;\n#endif\n#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(REFRACTION)\nuniform mat4 view;\n#endif";St.a.IncludesShadersStore.backgroundFragmentDeclaration=Hr;var Xr="layout(std140,column_major) uniform;\nuniform Material\n{\nuniform vec4 vPrimaryColor;\nuniform vec4 vPrimaryColorShadow;\nuniform vec2 vDiffuseInfos;\nuniform vec2 vReflectionInfos;\nuniform mat4 diffuseMatrix;\nuniform mat4 reflectionMatrix;\nuniform vec3 vReflectionMicrosurfaceInfos;\nuniform float fFovMultiplier;\nuniform float pointSize;\nuniform float shadowLevel;\nuniform float alpha;\n#if defined(REFLECTIONFRESNEL) || defined(OPACITYFRESNEL)\nuniform vec3 vBackgroundCenter;\n#endif\n#ifdef REFLECTIONFRESNEL\nuniform vec4 vReflectionControl;\n#endif\n};\nuniform Scene {\nmat4 viewProjection;\nmat4 view;\n};";St.a.IncludesShadersStore.backgroundUboDeclaration=Xr;i(105),i(76),i(77),i(111),i(104),i(91),i(92),i(86),i(106),i(93);var Yr="#ifdef TEXTURELODSUPPORT\n#extension GL_EXT_shader_texture_lod : enable\n#endif\nprecision highp float;\n#include<__decl__backgroundFragment>\n#define RECIPROCAL_PI2 0.15915494\n\nuniform vec3 vEyePosition;\n\nvarying vec3 vPositionW;\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2;\n#endif\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef DIFFUSE\n#if DIFFUSEDIRECTUV == 1\n#define vDiffuseUV vMainUV1\n#elif DIFFUSEDIRECTUV == 2\n#define vDiffuseUV vMainUV2\n#else\nvarying vec2 vDiffuseUV;\n#endif\nuniform sampler2D diffuseSampler;\n#endif\n\n#ifdef REFLECTION\n#ifdef REFLECTIONMAP_3D\n#define sampleReflection(s,c) textureCube(s,c)\nuniform samplerCube reflectionSampler;\n#ifdef TEXTURELODSUPPORT\n#define sampleReflectionLod(s,c,l) textureCubeLodEXT(s,c,l)\n#else\nuniform samplerCube reflectionSamplerLow;\nuniform samplerCube reflectionSamplerHigh;\n#endif\n#else\n#define sampleReflection(s,c) texture2D(s,c)\nuniform sampler2D reflectionSampler;\n#ifdef TEXTURELODSUPPORT\n#define sampleReflectionLod(s,c,l) texture2DLodEXT(s,c,l)\n#else\nuniform samplerCube reflectionSamplerLow;\nuniform samplerCube reflectionSamplerHigh;\n#endif\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#else\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#endif\n#include<reflectionFunction>\n#endif\n\n#ifndef FROMLINEARSPACE\n#define FROMLINEARSPACE;\n#endif\n\n#ifndef SHADOWONLY\n#define SHADOWONLY;\n#endif\n#include<imageProcessingDeclaration>\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<helperFunctions>\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n#include<imageProcessingFunctions>\n#include<clipPlaneFragmentDeclaration>\n\n#include<fogFragmentDeclaration>\n#ifdef REFLECTIONFRESNEL\n#define FRESNEL_MAXIMUM_ON_ROUGH 0.25\nvec3 fresnelSchlickEnvironmentGGX(float VdotN,vec3 reflectance0,vec3 reflectance90,float smoothness)\n{\n\nfloat weight=mix(FRESNEL_MAXIMUM_ON_ROUGH,1.0,smoothness);\nreturn reflectance0+weight*(reflectance90-reflectance0)*pow(clamp(1.0-VdotN,0.,1.),5.0);\n}\n#endif\nvoid main(void) {\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(0.0,1.0,0.0);\n#endif\n\nfloat shadow=1.;\nfloat globalShadow=0.;\nfloat shadowLightCount=0.;\n#include<lightFragment>[0..maxSimultaneousLights]\n#ifdef SHADOWINUSE\nglobalShadow/=shadowLightCount;\n#else\nglobalShadow=1.0;\n#endif\n\nvec4 reflectionColor=vec4(1.,1.,1.,1.);\n#ifdef REFLECTION\nvec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),normalW);\n#ifdef REFLECTIONMAP_OPPOSITEZ\nreflectionVector.z*=-1.0;\n#endif\n\n#ifdef REFLECTIONMAP_3D\nvec3 reflectionCoords=reflectionVector;\n#else\nvec2 reflectionCoords=reflectionVector.xy;\n#ifdef REFLECTIONMAP_PROJECTION\nreflectionCoords/=reflectionVector.z;\n#endif\nreflectionCoords.y=1.0-reflectionCoords.y;\n#endif\n#ifdef REFLECTIONBLUR\nfloat reflectionLOD=vReflectionInfos.y;\n#ifdef TEXTURELODSUPPORT\n\nreflectionLOD=reflectionLOD*log2(vReflectionMicrosurfaceInfos.x)*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z;\nreflectionColor=sampleReflectionLod(reflectionSampler,reflectionCoords,reflectionLOD);\n#else\nfloat lodReflectionNormalized=clamp(reflectionLOD,0.,1.);\nfloat lodReflectionNormalizedDoubled=lodReflectionNormalized*2.0;\nvec4 reflectionSpecularMid=sampleReflection(reflectionSampler,reflectionCoords);\nif(lodReflectionNormalizedDoubled<1.0){\nreflectionColor=mix(\nsampleReflection(reflectionSamplerHigh,reflectionCoords),\nreflectionSpecularMid,\nlodReflectionNormalizedDoubled\n);\n} else {\nreflectionColor=mix(\nreflectionSpecularMid,\nsampleReflection(reflectionSamplerLow,reflectionCoords),\nlodReflectionNormalizedDoubled-1.0\n);\n}\n#endif\n#else\nvec4 reflectionSample=sampleReflection(reflectionSampler,reflectionCoords);\nreflectionColor=reflectionSample;\n#endif\n#ifdef RGBDREFLECTION\nreflectionColor.rgb=fromRGBD(reflectionColor);\n#endif\n#ifdef GAMMAREFLECTION\nreflectionColor.rgb=toLinearSpace(reflectionColor.rgb);\n#endif\n#ifdef REFLECTIONBGR\nreflectionColor.rgb=reflectionColor.bgr;\n#endif\n\nreflectionColor.rgb*=vReflectionInfos.x;\n#endif\n\nvec3 diffuseColor=vec3(1.,1.,1.);\nfloat finalAlpha=alpha;\n#ifdef DIFFUSE\nvec4 diffuseMap=texture2D(diffuseSampler,vDiffuseUV);\n#ifdef GAMMADIFFUSE\ndiffuseMap.rgb=toLinearSpace(diffuseMap.rgb);\n#endif\n\ndiffuseMap.rgb*=vDiffuseInfos.y;\n#ifdef DIFFUSEHASALPHA\nfinalAlpha*=diffuseMap.a;\n#endif\ndiffuseColor=diffuseMap.rgb;\n#endif\n\n#ifdef REFLECTIONFRESNEL\nvec3 colorBase=diffuseColor;\n#else\nvec3 colorBase=reflectionColor.rgb*diffuseColor;\n#endif\ncolorBase=max(colorBase,0.0);\n\n#ifdef USERGBCOLOR\nvec3 finalColor=colorBase;\n#else\n#ifdef USEHIGHLIGHTANDSHADOWCOLORS\nvec3 mainColor=mix(vPrimaryColorShadow.rgb,vPrimaryColor.rgb,colorBase);\n#else\nvec3 mainColor=vPrimaryColor.rgb;\n#endif\nvec3 finalColor=colorBase*mainColor;\n#endif\n\n#ifdef REFLECTIONFRESNEL\nvec3 reflectionAmount=vReflectionControl.xxx;\nvec3 reflectionReflectance0=vReflectionControl.yyy;\nvec3 reflectionReflectance90=vReflectionControl.zzz;\nfloat VdotN=dot(normalize(vEyePosition),normalW);\nvec3 planarReflectionFresnel=fresnelSchlickEnvironmentGGX(clamp(VdotN,0.0,1.0),reflectionReflectance0,reflectionReflectance90,1.0);\nreflectionAmount*=planarReflectionFresnel;\n#ifdef REFLECTIONFALLOFF\nfloat reflectionDistanceFalloff=1.0-clamp(length(vPositionW.xyz-vBackgroundCenter)*vReflectionControl.w,0.0,1.0);\nreflectionDistanceFalloff*=reflectionDistanceFalloff;\nreflectionAmount*=reflectionDistanceFalloff;\n#endif\nfinalColor=mix(finalColor,reflectionColor.rgb,clamp(reflectionAmount,0.,1.));\n#endif\n#ifdef OPACITYFRESNEL\nfloat viewAngleToFloor=dot(normalW,normalize(vEyePosition-vBackgroundCenter));\n\nconst float startAngle=0.1;\nfloat fadeFactor=clamp(viewAngleToFloor/startAngle,0.0,1.0);\nfinalAlpha*=fadeFactor*fadeFactor;\n#endif\n\n#ifdef SHADOWINUSE\nfinalColor=mix(finalColor*shadowLevel,finalColor,globalShadow);\n#endif\n\nvec4 color=vec4(finalColor,finalAlpha);\n#include<fogFragment>\n#ifdef IMAGEPROCESSINGPOSTPROCESS\n\n\ncolor.rgb=clamp(color.rgb,0.,30.0);\n#else\n\ncolor=applyImageProcessing(color);\n#endif\n#ifdef PREMULTIPLYALPHA\n\ncolor.rgb*=color.a;\n#endif\n#ifdef NOISE\ncolor.rgb+=dither(vPositionW.xy,0.5);\ncolor=max(color,0.0);\n#endif\ngl_FragColor=color;\n}\n";St.a.ShadersStore.backgroundPixelShader=Yr;var Kr="uniform mat4 view;\nuniform mat4 viewProjection;\nuniform float shadowLevel;\n#ifdef DIFFUSE\nuniform mat4 diffuseMatrix;\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\nuniform mat4 reflectionMatrix;\nuniform vec3 vReflectionMicrosurfaceInfos;\nuniform float fFovMultiplier;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif";St.a.IncludesShadersStore.backgroundVertexDeclaration=Kr;i(62),i(63),i(94),i(95),i(64),i(65),i(87),i(108),i(109);var Qr="precision highp float;\n#include<__decl__backgroundVertex>\n#include<helperFunctions>\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2;\n#endif\n#if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0\nvarying vec2 vDiffuseUV;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\nvoid main(void) {\n#ifdef REFLECTIONMAP_SKYBOX\n#ifdef REFLECTIONMAP_SKYBOX_TRANSFORMED\nvPositionUVW=(reflectionMatrix*vec4(position,1.0)).xyz;\n#else\nvPositionUVW=position;\n#endif\n#endif\n#include<instancesVertex>\n#include<bonesVertex>\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\nvec4 worldPos=finalWorld*vec4(position,1.0);\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nmat3 normalWorld=mat3(finalWorld);\n#ifdef NONUNIFORMSCALING\nnormalWorld=transposeMat3(inverseMat3(normalWorld));\n#endif\nvNormalW=normalize(normalWorld*normal);\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvDirectionW=normalize(vec3(finalWorld*vec4(position,0.0)));\n#ifdef EQUIRECTANGULAR_RELFECTION_FOV\nmat3 screenToWorld=inverseMat3(mat3(finalWorld*viewProjection));\nvec3 segment=mix(vDirectionW,screenToWorld*vec3(0.0,0.0,1.0),abs(fFovMultiplier-1.0));\nif (fFovMultiplier<=1.0) {\nvDirectionW=normalize(segment);\n} else {\nvDirectionW=normalize(vDirectionW+(vDirectionW-segment));\n}\n#endif\n#endif\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef MAINUV1\nvMainUV1=uv;\n#endif\n#ifdef MAINUV2\nvMainUV2=uv2;\n#endif\n#if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0\nif (vDiffuseInfos.x == 0.)\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n\n#include<clipPlaneVertex>\n\n#include<fogVertex>\n\n#include<shadowsVertex>[0..maxSimultaneousLights]\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n}\n";St.a.ShadersStore.backgroundVertexShader=Qr;var qr=function(e){function t(){var t=e.call(this)||this;return t.DIFFUSE=!1,t.DIFFUSEDIRECTUV=0,t.GAMMADIFFUSE=!1,t.DIFFUSEHASALPHA=!1,t.OPACITYFRESNEL=!1,t.REFLECTIONBLUR=!1,t.REFLECTIONFRESNEL=!1,t.REFLECTIONFALLOFF=!1,t.TEXTURELODSUPPORT=!1,t.PREMULTIPLYALPHA=!1,t.USERGBCOLOR=!1,t.USEHIGHLIGHTANDSHADOWCOLORS=!1,t.NOISE=!1,t.REFLECTIONBGR=!1,t.IMAGEPROCESSING=!1,t.VIGNETTE=!1,t.VIGNETTEBLENDMODEMULTIPLY=!1,t.VIGNETTEBLENDMODEOPAQUE=!1,t.TONEMAPPING=!1,t.TONEMAPPING_ACES=!1,t.CONTRAST=!1,t.COLORCURVES=!1,t.COLORGRADING=!1,t.COLORGRADING3D=!1,t.SAMPLER3DGREENDEPTH=!1,t.SAMPLER3DBGRMAP=!1,t.IMAGEPROCESSINGPOSTPROCESS=!1,t.EXPOSURE=!1,t.REFLECTION=!1,t.REFLECTIONMAP_3D=!1,t.REFLECTIONMAP_SPHERICAL=!1,t.REFLECTIONMAP_PLANAR=!1,t.REFLECTIONMAP_CUBIC=!1,t.REFLECTIONMAP_PROJECTION=!1,t.REFLECTIONMAP_SKYBOX=!1,t.REFLECTIONMAP_SKYBOX_TRANSFORMED=!1,t.REFLECTIONMAP_EXPLICIT=!1,t.REFLECTIONMAP_EQUIRECTANGULAR=!1,t.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,t.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,t.INVERTCUBICMAP=!1,t.REFLECTIONMAP_OPPOSITEZ=!1,t.LODINREFLECTIONALPHA=!1,t.GAMMAREFLECTION=!1,t.RGBDREFLECTION=!1,t.EQUIRECTANGULAR_RELFECTION_FOV=!1,t.MAINUV1=!1,t.MAINUV2=!1,t.UV1=!1,t.UV2=!1,t.CLIPPLANE=!1,t.CLIPPLANE2=!1,t.CLIPPLANE3=!1,t.CLIPPLANE4=!1,t.POINTSIZE=!1,t.FOG=!1,t.NORMAL=!1,t.NUM_BONE_INFLUENCERS=0,t.BonesPerMesh=0,t.INSTANCES=!1,t.SHADOWFLOAT=!1,t.rebuild(),t}return l.d(t,e),t}(zr.a),Zr=function(e){function t(t,i){var r=e.call(this,t,i)||this;return r.primaryColor=o.e.White(),r._primaryColorShadowLevel=0,r._primaryColorHighlightLevel=0,r.reflectionTexture=null,r.reflectionBlur=0,r.diffuseTexture=null,r._shadowLights=null,r.shadowLights=null,r.shadowLevel=0,r.sceneCenter=o.x.Zero(),r.opacityFresnel=!0,r.reflectionFresnel=!1,r.reflectionFalloffDistance=0,r.reflectionAmount=1,r.reflectionReflectance0=.05,r.reflectionReflectance90=.5,r.useRGBColor=!0,r.enableNoise=!1,r._fovMultiplier=1,r.useEquirectangularFOV=!1,r._maxSimultaneousLights=4,r.maxSimultaneousLights=4,r._imageProcessingObserver=null,r.switchToBGR=!1,r._renderTargets=new Rt.a(16),r._reflectionControls=o.y.Zero(),r._white=o.e.White(),r._primaryShadowColor=o.e.Black(),r._primaryHighlightColor=o.e.Black(),r._attachImageProcessingConfiguration(null),r.getRenderTargetTextures=function(){return r._renderTargets.reset(),r._diffuseTexture&&r._diffuseTexture.isRenderTarget&&r._renderTargets.push(r._diffuseTexture),r._reflectionTexture&&r._reflectionTexture.isRenderTarget&&r._renderTargets.push(r._reflectionTexture),r._renderTargets},r}return l.d(t,e),Object.defineProperty(t.prototype,"_perceptualColor",{get:function(){return this.__perceptualColor},set:function(e){this.__perceptualColor=e,this._computePrimaryColorFromPerceptualColor(),this._markAllSubMeshesAsLightsDirty()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"primaryColorShadowLevel",{get:function(){return this._primaryColorShadowLevel},set:function(e){this._primaryColorShadowLevel=e,this._computePrimaryColors(),this._markAllSubMeshesAsLightsDirty()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"primaryColorHighlightLevel",{get:function(){return this._primaryColorHighlightLevel},set:function(e){this._primaryColorHighlightLevel=e,this._computePrimaryColors(),this._markAllSubMeshesAsLightsDirty()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"reflectionStandardFresnelWeight",{set:function(e){var i=e;i<.5?(i*=2,this.reflectionReflectance0=t.StandardReflectance0*i,this.reflectionReflectance90=t.StandardReflectance90*i):(i=2*i-1,this.reflectionReflectance0=t.StandardReflectance0+(1-t.StandardReflectance0)*i,this.reflectionReflectance90=t.StandardReflectance90+(1-t.StandardReflectance90)*i)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"fovMultiplier",{get:function(){return this._fovMultiplier},set:function(e){isNaN(e)&&(e=1),this._fovMultiplier=Math.max(0,Math.min(2,e))},enumerable:!0,configurable:!0}),t.prototype._attachImageProcessingConfiguration=function(e){var t=this;e!==this._imageProcessingConfiguration&&(this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),this._imageProcessingConfiguration=e||this.getScene().imageProcessingConfiguration,this._imageProcessingConfiguration&&(this._imageProcessingObserver=this._imageProcessingConfiguration.onUpdateParameters.add(function(){t._computePrimaryColorFromPerceptualColor(),t._markAllSubMeshesAsImageProcessingDirty()})))},Object.defineProperty(t.prototype,"imageProcessingConfiguration",{get:function(){return this._imageProcessingConfiguration},set:function(e){this._attachImageProcessingConfiguration(e),this._markAllSubMeshesAsTexturesDirty()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"cameraColorCurvesEnabled",{get:function(){return this.imageProcessingConfiguration.colorCurvesEnabled},set:function(e){this.imageProcessingConfiguration.colorCurvesEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"cameraColorGradingEnabled",{get:function(){return this.imageProcessingConfiguration.colorGradingEnabled},set:function(e){this.imageProcessingConfiguration.colorGradingEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"cameraToneMappingEnabled",{get:function(){return this._imageProcessingConfiguration.toneMappingEnabled},set:function(e){this._imageProcessingConfiguration.toneMappingEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"cameraExposure",{get:function(){return this._imageProcessingConfiguration.exposure},set:function(e){this._imageProcessingConfiguration.exposure=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"cameraContrast",{get:function(){return this._imageProcessingConfiguration.contrast},set:function(e){this._imageProcessingConfiguration.contrast=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"cameraColorGradingTexture",{get:function(){return this._imageProcessingConfiguration.colorGradingTexture},set:function(e){this.imageProcessingConfiguration.colorGradingTexture=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"cameraColorCurves",{get:function(){return this.imageProcessingConfiguration.colorCurves},set:function(e){this.imageProcessingConfiguration.colorCurves=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"hasRenderTargetTextures",{get:function(){return!(!this._diffuseTexture||!this._diffuseTexture.isRenderTarget)||!(!this._reflectionTexture||!this._reflectionTexture.isRenderTarget)},enumerable:!0,configurable:!0}),t.prototype.needAlphaTesting=function(){return!0},t.prototype.needAlphaBlending=function(){return this.alpha<0||null!=this._diffuseTexture&&this._diffuseTexture.hasAlpha},t.prototype.isReadyForSubMesh=function(e,t,i){var r=this;if(void 0===i&&(i=!1),t.effect&&this.isFrozen&&this._wasPreviouslyReady)return!0;t._materialDefines||(t._materialDefines=new qr);var n=this.getScene(),o=t._materialDefines;if(!this.checkReadyOnEveryCall&&t.effect&&o._renderId===n.getRenderId())return!0;var s=n.getEngine();if(kr.a.PrepareDefinesForLights(n,e,o,!1,this._maxSimultaneousLights),o._needNormals=!0,o._areTexturesDirty){if(o._needUVs=!1,n.texturesEnabled){if(n.getEngine().getCaps().textureLOD&&(o.TEXTURELODSUPPORT=!0),this._diffuseTexture&&Wr.a.DiffuseTextureEnabled){if(!this._diffuseTexture.isReadyOrNotBlocking())return!1;kr.a.PrepareDefinesForMergedUV(this._diffuseTexture,o,"DIFFUSE"),o.DIFFUSEHASALPHA=this._diffuseTexture.hasAlpha,o.GAMMADIFFUSE=this._diffuseTexture.gammaSpace,o.OPACITYFRESNEL=this._opacityFresnel}else o.DIFFUSE=!1,o.DIFFUSEHASALPHA=!1,o.GAMMADIFFUSE=!1,o.OPACITYFRESNEL=!1;var a=this._reflectionTexture;if(a&&Wr.a.ReflectionTextureEnabled){if(!a.isReadyOrNotBlocking())return!1;switch(o.REFLECTION=!0,o.GAMMAREFLECTION=a.gammaSpace,o.RGBDREFLECTION=a.isRGBD,o.REFLECTIONBLUR=this._reflectionBlur>0,o.REFLECTIONMAP_OPPOSITEZ=this.getScene().useRightHandedSystem?!a.invertZ:a.invertZ,o.LODINREFLECTIONALPHA=a.lodLevelInAlpha,o.EQUIRECTANGULAR_RELFECTION_FOV=this.useEquirectangularFOV,o.REFLECTIONBGR=this.switchToBGR,a.coordinatesMode===Ve.a.INVCUBIC_MODE&&(o.INVERTCUBICMAP=!0),o.REFLECTIONMAP_3D=a.isCube,a.coordinatesMode){case Ve.a.EXPLICIT_MODE:o.REFLECTIONMAP_EXPLICIT=!0;break;case Ve.a.PLANAR_MODE:o.REFLECTIONMAP_PLANAR=!0;break;case Ve.a.PROJECTION_MODE:o.REFLECTIONMAP_PROJECTION=!0;break;case Ve.a.SKYBOX_MODE:o.REFLECTIONMAP_SKYBOX=!0,o.REFLECTIONMAP_SKYBOX_TRANSFORMED=!a.getReflectionTextureMatrix().isIdentity();break;case Ve.a.SPHERICAL_MODE:o.REFLECTIONMAP_SPHERICAL=!0;break;case Ve.a.EQUIRECTANGULAR_MODE:o.REFLECTIONMAP_EQUIRECTANGULAR=!0;break;case Ve.a.FIXED_EQUIRECTANGULAR_MODE:o.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!0;break;case Ve.a.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:o.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!0;break;case Ve.a.CUBIC_MODE:case Ve.a.INVCUBIC_MODE:default:o.REFLECTIONMAP_CUBIC=!0}this.reflectionFresnel?(o.REFLECTIONFRESNEL=!0,o.REFLECTIONFALLOFF=this.reflectionFalloffDistance>0,this._reflectionControls.x=this.reflectionAmount,this._reflectionControls.y=this.reflectionReflectance0,this._reflectionControls.z=this.reflectionReflectance90,this._reflectionControls.w=1/this.reflectionFalloffDistance):(o.REFLECTIONFRESNEL=!1,o.REFLECTIONFALLOFF=!1)}else o.REFLECTION=!1,o.REFLECTIONFRESNEL=!1,o.REFLECTIONFALLOFF=!1,o.REFLECTIONBLUR=!1,o.REFLECTIONMAP_3D=!1,o.REFLECTIONMAP_SPHERICAL=!1,o.REFLECTIONMAP_PLANAR=!1,o.REFLECTIONMAP_CUBIC=!1,o.REFLECTIONMAP_PROJECTION=!1,o.REFLECTIONMAP_SKYBOX=!1,o.REFLECTIONMAP_SKYBOX_TRANSFORMED=!1,o.REFLECTIONMAP_EXPLICIT=!1,o.REFLECTIONMAP_EQUIRECTANGULAR=!1,o.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,o.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,o.INVERTCUBICMAP=!1,o.REFLECTIONMAP_OPPOSITEZ=!1,o.LODINREFLECTIONALPHA=!1,o.GAMMAREFLECTION=!1,o.RGBDREFLECTION=!1}o.PREMULTIPLYALPHA=this.alphaMode===_.a.ALPHA_PREMULTIPLIED||this.alphaMode===_.a.ALPHA_PREMULTIPLIED_PORTERDUFF,o.USERGBCOLOR=this._useRGBColor,o.NOISE=this._enableNoise}if(o._areLightsDirty&&(o.USEHIGHLIGHTANDSHADOWCOLORS=!this._useRGBColor&&(0!==this._primaryColorShadowLevel||0!==this._primaryColorHighlightLevel)),o._areImageProcessingDirty&&this._imageProcessingConfiguration){if(!this._imageProcessingConfiguration.isReady())return!1;this._imageProcessingConfiguration.prepareDefines(o)}if(kr.a.PrepareDefinesForMisc(e,n,!1,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e),o),kr.a.PrepareDefinesForFrameBoundValues(n,s,o,i),kr.a.PrepareDefinesForAttributes(e,o,!1,!0,!1)&&e&&(n.getEngine().getCaps().standardDerivatives||e.isVerticesDataPresent(gi.b.NormalKind)||(e.createNormals(!0),p.a.Warn("BackgroundMaterial: Normals have been created for the mesh: "+e.name))),o.isDirty){o.markAsProcessed(),n.resetCachedMaterial();var c=new St.c;o.FOG&&c.addFallback(0,"FOG"),o.POINTSIZE&&c.addFallback(1,"POINTSIZE"),kr.a.HandleFallbacksForShadows(o,c,this._maxSimultaneousLights),o.NUM_BONE_INFLUENCERS>0&&c.addCPUSkinningFallback(0,e);var l=[gi.b.PositionKind];o.NORMAL&&l.push(gi.b.NormalKind),o.UV1&&l.push(gi.b.UVKind),o.UV2&&l.push(gi.b.UV2Kind),kr.a.PrepareAttributesForBones(l,e,o,c),kr.a.PrepareAttributesForInstances(l,o);var u=["world","view","viewProjection","vEyePosition","vLightsType","vFogInfos","vFogColor","pointSize","vClipPlane","vClipPlane2","vClipPlane3","vClipPlane4","mBones","vPrimaryColor","vPrimaryColorShadow","vReflectionInfos","reflectionMatrix","vReflectionMicrosurfaceInfos","fFovMultiplier","shadowLevel","alpha","vBackgroundCenter","vReflectionControl","vDiffuseInfos","diffuseMatrix"],h=["diffuseSampler","reflectionSampler","reflectionSamplerLow","reflectionSamplerHigh"],d=["Material","Scene"];ui.a&&(ui.a.PrepareUniforms(u,o),ui.a.PrepareSamplers(h,o)),kr.a.PrepareUniformsAndSamplersList({uniformsNames:u,uniformBuffersNames:d,samplers:h,defines:o,maxSimultaneousLights:this._maxSimultaneousLights});var f=o.toString();t.setEffect(n.getEngine().createEffect("background",{attributes:l,uniformsNames:u,uniformBuffersNames:d,samplers:h,defines:f,fallbacks:c,onCompiled:function(e){r.onCompiled&&r.onCompiled(e),r.bindSceneUniformBuffer(e,n.getSceneUniformBuffer())},onError:this.onError,indexParameters:{maxSimultaneousLights:this._maxSimultaneousLights}},s),o),this.buildUniformLayout()}return!(!t.effect||!t.effect.isReady())&&(o._renderId=n.getRenderId(),this._wasPreviouslyReady=!0,!0)},t.prototype._computePrimaryColorFromPerceptualColor=function(){this.__perceptualColor&&(this._primaryColor.copyFrom(this.__perceptualColor),this._primaryColor.toLinearSpaceToRef(this._primaryColor),this._imageProcessingConfiguration&&this._primaryColor.scaleToRef(1/this._imageProcessingConfiguration.exposure,this._primaryColor),this._computePrimaryColors())},t.prototype._computePrimaryColors=function(){0===this._primaryColorShadowLevel&&0===this._primaryColorHighlightLevel||(this._primaryColor.scaleToRef(this._primaryColorShadowLevel,this._primaryShadowColor),this._primaryColor.subtractToRef(this._primaryShadowColor,this._primaryShadowColor),this._white.subtractToRef(this._primaryColor,this._primaryHighlightColor),this._primaryHighlightColor.scaleToRef(this._primaryColorHighlightLevel,this._primaryHighlightColor),this._primaryColor.addToRef(this._primaryHighlightColor,this._primaryHighlightColor))},t.prototype.buildUniformLayout=function(){this._uniformBuffer.addUniform("vPrimaryColor",4),this._uniformBuffer.addUniform("vPrimaryColorShadow",4),this._uniformBuffer.addUniform("vDiffuseInfos",2),this._uniformBuffer.addUniform("vReflectionInfos",2),this._uniformBuffer.addUniform("diffuseMatrix",16),this._uniformBuffer.addUniform("reflectionMatrix",16),this._uniformBuffer.addUniform("vReflectionMicrosurfaceInfos",3),this._uniformBuffer.addUniform("fFovMultiplier",1),this._uniformBuffer.addUniform("pointSize",1),this._uniformBuffer.addUniform("shadowLevel",1),this._uniformBuffer.addUniform("alpha",1),this._uniformBuffer.addUniform("vBackgroundCenter",3),this._uniformBuffer.addUniform("vReflectionControl",4),this._uniformBuffer.create()},t.prototype.unbind=function(){this._diffuseTexture&&this._diffuseTexture.isRenderTarget&&this._uniformBuffer.setTexture("diffuseSampler",null),this._reflectionTexture&&this._reflectionTexture.isRenderTarget&&this._uniformBuffer.setTexture("reflectionSampler",null),e.prototype.unbind.call(this)},t.prototype.bindOnlyWorldMatrix=function(e){this._activeEffect.setMatrix("world",e)},t.prototype.bindForSubMesh=function(e,t,i){var r=this.getScene(),n=i._materialDefines;if(n){var o=i.effect;if(o){this._activeEffect=o,this.bindOnlyWorldMatrix(e),kr.a.BindBonesParameters(t,this._activeEffect);var s=this._mustRebind(r,o,t.visibility);if(s){this._uniformBuffer.bindToEffect(o,"Material"),this.bindViewProjection(o);var a=this._reflectionTexture;this._uniformBuffer.useUbo&&this.isFrozen&&this._uniformBuffer.isSync||(r.texturesEnabled&&(this._diffuseTexture&&Wr.a.DiffuseTextureEnabled&&(this._uniformBuffer.updateFloat2("vDiffuseInfos",this._diffuseTexture.coordinatesIndex,this._diffuseTexture.level),kr.a.BindTextureMatrix(this._diffuseTexture,this._uniformBuffer,"diffuse")),a&&Wr.a.ReflectionTextureEnabled&&(this._uniformBuffer.updateMatrix("reflectionMatrix",a.getReflectionTextureMatrix()),this._uniformBuffer.updateFloat2("vReflectionInfos",a.level,this._reflectionBlur),this._uniformBuffer.updateFloat3("vReflectionMicrosurfaceInfos",a.getSize().width,a.lodGenerationScale,a.lodGenerationOffset))),this.shadowLevel>0&&this._uniformBuffer.updateFloat("shadowLevel",this.shadowLevel),this._uniformBuffer.updateFloat("alpha",this.alpha),this.pointsCloud&&this._uniformBuffer.updateFloat("pointSize",this.pointSize),n.USEHIGHLIGHTANDSHADOWCOLORS?(this._uniformBuffer.updateColor4("vPrimaryColor",this._primaryHighlightColor,1),this._uniformBuffer.updateColor4("vPrimaryColorShadow",this._primaryShadowColor,1)):this._uniformBuffer.updateColor4("vPrimaryColor",this._primaryColor,1)),this._uniformBuffer.updateFloat("fFovMultiplier",this._fovMultiplier),r.texturesEnabled&&(this._diffuseTexture&&Wr.a.DiffuseTextureEnabled&&this._uniformBuffer.setTexture("diffuseSampler",this._diffuseTexture),a&&Wr.a.ReflectionTextureEnabled&&(n.REFLECTIONBLUR&&n.TEXTURELODSUPPORT?this._uniformBuffer.setTexture("reflectionSampler",a):n.REFLECTIONBLUR?(this._uniformBuffer.setTexture("reflectionSampler",a._lodTextureMid||a),this._uniformBuffer.setTexture("reflectionSamplerLow",a._lodTextureLow||a),this._uniformBuffer.setTexture("reflectionSamplerHigh",a._lodTextureHigh||a)):this._uniformBuffer.setTexture("reflectionSampler",a),n.REFLECTIONFRESNEL&&(this._uniformBuffer.updateFloat3("vBackgroundCenter",this.sceneCenter.x,this.sceneCenter.y,this.sceneCenter.z),this._uniformBuffer.updateFloat4("vReflectionControl",this._reflectionControls.x,this._reflectionControls.y,this._reflectionControls.z,this._reflectionControls.w)))),kr.a.BindClipPlane(this._activeEffect,r),kr.a.BindEyePosition(o,r)}!s&&this.isFrozen||(r.lightsEnabled&&kr.a.BindLights(r,t,this._activeEffect,n,this._maxSimultaneousLights,!1),this.bindView(o),kr.a.BindFogParameters(r,t,this._activeEffect,!0),this._imageProcessingConfiguration&&this._imageProcessingConfiguration.bind(this._activeEffect)),this._uniformBuffer.update(),this._afterBind(t,this._activeEffect)}}},t.prototype.dispose=function(t,i){void 0===t&&(t=!1),void 0===i&&(i=!1),i&&(this.diffuseTexture&&this.diffuseTexture.dispose(),this.reflectionTexture&&this.reflectionTexture.dispose()),this._renderTargets.dispose(),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),e.prototype.dispose.call(this,t)},t.prototype.clone=function(e){var i=this;return w.a.Clone(function(){return new t(e,i.getScene())},this)},t.prototype.serialize=function(){var e=w.a.Serialize(this);return e.customType="BABYLON.BackgroundMaterial",e},t.prototype.getClassName=function(){return"BackgroundMaterial"},t.Parse=function(e,i,r){return w.a.Parse(function(){return new t(e.name,i)},e,i,r)},t.StandardReflectance0=.05,t.StandardReflectance90=.5,l.c([Object(w.e)()],t.prototype,"_primaryColor",void 0),l.c([Object(w.b)("_markAllSubMeshesAsLightsDirty")],t.prototype,"primaryColor",void 0),l.c([Object(w.e)()],t.prototype,"__perceptualColor",void 0),l.c([Object(w.c)()],t.prototype,"_primaryColorShadowLevel",void 0),l.c([Object(w.c)()],t.prototype,"_primaryColorHighlightLevel",void 0),l.c([Object(w.b)("_markAllSubMeshesAsLightsDirty")],t.prototype,"primaryColorHighlightLevel",null),l.c([Object(w.l)()],t.prototype,"_reflectionTexture",void 0),l.c([Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionTexture",void 0),l.c([Object(w.c)()],t.prototype,"_reflectionBlur",void 0),l.c([Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionBlur",void 0),l.c([Object(w.l)()],t.prototype,"_diffuseTexture",void 0),l.c([Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"diffuseTexture",void 0),l.c([Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"shadowLights",void 0),l.c([Object(w.c)()],t.prototype,"_shadowLevel",void 0),l.c([Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"shadowLevel",void 0),l.c([Object(w.n)()],t.prototype,"_sceneCenter",void 0),l.c([Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"sceneCenter",void 0),l.c([Object(w.c)()],t.prototype,"_opacityFresnel",void 0),l.c([Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"opacityFresnel",void 0),l.c([Object(w.c)()],t.prototype,"_reflectionFresnel",void 0),l.c([Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionFresnel",void 0),l.c([Object(w.c)()],t.prototype,"_reflectionFalloffDistance",void 0),l.c([Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionFalloffDistance",void 0),l.c([Object(w.c)()],t.prototype,"_reflectionAmount",void 0),l.c([Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionAmount",void 0),l.c([Object(w.c)()],t.prototype,"_reflectionReflectance0",void 0),l.c([Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionReflectance0",void 0),l.c([Object(w.c)()],t.prototype,"_reflectionReflectance90",void 0),l.c([Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionReflectance90",void 0),l.c([Object(w.c)()],t.prototype,"_useRGBColor",void 0),l.c([Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRGBColor",void 0),l.c([Object(w.c)()],t.prototype,"_enableNoise",void 0),l.c([Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"enableNoise",void 0),l.c([Object(w.c)()],t.prototype,"_maxSimultaneousLights",void 0),l.c([Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"maxSimultaneousLights",void 0),l.c([Object(w.i)()],t.prototype,"_imageProcessingConfiguration",void 0),t}(jr.a);s.a.RegisteredTypes["BABYLON.BackgroundMaterial"]=Zr;var Jr=i(73),$r=function(){function e(t,i){var r=this;this._errorHandler=function(e,t){r.onErrorObservable.notifyObservers({message:e,exception:t})},this._options=l.a({},e._getDefaultOptions(),t),this._scene=i,this.onErrorObservable=new n.c,this._setupBackground(),this._setupImageProcessing()}return e._getDefaultOptions=function(){return{createGround:!0,groundSize:15,groundTexture:this._groundTextureCDNUrl,groundColor:new o.e(.2,.2,.3).toLinearSpace().scale(3),groundOpacity:.9,enableGroundShadow:!0,groundShadowLevel:.5,enableGroundMirror:!1,groundMirrorSizeRatio:.3,groundMirrorBlurKernel:64,groundMirrorAmount:1,groundMirrorFresnelWeight:1,groundMirrorFallOffDistance:0,groundMirrorTextureType:_.a.TEXTURETYPE_UNSIGNED_INT,groundYBias:1e-5,createSkybox:!0,skyboxSize:20,skyboxTexture:this._skyboxTextureCDNUrl,skyboxColor:new o.e(.2,.2,.3).toLinearSpace().scale(3),backgroundYRotation:0,sizeAuto:!0,rootPosition:o.x.Zero(),setupImageProcessing:!0,environmentTexture:this._environmentTextureCDNUrl,cameraExposure:.8,cameraContrast:1.2,toneMappingEnabled:!0}},Object.defineProperty(e.prototype,"rootMesh",{get:function(){return this._rootMesh},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"skybox",{get:function(){return this._skybox},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"skyboxTexture",{get:function(){return this._skyboxTexture},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"skyboxMaterial",{get:function(){return this._skyboxMaterial},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"ground",{get:function(){return this._ground},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"groundTexture",{get:function(){return this._groundTexture},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"groundMirror",{get:function(){return this._groundMirror},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"groundMirrorRenderList",{get:function(){return this._groundMirror?this._groundMirror.renderList:null},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"groundMaterial",{get:function(){return this._groundMaterial},enumerable:!0,configurable:!0}),e.prototype.updateOptions=function(e){var t=l.a({},this._options,e);this._ground&&!t.createGround&&(this._ground.dispose(),this._ground=null),this._groundMaterial&&!t.createGround&&(this._groundMaterial.dispose(),this._groundMaterial=null),this._groundTexture&&this._options.groundTexture!=t.groundTexture&&(this._groundTexture.dispose(),this._groundTexture=null),this._skybox&&!t.createSkybox&&(this._skybox.dispose(),this._skybox=null),this._skyboxMaterial&&!t.createSkybox&&(this._skyboxMaterial.dispose(),this._skyboxMaterial=null),this._skyboxTexture&&this._options.skyboxTexture!=t.skyboxTexture&&(this._skyboxTexture.dispose(),this._skyboxTexture=null),this._groundMirror&&!t.enableGroundMirror&&(this._groundMirror.dispose(),this._groundMirror=null),this._scene.environmentTexture&&this._options.environmentTexture!=t.environmentTexture&&this._scene.environmentTexture.dispose(),this._options=t,this._setupBackground(),this._setupImageProcessing()},e.prototype.setMainColor=function(e){this.groundMaterial&&(this.groundMaterial.primaryColor=e),this.skyboxMaterial&&(this.skyboxMaterial.primaryColor=e),this.groundMirror&&(this.groundMirror.clearColor=new o.f(e.r,e.g,e.b,1))},e.prototype._setupImageProcessing=function(){this._options.setupImageProcessing&&(this._scene.imageProcessingConfiguration.contrast=this._options.cameraContrast,this._scene.imageProcessingConfiguration.exposure=this._options.cameraExposure,this._scene.imageProcessingConfiguration.toneMappingEnabled=this._options.toneMappingEnabled,this._setupEnvironmentTexture())},e.prototype._setupEnvironmentTexture=function(){if(!this._scene.environmentTexture)if(this._options.environmentTexture instanceof wr.a)this._scene.environmentTexture=this._options.environmentTexture;else{var e=Gr.CreateFromPrefilteredData(this._options.environmentTexture,this._scene);this._scene.environmentTexture=e}},e.prototype._setupBackground=function(){this._rootMesh||(this._rootMesh=new de.a("BackgroundHelper",this._scene)),this._rootMesh.rotation.y=this._options.backgroundYRotation;var e=this._getSceneSize();this._options.createGround&&(this._setupGround(e),this._setupGroundMaterial(),this._setupGroundDiffuseTexture(),this._options.enableGroundMirror&&this._setupGroundMirrorTexture(e),this._setupMirrorInGroundMaterial()),this._options.createSkybox&&(this._setupSkybox(e),this._setupSkyboxMaterial(),this._setupSkyboxReflectionTexture()),this._rootMesh.position.x=e.rootPosition.x,this._rootMesh.position.z=e.rootPosition.z,this._rootMesh.position.y=e.rootPosition.y},e.prototype._getSceneSize=function(){var e=this,t=this._options.groundSize,i=this._options.skyboxSize,r=this._options.rootPosition;if(!this._scene.meshes||1===this._scene.meshes.length)return{groundSize:t,skyboxSize:i,rootPosition:r};var n=this._scene.getWorldExtends(function(t){return t!==e._ground&&t!==e._rootMesh&&t!==e._skybox}),o=n.max.subtract(n.min);if(this._options.sizeAuto){this._scene.activeCamera instanceof _t&&this._scene.activeCamera.upperRadiusLimit&&(i=t=2*this._scene.activeCamera.upperRadiusLimit);var s=o.length();s>t&&(i=t=2*s),t*=1.1,i*=1.5,(r=n.min.add(o.scale(.5))).y=n.min.y-this._options.groundYBias}return{groundSize:t,skyboxSize:i,rootPosition:r}},e.prototype._setupGround=function(e){var t=this;this._ground&&!this._ground.isDisposed()||(this._ground=de.a.CreatePlane("BackgroundPlane",e.groundSize,this._scene),this._ground.rotation.x=Math.PI/2,this._ground.parent=this._rootMesh,this._ground.onDisposeObservable.add(function(){t._ground=null})),this._ground.receiveShadows=this._options.enableGroundShadow},e.prototype._setupGroundMaterial=function(){this._groundMaterial||(this._groundMaterial=new Zr("BackgroundPlaneMaterial",this._scene)),this._groundMaterial.alpha=this._options.groundOpacity,this._groundMaterial.alphaMode=_.a.ALPHA_PREMULTIPLIED_PORTERDUFF,this._groundMaterial.shadowLevel=this._options.groundShadowLevel,this._groundMaterial.primaryColor=this._options.groundColor,this._groundMaterial.useRGBColor=!1,this._groundMaterial.enableNoise=!0,this._ground&&(this._ground.material=this._groundMaterial)},e.prototype._setupGroundDiffuseTexture=function(){if(this._groundMaterial&&!this._groundTexture)if(this._options.groundTexture instanceof wr.a)this._groundMaterial.diffuseTexture=this._options.groundTexture;else{var e=new Ve.a(this._options.groundTexture,this._scene,void 0,void 0,void 0,void 0,this._errorHandler);e.gammaSpace=!1,e.hasAlpha=!0,this._groundMaterial.diffuseTexture=e}},e.prototype._setupGroundMirrorTexture=function(e){var t=Ve.a.CLAMP_ADDRESSMODE;if(!this._groundMirror&&(this._groundMirror=new Vr("BackgroundPlaneMirrorTexture",{ratio:this._options.groundMirrorSizeRatio},this._scene,!1,this._options.groundMirrorTextureType,Ve.a.BILINEAR_SAMPLINGMODE,!0),this._groundMirror.mirrorPlane=new o.n(0,-1,0,e.rootPosition.y),this._groundMirror.anisotropicFilteringLevel=1,this._groundMirror.wrapU=t,this._groundMirror.wrapV=t,this._groundMirror.gammaSpace=!1,this._groundMirror.renderList))for(var i=0;i<this._scene.meshes.length;i++){var r=this._scene.meshes[i];r!==this._ground&&r!==this._skybox&&r!==this._rootMesh&&this._groundMirror.renderList.push(r)}this._groundMirror.clearColor=new o.f(this._options.groundColor.r,this._options.groundColor.g,this._options.groundColor.b,1),this._groundMirror.adaptiveBlurKernel=this._options.groundMirrorBlurKernel},e.prototype._setupMirrorInGroundMaterial=function(){this._groundMaterial&&(this._groundMaterial.reflectionTexture=this._groundMirror,this._groundMaterial.reflectionFresnel=!0,this._groundMaterial.reflectionAmount=this._options.groundMirrorAmount,this._groundMaterial.reflectionStandardFresnelWeight=this._options.groundMirrorFresnelWeight,this._groundMaterial.reflectionFalloffDistance=this._options.groundMirrorFallOffDistance)},e.prototype._setupSkybox=function(e){var t=this;this._skybox&&!this._skybox.isDisposed()||(this._skybox=de.a.CreateBox("BackgroundSkybox",e.skyboxSize,this._scene,void 0,de.a.BACKSIDE),this._skybox.onDisposeObservable.add(function(){t._skybox=null})),this._skybox.parent=this._rootMesh},e.prototype._setupSkyboxMaterial=function(){this._skybox&&(this._skyboxMaterial||(this._skyboxMaterial=new Zr("BackgroundSkyboxMaterial",this._scene)),this._skyboxMaterial.useRGBColor=!1,this._skyboxMaterial.primaryColor=this._options.skyboxColor,this._skyboxMaterial.enableNoise=!0,this._skybox.material=this._skyboxMaterial)},e.prototype._setupSkyboxReflectionTexture=function(){this._skyboxMaterial&&(this._skyboxTexture||(this._options.skyboxTexture instanceof wr.a?this._skyboxMaterial.reflectionTexture=this._options.skyboxTexture:(this._skyboxTexture=new Gr(this._options.skyboxTexture,this._scene,void 0,void 0,void 0,void 0,this._errorHandler),this._skyboxTexture.coordinatesMode=Ve.a.SKYBOX_MODE,this._skyboxTexture.gammaSpace=!1,this._skyboxMaterial.reflectionTexture=this._skyboxTexture)))},e.prototype.dispose=function(){this._groundMaterial&&this._groundMaterial.dispose(!0,!0),this._skyboxMaterial&&this._skyboxMaterial.dispose(!0,!0),this._rootMesh.dispose(!1)},e._groundTextureCDNUrl="https://assets.babylonjs.com/environments/backgroundGround.png",e._skyboxTextureCDNUrl="https://assets.babylonjs.com/environments/backgroundSkybox.dds",e._environmentTextureCDNUrl="https://assets.babylonjs.com/environments/environmentSpecular.env",e}(),en=i(46),tn=function(e){function t(t,i,r,o,s){void 0===s&&(s=null);var a=e.call(this,t,o)||this;a._useDirectMapping=!1,a.onLoadErrorObservable=new n.c,t=t||"photoDome",r.resolution=0|Math.abs(r.resolution)||32,r.size=Math.abs(r.size)||(o.activeCamera?.48*o.activeCamera.maxZ:1e3),void 0===r.useDirectMapping?a._useDirectMapping=!0:a._useDirectMapping=r.useDirectMapping,a._setReady(!1);var c=a._material=new Zr(t+"_material",o);return a._mesh=de.a.CreateSphere(t+"_mesh",r.resolution,r.size,o,!1,de.a.BACKSIDE),c.opacityFresnel=!1,c.useEquirectangularFOV=!0,c.fovMultiplier=1,a.photoTexture=new Ve.a(i,o,!0,!a._useDirectMapping,void 0,void 0,function(e,t){a.onLoadErrorObservable.notifyObservers(e||"Unknown error occured"),s&&s(e,t)}),a.photoTexture.onLoadObservable.addOnce(function(){a._setReady(!0)}),a._mesh.material=c,a._mesh.parent=a,a}return l.d(t,e),Object.defineProperty(t.prototype,"photoTexture",{get:function(){return this._photoTexture},set:function(e){this._photoTexture!==e&&(this._photoTexture=e,this._useDirectMapping?(this._photoTexture.wrapU=Ve.a.CLAMP_ADDRESSMODE,this._photoTexture.wrapV=Ve.a.CLAMP_ADDRESSMODE,this._material.diffuseTexture=this._photoTexture):(this._photoTexture.coordinatesMode=Ve.a.FIXED_EQUIRECTANGULAR_MIRRORED_MODE,this._photoTexture.wrapV=Ve.a.CLAMP_ADDRESSMODE,this._material.reflectionTexture=this._photoTexture))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"fovMultiplier",{get:function(){return this._material.fovMultiplier},set:function(e){this._material.fovMultiplier=e},enumerable:!0,configurable:!0}),t.prototype.dispose=function(t,i){void 0===i&&(i=!1),this._photoTexture.dispose(),this._mesh.dispose(),this._material.dispose(),this.onLoadErrorObservable.clear(),e.prototype.dispose.call(this,t,i)},t}(en.a),rn=function(){function e(){}return e.CreateResizedCopy=function(e,t,i,r){void 0===r&&(r=!0);var n=e.getScene(),o=n.getEngine(),s=new Mi("resized"+e.name,{width:t,height:i},n,!e.noMipmap,!0,e._texture.type,!1,e.samplingMode,!1);s.wrapU=e.wrapU,s.wrapV=e.wrapV,s.uOffset=e.uOffset,s.vOffset=e.vOffset,s.uScale=e.uScale,s.vScale=e.vScale,s.uAng=e.uAng,s.vAng=e.vAng,s.wAng=e.wAng,s.coordinatesIndex=e.coordinatesIndex,s.level=e.level,s.anisotropicFilteringLevel=e.anisotropicFilteringLevel,s._texture.isReady=!1,e.wrapU=Ve.a.CLAMP_ADDRESSMODE,e.wrapV=Ve.a.CLAMP_ADDRESSMODE;var a=new Dt("pass",1,null,r?Ve.a.BILINEAR_SAMPLINGMODE:Ve.a.NEAREST_SAMPLINGMODE,o,!1,_.a.TEXTURETYPE_UNSIGNED_INT);return a.getEffect().executeWhenCompiled(function(){a.onApply=function(t){t.setTexture("textureSampler",e)};var t=s.getInternalTexture();t&&(n.postProcessManager.directRender([a],t),o.unBindFramebuffer(t),s.disposeFramebufferObjects(),a.dispose(),t.isReady=!0)}),s},e.GetEnvironmentBRDFTexture=function(e){if(!e._environmentBRDFTexture){var t=Ve.a.CreateFromBase64String(this._environmentBRDFBase64Texture,"EnvironmentBRDFTexture",e,!0,!1,Ve.a.BILINEAR_SAMPLINGMODE);t.wrapU=Ve.a.CLAMP_ADDRESSMODE,t.wrapV=Ve.a.CLAMP_ADDRESSMODE,e._environmentBRDFTexture=t}return e._environmentBRDFTexture},e._environmentBRDFBase64Texture="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAYAAABccqhmAAAgAElEQVR4Xu19Z7PtTHbW1g3jMMbGmGDAZAMm5xxMLDAU0WSKWOQcCoqccw6eGdtgk4yNbZxnvvAL+Af8Af6AsQl+06ako9X36dXPSi3pnPu+cz/cOntL3S1pq5+w1mrpLs/eud9fvn27rf9evPPwFz+v22S7fGZ/n7/70G79J5/Xv/qzbLP+Pnvvoc/6Tz7jX/15/c62LfeH7fofbpfP3l/ct36Wf+u4+D37+XYb++G26LPsr/zFttnPuh37bm1bt0f7MvtlnOx4uv0H4fty8UUsz77rfn/57u32cgXvDv72eQf0tl0+G38b0Nf9K4Dl704MEfA16KsE8Gw9JgD+DQE8EA0DT2b7GwK4GHnF4a8iguXZt9/vL5/dbisJbEq/uwD5vIK/fbbAv4N9U/8nJIDNCazKvBLBGwdwu62OhajxmQSAx6gqNp5HCg9wPan2nwSNjhLD8ux/3u8vP3y7vbwDAYjtR8AzFyDqLu1Q+YEINnew23rPCYiKb+q/K7o4AVT4tg0t/h4ydJZfkQASQ/d5b9fZ/Z1ENmuPn/cwYCYEELBguKC3nRkCnE0AFOwOKCOAR/sH/L4hgFMpbSWP5dn/uN9ffs7t9mJ5cAHoBLTyszBAFJ/F/xIKdASw5wgaEWDMLySxAk4svf6L+4QAGPiJCziNAPb4f3UZ2dh/m+z7BK4SAPYrxf5FB6ABPgCUAfANAZwKyscc7IEA/vv9/uLzbreXzx9cQCMACAl00m8jAlF7ov6SCMQ8gJsMFFBnCECSg5H6TxJAU3vPAbwhgFfz9AABeOEDBcIbB3AqPzwQwH+731/8sNvt5Ydut5e3B2C/fG9P+jESgGz/RgxG9r9VAwTUUh0goQDafUz+DYnAnSha5l99Z1l/yQVswAZSGIAugNd/9xBgCw9E8aECkHUB22QPHIAVDlQdQAMWAibhBgZAasAVHUAI8Cqg96Tm0bj3VBS9jwd7IIBvuN9ffMHt9vLTbreXy+32QlwAhgMIeuNzKwOqCoB2Aa00KHE+EsIeDuj4H2N+Hf/TfAC6A4nhgQCQDDwiaKDXiq9KgBEJNPArAtCk0AEd2mpAizW3/lYIoANpBPg3BPA+hjs/9eXZV+0E8Bm32wsJA9aEoBCAuAABPiEAC/yDC4gSgRgKRHkAlgsI6v7iEFqJEMgBwb4BGkEfEEDnDlReoAP/SQRgOYIB+IYDMEE/SQBbXoLNr0jhq4qOZc0PHBSf5oKW519xvz//kbfby8+83V68ABfwniIBgwgQ/HoRUMv8w5qAoQqgk4DWQiCw+63eD8k/XAPQgK5s/5a5xzAAqgR6wY9k+ZEMtCOoJABb230hEHMFWQdgAl0Ap/+uc6tKBrrP/n0AuwfiNwTwNKguHHV5/qX3+/M1B/Ddb7cXax7g2e324vaQB3hhkMAW92tHoFb96cVAbimwkgQ0Vv7R+D8iACfuxzKfLvnNlAAjAsBwwP2MwLQAD9sbYJME0AFcg5uBPSAA0x0AobhtcDKDA0j3KYDhk7Hp8uKj9/vzH3C7vfget9uLT9nDgDUZuOYCLBJA8MNKPyGGIftPrL+4gy3eh5p/lwRUYYAs9Fn7tM/E9lvJwCH2DxJ/mPTr4nyyLiDtBgTAGCrgNuPzNuETgN+suEEAFhng9lkCoICMLH7V0isCeEMCxylrefkl9/uzz90J4NNUGLDmAnYXINUBrf5dCCAuQCcCvYVAYPk3G++VAveVfkIAFRLolgbr2F9ifP33pAqAV/fHRF4HcAS7AKlAAEIYFNwITOszs/wMsB6II4BXFZ0QwBsSOEYCDwTw2TsBfPrt9uLlqzCgcwFABI0EVCiANl8Uvq0JWNsi2JPZ/0YKsOiHxftsW4v51ZqAaBWgZf91PsBL/jFHwEqBR1cCiuJ3gAfCmCEA3cf8rmz8AMZHIoA3JDBPAsuHVgL4jNvt+UoCH34ggK0asIYBGArsAB7AD+reQgCl+GwZ8LaNlP3MEEDaSg4ACMGr/+ulwV4JsAEfLH42/vdKgWElAJ4QpBl+LAlKErHwt+oGMgTA2ngE4IUIOH3dGr/hAKT/m/UBdSJYPuVL7vflU26352sScCWAD+0EsCcDVxewKjfmAzAsENVn4EfgdySgnYB81yEAgL4RA8T8mTUASAAYBgylQAkL8K/+zL6rsl8qF6ArAeS7WRGoAB8Sf7isN/VZqTs6jQ5wXlweWfyqpQ8I4I0TmCCAT/3I/b48u92ef9bt9nwNAdZE4FoOFALYXcAGegkDMByAzzQEgJh+cAIs/legH0IA5QTCPADE+7ISkD0TgA/8sBIgLQfOgF/F9kPcr+J8fIYguyCILQRKgV4DNviOzoKqeJS0u4AA3pBAjQSWT//I/b5OmC0MWB3ASgBrGLA+IryvDNxCgRXo+wKhjgwk8bcTwUACsJ09ANRVAALwCxmEoFcrAUsuAJ4M1E8BDuHABAHomJ8RgACrZfQLyT9dBWi2OOEG9NJd/TDQ8HAQuBE97ZhjGKy6o+imnU+4gDckkCeB5cMfud/v6zr9Dz84gOdCAM/3JwQhF9CAD25gBWWz/8wNgMpj3K9Lfy0foMMBVffXyT4r+cceC9bvCcDFP0311QrATPkvWgosYQFLAuoqQEcQuw3v2si25F+M1RkZXLUU+CgBmCBOEsCbvECOBJbP+Oj9fv+u2+3Zp91uz9cy4Kfebs/3ROD6iPD2b10YJCXB+0PyrgsHdtBuRACfBeTN+uM+suJPSEDbfh3/oxPoHgwiC3/06j8Eutj69sAQqj++I0CUfvIpwCEvYCT90O4Pn1XsT5Ve1/+dcp9FBh3woqXBSEJkvjHHEOUPqJPAjUUCeOMGfCJYPvOj9/t7//d2e7YmAlcS2B3A8xcPYcBm/7ULEDIQew+5gS0EIEA31R8Uf6gAoBsgKwBd9ddvBBJAs6XARgLQXQ2o7T8+IETe+9eRACg7rhCMVgCiE8D4O9wOCb2ubOht1/vYd2ubzLlgKbBHEDSnAMfL6durVm8qBPwXWz7rY/f7/X/fbsvL2+3Zqv4QAjzfw4COAMAJbEC3wC8koBJ9lAhgxZ+4hi3Oh/f8dU8EqtV/JhHgWn9cC4CJQZXZp6GAk/1nawMkrrcqAiwPIIA2FwOB2oaAF5UkcX+GADBs0I5gsNbBQqCorJcFJjqWKvhNMjky0Aek7/LZH7vf3/vO2215vruAD91uz/dSYCOAPQzYkoD7vw34sFIQw4LNymNSUKk8Wv0hCYhkoJ74Q6BboO9eDKoWAHXvBiCvAdPZf4nt3QqA924AbfXV8t8uN4Bt2We029WkoErWpSoCSm11TM8AOYA5uRS4RAITIQDDavaYHxCcm5exfM7H7vd3v2N9McDt9uxDD//WKsAG/ue32/M1DEACuO3g1jkBsf57fqCL/7UbIISAio85AAG0VQEYiIC9DJTYfy/+Dx8HlpeDRK8G90IBHQbgWgD2WT8LoOJ7NyeA5JEkAwwxmuqzur5X6y+sBEwDMggrqoBNH7c68Puk/fI9Vwfwvx4e6H724oEA1iSg5AAaAewlweeyLmAnAHQCTfU1CTAH4GyTMt+QDMRFQFEYQB71lXUAOjHYlvTqh4N2xe5yASoh2PpaJUGDBDrLr9cGIDlY1l+vDlQOAQHckYMiA68KMFsGtOy65RCGsMIDT+QqJoD3yUwCy/f+6P3+7koAt50AXrwigM0FrIuEoBrwHMMAUhmQUKAlAwHo7VmAPURo9h/r//ozLv1V7/5v6wGMV4B3rwYPXEBqIZAQwp4TYDE+LQlqtQfw6my/LgsyZaeLg7wVgmDnWQ5AA5ZWCDRx7ECzyn3udgFptFCIgTlyFRMEUCKgA+O/jl2Xz/3o/f7Otz88QvpszQOsLmAPARoBSDVgud02AthdwPZ5BSxUBVr8L3kAVHrvs076KSLQi3/M9QCJ7H/G/rf4n8X41XIgcwHecuBMDgAe+BHA6uQgqnvbF5DB5hwUQM3vQgIWkKOVftH+gAC6cz0RXZ9MjmD5fh/ZCWCd1CsB7CSwhgArAUgIIC5AQoDOCewJwab+CH79WR4C0mQAZT4hEQS9DgfEztNkoEECDfi6FAhZflb6Q1XXqwHDEECpvZX4a0qP1l7bfAS98cQfzQUo9a4mASMC0CsIm6JGK/2i/QkCuFK9PxmIYPm8nQDu795uy3K7LTvwVyJAB7ARwJoAVLkA7QIkJ9A5AQS95Ad2YmgvAJWwQFcBpB38pUuB9wVKbAWgCXwV86Mz2ICKTwUWFgOxMEBicr0eoBwCGBUADfxsDsAiA+zflNay31ZcfnAdAAXgDGkcdAcfZCJYfuCX3O9vf/vtthHAmgcQF7ATwOoAtn9IACsRSDkQ/wqIIUGoXYEQQ/sL5IDJP539776DwodVAGlr5QBgP8sDdApP3gSUXQa8/rZsRaBeHmy+HwDyCI1MUNlZzX9iJSBO9igJGJYCo4RdIqMfJQ4Ztq8C7FXjHuSnQ92XH/yvdwJ4Z68ErOXAlQRW0O9/JRG42v9GBHsuAImAqv+uzDo30C3yAfVHoHeg9xyAp/7wlp+WFCSWv1sOTBb+0EoAZP5DImBrApAUMFHolQG19c+EAkbpjyUEdQ6gm/QEsCzZFxKDlWNwprJVWfBm/1WAvWrcQ0ie7Lz80H91v7/9v263+9sPI2zrAZAEdvXvXMBKBJIIFDcgyUAEvHICg/o7wA/Bvyt35wCc2F9Cg03RvRyAA34N8hD0xsIfXP7bQgDMFSgyYO8GsF4N/hQ5ALak1yUGRQDZZJ5VWXgKEsie8yQuH63b8vn/8oEA3lsJYJ2EQgD73xX4z9bs/74gaHMBQgA7+DsXAJWBBniHCLTtNx2AUnkG/LYNiUCpvX7wp6sIOHF/lwgkNf8UGagwYMgLMBdgLQCyVgOyciCGCs5nz/Jr8EXOQOcQZEbrfjjTU8qaCBseMyx4vxPB8iP+RU8A24Kg9R8Qgaj/av8lDBgcwApQ+QdVgW0bKr3+jsk//AztzBKgtv4K+Kj08rl7JFgt9BnCAIsQcD2AsQAolQj0CAGAqhOFCK5u3cA+84dyIJLCPm6buAgoBa5qDoDF6wzUkZ13iSDKKwTamSKZSf29cuzJUwq7LV/wz18RwH2Nl9dKABLArv6bC5B/+9OBGxmsIIR1AQ3w2gk4RECTfwBulgC0rP96/FYJUOv9SzkAB/xuKTBY/qsTgZ0LILF/s/RW9v81ywEwhbeAwUIH6hRwGp+wEOhqoF49fojqQoPlR/+z+/3t77jd3n3rdru999CzEYAQAYJfXACEAqL8W5lQgA5uoJUK9zxBB3ii9ALiYT2AjvuN72wFILP+XdlP8gLKFeg6f5QM3AC+VlMMZ9ABGuN+VePHWL6tHVD23or3tQPo2iWfBRgShDp0ELcBjmIAbwTWqEzIJvLM6kEDEFcD9erxCzg3my4/9p/e7299x+323lu32+oAtjwAhgE7Cazqv7mAvRLQcgG7A9B5AAwHus87CWBYsIKFfe+eCSBgt2J+7QBQ+VsogOU/9fIPBvLhASEF8AHwlhPQ2wVYFhmo/Wby74QyYLcmQAEbbbue2FcnAb28QTmHQKBwNVCvHv8IESw//h/f7299pyIA7QIE/LsTeIbqL59hPUADvHIBG8jBIWgn0L4rsKMj2Noomz8QgZELsCoAAnh0Caj8lup7ib9tX+ZBoKgUmFkWTGJ8S/UHZa/kAHT+QGaeoeQmMUC/CoAzVYAjYDvSNwPCq8fPnINus/zEfwQE8O7tdt8dwGZjIQQQ9Y9cwAB+RQIC4I4MdvvdLL+O//E7LgLykn6q3Efjf6X8bOUfkoNYcQZ8z/KzBUBYCqT/YQgjBuOBHxPs7JHh7JoAy/IzWz+xEtBKBEYg8fIGw+SeQQQ+CzHZP+oWXWPU/8z9y0/+h/f729/5kAN4791X/6/cpl4SCsDfLRQwHEBLCmJFYH92vssNgBPo7D8qv4CekIHpAjKgx1iffGbKb5UAQwdguIAtz2KsEWj7vIQggNON91lYoIFN2mznYKj9UBmwQgXLLcDstRTdBchEFWAWcLP9MgC9cuzM8aXN8lP//v3+9v/uCUDyAM0FIBFADqAjAsgFiAvYwK3/MfAL8InSd/Yfy37Qpyv3OSTgxf8C5vZXPfF3aB2AA3hJGg5LghMOgCUBo8SgEAyC3Irvh5xAwhW0cT1iQBKYWds/QQLdeVUQcrEjeGoiWH7633sggHfWJOAaAkglYL/wLQyQf3tYsCp9CwmgFIgOgIJ/JwMdBuB3cQTDX4z9wR2whN+WE9idh67761p/F/8bpb8O/OotQCsJDhZfji0qT9p0LsCI83X9H8E9KH8iCSiTrQO29bwAAbvlCipPAw4T/oRKQAVElbaMJ472t7jnqnEjrlt+1t+539/6P4oAxLquawIkF7Bb/40M9hAAHcD2GVzABmBYKSgxfyMGAbROCipl1w6gs/8ZF0Cy/UIOOr7vHAIu9iHP/2v77yX9ROUt29+AHVUCnDJgtvSn8wXsnQGzIUAW3F27qFS4z2CrD07wCogqbR8LtGecUwR4vX/5OX/7FQFsOYC9FCiToBGAEAH83ZwA5AM06BspiPKrNQIt/kcg69iffBegNqVXb/wdQgIMC0DltUuQ+L+Bmz0OrNTdK/91+4JVf15SEPMCYRkwEfc3stBxurMS0AoTMKRocaV8cKw6jpcFsdUn2/8qRT8buGeP55HC8vP+5v3+1v99cADvvfNQBZB4dO24Kv5GAntSUOz/+n1wAis4wAnoMAC/N9svSUKsBABgmwPAbQTwWzsW/2vAI6j14h+1CEjnBYZFQWSxj+sEVFyPjgBBrhf+aOtPY39vRaBVJlQ2vyOGIATQsb6etBguDMSQyAF4IMhUAmZANNNnUNSqBDvtzzif6HSWL/wbuwN4eycA4gDEBQgRYPzfSGC3/BYBdOCHxKBHBAJoAbdWfIz1I9XXsf5g9y0yAJB7iUDPCaC6e2EA2ngMGyIHwAgBldncf4ID0EDXVp1NYmbnrclOtyfDhiPOoCO4CEXB/rOBfOZ4yy/8a7sDAALY1gKAfWMEgOovoNdk0IArKr+7gwH02gWQ2L4t/sEEoLL2IQnoFX96HYC4CIz/jcSgAJSVAtu2RPZ/SPRBHkC7AkYEqceC2fqBfdKaCcHAAeAkpKVBCANcElBVgBQRTC4HngHOTJ+rQo2jhEbP6xf/VU4AmBza7L+EAZgLgGSgxP8dGQDwmQOQbS2xp6oEWAnQn1seIEMCJO4fsv8Q2w/JQU0IJMvPiCCT/NPuQP/noJ0rAFBa23VSr1N/vQhIgxzzB9odMMIAkGvFZPF6JkyIlJeFFl6IcRYYX0ciOOOcll/6l+/3t/7fngPYy4BSCmyT0SGAlgvY4/+BAET10fZjUhAWCg2AV8nBEPQ6D6DJgSUAoQ/G+Dr+T9l/pfg0HxAs/e3WBUhbsihIgHKkHGiGCQHYO/UHomDgdd0BcRkZlYtyAFlgZNtlzqkSJcwc1xr/6FjLL/tLPQG8t+YA3tuXBKPiqISgAB//bjZdkoNE/Rs5EAIYXIAKCwYHYJADlvhalp8RgS4PogNwFN8jgo1A2LoALxRw1gA09TbCAjckQHBZlQEFwEoS0Iv1S3mAYFGPlwOIJn+0v+ocPohEsHzRX9gJYM0BvPvwTyoB2gGsP6iEAowANsBJWAAVgRYeAPCb/WdkAKEAttNJwRbzM+UPQI8K36k9Kf3RagBTe2vhj3o8uAFXLxUGxTdXBrK1AIltTZ2JzUe7Lp/Ralvxvrb5kcWP9nv2fwBzIRF4FRFkx/XcwRljHCGm5Vf++fv9re+63d4xCABVRhOAJoOtRCguQKoCmghwv7L/mBPQwB/KfMQhCEF0ym8RAUkIToUAxrP/gxOwSoDGmn9WCjTzASw3kHQA5poA7Q4g3n+MEMAChiadiopXwHZV26usvB43e/7Lr/pznADakmBdDcB8AFj+5ggcF4AhgAlwwyUM6m+pPgF8U3BS6jOdAAkJ3HUAO5C7ZKBT99/IVDsGhwyY3e8qNfhCERXDa5BrlW/ftaoqe265Ar0U+PIQQCUzqwqYBYfnSK4AcuW8sjmHaMzl1/zZnQDeud3eXRcCrfH/ngNYbyxzAKL8nQNAMiC5gI0gBNz42XIBAnAkBACwqDyWByPlp2BPWP7WD0Crs/5ewq+1JaBnWX8rEajbDiVAlbNpwHRyAJ4D6EqECQcQWfxo/0wI4E3wcPJnUbSLXqH5A26qHaD9kb7ssKaj+nV/ZiSALRG4rwhsJLBfUKt/k3yAJMGwEtCFBGD/PTIY4n6d8ANyaEk/Q/nPUv8h+WeRgXYCVgIwSwbK3osKi4PonEGUC2C2Pngc2LL73Xanlj9bBTg7BIgAFe2vuoxZS14B7wy/DCT8xX/qfn/rrYccwLtrElA7AJkgkrDSJUHJfO/Z/wZ4Kx8g4IXyYKfm0i9QfkoSJK5HghALr51Ce2Jwv0ad9BvAj1WCidKfZf1x3UDnvPQ90HYf7o1WfSQMGbOpU1D3H6oCynpjPE7VfSccpoalMEHNdAxFKkDLgDzTRo5ZaXukz1E34f1Gy2/8kzEB6MUlsjCoCwWMEAAdgOcGTECrnECn+JYTgPyABn0U82vwt7hfJft0rK9DAlHooTSolH94GxBUAnTSL/reAbz6UBADt344SDkIJBIT5E62HgnEAwgFmjq3ChFkAJUFd7Zd9fwsdZ89nnX85Tf/8Z0A1hwAOgDJAxBbuU1usboYCoiCKvWX+L/lAUDlNUG0bD8Bt7dviP9Vf0v9LbV3XQCz/3qbZf2d0h8D+JAPYDb/RAfArL1l92W7Z/OjEICpOZvkw7bES0EisET7M0RxRNkzx78qJGj37rf+MUUA+zoAnQjs1gTAhJNyFy4X7kBtkYHKB0ifDMgrLiADfJMESGa/Cwe0/a+CHsmA5QQ8N6ByAzJZh1IhEobOAegsvwaVDhEKDkCre0cielYbau4SQfIZggyIM0DMtMkc6ywnMHMsduzlt/+R+/2tt2+3d8QBiAtQSUBaEVDxPyYB22cEuiYDQgJtLUFk7539ke1vgAeAR05gC3ekbAclwuaEjEVA3XoAAnLpT6sBCuStrUrIpqsBHhkwcBOVTecFJAteCAFSyk/GzapwBOJofwV0mbEQkNX2p/X9HX9IEcB7eyLw3q8IlPgSbV/LBThEIMreQJkhAeYOIsDrsELV8VmIgHX9ITGo1L+BnxGB5wQY6IvKLzZZCKD7nsj8m+sADjoAVHk9ga19tF1CzSk5GO8T9MCUAdpZbSqEUW17lpNYfucfvN/fBgfwLlQBcEnwdkA9cdGiCjCgGrCpZhACDMSA6wL28dewgKl6GzuI963EXwtf1Nr/wQ0YMb+bCJwAPgKc5gPIPeiImeUC4B5J2zbZnGXBQjI4Mdk2HFNPYqv9MNlJCJByAzPPEezIiUAe7a8ANjPWGYpePc52Db/799/vb7/zKgQQAnhvDwH0cwFWLqBluwkRYJ7AqgoMTiHjApTqR9ZfbLxbCbCUX1wOKQGiO8ASn7XdKgMimL2SoG4nkxGVnqk+OoeBDHR4AN87EmCWnlULBGiBuiNJMFC5RJB8HsACRgYwZ7WpEEY2pNEuYOoYv/f37Q7g3dvtnT3+39YC6BBAv3IK1wVA9p8SAYC5gRDBqz53QDasvag/dQboGMCy0zBA7e/CgoTyszX/VeA35QeH1YGc2Hwr2YchGn5mJNGVd8FdoEOIHEBo9VkeQc3cqFJgEkPhxSBHwoIMCVTAlx1vlggq4y+/7/fe72+tDuDdV2XARgD7isDtd95BpZWjKRUov4Acwa6BT5OEsEjICg1aBUAl8DpwA2kgQeCYbHsjL0zygfKbll9XC5xk3zYGgM1yA0IKERGgI2PJQJ20M13CAQfgWv1kEjBj+Yc2zlqAGdWPgBPtrwI2O16FXMrn8Ad+z04AaxVgTwDiasAtBNgnrK4E6HBgSApichCBBHkBCnQNbmb1iTPoSEXlDXCfTv6x0EAA2OUDtCPA70bMT6sAXjVAlf4sIhieC8BYXy0CYk5gIPKCA8CJGzoAI5QYJqoRzx8NAZ6KCLLgzra7igSWP/i79hzA6gCAAMQFrBMNSUCrFypUm+x78k/cQRffY45AqatOGDJy0CDHkh5dDERielFhWvrTIYHO+icy/jK+qe6sCkCAH70erLsXylXMWv5GFowQrLyACISU6HZ0W+RALX0Qz2ug4NgYUWScRNQ+q6IZ8GbaVMCdHS99jX/4dwIBCAmsoNd5AHAB1sRDArByAV1YgLkBnfRDF6AtPbP4LNY32lkOgMX/tPynSKFzC466Y2JP+mT+mk8BOiVAVP2MA9COgH4nQGcgHxyCAe5uMicqARTcJ+QBIlB5+6O+V4E7c9wMCSx/9HfkCEDyAMPDJiQZ2AABqtZUVwG7s+ZWMlCDO/F9iPFZso9l/IkDaMRgxPqe4g8JQa30yg14pdaM7TddgWHxXcUPVgLqvnqyWw6AqrlT0jPV33AekYJb4IlAdfX+6LwR0BVi8Yhg+WO//X5/e68AyLMAawlwCAEwF2BkpTfgqwlu5QU6G45KrdYNsNi9qwAQMgjBnyEDI77XYGcxfjXut1wAhlfSptsGoNHJPab6XkLwTAeAk1MIidp+mJlRJYCqPxCABwizr0aUDl3I/ogEMsDMjJEZp0oYjECWP/HbSA4ACEDWAbA8gJ6MjADWbYP6i5LqvyRROBBABHgjXEAV14k963s7d0koOkm/s+J+FiaERADqbjkAHKNNrsRCoE7lmYsQ0HjlPm+dgMzKRLmQkkgyBJhR/SPWPwPyTJuriWD5U78FHMB7eyJQ5QDaYiBhXL0mgGWumRNQAO/KbieTASMOL8bvVgUSq2/lAvAaOvDiwiEjs6/BThdZ6bUBJNvfuQN0Z+pzVzI09nXqrT3UMRMAACAASURBVJcKg+J6xKAnLao7Tvruc6ZcyBS6EDpUXUIEvgyAz2oTnQuqe+aYzT386d98v69rALZ1AEIAazVgz/4zBzC8aorlAdS2rkIgC4e8v2TxkOsGMLeA45I6vgZ7ygFg4g8JQhOdl+FPZv+ZnRey0CQhE4PtH1TfCBmkXQd+S+1ZXkCTiQZq0gG4sb6qMHSAKFYQHpsIMoDMtKla/syYy5/9Tb0DWGP/7R8QgOUA2NtnzEw3LhRS6hjlA9CK6/gfS4XU5rOk427p9bg02cfATtS9CwGcSsB6/taTf9Zvx0ItvQ2JgH7WgEYyMMA+5AwmHMBMDsAjAhrPTz5M9H4mggy4M65g+XO/YSeAXf1lLYAsBca/24D7MwKdakBIYOUBxKYyJ0BDAeIOTOW2QI75AgVkXNVH7b+VBFTgDisAQda/gd5LrCrlZpa/WXJrEVBk+cGxNWAkqwDMQWiFNq2/zNKgDOi6A2NFICULRAV8rrSN7HgEzmh/NH4G2MZlDi8qXf78Fz8QgNj/thjIcADtvw9HNcgQwGxIwPIGLHTQVj8BfszWmzkAlZsQwFrlPbcCYOUCjBwKKwl6pUBRWyFhukxY7LmO7414X8f61BVY4YLY9iDBhy6BTX6LPJCoPHtcAXelbQRUD+gZEojGZyCvjrv8hV/fOwArBGBLgnFpcGdJYUJ0gNknxLDNCwm8xKEV6xtqPwt4DWpm92kIQICN7bSNF2Xv/pLfUgNd5wxoCEAA34GbqL0VAmhSuMIBuIqv8wGJRUQWmCzAfNIQwV/8tff7O+9BEhBKgEMiUIUAXjLQinMbAAAcCIruFWMVgBPFX28iLhW2Yvzu+JCo06A21wAQm69XRVJwk+RpaiEQCxeQKEDlaWhgtEWQWEqvt7vhwoQDKAFfjR+5hytdgjf20X1HLH/kIpa//GtUCLATgE4CogOQz628IwzslKx0gosuG1bWnuUGotJhyzUYYUIjBSsnoJKVXZnPCAeYo3EBH1UDDIA38CniiBR/CA1I1r5VEQBUg/1XVt8jjG7iWZUD5WEz5UIK8sRagIhYquQQgfqI/a/aeBYKZMOD5a/86r0MCGsApAqQcQDbgTQBMNuqJ70GE/nuOgMSGjDFj7ZZhNABnxBTIxon459Vfa9yYpUEEfRU5RXounEUkJEgGJlEYNb9O2IQ16hsO07y9nk2ETjzJKG4JIKUSlgQKqyDzgzQM22ic/AcxPLXflXSAew30no8eDsJvBGWyhmJsKojQOAOi3R0yRFtPcvuqxo/tf7qeryYv2T/mZqT0IARgfzmG9Eg6erP8Jvr+4Tk4Sk6IwnWfgA/IxsCPhmfKWuk3ugcqENIgLwC+hl1j4Ac7c+CPDNOd4/++q/ccwCRA1iFHkqAtBrA3ICh/J46Yp7AjM+DHIK27t1aA0YIbKGPIisrw59NAOqSH/0NEKyMCBS4qwnAtNpnk4JGnN8pfKYKoIgiA2R2DEYglW1XE8FZQI6AHu1vv8nf+BUPBNDKgFYOgDkAsHdmQhAnkhP74kNDg72OwgMP0CRuN90GW+CTdCwWoVluQKv3EAYQ1cZjuOpv9JXJNyT49KIgliMwlByVu7kJUFwvPBjcQuaxYSuUOBAGZMjGIxEP1BEQn3z/3/oi4gA0CQD4uxAACMBLCKLNjFSPJd3Q7rtJOWu1oZNcHMgmE+8H5T3P3Xj7OlCzCgEeN+sEVDs8Rpu4Ol9ggd1ScuYWkAQIsDv1lrYqB+BZ/2FfsBqQAe3sbZG6Xwn2aGzr3Ja//cuJA8CnAXfr314SajgBkwBwAs6EAwmwWWFChThY0s8iI297B3DDPYRtCLi3Psb2AdRAHrKvqb9BCEyNtaKXS4OkoqAnomXjKUEo9e/GSjqAs0HvAS8C5WzfaNwKES1/95cZDmAlAbIacPudIRcgi4H0oqBuUirgU6WDSVtJsHnJw8gtZNyGWeJLEJNn61vZzYjzo/3dQ0Ea1DgmUXMWAqTAbil9UOaLynttQj+iAzibCCLQRfstUM+ShJiqqP/y937p7gDuex5gBz5bByD23woDMA9ACeCAG8jkCLTis+8ZUhjCAisZOKvwySw/OoWONFWMrmv4ZsWAqX+wrXMGbLkwnMvgIowEIWuHTsV1CTKz978WeViA88IKDzRnA/Ts8TyCcUng7/+SngC2twFZJLBPljIB4IQ1wgA9waPM+rCfJApN9Tae1beOGZ1LO06CEKj7UbF9A7CVB7AShIa9R3Uf1gOwhF9V6S1iEEQFDqFN3my14IJEYNYRTANNERd+PZMMIsXXp7H8g198v68VgHf2uP9dBX5xAtvbgaUUqEqCg/1HKweAlx9vsLeGIlqxchWojCyqY1RCgXK5jxGHofIsD9B+V92nSAgIxCEkgLEGBU8mAaO4PgoVmEJbOQQG1CzIs+08Msg6kAwRzJBOlgiWf/SLRgewksCq8l0YAKBveQAgBGb/t4vDhJQmAwf4a9dQeZPWnJbiHMfgOYeNlAKlx3BFOxs3L6B+LySS8EUg6rzwuEgQ3luBGugDqx/lCzyCGPbtCBBi05M9Io2OFB4hEXgmGLMgzZDEjIvYruUf/0I7BGgkAJWAbY46SUArGThMyAIZVADH2ppEkiCBir2n5xmpu5ME1I5pUH+LYEnFICKEDpiFEADPSSu0JhQX/MphTBFBIYnI3MRjgLviLs48H9OR/JNf4IcAK9bxPwoV9TerAXgj4T0BOJk9MhAQDZOfACUCNgIy0zbTJpPZpyGAQwTiKug7AYkr0L+N991Vf00gpGyHINbK3yZVMQQwVT2xEMh1BEZ/Nvk1EKsKmgXyGeOeTQQdEf/TL3wggNX2b/H//jqwLRGo1gC0HMCeD9AlQPw+WDqZJEZIoCdaNY6OgOmFAVq5u7ae3Y9AHam7sd8kApUsZHaekclAvrv86eoBcwkZkFvrA1hf1wU4Cu4Btu1T/c8G/hWgrxDEmSFDc0D//OdDCEAqADoPIMnA7a8wrv6LpSEFfJlkoQtAdfKShEmAWlUDN7xgOYYE6DPuBY+Lv0W0HRXdK/cN2X6l0jqcsICubbx2AVeFAK7Sy+zV1YDiasAjgH6MvqZth+vXH6sksfyLn/eKAFaw6yoA5gEE9FYScDsZZfsR8CwhSJNb2Tq5UVLsQO0lE5Pk4bqRiBDU/oEcHFVn9X1T4dFZ6TKhYfWZcltqbm6HsZm6D07QKuGRcqQGgEUKSF5N2QySYPutbZkw4SmJwCIIJIXIYSz/8uf2BEDXAWAosN/w7gUhAHwhge7GY2wGBKFtf5oMGKgcl1Cx/wKwKKQY2hWB3oHbqver7ab6J8t/2L9VbaR6sM8auk4gArlRNbBchQnSaBw5RyV7lRCAgSYCerS/otRZwqiMmSECc7x/9XNUDkCvAyB5AAwDtrlBQgG8KegCOsvolQgrgPKcQKTQSReBhOCquBP3a8LTToXF/vpY8ls2J6AdBFH/rNJfov4YDoL6UzVP5gDc8MBJBFbBnwHrWW08EEcqrvhw+5oNBZZ//bMLBCDqb7kAcAJtUQeyOuQDcGIPnzFeJQClSbJqngBULW3xIzKpkBYe3wGxkISn/u5zASwccLbh5NHhht43ELsFcGeFXwfmA1UAdBsZ9YxU/ej+zDkwJ+RtO5Mkmhh9yc+637cKwJ79lxyAlP/kKcC1IqBzAJgL0K4AQwC0m7hgyAsBrAVEaL0HJU6SQKeiyT6dWictOwsTsqW+9ttosAax/pA3AKJBEqEhQLX+T+J2PG9GEIxEPPC6ag/SNzhOtm/fZo3JABYpfLT/KBFU+leUvxHNR37mSAAC/lYBUDkA76EgIYWOAHASKnXHm4/hwaB8pIxIV8oFFpxlziNws/0diSgF91bwuQQmE7QQ+2fUvwO+pf7KkXRA9db6W6QB1+KCHu1qMgTQE70DoTOG24/Y5qMuIEMOFYBXQ4FM++WjP2MnAFUClGTg5gCEAMhy4M4F7JNou/eZ0qBWELD7qO6D0uNkZXmEwKqb4HXI4wzAa8ejLTYSjb5mfXz8jgCvlP86YrhC/ZH4lfpSFU4SgAfMo88TZFxAlRgyY1aI4Iy2zQF87KfbBLCVAAP199YCaBJAV9AlnAxX0NqwnIBSrHSSziAPa/VeJt/ACMp0AY6l1+CNvofqb6h6NikoJMMUHN2apayZNt3YxRwAPa6Tb2iTXj4cVP2MwkdkUQFz5njsGt1tX/rTHghArwHY7P++DBhdwDanYCWgzgPIfh2TtfUB+6QcJhcBedfGUXoGwAaOyXhdKy4rC1rxPAtlymqfjP0x5h6ArVSdARJdiQa6BWC8t3h8RhQ616AnY+cEigRQdREWUZ1NDBnFz4I5Y+OroMf2y5f9VE4ACH50AS4B7OD28gDtxyEVgW6yOIQwWGlg/Uz8bQLXcBoa/AM56Dq8FcMbCTyx/o3ISF3fsvaMWPRv7JLEPht08nC4TyTDb5UNI1VnwO3coaHQFPBKxa0QwAO/G1LAucwA+2oHkDkny2Vs27/8pygCANUXF9D+h2CdC1CA334rcQf7Z7yxsp8qiFpBOKhPQAiW6jIlN9UdzllAKQBjdtxT9eF8HJLQ5xNae6Lska1nSu+pfyMjb3GOlxwEYrHANwA6sO/abdBxyRiPAf4ZoGf6WOA9y0Es/+YnAwHs4JfsP4v/JSEoTgD/is1veYFZEsB+xAp7gDEX0yRU2asQaHX2wD8QjEEsCDKt0pZqM2LpSqaiiNpteCW7mQSgukc4UTWxsH0Z8EaKT/erRGIW/E/pAo6AOdt35+Pxvwf/t0gA8BKQFfzZMiDmAYakoJ4oUB2gE4UtHDLiYQSa9bnsDEhJj4HfdBYHF/V4Vn8gvh3sh9Rfk60ot7c9Uf+Xc80AkDnCNGng+RrnzCa/RS6Z8zXBJDv0ORnf9bHY96Pbov7LV/ykMQfQrQMgVQABvP67//60BKgXA7UTU9Z/mDgk+TeAndjrBtpCBcEF9Wz23on7j1p9TW74mzaH4jgC/Vtri20uDdakzvIDbTL0y1I9Gx+V8CJHgNeTBfIMEXhjz5LDU5HB8pU/ccwByBOAXQ6AxP9sQVBL5EJGF8uByPYDCehJE1UGAuB7JKD3MadA22iFx9DCiPPpeZAFOZWyH46Jk2cDPiZFRX1IvI7XrMdg2fsOvCRsYGMM25QadgC8KAeQIg5BblAajOL26v5Z4DPrb6m95wKWf/cTxhwAPgJskQAu/aUhAIB5+22J9aelQa0uOuFFQoRBCY2Soc4PNBDBMQVAGJ50amqVI8kYOH4F3FTZsyU9EvuLMs4q/NBP3SNT1Y2FPQyQcs0RYYT7JxYTZQgiAmoE/Ki/8E80DgO+RQYe8Nvx/v2P3wng9updALgAyEoEYrY/ejS4katyBegG2OfOEqpSX7s4K0QohgVUpSft+5VgR7BFsb/nEkxScByD/s31pB2IIOMSIETRE9YLF0wiOGMtwcUu4EoyyIAe79uyEsDwIhAsBSrrT6sAuyJ0i4KU6p9CAkpl9boBNuHT7iCw9vThJBJfe8erKrt2IZZjoWSIcTkLCTwVt6oC6nojwLKYvuoWIsUf1DsZRljn7m3PAPcMBY/GqIK8YU/IHTYs/+HHKQLYAd+tBCQkMIQA7L0AQAxo8bbjI1MXPiOIqMJNOgIEly4HmvsUIaUA7oQ0tD/LuBsAzTqC7XosUnAy/MwBZADtKTl1fjhB2aT19j9RCHAGOWTGyII/Gyos//HHAgEo5c8kAbv4X6m+lRDEmy73EtViSEA5pcFOIVTSMHIEAgTLVuvVceXVeFWwO3F+ByIW5zuxv1ZRRqL6d2TK64E1Y/9dIiDWfVB3veqPEcEThAARcDNgPKtNdC6Dw/lPP+Z+fxcWAOHbgM2FQKDsQ/wP+7TSo+qzsiAqk1apLmGoVUor4kTpcCCDALzZen1EQpbNp+QEjgNdiZWxN8t4pCKQUXeLOChZOFacEoFxTmzsYRIjEZwQAnjjRwCL7Hu0PxofLnVc1IM7gzxGE96vWgkAHwUWF8AWAuGDQOyhIAQ/KwPu+9t5KmVvJwXtMHSgE9BQfU0g7oMy2g4byb9ZMFtkwUCMhNDtJ2VDDVoNLBoSEBLpQBYB18kPpElkv9HM1XRzwFB85gzw2BaArX4uoRRAFYG7up+RQYYgKm5i+aof/RACiPK39wAAEbB3ArSq3v4Bl//qpcAa8Nt3QhAM7N0FE7DTSWc4goEUAAwm8Ky1CNYCG69syWr/BJBWLkArvWflL1H/iDwE2I6dH0hKJkeyYtCRFYCThSdZYLuEwo6hCGwGlE9FBsNx//OP2gkAwwBJBBoVgK4SsE8KyQWwuJ8RAoIdCQJvpMXqVnlQA3z4TpRdjsHA1IEo6hss7JFzQQDQYwaE0AHAUmMrSWgAmJKomuRH7D8DmOVWGMAjgHb7T8oBeORR2XcFOcyMyfps2776C/ocwPr7df8rkEMC23xS/0uQLgVm3IBOAHYni1ldneHVcSMJKdbJEYYOQU7BDR+M8VMZeQZUY1tHVNYxlQJnQgJNKNbk9tzGAFovx0CWDXurDkPF1+MVcgBZhzDbbgaoVWdQsftNaIHcNwLQIYCQgCh9SwaC2jfgQ/lPg92qAnQnokIB6gCUcrlVAqNsZqqco+xMtTM2/FTwVxyBofAsvGGgNe25UxqskgxV+ETIkCaCAgFEzkLmqdXuqZ1ARBam6gMAl6/5kSoEUPYfwa/fBNSeBQBi2MZW7wRox8skBgnYTUfgKLeA11O4KDk3gJ0pWzI00BOYxuhOeU9fhwXWqdg/Io7MfuJKKNhBfRrAJisAFJgH1wF4oPYAF4HxyP6oLwN6xhls/f7Lj7jf5dHf9hdeBNoRgJH5L4UB+2TSpBDmBADsCG5U9izYq+Sg25uKqqsJhnJ64JdrcC13Mfan14tAdDL76MhM0qmOFdh2fRxGJBZQoycKI7BkQZ5tFx0v2h+BPw30BrhXH7bweCOA/eWf+kUgFvjxKcChGqAAbuYADCLQ4N5O14j9I/DjftcGe1UDpn7Ogh2LhCrHfyzw098Hwews/aVkkMzkD8qd7JciggNJQItUjoC0CuAjxMLOMzz3r/3h4ADgLcDM+ktOwKwC4HJg9ZmV/RoXWaGBUv1TiYABO8ofWLHwRDLPBd8JCn8quLMWPeMkiPozK5/dNpBCkAPIgnwWiLP9QqAqBc8of6rN1/3wh4VA8gRg9AxARwI7iFgJUCcAKwlBFg50lQIdDoCbMC1rpYKQrBygW+kUMcjkR+CsxvHus/sReCPQRvsR0A74rPCBnXtK6ZVTsdzgYwK+ovaVthE5zCi/8MnydZ+vQgC1AIiFARveINHnJQMbNlHlAbDbiTj7NBmUiYCoNqsiDBNUT+YjoHaSh3Lz3BDBcivedkaSjvqa8X2ypBe+QEQBVl9vBHrmCCi4H7EKcJban00GFcJYvv6H9UlA+i4AXAuAZT/1WWf/LdXv8G6VAQkxlMHPMsJFJ3CJylugstTaU2FPdT3wZpQ9UZ4LiYvU/TswJ1xDRsWZ88v0a0oIFjtDNt7YEQCPEEc0dnX/AwGQ2P9oDkDCAvld9XdP9dEV4I3tbpaenMZ3V2lIn0yCSlv0wyTh1Nkz9p6ppxVGoFU2VV/UOqn+6NKiMbtzdQgmcgRv1P/hJlXdw/C7/dcfajsAifeFDESU27MB+wa5jzoUaOB3LD4SA4v9NVF4LgAnd3ehgeozAHugHianEx6wCR+FG2YeA294whVQYtjvWQRUMw9BlDIkG7b6j4VmVrusOp9s/y0ncJX6R+POAD4kiI0A4L8BQ+Uf3gfg2H/2MBBTfdP+C7vAzdaPAFfIwLSERHVoIoqUBjNKm3EDGVIwx8kAOFLuaL86hkkkxcU/jDgrSh8CUhG9B6iMzc+0iUB7xO6H4EWszLqBb/ghJARgTwKytwI7OYAhBHBcQDYckOtlTmFYABIA3XILbCEJ3QaE1ampsRItHTbsF+mqqpUryCzZzYA/QzJJN+ICPLFqLwPCI/F/aXy5N4YjiRT6akB7BGmd2/INP/ghBGjJPwL+1QnIfGf2X8CuQ4GGEZXoO9UFEOdwhAxYDiCtXE79ngKh2t7LFWTAHwAbSTEKEby2kaqznEHUJ6XmCUJJjaPUdFbFK4CvtI2IprJ/+caVAHQSkD0ObL0MxCgJbnNNqb7+XlX+KATYLlwdky4NZVaRxY/ZcMGLZwNHkCaXCPwZ1bbOBZXNyS0wkJruSKmll1w9CsrHdACzZOBdYwWwYj7CcAhcijf+8o0/KHYAkgzs/u4Trqm+/g7gKYUDRNG7F4jKhTlAbz+SbgNjdz+g0S5yA0wFO5AQAnHVzwOoZ/vPAn8yMeclKSMlPwOspm1nhO2oeRZEM+0qgH8q9d/O8ZtWAig4AMGQuRDIWQ48JAUBkO3eRcDWuQSi+pETQOBSdpxQ/kjJI7IYljkrVXaBlajpZxbqeGrOQEDzGqA8OoywfvdqHP5+IICznEKFSDJOYhjvm35g0QEkFwIh2Bm4w3AgcAJ6MrV5R+y9BpcmCFQl+oOz8MByE0qNu/EK4UDkJBihWHF7Bvz4m5jAJct+I8Wn+6+I1a8YE0k4+OwBtaLwlbYZwIfjrQQwrP4jK/82+6+2y8q/IQmolR2SiNvvqFUc3x/A9jOwESfAgB6BnxGJFR6E9tWbhJ499ey9FUbIhDT6ejadAjwKMbSVtkgxY7kvAOuZjwFn1fvq0CACeAhucGPycejzzT9gdABYERheCLqDUQhh+0qeC2iYNcBvWf4wMWgQhE7+CdHoC04TAlFy0zkY6+41udAJkyANar8JKVIHEBFEspYfOZLIxofkmSEOr82B+H9WvWcIoALaStuILNj+bdtKAF4JUKu+uQpQx/5AFKj6NBwQeiLOYCCxKEegCELb++GHcCoCA2taYHXU0IrtXTJhjsd5kKcDpziDBEEgQZkkg+MBWVigiYjA/T3gZofjGI4kC+azwTszXgTaqwlgHX/5ls97tRRYVL2tADRCgUH1yYKgDofE4nc4VqDG/EGbE0ZiziMIF/yGYlCHYJEKKzviJLaOEWTbQ5CQpN9AAhcoP5JWGaBA8lmyKYHZI+FgldwMeLNhgncNlX0RWczufyAAWQqcjP2tCgACV+Z+t0RYAUmIpAOxEdtHTmDbTybBsHaAnIMmiuHmatcBk9m8iexcEgrqVgP2c6cxvFL+LMii2HkYJ5Er8H6TaeL4ANj/CKSPofiIowcH8P23COBGnwHQhOBVALxHg1l4kCED0mbIEVjqTIhk+4GT26dJIXAF0yGBQR4U6MR5ZNsNTkIRS0mVsa8ir+o4LnF4ZKvPYXKV3xWK/1o4gG/9/ioJKC8E9dyAAXaM75sDANDp+N8LA7p3CyjF1Y5B3xxKEsZ6AVo5SIDYZHMvGRUlqqLseLCSbzunpBVGMsy6hTA0icAWXf9sIjC45irZyPzKuJUjIH4KxR8cwLd+v50A1PMAmOzTnwXTYvkld7Bth5uM+9uBo3yAodKR8uP4HUEQ5dFtGYEM25QCDwQQqVAEzAgcQdx/JvipC4jICX50Cpxk/wzoorCkAsrM8WbHM0WCEGXU9qr9y0oAWwiglH8LCYz1/w3wqvznqr5BDhqsUwuEqg5BkUwHdgOI2yGsx02tHIHcaGd/pMQIbArMRF7hCGAwFMqAxWwTEdys+sO9zJzfjBuoKPVVba8lgGISsFsApElivyE45wdXADdNhwUdlkm8nnYCCeWXY+l439tecgvG5OxuZqSMjnPoJnwWYJETYUoenWOkaBP9M2C2yDML8my72fg/Am2FLKKxZvZvfb7t+77KAWxOwEj8NXUHp7DNb3QBCvwSAnSCq0MAQhiitugOcCzcbsX71qrAri9OXEY21nMGHUu9GnG4oQVncMg2Z8FPSDEFNMcVHemf6ssIidw3a6wsyM9oVwXhUQLwznkQMVIKbQRAV/45RKDJoAHcIQMhiwjUQwjQscer3hYh0BWBxhhCNCzej/ZZx9FuIsolHLbMFUWfAXIUviAY2ecKOUVjMTIoXH8EmAwhRSA/Cuoj/c255pHot33uQw6A5QFku5cLQGAjMSDmLCcw4BImixUaCDCZkntuwGtPCcABCx6nHBJkVDg7qSuvwEoAcQDIBPi9MTIAKyt59rcKyGWWHCr9IvJ4kv2NAII8gIC1Wwqs1wUAoi0yEABrx82UP+sGziCFDsgkHLDyBN1N80gjqCLg+CkQJOPqdn4BUOhEniENVJtE/2x8TduRa/IAmT1WBMSzxomO8yj7P/65r1YCotIPn0m8j28BFpVvwGdkoCRf2/gOd1k3MNgImIEEyBZZYEKJugVrHYEoi3EsTSzu5HEIZCCFyuQPnMIl4If7kgVMtt0hUkOCMj5XgVex7VM2XU3IlEAQxyPDdP0//n3GlYAh+FWs370OXBbbqWSfblNxAlbbsuUPyMLLBeA9YLafTZruB8+AO2vps+32650Flqem4b4T1d881oyreWICqJLL1e2XjQDkjUDkmX+d5WffEVeWE0CBNJU/qfq6f0eQBdVv/Qw1tdyCBWzGsDJGqBIZgiCAzjqK0kQ6A1hnjOGBNUEwIUmd5AAqxyndB0PFw7nkOAY9R5ePf+9XSUBGBAJudAVt234Ttn37xi4ESGyTE0rnAIBtBqwfAD/+Zl68r8nGdA3RykEsy2TtfJYkKsfWk+wM4GavJwnA2fj/CDCPgqzSPwoLov1HSOUVAeBKwGgtgJH80+AfbL8OC9A66Od0gFy0UiuCa+Sjt0cKboYQRGmHsR0w4vmGE0GRltk+AapuIlTbG9dcDh8mxpkCauL6wt/eUcojfY8AUiv0Wd+tc3ogAA/8xsKfDuykTVP2/YO1GlCLNnUCiii0Cpu7LUfgjUf2WTG/JgXLORwFtbkE2VLQRNKPTgiHjNKASBw7PZZ2J0Vnc+Q4ugsk6gAAG0BJREFUVVKKQH/muZxKCp/4Xv3DQGLn0fI3sEerAPVTghAaaFyllgcDi1Asq43t6yzwI2IIKgHiOFKWjZyjZ3XZBMuAOJqYbTJVwwuDfIb/l8FR2cy5VX6Ts0HmZdunz90i7eClJZnjZdoMv1EjAMcFbLiYAT+x8TpX0DCeAHPXxAA5XTug7YiW7on9NPYPwgLtEEKiSNjcTg2y4YSehCeBv+xUZid98ne5khCmwHaQDGeOGfVZVgKwqgAiiBH4U2XAfTCco1qxNcAZxiOAm+J/kSvwEoYU4Anl325ath0hr5BYNPDYq9Sr4LzY+reJfBZZVa/vhPYRGGf2Z/p4bZZPfM++CmCFAF4YIETR/upnApw3AqUJAQ4ShQPD/ovA3wjdANDwwxvKZbVjN45uSwI427eqnIywpsbIKOT7iAAy4Ix+p5kxMn2kzSsCCKoA+AiwJoOOAJTtF8vPSAK3NSFLhAJdPwLuTKiwHc8jhsx+1YaGBSRxJdeadQgWETBVTJNG0mVEE3TbXww9yg6lmPzL/gapawNSitpXgIdcF40783tlzmUd94EAEiVAuc8m+HWOoCH61fxAy19R/mplAElHicqrryeD3wM1fVkpm1gBkOgxHEV0gZA4VnpiFlQ5MzHNNoXjpM+9APBozKuI59BvpgAwJgE/B0KA6CWgrP7vZP4bWcBJZJYEI1FYQuzlAtw8gTFg2jXs12I+diz7gQA9tu/2GaRkOQvrfYapiZgNR6znyMn1zQCkpG7GOZfG0PenQAAZIM6cS2bcq9osnxAC0C6AgH14+Ie9EIQQwoY5FRo0HAbbKY5In3Yf2QtHEGVWiGEAVhHow1cHPHgeJnAZqAIll3GrSUdKBkdyBmQF41WTsxv3LMK6mAAe5bdwSKt6/AcCMEIAmevrbz88A7Dv1CofVQQ66w9ftAJrMdSuAHD46ucIiEGDeRDcKCwgB43KgZYa47l4biIav0QyybjfOufhWGcRiQHK7nivKQFUATcQ+Ylgnhl7+cT3sEOARgDO038dATjZ/w74AKTM9q05AScjBY8YEHRVy4/Kr4mEKZXbRnaSa/IAvR3HISk3CZkkr3AMOPeM3c2SiTtWAfyzgDyz3+xYZ/6e6XPoCMBZ9tuAboB8cALKIbT5x54H2CeVBrkGOHUFHjFQNlBJ6wnVZ+AWgogA3Fg6cVymuJ1zME/kYQdT0CwgXTUpEFdmUodtCgQQjrVf2NXtMuNn2lTu18x4rxyACgO8sp+n+ts+A+Rs+a+0Z1jFfXS/ASLLGQxjJEAYlgpn1FwdN0UazloDD6wR4aQVH4GTPP+ZCUkn/MmhxtWgsu7H7O9x5fkun/hsFQKw5B+AGsGfjfc9UrDIYjukmmjatlv4taoAFduvyccFWYJIvOSdFvIo7s8Avps0ScBaE606VoVUdFvL9byO4Inc2PvhnEcC2CfL+mf7p+P//ar1dgTsEA7AmJ1gFrZ36k36tXEjV8CshFwT3tEsqBPt2rDQNqX68GNl2kfEUQGmpcQR+VSOkQJIQf2vUMorxkxdd1R+hbl6aLzmAMhCnuEZAKPmrxW+EYAFcGtpsLM9dATgUrSiMvLQbSruYArQCaKIAJxyCjgxnGN6hGLuyy55npicFuEcJZSjAD7aPwvOK46TGfPBAej4nz3959T8B8VXYMR5aK4HIACOLD8DLZvzlp2nZiAB1G1+J9pVbD8jrdR6Awts5PymQL+Pf6j6EBCCNVHN/7iV/lgq6XkWCcn1k2NmwX2UxLLHyQBeLkPGXD7x3cccQGbdP1P9UPmt5CAAqiMLOVvD8re2XkjggHXASALUWfAzl4BzKLT0wblk+kdt0vuNc6lMbBPkhtU9tMpRgfUogGaApfmi8lsdPd9S/44ASLyPQEelZwlATQqIPU/56ctB1MtEGI61slP1NybvU4LfELBXmxMZfzZGxnGkQY8HgB9rxkVM9XkK0imqfYUYqgRYAnHBEelxXzkAJwcg4EOFz9p+5hSasBPlZuGCMgIPIkwmiN50RjWg+22zDsFxHRnwR21cEKtzjADvTUx0OzMgjsY2VbEI/iq4ps+L3JiKslfPszJ2pS2exwMBZHMA+8Re709HAGxxELTtnACgWZNIa5ew/APY9c0xngno+qlBXHxfDP7tBlaOwSZjsn+GFLZJciAMOUQYRQI4dKxHBvWVJDAz9vKJz4rXAYjidiHA/sPRtQDWE4LGOwIt1e+2KxvgEsD7DPyotNPqXwQNO84ApIkxI3IJwXryMcPjnUAAVeCd1f6MaxsJgNX9WXjgKbzlCIwyX7vn3jJhpZCUAGBjRBCKTzjukoraOlfbp04iooTk04mFic4I6QiwvQkvp+XlL44cewYkZwF0uDZ1D2Ztu76VR8ZZPv5ZDxpOwwDr+X9P4ZV9b66B2HodRmgXnHEGrc8Tgz98B4GF4wJp0Bud7B+BqDu9fcxMn6hNaT+5llL/IsnNkMNMn9eZUDYC0M/5I2jXzxqowzaw9l1bZzsCl1p9I1zQJCHkhffeVH+HJBgA9HwysZYE4TA/Z/sZziECi+clPAXOKg62y5xLFHJMjZFU2ciVnA30GRJ4jD7Lxz/zVQ5AwFVa/rt3osAv5gIQ3A+25OFuenbefV6AlBLZeBb4U/hMNSLQC8gonPyzx7Xq7gapyObwfKJx4SfIOJmzjveYQM78VlW7PktU2eseCSCI9wegW5Y/SQwakDpksPYLM1juofVTQHFxE71NKGkJQmyGDTyt9qsFGeCYo8N5ZcfJtnMnsvo9smNm2mWBUHU50bFnjvvYY67H6wiAvvLLyQPgk3xWqKCFRZSdAbdti5KBilws8YrcAd70cgxfJYtAYQPI97uPEog62DbxCmNGE7UKJjx2duwz2kVjXLl/hiAihzEz5isCCFYByhzRCj0A37H92xjE1neuwtmP/V1nQBYKWfMbQ40MCKvtD5EMO6ErgBqMGQGBnWa6z37sdPujoUYUipy4f9a+R0A/c9zl277bXgXYRQABjsDUIK0Anym7DiW0m2CCaS0ZHsggafuzYO6GSwCQNkn0CwnojDESYUwFjDjcTL9osVHZTTwigCMgvu77txCAEkCy7s9IAcHI3IIGNoJwIAV0ppmwYD+4xgn9HoCpAuIQl0aDsF9nH0J6KDWo2v5DKk86zxy/QjCZtq9Tm+hcrtq/EUCn9M4LQIYwYL+x5mpABUgK8H0jgmH47IC/U38Sl1fBnwV+GryzuYILwd+GTl5ENPmyzNONkzx2xg7PklP2ujLtHqtNdJxov3YljQBEibW1t7Y34CVW/Wngt3vv9MXxB4sPd5w5CBY+6PESTvihCUzU7JzF68uCwzrnSnKudCx1MZmJUxo/itWTP+bMeWX7PEW7s46ZGSdq00IA+uYfou4DkEG9vX2W7Weqz8gBccjcAQNPRfnNuUjcCQPB6a7BZIMqBI32SfBVjhZNtm6sxPFL48HglX5XtM2OeWa7zFhWm+VbP6NPAgrYXOX3VH8fwFT9qEqg+rvq76izRxQZfEVlQXcOJ4nDBdgZY6TZKoZ6ZpLFo4iq8JZHj1Htf1X7K8bNjDnTZiCAyPLPxvs4LnUEiaW/HaifCPyReEXEkSGfM22/nO82OaKTTyP4QMOLQo/M5NdnfXWf6viZ9pk263Vm2m0hwOoAUK3NxUCBsrvEkFH9YI1AN3+zFYHki0M6UBog8bCDYcth0SUHOgW3pwxyAPiJ9wvMjp6Z7Gzsx+pXPU62/RntGgFYyt/IQVnS9au3DwHL6vc6RIjWASDIBntvOMvsSkAPwBZuuu0HQBuNUwUFPd+LwZ+diFc4kPSxyQ/52H2rx6u0z7bV7ZZvkRyAEddr694BP3IFmXyAE/NHlt8iAv2fjXju1wJ/Cvhq4AzOzDZO58y4mXxClUxObX/4IvqzyU547xqOjnGkf7VvpX2p7bd8eCIJKIpLXAFTfq322jl0feCOee00qC2HYIHfUt408GFgb26n5v0JawVmiOVUgHuDpX6E+GwqEzseLRcnXz3OzDVV+3jtl5UAEKAIOhO40WO+mZifOA5KBEG7DuCJhUADIcDkZPPUJIQDil21/dP4KXYsNs9g46HNgYGrkz1/UucRwHrMo+c527/abwwBdgLoSIAou1bjSNU98jD/81Ct/t7/IyAuRPocAH9F9be2pEM0x+l+tTEag03u11H55Zy2yTZzURUUH2xbBVDmcEfGfOy+yzfrEMBaCrzfTAbsiBwyYcGg/oSEAOu9sKi2oe2fUP3WJQnacN4XbH84lp6VB9xJZoKn25RPPD3yaQ2PAC5zEkfHP9I/03cjAAbgAegHFv9YBMEsPyqsPgcNbNaWgb+bh4QsNLHgjWV9Q4IxZoZFIubxghmWcRWZSVrgj/xwb8Df/VYZMEY/7hVjPBAAgIIqvKHGkfJ3Y0UEsl99+L4AaQcoxLmm593Z4Gfz2pvrw76kg5giBXIiV+EwHDdsEE336/efAaiZszzzuEfHWr7508k7ARXIEMjMGZhKnnkpKGnDxhu2ESWfAX8K0Jn/ZwBmgjn3E7Y/i5uIWDITM3uszFgdYV01cPVEgvZHwXP0dK46fmXc5Zs+nZcBN8BFqn10v7H8V5NMZ7kTVYHBoicBTMkgqaqhC3AaRHiJ9m8TccJZeBM4dUw2wIHrjABVmdjkJ2nDV8eJzuus/VeelzX2RgCDwnuLghxV74CbedQ3Uy5MvBQkUn53P7odreIJUFnzvdueGKdq+b3xLwF2NqE/zRxnweiDNc6VpLD+Uo0AGnjBWg92f6dVur2yNFhA59h4nEfb5+T6fw2MCPxU9ZV8mG3UXKNzn1yjnqIRZtz9RXIpinaIplkiCgd+08D9Bc4ihuUbMQRQkzXrDBAv4UNBcllR+IDK/Ejgb5MZZnVEIJ7V9J4M9EAdEUI7ZqZhVrkzZJawFslTegPvR/gFMiSxEYBW2PX7oPIROWTe+JsIHzoygS/6fDTwjiq/Bv8s8BmJAOfR2x6BxnMW1dDBIyxrTkbnt/VzGqX6PwIgjhxCX0MGXEeO9xh912t4IIAo5nfAj2o0kAaqeDLb341hHNcDf/QEoAvsI8lCA4nW5D/iAE5558ABxR/O/SDCD3a/DCuZ83q/E8HyDZ/mVAF2pCEoKcizdj5DJEIaVfAnlgJXwT/lApxS3wzoM2DLTNSK8mfHE+UvtS/A9apxM6fwlMeW81vJ5WrnsREAA/W2LQHsVMyfGKez/gr8Q1ignEXm8V8PzFXXYIHJUmY2mWbIwPq/EvWEzkzeTJuQNMgg2XEzIJwJb6rjHgp7zjrYI43D3MryX8EBWHZ+VvUtEmGAbseAGUSPWwT/2apvglntOAv0bRwDWRnAXdYmM/BkEvKpgZm8tEeC7nWH6QhgRvVdkColt9rKcT1ioC4gsP0V8LttjUnMwFkBvjXJhu2EFGcBEk3saL8cN5uHmD3PaMpnzzMax9v/GMc4cn5n9N0IANXXBWnmPQCi0Enwb8AO2mbAXwFw1fJXiKQBxLg7FYJAR8aGiyboZfvVwNFxMhN1ZoyZPplzie5hZYzXve3y9RICEBAOZJAEdQnQxpiuG3DWBWA//RnJhu5TdyskFTIDKwBPtU2qfwQGb3/Ut/utEo0TTUxczPSd6ZMF5pVjZ88hanfkHDcCiAC7HSAqFQJthi4icAlU8YMyImPtAcAOmLBtCHzCHikwR6GEvtMnVxQY6ZFD2vMt8TDTjFN5yj5Xgisa29t/BNSV4y5f/6nj04ADABNZfI8kqJor5XcVPwF+D7RybimSgF/PHDNQ5YhAPCC2vkl3EYF6VvlpP7VxZpJW+lTasntbAYLVduYcKse9evzoXJav+9RX6wBkMnUKfgH4U+VFDcTkcmANCAR/SBIF8M+CPOUUCDnijZwB9UyfDlSJmZpo0s3HTPtMm7McRMkNRcgK9s9e18HDDt03AugArx7qMfftQ0XKP+MmvD4U4HguhDi8PpV9mfUGTJFToJdrMGaGNWHO2u46iYCQjgAwC4RsuyxRZoA0c8xo3CvGjI7p3dvla4kD2Dqom06JIOsOEs8A4A9jOZCzwV9yBKpxBtSZNt01JY5h3cwzicA7p84VZGZech1AFhjZdjPneYTIop+iet7ReGed60YAFuBc9T8R/IPiF2N+Rh6RWtM+xEmIw/EmlEckacA6KnsGuL0JaO5LJv2ykztqF+2fBXV23LNApcc5cnyPCM4Yd/kv6ACyoM62q7wSTD+BaDiQlAuYLBNSIBeAGRGBSQbkTlZAf0bb4dySbqQ62TOTNtPGDVkIarJjnkkCR45Z/V1nHMPa5xUBwEQ/TfnhF3DHJC8TYa7gKPhLqg8Hi4Bd3W9ZbDZhzgB3ZYx2bs7szUzsqM3R/Y/pBqJzPZM0HgP4eD0bAaTi/WxeoBDvD6SQIAzG/K1bslJgEUF3o48+XUhi32EiFev8WYKYAjzOPBCDSFkicHj7o75Zlc+MQy4vurS2vzp+9ryvtveZ81i+5lPGMiBT3zRJ7J3Tig9UHvVxHYC6SxmQm22csVwC2q8lcgTbGGRWHQF4tq83KbYxjNkegWAW6NG4mUk84wYyx50Zt3K+FgFUzu2o+9gIIALeVeBHuxmdQxb8VeAP48IAEZCn9zvHsCZQFuDZdvQ4CeWPJudTE0F0fjNOoDLmEQKoHmfmWjRhLF8dOQA1KVygFpKDrwP4B7IwgDkNdOYIDJBlgXt2O7wPenJEE3IG7DN9qhM9Ou8rx5slgMo5zzoT5hY2AjBBfTL48cfZhs6+OhzOvANtArBpR5AA5mEiIHc5GjPrCLLEcIXyW5O3uj07sTNgybTJgjU7Vna8KtEebe/1X/6z5QAmwT+AnL1g9CD4hTzcsMAiDba9mPCLQEv3G2RlTfoMoDNtvEnZ+quBZlR6Buwzx7lCvTMAz7SZIYDsuFlyZCrvnddGAIMDCMDfgbxCFIkKgUcg2q6m1X3/VWj7yTUD7Ec1iSHhLrJEcAT0dLIVKxHRRKwSQQSAq/dH15PdX2030z76LRj4oz7LV2kHQJRqIAgB1GOD31DRChF0bR3lM8GcKO91fYvuwmJr73y8yeQSRlL5zwL1rOJHk/jo/oxyR8e4GtDZ41fPoyeAQhKvVBk4Q/kD8FdIYLvhCTLxQozIAWzDBwCLQB3tj87BnQwTyl8hgkrbzKSNAHD1/gxJZNtkrhfVPLo2rfyV9hsBlMH8RMpfBjn8MpbyZ8asEEEbT/1GFZWOgB/tD13EBcpfBfwVbiCa+FfvrwA7OpfKWLNksZ7D8p8+lFwI9AS2H1U0A1Rp47YlwLTaTwF/7xSB9Oj+I+pfeX15SCYGyWYm5etGAhlQPmabqxwFjrsRgAaO+f0k5ccTcI+dBGuaHJLjReByCSNQ16PAj/qHgIUBKqrN2h7tH6ncFQQRgSoCeLQ/Gj+65gxxasufPSZrt/zHrAN4jcCfBjyG4RPPCZQdgAOuCLgeqUSEFIIeZt0VQD46pjeBryCBCMRX788CNjqPCplYx9wIIHQAB8GfVvwT3gNAgTQBflflme0l7qJCIDMgzwCvtQmcSZpECi82rTiECBTVsWbHi/pl9kdtzgT20bGW/xA5gNcc/K4bOAh8D8DdD3/kPygplhVLoL9Q+TPnESlUFdTV9rPOIgLw0f1HQRv9rjpE8I63EYDpAF5D8LuAP2j5o7GpSkMn/UNXvlfaZtxCa3Oh8lcAWWk7C9yzjpEFmAes2X3ZY2dIKNNm+feWA3hC8FeASNuS9QxZNbeOTfur38i6edkxI2BnVFc7kyPWPnO8yvhntI0m9WOSwBGQRy7g6P4skWwEMDiASfDjzTFdxX5m3f4CYCNyyCzwicZIkQUBv6fiFYWvtDVB9cjKnyWLqrqfBehZsM4CcbZfFrjR+BFRynGWf6cdwCT4GahSJBCAPwJrtx++6GOnQK3icVO5T3p+oAL0qG13fYScvImVAW/p+CoIzYxfPb8qkUSAuIIgZseMzjWzP9NmPb+NABpYXgPwlwAPE02vZjwT8BHJsMn7ZG6AzLoMAM9qU7H5Z6j7GWNkVLd6nCwAFVe2r5HCn7V/+crVAVSeAUALbyjhrPJ7LsIC9NaHKN4lDsBQVtMpOI7CIyg2ebxjzKr/DOgzfSok8NhtI2CeCfQjID3SN7pG3L985cvEOgAE/ZFXfSceCio7AMO1uIShriflFhySqQL2DMKgx0yofwbAnnupALYCpsx5PUaY8H4ILSoAjxzG8hUvi88C7Ee3VB5PjrZJuA02BgVp4EBSwM7E/cn1BBVV90A2tQ86RQCOCCuz/ygRZAF/lETOBLSnypXz9Igssy8igIp7WP7tTgAhcCfVuyOBE8DfLq4A/shVuERhAGsKpBeFBNH/gmRNqogoov2PRQJHj/MYJDBDDkeAPHs8fcxGAJaiVwHMwLZtS4Df7Kst+8HKgQX44fj7hizYz24XKbH8rmjzItAe3R+dU9WmZ53AB5UEZoE8228ggH+TdQAFADMgpQhGAZ0SAlHkSOGj/VZ4MRNCZPvMtuv6JQgqA9gqKWTBmAV3tl32uGcpvgWy6vZZpT8L5CgQlAA85a2qtwZ6RflDB5AEfwT4aL+21Fb7LIhn+kfAzfzHIhVgR22j8zmq/BVQZc61SgKV41fH9n6bWXI4q9/y5SoJiAMfBb9Xm7ccwXB8cQVE7QayIW8groI0s5KwOmYEHm9Cm/suUP+MEp/V5oiaV8B6VdsZEphR9Jk+FXLYCMAE0oTtb2OpCZoBq+kAjLFMsgDP4x33TOsfugohMnJuEUEM56lmRaSIV+/PnP8RwGfHrxzjyrZnksPlBPBlRhlwxrpnwW8CnWXJC0RymBCS5b4zwV5Wf+hwBNhH+lqW9rHdwVF1P9r/dQZ6ljiWlQC0SjIbPLRRilYFv0cC7Yc9WOrLAFWf94y9n+ljnZurdie8YnzquMS9PAUJHAVshqCs63oMsFeuzzvPaB8eZ/lS7QCU4jJVNckgUGurH1XuiVJfilSYFTdUtUIgR0nA67/tU7OjouBll2GEKVnQZ4EWXUPFps8es3KM15EEskoPt3T7KP02AojUO0UCk+CnoCWAzII7Au2w3yG8o6COzoUBioKCnKPrFBjJqRlQcQLVY2WJIjNuBaCvIwlUVX0G0NVjdATwMXEAAYBdEnhC8Ecgc/efGPNH5xFNdhOQRdt/ptpHCh3tj675CFE8JTFUjv2UriFz7GUlgOp/DNKRwUHwdxPfUeMjDoCCq5BfOOoEZvpr2x+BLavolXEyAM6obnTMzHEqoMuc09HxKv2rbTPAVYZO/ydUbXfkKP4/BnecprBuissAAAAASUVORK5CYII=",e}(),nn="uniform vec3 vReflectionColor;\nuniform vec4 vAlbedoColor;\n\nuniform vec4 vLightingIntensity;\nuniform vec4 vReflectivityColor;\nuniform vec3 vEmissiveColor;\n\n#ifdef ALBEDO\nuniform vec2 vAlbedoInfos;\n#endif\n#ifdef AMBIENT\nuniform vec4 vAmbientInfos;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;\nuniform vec2 vTangentSpaceParams;\n#endif\n#ifdef OPACITY\nuniform vec2 vOpacityInfos;\n#endif\n#ifdef EMISSIVE\nuniform vec2 vEmissiveInfos;\n#endif\n#ifdef LIGHTMAP\nuniform vec2 vLightmapInfos;\n#endif\n#ifdef REFLECTIVITY\nuniform vec3 vReflectivityInfos;\n#endif\n#ifdef MICROSURFACEMAP\nuniform vec2 vMicroSurfaceSamplerInfos;\n#endif\n\n#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(REFRACTION)\nuniform mat4 view;\n#endif\n\n#ifdef REFRACTION\nuniform vec4 vRefractionInfos;\nuniform mat4 refractionMatrix;\nuniform vec3 vRefractionMicrosurfaceInfos;\n#endif\n\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\nuniform mat4 reflectionMatrix;\nuniform vec3 vReflectionMicrosurfaceInfos;\n#if defined(USE_LOCAL_REFLECTIONMAP_CUBIC) && defined(REFLECTIONMAP_CUBIC)\nuniform vec3 vReflectionPosition;\nuniform vec3 vReflectionSize;\n#endif\n#endif";St.a.IncludesShadersStore.pbrFragmentDeclaration=nn;var on="layout(std140,column_major) uniform;\nuniform Material\n{\nuniform vec2 vAlbedoInfos;\nuniform vec4 vAmbientInfos;\nuniform vec2 vOpacityInfos;\nuniform vec2 vEmissiveInfos;\nuniform vec2 vLightmapInfos;\nuniform vec3 vReflectivityInfos;\nuniform vec2 vMicroSurfaceSamplerInfos;\nuniform vec4 vRefractionInfos;\nuniform vec2 vReflectionInfos;\nuniform vec3 vReflectionPosition;\nuniform vec3 vReflectionSize;\nuniform vec3 vBumpInfos;\nuniform mat4 albedoMatrix;\nuniform mat4 ambientMatrix;\nuniform mat4 opacityMatrix;\nuniform mat4 emissiveMatrix;\nuniform mat4 lightmapMatrix;\nuniform mat4 reflectivityMatrix;\nuniform mat4 microSurfaceSamplerMatrix;\nuniform mat4 bumpMatrix;\nuniform vec2 vTangentSpaceParams;\nuniform mat4 refractionMatrix;\nuniform mat4 reflectionMatrix;\nuniform vec3 vReflectionColor;\nuniform vec4 vAlbedoColor;\nuniform vec4 vLightingIntensity;\nuniform vec3 vRefractionMicrosurfaceInfos;\nuniform vec3 vReflectionMicrosurfaceInfos;\nuniform vec4 vReflectivityColor;\nuniform vec3 vEmissiveColor;\nuniform float pointSize;\n};\nuniform Scene {\nmat4 viewProjection;\nmat4 view;\n};";St.a.IncludesShadersStore.pbrUboDeclaration=on;var sn="\n#define RECIPROCAL_PI2 0.15915494\n#define FRESNEL_MAXIMUM_ON_ROUGH 0.25\n\nconst float kRougnhessToAlphaScale=0.1;\nconst float kRougnhessToAlphaOffset=0.29248125;\nfloat convertRoughnessToAverageSlope(float roughness)\n{\n\nconst float kMinimumVariance=0.0005;\nfloat alphaG=square(roughness)+kMinimumVariance;\nreturn alphaG;\n}\n\nfloat smithVisibilityG1_TrowbridgeReitzGGX(float dot,float alphaG)\n{\nfloat tanSquared=(1.0-dot*dot)/(dot*dot);\nreturn 2.0/(1.0+sqrt(1.0+alphaG*alphaG*tanSquared));\n}\nfloat smithVisibilityG_TrowbridgeReitzGGX_Walter(float NdotL,float NdotV,float alphaG)\n{\nreturn smithVisibilityG1_TrowbridgeReitzGGX(NdotL,alphaG)*smithVisibilityG1_TrowbridgeReitzGGX(NdotV,alphaG);\n}\n\n\nfloat normalDistributionFunction_TrowbridgeReitzGGX(float NdotH,float alphaG)\n{\n\n\n\nfloat a2=square(alphaG);\nfloat d=NdotH*NdotH*(a2-1.0)+1.0;\nreturn a2/(PI*d*d);\n}\nvec3 fresnelSchlickGGX(float VdotH,vec3 reflectance0,vec3 reflectance90)\n{\nreturn reflectance0+(reflectance90-reflectance0)*pow(clamp(1.0-VdotH,0.,1.),5.0);\n}\nvec3 fresnelSchlickEnvironmentGGX(float VdotN,vec3 reflectance0,vec3 reflectance90,float smoothness)\n{\n\nfloat weight=mix(FRESNEL_MAXIMUM_ON_ROUGH,1.0,smoothness);\nreturn reflectance0+weight*(reflectance90-reflectance0)*pow(clamp(1.0-VdotN,0.,1.),5.0);\n}\n\nvec3 computeSpecularTerm(float NdotH,float NdotL,float NdotV,float VdotH,float roughness,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor)\n{\nroughness=max(roughness,geometricRoughnessFactor);\nfloat alphaG=convertRoughnessToAverageSlope(roughness);\nfloat distribution=normalDistributionFunction_TrowbridgeReitzGGX(NdotH,alphaG);\nfloat visibility=smithVisibilityG_TrowbridgeReitzGGX_Walter(NdotL,NdotV,alphaG);\nvisibility/=(4.0*NdotL*NdotV);\nfloat specTerm=max(0.,visibility*distribution)*NdotL;\nvec3 fresnel=fresnelSchlickGGX(VdotH,reflectance0,reflectance90);\nreturn fresnel*specTerm;\n}\nfloat computeDiffuseTerm(float NdotL,float NdotV,float VdotH,float roughness)\n{\n\n\nfloat diffuseFresnelNV=pow(clamp(1.0-NdotL,0.000001,1.),5.0);\nfloat diffuseFresnelNL=pow(clamp(1.0-NdotV,0.000001,1.),5.0);\nfloat diffuseFresnel90=0.5+2.0*VdotH*VdotH*roughness;\nfloat fresnel =\n(1.0+(diffuseFresnel90-1.0)*diffuseFresnelNL) *\n(1.0+(diffuseFresnel90-1.0)*diffuseFresnelNV);\nreturn fresnel*NdotL/PI;\n}\nfloat adjustRoughnessFromLightProperties(float roughness,float lightRadius,float lightDistance)\n{\n#if defined(USEPHYSICALLIGHTFALLOFF) || defined(USEGLTFLIGHTFALLOFF)\n\nfloat lightRoughness=lightRadius/lightDistance;\n\nfloat totalRoughness=clamp(lightRoughness+roughness,0.,1.);\nreturn totalRoughness;\n#else\nreturn roughness;\n#endif\n}\nfloat computeDefaultMicroSurface(float microSurface,vec3 reflectivityColor)\n{\nconst float kReflectivityNoAlphaWorkflow_SmoothnessMax=0.95;\nfloat reflectivityLuminance=getLuminance(reflectivityColor);\nfloat reflectivityLuma=sqrt(reflectivityLuminance);\nmicroSurface=reflectivityLuma*kReflectivityNoAlphaWorkflow_SmoothnessMax;\nreturn microSurface;\n}\n\n\nfloat fresnelGrazingReflectance(float reflectance0) {\nfloat reflectance90=clamp(reflectance0*25.0,0.0,1.0);\nreturn reflectance90;\n}\n\n\n#define UNPACK_LOD(x) (1.0-x)*255.0\nfloat getLodFromAlphaG(float cubeMapDimensionPixels,float alphaG,float NdotV) {\nfloat microsurfaceAverageSlope=alphaG;\n\n\n\n\n\n\nmicrosurfaceAverageSlope*=sqrt(abs(NdotV));\nfloat microsurfaceAverageSlopeTexels=microsurfaceAverageSlope*cubeMapDimensionPixels;\nfloat lod=log2(microsurfaceAverageSlopeTexels);\nreturn lod;\n}\nfloat environmentRadianceOcclusion(float ambientOcclusion,float NdotVUnclamped) {\n\n\nfloat temp=NdotVUnclamped+ambientOcclusion;\nreturn clamp(square(temp)-1.0+ambientOcclusion,0.0,1.0);\n}\nfloat environmentHorizonOcclusion(vec3 view,vec3 normal) {\n\nvec3 reflection=reflect(view,normal);\nfloat temp=clamp( 1.0+1.1*dot(reflection,normal),0.0,1.0);\nreturn square(temp);\n}";St.a.IncludesShadersStore.pbrFunctions=sn;var an="#ifdef USESPHERICALFROMREFLECTIONMAP\nuniform vec3 vSphericalX;\nuniform vec3 vSphericalY;\nuniform vec3 vSphericalZ;\nuniform vec3 vSphericalXX_ZZ;\nuniform vec3 vSphericalYY_ZZ;\nuniform vec3 vSphericalZZ;\nuniform vec3 vSphericalXY;\nuniform vec3 vSphericalYZ;\nuniform vec3 vSphericalZX;\nvec3 quaternionVectorRotation_ScaledSqrtTwo(vec4 Q,vec3 V){\nvec3 T=cross(Q.xyz,V);\nT+=Q.www*V;\nreturn cross(Q.xyz,T)+V;\n}\nvec3 environmentIrradianceJones(vec3 normal)\n{\n\n\n\n\n\n\n\n\n\nfloat Nx=normal.x;\nfloat Ny=normal.y;\nfloat Nz=normal.z;\nvec3 C1=vSphericalZZ.rgb;\nvec3 Cx=vSphericalX.rgb;\nvec3 Cy=vSphericalY.rgb;\nvec3 Cz=vSphericalZ.rgb;\nvec3 Cxx_zz=vSphericalXX_ZZ.rgb;\nvec3 Cyy_zz=vSphericalYY_ZZ.rgb;\nvec3 Cxy=vSphericalXY.rgb;\nvec3 Cyz=vSphericalYZ.rgb;\nvec3 Czx=vSphericalZX.rgb;\nvec3 a1=Cyy_zz*Ny+Cy;\nvec3 a2=Cyz*Nz+a1;\nvec3 b1=Czx*Nz+Cx;\nvec3 b2=Cxy*Ny+b1;\nvec3 b3=Cxx_zz*Nx+b2;\nvec3 t1=Cz*Nz+C1;\nvec3 t2=a2*Ny+t1;\nvec3 t3=b3*Nx+t2;\nreturn t3;\n}\n#endif";St.a.IncludesShadersStore.harmonicsFunctions=an;var cn="\nstruct lightingInfo\n{\nvec3 diffuse;\n#ifdef SPECULARTERM\nvec3 specular;\n#endif\n};\nstruct pointLightingInfo\n{\nvec3 lightOffset;\nfloat lightDistanceSquared;\nfloat attenuation;\n};\nstruct spotLightingInfo\n{\nvec3 lightOffset;\nfloat lightDistanceSquared;\nvec3 directionToLightCenterW;\nfloat attenuation;\n};\nfloat computeDistanceLightFalloff_Standard(vec3 lightOffset,float range)\n{\nreturn max(0.,1.0-length(lightOffset)/range);\n}\nfloat computeDistanceLightFalloff_Physical(float lightDistanceSquared)\n{\nreturn 1.0/((lightDistanceSquared+0.001));\n}\nfloat computeDistanceLightFalloff_GLTF(float lightDistanceSquared,float inverseSquaredRange)\n{\nconst float minDistanceSquared=0.01*0.01;\nfloat lightDistanceFalloff=1.0/(max(lightDistanceSquared,minDistanceSquared));\nfloat factor=lightDistanceSquared*inverseSquaredRange;\nfloat attenuation=clamp(1.0-factor*factor,0.,1.);\nattenuation*=attenuation;\n\nlightDistanceFalloff*=attenuation;\nreturn lightDistanceFalloff;\n}\nfloat computeDistanceLightFalloff(vec3 lightOffset,float lightDistanceSquared,float range,float inverseSquaredRange)\n{\n#ifdef USEPHYSICALLIGHTFALLOFF\nreturn computeDistanceLightFalloff_Physical(lightDistanceSquared);\n#elif defined(USEGLTFLIGHTFALLOFF)\nreturn computeDistanceLightFalloff_GLTF(lightDistanceSquared,inverseSquaredRange);\n#else\nreturn computeDistanceLightFalloff_Standard(lightOffset,range);\n#endif\n}\nfloat computeDirectionalLightFalloff_Standard(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle,float exponent)\n{\nfloat falloff=0.0;\nfloat cosAngle=max(0.000000000000001,dot(-lightDirection,directionToLightCenterW));\nif (cosAngle>=cosHalfAngle)\n{\nfalloff=max(0.,pow(cosAngle,exponent));\n}\nreturn falloff;\n}\nfloat computeDirectionalLightFalloff_Physical(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle)\n{\nconst float kMinusLog2ConeAngleIntensityRatio=6.64385618977;\n\n\n\n\n\nfloat concentrationKappa=kMinusLog2ConeAngleIntensityRatio/(1.0-cosHalfAngle);\n\n\nvec4 lightDirectionSpreadSG=vec4(-lightDirection*concentrationKappa,-concentrationKappa);\nfloat falloff=exp2(dot(vec4(directionToLightCenterW,1.0),lightDirectionSpreadSG));\nreturn falloff;\n}\nfloat computeDirectionalLightFalloff_GLTF(vec3 lightDirection,vec3 directionToLightCenterW,float lightAngleScale,float lightAngleOffset)\n{\n\n\n\nfloat cd=dot(-lightDirection,directionToLightCenterW);\nfloat falloff=clamp(cd*lightAngleScale+lightAngleOffset,0.,1.);\n\nfalloff*=falloff;\nreturn falloff;\n}\nfloat computeDirectionalLightFalloff(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle,float exponent,float lightAngleScale,float lightAngleOffset)\n{\n#ifdef USEPHYSICALLIGHTFALLOFF\nreturn computeDirectionalLightFalloff_Physical(lightDirection,directionToLightCenterW,cosHalfAngle);\n#elif defined(USEGLTFLIGHTFALLOFF)\nreturn computeDirectionalLightFalloff_GLTF(lightDirection,directionToLightCenterW,lightAngleScale,lightAngleOffset);\n#else\nreturn computeDirectionalLightFalloff_Standard(lightDirection,directionToLightCenterW,cosHalfAngle,exponent);\n#endif\n}\npointLightingInfo computePointLightingInfo(vec4 lightData) {\npointLightingInfo result;\nresult.lightOffset=lightData.xyz-vPositionW;\nresult.lightDistanceSquared=dot(result.lightOffset,result.lightOffset);\nreturn result;\n}\nspotLightingInfo computeSpotLightingInfo(vec4 lightData) {\nspotLightingInfo result;\nresult.lightOffset=lightData.xyz-vPositionW;\nresult.directionToLightCenterW=normalize(result.lightOffset);\nresult.lightDistanceSquared=dot(result.lightOffset,result.lightOffset);\nreturn result;\n}\nlightingInfo computePointLighting(pointLightingInfo info,vec3 viewDirectionW,vec3 vNormal,vec3 diffuseColor,float lightRadius,float roughness,float NdotV,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,out float NdotL) {\nlightingInfo result;\nfloat lightDistance=sqrt(info.lightDistanceSquared);\nvec3 lightDirection=normalize(info.lightOffset);\n\nroughness=adjustRoughnessFromLightProperties(roughness,lightRadius,lightDistance);\n\nvec3 H=normalize(viewDirectionW+lightDirection);\nNdotL=clamp(dot(vNormal,lightDirection),0.00000000001,1.0);\nfloat VdotH=clamp(dot(viewDirectionW,H),0.0,1.0);\nfloat diffuseTerm=computeDiffuseTerm(NdotL,NdotV,VdotH,roughness);\nresult.diffuse=diffuseTerm*diffuseColor*info.attenuation;\n#ifdef SPECULARTERM\n\nfloat NdotH=clamp(dot(vNormal,H),0.000000000001,1.0);\nvec3 specTerm=computeSpecularTerm(NdotH,NdotL,NdotV,VdotH,roughness,reflectance0,reflectance90,geometricRoughnessFactor);\nresult.specular=specTerm*diffuseColor*info.attenuation;\n#endif\nreturn result;\n}\nlightingInfo computeSpotLighting(spotLightingInfo info,vec3 viewDirectionW,vec3 vNormal,vec4 lightDirection,vec3 diffuseColor,float lightRadius,float roughness,float NdotV,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,out float NdotL) {\nlightingInfo result;\n\nfloat lightDistance=sqrt(info.lightDistanceSquared);\nroughness=adjustRoughnessFromLightProperties(roughness,lightRadius,lightDistance);\n\nvec3 H=normalize(viewDirectionW+info.directionToLightCenterW);\nNdotL=clamp(dot(vNormal,info.directionToLightCenterW),0.000000000001,1.0);\nfloat VdotH=clamp(dot(viewDirectionW,H),0.0,1.0);\nfloat diffuseTerm=computeDiffuseTerm(NdotL,NdotV,VdotH,roughness);\nresult.diffuse=diffuseTerm*diffuseColor*info.attenuation;\n#ifdef SPECULARTERM\n\nfloat NdotH=clamp(dot(vNormal,H),0.000000000001,1.0);\nvec3 specTerm=computeSpecularTerm(NdotH,NdotL,NdotV,VdotH,roughness,reflectance0,reflectance90,geometricRoughnessFactor);\nresult.specular=specTerm*diffuseColor*info.attenuation;\n#endif\nreturn result;\n}\nlightingInfo computeDirectionalLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec3 diffuseColor,vec3 specularColor,float lightRadius,float roughness,float NdotV,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,out float NdotL) {\nlightingInfo result;\nfloat lightDistance=length(-lightData.xyz);\nvec3 lightDirection=normalize(-lightData.xyz);\n\nroughness=adjustRoughnessFromLightProperties(roughness,lightRadius,lightDistance);\n\nvec3 H=normalize(viewDirectionW+lightDirection);\nNdotL=clamp(dot(vNormal,lightDirection),0.00000000001,1.0);\nfloat VdotH=clamp(dot(viewDirectionW,H),0.0,1.0);\nfloat diffuseTerm=computeDiffuseTerm(NdotL,NdotV,VdotH,roughness);\nresult.diffuse=diffuseTerm*diffuseColor;\n#ifdef SPECULARTERM\n\nfloat NdotH=clamp(dot(vNormal,H),0.000000000001,1.0);\nvec3 specTerm=computeSpecularTerm(NdotH,NdotL,NdotV,VdotH,roughness,reflectance0,reflectance90,geometricRoughnessFactor);\nresult.specular=specTerm*diffuseColor;\n#endif\nreturn result;\n}\nlightingInfo computeHemisphericLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec3 diffuseColor,vec3 specularColor,vec3 groundColor,float roughness,float NdotV,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,out float NdotL) {\nlightingInfo result;\n\n\n\nNdotL=dot(vNormal,lightData.xyz)*0.5+0.5;\nresult.diffuse=mix(groundColor,diffuseColor,NdotL);\n#ifdef SPECULARTERM\n\nvec3 lightVectorW=normalize(lightData.xyz);\nvec3 H=normalize(viewDirectionW+lightVectorW);\nfloat NdotH=clamp(dot(vNormal,H),0.000000000001,1.0);\nNdotL=clamp(NdotL,0.000000000001,1.0);\nfloat VdotH=clamp(dot(viewDirectionW,H),0.0,1.0);\nvec3 specTerm=computeSpecularTerm(NdotH,NdotL,NdotV,VdotH,roughness,reflectance0,reflectance90,geometricRoughnessFactor);\nresult.specular=specTerm*diffuseColor;\n#endif\nreturn result;\n}\nvec3 computeProjectionTextureDiffuseLighting(sampler2D projectionLightSampler,mat4 textureProjectionMatrix){\nvec4 strq=textureProjectionMatrix*vec4(vPositionW,1.0);\nstrq/=strq.w;\nvec3 textureColor=texture2D(projectionLightSampler,strq.xy).rgb;\nreturn toLinearSpace(textureColor);\n}";St.a.IncludesShadersStore.pbrLightFunctions=cn;i(112),i(80),i(113),i(114),i(107);var ln="#if defined(BUMP) || !defined(NORMAL) || defined(FORCENORMALFORWARD) || defined(SPECULARAA)\n#extension GL_OES_standard_derivatives : enable\n#endif\n#ifdef LODBASEDMICROSFURACE\n#extension GL_EXT_shader_texture_lod : enable\n#endif\n#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\nprecision highp float;\n#include<__decl__pbrFragment>\nuniform vec4 vEyePosition;\nuniform vec3 vAmbientColor;\nuniform vec4 vCameraInfos;\n\nvarying vec3 vPositionW;\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2;\n#endif\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)\nvarying vec3 vEnvironmentIrradiance;\n#endif\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n\n#ifdef ALBEDO\n#if ALBEDODIRECTUV == 1\n#define vAlbedoUV vMainUV1\n#elif ALBEDODIRECTUV == 2\n#define vAlbedoUV vMainUV2\n#else\nvarying vec2 vAlbedoUV;\n#endif\nuniform sampler2D albedoSampler;\n#endif\n#ifdef AMBIENT\n#if AMBIENTDIRECTUV == 1\n#define vAmbientUV vMainUV1\n#elif AMBIENTDIRECTUV == 2\n#define vAmbientUV vMainUV2\n#else\nvarying vec2 vAmbientUV;\n#endif\nuniform sampler2D ambientSampler;\n#endif\n#ifdef OPACITY\n#if OPACITYDIRECTUV == 1\n#define vOpacityUV vMainUV1\n#elif OPACITYDIRECTUV == 2\n#define vOpacityUV vMainUV2\n#else\nvarying vec2 vOpacityUV;\n#endif\nuniform sampler2D opacitySampler;\n#endif\n#ifdef EMISSIVE\n#if EMISSIVEDIRECTUV == 1\n#define vEmissiveUV vMainUV1\n#elif EMISSIVEDIRECTUV == 2\n#define vEmissiveUV vMainUV2\n#else\nvarying vec2 vEmissiveUV;\n#endif\nuniform sampler2D emissiveSampler;\n#endif\n#ifdef LIGHTMAP\n#if LIGHTMAPDIRECTUV == 1\n#define vLightmapUV vMainUV1\n#elif LIGHTMAPDIRECTUV == 2\n#define vLightmapUV vMainUV2\n#else\nvarying vec2 vLightmapUV;\n#endif\nuniform sampler2D lightmapSampler;\n#endif\n#ifdef REFLECTIVITY\n#if REFLECTIVITYDIRECTUV == 1\n#define vReflectivityUV vMainUV1\n#elif REFLECTIVITYDIRECTUV == 2\n#define vReflectivityUV vMainUV2\n#else\nvarying vec2 vReflectivityUV;\n#endif\nuniform sampler2D reflectivitySampler;\n#endif\n#ifdef MICROSURFACEMAP\n#if MICROSURFACEMAPDIRECTUV == 1\n#define vMicroSurfaceSamplerUV vMainUV1\n#elif MICROSURFACEMAPDIRECTUV == 2\n#define vMicroSurfaceSamplerUV vMainUV2\n#else\nvarying vec2 vMicroSurfaceSamplerUV;\n#endif\nuniform sampler2D microSurfaceSampler;\n#endif\n\n#ifdef REFRACTION\n#ifdef REFRACTIONMAP_3D\n#define sampleRefraction(s,c) textureCube(s,c)\nuniform samplerCube refractionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleRefractionLod(s,c,l) textureCubeLodEXT(s,c,l)\n#else\nuniform samplerCube refractionSamplerLow;\nuniform samplerCube refractionSamplerHigh;\n#endif\n#else\n#define sampleRefraction(s,c) texture2D(s,c)\nuniform sampler2D refractionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleRefractionLod(s,c,l) texture2DLodEXT(s,c,l)\n#else\nuniform samplerCube refractionSamplerLow;\nuniform samplerCube refractionSamplerHigh;\n#endif\n#endif\n#endif\n\n#ifdef REFLECTION\n#ifdef REFLECTIONMAP_3D\n#define sampleReflection(s,c) textureCube(s,c)\nuniform samplerCube reflectionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleReflectionLod(s,c,l) textureCubeLodEXT(s,c,l)\n#else\nuniform samplerCube reflectionSamplerLow;\nuniform samplerCube reflectionSamplerHigh;\n#endif\n#else\n#define sampleReflection(s,c) texture2D(s,c)\nuniform sampler2D reflectionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleReflectionLod(s,c,l) texture2DLodEXT(s,c,l)\n#else\nuniform samplerCube reflectionSamplerLow;\nuniform samplerCube reflectionSamplerHigh;\n#endif\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#else\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#endif\n#include<reflectionFunction>\n#endif\n#ifdef ENVIRONMENTBRDF\nuniform sampler2D environmentBrdfSampler;\n#endif\n\n#ifndef FROMLINEARSPACE\n#define FROMLINEARSPACE;\n#endif\n#include<imageProcessingDeclaration>\n#include<helperFunctions>\n#include<imageProcessingFunctions>\n\n#include<shadowsFragmentFunctions>\n#include<pbrFunctions>\n#include<harmonicsFunctions>\n#include<pbrLightFunctions>\n#include<bumpFragmentFunctions>\n#include<clipPlaneFragmentDeclaration>\n#include<logDepthDeclaration>\n\n#include<fogFragmentDeclaration>\nvoid main(void) {\n#include<clipPlaneFragment>\n\n\nvec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=normalize(cross(dFdx(vPositionW),dFdy(vPositionW)))*vEyePosition.w;\n#endif\n#include<bumpFragment>\n#ifdef SPECULARAA\nvec3 nDfdx=dFdx(normalW.xyz);\nvec3 nDfdy=dFdy(normalW.xyz);\nfloat slopeSquare=max(dot(nDfdx,nDfdx),dot(nDfdy,nDfdy));\n\nfloat geometricRoughnessFactor=pow(clamp(slopeSquare ,0.,1.),0.333);\n\nfloat geometricAlphaGFactor=sqrt(slopeSquare);\n#else\nfloat geometricRoughnessFactor=0.;\n#endif\n#if defined(FORCENORMALFORWARD) && defined(NORMAL)\nvec3 faceNormal=normalize(cross(dFdx(vPositionW),dFdy(vPositionW)))*vEyePosition.w;\n#if defined(TWOSIDEDLIGHTING)\nfaceNormal=gl_FrontFacing ? faceNormal : -faceNormal;\n#endif\nnormalW*=sign(dot(normalW,faceNormal));\n#endif\n#if defined(TWOSIDEDLIGHTING) && defined(NORMAL)\nnormalW=gl_FrontFacing ? normalW : -normalW;\n#endif\n\n\nvec3 surfaceAlbedo=vAlbedoColor.rgb;\n\nfloat alpha=vAlbedoColor.a;\n#ifdef ALBEDO\nvec4 albedoTexture=texture2D(albedoSampler,vAlbedoUV+uvOffset);\n#if defined(ALPHAFROMALBEDO) || defined(ALPHATEST)\nalpha*=albedoTexture.a;\n#endif\nsurfaceAlbedo*=toLinearSpace(albedoTexture.rgb);\nsurfaceAlbedo*=vAlbedoInfos.y;\n#endif\n\n#ifdef OPACITY\nvec4 opacityMap=texture2D(opacitySampler,vOpacityUV+uvOffset);\n#ifdef OPACITYRGB\nalpha=getLuminance(opacityMap.rgb);\n#else\nalpha*=opacityMap.a;\n#endif\nalpha*=vOpacityInfos.y;\n#endif\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n#if !defined(LINKREFRACTIONTOTRANSPARENCY) && !defined(ALPHAFRESNEL)\n#ifdef ALPHATEST\nif (alpha<ALPHATESTVALUE)\ndiscard;\n#ifndef ALPHABLEND\n\nalpha=1.0;\n#endif\n#endif\n#endif\n#include<depthPrePass>\n#ifdef VERTEXCOLOR\nsurfaceAlbedo*=vColor.rgb;\n#endif\n\nvec3 ambientOcclusionColor=vec3(1.,1.,1.);\n#ifdef AMBIENT\nvec3 ambientOcclusionColorMap=texture2D(ambientSampler,vAmbientUV+uvOffset).rgb*vAmbientInfos.y;\n#ifdef AMBIENTINGRAYSCALE\nambientOcclusionColorMap=vec3(ambientOcclusionColorMap.r,ambientOcclusionColorMap.r,ambientOcclusionColorMap.r);\n#endif\nambientOcclusionColor=mix(ambientOcclusionColor,ambientOcclusionColorMap,vAmbientInfos.z);\n#endif\n#ifdef UNLIT\nvec3 diffuseBase=vec3(1.,1.,1.);\n#else\n\nfloat microSurface=vReflectivityColor.a;\nvec3 surfaceReflectivityColor=vReflectivityColor.rgb;\n#ifdef METALLICWORKFLOW\nvec2 metallicRoughness=surfaceReflectivityColor.rg;\n#ifdef REFLECTIVITY\nvec4 surfaceMetallicColorMap=texture2D(reflectivitySampler,vReflectivityUV+uvOffset);\n#ifdef AOSTOREINMETALMAPRED\nvec3 aoStoreInMetalMap=vec3(surfaceMetallicColorMap.r,surfaceMetallicColorMap.r,surfaceMetallicColorMap.r);\nambientOcclusionColor=mix(ambientOcclusionColor,aoStoreInMetalMap,vReflectivityInfos.z);\n#endif\n#ifdef METALLNESSSTOREINMETALMAPBLUE\nmetallicRoughness.r*=surfaceMetallicColorMap.b;\n#else\nmetallicRoughness.r*=surfaceMetallicColorMap.r;\n#endif\n#ifdef ROUGHNESSSTOREINMETALMAPALPHA\nmetallicRoughness.g*=surfaceMetallicColorMap.a;\n#else\n#ifdef ROUGHNESSSTOREINMETALMAPGREEN\nmetallicRoughness.g*=surfaceMetallicColorMap.g;\n#endif\n#endif\n#endif\n#ifdef MICROSURFACEMAP\nvec4 microSurfaceTexel=texture2D(microSurfaceSampler,vMicroSurfaceSamplerUV+uvOffset)*vMicroSurfaceSamplerInfos.y;\nmetallicRoughness.g*=microSurfaceTexel.r;\n#endif\n\nmicroSurface=1.0-metallicRoughness.g;\n\nvec3 baseColor=surfaceAlbedo;\n\n\nconst vec3 DefaultSpecularReflectanceDielectric=vec3(0.04,0.04,0.04);\n\nsurfaceAlbedo=mix(baseColor.rgb*(1.0-DefaultSpecularReflectanceDielectric.r),vec3(0.,0.,0.),metallicRoughness.r);\n\nsurfaceReflectivityColor=mix(DefaultSpecularReflectanceDielectric,baseColor,metallicRoughness.r);\n#else\n#ifdef REFLECTIVITY\nvec4 surfaceReflectivityColorMap=texture2D(reflectivitySampler,vReflectivityUV+uvOffset);\nsurfaceReflectivityColor*=toLinearSpace(surfaceReflectivityColorMap.rgb);\nsurfaceReflectivityColor*=vReflectivityInfos.y;\n#ifdef MICROSURFACEFROMREFLECTIVITYMAP\nmicroSurface*=surfaceReflectivityColorMap.a;\nmicroSurface*=vReflectivityInfos.z;\n#else\n#ifdef MICROSURFACEAUTOMATIC\nmicroSurface*=computeDefaultMicroSurface(microSurface,surfaceReflectivityColor);\n#endif\n#ifdef MICROSURFACEMAP\nvec4 microSurfaceTexel=texture2D(microSurfaceSampler,vMicroSurfaceSamplerUV+uvOffset)*vMicroSurfaceSamplerInfos.y;\nmicroSurface*=microSurfaceTexel.r;\n#endif\n#endif\n#endif\n#endif\n\nmicroSurface=clamp(microSurface,0.,1.);\n\nfloat roughness=1.-microSurface;\n\n#ifdef ALPHAFRESNEL\n#if defined(ALPHATEST) || defined(ALPHABLEND)\n\n\n\nfloat opacityPerceptual=alpha;\n#ifdef LINEARALPHAFRESNEL\nfloat opacity0=opacityPerceptual;\n#else\nfloat opacity0=opacityPerceptual*opacityPerceptual;\n#endif\nfloat opacity90=fresnelGrazingReflectance(opacity0);\nvec3 normalForward=faceforward(normalW,-viewDirectionW,normalW);\n\nalpha=fresnelSchlickEnvironmentGGX(clamp(dot(viewDirectionW,normalForward),0.0,1.0),vec3(opacity0),vec3(opacity90),sqrt(microSurface)).x;\n#ifdef ALPHATEST\nif (alpha<ALPHATESTVALUE)\ndiscard;\n#ifndef ALPHABLEND\n\nalpha=1.0;\n#endif\n#endif\n#endif\n#endif\n\n\nfloat NdotVUnclamped=dot(normalW,viewDirectionW);\nfloat NdotV=clamp(NdotVUnclamped,0.,1.)+0.00001;\nfloat alphaG=convertRoughnessToAverageSlope(roughness);\n#ifdef SPECULARAA\n\n\nalphaG+=(0.75*geometricAlphaGFactor);\n#endif\n\n#ifdef REFRACTION\nvec4 environmentRefraction=vec4(0.,0.,0.,0.);\nvec3 refractionVector=refract(-viewDirectionW,normalW,vRefractionInfos.y);\n#ifdef REFRACTIONMAP_OPPOSITEZ\nrefractionVector.z*=-1.0;\n#endif\n\n#ifdef REFRACTIONMAP_3D\nrefractionVector.y=refractionVector.y*vRefractionInfos.w;\nvec3 refractionCoords=refractionVector;\nrefractionCoords=vec3(refractionMatrix*vec4(refractionCoords,0));\n#else\nvec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*vRefractionInfos.z,1.0)));\nvec2 refractionCoords=vRefractionUVW.xy/vRefractionUVW.z;\nrefractionCoords.y=1.0-refractionCoords.y;\n#endif\n#ifdef LODINREFRACTIONALPHA\nfloat refractionLOD=getLodFromAlphaG(vRefractionMicrosurfaceInfos.x,alphaG,NdotVUnclamped);\n#else\nfloat refractionLOD=getLodFromAlphaG(vRefractionMicrosurfaceInfos.x,alphaG,1.0);\n#endif\n#ifdef LODBASEDMICROSFURACE\n\nrefractionLOD=refractionLOD*vRefractionMicrosurfaceInfos.y+vRefractionMicrosurfaceInfos.z;\n#ifdef LODINREFRACTIONALPHA\n\n\n\n\n\n\n\n\n\nfloat automaticRefractionLOD=UNPACK_LOD(sampleRefraction(refractionSampler,refractionCoords).a);\nfloat requestedRefractionLOD=max(automaticRefractionLOD,refractionLOD);\n#else\nfloat requestedRefractionLOD=refractionLOD;\n#endif\nenvironmentRefraction=sampleRefractionLod(refractionSampler,refractionCoords,requestedRefractionLOD);\n#else\nfloat lodRefractionNormalized=clamp(refractionLOD/log2(vRefractionMicrosurfaceInfos.x),0.,1.);\nfloat lodRefractionNormalizedDoubled=lodRefractionNormalized*2.0;\nvec4 environmentRefractionMid=sampleRefraction(refractionSampler,refractionCoords);\nif(lodRefractionNormalizedDoubled<1.0){\nenvironmentRefraction=mix(\nsampleRefraction(refractionSamplerHigh,refractionCoords),\nenvironmentRefractionMid,\nlodRefractionNormalizedDoubled\n);\n}else{\nenvironmentRefraction=mix(\nenvironmentRefractionMid,\nsampleRefraction(refractionSamplerLow,refractionCoords),\nlodRefractionNormalizedDoubled-1.0\n);\n}\n#endif\n#ifdef RGBDREFRACTION\nenvironmentRefraction.rgb=fromRGBD(environmentRefraction);\n#endif\n#ifdef GAMMAREFRACTION\nenvironmentRefraction.rgb=toLinearSpace(environmentRefraction.rgb);\n#endif\n\nenvironmentRefraction.rgb*=vRefractionInfos.x;\n#endif\n\n#ifdef REFLECTION\nvec4 environmentRadiance=vec4(0.,0.,0.,0.);\nvec3 environmentIrradiance=vec3(0.,0.,0.);\nvec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),normalW);\n#ifdef REFLECTIONMAP_OPPOSITEZ\nreflectionVector.z*=-1.0;\n#endif\n\n#ifdef REFLECTIONMAP_3D\nvec3 reflectionCoords=reflectionVector;\n#else\nvec2 reflectionCoords=reflectionVector.xy;\n#ifdef REFLECTIONMAP_PROJECTION\nreflectionCoords/=reflectionVector.z;\n#endif\nreflectionCoords.y=1.0-reflectionCoords.y;\n#endif\n#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)\nfloat reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG,NdotVUnclamped);\n#else\nfloat reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG,1.);\n#endif\n#ifdef LODBASEDMICROSFURACE\n\nreflectionLOD=reflectionLOD*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z;\n#ifdef LODINREFLECTIONALPHA\n\n\n\n\n\n\n\n\n\nfloat automaticReflectionLOD=UNPACK_LOD(sampleReflection(reflectionSampler,reflectionCoords).a);\nfloat requestedReflectionLOD=max(automaticReflectionLOD,reflectionLOD);\n#else\nfloat requestedReflectionLOD=reflectionLOD;\n#endif\nenvironmentRadiance=sampleReflectionLod(reflectionSampler,reflectionCoords,requestedReflectionLOD);\n#else\nfloat lodReflectionNormalized=clamp(reflectionLOD/log2(vReflectionMicrosurfaceInfos.x),0.,1.);\nfloat lodReflectionNormalizedDoubled=lodReflectionNormalized*2.0;\nvec4 environmentSpecularMid=sampleReflection(reflectionSampler,reflectionCoords);\nif(lodReflectionNormalizedDoubled<1.0){\nenvironmentRadiance=mix(\nsampleReflection(reflectionSamplerHigh,reflectionCoords),\nenvironmentSpecularMid,\nlodReflectionNormalizedDoubled\n);\n}else{\nenvironmentRadiance=mix(\nenvironmentSpecularMid,\nsampleReflection(reflectionSamplerLow,reflectionCoords),\nlodReflectionNormalizedDoubled-1.0\n);\n}\n#endif\n#ifdef RGBDREFLECTION\nenvironmentRadiance.rgb=fromRGBD(environmentRadiance);\n#endif\n#ifdef GAMMAREFLECTION\nenvironmentRadiance.rgb=toLinearSpace(environmentRadiance.rgb);\n#endif\n\n#ifdef USESPHERICALFROMREFLECTIONMAP\n#if defined(NORMAL) && defined(USESPHERICALINVERTEX)\nenvironmentIrradiance=vEnvironmentIrradiance;\n#else\nvec3 irradianceVector=vec3(reflectionMatrix*vec4(normalW,0)).xyz;\n#ifdef REFLECTIONMAP_OPPOSITEZ\nirradianceVector.z*=-1.0;\n#endif\nenvironmentIrradiance=environmentIrradianceJones(irradianceVector);\n#endif\n#endif\n\nenvironmentRadiance.rgb*=vReflectionInfos.x;\nenvironmentRadiance.rgb*=vReflectionColor.rgb;\nenvironmentIrradiance*=vReflectionColor.rgb;\n#endif\n\n\n\nfloat reflectance=max(max(surfaceReflectivityColor.r,surfaceReflectivityColor.g),surfaceReflectivityColor.b);\nfloat reflectance90=fresnelGrazingReflectance(reflectance);\nvec3 specularEnvironmentR0=surfaceReflectivityColor.rgb;\nvec3 specularEnvironmentR90=vec3(1.0,1.0,1.0)*reflectance90;\n\nvec3 diffuseBase=vec3(0.,0.,0.);\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif\n#ifdef LIGHTMAP\nvec3 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset).rgb;\n#ifdef GAMMALIGHTMAP\nlightmapColor=toLinearSpace(lightmapColor);\n#endif\nlightmapColor*=vLightmapInfos.y;\n#endif\nlightingInfo info;\npointLightingInfo pointInfo;\nspotLightingInfo spotInfo;\nfloat shadow=1.;\nfloat NdotL=-1.;\n#include<lightFragment>[0..maxSimultaneousLights]\n\n#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)\n\nvec2 brdfSamplerUV=vec2(NdotV,roughness);\n\nvec4 environmentBrdf=texture2D(environmentBrdfSampler,brdfSamplerUV);\nvec3 specularEnvironmentReflectance=specularEnvironmentR0*environmentBrdf.x+environmentBrdf.y;\n#ifdef RADIANCEOCCLUSION\n#ifdef AMBIENTINGRAYSCALE\nfloat ambientMonochrome=ambientOcclusionColor.r;\n#else\nfloat ambientMonochrome=getLuminance(ambientOcclusionColor);\n#endif\nfloat seo=environmentRadianceOcclusion(ambientMonochrome,NdotVUnclamped);\nspecularEnvironmentReflectance*=seo;\n#endif\n#ifdef HORIZONOCCLUSION\n#ifdef BUMP\n#ifdef REFLECTIONMAP_3D\nfloat eho=environmentHorizonOcclusion(-viewDirectionW,normalW);\nspecularEnvironmentReflectance*=eho;\n#endif\n#endif\n#endif\n#else\n\nvec3 specularEnvironmentReflectance=fresnelSchlickEnvironmentGGX(NdotV,specularEnvironmentR0,specularEnvironmentR90,sqrt(microSurface));\n#endif\n\n#ifdef REFRACTION\nvec3 refractance=vec3(0.0,0.0,0.0);\nvec3 transmission=vec3(1.0,1.0,1.0);\n#ifdef LINKREFRACTIONTOTRANSPARENCY\n\ntransmission*=(1.0-alpha);\n\n\nvec3 mixedAlbedo=surfaceAlbedo;\nfloat maxChannel=max(max(mixedAlbedo.r,mixedAlbedo.g),mixedAlbedo.b);\nvec3 tint=clamp(maxChannel*mixedAlbedo,0.0,1.0);\n\nsurfaceAlbedo*=alpha;\n\nenvironmentIrradiance*=alpha;\n\nenvironmentRefraction.rgb*=tint;\n\nalpha=1.0;\n#endif\n\nvec3 bounceSpecularEnvironmentReflectance=(2.0*specularEnvironmentReflectance)/(1.0+specularEnvironmentReflectance);\nspecularEnvironmentReflectance=mix(bounceSpecularEnvironmentReflectance,specularEnvironmentReflectance,alpha);\n\ntransmission*=1.0-specularEnvironmentReflectance;\n\nrefractance=transmission;\n#endif\n\n\n\n\nsurfaceAlbedo.rgb=(1.-reflectance)*surfaceAlbedo.rgb;\n\n#ifdef REFLECTION\nvec3 finalIrradiance=environmentIrradiance;\nfinalIrradiance*=surfaceAlbedo.rgb;\n#endif\n\n#ifdef SPECULARTERM\nvec3 finalSpecular=specularBase;\nfinalSpecular=max(finalSpecular,0.0);\n\nvec3 finalSpecularScaled=finalSpecular*vLightingIntensity.x*vLightingIntensity.w;\n#endif\n\n#ifdef REFLECTION\nvec3 finalRadiance=environmentRadiance.rgb;\nfinalRadiance*=specularEnvironmentReflectance;\n\nvec3 finalRadianceScaled=finalRadiance*vLightingIntensity.z;\n#endif\n\n#ifdef REFRACTION\nvec3 finalRefraction=environmentRefraction.rgb;\nfinalRefraction*=refractance;\n#endif\n\n#ifdef ALPHABLEND\nfloat luminanceOverAlpha=0.0;\n#if defined(REFLECTION) && defined(RADIANCEOVERALPHA)\nluminanceOverAlpha+=getLuminance(finalRadianceScaled);\n#endif\n#if defined(SPECULARTERM) && defined(SPECULAROVERALPHA)\nluminanceOverAlpha+=getLuminance(finalSpecularScaled);\n#endif\n#if defined(RADIANCEOVERALPHA) || defined(SPECULAROVERALPHA)\nalpha=clamp(alpha+luminanceOverAlpha*luminanceOverAlpha,0.,1.);\n#endif\n#endif\n#endif\n\nvec3 finalDiffuse=diffuseBase;\nfinalDiffuse.rgb+=vAmbientColor;\nfinalDiffuse*=surfaceAlbedo.rgb;\nfinalDiffuse=max(finalDiffuse,0.0);\n\nvec3 finalEmissive=vEmissiveColor;\n#ifdef EMISSIVE\nvec3 emissiveColorTex=texture2D(emissiveSampler,vEmissiveUV+uvOffset).rgb;\nfinalEmissive*=toLinearSpace(emissiveColorTex.rgb);\nfinalEmissive*=vEmissiveInfos.y;\n#endif\n\n#ifdef AMBIENT\nvec3 ambientOcclusionForDirectDiffuse=mix(vec3(1.),ambientOcclusionColor,vAmbientInfos.w);\n#else\nvec3 ambientOcclusionForDirectDiffuse=ambientOcclusionColor;\n#endif\n\n\n\nvec4 finalColor=vec4(\nfinalDiffuse*ambientOcclusionForDirectDiffuse*vLightingIntensity.x +\n#ifndef UNLIT\n#ifdef REFLECTION\nfinalIrradiance*ambientOcclusionColor*vLightingIntensity.z +\n#endif\n#ifdef SPECULARTERM\n\n\nfinalSpecularScaled +\n#endif\n#ifdef REFLECTION\n\n\nfinalRadianceScaled +\n#endif\n#ifdef REFRACTION\nfinalRefraction*vLightingIntensity.z +\n#endif\n#endif\nfinalEmissive*vLightingIntensity.y,\nalpha);\n\n#ifdef LIGHTMAP\n#ifndef LIGHTMAPEXCLUDED\n#ifdef USELIGHTMAPASSHADOWMAP\nfinalColor.rgb*=lightmapColor;\n#else\nfinalColor.rgb+=lightmapColor;\n#endif\n#endif\n#endif\n\nfinalColor=max(finalColor,0.0);\n#include<logDepthFragment>\n#include<fogFragment>(color,finalColor)\n#ifdef IMAGEPROCESSINGPOSTPROCESS\n\n\nfinalColor.rgb=clamp(finalColor.rgb,0.,30.0);\n#else\n\nfinalColor=applyImageProcessing(finalColor);\n#endif\n#ifdef PREMULTIPLYALPHA\n\nfinalColor.rgb*=finalColor.a;\n#endif\ngl_FragColor=finalColor;\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n}\n";St.a.ShadersStore.pbrPixelShader=ln;var un="uniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef ALBEDO\nuniform mat4 albedoMatrix;\nuniform vec2 vAlbedoInfos;\n#endif\n#ifdef AMBIENT\nuniform mat4 ambientMatrix;\nuniform vec4 vAmbientInfos;\n#endif\n#ifdef OPACITY\nuniform mat4 opacityMatrix;\nuniform vec2 vOpacityInfos;\n#endif\n#ifdef EMISSIVE\nuniform vec2 vEmissiveInfos;\nuniform mat4 emissiveMatrix;\n#endif\n#ifdef LIGHTMAP\nuniform vec2 vLightmapInfos;\nuniform mat4 lightmapMatrix;\n#endif\n#ifdef REFLECTIVITY\nuniform vec3 vReflectivityInfos;\nuniform mat4 reflectivityMatrix;\n#endif\n#ifdef MICROSURFACEMAP\nuniform vec2 vMicroSurfaceSamplerInfos;\nuniform mat4 microSurfaceSamplerMatrix;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;\nuniform mat4 bumpMatrix;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n\n#ifdef REFRACTION\nuniform vec4 vRefractionInfos;\nuniform mat4 refractionMatrix;\nuniform vec3 vRefractionMicrosurfaceInfos;\n#endif\n\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\nuniform mat4 reflectionMatrix;\nuniform vec3 vReflectionMicrosurfaceInfos;\n#endif\n";St.a.IncludesShadersStore.pbrVertexDeclaration=un;i(115),i(96),i(97),i(98),i(116),i(110);var hn="precision highp float;\n#include<__decl__pbrVertex>\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#ifdef TANGENT\nattribute vec4 tangent;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2;\n#endif\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<helperFunctions>\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\n#if defined(ALBEDO) && ALBEDODIRECTUV == 0\nvarying vec2 vAlbedoUV;\n#endif\n#if defined(AMBIENT) && AMBIENTDIRECTUV == 0\nvarying vec2 vAmbientUV;\n#endif\n#if defined(OPACITY) && OPACITYDIRECTUV == 0\nvarying vec2 vOpacityUV;\n#endif\n#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0\nvarying vec2 vEmissiveUV;\n#endif\n#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0\nvarying vec2 vLightmapUV;\n#endif\n#if defined(REFLECTIVITY) && REFLECTIVITYDIRECTUV == 0\nvarying vec2 vReflectivityUV;\n#endif\n#if defined(MICROSURFACEMAP) && MICROSURFACEMAPDIRECTUV == 0\nvarying vec2 vMicroSurfaceSamplerUV;\n#endif\n#if defined(BUMP) && BUMPDIRECTUV == 0\nvarying vec2 vBumpUV;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)\nvarying vec3 vEnvironmentIrradiance;\n#include<harmonicsFunctions>\n#endif\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<bumpVertexDeclaration>\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<morphTargetsVertexGlobalDeclaration>\n#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#include<logDepthDeclaration>\nvoid main(void) {\nvec3 positionUpdated=position;\n#ifdef NORMAL\nvec3 normalUpdated=normal;\n#endif\n#ifdef TANGENT\nvec4 tangentUpdated=tangent;\n#endif\n#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\n#ifdef REFLECTIONMAP_SKYBOX_TRANSFORMED\nvPositionUVW=(reflectionMatrix*vec4(positionUpdated,1.0)).xyz;\n#else\nvPositionUVW=positionUpdated;\n#endif\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\nmat3 normalWorld=mat3(finalWorld);\n#ifdef NONUNIFORMSCALING\nnormalWorld=transposeMat3(inverseMat3(normalWorld));\n#endif\nvNormalW=normalize(normalWorld*normalUpdated);\n#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)\nvec3 reflectionVector=vec3(reflectionMatrix*vec4(vNormalW,0)).xyz;\n#ifdef REFLECTIONMAP_OPPOSITEZ\nreflectionVector.z*=-1.0;\n#endif\nvEnvironmentIrradiance=environmentIrradianceJones(reflectionVector);\n#endif\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvDirectionW=normalize(vec3(finalWorld*vec4(positionUpdated,0.0)));\n#endif\n\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef MAINUV1\nvMainUV1=uv;\n#endif\n#ifdef MAINUV2\nvMainUV2=uv2;\n#endif\n#if defined(ALBEDO) && ALBEDODIRECTUV == 0\nif (vAlbedoInfos.x == 0.)\n{\nvAlbedoUV=vec2(albedoMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvAlbedoUV=vec2(albedoMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(AMBIENT) && AMBIENTDIRECTUV == 0\nif (vAmbientInfos.x == 0.)\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(OPACITY) && OPACITYDIRECTUV == 0\nif (vOpacityInfos.x == 0.)\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0\nif (vEmissiveInfos.x == 0.)\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0\nif (vLightmapInfos.x == 0.)\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(REFLECTIVITY) && REFLECTIVITYDIRECTUV == 0\nif (vReflectivityInfos.x == 0.)\n{\nvReflectivityUV=vec2(reflectivityMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvReflectivityUV=vec2(reflectivityMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(MICROSURFACEMAP) && MICROSURFACEMAPDIRECTUV == 0\nif (vMicroSurfaceSamplerInfos.x == 0.)\n{\nvMicroSurfaceSamplerUV=vec2(microSurfaceSamplerMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvMicroSurfaceSamplerUV=vec2(microSurfaceSamplerMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(BUMP) && BUMPDIRECTUV == 0\nif (vBumpInfos.x == 0.)\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n\n#include<bumpVertex>\n\n#include<clipPlaneVertex>\n\n#include<fogVertex>\n\n#include<shadowsVertex>[0..maxSimultaneousLights]\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n\n#include<logDepthVertex>\n}";St.a.ShadersStore.pbrVertexShader=hn;var dn=function(e){function t(){var t=e.call(this)||this;return t.PBR=!0,t.MAINUV1=!1,t.MAINUV2=!1,t.UV1=!1,t.UV2=!1,t.ALBEDO=!1,t.ALBEDODIRECTUV=0,t.VERTEXCOLOR=!1,t.AMBIENT=!1,t.AMBIENTDIRECTUV=0,t.AMBIENTINGRAYSCALE=!1,t.OPACITY=!1,t.VERTEXALPHA=!1,t.OPACITYDIRECTUV=0,t.OPACITYRGB=!1,t.ALPHATEST=!1,t.DEPTHPREPASS=!1,t.ALPHABLEND=!1,t.ALPHAFROMALBEDO=!1,t.ALPHATESTVALUE="0.5",t.SPECULAROVERALPHA=!1,t.RADIANCEOVERALPHA=!1,t.ALPHAFRESNEL=!1,t.LINEARALPHAFRESNEL=!1,t.PREMULTIPLYALPHA=!1,t.EMISSIVE=!1,t.EMISSIVEDIRECTUV=0,t.REFLECTIVITY=!1,t.REFLECTIVITYDIRECTUV=0,t.SPECULARTERM=!1,t.MICROSURFACEFROMREFLECTIVITYMAP=!1,t.MICROSURFACEAUTOMATIC=!1,t.LODBASEDMICROSFURACE=!1,t.MICROSURFACEMAP=!1,t.MICROSURFACEMAPDIRECTUV=0,t.METALLICWORKFLOW=!1,t.ROUGHNESSSTOREINMETALMAPALPHA=!1,t.ROUGHNESSSTOREINMETALMAPGREEN=!1,t.METALLNESSSTOREINMETALMAPBLUE=!1,t.AOSTOREINMETALMAPRED=!1,t.ENVIRONMENTBRDF=!1,t.NORMAL=!1,t.TANGENT=!1,t.BUMP=!1,t.BUMPDIRECTUV=0,t.OBJECTSPACE_NORMALMAP=!1,t.PARALLAX=!1,t.PARALLAXOCCLUSION=!1,t.NORMALXYSCALE=!0,t.LIGHTMAP=!1,t.LIGHTMAPDIRECTUV=0,t.USELIGHTMAPASSHADOWMAP=!1,t.GAMMALIGHTMAP=!1,t.REFLECTION=!1,t.REFLECTIONMAP_3D=!1,t.REFLECTIONMAP_SPHERICAL=!1,t.REFLECTIONMAP_PLANAR=!1,t.REFLECTIONMAP_CUBIC=!1,t.USE_LOCAL_REFLECTIONMAP_CUBIC=!1,t.REFLECTIONMAP_PROJECTION=!1,t.REFLECTIONMAP_SKYBOX=!1,t.REFLECTIONMAP_SKYBOX_TRANSFORMED=!1,t.REFLECTIONMAP_EXPLICIT=!1,t.REFLECTIONMAP_EQUIRECTANGULAR=!1,t.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,t.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,t.INVERTCUBICMAP=!1,t.USESPHERICALFROMREFLECTIONMAP=!1,t.USESPHERICALINVERTEX=!1,t.REFLECTIONMAP_OPPOSITEZ=!1,t.LODINREFLECTIONALPHA=!1,t.GAMMAREFLECTION=!1,t.RGBDREFLECTION=!1,t.RADIANCEOCCLUSION=!1,t.HORIZONOCCLUSION=!1,t.REFRACTION=!1,t.REFRACTIONMAP_3D=!1,t.REFRACTIONMAP_OPPOSITEZ=!1,t.LODINREFRACTIONALPHA=!1,t.GAMMAREFRACTION=!1,t.RGBDREFRACTION=!1,t.LINKREFRACTIONTOTRANSPARENCY=!1,t.INSTANCES=!1,t.NUM_BONE_INFLUENCERS=0,t.BonesPerMesh=0,t.BONETEXTURE=!1,t.NONUNIFORMSCALING=!1,t.MORPHTARGETS=!1,t.MORPHTARGETS_NORMAL=!1,t.MORPHTARGETS_TANGENT=!1,t.NUM_MORPH_INFLUENCERS=0,t.IMAGEPROCESSING=!1,t.VIGNETTE=!1,t.VIGNETTEBLENDMODEMULTIPLY=!1,t.VIGNETTEBLENDMODEOPAQUE=!1,t.TONEMAPPING=!1,t.TONEMAPPING_ACES=!1,t.CONTRAST=!1,t.COLORCURVES=!1,t.COLORGRADING=!1,t.COLORGRADING3D=!1,t.SAMPLER3DGREENDEPTH=!1,t.SAMPLER3DBGRMAP=!1,t.IMAGEPROCESSINGPOSTPROCESS=!1,t.EXPOSURE=!1,t.USEPHYSICALLIGHTFALLOFF=!1,t.USEGLTFLIGHTFALLOFF=!1,t.TWOSIDEDLIGHTING=!1,t.SHADOWFLOAT=!1,t.CLIPPLANE=!1,t.CLIPPLANE2=!1,t.CLIPPLANE3=!1,t.CLIPPLANE4=!1,t.POINTSIZE=!1,t.FOG=!1,t.LOGARITHMICDEPTH=!1,t.FORCENORMALFORWARD=!1,t.SPECULARAA=!1,t.UNLIT=!1,t.rebuild(),t}return l.d(t,e),t.prototype.reset=function(){e.prototype.reset.call(this),this.ALPHATESTVALUE="0.5",this.PBR=!0},t}(zr.a),fn=function(e){function t(i,r){var n=e.call(this,i,r)||this;return n._directIntensity=1,n._emissiveIntensity=1,n._environmentIntensity=1,n._specularIntensity=1,n._lightingInfos=new o.y(n._directIntensity,n._emissiveIntensity,n._environmentIntensity,n._specularIntensity),n._disableBumpMap=!1,n._ambientTextureStrength=1,n._ambientTextureImpactOnAnalyticalLights=t.DEFAULT_AO_ON_ANALYTICAL_LIGHTS,n._ambientColor=new o.e(0,0,0),n._albedoColor=new o.e(1,1,1),n._reflectivityColor=new o.e(1,1,1),n._reflectionColor=new o.e(1,1,1),n._emissiveColor=new o.e(0,0,0),n._microSurface=.9,n._indexOfRefraction=.66,n._invertRefractionY=!1,n._linkRefractionWithTransparency=!1,n._useLightmapAsShadowmap=!1,n._useHorizonOcclusion=!0,n._useRadianceOcclusion=!0,n._useAlphaFromAlbedoTexture=!1,n._useSpecularOverAlpha=!0,n._useMicroSurfaceFromReflectivityMapAlpha=!1,n._useRoughnessFromMetallicTextureAlpha=!0,n._useRoughnessFromMetallicTextureGreen=!1,n._useMetallnessFromMetallicTextureBlue=!1,n._useAmbientOcclusionFromMetallicTextureRed=!1,n._useAmbientInGrayScale=!1,n._useAutoMicroSurfaceFromReflectivityMap=!1,n._lightFalloff=t.LIGHTFALLOFF_PHYSICAL,n._useRadianceOverAlpha=!0,n._useObjectSpaceNormalMap=!1,n._useParallax=!1,n._useParallaxOcclusion=!1,n._parallaxScaleBias=.05,n._disableLighting=!1,n._maxSimultaneousLights=4,n._invertNormalMapX=!1,n._invertNormalMapY=!1,n._twoSidedLighting=!1,n._alphaCutOff=.4,n._forceAlphaTest=!1,n._useAlphaFresnel=!1,n._useLinearAlphaFresnel=!1,n._transparencyMode=null,n._environmentBRDFTexture=null,n._forceIrradianceInFragment=!1,n._forceNormalForward=!1,n._enableSpecularAntiAliasing=!1,n._renderTargets=new Rt.a(16),n._globalAmbientColor=new o.e(0,0,0),n._unlit=!1,n._attachImageProcessingConfiguration(null),n.getRenderTargetTextures=function(){return n._renderTargets.reset(),Wr.a.ReflectionTextureEnabled&&n._reflectionTexture&&n._reflectionTexture.isRenderTarget&&n._renderTargets.push(n._reflectionTexture),Wr.a.RefractionTextureEnabled&&n._refractionTexture&&n._refractionTexture.isRenderTarget&&n._renderTargets.push(n._refractionTexture),n._renderTargets},n._environmentBRDFTexture=rn.GetEnvironmentBRDFTexture(r),n}return l.d(t,e),t.prototype._attachImageProcessingConfiguration=function(e){var t=this;e!==this._imageProcessingConfiguration&&(this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),this._imageProcessingConfiguration=e||this.getScene().imageProcessingConfiguration,this._imageProcessingConfiguration&&(this._imageProcessingObserver=this._imageProcessingConfiguration.onUpdateParameters.add(function(){t._markAllSubMeshesAsImageProcessingDirty()})))},Object.defineProperty(t.prototype,"hasRenderTargetTextures",{get:function(){return!!(Wr.a.ReflectionTextureEnabled&&this._reflectionTexture&&this._reflectionTexture.isRenderTarget)||!!(Wr.a.RefractionTextureEnabled&&this._refractionTexture&&this._refractionTexture.isRenderTarget)},enumerable:!0,configurable:!0}),t.prototype.getClassName=function(){return"PBRBaseMaterial"},Object.defineProperty(t.prototype,"useLogarithmicDepth",{get:function(){return this._useLogarithmicDepth},set:function(e){this._useLogarithmicDepth=e&&this.getScene().getEngine().getCaps().fragmentDepthSupported},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"transparencyMode",{get:function(){return this._transparencyMode},set:function(e){this._transparencyMode!==e&&(this._transparencyMode=e,this._forceAlphaTest=e===t.PBRMATERIAL_ALPHATESTANDBLEND,this._markAllSubMeshesAsTexturesAndMiscDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"_disableAlphaBlending",{get:function(){return this._linkRefractionWithTransparency||this._transparencyMode===t.PBRMATERIAL_OPAQUE||this._transparencyMode===t.PBRMATERIAL_ALPHATEST},enumerable:!0,configurable:!0}),t.prototype.needAlphaBlending=function(){return!this._disableAlphaBlending&&(this.alpha<1||null!=this._opacityTexture||this._shouldUseAlphaFromAlbedoTexture())},t.prototype.needAlphaBlendingForMesh=function(t){return!this._disableAlphaBlending&&e.prototype.needAlphaBlendingForMesh.call(this,t)},t.prototype.needAlphaTesting=function(){return!!this._forceAlphaTest||!this._linkRefractionWithTransparency&&(null!=this._albedoTexture&&this._albedoTexture.hasAlpha&&(null==this._transparencyMode||this._transparencyMode===t.PBRMATERIAL_ALPHATEST))},t.prototype._shouldUseAlphaFromAlbedoTexture=function(){return null!=this._albedoTexture&&this._albedoTexture.hasAlpha&&this._useAlphaFromAlbedoTexture&&this._transparencyMode!==t.PBRMATERIAL_OPAQUE},t.prototype.getAlphaTestTexture=function(){return this._albedoTexture},t.prototype.isReadyForSubMesh=function(e,t,i){if(t.effect&&this.isFrozen&&this._wasPreviouslyReady)return!0;t._materialDefines||(t._materialDefines=new dn);var r=t._materialDefines;if(!this.checkReadyOnEveryCall&&t.effect&&r._renderId===this.getScene().getRenderId())return!0;var n=this.getScene(),o=n.getEngine();if(r._areTexturesDirty&&n.texturesEnabled){if(this._albedoTexture&&Wr.a.DiffuseTextureEnabled&&!this._albedoTexture.isReadyOrNotBlocking())return!1;if(this._ambientTexture&&Wr.a.AmbientTextureEnabled&&!this._ambientTexture.isReadyOrNotBlocking())return!1;if(this._opacityTexture&&Wr.a.OpacityTextureEnabled&&!this._opacityTexture.isReadyOrNotBlocking())return!1;var s=this._getReflectionTexture();if(s&&Wr.a.ReflectionTextureEnabled&&!s.isReadyOrNotBlocking())return!1;if(this._lightmapTexture&&Wr.a.LightmapTextureEnabled&&!this._lightmapTexture.isReadyOrNotBlocking())return!1;if(this._emissiveTexture&&Wr.a.EmissiveTextureEnabled&&!this._emissiveTexture.isReadyOrNotBlocking())return!1;if(Wr.a.SpecularTextureEnabled){if(this._metallicTexture){if(!this._metallicTexture.isReadyOrNotBlocking())return!1}else if(this._reflectivityTexture&&!this._reflectivityTexture.isReadyOrNotBlocking())return!1;if(this._microSurfaceTexture&&!this._microSurfaceTexture.isReadyOrNotBlocking())return!1}if(o.getCaps().standardDerivatives&&this._bumpTexture&&Wr.a.BumpTextureEnabled&&!this._disableBumpMap&&!this._bumpTexture.isReady())return!1;var a=this._getRefractionTexture();if(a&&Wr.a.RefractionTextureEnabled&&!a.isReadyOrNotBlocking())return!1;if(this._environmentBRDFTexture&&Wr.a.ReflectionTextureEnabled&&!this._environmentBRDFTexture.isReady())return!1}if(r._areImageProcessingDirty&&this._imageProcessingConfiguration&&!this._imageProcessingConfiguration.isReady())return!1;o.getCaps().standardDerivatives||e.isVerticesDataPresent(gi.b.NormalKind)||(e.createNormals(!0),p.a.Warn("PBRMaterial: Normals have been created for the mesh: "+e.name));var c=t.effect,l=this._prepareEffect(e,r,this.onCompiled,this.onError,i);return l&&(this.allowShaderHotSwapping&&c&&!l.isReady()?(l=c,r.markAsUnprocessed()):(n.resetCachedMaterial(),t.setEffect(l,r),this.buildUniformLayout())),!(!t.effect||!t.effect.isReady())&&(r._renderId=n.getRenderId(),this._wasPreviouslyReady=!0,!0)},t.prototype.isMetallicWorkflow=function(){return!(null==this._metallic&&null==this._roughness&&!this._metallicTexture)},t.prototype._prepareEffect=function(e,t,i,r,n,o){if(void 0===i&&(i=null),void 0===r&&(r=null),void 0===n&&(n=null),void 0===o&&(o=null),this._prepareDefines(e,t,n,o),!t.isDirty)return null;t.markAsProcessed();var s=this.getScene().getEngine(),a=new St.c,c=0;t.USESPHERICALINVERTEX&&a.addFallback(c++,"USESPHERICALINVERTEX"),t.FOG&&a.addFallback(c,"FOG"),t.SPECULARAA&&a.addFallback(c,"SPECULARAA"),t.POINTSIZE&&a.addFallback(c,"POINTSIZE"),t.LOGARITHMICDEPTH&&a.addFallback(c,"LOGARITHMICDEPTH"),t.PARALLAX&&a.addFallback(c,"PARALLAX"),t.PARALLAXOCCLUSION&&a.addFallback(c++,"PARALLAXOCCLUSION"),t.ENVIRONMENTBRDF&&a.addFallback(c++,"ENVIRONMENTBRDF"),t.TANGENT&&a.addFallback(c++,"TANGENT"),t.BUMP&&a.addFallback(c++,"BUMP"),c=kr.a.HandleFallbacksForShadows(t,a,this._maxSimultaneousLights,c++),t.SPECULARTERM&&a.addFallback(c++,"SPECULARTERM"),t.USESPHERICALFROMREFLECTIONMAP&&a.addFallback(c++,"USESPHERICALFROMREFLECTIONMAP"),t.LIGHTMAP&&a.addFallback(c++,"LIGHTMAP"),t.NORMAL&&a.addFallback(c++,"NORMAL"),t.AMBIENT&&a.addFallback(c++,"AMBIENT"),t.EMISSIVE&&a.addFallback(c++,"EMISSIVE"),t.VERTEXCOLOR&&a.addFallback(c++,"VERTEXCOLOR"),t.NUM_BONE_INFLUENCERS>0&&a.addCPUSkinningFallback(c++,e),t.MORPHTARGETS&&a.addFallback(c++,"MORPHTARGETS");var l=[gi.b.PositionKind];t.NORMAL&&l.push(gi.b.NormalKind),t.TANGENT&&l.push(gi.b.TangentKind),t.UV1&&l.push(gi.b.UVKind),t.UV2&&l.push(gi.b.UV2Kind),t.VERTEXCOLOR&&l.push(gi.b.ColorKind),kr.a.PrepareAttributesForBones(l,e,t,a),kr.a.PrepareAttributesForInstances(l,t),kr.a.PrepareAttributesForMorphTargets(l,e,t);var u=["world","view","viewProjection","vEyePosition","vLightsType","vAmbientColor","vAlbedoColor","vReflectivityColor","vEmissiveColor","vReflectionColor","vFogInfos","vFogColor","pointSize","vAlbedoInfos","vAmbientInfos","vOpacityInfos","vReflectionInfos","vReflectionPosition","vReflectionSize","vEmissiveInfos","vReflectivityInfos","vMicroSurfaceSamplerInfos","vBumpInfos","vLightmapInfos","vRefractionInfos","mBones","vClipPlane","vClipPlane2","vClipPlane3","vClipPlane4","albedoMatrix","ambientMatrix","opacityMatrix","reflectionMatrix","emissiveMatrix","reflectivityMatrix","normalMatrix","microSurfaceSamplerMatrix","bumpMatrix","lightmapMatrix","refractionMatrix","vLightingIntensity","logarithmicDepthConstant","vSphericalX","vSphericalY","vSphericalZ","vSphericalXX","vSphericalYY","vSphericalZZ","vSphericalXY","vSphericalYZ","vSphericalZX","vReflectionMicrosurfaceInfos","vRefractionMicrosurfaceInfos","vTangentSpaceParams","boneTextureWidth"],h=["albedoSampler","reflectivitySampler","ambientSampler","emissiveSampler","bumpSampler","lightmapSampler","opacitySampler","refractionSampler","refractionSamplerLow","refractionSamplerHigh","reflectionSampler","reflectionSamplerLow","reflectionSamplerHigh","microSurfaceSampler","environmentBrdfSampler","boneSampler"],d=["Material","Scene"];ui.a&&(ui.a.PrepareUniforms(u,t),ui.a.PrepareSamplers(h,t)),kr.a.PrepareUniformsAndSamplersList({uniformsNames:u,uniformBuffersNames:d,samplers:h,defines:t,maxSimultaneousLights:this._maxSimultaneousLights});var f=t.toString();return s.createEffect("pbr",{attributes:l,uniformsNames:u,uniformBuffersNames:d,samplers:h,defines:f,fallbacks:a,onCompiled:i,onError:r,indexParameters:{maxSimultaneousLights:this._maxSimultaneousLights,maxSimultaneousMorphTargets:t.NUM_MORPH_INFLUENCERS}},s)},t.prototype._prepareDefines=function(e,i,r,n){void 0===r&&(r=null),void 0===n&&(n=null);var o=this.getScene(),s=o.getEngine();if(kr.a.PrepareDefinesForLights(o,e,i,!0,this._maxSimultaneousLights,this._disableLighting),i._needNormals=!0,i.METALLICWORKFLOW=this.isMetallicWorkflow(),i._areTexturesDirty){if(i._needUVs=!1,o.texturesEnabled){o.getEngine().getCaps().textureLOD&&(i.LODBASEDMICROSFURACE=!0),this._albedoTexture&&Wr.a.DiffuseTextureEnabled?kr.a.PrepareDefinesForMergedUV(this._albedoTexture,i,"ALBEDO"):i.ALBEDO=!1,this._ambientTexture&&Wr.a.AmbientTextureEnabled?(kr.a.PrepareDefinesForMergedUV(this._ambientTexture,i,"AMBIENT"),i.AMBIENTINGRAYSCALE=this._useAmbientInGrayScale):i.AMBIENT=!1,this._opacityTexture&&Wr.a.OpacityTextureEnabled?(kr.a.PrepareDefinesForMergedUV(this._opacityTexture,i,"OPACITY"),i.OPACITYRGB=this._opacityTexture.getAlphaFromRGB):i.OPACITY=!1;var a=this._getReflectionTexture();if(a&&Wr.a.ReflectionTextureEnabled){switch(i.REFLECTION=!0,i.GAMMAREFLECTION=a.gammaSpace,i.RGBDREFLECTION=a.isRGBD,i.REFLECTIONMAP_OPPOSITEZ=this.getScene().useRightHandedSystem?!a.invertZ:a.invertZ,i.LODINREFLECTIONALPHA=a.lodLevelInAlpha,a.coordinatesMode===Ve.a.INVCUBIC_MODE&&(i.INVERTCUBICMAP=!0),i.REFLECTIONMAP_3D=a.isCube,i.REFLECTIONMAP_CUBIC=!1,i.REFLECTIONMAP_EXPLICIT=!1,i.REFLECTIONMAP_PLANAR=!1,i.REFLECTIONMAP_PROJECTION=!1,i.REFLECTIONMAP_SKYBOX=!1,i.REFLECTIONMAP_SPHERICAL=!1,i.REFLECTIONMAP_EQUIRECTANGULAR=!1,i.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,i.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,i.REFLECTIONMAP_SKYBOX_TRANSFORMED=!1,a.coordinatesMode){case Ve.a.EXPLICIT_MODE:i.REFLECTIONMAP_EXPLICIT=!0;break;case Ve.a.PLANAR_MODE:i.REFLECTIONMAP_PLANAR=!0;break;case Ve.a.PROJECTION_MODE:i.REFLECTIONMAP_PROJECTION=!0;break;case Ve.a.SKYBOX_MODE:i.REFLECTIONMAP_SKYBOX=!0;break;case Ve.a.SPHERICAL_MODE:i.REFLECTIONMAP_SPHERICAL=!0;break;case Ve.a.EQUIRECTANGULAR_MODE:i.REFLECTIONMAP_EQUIRECTANGULAR=!0;break;case Ve.a.FIXED_EQUIRECTANGULAR_MODE:i.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!0;break;case Ve.a.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:i.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!0;break;case Ve.a.CUBIC_MODE:case Ve.a.INVCUBIC_MODE:default:i.REFLECTIONMAP_CUBIC=!0,i.USE_LOCAL_REFLECTIONMAP_CUBIC=!!a.boundingBoxSize}a.coordinatesMode!==Ve.a.SKYBOX_MODE?a.sphericalPolynomial&&(i.USESPHERICALFROMREFLECTIONMAP=!0,this._forceIrradianceInFragment||o.getEngine().getCaps().maxVaryingVectors<=8?i.USESPHERICALINVERTEX=!1:i.USESPHERICALINVERTEX=!0):i.REFLECTIONMAP_SKYBOX_TRANSFORMED=!a.getReflectionTextureMatrix().isIdentity()}else i.REFLECTION=!1,i.REFLECTIONMAP_3D=!1,i.REFLECTIONMAP_SPHERICAL=!1,i.REFLECTIONMAP_PLANAR=!1,i.REFLECTIONMAP_CUBIC=!1,i.USE_LOCAL_REFLECTIONMAP_CUBIC=!1,i.REFLECTIONMAP_PROJECTION=!1,i.REFLECTIONMAP_SKYBOX=!1,i.REFLECTIONMAP_SKYBOX_TRANSFORMED=!1,i.REFLECTIONMAP_EXPLICIT=!1,i.REFLECTIONMAP_EQUIRECTANGULAR=!1,i.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,i.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,i.INVERTCUBICMAP=!1,i.USESPHERICALFROMREFLECTIONMAP=!1,i.USESPHERICALINVERTEX=!1,i.REFLECTIONMAP_OPPOSITEZ=!1,i.LODINREFLECTIONALPHA=!1,i.GAMMAREFLECTION=!1,i.RGBDREFLECTION=!1;this._lightmapTexture&&Wr.a.LightmapTextureEnabled?(kr.a.PrepareDefinesForMergedUV(this._lightmapTexture,i,"LIGHTMAP"),i.USELIGHTMAPASSHADOWMAP=this._useLightmapAsShadowmap,i.GAMMALIGHTMAP=this._lightmapTexture.gammaSpace):i.LIGHTMAP=!1,this._emissiveTexture&&Wr.a.EmissiveTextureEnabled?kr.a.PrepareDefinesForMergedUV(this._emissiveTexture,i,"EMISSIVE"):i.EMISSIVE=!1,Wr.a.SpecularTextureEnabled?(this._metallicTexture?(kr.a.PrepareDefinesForMergedUV(this._metallicTexture,i,"REFLECTIVITY"),i.ROUGHNESSSTOREINMETALMAPALPHA=this._useRoughnessFromMetallicTextureAlpha,i.ROUGHNESSSTOREINMETALMAPGREEN=!this._useRoughnessFromMetallicTextureAlpha&&this._useRoughnessFromMetallicTextureGreen,i.METALLNESSSTOREINMETALMAPBLUE=this._useMetallnessFromMetallicTextureBlue,i.AOSTOREINMETALMAPRED=this._useAmbientOcclusionFromMetallicTextureRed):this._reflectivityTexture?(kr.a.PrepareDefinesForMergedUV(this._reflectivityTexture,i,"REFLECTIVITY"),i.MICROSURFACEFROMREFLECTIVITYMAP=this._useMicroSurfaceFromReflectivityMapAlpha,i.MICROSURFACEAUTOMATIC=this._useAutoMicroSurfaceFromReflectivityMap):i.REFLECTIVITY=!1,this._microSurfaceTexture?kr.a.PrepareDefinesForMergedUV(this._microSurfaceTexture,i,"MICROSURFACEMAP"):i.MICROSURFACEMAP=!1):(i.REFLECTIVITY=!1,i.MICROSURFACEMAP=!1),o.getEngine().getCaps().standardDerivatives&&this._bumpTexture&&Wr.a.BumpTextureEnabled&&!this._disableBumpMap?(kr.a.PrepareDefinesForMergedUV(this._bumpTexture,i,"BUMP"),this._useParallax&&this._albedoTexture&&Wr.a.DiffuseTextureEnabled?(i.PARALLAX=!0,i.PARALLAXOCCLUSION=!!this._useParallaxOcclusion):i.PARALLAX=!1,i.OBJECTSPACE_NORMALMAP=this._useObjectSpaceNormalMap):i.BUMP=!1;var c=this._getRefractionTexture();c&&Wr.a.RefractionTextureEnabled?(i.REFRACTION=!0,i.REFRACTIONMAP_3D=c.isCube,i.GAMMAREFRACTION=c.gammaSpace,i.RGBDREFRACTION=c.isRGBD,i.REFRACTIONMAP_OPPOSITEZ=c.invertZ,i.LODINREFRACTIONALPHA=c.lodLevelInAlpha,this._linkRefractionWithTransparency&&(i.LINKREFRACTIONTOTRANSPARENCY=!0)):i.REFRACTION=!1,this._environmentBRDFTexture&&Wr.a.ReflectionTextureEnabled?i.ENVIRONMENTBRDF=!0:i.ENVIRONMENTBRDF=!1,this._shouldUseAlphaFromAlbedoTexture()?i.ALPHAFROMALBEDO=!0:i.ALPHAFROMALBEDO=!1}i.SPECULAROVERALPHA=this._useSpecularOverAlpha,this._lightFalloff===t.LIGHTFALLOFF_STANDARD?(i.USEPHYSICALLIGHTFALLOFF=!1,i.USEGLTFLIGHTFALLOFF=!1):this._lightFalloff===t.LIGHTFALLOFF_GLTF?(i.USEPHYSICALLIGHTFALLOFF=!1,i.USEGLTFLIGHTFALLOFF=!0):(i.USEPHYSICALLIGHTFALLOFF=!0,i.USEGLTFLIGHTFALLOFF=!1),i.RADIANCEOVERALPHA=this._useRadianceOverAlpha,!this.backFaceCulling&&this._twoSidedLighting?i.TWOSIDEDLIGHTING=!0:i.TWOSIDEDLIGHTING=!1,i.ALPHATESTVALUE=this._alphaCutOff+(this._alphaCutOff%1==0?".":""),i.PREMULTIPLYALPHA=this.alphaMode===_.a.ALPHA_PREMULTIPLIED||this.alphaMode===_.a.ALPHA_PREMULTIPLIED_PORTERDUFF,i.ALPHABLEND=this.needAlphaBlendingForMesh(e),i.ALPHAFRESNEL=this._useAlphaFresnel||this._useLinearAlphaFresnel,i.LINEARALPHAFRESNEL=this._useLinearAlphaFresnel,i.SPECULARAA=o.getEngine().getCaps().standardDerivatives&&this._enableSpecularAntiAliasing}i._areImageProcessingDirty&&this._imageProcessingConfiguration&&this._imageProcessingConfiguration.prepareDefines(i),i.FORCENORMALFORWARD=this._forceNormalForward,i.RADIANCEOCCLUSION=this._useRadianceOcclusion,i.HORIZONOCCLUSION=this._useHorizonOcclusion,i._areMiscDirty&&(kr.a.PrepareDefinesForMisc(e,o,this._useLogarithmicDepth,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e)||this._forceAlphaTest,i),i.UNLIT=this._unlit||(this.pointsCloud||this.wireframe)&&!e.isVerticesDataPresent(gi.b.NormalKind)),kr.a.PrepareDefinesForFrameBoundValues(o,s,i,!!r,n),kr.a.PrepareDefinesForAttributes(e,i,!0,!0,!0,this._transparencyMode!==t.PBRMATERIAL_OPAQUE)},t.prototype.forceCompilation=function(e,t,i){var r=this,n=l.a({clipPlane:!1},i),o=new dn,s=this._prepareEffect(e,o,void 0,void 0,void 0,n.clipPlane);s.isReady()?t&&t(this):s.onCompileObservable.add(function(){t&&t(r)})},t.prototype.buildUniformLayout=function(){this._uniformBuffer.addUniform("vAlbedoInfos",2),this._uniformBuffer.addUniform("vAmbientInfos",4),this._uniformBuffer.addUniform("vOpacityInfos",2),this._uniformBuffer.addUniform("vEmissiveInfos",2),this._uniformBuffer.addUniform("vLightmapInfos",2),this._uniformBuffer.addUniform("vReflectivityInfos",3),this._uniformBuffer.addUniform("vMicroSurfaceSamplerInfos",2),this._uniformBuffer.addUniform("vRefractionInfos",4),this._uniformBuffer.addUniform("vReflectionInfos",2),this._uniformBuffer.addUniform("vReflectionPosition",3),this._uniformBuffer.addUniform("vReflectionSize",3),this._uniformBuffer.addUniform("vBumpInfos",3),this._uniformBuffer.addUniform("albedoMatrix",16),this._uniformBuffer.addUniform("ambientMatrix",16),this._uniformBuffer.addUniform("opacityMatrix",16),this._uniformBuffer.addUniform("emissiveMatrix",16),this._uniformBuffer.addUniform("lightmapMatrix",16),this._uniformBuffer.addUniform("reflectivityMatrix",16),this._uniformBuffer.addUniform("microSurfaceSamplerMatrix",16),this._uniformBuffer.addUniform("bumpMatrix",16),this._uniformBuffer.addUniform("vTangentSpaceParams",2),this._uniformBuffer.addUniform("refractionMatrix",16),this._uniformBuffer.addUniform("reflectionMatrix",16),this._uniformBuffer.addUniform("vReflectionColor",3),this._uniformBuffer.addUniform("vAlbedoColor",4),this._uniformBuffer.addUniform("vLightingIntensity",4),this._uniformBuffer.addUniform("vRefractionMicrosurfaceInfos",3),this._uniformBuffer.addUniform("vReflectionMicrosurfaceInfos",3),this._uniformBuffer.addUniform("vReflectivityColor",4),this._uniformBuffer.addUniform("vEmissiveColor",3),this._uniformBuffer.addUniform("pointSize",1),this._uniformBuffer.create()},t.prototype.unbind=function(){this._reflectionTexture&&this._reflectionTexture.isRenderTarget&&this._uniformBuffer.setTexture("reflectionSampler",null),this._refractionTexture&&this._refractionTexture.isRenderTarget&&this._uniformBuffer.setTexture("refractionSampler",null),e.prototype.unbind.call(this)},t.prototype.bindForSubMesh=function(e,i,r){var n=this.getScene(),s=r._materialDefines;if(s){var a=r.effect;if(a){this._activeEffect=a,this.bindOnlyWorldMatrix(e),s.OBJECTSPACE_NORMALMAP&&(e.toNormalMatrix(this._normalMatrix),this.bindOnlyNormalMatrix(this._normalMatrix));var c=this._mustRebind(n,a,i.visibility);kr.a.BindBonesParameters(i,this._activeEffect);var l=null;if(c){this._uniformBuffer.bindToEffect(a,"Material"),this.bindViewProjection(a),l=this._getReflectionTexture();var u=this._getRefractionTexture();if(!this._uniformBuffer.useUbo||!this.isFrozen||!this._uniformBuffer.isSync){if(n.texturesEnabled){if(this._albedoTexture&&Wr.a.DiffuseTextureEnabled&&(this._uniformBuffer.updateFloat2("vAlbedoInfos",this._albedoTexture.coordinatesIndex,this._albedoTexture.level),kr.a.BindTextureMatrix(this._albedoTexture,this._uniformBuffer,"albedo")),this._ambientTexture&&Wr.a.AmbientTextureEnabled&&(this._uniformBuffer.updateFloat4("vAmbientInfos",this._ambientTexture.coordinatesIndex,this._ambientTexture.level,this._ambientTextureStrength,this._ambientTextureImpactOnAnalyticalLights),kr.a.BindTextureMatrix(this._ambientTexture,this._uniformBuffer,"ambient")),this._opacityTexture&&Wr.a.OpacityTextureEnabled&&(this._uniformBuffer.updateFloat2("vOpacityInfos",this._opacityTexture.coordinatesIndex,this._opacityTexture.level),kr.a.BindTextureMatrix(this._opacityTexture,this._uniformBuffer,"opacity")),l&&Wr.a.ReflectionTextureEnabled){if(this._uniformBuffer.updateMatrix("reflectionMatrix",l.getReflectionTextureMatrix()),this._uniformBuffer.updateFloat2("vReflectionInfos",l.level,0),l.boundingBoxSize){var h=l;this._uniformBuffer.updateVector3("vReflectionPosition",h.boundingBoxPosition),this._uniformBuffer.updateVector3("vReflectionSize",h.boundingBoxSize)}var d=l.sphericalPolynomial;s.USESPHERICALFROMREFLECTIONMAP&&d&&(this._activeEffect.setFloat3("vSphericalX",d.x.x,d.x.y,d.x.z),this._activeEffect.setFloat3("vSphericalY",d.y.x,d.y.y,d.y.z),this._activeEffect.setFloat3("vSphericalZ",d.z.x,d.z.y,d.z.z),this._activeEffect.setFloat3("vSphericalXX_ZZ",d.xx.x-d.zz.x,d.xx.y-d.zz.y,d.xx.z-d.zz.z),this._activeEffect.setFloat3("vSphericalYY_ZZ",d.yy.x-d.zz.x,d.yy.y-d.zz.y,d.yy.z-d.zz.z),this._activeEffect.setFloat3("vSphericalZZ",d.zz.x,d.zz.y,d.zz.z),this._activeEffect.setFloat3("vSphericalXY",d.xy.x,d.xy.y,d.xy.z),this._activeEffect.setFloat3("vSphericalYZ",d.yz.x,d.yz.y,d.yz.z),this._activeEffect.setFloat3("vSphericalZX",d.zx.x,d.zx.y,d.zx.z)),this._uniformBuffer.updateFloat3("vReflectionMicrosurfaceInfos",l.getSize().width,l.lodGenerationScale,l.lodGenerationOffset)}if(this._emissiveTexture&&Wr.a.EmissiveTextureEnabled&&(this._uniformBuffer.updateFloat2("vEmissiveInfos",this._emissiveTexture.coordinatesIndex,this._emissiveTexture.level),kr.a.BindTextureMatrix(this._emissiveTexture,this._uniformBuffer,"emissive")),this._lightmapTexture&&Wr.a.LightmapTextureEnabled&&(this._uniformBuffer.updateFloat2("vLightmapInfos",this._lightmapTexture.coordinatesIndex,this._lightmapTexture.level),kr.a.BindTextureMatrix(this._lightmapTexture,this._uniformBuffer,"lightmap")),Wr.a.SpecularTextureEnabled&&(this._metallicTexture?(this._uniformBuffer.updateFloat3("vReflectivityInfos",this._metallicTexture.coordinatesIndex,this._metallicTexture.level,this._ambientTextureStrength),kr.a.BindTextureMatrix(this._metallicTexture,this._uniformBuffer,"reflectivity")):this._reflectivityTexture&&(this._uniformBuffer.updateFloat3("vReflectivityInfos",this._reflectivityTexture.coordinatesIndex,this._reflectivityTexture.level,1),kr.a.BindTextureMatrix(this._reflectivityTexture,this._uniformBuffer,"reflectivity")),this._microSurfaceTexture&&(this._uniformBuffer.updateFloat2("vMicroSurfaceSamplerInfos",this._microSurfaceTexture.coordinatesIndex,this._microSurfaceTexture.level),kr.a.BindTextureMatrix(this._microSurfaceTexture,this._uniformBuffer,"microSurfaceSampler"))),this._bumpTexture&&n.getEngine().getCaps().standardDerivatives&&Wr.a.BumpTextureEnabled&&!this._disableBumpMap&&(this._uniformBuffer.updateFloat3("vBumpInfos",this._bumpTexture.coordinatesIndex,this._bumpTexture.level,this._parallaxScaleBias),kr.a.BindTextureMatrix(this._bumpTexture,this._uniformBuffer,"bump"),n._mirroredCameraPosition?this._uniformBuffer.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?1:-1,this._invertNormalMapY?1:-1):this._uniformBuffer.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?-1:1,this._invertNormalMapY?-1:1)),u&&Wr.a.RefractionTextureEnabled){this._uniformBuffer.updateMatrix("refractionMatrix",u.getReflectionTextureMatrix());var f=1;u.isCube||u.depth&&(f=u.depth),this._uniformBuffer.updateFloat4("vRefractionInfos",u.level,this._indexOfRefraction,f,this._invertRefractionY?-1:1),this._uniformBuffer.updateFloat3("vRefractionMicrosurfaceInfos",u.getSize().width,u.lodGenerationScale,u.lodGenerationOffset)}}this.pointsCloud&&this._uniformBuffer.updateFloat("pointSize",this.pointSize),s.METALLICWORKFLOW?(o.t.Color3[0].r=void 0===this._metallic||null===this._metallic?1:this._metallic,o.t.Color3[0].g=void 0===this._roughness||null===this._roughness?1:this._roughness,this._uniformBuffer.updateColor4("vReflectivityColor",o.t.Color3[0],0)):this._uniformBuffer.updateColor4("vReflectivityColor",this._reflectivityColor,this._microSurface),this._uniformBuffer.updateColor3("vEmissiveColor",Wr.a.EmissiveTextureEnabled?this._emissiveColor:o.e.BlackReadOnly),this._uniformBuffer.updateColor3("vReflectionColor",this._reflectionColor),this._uniformBuffer.updateColor4("vAlbedoColor",this._albedoColor,this.alpha*i.visibility),this._lightingInfos.x=this._directIntensity,this._lightingInfos.y=this._emissiveIntensity,this._lightingInfos.z=this._environmentIntensity,this._lightingInfos.w=this._specularIntensity,this._uniformBuffer.updateVector4("vLightingIntensity",this._lightingInfos)}n.texturesEnabled&&(this._albedoTexture&&Wr.a.DiffuseTextureEnabled&&this._uniformBuffer.setTexture("albedoSampler",this._albedoTexture),this._ambientTexture&&Wr.a.AmbientTextureEnabled&&this._uniformBuffer.setTexture("ambientSampler",this._ambientTexture),this._opacityTexture&&Wr.a.OpacityTextureEnabled&&this._uniformBuffer.setTexture("opacitySampler",this._opacityTexture),l&&Wr.a.ReflectionTextureEnabled&&(s.LODBASEDMICROSFURACE?this._uniformBuffer.setTexture("reflectionSampler",l):(this._uniformBuffer.setTexture("reflectionSampler",l._lodTextureMid||l),this._uniformBuffer.setTexture("reflectionSamplerLow",l._lodTextureLow||l),this._uniformBuffer.setTexture("reflectionSamplerHigh",l._lodTextureHigh||l))),s.ENVIRONMENTBRDF&&this._uniformBuffer.setTexture("environmentBrdfSampler",this._environmentBRDFTexture),u&&Wr.a.RefractionTextureEnabled&&(s.LODBASEDMICROSFURACE?this._uniformBuffer.setTexture("refractionSampler",u):(this._uniformBuffer.setTexture("refractionSampler",u._lodTextureMid||u),this._uniformBuffer.setTexture("refractionSamplerLow",u._lodTextureLow||u),this._uniformBuffer.setTexture("refractionSamplerHigh",u._lodTextureHigh||u))),this._emissiveTexture&&Wr.a.EmissiveTextureEnabled&&this._uniformBuffer.setTexture("emissiveSampler",this._emissiveTexture),this._lightmapTexture&&Wr.a.LightmapTextureEnabled&&this._uniformBuffer.setTexture("lightmapSampler",this._lightmapTexture),Wr.a.SpecularTextureEnabled&&(this._metallicTexture?this._uniformBuffer.setTexture("reflectivitySampler",this._metallicTexture):this._reflectivityTexture&&this._uniformBuffer.setTexture("reflectivitySampler",this._reflectivityTexture),this._microSurfaceTexture&&this._uniformBuffer.setTexture("microSurfaceSampler",this._microSurfaceTexture)),this._bumpTexture&&n.getEngine().getCaps().standardDerivatives&&Wr.a.BumpTextureEnabled&&!this._disableBumpMap&&this._uniformBuffer.setTexture("bumpSampler",this._bumpTexture)),kr.a.BindClipPlane(this._activeEffect,n),n.ambientColor.multiplyToRef(this._ambientColor,this._globalAmbientColor);var p=n._forcedViewPosition?n._forcedViewPosition:n._mirroredCameraPosition?n._mirroredCameraPosition:n.activeCamera.globalPosition,_=n.useRightHandedSystem===(null!=n._mirroredCameraPosition);a.setFloat4("vEyePosition",p.x,p.y,p.z,_?-1:1),a.setColor3("vAmbientColor",this._globalAmbientColor)}!c&&this.isFrozen||(n.lightsEnabled&&!this._disableLighting&&kr.a.BindLights(n,i,this._activeEffect,s,this._maxSimultaneousLights,this._lightFalloff!==t.LIGHTFALLOFF_STANDARD),(n.fogEnabled&&i.applyFog&&n.fogMode!==W.a.FOGMODE_NONE||l)&&this.bindView(a),kr.a.BindFogParameters(n,i,this._activeEffect,!0),s.NUM_MORPH_INFLUENCERS&&kr.a.BindMorphTargetParameters(i,this._activeEffect),this._imageProcessingConfiguration.bind(this._activeEffect),kr.a.BindLogDepth(s,this._activeEffect,n)),this._uniformBuffer.update(),this._afterBind(i,this._activeEffect)}}},t.prototype.getAnimatables=function(){var e=[];return this._albedoTexture&&this._albedoTexture.animations&&this._albedoTexture.animations.length>0&&e.push(this._albedoTexture),this._ambientTexture&&this._ambientTexture.animations&&this._ambientTexture.animations.length>0&&e.push(this._ambientTexture),this._opacityTexture&&this._opacityTexture.animations&&this._opacityTexture.animations.length>0&&e.push(this._opacityTexture),this._reflectionTexture&&this._reflectionTexture.animations&&this._reflectionTexture.animations.length>0&&e.push(this._reflectionTexture),this._emissiveTexture&&this._emissiveTexture.animations&&this._emissiveTexture.animations.length>0&&e.push(this._emissiveTexture),this._metallicTexture&&this._metallicTexture.animations&&this._metallicTexture.animations.length>0?e.push(this._metallicTexture):this._reflectivityTexture&&this._reflectivityTexture.animations&&this._reflectivityTexture.animations.length>0&&e.push(this._reflectivityTexture),this._bumpTexture&&this._bumpTexture.animations&&this._bumpTexture.animations.length>0&&e.push(this._bumpTexture),this._lightmapTexture&&this._lightmapTexture.animations&&this._lightmapTexture.animations.length>0&&e.push(this._lightmapTexture),this._refractionTexture&&this._refractionTexture.animations&&this._refractionTexture.animations.length>0&&e.push(this._refractionTexture),e},t.prototype._getReflectionTexture=function(){return this._reflectionTexture?this._reflectionTexture:this.getScene().environmentTexture},t.prototype._getRefractionTexture=function(){return this._refractionTexture?this._refractionTexture:this._linkRefractionWithTransparency?this.getScene().environmentTexture:null},t.prototype.dispose=function(t,i){i&&(this._albedoTexture&&this._albedoTexture.dispose(),this._ambientTexture&&this._ambientTexture.dispose(),this._opacityTexture&&this._opacityTexture.dispose(),this._reflectionTexture&&this._reflectionTexture.dispose(),this._environmentBRDFTexture&&this.getScene()._environmentBRDFTexture!==this._environmentBRDFTexture&&this._environmentBRDFTexture.dispose(),this._emissiveTexture&&this._emissiveTexture.dispose(),this._metallicTexture&&this._metallicTexture.dispose(),this._reflectivityTexture&&this._reflectivityTexture.dispose(),this._bumpTexture&&this._bumpTexture.dispose(),this._lightmapTexture&&this._lightmapTexture.dispose(),this._refractionTexture&&this._refractionTexture.dispose()),this._renderTargets.dispose(),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),e.prototype.dispose.call(this,t,i)},t.PBRMATERIAL_OPAQUE=0,t.PBRMATERIAL_ALPHATEST=1,t.PBRMATERIAL_ALPHABLEND=2,t.PBRMATERIAL_ALPHATESTANDBLEND=3,t.DEFAULT_AO_ON_ANALYTICAL_LIGHTS=1,t.LIGHTFALLOFF_PHYSICAL=0,t.LIGHTFALLOFF_GLTF=1,t.LIGHTFALLOFF_STANDARD=2,l.c([Object(w.i)()],t.prototype,"_imageProcessingConfiguration",void 0),l.c([Object(w.c)()],t.prototype,"useLogarithmicDepth",null),l.c([Object(w.c)()],t.prototype,"transparencyMode",null),t}(jr.a),pn=function(e){function t(i,r){var n=e.call(this,i,r)||this;return n.directIntensity=1,n.emissiveIntensity=1,n.environmentIntensity=1,n.specularIntensity=1,n.disableBumpMap=!1,n.ambientTextureStrength=1,n.ambientTextureImpactOnAnalyticalLights=t.DEFAULT_AO_ON_ANALYTICAL_LIGHTS,n.ambientColor=new o.e(0,0,0),n.albedoColor=new o.e(1,1,1),n.reflectivityColor=new o.e(1,1,1),n.reflectionColor=new o.e(1,1,1),n.emissiveColor=new o.e(0,0,0),n.microSurface=1,n.indexOfRefraction=.66,n.invertRefractionY=!1,n.linkRefractionWithTransparency=!1,n.useLightmapAsShadowmap=!1,n.useAlphaFromAlbedoTexture=!1,n.forceAlphaTest=!1,n.alphaCutOff=.4,n.useSpecularOverAlpha=!0,n.useMicroSurfaceFromReflectivityMapAlpha=!1,n.useRoughnessFromMetallicTextureAlpha=!0,n.useRoughnessFromMetallicTextureGreen=!1,n.useMetallnessFromMetallicTextureBlue=!1,n.useAmbientOcclusionFromMetallicTextureRed=!1,n.useAmbientInGrayScale=!1,n.useAutoMicroSurfaceFromReflectivityMap=!1,n.useRadianceOverAlpha=!0,n.useObjectSpaceNormalMap=!1,n.useParallax=!1,n.useParallaxOcclusion=!1,n.parallaxScaleBias=.05,n.disableLighting=!1,n.forceIrradianceInFragment=!1,n.maxSimultaneousLights=4,n.invertNormalMapX=!1,n.invertNormalMapY=!1,n.twoSidedLighting=!1,n.useAlphaFresnel=!1,n.useLinearAlphaFresnel=!1,n.environmentBRDFTexture=null,n.forceNormalForward=!1,n.enableSpecularAntiAliasing=!1,n.useHorizonOcclusion=!0,n.useRadianceOcclusion=!0,n.unlit=!1,n._environmentBRDFTexture=rn.GetEnvironmentBRDFTexture(r),n}return l.d(t,e),Object.defineProperty(t.prototype,"usePhysicalLightFalloff",{get:function(){return this._lightFalloff===fn.LIGHTFALLOFF_PHYSICAL},set:function(e){e!==this.usePhysicalLightFalloff&&(this._markAllSubMeshesAsTexturesDirty(),this._lightFalloff=e?fn.LIGHTFALLOFF_PHYSICAL:fn.LIGHTFALLOFF_STANDARD)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useGLTFLightFalloff",{get:function(){return this._lightFalloff===fn.LIGHTFALLOFF_GLTF},set:function(e){e!==this.useGLTFLightFalloff&&(this._markAllSubMeshesAsTexturesDirty(),this._lightFalloff=e?fn.LIGHTFALLOFF_GLTF:fn.LIGHTFALLOFF_STANDARD)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"imageProcessingConfiguration",{get:function(){return this._imageProcessingConfiguration},set:function(e){this._attachImageProcessingConfiguration(e),this._markAllSubMeshesAsTexturesDirty()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"cameraColorCurvesEnabled",{get:function(){return this.imageProcessingConfiguration.colorCurvesEnabled},set:function(e){this.imageProcessingConfiguration.colorCurvesEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"cameraColorGradingEnabled",{get:function(){return this.imageProcessingConfiguration.colorGradingEnabled},set:function(e){this.imageProcessingConfiguration.colorGradingEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"cameraToneMappingEnabled",{get:function(){return this._imageProcessingConfiguration.toneMappingEnabled},set:function(e){this._imageProcessingConfiguration.toneMappingEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"cameraExposure",{get:function(){return this._imageProcessingConfiguration.exposure},set:function(e){this._imageProcessingConfiguration.exposure=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"cameraContrast",{get:function(){return this._imageProcessingConfiguration.contrast},set:function(e){this._imageProcessingConfiguration.contrast=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"cameraColorGradingTexture",{get:function(){return this._imageProcessingConfiguration.colorGradingTexture},set:function(e){this._imageProcessingConfiguration.colorGradingTexture=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"cameraColorCurves",{get:function(){return this._imageProcessingConfiguration.colorCurves},set:function(e){this._imageProcessingConfiguration.colorCurves=e},enumerable:!0,configurable:!0}),t.prototype.getClassName=function(){return"PBRMaterial"},t.prototype.getActiveTextures=function(){var t=e.prototype.getActiveTextures.call(this);return this._albedoTexture&&t.push(this._albedoTexture),this._ambientTexture&&t.push(this._ambientTexture),this._opacityTexture&&t.push(this._opacityTexture),this._reflectionTexture&&t.push(this._reflectionTexture),this._emissiveTexture&&t.push(this._emissiveTexture),this._reflectivityTexture&&t.push(this._reflectivityTexture),this._metallicTexture&&t.push(this._metallicTexture),this._microSurfaceTexture&&t.push(this._microSurfaceTexture),this._bumpTexture&&t.push(this._bumpTexture),this._lightmapTexture&&t.push(this._lightmapTexture),this._refractionTexture&&t.push(this._refractionTexture),t},t.prototype.hasTexture=function(t){return!!e.prototype.hasTexture.call(this,t)||(this._albedoTexture===t||(this._ambientTexture===t||(this._opacityTexture===t||(this._reflectionTexture===t||(this._reflectivityTexture===t||(this._metallicTexture===t||(this._microSurfaceTexture===t||(this._bumpTexture===t||(this._lightmapTexture===t||this._refractionTexture===t)))))))))},t.prototype.clone=function(e){var i=this,r=w.a.Clone(function(){return new t(e,i.getScene())},this);return r.id=e,r.name=e,r},t.prototype.serialize=function(){var e=w.a.Serialize(this);return e.customType="BABYLON.PBRMaterial",e},t.Parse=function(e,i,r){return w.a.Parse(function(){return new t(e.name,i)},e,i,r)},t.PBRMATERIAL_OPAQUE=fn.PBRMATERIAL_OPAQUE,t.PBRMATERIAL_ALPHATEST=fn.PBRMATERIAL_ALPHATEST,t.PBRMATERIAL_ALPHABLEND=fn.PBRMATERIAL_ALPHABLEND,t.PBRMATERIAL_ALPHATESTANDBLEND=fn.PBRMATERIAL_ALPHATESTANDBLEND,t.DEFAULT_AO_ON_ANALYTICAL_LIGHTS=fn.DEFAULT_AO_ON_ANALYTICAL_LIGHTS,l.c([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"directIntensity",void 0),l.c([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"emissiveIntensity",void 0),l.c([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"environmentIntensity",void 0),l.c([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"specularIntensity",void 0),l.c([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"disableBumpMap",void 0),l.c([Object(w.l)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"albedoTexture",void 0),l.c([Object(w.l)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"ambientTexture",void 0),l.c([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"ambientTextureStrength",void 0),l.c([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"ambientTextureImpactOnAnalyticalLights",void 0),l.c([Object(w.l)(),Object(w.b)("_markAllSubMeshesAsTexturesAndMiscDirty")],t.prototype,"opacityTexture",void 0),l.c([Object(w.l)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionTexture",void 0),l.c([Object(w.l)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"emissiveTexture",void 0),l.c([Object(w.l)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectivityTexture",void 0),l.c([Object(w.l)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"metallicTexture",void 0),l.c([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"metallic",void 0),l.c([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"roughness",void 0),l.c([Object(w.l)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"microSurfaceTexture",void 0),l.c([Object(w.l)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"bumpTexture",void 0),l.c([Object(w.l)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty",null)],t.prototype,"lightmapTexture",void 0),l.c([Object(w.l)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"refractionTexture",void 0),l.c([Object(w.e)("ambient"),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"ambientColor",void 0),l.c([Object(w.e)("albedo"),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"albedoColor",void 0),l.c([Object(w.e)("reflectivity"),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectivityColor",void 0),l.c([Object(w.e)("reflection"),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionColor",void 0),l.c([Object(w.e)("emissive"),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"emissiveColor",void 0),l.c([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"microSurface",void 0),l.c([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"indexOfRefraction",void 0),l.c([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"invertRefractionY",void 0),l.c([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"linkRefractionWithTransparency",void 0),l.c([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useLightmapAsShadowmap",void 0),l.c([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesAndMiscDirty")],t.prototype,"useAlphaFromAlbedoTexture",void 0),l.c([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesAndMiscDirty")],t.prototype,"forceAlphaTest",void 0),l.c([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesAndMiscDirty")],t.prototype,"alphaCutOff",void 0),l.c([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useSpecularOverAlpha",void 0),l.c([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useMicroSurfaceFromReflectivityMapAlpha",void 0),l.c([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRoughnessFromMetallicTextureAlpha",void 0),l.c([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRoughnessFromMetallicTextureGreen",void 0),l.c([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useMetallnessFromMetallicTextureBlue",void 0),l.c([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAmbientOcclusionFromMetallicTextureRed",void 0),l.c([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAmbientInGrayScale",void 0),l.c([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAutoMicroSurfaceFromReflectivityMap",void 0),l.c([Object(w.c)()],t.prototype,"usePhysicalLightFalloff",null),l.c([Object(w.c)()],t.prototype,"useGLTFLightFalloff",null),l.c([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRadianceOverAlpha",void 0),l.c([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useObjectSpaceNormalMap",void 0),l.c([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useParallax",void 0),l.c([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useParallaxOcclusion",void 0),l.c([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"parallaxScaleBias",void 0),l.c([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsLightsDirty")],t.prototype,"disableLighting",void 0),l.c([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"forceIrradianceInFragment",void 0),l.c([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsLightsDirty")],t.prototype,"maxSimultaneousLights",void 0),l.c([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"invertNormalMapX",void 0),l.c([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"invertNormalMapY",void 0),l.c([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"twoSidedLighting",void 0),l.c([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAlphaFresnel",void 0),l.c([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useLinearAlphaFresnel",void 0),l.c([Object(w.l)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"environmentBRDFTexture",void 0),l.c([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"forceNormalForward",void 0),l.c([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"enableSpecularAntiAliasing",void 0),l.c([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useHorizonOcclusion",void 0),l.c([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRadianceOcclusion",void 0),l.c([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsMiscDirty")],t.prototype,"unlit",void 0),t}(fn);s.a.RegisteredTypes["BABYLON.PBRMaterial"]=pn;W.a.prototype.createDefaultLight=function(e){if(void 0===e&&(e=!1),e&&this.lights)for(var t=0;t<this.lights.length;t++)this.lights[t].dispose();0===this.lights.length&&new ni("default light",o.x.Up(),this)},W.a.prototype.createDefaultCamera=function(e,t,i){if(void 0===e&&(e=!1),void 0===t&&(t=!1),void 0===i&&(i=!1),t&&this.activeCamera&&(this.activeCamera.dispose(),this.activeCamera=null),!this.activeCamera){var r,n=this.getWorldExtends(),s=n.max.subtract(n.min),a=n.min.add(s.scale(.5)),c=1.5*s.length();if(isFinite(c)||(c=1,a.copyFromFloats(0,0,0)),e){var l=new _t("default camera",-Math.PI/2,Math.PI/2,c,a,this);l.lowerRadiusLimit=.01*c,l.wheelPrecision=100/c,r=l}else{var u=new ft("default camera",new o.x(a.x,a.y,-c),this);u.setTarget(a),r=u}r.minZ=.01*c,r.maxZ=1e3*c,r.speed=.2*c,this.activeCamera=r;var h=this.getEngine().getRenderingCanvas();i&&h&&r.attachControl(h)}},W.a.prototype.createDefaultCameraOrLight=function(e,t,i){void 0===e&&(e=!1),void 0===t&&(t=!1),void 0===i&&(i=!1),this.createDefaultLight(t),this.createDefaultCamera(e,t,i)},W.a.prototype.createDefaultSkybox=function(e,t,i,r,n){if(void 0===t&&(t=!1),void 0===i&&(i=1e3),void 0===r&&(r=0),void 0===n&&(n=!0),!e)return p.a.Warn("Can not create default skybox without environment texture."),null;n&&e&&(this.environmentTexture=e);var o=de.a.CreateBox("hdrSkyBox",i,this);if(t){var s=new pn("skyBox",this);s.backFaceCulling=!1,s.reflectionTexture=e.clone(),s.reflectionTexture&&(s.reflectionTexture.coordinatesMode=Ve.a.SKYBOX_MODE),s.microSurface=1-r,s.disableLighting=!0,s.twoSidedLighting=!0,o.infiniteDistance=!0,o.material=s}else{var a=new hi.a("skyBox",this);a.backFaceCulling=!1,a.reflectionTexture=e.clone(),a.reflectionTexture&&(a.reflectionTexture.coordinatesMode=Ve.a.SKYBOX_MODE),a.disableLighting=!0,o.infiniteDistance=!0,o.material=a}return o.isPickable=!1,o},W.a.prototype.createDefaultEnvironment=function(e){return $r?new $r(e,this):null},W.a.prototype.createDefaultVRExperience=function(e){return void 0===e&&(e={}),new Ai(this,e)},W.a.prototype.createDefaultXRExperienceAsync=function(){var e=this;return wi.CreateAsync(this).then(function(t){var i=new Vi(t);return Ni.CreateAsync(e,t,{outputCanvasContext:i.canvasContext}).then(function(e){return new Ui(t),t})})};var _n=function(e){function t(t,i,r,n,o,s,a){void 0===n&&(n=!1),void 0===o&&(o=!1),void 0===s&&(s=Ve.a.TRILINEAR_SAMPLINGMODE),void 0===a&&(a={autoPlay:!0,loop:!0,autoUpdateTexture:!0});var c=e.call(this,null,r,!n,o)||this;c._onUserActionRequestedObservable=null,c._stillImageCaptured=!1,c._displayingPosterTexture=!1,c._createInternalTexture=function(){if(null!=c._texture){if(!c._displayingPosterTexture)return;c._texture.dispose(),c._displayingPosterTexture=!1}if(!c._engine.needPOTTextures||ve.h.IsExponentOfTwo(c.video.videoWidth)&&ve.h.IsExponentOfTwo(c.video.videoHeight)?(c.wrapU=Ve.a.WRAP_ADDRESSMODE,c.wrapV=Ve.a.WRAP_ADDRESSMODE):(c.wrapU=Ve.a.CLAMP_ADDRESSMODE,c.wrapV=Ve.a.CLAMP_ADDRESSMODE,c._generateMipMaps=!1),c._texture=c._engine.createDynamicTexture(c.video.videoWidth,c.video.videoHeight,c._generateMipMaps,c.samplingMode),c.video.autoplay||c._settings.poster)c._texture.isReady=!0,c._updateInternalTexture(),c.onLoadObservable.hasObservers()&&c.onLoadObservable.notifyObservers(c);else{var e=c.video.onplaying,t=!1;c.video.onplaying=function(){c.video.onplaying=e,c._texture.isReady=!0,c._updateInternalTexture(),t||c.video.pause(),c.onLoadObservable.hasObservers()&&c.onLoadObservable.notifyObservers(c)};var i=c.video.play();i?i.then(function(){}).catch(function(){t=!0,c._onUserActionRequestedObservable&&c._onUserActionRequestedObservable.hasObservers()&&c._onUserActionRequestedObservable.notifyObservers(c)}):(c.video.onplaying=e,c._texture.isReady=!0,c._updateInternalTexture(),c.onLoadObservable.hasObservers()&&c.onLoadObservable.notifyObservers(c))}},c.reset=function(){null!=c._texture&&(c._displayingPosterTexture||(c._texture.dispose(),c._texture=null))},c._updateInternalTexture=function(){null!=c._texture&&c._texture.isReady&&(c.video.readyState<c.video.HAVE_CURRENT_DATA||c._displayingPosterTexture||c._engine.updateVideoTexture(c._texture,c.video,c._invertY))},c._engine=c.getScene().getEngine(),c._generateMipMaps=n,c._initialSamplingMode=s,c.autoUpdateTexture=a.autoUpdateTexture,c.name=t||c._getName(i),c.video=c._getVideo(i),c._settings=a,a.poster&&(c.video.poster=a.poster),void 0!==a.autoPlay&&(c.video.autoplay=a.autoPlay),void 0!==a.loop&&(c.video.loop=a.loop),c.video.setAttribute("playsinline",""),c.video.addEventListener("paused",c._updateInternalTexture),c.video.addEventListener("seeked",c._updateInternalTexture),c.video.addEventListener("emptied",c.reset),c._createInternalTextureOnEvent=a.poster&&!a.autoPlay?"play":"canplay",c.video.addEventListener(c._createInternalTextureOnEvent,c._createInternalTexture);var l=c.video.readyState>=c.video.HAVE_CURRENT_DATA;return!a.poster||a.autoPlay&&l?l&&c._createInternalTexture():(c._texture=c._engine.createTexture(a.poster,!1,!0,r),c._displayingPosterTexture=!0),c}return l.d(t,e),Object.defineProperty(t.prototype,"onUserActionRequestedObservable",{get:function(){return this._onUserActionRequestedObservable||(this._onUserActionRequestedObservable=new n.c),this._onUserActionRequestedObservable},enumerable:!0,configurable:!0}),t.prototype._getName=function(e){return e instanceof HTMLVideoElement?e.currentSrc:"object"==typeof e?e.toString():e},t.prototype._getVideo=function(e){if(e instanceof HTMLVideoElement)return ve.h.SetCorsBehavior(e.currentSrc,e),e;var t=document.createElement("video");return"string"==typeof e?(ve.h.SetCorsBehavior(e,t),t.src=e):(ve.h.SetCorsBehavior(e[0],t),e.forEach(function(e){var i=document.createElement("source");i.src=e,t.appendChild(i)})),t},t.prototype._rebuild=function(){this.update()},t.prototype.update=function(){this.autoUpdateTexture&&this.updateTexture(!0)},t.prototype.updateTexture=function(e){e&&(this.video.paused&&this._stillImageCaptured||(this._stillImageCaptured=!0,this._updateInternalTexture()))},t.prototype.updateURL=function(e){this.video.src=e},t.prototype.dispose=function(){e.prototype.dispose.call(this),this._onUserActionRequestedObservable&&(this._onUserActionRequestedObservable.clear(),this._onUserActionRequestedObservable=null),this.video.removeEventListener(this._createInternalTextureOnEvent,this._createInternalTexture),this.video.removeEventListener("paused",this._updateInternalTexture),this.video.removeEventListener("seeked",this._updateInternalTexture),this.video.removeEventListener("emptied",this.reset),this.video.pause()},t.CreateFromWebCam=function(e,i,r){var n,o=document.createElement("video");o.setAttribute("autoplay",""),o.setAttribute("muted",""),o.setAttribute("playsinline",""),r&&r.deviceId&&(n={exact:r.deviceId}),window.URL=window.URL||window.webkitURL||window.mozURL||window.msURL,navigator.mediaDevices?navigator.mediaDevices.getUserMedia({video:r}).then(function(r){void 0!==o.mozSrcObject?o.mozSrcObject=r:o.srcObject=r;var n=function(){i&&i(new t("video",o,e,!0,!0)),o.removeEventListener("playing",n)};o.addEventListener("playing",n),o.play()}).catch(function(e){p.a.Error(e.name)}):(navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia,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!==o.mozSrcObject?o.mozSrcObject=r:o.src=window.URL&&window.URL.createObjectURL(r)||r,o.play(),i&&i(new t("video",o,e,!0,!0))},function(e){p.a.Error(e.name)}))},t}(Ve.a),gn=function(e){function t(t,i,r,n){var o=e.call(this,t,n)||this;o._useDirectMapping=!1,t=t||"videoDome",r.resolution=0|Math.abs(r.resolution)||32,r.clickToPlay=Boolean(r.clickToPlay),r.autoPlay=void 0===r.autoPlay||Boolean(r.autoPlay),r.loop=void 0===r.loop||Boolean(r.loop),r.size=Math.abs(r.size)||(n.activeCamera?.48*n.activeCamera.maxZ:1e3),void 0===r.useDirectMapping?o._useDirectMapping=!0:o._useDirectMapping=r.useDirectMapping,o._setReady(!1);var s={loop:r.loop,autoPlay:r.autoPlay,autoUpdateTexture:!0,poster:r.poster},a=o._material=new Zr(t+"_material",n),c=o._videoTexture=new _n(t+"_texture",i,n,!1,o._useDirectMapping,Ve.a.TRILINEAR_SAMPLINGMODE,s);return o._mesh=de.a.CreateSphere(t+"_mesh",r.resolution,r.size,n,!1,de.a.BACKSIDE),c.onLoadObservable.addOnce(function(){o._setReady(!0)}),a.useEquirectangularFOV=!0,a.fovMultiplier=1,a.opacityFresnel=!1,o._useDirectMapping?(c.wrapU=Ve.a.CLAMP_ADDRESSMODE,c.wrapV=Ve.a.CLAMP_ADDRESSMODE,a.diffuseTexture=c):(c.coordinatesMode=Ve.a.FIXED_EQUIRECTANGULAR_MIRRORED_MODE,c.wrapV=Ve.a.CLAMP_ADDRESSMODE,a.reflectionTexture=c),o._mesh.material=a,o._mesh.parent=o,r.clickToPlay&&(n.onPointerUp=function(){o._videoTexture.video.play()}),o}return l.d(t,e),Object.defineProperty(t.prototype,"videoTexture",{get:function(){return this._videoTexture},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"fovMultiplier",{get:function(){return this._material.fovMultiplier},set:function(e){this._material.fovMultiplier=e},enumerable:!0,configurable:!0}),t.prototype.dispose=function(t,i){void 0===i&&(i=!1),this._videoTexture.dispose(),this._mesh.dispose(),this._material.dispose(),e.prototype.dispose.call(this,t,i)},t}(en.a),mn=function(){function e(e){this.engine=e,this._captureGPUFrameTime=!1,this._gpuFrameTime=new ve.f,this._captureShaderCompilationTime=!1,this._shaderCompilationTime=new ve.f,this._onBeginFrameObserver=null,this._onEndFrameObserver=null,this._onBeforeShaderCompilationObserver=null,this._onAfterShaderCompilationObserver=null}return Object.defineProperty(e.prototype,"gpuFrameTimeCounter",{get:function(){return this._gpuFrameTime},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"captureGPUFrameTime",{get:function(){return this._captureGPUFrameTime},set:function(e){var t=this;e!==this._captureGPUFrameTime&&(this._captureGPUFrameTime=e,e?(this._onBeginFrameObserver=this.engine.onBeginFrameObservable.add(function(){t._gpuFrameTimeToken||(t._gpuFrameTimeToken=t.engine.startTimeQuery())}),this._onEndFrameObserver=this.engine.onEndFrameObservable.add(function(){if(t._gpuFrameTimeToken){var e=t.engine.endTimeQuery(t._gpuFrameTimeToken);e>-1&&(t._gpuFrameTimeToken=null,t._gpuFrameTime.fetchNewFrame(),t._gpuFrameTime.addCount(e,!0))}})):(this.engine.onBeginFrameObservable.remove(this._onBeginFrameObserver),this._onBeginFrameObserver=null,this.engine.onEndFrameObservable.remove(this._onEndFrameObserver),this._onEndFrameObserver=null))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"shaderCompilationTimeCounter",{get:function(){return this._shaderCompilationTime},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"captureShaderCompilationTime",{get:function(){return this._captureShaderCompilationTime},set:function(e){var t=this;e!==this._captureShaderCompilationTime&&(this._captureShaderCompilationTime=e,e?(this._onBeforeShaderCompilationObserver=this.engine.onBeforeShaderCompilationObservable.add(function(){t._shaderCompilationTime.fetchNewFrame(),t._shaderCompilationTime.beginMonitoring()}),this._onAfterShaderCompilationObserver=this.engine.onAfterShaderCompilationObservable.add(function(){t._shaderCompilationTime.endMonitoring()})):(this.engine.onBeforeShaderCompilationObservable.remove(this._onBeforeShaderCompilationObserver),this._onBeforeShaderCompilationObserver=null,this.engine.onAfterShaderCompilationObservable.remove(this._onAfterShaderCompilationObserver),this._onAfterShaderCompilationObserver=null))},enumerable:!0,configurable:!0}),e.prototype.dispose=function(){this.engine.onBeginFrameObservable.remove(this._onBeginFrameObserver),this._onBeginFrameObserver=null,this.engine.onEndFrameObservable.remove(this._onEndFrameObserver),this._onEndFrameObserver=null,this.engine.onBeforeShaderCompilationObservable.remove(this._onBeforeShaderCompilationObserver),this._onBeforeShaderCompilationObserver=null,this.engine.onAfterShaderCompilationObservable.remove(this._onAfterShaderCompilationObserver),this._onAfterShaderCompilationObserver=null,this.engine=null},e}(),vn=function(){function e(e){var t=this;this.scene=e,this._captureActiveMeshesEvaluationTime=!1,this._activeMeshesEvaluationTime=new ve.f,this._captureRenderTargetsRenderTime=!1,this._renderTargetsRenderTime=new ve.f,this._captureFrameTime=!1,this._frameTime=new ve.f,this._captureRenderTime=!1,this._renderTime=new ve.f,this._captureInterFrameTime=!1,this._interFrameTime=new ve.f,this._captureParticlesRenderTime=!1,this._particlesRenderTime=new ve.f,this._captureSpritesRenderTime=!1,this._spritesRenderTime=new ve.f,this._capturePhysicsTime=!1,this._physicsTime=new ve.f,this._captureAnimationsTime=!1,this._animationsTime=new ve.f,this._captureCameraRenderTime=!1,this._cameraRenderTime=new ve.f,this._onBeforeActiveMeshesEvaluationObserver=null,this._onAfterActiveMeshesEvaluationObserver=null,this._onBeforeRenderTargetsRenderObserver=null,this._onAfterRenderTargetsRenderObserver=null,this._onAfterRenderObserver=null,this._onBeforeDrawPhaseObserver=null,this._onAfterDrawPhaseObserver=null,this._onBeforeAnimationsObserver=null,this._onBeforeParticlesRenderingObserver=null,this._onAfterParticlesRenderingObserver=null,this._onBeforeSpritesRenderingObserver=null,this._onAfterSpritesRenderingObserver=null,this._onBeforePhysicsObserver=null,this._onAfterPhysicsObserver=null,this._onAfterAnimationsObserver=null,this._onBeforeCameraRenderObserver=null,this._onAfterCameraRenderObserver=null,this._onBeforeAnimationsObserver=e.onBeforeAnimationsObservable.add(function(){t._captureActiveMeshesEvaluationTime&&t._activeMeshesEvaluationTime.fetchNewFrame(),t._captureRenderTargetsRenderTime&&t._renderTargetsRenderTime.fetchNewFrame(),t._captureFrameTime&&(ve.h.StartPerformanceCounter("Scene rendering"),t._frameTime.beginMonitoring()),t._captureInterFrameTime&&t._interFrameTime.endMonitoring(),t._captureParticlesRenderTime&&t._particlesRenderTime.fetchNewFrame(),t._captureSpritesRenderTime&&t._spritesRenderTime.fetchNewFrame(),t._captureAnimationsTime&&t._animationsTime.beginMonitoring(),t.scene.getEngine()._drawCalls.fetchNewFrame(),t.scene.getEngine()._textureCollisions.fetchNewFrame()}),this._onAfterRenderObserver=e.onAfterRenderObservable.add(function(){t._captureFrameTime&&(ve.h.EndPerformanceCounter("Scene rendering"),t._frameTime.endMonitoring()),t._captureRenderTime&&t._renderTime.endMonitoring(!1),t._captureInterFrameTime&&t._interFrameTime.beginMonitoring()})}return Object.defineProperty(e.prototype,"activeMeshesEvaluationTimeCounter",{get:function(){return this._activeMeshesEvaluationTime},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"captureActiveMeshesEvaluationTime",{get:function(){return this._captureActiveMeshesEvaluationTime},set:function(e){var t=this;e!==this._captureActiveMeshesEvaluationTime&&(this._captureActiveMeshesEvaluationTime=e,e?(this._onBeforeActiveMeshesEvaluationObserver=this.scene.onBeforeActiveMeshesEvaluationObservable.add(function(){ve.h.StartPerformanceCounter("Active meshes evaluation"),t._activeMeshesEvaluationTime.beginMonitoring()}),this._onAfterActiveMeshesEvaluationObserver=this.scene.onAfterActiveMeshesEvaluationObservable.add(function(){ve.h.EndPerformanceCounter("Active meshes evaluation"),t._activeMeshesEvaluationTime.endMonitoring()})):(this.scene.onBeforeActiveMeshesEvaluationObservable.remove(this._onBeforeActiveMeshesEvaluationObserver),this._onBeforeActiveMeshesEvaluationObserver=null,this.scene.onAfterActiveMeshesEvaluationObservable.remove(this._onAfterActiveMeshesEvaluationObserver),this._onAfterActiveMeshesEvaluationObserver=null))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"renderTargetsRenderTimeCounter",{get:function(){return this._renderTargetsRenderTime},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"captureRenderTargetsRenderTime",{get:function(){return this._captureRenderTargetsRenderTime},set:function(e){var t=this;e!==this._captureRenderTargetsRenderTime&&(this._captureRenderTargetsRenderTime=e,e?(this._onBeforeRenderTargetsRenderObserver=this.scene.onBeforeRenderTargetsRenderObservable.add(function(){ve.h.StartPerformanceCounter("Render targets rendering"),t._renderTargetsRenderTime.beginMonitoring()}),this._onAfterRenderTargetsRenderObserver=this.scene.onAfterRenderTargetsRenderObservable.add(function(){ve.h.EndPerformanceCounter("Render targets rendering"),t._renderTargetsRenderTime.endMonitoring(!1)})):(this.scene.onBeforeRenderTargetsRenderObservable.remove(this._onBeforeRenderTargetsRenderObserver),this._onBeforeRenderTargetsRenderObserver=null,this.scene.onAfterRenderTargetsRenderObservable.remove(this._onAfterRenderTargetsRenderObserver),this._onAfterRenderTargetsRenderObserver=null))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"particlesRenderTimeCounter",{get:function(){return this._particlesRenderTime},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"captureParticlesRenderTime",{get:function(){return this._captureParticlesRenderTime},set:function(e){var t=this;e!==this._captureParticlesRenderTime&&(this._captureParticlesRenderTime=e,e?(this._onBeforeParticlesRenderingObserver=this.scene.onBeforeParticlesRenderingObservable.add(function(){ve.h.StartPerformanceCounter("Particles"),t._particlesRenderTime.beginMonitoring()}),this._onAfterParticlesRenderingObserver=this.scene.onAfterParticlesRenderingObservable.add(function(){ve.h.EndPerformanceCounter("Particles"),t._particlesRenderTime.endMonitoring(!1)})):(this.scene.onBeforeParticlesRenderingObservable.remove(this._onBeforeParticlesRenderingObserver),this._onBeforeParticlesRenderingObserver=null,this.scene.onAfterParticlesRenderingObservable.remove(this._onAfterParticlesRenderingObserver),this._onAfterParticlesRenderingObserver=null))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"spritesRenderTimeCounter",{get:function(){return this._spritesRenderTime},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"captureSpritesRenderTime",{get:function(){return this._captureSpritesRenderTime},set:function(e){var t=this;e!==this._captureSpritesRenderTime&&(this._captureSpritesRenderTime=e,this.scene.spriteManagers&&(e?(this._onBeforeSpritesRenderingObserver=this.scene.onBeforeSpritesRenderingObservable.add(function(){ve.h.StartPerformanceCounter("Sprites"),t._spritesRenderTime.beginMonitoring()}),this._onAfterSpritesRenderingObserver=this.scene.onAfterSpritesRenderingObservable.add(function(){ve.h.EndPerformanceCounter("Sprites"),t._spritesRenderTime.endMonitoring(!1)})):(this.scene.onBeforeSpritesRenderingObservable.remove(this._onBeforeSpritesRenderingObserver),this._onBeforeSpritesRenderingObserver=null,this.scene.onAfterSpritesRenderingObservable.remove(this._onAfterSpritesRenderingObserver),this._onAfterSpritesRenderingObserver=null)))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"physicsTimeCounter",{get:function(){return this._physicsTime},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"capturePhysicsTime",{get:function(){return this._capturePhysicsTime},set:function(e){var t=this;e!==this._capturePhysicsTime&&this.scene.onBeforePhysicsObservable&&(this._capturePhysicsTime=e,e?(this._onBeforePhysicsObserver=this.scene.onBeforePhysicsObservable.add(function(){ve.h.StartPerformanceCounter("Physics"),t._physicsTime.beginMonitoring()}),this._onAfterPhysicsObserver=this.scene.onAfterPhysicsObservable.add(function(){ve.h.EndPerformanceCounter("Physics"),t._physicsTime.endMonitoring()})):(this.scene.onBeforePhysicsObservable.remove(this._onBeforePhysicsObserver),this._onBeforePhysicsObserver=null,this.scene.onAfterPhysicsObservable.remove(this._onAfterPhysicsObserver),this._onAfterPhysicsObserver=null))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"animationsTimeCounter",{get:function(){return this._animationsTime},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"captureAnimationsTime",{get:function(){return this._captureAnimationsTime},set:function(e){var t=this;e!==this._captureAnimationsTime&&(this._captureAnimationsTime=e,e?this._onAfterAnimationsObserver=this.scene.onAfterAnimationsObservable.add(function(){t._animationsTime.endMonitoring()}):(this.scene.onAfterAnimationsObservable.remove(this._onAfterAnimationsObserver),this._onAfterAnimationsObserver=null))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"frameTimeCounter",{get:function(){return this._frameTime},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"captureFrameTime",{get:function(){return this._captureFrameTime},set:function(e){this._captureFrameTime=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"interFrameTimeCounter",{get:function(){return this._interFrameTime},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"captureInterFrameTime",{get:function(){return this._captureInterFrameTime},set:function(e){this._captureInterFrameTime=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"renderTimeCounter",{get:function(){return this._renderTime},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"captureRenderTime",{get:function(){return this._captureRenderTime},set:function(e){var t=this;e!==this._captureRenderTime&&(this._captureRenderTime=e,e?(this._onBeforeDrawPhaseObserver=this.scene.onBeforeDrawPhaseObservable.add(function(){t._renderTime.beginMonitoring(),ve.h.StartPerformanceCounter("Main render")}),this._onAfterDrawPhaseObserver=this.scene.onAfterDrawPhaseObservable.add(function(){t._renderTime.endMonitoring(!1),ve.h.EndPerformanceCounter("Main render")})):(this.scene.onBeforeDrawPhaseObservable.remove(this._onBeforeDrawPhaseObserver),this._onBeforeDrawPhaseObserver=null,this.scene.onAfterDrawPhaseObservable.remove(this._onAfterDrawPhaseObserver),this._onAfterDrawPhaseObserver=null))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"cameraRenderTimeCounter",{get:function(){return this._cameraRenderTime},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"captureCameraRenderTime",{get:function(){return this._captureCameraRenderTime},set:function(e){var t=this;e!==this._captureCameraRenderTime&&(this._captureCameraRenderTime=e,e?(this._onBeforeCameraRenderObserver=this.scene.onBeforeCameraRenderObservable.add(function(e){t._cameraRenderTime.beginMonitoring(),ve.h.StartPerformanceCounter("Rendering camera "+e.name)}),this._onAfterCameraRenderObserver=this.scene.onAfterCameraRenderObservable.add(function(e){t._cameraRenderTime.endMonitoring(!1),ve.h.EndPerformanceCounter("Rendering camera "+e.name)})):(this.scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver),this._onBeforeCameraRenderObserver=null,this.scene.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver),this._onAfterCameraRenderObserver=null))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"drawCallsCounter",{get:function(){return this.scene.getEngine()._drawCalls},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"textureCollisionsCounter",{get:function(){return this.scene.getEngine()._textureCollisions},enumerable:!0,configurable:!0}),e.prototype.dispose=function(){this.scene.onAfterRenderObservable.remove(this._onAfterRenderObserver),this._onAfterRenderObserver=null,this.scene.onBeforeActiveMeshesEvaluationObservable.remove(this._onBeforeActiveMeshesEvaluationObserver),this._onBeforeActiveMeshesEvaluationObserver=null,this.scene.onAfterActiveMeshesEvaluationObservable.remove(this._onAfterActiveMeshesEvaluationObserver),this._onAfterActiveMeshesEvaluationObserver=null,this.scene.onBeforeRenderTargetsRenderObservable.remove(this._onBeforeRenderTargetsRenderObserver),this._onBeforeRenderTargetsRenderObserver=null,this.scene.onAfterRenderTargetsRenderObservable.remove(this._onAfterRenderTargetsRenderObserver),this._onAfterRenderTargetsRenderObserver=null,this.scene.onBeforeAnimationsObservable.remove(this._onBeforeAnimationsObserver),this._onBeforeAnimationsObserver=null,this.scene.onBeforeParticlesRenderingObservable.remove(this._onBeforeParticlesRenderingObserver),this._onBeforeParticlesRenderingObserver=null,this.scene.onAfterParticlesRenderingObservable.remove(this._onAfterParticlesRenderingObserver),this._onAfterParticlesRenderingObserver=null,this._onBeforeSpritesRenderingObserver&&(this.scene.onBeforeSpritesRenderingObservable.remove(this._onBeforeSpritesRenderingObserver),this._onBeforeSpritesRenderingObserver=null),this._onAfterSpritesRenderingObserver&&(this.scene.onAfterSpritesRenderingObservable.remove(this._onAfterSpritesRenderingObserver),this._onAfterSpritesRenderingObserver=null),this.scene.onBeforeDrawPhaseObservable.remove(this._onBeforeDrawPhaseObserver),this._onBeforeDrawPhaseObserver=null,this.scene.onAfterDrawPhaseObservable.remove(this._onAfterDrawPhaseObserver),this._onAfterDrawPhaseObserver=null,this._onBeforePhysicsObserver&&(this.scene.onBeforePhysicsObservable.remove(this._onBeforePhysicsObserver),this._onBeforePhysicsObserver=null),this._onAfterPhysicsObserver&&(this.scene.onAfterPhysicsObservable.remove(this._onAfterPhysicsObserver),this._onAfterPhysicsObserver=null),this.scene.onAfterAnimationsObservable.remove(this._onAfterAnimationsObserver),this._onAfterAnimationsObserver=null,this.scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver),this._onBeforeCameraRenderObserver=null,this.scene.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver),this._onAfterCameraRenderObserver=null,this.scene=null},e}(),yn=i(18),bn="#ifdef DIFFUSE\nvarying vec2 vUVDiffuse;\nuniform sampler2D diffuseSampler;\n#endif\n#ifdef OPACITY\nvarying vec2 vUVOpacity;\nuniform sampler2D opacitySampler;\nuniform float opacityIntensity;\n#endif\n#ifdef EMISSIVE\nvarying vec2 vUVEmissive;\nuniform sampler2D emissiveSampler;\n#endif\nuniform vec4 color;\nvoid main(void)\n{\nvec4 finalColor=color;\n\n#ifdef DIFFUSE\nvec4 albedoTexture=texture2D(diffuseSampler,vUVDiffuse);\nfinalColor.a*=albedoTexture.a;\n#endif\n#ifdef OPACITY\nvec4 opacityMap=texture2D(opacitySampler,vUVOpacity);\n#ifdef OPACITYRGB\nfinalColor.a*=getLuminance(opacityMap.rgb);\n#else\nfinalColor.a*=opacityMap.a;\n#endif\nfinalColor.a*=opacityIntensity;\n#endif\n#ifdef VERTEXALPHA\nfinalColor.a*=vColor.a;\n#endif\n#ifdef ALPHATEST\nif (finalColor.a<ALPHATESTVALUE)\ndiscard;\n#endif\n#ifdef EMISSIVE\ngl_FragColor=texture2D(emissiveSampler,vUVEmissive)*finalColor;\n#else\ngl_FragColor=finalColor;\n#endif\n#ifdef GLOW\ngl_FragColor.rgb*=gl_FragColor.a;\ngl_FragColor.a=1.0;\n#endif\n}";St.a.ShadersStore.glowMapGenerationPixelShader=bn;var Tn="\nattribute vec3 position;\n#include<bonesDeclaration>\n#include<morphTargetsVertexGlobalDeclaration>\n#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]\n\n#include<instancesDeclaration>\nuniform mat4 viewProjection;\nvarying vec4 vPosition;\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef DIFFUSE\nvarying vec2 vUVDiffuse;\nuniform mat4 diffuseMatrix;\n#endif\n#ifdef OPACITY\nvarying vec2 vUVOpacity;\nuniform mat4 opacityMatrix;\n#endif\n#ifdef EMISSIVE\nvarying vec2 vUVEmissive;\nuniform mat4 emissiveMatrix;\n#endif\n#ifdef VERTEXALPHA\nattribute vec4 color;\nvarying vec4 vColor;\n#endif\nvoid main(void)\n{\nvec3 positionUpdated=position;\n#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]\n#include<instancesVertex>\n#include<bonesVertex>\n#ifdef CUBEMAP\nvPosition=finalWorld*vec4(positionUpdated,1.0);\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\n#else\nvPosition=viewProjection*finalWorld*vec4(positionUpdated,1.0);\ngl_Position=vPosition;\n#endif\n#ifdef DIFFUSE\n#ifdef DIFFUSEUV1\nvUVDiffuse=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n#endif\n#ifdef DIFFUSEUV2\nvUVDiffuse=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n#ifdef OPACITY\n#ifdef OPACITYUV1\nvUVOpacity=vec2(opacityMatrix*vec4(uv,1.0,0.0));\n#endif\n#ifdef OPACITYUV2\nvUVOpacity=vec2(opacityMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n#ifdef EMISSIVE\n#ifdef EMISSIVEUV1\nvUVEmissive=vec2(emissiveMatrix*vec4(uv,1.0,0.0));\n#endif\n#ifdef EMISSIVEUV2\nvUVEmissive=vec2(emissiveMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n#ifdef VERTEXALPHA\nvColor=color;\n#endif\n}";St.a.ShadersStore.glowMapGenerationVertexShader=Tn;var En=function(){function e(t,i){this._vertexBuffers={},this._maxSize=0,this._mainTextureDesiredSize={width:0,height:0},this._shouldRender=!0,this._postProcesses=[],this._textures=[],this._emissiveTextureAndColor={texture:null,color:new o.f},this.neutralColor=new o.f,this.isEnabled=!0,this.onDisposeObservable=new n.c,this.onBeforeRenderMainTextureObservable=new n.c,this.onBeforeComposeObservable=new n.c,this.onAfterComposeObservable=new n.c,this.onSizeChangedObservable=new n.c,this.name=t,this._scene=i||R.a.LastCreatedScene,e._SceneComponentInitialization(this._scene),this._engine=this._scene.getEngine(),this._maxSize=this._engine.getCaps().maxTextureSize,this._scene.effectLayers.push(this),this._generateIndexBuffer(),this._genrateVertexBuffer()}return Object.defineProperty(e.prototype,"camera",{get:function(){return this._effectLayerOptions.camera},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"renderingGroupId",{get:function(){return this._effectLayerOptions.renderingGroupId},enumerable:!0,configurable:!0}),e.prototype._init=function(e){this._effectLayerOptions=l.a({mainTextureRatio:.5,alphaBlendingMode:_.a.ALPHA_COMBINE,camera:null,renderingGroupId:-1},e),this._setMainTextureSize(),this._createMainTexture(),this._createTextureAndPostProcesses(),this._mergeEffect=this._createMergeEffect()},e.prototype._generateIndexBuffer=function(){var e=[];e.push(0),e.push(1),e.push(2),e.push(0),e.push(2),e.push(3),this._indexBuffer=this._engine.createIndexBuffer(e)},e.prototype._genrateVertexBuffer=function(){var e=[];e.push(1,1),e.push(-1,1),e.push(-1,-1),e.push(1,-1);var t=new gi.b(this._engine,e,gi.b.PositionKind,!1,!1,2);this._vertexBuffers[gi.b.PositionKind]=t},e.prototype._setMainTextureSize=function(){this._effectLayerOptions.mainTextureFixedSize?(this._mainTextureDesiredSize.width=this._effectLayerOptions.mainTextureFixedSize,this._mainTextureDesiredSize.height=this._effectLayerOptions.mainTextureFixedSize):(this._mainTextureDesiredSize.width=this._engine.getRenderWidth()*this._effectLayerOptions.mainTextureRatio,this._mainTextureDesiredSize.height=this._engine.getRenderHeight()*this._effectLayerOptions.mainTextureRatio,this._mainTextureDesiredSize.width=this._engine.needPOTTextures?ve.h.GetExponentOfTwo(this._mainTextureDesiredSize.width,this._maxSize):this._mainTextureDesiredSize.width,this._mainTextureDesiredSize.height=this._engine.needPOTTextures?ve.h.GetExponentOfTwo(this._mainTextureDesiredSize.height,this._maxSize):this._mainTextureDesiredSize.height),this._mainTextureDesiredSize.width=Math.floor(this._mainTextureDesiredSize.width),this._mainTextureDesiredSize.height=Math.floor(this._mainTextureDesiredSize.height)},e.prototype._createMainTexture=function(){var e=this;this._mainTexture=new Mi("HighlightLayerMainRTT",{width:this._mainTextureDesiredSize.width,height:this._mainTextureDesiredSize.height},this._scene,!1,!0,_.a.TEXTURETYPE_UNSIGNED_INT),this._mainTexture.activeCamera=this._effectLayerOptions.camera,this._mainTexture.wrapU=Ve.a.CLAMP_ADDRESSMODE,this._mainTexture.wrapV=Ve.a.CLAMP_ADDRESSMODE,this._mainTexture.anisotropicFilteringLevel=1,this._mainTexture.updateSamplingMode(Ve.a.BILINEAR_SAMPLINGMODE),this._mainTexture.renderParticles=!1,this._mainTexture.renderList=null,this._mainTexture.ignoreCameraViewport=!0,this._mainTexture.customRenderFunction=function(t,i,r,n){var o;e.onBeforeRenderMainTextureObservable.notifyObservers(e);var s=e._scene.getEngine();if(n.length){for(s.setColorWrite(!1),o=0;o<n.length;o++)e._renderSubMesh(n.data[o]);s.setColorWrite(!0)}for(o=0;o<t.length;o++)e._renderSubMesh(t.data[o]);for(o=0;o<i.length;o++)e._renderSubMesh(i.data[o]);for(o=0;o<r.length;o++)e._renderSubMesh(r.data[o])},this._mainTexture.onClearObservable.add(function(t){t.clear(e.neutralColor,!0,!0,!0)})},e.prototype._addCustomEffectDefines=function(e){},e.prototype._isReady=function(e,t,i){var r=e.getMaterial();if(!r)return!1;if(!r.isReadyForSubMesh(e.getMesh(),e,t))return!1;var n=[],o=[gi.b.PositionKind],s=e.getMesh(),a=!1,c=!1;if(r){var l=r.needAlphaTesting(),u=r.getAlphaTestTexture(),h=u&&u.hasAlpha&&(r.useAlphaFromDiffuseTexture||r._useAlphaFromAlbedoTexture);u&&(l||h)&&(n.push("#define DIFFUSE"),s.isVerticesDataPresent(gi.b.UV2Kind)&&1===u.coordinatesIndex?(n.push("#define DIFFUSEUV2"),c=!0):s.isVerticesDataPresent(gi.b.UVKind)&&(n.push("#define DIFFUSEUV1"),a=!0),l&&(n.push("#define ALPHATEST"),n.push("#define ALPHATESTVALUE 0.4")));var d=r.opacityTexture;d&&(n.push("#define OPACITY"),s.isVerticesDataPresent(gi.b.UV2Kind)&&1===d.coordinatesIndex?(n.push("#define OPACITYUV2"),c=!0):s.isVerticesDataPresent(gi.b.UVKind)&&(n.push("#define OPACITYUV1"),a=!0))}i&&(n.push("#define EMISSIVE"),s.isVerticesDataPresent(gi.b.UV2Kind)&&1===i.coordinatesIndex?(n.push("#define EMISSIVEUV2"),c=!0):s.isVerticesDataPresent(gi.b.UVKind)&&(n.push("#define EMISSIVEUV1"),a=!0)),s.isVerticesDataPresent(gi.b.ColorKind)&&s.hasVertexAlpha&&(o.push(gi.b.ColorKind),n.push("#define VERTEXALPHA")),a&&(o.push(gi.b.UVKind),n.push("#define UV1")),c&&(o.push(gi.b.UV2Kind),n.push("#define UV2")),s.useBones&&s.computeBonesUsingShaders?(o.push(gi.b.MatricesIndicesKind),o.push(gi.b.MatricesWeightsKind),s.numBoneInfluencers>4&&(o.push(gi.b.MatricesIndicesExtraKind),o.push(gi.b.MatricesWeightsExtraKind)),n.push("#define NUM_BONE_INFLUENCERS "+s.numBoneInfluencers),n.push("#define BonesPerMesh "+(s.skeleton?s.skeleton.bones.length+1:0))):n.push("#define NUM_BONE_INFLUENCERS 0");var f=s.morphTargetManager,p=0;f&&f.numInfluencers>0&&(n.push("#define MORPHTARGETS"),p=f.numInfluencers,n.push("#define NUM_MORPH_INFLUENCERS "+p),kr.a.PrepareAttributesForMorphTargets(o,s,{NUM_MORPH_INFLUENCERS:p})),t&&(n.push("#define INSTANCES"),o.push("world0"),o.push("world1"),o.push("world2"),o.push("world3")),this._addCustomEffectDefines(n);var _=n.join("\n");return this._cachedDefines!==_&&(this._cachedDefines=_,this._effectLayerMapGenerationEffect=this._scene.getEngine().createEffect("glowMapGeneration",o,["world","mBones","viewProjection","color","morphTargetInfluences","diffuseMatrix","emissiveMatrix","opacityMatrix","opacityIntensity"],["diffuseSampler","emissiveSampler","opacitySampler"],_,void 0,void 0,void 0,{maxSimultaneousMorphTargets:p})),this._effectLayerMapGenerationEffect.isReady()},e.prototype.render=function(){var e=this._mergeEffect;if(e.isReady()){for(var t=0;t<this._postProcesses.length;t++)if(!this._postProcesses[t].isReady())return;var i=this._scene.getEngine();this.onBeforeComposeObservable.notifyObservers(this),i.enableEffect(e),i.setState(!1),i.bindBuffers(this._vertexBuffers,this._indexBuffer,e);var r=i.getAlphaMode();i.setAlphaMode(this._effectLayerOptions.alphaBlendingMode),this._internalRender(e),i.setAlphaMode(r),this.onAfterComposeObservable.notifyObservers(this);var n=this._mainTexture.getSize();this._setMainTextureSize(),n.width===this._mainTextureDesiredSize.width&&n.height===this._mainTextureDesiredSize.height||(this.onSizeChangedObservable.notifyObservers(this),this._disposeTextureAndPostProcesses(),this._createMainTexture(),this._createTextureAndPostProcesses())}},e.prototype.hasMesh=function(e){return-1===this.renderingGroupId||e.renderingGroupId===this.renderingGroupId},e.prototype.shouldRender=function(){return this.isEnabled&&this._shouldRender},e.prototype._shouldRenderMesh=function(e){return!0},e.prototype._canRenderMesh=function(e,t){return!t.needAlphaBlendingForMesh(e)},e.prototype._shouldRenderEmissiveTextureForMesh=function(){return!0},e.prototype._renderSubMesh=function(e){var t=this;if(this.shouldRender()){var i=e.getMaterial(),r=e.getRenderingMesh(),n=this._scene,o=n.getEngine();if(i&&this._canRenderMesh(r,i)){o.setState(i.backFaceCulling);var s=r._getInstancesRenderList(e._id);if(!s.mustReturn&&this._shouldRenderMesh(r)){var a=o.getCaps().instancedArrays&&null!==s.visibleInstances[e._id]&&void 0!==s.visibleInstances[e._id];if(this._setEmissiveTextureAndColor(r,e,i),this._isReady(e,a,this._emissiveTextureAndColor.texture)){o.enableEffect(this._effectLayerMapGenerationEffect),r._bind(e,this._effectLayerMapGenerationEffect,yn.a.TriangleFillMode),this._effectLayerMapGenerationEffect.setMatrix("viewProjection",n.getTransformMatrix()),this._effectLayerMapGenerationEffect.setFloat4("color",this._emissiveTextureAndColor.color.r,this._emissiveTextureAndColor.color.g,this._emissiveTextureAndColor.color.b,this._emissiveTextureAndColor.color.a);var c=i.needAlphaTesting(),l=i.getAlphaTestTexture(),u=l&&l.hasAlpha&&(i.useAlphaFromDiffuseTexture||i._useAlphaFromAlbedoTexture);if(l&&(c||u))this._effectLayerMapGenerationEffect.setTexture("diffuseSampler",l),(h=l.getTextureMatrix())&&this._effectLayerMapGenerationEffect.setMatrix("diffuseMatrix",h);var h,d=i.opacityTexture;if(d)this._effectLayerMapGenerationEffect.setTexture("opacitySampler",d),this._effectLayerMapGenerationEffect.setFloat("opacityIntensity",d.level),(h=d.getTextureMatrix())&&this._effectLayerMapGenerationEffect.setMatrix("opacityMatrix",h);this._emissiveTextureAndColor.texture&&(this._effectLayerMapGenerationEffect.setTexture("emissiveSampler",this._emissiveTextureAndColor.texture),this._effectLayerMapGenerationEffect.setMatrix("emissiveMatrix",this._emissiveTextureAndColor.texture.getTextureMatrix())),r.useBones&&r.computeBonesUsingShaders&&r.skeleton&&this._effectLayerMapGenerationEffect.setMatrices("mBones",r.skeleton.getTransformMatrices(r)),kr.a.BindMorphTargetParameters(r,this._effectLayerMapGenerationEffect),r._processRendering(e,this._effectLayerMapGenerationEffect,yn.a.TriangleFillMode,s,a,function(e,i){return t._effectLayerMapGenerationEffect.setMatrix("world",i)})}else this._mainTexture.resetRefreshCounter()}}}},e.prototype._rebuild=function(){var e=this._vertexBuffers[gi.b.PositionKind];e&&e._rebuild(),this._generateIndexBuffer()},e.prototype._disposeTextureAndPostProcesses=function(){this._mainTexture.dispose();for(var e=0;e<this._postProcesses.length;e++)this._postProcesses[e]&&this._postProcesses[e].dispose();this._postProcesses=[];for(e=0;e<this._textures.length;e++)this._textures[e]&&this._textures[e].dispose();this._textures=[]},e.prototype.dispose=function(){var e=this._vertexBuffers[gi.b.PositionKind];e&&(e.dispose(),this._vertexBuffers[gi.b.PositionKind]=null),this._indexBuffer&&(this._scene.getEngine()._releaseBuffer(this._indexBuffer),this._indexBuffer=null),this._disposeTextureAndPostProcesses();var t=this._scene.effectLayers.indexOf(this,0);t>-1&&this._scene.effectLayers.splice(t,1),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this.onBeforeRenderMainTextureObservable.clear(),this.onBeforeComposeObservable.clear(),this.onAfterComposeObservable.clear(),this.onSizeChangedObservable.clear()},e.prototype.getClassName=function(){return"EffectLayer"},e.Parse=function(e,t,i){return ve.h.Instantiate(e.customType).Parse(e,t,i)},e._SceneComponentInitialization=function(e){throw"Import EffectLayerSceneComponent before creating EffectLayer."},l.c([Object(w.c)()],e.prototype,"name",void 0),l.c([Object(w.f)()],e.prototype,"neutralColor",void 0),l.c([Object(w.c)()],e.prototype,"isEnabled",void 0),l.c([Object(w.d)()],e.prototype,"camera",null),l.c([Object(w.c)()],e.prototype,"renderingGroupId",null),e}();r.a.AddParser(Te.a.NAME_EFFECTLAYER,function(e,t,i,r){if(e.effectLayers){i.effectLayers||(i.effectLayers=new Array);for(var n=0;n<e.effectLayers.length;n++){var o=En.Parse(e.effectLayers[n],t,r);i.effectLayers.push(o)}}}),r.a.prototype.removeEffectLayer=function(e){var t=this.effectLayers.indexOf(e);return-1!==t&&this.effectLayers.splice(t,1),t},r.a.prototype.addEffectLayer=function(e){this.effectLayers.push(e)};var xn=function(){function e(e){this.name=Te.a.NAME_EFFECTLAYER,this._renderEffects=!1,this._needStencil=!1,this._previousStencilState=!1,this.scene=e,this._engine=e.getEngine(),e.effectLayers=new Array}return e.prototype.register=function(){this.scene._isReadyForMeshStage.registerStep(Te.a.STEP_ISREADYFORMESH_EFFECTLAYER,this,this._isReadyForMesh),this.scene._cameraDrawRenderTargetStage.registerStep(Te.a.STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER,this,this._renderMainTexture),this.scene._beforeCameraDrawStage.registerStep(Te.a.STEP_BEFORECAMERADRAW_EFFECTLAYER,this,this._setStencil),this.scene._afterRenderingGroupDrawStage.registerStep(Te.a.STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW,this,this._drawRenderingGroup),this.scene._afterCameraDrawStage.registerStep(Te.a.STEP_AFTERCAMERADRAW_EFFECTLAYER,this,this._setStencilBack),this.scene._afterCameraDrawStage.registerStep(Te.a.STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW,this,this._drawCamera)},e.prototype.rebuild=function(){for(var e=0,t=this.scene.effectLayers;e<t.length;e++){t[e]._rebuild()}},e.prototype.serialize=function(e){e.effectLayers=[];for(var t=0,i=this.scene.effectLayers;t<i.length;t++){var r=i[t];r.serialize&&e.effectLayers.push(r.serialize())}},e.prototype.addFromContainer=function(e){var t=this;e.effectLayers&&e.effectLayers.forEach(function(e){t.scene.addEffectLayer(e)})},e.prototype.removeFromContainer=function(e){var t=this;e.effectLayers&&e.effectLayers.forEach(function(e){t.scene.removeEffectLayer(e)})},e.prototype.dispose=function(){for(var e=this.scene.effectLayers;e.length;)e[0].dispose()},e.prototype._isReadyForMesh=function(e,t){for(var i=0,r=this.scene.effectLayers;i<r.length;i++){var n=r[i];if(n.hasMesh(e))for(var o=0,s=e.subMeshes;o<s.length;o++){var a=s[o];if(!n.isReady(a,t))return!1}}return!0},e.prototype._renderMainTexture=function(e){this._renderEffects=!1,this._needStencil=!1;var t=this.scene.effectLayers;if(t&&t.length>0){this._previousStencilState=this._engine.getStencilBuffer();for(var i=0,r=t;i<r.length;i++){var n=r[i];if(n.shouldRender()&&(!n.camera||n.camera.cameraRigMode===Le.a.RIG_MODE_NONE&&e===n.camera||n.camera.cameraRigMode!==Le.a.RIG_MODE_NONE&&n.camera._rigCameras.indexOf(e)>-1)){this._renderEffects=!0,this._needStencil=this._needStencil||n.needStencil();var o=n._mainTexture;o._shouldRender()&&(this.scene.incrementRenderId(),o.render(!1,!1))}}this.scene.incrementRenderId()}},e.prototype._setStencil=function(){this._needStencil&&this._engine.setStencilBuffer(!0)},e.prototype._setStencilBack=function(){this._needStencil&&this._engine.setStencilBuffer(this._previousStencilState)},e.prototype._draw=function(e){if(this._renderEffects){this._engine.setDepthBuffer(!1);for(var t=this.scene.effectLayers,i=0;i<t.length;i++){var r=t[i];r.renderingGroupId===e&&r.shouldRender()&&r.render()}this._engine.setDepthBuffer(!0)}},e.prototype._drawCamera=function(){this._renderEffects&&this._draw(-1)},e.prototype._drawRenderingGroup=function(e){!this.scene._isInIntermediateRendering()&&this._renderEffects&&this._draw(e)},e}();En._SceneComponentInitialization=function(e){var t=e._getComponent(Te.a.NAME_EFFECTLAYER);t||(t=new xn(e),e._addComponent(t))};var An="\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n#ifdef EMISSIVE\nuniform sampler2D textureSampler2;\n#endif\n\nuniform float offset;\nvoid main(void) {\nvec4 baseColor=texture2D(textureSampler,vUV);\n#ifdef EMISSIVE\nbaseColor+=texture2D(textureSampler2,vUV);\nbaseColor*=offset;\n#else\nbaseColor.a=abs(offset-baseColor.a);\n#ifdef STROKE\nfloat alpha=smoothstep(.0,.1,baseColor.a);\nbaseColor.a=alpha;\nbaseColor.rgb=baseColor.rgb*alpha;\n#endif\n#endif\ngl_FragColor=baseColor;\n}";St.a.ShadersStore.glowMapMergePixelShader=An;var Pn="\nattribute vec2 position;\n\nvarying vec2 vUV;\nconst vec2 madd=vec2(0.5,0.5);\nvoid main(void) {\nvUV=position*madd+madd;\ngl_Position=vec4(position,0.0,1.0);\n}";St.a.ShadersStore.glowMapMergeVertexShader=Pn;r.a.prototype.getGlowLayerByName=function(e){for(var t=0;t<this.effectLayers.length;t++)if(this.effectLayers[t].name===e&&this.effectLayers[t].getEffectName()===Rn.EffectName)return this.effectLayers[t];return null};var Rn=function(e){function t(i,r,n){var s=e.call(this,i,r)||this;return s._intensity=1,s._includedOnlyMeshes=[],s._excludedMeshes=[],s.neutralColor=new o.f(0,0,0,1),s._options=l.a({mainTextureRatio:t.DefaultTextureRatio,blurKernelSize:32,mainTextureFixedSize:void 0,camera:null,mainTextureSamples:1,renderingGroupId:-1},n),s._init({alphaBlendingMode:_.a.ALPHA_ADD,camera:s._options.camera,mainTextureFixedSize:s._options.mainTextureFixedSize,mainTextureRatio:s._options.mainTextureRatio,renderingGroupId:s._options.renderingGroupId}),s}return l.d(t,e),Object.defineProperty(t.prototype,"blurKernelSize",{get:function(){return this._horizontalBlurPostprocess1.kernel},set:function(e){this._horizontalBlurPostprocess1.kernel=e,this._verticalBlurPostprocess1.kernel=e,this._horizontalBlurPostprocess2.kernel=e,this._verticalBlurPostprocess2.kernel=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"intensity",{get:function(){return this._intensity},set:function(e){this._intensity=e},enumerable:!0,configurable:!0}),t.prototype.getEffectName=function(){return t.EffectName},t.prototype._createMergeEffect=function(){return this._engine.createEffect("glowMapMerge",[gi.b.PositionKind],["offset"],["textureSampler","textureSampler2"],"#define EMISSIVE \n")},t.prototype._createTextureAndPostProcesses=function(){var e=this,t=this._mainTextureDesiredSize.width,i=this._mainTextureDesiredSize.height;t=this._engine.needPOTTextures?ve.h.GetExponentOfTwo(t,this._maxSize):t,i=this._engine.needPOTTextures?ve.h.GetExponentOfTwo(i,this._maxSize):i;var r=0;r=this._engine.getCaps().textureHalfFloatRender?_.a.TEXTURETYPE_HALF_FLOAT:_.a.TEXTURETYPE_UNSIGNED_INT,this._blurTexture1=new Mi("GlowLayerBlurRTT",{width:t,height:i},this._scene,!1,!0,r),this._blurTexture1.wrapU=Ve.a.CLAMP_ADDRESSMODE,this._blurTexture1.wrapV=Ve.a.CLAMP_ADDRESSMODE,this._blurTexture1.updateSamplingMode(Ve.a.BILINEAR_SAMPLINGMODE),this._blurTexture1.renderParticles=!1,this._blurTexture1.ignoreCameraViewport=!0;var n=Math.floor(t/2),s=Math.floor(i/2);this._blurTexture2=new Mi("GlowLayerBlurRTT2",{width:n,height:s},this._scene,!1,!0,r),this._blurTexture2.wrapU=Ve.a.CLAMP_ADDRESSMODE,this._blurTexture2.wrapV=Ve.a.CLAMP_ADDRESSMODE,this._blurTexture2.updateSamplingMode(Ve.a.BILINEAR_SAMPLINGMODE),this._blurTexture2.renderParticles=!1,this._blurTexture2.ignoreCameraViewport=!0,this._textures=[this._blurTexture1,this._blurTexture2],this._horizontalBlurPostprocess1=new Ur("GlowLayerHBP1",new o.w(1,0),this._options.blurKernelSize/2,{width:t,height:i},null,Ve.a.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,r),this._horizontalBlurPostprocess1.width=t,this._horizontalBlurPostprocess1.height=i,this._horizontalBlurPostprocess1.onApplyObservable.add(function(t){t.setTexture("textureSampler",e._mainTexture)}),this._verticalBlurPostprocess1=new Ur("GlowLayerVBP1",new o.w(0,1),this._options.blurKernelSize/2,{width:t,height:i},null,Ve.a.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,r),this._horizontalBlurPostprocess2=new Ur("GlowLayerHBP2",new o.w(1,0),this._options.blurKernelSize/2,{width:n,height:s},null,Ve.a.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,r),this._horizontalBlurPostprocess2.width=n,this._horizontalBlurPostprocess2.height=s,this._horizontalBlurPostprocess2.onApplyObservable.add(function(t){t.setTexture("textureSampler",e._blurTexture1)}),this._verticalBlurPostprocess2=new Ur("GlowLayerVBP2",new o.w(0,1),this._options.blurKernelSize/2,{width:n,height:s},null,Ve.a.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,r),this._postProcesses=[this._horizontalBlurPostprocess1,this._verticalBlurPostprocess1,this._horizontalBlurPostprocess2,this._verticalBlurPostprocess2],this._postProcesses1=[this._horizontalBlurPostprocess1,this._verticalBlurPostprocess1],this._postProcesses2=[this._horizontalBlurPostprocess2,this._verticalBlurPostprocess2],this._mainTexture.samples=this._options.mainTextureSamples,this._mainTexture.onAfterUnbindObservable.add(function(){var t=e._blurTexture1.getInternalTexture();t&&(e._scene.postProcessManager.directRender(e._postProcesses1,t,!0),(t=e._blurTexture2.getInternalTexture())&&e._scene.postProcessManager.directRender(e._postProcesses2,t,!0))}),this._postProcesses.map(function(e){e.autoClear=!1})},t.prototype.isReady=function(t,i){var r=t.getMaterial(),n=t.getRenderingMesh();if(!r||!n)return!1;var o=r.emissiveTexture;return e.prototype._isReady.call(this,t,i,o)},t.prototype.needStencil=function(){return!1},t.prototype._canRenderMesh=function(e,t){return!0},t.prototype._internalRender=function(e){e.setTexture("textureSampler",this._blurTexture1),e.setTexture("textureSampler2",this._blurTexture2),e.setFloat("offset",this._intensity);var t=this._engine,i=t.getStencilBuffer();t.setStencilBuffer(!1),t.drawElementsType(yn.a.TriangleFillMode,0,6),t.setStencilBuffer(i)},t.prototype._setEmissiveTextureAndColor=function(e,t,i){var r=1;this.customEmissiveTextureSelector?this._emissiveTextureAndColor.texture=this.customEmissiveTextureSelector(e,t,i):i?(this._emissiveTextureAndColor.texture=i.emissiveTexture,this._emissiveTextureAndColor.texture&&(r=this._emissiveTextureAndColor.texture.level)):this._emissiveTextureAndColor.texture=null,this.customEmissiveColorSelector?this.customEmissiveColorSelector(e,t,i,this._emissiveTextureAndColor.color):i.emissiveColor?this._emissiveTextureAndColor.color.set(i.emissiveColor.r*r,i.emissiveColor.g*r,i.emissiveColor.b*r,i.alpha):this._emissiveTextureAndColor.color.set(this.neutralColor.r,this.neutralColor.g,this.neutralColor.b,this.neutralColor.a)},t.prototype._shouldRenderMesh=function(e){return this.hasMesh(e)},t.prototype._addCustomEffectDefines=function(e){e.push("#define GLOW")},t.prototype.addExcludedMesh=function(e){-1===this._excludedMeshes.indexOf(e.uniqueId)&&this._excludedMeshes.push(e.uniqueId)},t.prototype.removeExcludedMesh=function(e){var t=this._excludedMeshes.indexOf(e.uniqueId);-1!==t&&this._excludedMeshes.splice(t,1)},t.prototype.addIncludedOnlyMesh=function(e){-1===this._includedOnlyMeshes.indexOf(e.uniqueId)&&this._includedOnlyMeshes.push(e.uniqueId)},t.prototype.removeIncludedOnlyMesh=function(e){var t=this._includedOnlyMeshes.indexOf(e.uniqueId);-1!==t&&this._includedOnlyMeshes.splice(t,1)},t.prototype.hasMesh=function(t){return!!e.prototype.hasMesh.call(this,t)&&(this._includedOnlyMeshes.length?-1!==this._includedOnlyMeshes.indexOf(t.uniqueId):!this._excludedMeshes.length||-1===this._excludedMeshes.indexOf(t.uniqueId))},t.prototype._disposeMesh=function(e){this.removeIncludedOnlyMesh(e),this.removeExcludedMesh(e)},t.prototype.getClassName=function(){return"GlowLayer"},t.prototype.serialize=function(){var e,t=w.a.Serialize(this);if(t.customType="BABYLON.GlowLayer",t.includedMeshes=[],this._includedOnlyMeshes.length)for(e=0;e<this._includedOnlyMeshes.length;e++){(i=this._scene.getMeshByUniqueID(this._includedOnlyMeshes[e]))&&t.includedMeshes.push(i.id)}if(t.excludedMeshes=[],this._excludedMeshes.length)for(e=0;e<this._excludedMeshes.length;e++){var i;(i=this._scene.getMeshByUniqueID(this._excludedMeshes[e]))&&t.excludedMeshes.push(i.id)}return t},t.Parse=function(e,i,r){var n,o=w.a.Parse(function(){return new t(e.name,i,e.options)},e,i,r);for(n=0;n<e.excludedMeshes.length;n++){(s=i.getMeshByID(e.excludedMeshes[n]))&&o.addExcludedMesh(s)}for(n=0;n<e.includedMeshes.length;n++){var s;(s=i.getMeshByID(e.includedMeshes[n]))&&o.addIncludedOnlyMesh(s)}return o},t.EffectName="GlowLayer",t.DefaultBlurKernelSize=32,t.DefaultTextureRatio=.5,l.c([Object(w.c)()],t.prototype,"blurKernelSize",null),l.c([Object(w.c)()],t.prototype,"intensity",null),l.c([Object(w.c)("options")],t.prototype,"_options",void 0),t}(En);s.a.RegisteredTypes["BABYLON.GlowLayer"]=Rn;var Sn="\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n\nuniform vec2 screenSize;\nuniform vec2 direction;\nuniform float blurWidth;\n\nfloat getLuminance(vec3 color)\n{\nreturn dot(color,vec3(0.2126,0.7152,0.0722));\n}\nvoid main(void)\n{\nfloat weights[7];\nweights[0]=0.05;\nweights[1]=0.1;\nweights[2]=0.2;\nweights[3]=0.3;\nweights[4]=0.2;\nweights[5]=0.1;\nweights[6]=0.05;\nvec2 texelSize=vec2(1.0/screenSize.x,1.0/screenSize.y);\nvec2 texelStep=texelSize*direction*blurWidth;\nvec2 start=vUV-3.0*texelStep;\nvec4 baseColor=vec4(0.,0.,0.,0.);\nvec2 texelOffset=vec2(0.,0.);\nfor (int i=0; i<7; i++)\n{\n\nvec4 texel=texture2D(textureSampler,start+texelOffset);\nbaseColor.a+=texel.a*weights[i];\n\nfloat luminance=getLuminance(baseColor.rgb);\nfloat luminanceTexel=getLuminance(texel.rgb);\nfloat choice=step(luminanceTexel,luminance);\nbaseColor.rgb=choice*baseColor.rgb+(1.0-choice)*texel.rgb;\ntexelOffset+=texelStep;\n}\ngl_FragColor=baseColor;\n}";St.a.ShadersStore.glowBlurPostProcessPixelShader=Sn;r.a.prototype.getHighlightLayerByName=function(e){for(var t=0;t<this.effectLayers.length;t++)if(this.effectLayers[t].name===e&&this.effectLayers[t].getEffectName()===Mn.EffectName)return this.effectLayers[t];return null};var Cn=function(e){function t(t,i,r,n,o,s,a,c){void 0===s&&(s=Ve.a.BILINEAR_SAMPLINGMODE);var l=e.call(this,t,"glowBlurPostProcess",["screenSize","direction","blurWidth"],null,n,o,s,a,c)||this;return l.direction=i,l.kernel=r,l.onApplyObservable.add(function(e){e.setFloat2("screenSize",l.width,l.height),e.setVector2("direction",l.direction),e.setFloat("blurWidth",l.kernel)}),l}return l.d(t,e),t}(Mt),Mn=function(e){function t(i,r,o){var s=e.call(this,i,r)||this;return s.name=i,s.innerGlow=!0,s.outerGlow=!0,s.onBeforeBlurObservable=new n.c,s.onAfterBlurObservable=new n.c,s._instanceGlowingMeshStencilReference=t.GlowingMeshStencilReference++,s._meshes={},s._excludedMeshes={},s.neutralColor=t.NeutralColor,s._engine.isStencilEnable||p.a.Warn("Rendering the Highlight Layer requires the stencil to be active on the canvas. var engine = new Engine(canvas, antialias, { stencil: true }"),s._options=l.a({mainTextureRatio:.5,blurTextureSizeRatio:.5,blurHorizontalSize:1,blurVerticalSize:1,alphaBlendingMode:_.a.ALPHA_COMBINE,camera:null,renderingGroupId:-1},o),s._init({alphaBlendingMode:s._options.alphaBlendingMode,camera:s._options.camera,mainTextureFixedSize:s._options.mainTextureFixedSize,mainTextureRatio:s._options.mainTextureRatio,renderingGroupId:s._options.renderingGroupId}),s._shouldRender=!1,s}return l.d(t,e),Object.defineProperty(t.prototype,"blurHorizontalSize",{get:function(){return this._horizontalBlurPostprocess.kernel},set:function(e){this._horizontalBlurPostprocess.kernel=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"blurVerticalSize",{get:function(){return this._verticalBlurPostprocess.kernel},set:function(e){this._verticalBlurPostprocess.kernel=e},enumerable:!0,configurable:!0}),t.prototype.getEffectName=function(){return t.EffectName},t.prototype._createMergeEffect=function(){return this._engine.createEffect("glowMapMerge",[gi.b.PositionKind],["offset"],["textureSampler"],this._options.isStroke?"#define STROKE \n":void 0)},t.prototype._createTextureAndPostProcesses=function(){var e=this,t=this._mainTextureDesiredSize.width*this._options.blurTextureSizeRatio,i=this._mainTextureDesiredSize.height*this._options.blurTextureSizeRatio;t=this._engine.needPOTTextures?ve.h.GetExponentOfTwo(t,this._maxSize):t,i=this._engine.needPOTTextures?ve.h.GetExponentOfTwo(i,this._maxSize):i;var r=0;r=this._engine.getCaps().textureHalfFloatRender?_.a.TEXTURETYPE_HALF_FLOAT:_.a.TEXTURETYPE_UNSIGNED_INT,this._blurTexture=new Mi("HighlightLayerBlurRTT",{width:t,height:i},this._scene,!1,!0,r),this._blurTexture.wrapU=Ve.a.CLAMP_ADDRESSMODE,this._blurTexture.wrapV=Ve.a.CLAMP_ADDRESSMODE,this._blurTexture.anisotropicFilteringLevel=16,this._blurTexture.updateSamplingMode(Ve.a.TRILINEAR_SAMPLINGMODE),this._blurTexture.renderParticles=!1,this._blurTexture.ignoreCameraViewport=!0,this._textures=[this._blurTexture],this._options.alphaBlendingMode===_.a.ALPHA_COMBINE?(this._downSamplePostprocess=new Dt("HighlightLayerPPP",this._options.blurTextureSizeRatio,null,Ve.a.BILINEAR_SAMPLINGMODE,this._scene.getEngine()),this._downSamplePostprocess.onApplyObservable.add(function(t){t.setTexture("textureSampler",e._mainTexture)}),this._horizontalBlurPostprocess=new Cn("HighlightLayerHBP",new o.w(1,0),this._options.blurHorizontalSize,1,null,Ve.a.BILINEAR_SAMPLINGMODE,this._scene.getEngine()),this._horizontalBlurPostprocess.onApplyObservable.add(function(e){e.setFloat2("screenSize",t,i)}),this._verticalBlurPostprocess=new Cn("HighlightLayerVBP",new o.w(0,1),this._options.blurVerticalSize,1,null,Ve.a.BILINEAR_SAMPLINGMODE,this._scene.getEngine()),this._verticalBlurPostprocess.onApplyObservable.add(function(e){e.setFloat2("screenSize",t,i)}),this._postProcesses=[this._downSamplePostprocess,this._horizontalBlurPostprocess,this._verticalBlurPostprocess]):(this._horizontalBlurPostprocess=new Ur("HighlightLayerHBP",new o.w(1,0),this._options.blurHorizontalSize/2,{width:t,height:i},null,Ve.a.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,r),this._horizontalBlurPostprocess.width=t,this._horizontalBlurPostprocess.height=i,this._horizontalBlurPostprocess.onApplyObservable.add(function(t){t.setTexture("textureSampler",e._mainTexture)}),this._verticalBlurPostprocess=new Ur("HighlightLayerVBP",new o.w(0,1),this._options.blurVerticalSize/2,{width:t,height:i},null,Ve.a.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,r),this._postProcesses=[this._horizontalBlurPostprocess,this._verticalBlurPostprocess]),this._mainTexture.onAfterUnbindObservable.add(function(){e.onBeforeBlurObservable.notifyObservers(e);var t=e._blurTexture.getInternalTexture();t&&e._scene.postProcessManager.directRender(e._postProcesses,t,!0),e.onAfterBlurObservable.notifyObservers(e)}),this._postProcesses.map(function(e){e.autoClear=!1})},t.prototype.needStencil=function(){return!0},t.prototype.isReady=function(t,i){var r=t.getMaterial(),n=t.getRenderingMesh();if(!r||!n||!this._meshes)return!1;var o=null,s=this._meshes[n.uniqueId];return s&&s.glowEmissiveOnly&&r&&(o=r.emissiveTexture),e.prototype._isReady.call(this,t,i,o)},t.prototype._internalRender=function(e){e.setTexture("textureSampler",this._blurTexture);var t=this._engine,i=t.getStencilBuffer(),r=t.getStencilFunction(),n=t.getStencilMask(),o=t.getStencilOperationPass(),s=t.getStencilOperationFail(),a=t.getStencilOperationDepthFail(),c=t.getStencilFunctionReference();t.setStencilOperationPass(_.a.REPLACE),t.setStencilOperationFail(_.a.KEEP),t.setStencilOperationDepthFail(_.a.KEEP),t.setStencilMask(0),t.setStencilBuffer(!0),t.setStencilFunctionReference(this._instanceGlowingMeshStencilReference),this.outerGlow&&(e.setFloat("offset",0),t.setStencilFunction(_.a.NOTEQUAL),t.drawElementsType(yn.a.TriangleFillMode,0,6)),this.innerGlow&&(e.setFloat("offset",1),t.setStencilFunction(_.a.EQUAL),t.drawElementsType(yn.a.TriangleFillMode,0,6)),t.setStencilFunction(r),t.setStencilMask(n),t.setStencilBuffer(i),t.setStencilOperationPass(o),t.setStencilOperationFail(s),t.setStencilOperationDepthFail(a),t.setStencilFunctionReference(c)},t.prototype.shouldRender=function(){return!!e.prototype.shouldRender.call(this)&&!!this._meshes},t.prototype._shouldRenderMesh=function(t){return(!this._excludedMeshes||!this._excludedMeshes[t.uniqueId])&&!!e.prototype.hasMesh.call(this,t)},t.prototype._setEmissiveTextureAndColor=function(e,t,i){var r=this._meshes[e.uniqueId];r?this._emissiveTextureAndColor.color.set(r.color.r,r.color.g,r.color.b,1):this._emissiveTextureAndColor.color.set(this.neutralColor.r,this.neutralColor.g,this.neutralColor.b,this.neutralColor.a),r&&r.glowEmissiveOnly&&i?(this._emissiveTextureAndColor.texture=i.emissiveTexture,this._emissiveTextureAndColor.color.set(1,1,1,1)):this._emissiveTextureAndColor.texture=null},t.prototype.addExcludedMesh=function(e){this._excludedMeshes&&(this._excludedMeshes[e.uniqueId]||(this._excludedMeshes[e.uniqueId]={mesh:e,beforeBind:e.onBeforeBindObservable.add(function(e){e.getEngine().setStencilBuffer(!1)}),afterRender:e.onAfterRenderObservable.add(function(e){e.getEngine().setStencilBuffer(!0)})}))},t.prototype.removeExcludedMesh=function(e){if(this._excludedMeshes){var t=this._excludedMeshes[e.uniqueId];t&&(t.beforeBind&&e.onBeforeBindObservable.remove(t.beforeBind),t.afterRender&&e.onAfterRenderObservable.remove(t.afterRender)),this._excludedMeshes[e.uniqueId]=null}},t.prototype.hasMesh=function(t){return!!this._meshes&&(!!e.prototype.hasMesh.call(this,t)&&(void 0!==this._meshes[t.uniqueId]&&null!==this._meshes[t.uniqueId]))},t.prototype.addMesh=function(e,t,i){var r=this;if(void 0===i&&(i=!1),this._meshes){var n=this._meshes[e.uniqueId];n?n.color=t:(this._meshes[e.uniqueId]={mesh:e,color:t,observerHighlight:e.onBeforeBindObservable.add(function(e){r._excludedMeshes&&r._excludedMeshes[e.uniqueId]?r._defaultStencilReference(e):e.getScene().getEngine().setStencilFunctionReference(r._instanceGlowingMeshStencilReference)}),observerDefault:e.onAfterRenderObservable.add(this._defaultStencilReference),glowEmissiveOnly:i},e.onDisposeObservable.add(function(){r._disposeMesh(e)})),this._shouldRender=!0}},t.prototype.removeMesh=function(e){if(this._meshes){var t=this._meshes[e.uniqueId];for(var i in t&&(t.observerHighlight&&e.onBeforeBindObservable.remove(t.observerHighlight),t.observerDefault&&e.onAfterRenderObservable.remove(t.observerDefault),delete this._meshes[e.uniqueId]),this._shouldRender=!1,this._meshes)if(this._meshes[i]){this._shouldRender=!0;break}}},t.prototype._defaultStencilReference=function(e){e.getScene().getEngine().setStencilFunctionReference(t.NormalMeshStencilReference)},t.prototype._disposeMesh=function(e){this.removeMesh(e),this.removeExcludedMesh(e)},t.prototype.dispose=function(){if(this._meshes){for(var t in this._meshes){(i=this._meshes[t])&&i.mesh&&(i.observerHighlight&&i.mesh.onBeforeBindObservable.remove(i.observerHighlight),i.observerDefault&&i.mesh.onAfterRenderObservable.remove(i.observerDefault))}this._meshes=null}if(this._excludedMeshes){for(var t in this._excludedMeshes){var i;(i=this._excludedMeshes[t])&&(i.beforeBind&&i.mesh.onBeforeBindObservable.remove(i.beforeBind),i.afterRender&&i.mesh.onAfterRenderObservable.remove(i.afterRender))}this._excludedMeshes=null}e.prototype.dispose.call(this)},t.prototype.getClassName=function(){return"HighlightLayer"},t.prototype.serialize=function(){var e=w.a.Serialize(this);if(e.customType="BABYLON.HighlightLayer",e.meshes=[],this._meshes)for(var t in this._meshes){var i=this._meshes[t];i&&e.meshes.push({glowEmissiveOnly:i.glowEmissiveOnly,color:i.color.asArray(),meshId:i.mesh.id})}if(e.excludedMeshes=[],this._excludedMeshes)for(var r in this._excludedMeshes){var n=this._excludedMeshes[r];n&&e.excludedMeshes.push(n.mesh.id)}return e},t.Parse=function(e,i,r){var n,s=w.a.Parse(function(){return new t(e.name,i,e.options)},e,i,r);for(n=0;n<e.excludedMeshes.length;n++){(a=i.getMeshByID(e.excludedMeshes[n]))&&s.addExcludedMesh(a)}for(n=0;n<e.meshes.length;n++){var a,c=e.meshes[n];(a=i.getMeshByID(c.meshId))&&s.addMesh(a,o.e.FromArray(c.color),c.glowEmissiveOnly)}return s},t.EffectName="HighlightLayer",t.NeutralColor=new o.f(0,0,0,0),t.GlowingMeshStencilReference=2,t.NormalMeshStencilReference=1,l.c([Object(w.c)()],t.prototype,"innerGlow",void 0),l.c([Object(w.c)()],t.prototype,"outerGlow",void 0),l.c([Object(w.c)()],t.prototype,"blurHorizontalSize",null),l.c([Object(w.c)()],t.prototype,"blurVerticalSize",null),l.c([Object(w.c)("options")],t.prototype,"_options",void 0),t}(En);s.a.RegisteredTypes["BABYLON.HighlightLayer"]=Mn;var On=function(){function e(e){this.name=Te.a.NAME_LAYER,this.scene=e,this._engine=e.getEngine(),e.layers=new Array}return e.prototype.register=function(){this.scene._beforeCameraDrawStage.registerStep(Te.a.STEP_BEFORECAMERADRAW_LAYER,this,this._drawCameraBackground),this.scene._afterCameraDrawStage.registerStep(Te.a.STEP_AFTERCAMERADRAW_LAYER,this,this._drawCameraForeground),this.scene._beforeRenderTargetDrawStage.registerStep(Te.a.STEP_BEFORERENDERTARGETDRAW_LAYER,this,this._drawRenderTargetBackground),this.scene._afterRenderTargetDrawStage.registerStep(Te.a.STEP_AFTERRENDERTARGETDRAW_LAYER,this,this._drawRenderTargetForeground)},e.prototype.rebuild=function(){for(var e=0,t=this.scene.layers;e<t.length;e++){t[e]._rebuild()}},e.prototype.dispose=function(){for(var e=this.scene.layers;e.length;)e[0].dispose()},e.prototype._draw=function(e){var t=this.scene.layers;if(t.length){this._engine.setDepthBuffer(!1);for(var i=0,r=t;i<r.length;i++){var n=r[i];e(n)&&n.render()}this._engine.setDepthBuffer(!0)}},e.prototype._drawCameraPredicate=function(e,t,i){return!e.renderOnlyInRenderTargetTextures&&e.isBackground===t&&0!=(e.layerMask&i)},e.prototype._drawCameraBackground=function(e){var t=this;this._draw(function(i){return t._drawCameraPredicate(i,!0,e.layerMask)})},e.prototype._drawCameraForeground=function(e){var t=this;this._draw(function(i){return t._drawCameraPredicate(i,!1,e.layerMask)})},e.prototype._drawRenderTargetPredicate=function(e,t,i,r){return e.renderTargetTextures.length>0&&e.isBackground===t&&e.renderTargetTextures.indexOf(r)>-1&&0!=(e.layerMask&i)},e.prototype._drawRenderTargetBackground=function(e){var t=this;this._draw(function(i){return t._drawRenderTargetPredicate(i,!0,t.scene.activeCamera.layerMask,e)})},e.prototype._drawRenderTargetForeground=function(e){var t=this;this._draw(function(i){return t._drawRenderTargetPredicate(i,!1,t.scene.activeCamera.layerMask,e)})},e}(),In="\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n\nuniform vec4 color;\nvoid main(void) {\nvec4 baseColor=texture2D(textureSampler,vUV);\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\ngl_FragColor=baseColor*color;\n}";St.a.ShadersStore.layerPixelShader=In;var Dn="\nattribute vec2 position;\n\nuniform vec2 scale;\nuniform vec2 offset;\nuniform mat4 textureMatrix;\n\nvarying vec2 vUV;\nconst vec2 madd=vec2(0.5,0.5);\nvoid main(void) {\nvec2 shiftedPosition=position*scale+offset;\nvUV=vec2(textureMatrix*vec4(shiftedPosition*madd+madd,1.0,0.0));\ngl_Position=vec4(shiftedPosition,0.0,1.0);\n}";St.a.ShadersStore.layerVertexShader=Dn;var wn=function(){function e(e,t,i,r,s){this.name=e,this.scale=new o.w(1,1),this.offset=new o.w(0,0),this.alphaBlendingMode=_.a.ALPHA_COMBINE,this.layerMask=268435455,this.renderTargetTextures=[],this.renderOnlyInRenderTargetTextures=!1,this._vertexBuffers={},this.onDisposeObservable=new n.c,this.onBeforeRenderObservable=new n.c,this.onAfterRenderObservable=new n.c,this.texture=t?new Ve.a(t,i,!0):null,this.isBackground=void 0===r||r,this.color=void 0===s?new o.f(1,1,1,1):s,this._scene=i||R.a.LastCreatedScene;var a=this._scene._getComponent(Te.a.NAME_LAYER);a||(a=new On(this._scene),this._scene._addComponent(a)),this._scene.layers.push(this);var c=this._scene.getEngine(),l=[];l.push(1,1),l.push(-1,1),l.push(-1,-1),l.push(1,-1);var u=new gi.b(c,l,gi.b.PositionKind,!1,!1,2);this._vertexBuffers[gi.b.PositionKind]=u,this._createIndexBuffer(),this._effect=c.createEffect("layer",[gi.b.PositionKind],["textureMatrix","color","scale","offset"],["textureSampler"],""),this._alphaTestEffect=c.createEffect("layer",[gi.b.PositionKind],["textureMatrix","color","scale","offset"],["textureSampler"],"#define ALPHATEST")}return Object.defineProperty(e.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onBeforeRender",{set:function(e){this._onBeforeRenderObserver&&this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),this._onBeforeRenderObserver=this.onBeforeRenderObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onAfterRender",{set:function(e){this._onAfterRenderObserver&&this.onAfterRenderObservable.remove(this._onAfterRenderObserver),this._onAfterRenderObserver=this.onAfterRenderObservable.add(e)},enumerable:!0,configurable:!0}),e.prototype._createIndexBuffer=function(){var e=this._scene.getEngine(),t=[];t.push(0),t.push(1),t.push(2),t.push(0),t.push(2),t.push(3),this._indexBuffer=e.createIndexBuffer(t)},e.prototype._rebuild=function(){var e=this._vertexBuffers[gi.b.PositionKind];e&&e._rebuild(),this._createIndexBuffer()},e.prototype.render=function(){var e=this.alphaTest?this._alphaTestEffect:this._effect;if(e.isReady()&&this.texture&&this.texture.isReady()){var t=this._scene.getEngine();this.onBeforeRenderObservable.notifyObservers(this),t.enableEffect(e),t.setState(!1),e.setTexture("textureSampler",this.texture),e.setMatrix("textureMatrix",this.texture.getTextureMatrix()),e.setFloat4("color",this.color.r,this.color.g,this.color.b,this.color.a),e.setVector2("offset",this.offset),e.setVector2("scale",this.scale),t.bindBuffers(this._vertexBuffers,this._indexBuffer,e),this.alphaTest?t.drawElementsType(yn.a.TriangleFillMode,0,6):(t.setAlphaMode(this.alphaBlendingMode),t.drawElementsType(yn.a.TriangleFillMode,0,6),t.setAlphaMode(_.a.ALPHA_DISABLE)),this.onAfterRenderObservable.notifyObservers(this)}},e.prototype.dispose=function(){var e=this._vertexBuffers[gi.b.PositionKind];e&&(e.dispose(),this._vertexBuffers[gi.b.PositionKind]=null),this._indexBuffer&&(this._scene.getEngine()._releaseBuffer(this._indexBuffer),this._indexBuffer=null),this.texture&&(this.texture.dispose(),this.texture=null),this.renderTargetTextures=[];var t=this._scene.layers.indexOf(this);this._scene.layers.splice(t,1),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this.onAfterRenderObservable.clear(),this.onBeforeRenderObservable.clear()},e}(),Ln=function(){function e(e,t,i,r,n){this.size=e,this.position=t,this.alphaMode=_.a.ALPHA_ONEONE,this.color=i||new o.e(1,1,1),this.texture=r?new Ve.a(r,n.getScene(),!0):null,this._system=n,n.lensFlares.push(this)}return e.AddFlare=function(t,i,r,n,o){return new e(t,i,r,n,o)},e.prototype.dispose=function(){this.texture&&this.texture.dispose();var e=this._system.lensFlares.indexOf(this);this._system.lensFlares.splice(e,1)},e}(),Fn="\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n\nuniform vec4 color;\nvoid main(void) {\nvec4 baseColor=texture2D(textureSampler,vUV);\ngl_FragColor=baseColor*color;\n}";St.a.ShadersStore.lensFlarePixelShader=Fn;var Nn="\nattribute vec2 position;\n\nuniform mat4 viewportMatrix;\n\nvarying vec2 vUV;\nconst vec2 madd=vec2(0.5,0.5);\nvoid main(void) {\nvUV=position*madd+madd;\ngl_Position=viewportMatrix*vec4(position,0.0,1.0);\n}";St.a.ShadersStore.lensFlareVertexShader=Nn;var Bn=function(){function e(t,i,r){this.name=t,this.lensFlares=new Array,this.borderLimit=300,this.viewportBorder=0,this.layerMask=268435455,this._vertexBuffers={},this._isEnabled=!0,this._scene=r||R.a.LastCreatedScene,e._SceneComponentInitialization(this._scene),this._emitter=i,this.id=t,r.lensFlareSystems.push(this),this.meshesSelectionPredicate=function(e){return r.activeCamera&&e.material&&e.isVisible&&e.isEnabled()&&e.isBlocker&&0!=(e.layerMask&r.activeCamera.layerMask)};var n=r.getEngine(),o=[];o.push(1,1),o.push(-1,1),o.push(-1,-1),o.push(1,-1),this._vertexBuffers[gi.b.PositionKind]=new gi.b(n,o,gi.b.PositionKind,!1,!1,2);var s=[];s.push(0),s.push(1),s.push(2),s.push(0),s.push(2),s.push(3),this._indexBuffer=n.createIndexBuffer(s),this._effect=n.createEffect("lensFlare",[gi.b.PositionKind],["color","viewportMatrix"],["textureSampler"],"")}return Object.defineProperty(e.prototype,"isEnabled",{get:function(){return this._isEnabled},set:function(e){this._isEnabled=e},enumerable:!0,configurable:!0}),e.prototype.getScene=function(){return this._scene},e.prototype.getEmitter=function(){return this._emitter},e.prototype.setEmitter=function(e){this._emitter=e},e.prototype.getEmitterPosition=function(){return this._emitter.getAbsolutePosition?this._emitter.getAbsolutePosition():this._emitter.position},e.prototype.computeEffectivePosition=function(e){var t=this.getEmitterPosition();return t=o.x.Project(t,o.j.Identity(),this._scene.getTransformMatrix(),e),this._positionX=t.x,this._positionY=t.y,t=o.x.TransformCoordinates(this.getEmitterPosition(),this._scene.getViewMatrix()),this.viewportBorder>0&&(e.x-=this.viewportBorder,e.y-=this.viewportBorder,e.width+=2*this.viewportBorder,e.height+=2*this.viewportBorder,t.x+=this.viewportBorder,t.y+=this.viewportBorder,this._positionX+=this.viewportBorder,this._positionY+=this.viewportBorder),t.z>0&&(this._positionX>e.x&&this._positionX<e.x+e.width&&this._positionY>e.y&&(this._positionY,e.y,e.height),!0)},e.prototype._isVisible=function(){if(!this._isEnabled||!this._scene.activeCamera)return!1;var e=this.getEmitterPosition().subtract(this._scene.activeCamera.globalPosition),t=e.length();e.normalize();var i=new ei.a(this._scene.activeCamera.globalPosition,e),r=this._scene.pickWithRay(i,this.meshesSelectionPredicate,!0);return!r||!r.hit||r.distance>t},e.prototype.render=function(){if(!this._effect.isReady()||!this._scene.activeCamera)return!1;var e,t,i=this._scene.getEngine(),r=this._scene.activeCamera.viewport.toGlobal(i.getRenderWidth(!0),i.getRenderHeight(!0));if(!this.computeEffectivePosition(r))return!1;if(!this._isVisible())return!1;var n=(e=this._positionX<this.borderLimit+r.x?this.borderLimit+r.x-this._positionX:this._positionX>r.x+r.width-this.borderLimit?this._positionX-r.x-r.width+this.borderLimit:0)>(t=this._positionY<this.borderLimit+r.y?this.borderLimit+r.y-this._positionY:this._positionY>r.y+r.height-this.borderLimit?this._positionY-r.y-r.height+this.borderLimit:0)?e:t;(n-=this.viewportBorder)>this.borderLimit&&(n=this.borderLimit);var s=1-D.a.Clamp(n/this.borderLimit,0,1);if(s<0)return!1;s>1&&(s=1),this.viewportBorder>0&&(r.x+=this.viewportBorder,r.y+=this.viewportBorder,r.width-=2*this.viewportBorder,r.height-=2*this.viewportBorder,this._positionX-=this.viewportBorder,this._positionY-=this.viewportBorder);var a=r.x+r.width/2,c=r.y+r.height/2,l=a-this._positionX,u=c-this._positionY;i.enableEffect(this._effect),i.setState(!1),i.setDepthBuffer(!1),i.bindBuffers(this._vertexBuffers,this._indexBuffer,this._effect);for(var h=0;h<this.lensFlares.length;h++){var d=this.lensFlares[h];i.setAlphaMode(d.alphaMode);var f=a-l*d.position,p=c-u*d.position,g=d.size,m=d.size*i.getAspectRatio(this._scene.activeCamera,!0),v=f/(r.width+2*r.x)*2-1,y=1-p/(r.height+2*r.y)*2,b=o.j.FromValues(g/2,0,0,0,0,m/2,0,0,0,0,1,0,v,y,0,1);this._effect.setMatrix("viewportMatrix",b),this._effect.setTexture("textureSampler",d.texture),this._effect.setFloat4("color",d.color.r*s,d.color.g*s,d.color.b*s,1),i.drawElementsType(yn.a.TriangleFillMode,0,6)}return i.setDepthBuffer(!0),i.setAlphaMode(_.a.ALPHA_DISABLE),!0},e.prototype.dispose=function(){var e=this._vertexBuffers[gi.b.PositionKind];for(e&&(e.dispose(),this._vertexBuffers[gi.b.PositionKind]=null),this._indexBuffer&&(this._scene.getEngine()._releaseBuffer(this._indexBuffer),this._indexBuffer=null);this.lensFlares.length;)this.lensFlares[0].dispose();var t=this._scene.lensFlareSystems.indexOf(this);this._scene.lensFlareSystems.splice(t,1)},e.Parse=function(t,i,r){var n=i.getLastEntryByID(t.emitterId),s=t.name||"lensFlareSystem#"+t.emitterId,a=new e(s,n,i);a.id=t.id||s,a.borderLimit=t.borderLimit;for(var c=0;c<t.flares.length;c++){var l=t.flares[c];Ln.AddFlare(l.size,l.position,o.e.FromArray(l.color),l.textureName?r+l.textureName:"",a)}return a},e.prototype.serialize=function(){var e={};e.id=this.id,e.name=this.name,e.emitterId=this.getEmitter().id,e.borderLimit=this.borderLimit,e.flares=[];for(var t=0;t<this.lensFlares.length;t++){var i=this.lensFlares[t];e.flares.push({size:i.size,position:i.position,color:i.color.asArray(),textureName:ve.h.GetFilename(i.texture?i.texture.name:"")})}return e},e._SceneComponentInitialization=function(e){throw"Import LensFlareSystemSceneComponent before creating LensFlareSystem."},e}();r.a.AddParser(Te.a.NAME_LENSFLARESYSTEM,function(e,t,i,r){if(void 0!==e.lensFlareSystems&&null!==e.lensFlareSystems){i.lensFlareSystems||(i.lensFlareSystems=new Array);for(var n=0,o=e.lensFlareSystems.length;n<o;n++){var s=e.lensFlareSystems[n],a=Bn.Parse(s,t,r);i.lensFlareSystems.push(a)}}}),r.a.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.a.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.a.prototype.removeLensFlareSystem=function(e){var t=this.lensFlareSystems.indexOf(e);return-1!==t&&this.lensFlareSystems.splice(t,1),t},r.a.prototype.addLensFlareSystem=function(e){this.lensFlareSystems.push(e)};var Un=function(){function e(e){this.name=Te.a.NAME_LENSFLARESYSTEM,this.scene=e,e.lensFlareSystems=new Array}return e.prototype.register=function(){this.scene._afterCameraDrawStage.registerStep(Te.a.STEP_AFTERCAMERADRAW_LENSFLARESYSTEM,this,this._draw)},e.prototype.rebuild=function(){},e.prototype.addFromContainer=function(e){var t=this;e.lensFlareSystems&&e.lensFlareSystems.forEach(function(e){t.scene.addLensFlareSystem(e)})},e.prototype.removeFromContainer=function(e){var t=this;e.lensFlareSystems&&e.lensFlareSystems.forEach(function(e){t.scene.removeLensFlareSystem(e)})},e.prototype.serialize=function(e){e.lensFlareSystems=[];for(var t=0,i=this.scene.lensFlareSystems;t<i.length;t++){var r=i[t];e.lensFlareSystems.push(r.serialize())}},e.prototype.dispose=function(){for(var e=this.scene.lensFlareSystems;e.length;)e[0].dispose()},e.prototype._draw=function(e){if(this.scene.lensFlaresEnabled){var t=this.scene.lensFlareSystems;ve.h.StartPerformanceCounter("Lens flares",t.length>0);for(var i=0,r=t;i<r.length;i++){var n=r[i];0!=(e.layerMask&n.layerMask)&&n.render()}ve.h.EndPerformanceCounter("Lens flares",t.length>0)}},e}();Bn._SceneComponentInitialization=function(e){var t=e._getComponent(Te.a.NAME_LENSFLARESYSTEM);t||(t=new Un(e),e._addComponent(t))};var Vn=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._needProjectionMatrixCompute=!0,t}return l.d(t,e),t.prototype._setPosition=function(e){this._position=e},Object.defineProperty(t.prototype,"position",{get:function(){return this._position},set:function(e){this._setPosition(e)},enumerable:!0,configurable:!0}),t.prototype._setDirection=function(e){this._direction=e},Object.defineProperty(t.prototype,"direction",{get:function(){return this._direction},set:function(e){this._setDirection(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"shadowMinZ",{get:function(){return this._shadowMinZ},set:function(e){this._shadowMinZ=e,this.forceProjectionMatrixCompute()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"shadowMaxZ",{get:function(){return this._shadowMaxZ},set:function(e){this._shadowMaxZ=e,this.forceProjectionMatrixCompute()},enumerable:!0,configurable:!0}),t.prototype.computeTransformedInformation=function(){return!(!this.parent||!this.parent.getWorldMatrix)&&(this.transformedPosition||(this.transformedPosition=o.x.Zero()),o.x.TransformCoordinatesToRef(this.position,this.parent.getWorldMatrix(),this.transformedPosition),this.direction&&(this.transformedDirection||(this.transformedDirection=o.x.Zero()),o.x.TransformNormalToRef(this.direction,this.parent.getWorldMatrix(),this.transformedDirection)),!0)},t.prototype.getDepthScale=function(){return 50},t.prototype.getShadowDirection=function(e){return this.transformedDirection?this.transformedDirection:this.direction},t.prototype.getAbsolutePosition=function(){return this.transformedPosition?this.transformedPosition:this.position},t.prototype.setDirectionToTarget=function(e){return this.direction=o.x.Normalize(e.subtract(this.position)),this.direction},t.prototype.getRotation=function(){this.direction.normalize();var e=o.x.Cross(this.direction,o.c.Y),t=o.x.Cross(e,this.direction);return o.x.RotationFromAxis(e,t,this.direction)},t.prototype.needCube=function(){return!1},t.prototype.needProjectionMatrixCompute=function(){return this._needProjectionMatrixCompute},t.prototype.forceProjectionMatrixCompute=function(){this._needProjectionMatrixCompute=!0},t.prototype._initCache=function(){e.prototype._initCache.call(this),this._cache.position=o.x.Zero()},t.prototype._isSynchronized=function(){return!!this._cache.position.equals(this.position)},t.prototype.computeWorldMatrix=function(e){return!e&&this.isSynchronized()?(this._currentRenderId=this.getScene().getRenderId(),this._worldMatrix):(this._updateCache(),this._cache.position.copyFrom(this.position),this._worldMatrix||(this._worldMatrix=o.j.Identity()),o.j.TranslationToRef(this.position.x,this.position.y,this.position.z,this._worldMatrix),this.parent&&this.parent.getWorldMatrix&&(this._worldMatrix.multiplyToRef(this.parent.getWorldMatrix(),this._worldMatrix),this._markSyncedWithParent()),this._worldMatrixDeterminant=this._worldMatrix.determinant(),this._worldMatrix)},t.prototype.getDepthMinZ=function(e){return void 0!==this.shadowMinZ?this.shadowMinZ:e.minZ},t.prototype.getDepthMaxZ=function(e){return void 0!==this.shadowMaxZ?this.shadowMaxZ:e.maxZ},t.prototype.setShadowProjectionMatrix=function(e,t,i){return this.customProjectionMatrixBuilder?this.customProjectionMatrixBuilder(t,i,e):this._setDefaultShadowProjectionMatrix(e,t,i),this},l.c([Object(w.n)()],t.prototype,"position",null),l.c([Object(w.n)()],t.prototype,"direction",null),l.c([Object(w.c)()],t.prototype,"shadowMinZ",null),l.c([Object(w.c)()],t.prototype,"shadowMaxZ",null),t}(ri.a),Gn="#ifndef FLOAT\nvec4 pack(float depth)\n{\nconst vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);\nconst vec4 bit_mask=vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);\nvec4 res=fract(depth*bit_shift);\nres-=res.xxyz*bit_mask;\nreturn res;\n}\n#endif\nvarying float vDepthMetric;\n#ifdef ALPHATEST\nvarying vec2 vUV;\nuniform sampler2D diffuseSampler;\n#endif\nuniform vec3 biasAndScale;\nuniform vec2 depthValues;\nvoid main(void)\n{\n#ifdef ALPHATEST\nif (texture2D(diffuseSampler,vUV).a<0.4)\ndiscard;\n#endif\nfloat depth=vDepthMetric;\n#ifdef ESM\ndepth=clamp(exp(-min(87.,biasAndScale.z*depth)),0.,1.);\n#endif\n#ifdef FLOAT\ngl_FragColor=vec4(depth,1.0,1.0,1.0);\n#else\ngl_FragColor=pack(depth);\n#endif\n}";St.a.ShadersStore.shadowMapPixelShader=Gn;var kn="\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\nuniform vec3 lightData;\n#endif\n#include<bonesDeclaration>\n#include<morphTargetsVertexGlobalDeclaration>\n#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]\n\n#include<instancesDeclaration>\n#include<helperFunctions>\nuniform mat4 viewProjection;\nuniform vec3 biasAndScale;\nuniform vec2 depthValues;\nvarying float vDepthMetric;\n#ifdef ALPHATEST\nvarying vec2 vUV;\nuniform mat4 diffuseMatrix;\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#endif\nvoid main(void)\n{\nvec3 positionUpdated=position;\n#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]\n#include<instancesVertex>\n#include<bonesVertex>\nvec4 worldPos=finalWorld*vec4(positionUpdated,1.0);\n\n#ifdef NORMAL\nmat3 normalWorld=mat3(finalWorld);\n#ifdef NONUNIFORMSCALING\nnormalWorld=transposeMat3(inverseMat3(normalWorld));\n#endif\nvec3 worldNor=normalize(normalWorld*normal);\n#ifdef DIRECTIONINLIGHTDATA\nvec3 worldLightDir=normalize(-lightData.xyz);\n#else\nvec3 directionToLight=lightData.xyz-worldPos.xyz;\nvec3 worldLightDir=normalize(directionToLight);\n#endif\nfloat ndl=dot(worldNor,worldLightDir);\nfloat sinNL=sqrt(1.0-ndl*ndl);\nfloat normalBias=biasAndScale.y*sinNL;\nworldPos.xyz-=worldNor*normalBias;\n#endif\n\ngl_Position=viewProjection*worldPos;\n#ifdef DEPTHTEXTURE\n\ngl_Position.z+=biasAndScale.x*gl_Position.w;\n#endif\n\nvDepthMetric=((gl_Position.z+depthValues.x)/(depthValues.y))+biasAndScale.x;\n#ifdef ALPHATEST\n#ifdef UV1\nvUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n#endif\n#ifdef UV2\nvUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n}";St.a.ShadersStore.shadowMapVertexShader=kn;var zn="\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n\nuniform vec2 screenSize;\nvoid main(void)\n{\nvec4 colorDepth=vec4(0.0);\nfor (int x=-OFFSET; x<=OFFSET; x++)\nfor (int y=-OFFSET; y<=OFFSET; y++)\ncolorDepth+=texture2D(textureSampler,vUV+vec2(x,y)/screenSize);\ngl_FragColor=(colorDepth/float((OFFSET*2+1)*(OFFSET*2+1)));\n}";St.a.ShadersStore.depthBoxBlurPixelShader=zn;var jn=function(){function e(t,i,r){this.onBeforeShadowMapRenderObservable=new n.c,this._bias=5e-5,this._normalBias=0,this._blurBoxOffset=1,this._blurScale=2,this._blurKernel=1,this._useKernelBlur=!1,this._filter=e.FILTER_NONE,this._filteringQuality=e.QUALITY_HIGH,this._contactHardeningLightSizeUVRatio=.1,this._darkness=0,this._transparencyShadow=!1,this.frustumEdgeFalloff=0,this.forceBackFacesOnly=!1,this._lightDirection=o.x.Zero(),this._viewMatrix=o.j.Zero(),this._projectionMatrix=o.j.Zero(),this._transformMatrix=o.j.Zero(),this._cachedPosition=new o.x(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cachedDirection=new o.x(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._currentFaceIndex=0,this._currentFaceIndexCache=0,this._defaultTextureMatrix=o.j.Identity(),this._mapSize=t,this._light=i,this._scene=i.getScene(),i._shadowGenerator=this,e._SceneComponentInitialization(this._scene);var s=this._scene.getEngine().getCaps();r?s.textureFloatRender&&s.textureFloatLinearFiltering?this._textureType=_.a.TEXTURETYPE_FLOAT:s.textureHalfFloatRender&&s.textureHalfFloatLinearFiltering?this._textureType=_.a.TEXTURETYPE_HALF_FLOAT:this._textureType=_.a.TEXTURETYPE_UNSIGNED_INT:s.textureHalfFloatRender&&s.textureHalfFloatLinearFiltering?this._textureType=_.a.TEXTURETYPE_HALF_FLOAT:s.textureFloatRender&&s.textureFloatLinearFiltering?this._textureType=_.a.TEXTURETYPE_FLOAT:this._textureType=_.a.TEXTURETYPE_UNSIGNED_INT,this._initializeGenerator(),this._applyFilterValues()}return Object.defineProperty(e.prototype,"bias",{get:function(){return this._bias},set:function(e){this._bias=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"normalBias",{get:function(){return this._normalBias},set:function(e){this._normalBias=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"blurBoxOffset",{get:function(){return this._blurBoxOffset},set:function(e){this._blurBoxOffset!==e&&(this._blurBoxOffset=e,this._disposeBlurPostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"blurScale",{get:function(){return this._blurScale},set:function(e){this._blurScale!==e&&(this._blurScale=e,this._disposeBlurPostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"blurKernel",{get:function(){return this._blurKernel},set:function(e){this._blurKernel!==e&&(this._blurKernel=e,this._disposeBlurPostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"useKernelBlur",{get:function(){return this._useKernelBlur},set:function(e){this._useKernelBlur!==e&&(this._useKernelBlur=e,this._disposeBlurPostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"depthScale",{get:function(){return void 0!==this._depthScale?this._depthScale:this._light.getDepthScale()},set:function(e){this._depthScale=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"filter",{get:function(){return this._filter},set:function(t){if(this._light.needCube()){if(t===e.FILTER_BLUREXPONENTIALSHADOWMAP)return void(this.useExponentialShadowMap=!0);if(t===e.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP)return void(this.useCloseExponentialShadowMap=!0);if(t===e.FILTER_PCF||t===e.FILTER_PCSS)return void(this.usePoissonSampling=!0)}t!==e.FILTER_PCF&&t!==e.FILTER_PCSS||1!==this._scene.getEngine().webGLVersion?this._filter!==t&&(this._filter=t,this._disposeBlurPostProcesses(),this._applyFilterValues(),this._light._markMeshesAsLightDirty()):this.usePoissonSampling=!0},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"usePoissonSampling",{get:function(){return this.filter===e.FILTER_POISSONSAMPLING},set:function(t){(t||this.filter===e.FILTER_POISSONSAMPLING)&&(this.filter=t?e.FILTER_POISSONSAMPLING:e.FILTER_NONE)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"useExponentialShadowMap",{get:function(){return this.filter===e.FILTER_EXPONENTIALSHADOWMAP},set:function(t){(t||this.filter===e.FILTER_EXPONENTIALSHADOWMAP)&&(this.filter=t?e.FILTER_EXPONENTIALSHADOWMAP:e.FILTER_NONE)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"useBlurExponentialShadowMap",{get:function(){return this.filter===e.FILTER_BLUREXPONENTIALSHADOWMAP},set:function(t){(t||this.filter===e.FILTER_BLUREXPONENTIALSHADOWMAP)&&(this.filter=t?e.FILTER_BLUREXPONENTIALSHADOWMAP:e.FILTER_NONE)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"useCloseExponentialShadowMap",{get:function(){return this.filter===e.FILTER_CLOSEEXPONENTIALSHADOWMAP},set:function(t){(t||this.filter===e.FILTER_CLOSEEXPONENTIALSHADOWMAP)&&(this.filter=t?e.FILTER_CLOSEEXPONENTIALSHADOWMAP:e.FILTER_NONE)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"useBlurCloseExponentialShadowMap",{get:function(){return this.filter===e.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP},set:function(t){(t||this.filter===e.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP)&&(this.filter=t?e.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP:e.FILTER_NONE)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"usePercentageCloserFiltering",{get:function(){return this.filter===e.FILTER_PCF},set:function(t){(t||this.filter===e.FILTER_PCF)&&(this.filter=t?e.FILTER_PCF:e.FILTER_NONE)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"filteringQuality",{get:function(){return this._filteringQuality},set:function(e){this._filteringQuality=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"useContactHardeningShadow",{get:function(){return this.filter===e.FILTER_PCSS},set:function(t){(t||this.filter===e.FILTER_PCSS)&&(this.filter=t?e.FILTER_PCSS:e.FILTER_NONE)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"contactHardeningLightSizeUVRatio",{get:function(){return this._contactHardeningLightSizeUVRatio},set:function(e){this._contactHardeningLightSizeUVRatio=e},enumerable:!0,configurable:!0}),e.prototype.getDarkness=function(){return this._darkness},e.prototype.setDarkness=function(e){return this._darkness=e>=1?1:e<=0?0:e,this},e.prototype.setTransparencyShadow=function(e){return this._transparencyShadow=e,this},e.prototype.getShadowMap=function(){return this._shadowMap},e.prototype.getShadowMapForRendering=function(){return this._shadowMap2?this._shadowMap2:this._shadowMap},e.prototype.addShadowCaster=function(e,t){var i;return void 0===t&&(t=!0),this._shadowMap?(this._shadowMap.renderList||(this._shadowMap.renderList=[]),this._shadowMap.renderList.push(e),t&&(i=this._shadowMap.renderList).push.apply(i,e.getChildMeshes()),this):this},e.prototype.removeShadowCaster=function(e,t){if(void 0===t&&(t=!0),!this._shadowMap||!this._shadowMap.renderList)return this;var i=this._shadowMap.renderList.indexOf(e);if(-1!==i&&this._shadowMap.renderList.splice(i,1),t)for(var r=0,n=e.getChildren();r<n.length;r++){var o=n[r];this.removeShadowCaster(o)}return this},e.prototype.getLight=function(){return this._light},e.prototype._initializeGenerator=function(){this._light._markMeshesAsLightDirty(),this._initializeShadowMap()},e.prototype._initializeShadowMap=function(){var t=this,i=this._scene.getEngine();i.webGLVersion>1?(this._shadowMap=new Mi(this._light.name+"_shadowMap",this._mapSize,this._scene,!1,!0,this._textureType,this._light.needCube(),void 0,!1,!1),this._shadowMap.createDepthStencilTexture(_.a.LESS,!0)):this._shadowMap=new Mi(this._light.name+"_shadowMap",this._mapSize,this._scene,!1,!0,this._textureType,this._light.needCube()),this._shadowMap.wrapU=Ve.a.CLAMP_ADDRESSMODE,this._shadowMap.wrapV=Ve.a.CLAMP_ADDRESSMODE,this._shadowMap.anisotropicFilteringLevel=1,this._shadowMap.updateSamplingMode(Ve.a.BILINEAR_SAMPLINGMODE),this._shadowMap.renderParticles=!1,this._shadowMap.ignoreCameraViewport=!0,this._shadowMap.onBeforeRenderObservable.add(function(r){t._currentFaceIndex=r,t._filter===e.FILTER_PCF&&i.setColorWrite(!1)}),this._shadowMap.customRenderFunction=this._renderForShadowMap.bind(this),this._shadowMap.onAfterUnbindObservable.add(function(){if(t._filter===e.FILTER_PCF&&i.setColorWrite(!0),t.useBlurExponentialShadowMap||t.useBlurCloseExponentialShadowMap){var r=t.getShadowMapForRendering();r&&t._scene.postProcessManager.directRender(t._blurPostProcesses,r.getInternalTexture(),!0)}});var r=new o.f(0,0,0,0),n=new o.f(1,1,1,1);this._shadowMap.onClearObservable.add(function(i){t._filter===e.FILTER_PCF?i.clear(n,!1,!0,!1):t.useExponentialShadowMap||t.useBlurExponentialShadowMap?i.clear(r,!0,!0,!1):i.clear(n,!0,!0,!1)})},e.prototype._initializeBlurRTTAndPostProcesses=function(){var e=this,t=this._scene.getEngine(),i=this._mapSize/this.blurScale;this.useKernelBlur&&1===this.blurScale||(this._shadowMap2=new Mi(this._light.name+"_shadowMap2",i,this._scene,!1,!0,this._textureType),this._shadowMap2.wrapU=Ve.a.CLAMP_ADDRESSMODE,this._shadowMap2.wrapV=Ve.a.CLAMP_ADDRESSMODE,this._shadowMap2.updateSamplingMode(Ve.a.BILINEAR_SAMPLINGMODE)),this.useKernelBlur?(this._kernelBlurXPostprocess=new Ur(this._light.name+"KernelBlurX",new o.w(1,0),this.blurKernel,1,null,Ve.a.BILINEAR_SAMPLINGMODE,t,!1,this._textureType),this._kernelBlurXPostprocess.width=i,this._kernelBlurXPostprocess.height=i,this._kernelBlurXPostprocess.onApplyObservable.add(function(t){t.setTexture("textureSampler",e._shadowMap)}),this._kernelBlurYPostprocess=new Ur(this._light.name+"KernelBlurY",new o.w(0,1),this.blurKernel,1,null,Ve.a.BILINEAR_SAMPLINGMODE,t,!1,this._textureType),this._kernelBlurXPostprocess.autoClear=!1,this._kernelBlurYPostprocess.autoClear=!1,this._textureType===_.a.TEXTURETYPE_UNSIGNED_INT&&(this._kernelBlurXPostprocess.packedFloat=!0,this._kernelBlurYPostprocess.packedFloat=!0),this._blurPostProcesses=[this._kernelBlurXPostprocess,this._kernelBlurYPostprocess]):(this._boxBlurPostprocess=new Mt(this._light.name+"DepthBoxBlur","depthBoxBlur",["screenSize","boxOffset"],[],1,null,Ve.a.BILINEAR_SAMPLINGMODE,t,!1,"#define OFFSET "+this._blurBoxOffset,this._textureType),this._boxBlurPostprocess.onApplyObservable.add(function(t){t.setFloat2("screenSize",i,i),t.setTexture("textureSampler",e._shadowMap)}),this._boxBlurPostprocess.autoClear=!1,this._blurPostProcesses=[this._boxBlurPostprocess])},e.prototype._renderForShadowMap=function(e,t,i,r){var n,o=this._scene.getEngine();if(r.length){for(o.setColorWrite(!1),n=0;n<r.length;n++)this._renderSubMeshForShadowMap(r.data[n]);o.setColorWrite(!0)}for(n=0;n<e.length;n++)this._renderSubMeshForShadowMap(e.data[n]);for(n=0;n<t.length;n++)this._renderSubMeshForShadowMap(t.data[n]);if(this._transparencyShadow)for(n=0;n<i.length;n++)this._renderSubMeshForShadowMap(i.data[n])},e.prototype._renderSubMeshForShadowMap=function(e){var t=this,i=e.getRenderingMesh(),r=this._scene,n=r.getEngine(),o=e.getMaterial();if(o&&0!==e.verticesCount){n.setState(o.backFaceCulling);var s=i._getInstancesRenderList(e._id);if(!s.mustReturn){var a=n.getCaps().instancedArrays&&null!==s.visibleInstances[e._id]&&void 0!==s.visibleInstances[e._id];if(this.isReady(e,a)){if(n.enableEffect(this._effect),i._bind(e,this._effect,yn.a.TriangleFillMode),this._effect.setFloat3("biasAndScale",this.bias,this.normalBias,this.depthScale),this._effect.setMatrix("viewProjection",this.getTransformMatrix()),this.getLight().getTypeID()===ri.a.LIGHTTYPEID_DIRECTIONALLIGHT?this._effect.setVector3("lightData",this._cachedDirection):this._effect.setVector3("lightData",this._cachedPosition),r.activeCamera&&this._effect.setFloat2("depthValues",this.getLight().getDepthMinZ(r.activeCamera),this.getLight().getDepthMinZ(r.activeCamera)+this.getLight().getDepthMaxZ(r.activeCamera)),o&&o.needAlphaTesting()){var c=o.getAlphaTestTexture();c&&(this._effect.setTexture("diffuseSampler",c),this._effect.setMatrix("diffuseMatrix",c.getTextureMatrix()||this._defaultTextureMatrix))}if(i.useBones&&i.computeBonesUsingShaders&&i.skeleton){var l=i.skeleton;if(l.isUsingTextureForMatrices){var u=l.getTransformMatrixTexture();if(!u)return;this._effect.setTexture("boneSampler",u),this._effect.setFloat("boneTextureWidth",4*(l.bones.length+1))}else this._effect.setMatrices("mBones",l.getTransformMatrices(i))}kr.a.BindMorphTargetParameters(i,this._effect),this.forceBackFacesOnly&&n.setState(!0,0,!1,!0),this.onBeforeShadowMapRenderObservable.notifyObservers(this._effect),i._processRendering(e,this._effect,yn.a.TriangleFillMode,s,a,function(e,i){return t._effect.setMatrix("world",i)}),this.forceBackFacesOnly&&n.setState(!0,0,!1,!1)}else this._shadowMap&&this._shadowMap.resetRefreshCounter()}}},e.prototype._applyFilterValues=function(){this._shadowMap&&(this.filter===e.FILTER_NONE||this.filter===e.FILTER_PCSS?this._shadowMap.updateSamplingMode(Ve.a.NEAREST_SAMPLINGMODE):this._shadowMap.updateSamplingMode(Ve.a.BILINEAR_SAMPLINGMODE))},e.prototype.forceCompilation=function(e,t){var i=this,r=l.a({useInstances:!1},t),n=this.getShadowMap();if(n){var o=n.renderList;if(o){for(var s=new Array,a=0,c=o;a<c.length;a++){var u=c[a];s.push.apply(s,u.subMeshes)}if(0!==s.length){var h=0,d=function(){if(i._scene&&i._scene.getEngine()){for(;i.isReady(s[h],r.useInstances);)if(++h>=s.length)return void(e&&e(i));setTimeout(d,16)}};d()}else e&&e(this)}else e&&e(this)}else e&&e(this)},e.prototype.forceCompilationAsync=function(e){var t=this;return new Promise(function(i){t.forceCompilation(function(){i()},e)})},e.prototype.isReady=function(e,t){var i=[];this._textureType!==_.a.TEXTURETYPE_UNSIGNED_INT&&i.push("#define FLOAT"),this.useExponentialShadowMap||this.useBlurExponentialShadowMap?i.push("#define ESM"):(this.usePercentageCloserFiltering||this.useContactHardeningShadow)&&i.push("#define DEPTHTEXTURE");var r=[gi.b.PositionKind],n=e.getMesh(),o=e.getMaterial();if(this.normalBias&&n.isVerticesDataPresent(gi.b.NormalKind)&&(r.push(gi.b.NormalKind),i.push("#define NORMAL"),n.nonUniformScaling&&i.push("#define NONUNIFORMSCALING"),this.getLight().getTypeID()===ri.a.LIGHTTYPEID_DIRECTIONALLIGHT&&i.push("#define DIRECTIONINLIGHTDATA")),o&&o.needAlphaTesting()){var s=o.getAlphaTestTexture();s&&(i.push("#define ALPHATEST"),n.isVerticesDataPresent(gi.b.UVKind)&&(r.push(gi.b.UVKind),i.push("#define UV1")),n.isVerticesDataPresent(gi.b.UV2Kind)&&1===s.coordinatesIndex&&(r.push(gi.b.UV2Kind),i.push("#define UV2")))}if(n.useBones&&n.computeBonesUsingShaders&&n.skeleton){r.push(gi.b.MatricesIndicesKind),r.push(gi.b.MatricesWeightsKind),n.numBoneInfluencers>4&&(r.push(gi.b.MatricesIndicesExtraKind),r.push(gi.b.MatricesWeightsExtraKind));var a=n.skeleton;i.push("#define NUM_BONE_INFLUENCERS "+n.numBoneInfluencers),a.isUsingTextureForMatrices?i.push("#define BONETEXTURE"):i.push("#define BonesPerMesh "+(a.bones.length+1))}else i.push("#define NUM_BONE_INFLUENCERS 0");var c=n.morphTargetManager,l=0;if(c&&c.numInfluencers>0&&(i.push("#define MORPHTARGETS"),l=c.numInfluencers,i.push("#define NUM_MORPH_INFLUENCERS "+l),kr.a.PrepareAttributesForMorphTargets(r,n,{NUM_MORPH_INFLUENCERS:l})),t&&(i.push("#define INSTANCES"),r.push("world0"),r.push("world1"),r.push("world2"),r.push("world3")),this.customShaderOptions&&this.customShaderOptions.defines)for(var u=0,h=this.customShaderOptions.defines;u<h.length;u++){var d=h[u];-1===i.indexOf(d)&&i.push(d)}var f=i.join("\n");if(this._cachedDefines!==f){this._cachedDefines=f;var p="shadowMap",g=["world","mBones","viewProjection","diffuseMatrix","lightData","depthValues","biasAndScale","morphTargetInfluences","boneTextureWidth"],m=["diffuseSampler","boneSampler"];if(this.customShaderOptions){if(p=this.customShaderOptions.shaderName,this.customShaderOptions.attributes)for(var v=0,y=this.customShaderOptions.attributes;v<y.length;v++){var b=y[v];-1===r.indexOf(b)&&r.push(b)}if(this.customShaderOptions.uniforms)for(var T=0,E=this.customShaderOptions.uniforms;T<E.length;T++){var x=E[T];-1===g.indexOf(x)&&g.push(x)}if(this.customShaderOptions.samplers)for(var A=0,P=this.customShaderOptions.samplers;A<P.length;A++){var R=P[A];-1===m.indexOf(R)&&m.push(R)}}this._effect=this._scene.getEngine().createEffect(p,r,g,m,f,void 0,void 0,void 0,{maxSimultaneousMorphTargets:l})}return!!this._effect.isReady()&&((this.useBlurExponentialShadowMap||this.useBlurCloseExponentialShadowMap)&&(this._blurPostProcesses&&this._blurPostProcesses.length||this._initializeBlurRTTAndPostProcesses()),!(this._kernelBlurXPostprocess&&!this._kernelBlurXPostprocess.isReady())&&(!(this._kernelBlurYPostprocess&&!this._kernelBlurYPostprocess.isReady())&&!(this._boxBlurPostprocess&&!this._boxBlurPostprocess.isReady())))},e.prototype.prepareDefines=function(t,i){var r=this._scene,n=this._light;r.shadowsEnabled&&n.shadowEnabled&&(t["SHADOW"+i]=!0,this.useContactHardeningShadow&&(t["SHADOWPCSS"+i]=!0,this._filteringQuality===e.QUALITY_LOW?t["SHADOWLOWQUALITY"+i]=!0:this._filteringQuality===e.QUALITY_MEDIUM&&(t["SHADOWMEDIUMQUALITY"+i]=!0)),this.usePercentageCloserFiltering?(t["SHADOWPCF"+i]=!0,this._filteringQuality===e.QUALITY_LOW?t["SHADOWLOWQUALITY"+i]=!0:this._filteringQuality===e.QUALITY_MEDIUM&&(t["SHADOWMEDIUMQUALITY"+i]=!0)):this.usePoissonSampling?t["SHADOWPOISSON"+i]=!0:this.useExponentialShadowMap||this.useBlurExponentialShadowMap?t["SHADOWESM"+i]=!0:(this.useCloseExponentialShadowMap||this.useBlurCloseExponentialShadowMap)&&(t["SHADOWCLOSEESM"+i]=!0),n.needCube()&&(t["SHADOWCUBE"+i]=!0))},e.prototype.bindShadowLight=function(t,i){var r=this._light,n=this._scene;if(n.shadowsEnabled&&r.shadowEnabled){var o=n.activeCamera;if(o){var s=this.getShadowMap();s&&(r.needCube()||i.setMatrix("lightMatrix"+t,this.getTransformMatrix()),this._filter===e.FILTER_PCF?(i.setDepthStencilTexture("shadowSampler"+t,this.getShadowMapForRendering()),r._uniformBuffer.updateFloat4("shadowsInfo",this.getDarkness(),s.getSize().width,1/s.getSize().width,this.frustumEdgeFalloff,t)):this._filter===e.FILTER_PCSS?(i.setDepthStencilTexture("shadowSampler"+t,this.getShadowMapForRendering()),i.setTexture("depthSampler"+t,this.getShadowMapForRendering()),r._uniformBuffer.updateFloat4("shadowsInfo",this.getDarkness(),1/s.getSize().width,this._contactHardeningLightSizeUVRatio*s.getSize().width,this.frustumEdgeFalloff,t)):(i.setTexture("shadowSampler"+t,this.getShadowMapForRendering()),r._uniformBuffer.updateFloat4("shadowsInfo",this.getDarkness(),this.blurScale/s.getSize().width,this.depthScale,this.frustumEdgeFalloff,t)),r._uniformBuffer.updateFloat2("depthValues",this.getLight().getDepthMinZ(o),this.getLight().getDepthMinZ(o)+this.getLight().getDepthMaxZ(o),t))}}},e.prototype.getTransformMatrix=function(){var e=this._scene;if(this._currentRenderID===e.getRenderId()&&this._currentFaceIndexCache===this._currentFaceIndex)return this._transformMatrix;this._currentRenderID=e.getRenderId(),this._currentFaceIndexCache=this._currentFaceIndex;var t=this._light.position;if(this._light.computeTransformedInformation()&&(t=this._light.transformedPosition),o.x.NormalizeToRef(this._light.getShadowDirection(this._currentFaceIndex),this._lightDirection),1===Math.abs(o.x.Dot(this._lightDirection,o.x.Up()))&&(this._lightDirection.z=1e-13),this._light.needProjectionMatrixCompute()||!this._cachedPosition||!this._cachedDirection||!t.equals(this._cachedPosition)||!this._lightDirection.equals(this._cachedDirection)){this._cachedPosition.copyFrom(t),this._cachedDirection.copyFrom(this._lightDirection),o.j.LookAtLHToRef(t,t.add(this._lightDirection),o.x.Up(),this._viewMatrix);var i=this.getShadowMap();if(i){var r=i.renderList;r&&this._light.setShadowProjectionMatrix(this._projectionMatrix,this._viewMatrix,r)}this._viewMatrix.multiplyToRef(this._projectionMatrix,this._transformMatrix)}return this._transformMatrix},e.prototype.recreateShadowMap=function(){var e=this._shadowMap;if(e){var t=e.renderList;this._disposeRTTandPostProcesses(),this._initializeGenerator(),this.filter=this.filter,this._applyFilterValues(),this._shadowMap.renderList=t}},e.prototype._disposeBlurPostProcesses=function(){this._shadowMap2&&(this._shadowMap2.dispose(),this._shadowMap2=null),this._boxBlurPostprocess&&(this._boxBlurPostprocess.dispose(),this._boxBlurPostprocess=null),this._kernelBlurXPostprocess&&(this._kernelBlurXPostprocess.dispose(),this._kernelBlurXPostprocess=null),this._kernelBlurYPostprocess&&(this._kernelBlurYPostprocess.dispose(),this._kernelBlurYPostprocess=null),this._blurPostProcesses=[]},e.prototype._disposeRTTandPostProcesses=function(){this._shadowMap&&(this._shadowMap.dispose(),this._shadowMap=null),this._disposeBlurPostProcesses()},e.prototype.dispose=function(){this._disposeRTTandPostProcesses(),this._light&&(this._light._shadowGenerator=null,this._light._markMeshesAsLightDirty())},e.prototype.serialize=function(){var e={},t=this.getShadowMap();if(!t)return e;if(e.lightId=this._light.id,e.mapSize=t.getRenderSize(),e.useExponentialShadowMap=this.useExponentialShadowMap,e.useBlurExponentialShadowMap=this.useBlurExponentialShadowMap,e.useCloseExponentialShadowMap=this.useBlurExponentialShadowMap,e.useBlurCloseExponentialShadowMap=this.useBlurExponentialShadowMap,e.usePoissonSampling=this.usePoissonSampling,e.forceBackFacesOnly=this.forceBackFacesOnly,e.depthScale=this.depthScale,e.darkness=this.getDarkness(),e.blurBoxOffset=this.blurBoxOffset,e.blurKernel=this.blurKernel,e.blurScale=this.blurScale,e.useKernelBlur=this.useKernelBlur,e.transparencyShadow=this._transparencyShadow,e.frustumEdgeFalloff=this.frustumEdgeFalloff,e.bias=this.bias,e.normalBias=this.normalBias,e.usePercentageCloserFiltering=this.usePercentageCloserFiltering,e.useContactHardeningShadow=this.useContactHardeningShadow,e.filteringQuality=this.filteringQuality,e.contactHardeningLightSizeUVRatio=this.contactHardeningLightSizeUVRatio,e.renderList=[],t.renderList)for(var i=0;i<t.renderList.length;i++){var r=t.renderList[i];e.renderList.push(r.id)}return e},e.Parse=function(t,i){for(var r=i.getLightByID(t.lightId),n=new e(t.mapSize,r),o=n.getShadowMap(),s=0;s<t.renderList.length;s++){i.getMeshesByID(t.renderList[s]).forEach(function(e){o&&(o.renderList||(o.renderList=[]),o.renderList.push(e))})}return t.usePoissonSampling?n.usePoissonSampling=!0:t.useExponentialShadowMap?n.useExponentialShadowMap=!0:t.useBlurExponentialShadowMap?n.useBlurExponentialShadowMap=!0:t.useCloseExponentialShadowMap?n.useCloseExponentialShadowMap=!0:t.useBlurCloseExponentialShadowMap?n.useBlurCloseExponentialShadowMap=!0:t.usePercentageCloserFiltering?n.usePercentageCloserFiltering=!0:t.useContactHardeningShadow&&(n.useContactHardeningShadow=!0),t.filteringQuality&&(n.filteringQuality=t.filteringQuality),t.contactHardeningLightSizeUVRatio?n.contactHardeningLightSizeUVRatio=t.contactHardeningLightSizeUVRatio:t.useVarianceShadowMap?n.useExponentialShadowMap=!0:t.useBlurVarianceShadowMap&&(n.useBlurExponentialShadowMap=!0),t.depthScale&&(n.depthScale=t.depthScale),t.blurScale&&(n.blurScale=t.blurScale),t.blurBoxOffset&&(n.blurBoxOffset=t.blurBoxOffset),t.useKernelBlur&&(n.useKernelBlur=t.useKernelBlur),t.blurKernel&&(n.blurKernel=t.blurKernel),void 0!==t.bias&&(n.bias=t.bias),void 0!==t.normalBias&&(n.normalBias=t.normalBias),void 0!==t.frustumEdgeFalloff&&(n.frustumEdgeFalloff=t.frustumEdgeFalloff),t.darkness&&n.setDarkness(t.darkness),t.transparencyShadow&&n.setTransparencyShadow(!0),n.forceBackFacesOnly=t.forceBackFacesOnly,n},e.FILTER_NONE=0,e.FILTER_EXPONENTIALSHADOWMAP=1,e.FILTER_POISSONSAMPLING=2,e.FILTER_BLUREXPONENTIALSHADOWMAP=3,e.FILTER_CLOSEEXPONENTIALSHADOWMAP=4,e.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP=5,e.FILTER_PCF=6,e.FILTER_PCSS=7,e.QUALITY_HIGH=0,e.QUALITY_MEDIUM=1,e.QUALITY_LOW=2,e._SceneComponentInitialization=function(e){throw"Import ShadowGeneratorSceneComponent before creating ShadowGenerator."},e}();r.a.AddParser(Te.a.NAME_SHADOWGENERATOR,function(e,t){if(void 0!==e.shadowGenerators&&null!==e.shadowGenerators)for(var i=0,r=e.shadowGenerators.length;i<r;i++){var n=e.shadowGenerators[i];jn.Parse(n,t)}});var Wn=function(){function e(e){this.name=Te.a.NAME_SHADOWGENERATOR,this.scene=e}return e.prototype.register=function(){this.scene._gatherRenderTargetsStage.registerStep(Te.a.STEP_GATHERRENDERTARGETS_SHADOWGENERATOR,this,this._gatherRenderTargets)},e.prototype.rebuild=function(){},e.prototype.serialize=function(e){e.shadowGenerators=[];for(var t=0,i=this.scene.lights;t<i.length;t++){var r=i[t].getShadowGenerator();r&&e.shadowGenerators.push(r.serialize())}},e.prototype.addFromContainer=function(e){},e.prototype.removeFromContainer=function(e){},e.prototype.dispose=function(){},e.prototype._gatherRenderTargets=function(e){var t=this.scene;if(this.scene.shadowsEnabled)for(var i=0;i<t.lights.length;i++){var r=t.lights[i],n=r.getShadowGenerator();if(r.isEnabled()&&r.shadowEnabled&&n){var o=n.getShadowMap();-1!==t.textures.indexOf(o)&&e.push(o)}}},e}();jn._SceneComponentInitialization=function(e){var t=e._getComponent(Te.a.NAME_SHADOWGENERATOR);t||(t=new Wn(e),e._addComponent(t))},F.a.AddNodeConstructor("Light_Type_1",function(e,t){return function(){return new Hn(e,o.x.Zero(),t)}});var Hn=function(e){function t(t,i,r){var n=e.call(this,t,r)||this;return n._shadowFrustumSize=0,n._shadowOrthoScale=.1,n.autoUpdateExtends=!0,n._orthoLeft=Number.MAX_VALUE,n._orthoRight=Number.MIN_VALUE,n._orthoTop=Number.MIN_VALUE,n._orthoBottom=Number.MAX_VALUE,n.position=i.scale(-1),n.direction=i,n}return l.d(t,e),Object.defineProperty(t.prototype,"shadowFrustumSize",{get:function(){return this._shadowFrustumSize},set:function(e){this._shadowFrustumSize=e,this.forceProjectionMatrixCompute()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"shadowOrthoScale",{get:function(){return this._shadowOrthoScale},set:function(e){this._shadowOrthoScale=e,this.forceProjectionMatrixCompute()},enumerable:!0,configurable:!0}),t.prototype.getClassName=function(){return"DirectionalLight"},t.prototype.getTypeID=function(){return ri.a.LIGHTTYPEID_DIRECTIONALLIGHT},t.prototype._setDefaultShadowProjectionMatrix=function(e,t,i){this.shadowFrustumSize>0?this._setDefaultFixedFrustumShadowProjectionMatrix(e):this._setDefaultAutoExtendShadowProjectionMatrix(e,t,i)},t.prototype._setDefaultFixedFrustumShadowProjectionMatrix=function(e){var t=this.getScene().activeCamera;t&&o.j.OrthoLHToRef(this.shadowFrustumSize,this.shadowFrustumSize,void 0!==this.shadowMinZ?this.shadowMinZ:t.minZ,void 0!==this.shadowMaxZ?this.shadowMaxZ:t.maxZ,e)},t.prototype._setDefaultAutoExtendShadowProjectionMatrix=function(e,t,i){var r=this.getScene().activeCamera;if(r){if(this.autoUpdateExtends||this._orthoLeft===Number.MAX_VALUE){var n=o.x.Zero();this._orthoLeft=Number.MAX_VALUE,this._orthoRight=Number.MIN_VALUE,this._orthoTop=Number.MIN_VALUE,this._orthoBottom=Number.MAX_VALUE;for(var s=0;s<i.length;s++){var a=i[s];if(a)for(var c=a.getBoundingInfo().boundingBox,l=0;l<c.vectorsWorld.length;l++)o.x.TransformCoordinatesToRef(c.vectorsWorld[l],t,n),n.x<this._orthoLeft&&(this._orthoLeft=n.x),n.y<this._orthoBottom&&(this._orthoBottom=n.y),n.x>this._orthoRight&&(this._orthoRight=n.x),n.y>this._orthoTop&&(this._orthoTop=n.y)}}var u=this._orthoRight-this._orthoLeft,h=this._orthoTop-this._orthoBottom;o.j.OrthoOffCenterLHToRef(this._orthoLeft-u*this.shadowOrthoScale,this._orthoRight+u*this.shadowOrthoScale,this._orthoBottom-h*this.shadowOrthoScale,this._orthoTop+h*this.shadowOrthoScale,void 0!==this.shadowMinZ?this.shadowMinZ:r.minZ,void 0!==this.shadowMaxZ?this.shadowMaxZ:r.maxZ,e)}},t.prototype._buildUniformLayout=function(){this._uniformBuffer.addUniform("vLightData",4),this._uniformBuffer.addUniform("vLightDiffuse",4),this._uniformBuffer.addUniform("vLightSpecular",3),this._uniformBuffer.addUniform("shadowsInfo",3),this._uniformBuffer.addUniform("depthValues",2),this._uniformBuffer.create()},t.prototype.transferToEffect=function(e,t){return this.computeTransformedInformation()?(this._uniformBuffer.updateFloat4("vLightData",this.transformedDirection.x,this.transformedDirection.y,this.transformedDirection.z,1,t),this):(this._uniformBuffer.updateFloat4("vLightData",this.direction.x,this.direction.y,this.direction.z,1,t),this)},t.prototype.getDepthMinZ=function(e){return 1},t.prototype.getDepthMaxZ=function(e){return 1},t.prototype.prepareLightSpecificDefines=function(e,t){e["DIRLIGHT"+t]=!0},l.c([Object(w.c)()],t.prototype,"shadowFrustumSize",null),l.c([Object(w.c)()],t.prototype,"shadowOrthoScale",null),l.c([Object(w.c)()],t.prototype,"autoUpdateExtends",void 0),t}(Vn);F.a.AddNodeConstructor("Light_Type_0",function(e,t){return function(){return new Xn(e,o.x.Zero(),t)}});var Xn=function(e){function t(t,i,r){var n=e.call(this,t,r)||this;return n._shadowAngle=Math.PI/2,n.position=i,n}return l.d(t,e),Object.defineProperty(t.prototype,"shadowAngle",{get:function(){return this._shadowAngle},set:function(e){this._shadowAngle=e,this.forceProjectionMatrixCompute()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"direction",{get:function(){return this._direction},set:function(e){var t=this.needCube();this._direction=e,this.needCube()!==t&&this._shadowGenerator&&this._shadowGenerator.recreateShadowMap()},enumerable:!0,configurable:!0}),t.prototype.getClassName=function(){return"PointLight"},t.prototype.getTypeID=function(){return ri.a.LIGHTTYPEID_POINTLIGHT},t.prototype.needCube=function(){return!this.direction},t.prototype.getShadowDirection=function(t){if(this.direction)return e.prototype.getShadowDirection.call(this,t);switch(t){case 0:return new o.x(1,0,0);case 1:return new o.x(-1,0,0);case 2:return new o.x(0,-1,0);case 3:return new o.x(0,1,0);case 4:return new o.x(0,0,1);case 5:return new o.x(0,0,-1)}return o.x.Zero()},t.prototype._setDefaultShadowProjectionMatrix=function(e,t,i){var r=this.getScene().activeCamera;r&&o.j.PerspectiveFovLHToRef(this.shadowAngle,1,this.getDepthMinZ(r),this.getDepthMaxZ(r),e)},t.prototype._buildUniformLayout=function(){this._uniformBuffer.addUniform("vLightData",4),this._uniformBuffer.addUniform("vLightDiffuse",4),this._uniformBuffer.addUniform("vLightSpecular",3),this._uniformBuffer.addUniform("vLightFalloff",4),this._uniformBuffer.addUniform("shadowsInfo",3),this._uniformBuffer.addUniform("depthValues",2),this._uniformBuffer.create()},t.prototype.transferToEffect=function(e,t){return this.computeTransformedInformation()?this._uniformBuffer.updateFloat4("vLightData",this.transformedPosition.x,this.transformedPosition.y,this.transformedPosition.z,0,t):this._uniformBuffer.updateFloat4("vLightData",this.position.x,this.position.y,this.position.z,0,t),this._uniformBuffer.updateFloat4("vLightFalloff",this.range,this._inverseSquaredRange,0,0,t),this},t.prototype.prepareLightSpecificDefines=function(e,t){e["POINTLIGHT"+t]=!0},l.c([Object(w.c)()],t.prototype,"shadowAngle",null),t}(Vn);F.a.AddNodeConstructor("Light_Type_2",function(e,t){return function(){return new Yn(e,o.x.Zero(),o.x.Zero(),0,0,t)}});var Yn=function(e){function t(t,i,r,n,s,a){var c=e.call(this,t,a)||this;return c._innerAngle=0,c._projectionTextureMatrix=o.j.Zero(),c._projectionTextureLightNear=1e-6,c._projectionTextureLightFar=1e3,c._projectionTextureUpDirection=o.x.Up(),c._projectionTextureViewLightDirty=!0,c._projectionTextureProjectionLightDirty=!0,c._projectionTextureDirty=!0,c._projectionTextureViewTargetVector=o.x.Zero(),c._projectionTextureViewLightMatrix=o.j.Zero(),c._projectionTextureProjectionLightMatrix=o.j.Zero(),c._projectionTextureScalingMatrix=o.j.FromValues(.5,0,0,0,0,.5,0,0,0,0,.5,0,.5,.5,.5,1),c.position=i,c.direction=r,c.angle=n,c.exponent=s,c}return l.d(t,e),Object.defineProperty(t.prototype,"angle",{get:function(){return this._angle},set:function(e){this._angle=e,this._cosHalfAngle=Math.cos(.5*e),this._projectionTextureProjectionLightDirty=!0,this.forceProjectionMatrixCompute(),this._computeAngleValues()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"innerAngle",{get:function(){return this._innerAngle},set:function(e){this._innerAngle=e,this._computeAngleValues()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"shadowAngleScale",{get:function(){return this._shadowAngleScale},set:function(e){this._shadowAngleScale=e,this.forceProjectionMatrixCompute()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"projectionTextureMatrix",{get:function(){return this._projectionTextureMatrix},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"projectionTextureLightNear",{get:function(){return this._projectionTextureLightNear},set:function(e){this._projectionTextureLightNear=e,this._projectionTextureProjectionLightDirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"projectionTextureLightFar",{get:function(){return this._projectionTextureLightFar},set:function(e){this._projectionTextureLightFar=e,this._projectionTextureProjectionLightDirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"projectionTextureUpDirection",{get:function(){return this._projectionTextureUpDirection},set:function(e){this._projectionTextureUpDirection=e,this._projectionTextureProjectionLightDirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"projectionTexture",{get:function(){return this._projectionTexture},set:function(e){this._projectionTexture=e,this._projectionTextureDirty=!0},enumerable:!0,configurable:!0}),t.prototype.getClassName=function(){return"SpotLight"},t.prototype.getTypeID=function(){return ri.a.LIGHTTYPEID_SPOTLIGHT},t.prototype._setDirection=function(t){e.prototype._setDirection.call(this,t),this._projectionTextureViewLightDirty=!0},t.prototype._setPosition=function(t){e.prototype._setPosition.call(this,t),this._projectionTextureViewLightDirty=!0},t.prototype._setDefaultShadowProjectionMatrix=function(e,t,i){var r=this.getScene().activeCamera;if(r){this._shadowAngleScale=this._shadowAngleScale||1;var n=this._shadowAngleScale*this._angle;o.j.PerspectiveFovLHToRef(n,1,this.getDepthMinZ(r),this.getDepthMaxZ(r),e)}},t.prototype._computeProjectionTextureViewLightMatrix=function(){this._projectionTextureViewLightDirty=!1,this._projectionTextureDirty=!0,this.position.addToRef(this.direction,this._projectionTextureViewTargetVector),o.j.LookAtLHToRef(this.position,this._projectionTextureViewTargetVector,this._projectionTextureUpDirection,this._projectionTextureViewLightMatrix)},t.prototype._computeProjectionTextureProjectionLightMatrix=function(){this._projectionTextureProjectionLightDirty=!1,this._projectionTextureDirty=!0;var e=this.projectionTextureLightFar,t=this.projectionTextureLightNear,i=e/(e-t),r=-i*t,n=1/Math.tan(this._angle/2);o.j.FromValuesToRef(n/1,0,0,0,0,n,0,0,0,0,i,1,0,0,r,0,this._projectionTextureProjectionLightMatrix)},t.prototype._computeProjectionTextureMatrix=function(){this._projectionTextureDirty=!1,this._projectionTextureViewLightMatrix.multiplyToRef(this._projectionTextureProjectionLightMatrix,this._projectionTextureMatrix),this._projectionTextureMatrix.multiplyToRef(this._projectionTextureScalingMatrix,this._projectionTextureMatrix)},t.prototype._buildUniformLayout=function(){this._uniformBuffer.addUniform("vLightData",4),this._uniformBuffer.addUniform("vLightDiffuse",4),this._uniformBuffer.addUniform("vLightSpecular",3),this._uniformBuffer.addUniform("vLightDirection",3),this._uniformBuffer.addUniform("vLightFalloff",4),this._uniformBuffer.addUniform("shadowsInfo",3),this._uniformBuffer.addUniform("depthValues",2),this._uniformBuffer.create()},t.prototype._computeAngleValues=function(){this._lightAngleScale=1/Math.max(.001,Math.cos(.5*this._innerAngle)-this._cosHalfAngle),this._lightAngleOffset=-this._cosHalfAngle*this._lightAngleScale},t.prototype.transferToEffect=function(e,t){var i;return this.computeTransformedInformation()?(this._uniformBuffer.updateFloat4("vLightData",this.transformedPosition.x,this.transformedPosition.y,this.transformedPosition.z,this.exponent,t),i=o.x.Normalize(this.transformedDirection)):(this._uniformBuffer.updateFloat4("vLightData",this.position.x,this.position.y,this.position.z,this.exponent,t),i=o.x.Normalize(this.direction)),this._uniformBuffer.updateFloat4("vLightDirection",i.x,i.y,i.z,this._cosHalfAngle,t),this._uniformBuffer.updateFloat4("vLightFalloff",this.range,this._inverseSquaredRange,this._lightAngleScale,this._lightAngleOffset,t),this.projectionTexture&&this.projectionTexture.isReady()&&(this._projectionTextureViewLightDirty&&this._computeProjectionTextureViewLightMatrix(),this._projectionTextureProjectionLightDirty&&this._computeProjectionTextureProjectionLightMatrix(),this._projectionTextureDirty&&this._computeProjectionTextureMatrix(),e.setMatrix("textureProjectionMatrix"+t,this._projectionTextureMatrix),e.setTexture("projectionLightSampler"+t,this.projectionTexture)),this},t.prototype.dispose=function(){e.prototype.dispose.call(this),this._projectionTexture&&this._projectionTexture.dispose()},t.prototype.prepareLightSpecificDefines=function(e,t){e["SPOTLIGHT"+t]=!0,e["PROJECTEDLIGHTTEXTURE"+t]=!!this.projectionTexture},l.c([Object(w.c)()],t.prototype,"angle",null),l.c([Object(w.c)()],t.prototype,"innerAngle",null),l.c([Object(w.c)()],t.prototype,"shadowAngleScale",null),l.c([Object(w.c)()],t.prototype,"exponent",void 0),l.c([Object(w.c)()],t.prototype,"projectionTextureLightNear",null),l.c([Object(w.c)()],t.prototype,"projectionTextureLightFar",null),l.c([Object(w.c)()],t.prototype,"projectionTextureUpDirection",null),l.c([Object(w.l)("projectedLightTexture")],t.prototype,"_projectionTexture",void 0),t}(Vn),Kn=function(){function e(e,t,i){void 0===t&&(t=""),void 0===i&&(i="black");var r=this;this._renderingCanvas=e,this._loadingText=t,this._loadingDivBackgroundColor=i,this._resizeLoadingUI=function(){var e=r._renderingCanvas.getBoundingClientRect(),t=window.getComputedStyle(r._renderingCanvas).position;r._loadingDiv&&(r._loadingDiv.style.position="fixed"===t?"fixed":"absolute",r._loadingDiv.style.left=e.left+"px",r._loadingDiv.style.top=e.top+"px",r._loadingDiv.style.width=e.width+"px",r._loadingDiv.style.height=e.height+"px")}}return e.prototype.displayLoadingUI=function(){if(!this._loadingDiv){this._loadingDiv=document.createElement("div"),this._loadingDiv.id="babylonjsLoadingDiv",this._loadingDiv.style.opacity="0",this._loadingDiv.style.transition="opacity 1.5s ease",this._loadingDiv.style.pointerEvents="none",this._loadingTextDiv=document.createElement("div"),this._loadingTextDiv.style.position="absolute",this._loadingTextDiv.style.left="0",this._loadingTextDiv.style.top="50%",this._loadingTextDiv.style.marginTop="80px",this._loadingTextDiv.style.width="100%",this._loadingTextDiv.style.height="20px",this._loadingTextDiv.style.fontFamily="Arial",this._loadingTextDiv.style.fontSize="14px",this._loadingTextDiv.style.color="white",this._loadingTextDiv.style.textAlign="center",this._loadingTextDiv.innerHTML="Loading",this._loadingDiv.appendChild(this._loadingTextDiv),this._loadingTextDiv.innerHTML=this._loadingText;var e=document.createElement("style");e.type="text/css";e.innerHTML="@-webkit-keyframes spin1 { 0% { -webkit-transform: rotate(0deg);}\n 100% { -webkit-transform: rotate(360deg);}\n } @keyframes spin1 { 0% { transform: rotate(0deg);}\n 100% { transform: rotate(360deg);}\n }",document.getElementsByTagName("head")[0].appendChild(e);var t=new Image;t.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAYAAAA5ZDbSAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAZdEVYdFNvZnR3YXJlAHBhaW50Lm5ldCA0LjAuMTZEaa/1AAAYq0lEQVR4Xu2dCZRcVZnHScAJUZSwjSOIbAJmEAZwQCCMoAInYRGIg8AwegQx7AFzUBBmzAFlE4EAwxz2GRk2w7AnAURZBiEOZgyEQDAQAjmEJqTpNd3V1V3Vmd+/6utKV7/1vnpVXd2p/zn3vOV+27vfu/fd/W3QQAPrBZqbm7fJZrN79vf3T+/r67uf4wO9vb37WXQDIwWtra0Tenp6voQTv5XP56/BkfcR3iLk1g6B7hEeI+zP5V+ZiAbqBZ2dnZ8lV+6Gg87CobfhpOc4byf0FjwYE9DneBkWcXrM2tmzNzTxDdQKJPyETCazI46YgiMuI9zJuXJltuChFIHsP/PSfIfTjU19A2mira1tcxy3ey6XO5vEnkV4kes11XBmENDVj97XOT2O03FmWgMuoNLzGRJva8IUnPkzjjcT/kLoKCZzfQB7XiX8M2G8md7AUJgzJ+Z6e88gZ1xGuj3HsY17PcVkrG9gp7CUF/F8PUvxqdZDrFq1ahNVfKjwTCYxZuDE2wjKlc2WViMePM+HPNsFPOdf22OPblD5OZQHvphnV65cjTMzxaQY3eA5V9OO/hmnm1lSjE7woFsQbiXki4++foHnXkW4mLC1JUl947333tsMY3emqfB9jtPJlXN5U0+bOXPmWCPxgOccSy4+AfqPio+9/oFnbyatbqVE28GSZfjQ1NT0KQzaHMcdyPfyaNoE12HcvdxT29K3Fkv8A2vWrPmcifAFZNtD91yRY+SBZ+9UsMtEgD+jTpeenp6JXI6xpKkuUDqRcA6Kr0Wpens+InQTnIpV6Fdi+BQT64ulS5eOIzefD62na7CeoGcnLCM8ykt5OWlzcPv772/BS/w3nP+K+xU11+DvQe5dcrQlTfWAwbNMb8XA8AyGX80xtLlA6TAJuteMbVhhia1v5VMcr+LWMeoZ4xiYw7q6urbhHbgG+paCkIRQehHu4pO3O5fVydEomF5Ulx548JfVD2wqfKE2I3R3ob/f2GoC1DWhdz7HG3i5j2pvb9+Z24m6HvVZQtYsZFWcowlzePEP4jJdR/OQhxTVpAs9NMXxmZxuZKo8IG4s+v8R2tUFphSBTBWzH+OAFwn/gS3TuN55xYoVqfc6dXd3fwHZ1xFaTX0iyGbwjJqXXAammxP00EXx6UMGEx7ram7+vKnzBZ/87Xiwp40tEdDTgYwlHG/CmadSjO7L+XiialOZAej7POFG2VK0Khngl6Pn8/LL0YEtlFh4n8oDAqvaAYH8tzH2iNDm1IIFn8Ax50G7xtgCAU07CfAG4RHOz+vLZL7e0dGxlYlKHaj8BHo25xgrsfV5wrYH4KmouxV+ZZDnCUdwmXxMGgFvFUVWD+jQuOot6rI0tb4gcfaG9v+MrcAn+wj38gL8C7cObmlp2ZRjOkWYD6ypuAf6zjFHLSJ0c/6YQ813DM/yZXgehreiVgP8cvSfsOeExYsXuzs6n8v9j8mqBRZQmdjXVPuira1NHSpn8UDf4Xu0vd2uCtDzacJOlDDf5ng94X8JTWarB8R1EK7ju7udiYgEz/v3pLFKm4oHUHhh3iZdfshpaEYpA4pvKLLXBujLYKRq71XLhUHg27z12rW9B6L/QhLrWWxRH7nzeDK8awi/5HRTEx0K6MZQ694LHk0DqrgfADkreIYz1q5c+UlTEQzesIuMryrggYQWjNL3RGO7p2tuFMeqjaOidgzyCz1yJMTJ6L6d66WEVCcHIO/dQkI75Chs2g97Hoc3jRz9Lge1ED5l4r0gckqRPB0gTw34t1B+h3IqxZkmrn2SULUa7ezZszdE5xfR9130Xsm5ilrnHrmkQOcKvrkncxqrIiY6wlewbw7BOUfDo/b84zzvj9C7J7eCS0NrUiRKCPjUE7ScMBdlF/B2HqBi0ERXBcuXL99YnQz9fX2ah3Up4UnsWGEmDRuUhoTn+Z5PfvbZZ2N/fuCZRJgnfhNVBu73EZoIKt7l0L2UBsYeDZg016nb5EUCWuXQewinUtTuyq2aTStF14a8SD+VDQVj6hDYxjuXf4Hjl83sSMCmTp8j4FtoMuRQ5dAZcii3kk/0s2bBhxIcBxjxUlib1hWInEDO/6qKV+y4geO5HAMntEE/pq+nZyo0ywsG1SmwL4Orf+0yqGCfmvR73LAn9lAeBjQTEhkA+1h49a08iRflcq4H5iuXFU9cz4lqihC/LXS/NZa6Bc+pz5gql5ub6VXD2tZWTSPeyS7XgeLhXrMnEhj6MSHSwaIhFGZH8oA/JzzFeexvJbRN2HW03moT6cEChx6w4QY2rurn85JWrxsiCy0FwjcIqos8w7GZNPulkawDEbFHlaBtjzODEDrVztuKXMmADPWA3RaljyJeNdKq98ilAez8iJdyGqfO31V4NoV/EvyaCqR54V2EshE5Lqcb+TrkstkTLD4WKB4PNNZQ8P05HAelMXNSPWChC8JsYvwthJo0jSoF6fIqjjqe08Aat+LIkd+AVjn09zxbZFqK3tjXAUbXUaWDjTUSyN4J45YZX2Igo4cEOVfFson2ALIxSjR0jog5YNgpfNHM90BxIjDyWIB8Z2NfB01HISJ20wPaw4w1FlavXq1v8aPGXhFw9JNRFTDItifU/RwwpfmKxYsDK180kU4x0lhAXvOSJUs+bezlIDL2N4xi4GpjK4MGCuzUA+SPxzn3m4iKgKyV2DCV08DeMWg0B+zHHOt2DpjS3Mz1BfFOM25C5ZH4LxldJBB0g7GVARkaXgv8VsKqZtIMPpN9RUnJgRzU5Wfp22vifcG3+2vQvmdsdQXsX2pm+oKX+GYjjQXkPWqsXshpRhcJ0RpbGShSHiSuheP37ZYHsGusVHOrU1lMxkO9od4eE+8LlSzQqfetpnPAooBN/2Um+gISp89MkF8K4G3RrMJYoOhbYGxlQEGhSOGogfoLwipExGtUZVVBYIVAluaAaUpuWA+YujlPF22Ra/iBLYEOsV6tV4w0FiitfmLsXiBMU0NiAVrfsp77Zd8MHPgbDoHtva6uLs1jiv1piAKy5tCG+4KJ9wVO/p6RDzvy+b5rzSwP9Okh/WKPERiCWzfk4K8bUSTiOljAyCdx5DZG4gE8W5Dov+NYUfsV/j50fUC4dmXIQDh0qQ6PVgJsOcLM8oA410Ggvo6Ojr81di+g2TKuQOiyJOKWxlpCJpM5zUjKAL3awTsamQfEbYhjtDGKa5tPsyn/wAuiURftlBO56h6aunEwCMxxvV1d+2Fr7Jce2vAu5LUtLeoGi/19gtbToCaR97BoD6BvUs+WkXqgbw6OuhC6wH5l4rRGaCFOvYnjYbyxnpcsCvDVhYOxo6+zszNwSNHVTtJEmSiwzlMAQmNPwIPW42Dds2hfEK/5WJo0Fth+5VNxFHSlkoTzFRh/N3wnq0OGWxXtdoO8enFwaI4jsyidYgNZTxhrMEjEJ4w+En65ESWRXZ7Q4K/COqDAPlhka87WedB8KawmngTIHREOJs5pMiRp+p/GGgxL1FiA9hxjK6G1tVVdhJGAV15+cPXq1f7dahVC20Wg4miCp0uTe3Xh4Hwu93rY1B7SR/t7xQbP5R1FGgpy8IlKe+MJhZ9Aa7u5jPm+pGLX2BMDOZ+hDXgQiXIJ5xoXHZg96anEEFcvOTi0SMUXS4w0FijSTzTWYEA3hkTSEtDI2qw6RoytDLA6jctCvzKqJ8oPFOO7kAhnYe9cZGiWiZ/N9ezguWaSL4h3TUfvKJIfoN0I4sjigYSdZyxlcDVMgEczEY41ER6oZFBOh2Yqegf2zYoziFC3DuZZrjSTPLDtMlxaNPmPP/54W2OPxksrVozP5fLPGr8vEOpbxJCr3jQSJyDvGRNRhv7iHh8vE5LMpKznHBz4zSTOaXwe+mXGGh9tbWvVQf+iyfCAON/ZlTj4v43ECfB94Le4CuMrWVpTtw7O9fZOM5M8oD7xVSOLBdLuNWN1g7bgJUF8+4qpBjf7Te9M6hD4tBDc0289Wh2MHbuaSR7gsHOMLBaQ9W/G6o5MJrNDPu9dcYdQ33Yc95I6OFV5hnp2cGCliDingX5KU+9MShd0dmqta/k8J4zwnV2JsuuNxAnI83VwNpO52kiSoC4djA255cuXBzYPycGzjTQWkPdNY00OfRcQVLafRnd39ySLLsG1i20AyPZ3cDb7AyNJgnp1cOhUHUhcFiL045v9jTUa8Gjlm29fsQQhb3DzJLUEhC+oiK7EISPOwapoEh+7JQJti5YfGXs0YNC62ouC1h9lsrlToClsjc/RM7uSe0kd3EmlzTO/Kqk8Q106mM/Yw2aOB9jnOg6sWTHxJ9FraSJMy6nGz7RbZUDYmN7e3BnQ5Gisez7u3J9c0JwA6Pb0aCFvNObgwKk6NoU59uJwaJ8y1viAT4vCtEFXYO8SFQGtCZpllyXQtNqL+4lmZ/BN/5qJKQFZozEHe9JtAGSaw4wsFnie4JmUQcjleh8yZq0Fnmq3y0D02IzPMgnonYqYIfA4pC+TcXrgIahLB+PEb5s5HrjaR0b7kbHGB0pK7TDO1/T39x1lUZGAPlUH0xTbz+KSoC4dDDx2DQCHzTCaWOB5zjbW+KCSpW0IS0BIJmy6zWCk7WDuxZ4r5oO6dHB7e/sBZo4H2OfUsYOv9jHW+ECJdkAtA/c6MpmMd+XaEKj7km9M4F5TEfBzSKovDLKG1cHobw+b6EDa3WOksYBPAhevBUJMxl8GJTRhFyMLBKSJFn5ls9nvmogS0DfaHOzb3h8AcUuNNBLQNiWa0gRv4MwMMyBwCqxAfCIH82JdYSJKQN+ocjA5NHD2I/e1aj/23iPyhbG6A+bAgXsZoUEII/UAkkQORu71JqIE7o22HBw4VaelpWU74mPPDc/39d1trO5Qb4vJ8QXxbwat06WofcTInMCzeToAtN4VXUn/l1AXDkan9tDSfmL6C81BZooHxDkN9CMveLFZFFAWWZtDwVta3G0sJcAbe3bmYEiniShBXabcL+wflQDD5mD0yKlvk0b/Tk33AG5F7idG+/ibRe54oEl1nLG6A+ZYe1jyAIuG/u2LB3MazxwAfL5vJFGJinxQUwcju6c/n3+FNPm5JhJyy2k/sQTp5nm+2HBJCGi1X1WpwzuBoQXAN+IcjDz8mdePKi/WhH1uxd7GcCjIVBcWpUYDfZ0VbclEJSr2akMBhVrdX6j+Jx3DpSh7vKB8CIiqKwcrcXGqdr05k3RKbU9ryTQVkUB3aHMrEshw7kGCXiv8xxG0h6Uzent6Fpn6MhA17A6GT/3yTxNO1coJbgWur3JFf1fXNuTes5AZe18xXobFHJKv04JZc3O7CtIcgGL9KW03u3QCfL4D4b292dhrpoYgsYOhEz4kaOuHqXKqiagYiN9QnUlyKgX84JUYsQFP9GKzMFRSe8XJb9upE9Dn62CK/KQT75wdTLz+NXgPNdrDuYzeUd0ByN4Wp07n+EdCRZuTY1/ymZQDwIjQye9pA32xdw6IiUgHc639mN8kzCLRjkxzQRzitUpkZ8LZBP1CILUd55EVvdgsCrzJl5i8mgCja+Zgjst4Pq3DUnMmtSWqyNIuQruRU3+CbO08n+pvBAZAjf1IU5kcGJc0YRMBfVV3MPd2RN4+YbvYukI/3sSpe+LUmbw0ryG/6ts1oSLeYrMw6C0xeaFAGc+Wq3hbfeRk582b55lrzf3UHJwWkD0Wp+6BQ3+BfXEXw6UCdHX4TVB0BoJi9Y1Cp59XbUWN8HW7lRjLli3zbINE+1hNiCRI1cGakIhT99ani/A6z1z1nDoUqNQfbO40kyqDfrCBwMg3E5rsCy+8sFlHR8dEnFzRTq/I8hQ9NFFOtGhXVOxgFeUqfknUK7Ctpjl1ANKJ/vmUkvrdwRZmWjpA4J9MTyja2toKY8TQa/ufxP/Whdd5c5cQJHIwfBsTvkKiaqd6/fRyOHKqavdL0H+V2sxmWvrQCAeKItfmQlNyDG/8SVwnetMHyxmA7lm0K2I7GFrlVBW/V6FPP9GqeU4V0Kt2+O2yhctUN6AJBEWD9ngMnessJxh5AfCoQe+8q+xQOYLuWbQrQh2MXP1XYh8S9DKC2sI1z6kCatW3/RCZ6Vj9fNPMqx2wQVNJQlcNEl/mGG5pv48bi7HxMVSOoHsW7QqPg5GlvnJtk6/B9+HMqYUfaXE6rampqWy4dVhgi8FfLprnBXEex+i/wCSkNiSNDSpUxxt7Ccj2nQQYAwUHc9yE3HEotuifDklnfFYMdGNC/lWCxotDf4PvB/jHZTs71c+f2n+ryqCPPcb5/pKdGrTvbH2MUjH4ByOLBDpON9YSFi5cuI1FOwFbbyTox5T6y+iwFL8CqvWvwVtolWgSv/N4sXbl5ZP3r8hRLT50d56KgYJDCYXVhYOhtqqReKDdZuGJtSQSOk8f67x581SspvH3lpoBe9Vefbg/lzveaXmnAf6tEDMNGRp3LnV3ch29o10lQIf+bOKZc+XnmMGARF2EK4vUwQiSw33n7ZlqDWwcaK9Ob29vd26vwj+OT8m3kKFxdd9tlILSJ1Wo8Y8RZT/YiKOY4le5P3SGZJAc7telg7FroL16Jc/n/a1cBBCxsSblwT8LOfofcCh4AQ4x1uoCXZtgVKnYDXLMUECnPSQD29VBcrhfVw7GHrVXb6WylGg0SvUZcrr+YPYuwWVfaE9ltmpA2Q6EQq2UY+yigzf2oqCH4v4MIysD94fdwdig9uqDnB4T5/d+gwHPGNVFcOopyJiPLOfmGTwa0Ek8qS8RKDKORLFWH95utwbDd94SRqqN/Cv4PDXbTFfXfUZWBvRUPJCRBJiIqfnnccy0Dz74wHkWoypY2D4ZGU8gK+kKjQKQ8RcTW1uQI2fmc7nH7LIMFEW+sw6xdyN4CgvNByNIDjp+ZyRVhzlV7dVLaZc7t1cRoW0w9of/No6ptbuRdZupqC3QPZY33HchMkbJiRPssgyaHkN82XaJXPtOJuN+JRuixQI6Cu1VXiZtJehcFGpeNPyXI6cqPWTIvsxU1R7o912akevre4OHfTHot3fEfRbD3y8+Qu0djO5Ce5UXNGl7dTt4z0RGqnOuhgLZgmcPk2FHrrd3jgwkAVQ58e1ioxjcHeMLPWQcq+5gZKm9+hJHjXo5z4xQBQsxxyDjEfir+nNq5GfQo/nYh6f9e4NUgGEFx3DEzvw1nPrOhSJ+kh6GUBUHw6//Kmls96dJ2qv6FxNF9z8g405kVLVXDfkaiFAd4JIkttYUGFpyDOf91Ch/YVEe8DA/gORpuywDfLNMjBOQt4qEupbTPTX4YeJig+/qrnoxkfMeIdH2UHGBfP0H6kFepElc1rY5lBQYXZbzuO7BWYH7b3V3d/+TX1FEG/JSExEJdOi7qsnrx3DuNM8Zdg2NqnN/BjK0EXlVhxORr56wP6Lv/DT+X1FzYLynaOWe2s1TjCQW4An9t6Jk4hBVdH6YpB9YNXoS+SRk/JaQZHd5J2CnesLuyGaze3KZ2hTemoNcpO+uB3pAQuzvC7SeJSfc0258Wo97aX9PT+TmMEMB73jsO0wJzXnVx4llL7pe5kWaFtSqGHHgu6rpPr5jsdx+hyI59G+hA4C25GDO1V69mbf/77h0+lZpzZX44B+Ye1X1cWKz92pKrYlcjtzc6gfN+ufhApd/ErcwTvuTRNI0m4c4Tg77u6gfbCHdTuQcrRFaRKiFU7Xl1O/RqX9RObevRxR43gmEBYUn9wEJIMeF/jk0yVKTta2tE0jg43kx1OatWifEYKDrHYKGDnfkMrU1xHUPaoh7k8i+030EvoV3c6i4aTCoc/9+9NVkFgh6BmZFaig08he3oxYkwBEkQGCzg7gfG6kzaDvuSyLfgIyqt1cF6SAspoS4iJf3c9xaf3JrGEgUzZcOGgvO4agzjTQUkI9V5z4851MuLhBvUUp1gR7tjXEHL+shXFZnduNIBomi6T73FVLLByQePu4N3CxMbVxyzfeQUTYZrdpA3yvoPVf/1jdTGggC6aXx0ieLSecFcWoj72vkhU4IcswU7gVORksb6FHnufbouJ4Xbv+gf1g0EADav9uSeO9YenpA3IfURFVZ0gqEms1rRg0qCzM4TuYy1T061jt0dXXpX0xJ96FMDXIqQXtJ3tSfze6OaY0KU1ogfTUgUJMK0lBIL06dS/F/LJeRe0k2kAAk7BgSWN2GVW/aCOjRuPCbBHVGBG6J3ECKIN3VlfjroguqA+RrMsFvCNqisf5mRox2qPlB4s8vuiMdIE/fVjVvLlRnhKlqYLig7QIpOiva40PAqR2E22neJFrN10AVgWMOIDgPuMOjmRFa+HVaR0fHliaugXoEOe80nBWrZg2dZkZoYffuaW5u1kCVkadmbT70AGdqJodWOhxHqP2eFg1UDvsLatnSFq41M+KKnp6eXbhsdB2OdGiCeX8+/2ecqgnmk/VXNYtqYLSAnNposzpjgw3+H/belpVa8J7TAAAAAElFTkSuQmCC",t.style.position="absolute",t.style.left="50%",t.style.top="50%",t.style.marginLeft="-60px",t.style.marginTop="-60px",t.style.animation="spin1 2s infinite ease-in-out",t.style.webkitAnimation="spin1 2s infinite ease-in-out",t.style.transformOrigin="50% 50%",t.style.webkitTransformOrigin="50% 50%",this._loadingDiv.appendChild(t),this._resizeLoadingUI(),window.addEventListener("resize",this._resizeLoadingUI),this._loadingDiv.style.backgroundColor=this._loadingDivBackgroundColor,document.body.appendChild(this._loadingDiv),this._loadingDiv.style.opacity="1"}},e.prototype.hideLoadingUI=function(){var e=this;if(this._loadingDiv){this._loadingDiv.style.opacity="0",this._loadingDiv.addEventListener("transitionend",function(){e._loadingDiv&&(e._loadingDiv.parentElement&&e._loadingDiv.parentElement.removeChild(e._loadingDiv),window.removeEventListener("resize",e._resizeLoadingUI),e._loadingDiv=null)})}},Object.defineProperty(e.prototype,"loadingUIText",{get:function(){return this._loadingText},set:function(e){this._loadingText=e,this._loadingTextDiv&&(this._loadingTextDiv.innerHTML=this._loadingText)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"loadingUIBackgroundColor",{get:function(){return this._loadingDivBackgroundColor},set:function(e){this._loadingDivBackgroundColor=e,this._loadingDiv&&(this._loadingDiv.style.backgroundColor=this._loadingDivBackgroundColor)},enumerable:!0,configurable:!0}),e}();_e.b.DefaultLoadingScreenFactory=function(e){return new Kn(e)};var Qn=i(55),qn=i(26),Zn=function(e){function t(t,i){var r=e.call(this,t,i,!0)||this;return i.multiMaterials.push(r),r.subMaterials=new Array,r._storeEffectOnSubMeshes=!0,r}return l.d(t,e),Object.defineProperty(t.prototype,"subMaterials",{get:function(){return this._subMaterials},set:function(e){this._subMaterials=e,this._hookArray(e)},enumerable:!0,configurable:!0}),t.prototype.getChildren=function(){return this.subMaterials},t.prototype._hookArray=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 o=i.apply(e,r);return t._markAllSubMeshesAsTexturesDirty(),o};var r=e.splice;e.splice=function(i,n){var o=r.apply(e,[i,n]);return t._markAllSubMeshesAsTexturesDirty(),o}},t.prototype.getSubMaterial=function(e){return e<0||e>=this.subMaterials.length?this.getScene().defaultMaterial:this.subMaterials[e]},t.prototype.getActiveTextures=function(){var t;return(t=e.prototype.getActiveTextures.call(this)).concat.apply(t,this.subMaterials.map(function(e){return e?e.getActiveTextures():[]}))},t.prototype.getClassName=function(){return"MultiMaterial"},t.prototype.isReadyForSubMesh=function(e,t,i){for(var r=0;r<this.subMaterials.length;r++){var n=this.subMaterials[r];if(n){if(n._storeEffectOnSubMeshes){if(!n.isReadyForSubMesh(e,t,i))return!1;continue}if(!n.isReady(e))return!1}}return!0},t.prototype.clone=function(e,i){for(var r=new t(e,this.getScene()),n=0;n<this.subMaterials.length;n++){var o=null,s=this.subMaterials[n];o=i&&s?s.clone(e+"-"+s.name):this.subMaterials[n],r.subMaterials.push(o)}return r},t.prototype.serialize=function(){var e={};e.name=this.name,e.id=this.id,qn.a&&(e.tags=qn.a.GetTags(this)),e.materials=[];for(var t=0;t<this.subMaterials.length;t++){var i=this.subMaterials[t];i?e.materials.push(i.id):e.materials.push(null)}return e},t.prototype.dispose=function(t,i,r){var n=this.getScene();if(n){if(r)for(var o=0;o<this.subMaterials.length;o++){var s=this.subMaterials[o];s&&s.dispose(t,i)}(o=n.multiMaterials.indexOf(this))>=0&&n.multiMaterials.splice(o,1),e.prototype.dispose.call(this,t,i)}},t.ParseMultiMaterial=function(e,i){var r=new t(e.name,i);r.id=e.id,qn.a&&qn.a.AddTagsTo(r,e.tags);for(var n=0;n<e.materials.length;n++){var o=e.materials[n];o?r.subMaterials.push(i.getMaterialByID(o)):r.subMaterials.push(null)}return r},t}(yn.a);s.a.RegisteredTypes["BABYLON.MultiMaterial"]=Zn;var Jn=function(){function e(){}return e.ConvertPanoramaToCubemap=function(e,t,i,r){if(!e)throw"ConvertPanoramaToCubemap: input cannot be null";if(e.length!=t*i*3)throw"ConvertPanoramaToCubemap: input size is wrong";return{front:this.CreateCubemapTexture(r,this.FACE_FRONT,e,t,i),back:this.CreateCubemapTexture(r,this.FACE_BACK,e,t,i),left:this.CreateCubemapTexture(r,this.FACE_LEFT,e,t,i),right:this.CreateCubemapTexture(r,this.FACE_RIGHT,e,t,i),up:this.CreateCubemapTexture(r,this.FACE_UP,e,t,i),down:this.CreateCubemapTexture(r,this.FACE_DOWN,e,t,i),size:r,type:_.a.TEXTURETYPE_FLOAT,format:_.a.TEXTUREFORMAT_RGB,gammaSpace:!1}},e.CreateCubemapTexture=function(e,t,i,r,n){for(var o=new ArrayBuffer(e*e*4*3),s=new Float32Array(o),a=t[1].subtract(t[0]).scale(1/e),c=t[3].subtract(t[2]).scale(1/e),l=1/e,u=0,h=0;h<e;h++){for(var d=t[0],f=t[2],p=0;p<e;p++){var _=f.subtract(d).scale(u).add(d);_.normalize();var g=this.CalcProjectionSpherical(_,i,r,n);s[h*e*3+3*p+0]=g.r,s[h*e*3+3*p+1]=g.g,s[h*e*3+3*p+2]=g.b,d=d.add(a),f=f.add(c)}u+=l}return s},e.CalcProjectionSpherical=function(e,t,i,r){for(var n=Math.atan2(e.z,e.x),o=Math.acos(e.y);n<-Math.PI;)n+=2*Math.PI;for(;n>Math.PI;)n-=2*Math.PI;var s=n/Math.PI,a=o/Math.PI;s=.5*s+.5;var c=Math.round(s*i);c<0?c=0:c>=i&&(c=i-1);var l=Math.round(a*r);l<0?l=0:l>=r&&(l=r-1);var u=r-l-1;return{r:t[u*i*3+3*c+0],g:t[u*i*3+3*c+1],b:t[u*i*3+3*c+2]}},e.FACE_FRONT=[new o.x(-1,-1,-1),new o.x(1,-1,-1),new o.x(-1,1,-1),new o.x(1,1,-1)],e.FACE_BACK=[new o.x(1,-1,1),new o.x(-1,-1,1),new o.x(1,1,1),new o.x(-1,1,1)],e.FACE_RIGHT=[new o.x(1,-1,-1),new o.x(1,-1,1),new o.x(1,1,-1),new o.x(1,1,1)],e.FACE_LEFT=[new o.x(-1,-1,1),new o.x(-1,-1,-1),new o.x(-1,1,1),new o.x(-1,1,-1)],e.FACE_DOWN=[new o.x(-1,1,-1),new o.x(1,1,-1),new o.x(-1,1,1),new o.x(1,1,1)],e.FACE_UP=[new o.x(-1,-1,1),new o.x(1,-1,1),new o.x(-1,-1,-1),new o.x(1,-1,-1)],e}(),$n=function(){function e(){}return e.Ldexp=function(e,t){return t>1023?e*Math.pow(2,1023)*Math.pow(2,t-1023):t<-1074?e*Math.pow(2,-1074)*Math.pow(2,t+1074):e*Math.pow(2,t)},e.Rgbe2float=function(e,t,i,r,n,o){n>0?(n=this.Ldexp(1,n-136),e[o+0]=t*n,e[o+1]=i*n,e[o+2]=r*n):(e[o+0]=0,e[o+1]=0,e[o+2]=0)},e.readStringLine=function(e,t){for(var i="",r="",n=t;n<e.length-t&&"\n"!=(r=String.fromCharCode(e[n]));n++)i+=r;return i},e.RGBE_ReadHeader=function(e){var t,i,r=this.readStringLine(e,0);if("#"!=r[0]||"?"!=r[1])throw"Bad HDR Format.";var n=!1,o=!1,s=0;do{s+=r.length+1,"FORMAT=32-bit_rle_rgbe"==(r=this.readStringLine(e,s))?o=!0:0==r.length&&(n=!0)}while(!n);if(!o)throw"HDR Bad header format, unsupported FORMAT";s+=r.length+1,r=this.readStringLine(e,s);var a=/^\-Y (.*) \+X (.*)$/g.exec(r);if(!a||a.length<3)throw"HDR Bad header format, no size";if(i=parseInt(a[2]),t=parseInt(a[1]),i<8||i>32767)throw"HDR Bad header format, unsupported size";return{height:t,width:i,dataPosition:s+=r.length+1}},e.GetCubeMapTextureData=function(e,t){var i=new Uint8Array(e),r=this.RGBE_ReadHeader(i),n=this.RGBE_ReadPixels_RLE(i,r);return Jn.ConvertPanoramaToCubemap(n,r.width,r.height,t)},e.RGBE_ReadPixels=function(e,t){return this.RGBE_ReadPixels_RLE(e,t)},e.RGBE_ReadPixels_RLE=function(e,t){for(var i,r,n,o,s,a=t.height,c=t.width,l=t.dataPosition,u=0,h=0,d=0,f=new ArrayBuffer(4*c),p=new Uint8Array(f),_=new ArrayBuffer(t.width*t.height*4*3),g=new Float32Array(_);a>0;){if(i=e[l++],r=e[l++],n=e[l++],o=e[l++],2!=i||2!=r||128&n)throw"HDR Bad header format, not RLE";if((n<<8|o)!=c)throw"HDR Bad header format, wrong scan line width";for(u=0,d=0;d<4;d++)for(h=(d+1)*c;u<h;)if(i=e[l++],r=e[l++],i>128){if(0==(s=i-128)||s>h-u)throw"HDR Bad Format, bad scanline data (run)";for(;s-- >0;)p[u++]=r}else{if(0==(s=i)||s>h-u)throw"HDR Bad Format, bad scanline data (non-run)";if(p[u++]=r,--s>0)for(var m=0;m<s;m++)p[u++]=e[l++]}for(d=0;d<c;d++)i=p[d],r=p[d+c],n=p[d+2*c],o=p[d+3*c],this.Rgbe2float(g,i,r,n,o,(t.height-a)*c*3+3*d);a--}return g},e}(),eo=i(67),to=function(e){function t(t,i,r,n,s,a,c,l,u){void 0===n&&(n=!1),void 0===s&&(s=!0),void 0===a&&(a=!1),void 0===c&&(c=!1),void 0===l&&(l=null),void 0===u&&(u=null);var h=e.call(this,i)||this;return h._generateHarmonics=!0,h._onLoad=null,h._onError=null,h.coordinatesMode=Ve.a.CUBIC_MODE,h._isBlocking=!0,h._rotationY=0,h.boundingBoxPosition=o.x.Zero(),t?(h.name=t,h.url=t,h.hasAlpha=!1,h.isCube=!0,h._textureMatrix=o.j.Identity(),h._onLoad=l,h._onError=u,h.gammaSpace=a,h._noMipmap=n,h._size=r,h._texture=h._getFromCache(t,h._noMipmap),h._texture||(i.useDelayedTextureLoading?h.delayLoadState=_e.b.DELAYLOADSTATE_NOTLOADED:h.loadTexture()),h):h}return l.d(t,e),Object.defineProperty(t.prototype,"isBlocking",{get:function(){return this._isBlocking},set:function(e){this._isBlocking=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"rotationY",{get:function(){return this._rotationY},set:function(e){this._rotationY=e,this.setReflectionTextureMatrix(o.j.RotationY(this._rotationY))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"boundingBoxSize",{get:function(){return this._boundingBoxSize},set:function(e){if(!this._boundingBoxSize||!this._boundingBoxSize.equals(e)){this._boundingBoxSize=e;var t=this.getScene();t&&t.markAllMaterialsAsDirty(_.a.MATERIAL_TextureDirtyFlag)}},enumerable:!0,configurable:!0}),t.prototype.getClassName=function(){return"HDRCubeTexture"},t.prototype.loadTexture=function(){var e=this,i=this.getScene();i&&(this._texture=i.getEngine().createRawCubeTextureFromUrl(this.url,i,this._size,_e.b.TEXTUREFORMAT_RGB,i.getEngine().getCaps().textureFloat?_e.b.TEXTURETYPE_FLOAT:_e.b.TEXTURETYPE_UNSIGNED_INT,this._noMipmap,function(i){e.lodGenerationOffset=0,e.lodGenerationScale=.8;var r=e.getScene();if(!r)return null;var n=$n.GetCubeMapTextureData(i,e._size);if(e._generateHarmonics){var s=eo.a.ConvertCubeMapToSphericalPolynomial(n);e.sphericalPolynomial=s}for(var a=[],c=null,l=0;l<6;l++){if(!r.getEngine().getCaps().textureFloat){var u=new ArrayBuffer(e._size*e._size*3);c=new Uint8Array(u)}var h=n[t._facesMapping[l]];if(e.gammaSpace||c)for(var d=0;d<e._size*e._size;d++)if(e.gammaSpace&&(h[3*d+0]=Math.pow(h[3*d+0],o.u),h[3*d+1]=Math.pow(h[3*d+1],o.u),h[3*d+2]=Math.pow(h[3*d+2],o.u)),c){var f=Math.max(255*h[3*d+0],0),p=Math.max(255*h[3*d+1],0),_=Math.max(255*h[3*d+2],0),g=Math.max(Math.max(f,p),_);if(g>255){var m=255/g;f*=m,p*=m,_*=m}c[3*d+0]=f,c[3*d+1]=p,c[3*d+2]=_}c?a.push(c):a.push(h)}return a},null,this._onLoad,this._onError))},t.prototype.clone=function(){var e=this.getScene();if(!e)return this;var i=new t(this.url,e,this._size,this._noMipmap,this._generateHarmonics,this.gammaSpace);return i.level=this.level,i.wrapU=this.wrapU,i.wrapV=this.wrapV,i.coordinatesIndex=this.coordinatesIndex,i.coordinatesMode=this.coordinatesMode,i},t.prototype.delayLoad=function(){this.delayLoadState===_e.b.DELAYLOADSTATE_NOTLOADED&&(this.delayLoadState=_e.b.DELAYLOADSTATE_LOADED,this._texture=this._getFromCache(this.url,this._noMipmap),this._texture||this.loadTexture())},t.prototype.getReflectionTextureMatrix=function(){return this._textureMatrix},t.prototype.setReflectionTextureMatrix=function(e){var t=this;this._textureMatrix=e,e.updateFlag!==this._textureMatrix.updateFlag&&e.isIdentity()!==this._textureMatrix.isIdentity()&&this.getScene().markAllMaterialsAsDirty(_.a.MATERIAL_TextureDirtyFlag,function(e){return-1!==e.getActiveTextures().indexOf(t)})},t.Parse=function(e,i,r){var n=null;return e.name&&!e.isRenderTarget&&((n=new t(r+e.name,i,e.size,e.noMipmap,e.generateHarmonics,e.useInGammaSpace)).name=e.name,n.hasAlpha=e.hasAlpha,n.level=e.level,n.coordinatesMode=e.coordinatesMode,n.isBlocking=e.isBlocking),n&&(e.boundingBoxPosition&&(n.boundingBoxPosition=o.x.FromArray(e.boundingBoxPosition)),e.boundingBoxSize&&(n.boundingBoxSize=o.x.FromArray(e.boundingBoxSize)),e.rotationY&&(n.rotationY=e.rotationY)),n},t.prototype.serialize=function(){if(!this.name)return null;var e={};return e.name=this.name,e.hasAlpha=this.hasAlpha,e.isCube=!0,e.level=this.level,e.size=this._size,e.coordinatesMode=this.coordinatesMode,e.useInGammaSpace=this.gammaSpace,e.generateHarmonics=this._generateHarmonics,e.customType="BABYLON.HDRCubeTexture",e.noMipmap=this._noMipmap,e.isBlocking=this._isBlocking,e.rotationY=this._rotationY,e},t._facesMapping=["right","left","up","down","front","back"],t}(wr.a);s.a.RegisteredTypes["BABYLON.HDRCubeTexture"]=to;var io=function(){function e(e,t,i){void 0===t&&(t=0),void 0===i&&(i=null),this.name=e,this.animations=new Array,this._positions=null,this._normals=null,this._tangents=null,this.onInfluenceChanged=new n.c,this._onDataLayoutChanged=new n.c,this._animationPropertiesOverride=null,this._scene=i||R.a.LastCreatedScene,this.influence=t}return Object.defineProperty(e.prototype,"influence",{get:function(){return this._influence},set:function(e){if(this._influence!==e){var t=this._influence;this._influence=e,this.onInfluenceChanged.hasObservers&&this.onInfluenceChanged.notifyObservers(0===t||0===e)}},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"animationPropertiesOverride",{get:function(){return!this._animationPropertiesOverride&&this._scene?this._scene.animationPropertiesOverride:this._animationPropertiesOverride},set:function(e){this._animationPropertiesOverride=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"hasPositions",{get:function(){return!!this._positions},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"hasNormals",{get:function(){return!!this._normals},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"hasTangents",{get:function(){return!!this._tangents},enumerable:!0,configurable:!0}),e.prototype.setPositions=function(e){var t=this.hasPositions;this._positions=e,t!==this.hasPositions&&this._onDataLayoutChanged.notifyObservers(void 0)},e.prototype.getPositions=function(){return this._positions},e.prototype.setNormals=function(e){var t=this.hasNormals;this._normals=e,t!==this.hasNormals&&this._onDataLayoutChanged.notifyObservers(void 0)},e.prototype.getNormals=function(){return this._normals},e.prototype.setTangents=function(e){var t=this.hasTangents;this._tangents=e,t!==this.hasTangents&&this._onDataLayoutChanged.notifyObservers(void 0)},e.prototype.getTangents=function(){return this._tangents},e.prototype.serialize=function(){var e={};return e.name=this.name,e.influence=this.influence,e.positions=Array.prototype.slice.call(this.getPositions()),null!=this.id&&(e.id=this.id),this.hasNormals&&(e.normals=Array.prototype.slice.call(this.getNormals())),this.hasTangents&&(e.tangents=Array.prototype.slice.call(this.getTangents())),w.a.AppendSerializedAnimations(this,e),e},e.prototype.getClassName=function(){return"MorphTarget"},e.Parse=function(t){var i=new e(t.name,t.influence);if(i.setPositions(t.positions),null!=t.id&&(i.id=t.id),t.normals&&i.setNormals(t.normals),t.tangents&&i.setTangents(t.tangents),t.animations)for(var r=0;r<t.animations.length;r++){var n=t.animations[r],o=s.a.GetClass("BABYLON.Animation");o&&i.animations.push(o.Parse(n))}return i},e.FromMesh=function(t,i,r){i||(i=t.name);var n=new e(i,r,t.getScene());return n.setPositions(t.getVerticesData(gi.b.PositionKind)),t.isVerticesDataPresent(gi.b.NormalKind)&&n.setNormals(t.getVerticesData(gi.b.NormalKind)),t.isVerticesDataPresent(gi.b.TangentKind)&&n.setTangents(t.getVerticesData(gi.b.TangentKind)),n},l.c([Object(w.c)()],e.prototype,"id",void 0),e}(),ro=function(){function e(e){void 0===e&&(e=null),this._targets=new Array,this._targetInfluenceChangedObservers=new Array,this._targetDataLayoutChangedObservers=new Array,this._activeTargets=new Rt.a(16),this._supportsNormals=!1,this._supportsTangents=!1,this._vertexCount=0,this._uniqueId=0,this._tempInfluences=new Array,e||(e=R.a.LastCreatedScene),this._scene=e,this._scene&&(this._scene.morphTargetManagers.push(this),this._uniqueId=this._scene.getUniqueId())}return Object.defineProperty(e.prototype,"uniqueId",{get:function(){return this._uniqueId},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"vertexCount",{get:function(){return this._vertexCount},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"supportsNormals",{get:function(){return this._supportsNormals},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"supportsTangents",{get:function(){return this._supportsTangents},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"numTargets",{get:function(){return this._targets.length},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"numInfluencers",{get:function(){return this._activeTargets.length},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"influences",{get:function(){return this._influences},enumerable:!0,configurable:!0}),e.prototype.getActiveTarget=function(e){return this._activeTargets.data[e]},e.prototype.getTarget=function(e){return this._targets[e]},e.prototype.addTarget=function(e){var t=this;this._targets.push(e),this._targetInfluenceChangedObservers.push(e.onInfluenceChanged.add(function(e){t._syncActiveTargets(e)})),this._targetDataLayoutChangedObservers.push(e._onDataLayoutChanged.add(function(){t._syncActiveTargets(!0)})),this._syncActiveTargets(!0)},e.prototype.removeTarget=function(e){var t=this._targets.indexOf(e);t>=0&&(this._targets.splice(t,1),e.onInfluenceChanged.remove(this._targetInfluenceChangedObservers.splice(t,1)[0]),e._onDataLayoutChanged.remove(this._targetDataLayoutChangedObservers.splice(t,1)[0]),this._syncActiveTargets(!0))},e.prototype.serialize=function(){var e={};e.id=this.uniqueId,e.targets=[];for(var t=0,i=this._targets;t<i.length;t++){var r=i[t];e.targets.push(r.serialize())}return e},e.prototype._syncActiveTargets=function(e){var t=0;this._activeTargets.reset(),this._supportsNormals=!0,this._supportsTangents=!0,this._vertexCount=0;for(var i=0,r=this._targets;i<r.length;i++){var n=r[i];if(0!==n.influence){this._activeTargets.push(n),this._tempInfluences[t++]=n.influence,this._supportsNormals=this._supportsNormals&&n.hasNormals,this._supportsTangents=this._supportsTangents&&n.hasTangents;var o=n.getPositions();if(o){var s=o.length/3;if(0===this._vertexCount)this._vertexCount=s;else if(this._vertexCount!==s)return void p.a.Error("Incompatible target. Targets must all have the same vertices count.")}}}this._influences&&this._influences.length===t||(this._influences=new Float32Array(t));for(var a=0;a<t;a++)this._influences[a]=this._tempInfluences[a];e&&this.synchronize()},e.prototype.synchronize=function(){if(this._scene)for(var e=0,t=this._scene.meshes;e<t.length;e++){var i=t[e];i.morphTargetManager===this&&i._syncGeometryWithMorphTargetManager()}},e.Parse=function(t,i){var r=new e(i);r._uniqueId=t.id;for(var n=0,o=t.targets;n<o.length;n++){var s=o[n];r.addTarget(io.Parse(s))}return r},e}(),no=i(29),oo=i(36),so=function(){function e(t,i){if(void 0===i&&(i=e.DefaultPluginFactory()),this._physicsPlugin=i,this._impostors=[],this._joints=[],!this._physicsPlugin.isSupported())throw new Error("Physics Engine "+this._physicsPlugin.name+" cannot be found. Please make sure it is included.");t=t||new o.x(0,-9.807,0),this.setGravity(t),this.setTimeStep()}return e.DefaultPluginFactory=function(){throw"Import CannonJSPlugin or Fill DefaultPluginFactory static property on PhysicsEngine before relying on default physics plugin."},e.prototype.setGravity=function(e){this.gravity=e,this._physicsPlugin.setGravity(this.gravity)},e.prototype.setTimeStep=function(e){void 0===e&&(e=1/60),this._physicsPlugin.setTimeStep(e)},e.prototype.getTimeStep=function(){return this._physicsPlugin.getTimeStep()},e.prototype.dispose=function(){this._impostors.forEach(function(e){e.dispose()}),this._physicsPlugin.dispose()},e.prototype.getPhysicsPluginName=function(){return this._physicsPlugin.name},e.prototype.addImpostor=function(e){e.uniqueId=this._impostors.push(e),e.parent||this._physicsPlugin.generatePhysicsBody(e)},e.prototype.removeImpostor=function(e){var t=this._impostors.indexOf(e);if(t>-1){var i=this._impostors.splice(t,1);i.length&&(i[0].physicsBody=null)}},e.prototype.addJoint=function(e,t,i){var r={mainImpostor:e,connectedImpostor:t,joint:i};i.physicsPlugin=this._physicsPlugin,this._joints.push(r),this._physicsPlugin.generateJoint(r)},e.prototype.removeJoint=function(e,t,i){var r=this._joints.filter(function(r){return r.connectedImpostor===t&&r.joint===i&&r.mainImpostor===e});r.length&&this._physicsPlugin.removeJoint(r[0])},e.prototype._step=function(e){var t=this;this._impostors.forEach(function(e){e.isBodyInitRequired()&&t._physicsPlugin.generatePhysicsBody(e)}),e>.1?e=.1:e<=0&&(e=1/60),this._physicsPlugin.executeStep(e,this._impostors)},e.prototype.getPhysicsPlugin=function(){return this._physicsPlugin},e.prototype.getImpostors=function(){return this._impostors},e.prototype.getImpostorForPhysicsObject=function(e){for(var t=0;t<this._impostors.length;++t)if(this._impostors[t].object===e)return this._impostors[t];return null},e.prototype.getImpostorWithPhysicsBody=function(e){for(var t=0;t<this._impostors.length;++t)if(this._impostors[t].physicsBody===e)return this._impostors[t];return null},e.Epsilon=.001,e}(),ao=function(){function e(e,t,i){void 0===e&&(e=!0),void 0===t&&(t=10),void 0===i&&(i=CANNON),this._useDeltaForWorldStep=e,this.name="CannonJSPlugin",this._physicsMaterials=new Array,this._fixedTimeStep=1/60,this._minus90X=new o.q(-.7071067811865475,0,0,.7071067811865475),this._plus90X=new o.q(.7071067811865475,0,0,.7071067811865475),this._tmpPosition=o.x.Zero(),this._tmpDeltaPosition=o.x.Zero(),this._tmpUnityRotation=new o.q,this.BJSCANNON=i,this.isSupported()?(this._extendNamespace(),this.world=new this.BJSCANNON.World,this.world.broadphase=new this.BJSCANNON.NaiveBroadphase,this.world.solver.iterations=t):p.a.Error("CannonJS is not available. Please make sure you included the js file.")}return e.prototype.setGravity=function(e){this.world.gravity.copy(e)},e.prototype.setTimeStep=function(e){this._fixedTimeStep=e},e.prototype.getTimeStep=function(){return this._fixedTimeStep},e.prototype.executeStep=function(e){this.world.step(this._fixedTimeStep,this._useDeltaForWorldStep?e:0,3)},e.prototype.applyImpulse=function(e,t,i){var r=new this.BJSCANNON.Vec3(i.x,i.y,i.z),n=new this.BJSCANNON.Vec3(t.x,t.y,t.z);e.physicsBody.applyImpulse(n,r)},e.prototype.applyForce=function(e,t,i){var r=new this.BJSCANNON.Vec3(i.x,i.y,i.z),n=new this.BJSCANNON.Vec3(t.x,t.y,t.z);e.physicsBody.applyForce(n,r)},e.prototype.generatePhysicsBody=function(e){if(e.parent)e.physicsBody&&(this.removePhysicsBody(e),e.forceUpdate());else{if(e.isBodyInitRequired()){var t=this._createShape(e),i=e.physicsBody;i&&this.removePhysicsBody(e);var r=this._addMaterial("mat-"+e.uniqueId,e.getParam("friction"),e.getParam("restitution")),n={mass:e.getParam("mass"),material:r},o=e.getParam("nativeOptions");for(var s in o)o.hasOwnProperty(s)&&(n[s]=o[s]);e.physicsBody=new this.BJSCANNON.Body(n),e.physicsBody.addEventListener("collide",e.onCollide),this.world.addEventListener("preStep",e.beforeStep),this.world.addEventListener("postStep",e.afterStep),e.physicsBody.addShape(t),this.world.add(e.physicsBody),i&&["force","torque","velocity","angularVelocity"].forEach(function(t){e.physicsBody[t].copy(i[t])}),this._processChildMeshes(e)}this._updatePhysicsBodyTransformation(e)}},e.prototype._processChildMeshes=function(e){var t=this,i=e.object.getChildMeshes?e.object.getChildMeshes(!0):[],r=e.object.rotationQuaternion;if(i.length){var n=function(i,s){if(r&&s.rotationQuaternion){var a=s.getPhysicsImpostor();if(a)if(a.parent!==e){var c=s.getAbsolutePosition().subtract(e.object.getAbsolutePosition()),l=s.rotationQuaternion.multiply(o.q.Inverse(r));a.physicsBody&&(t.removePhysicsBody(a),a.physicsBody=null),a.parent=e,a.resetUpdateFlags(),e.physicsBody.addShape(t._createShape(a),new t.BJSCANNON.Vec3(c.x,c.y,c.z),new t.BJSCANNON.Quaternion(l.x,l.y,l.z,l.w)),e.physicsBody.mass+=a.getParam("mass")}r.multiplyInPlace(s.rotationQuaternion),s.getChildMeshes(!0).filter(function(e){return!!e.physicsImpostor}).forEach(n.bind(t,s.getAbsolutePosition()))}};i.filter(function(e){return!!e.physicsImpostor}).forEach(n.bind(this,e.object.getAbsolutePosition()))}},e.prototype.removePhysicsBody=function(e){e.physicsBody.removeEventListener("collide",e.onCollide),this.world.removeEventListener("preStep",e.beforeStep),this.world.removeEventListener("postStep",e.afterStep),this.world.remove(e.physicsBody)},e.prototype.generateJoint=function(e){var t=e.mainImpostor.physicsBody,i=e.connectedImpostor.physicsBody;if(t&&i){var r,n=e.joint.jointData,o={pivotA:n.mainPivot?(new this.BJSCANNON.Vec3).copy(n.mainPivot):null,pivotB:n.connectedPivot?(new this.BJSCANNON.Vec3).copy(n.connectedPivot):null,axisA:n.mainAxis?(new this.BJSCANNON.Vec3).copy(n.mainAxis):null,axisB:n.connectedAxis?(new this.BJSCANNON.Vec3).copy(n.connectedAxis):null,maxForce:n.nativeParams.maxForce,collideConnected:!!n.collision};switch(e.joint.type){case oo.e.HingeJoint:case oo.e.Hinge2Joint:r=new this.BJSCANNON.HingeConstraint(t,i,o);break;case oo.e.DistanceJoint:r=new this.BJSCANNON.DistanceConstraint(t,i,n.maxDistance||2);break;case oo.e.SpringJoint:var s=n;r=new this.BJSCANNON.Spring(t,i,{restLength:s.length,stiffness:s.stiffness,damping:s.damping,localAnchorA:o.pivotA,localAnchorB:o.pivotB});break;case oo.e.LockJoint:r=new this.BJSCANNON.LockConstraint(t,i,o);break;case oo.e.PointToPointJoint:case oo.e.BallAndSocketJoint:default:r=new this.BJSCANNON.PointToPointConstraint(t,o.pivotA,i,o.pivotB,o.maxForce)}r.collideConnected=!!n.collision,e.joint.physicsJoint=r,e.joint.type!==oo.e.SpringJoint?this.world.addConstraint(r):(e.joint.jointData.forceApplicationCallback=e.joint.jointData.forceApplicationCallback||function(){r.applyForce()},e.mainImpostor.registerAfterPhysicsStep(e.joint.jointData.forceApplicationCallback))}},e.prototype.removeJoint=function(e){e.joint.type!==oo.e.SpringJoint?this.world.removeConstraint(e.joint.physicsJoint):e.mainImpostor.unregisterAfterPhysicsStep(e.joint.jointData.forceApplicationCallback)},e.prototype._addMaterial=function(e,t,i){var r,n;for(r=0;r<this._physicsMaterials.length;r++)if((n=this._physicsMaterials[r]).friction===t&&n.restitution===i)return n;var o=new this.BJSCANNON.Material(e);return o.friction=t,o.restitution=i,this._physicsMaterials.push(o),o},e.prototype._checkWithEpsilon=function(e){return e<so.Epsilon?so.Epsilon:e},e.prototype._createShape=function(e){var t,i=e.object,r=e.getObjectExtendSize();switch(e.type){case no.a.SphereImpostor:var n=r.x,s=r.y,a=r.z;t=new this.BJSCANNON.Sphere(Math.max(this._checkWithEpsilon(n),this._checkWithEpsilon(s),this._checkWithEpsilon(a))/2);break;case no.a.CylinderImpostor:var c=e.getParam("nativeOptions");c||(c={});var l=void 0!==c.radiusTop?c.radiusTop:this._checkWithEpsilon(r.x)/2,u=void 0!==c.radiusBottom?c.radiusBottom:this._checkWithEpsilon(r.x)/2,h=void 0!==c.height?c.height:this._checkWithEpsilon(r.y),d=void 0!==c.numSegments?c.numSegments:16;t=new this.BJSCANNON.Cylinder(l,u,h,d);var f=new this.BJSCANNON.Quaternion;f.setFromAxisAngle(new this.BJSCANNON.Vec3(1,0,0),-Math.PI/2);var _=new this.BJSCANNON.Vec3(0,0,0);t.transformAllPoints(_,f);break;case no.a.BoxImpostor:var g=r.scale(.5);t=new this.BJSCANNON.Box(new this.BJSCANNON.Vec3(this._checkWithEpsilon(g.x),this._checkWithEpsilon(g.y),this._checkWithEpsilon(g.z)));break;case no.a.PlaneImpostor:p.a.Warn("Attention, PlaneImposter might not behave as you expect. Consider using BoxImposter instead"),t=new this.BJSCANNON.Plane;break;case no.a.MeshImpostor:var m=i.getVerticesData?i.getVerticesData(gi.b.PositionKind):[],v=i.getIndices?i.getIndices():[];if(!m)return;var y=i.position.clone(),b=i.rotation&&i.rotation.clone(),T=i.rotationQuaternion&&i.rotationQuaternion.clone();i.position.copyFromFloats(0,0,0),i.rotation&&i.rotation.copyFromFloats(0,0,0),i.rotationQuaternion&&i.rotationQuaternion.copyFrom(e.getParentsRotation()),i.rotationQuaternion&&i.parent&&i.rotationQuaternion.conjugateInPlace();var E,x=i.computeWorldMatrix(!0),A=new Array;for(E=0;E<m.length;E+=3)o.x.TransformCoordinates(o.x.FromArray(m,E),x).toArray(A,E);p.a.Warn("MeshImpostor only collides against spheres."),t=new this.BJSCANNON.Trimesh(A,v),i.position.copyFrom(y),b&&i.rotation&&i.rotation.copyFrom(b),T&&i.rotationQuaternion&&i.rotationQuaternion.copyFrom(T);break;case no.a.HeightmapImpostor:var P=i.position.clone(),R=i.rotation&&i.rotation.clone(),S=i.rotationQuaternion&&i.rotationQuaternion.clone();i.position.copyFromFloats(0,0,0),i.rotation&&i.rotation.copyFromFloats(0,0,0),i.rotationQuaternion&&i.rotationQuaternion.copyFrom(e.getParentsRotation()),i.rotationQuaternion&&i.parent&&i.rotationQuaternion.conjugateInPlace(),i.rotationQuaternion&&i.rotationQuaternion.multiplyInPlace(this._minus90X),t=this._createHeightmap(i),i.position.copyFrom(P),R&&i.rotation&&i.rotation.copyFrom(R),S&&i.rotationQuaternion&&i.rotationQuaternion.copyFrom(S),i.computeWorldMatrix(!0);break;case no.a.ParticleImpostor:t=new this.BJSCANNON.Particle;break;case no.a.NoImpostor:t=new this.BJSCANNON.Box(new this.BJSCANNON.Vec3(0,0,0))}return t},e.prototype._createHeightmap=function(e,t){var i,r=e.getVerticesData(gi.b.PositionKind),n=e.computeWorldMatrix(!0),s=new Array;for(i=0;i<r.length;i+=3)o.x.TransformCoordinates(o.x.FromArray(r,i),n).toArray(s,i);r=s;for(var a=new Array,c=t||~~(Math.sqrt(r.length/3)-1),l=e.getBoundingInfo(),u=Math.min(l.boundingBox.extendSizeWorld.x,l.boundingBox.extendSizeWorld.y),h=l.boundingBox.extendSizeWorld.z,d=2*u/c,f=0;f<r.length;f+=3){var p=Math.round(r[f+0]/d+c/2),_=Math.round(-1*(r[f+1]/d-c/2)),g=-r[f+2]+h;a[p]||(a[p]=[]),a[p][_]||(a[p][_]=g),a[p][_]=Math.max(g,a[p][_])}for(p=0;p<=c;++p){if(!a[p]){for(var m=1;!a[(p+m)%c];)m++;a[p]=a[(p+m)%c].slice()}for(_=0;_<=c;++_)if(!a[p][_]){var v;for(m=1;void 0===v;)v=a[p][(_+m++)%c];a[p][_]=v}}var y=new this.BJSCANNON.Heightfield(a,{elementSize:d});return y.minY=h,y},e.prototype._updatePhysicsBodyTransformation=function(e){var t=e.object;if(t.computeWorldMatrix&&t.computeWorldMatrix(!0),t.getBoundingInfo()){var i=e.getObjectCenter();this._tmpDeltaPosition.copyFrom(t.getAbsolutePivotPoint().subtract(i)),this._tmpDeltaPosition.divideInPlace(e.object.scaling),this._tmpPosition.copyFrom(i);var r=t.rotationQuaternion;if(r){if(e.type!==no.a.PlaneImpostor&&e.type!==no.a.HeightmapImpostor||(r=r.multiply(this._minus90X),e.setDeltaRotation(this._plus90X)),e.type===no.a.HeightmapImpostor){var n=t,s=n.getBoundingInfo(),a=n.rotationQuaternion;n.rotationQuaternion=this._tmpUnityRotation,n.computeWorldMatrix(!0);var c=i.clone(),l=n.getPivotMatrix();l=l?l.clone():o.j.Identity();var u=o.j.Translation(s.boundingBox.extendSizeWorld.x,0,-s.boundingBox.extendSizeWorld.z);n.setPreTransformMatrix(u),n.computeWorldMatrix(!0);var h=s.boundingBox.centerWorld.subtract(i).subtract(n.position).negate();this._tmpPosition.copyFromFloats(h.x,h.y-s.boundingBox.extendSizeWorld.y,h.z),this._tmpDeltaPosition.copyFrom(s.boundingBox.centerWorld.subtract(c)),this._tmpDeltaPosition.y+=s.boundingBox.extendSizeWorld.y,n.rotationQuaternion=a,n.setPreTransformMatrix(l),n.computeWorldMatrix(!0)}else e.type===no.a.MeshImpostor&&this._tmpDeltaPosition.copyFromFloats(0,0,0);e.setDeltaPosition(this._tmpDeltaPosition),e.physicsBody.position.copy(this._tmpPosition),e.physicsBody.quaternion.copy(r)}}},e.prototype.setTransformationFromPhysicsBody=function(e){e.object.position.copyFrom(e.physicsBody.position),e.object.rotationQuaternion&&e.object.rotationQuaternion.copyFrom(e.physicsBody.quaternion)},e.prototype.setPhysicsBodyTransformation=function(e,t,i){e.physicsBody.position.copy(t),e.physicsBody.quaternion.copy(i)},e.prototype.isSupported=function(){return void 0!==this.BJSCANNON},e.prototype.setLinearVelocity=function(e,t){e.physicsBody.velocity.copy(t)},e.prototype.setAngularVelocity=function(e,t){e.physicsBody.angularVelocity.copy(t)},e.prototype.getLinearVelocity=function(e){var t=e.physicsBody.velocity;return t?new o.x(t.x,t.y,t.z):null},e.prototype.getAngularVelocity=function(e){var t=e.physicsBody.angularVelocity;return t?new o.x(t.x,t.y,t.z):null},e.prototype.setBodyMass=function(e,t){e.physicsBody.mass=t,e.physicsBody.updateMassProperties()},e.prototype.getBodyMass=function(e){return e.physicsBody.mass},e.prototype.getBodyFriction=function(e){return e.physicsBody.material.friction},e.prototype.setBodyFriction=function(e,t){e.physicsBody.material.friction=t},e.prototype.getBodyRestitution=function(e){return e.physicsBody.material.restitution},e.prototype.setBodyRestitution=function(e,t){e.physicsBody.material.restitution=t},e.prototype.sleepBody=function(e){e.physicsBody.sleep()},e.prototype.wakeUpBody=function(e){e.physicsBody.wakeUp()},e.prototype.updateDistanceJoint=function(e,t){e.physicsJoint.distance=t},e.prototype.setMotor=function(e,t,i,r){r||(e.physicsJoint.enableMotor(),e.physicsJoint.setMotorSpeed(t),i&&this.setLimit(e,i))},e.prototype.setLimit=function(e,t,i){e.physicsJoint.motorEquation.maxForce=t,e.physicsJoint.motorEquation.minForce=void 0===i?-t:i},e.prototype.syncMeshWithImpostor=function(e,t){var i=t.physicsBody;e.position.x=i.position.x,e.position.y=i.position.y,e.position.z=i.position.z,e.rotationQuaternion&&(e.rotationQuaternion.x=i.quaternion.x,e.rotationQuaternion.y=i.quaternion.y,e.rotationQuaternion.z=i.quaternion.z,e.rotationQuaternion.w=i.quaternion.w)},e.prototype.getRadius=function(e){return e.physicsBody.shapes[0].boundingSphereRadius},e.prototype.getBoxSizeToRef=function(e,t){var i=e.physicsBody.shapes[0];t.x=2*i.halfExtents.x,t.y=2*i.halfExtents.y,t.z=2*i.halfExtents.z},e.prototype.dispose=function(){},e.prototype._extendNamespace=function(){var e=new this.BJSCANNON.Vec3,t=this.BJSCANNON;this.BJSCANNON.World.prototype.step=function(i,r,n){if(n=n||10,0===(r=r||0))this.internalStep(i),this.time+=i;else{var o=Math.floor((this.time+r)/i)-Math.floor(this.time/i);o=Math.min(o,n)||1;for(var s=performance.now(),a=0;a!==o&&(this.internalStep(i),!(performance.now()-s>1e3*i));a++);this.time+=r;for(var c=this.time%i/i,l=e,u=this.bodies,h=0;h!==u.length;h++){var d=u[h];d.type!==t.Body.STATIC&&d.sleepState!==t.Body.SLEEPING?(d.position.vsub(d.previousPosition,l),l.scale(c,l),d.position.vadd(l,d.interpolatedPosition)):(d.interpolatedPosition.copy(d.position),d.interpolatedQuaternion.copy(d.quaternion))}}}},e}();so.DefaultPluginFactory=function(){return new ao};var co=function(){function e(e,t){void 0===t&&(t=OIMO),this.name="OimoJSPlugin",this._tmpImpostorsArray=[],this._tmpPositionVector=o.x.Zero(),this.BJSOIMO=t,this.world=new this.BJSOIMO.World({iterations:e}),this.world.clear()}return e.prototype.setGravity=function(e){this.world.gravity.copy(e)},e.prototype.setTimeStep=function(e){this.world.timeStep=e},e.prototype.getTimeStep=function(){return this.world.timeStep},e.prototype.executeStep=function(e,t){var i=this;t.forEach(function(e){e.beforeStep()}),this.world.step(),t.forEach(function(e){e.afterStep(),i._tmpImpostorsArray[e.uniqueId]=e});for(var r=this.world.contacts;null!==r;)if(!r.touching||r.body1.sleeping||r.body2.sleeping){var n=this._tmpImpostorsArray[+r.body1.name],o=this._tmpImpostorsArray[+r.body2.name];n&&o?(n.onCollide({body:o.physicsBody}),o.onCollide({body:n.physicsBody}),r=r.next):r=r.next}else r=r.next},e.prototype.applyImpulse=function(e,t,i){var r=e.physicsBody.mass;e.physicsBody.applyImpulse(i.scale(this.world.invScale),t.scale(this.world.invScale*r))},e.prototype.applyForce=function(e,t,i){p.a.Warn("Oimo doesn't support applying force. Using impule instead."),this.applyImpulse(e,t,i)},e.prototype.generatePhysicsBody=function(e){var t=this;if(e.parent)e.physicsBody&&(this.removePhysicsBody(e),e.forceUpdate());else{if(e.isBodyInitRequired()){var i={name:e.uniqueId,config:[e.getParam("mass")||1,e.getParam("friction"),e.getParam("restitution")],size:[],type:[],pos:[],posShape:[],rot:[],rotShape:[],move:0!==e.getParam("mass"),density:e.getParam("mass"),friction:e.getParam("friction"),restitution:e.getParam("restitution"),world:this.world},r=[e];(a=e.object).getChildMeshes&&a.getChildMeshes().forEach(function(e){e.physicsImpostor&&r.push(e.physicsImpostor)});var n=function(e){return Math.max(e,so.Epsilon)},s=new o.q;r.forEach(function(r){if(r.object.rotationQuaternion){var o=r.object.rotationQuaternion;s=o.clone();var a=o.toEulerAngles(),c=r.getObjectExtendSize();if(r===e){var l=e.getObjectCenter();e.object.getAbsolutePivotPoint().subtractToRef(l,t._tmpPositionVector),t._tmpPositionVector.divideInPlace(e.object.scaling),i.pos.push(l.x),i.pos.push(l.y),i.pos.push(l.z),i.posShape.push(0,0,0),i.rotShape.push(0,0,0)}else{var u=r.object.getAbsolutePosition().subtract(e.object.getAbsolutePosition());i.posShape.push(u.x),i.posShape.push(u.y),i.posShape.push(u.z),i.pos.push(0,0,0),i.rotShape.push(57.29577951308232*a.x),i.rotShape.push(57.29577951308232*a.y),i.rotShape.push(57.29577951308232*a.z)}switch(r.type){case no.a.ParticleImpostor:p.a.Warn("No Particle support in OIMO.js. using SphereImpostor instead");case no.a.SphereImpostor:var h=c.x,d=c.y,f=c.z,_=Math.max(n(h),n(d),n(f))/2;i.type.push("sphere"),i.size.push(_),i.size.push(_),i.size.push(_);break;case no.a.CylinderImpostor:var g=n(c.x)/2,m=n(c.y);i.type.push("cylinder"),i.size.push(g),i.size.push(m),i.size.push(m);break;case no.a.PlaneImpostor:case no.a.BoxImpostor:default:g=n(c.x),m=n(c.y);var v=n(c.z);i.type.push("box"),i.size.push(g),i.size.push(m),i.size.push(v)}r.object.rotationQuaternion=o}}),e.physicsBody=this.world.add(i),e.physicsBody.resetQuaternion(s),e.physicsBody.updatePosition(0)}else this._tmpPositionVector.copyFromFloats(0,0,0);var a;e.setDeltaPosition(this._tmpPositionVector)}},e.prototype.removePhysicsBody=function(e){this.world.removeRigidBody(e.physicsBody)},e.prototype.generateJoint=function(e){var t=e.mainImpostor.physicsBody,i=e.connectedImpostor.physicsBody;if(t&&i){var r,n=e.joint.jointData,o=n.nativeParams||{},s={body1:t,body2:i,axe1:o.axe1||(n.mainAxis?n.mainAxis.asArray():null),axe2:o.axe2||(n.connectedAxis?n.connectedAxis.asArray():null),pos1:o.pos1||(n.mainPivot?n.mainPivot.asArray():null),pos2:o.pos2||(n.connectedPivot?n.connectedPivot.asArray():null),min:o.min,max:o.max,collision:o.collision||n.collision,spring:o.spring,world:this.world};switch(e.joint.type){case oo.e.BallAndSocketJoint:r="jointBall";break;case oo.e.SpringJoint:p.a.Warn("OIMO.js doesn't support Spring Constraint. Simulating using DistanceJoint instead");var a=n;s.min=a.length||s.min,s.max=Math.max(s.min,s.max);case oo.e.DistanceJoint:r="jointDistance",s.max=n.maxDistance;break;case oo.e.PrismaticJoint:r="jointPrisme";break;case oo.e.SliderJoint:r="jointSlide";break;case oo.e.WheelJoint:r="jointWheel";break;case oo.e.HingeJoint:default:r="jointHinge"}s.type=r,e.joint.physicsJoint=this.world.add(s)}},e.prototype.removeJoint=function(e){try{this.world.removeJoint(e.joint.physicsJoint)}catch(e){p.a.Warn(e)}},e.prototype.isSupported=function(){return void 0!==this.BJSOIMO},e.prototype.setTransformationFromPhysicsBody=function(e){e.physicsBody.sleeping||(e.object.position.copyFrom(e.physicsBody.getPosition()),e.object.rotationQuaternion&&e.object.rotationQuaternion.copyFrom(e.physicsBody.getQuaternion()))},e.prototype.setPhysicsBodyTransformation=function(e,t,i){var r=e.physicsBody;r.position.copy(t),r.orientation.copy(i),r.syncShapes(),r.awake()},e.prototype.setLinearVelocity=function(e,t){e.physicsBody.linearVelocity.copy(t)},e.prototype.setAngularVelocity=function(e,t){e.physicsBody.angularVelocity.copy(t)},e.prototype.getLinearVelocity=function(e){var t=e.physicsBody.linearVelocity;return t?new o.x(t.x,t.y,t.z):null},e.prototype.getAngularVelocity=function(e){var t=e.physicsBody.angularVelocity;return t?new o.x(t.x,t.y,t.z):null},e.prototype.setBodyMass=function(e,t){var i=0===t;e.physicsBody.shapes.density=i?1:t,e.physicsBody.setupMass(i?2:1)},e.prototype.getBodyMass=function(e){return e.physicsBody.shapes.density},e.prototype.getBodyFriction=function(e){return e.physicsBody.shapes.friction},e.prototype.setBodyFriction=function(e,t){e.physicsBody.shapes.friction=t},e.prototype.getBodyRestitution=function(e){return e.physicsBody.shapes.restitution},e.prototype.setBodyRestitution=function(e,t){e.physicsBody.shapes.restitution=t},e.prototype.sleepBody=function(e){e.physicsBody.sleep()},e.prototype.wakeUpBody=function(e){e.physicsBody.awake()},e.prototype.updateDistanceJoint=function(e,t,i){e.physicsJoint.limitMotor.upperLimit=t,void 0!==i&&(e.physicsJoint.limitMotor.lowerLimit=i)},e.prototype.setMotor=function(e,t,i,r){void 0!==i&&p.a.Warn("OimoJS plugin does not support setMotor with maxForce"),i=1e6,t*=-1;var n=r?e.physicsJoint.rotationalLimitMotor2:e.physicsJoint.rotationalLimitMotor1||e.physicsJoint.rotationalLimitMotor||e.physicsJoint.limitMotor;n&&n.setMotor(t,i)},e.prototype.setLimit=function(e,t,i,r){var n=r?e.physicsJoint.rotationalLimitMotor2:e.physicsJoint.rotationalLimitMotor1||e.physicsJoint.rotationalLimitMotor||e.physicsJoint.limitMotor;n&&n.setLimit(t,void 0===i?-t:i)},e.prototype.syncMeshWithImpostor=function(e,t){var i=t.physicsBody;e.position.x=i.position.x,e.position.y=i.position.y,e.position.z=i.position.z,e.rotationQuaternion&&(e.rotationQuaternion.x=i.orientation.x,e.rotationQuaternion.y=i.orientation.y,e.rotationQuaternion.z=i.orientation.z,e.rotationQuaternion.w=i.orientation.s)},e.prototype.getRadius=function(e){return e.physicsBody.shapes.radius},e.prototype.getBoxSizeToRef=function(e,t){var i=e.physicsBody.shapes;t.x=2*i.halfWidth,t.y=2*i.halfHeight,t.z=2*i.halfDepth},e.prototype.dispose=function(){this.world.clear()},e}();r.a.prototype.removeReflectionProbe=function(e){if(!this.reflectionProbes)return-1;var t=this.reflectionProbes.indexOf(e);return-1!==t&&this.reflectionProbes.splice(t,1),t},r.a.prototype.addReflectionProbe=function(e){this.reflectionProbes||(this.reflectionProbes=[]),this.reflectionProbes.push(e)};var lo=function(){function e(e,t,i,r,n){void 0===r&&(r=!0),void 0===n&&(n=!1);var s=this;this.name=e,this._viewMatrix=o.j.Identity(),this._target=o.x.Zero(),this._add=o.x.Zero(),this._invertYAxis=!1,this.position=o.x.Zero(),this._scene=i,this._scene.reflectionProbes||(this._scene.reflectionProbes=new Array),this._scene.reflectionProbes.push(this),this._renderTargetTexture=new Mi(e,t,i,r,!0,n?_.a.TEXTURETYPE_FLOAT:_.a.TEXTURETYPE_UNSIGNED_INT,!0),this._renderTargetTexture.onBeforeRenderObservable.add(function(e){switch(e){case 0:s._add.copyFromFloats(1,0,0);break;case 1:s._add.copyFromFloats(-1,0,0);break;case 2:s._add.copyFromFloats(0,s._invertYAxis?1:-1,0);break;case 3:s._add.copyFromFloats(0,s._invertYAxis?-1:1,0);break;case 4:s._add.copyFromFloats(0,0,1);break;case 5:s._add.copyFromFloats(0,0,-1)}s._attachedMesh&&s.position.copyFrom(s._attachedMesh.getAbsolutePosition()),s.position.addToRef(s._add,s._target),o.j.LookAtLHToRef(s.position,s._target,o.x.Up(),s._viewMatrix),i.activeCamera&&(s._projectionMatrix=o.j.PerspectiveFovLH(Math.PI/2,1,i.activeCamera.minZ,i.activeCamera.maxZ),i.setTransformMatrix(s._viewMatrix,s._projectionMatrix)),i._forcedViewPosition=s.position}),this._renderTargetTexture.onAfterUnbindObservable.add(function(){i._forcedViewPosition=null,i.updateTransformMatrix(!0)})}return Object.defineProperty(e.prototype,"samples",{get:function(){return this._renderTargetTexture.samples},set:function(e){this._renderTargetTexture.samples=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"refreshRate",{get:function(){return this._renderTargetTexture.refreshRate},set:function(e){this._renderTargetTexture.refreshRate=e},enumerable:!0,configurable:!0}),e.prototype.getScene=function(){return this._scene},Object.defineProperty(e.prototype,"cubeTexture",{get:function(){return this._renderTargetTexture},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"renderList",{get:function(){return this._renderTargetTexture.renderList},enumerable:!0,configurable:!0}),e.prototype.attachToMesh=function(e){this._attachedMesh=e},e.prototype.setRenderingAutoClearDepthStencil=function(e,t){this._renderTargetTexture.setRenderingAutoClearDepthStencil(e,t)},e.prototype.dispose=function(){var e=this._scene.reflectionProbes.indexOf(this);-1!==e&&this._scene.reflectionProbes.splice(e,1),this._renderTargetTexture&&(this._renderTargetTexture.dispose(),this._renderTargetTexture=null)},e.prototype.toString=function(e){var t="Name: "+this.name;return e&&(t+=", position: "+this.position.toString(),this._attachedMesh&&(t+=", attached mesh: "+this._attachedMesh.name)),t},e.prototype.getClassName=function(){return"ReflectionProbe"},e.prototype.serialize=function(){var e=w.a.Serialize(this,this._renderTargetTexture.serialize());return e.isReflectionProbe=!0,e},e.Parse=function(t,i,r){var n=null;if(i.reflectionProbes)for(var o=0;o<i.reflectionProbes.length;o++){var s=i.reflectionProbes[o];if(s.name===t.name){n=s;break}}return(n=w.a.Parse(function(){return n||new e(t.name,t.renderTargetSize,i,t._generateMipMaps)},t,i,r)).cubeTexture._waitingRenderList=t.renderList,t._attachedMesh&&n.attachToMesh(i.getMeshByID(t._attachedMesh)),n},l.c([Object(w.j)()],e.prototype,"_attachedMesh",void 0),l.c([Object(w.n)()],e.prototype,"position",void 0),e}(),uo=function(e,t,i,r){for(var n=0,o=t.materials.length;n<o;n++){var s=t.materials[n];if(s.id===e)return yn.a.Parse(s,i,r)}return null},ho=function(e,t,i){for(var r in t)if(e.name===t[r])return i.push(e.id),!0;return!(!e.parentId||-1===i.indexOf(e.parentId))&&(i.push(e.id),!0)},fo=function(e,t){return e+" of "+(t?t.file+" from "+t.name+" version: "+t.version+", exporter version: "+t.exporter_version:"unknown")},po=function(e,t,i,n,o){void 0===o&&(o=!1);var a=new pe(e),c="importScene has failed JSON parse";try{var l=JSON.parse(t);c="";var u,h,d=cr.loggingLevel===cr.DETAILED_LOGGING;if(void 0!==l.lights&&null!==l.lights)for(u=0,h=l.lights.length;u<h;u++){var f=l.lights[u],_=ri.a.Parse(f,e);_&&(a.lights.push(_),c+=0===u?"\n\tLights:":"",c+="\n\t\t"+_.toString(d))}if(void 0!==l.reflectionProbes&&null!==l.reflectionProbes)for(u=0,h=l.reflectionProbes.length;u<h;u++){var g=l.reflectionProbes[u],m=lo.Parse(g,e,i);m&&(a.reflectionProbes.push(m),c+=0===u?"\n\tReflection Probes:":"",c+="\n\t\t"+m.toString(d))}if(void 0!==l.animations&&null!==l.animations)for(u=0,h=l.animations.length;u<h;u++){var v=l.animations[u],y=s.a.GetClass("BABYLON.Animation");if(y){var b=y.Parse(v);e.animations.push(b),a.animations.push(b),c+=0===u?"\n\tAnimations:":"",c+="\n\t\t"+b.toString(d)}}if(void 0!==l.materials&&null!==l.materials)for(u=0,h=l.materials.length;u<h;u++){var T=l.materials[u],E=yn.a.Parse(T,e,i);a.materials.push(E),c+=0===u?"\n\tMaterials:":"",c+="\n\t\t"+E.toString(d)}if(void 0!==l.multiMaterials&&null!==l.multiMaterials)for(u=0,h=l.multiMaterials.length;u<h;u++){var x=l.multiMaterials[u],A=Zn.ParseMultiMaterial(x,e);a.multiMaterials.push(A),c+=0===u?"\n\tMultiMaterials:":"",c+="\n\t\t"+A.toString(d)}if(void 0!==l.morphTargetManagers&&null!==l.morphTargetManagers)for(var P=0,R=l.morphTargetManagers;P<R.length;P++){var S=R[P];a.morphTargetManagers.push(ro.Parse(S,e))}if(void 0!==l.skeletons&&null!==l.skeletons)for(u=0,h=l.skeletons.length;u<h;u++){var M=l.skeletons[u],O=ke.Parse(M,e);a.skeletons.push(O),c+=0===u?"\n\tSkeletons:":"",c+="\n\t\t"+O.toString(d)}var I=l.geometries;if(null!=I){var D=new Array,w=I.vertexData;if(null!=w)for(u=0,h=w.length;u<h;u++){var L=w[u];D.push(Qn.a.Parse(L,e,i))}D.forEach(function(e){e&&a.geometries.push(e)})}if(void 0!==l.transformNodes&&null!==l.transformNodes)for(u=0,h=l.transformNodes.length;u<h;u++){var F=l.transformNodes[u],N=en.a.Parse(F,e,i);a.transformNodes.push(N)}if(void 0!==l.meshes&&null!==l.meshes)for(u=0,h=l.meshes.length;u<h;u++){var B=l.meshes[u],U=de.a.Parse(B,e,i);a.meshes.push(U),c+=0===u?"\n\tMeshes:":"",c+="\n\t\t"+U.toString(d)}if(void 0!==l.cameras&&null!==l.cameras)for(u=0,h=l.cameras.length;u<h;u++){var V=l.cameras[u],G=Le.a.Parse(V,e);a.cameras.push(G),c+=0===u?"\n\tCameras:":"",c+="\n\t\t"+G.toString(d)}if(void 0!==l.animationGroups&&null!==l.animationGroups)for(u=0,h=l.animationGroups.length;u<h;u++){var k=l.animationGroups[u],z=q.Parse(k,e);a.animationGroups.push(z),c+=0===u?"\n\tAnimationGroups:":"",c+="\n\t\t"+z.toString(d)}for(u=0,h=e.cameras.length;u<h;u++){(G=e.cameras[u])._waitingParentId&&(G.parent=e.getLastEntryByID(G._waitingParentId),G._waitingParentId=null)}for(u=0,h=e.lights.length;u<h;u++){var j=e.lights[u];j&&j._waitingParentId&&(j.parent=e.getLastEntryByID(j._waitingParentId),j._waitingParentId=null)}for(u=0,h=e.transformNodes.length;u<h;u++){var W=e.transformNodes[u];W._waitingParentId&&(W.parent=e.getLastEntryByID(W._waitingParentId),W._waitingParentId=null)}for(u=0,h=e.meshes.length;u<h;u++){(U=e.meshes[u])._waitingParentId&&(U.parent=e.getLastEntryByID(U._waitingParentId),U._waitingParentId=null)}for(u=0,h=e.meshes.length;u<h;u++){var H=e.meshes[u];H._waitingFreezeWorldMatrix?(H.freezeWorldMatrix(),H._waitingFreezeWorldMatrix=null):H.computeWorldMatrix(!0)}for(u=0,h=e.lights.length;u<h;u++){var X=e.lights[u];if(X._excludedMeshesIds.length>0){for(var Y=0;Y<X._excludedMeshesIds.length;Y++){var K=e.getMeshByID(X._excludedMeshesIds[Y]);K&&X.excludedMeshes.push(K)}X._excludedMeshesIds=[]}if(X._includedOnlyMeshesIds.length>0){for(var Q=0;Q<X._includedOnlyMeshesIds.length;Q++){var Z=e.getMeshByID(X._includedOnlyMeshesIds[Q]);Z&&X.includedOnlyMeshes.push(Z)}X._includedOnlyMeshesIds=[]}}for(r.a.Parse(l,e,a,i),u=0,h=e.meshes.length;u<h;u++){(U=e.meshes[u])._waitingActions&&(C.Parse(U._waitingActions,U,e),U._waitingActions=null)}void 0!==l.actions&&null!==l.actions&&C.Parse(l.actions,null,e),o||a.removeAllFromScene()}catch(e){var J=fo("loadAssets",l?l.producer:"Unknown")+c;if(!n)throw p.a.Log(J),e;n(J,e)}finally{null!==c&&cr.loggingLevel!==cr.NO_LOGGING&&p.a.Log(fo("loadAssets",l?l.producer:"Unknown")+(cr.loggingLevel!==cr.MINIMAL_LOGGING?c:""))}return a};cr.RegisterPlugin({name:"babylon.js",extensions:".babylon",canDirectLoad:function(e){return-1!==e.indexOf("babylon")},importMesh:function(e,t,i,n,o,s,a,c){var l="importMesh has failed JSON parse";try{var u=JSON.parse(i);l="";var h=cr.loggingLevel===cr.DETAILED_LOGGING;e?Array.isArray(e)||(e=[e]):e=null;var d=new Array;if(void 0!==u.meshes&&null!==u.meshes){var f,_,g,m=[],v=[];for(f=0,_=u.meshes.length;f<_;f++){var y=u.meshes[f];if(null===e||ho(y,e,d)){if(null!==e&&delete e[e.indexOf(y.name)],void 0!==y.geometryId&&null!==y.geometryId&&void 0!==u.geometries&&null!==u.geometries){var b=!1;["boxes","spheres","cylinders","toruses","grounds","planes","torusKnots","vertexData"].forEach(function(e){!0!==b&&u.geometries[e]&&Array.isArray(u.geometries[e])&&u.geometries[e].forEach(function(i){if(i.id===y.geometryId){switch(e){case"vertexData":Qn.a.Parse(i,t,n)}b=!0}})}),!1===b&&p.a.Warn("Geometry not found for mesh "+y.id)}if(y.materialId){var T=-1!==v.indexOf(y.materialId);if(!1===T&&void 0!==u.multiMaterials&&null!==u.multiMaterials)for(var E=0,x=u.multiMaterials.length;E<x;E++){var A=u.multiMaterials[E];if(A.id===y.materialId){for(var P=0,R=A.materials.length;P<R;P++){var S,C=A.materials[P];v.push(C),(S=uo(C,u,t,n))&&(l+="\n\tMaterial "+S.toString(h))}v.push(A.id);var M=Zn.ParseMultiMaterial(A,t);M&&(T=!0,l+="\n\tMulti-Material "+M.toString(h));break}}if(!1===T)v.push(y.materialId),(S=uo(y.materialId,u,t,n))?l+="\n\tMaterial "+S.toString(h):p.a.Warn("Material not found for mesh "+y.id)}if(y.skeletonId>-1&&void 0!==u.skeletons&&null!==u.skeletons)if(!1===m.indexOf(y.skeletonId)>-1)for(var O=0,I=u.skeletons.length;O<I;O++){var D=u.skeletons[O];if(D.id===y.skeletonId){var w=ke.Parse(D,t);a.push(w),m.push(D.id),l+="\n\tSkeleton "+w.toString(h)}}if(void 0!==u.morphTargetManagers&&null!==u.morphTargetManagers)for(var L=0,F=u.morphTargetManagers;L<F.length;L++){var N=F[L];ro.Parse(N,t)}var B=de.a.Parse(y,t,n);o.push(B),l+="\n\tMesh "+B.toString(h)}}for(f=0,_=t.meshes.length;f<_;f++)(g=t.meshes[f])._waitingParentId&&(g.parent=t.getLastEntryByID(g._waitingParentId),g._waitingParentId=null);for(f=0,_=t.meshes.length;f<_;f++)(g=t.meshes[f])._waitingFreezeWorldMatrix?(g.freezeWorldMatrix(),g._waitingFreezeWorldMatrix=null):g.computeWorldMatrix(!0)}if(void 0!==u.particleSystems&&null!==u.particleSystems){var U=r.a.GetIndividualParser(Te.a.NAME_PARTICLESYSTEM);if(U)for(f=0,_=u.particleSystems.length;f<_;f++){var V=u.particleSystems[f];-1!==d.indexOf(V.emitterId)&&s.push(U(V,t,n))}}return!0}catch(e){var G=fo("importMesh",u?u.producer:"Unknown")+l;if(!c)throw p.a.Log(G),e;c(G,e)}finally{null!==l&&cr.loggingLevel!==cr.NO_LOGGING&&p.a.Log(fo("importMesh",u?u.producer:"Unknown")+(cr.loggingLevel!==cr.MINIMAL_LOGGING?l:""))}return!1},load:function(e,t,i,r){var n="importScene has failed JSON parse";try{var s=JSON.parse(t);if(n="",void 0!==s.useDelayedTextureLoading&&null!==s.useDelayedTextureLoading&&(e.useDelayedTextureLoading=s.useDelayedTextureLoading&&!cr.ForceFullSceneLoadingForIncremental),void 0!==s.autoClear&&null!==s.autoClear&&(e.autoClear=s.autoClear),void 0!==s.clearColor&&null!==s.clearColor&&(e.clearColor=o.f.FromArray(s.clearColor)),void 0!==s.ambientColor&&null!==s.ambientColor&&(e.ambientColor=o.e.FromArray(s.ambientColor)),void 0!==s.gravity&&null!==s.gravity&&(e.gravity=o.x.FromArray(s.gravity)),s.fogMode&&0!==s.fogMode)switch(e.fogMode=s.fogMode,e.fogColor=o.e.FromArray(s.fogColor),e.fogStart=s.fogStart,e.fogEnd=s.fogEnd,e.fogDensity=s.fogDensity,n+="\tFog mode for scene: ",e.fogMode){case 1:n+="exp\n";break;case 2:n+="exp2\n";break;case 3:n+="linear\n"}if(s.physicsEnabled){var a;"cannon"===s.physicsEngine?a=new ao:"oimo"===s.physicsEngine&&(a=new co),n="\tPhysics engine "+(s.physicsEngine?s.physicsEngine:"oimo")+" enabled\n";var c=s.physicsGravity?o.x.FromArray(s.physicsGravity):null;e.enablePhysics(c,a)}if(void 0!==s.metadata&&null!==s.metadata&&(e.metadata=s.metadata),void 0!==s.collisionsEnabled&&null!==s.collisionsEnabled&&(e.collisionsEnabled=s.collisionsEnabled),!po(e,t,i,r,!0))return!1;if(s.autoAnimate&&e.beginAnimation(e,s.autoAnimateFrom,s.autoAnimateTo,s.autoAnimateLoop,s.autoAnimateSpeed||1),void 0!==s.activeCameraID&&null!==s.activeCameraID&&e.setActiveCameraByID(s.activeCameraID),void 0!==s.environmentTexture&&null!==s.environmentTexture){var l=void 0===s.isPBR||s.isPBR;if(s.environmentTextureType&&"BABYLON.HDRCubeTexture"===s.environmentTextureType){var u=s.environmentTextureSize?s.environmentTextureSize:128,h=new to(i+s.environmentTexture,e,u,!0,!l);s.environmentTextureRotationY&&(h.rotationY=s.environmentTextureRotationY),e.environmentTexture=h}else{var d=Gr.CreateFromPrefilteredData(i+s.environmentTexture,e);s.environmentTextureRotationY&&(d.rotationY=s.environmentTextureRotationY),e.environmentTexture=d}if(!0===s.createDefaultSkybox){var f=void 0!==e.activeCamera&&null!==e.activeCamera?(e.activeCamera.maxZ-e.activeCamera.minZ)/2:1e3,_=s.skyboxBlurLevel||0;e.createDefaultSkybox(e.environmentTexture,l,f,_)}}return!0}catch(e){var g=fo("importScene",s?s.producer:"Unknown")+n;if(!r)throw p.a.Log(g),e;r(g,e)}finally{null!==n&&cr.loggingLevel!==cr.NO_LOGGING&&p.a.Log(fo("importScene",s?s.producer:"Unknown")+(cr.loggingLevel!==cr.MINIMAL_LOGGING?n:""))}return!1},loadAssetContainer:function(e,t,i,r){return po(e,t,i,r)}});var _o=i(84),go=function(){function e(){this._isEnabled=!0,this.leftColor=o.e.White(),this.rightColor=o.e.Black(),this.bias=0,this.power=1}return Object.defineProperty(e.prototype,"isEnabled",{get:function(){return this._isEnabled},set:function(e){this._isEnabled!==e&&(this._isEnabled=e,_e.b.MarkAllMaterialsAsDirty(_.a.MATERIAL_FresnelDirtyFlag|_.a.MATERIAL_MiscDirtyFlag))},enumerable:!0,configurable:!0}),e.prototype.clone=function(){var t=new e;return S.a.DeepCopy(this,t),t},e.prototype.serialize=function(){var e={};return e.isEnabled=this.isEnabled,e.leftColor=this.leftColor.asArray(),e.rightColor=this.rightColor.asArray(),e.bias=this.bias,e.power=this.power,e},e.Parse=function(t){var i=new e;return i.isEnabled=t.isEnabled,i.leftColor=o.e.FromArray(t.leftColor),i.rightColor=o.e.FromArray(t.rightColor),i.bias=t.bias,i.power=t.power||1,i},e}();w.a._FresnelParametersParser=go.Parse;var mo=function(e){function t(t,i){var r=e.call(this,t,i)||this;return r.maxSimultaneousLights=4,r.disableLighting=!1,r.invertNormalMapX=!1,r.invertNormalMapY=!1,r.emissiveColor=new o.e(0,0,0),r.occlusionStrength=1,r.useLightmapAsShadowmap=!1,r._useAlphaFromAlbedoTexture=!0,r._useAmbientInGrayScale=!0,r}return l.d(t,e),Object.defineProperty(t.prototype,"doubleSided",{get:function(){return this._twoSidedLighting},set:function(e){this._twoSidedLighting!==e&&(this._twoSidedLighting=e,this.backFaceCulling=!e,this._markAllSubMeshesAsTexturesDirty())},enumerable:!0,configurable:!0}),t.prototype.getActiveTextures=function(){var t=e.prototype.getActiveTextures.call(this);return this.environmentTexture&&t.push(this.environmentTexture),this.normalTexture&&t.push(this.normalTexture),this.emissiveTexture&&t.push(this.emissiveTexture),this.occlusionTexture&&t.push(this.occlusionTexture),this.lightmapTexture&&t.push(this.lightmapTexture),t},t.prototype.hasTexture=function(t){return!!e.prototype.hasTexture.call(this,t)||this.lightmapTexture===t},t.prototype.getClassName=function(){return"PBRBaseSimpleMaterial"},l.c([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsLightsDirty")],t.prototype,"maxSimultaneousLights",void 0),l.c([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsLightsDirty")],t.prototype,"disableLighting",void 0),l.c([Object(w.l)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty","_reflectionTexture")],t.prototype,"environmentTexture",void 0),l.c([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"invertNormalMapX",void 0),l.c([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"invertNormalMapY",void 0),l.c([Object(w.l)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty","_bumpTexture")],t.prototype,"normalTexture",void 0),l.c([Object(w.e)("emissive"),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"emissiveColor",void 0),l.c([Object(w.l)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"emissiveTexture",void 0),l.c([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty","_ambientTextureStrength")],t.prototype,"occlusionStrength",void 0),l.c([Object(w.l)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty","_ambientTexture")],t.prototype,"occlusionTexture",void 0),l.c([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty","_alphaCutOff")],t.prototype,"alphaCutOff",void 0),l.c([Object(w.c)()],t.prototype,"doubleSided",null),l.c([Object(w.l)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty",null)],t.prototype,"lightmapTexture",void 0),l.c([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useLightmapAsShadowmap",void 0),t}(fn),vo=function(e){function t(t,i){var r=e.call(this,t,i)||this;return r._useRoughnessFromMetallicTextureAlpha=!1,r._useRoughnessFromMetallicTextureGreen=!0,r._useMetallnessFromMetallicTextureBlue=!0,r.metallic=1,r.roughness=1,r}return l.d(t,e),t.prototype.getClassName=function(){return"PBRMetallicRoughnessMaterial"},t.prototype.getActiveTextures=function(){var t=e.prototype.getActiveTextures.call(this);return this.baseTexture&&t.push(this.baseTexture),this.metallicRoughnessTexture&&t.push(this.metallicRoughnessTexture),t},t.prototype.hasTexture=function(t){return!!e.prototype.hasTexture.call(this,t)||(this.baseTexture===t||this.metallicRoughnessTexture===t)},t.prototype.clone=function(e){var i=this,r=w.a.Clone(function(){return new t(e,i.getScene())},this);return r.id=e,r.name=e,r},t.prototype.serialize=function(){var e=w.a.Serialize(this);return e.customType="BABYLON.PBRMetallicRoughnessMaterial",e},t.Parse=function(e,i,r){return w.a.Parse(function(){return new t(e.name,i)},e,i,r)},l.c([Object(w.e)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty","_albedoColor")],t.prototype,"baseColor",void 0),l.c([Object(w.l)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty","_albedoTexture")],t.prototype,"baseTexture",void 0),l.c([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"metallic",void 0),l.c([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"roughness",void 0),l.c([Object(w.l)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty","_metallicTexture")],t.prototype,"metallicRoughnessTexture",void 0),t}(mo);s.a.RegisteredTypes["BABYLON.PBRMetallicRoughnessMaterial"]=vo;var yo=function(e){function t(t,i){var r=e.call(this,t,i)||this;return r._useMicroSurfaceFromReflectivityMapAlpha=!0,r}return l.d(t,e),t.prototype.getClassName=function(){return"PBRSpecularGlossinessMaterial"},t.prototype.getActiveTextures=function(){var t=e.prototype.getActiveTextures.call(this);return this.diffuseTexture&&t.push(this.diffuseTexture),this.specularGlossinessTexture&&t.push(this.specularGlossinessTexture),t},t.prototype.hasTexture=function(t){return!!e.prototype.hasTexture.call(this,t)||(this.diffuseTexture===t||this.specularGlossinessTexture===t)},t.prototype.clone=function(e){var i=this,r=w.a.Clone(function(){return new t(e,i.getScene())},this);return r.id=e,r.name=e,r},t.prototype.serialize=function(){var e=w.a.Serialize(this);return e.customType="BABYLON.PBRSpecularGlossinessMaterial",e},t.Parse=function(e,i,r){return w.a.Parse(function(){return new t(e.name,i)},e,i,r)},l.c([Object(w.e)("diffuse"),Object(w.b)("_markAllSubMeshesAsTexturesDirty","_albedoColor")],t.prototype,"diffuseColor",void 0),l.c([Object(w.l)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty","_albedoTexture")],t.prototype,"diffuseTexture",void 0),l.c([Object(w.e)("specular"),Object(w.b)("_markAllSubMeshesAsTexturesDirty","_reflectivityColor")],t.prototype,"specularColor",void 0),l.c([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty","_microSurface")],t.prototype,"glossiness",void 0),l.c([Object(w.l)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty","_reflectivityTexture")],t.prototype,"specularGlossinessTexture",void 0),t}(mo);s.a.RegisteredTypes["BABYLON.PBRSpecularGlossinessMaterial"]=yo;var bo=i(70),To=function(e){function t(t,i){var r=e.call(this,i)||this;return t?(r._engine=i.getEngine(),r._textureMatrix=o.j.Identity(),r.name=t,r.url=t,r.hasAlpha=!1,r.isCube=!1,r.is3D=r._engine.webGLVersion>1,r.wrapU=_.a.TEXTURE_CLAMP_ADDRESSMODE,r.wrapV=_.a.TEXTURE_CLAMP_ADDRESSMODE,r.wrapR=_.a.TEXTURE_CLAMP_ADDRESSMODE,r.anisotropicFilteringLevel=1,r._texture=r._getFromCache(t,!0),r._texture||(i.useDelayedTextureLoading?r.delayLoadState=_.a.DELAYLOADSTATE_NOTLOADED:r.loadTexture()),r):r}return l.d(t,e),t.prototype.getTextureMatrix=function(){return this._textureMatrix},t.prototype.load3dlTexture=function(){var e,i=this._engine;e=1===i.webGLVersion?i.createRawTexture(null,1,1,_.a.TEXTUREFORMAT_RGBA,!1,!1,_.a.TEXTURE_BILINEAR_SAMPLINGMODE):i.createRawTexture3D(null,1,1,1,_.a.TEXTUREFORMAT_RGBA,!1,!1,_.a.TEXTURE_BILINEAR_SAMPLINGMODE),this._texture=e;var r=function(r){if("string"==typeof r){for(var n,o=null,s=null,a=r.split("\n"),c=0,l=0,u=0,h=0,d=0,f=0;f<a.length;f++)if(n=a[f],t._noneEmptyLineRegex.test(n)&&0!==n.indexOf("#")){var p=n.split(" ");if(0!==c){if(0!=c){var g=Math.max(parseInt(p[0]),0),m=Math.max(parseInt(p[1]),0),v=Math.max(parseInt(p[2]),0);d=Math.max(g,d),d=Math.max(m,d),d=Math.max(v,d);var y=4*(l+h*c+u*c*c);s&&(s[y+0]=g,s[y+1]=m,s[y+2]=v),++u%c==0&&(u=0,++h%c==0&&(l++,h=0))}}else c=p.length,o=new Uint8Array(c*c*c*4),s=new Float32Array(c*c*c*4)}if(s&&o)for(f=0;f<s.length;f++)if(f>0&&(f+1)%4==0)o[f]=255;else{var b=s[f];o[f]=b/d*255}e.is3D?(e.updateSize(c,c,c),i.updateRawTexture3D(e,o,_.a.TEXTUREFORMAT_RGBA,!1)):(e.updateSize(c*c,c),i.updateRawTexture(e,o,_.a.TEXTUREFORMAT_RGBA,!1))}},n=this.getScene();return n?n._loadFile(this.url,r):this._engine._loadFile(this.url,r),this._texture},t.prototype.loadTexture=function(){this.url&&this.url.toLocaleLowerCase().indexOf(".3dl")==this.url.length-4&&this.load3dlTexture()},t.prototype.clone=function(){var e=new t(this.url,this.getScene());return e.level=this.level,e},t.prototype.delayLoad=function(){this.delayLoadState===_.a.DELAYLOADSTATE_NOTLOADED&&(this.delayLoadState=_.a.DELAYLOADSTATE_LOADED,this._texture=this._getFromCache(this.url,!0),this._texture||this.loadTexture())},t.Parse=function(e,i){var r=null;return e.name&&!e.isRenderTarget&&((r=new t(e.name,i)).name=e.name,r.level=e.level),r},t.prototype.serialize=function(){if(!this.name)return null;var e={};return e.name=this.name,e.level=this.level,e.customType="BABYLON.ColorGradingTexture",e},t._noneEmptyLineRegex=/\S+/,t}(wr.a);s.a.RegisteredTypes["BABYLON.ColorGradingTexture"]=To;var Eo=i(88),xo=i(59);function Ao(e){return e.charCodeAt(0)+(e.charCodeAt(1)<<8)+(e.charCodeAt(2)<<16)+(e.charCodeAt(3)<<24)}var Po=Ao("DXT1"),Ro=Ao("DXT3"),So=Ao("DXT5"),Co=Ao("DX10"),Mo=function(){function e(){}return e.GetDDSInfo=function(e){var t=new Int32Array(e,0,31),i=new Int32Array(e,0,35),r=1;131072&t[2]&&(r=Math.max(1,t[7]));var n=t[21],o=n===Co?i[32]:0,s=_.a.TEXTURETYPE_UNSIGNED_INT;switch(n){case 113:s=_.a.TEXTURETYPE_HALF_FLOAT;break;case 116:s=_.a.TEXTURETYPE_FLOAT;break;case Co:if(10===o){s=_.a.TEXTURETYPE_HALF_FLOAT;break}}return{width:t[4],height:t[3],mipmapCount:r,isFourCC:4==(4&t[20]),isRGB:64==(64&t[20]),isLuminance:131072==(131072&t[20]),isCube:512==(512&t[28]),isCompressed:n===Po||n===Ro||n===So,dxgiFormat:o,textureType:s}},e._ToHalfFloat=function(t){e._FloatView||(e._FloatView=new Float32Array(1),e._Int32View=new Int32Array(e._FloatView.buffer)),e._FloatView[0]=t;var i=e._Int32View[0],r=i>>16&32768,n=i>>12&2047,o=i>>23&255;return o<103?r:o>142?(r|=31744,r|=(255==o?0:1)&&8388607&i):o<113?r|=((n|=2048)>>114-o)+(n>>113-o&1):(r|=o-112<<10|n>>1,r+=1&n)},e._FromHalfFloat=function(e){var t=(32768&e)>>15,i=(31744&e)>>10,r=1023&e;return 0===i?(t?-1:1)*Math.pow(2,-14)*(r/Math.pow(2,10)):31==i?r?NaN:1/0*(t?-1:1):(t?-1:1)*Math.pow(2,i-15)*(1+r/Math.pow(2,10))},e._GetHalfFloatAsFloatRGBAArrayBuffer=function(t,i,r,n,o,s){for(var a=new Float32Array(n),c=new Uint16Array(o,r),l=0,u=0;u<i;u++)for(var h=0;h<t;h++){var d=4*(h+u*t);a[l]=e._FromHalfFloat(c[d]),a[l+1]=e._FromHalfFloat(c[d+1]),a[l+2]=e._FromHalfFloat(c[d+2]),e.StoreLODInAlphaChannel?a[l+3]=s:a[l+3]=e._FromHalfFloat(c[d+3]),l+=4}return a},e._GetHalfFloatRGBAArrayBuffer=function(t,i,r,n,o,s){if(e.StoreLODInAlphaChannel){for(var a=new Uint16Array(n),c=new Uint16Array(o,r),l=0,u=0;u<i;u++)for(var h=0;h<t;h++){var d=4*(h+u*t);a[l]=c[d],a[l+1]=c[d+1],a[l+2]=c[d+2],a[l+3]=e._ToHalfFloat(s),l+=4}return a}return new Uint16Array(o,r,n)},e._GetFloatRGBAArrayBuffer=function(t,i,r,n,o,s){if(e.StoreLODInAlphaChannel){for(var a=new Float32Array(n),c=new Float32Array(o,r),l=0,u=0;u<i;u++)for(var h=0;h<t;h++){var d=4*(h+u*t);a[l]=c[d],a[l+1]=c[d+1],a[l+2]=c[d+2],a[l+3]=s,l+=4}return a}return new Float32Array(o,r,n)},e._GetFloatAsUIntRGBAArrayBuffer=function(t,i,r,n,o,s){for(var a=new Uint8Array(n),c=new Float32Array(o,r),l=0,u=0;u<i;u++)for(var h=0;h<t;h++){var d=4*(h+u*t);a[l]=255*D.a.Clamp(c[d]),a[l+1]=255*D.a.Clamp(c[d+1]),a[l+2]=255*D.a.Clamp(c[d+2]),e.StoreLODInAlphaChannel?a[l+3]=s:a[l+3]=255*D.a.Clamp(c[d+3]),l+=4}return a},e._GetHalfFloatAsUIntRGBAArrayBuffer=function(t,i,r,n,o,s){for(var a=new Uint8Array(n),c=new Uint16Array(o,r),l=0,u=0;u<i;u++)for(var h=0;h<t;h++){var d=4*(h+u*t);a[l]=255*D.a.Clamp(e._FromHalfFloat(c[d])),a[l+1]=255*D.a.Clamp(e._FromHalfFloat(c[d+1])),a[l+2]=255*D.a.Clamp(e._FromHalfFloat(c[d+2])),e.StoreLODInAlphaChannel?a[l+3]=s:a[l+3]=255*D.a.Clamp(e._FromHalfFloat(c[d+3])),l+=4}return a},e._GetRGBAArrayBuffer=function(e,t,i,r,n,o,s,a,c){for(var l=new Uint8Array(r),u=new Uint8Array(n,i),h=0,d=0;d<t;d++)for(var f=0;f<e;f++){var p=4*(f+d*e);l[h]=u[p+o],l[h+1]=u[p+s],l[h+2]=u[p+a],l[h+3]=u[p+c],h+=4}return l},e._ExtractLongWordOrder=function(t){return 0===t||255===t||-16777216===t?0:1+e._ExtractLongWordOrder(t>>8)},e._GetRGBArrayBuffer=function(e,t,i,r,n,o,s,a){for(var c=new Uint8Array(r),l=new Uint8Array(n,i),u=0,h=0;h<t;h++)for(var d=0;d<e;d++){var f=3*(d+h*e);c[u]=l[f+o],c[u+1]=l[f+s],c[u+2]=l[f+a],u+=3}return c},e._GetLuminanceArrayBuffer=function(e,t,i,r,n){for(var o=new Uint8Array(r),s=new Uint8Array(n,i),a=0,c=0;c<t;c++)for(var l=0;l<e;l++){var u=l+c*e;o[a]=s[u],a++}return o},e.UploadDDSLevels=function(t,i,r,n,o,s,a,c){void 0===a&&(a=-1);var l=null;n.sphericalPolynomial&&(l=new Array);var u,h,d,f,g,m,v,y=t.getCaps().s3tc,b=new Int32Array(r,0,31),T=0,E=0,x=1;if(542327876===b[0])if(n.isFourCC||n.isRGB||n.isLuminance)if(!n.isCompressed||y){var A=b[22];f=b[1]+4;var P,R=!1;if(n.isFourCC)switch(u=b[21]){case Po:x=8,E=y.COMPRESSED_RGBA_S3TC_DXT1_EXT;break;case Ro:x=16,E=y.COMPRESSED_RGBA_S3TC_DXT3_EXT;break;case So:x=16,E=y.COMPRESSED_RGBA_S3TC_DXT5_EXT;break;case 113:case 116:R=!0;break;case Co:f+=20;var S=!1;switch(n.dxgiFormat){case 10:R=!0,S=!0;break;case 88:n.isRGB=!0,n.isFourCC=!1,A=32,S=!0}if(S)break;default:return void console.error("Unsupported FourCC code:",(P=u,String.fromCharCode(255&P,P>>8&255,P>>16&255,P>>24&255)))}var C=e._ExtractLongWordOrder(b[23]),M=e._ExtractLongWordOrder(b[24]),O=e._ExtractLongWordOrder(b[25]),I=e._ExtractLongWordOrder(b[26]);R&&(E=t._getRGBABufferInternalSizedFormat(n.textureType)),m=1,131072&b[2]&&!1!==o&&(m=Math.max(1,b[7]));for(var D=0;D<s;D++){for(h=b[4],d=b[3],v=0;v<m;++v){if(-1===a||a===v){var w=-1===a?v:0;if(!n.isCompressed&&n.isFourCC){i.format=_.a.TEXTUREFORMAT_RGBA,T=h*d*4;var L=null;t._badOS||t._badDesktopOS||!t.getCaps().textureHalfFloat&&!t.getCaps().textureFloat?(128===A?(L=e._GetFloatAsUIntRGBAArrayBuffer(h,d,f,T,r,w),l&&0==w&&l.push(e._GetFloatRGBAArrayBuffer(h,d,f,T,r,w))):64===A&&(L=e._GetHalfFloatAsUIntRGBAArrayBuffer(h,d,f,T,r,w),l&&0==w&&l.push(e._GetHalfFloatAsFloatRGBAArrayBuffer(h,d,f,T,r,w))),i.type=_.a.TEXTURETYPE_UNSIGNED_INT):128===A?(i.type=_.a.TEXTURETYPE_FLOAT,L=e._GetFloatRGBAArrayBuffer(h,d,f,T,r,w),l&&0==w&&l.push(L)):64!==A||t.getCaps().textureHalfFloat?(i.type=_.a.TEXTURETYPE_HALF_FLOAT,L=e._GetHalfFloatRGBAArrayBuffer(h,d,f,T,r,w),l&&0==w&&l.push(e._GetHalfFloatAsFloatRGBAArrayBuffer(h,d,f,T,r,w))):(i.type=_.a.TEXTURETYPE_FLOAT,L=e._GetHalfFloatAsFloatRGBAArrayBuffer(h,d,f,T,r,w),l&&0==w&&l.push(L)),L&&t._uploadDataToTextureDirectly(i,L,D,w)}else if(n.isRGB)i.type=_.a.TEXTURETYPE_UNSIGNED_INT,24===A?(i.format=_.a.TEXTUREFORMAT_RGB,T=h*d*3,g=e._GetRGBArrayBuffer(h,d,f,T,r,C,M,O),t._uploadDataToTextureDirectly(i,g,D,w)):(i.format=_.a.TEXTUREFORMAT_RGBA,T=h*d*4,g=e._GetRGBAArrayBuffer(h,d,f,T,r,C,M,O,I),t._uploadDataToTextureDirectly(i,g,D,w));else if(n.isLuminance){var F=t._getUnpackAlignement(),N=h;T=Math.floor((h+F-1)/F)*F*(d-1)+N,g=e._GetLuminanceArrayBuffer(h,d,f,T,r),i.format=_.a.TEXTUREFORMAT_LUMINANCE,i.type=_.a.TEXTURETYPE_UNSIGNED_INT,t._uploadDataToTextureDirectly(i,g,D,w)}else T=Math.max(4,h)/4*Math.max(4,d)/4*x,g=new Uint8Array(r,f,T),i.type=_.a.TEXTURETYPE_UNSIGNED_INT,t._uploadCompressedDataToTextureDirectly(i,E,h,d,g,D,w)}f+=A?h*d*(A/8):T,h*=.5,d*=.5,h=Math.max(1,h),d=Math.max(1,d)}if(void 0!==c)break}l&&l.length>0?n.sphericalPolynomial=eo.a.ConvertCubeMapToSphericalPolynomial({size:b[4],right:l[0],left:l[1],up:l[2],down:l[3],front:l[4],back:l[5],format:_.a.TEXTUREFORMAT_RGBA,type:_.a.TEXTURETYPE_FLOAT,gammaSpace:!1}):n.sphericalPolynomial=void 0}else p.a.Error("Compressed textures are not supported on this platform.");else p.a.Error("Unsupported format, must contain a FourCC, RGB or LUMINANCE code");else p.a.Error("Invalid magic number in DDS header")},e.StoreLODInAlphaChannel=!1,e}();_e.b.prototype.createPrefilteredCubeTexture=function(e,t,i,r,n,o,s,a,c){var l=this;void 0===n&&(n=null),void 0===o&&(o=null),void 0===a&&(a=null),void 0===c&&(c=!0);return this.createCubeTexture(e,t,null,!1,function(e){if(e){var o=e.texture;if(c?e.info.sphericalPolynomial&&(o._sphericalPolynomial=e.info.sphericalPolynomial):o._sphericalPolynomial=new xo.b,o._dataSource=Ri.a.DATASOURCE_CUBEPREFILTERED,l.getCaps().textureLOD)n&&n(o);else{var s=l._gl,a=e.width;if(a){for(var u=[],h=0;h<3;h++){var d=1-h/2,f=r,_=D.a.Log2(a)*i+r,g=f+(_-f)*d,m=Math.round(Math.min(Math.max(g,0),_)),v=new Ri.a(l,Ri.a.DATASOURCE_TEMP);if(v.type=o.type,v.format=o.format,v.width=Math.pow(2,Math.max(D.a.Log2(a)-m,0)),v.height=v.width,v.isCube=!0,l._bindTextureDirectly(s.TEXTURE_CUBE_MAP,v,!0),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_MAG_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_MIN_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_CUBE_MAP,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),e.isDDS){var y=e.info,b=e.data;l._unpackFlipY(y.isCompressed),Mo.UploadDDSLevels(l,v,b,y,!0,6,m)}else p.a.Warn("DDS is the only prefiltered cube map supported so far.");l._bindTextureDirectly(s.TEXTURE_CUBE_MAP,null);var T=new wr.a(t);T.isCube=!0,T._texture=v,v.isReady=!0,u.push(T)}o._lodTextureHigh=u[2],o._lodTextureMid=u[1],o._lodTextureLow=u[0],n&&n(o)}}}else n&&n(null)},o,s,a,c,i,r)};var Oo=function(){function e(){this.supportCascades=!0}return e.prototype.canLoad=function(e,t,i,r,n){return 0===e.indexOf(".dds")},e.prototype.transformUrl=function(e,t){return e},e.prototype.getFallbackTextureUrl=function(e,t){return null},e.prototype.loadCubeData=function(e,t,i,r,n){var o,s=t.getEngine(),a=!1;if(Array.isArray(e))for(var c=0;c<e.length;c++){var l=e[c];o=Mo.GetDDSInfo(l),t.width=o.width,t.height=o.height,a=(o.isRGB||o.isLuminance||o.mipmapCount>1)&&t.generateMipMaps,s._unpackFlipY(o.isCompressed),Mo.UploadDDSLevels(s,t,l,o,a,6,-1,c),o.isFourCC||1!==o.mipmapCount||s.generateMipMapsForCubemap(t)}else{var u=e;o=Mo.GetDDSInfo(u),t.width=o.width,t.height=o.height,i&&(o.sphericalPolynomial=new xo.b),a=(o.isRGB||o.isLuminance||o.mipmapCount>1)&&t.generateMipMaps,s._unpackFlipY(o.isCompressed),Mo.UploadDDSLevels(s,t,u,o,a,6),o.isFourCC||1!==o.mipmapCount||s.generateMipMapsForCubemap(t)}s._setCubeMapTextureParams(a),t.isReady=!0,r&&r({isDDS:!0,width:t.width,info:o,data:e,texture:t})},e.prototype.loadData=function(e,t,i){var r=Mo.GetDDSInfo(e),n=(r.isRGB||r.isLuminance||r.mipmapCount>1)&&t.generateMipMaps&&r.width>>r.mipmapCount-1==1;i(r.width,r.height,n,r.isFourCC,function(){Mo.UploadDDSLevels(t.getEngine(),t,e,r,n,1)})},e}();_e.b._TextureLoaders.push(new Oo);var Io="\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n#include<helperFunctions>\nvoid main(void)\n{\ngl_FragColor=toRGBD(texture2D(textureSampler,vUV).rgb);\n}";St.a.ShadersStore.rgbdEncodePixelShader=Io;var Do="\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n#include<helperFunctions>\nvoid main(void)\n{\ngl_FragColor=vec4(fromRGBD(texture2D(textureSampler,vUV)),1.0);\n}";St.a.ShadersStore.rgbdDecodePixelShader=Do;var wo=function(){function e(){}return e.GetEnvInfo=function(t){for(var i=new DataView(t),r=0,n=0;n<e._MagicBytes.length;n++)if(i.getUint8(r++)!==e._MagicBytes[n])return p.a.Error("Not a babylon environment map"),null;for(var o="",s=0;s=i.getUint8(r++);)o+=String.fromCharCode(s);var a=JSON.parse(o);return a.specular&&(a.specular.specularDataPosition=r,a.specular.lodGenerationScale=a.specular.lodGenerationScale||.8),a},e.CreateEnvTextureAsync=function(t){var i=this,r=t.getInternalTexture();if(!r)return Promise.reject("The cube texture is invalid.");if(!t._prefiltered)return Promise.reject("The cube texture is invalid (not prefiltered).");var n=r.getEngine();if(n&&n.premultipliedAlpha)return Promise.reject("Env texture can only be created when the engine is created with the premultipliedAlpha option set to false.");if(t.textureType===_.a.TEXTURETYPE_UNSIGNED_INT)return Promise.reject("The cube texture should allow HDR (Full Float or Half Float).");var o=n.getRenderingCanvas();if(!o)return Promise.reject("Env texture can only be created when the engine is associated to a canvas.");var s=_.a.TEXTURETYPE_FLOAT;if(!n.getCaps().textureFloatRender&&(s=_.a.TEXTURETYPE_HALF_FLOAT,!n.getCaps().textureHalfFloatRender))return Promise.reject("Env texture can only be created when the browser supports half float or full float rendering.");var a=r.width,c=new W.a(n),l={},u=[],h=D.a.Log2(r.width);h=Math.round(h);for(var d=function(e){for(var i=Math.pow(2,h-e),r=function(r){var a=t.readPixels(r,e),h=n.createRawTexture(a,i,i,_.a.TEXTUREFORMAT_RGBA,!1,!1,_.a.TEXTURE_NEAREST_SAMPLINGMODE,null,s),d=new Promise(function(t,s){var a=new Mt("rgbdEncode","rgbdEncode",null,null,1,null,_.a.TEXTURE_NEAREST_SAMPLINGMODE,n,!1,void 0,_.a.TEXTURETYPE_UNSIGNED_INT,void 0,null,!1);a.getEffect().executeWhenCompiled(function(){a.onApply=function(e){e._bindTexture("textureSampler",h)};var s=n.getRenderWidth(),u=n.getRenderHeight();n.setSize(i,i),c.postProcessManager.directRender([a],null),ve.h.ToBlob(o,function(i){var n=new FileReader;n.onload=function(i){var n=i.target.result;l[6*e+r]=n,t()},n.readAsArrayBuffer(i)}),n.setSize(s,u)})});u.push(d)},a=0;a<6;a++)r(a)},f=0;f<=h;f++)d(f);return Promise.all(u).then(function(){c.dispose();for(var r={version:1,width:a,irradiance:i._CreateEnvTextureIrradiance(t),specular:{mipmaps:[],lodGenerationScale:t.lodGenerationScale}},n=0,o=0;o<=h;o++)for(var s=0;s<6;s++){var u=l[6*o+s].byteLength;r.specular.mipmaps.push({length:u,position:n}),n+=u}for(var d=JSON.stringify(r),f=new ArrayBuffer(d.length+1),p=new Uint8Array(f),_=(o=0,d.length);o<_;o++)p[o]=d.charCodeAt(o);p[d.length]=0;var g=e._MagicBytes.length+n+f.byteLength,m=new ArrayBuffer(g),v=new Uint8Array(m),y=new DataView(m),b=0;for(o=0;o<e._MagicBytes.length;o++)y.setUint8(b++,e._MagicBytes[o]);v.set(new Uint8Array(f),b),b+=f.byteLength;for(o=0;o<=h;o++)for(s=0;s<6;s++){var T=l[6*o+s];v.set(new Uint8Array(T),b),b+=T.byteLength}return m})},e._CreateEnvTextureIrradiance=function(e){var t=e.sphericalPolynomial;return null==t?null:{x:[t.x.x,t.x.y,t.x.z],y:[t.y.x,t.y.y,t.y.z],z:[t.z.x,t.z.y,t.z.z],xx:[t.xx.x,t.xx.y,t.xx.z],yy:[t.yy.x,t.yy.y,t.yy.z],zz:[t.zz.x,t.zz.y,t.zz.z],yz:[t.yz.x,t.yz.y,t.yz.z],zx:[t.zx.x,t.zx.y,t.zx.z],xy:[t.xy.x,t.xy.y,t.xy.z]}},e.UploadEnvLevelsAsync=function(t,i,r){if(1!==r.version)throw new Error('Unsupported babylon environment map version "'+r.version+'"');var n=r.specular;if(!n)return Promise.resolve();var o=D.a.Log2(r.width);if(o=Math.round(o)+1,n.mipmaps.length!==6*o)throw new Error('Unsupported specular mipmaps number "'+n.mipmaps.length+'"');t._lodGenerationScale=n.lodGenerationScale;for(var s=new Array(o),a=0;a<o;a++){s[a]=new Array(6);for(var c=0;c<6;c++){var l=n.mipmaps[6*a+c];s[a][c]=new Uint8Array(i,n.specularDataPosition+l.position,l.length)}}return e.UploadLevelsAsync(t,s)},e.UploadLevelsAsync=function(e,t){if(!ve.h.IsExponentOfTwo(e.width))throw new Error("Texture size must be a power of two");var i=Math.round(D.a.Log2(e.width))+1,r=e.getEngine(),n=!1,o=!1,s=null,a=null,c=null,l=r.getCaps();if(e.format=_.a.TEXTUREFORMAT_RGBA,e.type=_.a.TEXTURETYPE_UNSIGNED_INT,e.generateMipMaps=!0,r.updateTextureSamplingMode(_.a.TEXTURE_TRILINEAR_SAMPLINGMODE,e),l.textureLOD?r.webGLVersion<2?n=!1:l.textureHalfFloatRender&&l.textureHalfFloatLinearFiltering?(n=!0,e.type=_.a.TEXTURETYPE_HALF_FLOAT):l.textureFloatRender&&l.textureFloatLinearFiltering&&(n=!0,e.type=_.a.TEXTURETYPE_FLOAT):(n=!1,o=!0,c={}),n)s=new Mt("rgbdDecode","rgbdDecode",null,null,1,null,_.a.TEXTURE_TRILINEAR_SAMPLINGMODE,r,!1,void 0,e.type,void 0,null,!1),e._isRGBD=!1,e.invertY=!1,a=r.createRenderTargetCubeTexture(e.width,{generateDepthBuffer:!1,generateMipMaps:!0,generateStencilBuffer:!1,samplingMode:_.a.TEXTURE_TRILINEAR_SAMPLINGMODE,type:e.type,format:_.a.TEXTUREFORMAT_RGBA});else if(e._isRGBD=!0,e.invertY=!0,o)for(var u=e._lodGenerationScale,h=e._lodGenerationOffset,d=0;d<3;d++){var f=(i-1)*u+h,p=h+(f-h)*(1-d/2),g=Math.round(Math.min(Math.max(p,0),f)),m=new Ri.a(r,Ri.a.DATASOURCE_TEMP);m.isCube=!0,m.invertY=!0,m.generateMipMaps=!1,r.updateTextureSamplingMode(_.a.TEXTURE_LINEAR_LINEAR,m);var v=new wr.a(null);switch(v.isCube=!0,v._texture=m,c[g]=v,d){case 0:e._lodTextureLow=v;break;case 1:e._lodTextureMid=v;break;case 2:e._lodTextureHigh=v}}var y=[],b=function(i){for(var l=function(l){var u=t[i][l],h=new Blob([u],{type:"image/png"}),d=URL.createObjectURL(h),f=new Image;f.src=d;var p=new Promise(function(t,u){f.onload=function(){if(n){var h=r.createTexture(null,!0,!0,null,_.a.TEXTURE_NEAREST_SAMPLINGMODE,null,function(e){u(e)},f);s.getEffect().executeWhenCompiled(function(){s.onApply=function(e){e._bindTexture("textureSampler",h),e.setFloat2("scale",1,1)},r.scenes[0].postProcessManager.directRender([s],a,!0,l,i),r.restoreDefaultFramebuffer(),h.dispose(),window.URL.revokeObjectURL(d),t()})}else{if(r._uploadImageToTexture(e,f,l,i),o){var p=c[i];p&&r._uploadImageToTexture(p._texture,f,l,0)}t()}},f.onerror=function(e){u(e)}});y.push(p)},u=0;u<6;u++)l(u)};for(d=0;d<t.length;d++)b(d);if(t.length<i){var T=void 0,E=Math.pow(2,i-1-t.length),x=E*E*4;switch(e.type){case _.a.TEXTURETYPE_UNSIGNED_INT:T=new Uint8Array(x);break;case _.a.TEXTURETYPE_HALF_FLOAT:T=new Uint16Array(x);break;case _.a.TEXTURETYPE_FLOAT:T=new Float32Array(x)}for(d=t.length;d<i;d++)for(var A=0;A<6;A++)r._uploadArrayBufferViewToTexture(e,T,A,d)}return Promise.all(y).then(function(){a&&(r._releaseFramebufferObjects(a),a._swapAndDie(e)),s&&s.dispose(),o&&(e._lodTextureHigh&&e._lodTextureHigh._texture&&(e._lodTextureHigh._texture.isReady=!0),e._lodTextureMid&&e._lodTextureMid._texture&&(e._lodTextureMid._texture.isReady=!0),e._lodTextureLow&&e._lodTextureLow._texture&&(e._lodTextureLow._texture.isReady=!0))})},e.UploadEnvSpherical=function(e,t){1!==t.version&&p.a.Warn('Unsupported babylon environment map version "'+t.version+'"');var i=t.irradiance;if(i){var r=new xo.b;o.x.FromArrayToRef(i.x,0,r.x),o.x.FromArrayToRef(i.y,0,r.y),o.x.FromArrayToRef(i.z,0,r.z),o.x.FromArrayToRef(i.xx,0,r.xx),o.x.FromArrayToRef(i.yy,0,r.yy),o.x.FromArrayToRef(i.zz,0,r.zz),o.x.FromArrayToRef(i.yz,0,r.yz),o.x.FromArrayToRef(i.zx,0,r.zx),o.x.FromArrayToRef(i.xy,0,r.xy),e._sphericalPolynomial=r}},e._UpdateRGBDAsync=function(t,i,r,n,o){return t._dataSource=Ri.a.DATASOURCE_CUBERAW_RGBD,t._bufferViewArrayArray=i,t._lodGenerationScale=n,t._lodGenerationOffset=o,t._sphericalPolynomial=r,e.UploadLevelsAsync(t,i).then(function(){t.isReady=!0})},e._MagicBytes=[134,22,135,150,246,214,150,54],e}();Ri.a._UpdateRGBDAsync=wo._UpdateRGBDAsync;var Lo=function(){function e(){this.supportCascades=!1}return e.prototype.canLoad=function(e,t,i,r,n){return 0===e.indexOf(".env")},e.prototype.transformUrl=function(e,t){return e},e.prototype.getFallbackTextureUrl=function(e,t){return null},e.prototype.loadCubeData=function(e,t,i,r,n){if(!Array.isArray(e)){e=e;var o=wo.GetEnvInfo(e);o?(t.width=o.width,t.height=o.width,wo.UploadEnvSpherical(t,o),wo.UploadEnvLevelsAsync(t,e,o).then(function(){t.isReady=!0,r&&r()})):n&&n("Can not parse the environment file",null)}},e.prototype.loadData=function(e,t,i){throw".env not supported in 2d."},e}();_e.b._TextureLoaders.push(new Lo);var Fo=function(){function e(t,i,r,n){this.arrayBuffer=t,this.isInvalid=!1;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 this.isInvalid=!0,void p.a.Error("texture missing KTX identifier");var s=Uint32Array.BYTES_PER_ELEMENT,a=new DataView(this.arrayBuffer,12,13*s),c=67305985===a.getUint32(0,!0);this.glType=a.getUint32(1*s,c),this.glTypeSize=a.getUint32(2*s,c),this.glFormat=a.getUint32(3*s,c),this.glInternalFormat=a.getUint32(4*s,c),this.glBaseInternalFormat=a.getUint32(5*s,c),this.pixelWidth=a.getUint32(6*s,c),this.pixelHeight=a.getUint32(7*s,c),this.pixelDepth=a.getUint32(8*s,c),this.numberOfArrayElements=a.getUint32(9*s,c),this.numberOfFaces=a.getUint32(10*s,c),this.numberOfMipmapLevels=a.getUint32(11*s,c),this.bytesOfKeyValueData=a.getUint32(12*s,c),0===this.glType?(this.numberOfMipmapLevels=Math.max(1,this.numberOfMipmapLevels),0!==this.pixelHeight&&0===this.pixelDepth?0===this.numberOfArrayElements?this.numberOfFaces===i?this.loadType=e.COMPRESSED_2D:p.a.Error("number of faces expected"+i+", but found "+this.numberOfFaces):p.a.Error("texture arrays not currently supported"):p.a.Error("only 2D textures currently supported")):p.a.Error("only compressed formats currently supported")}return e.prototype.uploadLevels=function(t,i){switch(this.loadType){case e.COMPRESSED_2D:this._upload2DCompressedLevels(t,i);break;case e.TEX_2D:case e.COMPRESSED_3D:case e.TEX_3D:}},e.prototype._upload2DCompressedLevels=function(t,i){for(var r=e.HEADER_LEN+this.bytesOfKeyValueData,n=this.pixelWidth,o=this.pixelHeight,s=i?this.numberOfMipmapLevels:1,a=0;a<s;a++){var c=new Int32Array(this.arrayBuffer,r,1)[0];r+=4;for(var l=0;l<this.numberOfFaces;l++){var u=new Uint8Array(this.arrayBuffer,r,c);t.getEngine()._uploadCompressedDataToTextureDirectly(t,this.glInternalFormat,n,o,u,l,a),r+=c,r+=3-(c+3)%4}n=Math.max(1,.5*n),o=Math.max(1,.5*o)}},e.HEADER_LEN=64,e.COMPRESSED_2D=0,e.COMPRESSED_3D=1,e.TEX_2D=2,e.TEX_3D=3,e}(),No=function(){function e(){this.supportCascades=!1}return e.prototype.canLoad=function(e,t,i,r,n){return!(!t||r||i||n)},e.prototype.transformUrl=function(e,t){var i=e.lastIndexOf(".");return-1!=i&&"ktx"==e.substring(i+1)?e:(i>-1?e.substring(0,i):e)+t},e.prototype.getFallbackTextureUrl=function(e,t){var i=new RegExp(t+"$");return e.replace(i,"")},e.prototype.loadCubeData=function(e,t,i,r,n){if(!Array.isArray(e)){t._invertVScale=!t.invertY;var o=t.getEngine(),s=new Fo(e,6),a=s.numberOfMipmapLevels>1&&t.generateMipMaps;o._unpackFlipY(!0),s.uploadLevels(t,t.generateMipMaps),t.width=s.pixelWidth,t.height=s.pixelHeight,o._setCubeMapTextureParams(a),t.isReady=!0}},e.prototype.loadData=function(e,t,i){t._invertVScale=!t.invertY;var r=new Fo(e,1);i(r.pixelWidth,r.pixelHeight,!1,!0,function(){r.uploadLevels(t,t.generateMipMaps)},r.isInvalid)},e}();_e.b._TextureLoaders.unshift(new No);var Bo=function(){function e(){}return e.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++]}},e.UploadContent=function(t,i){if(i.length<19)p.a.Error("Unable to load TGA file - Not enough data to contain header");else{var r=18,n=e.GetTGAHeader(i);if(n.id_length+r>i.length)p.a.Error("Unable to load TGA file - Not enough data");else{r+=n.id_length;var o,s=!1,a=!1,c=!1;switch(n.image_type){case e._TYPE_RLE_INDEXED:s=!0;case e._TYPE_INDEXED:a=!0;break;case e._TYPE_RLE_RGB:s=!0;case e._TYPE_RGB:break;case e._TYPE_RLE_GREY:s=!0;case e._TYPE_GREY:c=!0}var l,u,h,d,f,_,g,m=n.pixel_size>>3,v=n.width*n.height*m;if(a&&(l=i.subarray(r,r+=n.colormap_length*(n.colormap_size>>3))),s){var y,b,T;o=new Uint8Array(v);for(var E=0,x=new Uint8Array(m);r<v&&E<v;)if(b=1+(127&(y=i[r++])),128&y){for(T=0;T<m;++T)x[T]=i[r++];for(T=0;T<b;++T)o.set(x,E+T*m);E+=m*b}else{for(b*=m,T=0;T<b;++T)o[E+T]=i[r++];E+=b}}else o=i.subarray(r,r+=a?n.width*n.height:v);switch((n.flags&e._ORIGIN_MASK)>>e._ORIGIN_SHIFT){default:case e._ORIGIN_UL:u=0,d=1,g=n.width,h=0,f=1,_=n.height;break;case e._ORIGIN_BL:u=0,d=1,g=n.width,h=n.height-1,f=-1,_=-1;break;case e._ORIGIN_UR:u=n.width-1,d=-1,g=-1,h=0,f=1,_=n.height;break;case e._ORIGIN_BR:u=n.width-1,d=-1,g=-1,h=n.height-1,f=-1,_=-1}var A=e["_getImageData"+(c?"Grey":"")+n.pixel_size+"bits"](n,l,o,h,f,_,u,d,g);t.getEngine()._uploadDataToTextureDirectly(t,A)}}},e._getImageData8bits=function(e,t,i,r,n,o,s,a,c){var l,u,h,d=i,f=t,p=e.width,_=e.height,g=0,m=new Uint8Array(p*_*4);for(h=r;h!==o;h+=n)for(u=s;u!==c;u+=a,g++)l=d[g],m[4*(u+p*h)+3]=255,m[4*(u+p*h)+2]=f[3*l+0],m[4*(u+p*h)+1]=f[3*l+1],m[4*(u+p*h)+0]=f[3*l+2];return m},e._getImageData16bits=function(e,t,i,r,n,o,s,a,c){var l,u,h,d=i,f=e.width,p=e.height,_=0,g=new Uint8Array(f*p*4);for(h=r;h!==o;h+=n)for(u=s;u!==c;u+=a,_+=2){var m=255*((31744&(l=d[_+0]+(d[_+1]<<8)))>>10)/31|0,v=255*((992&l)>>5)/31|0,y=255*(31&l)/31|0;g[4*(u+f*h)+0]=m,g[4*(u+f*h)+1]=v,g[4*(u+f*h)+2]=y,g[4*(u+f*h)+3]=32768&l?0:255}return g},e._getImageData24bits=function(e,t,i,r,n,o,s,a,c){var l,u,h=i,d=e.width,f=e.height,p=0,_=new Uint8Array(d*f*4);for(u=r;u!==o;u+=n)for(l=s;l!==c;l+=a,p+=3)_[4*(l+d*u)+3]=255,_[4*(l+d*u)+2]=h[p+0],_[4*(l+d*u)+1]=h[p+1],_[4*(l+d*u)+0]=h[p+2];return _},e._getImageData32bits=function(e,t,i,r,n,o,s,a,c){var l,u,h=i,d=e.width,f=e.height,p=0,_=new Uint8Array(d*f*4);for(u=r;u!==o;u+=n)for(l=s;l!==c;l+=a,p+=4)_[4*(l+d*u)+2]=h[p+0],_[4*(l+d*u)+1]=h[p+1],_[4*(l+d*u)+0]=h[p+2],_[4*(l+d*u)+3]=h[p+3];return _},e._getImageDataGrey8bits=function(e,t,i,r,n,o,s,a,c){var l,u,h,d=i,f=e.width,p=e.height,_=0,g=new Uint8Array(f*p*4);for(h=r;h!==o;h+=n)for(u=s;u!==c;u+=a,_++)l=d[_],g[4*(u+f*h)+0]=l,g[4*(u+f*h)+1]=l,g[4*(u+f*h)+2]=l,g[4*(u+f*h)+3]=255;return g},e._getImageDataGrey16bits=function(e,t,i,r,n,o,s,a,c){var l,u,h=i,d=e.width,f=e.height,p=0,_=new Uint8Array(d*f*4);for(u=r;u!==o;u+=n)for(l=s;l!==c;l+=a,p+=2)_[4*(l+d*u)+0]=h[p+0],_[4*(l+d*u)+1]=h[p+0],_[4*(l+d*u)+2]=h[p+0],_[4*(l+d*u)+3]=h[p+1];return _},e._TYPE_INDEXED=1,e._TYPE_RGB=2,e._TYPE_GREY=3,e._TYPE_RLE_INDEXED=9,e._TYPE_RLE_RGB=10,e._TYPE_RLE_GREY=11,e._ORIGIN_MASK=48,e._ORIGIN_SHIFT=4,e._ORIGIN_BL=0,e._ORIGIN_BR=1,e._ORIGIN_UL=2,e._ORIGIN_UR=3,e}(),Uo=function(){function e(){this.supportCascades=!1}return e.prototype.canLoad=function(e,t,i,r,n){return 0===e.indexOf(".tga")},e.prototype.transformUrl=function(e,t){return e},e.prototype.getFallbackTextureUrl=function(e,t){return null},e.prototype.loadCubeData=function(e,t,i,r,n){throw".env not supported in Cube."},e.prototype.loadData=function(e,t,i){var r=new Uint8Array(e),n=Bo.GetTGAHeader(r);i(n.width,n.height,t.generateMipMaps,!1,function(){Bo.UploadContent(t,r)})},e}();_e.b._TextureLoaders.push(new Uo);var Vo=function(e){function t(t,i,r,n,o){var s=this,a=!(!o||!o.generateMipMaps)&&o.generateMipMaps,c=!(!o||!o.generateDepthTexture)&&o.generateDepthTexture,l=!o||void 0===o.doNotChangeAspectRatio||o.doNotChangeAspectRatio;if((s=e.call(this,t,i,n,a,l)||this)._engine=n.getEngine(),s.isSupported){for(var u=[],h=[],d=0;d<r;d++)o&&o.types&&void 0!==o.types[d]?u.push(o.types[d]):u.push(o&&o.defaultType?o.defaultType:_.a.TEXTURETYPE_UNSIGNED_INT),o&&o.samplingModes&&void 0!==o.samplingModes[d]?h.push(o.samplingModes[d]):h.push(Ve.a.BILINEAR_SAMPLINGMODE);var f=!o||void 0===o.generateDepthBuffer||o.generateDepthBuffer,p=!(!o||void 0===o.generateStencilBuffer)&&o.generateStencilBuffer;return s._size=i,s._multiRenderTargetOptions={samplingModes:h,generateMipMaps:a,generateDepthBuffer:f,generateStencilBuffer:p,generateDepthTexture:c,types:u,textureCount:r},s._createInternalTextures(),s._createTextures(),s}s.dispose()}return l.d(t,e),Object.defineProperty(t.prototype,"isSupported",{get:function(){return this._engine.webGLVersion>1||this._engine.getCaps().drawBuffersExtension},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"textures",{get:function(){return this._textures},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"depthTexture",{get:function(){return this._textures[this._textures.length-1]},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"wrapU",{set:function(e){if(this._textures)for(var t=0;t<this._textures.length;t++)this._textures[t].wrapU=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"wrapV",{set:function(e){if(this._textures)for(var t=0;t<this._textures.length;t++)this._textures[t].wrapV=e},enumerable:!0,configurable:!0}),t.prototype._rebuild=function(){this.releaseInternalTextures(),this._createInternalTextures();for(var e=0;e<this._internalTextures.length;e++){this._textures[e]._texture=this._internalTextures[e]}this._texture=this._internalTextures[0]},t.prototype._createInternalTextures=function(){this._internalTextures=this._engine.createMultipleRenderTarget(this._size,this._multiRenderTargetOptions)},t.prototype._createTextures=function(){this._textures=[];for(var e=0;e<this._internalTextures.length;e++){var t=new Ve.a(null,this.getScene());t._texture=this._internalTextures[e],this._textures.push(t)}this._texture=this._internalTextures[0]},Object.defineProperty(t.prototype,"samples",{get:function(){return this._samples},set:function(e){this._samples!==e&&(this._samples=this._engine.updateMultipleRenderTargetTextureSampleCount(this._internalTextures,e))},enumerable:!0,configurable:!0}),t.prototype.resize=function(e){this.releaseInternalTextures(),this._internalTextures=this._engine.createMultipleRenderTarget(e,this._multiRenderTargetOptions),this._createInternalTextures()},t.prototype.unbindFrameBuffer=function(e,t){var i=this;e.unBindMultiColorAttachmentFramebuffer(this._internalTextures,this.isCube,function(){i.onAfterRenderObservable.notifyObservers(t)})},t.prototype.dispose=function(){this.releaseInternalTextures(),e.prototype.dispose.call(this)},t.prototype.releaseInternalTextures=function(){if(this._internalTextures)for(var e=this._internalTextures.length-1;e>=0;e--)void 0!==this._internalTextures[e]&&(this._internalTextures[e].dispose(),this._internalTextures.splice(e,1))},t}(Mi),Go=function(){function e(e){this.name=Te.a.NAME_PROCEDURALTEXTURE,this.scene=e,this.scene.proceduralTextures=new Array,e.layers=new Array}return e.prototype.register=function(){this.scene._beforeClearStage.registerStep(Te.a.STEP_BEFORECLEAR_PROCEDURALTEXTURE,this,this._beforeClear)},e.prototype.rebuild=function(){},e.prototype.dispose=function(){},e.prototype._beforeClear=function(){if(this.scene.proceduralTexturesEnabled){ve.h.StartPerformanceCounter("Procedural textures",this.scene.proceduralTextures.length>0);for(var e=0;e<this.scene.proceduralTextures.length;e++){var t=this.scene.proceduralTextures[e];t._shouldRender()&&t.render()}ve.h.EndPerformanceCounter("Procedural textures",this.scene.proceduralTextures.length>0)}},e}(),ko="\nattribute vec2 position;\n\nvarying vec2 vPosition;\nvarying vec2 vUV;\nconst vec2 madd=vec2(0.5,0.5);\nvoid main(void) {\nvPosition=position;\nvUV=position*madd+madd;\ngl_Position=vec4(position,0.0,1.0);\n}";St.a.ShadersStore.proceduralVertexShader=ko;var zo=function(e){function t(t,i,r,o,s,a,c){void 0===s&&(s=null),void 0===a&&(a=!0),void 0===c&&(c=!1);var l=e.call(this,null,o,!a)||this;l.isCube=c,l.isEnabled=!0,l.autoClear=!0,l.onGeneratedObservable=new n.c,l._textures={},l._currentRefreshId=-1,l._refreshRate=1,l._vertexBuffers={},l._uniforms=new Array,l._samplers=new Array,l._floats={},l._ints={},l._floatsArrays={},l._colors3={},l._colors4={},l._vectors2={},l._vectors3={},l._matrices={},l._fallbackTextureUsed=!1,l._cachedDefines="",l._contentUpdateId=-1;var u=(o=l.getScene())._getComponent(Te.a.NAME_PROCEDURALTEXTURE);u||(u=new Go(o),o._addComponent(u)),o.proceduralTextures.push(l),l._engine=o.getEngine(),l.name=t,l.isRenderTarget=!0,l._size=i,l._generateMipMaps=a,l.setFragment(r),l._fallbackTexture=s,c?(l._texture=l._engine.createRenderTargetCubeTexture(i,{generateMipMaps:a,generateDepthBuffer:!1,generateStencilBuffer:!1}),l.setFloat("face",0)):l._texture=l._engine.createRenderTargetTexture(i,{generateMipMaps:a,generateDepthBuffer:!1,generateStencilBuffer:!1});var h=[];return h.push(1,1),h.push(-1,1),h.push(-1,-1),h.push(1,-1),l._vertexBuffers[gi.b.PositionKind]=new gi.b(l._engine,h,gi.b.PositionKind,!1,!1,2),l._createIndexBuffer(),l}return l.d(t,e),t.prototype.getEffect=function(){return this._effect},t.prototype.getContent=function(){return this._contentData&&this._currentRefreshId==this._contentUpdateId?this._contentData:(this._contentData=this.readPixels(0,0,this._contentData),this._contentUpdateId=this._currentRefreshId,this._contentData)},t.prototype._createIndexBuffer=function(){var e=this._engine,t=[];t.push(0),t.push(1),t.push(2),t.push(0),t.push(2),t.push(3),this._indexBuffer=e.createIndexBuffer(t)},t.prototype._rebuild=function(){var e=this._vertexBuffers[gi.b.PositionKind];e&&e._rebuild(),this._createIndexBuffer(),this.refreshRate===Mi.REFRESHRATE_RENDER_ONCE&&(this.refreshRate=Mi.REFRESHRATE_RENDER_ONCE)},t.prototype.reset=function(){void 0!==this._effect&&this._engine._releaseEffect(this._effect)},t.prototype._getDefines=function(){return""},t.prototype.isReady=function(){var e,t=this,i=this._engine;if(!this._fragment)return!1;if(this._fallbackTextureUsed)return!0;var r=this._getDefines();return!(!this._effect||r!==this._cachedDefines||!this._effect.isReady())||(e=void 0!==this._fragment.fragmentElement?{vertex:"procedural",fragmentElement:this._fragment.fragmentElement}:{vertex:"procedural",fragment:this._fragment},this._cachedDefines=r,this._effect=i.createEffect(e,[gi.b.PositionKind],this._uniforms,this._samplers,r,void 0,void 0,function(){t.releaseInternalTexture(),t._fallbackTexture&&(t._texture=t._fallbackTexture._texture,t._texture&&t._texture.incrementReferences()),t._fallbackTextureUsed=!0}),this._effect.isReady())},t.prototype.resetRefreshCounter=function(){this._currentRefreshId=-1},t.prototype.setFragment=function(e){this._fragment=e},Object.defineProperty(t.prototype,"refreshRate",{get:function(){return this._refreshRate},set:function(e){this._refreshRate=e,this.resetRefreshCounter()},enumerable:!0,configurable:!0}),t.prototype._shouldRender=function(){return this.isEnabled&&this.isReady()&&this._texture?!this._fallbackTextureUsed&&(-1===this._currentRefreshId?(this._currentRefreshId=1,!0):this.refreshRate===this._currentRefreshId?(this._currentRefreshId=1,!0):(this._currentRefreshId++,!1)):(this._texture&&(this._texture.isReady=!1),!1)},t.prototype.getRenderSize=function(){return this._size},t.prototype.resize=function(e,t){this._fallbackTextureUsed||(this.releaseInternalTexture(),this._texture=this._engine.createRenderTargetTexture(e,t),this._size=e,this._generateMipMaps=t)},t.prototype._checkUniform=function(e){-1===this._uniforms.indexOf(e)&&this._uniforms.push(e)},t.prototype.setTexture=function(e,t){return-1===this._samplers.indexOf(e)&&this._samplers.push(e),this._textures[e]=t,this},t.prototype.setFloat=function(e,t){return this._checkUniform(e),this._floats[e]=t,this},t.prototype.setInt=function(e,t){return this._checkUniform(e),this._ints[e]=t,this},t.prototype.setFloats=function(e,t){return this._checkUniform(e),this._floatsArrays[e]=t,this},t.prototype.setColor3=function(e,t){return this._checkUniform(e),this._colors3[e]=t,this},t.prototype.setColor4=function(e,t){return this._checkUniform(e),this._colors4[e]=t,this},t.prototype.setVector2=function(e,t){return this._checkUniform(e),this._vectors2[e]=t,this},t.prototype.setVector3=function(e,t){return this._checkUniform(e),this._vectors3[e]=t,this},t.prototype.setMatrix=function(e,t){return this._checkUniform(e),this._matrices[e]=t,this},t.prototype.render=function(e){var t=this.getScene();if(t){var i=this._engine;for(var r in i.enableEffect(this._effect),i.setState(!1),this._textures)this._effect.setTexture(r,this._textures[r]);for(r in this._ints)this._effect.setInt(r,this._ints[r]);for(r in this._floats)this._effect.setFloat(r,this._floats[r]);for(r in this._floatsArrays)this._effect.setArray(r,this._floatsArrays[r]);for(r in this._colors3)this._effect.setColor3(r,this._colors3[r]);for(r in this._colors4){var n=this._colors4[r];this._effect.setFloat4(r,n.r,n.g,n.b,n.a)}for(r in this._vectors2)this._effect.setVector2(r,this._vectors2[r]);for(r in this._vectors3)this._effect.setVector3(r,this._vectors3[r]);for(r in this._matrices)this._effect.setMatrix(r,this._matrices[r]);if(this._texture){if(this.isCube)for(var o=0;o<6;o++)i.bindFramebuffer(this._texture,o,void 0,void 0,!0),i.bindBuffers(this._vertexBuffers,this._indexBuffer,this._effect),this._effect.setFloat("face",o),this.autoClear&&i.clear(t.clearColor,!0,!1,!1),i.drawElementsType(yn.a.TriangleFillMode,0,6),5===o&&i.generateMipMapsForCubemap(this._texture);else i.bindFramebuffer(this._texture,0,void 0,void 0,!0),i.bindBuffers(this._vertexBuffers,this._indexBuffer,this._effect),this.autoClear&&i.clear(t.clearColor,!0,!1,!1),i.drawElementsType(yn.a.TriangleFillMode,0,6);i.unBindFramebuffer(this._texture,this.isCube),this.onGenerated&&this.onGenerated(),this.onGeneratedObservable.notifyObservers(this)}}},t.prototype.clone=function(){var e=this.getSize(),i=new t(this.name,e.width,this._fragment,this.getScene(),this._fallbackTexture,this._generateMipMaps);return i.hasAlpha=this.hasAlpha,i.level=this.level,i.coordinatesMode=this.coordinatesMode,i},t.prototype.dispose=function(){var t=this.getScene();if(t){var i=t.proceduralTextures.indexOf(this);i>=0&&t.proceduralTextures.splice(i,1);var r=this._vertexBuffers[gi.b.PositionKind];r&&(r.dispose(),this._vertexBuffers[gi.b.PositionKind]=null),this._indexBuffer&&this._engine._releaseBuffer(this._indexBuffer)&&(this._indexBuffer=null),e.prototype.dispose.call(this)}},l.c([Object(w.c)()],t.prototype,"isEnabled",void 0),l.c([Object(w.c)()],t.prototype,"autoClear",void 0),l.c([Object(w.c)()],t.prototype,"_generateMipMaps",void 0),l.c([Object(w.c)()],t.prototype,"_size",void 0),l.c([Object(w.c)()],t.prototype,"refreshRate",null),t}(Ve.a),jo=function(e){function t(t,i,r,n,o,s){var a=e.call(this,t,r,null,n,o,s)||this;return a._animate=!0,a._time=0,a._texturePath=i,a._loadJson(i),a.refreshRate=1,a}return l.d(t,e),t.prototype._loadJson=function(e){var t=this,i=function(){p.a.Log("No config file found in "+e+" trying to use ShadersStore or DOM element");try{t.setFragment(t._texturePath)}catch(e){p.a.Error("No json or ShaderStore or DOM element found for CustomProceduralTexture")}},r=e+"/config.json",n=new XMLHttpRequest;n.open("GET",r,!0),n.addEventListener("load",function(){if(200===n.status||n.responseText&&n.responseText.length>0)try{t._config=JSON.parse(n.response),t.updateShaderUniforms(),t.updateTextures(),t.setFragment(t._texturePath+"/custom"),t._animate=t._config.animate,t.refreshRate=t._config.refreshrate}catch(e){i()}else i()},!1),n.addEventListener("error",function(){i()},!1);try{ve.h.UseCustomRequestHeaders&&ve.h.InjectCustomRequestHeaders(n),n.send()}catch(e){p.a.Error("CustomProceduralTexture: Error on XHR send request.")}},t.prototype.isReady=function(){if(!e.prototype.isReady.call(this))return!1;for(var t in this._textures){if(!this._textures[t].isReady())return!1}return!0},t.prototype.render=function(t){var i=this.getScene();this._animate&&i&&(this._time+=.03*i.getAnimationRatio(),this.updateShaderUniforms()),e.prototype.render.call(this,t)},t.prototype.updateTextures=function(){for(var e=0;e<this._config.sampler2Ds.length;e++)this.setTexture(this._config.sampler2Ds[e].sample2Dname,new Ve.a(this._texturePath+"/"+this._config.sampler2Ds[e].textureRelativeUrl,this.getScene()))},t.prototype.updateShaderUniforms=function(){if(this._config)for(var e=0;e<this._config.uniforms.length;e++){var t=this._config.uniforms[e];switch(t.type){case"float":this.setFloat(t.name,t.value);break;case"color3":this.setColor3(t.name,new o.e(t.r,t.g,t.b));break;case"color4":this.setColor4(t.name,new o.f(t.r,t.g,t.b,t.a));break;case"vector2":this.setVector2(t.name,new o.w(t.x,t.y));break;case"vector3":this.setVector3(t.name,new o.x(t.x,t.y,t.z))}}this.setFloat("time",this._time)},Object.defineProperty(t.prototype,"animate",{get:function(){return this._animate},set:function(e){this._animate=e},enumerable:!0,configurable:!0}),t}(zo),Wo="\n\nuniform float brightness;\nuniform float persistence;\nuniform float timeScale;\n\nvarying vec2 vUV;\n\nvec2 hash22(vec2 p)\n{\np=p*mat2(127.1,311.7,269.5,183.3);\np=-1.0+2.0*fract(sin(p)*43758.5453123);\nreturn sin(p*6.283+timeScale);\n}\nfloat interpolationNoise(vec2 p)\n{\nvec2 pi=floor(p);\nvec2 pf=p-pi;\nvec2 w=pf*pf*(3.-2.*pf);\nfloat f00=dot(hash22(pi+vec2(.0,.0)),pf-vec2(.0,.0));\nfloat f01=dot(hash22(pi+vec2(.0,1.)),pf-vec2(.0,1.));\nfloat f10=dot(hash22(pi+vec2(1.0,0.)),pf-vec2(1.0,0.));\nfloat f11=dot(hash22(pi+vec2(1.0,1.)),pf-vec2(1.0,1.));\nfloat xm1=mix(f00,f10,w.x);\nfloat xm2=mix(f01,f11,w.x);\nfloat ym=mix(xm1,xm2,w.y);\nreturn ym;\n}\nfloat perlinNoise2D(float x,float y)\n{\nfloat sum=0.0;\nfloat frequency=0.0;\nfloat amplitude=0.0;\nfor(int i=0; i<OCTAVES; i++)\n{\nfrequency=pow(2.0,float(i));\namplitude=pow(persistence,float(i));\nsum=sum+interpolationNoise(vec2(x*frequency,y*frequency))*amplitude;\n}\nreturn sum;\n}\n\nvoid main(void)\n{\nfloat x=abs(vUV.x);\nfloat y=abs(vUV.y);\nfloat noise=brightness+(1.0-brightness)*perlinNoise2D(x,y);\ngl_FragColor=vec4(noise,noise,noise,1.0);\n}\n";St.a.ShadersStore.noisePixelShader=Wo;var Ho=function(e){function t(t,i,r,n,o){void 0===i&&(i=256),void 0===r&&(r=R.a.LastCreatedScene);var s=e.call(this,t,i,"noise",r,n,o)||this;return s._time=0,s.brightness=.2,s.octaves=3,s.persistence=.8,s.animationSpeedFactor=1,s.autoClear=!1,s._updateShaderUniforms(),s}return l.d(t,e),t.prototype._updateShaderUniforms=function(){var e=this.getScene();e&&(this._time+=e.getAnimationRatio()*this.animationSpeedFactor*.01,this.setFloat("brightness",this.brightness),this.setFloat("persistence",this.persistence),this.setFloat("timeScale",this._time))},t.prototype._getDefines=function(){return"#define OCTAVES "+(0|this.octaves)},t.prototype.render=function(t){this._updateShaderUniforms(),e.prototype.render.call(this,t)},t.prototype.serialize=function(){var e={customType:"BABYLON.NoiseProceduralTexture"};return e.brightness=this.brightness,e.octaves=this.octaves,e.persistence=this.persistence,e.animationSpeedFactor=this.animationSpeedFactor,e.size=this.getSize().width,e.generateMipMaps=this._generateMipMaps,e},t.Parse=function(e,i){var r=new t(e.name,e.size,i,void 0,e.generateMipMaps);return r.brightness=e.brightness,r.octaves=e.octaves,r.persistence=e.persistence,r.animationSpeedFactor=e.animationSpeedFactor,r},t}(zo);s.a.RegisteredTypes["BABYLON.NoiseProceduralTexture"]=Ho;var Xo=function(e){function t(t,i,r,n,o,s,a,c,l){void 0===n&&(n=_.a.TEXTUREFORMAT_RGBA),void 0===o&&(o=_.a.TEXTURETYPE_UNSIGNED_INT),void 0===s&&(s=!1),void 0===a&&(a=!1),void 0===c&&(c=_.a.TEXTURE_TRILINEAR_SAMPLINGMODE),void 0===l&&(l=null);var u=e.call(this,"",t)||this;return u._texture=t.getEngine().createRawCubeTexture(i,r,n,o,s,a,c,l),u}return l.d(t,e),t.prototype.update=function(e,t,i,r,n){void 0===n&&(n=null),this._texture.getEngine().updateRawCubeTexture(this._texture,e,t,i,r,n)},t.prototype.updateRGBDAsync=function(e,i,r,n){return void 0===i&&(i=null),void 0===r&&(r=.8),void 0===n&&(n=0),t._UpdateRGBDAsync(this._texture,e,i,r,n)},t.prototype.clone=function(){var e=this;return w.a.Clone(function(){var i=e.getScene(),r=e._texture,n=new t(i,r._bufferViewArray,r.width,r.format,r.type,r.generateMipMaps,r.invertY,r.samplingMode,r._compression);return r.dataSource===Ri.a.DATASOURCE_CUBERAW_RGBD&&n.updateRGBDAsync(r._bufferViewArrayArray,r._sphericalPolynomial,r._lodGenerationScale,r._lodGenerationOffset),n},this)},t._UpdateRGBDAsync=function(e,t,i,r,n){return e._dataSource=Ri.a.DATASOURCE_CUBERAW_RGBD,e._bufferViewArrayArray=t,e._lodGenerationScale=r,e._lodGenerationOffset=n,e._sphericalPolynomial=i,wo.UploadLevelsAsync(e,t).then(function(){e.isReady=!0})},t}(Gr),Yo=function(e){function t(t,i,r,n,o,s,a,c,l,u){void 0===a&&(a=!0),void 0===c&&(c=!1),void 0===l&&(l=Ve.a.TRILINEAR_SAMPLINGMODE),void 0===u&&(u=_.a.TEXTURETYPE_UNSIGNED_INT);var h=e.call(this,null,s,!a,c)||this;return h.format=o,h._engine=s.getEngine(),h._texture=s.getEngine().createRawTexture3D(t,i,r,n,o,a,c,l,void 0,u),h.is3D=!0,h}return l.d(t,e),t.prototype.update=function(e){this._texture&&this._engine.updateRawTexture3D(this._texture,e,this._texture.format,this._texture.invertY,void 0,this._texture.type)},t}(Ve.a),Ko=function(e){function t(t,i,r,n){var s=e.call(this,t,i,r,n,!0)||this;return s.refractionPlane=new o.n(0,1,0,1),s.depth=2,s.onBeforeRenderObservable.add(function(){r.clipPlane=s.refractionPlane}),s.onAfterRenderObservable.add(function(){delete r.clipPlane}),s}return l.d(t,e),t.prototype.clone=function(){var e=this.getScene();if(!e)return this;var i=this.getSize(),r=new t(this.name,i.width,e,this._generateMipMaps);return r.hasAlpha=this.hasAlpha,r.level=this.level,r.refractionPlane=this.refractionPlane.clone(),this.renderList&&(r.renderList=this.renderList.slice(0)),r.depth=this.depth,r},t.prototype.serialize=function(){if(!this.name)return null;var t=e.prototype.serialize.call(this);return t.mirrorPlane=this.refractionPlane.asArray(),t.depth=this.depth,t},t}(Mi),Qo=i(66),qo=function(){function e(){}return Object.defineProperty(e,"DecoderAvailable",{get:function(){if("undefined"!=typeof DracoDecoderModule)return!0;var t=e.Configuration.decoder;if(t){if(t.wasmUrl&&t.wasmBinaryUrl&&"object"==typeof WebAssembly)return!0;if(t.fallbackUrl)return!0}return!1},enumerable:!0,configurable:!0}),e.prototype.dispose=function(){},e.prototype.decodeMeshAsync=function(t,i){var r=t instanceof ArrayBuffer?new Uint8Array(t):t;return e._GetDecoderModule().then(function(e){var t=e.module,n=new _i.a,o=new t.DecoderBuffer;o.Init(r,r.byteLength);var s,a,c=new t.Decoder;try{var l=c.GetEncodedGeometryType(o);switch(l){case t.TRIANGULAR_MESH:s=new t.Mesh,a=c.DecodeBufferToMesh(o,s);break;case t.POINT_CLOUD:s=new t.PointCloud,a=c.DecodeBufferToPointCloud(o,s);break;default:throw new Error("Invalid geometry type "+l)}if(!a.ok()||!s.ptr)throw new Error(a.error_msg());var u=s.num_points();if(l===t.TRIANGULAR_MESH){var h=s.num_faces(),d=new t.DracoInt32Array;try{for(var f=new Uint32Array(3*h),p=0;p<h;p++){c.GetFaceFromMesh(s,p,d);var _=3*p;f[_+0]=d.GetValue(0),f[_+1]=d.GetValue(1),f[_+2]=d.GetValue(2)}n.indices=f}finally{t.destroy(d)}}for(var g in i){var m=i[g],v=c.GetAttributeByUniqueId(s,m),y=new t.DracoFloat32Array;try{c.GetAttributeFloatForAllPoints(s,v,y);var b=new Float32Array(u*v.num_components());for(p=0;p<b.length;p++)b[p]=y.GetValue(p);n.set(b,g)}finally{t.destroy(y)}}}finally{s&&t.destroy(s),t.destroy(c),t.destroy(o)}return n})},e._GetDecoderModule=function(){if(!e._DecoderModulePromise){var t=null,i={};if("undefined"!=typeof DracoDecoderModule)t=Promise.resolve();else{var r=e.Configuration.decoder;r&&(r.wasmUrl&&r.wasmBinaryUrl&&"object"==typeof WebAssembly?t=Promise.all([e._LoadScriptAsync(r.wasmUrl),e._LoadFileAsync(r.wasmBinaryUrl).then(function(e){i.wasmBinary=e})]):r.fallbackUrl&&(t=e._LoadScriptAsync(r.fallbackUrl)))}if(!t)throw new Error("Draco decoder module is not available");e._DecoderModulePromise=t.then(function(){return new Promise(function(e){i.onModuleLoaded=function(t){e({module:t})},DracoDecoderModule(i)})})}return e._DecoderModulePromise},e._LoadScriptAsync=function(e){return new Promise(function(t,i){ve.h.LoadScript(e,function(){t()},function(e){i(new Error(e))})})},e._LoadFileAsync=function(e){return new Promise(function(t,i){ve.h.LoadFile(e,function(e){t(e)},void 0,void 0,!0,function(e,t){i(t)})})},e.Configuration={decoder:{wasmUrl:"https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js",wasmBinaryUrl:"https://preview.babylonjs.com/draco_decoder_gltf.wasm",fallbackUrl:"https://preview.babylonjs.com/draco_decoder_gltf.js"}},e}(),Zo=i(45),Jo=0,$o=function(){function e(e,t,i){this.pos=e,this.normal=t,this.uv=i}return e.prototype.clone=function(){return new e(this.pos.clone(),this.normal.clone(),this.uv.clone())},e.prototype.flip=function(){this.normal=this.normal.scale(-1)},e.prototype.interpolate=function(t,i){return new e(o.x.Lerp(this.pos,t.pos,i),o.x.Lerp(this.normal,t.normal,i),o.w.Lerp(this.uv,t.uv,i))},e}(),es=function(){function e(e,t){this.normal=e,this.w=t}return e.FromPoints=function(t,i,r){var n=r.subtract(t),s=i.subtract(t);if(0===n.lengthSquared()||0===s.lengthSquared())return null;var a=o.x.Normalize(o.x.Cross(n,s));return new e(a,o.x.Dot(a,t))},e.prototype.clone=function(){return new e(this.normal.clone(),this.w)},e.prototype.flip=function(){this.normal.scaleInPlace(-1),this.w=-this.w},e.prototype.splitPolygon=function(t,i,r,n,s){var a,c,l=0,u=[];for(a=0;a<t.vertices.length;a++){var h=(c=o.x.Dot(this.normal,t.vertices[a].pos)-this.w)<-e.EPSILON?2:c>e.EPSILON?1:0;l|=h,u.push(h)}switch(l){case 0:(o.x.Dot(this.normal,t.plane.normal)>0?i:r).push(t);break;case 1:n.push(t);break;case 2:s.push(t);break;case 3:var d,f=[],p=[];for(a=0;a<t.vertices.length;a++){var _=(a+1)%t.vertices.length,g=u[a],m=u[_],v=t.vertices[a],y=t.vertices[_];if(2!==g&&f.push(v),1!==g&&p.push(2!==g?v.clone():v),3==(g|m)){c=(this.w-o.x.Dot(this.normal,v.pos))/o.x.Dot(this.normal,y.pos.subtract(v.pos));var b=v.interpolate(y,c);f.push(b),p.push(b.clone())}}f.length>=3&&(d=new ts(f,t.shared)).plane&&n.push(d),p.length>=3&&(d=new ts(p,t.shared)).plane&&s.push(d)}},e.EPSILON=1e-5,e}(),ts=function(){function e(e,t){this.vertices=e,this.shared=t,this.plane=es.FromPoints(e[0].pos,e[1].pos,e[2].pos)}return e.prototype.clone=function(){return new e(this.vertices.map(function(e){return e.clone()}),this.shared)},e.prototype.flip=function(){this.vertices.reverse().map(function(e){e.flip()}),this.plane.flip()},e}(),is=function(){function e(e){this.plane=null,this.front=null,this.back=null,this.polygons=new Array,e&&this.build(e)}return e.prototype.clone=function(){var t=new e;return t.plane=this.plane&&this.plane.clone(),t.front=this.front&&this.front.clone(),t.back=this.back&&this.back.clone(),t.polygons=this.polygons.map(function(e){return e.clone()}),t},e.prototype.invert=function(){for(var e=0;e<this.polygons.length;e++)this.polygons[e].flip();this.plane&&this.plane.flip(),this.front&&this.front.invert(),this.back&&this.back.invert();var t=this.front;this.front=this.back,this.back=t},e.prototype.clipPolygons=function(e){if(!this.plane)return e.slice();for(var t=new Array,i=new Array,r=0;r<e.length;r++)this.plane.splitPolygon(e[r],t,i,t,i);return this.front&&(t=this.front.clipPolygons(t)),i=this.back?this.back.clipPolygons(i):[],t.concat(i)},e.prototype.clipTo=function(e){this.polygons=e.clipPolygons(this.polygons),this.front&&this.front.clipTo(e),this.back&&this.back.clipTo(e)},e.prototype.allPolygons=function(){var e=this.polygons.slice();return this.front&&(e=e.concat(this.front.allPolygons())),this.back&&(e=e.concat(this.back.allPolygons())),e},e.prototype.build=function(t){if(t.length){this.plane||(this.plane=t[0].plane.clone());for(var i=new Array,r=new Array,n=0;n<t.length;n++)this.plane.splitPolygon(t[n],this.polygons,this.polygons,i,r);i.length&&(this.front||(this.front=new e),this.front.build(i)),r.length&&(this.back||(this.back=new e),this.back.build(r))}},e}(),rs=function(){function e(){this.polygons=new Array}return e.FromMesh=function(t){var i,r,n,s,a,c,l,u,h,d,f=new Array,p=null;if(!(t instanceof de.a))throw"BABYLON.CSG: Wrong Mesh type, must be BABYLON.Mesh";t.computeWorldMatrix(!0),l=t.getWorldMatrix(),u=t.position.clone(),h=t.rotation.clone(),t.rotationQuaternion&&(p=t.rotationQuaternion.clone()),d=t.scaling.clone();for(var _=t.getIndices(),g=t.getVerticesData(gi.b.PositionKind),m=t.getVerticesData(gi.b.NormalKind),v=t.getVerticesData(gi.b.UVKind),y=t.subMeshes,b=0,T=y.length;b<T;b++)for(var E=y[b].indexStart,x=y[b].indexCount+y[b].indexStart;E<x;E+=3){c=[];for(var A=0;A<3;A++){var P=new o.x(m[3*_[E+A]],m[3*_[E+A]+1],m[3*_[E+A]+2]);n=new o.w(v[2*_[E+A]],v[2*_[E+A]+1]);var R=new o.x(g[3*_[E+A]],g[3*_[E+A]+1],g[3*_[E+A]+2]);s=o.x.TransformCoordinates(R,l),r=o.x.TransformNormal(P,l),i=new $o(s,r,n),c.push(i)}(a=new ts(c,{subMeshId:b,meshId:Jo,materialIndex:y[b].materialIndex})).plane&&f.push(a)}var S=e.FromPolygons(f);return S.matrix=l,S.position=u,S.rotation=h,S.scaling=d,S.rotationQuaternion=p,Jo++,S},e.FromPolygons=function(t){var i=new e;return i.polygons=t,i},e.prototype.clone=function(){var t=new e;return t.polygons=this.polygons.map(function(e){return e.clone()}),t.copyTransformAttributes(this),t},e.prototype.union=function(t){var i=new is(this.clone().polygons),r=new is(t.clone().polygons);return i.clipTo(r),r.clipTo(i),r.invert(),r.clipTo(i),r.invert(),i.build(r.allPolygons()),e.FromPolygons(i.allPolygons()).copyTransformAttributes(this)},e.prototype.unionInPlace=function(e){var t=new is(this.polygons),i=new is(e.polygons);t.clipTo(i),i.clipTo(t),i.invert(),i.clipTo(t),i.invert(),t.build(i.allPolygons()),this.polygons=t.allPolygons()},e.prototype.subtract=function(t){var i=new is(this.clone().polygons),r=new is(t.clone().polygons);return i.invert(),i.clipTo(r),r.clipTo(i),r.invert(),r.clipTo(i),r.invert(),i.build(r.allPolygons()),i.invert(),e.FromPolygons(i.allPolygons()).copyTransformAttributes(this)},e.prototype.subtractInPlace=function(e){var t=new is(this.polygons),i=new is(e.polygons);t.invert(),t.clipTo(i),i.clipTo(t),i.invert(),i.clipTo(t),i.invert(),t.build(i.allPolygons()),t.invert(),this.polygons=t.allPolygons()},e.prototype.intersect=function(t){var i=new is(this.clone().polygons),r=new is(t.clone().polygons);return i.invert(),r.clipTo(i),r.invert(),i.clipTo(r),r.clipTo(i),i.build(r.allPolygons()),i.invert(),e.FromPolygons(i.allPolygons()).copyTransformAttributes(this)},e.prototype.intersectInPlace=function(e){var t=new is(this.polygons),i=new is(e.polygons);t.invert(),i.clipTo(t),i.invert(),t.clipTo(i),i.clipTo(t),t.build(i.allPolygons()),t.invert(),this.polygons=t.allPolygons()},e.prototype.inverse=function(){var e=this.clone();return e.inverseInPlace(),e},e.prototype.inverseInPlace=function(){this.polygons.map(function(e){e.flip()})},e.prototype.copyTransformAttributes=function(e){return this.matrix=e.matrix,this.position=e.position,this.rotation=e.rotation,this.scaling=e.scaling,this.rotationQuaternion=e.rotationQuaternion,this},e.prototype.buildMeshGeometry=function(e,t,i){var r=this.matrix.clone();r.invert();var n,s,a,c=new de.a(e,t),l=[],u=[],h=[],d=[],f=o.x.Zero(),p=o.x.Zero(),_=o.w.Zero(),g=this.polygons,m=[0,0,0],v={},y=0,b={};i&&g.sort(function(e,t){return e.shared.meshId===t.shared.meshId?e.shared.subMeshId-t.shared.subMeshId:e.shared.meshId-t.shared.meshId});for(var T=0,E=g.length;T<E;T++){b[(n=g[T]).shared.meshId]||(b[n.shared.meshId]={}),b[n.shared.meshId][n.shared.subMeshId]||(b[n.shared.meshId][n.shared.subMeshId]={indexStart:1/0,indexEnd:-1/0,materialIndex:n.shared.materialIndex}),a=b[n.shared.meshId][n.shared.subMeshId];for(var x=2,A=n.vertices.length;x<A;x++){m[0]=0,m[1]=x-1,m[2]=x;for(var P=0;P<3;P++){f.copyFrom(n.vertices[m[P]].pos),p.copyFrom(n.vertices[m[P]].normal),_.copyFrom(n.vertices[m[P]].uv);var R=o.x.TransformCoordinates(f,r),S=o.x.TransformNormal(p,r);void 0!==(s=v[R.x+","+R.y+","+R.z])&&h[3*s]===S.x&&h[3*s+1]===S.y&&h[3*s+2]===S.z&&d[2*s]===_.x&&d[2*s+1]===_.y||(l.push(R.x,R.y,R.z),d.push(_.x,_.y),h.push(p.x,p.y,p.z),s=v[R.x+","+R.y+","+R.z]=l.length/3-1),u.push(s),a.indexStart=Math.min(y,a.indexStart),a.indexEnd=Math.max(y,a.indexEnd),y++}}}if(c.setVerticesData(gi.b.PositionKind,l),c.setVerticesData(gi.b.NormalKind,h),c.setVerticesData(gi.b.UVKind,d),c.setIndices(u,null),i){var C,M=0;for(var O in c.subMeshes=new Array,b){for(var I in C=-1,b[O])a=b[O][I],Zo.b.CreateFromIndices(a.materialIndex+M,a.indexStart,a.indexEnd-a.indexStart+1,c),C=Math.max(a.materialIndex,C);M+=++C}}return c},e.prototype.toMesh=function(e,t,i,r){var n=this.buildMeshGeometry(e,i,r);return n.material=t,n.position.copyFrom(this.position),n.rotation.copyFrom(this.rotation),this.rotationQuaternion&&(n.rotationQuaternion=this.rotationQuaternion.clone()),n.scaling.copyFrom(this.scaling),n.computeWorldMatrix(!0),n},e}(),ns=i(103),os=i(68);_i.a.CreateRibbon=function(e){var t=e.pathArray,i=e.closeArray||!1,r=e.closePath||!1,n=e.invertUV||!1,o=Math.floor(t[0].length/2),s=e.offset||o;s=s>o?o:Math.floor(s);var a,c,l,u,h=0===e.sideOrientation?0:e.sideOrientation||_i.a.DEFAULTSIDE,d=e.uvs,f=e.colors,p=[],_=[],g=[],m=[],v=[],y=[],b=[],T=[],E=[],x=[];if(t.length<2){var A=[],P=[];for(l=0;l<t[0].length-s;l++)A.push(t[0][l]),P.push(t[0][l+s]);t=[A,P]}var R,S,C,M,O,I=0,D=r?1:0;for(a=t[0].length,c=0;c<t.length;c++){for(b[c]=0,v[c]=[0],a=a<(S=(R=t[c]).length)?a:S,u=0;u<S;)p.push(R[u].x,R[u].y,R[u].z),u>0&&(C=R[u].subtract(R[u-1]).length()+b[c],v[c].push(C),b[c]=C),u++;r&&(u--,p.push(R[0].x,R[0].y,R[0].z),C=R[u].subtract(R[0]).length()+b[c],v[c].push(C),b[c]=C),E[c]=S+D,x[c]=I,I+=S+D}var w,L,F=null,N=null;for(l=0;l<a+D;l++){for(T[l]=0,y[l]=[0],c=0;c<t.length-1;c++)M=t[c],O=t[c+1],l===a?(F=M[0],N=O[0]):(F=M[l],N=O[l]),C=N.subtract(F).length()+T[l],y[l].push(C),T[l]=C;i&&N&&F&&(M=t[c],O=t[0],l===a&&(N=O[0]),C=N.subtract(F).length()+T[l],T[l]=C)}if(d)for(c=0;c<d.length;c++)m.push(d[c].x,d[c].y);else for(c=0;c<t.length;c++)for(l=0;l<a+D;l++)w=0!=b[c]?v[c][l]/b[c]:0,L=0!=T[l]?y[l][c]/T[l]:0,n?m.push(L,w):m.push(w,L);for(var B=0,U=E[c=0]-1,V=E[c+1]-1,G=U<V?U:V,k=x[1]-x[0],z=i?E.length:E.length-1;B<=G&&c<z;)_.push(B,B+k,B+1),_.push(B+k+1,B+1,B+k),(B+=1)===G&&(++c===E.length-1?(k=x[0]-x[c],U=E[c]-1,V=E[0]-1):(k=x[c+1]-x[c],U=E[c]-1,V=E[c+1]-1),B=x[c],G=U<V?U+B:V+B);if(_i.a.ComputeNormals(p,_,g),r){var j=0,W=0;for(c=0;c<t.length;c++)j=3*x[c],W=c+1<t.length?3*(x[c+1]-1):g.length-3,g[j]=.5*(g[j]+g[W]),g[j+1]=.5*(g[j+1]+g[W+1]),g[j+2]=.5*(g[j+2]+g[W+2]),g[W]=g[j],g[W+1]=g[j+1],g[W+2]=g[j+2]}_i.a._ComputeSides(h,p,_,g,m,e.frontUVs,e.backUVs);var H=null;if(f){H=new Float32Array(4*f.length);for(var X=0;X<f.length;X++)H[4*X]=f[X].r,H[4*X+1]=f[X].g,H[4*X+2]=f[X].b,H[4*X+3]=f[X].a}var Y=new _i.a,K=new Float32Array(p),Q=new Float32Array(g),q=new Float32Array(m);return Y.indices=_,Y.positions=K,Y.normals=Q,Y.uvs=q,H&&Y.set(H,gi.b.ColorKind),r&&(Y._idx=x),Y},de.a.CreateRibbon=function(e,t,i,r,n,o,s,a,c){return void 0===i&&(i=!1),void 0===s&&(s=!1),ss.CreateRibbon(e,{pathArray:t,closeArray:i,closePath:r,offset:n,updatable:s,sideOrientation:a,instance:c},o)};var ss=function(){function e(){}return e.CreateRibbon=function(e,t,i){void 0===i&&(i=null);var r=t.pathArray,n=t.closeArray,s=t.closePath,a=de.a._GetDefaultSideOrientation(t.sideOrientation),c=t.instance,l=t.updatable;if(c){var u=o.t.Vector3[0].setAll(Number.MAX_VALUE),h=o.t.Vector3[1].setAll(-Number.MAX_VALUE),d=c.getVerticesData(gi.b.PositionKind);if(function(e){for(var t=r[0].length,i=c,n=0,o=i._originalBuilderSideOrientation===de.a.DOUBLESIDE?2:1,s=1;s<=o;++s)for(var a=0;a<r.length;++a){var l=r[a],d=l.length;t=t<d?t:d;for(var f=0;f<t;++f){var p=l[f];e[n]=p.x,e[n+1]=p.y,e[n+2]=p.z,u.minimizeInPlaceFromFloats(p.x,p.y,p.z),h.maximizeInPlaceFromFloats(p.x,p.y,p.z),n+=3}i._creationDataStorage&&i._creationDataStorage.closePath&&(p=l[0],e[n]=p.x,e[n+1]=p.y,e[n+2]=p.z,n+=3)}}(d),c._boundingInfo?c._boundingInfo.reConstruct(u,h,c._worldMatrix):c._boundingInfo=new Xi.a(u,h,c._worldMatrix),c.updateVerticesData(gi.b.PositionKind,d,!1,!1),t.colors){for(var f=c.getVerticesData(gi.b.ColorKind),p=0,_=0;p<t.colors.length;p++,_+=4){var g=t.colors[p];f[_]=g.r,f[_+1]=g.g,f[_+2]=g.b,f[_+3]=g.a}c.updateVerticesData(gi.b.ColorKind,f,!1,!1)}if(t.uvs){for(var m=c.getVerticesData(gi.b.UVKind),v=0;v<t.uvs.length;v++)m[2*v]=t.uvs[v].x,m[2*v+1]=t.uvs[v].y;c.updateVerticesData(gi.b.UVKind,m,!1,!1)}if(!c.areNormalsFrozen||c.isFacetDataEnabled){var y=c.getIndices(),b=c.getVerticesData(gi.b.NormalKind),T=c.isFacetDataEnabled?c.getFacetDataParameters():null;if(_i.a.ComputeNormals(d,y,b,T),c._creationDataStorage&&c._creationDataStorage.closePath)for(var E=0,x=0,A=0;A<r.length;A++)E=3*c._creationDataStorage.idx[A],x=A+1<r.length?3*(c._creationDataStorage.idx[A+1]-1):b.length-3,b[E]=.5*(b[E]+b[x]),b[E+1]=.5*(b[E+1]+b[x+1]),b[E+2]=.5*(b[E+2]+b[x+2]),b[x]=b[E],b[x+1]=b[E+1],b[x+2]=b[E+2];c.areNormalsFrozen||c.updateVerticesData(gi.b.NormalKind,b,!1,!1)}return c}var P=new de.a(e,i);P._originalBuilderSideOrientation=a,P._creationDataStorage=new de.c;var R=_i.a.CreateRibbon(t);return s&&(P._creationDataStorage.idx=R._idx),P._creationDataStorage.closePath=s,P._creationDataStorage.closeArray=n,R.applyToMesh(P,l),P},e}();_i.a.CreateDisc=function(e){var t=new Array,i=new Array,r=new Array,n=new Array,o=e.radius||.5,s=e.tessellation||64,a=e.arc&&(e.arc<=0||e.arc>1)?1:e.arc||1,c=0===e.sideOrientation?0:e.sideOrientation||_i.a.DEFAULTSIDE;t.push(0,0,0),n.push(.5,.5);for(var l=2*Math.PI*a,u=l/s,h=0;h<l;h+=u){var d=Math.cos(h),f=Math.sin(h),p=(d+1)/2,_=(1-f)/2;t.push(o*d,o*f,0),n.push(p,_)}1===a&&(t.push(t[3],t[4],t[5]),n.push(n[2],n[3]));for(var g=t.length/3,m=1;m<g-1;m++)i.push(m+1,0,m);_i.a.ComputeNormals(t,i,r),_i.a._ComputeSides(c,t,i,r,n,e.frontUVs,e.backUVs);var v=new _i.a;return v.indices=i,v.positions=t,v.normals=r,v.uvs=n,v},de.a.CreateDisc=function(e,t,i,r,n,o){void 0===r&&(r=null);var s={radius:t,tessellation:i,sideOrientation:o,updatable:n};return as.CreateDisc(e,s,r)};var as=function(){function e(){}return e.CreateDisc=function(e,t,i){void 0===i&&(i=null);var r=new de.a(e,i);return t.sideOrientation=de.a._GetDefaultSideOrientation(t.sideOrientation),r._originalBuilderSideOrientation=t.sideOrientation,_i.a.CreateDisc(t).applyToMesh(r,t.updatable),r},e}();_i.a.CreateTorusKnot=function(e){var t,i,r=new Array,n=new Array,s=new Array,a=new Array,c=e.radius||2,l=e.tube||.5,u=e.radialSegments||32,h=e.tubularSegments||32,d=e.p||2,f=e.q||3,p=0===e.sideOrientation?0:e.sideOrientation||_i.a.DEFAULTSIDE,_=function(e){var t=Math.cos(e),i=Math.sin(e),r=f/d*e,n=Math.cos(r),s=c*(2+n)*.5*t,a=c*(2+n)*i*.5,l=c*Math.sin(r)*.5;return new o.x(s,a,l)};for(t=0;t<=u;t++){var g=t%u/u*2*d*Math.PI,m=_(g),v=_(g+.01),y=v.subtract(m),b=v.add(m),T=o.x.Cross(y,b);for(b=o.x.Cross(T,y),T.normalize(),b.normalize(),i=0;i<h;i++){var E=i%h/h*2*Math.PI,x=-l*Math.cos(E),A=l*Math.sin(E);n.push(m.x+x*b.x+A*T.x),n.push(m.y+x*b.y+A*T.y),n.push(m.z+x*b.z+A*T.z),a.push(t/u),a.push(i/h)}}for(t=0;t<u;t++)for(i=0;i<h;i++){var P=(i+1)%h,R=t*h+i,S=(t+1)*h+i,C=(t+1)*h+P,M=t*h+P;r.push(M),r.push(S),r.push(R),r.push(M),r.push(C),r.push(S)}_i.a.ComputeNormals(n,r,s),_i.a._ComputeSides(p,n,r,s,a,e.frontUVs,e.backUVs);var O=new _i.a;return O.indices=r,O.positions=n,O.normals=s,O.uvs=a,O},de.a.CreateTorusKnot=function(e,t,i,r,n,o,s,a,c,l){var u={radius:t,tube:i,radialSegments:r,tubularSegments:n,p:o,q:s,sideOrientation:l,updatable:c};return cs.CreateTorusKnot(e,u,a)};var cs=function(){function e(){}return e.CreateTorusKnot=function(e,t,i){var r=new de.a(e,i);return t.sideOrientation=de.a._GetDefaultSideOrientation(t.sideOrientation),r._originalBuilderSideOrientation=t.sideOrientation,_i.a.CreateTorusKnot(t).applyToMesh(r,t.updatable),r},e}(),ls=function(e){function t(t,i){var r=e.call(this,t.x,t.y)||this;return r.index=i,r}return l.d(t,e),t}(o.w),us=function(){function e(){this.elements=new Array}return e.prototype.add=function(e){var t=this,i=new Array;return e.forEach(function(e){if(0===i.length||!e.equalsWithEpsilon(i[0])){var r=new ls(e,t.elements.length);i.push(r),t.elements.push(r)}}),i},e.prototype.computeBounds=function(){var e=new o.w(this.elements[0].x,this.elements[0].y),t=new o.w(this.elements[0].x,this.elements[0].y);return this.elements.forEach(function(i){i.x<e.x?e.x=i.x:i.x>t.x&&(t.x=i.x),i.y<e.y?e.y=i.y:i.y>t.y&&(t.y=i.y)}),{min:e,max:t,width:t.x-e.x,height:t.y-e.y}},e}(),hs=function(){function e(){}return e.Rectangle=function(e,t,i,r){return[new o.w(e,t),new o.w(i,t),new o.w(i,r),new o.w(e,r)]},e.Circle=function(e,t,i,r){void 0===t&&(t=0),void 0===i&&(i=0),void 0===r&&(r=32);for(var n=new Array,s=0,a=2*Math.PI/r,c=0;c<r;c++)n.push(new o.w(t+Math.cos(s)*e,i+Math.sin(s)*e)),s-=a;return n},e.Parse=function(e){var t,i=e.split(/[^-+eE\.\d]+/).map(parseFloat).filter(function(e){return!isNaN(e)}),r=[];for(t=0;t<(2147483646&i.length);t+=2)r.push(new o.w(i[t],i[t+1]));return r},e.StartingAt=function(e,t){return o.l.StartingAt(e,t)},e}(),ds=function(){function e(e,t,i,r){var n;void 0===r&&(r=earcut),this._points=new us,this._outlinepoints=new us,this._holes=new Array,this._epoints=new Array,this._eholes=new Array,this.bjsEarcut=r,this._name=e,this._scene=i,n=t instanceof o.l?t.getPoints():t,this._addToepoint(n),this._points.add(n),this._outlinepoints.add(n),void 0===this.bjsEarcut&&p.a.Warn("Earcut was not found, the polygon will not be built.")}return e.prototype._addToepoint=function(e){for(var t=0,i=e;t<i.length;t++){var r=i[t];this._epoints.push(r.x,r.y)}},e.prototype.addHole=function(e){this._points.add(e);var t=new us;return t.add(e),this._holes.push(t),this._eholes.push(this._epoints.length/2),this._addToepoint(e),this},e.prototype.build=function(e,t){var i=this;void 0===e&&(e=!1),void 0===t&&(t=0);var r=new de.a(this._name,this._scene),n=new Array,o=new Array,s=new Array,a=this._points.computeBounds();this._points.elements.forEach(function(e){n.push(0,1,0),o.push(e.x,0,e.y),s.push((e.x-a.min.x)/a.width,(e.y-a.min.y)/a.height)});for(var c=new Array,l=this.bjsEarcut(this._epoints,this._eholes,2),u=0;u<l.length;u++)c.push(l[u]);if(t>0){var h=o.length/3;this._points.elements.forEach(function(e){n.push(0,-1,0),o.push(e.x,-t,e.y),s.push(1-(e.x-a.min.x)/a.width,1-(e.y-a.min.y)/a.height)});var d=c.length;for(u=0;u<d;u+=3){var f=c[u+0],p=c[u+1],_=c[u+2];c.push(_+h),c.push(p+h),c.push(f+h)}this.addSide(o,n,s,c,a,this._outlinepoints,t,!1),this._holes.forEach(function(e){i.addSide(o,n,s,c,a,e,t,!0)})}return r.setVerticesData(gi.b.PositionKind,o,e),r.setVerticesData(gi.b.NormalKind,n,e),r.setVerticesData(gi.b.UVKind,s,e),r.setIndices(c),r},e.prototype.addSide=function(e,t,i,r,n,s,a,c){for(var l=e.length/3,u=0,h=0;h<s.elements.length;h++){var d,f=s.elements[h];d=h+1>s.elements.length-1?s.elements[0]:s.elements[h+1],e.push(f.x,0,f.y),e.push(f.x,-a,f.y),e.push(d.x,0,d.y),e.push(d.x,-a,d.y);var p=new o.x(f.x,0,f.y),_=new o.x(d.x,0,d.y).subtract(p),g=new o.x(0,1,0),m=o.x.Cross(_,g);m=m.normalize(),i.push(u/n.width,0),i.push(u/n.width,1),u+=_.length(),i.push(u/n.width,0),i.push(u/n.width,1),c?(t.push(m.x,m.y,m.z),t.push(m.x,m.y,m.z),t.push(m.x,m.y,m.z),t.push(m.x,m.y,m.z),r.push(l),r.push(l+2),r.push(l+1),r.push(l+1),r.push(l+2),r.push(l+3)):(t.push(-m.x,-m.y,-m.z),t.push(-m.x,-m.y,-m.z),t.push(-m.x,-m.y,-m.z),t.push(-m.x,-m.y,-m.z),r.push(l),r.push(l+1),r.push(l+2),r.push(l+1),r.push(l+3),r.push(l+2)),l+=4}},e}();_i.a.CreatePolygon=function(e,t,i,r,n,s){for(var a=i||new Array(3),c=r,l=[],u=0;u<3;u++)void 0===a[u]&&(a[u]=new o.y(0,0,1,1)),c&&void 0===c[u]&&(c[u]=new o.f(1,1,1,1));for(var h=e.getVerticesData(gi.b.PositionKind),d=e.getVerticesData(gi.b.NormalKind),f=e.getVerticesData(gi.b.UVKind),p=e.getIndices(),_=0,g=0,m=0;m<d.length;m+=3)Math.abs(d[m+1])<.001&&(g=1),Math.abs(d[m+1]-1)<.001&&(g=0),Math.abs(d[m+1]+1)<.001&&(g=2),f[2*(_=m/3)]=(1-f[2*_])*a[g].x+f[2*_]*a[g].z,f[2*_+1]=(1-f[2*_+1])*a[g].y+f[2*_+1]*a[g].w,c&&l.push(c[g].r,c[g].g,c[g].b,c[g].a);_i.a._ComputeSides(t,h,p,d,f,n,s);var v=new _i.a;if(v.indices=p,v.positions=h,v.normals=d,v.uvs=f,c){var y=t===_i.a.DOUBLESIDE?l.concat(l):l;v.colors=y}return v},de.a.CreatePolygon=function(e,t,i,r,n,o,s){void 0===s&&(s=earcut);var a={shape:t,holes:r,updatable:n,sideOrientation:o};return fs.CreatePolygon(e,a,i,s)},de.a.ExtrudePolygon=function(e,t,i,r,n,o,s,a){void 0===a&&(a=earcut);var c={shape:t,holes:n,depth:i,updatable:o,sideOrientation:s};return fs.ExtrudePolygon(e,c,r,a)};var fs=function(){function e(){}return e.CreatePolygon=function(e,t,i,r){void 0===r&&(r=earcut),t.sideOrientation=de.a._GetDefaultSideOrientation(t.sideOrientation);for(var n=t.shape,s=t.holes||[],a=t.depth||0,c=[],l=[],u=0;u<n.length;u++)c[u]=new o.w(n[u].x,n[u].z);c[0].equalsWithEpsilon(c[c.length-1],1e-8)&&c.pop();for(var h=new ds(e,c,i,r),d=0;d<s.length;d++){l=[];for(var f=0;f<s[d].length;f++)l.push(new o.w(s[d][f].x,s[d][f].z));h.addHole(l)}var p=h.build(t.updatable,a);return p._originalBuilderSideOrientation=t.sideOrientation,_i.a.CreatePolygon(p,t.sideOrientation,t.faceUV,t.faceColors,t.frontUVs,t.backUVs).applyToMesh(p,t.updatable),p},e.ExtrudePolygon=function(t,i,r,n){return void 0===n&&(n=earcut),e.CreatePolygon(t,i,r,n)},e}();de.a.ExtrudeShape=function(e,t,i,r,n,o,s,a,c,l){void 0===s&&(s=null);var u={shape:t,path:i,scale:r,rotation:n,cap:0===o?0:o||de.a.NO_CAP,sideOrientation:c,instance:l,updatable:a};return ps.ExtrudeShape(e,u,s)},de.a.ExtrudeShapeCustom=function(e,t,i,r,n,o,s,a,c,l,u,h){var d={shape:t,path:i,scaleFunction:r,rotationFunction:n,ribbonCloseArray:o,ribbonClosePath:s,cap:0===a?0:a||de.a.NO_CAP,sideOrientation:u,instance:h,updatable:l};return ps.ExtrudeShapeCustom(e,d,c)};var ps=function(){function e(){}return e.ExtrudeShape=function(t,i,r){void 0===r&&(r=null);var n=i.path,o=i.shape,s=i.scale||1,a=i.rotation||0,c=0===i.cap?0:i.cap||de.a.NO_CAP,l=i.updatable,u=de.a._GetDefaultSideOrientation(i.sideOrientation),h=i.instance||null,d=i.invertUV||!1;return e._ExtrudeShapeGeneric(t,o,n,s,a,null,null,!1,!1,c,!1,r,!!l,u,h,d,i.frontUVs||null,i.backUVs||null)},e.ExtrudeShapeCustom=function(t,i,r){var n=i.path,o=i.shape,s=i.scaleFunction||function(){return 1},a=i.rotationFunction||function(){return 0},c=i.ribbonCloseArray||!1,l=i.ribbonClosePath||!1,u=0===i.cap?0:i.cap||de.a.NO_CAP,h=i.updatable,d=de.a._GetDefaultSideOrientation(i.sideOrientation),f=i.instance,p=i.invertUV||!1;return e._ExtrudeShapeGeneric(t,o,n,null,null,s,a,c,l,u,!0,r,!!h,d,f||null,p,i.frontUVs||null,i.backUVs||null)},e._ExtrudeShapeGeneric=function(e,t,i,r,n,s,a,c,l,u,h,d,f,p,_,g,m,v){var y,b,T=function(e,t,i,r,n,s,a,c,l,u){for(var h=i.getTangents(),d=i.getNormals(),f=i.getBinormals(),p=i.getDistances(),_=0,g=u&&c?c:function(){return null!==s?s:0},m=u&&a?a:function(){return null!==n?n:1},v=l===de.a.NO_CAP||l===de.a.CAP_END?0:2,y=o.t.Matrix[0],b=0;b<t.length;b++){for(var T=new Array,E=g(b,p[b]),x=m(b,p[b]),A=0;A<e.length;A++){o.j.RotationAxisToRef(h[b],_,y);var P=h[b].scale(e[A].z).add(d[b].scale(e[A].x)).add(f[b].scale(e[A].y)),R=T[A]?T[A]:o.x.Zero();o.x.TransformCoordinatesToRef(P,y,R),R.scaleInPlace(x).addInPlace(t[b]),T[A]=R}r[v]=T,_+=E,v++}var S=function(e){var t,i=Array(),r=o.x.Zero();for(t=0;t<e.length;t++)r.addInPlace(e[t]);for(r.scaleInPlace(1/e.length),t=0;t<e.length;t++)i.push(r);return i};switch(l){case de.a.NO_CAP:break;case de.a.CAP_START:r[0]=S(r[2]),r[1]=r[2];break;case de.a.CAP_END:r[v]=r[v-1],r[v+1]=S(r[v-1]);break;case de.a.CAP_ALL:r[0]=S(r[2]),r[1]=r[2],r[v]=r[v-1],r[v+1]=S(r[v-1])}return r};if(_){var E=_._creationDataStorage;return y=E.path3D.update(i),b=T(t,i,E.path3D,E.pathArray,r,n,s,a,E.cap,h),_=de.a.CreateRibbon("",b,!1,!1,0,d||void 0,!1,0,_)}b=T(t,i,y=new o.m(i),new Array,r,n,s,a,u=u<0||u>3?0:u,h);var x=ss.CreateRibbon(e,{pathArray:b,closeArray:c,closePath:l,updatable:f,sideOrientation:p,invertUV:g,frontUVs:m||void 0,backUVs:v||void 0},d);return x._creationDataStorage.pathArray=b,x._creationDataStorage.path3D=y,x._creationDataStorage.cap=u,x},e}();de.a.CreateLathe=function(e,t,i,r,n,o,s){var a={shape:t,radius:i,tessellation:r,sideOrientation:s,updatable:o};return _s.CreateLathe(e,a,n)};var _s=function(){function e(){}return e.CreateLathe=function(e,t,i){var r,n=t.arc?t.arc<=0||t.arc>1?1:t.arc:1,s=void 0===t.closed||t.closed,a=t.shape,c=t.radius||1,l=t.tessellation||64,u=t.clip||0,h=t.updatable,d=de.a._GetDefaultSideOrientation(t.sideOrientation),f=t.cap||de.a.NO_CAP,p=2*Math.PI,_=new Array,g=t.invertUV||!1,m=0,v=0,y=p/l*n,b=new Array;for(m=0;m<=l-u;m++){b=[];for(f!=de.a.CAP_START&&f!=de.a.CAP_ALL||(b.push(new o.x(0,a[0].y,0)),b.push(new o.x(Math.cos(m*y)*a[0].x*c,a[0].y,Math.sin(m*y)*a[0].x*c))),v=0;v<a.length;v++)r=new o.x(Math.cos(m*y)*a[v].x*c,a[v].y,Math.sin(m*y)*a[v].x*c),b.push(r);f!=de.a.CAP_END&&f!=de.a.CAP_ALL||(b.push(new o.x(Math.cos(m*y)*a[a.length-1].x*c,a[a.length-1].y,Math.sin(m*y)*a[a.length-1].x*c)),b.push(new o.x(0,a[a.length-1].y,0))),_.push(b)}return ss.CreateRibbon(e,{pathArray:_,closeArray:s,sideOrientation:d,updatable:h,invertUV:g,frontUVs:t.frontUVs,backUVs:t.backUVs},i)},e}();de.a.CreateTube=function(e,t,i,r,n,o,s,a,c,l){var u={path:t,radius:i,tessellation:r,radiusFunction:n,arc:1,cap:o,updatable:a,sideOrientation:c,instance:l};return gs.CreateTube(e,u,s)};var gs=function(){function e(){}return e.CreateTube=function(e,t,i){var r=t.path,n=t.instance,s=1;void 0!==t.radius?s=t.radius:n&&(s=n._creationDataStorage.radius);var a=t.tessellation||64,c=t.radiusFunction||null,l=t.cap||de.a.NO_CAP,u=t.invertUV||!1,h=t.updatable,d=de.a._GetDefaultSideOrientation(t.sideOrientation);t.arc=t.arc&&(t.arc<=0||t.arc>1)?1:t.arc||1;var f,p,_=function(e,t,i,r,n,s,a,c){for(var l,u,h,d,f=t.getTangents(),p=t.getNormals(),_=t.getDistances(),g=2*Math.PI/n*c,m=s||function(){return r},v=o.t.Matrix[0],y=a===de.a.NO_CAP||a===de.a.CAP_END?0:2,b=0;b<e.length;b++){u=m(b,_[b]),l=Array(),h=p[b];for(var T=0;T<n;T++)o.j.RotationAxisToRef(f[b],g*T,v),d=l[T]?l[T]:o.x.Zero(),o.x.TransformCoordinatesToRef(h,v,d),d.scaleInPlace(u).addInPlace(e[b]),l[T]=d;i[y]=l,y++}var E=function(t,i){for(var r=Array(),n=0;n<t;n++)r.push(e[i]);return r};switch(a){case de.a.NO_CAP:break;case de.a.CAP_START:i[0]=E(n,0),i[1]=i[2].slice(0);break;case de.a.CAP_END:i[y]=i[y-1].slice(0),i[y+1]=E(n,e.length-1);break;case de.a.CAP_ALL:i[0]=E(n,0),i[1]=i[2].slice(0),i[y]=i[y-1].slice(0),i[y+1]=E(n,e.length-1)}return i};if(n){var g=n._creationDataStorage,m=t.arc||g.arc;return p=_(r,f=g.path3D.update(r),g.pathArray,s,g.tessellation,c,g.cap,m),n=ss.CreateRibbon("",{pathArray:p,instance:n}),g.path3D=f,g.pathArray=p,g.arc=m,g.radius=s,n}p=_(r,f=new o.m(r),new Array,s,a,c,l=l<0||l>3?0:l,t.arc);var v=ss.CreateRibbon(e,{pathArray:p,closePath:!0,closeArray:!1,updatable:h,sideOrientation:d,invertUV:u,frontUVs:t.frontUVs,backUVs:t.backUVs},i);return v._creationDataStorage.pathArray=p,v._creationDataStorage.path3D=f,v._creationDataStorage.tessellation=a,v._creationDataStorage.cap=l,v._creationDataStorage.arc=t.arc,v._creationDataStorage.radius=s,v},e}();_i.a.CreateIcoSphere=function(e){var t,i=e.sideOrientation||_i.a.DEFAULTSIDE,r=e.radius||1,n=void 0===e.flat||e.flat,s=e.subdivisions||4,a=e.radiusX||r,c=e.radiusY||r,l=e.radiusZ||r,u=(1+Math.sqrt(5))/2,h=[-1,u,-0,1,u,0,-1,-u,0,1,-u,0,0,-1,-u,0,1,-u,0,-1,u,0,1,u,u,0,1,u,0,-1,-u,0,1,-u,0,-1],d=[0,11,5,0,5,1,0,1,7,0,7,10,12,22,23,1,5,20,5,11,4,23,22,13,22,18,6,7,1,8,14,21,4,14,4,2,16,13,6,15,6,19,3,8,9,4,21,5,13,17,23,6,13,22,19,6,18,9,8,1],f=[0,1,2,3,4,5,6,7,8,9,10,11,0,2,3,3,3,4,7,8,9,9,10,11],p=[5,1,3,1,6,4,0,0,5,3,4,2,2,2,4,0,2,0,1,1,6,0,6,2,0,4,3,3,4,4,3,1,4,2,4,4,0,2,1,1,2,2,3,3,1,3,2,4],_=[0,0,0,0,1,0,0,1,1,0,0,0,1,1,0,0,1,1,1,0],g=new Array,m=new Array,v=new Array,y=new Array,b=0,T=new Array(3),E=new Array(3);for(t=0;t<3;t++)T[t]=o.x.Zero(),E[t]=o.w.Zero();for(var x=0;x<20;x++){for(t=0;t<3;t++){var A=d[3*x+t];T[t].copyFromFloats(h[3*f[A]],h[3*f[A]+1],h[3*f[A]+2]),T[t].normalize().scaleInPlace(r),E[t].copyFromFloats(p[2*A]*(138/1024)+60/1024+_[x]*(-40/1024),p[2*A+1]*(239/1024)+26/1024+_[x]*(20/1024))}for(var P=function(e,t,i,r){var u,h=o.x.Lerp(T[0],T[2],t/s),d=o.x.Lerp(T[1],T[2],t/s),f=s===t?T[2]:o.x.Lerp(h,d,e/(s-t));if(f.normalize(),n){var p=o.x.Lerp(T[0],T[2],r/s),_=o.x.Lerp(T[1],T[2],r/s);u=o.x.Lerp(p,_,i/(s-r))}else u=new o.x(f.x,f.y,f.z);u.x/=a,u.y/=c,u.z/=l,u.normalize();var x=o.w.Lerp(E[0],E[2],t/s),A=o.w.Lerp(E[1],E[2],t/s),P=s===t?E[2]:o.w.Lerp(x,A,e/(s-t));m.push(f.x*a,f.y*c,f.z*l),v.push(u.x,u.y,u.z),y.push(P.x,P.y),g.push(b),b++},R=0;R<s;R++)for(var S=0;S+R<s;S++)P(S,R,S+1/3,R+1/3),P(S+1,R,S+1/3,R+1/3),P(S,R+1,S+1/3,R+1/3),S+R+1<s&&(P(S+1,R,S+2/3,R+2/3),P(S+1,R+1,S+2/3,R+2/3),P(S,R+1,S+2/3,R+2/3))}_i.a._ComputeSides(i,m,g,v,y,e.frontUVs,e.backUVs);var C=new _i.a;return C.indices=g,C.positions=m,C.normals=v,C.uvs=y,C},de.a.CreateIcoSphere=function(e,t,i){return ms.CreateIcoSphere(e,t,i)};var ms=function(){function e(){}return e.CreateIcoSphere=function(e,t,i){var r=new de.a(e,i);return t.sideOrientation=de.a._GetDefaultSideOrientation(t.sideOrientation),r._originalBuilderSideOrientation=t.sideOrientation,_i.a.CreateIcoSphere(t).applyToMesh(r,t.updatable),r},e}();de.a.CreateDecal=function(e,t,i,r,n,o){var s={position:i,normal:r,size:n,angle:o};return ys.CreateDecal(e,t,s)};var vs,ys=function(){function e(){}return e.CreateDecal=function(e,t,i){var r=t.getIndices(),n=t.getVerticesData(gi.b.PositionKind),s=t.getVerticesData(gi.b.NormalKind),a=i.position||o.x.Zero(),c=i.normal||o.x.Up(),l=i.size||o.x.One(),u=i.angle||0;if(!c){var h=new o.x(0,0,1),d=t.getScene().activeCamera,f=o.x.TransformCoordinates(h,d.getWorldMatrix());c=d.globalPosition.subtract(f)}var p=-Math.atan2(c.z,c.x)-Math.PI/2,_=Math.sqrt(c.x*c.x+c.z*c.z),g=Math.atan2(c.y,_),m=o.j.RotationYawPitchRoll(p,g,u).multiply(o.j.Translation(a.x,a.y,a.z)),v=o.j.Invert(m),y=t.getWorldMatrix().multiply(v),b=new _i.a;b.indices=[],b.positions=[],b.normals=[],b.uvs=[];for(var T=0,E=function(e){var t=new o.p;if(!r||!n||!s)return t;var i=r[e];return t.position=new o.x(n[3*i],n[3*i+1],n[3*i+2]),t.position=o.x.TransformCoordinates(t.position,y),t.normal=new o.x(s[3*i],s[3*i+1],s[3*i+2]),t.normal=o.x.TransformNormal(t.normal,y),t},x=function(e,t){if(0===e.length)return e;for(var i=.5*Math.abs(o.x.Dot(l,t)),r=function(e,r){var n=o.x.GetClipFactor(e.position,r.position,t,i);return new o.p(o.x.Lerp(e.position,r.position,n),o.x.Lerp(e.normal,r.normal,n))},n=new Array,s=0;s<e.length;s+=3){var a,c,u,h=null,d=null,f=null,p=null;switch(((a=o.x.Dot(e[s].position,t)-i>0)?1:0)+((c=o.x.Dot(e[s+1].position,t)-i>0)?1:0)+((u=o.x.Dot(e[s+2].position,t)-i>0)?1:0)){case 0:n.push(e[s]),n.push(e[s+1]),n.push(e[s+2]);break;case 1:if(a&&(h=e[s+1],d=e[s+2],f=r(e[s],h),p=r(e[s],d)),c){h=e[s],d=e[s+2],f=r(e[s+1],h),p=r(e[s+1],d),n.push(f),n.push(d.clone()),n.push(h.clone()),n.push(d.clone()),n.push(f.clone()),n.push(p);break}u&&(h=e[s],d=e[s+1],f=r(e[s+2],h),p=r(e[s+2],d)),h&&d&&f&&p&&(n.push(h.clone()),n.push(d.clone()),n.push(f),n.push(p),n.push(f.clone()),n.push(d.clone()));break;case 2:a||(d=r(h=e[s].clone(),e[s+1]),f=r(h,e[s+2]),n.push(h),n.push(d),n.push(f)),c||(d=r(h=e[s+1].clone(),e[s+2]),f=r(h,e[s]),n.push(h),n.push(d),n.push(f)),u||(d=r(h=e[s+2].clone(),e[s]),f=r(h,e[s+1]),n.push(h),n.push(d),n.push(f))}}return n},A=0;A<r.length;A+=3){var P=new Array;if(P.push(E(A)),P.push(E(A+1)),P.push(E(A+2)),P=x(P,new o.x(1,0,0)),P=x(P,new o.x(-1,0,0)),P=x(P,new o.x(0,1,0)),P=x(P,new o.x(0,-1,0)),P=x(P,new o.x(0,0,1)),0!==(P=x(P,new o.x(0,0,-1))).length)for(var R=0;R<P.length;R++){var S=P[R];b.indices.push(T),S.position.toArray(b.positions,3*T),S.normal.toArray(b.normals,3*T),b.uvs.push(.5+S.position.x/l.x),b.uvs.push(.5+S.position.y/l.y),T++}}var C=new de.a(e,t.getScene());return b.applyToMesh(C),C.position=a.clone(),C.rotation=new o.x(g,p,u),C},e}(),bs=function(){function e(){}return e.CreateBox=function(e,t,i){return void 0===i&&(i=null),br.a.CreateBox(e,t,i)},e.CreateSphere=function(e,t,i){return Pr.a.CreateSphere(e,t,i)},e.CreateDisc=function(e,t,i){return void 0===i&&(i=null),as.CreateDisc(e,t,i)},e.CreateIcoSphere=function(e,t,i){return ms.CreateIcoSphere(e,t,i)},e.CreateRibbon=function(e,t,i){return void 0===i&&(i=null),ss.CreateRibbon(e,t,i)},e.CreateCylinder=function(e,t,i){return bi.a.CreateCylinder(e,t,i)},e.CreateTorus=function(e,t,i){return yi.CreateTorus(e,t,i)},e.CreateTorusKnot=function(e,t,i){return cs.CreateTorusKnot(e,t,i)},e.CreateLineSystem=function(e,t,i){return Tr.a.CreateLineSystem(e,t,i)},e.CreateLines=function(e,t,i){return void 0===i&&(i=null),Tr.a.CreateLines(e,t,i)},e.CreateDashedLines=function(e,t,i){return void 0===i&&(i=null),Tr.a.CreateDashedLines(e,t,i)},e.ExtrudeShape=function(e,t,i){return void 0===i&&(i=null),ps.ExtrudeShape(e,t,i)},e.ExtrudeShapeCustom=function(e,t,i){return ps.ExtrudeShapeCustom(e,t,i)},e.CreateLathe=function(e,t,i){return _s.CreateLathe(e,t,i)},e.CreatePlane=function(e,t,i){return Jr.a.CreatePlane(e,t,i)},e.CreateGround=function(e,t,i){return vi.CreateGround(e,t,i)},e.CreateTiledGround=function(e,t,i){return vi.CreateTiledGround(e,t,i)},e.CreateGroundFromHeightMap=function(e,t,i,r){return vi.CreateGroundFromHeightMap(e,t,i,r)},e.CreatePolygon=function(e,t,i,r){return void 0===r&&(r=earcut),fs.CreatePolygon(e,t,i,r)},e.ExtrudePolygon=function(e,t,i,r){return void 0===r&&(r=earcut),fs.ExtrudePolygon(e,t,i,r)},e.CreateTube=function(e,t,i){return gs.CreateTube(e,t,i)},e.CreatePolyhedron=function(e,t,i){return Or.CreatePolyhedron(e,t,i)},e.CreateDecal=function(e,t,i){return ys.CreateDecal(e,t,i)},e}(),Ts=function(){return function(e,t,i){this.quality=e,this.distance=t,this.optimizeMesh=i}}(),Es=function(){function e(){this.running=!1,this._simplificationArray=[]}return e.prototype.addTask=function(e){this._simplificationArray.push(e)},e.prototype.executeNext=function(){var e=this._simplificationArray.pop();e?(this.running=!0,this.runSimplification(e)):this.running=!1},e.prototype.runSimplification=function(e){var t=this;if(e.parallelProcessing)e.settings.forEach(function(i){t.getSimplifier(e).simplify(i,function(r){e.mesh.addLODLevel(i.distance,r),r.isVisible=!0,i.quality===e.settings[e.settings.length-1].quality&&e.successCallback&&e.successCallback(),t.executeNext()})});else{var i=this.getSimplifier(e);ve.a.Run(e.settings.length,function(t){var r,n;r=e.settings[t.index],n=function(){t.executeNext()},i.simplify(r,function(t){e.mesh.addLODLevel(r.distance,t),t.isVisible=!0,n()})},function(){e.successCallback&&e.successCallback(),t.executeNext()})}},e.prototype.getSimplifier=function(e){switch(e.simplificationType){case vs.QUADRATIC:default:return new Ss(e.mesh)}},e}();!function(e){e[e.QUADRATIC=0]="QUADRATIC"}(vs||(vs={}));var xs=function(){return function(e){this.vertices=e,this.error=new Array(4),this.deleted=!1,this.isDirty=!1,this.deletePending=!1,this.borderFactor=0}}(),As=function(){function e(e,t){this.position=e,this.id=t,this.isBorder=!0,this.q=new Ps,this.triangleCount=0,this.triangleStart=0,this.originalOffsets=[]}return e.prototype.updatePosition=function(e){this.position.copyFrom(e)},e}(),Ps=function(){function e(e){this.data=new Array(10);for(var t=0;t<10;++t)e&&e[t]?this.data[t]=e[t]:this.data[t]=0}return e.prototype.det=function(e,t,i,r,n,o,s,a,c){return this.data[e]*this.data[n]*this.data[c]+this.data[i]*this.data[r]*this.data[a]+this.data[t]*this.data[o]*this.data[s]-this.data[i]*this.data[n]*this.data[s]-this.data[e]*this.data[o]*this.data[a]-this.data[t]*this.data[r]*this.data[c]},e.prototype.addInPlace=function(e){for(var t=0;t<10;++t)this.data[t]+=e.data[t]},e.prototype.addArrayInPlace=function(e){for(var t=0;t<10;++t)this.data[t]+=e[t]},e.prototype.add=function(t){for(var i=new e,r=0;r<10;++r)i.data[r]=this.data[r]+t.data[r];return i},e.FromData=function(t,i,r,n){return new e(e.DataFromNumbers(t,i,r,n))},e.DataFromNumbers=function(e,t,i,r){return[e*e,e*t,e*i,e*r,t*t,t*i,t*r,i*i,i*r,r*r]},e}(),Rs=function(){return function(e,t){this.vertexId=e,this.triangleId=t}}(),Ss=function(){function e(e){this._mesh=e,this.syncIterations=5e3,this.aggressiveness=7,this.decimationIterations=100,this.boundingBoxEpsilon=o.h}return e.prototype.simplify=function(e,t){var i=this;this.initDecimatedMesh(),ve.a.Run(this._mesh.subMeshes.length,function(t){i.initWithMesh(t.index,function(){i.runDecimation(e,t.index,function(){t.executeNext()})},e.optimizeMesh)},function(){setTimeout(function(){t(i._reconstructedMesh)},0)})},e.prototype.runDecimation=function(e,t,i){var r=this,n=~~(this.triangles.length*e.quality),s=0,a=this.triangles.length;ve.a.Run(this.decimationIterations,function(e){var t,i;a-s<=n?e.breakLoop():(t=e.index,i=function(){e.executeNext()},setTimeout(function(){t%5==0&&r.updateMesh(0===t);for(var e=0;e<r.triangles.length;++e)r.triangles[e].isDirty=!1;var c=1e-9*Math.pow(t+3,r.aggressiveness);ve.a.SyncAsyncForLoop(r.triangles.length,r.syncIterations,function(e){var t=~~((r.triangles.length/2+e)%r.triangles.length),i=r.triangles[t];if(i&&!(i.error[3]>c||i.deleted||i.isDirty))for(var n=0;n<3;++n)if(i.error[n]<c){var a=[],l=[],u=i.vertices[n],h=i.vertices[(n+1)%3];if(u.isBorder||h.isBorder)continue;var d=o.x.Zero();r.calculateError(u,h,d);var f=new Array;if(r.isFlipped(u,h,d,a,f))continue;if(r.isFlipped(h,u,d,l,f))continue;if(a.indexOf(!0)<0||l.indexOf(!0)<0)continue;var p=new Array;if(f.forEach(function(e){-1===p.indexOf(e)&&(e.deletePending=!0,p.push(e))}),p.length%2!=0)continue;u.q=h.q.add(u.q),u.updatePosition(d);var _=r.references.length;s=r.updateTriangles(u,u,a,s),s=r.updateTriangles(u,h,l,s);var g=r.references.length-_;if(g<=u.triangleCount){if(g)for(var m=0;m<g;m++)r.references[u.triangleStart+m]=r.references[_+m]}else u.triangleStart=_;u.triangleCount=g;break}},i,function(){return a-s<=n})},0))},function(){setTimeout(function(){r.reconstructMesh(t),i()},0)})},e.prototype.initWithMesh=function(e,t,i){var r=this;this.vertices=[],this.triangles=[];var n=this._mesh.getVerticesData(gi.b.PositionKind),s=this._mesh.getIndices(),a=this._mesh.subMeshes[e],c=[],l=a.verticesCount;ve.a.SyncAsyncForLoop(l,this.syncIterations/4>>0,function(e){if(n){var t=e+a.verticesStart,s=o.x.FromArray(n,3*t),l=function(e){if(i)for(var t=0;t<r.vertices.length;++t)if(r.vertices[t].position.equals(e))return r.vertices[t];return null}(s)||new As(s,r.vertices.length);l.originalOffsets.push(t),l.id===r.vertices.length&&r.vertices.push(l),c.push(l.id)}},function(){ve.a.SyncAsyncForLoop(a.indexCount/3,r.syncIterations,function(e){if(s){var t=3*(a.indexStart/3+e),i=s[t+0],n=s[t+1],o=s[t+2],l=r.vertices[c[i-a.verticesStart]],u=r.vertices[c[n-a.verticesStart]],h=r.vertices[c[o-a.verticesStart]],d=new xs([l,u,h]);d.originalOffset=t,r.triangles.push(d)}},function(){r.init(t)})})},e.prototype.init=function(e){var t=this;ve.a.SyncAsyncForLoop(this.triangles.length,this.syncIterations,function(e){var i=t.triangles[e];i.normal=o.x.Cross(i.vertices[1].position.subtract(i.vertices[0].position),i.vertices[2].position.subtract(i.vertices[0].position)).normalize();for(var r=0;r<3;r++)i.vertices[r].q.addArrayInPlace(Ps.DataFromNumbers(i.normal.x,i.normal.y,i.normal.z,-o.x.Dot(i.normal,i.vertices[0].position)))},function(){ve.a.SyncAsyncForLoop(t.triangles.length,t.syncIterations,function(e){for(var i=t.triangles[e],r=0;r<3;++r)i.error[r]=t.calculateError(i.vertices[r],i.vertices[(r+1)%3]);i.error[3]=Math.min(i.error[0],i.error[1],i.error[2])},function(){e()})})},e.prototype.reconstructMesh=function(e){var t,i,r,n=[];for(t=0;t<this.vertices.length;++t)this.vertices[t].triangleCount=0;for(t=0;t<this.triangles.length;++t)if(!this.triangles[t].deleted){for(i=this.triangles[t],r=0;r<3;++r)i.vertices[r].triangleCount=1;n.push(i)}var o=this._reconstructedMesh.getVerticesData(gi.b.PositionKind)||[],s=this._reconstructedMesh.getVerticesData(gi.b.NormalKind)||[],a=this._reconstructedMesh.getVerticesData(gi.b.UVKind)||[],c=this._reconstructedMesh.getVerticesData(gi.b.ColorKind)||[],l=this._mesh.getVerticesData(gi.b.NormalKind),u=this._mesh.getVerticesData(gi.b.UVKind),h=this._mesh.getVerticesData(gi.b.ColorKind),d=0;for(t=0;t<this.vertices.length;++t){var f=this.vertices[t];f.id=d,f.triangleCount&&f.originalOffsets.forEach(function(e){l&&(o.push(f.position.x),o.push(f.position.y),o.push(f.position.z),s.push(l[3*e]),s.push(l[3*e+1]),s.push(l[3*e+2]),u&&u.length?(a.push(u[2*e]),a.push(u[2*e+1])):h&&h.length&&(c.push(h[4*e]),c.push(h[4*e+1]),c.push(h[4*e+2]),c.push(h[4*e+3])),++d)})}var p=this._reconstructedMesh.getTotalIndices(),_=this._reconstructedMesh.getTotalVertices(),g=this._reconstructedMesh.subMeshes;this._reconstructedMesh.subMeshes=[];var m=this._reconstructedMesh.getIndices(),v=this._mesh.getIndices();for(t=0;t<n.length;++t)i=n[t],[0,1,2].forEach(function(e){var t=v[i.originalOffset+e],r=i.vertices[e].originalOffsets.indexOf(t);r<0&&(r=0),m.push(i.vertices[e].id+r+_)});this._reconstructedMesh.setIndices(m),this._reconstructedMesh.setVerticesData(gi.b.PositionKind,o),this._reconstructedMesh.setVerticesData(gi.b.NormalKind,s),a.length>0&&this._reconstructedMesh.setVerticesData(gi.b.UVKind,a),c.length>0&&this._reconstructedMesh.setVerticesData(gi.b.ColorKind,c);var y=this._mesh.subMeshes[e];e>0&&(this._reconstructedMesh.subMeshes=[],g.forEach(function(e){Zo.b.AddToMesh(e.materialIndex,e.verticesStart,e.verticesCount,e.indexStart,e.indexCount,e.getMesh())}),Zo.b.AddToMesh(y.materialIndex,_,d,p,3*n.length,this._reconstructedMesh))},e.prototype.initDecimatedMesh=function(){this._reconstructedMesh=new de.a(this._mesh.name+"Decimated",this._mesh.getScene()),this._reconstructedMesh.material=this._mesh.material,this._reconstructedMesh.parent=this._mesh.parent,this._reconstructedMesh.isVisible=!1,this._reconstructedMesh.renderingGroupId=this._mesh.renderingGroupId},e.prototype.isFlipped=function(e,t,i,r,n){for(var s=0;s<e.triangleCount;++s){var a=this.triangles[this.references[e.triangleStart+s].triangleId];if(!a.deleted){var c=this.references[e.triangleStart+s].vertexId,l=a.vertices[(c+1)%3],u=a.vertices[(c+2)%3];if(l!==t&&u!==t){var h=l.position.subtract(i);h=h.normalize();var d=u.position.subtract(i);if(d=d.normalize(),Math.abs(o.x.Dot(h,d))>.999)return!0;var f=o.x.Cross(h,d).normalize();if(r[s]=!1,o.x.Dot(f,a.normal)<.2)return!0}else r[s]=!0,n.push(a)}}return!1},e.prototype.updateTriangles=function(e,t,i,r){for(var n=r,o=0;o<t.triangleCount;++o){var s=this.references[t.triangleStart+o],a=this.triangles[s.triangleId];a.deleted||(i[o]&&a.deletePending?(a.deleted=!0,n++):(a.vertices[s.vertexId]=e,a.isDirty=!0,a.error[0]=this.calculateError(a.vertices[0],a.vertices[1])+a.borderFactor/2,a.error[1]=this.calculateError(a.vertices[1],a.vertices[2])+a.borderFactor/2,a.error[2]=this.calculateError(a.vertices[2],a.vertices[0])+a.borderFactor/2,a.error[3]=Math.min(a.error[0],a.error[1],a.error[2]),this.references.push(s)))}return n},e.prototype.identifyBorder=function(){for(var e=0;e<this.vertices.length;++e){var t,i=[],r=[],n=this.vertices[e];for(t=0;t<n.triangleCount;++t)for(var o=this.triangles[this.references[n.triangleStart+t].triangleId],s=0;s<3;s++){for(var a=0,c=o.vertices[s];a<i.length&&r[a]!==c.id;)++a;a===i.length?(i.push(1),r.push(c.id)):i[a]++}for(t=0;t<i.length;++t)1===i[t]?this.vertices[r[t]].isBorder=!0:this.vertices[r[t]].isBorder=!1}},e.prototype.updateMesh=function(e){var t,i,r,n;if(void 0===e&&(e=!1),!e){var o=[];for(t=0;t<this.triangles.length;++t)this.triangles[t].deleted||o.push(this.triangles[t]);this.triangles=o}for(t=0;t<this.vertices.length;++t)this.vertices[t].triangleCount=0,this.vertices[t].triangleStart=0;for(t=0;t<this.triangles.length;++t)for(i=this.triangles[t],r=0;r<3;++r)(n=i.vertices[r]).triangleCount++;var s=0;for(t=0;t<this.vertices.length;++t)this.vertices[t].triangleStart=s,s+=this.vertices[t].triangleCount,this.vertices[t].triangleCount=0;var a=new Array(3*this.triangles.length);for(t=0;t<this.triangles.length;++t)for(i=this.triangles[t],r=0;r<3;++r)a[(n=i.vertices[r]).triangleStart+n.triangleCount]=new Rs(r,t),n.triangleCount++;this.references=a,e&&this.identifyBorder()},e.prototype.vertexError=function(e,t){var i=t.x,r=t.y,n=t.z;return e.data[0]*i*i+2*e.data[1]*i*r+2*e.data[2]*i*n+2*e.data[3]*i+e.data[4]*r*r+2*e.data[5]*r*n+2*e.data[6]*r+e.data[7]*n*n+2*e.data[8]*n+e.data[9]},e.prototype.calculateError=function(e,t,i){var r=e.q.add(t.q),n=e.isBorder&&t.isBorder,s=0,a=r.det(0,1,2,1,4,5,2,5,7);if(0===a||n){var c=e.position.add(t.position).divide(new o.x(2,2,2)),l=this.vertexError(r,e.position),u=this.vertexError(r,t.position),h=this.vertexError(r,c);(s=Math.min(l,u,h))===l?i&&i.copyFrom(e.position):s===u?i&&i.copyFrom(t.position):i&&i.copyFrom(c)}else i||(i=o.x.Zero()),i.x=-1/a*r.det(1,2,3,4,5,6,5,7,8),i.y=1/a*r.det(0,2,3,1,5,6,2,7,8),i.z=-1/a*r.det(0,1,3,1,4,6,2,5,8),s=this.vertexError(r,i);return s},e}();Object.defineProperty(W.a.prototype,"simplificationQueue",{get:function(){if(!this._simplificationQueue){this._simplificationQueue=new Es;var e=this._getComponent(Te.a.NAME_SIMPLIFICATIONQUEUE);e||(e=new Cs(this),this._addComponent(e))}return this._simplificationQueue},set:function(e){this._simplificationQueue=e},enumerable:!0,configurable:!0}),de.a.prototype.simplify=function(e,t,i,r){return void 0===t&&(t=!0),void 0===i&&(i=vs.QUADRATIC),this.getScene().simplificationQueue.addTask({settings:e,parallelProcessing:t,mesh:this,simplificationType:i,successCallback:r}),this};var Cs=function(){function e(e){this.name=Te.a.NAME_SIMPLIFICATIONQUEUE,this.scene=e}return e.prototype.register=function(){this.scene._beforeCameraUpdateStage.registerStep(Te.a.STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE,this,this._beforeCameraUpdate)},e.prototype.rebuild=function(){},e.prototype.dispose=function(){},e.prototype._beforeCameraUpdate=function(){this.scene._simplificationQueue&&!this.scene._simplificationQueue.running&&this.scene._simplificationQueue.executeNext()},e}();_e.b.OfflineProviderFactory=function(e,t,i){return void 0===i&&(i=!1),new Os(e,t,i)};var Ms,Os=function(){function e(t,i,r){void 0===r&&(r=!1);var n=this;this._idbFactory=window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB,this._callbackManifestChecked=i,this._currentSceneUrl=e._ReturnFullUrlLocation(t),this._db=null,this._enableSceneOffline=!1,this._enableTexturesOffline=!1,this._manifestVersionFound=0,this._mustUpdateRessources=!1,this._hasReachedQuota=!1,e.IDBStorageEnabled?r?(this._enableSceneOffline=!0,this._enableTexturesOffline=!0,this._manifestVersionFound=1,ve.h.SetImmediate(function(){n._callbackManifestChecked(!0)})):this._checkManifestFile():this._callbackManifestChecked(!0)}return Object.defineProperty(e.prototype,"enableSceneOffline",{get:function(){return this._enableSceneOffline},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"enableTexturesOffline",{get:function(){return this._enableTexturesOffline},enumerable:!0,configurable:!0}),e.prototype._checkManifestFile=function(){var t=this,i=function(){t._enableSceneOffline=!1,t._enableTexturesOffline=!1,t._callbackManifestChecked(!1)},r=!1,n=this._currentSceneUrl+".manifest",o=new XMLHttpRequest;navigator.onLine&&(r=!0,n=n+(null==n.match(/\?/)?"?":"&")+Date.now()),o.open("GET",n,!0),o.addEventListener("load",function(){if(200===o.status||e._ValidateXHRData(o,1))try{var r=JSON.parse(o.response);t._enableSceneOffline=r.enableSceneOffline,t._enableTexturesOffline=r.enableTexturesOffline&&e.IsUASupportingBlobStorage,r.version&&!isNaN(parseInt(r.version))&&(t._manifestVersionFound=r.version),t._callbackManifestChecked&&t._callbackManifestChecked(!0)}catch(e){i()}else i()},!1),o.addEventListener("error",function(){if(r){r=!1;var e=t._currentSceneUrl+".manifest";o.open("GET",e,!0),ve.h.UseCustomRequestHeaders&&ve.h.InjectCustomRequestHeaders(o),o.send()}else i()},!1);try{ve.h.UseCustomRequestHeaders&&ve.h.InjectCustomRequestHeaders(o),o.send()}catch(e){p.a.Error("Error on XHR send request."),this._callbackManifestChecked(!1)}},e.prototype.open=function(e,t){var i=this,r=function(){i._isSupported=!1,t&&t()};if(this._idbFactory&&(this._enableSceneOffline||this._enableTexturesOffline))if(this._db)e&&e();else{this._hasReachedQuota=!1,this._isSupported=!0;var n=this._idbFactory.open("babylonjs",1);n.onerror=function(){r()},n.onblocked=function(){p.a.Error("IDB request blocked. Please reload the page."),r()},n.onsuccess=function(){i._db=n.result,e()},n.onupgradeneeded=function(e){if(i._db=e.target.result,i._db)try{i._db.createObjectStore("scenes",{keyPath:"sceneUrl"}),i._db.createObjectStore("versions",{keyPath:"sceneUrl"}),i._db.createObjectStore("textures",{keyPath:"textureUrl"})}catch(e){p.a.Error("Error while creating object stores. Exception: "+e.message),r()}}}else this._isSupported=!1,t&&t()},e.prototype.loadImage=function(t,i){var r=this,n=e._ReturnFullUrlLocation(t),o=function(){r._hasReachedQuota||null===r._db?i.src=t:r._saveImageIntoDBAsync(n,i)};this._mustUpdateRessources?o():this._loadImageFromDBAsync(n,i,o)},e.prototype._loadImageFromDBAsync=function(e,t,i){if(this._isSupported&&null!==this._db){var r,n=this._db.transaction(["textures"]);n.onabort=function(){t.src=e},n.oncomplete=function(){var n;if(r){var o=window.URL||window.webkitURL;n=o.createObjectURL(r.data),t.onerror=function(){p.a.Error("Error loading image from blob URL: "+n+" switching back to web url: "+e),t.src=e},t.src=n}else i()};var o=n.objectStore("textures").get(e);o.onsuccess=function(e){r=e.target.result},o.onerror=function(){p.a.Error("Error loading texture "+e+" from DB."),t.src=e}}else p.a.Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open."),t.src=e},e.prototype._saveImageIntoDBAsync=function(t,i){var r=this;if(this._isSupported){var n=function(){var e;if(o){var t=window.URL||window.webkitURL;try{e=t.createObjectURL(o)}catch(i){e=t.createObjectURL(o)}}e&&(i.src=e)};if(e.IsUASupportingBlobStorage){var o,s=new XMLHttpRequest;s.open("GET",t,!0),s.responseType="blob",s.addEventListener("load",function(){if(200===s.status&&r._db){o=s.response;var a=r._db.transaction(["textures"],"readwrite");a.onabort=function(e){try{var t=(e.srcElement||e.target).error;t&&"QuotaExceededError"===t.name&&(r._hasReachedQuota=!0)}catch(e){}n()},a.oncomplete=function(){n()};var c={textureUrl:t,data:o};try{var l=a.objectStore("textures").put(c);l.onsuccess=function(){},l.onerror=function(){n()}}catch(n){25===n.code&&(e.IsUASupportingBlobStorage=!1,r._enableTexturesOffline=!1),i.src=t}}else i.src=t},!1),s.addEventListener("error",function(){p.a.Error("Error in XHR request in BABYLON.Database."),i.src=t},!1),ve.h.CustomRequestHeaders&&ve.h.InjectCustomRequestHeaders(s),s.send()}else i.src=t}else p.a.Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open."),i.src=t},e.prototype._checkVersionFromDB=function(e,t){var i=this;this._loadVersionFromDBAsync(e,t,function(){i._saveVersionIntoDBAsync(e,t)})},e.prototype._loadVersionFromDBAsync=function(e,t,i){var r,n=this;if(this._isSupported&&this._db)try{var o=this._db.transaction(["versions"]);o.oncomplete=function(){r?n._manifestVersionFound!==r.data?(n._mustUpdateRessources=!0,i()):t(r.data):(n._mustUpdateRessources=!0,i())},o.onabort=function(){t(-1)};var s=o.objectStore("versions").get(e);s.onsuccess=function(e){r=e.target.result},s.onerror=function(){p.a.Error("Error loading version for scene "+e+" from DB."),t(-1)}}catch(e){p.a.Error("Error while accessing 'versions' object store (READ OP). Exception: "+e.message),t(-1)}else p.a.Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open."),t(-1)},e.prototype._saveVersionIntoDBAsync=function(e,t){var i=this;if(this._isSupported&&!this._hasReachedQuota&&this._db)try{var r=this._db.transaction(["versions"],"readwrite");r.onabort=function(e){try{var r=e.srcElement.error;r&&"QuotaExceededError"===r.name&&(i._hasReachedQuota=!0)}catch(e){}t(-1)},r.oncomplete=function(){t(i._manifestVersionFound)};var n={sceneUrl:e,data:this._manifestVersionFound},o=r.objectStore("versions").put(n);o.onsuccess=function(){},o.onerror=function(){p.a.Error("Error in DB add version request in BABYLON.Database.")}}catch(e){p.a.Error("Error while accessing 'versions' object store (WRITE OP). Exception: "+e.message),t(-1)}else t(-1)},e.prototype.loadFile=function(t,i,r,n,o){var s=this,a=e._ReturnFullUrlLocation(t),c=function(){s._saveFileAsync(a,i,r,o,n)};this._checkVersionFromDB(a,function(e){-1!==e?s._mustUpdateRessources?s._saveFileAsync(a,i,r,o,n):s._loadFileAsync(a,i,c):n&&n()})},e.prototype._loadFileAsync=function(e,t,i){if(this._isSupported&&this._db){var r,n;r=-1!==e.indexOf(".babylon")?"scenes":"textures";var o=this._db.transaction([r]);o.oncomplete=function(){n?t(n.data):i()},o.onabort=function(){i()};var s=o.objectStore(r).get(e);s.onsuccess=function(e){n=e.target.result},s.onerror=function(){p.a.Error("Error loading file "+e+" from DB."),i()}}else p.a.Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open."),t()},e.prototype._saveFileAsync=function(t,i,r,n,o){var s=this;if(this._isSupported){var a;a=-1!==t.indexOf(".babylon")?"scenes":"textures";var c,l=new XMLHttpRequest;l.open("GET",t+"?"+Date.now(),!0),n&&(l.responseType="arraybuffer"),r&&(l.onprogress=r),l.addEventListener("load",function(){if(200===l.status||l.status<400&&e._ValidateXHRData(l,n?6:1))if(c=n?l.response:l.responseText,!s._hasReachedQuota&&s._db){var r,u=s._db.transaction([a],"readwrite");u.onabort=function(e){try{var t=e.srcElement.error;t&&"QuotaExceededError"===t.name&&(s._hasReachedQuota=!0)}catch(e){}i(c)},u.oncomplete=function(){i(c)},r="scenes"===a?{sceneUrl:t,data:c,version:s._manifestVersionFound}:{textureUrl:t,data:c};try{var h=u.objectStore(a).put(r);h.onsuccess=function(){},h.onerror=function(){p.a.Error("Error in DB add file request in BABYLON.Database.")}}catch(e){i(c)}}else i(c);else l.status>=400&&o?o(l):i()},!1),l.addEventListener("error",function(){p.a.Error("error on XHR request."),i()},!1),ve.h.UseCustomRequestHeaders&&ve.h.InjectCustomRequestHeaders(l),l.send()}else p.a.Error("Error: IndexedDB not supported by your browser or Babylon.js Database is not open."),i()},e._ValidateXHRData=function(e,t){void 0===t&&(t=7);try{if(1&t){if(e.responseText&&e.responseText.length>0)return!0;if(1===t)return!1}if(2&t){var i=Bo.GetTGAHeader(e.response);if(i.width&&i.height&&i.width>0&&i.height>0)return!0;if(2===t)return!1}if(4&t){var r=new Uint8Array(e.response,0,3);return 68===r[0]&&68===r[1]&&83===r[2]}}catch(e){}return!1},e.IsUASupportingBlobStorage=!0,e.IDBStorageEnabled=!1,e._ParseURL=function(e){document.createElement("a").href=e;var t=e.substring(0,e.lastIndexOf("#")),i=e.substring(t.lastIndexOf("/")+1,e.length);return e.substring(0,e.indexOf(i,0))},e._ReturnFullUrlLocation=function(t){return-1===t.indexOf("http:/")&&-1===t.indexOf("https:/")?e._ParseURL(window.location.href)+t:t},e}(),Is=function(){function e(){this.direction1=new o.x(0,1,0),this.direction2=new o.x(0,1,0),this.minEmitBox=new o.x(-.5,-.5,-.5),this.maxEmitBox=new o.x(.5,.5,.5)}return e.prototype.startDirectionFunction=function(e,t,i){var r=D.a.RandomRange(this.direction1.x,this.direction2.x),n=D.a.RandomRange(this.direction1.y,this.direction2.y),s=D.a.RandomRange(this.direction1.z,this.direction2.z);o.x.TransformNormalFromFloatsToRef(r,n,s,e,t)},e.prototype.startPositionFunction=function(e,t,i){var r=D.a.RandomRange(this.minEmitBox.x,this.maxEmitBox.x),n=D.a.RandomRange(this.minEmitBox.y,this.maxEmitBox.y),s=D.a.RandomRange(this.minEmitBox.z,this.maxEmitBox.z);o.x.TransformCoordinatesFromFloatsToRef(r,n,s,e,t)},e.prototype.clone=function(){var t=new e;return S.a.DeepCopy(this,t),t},e.prototype.applyToShader=function(e){e.setVector3("direction1",this.direction1),e.setVector3("direction2",this.direction2),e.setVector3("minEmitBox",this.minEmitBox),e.setVector3("maxEmitBox",this.maxEmitBox)},e.prototype.getEffectDefines=function(){return"#define BOXEMITTER"},e.prototype.getClassName=function(){return"BoxParticleEmitter"},e.prototype.serialize=function(){var e={};return e.type=this.getClassName(),e.direction1=this.direction1.asArray(),e.direction2=this.direction2.asArray(),e.minEmitBox=this.minEmitBox.asArray(),e.maxEmitBox=this.maxEmitBox.asArray(),e},e.prototype.parse=function(e){o.x.FromArrayToRef(e.direction1,0,this.direction1),o.x.FromArrayToRef(e.direction2,0,this.direction2),o.x.FromArrayToRef(e.minEmitBox,0,this.minEmitBox),o.x.FromArrayToRef(e.maxEmitBox,0,this.maxEmitBox)},e}(),Ds=function(){function e(e,t,i){void 0===e&&(e=1),void 0===t&&(t=Math.PI),void 0===i&&(i=0),this.directionRandomizer=i,this.radiusRange=1,this.heightRange=1,this.emitFromSpawnPointOnly=!1,this.angle=t,this.radius=e}return Object.defineProperty(e.prototype,"radius",{get:function(){return this._radius},set:function(e){this._radius=e,this._buildHeight()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"angle",{get:function(){return this._angle},set:function(e){this._angle=e,this._buildHeight()},enumerable:!0,configurable:!0}),e.prototype._buildHeight=function(){0!==this._angle?this._height=this._radius/Math.tan(this._angle/2):this._height=1},e.prototype.startDirectionFunction=function(e,t,i){if(1===Math.abs(Math.cos(this._angle)))o.x.TransformNormalFromFloatsToRef(0,1,0,e,t);else{var r=i.position.subtract(e.getTranslation()).normalize(),n=D.a.RandomRange(0,this.directionRandomizer),s=D.a.RandomRange(0,this.directionRandomizer),a=D.a.RandomRange(0,this.directionRandomizer);r.x+=n,r.y+=s,r.z+=a,r.normalize(),o.x.TransformNormalFromFloatsToRef(r.x,r.y,r.z,e,t)}},e.prototype.startPositionFunction=function(e,t,i){var r,n=D.a.RandomRange(0,2*Math.PI);r=this.emitFromSpawnPointOnly?1e-4:1-(r=D.a.RandomRange(0,this.heightRange))*r;var s=this._radius-D.a.RandomRange(0,this._radius*this.radiusRange),a=(s*=r)*Math.sin(n),c=s*Math.cos(n),l=r*this._height;o.x.TransformCoordinatesFromFloatsToRef(a,l,c,e,t)},e.prototype.clone=function(){var t=new e(this._radius,this._angle,this.directionRandomizer);return S.a.DeepCopy(this,t),t},e.prototype.applyToShader=function(e){e.setFloat2("radius",this._radius,this.radiusRange),e.setFloat("coneAngle",this._angle),e.setFloat2("height",this._height,this.heightRange),e.setFloat("directionRandomizer",this.directionRandomizer)},e.prototype.getEffectDefines=function(){var e="#define CONEEMITTER";return this.emitFromSpawnPointOnly&&(e+="\n#define CONEEMITTERSPAWNPOINT"),e},e.prototype.getClassName=function(){return"ConeParticleEmitter"},e.prototype.serialize=function(){var e={};return e.type=this.getClassName(),e.radius=this._radius,e.angle=this._angle,e.directionRandomizer=this.directionRandomizer,e},e.prototype.parse=function(e){this.radius=e.radius,this.angle=e.angle,this.directionRandomizer=e.directionRandomizer},e}(),ws=function(){function e(e,t,i,r){void 0===e&&(e=1),void 0===t&&(t=1),void 0===i&&(i=1),void 0===r&&(r=0),this.radius=e,this.height=t,this.radiusRange=i,this.directionRandomizer=r}return e.prototype.startDirectionFunction=function(e,t,i){var r=i.position.subtract(e.getTranslation()).normalize(),n=D.a.RandomRange(-this.directionRandomizer/2,this.directionRandomizer/2),s=Math.atan2(r.x,r.z);s+=D.a.RandomRange(-Math.PI/2,Math.PI/2)*this.directionRandomizer,r.y=n,r.x=Math.sin(s),r.z=Math.cos(s),r.normalize(),o.x.TransformNormalFromFloatsToRef(r.x,r.y,r.z,e,t)},e.prototype.startPositionFunction=function(e,t,i){var r=D.a.RandomRange(-this.height/2,this.height/2),n=D.a.RandomRange(0,2*Math.PI),s=D.a.RandomRange((1-this.radiusRange)*(1-this.radiusRange),1),a=Math.sqrt(s)*this.radius,c=a*Math.cos(n),l=a*Math.sin(n);o.x.TransformCoordinatesFromFloatsToRef(c,r,l,e,t)},e.prototype.clone=function(){var t=new e(this.radius,this.directionRandomizer);return S.a.DeepCopy(this,t),t},e.prototype.applyToShader=function(e){e.setFloat("radius",this.radius),e.setFloat("height",this.height),e.setFloat("radiusRange",this.radiusRange),e.setFloat("directionRandomizer",this.directionRandomizer)},e.prototype.getEffectDefines=function(){return"#define CYLINDEREMITTER"},e.prototype.getClassName=function(){return"CylinderParticleEmitter"},e.prototype.serialize=function(){var e={};return e.type=this.getClassName(),e.radius=this.radius,e.height=this.height,e.radiusRange=this.radiusRange,e.directionRandomizer=this.directionRandomizer,e},e.prototype.parse=function(e){this.radius=e.radius,this.height=e.height,this.radiusRange=e.radiusRange,this.directionRandomizer=e.directionRandomizer},e}(),Ls=function(e){function t(t,i,r,n,s){void 0===t&&(t=1),void 0===i&&(i=1),void 0===r&&(r=1),void 0===n&&(n=new o.x(0,1,0)),void 0===s&&(s=new o.x(0,1,0));var a=e.call(this,t,i,r)||this;return a.direction1=n,a.direction2=s,a}return l.d(t,e),t.prototype.startDirectionFunction=function(e,t,i){var r=D.a.RandomRange(this.direction1.x,this.direction2.x),n=D.a.RandomRange(this.direction1.y,this.direction2.y),s=D.a.RandomRange(this.direction1.z,this.direction2.z);o.x.TransformNormalFromFloatsToRef(r,n,s,e,t)},t.prototype.clone=function(){var e=new t(this.radius,this.height,this.radiusRange,this.direction1,this.direction2);return S.a.DeepCopy(this,e),e},t.prototype.applyToShader=function(e){e.setFloat("radius",this.radius),e.setFloat("height",this.height),e.setFloat("radiusRange",this.radiusRange),e.setVector3("direction1",this.direction1),e.setVector3("direction2",this.direction2)},t.prototype.getEffectDefines=function(){return"#define CYLINDEREMITTER\n#define DIRECTEDCYLINDEREMITTER"},t.prototype.getClassName=function(){return"CylinderDirectedParticleEmitter"},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return t.direction1=this.direction1.asArray(),t.direction2=this.direction2.asArray(),t},t.prototype.parse=function(t){e.prototype.parse.call(this,t),this.direction1.copyFrom(t.direction1),this.direction2.copyFrom(t.direction2)},t}(ws),Fs=function(){function e(e,t,i){void 0===e&&(e=1),void 0===t&&(t=1),void 0===i&&(i=0),this.radius=e,this.radiusRange=t,this.directionRandomizer=i}return e.prototype.startDirectionFunction=function(e,t,i){var r=i.position.subtract(e.getTranslation()).normalize(),n=D.a.RandomRange(0,this.directionRandomizer),s=D.a.RandomRange(0,this.directionRandomizer),a=D.a.RandomRange(0,this.directionRandomizer);r.x+=n,r.y+=s,r.z+=a,r.normalize(),o.x.TransformNormalFromFloatsToRef(r.x,r.y,r.z,e,t)},e.prototype.startPositionFunction=function(e,t,i){var r=this.radius-D.a.RandomRange(0,this.radius*this.radiusRange),n=D.a.RandomRange(0,1),s=D.a.RandomRange(0,2*Math.PI),a=Math.acos(2*n-1),c=r*Math.cos(s)*Math.sin(a),l=r*Math.cos(a),u=r*Math.sin(s)*Math.sin(a);o.x.TransformCoordinatesFromFloatsToRef(c,Math.abs(l),u,e,t)},e.prototype.clone=function(){var t=new e(this.radius,this.directionRandomizer);return S.a.DeepCopy(this,t),t},e.prototype.applyToShader=function(e){e.setFloat("radius",this.radius),e.setFloat("radiusRange",this.radiusRange),e.setFloat("directionRandomizer",this.directionRandomizer)},e.prototype.getEffectDefines=function(){return"#define HEMISPHERICEMITTER"},e.prototype.getClassName=function(){return"HemisphericParticleEmitter"},e.prototype.serialize=function(){var e={};return e.type=this.getClassName(),e.radius=this.radius,e.radiusRange=this.radiusRange,e.directionRandomizer=this.directionRandomizer,e},e.prototype.parse=function(e){this.radius=e.radius,this.radiusRange=e.radiusRange,this.directionRandomizer=e.directionRandomizer},e}(),Ns=function(){function e(){this.direction1=new o.x(0,1,0),this.direction2=new o.x(0,1,0)}return e.prototype.startDirectionFunction=function(e,t,i){var r=D.a.RandomRange(this.direction1.x,this.direction2.x),n=D.a.RandomRange(this.direction1.y,this.direction2.y),s=D.a.RandomRange(this.direction1.z,this.direction2.z);o.x.TransformNormalFromFloatsToRef(r,n,s,e,t)},e.prototype.startPositionFunction=function(e,t,i){o.x.TransformCoordinatesFromFloatsToRef(0,0,0,e,t)},e.prototype.clone=function(){var t=new e;return S.a.DeepCopy(this,t),t},e.prototype.applyToShader=function(e){e.setVector3("direction1",this.direction1),e.setVector3("direction2",this.direction2)},e.prototype.getEffectDefines=function(){return"#define POINTEMITTER"},e.prototype.getClassName=function(){return"PointParticleEmitter"},e.prototype.serialize=function(){var e={};return e.type=this.getClassName(),e.direction1=this.direction1.asArray(),e.direction2=this.direction2.asArray(),e},e.prototype.parse=function(e){o.x.FromArrayToRef(e.direction1,0,this.direction1),o.x.FromArrayToRef(e.direction2,0,this.direction2)},e}(),Bs=function(){function e(e,t,i){void 0===e&&(e=1),void 0===t&&(t=1),void 0===i&&(i=0),this.radius=e,this.radiusRange=t,this.directionRandomizer=i}return e.prototype.startDirectionFunction=function(e,t,i){var r=i.position.subtract(e.getTranslation()).normalize(),n=D.a.RandomRange(0,this.directionRandomizer),s=D.a.RandomRange(0,this.directionRandomizer),a=D.a.RandomRange(0,this.directionRandomizer);r.x+=n,r.y+=s,r.z+=a,r.normalize(),o.x.TransformNormalFromFloatsToRef(r.x,r.y,r.z,e,t)},e.prototype.startPositionFunction=function(e,t,i){var r=this.radius-D.a.RandomRange(0,this.radius*this.radiusRange),n=D.a.RandomRange(0,1),s=D.a.RandomRange(0,2*Math.PI),a=Math.acos(2*n-1),c=r*Math.cos(s)*Math.sin(a),l=r*Math.cos(a),u=r*Math.sin(s)*Math.sin(a);o.x.TransformCoordinatesFromFloatsToRef(c,l,u,e,t)},e.prototype.clone=function(){var t=new e(this.radius,this.directionRandomizer);return S.a.DeepCopy(this,t),t},e.prototype.applyToShader=function(e){e.setFloat("radius",this.radius),e.setFloat("radiusRange",this.radiusRange),e.setFloat("directionRandomizer",this.directionRandomizer)},e.prototype.getEffectDefines=function(){return"#define SPHEREEMITTER"},e.prototype.getClassName=function(){return"SphereParticleEmitter"},e.prototype.serialize=function(){var e={};return e.type=this.getClassName(),e.radius=this.radius,e.radiusRange=this.radiusRange,e.directionRandomizer=this.directionRandomizer,e},e.prototype.parse=function(e){this.radius=e.radius,this.radiusRange=e.radiusRange,this.directionRandomizer=e.directionRandomizer},e}(),Us=function(e){function t(t,i,r){void 0===t&&(t=1),void 0===i&&(i=new o.x(0,1,0)),void 0===r&&(r=new o.x(0,1,0));var n=e.call(this,t)||this;return n.direction1=i,n.direction2=r,n}return l.d(t,e),t.prototype.startDirectionFunction=function(e,t,i){var r=D.a.RandomRange(this.direction1.x,this.direction2.x),n=D.a.RandomRange(this.direction1.y,this.direction2.y),s=D.a.RandomRange(this.direction1.z,this.direction2.z);o.x.TransformNormalFromFloatsToRef(r,n,s,e,t)},t.prototype.clone=function(){var e=new t(this.radius,this.direction1,this.direction2);return S.a.DeepCopy(this,e),e},t.prototype.applyToShader=function(e){e.setFloat("radius",this.radius),e.setFloat("radiusRange",this.radiusRange),e.setVector3("direction1",this.direction1),e.setVector3("direction2",this.direction2)},t.prototype.getEffectDefines=function(){return"#define SPHEREEMITTER\n#define DIRECTEDSPHEREEMITTER"},t.prototype.getClassName=function(){return"SphereDirectedParticleEmitter"},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return t.direction1=this.direction1.asArray(),t.direction2=this.direction2.asArray(),t},t.prototype.parse=function(t){e.prototype.parse.call(this,t),this.direction1.copyFrom(t.direction1),this.direction2.copyFrom(t.direction2)},t}(Bs),Vs=function(){function e(t){this.animations=[],this.renderingGroupId=0,this.emitter=null,this.emitRate=10,this.manualEmitCount=-1,this.updateSpeed=.01,this.targetStopDuration=0,this.disposeOnStop=!1,this.minEmitPower=1,this.maxEmitPower=1,this.minLifeTime=1,this.maxLifeTime=1,this.minSize=1,this.maxSize=1,this.minScaleX=1,this.maxScaleX=1,this.minScaleY=1,this.maxScaleY=1,this.minInitialRotation=0,this.maxInitialRotation=0,this.minAngularSpeed=0,this.maxAngularSpeed=0,this.layerMask=268435455,this.customShader=null,this.preventAutoStart=!1,this.noiseStrength=new o.x(10,10,10),this.onAnimationEnd=null,this.blendMode=e.BLENDMODE_ONEONE,this.forceDepthWrite=!1,this.preWarmCycles=0,this.preWarmStepOffset=1,this.spriteCellChangeSpeed=1,this.startSpriteCellID=0,this.endSpriteCellID=0,this.spriteCellWidth=0,this.spriteCellHeight=0,this.spriteRandomStartCell=!1,this.translationPivot=new o.w(0,0),this.beginAnimationOnStart=!1,this.beginAnimationFrom=0,this.beginAnimationTo=60,this.beginAnimationLoop=!1,this.gravity=o.x.Zero(),this._colorGradients=null,this._sizeGradients=null,this._lifeTimeGradients=null,this._angularSpeedGradients=null,this._velocityGradients=null,this._limitVelocityGradients=null,this._dragGradients=null,this._emitRateGradients=null,this._startSizeGradients=null,this._rampGradients=null,this._colorRemapGradients=null,this._alphaRemapGradients=null,this.startDelay=0,this.limitVelocityDamping=.4,this.color1=new o.f(1,1,1,1),this.color2=new o.f(1,1,1,1),this.colorDead=new o.f(0,0,0,1),this.textureMask=new o.f(1,1,1,1),this._isSubEmitter=!1,this.billboardMode=_.a.PARTICLES_BILLBOARDMODE_ALL,this._isBillboardBased=!0,this._imageProcessingConfigurationDefines=new ui.b,this.id=t,this.name=t}return Object.defineProperty(e.prototype,"noiseTexture",{get:function(){return this._noiseTexture},set:function(e){this._noiseTexture!==e&&(this._noiseTexture=e,this._reset())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isAnimationSheetEnabled",{get:function(){return this._isAnimationSheetEnabled},set:function(e){this._isAnimationSheetEnabled!=e&&(this._isAnimationSheetEnabled=e,this._reset())},enumerable:!0,configurable:!0}),e.prototype.getScene=function(){return this._scene},e.prototype._hasTargetStopDurationDependantGradient=function(){return this._startSizeGradients&&this._startSizeGradients.length>0||this._emitRateGradients&&this._emitRateGradients.length>0||this._lifeTimeGradients&&this._lifeTimeGradients.length>0},e.prototype.getDragGradients=function(){return this._dragGradients},e.prototype.getLimitVelocityGradients=function(){return this._limitVelocityGradients},e.prototype.getColorGradients=function(){return this._colorGradients},e.prototype.getSizeGradients=function(){return this._sizeGradients},e.prototype.getColorRemapGradients=function(){return this._colorRemapGradients},e.prototype.getAlphaRemapGradients=function(){return this._alphaRemapGradients},e.prototype.getLifeTimeGradients=function(){return this._lifeTimeGradients},e.prototype.getAngularSpeedGradients=function(){return this._angularSpeedGradients},e.prototype.getVelocityGradients=function(){return this._velocityGradients},e.prototype.getStartSizeGradients=function(){return this._startSizeGradients},e.prototype.getEmitRateGradients=function(){return this._emitRateGradients},Object.defineProperty(e.prototype,"direction1",{get:function(){return this.particleEmitterType.direction1?this.particleEmitterType.direction1:o.x.Zero()},set:function(e){this.particleEmitterType.direction1&&(this.particleEmitterType.direction1=e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"direction2",{get:function(){return this.particleEmitterType.direction2?this.particleEmitterType.direction2:o.x.Zero()},set:function(e){this.particleEmitterType.direction2&&(this.particleEmitterType.direction2=e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"minEmitBox",{get:function(){return this.particleEmitterType.minEmitBox?this.particleEmitterType.minEmitBox:o.x.Zero()},set:function(e){this.particleEmitterType.minEmitBox&&(this.particleEmitterType.minEmitBox=e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"maxEmitBox",{get:function(){return this.particleEmitterType.maxEmitBox?this.particleEmitterType.maxEmitBox:o.x.Zero()},set:function(e){this.particleEmitterType.maxEmitBox&&(this.particleEmitterType.maxEmitBox=e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isBillboardBased",{get:function(){return this._isBillboardBased},set:function(e){this._isBillboardBased!==e&&(this._isBillboardBased=e,this._reset())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"imageProcessingConfiguration",{get:function(){return this._imageProcessingConfiguration},set:function(e){this._attachImageProcessingConfiguration(e)},enumerable:!0,configurable:!0}),e.prototype._attachImageProcessingConfiguration=function(e){e!==this._imageProcessingConfiguration&&(this._imageProcessingConfiguration=e||this._scene.imageProcessingConfiguration)},e.prototype._reset=function(){},e.prototype._removeGradientAndTexture=function(e,t,i){if(!t)return this;for(var r=0,n=0,o=t;n<o.length;n++){if(o[n].gradient===e){t.splice(r,1);break}r++}return i&&i.dispose(),this},e.prototype.createPointEmitter=function(e,t){var i=new Ns;return i.direction1=e,i.direction2=t,this.particleEmitterType=i,i},e.prototype.createHemisphericEmitter=function(e,t){void 0===e&&(e=1),void 0===t&&(t=1);var i=new Fs(e,t);return this.particleEmitterType=i,i},e.prototype.createSphereEmitter=function(e,t){void 0===e&&(e=1),void 0===t&&(t=1);var i=new Bs(e,t);return this.particleEmitterType=i,i},e.prototype.createDirectedSphereEmitter=function(e,t,i){void 0===e&&(e=1),void 0===t&&(t=new o.x(0,1,0)),void 0===i&&(i=new o.x(0,1,0));var r=new Us(e,t,i);return this.particleEmitterType=r,r},e.prototype.createCylinderEmitter=function(e,t,i,r){void 0===e&&(e=1),void 0===t&&(t=1),void 0===i&&(i=1),void 0===r&&(r=0);var n=new ws(e,t,i,r);return this.particleEmitterType=n,n},e.prototype.createDirectedCylinderEmitter=function(e,t,i,r,n){void 0===e&&(e=1),void 0===t&&(t=1),void 0===i&&(i=1),void 0===r&&(r=new o.x(0,1,0)),void 0===n&&(n=new o.x(0,1,0));var s=new Ls(e,t,i,r,n);return this.particleEmitterType=s,s},e.prototype.createConeEmitter=function(e,t){void 0===e&&(e=1),void 0===t&&(t=Math.PI/4);var i=new Ds(e,t);return this.particleEmitterType=i,i},e.prototype.createBoxEmitter=function(e,t,i,r){var n=new Is;return this.particleEmitterType=n,this.direction1=e,this.direction2=t,this.minEmitBox=i,this.maxEmitBox=r,n},e.BLENDMODE_ONEONE=0,e.BLENDMODE_STANDARD=1,e.BLENDMODE_ADD=2,e.BLENDMODE_MULTIPLY=3,e.BLENDMODE_MULTIPLYADD=4,e}(),Gs=function(){function e(t){this.particleSystem=t,this.position=o.x.Zero(),this.direction=o.x.Zero(),this.color=new o.f(0,0,0,0),this.colorStep=new o.f(0,0,0,0),this.lifeTime=1,this.age=0,this.size=0,this.scale=new o.w(1,1),this.angle=0,this.angularSpeed=0,this.cellIndex=0,this._attachedSubEmitters=null,this._currentColor1=new o.f(0,0,0,0),this._currentColor2=new o.f(0,0,0,0),this._currentSize1=0,this._currentSize2=0,this._currentAngularSpeed1=0,this._currentAngularSpeed2=0,this._currentVelocity1=0,this._currentVelocity2=0,this._currentLimitVelocity1=0,this._currentLimitVelocity2=0,this._currentDrag1=0,this._currentDrag2=0,this.id=e._Count++,this.particleSystem.isAnimationSheetEnabled&&this.updateCellInfoFromSystem()}return e.prototype.updateCellInfoFromSystem=function(){this.cellIndex=this.particleSystem.startSpriteCellID},e.prototype.updateCellIndex=function(){var e=this.age,t=this.particleSystem.spriteCellChangeSpeed;this.particleSystem.spriteRandomStartCell&&(void 0===this._randomCellOffset&&(this._randomCellOffset=Math.random()*this.lifeTime),0===t?(t=1,e=this._randomCellOffset):e+=this._randomCellOffset);var i=this._initialEndSpriteCellID-this._initialStartSpriteCellID,r=D.a.Clamp(e*t%this.lifeTime/this.lifeTime);this.cellIndex=this._initialStartSpriteCellID+r*i|0},e.prototype._inheritParticleInfoToSubEmitter=function(e){if(e.particleSystem.emitter.position){var t=e.particleSystem.emitter;t.position.copyFrom(this.position),e.inheritDirection&&(t.position.subtractToRef(this.direction,o.t.Vector3[0]),t.lookAt(o.t.Vector3[0],0,Math.PI/2))}else{e.particleSystem.emitter.copyFrom(this.position)}this.direction.scaleToRef(e.inheritedVelocityAmount/2,o.t.Vector3[0]),e.particleSystem._inheritedVelocityOffset.copyFrom(o.t.Vector3[0])},e.prototype._inheritParticleInfoToSubEmitters=function(){var e=this;this._attachedSubEmitters&&this._attachedSubEmitters.length>0&&this._attachedSubEmitters.forEach(function(t){e._inheritParticleInfoToSubEmitter(t)})},e.prototype._reset=function(){this.age=0,this._currentColorGradient=null,this._currentSizeGradient=null,this._currentAngularSpeedGradient=null,this._currentVelocityGradient=null,this._currentLimitVelocityGradient=null,this._currentDragGradient=null,this.cellIndex=this.particleSystem.startSpriteCellID,this._randomCellOffset=void 0},e.prototype.copyTo=function(e){e.position.copyFrom(this.position),this._initialDirection?e._initialDirection?e._initialDirection.copyFrom(this._initialDirection):e._initialDirection=this._initialDirection.clone():e._initialDirection=null,e.direction.copyFrom(this.direction),e.color.copyFrom(this.color),e.colorStep.copyFrom(this.colorStep),e.lifeTime=this.lifeTime,e.age=this.age,e._randomCellOffset=this._randomCellOffset,e.size=this.size,e.scale.copyFrom(this.scale),e.angle=this.angle,e.angularSpeed=this.angularSpeed,e.particleSystem=this.particleSystem,e.cellIndex=this.cellIndex,e.id=this.id,e._attachedSubEmitters=this._attachedSubEmitters,this._currentColorGradient&&(e._currentColorGradient=this._currentColorGradient,e._currentColor1.copyFrom(this._currentColor1),e._currentColor2.copyFrom(this._currentColor2)),this._currentSizeGradient&&(e._currentSizeGradient=this._currentSizeGradient,e._currentSize1=this._currentSize1,e._currentSize2=this._currentSize2),this._currentAngularSpeedGradient&&(e._currentAngularSpeedGradient=this._currentAngularSpeedGradient,e._currentAngularSpeed1=this._currentAngularSpeed1,e._currentAngularSpeed2=this._currentAngularSpeed2),this._currentVelocityGradient&&(e._currentVelocityGradient=this._currentVelocityGradient,e._currentVelocity1=this._currentVelocity1,e._currentVelocity2=this._currentVelocity2),this._currentLimitVelocityGradient&&(e._currentLimitVelocityGradient=this._currentLimitVelocityGradient,e._currentLimitVelocity1=this._currentLimitVelocity1,e._currentLimitVelocity2=this._currentLimitVelocity2),this._currentDragGradient&&(e._currentDragGradient=this._currentDragGradient,e._currentDrag1=this._currentDrag1,e._currentDrag2=this._currentDrag2),this.particleSystem.isAnimationSheetEnabled&&(e._initialStartSpriteCellID=this._initialStartSpriteCellID,e._initialEndSpriteCellID=this._initialEndSpriteCellID),this.particleSystem.useRampGradients&&e.remapData.copyFrom(this.remapData),this._randomNoiseCoordinates1&&(e._randomNoiseCoordinates1?(e._randomNoiseCoordinates1.copyFrom(this._randomNoiseCoordinates1),e._randomNoiseCoordinates2.copyFrom(this._randomNoiseCoordinates2)):(e._randomNoiseCoordinates1=this._randomNoiseCoordinates1.clone(),e._randomNoiseCoordinates2=this._randomNoiseCoordinates2.clone()))},e._Count=0,e}();!function(e){e[e.ATTACHED=0]="ATTACHED",e[e.END=1]="END"}(Ms||(Ms={}));var ks=function(){function e(e){this.particleSystem=e,this.type=Ms.END,this.inheritDirection=!1,this.inheritedVelocityAmount=0,e.emitter&&e.emitter.dispose||(e.emitter=new we.a("SubemitterSystemEmitter",e.getScene())),e.onDisposeObservable.add(function(){e.emitter&&e.emitter.dispose&&e.emitter.dispose()})}return e.prototype.clone=function(){var t=this.particleSystem.emitter;t?t instanceof o.x?t=t.clone():t instanceof we.a&&((t=new de.a("",t.getScene())).isVisible=!1):t=new o.x;var i=new e(this.particleSystem.clone("",t));return i.type=this.type,i.inheritDirection=this.inheritDirection,i.inheritedVelocityAmount=this.inheritedVelocityAmount,i.particleSystem._disposeEmitterOnDispose=!0,i.particleSystem.disposeOnStop=!0,i},e.prototype.serialize=function(){var e={};return e.type=this.type,e.inheritDirection=this.inheritDirection,e.inheritedVelocityAmount=this.inheritedVelocityAmount,e.particleSystem=this.particleSystem.serialize(),e},e._ParseParticleSystem=function(e,t,i){throw"Import ParseParticle before parsing SubEmitter."},e.Parse=function(t,i,r){var n=t.particleSystem,o=new e(e._ParseParticleSystem(n,i,r));return o.type=t.type,o.inheritDirection=t.inheritDirection,o.inheritedVelocityAmount=t.inheritedVelocityAmount,o.particleSystem._isSubEmitter=!0,o},e.prototype.dispose=function(){this.particleSystem.dispose()},e}(),zs="\nvarying vec2 vUV;\nvarying vec4 vColor;\nuniform vec4 textureMask;\nuniform sampler2D diffuseSampler;\n#include<clipPlaneFragmentDeclaration>\n#include<imageProcessingDeclaration>\n#include<helperFunctions>\n#include<imageProcessingFunctions>\n#ifdef RAMPGRADIENT\nvarying vec4 remapRanges;\nuniform sampler2D rampSampler;\n#endif\nvoid main(void) {\n#include<clipPlaneFragment>\nvec4 textureColor=texture2D(diffuseSampler,vUV);\nvec4 baseColor=(textureColor*textureMask+(vec4(1.,1.,1.,1.)-textureMask))*vColor;\n#ifdef RAMPGRADIENT\nfloat alpha=baseColor.a;\nfloat remappedColorIndex=clamp((alpha-remapRanges.x)/remapRanges.y,0.0,1.0);\nvec4 rampColor=texture2D(rampSampler,vec2(1.0-remappedColorIndex,0.));\nbaseColor.rgb*=rampColor.rgb;\n\nfloat finalAlpha=baseColor.a;\nbaseColor.a=clamp((alpha*rampColor.a-remapRanges.z)/remapRanges.w,0.0,1.0);\n#endif\n#ifdef BLENDMULTIPLYMODE\nfloat sourceAlpha=vColor.a*textureColor.a;\nbaseColor.rgb=baseColor.rgb*sourceAlpha+vec3(1.0)*(1.0-sourceAlpha);\n#endif\n\n\n#ifdef IMAGEPROCESSINGPOSTPROCESS\nbaseColor.rgb=toLinearSpace(baseColor.rgb);\n#else\n#ifdef IMAGEPROCESSING\nbaseColor.rgb=toLinearSpace(baseColor.rgb);\nbaseColor=applyImageProcessing(baseColor);\n#endif\n#endif\ngl_FragColor=baseColor;\n}";St.a.ShadersStore.particlesPixelShader=zs;var js="\nattribute vec3 position;\nattribute vec4 color;\nattribute float angle;\nattribute vec2 size;\n#ifdef ANIMATESHEET\nattribute float cellIndex;\n#endif\n#ifndef BILLBOARD\nattribute vec3 direction;\n#endif\n#ifdef BILLBOARDSTRETCHED\nattribute vec3 direction;\n#endif\n#ifdef RAMPGRADIENT\nattribute vec4 remapData;\n#endif\nattribute vec2 offset;\n\nuniform mat4 view;\nuniform mat4 projection;\nuniform vec2 translationPivot;\n#ifdef ANIMATESHEET\nuniform vec3 particlesInfos;\n#endif\n\nvarying vec2 vUV;\nvarying vec4 vColor;\n#ifdef RAMPGRADIENT\nvarying vec4 remapRanges;\n#endif\n#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4)\nuniform mat4 invView;\n#endif\n#include<clipPlaneVertexDeclaration>\n#ifdef BILLBOARD\nuniform vec3 eyePosition;\n#endif\nvec3 rotate(vec3 yaxis,vec3 rotatedCorner) {\nvec3 xaxis=normalize(cross(vec3(0.,1.0,0.),yaxis));\nvec3 zaxis=normalize(cross(yaxis,xaxis));\nvec3 row0=vec3(xaxis.x,xaxis.y,xaxis.z);\nvec3 row1=vec3(yaxis.x,yaxis.y,yaxis.z);\nvec3 row2=vec3(zaxis.x,zaxis.y,zaxis.z);\nmat3 rotMatrix=mat3(row0,row1,row2);\nvec3 alignedCorner=rotMatrix*rotatedCorner;\nreturn position+alignedCorner;\n}\n#ifdef BILLBOARDSTRETCHED\nvec3 rotateAlign(vec3 toCamera,vec3 rotatedCorner) {\nvec3 normalizedToCamera=normalize(toCamera);\nvec3 normalizedCrossDirToCamera=normalize(cross(normalize(direction),normalizedToCamera));\nvec3 crossProduct=normalize(cross(normalizedToCamera,normalizedCrossDirToCamera));\nvec3 row0=vec3(normalizedCrossDirToCamera.x,normalizedCrossDirToCamera.y,normalizedCrossDirToCamera.z);\nvec3 row1=vec3(crossProduct.x,crossProduct.y,crossProduct.z);\nvec3 row2=vec3(normalizedToCamera.x,normalizedToCamera.y,normalizedToCamera.z);\nmat3 rotMatrix=mat3(row0,row1,row2);\nvec3 alignedCorner=rotMatrix*rotatedCorner;\nreturn position+alignedCorner;\n}\n#endif\nvoid main(void) {\nvec2 cornerPos;\ncornerPos=(vec2(offset.x-0.5,offset.y-0.5)-translationPivot)*size+translationPivot;\n#ifdef BILLBOARD\n\nvec3 rotatedCorner;\n#ifdef BILLBOARDY\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.y=0.;\nvec3 yaxis=position-eyePosition;\nyaxis.y=0.;\nvec3 worldPos=rotate(normalize(yaxis),rotatedCorner);\nvec3 viewPos=(view*vec4(worldPos,1.0)).xyz;\n#elif defined(BILLBOARDSTRETCHED)\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.z=0.;\nvec3 toCamera=position-eyePosition;\nvec3 worldPos=rotateAlign(toCamera,rotatedCorner);\nvec3 viewPos=(view*vec4(worldPos,1.0)).xyz;\n#else\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.z=0.;\nvec3 viewPos=(view*vec4(position,1.0)).xyz+rotatedCorner;\n#endif\n#ifdef RAMPGRADIENT\nremapRanges=remapData;\n#endif\n\ngl_Position=projection*vec4(viewPos,1.0);\n#else\n\nvec3 rotatedCorner;\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.y=0.;\nvec3 yaxis=normalize(direction);\nvec3 worldPos=rotate(yaxis,rotatedCorner);\ngl_Position=projection*view*vec4(worldPos,1.0);\n#endif\nvColor=color;\n#ifdef ANIMATESHEET\nfloat rowOffset=floor(cellIndex/particlesInfos.z);\nfloat columnOffset=cellIndex-rowOffset*particlesInfos.z;\nvec2 uvScale=particlesInfos.xy;\nvec2 uvOffset=vec2(offset.x ,1.0-offset.y);\nvUV=(uvOffset+vec2(columnOffset,rowOffset))*uvScale;\n#else\nvUV=offset;\n#endif\n\n#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4)\nvec4 worldPos=invView*vec4(viewPos,1.0);\n#endif\n#include<clipPlaneVertex>\n}";St.a.ShadersStore.particlesVertexShader=js;var Ws=function(e){function t(t,i,r,s,a,c){void 0===s&&(s=null),void 0===a&&(a=!1),void 0===c&&(c=.01);var l=e.call(this,t)||this;return l._inheritedVelocityOffset=new o.x,l.onDisposeObservable=new n.c,l._particles=new Array,l._stockParticles=new Array,l._newPartsExcess=0,l._vertexBuffers={},l._scaledColorStep=new o.f(0,0,0,0),l._colorDiff=new o.f(0,0,0,0),l._scaledDirection=o.x.Zero(),l._scaledGravity=o.x.Zero(),l._currentRenderId=-1,l._useInstancing=!1,l._started=!1,l._stopped=!1,l._actualFrame=0,l._currentEmitRate1=0,l._currentEmitRate2=0,l._currentStartSize1=0,l._currentStartSize2=0,l._rawTextureWidth=256,l._useRampGradients=!1,l._disposeEmitterOnDispose=!1,l.recycleParticle=function(e){var t=l._particles.pop();t!==e&&t.copyTo(e),l._stockParticles.push(t)},l._createParticle=function(){var e;if(0!==l._stockParticles.length?(e=l._stockParticles.pop())._reset():e=new Gs(l),l._subEmitters&&l._subEmitters.length>0){var t=l._subEmitters[Math.floor(Math.random()*l._subEmitters.length)];e._attachedSubEmitters=[],t.forEach(function(t){if(t.type===Ms.ATTACHED){var i=t.clone();e._attachedSubEmitters.push(i),i.particleSystem.start()}})}return e},l._emitFromParticle=function(e){if(l._subEmitters&&0!==l._subEmitters.length){var t=Math.floor(Math.random()*l._subEmitters.length);l._subEmitters[t].forEach(function(t){if(t.type===Ms.END){var i=t.clone();e._inheritParticleInfoToSubEmitter(i),i.particleSystem._rootParticleSystem=l,l.activeSubSystems.push(i.particleSystem),i.particleSystem.start()}})}},l._capacity=i,l._epsilon=c,l._isAnimationSheetEnabled=a,l._scene=r||R.a.LastCreatedScene,l._attachImageProcessingConfiguration(null),l._customEffect=s,l._scene.particleSystems.push(l),l._useInstancing=l._scene.getEngine().getCaps().instancedArrays,l._createIndexBuffer(),l._createVertexBuffers(),l.particleEmitterType=new Is,l.updateFunction=function(e){var t=null,i=null;l.noiseTexture&&(t=l.noiseTexture.getSize(),i=l.noiseTexture.getContent());for(var r,n=function(){r=e[s];var n=l._scaledUpdateSpeed,a=r.age;if(r.age+=n,r.age>r.lifeTime){var c=r.age-a;n=(r.lifeTime-a)*n/c,r.age=r.lifeTime}var u=r.age/r.lifeTime;l._colorGradients&&l._colorGradients.length>0?ve.h.GetCurrentGradient(u,l._colorGradients,function(e,t,i){e!==r._currentColorGradient&&(r._currentColor1.copyFrom(r._currentColor2),t.getColorToRef(r._currentColor2),r._currentColorGradient=e),o.f.LerpToRef(r._currentColor1,r._currentColor2,i,r.color)}):(r.colorStep.scaleToRef(n,l._scaledColorStep),r.color.addInPlace(l._scaledColorStep),r.color.a<0&&(r.color.a=0)),l._angularSpeedGradients&&l._angularSpeedGradients.length>0&&ve.h.GetCurrentGradient(u,l._angularSpeedGradients,function(e,t,i){e!==r._currentAngularSpeedGradient&&(r._currentAngularSpeed1=r._currentAngularSpeed2,r._currentAngularSpeed2=t.getFactor(),r._currentAngularSpeedGradient=e),r.angularSpeed=D.a.Lerp(r._currentAngularSpeed1,r._currentAngularSpeed2,i)}),r.angle+=r.angularSpeed*n;var h=n;if(l._velocityGradients&&l._velocityGradients.length>0&&ve.h.GetCurrentGradient(u,l._velocityGradients,function(e,t,i){e!==r._currentVelocityGradient&&(r._currentVelocity1=r._currentVelocity2,r._currentVelocity2=t.getFactor(),r._currentVelocityGradient=e),h*=D.a.Lerp(r._currentVelocity1,r._currentVelocity2,i)}),r.direction.scaleToRef(h,l._scaledDirection),l._limitVelocityGradients&&l._limitVelocityGradients.length>0&&ve.h.GetCurrentGradient(u,l._limitVelocityGradients,function(e,t,i){e!==r._currentLimitVelocityGradient&&(r._currentLimitVelocity1=r._currentLimitVelocity2,r._currentLimitVelocity2=t.getFactor(),r._currentLimitVelocityGradient=e);var n=D.a.Lerp(r._currentLimitVelocity1,r._currentLimitVelocity2,i);r.direction.length()>n&&r.direction.scaleInPlace(l.limitVelocityDamping)}),l._dragGradients&&l._dragGradients.length>0&&ve.h.GetCurrentGradient(u,l._dragGradients,function(e,t,i){e!==r._currentDragGradient&&(r._currentDrag1=r._currentDrag2,r._currentDrag2=t.getFactor(),r._currentDragGradient=e);var n=D.a.Lerp(r._currentDrag1,r._currentDrag2,i);l._scaledDirection.scaleInPlace(1-n)}),r.position.addInPlace(l._scaledDirection),i&&t&&r._randomNoiseCoordinates1){var d=l._fetchR(r._randomNoiseCoordinates1.x,r._randomNoiseCoordinates1.y,t.width,t.height,i),f=l._fetchR(r._randomNoiseCoordinates1.z,r._randomNoiseCoordinates2.x,t.width,t.height,i),p=l._fetchR(r._randomNoiseCoordinates2.y,r._randomNoiseCoordinates2.z,t.width,t.height,i),_=o.t.Vector3[0],g=o.t.Vector3[1];_.copyFromFloats((2*d-1)*l.noiseStrength.x,(2*f-1)*l.noiseStrength.y,(2*p-1)*l.noiseStrength.z),_.scaleToRef(n,g),r.direction.addInPlace(g)}if(l.gravity.scaleToRef(n,l._scaledGravity),r.direction.addInPlace(l._scaledGravity),l._sizeGradients&&l._sizeGradients.length>0&&ve.h.GetCurrentGradient(u,l._sizeGradients,function(e,t,i){e!==r._currentSizeGradient&&(r._currentSize1=r._currentSize2,r._currentSize2=t.getFactor(),r._currentSizeGradient=e),r.size=D.a.Lerp(r._currentSize1,r._currentSize2,i)}),l._useRampGradients&&(l._colorRemapGradients&&l._colorRemapGradients.length>0&&ve.h.GetCurrentGradient(u,l._colorRemapGradients,function(e,t,i){var n=D.a.Lerp(e.factor1,t.factor1,i),o=D.a.Lerp(e.factor2,t.factor2,i);r.remapData.x=n,r.remapData.y=o-n}),l._alphaRemapGradients&&l._alphaRemapGradients.length>0&&ve.h.GetCurrentGradient(u,l._alphaRemapGradients,function(e,t,i){var n=D.a.Lerp(e.factor1,t.factor1,i),o=D.a.Lerp(e.factor2,t.factor2,i);r.remapData.z=n,r.remapData.w=o-n})),l._isAnimationSheetEnabled&&r.updateCellIndex(),r._inheritParticleInfoToSubEmitters(),r.age>=r.lifeTime)return l._emitFromParticle(r),r._attachedSubEmitters&&(r._attachedSubEmitters.forEach(function(e){e.particleSystem.disposeOnStop=!0,e.particleSystem.stop()}),r._attachedSubEmitters=null),l.recycleParticle(r),s--,"continue"},s=0;s<e.length;s++)n()},l}return l.d(t,e),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,"useRampGradients",{get:function(){return this._useRampGradients},set:function(e){this._useRampGradients!==e&&(this._useRampGradients=e,this._resetEffect())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"particles",{get:function(){return this._particles},enumerable:!0,configurable:!0}),t.prototype.getClassName=function(){return"ParticleSystem"},t.prototype._addFactorGradient=function(e,t,i,r){var n=new ve.d;n.gradient=t,n.factor1=i,n.factor2=r,e.push(n),e.sort(function(e,t){return e.gradient<t.gradient?-1:e.gradient>t.gradient?1:0})},t.prototype._removeFactorGradient=function(e,t){if(e)for(var i=0,r=0,n=e;r<n.length;r++){if(n[r].gradient===t){e.splice(i,1);break}i++}},t.prototype.addLifeTimeGradient=function(e,t,i){return this._lifeTimeGradients||(this._lifeTimeGradients=[]),this._addFactorGradient(this._lifeTimeGradients,e,t,i),this},t.prototype.removeLifeTimeGradient=function(e){return this._removeFactorGradient(this._lifeTimeGradients,e),this},t.prototype.addSizeGradient=function(e,t,i){return this._sizeGradients||(this._sizeGradients=[]),this._addFactorGradient(this._sizeGradients,e,t,i),this},t.prototype.removeSizeGradient=function(e){return this._removeFactorGradient(this._sizeGradients,e),this},t.prototype.addColorRemapGradient=function(e,t,i){return this._colorRemapGradients||(this._colorRemapGradients=[]),this._addFactorGradient(this._colorRemapGradients,e,t,i),this},t.prototype.removeColorRemapGradient=function(e){return this._removeFactorGradient(this._colorRemapGradients,e),this},t.prototype.addAlphaRemapGradient=function(e,t,i){return this._alphaRemapGradients||(this._alphaRemapGradients=[]),this._addFactorGradient(this._alphaRemapGradients,e,t,i),this},t.prototype.removeAlphaRemapGradient=function(e){return this._removeFactorGradient(this._alphaRemapGradients,e),this},t.prototype.addAngularSpeedGradient=function(e,t,i){return this._angularSpeedGradients||(this._angularSpeedGradients=[]),this._addFactorGradient(this._angularSpeedGradients,e,t,i),this},t.prototype.removeAngularSpeedGradient=function(e){return this._removeFactorGradient(this._angularSpeedGradients,e),this},t.prototype.addVelocityGradient=function(e,t,i){return this._velocityGradients||(this._velocityGradients=[]),this._addFactorGradient(this._velocityGradients,e,t,i),this},t.prototype.removeVelocityGradient=function(e){return this._removeFactorGradient(this._velocityGradients,e),this},t.prototype.addLimitVelocityGradient=function(e,t,i){return this._limitVelocityGradients||(this._limitVelocityGradients=[]),this._addFactorGradient(this._limitVelocityGradients,e,t,i),this},t.prototype.removeLimitVelocityGradient=function(e){return this._removeFactorGradient(this._limitVelocityGradients,e),this},t.prototype.addDragGradient=function(e,t,i){return this._dragGradients||(this._dragGradients=[]),this._addFactorGradient(this._dragGradients,e,t,i),this},t.prototype.removeDragGradient=function(e){return this._removeFactorGradient(this._dragGradients,e),this},t.prototype.addEmitRateGradient=function(e,t,i){return this._emitRateGradients||(this._emitRateGradients=[]),this._addFactorGradient(this._emitRateGradients,e,t,i),this},t.prototype.removeEmitRateGradient=function(e){return this._removeFactorGradient(this._emitRateGradients,e),this},t.prototype.addStartSizeGradient=function(e,t,i){return this._startSizeGradients||(this._startSizeGradients=[]),this._addFactorGradient(this._startSizeGradients,e,t,i),this},t.prototype.removeStartSizeGradient=function(e){return this._removeFactorGradient(this._emitRateGradients,e),this},t.prototype._createRampGradientTexture=function(){if(this._rampGradients&&this._rampGradients.length&&!this._rampGradientsTexture){for(var e=new Uint8Array(4*this._rawTextureWidth),t=o.t.Color3[0],i=0;i<this._rawTextureWidth;i++){var r=i/this._rawTextureWidth;ve.h.GetCurrentGradient(r,this._rampGradients,function(r,n,s){o.e.LerpToRef(r.color,n.color,s,t),e[4*i]=255*t.r,e[4*i+1]=255*t.g,e[4*i+2]=255*t.b,e[4*i+3]=255})}this._rampGradientsTexture=Ge.CreateRGBATexture(e,this._rawTextureWidth,1,this._scene,!1,!1,Ve.a.NEAREST_SAMPLINGMODE)}},t.prototype.getRampGradients=function(){return this._rampGradients},t.prototype.addRampGradient=function(e,t){this._rampGradients||(this._rampGradients=[]);var i=new ve.b;return i.gradient=e,i.color=t,this._rampGradients.push(i),this._rampGradients.sort(function(e,t){return e.gradient<t.gradient?-1:e.gradient>t.gradient?1:0}),this._rampGradientsTexture&&(this._rampGradientsTexture.dispose(),this._rampGradientsTexture=null),this._createRampGradientTexture(),this},t.prototype.removeRampGradient=function(e){return this._removeGradientAndTexture(e,this._rampGradients,this._rampGradientsTexture),this._rampGradientsTexture=null,this._rampGradients&&this._rampGradients.length>0&&this._createRampGradientTexture(),this},t.prototype.addColorGradient=function(e,t,i){this._colorGradients||(this._colorGradients=[]);var r=new ve.c;return r.gradient=e,r.color1=t,r.color2=i,this._colorGradients.push(r),this._colorGradients.sort(function(e,t){return e.gradient<t.gradient?-1:e.gradient>t.gradient?1:0}),this},t.prototype.removeColorGradient=function(e){if(!this._colorGradients)return this;for(var t=0,i=0,r=this._colorGradients;i<r.length;i++){if(r[i].gradient===e){this._colorGradients.splice(t,1);break}t++}return this},t.prototype._fetchR=function(e,t,i,r,n){return n[4*(((e=.5*Math.abs(e)+.5)*i%i|0)+((t=.5*Math.abs(t)+.5)*r%r|0)*i)]/255},t.prototype._reset=function(){this._resetEffect()},t.prototype._resetEffect=function(){this._vertexBuffer&&(this._vertexBuffer.dispose(),this._vertexBuffer=null),this._spriteBuffer&&(this._spriteBuffer.dispose(),this._spriteBuffer=null),this._createVertexBuffers()},t.prototype._createVertexBuffers=function(){this._vertexBufferSize=this._useInstancing?10:12,this._isAnimationSheetEnabled&&(this._vertexBufferSize+=1),this._isBillboardBased&&this.billboardMode!==t.BILLBOARDMODE_STRETCHED||(this._vertexBufferSize+=3),this._useRampGradients&&(this._vertexBufferSize+=4);var e=this._scene.getEngine();this._vertexData=new Float32Array(this._capacity*this._vertexBufferSize*(this._useInstancing?1:4)),this._vertexBuffer=new gi.a(e,this._vertexData,!0,this._vertexBufferSize);var i=0,r=this._vertexBuffer.createVertexBuffer(gi.b.PositionKind,i,3,this._vertexBufferSize,this._useInstancing);this._vertexBuffers[gi.b.PositionKind]=r,i+=3;var n=this._vertexBuffer.createVertexBuffer(gi.b.ColorKind,i,4,this._vertexBufferSize,this._useInstancing);this._vertexBuffers[gi.b.ColorKind]=n,i+=4;var o=this._vertexBuffer.createVertexBuffer("angle",i,1,this._vertexBufferSize,this._useInstancing);this._vertexBuffers.angle=o,i+=1;var s,a=this._vertexBuffer.createVertexBuffer("size",i,2,this._vertexBufferSize,this._useInstancing);if(this._vertexBuffers.size=a,i+=2,this._isAnimationSheetEnabled){var c=this._vertexBuffer.createVertexBuffer("cellIndex",i,1,this._vertexBufferSize,this._useInstancing);this._vertexBuffers.cellIndex=c,i+=1}if(!this._isBillboardBased||this.billboardMode===t.BILLBOARDMODE_STRETCHED){var l=this._vertexBuffer.createVertexBuffer("direction",i,3,this._vertexBufferSize,this._useInstancing);this._vertexBuffers.direction=l,i+=3}if(this._useRampGradients){var u=this._vertexBuffer.createVertexBuffer("remapData",i,4,this._vertexBufferSize,this._useInstancing);this._vertexBuffers.remapData=u,i+=4}if(this._useInstancing){var h=new Float32Array([0,0,1,0,1,1,0,1]);this._spriteBuffer=new gi.a(e,h,!1,2),s=this._spriteBuffer.createVertexBuffer("offset",0,2)}else s=this._vertexBuffer.createVertexBuffer("offset",i,2,this._vertexBufferSize,this._useInstancing),i+=2;this._vertexBuffers.offset=s},t.prototype._createIndexBuffer=function(){if(!this._useInstancing){for(var e=[],t=0,i=0;i<this._capacity;i++)e.push(t),e.push(t+1),e.push(t+2),e.push(t),e.push(t+2),e.push(t+3),t+=4;this._indexBuffer=this._scene.getEngine().createIndexBuffer(e)}},t.prototype.getCapacity=function(){return this._capacity},t.prototype.isAlive=function(){return this._alive},t.prototype.isStarted=function(){return this._started},t.prototype._prepareSubEmitterInternalArray=function(){var e=this;this._subEmitters=new Array,this.subEmitters&&this.subEmitters.forEach(function(i){i instanceof t?e._subEmitters.push([new ks(i)]):i instanceof ks?e._subEmitters.push([i]):i instanceof Array&&e._subEmitters.push(i)})},t.prototype.start=function(e){var t=this;if(void 0===e&&(e=this.startDelay),!this.targetStopDuration&&this._hasTargetStopDurationDependantGradient())throw"Particle system started with a targetStopDuration dependant gradient (eg. startSizeGradients) but no targetStopDuration set";if(e)setTimeout(function(){t.start(0)},e);else{if(this._prepareSubEmitterInternalArray(),this._started=!0,this._stopped=!1,this._actualFrame=0,this._subEmitters&&0!=this._subEmitters.length&&(this.activeSubSystems=new Array),this._emitRateGradients&&(this._emitRateGradients.length>0&&(this._currentEmitRateGradient=this._emitRateGradients[0],this._currentEmitRate1=this._currentEmitRateGradient.getFactor(),this._currentEmitRate2=this._currentEmitRate1),this._emitRateGradients.length>1&&(this._currentEmitRate2=this._emitRateGradients[1].getFactor())),this._startSizeGradients&&(this._startSizeGradients.length>0&&(this._currentStartSizeGradient=this._startSizeGradients[0],this._currentStartSize1=this._currentStartSizeGradient.getFactor(),this._currentStartSize2=this._currentStartSize1),this._startSizeGradients.length>1&&(this._currentStartSize2=this._startSizeGradients[1].getFactor())),this.preWarmCycles){this.emitter instanceof we.a&&this.emitter.computeWorldMatrix(!0);var i=this.noiseTexture;if(i&&i.onGeneratedObservable)i.onGeneratedObservable.addOnce(function(){setTimeout(function(){for(var e=0;e<t.preWarmCycles;e++)t.animate(!0),i.render()})});else for(var r=0;r<this.preWarmCycles;r++)this.animate(!0)}this.beginAnimationOnStart&&this.animations&&this.animations.length>0&&this.getScene().beginAnimation(this,this.beginAnimationFrom,this.beginAnimationTo,this.beginAnimationLoop)}},t.prototype.stop=function(e){void 0===e&&(e=!0),this._stopped=!0,e&&this._stopSubEmitters()},t.prototype.reset=function(){this._stockParticles=[],this._particles=[]},t.prototype._appendParticleVertex=function(e,i,r,n){var o=e*this._vertexBufferSize;this._vertexData[o++]=i.position.x,this._vertexData[o++]=i.position.y,this._vertexData[o++]=i.position.z,this._vertexData[o++]=i.color.r,this._vertexData[o++]=i.color.g,this._vertexData[o++]=i.color.b,this._vertexData[o++]=i.color.a,this._vertexData[o++]=i.angle,this._vertexData[o++]=i.scale.x*i.size,this._vertexData[o++]=i.scale.y*i.size,this._isAnimationSheetEnabled&&(this._vertexData[o++]=i.cellIndex),this._isBillboardBased?this.billboardMode===t.BILLBOARDMODE_STRETCHED&&(this._vertexData[o++]=i.direction.x,this._vertexData[o++]=i.direction.y,this._vertexData[o++]=i.direction.z):i._initialDirection?(this._vertexData[o++]=i._initialDirection.x,this._vertexData[o++]=i._initialDirection.y,this._vertexData[o++]=i._initialDirection.z):(this._vertexData[o++]=i.direction.x,this._vertexData[o++]=i.direction.y,this._vertexData[o++]=i.direction.z),this._useRampGradients&&(this._vertexData[o++]=i.remapData.x,this._vertexData[o++]=i.remapData.y,this._vertexData[o++]=i.remapData.z,this._vertexData[o++]=i.remapData.w),this._useInstancing||(this._isAnimationSheetEnabled&&(0===r?r=this._epsilon:1===r&&(r=1-this._epsilon),0===n?n=this._epsilon:1===n&&(n=1-this._epsilon)),this._vertexData[o++]=r,this._vertexData[o++]=n)},t.prototype._stopSubEmitters=function(){this.activeSubSystems&&(this.activeSubSystems.forEach(function(e){e.stop(!0)}),this.activeSubSystems=new Array)},t.prototype._removeFromRoot=function(){if(this._rootParticleSystem){var e=this._rootParticleSystem.activeSubSystems.indexOf(this);-1!==e&&this._rootParticleSystem.activeSubSystems.splice(e,1),this._rootParticleSystem=null}},t.prototype._update=function(e){var t,i=this;if(this._alive=this._particles.length>0,this.emitter.position){var r=this.emitter;this._emitterWorldMatrix=r.getWorldMatrix()}else{var n=this.emitter;this._emitterWorldMatrix=o.j.Translation(n.x,n.y,n.z)}this.updateFunction(this._particles);for(var s,a=function(){if(c._particles.length===c._capacity)return"break";t=c._createParticle(),c._particles.push(t);var e=D.a.RandomRange(c.minEmitPower,c.maxEmitPower);if(c.startPositionFunction?c.startPositionFunction(c._emitterWorldMatrix,t.position,t):c.particleEmitterType.startPositionFunction(c._emitterWorldMatrix,t.position,t),c.startDirectionFunction?c.startDirectionFunction(c._emitterWorldMatrix,t.direction,t):c.particleEmitterType.startDirectionFunction(c._emitterWorldMatrix,t.direction,t),0===e?t._initialDirection?t._initialDirection.copyFrom(t.direction):t._initialDirection=t.direction.clone():t._initialDirection=null,t.direction.scaleInPlace(e),c.targetStopDuration&&c._lifeTimeGradients&&c._lifeTimeGradients.length>0){var r=D.a.Clamp(c._actualFrame/c.targetStopDuration);ve.h.GetCurrentGradient(r,c._lifeTimeGradients,function(e,i){var n=e,o=i,s=n.getFactor(),a=o.getFactor(),c=(r-n.gradient)/(o.gradient-n.gradient);t.lifeTime=D.a.Lerp(s,a,c)})}else t.lifeTime=D.a.RandomRange(c.minLifeTime,c.maxLifeTime);if(c._sizeGradients&&0!==c._sizeGradients.length?(t._currentSizeGradient=c._sizeGradients[0],t._currentSize1=t._currentSizeGradient.getFactor(),t.size=t._currentSize1,c._sizeGradients.length>1?t._currentSize2=c._sizeGradients[1].getFactor():t._currentSize2=t._currentSize1):t.size=D.a.RandomRange(c.minSize,c.maxSize),t.scale.copyFromFloats(D.a.RandomRange(c.minScaleX,c.maxScaleX),D.a.RandomRange(c.minScaleY,c.maxScaleY)),c._startSizeGradients&&c._startSizeGradients[0]&&c.targetStopDuration){var n=c._actualFrame/c.targetStopDuration;ve.h.GetCurrentGradient(n,c._startSizeGradients,function(e,r,n){e!==i._currentStartSizeGradient&&(i._currentStartSize1=i._currentStartSize2,i._currentStartSize2=r.getFactor(),i._currentStartSizeGradient=e);var o=D.a.Lerp(i._currentStartSize1,i._currentStartSize2,n);t.scale.scaleInPlace(o)})}c._angularSpeedGradients&&0!==c._angularSpeedGradients.length?(t._currentAngularSpeedGradient=c._angularSpeedGradients[0],t.angularSpeed=t._currentAngularSpeedGradient.getFactor(),t._currentAngularSpeed1=t.angularSpeed,c._angularSpeedGradients.length>1?t._currentAngularSpeed2=c._angularSpeedGradients[1].getFactor():t._currentAngularSpeed2=t._currentAngularSpeed1):t.angularSpeed=D.a.RandomRange(c.minAngularSpeed,c.maxAngularSpeed),t.angle=D.a.RandomRange(c.minInitialRotation,c.maxInitialRotation),c._velocityGradients&&c._velocityGradients.length>0&&(t._currentVelocityGradient=c._velocityGradients[0],t._currentVelocity1=t._currentVelocityGradient.getFactor(),c._velocityGradients.length>1?t._currentVelocity2=c._velocityGradients[1].getFactor():t._currentVelocity2=t._currentVelocity1),c._limitVelocityGradients&&c._limitVelocityGradients.length>0&&(t._currentLimitVelocityGradient=c._limitVelocityGradients[0],t._currentLimitVelocity1=t._currentLimitVelocityGradient.getFactor(),c._limitVelocityGradients.length>1?t._currentLimitVelocity2=c._limitVelocityGradients[1].getFactor():t._currentLimitVelocity2=t._currentLimitVelocity1),c._dragGradients&&c._dragGradients.length>0&&(t._currentDragGradient=c._dragGradients[0],t._currentDrag1=t._currentDragGradient.getFactor(),c._dragGradients.length>1?t._currentDrag2=c._dragGradients[1].getFactor():t._currentDrag2=t._currentDrag1),c._colorGradients&&0!==c._colorGradients.length?(t._currentColorGradient=c._colorGradients[0],t._currentColorGradient.getColorToRef(t.color),t._currentColor1.copyFrom(t.color),c._colorGradients.length>1?c._colorGradients[1].getColorToRef(t._currentColor2):t._currentColor2.copyFrom(t.color)):(s=D.a.RandomRange(0,1),o.f.LerpToRef(c.color1,c.color2,s,t.color),c.colorDead.subtractToRef(t.color,c._colorDiff),c._colorDiff.scaleToRef(1/t.lifeTime,t.colorStep)),c._isAnimationSheetEnabled&&(t._initialStartSpriteCellID=c.startSpriteCellID,t._initialEndSpriteCellID=c.endSpriteCellID),t.direction.addInPlace(c._inheritedVelocityOffset),c._useRampGradients&&(t.remapData=new o.y(0,1,0,1)),c.noiseTexture&&(t._randomNoiseCoordinates1?(t._randomNoiseCoordinates1.copyFromFloats(Math.random(),Math.random(),Math.random()),t._randomNoiseCoordinates2.copyFromFloats(Math.random(),Math.random(),Math.random())):(t._randomNoiseCoordinates1=new o.x(Math.random(),Math.random(),Math.random()),t._randomNoiseCoordinates2=new o.x(Math.random(),Math.random(),Math.random()))),t._inheritParticleInfoToSubEmitters()},c=this,l=0;l<e;l++){if("break"===a())break}},t._GetAttributeNamesOrOptions=function(e,t,i){void 0===e&&(e=!1),void 0===t&&(t=!1),void 0===i&&(i=!1);var r=[gi.b.PositionKind,gi.b.ColorKind,"angle","offset","size"];return e&&r.push("cellIndex"),t||r.push("direction"),i&&r.push("remapData"),r},t._GetEffectCreationOptions=function(e){void 0===e&&(e=!1);var t=["invView","view","projection","vClipPlane","vClipPlane2","vClipPlane3","vClipPlane4","textureMask","translationPivot","eyePosition"];return e&&t.push("particlesInfos"),t},t.prototype._getEffect=function(e){if(this._customEffect)return this._customEffect;var i=[];if(this._scene.clipPlane&&i.push("#define CLIPPLANE"),this._scene.clipPlane2&&i.push("#define CLIPPLANE2"),this._scene.clipPlane3&&i.push("#define CLIPPLANE3"),this._scene.clipPlane4&&i.push("#define CLIPPLANE4"),this._isAnimationSheetEnabled&&i.push("#define ANIMATESHEET"),e===t.BLENDMODE_MULTIPLY&&i.push("#define BLENDMULTIPLYMODE"),this._useRampGradients&&i.push("#define RAMPGRADIENT"),this._isBillboardBased)switch(i.push("#define BILLBOARD"),this.billboardMode){case t.BILLBOARDMODE_Y:i.push("#define BILLBOARDY");break;case t.BILLBOARDMODE_STRETCHED:i.push("#define BILLBOARDSTRETCHED");break;case t.BILLBOARDMODE_ALL:}this._imageProcessingConfiguration&&(this._imageProcessingConfiguration.prepareDefines(this._imageProcessingConfigurationDefines),i.push(this._imageProcessingConfigurationDefines.toString()));var r=i.join("\n");if(this._cachedDefines!==r){this._cachedDefines=r;var n=t._GetAttributeNamesOrOptions(this._isAnimationSheetEnabled,this._isBillboardBased&&this.billboardMode!==t.BILLBOARDMODE_STRETCHED,this._useRampGradients),o=t._GetEffectCreationOptions(this._isAnimationSheetEnabled),s=["diffuseSampler","rampSampler"];ui.a&&(ui.a.PrepareUniforms(o,this._imageProcessingConfigurationDefines),ui.a.PrepareSamplers(s,this._imageProcessingConfigurationDefines)),this._effect=this._scene.getEngine().createEffect("particles",n,o,s,r)}return this._effect},t.prototype.animate=function(e){var t=this;if(void 0===e&&(e=!1),this._started){if(!e){if(!this.isReady())return;if(this._currentRenderId===this._scene.getFrameId())return;this._currentRenderId=this._scene.getFrameId()}var i;if(this._scaledUpdateSpeed=this.updateSpeed*(e?this.preWarmStepOffset:this._scene.getAnimationRatio()),this.manualEmitCount>-1)i=this.manualEmitCount,this._newPartsExcess=0,this.manualEmitCount=0;else{var r=this.emitRate;if(this._emitRateGradients&&this._emitRateGradients.length>0&&this.targetStopDuration){var n=this._actualFrame/this.targetStopDuration;ve.h.GetCurrentGradient(n,this._emitRateGradients,function(e,i,n){e!==t._currentEmitRateGradient&&(t._currentEmitRate1=t._currentEmitRate2,t._currentEmitRate2=i.getFactor(),t._currentEmitRateGradient=e),r=D.a.Lerp(t._currentEmitRate1,t._currentEmitRate2,n)})}i=r*this._scaledUpdateSpeed>>0,this._newPartsExcess+=r*this._scaledUpdateSpeed-i}if(this._newPartsExcess>1&&(i+=this._newPartsExcess>>0,this._newPartsExcess-=this._newPartsExcess>>0),this._alive=!1,this._stopped?i=0:(this._actualFrame+=this._scaledUpdateSpeed,this.targetStopDuration&&this._actualFrame>=this.targetStopDuration&&this.stop()),this._update(i),this._stopped&&(this._alive||(this._started=!1,this.onAnimationEnd&&this.onAnimationEnd(),this.disposeOnStop&&this._scene._toBeDisposed.push(this))),!e){for(var o=0,s=0;s<this._particles.length;s++){var a=this._particles[s];this._appendParticleVertices(o,a),o+=this._useInstancing?1:4}this._vertexBuffer&&this._vertexBuffer.update(this._vertexData)}0===this.manualEmitCount&&this.disposeOnStop&&this.stop()}},t.prototype._appendParticleVertices=function(e,t){this._appendParticleVertex(e++,t,0,0),this._useInstancing||(this._appendParticleVertex(e++,t,1,0),this._appendParticleVertex(e++,t,1,1),this._appendParticleVertex(e++,t,0,1))},t.prototype.rebuild=function(){this._createIndexBuffer(),this._vertexBuffer&&this._vertexBuffer._rebuild()},t.prototype.isReady=function(){if(!(this.emitter&&this._imageProcessingConfiguration.isReady()&&this.particleTexture&&this.particleTexture.isReady()))return!1;if(this.blendMode!==t.BLENDMODE_MULTIPLYADD){if(!this._getEffect(this.blendMode).isReady())return!1}else{if(!this._getEffect(t.BLENDMODE_MULTIPLY).isReady())return!1;if(!this._getEffect(t.BLENDMODE_ADD).isReady())return!1}return!0},t.prototype._render=function(e){var i=this._getEffect(e),r=this._scene.getEngine();r.enableEffect(i);var n=this._scene.getViewMatrix();if(i.setTexture("diffuseSampler",this.particleTexture),i.setMatrix("view",n),i.setMatrix("projection",this._scene.getProjectionMatrix()),this._isAnimationSheetEnabled&&this.particleTexture){var o=this.particleTexture.getBaseSize();i.setFloat3("particlesInfos",this.spriteCellWidth/o.width,this.spriteCellHeight/o.height,o.width/this.spriteCellWidth)}if(i.setVector2("translationPivot",this.translationPivot),i.setFloat4("textureMask",this.textureMask.r,this.textureMask.g,this.textureMask.b,this.textureMask.a),this._isBillboardBased){var s=this._scene.activeCamera;i.setVector3("eyePosition",s.globalPosition)}if(this._rampGradientsTexture&&i.setTexture("rampSampler",this._rampGradientsTexture),this._scene.clipPlane||this._scene.clipPlane2||this._scene.clipPlane3||this._scene.clipPlane4){var a=n.clone();a.invert(),i.setMatrix("invView",a),kr.a.BindClipPlane(i,this._scene)}switch(r.bindBuffers(this._vertexBuffers,this._indexBuffer,i),this._imageProcessingConfiguration&&!this._imageProcessingConfiguration.applyByPostProcess&&this._imageProcessingConfiguration.bind(i),e){case t.BLENDMODE_ADD:r.setAlphaMode(_.a.ALPHA_ADD);break;case t.BLENDMODE_ONEONE:r.setAlphaMode(_.a.ALPHA_ONEONE);break;case t.BLENDMODE_STANDARD:r.setAlphaMode(_.a.ALPHA_COMBINE);break;case t.BLENDMODE_MULTIPLY:r.setAlphaMode(_.a.ALPHA_MULTIPLY)}return this._useInstancing?r.drawArraysType(yn.a.TriangleFanDrawMode,0,4,this._particles.length):r.drawElementsType(yn.a.TriangleFillMode,0,6*this._particles.length),this._particles.length},t.prototype.render=function(){if(!this.isReady()||!this._particles.length)return 0;var e=this._scene.getEngine();e.setState(!1),this.forceDepthWrite&&e.setDepthWrite(!0);var i=0;return this.blendMode===t.BLENDMODE_MULTIPLYADD&&(i=this._render(t.BLENDMODE_MULTIPLY)+this._render(t.BLENDMODE_ADD)),i=this._render(this.blendMode),e.unbindInstanceAttributes(),e.setAlphaMode(_.a.ALPHA_DISABLE),i},t.prototype.dispose=function(e){if(void 0===e&&(e=!0),this._vertexBuffer&&(this._vertexBuffer.dispose(),this._vertexBuffer=null),this._spriteBuffer&&(this._spriteBuffer.dispose(),this._spriteBuffer=null),this._indexBuffer&&(this._scene.getEngine()._releaseBuffer(this._indexBuffer),this._indexBuffer=null),e&&this.particleTexture&&(this.particleTexture.dispose(),this.particleTexture=null),e&&this.noiseTexture&&(this.noiseTexture.dispose(),this.noiseTexture=null),this._rampGradientsTexture&&(this._rampGradientsTexture.dispose(),this._rampGradientsTexture=null),this._removeFromRoot(),this._subEmitters&&this._subEmitters.length){for(var t=0;t<this._subEmitters.length;t++)for(var i=0,r=this._subEmitters[t];i<r.length;i++){r[i].dispose()}this._subEmitters=[],this.subEmitters=[]}this._disposeEmitterOnDispose&&this.emitter&&this.emitter.dispose&&this.emitter.dispose(!0),(t=this._scene.particleSystems.indexOf(this))>-1&&this._scene.particleSystems.splice(t,1),this._scene._activeParticleSystems.dispose(),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this.reset()},t.prototype.clone=function(e,i){var r=null,n=null;if(null!=this.customShader){var o=(n=this.customShader).shaderOptions.defines.length>0?n.shaderOptions.defines.join("\n"):"";r=this._scene.getEngine().createEffectForParticles(n.shaderPath.fragmentElement,n.shaderOptions.uniforms,n.shaderOptions.samplers,o)}else this._customEffect&&(r=this._customEffect);var s=new t(e,this._capacity,this._scene,r);return s.customShader=n,S.a.DeepCopy(this,s,["particles","customShader","noiseTexture"]),void 0===i&&(i=this.emitter),s.noiseTexture=this.noiseTexture,s.emitter=i,this.particleTexture&&(s.particleTexture=new Ve.a(this.particleTexture.url,this._scene)),this._colorGradients&&this._colorGradients.forEach(function(e){s.addColorGradient(e.gradient,e.color1,e.color2)}),this._dragGradients&&this._dragGradients.forEach(function(e){s.addDragGradient(e.gradient,e.factor1,e.factor2)}),this._angularSpeedGradients&&this._angularSpeedGradients.forEach(function(e){s.addAngularSpeedGradient(e.gradient,e.factor1,e.factor2)}),this._emitRateGradients&&this._emitRateGradients.forEach(function(e){s.addEmitRateGradient(e.gradient,e.factor1,e.factor2)}),this._lifeTimeGradients&&this._lifeTimeGradients.forEach(function(e){s.addLifeTimeGradient(e.gradient,e.factor1,e.factor2)}),this._limitVelocityGradients&&this._limitVelocityGradients.forEach(function(e){s.addLimitVelocityGradient(e.gradient,e.factor1,e.factor2)}),this._sizeGradients&&this._sizeGradients.forEach(function(e){s.addSizeGradient(e.gradient,e.factor1,e.factor2)}),this._startSizeGradients&&this._startSizeGradients.forEach(function(e){s.addStartSizeGradient(e.gradient,e.factor1,e.factor2)}),this._velocityGradients&&this._velocityGradients.forEach(function(e){s.addVelocityGradient(e.gradient,e.factor1,e.factor2)}),this._rampGradients&&this._rampGradients.forEach(function(e){s.addRampGradient(e.gradient,e.color)}),this._colorRemapGradients&&this._colorRemapGradients.forEach(function(e){s.addColorRemapGradient(e.gradient,e.factor1,e.factor2)}),this._alphaRemapGradients&&this._alphaRemapGradients.forEach(function(e){s.addAlphaRemapGradient(e.gradient,e.factor1,e.factor2)}),this.preventAutoStart||s.start(),s},t.prototype.serialize=function(){var e={};if(t._Serialize(e,this),e.textureMask=this.textureMask.asArray(),e.customShader=this.customShader,e.preventAutoStart=this.preventAutoStart,this.subEmitters){e.subEmitters=[],this._subEmitters||this._prepareSubEmitterInternalArray();for(var i=0,r=this._subEmitters;i<r.length;i++){for(var n=[],o=0,s=r[i];o<s.length;o++){var a=s[o];n.push(a.serialize())}e.subEmitters.push(n)}}return e},t._Serialize=function(e,t){if(e.name=t.name,e.id=t.id,e.capacity=t.getCapacity(),t.emitter.position){var i=t.emitter;e.emitterId=i.id}else{var r=t.emitter;e.emitter=r.asArray()}t.particleEmitterType&&(e.particleEmitterType=t.particleEmitterType.serialize()),t.particleTexture&&(e.textureName=t.particleTexture.name,e.invertY=t.particleTexture._invertY),w.a.AppendSerializedAnimations(t,e),e.beginAnimationOnStart=t.beginAnimationOnStart,e.beginAnimationFrom=t.beginAnimationFrom,e.beginAnimationTo=t.beginAnimationTo,e.beginAnimationLoop=t.beginAnimationLoop,e.startDelay=t.startDelay,e.renderingGroupId=t.renderingGroupId,e.isBillboardBased=t.isBillboardBased,e.billboardMode=t.billboardMode,e.minAngularSpeed=t.minAngularSpeed,e.maxAngularSpeed=t.maxAngularSpeed,e.minSize=t.minSize,e.maxSize=t.maxSize,e.minScaleX=t.minScaleX,e.maxScaleX=t.maxScaleX,e.minScaleY=t.minScaleY,e.maxScaleY=t.maxScaleY,e.minEmitPower=t.minEmitPower,e.maxEmitPower=t.maxEmitPower,e.minLifeTime=t.minLifeTime,e.maxLifeTime=t.maxLifeTime,e.emitRate=t.emitRate,e.gravity=t.gravity.asArray(),e.noiseStrength=t.noiseStrength.asArray(),e.color1=t.color1.asArray(),e.color2=t.color2.asArray(),e.colorDead=t.colorDead.asArray(),e.updateSpeed=t.updateSpeed,e.targetStopDuration=t.targetStopDuration,e.blendMode=t.blendMode,e.preWarmCycles=t.preWarmCycles,e.preWarmStepOffset=t.preWarmStepOffset,e.minInitialRotation=t.minInitialRotation,e.maxInitialRotation=t.maxInitialRotation,e.startSpriteCellID=t.startSpriteCellID,e.endSpriteCellID=t.endSpriteCellID,e.spriteCellChangeSpeed=t.spriteCellChangeSpeed,e.spriteCellWidth=t.spriteCellWidth,e.spriteCellHeight=t.spriteCellHeight,e.spriteRandomStartCell=t.spriteRandomStartCell,e.isAnimationSheetEnabled=t.isAnimationSheetEnabled;var n=t.getColorGradients();if(n){e.colorGradients=[];for(var o=0,s=n;o<s.length;o++){var a=s[o],c={gradient:a.gradient,color1:a.color1.asArray()};a.color2&&(c.color2=a.color2.asArray()),e.colorGradients.push(c)}}var l=t.getRampGradients();if(l){e.rampGradients=[];for(var u=0,h=l;u<h.length;u++){var d=h[u];c={gradient:d.gradient,color:d.color.asArray()};e.rampGradients.push(c)}e.useRampGradients=t.useRampGradients}var f=t.getColorRemapGradients();if(f){e.colorRemapGradients=[];for(var p=0,_=f;p<_.length;p++){var g=_[p];c={gradient:g.gradient,factor1:g.factor1};void 0!==g.factor2&&(c.factor2=g.factor2),e.colorRemapGradients.push(c)}}var m=t.getAlphaRemapGradients();if(m){e.alphaRemapGradients=[];for(var v=0,y=m;v<y.length;v++){var b=y[v];c={gradient:b.gradient,factor1:b.factor1};void 0!==b.factor2&&(c.factor2=b.factor2),e.alphaRemapGradients.push(c)}}var T=t.getSizeGradients();if(T){e.sizeGradients=[];for(var E=0,x=T;E<x.length;E++){var A=x[E];c={gradient:A.gradient,factor1:A.factor1};void 0!==A.factor2&&(c.factor2=A.factor2),e.sizeGradients.push(c)}}var P=t.getAngularSpeedGradients();if(P){e.angularSpeedGradients=[];for(var R=0,S=P;R<S.length;R++){var C=S[R];c={gradient:C.gradient,factor1:C.factor1};void 0!==C.factor2&&(c.factor2=C.factor2),e.angularSpeedGradients.push(c)}}var M=t.getVelocityGradients();if(M){e.velocityGradients=[];for(var O=0,I=M;O<I.length;O++){var D=I[O];c={gradient:D.gradient,factor1:D.factor1};void 0!==D.factor2&&(c.factor2=D.factor2),e.velocityGradients.push(c)}}var L=t.getDragGradients();if(L){e.dragyGradients=[];for(var F=0,N=L;F<N.length;F++){var B=N[F];c={gradient:B.gradient,factor1:B.factor1};void 0!==B.factor2&&(c.factor2=B.factor2),e.dragGradients.push(c)}}var U=t.getEmitRateGradients();if(U){e.emitRateGradients=[];for(var V=0,G=U;V<G.length;V++){var k=G[V];c={gradient:k.gradient,factor1:k.factor1};void 0!==k.factor2&&(c.factor2=k.factor2),e.emitRateGradients.push(c)}}var z=t.getStartSizeGradients();if(z){e.startSizeGradients=[];for(var j=0,W=z;j<W.length;j++){var H=W[j];c={gradient:H.gradient,factor1:H.factor1};void 0!==H.factor2&&(c.factor2=H.factor2),e.startSizeGradients.push(c)}}var X=t.getLifeTimeGradients();if(X){e.lifeTimeGradients=[];for(var Y=0,K=X;Y<K.length;Y++){var Q=K[Y];c={gradient:Q.gradient,factor1:Q.factor1};void 0!==Q.factor2&&(c.factor2=Q.factor2),e.lifeTimeGradients.push(c)}}var q=t.getLimitVelocityGradients();if(q){e.limitVelocityGradients=[];for(var Z=0,J=q;Z<J.length;Z++){var $=J[Z];c={gradient:$.gradient,factor1:$.factor1};void 0!==$.factor2&&(c.factor2=$.factor2),e.limitVelocityGradients.push(c)}e.limitVelocityDamping=t.limitVelocityDamping}t.noiseTexture&&(e.noiseTexture=t.noiseTexture.serialize())},t._Parse=function(e,t,i,r){if(e.textureName&&(t.particleTexture=new Ve.a(r+e.textureName,i,!1,void 0===e.invertY||e.invertY),t.particleTexture.name=e.textureName),e.emitterId||0===e.emitterId||void 0!==e.emitter?e.emitterId?t.emitter=i.getLastMeshByID(e.emitterId):t.emitter=o.x.FromArray(e.emitter):t.emitter=o.x.Zero(),void 0!==e.renderingGroupId&&(t.renderingGroupId=e.renderingGroupId),void 0!==e.isBillboardBased&&(t.isBillboardBased=e.isBillboardBased),void 0!==e.billboardMode&&(t.billboardMode=e.billboardMode),e.animations){for(var n=0;n<e.animations.length;n++){var a=e.animations[n],c=s.a.GetClass("BABYLON.Animation");c&&t.animations.push(c.Parse(a))}t.beginAnimationOnStart=e.beginAnimationOnStart,t.beginAnimationFrom=e.beginAnimationFrom,t.beginAnimationTo=e.beginAnimationTo,t.beginAnimationLoop=e.beginAnimationLoop}if(e.autoAnimate&&i.beginAnimation(t,e.autoAnimateFrom,e.autoAnimateTo,e.autoAnimateLoop,e.autoAnimateSpeed||1),t.startDelay=0|e.startDelay,t.minAngularSpeed=e.minAngularSpeed,t.maxAngularSpeed=e.maxAngularSpeed,t.minSize=e.minSize,t.maxSize=e.maxSize,e.minScaleX&&(t.minScaleX=e.minScaleX,t.maxScaleX=e.maxScaleX,t.minScaleY=e.minScaleY,t.maxScaleY=e.maxScaleY),void 0!==e.preWarmCycles&&(t.preWarmCycles=e.preWarmCycles,t.preWarmStepOffset=e.preWarmStepOffset),void 0!==e.minInitialRotation&&(t.minInitialRotation=e.minInitialRotation,t.maxInitialRotation=e.maxInitialRotation),t.minLifeTime=e.minLifeTime,t.maxLifeTime=e.maxLifeTime,t.minEmitPower=e.minEmitPower,t.maxEmitPower=e.maxEmitPower,t.emitRate=e.emitRate,t.gravity=o.x.FromArray(e.gravity),e.noiseStrength&&(t.noiseStrength=o.x.FromArray(e.noiseStrength)),t.color1=o.f.FromArray(e.color1),t.color2=o.f.FromArray(e.color2),t.colorDead=o.f.FromArray(e.colorDead),t.updateSpeed=e.updateSpeed,t.targetStopDuration=e.targetStopDuration,t.blendMode=e.blendMode,e.colorGradients)for(var l=0,u=e.colorGradients;l<u.length;l++){var h=u[l];t.addColorGradient(h.gradient,o.f.FromArray(h.color1),h.color2?o.f.FromArray(h.color2):void 0)}if(e.rampGradients){for(var d=0,f=e.rampGradients;d<f.length;d++){var p=f[d];t.addRampGradient(p.gradient,o.e.FromArray(p.color))}t.useRampGradients=e.useRampGradients}if(e.colorRemapGradients)for(var _=0,g=e.colorRemapGradients;_<g.length;_++){var m=g[_];t.addColorRemapGradient(m.gradient,void 0!==m.factor1?m.factor1:m.factor,m.factor2)}if(e.alphaRemapGradients)for(var v=0,y=e.alphaRemapGradients;v<y.length;v++){var b=y[v];t.addAlphaRemapGradient(b.gradient,void 0!==b.factor1?b.factor1:b.factor,b.factor2)}if(e.sizeGradients)for(var T=0,E=e.sizeGradients;T<E.length;T++){var x=E[T];t.addSizeGradient(x.gradient,void 0!==x.factor1?x.factor1:x.factor,x.factor2)}if(e.sizeGradients)for(var A=0,P=e.sizeGradients;A<P.length;A++){x=P[A];t.addSizeGradient(x.gradient,void 0!==x.factor1?x.factor1:x.factor,x.factor2)}if(e.angularSpeedGradients)for(var R=0,S=e.angularSpeedGradients;R<S.length;R++){var C=S[R];t.addAngularSpeedGradient(C.gradient,void 0!==C.factor1?C.factor1:C.factor,C.factor2)}if(e.velocityGradients)for(var M=0,O=e.velocityGradients;M<O.length;M++){var I=O[M];t.addVelocityGradient(I.gradient,void 0!==I.factor1?I.factor1:I.factor,I.factor2)}if(e.dragGradients)for(var D=0,w=e.dragGradients;D<w.length;D++){var L=w[D];t.addDragGradient(L.gradient,void 0!==L.factor1?L.factor1:L.factor,L.factor2)}if(e.emitRateGradients)for(var F=0,N=e.emitRateGradients;F<N.length;F++){var B=N[F];t.addEmitRateGradient(B.gradient,void 0!==B.factor1?B.factor1:B.factor,B.factor2)}if(e.startSizeGradients)for(var U=0,V=e.startSizeGradients;U<V.length;U++){var G=V[U];t.addStartSizeGradient(G.gradient,void 0!==G.factor1?G.factor1:G.factor,G.factor2)}if(e.lifeTimeGradients)for(var k=0,z=e.lifeTimeGradients;k<z.length;k++){var j=z[k];t.addLifeTimeGradient(j.gradient,void 0!==j.factor1?j.factor1:j.factor,j.factor2)}if(e.limitVelocityGradients){for(var W=0,H=e.limitVelocityGradients;W<H.length;W++){var X=H[W];t.addLimitVelocityGradient(X.gradient,void 0!==X.factor1?X.factor1:X.factor,X.factor2)}t.limitVelocityDamping=e.limitVelocityDamping}var Y;if(e.noiseTexture&&(t.noiseTexture=zo.Parse(e.noiseTexture,i,r)),e.particleEmitterType){switch(e.particleEmitterType.type){case"SphereParticleEmitter":Y=new Bs;break;case"SphereDirectedParticleEmitter":Y=new Us;break;case"ConeEmitter":case"ConeParticleEmitter":Y=new Ds;break;case"CylinderParticleEmitter":Y=new ws;break;case"HemisphericParticleEmitter":Y=new Fs;break;case"BoxEmitter":case"BoxParticleEmitter":default:Y=new Is}Y.parse(e.particleEmitterType)}else(Y=new Is).parse(e);t.particleEmitterType=Y,t.startSpriteCellID=e.startSpriteCellID,t.endSpriteCellID=e.endSpriteCellID,t.spriteCellWidth=e.spriteCellWidth,t.spriteCellHeight=e.spriteCellHeight,t.spriteCellChangeSpeed=e.spriteCellChangeSpeed,t.spriteRandomStartCell=e.spriteRandomStartCell},t.Parse=function(e,i,r,n){void 0===n&&(n=!1);var s=e.name,a=null,c=null;if(e.customShader){var l=(c=e.customShader).shaderOptions.defines.length>0?c.shaderOptions.defines.join("\n"):"";a=i.getEngine().createEffectForParticles(c.shaderPath.fragmentElement,c.shaderOptions.uniforms,c.shaderOptions.samplers,l)}var u=new t(s,e.capacity,i,a,e.isAnimationSheetEnabled);if(u.customShader=c,e.id&&(u.id=e.id),e.subEmitters){u.subEmitters=[];for(var h=0,d=e.subEmitters;h<d.length;h++){for(var f=[],p=0,_=d[h];p<_.length;p++){var g=_[p];f.push(ks.Parse(g,i,r))}u.subEmitters.push(f)}}return t._Parse(e,u,i,r),u.textureMask=o.f.FromArray(e.textureMask),e.preventAutoStart&&(u.preventAutoStart=e.preventAutoStart),n||u.preventAutoStart||u.start(),u},t.BILLBOARDMODE_Y=_.a.PARTICLES_BILLBOARDMODE_Y,t.BILLBOARDMODE_ALL=_.a.PARTICLES_BILLBOARDMODE_ALL,t.BILLBOARDMODE_STRETCHED=_.a.PARTICLES_BILLBOARDMODE_STRETCHED,t}(Vs);ks._ParseParticleSystem=Ws.Parse;St.a.ShadersStore.gpuUpdateParticlesPixelShader="#version 300 es\nvoid main() {\ndiscard;\n}\n";var Hs="#version 300 es\n#define PI 3.14159\nuniform float currentCount;\nuniform float timeDelta;\nuniform float stopFactor;\nuniform mat4 emitterWM;\nuniform vec2 lifeTime;\nuniform vec2 emitPower;\nuniform vec2 sizeRange;\nuniform vec4 scaleRange;\n#ifndef COLORGRADIENTS\nuniform vec4 color1;\nuniform vec4 color2;\n#endif\nuniform vec3 gravity;\nuniform sampler2D randomSampler;\nuniform sampler2D randomSampler2;\nuniform vec4 angleRange;\n#ifdef BOXEMITTER\nuniform vec3 direction1;\nuniform vec3 direction2;\nuniform vec3 minEmitBox;\nuniform vec3 maxEmitBox;\n#endif\n#ifdef POINTEMITTER\nuniform vec3 direction1;\nuniform vec3 direction2;\n#endif\n#ifdef HEMISPHERICEMITTER\nuniform float radius;\nuniform float radiusRange;\nuniform float directionRandomizer;\n#endif\n#ifdef SPHEREEMITTER\nuniform float radius;\nuniform float radiusRange;\n#ifdef DIRECTEDSPHEREEMITTER\nuniform vec3 direction1;\nuniform vec3 direction2;\n#else\nuniform float directionRandomizer;\n#endif\n#endif\n#ifdef CYLINDEREMITTER\nuniform float radius;\nuniform float height;\nuniform float radiusRange;\n#ifdef DIRECTEDCYLINDEREMITTER\nuniform vec3 direction1;\nuniform vec3 direction2;\n#else\nuniform float directionRandomizer;\n#endif\n#endif\n#ifdef CONEEMITTER\nuniform vec2 radius;\nuniform float coneAngle;\nuniform vec2 height;\nuniform float directionRandomizer;\n#endif\n\nin vec3 position;\nin float age;\nin float life;\nin vec4 seed;\nin vec3 size;\n#ifndef COLORGRADIENTS\nin vec4 color;\n#endif\nin vec3 direction;\n#ifndef BILLBOARD\nin vec3 initialDirection;\n#endif\n#ifdef ANGULARSPEEDGRADIENTS\nin float angle;\n#else\nin vec2 angle;\n#endif\n#ifdef ANIMATESHEET\nin float cellIndex;\n#ifdef ANIMATESHEETRANDOMSTART\nin float cellStartOffset;\n#endif\n#endif\n#ifdef NOISE\nin vec3 noiseCoordinates1;\nin vec3 noiseCoordinates2;\n#endif\n\nout vec3 outPosition;\nout float outAge;\nout float outLife;\nout vec4 outSeed;\nout vec3 outSize;\n#ifndef COLORGRADIENTS\nout vec4 outColor;\n#endif\nout vec3 outDirection;\n#ifndef BILLBOARD\nout vec3 outInitialDirection;\n#endif\n#ifdef ANGULARSPEEDGRADIENTS\nout float outAngle;\n#else\nout vec2 outAngle;\n#endif\n#ifdef ANIMATESHEET\nout float outCellIndex;\n#ifdef ANIMATESHEETRANDOMSTART\nout float outCellStartOffset;\n#endif\n#endif\n#ifdef NOISE\nout vec3 outNoiseCoordinates1;\nout vec3 outNoiseCoordinates2;\n#endif\n#ifdef SIZEGRADIENTS\nuniform sampler2D sizeGradientSampler;\n#endif\n#ifdef ANGULARSPEEDGRADIENTS\nuniform sampler2D angularSpeedGradientSampler;\n#endif\n#ifdef VELOCITYGRADIENTS\nuniform sampler2D velocityGradientSampler;\n#endif\n#ifdef LIMITVELOCITYGRADIENTS\nuniform sampler2D limitVelocityGradientSampler;\nuniform float limitVelocityDamping;\n#endif\n#ifdef DRAGGRADIENTS\nuniform sampler2D dragGradientSampler;\n#endif\n#ifdef NOISE\nuniform vec3 noiseStrength;\nuniform sampler2D noiseSampler;\n#endif\n#ifdef ANIMATESHEET\nuniform vec3 cellInfos;\n#endif\nvec3 getRandomVec3(float offset) {\nreturn texture(randomSampler2,vec2(float(gl_VertexID)*offset/currentCount,0)).rgb;\n}\nvec4 getRandomVec4(float offset) {\nreturn texture(randomSampler,vec2(float(gl_VertexID)*offset/currentCount,0));\n}\nvoid main() {\nfloat newAge=age+timeDelta;\n\nif (newAge>=life && stopFactor != 0.) {\nvec3 position;\nvec3 direction;\n\nvec4 randoms=getRandomVec4(seed.x);\n\noutLife=lifeTime.x+(lifeTime.y-lifeTime.x)*randoms.r;\noutAge=mod(newAge,outLife);\n\noutSeed=seed;\n\n#ifdef SIZEGRADIENTS\noutSize.x=texture(sizeGradientSampler,vec2(0,0)).r;\n#else\noutSize.x=sizeRange.x+(sizeRange.y-sizeRange.x)*randoms.g;\n#endif\noutSize.y=scaleRange.x+(scaleRange.y-scaleRange.x)*randoms.b;\noutSize.z=scaleRange.z+(scaleRange.w-scaleRange.z)*randoms.a;\n#ifndef COLORGRADIENTS\n\noutColor=color1+(color2-color1)*randoms.b;\n#endif\n\n#ifndef ANGULARSPEEDGRADIENTS\noutAngle.y=angleRange.x+(angleRange.y-angleRange.x)*randoms.a;\noutAngle.x=angleRange.z+(angleRange.w-angleRange.z)*randoms.r;\n#else\noutAngle=angleRange.z+(angleRange.w-angleRange.z)*randoms.r;\n#endif\n\n#ifdef POINTEMITTER\nvec3 randoms2=getRandomVec3(seed.y);\nvec3 randoms3=getRandomVec3(seed.z);\nposition=vec3(0,0,0);\ndirection=direction1+(direction2-direction1)*randoms3;\n#elif defined(BOXEMITTER)\nvec3 randoms2=getRandomVec3(seed.y);\nvec3 randoms3=getRandomVec3(seed.z);\nposition=minEmitBox+(maxEmitBox-minEmitBox)*randoms2;\ndirection=direction1+(direction2-direction1)*randoms3;\n#elif defined(HEMISPHERICEMITTER)\nvec3 randoms2=getRandomVec3(seed.y);\nvec3 randoms3=getRandomVec3(seed.z);\n\nfloat phi=2.0*PI*randoms2.x;\nfloat theta=acos(2.0*randoms2.y-1.0);\nfloat randX=cos(phi)*sin(theta);\nfloat randY=cos(theta);\nfloat randZ=sin(phi)*sin(theta);\nposition=(radius-(radius*radiusRange*randoms2.z))*vec3(randX,abs(randY),randZ);\ndirection=position+directionRandomizer*randoms3;\n#elif defined(SPHEREEMITTER)\nvec3 randoms2=getRandomVec3(seed.y);\nvec3 randoms3=getRandomVec3(seed.z);\n\nfloat phi=2.0*PI*randoms2.x;\nfloat theta=acos(2.0*randoms2.y-1.0);\nfloat randX=cos(phi)*sin(theta);\nfloat randY=cos(theta);\nfloat randZ=sin(phi)*sin(theta);\nposition=(radius-(radius*radiusRange*randoms2.z))*vec3(randX,randY,randZ);\n#ifdef DIRECTEDSPHEREEMITTER\ndirection=direction1+(direction2-direction1)*randoms3;\n#else\n\ndirection=position+directionRandomizer*randoms3;\n#endif\n#elif defined(CYLINDEREMITTER)\nvec3 randoms2=getRandomVec3(seed.y);\nvec3 randoms3=getRandomVec3(seed.z);\n\nfloat yPos=(randoms2.x-0.5)*height;\nfloat angle=randoms2.y*PI*2.;\nfloat inverseRadiusRangeSquared=((1.-radiusRange)*(1.-radiusRange));\nfloat positionRadius=radius*sqrt(inverseRadiusRangeSquared+(randoms2.z*(1.-inverseRadiusRangeSquared)));\nfloat xPos=positionRadius*cos(angle);\nfloat zPos=positionRadius*sin(angle);\nposition=vec3(xPos,yPos,zPos);\n#ifdef DIRECTEDCYLINDEREMITTER\ndirection=direction1+(direction2-direction1)*randoms3;\n#else\n\nangle=angle+((randoms3.x-0.5)*PI);\ndirection=vec3(cos(angle),randoms3.y-0.5,sin(angle));\ndirection=normalize(direction);\n#endif\n#elif defined(CONEEMITTER)\nvec3 randoms2=getRandomVec3(seed.y);\nfloat s=2.0*PI*randoms2.x;\n#ifdef CONEEMITTERSPAWNPOINT\nfloat h=0.00001;\n#else\nfloat h=randoms2.y*height.y;\n\nh=1.-h*h;\n#endif\nfloat lRadius=radius.x-radius.x*randoms2.z*radius.y;\nlRadius=lRadius*h;\nfloat randX=lRadius*sin(s);\nfloat randZ=lRadius*cos(s);\nfloat randY=h*height.x;\nposition=vec3(randX,randY,randZ);\n\nif (abs(cos(coneAngle)) == 1.0) {\ndirection=vec3(0.,1.0,0.);\n} else {\nvec3 randoms3=getRandomVec3(seed.z);\ndirection=position+directionRandomizer*randoms3;\n}\n#else\n\nposition=vec3(0.,0.,0.);\n\ndirection=2.0*(getRandomVec3(seed.w)-vec3(0.5,0.5,0.5));\n#endif\nfloat power=emitPower.x+(emitPower.y-emitPower.x)*randoms.a;\noutPosition=(emitterWM*vec4(position,1.)).xyz;\nvec3 initial=(emitterWM*vec4(direction,0.)).xyz;\noutDirection=initial*power;\n#ifndef BILLBOARD\noutInitialDirection=initial;\n#endif\n#ifdef ANIMATESHEET\noutCellIndex=cellInfos.x;\n#ifdef ANIMATESHEETRANDOMSTART\noutCellStartOffset=randoms.a*outLife;\n#endif\n#endif\n#ifdef NOISE\noutNoiseCoordinates1=noiseCoordinates1;\noutNoiseCoordinates2=noiseCoordinates2;\n#endif\n} else {\nfloat directionScale=timeDelta;\noutAge=newAge;\nfloat ageGradient=newAge/life;\n#ifdef VELOCITYGRADIENTS\ndirectionScale*=texture(velocityGradientSampler,vec2(ageGradient,0)).r;\n#endif\n#ifdef DRAGGRADIENTS\ndirectionScale*=1.0-texture(dragGradientSampler,vec2(ageGradient,0)).r;\n#endif\noutPosition=position+direction*directionScale;\noutLife=life;\noutSeed=seed;\n#ifndef COLORGRADIENTS\noutColor=color;\n#endif\n#ifdef SIZEGRADIENTS\noutSize.x=texture(sizeGradientSampler,vec2(ageGradient,0)).r;\noutSize.yz=size.yz;\n#else\noutSize=size;\n#endif\n#ifndef BILLBOARD\noutInitialDirection=initialDirection;\n#endif\nvec3 updatedDirection=direction+gravity*timeDelta;\n#ifdef LIMITVELOCITYGRADIENTS\nfloat limitVelocity=texture(limitVelocityGradientSampler,vec2(ageGradient,0)).r;\nfloat currentVelocity=length(updatedDirection);\nif (currentVelocity>limitVelocity) {\nupdatedDirection=updatedDirection*limitVelocityDamping;\n}\n#endif\noutDirection=updatedDirection;\n#ifdef NOISE\nvec3 localPosition=outPosition-emitterWM[3].xyz;\nfloat fetchedR=texture(noiseSampler,vec2(noiseCoordinates1.x,noiseCoordinates1.y)*vec2(0.5)+vec2(0.5)).r;\nfloat fetchedG=texture(noiseSampler,vec2(noiseCoordinates1.z,noiseCoordinates2.x)*vec2(0.5)+vec2(0.5)).r;\nfloat fetchedB=texture(noiseSampler,vec2(noiseCoordinates2.y,noiseCoordinates2.z)*vec2(0.5)+vec2(0.5)).r;\nvec3 force=vec3(2.*fetchedR-1.,2.*fetchedG-1.,2.*fetchedB-1.)*noiseStrength;\noutDirection=outDirection+force*timeDelta;\noutNoiseCoordinates1=noiseCoordinates1;\noutNoiseCoordinates2=noiseCoordinates2;\n#endif\n#ifdef ANGULARSPEEDGRADIENTS\nfloat angularSpeed=texture(angularSpeedGradientSampler,vec2(ageGradient,0)).r;\noutAngle=angle+angularSpeed*timeDelta;\n#else\noutAngle=vec2(angle.x+angle.y*timeDelta,angle.y);\n#endif\n#ifdef ANIMATESHEET\nfloat offsetAge=outAge;\nfloat dist=cellInfos.y-cellInfos.x;\n#ifdef ANIMATESHEETRANDOMSTART\noutCellStartOffset=cellStartOffset;\noffsetAge+=cellStartOffset;\n#endif\nfloat ratio=clamp(mod(offsetAge*cellInfos.z,life)/life,0.,1.0);\noutCellIndex=float(int(cellInfos.x+ratio*dist));\n#endif\n}\n}";St.a.ShadersStore.gpuUpdateParticlesVertexShader=Hs;var Xs="#ifdef CLIPPLANE\nin float fClipDistance;\n#endif\n#ifdef CLIPPLANE2\nin float fClipDistance2;\n#endif\n#ifdef CLIPPLANE3\nin float fClipDistance3;\n#endif\n#ifdef CLIPPLANE4\nin float fClipDistance4;\n#endif";St.a.IncludesShadersStore.clipPlaneFragmentDeclaration2=Xs;var Ys="#version 300 es\nuniform sampler2D textureSampler;\nin vec2 vUV;\nin vec4 vColor;\nout vec4 outFragColor;\n#include<clipPlaneFragmentDeclaration2>\n#include<imageProcessingDeclaration>\n#include<helperFunctions>\n#include<imageProcessingFunctions>\nvoid main() {\n#include<clipPlaneFragment>\nvec4 textureColor=texture(textureSampler,vUV);\noutFragColor=textureColor*vColor;\n#ifdef BLENDMULTIPLYMODE\nfloat alpha=vColor.a*textureColor.a;\noutFragColor.rgb=outFragColor.rgb*alpha+vec3(1.0)*(1.0-alpha);\n#endif\n\n\n#ifdef IMAGEPROCESSINGPOSTPROCESS\noutFragColor.rgb=toLinearSpace(outFragColor.rgb);\n#else\n#ifdef IMAGEPROCESSING\noutFragColor.rgb=toLinearSpace(outFragColor.rgb);\noutFragColor=applyImageProcessing(outFragColor);\n#endif\n#endif\n}\n";St.a.ShadersStore.gpuRenderParticlesPixelShader=Ys;var Ks="#ifdef CLIPPLANE\nuniform vec4 vClipPlane;\nout float fClipDistance;\n#endif\n#ifdef CLIPPLANE2\nuniform vec4 vClipPlane2;\nout float fClipDistance2;\n#endif\n#ifdef CLIPPLANE3\nuniform vec4 vClipPlane3;\nout float fClipDistance3;\n#endif\n#ifdef CLIPPLANE4\nuniform vec4 vClipPlane4;\nout float fClipDistance4;\n#endif";St.a.IncludesShadersStore.clipPlaneVertexDeclaration2=Ks;var Qs="#version 300 es\nuniform mat4 view;\nuniform mat4 projection;\nuniform vec2 translationPivot;\n\nin vec3 position;\nin float age;\nin float life;\nin vec3 size;\n#ifndef BILLBOARD\nin vec3 initialDirection;\n#endif\n#ifdef BILLBOARDSTRETCHED\nin vec3 direction;\n#endif\nin float angle;\n#ifdef ANIMATESHEET\nin float cellIndex;\n#endif\nin vec2 offset;\nin vec2 uv;\nout vec2 vUV;\nout vec4 vColor;\n#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4)\nuniform mat4 invView;\n#endif\n#include<clipPlaneVertexDeclaration2>\n#ifdef COLORGRADIENTS\nuniform sampler2D colorGradientSampler;\n#else\nuniform vec4 colorDead;\nin vec4 color;\n#endif\n#ifdef ANIMATESHEET\nuniform vec3 sheetInfos;\n#endif\n#ifdef BILLBOARD\nuniform vec3 eyePosition;\n#endif\nvec3 rotate(vec3 yaxis,vec3 rotatedCorner) {\nvec3 xaxis=normalize(cross(vec3(0.,1.0,0.),yaxis));\nvec3 zaxis=normalize(cross(yaxis,xaxis));\nvec3 row0=vec3(xaxis.x,xaxis.y,xaxis.z);\nvec3 row1=vec3(yaxis.x,yaxis.y,yaxis.z);\nvec3 row2=vec3(zaxis.x,zaxis.y,zaxis.z);\nmat3 rotMatrix=mat3(row0,row1,row2);\nvec3 alignedCorner=rotMatrix*rotatedCorner;\nreturn position+alignedCorner;\n}\n#ifdef BILLBOARDSTRETCHED\nvec3 rotateAlign(vec3 toCamera,vec3 rotatedCorner) {\nvec3 normalizedToCamera=normalize(toCamera);\nvec3 normalizedCrossDirToCamera=normalize(cross(normalize(direction),normalizedToCamera));\nvec3 crossProduct=normalize(cross(normalizedToCamera,normalizedCrossDirToCamera));\nvec3 row0=vec3(normalizedCrossDirToCamera.x,normalizedCrossDirToCamera.y,normalizedCrossDirToCamera.z);\nvec3 row1=vec3(crossProduct.x,crossProduct.y,crossProduct.z);\nvec3 row2=vec3(normalizedToCamera.x,normalizedToCamera.y,normalizedToCamera.z);\nmat3 rotMatrix=mat3(row0,row1,row2);\nvec3 alignedCorner=rotMatrix*rotatedCorner;\nreturn position+alignedCorner;\n}\n#endif\nvoid main() {\n#ifdef ANIMATESHEET\nfloat rowOffset=floor(cellIndex/sheetInfos.z);\nfloat columnOffset=cellIndex-rowOffset*sheetInfos.z;\nvec2 uvScale=sheetInfos.xy;\nvec2 uvOffset=vec2(uv.x ,1.0-uv.y);\nvUV=(uvOffset+vec2(columnOffset,rowOffset))*uvScale;\n#else\nvUV=uv;\n#endif\nfloat ratio=age/life;\n#ifdef COLORGRADIENTS\nvColor=texture(colorGradientSampler,vec2(ratio,0));\n#else\nvColor=color*vec4(1.0-ratio)+colorDead*vec4(ratio);\n#endif\nvec2 cornerPos=(offset-translationPivot)*size.yz*size.x+translationPivot;\n#ifdef BILLBOARD\nvec4 rotatedCorner;\nrotatedCorner.w=0.;\n#ifdef BILLBOARDY\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.y=0.;\nvec3 yaxis=position-eyePosition;\nyaxis.y=0.;\nvec3 worldPos=rotate(normalize(yaxis),rotatedCorner.xyz);\nvec4 viewPosition=(view*vec4(worldPos,1.0));\n#elif defined(BILLBOARDSTRETCHED)\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.z=0.;\nvec3 toCamera=position-eyePosition;\nvec3 worldPos=rotateAlign(toCamera,rotatedCorner.xyz);\nvec4 viewPosition=(view*vec4(worldPos,1.0));\n#else\n\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.z=0.;\n\nvec4 viewPosition=view*vec4(position,1.0)+rotatedCorner;\n#endif\n#else\n\nvec3 rotatedCorner;\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.y=0.;\nrotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nvec3 yaxis=normalize(initialDirection);\nvec3 worldPos=rotate(yaxis,rotatedCorner);\n\nvec4 viewPosition=view*vec4(worldPos,1.0);\n#endif\ngl_Position=projection*viewPosition;\n\n#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4)\nvec4 worldPos=invView*viewPosition;\n#endif\n#include<clipPlaneVertex>\n}";St.a.ShadersStore.gpuRenderParticlesVertexShader=Qs;var qs=function(e){function t(t,i,r,o){void 0===o&&(o=!1);var s=e.call(this,t)||this;s.layerMask=268435455,s._accumulatedCount=0,s._targetIndex=0,s._currentRenderId=-1,s._started=!1,s._stopped=!1,s._timeDelta=0,s._actualFrame=0,s._rawTextureWidth=256,s.onDisposeObservable=new n.c,s.forceDepthWrite=!1,s._preWarmDone=!1,s._scene=r||R.a.LastCreatedScene,s._attachImageProcessingConfiguration(null),s._engine=s._scene.getEngine(),i.randomTextureSize||delete i.randomTextureSize;var a=l.a({capacity:5e4,randomTextureSize:s._engine.getCaps().maxTextureSize},i),c=i;isFinite(c)&&(a.capacity=c),s._capacity=a.capacity,s._activeCount=a.capacity,s._currentActiveCount=0,s._isAnimationSheetEnabled=o,s._scene.particleSystems.push(s),s._updateEffectOptions={attributes:["position","age","life","seed","size","color","direction","initialDirection","angle","cellIndex","cellStartOffset","noiseCoordinates1","noiseCoordinates2"],uniformsNames:["currentCount","timeDelta","emitterWM","lifeTime","color1","color2","sizeRange","scaleRange","gravity","emitPower","direction1","direction2","minEmitBox","maxEmitBox","radius","directionRandomizer","height","coneAngle","stopFactor","angleRange","radiusRange","cellInfos","noiseStrength","limitVelocityDamping"],uniformBuffersNames:[],samplers:["randomSampler","randomSampler2","sizeGradientSampler","angularSpeedGradientSampler","velocityGradientSampler","limitVelocityGradientSampler","noiseSampler","dragGradientSampler"],defines:"",fallbacks:null,onCompiled:null,onError:null,indexParameters:null,maxSimultaneousLights:0,transformFeedbackVaryings:[]},s.particleEmitterType=new Is;for(var u=Math.min(s._engine.getCaps().maxTextureSize,a.randomTextureSize),h=[],d=0;d<u;++d)h.push(Math.random()),h.push(Math.random()),h.push(Math.random()),h.push(Math.random());s._randomTexture=new Ge(new Float32Array(h),u,1,_.a.TEXTUREFORMAT_RGBA,s._scene,!1,!1,_.a.TEXTURE_NEAREST_SAMPLINGMODE,_.a.TEXTURETYPE_FLOAT),s._randomTexture.wrapU=Ve.a.WRAP_ADDRESSMODE,s._randomTexture.wrapV=Ve.a.WRAP_ADDRESSMODE,h=[];for(d=0;d<u;++d)h.push(Math.random()),h.push(Math.random()),h.push(Math.random()),h.push(Math.random());return s._randomTexture2=new Ge(new Float32Array(h),u,1,_.a.TEXTUREFORMAT_RGBA,s._scene,!1,!1,_.a.TEXTURE_NEAREST_SAMPLINGMODE,_.a.TEXTURETYPE_FLOAT),s._randomTexture2.wrapU=Ve.a.WRAP_ADDRESSMODE,s._randomTexture2.wrapV=Ve.a.WRAP_ADDRESSMODE,s._randomTextureSize=u,s}return l.d(t,e),Object.defineProperty(t,"IsSupported",{get:function(){return!!R.a.LastCreatedEngine&&R.a.LastCreatedEngine.webGLVersion>1},enumerable:!0,configurable:!0}),t.prototype.getCapacity=function(){return this._capacity},Object.defineProperty(t.prototype,"activeParticleCount",{get:function(){return this._activeCount},set:function(e){this._activeCount=Math.min(e,this._capacity)},enumerable:!0,configurable:!0}),t.prototype.isReady=function(){return this._updateEffect?!!(this.emitter&&this._updateEffect.isReady()&&this._imageProcessingConfiguration.isReady()&&this._renderEffect.isReady()&&this.particleTexture&&this.particleTexture.isReady()):(this._recreateUpdateEffect(),this._recreateRenderEffect(),!1)},t.prototype.isStarted=function(){return this._started},t.prototype.start=function(e){var t=this;if(void 0===e&&(e=this.startDelay),!this.targetStopDuration&&this._hasTargetStopDurationDependantGradient())throw"Particle system started with a targetStopDuration dependant gradient (eg. startSizeGradients) but no targetStopDuration set";e?setTimeout(function(){t.start(0)},e):(this._started=!0,this._stopped=!1,this._preWarmDone=!1,this.beginAnimationOnStart&&this.animations&&this.animations.length>0&&this.getScene().beginAnimation(this,this.beginAnimationFrom,this.beginAnimationTo,this.beginAnimationLoop))},t.prototype.stop=function(){this._stopped=!0},t.prototype.reset=function(){this._releaseBuffers(),this._releaseVAOs(),this._currentActiveCount=0,this._targetIndex=0},t.prototype.getClassName=function(){return"GPUParticleSystem"},t.prototype._removeGradientAndTexture=function(t,i,r){return e.prototype._removeGradientAndTexture.call(this,t,i,r),this._releaseBuffers(),this},t.prototype.addColorGradient=function(e,t,i){this._colorGradients||(this._colorGradients=[]);var r=new ve.c;return r.gradient=e,r.color1=t,this._colorGradients.push(r),this._colorGradients.sort(function(e,t){return e.gradient<t.gradient?-1:e.gradient>t.gradient?1:0}),this._colorGradientsTexture&&(this._colorGradientsTexture.dispose(),this._colorGradientsTexture=null),this._releaseBuffers(),this},t.prototype.removeColorGradient=function(e){return this._removeGradientAndTexture(e,this._colorGradients,this._colorGradientsTexture),this._colorGradientsTexture=null,this},t.prototype._addFactorGradient=function(e,t,i){var r=new ve.d;r.gradient=t,r.factor1=i,e.push(r),e.sort(function(e,t){return e.gradient<t.gradient?-1:e.gradient>t.gradient?1:0}),this._releaseBuffers()},t.prototype.addSizeGradient=function(e,t){return this._sizeGradients||(this._sizeGradients=[]),this._addFactorGradient(this._sizeGradients,e,t),this._sizeGradientsTexture&&(this._sizeGradientsTexture.dispose(),this._sizeGradientsTexture=null),this._releaseBuffers(),this},t.prototype.removeSizeGradient=function(e){return this._removeGradientAndTexture(e,this._sizeGradients,this._sizeGradientsTexture),this._sizeGradientsTexture=null,this},t.prototype.addAngularSpeedGradient=function(e,t){return this._angularSpeedGradients||(this._angularSpeedGradients=[]),this._addFactorGradient(this._angularSpeedGradients,e,t),this._angularSpeedGradientsTexture&&(this._angularSpeedGradientsTexture.dispose(),this._angularSpeedGradientsTexture=null),this._releaseBuffers(),this},t.prototype.removeAngularSpeedGradient=function(e){return this._removeGradientAndTexture(e,this._angularSpeedGradients,this._angularSpeedGradientsTexture),this._angularSpeedGradientsTexture=null,this},t.prototype.addVelocityGradient=function(e,t){return this._velocityGradients||(this._velocityGradients=[]),this._addFactorGradient(this._velocityGradients,e,t),this._velocityGradientsTexture&&(this._velocityGradientsTexture.dispose(),this._velocityGradientsTexture=null),this._releaseBuffers(),this},t.prototype.removeVelocityGradient=function(e){return this._removeGradientAndTexture(e,this._velocityGradients,this._velocityGradientsTexture),this._velocityGradientsTexture=null,this},t.prototype.addLimitVelocityGradient=function(e,t){return this._limitVelocityGradients||(this._limitVelocityGradients=[]),this._addFactorGradient(this._limitVelocityGradients,e,t),this._limitVelocityGradientsTexture&&(this._limitVelocityGradientsTexture.dispose(),this._limitVelocityGradientsTexture=null),this._releaseBuffers(),this},t.prototype.removeLimitVelocityGradient=function(e){return this._removeGradientAndTexture(e,this._limitVelocityGradients,this._limitVelocityGradientsTexture),this._limitVelocityGradientsTexture=null,this},t.prototype.addDragGradient=function(e,t){return this._dragGradients||(this._dragGradients=[]),this._addFactorGradient(this._dragGradients,e,t),this._dragGradientsTexture&&(this._dragGradientsTexture.dispose(),this._dragGradientsTexture=null),this._releaseBuffers(),this},t.prototype.removeDragGradient=function(e){return this._removeGradientAndTexture(e,this._dragGradients,this._dragGradientsTexture),this._dragGradientsTexture=null,this},t.prototype.addEmitRateGradient=function(e,t,i){return this},t.prototype.removeEmitRateGradient=function(e){return this},t.prototype.addStartSizeGradient=function(e,t,i){return this},t.prototype.removeStartSizeGradient=function(e){return this},t.prototype.addColorRemapGradient=function(e,t,i){return this},t.prototype.removeColorRemapGradient=function(){return this},t.prototype.addAlphaRemapGradient=function(e,t,i){return this},t.prototype.removeAlphaRemapGradient=function(){return this},t.prototype.addRampGradient=function(e,t){return this},t.prototype.removeRampGradient=function(){return this},t.prototype.getRampGradients=function(){return null},Object.defineProperty(t.prototype,"useRampGradients",{get:function(){return!1},set:function(e){},enumerable:!0,configurable:!0}),t.prototype.addLifeTimeGradient=function(e,t,i){return this},t.prototype.removeLifeTimeGradient=function(e){return this},t.prototype._reset=function(){this._releaseBuffers()},t.prototype._createUpdateVAO=function(e){var t={};t.position=e.createVertexBuffer("position",0,3),t.age=e.createVertexBuffer("age",3,1),t.life=e.createVertexBuffer("life",4,1),t.seed=e.createVertexBuffer("seed",5,4),t.size=e.createVertexBuffer("size",9,3);var i=12;this._colorGradientsTexture||(t.color=e.createVertexBuffer("color",i,4),i+=4),t.direction=e.createVertexBuffer("direction",i,3),i+=3,this._isBillboardBased||(t.initialDirection=e.createVertexBuffer("initialDirection",i,3),i+=3),this._angularSpeedGradientsTexture?(t.angle=e.createVertexBuffer("angle",i,1),i+=1):(t.angle=e.createVertexBuffer("angle",i,2),i+=2),this._isAnimationSheetEnabled&&(t.cellIndex=e.createVertexBuffer("cellIndex",i,1),i+=1,this.spriteRandomStartCell&&(t.cellStartOffset=e.createVertexBuffer("cellStartOffset",i,1),i+=1)),this.noiseTexture&&(t.noiseCoordinates1=e.createVertexBuffer("noiseCoordinates1",i,3),i+=3,t.noiseCoordinates2=e.createVertexBuffer("noiseCoordinates2",i,3),i+=3);var r=this._engine.recordVertexArrayObject(t,null,this._updateEffect);return this._engine.bindArrayBuffer(null),r},t.prototype._createRenderVAO=function(e,t){var i={};i.position=e.createVertexBuffer("position",0,3,this._attributesStrideSize,!0),i.age=e.createVertexBuffer("age",3,1,this._attributesStrideSize,!0),i.life=e.createVertexBuffer("life",4,1,this._attributesStrideSize,!0),i.size=e.createVertexBuffer("size",9,3,this._attributesStrideSize,!0);var r=12;this._colorGradientsTexture||(i.color=e.createVertexBuffer("color",r,4,this._attributesStrideSize,!0),r+=4),this.billboardMode===Ws.BILLBOARDMODE_STRETCHED&&(i.direction=e.createVertexBuffer("direction",r,3,this._attributesStrideSize,!0)),r+=3,this._isBillboardBased||(i.initialDirection=e.createVertexBuffer("initialDirection",r,3,this._attributesStrideSize,!0),r+=3),i.angle=e.createVertexBuffer("angle",r,1,this._attributesStrideSize,!0),this._angularSpeedGradientsTexture?r++:r+=2,this._isAnimationSheetEnabled&&(i.cellIndex=e.createVertexBuffer("cellIndex",r,1,this._attributesStrideSize,!0),r+=1,this.spriteRandomStartCell&&(i.cellStartOffset=e.createVertexBuffer("cellStartOffset",r,1,this._attributesStrideSize,!0),r+=1)),this.noiseTexture&&(i.noiseCoordinates1=e.createVertexBuffer("noiseCoordinates1",r,3,this._attributesStrideSize,!0),r+=3,i.noiseCoordinates2=e.createVertexBuffer("noiseCoordinates2",r,3,this._attributesStrideSize,!0),r+=3),i.offset=t.createVertexBuffer("offset",0,2),i.uv=t.createVertexBuffer("uv",2,2);var n=this._engine.recordVertexArrayObject(i,null,this._renderEffect);return this._engine.bindArrayBuffer(null),n},t.prototype._initialize=function(e){if(void 0===e&&(e=!1),!this._buffer0||e){var t=this._scene.getEngine(),i=new Array;this._attributesStrideSize=21,this._targetIndex=0,this.isBillboardBased||(this._attributesStrideSize+=3),this._colorGradientsTexture&&(this._attributesStrideSize-=4),this._angularSpeedGradientsTexture&&(this._attributesStrideSize-=1),this._isAnimationSheetEnabled&&(this._attributesStrideSize+=1,this.spriteRandomStartCell&&(this._attributesStrideSize+=1)),this.noiseTexture&&(this._attributesStrideSize+=6);for(var r=0;r<this._capacity;r++)i.push(0),i.push(0),i.push(0),i.push(0),i.push(0),i.push(Math.random()),i.push(Math.random()),i.push(Math.random()),i.push(Math.random()),i.push(0),i.push(0),i.push(0),this._colorGradientsTexture||(i.push(0),i.push(0),i.push(0),i.push(0)),i.push(0),i.push(0),i.push(0),this.isBillboardBased||(i.push(0),i.push(0),i.push(0)),i.push(0),this._angularSpeedGradientsTexture||i.push(0),this._isAnimationSheetEnabled&&(i.push(0),this.spriteRandomStartCell&&i.push(0)),this.noiseTexture&&(i.push(Math.random()),i.push(Math.random()),i.push(Math.random()),i.push(Math.random()),i.push(Math.random()),i.push(Math.random()));var n=new Float32Array([.5,.5,1,1,-.5,.5,0,1,-.5,-.5,0,0,.5,-.5,1,0]);this._buffer0=new gi.a(t,i,!1,this._attributesStrideSize),this._buffer1=new gi.a(t,i,!1,this._attributesStrideSize),this._spriteBuffer=new gi.a(t,n,!1,4),this._updateVAO=[],this._updateVAO.push(this._createUpdateVAO(this._buffer0)),this._updateVAO.push(this._createUpdateVAO(this._buffer1)),this._renderVAO=[],this._renderVAO.push(this._createRenderVAO(this._buffer1,this._spriteBuffer)),this._renderVAO.push(this._createRenderVAO(this._buffer0,this._spriteBuffer)),this._sourceBuffer=this._buffer0,this._targetBuffer=this._buffer1}},t.prototype._recreateUpdateEffect=function(){var e=this.particleEmitterType?this.particleEmitterType.getEffectDefines():"";this._isBillboardBased&&(e+="\n#define BILLBOARD"),this._colorGradientsTexture&&(e+="\n#define COLORGRADIENTS"),this._sizeGradientsTexture&&(e+="\n#define SIZEGRADIENTS"),this._angularSpeedGradientsTexture&&(e+="\n#define ANGULARSPEEDGRADIENTS"),this._velocityGradientsTexture&&(e+="\n#define VELOCITYGRADIENTS"),this._limitVelocityGradientsTexture&&(e+="\n#define LIMITVELOCITYGRADIENTS"),this._dragGradientsTexture&&(e+="\n#define DRAGGRADIENTS"),this.isAnimationSheetEnabled&&(e+="\n#define ANIMATESHEET",this.spriteRandomStartCell&&(e+="\n#define ANIMATESHEETRANDOMSTART")),this.noiseTexture&&(e+="\n#define NOISE"),this._updateEffect&&this._updateEffectOptions.defines===e||(this._updateEffectOptions.transformFeedbackVaryings=["outPosition","outAge","outLife","outSeed","outSize"],this._colorGradientsTexture||this._updateEffectOptions.transformFeedbackVaryings.push("outColor"),this._updateEffectOptions.transformFeedbackVaryings.push("outDirection"),this._isBillboardBased||this._updateEffectOptions.transformFeedbackVaryings.push("outInitialDirection"),this._updateEffectOptions.transformFeedbackVaryings.push("outAngle"),this.isAnimationSheetEnabled&&(this._updateEffectOptions.transformFeedbackVaryings.push("outCellIndex"),this.spriteRandomStartCell&&this._updateEffectOptions.transformFeedbackVaryings.push("outCellStartOffset")),this.noiseTexture&&(this._updateEffectOptions.transformFeedbackVaryings.push("outNoiseCoordinates1"),this._updateEffectOptions.transformFeedbackVaryings.push("outNoiseCoordinates2")),this._updateEffectOptions.defines=e,this._updateEffect=new St.a("gpuUpdateParticles",this._updateEffectOptions,this._scene.getEngine()))},t.prototype._recreateRenderEffect=function(){var e="";if(this._scene.clipPlane&&(e="\n#define CLIPPLANE"),this._scene.clipPlane2&&(e="\n#define CLIPPLANE2"),this._scene.clipPlane3&&(e="\n#define CLIPPLANE3"),this._scene.clipPlane4&&(e="\n#define CLIPPLANE4"),this.blendMode===Ws.BLENDMODE_MULTIPLY&&(e="\n#define BLENDMULTIPLYMODE"),this._isBillboardBased)switch(e+="\n#define BILLBOARD",this.billboardMode){case Ws.BILLBOARDMODE_Y:e+="\n#define BILLBOARDY";break;case Ws.BILLBOARDMODE_STRETCHED:e+="\n#define BILLBOARDSTRETCHED";break;case Ws.BILLBOARDMODE_ALL:}if(this._colorGradientsTexture&&(e+="\n#define COLORGRADIENTS"),this.isAnimationSheetEnabled&&(e+="\n#define ANIMATESHEET"),this._imageProcessingConfiguration&&(this._imageProcessingConfiguration.prepareDefines(this._imageProcessingConfigurationDefines),e+="\n"+this._imageProcessingConfigurationDefines.toString()),!this._renderEffect||this._renderEffect.defines!==e){var t=["view","projection","colorDead","invView","vClipPlane","vClipPlane2","vClipPlane3","vClipPlane4","sheetInfos","translationPivot","eyePosition"],i=["textureSampler","colorGradientSampler"];ui.a&&(ui.a.PrepareUniforms(t,this._imageProcessingConfigurationDefines),ui.a.PrepareSamplers(i,this._imageProcessingConfigurationDefines)),this._renderEffect=new St.a("gpuRenderParticles",["position","age","life","size","color","offset","uv","direction","initialDirection","angle","cellIndex"],t,i,this._scene.getEngine(),e)}},t.prototype.animate=function(e){void 0===e&&(e=!1),this._timeDelta=this.updateSpeed*(e?this.preWarmStepOffset:this._scene.getAnimationRatio()),this._actualFrame+=this._timeDelta,this._stopped||this.targetStopDuration&&this._actualFrame>=this.targetStopDuration&&this.stop()},t.prototype._createFactorGradientTexture=function(e,t){var i=this[t];if(e&&e.length&&!i){for(var r=new Float32Array(this._rawTextureWidth),n=0;n<this._rawTextureWidth;n++){var o=n/this._rawTextureWidth;ve.h.GetCurrentGradient(o,e,function(e,t,i){r[n]=D.a.Lerp(e.factor1,t.factor1,i)})}this[t]=Ge.CreateRTexture(r,this._rawTextureWidth,1,this._scene,!1,!1,Ve.a.NEAREST_SAMPLINGMODE)}},t.prototype._createSizeGradientTexture=function(){this._createFactorGradientTexture(this._sizeGradients,"_sizeGradientsTexture")},t.prototype._createAngularSpeedGradientTexture=function(){this._createFactorGradientTexture(this._angularSpeedGradients,"_angularSpeedGradientsTexture")},t.prototype._createVelocityGradientTexture=function(){this._createFactorGradientTexture(this._velocityGradients,"_velocityGradientsTexture")},t.prototype._createLimitVelocityGradientTexture=function(){this._createFactorGradientTexture(this._limitVelocityGradients,"_limitVelocityGradientsTexture")},t.prototype._createDragGradientTexture=function(){this._createFactorGradientTexture(this._dragGradients,"_dragGradientsTexture")},t.prototype._createColorGradientTexture=function(){if(this._colorGradients&&this._colorGradients.length&&!this._colorGradientsTexture){for(var e=new Uint8Array(4*this._rawTextureWidth),t=o.t.Color4[0],i=0;i<this._rawTextureWidth;i++){var r=i/this._rawTextureWidth;ve.h.GetCurrentGradient(r,this._colorGradients,function(r,n,s){o.f.LerpToRef(r.color1,n.color1,s,t),e[4*i]=255*t.r,e[4*i+1]=255*t.g,e[4*i+2]=255*t.b,e[4*i+3]=255*t.a})}this._colorGradientsTexture=Ge.CreateRGBATexture(e,this._rawTextureWidth,1,this._scene,!1,!1,Ve.a.NEAREST_SAMPLINGMODE)}},t.prototype.render=function(e){if(void 0===e&&(e=!1),!this._started)return 0;if(this._createColorGradientTexture(),this._createSizeGradientTexture(),this._createAngularSpeedGradientTexture(),this._createVelocityGradientTexture(),this._createLimitVelocityGradientTexture(),this._createDragGradientTexture(),this._recreateUpdateEffect(),this._recreateRenderEffect(),!this.isReady())return 0;if(!e){if(!this._preWarmDone&&this.preWarmCycles){for(var t=0;t<this.preWarmCycles;t++)this.animate(!0),this.render(!0);this._preWarmDone=!0}if(this._currentRenderId===this._scene.getFrameId())return 0;this._currentRenderId=this._scene.getFrameId()}if(this._initialize(),this._accumulatedCount+=this.emitRate*this._timeDelta,this._accumulatedCount>1){var i=0|this._accumulatedCount;this._accumulatedCount-=i,this._currentActiveCount=Math.min(this._activeCount,this._currentActiveCount+i)}if(!this._currentActiveCount)return 0;var r;if(this._engine.enableEffect(this._updateEffect),this._engine.setState(!1),this._updateEffect.setFloat("currentCount",this._currentActiveCount),this._updateEffect.setFloat("timeDelta",this._timeDelta),this._updateEffect.setFloat("stopFactor",this._stopped?0:1),this._updateEffect.setTexture("randomSampler",this._randomTexture),this._updateEffect.setTexture("randomSampler2",this._randomTexture2),this._updateEffect.setFloat2("lifeTime",this.minLifeTime,this.maxLifeTime),this._updateEffect.setFloat2("emitPower",this.minEmitPower,this.maxEmitPower),this._colorGradientsTexture||(this._updateEffect.setDirectColor4("color1",this.color1),this._updateEffect.setDirectColor4("color2",this.color2)),this._updateEffect.setFloat2("sizeRange",this.minSize,this.maxSize),this._updateEffect.setFloat4("scaleRange",this.minScaleX,this.maxScaleX,this.minScaleY,this.maxScaleY),this._updateEffect.setFloat4("angleRange",this.minAngularSpeed,this.maxAngularSpeed,this.minInitialRotation,this.maxInitialRotation),this._updateEffect.setVector3("gravity",this.gravity),this._sizeGradientsTexture&&this._updateEffect.setTexture("sizeGradientSampler",this._sizeGradientsTexture),this._angularSpeedGradientsTexture&&this._updateEffect.setTexture("angularSpeedGradientSampler",this._angularSpeedGradientsTexture),this._velocityGradientsTexture&&this._updateEffect.setTexture("velocityGradientSampler",this._velocityGradientsTexture),this._limitVelocityGradientsTexture&&(this._updateEffect.setTexture("limitVelocityGradientSampler",this._limitVelocityGradientsTexture),this._updateEffect.setFloat("limitVelocityDamping",this.limitVelocityDamping)),this._dragGradientsTexture&&this._updateEffect.setTexture("dragGradientSampler",this._dragGradientsTexture),this.particleEmitterType&&this.particleEmitterType.applyToShader(this._updateEffect),this._isAnimationSheetEnabled&&this._updateEffect.setFloat3("cellInfos",this.startSpriteCellID,this.endSpriteCellID,this.spriteCellChangeSpeed),this.noiseTexture&&(this._updateEffect.setTexture("noiseSampler",this.noiseTexture),this._updateEffect.setVector3("noiseStrength",this.noiseStrength)),this.emitter.position){r=this.emitter.getWorldMatrix()}else{var n=this.emitter;r=o.j.Translation(n.x,n.y,n.z)}if(this._updateEffect.setMatrix("emitterWM",r),this._engine.bindVertexArrayObject(this._updateVAO[this._targetIndex],null),this._engine.bindTransformFeedbackBuffer(this._targetBuffer.getBuffer()),this._engine.setRasterizerState(!1),this._engine.beginTransformFeedback(!0),this._engine.drawArraysType(yn.a.PointListDrawMode,0,this._currentActiveCount),this._engine.endTransformFeedback(),this._engine.setRasterizerState(!0),this._engine.bindTransformFeedbackBuffer(null),!e){this._engine.enableEffect(this._renderEffect);var s=this._scene.getViewMatrix();if(this._renderEffect.setMatrix("view",s),this._renderEffect.setMatrix("projection",this._scene.getProjectionMatrix()),this._renderEffect.setTexture("textureSampler",this.particleTexture),this._renderEffect.setVector2("translationPivot",this.translationPivot),this._colorGradientsTexture?this._renderEffect.setTexture("colorGradientSampler",this._colorGradientsTexture):this._renderEffect.setDirectColor4("colorDead",this.colorDead),this._isAnimationSheetEnabled&&this.particleTexture){var a=this.particleTexture.getBaseSize();this._renderEffect.setFloat3("sheetInfos",this.spriteCellWidth/a.width,this.spriteCellHeight/a.height,a.width/this.spriteCellWidth)}if(this._isBillboardBased){var c=this._scene.activeCamera;this._renderEffect.setVector3("eyePosition",c.globalPosition)}if(this._scene.clipPlane||this._scene.clipPlane2||this._scene.clipPlane3||this._scene.clipPlane4){var l=s.clone();l.invert(),this._renderEffect.setMatrix("invView",l),kr.a.BindClipPlane(this._renderEffect,this._scene)}switch(this._imageProcessingConfiguration&&!this._imageProcessingConfiguration.applyByPostProcess&&this._imageProcessingConfiguration.bind(this._renderEffect),this.blendMode){case Ws.BLENDMODE_ADD:this._engine.setAlphaMode(_.a.ALPHA_ADD);break;case Ws.BLENDMODE_ONEONE:this._engine.setAlphaMode(_.a.ALPHA_ONEONE);break;case Ws.BLENDMODE_STANDARD:this._engine.setAlphaMode(_.a.ALPHA_COMBINE);break;case Ws.BLENDMODE_MULTIPLY:this._engine.setAlphaMode(_.a.ALPHA_MULTIPLY)}this.forceDepthWrite&&this._engine.setDepthWrite(!0),this._engine.bindVertexArrayObject(this._renderVAO[this._targetIndex],null),this._engine.drawArraysType(yn.a.TriangleFanDrawMode,0,4,this._currentActiveCount),this._engine.setAlphaMode(_.a.ALPHA_DISABLE)}this._targetIndex++,2===this._targetIndex&&(this._targetIndex=0);var u=this._sourceBuffer;return this._sourceBuffer=this._targetBuffer,this._targetBuffer=u,this._currentActiveCount},t.prototype.rebuild=function(){this._initialize(!0)},t.prototype._releaseBuffers=function(){this._buffer0&&(this._buffer0.dispose(),this._buffer0=null),this._buffer1&&(this._buffer1.dispose(),this._buffer1=null),this._spriteBuffer&&(this._spriteBuffer.dispose(),this._spriteBuffer=null)},t.prototype._releaseVAOs=function(){if(this._updateVAO){for(var e=0;e<this._updateVAO.length;e++)this._engine.releaseVertexArrayObject(this._updateVAO[e]);this._updateVAO=[];for(e=0;e<this._renderVAO.length;e++)this._engine.releaseVertexArrayObject(this._renderVAO[e]);this._renderVAO=[]}},t.prototype.dispose=function(e){void 0===e&&(e=!0);var t=this._scene.particleSystems.indexOf(this);t>-1&&this._scene.particleSystems.splice(t,1),this._releaseBuffers(),this._releaseVAOs(),this._colorGradientsTexture&&(this._colorGradientsTexture.dispose(),this._colorGradientsTexture=null),this._sizeGradientsTexture&&(this._sizeGradientsTexture.dispose(),this._sizeGradientsTexture=null),this._angularSpeedGradientsTexture&&(this._angularSpeedGradientsTexture.dispose(),this._angularSpeedGradientsTexture=null),this._velocityGradientsTexture&&(this._velocityGradientsTexture.dispose(),this._velocityGradientsTexture=null),this._limitVelocityGradientsTexture&&(this._limitVelocityGradientsTexture.dispose(),this._limitVelocityGradientsTexture=null),this._dragGradientsTexture&&(this._dragGradientsTexture.dispose(),this._dragGradientsTexture=null),this._randomTexture&&(this._randomTexture.dispose(),this._randomTexture=null),this._randomTexture2&&(this._randomTexture2.dispose(),this._randomTexture2=null),e&&this.particleTexture&&(this.particleTexture.dispose(),this.particleTexture=null),e&&this.noiseTexture&&(this.noiseTexture.dispose(),this.noiseTexture=null),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear()},t.prototype.clone=function(e,i){var r=new t(e,{capacity:this._capacity,randomTextureSize:this._randomTextureSize},this._scene);return S.a.DeepCopy(this,r),void 0===i&&(i=this.emitter),r.emitter=i,this.particleTexture&&(r.particleTexture=new Ve.a(this.particleTexture.url,this._scene)),r},t.prototype.serialize=function(){var e={};return Ws._Serialize(e,this),e.activeParticleCount=this.activeParticleCount,e},t.Parse=function(e,i,r,n){void 0===n&&(n=!1);var o=new t(e.name,{capacity:e.capacity,randomTextureSize:e.randomTextureSize},i);return e.activeParticleCount&&(o.activeParticleCount=e.activeParticleCount),Ws._Parse(e,o,i,r),e.preventAutoStart&&(o.preventAutoStart=e.preventAutoStart),n||o.preventAutoStart||o.start(),o},t}(Vs),Zs=(function(){}(),function(){function e(){this.systems=new Array}return Object.defineProperty(e.prototype,"emitterNode",{get:function(){return this._emitterNode},enumerable:!0,configurable:!0}),e.prototype.setEmitterAsSphere=function(e,t,i){this._emitterNode&&this._emitterNode.dispose(),this._emitterCreationOptions={kind:"Sphere",options:e,renderingGroupId:t};var r=Pr.a.CreateSphere("emitterSphere",{diameter:e.diameter,segments:e.segments},i);r.renderingGroupId=t;var n=new hi.a("emitterSphereMaterial",i);n.emissiveColor=e.color,r.material=n;for(var o=0,s=this.systems;o<s.length;o++){s[o].emitter=r}this._emitterNode=r},e.prototype.start=function(e){for(var t=0,i=this.systems;t<i.length;t++){var r=i[t];e&&(r.emitter=e),r.start()}},e.prototype.dispose=function(){for(var e=0,t=this.systems;e<t.length;e++){t[e].dispose()}this.systems=[],this._emitterNode&&(this._emitterNode.dispose(),this._emitterNode=null)},e.prototype.serialize=function(){for(var e={systems:[]},t=0,i=this.systems;t<i.length;t++){var r=i[t];e.systems.push(r.serialize())}return this._emitterNode&&(e.emitter=this._emitterCreationOptions),e},e.Parse=function(t,i,r){void 0===r&&(r=!1);var n=new e,s=_.a.PARTICLES_BaseAssetsUrl+"/textures/";i=i||R.a.LastCreatedScene;for(var a=0,c=t.systems;a<c.length;a++){var l=c[a];n.systems.push(r?qs.Parse(l,i,s,!0):Ws.Parse(l,i,s,!0))}if(t.emitter){var u=t.emitter.options;switch(t.emitter.kind){case"Sphere":n.setEmitterAsSphere({diameter:u.diameter,segments:u.segments,color:o.e.FromArray(u.color)},t.emitter.renderingGroupId,i)}}return n},e}()),Js=function(){function e(){}return e.CreateDefault=function(e,t,i,r){var n;return void 0===t&&(t=500),void 0===r&&(r=!1),(n=r?new qs("default system",{capacity:t},i):new Ws("default system",t,i)).emitter=e,n.particleTexture=new Ve.a("https://www.babylonjs.com/assets/Flare.png",n.getScene()),n.createConeEmitter(.1,Math.PI/4),n.color1=new o.f(1,1,1,1),n.color2=new o.f(1,1,1,1),n.colorDead=new o.f(1,1,1,0),n.minSize=.1,n.maxSize=.1,n.minEmitPower=2,n.maxEmitPower=2,n.updateSpeed=1/60,n.emitRate=30,n},e.CreateAsync=function(t,i,r){void 0===r&&(r=!1),i||(i=R.a.LastCreatedScene);var n={};return i._addPendingData(n),new Promise(function(o,s){if(r&&!qs.IsSupported)return i._removePendingData(n),s("Particle system with GPU is not supported.");ve.h.LoadFile(e.BaseAssetsUrl+"/systems/"+t+".json",function(e){i._removePendingData(n);var t=JSON.parse(e.toString());return o(Zs.Parse(t,i,r))},void 0,void 0,void 0,function(){return i._removePendingData(n),s("An error occured while the creation of your particle system. Check if your type '"+t+"' exists.")})})},e.ExportSet=function(e){for(var t=new Zs,i=0,r=e;i<r.length;i++){var n=r[i];t.systems.push(n)}return t},e.BaseAssetsUrl=_.a.PARTICLES_BaseAssetsUrl,e}();r.a.AddParser(Te.a.NAME_PARTICLESYSTEM,function(e,t,i,n){var o=r.a.GetIndividualParser(Te.a.NAME_PARTICLESYSTEM);if(o&&void 0!==e.particleSystems&&null!==e.particleSystems)for(var s=0,a=e.particleSystems.length;s<a;s++){var c=e.particleSystems[s];i.particleSystems.push(o(c,t,n))}}),r.a.AddIndividualParser(Te.a.NAME_PARTICLESYSTEM,function(e,t,i){return e.activeParticleCount?qs.Parse(e,t,i):Ws.Parse(e,t,i)}),_e.b.prototype.createEffectForParticles=function(e,t,i,r,n,o,s){void 0===t&&(t=[]),void 0===i&&(i=[]),void 0===r&&(r="");var a=Ws._GetAttributeNamesOrOptions(),c=Ws._GetEffectCreationOptions();return-1===r.indexOf(" BILLBOARD")&&(r+="\n#define BILLBOARD\n"),-1===i.indexOf("diffuseSampler")&&i.push("diffuseSampler"),this.createEffect({vertex:"particles",fragmentElement:e},a,c.concat(t),i,r,n,o,s)},de.a.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},de.a.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],n=r.emitter;n.position&&-1!==t.indexOf(n)&&e.push(r)}return e};var $s=function(){function e(e,t,i,r,n,s,a,c){void 0===c&&(c=null),this.idx=0,this.color=new o.f(1,1,1,1),this.position=o.x.Zero(),this.rotation=o.x.Zero(),this.scaling=o.x.One(),this.uvs=new o.y(0,0,1,1),this.velocity=o.x.Zero(),this.pivot=o.x.Zero(),this.translateFromPivot=!1,this.alive=!0,this.isVisible=!0,this._pos=0,this._ind=0,this.shapeId=0,this.idxInShape=0,this._stillInvisible=!1,this._rotationMatrix=[1,0,0,0,1,0,0,0,1],this.parentId=null,this.cullingStrategy=we.a.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY,this._globalPosition=o.x.Zero(),this.idx=e,this._pos=t,this._ind=i,this._model=r,this.shapeId=n,this.idxInShape=s,this._sps=a,c&&(this._modelBoundingInfo=c,this._boundingInfo=new Xi.a(c.minimum,c.maximum))}return Object.defineProperty(e.prototype,"scale",{get:function(){return this.scaling},set:function(e){this.scaling=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"quaternion",{get:function(){return this.rotationQuaternion},set:function(e){this.rotationQuaternion=e},enumerable:!0,configurable:!0}),e.prototype.intersectsMesh=function(e){return!(!this._boundingInfo||!e._boundingInfo)&&(this._sps._bSphereOnly?Yi.a.Intersects(this._boundingInfo.boundingSphere,e._boundingInfo.boundingSphere):this._boundingInfo.intersects(e._boundingInfo,!1))},e.prototype.isInFrustum=function(e){return null!==this._boundingInfo&&this._boundingInfo.isInFrustum(e,this.cullingStrategy)},e.prototype.getRotationMatrix=function(e){var t;if(this.rotationQuaternion)t=this.rotationQuaternion;else{t=o.t.Quaternion[0];var i=this.rotation;o.q.RotationYawPitchRollToRef(i.y,i.x,i.z,t)}t.toRotationMatrix(e)},e}(),ea=function(){return function(e,t,i,r,n,o){this._indicesLength=0,this.shapeID=e,this._shape=t,this._indicesLength=i,this._shapeUV=r,this._positionFunction=n,this._vertexFunction=o}}(),ta=function(){return function(){this.ind=0,this.indicesLength=0,this.sqDistance=0}}(),ia=function(e,t){return t.sqDistance-e.sqDistance},ra=function(){function e(e,t,i){this.particles=new Array,this.nbParticles=0,this.billboard=!1,this.recomputeNormals=!0,this.counter=0,this.vars={},this._bSphereOnly=!1,this._bSphereRadiusFactor=1,this._positions=new Array,this._indices=new Array,this._normals=new Array,this._colors=new Array,this._uvs=new Array,this._index=0,this._updatable=!0,this._pickable=!1,this._isVisibilityBoxLocked=!1,this._alwaysVisible=!1,this._depthSort=!1,this._shapeCounter=0,this._copy=new $s(0,0,0,null,0,0,this),this._color=new o.f(0,0,0,0),this._computeParticleColor=!0,this._computeParticleTexture=!0,this._computeParticleRotation=!0,this._computeParticleVertex=!1,this._computeBoundingBox=!1,this._depthSortParticles=!0,this._mustUnrotateFixedNormals=!1,this._particlesIntersect=!1,this._needs32Bits=!1,this.name=e,this._scene=t||R.a.LastCreatedScene,this._camera=t.activeCamera,this._pickable=!!i&&i.isPickable,this._depthSort=!!i&&i.enableDepthSort,this._particlesIntersect=!!i&&i.particleIntersection,this._bSphereOnly=!!i&&i.boundingSphereOnly,this._bSphereRadiusFactor=i&&i.bSphereRadiusFactor?i.bSphereRadiusFactor:1,i&&void 0!==i.updatable?this._updatable=i.updatable:this._updatable=!0,this._pickable&&(this.pickedParticles=[]),this._depthSort&&(this.depthSortedParticles=[])}return e.prototype.buildMesh=function(){if(0===this.nbParticles){var e=as.CreateDisc("",{radius:1,tessellation:3},this._scene);this.addShape(e,1),e.dispose()}this._indices32=this._needs32Bits?new Uint32Array(this._indices):new Uint16Array(this._indices),this._positions32=new Float32Array(this._positions),this._uvs32=new Float32Array(this._uvs),this._colors32=new Float32Array(this._colors),this.recomputeNormals&&_i.a.ComputeNormals(this._positions32,this._indices32,this._normals),this._normals32=new Float32Array(this._normals),this._fixedNormal32=new Float32Array(this._normals),this._mustUnrotateFixedNormals&&this._unrotateFixedNormals();var t=new _i.a;t.indices=this._depthSort?this._indices:this._indices32,t.set(this._positions32,gi.b.PositionKind),t.set(this._normals32,gi.b.NormalKind),this._uvs32.length>0&&t.set(this._uvs32,gi.b.UVKind),this._colors32.length>0&&t.set(this._colors32,gi.b.ColorKind);var i=new de.a(this.name,this._scene);return t.applyToMesh(i,this._updatable),this.mesh=i,this.mesh.isPickable=this._pickable,this._depthSort||(this._indices=null),this._positions=null,this._normals=null,this._uvs=null,this._colors=null,this._updatable||(this.particles.length=0),i},e.prototype.digest=function(e,t){var i=t&&t.facetNb||1,r=t&&t.number||0,n=t&&t.delta||0,s=e.getVerticesData(gi.b.PositionKind),a=e.getIndices(),c=e.getVerticesData(gi.b.UVKind),l=e.getVerticesData(gi.b.ColorKind),u=e.getVerticesData(gi.b.NormalKind),h=0,d=a.length/3;r?(r=r>d?d:r,i=Math.round(d/r),n=0):i=i>d?d:i;for(var f=[],p=[],_=[],g=[],m=o.x.Zero(),v=i;h<d;){h>d-(i=v+Math.floor((1+n)*Math.random()))&&(i=d-h),f.length=0,p.length=0,_.length=0,g.length=0;for(var y=0,b=3*h;b<3*(h+i);b++){p.push(y);var T=a[b];f.push(s[3*T],s[3*T+1],s[3*T+2]),c&&_.push(c[2*T],c[2*T+1]),l&&g.push(l[4*T],l[4*T+1],l[4*T+2],l[4*T+3]),y++}var E,x,A=this.nbParticles,P=this._posToShape(f),R=this._uvsToShapeUV(_);for(E=0;E<P.length;E++)m.addInPlace(P[E]);for(m.scaleInPlace(1/P.length),E=0;E<P.length;E++)P[E].subtractInPlace(m);this._particlesIntersect&&(x=new Xi.a(m,m));var S=new ea(this._shapeCounter,P,3*i,R,null,null),C=this._positions.length,M=this._indices.length;this._meshBuilder(this._index,P,this._positions,p,this._indices,_,this._uvs,g,this._colors,u,this._normals,A,0,null),this._addParticle(A,C,M,S,this._shapeCounter,0,x),this.particles[this.nbParticles].position.addInPlace(m),this._index+=P.length,A++,this.nbParticles++,this._shapeCounter++,h+=i}return this},e.prototype._unrotateFixedNormals=function(){for(var e=0,t=0,i=o.t.Vector3[0],r=o.t.Quaternion[0],n=o.t.Matrix[0],s=0;s<this.particles.length;s++){var a=this.particles[s],c=a._model._shape;if(a.rotationQuaternion)a.rotationQuaternion.conjugateToRef(r);else{var l=a.rotation;o.q.RotationYawPitchRollToRef(l.y,l.x,l.z,r),r.conjugateInPlace()}r.toRotationMatrix(n);for(var u=0;u<c.length;u++)t=e+3*u,o.x.TransformNormalFromFloatsToRef(this._normals32[t],this._normals32[t+1],this._normals32[t+2],n,i),i.toArray(this._fixedNormal32,t);e=t+3}},e.prototype._resetCopy=function(){var e=this._copy;e.position.setAll(0),e.rotation.setAll(0),e.rotationQuaternion=null,e.scaling.setAll(1),e.uvs.copyFromFloats(0,0,1,1),e.color=null,e.translateFromPivot=!1},e.prototype._meshBuilder=function(e,t,i,r,n,s,a,c,l,u,h,d,f,p){var _,g=0,m=0,v=0;this._resetCopy();var y=this._copy;p&&p.positionFunction&&(p.positionFunction(y,d,f),this._mustUnrotateFixedNormals=!0);var b=o.t.Matrix[0],T=o.t.Vector3[0],E=o.t.Vector3[1],x=o.t.Vector3[2],A=o.t.Vector3[3];for(y.getRotationMatrix(b),y.pivot.multiplyToRef(y.scaling,A),y.translateFromPivot?x.setAll(0):x.copyFrom(A),_=0;_<t.length;_++){if(T.copyFrom(t[_]),p&&p.vertexFunction&&p.vertexFunction(y,T,_),T.multiplyInPlace(y.scaling).subtractInPlace(A),o.x.TransformCoordinatesToRef(T,b,E),E.addInPlace(x).addInPlace(y.position),i.push(E.x,E.y,E.z),s){var P=y.uvs;a.push((P.z-P.x)*s[g]+P.x,(P.w-P.y)*s[g+1]+P.y),g+=2}if(y.color)this._color=y.color;else{var R=this._color;c&&void 0!==c[m]?(R.r=c[m],R.g=c[m+1],R.b=c[m+2],R.a=c[m+3]):(R.r=1,R.g=1,R.b=1,R.a=1)}l.push(this._color.r,this._color.g,this._color.b,this._color.a),m+=4,!this.recomputeNormals&&u&&(T.x=u[v],T.y=u[v+1],T.z=u[v+2],o.x.TransformNormalToRef(T,b,T),h.push(T.x,T.y,T.z),v+=3)}for(_=0;_<r.length;_++){var S=e+r[_];n.push(S),S>65535&&(this._needs32Bits=!0)}if(this._pickable){var C=r.length/3;for(_=0;_<C;_++)this.pickedParticles.push({idx:d,faceId:_})}return this._depthSort&&this.depthSortedParticles.push(new ta),y},e.prototype._posToShape=function(e){for(var t=[],i=0;i<e.length;i+=3)t.push(o.x.FromArray(e,i));return t},e.prototype._uvsToShapeUV=function(e){var t=[];if(e)for(var i=0;i<e.length;i++)t.push(e[i]);return t},e.prototype._addParticle=function(e,t,i,r,n,o,s){void 0===s&&(s=null);var a=new $s(e,t,i,r,n,o,this,s);return this.particles.push(a),a},e.prototype.addShape=function(e,t,i){var r,n=e.getVerticesData(gi.b.PositionKind),o=e.getIndices(),s=e.getVerticesData(gi.b.UVKind),a=e.getVerticesData(gi.b.ColorKind),c=e.getVerticesData(gi.b.NormalKind);this._particlesIntersect&&(r=e.getBoundingInfo());for(var l,u,h=this._posToShape(n),d=this._uvsToShapeUV(s),f=i?i.positionFunction:null,p=i?i.vertexFunction:null,_=new ea(this._shapeCounter,h,o.length,d,f,p),g=this.nbParticles,m=0;m<t;m++){var v=this._positions.length,y=this._indices.length;u=this._meshBuilder(this._index,h,this._positions,o,this._indices,s,this._uvs,a,this._colors,c,this._normals,g,m,i),this._updatable&&((l=this._addParticle(g,v,y,_,this._shapeCounter,m,r)).position.copyFrom(u.position),l.rotation.copyFrom(u.rotation),u.rotationQuaternion&&l.rotationQuaternion&&l.rotationQuaternion.copyFrom(u.rotationQuaternion),u.color&&l.color&&l.color.copyFrom(u.color),l.scaling.copyFrom(u.scaling),l.uvs.copyFrom(u.uvs)),this._index+=h.length,g++}return this.nbParticles+=t,this._shapeCounter++,this._shapeCounter-1},e.prototype._rebuildParticle=function(e){this._resetCopy();var t=this._copy;e._model._positionFunction&&e._model._positionFunction(t,e.idx,e.idxInShape);var i=o.t.Matrix[0],r=o.t.Vector3[0],n=o.t.Vector3[1],s=o.t.Vector3[2],a=o.t.Vector3[3];t.getRotationMatrix(i),e.pivot.multiplyToRef(e.scaling,a),t.translateFromPivot?s.copyFromFloats(0,0,0):s.copyFrom(a);for(var c=e._model._shape,l=0;l<c.length;l++)r.copyFrom(c[l]),e._model._vertexFunction&&e._model._vertexFunction(t,r,l),r.multiplyInPlace(t.scaling).subtractInPlace(a),o.x.TransformCoordinatesToRef(r,i,n),n.addInPlace(s).addInPlace(t.position).toArray(this._positions32,e._pos+3*l);e.position.setAll(0),e.rotation.setAll(0),e.rotationQuaternion=null,e.scaling.setAll(1),e.uvs.setAll(0),e.pivot.setAll(0),e.translateFromPivot=!1,e.parentId=null},e.prototype.rebuildMesh=function(){for(var e=0;e<this.particles.length;e++)this._rebuildParticle(this.particles[e]);return this.mesh.updateVerticesData(gi.b.PositionKind,this._positions32,!1,!1),this},e.prototype.setParticles=function(e,t,i){if(void 0===e&&(e=0),void 0===t&&(t=this.nbParticles-1),void 0===i&&(i=!0),!this._updatable)return this;this.beforeUpdateParticles(e,t,i);var r=o.t.Matrix[0],n=o.t.Matrix[1],s=this.mesh,a=this._colors32,c=this._positions32,l=this._normals32,u=this._uvs32,h=this._indices32,d=this._indices,f=this._fixedNormal32,p=o.t.Vector3,_=p[5].copyFromFloats(1,0,0),g=p[6].copyFromFloats(0,1,0),m=p[7].copyFromFloats(0,0,1),v=p[8].setAll(Number.MAX_VALUE),y=p[9].setAll(-Number.MAX_VALUE),b=p[10].setAll(0);if((this.billboard||this._depthSort)&&(this.mesh.computeWorldMatrix(!0),this.mesh._worldMatrix.invertToRef(n)),this.billboard){var T=p[0];this._camera.getDirectionToRef(o.c.Z,T),o.x.TransformNormalToRef(T,n,m),m.normalize();var E=this._camera.getViewMatrix(!0);o.x.TransformNormalFromFloatsToRef(E.m[1],E.m[5],E.m[9],n,g),o.x.CrossToRef(g,m,_),g.normalize(),_.normalize()}this._depthSort&&o.x.TransformCoordinatesToRef(this._camera.globalPosition,n,b),o.j.IdentityToRef(r);var x=0,A=0,P=0,R=0,S=0,C=0,M=0;if(this.mesh.isFacetDataEnabled&&(this._computeBoundingBox=!0),t=t>=this.nbParticles?this.nbParticles-1:t,this._computeBoundingBox&&(0!=e||t!=this.nbParticles-1)){var O=this.mesh._boundingInfo;O&&(v.copyFrom(O.minimum),y.copyFrom(O.maximum))}var I=(A=this.particles[e]._pos)/3|0;R=4*I,C=2*I;for(var D=e;D<=t;D++){var w=this.particles[D];this.updateParticle(w);var L=w._model._shape,F=w._model._shapeUV,N=w._rotationMatrix,B=w.position,U=w.rotation,V=w.scaling,G=w._globalPosition;if(this._depthSort&&this._depthSortParticles){var k=this.depthSortedParticles[D];k.ind=w._ind,k.indicesLength=w._model._indicesLength,k.sqDistance=o.x.DistanceSquared(w.position,b)}if(!w.alive||w._stillInvisible&&!w.isVisible)A+=3*(M=L.length),R+=4*M,C+=2*M;else{if(w.isVisible){w._stillInvisible=!1;var z=p[12];if(w.pivot.multiplyToRef(V,z),this.billboard&&(U.x=0,U.y=0),(this._computeParticleRotation||this.billboard)&&w.getRotationMatrix(r),null!==w.parentId){var j=this.particles[w.parentId],W=j._rotationMatrix,H=j._globalPosition,X=B.x*W[1]+B.y*W[4]+B.z*W[7],Y=B.x*W[0]+B.y*W[3]+B.z*W[6],K=B.x*W[2]+B.y*W[5]+B.z*W[8];if(G.x=H.x+Y,G.y=H.y+X,G.z=H.z+K,this._computeParticleRotation||this.billboard){var Q=r.m;N[0]=Q[0]*W[0]+Q[1]*W[3]+Q[2]*W[6],N[1]=Q[0]*W[1]+Q[1]*W[4]+Q[2]*W[7],N[2]=Q[0]*W[2]+Q[1]*W[5]+Q[2]*W[8],N[3]=Q[4]*W[0]+Q[5]*W[3]+Q[6]*W[6],N[4]=Q[4]*W[1]+Q[5]*W[4]+Q[6]*W[7],N[5]=Q[4]*W[2]+Q[5]*W[5]+Q[6]*W[8],N[6]=Q[8]*W[0]+Q[9]*W[3]+Q[10]*W[6],N[7]=Q[8]*W[1]+Q[9]*W[4]+Q[10]*W[7],N[8]=Q[8]*W[2]+Q[9]*W[5]+Q[10]*W[8]}}else if(G.x=B.x,G.y=B.y,G.z=B.z,this._computeParticleRotation||this.billboard){Q=r.m;N[0]=Q[0],N[1]=Q[1],N[2]=Q[2],N[3]=Q[4],N[4]=Q[5],N[5]=Q[6],N[6]=Q[8],N[7]=Q[9],N[8]=Q[10]}var q=p[11];for(w.translateFromPivot?q.setAll(0):q.copyFrom(z),M=0;M<L.length;M++){x=A+3*M,P=R+4*M,S=C+2*M,(T=p[0]).copyFrom(L[M]),this._computeParticleVertex&&this.updateParticleVertex(w,T,M);var Z=T.x*V.x-z.x,J=T.y*V.y-z.y,$=T.z*V.z-z.z;Y=Z*N[0]+J*N[3]+$*N[6],X=Z*N[1]+J*N[4]+$*N[7],K=Z*N[2]+J*N[5]+$*N[8];Y+=q.x,X+=q.y,K+=q.z;var ee=c[x]=G.x+_.x*Y+g.x*X+m.x*K,te=c[x+1]=G.y+_.y*Y+g.y*X+m.y*K,ie=c[x+2]=G.z+_.z*Y+g.z*X+m.z*K;if(this._computeBoundingBox&&(v.minimizeInPlaceFromFloats(ee,te,ie),y.maximizeInPlaceFromFloats(ee,te,ie)),!this._computeParticleVertex){var re=f[x],ne=f[x+1],oe=f[x+2],se=re*N[0]+ne*N[3]+oe*N[6],ae=re*N[1]+ne*N[4]+oe*N[7],ce=re*N[2]+ne*N[5]+oe*N[8];l[x]=_.x*se+g.x*ae+m.x*ce,l[x+1]=_.y*se+g.y*ae+m.y*ce,l[x+2]=_.z*se+g.z*ae+m.z*ce}if(this._computeParticleColor&&w.color){var le=w.color,ue=this._colors32;ue[P]=le.r,ue[P+1]=le.g,ue[P+2]=le.b,ue[P+3]=le.a}if(this._computeParticleTexture){var he=w.uvs;u[S]=F[2*M]*(he.z-he.x)+he.x,u[S+1]=F[2*M+1]*(he.w-he.y)+he.y}}}else for(w._stillInvisible=!0,M=0;M<L.length;M++){if(P=R+4*M,S=C+2*M,c[x=A+3*M]=c[x+1]=c[x+2]=0,l[x]=l[x+1]=l[x+2]=0,this._computeParticleColor&&w.color){le=w.color;a[P]=le.r,a[P+1]=le.g,a[P+2]=le.b,a[P+3]=le.a}if(this._computeParticleTexture){he=w.uvs;u[S]=F[2*M]*(he.z-he.x)+he.x,u[S+1]=F[2*M+1]*(he.w-he.y)+he.y}}if(this._particlesIntersect){var de=w._boundingInfo,fe=de.boundingBox,pe=de.boundingSphere,_e=w._modelBoundingInfo;if(!this._bSphereOnly){var ge=_e.boundingBox.vectors,me=p[1],ve=p[2];me.setAll(Number.MAX_VALUE),ve.setAll(-Number.MAX_VALUE);for(var ye=0;ye<8;ye++){var be=ge[ye].x*V.x,Te=ge[ye].y*V.y,Ee=ge[ye].z*V.z,xe=(Y=be*N[0]+Te*N[3]+Ee*N[6],X=be*N[1]+Te*N[4]+Ee*N[7],K=be*N[2]+Te*N[5]+Ee*N[8],B.x+_.x*Y+g.x*X+m.x*K),Ae=B.y+_.y*Y+g.y*X+m.y*K,Pe=B.z+_.z*Y+g.z*X+m.z*K;me.minimizeInPlaceFromFloats(xe,Ae,Pe),ve.maximizeInPlaceFromFloats(xe,Ae,Pe)}fe.reConstruct(me,ve,s._worldMatrix)}var Re=_e.minimum.multiplyToRef(V,p[1]),Se=_e.maximum.multiplyToRef(V,p[2]),Ce=Se.addToRef(Re,p[3]).scaleInPlace(.5).addInPlace(G),Me=Se.subtractToRef(Re,p[4]).scaleInPlace(.5*this._bSphereRadiusFactor),Oe=Ce.subtractToRef(Me,p[1]),Ie=Ce.addToRef(Me,p[2]);pe.reConstruct(Oe,Ie,s._worldMatrix)}A=x+3,R=P+4,C=S+2}}if(i){if(this._computeParticleColor&&s.updateVerticesData(gi.b.ColorKind,a,!1,!1),this._computeParticleTexture&&s.updateVerticesData(gi.b.UVKind,u,!1,!1),s.updateVerticesData(gi.b.PositionKind,c,!1,!1),!s.areNormalsFrozen||s.isFacetDataEnabled){if(this._computeParticleVertex||s.isFacetDataEnabled){var De=s.isFacetDataEnabled?s.getFacetDataParameters():null;_i.a.ComputeNormals(c,h,l,De);for(var we=0;we<l.length;we++)f[we]=l[we]}s.areNormalsFrozen||s.updateVerticesData(gi.b.NormalKind,l,!1,!1)}if(this._depthSort&&this._depthSortParticles){var Le=this.depthSortedParticles;Le.sort(ia);for(var Fe=Le.length,Ne=0,Be=0;Be<Fe;Be++){var Ue=Le[Be].indicesLength,Ve=Le[Be].ind;for(we=0;we<Ue;we++)h[Ne]=d[Ve+we],Ne++}s.updateIndices(h)}}return this._computeBoundingBox&&(s._boundingInfo?s._boundingInfo.reConstruct(v,y,s._worldMatrix):s._boundingInfo=new Xi.a(v,y,s._worldMatrix)),this.afterUpdateParticles(e,t,i),this},e.prototype.dispose=function(){this.mesh.dispose(),this.vars=null,this._positions=null,this._indices=null,this._normals=null,this._uvs=null,this._colors=null,this._indices32=null,this._positions32=null,this._normals32=null,this._fixedNormal32=null,this._uvs32=null,this._colors32=null,this.pickedParticles=null},e.prototype.refreshVisibleSize=function(){return this._isVisibilityBoxLocked||this.mesh.refreshBoundingInfo(),this},e.prototype.setVisibilityBox=function(e){var t=e/2;this.mesh._boundingInfo=new Xi.a(new o.x(-t,-t,-t),new o.x(t,t,t))},Object.defineProperty(e.prototype,"isAlwaysVisible",{get:function(){return this._alwaysVisible},set:function(e){this._alwaysVisible=e,this.mesh.alwaysSelectAsActiveMesh=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isVisibilityBoxLocked",{get:function(){return this._isVisibilityBoxLocked},set:function(e){this._isVisibilityBoxLocked=e,this.mesh.getBoundingInfo().isLocked=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"computeParticleRotation",{get:function(){return this._computeParticleRotation},set:function(e){this._computeParticleRotation=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"computeParticleColor",{get:function(){return this._computeParticleColor},set:function(e){this._computeParticleColor=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"computeParticleTexture",{get:function(){return this._computeParticleTexture},set:function(e){this._computeParticleTexture=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"computeParticleVertex",{get:function(){return this._computeParticleVertex},set:function(e){this._computeParticleVertex=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"computeBoundingBox",{get:function(){return this._computeBoundingBox},set:function(e){this._computeBoundingBox=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"depthSortParticles",{get:function(){return this._depthSortParticles},set:function(e){this._depthSortParticles=e},enumerable:!0,configurable:!0}),e.prototype.initParticles=function(){},e.prototype.recycleParticle=function(e){return e},e.prototype.updateParticle=function(e){return e},e.prototype.updateParticleVertex=function(e,t,i){return t},e.prototype.beforeUpdateParticles=function(e,t,i){},e.prototype.afterUpdateParticles=function(e,t,i){},e}();W.a.prototype.getPhysicsEngine=function(){return this._physicsEngine},W.a.prototype.enablePhysics=function(e,t){if(void 0===e&&(e=null),this._physicsEngine)return!0;var i=this._getComponent(Te.a.NAME_PHYSICSENGINE);i||(i=new sa(this),this._addComponent(i));try{return this._physicsEngine=new so(e,t),!0}catch(e){return p.a.Error(e.message),!1}},W.a.prototype.disablePhysicsEngine=function(){this._physicsEngine&&(this._physicsEngine.dispose(),this._physicsEngine=null)},W.a.prototype.isPhysicsEnabled=function(){return void 0!==this._physicsEngine},W.a.prototype.deleteCompoundImpostor=function(e){var t=e.parts[0].mesh;t.physicsImpostor&&(t.physicsImpostor.dispose(),t.physicsImpostor=null)},W.a.prototype._advancePhysicsEngineStep=function(e){this._physicsEngine&&(this.onBeforePhysicsObservable.notifyObservers(this),this._physicsEngine._step(e/1e3),this.onAfterPhysicsObservable.notifyObservers(this))},Object.defineProperty(we.a.prototype,"physicsImpostor",{get:function(){return this._physicsImpostor},set:function(e){var t=this;this._physicsImpostor!==e&&(this._disposePhysicsObserver&&this.onDisposeObservable.remove(this._disposePhysicsObserver),this._physicsImpostor=e,e&&(this._disposePhysicsObserver=this.onDisposeObservable.add(function(){t.physicsImpostor&&(t.physicsImpostor.dispose(),t.physicsImpostor=null)})))},enumerable:!0,configurable:!0}),we.a.prototype.getPhysicsImpostor=function(){return this.physicsImpostor},we.a.prototype.applyImpulse=function(e,t){return this.physicsImpostor?(this.physicsImpostor.applyImpulse(e,t),this):this},we.a.prototype.setPhysicsLinkWith=function(e,t,i,r){return this.physicsImpostor&&e.physicsImpostor?(this.physicsImpostor.createJoint(e.physicsImpostor,oo.e.HingeJoint,{mainPivot:t,connectedPivot:i,nativeParams:r}),this):this};var na,oa,sa=function(){function e(e){var t=this;this.name=Te.a.NAME_PHYSICSENGINE,this.scene=e,this.scene.onBeforePhysicsObservable=new n.c,this.scene.onAfterPhysicsObservable=new n.c,this.scene.getDeterministicFrameTime=function(){return t.scene._physicsEngine?1e3*t.scene._physicsEngine.getTimeStep():1e3/60}}return e.prototype.register=function(){},e.prototype.rebuild=function(){},e.prototype.dispose=function(){this.scene.onBeforePhysicsObservable.clear(),this.scene.onAfterPhysicsObservable.clear(),this.scene._physicsEngine&&this.scene.disablePhysicsEngine()},e}(),aa=function(){function e(e){this._scene=e,this._physicsEngine=this._scene.getPhysicsEngine(),this._physicsEngine||p.a.Warn("Physics engine not enabled. Please enable the physics before you can use the methods.")}return e.prototype.applyRadialExplosionImpulse=function(e,t,i,r){if(void 0===r&&(r=na.Constant),!this._physicsEngine)return p.a.Warn("Physics engine not enabled. Please enable the physics before you call this method."),null;var n=this._physicsEngine.getImpostors();if(0===n.length)return null;var o=new ca(this._scene);return n.forEach(function(n){var s=o.getImpostorForceAndContactPoint(n,e,t,i,r);s&&n.applyImpulse(s.force,s.contactPoint)}),o.dispose(!1),o},e.prototype.applyRadialExplosionForce=function(e,t,i,r){if(void 0===r&&(r=na.Constant),!this._physicsEngine)return p.a.Warn("Physics engine not enabled. Please enable the physics before you call the PhysicsHelper."),null;var n=this._physicsEngine.getImpostors();if(0===n.length)return null;var o=new ca(this._scene);return n.forEach(function(n){var s=o.getImpostorForceAndContactPoint(n,e,t,i,r);s&&n.applyForce(s.force,s.contactPoint)}),o.dispose(!1),o},e.prototype.gravitationalField=function(e,t,i,r){if(void 0===r&&(r=na.Constant),!this._physicsEngine)return p.a.Warn("Physics engine not enabled. Please enable the physics before you call the PhysicsHelper."),null;if(0===this._physicsEngine.getImpostors().length)return null;var n=new la(this,this._scene,e,t,i,r);return n.dispose(!1),n},e.prototype.updraft=function(e,t,i,r,n){if(void 0===n&&(n=oa.Center),!this._physicsEngine)return p.a.Warn("Physics engine not enabled. Please enable the physics before you call the PhysicsHelper."),null;if(0===this._physicsEngine.getImpostors().length)return null;var o=new ua(this._scene,e,t,i,r,n);return o.dispose(!1),o},e.prototype.vortex=function(e,t,i,r){if(!this._physicsEngine)return p.a.Warn("Physics engine not enabled. Please enable the physics before you call the PhysicsHelper."),null;if(0===this._physicsEngine.getImpostors().length)return null;var n=new ha(this._scene,e,t,i,r);return n.dispose(!1),n},e}(),ca=function(){function e(e){this._sphereOptions={segments:32,diameter:1},this._rays=[],this._dataFetched=!1,this._scene=e}return e.prototype.getData=function(){return this._dataFetched=!0,{sphere:this._sphere,rays:this._rays}},e.prototype.getImpostorForceAndContactPoint=function(e,t,i,r,n){if(0===e.mass)return null;if(!this._intersectsWithSphere(e,t,i))return null;if("Mesh"!==e.object.getClassName()&&"InstancedMesh"!==e.object.getClassName())return null;var s=e.getObjectCenter().subtract(t),a=new ei.a(t,s,i);this._rays.push(a);var c=a.intersectsMesh(e.object).pickedPoint;if(!c)return null;var l=o.x.Distance(t,c);if(l>i)return null;var u=n===na.Constant?r:r*(1-l/i);return{force:s.multiplyByFloats(u,u,u),contactPoint:c}},e.prototype.dispose=function(e){var t=this;void 0===e&&(e=!0),e?this._sphere.dispose():setTimeout(function(){t._dataFetched||t._sphere.dispose()},0)},e.prototype._prepareSphere=function(){this._sphere||(this._sphere=Pr.a.CreateSphere("radialExplosionEventSphere",this._sphereOptions,this._scene),this._sphere.isVisible=!1)},e.prototype._intersectsWithSphere=function(e,t,i){var r=e.object;return this._prepareSphere(),this._sphere.position=t,this._sphere.scaling=new o.x(2*i,2*i,2*i),this._sphere._updateBoundingInfo(),this._sphere.computeWorldMatrix(!0),this._sphere.intersectsMesh(r,!0)},e}(),la=function(){function e(e,t,i,r,n,o){void 0===o&&(o=na.Constant),this._dataFetched=!1,this._physicsHelper=e,this._scene=t,this._origin=i,this._radius=r,this._strength=n,this._falloff=o,this._tickCallback=this._tick.bind(this)}return e.prototype.getData=function(){return this._dataFetched=!0,{sphere:this._sphere}},e.prototype.enable=function(){this._tickCallback.call(this),this._scene.registerBeforeRender(this._tickCallback)},e.prototype.disable=function(){this._scene.unregisterBeforeRender(this._tickCallback)},e.prototype.dispose=function(e){var t=this;void 0===e&&(e=!0),e?this._sphere.dispose():setTimeout(function(){t._dataFetched||t._sphere.dispose()},0)},e.prototype._tick=function(){if(this._sphere)this._physicsHelper.applyRadialExplosionForce(this._origin,this._radius,-1*this._strength,this._falloff);else{var e=this._physicsHelper.applyRadialExplosionForce(this._origin,this._radius,-1*this._strength,this._falloff);e&&(this._sphere=e.getData().sphere.clone("radialExplosionEventSphereClone"))}},e}(),ua=function(){function e(e,t,i,r,n,s){this._scene=e,this._origin=t,this._radius=i,this._strength=r,this._height=n,this._updraftMode=s,this._originTop=o.x.Zero(),this._originDirection=o.x.Zero(),this._cylinderPosition=o.x.Zero(),this._dataFetched=!1,this._physicsEngine=this._scene.getPhysicsEngine(),this._origin.addToRef(new o.x(0,this._height/2,0),this._cylinderPosition),this._origin.addToRef(new o.x(0,this._height,0),this._originTop),this._updraftMode===oa.Perpendicular&&(this._originDirection=this._origin.subtract(this._originTop).normalize()),this._tickCallback=this._tick.bind(this),this._prepareCylinder()}return e.prototype.getData=function(){return this._dataFetched=!0,{cylinder:this._cylinder}},e.prototype.enable=function(){this._tickCallback.call(this),this._scene.registerBeforeRender(this._tickCallback)},e.prototype.disable=function(){this._scene.unregisterBeforeRender(this._tickCallback)},e.prototype.dispose=function(e){var t=this;void 0===e&&(e=!0),this._cylinder&&(e?this._cylinder.dispose():setTimeout(function(){t._dataFetched||t._cylinder.dispose()},0))},e.prototype.getImpostorForceAndContactPoint=function(e){if(0===e.mass)return null;if(!this._intersectsWithCylinder(e))return null;var t=e.getObjectCenter();if(this._updraftMode===oa.Perpendicular)var i=this._originDirection;else i=t.subtract(this._originTop);var r=-1*this._strength;return{force:i.multiplyByFloats(r,r,r),contactPoint:t}},e.prototype._tick=function(){var e=this;this._physicsEngine.getImpostors().forEach(function(t){var i=e.getImpostorForceAndContactPoint(t);i&&t.applyForce(i.force,i.contactPoint)})},e.prototype._prepareCylinder=function(){this._cylinder||(this._cylinder=bi.a.CreateCylinder("updraftEventCylinder",{height:this._height,diameter:2*this._radius},this._scene),this._cylinder.isVisible=!1)},e.prototype._intersectsWithCylinder=function(e){var t=e.object;return this._cylinder.position=this._cylinderPosition,this._cylinder.intersectsMesh(t,!0)},e}(),ha=function(){function e(e,t,i,r,n){this._scene=e,this._origin=t,this._radius=i,this._strength=r,this._height=n,this._originTop=o.x.Zero(),this._centripetalForceThreshold=.7,this._updraftMultiplier=.02,this._cylinderPosition=o.x.Zero(),this._dataFetched=!1,this._physicsEngine=this._scene.getPhysicsEngine(),this._origin.addToRef(new o.x(0,this._height/2,0),this._cylinderPosition),this._origin.addToRef(new o.x(0,this._height,0),this._originTop),this._tickCallback=this._tick.bind(this),this._prepareCylinder()}return e.prototype.getData=function(){return this._dataFetched=!0,{cylinder:this._cylinder}},e.prototype.enable=function(){this._tickCallback.call(this),this._scene.registerBeforeRender(this._tickCallback)},e.prototype.disable=function(){this._scene.unregisterBeforeRender(this._tickCallback)},e.prototype.dispose=function(e){var t=this;void 0===e&&(e=!0),e?this._cylinder.dispose():setTimeout(function(){t._dataFetched||t._cylinder.dispose()},0)},e.prototype.getImpostorForceAndContactPoint=function(e){if(0===e.mass)return null;if(!this._intersectsWithCylinder(e))return null;if("Mesh"!==e.object.getClassName()&&"InstancedMesh"!==e.object.getClassName())return null;var t=e.getObjectCenter(),i=new o.x(this._origin.x,t.y,this._origin.z),r=t.subtract(i),n=new ei.a(i,r,this._radius).intersectsMesh(e.object),s=n.pickedPoint;if(!s)return null;var a=n.distance/this._radius,c=o.x.Cross(i,t).normalize(),l=s.normalize();if(a>this._centripetalForceThreshold&&(l=l.negate()),a>this._centripetalForceThreshold)var u=l.x*this._strength/8,h=l.y*this._updraftMultiplier,d=l.z*this._strength/8;else u=(c.x+l.x)/2,h=this._originTop.y*this._updraftMultiplier,d=(c.z+l.z)/2;var f=new o.x(u,h,d);return{force:f=f.multiplyByFloats(this._strength,this._strength,this._strength),contactPoint:t}},e.prototype._tick=function(){var e=this;this._physicsEngine.getImpostors().forEach(function(t){var i=e.getImpostorForceAndContactPoint(t);i&&t.applyForce(i.force,i.contactPoint)})},e.prototype._prepareCylinder=function(){this._cylinder||(this._cylinder=bi.a.CreateCylinder("vortexEventCylinder",{height:this._height,diameter:2*this._radius},this._scene),this._cylinder.isVisible=!1)},e.prototype._intersectsWithCylinder=function(e){var t=e.object;return this._cylinder.position=this._cylinderPosition,this._cylinder.intersectsMesh(t,!0)},e}();!function(e){e[e.Constant=0]="Constant",e[e.Linear=1]="Linear"}(na||(na={})),function(e){e[e.Center=0]="Center",e[e.Perpendicular=1]="Perpendicular"}(oa||(oa={}));var da=function(){function e(e,t){void 0===e&&(e=!0),void 0===t&&(t=Ammo);var i=this;this._useDeltaForWorldStep=e,this.bjsAMMO={},this.name="AmmoJSPlugin",this._timeStep=1/60,this._fixedTimeStep=1/60,this._maxSteps=5,this._tmpQuaternion=new o.q,this._tmpContactCallbackResult=!1,this._tmpVector=new o.x,this._tmpMatrix=new o.j,"function"==typeof t?t(this.bjsAMMO):this.bjsAMMO=t,this.isSupported()?(this._collisionConfiguration=new this.bjsAMMO.btDefaultCollisionConfiguration,this._dispatcher=new this.bjsAMMO.btCollisionDispatcher(this._collisionConfiguration),this._overlappingPairCache=new this.bjsAMMO.btDbvtBroadphase,this._solver=new this.bjsAMMO.btSequentialImpulseConstraintSolver,this.world=new this.bjsAMMO.btDiscreteDynamicsWorld(this._dispatcher,this._overlappingPairCache,this._solver,this._collisionConfiguration),this._tmpAmmoConcreteContactResultCallback=new this.bjsAMMO.ConcreteContactResultCallback,this._tmpAmmoConcreteContactResultCallback.addSingleResult=function(){i._tmpContactCallbackResult=!0},this._tmpAmmoTransform=new this.bjsAMMO.btTransform,this._tmpAmmoTransform.setIdentity(),this._tmpAmmoQuaternion=new this.bjsAMMO.btQuaternion(0,0,0,1),this._tmpAmmoVectorA=new this.bjsAMMO.btVector3(0,0,0),this._tmpAmmoVectorB=new this.bjsAMMO.btVector3(0,0,0),this._tmpAmmoVectorC=new this.bjsAMMO.btVector3(0,0,0)):p.a.Error("AmmoJS is not available. Please make sure you included the js file.")}return e.prototype.setGravity=function(e){this._tmpAmmoVectorA.setValue(e.x,e.y,e.z),this.world.setGravity(this._tmpAmmoVectorA)},e.prototype.setTimeStep=function(e){this._timeStep=e},e.prototype.setFixedTimeStep=function(e){this._fixedTimeStep=e},e.prototype.setMaxSteps=function(e){this._maxSteps=e},e.prototype.getTimeStep=function(){return this._timeStep},e.prototype._isImpostorInContact=function(e){return this._tmpContactCallbackResult=!1,this.world.contactTest(e.physicsBody,this._tmpAmmoConcreteContactResultCallback),this._tmpContactCallbackResult},e.prototype._isImpostorPairInContact=function(e,t){return this._tmpContactCallbackResult=!1,this.world.contactPairTest(e.physicsBody,t.physicsBody,this._tmpAmmoConcreteContactResultCallback),this._tmpContactCallbackResult},e.prototype._stepSimulation=function(e,t,i){if(void 0===e&&(e=1/60),void 0===t&&(t=10),void 0===i&&(i=1/60),0==t)this.world.stepSimulation(e,0);else for(;t>0&&e>0;)e-i<i?(this.world.stepSimulation(e,0),e=0):(e-=i,this.world.stepSimulation(i,0)),t--},e.prototype.executeStep=function(e,t){for(var i=0,r=t;i<r.length;i++){r[i].beforeStep()}this._stepSimulation(this._useDeltaForWorldStep?e:this._timeStep,this._maxSteps,this._fixedTimeStep);for(var n=0,o=t;n<o.length;n++){var s=o[n];if(s.afterStep(),s._onPhysicsCollideCallbacks.length>0&&this._isImpostorInContact(s))for(var a=0,c=s._onPhysicsCollideCallbacks;a<c.length;a++)for(var l=0,u=c[a].otherImpostors;l<u.length;l++){var h=u[l];(s.physicsBody.isActive()||h.physicsBody.isActive())&&this._isImpostorPairInContact(s,h)&&(s.onCollide({body:h.physicsBody}),h.onCollide({body:s.physicsBody}))}}},e.prototype.applyImpulse=function(e,t,i){e.physicsBody.activate();var r=this._tmpAmmoVectorA,n=this._tmpAmmoVectorB;e.object&&e.object.getWorldMatrix&&(e.object.getWorldMatrix().invertToRef(this._tmpMatrix),o.x.TransformCoordinatesToRef(i,this._tmpMatrix,this._tmpVector),i=this._tmpVector),r.setValue(i.x,i.y,i.z),n.setValue(t.x,t.y,t.z),e.physicsBody.applyImpulse(n,r)},e.prototype.applyForce=function(e,t,i){e.physicsBody.activate();var r=this._tmpAmmoVectorA,n=this._tmpAmmoVectorB;e.object&&e.object.getWorldMatrix&&(e.object.getWorldMatrix().invertToRef(this._tmpMatrix),o.x.TransformCoordinatesToRef(i,this._tmpMatrix,this._tmpVector),i=this._tmpVector),r.setValue(i.x,i.y,i.z),n.setValue(t.x,t.y,t.z),e.physicsBody.applyForce(n,r)},e.prototype.generatePhysicsBody=function(t){if(t._pluginData={toDispose:[]},t.parent)t.physicsBody&&(this.removePhysicsBody(t),t.forceUpdate());else if(t.isBodyInitRequired()){var i=this._createShape(t),r=t.getParam("mass");t._pluginData.mass=r;var n=new Ammo.btVector3(0,0,0),o=new Ammo.btTransform;o.setIdentity(),0!==r&&i.calculateLocalInertia(r,n),this._tmpAmmoVectorA.setValue(t.object.position.x,t.object.position.y,t.object.position.z),this._tmpAmmoQuaternion.setValue(t.object.rotationQuaternion.x,t.object.rotationQuaternion.y,t.object.rotationQuaternion.z,t.object.rotationQuaternion.w),o.setOrigin(this._tmpAmmoVectorA),o.setRotation(this._tmpAmmoQuaternion);var s=new Ammo.btDefaultMotionState(o),a=new Ammo.btRigidBodyConstructionInfo(r,s,i,n),c=new Ammo.btRigidBody(a);0===r&&(c.setCollisionFlags(c.getCollisionFlags()|e.KINEMATIC_FLAG),c.setActivationState(e.DISABLE_DEACTIVATION_FLAG)),t.type!=no.a.NoImpostor||i.getChildShape||c.setCollisionFlags(c.getCollisionFlags()|e.DISABLE_COLLISION_FLAG),this.world.addRigidBody(c),t.physicsBody=c,this.setBodyRestitution(t,t.getParam("restitution")),this.setBodyFriction(t,t.getParam("friction")),t._pluginData.toDispose.concat([c,a,s,o,n,i])}},e.prototype.removePhysicsBody=function(e){var t=this;this.world&&(this.world.removeRigidBody(e.physicsBody),e._pluginData.toDispose.forEach(function(e){t.bjsAMMO.destroy(e)}))},e.prototype.generateJoint=function(e){var t=e.mainImpostor.physicsBody,i=e.connectedImpostor.physicsBody;if(t&&i){var r,n=e.joint.jointData;switch(n.mainPivot||(n.mainPivot=new o.x(0,0,0)),n.connectedPivot||(n.connectedPivot=new o.x(0,0,0)),e.joint.type){case oo.e.DistanceJoint:var s=n.maxDistance;s&&(n.mainPivot=new o.x(0,-s/2,0),n.connectedPivot=new o.x(0,s/2,0)),r=new Ammo.btPoint2PointConstraint(t,i,new Ammo.btVector3(n.mainPivot.x,n.mainPivot.y,n.mainPivot.z),new Ammo.btVector3(n.connectedPivot.x,n.connectedPivot.y,n.connectedPivot.z));break;case oo.e.HingeJoint:n.mainAxis||(n.mainAxis=new o.x(0,0,0)),n.connectedAxis||(n.connectedAxis=new o.x(0,0,0));var a=new Ammo.btVector3(n.mainAxis.x,n.mainAxis.y,n.mainAxis.z),c=new Ammo.btVector3(n.connectedAxis.x,n.connectedAxis.y,n.connectedAxis.z);r=new Ammo.btHingeConstraint(t,i,new Ammo.btVector3(n.mainPivot.x,n.mainPivot.y,n.mainPivot.z),new Ammo.btVector3(n.connectedPivot.x,n.connectedPivot.y,n.connectedPivot.z),a,c);break;case oo.e.BallAndSocketJoint:r=new Ammo.btPoint2PointConstraint(t,i,new Ammo.btVector3(n.mainPivot.x,n.mainPivot.y,n.mainPivot.z),new Ammo.btVector3(n.connectedPivot.x,n.connectedPivot.y,n.connectedPivot.z));break;default:p.a.Warn("JointType not currently supported by the Ammo plugin, falling back to PhysicsJoint.BallAndSocketJoint"),r=new Ammo.btPoint2PointConstraint(t,i,new Ammo.btVector3(n.mainPivot.x,n.mainPivot.y,n.mainPivot.z),new Ammo.btVector3(n.connectedPivot.x,n.connectedPivot.y,n.connectedPivot.z))}this.world.addConstraint(r,!e.joint.jointData.collision),e.joint.physicsJoint=r}},e.prototype.removeJoint=function(e){this.world&&this.world.removeConstraint(e.joint.physicsJoint)},e.prototype._addMeshVerts=function(e,t,i){var r=this,n=0;if(i&&i.getIndices&&i.getWorldMatrix&&i.getChildMeshes){var s=i.getIndices();s||(s=[]);var a=i.getVerticesData(gi.b.PositionKind);a||(a=[]),i.computeWorldMatrix(!1);for(var c=s.length/3,l=0;l<c;l++){for(var u=[],h=0;h<3;h++){var d,f=new o.x(a[3*s[3*l+h]+0],a[3*s[3*l+h]+1],a[3*s[3*l+h]+2]);(f=o.x.TransformCoordinates(f,i.getWorldMatrix())).subtractInPlace(t.position),(d=0==h?this._tmpAmmoVectorA:1==h?this._tmpAmmoVectorB:this._tmpAmmoVectorC).setValue(f.x,f.y,f.z),u.push(d)}e.addTriangle(u[0],u[1],u[2]),n++}i.getChildMeshes().forEach(function(i){n+=r._addMeshVerts(e,t,i)})}return n},e.prototype._createShape=function(e,t){var i=this;void 0===t&&(t=!1);var r,n=e.object,s=e.getObjectExtendSize();if(!t){var a=e.object.getChildMeshes?e.object.getChildMeshes(!0):[];r=new Ammo.btCompoundShape;var c=0;if(a.forEach(function(e){var t=e.getPhysicsImpostor();if(t){var n=i._createShape(t),s=e.parent.getWorldMatrix().clone(),a=new o.x;s.decompose(a),i._tmpAmmoTransform.getOrigin().setValue(e.position.x*a.x,e.position.y*a.y,e.position.z*a.z),i._tmpAmmoQuaternion.setValue(e.rotationQuaternion.x,e.rotationQuaternion.y,e.rotationQuaternion.z,e.rotationQuaternion.w),i._tmpAmmoTransform.setRotation(i._tmpAmmoQuaternion),r.addChildShape(i._tmpAmmoTransform,n),t.dispose(),c++}}),c>0){if(e.type!=no.a.NoImpostor){var l=this._createShape(e,!0);l&&(this._tmpAmmoTransform.getOrigin().setValue(0,0,0),this._tmpAmmoQuaternion.setValue(0,0,0,1),this._tmpAmmoTransform.setRotation(this._tmpAmmoQuaternion),r.addChildShape(this._tmpAmmoTransform,l))}return r}Ammo.destroy(r),r=null}switch(e.type){case no.a.SphereImpostor:r=new Ammo.btSphereShape(s.x/2);break;case no.a.CylinderImpostor:this._tmpAmmoVectorA.setValue(s.x/2,s.y/2,s.z/2),r=new Ammo.btCylinderShape(this._tmpAmmoVectorA);break;case no.a.PlaneImpostor:case no.a.BoxImpostor:this._tmpAmmoVectorA.setValue(s.x/2,s.y/2,s.z/2),r=new Ammo.btBoxShape(this._tmpAmmoVectorA);break;case no.a.MeshImpostor:var u=new Ammo.btTriangleMesh;e._pluginData.toDispose.concat([u]);var h=this._addMeshVerts(u,n,n);r=0==h?new Ammo.btCompoundShape:new Ammo.btBvhTriangleMeshShape(u);break;case no.a.NoImpostor:r=new Ammo.btSphereShape(s.x/2);break;default:p.a.Warn("The impostor type is not currently supported by the ammo plugin.")}return r},e.prototype.setTransformationFromPhysicsBody=function(e){e.physicsBody.getMotionState().getWorldTransform(this._tmpAmmoTransform),e.object.position.set(this._tmpAmmoTransform.getOrigin().x(),this._tmpAmmoTransform.getOrigin().y(),this._tmpAmmoTransform.getOrigin().z()),e.object.rotationQuaternion?e.object.rotationQuaternion.set(this._tmpAmmoTransform.getRotation().x(),this._tmpAmmoTransform.getRotation().y(),this._tmpAmmoTransform.getRotation().z(),this._tmpAmmoTransform.getRotation().w()):e.object.rotation&&(this._tmpQuaternion.set(this._tmpAmmoTransform.getRotation().x(),this._tmpAmmoTransform.getRotation().y(),this._tmpAmmoTransform.getRotation().z(),this._tmpAmmoTransform.getRotation().w()),this._tmpQuaternion.toEulerAnglesToRef(e.object.rotation))},e.prototype.setPhysicsBodyTransformation=function(e,t,i){var r=e.physicsBody.getWorldTransform();if(r.getOrigin().x()!=t.x||r.getOrigin().y()!=t.y||r.getOrigin().z()!=t.z||r.getRotation().x()!=i.x||r.getRotation().y()!=i.y||r.getRotation().z()!=i.z||r.getRotation().w()!=i.w)if(this._tmpAmmoVectorA.setValue(t.x,t.y,t.z),r.setOrigin(this._tmpAmmoVectorA),this._tmpAmmoQuaternion.setValue(i.x,i.y,i.z,i.w),r.setRotation(this._tmpAmmoQuaternion),e.physicsBody.setWorldTransform(r),0==e.mass){var n=e.physicsBody.getMotionState();n&&n.setWorldTransform(r)}else e.physicsBody.activate()},e.prototype.isSupported=function(){return void 0!==this.bjsAMMO},e.prototype.setLinearVelocity=function(e,t){this._tmpAmmoVectorA.setValue(t.x,t.y,t.z),e.physicsBody.setLinearVelocity(this._tmpAmmoVectorA)},e.prototype.setAngularVelocity=function(e,t){this._tmpAmmoVectorA.setValue(t.x,t.y,t.z),e.physicsBody.setAngularVelocity(this._tmpAmmoVectorA)},e.prototype.getLinearVelocity=function(e){var t=e.physicsBody.getLinearVelocity();return t?new o.x(t.x(),t.y(),t.z()):null},e.prototype.getAngularVelocity=function(e){var t=e.physicsBody.getAngularVelocity();return t?new o.x(t.x(),t.y(),t.z()):null},e.prototype.setBodyMass=function(e,t){e.physicsBody.setMassProps(t),e._pluginData.mass=t},e.prototype.getBodyMass=function(e){return e._pluginData.mass},e.prototype.getBodyFriction=function(e){return e._pluginData.friction},e.prototype.setBodyFriction=function(e,t){e.physicsBody.setFriction(t),e._pluginData.friction=t},e.prototype.getBodyRestitution=function(e){return e._pluginData.restitution},e.prototype.setBodyRestitution=function(e,t){e.physicsBody.setRestitution(t),e._pluginData.restitution=t},e.prototype.sleepBody=function(e){p.a.Warn("sleepBody is not currently supported by the Ammo physics plugin")},e.prototype.wakeUpBody=function(e){e.physicsBody.activate()},e.prototype.updateDistanceJoint=function(e,t,i){p.a.Warn("updateDistanceJoint is not currently supported by the Ammo physics plugin")},e.prototype.setMotor=function(e,t,i,r){e.physicsJoint.enableAngularMotor(!0,t,i)},e.prototype.setLimit=function(e,t,i){p.a.Warn("setLimit is not currently supported by the Ammo physics plugin")},e.prototype.syncMeshWithImpostor=function(e,t){t.physicsBody.getMotionState().getWorldTransform(this._tmpAmmoTransform),e.position.x=this._tmpAmmoTransform.getOrigin().x(),e.position.y=this._tmpAmmoTransform.getOrigin().y(),e.position.z=this._tmpAmmoTransform.getOrigin().z(),e.rotationQuaternion&&(e.rotationQuaternion.x=this._tmpAmmoTransform.getRotation().x(),e.rotationQuaternion.y=this._tmpAmmoTransform.getRotation().y(),e.rotationQuaternion.z=this._tmpAmmoTransform.getRotation().z(),e.rotationQuaternion.w=this._tmpAmmoTransform.getRotation().w())},e.prototype.getRadius=function(e){return e.getObjectExtendSize().x/2},e.prototype.getBoxSizeToRef=function(e,t){var i=e.getObjectExtendSize();t.x=i.x,t.y=i.y,t.z=i.z},e.prototype.dispose=function(){Ammo.destroy(this.world),Ammo.destroy(this._solver),Ammo.destroy(this._overlappingPairCache),Ammo.destroy(this._dispatcher),Ammo.destroy(this._collisionConfiguration),Ammo.destroy(this._tmpAmmoVectorA),Ammo.destroy(this._tmpAmmoVectorB),Ammo.destroy(this._tmpAmmoVectorC),Ammo.destroy(this._tmpAmmoTransform),Ammo.destroy(this._tmpAmmoQuaternion),Ammo.destroy(this._tmpAmmoConcreteContactResultCallback),this.world=null},e.DISABLE_COLLISION_FLAG=4,e.KINEMATIC_FLAG=2,e.DISABLE_DEACTIVATION_FLAG=4,e}(),fa="\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform float degree;\nvoid main(void)\n{\nvec3 color=texture2D(textureSampler,vUV).rgb;\nfloat luminance=dot(color,vec3(0.3,0.59,0.11));\nvec3 blackAndWhite=vec3(luminance,luminance,luminance);\ngl_FragColor=vec4(color-((color-blackAndWhite)*degree),1.0);\n}";St.a.ShadersStore.blackAndWhitePixelShader=fa;var pa=function(e){function t(t,i,r,n,o,s){var a=e.call(this,t,"blackAndWhite",["degree"],null,i,r,n,o,s)||this;return a.degree=1,a.onApplyObservable.add(function(e){e.setFloat("degree",a.degree)}),a}return l.d(t,e),t}(Mt),_a=function(){function e(e,t,i,r){this._name=t,this._singleInstance=r||!0,this._getPostProcesses=i,this._cameras={},this._indicesForCamera={},this._postProcesses={}}return Object.defineProperty(e.prototype,"isSupported",{get:function(){for(var e in this._postProcesses)if(this._postProcesses.hasOwnProperty(e))for(var t=this._postProcesses[e],i=0;i<t.length;i++)if(!t[i].isSupported)return!1;return!0},enumerable:!0,configurable:!0}),e.prototype._update=function(){},e.prototype._attachCameras=function(e){var t,i=this,r=ve.h.MakeArray(e||this._cameras);if(r)for(var n=0;n<r.length;n++){var o=r[n],s=o.name;if(t=this._singleInstance?0:s,!this._postProcesses[t]){var a=this._getPostProcesses();a&&(this._postProcesses[t]=Array.isArray(a)?a:[a])}this._indicesForCamera[s]||(this._indicesForCamera[s]=[]),this._postProcesses[t].forEach(function(e){var t=o.attachPostProcess(e);i._indicesForCamera[s].push(t)}),this._cameras[s]||(this._cameras[s]=o)}},e.prototype._detachCameras=function(e){var t=ve.h.MakeArray(e||this._cameras);if(t)for(var i=0;i<t.length;i++){var r=t[i],n=r.name,o=this._postProcesses[this._singleInstance?0:n];o&&o.forEach(function(e){r.detachPostProcess(e)}),this._cameras[n]&&(this._cameras[n]=null)}},e.prototype._enable=function(e){var t=this,i=ve.h.MakeArray(e||this._cameras);if(i)for(var r=0;r<i.length;r++)for(var n=i[r],o=n.name,s=0;s<this._indicesForCamera[o].length;s++)void 0!==n._postProcesses[this._indicesForCamera[o][s]]&&null!==n._postProcesses[this._indicesForCamera[o][s]]||this._postProcesses[this._singleInstance?0:o].forEach(function(e){i[r].attachPostProcess(e,t._indicesForCamera[o][s])})},e.prototype._disable=function(e){var t=ve.h.MakeArray(e||this._cameras);if(t)for(var i=0;i<t.length;i++){var r=t[i],n=r.name;this._postProcesses[this._singleInstance?0:n].forEach(function(e){r.detachPostProcess(e)})}},e.prototype.getPostProcesses=function(e){return this._singleInstance?this._postProcesses[0]:e?this._postProcesses[e.name]:null},e}(),ga="#include<helperFunctions>\n\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform float threshold;\nuniform float exposure;\nvoid main(void)\n{\ngl_FragColor=texture2D(textureSampler,vUV);\nfloat luma=getLuminance(gl_FragColor.rgb*exposure);\ngl_FragColor.rgb=step(threshold,luma)*gl_FragColor.rgb;\n}";St.a.ShadersStore.extractHighlightsPixelShader=ga;var ma=function(e){function t(t,i,r,n,s,a,c,l){void 0===c&&(c=_.a.TEXTURETYPE_UNSIGNED_INT),void 0===l&&(l=!1);var u=e.call(this,t,"extractHighlights",["threshold","exposure"],null,i,r,n,s,a,null,c,void 0,null,l)||this;return u.threshold=.9,u._exposure=1,u._inputPostProcess=null,u.onApplyObservable.add(function(e){u._inputPostProcess&&e.setTextureFromPostProcess("textureSampler",u._inputPostProcess),e.setFloat("threshold",Math.pow(u.threshold,o.u)),e.setFloat("exposure",u._exposure)}),u}return l.d(t,e),t}(Mt),va="uniform sampler2D textureSampler;\nuniform sampler2D bloomBlur;\nvarying vec2 vUV;\nuniform float bloomWeight;\nvoid main(void)\n{\ngl_FragColor=texture2D(textureSampler,vUV);\nvec3 blurred=texture2D(bloomBlur,vUV).rgb;\ngl_FragColor.rgb=gl_FragColor.rgb+(blurred.rgb*bloomWeight);\n}\n";St.a.ShadersStore.bloomMergePixelShader=va;var ya=function(e){function t(t,i,r,n,o,s,a,c,l,u,h){void 0===u&&(u=_.a.TEXTURETYPE_UNSIGNED_INT),void 0===h&&(h=!1);var d=e.call(this,t,"bloomMerge",["bloomWeight"],["circleOfConfusionSampler","blurStep0","blurStep1","blurStep2","bloomBlur"],o,s,a,c,l,null,u,void 0,null,!0)||this;return d.weight=n,d.onApplyObservable.add(function(e){e.setTextureFromPostProcess("textureSampler",i),e.setTextureFromPostProcessOutput("bloomBlur",r),e.setFloat("bloomWeight",d.weight)}),h||d.updateEffect(),d}return l.d(t,e),t}(Mt),ba=function(e){function t(t,i,r,n,s,a){void 0===s&&(s=0),void 0===a&&(a=!1);var c=e.call(this,t.getEngine(),"bloom",function(){return c._effects},!0)||this;return c.bloomScale=i,c._effects=[],c._downscale=new ma("highlights",1,null,Ve.a.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,s,a),c._blurX=new Ur("horizontal blur",new o.w(1,0),10,i,null,Ve.a.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,s,void 0,a),c._blurX.alwaysForcePOT=!0,c._blurX.autoClear=!1,c._blurY=new Ur("vertical blur",new o.w(0,1),10,i,null,Ve.a.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,s,void 0,a),c._blurY.alwaysForcePOT=!0,c._blurY.autoClear=!1,c.kernel=n,c._effects=[c._downscale,c._blurX,c._blurY],c._merge=new ya("bloomMerge",c._downscale,c._blurY,r,i,null,Ve.a.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,s,a),c._merge.autoClear=!1,c._effects.push(c._merge),c}return l.d(t,e),Object.defineProperty(t.prototype,"threshold",{get:function(){return this._downscale.threshold},set:function(e){this._downscale.threshold=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"weight",{get:function(){return this._merge.weight},set:function(e){this._merge.weight=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"kernel",{get:function(){return this._blurX.kernel/this.bloomScale},set:function(e){this._blurX.kernel=e*this.bloomScale,this._blurY.kernel=e*this.bloomScale},enumerable:!0,configurable:!0}),t.prototype.disposeEffects=function(e){for(var t=0;t<this._effects.length;t++)this._effects[t].dispose(e)},t.prototype._updateEffects=function(){for(var e=0;e<this._effects.length;e++)this._effects[e].updateEffect()},t.prototype._isReady=function(){for(var e=0;e<this._effects.length;e++)if(!this._effects[e].isReady())return!1;return!0},t}(_a),Ta="\nuniform sampler2D textureSampler;\n\nuniform float chromatic_aberration;\nuniform float radialIntensity;\nuniform vec2 direction;\nuniform vec2 centerPosition;\nuniform float screen_width;\nuniform float screen_height;\n\nvarying vec2 vUV;\nvoid main(void)\n{\nvec2 centered_screen_pos=vec2(vUV.x-centerPosition.x,vUV.y-centerPosition.y);\nvec2 directionOfEffect=direction;\nif(directionOfEffect.x == 0. && directionOfEffect.y == 0.){\ndirectionOfEffect=normalize(centered_screen_pos);\n}\nfloat radius2=centered_screen_pos.x*centered_screen_pos.x\n+centered_screen_pos.y*centered_screen_pos.y;\nfloat radius=sqrt(radius2);\nvec4 original=texture2D(textureSampler,vUV);\n\nvec3 ref_indices=vec3(-0.3,0.0,0.3);\nfloat ref_shiftX=chromatic_aberration*pow(radius,radialIntensity)*directionOfEffect.x/screen_width;\nfloat ref_shiftY=chromatic_aberration*pow(radius,radialIntensity)*directionOfEffect.y/screen_height;\n\nvec2 ref_coords_r=vec2(vUV.x+ref_indices.r*ref_shiftX,vUV.y+ref_indices.r*ref_shiftY*0.5);\nvec2 ref_coords_g=vec2(vUV.x+ref_indices.g*ref_shiftX,vUV.y+ref_indices.g*ref_shiftY*0.5);\nvec2 ref_coords_b=vec2(vUV.x+ref_indices.b*ref_shiftX,vUV.y+ref_indices.b*ref_shiftY*0.5);\noriginal.r=texture2D(textureSampler,ref_coords_r).r;\noriginal.g=texture2D(textureSampler,ref_coords_g).g;\noriginal.b=texture2D(textureSampler,ref_coords_b).b;\noriginal.a=clamp(texture2D(textureSampler,ref_coords_r).a+texture2D(textureSampler,ref_coords_g).a+texture2D(textureSampler,ref_coords_b).a,0.,1.);\ngl_FragColor=original;\n}";St.a.ShadersStore.chromaticAberrationPixelShader=Ta;var Ea=function(e){function t(t,i,r,n,s,a,c,l,u,h){void 0===u&&(u=_.a.TEXTURETYPE_UNSIGNED_INT),void 0===h&&(h=!1);var d=e.call(this,t,"chromaticAberration",["chromatic_aberration","screen_width","screen_height","direction","radialIntensity","centerPosition"],[],n,s,a,c,l,null,u,void 0,null,h)||this;return d.aberrationAmount=30,d.radialIntensity=0,d.direction=new o.w(.707,.707),d.centerPosition=new o.w(.5,.5),d.onApplyObservable.add(function(e){e.setFloat("chromatic_aberration",d.aberrationAmount),e.setFloat("screen_width",i),e.setFloat("screen_height",r),e.setFloat("radialIntensity",d.radialIntensity),e.setFloat2("direction",d.direction.x,d.direction.y),e.setFloat2("centerPosition",d.centerPosition.x,d.centerPosition.y)}),d}return l.d(t,e),t}(Mt),xa="\nuniform sampler2D depthSampler;\n\nvarying vec2 vUV;\n\nuniform vec2 cameraMinMaxZ;\n\nuniform float focusDistance;\nuniform float cocPrecalculation;\nvoid main(void)\n{\nfloat depth=texture2D(depthSampler,vUV).r;\nfloat pixelDistance=(cameraMinMaxZ.x+(cameraMinMaxZ.y-cameraMinMaxZ.x)*depth)*1000.0;\nfloat coc=abs(cocPrecalculation* ((focusDistance-pixelDistance)/pixelDistance));\ncoc=clamp(coc,0.0,1.0);\ngl_FragColor=vec4(coc,depth,coc,1.0);\n}\n";St.a.ShadersStore.circleOfConfusionPixelShader=xa;var Aa=function(e){function t(t,i,r,n,o,s,a,c,l){void 0===c&&(c=_.a.TEXTURETYPE_UNSIGNED_INT),void 0===l&&(l=!1);var u=e.call(this,t,"circleOfConfusion",["cameraMinMaxZ","focusDistance","cocPrecalculation"],["depthSampler"],r,n,o,s,a,null,c,void 0,null,l)||this;return u.lensSize=50,u.fStop=1.4,u.focusDistance=2e3,u.focalLength=50,u._depthTexture=null,u._depthTexture=i,u.onApplyObservable.add(function(e){if(u._depthTexture){e.setTexture("depthSampler",u._depthTexture);var t=u.lensSize/u.fStop*u.focalLength/(u.focusDistance-u.focalLength);e.setFloat("focusDistance",u.focusDistance),e.setFloat("cocPrecalculation",t),e.setFloat2("cameraMinMaxZ",u._depthTexture.activeCamera.minZ,u._depthTexture.activeCamera.maxZ)}else p.a.Warn("No depth texture set on CircleOfConfusionPostProcess")}),u}return l.d(t,e),Object.defineProperty(t.prototype,"depthTexture",{set:function(e){this._depthTexture=e},enumerable:!0,configurable:!0}),t}(Mt),Pa="\nuniform sampler2D textureSampler;\nuniform sampler2D colorTable;\n\nvarying vec2 vUV;\n\nconst float SLICE_COUNT=16.0;\n\nvec4 sampleAs3DTexture(sampler2D textureSampler,vec3 uv,float width) {\nfloat sliceSize=1.0/width;\nfloat slicePixelSize=sliceSize/width;\nfloat sliceInnerSize=slicePixelSize*(width-1.0);\nfloat zSlice0=min(floor(uv.z*width),width-1.0);\nfloat zSlice1=min(zSlice0+1.0,width-1.0);\nfloat xOffset=slicePixelSize*0.5+uv.x*sliceInnerSize;\nfloat s0=xOffset+(zSlice0*sliceSize);\nfloat s1=xOffset+(zSlice1*sliceSize);\nvec4 slice0Color=texture2D(textureSampler,vec2(s0,uv.y));\nvec4 slice1Color=texture2D(textureSampler,vec2(s1,uv.y));\nfloat zOffset=mod(uv.z*width,1.0);\nvec4 result=mix(slice0Color,slice1Color,zOffset);\nreturn result;\n}\nvoid main(void)\n{\nvec4 screen_color=texture2D(textureSampler,vUV);\ngl_FragColor=sampleAs3DTexture(colorTable,screen_color.rgb,SLICE_COUNT);\n}";St.a.ShadersStore.colorCorrectionPixelShader=Pa;var Ra=function(e){function t(t,i,r,n,o,s,a){var c=e.call(this,t,"colorCorrection",null,["colorTable"],r,n,o,s,a)||this;return c._colorTableTexture=new Ve.a(i,n.getScene(),!0,!1,Ve.a.TRILINEAR_SAMPLINGMODE),c._colorTableTexture.anisotropicFilteringLevel=1,c._colorTableTexture.wrapU=Ve.a.CLAMP_ADDRESSMODE,c._colorTableTexture.wrapV=Ve.a.CLAMP_ADDRESSMODE,c.onApply=function(e){e.setTexture("colorTable",c._colorTableTexture)},c}return l.d(t,e),t}(Mt),Sa="\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform vec2 screenSize;\nuniform float kernel[9];\nvoid main(void)\n{\nvec2 onePixel=vec2(1.0,1.0)/screenSize;\nvec4 colorSum =\ntexture2D(textureSampler,vUV+onePixel*vec2(-1,-1))*kernel[0] +\ntexture2D(textureSampler,vUV+onePixel*vec2(0,-1))*kernel[1] +\ntexture2D(textureSampler,vUV+onePixel*vec2(1,-1))*kernel[2] +\ntexture2D(textureSampler,vUV+onePixel*vec2(-1,0))*kernel[3] +\ntexture2D(textureSampler,vUV+onePixel*vec2(0,0))*kernel[4] +\ntexture2D(textureSampler,vUV+onePixel*vec2(1,0))*kernel[5] +\ntexture2D(textureSampler,vUV+onePixel*vec2(-1,1))*kernel[6] +\ntexture2D(textureSampler,vUV+onePixel*vec2(0,1))*kernel[7] +\ntexture2D(textureSampler,vUV+onePixel*vec2(1,1))*kernel[8];\nfloat kernelWeight =\nkernel[0] +\nkernel[1] +\nkernel[2] +\nkernel[3] +\nkernel[4] +\nkernel[5] +\nkernel[6] +\nkernel[7] +\nkernel[8];\nif (kernelWeight<=0.0) {\nkernelWeight=1.0;\n}\ngl_FragColor=vec4((colorSum/kernelWeight).rgb,1);\n}";St.a.ShadersStore.convolutionPixelShader=Sa;var Ca=function(e){function t(t,i,r,n,o,s,a,c){void 0===c&&(c=_.a.TEXTURETYPE_UNSIGNED_INT);var l=e.call(this,t,"convolution",["kernel","screenSize"],null,r,n,o,s,a,null,c)||this;return l.kernel=i,l.onApply=function(e){e.setFloat2("screenSize",l.width,l.height),e.setArray("kernel",l.kernel)},l}return l.d(t,e),t.EdgeDetect0Kernel=[1,0,-1,0,0,0,-1,0,1],t.EdgeDetect1Kernel=[0,1,0,1,-4,1,0,1,0],t.EdgeDetect2Kernel=[-1,-1,-1,-1,8,-1,-1,-1,-1],t.SharpenKernel=[0,-1,0,-1,5,-1,0,-1,0],t.EmbossKernel=[-2,-1,0,-1,1,1,0,1,2],t.GaussianKernel=[0,1,0,1,1,1,0,1,0],t}(Mt),Ma=function(e){function t(t,i,r,n,o,s,a,c,l,u,h,d,f){void 0===c&&(c=null),void 0===l&&(l=Ve.a.BILINEAR_SAMPLINGMODE),void 0===d&&(d=_.a.TEXTURETYPE_UNSIGNED_INT),void 0===f&&(f=!1);var p=e.call(this,t,r,n,o,s,l=_.a.TEXTURE_BILINEAR_SAMPLINGMODE,u,h,d=_.a.TEXTURETYPE_UNSIGNED_INT,"#define DOF 1\r\n",f)||this;return p.direction=r,p.onApplyObservable.add(function(e){null!=c&&e.setTextureFromPostProcess("textureSampler",c),e.setTextureFromPostProcessOutput("circleOfConfusionSampler",a),i.activeCamera&&e.setFloat2("cameraMinMaxZ",i.activeCamera.minZ,i.activeCamera.maxZ)}),p}return l.d(t,e),t}(Ur),Oa="uniform sampler2D textureSampler;\nvarying vec2 vUV;\nuniform sampler2D circleOfConfusionSampler;\nuniform sampler2D blurStep0;\n#if BLUR_LEVEL>0\nuniform sampler2D blurStep1;\n#endif\n#if BLUR_LEVEL>1\nuniform sampler2D blurStep2;\n#endif\nvoid main(void)\n{\nfloat coc=texture2D(circleOfConfusionSampler,vUV).r;\n#if BLUR_LEVEL == 0\nvec4 original=texture2D(textureSampler,vUV);\nvec4 blurred0=texture2D(blurStep0,vUV);\ngl_FragColor=mix(original,blurred0,coc);\n#endif\n#if BLUR_LEVEL == 1\nif(coc<0.5){\nvec4 original=texture2D(textureSampler,vUV);\nvec4 blurred1=texture2D(blurStep1,vUV);\ngl_FragColor=mix(original,blurred1,coc/0.5);\n}else{\nvec4 blurred0=texture2D(blurStep0,vUV);\nvec4 blurred1=texture2D(blurStep1,vUV);\ngl_FragColor=mix(blurred1,blurred0,(coc-0.5)/0.5);\n}\n#endif\n#if BLUR_LEVEL == 2\nif(coc<0.33){\nvec4 original=texture2D(textureSampler,vUV);\nvec4 blurred2=texture2D(blurStep2,vUV);\ngl_FragColor=mix(original,blurred2,coc/0.33);\n}else if(coc<0.66){\nvec4 blurred1=texture2D(blurStep1,vUV);\nvec4 blurred2=texture2D(blurStep2,vUV);\ngl_FragColor=mix(blurred2,blurred1,(coc-0.33)/0.33);\n}else{\nvec4 blurred0=texture2D(blurStep0,vUV);\nvec4 blurred1=texture2D(blurStep1,vUV);\ngl_FragColor=mix(blurred1,blurred0,(coc-0.66)/0.34);\n}\n#endif\n}\n";St.a.ShadersStore.depthOfFieldMergePixelShader=Oa;var Ia,Da=function(){return function(){}}(),wa=function(e){function t(t,i,r,n,o,s,a,c,l,u,h){void 0===u&&(u=_.a.TEXTURETYPE_UNSIGNED_INT),void 0===h&&(h=!1);var d=e.call(this,t,"depthOfFieldMerge",[],["circleOfConfusionSampler","blurStep0","blurStep1","blurStep2"],o,s,a,c,l,null,u,void 0,null,!0)||this;return d.blurSteps=n,d.onApplyObservable.add(function(e){e.setTextureFromPostProcess("textureSampler",i),e.setTextureFromPostProcessOutput("circleOfConfusionSampler",r),n.forEach(function(t,i){e.setTextureFromPostProcessOutput("blurStep"+(n.length-i-1),t)})}),h||d.updateEffect(),d}return l.d(t,e),t.prototype.updateEffect=function(t,i,r,n,o,s){void 0===t&&(t=null),void 0===i&&(i=null),void 0===r&&(r=null),t||(t="",t+="#define BLUR_LEVEL "+(this.blurSteps.length-1)+"\n"),e.prototype.updateEffect.call(this,t,i,r,n,o,s)},t}(Mt);!function(e){e[e.Low=0]="Low",e[e.Medium=1]="Medium",e[e.High=2]="High"}(Ia||(Ia={}));var La=function(e){function t(t,i,r,n,s){void 0===r&&(r=Ia.Low),void 0===n&&(n=0),void 0===s&&(s=!1);var a=e.call(this,t.getEngine(),"depth of field",function(){return a._effects},!0)||this;a._effects=[],a._circleOfConfusion=new Aa("circleOfConfusion",i,1,null,Ve.a.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,n,s),a._depthOfFieldBlurY=[],a._depthOfFieldBlurX=[];var c=1,l=15;switch(r){case Ia.High:c=3,l=51;break;case Ia.Medium:c=2,l=31;break;default:l=15,c=1}for(var u=l/Math.pow(2,c-1),h=1,d=0;d<c;d++){var f=new Ma("verticle blur",t,new o.w(0,1),u,h,null,a._circleOfConfusion,0==d?a._circleOfConfusion:null,Ve.a.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,n,s);f.autoClear=!1,h=.75/Math.pow(2,d);var p=new Ma("horizontal blur",t,new o.w(1,0),u,h,null,a._circleOfConfusion,null,Ve.a.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,n,s);p.autoClear=!1,a._depthOfFieldBlurY.push(f),a._depthOfFieldBlurX.push(p)}a._effects=[a._circleOfConfusion];for(d=0;d<a._depthOfFieldBlurX.length;d++)a._effects.push(a._depthOfFieldBlurY[d]),a._effects.push(a._depthOfFieldBlurX[d]);return a._dofMerge=new wa("dofMerge",a._circleOfConfusion,a._circleOfConfusion,a._depthOfFieldBlurX,h,null,Ve.a.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,n,s),a._dofMerge.autoClear=!1,a._effects.push(a._dofMerge),a}return l.d(t,e),Object.defineProperty(t.prototype,"focalLength",{get:function(){return this._circleOfConfusion.focalLength},set:function(e){this._circleOfConfusion.focalLength=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"fStop",{get:function(){return this._circleOfConfusion.fStop},set:function(e){this._circleOfConfusion.fStop=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"focusDistance",{get:function(){return this._circleOfConfusion.focusDistance},set:function(e){this._circleOfConfusion.focusDistance=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"lensSize",{get:function(){return this._circleOfConfusion.lensSize},set:function(e){this._circleOfConfusion.lensSize=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"depthTexture",{set:function(e){this._circleOfConfusion.depthTexture=e},enumerable:!0,configurable:!0}),t.prototype.disposeEffects=function(e){for(var t=0;t<this._effects.length;t++)this._effects[t].dispose(e)},t.prototype._updateEffects=function(){for(var e=0;e<this._effects.length;e++)this._effects[e].updateEffect()},t.prototype._isReady=function(){for(var e=0;e<this._effects.length;e++)if(!this._effects[e].isReady())return!1;return!0},t}(_a),Fa="\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform sampler2D passSampler;\nvoid main(void)\n{\ngl_FragColor=texture2D(passSampler,vUV);\n}";St.a.ShadersStore.displayPassPixelShader=Fa;var Na=function(e){function t(t,i,r,n,o,s){return e.call(this,t,"displayPass",["passSampler"],["passSampler"],i,r,n,o,s)||this}return l.d(t,e),t}(Mt),Ba="\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform mat4 kernelMatrix;\nvoid main(void)\n{\nvec3 baseColor=texture2D(textureSampler,vUV).rgb;\nvec3 updatedColor=(kernelMatrix*vec4(baseColor,1.0)).rgb;\ngl_FragColor=vec4(updatedColor,1.0);\n}";St.a.ShadersStore.filterPixelShader=Ba;var Ua=function(e){function t(t,i,r,n,o,s,a){var c=e.call(this,t,"filter",["kernelMatrix"],null,r,n,o,s,a)||this;return c.kernelMatrix=i,c.onApply=function(e){e.setMatrix("kernelMatrix",c.kernelMatrix)},c}return l.d(t,e),t}(Mt),Va="uniform sampler2D textureSampler;\nuniform vec2 texelSize;\nvarying vec2 vUV;\nvarying vec2 sampleCoordS;\nvarying vec2 sampleCoordE;\nvarying vec2 sampleCoordN;\nvarying vec2 sampleCoordW;\nvarying vec2 sampleCoordNW;\nvarying vec2 sampleCoordSE;\nvarying vec2 sampleCoordNE;\nvarying vec2 sampleCoordSW;\nconst float fxaaQualitySubpix=1.0;\nconst float fxaaQualityEdgeThreshold=0.166;\nconst float fxaaQualityEdgeThresholdMin=0.0833;\nconst vec3 kLumaCoefficients=vec3(0.2126,0.7152,0.0722);\n#define FxaaLuma(rgba) dot(rgba.rgb,kLumaCoefficients)\nvoid main(){\nvec2 posM;\nposM.x=vUV.x;\nposM.y=vUV.y;\nvec4 rgbyM=texture2D(textureSampler,vUV,0.0);\nfloat lumaM=FxaaLuma(rgbyM);\nfloat lumaS=FxaaLuma(texture2D(textureSampler,sampleCoordS,0.0));\nfloat lumaE=FxaaLuma(texture2D(textureSampler,sampleCoordE,0.0));\nfloat lumaN=FxaaLuma(texture2D(textureSampler,sampleCoordN,0.0));\nfloat lumaW=FxaaLuma(texture2D(textureSampler,sampleCoordW,0.0));\nfloat maxSM=max(lumaS,lumaM);\nfloat minSM=min(lumaS,lumaM);\nfloat maxESM=max(lumaE,maxSM);\nfloat minESM=min(lumaE,minSM);\nfloat maxWN=max(lumaN,lumaW);\nfloat minWN=min(lumaN,lumaW);\nfloat rangeMax=max(maxWN,maxESM);\nfloat rangeMin=min(minWN,minESM);\nfloat rangeMaxScaled=rangeMax*fxaaQualityEdgeThreshold;\nfloat range=rangeMax-rangeMin;\nfloat rangeMaxClamped=max(fxaaQualityEdgeThresholdMin,rangeMaxScaled);\n#ifndef MALI\nif(range<rangeMaxClamped)\n{\ngl_FragColor=rgbyM;\nreturn;\n}\n#endif\nfloat lumaNW=FxaaLuma(texture2D(textureSampler,sampleCoordNW,0.0));\nfloat lumaSE=FxaaLuma(texture2D(textureSampler,sampleCoordSE,0.0));\nfloat lumaNE=FxaaLuma(texture2D(textureSampler,sampleCoordNE,0.0));\nfloat lumaSW=FxaaLuma(texture2D(textureSampler,sampleCoordSW,0.0));\nfloat lumaNS=lumaN+lumaS;\nfloat lumaWE=lumaW+lumaE;\nfloat subpixRcpRange=1.0/range;\nfloat subpixNSWE=lumaNS+lumaWE;\nfloat edgeHorz1=(-2.0*lumaM)+lumaNS;\nfloat edgeVert1=(-2.0*lumaM)+lumaWE;\nfloat lumaNESE=lumaNE+lumaSE;\nfloat lumaNWNE=lumaNW+lumaNE;\nfloat edgeHorz2=(-2.0*lumaE)+lumaNESE;\nfloat edgeVert2=(-2.0*lumaN)+lumaNWNE;\nfloat lumaNWSW=lumaNW+lumaSW;\nfloat lumaSWSE=lumaSW+lumaSE;\nfloat edgeHorz4=(abs(edgeHorz1)*2.0)+abs(edgeHorz2);\nfloat edgeVert4=(abs(edgeVert1)*2.0)+abs(edgeVert2);\nfloat edgeHorz3=(-2.0*lumaW)+lumaNWSW;\nfloat edgeVert3=(-2.0*lumaS)+lumaSWSE;\nfloat edgeHorz=abs(edgeHorz3)+edgeHorz4;\nfloat edgeVert=abs(edgeVert3)+edgeVert4;\nfloat subpixNWSWNESE=lumaNWSW+lumaNESE;\nfloat lengthSign=texelSize.x;\nbool horzSpan=edgeHorz>=edgeVert;\nfloat subpixA=subpixNSWE*2.0+subpixNWSWNESE;\nif (!horzSpan)\n{\nlumaN=lumaW;\n}\nif (!horzSpan)\n{\nlumaS=lumaE;\n}\nif (horzSpan)\n{\nlengthSign=texelSize.y;\n}\nfloat subpixB=(subpixA*(1.0/12.0))-lumaM;\nfloat gradientN=lumaN-lumaM;\nfloat gradientS=lumaS-lumaM;\nfloat lumaNN=lumaN+lumaM;\nfloat lumaSS=lumaS+lumaM;\nbool pairN=abs(gradientN)>=abs(gradientS);\nfloat gradient=max(abs(gradientN),abs(gradientS));\nif (pairN)\n{\nlengthSign=-lengthSign;\n}\nfloat subpixC=clamp(abs(subpixB)*subpixRcpRange,0.0,1.0);\nvec2 posB;\nposB.x=posM.x;\nposB.y=posM.y;\nvec2 offNP;\noffNP.x=(!horzSpan) ? 0.0 : texelSize.x;\noffNP.y=(horzSpan) ? 0.0 : texelSize.y;\nif (!horzSpan)\n{\nposB.x+=lengthSign*0.5;\n}\nif (horzSpan)\n{\nposB.y+=lengthSign*0.5;\n}\nvec2 posN;\nposN.x=posB.x-offNP.x*1.5;\nposN.y=posB.y-offNP.y*1.5;\nvec2 posP;\nposP.x=posB.x+offNP.x*1.5;\nposP.y=posB.y+offNP.y*1.5;\nfloat subpixD=((-2.0)*subpixC)+3.0;\nfloat lumaEndN=FxaaLuma(texture2D(textureSampler,posN,0.0));\nfloat subpixE=subpixC*subpixC;\nfloat lumaEndP=FxaaLuma(texture2D(textureSampler,posP,0.0));\nif (!pairN)\n{\nlumaNN=lumaSS;\n}\nfloat gradientScaled=gradient*1.0/4.0;\nfloat lumaMM=lumaM-lumaNN*0.5;\nfloat subpixF=subpixD*subpixE;\nbool lumaMLTZero=lumaMM<0.0;\nlumaEndN-=lumaNN*0.5;\nlumaEndP-=lumaNN*0.5;\nbool doneN=abs(lumaEndN)>=gradientScaled;\nbool doneP=abs(lumaEndP)>=gradientScaled;\nif (!doneN)\n{\nposN.x-=offNP.x*3.0;\n}\nif (!doneN)\n{\nposN.y-=offNP.y*3.0;\n}\nbool doneNP=(!doneN) || (!doneP);\nif (!doneP)\n{\nposP.x+=offNP.x*3.0;\n}\nif (!doneP)\n{\nposP.y+=offNP.y*3.0;\n}\nif (doneNP)\n{\nif (!doneN) lumaEndN=FxaaLuma(texture2D(textureSampler,posN.xy,0.0));\nif (!doneP) lumaEndP=FxaaLuma(texture2D(textureSampler,posP.xy,0.0));\nif (!doneN) lumaEndN=lumaEndN-lumaNN*0.5;\nif (!doneP) lumaEndP=lumaEndP-lumaNN*0.5;\ndoneN=abs(lumaEndN)>=gradientScaled;\ndoneP=abs(lumaEndP)>=gradientScaled;\nif (!doneN) posN.x-=offNP.x*12.0;\nif (!doneN) posN.y-=offNP.y*12.0;\ndoneNP=(!doneN) || (!doneP);\nif (!doneP) posP.x+=offNP.x*12.0;\nif (!doneP) posP.y+=offNP.y*12.0;\n}\nfloat dstN=posM.x-posN.x;\nfloat dstP=posP.x-posM.x;\nif (!horzSpan)\n{\ndstN=posM.y-posN.y;\n}\nif (!horzSpan)\n{\ndstP=posP.y-posM.y;\n}\nbool goodSpanN=(lumaEndN<0.0) != lumaMLTZero;\nfloat spanLength=(dstP+dstN);\nbool goodSpanP=(lumaEndP<0.0) != lumaMLTZero;\nfloat spanLengthRcp=1.0/spanLength;\nbool directionN=dstN<dstP;\nfloat dst=min(dstN,dstP);\nbool goodSpan=directionN ? goodSpanN : goodSpanP;\nfloat subpixG=subpixF*subpixF;\nfloat pixelOffset=(dst*(-spanLengthRcp))+0.5;\nfloat subpixH=subpixG*fxaaQualitySubpix;\nfloat pixelOffsetGood=goodSpan ? pixelOffset : 0.0;\nfloat pixelOffsetSubpix=max(pixelOffsetGood,subpixH);\nif (!horzSpan)\n{\nposM.x+=pixelOffsetSubpix*lengthSign;\n}\nif (horzSpan)\n{\nposM.y+=pixelOffsetSubpix*lengthSign;\n}\n#ifdef MALI\nif(range<rangeMaxClamped)\n{\ngl_FragColor=rgbyM;\n}\nelse\n{\ngl_FragColor=texture2D(textureSampler,posM,0.0);\n}\n#else\ngl_FragColor=texture2D(textureSampler,posM,0.0);\n#endif\n}";St.a.ShadersStore.fxaaPixelShader=Va;var Ga="\nattribute vec2 position;\nuniform vec2 texelSize;\n\nvarying vec2 vUV;\nvarying vec2 sampleCoordS;\nvarying vec2 sampleCoordE;\nvarying vec2 sampleCoordN;\nvarying vec2 sampleCoordW;\nvarying vec2 sampleCoordNW;\nvarying vec2 sampleCoordSE;\nvarying vec2 sampleCoordNE;\nvarying vec2 sampleCoordSW;\nconst vec2 madd=vec2(0.5,0.5);\nvoid main(void) {\nvUV=(position*madd+madd);\nsampleCoordS=vUV+vec2( 0.0,1.0)*texelSize;\nsampleCoordE=vUV+vec2( 1.0,0.0)*texelSize;\nsampleCoordN=vUV+vec2( 0.0,-1.0)*texelSize;\nsampleCoordW=vUV+vec2(-1.0,0.0)*texelSize;\nsampleCoordNW=vUV+vec2(-1.0,-1.0)*texelSize;\nsampleCoordSE=vUV+vec2( 1.0,1.0)*texelSize;\nsampleCoordNE=vUV+vec2( 1.0,-1.0)*texelSize;\nsampleCoordSW=vUV+vec2(-1.0,1.0)*texelSize;\ngl_Position=vec4(position,0.0,1.0);\n}";St.a.ShadersStore.fxaaVertexShader=Ga;var ka=function(e){function t(t,i,r,n,o,s,a){void 0===r&&(r=null),void 0===a&&(a=_.a.TEXTURETYPE_UNSIGNED_INT);var c=e.call(this,t,"fxaa",["texelSize"],null,i,r,n||Ve.a.BILINEAR_SAMPLINGMODE,o,s,null,a,"fxaa",void 0,!0)||this,l=c._getDefines();return c.updateEffect(l),c.onApplyObservable.add(function(e){var t=c.texelSize;e.setFloat2("texelSize",t.x,t.y)}),c}return l.d(t,e),t.prototype._getDefines=function(){var e=this.getEngine();if(!e)return null;var t=e.getGlInfo();return t&&t.renderer&&t.renderer.toLowerCase().indexOf("mali")>-1?"#define MALI 1\n":null},t}(Mt),za="#include<helperFunctions>\n\nuniform sampler2D textureSampler;\n\nuniform float intensity;\nuniform float animatedSeed;\n\nvarying vec2 vUV;\nvoid main(void)\n{\ngl_FragColor=texture2D(textureSampler,vUV);\nvec2 seed=vUV*(animatedSeed);\nfloat grain=dither(seed,intensity);\n\nfloat lum=getLuminance(gl_FragColor.rgb);\nfloat grainAmount=(cos(-PI+(lum*PI*2.))+1.)/2.;\ngl_FragColor.rgb+=grain*grainAmount;\ngl_FragColor.rgb=max(gl_FragColor.rgb,0.0);\n}";St.a.ShadersStore.grainPixelShader=za;var ja=function(e){function t(t,i,r,n,o,s,a,c){void 0===a&&(a=_.a.TEXTURETYPE_UNSIGNED_INT),void 0===c&&(c=!1);var l=e.call(this,t,"grain",["intensity","animatedSeed"],[],i,r,n,o,s,null,a,void 0,null,c)||this;return l.intensity=30,l.animated=!1,l.onApplyObservable.add(function(e){e.setFloat("intensity",l.intensity),e.setFloat("animatedSeed",l.animated?Math.random()+1:1)}),l}return l.d(t,e),t}(Mt),Wa="\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nconst vec3 RGBLuminanceCoefficients=vec3(0.2126,0.7152,0.0722);\nvoid main(void)\n{\nvec4 tex=texture2D(textureSampler,vUV);\nvec3 c=tex.rgb;\nfloat luma=dot(c.rgb,RGBLuminanceCoefficients);\n\n\ngl_FragColor=vec4(pow(c,vec3(25.0-luma*15.0)),tex.a);\n}";St.a.ShadersStore.highlightsPixelShader=Wa;var Ha=function(e){function t(t,i,r,n,o,s,a){return void 0===a&&(a=_.a.TEXTURETYPE_UNSIGNED_INT),e.call(this,t,"highlights",null,null,i,r,n,o,s,null,a)||this}return l.d(t,e),t}(Mt);St.a.IncludesShadersStore.mrtFragmentDeclaration="#if __VERSION__>=200\nlayout(location=0) out vec4 glFragData[{X}];\n#endif\n";var Xa="#extension GL_EXT_draw_buffers : require\nprecision highp float;\nprecision highp int;\nvarying vec3 vNormalV;\nvarying vec4 vViewPos;\n#ifdef POSITION\nvarying vec3 vPosition;\n#endif\n#ifdef VELOCITY\nvarying vec4 vCurrentPosition;\nvarying vec4 vPreviousPosition;\n#endif\n#ifdef ALPHATEST\nvarying vec2 vUV;\nuniform sampler2D diffuseSampler;\n#endif\n#include<mrtFragmentDeclaration>[RENDER_TARGET_COUNT]\nvoid main() {\n#ifdef ALPHATEST\nif (texture2D(diffuseSampler,vUV).a<0.4)\ndiscard;\n#endif\ngl_FragData[0]=vec4(vViewPos.z/vViewPos.w,0.0,0.0,1.0);\n\ngl_FragData[1]=vec4(normalize(vNormalV),1.0);\n\n#ifdef POSITION\ngl_FragData[POSITION_INDEX]=vec4(vPosition,1.0);\n#endif\n#ifdef VELOCITY\nvec2 a=(vCurrentPosition.xy/vCurrentPosition.w)*0.5+0.5;\nvec2 b=(vPreviousPosition.xy/vPreviousPosition.w)*0.5+0.5;\nvec2 velocity=(a-b)*0.5+0.5;\nvelocity*=0.5+0.5;\nvelocity=vec2(pow(velocity.x,3.0),pow(velocity.y,3.0));\ngl_FragData[VELOCITY_INDEX]=vec4(velocity,0.0,1.0);\n#endif\n}";St.a.ShadersStore.geometryPixelShader=Xa;var Ya="precision highp float;\nprecision highp int;\n#include<bonesDeclaration>\n#include<instancesDeclaration>\nattribute vec3 position;\nattribute vec3 normal;\n#if defined(ALPHATEST) || defined(NEED_UV)\nvarying vec2 vUV;\nuniform mat4 diffuseMatrix;\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#endif\n\nuniform mat4 viewProjection;\nuniform mat4 view;\nvarying vec3 vNormalV;\nvarying vec4 vViewPos;\n#ifdef POSITION\nvarying vec3 vPosition;\n#endif\n#ifdef VELOCITY\nuniform mat4 previousWorldViewProjection;\nvarying vec4 vCurrentPosition;\nvarying vec4 vPreviousPosition;\n#endif\nvoid main(void)\n{\n#include<instancesVertex>\n#include<bonesVertex>\nvec4 pos=vec4(finalWorld*vec4(position,1.0));\nvNormalV=normalize(vec3((view*finalWorld)*vec4(normal,0.0)));\nvViewPos=view*pos;\n#ifdef POSITION\nvPosition=pos.xyz/pos.w;\n#endif\n#ifdef VELOCITY\nvCurrentPosition=viewProjection*finalWorld*vec4(position,1.0);\nvPreviousPosition=previousWorldViewProjection*vec4(position,1.0);\n#endif\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\n#if defined(ALPHATEST) || defined(BASIC_RENDER)\n#ifdef UV1\nvUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n#endif\n#ifdef UV2\nvUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n}";St.a.ShadersStore.geometryVertexShader=Ya;var Ka=function(){function e(t,i){void 0===i&&(i=1),this._previousTransformationMatrices={},this._enablePosition=!1,this._enableVelocity=!1,this._positionIndex=-1,this._velocityIndex=-1,this._scene=t,this._ratio=i,e._SceneComponentInitialization(this._scene),this._createRenderTargets()}return Object.defineProperty(e.prototype,"renderList",{set:function(e){this._multiRenderTarget.renderList=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isSupported",{get:function(){return this._multiRenderTarget.isSupported},enumerable:!0,configurable:!0}),e.prototype.getTextureIndex=function(t){switch(t){case e.POSITION_TEXTURE_TYPE:return this._positionIndex;case e.VELOCITY_TEXTURE_TYPE:return this._velocityIndex;default:return-1}},Object.defineProperty(e.prototype,"enablePosition",{get:function(){return this._enablePosition},set:function(e){this._enablePosition=e,this.dispose(),this._createRenderTargets()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"enableVelocity",{get:function(){return this._enableVelocity},set:function(e){this._enableVelocity=e,this.dispose(),this._createRenderTargets()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"scene",{get:function(){return this._scene},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"ratio",{get:function(){return this._ratio},enumerable:!0,configurable:!0}),e.prototype.isReady=function(e,t){var i=e.getMaterial();if(i&&i.disableDepthWrite)return!1;var r=[],n=[gi.b.PositionKind,gi.b.NormalKind],o=e.getMesh();i&&i.needAlphaTesting()&&(r.push("#define ALPHATEST"),o.isVerticesDataPresent(gi.b.UVKind)&&(n.push(gi.b.UVKind),r.push("#define UV1")),o.isVerticesDataPresent(gi.b.UV2Kind)&&(n.push(gi.b.UV2Kind),r.push("#define UV2"))),this._enablePosition&&(r.push("#define POSITION"),r.push("#define POSITION_INDEX "+this._positionIndex)),this._enableVelocity&&(r.push("#define VELOCITY"),r.push("#define VELOCITY_INDEX "+this._velocityIndex)),o.useBones&&o.computeBonesUsingShaders?(n.push(gi.b.MatricesIndicesKind),n.push(gi.b.MatricesWeightsKind),o.numBoneInfluencers>4&&(n.push(gi.b.MatricesIndicesExtraKind),n.push(gi.b.MatricesWeightsExtraKind)),r.push("#define NUM_BONE_INFLUENCERS "+o.numBoneInfluencers),r.push("#define BonesPerMesh "+(o.skeleton?o.skeleton.bones.length+1:0))):r.push("#define NUM_BONE_INFLUENCERS 0"),t&&(r.push("#define INSTANCES"),n.push("world0"),n.push("world1"),n.push("world2"),n.push("world3")),r.push("#define RENDER_TARGET_COUNT "+this._multiRenderTarget.textures.length);var s=r.join("\n");return this._cachedDefines!==s&&(this._cachedDefines=s,this._effect=this._scene.getEngine().createEffect("geometry",n,["world","mBones","viewProjection","diffuseMatrix","view","previousWorldViewProjection"],["diffuseSampler"],s,void 0,void 0,void 0,{buffersCount:this._enablePosition?3:2})),this._effect.isReady()},e.prototype.getGBuffer=function(){return this._multiRenderTarget},Object.defineProperty(e.prototype,"samples",{get:function(){return this._multiRenderTarget.samples},set:function(e){this._multiRenderTarget.samples=e},enumerable:!0,configurable:!0}),e.prototype.dispose=function(){this.getGBuffer().dispose()},e.prototype._createRenderTargets=function(){var e=this,t=this._scene.getEngine(),i=2;if(this._enablePosition&&(this._positionIndex=i,i++),this._enableVelocity&&(this._velocityIndex=i,i++),this._multiRenderTarget=new Vo("gBuffer",{width:t.getRenderWidth()*this._ratio,height:t.getRenderHeight()*this._ratio},i,this._scene,{generateMipMaps:!1,generateDepthTexture:!0,defaultType:_.a.TEXTURETYPE_FLOAT}),this.isSupported){this._multiRenderTarget.wrapU=Ve.a.CLAMP_ADDRESSMODE,this._multiRenderTarget.wrapV=Ve.a.CLAMP_ADDRESSMODE,this._multiRenderTarget.refreshRate=1,this._multiRenderTarget.renderParticles=!1,this._multiRenderTarget.renderList=null,this._multiRenderTarget.onClearObservable.add(function(e){e.clear(new o.f(0,0,0,1),!0,!0,!0)});var r=function(t){var i=t.getRenderingMesh(),r=e._scene,n=r.getEngine(),s=t.getMaterial();if(s){e._previousTransformationMatrices[i.uniqueId]||(e._previousTransformationMatrices[i.uniqueId]=o.j.Identity()),n.setState(s.backFaceCulling,0,!1,r.useRightHandedSystem);var a=i._getInstancesRenderList(t._id);if(!a.mustReturn){var c=n.getCaps().instancedArrays&&null!==a.visibleInstances[t._id];if(e.isReady(t,c)){if(n.enableEffect(e._effect),i._bind(t,e._effect,yn.a.TriangleFillMode),e._effect.setMatrix("viewProjection",r.getTransformMatrix()),e._effect.setMatrix("view",r.getViewMatrix()),s&&s.needAlphaTesting()){var l=s.getAlphaTestTexture();l&&(e._effect.setTexture("diffuseSampler",l),e._effect.setMatrix("diffuseMatrix",l.getTextureMatrix()))}i.useBones&&i.computeBonesUsingShaders&&i.skeleton&&e._effect.setMatrices("mBones",i.skeleton.getTransformMatrices(i)),e._effect.setMatrix("previousWorldViewProjection",e._previousTransformationMatrices[i.uniqueId]),i._processRendering(t,e._effect,yn.a.TriangleFillMode,a,c,function(t,i){return e._effect.setMatrix("world",i)})}e._previousTransformationMatrices[i.uniqueId]=i.getWorldMatrix().multiply(e._scene.getTransformMatrix())}}};this._multiRenderTarget.customRenderFunction=function(e,i,n,o){var s;if(o.length){for(t.setColorWrite(!1),s=0;s<o.length;s++)r(o.data[s]);t.setColorWrite(!0)}for(s=0;s<e.length;s++)r(e.data[s]);for(s=0;s<i.length;s++)r(i.data[s])}}},e.POSITION_TEXTURE_TYPE=1,e.VELOCITY_TEXTURE_TYPE=2,e._SceneComponentInitialization=function(e){throw"Import GeometryBufferRendererSceneComponent before creating GeometryBufferRenderer."},e}(),Qa="\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform sampler2D velocitySampler;\nuniform float motionStrength;\nuniform float motionScale;\nuniform vec2 screenSize;\nvoid main(void)\n{\n#ifdef GEOMETRY_SUPPORTED\nvec2 texelSize=1.0/screenSize;\nvec2 velocityColor=texture2D(velocitySampler,vUV).rg;\nvec2 velocity=vec2(pow(velocityColor.r,1.0/3.0),pow(velocityColor.g,1.0/3.0))*2.0-1.0;\nvelocity*=motionScale*motionStrength;\nfloat speed=length(velocity/texelSize);\nint samplesCount=int(clamp(speed,1.0,SAMPLES));\nvelocity=normalize(velocity)*texelSize;\nfloat hlim=float(-samplesCount)*0.5+0.5;\nvec4 result=texture2D(textureSampler,vUV);\nfor (int i=1; i<int(SAMPLES); ++i)\n{\nif (i>=samplesCount)\nbreak;\nvec2 offset=vUV+velocity*(hlim+float(i));\nresult+=texture2D(textureSampler,offset);\n}\ngl_FragColor=result/float(samplesCount);\n#else\ngl_FragColor=texture2D(textureSampler,vUV);\n#endif\n}\n";St.a.ShadersStore.motionBlurPixelShader=Qa;var qa=function(e){function t(t,i,r,n,s,a,c,l,u){void 0===l&&(l=_.a.TEXTURETYPE_UNSIGNED_INT),void 0===u&&(u=!1);var h=e.call(this,t,"motionBlur",["motionStrength","motionScale","screenSize"],["velocitySampler"],r,n,s,a,c,"#define GEOMETRY_SUPPORTED\n#define SAMPLES 64.0",l,void 0,null,u)||this;return h.motionStrength=1,h._motionBlurSamples=32,h._geometryBufferRenderer=i.enableGeometryBufferRenderer(),h._geometryBufferRenderer?(h._geometryBufferRenderer.enableVelocity=!0,h.onApply=function(e){if(e.setVector2("screenSize",new o.w(h.width,h.height)),e.setFloat("motionScale",i.getAnimationRatio()),e.setFloat("motionStrength",h.motionStrength),h._geometryBufferRenderer){var t=h._geometryBufferRenderer.getTextureIndex(Ka.VELOCITY_TEXTURE_TYPE);e.setTexture("velocitySampler",h._geometryBufferRenderer.getGBuffer().textures[t])}}):(p.a.Warn("Multiple Render Target support needed to compute object based motion blur"),h.updateEffect()),h}return l.d(t,e),Object.defineProperty(t.prototype,"motionBlurSamples",{get:function(){return this._motionBlurSamples},set:function(e){this._motionBlurSamples=e,this._geometryBufferRenderer&&this.updateEffect("#define GEOMETRY_SUPPORTED\n#define SAMPLES "+e.toFixed(1))},enumerable:!0,configurable:!0}),t.prototype.dispose=function(t){this._geometryBufferRenderer&&(this._geometryBufferRenderer._previousTransformationMatrices={}),e.prototype.dispose.call(this,t)},t}(Mt),Za="\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform sampler2D refractionSampler;\n\nuniform vec3 baseColor;\nuniform float depth;\nuniform float colorLevel;\nvoid main() {\nfloat ref=1.0-texture2D(refractionSampler,vUV).r;\nvec2 uv=vUV-vec2(0.5);\nvec2 offset=uv*depth*ref;\nvec3 sourceColor=texture2D(textureSampler,vUV-offset).rgb;\ngl_FragColor=vec4(sourceColor+sourceColor*ref*colorLevel,1.0);\n}";St.a.ShadersStore.refractionPixelShader=Za;var Ja=function(e){function t(t,i,r,n,o,s,a,c,l,u){var h=e.call(this,t,"refraction",["baseColor","depth","colorLevel"],["refractionSampler"],s,a,c,l,u)||this;return h.color=r,h.depth=n,h.colorLevel=o,h._ownRefractionTexture=!0,h.onActivateObservable.add(function(e){h._refTexture=h._refTexture||new Ve.a(i,e.getScene())}),h.onApplyObservable.add(function(e){e.setColor3("baseColor",h.color),e.setFloat("depth",h.depth),e.setFloat("colorLevel",h.colorLevel),e.setTexture("refractionSampler",h._refTexture)}),h}return l.d(t,e),Object.defineProperty(t.prototype,"refractionTexture",{get:function(){return this._refTexture},set:function(e){this._refTexture&&this._ownRefractionTexture&&this._refTexture.dispose(),this._refTexture=e,this._ownRefractionTexture=!1},enumerable:!0,configurable:!0}),t.prototype.dispose=function(t){this._refTexture&&this._ownRefractionTexture&&(this._refTexture.dispose(),this._refTexture=null),e.prototype.dispose.call(this,t)},t}(Mt),$a="\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform vec2 screenSize;\nuniform vec2 sharpnessAmounts;\nvoid main(void)\n{\nvec2 onePixel=vec2(1.0,1.0)/screenSize;\nvec4 color=texture2D(textureSampler,vUV);\nvec4 edgeDetection=texture2D(textureSampler,vUV+onePixel*vec2(0,-1)) +\ntexture2D(textureSampler,vUV+onePixel*vec2(-1,0)) +\ntexture2D(textureSampler,vUV+onePixel*vec2(1,0)) +\ntexture2D(textureSampler,vUV+onePixel*vec2(0,1)) -\ncolor*4.0;\ngl_FragColor=max(vec4(color.rgb*sharpnessAmounts.y,color.a)-(sharpnessAmounts.x*vec4(edgeDetection.rgb,0)),0.);\n}";St.a.ShadersStore.sharpenPixelShader=$a;var ec=function(e){function t(t,i,r,n,o,s,a,c){void 0===a&&(a=_.a.TEXTURETYPE_UNSIGNED_INT),void 0===c&&(c=!1);var l=e.call(this,t,"sharpen",["sharpnessAmounts","screenSize"],null,i,r,n,o,s,null,a,void 0,null,c)||this;return l.colorAmount=1,l.edgeAmount=.3,l.onApply=function(e){e.setFloat2("screenSize",l.width,l.height),e.setFloat2("sharpnessAmounts",l.edgeAmount,l.colorAmount)},l}return l.d(t,e),t}(Mt),tc=function(){function e(e,t){this.engine=e,this._name=t,this._renderEffects={},this._renderEffectsForIsolatedPass=new Array,this._cameras=[]}return e.prototype.getClassName=function(){return"PostProcessRenderPipeline"},Object.defineProperty(e.prototype,"isSupported",{get:function(){for(var e in this._renderEffects)if(this._renderEffects.hasOwnProperty(e)&&!this._renderEffects[e].isSupported)return!1;return!0},enumerable:!0,configurable:!0}),e.prototype.addEffect=function(e){this._renderEffects[e._name]=e},e.prototype._rebuild=function(){},e.prototype._enableEffect=function(e,t){var i=this._renderEffects[e];i&&i._enable(ve.h.MakeArray(t||this._cameras))},e.prototype._disableEffect=function(e,t){var i=this._renderEffects[e];i&&i._disable(ve.h.MakeArray(t||this._cameras))},e.prototype._attachCameras=function(e,t){var i=ve.h.MakeArray(e||this._cameras);if(i){var r,n=[];for(r=0;r<i.length;r++){var o=i[r],s=o.name;-1===this._cameras.indexOf(o)?this._cameras[s]=o:t&&n.push(r)}for(r=0;r<n.length;r++)e.splice(n[r],1);for(var a in this._renderEffects)this._renderEffects.hasOwnProperty(a)&&this._renderEffects[a]._attachCameras(i)}},e.prototype._detachCameras=function(e){var t=ve.h.MakeArray(e||this._cameras);if(t){for(var i in this._renderEffects)this._renderEffects.hasOwnProperty(i)&&this._renderEffects[i]._detachCameras(t);for(var r=0;r<t.length;r++)this._cameras.splice(this._cameras.indexOf(t[r]),1)}},e.prototype._update=function(){for(var e in this._renderEffects)this._renderEffects.hasOwnProperty(e)&&this._renderEffects[e]._update();for(var t=0;t<this._cameras.length;t++){var i=this._cameras[t].name;this._renderEffectsForIsolatedPass[i]&&this._renderEffectsForIsolatedPass[i]._update()}},e.prototype._reset=function(){this._renderEffects={},this._renderEffectsForIsolatedPass=new Array},e.prototype._enableMSAAOnFirstPostProcess=function(e){var t=Object.keys(this._renderEffects);if(this.engine.webGLVersion>=2&&t.length>0){var i=this._renderEffects[t[0]].getPostProcesses();if(i)return i[0].samples=e,!0}return!1},e.prototype.dispose=function(){},l.c([Object(w.c)()],e.prototype,"_name",void 0),e}(),ic=function(e){function t(t,i,r,n,o){void 0===t&&(t=""),void 0===i&&(i=!0),void 0===r&&(r=R.a.LastCreatedScene),void 0===o&&(o=!0);var s=e.call(this,r.getEngine(),t)||this;s._camerasToBeAttached=[],s.SharpenPostProcessId="SharpenPostProcessEffect",s.ImageProcessingPostProcessId="ImageProcessingPostProcessEffect",s.FxaaPostProcessId="FxaaPostProcessEffect",s.ChromaticAberrationPostProcessId="ChromaticAberrationPostProcessEffect",s.GrainPostProcessId="GrainPostProcessEffect",s._glowLayer=null,s.animations=[],s._imageProcessingConfigurationObserver=null,s._sharpenEnabled=!1,s._bloomEnabled=!1,s._depthOfFieldEnabled=!1,s._depthOfFieldBlurLevel=Ia.Low,s._fxaaEnabled=!1,s._imageProcessingEnabled=!0,s._bloomScale=.5,s._chromaticAberrationEnabled=!1,s._grainEnabled=!1,s._buildAllowed=!0,s._resizeObserver=null,s._hardwareScaleLevel=1,s._bloomKernel=64,s._bloomWeight=.15,s._bloomThreshold=.9,s._samples=1,s._hasCleared=!1,s._prevPostProcess=null,s._prevPrevPostProcess=null,s._depthOfFieldSceneObserver=null,s._cameras=n||r.cameras,s._cameras=s._cameras.slice(),s._camerasToBeAttached=s._cameras.slice(),s._buildAllowed=o,s._scene=r;var a=s._scene.getEngine().getCaps();s._hdr=i&&(a.textureHalfFloatRender||a.textureFloatRender),s._hdr?a.textureHalfFloatRender?s._defaultPipelineTextureType=_.a.TEXTURETYPE_HALF_FLOAT:a.textureFloatRender&&(s._defaultPipelineTextureType=_.a.TEXTURETYPE_FLOAT):s._defaultPipelineTextureType=_.a.TEXTURETYPE_UNSIGNED_INT,r.postProcessRenderPipelineManager.addPipeline(s);var c=s._scene.getEngine();return s.sharpen=new ec("sharpen",1,null,Ve.a.BILINEAR_SAMPLINGMODE,c,!1,s._defaultPipelineTextureType,!0),s._sharpenEffect=new _a(c,s.SharpenPostProcessId,function(){return s.sharpen},!0),s.depthOfField=new La(s._scene,null,s._depthOfFieldBlurLevel,s._defaultPipelineTextureType,!0),s.bloom=new ba(s._scene,s._bloomScale,s._bloomWeight,s.bloomKernel,s._defaultPipelineTextureType,!0),s.chromaticAberration=new Ea("ChromaticAberration",c.getRenderWidth(),c.getRenderHeight(),1,null,Ve.a.BILINEAR_SAMPLINGMODE,c,!1,s._defaultPipelineTextureType,!0),s._chromaticAberrationEffect=new _a(c,s.ChromaticAberrationPostProcessId,function(){return s.chromaticAberration},!0),s.grain=new ja("Grain",1,null,Ve.a.BILINEAR_SAMPLINGMODE,c,!1,s._defaultPipelineTextureType,!0),s._grainEffect=new _a(c,s.GrainPostProcessId,function(){return s.grain},!0),s._resizeObserver=c.onResizeObservable.add(function(){s._hardwareScaleLevel=c.getHardwareScalingLevel(),s.bloomKernel=s.bloomKernel}),s._imageProcessingConfigurationObserver=s._scene.imageProcessingConfiguration.onUpdateParameters.add(function(){s.bloom._downscale._exposure=s._scene.imageProcessingConfiguration.exposure}),s._buildPipeline(),s}return l.d(t,e),Object.defineProperty(t.prototype,"sharpenEnabled",{get:function(){return this._sharpenEnabled},set:function(e){this._sharpenEnabled!==e&&(this._sharpenEnabled=e,this._buildPipeline())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"bloomKernel",{get:function(){return this._bloomKernel},set:function(e){this._bloomKernel=e,this.bloom.kernel=e/this._hardwareScaleLevel},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"bloomWeight",{get:function(){return this._bloomWeight},set:function(e){this._bloomWeight!==e&&(this.bloom.weight=e,this._bloomWeight=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"bloomThreshold",{get:function(){return this._bloomThreshold},set:function(e){this._bloomThreshold!==e&&(this.bloom.threshold=e,this._bloomThreshold=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"bloomScale",{get:function(){return this._bloomScale},set:function(e){this._bloomScale!==e&&(this._bloomScale=e,this._rebuildBloom(),this._buildPipeline())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"bloomEnabled",{get:function(){return this._bloomEnabled},set:function(e){this._bloomEnabled!==e&&(this._bloomEnabled=e,this._buildPipeline())},enumerable:!0,configurable:!0}),t.prototype._rebuildBloom=function(){var e=this.bloom;this.bloom=new ba(this._scene,this.bloomScale,this._bloomWeight,this.bloomKernel,this._defaultPipelineTextureType,!1),this.bloom.threshold=e.threshold;for(var t=0;t<this._cameras.length;t++)e.disposeEffects(this._cameras[t])},Object.defineProperty(t.prototype,"depthOfFieldEnabled",{get:function(){return this._depthOfFieldEnabled},set:function(e){this._depthOfFieldEnabled!==e&&(this._depthOfFieldEnabled=e,this._buildPipeline())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"depthOfFieldBlurLevel",{get:function(){return this._depthOfFieldBlurLevel},set:function(e){if(this._depthOfFieldBlurLevel!==e){this._depthOfFieldBlurLevel=e;var t=this.depthOfField;this.depthOfField=new La(this._scene,null,this._depthOfFieldBlurLevel,this._defaultPipelineTextureType,!1),this.depthOfField.focalLength=t.focalLength,this.depthOfField.focusDistance=t.focusDistance,this.depthOfField.fStop=t.fStop,this.depthOfField.lensSize=t.lensSize;for(var i=0;i<this._cameras.length;i++)t.disposeEffects(this._cameras[i]);this._buildPipeline()}},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"fxaaEnabled",{get:function(){return this._fxaaEnabled},set:function(e){this._fxaaEnabled!==e&&(this._fxaaEnabled=e,this._buildPipeline())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"samples",{get:function(){return this._samples},set:function(e){this._samples!==e&&(this._samples=e,this._buildPipeline())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"imageProcessingEnabled",{get:function(){return this._imageProcessingEnabled},set:function(e){this._imageProcessingEnabled!==e&&(this._imageProcessingEnabled=e,this._buildPipeline())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"glowLayerEnabled",{get:function(){return null==this._glowLayer},set:function(e){e&&!this._glowLayer?this._glowLayer=new Rn("",this._scene):!e&&this._glowLayer&&(this._glowLayer.dispose(),this._glowLayer=null)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"chromaticAberrationEnabled",{get:function(){return this._chromaticAberrationEnabled},set:function(e){this._chromaticAberrationEnabled!==e&&(this._chromaticAberrationEnabled=e,this._buildPipeline())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"grainEnabled",{get:function(){return this._grainEnabled},set:function(e){this._grainEnabled!==e&&(this._grainEnabled=e,this._buildPipeline())},enumerable:!0,configurable:!0}),t.prototype.prepare=function(){var e=this._buildAllowed;this._buildAllowed=!0,this._buildPipeline(),this._buildAllowed=e},t.prototype._setAutoClearAndTextureSharing=function(e,t){void 0===t&&(t=!1),this._hasCleared?e.autoClear=!1:(e.autoClear=!0,this._scene.autoClear=!1,this._hasCleared=!0),t||(this._prevPrevPostProcess?e.shareOutputWith(this._prevPrevPostProcess):e.useOwnOutput(),this._prevPostProcess&&(this._prevPrevPostProcess=this._prevPostProcess),this._prevPostProcess=e)},t.prototype._buildPipeline=function(){var e=this;if(this._buildAllowed){this._scene.autoClear=!0;var t=this._scene.getEngine();if(this._disposePostProcesses(),null!==this._cameras&&(this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name,this._cameras),this._cameras=this._camerasToBeAttached.slice()),this._reset(),this._prevPostProcess=null,this._prevPrevPostProcess=null,this._hasCleared=!1,this.depthOfFieldEnabled){if(this._cameras.length>1){for(var i=0,r=this._cameras;i<r.length;i++){var n=r[i];(o=this._scene.enableDepthRenderer(n)).useOnlyInActiveCamera=!0}this._depthOfFieldSceneObserver=this._scene.onAfterRenderTargetsRenderObservable.add(function(t){e._cameras.indexOf(t.activeCamera)>-1&&(e.depthOfField.depthTexture=t.enableDepthRenderer(t.activeCamera).getDepthMap())})}else{this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);var o=this._scene.enableDepthRenderer(this._cameras[0]);this.depthOfField.depthTexture=o.getDepthMap()}this.depthOfField._isReady()||this.depthOfField._updateEffects(),this.addEffect(this.depthOfField),this._setAutoClearAndTextureSharing(this.depthOfField._effects[0],!0)}else this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);this.bloomEnabled&&(this.bloom._isReady()||this.bloom._updateEffects(),this.addEffect(this.bloom),this._setAutoClearAndTextureSharing(this.bloom._effects[0],!0)),this._imageProcessingEnabled&&(this.imageProcessing=new pi("imageProcessing",1,null,Ve.a.BILINEAR_SAMPLINGMODE,t,!1,this._defaultPipelineTextureType),this._hdr?(this.addEffect(new _a(t,this.ImageProcessingPostProcessId,function(){return e.imageProcessing},!0)),this._setAutoClearAndTextureSharing(this.imageProcessing)):this._scene.imageProcessingConfiguration.applyByPostProcess=!1),this.sharpenEnabled&&(this.sharpen.isReady()||this.sharpen.updateEffect(),this.addEffect(this._sharpenEffect),this._setAutoClearAndTextureSharing(this.sharpen)),this.grainEnabled&&(this.grain.isReady()||this.grain.updateEffect(),this.addEffect(this._grainEffect),this._setAutoClearAndTextureSharing(this.grain)),this.chromaticAberrationEnabled&&(this.chromaticAberration.isReady()||this.chromaticAberration.updateEffect(),this.addEffect(this._chromaticAberrationEffect),this._setAutoClearAndTextureSharing(this.chromaticAberration)),this.fxaaEnabled&&(this.fxaa=new ka("fxaa",1,null,Ve.a.BILINEAR_SAMPLINGMODE,t,!1,this._defaultPipelineTextureType),this.addEffect(new _a(t,this.FxaaPostProcessId,function(){return e.fxaa},!0)),this._setAutoClearAndTextureSharing(this.fxaa,!0)),null!==this._cameras&&this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name,this._cameras),!this._enableMSAAOnFirstPostProcess(this.samples)&&this.samples>1&&p.a.Warn("MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0")}},t.prototype._disposePostProcesses=function(e){void 0===e&&(e=!1);for(var t=0;t<this._cameras.length;t++){var i=this._cameras[t];this.imageProcessing&&this.imageProcessing.dispose(i),this.fxaa&&this.fxaa.dispose(i),e&&(this.sharpen&&this.sharpen.dispose(i),this.depthOfField&&(this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver),this.depthOfField.disposeEffects(i)),this.bloom&&this.bloom.disposeEffects(i),this.chromaticAberration&&this.chromaticAberration.dispose(i),this.grain&&this.grain.dispose(i),this._glowLayer&&this._glowLayer.dispose())}this.imageProcessing=null,this.fxaa=null,e&&(this.sharpen=null,this._sharpenEffect=null,this.depthOfField=null,this.bloom=null,this.chromaticAberration=null,this._chromaticAberrationEffect=null,this.grain=null,this._grainEffect=null,this._glowLayer=null)},t.prototype.addCamera=function(e){this._camerasToBeAttached.push(e),this._buildPipeline()},t.prototype.removeCamera=function(e){var t=this._camerasToBeAttached.indexOf(e);this._camerasToBeAttached.splice(t,1),this._buildPipeline()},t.prototype.dispose=function(){this._disposePostProcesses(!0),this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name,this._cameras),this._scene.autoClear=!0,this._resizeObserver&&(this._scene.getEngine().onResizeObservable.remove(this._resizeObserver),this._resizeObserver=null),this._scene.imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingConfigurationObserver),e.prototype.dispose.call(this)},t.prototype.serialize=function(){var e=w.a.Serialize(this);return e.customType="DefaultRenderingPipeline",e},t.Parse=function(e,i,r){return w.a.Parse(function(){return new t(e._name,e._name._hdr,i)},e,i,r)},l.c([Object(w.c)()],t.prototype,"sharpenEnabled",null),l.c([Object(w.c)()],t.prototype,"bloomKernel",null),l.c([Object(w.c)()],t.prototype,"_bloomWeight",void 0),l.c([Object(w.c)()],t.prototype,"_bloomThreshold",void 0),l.c([Object(w.c)()],t.prototype,"_hdr",void 0),l.c([Object(w.c)()],t.prototype,"bloomWeight",null),l.c([Object(w.c)()],t.prototype,"bloomThreshold",null),l.c([Object(w.c)()],t.prototype,"bloomScale",null),l.c([Object(w.c)()],t.prototype,"bloomEnabled",null),l.c([Object(w.c)()],t.prototype,"depthOfFieldEnabled",null),l.c([Object(w.c)()],t.prototype,"depthOfFieldBlurLevel",null),l.c([Object(w.c)()],t.prototype,"fxaaEnabled",null),l.c([Object(w.c)()],t.prototype,"samples",null),l.c([Object(w.c)()],t.prototype,"imageProcessingEnabled",null),l.c([Object(w.c)()],t.prototype,"glowLayerEnabled",null),l.c([Object(w.c)()],t.prototype,"chromaticAberrationEnabled",null),l.c([Object(w.c)()],t.prototype,"grainEnabled",null),t}(tc);s.a.RegisteredTypes["BABYLON.DefaultRenderingPipeline"]=ic;var rc="\nuniform sampler2D textureSampler;\n\nuniform float gain;\nuniform float threshold;\nuniform float screen_width;\nuniform float screen_height;\n\nvarying vec2 vUV;\n\nvec4 highlightColor(vec4 color) {\nvec4 highlight=color;\nfloat luminance=dot(highlight.rgb,vec3(0.2125,0.7154,0.0721));\nfloat lum_threshold;\nif (threshold>1.0) { lum_threshold=0.94+0.01*threshold; }\nelse { lum_threshold=0.5+0.44*threshold; }\nluminance=clamp((luminance-lum_threshold)*(1.0/(1.0-lum_threshold)),0.0,1.0);\nhighlight*=luminance*gain;\nhighlight.a=1.0;\nreturn highlight;\n}\nvoid main(void)\n{\nvec4 original=texture2D(textureSampler,vUV);\n\nif (gain == -1.0) {\ngl_FragColor=vec4(0.0,0.0,0.0,1.0);\nreturn;\n}\nfloat w=2.0/screen_width;\nfloat h=2.0/screen_height;\nfloat weight=1.0;\n\nvec4 blurred=vec4(0.0,0.0,0.0,0.0);\n#ifdef PENTAGON\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.84*w,0.43*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.48*w,-1.29*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.61*w,1.51*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.55*w,-0.74*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.71*w,-0.52*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.94*w,1.59*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.40*w,-1.87*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.62*w,1.16*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.09*w,0.25*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.46*w,-1.71*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.08*w,2.42*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.85*w,-1.89*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.89*w,0.16*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.29*w,1.88*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.40*w,-2.81*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.54*w,2.26*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.60*w,-0.61*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.31*w,-1.30*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.83*w,2.53*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.12*w,-2.48*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.60*w,1.11*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.82*w,0.99*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.50*w,-2.81*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.85*w,3.33*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.94*w,-1.92*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.27*w,-0.53*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.95*w,2.48*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.23*w,-3.04*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.17*w,2.05*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.97*w,-0.04*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.25*w,-2.00*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.31*w,3.08*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.94*w,-2.59*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.37*w,0.64*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-3.13*w,1.93*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.03*w,-3.65*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.60*w,3.17*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-3.14*w,-1.19*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.00*w,-1.19*h)));\n#else\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.85*w,0.36*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.52*w,-1.14*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.46*w,1.42*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.46*w,-0.83*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.79*w,-0.42*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.11*w,1.62*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.29*w,-2.07*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.69*w,1.39*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.28*w,0.12*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.65*w,-1.69*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.08*w,2.44*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.63*w,-1.90*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.55*w,0.31*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.13*w,1.52*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.56*w,-2.61*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.38*w,2.34*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.64*w,-0.81*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.53*w,-1.21*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.06*w,2.63*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.00*w,-2.69*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.59*w,1.32*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.82*w,0.78*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.57*w,-2.50*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.54*w,2.93*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.39*w,-1.81*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.01*w,-0.28*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.04*w,2.25*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.02*w,-3.05*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.09*w,2.25*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-3.07*w,-0.25*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.44*w,-1.90*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.52*w,3.05*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.68*w,-2.61*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.01*w,0.79*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.76*w,1.46*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.05*w,-2.94*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.21*w,2.88*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.84*w,-1.30*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.98*w,-0.96*h)));\n#endif\nblurred/=39.0;\ngl_FragColor=blurred;\n\n}";St.a.ShadersStore.lensHighlightsPixelShader=rc;var nc="\n\n\n\n\nuniform sampler2D textureSampler;\nuniform sampler2D highlightsSampler;\nuniform sampler2D depthSampler;\nuniform sampler2D grainSampler;\n\nuniform float grain_amount;\nuniform bool blur_noise;\nuniform float screen_width;\nuniform float screen_height;\nuniform float distortion;\nuniform bool dof_enabled;\n\nuniform float screen_distance;\nuniform float aperture;\nuniform float darken;\nuniform float edge_blur;\nuniform bool highlights;\n\nuniform float near;\nuniform float far;\n\nvarying vec2 vUV;\n\n#define PI 3.14159265\n#define TWOPI 6.28318530\n#define inverse_focal_length 0.1\n\nvec2 centered_screen_pos;\nvec2 distorted_coords;\nfloat radius2;\nfloat radius;\n\nvec2 rand(vec2 co)\n{\nfloat noise1=(fract(sin(dot(co,vec2(12.9898,78.233)))*43758.5453));\nfloat noise2=(fract(sin(dot(co,vec2(12.9898,78.233)*2.0))*43758.5453));\nreturn clamp(vec2(noise1,noise2),0.0,1.0);\n}\n\nvec2 getDistortedCoords(vec2 coords) {\nif (distortion == 0.0) { return coords; }\nvec2 direction=1.0*normalize(centered_screen_pos);\nvec2 dist_coords=vec2(0.5,0.5);\ndist_coords.x=0.5+direction.x*radius2*1.0;\ndist_coords.y=0.5+direction.y*radius2*1.0;\nfloat dist_amount=clamp(distortion*0.23,0.0,1.0);\ndist_coords=mix(coords,dist_coords,dist_amount);\nreturn dist_coords;\n}\n\nfloat sampleScreen(inout vec4 color,const in vec2 offset,const in float weight) {\n\nvec2 coords=distorted_coords;\nfloat angle=rand(coords*100.0).x*TWOPI;\ncoords+=vec2(offset.x*cos(angle)-offset.y*sin(angle),offset.x*sin(angle)+offset.y*cos(angle));\ncolor+=texture2D(textureSampler,coords)*weight;\nreturn weight;\n}\n\nfloat getBlurLevel(float size) {\nreturn min(3.0,ceil(size/1.0));\n}\n\nvec4 getBlurColor(float size) {\nvec4 col=texture2D(textureSampler,distorted_coords);\nif (size == 0.0) { return col; }\n\n\nfloat blur_level=getBlurLevel(size);\nfloat w=(size/screen_width);\nfloat h=(size/screen_height);\nfloat total_weight=1.0;\nvec2 sample_coords;\ntotal_weight+=sampleScreen(col,vec2(-0.50*w,0.24*h),0.93);\ntotal_weight+=sampleScreen(col,vec2(0.30*w,-0.75*h),0.90);\ntotal_weight+=sampleScreen(col,vec2(0.36*w,0.96*h),0.87);\ntotal_weight+=sampleScreen(col,vec2(-1.08*w,-0.55*h),0.85);\ntotal_weight+=sampleScreen(col,vec2(1.33*w,-0.37*h),0.83);\ntotal_weight+=sampleScreen(col,vec2(-0.82*w,1.31*h),0.80);\ntotal_weight+=sampleScreen(col,vec2(-0.31*w,-1.67*h),0.78);\ntotal_weight+=sampleScreen(col,vec2(1.47*w,1.11*h),0.76);\ntotal_weight+=sampleScreen(col,vec2(-1.97*w,0.19*h),0.74);\ntotal_weight+=sampleScreen(col,vec2(1.42*w,-1.57*h),0.72);\nif (blur_level>1.0) {\ntotal_weight+=sampleScreen(col,vec2(0.01*w,2.25*h),0.70);\ntotal_weight+=sampleScreen(col,vec2(-1.62*w,-1.74*h),0.67);\ntotal_weight+=sampleScreen(col,vec2(2.49*w,0.20*h),0.65);\ntotal_weight+=sampleScreen(col,vec2(-2.07*w,1.61*h),0.63);\ntotal_weight+=sampleScreen(col,vec2(0.46*w,-2.70*h),0.61);\ntotal_weight+=sampleScreen(col,vec2(1.55*w,2.40*h),0.59);\ntotal_weight+=sampleScreen(col,vec2(-2.88*w,-0.75*h),0.56);\ntotal_weight+=sampleScreen(col,vec2(2.73*w,-1.44*h),0.54);\ntotal_weight+=sampleScreen(col,vec2(-1.08*w,3.02*h),0.52);\ntotal_weight+=sampleScreen(col,vec2(-1.28*w,-3.05*h),0.49);\n}\nif (blur_level>2.0) {\ntotal_weight+=sampleScreen(col,vec2(3.11*w,1.43*h),0.46);\ntotal_weight+=sampleScreen(col,vec2(-3.36*w,1.08*h),0.44);\ntotal_weight+=sampleScreen(col,vec2(1.80*w,-3.16*h),0.41);\ntotal_weight+=sampleScreen(col,vec2(0.83*w,3.65*h),0.38);\ntotal_weight+=sampleScreen(col,vec2(-3.16*w,-2.19*h),0.34);\ntotal_weight+=sampleScreen(col,vec2(3.92*w,-0.53*h),0.31);\ntotal_weight+=sampleScreen(col,vec2(-2.59*w,3.12*h),0.26);\ntotal_weight+=sampleScreen(col,vec2(-0.20*w,-4.15*h),0.22);\ntotal_weight+=sampleScreen(col,vec2(3.02*w,3.00*h),0.15);\n}\ncol/=total_weight;\n\nif (darken>0.0) {\ncol.rgb*=clamp(0.3,1.0,1.05-size*0.5*darken);\n}\n\n\n\n\nreturn col;\n}\nvoid main(void)\n{\n\ncentered_screen_pos=vec2(vUV.x-0.5,vUV.y-0.5);\nradius2=centered_screen_pos.x*centered_screen_pos.x+centered_screen_pos.y*centered_screen_pos.y;\nradius=sqrt(radius2);\ndistorted_coords=getDistortedCoords(vUV);\nvec2 texels_coords=vec2(vUV.x*screen_width,vUV.y*screen_height);\nfloat depth=texture2D(depthSampler,distorted_coords).r;\nfloat distance=near+(far-near)*depth;\nvec4 color=texture2D(textureSampler,vUV);\n\n\nfloat coc=abs(aperture*(screen_distance*(inverse_focal_length-1.0/distance)-1.0));\n\nif (dof_enabled == false || coc<0.07) { coc=0.0; }\n\nfloat edge_blur_amount=0.0;\nif (edge_blur>0.0) {\nedge_blur_amount=clamp((radius*2.0-1.0+0.15*edge_blur)*1.5,0.0,1.0)*1.3;\n}\n\nfloat blur_amount=max(edge_blur_amount,coc);\n\nif (blur_amount == 0.0) {\ngl_FragColor=texture2D(textureSampler,distorted_coords);\n}\nelse {\n\ngl_FragColor=getBlurColor(blur_amount*1.7);\n\nif (highlights) {\ngl_FragColor.rgb+=clamp(coc,0.0,1.0)*texture2D(highlightsSampler,distorted_coords).rgb;\n}\nif (blur_noise) {\n\nvec2 noise=rand(distorted_coords)*0.01*blur_amount;\nvec2 blurred_coord=vec2(distorted_coords.x+noise.x,distorted_coords.y+noise.y);\ngl_FragColor=0.04*texture2D(textureSampler,blurred_coord)+0.96*gl_FragColor;\n}\n}\n\nif (grain_amount>0.0) {\nvec4 grain_color=texture2D(grainSampler,texels_coords*0.003);\ngl_FragColor.rgb+=(-0.5+grain_color.rgb)*0.30*grain_amount;\n}\n}\n";St.a.ShadersStore.depthOfFieldPixelShader=nc;var oc=function(e){function t(t,i,r,n,o){void 0===n&&(n=1);var s=e.call(this,r.getEngine(),t)||this;return s.LensChromaticAberrationEffect="LensChromaticAberrationEffect",s.HighlightsEnhancingEffect="HighlightsEnhancingEffect",s.LensDepthOfFieldEffect="LensDepthOfFieldEffect",s._scene=r,s._depthTexture=r.enableDepthRenderer().getDepthMap(),i.grain_texture?s._grainTexture=i.grain_texture:s._createGrainTexture(),s._edgeBlur=i.edge_blur?i.edge_blur:0,s._grainAmount=i.grain_amount?i.grain_amount:0,s._chromaticAberration=i.chromatic_aberration?i.chromatic_aberration:0,s._distortion=i.distortion?i.distortion:0,s._highlightsGain=void 0!==i.dof_gain?i.dof_gain:-1,s._highlightsThreshold=i.dof_threshold?i.dof_threshold:1,s._dofDistance=void 0!==i.dof_focus_distance?i.dof_focus_distance:-1,s._dofAperture=i.dof_aperture?i.dof_aperture:1,s._dofDarken=i.dof_darken?i.dof_darken:0,s._dofPentagon=void 0===i.dof_pentagon||i.dof_pentagon,s._blurNoise=void 0===i.blur_noise||i.blur_noise,s._createChromaticAberrationPostProcess(n),s._createHighlightsPostProcess(n),s._createDepthOfFieldPostProcess(n/4),s.addEffect(new _a(r.getEngine(),s.LensChromaticAberrationEffect,function(){return s._chromaticAberrationPostProcess},!0)),s.addEffect(new _a(r.getEngine(),s.HighlightsEnhancingEffect,function(){return s._highlightsPostProcess},!0)),s.addEffect(new _a(r.getEngine(),s.LensDepthOfFieldEffect,function(){return s._depthOfFieldPostProcess},!0)),-1===s._highlightsGain&&s._disableEffect(s.HighlightsEnhancingEffect,null),r.postProcessRenderPipelineManager.addPipeline(s),o&&r.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(t,o),s}return l.d(t,e),t.prototype.setEdgeBlur=function(e){this._edgeBlur=e},t.prototype.disableEdgeBlur=function(){this._edgeBlur=0},t.prototype.setGrainAmount=function(e){this._grainAmount=e},t.prototype.disableGrain=function(){this._grainAmount=0},t.prototype.setChromaticAberration=function(e){this._chromaticAberration=e},t.prototype.disableChromaticAberration=function(){this._chromaticAberration=0},t.prototype.setEdgeDistortion=function(e){this._distortion=e},t.prototype.disableEdgeDistortion=function(){this._distortion=0},t.prototype.setFocusDistance=function(e){this._dofDistance=e},t.prototype.disableDepthOfField=function(){this._dofDistance=-1},t.prototype.setAperture=function(e){this._dofAperture=e},t.prototype.setDarkenOutOfFocus=function(e){this._dofDarken=e},t.prototype.enablePentagonBokeh=function(){this._highlightsPostProcess.updateEffect("#define PENTAGON\n")},t.prototype.disablePentagonBokeh=function(){this._highlightsPostProcess.updateEffect()},t.prototype.enableNoiseBlur=function(){this._blurNoise=!0},t.prototype.disableNoiseBlur=function(){this._blurNoise=!1},t.prototype.setHighlightsGain=function(e){this._highlightsGain=e},t.prototype.setHighlightsThreshold=function(e){-1===this._highlightsGain&&(this._highlightsGain=1),this._highlightsThreshold=e},t.prototype.disableHighlights=function(){this._highlightsGain=-1},t.prototype.dispose=function(e){void 0===e&&(e=!1),this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name,this._scene.cameras),this._chromaticAberrationPostProcess=null,this._highlightsPostProcess=null,this._depthOfFieldPostProcess=null,this._grainTexture.dispose(),e&&this._scene.disableDepthRenderer()},t.prototype._createChromaticAberrationPostProcess=function(e){var t=this;this._chromaticAberrationPostProcess=new Mt("LensChromaticAberration","chromaticAberration",["chromatic_aberration","screen_width","screen_height","direction","radialIntensity","centerPosition"],[],e,null,Ve.a.TRILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1),this._chromaticAberrationPostProcess.onApply=function(e){e.setFloat("chromatic_aberration",t._chromaticAberration),e.setFloat("screen_width",t._scene.getEngine().getRenderWidth()),e.setFloat("screen_height",t._scene.getEngine().getRenderHeight()),e.setFloat("radialIntensity",1),e.setFloat2("direction",17,17),e.setFloat2("centerPosition",.5,.5)}},t.prototype._createHighlightsPostProcess=function(e){var t=this;this._highlightsPostProcess=new Mt("LensHighlights","lensHighlights",["gain","threshold","screen_width","screen_height"],[],e,null,Ve.a.TRILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,this._dofPentagon?"#define PENTAGON\n":""),this._highlightsPostProcess.onApply=function(e){e.setFloat("gain",t._highlightsGain),e.setFloat("threshold",t._highlightsThreshold),e.setTextureFromPostProcess("textureSampler",t._chromaticAberrationPostProcess),e.setFloat("screen_width",t._scene.getEngine().getRenderWidth()),e.setFloat("screen_height",t._scene.getEngine().getRenderHeight())}},t.prototype._createDepthOfFieldPostProcess=function(e){var t=this;this._depthOfFieldPostProcess=new Mt("LensDepthOfField","depthOfField",["grain_amount","blur_noise","screen_width","screen_height","distortion","dof_enabled","screen_distance","aperture","darken","edge_blur","highlights","near","far"],["depthSampler","grainSampler","highlightsSampler"],e,null,Ve.a.TRILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1),this._depthOfFieldPostProcess.onApply=function(e){e.setTexture("depthSampler",t._depthTexture),e.setTexture("grainSampler",t._grainTexture),e.setTextureFromPostProcess("textureSampler",t._highlightsPostProcess),e.setTextureFromPostProcess("highlightsSampler",t._depthOfFieldPostProcess),e.setFloat("grain_amount",t._grainAmount),e.setBool("blur_noise",t._blurNoise),e.setFloat("screen_width",t._scene.getEngine().getRenderWidth()),e.setFloat("screen_height",t._scene.getEngine().getRenderHeight()),e.setFloat("distortion",t._distortion),e.setBool("dof_enabled",-1!==t._dofDistance),e.setFloat("screen_distance",1/(.1-1/t._dofDistance)),e.setFloat("aperture",t._dofAperture),e.setFloat("darken",t._dofDarken),e.setFloat("edge_blur",t._edgeBlur),e.setBool("highlights",-1!==t._highlightsGain),t._scene.activeCamera&&(e.setFloat("near",t._scene.activeCamera.minZ),e.setFloat("far",t._scene.activeCamera.maxZ))}},t.prototype._createGrainTexture=function(){this._grainTexture=new di("LensNoiseTexture",512,this._scene,!1,Ve.a.BILINEAR_SAMPLINGMODE),this._grainTexture.wrapU=Ve.a.WRAP_ADDRESSMODE,this._grainTexture.wrapV=Ve.a.WRAP_ADDRESSMODE;for(var e,t,i,r=this._grainTexture.getContext(),n=0;n<512;n++)for(var o=0;o<512;o++)e=Math.floor(255*(t=.42,i=.58,Math.random()*(i-t)+t)),r.fillStyle="rgb("+e+", "+e+", "+e+")",r.fillRect(n,o,1,1);this._grainTexture.update(!1)},t}(tc),sc="\nprecision highp float;\nuniform sampler2D textureSampler;\nuniform float near;\nuniform float far;\nuniform float radius;\nfloat scales[16]=float[16](\n0.1,\n0.11406250000000001,\n0.131640625,\n0.15625,\n0.187890625,\n0.2265625,\n0.272265625,\n0.325,\n0.384765625,\n0.4515625,\n0.525390625,\n0.60625,\n0.694140625,\n0.7890625,\n0.891015625,\n1.0\n);\nvarying vec2 vUV;\nfloat perspectiveDepthToViewZ( const in float invClipZ,const in float near,const in float far ) {\nreturn ( near*far )/( ( far-near )*invClipZ-far );\n}\nfloat viewZToPerspectiveDepth( const in float viewZ,const in float near,const in float far ) {\nreturn ( near*far/viewZ+far)/( far-near );\n}\nfloat viewZToOrthographicDepth( const in float viewZ,const in float near,const in float far ) {\nreturn ( viewZ+near )/( near-far );\n}\n#ifdef SSAO\nuniform sampler2D randomSampler;\nuniform sampler2D normalSampler;\nuniform float randTextureTiles;\nuniform float samplesFactor;\nuniform vec3 sampleSphere[SAMPLES];\nuniform float totalStrength;\nuniform float base;\nuniform float xViewport;\nuniform float yViewport;\nuniform float maxZ;\nuniform float minZAspect;\nuniform vec2 texelSize;\nuniform mat4 projection;\nvoid main()\n{\nvec3 random=texture2D(randomSampler,vUV*randTextureTiles).rgb;\nfloat depth=texture2D(textureSampler,vUV).r;\nfloat depthSign=depth/abs(depth);\ndepth=depth*depthSign;\nvec3 normal=texture2D(normalSampler,vUV).rgb;\nfloat occlusion=0.0;\nfloat correctedRadius=min(radius,minZAspect*depth/near);\nvec3 vViewRay=vec3((vUV.x*2.0-1.0)*xViewport,(vUV.y*2.0-1.0)*yViewport,depthSign);\nvec3 origin=vViewRay*depth;\nvec3 rvec=random*2.0-1.0;\nrvec.z=0.0;\n\nfloat dotProduct=dot(rvec,normal);\nrvec=1.0-abs(dotProduct)>1e-2 ? rvec : vec3(-rvec.y,0.0,rvec.x);\nvec3 tangent=normalize(rvec-normal*dot(rvec,normal));\nvec3 bitangent=cross(normal,tangent);\nmat3 tbn=mat3(tangent,bitangent,normal);\nfloat difference;\nfor (int i=0; i<SAMPLES; ++i) {\n\nvec3 samplePosition=scales[(i+int(random.x*16.0)) % 16]*tbn*sampleSphere[(i+int(random.y*16.0)) % 16];\nsamplePosition=samplePosition*correctedRadius+origin;\n\nvec4 offset=vec4(samplePosition,1.0);\noffset=projection*offset;\noffset.xyz/=offset.w;\noffset.xy=offset.xy*0.5+0.5;\nif (offset.x<0.0 || offset.y<0.0 || offset.x>1.0 || offset.y>1.0) {\ncontinue;\n}\n\nfloat sampleDepth=abs(texture2D(textureSampler,offset.xy).r);\n\ndifference=depthSign*samplePosition.z-sampleDepth;\nfloat rangeCheck=1.0-smoothstep(correctedRadius*0.5,correctedRadius,difference);\nocclusion+=(difference>=0.0 ? 1.0 : 0.0)*rangeCheck;\n}\nocclusion=occlusion*(1.0-smoothstep(maxZ*0.75,maxZ,depth));\nfloat ao=1.0-totalStrength*occlusion*samplesFactor;\nfloat result=clamp(ao+base,0.0,1.0);\ngl_FragColor=vec4(vec3(result),1.0);\n}\n#endif\n#ifdef BILATERAL_BLUR\nuniform sampler2D depthSampler;\nuniform float outSize;\nuniform float samplerOffsets[SAMPLES];\nvec4 blur9(sampler2D image,vec2 uv,float resolution,vec2 direction) {\nvec4 color=vec4(0.0);\nvec2 off1=vec2(1.3846153846)*direction;\nvec2 off2=vec2(3.2307692308)*direction;\ncolor+=texture2D(image,uv)*0.2270270270;\ncolor+=texture2D(image,uv+(off1/resolution))*0.3162162162;\ncolor+=texture2D(image,uv-(off1/resolution))*0.3162162162;\ncolor+=texture2D(image,uv+(off2/resolution))*0.0702702703;\ncolor+=texture2D(image,uv-(off2/resolution))*0.0702702703;\nreturn color;\n}\nvec4 blur13(sampler2D image,vec2 uv,float resolution,vec2 direction) {\nvec4 color=vec4(0.0);\nvec2 off1=vec2(1.411764705882353)*direction;\nvec2 off2=vec2(3.2941176470588234)*direction;\nvec2 off3=vec2(5.176470588235294)*direction;\ncolor+=texture2D(image,uv)*0.1964825501511404;\ncolor+=texture2D(image,uv+(off1/resolution))*0.2969069646728344;\ncolor+=texture2D(image,uv-(off1/resolution))*0.2969069646728344;\ncolor+=texture2D(image,uv+(off2/resolution))*0.09447039785044732;\ncolor+=texture2D(image,uv-(off2/resolution))*0.09447039785044732;\ncolor+=texture2D(image,uv+(off3/resolution))*0.010381362401148057;\ncolor+=texture2D(image,uv-(off3/resolution))*0.010381362401148057;\nreturn color;\n}\nvec4 blur13Bilateral(sampler2D image,vec2 uv,float resolution,vec2 direction) {\nvec4 color=vec4(0.0);\nvec2 off1=vec2(1.411764705882353)*direction;\nvec2 off2=vec2(3.2941176470588234)*direction;\nvec2 off3=vec2(5.176470588235294)*direction;\nfloat compareDepth=abs(texture2D(depthSampler,uv).r);\nfloat sampleDepth;\nfloat weight;\nfloat weightSum=30.0;\ncolor+=texture2D(image,uv)*30.0;\nsampleDepth=abs(texture2D(depthSampler,uv+(off1/resolution)).r);\nweight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);\nweightSum+=weight;\ncolor+=texture2D(image,uv+(off1/resolution))*weight;\nsampleDepth=abs(texture2D(depthSampler,uv-(off1/resolution)).r);\nweight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);\nweightSum+=weight;\ncolor+=texture2D(image,uv-(off1/resolution))*weight;\nsampleDepth=abs(texture2D(depthSampler,uv+(off2/resolution)).r);\nweight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);\nweightSum+=weight;\ncolor+=texture2D(image,uv+(off2/resolution))*weight;\nsampleDepth=abs(texture2D(depthSampler,uv-(off2/resolution)).r);\nweight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);\nweightSum+=weight;\ncolor+=texture2D(image,uv-(off2/resolution))*weight;\nsampleDepth=abs(texture2D(depthSampler,uv+(off3/resolution)).r);\nweight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);\nweightSum+=weight;\ncolor+=texture2D(image,uv+(off3/resolution))*weight;\nsampleDepth=abs(texture2D(depthSampler,uv-(off3/resolution)).r);\nweight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);\nweightSum+=weight;\ncolor+=texture2D(image,uv-(off3/resolution))*weight;\nreturn color/weightSum;\n}\nvoid main()\n{\n#if EXPENSIVE\nfloat compareDepth=abs(texture2D(depthSampler,vUV).r);\nfloat texelsize=1.0/outSize;\nfloat result=0.0;\nfloat weightSum=0.0;\nfor (int i=0; i<SAMPLES; ++i)\n{\n#ifdef BILATERAL_BLUR_H\nvec2 direction=vec2(1.0,0.0);\nvec2 sampleOffset=vec2(texelsize*samplerOffsets[i],0.0);\n#else\nvec2 direction=vec2(0.0,1.0);\nvec2 sampleOffset=vec2(0.0,texelsize*samplerOffsets[i]);\n#endif\nvec2 samplePos=vUV+sampleOffset;\nfloat sampleDepth=abs(texture2D(depthSampler,samplePos).r);\nfloat weight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30000.0);\nresult+=texture2D(textureSampler,samplePos).r*weight;\nweightSum+=weight;\n}\nresult/=weightSum;\ngl_FragColor.rgb=vec3(result);\ngl_FragColor.a=1.0;\n#else\nvec4 color;\n#ifdef BILATERAL_BLUR_H\nvec2 direction=vec2(1.0,0.0);\ncolor=blur13Bilateral(textureSampler,vUV,outSize,direction);\n#else\nvec2 direction=vec2(0.0,1.0);\ncolor=blur13Bilateral(textureSampler,vUV,outSize,direction);\n#endif\ngl_FragColor.rgb=vec3(color.r);\ngl_FragColor.a=1.0;\n#endif\n}\n#endif\n";St.a.ShadersStore.ssao2PixelShader=sc;var ac="uniform sampler2D textureSampler;\nuniform sampler2D originalColor;\nuniform vec4 viewport;\nvarying vec2 vUV;\nvoid main(void) {\nvec4 ssaoColor=texture2D(textureSampler,viewport.xy+vUV*viewport.zw);\nvec4 sceneColor=texture2D(originalColor,vUV);\ngl_FragColor=sceneColor*ssaoColor;\n}\n";St.a.ShadersStore.ssaoCombinePixelShader=ac;var cc=function(e){function t(t,i,r,n){var o=e.call(this,i.getEngine(),t)||this;if(o.SSAOOriginalSceneColorEffect="SSAOOriginalSceneColorEffect",o.SSAORenderEffect="SSAORenderEffect",o.SSAOBlurHRenderEffect="SSAOBlurHRenderEffect",o.SSAOBlurVRenderEffect="SSAOBlurVRenderEffect",o.SSAOCombineRenderEffect="SSAOCombineRenderEffect",o.totalStrength=1,o.maxZ=100,o.minZAspect=.2,o._samples=8,o._textureSamples=1,o._expensiveBlur=!0,o.radius=2,o.base=0,o._firstUpdate=!0,o._bits=new Uint32Array(1),o._scene=i,o._ratio=r,!o.isSupported)return p.a.Error("SSAO 2 needs WebGL 2 support."),o;var s=o._ratio.ssaoRatio||r,a=o._ratio.blurRatio||r,c=i.enableGeometryBufferRenderer();return o._createRandomTexture(),o._depthTexture=c.getGBuffer().textures[0],o._normalTexture=c.getGBuffer().textures[1],o._originalColorPostProcess=new Dt("SSAOOriginalSceneColor",1,null,Ve.a.BILINEAR_SAMPLINGMODE,i.getEngine(),!1),o._originalColorPostProcess.samples=o.textureSamples,o._createSSAOPostProcess(1),o._createBlurPostProcess(s,a),o._createSSAOCombinePostProcess(a),o.addEffect(new _a(i.getEngine(),o.SSAOOriginalSceneColorEffect,function(){return o._originalColorPostProcess},!0)),o.addEffect(new _a(i.getEngine(),o.SSAORenderEffect,function(){return o._ssaoPostProcess},!0)),o.addEffect(new _a(i.getEngine(),o.SSAOBlurHRenderEffect,function(){return o._blurHPostProcess},!0)),o.addEffect(new _a(i.getEngine(),o.SSAOBlurVRenderEffect,function(){return o._blurVPostProcess},!0)),o.addEffect(new _a(i.getEngine(),o.SSAOCombineRenderEffect,function(){return o._ssaoCombinePostProcess},!0)),i.postProcessRenderPipelineManager.addPipeline(o),n&&i.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(t,n),o}return l.d(t,e),Object.defineProperty(t.prototype,"samples",{get:function(){return this._samples},set:function(e){this._ssaoPostProcess.updateEffect("#define SAMPLES "+e+"\n#define SSAO"),this._samples=e,this._sampleSphere=this._generateHemisphere(),this._firstUpdate=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"textureSamples",{get:function(){return this._textureSamples},set:function(e){this._textureSamples=e,this._originalColorPostProcess.samples=e,this._blurHPostProcess.samples=e,this._blurVPostProcess.samples=e,this._ssaoPostProcess.samples=e,this._ssaoCombinePostProcess.samples=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"expensiveBlur",{get:function(){return this._expensiveBlur},set:function(e){this._blurHPostProcess.updateEffect("#define BILATERAL_BLUR\n#define BILATERAL_BLUR_H\n#define SAMPLES 16\n#define EXPENSIVE "+(e?"1":"0")+"\n",null,["textureSampler","depthSampler"]),this._blurVPostProcess.updateEffect("#define BILATERAL_BLUR\n#define SAMPLES 16\n#define EXPENSIVE "+(e?"1":"0")+"\n",null,["textureSampler","depthSampler"]),this._expensiveBlur=e,this._firstUpdate=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t,"IsSupported",{get:function(){var e=R.a.LastCreatedEngine;return!!e&&e.getCaps().drawBuffersExtension},enumerable:!0,configurable:!0}),t.prototype.dispose=function(t){void 0===t&&(t=!1);for(var i=0;i<this._scene.cameras.length;i++){var r=this._scene.cameras[i];this._originalColorPostProcess.dispose(r),this._ssaoPostProcess.dispose(r),this._blurHPostProcess.dispose(r),this._blurVPostProcess.dispose(r),this._ssaoCombinePostProcess.dispose(r)}this._randomTexture.dispose(),t&&this._scene.disableGeometryBufferRenderer(),this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name,this._scene.cameras),e.prototype.dispose.call(this)},t.prototype._createBlurPostProcess=function(e,t){var i=this;this._samplerOffsets=[];for(var r=this.expensiveBlur,n=-8;n<8;n++)this._samplerOffsets.push(2*n+.5);this._blurHPostProcess=new Mt("BlurH","ssao2",["outSize","samplerOffsets","near","far","radius"],["depthSampler"],e,null,Ve.a.TRILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,"#define BILATERAL_BLUR\n#define BILATERAL_BLUR_H\n#define SAMPLES 16\n#define EXPENSIVE "+(r?"1":"0")+"\n"),this._blurHPostProcess.onApply=function(e){i._scene.activeCamera&&(e.setFloat("outSize",i._ssaoCombinePostProcess.width>0?i._ssaoCombinePostProcess.width:i._originalColorPostProcess.width),e.setFloat("near",i._scene.activeCamera.minZ),e.setFloat("far",i._scene.activeCamera.maxZ),e.setFloat("radius",i.radius),e.setTexture("depthSampler",i._depthTexture),i._firstUpdate&&e.setArray("samplerOffsets",i._samplerOffsets))},this._blurVPostProcess=new Mt("BlurV","ssao2",["outSize","samplerOffsets","near","far","radius"],["depthSampler"],t,null,Ve.a.TRILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,"#define BILATERAL_BLUR\n#define BILATERAL_BLUR_V\n#define SAMPLES 16\n#define EXPENSIVE "+(r?"1":"0")+"\n"),this._blurVPostProcess.onApply=function(e){i._scene.activeCamera&&(e.setFloat("outSize",i._ssaoCombinePostProcess.height>0?i._ssaoCombinePostProcess.height:i._originalColorPostProcess.height),e.setFloat("near",i._scene.activeCamera.minZ),e.setFloat("far",i._scene.activeCamera.maxZ),e.setFloat("radius",i.radius),e.setTexture("depthSampler",i._depthTexture),i._firstUpdate&&(e.setArray("samplerOffsets",i._samplerOffsets),i._firstUpdate=!1))},this._blurHPostProcess.samples=this.textureSamples,this._blurVPostProcess.samples=this.textureSamples},t.prototype._rebuild=function(){this._firstUpdate=!0,e.prototype._rebuild.call(this)},t.prototype._radicalInverse_VdC=function(e){return this._bits[0]=e,this._bits[0]=(this._bits[0]<<16|this._bits[0]>>16)>>>0,this._bits[0]=(1431655765&this._bits[0])<<1|(2863311530&this._bits[0])>>>1>>>0,this._bits[0]=(858993459&this._bits[0])<<2|(3435973836&this._bits[0])>>>2>>>0,this._bits[0]=(252645135&this._bits[0])<<4|(4042322160&this._bits[0])>>>4>>>0,this._bits[0]=(16711935&this._bits[0])<<8|(4278255360&this._bits[0])>>>8>>>0,2.3283064365386963e-10*this._bits[0]},t.prototype._hammersley=function(e,t){return[e/t,this._radicalInverse_VdC(e)]},t.prototype._hemisphereSample_uniform=function(e,t){var i=2*t*Math.PI,r=1-(.85*e+.15),n=Math.sqrt(1-r*r);return new o.x(Math.cos(i)*n,Math.sin(i)*n,r)},t.prototype._generateHemisphere=function(){for(var e,t=this.samples,i=[],r=0;r<t;){if(t<16)e=this._hemisphereSample_uniform(Math.random(),Math.random());else{var n=this._hammersley(r,t);e=this._hemisphereSample_uniform(n[0],n[1])}i.push(e.x,e.y,e.z),r++}return i},t.prototype._createSSAOPostProcess=function(e){var t=this,i=this.samples;this._sampleSphere=this._generateHemisphere(),this._ssaoPostProcess=new Mt("ssao2","ssao2",["sampleSphere","samplesFactor","randTextureTiles","totalStrength","radius","base","range","projection","near","far","texelSize","xViewport","yViewport","maxZ","minZAspect"],["randomSampler","normalSampler"],e,null,Ve.a.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,"#define SAMPLES "+i+"\n#define SSAO"),this._ssaoPostProcess.onApply=function(e){t._firstUpdate&&(e.setArray3("sampleSphere",t._sampleSphere),e.setFloat("randTextureTiles",32)),t._scene.activeCamera&&(e.setFloat("samplesFactor",1/t.samples),e.setFloat("totalStrength",t.totalStrength),e.setFloat2("texelSize",1/t._ssaoPostProcess.width,1/t._ssaoPostProcess.height),e.setFloat("radius",t.radius),e.setFloat("maxZ",t.maxZ),e.setFloat("minZAspect",t.minZAspect),e.setFloat("base",t.base),e.setFloat("near",t._scene.activeCamera.minZ),e.setFloat("far",t._scene.activeCamera.maxZ),e.setFloat("xViewport",Math.tan(t._scene.activeCamera.fov/2)*t._scene.getEngine().getAspectRatio(t._scene.activeCamera,!0)),e.setFloat("yViewport",Math.tan(t._scene.activeCamera.fov/2)),e.setMatrix("projection",t._scene.getProjectionMatrix()),e.setTexture("textureSampler",t._depthTexture),e.setTexture("normalSampler",t._normalTexture),e.setTexture("randomSampler",t._randomTexture))},this._ssaoPostProcess.samples=this.textureSamples},t.prototype._createSSAOCombinePostProcess=function(e){var t=this;this._ssaoCombinePostProcess=new Mt("ssaoCombine","ssaoCombine",[],["originalColor","viewport"],e,null,Ve.a.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1),this._ssaoCombinePostProcess.onApply=function(e){var i=t._scene.activeCamera.viewport;e.setVector4("viewport",o.t.Vector4[0].copyFromFloats(i.x,i.y,i.width,i.height)),e.setTextureFromPostProcess("originalColor",t._originalColorPostProcess)},this._ssaoCombinePostProcess.samples=this.textureSamples},t.prototype._createRandomTexture=function(){this._randomTexture=new di("SSAORandomTexture",128,this._scene,!1,Ve.a.TRILINEAR_SAMPLINGMODE),this._randomTexture.wrapU=Ve.a.WRAP_ADDRESSMODE,this._randomTexture.wrapV=Ve.a.WRAP_ADDRESSMODE;for(var e=this._randomTexture.getContext(),t=function(e,t){return Math.random()*(t-e)+e},i=o.x.Zero(),r=0;r<128;r++)for(var n=0;n<128;n++)i.x=t(0,1),i.y=t(0,1),i.z=0,i.normalize(),i.scaleInPlace(255),i.x=Math.floor(i.x),i.y=Math.floor(i.y),e.fillStyle="rgb("+i.x+", "+i.y+", "+i.z+")",e.fillRect(r,n,1,1);this._randomTexture.update(!1)},t.prototype.serialize=function(){var e=w.a.Serialize(this);return e.customType="SSAO2RenderingPipeline",e},t.Parse=function(e,i,r){return w.a.Parse(function(){return new t(e._name,i,e._ratio)},e,i,r)},l.c([Object(w.c)()],t.prototype,"totalStrength",void 0),l.c([Object(w.c)()],t.prototype,"maxZ",void 0),l.c([Object(w.c)()],t.prototype,"minZAspect",void 0),l.c([Object(w.c)("samples")],t.prototype,"_samples",void 0),l.c([Object(w.c)("textureSamples")],t.prototype,"_textureSamples",void 0),l.c([Object(w.c)()],t.prototype,"_ratio",void 0),l.c([Object(w.c)("expensiveBlur")],t.prototype,"_expensiveBlur",void 0),l.c([Object(w.c)()],t.prototype,"radius",void 0),l.c([Object(w.c)()],t.prototype,"base",void 0),t}(tc);s.a.RegisteredTypes["BABYLON.SSAO2RenderingPipeline"]=cc;var lc="\nuniform sampler2D textureSampler;\nvarying vec2 vUV;\n#ifdef SSAO\nuniform sampler2D randomSampler;\nuniform float randTextureTiles;\nuniform float samplesFactor;\nuniform vec3 sampleSphere[SAMPLES];\nuniform float totalStrength;\nuniform float radius;\nuniform float area;\nuniform float fallOff;\nuniform float base;\nvec3 normalFromDepth(float depth,vec2 coords)\n{\nvec2 offset1=vec2(0.0,radius);\nvec2 offset2=vec2(radius,0.0);\nfloat depth1=texture2D(textureSampler,coords+offset1).r;\nfloat depth2=texture2D(textureSampler,coords+offset2).r;\nvec3 p1=vec3(offset1,depth1-depth);\nvec3 p2=vec3(offset2,depth2-depth);\nvec3 normal=cross(p1,p2);\nnormal.z=-normal.z;\nreturn normalize(normal);\n}\nvoid main()\n{\nvec3 random=normalize(texture2D(randomSampler,vUV*randTextureTiles).rgb);\nfloat depth=texture2D(textureSampler,vUV).r;\nvec3 position=vec3(vUV,depth);\nvec3 normal=normalFromDepth(depth,vUV);\nfloat radiusDepth=radius/depth;\nfloat occlusion=0.0;\nvec3 ray;\nvec3 hemiRay;\nfloat occlusionDepth;\nfloat difference;\nfor (int i=0; i<SAMPLES; i++)\n{\nray=radiusDepth*reflect(sampleSphere[i],random);\nhemiRay=position+sign(dot(ray,normal))*ray;\nocclusionDepth=texture2D(textureSampler,clamp(hemiRay.xy,vec2(0.001,0.001),vec2(0.999,0.999))).r;\ndifference=depth-occlusionDepth;\nocclusion+=step(fallOff,difference)*(1.0-smoothstep(fallOff,area,difference));\n}\nfloat ao=1.0-totalStrength*occlusion*samplesFactor;\nfloat result=clamp(ao+base,0.0,1.0);\ngl_FragColor.r=result;\ngl_FragColor.g=result;\ngl_FragColor.b=result;\ngl_FragColor.a=1.0;\n}\n#endif\n";St.a.ShadersStore.ssaoPixelShader=lc;var uc=function(e){function t(t,i,r,n){var o=e.call(this,i.getEngine(),t)||this;o.SSAOOriginalSceneColorEffect="SSAOOriginalSceneColorEffect",o.SSAORenderEffect="SSAORenderEffect",o.SSAOBlurHRenderEffect="SSAOBlurHRenderEffect",o.SSAOBlurVRenderEffect="SSAOBlurVRenderEffect",o.SSAOCombineRenderEffect="SSAOCombineRenderEffect",o.totalStrength=1,o.radius=1e-4,o.area=.0075,o.fallOff=1e-6,o.base=.5,o._firstUpdate=!0,o._scene=i,o._createRandomTexture(),o._depthTexture=i.enableDepthRenderer().getDepthMap();var s=r.ssaoRatio||r,a=r.combineRatio||r;return o._originalColorPostProcess=new Dt("SSAOOriginalSceneColor",a,null,Ve.a.BILINEAR_SAMPLINGMODE,i.getEngine(),!1),o._createSSAOPostProcess(s),o._createBlurPostProcess(s),o._createSSAOCombinePostProcess(a),o.addEffect(new _a(i.getEngine(),o.SSAOOriginalSceneColorEffect,function(){return o._originalColorPostProcess},!0)),o.addEffect(new _a(i.getEngine(),o.SSAORenderEffect,function(){return o._ssaoPostProcess},!0)),o.addEffect(new _a(i.getEngine(),o.SSAOBlurHRenderEffect,function(){return o._blurHPostProcess},!0)),o.addEffect(new _a(i.getEngine(),o.SSAOBlurVRenderEffect,function(){return o._blurVPostProcess},!0)),o.addEffect(new _a(i.getEngine(),o.SSAOCombineRenderEffect,function(){return o._ssaoCombinePostProcess},!0)),i.postProcessRenderPipelineManager.addPipeline(o),n&&i.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(t,n),o}return l.d(t,e),t.prototype.dispose=function(t){void 0===t&&(t=!1);for(var i=0;i<this._scene.cameras.length;i++){var r=this._scene.cameras[i];this._originalColorPostProcess.dispose(r),this._ssaoPostProcess.dispose(r),this._blurHPostProcess.dispose(r),this._blurVPostProcess.dispose(r),this._ssaoCombinePostProcess.dispose(r)}this._randomTexture.dispose(),t&&this._scene.disableDepthRenderer(),this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name,this._scene.cameras),e.prototype.dispose.call(this)},t.prototype._createBlurPostProcess=function(e){var t=this;this._blurHPostProcess=new Ur("BlurH",new o.w(1,0),16,e,null,Ve.a.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,_.a.TEXTURETYPE_UNSIGNED_INT),this._blurVPostProcess=new Ur("BlurV",new o.w(0,1),16,e,null,Ve.a.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,_.a.TEXTURETYPE_UNSIGNED_INT),this._blurHPostProcess.onActivateObservable.add(function(){var e=t._blurHPostProcess.width/t._scene.getEngine().getRenderWidth();t._blurHPostProcess.kernel=16*e}),this._blurVPostProcess.onActivateObservable.add(function(){var e=t._blurVPostProcess.height/t._scene.getEngine().getRenderHeight();t._blurVPostProcess.kernel=16*e})},t.prototype._rebuild=function(){this._firstUpdate=!0,e.prototype._rebuild.call(this)},t.prototype._createSSAOPostProcess=function(e){var t=this,i=[.5381,.1856,-.4319,.1379,.2486,.443,.3371,.5679,-.0057,-.6999,-.0451,-.0019,.0689,-.1598,-.8547,.056,.0069,-.1843,-.0146,.1402,.0762,.01,-.1924,-.0344,-.3577,-.5301,-.4358,-.3169,.1063,.0158,.0103,-.5869,.0046,-.0897,-.494,.3287,.7119,-.0154,-.0918,-.0533,.0596,-.5411,.0352,-.0631,.546,-.4776,.2847,-.0271];this._ssaoPostProcess=new Mt("ssao","ssao",["sampleSphere","samplesFactor","randTextureTiles","totalStrength","radius","area","fallOff","base","range","viewport"],["randomSampler"],e,null,Ve.a.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,"#define SAMPLES 16\n#define SSAO"),this._ssaoPostProcess.onApply=function(e){t._firstUpdate&&(e.setArray3("sampleSphere",i),e.setFloat("samplesFactor",1/16),e.setFloat("randTextureTiles",4)),e.setFloat("totalStrength",t.totalStrength),e.setFloat("radius",t.radius),e.setFloat("area",t.area),e.setFloat("fallOff",t.fallOff),e.setFloat("base",t.base),e.setTexture("textureSampler",t._depthTexture),e.setTexture("randomSampler",t._randomTexture)}},t.prototype._createSSAOCombinePostProcess=function(e){var t=this;this._ssaoCombinePostProcess=new Mt("ssaoCombine","ssaoCombine",[],["originalColor","viewport"],e,null,Ve.a.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1),this._ssaoCombinePostProcess.onApply=function(e){e.setVector4("viewport",o.t.Vector4[0].copyFromFloats(0,0,1,1)),e.setTextureFromPostProcess("originalColor",t._originalColorPostProcess)}},t.prototype._createRandomTexture=function(){this._randomTexture=new di("SSAORandomTexture",512,this._scene,!1,Ve.a.TRILINEAR_SAMPLINGMODE),this._randomTexture.wrapU=Ve.a.WRAP_ADDRESSMODE,this._randomTexture.wrapV=Ve.a.WRAP_ADDRESSMODE;for(var e=this._randomTexture.getContext(),t=function(e,t){return Math.random()*(t-e)+e},i=o.x.Zero(),r=0;r<512;r++)for(var n=0;n<512;n++)i.x=Math.floor(255*t(-1,1)),i.y=Math.floor(255*t(-1,1)),i.z=Math.floor(255*t(-1,1)),e.fillStyle="rgb("+i.x+", "+i.y+", "+i.z+")",e.fillRect(r,n,1,1);this._randomTexture.update(!1)},l.c([Object(w.c)()],t.prototype,"totalStrength",void 0),l.c([Object(w.c)()],t.prototype,"radius",void 0),l.c([Object(w.c)()],t.prototype,"area",void 0),l.c([Object(w.c)()],t.prototype,"fallOff",void 0),l.c([Object(w.c)()],t.prototype,"base",void 0),t}(tc),hc="uniform sampler2D textureSampler;\nvarying vec2 vUV;\n#if defined(PASS_POST_PROCESS)\nvoid main(void)\n{\nvec4 color=texture2D(textureSampler,vUV);\ngl_FragColor=color;\n}\n#endif\n#if defined(DOWN_SAMPLE_X4)\nuniform vec2 dsOffsets[16];\nvoid main(void)\n{\nvec4 average=vec4(0.0,0.0,0.0,0.0);\naverage=texture2D(textureSampler,vUV+dsOffsets[0]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[1]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[2]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[3]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[4]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[5]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[6]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[7]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[8]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[9]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[10]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[11]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[12]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[13]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[14]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[15]);\naverage/=16.0;\ngl_FragColor=average;\n}\n#endif\n#if defined(BRIGHT_PASS)\nuniform vec2 dsOffsets[4];\nuniform float brightThreshold;\nvoid main(void)\n{\nvec4 average=vec4(0.0,0.0,0.0,0.0);\naverage=texture2D(textureSampler,vUV+vec2(dsOffsets[0].x,dsOffsets[0].y));\naverage+=texture2D(textureSampler,vUV+vec2(dsOffsets[1].x,dsOffsets[1].y));\naverage+=texture2D(textureSampler,vUV+vec2(dsOffsets[2].x,dsOffsets[2].y));\naverage+=texture2D(textureSampler,vUV+vec2(dsOffsets[3].x,dsOffsets[3].y));\naverage*=0.25;\nfloat luminance=length(average.rgb);\nif (luminance<brightThreshold) {\naverage=vec4(0.0,0.0,0.0,1.0);\n}\ngl_FragColor=average;\n}\n#endif\n#if defined(TEXTURE_ADDER)\nuniform sampler2D otherSampler;\nuniform sampler2D lensSampler;\nuniform float exposure;\nvoid main(void)\n{\nvec3 colour=texture2D(textureSampler,vUV).rgb;\ncolour*=exposure;\nvec3 X=max(vec3(0.0,0.0,0.0),colour-0.004);\nvec3 retColor=(X*(6.2*X+0.5))/(X*(6.2*X+1.7)+0.06);\ncolour=retColor*retColor;\ncolour+=colour*texture2D(lensSampler,vUV).rgb;\nvec4 finalColor=vec4(colour.rgb,1.0)+texture2D(otherSampler,vUV);\ngl_FragColor=finalColor;\n}\n#endif\n#if defined(VLS)\n#define PI 3.1415926535897932384626433832795\nuniform mat4 shadowViewProjection;\nuniform mat4 lightWorld;\nuniform vec3 cameraPosition;\nuniform vec3 sunDirection;\nuniform vec3 sunColor;\nuniform vec2 depthValues;\nuniform float scatteringCoefficient;\nuniform float scatteringPower;\nuniform sampler2D shadowMapSampler;\nuniform sampler2D positionSampler;\nfloat computeScattering(float lightDotView)\n{\nfloat result=1.0-scatteringCoefficient*scatteringCoefficient;\nresult/=(4.0*PI*pow(1.0+scatteringCoefficient*scatteringCoefficient-(2.0*scatteringCoefficient)*lightDotView,1.5));\nreturn result;\n}\nvoid main(void)\n{\n\nvec3 worldPos=texture2D(positionSampler,vUV).rgb;\nvec3 startPosition=cameraPosition;\nvec3 rayVector=worldPos-startPosition;\nfloat rayLength=length(rayVector);\nvec3 rayDirection=rayVector/rayLength;\nfloat stepLength=rayLength/NB_STEPS;\nvec3 stepL=rayDirection*stepLength;\nvec3 currentPosition=startPosition;\nvec3 accumFog=vec3(0.0);\nfor (int i=0; i<int(NB_STEPS); i++)\n{\nvec4 worldInShadowCameraSpace=shadowViewProjection*vec4(currentPosition,1.0);\nfloat depthMetric=(worldInShadowCameraSpace.z+depthValues.x)/(depthValues.y);\nfloat shadowPixelDepth=clamp(depthMetric,0.0,1.0);\nworldInShadowCameraSpace.xyz/=worldInShadowCameraSpace.w;\nworldInShadowCameraSpace.xyz=0.5*worldInShadowCameraSpace.xyz+vec3(0.5);\nfloat shadowMapValue=texture2D(shadowMapSampler,worldInShadowCameraSpace.xy).r;\nif (shadowMapValue>shadowPixelDepth)\naccumFog+=sunColor*computeScattering(dot(rayDirection,sunDirection));\ncurrentPosition+=stepL;\n}\naccumFog/=NB_STEPS;\nvec3 color=accumFog*scatteringPower;\ngl_FragColor=vec4(color*exp(color) ,1.0);\n}\n#endif\n#if defined(VLSMERGE)\nuniform sampler2D originalSampler;\nvoid main(void)\n{\ngl_FragColor=texture2D(originalSampler,vUV)+texture2D(textureSampler,vUV);\n}\n#endif\n#if defined(LUMINANCE)\nuniform vec2 lumOffsets[4];\nvoid main()\n{\nfloat average=0.0;\nvec4 color=vec4(0.0);\nfloat maximum=-1e20;\nvec3 weight=vec3(0.299,0.587,0.114);\nfor (int i=0; i<4; i++)\n{\ncolor=texture2D(textureSampler,vUV+ lumOffsets[i]);\n\nfloat GreyValue=dot(color.rgb,vec3(0.33,0.33,0.33));\n\n#ifdef WEIGHTED_AVERAGE\nfloat GreyValue=dot(color.rgb,weight);\n#endif\n#ifdef BRIGHTNESS\nfloat GreyValue=max(color.r,max(color.g,color.b));\n#endif\n#ifdef HSL_COMPONENT\nfloat GreyValue=0.5*(max(color.r,max(color.g,color.b))+min(color.r,min(color.g,color.b)));\n#endif\n#ifdef MAGNITUDE\nfloat GreyValue=length(color.rgb);\n#endif\nmaximum=max(maximum,GreyValue);\naverage+=(0.25*log(1e-5+GreyValue));\n}\naverage=exp(average);\ngl_FragColor=vec4(average,maximum,0.0,1.0);\n}\n#endif\n#if defined(LUMINANCE_DOWN_SAMPLE)\nuniform vec2 dsOffsets[9];\nuniform float halfDestPixelSize;\n#ifdef FINAL_DOWN_SAMPLER\nvec4 pack(float value) {\nconst vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);\nconst vec4 bit_mask=vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);\nvec4 res=fract(value*bit_shift);\nres-=res.xxyz*bit_mask;\nreturn res;\n}\n#endif\nvoid main()\n{\nvec4 color=vec4(0.0);\nfloat average=0.0;\nfor (int i=0; i<9; i++)\n{\ncolor=texture2D(textureSampler,vUV+vec2(halfDestPixelSize,halfDestPixelSize)+dsOffsets[i]);\naverage+=color.r;\n}\naverage/=9.0;\n#ifdef FINAL_DOWN_SAMPLER\ngl_FragColor=pack(average);\n#else\ngl_FragColor=vec4(average,average,0.0,1.0);\n#endif\n}\n#endif\n#if defined(HDR)\nuniform sampler2D textureAdderSampler;\nuniform float averageLuminance;\nvoid main()\n{\nvec4 color=texture2D(textureAdderSampler,vUV);\nvec4 adjustedColor=color/averageLuminance;\ncolor=adjustedColor;\ncolor.a=1.0;\ngl_FragColor=color;\n}\n#endif\n#if defined(LENS_FLARE)\n#define GHOSTS 3\nuniform sampler2D lensColorSampler;\nuniform float strength;\nuniform float ghostDispersal;\nuniform float haloWidth;\nuniform vec2 resolution;\nuniform float distortionStrength;\nfloat hash(vec2 p)\n{\nfloat h=dot(p,vec2(127.1,311.7));\nreturn -1.0+2.0*fract(sin(h)*43758.5453123);\n}\nfloat noise(in vec2 p)\n{\nvec2 i=floor(p);\nvec2 f=fract(p);\nvec2 u=f*f*(3.0-2.0*f);\nreturn mix(mix(hash(i+vec2(0.0,0.0)),\nhash(i+vec2(1.0,0.0)),u.x),\nmix(hash(i+vec2(0.0,1.0)),\nhash(i+vec2(1.0,1.0)),u.x),u.y);\n}\nfloat fbm(vec2 p)\n{\nfloat f=0.0;\nf+=0.5000*noise(p); p*=2.02;\nf+=0.2500*noise(p); p*=2.03;\nf+=0.1250*noise(p); p*=2.01;\nf+=0.0625*noise(p); p*=2.04;\nf/=0.9375;\nreturn f;\n}\nvec3 pattern(vec2 uv)\n{\nvec2 p=-1.0+2.0*uv;\nfloat p2=dot(p,p);\nfloat f=fbm(vec2(15.0*p2))/2.0;\nfloat r=0.2+0.6*sin(12.5*length(uv-vec2(0.5)));\nfloat g=0.2+0.6*sin(20.5*length(uv-vec2(0.5)));\nfloat b=0.2+0.6*sin(17.2*length(uv-vec2(0.5)));\nreturn (1.0-f)*vec3(r,g,b);\n}\nfloat luminance(vec3 color)\n{\nreturn dot(color.rgb,vec3(0.2126,0.7152,0.0722));\n}\nvec4 textureDistorted(sampler2D tex,vec2 texcoord,vec2 direction,vec3 distortion)\n{\nreturn vec4(\ntexture2D(tex,texcoord+direction*distortion.r).r,\ntexture2D(tex,texcoord+direction*distortion.g).g,\ntexture2D(tex,texcoord+direction*distortion.b).b,\n1.0\n);\n}\nvoid main(void)\n{\nvec2 uv=-vUV+vec2(1.0);\nvec2 ghostDir=(vec2(0.5)-uv)*ghostDispersal;\nvec2 texelSize=1.0/resolution;\nvec3 distortion=vec3(-texelSize.x*distortionStrength,0.0,texelSize.x*distortionStrength);\nvec4 result=vec4(0.0);\nfloat ghostIndice=1.0;\nfor (int i=0; i<GHOSTS; ++i)\n{\nvec2 offset=fract(uv+ghostDir*ghostIndice);\nfloat weight=length(vec2(0.5)-offset)/length(vec2(0.5));\nweight=pow(1.0-weight,10.0);\nresult+=textureDistorted(textureSampler,offset,normalize(ghostDir),distortion)*weight*strength;\nghostIndice+=1.0;\n}\nvec2 haloVec=normalize(ghostDir)*haloWidth;\nfloat weight=length(vec2(0.5)-fract(uv+haloVec))/length(vec2(0.5));\nweight=pow(1.0-weight,10.0);\nresult+=textureDistorted(textureSampler,fract(uv+haloVec),normalize(ghostDir),distortion)*weight*strength;\nresult*=texture2D(lensColorSampler,vec2(length(vec2(0.5)-uv)/length(vec2(0.5))));\ngl_FragColor=result;\n}\n#endif\n#if defined(LENS_FLARE_COMPOSE)\nuniform sampler2D otherSampler;\nuniform sampler2D lensDirtSampler;\nuniform sampler2D lensStarSampler;\nuniform mat4 lensStarMatrix;\nvoid main(void)\n{\nvec2 lensFlareCoords=(lensStarMatrix*vec4(vUV,1.0,1.0)).xy;\nvec4 lensMod=texture2D(lensDirtSampler,vUV);\nlensMod+=texture2D(lensStarSampler,vUV);\nvec4 result=texture2D(textureSampler,vUV)*lensMod;\ngl_FragColor=texture2D(otherSampler,vUV)+result;\n}\n#endif\n#if defined(DEPTH_OF_FIELD)\nuniform sampler2D otherSampler;\nuniform sampler2D depthSampler;\nuniform float distance;\nvoid main(void)\n{\nvec4 sharp=texture2D(otherSampler,vUV);\nvec4 blur=texture2D(textureSampler,vUV);\nfloat dist=clamp(texture2D(depthSampler,vUV).r*distance,0.0,1.0);\nfloat factor=0.0;\nif (dist<0.05)\nfactor=1.0;\nelse if (dist<0.1)\nfactor=20.0*(0.1-dist);\nelse if (dist<0.5)\nfactor=0.0;\nelse\nfactor=2.0*(dist-0.5);\nfactor=clamp(factor,0.0,0.90);\ngl_FragColor=mix(sharp,blur,factor);\n}\n#endif\n#if defined(MOTION_BLUR)\nuniform mat4 inverseViewProjection;\nuniform mat4 prevViewProjection;\nuniform vec2 screenSize;\nuniform float motionScale;\nuniform float motionStrength;\nuniform sampler2D depthSampler;\nvoid main(void)\n{\nvec2 texelSize=1.0/screenSize;\nfloat depth=texture2D(depthSampler,vUV).r;\nvec4 cpos=vec4(vUV*2.0-1.0,depth,1.0);\ncpos=cpos*inverseViewProjection;\nvec4 ppos=cpos*prevViewProjection;\nppos.xyz/=ppos.w;\nppos.xy=ppos.xy*0.5+0.5;\nvec2 velocity=(ppos.xy-vUV)*motionScale*motionStrength;\nfloat speed=length(velocity/texelSize);\nint nSamples=int(clamp(speed,1.0,MAX_MOTION_SAMPLES));\nvec4 result=texture2D(textureSampler,vUV);\nfor (int i=1; i<int(MAX_MOTION_SAMPLES); ++i) {\nif (i>=nSamples)\nbreak;\nvec2 offset1=vUV+velocity*(float(i)/float(nSamples-1)-0.5);\nresult+=texture2D(textureSampler,offset1);\n}\ngl_FragColor=result/float(nSamples);\n}\n#endif\n";St.a.ShadersStore.standardPixelShader=hc;var dc=function(e){function t(t,i,r,n,o){void 0===n&&(n=null);var s=e.call(this,i.getEngine(),t)||this;return s.downSampleX4PostProcess=null,s.brightPassPostProcess=null,s.blurHPostProcesses=[],s.blurVPostProcesses=[],s.textureAdderPostProcess=null,s.volumetricLightPostProcess=null,s.volumetricLightSmoothXPostProcess=null,s.volumetricLightSmoothYPostProcess=null,s.volumetricLightMergePostProces=null,s.volumetricLightFinalPostProcess=null,s.luminancePostProcess=null,s.luminanceDownSamplePostProcesses=[],s.hdrPostProcess=null,s.textureAdderFinalPostProcess=null,s.lensFlareFinalPostProcess=null,s.hdrFinalPostProcess=null,s.lensFlarePostProcess=null,s.lensFlareComposePostProcess=null,s.motionBlurPostProcess=null,s.depthOfFieldPostProcess=null,s.fxaaPostProcess=null,s.brightThreshold=1,s.blurWidth=512,s.horizontalBlur=!1,s.exposure=1,s.lensTexture=null,s.volumetricLightCoefficient=.2,s.volumetricLightPower=4,s.volumetricLightBlurScale=64,s.sourceLight=null,s.hdrMinimumLuminance=1,s.hdrDecreaseRate=.5,s.hdrIncreaseRate=.5,s.lensColorTexture=null,s.lensFlareStrength=20,s.lensFlareGhostDispersal=1.4,s.lensFlareHaloWidth=.7,s.lensFlareDistortionStrength=16,s.lensStarTexture=null,s.lensFlareDirtTexture=null,s.depthOfFieldDistance=10,s.depthOfFieldBlurWidth=64,s.motionStrength=1,s.animations=[],s._currentDepthOfFieldSource=null,s._hdrCurrentLuminance=1,s._bloomEnabled=!1,s._depthOfFieldEnabled=!1,s._vlsEnabled=!1,s._lensFlareEnabled=!1,s._hdrEnabled=!1,s._motionBlurEnabled=!1,s._fxaaEnabled=!1,s._motionBlurSamples=64,s._volumetricLightStepsCount=50,s._samples=1,s._cameras=o||[],s._scene=i,s._basePostProcess=n,s._ratio=r,s._floatTextureType=i.getEngine().getCaps().textureFloatRender?_.a.TEXTURETYPE_FLOAT:_.a.TEXTURETYPE_HALF_FLOAT,i.postProcessRenderPipelineManager.addPipeline(s),s._buildPipeline(),s}return l.d(t,e),Object.defineProperty(t.prototype,"BloomEnabled",{get:function(){return this._bloomEnabled},set:function(e){this._bloomEnabled!==e&&(this._bloomEnabled=e,this._buildPipeline())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"DepthOfFieldEnabled",{get:function(){return this._depthOfFieldEnabled},set:function(e){this._depthOfFieldEnabled!==e&&(this._depthOfFieldEnabled=e,this._buildPipeline())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"LensFlareEnabled",{get:function(){return this._lensFlareEnabled},set:function(e){this._lensFlareEnabled!==e&&(this._lensFlareEnabled=e,this._buildPipeline())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"HDREnabled",{get:function(){return this._hdrEnabled},set:function(e){this._hdrEnabled!==e&&(this._hdrEnabled=e,this._buildPipeline())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"VLSEnabled",{get:function(){return this._vlsEnabled},set:function(e){if(this._vlsEnabled!==e){if(e)if(!this._scene.enableGeometryBufferRenderer())return void p.a.Warn("Geometry renderer is not supported, cannot create volumetric lights in Standard Rendering Pipeline");this._vlsEnabled=e,this._buildPipeline()}},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"MotionBlurEnabled",{get:function(){return this._motionBlurEnabled},set:function(e){this._motionBlurEnabled!==e&&(this._motionBlurEnabled=e,this._buildPipeline())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"fxaaEnabled",{get:function(){return this._fxaaEnabled},set:function(e){this._fxaaEnabled!==e&&(this._fxaaEnabled=e,this._buildPipeline())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"volumetricLightStepsCount",{get:function(){return this._volumetricLightStepsCount},set:function(e){this.volumetricLightPostProcess&&this.volumetricLightPostProcess.updateEffect("#define VLS\n#define NB_STEPS "+e.toFixed(1)),this._volumetricLightStepsCount=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"motionBlurSamples",{get:function(){return this._motionBlurSamples},set:function(e){this.motionBlurPostProcess&&this.motionBlurPostProcess.updateEffect("#define MOTION_BLUR\n#define MAX_MOTION_SAMPLES "+e.toFixed(1)),this._motionBlurSamples=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"samples",{get:function(){return this._samples},set:function(e){this._samples!==e&&(this._samples=e,this._buildPipeline())},enumerable:!0,configurable:!0}),t.prototype._buildPipeline=function(){var e=this,t=this._ratio,i=this._scene;this._disposePostProcesses(),this._reset(),this._basePostProcess?this.originalPostProcess=this._basePostProcess:(this.originalPostProcess=new Mt("HDRPass","standard",[],[],t,null,_.a.TEXTURE_BILINEAR_SAMPLINGMODE,i.getEngine(),!1,"#define PASS_POST_PROCESS",this._floatTextureType),this.originalPostProcess.onApply=function(){e._currentDepthOfFieldSource=e.originalPostProcess}),(this._bloomEnabled||this._vlsEnabled||this._lensFlareEnabled||this._depthOfFieldEnabled||this._motionBlurEnabled)&&this.addEffect(new _a(i.getEngine(),"HDRPassPostProcess",function(){return e.originalPostProcess},!0)),this._currentDepthOfFieldSource=this.originalPostProcess,this._bloomEnabled&&(this._createDownSampleX4PostProcess(i,t/2),this._createBrightPassPostProcess(i,t/2),this._createBlurPostProcesses(i,t/4,1),this._createTextureAdderPostProcess(i,t),this.textureAdderFinalPostProcess=new Mt("HDRDepthOfFieldSource","standard",[],[],t,null,Ve.a.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,"#define PASS_POST_PROCESS",_.a.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new _a(i.getEngine(),"HDRBaseDepthOfFieldSource",function(){return e.textureAdderFinalPostProcess},!0))),this._vlsEnabled&&(this._createVolumetricLightPostProcess(i,t),this.volumetricLightFinalPostProcess=new Mt("HDRVLSFinal","standard",[],[],t,null,Ve.a.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,"#define PASS_POST_PROCESS",_.a.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new _a(i.getEngine(),"HDRVLSFinal",function(){return e.volumetricLightFinalPostProcess},!0))),this._lensFlareEnabled&&(this._createLensFlarePostProcess(i,t),this.lensFlareFinalPostProcess=new Mt("HDRPostLensFlareDepthOfFieldSource","standard",[],[],t,null,Ve.a.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,"#define PASS_POST_PROCESS",_.a.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new _a(i.getEngine(),"HDRPostLensFlareDepthOfFieldSource",function(){return e.lensFlareFinalPostProcess},!0))),this._hdrEnabled&&(this._createLuminancePostProcesses(i,this._floatTextureType),this._createHdrPostProcess(i,t),this.hdrFinalPostProcess=new Mt("HDRPostHDReDepthOfFieldSource","standard",[],[],t,null,Ve.a.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,"#define PASS_POST_PROCESS",_.a.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new _a(i.getEngine(),"HDRPostHDReDepthOfFieldSource",function(){return e.hdrFinalPostProcess},!0))),this._depthOfFieldEnabled&&(this._createBlurPostProcesses(i,t/2,3,"depthOfFieldBlurWidth"),this._createDepthOfFieldPostProcess(i,t)),this._motionBlurEnabled&&this._createMotionBlurPostProcess(i,t),this._fxaaEnabled&&(this.fxaaPostProcess=new ka("fxaa",1,null,Ve.a.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,_.a.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new _a(i.getEngine(),"HDRFxaa",function(){return e.fxaaPostProcess},!0))),null!==this._cameras&&this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name,this._cameras),!this._enableMSAAOnFirstPostProcess(this._samples)&&this._samples>1&&p.a.Warn("MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0")},t.prototype._createDownSampleX4PostProcess=function(e,t){var i=this,r=new Array(32);this.downSampleX4PostProcess=new Mt("HDRDownSampleX4","standard",["dsOffsets"],[],t,null,Ve.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define DOWN_SAMPLE_X4",_.a.TEXTURETYPE_UNSIGNED_INT),this.downSampleX4PostProcess.onApply=function(e){for(var t=0,n=i.downSampleX4PostProcess.width,o=i.downSampleX4PostProcess.height,s=-2;s<2;s++)for(var a=-2;a<2;a++)r[t]=(s+.5)*(1/n),r[t+1]=(a+.5)*(1/o),t+=2;e.setArray2("dsOffsets",r)},this.addEffect(new _a(e.getEngine(),"HDRDownSampleX4",function(){return i.downSampleX4PostProcess},!0))},t.prototype._createBrightPassPostProcess=function(e,t){var i=this,r=new Array(8);this.brightPassPostProcess=new Mt("HDRBrightPass","standard",["dsOffsets","brightThreshold"],[],t,null,Ve.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define BRIGHT_PASS",_.a.TEXTURETYPE_UNSIGNED_INT),this.brightPassPostProcess.onApply=function(e){var t=1/i.brightPassPostProcess.width,n=1/i.brightPassPostProcess.height;r[0]=-.5*t,r[1]=.5*n,r[2]=.5*t,r[3]=.5*n,r[4]=-.5*t,r[5]=-.5*n,r[6]=.5*t,r[7]=-.5*n,e.setArray2("dsOffsets",r),e.setFloat("brightThreshold",i.brightThreshold)},this.addEffect(new _a(e.getEngine(),"HDRBrightPass",function(){return i.brightPassPostProcess},!0))},t.prototype._createBlurPostProcesses=function(e,t,i,r){var n=this;void 0===r&&(r="blurWidth");var s=e.getEngine(),a=new Ur("HDRBlurH_"+i,new o.w(1,0),this[r],t,null,Ve.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,_.a.TEXTURETYPE_UNSIGNED_INT),c=new Ur("HDRBlurV_"+i,new o.w(0,1),this[r],t,null,Ve.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,_.a.TEXTURETYPE_UNSIGNED_INT);a.onActivateObservable.add(function(){var e=a.width/s.getRenderWidth();a.kernel=n[r]*e}),c.onActivateObservable.add(function(){var e=c.height/s.getRenderHeight();c.kernel=n.horizontalBlur?64*e:n[r]*e}),this.addEffect(new _a(e.getEngine(),"HDRBlurH"+i,function(){return a},!0)),this.addEffect(new _a(e.getEngine(),"HDRBlurV"+i,function(){return c},!0)),this.blurHPostProcesses.push(a),this.blurVPostProcesses.push(c)},t.prototype._createTextureAdderPostProcess=function(e,t){var i=this;this.textureAdderPostProcess=new Mt("HDRTextureAdder","standard",["exposure"],["otherSampler","lensSampler"],t,null,Ve.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define TEXTURE_ADDER",_.a.TEXTURETYPE_UNSIGNED_INT),this.textureAdderPostProcess.onApply=function(e){e.setTextureFromPostProcess("otherSampler",i._vlsEnabled?i._currentDepthOfFieldSource:i.originalPostProcess),e.setTexture("lensSampler",i.lensTexture),e.setFloat("exposure",i.exposure),i._currentDepthOfFieldSource=i.textureAdderFinalPostProcess},this.addEffect(new _a(e.getEngine(),"HDRTextureAdder",function(){return i.textureAdderPostProcess},!0))},t.prototype._createVolumetricLightPostProcess=function(e,t){var i=this,r=e.enableGeometryBufferRenderer();r.enablePosition=!0;var n=r.getGBuffer();this.volumetricLightPostProcess=new Mt("HDRVLS","standard",["shadowViewProjection","cameraPosition","sunDirection","sunColor","scatteringCoefficient","scatteringPower","depthValues"],["shadowMapSampler","positionSampler"],t/8,null,Ve.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define VLS\n#define NB_STEPS "+this._volumetricLightStepsCount.toFixed(1));var s=o.w.Zero();this.volumetricLightPostProcess.onApply=function(e){if(i.sourceLight&&i.sourceLight.getShadowGenerator()&&i._scene.activeCamera){var t=i.sourceLight.getShadowGenerator();e.setTexture("shadowMapSampler",t.getShadowMap()),e.setTexture("positionSampler",n.textures[2]),e.setColor3("sunColor",i.sourceLight.diffuse),e.setVector3("sunDirection",i.sourceLight.getShadowDirection()),e.setVector3("cameraPosition",i._scene.activeCamera.globalPosition),e.setMatrix("shadowViewProjection",t.getTransformMatrix()),e.setFloat("scatteringCoefficient",i.volumetricLightCoefficient),e.setFloat("scatteringPower",i.volumetricLightPower),s.x=i.sourceLight.getDepthMinZ(i._scene.activeCamera),s.y=i.sourceLight.getDepthMaxZ(i._scene.activeCamera),e.setVector2("depthValues",s)}},this.addEffect(new _a(e.getEngine(),"HDRVLS",function(){return i.volumetricLightPostProcess},!0)),this._createBlurPostProcesses(e,t/4,0,"volumetricLightBlurScale"),this.volumetricLightMergePostProces=new Mt("HDRVLSMerge","standard",[],["originalSampler"],t,null,Ve.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define VLSMERGE"),this.volumetricLightMergePostProces.onApply=function(e){e.setTextureFromPostProcess("originalSampler",i._bloomEnabled?i.textureAdderFinalPostProcess:i.originalPostProcess),i._currentDepthOfFieldSource=i.volumetricLightFinalPostProcess},this.addEffect(new _a(e.getEngine(),"HDRVLSMerge",function(){return i.volumetricLightMergePostProces},!0))},t.prototype._createLuminancePostProcesses=function(e,i){var r=this,n=Math.pow(3,t.LuminanceSteps);this.luminancePostProcess=new Mt("HDRLuminance","standard",["lumOffsets"],[],{width:n,height:n},null,Ve.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define LUMINANCE",i);var s=[];this.luminancePostProcess.onApply=function(e){var t=1/r.luminancePostProcess.width,i=1/r.luminancePostProcess.height;s[0]=-.5*t,s[1]=.5*i,s[2]=.5*t,s[3]=.5*i,s[4]=-.5*t,s[5]=-.5*i,s[6]=.5*t,s[7]=-.5*i,e.setArray2("lumOffsets",s)},this.addEffect(new _a(e.getEngine(),"HDRLuminance",function(){return r.luminancePostProcess},!0));for(var a=t.LuminanceSteps-1;a>=0;a--){n=Math.pow(3,a);var c="#define LUMINANCE_DOWN_SAMPLE\n";0===a&&(c+="#define FINAL_DOWN_SAMPLER");var l=new Mt("HDRLuminanceDownSample"+a,"standard",["dsOffsets","halfDestPixelSize"],[],{width:n,height:n},null,Ve.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,c,i);this.luminanceDownSamplePostProcesses.push(l)}var u=this.luminancePostProcess;this.luminanceDownSamplePostProcesses.forEach(function(t,i){var n=new Array(18);t.onApply=function(e){if(u){for(var o=0,s=-1;s<2;s++)for(var a=-1;a<2;a++)n[o]=s/u.width,n[o+1]=a/u.height,o+=2;e.setArray2("dsOffsets",n),e.setFloat("halfDestPixelSize",.5/u.width),u=i===r.luminanceDownSamplePostProcesses.length-1?r.luminancePostProcess:t}},i===r.luminanceDownSamplePostProcesses.length-1&&(t.onAfterRender=function(){var t=e.getEngine().readPixels(0,0,1,1),i=new o.y(1/16581375,1/65025,1/255,1);r._hdrCurrentLuminance=(t[0]*i.x+t[1]*i.y+t[2]*i.z+t[3]*i.w)/100}),r.addEffect(new _a(e.getEngine(),"HDRLuminanceDownSample"+i,function(){return t},!0))})},t.prototype._createHdrPostProcess=function(e,t){var i=this;this.hdrPostProcess=new Mt("HDR","standard",["averageLuminance"],["textureAdderSampler"],t,null,Ve.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define HDR",_.a.TEXTURETYPE_UNSIGNED_INT);var r=1,n=0,o=0;this.hdrPostProcess.onApply=function(t){if(t.setTextureFromPostProcess("textureAdderSampler",i._currentDepthOfFieldSource),n+=e.getEngine().getDeltaTime(),r<0)r=i._hdrCurrentLuminance;else{var s=(o-n)/1e3;i._hdrCurrentLuminance<r+i.hdrDecreaseRate*s?r+=i.hdrDecreaseRate*s:i._hdrCurrentLuminance>r-i.hdrIncreaseRate*s?r-=i.hdrIncreaseRate*s:r=i._hdrCurrentLuminance}r=D.a.Clamp(r,i.hdrMinimumLuminance,1e20),t.setFloat("averageLuminance",r),o=n,i._currentDepthOfFieldSource=i.hdrFinalPostProcess},this.addEffect(new _a(e.getEngine(),"HDR",function(){return i.hdrPostProcess},!0))},t.prototype._createLensFlarePostProcess=function(e,t){var i=this;this.lensFlarePostProcess=new Mt("HDRLensFlare","standard",["strength","ghostDispersal","haloWidth","resolution","distortionStrength"],["lensColorSampler"],t/2,null,Ve.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define LENS_FLARE",_.a.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new _a(e.getEngine(),"HDRLensFlare",function(){return i.lensFlarePostProcess},!0)),this._createBlurPostProcesses(e,t/4,2),this.lensFlareComposePostProcess=new Mt("HDRLensFlareCompose","standard",["lensStarMatrix"],["otherSampler","lensDirtSampler","lensStarSampler"],t,null,Ve.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define LENS_FLARE_COMPOSE",_.a.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new _a(e.getEngine(),"HDRLensFlareCompose",function(){return i.lensFlareComposePostProcess},!0));var r=new o.w(0,0);this.lensFlarePostProcess.onApply=function(e){e.setTextureFromPostProcess("textureSampler",i._bloomEnabled?i.blurHPostProcesses[0]:i.originalPostProcess),e.setTexture("lensColorSampler",i.lensColorTexture),e.setFloat("strength",i.lensFlareStrength),e.setFloat("ghostDispersal",i.lensFlareGhostDispersal),e.setFloat("haloWidth",i.lensFlareHaloWidth),r.x=i.lensFlarePostProcess.width,r.y=i.lensFlarePostProcess.height,e.setVector2("resolution",r),e.setFloat("distortionStrength",i.lensFlareDistortionStrength)};var n=o.j.FromValues(2,0,-1,0,0,2,-1,0,0,0,1,0,0,0,0,1),s=o.j.FromValues(.5,0,.5,0,0,.5,.5,0,0,0,1,0,0,0,0,1);this.lensFlareComposePostProcess.onApply=function(e){if(i._scene.activeCamera){e.setTextureFromPostProcess("otherSampler",i._currentDepthOfFieldSource),e.setTexture("lensDirtSampler",i.lensFlareDirtTexture),e.setTexture("lensStarSampler",i.lensStarTexture);var t=i._scene.activeCamera.getViewMatrix().getRow(0),r=i._scene.activeCamera.getViewMatrix().getRow(2),a=o.x.Dot(t.toVector3(),new o.x(1,0,0))+o.x.Dot(r.toVector3(),new o.x(0,0,1));a*=4;var c=o.j.FromValues(.5*Math.cos(a),-Math.sin(a),0,0,Math.sin(a),.5*Math.cos(a),0,0,0,0,1,0,0,0,0,1),l=s.multiply(c).multiply(n);e.setMatrix("lensStarMatrix",l),i._currentDepthOfFieldSource=i.lensFlareFinalPostProcess}}},t.prototype._createDepthOfFieldPostProcess=function(e,t){var i=this;this.depthOfFieldPostProcess=new Mt("HDRDepthOfField","standard",["distance"],["otherSampler","depthSampler"],t,null,Ve.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define DEPTH_OF_FIELD",_.a.TEXTURETYPE_UNSIGNED_INT),this.depthOfFieldPostProcess.onApply=function(e){e.setTextureFromPostProcess("otherSampler",i._currentDepthOfFieldSource),e.setTexture("depthSampler",i._getDepthTexture()),e.setFloat("distance",i.depthOfFieldDistance)},this.addEffect(new _a(e.getEngine(),"HDRDepthOfField",function(){return i.depthOfFieldPostProcess},!0))},t.prototype._createMotionBlurPostProcess=function(e,t){var i=this;this.motionBlurPostProcess=new Mt("HDRMotionBlur","standard",["inverseViewProjection","prevViewProjection","screenSize","motionScale","motionStrength"],["depthSampler"],t,null,Ve.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define MOTION_BLUR\n#define MAX_MOTION_SAMPLES "+this.motionBlurSamples.toFixed(1),_.a.TEXTURETYPE_UNSIGNED_INT);var r=0,n=o.j.Identity(),s=o.j.Identity(),a=o.j.Identity(),c=o.w.Zero();this.motionBlurPostProcess.onApply=function(t){(a=e.getProjectionMatrix().multiply(e.getViewMatrix())).invertToRef(s),t.setMatrix("inverseViewProjection",s),t.setMatrix("prevViewProjection",n),n=a,c.x=i.motionBlurPostProcess.width,c.y=i.motionBlurPostProcess.height,t.setVector2("screenSize",c),r=e.getEngine().getFps()/60,t.setFloat("motionScale",r),t.setFloat("motionStrength",i.motionStrength),t.setTexture("depthSampler",i._getDepthTexture())},this.addEffect(new _a(e.getEngine(),"HDRMotionBlur",function(){return i.motionBlurPostProcess},!0))},t.prototype._getDepthTexture=function(){return this._scene.getEngine().getCaps().drawBuffersExtension?this._scene.enableGeometryBufferRenderer().getGBuffer().textures[0]:this._scene.enableDepthRenderer().getDepthMap()},t.prototype._disposePostProcesses=function(){for(var e=0;e<this._cameras.length;e++){var t=this._cameras[e];this.originalPostProcess&&this.originalPostProcess.dispose(t),this.downSampleX4PostProcess&&this.downSampleX4PostProcess.dispose(t),this.brightPassPostProcess&&this.brightPassPostProcess.dispose(t),this.textureAdderPostProcess&&this.textureAdderPostProcess.dispose(t),this.textureAdderFinalPostProcess&&this.textureAdderFinalPostProcess.dispose(t),this.volumetricLightPostProcess&&this.volumetricLightPostProcess.dispose(t),this.volumetricLightSmoothXPostProcess&&this.volumetricLightSmoothXPostProcess.dispose(t),this.volumetricLightSmoothYPostProcess&&this.volumetricLightSmoothYPostProcess.dispose(t),this.volumetricLightMergePostProces&&this.volumetricLightMergePostProces.dispose(t),this.volumetricLightFinalPostProcess&&this.volumetricLightFinalPostProcess.dispose(t),this.lensFlarePostProcess&&this.lensFlarePostProcess.dispose(t),this.lensFlareComposePostProcess&&this.lensFlareComposePostProcess.dispose(t);for(var i=0;i<this.luminanceDownSamplePostProcesses.length;i++)this.luminanceDownSamplePostProcesses[i].dispose(t);this.luminancePostProcess&&this.luminancePostProcess.dispose(t),this.hdrPostProcess&&this.hdrPostProcess.dispose(t),this.hdrFinalPostProcess&&this.hdrFinalPostProcess.dispose(t),this.depthOfFieldPostProcess&&this.depthOfFieldPostProcess.dispose(t),this.motionBlurPostProcess&&this.motionBlurPostProcess.dispose(t),this.fxaaPostProcess&&this.fxaaPostProcess.dispose(t);for(i=0;i<this.blurHPostProcesses.length;i++)this.blurHPostProcesses[i].dispose(t);for(i=0;i<this.blurVPostProcesses.length;i++)this.blurVPostProcesses[i].dispose(t)}this.originalPostProcess=null,this.downSampleX4PostProcess=null,this.brightPassPostProcess=null,this.textureAdderPostProcess=null,this.textureAdderFinalPostProcess=null,this.volumetricLightPostProcess=null,this.volumetricLightSmoothXPostProcess=null,this.volumetricLightSmoothYPostProcess=null,this.volumetricLightMergePostProces=null,this.volumetricLightFinalPostProcess=null,this.lensFlarePostProcess=null,this.lensFlareComposePostProcess=null,this.luminancePostProcess=null,this.hdrPostProcess=null,this.hdrFinalPostProcess=null,this.depthOfFieldPostProcess=null,this.motionBlurPostProcess=null,this.fxaaPostProcess=null,this.luminanceDownSamplePostProcesses=[],this.blurHPostProcesses=[],this.blurVPostProcesses=[]},t.prototype.dispose=function(){this._disposePostProcesses(),this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name,this._cameras),e.prototype.dispose.call(this)},t.prototype.serialize=function(){var e=w.a.Serialize(this);return this.sourceLight&&(e.sourceLightId=this.sourceLight.id),e.customType="StandardRenderingPipeline",e},t.Parse=function(e,i,r){var n=w.a.Parse(function(){return new t(e._name,i,e._ratio)},e,i,r);return e.sourceLightId&&(n.sourceLight=i.getLightByID(e.sourceLightId)),n},t.LuminanceSteps=6,l.c([Object(w.c)()],t.prototype,"brightThreshold",void 0),l.c([Object(w.c)()],t.prototype,"blurWidth",void 0),l.c([Object(w.c)()],t.prototype,"horizontalBlur",void 0),l.c([Object(w.c)()],t.prototype,"exposure",void 0),l.c([Object(w.l)("lensTexture")],t.prototype,"lensTexture",void 0),l.c([Object(w.c)()],t.prototype,"volumetricLightCoefficient",void 0),l.c([Object(w.c)()],t.prototype,"volumetricLightPower",void 0),l.c([Object(w.c)()],t.prototype,"volumetricLightBlurScale",void 0),l.c([Object(w.c)()],t.prototype,"hdrMinimumLuminance",void 0),l.c([Object(w.c)()],t.prototype,"hdrDecreaseRate",void 0),l.c([Object(w.c)()],t.prototype,"hdrIncreaseRate",void 0),l.c([Object(w.l)("lensColorTexture")],t.prototype,"lensColorTexture",void 0),l.c([Object(w.c)()],t.prototype,"lensFlareStrength",void 0),l.c([Object(w.c)()],t.prototype,"lensFlareGhostDispersal",void 0),l.c([Object(w.c)()],t.prototype,"lensFlareHaloWidth",void 0),l.c([Object(w.c)()],t.prototype,"lensFlareDistortionStrength",void 0),l.c([Object(w.l)("lensStarTexture")],t.prototype,"lensStarTexture",void 0),l.c([Object(w.l)("lensFlareDirtTexture")],t.prototype,"lensFlareDirtTexture",void 0),l.c([Object(w.c)()],t.prototype,"depthOfFieldDistance",void 0),l.c([Object(w.c)()],t.prototype,"depthOfFieldBlurWidth",void 0),l.c([Object(w.c)()],t.prototype,"motionStrength",void 0),l.c([Object(w.c)()],t.prototype,"_ratio",void 0),l.c([Object(w.c)()],t.prototype,"BloomEnabled",null),l.c([Object(w.c)()],t.prototype,"DepthOfFieldEnabled",null),l.c([Object(w.c)()],t.prototype,"LensFlareEnabled",null),l.c([Object(w.c)()],t.prototype,"HDREnabled",null),l.c([Object(w.c)()],t.prototype,"VLSEnabled",null),l.c([Object(w.c)()],t.prototype,"MotionBlurEnabled",null),l.c([Object(w.c)()],t.prototype,"fxaaEnabled",null),l.c([Object(w.c)()],t.prototype,"volumetricLightStepsCount",null),l.c([Object(w.c)()],t.prototype,"motionBlurSamples",null),l.c([Object(w.c)()],t.prototype,"samples",null),t}(tc);s.a.RegisteredTypes["BABYLON.StandardRenderingPipeline"]=dc;var fc=function(){function e(){this._renderPipelines={}}return e.prototype.addPipeline=function(e){this._renderPipelines[e._name]=e},e.prototype.attachCamerasToRenderPipeline=function(e,t,i){void 0===i&&(i=!1);var r=this._renderPipelines[e];r&&r._attachCameras(t,i)},e.prototype.detachCamerasFromRenderPipeline=function(e,t){var i=this._renderPipelines[e];i&&i._detachCameras(t)},e.prototype.enableEffectInPipeline=function(e,t,i){var r=this._renderPipelines[e];r&&r._enableEffect(t,i)},e.prototype.disableEffectInPipeline=function(e,t,i){var r=this._renderPipelines[e];r&&r._disableEffect(t,i)},e.prototype.update=function(){for(var e in this._renderPipelines)if(this._renderPipelines.hasOwnProperty(e)){var t=this._renderPipelines[e];t.isSupported?t._update():(t.dispose(),delete this._renderPipelines[e])}},e.prototype._rebuild=function(){for(var e in this._renderPipelines){if(this._renderPipelines.hasOwnProperty(e))this._renderPipelines[e]._rebuild()}},e.prototype.dispose=function(){for(var e in this._renderPipelines){if(this._renderPipelines.hasOwnProperty(e))this._renderPipelines[e].dispose()}},e}();Object.defineProperty(W.a.prototype,"postProcessRenderPipelineManager",{get:function(){if(!this._postProcessRenderPipelineManager){var e=this._getComponent(Te.a.NAME_POSTPROCESSRENDERPIPELINEMANAGER);e||(e=new pc(this),this._addComponent(e)),this._postProcessRenderPipelineManager=new fc}return this._postProcessRenderPipelineManager},enumerable:!0,configurable:!0});var pc=function(){function e(e){this.name=Te.a.NAME_POSTPROCESSRENDERPIPELINEMANAGER,this.scene=e}return e.prototype.register=function(){this.scene._gatherRenderTargetsStage.registerStep(Te.a.STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER,this,this._gatherRenderTargets)},e.prototype.rebuild=function(){this.scene._postProcessRenderPipelineManager&&this.scene._postProcessRenderPipelineManager._rebuild()},e.prototype.dispose=function(){this.scene._postProcessRenderPipelineManager&&this.scene._postProcessRenderPipelineManager.dispose()},e.prototype._gatherRenderTargets=function(){this.scene._postProcessRenderPipelineManager&&this.scene._postProcessRenderPipelineManager.update()},e}(),_c="\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n\nuniform float _ExposureAdjustment;\n#if defined(HABLE_TONEMAPPING)\nconst float A=0.15;\nconst float B=0.50;\nconst float C=0.10;\nconst float D=0.20;\nconst float E=0.02;\nconst float F=0.30;\nconst float W=11.2;\n#endif\nfloat Luminance(vec3 c)\n{\nreturn dot(c,vec3(0.22,0.707,0.071));\n}\nvoid main(void)\n{\nvec3 colour=texture2D(textureSampler,vUV).rgb;\n#if defined(REINHARD_TONEMAPPING)\nfloat lum=Luminance(colour.rgb);\nfloat lumTm=lum*_ExposureAdjustment;\nfloat scale=lumTm/(1.0+lumTm);\ncolour*=scale/lum;\n#elif defined(HABLE_TONEMAPPING)\ncolour*=_ExposureAdjustment;\nconst float ExposureBias=2.0;\nvec3 x=ExposureBias*colour;\nvec3 curr=((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;\nx=vec3(W,W,W);\nvec3 whiteScale=1.0/(((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F);\ncolour=curr*whiteScale;\n#elif defined(OPTIMIZED_HEJIDAWSON_TONEMAPPING)\ncolour*=_ExposureAdjustment;\nvec3 X=max(vec3(0.0,0.0,0.0),colour-0.004);\nvec3 retColor=(X*(6.2*X+0.5))/(X*(6.2*X+1.7)+0.06);\ncolour=retColor*retColor;\n#elif defined(PHOTOGRAPHIC_TONEMAPPING)\ncolour=vec3(1.0,1.0,1.0)-exp2(-_ExposureAdjustment*colour);\n#endif\ngl_FragColor=vec4(colour.rgb,1.0);\n}";St.a.ShadersStore.tonemapPixelShader=_c;var gc;!function(e){e[e.Hable=0]="Hable",e[e.Reinhard=1]="Reinhard",e[e.HejiDawson=2]="HejiDawson",e[e.Photographic=3]="Photographic"}(gc||(gc={}));var mc=function(e){function t(t,i,r,n,o,s,a){void 0===o&&(o=_.a.TEXTURE_BILINEAR_SAMPLINGMODE),void 0===a&&(a=_.a.TEXTURETYPE_UNSIGNED_INT);var c=e.call(this,t,"tonemap",["_ExposureAdjustment"],null,1,n,o,s,!0,null,a)||this;c._operator=i,c.exposureAdjustment=r;var l="#define ";return c._operator===gc.Hable?l+="HABLE_TONEMAPPING":c._operator===gc.Reinhard?l+="REINHARD_TONEMAPPING":c._operator===gc.HejiDawson?l+="OPTIMIZED_HEJIDAWSON_TONEMAPPING":c._operator===gc.Photographic&&(l+="PHOTOGRAPHIC_TONEMAPPING"),c.updateEffect(l),c.onApply=function(e){e.setFloat("_ExposureAdjustment",c.exposureAdjustment)},c}return l.d(t,e),t}(Mt),vc="\nattribute vec3 position;\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\nuniform mat4 viewProjection;\nuniform vec2 depthValues;\n#if defined(ALPHATEST) || defined(NEED_UV)\nvarying vec2 vUV;\nuniform mat4 diffuseMatrix;\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#endif\nvarying float vDepthMetric;\nvoid main(void)\n{\n#include<instancesVertex>\n#include<bonesVertex>\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\nvDepthMetric=((gl_Position.z+depthValues.x)/(depthValues.y));\n#if defined(ALPHATEST) || defined(BASIC_RENDER)\n#ifdef UV1\nvUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n#endif\n#ifdef UV2\nvUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n}";St.a.ShadersStore.depthVertexShader=vc;var yc="uniform sampler2D textureSampler;\nuniform sampler2D lightScatteringSampler;\nuniform float decay;\nuniform float exposure;\nuniform float weight;\nuniform float density;\nuniform vec2 meshPositionOnScreen;\nvarying vec2 vUV;\nvoid main(void) {\nvec2 tc=vUV;\nvec2 deltaTexCoord=(tc-meshPositionOnScreen.xy);\ndeltaTexCoord*=1.0/float(NUM_SAMPLES)*density;\nfloat illuminationDecay=1.0;\nvec4 color=texture2D(lightScatteringSampler,tc)*0.4;\nfor(int i=0; i<NUM_SAMPLES; i++) {\ntc-=deltaTexCoord;\nvec4 dataSample=texture2D(lightScatteringSampler,tc)*0.4;\ndataSample*=illuminationDecay*weight;\ncolor+=dataSample;\nilluminationDecay*=decay;\n}\nvec4 realColor=texture2D(textureSampler,vUV);\ngl_FragColor=((vec4((vec3(color.r,color.g,color.b)*exposure),1))+(realColor*(1.5-0.4)));\n}\n";St.a.ShadersStore.volumetricLightScatteringPixelShader=yc;var bc="#if defined(ALPHATEST) || defined(NEED_UV)\nvarying vec2 vUV;\n#endif\n#if defined(ALPHATEST)\nuniform sampler2D diffuseSampler;\n#endif\nvoid main(void)\n{\n#if defined(ALPHATEST)\nvec4 diffuseColor=texture2D(diffuseSampler,vUV);\nif (diffuseColor.a<0.4)\ndiscard;\n#endif\ngl_FragColor=vec4(0.0,0.0,0.0,1.0);\n}\n";St.a.ShadersStore.volumetricLightScatteringPassPixelShader=bc;var Tc=function(e){function t(i,r,n,s,a,c,l,u,h){void 0===a&&(a=100),void 0===c&&(c=Ve.a.BILINEAR_SAMPLINGMODE);var d=e.call(this,i,"volumetricLightScattering",["decay","exposure","weight","meshPositionOnScreen","density"],["lightScatteringSampler"],r.postProcessRatio||r,n,c,l,u,"#define NUM_SAMPLES "+a)||this;return d._screenCoordinates=o.w.Zero(),d.customMeshPosition=o.x.Zero(),d.useCustomMeshPosition=!1,d.invert=!0,d.excludedMeshes=new Array,d.exposure=.3,d.decay=.96815,d.weight=.58767,d.density=.926,l=(h=null===n?h:n.getScene()).getEngine(),d._viewPort=new o.z(0,0,1,1).toGlobal(l.getRenderWidth(),l.getRenderHeight()),d.mesh=null!==s?s:t.CreateDefaultMesh("VolumetricLightScatteringMesh",h),d._createPass(h,r.passRatio||r),d.onActivate=function(e){d.isSupported||d.dispose(e),d.onActivate=null},d.onApplyObservable.add(function(e){d._updateMeshScreenCoordinates(h),e.setTexture("lightScatteringSampler",d._volumetricLightScatteringRTT),e.setFloat("exposure",d.exposure),e.setFloat("decay",d.decay),e.setFloat("weight",d.weight),e.setFloat("density",d.density),e.setVector2("meshPositionOnScreen",d._screenCoordinates)}),d}return l.d(t,e),Object.defineProperty(t.prototype,"useDiffuseColor",{get:function(){return p.a.Warn("VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead"),!1},set:function(e){p.a.Warn("VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead")},enumerable:!0,configurable:!0}),t.prototype.getClassName=function(){return"VolumetricLightScatteringPostProcess"},t.prototype._isReady=function(e,t){var i=e.getMesh();if(i===this.mesh&&i.material)return i.material.isReady(i);var r=[],n=[gi.b.PositionKind],o=e.getMaterial();o&&(o.needAlphaTesting()&&r.push("#define ALPHATEST"),i.isVerticesDataPresent(gi.b.UVKind)&&(n.push(gi.b.UVKind),r.push("#define UV1")),i.isVerticesDataPresent(gi.b.UV2Kind)&&(n.push(gi.b.UV2Kind),r.push("#define UV2"))),i.useBones&&i.computeBonesUsingShaders?(n.push(gi.b.MatricesIndicesKind),n.push(gi.b.MatricesWeightsKind),r.push("#define NUM_BONE_INFLUENCERS "+i.numBoneInfluencers),r.push("#define BonesPerMesh "+(i.skeleton?i.skeleton.bones.length+1:0))):r.push("#define NUM_BONE_INFLUENCERS 0"),t&&(r.push("#define INSTANCES"),n.push("world0"),n.push("world1"),n.push("world2"),n.push("world3"));var s=r.join("\n");return this._cachedDefines!==s&&(this._cachedDefines=s,this._volumetricLightScatteringPass=i.getScene().getEngine().createEffect({vertexElement:"depth",fragmentElement:"volumetricLightScatteringPass"},n,["world","mBones","viewProjection","diffuseMatrix"],["diffuseSampler"],s)),this._volumetricLightScatteringPass.isReady()},t.prototype.setCustomMeshPosition=function(e){this.customMeshPosition=e},t.prototype.getCustomMeshPosition=function(){return this.customMeshPosition},t.prototype.dispose=function(t){var i=t.getScene().customRenderTargets.indexOf(this._volumetricLightScatteringRTT);-1!==i&&t.getScene().customRenderTargets.splice(i,1),this._volumetricLightScatteringRTT.dispose(),e.prototype.dispose.call(this,t)},t.prototype.getPass=function(){return this._volumetricLightScatteringRTT},t.prototype._meshExcluded=function(e){return this.excludedMeshes.length>0&&-1!==this.excludedMeshes.indexOf(e)},t.prototype._createPass=function(e,t){var i=this,r=e.getEngine();this._volumetricLightScatteringRTT=new Mi("volumetricLightScatteringMap",{width:r.getRenderWidth()*t,height:r.getRenderHeight()*t},e,!1,!0,_.a.TEXTURETYPE_UNSIGNED_INT),this._volumetricLightScatteringRTT.wrapU=Ve.a.CLAMP_ADDRESSMODE,this._volumetricLightScatteringRTT.wrapV=Ve.a.CLAMP_ADDRESSMODE,this._volumetricLightScatteringRTT.renderList=null,this._volumetricLightScatteringRTT.renderParticles=!1,this._volumetricLightScatteringRTT.ignoreCameraViewport=!0;var n=this.getCamera();n?n.customRenderTargets.push(this._volumetricLightScatteringRTT):e.customRenderTargets.push(this._volumetricLightScatteringRTT);var s,a=function(e){var t=e.getRenderingMesh();if(!i._meshExcluded(t)){var r=e.getMaterial();if(r){var n=t.getScene(),o=n.getEngine();o.setState(r.backFaceCulling);var s=t._getInstancesRenderList(e._id);if(!s.mustReturn){var a=o.getCaps().instancedArrays&&null!==s.visibleInstances[e._id];if(i._isReady(e,a)){var c=i._volumetricLightScatteringPass;if(t===i.mesh&&(c=e.effect?e.effect:r.getEffect()),o.enableEffect(c),t._bind(e,c,yn.a.TriangleFillMode),t===i.mesh)r.bind(t.getWorldMatrix(),t);else{if(i._volumetricLightScatteringPass.setMatrix("viewProjection",n.getTransformMatrix()),r&&r.needAlphaTesting()){var l=r.getAlphaTestTexture();i._volumetricLightScatteringPass.setTexture("diffuseSampler",l),l&&i._volumetricLightScatteringPass.setMatrix("diffuseMatrix",l.getTextureMatrix())}t.useBones&&t.computeBonesUsingShaders&&t.skeleton&&i._volumetricLightScatteringPass.setMatrices("mBones",t.skeleton.getTransformMatrices(t))}t._processRendering(e,i._volumetricLightScatteringPass,yn.a.TriangleFillMode,s,a,function(e,t){return c.setMatrix("world",t)})}}}}},c=new o.f(0,0,0,1);this._volumetricLightScatteringRTT.onBeforeRenderObservable.add(function(){s=e.clearColor,e.clearColor=c}),this._volumetricLightScatteringRTT.onAfterRenderObservable.add(function(){e.clearColor=s}),this._volumetricLightScatteringRTT.customRenderFunction=function(t,i,r,n){var o,s=e.getEngine();if(n.length){for(s.setColorWrite(!1),o=0;o<n.length;o++)a(n.data[o]);s.setColorWrite(!0)}for(o=0;o<t.length;o++)a(t.data[o]);for(o=0;o<i.length;o++)a(i.data[o]);if(r.length){for(o=0;o<r.length;o++){var c=r.data[o],l=c.getBoundingInfo();l&&e.activeCamera&&(c._alphaIndex=c.getMesh().alphaIndex,c._distanceToCamera=l.boundingSphere.centerWorld.subtract(e.activeCamera.position).length())}var u=r.data.slice(0,r.length);for(u.sort(function(e,t){return e._alphaIndex>t._alphaIndex?1:e._alphaIndex<t._alphaIndex?-1:e._distanceToCamera<t._distanceToCamera?1:e._distanceToCamera>t._distanceToCamera?-1:0}),s.setAlphaMode(_.a.ALPHA_COMBINE),o=0;o<u.length;o++)a(u[o]);s.setAlphaMode(_.a.ALPHA_DISABLE)}}},t.prototype._updateMeshScreenCoordinates=function(e){var t,i=e.getTransformMatrix();t=this.useCustomMeshPosition?this.customMeshPosition:this.attachedNode?this.attachedNode.position:this.mesh.parent?this.mesh.getAbsolutePosition():this.mesh.position;var r=o.x.Project(t,o.j.Identity(),i,this._viewPort);this._screenCoordinates.x=r.x/this._viewPort.width,this._screenCoordinates.y=r.y/this._viewPort.height,this.invert&&(this._screenCoordinates.y=1-this._screenCoordinates.y)},t.CreateDefaultMesh=function(e,t){var i=de.a.CreatePlane(e,1,t);i.billboardMode=we.a.BILLBOARDMODE_ALL;var r=new hi.a(e+"Material",t);return r.emissiveColor=new o.e(1,1,1),i.material=r,i},l.c([Object(w.n)()],t.prototype,"customMeshPosition",void 0),l.c([Object(w.c)()],t.prototype,"useCustomMeshPosition",void 0),l.c([Object(w.c)()],t.prototype,"invert",void 0),l.c([Object(w.j)()],t.prototype,"mesh",void 0),l.c([Object(w.c)()],t.prototype,"excludedMeshes",void 0),l.c([Object(w.c)()],t.prototype,"exposure",void 0),l.c([Object(w.c)()],t.prototype,"decay",void 0),l.c([Object(w.c)()],t.prototype,"weight",void 0),l.c([Object(w.c)()],t.prototype,"density",void 0),t}(Mt);i(117),i(118);Object.defineProperty(W.a.prototype,"forceShowBoundingBoxes",{get:function(){return this._forceShowBoundingBoxes||!1},set:function(e){this._forceShowBoundingBoxes=e,e&&this.getBoundingBoxRenderer()},enumerable:!0,configurable:!0}),W.a.prototype.getBoundingBoxRenderer=function(){return this._boundingBoxRenderer||(this._boundingBoxRenderer=new Ec(this)),this._boundingBoxRenderer},Object.defineProperty(we.a.prototype,"showBoundingBox",{get:function(){return this._showBoundingBox||!1},set:function(e){this._showBoundingBox=e,e&&this.getScene().getBoundingBoxRenderer()},enumerable:!0,configurable:!0});var Ec=function(){function e(e){this.name=Te.a.NAME_BOUNDINGBOXRENDERER,this.frontColor=new o.e(1,1,1),this.backColor=new o.e(.1,.1,.1),this.showBackLines=!0,this.renderList=new Rt.a(32),this._vertexBuffers={},this.scene=e,e._addComponent(this)}return e.prototype.register=function(){this.scene._beforeEvaluateActiveMeshStage.registerStep(Te.a.STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER,this,this.reset),this.scene._activeMeshStage.registerStep(Te.a.STEP_ACTIVEMESH_BOUNDINGBOXRENDERER,this,this._activeMesh),this.scene._evaluateSubMeshStage.registerStep(Te.a.STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER,this,this._evaluateSubMesh),this.scene._afterRenderingGroupDrawStage.registerStep(Te.a.STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER,this,this.render)},e.prototype._evaluateSubMesh=function(e,t){if(e.showSubMeshesBoundingBox){var i=t.getBoundingInfo();null!=i&&(i.boundingBox._tag=e.renderingGroupId,this.renderList.push(i.boundingBox))}},e.prototype._activeMesh=function(e,t){if(e.showBoundingBox||this.scene.forceShowBoundingBoxes){var i=e.getBoundingInfo();i.boundingBox._tag=t.renderingGroupId,this.renderList.push(i.boundingBox)}},e.prototype._prepareRessources=function(){if(!this._colorShader){this._colorShader=new bo.a("colorShader",this.scene,"color",{attributes:[gi.b.PositionKind],uniforms:["world","viewProjection","color"]});var e=this.scene.getEngine(),t=_i.a.CreateBox({size:1});this._vertexBuffers[gi.b.PositionKind]=new gi.b(e,t.positions,gi.b.PositionKind,!1),this._createIndexBuffer()}},e.prototype._createIndexBuffer=function(){var e=this.scene.getEngine();this._indexBuffer=e.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])},e.prototype.rebuild=function(){var e=this._vertexBuffers[gi.b.PositionKind];e&&e._rebuild(),this._createIndexBuffer()},e.prototype.reset=function(){this.renderList.reset()},e.prototype.render=function(e){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];if(r._tag===e){var n=r.minimum,s=r.maximum.subtract(n),a=n.add(s.scale(.5)),c=o.j.Scaling(s.x,s.y,s.z).multiply(o.j.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(c),t.drawElementsType(yn.a.LineListDrawMode,0,24)),t.setDepthFunctionToLess(),this.scene.resetCachedMaterial(),this._colorShader.setColor4("color",this.frontColor.toColor4()),this._colorShader.bind(c),t.drawElementsType(yn.a.LineListDrawMode,0,24)}}this._colorShader.unbind(),t.setDepthFunctionToLessOrEqual(),t.setDepthWrite(!0)}},e.prototype.renderOcclusionBoundingBox=function(e){if(this._prepareRessources(),this._colorShader.isReady()&&e._boundingInfo){var t=this.scene.getEngine();t.setDepthWrite(!1),t.setColorWrite(!1),this._colorShader._preBind();var i=e._boundingInfo.boundingBox,r=i.minimum,n=i.maximum.subtract(r),s=r.add(n.scale(.5)),a=o.j.Scaling(n.x,n.y,n.z).multiply(o.j.Translation(s.x,s.y,s.z)).multiply(i.getWorldMatrix());t.bindBuffers(this._vertexBuffers,this._indexBuffer,this._colorShader.getEffect()),t.setDepthFunctionToLess(),this.scene.resetCachedMaterial(),this._colorShader.bind(a),t.drawElementsType(yn.a.LineListDrawMode,0,24),this._colorShader.unbind(),t.setDepthFunctionToLessOrEqual(),t.setDepthWrite(!0),t.setColorWrite(!0)}},e.prototype.dispose=function(){if(this._colorShader){this.renderList.dispose(),this._colorShader.dispose();var e=this._vertexBuffers[gi.b.PositionKind];e&&(e.dispose(),this._vertexBuffers[gi.b.PositionKind]=null),this.scene.getEngine()._releaseBuffer(this._indexBuffer)}},e}(),xc="#ifdef ALPHATEST\nvarying vec2 vUV;\nuniform sampler2D diffuseSampler;\n#endif\nvarying float vDepthMetric;\nvoid main(void)\n{\n#ifdef ALPHATEST\nif (texture2D(diffuseSampler,vUV).a<0.4)\ndiscard;\n#endif\ngl_FragColor=vec4(vDepthMetric,vDepthMetric*vDepthMetric,0.0,1.0);\n}";St.a.ShadersStore.depthPixelShader=xc;var Ac=function(){function e(t,i,r){void 0===i&&(i=_.a.TEXTURETYPE_FLOAT),void 0===r&&(r=null);var n=this;this.useOnlyInActiveCamera=!1,this._scene=t,e._SceneComponentInitialization(this._scene),this._camera=r;var s=t.getEngine();this._depthMap=new Mi("depthMap",{width:s.getRenderWidth(),height:s.getRenderHeight()},this._scene,!1,!0,i),this._depthMap.wrapU=Ve.a.CLAMP_ADDRESSMODE,this._depthMap.wrapV=Ve.a.CLAMP_ADDRESSMODE,this._depthMap.refreshRate=1,this._depthMap.renderParticles=!1,this._depthMap.renderList=null,this._depthMap.activeCamera=this._camera,this._depthMap.ignoreCameraViewport=!0,this._depthMap.useCameraPostProcesses=!1,this._depthMap.onClearObservable.add(function(e){e.clear(new o.f(1,1,1,1),!0,!0,!0)});var a=function(e){var t=e.getRenderingMesh(),i=n._scene,r=i.getEngine(),o=e.getMaterial();if(o){r.setState(o.backFaceCulling,0,!1,i.useRightHandedSystem);var s=t._getInstancesRenderList(e._id);if(!s.mustReturn){var a=r.getCaps().instancedArrays&&null!==s.visibleInstances[e._id],c=n._camera||i.activeCamera;if(n.isReady(e,a)&&c){if(r.enableEffect(n._effect),t._bind(e,n._effect,yn.a.TriangleFillMode),n._effect.setMatrix("viewProjection",i.getTransformMatrix()),n._effect.setFloat2("depthValues",c.minZ,c.minZ+c.maxZ),o&&o.needAlphaTesting()){var l=o.getAlphaTestTexture();l&&(n._effect.setTexture("diffuseSampler",l),n._effect.setMatrix("diffuseMatrix",l.getTextureMatrix()))}t.useBones&&t.computeBonesUsingShaders&&t.skeleton&&n._effect.setMatrices("mBones",t.skeleton.getTransformMatrices(t)),t._processRendering(e,n._effect,yn.a.TriangleFillMode,s,a,function(e,t){return n._effect.setMatrix("world",t)})}}}};this._depthMap.customRenderFunction=function(e,t,i,r){var n;if(r.length){for(s.setColorWrite(!1),n=0;n<r.length;n++)a(r.data[n]);s.setColorWrite(!0)}for(n=0;n<e.length;n++)a(e.data[n]);for(n=0;n<t.length;n++)a(t.data[n])}}return e.prototype.isReady=function(e,t){var i=e.getMaterial();if(i.disableDepthWrite)return!1;var r=[],n=[gi.b.PositionKind],o=e.getMesh();i&&i.needAlphaTesting()&&i.getAlphaTestTexture()&&(r.push("#define ALPHATEST"),o.isVerticesDataPresent(gi.b.UVKind)&&(n.push(gi.b.UVKind),r.push("#define UV1")),o.isVerticesDataPresent(gi.b.UV2Kind)&&(n.push(gi.b.UV2Kind),r.push("#define UV2"))),o.useBones&&o.computeBonesUsingShaders?(n.push(gi.b.MatricesIndicesKind),n.push(gi.b.MatricesWeightsKind),o.numBoneInfluencers>4&&(n.push(gi.b.MatricesIndicesExtraKind),n.push(gi.b.MatricesWeightsExtraKind)),r.push("#define NUM_BONE_INFLUENCERS "+o.numBoneInfluencers),r.push("#define BonesPerMesh "+(o.skeleton?o.skeleton.bones.length+1:0))):r.push("#define NUM_BONE_INFLUENCERS 0"),t&&(r.push("#define INSTANCES"),n.push("world0"),n.push("world1"),n.push("world2"),n.push("world3"));var s=r.join("\n");return this._cachedDefines!==s&&(this._cachedDefines=s,this._effect=this._scene.getEngine().createEffect("depth",n,["world","mBones","viewProjection","diffuseMatrix","depthValues"],["diffuseSampler"],s)),this._effect.isReady()},e.prototype.getDepthMap=function(){return this._depthMap},e.prototype.dispose=function(){this._depthMap.dispose()},e._SceneComponentInitialization=function(e){throw"Import DepthRendererSceneComponent before creating DepthRenderer."},e}();W.a.prototype.enableDepthRenderer=function(e){if(!(e=e||this.activeCamera))throw"No camera available to enable depth renderer";if(this._depthRenderer||(this._depthRenderer={}),!this._depthRenderer[e.id]){var t=0;if(this.getEngine().getCaps().textureHalfFloatRender)t=_.a.TEXTURETYPE_HALF_FLOAT;else{if(!this.getEngine().getCaps().textureFloatRender)throw"Depth renderer does not support int texture type";t=_.a.TEXTURETYPE_FLOAT}this._depthRenderer[e.id]=new Ac(this,t,e)}return this._depthRenderer[e.id]},W.a.prototype.disableDepthRenderer=function(e){(e=e||this.activeCamera)&&this._depthRenderer&&this._depthRenderer[e.id]&&(this._depthRenderer[e.id].dispose(),delete this._depthRenderer[e.id])};var Pc=function(){function e(e){this.name=Te.a.NAME_DEPTHRENDERER,this.scene=e}return e.prototype.register=function(){this.scene._gatherRenderTargetsStage.registerStep(Te.a.STEP_GATHERRENDERTARGETS_DEPTHRENDERER,this,this._gatherRenderTargets),this.scene._gatherActiveCameraRenderTargetsStage.registerStep(Te.a.STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER,this,this._gatherActiveCameraRenderTargets)},e.prototype.rebuild=function(){},e.prototype.dispose=function(){for(var e in this.scene._depthRenderer)this.scene._depthRenderer[e].dispose()},e.prototype._gatherRenderTargets=function(e){if(this.scene._depthRenderer)for(var t in this.scene._depthRenderer){var i=this.scene._depthRenderer[t];i.useOnlyInActiveCamera||e.push(i.getDepthMap())}},e.prototype._gatherActiveCameraRenderTargets=function(e){if(this.scene._depthRenderer)for(var t in this.scene._depthRenderer){var i=this.scene._depthRenderer[t];i.useOnlyInActiveCamera&&this.scene.activeCamera.id===t&&e.push(i.getDepthMap())}},e}();Ac._SceneComponentInitialization=function(e){var t=e._getComponent(Te.a.NAME_DEPTHRENDERER);t||(t=new Pc(e),e._addComponent(t))};var Rc="uniform vec4 color;\nvoid main(void) {\ngl_FragColor=color;\n}";St.a.ShadersStore.linePixelShader=Rc;var Sc="\nattribute vec3 position;\nattribute vec4 normal;\n\nuniform mat4 worldViewProjection;\nuniform float width;\nuniform float aspectRatio;\nvoid main(void) {\nvec4 viewPosition=worldViewProjection*vec4(position,1.0);\nvec4 viewPositionNext=worldViewProjection*vec4(normal.xyz,1.0);\nvec2 currentScreen=viewPosition.xy/viewPosition.w;\nvec2 nextScreen=viewPositionNext.xy/viewPositionNext.w;\ncurrentScreen.x*=aspectRatio;\nnextScreen.x*=aspectRatio;\nvec2 dir=normalize(nextScreen-currentScreen);\nvec2 normalDir=vec2(-dir.y,dir.x);\nnormalDir*=width/2.0;\nnormalDir.x/=aspectRatio;\nvec4 offset=vec4(normalDir*normal.w,0.0,0.0);\ngl_Position=viewPosition+offset;\n}";St.a.ShadersStore.lineVertexShader=Sc;we.a.prototype.disableEdgesRendering=function(){return this._edgesRenderer&&(this._edgesRenderer.dispose(),this._edgesRenderer=null),this},we.a.prototype.enableEdgesRendering=function(e,t){return void 0===e&&(e=.95),void 0===t&&(t=!1),this.disableEdgesRendering(),this._edgesRenderer=new Mc(this,e,t),this},Object.defineProperty(we.a.prototype,"edgesRenderer",{get:function(){return this._edgesRenderer},enumerable:!0,configurable:!0}),os.b.prototype.enableEdgesRendering=function(e,t){return void 0===e&&(e=.95),void 0===t&&(t=!1),this.disableEdgesRendering(),this._edgesRenderer=new Oc(this,e,t),this},os.a.prototype.enableEdgesRendering=function(e,t){return void 0===e&&(e=.95),void 0===t&&(t=!1),os.b.prototype.enableEdgesRendering.apply(this,arguments),this};var Cc=function(){return function(){this.edges=new Array,this.edgesConnectedCount=0}}(),Mc=function(){function e(e,t,i,r){void 0===t&&(t=.95),void 0===i&&(i=!1),void 0===r&&(r=!0);var n=this;this.edgesWidthScalerForOrthographic=1e3,this.edgesWidthScalerForPerspective=50,this._linesPositions=new Array,this._linesNormals=new Array,this._linesIndices=new Array,this._buffers={},this._checkVerticesInsteadOfIndices=!1,this.isEnabled=!0,this._source=e,this._checkVerticesInsteadOfIndices=i,this._epsilon=t,this._prepareRessources(),r&&this._generateEdgesLines(),this._meshRebuildObserver=this._source.onRebuildObservable.add(function(){n._rebuild()}),this._meshDisposeObserver=this._source.onDisposeObservable.add(function(){n.dispose()})}return e.prototype._prepareRessources=function(){this._lineShader||(this._lineShader=new bo.a("lineShader",this._source.getScene(),"line",{attributes:["position","normal"],uniforms:["worldViewProjection","color","width","aspectRatio"]}),this._lineShader.disableDepthWrite=!0,this._lineShader.backFaceCulling=!1)},e.prototype._rebuild=function(){var e=this._buffers[gi.b.PositionKind];e&&e._rebuild(),(e=this._buffers[gi.b.NormalKind])&&e._rebuild();var t=this._source.getScene().getEngine();this._ib=t.createIndexBuffer(this._linesIndices)},e.prototype.dispose=function(){this._source.onRebuildObservable.remove(this._meshRebuildObserver),this._source.onDisposeObservable.remove(this._meshDisposeObserver);var e=this._buffers[gi.b.PositionKind];e&&(e.dispose(),this._buffers[gi.b.PositionKind]=null),(e=this._buffers[gi.b.NormalKind])&&(e.dispose(),this._buffers[gi.b.NormalKind]=null),this._source.getScene().getEngine()._releaseBuffer(this._ib),this._lineShader.dispose()},e.prototype._processEdgeForAdjacencies=function(e,t,i,r,n){return e===i&&t===r||e===r&&t===i?0:e===r&&t===n||e===n&&t===r?1:e===n&&t===i||e===i&&t===n?2:-1},e.prototype._processEdgeForAdjacenciesWithVertices=function(e,t,i,r,n){return e.equalsWithEpsilon(i)&&t.equalsWithEpsilon(r)||e.equalsWithEpsilon(r)&&t.equalsWithEpsilon(i)?0:e.equalsWithEpsilon(r)&&t.equalsWithEpsilon(n)||e.equalsWithEpsilon(n)&&t.equalsWithEpsilon(r)?1:e.equalsWithEpsilon(n)&&t.equalsWithEpsilon(i)||e.equalsWithEpsilon(i)&&t.equalsWithEpsilon(n)?2:-1},e.prototype._checkEdge=function(e,t,i,r,n){var s;void 0===t?s=!0:s=o.x.Dot(i[e],i[t])<this._epsilon;s&&this.createLine(r,n,this._linesPositions.length/3)},e.prototype.createLine=function(e,t,i){this._linesPositions.push(e.x,e.y,e.z,e.x,e.y,e.z,t.x,t.y,t.z,t.x,t.y,t.z),this._linesNormals.push(t.x,t.y,t.z,-1,t.x,t.y,t.z,1,e.x,e.y,e.z,-1,e.x,e.y,e.z,1),this._linesIndices.push(i,i+1,i+2,i,i+2,i+3)},e.prototype._generateEdgesLines=function(){var e=this._source.getVerticesData(gi.b.PositionKind),t=this._source.getIndices();if(t&&e){var i,r,n=new Array,s=new Array;for(i=0;i<t.length;i+=3){r=new Cc;var a=t[i],c=t[i+1],l=t[i+2];r.p0=new o.x(e[3*a],e[3*a+1],e[3*a+2]),r.p1=new o.x(e[3*c],e[3*c+1],e[3*c+2]),r.p2=new o.x(e[3*l],e[3*l+1],e[3*l+2]);var u=o.x.Cross(r.p1.subtract(r.p0),r.p2.subtract(r.p1));u.normalize(),s.push(u),n.push(r)}for(i=0;i<n.length;i++){r=n[i];for(var h=i+1;h<n.length;h++){var d=n[h];if(3===r.edgesConnectedCount)break;if(3!==d.edgesConnectedCount)for(var f=t[3*h],p=t[3*h+1],_=t[3*h+2],g=0;g<3;g++){var m=0;if(void 0===r.edges[g]){switch(g){case 0:m=this._checkVerticesInsteadOfIndices?this._processEdgeForAdjacenciesWithVertices(r.p0,r.p1,d.p0,d.p1,d.p2):this._processEdgeForAdjacencies(t[3*i],t[3*i+1],f,p,_);break;case 1:m=this._checkVerticesInsteadOfIndices?this._processEdgeForAdjacenciesWithVertices(r.p1,r.p2,d.p0,d.p1,d.p2):this._processEdgeForAdjacencies(t[3*i+1],t[3*i+2],f,p,_);break;case 2:m=this._checkVerticesInsteadOfIndices?this._processEdgeForAdjacenciesWithVertices(r.p2,r.p0,d.p0,d.p1,d.p2):this._processEdgeForAdjacencies(t[3*i+2],t[3*i],f,p,_)}if(-1!==m&&(r.edges[g]=h,d.edges[m]=i,r.edgesConnectedCount++,d.edgesConnectedCount++,3===r.edgesConnectedCount))break}}}}for(i=0;i<n.length;i++){var v=n[i];this._checkEdge(i,v.edges[0],s,v.p0,v.p1),this._checkEdge(i,v.edges[1],s,v.p1,v.p2),this._checkEdge(i,v.edges[2],s,v.p2,v.p0)}var y=this._source.getScene().getEngine();this._buffers[gi.b.PositionKind]=new gi.b(y,this._linesPositions,gi.b.PositionKind,!1),this._buffers[gi.b.NormalKind]=new gi.b(y,this._linesNormals,gi.b.NormalKind,!1,!1,4),this._ib=y.createIndexBuffer(this._linesIndices),this._indicesCount=this._linesIndices.length}},e.prototype.isReady=function(){return this._lineShader.isReady()},e.prototype.render=function(){var e=this._source.getScene();if(this.isReady()&&e.activeCamera){var t=e.getEngine();this._lineShader._preBind(),1!==this._source.edgesColor.a?t.setAlphaMode(_.a.ALPHA_COMBINE):t.setAlphaMode(_.a.ALPHA_DISABLE),t.bindBuffers(this._buffers,this._ib,this._lineShader.getEffect()),e.resetCachedMaterial(),this._lineShader.setColor4("color",this._source.edgesColor),e.activeCamera.mode===Le.a.ORTHOGRAPHIC_CAMERA?this._lineShader.setFloat("width",this._source.edgesWidth/this.edgesWidthScalerForOrthographic):this._lineShader.setFloat("width",this._source.edgesWidth/this.edgesWidthScalerForPerspective),this._lineShader.setFloat("aspectRatio",t.getAspectRatio(e.activeCamera)),this._lineShader.bind(this._source.getWorldMatrix()),t.drawElementsType(yn.a.TriangleFillMode,0,this._indicesCount),this._lineShader.unbind()}},e}(),Oc=function(e){function t(t,i,r){void 0===i&&(i=.95),void 0===r&&(r=!1);var n=e.call(this,t,i,r,!1)||this;return n._generateEdgesLines(),n}return l.d(t,e),t.prototype._generateEdgesLines=function(){var e=this._source.getVerticesData(gi.b.PositionKind),t=this._source.getIndices();if(t&&e){for(var i=o.t.Vector3[0],r=o.t.Vector3[1],n=t.length-1,s=0,a=0;s<n;s+=2,a+=4)o.x.FromArrayToRef(e,3*t[s],i),o.x.FromArrayToRef(e,3*t[s+1],r),this.createLine(i,r,a);var c=this._source.getScene().getEngine();this._buffers[gi.b.PositionKind]=new gi.b(c,this._linesPositions,gi.b.PositionKind,!1),this._buffers[gi.b.NormalKind]=new gi.b(c,this._linesNormals,gi.b.NormalKind,!1,!1,4),this._ib=c.createIndexBuffer(this._linesIndices),this._indicesCount=this._linesIndices.length}},t}(Mc);Object.defineProperty(W.a.prototype,"geometryBufferRenderer",{get:function(){this._geometryBufferRenderer},set:function(e){e&&e.isSupported&&(this._geometryBufferRenderer=e)},enumerable:!0,configurable:!0}),W.a.prototype.enableGeometryBufferRenderer=function(e){return void 0===e&&(e=1),this._geometryBufferRenderer?this._geometryBufferRenderer:(this._geometryBufferRenderer=new Ka(this,e),this._geometryBufferRenderer.isSupported||(this._geometryBufferRenderer=null),this._geometryBufferRenderer)},W.a.prototype.disableGeometryBufferRenderer=function(){this._geometryBufferRenderer&&(this._geometryBufferRenderer.dispose(),this._geometryBufferRenderer=null)};var Ic=function(){function e(e){this.name=Te.a.NAME_GEOMETRYBUFFERRENDERER,this.scene=e}return e.prototype.register=function(){this.scene._gatherRenderTargetsStage.registerStep(Te.a.STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER,this,this._gatherRenderTargets)},e.prototype.rebuild=function(){},e.prototype.dispose=function(){},e.prototype._gatherRenderTargets=function(e){this.scene._geometryBufferRenderer&&e.push(this.scene._geometryBufferRenderer.getGBuffer())},e}();Ka._SceneComponentInitialization=function(e){var t=e._getComponent(Te.a.NAME_GEOMETRYBUFFERRENDERER);t||(t=new Ic(e),e._addComponent(t))};var Dc="#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\nuniform vec4 color;\n#ifdef ALPHATEST\nvarying vec2 vUV;\nuniform sampler2D diffuseSampler;\n#endif\n#include<logDepthDeclaration>\nvoid main(void) {\n#ifdef ALPHATEST\nif (texture2D(diffuseSampler,vUV).a<0.4)\ndiscard;\n#endif\n#include<logDepthFragment>\ngl_FragColor=color;\n}";St.a.ShadersStore.outlinePixelShader=Dc;var wc="\nattribute vec3 position;\nattribute vec3 normal;\n#include<bonesDeclaration>\n\nuniform float offset;\n#include<instancesDeclaration>\nuniform mat4 viewProjection;\n#ifdef ALPHATEST\nvarying vec2 vUV;\nuniform mat4 diffuseMatrix;\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#endif\n#include<logDepthDeclaration>\nvoid main(void)\n{\nvec3 offsetPosition=position+normal*offset;\n#include<instancesVertex>\n#include<bonesVertex>\ngl_Position=viewProjection*finalWorld*vec4(offsetPosition,1.0);\n#ifdef ALPHATEST\n#ifdef UV1\nvUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n#endif\n#ifdef UV2\nvUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n#include<logDepthVertex>\n}\n";St.a.ShadersStore.outlineVertexShader=wc;W.a.prototype.getOutlineRenderer=function(){return this._outlineRenderer||(this._outlineRenderer=new Lc(this)),this._outlineRenderer},Object.defineProperty(we.a.prototype,"renderOutline",{get:function(){return this._renderOutline},set:function(e){e&&this.getScene().getOutlineRenderer(),this._renderOutline=e},enumerable:!0,configurable:!0}),Object.defineProperty(we.a.prototype,"renderOverlay",{get:function(){return this._renderOverlay},set:function(e){e&&this.getScene().getOutlineRenderer(),this._renderOverlay=e},enumerable:!0,configurable:!0});var Lc=function(){function e(e){this.name=Te.a.NAME_OUTLINERENDERER,this.zOffset=1,this.scene=e,this._engine=e.getEngine(),this.scene._addComponent(this)}return e.prototype.register=function(){this.scene._beforeRenderingMeshStage.registerStep(Te.a.STEP_BEFORERENDERINGMESH_OUTLINE,this,this._beforeRenderingMesh),this.scene._afterRenderingMeshStage.registerStep(Te.a.STEP_AFTERRENDERINGMESH_OUTLINE,this,this._afterRenderingMesh)},e.prototype.rebuild=function(){},e.prototype.dispose=function(){},e.prototype.render=function(e,t,i){var r=this;void 0===i&&(i=!1);var n=this.scene,o=n.getEngine(),s=o.getCaps().instancedArrays&&null!==t.visibleInstances[e._id]&&void 0!==t.visibleInstances[e._id];if(this.isReady(e,s)){var a=e.getRenderingMesh(),c=e.getMaterial();if(c&&n.activeCamera){if(o.enableEffect(this._effect),c.useLogarithmicDepth&&this._effect.setFloat("logarithmicDepthConstant",2/(Math.log(n.activeCamera.maxZ+1)/Math.LN2)),this._effect.setFloat("offset",i?0:a.outlineWidth),this._effect.setColor4("color",i?a.overlayColor:a.outlineColor,i?a.overlayAlpha:c.alpha),this._effect.setMatrix("viewProjection",n.getTransformMatrix()),a.useBones&&a.computeBonesUsingShaders&&a.skeleton&&this._effect.setMatrices("mBones",a.skeleton.getTransformMatrices(a)),a._bind(e,this._effect,yn.a.TriangleFillMode),c&&c.needAlphaTesting()){var l=c.getAlphaTestTexture();l&&(this._effect.setTexture("diffuseSampler",l),this._effect.setMatrix("diffuseMatrix",l.getTextureMatrix()))}o.setZOffset(-this.zOffset),a._processRendering(e,this._effect,yn.a.TriangleFillMode,t,s,function(e,t){r._effect.setMatrix("world",t)}),o.setZOffset(0)}}},e.prototype.isReady=function(e,t){var i=[],r=[gi.b.PositionKind,gi.b.NormalKind],n=e.getMesh(),o=e.getMaterial();o&&(o.needAlphaTesting()&&(i.push("#define ALPHATEST"),n.isVerticesDataPresent(gi.b.UVKind)&&(r.push(gi.b.UVKind),i.push("#define UV1")),n.isVerticesDataPresent(gi.b.UV2Kind)&&(r.push(gi.b.UV2Kind),i.push("#define UV2"))),o.useLogarithmicDepth&&i.push("#define LOGARITHMICDEPTH")),n.useBones&&n.computeBonesUsingShaders?(r.push(gi.b.MatricesIndicesKind),r.push(gi.b.MatricesWeightsKind),n.numBoneInfluencers>4&&(r.push(gi.b.MatricesIndicesExtraKind),r.push(gi.b.MatricesWeightsExtraKind)),i.push("#define NUM_BONE_INFLUENCERS "+n.numBoneInfluencers),i.push("#define BonesPerMesh "+(n.skeleton?n.skeleton.bones.length+1:0))):i.push("#define NUM_BONE_INFLUENCERS 0"),t&&(i.push("#define INSTANCES"),r.push("world0"),r.push("world1"),r.push("world2"),r.push("world3"));var s=i.join("\n");return this._cachedDefines!==s&&(this._cachedDefines=s,this._effect=this.scene.getEngine().createEffect("outline",r,["world","mBones","viewProjection","diffuseMatrix","offset","color","logarithmicDepthConstant"],["diffuseSampler"],s)),this._effect.isReady()},e.prototype._beforeRenderingMesh=function(e,t,i){this._savedDepthWrite=this._engine.getDepthWrite(),e.renderOutline&&(this._engine.setDepthWrite(!1),this.render(t,i),this._engine.setDepthWrite(this._savedDepthWrite))},e.prototype._afterRenderingMesh=function(e,t,i){if(e.renderOutline&&this._savedDepthWrite&&(this._engine.setDepthWrite(!0),this._engine.setColorWrite(!1),this.render(t,i),this._engine.setColorWrite(!0)),e.renderOverlay){var r=this._engine.getAlphaMode();this._engine.setAlphaMode(_.a.ALPHA_COMBINE),this.render(t,i,!0),this._engine.setAlphaMode(r)}},e}(),Fc=i(102),Nc=function(){function e(e,t){this.name=e,this.color=new o.f(1,1,1,1),this.width=1,this.height=1,this.angle=0,this.cellIndex=0,this.invertU=0,this.invertV=0,this.animations=new Array,this.isPickable=!1,this._animationStarted=!1,this._loopAnimation=!1,this._fromIndex=0,this._toIndex=0,this._delay=0,this._direction=1,this._time=0,this.isVisible=!0,this._manager=t,this._manager.sprites.push(this),this.position=o.x.Zero()}return Object.defineProperty(e.prototype,"size",{get:function(){return this.width},set:function(e){this.width=e,this.height=e},enumerable:!0,configurable:!0}),e.prototype.playAnimation=function(e,t,i,r,n){this._fromIndex=e,this._toIndex=t,this._loopAnimation=i,this._delay=r,this._animationStarted=!0,this._direction=e<t?1:-1,this.cellIndex=e,this._time=0,this._onAnimationEnd=n},e.prototype.stopAnimation=function(){this._animationStarted=!1},e.prototype._animate=function(e){this._animationStarted&&(this._time+=e,this._time>this._delay&&(this._time=this._time%this._delay,this.cellIndex+=this._direction,this.cellIndex>this._toIndex&&(this._loopAnimation?this.cellIndex=this._fromIndex:(this.cellIndex=this._toIndex,this._animationStarted=!1,this._onAnimationEnd&&this._onAnimationEnd(),this.disposeWhenFinishedAnimating&&this.dispose()))))},e.prototype.dispose=function(){for(var e=0;e<this._manager.sprites.length;e++)this._manager.sprites[e]==this&&this._manager.sprites.splice(e,1)},e}();W.a.prototype._internalPickSprites=function(e,t,i,r){if(!ji.a)return null;var n=null;if(!r){if(!this.activeCamera)return null;r=this.activeCamera}if(this.spriteManagers.length>0)for(var o=0;o<this.spriteManagers.length;o++){var s=this.spriteManagers[o];if(s.isPickable){var a=s.intersects(e,r,t,i);if(a&&a.hit&&(i||null==n||!(a.distance>=n.distance))&&(n=a,i))break}}return n||new ji.a},W.a.prototype.pickSprite=function(e,t,i,r,n){return this.createPickingRayInCameraSpaceToRef(e,t,this._tempSpritePickingRay,n),this._internalPickSprites(this._tempSpritePickingRay,i,r,n)},W.a.prototype.pickSpriteWithRay=function(e,t,i,r){if(!this._tempSpritePickingRay)return null;if(!r){if(!this.activeCamera)return null;r=this.activeCamera}return ei.a.TransformToRef(e,r.getViewMatrix(),this._tempSpritePickingRay),this._internalPickSprites(this._tempSpritePickingRay,t,i,r)},W.a.prototype.setPointerOverSprite=function(e){this._pointerOverSprite!==e&&(this._pointerOverSprite&&this._pointerOverSprite.actionManager&&this._pointerOverSprite.actionManager.processTrigger(_.a.ACTION_OnPointerOutTrigger,c.a.CreateNewFromSprite(this._pointerOverSprite,this)),this._pointerOverSprite=e,this._pointerOverSprite&&this._pointerOverSprite.actionManager&&this._pointerOverSprite.actionManager.processTrigger(_.a.ACTION_OnPointerOverTrigger,c.a.CreateNewFromSprite(this._pointerOverSprite,this)))},W.a.prototype.getPointerOverSprite=function(){return this._pointerOverSprite};var Bc=function(){function e(e){this.name=Te.a.NAME_SPRITE,this.scene=e,this.scene.spriteManagers=new Array,this.scene._tempSpritePickingRay=ei.a?ei.a.Zero():null,this.scene.onBeforeSpritesRenderingObservable=new n.c,this.scene.onAfterSpritesRenderingObservable=new n.c,this._spritePredicate=function(e){return!!e.actionManager&&(e.isPickable&&e.actionManager.hasPointerTriggers)}}return e.prototype.register=function(){this.scene._pointerMoveStage.registerStep(Te.a.STEP_POINTERMOVE_SPRITE,this,this._pointerMove),this.scene._pointerDownStage.registerStep(Te.a.STEP_POINTERDOWN_SPRITE,this,this._pointerDown),this.scene._pointerUpStage.registerStep(Te.a.STEP_POINTERUP_SPRITE,this,this._pointerUp)},e.prototype.rebuild=function(){},e.prototype.dispose=function(){this.scene.onBeforeSpritesRenderingObservable.clear(),this.scene.onAfterSpritesRenderingObservable.clear();for(var e=this.scene.spriteManagers;e.length;)e[0].dispose()},e.prototype._pickSpriteButKeepRay=function(e,t,i,r,n){var o=this.scene.pickSprite(t,i,this._spritePredicate,r,n);return o&&(o.ray=e?e.ray:null),o},e.prototype._pointerMove=function(e,t,i,r,n){var o=this.scene;return r?o.setPointerOverSprite(null):(i=this._pickSpriteButKeepRay(i,e,t,!1,o.cameraToUseForPointers||void 0))&&i.hit&&i.pickedSprite?(o.setPointerOverSprite(i.pickedSprite),o._pointerOverSprite&&o._pointerOverSprite.actionManager&&o._pointerOverSprite.actionManager.hoverCursor?n.style.cursor=o._pointerOverSprite.actionManager.hoverCursor:n.style.cursor=o.hoverCursor):o.setPointerOverSprite(null),i},e.prototype._pointerDown=function(e,t,i,r){var n=this.scene;if(n._pickedDownSprite=null,n.spriteManagers.length>0&&(i=n.pickSprite(e,t,this._spritePredicate,!1,n.cameraToUseForPointers||void 0))&&i.hit&&i.pickedSprite&&i.pickedSprite.actionManager){switch(n._pickedDownSprite=i.pickedSprite,r.button){case 0:i.pickedSprite.actionManager.processTrigger(_.a.ACTION_OnLeftPickTrigger,c.a.CreateNewFromSprite(i.pickedSprite,n,r));break;case 1:i.pickedSprite.actionManager.processTrigger(_.a.ACTION_OnCenterPickTrigger,c.a.CreateNewFromSprite(i.pickedSprite,n,r));break;case 2:i.pickedSprite.actionManager.processTrigger(_.a.ACTION_OnRightPickTrigger,c.a.CreateNewFromSprite(i.pickedSprite,n,r))}i.pickedSprite.actionManager&&i.pickedSprite.actionManager.processTrigger(_.a.ACTION_OnPickDownTrigger,c.a.CreateNewFromSprite(i.pickedSprite,n,r))}return i},e.prototype._pointerUp=function(e,t,i,r){var n=this.scene;if(n.spriteManagers.length>0){var o=n.pickSprite(e,t,this._spritePredicate,!1,n.cameraToUseForPointers||void 0);o&&(o.hit&&o.pickedSprite&&o.pickedSprite.actionManager&&(o.pickedSprite.actionManager.processTrigger(_.a.ACTION_OnPickUpTrigger,c.a.CreateNewFromSprite(o.pickedSprite,n,r)),o.pickedSprite.actionManager&&(this.scene._isPointerSwiping()||o.pickedSprite.actionManager.processTrigger(_.a.ACTION_OnPickTrigger,c.a.CreateNewFromSprite(o.pickedSprite,n,r)))),n._pickedDownSprite&&n._pickedDownSprite.actionManager&&n._pickedDownSprite!==o.pickedSprite&&n._pickedDownSprite.actionManager.processTrigger(_.a.ACTION_OnPickOutTrigger,c.a.CreateNewFromSprite(n._pickedDownSprite,n,r)))}return i},e}(),Uc="uniform bool alphaTest;\nvarying vec4 vColor;\n\nvarying vec2 vUV;\nuniform sampler2D diffuseSampler;\n\n#include<fogFragmentDeclaration>\nvoid main(void) {\nvec4 color=texture2D(diffuseSampler,vUV);\nif (alphaTest)\n{\nif (color.a<0.95)\ndiscard;\n}\ncolor*=vColor;\n#include<fogFragment>\ngl_FragColor=color;\n}";St.a.ShadersStore.spritesPixelShader=Uc;var Vc="\nattribute vec4 position;\nattribute vec4 options;\nattribute vec4 cellInfo;\nattribute vec4 color;\n\nuniform vec2 textureInfos;\nuniform mat4 view;\nuniform mat4 projection;\n\nvarying vec2 vUV;\nvarying vec4 vColor;\n#include<fogVertexDeclaration>\nvoid main(void) {\nvec3 viewPos=(view*vec4(position.xyz,1.0)).xyz;\nvec2 cornerPos;\nfloat angle=position.w;\nvec2 size=vec2(options.x,options.y);\nvec2 offset=options.zw;\nvec2 uvScale=textureInfos.xy;\ncornerPos=vec2(offset.x-0.5,offset.y-0.5)*size;\n\nvec3 rotatedCorner;\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.z=0.;\n\nviewPos+=rotatedCorner;\ngl_Position=projection*vec4(viewPos,1.0);\n\nvColor=color;\n\nvec2 uvOffset=vec2(abs(offset.x-cellInfo.x),1.0-abs(offset.y-cellInfo.y));\nvUV=(uvOffset+cellInfo.zw)*uvScale;\n\n#ifdef FOG\nvFogDistance=viewPos;\n#endif\n}";St.a.ShadersStore.spritesVertexShader=Vc;var Gc,kc=function(){function e(e,t,i,r,o,s,a){if(void 0===s&&(s=.01),void 0===a&&(a=Ve.a.TRILINEAR_SAMPLINGMODE),this.name=e,this.sprites=new Array,this.renderingGroupId=0,this.layerMask=268435455,this.fogEnabled=!0,this.isPickable=!1,this.onDisposeObservable=new n.c,this._vertexBuffers={},o._getComponent(Te.a.NAME_SPRITE)||o._addComponent(new Bc(o)),this._capacity=i,this._spriteTexture=new Ve.a(t,o,!0,!1,a),this._spriteTexture.wrapU=Ve.a.CLAMP_ADDRESSMODE,this._spriteTexture.wrapV=Ve.a.CLAMP_ADDRESSMODE,r.width&&r.height)this.cellWidth=r.width,this.cellHeight=r.height;else{if(void 0===r)return;this.cellWidth=r,this.cellHeight=r}this._epsilon=s,this._scene=o,this._scene.spriteManagers.push(this);for(var c=[],l=0,u=0;u<i;u++)c.push(l),c.push(l+1),c.push(l+2),c.push(l),c.push(l+2),c.push(l+3),l+=4;this._indexBuffer=o.getEngine().createIndexBuffer(c),this._vertexData=new Float32Array(16*i*4),this._buffer=new gi.a(o.getEngine(),this._vertexData,!0,16);var h=this._buffer.createVertexBuffer(gi.b.PositionKind,0,4),d=this._buffer.createVertexBuffer("options",4,4),f=this._buffer.createVertexBuffer("cellInfo",8,4),p=this._buffer.createVertexBuffer(gi.b.ColorKind,12,4);this._vertexBuffers[gi.b.PositionKind]=h,this._vertexBuffers.options=d,this._vertexBuffers.cellInfo=f,this._vertexBuffers[gi.b.ColorKind]=p,this._effectBase=this._scene.getEngine().createEffect("sprites",[gi.b.PositionKind,"options","cellInfo",gi.b.ColorKind],["view","projection","textureInfos","alphaTest"],["diffuseSampler"],""),this._effectFog=this._scene.getEngine().createEffect("sprites",[gi.b.PositionKind,"options","cellInfo",gi.b.ColorKind],["view","projection","textureInfos","alphaTest","vFogInfos","vFogColor"],["diffuseSampler"],"#define FOG")}return Object.defineProperty(e.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"texture",{get:function(){return this._spriteTexture},set:function(e){this._spriteTexture=e},enumerable:!0,configurable:!0}),e.prototype._appendSpriteVertex=function(e,t,i,r,n){var o=16*e;0===i?i=this._epsilon:1===i&&(i=1-this._epsilon),0===r?r=this._epsilon:1===r&&(r=1-this._epsilon),this._vertexData[o]=t.position.x,this._vertexData[o+1]=t.position.y,this._vertexData[o+2]=t.position.z,this._vertexData[o+3]=t.angle,this._vertexData[o+4]=t.width,this._vertexData[o+5]=t.height,this._vertexData[o+6]=i,this._vertexData[o+7]=r,this._vertexData[o+8]=t.invertU?1:0,this._vertexData[o+9]=t.invertV?1:0;var s=t.cellIndex/n>>0;this._vertexData[o+10]=t.cellIndex-s*n,this._vertexData[o+11]=s,this._vertexData[o+12]=t.color.r,this._vertexData[o+13]=t.color.g,this._vertexData[o+14]=t.color.b,this._vertexData[o+15]=t.color.a},e.prototype.intersects=function(e,t,i,r){for(var n=Math.min(this._capacity,this.sprites.length),s=o.x.Zero(),a=o.x.Zero(),c=Number.MAX_VALUE,l=null,u=o.x.Zero(),h=t.getViewMatrix(),d=0;d<n;d++){var f=this.sprites[d];if(f){if(i){if(!i(f))continue}else if(!f.isPickable)continue;if(o.x.TransformCoordinatesToRef(f.position,h,u),s.copyFromFloats(u.x-f.width/2,u.y-f.height/2,u.z),a.copyFromFloats(u.x+f.width/2,u.y+f.height/2,u.z),e.intersectsBoxMinMax(s,a)){var p=o.x.Distance(u,e.origin);if(c>p&&(c=p,l=f,r))break}}}if(l){var _=new ji.a;return _.hit=!0,_.pickedSprite=l,_.distance=c,_}return null},e.prototype.render=function(){if(this._effectBase.isReady()&&this._effectFog.isReady()&&this._spriteTexture&&this._spriteTexture.isReady()&&this.sprites.length){for(var e=this._scene.getEngine(),t=this._spriteTexture.getBaseSize(),i=e.getDeltaTime(),r=Math.min(this._capacity,this.sprites.length),n=t.width/this.cellWidth,o=0,s=0;s<r;s++){var a=this.sprites[s];a&&a.isVisible&&(a._animate(i),this._appendSpriteVertex(o++,a,0,0,n),this._appendSpriteVertex(o++,a,1,0,n),this._appendSpriteVertex(o++,a,1,1,n),this._appendSpriteVertex(o++,a,0,1,n))}this._buffer.update(this._vertexData);var c=this._effectBase;this._scene.fogEnabled&&this._scene.fogMode!==W.a.FOGMODE_NONE&&this.fogEnabled&&(c=this._effectFog),e.enableEffect(c);var l=this._scene.getViewMatrix();c.setTexture("diffuseSampler",this._spriteTexture),c.setMatrix("view",l),c.setMatrix("projection",this._scene.getProjectionMatrix()),c.setFloat2("textureInfos",this.cellWidth/t.width,this.cellHeight/t.height),this._scene.fogEnabled&&this._scene.fogMode!==W.a.FOGMODE_NONE&&this.fogEnabled&&(c.setFloat4("vFogInfos",this._scene.fogMode,this._scene.fogStart,this._scene.fogEnd,this._scene.fogDensity),c.setColor3("vFogColor",this._scene.fogColor)),e.bindBuffers(this._vertexBuffers,this._indexBuffer,c),e.setDepthFunctionToLessOrEqual(),c.setBool("alphaTest",!0),e.setColorWrite(!1),e.drawElementsType(yn.a.TriangleFillMode,0,o/4*6),e.setColorWrite(!0),c.setBool("alphaTest",!1),e.setAlphaMode(_.a.ALPHA_COMBINE),e.drawElementsType(yn.a.TriangleFillMode,0,o/4*6),e.setAlphaMode(_.a.ALPHA_DISABLE)}},e.prototype.dispose=function(){this._buffer&&(this._buffer.dispose(),this._buffer=null),this._indexBuffer&&(this._scene.getEngine()._releaseBuffer(this._indexBuffer),this._indexBuffer=null),this._spriteTexture&&(this._spriteTexture.dispose(),this._spriteTexture=null);var e=this._scene.spriteManagers.indexOf(this);this._scene.spriteManagers.splice(e,1),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear()},e}(),zc=i(85),jc=i(99);!function(e){e[e.INIT=0]="INIT",e[e.RUNNING=1]="RUNNING",e[e.DONE=2]="DONE",e[e.ERROR=3]="ERROR"}(Gc||(Gc={}));var Wc,Hc=function(){function e(e){this.name=e,this._isCompleted=!1,this._taskState=Gc.INIT}return Object.defineProperty(e.prototype,"isCompleted",{get:function(){return this._isCompleted},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"taskState",{get:function(){return this._taskState},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"errorObject",{get:function(){return this._errorObject},enumerable:!0,configurable:!0}),e.prototype._setErrorObject=function(e,t){this._errorObject||(this._errorObject={message:e,exception:t})},e.prototype.run=function(e,t,i){var r=this;this._taskState=Gc.RUNNING,this.runTask(e,function(){r.onDoneCallback(t,i)},function(e,t){r.onErrorCallback(i,e,t)})},e.prototype.runTask=function(e,t,i){throw new Error("runTask is not implemented")},e.prototype.reset=function(){this._taskState=Gc.INIT},e.prototype.onErrorCallback=function(e,t,i){this._taskState=Gc.ERROR,this._errorObject={message:t,exception:i},this.onError&&this.onError(this,t,i),e()},e.prototype.onDoneCallback=function(e,t){try{this._taskState=Gc.DONE,this._isCompleted=!0,this.onSuccess&&this.onSuccess(this),e()}catch(e){this.onErrorCallback(t,"Task is done, error executing success callback(s)",e)}},e}(),Xc=function(){return function(e,t,i){this.remainingCount=e,this.totalCount=t,this.task=i}}(),Yc=function(e){function t(t,i,r,n){var o=e.call(this,t)||this;return o.name=t,o.meshesNames=i,o.rootUrl=r,o.sceneFilename=n,o}return l.d(t,e),t.prototype.runTask=function(e,t,i){var r=this;cr.ImportMesh(this.meshesNames,this.rootUrl,this.sceneFilename,e,function(e,i,n,o){r.loadedMeshes=e,r.loadedParticleSystems=i,r.loadedSkeletons=n,r.loadedAnimationGroups=o,t()},null,function(e,t,r){i(t,r)})},t}(Hc),Kc=function(e){function t(t,i){var r=e.call(this,t)||this;return r.name=t,r.url=i,r}return l.d(t,e),t.prototype.runTask=function(e,t,i){var r=this;e._loadFile(this.url,function(e){r.text=e,t()},void 0,!1,!1,function(e,t){e&&i(e.status+" "+e.statusText,t)})},t}(Hc),Qc=function(e){function t(t,i){var r=e.call(this,t)||this;return r.name=t,r.url=i,r}return l.d(t,e),t.prototype.runTask=function(e,t,i){var r=this;e._loadFile(this.url,function(e){r.data=e,t()},void 0,!0,!0,function(e,t){e&&i(e.status+" "+e.statusText,t)})},t}(Hc),qc=function(e){function t(t,i){var r=e.call(this,t)||this;return r.name=t,r.url=i,r}return l.d(t,e),t.prototype.runTask=function(e,t,i){var r=this,n=new Image;ve.h.SetCorsBehavior(this.url,n),n.onload=function(){r.image=n,t()},n.onerror=function(e){i("Error loading image",e)},n.src=this.url},t}(Hc),Zc=function(e){function t(t,i,r,n,o){void 0===o&&(o=Ve.a.TRILINEAR_SAMPLINGMODE);var s=e.call(this,t)||this;return s.name=t,s.url=i,s.noMipmap=r,s.invertY=n,s.samplingMode=o,s}return l.d(t,e),t.prototype.runTask=function(e,t,i){this.texture=new Ve.a(this.url,e,this.noMipmap,this.invertY,this.samplingMode,function(){t()},function(e,t){i(e,t)})},t}(Hc),Jc=function(e){function t(t,i,r,n,o){var s=e.call(this,t)||this;return s.name=t,s.url=i,s.extensions=r,s.noMipmap=n,s.files=o,s}return l.d(t,e),t.prototype.runTask=function(e,t,i){this.texture=new Gr(this.url,e,this.extensions,this.noMipmap,this.files,function(){t()},function(e,t){i(e,t)})},t}(Hc),$c=function(e){function t(t,i,r,n,o,s,a){void 0===n&&(n=!1),void 0===o&&(o=!0),void 0===s&&(s=!1),void 0===a&&(a=!1);var c=e.call(this,t)||this;return c.name=t,c.url=i,c.size=r,c.noMipmap=n,c.generateHarmonics=o,c.gammaSpace=s,c.reserved=a,c}return l.d(t,e),t.prototype.run=function(e,t,i){this.texture=new to(this.url,e,this.size,this.noMipmap,this.generateHarmonics,this.gammaSpace,this.reserved,function(){t()},function(e,t){i(e,t)})},t}(Hc),el=function(){function e(e){this._isLoading=!1,this._tasks=new Array,this._waitingTasksCount=0,this._totalTasksCount=0,this.onTaskSuccessObservable=new n.c,this.onTaskErrorObservable=new n.c,this.onTasksDoneObservable=new n.c,this.onProgressObservable=new n.c,this.useDefaultLoadingScreen=!0,this._scene=e}return e.prototype.addMeshTask=function(e,t,i,r){var n=new Yc(e,t,i,r);return this._tasks.push(n),n},e.prototype.addTextFileTask=function(e,t){var i=new Kc(e,t);return this._tasks.push(i),i},e.prototype.addBinaryFileTask=function(e,t){var i=new Qc(e,t);return this._tasks.push(i),i},e.prototype.addImageTask=function(e,t){var i=new qc(e,t);return this._tasks.push(i),i},e.prototype.addTextureTask=function(e,t,i,r,n){void 0===n&&(n=Ve.a.TRILINEAR_SAMPLINGMODE);var o=new Zc(e,t,i,r,n);return this._tasks.push(o),o},e.prototype.addCubeTextureTask=function(e,t,i,r,n){var o=new Jc(e,t,i,r,n);return this._tasks.push(o),o},e.prototype.addHDRCubeTextureTask=function(e,t,i,r,n,o,s){void 0===r&&(r=!1),void 0===n&&(n=!0),void 0===o&&(o=!1),void 0===s&&(s=!1);var a=new $c(e,t,i,r,n,o,s);return this._tasks.push(a),a},e.prototype.removeTask=function(e){var t=this._tasks.indexOf(e);t>-1&&this._tasks.splice(t,1)},e.prototype._decreaseWaitingTasksCount=function(e){this._waitingTasksCount--;try{this.onProgress&&this.onProgress(this._waitingTasksCount,this._totalTasksCount,e),this.onProgressObservable.notifyObservers(new Xc(this._waitingTasksCount,this._totalTasksCount,e))}catch(e){p.a.Error("Error running progress callbacks."),console.log(e)}if(0===this._waitingTasksCount){try{this.onFinish&&this.onFinish(this._tasks);for(var t=this._tasks.slice(),i=0,r=t;i<r.length;i++){if((e=r[i]).taskState===Gc.DONE){var n=this._tasks.indexOf(e);n>-1&&this._tasks.splice(n,1)}}this.onTasksDoneObservable.notifyObservers(this._tasks)}catch(e){p.a.Error("Error running tasks-done callbacks."),console.log(e)}this._isLoading=!1,this._scene.getEngine().hideLoadingUI()}},e.prototype._runTask=function(e){var t=this,i=function(i,r){e._setErrorObject(i,r),t.onTaskError&&t.onTaskError(e),t.onTaskErrorObservable.notifyObservers(e),t._decreaseWaitingTasksCount(e)};e.run(this._scene,function(){try{t.onTaskSuccess&&t.onTaskSuccess(e),t.onTaskSuccessObservable.notifyObservers(e),t._decreaseWaitingTasksCount(e)}catch(e){i("Error executing task success callbacks",e)}},i)},e.prototype.reset=function(){return this._isLoading=!1,this._tasks=new Array,this},e.prototype.load=function(){if(this._isLoading)return this;if(this._isLoading=!0,this._waitingTasksCount=this._tasks.length,this._totalTasksCount=this._tasks.length,0===this._waitingTasksCount)return this._isLoading=!1,this.onFinish&&this.onFinish(this._tasks),this.onTasksDoneObservable.notifyObservers(this._tasks),this;this.useDefaultLoadingScreen&&this._scene.getEngine().displayLoadingUI();for(var e=0;e<this._tasks.length;e++){var t=this._tasks[e];t.taskState===Gc.INIT&&this._runTask(t)}return this},e}(),tl=function(){function e(){var e=this;this.promise=new Promise(function(t,i){e._resolve=t,e._reject=i})}return Object.defineProperty(e.prototype,"resolve",{get:function(){return this._resolve},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"reject",{get:function(){return this._reject},enumerable:!0,configurable:!0}),e}(),il=function(){function e(e,t,i,r,n,o,s,a,c){this.onProcessFileCallback=function(){return!0},this._engine=e,this._currentScene=t,this._sceneLoadedCallback=i,this._progressCallback=r,this._additionalRenderLoopLogicCallback=n,this._textureLoadingCallback=o,this._startingProcessingFilesCallback=s,this._onReloadCallback=a,this._errorCallback=c}return Object.defineProperty(e,"FilesToLoad",{get:function(){return or.a.FilesToLoad},enumerable:!0,configurable:!0}),e.prototype.monitorElementForDragNDrop=function(e){var t=this;e&&(this._elementToMonitor=e,this._dragEnterHandler=function(e){t.drag(e)},this._dragOverHandler=function(e){t.drag(e)},this._dropHandler=function(e){t.drop(e)},this._elementToMonitor.addEventListener("dragenter",this._dragEnterHandler,!1),this._elementToMonitor.addEventListener("dragover",this._dragOverHandler,!1),this._elementToMonitor.addEventListener("drop",this._dropHandler,!1))},e.prototype.dispose=function(){this._elementToMonitor&&(this._elementToMonitor.removeEventListener("dragenter",this._dragEnterHandler),this._elementToMonitor.removeEventListener("dragover",this._dragOverHandler),this._elementToMonitor.removeEventListener("drop",this._dropHandler))},e.prototype.renderFunction=function(){if(this._additionalRenderLoopLogicCallback&&this._additionalRenderLoopLogicCallback(),this._currentScene){if(this._textureLoadingCallback){var e=this._currentScene.getWaitingItemsCount();e>0&&this._textureLoadingCallback(e)}this._currentScene.render()}},e.prototype.drag=function(e){e.stopPropagation(),e.preventDefault()},e.prototype.drop=function(e){e.stopPropagation(),e.preventDefault(),this.loadFiles(e)},e.prototype._traverseFolder=function(e,t,i,r){var n=this,o=e.createReader(),s=e.fullPath.replace(/^\//,"").replace(/(.+?)\/?$/,"$1/");o.readEntries(function(e){i.count+=e.length;for(var o=0,a=e;o<a.length;o++){var c=a[o];c.isFile?c.file(function(e){e.correctName=s+e.name,t.push(e),0==--i.count&&r()}):c.isDirectory&&n._traverseFolder(c,t,i,r)}--i.count&&r()})},e.prototype._processFiles=function(t){for(var i=0;i<t.length;i++){var r=t[i].correctName.toLowerCase(),n=r.split(".").pop();this.onProcessFileCallback(t[i],r,n)&&("babylon"!==n&&"stl"!==n&&"obj"!==n&&"gltf"!==n&&"glb"!==n||-1!==r.indexOf(".binary.babylon")||-1!==r.indexOf(".incremental.babylon")||(this._sceneFileToLoad=t[i]),e.FilesToLoad[r]=t[i])}},e.prototype.loadFiles=function(e){var t=this;if(e&&e.dataTransfer&&e.dataTransfer.files&&(this._filesToLoad=e.dataTransfer.files),e&&e.target&&e.target.files&&(this._filesToLoad=e.target.files),this._filesToLoad&&0!==this._filesToLoad.length&&(this._startingProcessingFilesCallback&&this._startingProcessingFilesCallback(this._filesToLoad),this._filesToLoad&&this._filesToLoad.length>0)){for(var i=new Array,r=[],n=e.dataTransfer?e.dataTransfer.items:null,o=0;o<this._filesToLoad.length;o++){var s=this._filesToLoad[o],a=s.name.toLowerCase(),c=void 0;if(s.correctName=a,n){var l=n[o];l.getAsEntry?c=l.getAsEntry():l.webkitGetAsEntry&&(c=l.webkitGetAsEntry())}c&&c.isDirectory?r.push(c):i.push(s)}if(0===r.length)this._processFiles(i),this._processReload();else for(var u={count:r.length},h=0,d=r;h<d.length;h++){var f=d[h];this._traverseFolder(f,i,u,function(){t._processFiles(i),0===u.count&&t._processReload()})}}},e.prototype._processReload=function(){this._onReloadCallback?this._onReloadCallback(this._sceneFileToLoad):this.reload()},e.prototype.reload=function(){var e=this;this._sceneFileToLoad?(this._currentScene&&(p.a.errorsCount>0&&p.a.ClearLogCache(),this._engine.stopRenderLoop()),cr.LoadAsync("file:",this._sceneFileToLoad,this._engine,function(t){e._progressCallback&&e._progressCallback(t)}).then(function(t){e._currentScene&&e._currentScene.dispose(),e._currentScene=t,e._sceneLoadedCallback&&e._sceneLoadedCallback(e._sceneFileToLoad,e._currentScene),e._currentScene.executeWhenReady(function(){e._engine.runRenderLoop(function(){e.renderFunction()})})}).catch(function(t){e._errorCallback&&e._errorCallback(e._sceneFileToLoad,e._currentScene,t.message)})):p.a.Error("Please provide a valid .babylon file.")},e}(),rl=i(100),nl=i(101),ol=function(){function e(e){void 0===e&&(e=0),this.priority=e}return e.prototype.getDescription=function(){return""},e.prototype.apply=function(e,t){return!0},e}(),sl=function(e){function t(t,i,r){void 0===t&&(t=0),void 0===i&&(i=1024),void 0===r&&(r=.5);var n=e.call(this,t)||this;return n.priority=t,n.maximumSize=i,n.step=r,n}return l.d(t,e),t.prototype.getDescription=function(){return"Reducing render target texture size to "+this.maximumSize},t.prototype.apply=function(e,t){for(var i=!0,r=0;r<e.textures.length;r++){var n=e.textures[r];if(n.canRescale&&!n.getContext){var o=n.getSize();Math.max(o.width,o.height)>this.maximumSize&&(n.scale(this.step),i=!1)}}return i},t}(ol),al=function(e){function t(t,i,r){void 0===t&&(t=0),void 0===i&&(i=2),void 0===r&&(r=.25);var n=e.call(this,t)||this;return n.priority=t,n.maximumScale=i,n.step=r,n._currentScale=-1,n._directionOffset=1,n}return l.d(t,e),t.prototype.getDescription=function(){return"Setting hardware scaling level to "+this._currentScale},t.prototype.apply=function(e,t){return-1===this._currentScale&&(this._currentScale=e.getEngine().getHardwareScalingLevel(),this._currentScale>this.maximumScale&&(this._directionOffset=-1)),this._currentScale+=this._directionOffset*this.step,e.getEngine().setHardwareScalingLevel(this._currentScale),1===this._directionOffset?this._currentScale>=this.maximumScale:this._currentScale<=this.maximumScale},t}(ol),cl=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return l.d(t,e),t.prototype.getDescription=function(){return"Turning shadows on/off"},t.prototype.apply=function(e,t){return e.shadowsEnabled=t.isInImprovementMode,!0},t}(ol),ll=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return l.d(t,e),t.prototype.getDescription=function(){return"Turning post-processes on/off"},t.prototype.apply=function(e,t){return e.postProcessesEnabled=t.isInImprovementMode,!0},t}(ol),ul=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return l.d(t,e),t.prototype.getDescription=function(){return"Turning lens flares on/off"},t.prototype.apply=function(e,t){return e.lensFlaresEnabled=t.isInImprovementMode,!0},t}(ol),hl=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return l.d(t,e),t.prototype.getDescription=function(){return this.onGetDescription?this.onGetDescription():"Running user defined callback"},t.prototype.apply=function(e,t){return!this.onApply||this.onApply(e,t)},t}(ol),dl=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return l.d(t,e),t.prototype.getDescription=function(){return"Turning particles on/off"},t.prototype.apply=function(e,t){return e.particlesEnabled=t.isInImprovementMode,!0},t}(ol),fl=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return l.d(t,e),t.prototype.getDescription=function(){return"Turning render targets off"},t.prototype.apply=function(e,t){return e.renderTargetsEnabled=t.isInImprovementMode,!0},t}(ol),pl=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._canBeMerged=function(e){if(!(e instanceof de.a))return!1;var t=e;return!t.isDisposed()&&(!(!t.isVisible||!t.isEnabled())&&(!(t.instances.length>0)&&(!t.skeleton&&!t.hasLODLevels)))},t}return l.d(t,e),Object.defineProperty(t,"UpdateSelectionTree",{get:function(){return t._UpdateSelectionTree},set:function(e){t._UpdateSelectionTree=e},enumerable:!0,configurable:!0}),t.prototype.getDescription=function(){return"Merging similar meshes together"},t.prototype.apply=function(e,i,r){for(var n=e.meshes.slice(0),o=n.length,s=0;s<o;s++){var a=new Array,c=n[s];if(this._canBeMerged(c)){a.push(c);for(var l=s+1;l<o;l++){var u=n[l];this._canBeMerged(u)&&(u.material===c.material&&u.checkCollisions===c.checkCollisions&&(a.push(u),o--,n.splice(l,1),l--))}a.length<2||de.a.MergeMeshes(a,void 0,!0)}}var h=e;return h.createOrUpdateSelectionOctree&&(null!=r?r&&h.createOrUpdateSelectionOctree():t.UpdateSelectionTree&&h.createOrUpdateSelectionOctree()),!0},t._UpdateSelectionTree=!1,t}(ol),_l=function(){function e(e,t){void 0===e&&(e=60),void 0===t&&(t=2e3),this.targetFrameRate=e,this.trackerDuration=t,this.optimizations=new Array}return e.prototype.addOptimization=function(e){return this.optimizations.push(e),this},e.prototype.addCustomOptimization=function(e,t,i){void 0===i&&(i=0);var r=new hl(i);return r.onApply=e,r.onGetDescription=t,this.optimizations.push(r),this},e.LowDegradationAllowed=function(t){var i=new e(t),r=0;return i.addOptimization(new pl(r)),i.addOptimization(new cl(r)),i.addOptimization(new ul(r)),r++,i.addOptimization(new ll(r)),i.addOptimization(new dl(r)),r++,i.addOptimization(new sl(r,1024)),i},e.ModerateDegradationAllowed=function(t){var i=new e(t),r=0;return i.addOptimization(new pl(r)),i.addOptimization(new cl(r)),i.addOptimization(new ul(r)),r++,i.addOptimization(new ll(r)),i.addOptimization(new dl(r)),r++,i.addOptimization(new sl(r,512)),r++,i.addOptimization(new fl(r)),r++,i.addOptimization(new al(r,2)),i},e.HighDegradationAllowed=function(t){var i=new e(t),r=0;return i.addOptimization(new pl(r)),i.addOptimization(new cl(r)),i.addOptimization(new ul(r)),r++,i.addOptimization(new ll(r)),i.addOptimization(new dl(r)),r++,i.addOptimization(new sl(r,256)),r++,i.addOptimization(new fl(r)),r++,i.addOptimization(new al(r,4)),i},e}(),gl=function(){function e(e,t,i,r){void 0===i&&(i=!0),void 0===r&&(r=!1);var o=this;if(this._isRunning=!1,this._currentPriorityLevel=0,this._targetFrameRate=60,this._trackerDuration=2e3,this._currentFrameRate=0,this._improvementMode=!1,this.onSuccessObservable=new n.c,this.onNewOptimizationAppliedObservable=new n.c,this.onFailureObservable=new n.c,this._options=t||new _l,this._options.targetFrameRate&&(this._targetFrameRate=this._options.targetFrameRate),this._options.trackerDuration&&(this._trackerDuration=this._options.trackerDuration),i)for(var s=0,a=0,c=this._options.optimizations;a<c.length;a++){c[a].priority=s++}this._improvementMode=r,this._scene=e||R.a.LastCreatedScene,this._sceneDisposeObserver=this._scene.onDisposeObservable.add(function(){o._sceneDisposeObserver=null,o.dispose()})}return Object.defineProperty(e.prototype,"isInImprovementMode",{get:function(){return this._improvementMode},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"currentPriorityLevel",{get:function(){return this._currentPriorityLevel},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"currentFrameRate",{get:function(){return this._currentFrameRate},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"targetFrameRate",{get:function(){return this._targetFrameRate},set:function(e){this._targetFrameRate=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"trackerDuration",{get:function(){return this._trackerDuration},set:function(e){this._trackerDuration=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"optimizations",{get:function(){return this._options.optimizations},enumerable:!0,configurable:!0}),e.prototype.stop=function(){this._isRunning=!1},e.prototype.reset=function(){this._currentPriorityLevel=0},e.prototype.start=function(){var e=this;this._isRunning||(this._isRunning=!0,this._scene.executeWhenReady(function(){setTimeout(function(){e._checkCurrentState()},e._trackerDuration)}))},e.prototype._checkCurrentState=function(){var e=this;if(this._isRunning){var t=this._scene,i=this._options;if(this._currentFrameRate=Math.round(t.getEngine().getFps()),this._improvementMode&&this._currentFrameRate<=this._targetFrameRate||!this._improvementMode&&this._currentFrameRate>=this._targetFrameRate)return this._isRunning=!1,void this.onSuccessObservable.notifyObservers(this);for(var r=!0,n=!0,o=0;o<i.optimizations.length;o++){var s=i.optimizations[o];s.priority===this._currentPriorityLevel&&(n=!1,r=r&&s.apply(t,this),this.onNewOptimizationAppliedObservable.notifyObservers(s))}if(n)return this._isRunning=!1,void this.onFailureObservable.notifyObservers(this);r&&this._currentPriorityLevel++,t.executeWhenReady(function(){setTimeout(function(){e._checkCurrentState()},e._trackerDuration)})}},e.prototype.dispose=function(){this.stop(),this.onSuccessObservable.clear(),this.onFailureObservable.clear(),this.onNewOptimizationAppliedObservable.clear(),this._sceneDisposeObserver&&this._scene.onDisposeObservable.remove(this._sceneDisposeObserver)},e.OptimizeAsync=function(t,i,r,n){var o=new e(t,i||_l.ModerateDegradationAllowed(),!1);return r&&o.onSuccessObservable.add(function(){r()}),n&&o.onFailureObservable.add(function(){n()}),o.start(),o},e}(),ml=[],vl=function(e,t){ml[e.id]||e.doNotSerialize||(t.vertexData.push(e.serializeVerticeData()),ml[e.id]=!0)},yl=function(e,t){var i={},r=e._geometry;return r&&(e.getScene().getGeometryByID(r.id)||vl(r,t.geometries)),e.serialize&&e.serialize(i),i},bl=function(){function e(){}return e.ClearCache=function(){ml=[]},e.Serialize=function(t){var i,r,n,o={};if(e.ClearCache(),o.useDelayedTextureLoading=t.useDelayedTextureLoading,o.autoClear=t.autoClear,o.clearColor=t.clearColor.asArray(),o.ambientColor=t.ambientColor.asArray(),o.gravity=t.gravity.asArray(),o.collisionsEnabled=t.collisionsEnabled,t.fogMode&&0!==t.fogMode&&(o.fogMode=t.fogMode,o.fogColor=t.fogColor.asArray(),o.fogStart=t.fogStart,o.fogEnd=t.fogEnd,o.fogDensity=t.fogDensity),t.isPhysicsEnabled()){var s=t.getPhysicsEngine();s&&(o.physicsEnabled=!0,o.physicsGravity=s.gravity.asArray(),o.physicsEngine=s.getPhysicsPluginName())}t.metadata&&(o.metadata=t.metadata),o.morphTargetManagers=[];for(var a=0,c=t.meshes;a<c.length;a++){var l=(m=c[a]).morphTargetManager;l&&o.morphTargetManagers.push(l.serialize())}for(o.lights=[],i=0;i<t.lights.length;i++)(r=t.lights[i]).doNotSerialize||o.lights.push(r.serialize());for(o.cameras=[],i=0;i<t.cameras.length;i++){var u=t.cameras[i];u.doNotSerialize||o.cameras.push(u.serialize())}if(t.activeCamera&&(o.activeCameraID=t.activeCamera.id),w.a.AppendSerializedAnimations(t,o),t.reflectionProbes&&t.reflectionProbes.length>0)for(o.reflectionProbes=[],i=0;i<t.reflectionProbes.length;i++){var h=t.reflectionProbes[i];o.reflectionProbes.push(h.serialize())}for(o.materials=[],o.multiMaterials=[],i=0;i<t.materials.length;i++)(n=t.materials[i]).doNotSerialize||o.materials.push(n.serialize());for(o.multiMaterials=[],i=0;i<t.multiMaterials.length;i++){var d=t.multiMaterials[i];o.multiMaterials.push(d.serialize())}for(t.environmentTexture&&(o.environmentTexture=t.environmentTexture.name),o.skeletons=[],i=0;i<t.skeletons.length;i++){var f=t.skeletons[i];f.doNotSerialize||o.skeletons.push(f.serialize())}for(o.transformNodes=[],i=0;i<t.transformNodes.length;i++)o.transformNodes.push(t.transformNodes[i].serialize());o.geometries={},o.geometries.boxes=[],o.geometries.spheres=[],o.geometries.cylinders=[],o.geometries.toruses=[],o.geometries.grounds=[],o.geometries.planes=[],o.geometries.torusKnots=[],o.geometries.vertexData=[],ml=[];var p=t.getGeometries();for(i=0;i<p.length;i++){var g=p[i];g.isReady()&&vl(g,o.geometries)}for(o.meshes=[],i=0;i<t.meshes.length;i++){var m;if((m=t.meshes[i])instanceof de.a){var v=m;v.doNotSerialize||v.delayLoadState!==_.a.DELAYLOADSTATE_LOADED&&v.delayLoadState!==_.a.DELAYLOADSTATE_NONE||o.meshes.push(yl(v,o))}}for(o.particleSystems=[],i=0;i<t.particleSystems.length;i++)o.particleSystems.push(t.particleSystems[i].serialize());t.actionManager&&(o.actions=t.actionManager.serialize("scene"));for(var y=0,b=t._serializableComponents;y<b.length;y++){b[y].serialize(o)}return o},e.SerializeMesh=function(t,i,r){void 0===i&&(i=!1),void 0===r&&(r=!1);var n={};if(e.ClearCache(),t=t instanceof Array?t:[t],i||r)for(var o=0;o<t.length;++o)r&&t[o].getDescendants().forEach(function(e){e instanceof de.a&&t.indexOf(e)<0&&t.push(e)}),i&&t[o].parent&&t.indexOf(t[o].parent)<0&&t.push(t[o].parent);return t.forEach(function(e){!function(e,t){if(e.delayLoadState===_.a.DELAYLOADSTATE_LOADED||e.delayLoadState===_.a.DELAYLOADSTATE_NONE){if(e.material)if(e.material instanceof Zn){if(t.multiMaterials=t.multiMaterials||[],t.materials=t.materials||[],!t.multiMaterials.some(function(t){return t.id===e.material.id})){t.multiMaterials.push(e.material.serialize());for(var i=function(e){e&&(t.materials.some(function(t){return t.id===e.id})||t.materials.push(e.serialize()))},r=0,n=e.material.subMaterials;r<n.length;r++)i(n[r])}}else t.materials=t.materials||[],t.materials.some(function(t){return t.id===e.material.id})||t.materials.push(e.material.serialize());var o=e._geometry;o&&(t.geometries||(t.geometries={},t.geometries.boxes=[],t.geometries.spheres=[],t.geometries.cylinders=[],t.geometries.toruses=[],t.geometries.grounds=[],t.geometries.planes=[],t.geometries.torusKnots=[],t.geometries.vertexData=[]),vl(o,t.geometries)),e.skeleton&&(t.skeletons=t.skeletons||[],t.skeletons.push(e.skeleton.serialize())),t.meshes=t.meshes||[],t.meshes.push(yl(e,t))}}(e,n)}),n},e}(),Tl=function(){function e(t,i){if(void 0===i&&(i=null),!e.IsSupported(t))throw"Your browser does not support recording so far.";var r=t.getRenderingCanvas();if(!r)throw"The babylon engine must have a canvas to be recorded";this._canvas=r,this._canvas.isRecording=!1,this._options=l.a({},e._defaultOptions,i);var n=this._canvas.captureStream(this._options.fps);this._mediaRecorder=new MediaRecorder(n,{mimeType:this._options.mimeType}),this._mediaRecorder.ondataavailable=this._handleDataAvailable.bind(this),this._mediaRecorder.onerror=this._handleError.bind(this),this._mediaRecorder.onstop=this._handleStop.bind(this)}return e.IsSupported=function(e){var t=e.getRenderingCanvas();return!!t&&"function"==typeof t.captureStream},Object.defineProperty(e.prototype,"isRecording",{get:function(){return!!this._canvas&&this._canvas.isRecording},enumerable:!0,configurable:!0}),e.prototype.stopRecording=function(){this._canvas&&this._mediaRecorder&&this.isRecording&&(this._canvas.isRecording=!1,this._mediaRecorder.stop())},e.prototype.startRecording=function(e,t){var i=this;if(void 0===e&&(e="babylonjs.webm"),void 0===t&&(t=7),!this._canvas||!this._mediaRecorder)throw"Recorder has already been disposed";if(this.isRecording)throw"Recording already in progress";return t>0&&setTimeout(function(){i.stopRecording()},1e3*t),this._fileName=e,this._recordedChunks=[],this._resolve=null,this._reject=null,this._canvas.isRecording=!0,this._mediaRecorder.start(this._options.recordChunckSize),new Promise(function(e,t){i._resolve=e,i._reject=t})},e.prototype.dispose=function(){this._canvas=null,this._mediaRecorder=null,this._recordedChunks=[],this._fileName=null,this._resolve=null,this._reject=null},e.prototype._handleDataAvailable=function(e){e.data.size>0&&this._recordedChunks.push(e.data)},e.prototype._handleError=function(e){if(this.stopRecording(),!this._reject)throw new e.error;this._reject(e.error)},e.prototype._handleStop=function(){this.stopRecording();var e=new Blob(this._recordedChunks);this._resolve&&this._resolve(e),window.URL.createObjectURL(e),this._fileName&&ve.h.Download(e,this._fileName)},e._defaultOptions={mimeType:"video/webm",fps:25,recordChunckSize:3e3},e}(),El=function(){function e(e){this._pendingActions=new Array,this._workerInfos=e.map(function(e){return{worker:e,active:!1}})}return e.prototype.dispose=function(){for(var e=0,t=this._workerInfos;e<t.length;e++){t[e].worker.terminate()}delete this._workerInfos,delete this._pendingActions},e.prototype.push=function(e){for(var t=0,i=this._workerInfos;t<i.length;t++){var r=i[t];if(!r.active)return void this._execute(r,e)}this._pendingActions.push(e)},e.prototype._execute=function(e,t){var i=this;e.active=!0,t(e.worker,function(){e.active=!1;var t=i._pendingActions.shift();t&&i._execute(e,t)})},e}(),xl=function(){function e(){}return e.CreateScreenshot=function(e,t,i,r,n){var o,s;if(void 0===n&&(n="image/png"),i.precision)o=Math.round(e.getRenderWidth()*i.precision),s=Math.round(o/e.getAspectRatio(t));else if(i.width&&i.height)o=i.width,s=i.height;else if(i.width&&!i.height)o=i.width,s=Math.round(o/e.getAspectRatio(t));else if(i.height&&!i.width)s=i.height,o=Math.round(s*e.getAspectRatio(t));else{if(isNaN(i))return void p.a.Error("Invalid 'size' parameter !");s=i,o=i}Wc||(Wc=document.createElement("canvas")),Wc.width=o,Wc.height=s;var a=Wc.getContext("2d"),c=e.getRenderWidth()/e.getRenderHeight(),l=o,u=l/c;u>s&&(l=(u=s)*c);var h=Math.max(0,o-l)/2,d=Math.max(0,s-u)/2,f=e.getRenderingCanvas();a&&f&&a.drawImage(f,h,d,l,u),ve.h.EncodeScreenshotCanvasData(r,n)},e.CreateScreenshotUsingRenderTarget=function(e,t,i,r,n,o,s,a){var c,l;if(void 0===n&&(n="image/png"),void 0===o&&(o=1),void 0===s&&(s=!1),i.precision)c=Math.round(e.getRenderWidth()*i.precision),l=Math.round(c/e.getAspectRatio(t)),i={width:c,height:l};else if(i.width&&i.height)c=i.width,l=i.height;else if(i.width&&!i.height)c=i.width,l=Math.round(c/e.getAspectRatio(t)),i={width:c,height:l};else if(i.height&&!i.width)l=i.height,i={width:c=Math.round(l*e.getAspectRatio(t)),height:l};else{if(isNaN(i))return void p.a.Error("Invalid 'size' parameter !");l=i,c=i}var u=t.getScene(),h=null;u.activeCamera!==t&&(h=u.activeCamera,u.activeCamera=t);var d=e.getRenderingCanvas();if(d){var f={width:d.width,height:d.height};e.setSize(c,l),u.render();var g=new Mi("screenShot",i,u,!1,!1,_.a.TEXTURETYPE_UNSIGNED_INT,!1,Ve.a.NEAREST_SAMPLINGMODE);g.renderList=null,g.samples=o,s&&g.addPostProcess(new ka("antialiasing",1,u.activeCamera)),g.onAfterRenderObservable.add(function(){ve.h.DumpFramebuffer(c,l,e,r,n,a)}),u.incrementRenderId(),u.resetCachedMaterial(),g.render(!0),g.dispose(),h&&(u.activeCamera=h),e.setSize(f.width,f.height),t.getProjectionMatrix(!0)}else p.a.Error("No rendering canvas found !")},e}();ve.h.CreateScreenshot=xl.CreateScreenshot,ve.h.CreateScreenshotUsingRenderTarget=xl.CreateScreenshotUsingRenderTarget,i.d(t,"AbstractScene",function(){return r.a}),i.d(t,"Action",function(){return a}),i.d(t,"ActionEvent",function(){return c.a}),i.d(t,"ActionManager",function(){return C}),i.d(t,"Condition",function(){return u}),i.d(t,"ValueCondition",function(){return h}),i.d(t,"PredicateCondition",function(){return d}),i.d(t,"StateCondition",function(){return f}),i.d(t,"SwitchBooleanAction",function(){return g}),i.d(t,"SetStateAction",function(){return m}),i.d(t,"SetValueAction",function(){return v}),i.d(t,"IncrementValueAction",function(){return y}),i.d(t,"PlayAnimationAction",function(){return b}),i.d(t,"StopAnimationAction",function(){return T}),i.d(t,"DoNothingAction",function(){return E}),i.d(t,"CombineAction",function(){return x}),i.d(t,"ExecuteCodeAction",function(){return A}),i.d(t,"SetParentAction",function(){return P}),i.d(t,"PlaySoundAction",function(){return M}),i.d(t,"StopSoundAction",function(){return O}),i.d(t,"InterpolateValueAction",function(){return B}),i.d(t,"Animatable",function(){return K}),i.d(t,"Animation",function(){return N}),i.d(t,"TargetedAnimation",function(){return Q}),i.d(t,"AnimationGroup",function(){return q}),i.d(t,"AnimationPropertiesOverride",function(){return Z}),i.d(t,"EasingFunction",function(){return J}),i.d(t,"CircleEase",function(){return $}),i.d(t,"BackEase",function(){return ee}),i.d(t,"BounceEase",function(){return te}),i.d(t,"CubicEase",function(){return ie}),i.d(t,"ElasticEase",function(){return re}),i.d(t,"ExponentialEase",function(){return ne}),i.d(t,"PowerEase",function(){return oe}),i.d(t,"QuadraticEase",function(){return se}),i.d(t,"QuarticEase",function(){return ae}),i.d(t,"QuinticEase",function(){return ce}),i.d(t,"SineEase",function(){return le}),i.d(t,"BezierCurveEase",function(){return ue}),i.d(t,"RuntimeAnimation",function(){return j}),i.d(t,"AnimationEvent",function(){return he}),i.d(t,"AnimationKeyInterpolation",function(){return I}),i.d(t,"AnimationRange",function(){return L}),i.d(t,"KeepAssets",function(){return fe}),i.d(t,"AssetContainer",function(){return pe}),i.d(t,"Analyser",function(){return ge}),i.d(t,"AudioEngine",function(){return me}),i.d(t,"AudioSceneComponent",function(){return Ee}),i.d(t,"Sound",function(){return ye}),i.d(t,"SoundTrack",function(){return be}),i.d(t,"WeightedSound",function(){return xe}),i.d(t,"AutoRotationBehavior",function(){return Pe}),i.d(t,"BouncingBehavior",function(){return Re}),i.d(t,"FramingBehavior",function(){return Se}),i.d(t,"AttachToBoxBehavior",function(){return Me}),i.d(t,"FadeInOutBehavior",function(){return Oe}),i.d(t,"MultiPointerScaleBehavior",function(){return De}),i.d(t,"PointerDragBehavior",function(){return Ie.a}),i.d(t,"SixDofDragBehavior",function(){return Ne}),i.d(t,"Bone",function(){return Y}),i.d(t,"BoneIKController",function(){return Be}),i.d(t,"BoneLookController",function(){return Ue}),i.d(t,"Skeleton",function(){return ke}),i.d(t,"CameraInputTypes",function(){return ze}),i.d(t,"CameraInputsManager",function(){return je}),i.d(t,"Camera",function(){return Le.a}),i.d(t,"TargetCamera",function(){return dt}),i.d(t,"FreeCamera",function(){return ft}),i.d(t,"FreeCameraInputsManager",function(){return ot}),i.d(t,"TouchCamera",function(){return pt}),i.d(t,"ArcRotateCamera",function(){return _t}),i.d(t,"ArcRotateCameraInputsManager",function(){return Je}),i.d(t,"DeviceOrientationCamera",function(){return gt}),i.d(t,"FlyCamera",function(){return vt}),i.d(t,"FlyCameraInputsManager",function(){return mt}),i.d(t,"FollowCamera",function(){return Et}),i.d(t,"ArcFollowCamera",function(){return xt}),i.d(t,"GamepadCamera",function(){return Pt}),i.d(t,"UniversalCamera",function(){return At}),i.d(t,"VirtualJoysticksCamera",function(){return Xt}),i.d(t,"ArcRotateCameraGamepadInput",function(){return Ye}),i.d(t,"ArcRotateCameraKeyboardMoveInput",function(){return Qe}),i.d(t,"ArcRotateCameraMouseWheelInput",function(){return qe}),i.d(t,"ArcRotateCameraPointersInput",function(){return Ze}),i.d(t,"ArcRotateCameraVRDeviceOrientationInput",function(){return $e}),i.d(t,"FlyCameraKeyboardInput",function(){return et}),i.d(t,"FlyCameraMouseInput",function(){return tt}),i.d(t,"FreeCameraDeviceOrientationInput",function(){return st}),i.d(t,"FreeCameraGamepadInput",function(){return at}),i.d(t,"FreeCameraKeyboardMoveInput",function(){return it}),i.d(t,"FreeCameraMouseInput",function(){return rt}),i.d(t,"FreeCameraTouchInput",function(){return nt}),i.d(t,"FreeCameraVirtualJoystickInput",function(){return ht}),i.d(t,"AnaglyphArcRotateCamera",function(){return Nt}),i.d(t,"AnaglyphFreeCamera",function(){return Bt}),i.d(t,"AnaglyphGamepadCamera",function(){return Ut}),i.d(t,"AnaglyphUniversalCamera",function(){return Vt}),i.d(t,"StereoscopicArcRotateCamera",function(){return zt}),i.d(t,"StereoscopicFreeCamera",function(){return jt}),i.d(t,"StereoscopicGamepadCamera",function(){return Wt}),i.d(t,"StereoscopicUniversalCamera",function(){return Ht}),i.d(t,"VRCameraMetrics",function(){return Yt}),i.d(t,"VRDeviceOrientationArcRotateCamera",function(){return qt}),i.d(t,"VRDeviceOrientationFreeCamera",function(){return Zt}),i.d(t,"VRDeviceOrientationGamepadCamera",function(){return $t}),i.d(t,"VRExperienceHelper",function(){return Ai}),i.d(t,"WebVRFreeCamera",function(){return ai}),i.d(t,"WebXRCamera",function(){return Pi}),i.d(t,"WebXREnterExitUIButton",function(){return Li}),i.d(t,"WebXREnterExitUIOptions",function(){return Fi}),i.d(t,"WebXREnterExitUI",function(){return Ni}),i.d(t,"WebXRState",function(){return Oi}),i.d(t,"WebXRExperienceHelper",function(){return wi}),i.d(t,"WebXRController",function(){return Bi}),i.d(t,"WebXRInput",function(){return Ui}),i.d(t,"WebXRManagedOutputCanvas",function(){return Vi}),i.d(t,"WebXRSessionManager",function(){return Ii}),i.d(t,"Collider",function(){return ki}),i.d(t,"DefaultCollisionCoordinator",function(){return zi}),i.d(t,"PickingInfo",function(){return ji.a}),i.d(t,"IntersectionInfo",function(){return Wi.a}),i.d(t,"BoundingBox",function(){return Hi.a}),i.d(t,"BoundingInfo",function(){return Xi.a}),i.d(t,"BoundingSphere",function(){return Yi.a}),i.d(t,"Ray",function(){return ei.a}),i.d(t,"Octree",function(){return Qi}),i.d(t,"OctreeBlock",function(){return Ki}),i.d(t,"OctreeSceneComponent",function(){return qi}),i.d(t,"AxesViewer",function(){return Zi.AxesViewer}),i.d(t,"BoneAxesViewer",function(){return Zi.BoneAxesViewer}),i.d(t,"DebugLayer",function(){return Zi.DebugLayer}),i.d(t,"PhysicsViewer",function(){return Zi.PhysicsViewer}),i.d(t,"RayHelper",function(){return Zi.RayHelper}),i.d(t,"SkeletonViewer",function(){return Zi.SkeletonViewer}),i.d(t,"Constants",function(){return _.a}),i.d(t,"InstancingAttributeInfo",function(){return _e.d}),i.d(t,"DepthTextureCreationOptions",function(){return _e.a}),i.d(t,"EngineCapabilities",function(){return _e.c}),i.d(t,"Engine",function(){return _e.b}),i.d(t,"EngineStore",function(){return R.a}),i.d(t,"NullEngineOptions",function(){return $i}),i.d(t,"NullEngine",function(){return er}),i.d(t,"_OcclusionDataStorage",function(){return ir}),i.d(t,"_forceTransformFeedbackToBundle",function(){return!0}),i.d(t,"KeyboardEventTypes",function(){return Ke.a}),i.d(t,"KeyboardInfo",function(){return Ke.b}),i.d(t,"KeyboardInfoPre",function(){return Ke.c}),i.d(t,"PointerEventTypes",function(){return Ae.a}),i.d(t,"PointerInfoBase",function(){return Ae.c}),i.d(t,"PointerInfoPre",function(){return Ae.d}),i.d(t,"PointerInfo",function(){return Ae.b}),i.d(t,"ClipboardEventTypes",function(){return rr}),i.d(t,"ClipboardInfo",function(){return nr}),i.d(t,"DaydreamController",function(){return lr}),i.d(t,"GearVRController",function(){return ur}),i.d(t,"GenericController",function(){return hr}),i.d(t,"OculusTouchController",function(){return dr}),i.d(t,"PoseEnabledControllerType",function(){return Jt}),i.d(t,"PoseEnabledControllerHelper",function(){return ti}),i.d(t,"PoseEnabledController",function(){return ii}),i.d(t,"ViveController",function(){return fr}),i.d(t,"WebVRController",function(){return ci}),i.d(t,"WindowsMotionController",function(){return _r}),i.d(t,"StickValues",function(){return We}),i.d(t,"Gamepad",function(){return He}),i.d(t,"GenericPad",function(){return Xe}),i.d(t,"GamepadManager",function(){return mr}),i.d(t,"GamepadSystemSceneComponent",function(){return vr}),i.d(t,"Xbox360Button",function(){return oi}),i.d(t,"Xbox360Dpad",function(){return si}),i.d(t,"Xbox360Pad",function(){return li}),i.d(t,"AxisDragGizmo",function(){return yr.a}),i.d(t,"AxisScaleGizmo",function(){return Ar}),i.d(t,"BoundingBoxGizmo",function(){return Rr}),i.d(t,"Gizmo",function(){return Er.a}),i.d(t,"GizmoManager",function(){return Dr}),i.d(t,"PlaneRotationGizmo",function(){return Sr}),i.d(t,"PositionGizmo",function(){return Mr}),i.d(t,"RotationGizmo",function(){return Cr}),i.d(t,"ScaleGizmo",function(){return Ir}),i.d(t,"EnvironmentHelper",function(){return $r}),i.d(t,"PhotoDome",function(){return tn}),i.d(t,"_forceSceneHelpersToBundle",function(){return!0}),i.d(t,"VideoDome",function(){return gn}),i.d(t,"EngineInstrumentation",function(){return mn}),i.d(t,"SceneInstrumentation",function(){return vn}),i.d(t,"_TimeToken",function(){return tr}),i.d(t,"EffectLayer",function(){return En}),i.d(t,"EffectLayerSceneComponent",function(){return xn}),i.d(t,"GlowLayer",function(){return Rn}),i.d(t,"HighlightLayer",function(){return Mn}),i.d(t,"Layer",function(){return wn}),i.d(t,"LayerSceneComponent",function(){return On}),i.d(t,"LensFlare",function(){return Ln}),i.d(t,"LensFlareSystem",function(){return Bn}),i.d(t,"LensFlareSystemSceneComponent",function(){return Un}),i.d(t,"Light",function(){return ri.a}),i.d(t,"ShadowLight",function(){return Vn}),i.d(t,"DirectionalLight",function(){return Hn}),i.d(t,"HemisphericLight",function(){return ni}),i.d(t,"PointLight",function(){return Xn}),i.d(t,"SpotLight",function(){return Yn}),i.d(t,"ShadowGenerator",function(){return jn}),i.d(t,"ShadowGeneratorSceneComponent",function(){return Wn}),i.d(t,"DefaultLoadingScreen",function(){return Kn}),i.d(t,"SceneLoaderProgressEvent",function(){return ar}),i.d(t,"SceneLoader",function(){return cr}),i.d(t,"SceneLoaderFlags",function(){return sr.a}),i.d(t,"_BabylonLoaderRegistered",function(){return!0}),i.d(t,"ColorCurves",function(){return _o.a}),i.d(t,"EffectFallbacks",function(){return St.c}),i.d(t,"EffectCreationOptions",function(){return St.b}),i.d(t,"Effect",function(){return St.a}),i.d(t,"FresnelParameters",function(){return go}),i.d(t,"ImageProcessingConfigurationDefines",function(){return ui.b}),i.d(t,"ImageProcessingConfiguration",function(){return ui.a}),i.d(t,"Material",function(){return yn.a}),i.d(t,"MaterialDefines",function(){return zr.a}),i.d(t,"MaterialHelper",function(){return kr.a}),i.d(t,"MultiMaterial",function(){return Zn}),i.d(t,"PushMaterial",function(){return jr.a}),i.d(t,"ShaderMaterial",function(){return bo.a}),i.d(t,"StandardMaterialDefines",function(){return hi.b}),i.d(t,"StandardMaterial",function(){return hi.a}),i.d(t,"BaseTexture",function(){return wr.a}),i.d(t,"CubeTexture",function(){return Gr}),i.d(t,"HDRCubeTexture",function(){return to}),i.d(t,"InternalTexture",function(){return Ri.a}),i.d(t,"DummyInternalTextureTracker",function(){return Eo.a}),i.d(t,"MirrorTexture",function(){return Vr}),i.d(t,"MultiRenderTarget",function(){return Vo}),i.d(t,"RawTexture",function(){return Ge}),i.d(t,"RenderTargetTexture",function(){return Mi}),i.d(t,"Texture",function(){return Ve.a}),i.d(t,"UniformBuffer",function(){return Qo.a}),i.d(t,"MaterialFlags",function(){return Wr.a}),i.d(t,"BackgroundMaterial",function(){return Zr}),i.d(t,"PBRBaseMaterial",function(){return fn}),i.d(t,"PBRBaseSimpleMaterial",function(){return mo}),i.d(t,"PBRMaterial",function(){return pn}),i.d(t,"PBRMetallicRoughnessMaterial",function(){return vo}),i.d(t,"PBRSpecularGlossinessMaterial",function(){return yo}),i.d(t,"ColorGradingTexture",function(){return To}),i.d(t,"DynamicTexture",function(){return di}),i.d(t,"ProceduralTexture",function(){return zo}),i.d(t,"RawCubeTexture",function(){return Xo}),i.d(t,"RawTexture3D",function(){return Yo}),i.d(t,"RefractionTexture",function(){return Ko}),i.d(t,"VideoTexture",function(){return _n}),i.d(t,"_DDSTextureLoader",function(){return Oo}),i.d(t,"_ENVTextureLoader",function(){return Lo}),i.d(t,"_KTXTextureLoader",function(){return No}),i.d(t,"_TGATextureLoader",function(){return Uo}),i.d(t,"CustomProceduralTexture",function(){return jo}),i.d(t,"NoiseProceduralTexture",function(){return Ho}),i.d(t,"ProceduralTextureSceneComponent",function(){return Go}),i.d(t,"Scalar",function(){return D.a}),i.d(t,"ToGammaSpace",function(){return o.u}),i.d(t,"ToLinearSpace",function(){return o.v}),i.d(t,"Epsilon",function(){return o.h}),i.d(t,"Color3",function(){return o.e}),i.d(t,"Color4",function(){return o.f}),i.d(t,"Vector2",function(){return o.w}),i.d(t,"Vector3",function(){return o.x}),i.d(t,"Vector4",function(){return o.y}),i.d(t,"Size",function(){return o.r}),i.d(t,"Quaternion",function(){return o.q}),i.d(t,"Matrix",function(){return o.j}),i.d(t,"Plane",function(){return o.n}),i.d(t,"Viewport",function(){return o.z}),i.d(t,"Frustum",function(){return o.i}),i.d(t,"Space",function(){return o.s}),i.d(t,"Axis",function(){return o.c}),i.d(t,"BezierCurve",function(){return o.d}),i.d(t,"Orientation",function(){return o.k}),i.d(t,"Angle",function(){return o.a}),i.d(t,"Arc2",function(){return o.b}),i.d(t,"Path2",function(){return o.l}),i.d(t,"Path3D",function(){return o.m}),i.d(t,"Curve3",function(){return o.g}),i.d(t,"PositionNormalVertex",function(){return o.p}),i.d(t,"PositionNormalTextureVertex",function(){return o.o}),i.d(t,"Tmp",function(){return o.t}),i.d(t,"SphericalPolynomial",function(){return xo.b}),i.d(t,"SphericalHarmonics",function(){return xo.a}),i.d(t,"AbstractMesh",function(){return we.a}),i.d(t,"Buffer",function(){return gi.a}),i.d(t,"VertexBuffer",function(){return gi.b}),i.d(t,"CSG",function(){return rs}),i.d(t,"Geometry",function(){return Qn.a}),i.d(t,"GroundMesh",function(){return mi}),i.d(t,"InstancedMesh",function(){return ns.a}),i.d(t,"LinesMesh",function(){return os.b}),i.d(t,"InstancedLinesMesh",function(){return os.a}),i.d(t,"MeshLODLevel",function(){return de.b}),i.d(t,"_CreationDataStorage",function(){return de.c}),i.d(t,"_InstancesBatch",function(){return de.d}),i.d(t,"Mesh",function(){return de.a}),i.d(t,"VertexData",function(){return _i.a}),i.d(t,"MeshBuilder",function(){return bs}),i.d(t,"SimplificationSettings",function(){return Ts}),i.d(t,"SimplificationQueue",function(){return Es}),i.d(t,"SimplificationType",function(){return vs}),i.d(t,"SimplicationQueueSceneComponent",function(){return Cs}),i.d(t,"Polygon",function(){return hs}),i.d(t,"PolygonMeshBuilder",function(){return ds}),i.d(t,"BaseSubMesh",function(){return Zo.a}),i.d(t,"SubMesh",function(){return Zo.b}),i.d(t,"TransformNode",function(){return en.a}),i.d(t,"BoxBuilder",function(){return br.a}),i.d(t,"DiscBuilder",function(){return as}),i.d(t,"SphereBuilder",function(){return Pr.a}),i.d(t,"CylinderBuilder",function(){return bi.a}),i.d(t,"LinesBuilder",function(){return Tr.a}),i.d(t,"PlaneBuilder",function(){return Jr.a}),i.d(t,"DracoCompression",function(){return qo}),i.d(t,"RibbonBuilder",function(){return ss}),i.d(t,"TorusBuilder",function(){return yi}),i.d(t,"TorusKnotBuilder",function(){return cs}),i.d(t,"PolygonBuilder",function(){return fs}),i.d(t,"ShapeBuilder",function(){return ps}),i.d(t,"LatheBuilder",function(){return _s}),i.d(t,"GroundBuilder",function(){return vi}),i.d(t,"TubeBuilder",function(){return gs}),i.d(t,"PolyhedronBuilder",function(){return Or}),i.d(t,"IcoSphereBuilder",function(){return ms}),i.d(t,"DecalBuilder",function(){return ys}),i.d(t,"MorphTarget",function(){return io}),i.d(t,"MorphTargetManager",function(){return ro}),i.d(t,"Node",function(){return F.a}),i.d(t,"Database",function(){return Os}),i.d(t,"BaseParticleSystem",function(){return Vs}),i.d(t,"GPUParticleSystem",function(){return qs}),i.d(t,"Particle",function(){return Gs}),i.d(t,"ParticleHelper",function(){return Js}),i.d(t,"ParticleSystem",function(){return Ws}),i.d(t,"_IDoNeedToBeInTheBuild",function(){return 42}),i.d(t,"ParticleSystemSet",function(){return Zs}),i.d(t,"SolidParticle",function(){return $s}),i.d(t,"ModelShape",function(){return ea}),i.d(t,"DepthSortedParticle",function(){return ta}),i.d(t,"SolidParticleSystem",function(){return ra}),i.d(t,"SubEmitterType",function(){return Ms}),i.d(t,"SubEmitter",function(){return ks}),i.d(t,"BoxParticleEmitter",function(){return Is}),i.d(t,"ConeParticleEmitter",function(){return Ds}),i.d(t,"CylinderParticleEmitter",function(){return ws}),i.d(t,"CylinderDirectedParticleEmitter",function(){return Ls}),i.d(t,"HemisphericParticleEmitter",function(){return Fs}),i.d(t,"PointParticleEmitter",function(){return Ns}),i.d(t,"SphereParticleEmitter",function(){return Bs}),i.d(t,"SphereDirectedParticleEmitter",function(){return Us}),i.d(t,"PhysicsEngine",function(){return so}),i.d(t,"PhysicsEngineSceneComponent",function(){return sa}),i.d(t,"PhysicsHelper",function(){return aa}),i.d(t,"PhysicsRadialExplosionEvent",function(){return ca}),i.d(t,"PhysicsGravitationalFieldEvent",function(){return la}),i.d(t,"PhysicsUpdraftEvent",function(){return ua}),i.d(t,"PhysicsVortexEvent",function(){return ha}),i.d(t,"PhysicsRadialImpulseFalloff",function(){return na}),i.d(t,"PhysicsUpdraftMode",function(){return oa}),i.d(t,"PhysicsImpostor",function(){return no.a}),i.d(t,"PhysicsJoint",function(){return oo.e}),i.d(t,"DistanceJoint",function(){return oo.a}),i.d(t,"MotorEnabledJoint",function(){return oo.d}),i.d(t,"HingeJoint",function(){return oo.c}),i.d(t,"Hinge2Joint",function(){return oo.b}),i.d(t,"CannonJSPlugin",function(){return ao}),i.d(t,"AmmoJSPlugin",function(){return da}),i.d(t,"OimoJSPlugin",function(){return co}),i.d(t,"AnaglyphPostProcess",function(){return Ft}),i.d(t,"BlackAndWhitePostProcess",function(){return pa}),i.d(t,"BloomEffect",function(){return ba}),i.d(t,"BloomMergePostProcess",function(){return ya}),i.d(t,"BlurPostProcess",function(){return Ur}),i.d(t,"ChromaticAberrationPostProcess",function(){return Ea}),i.d(t,"CircleOfConfusionPostProcess",function(){return Aa}),i.d(t,"ColorCorrectionPostProcess",function(){return Ra}),i.d(t,"ConvolutionPostProcess",function(){return Ca}),i.d(t,"DepthOfFieldBlurPostProcess",function(){return Ma}),i.d(t,"DepthOfFieldEffectBlurLevel",function(){return Ia}),i.d(t,"DepthOfFieldEffect",function(){return La}),i.d(t,"DepthOfFieldMergePostProcessOptions",function(){return Da}),i.d(t,"DepthOfFieldMergePostProcess",function(){return wa}),i.d(t,"DisplayPassPostProcess",function(){return Na}),i.d(t,"ExtractHighlightsPostProcess",function(){return ma}),i.d(t,"FilterPostProcess",function(){return Ua}),i.d(t,"FxaaPostProcess",function(){return ka}),i.d(t,"GrainPostProcess",function(){return ja}),i.d(t,"HighlightsPostProcess",function(){return Ha}),i.d(t,"ImageProcessingPostProcess",function(){return pi}),i.d(t,"MotionBlurPostProcess",function(){return qa}),i.d(t,"PassPostProcess",function(){return Dt}),i.d(t,"PassCubePostProcess",function(){return wt}),i.d(t,"PostProcess",function(){return Mt}),i.d(t,"PostProcessManager",function(){return Si.a}),i.d(t,"RefractionPostProcess",function(){return Ja}),i.d(t,"SharpenPostProcess",function(){return ec}),i.d(t,"StereoscopicInterlacePostProcess",function(){return kt}),i.d(t,"TonemappingOperator",function(){return gc}),i.d(t,"TonemapPostProcess",function(){return mc}),i.d(t,"VolumetricLightScatteringPostProcess",function(){return Tc}),i.d(t,"VRDistortionCorrectionPostProcess",function(){return Qt}),i.d(t,"PostProcessRenderEffect",function(){return _a}),i.d(t,"PostProcessRenderPipeline",function(){return tc}),i.d(t,"PostProcessRenderPipelineManager",function(){return fc}),i.d(t,"PostProcessRenderPipelineManagerSceneComponent",function(){return pc}),i.d(t,"DefaultRenderingPipeline",function(){return ic}),i.d(t,"LensRenderingPipeline",function(){return oc}),i.d(t,"SSAO2RenderingPipeline",function(){return cc}),i.d(t,"SSAORenderingPipeline",function(){return uc}),i.d(t,"StandardRenderingPipeline",function(){return dc}),i.d(t,"ReflectionProbe",function(){return lo}),i.d(t,"BoundingBoxRenderer",function(){return Ec}),i.d(t,"DepthRenderer",function(){return Ac}),i.d(t,"DepthRendererSceneComponent",function(){return Pc}),i.d(t,"EdgesRenderer",function(){return Mc}),i.d(t,"LineEdgesRenderer",function(){return Oc}),i.d(t,"GeometryBufferRenderer",function(){return Ka}),i.d(t,"GeometryBufferRendererSceneComponent",function(){return Ic}),i.d(t,"OutlineRenderer",function(){return Lc}),i.d(t,"RenderingGroup",function(){return Fc.a}),i.d(t,"RenderingGroupInfo",function(){return Ci.a}),i.d(t,"RenderingManager",function(){return Ci.b}),i.d(t,"UtilityLayerRenderer",function(){return xr.a}),i.d(t,"Scene",function(){return W.a}),i.d(t,"SceneComponentConstants",function(){return Te.a}),i.d(t,"Stage",function(){return Te.b}),i.d(t,"Sprite",function(){return Nc}),i.d(t,"SpriteManager",function(){return kc}),i.d(t,"SpriteSceneComponent",function(){return Bc}),i.d(t,"_AlphaState",function(){return zc.a}),i.d(t,"_DepthCullingState",function(){return zc.b}),i.d(t,"_StencilState",function(){return zc.c}),i.d(t,"AndOrNotEvaluator",function(){return jc.a}),i.d(t,"AssetTaskState",function(){return Gc}),i.d(t,"AbstractAssetTask",function(){return Hc}),i.d(t,"AssetsProgressEvent",function(){return Xc}),i.d(t,"MeshAssetTask",function(){return Yc}),i.d(t,"TextFileAssetTask",function(){return Kc}),i.d(t,"BinaryFileAssetTask",function(){return Qc}),i.d(t,"ImageAssetTask",function(){return qc}),i.d(t,"TextureAssetTask",function(){return Zc}),i.d(t,"CubeTextureAssetTask",function(){return Jc}),i.d(t,"HDRCubeTextureAssetTask",function(){return $c}),i.d(t,"AssetsManager",function(){return el}),i.d(t,"DDSTools",function(){return Mo}),i.d(t,"expandToProperty",function(){return w.b}),i.d(t,"serialize",function(){return w.c}),i.d(t,"serializeAsTexture",function(){return w.l}),i.d(t,"serializeAsColor3",function(){return w.e}),i.d(t,"serializeAsFresnelParameters",function(){return w.h}),i.d(t,"serializeAsVector2",function(){return w.m}),i.d(t,"serializeAsVector3",function(){return w.n}),i.d(t,"serializeAsMeshReference",function(){return w.j}),i.d(t,"serializeAsColorCurves",function(){return w.g}),i.d(t,"serializeAsColor4",function(){return w.f}),i.d(t,"serializeAsImageProcessingConfiguration",function(){return w.i}),i.d(t,"serializeAsQuaternion",function(){return w.k}),i.d(t,"serializeAsCameraReference",function(){return w.d}),i.d(t,"SerializationHelper",function(){return w.a}),i.d(t,"Deferred",function(){return tl}),i.d(t,"EnvironmentTextureTools",function(){return wo}),i.d(t,"FilesInput",function(){return il}),i.d(t,"KhronosTextureContainer",function(){return Fo}),i.d(t,"EventState",function(){return n.a}),i.d(t,"Observer",function(){return n.d}),i.d(t,"MultiObserver",function(){return n.b}),i.d(t,"Observable",function(){return n.c}),i.d(t,"PerformanceMonitor",function(){return rl.a}),i.d(t,"RollingAverage",function(){return rl.b}),i.d(t,"PromisePolyfill",function(){return nl.a}),i.d(t,"SceneOptimization",function(){return ol}),i.d(t,"TextureOptimization",function(){return sl}),i.d(t,"HardwareScalingOptimization",function(){return al}),i.d(t,"ShadowsOptimization",function(){return cl}),i.d(t,"PostProcessesOptimization",function(){return ll}),i.d(t,"LensFlaresOptimization",function(){return ul}),i.d(t,"CustomOptimization",function(){return hl}),i.d(t,"ParticlesOptimization",function(){return dl}),i.d(t,"RenderTargetsOptimization",function(){return fl}),i.d(t,"MergeMeshesOptimization",function(){return pl}),i.d(t,"SceneOptimizerOptions",function(){return _l}),i.d(t,"SceneOptimizer",function(){return gl}),i.d(t,"SceneSerializer",function(){return bl}),i.d(t,"SmartArray",function(){return Rt.a}),i.d(t,"SmartArrayNoDuplicate",function(){return Rt.b}),i.d(t,"StringDictionary",function(){return lt.a}),i.d(t,"Tags",function(){return qn.a}),i.d(t,"TextureTools",function(){return rn}),i.d(t,"TGATools",function(){return Bo}),i.d(t,"ColorGradient",function(){return ve.c}),i.d(t,"Color3Gradient",function(){return ve.b}),i.d(t,"FactorGradient",function(){return ve.d}),i.d(t,"LoadFileError",function(){return ve.e}),i.d(t,"RetryStrategy",function(){return ve.g}),i.d(t,"Tools",function(){return ve.h}),i.d(t,"PerfCounter",function(){return ve.f}),i.d(t,"className",function(){return ve.i}),i.d(t,"AsyncLoop",function(){return ve.a}),i.d(t,"VideoRecorder",function(){return Tl}),i.d(t,"JoystickAxis",function(){return ct}),i.d(t,"VirtualJoystick",function(){return ut}),i.d(t,"WorkerPool",function(){return El}),i.d(t,"Logger",function(){return p.a}),i.d(t,"_TypeStore",function(){return s.a}),i.d(t,"FilesInputStore",function(){return or.a}),i.d(t,"DeepCopier",function(){return S.a}),i.d(t,"PivotTools",function(){return Fe.a}),i.d(t,"PrecisionDate",function(){return H.a}),i.d(t,"ScreenshotTools",function(){return xl}),i.d(t,"CubeMapToSphericalPolynomialTools",function(){return eo.a}),i.d(t,"HDRTools",function(){return $n}),i.d(t,"PanoramaToCubeMapTools",function(){return Jn})},function(e,t,i){"use strict";i.r(t);var r=i(0),n=i(33),o=i(56),s=function(){function e(t,i,s,a,c,l){if(void 0===i&&(i=1),void 0===s&&(s=2),this._scaleLinesFactor=4,this._instanced=!1,this.scaleLines=1,this.scaleLines=i,!a){var u=new n.a("",t);u.disableLighting=!0,u.emissiveColor=r.e.Red().scale(.5),a=o.a._CreateArrow(t,u)}if(!c){var h=new n.a("",t);h.disableLighting=!0,h.emissiveColor=r.e.Green().scale(.5),c=o.a._CreateArrow(t,h)}if(!l){var d=new n.a("",t);d.disableLighting=!0,d.emissiveColor=r.e.Blue().scale(.5),l=o.a._CreateArrow(t,d)}this._xAxis=a,this._xAxis.scaling.setAll(this.scaleLines*this._scaleLinesFactor),this._yAxis=c,this._yAxis.scaling.setAll(this.scaleLines*this._scaleLinesFactor),this._zAxis=l,this._zAxis.scaling.setAll(this.scaleLines*this._scaleLinesFactor),null!=s&&(e._SetRenderingGroupId(this._xAxis,s),e._SetRenderingGroupId(this._yAxis,s),e._SetRenderingGroupId(this._zAxis,s)),this.scene=t,this.update(new r.x,r.x.Right(),r.x.Up(),r.x.Forward())}return Object.defineProperty(e.prototype,"xAxis",{get:function(){return this._xAxis},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"yAxis",{get:function(){return this._yAxis},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"zAxis",{get:function(){return this._zAxis},enumerable:!0,configurable:!0}),e.prototype.update=function(e,t,i,r){this._xAxis.position.copyFrom(e),this._xAxis.setDirection(t),this._xAxis.scaling.setAll(this.scaleLines*this._scaleLinesFactor),this._yAxis.position.copyFrom(e),this._yAxis.setDirection(i),this._yAxis.scaling.setAll(this.scaleLines*this._scaleLinesFactor),this._zAxis.position.copyFrom(e),this._zAxis.setDirection(r),this._zAxis.scaling.setAll(this.scaleLines*this._scaleLinesFactor)},e.prototype.createInstance=function(){var t=o.a._CreateArrowInstance(this.scene,this._xAxis),i=o.a._CreateArrowInstance(this.scene,this._yAxis),r=o.a._CreateArrowInstance(this.scene,this._zAxis),n=new e(this.scene,this.scaleLines,null,t,i,r);return n._instanced=!0,n},e.prototype.dispose=function(){this._xAxis&&(this._xAxis.dispose(!1,!this._instanced),delete this._xAxis),this._yAxis&&(this._yAxis.dispose(!1,!this._instanced),delete this._yAxis),this._zAxis&&(this._zAxis.dispose(!1,!this._instanced),delete this._zAxis),delete this.scene},e._SetRenderingGroupId=function(e,t){e.getChildMeshes().forEach(function(e){e.renderingGroupId=t})},e}(),a=i(1),c=function(e){function t(t,i,n,o){void 0===o&&(o=1);var s=e.call(this,t,o)||this;return s.pos=r.x.Zero(),s.xaxis=r.x.Zero(),s.yaxis=r.x.Zero(),s.zaxis=r.x.Zero(),s.mesh=n,s.bone=i,s}return a.d(t,e),t.prototype.update=function(){if(this.mesh&&this.bone){var t=this.bone;t.getAbsolutePositionToRef(this.mesh,this.pos),t.getDirectionToRef(r.c.X,this.mesh,this.xaxis),t.getDirectionToRef(r.c.Y,this.mesh,this.yaxis),t.getDirectionToRef(r.c.Z,this.mesh,this.zaxis),e.prototype.update.call(this,this.pos,this.xaxis,this.yaxis,this.zaxis)}},t.prototype.dispose=function(){this.mesh&&(this.mesh=null,this.bone=null,e.prototype.dispose.call(this))},t}(s),l=i(9),u=i(7),h=i(17);Object.defineProperty(h.a.prototype,"debugLayer",{get:function(){return this._debugLayer||(this._debugLayer=new d(this)),this._debugLayer},enumerable:!0,configurable:!0});var d=function(){function e(e){var t=this;this.BJSINSPECTOR=this._getGlobalInspector(),this.onPropertyChangedObservable=new u.c,this._scene=e,this._scene.onDisposeObservable.add(function(){t._scene._debugLayer&&t._scene._debugLayer.hide()})}return e.prototype._createInspector=function(e){if(!this.isVisible()){var t=a.a({overlay:!1,showExplorer:!0,showInspector:!0,embedMode:!1,handleResize:!0,enablePopup:!0},e);this.BJSINSPECTOR=this.BJSINSPECTOR||this._getGlobalInspector(),this.BJSINSPECTOR.Inspector.Show(this._scene,t)}},e.prototype._getGlobalInspector=function(){return"undefined"!=typeof INSPECTOR?INSPECTOR:"undefined"!=typeof BABYLON&&void 0!==BABYLON.Inspector?BABYLON:void 0},e.prototype.isVisible=function(){return this.BJSINSPECTOR&&this.BJSINSPECTOR.Inspector.IsVisible},e.prototype.hide=function(){this.BJSINSPECTOR&&this.BJSINSPECTOR.Inspector.Hide()},e.prototype.show=function(t){void 0===this.BJSINSPECTOR?l.h.LoadScript(e.InspectorURL,this._createInspector.bind(this,t)):this._createInspector(t)},e.InspectorURL="https://preview.babylonjs.com/inspector/babylon.inspector.bundle.js",e}(),f=i(49),p=i(54),_=i(22),g=i(29),m=i(40),v=function(){function e(e){this._impostors=[],this._meshes=[],this._numMeshes=0,this._scene=e||_.a.LastCreatedScene;var t=this._scene.getPhysicsEngine();t&&(this._physicsEnginePlugin=t.getPhysicsPlugin()),this._utilityLayer=new m.a(this._scene,!1),this._utilityLayer.pickUtilitySceneFirst=!1,this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil=!0}return e.prototype._updateDebugMeshes=function(){for(var e=this._physicsEnginePlugin,t=0;t<this._numMeshes;t++){var i=this._impostors[t];if(i)if(i.isDisposed)this.hideImpostor(this._impostors[t--]);else{var r=this._meshes[t];r&&e&&e.syncMeshWithImpostor(r,i)}}},e.prototype.showImpostor=function(e){if(!this._scene)return null;for(var t=0;t<this._numMeshes;t++)if(this._impostors[t]==e)return null;var i=this._getDebugMesh(e);return i&&(this._impostors[this._numMeshes]=e,this._meshes[this._numMeshes]=i,0===this._numMeshes&&(this._renderFunction=this._updateDebugMeshes.bind(this),this._scene.registerBeforeRender(this._renderFunction)),this._numMeshes++),i},e.prototype.hideImpostor=function(e){if(e&&this._scene&&this._utilityLayer){for(var t=!1,i=this._utilityLayer.utilityLayerScene,r=0;r<this._numMeshes;r++)if(this._impostors[r]==e){var n=this._meshes[r];if(!n)continue;i.removeMesh(n),n.dispose(),this._numMeshes--,this._numMeshes>0?(this._meshes[r]=this._meshes[this._numMeshes],this._impostors[r]=this._impostors[this._numMeshes],this._meshes[this._numMeshes]=null,this._impostors[this._numMeshes]=null):(this._meshes[0]=null,this._impostors[0]=null),t=!0;break}t&&0===this._numMeshes&&this._scene.unregisterBeforeRender(this._renderFunction)}},e.prototype._getDebugMaterial=function(e){return this._debugMaterial||(this._debugMaterial=new n.a("",e),this._debugMaterial.wireframe=!0,this._debugMaterial.emissiveColor=r.e.White(),this._debugMaterial.disableLighting=!0),this._debugMaterial},e.prototype._getDebugBoxMesh=function(e){return this._debugBoxMesh||(this._debugBoxMesh=f.a.CreateBox("physicsBodyBoxViewMesh",{size:1},e),this._debugBoxMesh.rotationQuaternion=r.q.Identity(),this._debugBoxMesh.material=this._getDebugMaterial(e)),this._debugBoxMesh.createInstance("physicsBodyBoxViewInstance")},e.prototype._getDebugSphereMesh=function(e){return this._debugSphereMesh||(this._debugSphereMesh=p.a.CreateSphere("physicsBodySphereViewMesh",{diameter:1},e),this._debugSphereMesh.rotationQuaternion=r.q.Identity(),this._debugSphereMesh.material=this._getDebugMaterial(e)),this._debugSphereMesh.createInstance("physicsBodyBoxViewInstance")},e.prototype._getDebugMesh=function(e){if(!this._utilityLayer)return null;var t=null,i=this._utilityLayer.utilityLayerScene;if(e.type==g.a.BoxImpostor)t=this._getDebugBoxMesh(i),e.getBoxSizeToRef(t.scaling);else if(e.type==g.a.SphereImpostor){t=this._getDebugSphereMesh(i);var r=e.getRadius();t.scaling.x=2*r,t.scaling.y=2*r,t.scaling.z=2*r}return t},e.prototype.dispose=function(){for(var e=0;e<this._numMeshes;e++)this.hideImpostor(this._impostors[e]);this._debugBoxMesh&&this._debugBoxMesh.dispose(),this._debugSphereMesh&&this._debugSphereMesh.dispose(),this._debugMaterial&&this._debugMaterial.dispose(),this._impostors.length=0,this._scene=null,this._physicsEnginePlugin=null,this._utilityLayer&&(this._utilityLayer.dispose(),this._utilityLayer=null)},e}(),y=i(10),b=i(35),T=function(){function e(e){this.ray=e}return e.CreateAndShow=function(t,i,r){var n=new e(t);return n.show(i,r),n},e.prototype.show=function(e,t){if(!this._renderFunction&&this.ray){var i=this.ray;this._renderFunction=this._render.bind(this),this._scene=e,this._renderPoints=[i.origin,i.origin.add(i.direction.scale(i.length))],this._renderLine=y.a.CreateLines("ray",this._renderPoints,e,!0),this._renderFunction&&this._scene.registerBeforeRender(this._renderFunction)}t&&this._renderLine&&this._renderLine.color.copyFrom(t)},e.prototype.hide=function(){this._renderFunction&&this._scene&&(this._scene.unregisterBeforeRender(this._renderFunction),this._scene=null,this._renderFunction=null,this._renderLine&&(this._renderLine.dispose(),this._renderLine=null),this._renderPoints=[])},e.prototype._render=function(){var e=this.ray;if(e){var t=this._renderPoints[1],i=Math.min(e.length,1e6);t.copyFrom(e.direction),t.scaleInPlace(i),t.addInPlace(e.origin),y.a.CreateLines("ray",this._renderPoints,this._scene,!0,this._renderLine)}},e.prototype.attachToMesh=function(e,t,i,n){this._attachedToMesh=e;var o=this.ray;o&&(o.direction||(o.direction=r.x.Zero()),o.origin||(o.origin=r.x.Zero()),n&&(o.length=n),i||(i=r.x.Zero()),t||(t=new r.x(0,0,-1)),this._meshSpaceDirection?(this._meshSpaceDirection.copyFrom(t),this._meshSpaceOrigin.copyFrom(i)):(this._meshSpaceDirection=t.clone(),this._meshSpaceOrigin=i.clone()),this._updateToMeshFunction||(this._updateToMeshFunction=this._updateToMesh.bind(this),this._attachedToMesh.getScene().registerBeforeRender(this._updateToMeshFunction)),this._updateToMesh())},e.prototype.detachFromMesh=function(){this._attachedToMesh&&(this._updateToMeshFunction&&this._attachedToMesh.getScene().unregisterBeforeRender(this._updateToMeshFunction),this._attachedToMesh=null,this._updateToMeshFunction=null)},e.prototype._updateToMesh=function(){var e=this.ray;this._attachedToMesh&&e&&(this._attachedToMesh._isDisposed?this.detachFromMesh():(this._attachedToMesh.getDirectionToRef(this._meshSpaceDirection,e.direction),r.x.TransformCoordinatesToRef(this._meshSpaceOrigin,this._attachedToMesh.getWorldMatrix(),e.origin)))},e.prototype.dispose=function(){this.hide(),this.detachFromMesh(),this.ray=null},e}(),E=function(){function e(e,t,i,n,o){void 0===n&&(n=!0),void 0===o&&(o=1),this.skeleton=e,this.mesh=t,this.autoUpdateBonesMatrices=n,this.renderingGroupId=o,this.color=r.e.White(),this._debugLines=new Array,this._isEnabled=!1,this._scene=i,this._utilityLayer=new m.a(this._scene,!1),this._utilityLayer.pickUtilitySceneFirst=!1,this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil=!0,this.update(),this._renderFunction=this.update.bind(this)}return Object.defineProperty(e.prototype,"debugMesh",{get:function(){return this._debugMesh},enumerable:!0,configurable:!0}),Object.defineProperty(e.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}),e.prototype._getBonePosition=function(e,t,i,n,o,s){void 0===n&&(n=0),void 0===o&&(o=0),void 0===s&&(s=0);var a=r.t.Matrix[0],c=t.getParent();if(a.copyFrom(t.getLocalMatrix()),0!==n||0!==o||0!==s){var l=r.t.Matrix[1];r.j.IdentityToRef(l),l.setTranslationFromFloats(n,o,s),l.multiplyToRef(a,a)}c&&a.multiplyToRef(c.getAbsoluteTransform(),a),a.multiplyToRef(i,a),e.x=a.m[12],e.y=a.m[13],e.z=a.m[14]},e.prototype._getLinesForBonesWithLength=function(e,t){for(var i=e.length,n=this.mesh.position,o=0;o<i;o++){var s=e[o],a=this._debugLines[o];a||(a=[r.x.Zero(),r.x.Zero()],this._debugLines[o]=a),this._getBonePosition(a[0],s,t),this._getBonePosition(a[1],s,t,0,s.length,0),a[0].subtractInPlace(n),a[1].subtractInPlace(n)}},e.prototype._getLinesForBonesNoLength=function(e,t){for(var i=e.length,n=0,o=this.mesh.position,s=i-1;s>=0;s--){var a=e[s],c=a.getParent();if(c){var l=this._debugLines[n];l||(l=[r.x.Zero(),r.x.Zero()],this._debugLines[n]=l),a.getAbsolutePositionToRef(this.mesh,l[0]),c.getAbsolutePositionToRef(this.mesh,l[1]),l[0].subtractInPlace(o),l[1].subtractInPlace(o),n++}}},e.prototype.update=function(){if(this._utilityLayer){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());var e=this._utilityLayer.utilityLayerScene;this._debugMesh?b.a.CreateLineSystem("",{lines:this._debugLines,updatable:!0,instance:this._debugMesh},e):(this._debugMesh=b.a.CreateLineSystem("",{lines:this._debugLines,updatable:!0,instance:null},e),this._debugMesh.renderingGroupId=this.renderingGroupId),this._debugMesh.position.copyFrom(this.mesh.position),this._debugMesh.color=this.color}},e.prototype.dispose=function(){this.isEnabled=!1,this._debugMesh&&(this.isEnabled=!1,this._debugMesh.dispose(),this._debugMesh=null),this._utilityLayer&&(this._utilityLayer.dispose(),this._utilityLayer=null)},e}();i.d(t,"AxesViewer",function(){return s}),i.d(t,"BoneAxesViewer",function(){return c}),i.d(t,"DebugLayer",function(){return d}),i.d(t,"PhysicsViewer",function(){return v}),i.d(t,"RayHelper",function(){return T}),i.d(t,"SkeletonViewer",function(){return E})},function(e,t,i){"use strict";var r="clipPlaneFragmentDeclaration",n="#ifdef CLIPPLANE\nvarying float fClipDistance;\n#endif\n#ifdef CLIPPLANE2\nvarying float fClipDistance2;\n#endif\n#ifdef CLIPPLANE3\nvarying float fClipDistance3;\n#endif\n#ifdef CLIPPLANE4\nvarying float fClipDistance4;\n#endif";i(5).a.IncludesShadersStore[r]=n},function(e,t,i){"use strict";var r="fogFragmentDeclaration",n="#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";i(5).a.IncludesShadersStore[r]=n},function(e,t,i){"use strict";var r="#ifdef FOG\nfloat fog=CalcFogFactor();\ncolor.rgb=fog*color.rgb+(1.0-fog)*vFogColor;\n#endif";i(5).a.IncludesShadersStore.fogFragment=r},function(e,t,i){"use strict";var r="clipPlaneVertexDeclaration",n="#ifdef CLIPPLANE\nuniform vec4 vClipPlane;\nvarying float fClipDistance;\n#endif\n#ifdef CLIPPLANE2\nuniform vec4 vClipPlane2;\nvarying float fClipDistance2;\n#endif\n#ifdef CLIPPLANE3\nuniform vec4 vClipPlane3;\nvarying float fClipDistance3;\n#endif\n#ifdef CLIPPLANE4\nuniform vec4 vClipPlane4;\nvarying float fClipDistance4;\n#endif";i(5).a.IncludesShadersStore[r]=n},function(e,t,i){"use strict";var r="fogVertexDeclaration",n="#ifdef FOG\nvarying vec3 vFogDistance;\n#endif";i(5).a.IncludesShadersStore[r]=n},function(e,t,i){"use strict";var r="morphTargetsVertexGlobalDeclaration",n="#ifdef MORPHTARGETS\nuniform float morphTargetInfluences[NUM_MORPH_INFLUENCERS];\n#endif";i(5).a.IncludesShadersStore[r]=n},function(e,t,i){"use strict";var r="morphTargetsVertexDeclaration",n="#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";i(5).a.IncludesShadersStore[r]=n},function(e,t,i){"use strict";var r="morphTargetsVertex",n="#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";i(5).a.IncludesShadersStore[r]=n},function(e,t,i){"use strict";i.d(t,"a",function(){return r});var r=function(){function e(){}return e.Eval=function(t,i){return"true"===(t=t.match(/\([^\(\)]*\)/g)?t.replace(/\([^\(\)]*\)/g,function(t){return t=t.slice(1,t.length-1),e._HandleParenthesisContent(t,i)}):e._HandleParenthesisContent(t,i))||"false"!==t&&e.Eval(t,i)},e._HandleParenthesisContent=function(t,i){var r;i=i||function(e){return"true"===e};var n=t.split("||");for(var o in n)if(n.hasOwnProperty(o)){var s=e._SimplifyNegation(n[o].trim()),a=s.split("&&");if(a.length>1)for(var c=0;c<a.length;++c){var l=e._SimplifyNegation(a[c].trim());if(!(r="true"!==l&&"false"!==l?"!"===l[0]?!i(l.substring(1)):i(l):"true"===l)){s="false";break}}if(r||"true"===s){r=!0;break}r="true"!==s&&"false"!==s?"!"===s[0]?!i(s.substring(1)):i(s):"true"===s}return r?"true":"false"},e._SimplifyNegation=function(e){return"!true"===(e=(e=e.replace(/^[\s!]+/,function(e){return(e=e.replace(/[\s]/g,function(){return""})).length%2?"!":""})).trim())?e="false":"!false"===e&&(e="true"),e},e}()},function(e,t,i){"use strict";i.d(t,"a",function(){return n}),i.d(t,"b",function(){return o});var r=i(43),n=function(){function e(e){void 0===e&&(e=30),this._enabled=!0,this._rollingFrameTime=new o(e)}return e.prototype.sampleFrame=function(e){if(void 0===e&&(e=r.a.Now),this._enabled){if(null!=this._lastFrameTimeMs){var t=e-this._lastFrameTimeMs;this._rollingFrameTime.add(t)}this._lastFrameTimeMs=e}},Object.defineProperty(e.prototype,"averageFrameTime",{get:function(){return this._rollingFrameTime.average},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"averageFrameTimeVariance",{get:function(){return this._rollingFrameTime.variance},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"instantaneousFrameTime",{get:function(){return this._rollingFrameTime.history(0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"averageFPS",{get:function(){return 1e3/this._rollingFrameTime.average},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"instantaneousFPS",{get:function(){var e=this._rollingFrameTime.history(0);return 0===e?0:1e3/e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isSaturated",{get:function(){return this._rollingFrameTime.isSaturated()},enumerable:!0,configurable:!0}),e.prototype.enable=function(){this._enabled=!0},e.prototype.disable=function(){this._enabled=!1,this._lastFrameTimeMs=null},Object.defineProperty(e.prototype,"isEnabled",{get:function(){return this._enabled},enumerable:!0,configurable:!0}),e.prototype.reset=function(){this._lastFrameTimeMs=null,this._rollingFrameTime.reset()},e}(),o=function(){function e(e){this._samples=new Array(e),this.reset()}return e.prototype.add=function(e){var t;if(this.isSaturated()){var i=this._samples[this._pos];t=i-this.average,this.average-=t/(this._sampleCount-1),this._m2-=t*(i-this.average)}else this._sampleCount++;t=e-this.average,this.average+=t/this._sampleCount,this._m2+=t*(e-this.average),this.variance=this._m2/(this._sampleCount-1),this._samples[this._pos]=e,this._pos++,this._pos%=this._samples.length},e.prototype.history=function(e){if(e>=this._sampleCount||e>=this._samples.length)return 0;var t=this._wrapPosition(this._pos-1);return this._samples[this._wrapPosition(t-e)]},e.prototype.isSaturated=function(){return this._sampleCount>=this._samples.length},e.prototype.reset=function(){this.average=0,this.variance=0,this._sampleCount=0,this._pos=0,this._m2=0},e.prototype._wrapPosition=function(e){var t=this._samples.length;return(e%t+t)%t},e}()},function(e,t,i){"use strict";i.d(t,"a",function(){return a});var r,n=i(9);!function(e){e[e.Pending=0]="Pending",e[e.Fulfilled=1]="Fulfilled",e[e.Rejected=2]="Rejected"}(r||(r={}));var o=function(){return function(){this.count=0,this.target=0,this.results=[]}}(),s=function(){function e(e){var t=this;if(this._state=r.Pending,this._children=new Array,this._rejectWasConsumed=!1,e)try{e(function(e){t._resolve(e)},function(e){t._reject(e)})}catch(e){this._reject(e)}}return Object.defineProperty(e.prototype,"_result",{get:function(){return this._resultValue},set:function(e){this._resultValue=e,this._parent&&void 0===this._parent._result&&(this._parent._result=e)},enumerable:!0,configurable:!0}),e.prototype.catch=function(e){return this.then(void 0,e)},e.prototype.then=function(t,i){var o=this,s=new e;return s._onFulfilled=t,s._onRejected=i,this._children.push(s),s._parent=this,this._state!==r.Pending&&n.h.SetImmediate(function(){if(o._state===r.Fulfilled||o._rejectWasConsumed){var e=s._resolve(o._result);if(null!=e)if(void 0!==e._state){var t=e;s._children.push(t),t._parent=s,s=t}else s._result=e}else s._reject(o._reason)}),s},e.prototype._moveChildren=function(e){var t,i=this;if((t=this._children).push.apply(t,e.splice(0,e.length)),this._children.forEach(function(e){e._parent=i}),this._state===r.Fulfilled)for(var n=0,o=this._children;n<o.length;n++){o[n]._resolve(this._result)}else if(this._state===r.Rejected)for(var s=0,a=this._children;s<a.length;s++){a[s]._reject(this._reason)}},e.prototype._resolve=function(e){try{this._state=r.Fulfilled;var t=null;if(this._onFulfilled&&(t=this._onFulfilled(e)),null!=t)if(void 0!==t._state){var i=t;i._parent=this,i._moveChildren(this._children),e=i._result}else e=t;this._result=e;for(var n=0,o=this._children;n<o.length;n++){o[n]._resolve(e)}this._children.length=0,delete this._onFulfilled,delete this._onRejected}catch(e){this._reject(e,!0)}},e.prototype._reject=function(e,t){if(void 0===t&&(t=!1),this._state=r.Rejected,this._reason=e,this._onRejected&&!t)try{this._onRejected(e),this._rejectWasConsumed=!0}catch(t){e=t}for(var i=0,n=this._children;i<n.length;i++){var o=n[i];this._rejectWasConsumed?o._resolve(null):o._reject(e)}this._children.length=0,delete this._onFulfilled,delete this._onRejected},e.resolve=function(t){var i=new e;return i._resolve(t),i},e._RegisterForFulfillment=function(e,t,i){e.then(function(e){return t.results[i]=e,t.count++,t.count===t.target&&t.rootPromise._resolve(t.results),null},function(e){t.rootPromise._state!==r.Rejected&&t.rootPromise._reject(e)})},e.all=function(t){var i=new e,r=new o;if(r.target=t.length,r.rootPromise=i,t.length)for(var n=0;n<t.length;n++)e._RegisterForFulfillment(t[n],r,n);else i._resolve([]);return i},e.race=function(t){var i=new e;if(t.length)for(var r=0,n=t;r<n.length;r++){n[r].then(function(e){return i&&(i._resolve(e),i=null),null},function(e){i&&(i._reject(e),i=null)})}return i},e}(),a=function(){function e(){}return e.Apply=function(e){(void 0===e&&(e=!1),e||"undefined"==typeof Promise)&&(window.Promise=s)},e}()},function(e,t,i){"use strict";i.d(t,"a",function(){return s});var r=i(28),n=i(0),o=i(3),s=function(){function e(e,t,i,n,o){void 0===i&&(i=null),void 0===n&&(n=null),void 0===o&&(o=null),this.index=e,this._opaqueSubMeshes=new r.a(256),this._transparentSubMeshes=new r.a(256),this._alphaTestSubMeshes=new r.a(256),this._depthOnlySubMeshes=new r.a(256),this._particleSystems=new r.a(256),this._spriteManagers=new r.a(256),this._edgesRenderers=new r.a(16),this._scene=t,this.opaqueSortCompareFn=i,this.alphaTestSortCompareFn=n,this.transparentSortCompareFn=o}return Object.defineProperty(e.prototype,"opaqueSortCompareFn",{set:function(t){this._opaqueSortCompareFn=t,this._renderOpaque=t?this.renderOpaqueSorted:e.renderUnsorted},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"alphaTestSortCompareFn",{set:function(t){this._alphaTestSortCompareFn=t,this._renderAlphaTest=t?this.renderAlphaTestSorted:e.renderUnsorted},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"transparentSortCompareFn",{set:function(t){this._transparentSortCompareFn=t||e.defaultTransparentSortCompare,this._renderTransparent=this.renderTransparentSorted},enumerable:!0,configurable:!0}),e.prototype.render=function(e,t,i,r){if(e)e(this._opaqueSubMeshes,this._alphaTestSubMeshes,this._transparentSubMeshes,this._depthOnlySubMeshes);else{var n=this._scene.getEngine();0!==this._depthOnlySubMeshes.length&&(n.setColorWrite(!1),this._renderAlphaTest(this._depthOnlySubMeshes),n.setColorWrite(!0)),0!==this._opaqueSubMeshes.length&&this._renderOpaque(this._opaqueSubMeshes),0!==this._alphaTestSubMeshes.length&&this._renderAlphaTest(this._alphaTestSubMeshes);var s=n.getStencilBuffer();if(n.setStencilBuffer(!1),t&&this._renderSprites(),i&&this._renderParticles(r),this.onBeforeTransparentRendering&&this.onBeforeTransparentRendering(),0!==this._transparentSubMeshes.length&&(this._renderTransparent(this._transparentSubMeshes),n.setAlphaMode(o.a.ALPHA_DISABLE)),n.setStencilBuffer(!1),this._edgesRenderers.length){for(var a=0;a<this._edgesRenderers.length;a++)this._edgesRenderers.data[a].render();n.setAlphaMode(o.a.ALPHA_DISABLE)}n.setStencilBuffer(s)}},e.prototype.renderOpaqueSorted=function(t){return e.renderSorted(t,this._opaqueSortCompareFn,this._scene.activeCamera,!1)},e.prototype.renderAlphaTestSorted=function(t){return e.renderSorted(t,this._alphaTestSortCompareFn,this._scene.activeCamera,!1)},e.prototype.renderTransparentSorted=function(t){return e.renderSorted(t,this._transparentSortCompareFn,this._scene.activeCamera,!0)},e.renderSorted=function(e,t,i,r){for(var s,a=0,c=i?i.globalPosition:n.x.Zero();a<e.length;a++)(s=e.data[a])._alphaIndex=s.getMesh().alphaIndex,s._distanceToCamera=s.getBoundingInfo().boundingSphere.centerWorld.subtract(c).length();var l=e.data.slice(0,e.length);for(t&&l.sort(t),a=0;a<l.length;a++){if(s=l[a],r){var u=s.getMaterial();if(u&&u.needDepthPrePass){var h=u.getScene().getEngine();h.setColorWrite(!1),h.setAlphaMode(o.a.ALPHA_DISABLE),s.render(!1),h.setColorWrite(!0)}}s.render(r)}},e.renderUnsorted=function(e){for(var t=0;t<e.length;t++){e.data[t].render(!1)}},e.defaultTransparentSortCompare=function(t,i){return t._alphaIndex>i._alphaIndex?1:t._alphaIndex<i._alphaIndex?-1:e.backToFrontSortCompare(t,i)},e.backToFrontSortCompare=function(e,t){return e._distanceToCamera<t._distanceToCamera?1:e._distanceToCamera>t._distanceToCamera?-1:0},e.frontToBackSortCompare=function(e,t){return e._distanceToCamera<t._distanceToCamera?-1:e._distanceToCamera>t._distanceToCamera?1:0},e.prototype.prepare=function(){this._opaqueSubMeshes.reset(),this._transparentSubMeshes.reset(),this._alphaTestSubMeshes.reset(),this._depthOnlySubMeshes.reset(),this._particleSystems.reset(),this._spriteManagers.reset(),this._edgesRenderers.reset()},e.prototype.dispose=function(){this._opaqueSubMeshes.dispose(),this._transparentSubMeshes.dispose(),this._alphaTestSubMeshes.dispose(),this._depthOnlySubMeshes.dispose(),this._particleSystems.dispose(),this._spriteManagers.dispose(),this._edgesRenderers.dispose()},e.prototype.dispatch=function(e,t,i){void 0===t&&(t=e.getMesh()),void 0===i&&(i=e.getMaterial()),null!=i&&(i.needAlphaBlendingForMesh(t)?this._transparentSubMeshes.push(e):i.needAlphaTesting()?(i.needDepthPrePass&&this._depthOnlySubMeshes.push(e),this._alphaTestSubMeshes.push(e)):(i.needDepthPrePass&&this._depthOnlySubMeshes.push(e),this._opaqueSubMeshes.push(e)),t._edgesRenderer&&t._edgesRenderer.isEnabled&&this._edgesRenderers.push(t._edgesRenderer))},e.prototype.dispatchSprites=function(e){this._spriteManagers.push(e)},e.prototype.dispatchParticles=function(e){this._particleSystems.push(e)},e.prototype._renderParticles=function(e){if(0!==this._particleSystems.length){var t=this._scene.activeCamera;this._scene.onBeforeParticlesRenderingObservable.notifyObservers(this._scene);for(var i=0;i<this._particleSystems.length;i++){var r=this._particleSystems.data[i];if(0!==(t&&t.layerMask&r.layerMask)){var n=r.emitter;n.position&&e&&-1===e.indexOf(n)||this._scene._activeParticles.addCount(r.render(),!1)}}this._scene.onAfterParticlesRenderingObservable.notifyObservers(this._scene)}},e.prototype._renderSprites=function(){if(this._scene.spritesEnabled&&0!==this._spriteManagers.length){var e=this._scene.activeCamera;this._scene.onBeforeSpritesRenderingObservable.notifyObservers(this._scene);for(var t=0;t<this._spriteManagers.length;t++){var i=this._spriteManagers.data[t];0!==(e&&e.layerMask&i.layerMask)&&i.render()}this._scene.onAfterSpritesRenderingObservable.notifyObservers(this._scene)}},e}()},function(e,t,i){"use strict";i.d(t,"a",function(){return c});var r=i(1),n=i(8),o=i(23),s=i(10),a=i(32);s.a._instancedMeshFactory=function(e,t){return new c(e,t)};var c=function(e){function t(t,i){var r=e.call(this,t,i.getScene())||this;return r._indexInSourceMeshInstanceArray=-1,i.addInstance(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 r.d(t,e),t.prototype.getClassName=function(){return"InstancedMesh"},Object.defineProperty(t.prototype,"receiveShadows",{get:function(){return this._sourceMesh.receiveShadows},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"material",{get:function(){return this._sourceMesh.material},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"visibility",{get:function(){return this._sourceMesh.visibility},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"skeleton",{get:function(){return this._sourceMesh.skeleton},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"renderingGroupId",{get:function(){return this._sourceMesh.renderingGroupId},set:function(e){this._sourceMesh&&e!==this._sourceMesh.renderingGroupId&&n.a.Warn("Note - setting renderingGroupId of an instanced mesh has no effect on the scene")},enumerable:!0,configurable:!0}),t.prototype.getTotalVertices=function(){return this._sourceMesh.getTotalVertices()},t.prototype.getTotalIndices=function(){return this._sourceMesh.getTotalIndices()},Object.defineProperty(t.prototype,"sourceMesh",{get:function(){return this._sourceMesh},enumerable:!0,configurable:!0}),t.prototype.isReady=function(e){return void 0===e&&(e=!1),this._sourceMesh.isReady(e,!0)},t.prototype.getVerticesData=function(e,t){return this._sourceMesh.getVerticesData(e,t)},t.prototype.setVerticesData=function(e,t,i,r){return this.sourceMesh&&this.sourceMesh.setVerticesData(e,t,i,r),this.sourceMesh},t.prototype.updateVerticesData=function(e,t,i,r){return this.sourceMesh&&this.sourceMesh.updateVerticesData(e,t,i,r),this.sourceMesh},t.prototype.setIndices=function(e,t){return void 0===t&&(t=null),this.sourceMesh&&this.sourceMesh.setIndices(e,t),this.sourceMesh},t.prototype.isVerticesDataPresent=function(e){return this._sourceMesh.isVerticesDataPresent(e)},t.prototype.getIndices=function(){return this._sourceMesh.getIndices()},Object.defineProperty(t.prototype,"_positions",{get:function(){return this._sourceMesh._positions},enumerable:!0,configurable:!0}),t.prototype.refreshBoundingInfo=function(e){if(void 0===e&&(e=!1),this._boundingInfo&&this._boundingInfo.isLocked)return this;var t=this._sourceMesh.geometry?this._sourceMesh.geometry.boundingBias:null;return this._refreshBoundingInfo(this._sourceMesh._getPositionData(e),t),this},t.prototype._preActivate=function(){return this._currentLOD&&this._currentLOD._preActivate(),this},t.prototype._activate=function(e){return this._currentLOD&&this._currentLOD._registerInstanceForRenderId(this,e),this},t.prototype.getLOD=function(e){if(!e)return this;var t=this.getBoundingInfo();return this._currentLOD=this.sourceMesh.getLOD(e,t.boundingSphere),this._currentLOD===this.sourceMesh?this:this._currentLOD},t.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},t.prototype._generatePointsArray=function(){return this._sourceMesh._generatePointsArray()},t.prototype.clone=function(e,t,i){var r=this._sourceMesh.createInstance(e);if(a.a.DeepCopy(this,r,["name","subMeshes","uniqueId"],[]),this.refreshBoundingInfo(),t&&(r.parent=t),!i)for(var n=0;n<this.getScene().meshes.length;n++){var o=this.getScene().meshes[n];o.parent===this&&o.clone(o.name,r)}return r.computeWorldMatrix(!0),r},t.prototype.dispose=function(t,i){void 0===i&&(i=!1),this._sourceMesh.removeInstance(this),e.prototype.dispose.call(this,t,i)},t}(o.a)},function(e,t,i){"use strict";var r="shadowsFragmentFunctions",n="#ifdef SHADOWS\n#ifndef SHADOWFLOAT\nfloat unpack(vec4 color)\n{\nconst vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);\nreturn dot(color,bit_shift);\n}\n#endif\nfloat computeShadowCube(vec3 lightPosition,samplerCube shadowSampler,float darkness,vec2 depthValues)\n{\nvec3 directionToLight=vPositionW-lightPosition;\nfloat depth=length(directionToLight);\ndepth=(depth+depthValues.x)/(depthValues.y);\ndepth=clamp(depth,0.,1.0);\ndirectionToLight=normalize(directionToLight);\ndirectionToLight.y=-directionToLight.y;\n#ifndef SHADOWFLOAT\nfloat shadow=unpack(textureCube(shadowSampler,directionToLight));\n#else\nfloat shadow=textureCube(shadowSampler,directionToLight).x;\n#endif\nif (depth>shadow)\n{\nreturn darkness;\n}\nreturn 1.0;\n}\nfloat computeShadowWithPoissonSamplingCube(vec3 lightPosition,samplerCube shadowSampler,float mapSize,float darkness,vec2 depthValues)\n{\nvec3 directionToLight=vPositionW-lightPosition;\nfloat depth=length(directionToLight);\ndepth=(depth+depthValues.x)/(depthValues.y);\ndepth=clamp(depth,0.,1.0);\ndirectionToLight=normalize(directionToLight);\ndirectionToLight.y=-directionToLight.y;\nfloat visibility=1.;\nvec3 poissonDisk[4];\npoissonDisk[0]=vec3(-1.0,1.0,-1.0);\npoissonDisk[1]=vec3(1.0,-1.0,-1.0);\npoissonDisk[2]=vec3(-1.0,-1.0,-1.0);\npoissonDisk[3]=vec3(1.0,-1.0,1.0);\n\n#ifndef SHADOWFLOAT\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[0]*mapSize))<depth) visibility-=0.25;\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[1]*mapSize))<depth) visibility-=0.25;\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[2]*mapSize))<depth) visibility-=0.25;\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[3]*mapSize))<depth) visibility-=0.25;\n#else\nif (textureCube(shadowSampler,directionToLight+poissonDisk[0]*mapSize).x<depth) visibility-=0.25;\nif (textureCube(shadowSampler,directionToLight+poissonDisk[1]*mapSize).x<depth) visibility-=0.25;\nif (textureCube(shadowSampler,directionToLight+poissonDisk[2]*mapSize).x<depth) visibility-=0.25;\nif (textureCube(shadowSampler,directionToLight+poissonDisk[3]*mapSize).x<depth) visibility-=0.25;\n#endif\nreturn min(1.0,visibility+darkness);\n}\nfloat computeShadowWithESMCube(vec3 lightPosition,samplerCube shadowSampler,float darkness,float depthScale,vec2 depthValues)\n{\nvec3 directionToLight=vPositionW-lightPosition;\nfloat depth=length(directionToLight);\ndepth=(depth+depthValues.x)/(depthValues.y);\nfloat shadowPixelDepth=clamp(depth,0.,1.0);\ndirectionToLight=normalize(directionToLight);\ndirectionToLight.y=-directionToLight.y;\n#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(textureCube(shadowSampler,directionToLight));\n#else\nfloat shadowMapSample=textureCube(shadowSampler,directionToLight).x;\n#endif\nfloat esm=1.0-clamp(exp(min(87.,depthScale*shadowPixelDepth))*shadowMapSample,0.,1.-darkness);\nreturn esm;\n}\nfloat computeShadowWithCloseESMCube(vec3 lightPosition,samplerCube shadowSampler,float darkness,float depthScale,vec2 depthValues)\n{\nvec3 directionToLight=vPositionW-lightPosition;\nfloat depth=length(directionToLight);\ndepth=(depth+depthValues.x)/(depthValues.y);\nfloat shadowPixelDepth=clamp(depth,0.,1.0);\ndirectionToLight=normalize(directionToLight);\ndirectionToLight.y=-directionToLight.y;\n#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(textureCube(shadowSampler,directionToLight));\n#else\nfloat shadowMapSample=textureCube(shadowSampler,directionToLight).x;\n#endif\nfloat esm=clamp(exp(min(87.,-depthScale*(shadowPixelDepth-shadowMapSample))),darkness,1.);\nreturn esm;\n}\nfloat computeShadow(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\n#ifndef SHADOWFLOAT\nfloat shadow=unpack(texture2D(shadowSampler,uv));\n#else\nfloat shadow=texture2D(shadowSampler,uv).x;\n#endif\nif (shadowPixelDepth>shadow)\n{\nreturn computeFallOff(darkness,clipSpace.xy,frustumEdgeFalloff);\n}\nreturn 1.;\n}\nfloat computeShadowWithPoissonSampling(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float mapSize,float darkness,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\nfloat visibility=1.;\nvec2 poissonDisk[4];\npoissonDisk[0]=vec2(-0.94201624,-0.39906216);\npoissonDisk[1]=vec2(0.94558609,-0.76890725);\npoissonDisk[2]=vec2(-0.094184101,-0.92938870);\npoissonDisk[3]=vec2(0.34495938,0.29387760);\n\n#ifndef SHADOWFLOAT\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[0]*mapSize))<shadowPixelDepth) visibility-=0.25;\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[1]*mapSize))<shadowPixelDepth) visibility-=0.25;\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[2]*mapSize))<shadowPixelDepth) visibility-=0.25;\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[3]*mapSize))<shadowPixelDepth) visibility-=0.25;\n#else\nif (texture2D(shadowSampler,uv+poissonDisk[0]*mapSize).x<shadowPixelDepth) visibility-=0.25;\nif (texture2D(shadowSampler,uv+poissonDisk[1]*mapSize).x<shadowPixelDepth) visibility-=0.25;\nif (texture2D(shadowSampler,uv+poissonDisk[2]*mapSize).x<shadowPixelDepth) visibility-=0.25;\nif (texture2D(shadowSampler,uv+poissonDisk[3]*mapSize).x<shadowPixelDepth) visibility-=0.25;\n#endif\nreturn computeFallOff(min(1.0,visibility+darkness),clipSpace.xy,frustumEdgeFalloff);\n}\nfloat computeShadowWithESM(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float depthScale,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\n#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(texture2D(shadowSampler,uv));\n#else\nfloat shadowMapSample=texture2D(shadowSampler,uv).x;\n#endif\nfloat esm=1.0-clamp(exp(min(87.,depthScale*shadowPixelDepth))*shadowMapSample,0.,1.-darkness);\nreturn computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);\n}\nfloat computeShadowWithCloseESM(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float depthScale,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\n#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(texture2D(shadowSampler,uv));\n#else\nfloat shadowMapSample=texture2D(shadowSampler,uv).x;\n#endif\nfloat esm=clamp(exp(min(87.,-depthScale*(shadowPixelDepth-shadowMapSample))),darkness,1.);\nreturn computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);\n}\n#ifdef WEBGL2\n\nfloat computeShadowWithPCF1(vec4 vPositionFromLight,float depthMetric,sampler2DShadow shadowSampler,float darkness,float frustumEdgeFalloff)\n{\nif (depthMetric>1.0 || depthMetric<0.0) {\nreturn 1.0;\n}\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nfloat shadow=texture2D(shadowSampler,uvDepth);\nshadow=mix(darkness,1.,shadow);\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\n\n\n\nfloat computeShadowWithPCF3(vec4 vPositionFromLight,float depthMetric,sampler2DShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)\n{\nif (depthMetric>1.0 || depthMetric<0.0) {\nreturn 1.0;\n}\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nvec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x;\nuv+=0.5;\nvec2 st=fract(uv);\nvec2 base_uv=floor(uv)-0.5;\nbase_uv*=shadowMapSizeAndInverse.y;\n\n\n\n\nvec2 uvw0=3.-2.*st;\nvec2 uvw1=1.+2.*st;\nvec2 u=vec2((2.-st.x)/uvw0.x-1.,st.x/uvw1.x+1.)*shadowMapSizeAndInverse.y;\nvec2 v=vec2((2.-st.y)/uvw0.y-1.,st.y/uvw1.y+1.)*shadowMapSizeAndInverse.y;\nfloat shadow=0.;\nshadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[0]),uvDepth.z));\nshadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[0]),uvDepth.z));\nshadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[1]),uvDepth.z));\nshadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[1]),uvDepth.z));\nshadow=shadow/16.;\nshadow=mix(darkness,1.,shadow);\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\n\n\n\nfloat computeShadowWithPCF5(vec4 vPositionFromLight,float depthMetric,sampler2DShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)\n{\nif (depthMetric>1.0 || depthMetric<0.0) {\nreturn 1.0;\n}\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nvec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x;\nuv+=0.5;\nvec2 st=fract(uv);\nvec2 base_uv=floor(uv)-0.5;\nbase_uv*=shadowMapSizeAndInverse.y;\n\n\nvec2 uvw0=4.-3.*st;\nvec2 uvw1=vec2(7.);\nvec2 uvw2=1.+3.*st;\nvec3 u=vec3((3.-2.*st.x)/uvw0.x-2.,(3.+st.x)/uvw1.x,st.x/uvw2.x+2.)*shadowMapSizeAndInverse.y;\nvec3 v=vec3((3.-2.*st.y)/uvw0.y-2.,(3.+st.y)/uvw1.y,st.y/uvw2.y+2.)*shadowMapSizeAndInverse.y;\nfloat shadow=0.;\nshadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[0]),uvDepth.z));\nshadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[0]),uvDepth.z));\nshadow+=uvw2.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[0]),uvDepth.z));\nshadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[1]),uvDepth.z));\nshadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[1]),uvDepth.z));\nshadow+=uvw2.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[1]),uvDepth.z));\nshadow+=uvw0.x*uvw2.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[2]),uvDepth.z));\nshadow+=uvw1.x*uvw2.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[2]),uvDepth.z));\nshadow+=uvw2.x*uvw2.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[2]),uvDepth.z));\nshadow=shadow/144.;\nshadow=mix(darkness,1.,shadow);\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\nconst vec3 PoissonSamplers32[64]=vec3[64](\nvec3(0.06407013,0.05409927,0.),\nvec3(0.7366577,0.5789394,0.),\nvec3(-0.6270542,-0.5320278,0.),\nvec3(-0.4096107,0.8411095,0.),\nvec3(0.6849564,-0.4990818,0.),\nvec3(-0.874181,-0.04579735,0.),\nvec3(0.9989998,0.0009880066,0.),\nvec3(-0.004920578,-0.9151649,0.),\nvec3(0.1805763,0.9747483,0.),\nvec3(-0.2138451,0.2635818,0.),\nvec3(0.109845,0.3884785,0.),\nvec3(0.06876755,-0.3581074,0.),\nvec3(0.374073,-0.7661266,0.),\nvec3(0.3079132,-0.1216763,0.),\nvec3(-0.3794335,-0.8271583,0.),\nvec3(-0.203878,-0.07715034,0.),\nvec3(0.5912697,0.1469799,0.),\nvec3(-0.88069,0.3031784,0.),\nvec3(0.5040108,0.8283722,0.),\nvec3(-0.5844124,0.5494877,0.),\nvec3(0.6017799,-0.1726654,0.),\nvec3(-0.5554981,0.1559997,0.),\nvec3(-0.3016369,-0.3900928,0.),\nvec3(-0.5550632,-0.1723762,0.),\nvec3(0.925029,0.2995041,0.),\nvec3(-0.2473137,0.5538505,0.),\nvec3(0.9183037,-0.2862392,0.),\nvec3(0.2469421,0.6718712,0.),\nvec3(0.3916397,-0.4328209,0.),\nvec3(-0.03576927,-0.6220032,0.),\nvec3(-0.04661255,0.7995201,0.),\nvec3(0.4402924,0.3640312,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.)\n);\nconst vec3 PoissonSamplers64[64]=vec3[64](\nvec3(-0.613392,0.617481,0.),\nvec3(0.170019,-0.040254,0.),\nvec3(-0.299417,0.791925,0.),\nvec3(0.645680,0.493210,0.),\nvec3(-0.651784,0.717887,0.),\nvec3(0.421003,0.027070,0.),\nvec3(-0.817194,-0.271096,0.),\nvec3(-0.705374,-0.668203,0.),\nvec3(0.977050,-0.108615,0.),\nvec3(0.063326,0.142369,0.),\nvec3(0.203528,0.214331,0.),\nvec3(-0.667531,0.326090,0.),\nvec3(-0.098422,-0.295755,0.),\nvec3(-0.885922,0.215369,0.),\nvec3(0.566637,0.605213,0.),\nvec3(0.039766,-0.396100,0.),\nvec3(0.751946,0.453352,0.),\nvec3(0.078707,-0.715323,0.),\nvec3(-0.075838,-0.529344,0.),\nvec3(0.724479,-0.580798,0.),\nvec3(0.222999,-0.215125,0.),\nvec3(-0.467574,-0.405438,0.),\nvec3(-0.248268,-0.814753,0.),\nvec3(0.354411,-0.887570,0.),\nvec3(0.175817,0.382366,0.),\nvec3(0.487472,-0.063082,0.),\nvec3(-0.084078,0.898312,0.),\nvec3(0.488876,-0.783441,0.),\nvec3(0.470016,0.217933,0.),\nvec3(-0.696890,-0.549791,0.),\nvec3(-0.149693,0.605762,0.),\nvec3(0.034211,0.979980,0.),\nvec3(0.503098,-0.308878,0.),\nvec3(-0.016205,-0.872921,0.),\nvec3(0.385784,-0.393902,0.),\nvec3(-0.146886,-0.859249,0.),\nvec3(0.643361,0.164098,0.),\nvec3(0.634388,-0.049471,0.),\nvec3(-0.688894,0.007843,0.),\nvec3(0.464034,-0.188818,0.),\nvec3(-0.440840,0.137486,0.),\nvec3(0.364483,0.511704,0.),\nvec3(0.034028,0.325968,0.),\nvec3(0.099094,-0.308023,0.),\nvec3(0.693960,-0.366253,0.),\nvec3(0.678884,-0.204688,0.),\nvec3(0.001801,0.780328,0.),\nvec3(0.145177,-0.898984,0.),\nvec3(0.062655,-0.611866,0.),\nvec3(0.315226,-0.604297,0.),\nvec3(-0.780145,0.486251,0.),\nvec3(-0.371868,0.882138,0.),\nvec3(0.200476,0.494430,0.),\nvec3(-0.494552,-0.711051,0.),\nvec3(0.612476,0.705252,0.),\nvec3(-0.578845,-0.768792,0.),\nvec3(-0.772454,-0.090976,0.),\nvec3(0.504440,0.372295,0.),\nvec3(0.155736,0.065157,0.),\nvec3(0.391522,0.849605,0.),\nvec3(-0.620106,-0.328104,0.),\nvec3(0.789239,-0.419965,0.),\nvec3(-0.545396,0.538133,0.),\nvec3(-0.178564,-0.596057,0.)\n);\n\n\n\n\n\nfloat computeShadowWithPCSS(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff,int searchTapCount,int pcfTapCount,vec3[64] poissonSamplers)\n{\nif (depthMetric>1.0 || depthMetric<0.0) {\nreturn 1.0;\n}\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nfloat blockerDepth=0.0;\nfloat sumBlockerDepth=0.0;\nfloat numBlocker=0.0;\nfor (int i=0; i<searchTapCount; i ++) {\nblockerDepth=texture(depthSampler,uvDepth.xy+(lightSizeUV*shadowMapSizeInverse*PoissonSamplers32[i].xy)).r;\nif (blockerDepth<depthMetric) {\nsumBlockerDepth+=blockerDepth;\nnumBlocker++;\n}\n}\nif (numBlocker<1.0) {\nreturn 1.0;\n}\nfloat avgBlockerDepth=sumBlockerDepth/numBlocker;\n\nfloat AAOffset=shadowMapSizeInverse*10.;\n\n\nfloat penumbraRatio=((depthMetric-avgBlockerDepth)+AAOffset);\nfloat filterRadius=penumbraRatio*lightSizeUV*shadowMapSizeInverse;\nfloat random=getRand(vPositionFromLight.xy);\nfloat rotationAngle=random*3.1415926;\nvec2 rotationVector=vec2(cos(rotationAngle),sin(rotationAngle));\nfloat shadow=0.;\nfor (int i=0; i<pcfTapCount; i++) {\nvec3 offset=poissonSamplers[i];\n\noffset=vec3(offset.x*rotationVector.x-offset.y*rotationVector.y,offset.y*rotationVector.x+offset.x*rotationVector.y,0.);\nshadow+=texture2D(shadowSampler,uvDepth+offset*filterRadius);\n}\nshadow/=float(pcfTapCount);\n\nshadow=mix(shadow,1.,depthMetric-avgBlockerDepth);\n\nshadow=mix(darkness,1.,shadow);\n\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\nfloat computeShadowWithPCSS16(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff)\n{\nreturn computeShadowWithPCSS(vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,16,PoissonSamplers32);\n}\nfloat computeShadowWithPCSS32(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff)\n{\nreturn computeShadowWithPCSS(vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,32,PoissonSamplers32);\n}\nfloat computeShadowWithPCSS64(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff)\n{\nreturn computeShadowWithPCSS(vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,32,64,PoissonSamplers64);\n}\n#endif\n#endif\n";i(5).a.IncludesShadersStore[r]=n},function(e,t,i){"use strict";var r="reflectionFunction",n="#ifdef USE_LOCAL_REFLECTIONMAP_CUBIC\nvec3 parallaxCorrectNormal( vec3 vertexPos,vec3 origVec,vec3 cubeSize,vec3 cubePos ) {\n\nvec3 invOrigVec=vec3(1.0,1.0,1.0)/origVec;\nvec3 halfSize=cubeSize*0.5;\nvec3 intersecAtMaxPlane=(cubePos+halfSize-vertexPos)*invOrigVec;\nvec3 intersecAtMinPlane=(cubePos-halfSize-vertexPos)*invOrigVec;\n\nvec3 largestIntersec=max(intersecAtMaxPlane,intersecAtMinPlane);\n\nfloat distance=min(min(largestIntersec.x,largestIntersec.y),largestIntersec.z);\n\nvec3 intersectPositionWS=vertexPos+origVec*distance;\n\nreturn intersectPositionWS-cubePos;\n}\n#endif\nvec3 computeReflectionCoords(vec4 worldPos,vec3 worldNormal)\n{\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvec3 direction=normalize(vDirectionW);\nfloat lon=atan(direction.z,direction.x);\nfloat lat=acos(direction.y);\nvec2 sphereCoords=vec2(lon,lat)*RECIPROCAL_PI2*2.0;\nfloat s=sphereCoords.x*0.5+0.5;\nfloat t=sphereCoords.y;\n#ifdef REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED\nreturn vec3(1.0-s,t,0);\n#else\nreturn vec3(s,t,0);\n#endif\n#endif\n#ifdef REFLECTIONMAP_EQUIRECTANGULAR\nvec3 cameraToVertex=normalize(worldPos.xyz-vEyePosition.xyz);\nvec3 r=normalize(reflect(cameraToVertex,worldNormal));\nfloat lon=atan(r.z,r.x);\nfloat lat=acos(r.y);\nvec2 sphereCoords=vec2(lon,lat)*RECIPROCAL_PI2*2.0;\nfloat s=sphereCoords.x*0.5+0.5;\nfloat t=sphereCoords.y;\nreturn vec3(s,t,0);\n#endif\n#ifdef REFLECTIONMAP_SPHERICAL\nvec3 viewDir=normalize(vec3(view*worldPos));\nvec3 viewNormal=normalize(vec3(view*vec4(worldNormal,0.0)));\nvec3 r=reflect(viewDir,viewNormal);\nr.z=r.z-1.0;\nfloat m=2.0*length(r);\nreturn vec3(r.x/m+0.5,1.0-r.y/m-0.5,0);\n#endif\n#ifdef REFLECTIONMAP_PLANAR\nvec3 viewDir=worldPos.xyz-vEyePosition.xyz;\nvec3 coords=normalize(reflect(viewDir,worldNormal));\nreturn vec3(reflectionMatrix*vec4(coords,1));\n#endif\n#ifdef REFLECTIONMAP_CUBIC\nvec3 viewDir=normalize(worldPos.xyz-vEyePosition.xyz);\n\nvec3 coords=reflect(viewDir,worldNormal);\n#ifdef USE_LOCAL_REFLECTIONMAP_CUBIC\ncoords=parallaxCorrectNormal(worldPos.xyz,coords,vReflectionSize,vReflectionPosition);\n#endif\ncoords=vec3(reflectionMatrix*vec4(coords,0));\n#ifdef INVERTCUBICMAP\ncoords.y*=-1.0;\n#endif\nreturn coords;\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}";i(5).a.IncludesShadersStore[r]=n},function(e,t,i){"use strict";var r="lightFragment",n="#ifdef LIGHT{X}\n#if defined(SHADOWONLY) || (defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X}) && defined(LIGHTMAPNOSPECULAR{X}))\n\n#else\n#ifdef PBR\n#ifdef SPOTLIGHT{X}\nspotInfo=computeSpotLightingInfo(light{X}.vLightData);\n#ifdef LIGHT_FALLOFF_GLTF{X}\nspotInfo.attenuation=computeDistanceLightFalloff_GLTF(spotInfo.lightDistanceSquared,light{X}.vLightFalloff.y);\nspotInfo.attenuation*=computeDirectionalLightFalloff_GLTF(light{X}.vLightDirection.xyz,spotInfo.directionToLightCenterW,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w);\n#elif defined(LIGHT_FALLOFF_PHYSICAL{X})\nspotInfo.attenuation=computeDistanceLightFalloff_Physical(spotInfo.lightDistanceSquared);\nspotInfo.attenuation*=computeDirectionalLightFalloff_Physical(light{X}.vLightDirection.xyz,spotInfo.directionToLightCenterW,light{X}.vLightDirection.w);\n#elif defined(LIGHT_FALLOFF_STANDARD{X})\nspotInfo.attenuation=computeDistanceLightFalloff_Standard(spotInfo.lightOffset,light{X}.vLightFalloff.x);\nspotInfo.attenuation*=computeDirectionalLightFalloff_Standard(light{X}.vLightDirection.xyz,spotInfo.directionToLightCenterW,light{X}.vLightDirection.w,light{X}.vLightData.w);\n#else\nspotInfo.attenuation=computeDistanceLightFalloff(spotInfo.lightOffset,spotInfo.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);\nspotInfo.attenuation*=computeDirectionalLightFalloff(light{X}.vLightDirection.xyz,spotInfo.directionToLightCenterW,light{X}.vLightDirection.w,light{X}.vLightData.w,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w);\n#endif\ninfo=computeSpotLighting(spotInfo,viewDirectionW,normalW,light{X}.vLightDirection,light{X}.vLightDiffuse.rgb,light{X}.vLightDiffuse.a,roughness,NdotV,specularEnvironmentR0,specularEnvironmentR90,geometricRoughnessFactor,NdotL);\n#elif defined(POINTLIGHT{X})\npointInfo=computePointLightingInfo(light{X}.vLightData);\n#ifdef LIGHT_FALLOFF_GLTF{X}\npointInfo.attenuation=computeDistanceLightFalloff_GLTF(pointInfo.lightDistanceSquared,light{X}.vLightFalloff.y);\n#elif defined(LIGHT_FALLOFF_PHYSICAL{X})\npointInfo.attenuation=computeDistanceLightFalloff_Physical(pointInfo.lightDistanceSquared);\n#elif defined(LIGHT_FALLOFF_STANDARD{X})\npointInfo.attenuation=computeDistanceLightFalloff_Standard(pointInfo.lightOffset,light{X}.vLightFalloff.x);\n#else\npointInfo.attenuation=computeDistanceLightFalloff(pointInfo.lightOffset,pointInfo.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);\n#endif\ninfo=computePointLighting(pointInfo,viewDirectionW,normalW,light{X}.vLightDiffuse.rgb,light{X}.vLightDiffuse.a,roughness,NdotV,specularEnvironmentR0,specularEnvironmentR90,geometricRoughnessFactor,NdotL);\n#elif defined(HEMILIGHT{X})\ninfo=computeHemisphericLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,light{X}.vLightGround,roughness,NdotV,specularEnvironmentR0,specularEnvironmentR90,geometricRoughnessFactor,NdotL);\n#elif defined(DIRLIGHT{X})\ninfo=computeDirectionalLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,light{X}.vLightDiffuse.a,roughness,NdotV,specularEnvironmentR0,specularEnvironmentR90,geometricRoughnessFactor,NdotL);\n#endif\n#else\n#ifdef SPOTLIGHT{X}\ninfo=computeSpotLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDirection,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,light{X}.vLightDiffuse.a,glossiness);\n#elif defined(HEMILIGHT{X})\ninfo=computeHemisphericLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,light{X}.vLightGround,glossiness);\n#elif 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 PROJECTEDLIGHTTEXTURE{X}\ninfo.diffuse*=computeProjectionTextureDiffuseLighting(projectionLightSampler{X},textureProjectionMatrix{X});\n#endif\n#endif\n#ifdef SHADOW{X}\n#ifdef SHADOWCLOSEESM{X}\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowWithCloseESMCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues);\n#else\nshadow=computeShadowWithCloseESM(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w);\n#endif\n#elif defined(SHADOWESM{X})\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowWithESMCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues);\n#else\nshadow=computeShadowWithESM(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w);\n#endif\n#elif defined(SHADOWPOISSON{X})\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowWithPoissonSamplingCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.depthValues);\n#else\nshadow=computeShadowWithPoissonSampling(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#elif defined(SHADOWPCF{X})\n#if defined(SHADOWLOWQUALITY{X})\nshadow=computeShadowWithPCF1(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#elif defined(SHADOWMEDIUMQUALITY{X})\nshadow=computeShadowWithPCF3(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#else\nshadow=computeShadowWithPCF5(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#elif defined(SHADOWPCSS{X})\n#if defined(SHADOWLOWQUALITY{X})\nshadow=computeShadowWithPCSS16(vPositionFromLight{X},vDepthMetric{X},depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#elif defined(SHADOWMEDIUMQUALITY{X})\nshadow=computeShadowWithPCSS32(vPositionFromLight{X},vDepthMetric{X},depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#else\nshadow=computeShadowWithPCSS64(vPositionFromLight{X},vDepthMetric{X},depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#else\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.depthValues);\n#else\nshadow=computeShadow(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#endif\n#ifdef SHADOWONLY\n#ifndef SHADOWINUSE\n#define SHADOWINUSE\n#endif\nglobalShadow+=shadow;\nshadowLightCount+=1.0;\n#endif\n#else\nshadow=1.;\n#endif\n#ifndef SHADOWONLY\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\n#endif";i(5).a.IncludesShadersStore[r]=n},function(e,t,i){"use strict";var r="logDepthFragment",n="#ifdef LOGARITHMICDEPTH\ngl_FragDepthEXT=log2(vFragmentDepth)*logarithmicDepthConstant*0.5;\n#endif";i(5).a.IncludesShadersStore[r]=n},function(e,t,i){"use strict";var r="#ifdef FOG\nvFogDistance=(view*worldPos).xyz;\n#endif";i(5).a.IncludesShadersStore.fogVertex=r},function(e,t,i){"use strict";var r="shadowsVertex",n="#ifdef SHADOWS\n#if defined(SHADOW{X}) && !defined(SHADOWCUBE{X})\nvPositionFromLight{X}=lightMatrix{X}*worldPos;\nvDepthMetric{X}=((vPositionFromLight{X}.z+light{X}.depthValues.x)/(light{X}.depthValues.y));\n#endif\n#endif";i(5).a.IncludesShadersStore[r]=n},function(e,t,i){"use strict";var r="logDepthVertex",n="#ifdef LOGARITHMICDEPTH\nvFragmentDepth=1.0+gl_Position.w;\ngl_Position.z=log2(max(0.000001,vFragmentDepth))*logarithmicDepthConstant;\n#endif";i(5).a.IncludesShadersStore[r]=n},function(e,t,i){"use strict";var r="lightsFragmentFunctions",n="\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}\nvec3 computeProjectionTextureDiffuseLighting(sampler2D projectionLightSampler,mat4 textureProjectionMatrix){\nvec4 strq=textureProjectionMatrix*vec4(vPositionW,1.0);\nstrq/=strq.w;\nvec3 textureColor=texture2D(projectionLightSampler,strq.xy).rgb;\nreturn textureColor;\n}";i(5).a.IncludesShadersStore[r]=n},function(e,t,i){"use strict";var r="bumpFragmentFunctions",n="#ifdef BUMP\n#if BUMPDIRECTUV == 1\n#define vBumpUV vMainUV1\n#elif BUMPDIRECTUV == 2\n#define vBumpUV vMainUV2\n#else\nvarying vec2 vBumpUV;\n#endif\nuniform sampler2D bumpSampler;\n#if defined(TANGENT) && defined(NORMAL)\nvarying mat3 vTBN;\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\nuniform mat4 normalMatrix;\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 bitangent=dp2perp*duv1.y+dp1perp*duv2.y;\n\ntangent*=vTangentSpaceParams.x;\nbitangent*=vTangentSpaceParams.y;\n\nfloat invmax=inversesqrt(max(dot(tangent,tangent),dot(bitangent,bitangent)));\nreturn mat3(tangent*invmax,bitangent*invmax,normal);\n}\nvec3 perturbNormal(mat3 cotangentFrame,vec2 uv)\n{\nvec3 map=texture2D(bumpSampler,uv).xyz;\nmap=map*2.0-1.0;\n#ifdef NORMALXYSCALE\nmap=normalize(map*vec3(vBumpInfos.y,vBumpInfos.y,1.0));\n#endif\nreturn normalize(cotangentFrame*map);\n}\n#ifdef PARALLAX\nconst float minSamples=4.;\nconst float maxSamples=15.;\nconst int iMaxSamples=15;\n\nvec2 parallaxOcclusion(vec3 vViewDirCoT,vec3 vNormalCoT,vec2 texCoord,float parallaxScale) {\nfloat parallaxLimit=length(vViewDirCoT.xy)/vViewDirCoT.z;\nparallaxLimit*=parallaxScale;\nvec2 vOffsetDir=normalize(vViewDirCoT.xy);\nvec2 vMaxOffset=vOffsetDir*parallaxLimit;\nfloat numSamples=maxSamples+(dot(vViewDirCoT,vNormalCoT)*(minSamples-maxSamples));\nfloat stepSize=1.0/numSamples;\n\nfloat currRayHeight=1.0;\nvec2 vCurrOffset=vec2(0,0);\nvec2 vLastOffset=vec2(0,0);\nfloat lastSampledHeight=1.0;\nfloat currSampledHeight=1.0;\nfor (int i=0; i<iMaxSamples; i++)\n{\ncurrSampledHeight=texture2D(bumpSampler,vBumpUV+vCurrOffset).w;\n\nif (currSampledHeight>currRayHeight)\n{\nfloat delta1=currSampledHeight-currRayHeight;\nfloat delta2=(currRayHeight+stepSize)-lastSampledHeight;\nfloat ratio=delta1/(delta1+delta2);\nvCurrOffset=(ratio)* vLastOffset+(1.0-ratio)*vCurrOffset;\n\nbreak;\n}\nelse\n{\ncurrRayHeight-=stepSize;\nvLastOffset=vCurrOffset;\nvCurrOffset+=stepSize*vMaxOffset;\nlastSampledHeight=currSampledHeight;\n}\n}\nreturn vCurrOffset;\n}\nvec2 parallaxOffset(vec3 viewDir,float heightScale)\n{\n\nfloat height=texture2D(bumpSampler,vBumpUV).w;\nvec2 texCoordOffset=heightScale*viewDir.xy*height;\nreturn -texCoordOffset;\n}\n#endif\n#endif";i(5).a.IncludesShadersStore[r]=n},function(e,t,i){"use strict";var r="vec2 uvOffset=vec2(0.0,0.0);\n#if defined(BUMP) || defined(PARALLAX)\n#ifdef NORMALXYSCALE\nfloat normalScale=1.0;\n#else\nfloat normalScale=vBumpInfos.y;\n#endif\n#if defined(TANGENT) && defined(NORMAL)\nmat3 TBN=vTBN;\n#else\nmat3 TBN=cotangent_frame(normalW*normalScale,vPositionW,vBumpUV);\n#endif\n#endif\n#ifdef PARALLAX\nmat3 invTBN=transposeMat3(TBN);\n#ifdef PARALLAXOCCLUSION\nuvOffset=parallaxOcclusion(invTBN*-viewDirectionW,invTBN*normalW,vBumpUV,vBumpInfos.z);\n#else\nuvOffset=parallaxOffset(invTBN*viewDirectionW,vBumpInfos.z);\n#endif\n#endif\n#ifdef BUMP\n#ifdef OBJECTSPACE_NORMALMAP\nnormalW=normalize(texture2D(bumpSampler,vBumpUV).xyz*2.0-1.0);\nnormalW=normalize(mat3(normalMatrix)*normalW);\n#else\nnormalW=perturbNormal(TBN,vBumpUV+uvOffset);\n#endif\n#endif";i(5).a.IncludesShadersStore.bumpFragment=r},function(e,t,i){"use strict";var r="#ifdef DEPTHPREPASS\ngl_FragColor=vec4(0.,0.,0.,1.0);\nreturn;\n#endif";i(5).a.IncludesShadersStore.depthPrePass=r},function(e,t,i){"use strict";var r="bumpVertexDeclaration",n="#if defined(BUMP) || defined(PARALLAX)\n#if defined(TANGENT) && defined(NORMAL)\nvarying mat3 vTBN;\n#endif\n#endif\n";i(5).a.IncludesShadersStore[r]=n},function(e,t,i){"use strict";var r="#if defined(BUMP) || defined(PARALLAX)\n#if defined(TANGENT) && defined(NORMAL)\nvec3 tbnNormal=normalize(normalUpdated);\nvec3 tbnTangent=normalize(tangentUpdated.xyz);\nvec3 tbnBitangent=cross(tbnNormal,tbnTangent)*tangentUpdated.w;\nvTBN=mat3(finalWorld)*mat3(tbnTangent,tbnBitangent,tbnNormal);\n#endif\n#endif";i(5).a.IncludesShadersStore.bumpVertex=r},function(e,t,i){"use strict";var r="colorPixelShader",n="#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}";i(5).a.ShadersStore[r]=n},function(e,t,i){"use strict";var r=i(5),n=(i(62),i(63),i(64),i(65),"colorVertexShader"),o="\nattribute vec3 position;\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\nuniform mat4 viewProjection;\n\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\nvoid main(void) {\n#include<instancesVertex>\n#include<bonesVertex>\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\n#ifdef VERTEXCOLOR\n\nvColor=color;\n#endif\n}";r.a.ShadersStore[n]=o},function(e,t,i){"use strict";i.r(t),function(e){var r=i(89),n=i(90);i.d(t,"AbstractScene",function(){return r.AbstractScene}),i.d(t,"KeepAssets",function(){return r.KeepAssets}),i.d(t,"AssetContainer",function(){return r.AssetContainer}),i.d(t,"Node",function(){return r.Node}),i.d(t,"Scene",function(){return r.Scene}),i.d(t,"SceneComponentConstants",function(){return r.SceneComponentConstants}),i.d(t,"Stage",function(){return r.Stage}),i.d(t,"Action",function(){return r.Action}),i.d(t,"ActionEvent",function(){return r.ActionEvent}),i.d(t,"ActionManager",function(){return r.ActionManager}),i.d(t,"Condition",function(){return r.Condition}),i.d(t,"ValueCondition",function(){return r.ValueCondition}),i.d(t,"PredicateCondition",function(){return r.PredicateCondition}),i.d(t,"StateCondition",function(){return r.StateCondition}),i.d(t,"SwitchBooleanAction",function(){return r.SwitchBooleanAction}),i.d(t,"SetStateAction",function(){return r.SetStateAction}),i.d(t,"SetValueAction",function(){return r.SetValueAction}),i.d(t,"IncrementValueAction",function(){return r.IncrementValueAction}),i.d(t,"PlayAnimationAction",function(){return r.PlayAnimationAction}),i.d(t,"StopAnimationAction",function(){return r.StopAnimationAction}),i.d(t,"DoNothingAction",function(){return r.DoNothingAction}),i.d(t,"CombineAction",function(){return r.CombineAction}),i.d(t,"ExecuteCodeAction",function(){return r.ExecuteCodeAction}),i.d(t,"SetParentAction",function(){return r.SetParentAction}),i.d(t,"PlaySoundAction",function(){return r.PlaySoundAction}),i.d(t,"StopSoundAction",function(){return r.StopSoundAction}),i.d(t,"InterpolateValueAction",function(){return r.InterpolateValueAction}),i.d(t,"Animatable",function(){return r.Animatable}),i.d(t,"Animation",function(){return r.Animation}),i.d(t,"TargetedAnimation",function(){return r.TargetedAnimation}),i.d(t,"AnimationGroup",function(){return r.AnimationGroup}),i.d(t,"AnimationPropertiesOverride",function(){return r.AnimationPropertiesOverride}),i.d(t,"EasingFunction",function(){return r.EasingFunction}),i.d(t,"CircleEase",function(){return r.CircleEase}),i.d(t,"BackEase",function(){return r.BackEase}),i.d(t,"BounceEase",function(){return r.BounceEase}),i.d(t,"CubicEase",function(){return r.CubicEase}),i.d(t,"ElasticEase",function(){return r.ElasticEase}),i.d(t,"ExponentialEase",function(){return r.ExponentialEase}),i.d(t,"PowerEase",function(){return r.PowerEase}),i.d(t,"QuadraticEase",function(){return r.QuadraticEase}),i.d(t,"QuarticEase",function(){return r.QuarticEase}),i.d(t,"QuinticEase",function(){return r.QuinticEase}),i.d(t,"SineEase",function(){return r.SineEase}),i.d(t,"BezierCurveEase",function(){return r.BezierCurveEase}),i.d(t,"RuntimeAnimation",function(){return r.RuntimeAnimation}),i.d(t,"AnimationEvent",function(){return r.AnimationEvent}),i.d(t,"AnimationKeyInterpolation",function(){return r.AnimationKeyInterpolation}),i.d(t,"AnimationRange",function(){return r.AnimationRange}),i.d(t,"Analyser",function(){return r.Analyser}),i.d(t,"AudioEngine",function(){return r.AudioEngine}),i.d(t,"AudioSceneComponent",function(){return r.AudioSceneComponent}),i.d(t,"Sound",function(){return r.Sound}),i.d(t,"SoundTrack",function(){return r.SoundTrack}),i.d(t,"WeightedSound",function(){return r.WeightedSound}),i.d(t,"Bone",function(){return r.Bone}),i.d(t,"BoneIKController",function(){return r.BoneIKController}),i.d(t,"BoneLookController",function(){return r.BoneLookController}),i.d(t,"Skeleton",function(){return r.Skeleton}),i.d(t,"CameraInputTypes",function(){return r.CameraInputTypes}),i.d(t,"CameraInputsManager",function(){return r.CameraInputsManager}),i.d(t,"Camera",function(){return r.Camera}),i.d(t,"TargetCamera",function(){return r.TargetCamera}),i.d(t,"FreeCamera",function(){return r.FreeCamera}),i.d(t,"FreeCameraInputsManager",function(){return r.FreeCameraInputsManager}),i.d(t,"TouchCamera",function(){return r.TouchCamera}),i.d(t,"ArcRotateCamera",function(){return r.ArcRotateCamera}),i.d(t,"ArcRotateCameraInputsManager",function(){return r.ArcRotateCameraInputsManager}),i.d(t,"DeviceOrientationCamera",function(){return r.DeviceOrientationCamera}),i.d(t,"FlyCamera",function(){return r.FlyCamera}),i.d(t,"FlyCameraInputsManager",function(){return r.FlyCameraInputsManager}),i.d(t,"FollowCamera",function(){return r.FollowCamera}),i.d(t,"ArcFollowCamera",function(){return r.ArcFollowCamera}),i.d(t,"GamepadCamera",function(){return r.GamepadCamera}),i.d(t,"UniversalCamera",function(){return r.UniversalCamera}),i.d(t,"VirtualJoysticksCamera",function(){return r.VirtualJoysticksCamera}),i.d(t,"Collider",function(){return r.Collider}),i.d(t,"DefaultCollisionCoordinator",function(){return r.DefaultCollisionCoordinator}),i.d(t,"PickingInfo",function(){return r.PickingInfo}),i.d(t,"IntersectionInfo",function(){return r.IntersectionInfo}),i.d(t,"BoundingBox",function(){return r.BoundingBox}),i.d(t,"BoundingInfo",function(){return r.BoundingInfo}),i.d(t,"BoundingSphere",function(){return r.BoundingSphere}),i.d(t,"Ray",function(){return r.Ray}),i.d(t,"AxesViewer",function(){return r.AxesViewer}),i.d(t,"BoneAxesViewer",function(){return r.BoneAxesViewer}),i.d(t,"DebugLayer",function(){return r.DebugLayer}),i.d(t,"PhysicsViewer",function(){return r.PhysicsViewer}),i.d(t,"RayHelper",function(){return r.RayHelper}),i.d(t,"SkeletonViewer",function(){return r.SkeletonViewer}),i.d(t,"Constants",function(){return r.Constants}),i.d(t,"InstancingAttributeInfo",function(){return r.InstancingAttributeInfo}),i.d(t,"DepthTextureCreationOptions",function(){return r.DepthTextureCreationOptions}),i.d(t,"EngineCapabilities",function(){return r.EngineCapabilities}),i.d(t,"Engine",function(){return r.Engine}),i.d(t,"EngineStore",function(){return r.EngineStore}),i.d(t,"NullEngineOptions",function(){return r.NullEngineOptions}),i.d(t,"NullEngine",function(){return r.NullEngine}),i.d(t,"KeyboardEventTypes",function(){return r.KeyboardEventTypes}),i.d(t,"KeyboardInfo",function(){return r.KeyboardInfo}),i.d(t,"KeyboardInfoPre",function(){return r.KeyboardInfoPre}),i.d(t,"PointerEventTypes",function(){return r.PointerEventTypes}),i.d(t,"PointerInfoBase",function(){return r.PointerInfoBase}),i.d(t,"PointerInfoPre",function(){return r.PointerInfoPre}),i.d(t,"PointerInfo",function(){return r.PointerInfo}),i.d(t,"ClipboardEventTypes",function(){return r.ClipboardEventTypes}),i.d(t,"ClipboardInfo",function(){return r.ClipboardInfo}),i.d(t,"DaydreamController",function(){return r.DaydreamController}),i.d(t,"GearVRController",function(){return r.GearVRController}),i.d(t,"GenericController",function(){return r.GenericController}),i.d(t,"OculusTouchController",function(){return r.OculusTouchController}),i.d(t,"PoseEnabledControllerType",function(){return r.PoseEnabledControllerType}),i.d(t,"PoseEnabledControllerHelper",function(){return r.PoseEnabledControllerHelper}),i.d(t,"PoseEnabledController",function(){return r.PoseEnabledController}),i.d(t,"ViveController",function(){return r.ViveController}),i.d(t,"WebVRController",function(){return r.WebVRController}),i.d(t,"WindowsMotionController",function(){return r.WindowsMotionController}),i.d(t,"StickValues",function(){return r.StickValues}),i.d(t,"Gamepad",function(){return r.Gamepad}),i.d(t,"GenericPad",function(){return r.GenericPad}),i.d(t,"GamepadManager",function(){return r.GamepadManager}),i.d(t,"GamepadSystemSceneComponent",function(){return r.GamepadSystemSceneComponent}),i.d(t,"Xbox360Button",function(){return r.Xbox360Button}),i.d(t,"Xbox360Dpad",function(){return r.Xbox360Dpad}),i.d(t,"Xbox360Pad",function(){return r.Xbox360Pad}),i.d(t,"AxisDragGizmo",function(){return r.AxisDragGizmo}),i.d(t,"AxisScaleGizmo",function(){return r.AxisScaleGizmo}),i.d(t,"BoundingBoxGizmo",function(){return r.BoundingBoxGizmo}),i.d(t,"Gizmo",function(){return r.Gizmo}),i.d(t,"GizmoManager",function(){return r.GizmoManager}),i.d(t,"PlaneRotationGizmo",function(){return r.PlaneRotationGizmo}),i.d(t,"PositionGizmo",function(){return r.PositionGizmo}),i.d(t,"RotationGizmo",function(){return r.RotationGizmo}),i.d(t,"ScaleGizmo",function(){return r.ScaleGizmo}),i.d(t,"EnvironmentHelper",function(){return r.EnvironmentHelper}),i.d(t,"PhotoDome",function(){return r.PhotoDome}),i.d(t,"_forceSceneHelpersToBundle",function(){return r._forceSceneHelpersToBundle}),i.d(t,"VideoDome",function(){return r.VideoDome}),i.d(t,"EngineInstrumentation",function(){return r.EngineInstrumentation}),i.d(t,"SceneInstrumentation",function(){return r.SceneInstrumentation}),i.d(t,"_TimeToken",function(){return r._TimeToken}),i.d(t,"EffectLayer",function(){return r.EffectLayer}),i.d(t,"EffectLayerSceneComponent",function(){return r.EffectLayerSceneComponent}),i.d(t,"GlowLayer",function(){return r.GlowLayer}),i.d(t,"HighlightLayer",function(){return r.HighlightLayer}),i.d(t,"Layer",function(){return r.Layer}),i.d(t,"LayerSceneComponent",function(){return r.LayerSceneComponent}),i.d(t,"LensFlare",function(){return r.LensFlare}),i.d(t,"LensFlareSystem",function(){return r.LensFlareSystem}),i.d(t,"LensFlareSystemSceneComponent",function(){return r.LensFlareSystemSceneComponent}),i.d(t,"Light",function(){return r.Light}),i.d(t,"ShadowLight",function(){return r.ShadowLight}),i.d(t,"DirectionalLight",function(){return r.DirectionalLight}),i.d(t,"HemisphericLight",function(){return r.HemisphericLight}),i.d(t,"PointLight",function(){return r.PointLight}),i.d(t,"SpotLight",function(){return r.SpotLight}),i.d(t,"DefaultLoadingScreen",function(){return r.DefaultLoadingScreen}),i.d(t,"SceneLoaderProgressEvent",function(){return r.SceneLoaderProgressEvent}),i.d(t,"SceneLoader",function(){return r.SceneLoader}),i.d(t,"SceneLoaderFlags",function(){return r.SceneLoaderFlags}),i.d(t,"ColorCurves",function(){return r.ColorCurves}),i.d(t,"EffectFallbacks",function(){return r.EffectFallbacks}),i.d(t,"EffectCreationOptions",function(){return r.EffectCreationOptions}),i.d(t,"Effect",function(){return r.Effect}),i.d(t,"FresnelParameters",function(){return r.FresnelParameters}),i.d(t,"ImageProcessingConfigurationDefines",function(){return r.ImageProcessingConfigurationDefines}),i.d(t,"ImageProcessingConfiguration",function(){return r.ImageProcessingConfiguration}),i.d(t,"Material",function(){return r.Material}),i.d(t,"MaterialDefines",function(){return r.MaterialDefines}),i.d(t,"MaterialHelper",function(){return r.MaterialHelper}),i.d(t,"MultiMaterial",function(){return r.MultiMaterial}),i.d(t,"PushMaterial",function(){return r.PushMaterial}),i.d(t,"ShaderMaterial",function(){return r.ShaderMaterial}),i.d(t,"StandardMaterialDefines",function(){return r.StandardMaterialDefines}),i.d(t,"StandardMaterial",function(){return r.StandardMaterial}),i.d(t,"BaseTexture",function(){return r.BaseTexture}),i.d(t,"CubeTexture",function(){return r.CubeTexture}),i.d(t,"HDRCubeTexture",function(){return r.HDRCubeTexture}),i.d(t,"InternalTexture",function(){return r.InternalTexture}),i.d(t,"DummyInternalTextureTracker",function(){return r.DummyInternalTextureTracker}),i.d(t,"MirrorTexture",function(){return r.MirrorTexture}),i.d(t,"MultiRenderTarget",function(){return r.MultiRenderTarget}),i.d(t,"RawTexture",function(){return r.RawTexture}),i.d(t,"RenderTargetTexture",function(){return r.RenderTargetTexture}),i.d(t,"Texture",function(){return r.Texture}),i.d(t,"UniformBuffer",function(){return r.UniformBuffer}),i.d(t,"MaterialFlags",function(){return r.MaterialFlags}),i.d(t,"Scalar",function(){return r.Scalar}),i.d(t,"ToGammaSpace",function(){return r.ToGammaSpace}),i.d(t,"ToLinearSpace",function(){return r.ToLinearSpace}),i.d(t,"Epsilon",function(){return r.Epsilon}),i.d(t,"Color3",function(){return r.Color3}),i.d(t,"Color4",function(){return r.Color4}),i.d(t,"Vector2",function(){return r.Vector2}),i.d(t,"Vector3",function(){return r.Vector3}),i.d(t,"Vector4",function(){return r.Vector4}),i.d(t,"Size",function(){return r.Size}),i.d(t,"Quaternion",function(){return r.Quaternion}),i.d(t,"Matrix",function(){return r.Matrix}),i.d(t,"Plane",function(){return r.Plane}),i.d(t,"Viewport",function(){return r.Viewport}),i.d(t,"Frustum",function(){return r.Frustum}),i.d(t,"Space",function(){return r.Space}),i.d(t,"Axis",function(){return r.Axis}),i.d(t,"BezierCurve",function(){return r.BezierCurve}),i.d(t,"Orientation",function(){return r.Orientation}),i.d(t,"Angle",function(){return r.Angle}),i.d(t,"Arc2",function(){return r.Arc2}),i.d(t,"Path2",function(){return r.Path2}),i.d(t,"Path3D",function(){return r.Path3D}),i.d(t,"Curve3",function(){return r.Curve3}),i.d(t,"PositionNormalVertex",function(){return r.PositionNormalVertex}),i.d(t,"PositionNormalTextureVertex",function(){return r.PositionNormalTextureVertex}),i.d(t,"Tmp",function(){return r.Tmp}),i.d(t,"SphericalPolynomial",function(){return r.SphericalPolynomial}),i.d(t,"SphericalHarmonics",function(){return r.SphericalHarmonics}),i.d(t,"AbstractMesh",function(){return r.AbstractMesh}),i.d(t,"Buffer",function(){return r.Buffer}),i.d(t,"VertexBuffer",function(){return r.VertexBuffer}),i.d(t,"CSG",function(){return r.CSG}),i.d(t,"Geometry",function(){return r.Geometry}),i.d(t,"GroundMesh",function(){return r.GroundMesh}),i.d(t,"InstancedMesh",function(){return r.InstancedMesh}),i.d(t,"LinesMesh",function(){return r.LinesMesh}),i.d(t,"InstancedLinesMesh",function(){return r.InstancedLinesMesh}),i.d(t,"MeshLODLevel",function(){return r.MeshLODLevel}),i.d(t,"_CreationDataStorage",function(){return r._CreationDataStorage}),i.d(t,"_InstancesBatch",function(){return r._InstancesBatch}),i.d(t,"Mesh",function(){return r.Mesh}),i.d(t,"VertexData",function(){return r.VertexData}),i.d(t,"MeshBuilder",function(){return r.MeshBuilder}),i.d(t,"SimplificationSettings",function(){return r.SimplificationSettings}),i.d(t,"SimplificationQueue",function(){return r.SimplificationQueue}),i.d(t,"SimplificationType",function(){return r.SimplificationType}),i.d(t,"SimplicationQueueSceneComponent",function(){return r.SimplicationQueueSceneComponent}),i.d(t,"Polygon",function(){return r.Polygon}),i.d(t,"PolygonMeshBuilder",function(){return r.PolygonMeshBuilder}),i.d(t,"BaseSubMesh",function(){return r.BaseSubMesh}),i.d(t,"SubMesh",function(){return r.SubMesh}),i.d(t,"TransformNode",function(){return r.TransformNode}),i.d(t,"BoxBuilder",function(){return r.BoxBuilder}),i.d(t,"DiscBuilder",function(){return r.DiscBuilder}),i.d(t,"SphereBuilder",function(){return r.SphereBuilder}),i.d(t,"CylinderBuilder",function(){return r.CylinderBuilder}),i.d(t,"LinesBuilder",function(){return r.LinesBuilder}),i.d(t,"PlaneBuilder",function(){return r.PlaneBuilder}),i.d(t,"MorphTarget",function(){return r.MorphTarget}),i.d(t,"MorphTargetManager",function(){return r.MorphTargetManager}),i.d(t,"Database",function(){return r.Database}),i.d(t,"BaseParticleSystem",function(){return r.BaseParticleSystem}),i.d(t,"GPUParticleSystem",function(){return r.GPUParticleSystem}),i.d(t,"Particle",function(){return r.Particle}),i.d(t,"ParticleHelper",function(){return r.ParticleHelper}),i.d(t,"ParticleSystem",function(){return r.ParticleSystem}),i.d(t,"_IDoNeedToBeInTheBuild",function(){return r._IDoNeedToBeInTheBuild}),i.d(t,"ParticleSystemSet",function(){return r.ParticleSystemSet}),i.d(t,"SolidParticle",function(){return r.SolidParticle}),i.d(t,"ModelShape",function(){return r.ModelShape}),i.d(t,"DepthSortedParticle",function(){return r.DepthSortedParticle}),i.d(t,"SolidParticleSystem",function(){return r.SolidParticleSystem}),i.d(t,"SubEmitterType",function(){return r.SubEmitterType}),i.d(t,"SubEmitter",function(){return r.SubEmitter}),i.d(t,"PhysicsEngine",function(){return r.PhysicsEngine}),i.d(t,"PhysicsEngineSceneComponent",function(){return r.PhysicsEngineSceneComponent}),i.d(t,"PhysicsHelper",function(){return r.PhysicsHelper}),i.d(t,"PhysicsRadialExplosionEvent",function(){return r.PhysicsRadialExplosionEvent}),i.d(t,"PhysicsGravitationalFieldEvent",function(){return r.PhysicsGravitationalFieldEvent}),i.d(t,"PhysicsUpdraftEvent",function(){return r.PhysicsUpdraftEvent}),i.d(t,"PhysicsVortexEvent",function(){return r.PhysicsVortexEvent}),i.d(t,"PhysicsRadialImpulseFalloff",function(){return r.PhysicsRadialImpulseFalloff}),i.d(t,"PhysicsUpdraftMode",function(){return r.PhysicsUpdraftMode}),i.d(t,"PhysicsImpostor",function(){return r.PhysicsImpostor}),i.d(t,"PhysicsJoint",function(){return r.PhysicsJoint}),i.d(t,"DistanceJoint",function(){return r.DistanceJoint}),i.d(t,"MotorEnabledJoint",function(){return r.MotorEnabledJoint}),i.d(t,"HingeJoint",function(){return r.HingeJoint}),i.d(t,"Hinge2Joint",function(){return r.Hinge2Joint}),i.d(t,"AnaglyphPostProcess",function(){return r.AnaglyphPostProcess}),i.d(t,"BlackAndWhitePostProcess",function(){return r.BlackAndWhitePostProcess}),i.d(t,"BloomEffect",function(){return r.BloomEffect}),i.d(t,"BloomMergePostProcess",function(){return r.BloomMergePostProcess}),i.d(t,"BlurPostProcess",function(){return r.BlurPostProcess}),i.d(t,"ChromaticAberrationPostProcess",function(){return r.ChromaticAberrationPostProcess}),i.d(t,"CircleOfConfusionPostProcess",function(){return r.CircleOfConfusionPostProcess}),i.d(t,"ColorCorrectionPostProcess",function(){return r.ColorCorrectionPostProcess}),i.d(t,"ConvolutionPostProcess",function(){return r.ConvolutionPostProcess}),i.d(t,"DepthOfFieldBlurPostProcess",function(){return r.DepthOfFieldBlurPostProcess}),i.d(t,"DepthOfFieldEffectBlurLevel",function(){return r.DepthOfFieldEffectBlurLevel}),i.d(t,"DepthOfFieldEffect",function(){return r.DepthOfFieldEffect}),i.d(t,"DepthOfFieldMergePostProcessOptions",function(){return r.DepthOfFieldMergePostProcessOptions}),i.d(t,"DepthOfFieldMergePostProcess",function(){return r.DepthOfFieldMergePostProcess}),i.d(t,"DisplayPassPostProcess",function(){return r.DisplayPassPostProcess}),i.d(t,"ExtractHighlightsPostProcess",function(){return r.ExtractHighlightsPostProcess}),i.d(t,"FilterPostProcess",function(){return r.FilterPostProcess}),i.d(t,"FxaaPostProcess",function(){return r.FxaaPostProcess}),i.d(t,"GrainPostProcess",function(){return r.GrainPostProcess}),i.d(t,"HighlightsPostProcess",function(){return r.HighlightsPostProcess}),i.d(t,"ImageProcessingPostProcess",function(){return r.ImageProcessingPostProcess}),i.d(t,"MotionBlurPostProcess",function(){return r.MotionBlurPostProcess}),i.d(t,"PassPostProcess",function(){return r.PassPostProcess}),i.d(t,"PassCubePostProcess",function(){return r.PassCubePostProcess}),i.d(t,"PostProcess",function(){return r.PostProcess}),i.d(t,"PostProcessManager",function(){return r.PostProcessManager}),i.d(t,"RefractionPostProcess",function(){return r.RefractionPostProcess}),i.d(t,"SharpenPostProcess",function(){return r.SharpenPostProcess}),i.d(t,"StereoscopicInterlacePostProcess",function(){return r.StereoscopicInterlacePostProcess}),i.d(t,"TonemappingOperator",function(){return r.TonemappingOperator}),i.d(t,"TonemapPostProcess",function(){return r.TonemapPostProcess}),i.d(t,"VolumetricLightScatteringPostProcess",function(){return r.VolumetricLightScatteringPostProcess}),i.d(t,"VRDistortionCorrectionPostProcess",function(){return r.VRDistortionCorrectionPostProcess}),i.d(t,"ReflectionProbe",function(){return r.ReflectionProbe}),i.d(t,"BoundingBoxRenderer",function(){return r.BoundingBoxRenderer}),i.d(t,"DepthRenderer",function(){return r.DepthRenderer}),i.d(t,"DepthRendererSceneComponent",function(){return r.DepthRendererSceneComponent}),i.d(t,"EdgesRenderer",function(){return r.EdgesRenderer}),i.d(t,"LineEdgesRenderer",function(){return r.LineEdgesRenderer}),i.d(t,"GeometryBufferRenderer",function(){return r.GeometryBufferRenderer}),i.d(t,"GeometryBufferRendererSceneComponent",function(){return r.GeometryBufferRendererSceneComponent}),i.d(t,"OutlineRenderer",function(){return r.OutlineRenderer}),i.d(t,"RenderingGroup",function(){return r.RenderingGroup}),i.d(t,"RenderingGroupInfo",function(){return r.RenderingGroupInfo}),i.d(t,"RenderingManager",function(){return r.RenderingManager}),i.d(t,"UtilityLayerRenderer",function(){return r.UtilityLayerRenderer}),i.d(t,"Sprite",function(){return r.Sprite}),i.d(t,"SpriteManager",function(){return r.SpriteManager}),i.d(t,"SpriteSceneComponent",function(){return r.SpriteSceneComponent}),i.d(t,"_AlphaState",function(){return r._AlphaState}),i.d(t,"_DepthCullingState",function(){return r._DepthCullingState}),i.d(t,"_StencilState",function(){return r._StencilState}),i.d(t,"AndOrNotEvaluator",function(){return r.AndOrNotEvaluator}),i.d(t,"AssetTaskState",function(){return r.AssetTaskState}),i.d(t,"AbstractAssetTask",function(){return r.AbstractAssetTask}),i.d(t,"AssetsProgressEvent",function(){return r.AssetsProgressEvent}),i.d(t,"MeshAssetTask",function(){return r.MeshAssetTask}),i.d(t,"TextFileAssetTask",function(){return r.TextFileAssetTask}),i.d(t,"BinaryFileAssetTask",function(){return r.BinaryFileAssetTask}),i.d(t,"ImageAssetTask",function(){return r.ImageAssetTask}),i.d(t,"TextureAssetTask",function(){return r.TextureAssetTask}),i.d(t,"CubeTextureAssetTask",function(){return r.CubeTextureAssetTask}),i.d(t,"HDRCubeTextureAssetTask",function(){return r.HDRCubeTextureAssetTask}),i.d(t,"AssetsManager",function(){return r.AssetsManager}),i.d(t,"DDSTools",function(){return r.DDSTools}),i.d(t,"expandToProperty",function(){return r.expandToProperty}),i.d(t,"serialize",function(){return r.serialize}),i.d(t,"serializeAsTexture",function(){return r.serializeAsTexture}),i.d(t,"serializeAsColor3",function(){return r.serializeAsColor3}),i.d(t,"serializeAsFresnelParameters",function(){return r.serializeAsFresnelParameters}),i.d(t,"serializeAsVector2",function(){return r.serializeAsVector2}),i.d(t,"serializeAsVector3",function(){return r.serializeAsVector3}),i.d(t,"serializeAsMeshReference",function(){return r.serializeAsMeshReference}),i.d(t,"serializeAsColorCurves",function(){return r.serializeAsColorCurves}),i.d(t,"serializeAsColor4",function(){return r.serializeAsColor4}),i.d(t,"serializeAsImageProcessingConfiguration",function(){return r.serializeAsImageProcessingConfiguration}),i.d(t,"serializeAsQuaternion",function(){return r.serializeAsQuaternion}),i.d(t,"serializeAsCameraReference",function(){return r.serializeAsCameraReference}),i.d(t,"SerializationHelper",function(){return r.SerializationHelper}),i.d(t,"Deferred",function(){return r.Deferred}),i.d(t,"EnvironmentTextureTools",function(){return r.EnvironmentTextureTools}),i.d(t,"FilesInput",function(){return r.FilesInput}),i.d(t,"KhronosTextureContainer",function(){return r.KhronosTextureContainer}),i.d(t,"EventState",function(){return r.EventState}),i.d(t,"Observer",function(){return r.Observer}),i.d(t,"MultiObserver",function(){return r.MultiObserver}),i.d(t,"Observable",function(){return r.Observable}),i.d(t,"PerformanceMonitor",function(){return r.PerformanceMonitor}),i.d(t,"RollingAverage",function(){return r.RollingAverage}),i.d(t,"PromisePolyfill",function(){return r.PromisePolyfill}),i.d(t,"SceneOptimization",function(){return r.SceneOptimization}),i.d(t,"TextureOptimization",function(){return r.TextureOptimization}),i.d(t,"HardwareScalingOptimization",function(){return r.HardwareScalingOptimization}),i.d(t,"ShadowsOptimization",function(){return r.ShadowsOptimization}),i.d(t,"PostProcessesOptimization",function(){return r.PostProcessesOptimization}),i.d(t,"LensFlaresOptimization",function(){return r.LensFlaresOptimization}),i.d(t,"CustomOptimization",function(){return r.CustomOptimization}),i.d(t,"ParticlesOptimization",function(){return r.ParticlesOptimization}),i.d(t,"RenderTargetsOptimization",function(){return r.RenderTargetsOptimization}),i.d(t,"MergeMeshesOptimization",function(){return r.MergeMeshesOptimization}),i.d(t,"SceneOptimizerOptions",function(){return r.SceneOptimizerOptions}),i.d(t,"SceneOptimizer",function(){return r.SceneOptimizer}),i.d(t,"SceneSerializer",function(){return r.SceneSerializer}),i.d(t,"SmartArray",function(){return r.SmartArray}),i.d(t,"SmartArrayNoDuplicate",function(){return r.SmartArrayNoDuplicate}),i.d(t,"StringDictionary",function(){return r.StringDictionary}),i.d(t,"Tags",function(){return r.Tags}),i.d(t,"TextureTools",function(){return r.TextureTools}),i.d(t,"TGATools",function(){return r.TGATools}),i.d(t,"ColorGradient",function(){return r.ColorGradient}),i.d(t,"Color3Gradient",function(){return r.Color3Gradient}),i.d(t,"FactorGradient",function(){return r.FactorGradient}),i.d(t,"LoadFileError",function(){return r.LoadFileError}),i.d(t,"RetryStrategy",function(){return r.RetryStrategy}),i.d(t,"Tools",function(){return r.Tools}),i.d(t,"PerfCounter",function(){return r.PerfCounter}),i.d(t,"className",function(){return r.className}),i.d(t,"AsyncLoop",function(){return r.AsyncLoop}),i.d(t,"VideoRecorder",function(){return r.VideoRecorder}),i.d(t,"JoystickAxis",function(){return r.JoystickAxis}),i.d(t,"VirtualJoystick",function(){return r.VirtualJoystick}),i.d(t,"WorkerPool",function(){return r.WorkerPool}),i.d(t,"Logger",function(){return r.Logger}),i.d(t,"_TypeStore",function(){return r._TypeStore}),i.d(t,"FilesInputStore",function(){return r.FilesInputStore}),i.d(t,"DeepCopier",function(){return r.DeepCopier}),i.d(t,"PivotTools",function(){return r.PivotTools}),i.d(t,"PrecisionDate",function(){return r.PrecisionDate}),i.d(t,"ScreenshotTools",function(){return r.ScreenshotTools}),i.d(t,"AutoRotationBehavior",function(){return r.AutoRotationBehavior}),i.d(t,"BouncingBehavior",function(){return r.BouncingBehavior}),i.d(t,"FramingBehavior",function(){return r.FramingBehavior}),i.d(t,"AttachToBoxBehavior",function(){return r.AttachToBoxBehavior}),i.d(t,"FadeInOutBehavior",function(){return r.FadeInOutBehavior}),i.d(t,"MultiPointerScaleBehavior",function(){return r.MultiPointerScaleBehavior}),i.d(t,"PointerDragBehavior",function(){return r.PointerDragBehavior}),i.d(t,"SixDofDragBehavior",function(){return r.SixDofDragBehavior}),i.d(t,"ArcRotateCameraGamepadInput",function(){return r.ArcRotateCameraGamepadInput}),i.d(t,"ArcRotateCameraKeyboardMoveInput",function(){return r.ArcRotateCameraKeyboardMoveInput}),i.d(t,"ArcRotateCameraMouseWheelInput",function(){return r.ArcRotateCameraMouseWheelInput}),i.d(t,"ArcRotateCameraPointersInput",function(){return r.ArcRotateCameraPointersInput}),i.d(t,"ArcRotateCameraVRDeviceOrientationInput",function(){return r.ArcRotateCameraVRDeviceOrientationInput}),i.d(t,"FlyCameraKeyboardInput",function(){return r.FlyCameraKeyboardInput}),i.d(t,"FlyCameraMouseInput",function(){return r.FlyCameraMouseInput}),i.d(t,"FreeCameraDeviceOrientationInput",function(){return r.FreeCameraDeviceOrientationInput}),i.d(t,"FreeCameraGamepadInput",function(){return r.FreeCameraGamepadInput}),i.d(t,"FreeCameraKeyboardMoveInput",function(){return r.FreeCameraKeyboardMoveInput}),i.d(t,"FreeCameraMouseInput",function(){return r.FreeCameraMouseInput}),i.d(t,"FreeCameraTouchInput",function(){return r.FreeCameraTouchInput}),i.d(t,"FreeCameraVirtualJoystickInput",function(){return r.FreeCameraVirtualJoystickInput}),i.d(t,"AnaglyphArcRotateCamera",function(){return r.AnaglyphArcRotateCamera}),i.d(t,"AnaglyphFreeCamera",function(){return r.AnaglyphFreeCamera}),i.d(t,"AnaglyphGamepadCamera",function(){return r.AnaglyphGamepadCamera}),i.d(t,"AnaglyphUniversalCamera",function(){return r.AnaglyphUniversalCamera}),i.d(t,"StereoscopicArcRotateCamera",function(){return r.StereoscopicArcRotateCamera}),i.d(t,"StereoscopicFreeCamera",function(){return r.StereoscopicFreeCamera}),i.d(t,"StereoscopicGamepadCamera",function(){return r.StereoscopicGamepadCamera}),i.d(t,"StereoscopicUniversalCamera",function(){return r.StereoscopicUniversalCamera}),i.d(t,"VRCameraMetrics",function(){return r.VRCameraMetrics}),i.d(t,"VRDeviceOrientationArcRotateCamera",function(){return r.VRDeviceOrientationArcRotateCamera}),i.d(t,"VRDeviceOrientationFreeCamera",function(){return r.VRDeviceOrientationFreeCamera}),i.d(t,"VRDeviceOrientationGamepadCamera",function(){return r.VRDeviceOrientationGamepadCamera}),i.d(t,"VRExperienceHelper",function(){return r.VRExperienceHelper}),i.d(t,"WebVRFreeCamera",function(){return r.WebVRFreeCamera}),i.d(t,"WebXRCamera",function(){return r.WebXRCamera}),i.d(t,"WebXREnterExitUIButton",function(){return r.WebXREnterExitUIButton}),i.d(t,"WebXREnterExitUIOptions",function(){return r.WebXREnterExitUIOptions}),i.d(t,"WebXREnterExitUI",function(){return r.WebXREnterExitUI}),i.d(t,"WebXRState",function(){return r.WebXRState}),i.d(t,"WebXRExperienceHelper",function(){return r.WebXRExperienceHelper}),i.d(t,"WebXRController",function(){return r.WebXRController}),i.d(t,"WebXRInput",function(){return r.WebXRInput}),i.d(t,"WebXRManagedOutputCanvas",function(){return r.WebXRManagedOutputCanvas}),i.d(t,"WebXRSessionManager",function(){return r.WebXRSessionManager}),i.d(t,"Octree",function(){return r.Octree}),i.d(t,"OctreeBlock",function(){return r.OctreeBlock}),i.d(t,"OctreeSceneComponent",function(){return r.OctreeSceneComponent}),i.d(t,"_OcclusionDataStorage",function(){return r._OcclusionDataStorage}),i.d(t,"_forceTransformFeedbackToBundle",function(){return r._forceTransformFeedbackToBundle}),i.d(t,"ShadowGenerator",function(){return r.ShadowGenerator}),i.d(t,"ShadowGeneratorSceneComponent",function(){return r.ShadowGeneratorSceneComponent}),i.d(t,"_BabylonLoaderRegistered",function(){return r._BabylonLoaderRegistered}),i.d(t,"BackgroundMaterial",function(){return r.BackgroundMaterial}),i.d(t,"PBRBaseMaterial",function(){return r.PBRBaseMaterial}),i.d(t,"PBRBaseSimpleMaterial",function(){return r.PBRBaseSimpleMaterial}),i.d(t,"PBRMaterial",function(){return r.PBRMaterial}),i.d(t,"PBRMetallicRoughnessMaterial",function(){return r.PBRMetallicRoughnessMaterial}),i.d(t,"PBRSpecularGlossinessMaterial",function(){return r.PBRSpecularGlossinessMaterial}),i.d(t,"ColorGradingTexture",function(){return r.ColorGradingTexture}),i.d(t,"DynamicTexture",function(){return r.DynamicTexture}),i.d(t,"ProceduralTexture",function(){return r.ProceduralTexture}),i.d(t,"RawCubeTexture",function(){return r.RawCubeTexture}),i.d(t,"RawTexture3D",function(){return r.RawTexture3D}),i.d(t,"RefractionTexture",function(){return r.RefractionTexture}),i.d(t,"VideoTexture",function(){return r.VideoTexture}),i.d(t,"DracoCompression",function(){return r.DracoCompression}),i.d(t,"RibbonBuilder",function(){return r.RibbonBuilder}),i.d(t,"TorusBuilder",function(){return r.TorusBuilder}),i.d(t,"TorusKnotBuilder",function(){return r.TorusKnotBuilder}),i.d(t,"PolygonBuilder",function(){return r.PolygonBuilder}),i.d(t,"ShapeBuilder",function(){return r.ShapeBuilder}),i.d(t,"LatheBuilder",function(){return r.LatheBuilder}),i.d(t,"GroundBuilder",function(){return r.GroundBuilder}),i.d(t,"TubeBuilder",function(){return r.TubeBuilder}),i.d(t,"PolyhedronBuilder",function(){return r.PolyhedronBuilder}),i.d(t,"IcoSphereBuilder",function(){return r.IcoSphereBuilder}),i.d(t,"DecalBuilder",function(){return r.DecalBuilder}),i.d(t,"BoxParticleEmitter",function(){return r.BoxParticleEmitter}),i.d(t,"ConeParticleEmitter",function(){return r.ConeParticleEmitter}),i.d(t,"CylinderParticleEmitter",function(){return r.CylinderParticleEmitter}),i.d(t,"CylinderDirectedParticleEmitter",function(){return r.CylinderDirectedParticleEmitter}),i.d(t,"HemisphericParticleEmitter",function(){return r.HemisphericParticleEmitter}),i.d(t,"PointParticleEmitter",function(){return r.PointParticleEmitter}),i.d(t,"SphereParticleEmitter",function(){return r.SphereParticleEmitter}),i.d(t,"SphereDirectedParticleEmitter",function(){return r.SphereDirectedParticleEmitter}),i.d(t,"CannonJSPlugin",function(){return r.CannonJSPlugin}),i.d(t,"AmmoJSPlugin",function(){return r.AmmoJSPlugin}),i.d(t,"OimoJSPlugin",function(){return r.OimoJSPlugin}),i.d(t,"PostProcessRenderEffect",function(){return r.PostProcessRenderEffect}),i.d(t,"PostProcessRenderPipeline",function(){return r.PostProcessRenderPipeline}),i.d(t,"PostProcessRenderPipelineManager",function(){return r.PostProcessRenderPipelineManager}),i.d(t,"PostProcessRenderPipelineManagerSceneComponent",function(){return r.PostProcessRenderPipelineManagerSceneComponent}),i.d(t,"CubeMapToSphericalPolynomialTools",function(){return r.CubeMapToSphericalPolynomialTools}),i.d(t,"HDRTools",function(){return r.HDRTools}),i.d(t,"PanoramaToCubeMapTools",function(){return r.PanoramaToCubeMapTools}),i.d(t,"_DDSTextureLoader",function(){return r._DDSTextureLoader}),i.d(t,"_ENVTextureLoader",function(){return r._ENVTextureLoader}),i.d(t,"_KTXTextureLoader",function(){return r._KTXTextureLoader}),i.d(t,"_TGATextureLoader",function(){return r._TGATextureLoader}),i.d(t,"CustomProceduralTexture",function(){return r.CustomProceduralTexture}),i.d(t,"NoiseProceduralTexture",function(){return r.NoiseProceduralTexture}),i.d(t,"ProceduralTextureSceneComponent",function(){return r.ProceduralTextureSceneComponent}),i.d(t,"DefaultRenderingPipeline",function(){return r.DefaultRenderingPipeline}),i.d(t,"LensRenderingPipeline",function(){return r.LensRenderingPipeline}),i.d(t,"SSAO2RenderingPipeline",function(){return r.SSAO2RenderingPipeline}),i.d(t,"SSAORenderingPipeline",function(){return r.SSAORenderingPipeline}),i.d(t,"StandardRenderingPipeline",function(){return r.StandardRenderingPipeline});var o=void 0!==e?e:"undefined"!=typeof window?window:void 0;if(void 0!==o){o.BABYLON=s,o.BABYLON=o.BABYLON||{};var s=o.BABYLON;s.Debug=s.Debug||{};var a=[];for(var c in n)s.Debug[c]=n[c],a.push(c);for(var c in r)a.indexOf(c)>-1||(s[c]=r[c])}}.call(this,i(120))},function(e,t){var i;i=function(){return this}();try{i=i||new Function("return this")()}catch(e){"object"==typeof window&&(i=window)}e.exports=i}])});